LibGUI: Remove parent parameter to GUI::Widget constructor
This commit is contained in:
parent
4ce28c32d1
commit
c5d913970a
Notes:
sideshowbarker
2024-07-19 09:08:33 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/c5d913970ab
114 changed files with 207 additions and 313 deletions
|
@ -35,8 +35,7 @@
|
|||
#include <LibHTML/DOMTreeModel.h>
|
||||
#include <LibHTML/StylePropertiesModel.h>
|
||||
|
||||
InspectorWidget::InspectorWidget(GUI::Widget* parent)
|
||||
: GUI::Widget(parent)
|
||||
InspectorWidget::InspectorWidget()
|
||||
{
|
||||
set_layout(make<GUI::VerticalBoxLayout>());
|
||||
auto splitter = add<GUI::VerticalSplitter>();
|
||||
|
|
|
@ -36,7 +36,7 @@ public:
|
|||
void set_document(Document*);
|
||||
|
||||
private:
|
||||
explicit InspectorWidget(GUI::Widget* parent);
|
||||
InspectorWidget();
|
||||
|
||||
RefPtr<GUI::TreeView> m_dom_tree_view;
|
||||
RefPtr<GUI::TableView> m_style_table_view;
|
||||
|
|
|
@ -200,7 +200,7 @@ int main(int argc, char** argv)
|
|||
dom_inspector_window = GUI::Window::construct();
|
||||
dom_inspector_window->set_rect(100, 100, 300, 500);
|
||||
dom_inspector_window->set_title("DOM inspector");
|
||||
auto dom_inspector_widget = InspectorWidget::construct(nullptr);
|
||||
auto dom_inspector_widget = InspectorWidget::construct();
|
||||
dom_inspector_window->set_main_widget(dom_inspector_widget);
|
||||
}
|
||||
auto* inspector_widget = static_cast<InspectorWidget*>(dom_inspector_window->main_widget());
|
||||
|
|
|
@ -39,9 +39,8 @@
|
|||
#include <LibGfx/Font.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
FontEditorWidget::FontEditorWidget(const String& path, RefPtr<Gfx::Font>&& edited_font, GUI::Widget* parent)
|
||||
: GUI::Widget(parent)
|
||||
, m_edited_font(move(edited_font))
|
||||
FontEditorWidget::FontEditorWidget(const String& path, RefPtr<Gfx::Font>&& edited_font)
|
||||
: m_edited_font(move(edited_font))
|
||||
{
|
||||
set_fill_with_background_color(true);
|
||||
|
||||
|
|
|
@ -40,7 +40,7 @@ public:
|
|||
virtual ~FontEditorWidget() override;
|
||||
|
||||
private:
|
||||
FontEditorWidget(const String& path, RefPtr<Gfx::Font>&&, GUI::Widget* parent = nullptr);
|
||||
FontEditorWidget(const String& path, RefPtr<Gfx::Font>&&);
|
||||
RefPtr<Gfx::Font> m_edited_font;
|
||||
|
||||
GlyphMapWidget* m_glyph_map_widget { nullptr };
|
||||
|
|
|
@ -41,8 +41,7 @@
|
|||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
|
||||
HexEditor::HexEditor(GUI::Widget* parent)
|
||||
: ScrollableWidget(parent)
|
||||
HexEditor::HexEditor()
|
||||
{
|
||||
set_scrollbars_enabled(true);
|
||||
set_font(GFontDatabase::the().get_by_name("Csilla Thin"));
|
||||
|
|
|
@ -67,7 +67,7 @@ public:
|
|||
Function<void()> on_change;
|
||||
|
||||
protected:
|
||||
HexEditor(GUI::Widget* parent);
|
||||
HexEditor();
|
||||
|
||||
virtual void paint_event(GUI::PaintEvent&) override;
|
||||
virtual void mousedown_event(GUI::MouseEvent&) override;
|
||||
|
|
|
@ -49,7 +49,7 @@ HexEditorWidget::HexEditorWidget()
|
|||
set_layout(make<GUI::VerticalBoxLayout>());
|
||||
layout()->set_spacing(0);
|
||||
|
||||
m_editor = HexEditor::construct(this);
|
||||
m_editor = add<HexEditor>();
|
||||
|
||||
m_editor->on_status_change = [this](int position, HexEditor::EditMode edit_mode, int selection_start, int selection_end) {
|
||||
m_statusbar->set_text(0, String::format("Offset: %8X", position));
|
||||
|
@ -66,7 +66,7 @@ HexEditorWidget::HexEditorWidget()
|
|||
update_title();
|
||||
};
|
||||
|
||||
m_statusbar = GUI::StatusBar::construct(5, this);
|
||||
m_statusbar = add<GUI::StatusBar>(5);
|
||||
|
||||
m_new_action = GUI::Action::create("New", { Mod_Ctrl, Key_N }, Gfx::Bitmap::load_from_file("/res/icons/16x16/new.png"), [this](const GUI::Action&) {
|
||||
if (m_document_dirty) {
|
||||
|
|
|
@ -78,7 +78,7 @@ void IRCAppWindow::update_title()
|
|||
void IRCAppWindow::setup_client()
|
||||
{
|
||||
m_client->aid_create_window = [this](void* owner, IRCWindow::Type type, const String& name) {
|
||||
return &create_window(owner, type, name);
|
||||
return create_window(owner, type, name);
|
||||
};
|
||||
m_client->aid_get_active_window = [this] {
|
||||
return static_cast<IRCWindow*>(m_container->active_widget());
|
||||
|
@ -237,7 +237,7 @@ void IRCAppWindow::update_part_action()
|
|||
m_part_action->set_enabled(is_open_channel);
|
||||
}
|
||||
|
||||
IRCWindow& IRCAppWindow::create_window(void* owner, IRCWindow::Type type, const String& name)
|
||||
NonnullRefPtr<IRCWindow> IRCAppWindow::create_window(void* owner, IRCWindow::Type type, const String& name)
|
||||
{
|
||||
return *new IRCWindow(m_client, owner, type, name, m_container);
|
||||
return m_container->add<IRCWindow>(m_client, owner, type, name);
|
||||
}
|
||||
|
|
|
@ -50,7 +50,7 @@ private:
|
|||
void update_title();
|
||||
void update_part_action();
|
||||
|
||||
IRCWindow& create_window(void* owner, IRCWindow::Type, const String& name);
|
||||
NonnullRefPtr<IRCWindow> create_window(void* owner, IRCWindow::Type, const String& name);
|
||||
NonnullRefPtr<IRCClient> m_client;
|
||||
RefPtr<GUI::StackWidget> m_container;
|
||||
RefPtr<GUI::TableView> m_window_list;
|
||||
|
|
|
@ -70,7 +70,7 @@ public:
|
|||
Function<void(const String&)> on_nickname_changed;
|
||||
Function<void(IRCChannel&)> on_part_from_channel;
|
||||
|
||||
Function<IRCWindow*(void*, IRCWindow::Type, const String&)> aid_create_window;
|
||||
Function<NonnullRefPtr<IRCWindow>(void*, IRCWindow::Type, const String&)> aid_create_window;
|
||||
Function<IRCWindow*()> aid_get_active_window;
|
||||
Function<void()> aid_update_window_list;
|
||||
|
||||
|
|
|
@ -59,7 +59,7 @@ private:
|
|||
|
||||
IRCClient& m_client;
|
||||
String m_name;
|
||||
IRCWindow* m_window { nullptr };
|
||||
RefPtr<IRCWindow> m_window;
|
||||
|
||||
NonnullRefPtr<IRCLogBuffer> m_log;
|
||||
};
|
||||
|
|
|
@ -35,9 +35,8 @@
|
|||
#include <LibGUI/TextEditor.h>
|
||||
#include <LibHTML/HtmlView.h>
|
||||
|
||||
IRCWindow::IRCWindow(IRCClient& client, void* owner, Type type, const String& name, GUI::Widget* parent)
|
||||
: GUI::Widget(parent)
|
||||
, m_client(client)
|
||||
IRCWindow::IRCWindow(IRCClient& client, void* owner, Type type, const String& name)
|
||||
: m_client(client)
|
||||
, m_owner(owner)
|
||||
, m_type(type)
|
||||
, m_name(name)
|
||||
|
|
|
@ -43,7 +43,6 @@ public:
|
|||
Query,
|
||||
};
|
||||
|
||||
IRCWindow(IRCClient&, void* owner, Type, const String& name, GUI::Widget* parent);
|
||||
virtual ~IRCWindow() override;
|
||||
|
||||
String name() const { return m_name; }
|
||||
|
@ -67,6 +66,8 @@ public:
|
|||
const IRCQuery& query() const { return *(const IRCQuery*)m_owner; }
|
||||
|
||||
private:
|
||||
IRCWindow(IRCClient&, void* owner, Type, const String& name);
|
||||
|
||||
IRCClient& m_client;
|
||||
void* m_owner { nullptr };
|
||||
Type m_type;
|
||||
|
|
|
@ -32,8 +32,7 @@
|
|||
#include <LibGUI/Window.h>
|
||||
#include <LibGfx/Bitmap.h>
|
||||
|
||||
QSWidget::QSWidget(GUI::Widget* parent)
|
||||
: GUI::Frame(parent)
|
||||
QSWidget::QSWidget()
|
||||
{
|
||||
set_fill_with_background_color(true);
|
||||
set_background_color(Color::Black);
|
||||
|
|
|
@ -44,7 +44,7 @@ public:
|
|||
Function<void(int)> on_scale_change;
|
||||
|
||||
private:
|
||||
explicit QSWidget(GUI::Widget* parent = nullptr);
|
||||
QSWidget();
|
||||
virtual void paint_event(GUI::PaintEvent&) override;
|
||||
virtual void resize_event(GUI::ResizeEvent&) override;
|
||||
virtual void mousedown_event(GUI::MouseEvent&) override;
|
||||
|
|
|
@ -30,8 +30,7 @@
|
|||
#include <LibGUI/JsonArrayModel.h>
|
||||
#include <LibGUI/TableView.h>
|
||||
|
||||
NetworkStatisticsWidget::NetworkStatisticsWidget(GUI::Widget* parent)
|
||||
: GUI::LazyWidget(parent)
|
||||
NetworkStatisticsWidget::NetworkStatisticsWidget()
|
||||
{
|
||||
on_first_show = [this](auto&) {
|
||||
set_layout(make<GUI::VerticalBoxLayout>());
|
||||
|
|
|
@ -35,7 +35,7 @@ public:
|
|||
virtual ~NetworkStatisticsWidget() override;
|
||||
|
||||
private:
|
||||
explicit NetworkStatisticsWidget(GUI::Widget* parent = nullptr);
|
||||
NetworkStatisticsWidget();
|
||||
void update_models();
|
||||
|
||||
RefPtr<GUI::TableView> m_adapter_table_view;
|
||||
|
|
|
@ -29,12 +29,11 @@
|
|||
#include <LibGUI/JsonArrayModel.h>
|
||||
#include <LibGUI/TableView.h>
|
||||
|
||||
ProcessFileDescriptorMapWidget::ProcessFileDescriptorMapWidget(GUI::Widget* parent)
|
||||
: GUI::Widget(parent)
|
||||
ProcessFileDescriptorMapWidget::ProcessFileDescriptorMapWidget()
|
||||
{
|
||||
set_layout(make<GUI::VerticalBoxLayout>());
|
||||
layout()->set_margins({ 4, 4, 4, 4 });
|
||||
m_table_view = GUI::TableView::construct(this);
|
||||
m_table_view = add<GUI::TableView>();
|
||||
m_table_view->set_size_columns_to_fit_content(true);
|
||||
|
||||
Vector<GUI::JsonArrayModel::FieldSpec> pid_fds_fields;
|
||||
|
|
|
@ -36,7 +36,7 @@ public:
|
|||
void set_pid(pid_t);
|
||||
|
||||
private:
|
||||
explicit ProcessFileDescriptorMapWidget(GUI::Widget* parent);
|
||||
ProcessFileDescriptorMapWidget();
|
||||
|
||||
RefPtr<GUI::TableView> m_table_view;
|
||||
pid_t m_pid { -1 };
|
||||
|
|
|
@ -31,8 +31,7 @@
|
|||
#include <LibGUI/SortingProxyModel.h>
|
||||
#include <LibGUI/TableView.h>
|
||||
|
||||
ProcessMemoryMapWidget::ProcessMemoryMapWidget(GUI::Widget* parent)
|
||||
: GUI::Widget(parent)
|
||||
ProcessMemoryMapWidget::ProcessMemoryMapWidget()
|
||||
{
|
||||
set_layout(make<GUI::VerticalBoxLayout>());
|
||||
layout()->set_margins({ 4, 4, 4, 4 });
|
||||
|
|
|
@ -38,7 +38,7 @@ public:
|
|||
void refresh();
|
||||
|
||||
private:
|
||||
explicit ProcessMemoryMapWidget(GUI::Widget* parent);
|
||||
ProcessMemoryMapWidget();
|
||||
RefPtr<GUI::TableView> m_table_view;
|
||||
RefPtr<GUI::JsonArrayModel> m_json_model;
|
||||
pid_t m_pid { -1 };
|
||||
|
|
|
@ -30,8 +30,7 @@
|
|||
#include <LibCore/Timer.h>
|
||||
#include <LibGUI/BoxLayout.h>
|
||||
|
||||
ProcessStacksWidget::ProcessStacksWidget(GUI::Widget* parent)
|
||||
: GUI::Widget(parent)
|
||||
ProcessStacksWidget::ProcessStacksWidget()
|
||||
{
|
||||
set_layout(make<GUI::VerticalBoxLayout>());
|
||||
layout()->set_margins({ 4, 4, 4, 4 });
|
||||
|
|
|
@ -32,13 +32,14 @@
|
|||
class ProcessStacksWidget final : public GUI::Widget {
|
||||
C_OBJECT(ProcessStacksWidget)
|
||||
public:
|
||||
explicit ProcessStacksWidget(GUI::Widget* parent);
|
||||
virtual ~ProcessStacksWidget() override;
|
||||
|
||||
void set_pid(pid_t);
|
||||
void refresh();
|
||||
|
||||
private:
|
||||
ProcessStacksWidget();
|
||||
|
||||
pid_t m_pid { -1 };
|
||||
RefPtr<GUI::TextEditor> m_stacks_editor;
|
||||
RefPtr<Core::Timer> m_timer;
|
||||
|
|
|
@ -29,8 +29,7 @@
|
|||
#include <LibGUI/SortingProxyModel.h>
|
||||
#include <stdio.h>
|
||||
|
||||
ProcessTableView::ProcessTableView(GUI::Widget* parent)
|
||||
: TableView(parent)
|
||||
ProcessTableView::ProcessTableView()
|
||||
{
|
||||
set_size_columns_to_fit_content(true);
|
||||
set_model(GUI::SortingProxyModel::create(ProcessModel::create()));
|
||||
|
|
|
@ -45,5 +45,5 @@ public:
|
|||
Function<void(pid_t)> on_process_selected;
|
||||
|
||||
private:
|
||||
explicit ProcessTableView(GUI::Widget* parent = nullptr);
|
||||
ProcessTableView();
|
||||
};
|
||||
|
|
|
@ -29,12 +29,11 @@
|
|||
#include <LibGUI/JsonArrayModel.h>
|
||||
#include <LibGUI/TableView.h>
|
||||
|
||||
ProcessUnveiledPathsWidget::ProcessUnveiledPathsWidget(GUI::Widget* parent)
|
||||
: GUI::Widget(parent)
|
||||
ProcessUnveiledPathsWidget::ProcessUnveiledPathsWidget()
|
||||
{
|
||||
set_layout(make<GUI::VerticalBoxLayout>());
|
||||
layout()->set_margins({ 4, 4, 4, 4 });
|
||||
m_table_view = GUI::TableView::construct(this);
|
||||
m_table_view = add<GUI::TableView>();
|
||||
m_table_view->set_size_columns_to_fit_content(true);
|
||||
|
||||
Vector<GUI::JsonArrayModel::FieldSpec> pid_unveil_fields;
|
||||
|
|
|
@ -36,7 +36,7 @@ public:
|
|||
void set_pid(pid_t);
|
||||
|
||||
private:
|
||||
explicit ProcessUnveiledPathsWidget(GUI::Widget* parent);
|
||||
ProcessUnveiledPathsWidget();
|
||||
|
||||
RefPtr<GUI::TableView> m_table_view;
|
||||
pid_t m_pid { -1 };
|
||||
|
|
|
@ -123,7 +123,7 @@ int main(int argc, char** argv)
|
|||
|
||||
auto tabwidget = keeper->add<GUI::TabWidget>();
|
||||
|
||||
auto process_container_splitter = GUI::VerticalSplitter::construct(nullptr);
|
||||
auto process_container_splitter = GUI::VerticalSplitter::construct();
|
||||
tabwidget->add_widget("Processes", process_container_splitter);
|
||||
|
||||
auto process_table_container = process_container_splitter->add<GUI::Widget>();
|
||||
|
@ -136,7 +136,7 @@ int main(int argc, char** argv)
|
|||
|
||||
tabwidget->add_widget("Devices", build_devices_tab());
|
||||
|
||||
auto network_stats_widget = NetworkStatisticsWidget::construct(nullptr);
|
||||
auto network_stats_widget = NetworkStatisticsWidget::construct();
|
||||
tabwidget->add_widget("Network", network_stats_widget);
|
||||
|
||||
process_table_container->set_layout(make<GUI::VerticalBoxLayout>());
|
||||
|
@ -232,16 +232,16 @@ int main(int argc, char** argv)
|
|||
|
||||
auto process_tab_widget = process_container_splitter->add<GUI::TabWidget>();
|
||||
|
||||
auto memory_map_widget = ProcessMemoryMapWidget::construct(nullptr);
|
||||
auto memory_map_widget = ProcessMemoryMapWidget::construct();
|
||||
process_tab_widget->add_widget("Memory map", memory_map_widget);
|
||||
|
||||
auto open_files_widget = ProcessFileDescriptorMapWidget::construct(nullptr);
|
||||
auto open_files_widget = ProcessFileDescriptorMapWidget::construct();
|
||||
process_tab_widget->add_widget("Open files", open_files_widget);
|
||||
|
||||
auto unveiled_paths_widget = ProcessUnveiledPathsWidget::construct(nullptr);
|
||||
auto unveiled_paths_widget = ProcessUnveiledPathsWidget::construct();
|
||||
process_tab_widget->add_widget("Unveiled paths", unveiled_paths_widget);
|
||||
|
||||
auto stacks_widget = ProcessStacksWidget::construct(nullptr);
|
||||
auto stacks_widget = ProcessStacksWidget::construct();
|
||||
process_tab_widget->add_widget("Stacks", stacks_widget);
|
||||
|
||||
process_table_view->on_process_selected = [&](pid_t pid) {
|
||||
|
|
|
@ -29,8 +29,7 @@
|
|||
#include <LibGfx/Color.h>
|
||||
#include <LibGfx/Palette.h>
|
||||
|
||||
BackgroundWidget::BackgroundWidget(GUI::Widget* parent)
|
||||
: GUI::Frame(parent)
|
||||
BackgroundWidget::BackgroundWidget()
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -31,10 +31,11 @@
|
|||
class BackgroundWidget : public GUI::Frame {
|
||||
C_OBJECT(BackgroundWidget)
|
||||
public:
|
||||
explicit BackgroundWidget(GUI::Widget* parent = nullptr);
|
||||
virtual ~BackgroundWidget() override;
|
||||
|
||||
private:
|
||||
BackgroundWidget();
|
||||
|
||||
virtual void paint_event(GUI::PaintEvent&) override;
|
||||
virtual void resize_event(GUI::ResizeEvent&) override;
|
||||
};
|
||||
|
|
|
@ -33,14 +33,8 @@
|
|||
#include <LibGfx/Font.h>
|
||||
#include <LibGfx/Palette.h>
|
||||
|
||||
TextWidget::TextWidget(GUI::Widget* parent)
|
||||
: GUI::Frame(parent)
|
||||
{
|
||||
}
|
||||
|
||||
TextWidget::TextWidget(const StringView& text, GUI::Widget* parent)
|
||||
: GUI::Frame(parent)
|
||||
, m_text(text)
|
||||
TextWidget::TextWidget(const StringView& text)
|
||||
: m_text(text)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -32,10 +32,9 @@
|
|||
#include <LibGfx/TextAlignment.h>
|
||||
|
||||
class TextWidget : public GUI::Frame {
|
||||
C_OBJECT(TextWidget)
|
||||
C_OBJECT(TextWidget);
|
||||
|
||||
public:
|
||||
explicit TextWidget(GUI::Widget* parent = nullptr);
|
||||
TextWidget(const StringView& text, GUI::Widget* parent = nullptr);
|
||||
virtual ~TextWidget() override;
|
||||
|
||||
String text() const { return m_text; }
|
||||
|
@ -53,6 +52,8 @@ public:
|
|||
void wrap_and_set_height();
|
||||
|
||||
private:
|
||||
explicit TextWidget(const StringView& text = {});
|
||||
|
||||
virtual void paint_event(GUI::PaintEvent&) override;
|
||||
virtual void resize_event(GUI::ResizeEvent&) override;
|
||||
|
||||
|
|
|
@ -25,12 +25,8 @@
|
|||
*/
|
||||
|
||||
#include "UnuncheckableButton.h"
|
||||
#include <LibGUI/Painter.h>
|
||||
#include <LibGfx/Color.h>
|
||||
#include <LibGfx/Palette.h>
|
||||
|
||||
UnuncheckableButton::UnuncheckableButton(GUI::Widget* parent)
|
||||
: GUI::Button(parent)
|
||||
UnuncheckableButton::UnuncheckableButton()
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -31,8 +31,10 @@
|
|||
class UnuncheckableButton : public GUI::Button {
|
||||
C_OBJECT(UnuncheckableButton)
|
||||
public:
|
||||
explicit UnuncheckableButton(GUI::Widget* parent = nullptr);
|
||||
virtual ~UnuncheckableButton() override;
|
||||
|
||||
virtual bool is_uncheckable() const override { return false; }
|
||||
|
||||
private:
|
||||
UnuncheckableButton();
|
||||
};
|
||||
|
|
|
@ -90,7 +90,7 @@ int main(int argc, char** argv)
|
|||
dbg() << "UI_" << name << "::UI_" << name << "()";
|
||||
dbg() << "{";
|
||||
|
||||
dbg() << " main_widget = GUI::Widget::construct(nullptr);";
|
||||
dbg() << " main_widget = GUI::Widget::construct();";
|
||||
dbg() << " main_widget->set_fill_with_background_color(true);";
|
||||
|
||||
widgets.as_array().for_each([&](auto& value) {
|
||||
|
@ -98,7 +98,7 @@ int main(int argc, char** argv)
|
|||
const JsonObject& widget_object = value.as_object();
|
||||
auto name = widget_object.get("name").to_string();
|
||||
auto class_name = widget_object.get("class").to_string();
|
||||
dbg() << " " << name << " = " << class_name << "::construct(main_widget);";
|
||||
dbg() << " " << name << " = main_widget->add<" << class_name << ">();";
|
||||
|
||||
widget_object.for_each_member([&](auto& property_name, const JsonValue& property_value) {
|
||||
if (property_name == "class")
|
||||
|
|
|
@ -286,7 +286,8 @@ int main(int argc, char** argv)
|
|||
auto icon_path = String::format("/res/icons/widgets/G%s.png", reg.class_name().characters());
|
||||
auto action = GUI::Action::create(reg.class_name(), Gfx::Bitmap::load_from_file(icon_path), [®](auto&) {
|
||||
g_form_editor_widget->set_tool(make<WidgetTool>(*g_form_editor_widget, reg));
|
||||
auto widget = reg.construct(&g_form_editor_widget->form_widget());
|
||||
auto widget = reg.construct();
|
||||
g_form_editor_widget->form_widget().add_child(widget);
|
||||
widget->set_relative_rect(30, 30, 30, 30);
|
||||
g_form_editor_widget->model().update();
|
||||
});
|
||||
|
|
|
@ -28,9 +28,8 @@
|
|||
#include "Profile.h"
|
||||
#include <LibGUI/Painter.h>
|
||||
|
||||
ProfileTimelineWidget::ProfileTimelineWidget(Profile& profile, GUI::Widget* parent)
|
||||
: GUI::Frame(parent)
|
||||
, m_profile(profile)
|
||||
ProfileTimelineWidget::ProfileTimelineWidget(Profile& profile)
|
||||
: m_profile(profile)
|
||||
{
|
||||
set_background_color(Color::White);
|
||||
set_fill_with_background_color(true);
|
||||
|
|
|
@ -39,7 +39,7 @@ private:
|
|||
virtual void mousemove_event(GUI::MouseEvent&) override;
|
||||
virtual void mouseup_event(GUI::MouseEvent&) override;
|
||||
|
||||
ProfileTimelineWidget(Profile&, GUI::Widget* parent);
|
||||
explicit ProfileTimelineWidget(Profile&);
|
||||
|
||||
u64 timestamp_at_x(int x) const;
|
||||
|
||||
|
|
|
@ -62,9 +62,9 @@ int main(int argc, char** argv)
|
|||
main_widget->set_fill_with_background_color(true);
|
||||
main_widget->set_layout(make<GUI::VerticalBoxLayout>());
|
||||
|
||||
auto timeline_widget = ProfileTimelineWidget::construct(*profile, main_widget);
|
||||
auto timeline_widget = main_widget->add<ProfileTimelineWidget>(*profile);
|
||||
|
||||
auto tree_view = GUI::TreeView::construct(main_widget);
|
||||
auto tree_view = main_widget->add<GUI::TreeView>();
|
||||
tree_view->set_headers_visible(true);
|
||||
tree_view->set_size_columns_to_fit_content(true);
|
||||
tree_view->set_model(profile->model());
|
||||
|
|
|
@ -44,9 +44,8 @@ VBForm* VBForm::current()
|
|||
return s_current;
|
||||
}
|
||||
|
||||
VBForm::VBForm(const String& name, GUI::Widget* parent)
|
||||
: GUI::Widget(parent)
|
||||
, m_name(name)
|
||||
VBForm::VBForm(const String& name)
|
||||
: m_name(name)
|
||||
{
|
||||
s_current = this;
|
||||
set_fill_with_background_color(true);
|
||||
|
|
|
@ -33,8 +33,8 @@
|
|||
class VBForm : public GUI::Widget {
|
||||
C_OBJECT(VBForm)
|
||||
friend class VBWidget;
|
||||
|
||||
public:
|
||||
explicit VBForm(const String& name, GUI::Widget* parent = nullptr);
|
||||
virtual ~VBForm() override;
|
||||
|
||||
static VBForm* current();
|
||||
|
@ -66,6 +66,8 @@ protected:
|
|||
virtual void keydown_event(GUI::KeyEvent&) override;
|
||||
|
||||
private:
|
||||
explicit VBForm(const String& name);
|
||||
|
||||
void grabber_mousedown_event(GUI::MouseEvent&, Direction grabber);
|
||||
void set_single_selected_widget(VBWidget*);
|
||||
void add_to_selection(VBWidget&);
|
||||
|
|
|
@ -59,7 +59,7 @@ public:
|
|||
|
||||
virtual RefPtr<GUI::Widget> create_widget() override
|
||||
{
|
||||
auto combo = GUI::ComboBox::construct(nullptr);
|
||||
auto combo = GUI::ComboBox::construct();
|
||||
combo->set_only_allow_values_from_model(true);
|
||||
combo->set_model(adopt(*new BoolValuesModel));
|
||||
combo->on_return_pressed = [this] { commit(); };
|
||||
|
@ -87,7 +87,7 @@ VBPropertiesWindow::VBPropertiesWindow()
|
|||
widget->layout()->set_margins({ 2, 2, 2, 2 });
|
||||
set_main_widget(widget);
|
||||
|
||||
m_table_view = GUI::TableView::construct(widget);
|
||||
m_table_view = widget->add<GUI::TableView>();
|
||||
m_table_view->set_headers_visible(false);
|
||||
m_table_view->set_editable(true);
|
||||
|
||||
|
|
|
@ -112,7 +112,7 @@ RefPtr<GUI::Window> make_toolbox_window()
|
|||
widget->layout()->set_spacing(0);
|
||||
window->set_main_widget(widget);
|
||||
|
||||
auto label_button = GUI::Button::construct(widget);
|
||||
auto label_button = widget->add<GUI::Button>();
|
||||
label_button->set_button_style(Gfx::ButtonStyle::CoolBar);
|
||||
label_button->set_tooltip("GLabel");
|
||||
label_button->set_icon(Gfx::Bitmap::load_from_file("/res/icons/vbwidgets/label.png"));
|
||||
|
@ -121,7 +121,7 @@ RefPtr<GUI::Window> make_toolbox_window()
|
|||
form->insert_widget(VBWidgetType::GLabel);
|
||||
};
|
||||
|
||||
auto button_button = GUI::Button::construct(widget);
|
||||
auto button_button = widget->add<GUI::Button>();
|
||||
button_button->set_button_style(Gfx::ButtonStyle::CoolBar);
|
||||
button_button->set_tooltip("GButton");
|
||||
button_button->set_icon(Gfx::Bitmap::load_from_file("/res/icons/vbwidgets/button.png"));
|
||||
|
@ -129,7 +129,7 @@ RefPtr<GUI::Window> make_toolbox_window()
|
|||
if (auto* form = VBForm::current())
|
||||
form->insert_widget(VBWidgetType::GButton);
|
||||
};
|
||||
auto spinbox_button = GUI::Button::construct(widget);
|
||||
auto spinbox_button = widget->add<GUI::Button>();
|
||||
spinbox_button->set_button_style(Gfx::ButtonStyle::CoolBar);
|
||||
spinbox_button->set_tooltip("GSpinBox");
|
||||
spinbox_button->set_icon(Gfx::Bitmap::load_from_file("/res/icons/vbwidgets/spinbox.png"));
|
||||
|
@ -137,7 +137,7 @@ RefPtr<GUI::Window> make_toolbox_window()
|
|||
if (auto* form = VBForm::current())
|
||||
form->insert_widget(VBWidgetType::GSpinBox);
|
||||
};
|
||||
auto editor_button = GUI::Button::construct(widget);
|
||||
auto editor_button = widget->add<GUI::Button>();
|
||||
editor_button->set_button_style(Gfx::ButtonStyle::CoolBar);
|
||||
editor_button->set_tooltip("GTextEditor");
|
||||
editor_button->set_icon(Gfx::Bitmap::load_from_file("/res/icons/vbwidgets/textbox.png"));
|
||||
|
@ -145,7 +145,7 @@ RefPtr<GUI::Window> make_toolbox_window()
|
|||
if (auto* form = VBForm::current())
|
||||
form->insert_widget(VBWidgetType::GTextEditor);
|
||||
};
|
||||
auto progress_bar_button = GUI::Button::construct(widget);
|
||||
auto progress_bar_button = widget->add<GUI::Button>();
|
||||
progress_bar_button->set_button_style(Gfx::ButtonStyle::CoolBar);
|
||||
progress_bar_button->set_tooltip("GProgressBar");
|
||||
progress_bar_button->set_icon(Gfx::Bitmap::load_from_file("/res/icons/vbwidgets/progressbar.png"));
|
||||
|
@ -153,7 +153,7 @@ RefPtr<GUI::Window> make_toolbox_window()
|
|||
if (auto* form = VBForm::current())
|
||||
form->insert_widget(VBWidgetType::GProgressBar);
|
||||
};
|
||||
auto slider_button = GUI::Button::construct(widget);
|
||||
auto slider_button = widget->add<GUI::Button>();
|
||||
slider_button->set_button_style(Gfx::ButtonStyle::CoolBar);
|
||||
slider_button->set_tooltip("GSlider");
|
||||
slider_button->set_icon(Gfx::Bitmap::load_from_file("/res/icons/vbwidgets/slider.png"));
|
||||
|
@ -161,7 +161,7 @@ RefPtr<GUI::Window> make_toolbox_window()
|
|||
if (auto* form = VBForm::current())
|
||||
form->insert_widget(VBWidgetType::GSlider);
|
||||
};
|
||||
auto checkbox_button = GUI::Button::construct(widget);
|
||||
auto checkbox_button = widget->add<GUI::Button>();
|
||||
checkbox_button->set_button_style(Gfx::ButtonStyle::CoolBar);
|
||||
checkbox_button->set_tooltip("GCheckBox");
|
||||
checkbox_button->set_icon(Gfx::Bitmap::load_from_file("/res/icons/vbwidgets/checkbox.png"));
|
||||
|
@ -169,7 +169,7 @@ RefPtr<GUI::Window> make_toolbox_window()
|
|||
if (auto* form = VBForm::current())
|
||||
form->insert_widget(VBWidgetType::GCheckBox);
|
||||
};
|
||||
auto radiobutton_button = GUI::Button::construct(widget);
|
||||
auto radiobutton_button = widget->add<GUI::Button>();
|
||||
radiobutton_button->set_button_style(Gfx::ButtonStyle::CoolBar);
|
||||
radiobutton_button->set_tooltip("GRadioButton");
|
||||
radiobutton_button->set_icon(Gfx::Bitmap::load_from_file("/res/icons/filled-radio-circle.png"));
|
||||
|
@ -177,7 +177,7 @@ RefPtr<GUI::Window> make_toolbox_window()
|
|||
if (auto* form = VBForm::current())
|
||||
form->insert_widget(VBWidgetType::GRadioButton);
|
||||
};
|
||||
auto scrollbar_button = GUI::Button::construct(widget);
|
||||
auto scrollbar_button = widget->add<GUI::Button>();
|
||||
scrollbar_button->set_button_style(Gfx::ButtonStyle::CoolBar);
|
||||
scrollbar_button->set_tooltip("GScrollBar");
|
||||
scrollbar_button->set_icon(Gfx::Bitmap::load_from_file("/res/icons/vbwidgets/scrollbar.png"));
|
||||
|
@ -185,7 +185,7 @@ RefPtr<GUI::Window> make_toolbox_window()
|
|||
if (auto* form = VBForm::current())
|
||||
form->insert_widget(VBWidgetType::GScrollBar);
|
||||
};
|
||||
auto groupbox_button = GUI::Button::construct(widget);
|
||||
auto groupbox_button = widget->add<GUI::Button>();
|
||||
groupbox_button->set_button_style(Gfx::ButtonStyle::CoolBar);
|
||||
groupbox_button->set_tooltip("GGroupBox");
|
||||
groupbox_button->set_icon(Gfx::Bitmap::load_from_file("/res/icons/vbwidgets/groupbox.png"));
|
||||
|
|
|
@ -36,12 +36,9 @@
|
|||
#include <unistd.h>
|
||||
|
||||
class SquareButton final : public GUI::Button {
|
||||
public:
|
||||
SquareButton(GUI::Widget* parent)
|
||||
: GUI::Button(parent)
|
||||
{
|
||||
}
|
||||
C_OBJECT(SquareButton);
|
||||
|
||||
public:
|
||||
Function<void()> on_right_click;
|
||||
Function<void()> on_middle_click;
|
||||
|
||||
|
@ -57,16 +54,15 @@ public:
|
|||
}
|
||||
GUI::Button::mousedown_event(event);
|
||||
}
|
||||
|
||||
private:
|
||||
SquareButton() {}
|
||||
};
|
||||
|
||||
class SquareLabel final : public GUI::Label {
|
||||
public:
|
||||
SquareLabel(Square& square, GUI::Widget* parent)
|
||||
: GUI::Label(parent)
|
||||
, m_square(square)
|
||||
{
|
||||
}
|
||||
C_OBJECT(SquareLabel);
|
||||
|
||||
public:
|
||||
Function<void()> on_chord_click;
|
||||
|
||||
virtual void mousedown_event(GUI::MouseEvent& event) override
|
||||
|
@ -115,6 +111,12 @@ public:
|
|||
GUI::Label::mouseup_event(event);
|
||||
}
|
||||
|
||||
private:
|
||||
explicit SquareLabel(Square& square)
|
||||
: m_square(square)
|
||||
{
|
||||
}
|
||||
|
||||
Square& m_square;
|
||||
bool m_chord { false };
|
||||
};
|
||||
|
@ -243,7 +245,7 @@ void Field::reset()
|
|||
square.is_considering = false;
|
||||
square.is_swept = false;
|
||||
if (!square.label) {
|
||||
square.label = new SquareLabel(square, this);
|
||||
square.label = add<SquareLabel>(square);
|
||||
square.label->set_background_color(Color::from_rgb(0xff4040));
|
||||
}
|
||||
square.label->set_fill_with_background_color(false);
|
||||
|
@ -251,7 +253,7 @@ void Field::reset()
|
|||
square.label->set_visible(false);
|
||||
square.label->set_icon(square.has_mine ? m_mine_bitmap : nullptr);
|
||||
if (!square.button) {
|
||||
square.button = new SquareButton(this);
|
||||
square.button = add<SquareButton>();
|
||||
square.button->on_click = [this, &square](GUI::Button&) {
|
||||
on_square_clicked(square);
|
||||
};
|
||||
|
@ -513,10 +515,12 @@ void Field::set_single_chording(bool enabled)
|
|||
config->write_bool_entry("Minesweeper", "SingleChording", m_single_chording);
|
||||
}
|
||||
|
||||
Square::Square()
|
||||
{
|
||||
}
|
||||
|
||||
Square::~Square()
|
||||
{
|
||||
delete label;
|
||||
delete button;
|
||||
}
|
||||
|
||||
template<typename Callback>
|
||||
|
|
|
@ -37,7 +37,7 @@ class SquareLabel;
|
|||
class Square {
|
||||
AK_MAKE_NONCOPYABLE(Square)
|
||||
public:
|
||||
Square() {}
|
||||
Square();
|
||||
~Square();
|
||||
|
||||
Field* field { nullptr };
|
||||
|
@ -48,8 +48,8 @@ public:
|
|||
int row { 0 };
|
||||
int column { 0 };
|
||||
int number { 0 };
|
||||
SquareButton* button { nullptr };
|
||||
SquareLabel* label { nullptr };
|
||||
RefPtr<SquareButton> button;
|
||||
RefPtr<SquareLabel> label;
|
||||
|
||||
template<typename Callback>
|
||||
void for_each_neighbor(Callback);
|
||||
|
|
|
@ -32,8 +32,7 @@
|
|||
#include <stdlib.h>
|
||||
#include <time.h>
|
||||
|
||||
SnakeGame::SnakeGame(GUI::Widget* parent)
|
||||
: GUI::Widget(parent)
|
||||
SnakeGame::SnakeGame()
|
||||
{
|
||||
set_font(GFontDatabase::the().get_by_name("Liza Regular"));
|
||||
m_fruit_bitmaps.append(*Gfx::Bitmap::load_from_file("/res/icons/snake/paprika.png"));
|
||||
|
|
|
@ -38,7 +38,7 @@ public:
|
|||
void reset();
|
||||
|
||||
private:
|
||||
explicit SnakeGame(GUI::Widget* parent = nullptr);
|
||||
SnakeGame();
|
||||
virtual void paint_event(GUI::PaintEvent&) override;
|
||||
virtual void keydown_event(GUI::KeyEvent&) override;
|
||||
virtual void timer_event(Core::TimerEvent&) override;
|
||||
|
|
|
@ -31,14 +31,8 @@
|
|||
|
||||
namespace GUI {
|
||||
|
||||
AbstractButton::AbstractButton(Widget* parent)
|
||||
: AbstractButton({}, parent)
|
||||
{
|
||||
}
|
||||
|
||||
AbstractButton::AbstractButton(const StringView& text, Widget* parent)
|
||||
: Widget(parent)
|
||||
, m_text(text)
|
||||
AbstractButton::AbstractButton(const StringView& text)
|
||||
: m_text(text)
|
||||
{
|
||||
m_auto_repeat_timer = add<Core::Timer>();
|
||||
m_auto_repeat_timer->on_timeout = [this] {
|
||||
|
|
|
@ -60,8 +60,7 @@ public:
|
|||
void set_auto_repeat_interval(int interval) { m_auto_repeat_interval = interval; }
|
||||
|
||||
protected:
|
||||
explicit AbstractButton(Widget* parent = nullptr);
|
||||
AbstractButton(const StringView&, Widget* parent = nullptr);
|
||||
explicit AbstractButton(const StringView& = {});
|
||||
|
||||
virtual void mousedown_event(MouseEvent&) override;
|
||||
virtual void mousemove_event(MouseEvent&) override;
|
||||
|
|
|
@ -39,8 +39,7 @@ namespace GUI {
|
|||
|
||||
static const int minimum_column_width = 2;
|
||||
|
||||
AbstractTableView::AbstractTableView(Widget* parent)
|
||||
: AbstractView(parent)
|
||||
AbstractTableView::AbstractTableView()
|
||||
{
|
||||
set_should_hide_unnecessary_scrollbars(true);
|
||||
}
|
||||
|
|
|
@ -72,7 +72,7 @@ public:
|
|||
|
||||
protected:
|
||||
virtual ~AbstractTableView() override;
|
||||
explicit AbstractTableView(Widget* parent = nullptr);
|
||||
AbstractTableView();
|
||||
|
||||
virtual void did_update_model() override;
|
||||
virtual void mouseup_event(MouseEvent&) override;
|
||||
|
|
|
@ -37,9 +37,8 @@
|
|||
|
||||
namespace GUI {
|
||||
|
||||
AbstractView::AbstractView(Widget* parent)
|
||||
: ScrollableWidget(parent)
|
||||
, m_selection(*this)
|
||||
AbstractView::AbstractView()
|
||||
: m_selection(*this)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -73,7 +73,7 @@ public:
|
|||
NonnullRefPtr<Gfx::Font> font_for_index(const ModelIndex&) const;
|
||||
|
||||
protected:
|
||||
explicit AbstractView(Widget* parent = nullptr);
|
||||
AbstractView();
|
||||
virtual ~AbstractView() override;
|
||||
|
||||
virtual void mousedown_event(MouseEvent&) override;
|
||||
|
|
|
@ -36,13 +36,8 @@
|
|||
|
||||
namespace GUI {
|
||||
|
||||
Button::Button(Widget* parent)
|
||||
: AbstractButton(parent)
|
||||
{
|
||||
}
|
||||
|
||||
Button::Button(const StringView& text, Widget* parent)
|
||||
: AbstractButton(text, parent)
|
||||
Button::Button(const StringView& text)
|
||||
: AbstractButton(text)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -62,8 +62,7 @@ public:
|
|||
void set_focusable(bool b) { m_focusable = b; }
|
||||
|
||||
protected:
|
||||
Button(const StringView& text, Widget* parent = nullptr);
|
||||
explicit Button(Widget* parent = nullptr);
|
||||
explicit Button(const StringView& text = {});
|
||||
virtual void paint_event(PaintEvent&) override;
|
||||
|
||||
private:
|
||||
|
|
|
@ -52,13 +52,8 @@ static const int s_checked_bitmap_height = 9;
|
|||
static const int s_box_width = 13;
|
||||
static const int s_box_height = 13;
|
||||
|
||||
CheckBox::CheckBox(Widget* parent)
|
||||
: AbstractButton(parent)
|
||||
{
|
||||
}
|
||||
|
||||
CheckBox::CheckBox(const StringView& text, Widget* parent)
|
||||
: AbstractButton(text, parent)
|
||||
CheckBox::CheckBox(const StringView& text)
|
||||
: AbstractButton(text)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -38,8 +38,7 @@ public:
|
|||
virtual void click() override;
|
||||
|
||||
private:
|
||||
CheckBox(const StringView&, Widget* parent = nullptr);
|
||||
explicit CheckBox(Widget* parent = nullptr);
|
||||
explicit CheckBox(const StringView& = {});
|
||||
|
||||
// These don't make sense for a check box, so hide them.
|
||||
using AbstractButton::auto_repeat_interval;
|
||||
|
|
|
@ -47,8 +47,7 @@ static const char* s_arrow_bitmap_data = {
|
|||
static const int s_arrow_bitmap_width = 9;
|
||||
static const int s_arrow_bitmap_height = 9;
|
||||
|
||||
ColumnsView::ColumnsView(Widget* parent)
|
||||
: AbstractView(parent)
|
||||
ColumnsView::ColumnsView()
|
||||
{
|
||||
set_fill_with_background_color(true);
|
||||
set_background_role(ColorRole::Base);
|
||||
|
|
|
@ -40,8 +40,8 @@ public:
|
|||
virtual ModelIndex index_at_event_position(const Gfx::Point&) const override;
|
||||
|
||||
private:
|
||||
ColumnsView(Widget* parent = nullptr);
|
||||
virtual ~ColumnsView();
|
||||
ColumnsView();
|
||||
virtual ~ColumnsView() override;
|
||||
void push_column(ModelIndex& parent_index);
|
||||
void update_column_sizes();
|
||||
|
||||
|
|
|
@ -35,8 +35,7 @@
|
|||
|
||||
namespace GUI {
|
||||
|
||||
ComboBox::ComboBox(Widget* parent)
|
||||
: Widget(parent)
|
||||
ComboBox::ComboBox()
|
||||
{
|
||||
m_editor = add<TextBox>();
|
||||
m_editor->on_change = [this] {
|
||||
|
@ -57,11 +56,11 @@ ComboBox::ComboBox(Widget* parent)
|
|||
open();
|
||||
};
|
||||
|
||||
m_list_window = Window::construct(this);
|
||||
m_list_window = add<Window>();
|
||||
// FIXME: This is obviously not a tooltip window, but it's the closest thing to what we want atm.
|
||||
m_list_window->set_window_type(WindowType::Tooltip);
|
||||
|
||||
m_list_view = ListView::construct(nullptr);
|
||||
m_list_view = ListView::construct();
|
||||
m_list_view->horizontal_scrollbar().set_visible(false);
|
||||
m_list_window->set_main_widget(m_list_view);
|
||||
|
||||
|
|
|
@ -56,7 +56,7 @@ public:
|
|||
Function<void()> on_return_pressed;
|
||||
|
||||
protected:
|
||||
explicit ComboBox(Widget* parent = nullptr);
|
||||
ComboBox();
|
||||
virtual void resize_event(ResizeEvent&) override;
|
||||
|
||||
private:
|
||||
|
|
|
@ -31,8 +31,7 @@
|
|||
|
||||
namespace GUI {
|
||||
|
||||
Frame::Frame(Widget* parent)
|
||||
: Widget(parent)
|
||||
Frame::Frame()
|
||||
{
|
||||
set_frame_thickness(2);
|
||||
set_frame_shape(Gfx::FrameShape::Container);
|
||||
|
|
|
@ -49,7 +49,7 @@ public:
|
|||
Gfx::Rect frame_inner_rect() const { return frame_inner_rect_for_size(size()); }
|
||||
|
||||
protected:
|
||||
explicit Frame(Widget* parent = nullptr);
|
||||
Frame();
|
||||
void paint_event(PaintEvent&) override;
|
||||
|
||||
private:
|
||||
|
|
|
@ -32,14 +32,8 @@
|
|||
|
||||
namespace GUI {
|
||||
|
||||
GroupBox::GroupBox(Widget* parent)
|
||||
: GroupBox({}, parent)
|
||||
{
|
||||
}
|
||||
|
||||
GroupBox::GroupBox(const StringView& title, Widget* parent)
|
||||
: Widget(parent)
|
||||
, m_title(title)
|
||||
GroupBox::GroupBox(const StringView& title)
|
||||
: m_title(title)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -39,8 +39,7 @@ public:
|
|||
void set_title(const StringView&);
|
||||
|
||||
protected:
|
||||
explicit GroupBox(Widget* parent = nullptr);
|
||||
GroupBox(const StringView& title, Widget* parent = nullptr);
|
||||
explicit GroupBox(const StringView& title = {});
|
||||
|
||||
virtual void paint_event(PaintEvent&) override;
|
||||
|
||||
|
|
|
@ -37,8 +37,7 @@
|
|||
|
||||
namespace GUI {
|
||||
|
||||
ItemView::ItemView(Widget* parent)
|
||||
: AbstractView(parent)
|
||||
ItemView::ItemView()
|
||||
{
|
||||
set_background_role(ColorRole::Base);
|
||||
set_foreground_role(ColorRole::BaseText);
|
||||
|
|
|
@ -48,7 +48,7 @@ public:
|
|||
virtual ModelIndex index_at_event_position(const Gfx::Point&) const override;
|
||||
|
||||
private:
|
||||
explicit ItemView(Widget* parent = nullptr);
|
||||
ItemView();
|
||||
|
||||
virtual void did_update_model() override;
|
||||
virtual void paint_event(PaintEvent&) override;
|
||||
|
|
|
@ -32,14 +32,8 @@
|
|||
|
||||
namespace GUI {
|
||||
|
||||
Label::Label(Widget* parent)
|
||||
: Label({}, parent)
|
||||
{
|
||||
}
|
||||
|
||||
Label::Label(const StringView& text, Widget* parent)
|
||||
: Frame(parent)
|
||||
, m_text(text)
|
||||
Label::Label(const StringView& text)
|
||||
: m_text(text)
|
||||
{
|
||||
set_frame_thickness(0);
|
||||
set_frame_shadow(Gfx::FrameShadow::Plain);
|
||||
|
|
|
@ -52,8 +52,7 @@ public:
|
|||
void size_to_fit();
|
||||
|
||||
protected:
|
||||
explicit Label(Widget* parent = nullptr);
|
||||
Label(const StringView& text, Widget* parent = nullptr);
|
||||
explicit Label(const StringView& text = {});
|
||||
|
||||
virtual void paint_event(PaintEvent&) override;
|
||||
|
||||
|
|
|
@ -28,8 +28,7 @@
|
|||
|
||||
namespace GUI {
|
||||
|
||||
LazyWidget::LazyWidget(Widget* parent)
|
||||
: Widget(parent)
|
||||
LazyWidget::LazyWidget()
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -38,7 +38,7 @@ public:
|
|||
Function<void(LazyWidget&)> on_first_show;
|
||||
|
||||
protected:
|
||||
explicit LazyWidget(Widget* parent = nullptr);
|
||||
LazyWidget();
|
||||
|
||||
private:
|
||||
virtual void show_event(ShowEvent&) override;
|
||||
|
|
|
@ -33,8 +33,7 @@
|
|||
|
||||
namespace GUI {
|
||||
|
||||
ListView::ListView(Widget* parent)
|
||||
: AbstractView(parent)
|
||||
ListView::ListView()
|
||||
{
|
||||
set_background_role(ColorRole::Base);
|
||||
set_foreground_role(ColorRole::BaseText);
|
||||
|
|
|
@ -33,7 +33,6 @@ namespace GUI {
|
|||
class ListView : public AbstractView {
|
||||
C_OBJECT(ListView)
|
||||
public:
|
||||
explicit ListView(Widget* parent = nullptr);
|
||||
virtual ~ListView() override;
|
||||
|
||||
int item_height() const { return 16; }
|
||||
|
@ -54,6 +53,8 @@ public:
|
|||
void set_model_column(int column) { m_model_column = column; }
|
||||
|
||||
private:
|
||||
ListView();
|
||||
|
||||
virtual void did_update_model() override;
|
||||
virtual void paint_event(PaintEvent&) override;
|
||||
virtual void doubleclick_event(MouseEvent&) override;
|
||||
|
|
|
@ -77,7 +77,7 @@ public:
|
|||
|
||||
virtual RefPtr<Widget> create_widget() override
|
||||
{
|
||||
auto textbox = TextBox::construct(nullptr);
|
||||
auto textbox = TextBox::construct();
|
||||
textbox->on_return_pressed = [this] {
|
||||
commit();
|
||||
};
|
||||
|
|
|
@ -32,8 +32,7 @@
|
|||
|
||||
namespace GUI {
|
||||
|
||||
ProgressBar::ProgressBar(Widget* parent)
|
||||
: Frame(parent)
|
||||
ProgressBar::ProgressBar()
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -56,7 +56,7 @@ public:
|
|||
void set_format(Format format) { m_format = format; }
|
||||
|
||||
protected:
|
||||
explicit ProgressBar(Widget* parent = nullptr);
|
||||
ProgressBar();
|
||||
|
||||
virtual void paint_event(PaintEvent&) override;
|
||||
|
||||
|
|
|
@ -33,13 +33,8 @@
|
|||
|
||||
namespace GUI {
|
||||
|
||||
RadioButton::RadioButton(Widget* parent)
|
||||
: RadioButton({}, parent)
|
||||
{
|
||||
}
|
||||
|
||||
RadioButton::RadioButton(const StringView& text, Widget* parent)
|
||||
: AbstractButton(text, parent)
|
||||
RadioButton::RadioButton(const StringView& text)
|
||||
: AbstractButton(text)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -38,8 +38,7 @@ public:
|
|||
virtual void click() override;
|
||||
|
||||
protected:
|
||||
explicit RadioButton(Widget* parent = nullptr);
|
||||
explicit RadioButton(const StringView& text, Widget* parent = nullptr);
|
||||
explicit RadioButton(const StringView& text = {});
|
||||
virtual void paint_event(PaintEvent&) override;
|
||||
|
||||
private:
|
||||
|
|
|
@ -75,8 +75,7 @@ static Gfx::CharacterBitmap* s_resize_corner_highlights_bitmap;
|
|||
static const int s_resize_corner_bitmap_width = 16;
|
||||
static const int s_resize_corner_bitmap_height = 16;
|
||||
|
||||
ResizeCorner::ResizeCorner(Widget* parent)
|
||||
: Widget(parent)
|
||||
ResizeCorner::ResizeCorner()
|
||||
{
|
||||
set_background_role(ColorRole::Button);
|
||||
set_size_policy(SizePolicy::Fixed, SizePolicy::Fixed);
|
||||
|
|
|
@ -34,7 +34,7 @@ public:
|
|||
virtual ~ResizeCorner() override;
|
||||
|
||||
protected:
|
||||
explicit ResizeCorner(Widget* parent = nullptr);
|
||||
ResizeCorner();
|
||||
|
||||
virtual void paint_event(PaintEvent&) override;
|
||||
virtual void mousedown_event(MouseEvent&) override;
|
||||
|
|
|
@ -86,14 +86,8 @@ static Gfx::CharacterBitmap* s_down_arrow_bitmap;
|
|||
static Gfx::CharacterBitmap* s_left_arrow_bitmap;
|
||||
static Gfx::CharacterBitmap* s_right_arrow_bitmap;
|
||||
|
||||
ScrollBar::ScrollBar(Widget* parent)
|
||||
: ScrollBar(Orientation::Vertical, parent)
|
||||
{
|
||||
}
|
||||
|
||||
ScrollBar::ScrollBar(Orientation orientation, Widget* parent)
|
||||
: Widget(parent)
|
||||
, m_orientation(orientation)
|
||||
ScrollBar::ScrollBar(Orientation orientation)
|
||||
: m_orientation(orientation)
|
||||
{
|
||||
m_automatic_scrolling_timer = add<Core::Timer>();
|
||||
if (!s_up_arrow_bitmap)
|
||||
|
|
|
@ -65,8 +65,7 @@ public:
|
|||
};
|
||||
|
||||
private:
|
||||
explicit ScrollBar(Widget* parent = nullptr);
|
||||
explicit ScrollBar(Orientation, Widget* parent = nullptr);
|
||||
explicit ScrollBar(Gfx::Orientation = Gfx::Orientation::Vertical);
|
||||
|
||||
virtual void paint_event(PaintEvent&) override;
|
||||
virtual void mousedown_event(MouseEvent&) override;
|
||||
|
|
|
@ -29,17 +29,16 @@
|
|||
|
||||
namespace GUI {
|
||||
|
||||
ScrollableWidget::ScrollableWidget(Widget* parent)
|
||||
: Frame(parent)
|
||||
ScrollableWidget::ScrollableWidget()
|
||||
{
|
||||
m_vertical_scrollbar = ScrollBar::construct(Orientation::Vertical, this);
|
||||
m_vertical_scrollbar = add<ScrollBar>(Orientation::Vertical);
|
||||
m_vertical_scrollbar->set_step(4);
|
||||
m_vertical_scrollbar->on_change = [this](int) {
|
||||
did_scroll();
|
||||
update();
|
||||
};
|
||||
|
||||
m_horizontal_scrollbar = ScrollBar::construct(Orientation::Horizontal, this);
|
||||
m_horizontal_scrollbar = add<ScrollBar>(Orientation::Horizontal);
|
||||
m_horizontal_scrollbar->set_step(4);
|
||||
m_horizontal_scrollbar->set_big_step(30);
|
||||
m_horizontal_scrollbar->on_change = [this](int) {
|
||||
|
@ -47,7 +46,7 @@ ScrollableWidget::ScrollableWidget(Widget* parent)
|
|||
update();
|
||||
};
|
||||
|
||||
m_corner_widget = Widget::construct(this);
|
||||
m_corner_widget = add<Widget>();
|
||||
m_corner_widget->set_fill_with_background_color(true);
|
||||
}
|
||||
|
||||
|
|
|
@ -71,7 +71,7 @@ public:
|
|||
Gfx::Point to_widget_position(const Gfx::Point& content_position) const;
|
||||
|
||||
protected:
|
||||
explicit ScrollableWidget(Widget* parent = nullptr);
|
||||
ScrollableWidget();
|
||||
virtual void custom_layout() override;
|
||||
virtual void resize_event(ResizeEvent&) override;
|
||||
virtual void mousewheel_event(MouseEvent&) override;
|
||||
|
|
|
@ -33,14 +33,8 @@
|
|||
|
||||
namespace GUI {
|
||||
|
||||
Slider::Slider(Widget* parent)
|
||||
: Slider(Orientation::Horizontal, parent)
|
||||
{
|
||||
}
|
||||
|
||||
Slider::Slider(Orientation orientation, Widget* parent)
|
||||
: Widget(parent)
|
||||
, m_orientation(orientation)
|
||||
Slider::Slider(Orientation orientation)
|
||||
: m_orientation(orientation)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -74,8 +74,7 @@ public:
|
|||
Function<void(int)> on_value_changed;
|
||||
|
||||
protected:
|
||||
explicit Slider(Widget* = nullptr);
|
||||
explicit Slider(Orientation, Widget* = nullptr);
|
||||
explicit Slider(Orientation = Orientation::Vertical);
|
||||
|
||||
virtual void paint_event(PaintEvent&) override;
|
||||
virtual void mousedown_event(MouseEvent&) override;
|
||||
|
@ -106,8 +105,8 @@ public:
|
|||
virtual ~VerticalSlider() override {}
|
||||
|
||||
private:
|
||||
explicit VerticalSlider(Widget* parent = nullptr)
|
||||
: Slider(Orientation::Vertical, parent)
|
||||
VerticalSlider()
|
||||
: Slider(Orientation::Vertical)
|
||||
{
|
||||
}
|
||||
};
|
||||
|
@ -118,8 +117,8 @@ public:
|
|||
virtual ~HorizontalSlider() override {}
|
||||
|
||||
private:
|
||||
explicit HorizontalSlider(Widget* parent = nullptr)
|
||||
: Slider(Orientation::Horizontal, parent)
|
||||
HorizontalSlider()
|
||||
: Slider(Orientation::Horizontal)
|
||||
{
|
||||
}
|
||||
};
|
||||
|
|
|
@ -30,8 +30,7 @@
|
|||
|
||||
namespace GUI {
|
||||
|
||||
SpinBox::SpinBox(Widget* parent)
|
||||
: Widget(parent)
|
||||
SpinBox::SpinBox()
|
||||
{
|
||||
m_editor = add<TextBox>();
|
||||
m_editor->set_text("0");
|
||||
|
|
|
@ -47,7 +47,7 @@ public:
|
|||
Function<void(int value)> on_change;
|
||||
|
||||
protected:
|
||||
explicit SpinBox(Widget* parent = nullptr);
|
||||
SpinBox();
|
||||
|
||||
virtual void resize_event(ResizeEvent&) override;
|
||||
|
||||
|
|
|
@ -32,9 +32,8 @@
|
|||
|
||||
namespace GUI {
|
||||
|
||||
Splitter::Splitter(Orientation orientation, Widget* parent)
|
||||
: Frame(parent)
|
||||
, m_orientation(orientation)
|
||||
Splitter::Splitter(Orientation orientation)
|
||||
: m_orientation(orientation)
|
||||
{
|
||||
set_background_role(ColorRole::Button);
|
||||
set_layout(make<BoxLayout>(orientation));
|
||||
|
|
|
@ -36,7 +36,7 @@ public:
|
|||
virtual ~Splitter() override;
|
||||
|
||||
protected:
|
||||
Splitter(Gfx::Orientation, Widget* parent = nullptr);
|
||||
explicit Splitter(Gfx::Orientation);
|
||||
|
||||
virtual void paint_event(PaintEvent&) override;
|
||||
virtual void resize_event(ResizeEvent&) override;
|
||||
|
@ -68,8 +68,8 @@ public:
|
|||
virtual ~VerticalSplitter() override {}
|
||||
|
||||
private:
|
||||
explicit VerticalSplitter(Widget* parent = nullptr)
|
||||
: Splitter(Gfx::Orientation::Vertical, parent)
|
||||
VerticalSplitter()
|
||||
: Splitter(Gfx::Orientation::Vertical)
|
||||
{
|
||||
}
|
||||
};
|
||||
|
@ -80,8 +80,8 @@ public:
|
|||
virtual ~HorizontalSplitter() override {}
|
||||
|
||||
private:
|
||||
explicit HorizontalSplitter(Widget* parent = nullptr)
|
||||
: Splitter(Gfx::Orientation::Horizontal, parent)
|
||||
HorizontalSplitter()
|
||||
: Splitter(Gfx::Orientation::Horizontal)
|
||||
{
|
||||
}
|
||||
};
|
||||
|
|
|
@ -29,8 +29,7 @@
|
|||
|
||||
namespace GUI {
|
||||
|
||||
StackWidget::StackWidget(Widget* parent)
|
||||
: Widget(parent)
|
||||
StackWidget::StackWidget()
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -42,7 +42,7 @@ public:
|
|||
Function<void(Widget*)> on_active_widget_change;
|
||||
|
||||
protected:
|
||||
explicit StackWidget(Widget* parent = nullptr);
|
||||
StackWidget();
|
||||
virtual void child_event(Core::ChildEvent&) override;
|
||||
virtual void resize_event(ResizeEvent&) override;
|
||||
|
||||
|
|
|
@ -34,13 +34,7 @@
|
|||
|
||||
namespace GUI {
|
||||
|
||||
StatusBar::StatusBar(Widget* parent)
|
||||
: StatusBar(1, parent)
|
||||
{
|
||||
}
|
||||
|
||||
StatusBar::StatusBar(int label_count, Widget* parent)
|
||||
: Widget(parent)
|
||||
StatusBar::StatusBar(int label_count)
|
||||
{
|
||||
set_size_policy(SizePolicy::Fill, SizePolicy::Fixed);
|
||||
set_preferred_size(0, 20);
|
||||
|
@ -54,7 +48,7 @@ StatusBar::StatusBar(int label_count, Widget* parent)
|
|||
for (auto i = 0; i < label_count; i++)
|
||||
m_labels.append(create_label());
|
||||
|
||||
m_corner = ResizeCorner::construct(this);
|
||||
m_corner = add<ResizeCorner>();
|
||||
}
|
||||
|
||||
StatusBar::~StatusBar()
|
||||
|
@ -63,7 +57,7 @@ StatusBar::~StatusBar()
|
|||
|
||||
NonnullRefPtr<Label> StatusBar::create_label()
|
||||
{
|
||||
auto label = Label::construct(this);
|
||||
auto label = add<Label>();
|
||||
label->set_frame_shadow(Gfx::FrameShadow::Sunken);
|
||||
label->set_frame_shape(Gfx::FrameShape::Panel);
|
||||
label->set_frame_thickness(1);
|
||||
|
|
|
@ -41,8 +41,7 @@ public:
|
|||
void set_text(int index, const StringView&);
|
||||
|
||||
protected:
|
||||
explicit StatusBar(Widget* parent = nullptr);
|
||||
explicit StatusBar(int label_count, Widget* parent = nullptr);
|
||||
explicit StatusBar(int label_count = 1);
|
||||
virtual void paint_event(PaintEvent&) override;
|
||||
|
||||
private:
|
||||
|
|
|
@ -33,8 +33,7 @@
|
|||
|
||||
namespace GUI {
|
||||
|
||||
TabWidget::TabWidget(Widget* parent)
|
||||
: Widget(parent)
|
||||
TabWidget::TabWidget()
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -38,7 +38,6 @@ public:
|
|||
Bottom,
|
||||
};
|
||||
|
||||
explicit TabWidget(Widget* parent = nullptr);
|
||||
virtual ~TabWidget() override;
|
||||
|
||||
TabPosition tab_position() const { return m_tab_position; }
|
||||
|
@ -56,6 +55,8 @@ public:
|
|||
void add_widget(const StringView&, Widget*);
|
||||
|
||||
protected:
|
||||
TabWidget();
|
||||
|
||||
virtual void paint_event(PaintEvent&) override;
|
||||
virtual void child_event(Core::ChildEvent&) override;
|
||||
virtual void resize_event(ResizeEvent&) override;
|
||||
|
|
|
@ -38,8 +38,7 @@
|
|||
|
||||
namespace GUI {
|
||||
|
||||
TableView::TableView(Widget* parent)
|
||||
: AbstractTableView(parent)
|
||||
TableView::TableView()
|
||||
{
|
||||
set_background_role(ColorRole::Base);
|
||||
set_foreground_role(ColorRole::BaseText);
|
||||
|
|
|
@ -36,7 +36,7 @@ public:
|
|||
virtual ~TableView() override;
|
||||
|
||||
protected:
|
||||
explicit TableView(Widget* parent = nullptr);
|
||||
TableView();
|
||||
|
||||
virtual void paint_event(PaintEvent&) override;
|
||||
};
|
||||
|
|
|
@ -28,8 +28,8 @@
|
|||
|
||||
namespace GUI {
|
||||
|
||||
TextBox::TextBox(Widget* parent)
|
||||
: TextEditor(TextEditor::SingleLine, parent)
|
||||
TextBox::TextBox()
|
||||
: TextEditor(TextEditor::SingleLine)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Reference in a new issue