From c5bd9d4ed1d80ac91d46146565127b0c185f1b43 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Sun, 2 Feb 2020 15:07:41 +0100 Subject: [PATCH] LibGUI: Put all classes in the GUI namespace and remove the leading G This took me a moment. Welcome to the new world of GUI::Widget! :^) --- Applications/About/main.cpp | 38 +-- Applications/Browser/InspectorWidget.cpp | 16 +- Applications/Browser/InspectorWidget.h | 17 +- Applications/Browser/main.cpp | 60 ++-- Applications/Calculator/CalculatorWidget.cpp | 66 ++-- Applications/Calculator/CalculatorWidget.h | 60 ++-- Applications/Calculator/main.cpp | 18 +- Applications/ChanViewer/BoardListModel.cpp | 6 +- Applications/ChanViewer/BoardListModel.h | 8 +- .../ChanViewer/ThreadCatalogModel.cpp | 6 +- Applications/ChanViewer/ThreadCatalogModel.h | 8 +- Applications/ChanViewer/main.cpp | 34 +- .../DisplayProperties/DisplayProperties.cpp | 62 ++-- .../DisplayProperties/DisplayProperties.h | 8 +- .../DisplayProperties/ItemListModel.h | 8 +- Applications/DisplayProperties/main.cpp | 16 +- Applications/FileManager/DirectoryView.cpp | 32 +- Applications/FileManager/DirectoryView.h | 24 +- Applications/FileManager/PropertiesDialog.cpp | 90 +++--- Applications/FileManager/PropertiesDialog.h | 20 +- Applications/FileManager/main.cpp | 176 +++++------ Applications/FontEditor/FontEditor.cpp | 6 +- Applications/FontEditor/FontEditor.h | 5 +- Applications/FontEditor/FontEditorBottom.frm | 2 +- Applications/FontEditor/GlyphEditorWidget.cpp | 22 +- Applications/FontEditor/GlyphEditorWidget.h | 12 +- Applications/FontEditor/GlyphMapWidget.cpp | 12 +- Applications/FontEditor/GlyphMapWidget.h | 8 +- Applications/FontEditor/main.cpp | 18 +- Applications/Help/ManualModel.cpp | 14 +- Applications/Help/ManualModel.h | 16 +- Applications/Help/main.cpp | 40 +-- Applications/HexEditor/HexEditor.cpp | 38 +-- Applications/HexEditor/HexEditor.h | 20 +- Applications/HexEditor/HexEditorWidget.cpp | 84 ++--- Applications/HexEditor/HexEditorWidget.h | 23 +- Applications/HexEditor/main.cpp | 10 +- Applications/IRCClient/IRCAppWindow.cpp | 68 ++-- Applications/IRCClient/IRCAppWindow.h | 25 +- .../IRCClient/IRCChannelMemberListModel.cpp | 8 +- .../IRCClient/IRCChannelMemberListModel.h | 8 +- Applications/IRCClient/IRCWindow.cpp | 16 +- Applications/IRCClient/IRCWindow.h | 11 +- Applications/IRCClient/IRCWindowListModel.cpp | 8 +- Applications/IRCClient/IRCWindowListModel.h | 8 +- Applications/IRCClient/main.cpp | 2 +- Applications/PaintBrush/BucketTool.cpp | 4 +- Applications/PaintBrush/BucketTool.h | 2 +- Applications/PaintBrush/EllipseTool.cpp | 38 +-- Applications/PaintBrush/EllipseTool.h | 24 +- Applications/PaintBrush/EraseTool.cpp | 20 +- Applications/PaintBrush/EraseTool.h | 14 +- Applications/PaintBrush/LineTool.cpp | 36 +-- Applications/PaintBrush/LineTool.h | 24 +- Applications/PaintBrush/PaintableWidget.cpp | 48 +-- Applications/PaintBrush/PaintableWidget.h | 22 +- Applications/PaintBrush/PaletteWidget.cpp | 42 +-- Applications/PaintBrush/PaletteWidget.h | 8 +- Applications/PaintBrush/PenTool.cpp | 22 +- Applications/PaintBrush/PenTool.h | 16 +- Applications/PaintBrush/PickerTool.cpp | 6 +- Applications/PaintBrush/PickerTool.h | 2 +- Applications/PaintBrush/RectangleTool.cpp | 40 +-- Applications/PaintBrush/RectangleTool.h | 22 +- Applications/PaintBrush/SprayTool.cpp | 14 +- Applications/PaintBrush/SprayTool.h | 16 +- Applications/PaintBrush/Tool.h | 14 +- Applications/PaintBrush/ToolboxWidget.cpp | 18 +- Applications/PaintBrush/ToolboxWidget.h | 4 +- Applications/PaintBrush/main.cpp | 34 +- Applications/Piano/KeysWidget.cpp | 20 +- Applications/Piano/KeysWidget.h | 12 +- Applications/Piano/KnobsWidget.cpp | 46 +-- Applications/Piano/KnobsWidget.h | 41 +-- Applications/Piano/MainWidget.cpp | 18 +- Applications/Piano/MainWidget.h | 8 +- Applications/Piano/RollWidget.cpp | 12 +- Applications/Piano/RollWidget.h | 8 +- Applications/Piano/WaveWidget.cpp | 10 +- Applications/Piano/WaveWidget.h | 7 +- Applications/Piano/main.cpp | 18 +- Applications/QuickShow/QSWidget.cpp | 30 +- Applications/QuickShow/QSWidget.h | 19 +- Applications/QuickShow/main.cpp | 18 +- Applications/SoundPlayer/SampleWidget.cpp | 10 +- Applications/SoundPlayer/SampleWidget.h | 6 +- .../SoundPlayer/SoundPlayerWidget.cpp | 46 +-- Applications/SoundPlayer/SoundPlayerWidget.h | 28 +- Applications/SoundPlayer/main.cpp | 22 +- Applications/SystemDialog/main.cpp | 6 +- Applications/SystemMonitor/DevicesModel.cpp | 8 +- Applications/SystemMonitor/DevicesModel.h | 8 +- Applications/SystemMonitor/GraphWidget.cpp | 10 +- Applications/SystemMonitor/GraphWidget.h | 6 +- .../SystemMonitor/MemoryStatsWidget.cpp | 20 +- .../SystemMonitor/MemoryStatsWidget.h | 17 +- .../SystemMonitor/NetworkStatisticsWidget.cpp | 30 +- .../SystemMonitor/NetworkStatisticsWidget.h | 12 +- .../ProcessFileDescriptorMapWidget.cpp | 14 +- .../ProcessFileDescriptorMapWidget.h | 10 +- .../SystemMonitor/ProcessMemoryMapWidget.cpp | 16 +- .../SystemMonitor/ProcessMemoryMapWidget.h | 16 +- Applications/SystemMonitor/ProcessModel.cpp | 8 +- Applications/SystemMonitor/ProcessModel.h | 8 +- .../SystemMonitor/ProcessStacksWidget.cpp | 8 +- .../SystemMonitor/ProcessStacksWidget.h | 6 +- .../SystemMonitor/ProcessTableView.cpp | 10 +- Applications/SystemMonitor/ProcessTableView.h | 4 +- .../ProcessUnveiledPathsWidget.cpp | 14 +- .../ProcessUnveiledPathsWidget.h | 10 +- Applications/SystemMonitor/main.cpp | 120 +++---- Applications/Taskbar/TaskbarButton.cpp | 14 +- Applications/Taskbar/TaskbarButton.h | 8 +- Applications/Taskbar/TaskbarWindow.cpp | 46 +-- Applications/Taskbar/TaskbarWindow.h | 6 +- Applications/Taskbar/WindowList.cpp | 4 +- Applications/Taskbar/WindowList.h | 8 +- Applications/Taskbar/main.cpp | 2 +- Applications/Terminal/main.cpp | 62 ++-- Applications/TextEditor/TextEditorWidget.cpp | 146 ++++----- Applications/TextEditor/TextEditorWidget.h | 62 ++-- Applications/TextEditor/main.cpp | 10 +- Applications/Welcome/TextWidget.cpp | 20 +- Applications/Welcome/TextWidget.h | 10 +- Applications/Welcome/main.cpp | 46 +-- Demos/Fire/Fire.cpp | 46 +-- Demos/HelloWorld/main.cpp | 16 +- Demos/HelloWorld2/HelloWorld2.frm | 2 +- Demos/HelloWorld2/main.cpp | 4 +- Demos/WidgetGallery/main.cpp | 64 ++-- DevTools/FormCompiler/main.cpp | 10 +- DevTools/HackStudio/CursorTool.cpp | 22 +- DevTools/HackStudio/CursorTool.h | 16 +- DevTools/HackStudio/Editor.cpp | 32 +- DevTools/HackStudio/Editor.h | 12 +- DevTools/HackStudio/EditorWrapper.cpp | 20 +- DevTools/HackStudio/EditorWrapper.h | 15 +- DevTools/HackStudio/FindInFilesWidget.cpp | 30 +- DevTools/HackStudio/FindInFilesWidget.h | 18 +- DevTools/HackStudio/FormEditorWidget.cpp | 10 +- DevTools/HackStudio/FormEditorWidget.h | 22 +- DevTools/HackStudio/FormWidget.cpp | 18 +- DevTools/HackStudio/FormWidget.h | 14 +- DevTools/HackStudio/Locator.cpp | 40 +-- DevTools/HackStudio/Locator.h | 19 +- DevTools/HackStudio/ProcessStateWidget.cpp | 24 +- DevTools/HackStudio/ProcessStateWidget.h | 17 +- DevTools/HackStudio/Project.cpp | 12 +- DevTools/HackStudio/Project.h | 4 +- DevTools/HackStudio/ProjectFile.cpp | 4 +- DevTools/HackStudio/ProjectFile.h | 4 +- DevTools/HackStudio/TerminalWrapper.cpp | 12 +- DevTools/HackStudio/TerminalWrapper.h | 4 +- DevTools/HackStudio/Tool.h | 21 +- DevTools/HackStudio/WidgetTool.cpp | 8 +- DevTools/HackStudio/WidgetTool.h | 16 +- DevTools/HackStudio/WidgetTreeModel.cpp | 24 +- DevTools/HackStudio/WidgetTreeModel.h | 20 +- DevTools/HackStudio/main.cpp | 174 +++++------ DevTools/Inspector/RemoteObjectGraphModel.cpp | 10 +- DevTools/Inspector/RemoteObjectGraphModel.h | 12 +- .../Inspector/RemoteObjectPropertyModel.cpp | 4 +- .../Inspector/RemoteObjectPropertyModel.h | 8 +- DevTools/Inspector/main.cpp | 14 +- DevTools/ProfileViewer/Profile.cpp | 2 +- DevTools/ProfileViewer/Profile.h | 7 +- DevTools/ProfileViewer/ProfileModel.cpp | 12 +- DevTools/ProfileViewer/ProfileModel.h | 12 +- .../ProfileViewer/ProfileTimelineWidget.cpp | 22 +- .../ProfileViewer/ProfileTimelineWidget.h | 12 +- DevTools/ProfileViewer/main.cpp | 20 +- DevTools/VisualBuilder/VBForm.cpp | 64 ++-- DevTools/VisualBuilder/VBForm.h | 24 +- DevTools/VisualBuilder/VBPropertiesWindow.cpp | 36 +-- DevTools/VisualBuilder/VBPropertiesWindow.h | 14 +- DevTools/VisualBuilder/VBProperty.cpp | 6 +- DevTools/VisualBuilder/VBProperty.h | 21 +- DevTools/VisualBuilder/VBWidget.cpp | 70 ++--- DevTools/VisualBuilder/VBWidget.h | 13 +- .../VisualBuilder/VBWidgetPropertyModel.cpp | 10 +- .../VisualBuilder/VBWidgetPropertyModel.h | 12 +- DevTools/VisualBuilder/VBWidgetRegistry.cpp | 34 +- DevTools/VisualBuilder/VBWidgetRegistry.h | 2 +- DevTools/VisualBuilder/main.cpp | 74 ++--- Games/Minesweeper/Field.cpp | 52 ++-- Games/Minesweeper/Field.h | 19 +- Games/Minesweeper/main.cpp | 54 ++-- Games/Snake/SnakeGame.cpp | 10 +- Games/Snake/SnakeGame.h | 8 +- Games/Snake/main.cpp | 20 +- Libraries/LibDraw/Palette.h | 6 +- Libraries/LibGUI/GAboutDialog.cpp | 34 +- Libraries/LibGUI/GAboutDialog.h | 13 +- Libraries/LibGUI/GAbstractButton.cpp | 60 ++-- Libraries/LibGUI/GAbstractButton.h | 38 ++- Libraries/LibGUI/GAbstractTableView.cpp | 128 ++++---- Libraries/LibGUI/GAbstractTableView.h | 52 ++-- Libraries/LibGUI/GAbstractView.cpp | 76 ++--- Libraries/LibGUI/GAbstractView.h | 66 ++-- Libraries/LibGUI/GAction.cpp | 114 +++---- Libraries/LibGUI/GAction.h | 100 +++--- Libraries/LibGUI/GActionGroup.cpp | 8 +- Libraries/LibGUI/GActionGroup.h | 18 +- Libraries/LibGUI/GApplication.cpp | 50 +-- Libraries/LibGUI/GApplication.h | 39 +-- Libraries/LibGUI/GBoxLayout.cpp | 27 +- Libraries/LibGUI/GBoxLayout.h | 28 +- Libraries/LibGUI/GButton.cpp | 26 +- Libraries/LibGUI/GButton.h | 24 +- Libraries/LibGUI/GCheckBox.cpp | 20 +- Libraries/LibGUI/GCheckBox.h | 20 +- Libraries/LibGUI/GClipboard.cpp | 30 +- Libraries/LibGUI/GClipboard.h | 14 +- Libraries/LibGUI/GColorPicker.cpp | 36 ++- Libraries/LibGUI/GColorPicker.h | 16 +- Libraries/LibGUI/GColumnsView.cpp | 50 +-- Libraries/LibGUI/GColumnsView.h | 24 +- Libraries/LibGUI/GComboBox.cpp | 38 ++- Libraries/LibGUI/GComboBox.h | 34 +- Libraries/LibGUI/GCommand.cpp | 6 +- Libraries/LibGUI/GCommand.h | 10 +- Libraries/LibGUI/GDesktop.cpp | 27 +- Libraries/LibGUI/GDesktop.h | 14 +- Libraries/LibGUI/GDialog.cpp | 30 +- Libraries/LibGUI/GDialog.h | 12 +- Libraries/LibGUI/GDragOperation.cpp | 22 +- Libraries/LibGUI/GDragOperation.h | 19 +- Libraries/LibGUI/GEvent.h | 108 +++---- Libraries/LibGUI/GFilePicker.cpp | 118 +++---- Libraries/LibGUI/GFilePicker.h | 30 +- Libraries/LibGUI/GFileSystemModel.cpp | 58 ++-- Libraries/LibGUI/GFileSystemModel.h | 45 +-- Libraries/LibGUI/GFrame.cpp | 13 +- Libraries/LibGUI/GFrame.h | 14 +- Libraries/LibGUI/GGroupBox.cpp | 20 +- Libraries/LibGUI/GGroupBox.h | 16 +- Libraries/LibGUI/GInputBox.cpp | 32 +- Libraries/LibGUI/GInputBox.h | 22 +- Libraries/LibGUI/GItemView.cpp | 84 ++--- Libraries/LibGUI/GItemView.h | 36 ++- Libraries/LibGUI/GJsonArrayModel.cpp | 18 +- Libraries/LibGUI/GJsonArrayModel.h | 28 +- Libraries/LibGUI/GLabel.cpp | 26 +- Libraries/LibGUI/GLabel.h | 16 +- Libraries/LibGUI/GLayout.cpp | 28 +- Libraries/LibGUI/GLayout.h | 38 ++- Libraries/LibGUI/GLazyWidget.cpp | 12 +- Libraries/LibGUI/GLazyWidget.h | 17 +- Libraries/LibGUI/GListView.cpp | 56 ++-- Libraries/LibGUI/GListView.h | 28 +- Libraries/LibGUI/GMargins.h | 13 +- Libraries/LibGUI/GMenu.cpp | 70 +++-- Libraries/LibGUI/GMenu.h | 29 +- Libraries/LibGUI/GMenuBar.cpp | 26 +- Libraries/LibGUI/GMenuBar.h | 20 +- Libraries/LibGUI/GMenuItem.cpp | 24 +- Libraries/LibGUI/GMenuItem.h | 38 ++- Libraries/LibGUI/GMessageBox.cpp | 48 +-- Libraries/LibGUI/GMessageBox.h | 12 +- Libraries/LibGUI/GModel.cpp | 22 +- Libraries/LibGUI/GModel.h | 51 +-- Libraries/LibGUI/GModelEditingDelegate.h | 44 +-- Libraries/LibGUI/GModelIndex.h | 32 +- Libraries/LibGUI/GModelSelection.cpp | 14 +- Libraries/LibGUI/GModelSelection.h | 30 +- Libraries/LibGUI/GPainter.cpp | 9 +- Libraries/LibGUI/GPainter.h | 13 +- Libraries/LibGUI/GProgressBar.cpp | 20 +- Libraries/LibGUI/GProgressBar.h | 14 +- Libraries/LibGUI/GRadioButton.cpp | 28 +- Libraries/LibGUI/GRadioButton.h | 32 +- Libraries/LibGUI/GResizeCorner.cpp | 34 +- Libraries/LibGUI/GResizeCorner.h | 16 +- Libraries/LibGUI/GScrollBar.cpp | 64 ++-- Libraries/LibGUI/GScrollBar.h | 26 +- Libraries/LibGUI/GScrollableWidget.cpp | 54 ++-- Libraries/LibGUI/GScrollableWidget.h | 36 ++- Libraries/LibGUI/GShortcut.cpp | 10 +- Libraries/LibGUI/GShortcut.h | 16 +- Libraries/LibGUI/GSlider.cpp | 52 ++-- Libraries/LibGUI/GSlider.h | 24 +- Libraries/LibGUI/GSortingProxyModel.cpp | 42 +-- Libraries/LibGUI/GSortingProxyModel.h | 34 +- Libraries/LibGUI/GSpinBox.cpp | 26 +- Libraries/LibGUI/GSpinBox.h | 24 +- Libraries/LibGUI/GSplitter.cpp | 36 ++- Libraries/LibGUI/GSplitter.h | 22 +- Libraries/LibGUI/GStackWidget.cpp | 30 +- Libraries/LibGUI/GStackWidget.h | 24 +- Libraries/LibGUI/GStatusBar.cpp | 34 +- Libraries/LibGUI/GStatusBar.h | 26 +- Libraries/LibGUI/GTabWidget.cpp | 57 ++-- Libraries/LibGUI/GTabWidget.h | 32 +- Libraries/LibGUI/GTableView.cpp | 18 +- Libraries/LibGUI/GTableView.h | 14 +- Libraries/LibGUI/GTextBox.cpp | 10 +- Libraries/LibGUI/GTextBox.h | 12 +- Libraries/LibGUI/GTextDocument.cpp | 124 ++++---- Libraries/LibGUI/GTextDocument.h | 130 ++++---- Libraries/LibGUI/GTextEditor.cpp | 246 +++++++-------- Libraries/LibGUI/GTextEditor.h | 124 ++++---- Libraries/LibGUI/GTextPosition.h | 18 +- Libraries/LibGUI/GTextRange.h | 40 +-- Libraries/LibGUI/GToolBar.cpp | 40 +-- Libraries/LibGUI/GToolBar.h | 26 +- Libraries/LibGUI/GTreeView.cpp | 84 ++--- Libraries/LibGUI/GTreeView.h | 28 +- Libraries/LibGUI/GUndoStack.cpp | 16 +- Libraries/LibGUI/GUndoStack.h | 16 +- Libraries/LibGUI/GVariant.cpp | 88 +++--- Libraries/LibGUI/GVariant.h | 56 ++-- Libraries/LibGUI/GWidget.cpp | 292 +++++++++--------- Libraries/LibGUI/GWidget.h | 150 ++++----- Libraries/LibGUI/GWindow.cpp | 194 ++++++------ Libraries/LibGUI/GWindow.h | 84 ++--- Libraries/LibGUI/GWindowServerConnection.cpp | 186 +++++------ Libraries/LibGUI/GWindowServerConnection.h | 12 +- Libraries/LibGUI/GWindowType.h | 6 +- Libraries/LibHTML/DOM/HTMLInputElement.cpp | 8 +- Libraries/LibHTML/DOMTreeModel.cpp | 12 +- Libraries/LibHTML/DOMTreeModel.h | 12 +- Libraries/LibHTML/HtmlView.cpp | 44 +-- Libraries/LibHTML/HtmlView.h | 23 +- Libraries/LibHTML/Layout/LayoutWidget.cpp | 2 +- Libraries/LibHTML/Layout/LayoutWidget.h | 12 +- Libraries/LibHTML/RenderingContext.h | 10 +- Libraries/LibHTML/StylePropertiesModel.cpp | 4 +- Libraries/LibHTML/StylePropertiesModel.h | 8 +- Libraries/LibVT/TerminalWidget.cpp | 64 ++-- Libraries/LibVT/TerminalWidget.h | 40 +-- MenuApplets/Audio/main.cpp | 18 +- MenuApplets/CPUGraph/main.cpp | 18 +- MenuApplets/Clock/main.cpp | 14 +- Userland/copy.cpp | 4 +- Userland/html.cpp | 16 +- Userland/pape.cpp | 6 +- Userland/paste.cpp | 4 +- 337 files changed, 5400 insertions(+), 4816 deletions(-) diff --git a/Applications/About/main.cpp b/Applications/About/main.cpp index a391e63073a..0aa5cf42d9e 100644 --- a/Applications/About/main.cpp +++ b/Applications/About/main.cpp @@ -40,7 +40,7 @@ int main(int argc, char** argv) return 1; } - GApplication app(argc, argv); + GUI::Application app(argc, argv); if (pledge("stdio shared_buffer accept rpath", nullptr) < 0) { perror("pledge"); @@ -54,56 +54,56 @@ int main(int argc, char** argv) unveil(nullptr, nullptr); - auto window = GWindow::construct(); + auto window = GUI::Window::construct(); window->set_title("About SerenityOS"); Rect window_rect { 0, 0, 240, 180 }; - window_rect.center_within(GDesktop::the().rect()); + window_rect.center_within(GUI::Desktop::the().rect()); window->set_resizable(false); window->set_rect(window_rect); - auto widget = GWidget::construct(); + auto widget = GUI::Widget::construct(); window->set_main_widget(widget); widget->set_fill_with_background_color(true); - widget->set_layout(make()); + widget->set_layout(make()); widget->layout()->set_margins({ 0, 8, 0, 8 }); widget->layout()->set_spacing(8); - auto icon_label = GLabel::construct(widget); + auto icon_label = GUI::Label::construct(widget); icon_label->set_icon(GraphicsBitmap::load_from_file("/res/icons/serenity.png")); - icon_label->set_size_policy(SizePolicy::Fixed, SizePolicy::Fixed); + icon_label->set_size_policy(GUI::SizePolicy::Fixed, GUI::SizePolicy::Fixed); icon_label->set_preferred_size(icon_label->icon()->size()); - auto label = GLabel::construct(widget); + auto label = GUI::Label::construct(widget); label->set_font(Font::default_bold_font()); label->set_text("SerenityOS"); - label->set_size_policy(SizePolicy::Fill, SizePolicy::Fixed); + label->set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed); label->set_preferred_size(0, 11); utsname uts; int rc = uname(&uts); ASSERT(rc == 0); - auto version_label = GLabel::construct(widget); + auto version_label = GUI::Label::construct(widget); version_label->set_text(String::format("Version %s", uts.release)); - version_label->set_size_policy(SizePolicy::Fill, SizePolicy::Fixed); + version_label->set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed); version_label->set_preferred_size(0, 11); - auto git_info_label = GLabel::construct(widget); + auto git_info_label = GUI::Label::construct(widget); git_info_label->set_text(String::format("Built on %s@%s", GIT_BRANCH, GIT_COMMIT)); - git_info_label->set_size_policy(SizePolicy::Fill, SizePolicy::Fixed); + git_info_label->set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed); git_info_label->set_preferred_size(0, 11); - auto git_changes_label = GLabel::construct(widget); + auto git_changes_label = GUI::Label::construct(widget); git_changes_label->set_text(String::format("Changes: %s", GIT_CHANGES)); - git_changes_label->set_size_policy(SizePolicy::Fill, SizePolicy::Fixed); + git_changes_label->set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed); git_changes_label->set_preferred_size(0, 11); - auto quit_button = GButton::construct(widget); + auto quit_button = GUI::Button::construct(widget); quit_button->set_text("Okay"); - quit_button->set_size_policy(SizePolicy::Fixed, SizePolicy::Fixed); + quit_button->set_size_policy(GUI::SizePolicy::Fixed, GUI::SizePolicy::Fixed); quit_button->set_preferred_size(100, 20); - quit_button->on_click = [](GButton&) { - GApplication::the().quit(0); + quit_button->on_click = [](GUI::Button&) { + GUI::Application::the().quit(0); }; quit_button->set_focus(true); diff --git a/Applications/Browser/InspectorWidget.cpp b/Applications/Browser/InspectorWidget.cpp index b0cc359bf5c..718883a27fe 100644 --- a/Applications/Browser/InspectorWidget.cpp +++ b/Applications/Browser/InspectorWidget.cpp @@ -35,12 +35,12 @@ #include #include -InspectorWidget::InspectorWidget(GWidget* parent) - : GWidget(parent) +InspectorWidget::InspectorWidget(GUI::Widget* parent) + : GUI::Widget(parent) { - set_layout(make()); - auto splitter = GSplitter::construct(Orientation::Vertical, this); - m_dom_tree_view = GTreeView::construct(splitter); + set_layout(make()); + auto splitter = GUI::Splitter::construct(Orientation::Vertical, this); + m_dom_tree_view = GUI::TreeView::construct(splitter); m_dom_tree_view->on_selection = [this](auto& index) { auto* node = static_cast(index.internal_data()); node->document().set_inspected_node(node); @@ -55,13 +55,13 @@ InspectorWidget::InspectorWidget(GWidget* parent) m_computed_style_table_view->set_model(nullptr); } }; - m_style_table_view = GTableView::construct(nullptr); + m_style_table_view = GUI::TableView::construct(nullptr); m_style_table_view->set_size_columns_to_fit_content(true); - m_computed_style_table_view = GTableView::construct(nullptr); + m_computed_style_table_view = GUI::TableView::construct(nullptr); m_computed_style_table_view->set_size_columns_to_fit_content(true); - auto tabwidget = GTabWidget::construct(splitter); + auto tabwidget = GUI::TabWidget::construct(splitter); tabwidget->add_widget("Styles", m_style_table_view); tabwidget->add_widget("Computed", m_computed_style_table_view); } diff --git a/Applications/Browser/InspectorWidget.h b/Applications/Browser/InspectorWidget.h index e0957f62c51..96363d1a48a 100644 --- a/Applications/Browser/InspectorWidget.h +++ b/Applications/Browser/InspectorWidget.h @@ -27,10 +27,13 @@ #include class Document; -class GTableView; -class GTreeView; -class InspectorWidget final : public GWidget { +namespace GUI { +class TableView; +class TreeView; +} + +class InspectorWidget final : public GUI::Widget { C_OBJECT(InspectorWidget) public: virtual ~InspectorWidget(); @@ -38,10 +41,10 @@ public: void set_document(Document*); private: - explicit InspectorWidget(GWidget* parent); + explicit InspectorWidget(GUI::Widget* parent); - RefPtr m_dom_tree_view; - RefPtr m_style_table_view; - RefPtr m_computed_style_table_view; + RefPtr m_dom_tree_view; + RefPtr m_style_table_view; + RefPtr m_computed_style_table_view; RefPtr m_document; }; diff --git a/Applications/Browser/main.cpp b/Applications/Browser/main.cpp index 514128c7582..52944115e49 100644 --- a/Applications/Browser/main.cpp +++ b/Applications/Browser/main.cpp @@ -61,7 +61,7 @@ int main(int argc, char** argv) return 1; } - GApplication app(argc, argv); + GUI::Application app(argc, argv); // Connect to the ProtocolServer immediately so we can drop the "unix" pledge. ResourceLoader::the(); @@ -72,21 +72,21 @@ int main(int argc, char** argv) } - auto window = GWindow::construct(); + auto window = GUI::Window::construct(); window->set_rect(100, 100, 640, 480); - auto widget = GWidget::construct(); + auto widget = GUI::Widget::construct(); widget->set_fill_with_background_color(true); - widget->set_layout(make()); + widget->set_layout(make()); widget->layout()->set_spacing(0); - auto toolbar = GToolBar::construct(widget); + auto toolbar = GUI::ToolBar::construct(widget); auto html_widget = HtmlView::construct(widget); History history; - RefPtr go_back_action; - RefPtr go_forward_action; + RefPtr go_back_action; + RefPtr go_forward_action; auto update_actions = [&]() { go_back_action->set_enabled(history.can_go_back()); @@ -95,14 +95,14 @@ int main(int argc, char** argv) bool should_push_loads_to_history = true; - go_back_action = GCommonActions::make_go_back_action([&](auto&) { + go_back_action = GUI::CommonActions::make_go_back_action([&](auto&) { history.go_back(); update_actions(); TemporaryChange change(should_push_loads_to_history, false); html_widget->load(history.current()); }); - go_forward_action = GCommonActions::make_go_forward_action([&](auto&) { + go_forward_action = GUI::CommonActions::make_go_forward_action([&](auto&) { history.go_forward(); update_actions(); TemporaryChange change(should_push_loads_to_history, false); @@ -112,16 +112,16 @@ int main(int argc, char** argv) toolbar->add_action(*go_back_action); toolbar->add_action(*go_forward_action); - toolbar->add_action(GCommonActions::make_go_home_action([&](auto&) { + toolbar->add_action(GUI::CommonActions::make_go_home_action([&](auto&) { html_widget->load(home_url); })); - toolbar->add_action(GCommonActions::make_reload_action([&](auto&) { + toolbar->add_action(GUI::CommonActions::make_reload_action([&](auto&) { TemporaryChange change(should_push_loads_to_history, false); html_widget->reload(); })); - auto location_box = GTextBox::construct(toolbar); + auto location_box = GUI::TextBox::construct(toolbar); location_box->on_return_pressed = [&] { html_widget->load(location_box->text()); @@ -146,12 +146,12 @@ int main(int argc, char** argv) window->set_title(String::format("%s - Browser", title.characters())); }; - auto focus_location_box_action = GAction::create("Focus location box", { Mod_Ctrl, Key_L }, [&](auto&) { + auto focus_location_box_action = GUI::Action::create("Focus location box", { Mod_Ctrl, Key_L }, [&](auto&) { location_box->select_all(); location_box->set_focus(true); }); - auto statusbar = GStatusBar::construct(widget); + auto statusbar = GUI::StatusBar::construct(widget); html_widget->on_link_hover = [&](auto& href) { statusbar->set_text(href); @@ -165,18 +165,18 @@ int main(int argc, char** argv) statusbar->set_text(String::format("Loading (%d pending resources...)", ResourceLoader::the().pending_loads())); }; - auto menubar = make(); + auto menubar = make(); - auto app_menu = GMenu::construct("Browser"); - app_menu->add_action(GCommonActions::make_quit_action([&](auto&) { + auto app_menu = GUI::Menu::construct("Browser"); + app_menu->add_action(GUI::CommonActions::make_quit_action([&](auto&) { app.quit(); })); menubar->add_menu(move(app_menu)); - RefPtr dom_inspector_window; + RefPtr dom_inspector_window; - auto inspect_menu = GMenu::construct("Inspect"); - inspect_menu->add_action(GAction::create("View source", { Mod_Ctrl, Key_U }, [&](auto&) { + auto inspect_menu = GUI::Menu::construct("Inspect"); + inspect_menu->add_action(GUI::Action::create("View source", { Mod_Ctrl, Key_U }, [&](auto&) { String filename_to_open; char tmp_filename[] = "/tmp/view-source.XXXXXX"; ASSERT(html_widget->document()); @@ -195,9 +195,9 @@ int main(int argc, char** argv) ASSERT_NOT_REACHED(); } })); - inspect_menu->add_action(GAction::create("Inspect DOM tree", { Mod_None, Key_F12 }, [&](auto&) { + inspect_menu->add_action(GUI::Action::create("Inspect DOM tree", { Mod_None, Key_F12 }, [&](auto&) { if (!dom_inspector_window) { - dom_inspector_window = GWindow::construct(); + 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); @@ -210,20 +210,20 @@ int main(int argc, char** argv) })); menubar->add_menu(move(inspect_menu)); - auto debug_menu = GMenu::construct("Debug"); - debug_menu->add_action(GAction::create("Dump DOM tree", [&](auto&) { + auto debug_menu = GUI::Menu::construct("Debug"); + debug_menu->add_action(GUI::Action::create("Dump DOM tree", [&](auto&) { dump_tree(*html_widget->document()); })); - debug_menu->add_action(GAction::create("Dump Layout tree", [&](auto&) { + debug_menu->add_action(GUI::Action::create("Dump Layout tree", [&](auto&) { dump_tree(*html_widget->document()->layout_node()); })); - debug_menu->add_action(GAction::create("Dump Style sheets", [&](auto&) { + debug_menu->add_action(GUI::Action::create("Dump Style sheets", [&](auto&) { for (auto& sheet : html_widget->document()->stylesheets()) { dump_sheet(sheet); } })); debug_menu->add_separator(); - auto line_box_borders_action = GAction::create("Line box borders", [&](auto& action) { + auto line_box_borders_action = GUI::Action::create("Line box borders", [&](auto& action) { action.set_checked(!action.is_checked()); html_widget->set_should_show_line_box_borders(action.is_checked()); html_widget->update(); @@ -233,9 +233,9 @@ int main(int argc, char** argv) debug_menu->add_action(line_box_borders_action); menubar->add_menu(move(debug_menu)); - auto help_menu = GMenu::construct("Help"); - help_menu->add_action(GAction::create("About", [&](const GAction&) { - GAboutDialog::show("Browser", GraphicsBitmap::load_from_file("/res/icons/32x32/filetype-html.png"), window); + auto help_menu = GUI::Menu::construct("Help"); + help_menu->add_action(GUI::Action::create("About", [&](const GUI::Action&) { + GUI::AboutDialog::show("Browser", GraphicsBitmap::load_from_file("/res/icons/32x32/filetype-html.png"), window); })); menubar->add_menu(move(help_menu)); diff --git a/Applications/Calculator/CalculatorWidget.cpp b/Applications/Calculator/CalculatorWidget.cpp index 32fa5c494bb..736cd4ecbf8 100644 --- a/Applications/Calculator/CalculatorWidget.cpp +++ b/Applications/Calculator/CalculatorWidget.cpp @@ -30,16 +30,16 @@ #include #include -CalculatorWidget::CalculatorWidget(GWidget* parent) - : GWidget(parent) +CalculatorWidget::CalculatorWidget(GUI::Widget* parent) + : GUI::Widget(parent) { set_fill_with_background_color(true); - m_entry = GTextBox::construct(this); + m_entry = GUI::TextBox::construct(this); m_entry->set_relative_rect(5, 5, 244, 26); m_entry->set_text_alignment(TextAlignment::CenterRight); - m_label = GLabel::construct(this); + m_label = GUI::Label::construct(this); m_label->set_relative_rect(12, 42, 27, 27); m_label->set_foreground_color(Color::NamedColor::Red); m_label->set_frame_shadow(FrameShadow::Sunken); @@ -49,7 +49,7 @@ CalculatorWidget::CalculatorWidget(GWidget* parent) update_display(); for (int i = 0; i < 10; i++) { - m_digit_button[i] = GButton::construct(this); + m_digit_button[i] = GUI::Button::construct(this); auto& button = *m_digit_button[i]; int p = i ? i + 2 : 0; int x = 55 + (p % 3) * 39; @@ -59,34 +59,34 @@ CalculatorWidget::CalculatorWidget(GWidget* parent) add_button(button, i); } - m_mem_add_button = GButton::construct(this); + m_mem_add_button = GUI::Button::construct(this); m_mem_add_button->move_to(9, 177); m_mem_add_button->set_foreground_color(Color::NamedColor::Red); m_mem_add_button->set_text("M+"); add_button(*m_mem_add_button, Calculator::Operation::MemAdd); - m_mem_save_button = GButton::construct(this); + m_mem_save_button = GUI::Button::construct(this); m_mem_save_button->move_to(9, 144); m_mem_save_button->set_foreground_color(Color::NamedColor::Red); m_mem_save_button->set_text("MS"); add_button(*m_mem_save_button, Calculator::Operation::MemSave); - m_mem_recall_button = GButton::construct(this); + m_mem_recall_button = GUI::Button::construct(this); m_mem_recall_button->move_to(9, 111); m_mem_recall_button->set_foreground_color(Color::NamedColor::Red); m_mem_recall_button->set_text("MR"); add_button(*m_mem_recall_button, Calculator::Operation::MemRecall); - m_mem_clear_button = GButton::construct(this); + m_mem_clear_button = GUI::Button::construct(this); m_mem_clear_button->move_to(9, 78); m_mem_clear_button->set_foreground_color(Color::NamedColor::Red); m_mem_clear_button->set_text("MC"); add_button(*m_mem_clear_button, Calculator::Operation::MemClear); - m_clear_button = GButton::construct(this); + m_clear_button = GUI::Button::construct(this); m_clear_button->set_foreground_color(Color::NamedColor::Red); m_clear_button->set_text("C"); - m_clear_button->on_click = [this](GButton&) { + m_clear_button->on_click = [this](GUI::Button&) { m_keypad.set_value(0.0); m_calculator.clear_operation(); update_display(); @@ -94,89 +94,89 @@ CalculatorWidget::CalculatorWidget(GWidget* parent) add_button(*m_clear_button); m_clear_button->set_relative_rect(187, 40, 60, 28); - m_clear_error_button = GButton::construct(this); + m_clear_error_button = GUI::Button::construct(this); m_clear_error_button->set_foreground_color(Color::NamedColor::Red); m_clear_error_button->set_text("CE"); - m_clear_error_button->on_click = [this](GButton&) { + m_clear_error_button->on_click = [this](GUI::Button&) { m_calculator.clear_error(); update_display(); }; add_button(*m_clear_error_button); m_clear_error_button->set_relative_rect(124, 40, 59, 28); - m_backspace_button = GButton::construct(this); + m_backspace_button = GUI::Button::construct(this); m_backspace_button->set_foreground_color(Color::NamedColor::Red); m_backspace_button->set_text("Backspace"); - m_backspace_button->on_click = [this](GButton&) { + m_backspace_button->on_click = [this](GUI::Button&) { m_keypad.type_backspace(); update_display(); }; add_button(*m_backspace_button); m_backspace_button->set_relative_rect(55, 40, 65, 28); - m_decimal_point_button = GButton::construct(this); + m_decimal_point_button = GUI::Button::construct(this); m_decimal_point_button->move_to(133, 177); m_decimal_point_button->set_foreground_color(Color::NamedColor::Blue); m_decimal_point_button->set_text("."); - m_decimal_point_button->on_click = [this](GButton&) { + m_decimal_point_button->on_click = [this](GUI::Button&) { m_keypad.type_decimal_point(); update_display(); }; add_button(*m_decimal_point_button); - m_sign_button = GButton::construct(this); + m_sign_button = GUI::Button::construct(this); m_sign_button->move_to(94, 177); m_sign_button->set_foreground_color(Color::NamedColor::Blue); m_sign_button->set_text("+/-"); add_button(*m_sign_button, Calculator::Operation::ToggleSign); - m_add_button = GButton::construct(this); + m_add_button = GUI::Button::construct(this); m_add_button->move_to(172, 177); m_add_button->set_foreground_color(Color::NamedColor::Red); m_add_button->set_text("+"); add_button(*m_add_button, Calculator::Operation::Add); - m_subtract_button = GButton::construct(this); + m_subtract_button = GUI::Button::construct(this); m_subtract_button->move_to(172, 144); m_subtract_button->set_foreground_color(Color::NamedColor::Red); m_subtract_button->set_text("-"); add_button(*m_subtract_button, Calculator::Operation::Subtract); - m_multiply_button = GButton::construct(this); + m_multiply_button = GUI::Button::construct(this); m_multiply_button->move_to(172, 111); m_multiply_button->set_foreground_color(Color::NamedColor::Red); m_multiply_button->set_text("*"); add_button(*m_multiply_button, Calculator::Operation::Multiply); - m_divide_button = GButton::construct(this); + m_divide_button = GUI::Button::construct(this); m_divide_button->move_to(172, 78); m_divide_button->set_foreground_color(Color::NamedColor::Red); m_divide_button->set_text("/"); add_button(*m_divide_button, Calculator::Operation::Divide); - m_sqrt_button = GButton::construct(this); + m_sqrt_button = GUI::Button::construct(this); m_sqrt_button->move_to(211, 78); m_sqrt_button->set_foreground_color(Color::NamedColor::Blue); m_sqrt_button->set_text("sqrt"); add_button(*m_sqrt_button, Calculator::Operation::Sqrt); - m_inverse_button = GButton::construct(this); + m_inverse_button = GUI::Button::construct(this); m_inverse_button->move_to(211, 144); m_inverse_button->set_foreground_color(Color::NamedColor::Blue); m_inverse_button->set_text("1/x"); add_button(*m_inverse_button, Calculator::Operation::Inverse); - m_percent_button = GButton::construct(this); + m_percent_button = GUI::Button::construct(this); m_percent_button->move_to(211, 111); m_percent_button->set_foreground_color(Color::NamedColor::Blue); m_percent_button->set_text("%"); add_button(*m_percent_button, Calculator::Operation::Percent); - m_equals_button = GButton::construct(this); + m_equals_button = GUI::Button::construct(this); m_equals_button->move_to(211, 177); m_equals_button->set_foreground_color(Color::NamedColor::Red); m_equals_button->set_text("="); - m_equals_button->on_click = [this](GButton&) { + m_equals_button->on_click = [this](GUI::Button&) { double argument = m_keypad.value(); double res = m_calculator.finish_operation(argument); m_keypad.set_value(res); @@ -189,10 +189,10 @@ CalculatorWidget::~CalculatorWidget() { } -void CalculatorWidget::add_button(GButton& button, Calculator::Operation operation) +void CalculatorWidget::add_button(GUI::Button& button, Calculator::Operation operation) { add_button(button); - button.on_click = [this, operation](GButton&) { + button.on_click = [this, operation](GUI::Button&) { double argument = m_keypad.value(); double res = m_calculator.begin_operation(operation, argument); m_keypad.set_value(res); @@ -200,17 +200,17 @@ void CalculatorWidget::add_button(GButton& button, Calculator::Operation operati }; } -void CalculatorWidget::add_button(GButton& button, int digit) +void CalculatorWidget::add_button(GUI::Button& button, int digit) { add_button(button); button.set_text(String::number(digit)); - button.on_click = [this, digit](GButton&) { + button.on_click = [this, digit](GUI::Button&) { m_keypad.type_digit(digit); update_display(); }; } -void CalculatorWidget::add_button(GButton& button) +void CalculatorWidget::add_button(GUI::Button& button) { button.resize(35, 28); } @@ -224,7 +224,7 @@ void CalculatorWidget::update_display() m_label->set_text(""); } -void CalculatorWidget::keydown_event(GKeyEvent& event) +void CalculatorWidget::keydown_event(GUI::KeyEvent& event) { //Clear button selection when we are typing m_equals_button->set_focus(true); diff --git a/Applications/Calculator/CalculatorWidget.h b/Applications/Calculator/CalculatorWidget.h index bc0d1635359..8400ca756f0 100644 --- a/Applications/Calculator/CalculatorWidget.h +++ b/Applications/Calculator/CalculatorWidget.h @@ -31,47 +31,49 @@ #include #include -class GTextBox; -class GButton; -class GLabel; +namespace GUI { +class Button; +class Label; +class TextBox; +} -class CalculatorWidget final : public GWidget { +class CalculatorWidget final : public GUI::Widget { C_OBJECT(CalculatorWidget) public: virtual ~CalculatorWidget() override; private: - explicit CalculatorWidget(GWidget*); - void add_button(GButton&, Calculator::Operation); - void add_button(GButton&, int); - void add_button(GButton&); + explicit CalculatorWidget(GUI::Widget*); + void add_button(GUI::Button&, Calculator::Operation); + void add_button(GUI::Button&, int); + void add_button(GUI::Button&); void update_display(); - virtual void keydown_event(GKeyEvent&) override; + virtual void keydown_event(GUI::KeyEvent&) override; Calculator m_calculator; Keypad m_keypad; - RefPtr m_entry; - RefPtr m_label; + RefPtr m_entry; + RefPtr m_label; - RefPtr m_digit_button[10]; - RefPtr m_mem_add_button; - RefPtr m_mem_save_button; - RefPtr m_mem_recall_button; - RefPtr m_mem_clear_button; - RefPtr m_clear_button; - RefPtr m_clear_error_button; - RefPtr m_backspace_button; - RefPtr m_decimal_point_button; - RefPtr m_sign_button; - RefPtr m_add_button; - RefPtr m_subtract_button; - RefPtr m_multiply_button; - RefPtr m_divide_button; - RefPtr m_sqrt_button; - RefPtr m_inverse_button; - RefPtr m_percent_button; - RefPtr m_equals_button; + RefPtr m_digit_button[10]; + RefPtr m_mem_add_button; + RefPtr m_mem_save_button; + RefPtr m_mem_recall_button; + RefPtr m_mem_clear_button; + RefPtr m_clear_button; + RefPtr m_clear_error_button; + RefPtr m_backspace_button; + RefPtr m_decimal_point_button; + RefPtr m_sign_button; + RefPtr m_add_button; + RefPtr m_subtract_button; + RefPtr m_multiply_button; + RefPtr m_divide_button; + RefPtr m_sqrt_button; + RefPtr m_inverse_button; + RefPtr m_percent_button; + RefPtr m_equals_button; }; diff --git a/Applications/Calculator/main.cpp b/Applications/Calculator/main.cpp index ab7780b9a49..fb8f035e0b7 100644 --- a/Applications/Calculator/main.cpp +++ b/Applications/Calculator/main.cpp @@ -40,7 +40,7 @@ int main(int argc, char** argv) return 1; } - GApplication app(argc, argv); + GUI::Application app(argc, argv); if (pledge("stdio shared_buffer rpath accept", nullptr) < 0) { perror("pledge"); @@ -54,7 +54,7 @@ int main(int argc, char** argv) unveil(nullptr, nullptr); - auto window = GWindow::construct(); + auto window = GUI::Window::construct(); window->set_title("Calculator"); window->set_resizable(false); window->set_rect({ 300, 200, 254, 213 }); @@ -65,18 +65,18 @@ int main(int argc, char** argv) window->show(); window->set_icon(GraphicsBitmap::load_from_file("/res/icons/16x16/app-calculator.png")); - auto menubar = make(); + auto menubar = make(); - auto app_menu = GMenu::construct("Calculator"); - app_menu->add_action(GCommonActions::make_quit_action([](auto&) { - GApplication::the().quit(0); + auto app_menu = GUI::Menu::construct("Calculator"); + app_menu->add_action(GUI::CommonActions::make_quit_action([](auto&) { + GUI::Application::the().quit(0); return; })); menubar->add_menu(move(app_menu)); - auto help_menu = GMenu::construct("Help"); - help_menu->add_action(GAction::create("About", [&](const GAction&) { - GAboutDialog::show("Calculator", load_png("/res/icons/16x16/app-calculator.png"), window); + auto help_menu = GUI::Menu::construct("Help"); + help_menu->add_action(GUI::Action::create("About", [&](const GUI::Action&) { + GUI::AboutDialog::show("Calculator", load_png("/res/icons/16x16/app-calculator.png"), window); })); menubar->add_menu(move(help_menu)); diff --git a/Applications/ChanViewer/BoardListModel.cpp b/Applications/ChanViewer/BoardListModel.cpp index a7bee36f4a3..47a3fdd462e 100644 --- a/Applications/ChanViewer/BoardListModel.cpp +++ b/Applications/ChanViewer/BoardListModel.cpp @@ -72,7 +72,7 @@ void BoardListModel::update() }; } -int BoardListModel::row_count(const GModelIndex&) const +int BoardListModel::row_count(const GUI::ModelIndex&) const { return m_boards.size(); } @@ -87,12 +87,12 @@ String BoardListModel::column_name(int column) const } } -GModel::ColumnMetadata BoardListModel::column_metadata([[maybe_unused]] int column) const +GUI::Model::ColumnMetadata BoardListModel::column_metadata([[maybe_unused]] int column) const { return {}; } -GVariant BoardListModel::data(const GModelIndex& index, Role role) const +GUI::Variant BoardListModel::data(const GUI::ModelIndex& index, Role role) const { auto& board = m_boards.at(index.row()).as_object(); if (role == Role::Display) { diff --git a/Applications/ChanViewer/BoardListModel.h b/Applications/ChanViewer/BoardListModel.h index b67c142560c..d17e7868186 100644 --- a/Applications/ChanViewer/BoardListModel.h +++ b/Applications/ChanViewer/BoardListModel.h @@ -30,7 +30,7 @@ #include #include -class BoardListModel final : public GModel { +class BoardListModel final : public GUI::Model { public: enum Column { Board, @@ -40,11 +40,11 @@ public: static NonnullRefPtr create() { return adopt(*new BoardListModel); } virtual ~BoardListModel() override; - virtual int row_count(const GModelIndex& = GModelIndex()) const override; - virtual int column_count(const GModelIndex& = GModelIndex()) const override { return Column::__Count; } + virtual int row_count(const GUI::ModelIndex& = GUI::ModelIndex()) const override; + virtual int column_count(const GUI::ModelIndex& = GUI::ModelIndex()) const override { return Column::__Count; } virtual String column_name(int) const override; virtual ColumnMetadata column_metadata(int) const override; - virtual GVariant data(const GModelIndex&, Role = Role::Display) const override; + virtual GUI::Variant data(const GUI::ModelIndex&, Role = Role::Display) const override; virtual void update() override; private: diff --git a/Applications/ChanViewer/ThreadCatalogModel.cpp b/Applications/ChanViewer/ThreadCatalogModel.cpp index ea6d5f6b00c..3ba7ed527ca 100644 --- a/Applications/ChanViewer/ThreadCatalogModel.cpp +++ b/Applications/ChanViewer/ThreadCatalogModel.cpp @@ -100,7 +100,7 @@ void ThreadCatalogModel::update() }; } -int ThreadCatalogModel::row_count(const GModelIndex&) const +int ThreadCatalogModel::row_count(const GUI::ModelIndex&) const { return m_catalog.size(); } @@ -125,7 +125,7 @@ String ThreadCatalogModel::column_name(int column) const } } -GModel::ColumnMetadata ThreadCatalogModel::column_metadata(int column) const +GUI::Model::ColumnMetadata ThreadCatalogModel::column_metadata(int column) const { switch (column) { case Column::ThreadNumber: @@ -145,7 +145,7 @@ GModel::ColumnMetadata ThreadCatalogModel::column_metadata(int column) const } } -GVariant ThreadCatalogModel::data(const GModelIndex& index, Role role) const +GUI::Variant ThreadCatalogModel::data(const GUI::ModelIndex& index, Role role) const { auto& thread = m_catalog.at(index.row()).as_object(); if (role == Role::Display) { diff --git a/Applications/ChanViewer/ThreadCatalogModel.h b/Applications/ChanViewer/ThreadCatalogModel.h index a40d9ea9c53..284b9a751f2 100644 --- a/Applications/ChanViewer/ThreadCatalogModel.h +++ b/Applications/ChanViewer/ThreadCatalogModel.h @@ -30,7 +30,7 @@ #include #include -class ThreadCatalogModel final : public GModel { +class ThreadCatalogModel final : public GUI::Model { public: enum Column { ThreadNumber, @@ -45,11 +45,11 @@ public: static NonnullRefPtr create() { return adopt(*new ThreadCatalogModel); } virtual ~ThreadCatalogModel() override; - virtual int row_count(const GModelIndex& = GModelIndex()) const override; - virtual int column_count(const GModelIndex& = GModelIndex()) const override { return Column::__Count; } + virtual int row_count(const GUI::ModelIndex& = GUI::ModelIndex()) const override; + virtual int column_count(const GUI::ModelIndex& = GUI::ModelIndex()) const override { return Column::__Count; } virtual String column_name(int) const override; virtual ColumnMetadata column_metadata(int) const override; - virtual GVariant data(const GModelIndex&, Role = Role::Display) const override; + virtual GUI::Variant data(const GUI::ModelIndex&, Role = Role::Display) const override; virtual void update() override; const String& board() const { return m_board; } diff --git a/Applications/ChanViewer/main.cpp b/Applications/ChanViewer/main.cpp index 05700e7b4aa..99e1be7cc55 100644 --- a/Applications/ChanViewer/main.cpp +++ b/Applications/ChanViewer/main.cpp @@ -45,37 +45,37 @@ int main(int argc, char** argv) return 1; } - GApplication app(argc, argv); + GUI::Application app(argc, argv); if (pledge("stdio dns inet shared_buffer rpath", nullptr) < 0) { perror("pledge"); return 1; } - auto window = GWindow::construct(); + auto window = GUI::Window::construct(); window->set_title("ChanViewer"); window->set_rect(100, 100, 800, 500); window->set_icon(load_png("/res/icons/16x16/app-chanviewer.png")); - auto widget = GWidget::construct(); + auto widget = GUI::Widget::construct(); window->set_main_widget(widget); widget->set_fill_with_background_color(true); - widget->set_layout(make()); + widget->set_layout(make()); - auto board_combo = GComboBox::construct(widget); + auto board_combo = GUI::ComboBox::construct(widget); board_combo->set_only_allow_values_from_model(true); - board_combo->set_size_policy(SizePolicy::Fill, SizePolicy::Fixed); + board_combo->set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed); board_combo->set_preferred_size(0, 20); board_combo->set_model(BoardListModel::create()); - auto catalog_view = GTableView::construct(widget); + auto catalog_view = GUI::TableView::construct(widget); catalog_view->set_model(ThreadCatalogModel::create()); auto& catalog_model = *static_cast(catalog_view->model()); - auto statusbar = GStatusBar::construct(widget); + auto statusbar = GUI::StatusBar::construct(widget); - board_combo->on_change = [&] (auto&, const GModelIndex& index) { - auto selected_board = board_combo->model()->data(index, GModel::Role::Custom); + board_combo->on_change = [&] (auto&, const GUI::ModelIndex& index) { + auto selected_board = board_combo->model()->data(index, GUI::Model::Role::Custom); ASSERT(selected_board.is_string()); catalog_model.set_board(selected_board.to_string()); }; @@ -93,18 +93,18 @@ int main(int argc, char** argv) window->show(); - auto menubar = make(); + auto menubar = make(); - auto app_menu = GMenu::construct("ChanViewer"); - app_menu->add_action(GCommonActions::make_quit_action([](auto&) { - GApplication::the().quit(0); + auto app_menu = GUI::Menu::construct("ChanViewer"); + app_menu->add_action(GUI::CommonActions::make_quit_action([](auto&) { + GUI::Application::the().quit(0); return; })); menubar->add_menu(move(app_menu)); - auto help_menu = GMenu::construct("Help"); - help_menu->add_action(GAction::create("About", [&](const GAction&) { - GAboutDialog::show("ChanViewer", load_png("/res/icons/32x32/app-chanviewer.png"), window); + auto help_menu = GUI::Menu::construct("Help"); + help_menu->add_action(GUI::Action::create("About", [&](const GUI::Action&) { + GUI::AboutDialog::show("ChanViewer", load_png("/res/icons/32x32/app-chanviewer.png"), window); })); menubar->add_menu(move(help_menu)); diff --git a/Applications/DisplayProperties/DisplayProperties.cpp b/Applications/DisplayProperties/DisplayProperties.cpp index 4acd14b8263..4ef21805afd 100644 --- a/Applications/DisplayProperties/DisplayProperties.cpp +++ b/Applications/DisplayProperties/DisplayProperties.cpp @@ -100,8 +100,8 @@ void DisplayPropertiesWidget::create_resolution_list() void DisplayPropertiesWidget::create_root_widget() { - m_root_widget = GWidget::construct(); - m_root_widget->set_layout(make()); + m_root_widget = GUI::Widget::construct(); + m_root_widget->set_layout(make()); m_root_widget->set_fill_with_background_color(true); m_root_widget->layout()->set_margins({ 4, 4, 4, 16 }); } @@ -123,19 +123,19 @@ void DisplayPropertiesWidget::create_wallpaper_list() void DisplayPropertiesWidget::create_frame() { - auto tab_widget = GTabWidget::construct(m_root_widget); + auto tab_widget = GUI::TabWidget::construct(m_root_widget); // First, let's create the "Background" tab - auto background_splitter = GSplitter::construct(Orientation::Vertical, nullptr); + auto background_splitter = GUI::Splitter::construct(Orientation::Vertical, nullptr); tab_widget->add_widget("Wallpaper", background_splitter); - auto background_content = GWidget::construct(background_splitter.ptr()); - background_content->set_layout(make()); + auto background_content = GUI::Widget::construct(background_splitter.ptr()); + background_content->set_layout(make()); background_content->layout()->set_margins({ 4, 4, 4, 4 }); - m_wallpaper_preview = GLabel::construct(background_splitter); + m_wallpaper_preview = GUI::Label::construct(background_splitter); - auto wallpaper_list = GListView::construct(background_content); + auto wallpaper_list = GUI::ListView::construct(background_content); wallpaper_list->set_background_color(Color::White); wallpaper_list->set_model(*ItemListModel::create(m_wallpapers)); @@ -156,14 +156,14 @@ void DisplayPropertiesWidget::create_frame() }; // Let's add the settings tab - auto settings_splitter = GSplitter::construct(Orientation::Vertical, nullptr); + auto settings_splitter = GUI::Splitter::construct(Orientation::Vertical, nullptr); tab_widget->add_widget("Settings", settings_splitter); - auto settings_content = GWidget::construct(settings_splitter.ptr()); - settings_content->set_layout(make()); + auto settings_content = GUI::Widget::construct(settings_splitter.ptr()); + settings_content->set_layout(make()); settings_content->layout()->set_margins({ 4, 4, 4, 4 }); - auto resolution_list = GListView::construct(settings_content); + auto resolution_list = GUI::ListView::construct(settings_content); resolution_list->set_background_color(Color::White); resolution_list->set_model(*ItemListModel::create(m_resolutions)); @@ -181,38 +181,38 @@ void DisplayPropertiesWidget::create_frame() settings_content->layout()->add_spacer(); // Add the apply and cancel buttons - auto bottom_widget = GWidget::construct(m_root_widget.ptr()); - bottom_widget->set_layout(make()); + auto bottom_widget = GUI::Widget::construct(m_root_widget.ptr()); + bottom_widget->set_layout(make()); bottom_widget->layout()->add_spacer(); - bottom_widget->set_size_policy(Orientation::Vertical, SizePolicy::Fixed); + bottom_widget->set_size_policy(Orientation::Vertical, GUI::SizePolicy::Fixed); bottom_widget->set_preferred_size(1, 22); - auto apply_button = GButton::construct(bottom_widget); + auto apply_button = GUI::Button::construct(bottom_widget); apply_button->set_text("Apply"); - apply_button->set_size_policy(Orientation::Vertical, SizePolicy::Fixed); - apply_button->set_size_policy(Orientation::Horizontal, SizePolicy::Fixed); + apply_button->set_size_policy(Orientation::Vertical, GUI::SizePolicy::Fixed); + apply_button->set_size_policy(Orientation::Horizontal, GUI::SizePolicy::Fixed); apply_button->set_preferred_size(60, 22); - apply_button->on_click = [this, tab_widget](GButton&) { + apply_button->on_click = [this, tab_widget](GUI::Button&) { send_settings_to_window_server(tab_widget->active_tab_index()); }; - auto ok_button = GButton::construct(bottom_widget); + auto ok_button = GUI::Button::construct(bottom_widget); ok_button->set_text("OK"); - ok_button->set_size_policy(Orientation::Vertical, SizePolicy::Fixed); - ok_button->set_size_policy(Orientation::Horizontal, SizePolicy::Fixed); + ok_button->set_size_policy(Orientation::Vertical, GUI::SizePolicy::Fixed); + ok_button->set_size_policy(Orientation::Horizontal, GUI::SizePolicy::Fixed); ok_button->set_preferred_size(60, 22); - ok_button->on_click = [this, tab_widget](GButton&) { + ok_button->on_click = [this, tab_widget](GUI::Button&) { send_settings_to_window_server(tab_widget->active_tab_index()); - GApplication::the().quit(); + GUI::Application::the().quit(); }; - auto cancel_button = GButton::construct(bottom_widget); + auto cancel_button = GUI::Button::construct(bottom_widget); cancel_button->set_text("Cancel"); - cancel_button->set_size_policy(Orientation::Vertical, SizePolicy::Fixed); - cancel_button->set_size_policy(Orientation::Horizontal, SizePolicy::Fixed); + cancel_button->set_size_policy(Orientation::Vertical, GUI::SizePolicy::Fixed); + cancel_button->set_size_policy(Orientation::Horizontal, GUI::SizePolicy::Fixed); cancel_button->set_preferred_size(60, 22); - cancel_button->on_click = [this](GButton&) { - GApplication::the().quit(); + cancel_button->on_click = [](auto&) { + GUI::Application::the().quit(); }; } @@ -222,10 +222,10 @@ void DisplayPropertiesWidget::send_settings_to_window_server(int tab_index) StringBuilder builder; builder.append("/res/wallpapers/"); builder.append(m_selected_wallpaper); - GDesktop::the().set_wallpaper(builder.to_string()); + GUI::Desktop::the().set_wallpaper(builder.to_string()); } else if (tab_index == TabIndices::Settings) { dbg() << "Attempting to set resolution " << m_selected_resolution; - GWindowServerConnection::the().send_sync(m_selected_resolution); + GUI::WindowServerConnection::the().send_sync(m_selected_resolution); } else { dbg() << "Invalid tab index " << tab_index; } diff --git a/Applications/DisplayProperties/DisplayProperties.h b/Applications/DisplayProperties/DisplayProperties.h index 1273189d906..1f142d0ef9f 100644 --- a/Applications/DisplayProperties/DisplayProperties.h +++ b/Applications/DisplayProperties/DisplayProperties.h @@ -55,8 +55,8 @@ public: void send_settings_to_window_server(int tabIndex); void create_frame(); - const GWidget* root_widget() const { return m_root_widget; } - GWidget* root_widget() { return m_root_widget; } + const GUI::Widget* root_widget() const { return m_root_widget; } + GUI::Widget* root_widget() { return m_root_widget; } private: void create_wallpaper_list(); @@ -66,10 +66,10 @@ private: private: String m_wallpaper_path; RefPtr m_wm_config; - RefPtr m_root_widget; + RefPtr m_root_widget; Vector m_resolutions; Vector m_wallpapers; - RefPtr m_wallpaper_preview; + RefPtr m_wallpaper_preview; Size m_selected_resolution; String m_selected_wallpaper; diff --git a/Applications/DisplayProperties/ItemListModel.h b/Applications/DisplayProperties/ItemListModel.h index 1ce34b624f9..74cee2c3460 100644 --- a/Applications/DisplayProperties/ItemListModel.h +++ b/Applications/DisplayProperties/ItemListModel.h @@ -31,18 +31,18 @@ #include template -class ItemListModel final : public GModel { +class ItemListModel final : public GUI::Model { public: static NonnullRefPtr create(Vector& data) { return adopt(*new ItemListModel(data)); } virtual ~ItemListModel() override {} - virtual int row_count(const GModelIndex&) const override + virtual int row_count(const GUI::ModelIndex&) const override { return m_data.size(); } - virtual int column_count(const GModelIndex&) const override + virtual int column_count(const GUI::ModelIndex&) const override { return 1; } @@ -57,7 +57,7 @@ public: return { 70, TextAlignment::CenterLeft }; } - virtual GVariant data(const GModelIndex& index, Role role = Role::Display) const override + virtual GUI::Variant data(const GUI::ModelIndex& index, Role role = Role::Display) const override { if (role == Role::Display) return m_data.at(index.row()); diff --git a/Applications/DisplayProperties/main.cpp b/Applications/DisplayProperties/main.cpp index cdc7cc8e4a3..409e8f14d5f 100644 --- a/Applications/DisplayProperties/main.cpp +++ b/Applications/DisplayProperties/main.cpp @@ -43,7 +43,7 @@ int main(int argc, char** argv) return 1; } - GApplication app(argc, argv); + GUI::Application app(argc, argv); if (pledge("stdio shared_buffer rpath accept cpath wpath", nullptr) < 0) { perror("pledge"); @@ -52,7 +52,7 @@ int main(int argc, char** argv) DisplayPropertiesWidget instance; - auto window = GWindow::construct(); + auto window = GUI::Window::construct(); window->set_title("Display Properties"); window->move_to(100, 100); window->resize(400, 448); @@ -61,17 +61,17 @@ int main(int argc, char** argv) window->set_icon(load_png("/res/icons/16x16/app-display-properties.png")); // Let's create the menubar first - auto menubar = make(); + auto menubar = make(); - auto app_menu = GMenu::construct("Display Properties"); - app_menu->add_action(GCommonActions::make_quit_action([&](const GAction&) { + auto app_menu = GUI::Menu::construct("Display Properties"); + app_menu->add_action(GUI::CommonActions::make_quit_action([&](const GUI::Action&) { app.quit(); })); menubar->add_menu(move(app_menu)); - auto help_menu = GMenu::construct("Help"); - help_menu->add_action(GAction::create("About", [&](const GAction&) { - GAboutDialog::show("Display Properties", load_png("/res/icons/32x32/app-display-properties.png"), window); + auto help_menu = GUI::Menu::construct("Help"); + help_menu->add_action(GUI::Action::create("About", [&](const GUI::Action&) { + GUI::AboutDialog::show("Display Properties", load_png("/res/icons/32x32/app-display-properties.png"), window); })); menubar->add_menu(move(help_menu)); diff --git a/Applications/FileManager/DirectoryView.cpp b/Applications/FileManager/DirectoryView.cpp index af5570f02d0..e74d9dbe646 100644 --- a/Applications/FileManager/DirectoryView.cpp +++ b/Applications/FileManager/DirectoryView.cpp @@ -49,7 +49,7 @@ static String human_readable_size(size_t size) return number_string_with_one_decimal((float)size / (float)GB, "GB"); } -void DirectoryView::handle_activation(const GModelIndex& index) +void DirectoryView::handle_activation(const GUI::ModelIndex& index) { if (!index.is_valid()) return; @@ -118,24 +118,24 @@ void DirectoryView::handle_activation(const GModelIndex& index) } }; -DirectoryView::DirectoryView(GWidget* parent) - : GStackWidget(parent) - , m_model(GFileSystemModel::create()) +DirectoryView::DirectoryView(GUI::Widget* parent) + : GUI::StackWidget(parent) + , m_model(GUI::FileSystemModel::create()) { set_active_widget(nullptr); - m_item_view = GItemView::construct(this); + m_item_view = GUI::ItemView::construct(this); m_item_view->set_model(model()); - m_columns_view = GColumnsView::construct(this); + m_columns_view = GUI::ColumnsView::construct(this); m_columns_view->set_model(model()); - m_table_view = GTableView::construct(this); - m_table_view->set_model(GSortingProxyModel::create(m_model)); + m_table_view = GUI::TableView::construct(this); + m_table_view->set_model(GUI::SortingProxyModel::create(m_model)); - m_table_view->model()->set_key_column_and_sort_order(GFileSystemModel::Column::Name, GSortOrder::Ascending); + m_table_view->model()->set_key_column_and_sort_order(GUI::FileSystemModel::Column::Name, GUI::SortOrder::Ascending); - m_item_view->set_model_column(GFileSystemModel::Column::Name); - m_columns_view->set_model_column(GFileSystemModel::Column::Name); + m_item_view->set_model_column(GUI::FileSystemModel::Column::Name); + m_columns_view->set_model_column(GUI::FileSystemModel::Column::Name); m_model->on_root_path_change = [this] { m_table_view->selection().clear(); @@ -160,14 +160,14 @@ DirectoryView::DirectoryView(GWidget* parent) on_thumbnail_progress(done, total); }; - m_item_view->on_activation = [&](const GModelIndex& index) { + m_item_view->on_activation = [&](const GUI::ModelIndex& index) { handle_activation(index); }; - m_columns_view->on_activation = [&](const GModelIndex& index) { + m_columns_view->on_activation = [&](const GUI::ModelIndex& index) { handle_activation(index); }; m_table_view->on_activation = [&](auto& index) { - auto& filter_model = (GSortingProxyModel&)*m_table_view->model(); + auto& filter_model = (GUI::SortingProxyModel&)*m_table_view->model(); handle_activation(filter_model.map_to_target(index)); }; @@ -292,7 +292,7 @@ void DirectoryView::update_statusbar() current_view().selection().for_each_index([&](auto& index) { auto& model = *current_view().model(); - auto size_index = model.sibling(index.row(), GFileSystemModel::Column::Size, model.parent_index(index)); + auto size_index = model.sibling(index.row(), GUI::FileSystemModel::Column::Size, model.parent_index(index)); auto file_size = model.data(size_index).to_i32(); selected_byte_count += file_size; }); @@ -311,7 +311,7 @@ void DirectoryView::update_statusbar() // FIXME: This is disgusting. This code should not even be aware that there is a GSortingProxyModel in the table view. if (m_view_mode == ViewMode::List) { - auto& filter_model = (GSortingProxyModel&)*m_table_view->model(); + auto& filter_model = (GUI::SortingProxyModel&)*m_table_view->model(); index = filter_model.map_to_target(index); } diff --git a/Applications/FileManager/DirectoryView.h b/Applications/FileManager/DirectoryView.h index aa348b288ce..26fdd46b7ac 100644 --- a/Applications/FileManager/DirectoryView.h +++ b/Applications/FileManager/DirectoryView.h @@ -34,7 +34,7 @@ #include #include -class DirectoryView final : public GStackWidget { +class DirectoryView final : public GUI::StackWidget { C_OBJECT(DirectoryView) public: virtual ~DirectoryView() override; @@ -50,8 +50,8 @@ public: void refresh(); Function on_path_change; - Function on_selection_change; - Function on_context_menu_request; + Function on_selection_change; + Function on_context_menu_request; Function on_status_message; Function on_thumbnail_progress; @@ -64,7 +64,7 @@ public: void set_view_mode(ViewMode); ViewMode view_mode() const { return m_view_mode; } - GAbstractView& current_view() + GUI::AbstractView& current_view() { switch (m_view_mode) { case ViewMode::List: @@ -86,25 +86,25 @@ public: callback(*m_columns_view); } - GFileSystemModel& model() { return *m_model; } + GUI::FileSystemModel& model() { return *m_model; } private: - explicit DirectoryView(GWidget* parent); - const GFileSystemModel& model() const { return *m_model; } + explicit DirectoryView(GUI::Widget* parent); + const GUI::FileSystemModel& model() const { return *m_model; } - void handle_activation(const GModelIndex&); + void handle_activation(const GUI::ModelIndex&); void set_status_message(const StringView&); void update_statusbar(); ViewMode m_view_mode { Invalid }; - NonnullRefPtr m_model; + NonnullRefPtr m_model; int m_path_history_position { 0 }; Vector m_path_history; void add_path_to_history(const StringView& path); - RefPtr m_table_view; - RefPtr m_item_view; - RefPtr m_columns_view; + RefPtr m_table_view; + RefPtr m_item_view; + RefPtr m_columns_view; }; diff --git a/Applications/FileManager/PropertiesDialog.cpp b/Applications/FileManager/PropertiesDialog.cpp index 89f1a44cca3..21feb2b681d 100644 --- a/Applications/FileManager/PropertiesDialog.cpp +++ b/Applications/FileManager/PropertiesDialog.cpp @@ -35,15 +35,15 @@ #include #include -PropertiesDialog::PropertiesDialog(GFileSystemModel& model, String path, bool disable_rename, Core::Object* parent) - : GDialog(parent) +PropertiesDialog::PropertiesDialog(GUI::FileSystemModel& model, String path, bool disable_rename, Core::Object* parent) + : Dialog(parent) , m_model(model) { auto file_path = FileSystemPath(path); ASSERT(file_path.is_valid()); - auto main_widget = GWidget::construct(); - main_widget->set_layout(make()); + auto main_widget = GUI::Widget::construct(); + main_widget->set_layout(make()); main_widget->layout()->set_margins({ 4, 4, 4, 4 }); main_widget->set_fill_with_background_color(true); @@ -51,30 +51,30 @@ PropertiesDialog::PropertiesDialog(GFileSystemModel& model, String path, bool di set_rect({ 0, 0, 360, 420 }); set_resizable(false); - auto tab_widget = GTabWidget::construct(main_widget); + auto tab_widget = GUI::TabWidget::construct(main_widget); - auto general_tab = GWidget::construct(tab_widget.ptr()); - general_tab->set_layout(make()); + auto general_tab = GUI::Widget::construct(tab_widget.ptr()); + general_tab->set_layout(make()); general_tab->layout()->set_margins({ 12, 8, 12, 8 }); general_tab->layout()->set_spacing(10); tab_widget->add_widget("General", general_tab); general_tab->layout()->add_spacer(); - auto file_container = GWidget::construct(general_tab.ptr()); - file_container->set_layout(make()); - file_container->set_size_policy(SizePolicy::Fill, SizePolicy::Fixed); + auto file_container = GUI::Widget::construct(general_tab.ptr()); + file_container->set_layout(make()); + file_container->set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed); file_container->layout()->set_spacing(20); file_container->set_preferred_size(0, 34); - m_icon = GLabel::construct(file_container); - m_icon->set_size_policy(SizePolicy::Fixed, SizePolicy::Fixed); + m_icon = GUI::Label::construct(file_container); + m_icon->set_size_policy(GUI::SizePolicy::Fixed, GUI::SizePolicy::Fixed); m_icon->set_preferred_size(32, 32); m_name = file_path.basename(); - m_name_box = GTextBox::construct(file_container); - m_name_box->set_size_policy(SizePolicy::Fill, SizePolicy::Fixed); + m_name_box = GUI::TextBox::construct(file_container); + m_name_box->set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed); m_name_box->set_preferred_size({ 0, 22 }); m_name_box->set_text(m_name); m_name_box->on_change = [&, disable_rename]() { @@ -118,8 +118,8 @@ PropertiesDialog::PropertiesDialog(GFileSystemModel& model, String path, bool di properties.append({ "Size:", String::format("%zu bytes", st.st_size) }); properties.append({ "Owner:", String::format("%s (%lu)", user_pw->pw_name, static_cast(user_pw->pw_uid)) }); properties.append({ "Group:", String::format("%s (%lu)", group_pw->pw_name, static_cast(group_pw->pw_uid)) }); - properties.append({ "Created at:", GFileSystemModel::timestamp_string(st.st_ctime) }); - properties.append({ "Last modified:", GFileSystemModel::timestamp_string(st.st_mtime) }); + properties.append({ "Created at:", GUI::FileSystemModel::timestamp_string(st.st_ctime) }); + properties.append({ "Last modified:", GUI::FileSystemModel::timestamp_string(st.st_mtime) }); make_property_value_pairs(properties, general_tab); @@ -131,9 +131,9 @@ PropertiesDialog::PropertiesDialog(GFileSystemModel& model, String path, bool di general_tab->layout()->add_spacer(); - auto button_widget = GWidget::construct(main_widget.ptr()); - button_widget->set_layout(make()); - button_widget->set_size_policy(SizePolicy::Fill, SizePolicy::Fixed); + auto button_widget = GUI::Widget::construct(main_widget.ptr()); + button_widget->set_layout(make()); + button_widget->set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed); button_widget->set_preferred_size(0, 24); button_widget->layout()->set_spacing(5); @@ -180,13 +180,13 @@ bool PropertiesDialog::apply_changes() String new_name = m_name_box->text(); String new_file = make_full_path(new_name).characters(); - if (GFilePicker::file_exists(new_file)) { - GMessageBox::show(String::format("A file \"%s\" already exists!", new_name.characters()), "Error", GMessageBox::Type::Error); + if (GUI::FilePicker::file_exists(new_file)) { + GUI::MessageBox::show(String::format("A file \"%s\" already exists!", new_name.characters()), "Error", GUI::MessageBox::Type::Error); return false; } if (rename(make_full_path(m_name).characters(), new_file.characters())) { - GMessageBox::show(String::format("Could not rename file: %s!", strerror(errno)), "Error", GMessageBox::Type::Error); + GUI::MessageBox::show(String::format("Could not rename file: %s!", strerror(errno)), "Error", GUI::MessageBox::Type::Error); return false; } @@ -197,7 +197,7 @@ bool PropertiesDialog::apply_changes() if (m_permissions_dirty) { if (chmod(make_full_path(m_name).characters(), m_mode)) { - GMessageBox::show(String::format("Could not update permissions: %s!", strerror(errno)), "Error", GMessageBox::Type::Error); + GUI::MessageBox::show(String::format("Could not update permissions: %s!", strerror(errno)), "Error", GUI::MessageBox::Type::Error); return false; } @@ -209,48 +209,48 @@ bool PropertiesDialog::apply_changes() return true; } -void PropertiesDialog::make_permission_checkboxes(NonnullRefPtr& parent, PermissionMasks masks, String label_string, mode_t mode) +void PropertiesDialog::make_permission_checkboxes(NonnullRefPtr& parent, PermissionMasks masks, String label_string, mode_t mode) { - auto widget = GWidget::construct(parent.ptr()); - widget->set_layout(make()); - widget->set_size_policy(SizePolicy::Fill, SizePolicy::Fixed); + auto widget = GUI::Widget::construct(parent.ptr()); + widget->set_layout(make()); + widget->set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed); widget->set_preferred_size(0, 16); widget->layout()->set_spacing(10); - auto label = GLabel::construct(label_string, widget); + auto label = GUI::Label::construct(label_string, widget); label->set_text_alignment(TextAlignment::CenterLeft); - auto box_read = GCheckBox::construct("Read", widget); + auto box_read = GUI::CheckBox::construct("Read", widget); box_read->set_checked(mode & masks.read); box_read->on_checked = [&, masks](bool checked) { permission_changed(masks.read, checked); }; - auto box_write = GCheckBox::construct("Write", widget); + auto box_write = GUI::CheckBox::construct("Write", widget); box_write->set_checked(mode & masks.write); box_write->on_checked = [&, masks](bool checked) { permission_changed(masks.write, checked); }; - auto box_execute = GCheckBox::construct("Execute", widget); + auto box_execute = GUI::CheckBox::construct("Execute", widget); box_execute->set_checked(mode & masks.execute); box_execute->on_checked = [&, masks](bool checked) { permission_changed(masks.execute, checked); }; } -void PropertiesDialog::make_property_value_pairs(const Vector& pairs, NonnullRefPtr& parent) +void PropertiesDialog::make_property_value_pairs(const Vector& pairs, NonnullRefPtr& parent) { int max_width = 0; - Vector> property_labels; + Vector> property_labels; property_labels.ensure_capacity(pairs.size()); for (auto pair : pairs) { - auto label_container = GWidget::construct(parent.ptr()); - label_container->set_layout(make()); - label_container->set_size_policy(SizePolicy::Fill, SizePolicy::Fixed); + auto label_container = GUI::Widget::construct(parent.ptr()); + label_container->set_layout(make()); + label_container->set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed); label_container->set_preferred_size(0, 14); label_container->layout()->set_spacing(12); - auto label_property = GLabel::construct(pair.property, label_container); + auto label_property = GUI::Label::construct(pair.property, label_container); label_property->set_text_alignment(TextAlignment::CenterLeft); - label_property->set_size_policy(SizePolicy::Fixed, SizePolicy::Fill); + label_property->set_size_policy(GUI::SizePolicy::Fixed, GUI::SizePolicy::Fill); - GLabel::construct(pair.value, label_container)->set_text_alignment(TextAlignment::CenterLeft); + GUI::Label::construct(pair.value, label_container)->set_text_alignment(TextAlignment::CenterLeft); max_width = max(max_width, label_property->font().width(pair.property)); property_labels.append(label_property); @@ -260,20 +260,20 @@ void PropertiesDialog::make_property_value_pairs(const Vector label->set_preferred_size({ max_width, 0 }); } -NonnullRefPtr PropertiesDialog::make_button(String text, NonnullRefPtr& parent) +NonnullRefPtr PropertiesDialog::make_button(String text, NonnullRefPtr& parent) { - auto button = GButton::construct(text, parent.ptr()); - button->set_size_policy(SizePolicy::Fixed, SizePolicy::Fixed); + auto button = GUI::Button::construct(text, parent.ptr()); + button->set_size_policy(GUI::SizePolicy::Fixed, GUI::SizePolicy::Fixed); button->set_preferred_size(70, 22); return button; } -void PropertiesDialog::make_divider(NonnullRefPtr& parent) +void PropertiesDialog::make_divider(NonnullRefPtr& parent) { parent->layout()->add_spacer(); - auto divider = GFrame::construct(parent.ptr()); - divider->set_size_policy(SizePolicy::Fill, SizePolicy::Fixed); + auto divider = GUI::Frame::construct(parent.ptr()); + divider->set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed); divider->set_preferred_size({ 0, 2 }); divider->set_frame_shape(FrameShape::HorizontalLine); divider->set_frame_shadow(FrameShadow::Sunken); diff --git a/Applications/FileManager/PropertiesDialog.h b/Applications/FileManager/PropertiesDialog.h index f39a514cf07..986e3e2ba4a 100644 --- a/Applications/FileManager/PropertiesDialog.h +++ b/Applications/FileManager/PropertiesDialog.h @@ -34,13 +34,13 @@ #include #include -class PropertiesDialog final : public GDialog { +class PropertiesDialog final : public GUI::Dialog { C_OBJECT(PropertiesDialog) public: virtual ~PropertiesDialog() override; private: - PropertiesDialog(GFileSystemModel&, String, bool disable_rename, Core::Object* parent = nullptr); + PropertiesDialog(GUI::FileSystemModel&, String, bool disable_rename, Core::Object* parent = nullptr); struct PropertyValuePair { String property; @@ -75,19 +75,19 @@ private: return "Unknown"; } - NonnullRefPtr make_button(String, NonnullRefPtr&); - void make_divider(NonnullRefPtr&); - void make_property_value_pairs(const Vector& pairs, NonnullRefPtr& parent); - void make_permission_checkboxes(NonnullRefPtr& parent, PermissionMasks, String label_string, mode_t mode); + NonnullRefPtr make_button(String, NonnullRefPtr&); + void make_divider(NonnullRefPtr&); + void make_property_value_pairs(const Vector& pairs, NonnullRefPtr& parent); + void make_permission_checkboxes(NonnullRefPtr& parent, PermissionMasks, String label_string, mode_t mode); void permission_changed(mode_t mask, bool set); bool apply_changes(); void update(); String make_full_path(String name); - GFileSystemModel& m_model; - RefPtr m_apply_button; - RefPtr m_name_box; - RefPtr m_icon; + GUI::FileSystemModel& m_model; + RefPtr m_apply_button; + RefPtr m_name_box; + RefPtr m_icon; String m_name; String m_path; mode_t m_mode; diff --git a/Applications/FileManager/main.cpp b/Applications/FileManager/main.cpp index 7d5df0b35b3..cddefb11514 100644 --- a/Applications/FileManager/main.cpp +++ b/Applications/FileManager/main.cpp @@ -74,14 +74,14 @@ int main(int argc, char** argv) RefPtr config = Core::ConfigFile::get_for_app("FileManager"); - GApplication app(argc, argv); + GUI::Application app(argc, argv); if (pledge("stdio thread shared_buffer accept cpath rpath wpath fattr proc exec", nullptr) < 0) { perror("pledge"); return 1; } - auto window = GWindow::construct(); + auto window = GUI::Window::construct(); window->set_title("File Manager"); auto left = config->read_num_entry("Window", "Left", 150); @@ -90,41 +90,41 @@ int main(int argc, char** argv) auto heigth = config->read_num_entry("Window", "Heigth", 480); window->set_rect({ left, top, width, heigth }); - auto widget = GWidget::construct(); - widget->set_layout(make()); + auto widget = GUI::Widget::construct(); + widget->set_layout(make()); widget->layout()->set_spacing(0); - auto main_toolbar = GToolBar::construct(widget); - auto location_toolbar = GToolBar::construct(widget); + auto main_toolbar = GUI::ToolBar::construct(widget); + auto location_toolbar = GUI::ToolBar::construct(widget); location_toolbar->layout()->set_margins({ 6, 3, 6, 3 }); location_toolbar->set_preferred_size(0, 25); - auto location_label = GLabel::construct("Location: ", location_toolbar); + auto location_label = GUI::Label::construct("Location: ", location_toolbar); location_label->size_to_fit(); - auto location_textbox = GTextEditor::construct(GTextEditor::SingleLine, location_toolbar); + auto location_textbox = GUI::TextEditor::construct(GUI::TextEditor::SingleLine, location_toolbar); - auto splitter = GSplitter::construct(Orientation::Horizontal, widget); - auto tree_view = GTreeView::construct(splitter); - auto directories_model = GFileSystemModel::create("/", GFileSystemModel::Mode::DirectoriesOnly); + auto splitter = GUI::Splitter::construct(Orientation::Horizontal, widget); + auto tree_view = GUI::TreeView::construct(splitter); + auto directories_model = GUI::FileSystemModel::create("/", GUI::FileSystemModel::Mode::DirectoriesOnly); tree_view->set_model(directories_model); - tree_view->set_column_hidden(GFileSystemModel::Column::Icon, true); - tree_view->set_column_hidden(GFileSystemModel::Column::Size, true); - tree_view->set_column_hidden(GFileSystemModel::Column::Owner, true); - tree_view->set_column_hidden(GFileSystemModel::Column::Group, true); - tree_view->set_column_hidden(GFileSystemModel::Column::Permissions, true); - tree_view->set_column_hidden(GFileSystemModel::Column::ModificationTime, true); - tree_view->set_column_hidden(GFileSystemModel::Column::Inode, true); - tree_view->set_column_hidden(GFileSystemModel::Column::SymlinkTarget, true); - tree_view->set_size_policy(SizePolicy::Fixed, SizePolicy::Fill); + tree_view->set_column_hidden(GUI::FileSystemModel::Column::Icon, true); + tree_view->set_column_hidden(GUI::FileSystemModel::Column::Size, true); + tree_view->set_column_hidden(GUI::FileSystemModel::Column::Owner, true); + tree_view->set_column_hidden(GUI::FileSystemModel::Column::Group, true); + tree_view->set_column_hidden(GUI::FileSystemModel::Column::Permissions, true); + tree_view->set_column_hidden(GUI::FileSystemModel::Column::ModificationTime, true); + tree_view->set_column_hidden(GUI::FileSystemModel::Column::Inode, true); + tree_view->set_column_hidden(GUI::FileSystemModel::Column::SymlinkTarget, true); + tree_view->set_size_policy(GUI::SizePolicy::Fixed, GUI::SizePolicy::Fill); tree_view->set_preferred_size(150, 0); auto directory_view = DirectoryView::construct(splitter); - auto statusbar = GStatusBar::construct(widget); + auto statusbar = GUI::StatusBar::construct(widget); - auto progressbar = GProgressBar::construct(statusbar); + auto progressbar = GUI::ProgressBar::construct(statusbar); progressbar->set_caption("Generating thumbnails: "); - progressbar->set_format(GProgressBar::Format::ValueSlashMax); + progressbar->set_format(GUI::ProgressBar::Format::ValueSlashMax); progressbar->set_visible(false); progressbar->set_frame_shape(FrameShape::Panel); progressbar->set_frame_shadow(FrameShadow::Sunken); @@ -150,7 +150,7 @@ int main(int argc, char** argv) } // Reselect the existing folder in the tree. - auto new_index = directories_model->index(current_path, GFileSystemModel::Column::Name); + auto new_index = directories_model->index(current_path, GUI::FileSystemModel::Column::Name); tree_view->selection().set(new_index); tree_view->scroll_into_view(new_index, Orientation::Vertical); tree_view->update(); @@ -158,37 +158,37 @@ int main(int argc, char** argv) directory_view->refresh(); }; - auto directory_context_menu = GMenu::construct("Directory View Directory"); - auto file_context_menu = GMenu::construct("Directory View File"); - auto directory_view_context_menu = GMenu::construct("Directory View"); - auto tree_view_directory_context_menu = GMenu::construct("Tree View Directory"); - auto tree_view_context_menu = GMenu::construct("Tree View"); + auto directory_context_menu = GUI::Menu::construct("Directory View Directory"); + auto file_context_menu = GUI::Menu::construct("Directory View File"); + auto directory_view_context_menu = GUI::Menu::construct("Directory View"); + auto tree_view_directory_context_menu = GUI::Menu::construct("Tree View Directory"); + auto tree_view_context_menu = GUI::Menu::construct("Tree View"); - auto open_parent_directory_action = GAction::create("Open parent directory", { Mod_Alt, Key_Up }, GraphicsBitmap::load_from_file("/res/icons/16x16/open-parent-directory.png"), [&](const GAction&) { + auto open_parent_directory_action = GUI::Action::create("Open parent directory", { Mod_Alt, Key_Up }, GraphicsBitmap::load_from_file("/res/icons/16x16/open-parent-directory.png"), [&](const GUI::Action&) { directory_view->open_parent_directory(); }); - auto mkdir_action = GAction::create("New directory...", { Mod_Ctrl | Mod_Shift, Key_N }, GraphicsBitmap::load_from_file("/res/icons/16x16/mkdir.png"), [&](const GAction&) { - auto input_box = GInputBox::construct("Enter name:", "New directory", window); - if (input_box->exec() == GInputBox::ExecOK && !input_box->text_value().is_empty()) { + auto mkdir_action = GUI::Action::create("New directory...", { Mod_Ctrl | Mod_Shift, Key_N }, GraphicsBitmap::load_from_file("/res/icons/16x16/mkdir.png"), [&](const GUI::Action&) { + auto input_box = GUI::InputBox::construct("Enter name:", "New directory", window); + if (input_box->exec() == GUI::InputBox::ExecOK && !input_box->text_value().is_empty()) { auto new_dir_path = canonicalized_path( String::format("%s/%s", directory_view->path().characters(), input_box->text_value().characters())); int rc = mkdir(new_dir_path.characters(), 0777); if (rc < 0) { - GMessageBox::show(String::format("mkdir(\"%s\") failed: %s", new_dir_path.characters(), strerror(errno)), "Error", GMessageBox::Type::Error, GMessageBox::InputType::OK, window); + GUI::MessageBox::show(String::format("mkdir(\"%s\") failed: %s", new_dir_path.characters(), strerror(errno)), "Error", GUI::MessageBox::Type::Error, GUI::MessageBox::InputType::OK, window); } else { refresh_tree_view(); } } }); - RefPtr view_as_table_action; - RefPtr view_as_icons_action; - RefPtr view_as_columns_action; + RefPtr view_as_table_action; + RefPtr view_as_icons_action; + RefPtr view_as_columns_action; - view_as_table_action = GAction::create("Table view", { Mod_Ctrl, KeyCode::Key_L }, GraphicsBitmap::load_from_file("/res/icons/16x16/table-view.png"), [&](const GAction&) { + view_as_table_action = GUI::Action::create("Table view", { Mod_Ctrl, KeyCode::Key_L }, GraphicsBitmap::load_from_file("/res/icons/16x16/table-view.png"), [&](const GUI::Action&) { directory_view->set_view_mode(DirectoryView::ViewMode::List); view_as_table_action->set_checked(true); @@ -197,7 +197,7 @@ int main(int argc, char** argv) }, window); view_as_table_action->set_checkable(true); - view_as_icons_action = GAction::create("Icon view", { Mod_Ctrl, KeyCode::Key_I }, GraphicsBitmap::load_from_file("/res/icons/16x16/icon-view.png"), [&](const GAction&) { + view_as_icons_action = GUI::Action::create("Icon view", { Mod_Ctrl, KeyCode::Key_I }, GraphicsBitmap::load_from_file("/res/icons/16x16/icon-view.png"), [&](const GUI::Action&) { directory_view->set_view_mode(DirectoryView::ViewMode::Icon); view_as_icons_action->set_checked(true); @@ -206,7 +206,7 @@ int main(int argc, char** argv) }, window); view_as_icons_action->set_checkable(true); - view_as_columns_action = GAction::create("Columns view", GraphicsBitmap::load_from_file("/res/icons/16x16/columns-view.png"), [&](const GAction&) { + view_as_columns_action = GUI::Action::create("Columns view", GraphicsBitmap::load_from_file("/res/icons/16x16/columns-view.png"), [&](const GUI::Action&) { directory_view->set_view_mode(DirectoryView::ViewMode::Columns); view_as_columns_action->set_checked(true); @@ -215,7 +215,7 @@ int main(int argc, char** argv) }, window); view_as_columns_action->set_checkable(true); - auto view_type_action_group = make(); + auto view_type_action_group = make(); view_type_action_group->set_exclusive(true); view_type_action_group->add_action(*view_as_table_action); view_type_action_group->add_action(*view_as_icons_action); @@ -225,10 +225,10 @@ int main(int argc, char** argv) Vector paths; auto& view = directory_view->current_view(); auto& model = *view.model(); - view.selection().for_each_index([&](const GModelIndex& index) { + view.selection().for_each_index([&](const GUI::ModelIndex& index) { auto parent_index = model.parent_index(index); - auto name_index = model.index(index.row(), GFileSystemModel::Column::Name, parent_index); - auto path = model.data(name_index, GModel::Role::Custom).to_string(); + auto name_index = model.index(index.row(), GUI::FileSystemModel::Column::Name, parent_index); + auto path = model.data(name_index, GUI::Model::Role::Custom).to_string(); paths.append(path); }); return paths; @@ -237,17 +237,17 @@ int main(int argc, char** argv) auto tree_view_selected_file_paths = [&] { Vector paths; auto& view = tree_view; - view->selection().for_each_index([&](const GModelIndex& index) { + view->selection().for_each_index([&](const GUI::ModelIndex& index) { paths.append(directories_model->full_path(index)); }); return paths; }; - auto select_all_action = GAction::create("Select all", { Mod_Ctrl, KeyCode::Key_A }, [&](const GAction&) { + auto select_all_action = GUI::Action::create("Select all", { Mod_Ctrl, KeyCode::Key_A }, [&](const GUI::Action&) { directory_view->current_view().select_all(); }); - auto copy_action = GCommonActions::make_copy_action([&](const GAction& action) { + auto copy_action = GUI::CommonActions::make_copy_action([&](const GUI::Action& action) { Vector paths; if (action.activator() == directory_context_menu || directory_view->active_widget()->is_focused()) { paths = selected_file_paths(); @@ -260,12 +260,12 @@ int main(int argc, char** argv) for (auto& path : paths) { copy_text.appendf("%s\n", path.characters()); } - GClipboard::the().set_data(copy_text.build(), "file-list"); + GUI::Clipboard::the().set_data(copy_text.build(), "file-list"); }, window); copy_action->set_enabled(false); - auto paste_action = GCommonActions::make_paste_action([&](const GAction&) { - auto data_and_type = GClipboard::the().data_and_type(); + auto paste_action = GUI::CommonActions::make_paste_action([&](const GUI::Action&) { + auto data_and_type = GUI::Clipboard::the().data_and_type(); if (data_and_type.type != "file-list") { dbg() << "Cannot paste clipboard type " << data_and_type.type; return; @@ -285,20 +285,20 @@ int main(int argc, char** argv) if (!FileUtils::copy_file_or_directory(current_path, new_path)) { auto error_message = String::format("Could not paste %s.", current_path.characters()); - GMessageBox::show(error_message, "File Manager", GMessageBox::Type::Error); + GUI::MessageBox::show(error_message, "File Manager", GUI::MessageBox::Type::Error); } else { refresh_tree_view(); } } }, window); - paste_action->set_enabled(GClipboard::the().type() == "file-list"); + paste_action->set_enabled(GUI::Clipboard::the().type() == "file-list"); - GClipboard::the().on_content_change = [&](const String& data_type) { + GUI::Clipboard::the().on_content_change = [&](const String& data_type) { paste_action->set_enabled(data_type == "file-list"); }; auto properties_action - = GAction::create("Properties...", { Mod_Alt, Key_Return }, GraphicsBitmap::load_from_file("/res/icons/16x16/properties.png"), [&](const GAction& action) { + = GUI::Action::create("Properties...", { Mod_Alt, Key_Return }, GraphicsBitmap::load_from_file("/res/icons/16x16/properties.png"), [&](const GUI::Action& action) { auto& model = directory_view->model(); String path; Vector selected; @@ -325,7 +325,7 @@ int main(int argc, char** argv) Yes }; - auto do_delete = [&](ConfirmBeforeDelete confirm, const GAction& action) { + auto do_delete = [&](ConfirmBeforeDelete confirm, const GUI::Action& action) { Vector paths; if (action.activator() == directory_context_menu || directory_view->active_widget()->is_focused()) { paths = selected_file_paths(); @@ -343,13 +343,13 @@ int main(int argc, char** argv) } if (confirm == ConfirmBeforeDelete::Yes) { - auto result = GMessageBox::show( + auto result = GUI::MessageBox::show( message, "Confirm deletion", - GMessageBox::Type::Warning, - GMessageBox::InputType::OKCancel, + GUI::MessageBox::Type::Warning, + GUI::MessageBox::InputType::OKCancel, window); - if (result == GMessageBox::ExecCancel) + if (result == GUI::MessageBox::ExecCancel) return; } } @@ -357,11 +357,11 @@ int main(int argc, char** argv) for (auto& path : paths) { struct stat st; if (lstat(path.characters(), &st)) { - GMessageBox::show( + GUI::MessageBox::show( String::format("lstat(%s) failed: %s", path.characters(), strerror(errno)), "Delete failed", - GMessageBox::Type::Error, - GMessageBox::InputType::OK, + GUI::MessageBox::Type::Error, + GUI::MessageBox::InputType::OK, window); break; } else { @@ -373,11 +373,11 @@ int main(int argc, char** argv) int error = FileUtils::delete_directory(path, error_path); if (error) { - GMessageBox::show( + GUI::MessageBox::show( String::format("Failed to delete directory \"%s\": %s", error_path.characters(), strerror(error)), "Delete failed", - GMessageBox::Type::Error, - GMessageBox::InputType::OK, + GUI::MessageBox::Type::Error, + GUI::MessageBox::InputType::OK, window); break; } else { @@ -385,67 +385,67 @@ int main(int argc, char** argv) } } else if (unlink(path.characters()) < 0) { int saved_errno = errno; - GMessageBox::show( + GUI::MessageBox::show( String::format("unlink(%s) failed: %s", path.characters(), strerror(saved_errno)), "Delete failed", - GMessageBox::Type::Error, - GMessageBox::InputType::OK, + GUI::MessageBox::Type::Error, + GUI::MessageBox::InputType::OK, window); break; } } }; - auto force_delete_action = GAction::create("Delete without confirmation", { Mod_Shift, Key_Delete }, [&](const GAction& action) { + auto force_delete_action = GUI::Action::create("Delete without confirmation", { Mod_Shift, Key_Delete }, [&](const GUI::Action& action) { do_delete(ConfirmBeforeDelete::No, action); }, window); - auto delete_action = GCommonActions::make_delete_action([&](const GAction& action) { + auto delete_action = GUI::CommonActions::make_delete_action([&](const GUI::Action& action) { do_delete(ConfirmBeforeDelete::Yes, action); }, window); delete_action->set_enabled(false); - auto go_back_action = GCommonActions::make_go_back_action([&](auto&) { + auto go_back_action = GUI::CommonActions::make_go_back_action([&](auto&) { directory_view->open_previous_directory(); }, window); - auto go_forward_action = GCommonActions::make_go_forward_action([&](auto&) { + auto go_forward_action = GUI::CommonActions::make_go_forward_action([&](auto&) { directory_view->open_next_directory(); }, window); - auto go_home_action = GCommonActions::make_go_home_action([&](auto&) { + auto go_home_action = GUI::CommonActions::make_go_home_action([&](auto&) { directory_view->open(get_current_user_home_path()); }, window); - auto menubar = make(); + auto menubar = make(); - auto app_menu = GMenu::construct("File Manager"); + auto app_menu = GUI::Menu::construct("File Manager"); app_menu->add_action(mkdir_action); app_menu->add_action(copy_action); app_menu->add_action(paste_action); app_menu->add_action(delete_action); app_menu->add_separator(); - app_menu->add_action(GCommonActions::make_quit_action([](auto&) { - GApplication::the().quit(0); + app_menu->add_action(GUI::CommonActions::make_quit_action([](auto&) { + GUI::Application::the().quit(0); })); menubar->add_menu(move(app_menu)); - auto view_menu = GMenu::construct("View"); + auto view_menu = GUI::Menu::construct("View"); view_menu->add_action(*view_as_icons_action); view_menu->add_action(*view_as_table_action); view_menu->add_action(*view_as_columns_action); menubar->add_menu(move(view_menu)); - auto go_menu = GMenu::construct("Go"); + auto go_menu = GUI::Menu::construct("Go"); go_menu->add_action(go_back_action); go_menu->add_action(go_forward_action); go_menu->add_action(open_parent_directory_action); go_menu->add_action(go_home_action); menubar->add_menu(move(go_menu)); - auto help_menu = GMenu::construct("Help"); - help_menu->add_action(GAction::create("About", [&](const GAction&) { - GAboutDialog::show("File Manager", load_png("/res/icons/32x32/filetype-folder.png"), window); + auto help_menu = GUI::Menu::construct("Help"); + help_menu->add_action(GUI::Action::create("About", [&](const GUI::Action&) { + GUI::AboutDialog::show("File Manager", load_png("/res/icons/32x32/filetype-folder.png"), window); })); menubar->add_menu(move(help_menu)); @@ -470,7 +470,7 @@ int main(int argc, char** argv) directory_view->on_path_change = [&](const String& new_path) { window->set_title(String::format("File Manager: %s", new_path.characters())); location_textbox->set_text(new_path); - auto new_index = directories_model->index(new_path, GFileSystemModel::Column::Name); + auto new_index = directories_model->index(new_path, GUI::FileSystemModel::Column::Name); if (new_index.is_valid()) { tree_view->selection().set(new_index); tree_view->scroll_into_view(new_index, Orientation::Vertical); @@ -496,13 +496,13 @@ int main(int argc, char** argv) progressbar->set_visible(true); }; - directory_view->on_selection_change = [&](GAbstractView& view) { + directory_view->on_selection_change = [&](GUI::AbstractView& view) { // FIXME: Figure out how we can enable/disable the paste action, based on clipboard contents. copy_action->set_enabled(!view.selection().is_empty()); delete_action->set_enabled(!view.selection().is_empty()); }; - auto open_in_text_editor_action = GAction::create("Open in TextEditor...", GraphicsBitmap::load_from_file("/res/icons/TextEditor16.png"), [&](auto&) { + auto open_in_text_editor_action = GUI::Action::create("Open in TextEditor...", GraphicsBitmap::load_from_file("/res/icons/TextEditor16.png"), [&](auto&) { for (auto& path : selected_file_paths()) { if (!fork()) { int rc = execl("/bin/TextEditor", "TextEditor", path.characters(), nullptr); @@ -537,7 +537,7 @@ int main(int argc, char** argv) tree_view_directory_context_menu->add_separator(); tree_view_directory_context_menu->add_action(mkdir_action); - directory_view->on_context_menu_request = [&](const GAbstractView&, const GModelIndex& index, const GContextMenuEvent& event) { + directory_view->on_context_menu_request = [&](const GUI::AbstractView&, const GUI::ModelIndex& index, const GUI::ContextMenuEvent& event) { if (index.is_valid()) { auto& node = directory_view->model().node(index); @@ -559,7 +559,7 @@ int main(int argc, char** argv) delete_action->set_enabled(!tree_view->selection().is_empty()); }; - tree_view->on_context_menu_request = [&](const GModelIndex& index, const GContextMenuEvent& event) { + tree_view->on_context_menu_request = [&](const GUI::ModelIndex& index, const GUI::ContextMenuEvent& event) { if (index.is_valid()) { tree_view_directory_context_menu->popup(event.screen_position()); } @@ -611,7 +611,7 @@ int main(int argc, char** argv) config->write_num_entry("Window", "Heigth", window->height()); config->sync(); - return GWindow::CloseRequestDecision::Close; + return GUI::Window::CloseRequestDecision::Close; }; return app.exec(); diff --git a/Applications/FontEditor/FontEditor.cpp b/Applications/FontEditor/FontEditor.cpp index 2983a187ef8..815ab629d5d 100644 --- a/Applications/FontEditor/FontEditor.cpp +++ b/Applications/FontEditor/FontEditor.cpp @@ -38,8 +38,8 @@ #include #include -FontEditorWidget::FontEditorWidget(const String& path, RefPtr&& edited_font, GWidget* parent) - : GWidget(parent) +FontEditorWidget::FontEditorWidget(const String& path, RefPtr&& edited_font, GUI::Widget* parent) + : GUI::Widget(parent) , m_edited_font(move(edited_font)) { set_fill_with_background_color(true); @@ -75,7 +75,7 @@ FontEditorWidget::FontEditorWidget(const String& path, RefPtr&& edited_fon }; m_ui->save_button->set_text("Save"); - m_ui->save_button->on_click = [this](GButton&) { + m_ui->save_button->on_click = [this](GUI::Button&) { dbgprintf("write to file: '%s'\n", m_path.characters()); m_edited_font->write_to_file(m_path); }; diff --git a/Applications/FontEditor/FontEditor.h b/Applications/FontEditor/FontEditor.h index b5bbab55148..163ad3efd88 100644 --- a/Applications/FontEditor/FontEditor.h +++ b/Applications/FontEditor/FontEditor.h @@ -31,17 +31,16 @@ class GlyphEditorWidget; class GlyphMapWidget; -class GTextBox; struct UI_FontEditorBottom; -class FontEditorWidget final : public GWidget { +class FontEditorWidget final : public GUI::Widget { C_OBJECT(FontEditorWidget) public: virtual ~FontEditorWidget() override; private: - FontEditorWidget(const String& path, RefPtr&&, GWidget* parent = nullptr); + FontEditorWidget(const String& path, RefPtr&&, GUI::Widget* parent = nullptr); RefPtr m_edited_font; GlyphMapWidget* m_glyph_map_widget { nullptr }; diff --git a/Applications/FontEditor/FontEditorBottom.frm b/Applications/FontEditor/FontEditorBottom.frm index d0c12834a88..d690a27797f 100644 --- a/Applications/FontEditor/FontEditorBottom.frm +++ b/Applications/FontEditor/FontEditorBottom.frm @@ -1 +1 @@ -{"name":"FontEditorBottom","widgets":[{"enabled":true,"forecolor":"#000000ff","autofill":false,"x":5,"tooltip":"[null]","name":"info_label","height":16,"width":66,"y":15,"class":"GLabel","text":"info_label","backcolor":"#d4d0c8ff","visible":true},{"enabled":true,"forecolor":"#00000000","autofill":false,"x":95,"tooltip":null,"name":"demo_label_1","height":16,"width":276,"y":15,"class":"GLabel","text":"demo_label_1","backcolor":"#00000000","visible":true},{"enabled":true,"forecolor":"#00000000","autofill":false,"x":95,"tooltip":null,"name":"demo_label_2","height":16,"width":276,"y":40,"class":"GLabel","text":"demo_label_2","backcolor":"#00000000","visible":true},{"enabled":true,"forecolor":"#00000000","autofill":false,"x":5,"tooltip":null,"name":"label1","height":16,"width":66,"y":40,"class":"GLabel","text":"Glyph width:","backcolor":"#00000000","visible":true},{"forecolor":"#00000000","name":"width_spinbox","height":21,"backcolor":"#00000000","enabled":true,"value":0,"tooltip":null,"max":32,"visible":true,"y":60,"width":71,"autofill":false,"x":5,"class":"GSpinBox","min":0},{"enabled":true,"forecolor":"#00000000","autofill":false,"x":5,"tooltip":null,"name":"gb1","height":76,"width":300,"y":95,"class":"GGroupBox","backcolor":"#d4d0c8ff","title":"Font metadata","visible":true},{"enabled":true,"forecolor":"#00000000","autofill":false,"x":15,"tooltip":null,"name":"label2","height":16,"width":40,"y":105,"class":"GLabel","text":"Name:","backcolor":"#00000000","visible":true},{"tooltip":null,"forecolor":"#00000000","name":"name_textbox","y":120,"autofill":false,"x":15,"class":"GTextBox","backcolor":"#00000000","ruler_visible":false,"height":21,"enabled":true,"text":"","visible":true,"width":196},{"enabled":true,"forecolor":"#00000000","autofill":false,"x":215,"tooltip":null,"name":"label3","height":16,"width":80,"y":105,"class":"GLabel","text":"Glyph spacing:","backcolor":"#00000000","visible":true},{"forecolor":"#00000000","name":"spacing_spinbox","height":21,"backcolor":"#00000000","enabled":true,"value":0,"tooltip":null,"max":255,"visible":true,"y":120,"width":80,"autofill":false,"x":215,"class":"GSpinBox","min":0},{"tooltip":null,"checked":false,"forecolor":"#00000000","name":"fixed_width_checkbox","y":145,"autofill":false,"x":15,"class":"GCheckBox","backcolor":"#00000000","height":21,"enabled":true,"text":"Fixed width","visible":true,"width":101},{"tooltip":null,"forecolor":"#00000000","name":"path_textbox","y":175,"autofill":false,"x":5,"class":"GTextBox","backcolor":"#00000000","ruler_visible":false,"height":21,"enabled":true,"text":"","visible":true,"width":216},{"enabled":true,"forecolor":"#00000000","autofill":false,"x":5,"tooltip":null,"name":"save_button","height":21,"width":106,"y":205,"class":"GButton","text":"Save","backcolor":"#00000000","visible":true},{"enabled":true,"forecolor":"#00000000","autofill":false,"x":115,"tooltip":null,"name":"quit_button","height":21,"width":106,"y":205,"class":"GButton","text":"Quit","backcolor":"#00000000","visible":true}]} +{"name":"FontEditorBottom","widgets":[{"enabled":true,"forecolor":"#000000ff","autofill":false,"x":5,"tooltip":"[null]","name":"info_label","height":16,"width":66,"y":15,"class":"GUI::Label","text":"info_label","backcolor":"#d4d0c8ff","visible":true},{"enabled":true,"forecolor":"#00000000","autofill":false,"x":95,"tooltip":null,"name":"demo_label_1","height":16,"width":276,"y":15,"class":"GUI::Label","text":"demo_label_1","backcolor":"#00000000","visible":true},{"enabled":true,"forecolor":"#00000000","autofill":false,"x":95,"tooltip":null,"name":"demo_label_2","height":16,"width":276,"y":40,"class":"GUI::Label","text":"demo_label_2","backcolor":"#00000000","visible":true},{"enabled":true,"forecolor":"#00000000","autofill":false,"x":5,"tooltip":null,"name":"label1","height":16,"width":66,"y":40,"class":"GUI::Label","text":"Glyph width:","backcolor":"#00000000","visible":true},{"forecolor":"#00000000","name":"width_spinbox","height":21,"backcolor":"#00000000","enabled":true,"value":0,"tooltip":null,"max":32,"visible":true,"y":60,"width":71,"autofill":false,"x":5,"class":"GUI::SpinBox","min":0},{"enabled":true,"forecolor":"#00000000","autofill":false,"x":5,"tooltip":null,"name":"gb1","height":76,"width":300,"y":95,"class":"GUI::GroupBox","backcolor":"#d4d0c8ff","title":"Font metadata","visible":true},{"enabled":true,"forecolor":"#00000000","autofill":false,"x":15,"tooltip":null,"name":"label2","height":16,"width":40,"y":105,"class":"GUI::Label","text":"Name:","backcolor":"#00000000","visible":true},{"tooltip":null,"forecolor":"#00000000","name":"name_textbox","y":120,"autofill":false,"x":15,"class":"GUI::TextBox","backcolor":"#00000000","ruler_visible":false,"height":21,"enabled":true,"text":"","visible":true,"width":196},{"enabled":true,"forecolor":"#00000000","autofill":false,"x":215,"tooltip":null,"name":"label3","height":16,"width":80,"y":105,"class":"GUI::Label","text":"Glyph spacing:","backcolor":"#00000000","visible":true},{"forecolor":"#00000000","name":"spacing_spinbox","height":21,"backcolor":"#00000000","enabled":true,"value":0,"tooltip":null,"max":255,"visible":true,"y":120,"width":80,"autofill":false,"x":215,"class":"GUI::SpinBox","min":0},{"tooltip":null,"checked":false,"forecolor":"#00000000","name":"fixed_width_checkbox","y":145,"autofill":false,"x":15,"class":"GUI::CheckBox","backcolor":"#00000000","height":21,"enabled":true,"text":"Fixed width","visible":true,"width":101},{"tooltip":null,"forecolor":"#00000000","name":"path_textbox","y":175,"autofill":false,"x":5,"class":"GUI::TextBox","backcolor":"#00000000","ruler_visible":false,"height":21,"enabled":true,"text":"","visible":true,"width":216},{"enabled":true,"forecolor":"#00000000","autofill":false,"x":5,"tooltip":null,"name":"save_button","height":21,"width":106,"y":205,"class":"GUI::Button","text":"Save","backcolor":"#00000000","visible":true},{"enabled":true,"forecolor":"#00000000","autofill":false,"x":115,"tooltip":null,"name":"quit_button","height":21,"width":106,"y":205,"class":"GUI::Button","text":"Quit","backcolor":"#00000000","visible":true}]} diff --git a/Applications/FontEditor/GlyphEditorWidget.cpp b/Applications/FontEditor/GlyphEditorWidget.cpp index 672808ce725..44ac553de91 100644 --- a/Applications/FontEditor/GlyphEditorWidget.cpp +++ b/Applications/FontEditor/GlyphEditorWidget.cpp @@ -27,8 +27,8 @@ #include "GlyphEditorWidget.h" #include -GlyphEditorWidget::GlyphEditorWidget(Font& mutable_font, GWidget* parent) - : GFrame(parent) +GlyphEditorWidget::GlyphEditorWidget(Font& mutable_font, GUI::Widget* parent) + : GUI::Frame(parent) , m_font(mutable_font) { set_frame_thickness(2); @@ -49,11 +49,11 @@ void GlyphEditorWidget::set_glyph(u8 glyph) update(); } -void GlyphEditorWidget::paint_event(GPaintEvent& event) +void GlyphEditorWidget::paint_event(GUI::PaintEvent& event) { - GFrame::paint_event(event); + GUI::Frame::paint_event(event); - GPainter painter(*this); + GUI::Painter painter(*this); painter.add_clip_rect(frame_inner_rect()); painter.add_clip_rect(event.rect()); painter.fill_rect(frame_inner_rect(), Color::White); @@ -81,21 +81,21 @@ void GlyphEditorWidget::paint_event(GPaintEvent& event) } } -void GlyphEditorWidget::mousedown_event(GMouseEvent& event) +void GlyphEditorWidget::mousedown_event(GUI::MouseEvent& event) { draw_at_mouse(event); } -void GlyphEditorWidget::mousemove_event(GMouseEvent& event) +void GlyphEditorWidget::mousemove_event(GUI::MouseEvent& event) { - if (event.buttons() & (GMouseButton::Left | GMouseButton::Right)) + if (event.buttons() & (GUI::MouseButton::Left | GUI::MouseButton::Right)) draw_at_mouse(event); } -void GlyphEditorWidget::draw_at_mouse(const GMouseEvent& event) +void GlyphEditorWidget::draw_at_mouse(const GUI::MouseEvent& event) { - bool set = event.buttons() & GMouseButton::Left; - bool unset = event.buttons() & GMouseButton::Right; + bool set = event.buttons() & GUI::MouseButton::Left; + bool unset = event.buttons() & GUI::MouseButton::Right; if (!(set ^ unset)) return; int x = (event.x() - 1) / m_scale; diff --git a/Applications/FontEditor/GlyphEditorWidget.h b/Applications/FontEditor/GlyphEditorWidget.h index 8bba197a8e6..a54258aabdc 100644 --- a/Applications/FontEditor/GlyphEditorWidget.h +++ b/Applications/FontEditor/GlyphEditorWidget.h @@ -27,7 +27,7 @@ #include #include -class GlyphEditorWidget final : public GFrame { +class GlyphEditorWidget final : public GUI::Frame { C_OBJECT(GlyphEditorWidget) public: virtual ~GlyphEditorWidget() override; @@ -44,12 +44,12 @@ public: Function on_glyph_altered; private: - GlyphEditorWidget(Font&, GWidget* parent); - virtual void paint_event(GPaintEvent&) override; - virtual void mousedown_event(GMouseEvent&) override; - virtual void mousemove_event(GMouseEvent&) override; + GlyphEditorWidget(Font&, GUI::Widget* parent); + virtual void paint_event(GUI::PaintEvent&) override; + virtual void mousedown_event(GUI::MouseEvent&) override; + virtual void mousemove_event(GUI::MouseEvent&) override; - void draw_at_mouse(const GMouseEvent&); + void draw_at_mouse(const GUI::MouseEvent&); RefPtr m_font; u8 m_glyph { 0 }; diff --git a/Applications/FontEditor/GlyphMapWidget.cpp b/Applications/FontEditor/GlyphMapWidget.cpp index 5524ece6673..95ac188514c 100644 --- a/Applications/FontEditor/GlyphMapWidget.cpp +++ b/Applications/FontEditor/GlyphMapWidget.cpp @@ -28,8 +28,8 @@ #include #include -GlyphMapWidget::GlyphMapWidget(Font& mutable_font, GWidget* parent) - : GFrame(parent) +GlyphMapWidget::GlyphMapWidget(Font& mutable_font, GUI::Widget* parent) + : GUI::Frame(parent) , m_font(mutable_font) { set_frame_thickness(2); @@ -80,11 +80,11 @@ void GlyphMapWidget::update_glyph(u8 glyph) update(get_outer_rect(glyph)); } -void GlyphMapWidget::paint_event(GPaintEvent& event) +void GlyphMapWidget::paint_event(GUI::PaintEvent& event) { - GFrame::paint_event(event); + GUI::Frame::paint_event(event); - GPainter painter(*this); + GUI::Painter painter(*this); painter.add_clip_rect(event.rect()); painter.set_font(font()); @@ -110,7 +110,7 @@ void GlyphMapWidget::paint_event(GPaintEvent& event) } } -void GlyphMapWidget::mousedown_event(GMouseEvent& event) +void GlyphMapWidget::mousedown_event(GUI::MouseEvent& event) { // FIXME: This is a silly loop. for (unsigned glyph = 0; glyph < 256; ++glyph) { diff --git a/Applications/FontEditor/GlyphMapWidget.h b/Applications/FontEditor/GlyphMapWidget.h index 197ca6528b9..0ad9884e34e 100644 --- a/Applications/FontEditor/GlyphMapWidget.h +++ b/Applications/FontEditor/GlyphMapWidget.h @@ -29,7 +29,7 @@ #include #include -class GlyphMapWidget final : public GFrame { +class GlyphMapWidget final : public GUI::Frame { C_OBJECT(GlyphMapWidget) public: virtual ~GlyphMapWidget() override; @@ -51,9 +51,9 @@ public: Function on_glyph_selected; private: - GlyphMapWidget(Font&, GWidget* parent); - virtual void paint_event(GPaintEvent&) override; - virtual void mousedown_event(GMouseEvent&) override; + GlyphMapWidget(Font&, GUI::Widget* parent); + virtual void paint_event(GUI::PaintEvent&) override; + virtual void mousedown_event(GUI::MouseEvent&) override; Rect get_outer_rect(u8 glyph) const; diff --git a/Applications/FontEditor/main.cpp b/Applications/FontEditor/main.cpp index 09a25888347..94819dd3cbb 100644 --- a/Applications/FontEditor/main.cpp +++ b/Applications/FontEditor/main.cpp @@ -40,7 +40,7 @@ int main(int argc, char** argv) return 1; } - GApplication app(argc, argv); + GUI::Application app(argc, argv); if (pledge("stdio shared_buffer rpath accept cpath wpath", nullptr) < 0) { perror("pledge"); @@ -64,7 +64,7 @@ int main(int argc, char** argv) else edited_font = Font::default_font().clone(); - auto window = GWindow::construct(); + auto window = GUI::Window::construct(); window->set_title("Font Editor"); window->set_rect({ 50, 50, 390, 342 }); @@ -73,18 +73,18 @@ int main(int argc, char** argv) window->show(); window->set_icon(load_png("/res/icons/16x16/app-font-editor.png")); - auto menubar = make(); + auto menubar = make(); - auto app_menu = GMenu::construct("Font Editor"); - app_menu->add_action(GCommonActions::make_quit_action([](auto&) { - GApplication::the().quit(0); + auto app_menu = GUI::Menu::construct("Font Editor"); + app_menu->add_action(GUI::CommonActions::make_quit_action([](auto&) { + GUI::Application::the().quit(0); return; })); menubar->add_menu(move(app_menu)); - auto help_menu = GMenu::construct("Help"); - help_menu->add_action(GAction::create("About", [&](const GAction&) { - GAboutDialog::show("Font Editor", load_png("/res/icons/FontEditor.png"), window); + auto help_menu = GUI::Menu::construct("Help"); + help_menu->add_action(GUI::Action::create("About", [&](const GUI::Action&) { + GUI::AboutDialog::show("Font Editor", load_png("/res/icons/FontEditor.png"), window); })); menubar->add_menu(move(help_menu)); diff --git a/Applications/Help/ManualModel.cpp b/Applications/Help/ManualModel.cpp index 8086c597826..12fbd317260 100644 --- a/Applications/Help/ManualModel.cpp +++ b/Applications/Help/ManualModel.cpp @@ -48,7 +48,7 @@ ManualModel::ManualModel() m_page_icon.set_bitmap_for_size(16, load_png("/res/icons/16x16/filetype-unknown.png")); } -String ManualModel::page_path(const GModelIndex& index) const +String ManualModel::page_path(const GUI::ModelIndex& index) const { if (!index.is_valid()) return {}; @@ -59,7 +59,7 @@ String ManualModel::page_path(const GModelIndex& index) const return page->path(); } -String ManualModel::page_and_section(const GModelIndex& index) const +String ManualModel::page_and_section(const GUI::ModelIndex& index) const { if (!index.is_valid()) return {}; @@ -71,7 +71,7 @@ String ManualModel::page_and_section(const GModelIndex& index) const return String::format("%s(%s)", page->name().characters(), section->section_name().characters()); } -GModelIndex ManualModel::index(int row, int column, const GModelIndex& parent_index) const +GUI::ModelIndex ManualModel::index(int row, int column, const GUI::ModelIndex& parent_index) const { if (!parent_index.is_valid()) return create_index(row, column, &s_sections[row]); @@ -80,7 +80,7 @@ GModelIndex ManualModel::index(int row, int column, const GModelIndex& parent_in return create_index(row, column, child); } -GModelIndex ManualModel::parent_index(const GModelIndex& index) const +GUI::ModelIndex ManualModel::parent_index(const GUI::ModelIndex& index) const { if (!index.is_valid()) return {}; @@ -103,7 +103,7 @@ GModelIndex ManualModel::parent_index(const GModelIndex& index) const ASSERT_NOT_REACHED(); } -int ManualModel::row_count(const GModelIndex& index) const +int ManualModel::row_count(const GUI::ModelIndex& index) const { if (!index.is_valid()) return sizeof(s_sections) / sizeof(s_sections[0]); @@ -111,12 +111,12 @@ int ManualModel::row_count(const GModelIndex& index) const return node->children().size(); } -int ManualModel::column_count(const GModelIndex&) const +int ManualModel::column_count(const GUI::ModelIndex&) const { return 1; } -GVariant ManualModel::data(const GModelIndex& index, Role role) const +GUI::Variant ManualModel::data(const GUI::ModelIndex& index, Role role) const { auto* node = static_cast(index.internal_data()); switch (role) { diff --git a/Applications/Help/ManualModel.h b/Applications/Help/ManualModel.h index 52e9b67ad61..e2435e4cbb6 100644 --- a/Applications/Help/ManualModel.h +++ b/Applications/Help/ManualModel.h @@ -30,7 +30,7 @@ #include #include -class ManualModel final : public GModel { +class ManualModel final : public GUI::Model { public: static NonnullRefPtr create() { @@ -39,15 +39,15 @@ public: virtual ~ManualModel() override {}; - String page_path(const GModelIndex&) const; - String page_and_section(const GModelIndex&) const; + String page_path(const GUI::ModelIndex&) const; + String page_and_section(const GUI::ModelIndex&) const; - virtual int row_count(const GModelIndex& = GModelIndex()) const override; - virtual int column_count(const GModelIndex& = GModelIndex()) const override; - virtual GVariant data(const GModelIndex&, Role = Role::Display) const override; + virtual int row_count(const GUI::ModelIndex& = GUI::ModelIndex()) const override; + virtual int column_count(const GUI::ModelIndex& = GUI::ModelIndex()) const override; + virtual GUI::Variant data(const GUI::ModelIndex&, Role = Role::Display) const override; virtual void update() override; - virtual GModelIndex parent_index(const GModelIndex&) const override; - virtual GModelIndex index(int row, int column = 0, const GModelIndex& parent = GModelIndex()) const override; + virtual GUI::ModelIndex parent_index(const GUI::ModelIndex&) const override; + virtual GUI::ModelIndex index(int row, int column = 0, const GUI::ModelIndex& parent = GUI::ModelIndex()) const override; private: ManualModel(); diff --git a/Applications/Help/main.cpp b/Applications/Help/main.cpp index 8a174af4aef..69e50ed37e4 100644 --- a/Applications/Help/main.cpp +++ b/Applications/Help/main.cpp @@ -55,7 +55,7 @@ int main(int argc, char* argv[]) return 1; } - GApplication app(argc, argv); + GUI::Application app(argc, argv); if (pledge("stdio shared_buffer accept rpath", nullptr) < 0) { perror("pledge"); @@ -74,31 +74,31 @@ int main(int argc, char* argv[]) unveil(nullptr, nullptr); - auto window = GWindow::construct(); + auto window = GUI::Window::construct(); window->set_title("Help"); window->set_rect(300, 200, 570, 500); - auto widget = GWidget::construct(); - widget->set_layout(make()); + auto widget = GUI::Widget::construct(); + widget->set_layout(make()); widget->layout()->set_spacing(0); - auto toolbar = GToolBar::construct(widget); + auto toolbar = GUI::ToolBar::construct(widget); - auto splitter = GSplitter::construct(Orientation::Horizontal, widget); + auto splitter = GUI::Splitter::construct(Orientation::Horizontal, widget); auto model = ManualModel::create(); - auto tree_view = GTreeView::construct(splitter); + auto tree_view = GUI::TreeView::construct(splitter); tree_view->set_model(model); - tree_view->set_size_policy(SizePolicy::Fixed, SizePolicy::Fill); + tree_view->set_size_policy(GUI::SizePolicy::Fixed, GUI::SizePolicy::Fill); tree_view->set_preferred_size(200, 500); auto html_view = HtmlView::construct(splitter); History history; - RefPtr go_back_action; - RefPtr go_forward_action; + RefPtr go_back_action; + RefPtr go_forward_action; auto update_actions = [&]() { go_back_action->set_enabled(history.can_go_back()); @@ -118,7 +118,7 @@ int main(int argc, char* argv[]) if (!file->open(Core::IODevice::OpenMode::ReadOnly)) { int saved_errno = errno; - GMessageBox::show(strerror(saved_errno), "Failed to open man page", GMessageBox::Type::Error, GMessageBox::InputType::OK, window); + GUI::MessageBox::show(strerror(saved_errno), "Failed to open man page", GUI::MessageBox::Type::Error, GUI::MessageBox::InputType::OK, window); return; } auto buffer = file->read_all(); @@ -158,13 +158,13 @@ int main(int argc, char* argv[]) free(path); }; - go_back_action = GCommonActions::make_go_back_action([&](auto&) { + go_back_action = GUI::CommonActions::make_go_back_action([&](auto&) { history.go_back(); update_actions(); open_page(history.current()); }); - go_forward_action = GCommonActions::make_go_forward_action([&](auto&) { + go_forward_action = GUI::CommonActions::make_go_forward_action([&](auto&) { history.go_forward(); update_actions(); open_page(history.current()); @@ -176,19 +176,19 @@ int main(int argc, char* argv[]) toolbar->add_action(*go_back_action); toolbar->add_action(*go_forward_action); - auto menubar = make(); + auto menubar = make(); - auto app_menu = GMenu::construct("Help"); - app_menu->add_action(GAction::create("About", [&](const GAction&) { - GAboutDialog::show("Help", load_png("/res/icons/16x16/book.png"), window); + auto app_menu = GUI::Menu::construct("Help"); + app_menu->add_action(GUI::Action::create("About", [&](const GUI::Action&) { + GUI::AboutDialog::show("Help", load_png("/res/icons/16x16/book.png"), window); })); app_menu->add_separator(); - app_menu->add_action(GCommonActions::make_quit_action([](auto&) { - GApplication::the().quit(0); + app_menu->add_action(GUI::CommonActions::make_quit_action([](auto&) { + GUI::Application::the().quit(0); })); menubar->add_menu(move(app_menu)); - auto go_menu = GMenu::construct("Go"); + auto go_menu = GUI::Menu::construct("Go"); go_menu->add_action(*go_back_action); go_menu->add_action(*go_forward_action); menubar->add_menu(move(go_menu)); diff --git a/Applications/HexEditor/HexEditor.cpp b/Applications/HexEditor/HexEditor.cpp index d5f3514ce2b..a965009484d 100644 --- a/Applications/HexEditor/HexEditor.cpp +++ b/Applications/HexEditor/HexEditor.cpp @@ -41,8 +41,8 @@ #include #include -HexEditor::HexEditor(GWidget* parent) - : GScrollableWidget(parent) +HexEditor::HexEditor(GUI::Widget* parent) + : ScrollableWidget(parent) { set_frame_shape(FrameShape::Container); set_frame_shadow(FrameShadow::Sunken); @@ -139,7 +139,7 @@ bool HexEditor::copy_selected_hex_to_clipboard() output_string_builder.appendf("%02X ", m_buffer.data()[i]); } - GClipboard::the().set_data(output_string_builder.to_string()); + GUI::Clipboard::the().set_data(output_string_builder.to_string()); return true; } @@ -153,7 +153,7 @@ bool HexEditor::copy_selected_text_to_clipboard() output_string_builder.appendf("%c", isprint(m_buffer.data()[i]) ? m_buffer[i] : '.'); } - GClipboard::the().set_data(output_string_builder.to_string()); + GUI::Clipboard::the().set_data(output_string_builder.to_string()); return true; } @@ -176,7 +176,7 @@ bool HexEditor::copy_selected_hex_to_clipboard_as_c_code() } output_string_builder.append("\n};\n"); - GClipboard::the().set_data(output_string_builder.to_string()); + GUI::Clipboard::the().set_data(output_string_builder.to_string()); return true; } @@ -195,9 +195,9 @@ void HexEditor::set_content_length(int length) set_content_size({ offset_margin_width() + (m_bytes_per_row * (character_width() * 3)) + 10 + (m_bytes_per_row * character_width()) + 20, total_rows() * line_height() + 10 }); } -void HexEditor::mousedown_event(GMouseEvent& event) +void HexEditor::mousedown_event(GUI::MouseEvent& event) { - if (event.button() != GMouseButton::Left) { + if (event.button() != GUI::MouseButton::Left) { return; } @@ -259,7 +259,7 @@ void HexEditor::mousedown_event(GMouseEvent& event) } } -void HexEditor::mousemove_event(GMouseEvent& event) +void HexEditor::mousemove_event(GUI::MouseEvent& event) { auto absolute_x = horizontal_scrollbar().value() + event.x(); auto absolute_y = vertical_scrollbar().value() + event.y(); @@ -274,12 +274,12 @@ void HexEditor::mousemove_event(GMouseEvent& event) auto text_end_x = text_start_x + (bytes_per_row() * character_width()); auto text_end_y = text_start_y + 5 + (total_rows() * line_height()); - window()->set_override_cursor(GStandardCursor::None); + window()->set_override_cursor(GUI::StandardCursor::None); if ((absolute_x >= hex_start_x && absolute_x <= hex_end_x && absolute_y >= hex_start_y && absolute_y <= hex_end_y) || (absolute_x >= text_start_x && absolute_x <= text_end_x && absolute_y >= text_start_y && absolute_y <= text_end_y)) { - window()->set_override_cursor(GStandardCursor::IBeam); + window()->set_override_cursor(GUI::StandardCursor::IBeam); } if (m_in_drag_select) { @@ -311,9 +311,9 @@ void HexEditor::mousemove_event(GMouseEvent& event) } } -void HexEditor::mouseup_event(GMouseEvent& event) +void HexEditor::mouseup_event(GUI::MouseEvent& event) { - if (event.button() == GMouseButton::Left) { + if (event.button() == GUI::MouseButton::Left) { if (m_in_drag_select) { if (m_selection_end == -1 || m_selection_start == -1) { m_selection_start = -1; @@ -344,7 +344,7 @@ void HexEditor::scroll_position_into_view(int position) scroll_into_view(rect, true, true); } -void HexEditor::keydown_event(GKeyEvent& event) +void HexEditor::keydown_event(GUI::KeyEvent& event) { #ifdef HEX_DEBUG printf("HexEditor::keydown_event key=%d\n", event.key()); @@ -414,7 +414,7 @@ void HexEditor::keydown_event(GKeyEvent& event) } } -void HexEditor::hex_mode_keydown_event(GKeyEvent& event) +void HexEditor::hex_mode_keydown_event(GUI::KeyEvent& event) { if ((event.key() >= KeyCode::Key_0 && event.key() <= KeyCode::Key_9) || (event.key() >= KeyCode::Key_A && event.key() <= KeyCode::Key_F)) { @@ -439,7 +439,7 @@ void HexEditor::hex_mode_keydown_event(GKeyEvent& event) } } -void HexEditor::text_mode_keydown_event(GKeyEvent& event) +void HexEditor::text_mode_keydown_event(GUI::KeyEvent& event) { m_tracked_changes.set(m_position, m_buffer.data()[m_position]); m_buffer.data()[m_position] = (u8)event.text().characters()[0]; // save the first 4 bits, OR the new value in the last 4 @@ -462,11 +462,11 @@ void HexEditor::did_change() on_change(); } -void HexEditor::paint_event(GPaintEvent& event) +void HexEditor::paint_event(GUI::PaintEvent& event) { - GFrame::paint_event(event); + GUI::Frame::paint_event(event); - GPainter painter(*this); + GUI::Painter painter(*this); painter.add_clip_rect(widget_inner_rect()); painter.add_clip_rect(event.rect()); painter.fill_rect(event.rect(), Color::White); @@ -567,5 +567,5 @@ void HexEditor::paint_event(GPaintEvent& event) void HexEditor::leave_event(Core::Event&) { ASSERT(window()); - window()->set_override_cursor(GStandardCursor::None); + window()->set_override_cursor(GUI::StandardCursor::None); } diff --git a/Applications/HexEditor/HexEditor.h b/Applications/HexEditor/HexEditor.h index f570e0406ef..78b1bbd95bd 100644 --- a/Applications/HexEditor/HexEditor.h +++ b/Applications/HexEditor/HexEditor.h @@ -34,7 +34,7 @@ #include #include -class HexEditor : public GScrollableWidget { +class HexEditor : public GUI::ScrollableWidget { C_OBJECT(HexEditor) public: enum EditMode { @@ -65,13 +65,13 @@ public: Function on_change; protected: - HexEditor(GWidget* parent); + HexEditor(GUI::Widget* parent); - virtual void paint_event(GPaintEvent&) override; - virtual void mousedown_event(GMouseEvent&) override; - virtual void mouseup_event(GMouseEvent&) override; - virtual void mousemove_event(GMouseEvent&) override; - virtual void keydown_event(GKeyEvent&) override; + virtual void paint_event(GUI::PaintEvent&) override; + virtual void mousedown_event(GUI::MouseEvent&) override; + virtual void mouseup_event(GUI::MouseEvent&) override; + virtual void mousemove_event(GUI::MouseEvent&) override; + virtual void keydown_event(GUI::KeyEvent&) override; virtual bool accepts_focus() const override { return true; } virtual void leave_event(Core::Event&) override; @@ -97,10 +97,10 @@ private: int character_width() const { return font().glyph_width('W'); } int offset_margin_width() const { return 80; } - void hex_mode_keydown_event(GKeyEvent&); - void text_mode_keydown_event(GKeyEvent&); + void hex_mode_keydown_event(GUI::KeyEvent&); + void text_mode_keydown_event(GUI::KeyEvent&); void set_content_length(int); // I might make this public if I add fetching data on demand. void update_status(); void did_change(); -}; \ No newline at end of file +}; diff --git a/Applications/HexEditor/HexEditorWidget.cpp b/Applications/HexEditor/HexEditorWidget.cpp index 240e0bfdd50..eb548ba7b47 100644 --- a/Applications/HexEditor/HexEditorWidget.cpp +++ b/Applications/HexEditor/HexEditorWidget.cpp @@ -46,7 +46,7 @@ HexEditorWidget::HexEditorWidget() { - set_layout(make()); + set_layout(make()); layout()->set_spacing(0); m_editor = HexEditor::construct(this); @@ -66,20 +66,20 @@ HexEditorWidget::HexEditorWidget() update_title(); }; - m_statusbar = GStatusBar::construct(5, this); + m_statusbar = GUI::StatusBar::construct(5, this); - m_new_action = GAction::create("New", { Mod_Ctrl, Key_N }, GraphicsBitmap::load_from_file("/res/icons/16x16/new.png"), [this](const GAction&) { + m_new_action = GUI::Action::create("New", { Mod_Ctrl, Key_N }, GraphicsBitmap::load_from_file("/res/icons/16x16/new.png"), [this](const GUI::Action&) { if (m_document_dirty) { - auto save_document_first_box = GMessageBox::construct("Save Document First?", "Warning", GMessageBox::Type::Warning, GMessageBox::InputType::OKCancel, window()); + auto save_document_first_box = GUI::MessageBox::construct("Save Document First?", "Warning", GUI::MessageBox::Type::Warning, GUI::MessageBox::InputType::OKCancel, window()); auto save_document_first_result = save_document_first_box->exec(); - if (save_document_first_result != GDialog::ExecResult::ExecOK) + if (save_document_first_result != GUI::Dialog::ExecResult::ExecOK) return; m_save_action->activate(); } - auto input_box = GInputBox::construct("Enter new file size:", "New file size", this); - if (input_box->exec() == GInputBox::ExecOK && !input_box->text_value().is_empty()) { + auto input_box = GUI::InputBox::construct("Enter new file size:", "New file size", this); + if (input_box->exec() == GUI::InputBox::ExecOK && !input_box->text_value().is_empty()) { auto valid = false; auto file_size = input_box->text_value().to_int(valid); if (valid && file_size > 0) { @@ -88,13 +88,13 @@ HexEditorWidget::HexEditorWidget() set_path(FileSystemPath()); update_title(); } else { - GMessageBox::show("Invalid file size entered.", "Error", GMessageBox::Type::Error, GMessageBox::InputType::OK, window()); + GUI::MessageBox::show("Invalid file size entered.", "Error", GUI::MessageBox::Type::Error, GUI::MessageBox::InputType::OK, window()); } } }); - m_open_action = GCommonActions::make_open_action([this](auto&) { - Optional open_path = GFilePicker::get_open_filepath(); + m_open_action = GUI::CommonActions::make_open_action([this](auto&) { + Optional open_path = GUI::FilePicker::get_open_filepath(); if (!open_path.has_value()) return; @@ -102,10 +102,10 @@ HexEditorWidget::HexEditorWidget() open_file(open_path.value()); }); - m_save_action = GAction::create("Save", { Mod_Ctrl, Key_S }, GraphicsBitmap::load_from_file("/res/icons/16x16/save.png"), [&](const GAction&) { + m_save_action = GUI::Action::create("Save", { Mod_Ctrl, Key_S }, GraphicsBitmap::load_from_file("/res/icons/16x16/save.png"), [&](const GUI::Action&) { if (!m_path.is_empty()) { if (!m_editor->write_to_file(m_path)) { - GMessageBox::show("Unable to save file.\n", "Error", GMessageBox::Type::Error, GMessageBox::InputType::OK, window()); + GUI::MessageBox::show("Unable to save file.\n", "Error", GUI::MessageBox::Type::Error, GUI::MessageBox::InputType::OK, window()); } else { m_document_dirty = false; update_title(); @@ -116,13 +116,13 @@ HexEditorWidget::HexEditorWidget() m_save_as_action->activate(); }); - m_save_as_action = GAction::create("Save as...", { Mod_Ctrl | Mod_Shift, Key_S }, GraphicsBitmap::load_from_file("/res/icons/16x16/save.png"), [this](const GAction&) { - Optional save_path = GFilePicker::get_save_filepath(m_name.is_null() ? "Untitled" : m_name, m_extension.is_null() ? "bin" : m_extension); + m_save_as_action = GUI::Action::create("Save as...", { Mod_Ctrl | Mod_Shift, Key_S }, GraphicsBitmap::load_from_file("/res/icons/16x16/save.png"), [this](const GUI::Action&) { + Optional save_path = GUI::FilePicker::get_save_filepath(m_name.is_null() ? "Untitled" : m_name, m_extension.is_null() ? "bin" : m_extension); if (!save_path.has_value()) return; if (!m_editor->write_to_file(save_path.value())) { - GMessageBox::show("Unable to save file.\n", "Error", GMessageBox::Type::Error, GMessageBox::InputType::OK, window()); + GUI::MessageBox::show("Unable to save file.\n", "Error", GUI::MessageBox::Type::Error, GUI::MessageBox::InputType::OK, window()); return; } @@ -131,31 +131,31 @@ HexEditorWidget::HexEditorWidget() dbg() << "Wrote document to " << save_path.value(); }); - auto menubar = make(); - auto app_menu = GMenu::construct("Hex Editor"); + auto menubar = make(); + auto app_menu = GUI::Menu::construct("Hex Editor"); app_menu->add_action(*m_new_action); app_menu->add_action(*m_open_action); app_menu->add_action(*m_save_action); app_menu->add_action(*m_save_as_action); app_menu->add_separator(); - app_menu->add_action(GCommonActions::make_quit_action([this](auto&) { + app_menu->add_action(GUI::CommonActions::make_quit_action([this](auto&) { if (!request_close()) return; - GApplication::the().quit(0); + GUI::Application::the().quit(0); })); menubar->add_menu(move(app_menu)); - auto bytes_per_row_menu = GMenu::construct("Bytes Per Row"); + auto bytes_per_row_menu = GUI::Menu::construct("Bytes Per Row"); for (int i = 8; i <= 32; i += 8) { - bytes_per_row_menu->add_action(GAction::create(String::number(i), [this, i](auto&) { + bytes_per_row_menu->add_action(GUI::Action::create(String::number(i), [this, i](auto&) { m_editor->set_bytes_per_row(i); m_editor->update(); })); } - m_goto_decimal_offset_action = GAction::create("Go To Offset (Decimal)...", { Mod_Ctrl | Mod_Shift, Key_G }, GraphicsBitmap::load_from_file("/res/icons/16x16/go-forward.png"), [this](const GAction&) { - auto input_box = GInputBox::construct("Enter Decimal offset:", "Go To", this); - if (input_box->exec() == GInputBox::ExecOK && !input_box->text_value().is_empty()) { + m_goto_decimal_offset_action = GUI::Action::create("Go To Offset (Decimal)...", { Mod_Ctrl | Mod_Shift, Key_G }, GraphicsBitmap::load_from_file("/res/icons/16x16/go-forward.png"), [this](const GUI::Action&) { + auto input_box = GUI::InputBox::construct("Enter Decimal offset:", "Go To", this); + if (input_box->exec() == GUI::InputBox::ExecOK && !input_box->text_value().is_empty()) { auto valid = false; auto new_offset = input_box->text_value().to_int(valid); if (valid) { @@ -164,18 +164,18 @@ HexEditorWidget::HexEditorWidget() } }); - m_goto_hex_offset_action = GAction::create("Go To Offset (Hex)...", { Mod_Ctrl, Key_G }, GraphicsBitmap::load_from_file("/res/icons/16x16/go-forward.png"), [this](const GAction&) { - auto input_box = GInputBox::construct("Enter Hex offset:", "Go To", this); - if (input_box->exec() == GInputBox::ExecOK && !input_box->text_value().is_empty()) { + m_goto_hex_offset_action = GUI::Action::create("Go To Offset (Hex)...", { Mod_Ctrl, Key_G }, GraphicsBitmap::load_from_file("/res/icons/16x16/go-forward.png"), [this](const GUI::Action&) { + auto input_box = GUI::InputBox::construct("Enter Hex offset:", "Go To", this); + if (input_box->exec() == GUI::InputBox::ExecOK && !input_box->text_value().is_empty()) { auto new_offset = strtol(input_box->text_value().characters(), nullptr, 16); m_editor->set_position(new_offset); } }); - auto edit_menu = GMenu::construct("Edit"); - edit_menu->add_action(GAction::create("Fill selection...", { Mod_Ctrl, Key_B }, [&](const GAction&) { - auto input_box = GInputBox::construct("Fill byte (hex):", "Fill Selection", this); - if (input_box->exec() == GInputBox::ExecOK && !input_box->text_value().is_empty()) { + auto edit_menu = GUI::Menu::construct("Edit"); + edit_menu->add_action(GUI::Action::create("Fill selection...", { Mod_Ctrl, Key_B }, [&](const GUI::Action&) { + auto input_box = GUI::InputBox::construct("Fill byte (hex):", "Fill Selection", this); + if (input_box->exec() == GUI::InputBox::ExecOK && !input_box->text_value().is_empty()) { auto fill_byte = strtol(input_box->text_value().characters(), nullptr, 16); m_editor->fill_selection(fill_byte); } @@ -184,29 +184,29 @@ HexEditorWidget::HexEditorWidget() edit_menu->add_action(*m_goto_decimal_offset_action); edit_menu->add_action(*m_goto_hex_offset_action); edit_menu->add_separator(); - edit_menu->add_action(GAction::create("Copy Hex", { Mod_Ctrl, Key_C }, [&](const GAction&) { + edit_menu->add_action(GUI::Action::create("Copy Hex", { Mod_Ctrl, Key_C }, [&](const GUI::Action&) { m_editor->copy_selected_hex_to_clipboard(); })); - edit_menu->add_action(GAction::create("Copy Text", { Mod_Ctrl | Mod_Shift, Key_C }, [&](const GAction&) { + edit_menu->add_action(GUI::Action::create("Copy Text", { Mod_Ctrl | Mod_Shift, Key_C }, [&](const GUI::Action&) { m_editor->copy_selected_text_to_clipboard(); })); edit_menu->add_separator(); - edit_menu->add_action(GAction::create("Copy As C Code", { Mod_Alt | Mod_Shift, Key_C }, [&](const GAction&) { + edit_menu->add_action(GUI::Action::create("Copy As C Code", { Mod_Alt | Mod_Shift, Key_C }, [&](const GUI::Action&) { m_editor->copy_selected_hex_to_clipboard_as_c_code(); })); menubar->add_menu(move(edit_menu)); - auto view_menu = GMenu::construct("View"); + auto view_menu = GUI::Menu::construct("View"); view_menu->add_submenu(move(bytes_per_row_menu)); menubar->add_menu(move(view_menu)); - auto help_menu = GMenu::construct("Help"); - help_menu->add_action(GAction::create("About", [&](const GAction&) { - GAboutDialog::show("Hex Editor", load_png("/res/icons/32x32/app-hexeditor.png"), window()); + auto help_menu = GUI::Menu::construct("Help"); + help_menu->add_action(GUI::Action::create("About", [&](const GUI::Action&) { + GUI::AboutDialog::show("Hex Editor", load_png("/res/icons/32x32/app-hexeditor.png"), window()); })); menubar->add_menu(move(help_menu)); - GApplication::the().set_menubar(move(menubar)); + GUI::Application::the().set_menubar(move(menubar)); m_editor->set_focus(true); } @@ -237,7 +237,7 @@ void HexEditorWidget::open_file(const String& path) { auto file = Core::File::construct(path); if (!file->open(Core::IODevice::ReadOnly)) { - GMessageBox::show(String::format("Opening \"%s\" failed: %s", path.characters(), strerror(errno)), "Error", GMessageBox::Type::Error, GMessageBox::InputType::OK, window()); + GUI::MessageBox::show(String::format("Opening \"%s\" failed: %s", path.characters(), strerror(errno)), "Error", GUI::MessageBox::Type::Error, GUI::MessageBox::InputType::OK, window()); return; } @@ -250,6 +250,6 @@ bool HexEditorWidget::request_close() { if (!m_document_dirty) return true; - auto result = GMessageBox::show("The file has been modified. Quit without saving?", "Quit without saving?", GMessageBox::Type::Warning, GMessageBox::InputType::OKCancel, window()); - return result == GMessageBox::ExecOK; + auto result = GUI::MessageBox::show("The file has been modified. Quit without saving?", "Quit without saving?", GUI::MessageBox::Type::Warning, GUI::MessageBox::InputType::OKCancel, window()); + return result == GUI::MessageBox::ExecOK; } diff --git a/Applications/HexEditor/HexEditorWidget.h b/Applications/HexEditor/HexEditorWidget.h index 081444fa467..9b1ee334ca0 100644 --- a/Applications/HexEditor/HexEditorWidget.h +++ b/Applications/HexEditor/HexEditorWidget.h @@ -34,10 +34,13 @@ #include #include -class HexEditor; -class GStatusBar; +namespace GUI { +class StatusBar; +} -class HexEditorWidget final : public GWidget { +class HexEditor; + +class HexEditorWidget final : public GUI::Widget { C_OBJECT(HexEditorWidget) public: virtual ~HexEditorWidget() override; @@ -53,14 +56,14 @@ private: String m_path; String m_name; String m_extension; - RefPtr m_new_action; - RefPtr m_open_action; - RefPtr m_save_action; - RefPtr m_save_as_action; - RefPtr m_goto_decimal_offset_action; - RefPtr m_goto_hex_offset_action; + RefPtr m_new_action; + RefPtr m_open_action; + RefPtr m_save_action; + RefPtr m_save_as_action; + RefPtr m_goto_decimal_offset_action; + RefPtr m_goto_hex_offset_action; - RefPtr m_statusbar; + RefPtr m_statusbar; bool m_document_dirty { false }; }; diff --git a/Applications/HexEditor/main.cpp b/Applications/HexEditor/main.cpp index 52efb87a0ee..38cf4aeb460 100644 --- a/Applications/HexEditor/main.cpp +++ b/Applications/HexEditor/main.cpp @@ -35,24 +35,24 @@ int main(int argc, char** argv) return 1; } - GApplication app(argc, argv); + GUI::Application app(argc, argv); if (pledge("stdio shared_buffer accept rpath cpath wpath", nullptr) < 0) { perror("pledge"); return 1; } - auto window = GWindow::construct(); + auto window = GUI::Window::construct(); window->set_title("Hex Editor"); window->set_rect(20, 200, 640, 400); auto hex_editor_widget = HexEditorWidget::construct(); window->set_main_widget(hex_editor_widget); - window->on_close_request = [&]() -> GWindow::CloseRequestDecision { + window->on_close_request = [&]() -> GUI::Window::CloseRequestDecision { if (hex_editor_widget->request_close()) - return GWindow::CloseRequestDecision::Close; - return GWindow::CloseRequestDecision::StayOpen; + return GUI::Window::CloseRequestDecision::Close; + return GUI::Window::CloseRequestDecision::StayOpen; }; window->show(); diff --git a/Applications/IRCClient/IRCAppWindow.cpp b/Applications/IRCClient/IRCAppWindow.cpp index 354498038dc..5e2bb26c468 100644 --- a/Applications/IRCClient/IRCAppWindow.cpp +++ b/Applications/IRCClient/IRCAppWindow.cpp @@ -94,9 +94,9 @@ void IRCAppWindow::setup_client() }; if (m_client.hostname().is_empty()) { - auto input_box = GInputBox::construct("Enter server:", "Connect to server", this); + auto input_box = GUI::InputBox::construct("Enter server:", "Connect to server", this); auto result = input_box->exec(); - if (result == GInputBox::ExecCancel) + if (result == GUI::InputBox::ExecCancel) ::exit(0); m_client.set_server(input_box->text_value(), 6667); @@ -108,13 +108,13 @@ void IRCAppWindow::setup_client() void IRCAppWindow::setup_actions() { - m_join_action = GAction::create("Join channel", { Mod_Ctrl, Key_J }, GraphicsBitmap::load_from_file("/res/icons/16x16/irc-join.png"), [&](auto&) { - auto input_box = GInputBox::construct("Enter channel name:", "Join channel", this); - if (input_box->exec() == GInputBox::ExecOK && !input_box->text_value().is_empty()) + m_join_action = GUI::Action::create("Join channel", { Mod_Ctrl, Key_J }, GraphicsBitmap::load_from_file("/res/icons/16x16/irc-join.png"), [&](auto&) { + auto input_box = GUI::InputBox::construct("Enter channel name:", "Join channel", this); + if (input_box->exec() == GUI::InputBox::ExecOK && !input_box->text_value().is_empty()) m_client.handle_join_action(input_box->text_value()); }); - m_part_action = GAction::create("Part from channel", { Mod_Ctrl, Key_P }, GraphicsBitmap::load_from_file("/res/icons/16x16/irc-part.png"), [this](auto&) { + m_part_action = GUI::Action::create("Part from channel", { Mod_Ctrl, Key_P }, GraphicsBitmap::load_from_file("/res/icons/16x16/irc-part.png"), [this](auto&) { auto* window = m_client.current_window(); if (!window || window->type() != IRCWindow::Type::Channel) { // FIXME: Perhaps this action should have been disabled instead of allowing us to activate it. @@ -123,41 +123,41 @@ void IRCAppWindow::setup_actions() m_client.handle_part_action(window->channel().name()); }); - m_whois_action = GAction::create("Whois user", GraphicsBitmap::load_from_file("/res/icons/16x16/irc-whois.png"), [&](auto&) { - auto input_box = GInputBox::construct("Enter nickname:", "IRC WHOIS lookup", this); - if (input_box->exec() == GInputBox::ExecOK && !input_box->text_value().is_empty()) + m_whois_action = GUI::Action::create("Whois user", GraphicsBitmap::load_from_file("/res/icons/16x16/irc-whois.png"), [&](auto&) { + auto input_box = GUI::InputBox::construct("Enter nickname:", "IRC WHOIS lookup", this); + if (input_box->exec() == GUI::InputBox::ExecOK && !input_box->text_value().is_empty()) m_client.handle_whois_action(input_box->text_value()); }); - m_open_query_action = GAction::create("Open query", { Mod_Ctrl, Key_O }, GraphicsBitmap::load_from_file("/res/icons/16x16/irc-open-query.png"), [&](auto&) { - auto input_box = GInputBox::construct("Enter nickname:", "Open IRC query with...", this); - if (input_box->exec() == GInputBox::ExecOK && !input_box->text_value().is_empty()) + m_open_query_action = GUI::Action::create("Open query", { Mod_Ctrl, Key_O }, GraphicsBitmap::load_from_file("/res/icons/16x16/irc-open-query.png"), [&](auto&) { + auto input_box = GUI::InputBox::construct("Enter nickname:", "Open IRC query with...", this); + if (input_box->exec() == GUI::InputBox::ExecOK && !input_box->text_value().is_empty()) m_client.handle_open_query_action(input_box->text_value()); }); - m_close_query_action = GAction::create("Close query", { Mod_Ctrl, Key_D }, GraphicsBitmap::load_from_file("/res/icons/16x16/irc-close-query.png"), [](auto&) { + m_close_query_action = GUI::Action::create("Close query", { Mod_Ctrl, Key_D }, GraphicsBitmap::load_from_file("/res/icons/16x16/irc-close-query.png"), [](auto&) { printf("FIXME: Implement close-query action\n"); }); - m_change_nick_action = GAction::create("Change nickname", GraphicsBitmap::load_from_file("/res/icons/16x16/irc-nick.png"), [this](auto&) { - auto input_box = GInputBox::construct("Enter nickname:", "Change nickname", this); - if (input_box->exec() == GInputBox::ExecOK && !input_box->text_value().is_empty()) + m_change_nick_action = GUI::Action::create("Change nickname", GraphicsBitmap::load_from_file("/res/icons/16x16/irc-nick.png"), [this](auto&) { + auto input_box = GUI::InputBox::construct("Enter nickname:", "Change nickname", this); + if (input_box->exec() == GUI::InputBox::ExecOK && !input_box->text_value().is_empty()) m_client.handle_change_nick_action(input_box->text_value()); }); } void IRCAppWindow::setup_menus() { - auto menubar = make(); - auto app_menu = GMenu::construct("IRC Client"); - app_menu->add_action(GCommonActions::make_quit_action([](auto&) { + auto menubar = make(); + auto app_menu = GUI::Menu::construct("IRC Client"); + app_menu->add_action(GUI::CommonActions::make_quit_action([](auto&) { dbgprintf("Terminal: Quit menu activated!\n"); - GApplication::the().quit(0); + GUI::Application::the().quit(0); return; })); menubar->add_menu(move(app_menu)); - auto server_menu = GMenu::construct("Server"); + auto server_menu = GUI::Menu::construct("Server"); server_menu->add_action(*m_change_nick_action); server_menu->add_separator(); server_menu->add_action(*m_join_action); @@ -168,24 +168,24 @@ void IRCAppWindow::setup_menus() server_menu->add_action(*m_close_query_action); menubar->add_menu(move(server_menu)); - auto help_menu = GMenu::construct("Help"); - help_menu->add_action(GAction::create("About", [this](const GAction&) { - GAboutDialog::show("IRC Client", load_png("/res/icons/32x32/app-irc-client.png"), this); + auto help_menu = GUI::Menu::construct("Help"); + help_menu->add_action(GUI::Action::create("About", [this](const GUI::Action&) { + GUI::AboutDialog::show("IRC Client", load_png("/res/icons/32x32/app-irc-client.png"), this); })); menubar->add_menu(move(help_menu)); - GApplication::the().set_menubar(move(menubar)); + GUI::Application::the().set_menubar(move(menubar)); } void IRCAppWindow::setup_widgets() { - auto widget = GWidget::construct(); + auto widget = GUI::Widget::construct(); set_main_widget(widget); widget->set_fill_with_background_color(true); - widget->set_layout(make()); + widget->set_layout(make()); widget->layout()->set_spacing(0); - auto toolbar = GToolBar::construct(widget); + auto toolbar = GUI::ToolBar::construct(widget); toolbar->set_has_frame(false); toolbar->add_action(*m_change_nick_action); toolbar->add_separator(); @@ -196,25 +196,25 @@ void IRCAppWindow::setup_widgets() toolbar->add_action(*m_open_query_action); toolbar->add_action(*m_close_query_action); - auto outer_container = GWidget::construct(widget.ptr()); - outer_container->set_layout(make()); + auto outer_container = GUI::Widget::construct(widget.ptr()); + outer_container->set_layout(make()); outer_container->layout()->set_margins({ 2, 0, 2, 2 }); - auto horizontal_container = GSplitter::construct(Orientation::Horizontal, outer_container); + auto horizontal_container = GUI::Splitter::construct(Orientation::Horizontal, outer_container); - m_window_list = GTableView::construct(horizontal_container); + m_window_list = GUI::TableView::construct(horizontal_container); m_window_list->set_headers_visible(false); m_window_list->set_alternating_row_colors(false); m_window_list->set_size_columns_to_fit_content(true); m_window_list->set_model(m_client.client_window_list_model()); m_window_list->set_activates_on_selection(true); - m_window_list->set_size_policy(SizePolicy::Fixed, SizePolicy::Fill); + m_window_list->set_size_policy(GUI::SizePolicy::Fixed, GUI::SizePolicy::Fill); m_window_list->set_preferred_size(100, 0); m_window_list->on_activation = [this](auto& index) { set_active_window(m_client.window_at(index.row())); }; - m_container = GStackWidget::construct(horizontal_container); + m_container = GUI::StackWidget::construct(horizontal_container); m_container->on_active_widget_change = [this](auto*) { update_part_action(); }; diff --git a/Applications/IRCClient/IRCAppWindow.h b/Applications/IRCClient/IRCAppWindow.h index a92ed6c89d5..05af3d598e9 100644 --- a/Applications/IRCClient/IRCAppWindow.h +++ b/Applications/IRCClient/IRCAppWindow.h @@ -31,11 +31,12 @@ #include #include -class GAction; -class GStackWidget; -class GTableView; +namespace GUI { +class StackWidget; +class TableView; +} -class IRCAppWindow : public GWindow { +class IRCAppWindow : public GUI::Window { public: IRCAppWindow(); virtual ~IRCAppWindow() override; @@ -54,12 +55,12 @@ private: IRCWindow& create_window(void* owner, IRCWindow::Type, const String& name); IRCClient m_client; - RefPtr m_container; - RefPtr m_window_list; - RefPtr m_join_action; - RefPtr m_part_action; - RefPtr m_whois_action; - RefPtr m_open_query_action; - RefPtr m_close_query_action; - RefPtr m_change_nick_action; + RefPtr m_container; + RefPtr m_window_list; + RefPtr m_join_action; + RefPtr m_part_action; + RefPtr m_whois_action; + RefPtr m_open_query_action; + RefPtr m_close_query_action; + RefPtr m_change_nick_action; }; diff --git a/Applications/IRCClient/IRCChannelMemberListModel.cpp b/Applications/IRCClient/IRCChannelMemberListModel.cpp index 709b225dcdd..20b5094d23a 100644 --- a/Applications/IRCClient/IRCChannelMemberListModel.cpp +++ b/Applications/IRCClient/IRCChannelMemberListModel.cpp @@ -38,12 +38,12 @@ IRCChannelMemberListModel::~IRCChannelMemberListModel() { } -int IRCChannelMemberListModel::row_count(const GModelIndex&) const +int IRCChannelMemberListModel::row_count(const GUI::ModelIndex&) const { return m_channel.member_count(); } -int IRCChannelMemberListModel::column_count(const GModelIndex&) const +int IRCChannelMemberListModel::column_count(const GUI::ModelIndex&) const { return 1; } @@ -57,7 +57,7 @@ String IRCChannelMemberListModel::column_name(int column) const ASSERT_NOT_REACHED(); } -GModel::ColumnMetadata IRCChannelMemberListModel::column_metadata(int column) const +GUI::Model::ColumnMetadata IRCChannelMemberListModel::column_metadata(int column) const { switch (column) { case Column::Name: @@ -66,7 +66,7 @@ GModel::ColumnMetadata IRCChannelMemberListModel::column_metadata(int column) co ASSERT_NOT_REACHED(); } -GVariant IRCChannelMemberListModel::data(const GModelIndex& index, Role role) const +GUI::Variant IRCChannelMemberListModel::data(const GUI::ModelIndex& index, Role role) const { if (role == Role::Display) { switch (index.column()) { diff --git a/Applications/IRCClient/IRCChannelMemberListModel.h b/Applications/IRCClient/IRCChannelMemberListModel.h index ad00caeba9b..ae3d06b91e4 100644 --- a/Applications/IRCClient/IRCChannelMemberListModel.h +++ b/Applications/IRCClient/IRCChannelMemberListModel.h @@ -31,7 +31,7 @@ class IRCChannel; -class IRCChannelMemberListModel final : public GModel { +class IRCChannelMemberListModel final : public GUI::Model { public: enum Column { Name @@ -39,11 +39,11 @@ public: static NonnullRefPtr create(IRCChannel& channel) { return adopt(*new IRCChannelMemberListModel(channel)); } virtual ~IRCChannelMemberListModel() override; - virtual int row_count(const GModelIndex&) const override; - virtual int column_count(const GModelIndex&) const override; + virtual int row_count(const GUI::ModelIndex&) const override; + virtual int column_count(const GUI::ModelIndex&) const override; virtual String column_name(int column) const override; virtual ColumnMetadata column_metadata(int column) const override; - virtual GVariant data(const GModelIndex&, Role = Role::Display) const override; + virtual GUI::Variant data(const GUI::ModelIndex&, Role = Role::Display) const override; virtual void update() override; private: diff --git a/Applications/IRCClient/IRCWindow.cpp b/Applications/IRCClient/IRCWindow.cpp index 6d8a0900169..e0f1498e689 100644 --- a/Applications/IRCClient/IRCWindow.cpp +++ b/Applications/IRCClient/IRCWindow.cpp @@ -35,32 +35,32 @@ #include #include -IRCWindow::IRCWindow(IRCClient& client, void* owner, Type type, const String& name, GWidget* parent) - : GWidget(parent) +IRCWindow::IRCWindow(IRCClient& client, void* owner, Type type, const String& name, GUI::Widget* parent) + : GUI::Widget(parent) , m_client(client) , m_owner(owner) , m_type(type) , m_name(name) { - set_layout(make()); + set_layout(make()); // Make a container for the log buffer view + (optional) member list. - auto container = GSplitter::construct(Orientation::Horizontal, this); + auto container = GUI::Splitter::construct(Orientation::Horizontal, this); m_html_view = HtmlView::construct(container); if (m_type == Channel) { - auto member_view = GTableView::construct(container); + auto member_view = GUI::TableView::construct(container); member_view->set_headers_visible(false); - member_view->set_size_policy(SizePolicy::Fixed, SizePolicy::Fill); + member_view->set_size_policy(GUI::SizePolicy::Fixed, GUI::SizePolicy::Fill); member_view->set_preferred_size(100, 0); member_view->set_alternating_row_colors(false); member_view->set_model(channel().member_model()); member_view->set_activates_on_selection(true); } - m_text_editor = GTextEditor::construct(GTextEditor::SingleLine, this); - m_text_editor->set_size_policy(SizePolicy::Fill, SizePolicy::Fixed); + m_text_editor = GUI::TextEditor::construct(GUI::TextEditor::SingleLine, this); + m_text_editor->set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed); m_text_editor->set_preferred_size(0, 19); m_text_editor->on_return_pressed = [this] { if (m_type == Channel) diff --git a/Applications/IRCClient/IRCWindow.h b/Applications/IRCClient/IRCWindow.h index 6cb342fb4b0..6c280ff3ff6 100644 --- a/Applications/IRCClient/IRCWindow.h +++ b/Applications/IRCClient/IRCWindow.h @@ -28,14 +28,17 @@ #include +namespace GUI { +class TextEditor; +} + class IRCChannel; class IRCClient; class IRCQuery; class IRCLogBuffer; -class GTextEditor; class HtmlView; -class IRCWindow : public GWidget { +class IRCWindow : public GUI::Widget { C_OBJECT(IRCWindow) public: enum Type { @@ -44,7 +47,7 @@ public: Query, }; - IRCWindow(IRCClient&, void* owner, Type, const String& name, GWidget* parent); + IRCWindow(IRCClient&, void* owner, Type, const String& name, GUI::Widget* parent); virtual ~IRCWindow() override; String name() const { return m_name; } @@ -73,7 +76,7 @@ private: Type m_type; String m_name; RefPtr m_html_view; - RefPtr m_text_editor; + RefPtr m_text_editor; RefPtr m_log_buffer; int m_unread_count { 0 }; }; diff --git a/Applications/IRCClient/IRCWindowListModel.cpp b/Applications/IRCClient/IRCWindowListModel.cpp index 3d851d123c1..152ddfbb463 100644 --- a/Applications/IRCClient/IRCWindowListModel.cpp +++ b/Applications/IRCClient/IRCWindowListModel.cpp @@ -40,12 +40,12 @@ IRCWindowListModel::~IRCWindowListModel() { } -int IRCWindowListModel::row_count(const GModelIndex&) const +int IRCWindowListModel::row_count(const GUI::ModelIndex&) const { return m_client.window_count(); } -int IRCWindowListModel::column_count(const GModelIndex&) const +int IRCWindowListModel::column_count(const GUI::ModelIndex&) const { return 1; } @@ -59,7 +59,7 @@ String IRCWindowListModel::column_name(int column) const ASSERT_NOT_REACHED(); } -GModel::ColumnMetadata IRCWindowListModel::column_metadata(int column) const +GUI::Model::ColumnMetadata IRCWindowListModel::column_metadata(int column) const { switch (column) { case Column::Name: @@ -68,7 +68,7 @@ GModel::ColumnMetadata IRCWindowListModel::column_metadata(int column) const ASSERT_NOT_REACHED(); } -GVariant IRCWindowListModel::data(const GModelIndex& index, Role role) const +GUI::Variant IRCWindowListModel::data(const GUI::ModelIndex& index, Role role) const { if (role == Role::Display) { switch (index.column()) { diff --git a/Applications/IRCClient/IRCWindowListModel.h b/Applications/IRCClient/IRCWindowListModel.h index e03bdd07072..f7f8fcca457 100644 --- a/Applications/IRCClient/IRCWindowListModel.h +++ b/Applications/IRCClient/IRCWindowListModel.h @@ -32,7 +32,7 @@ class IRCClient; class IRCWindow; -class IRCWindowListModel final : public GModel { +class IRCWindowListModel final : public GUI::Model { public: enum Column { Name, @@ -41,11 +41,11 @@ public: static NonnullRefPtr create(IRCClient& client) { return adopt(*new IRCWindowListModel(client)); } virtual ~IRCWindowListModel() override; - virtual int row_count(const GModelIndex&) const override; - virtual int column_count(const GModelIndex&) const override; + virtual int row_count(const GUI::ModelIndex&) const override; + virtual int column_count(const GUI::ModelIndex&) const override; virtual String column_name(int column) const override; virtual ColumnMetadata column_metadata(int column) const override; - virtual GVariant data(const GModelIndex&, Role = Role::Display) const override; + virtual GUI::Variant data(const GUI::ModelIndex&, Role = Role::Display) const override; virtual void update() override; private: diff --git a/Applications/IRCClient/main.cpp b/Applications/IRCClient/main.cpp index 432f7033066..a2d0f30c852 100644 --- a/Applications/IRCClient/main.cpp +++ b/Applications/IRCClient/main.cpp @@ -36,7 +36,7 @@ int main(int argc, char** argv) return 1; } - GApplication app(argc, argv); + GUI::Application app(argc, argv); if (pledge("stdio inet dns unix shared_buffer rpath", nullptr) < 0) { perror("pledge"); diff --git a/Applications/PaintBrush/BucketTool.cpp b/Applications/PaintBrush/BucketTool.cpp index 83c990c010f..19668b5415d 100644 --- a/Applications/PaintBrush/BucketTool.cpp +++ b/Applications/PaintBrush/BucketTool.cpp @@ -70,12 +70,12 @@ static void flood_fill(GraphicsBitmap& bitmap, const Point& start_position, Colo } } -void BucketTool::on_mousedown(GMouseEvent& event) +void BucketTool::on_mousedown(GUI::MouseEvent& event) { if (!m_widget->rect().contains(event.position())) return; - GPainter painter(m_widget->bitmap()); + GUI::Painter painter(m_widget->bitmap()); auto target_color = m_widget->bitmap().get_pixel(event.x(), event.y()); flood_fill(m_widget->bitmap(), event.position(), target_color, m_widget->color_for(event)); diff --git a/Applications/PaintBrush/BucketTool.h b/Applications/PaintBrush/BucketTool.h index a692715e1c1..fb52e9624e9 100644 --- a/Applications/PaintBrush/BucketTool.h +++ b/Applications/PaintBrush/BucketTool.h @@ -33,7 +33,7 @@ public: BucketTool(); virtual ~BucketTool() override; - virtual void on_mousedown(GMouseEvent&) override; + virtual void on_mousedown(GUI::MouseEvent&) override; private: virtual const char* class_name() const override { return "BucketTool"; } diff --git a/Applications/PaintBrush/EllipseTool.cpp b/Applications/PaintBrush/EllipseTool.cpp index 1517c7065e4..3563fba2a7e 100644 --- a/Applications/PaintBrush/EllipseTool.cpp +++ b/Applications/PaintBrush/EllipseTool.cpp @@ -40,7 +40,7 @@ EllipseTool::~EllipseTool() { } -void EllipseTool::draw_using(Painter& painter) +void EllipseTool::draw_using(GUI::Painter& painter) { auto ellipse_intersecting_rect = Rect::from_two_points(m_ellipse_start_position, m_ellipse_end_position); switch (m_mode) { @@ -52,12 +52,12 @@ void EllipseTool::draw_using(Painter& painter) } } -void EllipseTool::on_mousedown(GMouseEvent& event) +void EllipseTool::on_mousedown(GUI::MouseEvent& event) { - if (event.button() != GMouseButton::Left && event.button() != GMouseButton::Right) + if (event.button() != GUI::MouseButton::Left && event.button() != GUI::MouseButton::Right) return; - if (m_drawing_button != GMouseButton::None) + if (m_drawing_button != GUI::MouseButton::None) return; m_drawing_button = event.button(); @@ -66,19 +66,19 @@ void EllipseTool::on_mousedown(GMouseEvent& event) m_widget->update(); } -void EllipseTool::on_mouseup(GMouseEvent& event) +void EllipseTool::on_mouseup(GUI::MouseEvent& event) { if (event.button() == m_drawing_button) { - GPainter painter(m_widget->bitmap()); + GUI::Painter painter(m_widget->bitmap()); draw_using(painter); - m_drawing_button = GMouseButton::None; + m_drawing_button = GUI::MouseButton::None; m_widget->update(); } } -void EllipseTool::on_mousemove(GMouseEvent& event) +void EllipseTool::on_mousemove(GUI::MouseEvent& event) { - if (m_drawing_button == GMouseButton::None) + if (m_drawing_button == GUI::MouseButton::None) return; if (!m_widget->rect().contains(event.position())) @@ -88,36 +88,36 @@ void EllipseTool::on_mousemove(GMouseEvent& event) m_widget->update(); } -void EllipseTool::on_second_paint(GPaintEvent& event) +void EllipseTool::on_second_paint(GUI::PaintEvent& event) { - if (m_drawing_button == GMouseButton::None) + if (m_drawing_button == GUI::MouseButton::None) return; - GPainter painter(*m_widget); + GUI::Painter painter(*m_widget); painter.add_clip_rect(event.rect()); draw_using(painter); } -void EllipseTool::on_keydown(GKeyEvent& event) +void EllipseTool::on_keydown(GUI::KeyEvent& event) { - if (event.key() == Key_Escape && m_drawing_button != GMouseButton::None) { - m_drawing_button = GMouseButton::None; + if (event.key() == Key_Escape && m_drawing_button != GUI::MouseButton::None) { + m_drawing_button = GUI::MouseButton::None; m_widget->update(); event.accept(); } } -void EllipseTool::on_contextmenu(GContextMenuEvent& event) +void EllipseTool::on_contextmenu(GUI::ContextMenuEvent& event) { if (!m_context_menu) { - m_context_menu = GMenu::construct(); - m_context_menu->add_action(GAction::create("Outline", [this](auto&) { + m_context_menu = GUI::Menu::construct(); + m_context_menu->add_action(GUI::Action::create("Outline", [this](auto&) { m_mode = Mode::Outline; })); m_context_menu->add_separator(); m_thickness_actions.set_exclusive(true); auto insert_action = [&](int size, bool checked = false) { - auto action = GAction::create(String::number(size), [this, size](auto& action) { + auto action = GUI::Action::create(String::number(size), [this, size](auto& action) { m_thickness = size; action.set_checked(true); }); diff --git a/Applications/PaintBrush/EllipseTool.h b/Applications/PaintBrush/EllipseTool.h index 09779566d8e..6c59b1637b9 100644 --- a/Applications/PaintBrush/EllipseTool.h +++ b/Applications/PaintBrush/EllipseTool.h @@ -30,20 +30,22 @@ #include #include -class GMenu; +namespace GUI { +class Menu; class Painter; +} class EllipseTool final : public Tool { public: EllipseTool(); virtual ~EllipseTool() override; - virtual void on_mousedown(GMouseEvent&) override; - virtual void on_mousemove(GMouseEvent&) override; - virtual void on_mouseup(GMouseEvent&) override; - virtual void on_contextmenu(GContextMenuEvent&) override; - virtual void on_second_paint(GPaintEvent&) override; - virtual void on_keydown(GKeyEvent&) override; + virtual void on_mousedown(GUI::MouseEvent&) override; + virtual void on_mousemove(GUI::MouseEvent&) override; + virtual void on_mouseup(GUI::MouseEvent&) override; + virtual void on_contextmenu(GUI::ContextMenuEvent&) override; + virtual void on_second_paint(GUI::PaintEvent&) override; + virtual void on_keydown(GUI::KeyEvent&) override; private: enum class Mode { @@ -52,13 +54,13 @@ private: }; virtual const char* class_name() const override { return "EllipseTool"; } - void draw_using(Painter& painter); + void draw_using(GUI::Painter& painter); - GMouseButton m_drawing_button { GMouseButton::None }; + GUI::MouseButton m_drawing_button { GUI::MouseButton::None }; Point m_ellipse_start_position; Point m_ellipse_end_position; - RefPtr m_context_menu; + RefPtr m_context_menu; int m_thickness { 1 }; - GActionGroup m_thickness_actions; + GUI::ActionGroup m_thickness_actions; Mode m_mode { Mode::Outline }; }; diff --git a/Applications/PaintBrush/EraseTool.cpp b/Applications/PaintBrush/EraseTool.cpp index cf9737b868e..42525084324 100644 --- a/Applications/PaintBrush/EraseTool.cpp +++ b/Applications/PaintBrush/EraseTool.cpp @@ -48,35 +48,35 @@ Rect EraseTool::build_rect(const Point& pos, const Rect& widget_rect) return Rect(ex - eraser_radius, ey - eraser_radius, eraser_size, eraser_size).intersected(widget_rect); } -void EraseTool::on_mousedown(GMouseEvent& event) +void EraseTool::on_mousedown(GUI::MouseEvent& event) { - if (event.button() != GMouseButton::Left && event.button() != GMouseButton::Right) + if (event.button() != GUI::MouseButton::Left && event.button() != GUI::MouseButton::Right) return; Rect r = build_rect(event.position(), m_widget->bitmap().rect()); - GPainter painter(m_widget->bitmap()); + GUI::Painter painter(m_widget->bitmap()); painter.fill_rect(r, get_color()); m_widget->update(); } -void EraseTool::on_mousemove(GMouseEvent& event) +void EraseTool::on_mousemove(GUI::MouseEvent& event) { if (!m_widget->rect().contains(event.position())) return; - if (event.buttons() & GMouseButton::Left || event.buttons() & GMouseButton::Right) { + if (event.buttons() & GUI::MouseButton::Left || event.buttons() & GUI::MouseButton::Right) { Rect r = build_rect(event.position(), m_widget->bitmap().rect()); - GPainter painter(m_widget->bitmap()); + GUI::Painter painter(m_widget->bitmap()); painter.fill_rect(r, get_color()); m_widget->update(); } } -void EraseTool::on_contextmenu(GContextMenuEvent& event) +void EraseTool::on_contextmenu(GUI::ContextMenuEvent& event) { if (!m_context_menu) { - m_context_menu = GMenu::construct(); + m_context_menu = GUI::Menu::construct(); - NonnullRefPtr eraser_color_toggler = GAction::create("Use secondary color", [&](GAction& action) { + NonnullRefPtr eraser_color_toggler = GUI::Action::create("Use secondary color", [&](GUI::Action& action) { bool toggled = !m_use_secondary_color; m_use_secondary_color = toggled; action.set_checked(toggled); @@ -89,7 +89,7 @@ void EraseTool::on_contextmenu(GContextMenuEvent& event) m_thickness_actions.set_exclusive(true); auto insert_action = [&](int size, bool checked = false) { - auto action = GAction::create(String::number(size), [this, size](auto& action) { + auto action = GUI::Action::create(String::number(size), [this, size](auto& action) { m_thickness = size; action.set_checked(true); }); diff --git a/Applications/PaintBrush/EraseTool.h b/Applications/PaintBrush/EraseTool.h index b7ca11ae8c4..576a1f5b46e 100644 --- a/Applications/PaintBrush/EraseTool.h +++ b/Applications/PaintBrush/EraseTool.h @@ -30,24 +30,26 @@ #include #include -class GMenu; +namespace GUI { +class Menu; +} class EraseTool final : public Tool { public: EraseTool(); virtual ~EraseTool() override; - virtual void on_mousedown(GMouseEvent&) override; - virtual void on_mousemove(GMouseEvent&) override; - virtual void on_contextmenu(GContextMenuEvent&) override; + virtual void on_mousedown(GUI::MouseEvent&) override; + virtual void on_mousemove(GUI::MouseEvent&) override; + virtual void on_contextmenu(GUI::ContextMenuEvent&) override; private: Color get_color() const; virtual const char* class_name() const override { return "EraseTool"; } Rect build_rect(const Point& pos, const Rect& widget_rect); - RefPtr m_context_menu; + RefPtr m_context_menu; bool m_use_secondary_color { true }; int m_thickness { 1 }; - GActionGroup m_thickness_actions; + GUI::ActionGroup m_thickness_actions; }; diff --git a/Applications/PaintBrush/LineTool.cpp b/Applications/PaintBrush/LineTool.cpp index 8fcffb0d24c..e3ffaa0bb63 100644 --- a/Applications/PaintBrush/LineTool.cpp +++ b/Applications/PaintBrush/LineTool.cpp @@ -52,12 +52,12 @@ LineTool::~LineTool() { } -void LineTool::on_mousedown(GMouseEvent& event) +void LineTool::on_mousedown(GUI::MouseEvent& event) { - if (event.button() != GMouseButton::Left && event.button() != GMouseButton::Right) + if (event.button() != GUI::MouseButton::Left && event.button() != GUI::MouseButton::Right) return; - if (m_drawing_button != GMouseButton::None) + if (m_drawing_button != GUI::MouseButton::None) return; m_drawing_button = event.button(); @@ -66,19 +66,19 @@ void LineTool::on_mousedown(GMouseEvent& event) m_widget->update(); } -void LineTool::on_mouseup(GMouseEvent& event) +void LineTool::on_mouseup(GUI::MouseEvent& event) { if (event.button() == m_drawing_button) { - GPainter painter(m_widget->bitmap()); + GUI::Painter painter(m_widget->bitmap()); painter.draw_line(m_line_start_position, m_line_end_position, m_widget->color_for(m_drawing_button), m_thickness); - m_drawing_button = GMouseButton::None; + m_drawing_button = GUI::MouseButton::None; m_widget->update(); } } -void LineTool::on_mousemove(GMouseEvent& event) +void LineTool::on_mousemove(GUI::MouseEvent& event) { - if (m_drawing_button == GMouseButton::None) + if (m_drawing_button == GUI::MouseButton::None) return; if (!m_widget->rect().contains(event.position())) @@ -93,20 +93,20 @@ void LineTool::on_mousemove(GMouseEvent& event) m_widget->update(); } -void LineTool::on_second_paint(GPaintEvent& event) +void LineTool::on_second_paint(GUI::PaintEvent& event) { - if (m_drawing_button == GMouseButton::None) + if (m_drawing_button == GUI::MouseButton::None) return; - GPainter painter(*m_widget); + GUI::Painter painter(*m_widget); painter.add_clip_rect(event.rect()); painter.draw_line(m_line_start_position, m_line_end_position, m_widget->color_for(m_drawing_button), m_thickness); } -void LineTool::on_keydown(GKeyEvent& event) +void LineTool::on_keydown(GUI::KeyEvent& event) { - if (event.key() == Key_Escape && m_drawing_button != GMouseButton::None) { - m_drawing_button = GMouseButton::None; + if (event.key() == Key_Escape && m_drawing_button != GUI::MouseButton::None) { + m_drawing_button = GUI::MouseButton::None; m_widget->update(); event.accept(); } @@ -118,7 +118,7 @@ void LineTool::on_keydown(GKeyEvent& event) } } -void LineTool::on_keyup(GKeyEvent& event) +void LineTool::on_keyup(GUI::KeyEvent& event) { if (event.key() == Key_Shift) { m_constrain_angle = false; @@ -127,13 +127,13 @@ void LineTool::on_keyup(GKeyEvent& event) } } -void LineTool::on_contextmenu(GContextMenuEvent& event) +void LineTool::on_contextmenu(GUI::ContextMenuEvent& event) { if (!m_context_menu) { - m_context_menu = GMenu::construct(); + m_context_menu = GUI::Menu::construct(); m_thickness_actions.set_exclusive(true); auto insert_action = [&](int size, bool checked = false) { - auto action = GAction::create(String::number(size), [this, size](auto& action) { + auto action = GUI::Action::create(String::number(size), [this, size](auto& action) { m_thickness = size; action.set_checked(true); }); diff --git a/Applications/PaintBrush/LineTool.h b/Applications/PaintBrush/LineTool.h index b591ffeef57..40657ac5b0a 100644 --- a/Applications/PaintBrush/LineTool.h +++ b/Applications/PaintBrush/LineTool.h @@ -30,29 +30,31 @@ #include #include -class GMenu; +namespace GUI { +class Menu; +} class LineTool final : public Tool { public: LineTool(); virtual ~LineTool() override; - virtual void on_mousedown(GMouseEvent&) override; - virtual void on_mousemove(GMouseEvent&) override; - virtual void on_mouseup(GMouseEvent&) override; - virtual void on_contextmenu(GContextMenuEvent&) override; - virtual void on_second_paint(GPaintEvent&) override; - virtual void on_keydown(GKeyEvent&) override; - virtual void on_keyup(GKeyEvent&) override; + virtual void on_mousedown(GUI::MouseEvent&) override; + virtual void on_mousemove(GUI::MouseEvent&) override; + virtual void on_mouseup(GUI::MouseEvent&) override; + virtual void on_contextmenu(GUI::ContextMenuEvent&) override; + virtual void on_second_paint(GUI::PaintEvent&) override; + virtual void on_keydown(GUI::KeyEvent&) override; + virtual void on_keyup(GUI::KeyEvent&) override; private: virtual const char* class_name() const override { return "LineTool"; } - GMouseButton m_drawing_button { GMouseButton::None }; + GUI::MouseButton m_drawing_button { GUI::MouseButton::None }; Point m_line_start_position; Point m_line_end_position; - RefPtr m_context_menu; - GActionGroup m_thickness_actions; + RefPtr m_context_menu; + GUI::ActionGroup m_thickness_actions; int m_thickness { 1 }; bool m_constrain_angle { false }; }; diff --git a/Applications/PaintBrush/PaintableWidget.cpp b/Applications/PaintBrush/PaintableWidget.cpp index 7f8187a34d4..42ac963529c 100644 --- a/Applications/PaintBrush/PaintableWidget.cpp +++ b/Applications/PaintBrush/PaintableWidget.cpp @@ -37,8 +37,8 @@ PaintableWidget& PaintableWidget::the() return *s_the; } -PaintableWidget::PaintableWidget(GWidget* parent) - : GWidget(parent) +PaintableWidget::PaintableWidget(GUI::Widget* parent) + : GUI::Widget(parent) { ASSERT(!s_the); s_the = this; @@ -55,9 +55,9 @@ PaintableWidget::~PaintableWidget() { } -void PaintableWidget::paint_event(GPaintEvent& event) +void PaintableWidget::paint_event(GUI::PaintEvent& event) { - GPainter painter(*this); + GUI::Painter painter(*this); painter.add_clip_rect(event.rect()); painter.blit({ 0, 0 }, *m_bitmap, m_bitmap->rect()); } @@ -76,68 +76,68 @@ Tool* PaintableWidget::tool() return m_tool; } -Color PaintableWidget::color_for(GMouseButton button) const +Color PaintableWidget::color_for(GUI::MouseButton button) const { - if (button == GMouseButton::Left) + if (button == GUI::MouseButton::Left) return m_primary_color; - if (button == GMouseButton::Right) + if (button == GUI::MouseButton::Right) return m_secondary_color; ASSERT_NOT_REACHED(); } -Color PaintableWidget::color_for(const GMouseEvent& event) const +Color PaintableWidget::color_for(const GUI::MouseEvent& event) const { - if (event.buttons() & GMouseButton::Left) + if (event.buttons() & GUI::MouseButton::Left) return m_primary_color; - if (event.buttons() & GMouseButton::Right) + if (event.buttons() & GUI::MouseButton::Right) return m_secondary_color; ASSERT_NOT_REACHED(); } -void PaintableWidget::mousedown_event(GMouseEvent& event) +void PaintableWidget::mousedown_event(GUI::MouseEvent& event) { - if (event.button() == GMouseButton::Left || event.button() == GMouseButton::Right) { + if (event.button() == GUI::MouseButton::Left || event.button() == GUI::MouseButton::Right) { if (m_tool) m_tool->on_mousedown(event); } - GWidget::mousedown_event(event); + GUI::Widget::mousedown_event(event); } -void PaintableWidget::mouseup_event(GMouseEvent& event) +void PaintableWidget::mouseup_event(GUI::MouseEvent& event) { - if (event.button() == GMouseButton::Left || event.button() == GMouseButton::Right) { + if (event.button() == GUI::MouseButton::Left || event.button() == GUI::MouseButton::Right) { if (m_tool) m_tool->on_mouseup(event); } - GWidget::mouseup_event(event); + GUI::Widget::mouseup_event(event); } -void PaintableWidget::mousemove_event(GMouseEvent& event) +void PaintableWidget::mousemove_event(GUI::MouseEvent& event) { if (m_tool) m_tool->on_mousemove(event); - GWidget::mousemove_event(event); + GUI::Widget::mousemove_event(event); } -void PaintableWidget::second_paint_event(GPaintEvent& event) +void PaintableWidget::second_paint_event(GUI::PaintEvent& event) { if (m_tool) m_tool->on_second_paint(event); - GWidget::second_paint_event(event); + GUI::Widget::second_paint_event(event); } -void PaintableWidget::keydown_event(GKeyEvent& event) +void PaintableWidget::keydown_event(GUI::KeyEvent& event) { if (m_tool) m_tool->on_keydown(event); - GWidget::keydown_event(event); + GUI::Widget::keydown_event(event); } -void PaintableWidget::keyup_event(GKeyEvent& event) +void PaintableWidget::keyup_event(GUI::KeyEvent& event) { if (m_tool) m_tool->on_keyup(event); - GWidget::keyup_event(event); + GUI::Widget::keyup_event(event); } void PaintableWidget::set_primary_color(Color color) diff --git a/Applications/PaintBrush/PaintableWidget.h b/Applications/PaintBrush/PaintableWidget.h index 8f747b434c8..1883a4fa571 100644 --- a/Applications/PaintBrush/PaintableWidget.h +++ b/Applications/PaintBrush/PaintableWidget.h @@ -29,12 +29,12 @@ #include class Tool; -class PaintableWidget final : public GWidget { +class PaintableWidget final : public GUI::Widget { C_OBJECT(PaintableWidget) public: static PaintableWidget& the(); - explicit PaintableWidget(GWidget* parent); + explicit PaintableWidget(GUI::Widget* parent); virtual ~PaintableWidget() override; Color primary_color() const { return m_primary_color; } @@ -46,8 +46,8 @@ public: void set_tool(Tool* tool); Tool* tool(); - Color color_for(const GMouseEvent&) const; - Color color_for(GMouseButton) const; + Color color_for(const GUI::MouseEvent&) const; + Color color_for(GUI::MouseButton) const; void set_bitmap(const GraphicsBitmap&); @@ -59,13 +59,13 @@ public: private: virtual bool accepts_focus() const override { return true; } - virtual void paint_event(GPaintEvent&) override; - virtual void second_paint_event(GPaintEvent&) override; - virtual void mousedown_event(GMouseEvent&) override; - virtual void mouseup_event(GMouseEvent&) override; - virtual void mousemove_event(GMouseEvent&) override; - virtual void keydown_event(GKeyEvent&) override; - virtual void keyup_event(GKeyEvent&) override; + virtual void paint_event(GUI::PaintEvent&) override; + virtual void second_paint_event(GUI::PaintEvent&) override; + virtual void mousedown_event(GUI::MouseEvent&) override; + virtual void mouseup_event(GUI::MouseEvent&) override; + virtual void mousemove_event(GUI::MouseEvent&) override; + virtual void keydown_event(GUI::KeyEvent&) override; + virtual void keyup_event(GUI::KeyEvent&) override; RefPtr m_bitmap; diff --git a/Applications/PaintBrush/PaletteWidget.cpp b/Applications/PaintBrush/PaletteWidget.cpp index 2aa0157b00f..0760d3074e4 100644 --- a/Applications/PaintBrush/PaletteWidget.cpp +++ b/Applications/PaintBrush/PaletteWidget.cpp @@ -29,11 +29,11 @@ #include #include -class ColorWidget : public GFrame { +class ColorWidget : public GUI::Frame { C_OBJECT(ColorWidget) public: - explicit ColorWidget(Color color, PaletteWidget& palette_widget, GWidget* parent) - : GFrame(parent) + explicit ColorWidget(Color color, PaletteWidget& palette_widget, GUI::Widget* parent) + : GUI::Frame(parent) , m_palette_widget(palette_widget) , m_color(color) { @@ -46,11 +46,11 @@ public: { } - virtual void mousedown_event(GMouseEvent& event) override + virtual void mousedown_event(GUI::MouseEvent& event) override { - if (event.modifiers() & KeyModifier::Mod_Ctrl && event.button() == GMouseButton::Left) { - auto dialog = GColorPicker::construct(m_color, window()); - if (dialog->exec() == GDialog::ExecOK) { + if (event.modifiers() & KeyModifier::Mod_Ctrl && event.button() == GUI::MouseButton::Left) { + auto dialog = GUI::ColorPicker::construct(m_color, window()); + if (dialog->exec() == GUI::Dialog::ExecOK) { m_color = dialog->color(); auto pal = palette(); pal.set_color(ColorRole::Background, m_color); @@ -60,9 +60,9 @@ public: return; } - if (event.button() == GMouseButton::Left) + if (event.button() == GUI::MouseButton::Left) m_palette_widget.set_primary_color(m_color); - else if (event.button() == GMouseButton::Right) + else if (event.button() == GUI::MouseButton::Right) m_palette_widget.set_secondary_color(m_color); } @@ -71,8 +71,8 @@ private: Color m_color; }; -PaletteWidget::PaletteWidget(PaintableWidget& paintable_widget, GWidget* parent) - : GFrame(parent) +PaletteWidget::PaletteWidget(PaintableWidget& paintable_widget, GUI::Widget* parent) + : GUI::Frame(parent) , m_paintable_widget(paintable_widget) { set_frame_shape(FrameShape::Panel); @@ -80,10 +80,10 @@ PaletteWidget::PaletteWidget(PaintableWidget& paintable_widget, GWidget* parent) set_frame_thickness(0); set_fill_with_background_color(true); - set_size_policy(SizePolicy::Fill, SizePolicy::Fixed); + set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed); set_preferred_size(0, 34); - m_secondary_color_widget = GFrame::construct(this); + m_secondary_color_widget = GUI::Frame::construct(this); m_secondary_color_widget->set_frame_thickness(2); m_secondary_color_widget->set_frame_shape(FrameShape::Container); m_secondary_color_widget->set_frame_shadow(FrameShadow::Sunken); @@ -91,7 +91,7 @@ PaletteWidget::PaletteWidget(PaintableWidget& paintable_widget, GWidget* parent) m_secondary_color_widget->set_fill_with_background_color(true); set_secondary_color(paintable_widget.secondary_color()); - m_primary_color_widget = GFrame::construct(this); + m_primary_color_widget = GUI::Frame::construct(this); m_primary_color_widget->set_frame_thickness(2); m_primary_color_widget->set_frame_shape(FrameShape::Container); m_primary_color_widget->set_frame_shadow(FrameShadow::Sunken); @@ -109,20 +109,20 @@ PaletteWidget::PaletteWidget(PaintableWidget& paintable_widget, GWidget* parent) set_secondary_color(color); }; - auto color_container = GWidget::construct(this); + auto color_container = GUI::Widget::construct(this); color_container->set_relative_rect(m_secondary_color_widget->relative_rect().right() + 2, 2, 500, 32); - color_container->set_layout(make()); + color_container->set_layout(make()); color_container->layout()->set_spacing(1); - auto top_color_container = GWidget::construct(color_container.ptr()); - top_color_container->set_layout(make()); + auto top_color_container = GUI::Widget::construct(color_container.ptr()); + top_color_container->set_layout(make()); top_color_container->layout()->set_spacing(1); - auto bottom_color_container = GWidget::construct(color_container.ptr()); - bottom_color_container->set_layout(make()); + auto bottom_color_container = GUI::Widget::construct(color_container.ptr()); + bottom_color_container->set_layout(make()); bottom_color_container->layout()->set_spacing(1); - auto add_color_widget = [&](GWidget* container, Color color) { + auto add_color_widget = [&](GUI::Widget* container, Color color) { auto color_widget = ColorWidget::construct(color, *this, container); color_widget->set_fill_with_background_color(true); auto pal = color_widget->palette(); diff --git a/Applications/PaintBrush/PaletteWidget.h b/Applications/PaintBrush/PaletteWidget.h index 177f3b7777f..ca2934d32e0 100644 --- a/Applications/PaintBrush/PaletteWidget.h +++ b/Applications/PaintBrush/PaletteWidget.h @@ -30,10 +30,10 @@ class PaintableWidget; -class PaletteWidget final : public GFrame { +class PaletteWidget final : public GUI::Frame { C_OBJECT(PaletteWidget) public: - explicit PaletteWidget(PaintableWidget&, GWidget* parent); + explicit PaletteWidget(PaintableWidget&, GUI::Widget* parent); virtual ~PaletteWidget() override; void set_primary_color(Color); @@ -41,6 +41,6 @@ public: private: PaintableWidget& m_paintable_widget; - RefPtr m_primary_color_widget; - RefPtr m_secondary_color_widget; + RefPtr m_primary_color_widget; + RefPtr m_secondary_color_widget; }; diff --git a/Applications/PaintBrush/PenTool.cpp b/Applications/PaintBrush/PenTool.cpp index e670afa97f0..9dcb7114c45 100644 --- a/Applications/PaintBrush/PenTool.cpp +++ b/Applications/PaintBrush/PenTool.cpp @@ -38,30 +38,30 @@ PenTool::~PenTool() { } -void PenTool::on_mousedown(GMouseEvent& event) +void PenTool::on_mousedown(GUI::MouseEvent& event) { - if (event.button() != GMouseButton::Left && event.button() != GMouseButton::Right) + if (event.button() != GUI::MouseButton::Left && event.button() != GUI::MouseButton::Right) return; - GPainter painter(m_widget->bitmap()); + GUI::Painter painter(m_widget->bitmap()); painter.draw_line(event.position(), event.position(), m_widget->color_for(event), m_thickness); m_widget->update(); m_last_drawing_event_position = event.position(); } -void PenTool::on_mouseup(GMouseEvent& event) +void PenTool::on_mouseup(GUI::MouseEvent& event) { - if (event.button() == GMouseButton::Left || event.button() == GMouseButton::Right) + if (event.button() == GUI::MouseButton::Left || event.button() == GUI::MouseButton::Right) m_last_drawing_event_position = { -1, -1 }; } -void PenTool::on_mousemove(GMouseEvent& event) +void PenTool::on_mousemove(GUI::MouseEvent& event) { if (!m_widget->rect().contains(event.position())) return; - if (event.buttons() & GMouseButton::Left || event.buttons() & GMouseButton::Right) { - GPainter painter(m_widget->bitmap()); + if (event.buttons() & GUI::MouseButton::Left || event.buttons() & GUI::MouseButton::Right) { + GUI::Painter painter(m_widget->bitmap()); if (m_last_drawing_event_position != Point(-1, -1)) painter.draw_line(m_last_drawing_event_position, event.position(), m_widget->color_for(event), m_thickness); @@ -73,13 +73,13 @@ void PenTool::on_mousemove(GMouseEvent& event) } } -void PenTool::on_contextmenu(GContextMenuEvent& event) +void PenTool::on_contextmenu(GUI::ContextMenuEvent& event) { if (!m_context_menu) { - m_context_menu = GMenu::construct(); + m_context_menu = GUI::Menu::construct(); m_thickness_actions.set_exclusive(true); auto insert_action = [&](int size, bool checked = false) { - auto action = GAction::create(String::number(size), [this, size](auto& action) { + auto action = GUI::Action::create(String::number(size), [this, size](auto& action) { m_thickness = size; action.set_checked(true); }); diff --git a/Applications/PaintBrush/PenTool.h b/Applications/PaintBrush/PenTool.h index 3495c23b2a4..c98f58ba0af 100644 --- a/Applications/PaintBrush/PenTool.h +++ b/Applications/PaintBrush/PenTool.h @@ -30,23 +30,25 @@ #include #include -class GMenu; +namespace GUI { +class Menu; +} class PenTool final : public Tool { public: PenTool(); virtual ~PenTool() override; - virtual void on_mousedown(GMouseEvent&) override; - virtual void on_mousemove(GMouseEvent&) override; - virtual void on_mouseup(GMouseEvent&) override; - virtual void on_contextmenu(GContextMenuEvent&) override; + virtual void on_mousedown(GUI::MouseEvent&) override; + virtual void on_mousemove(GUI::MouseEvent&) override; + virtual void on_mouseup(GUI::MouseEvent&) override; + virtual void on_contextmenu(GUI::ContextMenuEvent&) override; private: virtual const char* class_name() const override { return "PenTool"; } Point m_last_drawing_event_position { -1, -1 }; - RefPtr m_context_menu; + RefPtr m_context_menu; int m_thickness { 1 }; - GActionGroup m_thickness_actions; + GUI::ActionGroup m_thickness_actions; }; diff --git a/Applications/PaintBrush/PickerTool.cpp b/Applications/PaintBrush/PickerTool.cpp index 491b5b9bc45..1eccbf97002 100644 --- a/Applications/PaintBrush/PickerTool.cpp +++ b/Applications/PaintBrush/PickerTool.cpp @@ -35,14 +35,14 @@ PickerTool::~PickerTool() { } -void PickerTool::on_mousedown(GMouseEvent& event) +void PickerTool::on_mousedown(GUI::MouseEvent& event) { ASSERT(m_widget); if (!m_widget->bitmap().rect().contains(event.position())) return; auto color = m_widget->bitmap().get_pixel(event.position()); - if (event.button() == GMouseButton::Left) + if (event.button() == GUI::MouseButton::Left) m_widget->set_primary_color(color); - else if (event.button() == GMouseButton::Right) + else if (event.button() == GUI::MouseButton::Right) m_widget->set_secondary_color(color); } diff --git a/Applications/PaintBrush/PickerTool.h b/Applications/PaintBrush/PickerTool.h index f1d0846edbb..6ae0244b975 100644 --- a/Applications/PaintBrush/PickerTool.h +++ b/Applications/PaintBrush/PickerTool.h @@ -33,7 +33,7 @@ public: PickerTool(); virtual ~PickerTool() override; - virtual void on_mousedown(GMouseEvent&) override; + virtual void on_mousedown(GUI::MouseEvent&) override; private: virtual const char* class_name() const override { return "PickerTool"; } diff --git a/Applications/PaintBrush/RectangleTool.cpp b/Applications/PaintBrush/RectangleTool.cpp index c408e298b07..d3afc1c6f06 100644 --- a/Applications/PaintBrush/RectangleTool.cpp +++ b/Applications/PaintBrush/RectangleTool.cpp @@ -40,7 +40,7 @@ RectangleTool::~RectangleTool() { } -void RectangleTool::draw_using(Painter& painter) +void RectangleTool::draw_using(GUI::Painter& painter) { auto rect_to_draw = Rect::from_two_points(m_rectangle_start_position, m_rectangle_end_position); switch (m_mode) { @@ -58,12 +58,12 @@ void RectangleTool::draw_using(Painter& painter) } } -void RectangleTool::on_mousedown(GMouseEvent& event) +void RectangleTool::on_mousedown(GUI::MouseEvent& event) { - if (event.button() != GMouseButton::Left && event.button() != GMouseButton::Right) + if (event.button() != GUI::MouseButton::Left && event.button() != GUI::MouseButton::Right) return; - if (m_drawing_button != GMouseButton::None) + if (m_drawing_button != GUI::MouseButton::None) return; m_drawing_button = event.button(); @@ -72,19 +72,19 @@ void RectangleTool::on_mousedown(GMouseEvent& event) m_widget->update(); } -void RectangleTool::on_mouseup(GMouseEvent& event) +void RectangleTool::on_mouseup(GUI::MouseEvent& event) { if (event.button() == m_drawing_button) { - GPainter painter(m_widget->bitmap()); + GUI::Painter painter(m_widget->bitmap()); draw_using(painter); - m_drawing_button = GMouseButton::None; + m_drawing_button = GUI::MouseButton::None; m_widget->update(); } } -void RectangleTool::on_mousemove(GMouseEvent& event) +void RectangleTool::on_mousemove(GUI::MouseEvent& event) { - if (m_drawing_button == GMouseButton::None) + if (m_drawing_button == GUI::MouseButton::None) return; if (!m_widget->rect().contains(event.position())) @@ -94,36 +94,36 @@ void RectangleTool::on_mousemove(GMouseEvent& event) m_widget->update(); } -void RectangleTool::on_second_paint(GPaintEvent& event) +void RectangleTool::on_second_paint(GUI::PaintEvent& event) { - if (m_drawing_button == GMouseButton::None) + if (m_drawing_button == GUI::MouseButton::None) return; - GPainter painter(*m_widget); + GUI::Painter painter(*m_widget); painter.add_clip_rect(event.rect()); draw_using(painter); } -void RectangleTool::on_keydown(GKeyEvent& event) +void RectangleTool::on_keydown(GUI::KeyEvent& event) { - if (event.key() == Key_Escape && m_drawing_button != GMouseButton::None) { - m_drawing_button = GMouseButton::None; + if (event.key() == Key_Escape && m_drawing_button != GUI::MouseButton::None) { + m_drawing_button = GUI::MouseButton::None; m_widget->update(); event.accept(); } } -void RectangleTool::on_contextmenu(GContextMenuEvent& event) +void RectangleTool::on_contextmenu(GUI::ContextMenuEvent& event) { if (!m_context_menu) { - m_context_menu = GMenu::construct(); - m_context_menu->add_action(GAction::create("Fill", [this](auto&) { + m_context_menu = GUI::Menu::construct(); + m_context_menu->add_action(GUI::Action::create("Fill", [this](auto&) { m_mode = Mode::Fill; })); - m_context_menu->add_action(GAction::create("Outline", [this](auto&) { + m_context_menu->add_action(GUI::Action::create("Outline", [this](auto&) { m_mode = Mode::Outline; })); - m_context_menu->add_action(GAction::create("Gradient", [this](auto&) { + m_context_menu->add_action(GUI::Action::create("Gradient", [this](auto&) { m_mode = Mode::Gradient; })); } diff --git a/Applications/PaintBrush/RectangleTool.h b/Applications/PaintBrush/RectangleTool.h index 9f216daa2da..2e507acd0df 100644 --- a/Applications/PaintBrush/RectangleTool.h +++ b/Applications/PaintBrush/RectangleTool.h @@ -29,20 +29,22 @@ #include "Tool.h" #include -class GMenu; +namespace GUI { +class Menu; class Painter; +} class RectangleTool final : public Tool { public: RectangleTool(); virtual ~RectangleTool() override; - virtual void on_mousedown(GMouseEvent&) override; - virtual void on_mousemove(GMouseEvent&) override; - virtual void on_mouseup(GMouseEvent&) override; - virtual void on_contextmenu(GContextMenuEvent&) override; - virtual void on_second_paint(GPaintEvent&) override; - virtual void on_keydown(GKeyEvent&) override; + virtual void on_mousedown(GUI::MouseEvent&) override; + virtual void on_mousemove(GUI::MouseEvent&) override; + virtual void on_mouseup(GUI::MouseEvent&) override; + virtual void on_contextmenu(GUI::ContextMenuEvent&) override; + virtual void on_second_paint(GUI::PaintEvent&) override; + virtual void on_keydown(GUI::KeyEvent&) override; private: enum class Mode { @@ -52,11 +54,11 @@ private: }; virtual const char* class_name() const override { return "RectangleTool"; } - void draw_using(Painter& painter); + void draw_using(GUI::Painter& painter); - GMouseButton m_drawing_button { GMouseButton::None }; + GUI::MouseButton m_drawing_button { GUI::MouseButton::None }; Point m_rectangle_start_position; Point m_rectangle_end_position; - RefPtr m_context_menu; + RefPtr m_context_menu; Mode m_mode { Mode::Outline }; }; diff --git a/Applications/PaintBrush/SprayTool.cpp b/Applications/PaintBrush/SprayTool.cpp index a224de9b98b..cb07adf2626 100644 --- a/Applications/PaintBrush/SprayTool.cpp +++ b/Applications/PaintBrush/SprayTool.cpp @@ -55,7 +55,7 @@ static double nrand() void SprayTool::paint_it() { - GPainter painter(m_widget->bitmap()); + GUI::Painter painter(m_widget->bitmap()); auto& bitmap = m_widget->bitmap(); ASSERT(bitmap.bpp() == 32); m_widget->update(); @@ -74,7 +74,7 @@ void SprayTool::paint_it() } } -void SprayTool::on_mousedown(GMouseEvent& event) +void SprayTool::on_mousedown(GUI::MouseEvent& event) { if (!m_widget->rect().contains(event.position())) return; @@ -85,7 +85,7 @@ void SprayTool::on_mousedown(GMouseEvent& event) paint_it(); } -void SprayTool::on_mousemove(GMouseEvent& event) +void SprayTool::on_mousemove(GUI::MouseEvent& event) { m_last_pos = event.position(); if (m_timer->is_active()) { @@ -94,18 +94,18 @@ void SprayTool::on_mousemove(GMouseEvent& event) } } -void SprayTool::on_mouseup(GMouseEvent&) +void SprayTool::on_mouseup(GUI::MouseEvent&) { m_timer->stop(); } -void SprayTool::on_contextmenu(GContextMenuEvent& event) +void SprayTool::on_contextmenu(GUI::ContextMenuEvent& event) { if (!m_context_menu) { - m_context_menu = GMenu::construct(); + m_context_menu = GUI::Menu::construct(); m_thickness_actions.set_exclusive(true); auto insert_action = [&](int size, bool checked = false) { - auto action = GAction::create(String::number(size), [this, size](auto& action) { + auto action = GUI::Action::create(String::number(size), [this, size](auto& action) { m_thickness = size; action.set_checked(true); }); diff --git a/Applications/PaintBrush/SprayTool.h b/Applications/PaintBrush/SprayTool.h index ce48eca5017..65bbe7c7388 100644 --- a/Applications/PaintBrush/SprayTool.h +++ b/Applications/PaintBrush/SprayTool.h @@ -31,17 +31,19 @@ #include #include -class GMenu; +namespace GUI { +class Menu; +} class SprayTool final : public Tool { public: SprayTool(); virtual ~SprayTool() override; - virtual void on_mousedown(GMouseEvent&) override; - virtual void on_mouseup(GMouseEvent&) override; - virtual void on_mousemove(GMouseEvent&) override; - virtual void on_contextmenu(GContextMenuEvent&) override; + virtual void on_mousedown(GUI::MouseEvent&) override; + virtual void on_mouseup(GUI::MouseEvent&) override; + virtual void on_mousemove(GUI::MouseEvent&) override; + virtual void on_contextmenu(GUI::ContextMenuEvent&) override; private: virtual const char* class_name() const override { return "SprayTool"; } @@ -49,7 +51,7 @@ private: RefPtr m_timer; Point m_last_pos; Color m_color; - RefPtr m_context_menu; - GActionGroup m_thickness_actions; + RefPtr m_context_menu; + GUI::ActionGroup m_thickness_actions; int m_thickness { 1 }; }; diff --git a/Applications/PaintBrush/Tool.h b/Applications/PaintBrush/Tool.h index 30ee3416cb4..24fbde83a83 100644 --- a/Applications/PaintBrush/Tool.h +++ b/Applications/PaintBrush/Tool.h @@ -34,13 +34,13 @@ public: virtual const char* class_name() const = 0; - virtual void on_mousedown(GMouseEvent&) {} - virtual void on_mousemove(GMouseEvent&) {} - virtual void on_mouseup(GMouseEvent&) {} - virtual void on_contextmenu(GContextMenuEvent&) {} - virtual void on_second_paint(GPaintEvent&) {} - virtual void on_keydown(GKeyEvent&) {} - virtual void on_keyup(GKeyEvent&) {} + virtual void on_mousedown(GUI::MouseEvent&) {} + virtual void on_mousemove(GUI::MouseEvent&) {} + virtual void on_mouseup(GUI::MouseEvent&) {} + virtual void on_contextmenu(GUI::ContextMenuEvent&) {} + virtual void on_second_paint(GUI::PaintEvent&) {} + virtual void on_keydown(GUI::KeyEvent&) {} + virtual void on_keyup(GUI::KeyEvent&) {} void clear() { m_widget = nullptr; } void setup(PaintableWidget& widget) { m_widget = widget.make_weak_ptr(); } diff --git a/Applications/PaintBrush/ToolboxWidget.cpp b/Applications/PaintBrush/ToolboxWidget.cpp index 94d1e607ad7..3f0708cc68c 100644 --- a/Applications/PaintBrush/ToolboxWidget.cpp +++ b/Applications/PaintBrush/ToolboxWidget.cpp @@ -38,11 +38,11 @@ #include #include -class ToolButton final : public GButton { +class ToolButton final : public GUI::Button { C_OBJECT(ToolButton) public: - ToolButton(const String& name, GWidget* parent, OwnPtr&& tool) - : GButton(parent) + ToolButton(const String& name, GUI::Widget* parent, OwnPtr&& tool) + : GUI::Button(parent) , m_tool(move(tool)) { set_tooltip(name); @@ -51,7 +51,7 @@ public: const Tool& tool() const { return *m_tool; } Tool& tool() { return *m_tool; } - virtual void context_menu_event(GContextMenuEvent& event) override + virtual void context_menu_event(GUI::ContextMenuEvent& event) override { set_checked(true); m_tool->on_contextmenu(event); @@ -61,8 +61,8 @@ private: OwnPtr m_tool; }; -ToolboxWidget::ToolboxWidget(GWidget* parent) - : GFrame(parent) +ToolboxWidget::ToolboxWidget(GUI::Widget* parent) + : GUI::Frame(parent) { set_fill_with_background_color(true); @@ -70,15 +70,15 @@ ToolboxWidget::ToolboxWidget(GWidget* parent) set_frame_shape(FrameShape::Panel); set_frame_shadow(FrameShadow::Raised); - set_size_policy(SizePolicy::Fixed, SizePolicy::Fill); + set_size_policy(GUI::SizePolicy::Fixed, GUI::SizePolicy::Fill); set_preferred_size(48, 0); - set_layout(make()); + set_layout(make()); layout()->set_margins({ 4, 4, 4, 4 }); auto add_tool = [&](const StringView& name, const StringView& icon_name, OwnPtr&& tool) { auto button = ToolButton::construct(name, this, move(tool)); - button->set_size_policy(SizePolicy::Fill, SizePolicy::Fixed); + button->set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed); button->set_preferred_size(0, 32); button->set_checkable(true); button->set_exclusive(true); diff --git a/Applications/PaintBrush/ToolboxWidget.h b/Applications/PaintBrush/ToolboxWidget.h index e510497a2c4..2906064ac89 100644 --- a/Applications/PaintBrush/ToolboxWidget.h +++ b/Applications/PaintBrush/ToolboxWidget.h @@ -28,9 +28,9 @@ #include -class ToolboxWidget final : public GFrame { +class ToolboxWidget final : public GUI::Frame { C_OBJECT(ToolboxWidget) public: - explicit ToolboxWidget(GWidget* parent); + explicit ToolboxWidget(GUI::Widget* parent); virtual ~ToolboxWidget() override; }; diff --git a/Applications/PaintBrush/main.cpp b/Applications/PaintBrush/main.cpp index 20ed47eca48..9ce2ffc7bce 100644 --- a/Applications/PaintBrush/main.cpp +++ b/Applications/PaintBrush/main.cpp @@ -46,27 +46,27 @@ int main(int argc, char** argv) return 1; } - GApplication app(argc, argv); + GUI::Application app(argc, argv); if (pledge("stdio shared_buffer accept rpath wpath cpath", nullptr) < 0) { perror("pledge"); return 1; } - auto window = GWindow::construct(); + auto window = GUI::Window::construct(); window->set_title("PaintBrush"); window->set_rect(100, 100, 640, 480); window->set_icon(load_png("/res/icons/16x16/app-paintbrush.png")); - auto horizontal_container = GWidget::construct(); + auto horizontal_container = GUI::Widget::construct(); window->set_main_widget(horizontal_container); - horizontal_container->set_layout(make()); + horizontal_container->set_layout(make()); horizontal_container->layout()->set_spacing(0); new ToolboxWidget(horizontal_container); - auto vertical_container = GWidget::construct(horizontal_container.ptr()); - vertical_container->set_layout(make()); + auto vertical_container = GUI::Widget::construct(horizontal_container.ptr()); + vertical_container->set_layout(make()); vertical_container->layout()->set_spacing(0); auto paintable_widget = PaintableWidget::construct(vertical_container); @@ -75,36 +75,36 @@ int main(int argc, char** argv) window->show(); - auto menubar = make(); - auto app_menu = GMenu::construct("PaintBrush"); + auto menubar = make(); + auto app_menu = GUI::Menu::construct("PaintBrush"); - app_menu->add_action(GCommonActions::make_open_action([&](auto&) { - Optional open_path = GFilePicker::get_open_filepath(); + app_menu->add_action(GUI::CommonActions::make_open_action([&](auto&) { + Optional open_path = GUI::FilePicker::get_open_filepath(); if (!open_path.has_value()) return; auto bitmap = load_png(open_path.value()); if (!bitmap) { - GMessageBox::show(String::format("Failed to load '%s'", open_path.value().characters()), "Open failed", GMessageBox::Type::Error, GMessageBox::InputType::OK, window); + GUI::MessageBox::show(String::format("Failed to load '%s'", open_path.value().characters()), "Open failed", GUI::MessageBox::Type::Error, GUI::MessageBox::InputType::OK, window); return; } paintable_widget->set_bitmap(*bitmap); })); app_menu->add_separator(); - app_menu->add_action(GCommonActions::make_quit_action([](auto&) { - GApplication::the().quit(0); + app_menu->add_action(GUI::CommonActions::make_quit_action([](auto&) { + GUI::Application::the().quit(0); return; })); menubar->add_menu(move(app_menu)); - auto edit_menu = GMenu::construct("Edit"); + auto edit_menu = GUI::Menu::construct("Edit"); menubar->add_menu(move(edit_menu)); - auto help_menu = GMenu::construct("Help"); - help_menu->add_action(GAction::create("About", [&](auto&) { - GAboutDialog::show("PaintBrush", load_png("/res/icons/32x32/app-paintbrush.png"), window); + auto help_menu = GUI::Menu::construct("Help"); + help_menu->add_action(GUI::Action::create("About", [&](auto&) { + GUI::AboutDialog::show("PaintBrush", load_png("/res/icons/32x32/app-paintbrush.png"), window); })); menubar->add_menu(move(help_menu)); diff --git a/Applications/Piano/KeysWidget.cpp b/Applications/Piano/KeysWidget.cpp index 36d4ce19e69..77608e31bce 100644 --- a/Applications/Piano/KeysWidget.cpp +++ b/Applications/Piano/KeysWidget.cpp @@ -29,8 +29,8 @@ #include "AudioEngine.h" #include -KeysWidget::KeysWidget(GWidget* parent, AudioEngine& audio_engine) - : GFrame(parent) +KeysWidget::KeysWidget(GUI::Widget* parent, AudioEngine& audio_engine) + : GUI::Frame(parent) , m_audio_engine(audio_engine) { set_frame_thickness(2); @@ -174,9 +174,9 @@ constexpr int black_key_note_accumulator[] = { 3, }; -void KeysWidget::paint_event(GPaintEvent& event) +void KeysWidget::paint_event(GUI::PaintEvent& event) { - GPainter painter(*this); + GUI::Painter painter(*this); painter.translate(frame_thickness(), frame_thickness()); int note = 0; @@ -223,7 +223,7 @@ void KeysWidget::paint_event(GPaintEvent& event) break; } - GFrame::paint_event(event); + GUI::Frame::paint_event(event); } constexpr int notes_per_white_key[] = { @@ -278,9 +278,9 @@ int KeysWidget::note_for_event_position(Point point) const return note; } -void KeysWidget::mousedown_event(GMouseEvent& event) +void KeysWidget::mousedown_event(GUI::MouseEvent& event) { - if (event.button() != Left) + if (event.button() != GUI::MouseButton::Left) return; m_mouse_down = true; @@ -291,9 +291,9 @@ void KeysWidget::mousedown_event(GMouseEvent& event) update(); } -void KeysWidget::mouseup_event(GMouseEvent& event) +void KeysWidget::mouseup_event(GUI::MouseEvent& event) { - if (event.button() != Left) + if (event.button() != GUI::MouseButton::Left) return; m_mouse_down = false; @@ -302,7 +302,7 @@ void KeysWidget::mouseup_event(GMouseEvent& event) update(); } -void KeysWidget::mousemove_event(GMouseEvent& event) +void KeysWidget::mousemove_event(GUI::MouseEvent& event) { if (!m_mouse_down) return; diff --git a/Applications/Piano/KeysWidget.h b/Applications/Piano/KeysWidget.h index c8cdb315ae4..a051457b8d9 100644 --- a/Applications/Piano/KeysWidget.h +++ b/Applications/Piano/KeysWidget.h @@ -32,7 +32,7 @@ class AudioEngine; -class KeysWidget final : public GFrame { +class KeysWidget final : public GUI::Frame { C_OBJECT(KeysWidget) public: virtual ~KeysWidget() override; @@ -43,12 +43,12 @@ public: void set_key(int key, Switch); private: - KeysWidget(GWidget* parent, AudioEngine&); + KeysWidget(GUI::Widget* parent, AudioEngine&); - virtual void paint_event(GPaintEvent&) override; - virtual void mousedown_event(GMouseEvent&) override; - virtual void mouseup_event(GMouseEvent&) override; - virtual void mousemove_event(GMouseEvent&) override; + virtual void paint_event(GUI::PaintEvent&) override; + virtual void mousedown_event(GUI::MouseEvent&) override; + virtual void mouseup_event(GUI::MouseEvent&) override; + virtual void mousemove_event(GUI::MouseEvent&) override; int note_for_event_position(Point) const; diff --git a/Applications/Piano/KnobsWidget.cpp b/Applications/Piano/KnobsWidget.cpp index 61305452413..f543281edc8 100644 --- a/Applications/Piano/KnobsWidget.cpp +++ b/Applications/Piano/KnobsWidget.cpp @@ -32,43 +32,43 @@ #include #include -KnobsWidget::KnobsWidget(GWidget* parent, AudioEngine& audio_engine, MainWidget& main_widget) - : GFrame(parent) +KnobsWidget::KnobsWidget(GUI::Widget* parent, AudioEngine& audio_engine, MainWidget& main_widget) + : GUI::Frame(parent) , m_audio_engine(audio_engine) , m_main_widget(main_widget) { set_frame_thickness(2); set_frame_shadow(FrameShadow::Sunken); set_frame_shape(FrameShape::Container); - set_layout(make()); + set_layout(make()); set_fill_with_background_color(true); - m_labels_container = GWidget::construct(this); - m_labels_container->set_layout(make()); - m_labels_container->set_size_policy(SizePolicy::Fill, SizePolicy::Fixed); + m_labels_container = GUI::Widget::construct(this); + m_labels_container->set_layout(make()); + m_labels_container->set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed); m_labels_container->set_preferred_size(0, 20); - m_octave_label = GLabel::construct("Octave", m_labels_container); - m_wave_label = GLabel::construct("Wave", m_labels_container); - m_decay_label = GLabel::construct("Decay", m_labels_container); - m_delay_label = GLabel::construct("Delay", m_labels_container); + m_octave_label = GUI::Label::construct("Octave", m_labels_container); + m_wave_label = GUI::Label::construct("Wave", m_labels_container); + m_decay_label = GUI::Label::construct("Decay", m_labels_container); + m_delay_label = GUI::Label::construct("Delay", m_labels_container); - m_values_container = GWidget::construct(this); - m_values_container->set_layout(make()); - m_values_container->set_size_policy(SizePolicy::Fill, SizePolicy::Fixed); + m_values_container = GUI::Widget::construct(this); + m_values_container->set_layout(make()); + m_values_container->set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed); m_values_container->set_preferred_size(0, 10); - m_octave_value = GLabel::construct(String::number(m_audio_engine.octave()), m_values_container); - m_wave_value = GLabel::construct(wave_strings[m_audio_engine.wave()], m_values_container); - m_decay_value = GLabel::construct(String::number(m_audio_engine.decay()), m_values_container); - m_delay_value = GLabel::construct(String::number(m_audio_engine.delay() / m_audio_engine.tick()), m_values_container); + m_octave_value = GUI::Label::construct(String::number(m_audio_engine.octave()), m_values_container); + m_wave_value = GUI::Label::construct(wave_strings[m_audio_engine.wave()], m_values_container); + m_decay_value = GUI::Label::construct(String::number(m_audio_engine.decay()), m_values_container); + m_delay_value = GUI::Label::construct(String::number(m_audio_engine.delay() / m_audio_engine.tick()), m_values_container); - m_knobs_container = GWidget::construct(this); - m_knobs_container->set_layout(make()); + m_knobs_container = GUI::Widget::construct(this); + m_knobs_container->set_layout(make()); // FIXME: Implement vertical flipping in GSlider, not here. - m_octave_knob = GSlider::construct(Orientation::Vertical, m_knobs_container); + m_octave_knob = GUI::Slider::construct(Orientation::Vertical, m_knobs_container); m_octave_knob->set_tooltip("Z: octave down, X: octave up"); m_octave_knob->set_range(octave_min - 1, octave_max - 1); m_octave_knob->set_value(m_audio_engine.octave() - 1); @@ -80,7 +80,7 @@ KnobsWidget::KnobsWidget(GWidget* parent, AudioEngine& audio_engine, MainWidget& m_octave_value->set_text(String::number(new_octave)); }; - m_wave_knob = GSlider::construct(Orientation::Vertical, m_knobs_container); + m_wave_knob = GUI::Slider::construct(Orientation::Vertical, m_knobs_container); m_wave_knob->set_tooltip("C: cycle through waveforms"); m_wave_knob->set_range(0, last_wave); m_wave_knob->set_value(last_wave - m_audio_engine.wave()); @@ -92,7 +92,7 @@ KnobsWidget::KnobsWidget(GWidget* parent, AudioEngine& audio_engine, MainWidget& }; constexpr int max_decay = 20; - m_decay_knob = GSlider::construct(Orientation::Vertical, m_knobs_container); + m_decay_knob = GUI::Slider::construct(Orientation::Vertical, m_knobs_container); m_decay_knob->set_range(0, max_decay); m_decay_knob->set_value(max_decay); m_decay_knob->on_value_changed = [this](int value) { @@ -103,7 +103,7 @@ KnobsWidget::KnobsWidget(GWidget* parent, AudioEngine& audio_engine, MainWidget& }; constexpr int max_delay = 8; - m_delay_knob = GSlider::construct(Orientation::Vertical, m_knobs_container); + m_delay_knob = GUI::Slider::construct(Orientation::Vertical, m_knobs_container); m_delay_knob->set_range(0, max_delay); m_delay_knob->set_value(max_delay); m_delay_knob->on_value_changed = [this](int value) { diff --git a/Applications/Piano/KnobsWidget.h b/Applications/Piano/KnobsWidget.h index a2f6f2f0e64..715074dbe43 100644 --- a/Applications/Piano/KnobsWidget.h +++ b/Applications/Piano/KnobsWidget.h @@ -29,12 +29,15 @@ #include -class GSlider; -class GLabel; +namespace GUI { +class Label; +class Slider; +} + class AudioEngine; class MainWidget; -class KnobsWidget final : public GFrame { +class KnobsWidget final : public GUI::Frame { C_OBJECT(KnobsWidget) public: virtual ~KnobsWidget() override; @@ -42,28 +45,28 @@ public: void update_knobs(); private: - KnobsWidget(GWidget* parent, AudioEngine&, MainWidget&); + KnobsWidget(GUI::Widget* parent, AudioEngine&, MainWidget&); AudioEngine& m_audio_engine; MainWidget& m_main_widget; - RefPtr m_labels_container; - RefPtr m_octave_label; - RefPtr m_wave_label; - RefPtr m_decay_label; - RefPtr m_delay_label; + RefPtr m_labels_container; + RefPtr m_octave_label; + RefPtr m_wave_label; + RefPtr m_decay_label; + RefPtr m_delay_label; - RefPtr m_values_container; - RefPtr m_octave_value; - RefPtr m_wave_value; - RefPtr m_decay_value; - RefPtr m_delay_value; + RefPtr m_values_container; + RefPtr m_octave_value; + RefPtr m_wave_value; + RefPtr m_decay_value; + RefPtr m_delay_value; - RefPtr m_knobs_container; - RefPtr m_octave_knob; - RefPtr m_wave_knob; - RefPtr m_decay_knob; - RefPtr m_delay_knob; + RefPtr m_knobs_container; + RefPtr m_octave_knob; + RefPtr m_wave_knob; + RefPtr m_decay_knob; + RefPtr m_delay_knob; bool m_change_octave { true }; }; diff --git a/Applications/Piano/MainWidget.cpp b/Applications/Piano/MainWidget.cpp index cf597f6584f..7469414d489 100644 --- a/Applications/Piano/MainWidget.cpp +++ b/Applications/Piano/MainWidget.cpp @@ -36,30 +36,30 @@ MainWidget::MainWidget(AudioEngine& audio_engine) : m_audio_engine(audio_engine) { - set_layout(make()); + set_layout(make()); layout()->set_spacing(2); layout()->set_margins({ 2, 2, 2, 2 }); set_fill_with_background_color(true); m_wave_widget = WaveWidget::construct(this, audio_engine); - m_wave_widget->set_size_policy(SizePolicy::Fill, SizePolicy::Fixed); + m_wave_widget->set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed); m_wave_widget->set_preferred_size(0, 100); m_roll_widget = RollWidget::construct(this, audio_engine); - m_roll_widget->set_size_policy(SizePolicy::Fill, SizePolicy::Fill); + m_roll_widget->set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fill); m_roll_widget->set_preferred_size(0, 300); - m_keys_and_knobs_container = GWidget::construct(this); - m_keys_and_knobs_container->set_layout(make()); + m_keys_and_knobs_container = GUI::Widget::construct(this); + m_keys_and_knobs_container->set_layout(make()); m_keys_and_knobs_container->layout()->set_spacing(2); - m_keys_and_knobs_container->set_size_policy(SizePolicy::Fill, SizePolicy::Fixed); + m_keys_and_knobs_container->set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed); m_keys_and_knobs_container->set_preferred_size(0, 100); m_keys_and_knobs_container->set_fill_with_background_color(true); m_keys_widget = KeysWidget::construct(m_keys_and_knobs_container, audio_engine); m_knobs_widget = KnobsWidget::construct(m_keys_and_knobs_container, audio_engine, *this); - m_knobs_widget->set_size_policy(SizePolicy::Fixed, SizePolicy::Fill); + m_knobs_widget->set_size_policy(GUI::SizePolicy::Fixed, GUI::SizePolicy::Fill); m_knobs_widget->set_preferred_size(200, 0); } @@ -78,7 +78,7 @@ void MainWidget::custom_event(Core::CustomEvent&) m_roll_widget->update_roll(); } -void MainWidget::keydown_event(GKeyEvent& event) +void MainWidget::keydown_event(GUI::KeyEvent& event) { // This is to stop held-down keys from creating multiple events. if (m_keys_pressed[event.key()]) @@ -91,7 +91,7 @@ void MainWidget::keydown_event(GKeyEvent& event) m_keys_widget->update(); } -void MainWidget::keyup_event(GKeyEvent& event) +void MainWidget::keyup_event(GUI::KeyEvent& event) { m_keys_pressed[event.key()] = false; diff --git a/Applications/Piano/MainWidget.h b/Applications/Piano/MainWidget.h index 2a85ff4ab74..4b3ee1c034a 100644 --- a/Applications/Piano/MainWidget.h +++ b/Applications/Piano/MainWidget.h @@ -36,7 +36,7 @@ class RollWidget; class KeysWidget; class KnobsWidget; -class MainWidget final : public GWidget { +class MainWidget final : public GUI::Widget { C_OBJECT(MainWidget) public: virtual ~MainWidget() override; @@ -46,8 +46,8 @@ public: private: explicit MainWidget(AudioEngine&); - virtual void keydown_event(GKeyEvent&) override; - virtual void keyup_event(GKeyEvent&) override; + virtual void keydown_event(GUI::KeyEvent&) override; + virtual void keyup_event(GUI::KeyEvent&) override; virtual void custom_event(Core::CustomEvent&) override; void note_key_action(int key_code, Switch); @@ -57,7 +57,7 @@ private: RefPtr m_wave_widget; RefPtr m_roll_widget; - RefPtr m_keys_and_knobs_container; + RefPtr m_keys_and_knobs_container; RefPtr m_keys_widget; RefPtr m_knobs_widget; diff --git a/Applications/Piano/RollWidget.cpp b/Applications/Piano/RollWidget.cpp index 4f919ef0fc0..325cafe8802 100644 --- a/Applications/Piano/RollWidget.cpp +++ b/Applications/Piano/RollWidget.cpp @@ -33,8 +33,8 @@ constexpr int note_height = 20; constexpr int roll_height = note_count * note_height; -RollWidget::RollWidget(GWidget* parent, AudioEngine& audio_engine) - : GScrollableWidget(parent) +RollWidget::RollWidget(GUI::Widget* parent, AudioEngine& audio_engine) + : ScrollableWidget(parent) , m_audio_engine(audio_engine) { set_frame_thickness(2); @@ -50,7 +50,7 @@ RollWidget::~RollWidget() { } -void RollWidget::paint_event(GPaintEvent& event) +void RollWidget::paint_event(GUI::PaintEvent& event) { int roll_width = widget_inner_rect().width(); double note_width = static_cast(roll_width) / m_horizontal_notes; @@ -68,7 +68,7 @@ void RollWidget::paint_event(GPaintEvent& event) int notes_to_paint = paint_area / note_height; int key_pattern_index = (notes_per_octave - 1) - (note_offset % notes_per_octave); - GPainter painter(*this); + GUI::Painter painter(*this); painter.translate(frame_thickness(), frame_thickness()); painter.translate(0, -note_offset_remainder); @@ -99,10 +99,10 @@ void RollWidget::paint_event(GPaintEvent& event) key_pattern_index = notes_per_octave - 1; } - GFrame::paint_event(event); + GUI::Frame::paint_event(event); } -void RollWidget::mousedown_event(GMouseEvent& event) +void RollWidget::mousedown_event(GUI::MouseEvent& event) { if (!widget_inner_rect().contains(event.x(), event.y())) return; diff --git a/Applications/Piano/RollWidget.h b/Applications/Piano/RollWidget.h index 91c0c8aefdf..3cd3d5d44b2 100644 --- a/Applications/Piano/RollWidget.h +++ b/Applications/Piano/RollWidget.h @@ -32,7 +32,7 @@ class AudioEngine; -class RollWidget final : public GScrollableWidget { +class RollWidget final : public GUI::ScrollableWidget { C_OBJECT(RollWidget) public: virtual ~RollWidget() override; @@ -40,10 +40,10 @@ public: void update_roll(); private: - RollWidget(GWidget* parent, AudioEngine&); + RollWidget(GUI::Widget* parent, AudioEngine&); - virtual void paint_event(GPaintEvent&) override; - virtual void mousedown_event(GMouseEvent& event) override; + virtual void paint_event(GUI::PaintEvent&) override; + virtual void mousedown_event(GUI::MouseEvent& event) override; AudioEngine& m_audio_engine; diff --git a/Applications/Piano/WaveWidget.cpp b/Applications/Piano/WaveWidget.cpp index 2c0d014d6f7..5a66c6e08f2 100644 --- a/Applications/Piano/WaveWidget.cpp +++ b/Applications/Piano/WaveWidget.cpp @@ -30,8 +30,8 @@ #include #include -WaveWidget::WaveWidget(GWidget* parent, AudioEngine& audio_engine) - : GFrame(parent) +WaveWidget::WaveWidget(GUI::Widget* parent, AudioEngine& audio_engine) + : GUI::Frame(parent) , m_audio_engine(audio_engine) { set_frame_thickness(2); @@ -85,9 +85,9 @@ int WaveWidget::sample_to_y(int sample) const return y; } -void WaveWidget::paint_event(GPaintEvent& event) +void WaveWidget::paint_event(GUI::PaintEvent& event) { - GPainter painter(*this); + GUI::Painter painter(*this); painter.fill_rect(frame_inner_rect(), Color::Black); painter.translate(frame_thickness(), frame_thickness()); @@ -110,5 +110,5 @@ void WaveWidget::paint_event(GPaintEvent& event) prev_y = y; } - GFrame::paint_event(event); + GUI::Frame::paint_event(event); } diff --git a/Applications/Piano/WaveWidget.h b/Applications/Piano/WaveWidget.h index 1a8d9f72cd6..403968b7ddc 100644 --- a/Applications/Piano/WaveWidget.h +++ b/Applications/Piano/WaveWidget.h @@ -29,18 +29,17 @@ #include -class GPainter; class AudioEngine; -class WaveWidget final : public GFrame { +class WaveWidget final : public GUI::Frame { C_OBJECT(WaveWidget) public: virtual ~WaveWidget() override; private: - WaveWidget(GWidget* parent, AudioEngine&); + WaveWidget(GUI::Widget* parent, AudioEngine&); - virtual void paint_event(GPaintEvent&) override; + virtual void paint_event(GUI::PaintEvent&) override; int sample_to_y(int sample) const; diff --git a/Applications/Piano/main.cpp b/Applications/Piano/main.cpp index d33c0f70b85..b2880aef0e2 100644 --- a/Applications/Piano/main.cpp +++ b/Applications/Piano/main.cpp @@ -39,14 +39,14 @@ int main(int argc, char** argv) { - GApplication app(argc, argv); + GUI::Application app(argc, argv); auto audio_client = AClientConnection::construct(); audio_client->handshake(); AudioEngine audio_engine; - auto window = GWindow::construct(); + auto window = GUI::Window::construct(); auto main_widget = MainWidget::construct(audio_engine); window->set_main_widget(main_widget); window->set_title("Piano"); @@ -71,18 +71,18 @@ int main(int argc, char** argv) }); audio_thread.start(); - auto menubar = make(); + auto menubar = make(); - auto app_menu = GMenu::construct("Piano"); - app_menu->add_action(GCommonActions::make_quit_action([](auto&) { - GApplication::the().quit(0); + auto app_menu = GUI::Menu::construct("Piano"); + app_menu->add_action(GUI::CommonActions::make_quit_action([](auto&) { + GUI::Application::the().quit(0); return; })); menubar->add_menu(move(app_menu)); - auto help_menu = GMenu::construct("Help"); - help_menu->add_action(GAction::create("About", [&](const GAction&) { - GAboutDialog::show("Piano", load_png("/res/icons/32x32/app-piano.png"), window); + auto help_menu = GUI::Menu::construct("Help"); + help_menu->add_action(GUI::Action::create("About", [&](const GUI::Action&) { + GUI::AboutDialog::show("Piano", load_png("/res/icons/32x32/app-piano.png"), window); })); menubar->add_menu(move(help_menu)); diff --git a/Applications/QuickShow/QSWidget.cpp b/Applications/QuickShow/QSWidget.cpp index 53f1c170a80..957e487f28d 100644 --- a/Applications/QuickShow/QSWidget.cpp +++ b/Applications/QuickShow/QSWidget.cpp @@ -31,8 +31,8 @@ #include #include -QSWidget::QSWidget(GWidget* parent) - : GFrame(parent) +QSWidget::QSWidget(GUI::Widget* parent) + : GUI::Frame(parent) { set_frame_shape(FrameShape::Container); set_frame_shadow(FrameShadow::Sunken); @@ -61,36 +61,36 @@ void QSWidget::relayout() update(); } -void QSWidget::resize_event(GResizeEvent& event) +void QSWidget::resize_event(GUI::ResizeEvent& event) { relayout(); - GWidget::resize_event(event); + GUI::Widget::resize_event(event); } -void QSWidget::paint_event(GPaintEvent& event) +void QSWidget::paint_event(GUI::PaintEvent& event) { - GPainter painter(*this); + GUI::Painter painter(*this); painter.add_clip_rect(event.rect()); painter.draw_scaled_bitmap(m_bitmap_rect, *m_bitmap, m_bitmap->rect()); } -void QSWidget::mousedown_event(GMouseEvent& event) +void QSWidget::mousedown_event(GUI::MouseEvent& event) { - if (event.button() != GMouseButton::Left) + if (event.button() != GUI::MouseButton::Left) return; m_pan_origin = event.position(); m_pan_bitmap_origin = m_bitmap_rect.location(); } -void QSWidget::mouseup_event(GMouseEvent& event) +void QSWidget::mouseup_event(GUI::MouseEvent& event) { UNUSED_PARAM(event); } -void QSWidget::mousemove_event(GMouseEvent& event) +void QSWidget::mousemove_event(GUI::MouseEvent& event) { - if (!(event.buttons() & GMouseButton::Left)) + if (!(event.buttons() & GUI::MouseButton::Left)) return; auto delta = event.position() - m_pan_origin; @@ -98,7 +98,7 @@ void QSWidget::mousemove_event(GMouseEvent& event) update(); } -void QSWidget::mousewheel_event(GMouseEvent& event) +void QSWidget::mousewheel_event(GUI::MouseEvent& event) { auto old_scale = m_scale; auto old_scale_factor = (float)m_scale / 100.0f; @@ -125,7 +125,7 @@ void QSWidget::set_path(const String& path) m_path = path; } -void QSWidget::drop_event(GDropEvent& event) +void QSWidget::drop_event(GUI::DropEvent& event) { event.accept(); window()->move_to_front(); @@ -135,13 +135,13 @@ void QSWidget::drop_event(GDropEvent& event) if (lines.is_empty()) return; if (lines.size() > 1) { - GMessageBox::show("QuickShow can only open one file at a time!", "One at a time please!", GMessageBox::Type::Error, GMessageBox::InputType::OK, window()); + GUI::MessageBox::show("QuickShow can only open one file at a time!", "One at a time please!", GUI::MessageBox::Type::Error, GUI::MessageBox::InputType::OK, window()); return; } URL url(lines[0]); auto bitmap = GraphicsBitmap::load_from_file(url.path()); if (!bitmap) { - GMessageBox::show(String::format("Failed to open %s", url.to_string().characters()), "Cannot open image", GMessageBox::Type::Error, GMessageBox::InputType::OK, window()); + GUI::MessageBox::show(String::format("Failed to open %s", url.to_string().characters()), "Cannot open image", GUI::MessageBox::Type::Error, GUI::MessageBox::InputType::OK, window()); return; } diff --git a/Applications/QuickShow/QSWidget.h b/Applications/QuickShow/QSWidget.h index 66a512a1d41..21cd4450df5 100644 --- a/Applications/QuickShow/QSWidget.h +++ b/Applications/QuickShow/QSWidget.h @@ -28,10 +28,9 @@ #include -class GLabel; class QSLabel; -class QSWidget final : public GFrame { +class QSWidget final : public GUI::Frame { C_OBJECT(QSWidget) public: virtual ~QSWidget() override; @@ -45,14 +44,14 @@ public: Function on_scale_change; private: - explicit QSWidget(GWidget* parent = nullptr); - virtual void paint_event(GPaintEvent&) override; - virtual void resize_event(GResizeEvent&) override; - virtual void mousedown_event(GMouseEvent&) override; - virtual void mouseup_event(GMouseEvent&) override; - virtual void mousemove_event(GMouseEvent&) override; - virtual void mousewheel_event(GMouseEvent&) override; - virtual void drop_event(GDropEvent&) override; + explicit QSWidget(GUI::Widget* parent = nullptr); + virtual void paint_event(GUI::PaintEvent&) override; + virtual void resize_event(GUI::ResizeEvent&) override; + virtual void mousedown_event(GUI::MouseEvent&) override; + virtual void mouseup_event(GUI::MouseEvent&) override; + virtual void mousemove_event(GUI::MouseEvent&) override; + virtual void mousewheel_event(GUI::MouseEvent&) override; + virtual void drop_event(GUI::DropEvent&) override; void relayout(); diff --git a/Applications/QuickShow/main.cpp b/Applications/QuickShow/main.cpp index 572be401f44..c8f3a515cf3 100644 --- a/Applications/QuickShow/main.cpp +++ b/Applications/QuickShow/main.cpp @@ -42,27 +42,27 @@ int main(int argc, char** argv) return 1; } - GApplication app(argc, argv); + GUI::Application app(argc, argv); if (pledge("stdio shared_buffer accept rpath", nullptr) < 0) { perror("pledge"); return 1; } - auto menubar = make(); + auto menubar = make(); - auto app_menu = GMenu::construct("QuickShow"); - app_menu->add_action(GCommonActions::make_quit_action([](auto&) { - GApplication::the().quit(0); + auto app_menu = GUI::Menu::construct("QuickShow"); + app_menu->add_action(GUI::CommonActions::make_quit_action([](auto&) { + GUI::Application::the().quit(0); return; })); menubar->add_menu(move(app_menu)); - auto file_menu = GMenu::construct("File"); + auto file_menu = GUI::Menu::construct("File"); menubar->add_menu(move(file_menu)); - auto help_menu = GMenu::construct("Help"); - help_menu->add_action(GAction::create("About", [](const GAction&) { + auto help_menu = GUI::Menu::construct("Help"); + help_menu->add_action(GUI::Action::create("About", [](const GUI::Action&) { dbgprintf("FIXME: Implement Help/About\n"); })); menubar->add_menu(move(help_menu)); @@ -86,7 +86,7 @@ int main(int argc, char** argv) return 1; } - auto window = GWindow::construct(); + auto window = GUI::Window::construct(); auto widget = QSWidget::construct(); widget->set_path(path); widget->set_bitmap(*bitmap); diff --git a/Applications/SoundPlayer/SampleWidget.cpp b/Applications/SoundPlayer/SampleWidget.cpp index a306e9e8266..846c841cfe3 100644 --- a/Applications/SoundPlayer/SampleWidget.cpp +++ b/Applications/SoundPlayer/SampleWidget.cpp @@ -29,8 +29,8 @@ #include #include -SampleWidget::SampleWidget(GWidget* parent) - : GFrame(parent) +SampleWidget::SampleWidget(GUI::Widget* parent) + : GUI::Frame(parent) { set_frame_shape(FrameShape::Container); set_frame_shadow(FrameShadow::Sunken); @@ -41,10 +41,10 @@ SampleWidget::~SampleWidget() { } -void SampleWidget::paint_event(GPaintEvent& event) +void SampleWidget::paint_event(GUI::PaintEvent& event) { - GFrame::paint_event(event); - GPainter painter(*this); + GUI::Frame::paint_event(event); + GUI::Painter painter(*this); painter.add_clip_rect(event.rect()); painter.fill_rect(frame_inner_rect(), Color::Black); diff --git a/Applications/SoundPlayer/SampleWidget.h b/Applications/SoundPlayer/SampleWidget.h index 22560330785..385021c855d 100644 --- a/Applications/SoundPlayer/SampleWidget.h +++ b/Applications/SoundPlayer/SampleWidget.h @@ -30,15 +30,15 @@ class ABuffer; -class SampleWidget final : public GFrame { +class SampleWidget final : public GUI::Frame { C_OBJECT(SampleWidget) public: virtual ~SampleWidget() override; void set_buffer(ABuffer*); private: - explicit SampleWidget(GWidget* parent); - virtual void paint_event(GPaintEvent&) override; + explicit SampleWidget(GUI::Widget* parent); + virtual void paint_event(GUI::PaintEvent&) override; RefPtr m_buffer; }; diff --git a/Applications/SoundPlayer/SoundPlayerWidget.cpp b/Applications/SoundPlayer/SoundPlayerWidget.cpp index 6709411bed7..3f5a53b1bea 100644 --- a/Applications/SoundPlayer/SoundPlayerWidget.cpp +++ b/Applications/SoundPlayer/SoundPlayerWidget.cpp @@ -32,37 +32,37 @@ #include #include -SoundPlayerWidget::SoundPlayerWidget(GWindow& window, NonnullRefPtr connection) +SoundPlayerWidget::SoundPlayerWidget(GUI::Window& window, NonnullRefPtr connection) : m_window(window) , m_connection(connection) , m_manager(connection) { set_fill_with_background_color(true); - set_layout(make()); + set_layout(make()); layout()->set_margins({ 2, 2, 2, 2 }); - auto status_widget = GWidget::construct(this); + auto status_widget = GUI::Widget::construct(this); status_widget->set_fill_with_background_color(true); - status_widget->set_layout(make()); + status_widget->set_layout(make()); - m_elapsed = GLabel::construct(status_widget); + m_elapsed = GUI::Label::construct(status_widget); m_elapsed->set_frame_shape(FrameShape::Container); m_elapsed->set_frame_shadow(FrameShadow::Sunken); m_elapsed->set_frame_thickness(2); - m_elapsed->set_size_policy(SizePolicy::Fixed, SizePolicy::Fill); + m_elapsed->set_size_policy(GUI::SizePolicy::Fixed, GUI::SizePolicy::Fill); m_elapsed->set_preferred_size(80, 0); - auto sample_widget_container = GWidget::construct(status_widget.ptr()); - sample_widget_container->set_layout(make()); - sample_widget_container->set_size_policy(SizePolicy::Fill, SizePolicy::Fill); + auto sample_widget_container = GUI::Widget::construct(status_widget.ptr()); + sample_widget_container->set_layout(make()); + sample_widget_container->set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fill); m_sample_widget = SampleWidget::construct(sample_widget_container); - m_remaining = GLabel::construct(status_widget); + m_remaining = GUI::Label::construct(status_widget); m_remaining->set_frame_shape(FrameShape::Container); m_remaining->set_frame_shadow(FrameShadow::Sunken); m_remaining->set_frame_thickness(2); - m_remaining->set_size_policy(SizePolicy::Fixed, SizePolicy::Fill); + m_remaining->set_size_policy(GUI::SizePolicy::Fixed, GUI::SizePolicy::Fill); m_remaining->set_preferred_size(80, 0); m_slider = Slider::construct(Orientation::Horizontal, this); @@ -70,32 +70,32 @@ SoundPlayerWidget::SoundPlayerWidget(GWindow& window, NonnullRefPtrset_enabled(false); m_slider->on_knob_released = [&](int value) { m_manager.seek(denormalize_rate(value)); }; - auto control_widget = GWidget::construct(this); + auto control_widget = GUI::Widget::construct(this); control_widget->set_fill_with_background_color(true); - control_widget->set_layout(make()); - control_widget->set_size_policy(SizePolicy::Fill, SizePolicy::Fixed); + control_widget->set_layout(make()); + control_widget->set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed); control_widget->set_preferred_size(0, 30); control_widget->layout()->set_margins({ 10, 2, 10, 2 }); control_widget->layout()->set_spacing(10); - m_play = GButton::construct(control_widget); + m_play = GUI::Button::construct(control_widget); m_play->set_icon(*m_pause_icon); m_play->set_enabled(false); - m_play->on_click = [this](GButton& button) { + m_play->on_click = [this](GUI::Button& button) { button.set_icon(m_manager.toggle_pause() ? *m_play_icon : *m_pause_icon); }; - m_stop = GButton::construct(control_widget); + m_stop = GUI::Button::construct(control_widget); m_stop->set_enabled(false); m_stop->set_icon(GraphicsBitmap::load_from_file("/res/icons/16x16/stop.png")); - m_stop->on_click = [&](GButton&) { m_manager.stop(); }; + m_stop->on_click = [&](GUI::Button&) { m_manager.stop(); }; - m_status = GLabel::construct(this); + m_status = GUI::Label::construct(this); m_status->set_frame_shape(FrameShape::Box); m_status->set_frame_shadow(FrameShadow::Raised); m_status->set_frame_thickness(4); m_status->set_text_alignment(TextAlignment::CenterLeft); - m_status->set_size_policy(SizePolicy::Fill, SizePolicy::Fixed); + m_status->set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed); m_status->set_preferred_size(0, 18); m_status->set_text("No file open!"); @@ -120,18 +120,18 @@ void SoundPlayerWidget::hide_scope(bool hide) void SoundPlayerWidget::open_file(String path) { if (!path.ends_with(".wav")) { - GMessageBox::show("Selected file is not a \".wav\" file!", "Filetype error", GMessageBox::Type::Error); + GUI::MessageBox::show("Selected file is not a \".wav\" file!", "Filetype error", GUI::MessageBox::Type::Error); return; } OwnPtr loader = make(path); if (loader->has_error()) { - GMessageBox::show( + GUI::MessageBox::show( String::format( "Failed to load WAV file: %s (%s)", path.characters(), loader->error_string()), - "Filetype error", GMessageBox::Type::Error); + "Filetype error", GUI::MessageBox::Type::Error); return; } diff --git a/Applications/SoundPlayer/SoundPlayerWidget.h b/Applications/SoundPlayer/SoundPlayerWidget.h index 5173364b164..b9fd871b72f 100644 --- a/Applications/SoundPlayer/SoundPlayerWidget.h +++ b/Applications/SoundPlayer/SoundPlayerWidget.h @@ -34,7 +34,7 @@ #include #include -class SoundPlayerWidget final : public GWidget { +class SoundPlayerWidget final : public GUI::Widget { C_OBJECT(SoundPlayerWidget) public: virtual ~SoundPlayerWidget() override; @@ -43,14 +43,14 @@ public: PlaybackManager& manager() { return m_manager; } private: - explicit SoundPlayerWidget(GWindow&, NonnullRefPtr); + explicit SoundPlayerWidget(GUI::Window&, NonnullRefPtr); void update_position(const int position); void update_ui(); int normalize_rate(int) const; int denormalize_rate(int) const; - class Slider final : public GSlider { + class Slider final : public GUI::Slider { C_OBJECT(Slider) public: virtual ~Slider() override; @@ -58,35 +58,35 @@ private: void set_value(int value) { if (!knob_dragging()) - GSlider::set_value(value); + GUI::Slider::set_value(value); } protected: - Slider(Orientation orientation, GWidget* parent) - : GSlider(orientation, parent) + Slider(Orientation orientation, GUI::Widget* parent) + : GUI::Slider(orientation, parent) { } - virtual void mouseup_event(GMouseEvent& event) override + virtual void mouseup_event(GUI::MouseEvent& event) override { if (on_knob_released && is_enabled()) on_knob_released(value()); - GSlider::mouseup_event(event); + GUI::Slider::mouseup_event(event); } }; - GWindow& m_window; + GUI::Window& m_window; NonnullRefPtr m_connection; PlaybackManager m_manager; float m_sample_ratio; - RefPtr m_status; - RefPtr m_elapsed; - RefPtr m_remaining; + RefPtr m_status; + RefPtr m_elapsed; + RefPtr m_remaining; RefPtr m_slider; RefPtr m_sample_widget; RefPtr m_play_icon { GraphicsBitmap::load_from_file("/res/icons/16x16/play.png") }; RefPtr m_pause_icon { GraphicsBitmap::load_from_file("/res/icons/16x16/pause.png") }; - RefPtr m_play; - RefPtr m_stop; + RefPtr m_play; + RefPtr m_stop; }; diff --git a/Applications/SoundPlayer/main.cpp b/Applications/SoundPlayer/main.cpp index 646dbeed035..1107bd2971d 100644 --- a/Applications/SoundPlayer/main.cpp +++ b/Applications/SoundPlayer/main.cpp @@ -43,7 +43,7 @@ int main(int argc, char** argv) return 1; } - GApplication app(argc, argv); + GUI::Application app(argc, argv); if (pledge("stdio shared_buffer accept rpath unix", nullptr) < 0) { perror("pledge"); @@ -58,14 +58,14 @@ int main(int argc, char** argv) return 1; } - auto window = GWindow::construct(); + auto window = GUI::Window::construct(); window->set_title("SoundPlayer"); window->set_resizable(false); window->set_rect(300, 300, 350, 140); window->set_icon(GraphicsBitmap::load_from_file("/res/icons/16x16/app-sound-player.png")); - auto menubar = make(); - auto app_menu = GMenu::construct("SoundPlayer"); + auto menubar = make(); + auto app_menu = GUI::Menu::construct("SoundPlayer"); auto player = SoundPlayerWidget::construct(window, audio_client); if (argc > 1) { @@ -74,27 +74,27 @@ int main(int argc, char** argv) player->manager().play(); } - auto hide_scope = GAction::create("Hide scope", { Mod_Ctrl, Key_H }, [&](GAction& action) { + auto hide_scope = GUI::Action::create("Hide scope", { Mod_Ctrl, Key_H }, [&](GUI::Action& action) { action.set_checked(!action.is_checked()); player->hide_scope(action.is_checked()); }); hide_scope->set_checkable(true); - app_menu->add_action(GCommonActions::make_open_action([&](auto&) { - Optional path = GFilePicker::get_open_filepath("Open wav file..."); + app_menu->add_action(GUI::CommonActions::make_open_action([&](auto&) { + Optional path = GUI::FilePicker::get_open_filepath("Open wav file..."); if (path.has_value()) { player->open_file(path.value()); } })); app_menu->add_action(move(hide_scope)); app_menu->add_separator(); - app_menu->add_action(GCommonActions::make_quit_action([&](auto&) { + app_menu->add_action(GUI::CommonActions::make_quit_action([&](auto&) { app.quit(); })); - auto help_menu = GMenu::construct("Help"); - help_menu->add_action(GAction::create("About", [](auto&) { - GAboutDialog::show("SoundPlayer", GraphicsBitmap::load_from_file("/res/icons/32x32/app-sound-player.png")); + auto help_menu = GUI::Menu::construct("Help"); + help_menu->add_action(GUI::Action::create("About", [](auto&) { + GUI::AboutDialog::show("SoundPlayer", GraphicsBitmap::load_from_file("/res/icons/32x32/app-sound-player.png")); })); menubar->add_menu(move(app_menu)); diff --git a/Applications/SystemDialog/main.cpp b/Applications/SystemDialog/main.cpp index 7ada522178b..b5eb8e33912 100644 --- a/Applications/SystemDialog/main.cpp +++ b/Applications/SystemDialog/main.cpp @@ -52,12 +52,12 @@ int main(int argc, char** argv) int run_shutdown_dialog(int argc, char** argv) { - GApplication app(argc, argv); + GUI::Application app(argc, argv); { - auto result = GMessageBox::show("Shut down Serenity?", "Confirm Shutdown", GMessageBox::Type::Warning, GMessageBox::InputType::OKCancel); + auto result = GUI::MessageBox::show("Shut down Serenity?", "Confirm Shutdown", GUI::MessageBox::Type::Warning, GUI::MessageBox::InputType::OKCancel); - if (result == GMessageBox::ExecOK) { + if (result == GUI::MessageBox::ExecOK) { dbg() << "OK"; int rc = execl("/bin/shutdown", "/bin/shutdown", "-n", nullptr); if (rc < 0) { diff --git a/Applications/SystemMonitor/DevicesModel.cpp b/Applications/SystemMonitor/DevicesModel.cpp index a70e10eacf2..ed7946ad930 100644 --- a/Applications/SystemMonitor/DevicesModel.cpp +++ b/Applications/SystemMonitor/DevicesModel.cpp @@ -45,12 +45,12 @@ DevicesModel::~DevicesModel() { } -int DevicesModel::row_count(const GModelIndex&) const +int DevicesModel::row_count(const GUI::ModelIndex&) const { return m_devices.size(); } -int DevicesModel::column_count(const GModelIndex&) const +int DevicesModel::column_count(const GUI::ModelIndex&) const { return Column::__Count; } @@ -73,7 +73,7 @@ String DevicesModel::column_name(int column) const } } -GModel::ColumnMetadata DevicesModel::column_metadata(int column) const +GUI::Model::ColumnMetadata DevicesModel::column_metadata(int column) const { switch (column) { case Column::Device: @@ -91,7 +91,7 @@ GModel::ColumnMetadata DevicesModel::column_metadata(int column) const } } -GVariant DevicesModel::data(const GModelIndex& index, Role) const +GUI::Variant DevicesModel::data(const GUI::ModelIndex& index, Role) const { ASSERT(is_valid(index)); diff --git a/Applications/SystemMonitor/DevicesModel.h b/Applications/SystemMonitor/DevicesModel.h index dce58af3ae6..4d25515f838 100644 --- a/Applications/SystemMonitor/DevicesModel.h +++ b/Applications/SystemMonitor/DevicesModel.h @@ -30,7 +30,7 @@ #include #include -class DevicesModel final : public GModel { +class DevicesModel final : public GUI::Model { public: enum Column { Device = 0, @@ -44,11 +44,11 @@ public: virtual ~DevicesModel() override; static NonnullRefPtr create(); - virtual int row_count(const GModelIndex&) const override; - virtual int column_count(const GModelIndex&) const override; + virtual int row_count(const GUI::ModelIndex&) const override; + virtual int column_count(const GUI::ModelIndex&) const override; virtual String column_name(int column) const override; virtual ColumnMetadata column_metadata(int column) const override; - virtual GVariant data(const GModelIndex&, Role = Role::Display) const override; + virtual GUI::Variant data(const GUI::ModelIndex&, Role = Role::Display) const override; virtual void update() override; private: diff --git a/Applications/SystemMonitor/GraphWidget.cpp b/Applications/SystemMonitor/GraphWidget.cpp index bbab193b64d..863fede531a 100644 --- a/Applications/SystemMonitor/GraphWidget.cpp +++ b/Applications/SystemMonitor/GraphWidget.cpp @@ -27,8 +27,8 @@ #include "GraphWidget.h" #include -GraphWidget::GraphWidget(GWidget* parent) - : GFrame(parent) +GraphWidget::GraphWidget(GUI::Widget* parent) + : GUI::Frame(parent) { set_frame_thickness(2); set_frame_shape(FrameShape::Container); @@ -45,10 +45,10 @@ void GraphWidget::add_value(int value) update(); } -void GraphWidget::paint_event(GPaintEvent& event) +void GraphWidget::paint_event(GUI::PaintEvent& event) { - GFrame::paint_event(event); - GPainter painter(*this); + GUI::Frame::paint_event(event); + GUI::Painter painter(*this); painter.add_clip_rect(event.rect()); painter.add_clip_rect(frame_inner_rect()); painter.fill_rect(event.rect(), Color::Black); diff --git a/Applications/SystemMonitor/GraphWidget.h b/Applications/SystemMonitor/GraphWidget.h index 9fdf9f083b8..6f685e06fdf 100644 --- a/Applications/SystemMonitor/GraphWidget.h +++ b/Applications/SystemMonitor/GraphWidget.h @@ -27,7 +27,7 @@ #include #include -class GraphWidget final : public GFrame { +class GraphWidget final : public GUI::Frame { C_OBJECT(GraphWidget) public: virtual ~GraphWidget() override; @@ -41,9 +41,9 @@ public: Function text_formatter; private: - explicit GraphWidget(GWidget* parent); + explicit GraphWidget(GUI::Widget* parent); - virtual void paint_event(GPaintEvent&) override; + virtual void paint_event(GUI::PaintEvent&) override; int m_max { 100 }; CircularQueue m_values; diff --git a/Applications/SystemMonitor/MemoryStatsWidget.cpp b/Applications/SystemMonitor/MemoryStatsWidget.cpp index 21bee6a26af..1bd39f0c8b3 100644 --- a/Applications/SystemMonitor/MemoryStatsWidget.cpp +++ b/Applications/SystemMonitor/MemoryStatsWidget.cpp @@ -42,29 +42,29 @@ MemoryStatsWidget* MemoryStatsWidget::the() return s_the; } -MemoryStatsWidget::MemoryStatsWidget(GraphWidget& graph, GWidget* parent) - : GWidget(parent) +MemoryStatsWidget::MemoryStatsWidget(GraphWidget& graph, GUI::Widget* parent) + : GUI::Widget(parent) , m_graph(graph) { ASSERT(!s_the); s_the = this; - set_size_policy(SizePolicy::Fill, SizePolicy::Fixed); + set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed); set_preferred_size(0, 72); - set_layout(make()); + set_layout(make()); layout()->set_margins({ 0, 8, 0, 0 }); layout()->set_spacing(3); - auto build_widgets_for_label = [this](const String& description) -> RefPtr { - auto container = GWidget::construct(this); - container->set_layout(make()); - container->set_size_policy(SizePolicy::Fixed, SizePolicy::Fixed); + auto build_widgets_for_label = [this](const String& description) -> RefPtr { + auto container = GUI::Widget::construct(this); + container->set_layout(make()); + container->set_size_policy(GUI::SizePolicy::Fixed, GUI::SizePolicy::Fixed); container->set_preferred_size(275, 12); - auto description_label = GLabel::construct(description, container); + auto description_label = GUI::Label::construct(description, container); description_label->set_font(Font::default_bold_font()); description_label->set_text_alignment(TextAlignment::CenterLeft); - auto label = GLabel::construct(container); + auto label = GUI::Label::construct(container); label->set_text_alignment(TextAlignment::CenterRight); return label; }; diff --git a/Applications/SystemMonitor/MemoryStatsWidget.h b/Applications/SystemMonitor/MemoryStatsWidget.h index beb496ca8ae..2d695065862 100644 --- a/Applications/SystemMonitor/MemoryStatsWidget.h +++ b/Applications/SystemMonitor/MemoryStatsWidget.h @@ -28,10 +28,13 @@ #include -class GLabel; +namespace GUI { +class Label; +} + class GraphWidget; -class MemoryStatsWidget final : public GWidget { +class MemoryStatsWidget final : public GUI::Widget { C_OBJECT(MemoryStatsWidget) public: static MemoryStatsWidget* the(); @@ -41,11 +44,11 @@ public: void refresh(); private: - MemoryStatsWidget(GraphWidget& graph, GWidget* parent); + MemoryStatsWidget(GraphWidget& graph, GUI::Widget* parent); GraphWidget& m_graph; - RefPtr m_user_physical_pages_label; - RefPtr m_supervisor_physical_pages_label; - RefPtr m_kmalloc_label; - RefPtr m_kmalloc_count_label; + RefPtr m_user_physical_pages_label; + RefPtr m_supervisor_physical_pages_label; + RefPtr m_kmalloc_label; + RefPtr m_kmalloc_count_label; }; diff --git a/Applications/SystemMonitor/NetworkStatisticsWidget.cpp b/Applications/SystemMonitor/NetworkStatisticsWidget.cpp index 0400cb6658e..f14f0713369 100644 --- a/Applications/SystemMonitor/NetworkStatisticsWidget.cpp +++ b/Applications/SystemMonitor/NetworkStatisticsWidget.cpp @@ -30,24 +30,24 @@ #include #include -NetworkStatisticsWidget::NetworkStatisticsWidget(GWidget* parent) - : GLazyWidget(parent) +NetworkStatisticsWidget::NetworkStatisticsWidget(GUI::Widget* parent) + : GUI::LazyWidget(parent) { on_first_show = [this](auto&) { - set_layout(make()); + set_layout(make()); layout()->set_margins({ 4, 4, 4, 4 }); set_fill_with_background_color(true); - auto adapters_group_box = GGroupBox::construct("Adapters", this); - adapters_group_box->set_layout(make()); + auto adapters_group_box = GUI::GroupBox::construct("Adapters", this); + adapters_group_box->set_layout(make()); adapters_group_box->layout()->set_margins({ 6, 16, 6, 6 }); - adapters_group_box->set_size_policy(SizePolicy::Fill, SizePolicy::Fixed); + adapters_group_box->set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed); adapters_group_box->set_preferred_size(0, 120); - m_adapter_table_view = GTableView::construct(adapters_group_box); + m_adapter_table_view = GUI::TableView::construct(adapters_group_box); m_adapter_table_view->set_size_columns_to_fit_content(true); - Vector net_adapters_fields; + Vector net_adapters_fields; net_adapters_fields.empend("name", "Name", TextAlignment::CenterLeft); net_adapters_fields.empend("class_name", "Class", TextAlignment::CenterLeft); net_adapters_fields.empend("mac_address", "MAC", TextAlignment::CenterLeft); @@ -56,18 +56,18 @@ NetworkStatisticsWidget::NetworkStatisticsWidget(GWidget* parent) net_adapters_fields.empend("packets_out", "Pkt Out", TextAlignment::CenterRight); net_adapters_fields.empend("bytes_in", "Bytes In", TextAlignment::CenterRight); net_adapters_fields.empend("bytes_out", "Bytes Out", TextAlignment::CenterRight); - m_adapter_table_view->set_model(GJsonArrayModel::create("/proc/net/adapters", move(net_adapters_fields))); + m_adapter_table_view->set_model(GUI::JsonArrayModel::create("/proc/net/adapters", move(net_adapters_fields))); - auto sockets_group_box = GGroupBox::construct("Sockets", this); - sockets_group_box->set_layout(make()); + auto sockets_group_box = GUI::GroupBox::construct("Sockets", this); + sockets_group_box->set_layout(make()); sockets_group_box->layout()->set_margins({ 6, 16, 6, 6 }); - sockets_group_box->set_size_policy(SizePolicy::Fill, SizePolicy::Fill); + sockets_group_box->set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fill); sockets_group_box->set_preferred_size(0, 0); - m_socket_table_view = GTableView::construct(sockets_group_box); + m_socket_table_view = GUI::TableView::construct(sockets_group_box); m_socket_table_view->set_size_columns_to_fit_content(true); - Vector net_tcp_fields; + Vector net_tcp_fields; net_tcp_fields.empend("peer_address", "Peer", TextAlignment::CenterLeft); net_tcp_fields.empend("peer_port", "Port", TextAlignment::CenterRight); net_tcp_fields.empend("local_address", "Local", TextAlignment::CenterLeft); @@ -79,7 +79,7 @@ NetworkStatisticsWidget::NetworkStatisticsWidget(GWidget* parent) net_tcp_fields.empend("packets_out", "Pkt Out", TextAlignment::CenterRight); net_tcp_fields.empend("bytes_in", "Bytes In", TextAlignment::CenterRight); net_tcp_fields.empend("bytes_out", "Bytes Out", TextAlignment::CenterRight); - m_socket_table_view->set_model(GJsonArrayModel::create("/proc/net/tcp", move(net_tcp_fields))); + m_socket_table_view->set_model(GUI::JsonArrayModel::create("/proc/net/tcp", move(net_tcp_fields))); m_update_timer = Core::Timer::construct( 1000, [this] { diff --git a/Applications/SystemMonitor/NetworkStatisticsWidget.h b/Applications/SystemMonitor/NetworkStatisticsWidget.h index a354adfd5d3..782836328df 100644 --- a/Applications/SystemMonitor/NetworkStatisticsWidget.h +++ b/Applications/SystemMonitor/NetworkStatisticsWidget.h @@ -29,18 +29,20 @@ #include #include -class GTableView; +namespace GUI { +class TableView; +} -class NetworkStatisticsWidget final : public GLazyWidget { +class NetworkStatisticsWidget final : public GUI::LazyWidget { C_OBJECT(NetworkStatisticsWidget) public: virtual ~NetworkStatisticsWidget() override; private: - explicit NetworkStatisticsWidget(GWidget* parent = nullptr); + explicit NetworkStatisticsWidget(GUI::Widget* parent = nullptr); void update_models(); - RefPtr m_adapter_table_view; - RefPtr m_socket_table_view; + RefPtr m_adapter_table_view; + RefPtr m_socket_table_view; RefPtr m_update_timer; }; diff --git a/Applications/SystemMonitor/ProcessFileDescriptorMapWidget.cpp b/Applications/SystemMonitor/ProcessFileDescriptorMapWidget.cpp index 9f4e68913da..8529a288814 100644 --- a/Applications/SystemMonitor/ProcessFileDescriptorMapWidget.cpp +++ b/Applications/SystemMonitor/ProcessFileDescriptorMapWidget.cpp @@ -29,15 +29,15 @@ #include #include -ProcessFileDescriptorMapWidget::ProcessFileDescriptorMapWidget(GWidget* parent) - : GWidget(parent) +ProcessFileDescriptorMapWidget::ProcessFileDescriptorMapWidget(GUI::Widget* parent) + : GUI::Widget(parent) { - set_layout(make()); + set_layout(make()); layout()->set_margins({ 4, 4, 4, 4 }); - m_table_view = GTableView::construct(this); + m_table_view = GUI::TableView::construct(this); m_table_view->set_size_columns_to_fit_content(true); - Vector pid_fds_fields; + Vector pid_fds_fields; pid_fds_fields.empend("fd", "FD", TextAlignment::CenterRight); pid_fds_fields.empend("class", "Class", TextAlignment::CenterLeft); pid_fds_fields.empend("offset", "Offset", TextAlignment::CenterRight); @@ -58,7 +58,7 @@ ProcessFileDescriptorMapWidget::ProcessFileDescriptorMapWidget(GWidget* parent) return object.get("can_write").to_bool() ? "Yes" : "No"; }); - m_table_view->set_model(GJsonArrayModel::create({}, move(pid_fds_fields))); + m_table_view->set_model(GUI::JsonArrayModel::create({}, move(pid_fds_fields))); } ProcessFileDescriptorMapWidget::~ProcessFileDescriptorMapWidget() @@ -70,5 +70,5 @@ void ProcessFileDescriptorMapWidget::set_pid(pid_t pid) if (m_pid == pid) return; m_pid = pid; - static_cast(m_table_view->model())->set_json_path(String::format("/proc/%d/fds", m_pid)); + static_cast(m_table_view->model())->set_json_path(String::format("/proc/%d/fds", m_pid)); } diff --git a/Applications/SystemMonitor/ProcessFileDescriptorMapWidget.h b/Applications/SystemMonitor/ProcessFileDescriptorMapWidget.h index c02ac60e31f..604e47336a1 100644 --- a/Applications/SystemMonitor/ProcessFileDescriptorMapWidget.h +++ b/Applications/SystemMonitor/ProcessFileDescriptorMapWidget.h @@ -28,9 +28,11 @@ #include -class GTableView; +namespace GUI { +class TableView; +} -class ProcessFileDescriptorMapWidget final : public GWidget { +class ProcessFileDescriptorMapWidget final : public GUI::Widget { C_OBJECT(ProcessFileDescriptorMapWidget); public: virtual ~ProcessFileDescriptorMapWidget() override; @@ -38,8 +40,8 @@ public: void set_pid(pid_t); private: - explicit ProcessFileDescriptorMapWidget(GWidget* parent); + explicit ProcessFileDescriptorMapWidget(GUI::Widget* parent); - RefPtr m_table_view; + RefPtr m_table_view; pid_t m_pid { -1 }; }; diff --git a/Applications/SystemMonitor/ProcessMemoryMapWidget.cpp b/Applications/SystemMonitor/ProcessMemoryMapWidget.cpp index 11b29d04959..cc41110f785 100644 --- a/Applications/SystemMonitor/ProcessMemoryMapWidget.cpp +++ b/Applications/SystemMonitor/ProcessMemoryMapWidget.cpp @@ -31,14 +31,14 @@ #include #include -ProcessMemoryMapWidget::ProcessMemoryMapWidget(GWidget* parent) - : GWidget(parent) +ProcessMemoryMapWidget::ProcessMemoryMapWidget(GUI::Widget* parent) + : GUI::Widget(parent) { - set_layout(make()); + set_layout(make()); layout()->set_margins({ 4, 4, 4, 4 }); - m_table_view = GTableView::construct(this); + m_table_view = GUI::TableView::construct(this); m_table_view->set_size_columns_to_fit_content(true); - Vector pid_vm_fields; + Vector pid_vm_fields; pid_vm_fields.empend("Address", TextAlignment::CenterLeft, [](auto& object) { return String::format("%#x", object.get("address").to_u32()); }); @@ -70,9 +70,9 @@ ProcessMemoryMapWidget::ProcessMemoryMapWidget(GWidget* parent) }); pid_vm_fields.empend("cow_pages", "# CoW", TextAlignment::CenterRight); pid_vm_fields.empend("name", "Name", TextAlignment::CenterLeft); - m_json_model = GJsonArrayModel::create({}, move(pid_vm_fields)); - m_table_view->set_model(GSortingProxyModel::create(*m_json_model)); - m_table_view->model()->set_key_column_and_sort_order(0, GSortOrder::Ascending); + m_json_model = GUI::JsonArrayModel::create({}, move(pid_vm_fields)); + m_table_view->set_model(GUI::SortingProxyModel::create(*m_json_model)); + m_table_view->model()->set_key_column_and_sort_order(0, GUI::SortOrder::Ascending); m_timer = Core::Timer::construct(1000, [this] { refresh(); }, this); } diff --git a/Applications/SystemMonitor/ProcessMemoryMapWidget.h b/Applications/SystemMonitor/ProcessMemoryMapWidget.h index 58a82deb4d3..265eaccb8a1 100644 --- a/Applications/SystemMonitor/ProcessMemoryMapWidget.h +++ b/Applications/SystemMonitor/ProcessMemoryMapWidget.h @@ -31,12 +31,14 @@ namespace Core { class Timer; } +namespace GUI { +class JsonArrayModel; +class TableView; +} -class GJsonArrayModel; -class GTableView; - -class ProcessMemoryMapWidget final : public GWidget { +class ProcessMemoryMapWidget final : public GUI::Widget { C_OBJECT(ProcessMemoryMapWidget); + public: virtual ~ProcessMemoryMapWidget() override; @@ -44,9 +46,9 @@ public: void refresh(); private: - explicit ProcessMemoryMapWidget(GWidget* parent); - RefPtr m_table_view; - RefPtr m_json_model; + explicit ProcessMemoryMapWidget(GUI::Widget* parent); + RefPtr m_table_view; + RefPtr m_json_model; pid_t m_pid { -1 }; RefPtr m_timer; }; diff --git a/Applications/SystemMonitor/ProcessModel.cpp b/Applications/SystemMonitor/ProcessModel.cpp index 1693e7b71a3..7fb5a7f8d3d 100644 --- a/Applications/SystemMonitor/ProcessModel.cpp +++ b/Applications/SystemMonitor/ProcessModel.cpp @@ -56,12 +56,12 @@ ProcessModel::~ProcessModel() { } -int ProcessModel::row_count(const GModelIndex&) const +int ProcessModel::row_count(const GUI::ModelIndex&) const { return m_pids.size(); } -int ProcessModel::column_count(const GModelIndex&) const +int ProcessModel::column_count(const GUI::ModelIndex&) const { return Column::__Count; } @@ -128,7 +128,7 @@ String ProcessModel::column_name(int column) const } } -GModel::ColumnMetadata ProcessModel::column_metadata(int column) const +GUI::Model::ColumnMetadata ProcessModel::column_metadata(int column) const { switch (column) { case Column::Icon: @@ -195,7 +195,7 @@ static String pretty_byte_size(size_t size) return String::format("%uK", size / 1024); } -GVariant ProcessModel::data(const GModelIndex& index, Role role) const +GUI::Variant ProcessModel::data(const GUI::ModelIndex& index, Role role) const { ASSERT(is_valid(index)); diff --git a/Applications/SystemMonitor/ProcessModel.h b/Applications/SystemMonitor/ProcessModel.h index 5d25594264f..232670845d8 100644 --- a/Applications/SystemMonitor/ProcessModel.h +++ b/Applications/SystemMonitor/ProcessModel.h @@ -43,7 +43,7 @@ struct PidAndTid { int tid; }; -class ProcessModel final : public GModel { +class ProcessModel final : public GUI::Model { public: enum Column { Icon = 0, @@ -81,11 +81,11 @@ public: static NonnullRefPtr create() { return adopt(*new ProcessModel); } virtual ~ProcessModel() override; - virtual int row_count(const GModelIndex&) const override; - virtual int column_count(const GModelIndex&) const override; + virtual int row_count(const GUI::ModelIndex&) const override; + virtual int column_count(const GUI::ModelIndex&) const override; virtual String column_name(int column) const override; virtual ColumnMetadata column_metadata(int column) const override; - virtual GVariant data(const GModelIndex&, Role = Role::Display) const override; + virtual GUI::Variant data(const GUI::ModelIndex&, Role = Role::Display) const override; virtual void update() override; Function on_new_cpu_data_point; diff --git a/Applications/SystemMonitor/ProcessStacksWidget.cpp b/Applications/SystemMonitor/ProcessStacksWidget.cpp index d4b93780fa7..4ec175c0471 100644 --- a/Applications/SystemMonitor/ProcessStacksWidget.cpp +++ b/Applications/SystemMonitor/ProcessStacksWidget.cpp @@ -29,12 +29,12 @@ #include #include -ProcessStacksWidget::ProcessStacksWidget(GWidget* parent) - : GWidget(parent) +ProcessStacksWidget::ProcessStacksWidget(GUI::Widget* parent) + : GUI::Widget(parent) { - set_layout(make()); + set_layout(make()); layout()->set_margins({ 4, 4, 4, 4 }); - m_stacks_editor = GTextEditor::construct(GTextEditor::Type::MultiLine, this); + m_stacks_editor = GUI::TextEditor::construct(GUI::TextEditor::Type::MultiLine, this); m_stacks_editor->set_readonly(true); m_timer = Core::Timer::construct(1000, [this] { refresh(); }, this); diff --git a/Applications/SystemMonitor/ProcessStacksWidget.h b/Applications/SystemMonitor/ProcessStacksWidget.h index 42b27838e9d..1c17cc77dd2 100644 --- a/Applications/SystemMonitor/ProcessStacksWidget.h +++ b/Applications/SystemMonitor/ProcessStacksWidget.h @@ -33,10 +33,10 @@ namespace Core { class Timer; } -class ProcessStacksWidget final : public GWidget { +class ProcessStacksWidget final : public GUI::Widget { C_OBJECT(ProcessStacksWidget) public: - explicit ProcessStacksWidget(GWidget* parent); + explicit ProcessStacksWidget(GUI::Widget* parent); virtual ~ProcessStacksWidget() override; void set_pid(pid_t); @@ -44,6 +44,6 @@ public: private: pid_t m_pid { -1 }; - RefPtr m_stacks_editor; + RefPtr m_stacks_editor; RefPtr m_timer; }; diff --git a/Applications/SystemMonitor/ProcessTableView.cpp b/Applications/SystemMonitor/ProcessTableView.cpp index bec942b6ae0..d48a68c0662 100644 --- a/Applications/SystemMonitor/ProcessTableView.cpp +++ b/Applications/SystemMonitor/ProcessTableView.cpp @@ -29,12 +29,12 @@ #include #include -ProcessTableView::ProcessTableView(GWidget* parent) - : GTableView(parent) +ProcessTableView::ProcessTableView(GUI::Widget* parent) + : TableView(parent) { set_size_columns_to_fit_content(true); - set_model(GSortingProxyModel::create(ProcessModel::create())); - model()->set_key_column_and_sort_order(ProcessModel::Column::CPU, GSortOrder::Descending); + set_model(GUI::SortingProxyModel::create(ProcessModel::create())); + model()->set_key_column_and_sort_order(ProcessModel::Column::CPU, GUI::SortOrder::Descending); refresh(); on_selection = [this](auto&) { @@ -56,5 +56,5 @@ pid_t ProcessTableView::selected_pid() const { if (selection().is_empty()) return -1; - return model()->data(model()->index(selection().first().row(), ProcessModel::Column::PID), GModel::Role::Sort).as_i32(); + return model()->data(model()->index(selection().first().row(), ProcessModel::Column::PID), GUI::Model::Role::Sort).as_i32(); } diff --git a/Applications/SystemMonitor/ProcessTableView.h b/Applications/SystemMonitor/ProcessTableView.h index 9020ec5349c..3cc00d3b625 100644 --- a/Applications/SystemMonitor/ProcessTableView.h +++ b/Applications/SystemMonitor/ProcessTableView.h @@ -33,7 +33,7 @@ class GraphWidget; class ProcessModel; -class ProcessTableView final : public GTableView { +class ProcessTableView final : public GUI::TableView { C_OBJECT(ProcessTableView) public: virtual ~ProcessTableView() override; @@ -45,5 +45,5 @@ public: Function on_process_selected; private: - explicit ProcessTableView(GWidget* parent = nullptr); + explicit ProcessTableView(GUI::Widget* parent = nullptr); }; diff --git a/Applications/SystemMonitor/ProcessUnveiledPathsWidget.cpp b/Applications/SystemMonitor/ProcessUnveiledPathsWidget.cpp index bf6acabfc2a..5c713675bc6 100644 --- a/Applications/SystemMonitor/ProcessUnveiledPathsWidget.cpp +++ b/Applications/SystemMonitor/ProcessUnveiledPathsWidget.cpp @@ -29,18 +29,18 @@ #include #include -ProcessUnveiledPathsWidget::ProcessUnveiledPathsWidget(GWidget* parent) - : GWidget(parent) +ProcessUnveiledPathsWidget::ProcessUnveiledPathsWidget(GUI::Widget* parent) + : GUI::Widget(parent) { - set_layout(make()); + set_layout(make()); layout()->set_margins({ 4, 4, 4, 4 }); - m_table_view = GTableView::construct(this); + m_table_view = GUI::TableView::construct(this); m_table_view->set_size_columns_to_fit_content(true); - Vector pid_unveil_fields; + Vector pid_unveil_fields; pid_unveil_fields.empend("path", "Path", TextAlignment::CenterLeft); pid_unveil_fields.empend("permissions", "Permissions", TextAlignment::CenterLeft); - m_table_view->set_model(GJsonArrayModel::create({}, move(pid_unveil_fields))); + m_table_view->set_model(GUI::JsonArrayModel::create({}, move(pid_unveil_fields))); } ProcessUnveiledPathsWidget::~ProcessUnveiledPathsWidget() @@ -52,5 +52,5 @@ void ProcessUnveiledPathsWidget::set_pid(pid_t pid) if (m_pid == pid) return; m_pid = pid; - static_cast(m_table_view->model())->set_json_path(String::format("/proc/%d/unveil", m_pid)); + static_cast(m_table_view->model())->set_json_path(String::format("/proc/%d/unveil", m_pid)); } diff --git a/Applications/SystemMonitor/ProcessUnveiledPathsWidget.h b/Applications/SystemMonitor/ProcessUnveiledPathsWidget.h index 84abe4f5086..288c828ba6a 100644 --- a/Applications/SystemMonitor/ProcessUnveiledPathsWidget.h +++ b/Applications/SystemMonitor/ProcessUnveiledPathsWidget.h @@ -28,9 +28,11 @@ #include -class GTableView; +namespace GUI { +class TableView; +} -class ProcessUnveiledPathsWidget final : public GWidget { +class ProcessUnveiledPathsWidget final : public GUI::Widget { C_OBJECT(ProcessUnveiledPathsWidget); public: virtual ~ProcessUnveiledPathsWidget() override; @@ -38,8 +40,8 @@ public: void set_pid(pid_t); private: - explicit ProcessUnveiledPathsWidget(GWidget* parent); + explicit ProcessUnveiledPathsWidget(GUI::Widget* parent); - RefPtr m_table_view; + RefPtr m_table_view; pid_t m_pid { -1 }; }; diff --git a/Applications/SystemMonitor/main.cpp b/Applications/SystemMonitor/main.cpp index 501ea8a9fb4..26ef36f34aa 100644 --- a/Applications/SystemMonitor/main.cpp +++ b/Applications/SystemMonitor/main.cpp @@ -69,10 +69,10 @@ static String human_readable_size(u32 size) return String::format("%u GB", size / GB); } -static RefPtr build_file_systems_tab(); -static RefPtr build_pci_devices_tab(); -static RefPtr build_devices_tab(); -static NonnullRefPtr build_graphs_tab(); +static RefPtr build_file_systems_tab(); +static RefPtr build_pci_devices_tab(); +static RefPtr build_devices_tab(); +static NonnullRefPtr build_graphs_tab(); int main(int argc, char** argv) { @@ -81,7 +81,7 @@ int main(int argc, char** argv) return 1; } - GApplication app(argc, argv); + GUI::Application app(argc, argv); if (pledge("stdio proc shared_buffer accept rpath", nullptr) < 0) { perror("pledge"); @@ -110,22 +110,22 @@ int main(int argc, char** argv) unveil(nullptr, nullptr); - auto window = GWindow::construct(); + auto window = GUI::Window::construct(); window->set_title("System Monitor"); window->set_rect(20, 200, 680, 400); - auto keeper = GWidget::construct(); + auto keeper = GUI::Widget::construct(); window->set_main_widget(keeper); - keeper->set_layout(make()); + keeper->set_layout(make()); keeper->set_fill_with_background_color(true); keeper->layout()->set_margins({ 4, 4, 4, 4 }); - auto tabwidget = GTabWidget::construct(keeper); + auto tabwidget = GUI::TabWidget::construct(keeper); - auto process_container_splitter = GSplitter::construct(Orientation::Vertical, nullptr); + auto process_container_splitter = GUI::Splitter::construct(Orientation::Vertical, nullptr); tabwidget->add_widget("Processes", process_container_splitter); - auto process_table_container = GWidget::construct(process_container_splitter.ptr()); + auto process_table_container = GUI::Widget::construct(process_container_splitter.ptr()); tabwidget->add_widget("Graphs", build_graphs_tab()); @@ -138,11 +138,11 @@ int main(int argc, char** argv) auto network_stats_widget = NetworkStatisticsWidget::construct(nullptr); tabwidget->add_widget("Network", network_stats_widget); - process_table_container->set_layout(make()); + process_table_container->set_layout(make()); process_table_container->layout()->set_margins({ 4, 0, 4, 4 }); process_table_container->layout()->set_spacing(0); - auto toolbar = GToolBar::construct(process_table_container); + auto toolbar = GUI::ToolBar::construct(process_table_container); toolbar->set_has_frame(false); auto process_table_view = ProcessTableView::construct(process_table_container); @@ -152,19 +152,19 @@ int main(int argc, char** argv) memory_stats_widget->refresh(); }, window); - auto kill_action = GAction::create("Kill process", { Mod_Ctrl, Key_K }, GraphicsBitmap::load_from_file("/res/icons/kill16.png"), [process_table_view](const GAction&) { + auto kill_action = GUI::Action::create("Kill process", { Mod_Ctrl, Key_K }, GraphicsBitmap::load_from_file("/res/icons/kill16.png"), [process_table_view](const GUI::Action&) { pid_t pid = process_table_view->selected_pid(); if (pid != -1) kill(pid, SIGKILL); }); - auto stop_action = GAction::create("Stop process", { Mod_Ctrl, Key_S }, GraphicsBitmap::load_from_file("/res/icons/stop16.png"), [process_table_view](const GAction&) { + auto stop_action = GUI::Action::create("Stop process", { Mod_Ctrl, Key_S }, GraphicsBitmap::load_from_file("/res/icons/stop16.png"), [process_table_view](const GUI::Action&) { pid_t pid = process_table_view->selected_pid(); if (pid != -1) kill(pid, SIGSTOP); }); - auto continue_action = GAction::create("Continue process", { Mod_Ctrl, Key_C }, GraphicsBitmap::load_from_file("/res/icons/continue16.png"), [process_table_view](const GAction&) { + auto continue_action = GUI::Action::create("Continue process", { Mod_Ctrl, Key_C }, GraphicsBitmap::load_from_file("/res/icons/continue16.png"), [process_table_view](const GUI::Action&) { pid_t pid = process_table_view->selected_pid(); if (pid != -1) kill(pid, SIGCONT); @@ -174,35 +174,35 @@ int main(int argc, char** argv) toolbar->add_action(stop_action); toolbar->add_action(continue_action); - auto menubar = make(); - auto app_menu = GMenu::construct("System Monitor"); - app_menu->add_action(GCommonActions::make_quit_action([](auto&) { - GApplication::the().quit(0); + auto menubar = make(); + auto app_menu = GUI::Menu::construct("System Monitor"); + app_menu->add_action(GUI::CommonActions::make_quit_action([](auto&) { + GUI::Application::the().quit(0); return; })); menubar->add_menu(move(app_menu)); - auto process_menu = GMenu::construct("Process"); + auto process_menu = GUI::Menu::construct("Process"); process_menu->add_action(kill_action); process_menu->add_action(stop_action); process_menu->add_action(continue_action); menubar->add_menu(move(process_menu)); - auto process_context_menu = GMenu::construct(); + auto process_context_menu = GUI::Menu::construct(); process_context_menu->add_action(kill_action); process_context_menu->add_action(stop_action); process_context_menu->add_action(continue_action); - process_table_view->on_context_menu_request = [&](const GModelIndex& index, const GContextMenuEvent& event) { + process_table_view->on_context_menu_request = [&](const GUI::ModelIndex& index, const GUI::ContextMenuEvent& event) { (void)index; process_context_menu->popup(event.screen_position()); }; - auto frequency_menu = GMenu::construct("Frequency"); - GActionGroup frequency_action_group; + auto frequency_menu = GUI::Menu::construct("Frequency"); + GUI::ActionGroup frequency_action_group; frequency_action_group.set_exclusive(true); auto make_frequency_action = [&](auto& title, int interval, bool checked = false) { - auto action = GAction::create(title, [&refresh_timer, interval](auto& action) { + auto action = GUI::Action::create(title, [&refresh_timer, interval](auto& action) { refresh_timer->restart(interval); action.set_checked(true); }); @@ -220,15 +220,15 @@ int main(int argc, char** argv) menubar->add_menu(move(frequency_menu)); - auto help_menu = GMenu::construct("Help"); - help_menu->add_action(GAction::create("About", [&](const GAction&) { - GAboutDialog::show("System Monitor", load_png("/res/icons/32x32/app-system-monitor.png"), window); + auto help_menu = GUI::Menu::construct("Help"); + help_menu->add_action(GUI::Action::create("About", [&](const GUI::Action&) { + GUI::AboutDialog::show("System Monitor", load_png("/res/icons/32x32/app-system-monitor.png"), window); })); menubar->add_menu(move(help_menu)); app.set_menubar(move(menubar)); - auto process_tab_widget = GTabWidget::construct(process_container_splitter); + auto process_tab_widget = GUI::TabWidget::construct(process_container_splitter); auto memory_map_widget = ProcessMemoryMapWidget::construct(nullptr); process_tab_widget->add_widget("Memory map", memory_map_widget); @@ -256,16 +256,16 @@ int main(int argc, char** argv) return app.exec(); } -class ProgressBarPaintingDelegate final : public GTableCellPaintingDelegate { +class ProgressBarPaintingDelegate final : public GUI::TableCellPaintingDelegate { public: virtual ~ProgressBarPaintingDelegate() override {} - virtual void paint(GPainter& painter, const Rect& a_rect, const Palette& palette, const GModel& model, const GModelIndex& index) override + virtual void paint(GUI::Painter& painter, const Rect& a_rect, const Palette& palette, const GUI::Model& model, const GUI::ModelIndex& index) override { auto rect = a_rect.shrunken(2, 2); - auto percentage = model.data(index, GModel::Role::Custom).to_i32(); + auto percentage = model.data(index, GUI::Model::Role::Custom).to_i32(); - auto data = model.data(index, GModel::Role::Display); + auto data = model.data(index, GUI::Model::Role::Display); String text; if (data.is_string()) text = data.as_string(); @@ -274,17 +274,17 @@ public: } }; -RefPtr build_file_systems_tab() +RefPtr build_file_systems_tab() { - auto fs_widget = GLazyWidget::construct(); + auto fs_widget = GUI::LazyWidget::construct(); fs_widget->on_first_show = [](auto& self) { - self.set_layout(make()); + self.set_layout(make()); self.layout()->set_margins({ 4, 4, 4, 4 }); - auto fs_table_view = GTableView::construct(&self); + auto fs_table_view = GUI::TableView::construct(&self); fs_table_view->set_size_columns_to_fit_content(true); - Vector df_fields; + Vector df_fields; df_fields.empend("mount_point", "Mount point", TextAlignment::CenterLeft); df_fields.empend("class_name", "Class", TextAlignment::CenterLeft); df_fields.empend("device", "Device", TextAlignment::CenterLeft); @@ -354,7 +354,7 @@ RefPtr build_file_systems_tab() df_fields.empend("free_inode_count", "Free inodes", TextAlignment::CenterRight); df_fields.empend("total_inode_count", "Total inodes", TextAlignment::CenterRight); df_fields.empend("block_size", "Block size", TextAlignment::CenterRight); - fs_table_view->set_model(GSortingProxyModel::create(GJsonArrayModel::create("/proc/df", move(df_fields)))); + fs_table_view->set_model(GUI::SortingProxyModel::create(GUI::JsonArrayModel::create("/proc/df", move(df_fields)))); fs_table_view->set_cell_painting_delegate(3, make()); @@ -363,19 +363,19 @@ RefPtr build_file_systems_tab() return fs_widget; } -RefPtr build_pci_devices_tab() +RefPtr build_pci_devices_tab() { - auto pci_widget = GLazyWidget::construct(); + auto pci_widget = GUI::LazyWidget::construct(); pci_widget->on_first_show = [](auto& self) { - self.set_layout(make()); + self.set_layout(make()); self.layout()->set_margins({ 4, 4, 4, 4 }); - auto pci_table_view = GTableView::construct(&self); + auto pci_table_view = GUI::TableView::construct(&self); pci_table_view->set_size_columns_to_fit_content(true); auto db = PCIDB::Database::open(); - Vector pci_fields; + Vector pci_fields; pci_fields.empend( "Address", TextAlignment::CenterLeft, [](const JsonObject& object) { @@ -414,44 +414,44 @@ RefPtr build_pci_devices_tab() return String::format("%02x", revision_id); }); - pci_table_view->set_model(GSortingProxyModel::create(GJsonArrayModel::create("/proc/pci", move(pci_fields)))); + pci_table_view->set_model(GUI::SortingProxyModel::create(GUI::JsonArrayModel::create("/proc/pci", move(pci_fields)))); pci_table_view->model()->update(); }; return pci_widget; } -RefPtr build_devices_tab() +RefPtr build_devices_tab() { - auto devices_widget = GLazyWidget::construct(); + auto devices_widget = GUI::LazyWidget::construct(); devices_widget->on_first_show = [](auto& self) { - self.set_layout(make()); + self.set_layout(make()); self.layout()->set_margins({ 4, 4, 4, 4 }); - auto devices_table_view = GTableView::construct(&self); + auto devices_table_view = GUI::TableView::construct(&self); devices_table_view->set_size_columns_to_fit_content(true); - devices_table_view->set_model(GSortingProxyModel::create(DevicesModel::create())); + devices_table_view->set_model(GUI::SortingProxyModel::create(DevicesModel::create())); devices_table_view->model()->update(); }; return devices_widget; } -NonnullRefPtr build_graphs_tab() +NonnullRefPtr build_graphs_tab() { - auto graphs_container = GLazyWidget::construct(); + auto graphs_container = GUI::LazyWidget::construct(); graphs_container->on_first_show = [](auto& self) { self.set_fill_with_background_color(true); self.set_background_role(ColorRole::Button); - self.set_layout(make()); + self.set_layout(make()); self.layout()->set_margins({ 4, 4, 4, 4 }); - auto cpu_graph_group_box = GGroupBox::construct("CPU usage", &self); - cpu_graph_group_box->set_layout(make()); + auto cpu_graph_group_box = GUI::GroupBox::construct("CPU usage", &self); + cpu_graph_group_box->set_layout(make()); cpu_graph_group_box->layout()->set_margins({ 6, 16, 6, 6 }); - cpu_graph_group_box->set_size_policy(SizePolicy::Fill, SizePolicy::Fixed); + cpu_graph_group_box->set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed); cpu_graph_group_box->set_preferred_size(0, 120); auto cpu_graph = GraphWidget::construct(cpu_graph_group_box); cpu_graph->set_max(100); @@ -465,10 +465,10 @@ NonnullRefPtr build_graphs_tab() graph->add_value(cpu_percent); }; - auto memory_graph_group_box = GGroupBox::construct("Memory usage", &self); - memory_graph_group_box->set_layout(make()); + auto memory_graph_group_box = GUI::GroupBox::construct("Memory usage", &self); + memory_graph_group_box->set_layout(make()); memory_graph_group_box->layout()->set_margins({ 6, 16, 6, 6 }); - memory_graph_group_box->set_size_policy(SizePolicy::Fill, SizePolicy::Fixed); + memory_graph_group_box->set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed); memory_graph_group_box->set_preferred_size(0, 120); auto memory_graph = GraphWidget::construct(memory_graph_group_box); memory_graph->set_text_color(Color::Cyan); diff --git a/Applications/Taskbar/TaskbarButton.cpp b/Applications/Taskbar/TaskbarButton.cpp index 4fab06aa995..8c2dc7ef6b0 100644 --- a/Applications/Taskbar/TaskbarButton.cpp +++ b/Applications/Taskbar/TaskbarButton.cpp @@ -28,8 +28,8 @@ #include #include -TaskbarButton::TaskbarButton(const WindowIdentifier& identifier, GWidget* parent) - : GButton(parent) +TaskbarButton::TaskbarButton(const WindowIdentifier& identifier, GUI::Widget* parent) + : GUI::Button(parent) , m_identifier(identifier) { } @@ -38,17 +38,17 @@ TaskbarButton::~TaskbarButton() { } -void TaskbarButton::context_menu_event(GContextMenuEvent&) +void TaskbarButton::context_menu_event(GUI::ContextMenuEvent&) { - GWindowServerConnection::the().post_message(WindowServer::WM_PopupWindowMenu(m_identifier.client_id(), m_identifier.window_id(), screen_relative_rect().location())); + GUI::WindowServerConnection::the().post_message(WindowServer::WM_PopupWindowMenu(m_identifier.client_id(), m_identifier.window_id(), screen_relative_rect().location())); } -void TaskbarButton::resize_event(GResizeEvent& event) +void TaskbarButton::resize_event(GUI::ResizeEvent& event) { - GWindowServerConnection::the().post_message( + GUI::WindowServerConnection::the().post_message( WindowServer::WM_SetWindowTaskbarRect( m_identifier.client_id(), m_identifier.window_id(), screen_relative_rect())); - return GButton::resize_event(event); + return GUI::Button::resize_event(event); } diff --git a/Applications/Taskbar/TaskbarButton.h b/Applications/Taskbar/TaskbarButton.h index 204f7e178a8..6b998ebaaf4 100644 --- a/Applications/Taskbar/TaskbarButton.h +++ b/Applications/Taskbar/TaskbarButton.h @@ -29,15 +29,15 @@ #include "WindowIdentifier.h" #include -class TaskbarButton final : public GButton { +class TaskbarButton final : public GUI::Button { C_OBJECT(TaskbarButton) public: - TaskbarButton(const WindowIdentifier&, GWidget* parent); + TaskbarButton(const WindowIdentifier&, GUI::Widget* parent); virtual ~TaskbarButton() override; private: - virtual void context_menu_event(GContextMenuEvent&) override; - virtual void resize_event(GResizeEvent&) override; + virtual void context_menu_event(GUI::ContextMenuEvent&) override; + virtual void resize_event(GUI::ResizeEvent&) override; WindowIdentifier m_identifier; }; diff --git a/Applications/Taskbar/TaskbarWindow.cpp b/Applications/Taskbar/TaskbarWindow.cpp index 3492a12fba5..3049379d8bb 100644 --- a/Applications/Taskbar/TaskbarWindow.cpp +++ b/Applications/Taskbar/TaskbarWindow.cpp @@ -39,16 +39,16 @@ TaskbarWindow::TaskbarWindow() { - set_window_type(GWindowType::Taskbar); + set_window_type(GUI::WindowType::Taskbar); set_title("Taskbar"); - on_screen_rect_change(GDesktop::the().rect()); + on_screen_rect_change(GUI::Desktop::the().rect()); - GDesktop::the().on_rect_change = [this](const Rect& rect) { on_screen_rect_change(rect); }; + GUI::Desktop::the().on_rect_change = [this](const Rect& rect) { on_screen_rect_change(rect); }; - auto widget = GFrame::construct(); + auto widget = GUI::Frame::construct(); widget->set_fill_with_background_color(true); - widget->set_layout(make()); + widget->set_layout(make()); widget->layout()->set_margins({ 3, 2, 3, 2 }); widget->layout()->set_spacing(3); widget->set_frame_thickness(1); @@ -69,9 +69,9 @@ TaskbarWindow::~TaskbarWindow() void TaskbarWindow::create_quick_launch_bar() { - auto quick_launch_bar = GFrame::construct(main_widget()); - quick_launch_bar->set_size_policy(SizePolicy::Fixed, SizePolicy::Fixed); - quick_launch_bar->set_layout(make()); + auto quick_launch_bar = GUI::Frame::construct(main_widget()); + quick_launch_bar->set_size_policy(GUI::SizePolicy::Fixed, GUI::SizePolicy::Fixed); + quick_launch_bar->set_layout(make()); quick_launch_bar->layout()->set_spacing(3); quick_launch_bar->layout()->set_margins({ 3, 0, 3, 0 }); quick_launch_bar->set_frame_thickness(1); @@ -93,8 +93,8 @@ void TaskbarWindow::create_quick_launch_bar() auto app_executable = af->read_entry("App", "Executable"); auto app_icon_path = af->read_entry("Icons", "16x16"); - auto button = GButton::construct(quick_launch_bar); - button->set_size_policy(SizePolicy::Fixed, SizePolicy::Fixed); + auto button = GUI::Button::construct(quick_launch_bar); + button->set_size_policy(GUI::SizePolicy::Fixed, GUI::SizePolicy::Fixed); button->set_preferred_size(22, 22); button->set_button_style(ButtonStyle::CoolBar); @@ -127,28 +127,28 @@ void TaskbarWindow::on_screen_rect_change(const Rect& rect) set_rect(new_rect); } -NonnullRefPtr TaskbarWindow::create_button(const WindowIdentifier& identifier) +NonnullRefPtr TaskbarWindow::create_button(const WindowIdentifier& identifier) { auto button = TaskbarButton::construct(identifier, main_widget()); - button->set_size_policy(SizePolicy::Fixed, SizePolicy::Fixed); + button->set_size_policy(GUI::SizePolicy::Fixed, GUI::SizePolicy::Fixed); button->set_preferred_size(140, 22); button->set_checkable(true); button->set_text_alignment(TextAlignment::CenterLeft); return button; } -static bool should_include_window(GWindowType window_type) +static bool should_include_window(GUI::WindowType window_type) { - return window_type == GWindowType::Normal; + return window_type == GUI::WindowType::Normal; } -void TaskbarWindow::wm_event(GWMEvent& event) +void TaskbarWindow::wm_event(GUI::WMEvent& event) { WindowIdentifier identifier { event.client_id(), event.window_id() }; switch (event.type()) { - case GEvent::WM_WindowRemoved: { + case GUI::Event::WM_WindowRemoved: { #ifdef EVENT_DEBUG - auto& removed_event = static_cast(event); + auto& removed_event = static_cast(event); dbgprintf("WM_WindowRemoved: client_id=%d, window_id=%d\n", removed_event.client_id(), removed_event.window_id()); @@ -157,9 +157,9 @@ void TaskbarWindow::wm_event(GWMEvent& event) update(); break; } - case GEvent::WM_WindowRectChanged: { + case GUI::Event::WM_WindowRectChanged: { #ifdef EVENT_DEBUG - auto& changed_event = static_cast(event); + auto& changed_event = static_cast(event); dbgprintf("WM_WindowRectChanged: client_id=%d, window_id=%d, rect=%s\n", changed_event.client_id(), changed_event.window_id(), @@ -168,8 +168,8 @@ void TaskbarWindow::wm_event(GWMEvent& event) break; } - case GEvent::WM_WindowIconBitmapChanged: { - auto& changed_event = static_cast(event); + case GUI::Event::WM_WindowIconBitmapChanged: { + auto& changed_event = static_cast(event); #ifdef EVENT_DEBUG dbgprintf("WM_WindowIconBitmapChanged: client_id=%d, window_id=%d, icon_buffer_id=%d\n", changed_event.client_id(), @@ -184,8 +184,8 @@ void TaskbarWindow::wm_event(GWMEvent& event) break; } - case GEvent::WM_WindowStateChanged: { - auto& changed_event = static_cast(event); + case GUI::Event::WM_WindowStateChanged: { + auto& changed_event = static_cast(event); #ifdef EVENT_DEBUG dbgprintf("WM_WindowStateChanged: client_id=%d, window_id=%d, title=%s, rect=%s, is_active=%u, is_minimized=%u\n", changed_event.client_id(), diff --git a/Applications/Taskbar/TaskbarWindow.h b/Applications/Taskbar/TaskbarWindow.h index d26e585ed6e..6e42a6ba380 100644 --- a/Applications/Taskbar/TaskbarWindow.h +++ b/Applications/Taskbar/TaskbarWindow.h @@ -28,7 +28,7 @@ #include #include -class TaskbarWindow final : public GWindow { +class TaskbarWindow final : public GUI::Window { C_OBJECT(TaskbarWindow) public: TaskbarWindow(); @@ -39,7 +39,7 @@ public: private: void create_quick_launch_bar(); void on_screen_rect_change(const Rect&); - NonnullRefPtr create_button(const WindowIdentifier&); + NonnullRefPtr create_button(const WindowIdentifier&); - virtual void wm_event(GWMEvent&) override; + virtual void wm_event(GUI::WMEvent&) override; }; diff --git a/Applications/Taskbar/WindowList.cpp b/Applications/Taskbar/WindowList.cpp index 97dd168400e..fb6fd7e0d5e 100644 --- a/Applications/Taskbar/WindowList.cpp +++ b/Applications/Taskbar/WindowList.cpp @@ -52,9 +52,9 @@ Window& WindowList::ensure_window(const WindowIdentifier& identifier) window->set_button(aid_create_button(identifier)); window->button()->on_click = [window = window.ptr(), identifier](auto&) { if (window->is_minimized() || !window->is_active()) { - GWindowServerConnection::the().post_message(WindowServer::WM_SetActiveWindow(identifier.client_id(), identifier.window_id())); + GUI::WindowServerConnection::the().post_message(WindowServer::WM_SetActiveWindow(identifier.client_id(), identifier.window_id())); } else { - GWindowServerConnection::the().post_message(WindowServer::WM_SetWindowMinimized(identifier.client_id(), identifier.window_id(), true)); + GUI::WindowServerConnection::the().post_message(WindowServer::WM_SetWindowMinimized(identifier.client_id(), identifier.window_id(), true)); } }; auto& window_ref = *window; diff --git a/Applications/Taskbar/WindowList.h b/Applications/Taskbar/WindowList.h index 0d6e9447407..5ea89e5916c 100644 --- a/Applications/Taskbar/WindowList.h +++ b/Applications/Taskbar/WindowList.h @@ -53,8 +53,8 @@ public: Rect rect() const { return m_rect; } void set_rect(const Rect& rect) { m_rect = rect; } - GButton* button() { return m_button; } - void set_button(GButton* button) { m_button = button; } + GUI::Button* button() { return m_button; } + void set_button(GUI::Button* button) { m_button = button; } void set_active(bool active) { m_active = active; } bool is_active() const { return m_active; } @@ -68,7 +68,7 @@ private: WindowIdentifier m_identifier; String m_title; Rect m_rect; - RefPtr m_button; + RefPtr m_button; RefPtr m_icon; bool m_active { false }; bool m_minimized { false }; @@ -89,7 +89,7 @@ public: Window& ensure_window(const WindowIdentifier&); void remove_window(const WindowIdentifier&); - Function(const WindowIdentifier&)> aid_create_button; + Function(const WindowIdentifier&)> aid_create_button; private: HashMap> m_windows; diff --git a/Applications/Taskbar/main.cpp b/Applications/Taskbar/main.cpp index e3d5552e9c3..afdee7ed9e7 100644 --- a/Applications/Taskbar/main.cpp +++ b/Applications/Taskbar/main.cpp @@ -36,7 +36,7 @@ int main(int argc, char** argv) return 1; } - GApplication app(argc, argv); + GUI::Application app(argc, argv); if (pledge("stdio shared_buffer accept proc exec rpath", nullptr) < 0) { perror("pledge"); diff --git a/Applications/Terminal/main.cpp b/Applications/Terminal/main.cpp index 1eb659de67d..83070a9bb09 100644 --- a/Applications/Terminal/main.cpp +++ b/Applications/Terminal/main.cpp @@ -125,39 +125,39 @@ static void run_command(int ptm_fd, String command) } } -RefPtr create_settings_window(TerminalWidget& terminal) +RefPtr create_settings_window(TerminalWidget& terminal) { - auto window = GWindow::construct(); + auto window = GUI::Window::construct(); window->set_title("Terminal Settings"); window->set_rect(50, 50, 200, 140); - auto settings = GWidget::construct(); + auto settings = GUI::Widget::construct(); window->set_main_widget(settings); settings->set_fill_with_background_color(true); settings->set_background_role(ColorRole::Button); - settings->set_layout(make()); + settings->set_layout(make()); settings->layout()->set_margins({ 4, 4, 4, 4 }); - auto radio_container = GGroupBox::construct("Bell Mode", settings); - radio_container->set_layout(make()); + auto radio_container = GUI::GroupBox::construct("Bell Mode", settings); + radio_container->set_layout(make()); radio_container->layout()->set_margins({ 6, 16, 6, 6 }); - radio_container->set_size_policy(SizePolicy::Fill, SizePolicy::Fixed); + radio_container->set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed); radio_container->set_preferred_size(100, 70); - auto sysbell_radio = GRadioButton::construct("Use (Audible) System Bell", radio_container); - auto visbell_radio = GRadioButton::construct("Use (Visual) Terminal Bell", radio_container); + auto sysbell_radio = GUI::RadioButton::construct("Use (Audible) System Bell", radio_container); + auto visbell_radio = GUI::RadioButton::construct("Use (Visual) Terminal Bell", radio_container); sysbell_radio->set_checked(terminal.should_beep()); visbell_radio->set_checked(!terminal.should_beep()); sysbell_radio->on_checked = [&terminal](const bool checked) { terminal.set_should_beep(checked); }; - auto slider_container = GGroupBox::construct("Background Opacity", settings); - slider_container->set_layout(make()); + auto slider_container = GUI::GroupBox::construct("Background Opacity", settings); + slider_container->set_layout(make()); slider_container->layout()->set_margins({ 6, 16, 6, 6 }); - slider_container->set_size_policy(SizePolicy::Fill, SizePolicy::Fixed); + slider_container->set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed); slider_container->set_preferred_size(100, 50); - auto slider = GSlider::construct(Orientation::Horizontal, slider_container); + auto slider = GUI::Slider::construct(Orientation::Horizontal, slider_container); slider->on_value_changed = [&terminal](int value) { terminal.set_opacity(value); @@ -186,7 +186,7 @@ int main(int argc, char** argv) return 1; } - GApplication app(argc, argv); + GUI::Application app(argc, argv); if (pledge("stdio tty rpath accept cpath wpath shared_buffer proc exec", nullptr) < 0) { perror("pledge"); @@ -210,7 +210,7 @@ int main(int argc, char** argv) run_command(ptm_fd, command_to_execute); - auto window = GWindow::construct(); + auto window = GUI::Window::construct(); window->set_title("Terminal"); window->set_background_color(Color::Black); window->set_double_buffering_enabled(false); @@ -230,50 +230,50 @@ int main(int argc, char** argv) window->set_icon(load_png("/res/icons/16x16/app-terminal.png")); terminal->set_should_beep(config->read_bool_entry("Window", "AudibleBeep", false)); - RefPtr settings_window; + RefPtr settings_window; auto new_opacity = config->read_num_entry("Window", "Opacity", 255); terminal->set_opacity(new_opacity); window->set_has_alpha_channel(new_opacity < 255); - auto menubar = make(); + auto menubar = make(); - auto app_menu = GMenu::construct("Terminal"); - app_menu->add_action(GAction::create("Open new terminal", { Mod_Ctrl | Mod_Shift, Key_N }, GraphicsBitmap::load_from_file("/res/icons/16x16/app-terminal.png"), [&](auto&) { + auto app_menu = GUI::Menu::construct("Terminal"); + app_menu->add_action(GUI::Action::create("Open new terminal", { Mod_Ctrl | Mod_Shift, Key_N }, GraphicsBitmap::load_from_file("/res/icons/16x16/app-terminal.png"), [&](auto&) { if (!fork()) { execl("/bin/Terminal", "Terminal", nullptr); exit(1); } })); - app_menu->add_action(GAction::create("Settings...", load_png("/res/icons/gear16.png"), - [&](const GAction&) { + app_menu->add_action(GUI::Action::create("Settings...", load_png("/res/icons/gear16.png"), + [&](const GUI::Action&) { if (!settings_window) { settings_window = create_settings_window(*terminal); settings_window->on_close_request = [&] { settings_window = nullptr; - return GWindow::CloseRequestDecision::Close; + return GUI::Window::CloseRequestDecision::Close; }; } settings_window->show(); settings_window->move_to_front(); })); app_menu->add_separator(); - app_menu->add_action(GCommonActions::make_quit_action([](auto&) { + app_menu->add_action(GUI::CommonActions::make_quit_action([](auto&) { dbgprintf("Terminal: Quit menu activated!\n"); - GApplication::the().quit(0); + GUI::Application::the().quit(0); })); menubar->add_menu(move(app_menu)); - auto edit_menu = GMenu::construct("Edit"); + auto edit_menu = GUI::Menu::construct("Edit"); edit_menu->add_action(terminal->copy_action()); edit_menu->add_action(terminal->paste_action()); menubar->add_menu(move(edit_menu)); - GActionGroup font_action_group; + GUI::ActionGroup font_action_group; font_action_group.set_exclusive(true); - auto font_menu = GMenu::construct("Font"); + auto font_menu = GUI::Menu::construct("Font"); GFontDatabase::the().for_each_fixed_width_font([&](const StringView& font_name) { - auto action = GAction::create(font_name, [&](GAction& action) { + auto action = GUI::Action::create(font_name, [&](GUI::Action& action) { action.set_checked(true); terminal->set_font(GFontDatabase::the().get_by_name(action.text())); auto metadata = GFontDatabase::the().get_metadata_by_name(action.text()); @@ -290,9 +290,9 @@ int main(int argc, char** argv) }); menubar->add_menu(move(font_menu)); - auto help_menu = GMenu::construct("Help"); - help_menu->add_action(GAction::create("About", [&](const GAction&) { - GAboutDialog::show("Terminal", load_png("/res/icons/32x32/app-terminal.png"), window); + auto help_menu = GUI::Menu::construct("Help"); + help_menu->add_action(GUI::Action::create("About", [&](const GUI::Action&) { + GUI::AboutDialog::show("Terminal", load_png("/res/icons/32x32/app-terminal.png"), window); })); menubar->add_menu(move(help_menu)); diff --git a/Applications/TextEditor/TextEditorWidget.cpp b/Applications/TextEditor/TextEditorWidget.cpp index f519684d1f1..32cd3c6b47b 100644 --- a/Applications/TextEditor/TextEditorWidget.cpp +++ b/Applications/TextEditor/TextEditorWidget.cpp @@ -45,11 +45,11 @@ TextEditorWidget::TextEditorWidget() { - set_layout(make()); + set_layout(make()); layout()->set_spacing(0); - auto toolbar = GToolBar::construct(this); - m_editor = GTextEditor::construct(GTextEditor::MultiLine, this); + auto toolbar = GUI::ToolBar::construct(this); + m_editor = GUI::TextEditor::construct(GUI::TextEditor::MultiLine, this); m_editor->set_ruler_visible(true); m_editor->set_automatic_indentation_enabled(true); m_editor->set_line_wrapping_enabled(true); @@ -67,32 +67,32 @@ TextEditorWidget::TextEditorWidget() update_title(); }; - m_find_replace_widget = GWidget::construct(this); + m_find_replace_widget = GUI::Widget::construct(this); m_find_replace_widget->set_fill_with_background_color(true); - m_find_replace_widget->set_size_policy(SizePolicy::Fill, SizePolicy::Fixed); + m_find_replace_widget->set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed); m_find_replace_widget->set_preferred_size(0, 48); - m_find_replace_widget->set_layout(make()); + m_find_replace_widget->set_layout(make()); m_find_replace_widget->layout()->set_margins({ 2, 2, 2, 4 }); m_find_replace_widget->set_visible(false); - m_find_widget = GWidget::construct(m_find_replace_widget); + m_find_widget = GUI::Widget::construct(m_find_replace_widget); m_find_widget->set_fill_with_background_color(true); - m_find_widget->set_size_policy(SizePolicy::Fill, SizePolicy::Fixed); + m_find_widget->set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed); m_find_widget->set_preferred_size(0, 22); - m_find_widget->set_layout(make()); + m_find_widget->set_layout(make()); m_find_widget->set_visible(false); - m_replace_widget = GWidget::construct(m_find_replace_widget); + m_replace_widget = GUI::Widget::construct(m_find_replace_widget); m_replace_widget->set_fill_with_background_color(true); - m_replace_widget->set_size_policy(SizePolicy::Fill, SizePolicy::Fixed); + m_replace_widget->set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed); m_replace_widget->set_preferred_size(0, 22); - m_replace_widget->set_layout(make()); + m_replace_widget->set_layout(make()); m_replace_widget->set_visible(false); - m_find_textbox = GTextBox::construct(m_find_widget); - m_replace_textbox = GTextBox::construct(m_replace_widget); + m_find_textbox = GUI::TextBox::construct(m_find_widget); + m_replace_textbox = GUI::TextBox::construct(m_replace_widget); - m_find_next_action = GAction::create("Find next", { Mod_Ctrl, Key_G }, [&](auto&) { + m_find_next_action = GUI::Action::create("Find next", { Mod_Ctrl, Key_G }, [&](auto&) { auto needle = m_find_textbox->text(); if (needle.is_empty()) { dbg() << "find_next(\"\")"; @@ -103,15 +103,15 @@ TextEditorWidget::TextEditorWidget() if (found_range.is_valid()) { m_editor->set_selection(found_range); } else { - GMessageBox::show( + GUI::MessageBox::show( String::format("Not found: \"%s\"", needle.characters()), "Not found", - GMessageBox::Type::Information, - GMessageBox::InputType::OK, window()); + GUI::MessageBox::Type::Information, + GUI::MessageBox::InputType::OK, window()); } }); - m_find_previous_action = GAction::create("Find previous", { Mod_Ctrl | Mod_Shift, Key_G }, [&](auto&) { + m_find_previous_action = GUI::Action::create("Find previous", { Mod_Ctrl | Mod_Shift, Key_G }, [&](auto&) { auto needle = m_find_textbox->text(); if (needle.is_empty()) { dbg() << "find_prev(\"\")"; @@ -128,15 +128,15 @@ TextEditorWidget::TextEditorWidget() if (found_range.is_valid()) { m_editor->set_selection(found_range); } else { - GMessageBox::show( + GUI::MessageBox::show( String::format("Not found: \"%s\"", needle.characters()), "Not found", - GMessageBox::Type::Information, - GMessageBox::InputType::OK, window()); + GUI::MessageBox::Type::Information, + GUI::MessageBox::InputType::OK, window()); } }); - m_replace_next_action = GAction::create("Replace next", { Mod_Ctrl, Key_F1 }, [&](auto&) { + m_replace_next_action = GUI::Action::create("Replace next", { Mod_Ctrl, Key_F1 }, [&](auto&) { auto needle = m_find_textbox->text(); auto substitute = m_replace_textbox->text(); @@ -153,15 +153,15 @@ TextEditorWidget::TextEditorWidget() m_editor->set_selection(found_range); m_editor->insert_at_cursor_or_replace_selection(substitute); } else { - GMessageBox::show( + GUI::MessageBox::show( String::format("Not found: \"%s\"", needle.characters()), "Not found", - GMessageBox::Type::Information, - GMessageBox::InputType::OK, window()); + GUI::MessageBox::Type::Information, + GUI::MessageBox::InputType::OK, window()); } }); - m_replace_previous_action = GAction::create("Replace previous", { Mod_Ctrl | Mod_Shift, Key_F1 }, [&](auto&) { + m_replace_previous_action = GUI::Action::create("Replace previous", { Mod_Ctrl | Mod_Shift, Key_F1 }, [&](auto&) { auto needle = m_find_textbox->text(); auto substitute = m_replace_textbox->text(); if (needle.is_empty()) @@ -177,15 +177,15 @@ TextEditorWidget::TextEditorWidget() m_editor->set_selection(found_range); m_editor->insert_at_cursor_or_replace_selection(substitute); } else { - GMessageBox::show( + GUI::MessageBox::show( String::format("Not found: \"%s\"", needle.characters()), "Not found", - GMessageBox::Type::Information, - GMessageBox::InputType::OK, window()); + GUI::MessageBox::Type::Information, + GUI::MessageBox::InputType::OK, window()); } }); - m_replace_all_action = GAction::create("Replace all", { Mod_Ctrl, Key_F2 }, [&](auto&) { + m_replace_all_action = GUI::Action::create("Replace all", { Mod_Ctrl, Key_F2 }, [&](auto&) { auto needle = m_find_textbox->text(); auto substitute = m_replace_textbox->text(); if (needle.is_empty()) @@ -200,13 +200,13 @@ TextEditorWidget::TextEditorWidget() } }); - m_find_previous_button = GButton::construct("Find previous", m_find_widget); - m_find_previous_button->set_size_policy(SizePolicy::Fixed, SizePolicy::Fill); + m_find_previous_button = GUI::Button::construct("Find previous", m_find_widget); + m_find_previous_button->set_size_policy(GUI::SizePolicy::Fixed, GUI::SizePolicy::Fill); m_find_previous_button->set_preferred_size(150, 0); m_find_previous_button->set_action(*m_find_previous_action); - m_find_next_button = GButton::construct("Find next", m_find_widget); - m_find_next_button->set_size_policy(SizePolicy::Fixed, SizePolicy::Fill); + m_find_next_button = GUI::Button::construct("Find next", m_find_widget); + m_find_next_button->set_size_policy(GUI::SizePolicy::Fixed, GUI::SizePolicy::Fill); m_find_next_button->set_preferred_size(150, 0); m_find_next_button->set_action(*m_find_next_action); @@ -219,18 +219,18 @@ TextEditorWidget::TextEditorWidget() m_editor->set_focus(true); }; - m_replace_previous_button = GButton::construct("Replace previous", m_replace_widget); - m_replace_previous_button->set_size_policy(SizePolicy::Fixed, SizePolicy::Fill); + m_replace_previous_button = GUI::Button::construct("Replace previous", m_replace_widget); + m_replace_previous_button->set_size_policy(GUI::SizePolicy::Fixed, GUI::SizePolicy::Fill); m_replace_previous_button->set_preferred_size(100, 0); m_replace_previous_button->set_action(*m_replace_previous_action); - m_replace_next_button = GButton::construct("Replace next", m_replace_widget); - m_replace_next_button->set_size_policy(SizePolicy::Fixed, SizePolicy::Fill); + m_replace_next_button = GUI::Button::construct("Replace next", m_replace_widget); + m_replace_next_button->set_size_policy(GUI::SizePolicy::Fixed, GUI::SizePolicy::Fill); m_replace_next_button->set_preferred_size(100, 0); m_replace_next_button->set_action(*m_replace_next_action); - m_replace_all_button = GButton::construct("Replace all", m_replace_widget); - m_replace_all_button->set_size_policy(SizePolicy::Fixed, SizePolicy::Fill); + m_replace_all_button = GUI::Button::construct("Replace all", m_replace_widget); + m_replace_all_button->set_size_policy(GUI::SizePolicy::Fixed, GUI::SizePolicy::Fill); m_replace_all_button->set_preferred_size(100, 0); m_replace_all_button->set_action(*m_replace_all_action); @@ -243,7 +243,7 @@ TextEditorWidget::TextEditorWidget() m_editor->set_focus(true); }; - m_find_replace_action = GAction::create("Find/Replace...", { Mod_Ctrl, Key_F }, load_png("/res/icons/16x16/find.png"), [this](auto&) { + m_find_replace_action = GUI::Action::create("Find/Replace...", { Mod_Ctrl, Key_F }, load_png("/res/icons/16x16/find.png"), [this](auto&) { m_find_replace_widget->set_visible(true); m_find_widget->set_visible(true); m_replace_widget->set_visible(true); @@ -260,7 +260,7 @@ TextEditorWidget::TextEditorWidget() m_editor->add_custom_context_menu_action(*m_find_next_action); m_editor->add_custom_context_menu_action(*m_find_previous_action); - m_statusbar = GStatusBar::construct(this); + m_statusbar = GUI::StatusBar::construct(this); m_editor->on_cursor_change = [this] { StringBuilder builder; @@ -268,12 +268,12 @@ TextEditorWidget::TextEditorWidget() m_statusbar->set_text(builder.to_string()); }; - m_new_action = GAction::create("New", { Mod_Ctrl, Key_N }, GraphicsBitmap::load_from_file("/res/icons/16x16/new.png"), [this](const GAction&) { + m_new_action = GUI::Action::create("New", { Mod_Ctrl, Key_N }, GraphicsBitmap::load_from_file("/res/icons/16x16/new.png"), [this](const GUI::Action&) { if (m_document_dirty) { - auto save_document_first_box = GMessageBox::construct("Save Document First?", "Warning", GMessageBox::Type::Warning, GMessageBox::InputType::OKCancel, window()); + auto save_document_first_box = GUI::MessageBox::construct("Save Document First?", "Warning", GUI::MessageBox::Type::Warning, GUI::MessageBox::InputType::OKCancel, window()); auto save_document_first_result = save_document_first_box->exec(); - if (save_document_first_result != GDialog::ExecResult::ExecOK) + if (save_document_first_result != GUI::Dialog::ExecResult::ExecOK) return; m_save_action->activate(); } @@ -284,30 +284,30 @@ TextEditorWidget::TextEditorWidget() update_title(); }); - m_open_action = GCommonActions::make_open_action([this](auto&) { - Optional open_path = GFilePicker::get_open_filepath(); + m_open_action = GUI::CommonActions::make_open_action([this](auto&) { + Optional open_path = GUI::FilePicker::get_open_filepath(); if (!open_path.has_value()) return; if (m_document_dirty) { - auto save_document_first_box = GMessageBox::construct("Save Document First?", "Warning", GMessageBox::Type::Warning, GMessageBox::InputType::OKCancel, window()); + auto save_document_first_box = GUI::MessageBox::construct("Save Document First?", "Warning", GUI::MessageBox::Type::Warning, GUI::MessageBox::InputType::OKCancel, window()); auto save_document_first_result = save_document_first_box->exec(); - if (save_document_first_result == GDialog::ExecResult::ExecOK) + if (save_document_first_result == GUI::Dialog::ExecResult::ExecOK) m_save_action->activate(); } open_sesame(open_path.value()); }); - m_save_as_action = GAction::create("Save as...", { Mod_Ctrl | Mod_Shift, Key_S }, GraphicsBitmap::load_from_file("/res/icons/16x16/save.png"), [this](const GAction&) { - Optional save_path = GFilePicker::get_save_filepath(m_name.is_null() ? "Untitled" : m_name, m_extension.is_null() ? "txt" : m_extension); + m_save_as_action = GUI::Action::create("Save as...", { Mod_Ctrl | Mod_Shift, Key_S }, GraphicsBitmap::load_from_file("/res/icons/16x16/save.png"), [this](const GUI::Action&) { + Optional save_path = GUI::FilePicker::get_save_filepath(m_name.is_null() ? "Untitled" : m_name, m_extension.is_null() ? "txt" : m_extension); if (!save_path.has_value()) return; if (!m_editor->write_to_file(save_path.value())) { - GMessageBox::show("Unable to save file.\n", "Error", GMessageBox::Type::Error, GMessageBox::InputType::OK, window()); + GUI::MessageBox::show("Unable to save file.\n", "Error", GUI::MessageBox::Type::Error, GUI::MessageBox::InputType::OK, window()); return; } @@ -316,10 +316,10 @@ TextEditorWidget::TextEditorWidget() dbg() << "Wrote document to " << save_path.value(); }); - m_save_action = GAction::create("Save", { Mod_Ctrl, Key_S }, GraphicsBitmap::load_from_file("/res/icons/16x16/save.png"), [&](const GAction&) { + m_save_action = GUI::Action::create("Save", { Mod_Ctrl, Key_S }, GraphicsBitmap::load_from_file("/res/icons/16x16/save.png"), [&](const GUI::Action&) { if (!m_path.is_empty()) { if (!m_editor->write_to_file(m_path)) { - GMessageBox::show("Unable to save file.\n", "Error", GMessageBox::Type::Error, GMessageBox::InputType::OK, window()); + GUI::MessageBox::show("Unable to save file.\n", "Error", GUI::MessageBox::Type::Error, GUI::MessageBox::InputType::OK, window()); } else { m_document_dirty = false; update_title(); @@ -330,28 +330,28 @@ TextEditorWidget::TextEditorWidget() m_save_as_action->activate(); }); - m_line_wrapping_setting_action = GAction::create("Line wrapping", [&](GAction& action) { + m_line_wrapping_setting_action = GUI::Action::create("Line wrapping", [&](GUI::Action& action) { action.set_checked(!action.is_checked()); m_editor->set_line_wrapping_enabled(action.is_checked()); }); m_line_wrapping_setting_action->set_checkable(true); m_line_wrapping_setting_action->set_checked(m_editor->is_line_wrapping_enabled()); - auto menubar = make(); - auto app_menu = GMenu::construct("Text Editor"); + auto menubar = make(); + auto app_menu = GUI::Menu::construct("Text Editor"); app_menu->add_action(*m_new_action); app_menu->add_action(*m_open_action); app_menu->add_action(*m_save_action); app_menu->add_action(*m_save_as_action); app_menu->add_separator(); - app_menu->add_action(GCommonActions::make_quit_action([this](auto&) { + app_menu->add_action(GUI::CommonActions::make_quit_action([this](auto&) { if (!request_close()) return; - GApplication::the().quit(0); + GUI::Application::the().quit(0); })); menubar->add_menu(move(app_menu)); - auto edit_menu = GMenu::construct("Edit"); + auto edit_menu = GUI::Menu::construct("Edit"); edit_menu->add_action(m_editor->undo_action()); edit_menu->add_action(m_editor->redo_action()); edit_menu->add_separator(); @@ -368,27 +368,27 @@ TextEditorWidget::TextEditorWidget() edit_menu->add_action(*m_replace_all_action); menubar->add_menu(move(edit_menu)); - auto font_menu = GMenu::construct("Font"); + auto font_menu = GUI::Menu::construct("Font"); GFontDatabase::the().for_each_fixed_width_font([&](const StringView& font_name) { - font_menu->add_action(GAction::create(font_name, [this](const GAction& action) { + font_menu->add_action(GUI::Action::create(font_name, [this](const GUI::Action& action) { m_editor->set_font(GFontDatabase::the().get_by_name(action.text())); m_editor->update(); })); }); - auto view_menu = GMenu::construct("View"); + auto view_menu = GUI::Menu::construct("View"); view_menu->add_action(*m_line_wrapping_setting_action); view_menu->add_separator(); view_menu->add_submenu(move(font_menu)); menubar->add_menu(move(view_menu)); - auto help_menu = GMenu::construct("Help"); - help_menu->add_action(GAction::create("About", [&](const GAction&) { - GAboutDialog::show("Text Editor", load_png("/res/icons/32x32/app-texteditor.png"), window()); + auto help_menu = GUI::Menu::construct("Help"); + help_menu->add_action(GUI::Action::create("About", [&](const GUI::Action&) { + GUI::AboutDialog::show("Text Editor", load_png("/res/icons/32x32/app-texteditor.png"), window()); })); menubar->add_menu(move(help_menu)); - GApplication::the().set_menubar(move(menubar)); + GUI::Application::the().set_menubar(move(menubar)); toolbar->add_action(*m_new_action); toolbar->add_action(*m_open_action); @@ -433,7 +433,7 @@ void TextEditorWidget::open_sesame(const String& path) { auto file = Core::File::construct(path); if (!file->open(Core::IODevice::ReadOnly)) { - GMessageBox::show(String::format("Opening \"%s\" failed: %s", path.characters(), strerror(errno)), "Error", GMessageBox::Type::Error, GMessageBox::InputType::OK, window()); + GUI::MessageBox::show(String::format("Opening \"%s\" failed: %s", path.characters(), strerror(errno)), "Error", GUI::MessageBox::Type::Error, GUI::MessageBox::InputType::OK, window()); return; } @@ -450,11 +450,11 @@ bool TextEditorWidget::request_close() { if (!m_document_dirty) return true; - auto result = GMessageBox::show("The document has been modified. Quit without saving?", "Quit without saving?", GMessageBox::Type::Warning, GMessageBox::InputType::OKCancel, window()); - return result == GMessageBox::ExecOK; + auto result = GUI::MessageBox::show("The document has been modified. Quit without saving?", "Quit without saving?", GUI::MessageBox::Type::Warning, GUI::MessageBox::InputType::OKCancel, window()); + return result == GUI::MessageBox::ExecOK; } -void TextEditorWidget::drop_event(GDropEvent& event) +void TextEditorWidget::drop_event(GUI::DropEvent& event) { event.accept(); window()->move_to_front(); @@ -464,7 +464,7 @@ void TextEditorWidget::drop_event(GDropEvent& event) if (lines.is_empty()) return; if (lines.size() > 1) { - GMessageBox::show("TextEditor can only open one file at a time!", "One at a time please!", GMessageBox::Type::Error, GMessageBox::InputType::OK, window()); + GUI::MessageBox::show("TextEditor can only open one file at a time!", "One at a time please!", GUI::MessageBox::Type::Error, GUI::MessageBox::InputType::OK, window()); return; } URL url(lines[0]); diff --git a/Applications/TextEditor/TextEditorWidget.h b/Applications/TextEditor/TextEditorWidget.h index 1ff369f6c99..57823c355fd 100644 --- a/Applications/TextEditor/TextEditorWidget.h +++ b/Applications/TextEditor/TextEditorWidget.h @@ -33,55 +33,57 @@ #include #include -class GButton; -class GTextBox; -class GTextEditor; -class GStatusBar; +namespace GUI { +class Button; +class StatusBar; +class TextBox; +class TextEditor; +} -class TextEditorWidget final : public GWidget { +class TextEditorWidget final : public GUI::Widget { C_OBJECT(TextEditorWidget) public: virtual ~TextEditorWidget() override; void open_sesame(const String& path); bool request_close(); - GTextEditor& editor() { return *m_editor; } + GUI::TextEditor& editor() { return *m_editor; } private: TextEditorWidget(); void set_path(const FileSystemPath& file); void update_title(); - virtual void drop_event(GDropEvent&) override; + virtual void drop_event(GUI::DropEvent&) override; - RefPtr m_editor; + RefPtr m_editor; String m_path; String m_name; String m_extension; - RefPtr m_new_action; - RefPtr m_open_action; - RefPtr m_save_action; - RefPtr m_save_as_action; - RefPtr m_find_replace_action; - RefPtr m_line_wrapping_setting_action; - RefPtr m_find_next_action; - RefPtr m_find_previous_action; - RefPtr m_replace_next_action; - RefPtr m_replace_previous_action; - RefPtr m_replace_all_action; + RefPtr m_new_action; + RefPtr m_open_action; + RefPtr m_save_action; + RefPtr m_save_as_action; + RefPtr m_find_replace_action; + RefPtr m_line_wrapping_setting_action; + RefPtr m_find_next_action; + RefPtr m_find_previous_action; + RefPtr m_replace_next_action; + RefPtr m_replace_previous_action; + RefPtr m_replace_all_action; - RefPtr m_statusbar; + RefPtr m_statusbar; - RefPtr m_find_textbox; - RefPtr m_replace_textbox; - GButton* m_find_previous_button { nullptr }; - GButton* m_find_next_button { nullptr }; - GButton* m_replace_previous_button { nullptr }; - GButton* m_replace_next_button { nullptr }; - GButton* m_replace_all_button { nullptr }; - RefPtr m_find_replace_widget; - RefPtr m_find_widget; - RefPtr m_replace_widget; + RefPtr m_find_textbox; + RefPtr m_replace_textbox; + GUI::Button* m_find_previous_button { nullptr }; + GUI::Button* m_find_next_button { nullptr }; + GUI::Button* m_replace_previous_button { nullptr }; + GUI::Button* m_replace_next_button { nullptr }; + GUI::Button* m_replace_all_button { nullptr }; + RefPtr m_find_replace_widget; + RefPtr m_find_widget; + RefPtr m_replace_widget; bool m_document_dirty { false }; bool m_document_opening { false }; diff --git a/Applications/TextEditor/main.cpp b/Applications/TextEditor/main.cpp index e87d03c9da6..7b4b82a96b8 100644 --- a/Applications/TextEditor/main.cpp +++ b/Applications/TextEditor/main.cpp @@ -35,14 +35,14 @@ int main(int argc, char** argv) return 1; } - GApplication app(argc, argv); + GUI::Application app(argc, argv); if (pledge("stdio rpath accept cpath wpath shared_buffer", nullptr) < 0) { perror("pledge"); return 1; } - auto window = GWindow::construct(); + auto window = GUI::Window::construct(); window->set_title("Text Editor"); window->set_rect(20, 200, 640, 400); @@ -51,10 +51,10 @@ int main(int argc, char** argv) text_widget->editor().set_focus(true); - window->on_close_request = [&]() -> GWindow::CloseRequestDecision { + window->on_close_request = [&]() -> GUI::Window::CloseRequestDecision { if (text_widget->request_close()) - return GWindow::CloseRequestDecision::Close; - return GWindow::CloseRequestDecision::StayOpen; + return GUI::Window::CloseRequestDecision::Close; + return GUI::Window::CloseRequestDecision::StayOpen; }; if (argc >= 2) diff --git a/Applications/Welcome/TextWidget.cpp b/Applications/Welcome/TextWidget.cpp index c7e909d6eef..c709478e033 100644 --- a/Applications/Welcome/TextWidget.cpp +++ b/Applications/Welcome/TextWidget.cpp @@ -31,13 +31,13 @@ #include #include -TextWidget::TextWidget(GWidget* parent) - : GFrame(parent) +TextWidget::TextWidget(GUI::Widget* parent) + : GUI::Frame(parent) { } -TextWidget::TextWidget(const StringView& text, GWidget* parent) - : GFrame(parent) +TextWidget::TextWidget(const StringView& text, GUI::Widget* parent) + : GUI::Frame(parent) , m_text(text) { } @@ -55,11 +55,11 @@ void TextWidget::set_text(const StringView& text) update(); } -void TextWidget::paint_event(GPaintEvent& event) +void TextWidget::paint_event(GUI::PaintEvent& event) { - GFrame::paint_event(event); + GUI::Frame::paint_event(event); - GPainter painter(*this); + GUI::Painter painter(*this); painter.add_clip_rect(event.rect()); int indent = 0; @@ -83,10 +83,10 @@ void TextWidget::paint_event(GPaintEvent& event) } } -void TextWidget::resize_event(GResizeEvent& event) +void TextWidget::resize_event(GUI::ResizeEvent& event) { wrap_and_set_height(); - GWidget::resize_event(event); + GUI::Widget::resize_event(event); } void TextWidget::wrap_and_set_height() @@ -136,6 +136,6 @@ void TextWidget::wrap_and_set_height() m_lines = lines; - set_size_policy(SizePolicy::Fill, SizePolicy::Fixed); + set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed); set_preferred_size(0, m_lines.size() * m_line_height + frame_thickness() * 2); } diff --git a/Applications/Welcome/TextWidget.h b/Applications/Welcome/TextWidget.h index a89af79f790..153067819f7 100644 --- a/Applications/Welcome/TextWidget.h +++ b/Applications/Welcome/TextWidget.h @@ -31,11 +31,11 @@ #include #include -class TextWidget : public GFrame { +class TextWidget : public GUI::Frame { C_OBJECT(TextWidget) public: - explicit TextWidget(GWidget* parent = nullptr); - TextWidget(const StringView& text, GWidget* parent = nullptr); + explicit TextWidget(GUI::Widget* parent = nullptr); + TextWidget(const StringView& text, GUI::Widget* parent = nullptr); virtual ~TextWidget() override; String text() const { return m_text; } @@ -53,8 +53,8 @@ public: void wrap_and_set_height(); private: - virtual void paint_event(GPaintEvent&) override; - virtual void resize_event(GResizeEvent&) override; + virtual void paint_event(GUI::PaintEvent&) override; + virtual void resize_event(GUI::ResizeEvent&) override; String m_text; Vector m_lines; diff --git a/Applications/Welcome/main.cpp b/Applications/Welcome/main.cpp index 3f909a8ab2e..14855d50aca 100644 --- a/Applications/Welcome/main.cpp +++ b/Applications/Welcome/main.cpp @@ -86,68 +86,68 @@ int main(int argc, char** argv) }, }; - GApplication app(argc, argv); + GUI::Application app(argc, argv); - auto window = GWindow::construct(); + auto window = GUI::Window::construct(); window->set_title("Welcome to Serenity"); Rect window_rect { 0, 0, 640, 360 }; - window_rect.center_within(GDesktop::the().rect()); + window_rect.center_within(GUI::Desktop::the().rect()); window->set_resizable(true); window->set_rect(window_rect); - auto background = GLabel::construct(); + auto background = GUI::Label::construct(); window->set_main_widget(background); background->set_fill_with_background_color(true); - background->set_layout(make()); + background->set_layout(make()); background->layout()->set_margins({ 8, 8, 8, 8 }); background->layout()->set_spacing(8); background->set_icon(load_png_from_memory((const u8*)&_binary_background_png_start, (size_t)&_binary_background_png_size)); - background->set_size_policy(SizePolicy::Fill, SizePolicy::Fill); + background->set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fill); background->set_preferred_size(background->icon()->size()); // // header // - auto header = GLabel::construct(background.ptr()); + auto header = GUI::Label::construct(background.ptr()); header->set_font(Font::default_bold_font()); header->set_text("Welcome to Serenity"); header->set_text_alignment(TextAlignment::CenterLeft); - header->set_size_policy(SizePolicy::Fill, SizePolicy::Fixed); + header->set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed); header->set_preferred_size(0, 30); // // main section // - auto main_section = GWidget::construct(background.ptr()); - main_section->set_layout(make()); + auto main_section = GUI::Widget::construct(background.ptr()); + main_section->set_layout(make()); main_section->layout()->set_margins({ 0, 0, 0, 0 }); main_section->layout()->set_spacing(8); - main_section->set_size_policy(SizePolicy::Fill, SizePolicy::Fill); + main_section->set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fill); - auto menu = GWidget::construct(main_section.ptr()); - menu->set_layout(make()); + auto menu = GUI::Widget::construct(main_section.ptr()); + menu->set_layout(make()); menu->layout()->set_margins({ 0, 0, 0, 0 }); menu->layout()->set_spacing(8); - menu->set_size_policy(SizePolicy::Fixed, SizePolicy::Fill); + menu->set_size_policy(GUI::SizePolicy::Fixed, GUI::SizePolicy::Fill); menu->set_preferred_size(200, 0); - auto stack = GStackWidget::construct(main_section); - stack->set_size_policy(SizePolicy::Fill, SizePolicy::Fill); + auto stack = GUI::StackWidget::construct(main_section); + stack->set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fill); for (auto& page : pages) { - auto content = GWidget::construct(stack.ptr()); - content->set_layout(make()); + auto content = GUI::Widget::construct(stack.ptr()); + content->set_layout(make()); content->layout()->set_margins({ 0, 0, 0, 0 }); content->layout()->set_spacing(8); - content->set_size_policy(SizePolicy::Fill, SizePolicy::Fill); + content->set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fill); - auto content_title = GLabel::construct(content); + auto content_title = GUI::Label::construct(content); content_title->set_font(Font::default_bold_font()); content_title->set_text(page.title); content_title->set_text_alignment(TextAlignment::CenterLeft); - content_title->set_size_policy(SizePolicy::Fill, SizePolicy::Fixed); + content_title->set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed); content_title->set_preferred_size(0, 10); for (auto& paragraph : page.content) { @@ -159,11 +159,11 @@ int main(int argc, char** argv) content_text->wrap_and_set_height(); } - auto menu_option = GButton::construct(menu); + auto menu_option = GUI::Button::construct(menu); menu_option->set_font(Font::default_font()); menu_option->set_text(page.menu_name); menu_option->set_text_alignment(TextAlignment::CenterLeft); - menu_option->set_size_policy(SizePolicy::Fill, SizePolicy::Fixed); + menu_option->set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed); menu_option->set_preferred_size(0, 20); menu_option->on_click = [content = content.ptr(), &stack](auto&) { stack->set_active_widget(content); diff --git a/Demos/Fire/Fire.cpp b/Demos/Fire/Fire.cpp index bf2a0660124..34ce85efcb1 100644 --- a/Demos/Fire/Fire.cpp +++ b/Demos/Fire/Fire.cpp @@ -89,22 +89,22 @@ static int my_rand(void) /* * Fire Widget */ -class Fire : public GWidget { +class Fire : public GUI::Widget { C_OBJECT(Fire) public: virtual ~Fire() override; - void set_stat_label(GLabel* l) { stats = l; }; + void set_stat_label(RefPtr l) { stats = l; }; private: - explicit Fire(GWidget* parent = nullptr); + explicit Fire(GUI::Widget* parent = nullptr); RefPtr bitmap; - GLabel* stats; + RefPtr stats; - virtual void paint_event(GPaintEvent&) override; + virtual void paint_event(GUI::PaintEvent&) override; virtual void timer_event(Core::TimerEvent&) override; - virtual void mousedown_event(GMouseEvent& event) override; - virtual void mousemove_event(GMouseEvent& event) override; - virtual void mouseup_event(GMouseEvent& event) override; + virtual void mousedown_event(GUI::MouseEvent& event) override; + virtual void mousemove_event(GUI::MouseEvent& event) override; + virtual void mouseup_event(GUI::MouseEvent& event) override; bool dragging; int timeAvg; @@ -112,8 +112,8 @@ private: int phase; }; -Fire::Fire(GWidget* parent) - : GWidget(parent) +Fire::Fire(GUI::Widget* parent) + : GUI::Widget(parent) { bitmap = GraphicsBitmap::create(GraphicsBitmap::Format::Indexed8, { 320, 200 }); @@ -146,12 +146,12 @@ Fire::~Fire() { } -void Fire::paint_event(GPaintEvent& event) +void Fire::paint_event(GUI::PaintEvent& event) { Core::ElapsedTimer timer; timer.start(); - GPainter painter(*this); + GUI::Painter painter(*this); painter.add_clip_rect(event.rect()); /* Blit it! */ @@ -201,16 +201,16 @@ void Fire::timer_event(Core::TimerEvent&) /* * Mouse handling events */ -void Fire::mousedown_event(GMouseEvent& event) +void Fire::mousedown_event(GUI::MouseEvent& event) { - if (event.button() == GMouseButton::Left) + if (event.button() == GUI::MouseButton::Left) dragging = true; - return GWidget::mousedown_event(event); + return GUI::Widget::mousedown_event(event); } /* FIXME: needs to account for the size of the window rect */ -void Fire::mousemove_event(GMouseEvent& event) +void Fire::mousemove_event(GUI::MouseEvent& event) { if (dragging) { if (event.y() >= 2 && event.y() < 398 && event.x() <= 638) { @@ -223,15 +223,15 @@ void Fire::mousemove_event(GMouseEvent& event) } } - return GWidget::mousemove_event(event); + return GUI::Widget::mousemove_event(event); } -void Fire::mouseup_event(GMouseEvent& event) +void Fire::mouseup_event(GUI::MouseEvent& event) { - if (event.button() == GMouseButton::Left) + if (event.button() == GUI::MouseButton::Left) dragging = false; - return GWidget::mouseup_event(event); + return GUI::Widget::mouseup_event(event); } /* @@ -239,9 +239,9 @@ void Fire::mouseup_event(GMouseEvent& event) */ int main(int argc, char** argv) { - GApplication app(argc, argv); + GUI::Application app(argc, argv); - auto window = GWindow::construct(); + auto window = GUI::Window::construct(); window->set_double_buffering_enabled(false); window->set_title("Fire"); window->set_resizable(false); @@ -250,7 +250,7 @@ int main(int argc, char** argv) auto fire = Fire::construct(); window->set_main_widget(fire); - auto time = GLabel::construct(fire); + auto time = GUI::Label::construct(fire); time->set_relative_rect({ 0, 4, 40, 10 }); time->move_by({ window->width() - time->width(), 0 }); time->set_foreground_color(Color::from_rgb(0x444444)); diff --git a/Demos/HelloWorld/main.cpp b/Demos/HelloWorld/main.cpp index 84b8d460f99..1e65f0d413f 100644 --- a/Demos/HelloWorld/main.cpp +++ b/Demos/HelloWorld/main.cpp @@ -33,27 +33,27 @@ int main(int argc, char** argv) { - GApplication app(argc, argv); + GUI::Application app(argc, argv); - auto window = GWindow::construct(); + auto window = GUI::Window::construct(); window->set_rect(100, 100, 240, 160); window->set_title("Hello World!"); - auto main_widget = GWidget::construct(); + auto main_widget = GUI::Widget::construct(); window->set_main_widget(main_widget); main_widget->set_fill_with_background_color(true); main_widget->set_background_color(Color::White); - main_widget->set_layout(make()); + main_widget->set_layout(make()); main_widget->layout()->set_margins({ 4, 4, 4, 4 }); - auto label = GLabel::construct(main_widget); + auto label = GUI::Label::construct(main_widget); label->set_text("Hello\nWorld!"); - auto button = GButton::construct(main_widget); + auto button = GUI::Button::construct(main_widget); button->set_text("Good-bye"); - button->set_size_policy(SizePolicy::Fill, SizePolicy::Fixed); + button->set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed); button->set_preferred_size(0, 20); - button->on_click = [&](GButton&) { + button->on_click = [&](GUI::Button&) { app.quit(); }; diff --git a/Demos/HelloWorld2/HelloWorld2.frm b/Demos/HelloWorld2/HelloWorld2.frm index 932975dfe45..f4ae8251e56 100644 --- a/Demos/HelloWorld2/HelloWorld2.frm +++ b/Demos/HelloWorld2/HelloWorld2.frm @@ -1 +1 @@ -{"name":"HelloWorld2","widgets":[{"name":"w1","tooltip":null,"backcolor":"#d4d0c8ff","forecolor":"#000000ff","text":"Hello world!","class":"GLabel","autofill":true,"enabled":true,"visible":true,"x":5,"height":26,"y":5,"width":121},{"name":"w2","tooltip":null,"backcolor":"#d4d0c8ff","forecolor":"#000000ff","text":"Lefty","class":"GButton","autofill":false,"enabled":true,"visible":true,"x":5,"height":26,"y":40,"width":51},{"name":"w3","tooltip":null,"backcolor":"#d4d0c8ff","forecolor":"#000000ff","text":"Righty","class":"GButton","autofill":false,"enabled":true,"visible":true,"x":80,"height":26,"y":40,"width":51},{"name":"w4","enabled":true,"forecolor":"#000000ff","checked":false,"autofill":false,"x":150,"tooltip":null,"height":26,"width":91,"y":5,"class":"GCheckBox","text":"Awesome","backcolor":"#d4d0c8ff","visible":true},{"name":"w5","enabled":true,"forecolor":"#000000ff","checked":false,"autofill":false,"x":150,"tooltip":null,"height":26,"width":51,"y":30,"class":"GCheckBox","text":"Cool","backcolor":"#d4d0c8ff","visible":true}]} +{"name":"HelloWorld2","widgets":[{"name":"w1","tooltip":null,"backcolor":"#d4d0c8ff","forecolor":"#000000ff","text":"Hello world!","class":"GUI::Label","autofill":true,"enabled":true,"visible":true,"x":5,"height":26,"y":5,"width":121},{"name":"w2","tooltip":null,"backcolor":"#d4d0c8ff","forecolor":"#000000ff","text":"Lefty","class":"GUI::Button","autofill":false,"enabled":true,"visible":true,"x":5,"height":26,"y":40,"width":51},{"name":"w3","tooltip":null,"backcolor":"#d4d0c8ff","forecolor":"#000000ff","text":"Righty","class":"GUI::Button","autofill":false,"enabled":true,"visible":true,"x":80,"height":26,"y":40,"width":51},{"name":"w4","enabled":true,"forecolor":"#000000ff","checked":false,"autofill":false,"x":150,"tooltip":null,"height":26,"width":91,"y":5,"class":"GUI::CheckBox","text":"Awesome","backcolor":"#d4d0c8ff","visible":true},{"name":"w5","enabled":true,"forecolor":"#000000ff","checked":false,"autofill":false,"x":150,"tooltip":null,"height":26,"width":51,"y":30,"class":"GUI::CheckBox","text":"Cool","backcolor":"#d4d0c8ff","visible":true}]} diff --git a/Demos/HelloWorld2/main.cpp b/Demos/HelloWorld2/main.cpp index c523d872b29..ba0a9a98ef3 100644 --- a/Demos/HelloWorld2/main.cpp +++ b/Demos/HelloWorld2/main.cpp @@ -34,9 +34,9 @@ int main(int argc, char** argv) { - GApplication app(argc, argv); + GUI::Application app(argc, argv); - auto window = GWindow::construct(); + auto window = GUI::Window::construct(); window->set_rect(100, 100, 240, 160); window->set_title("Hello World!"); diff --git a/Demos/WidgetGallery/main.cpp b/Demos/WidgetGallery/main.cpp index 3c260af394e..bc5a85f20bd 100644 --- a/Demos/WidgetGallery/main.cpp +++ b/Demos/WidgetGallery/main.cpp @@ -42,84 +42,84 @@ int main(int argc, char** argv) { - GApplication app(argc, argv); + GUI::Application app(argc, argv); - auto window = GWindow::construct(); + auto window = GUI::Window::construct(); window->set_rect(100, 100, 320, 620); window->set_title("Widget Gallery"); - auto main_widget = GWidget::construct(); + auto main_widget = GUI::Widget::construct(); window->set_main_widget(main_widget); main_widget->set_fill_with_background_color(true); - main_widget->set_layout(make()); + main_widget->set_layout(make()); main_widget->layout()->set_margins({ 4, 4, 4, 4 }); - auto checkbox1 = GCheckBox::construct("GCheckBox 1", main_widget); + auto checkbox1 = GUI::CheckBox::construct("GCheckBox 1", main_widget); (void)checkbox1; - auto checkbox2 = GCheckBox::construct("GCheckBox 2", main_widget); + auto checkbox2 = GUI::CheckBox::construct("GCheckBox 2", main_widget); checkbox2->set_enabled(false); - auto radio1 = GRadioButton::construct("GRadioButton 1", main_widget); + auto radio1 = GUI::RadioButton::construct("GRadioButton 1", main_widget); (void)radio1; - auto radio2 = GRadioButton::construct("GRadioButton 2", main_widget); + auto radio2 = GUI::RadioButton::construct("GRadioButton 2", main_widget); radio2->set_enabled(false); - auto button1 = GButton::construct("GButton 1", main_widget); + auto button1 = GUI::Button::construct("GButton 1", main_widget); (void)button1; - auto button2 = GButton::construct("GButton 2", main_widget); + auto button2 = GUI::Button::construct("GButton 2", main_widget); button2->set_enabled(false); - auto progress1 = GProgressBar::construct(main_widget); + auto progress1 = GUI::ProgressBar::construct(main_widget); auto timer = Core::Timer::construct(100, [&] { progress1->set_value(progress1->value() + 1); if (progress1->value() == progress1->max()) progress1->set_value(progress1->min()); }); - auto label1 = GLabel::construct("GLabel 1", main_widget); + auto label1 = GUI::Label::construct("GLabel 1", main_widget); (void)label1; - auto label2 = GLabel::construct("GLabel 2", main_widget); + auto label2 = GUI::Label::construct("GLabel 2", main_widget); label2->set_enabled(false); - auto textbox1 = GTextBox::construct(main_widget); + auto textbox1 = GUI::TextBox::construct(main_widget); textbox1->set_text("GTextBox 1"); - auto textbox2 = GTextBox::construct(main_widget); + auto textbox2 = GUI::TextBox::construct(main_widget); textbox2->set_text("GTextBox 2"); textbox2->set_enabled(false); - auto spinbox1 = GSpinBox::construct(main_widget); + auto spinbox1 = GUI::SpinBox::construct(main_widget); (void)spinbox1; - auto spinbox2 = GSpinBox::construct(main_widget); + auto spinbox2 = GUI::SpinBox::construct(main_widget); spinbox2->set_enabled(false); - auto vertical_slider_container = GWidget::construct(main_widget.ptr()); - vertical_slider_container->set_size_policy(SizePolicy::Fill, SizePolicy::Fixed); + auto vertical_slider_container = GUI::Widget::construct(main_widget.ptr()); + vertical_slider_container->set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed); vertical_slider_container->set_preferred_size(0, 100); - vertical_slider_container->set_layout(make()); - auto vslider1 = GSlider::construct(Orientation::Vertical, vertical_slider_container); + vertical_slider_container->set_layout(make()); + auto vslider1 = GUI::Slider::construct(Orientation::Vertical, vertical_slider_container); (void)vslider1; - auto vslider2 = GSlider::construct(Orientation::Vertical, vertical_slider_container); + auto vslider2 = GUI::Slider::construct(Orientation::Vertical, vertical_slider_container); vslider2->set_enabled(false); - auto vslider3 = GSlider::construct(Orientation::Vertical, vertical_slider_container); + auto vslider3 = GUI::Slider::construct(Orientation::Vertical, vertical_slider_container); vslider3->set_max(5); - vslider3->set_knob_size_mode(GSlider::KnobSizeMode::Proportional); + vslider3->set_knob_size_mode(GUI::Slider::KnobSizeMode::Proportional); - auto slider1 = GSlider::construct(Orientation::Horizontal, main_widget); + auto slider1 = GUI::Slider::construct(Orientation::Horizontal, main_widget); (void)slider1; - auto slider2 = GSlider::construct(Orientation::Horizontal, main_widget); + auto slider2 = GUI::Slider::construct(Orientation::Horizontal, main_widget); slider2->set_enabled(false); - auto slider3 = GSlider::construct(Orientation::Horizontal, main_widget); + auto slider3 = GUI::Slider::construct(Orientation::Horizontal, main_widget); slider3->set_max(5); - slider3->set_knob_size_mode(GSlider::KnobSizeMode::Proportional); + slider3->set_knob_size_mode(GUI::Slider::KnobSizeMode::Proportional); - auto scrollbar1 = GScrollBar::construct(Orientation::Horizontal, main_widget); - scrollbar1->set_size_policy(SizePolicy::Fill, SizePolicy::Fixed); + auto scrollbar1 = GUI::ScrollBar::construct(Orientation::Horizontal, main_widget); + scrollbar1->set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed); scrollbar1->set_preferred_size(0, 16); scrollbar1->set_min(0); scrollbar1->set_max(100); scrollbar1->set_value(50); - auto scrollbar2 = GScrollBar::construct(Orientation::Horizontal, main_widget); - scrollbar2->set_size_policy(SizePolicy::Fill, SizePolicy::Fixed); + auto scrollbar2 = GUI::ScrollBar::construct(Orientation::Horizontal, main_widget); + scrollbar2->set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed); scrollbar2->set_preferred_size(0, 16); scrollbar2->set_enabled(false); diff --git a/DevTools/FormCompiler/main.cpp b/DevTools/FormCompiler/main.cpp index 22c793bce63..5b5c1fd34ea 100644 --- a/DevTools/FormCompiler/main.cpp +++ b/DevTools/FormCompiler/main.cpp @@ -66,11 +66,15 @@ int main(int argc, char** argv) widgets.as_array().for_each([&](auto& value) { const JsonObject& widget_object = value.as_object(); auto class_name = widget_object.get("class").to_string(); - dbg() << "#include "; + StringBuilder builder; + builder.append('G'); + auto parts = class_name.split(':'); + builder.append(parts.last()); + dbg() << "#include "; }); dbg() << "struct UI_" << name << " {"; - dbg() << " RefPtr main_widget;"; + dbg() << " RefPtr main_widget;"; widgets.as_array().for_each([&](auto& value) { ASSERT(value.is_object()); @@ -87,7 +91,7 @@ int main(int argc, char** argv) dbg() << "UI_" << name << "::UI_" << name << "()"; dbg() << "{"; - dbg() << " main_widget = GWidget::construct(nullptr);"; + dbg() << " main_widget = GUI::Widget::construct(nullptr);"; dbg() << " main_widget->set_fill_with_background_color(true);"; widgets.as_array().for_each([&](auto& value) { diff --git a/DevTools/HackStudio/CursorTool.cpp b/DevTools/HackStudio/CursorTool.cpp index 7c5a75a9c0b..bb298c6e1d5 100644 --- a/DevTools/HackStudio/CursorTool.cpp +++ b/DevTools/HackStudio/CursorTool.cpp @@ -30,13 +30,13 @@ #include "WidgetTreeModel.h" #include -void CursorTool::on_mousedown(GMouseEvent& event) +void CursorTool::on_mousedown(GUI::MouseEvent& event) { dbg() << "CursorTool::on_mousedown"; auto& form_widget = m_editor.form_widget(); - auto result = form_widget.hit_test(event.position(), GWidget::ShouldRespectGreediness::No); + auto result = form_widget.hit_test(event.position(), GUI::Widget::ShouldRespectGreediness::No); - if (event.button() == GMouseButton::Left) { + if (event.button() == GUI::MouseButton::Left) { if (result.widget && result.widget != &form_widget) { if (event.modifiers() & Mod_Ctrl) { m_editor.selection().toggle(*result.widget); @@ -65,12 +65,12 @@ void CursorTool::on_mousedown(GMouseEvent& event) } } -void CursorTool::on_mouseup(GMouseEvent& event) +void CursorTool::on_mouseup(GUI::MouseEvent& event) { dbg() << "CursorTool::on_mouseup"; - if (event.button() == GMouseButton::Left) { + if (event.button() == GUI::MouseButton::Left) { auto& form_widget = m_editor.form_widget(); - auto result = form_widget.hit_test(event.position(), GWidget::ShouldRespectGreediness::No); + auto result = form_widget.hit_test(event.position(), GUI::Widget::ShouldRespectGreediness::No); if (!m_dragging && !(event.modifiers() & Mod_Ctrl)) { if (result.widget && result.widget != &form_widget) { m_editor.selection().set(*result.widget); @@ -84,7 +84,7 @@ void CursorTool::on_mouseup(GMouseEvent& event) } } -void CursorTool::on_mousemove(GMouseEvent& event) +void CursorTool::on_mousemove(GUI::MouseEvent& event) { dbg() << "CursorTool::on_mousemove"; auto& form_widget = m_editor.form_widget(); @@ -94,8 +94,8 @@ void CursorTool::on_mousemove(GMouseEvent& event) return; } - if (!m_dragging && event.buttons() & GMouseButton::Left && event.position() != m_drag_origin) { - auto result = form_widget.hit_test(event.position(), GWidget::ShouldRespectGreediness::No); + if (!m_dragging && event.buttons() & GUI::MouseButton::Left && event.position() != m_drag_origin) { + auto result = form_widget.hit_test(event.position(), GUI::Widget::ShouldRespectGreediness::No); if (result.widget && result.widget != &form_widget) { if (!m_editor.selection().contains(*result.widget)) { m_editor.selection().set(*result.widget); @@ -121,7 +121,7 @@ void CursorTool::on_mousemove(GMouseEvent& event) } } -void CursorTool::on_keydown(GKeyEvent& event) +void CursorTool::on_keydown(GUI::KeyEvent& event) { dbg() << "CursorTool::on_keydown"; @@ -175,7 +175,7 @@ Rect CursorTool::rubber_band_rect() const return Rect::from_two_points(m_rubber_band_origin, m_rubber_band_position); } -void CursorTool::on_second_paint(GPainter& painter, GPaintEvent&) +void CursorTool::on_second_paint(GUI::Painter& painter, GUI::PaintEvent&) { if (!m_rubber_banding) return; diff --git a/DevTools/HackStudio/CursorTool.h b/DevTools/HackStudio/CursorTool.h index d9bc7cf7b21..2e31951fb3a 100644 --- a/DevTools/HackStudio/CursorTool.h +++ b/DevTools/HackStudio/CursorTool.h @@ -30,7 +30,9 @@ #include #include -class GWidget; +namespace GUI { +class Widget; +} class CursorTool final : public Tool { public: @@ -42,17 +44,17 @@ public: private: virtual const char* class_name() const override { return "CursorTool"; } - virtual void on_mousedown(GMouseEvent&) override; - virtual void on_mouseup(GMouseEvent&) override; - virtual void on_mousemove(GMouseEvent&) override; - virtual void on_keydown(GKeyEvent&) override; - virtual void on_second_paint(GPainter&, GPaintEvent&) override; + virtual void on_mousedown(GUI::MouseEvent&) override; + virtual void on_mouseup(GUI::MouseEvent&) override; + virtual void on_mousemove(GUI::MouseEvent&) override; + virtual void on_keydown(GUI::KeyEvent&) override; + virtual void on_second_paint(GUI::Painter&, GUI::PaintEvent&) override; void set_rubber_band_position(const Point&); Rect rubber_band_rect() const; Point m_drag_origin; - HashMap m_positions_before_drag; + HashMap m_positions_before_drag; bool m_dragging { false }; bool m_rubber_banding { false }; diff --git a/DevTools/HackStudio/Editor.cpp b/DevTools/HackStudio/Editor.cpp index 82cb12af10f..c034f616525 100644 --- a/DevTools/HackStudio/Editor.cpp +++ b/DevTools/HackStudio/Editor.cpp @@ -43,12 +43,12 @@ //#define EDITOR_DEBUG -Editor::Editor(GWidget* parent) - : GTextEditor(GTextEditor::MultiLine, parent) +Editor::Editor(GUI::Widget* parent) + : TextEditor(GUI::TextEditor::MultiLine, parent) { - m_documentation_tooltip_window = GWindow::construct(); + m_documentation_tooltip_window = GUI::Window::construct(); m_documentation_tooltip_window->set_rect(0, 0, 500, 400); - m_documentation_tooltip_window->set_window_type(GWindowType::Tooltip); + m_documentation_tooltip_window->set_window_type(GUI::WindowType::Tooltip); m_documentation_html_view = HtmlView::construct(nullptr); m_documentation_tooltip_window->set_main_widget(m_documentation_html_view); @@ -72,21 +72,21 @@ void Editor::focusin_event(Core::Event& event) wrapper().set_editor_has_focus({}, true); if (on_focus) on_focus(); - GTextEditor::focusin_event(event); + GUI::TextEditor::focusin_event(event); } void Editor::focusout_event(Core::Event& event) { wrapper().set_editor_has_focus({}, false); - GTextEditor::focusout_event(event); + GUI::TextEditor::focusout_event(event); } -void Editor::paint_event(GPaintEvent& event) +void Editor::paint_event(GUI::PaintEvent& event) { - GTextEditor::paint_event(event); + GUI::TextEditor::paint_event(event); if (is_focused()) { - GPainter painter(*this); + GUI::Painter painter(*this); painter.add_clip_rect(event.rect()); auto rect = frame_inner_rect(); @@ -170,16 +170,16 @@ void Editor::show_documentation_tooltip_if_available(const String& hovered_token m_last_parsed_token = hovered_token; } -void Editor::mousemove_event(GMouseEvent& event) +void Editor::mousemove_event(GUI::MouseEvent& event) { - GTextEditor::mousemove_event(event); + GUI::TextEditor::mousemove_event(event); if (document().spans().is_empty()) return; auto text_position = text_position_at(event.position()); if (!text_position.is_valid()) { - GApplication::the().hide_tooltip(); + GUI::Application::the().hide_tooltip(); return; } @@ -195,7 +195,7 @@ void Editor::mousemove_event(GMouseEvent& event) return; } } - GApplication::the().hide_tooltip(); + GUI::Application::the().hide_tooltip(); } void Editor::highlight_matching_token_pair() @@ -222,8 +222,8 @@ void Editor::highlight_matching_token_pair() }; auto make_buddies = [&](int index0, int index1) { - auto& buddy0 = const_cast(document().spans()[index0]); - auto& buddy1 = const_cast(document().spans()[index1]); + auto& buddy0 = const_cast(document().spans()[index0]); + auto& buddy1 = const_cast(document().spans()[index1]); m_has_brace_buddies = true; m_brace_buddies[0].index = index0; m_brace_buddies[1].index = index1; @@ -248,7 +248,7 @@ void Editor::highlight_matching_token_pair() }; for (int i = 0; i < document().spans().size(); ++i) { - auto& span = const_cast(document().spans().at(i)); + auto& span = const_cast(document().spans().at(i)); auto token_type = (CppToken::Type)((uintptr_t)span.data); for (auto& pair : pairs) { diff --git a/DevTools/HackStudio/Editor.h b/DevTools/HackStudio/Editor.h index f57b8adcab4..9c645b16fb9 100644 --- a/DevTools/HackStudio/Editor.h +++ b/DevTools/HackStudio/Editor.h @@ -31,7 +31,7 @@ class EditorWrapper; class HtmlView; -class Editor final : public GTextEditor { +class Editor final : public GUI::TextEditor { C_OBJECT(Editor) public: virtual ~Editor() override; @@ -46,22 +46,22 @@ public: private: virtual void focusin_event(Core::Event&) override; virtual void focusout_event(Core::Event&) override; - virtual void paint_event(GPaintEvent&) override; - virtual void mousemove_event(GMouseEvent&) override; + virtual void paint_event(GUI::PaintEvent&) override; + virtual void mousemove_event(GUI::MouseEvent&) override; virtual void cursor_did_change() override; void show_documentation_tooltip_if_available(const String&, const Point& screen_location); void highlight_matching_token_pair(); - explicit Editor(GWidget* parent); + explicit Editor(GUI::Widget* parent); - RefPtr m_documentation_tooltip_window; + RefPtr m_documentation_tooltip_window; RefPtr m_documentation_html_view; String m_last_parsed_token; struct BuddySpan { int index { -1 }; - GTextDocumentSpan span_backup; + GUI::TextDocumentSpan span_backup; }; bool m_has_brace_buddies { false }; diff --git a/DevTools/HackStudio/EditorWrapper.cpp b/DevTools/HackStudio/EditorWrapper.cpp index c9c920c27e0..d767b8ea64d 100644 --- a/DevTools/HackStudio/EditorWrapper.cpp +++ b/DevTools/HackStudio/EditorWrapper.cpp @@ -33,26 +33,26 @@ extern RefPtr g_current_editor_wrapper; -EditorWrapper::EditorWrapper(GWidget* parent) - : GWidget(parent) +EditorWrapper::EditorWrapper(GUI::Widget* parent) + : GUI::Widget(parent) { - set_layout(make()); + set_layout(make()); - auto label_wrapper = GWidget::construct(this); - label_wrapper->set_size_policy(SizePolicy::Fill, SizePolicy::Fixed); + auto label_wrapper = GUI::Widget::construct(this); + label_wrapper->set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed); label_wrapper->set_preferred_size(0, 14); label_wrapper->set_fill_with_background_color(true); - label_wrapper->set_layout(make()); + label_wrapper->set_layout(make()); label_wrapper->layout()->set_margins({ 2, 0, 2, 0 }); - m_filename_label = GLabel::construct("(Untitled)", label_wrapper); + m_filename_label = GUI::Label::construct("(Untitled)", label_wrapper); m_filename_label->set_text_alignment(TextAlignment::CenterLeft); - m_filename_label->set_size_policy(SizePolicy::Fill, SizePolicy::Fixed); + m_filename_label->set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed); m_filename_label->set_preferred_size(0, 14); - m_cursor_label = GLabel::construct("(Cursor)", label_wrapper); + m_cursor_label = GUI::Label::construct("(Cursor)", label_wrapper); m_cursor_label->set_text_alignment(TextAlignment::CenterRight); - m_cursor_label->set_size_policy(SizePolicy::Fill, SizePolicy::Fixed); + m_cursor_label->set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed); m_cursor_label->set_preferred_size(0, 14); m_editor = Editor::construct(this); diff --git a/DevTools/HackStudio/EditorWrapper.h b/DevTools/HackStudio/EditorWrapper.h index 89763f578f8..0fa549d0dc9 100644 --- a/DevTools/HackStudio/EditorWrapper.h +++ b/DevTools/HackStudio/EditorWrapper.h @@ -28,10 +28,13 @@ #include -class GLabel; +namespace GUI { +class Label; +} + class Editor; -class EditorWrapper : public GWidget { +class EditorWrapper : public GUI::Widget { C_OBJECT(EditorWrapper) public: virtual ~EditorWrapper() override; @@ -39,15 +42,15 @@ public: Editor& editor() { return *m_editor; } const Editor& editor() const { return *m_editor; } - GLabel& filename_label() { return *m_filename_label; } + GUI::Label& filename_label() { return *m_filename_label; } void set_editor_has_focus(Badge, bool); private: - explicit EditorWrapper(GWidget* parent = nullptr); + explicit EditorWrapper(GUI::Widget* parent = nullptr); - RefPtr m_filename_label; - RefPtr m_cursor_label; + RefPtr m_filename_label; + RefPtr m_cursor_label; RefPtr m_editor; }; diff --git a/DevTools/HackStudio/FindInFilesWidget.cpp b/DevTools/HackStudio/FindInFilesWidget.cpp index 1c70410f00a..ad8d04235f9 100644 --- a/DevTools/HackStudio/FindInFilesWidget.cpp +++ b/DevTools/HackStudio/FindInFilesWidget.cpp @@ -32,17 +32,17 @@ #include #include -extern GTextEditor& current_editor(); +extern GUI::TextEditor& current_editor(); extern void open_file(const String&); extern OwnPtr g_project; struct Match { String filename; - GTextRange range; + GUI::TextRange range; String text; }; -class SearchResultsModel final : public GModel { +class SearchResultsModel final : public GUI::Model { public: enum Column { Filename, @@ -56,8 +56,8 @@ public: { } - virtual int row_count(const GModelIndex& = GModelIndex()) const override { return m_matches.size(); } - virtual int column_count(const GModelIndex& = GModelIndex()) const override { return Column::__Count; } + virtual int row_count(const GUI::ModelIndex& = GUI::ModelIndex()) const override { return m_matches.size(); } + virtual int column_count(const GUI::ModelIndex& = GUI::ModelIndex()) const override { return Column::__Count; } virtual String column_name(int column) const override { @@ -73,7 +73,7 @@ public: } } - virtual GVariant data(const GModelIndex& index, Role role = Role::Display) const override + virtual GUI::Variant data(const GUI::ModelIndex& index, Role role = Role::Display) const override { if (role == Role::Display) { auto& match = m_matches.at(index.row()); @@ -98,7 +98,7 @@ public: } virtual void update() override {} - virtual GModelIndex index(int row, int column = 0, const GModelIndex& = GModelIndex()) const override { return create_index(row, column, &m_matches.at(row)); } + virtual GUI::ModelIndex index(int row, int column = 0, const GUI::ModelIndex& = GUI::ModelIndex()) const override { return create_index(row, column, &m_matches.at(row)); } private: Vector m_matches; @@ -127,18 +127,18 @@ static RefPtr find_in_files(const StringView& text) return adopt(*new SearchResultsModel(move(matches))); } -FindInFilesWidget::FindInFilesWidget(GWidget* parent) - : GWidget(parent) +FindInFilesWidget::FindInFilesWidget(GUI::Widget* parent) + : GUI::Widget(parent) { - set_layout(make()); - m_textbox = GTextBox::construct(this); - m_textbox->set_size_policy(SizePolicy::Fill, SizePolicy::Fixed); + set_layout(make()); + m_textbox = GUI::TextBox::construct(this); + m_textbox->set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed); m_textbox->set_preferred_size(0, 20); - m_button = GButton::construct("Find in files", this); - m_button->set_size_policy(SizePolicy::Fill, SizePolicy::Fixed); + m_button = GUI::Button::construct("Find in files", this); + m_button->set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed); m_button->set_preferred_size(0, 20); - m_result_view = GTableView::construct(this); + m_result_view = GUI::TableView::construct(this); m_result_view->set_size_columns_to_fit_content(true); m_result_view->on_activation = [](auto& index) { diff --git a/DevTools/HackStudio/FindInFilesWidget.h b/DevTools/HackStudio/FindInFilesWidget.h index 8085372ccf5..5f5d84b9191 100644 --- a/DevTools/HackStudio/FindInFilesWidget.h +++ b/DevTools/HackStudio/FindInFilesWidget.h @@ -28,11 +28,13 @@ #include -class GButton; -class GTableView; -class GTextBox; +namespace GUI { +class Button; +class TableView; +class TextBox; +} -class FindInFilesWidget final : public GWidget { +class FindInFilesWidget final : public GUI::Widget { C_OBJECT(FindInFilesWidget) public: virtual ~FindInFilesWidget() override {} @@ -40,9 +42,9 @@ public: void focus_textbox_and_select_all(); private: - explicit FindInFilesWidget(GWidget* parent); + explicit FindInFilesWidget(GUI::Widget* parent); - RefPtr m_textbox; - RefPtr m_button; - RefPtr m_result_view; + RefPtr m_textbox; + RefPtr m_button; + RefPtr m_result_view; }; diff --git a/DevTools/HackStudio/FormEditorWidget.cpp b/DevTools/HackStudio/FormEditorWidget.cpp index 8ffbc188162..97c1502cb4a 100644 --- a/DevTools/HackStudio/FormEditorWidget.cpp +++ b/DevTools/HackStudio/FormEditorWidget.cpp @@ -30,8 +30,8 @@ #include "WidgetTreeModel.h" #include -FormEditorWidget::FormEditorWidget(GWidget* parent) - : GScrollableWidget(parent) +FormEditorWidget::FormEditorWidget(GUI::Widget* parent) + : ScrollableWidget(parent) , m_tool(make(*this)) { set_fill_with_background_color(true); @@ -49,11 +49,11 @@ FormEditorWidget::~FormEditorWidget() { } -void FormEditorWidget::paint_event(GPaintEvent& event) +void FormEditorWidget::paint_event(GUI::PaintEvent& event) { - GFrame::paint_event(event); + GUI::Frame::paint_event(event); - GPainter painter(*this); + GUI::Painter painter(*this); painter.add_clip_rect(event.rect()); } diff --git a/DevTools/HackStudio/FormEditorWidget.h b/DevTools/HackStudio/FormEditorWidget.h index 6f2f4c0ea31..021905c6a50 100644 --- a/DevTools/HackStudio/FormEditorWidget.h +++ b/DevTools/HackStudio/FormEditorWidget.h @@ -32,7 +32,7 @@ class FormWidget; class Tool; class WidgetTreeModel; -class FormEditorWidget final : public GScrollableWidget { +class FormEditorWidget final : public GUI::ScrollableWidget { C_OBJECT(FormEditorWidget) public: virtual ~FormEditorWidget() override; @@ -49,8 +49,8 @@ public: class WidgetSelection { public: - Function on_remove; - Function on_add; + Function on_remove; + Function on_add; Function on_clear; void enable_hooks() { m_hooks_enabled = true; } @@ -61,12 +61,12 @@ public: return m_widgets.is_empty(); } - bool contains(GWidget& widget) const + bool contains(GUI::Widget& widget) const { return m_widgets.contains(&widget); } - void toggle(GWidget& widget) + void toggle(GUI::Widget& widget) { if (contains(widget)) remove(widget); @@ -74,13 +74,13 @@ public: add(widget); } - void set(GWidget& widget) + void set(GUI::Widget& widget) { clear(); add(widget); } - void remove(GWidget& widget) + void remove(GUI::Widget& widget) { ASSERT(m_widgets.contains(&widget)); m_widgets.remove(&widget); @@ -88,7 +88,7 @@ public: on_remove(widget); } - void add(GWidget& widget) + void add(GUI::Widget& widget) { m_widgets.set(&widget); if (m_hooks_enabled && on_add) @@ -114,16 +114,16 @@ public: WidgetSelection() {} private: - HashTable m_widgets; + HashTable m_widgets; bool m_hooks_enabled { true }; }; WidgetSelection& selection() { return m_selection; } private: - virtual void paint_event(GPaintEvent&) override; + virtual void paint_event(GUI::PaintEvent&) override; - explicit FormEditorWidget(GWidget* parent); + explicit FormEditorWidget(GUI::Widget* parent); RefPtr m_form_widget; RefPtr m_widget_tree_model; diff --git a/DevTools/HackStudio/FormWidget.cpp b/DevTools/HackStudio/FormWidget.cpp index 55e7b1a6dcb..63503903976 100644 --- a/DevTools/HackStudio/FormWidget.cpp +++ b/DevTools/HackStudio/FormWidget.cpp @@ -30,7 +30,7 @@ #include FormWidget::FormWidget(FormEditorWidget& parent) - : GWidget(&parent) + : GUI::Widget(&parent) { set_fill_with_background_color(true); set_relative_rect(5, 5, 400, 300); @@ -52,9 +52,9 @@ const FormEditorWidget& FormWidget::editor() const return static_cast(*parent()); } -void FormWidget::paint_event(GPaintEvent& event) +void FormWidget::paint_event(GUI::PaintEvent& event) { - GPainter painter(*this); + GUI::Painter painter(*this); painter.add_clip_rect(event.rect()); for (int y = 0; y < height(); y += m_grid_size) { @@ -64,9 +64,9 @@ void FormWidget::paint_event(GPaintEvent& event) } } -void FormWidget::second_paint_event(GPaintEvent& event) +void FormWidget::second_paint_event(GUI::PaintEvent& event) { - GPainter painter(*this); + GUI::Painter painter(*this); painter.add_clip_rect(event.rect()); if (!editor().selection().is_empty()) { @@ -81,22 +81,22 @@ void FormWidget::second_paint_event(GPaintEvent& event) editor().tool().on_second_paint(painter, event); } -void FormWidget::mousedown_event(GMouseEvent& event) +void FormWidget::mousedown_event(GUI::MouseEvent& event) { editor().tool().on_mousedown(event); } -void FormWidget::mouseup_event(GMouseEvent& event) +void FormWidget::mouseup_event(GUI::MouseEvent& event) { editor().tool().on_mouseup(event); } -void FormWidget::mousemove_event(GMouseEvent& event) +void FormWidget::mousemove_event(GUI::MouseEvent& event) { editor().tool().on_mousemove(event); } -void FormWidget::keydown_event(GKeyEvent& event) +void FormWidget::keydown_event(GUI::KeyEvent& event) { editor().tool().on_keydown(event); } diff --git a/DevTools/HackStudio/FormWidget.h b/DevTools/HackStudio/FormWidget.h index 803c873be84..d8cb050dfc7 100644 --- a/DevTools/HackStudio/FormWidget.h +++ b/DevTools/HackStudio/FormWidget.h @@ -32,7 +32,7 @@ class CursorTool; class FormEditorWidget; -class FormWidget final : public GWidget { +class FormWidget final : public GUI::Widget { C_OBJECT(FormWidget) public: virtual ~FormWidget() override; @@ -46,12 +46,12 @@ public: private: virtual bool accepts_focus() const override { return true; } - virtual void paint_event(GPaintEvent&) override; - virtual void second_paint_event(GPaintEvent&) override; - virtual void mousedown_event(GMouseEvent&) override; - virtual void mouseup_event(GMouseEvent&) override; - virtual void mousemove_event(GMouseEvent&) override; - virtual void keydown_event(GKeyEvent&) override; + virtual void paint_event(GUI::PaintEvent&) override; + virtual void second_paint_event(GUI::PaintEvent&) override; + virtual void mousedown_event(GUI::MouseEvent&) override; + virtual void mouseup_event(GUI::MouseEvent&) override; + virtual void mousemove_event(GUI::MouseEvent&) override; + virtual void keydown_event(GUI::KeyEvent&) override; explicit FormWidget(FormEditorWidget& parent); diff --git a/DevTools/HackStudio/Locator.cpp b/DevTools/HackStudio/Locator.cpp index 888425c80a4..847146da31c 100644 --- a/DevTools/HackStudio/Locator.cpp +++ b/DevTools/HackStudio/Locator.cpp @@ -37,7 +37,7 @@ static RefPtr s_file_icon; static RefPtr s_cplusplus_icon; static RefPtr s_header_icon; -class LocatorSuggestionModel final : public GModel { +class LocatorSuggestionModel final : public GUI::Model { public: explicit LocatorSuggestionModel(Vector&& suggestions) : m_suggestions(move(suggestions)) @@ -49,9 +49,9 @@ public: Name, __Column_Count, }; - virtual int row_count(const GModelIndex& = GModelIndex()) const override { return m_suggestions.size(); } - virtual int column_count(const GModelIndex& = GModelIndex()) const override { return Column::__Column_Count; } - virtual GVariant data(const GModelIndex& index, Role role = Role::Display) const override + virtual int row_count(const GUI::ModelIndex& = GUI::ModelIndex()) const override { return m_suggestions.size(); } + virtual int column_count(const GUI::ModelIndex& = GUI::ModelIndex()) const override { return Column::__Column_Count; } + virtual GUI::Variant data(const GUI::ModelIndex& index, Role role = Role::Display) const override { auto& suggestion = m_suggestions.at(index.row()); if (role == Role::Display) { @@ -73,7 +73,7 @@ private: Vector m_suggestions; }; -class LocatorTextBox final : public GTextBox { +class LocatorTextBox final : public GUI::TextBox { C_OBJECT(LocatorTextBox) public: virtual ~LocatorTextBox() override {} @@ -81,25 +81,25 @@ public: Function on_up; Function on_down; - virtual void keydown_event(GKeyEvent& event) override + virtual void keydown_event(GUI::KeyEvent& event) override { if (event.key() == Key_Up) on_up(); else if (event.key() == Key_Down) on_down(); - GTextBox::keydown_event(event); + GUI::TextBox::keydown_event(event); } private: - LocatorTextBox(GWidget* parent) - : GTextBox(parent) + LocatorTextBox(GUI::Widget* parent) + : GUI::TextBox(parent) { } }; -Locator::Locator(GWidget* parent) - : GWidget(parent) +Locator::Locator(GUI::Widget* parent) + : GUI::Widget(parent) { if (!s_cplusplus_icon) { s_file_icon = GraphicsBitmap::load_from_file("/res/icons/16x16/filetype-unknown.png"); @@ -107,8 +107,8 @@ Locator::Locator(GWidget* parent) s_header_icon = GraphicsBitmap::load_from_file("/res/icons/16x16/filetype-header.png"); } - set_layout(make()); - set_size_policy(SizePolicy::Fill, SizePolicy::Fixed); + set_layout(make()); + set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed); set_preferred_size(0, 20); m_textbox = LocatorTextBox::construct(this); m_textbox->on_change = [this] { @@ -118,7 +118,7 @@ Locator::Locator(GWidget* parent) m_popup_window->hide(); }; m_textbox->on_up = [this] { - GModelIndex new_index = m_suggestion_view->selection().first(); + GUI::ModelIndex new_index = m_suggestion_view->selection().first(); if (new_index.is_valid()) new_index = m_suggestion_view->model()->index(new_index.row() - 1); else @@ -130,7 +130,7 @@ Locator::Locator(GWidget* parent) } }; m_textbox->on_down = [this] { - GModelIndex new_index = m_suggestion_view->selection().first(); + GUI::ModelIndex new_index = m_suggestion_view->selection().first(); if (new_index.is_valid()) new_index = m_suggestion_view->model()->index(new_index.row() + 1); else @@ -149,12 +149,12 @@ Locator::Locator(GWidget* parent) open_suggestion(selected_index); }; - m_popup_window = GWindow::construct(); + m_popup_window = GUI::Window::construct(); // FIXME: This is obviously not a tooltip window, but it's the closest thing to what we want atm. - m_popup_window->set_window_type(GWindowType::Tooltip); + m_popup_window->set_window_type(GUI::WindowType::Tooltip); m_popup_window->set_rect(0, 0, 500, 200); - m_suggestion_view = GTableView::construct(nullptr); + m_suggestion_view = GUI::TableView::construct(nullptr); m_suggestion_view->set_size_columns_to_fit_content(true); m_suggestion_view->set_headers_visible(false); m_popup_window->set_main_widget(m_suggestion_view); @@ -168,10 +168,10 @@ Locator::~Locator() { } -void Locator::open_suggestion(const GModelIndex& index) +void Locator::open_suggestion(const GUI::ModelIndex& index) { auto filename_index = m_suggestion_view->model()->index(index.row(), LocatorSuggestionModel::Column::Name); - auto filename = m_suggestion_view->model()->data(filename_index, GModel::Role::Display).to_string(); + auto filename = m_suggestion_view->model()->data(filename_index, GUI::Model::Role::Display).to_string(); open_file(filename); close(); } diff --git a/DevTools/HackStudio/Locator.h b/DevTools/HackStudio/Locator.h index 041094499ea..5bf04cfc994 100644 --- a/DevTools/HackStudio/Locator.h +++ b/DevTools/HackStudio/Locator.h @@ -28,11 +28,14 @@ #include -class LocatorTextBox; -class GModelIndex; -class GTableView; +namespace GUI { +class ModelIndex; +class TableView; +} -class Locator final : public GWidget { +class LocatorTextBox; + +class Locator final : public GUI::Widget { C_OBJECT(Locator) public: virtual ~Locator() override; @@ -42,11 +45,11 @@ public: private: void update_suggestions(); - void open_suggestion(const GModelIndex&); + void open_suggestion(const GUI::ModelIndex&); - explicit Locator(GWidget* parent); + explicit Locator(GUI::Widget* parent); RefPtr m_textbox; - RefPtr m_popup_window; - RefPtr m_suggestion_view; + RefPtr m_popup_window; + RefPtr m_suggestion_view; }; diff --git a/DevTools/HackStudio/ProcessStateWidget.cpp b/DevTools/HackStudio/ProcessStateWidget.cpp index 7f8f64fa463..6f7f2ab8204 100644 --- a/DevTools/HackStudio/ProcessStateWidget.cpp +++ b/DevTools/HackStudio/ProcessStateWidget.cpp @@ -31,31 +31,31 @@ #include #include -ProcessStateWidget::ProcessStateWidget(GWidget* parent) - : GWidget(parent) +ProcessStateWidget::ProcessStateWidget(GUI::Widget* parent) + : GUI::Widget(parent) { - set_size_policy(SizePolicy::Fill, SizePolicy::Fixed); + set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed); set_preferred_size(0, 20); set_visible(false); - set_layout(make()); + set_layout(make()); - auto pid_label_label = GLabel::construct("Process:", this); + auto pid_label_label = GUI::Label::construct("Process:", this); pid_label_label->set_font(Font::default_bold_font()); - m_pid_label = GLabel::construct("", this); + m_pid_label = GUI::Label::construct("", this); - auto state_label_label = GLabel::construct("State:", this); + auto state_label_label = GUI::Label::construct("State:", this); state_label_label->set_font(Font::default_bold_font()); - m_state_label = GLabel::construct("", this); + m_state_label = GUI::Label::construct("", this); // FIXME: This should show CPU% instead. - auto cpu_label_label = GLabel::construct("Times scheduled:", this); + auto cpu_label_label = GUI::Label::construct("Times scheduled:", this); cpu_label_label->set_font(Font::default_bold_font()); - m_cpu_label = GLabel::construct("", this); + m_cpu_label = GUI::Label::construct("", this); - auto memory_label_label = GLabel::construct("Memory (resident):", this); + auto memory_label_label = GUI::Label::construct("Memory (resident):", this); memory_label_label->set_font(Font::default_bold_font()); - m_memory_label = GLabel::construct("", this); + m_memory_label = GUI::Label::construct("", this); m_timer = Core::Timer::construct(500, [this] { refresh(); diff --git a/DevTools/HackStudio/ProcessStateWidget.h b/DevTools/HackStudio/ProcessStateWidget.h index 423a2a650a9..d2fd7fd7375 100644 --- a/DevTools/HackStudio/ProcessStateWidget.h +++ b/DevTools/HackStudio/ProcessStateWidget.h @@ -31,10 +31,11 @@ namespace Core { class Timer; } +namespace GUI { +class Label; +} -class GLabel; - -class ProcessStateWidget final : public GWidget { +class ProcessStateWidget final : public GUI::Widget { C_OBJECT(ProcessStateWidget) public: virtual ~ProcessStateWidget() override; @@ -42,14 +43,14 @@ public: void set_tty_fd(int); private: - explicit ProcessStateWidget(GWidget* parent); + explicit ProcessStateWidget(GUI::Widget* parent); void refresh(); - RefPtr m_pid_label; - RefPtr m_state_label; - RefPtr m_cpu_label; - RefPtr m_memory_label; + RefPtr m_pid_label; + RefPtr m_state_label; + RefPtr m_cpu_label; + RefPtr m_memory_label; RefPtr m_timer; diff --git a/DevTools/HackStudio/Project.cpp b/DevTools/HackStudio/Project.cpp index 0c6cd386e74..13af7936b24 100644 --- a/DevTools/HackStudio/Project.cpp +++ b/DevTools/HackStudio/Project.cpp @@ -74,14 +74,14 @@ struct Project::ProjectTreeNode : public RefCounted { ProjectTreeNode* parent { nullptr }; }; -class ProjectModel final : public GModel { +class ProjectModel final : public GUI::Model { public: explicit ProjectModel(Project& project) : m_project(project) { } - virtual int row_count(const GModelIndex& index) const override + virtual int row_count(const GUI::ModelIndex& index) const override { if (!index.is_valid()) return 1; @@ -89,12 +89,12 @@ public: return node->children.size(); } - virtual int column_count(const GModelIndex&) const override + virtual int column_count(const GUI::ModelIndex&) const override { return 1; } - virtual GVariant data(const GModelIndex& index, Role role = Role::Display) const override + virtual GUI::Variant data(const GUI::ModelIndex& index, Role role = Role::Display) const override { auto* node = static_cast(index.internal_data()); if (role == Role::Display) { @@ -123,7 +123,7 @@ public: return {}; } - virtual GModelIndex index(int row, int column = 0, const GModelIndex& parent = GModelIndex()) const override + virtual GUI::ModelIndex index(int row, int column = 0, const GUI::ModelIndex& parent = GUI::ModelIndex()) const override { if (!parent.is_valid()) { return create_index(row, column, &m_project.root_node()); @@ -132,7 +132,7 @@ public: return create_index(row, column, node.children.at(row).ptr()); } - GModelIndex parent_index(const GModelIndex& index) const override + GUI::ModelIndex parent_index(const GUI::ModelIndex& index) const override { if (!index.is_valid()) return {}; diff --git a/DevTools/HackStudio/Project.h b/DevTools/HackStudio/Project.h index b02409eebc2..63000301d24 100644 --- a/DevTools/HackStudio/Project.h +++ b/DevTools/HackStudio/Project.h @@ -47,7 +47,7 @@ public: ProjectFile* get_file(const String& filename); - GModel& model() { return *m_model; } + GUI::Model& model() { return *m_model; } template void for_each_text_file(Callback callback) const @@ -67,7 +67,7 @@ private: String m_name; String m_path; - RefPtr m_model; + RefPtr m_model; NonnullRefPtrVector m_files; RefPtr m_root_node; diff --git a/DevTools/HackStudio/ProjectFile.cpp b/DevTools/HackStudio/ProjectFile.cpp index ecc327af1a3..5c65a9fd442 100644 --- a/DevTools/HackStudio/ProjectFile.cpp +++ b/DevTools/HackStudio/ProjectFile.cpp @@ -28,10 +28,10 @@ #include #include -const GTextDocument& ProjectFile::document() const +const GUI::TextDocument& ProjectFile::document() const { if (!m_document) { - m_document = GTextDocument::create(nullptr); + m_document = GUI::TextDocument::create(nullptr); auto file = Core::File::construct(m_name); if (!file->open(Core::File::ReadOnly)) { ASSERT_NOT_REACHED(); diff --git a/DevTools/HackStudio/ProjectFile.h b/DevTools/HackStudio/ProjectFile.h index c285de46565..6ad2052f9c8 100644 --- a/DevTools/HackStudio/ProjectFile.h +++ b/DevTools/HackStudio/ProjectFile.h @@ -41,7 +41,7 @@ public: const String& name() const { return m_name; } - const GTextDocument& document() const; + const GUI::TextDocument& document() const; private: explicit ProjectFile(const String& name) @@ -50,5 +50,5 @@ private: } String m_name; - mutable RefPtr m_document; + mutable RefPtr m_document; }; diff --git a/DevTools/HackStudio/TerminalWrapper.cpp b/DevTools/HackStudio/TerminalWrapper.cpp index af2a0f87d40..e7c5e192f98 100644 --- a/DevTools/HackStudio/TerminalWrapper.cpp +++ b/DevTools/HackStudio/TerminalWrapper.cpp @@ -43,11 +43,11 @@ void TerminalWrapper::run_command(const String& command) { if (m_pid != -1) { - GMessageBox::show( + GUI::MessageBox::show( "A command is already running in this TerminalWrapper", "Can't run command", - GMessageBox::Type::Error, - GMessageBox::InputType::OK, + GUI::MessageBox::Type::Error, + GUI::MessageBox::InputType::OK, window()); return; } @@ -158,10 +158,10 @@ void TerminalWrapper::kill_running_command() (void)killpg(m_pid, SIGTERM); } -TerminalWrapper::TerminalWrapper(GWidget* parent) - : GWidget(parent) +TerminalWrapper::TerminalWrapper(GUI::Widget* parent) + : GUI::Widget(parent) { - set_layout(make()); + set_layout(make()); RefPtr config = Core::ConfigFile::get_for_app("Terminal"); m_terminal_widget = TerminalWidget::construct(-1, false, config); diff --git a/DevTools/HackStudio/TerminalWrapper.h b/DevTools/HackStudio/TerminalWrapper.h index b249440322f..d606da6b1f3 100644 --- a/DevTools/HackStudio/TerminalWrapper.h +++ b/DevTools/HackStudio/TerminalWrapper.h @@ -31,7 +31,7 @@ class ProcessStateWidget; class TerminalWidget; -class TerminalWrapper final : public GWidget { +class TerminalWrapper final : public GUI::Widget { C_OBJECT(TerminalWrapper) public: virtual ~TerminalWrapper() override; @@ -42,7 +42,7 @@ public: Function on_command_exit; private: - explicit TerminalWrapper(GWidget* parent); + explicit TerminalWrapper(GUI::Widget* parent); RefPtr m_process_state_widget; RefPtr m_terminal_widget; diff --git a/DevTools/HackStudio/Tool.h b/DevTools/HackStudio/Tool.h index 650722877da..e181f43458a 100644 --- a/DevTools/HackStudio/Tool.h +++ b/DevTools/HackStudio/Tool.h @@ -29,10 +29,13 @@ #include class FormEditorWidget; -class GKeyEvent; -class GMouseEvent; -class GPaintEvent; -class GPainter; + +namespace GUI { +class KeyEvent; +class MouseEvent; +class PaintEvent; +class Painter; +} class Tool { AK_MAKE_NONCOPYABLE(Tool) @@ -40,11 +43,11 @@ class Tool { public: virtual ~Tool() {} - virtual void on_mousedown(GMouseEvent&) = 0; - virtual void on_mouseup(GMouseEvent&) = 0; - virtual void on_mousemove(GMouseEvent&) = 0; - virtual void on_keydown(GKeyEvent&) = 0; - virtual void on_second_paint(GPainter&, GPaintEvent&) {} + virtual void on_mousedown(GUI::MouseEvent&) = 0; + virtual void on_mouseup(GUI::MouseEvent&) = 0; + virtual void on_mousemove(GUI::MouseEvent&) = 0; + virtual void on_keydown(GUI::KeyEvent&) = 0; + virtual void on_second_paint(GUI::Painter&, GUI::PaintEvent&) {} virtual const char* class_name() const = 0; diff --git a/DevTools/HackStudio/WidgetTool.cpp b/DevTools/HackStudio/WidgetTool.cpp index 73f57deb69f..411a144c488 100644 --- a/DevTools/HackStudio/WidgetTool.cpp +++ b/DevTools/HackStudio/WidgetTool.cpp @@ -27,25 +27,25 @@ #include "WidgetTool.h" #include -void WidgetTool::on_mousedown(GMouseEvent& event) +void WidgetTool::on_mousedown(GUI::MouseEvent& event) { (void)event; dbg() << "WidgetTool::on_mousedown"; } -void WidgetTool::on_mouseup(GMouseEvent& event) +void WidgetTool::on_mouseup(GUI::MouseEvent& event) { (void)event; dbg() << "WidgetTool::on_mouseup"; } -void WidgetTool::on_mousemove(GMouseEvent& event) +void WidgetTool::on_mousemove(GUI::MouseEvent& event) { (void)event; dbg() << "WidgetTool::on_mousemove"; } -void WidgetTool::on_keydown(GKeyEvent& event) +void WidgetTool::on_keydown(GUI::KeyEvent& event) { (void)event; dbg() << "WidgetTool::on_keydown"; diff --git a/DevTools/HackStudio/WidgetTool.h b/DevTools/HackStudio/WidgetTool.h index 3f1990a56ad..72c2099e719 100644 --- a/DevTools/HackStudio/WidgetTool.h +++ b/DevTools/HackStudio/WidgetTool.h @@ -28,11 +28,13 @@ #include "Tool.h" -class GWidgetClassRegistration; +namespace GUI { +class WidgetClassRegistration; +} class WidgetTool final : public Tool { public: - explicit WidgetTool(FormEditorWidget& editor, const GWidgetClassRegistration& meta_class) + explicit WidgetTool(FormEditorWidget& editor, const GUI::WidgetClassRegistration& meta_class) : Tool(editor) , m_meta_class(meta_class) { @@ -41,10 +43,10 @@ public: private: virtual const char* class_name() const override { return "WidgetTool"; } - virtual void on_mousedown(GMouseEvent&) override; - virtual void on_mouseup(GMouseEvent&) override; - virtual void on_mousemove(GMouseEvent&) override; - virtual void on_keydown(GKeyEvent&) override; + virtual void on_mousedown(GUI::MouseEvent&) override; + virtual void on_mouseup(GUI::MouseEvent&) override; + virtual void on_mousemove(GUI::MouseEvent&) override; + virtual void on_keydown(GUI::KeyEvent&) override; - const GWidgetClassRegistration& m_meta_class; + const GUI::WidgetClassRegistration& m_meta_class; }; diff --git a/DevTools/HackStudio/WidgetTreeModel.cpp b/DevTools/HackStudio/WidgetTreeModel.cpp index e90ee4515db..be87bd67d14 100644 --- a/DevTools/HackStudio/WidgetTreeModel.cpp +++ b/DevTools/HackStudio/WidgetTreeModel.cpp @@ -29,7 +29,7 @@ #include #include -WidgetTreeModel::WidgetTreeModel(GWidget& root) +WidgetTreeModel::WidgetTreeModel(GUI::Widget& root) : m_root(root) { m_widget_icon.set_bitmap_for_size(16, GraphicsBitmap::load_from_file("/res/icons/16x16/inspector-object.png")); @@ -39,20 +39,20 @@ WidgetTreeModel::~WidgetTreeModel() { } -GModelIndex WidgetTreeModel::index(int row, int column, const GModelIndex& parent) const +GUI::ModelIndex WidgetTreeModel::index(int row, int column, const GUI::ModelIndex& parent) const { if (!parent.is_valid()) { return create_index(row, column, m_root.ptr()); } - auto& parent_node = *static_cast(parent.internal_data()); + auto& parent_node = *static_cast(parent.internal_data()); return create_index(row, column, parent_node.child_widgets().at(row)); } -GModelIndex WidgetTreeModel::parent_index(const GModelIndex& index) const +GUI::ModelIndex WidgetTreeModel::parent_index(const GUI::ModelIndex& index) const { if (!index.is_valid()) return {}; - auto& widget = *static_cast(index.internal_data()); + auto& widget = *static_cast(index.internal_data()); if (&widget == m_root.ptr()) return {}; @@ -60,7 +60,7 @@ GModelIndex WidgetTreeModel::parent_index(const GModelIndex& index) const return create_index(0, 0, m_root.ptr()); // Walk the grandparent's children to find the index of widget's parent in its parent. - // (This is needed to produce the row number of the GModelIndex corresponding to widget's parent.) + // (This is needed to produce the row number of the GUI::ModelIndex corresponding to widget's parent.) int grandparent_child_index = 0; for (auto& grandparent_child : widget.parent_widget()->parent_widget()->child_widgets()) { if (grandparent_child == widget.parent_widget()) @@ -72,22 +72,22 @@ GModelIndex WidgetTreeModel::parent_index(const GModelIndex& index) const return {}; } -int WidgetTreeModel::row_count(const GModelIndex& index) const +int WidgetTreeModel::row_count(const GUI::ModelIndex& index) const { if (!index.is_valid()) return 1; - auto& widget = *static_cast(index.internal_data()); + auto& widget = *static_cast(index.internal_data()); return widget.child_widgets().size(); } -int WidgetTreeModel::column_count(const GModelIndex&) const +int WidgetTreeModel::column_count(const GUI::ModelIndex&) const { return 1; } -GVariant WidgetTreeModel::data(const GModelIndex& index, Role role) const +GUI::Variant WidgetTreeModel::data(const GUI::ModelIndex& index, Role role) const { - auto* widget = static_cast(index.internal_data()); + auto* widget = static_cast(index.internal_data()); if (role == Role::Icon) { return m_widget_icon; } @@ -102,7 +102,7 @@ void WidgetTreeModel::update() did_update(); } -GModelIndex WidgetTreeModel::index_for_widget(GWidget& widget) const +GUI::ModelIndex WidgetTreeModel::index_for_widget(GUI::Widget& widget) const { int parent_child_index = 0; for (auto& parent_child : widget.parent_widget()->child_widgets()) { diff --git a/DevTools/HackStudio/WidgetTreeModel.h b/DevTools/HackStudio/WidgetTreeModel.h index 5b7523644a5..28bbeff59ef 100644 --- a/DevTools/HackStudio/WidgetTreeModel.h +++ b/DevTools/HackStudio/WidgetTreeModel.h @@ -29,23 +29,23 @@ #include #include -class WidgetTreeModel final : public GModel { +class WidgetTreeModel final : public GUI::Model { public: - static NonnullRefPtr create(GWidget& root) { return adopt(*new WidgetTreeModel(root)); } + static NonnullRefPtr create(GUI::Widget& root) { return adopt(*new WidgetTreeModel(root)); } virtual ~WidgetTreeModel() override; - virtual int row_count(const GModelIndex& = GModelIndex()) const override; - virtual int column_count(const GModelIndex& = GModelIndex()) const override; - virtual GVariant data(const GModelIndex&, Role = Role::Display) const override; - virtual GModelIndex index(int row, int column, const GModelIndex& parent = GModelIndex()) const override; - virtual GModelIndex parent_index(const GModelIndex&) const override; + virtual int row_count(const GUI::ModelIndex& = GUI::ModelIndex()) const override; + virtual int column_count(const GUI::ModelIndex& = GUI::ModelIndex()) const override; + virtual GUI::Variant data(const GUI::ModelIndex&, Role = Role::Display) const override; + virtual GUI::ModelIndex index(int row, int column, const GUI::ModelIndex& parent = GUI::ModelIndex()) const override; + virtual GUI::ModelIndex parent_index(const GUI::ModelIndex&) const override; virtual void update() override; - GModelIndex index_for_widget(GWidget&) const; + GUI::ModelIndex index_for_widget(GUI::Widget&) const; private: - explicit WidgetTreeModel(GWidget&); + explicit WidgetTreeModel(GUI::Widget&); - NonnullRefPtr m_root; + NonnullRefPtr m_root; GIcon m_widget_icon; }; diff --git a/DevTools/HackStudio/main.cpp b/DevTools/HackStudio/main.cpp index d4c2059fd18..84b7a77f74f 100644 --- a/DevTools/HackStudio/main.cpp +++ b/DevTools/HackStudio/main.cpp @@ -69,16 +69,16 @@ RefPtr g_current_editor_wrapper; String g_currently_open_file; OwnPtr g_project; -RefPtr g_window; -RefPtr g_project_tree_view; -RefPtr g_right_hand_stack; -RefPtr g_text_inner_splitter; -RefPtr g_form_inner_container; +RefPtr g_window; +RefPtr g_project_tree_view; +RefPtr g_right_hand_stack; +RefPtr g_text_inner_splitter; +RefPtr g_form_inner_container; RefPtr g_form_editor_widget; -static RefPtr s_action_tab_widget; +static RefPtr s_action_tab_widget; -void add_new_editor(GWidget& parent) +void add_new_editor(GUI::Widget& parent) { auto wrapper = EditorWrapper::construct(nullptr); if (s_action_tab_widget) { @@ -128,7 +128,7 @@ int main(int argc, char** argv) return 1; } - GApplication app(argc, argv); + GUI::Application app(argc, argv); if (pledge("stdio tty accept rpath cpath wpath shared_buffer proc exec fattr", nullptr) < 0) { perror("pledge"); @@ -137,15 +137,15 @@ int main(int argc, char** argv) Function update_actions; - g_window = GWindow::construct(); + g_window = GUI::Window::construct(); g_window->set_rect(90, 90, 840, 600); g_window->set_title("HackStudio"); - auto widget = GWidget::construct(); + auto widget = GUI::Widget::construct(); g_window->set_main_widget(widget); widget->set_fill_with_background_color(true); - widget->set_layout(make()); + widget->set_layout(make()); widget->layout()->set_spacing(0); StringBuilder path; @@ -156,7 +156,7 @@ int main(int argc, char** argv) setenv("PATH", path.to_string().characters(), true); if (!make_is_available()) - GMessageBox::show("The 'make' command is not available. You probably want to install the binutils, gcc, and make ports from the root of the Serenity repository.", "Error", GMessageBox::Type::Error, GMessageBox::InputType::OK, g_window); + GUI::MessageBox::show("The 'make' command is not available. You probably want to install the binutils, gcc, and make ports from the root of the Serenity repository.", "Error", GUI::MessageBox::Type::Error, GUI::MessageBox::InputType::OK, g_window); if (chdir("/home/anon/little") < 0) { perror("chdir"); @@ -165,47 +165,47 @@ int main(int argc, char** argv) g_project = Project::load_from_file("little.files"); ASSERT(g_project); - auto toolbar = GToolBar::construct(widget); + auto toolbar = GUI::ToolBar::construct(widget); auto selected_file_names = [&] { Vector files; - g_project_tree_view->selection().for_each_index([&](const GModelIndex& index) { + g_project_tree_view->selection().for_each_index([&](const GUI::ModelIndex& index) { files.append(g_project->model().data(index).as_string()); }); return files; }; - auto new_action = GAction::create("Add new file to project...", { Mod_Ctrl, Key_N }, GraphicsBitmap::load_from_file("/res/icons/16x16/new.png"), [&](const GAction&) { - auto input_box = GInputBox::construct("Enter name of new file:", "Add new file to project", g_window); - if (input_box->exec() == GInputBox::ExecCancel) + auto new_action = GUI::Action::create("Add new file to project...", { Mod_Ctrl, Key_N }, GraphicsBitmap::load_from_file("/res/icons/16x16/new.png"), [&](const GUI::Action&) { + auto input_box = GUI::InputBox::construct("Enter name of new file:", "Add new file to project", g_window); + if (input_box->exec() == GUI::InputBox::ExecCancel) return; auto filename = input_box->text_value(); auto file = Core::File::construct(filename); if (!file->open((Core::IODevice::OpenMode)(Core::IODevice::WriteOnly | Core::IODevice::MustBeNew))) { - GMessageBox::show(String::format("Failed to create '%s'", filename.characters()), "Error", GMessageBox::Type::Error, GMessageBox::InputType::OK, g_window); + GUI::MessageBox::show(String::format("Failed to create '%s'", filename.characters()), "Error", GUI::MessageBox::Type::Error, GUI::MessageBox::InputType::OK, g_window); return; } if (!g_project->add_file(filename)) { - GMessageBox::show(String::format("Failed to add '%s' to project", filename.characters()), "Error", GMessageBox::Type::Error, GMessageBox::InputType::OK, g_window); + GUI::MessageBox::show(String::format("Failed to add '%s' to project", filename.characters()), "Error", GUI::MessageBox::Type::Error, GUI::MessageBox::InputType::OK, g_window); // FIXME: Should we unlink the file here maybe? return; } open_file(filename); }); - auto add_existing_file_action = GAction::create("Add existing file to project...", GraphicsBitmap::load_from_file("/res/icons/16x16/open.png"), [&](auto&) { - auto result = GFilePicker::get_open_filepath("Add existing file to project"); + auto add_existing_file_action = GUI::Action::create("Add existing file to project...", GraphicsBitmap::load_from_file("/res/icons/16x16/open.png"), [&](auto&) { + auto result = GUI::FilePicker::get_open_filepath("Add existing file to project"); if (!result.has_value()) return; auto& filename = result.value(); if (!g_project->add_file(filename)) { - GMessageBox::show(String::format("Failed to add '%s' to project", filename.characters()), "Error", GMessageBox::Type::Error, GMessageBox::InputType::OK, g_window); + GUI::MessageBox::show(String::format("Failed to add '%s' to project", filename.characters()), "Error", GUI::MessageBox::Type::Error, GUI::MessageBox::InputType::OK, g_window); return; } open_file(filename); }); - auto delete_action = GCommonActions::make_delete_action([&](const GAction& action) { + auto delete_action = GUI::CommonActions::make_delete_action([&](const GUI::Action& action) { (void)action; auto files = selected_file_names(); @@ -219,22 +219,22 @@ int main(int argc, char** argv) message = String::format("Really remove %d files from the project?", files.size()); } - auto result = GMessageBox::show( + auto result = GUI::MessageBox::show( message, "Confirm deletion", - GMessageBox::Type::Warning, - GMessageBox::InputType::OKCancel, + GUI::MessageBox::Type::Warning, + GUI::MessageBox::InputType::OKCancel, g_window); - if (result == GMessageBox::ExecCancel) + if (result == GUI::MessageBox::ExecCancel) return; for (auto& file : files) { if (!g_project->remove_file(file)) { - GMessageBox::show( + GUI::MessageBox::show( String::format("Removing file %s from the project failed.", file.characters()), "Removal failed", - GMessageBox::Type::Error, - GMessageBox::InputType::OK, + GUI::MessageBox::Type::Error, + GUI::MessageBox::InputType::OK, g_window); break; } @@ -242,18 +242,18 @@ int main(int argc, char** argv) }); delete_action->set_enabled(false); - auto project_tree_view_context_menu = GMenu::construct("Project Files"); + auto project_tree_view_context_menu = GUI::Menu::construct("Project Files"); project_tree_view_context_menu->add_action(new_action); project_tree_view_context_menu->add_action(add_existing_file_action); project_tree_view_context_menu->add_action(delete_action); - auto outer_splitter = GSplitter::construct(Orientation::Horizontal, widget); - g_project_tree_view = GTreeView::construct(outer_splitter); + auto outer_splitter = GUI::Splitter::construct(Orientation::Horizontal, widget); + g_project_tree_view = GUI::TreeView::construct(outer_splitter); g_project_tree_view->set_model(g_project->model()); - g_project_tree_view->set_size_policy(SizePolicy::Fixed, SizePolicy::Fill); + g_project_tree_view->set_size_policy(GUI::SizePolicy::Fixed, GUI::SizePolicy::Fill); g_project_tree_view->set_preferred_size(140, 0); - g_project_tree_view->on_context_menu_request = [&](const GModelIndex& index, const GContextMenuEvent& event) { + g_project_tree_view->on_context_menu_request = [&](const GUI::ModelIndex& index, const GUI::ContextMenuEvent& event) { if (index.is_valid()) { project_tree_view_context_menu->popup(event.screen_position()); } @@ -263,17 +263,17 @@ int main(int argc, char** argv) delete_action->set_enabled(!g_project_tree_view->selection().is_empty()); }; - g_right_hand_stack = GStackWidget::construct(outer_splitter); + g_right_hand_stack = GUI::StackWidget::construct(outer_splitter); - g_form_inner_container = GWidget::construct(g_right_hand_stack); - g_form_inner_container->set_layout(make()); - auto form_widgets_toolbar = GToolBar::construct(Orientation::Vertical, 26, g_form_inner_container); + g_form_inner_container = GUI::Widget::construct(g_right_hand_stack); + g_form_inner_container->set_layout(make()); + auto form_widgets_toolbar = GUI::ToolBar::construct(Orientation::Vertical, 26, g_form_inner_container); form_widgets_toolbar->set_preferred_size(38, 0); - GActionGroup tool_actions; + GUI::ActionGroup tool_actions; tool_actions.set_exclusive(true); - auto cursor_tool_action = GAction::create("Cursor", GraphicsBitmap::load_from_file("/res/icons/widgets/Cursor.png"), [&](auto&) { + auto cursor_tool_action = GUI::Action::create("Cursor", GraphicsBitmap::load_from_file("/res/icons/widgets/Cursor.png"), [&](auto&) { g_form_editor_widget->set_tool(make(*g_form_editor_widget)); }); cursor_tool_action->set_checkable(true); @@ -282,9 +282,9 @@ int main(int argc, char** argv) form_widgets_toolbar->add_action(cursor_tool_action); - GWidgetClassRegistration::for_each([&](const GWidgetClassRegistration& reg) { + GUI::WidgetClassRegistration::for_each([&](const GUI::WidgetClassRegistration& reg) { auto icon_path = String::format("/res/icons/widgets/%s.png", reg.class_name().characters()); - auto action = GAction::create(reg.class_name(), GraphicsBitmap::load_from_file(icon_path), [®](auto&) { + auto action = GUI::Action::create(reg.class_name(), GraphicsBitmap::load_from_file(icon_path), [®](auto&) { g_form_editor_widget->set_tool(make(*g_form_editor_widget, reg)); auto widget = reg.construct(&g_form_editor_widget->form_widget()); widget->set_relative_rect(30, 30, 30, 30); @@ -296,28 +296,28 @@ int main(int argc, char** argv) form_widgets_toolbar->add_action(move(action)); }); - auto form_editor_inner_splitter = GSplitter::construct(Orientation::Horizontal, g_form_inner_container); + auto form_editor_inner_splitter = GUI::Splitter::construct(Orientation::Horizontal, g_form_inner_container); g_form_editor_widget = FormEditorWidget::construct(form_editor_inner_splitter); - auto form_editing_pane_container = GSplitter::construct(Orientation::Vertical, form_editor_inner_splitter); - form_editing_pane_container->set_size_policy(SizePolicy::Fixed, SizePolicy::Fill); + auto form_editing_pane_container = GUI::Splitter::construct(Orientation::Vertical, form_editor_inner_splitter); + form_editing_pane_container->set_size_policy(GUI::SizePolicy::Fixed, GUI::SizePolicy::Fill); form_editing_pane_container->set_preferred_size(190, 0); - form_editing_pane_container->set_layout(make()); + form_editing_pane_container->set_layout(make()); auto add_properties_pane = [&](auto& text, auto pane_widget) { - auto wrapper = GWidget::construct(form_editing_pane_container.ptr()); - wrapper->set_layout(make()); - auto label = GLabel::construct(text, wrapper); + auto wrapper = GUI::Widget::construct(form_editing_pane_container.ptr()); + wrapper->set_layout(make()); + auto label = GUI::Label::construct(text, wrapper); label->set_fill_with_background_color(true); label->set_text_alignment(TextAlignment::CenterLeft); label->set_font(Font::default_bold_font()); - label->set_size_policy(SizePolicy::Fill, SizePolicy::Fixed); + label->set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed); label->set_preferred_size(0, 16); wrapper->add_child(pane_widget); }; - auto form_widget_tree_view = GTreeView::construct(nullptr); + auto form_widget_tree_view = GUI::TreeView::construct(nullptr); form_widget_tree_view->set_model(g_form_editor_widget->model()); form_widget_tree_view->on_selection_change = [&] { g_form_editor_widget->selection().disable_hooks(); @@ -326,7 +326,7 @@ int main(int argc, char** argv) // NOTE: Make sure we don't add the FormWidget itself to the selection, // since that would allow you to drag-move the FormWidget. if (index.internal_data() != &g_form_editor_widget->form_widget()) - g_form_editor_widget->selection().add(*(GWidget*)index.internal_data()); + g_form_editor_widget->selection().add(*(GUI::Widget*)index.internal_data()); }); g_form_editor_widget->update(); g_form_editor_widget->selection().enable_hooks(); @@ -343,13 +343,13 @@ int main(int argc, char** argv) }; add_properties_pane("Form widget tree:", form_widget_tree_view); - add_properties_pane("Widget properties:", GTableView::construct(nullptr)); + add_properties_pane("Widget properties:", GUI::TableView::construct(nullptr)); - g_text_inner_splitter = GSplitter::construct(Orientation::Vertical, g_right_hand_stack); + g_text_inner_splitter = GUI::Splitter::construct(Orientation::Vertical, g_right_hand_stack); g_text_inner_splitter->layout()->set_margins({ 0, 3, 0, 0 }); add_new_editor(*g_text_inner_splitter); - auto switch_to_next_editor = GAction::create("Switch to next editor", { Mod_Ctrl, Key_E }, [&](auto&) { + auto switch_to_next_editor = GUI::Action::create("Switch to next editor", { Mod_Ctrl, Key_E }, [&](auto&) { if (g_all_editor_wrappers.size() <= 1) return; Vector wrappers; @@ -367,7 +367,7 @@ int main(int argc, char** argv) } }); - auto switch_to_previous_editor = GAction::create("Switch to previous editor", { Mod_Ctrl | Mod_Shift, Key_E }, [&](auto&) { + auto switch_to_previous_editor = GUI::Action::create("Switch to previous editor", { Mod_Ctrl | Mod_Shift, Key_E }, [&](auto&) { if (g_all_editor_wrappers.size() <= 1) return; Vector wrappers; @@ -385,7 +385,7 @@ int main(int argc, char** argv) } }); - auto remove_current_editor_action = GAction::create("Remove current editor", { Mod_Alt | Mod_Shift, Key_E }, [&](auto&) { + auto remove_current_editor_action = GUI::Action::create("Remove current editor", { Mod_Alt | Mod_Shift, Key_E }, [&](auto&) { if (g_all_editor_wrappers.size() <= 1) return; auto wrapper = g_current_editor_wrapper; @@ -395,7 +395,7 @@ int main(int argc, char** argv) update_actions(); }); - auto save_action = GAction::create("Save", { Mod_Ctrl, Key_S }, GraphicsBitmap::load_from_file("/res/icons/16x16/save.png"), [&](auto&) { + auto save_action = GUI::Action::create("Save", { Mod_Ctrl, Key_S }, GraphicsBitmap::load_from_file("/res/icons/16x16/save.png"), [&](auto&) { if (g_currently_open_file.is_empty()) return; current_editor().write_to_file(g_currently_open_file); @@ -407,22 +407,22 @@ int main(int argc, char** argv) toolbar->add_action(delete_action); toolbar->add_separator(); - toolbar->add_action(GCommonActions::make_cut_action([&](auto&) { current_editor().cut_action().activate(); })); - toolbar->add_action(GCommonActions::make_copy_action([&](auto&) { current_editor().copy_action().activate(); })); - toolbar->add_action(GCommonActions::make_paste_action([&](auto&) { current_editor().paste_action().activate(); })); + toolbar->add_action(GUI::CommonActions::make_cut_action([&](auto&) { current_editor().cut_action().activate(); })); + toolbar->add_action(GUI::CommonActions::make_copy_action([&](auto&) { current_editor().copy_action().activate(); })); + toolbar->add_action(GUI::CommonActions::make_paste_action([&](auto&) { current_editor().paste_action().activate(); })); toolbar->add_separator(); - toolbar->add_action(GCommonActions::make_undo_action([&](auto&) { current_editor().undo_action().activate(); })); - toolbar->add_action(GCommonActions::make_redo_action([&](auto&) { current_editor().redo_action().activate(); })); + toolbar->add_action(GUI::CommonActions::make_undo_action([&](auto&) { current_editor().undo_action().activate(); })); + toolbar->add_action(GUI::CommonActions::make_redo_action([&](auto&) { current_editor().redo_action().activate(); })); toolbar->add_separator(); g_project_tree_view->on_activation = [&](auto& index) { - auto filename = g_project_tree_view->model()->data(index, GModel::Role::Custom).to_string(); + auto filename = g_project_tree_view->model()->data(index, GUI::Model::Role::Custom).to_string(); open_file(filename); }; - s_action_tab_widget = GTabWidget::construct(g_text_inner_splitter); + s_action_tab_widget = GUI::TabWidget::construct(g_text_inner_splitter); - s_action_tab_widget->set_size_policy(SizePolicy::Fill, SizePolicy::Fixed); + s_action_tab_widget->set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed); s_action_tab_widget->set_preferred_size(0, 24); auto reveal_action_tab = [&](auto& widget) { @@ -435,11 +435,11 @@ int main(int argc, char** argv) s_action_tab_widget->set_preferred_size(0, 24); }; - auto hide_action_tabs_action = GAction::create("Hide action tabs", { Mod_Ctrl | Mod_Shift, Key_X }, [&](auto&) { + auto hide_action_tabs_action = GUI::Action::create("Hide action tabs", { Mod_Ctrl | Mod_Shift, Key_X }, [&](auto&) { hide_action_tabs(); }); - auto add_editor_action = GAction::create("Add new editor", { Mod_Ctrl | Mod_Alt, Key_E }, [&](auto&) { + auto add_editor_action = GUI::Action::create("Add new editor", { Mod_Ctrl | Mod_Alt, Key_E }, [&](auto&) { add_new_editor(*g_text_inner_splitter); update_actions(); }); @@ -452,31 +452,31 @@ int main(int argc, char** argv) auto locator = Locator::construct(widget); - auto open_locator_action = GAction::create("Open Locator...", { Mod_Ctrl, Key_K }, [&](auto&) { + auto open_locator_action = GUI::Action::create("Open Locator...", { Mod_Ctrl, Key_K }, [&](auto&) { locator->open(); }); - auto menubar = make(); - auto app_menu = GMenu::construct("HackStudio"); + auto menubar = make(); + auto app_menu = GUI::Menu::construct("HackStudio"); app_menu->add_action(save_action); - app_menu->add_action(GCommonActions::make_quit_action([&](auto&) { + app_menu->add_action(GUI::CommonActions::make_quit_action([&](auto&) { app.quit(); })); menubar->add_menu(move(app_menu)); - auto project_menu = GMenu::construct("Project"); + auto project_menu = GUI::Menu::construct("Project"); project_menu->add_action(new_action); project_menu->add_action(add_existing_file_action); menubar->add_menu(move(project_menu)); - auto edit_menu = GMenu::construct("Edit"); - edit_menu->add_action(GAction::create("Find in files...", { Mod_Ctrl | Mod_Shift, Key_F }, [&](auto&) { + auto edit_menu = GUI::Menu::construct("Edit"); + edit_menu->add_action(GUI::Action::create("Find in files...", { Mod_Ctrl | Mod_Shift, Key_F }, [&](auto&) { reveal_action_tab(find_in_files_widget); find_in_files_widget->focus_textbox_and_select_all(); })); menubar->add_menu(move(edit_menu)); - auto stop_action = GAction::create("Stop", GraphicsBitmap::load_from_file("/res/icons/16x16/stop.png"), [&](auto&) { + auto stop_action = GUI::Action::create("Stop", GraphicsBitmap::load_from_file("/res/icons/16x16/stop.png"), [&](auto&) { terminal_wrapper->kill_running_command(); }); @@ -485,14 +485,14 @@ int main(int argc, char** argv) stop_action->set_enabled(false); }; - auto build_action = GAction::create("Build", { Mod_Ctrl, Key_B }, GraphicsBitmap::load_from_file("/res/icons/16x16/build.png"), [&](auto&) { + auto build_action = GUI::Action::create("Build", { Mod_Ctrl, Key_B }, GraphicsBitmap::load_from_file("/res/icons/16x16/build.png"), [&](auto&) { reveal_action_tab(terminal_wrapper); build(terminal_wrapper); stop_action->set_enabled(true); }); toolbar->add_action(build_action); - auto run_action = GAction::create("Run", { Mod_Ctrl, Key_R }, GraphicsBitmap::load_from_file("/res/icons/16x16/play.png"), [&](auto&) { + auto run_action = GUI::Action::create("Run", { Mod_Ctrl, Key_R }, GraphicsBitmap::load_from_file("/res/icons/16x16/play.png"), [&](auto&) { reveal_action_tab(terminal_wrapper); run(terminal_wrapper); stop_action->set_enabled(true); @@ -500,13 +500,13 @@ int main(int argc, char** argv) toolbar->add_action(run_action); toolbar->add_action(stop_action); - auto build_menu = GMenu::construct("Build"); + auto build_menu = GUI::Menu::construct("Build"); build_menu->add_action(build_action); build_menu->add_action(run_action); build_menu->add_action(stop_action); menubar->add_menu(move(build_menu)); - auto view_menu = GMenu::construct("View"); + auto view_menu = GUI::Menu::construct("View"); view_menu->add_action(hide_action_tabs_action); view_menu->add_action(open_locator_action); view_menu->add_separator(); @@ -516,9 +516,9 @@ int main(int argc, char** argv) auto small_icon = GraphicsBitmap::load_from_file("/res/icons/16x16/app-hack-studio.png"); - auto help_menu = GMenu::construct("Help"); - help_menu->add_action(GAction::create("About", [&](auto&) { - GAboutDialog::show("HackStudio", small_icon, g_window); + auto help_menu = GUI::Menu::construct("Help"); + help_menu->add_action(GUI::Action::create("About", [&](auto&) { + GUI::AboutDialog::show("HackStudio", small_icon, g_window); })); menubar->add_menu(move(help_menu)); @@ -581,12 +581,12 @@ static void rehighlight() CppLexer lexer(text); auto tokens = lexer.lex(); - Vector spans; + Vector spans; for (auto& token : tokens) { #ifdef DEBUG_SYNTAX_HIGHLIGHTING dbg() << token.to_string() << " @ " << token.m_start.line << ":" << token.m_start.column << " - " << token.m_end.line << ":" << token.m_end.column; #endif - GTextDocumentSpan span; + GUI::TextDocumentSpan span; span.range.set_start({ token.m_start.line, token.m_start.column }); span.range.set_end({ token.m_end.line, token.m_end.column }); auto style = style_for_token_type(token.m_type); @@ -604,7 +604,7 @@ static void rehighlight() void open_file(const String& filename) { auto file = g_project->get_file(filename); - current_editor().set_document(const_cast(file->document())); + current_editor().set_document(const_cast(file->document())); if (filename.ends_with(".cpp") || filename.ends_with(".h")) { current_editor().on_change = [] { rehighlight(); }; diff --git a/DevTools/Inspector/RemoteObjectGraphModel.cpp b/DevTools/Inspector/RemoteObjectGraphModel.cpp index 18b81dbce4a..28a989f54d2 100644 --- a/DevTools/Inspector/RemoteObjectGraphModel.cpp +++ b/DevTools/Inspector/RemoteObjectGraphModel.cpp @@ -44,7 +44,7 @@ RemoteObjectGraphModel::~RemoteObjectGraphModel() { } -GModelIndex RemoteObjectGraphModel::index(int row, int column, const GModelIndex& parent) const +GUI::ModelIndex RemoteObjectGraphModel::index(int row, int column, const GUI::ModelIndex& parent) const { if (!parent.is_valid()) { if (m_process.roots().is_empty()) @@ -55,7 +55,7 @@ GModelIndex RemoteObjectGraphModel::index(int row, int column, const GModelIndex return create_index(row, column, &remote_parent.children.at(row)); } -GModelIndex RemoteObjectGraphModel::parent_index(const GModelIndex& index) const +GUI::ModelIndex RemoteObjectGraphModel::parent_index(const GUI::ModelIndex& index) const { if (!index.is_valid()) return {}; @@ -82,7 +82,7 @@ GModelIndex RemoteObjectGraphModel::parent_index(const GModelIndex& index) const return {}; } -int RemoteObjectGraphModel::row_count(const GModelIndex& index) const +int RemoteObjectGraphModel::row_count(const GUI::ModelIndex& index) const { if (!index.is_valid()) return m_process.roots().size(); @@ -90,12 +90,12 @@ int RemoteObjectGraphModel::row_count(const GModelIndex& index) const return remote_object.children.size(); } -int RemoteObjectGraphModel::column_count(const GModelIndex&) const +int RemoteObjectGraphModel::column_count(const GUI::ModelIndex&) const { return 1; } -GVariant RemoteObjectGraphModel::data(const GModelIndex& index, Role role) const +GUI::Variant RemoteObjectGraphModel::data(const GUI::ModelIndex& index, Role role) const { auto* remote_object = static_cast(index.internal_data()); if (role == Role::Icon) { diff --git a/DevTools/Inspector/RemoteObjectGraphModel.h b/DevTools/Inspector/RemoteObjectGraphModel.h index 61a193c1e20..fb4f66ea658 100644 --- a/DevTools/Inspector/RemoteObjectGraphModel.h +++ b/DevTools/Inspector/RemoteObjectGraphModel.h @@ -34,7 +34,7 @@ class RemoteProcess; -class RemoteObjectGraphModel final : public GModel { +class RemoteObjectGraphModel final : public GUI::Model { public: static NonnullRefPtr create(RemoteProcess& process) { @@ -43,11 +43,11 @@ public: virtual ~RemoteObjectGraphModel() override; - virtual int row_count(const GModelIndex& = GModelIndex()) const override; - virtual int column_count(const GModelIndex& = GModelIndex()) const override; - virtual GVariant data(const GModelIndex&, Role = Role::Display) const override; - virtual GModelIndex index(int row, int column, const GModelIndex& parent = GModelIndex()) const override; - virtual GModelIndex parent_index(const GModelIndex&) const override; + virtual int row_count(const GUI::ModelIndex& = GUI::ModelIndex()) const override; + virtual int column_count(const GUI::ModelIndex& = GUI::ModelIndex()) const override; + virtual GUI::Variant data(const GUI::ModelIndex&, Role = Role::Display) const override; + virtual GUI::ModelIndex index(int row, int column, const GUI::ModelIndex& parent = GUI::ModelIndex()) const override; + virtual GUI::ModelIndex parent_index(const GUI::ModelIndex&) const override; virtual void update() override; private: diff --git a/DevTools/Inspector/RemoteObjectPropertyModel.cpp b/DevTools/Inspector/RemoteObjectPropertyModel.cpp index 4bf789ee79b..fed429b4071 100644 --- a/DevTools/Inspector/RemoteObjectPropertyModel.cpp +++ b/DevTools/Inspector/RemoteObjectPropertyModel.cpp @@ -32,7 +32,7 @@ RemoteObjectPropertyModel::RemoteObjectPropertyModel(RemoteObject& object) { } -int RemoteObjectPropertyModel::row_count(const GModelIndex&) const +int RemoteObjectPropertyModel::row_count(const GUI::ModelIndex&) const { return m_properties.size(); } @@ -48,7 +48,7 @@ String RemoteObjectPropertyModel::column_name(int column) const ASSERT_NOT_REACHED(); } -GVariant RemoteObjectPropertyModel::data(const GModelIndex& index, Role role) const +GUI::Variant RemoteObjectPropertyModel::data(const GUI::ModelIndex& index, Role role) const { auto& property = m_properties[index.row()]; if (role == Role::Display) { diff --git a/DevTools/Inspector/RemoteObjectPropertyModel.h b/DevTools/Inspector/RemoteObjectPropertyModel.h index 8a89a10dd81..5e7ecb060f1 100644 --- a/DevTools/Inspector/RemoteObjectPropertyModel.h +++ b/DevTools/Inspector/RemoteObjectPropertyModel.h @@ -31,7 +31,7 @@ class RemoteObject; -class RemoteObjectPropertyModel final : public GModel { +class RemoteObjectPropertyModel final : public GUI::Model { public: virtual ~RemoteObjectPropertyModel() override {} static NonnullRefPtr create(RemoteObject& object) @@ -45,10 +45,10 @@ public: __Count, }; - virtual int row_count(const GModelIndex& = GModelIndex()) const override; - virtual int column_count(const GModelIndex& = GModelIndex()) const override { return Column::__Count; } + virtual int row_count(const GUI::ModelIndex& = GUI::ModelIndex()) const override; + virtual int column_count(const GUI::ModelIndex& = GUI::ModelIndex()) const override { return Column::__Count; } virtual String column_name(int) const override; - virtual GVariant data(const GModelIndex&, Role = Role::Display) const override; + virtual GUI::Variant data(const GUI::ModelIndex&, Role = Role::Display) const override; virtual void update() override; private: diff --git a/DevTools/Inspector/main.cpp b/DevTools/Inspector/main.cpp index 99548c5724e..4a4e75b3e1c 100644 --- a/DevTools/Inspector/main.cpp +++ b/DevTools/Inspector/main.cpp @@ -52,18 +52,18 @@ int main(int argc, char** argv) if (!ok) print_usage_and_exit(); - GApplication app(argc, argv); + GUI::Application app(argc, argv); - auto window = GWindow::construct(); + auto window = GUI::Window::construct(); window->set_title("Inspector"); window->set_rect(150, 150, 300, 500); - auto widget = GWidget::construct(); + auto widget = GUI::Widget::construct(); window->set_main_widget(widget); widget->set_fill_with_background_color(true); - widget->set_layout(make()); + widget->set_layout(make()); - auto splitter = GSplitter::construct(Orientation::Horizontal, widget); + auto splitter = GUI::Splitter::construct(Orientation::Horizontal, widget); RemoteProcess remote_process(pid); @@ -72,11 +72,11 @@ int main(int argc, char** argv) window->set_title(String::format("Inspector: %s (%d)", remote_process.process_name().characters(), remote_process.pid())); }; - auto tree_view = GTreeView::construct(splitter); + auto tree_view = GUI::TreeView::construct(splitter); tree_view->set_model(remote_process.object_graph_model()); tree_view->set_activates_on_selection(true); - auto properties_table_view = GTableView::construct(splitter); + auto properties_table_view = GUI::TableView::construct(splitter); properties_table_view->set_size_columns_to_fit_content(true); tree_view->on_activation = [&](auto& index) { diff --git a/DevTools/ProfileViewer/Profile.cpp b/DevTools/ProfileViewer/Profile.cpp index ea0671dfad8..d610a77ccc8 100644 --- a/DevTools/ProfileViewer/Profile.cpp +++ b/DevTools/ProfileViewer/Profile.cpp @@ -86,7 +86,7 @@ Profile::~Profile() { } -GModel& Profile::model() +GUI::Model& Profile::model() { return *m_model; } diff --git a/DevTools/ProfileViewer/Profile.h b/DevTools/ProfileViewer/Profile.h index 81dd2bafa35..bbefa20430a 100644 --- a/DevTools/ProfileViewer/Profile.h +++ b/DevTools/ProfileViewer/Profile.h @@ -32,7 +32,10 @@ #include #include -class GModel; +namespace GUI { +class Model; +} + class ProfileModel; class ProfileNode : public RefCounted { @@ -104,7 +107,7 @@ public: static OwnPtr load_from_file(const StringView& path); ~Profile(); - GModel& model(); + GUI::Model& model(); const Vector>& roots() const { return m_roots; } diff --git a/DevTools/ProfileViewer/ProfileModel.cpp b/DevTools/ProfileViewer/ProfileModel.cpp index 76cc000436f..ba2b0f99cbe 100644 --- a/DevTools/ProfileViewer/ProfileModel.cpp +++ b/DevTools/ProfileViewer/ProfileModel.cpp @@ -41,7 +41,7 @@ ProfileModel::~ProfileModel() { } -GModelIndex ProfileModel::index(int row, int column, const GModelIndex& parent) const +GUI::ModelIndex ProfileModel::index(int row, int column, const GUI::ModelIndex& parent) const { if (!parent.is_valid()) { if (m_profile.roots().is_empty()) @@ -52,7 +52,7 @@ GModelIndex ProfileModel::index(int row, int column, const GModelIndex& parent) return create_index(row, column, remote_parent.children().at(row).ptr()); } -GModelIndex ProfileModel::parent_index(const GModelIndex& index) const +GUI::ModelIndex ProfileModel::parent_index(const GUI::ModelIndex& index) const { if (!index.is_valid()) return {}; @@ -80,7 +80,7 @@ GModelIndex ProfileModel::parent_index(const GModelIndex& index) const return {}; } -int ProfileModel::row_count(const GModelIndex& index) const +int ProfileModel::row_count(const GUI::ModelIndex& index) const { if (!index.is_valid()) return m_profile.roots().size(); @@ -88,7 +88,7 @@ int ProfileModel::row_count(const GModelIndex& index) const return node.children().size(); } -int ProfileModel::column_count(const GModelIndex&) const +int ProfileModel::column_count(const GUI::ModelIndex&) const { return Column::__Count; } @@ -106,14 +106,14 @@ String ProfileModel::column_name(int column) const } } -GModel::ColumnMetadata ProfileModel::column_metadata(int column) const +GUI::Model::ColumnMetadata ProfileModel::column_metadata(int column) const { if (column == Column::SampleCount) return ColumnMetadata { 0, TextAlignment::CenterRight }; return {}; } -GVariant ProfileModel::data(const GModelIndex& index, Role role) const +GUI::Variant ProfileModel::data(const GUI::ModelIndex& index, Role role) const { auto* node = static_cast(index.internal_data()); if (role == Role::Icon) { diff --git a/DevTools/ProfileViewer/ProfileModel.h b/DevTools/ProfileViewer/ProfileModel.h index 688e3f5635e..3b3f3ab6012 100644 --- a/DevTools/ProfileViewer/ProfileModel.h +++ b/DevTools/ProfileViewer/ProfileModel.h @@ -30,7 +30,7 @@ class Profile; -class ProfileModel final : public GModel { +class ProfileModel final : public GUI::Model { public: static NonnullRefPtr create(Profile& profile) { @@ -45,13 +45,13 @@ public: virtual ~ProfileModel() override; - virtual int row_count(const GModelIndex& = GModelIndex()) const override; - virtual int column_count(const GModelIndex& = GModelIndex()) const override; + virtual int row_count(const GUI::ModelIndex& = GUI::ModelIndex()) const override; + virtual int column_count(const GUI::ModelIndex& = GUI::ModelIndex()) const override; virtual String column_name(int) const override; virtual ColumnMetadata column_metadata(int) const override; - virtual GVariant data(const GModelIndex&, Role = Role::Display) const override; - virtual GModelIndex index(int row, int column, const GModelIndex& parent = GModelIndex()) const override; - virtual GModelIndex parent_index(const GModelIndex&) const override; + virtual GUI::Variant data(const GUI::ModelIndex&, Role = Role::Display) const override; + virtual GUI::ModelIndex index(int row, int column, const GUI::ModelIndex& parent = GUI::ModelIndex()) const override; + virtual GUI::ModelIndex parent_index(const GUI::ModelIndex&) const override; virtual void update() override; virtual int tree_column() const override { return Column::StackFrame; } diff --git a/DevTools/ProfileViewer/ProfileTimelineWidget.cpp b/DevTools/ProfileViewer/ProfileTimelineWidget.cpp index 9e27175d293..4132217dc3d 100644 --- a/DevTools/ProfileViewer/ProfileTimelineWidget.cpp +++ b/DevTools/ProfileViewer/ProfileTimelineWidget.cpp @@ -28,8 +28,8 @@ #include "Profile.h" #include -ProfileTimelineWidget::ProfileTimelineWidget(Profile& profile, GWidget* parent) - : GFrame(parent) +ProfileTimelineWidget::ProfileTimelineWidget(Profile& profile, GUI::Widget* parent) + : GUI::Frame(parent) , m_profile(profile) { set_frame_thickness(2); @@ -37,7 +37,7 @@ ProfileTimelineWidget::ProfileTimelineWidget(Profile& profile, GWidget* parent) set_frame_shape(FrameShape::Container); set_background_color(Color::White); set_fill_with_background_color(true); - set_size_policy(SizePolicy::Fill, SizePolicy::Fixed); + set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed); set_preferred_size(0, 80); } @@ -45,11 +45,11 @@ ProfileTimelineWidget::~ProfileTimelineWidget() { } -void ProfileTimelineWidget::paint_event(GPaintEvent& event) +void ProfileTimelineWidget::paint_event(GUI::PaintEvent& event) { - GFrame::paint_event(event); + GUI::Frame::paint_event(event); - GPainter painter(*this); + GUI::Painter painter(*this); painter.add_clip_rect(event.rect()); float column_width = (float)frame_inner_rect().width() / (float)m_profile.length_in_ms(); @@ -83,9 +83,9 @@ u64 ProfileTimelineWidget::timestamp_at_x(int x) const return m_profile.first_timestamp() + (u64)ms_into_profile; } -void ProfileTimelineWidget::mousedown_event(GMouseEvent& event) +void ProfileTimelineWidget::mousedown_event(GUI::MouseEvent& event) { - if (event.button() != GMouseButton::Left) + if (event.button() != GUI::MouseButton::Left) return; m_selecting = true; @@ -95,7 +95,7 @@ void ProfileTimelineWidget::mousedown_event(GMouseEvent& event) update(); } -void ProfileTimelineWidget::mousemove_event(GMouseEvent& event) +void ProfileTimelineWidget::mousemove_event(GUI::MouseEvent& event) { if (!m_selecting) return; @@ -105,9 +105,9 @@ void ProfileTimelineWidget::mousemove_event(GMouseEvent& event) update(); } -void ProfileTimelineWidget::mouseup_event(GMouseEvent& event) +void ProfileTimelineWidget::mouseup_event(GUI::MouseEvent& event) { - if (event.button() != GMouseButton::Left) + if (event.button() != GUI::MouseButton::Left) return; m_selecting = false; diff --git a/DevTools/ProfileViewer/ProfileTimelineWidget.h b/DevTools/ProfileViewer/ProfileTimelineWidget.h index a7ba654a563..3954d0cc6ba 100644 --- a/DevTools/ProfileViewer/ProfileTimelineWidget.h +++ b/DevTools/ProfileViewer/ProfileTimelineWidget.h @@ -28,18 +28,18 @@ class Profile; -class ProfileTimelineWidget final : public GFrame { +class ProfileTimelineWidget final : public GUI::Frame { C_OBJECT(ProfileTimelineWidget) public: virtual ~ProfileTimelineWidget() override; private: - virtual void paint_event(GPaintEvent&) override; - virtual void mousedown_event(GMouseEvent&) override; - virtual void mousemove_event(GMouseEvent&) override; - virtual void mouseup_event(GMouseEvent&) override; + virtual void paint_event(GUI::PaintEvent&) override; + virtual void mousedown_event(GUI::MouseEvent&) override; + virtual void mousemove_event(GUI::MouseEvent&) override; + virtual void mouseup_event(GUI::MouseEvent&) override; - ProfileTimelineWidget(Profile&, GWidget* parent); + ProfileTimelineWidget(Profile&, GUI::Widget* parent); u64 timestamp_at_x(int x) const; diff --git a/DevTools/ProfileViewer/main.cpp b/DevTools/ProfileViewer/main.cpp index dc3aaf8bf17..86d0b83d6e0 100644 --- a/DevTools/ProfileViewer/main.cpp +++ b/DevTools/ProfileViewer/main.cpp @@ -50,32 +50,32 @@ int main(int argc, char** argv) return 1; } - GApplication app(argc, argv); + GUI::Application app(argc, argv); - auto window = GWindow::construct(); + auto window = GUI::Window::construct(); window->set_title("ProfileViewer"); window->set_rect(100, 100, 800, 600); - auto main_widget = GWidget::construct(); + auto main_widget = GUI::Widget::construct(); window->set_main_widget(main_widget); main_widget->set_fill_with_background_color(true); - main_widget->set_layout(make()); + main_widget->set_layout(make()); auto timeline_widget = ProfileTimelineWidget::construct(*profile, main_widget); - auto tree_view = GTreeView::construct(main_widget); + auto tree_view = GUI::TreeView::construct(main_widget); tree_view->set_headers_visible(true); tree_view->set_size_columns_to_fit_content(true); tree_view->set_model(profile->model()); - auto menubar = make(); - auto app_menu = GMenu::construct("ProfileViewer"); - app_menu->add_action(GCommonActions::make_quit_action([&](auto&) { app.quit(); })); + auto menubar = make(); + auto app_menu = GUI::Menu::construct("ProfileViewer"); + app_menu->add_action(GUI::CommonActions::make_quit_action([&](auto&) { app.quit(); })); menubar->add_menu(move(app_menu)); - auto view_menu = GMenu::construct("View"); - auto invert_action = GAction::create("Invert tree", { Mod_Ctrl, Key_I }, [&](auto& action) { + auto view_menu = GUI::Menu::construct("View"); + auto invert_action = GUI::Action::create("Invert tree", { Mod_Ctrl, Key_I }, [&](auto& action) { action.set_checked(!action.is_checked()); profile->set_inverted(action.is_checked()); }); diff --git a/DevTools/VisualBuilder/VBForm.cpp b/DevTools/VisualBuilder/VBForm.cpp index d4b55c80364..5f88b4b446e 100644 --- a/DevTools/VisualBuilder/VBForm.cpp +++ b/DevTools/VisualBuilder/VBForm.cpp @@ -45,43 +45,43 @@ VBForm* VBForm::current() return s_current; } -VBForm::VBForm(const String& name, GWidget* parent) - : GWidget(parent) +VBForm::VBForm(const String& name, GUI::Widget* parent) + : GUI::Widget(parent) , m_name(name) { s_current = this; set_fill_with_background_color(true); set_greedy_for_hits(true); - m_context_menu = GMenu::construct(); - m_context_menu->add_action(GCommonActions::make_move_to_front_action([this](auto&) { + m_context_menu = GUI::Menu::construct(); + m_context_menu->add_action(GUI::CommonActions::make_move_to_front_action([this](auto&) { if (auto* widget = single_selected_widget()) widget->gwidget()->move_to_front(); })); - m_context_menu->add_action(GCommonActions::make_move_to_back_action([this](auto&) { + m_context_menu->add_action(GUI::CommonActions::make_move_to_back_action([this](auto&) { if (auto* widget = single_selected_widget()) widget->gwidget()->move_to_back(); })); m_context_menu->add_separator(); - m_context_menu->add_action(GAction::create("Lay out horizontally", load_png("/res/icons/16x16/layout-horizontally.png"), [this](auto&) { + m_context_menu->add_action(GUI::Action::create("Lay out horizontally", load_png("/res/icons/16x16/layout-horizontally.png"), [this](auto&) { if (auto* widget = single_selected_widget()) { dbg() << "Giving " << *widget->gwidget() << " a horizontal box layout"; - widget->gwidget()->set_layout(make()); + widget->gwidget()->set_layout(make()); } })); - m_context_menu->add_action(GAction::create("Lay out vertically", load_png("/res/icons/16x16/layout-vertically.png"), [this](auto&) { + m_context_menu->add_action(GUI::Action::create("Lay out vertically", load_png("/res/icons/16x16/layout-vertically.png"), [this](auto&) { if (auto* widget = single_selected_widget()) { dbg() << "Giving " << *widget->gwidget() << " a vertical box layout"; - widget->gwidget()->set_layout(make()); + widget->gwidget()->set_layout(make()); } })); m_context_menu->add_separator(); - m_context_menu->add_action(GCommonActions::make_delete_action([this](auto&) { + m_context_menu->add_action(GUI::CommonActions::make_delete_action([this](auto&) { delete_selected_widgets(); })); } -void VBForm::context_menu_event(GContextMenuEvent& event) +void VBForm::context_menu_event(GUI::ContextMenuEvent& event) { m_context_menu->popup(event.screen_position()); } @@ -102,9 +102,9 @@ VBForm::~VBForm() { } -void VBForm::paint_event(GPaintEvent& event) +void VBForm::paint_event(GUI::PaintEvent& event) { - GPainter painter(*this); + GUI::Painter painter(*this); painter.add_clip_rect(event.rect()); for (int y = 0; y < height(); y += m_grid_size) { @@ -114,9 +114,9 @@ void VBForm::paint_event(GPaintEvent& event) } } -void VBForm::second_paint_event(GPaintEvent& event) +void VBForm::second_paint_event(GUI::PaintEvent& event) { - GPainter painter(*this); + GUI::Painter painter(*this); painter.add_clip_rect(event.rect()); for (auto& widget : m_widgets) { @@ -140,7 +140,7 @@ bool VBForm::is_selected(const VBWidget& widget) const VBWidget* VBForm::widget_at(const Point& position) { - auto result = hit_test(position, GWidget::ShouldRespectGreediness::No); + auto result = hit_test(position, GUI::Widget::ShouldRespectGreediness::No); if (!result.widget) return nullptr; auto* gwidget = result.widget; @@ -152,14 +152,14 @@ VBWidget* VBForm::widget_at(const Point& position) return nullptr; } -void VBForm::grabber_mousedown_event(GMouseEvent& event, Direction grabber) +void VBForm::grabber_mousedown_event(GUI::MouseEvent& event, Direction grabber) { m_transform_event_origin = event.position(); for_each_selected_widget([](auto& widget) { widget.capture_transform_origin_rect(); }); m_resize_direction = grabber; } -void VBForm::keydown_event(GKeyEvent& event) +void VBForm::keydown_event(GUI::KeyEvent& event) { if (event.key() == KeyCode::Key_Delete) { delete_selected_widgets(); @@ -252,7 +252,7 @@ void VBForm::remove_from_selection(VBWidget& widget) update(); } -void VBForm::mousedown_event(GMouseEvent& event) +void VBForm::mousedown_event(GUI::MouseEvent& event) { if (m_resize_direction == Direction::None) { bool hit_grabber = false; @@ -273,7 +273,7 @@ void VBForm::mousedown_event(GMouseEvent& event) set_single_selected_widget(nullptr); return; } - if (event.button() == GMouseButton::Left || event.button() == GMouseButton::Right) { + if (event.button() == GUI::MouseButton::Left || event.button() == GUI::MouseButton::Right) { m_transform_event_origin = event.position(); if (event.modifiers() == Mod_Ctrl) remove_from_selection(*widget); @@ -286,9 +286,9 @@ void VBForm::mousedown_event(GMouseEvent& event) } } -void VBForm::mousemove_event(GMouseEvent& event) +void VBForm::mousemove_event(GUI::MouseEvent& event) { - if (event.buttons() & GMouseButton::Left) { + if (event.buttons() & GUI::MouseButton::Left) { if (m_resize_direction == Direction::None) { update(); auto delta = event.position() - m_transform_event_origin; @@ -383,7 +383,7 @@ void VBForm::load_from_file(const String& path) { auto file = Core::File::construct(path); if (!file->open(Core::IODevice::ReadOnly)) { - GMessageBox::show(String::format("Could not open '%s' for reading", path.characters()), "Error", GMessageBox::Type::Error, GMessageBox::InputType::OK, window()); + GUI::MessageBox::show(String::format("Could not open '%s' for reading", path.characters()), "Error", GUI::MessageBox::Type::Error, GUI::MessageBox::InputType::OK, window()); return; } @@ -391,7 +391,7 @@ void VBForm::load_from_file(const String& path) auto form_json = JsonValue::from_string(file_contents); if (!form_json.is_object()) { - GMessageBox::show(String::format("Could not parse '%s'", path.characters()), "Error", GMessageBox::Type::Error, GMessageBox::InputType::OK, window()); + GUI::MessageBox::show(String::format("Could not parse '%s'", path.characters()), "Error", GUI::MessageBox::Type::Error, GUI::MessageBox::InputType::OK, window()); return; } @@ -419,7 +419,7 @@ void VBForm::write_to_file(const String& path) { auto file = Core::File::construct(path); if (!file->open(Core::IODevice::WriteOnly)) { - GMessageBox::show(String::format("Could not open '%s' for writing", path.characters()), "Error", GMessageBox::Type::Error, GMessageBox::InputType::OK, window()); + GUI::MessageBox::show(String::format("Could not open '%s' for writing", path.characters()), "Error", GUI::MessageBox::Type::Error, GUI::MessageBox::InputType::OK, window()); return; } @@ -459,9 +459,9 @@ void VBForm::dump() } } -void VBForm::mouseup_event(GMouseEvent& event) +void VBForm::mouseup_event(GUI::MouseEvent& event) { - if (event.button() == GMouseButton::Left) { + if (event.button() == GUI::MouseButton::Left) { m_transform_event_origin = {}; m_resize_direction = Direction::None; } @@ -496,22 +496,22 @@ void VBForm::set_cursor_type_from_grabber(Direction grabber) switch (grabber) { case Direction::Up: case Direction::Down: - window()->set_override_cursor(GStandardCursor::ResizeVertical); + window()->set_override_cursor(GUI::StandardCursor::ResizeVertical); break; case Direction::Left: case Direction::Right: - window()->set_override_cursor(GStandardCursor::ResizeHorizontal); + window()->set_override_cursor(GUI::StandardCursor::ResizeHorizontal); break; case Direction::UpLeft: case Direction::DownRight: - window()->set_override_cursor(GStandardCursor::ResizeDiagonalTLBR); + window()->set_override_cursor(GUI::StandardCursor::ResizeDiagonalTLBR); break; case Direction::UpRight: case Direction::DownLeft: - window()->set_override_cursor(GStandardCursor::ResizeDiagonalBLTR); + window()->set_override_cursor(GUI::StandardCursor::ResizeDiagonalBLTR); break; case Direction::None: - window()->set_override_cursor(GStandardCursor::None); + window()->set_override_cursor(GUI::StandardCursor::None); break; } diff --git a/DevTools/VisualBuilder/VBForm.h b/DevTools/VisualBuilder/VBForm.h index 908e830d7ac..4b49908fbb6 100644 --- a/DevTools/VisualBuilder/VBForm.h +++ b/DevTools/VisualBuilder/VBForm.h @@ -30,11 +30,11 @@ #include #include -class VBForm : public GWidget { +class VBForm : public GUI::Widget { C_OBJECT(VBForm) friend class VBWidget; public: - explicit VBForm(const String& name, GWidget* parent = nullptr); + explicit VBForm(const String& name, GUI::Widget* parent = nullptr); virtual ~VBForm() override; static VBForm* current(); @@ -57,16 +57,16 @@ public: void dump(); protected: - virtual void paint_event(GPaintEvent&) override; - virtual void second_paint_event(GPaintEvent&) override; - virtual void mousedown_event(GMouseEvent&) override; - virtual void mousemove_event(GMouseEvent&) override; - virtual void mouseup_event(GMouseEvent&) override; - virtual void context_menu_event(GContextMenuEvent&) override; - virtual void keydown_event(GKeyEvent&) override; + virtual void paint_event(GUI::PaintEvent&) override; + virtual void second_paint_event(GUI::PaintEvent&) override; + virtual void mousedown_event(GUI::MouseEvent&) override; + virtual void mousemove_event(GUI::MouseEvent&) override; + virtual void mouseup_event(GUI::MouseEvent&) override; + virtual void context_menu_event(GUI::ContextMenuEvent&) override; + virtual void keydown_event(GUI::KeyEvent&) override; private: - void grabber_mousedown_event(GMouseEvent&, Direction grabber); + void grabber_mousedown_event(GUI::MouseEvent&, Direction grabber); void set_single_selected_widget(VBWidget*); void add_to_selection(VBWidget&); void remove_from_selection(VBWidget&); @@ -81,11 +81,11 @@ private: int m_grid_size { 5 }; bool m_should_snap_to_grid { true }; NonnullRefPtrVector m_widgets; - HashMap m_gwidget_map; + HashMap m_gwidget_map; HashTable m_selected_widgets; Point m_transform_event_origin; Point m_next_insertion_position; Direction m_resize_direction { Direction::None }; Direction m_mouse_direction_type { Direction::None }; - RefPtr m_context_menu; + RefPtr m_context_menu; }; diff --git a/DevTools/VisualBuilder/VBPropertiesWindow.cpp b/DevTools/VisualBuilder/VBPropertiesWindow.cpp index 08da65f0827..ab1fc4ed076 100644 --- a/DevTools/VisualBuilder/VBPropertiesWindow.cpp +++ b/DevTools/VisualBuilder/VBPropertiesWindow.cpp @@ -33,12 +33,12 @@ #include #include -class BoolValuesModel final : public GModel { +class BoolValuesModel final : public GUI::Model { public: - virtual int row_count(const GModelIndex&) const override { return 2; } - virtual int column_count(const GModelIndex&) const override { return 1; } + virtual int row_count(const GUI::ModelIndex&) const override { return 2; } + virtual int column_count(const GUI::ModelIndex&) const override { return 1; } virtual void update() override {} - virtual GVariant data(const GModelIndex& index, Role role) const override + virtual GUI::Variant data(const GUI::ModelIndex& index, Role role) const override { if (role != Role::Display) return {}; @@ -52,25 +52,25 @@ public: } }; -class BoolModelEditingDelegate : public GModelEditingDelegate { +class BoolModelEditingDelegate : public GUI::ModelEditingDelegate { public: BoolModelEditingDelegate() {} virtual ~BoolModelEditingDelegate() override {} - virtual RefPtr create_widget() override + virtual RefPtr create_widget() override { - auto combo = GComboBox::construct(nullptr); + auto combo = GUI::ComboBox::construct(nullptr); combo->set_only_allow_values_from_model(true); combo->set_model(adopt(*new BoolValuesModel)); combo->on_return_pressed = [this] { commit(); }; combo->on_change = [this](auto&, auto&) { commit(); }; return combo; } - virtual GVariant value() const override { return static_cast(widget())->text() == "true"; } - virtual void set_value(const GVariant& value) override { static_cast(widget())->set_text(value.to_string()); } + virtual GUI::Variant value() const override { return static_cast(widget())->text() == "true"; } + virtual void set_value(const GUI::Variant& value) override { static_cast(widget())->set_text(value.to_string()); } virtual void will_begin_editing() override { - auto& combo = *static_cast(widget()); + auto& combo = *static_cast(widget()); combo.select_all(); combo.open(); } @@ -81,26 +81,26 @@ VBPropertiesWindow::VBPropertiesWindow() set_title("Properties"); set_rect(780, 200, 240, 280); - auto widget = GWidget::construct(); + auto widget = GUI::Widget::construct(); widget->set_fill_with_background_color(true); - widget->set_layout(make()); + widget->set_layout(make()); widget->layout()->set_margins({ 2, 2, 2, 2 }); set_main_widget(widget); - m_table_view = GTableView::construct(widget); + m_table_view = GUI::TableView::construct(widget); m_table_view->set_headers_visible(false); m_table_view->set_editable(true); - m_table_view->aid_create_editing_delegate = [this](auto& index) -> OwnPtr { + m_table_view->aid_create_editing_delegate = [this](auto& index) -> OwnPtr { if (!m_table_view->model()) return nullptr; auto type_index = m_table_view->model()->index(index.row(), VBWidgetPropertyModel::Column::Type); - auto type = m_table_view->model()->data(type_index, GModel::Role::Custom).to_i32(); - switch ((GVariant::Type)type) { - case GVariant::Type::Bool: + auto type = m_table_view->model()->data(type_index, GUI::Model::Role::Custom).to_i32(); + switch ((GUI::Variant::Type)type) { + case GUI::Variant::Type::Bool: return make(); default: - return make(); + return make(); } }; } diff --git a/DevTools/VisualBuilder/VBPropertiesWindow.h b/DevTools/VisualBuilder/VBPropertiesWindow.h index 8601542617e..4ae1be9acce 100644 --- a/DevTools/VisualBuilder/VBPropertiesWindow.h +++ b/DevTools/VisualBuilder/VBPropertiesWindow.h @@ -28,18 +28,20 @@ #include -class GTableView; -class GTextBox; +namespace GUI { +class TableView; +class TextBox; +} -class VBPropertiesWindow final : public GWindow { +class VBPropertiesWindow final : public GUI::Window { C_OBJECT(VBPropertiesWindow) public: VBPropertiesWindow(); virtual ~VBPropertiesWindow() override; - GTableView& table_view() { return *m_table_view; } - const GTableView& table_view() const { return *m_table_view; } + GUI::TableView& table_view() { return *m_table_view; } + const GUI::TableView& table_view() const { return *m_table_view; } private: - RefPtr m_table_view; + RefPtr m_table_view; }; diff --git a/DevTools/VisualBuilder/VBProperty.cpp b/DevTools/VisualBuilder/VBProperty.cpp index 4ab874cfc5f..96e352aa3b6 100644 --- a/DevTools/VisualBuilder/VBProperty.cpp +++ b/DevTools/VisualBuilder/VBProperty.cpp @@ -27,14 +27,14 @@ #include "VBProperty.h" #include "VBWidget.h" -VBProperty::VBProperty(VBWidget& widget, const String& name, const GVariant& value) +VBProperty::VBProperty(VBWidget& widget, const String& name, const GUI::Variant& value) : m_widget(widget) , m_name(name) , m_value(value) { } -VBProperty::VBProperty(VBWidget& widget, const String& name, Function&& getter, Function&& setter) +VBProperty::VBProperty(VBWidget& widget, const String& name, Function&& getter, Function&& setter) : m_widget(widget) , m_name(name) , m_getter(move(getter)) @@ -48,7 +48,7 @@ VBProperty::~VBProperty() { } -void VBProperty::set_value(const GVariant& value) +void VBProperty::set_value(const GUI::Variant& value) { if (m_value == value) return; diff --git a/DevTools/VisualBuilder/VBProperty.h b/DevTools/VisualBuilder/VBProperty.h index 0a0f0fc851a..c84660744b1 100644 --- a/DevTools/VisualBuilder/VBProperty.h +++ b/DevTools/VisualBuilder/VBProperty.h @@ -26,24 +26,27 @@ #pragma once -#include #include +#include #include -class GWidget; +namespace GUI { +class Widget; +} + class VBWidget; class VBProperty { friend class VBWidget; public: - VBProperty(VBWidget&, const String& name, const GVariant& value); - VBProperty(VBWidget&, const String& name, Function&& getter, Function&& setter); + VBProperty(VBWidget&, const String& name, const GUI::Variant& value); + VBProperty(VBWidget&, const String& name, Function&& getter, Function&& setter); ~VBProperty(); String name() const { return m_name; } - const GVariant& value() const { return m_value; } - void set_value(const GVariant&); + const GUI::Variant& value() const { return m_value; } + void set_value(const GUI::Variant&); bool is_readonly() const { return m_readonly; } void set_readonly(bool b) { m_readonly = b; } @@ -53,8 +56,8 @@ public: private: VBWidget& m_widget; String m_name; - GVariant m_value; - Function m_getter; - Function m_setter; + GUI::Variant m_value; + Function m_getter; + Function m_setter; bool m_readonly { false }; }; diff --git a/DevTools/VisualBuilder/VBWidget.cpp b/DevTools/VisualBuilder/VBWidget.cpp index 52279c1740e..3cac9cc6da7 100644 --- a/DevTools/VisualBuilder/VBWidget.cpp +++ b/DevTools/VisualBuilder/VBWidget.cpp @@ -123,7 +123,7 @@ void VBWidget::for_each_property(Function callback) } } -void VBWidget::add_property(const String& name, Function&& getter, Function&& setter) +void VBWidget::add_property(const String& name, Function&& getter, Function&& setter) { auto& prop = property(name); prop.m_getter = move(getter); @@ -133,74 +133,74 @@ void VBWidget::add_property(const String& name, Function GVariant { return ((const gclass&)widget).getter(); }, \ + [](auto& widget) -> GUI::Variant { return ((const gclass&)widget).getter(); }, \ [](auto& widget, auto& value) { ((gclass&)widget).setter(value.to_##variant_type()); }) void VBWidget::setup_properties() { VB_ADD_PROPERTY(Core::Object, "name", name, set_name, string); - VB_ADD_PROPERTY(GWidget, "width", width, set_width, i32); - VB_ADD_PROPERTY(GWidget, "height", height, set_height, i32); - VB_ADD_PROPERTY(GWidget, "x", x, set_x, i32); - VB_ADD_PROPERTY(GWidget, "y", y, set_y, i32); - VB_ADD_PROPERTY(GWidget, "visible", is_visible, set_visible, bool); - VB_ADD_PROPERTY(GWidget, "enabled", is_enabled, set_enabled, bool); - VB_ADD_PROPERTY(GWidget, "tooltip", tooltip, set_tooltip, string); - VB_ADD_PROPERTY(GWidget, "backcolor", background_color, set_background_color, color); - VB_ADD_PROPERTY(GWidget, "forecolor", foreground_color, set_foreground_color, color); - VB_ADD_PROPERTY(GWidget, "autofill", fill_with_background_color, set_fill_with_background_color, bool); + VB_ADD_PROPERTY(GUI::Widget, "width", width, set_width, i32); + VB_ADD_PROPERTY(GUI::Widget, "height", height, set_height, i32); + VB_ADD_PROPERTY(GUI::Widget, "x", x, set_x, i32); + VB_ADD_PROPERTY(GUI::Widget, "y", y, set_y, i32); + VB_ADD_PROPERTY(GUI::Widget, "visible", is_visible, set_visible, bool); + VB_ADD_PROPERTY(GUI::Widget, "enabled", is_enabled, set_enabled, bool); + VB_ADD_PROPERTY(GUI::Widget, "tooltip", tooltip, set_tooltip, string); + VB_ADD_PROPERTY(GUI::Widget, "backcolor", background_color, set_background_color, color); + VB_ADD_PROPERTY(GUI::Widget, "forecolor", foreground_color, set_foreground_color, color); + VB_ADD_PROPERTY(GUI::Widget, "autofill", fill_with_background_color, set_fill_with_background_color, bool); if (m_type == VBWidgetType::GLabel) { - VB_ADD_PROPERTY(GLabel, "text", text, set_text, string); + VB_ADD_PROPERTY(GUI::Label, "text", text, set_text, string); } if (m_type == VBWidgetType::GButton) { - VB_ADD_PROPERTY(GButton, "text", text, set_text, string); + VB_ADD_PROPERTY(GUI::Button, "text", text, set_text, string); } if (m_type == VBWidgetType::GGroupBox) { - VB_ADD_PROPERTY(GGroupBox, "title", title, set_title, string); + VB_ADD_PROPERTY(GUI::GroupBox, "title", title, set_title, string); } if (m_type == VBWidgetType::GScrollBar) { - VB_ADD_PROPERTY(GScrollBar, "min", min, set_min, i32); - VB_ADD_PROPERTY(GScrollBar, "max", max, set_max, i32); - VB_ADD_PROPERTY(GScrollBar, "value", value, set_value, i32); - VB_ADD_PROPERTY(GScrollBar, "step", step, set_step, i32); + VB_ADD_PROPERTY(GUI::ScrollBar, "min", min, set_min, i32); + VB_ADD_PROPERTY(GUI::ScrollBar, "max", max, set_max, i32); + VB_ADD_PROPERTY(GUI::ScrollBar, "value", value, set_value, i32); + VB_ADD_PROPERTY(GUI::ScrollBar, "step", step, set_step, i32); } if (m_type == VBWidgetType::GSpinBox) { - VB_ADD_PROPERTY(GSpinBox, "min", min, set_min, i32); - VB_ADD_PROPERTY(GSpinBox, "max", max, set_max, i32); - VB_ADD_PROPERTY(GSpinBox, "value", value, set_value, i32); + VB_ADD_PROPERTY(GUI::SpinBox, "min", min, set_min, i32); + VB_ADD_PROPERTY(GUI::SpinBox, "max", max, set_max, i32); + VB_ADD_PROPERTY(GUI::SpinBox, "value", value, set_value, i32); } if (m_type == VBWidgetType::GProgressBar) { - VB_ADD_PROPERTY(GProgressBar, "min", min, set_min, i32); - VB_ADD_PROPERTY(GProgressBar, "max", max, set_max, i32); - VB_ADD_PROPERTY(GProgressBar, "value", value, set_value, i32); + VB_ADD_PROPERTY(GUI::ProgressBar, "min", min, set_min, i32); + VB_ADD_PROPERTY(GUI::ProgressBar, "max", max, set_max, i32); + VB_ADD_PROPERTY(GUI::ProgressBar, "value", value, set_value, i32); } if (m_type == VBWidgetType::GSlider) { - VB_ADD_PROPERTY(GSlider, "min", min, set_min, i32); - VB_ADD_PROPERTY(GSlider, "max", max, set_max, i32); - VB_ADD_PROPERTY(GSlider, "value", value, set_value, i32); + VB_ADD_PROPERTY(GUI::Slider, "min", min, set_min, i32); + VB_ADD_PROPERTY(GUI::Slider, "max", max, set_max, i32); + VB_ADD_PROPERTY(GUI::Slider, "value", value, set_value, i32); } if (m_type == VBWidgetType::GTextEditor) { - VB_ADD_PROPERTY(GTextEditor, "text", text, set_text, string); - VB_ADD_PROPERTY(GTextEditor, "ruler_visible", is_ruler_visible, set_ruler_visible, bool); + VB_ADD_PROPERTY(GUI::TextEditor, "text", text, set_text, string); + VB_ADD_PROPERTY(GUI::TextEditor, "ruler_visible", is_ruler_visible, set_ruler_visible, bool); } if (m_type == VBWidgetType::GCheckBox) { - VB_ADD_PROPERTY(GCheckBox, "text", text, set_text, string); - VB_ADD_PROPERTY(GCheckBox, "checked", is_checked, set_checked, bool); + VB_ADD_PROPERTY(GUI::CheckBox, "text", text, set_text, string); + VB_ADD_PROPERTY(GUI::CheckBox, "checked", is_checked, set_checked, bool); } if (m_type == VBWidgetType::GRadioButton) { - VB_ADD_PROPERTY(GRadioButton, "text", text, set_text, string); - VB_ADD_PROPERTY(GRadioButton, "checked", is_checked, set_checked, bool); + VB_ADD_PROPERTY(GUI::RadioButton, "text", text, set_text, string); + VB_ADD_PROPERTY(GUI::RadioButton, "checked", is_checked, set_checked, bool); } } @@ -220,7 +220,7 @@ VBProperty& VBWidget::property(const String& name) if (prop.name() == name) return prop; } - m_properties.append(make(*this, name, GVariant())); + m_properties.append(make(*this, name, GUI::Variant())); return m_properties.last(); } diff --git a/DevTools/VisualBuilder/VBWidget.h b/DevTools/VisualBuilder/VBWidget.h index 89fcf504ac9..11870161871 100644 --- a/DevTools/VisualBuilder/VBWidget.h +++ b/DevTools/VisualBuilder/VBWidget.h @@ -36,8 +36,11 @@ #include #include -class GPainter; -class GVariant; +namespace GUI { +class Painter; +class Variant; +} + class VBForm; class VBProperty; class VBWidgetPropertyModel; @@ -82,7 +85,7 @@ public: Rect grabber_rect(Direction) const; Direction grabber_at(const Point&) const; - GWidget* gwidget() { return m_gwidget; } + GUI::Widget* gwidget() { return m_gwidget; } VBProperty& property(const String&); @@ -103,11 +106,11 @@ public: private: VBWidget(VBWidgetType, VBForm&, VBWidget* parent); - void add_property(const String& name, Function&& getter, Function&& setter); + void add_property(const String& name, Function&& getter, Function&& setter); VBWidgetType m_type { VBWidgetType::None }; VBForm& m_form; - RefPtr m_gwidget; + RefPtr m_gwidget; NonnullOwnPtrVector m_properties; NonnullRefPtr m_property_model; Rect m_transform_origin_rect; diff --git a/DevTools/VisualBuilder/VBWidgetPropertyModel.cpp b/DevTools/VisualBuilder/VBWidgetPropertyModel.cpp index 090c5cb854a..4f366ceff5e 100644 --- a/DevTools/VisualBuilder/VBWidgetPropertyModel.cpp +++ b/DevTools/VisualBuilder/VBWidgetPropertyModel.cpp @@ -38,7 +38,7 @@ VBWidgetPropertyModel::~VBWidgetPropertyModel() { } -int VBWidgetPropertyModel::row_count(const GModelIndex&) const +int VBWidgetPropertyModel::row_count(const GUI::ModelIndex&) const { return m_widget.m_properties.size(); } @@ -57,7 +57,7 @@ String VBWidgetPropertyModel::column_name(int column) const } } -GModel::ColumnMetadata VBWidgetPropertyModel::column_metadata(int column) const +GUI::Model::ColumnMetadata VBWidgetPropertyModel::column_metadata(int column) const { UNUSED_PARAM(column); if (column == Column::Name) @@ -65,7 +65,7 @@ GModel::ColumnMetadata VBWidgetPropertyModel::column_metadata(int column) const return { 90, TextAlignment::CenterLeft }; } -GVariant VBWidgetPropertyModel::data(const GModelIndex& index, Role role) const +GUI::Variant VBWidgetPropertyModel::data(const GUI::ModelIndex& index, Role role) const { if (role == Role::Custom) { auto& property = m_widget.m_properties[index.row()]; @@ -100,7 +100,7 @@ GVariant VBWidgetPropertyModel::data(const GModelIndex& index, Role role) const return {}; } -void VBWidgetPropertyModel::set_data(const GModelIndex& index, const GVariant& value) +void VBWidgetPropertyModel::set_data(const GUI::ModelIndex& index, const GUI::Variant& value) { ASSERT(index.column() == Column::Value); auto& property = m_widget.m_properties[index.row()]; @@ -108,7 +108,7 @@ void VBWidgetPropertyModel::set_data(const GModelIndex& index, const GVariant& v property.set_value(value); } -bool VBWidgetPropertyModel::is_editable(const GModelIndex& index) const +bool VBWidgetPropertyModel::is_editable(const GUI::ModelIndex& index) const { if (index.column() != Column::Value) return false; diff --git a/DevTools/VisualBuilder/VBWidgetPropertyModel.h b/DevTools/VisualBuilder/VBWidgetPropertyModel.h index e7c7ae97bfc..ec04cee905d 100644 --- a/DevTools/VisualBuilder/VBWidgetPropertyModel.h +++ b/DevTools/VisualBuilder/VBWidgetPropertyModel.h @@ -31,7 +31,7 @@ class VBWidget; class VBProperty; -class VBWidgetPropertyModel : public GModel { +class VBWidgetPropertyModel : public GUI::Model { public: enum Column { Name = 0, @@ -43,14 +43,14 @@ public: static NonnullRefPtr create(VBWidget& widget) { return adopt(*new VBWidgetPropertyModel(widget)); } virtual ~VBWidgetPropertyModel() override; - virtual int row_count(const GModelIndex&) const override; - virtual int column_count(const GModelIndex&) const override { return Column::__Count; } + virtual int row_count(const GUI::ModelIndex&) const override; + virtual int column_count(const GUI::ModelIndex&) const override { return Column::__Count; } virtual String column_name(int column) const override; virtual ColumnMetadata column_metadata(int column) const override; - virtual GVariant data(const GModelIndex&, Role = Role::Display) const override; + virtual GUI::Variant data(const GUI::ModelIndex&, Role = Role::Display) const override; virtual void update() override { did_update(); } - virtual bool is_editable(const GModelIndex&) const override; - virtual void set_data(const GModelIndex&, const GVariant&) override; + virtual bool is_editable(const GUI::ModelIndex&) const override; + virtual void set_data(const GUI::ModelIndex&, const GUI::Variant&) override; private: explicit VBWidgetPropertyModel(VBWidget&); diff --git a/DevTools/VisualBuilder/VBWidgetRegistry.cpp b/DevTools/VisualBuilder/VBWidgetRegistry.cpp index f5ca0cc2da8..a62d24984e6 100644 --- a/DevTools/VisualBuilder/VBWidgetRegistry.cpp +++ b/DevTools/VisualBuilder/VBWidgetRegistry.cpp @@ -41,7 +41,7 @@ String to_class_name(VBWidgetType type) { switch (type) { case VBWidgetType::GWidget: - return "GWidget"; + return "GUI::Widget"; case VBWidgetType::GButton: return "GButton"; case VBWidgetType::GLabel: @@ -69,7 +69,7 @@ String to_class_name(VBWidgetType type) VBWidgetType widget_type_from_class_name(const StringView& name) { - if (name == "GWidget") + if (name == "GUI::Widget") return VBWidgetType::GWidget; if (name == "GButton") return VBWidgetType::GButton; @@ -94,67 +94,67 @@ VBWidgetType widget_type_from_class_name(const StringView& name) ASSERT_NOT_REACHED(); } -static RefPtr build_gwidget(VBWidgetType type, GWidget* parent) +static RefPtr build_gwidget(VBWidgetType type, GUI::Widget* parent) { switch (type) { case VBWidgetType::GWidget: - return GWidget::construct(parent); + return GUI::Widget::construct(parent); case VBWidgetType::GScrollBar: - return GScrollBar::construct(Orientation::Vertical, parent); + return GUI::ScrollBar::construct(Orientation::Vertical, parent); case VBWidgetType::GGroupBox: - return GGroupBox::construct("groupbox_1", parent); + return GUI::GroupBox::construct("groupbox_1", parent); case VBWidgetType::GLabel: { - auto label = GLabel::construct(parent); + auto label = GUI::Label::construct(parent); label->set_fill_with_background_color(true); label->set_text("label_1"); return label; } case VBWidgetType::GButton: { - auto button = GButton::construct(parent); + auto button = GUI::Button::construct(parent); button->set_text("button_1"); return button; } case VBWidgetType::GSpinBox: { - auto box = GSpinBox::construct(parent); + auto box = GUI::SpinBox::construct(parent); box->set_range(0, 100); box->set_value(0); return box; } case VBWidgetType::GTextEditor: { - auto editor = GTextEditor::construct(GTextEditor::Type::MultiLine, parent); + auto editor = GUI::TextEditor::construct(GUI::TextEditor::Type::MultiLine, parent); editor->set_ruler_visible(false); return editor; } case VBWidgetType::GProgressBar: { - auto bar = GProgressBar::construct(parent); - bar->set_format(GProgressBar::Format::NoText); + auto bar = GUI::ProgressBar::construct(parent); + bar->set_format(GUI::ProgressBar::Format::NoText); bar->set_range(0, 100); bar->set_value(50); return bar; } case VBWidgetType::GSlider: { - auto slider = GSlider::construct(Orientation::Horizontal, parent); + auto slider = GUI::Slider::construct(Orientation::Horizontal, parent); slider->set_range(0, 100); slider->set_value(50); return slider; } case VBWidgetType::GCheckBox: { - auto box = GCheckBox::construct(parent); + auto box = GUI::CheckBox::construct(parent); box->set_text("checkbox_1"); return box; } case VBWidgetType::GRadioButton: - return GRadioButton::construct("radio_1", parent); + return GUI::RadioButton::construct("radio_1", parent); default: ASSERT_NOT_REACHED(); return nullptr; } } -RefPtr VBWidgetRegistry::build_gwidget(VBWidget& widget, VBWidgetType type, GWidget* parent, NonnullOwnPtrVector& properties) +RefPtr VBWidgetRegistry::build_gwidget(VBWidget& widget, VBWidgetType type, GUI::Widget* parent, NonnullOwnPtrVector& properties) { auto gwidget = ::build_gwidget(type, parent); - auto add_readonly_property = [&](const String& name, const GVariant& value) { + auto add_readonly_property = [&](const String& name, const GUI::Variant& value) { auto property = make(widget, name, value); property->set_readonly(true); properties.append(move(property)); diff --git a/DevTools/VisualBuilder/VBWidgetRegistry.h b/DevTools/VisualBuilder/VBWidgetRegistry.h index 29fb0e0f42e..189b5b2e808 100644 --- a/DevTools/VisualBuilder/VBWidgetRegistry.h +++ b/DevTools/VisualBuilder/VBWidgetRegistry.h @@ -45,7 +45,7 @@ public: callback((VBWidgetType)i); } - static RefPtr build_gwidget(VBWidget&, VBWidgetType, GWidget* parent, NonnullOwnPtrVector&); + static RefPtr build_gwidget(VBWidget&, VBWidgetType, GUI::Widget* parent, NonnullOwnPtrVector&); }; String to_class_name(VBWidgetType); diff --git a/DevTools/VisualBuilder/main.cpp b/DevTools/VisualBuilder/main.cpp index fc971c2189d..10d707dee8c 100644 --- a/DevTools/VisualBuilder/main.cpp +++ b/DevTools/VisualBuilder/main.cpp @@ -43,11 +43,11 @@ #include #include -static RefPtr make_toolbox_window(); +static RefPtr make_toolbox_window(); int main(int argc, char** argv) { - GApplication app(argc, argv); + GUI::Application app(argc, argv); auto propbox = VBPropertiesWindow::construct(); @@ -56,33 +56,33 @@ int main(int argc, char** argv) propbox->table_view().set_model(widget ? &widget->property_model() : nullptr); }; - auto menubar = make(); - auto app_menu = GMenu::construct("Visual Builder"); - app_menu->add_action(GCommonActions::make_quit_action([](auto&) { - GApplication::the().quit(0); + auto menubar = make(); + auto app_menu = GUI::Menu::construct("Visual Builder"); + app_menu->add_action(GUI::CommonActions::make_quit_action([](auto&) { + GUI::Application::the().quit(0); return; })); menubar->add_menu(move(app_menu)); - auto file_menu = GMenu::construct("File"); - file_menu->add_action(GAction::create("Dump Form", [&](auto&) { + auto file_menu = GUI::Menu::construct("File"); + file_menu->add_action(GUI::Action::create("Dump Form", [&](auto&) { form1->dump(); })); - file_menu->add_action(GAction::create("Save Form...", { Mod_Ctrl, Key_S }, [&](auto&) { + file_menu->add_action(GUI::Action::create("Save Form...", { Mod_Ctrl, Key_S }, [&](auto&) { form1->write_to_file("/tmp/form.frm"); })); menubar->add_menu(move(file_menu)); - auto window = GWindow::construct(); + auto window = GUI::Window::construct(); window->set_title(form1->name()); window->set_rect(120, 200, 640, 400); window->set_main_widget(form1); window->show(); - auto help_menu = GMenu::construct("Help"); - help_menu->add_action(GAction::create("About", [&](const GAction&) { - GAboutDialog::show("Visual Builder", load_png("/res/icons/32x32/app-visual-builder.png"), window); + auto help_menu = GUI::Menu::construct("Help"); + help_menu->add_action(GUI::Action::create("About", [&](const GUI::Action&) { + GUI::AboutDialog::show("Visual Builder", load_png("/res/icons/32x32/app-visual-builder.png"), window); })); menubar->add_menu(move(help_menu)); @@ -100,96 +100,96 @@ int main(int argc, char** argv) return app.exec(); } -RefPtr make_toolbox_window() +RefPtr make_toolbox_window() { - auto window = GWindow::construct(); + auto window = GUI::Window::construct(); window->set_title("Widgets"); window->set_rect(20, 200, 80, 300); - auto widget = GWidget::construct(); + auto widget = GUI::Widget::construct(); widget->set_fill_with_background_color(true); - widget->set_layout(make()); + widget->set_layout(make()); widget->layout()->set_spacing(0); window->set_main_widget(widget); - auto label_button = GButton::construct(widget); + auto label_button = GUI::Button::construct(widget); label_button->set_button_style(ButtonStyle::CoolBar); label_button->set_tooltip("GLabel"); label_button->set_icon(GraphicsBitmap::load_from_file("/res/icons/vbwidgets/label.png")); - label_button->on_click = [](GButton&) { + label_button->on_click = [](GUI::Button&) { if (auto* form = VBForm::current()) form->insert_widget(VBWidgetType::GLabel); }; - auto button_button = GButton::construct(widget); + auto button_button = GUI::Button::construct(widget); button_button->set_button_style(ButtonStyle::CoolBar); button_button->set_tooltip("GButton"); button_button->set_icon(GraphicsBitmap::load_from_file("/res/icons/vbwidgets/button.png")); - button_button->on_click = [](GButton&) { + button_button->on_click = [](GUI::Button&) { if (auto* form = VBForm::current()) form->insert_widget(VBWidgetType::GButton); }; - auto spinbox_button = GButton::construct(widget); + auto spinbox_button = GUI::Button::construct(widget); spinbox_button->set_button_style(ButtonStyle::CoolBar); spinbox_button->set_tooltip("GSpinBox"); spinbox_button->set_icon(GraphicsBitmap::load_from_file("/res/icons/vbwidgets/spinbox.png")); - spinbox_button->on_click = [](GButton&) { + spinbox_button->on_click = [](GUI::Button&) { if (auto* form = VBForm::current()) form->insert_widget(VBWidgetType::GSpinBox); }; - auto editor_button = GButton::construct(widget); + auto editor_button = GUI::Button::construct(widget); editor_button->set_button_style(ButtonStyle::CoolBar); editor_button->set_tooltip("GTextEditor"); editor_button->set_icon(GraphicsBitmap::load_from_file("/res/icons/vbwidgets/textbox.png")); - editor_button->on_click = [](GButton&) { + editor_button->on_click = [](GUI::Button&) { if (auto* form = VBForm::current()) form->insert_widget(VBWidgetType::GTextEditor); }; - auto progress_bar_button = GButton::construct(widget); + auto progress_bar_button = GUI::Button::construct(widget); progress_bar_button->set_button_style(ButtonStyle::CoolBar); progress_bar_button->set_tooltip("GProgressBar"); progress_bar_button->set_icon(GraphicsBitmap::load_from_file("/res/icons/vbwidgets/progressbar.png")); - progress_bar_button->on_click = [](GButton&) { + progress_bar_button->on_click = [](GUI::Button&) { if (auto* form = VBForm::current()) form->insert_widget(VBWidgetType::GProgressBar); }; - auto slider_button = GButton::construct(widget); + auto slider_button = GUI::Button::construct(widget); slider_button->set_button_style(ButtonStyle::CoolBar); slider_button->set_tooltip("GSlider"); slider_button->set_icon(GraphicsBitmap::load_from_file("/res/icons/vbwidgets/slider.png")); - slider_button->on_click = [](GButton&) { + slider_button->on_click = [](GUI::Button&) { if (auto* form = VBForm::current()) form->insert_widget(VBWidgetType::GSlider); }; - auto checkbox_button = GButton::construct(widget); + auto checkbox_button = GUI::Button::construct(widget); checkbox_button->set_button_style(ButtonStyle::CoolBar); checkbox_button->set_tooltip("GCheckBox"); checkbox_button->set_icon(GraphicsBitmap::load_from_file("/res/icons/vbwidgets/checkbox.png")); - checkbox_button->on_click = [](GButton&) { + checkbox_button->on_click = [](GUI::Button&) { if (auto* form = VBForm::current()) form->insert_widget(VBWidgetType::GCheckBox); }; - auto radiobutton_button = GButton::construct(widget); + auto radiobutton_button = GUI::Button::construct(widget); radiobutton_button->set_button_style(ButtonStyle::CoolBar); radiobutton_button->set_tooltip("GRadioButton"); radiobutton_button->set_icon(GraphicsBitmap::load_from_file("/res/icons/filled-radio-circle.png")); - radiobutton_button->on_click = [](GButton&) { + radiobutton_button->on_click = [](GUI::Button&) { if (auto* form = VBForm::current()) form->insert_widget(VBWidgetType::GRadioButton); }; - auto scrollbar_button = GButton::construct(widget); + auto scrollbar_button = GUI::Button::construct(widget); scrollbar_button->set_button_style(ButtonStyle::CoolBar); scrollbar_button->set_tooltip("GScrollBar"); scrollbar_button->set_icon(GraphicsBitmap::load_from_file("/res/icons/vbwidgets/scrollbar.png")); - scrollbar_button->on_click = [](GButton&) { + scrollbar_button->on_click = [](GUI::Button&) { if (auto* form = VBForm::current()) form->insert_widget(VBWidgetType::GScrollBar); }; - auto groupbox_button = GButton::construct(widget); + auto groupbox_button = GUI::Button::construct(widget); groupbox_button->set_button_style(ButtonStyle::CoolBar); groupbox_button->set_tooltip("GGroupBox"); groupbox_button->set_icon(GraphicsBitmap::load_from_file("/res/icons/vbwidgets/groupbox.png")); - groupbox_button->on_click = [](GButton&) { + groupbox_button->on_click = [](GUI::Button&) { if (auto* form = VBForm::current()) form->insert_widget(VBWidgetType::GGroupBox); }; diff --git a/Games/Minesweeper/Field.cpp b/Games/Minesweeper/Field.cpp index 9e1c1e41475..ef8074250a0 100644 --- a/Games/Minesweeper/Field.cpp +++ b/Games/Minesweeper/Field.cpp @@ -34,50 +34,50 @@ #include #include -class SquareButton final : public GButton { +class SquareButton final : public GUI::Button { public: - SquareButton(GWidget* parent) - : GButton(parent) + SquareButton(GUI::Widget* parent) + : GUI::Button(parent) { } Function on_right_click; Function on_middle_click; - virtual void mousedown_event(GMouseEvent& event) override + virtual void mousedown_event(GUI::MouseEvent& event) override { - if (event.button() == GMouseButton::Right) { + if (event.button() == GUI::MouseButton::Right) { if (on_right_click) on_right_click(); } - if (event.button() == GMouseButton::Middle) { + if (event.button() == GUI::MouseButton::Middle) { if (on_middle_click) on_middle_click(); } - GButton::mousedown_event(event); + GUI::Button::mousedown_event(event); } }; -class SquareLabel final : public GLabel { +class SquareLabel final : public GUI::Label { public: - SquareLabel(Square& square, GWidget* parent) - : GLabel(parent) + SquareLabel(Square& square, GUI::Widget* parent) + : GUI::Label(parent) , m_square(square) { } Function on_chord_click; - virtual void mousedown_event(GMouseEvent& event) override + virtual void mousedown_event(GUI::MouseEvent& event) override { - if (event.button() == GMouseButton::Right || event.button() == GMouseButton::Left) { - if (event.buttons() == (GMouseButton::Right | GMouseButton::Left) || + if (event.button() == GUI::MouseButton::Right || event.button() == GUI::MouseButton::Left) { + if (event.buttons() == (GUI::MouseButton::Right | GUI::MouseButton::Left) || m_square.field->is_single_chording()) { m_chord = true; m_square.field->set_chord_preview(m_square, true); } } - if (event.button() == GMouseButton::Middle) { + if (event.button() == GUI::MouseButton::Middle) { m_square.field->for_each_square([](auto& square) { if (square.is_considering) { square.is_considering = false; @@ -85,10 +85,10 @@ public: } }); } - GLabel::mousedown_event(event); + GUI::Label::mousedown_event(event); } - virtual void mousemove_event(GMouseEvent& event) override + virtual void mousemove_event(GUI::MouseEvent& event) override { if (m_chord) { if (rect().contains(event.position())) { @@ -97,13 +97,13 @@ public: m_square.field->set_chord_preview(m_square, false); } } - GLabel::mousemove_event(event); + GUI::Label::mousemove_event(event); } - virtual void mouseup_event(GMouseEvent& event) override + virtual void mouseup_event(GUI::MouseEvent& event) override { if (m_chord) { - if (event.button() == GMouseButton::Left || event.button() == GMouseButton::Right) { + if (event.button() == GUI::MouseButton::Left || event.button() == GUI::MouseButton::Right) { if (rect().contains(event.position())) { if (on_chord_click) on_chord_click(); @@ -112,15 +112,15 @@ public: } } m_square.field->set_chord_preview(m_square, m_chord); - GLabel::mouseup_event(event); + GUI::Label::mouseup_event(event); } Square& m_square; bool m_chord { false }; }; -Field::Field(GLabel& flag_label, GLabel& time_label, GButton& face_button, GWidget* parent, Function on_size_changed) - : GFrame(parent) +Field::Field(GUI::Label& flag_label, GUI::Label& time_label, GUI::Button& face_button, GUI::Widget* parent, Function on_size_changed) + : GUI::Frame(parent) , m_face_button(face_button) , m_flag_label(flag_label) , m_time_label(time_label) @@ -256,7 +256,7 @@ void Field::reset() square.label->set_icon(square.has_mine ? m_mine_bitmap : nullptr); if (!square.button) { square.button = new SquareButton(this); - square.button->on_click = [this, &square](GButton&) { + square.button->on_click = [this, &square](GUI::Button&) { on_square_clicked(square); }; square.button->on_right_click = [this, &square] { @@ -315,10 +315,10 @@ void Field::flood_fill(Square& square) } } -void Field::paint_event(GPaintEvent& event) +void Field::paint_event(GUI::PaintEvent& event) { - GFrame::paint_event(event); - GPainter painter(*this); + GUI::Frame::paint_event(event); + GUI::Painter painter(*this); painter.add_clip_rect(event.rect()); auto inner_rect = frame_inner_rect(); diff --git a/Games/Minesweeper/Field.h b/Games/Minesweeper/Field.h index 587bf27e220..7aa0b26fd34 100644 --- a/Games/Minesweeper/Field.h +++ b/Games/Minesweeper/Field.h @@ -30,9 +30,12 @@ #include #include +namespace GUI { +class Button; +class Label; +} + class Field; -class GButton; -class GLabel; class SquareButton; class SquareLabel; @@ -57,12 +60,12 @@ public: void for_each_neighbor(Callback); }; -class Field final : public GFrame { +class Field final : public GUI::Frame { C_OBJECT(Field) friend class Square; friend class SquareLabel; public: - Field(GLabel& flag_label, GLabel& time_label, GButton& face_button, GWidget* parent, Function on_size_changed); + Field(GUI::Label& flag_label, GUI::Label& time_label, GUI::Button& face_button, GUI::Widget* parent, Function on_size_changed); virtual ~Field() override; int rows() const { return m_rows; } @@ -77,7 +80,7 @@ public: void reset(); private: - virtual void paint_event(GPaintEvent&) override; + virtual void paint_event(GUI::PaintEvent&) override; void on_square_clicked(Square&); void on_square_right_clicked(Square&); @@ -118,9 +121,9 @@ private: RefPtr m_good_face_bitmap; RefPtr m_bad_face_bitmap; RefPtr m_number_bitmap[8]; - GButton& m_face_button; - GLabel& m_flag_label; - GLabel& m_time_label; + GUI::Button& m_face_button; + GUI::Label& m_flag_label; + GUI::Label& m_time_label; RefPtr m_timer; int m_time_elapsed { 0 }; int m_flags_left { 0 }; diff --git a/Games/Minesweeper/main.cpp b/Games/Minesweeper/main.cpp index 1a1dd29b5fc..58bfc99ac75 100644 --- a/Games/Minesweeper/main.cpp +++ b/Games/Minesweeper/main.cpp @@ -45,7 +45,7 @@ int main(int argc, char** argv) return 1; } - GApplication app(argc, argv); + GUI::Application app(argc, argv); if (pledge("stdio rpath accept wpath cpath shared_buffer", nullptr) < 0) { perror("pledge"); @@ -53,41 +53,41 @@ int main(int argc, char** argv) } - auto window = GWindow::construct(); + auto window = GUI::Window::construct(); window->set_resizable(false); window->set_title("Minesweeper"); window->set_rect(100, 100, 139, 175); - auto widget = GWidget::construct(); + auto widget = GUI::Widget::construct(); window->set_main_widget(widget); - widget->set_layout(make()); + widget->set_layout(make()); widget->layout()->set_spacing(0); - auto container = GWidget::construct(widget.ptr()); + auto container = GUI::Widget::construct(widget.ptr()); container->set_fill_with_background_color(true); - container->set_size_policy(SizePolicy::Fill, SizePolicy::Fixed); + container->set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed); container->set_preferred_size(0, 36); - container->set_layout(make()); - auto flag_icon_label = GLabel::construct(container); + container->set_layout(make()); + auto flag_icon_label = GUI::Label::construct(container); flag_icon_label->set_icon(GraphicsBitmap::load_from_file("/res/icons/minesweeper/flag.png")); - auto flag_label = GLabel::construct(container); - auto face_button = GButton::construct(container); + auto flag_label = GUI::Label::construct(container); + auto face_button = GUI::Button::construct(container); face_button->set_button_style(ButtonStyle::CoolBar); - face_button->set_size_policy(SizePolicy::Fixed, SizePolicy::Fill); + face_button->set_size_policy(GUI::SizePolicy::Fixed, GUI::SizePolicy::Fill); face_button->set_preferred_size(36, 0); - auto time_icon_label = GLabel::construct(container); + auto time_icon_label = GUI::Label::construct(container); time_icon_label->set_icon(GraphicsBitmap::load_from_file("/res/icons/minesweeper/timer.png")); - auto time_label = GLabel::construct(container); + auto time_label = GUI::Label::construct(container); auto field = Field::construct(*flag_label, *time_label, *face_button, widget, [&](Size size) { size.set_height(size.height() + container->preferred_size().height()); window->resize(size); }); - auto menubar = make(); + auto menubar = make(); - auto app_menu = GMenu::construct("Minesweeper"); + auto app_menu = GUI::Menu::construct("Minesweeper"); - app_menu->add_action(GAction::create("New game", { Mod_None, Key_F2 }, [&](const GAction&) { + app_menu->add_action(GUI::Action::create("New game", { Mod_None, Key_F2 }, [&](const GUI::Action&) { field->reset(); })); @@ -95,7 +95,7 @@ int main(int argc, char** argv) app_menu->add_separator(); - NonnullRefPtr chord_toggler_action = GAction::create("Single-click chording", [&](const GAction&) { + NonnullRefPtr chord_toggler_action = GUI::Action::create("Single-click chording", [&](const GUI::Action&) { bool toggled = !field->is_single_chording(); field->set_single_chording(toggled); chord_toggler_action->set_checked(toggled); @@ -106,30 +106,30 @@ int main(int argc, char** argv) app_menu->add_action(*chord_toggler_action); app_menu->add_separator(); - app_menu->add_action(GCommonActions::make_quit_action([](auto&) { - GApplication::the().quit(0); + app_menu->add_action(GUI::CommonActions::make_quit_action([](auto&) { + GUI::Application::the().quit(0); return; })); menubar->add_menu(move(app_menu)); - auto difficulty_menu = GMenu::construct("Difficulty"); - difficulty_menu->add_action(GAction::create("Beginner", { Mod_Ctrl, Key_B }, [&](const GAction&) { + auto difficulty_menu = GUI::Menu::construct("Difficulty"); + difficulty_menu->add_action(GUI::Action::create("Beginner", { Mod_Ctrl, Key_B }, [&](const GUI::Action&) { field->set_field_size(9, 9, 10); })); - difficulty_menu->add_action(GAction::create("Intermediate", { Mod_Ctrl, Key_I }, [&](const GAction&) { + difficulty_menu->add_action(GUI::Action::create("Intermediate", { Mod_Ctrl, Key_I }, [&](const GUI::Action&) { field->set_field_size(16, 16, 40); })); - difficulty_menu->add_action(GAction::create("Expert", { Mod_Ctrl, Key_E }, [&](const GAction&) { + difficulty_menu->add_action(GUI::Action::create("Expert", { Mod_Ctrl, Key_E }, [&](const GUI::Action&) { field->set_field_size(16, 30, 99); })); - difficulty_menu->add_action(GAction::create("Madwoman", { Mod_Ctrl, Key_M }, [&](const GAction&) { + difficulty_menu->add_action(GUI::Action::create("Madwoman", { Mod_Ctrl, Key_M }, [&](const GUI::Action&) { field->set_field_size(32, 60, 350); })); menubar->add_menu(move(difficulty_menu)); - auto help_menu = GMenu::construct("Help"); - help_menu->add_action(GAction::create("About", [&](const GAction&) { - GAboutDialog::show("Minesweeper", load_png("/res/icons/32x32/app-minesweeper.png"), window); + auto help_menu = GUI::Menu::construct("Help"); + help_menu->add_action(GUI::Action::create("About", [&](const GUI::Action&) { + GUI::AboutDialog::show("Minesweeper", load_png("/res/icons/32x32/app-minesweeper.png"), window); })); menubar->add_menu(move(help_menu)); diff --git a/Games/Snake/SnakeGame.cpp b/Games/Snake/SnakeGame.cpp index 6ffd0a38452..98a0acd4037 100644 --- a/Games/Snake/SnakeGame.cpp +++ b/Games/Snake/SnakeGame.cpp @@ -31,8 +31,8 @@ #include #include -SnakeGame::SnakeGame(GWidget* parent) - : GWidget(parent) +SnakeGame::SnakeGame(GUI::Widget* parent) + : GUI::Widget(parent) { set_font(GFontDatabase::the().get_by_name("Liza Regular")); m_fruit_bitmaps.append(*GraphicsBitmap::load_from_file("/res/icons/snake/paprika.png")); @@ -161,7 +161,7 @@ void SnakeGame::timer_event(Core::TimerEvent&) } } -void SnakeGame::keydown_event(GKeyEvent& event) +void SnakeGame::keydown_event(GUI::KeyEvent& event) { switch (event.key()) { case KeyCode::Key_A: @@ -205,9 +205,9 @@ Rect SnakeGame::cell_rect(const Coordinate& coord) const }; } -void SnakeGame::paint_event(GPaintEvent& event) +void SnakeGame::paint_event(GUI::PaintEvent& event) { - GPainter painter(*this); + GUI::Painter painter(*this); painter.add_clip_rect(event.rect()); painter.fill_rect(event.rect(), Color::Black); diff --git a/Games/Snake/SnakeGame.h b/Games/Snake/SnakeGame.h index 8dbf8f1d845..69df7d5c0e9 100644 --- a/Games/Snake/SnakeGame.h +++ b/Games/Snake/SnakeGame.h @@ -30,7 +30,7 @@ #include #include -class SnakeGame : public GWidget { +class SnakeGame : public GUI::Widget { C_OBJECT(SnakeGame) public: virtual ~SnakeGame() override; @@ -38,9 +38,9 @@ public: void reset(); private: - explicit SnakeGame(GWidget* parent = nullptr); - virtual void paint_event(GPaintEvent&) override; - virtual void keydown_event(GKeyEvent&) override; + explicit SnakeGame(GUI::Widget* parent = nullptr); + virtual void paint_event(GUI::PaintEvent&) override; + virtual void keydown_event(GUI::KeyEvent&) override; virtual void timer_event(Core::TimerEvent&) override; struct Coordinate { diff --git a/Games/Snake/main.cpp b/Games/Snake/main.cpp index 66532846455..d9293f16fa9 100644 --- a/Games/Snake/main.cpp +++ b/Games/Snake/main.cpp @@ -43,14 +43,14 @@ int main(int argc, char** argv) return 1; } - GApplication app(argc, argv); + GUI::Application app(argc, argv); if (pledge("stdio rpath shared_buffer accept", nullptr) < 0) { perror("pledge"); return 1; } - auto window = GWindow::construct(); + auto window = GUI::Window::construct(); window->set_double_buffering_enabled(false); window->set_title("Snake"); @@ -59,22 +59,22 @@ int main(int argc, char** argv) auto game = SnakeGame::construct(); window->set_main_widget(game); - auto menubar = make(); + auto menubar = make(); - auto app_menu = GMenu::construct("Snake"); + auto app_menu = GUI::Menu::construct("Snake"); - app_menu->add_action(GAction::create("New game", { Mod_None, Key_F2 }, [&](const GAction&) { + app_menu->add_action(GUI::Action::create("New game", { Mod_None, Key_F2 }, [&](const GUI::Action&) { game->reset(); })); - app_menu->add_action(GCommonActions::make_quit_action([](auto&) { - GApplication::the().quit(0); + app_menu->add_action(GUI::CommonActions::make_quit_action([](auto&) { + GUI::Application::the().quit(0); })); menubar->add_menu(move(app_menu)); - auto help_menu = GMenu::construct("Help"); - help_menu->add_action(GAction::create("About", [&](const GAction&) { - GAboutDialog::show("Snake", load_png("/res/icons/32x32/app-snake.png"), window); + auto help_menu = GUI::Menu::construct("Help"); + help_menu->add_action(GUI::Action::create("About", [&](const GUI::Action&) { + GUI::AboutDialog::show("Snake", load_png("/res/icons/32x32/app-snake.png"), window); })); menubar->add_menu(move(help_menu)); diff --git a/Libraries/LibDraw/Palette.h b/Libraries/LibDraw/Palette.h index c2a2680cb7d..5c18c102634 100644 --- a/Libraries/LibDraw/Palette.h +++ b/Libraries/LibDraw/Palette.h @@ -30,7 +30,9 @@ #include #include -class GApplication; +namespace GUI { +class Application; +} class PaletteImpl : public RefCounted { AK_MAKE_NONCOPYABLE(PaletteImpl) @@ -42,7 +44,7 @@ public: Color color(ColorRole) const; const SystemTheme& theme() const; - void replace_internal_buffer(Badge, SharedBuffer& buffer) { m_theme_buffer = buffer; } + void replace_internal_buffer(Badge, SharedBuffer& buffer) { m_theme_buffer = buffer; } private: explicit PaletteImpl(SharedBuffer&); diff --git a/Libraries/LibGUI/GAboutDialog.cpp b/Libraries/LibGUI/GAboutDialog.cpp index 8abdc56fb2d..1de04024070 100644 --- a/Libraries/LibGUI/GAboutDialog.cpp +++ b/Libraries/LibGUI/GAboutDialog.cpp @@ -30,8 +30,10 @@ #include #include -GAboutDialog::GAboutDialog(const StringView& name, const GraphicsBitmap* icon, Core::Object* parent) - : GDialog(parent) +namespace GUI { + +AboutDialog::AboutDialog(const StringView& name, const GraphicsBitmap* icon, Core::Object* parent) + : Dialog(parent) , m_name(name) , m_icon(icon) { @@ -39,27 +41,27 @@ GAboutDialog::GAboutDialog(const StringView& name, const GraphicsBitmap* icon, C set_title(String::format("About %s", m_name.characters())); set_resizable(false); - auto widget = GWidget::construct(); + auto widget = Widget::construct(); set_main_widget(widget); widget->set_fill_with_background_color(true); - widget->set_layout(make()); + widget->set_layout(make()); - auto left_container = GWidget::construct(widget.ptr()); + auto left_container = Widget::construct(widget.ptr()); left_container->set_size_policy(SizePolicy::Fixed, SizePolicy::Fill); left_container->set_preferred_size(48, 0); - left_container->set_layout(make()); - auto icon_label = GLabel::construct(left_container); + left_container->set_layout(make()); + auto icon_label = Label::construct(left_container); icon_label->set_icon(m_icon); icon_label->set_size_policy(SizePolicy::Fixed, SizePolicy::Fixed); icon_label->set_preferred_size(40, 40); left_container->layout()->add_spacer(); - auto right_container = GWidget::construct(widget.ptr()); - right_container->set_layout(make()); + auto right_container = Widget::construct(widget.ptr()); + right_container->set_layout(make()); right_container->layout()->set_margins({ 0, 4, 4, 4 }); auto make_label = [&](const StringView& text, bool bold = false) { - auto label = GLabel::construct(text, right_container); + auto label = Label::construct(text, right_container); label->set_text_alignment(TextAlignment::CenterLeft); label->set_size_policy(SizePolicy::Fill, SizePolicy::Fixed); label->set_preferred_size(0, 14); @@ -72,19 +74,21 @@ GAboutDialog::GAboutDialog(const StringView& name, const GraphicsBitmap* icon, C right_container->layout()->add_spacer(); - auto button_container = GWidget::construct(right_container.ptr()); + auto button_container = Widget::construct(right_container.ptr()); button_container->set_size_policy(SizePolicy::Fill, SizePolicy::Fixed); button_container->set_preferred_size(0, 20); - button_container->set_layout(make()); + button_container->set_layout(make()); button_container->layout()->add_spacer(); - auto ok_button = GButton::construct("OK", button_container); + auto ok_button = Button::construct("OK", button_container); ok_button->set_size_policy(SizePolicy::Fixed, SizePolicy::Fixed); ok_button->set_preferred_size(80, 20); ok_button->on_click = [this](auto&) { - done(GDialog::ExecOK); + done(Dialog::ExecOK); }; } -GAboutDialog::~GAboutDialog() +AboutDialog::~AboutDialog() { } + +} diff --git a/Libraries/LibGUI/GAboutDialog.h b/Libraries/LibGUI/GAboutDialog.h index e355d0355e6..601ca95bc3a 100644 --- a/Libraries/LibGUI/GAboutDialog.h +++ b/Libraries/LibGUI/GAboutDialog.h @@ -28,20 +28,23 @@ #include -class GAboutDialog final : public GDialog { - C_OBJECT(GAboutDialog) +namespace GUI { + +class AboutDialog final : public Dialog { + C_OBJECT(AboutDialog) public: - virtual ~GAboutDialog() override; + virtual ~AboutDialog() override; static void show(const StringView& name, const GraphicsBitmap* icon = nullptr, Core::Object* parent = nullptr) { - auto dialog = GAboutDialog::construct(name, icon, parent); + auto dialog = AboutDialog::construct(name, icon, parent); dialog->exec(); } private: - GAboutDialog(const StringView& name, const GraphicsBitmap* icon = nullptr, Core::Object* parent = nullptr); + AboutDialog(const StringView& name, const GraphicsBitmap* icon = nullptr, Core::Object* parent = nullptr); String m_name; RefPtr m_icon; }; +} diff --git a/Libraries/LibGUI/GAbstractButton.cpp b/Libraries/LibGUI/GAbstractButton.cpp index 68bd12fb849..0196f2ee12b 100644 --- a/Libraries/LibGUI/GAbstractButton.cpp +++ b/Libraries/LibGUI/GAbstractButton.cpp @@ -28,13 +28,15 @@ #include #include -GAbstractButton::GAbstractButton(GWidget* parent) - : GAbstractButton({}, parent) +namespace GUI { + +AbstractButton::AbstractButton(Widget* parent) + : AbstractButton({}, parent) { } -GAbstractButton::GAbstractButton(const StringView& text, GWidget* parent) - : GWidget(parent) +AbstractButton::AbstractButton(const StringView& text, Widget* parent) + : Widget(parent) , m_text(text) { m_auto_repeat_timer = Core::Timer::construct(this); @@ -43,11 +45,11 @@ GAbstractButton::GAbstractButton(const StringView& text, GWidget* parent) }; } -GAbstractButton::~GAbstractButton() +AbstractButton::~AbstractButton() { } -void GAbstractButton::set_text(const StringView& text) +void AbstractButton::set_text(const StringView& text) { if (m_text == text) return; @@ -55,14 +57,14 @@ void GAbstractButton::set_text(const StringView& text) update(); } -void GAbstractButton::set_checked(bool checked) +void AbstractButton::set_checked(bool checked) { if (m_checked == checked) return; m_checked = checked; if (is_exclusive() && checked) { - parent_widget()->for_each_child_of_type([&](auto& sibling) { + parent_widget()->for_each_child_of_type([&](auto& sibling) { if (!sibling.is_exclusive() || !sibling.is_checked()) return IterationDecision::Continue; sibling.m_checked = false; @@ -79,7 +81,7 @@ void GAbstractButton::set_checked(bool checked) on_checked(checked); } -void GAbstractButton::set_checkable(bool checkable) +void AbstractButton::set_checkable(bool checkable) { if (m_checkable == checkable) return; @@ -87,11 +89,11 @@ void GAbstractButton::set_checkable(bool checkable) update(); } -void GAbstractButton::mousemove_event(GMouseEvent& event) +void AbstractButton::mousemove_event(MouseEvent& event) { bool is_over = rect().contains(event.position()); m_hovered = is_over; - if (event.buttons() & GMouseButton::Left) { + if (event.buttons() & MouseButton::Left) { if (is_enabled()) { bool being_pressed = is_over; if (being_pressed != m_being_pressed) { @@ -106,15 +108,15 @@ void GAbstractButton::mousemove_event(GMouseEvent& event) } } } - GWidget::mousemove_event(event); + Widget::mousemove_event(event); } -void GAbstractButton::mousedown_event(GMouseEvent& event) +void AbstractButton::mousedown_event(MouseEvent& event) { #ifdef GABSTRACTBUTTON_DEBUG - dbgprintf("GAbstractButton::mouse_down_event: x=%d, y=%d, button=%u\n", event.x(), event.y(), (unsigned)event.button()); + dbgprintf("AbstractButton::mouse_down_event: x=%d, y=%d, button=%u\n", event.x(), event.y(), (unsigned)event.button()); #endif - if (event.button() == GMouseButton::Left) { + if (event.button() == MouseButton::Left) { if (is_enabled()) { m_being_pressed = true; update(); @@ -125,15 +127,15 @@ void GAbstractButton::mousedown_event(GMouseEvent& event) } } } - GWidget::mousedown_event(event); + Widget::mousedown_event(event); } -void GAbstractButton::mouseup_event(GMouseEvent& event) +void AbstractButton::mouseup_event(MouseEvent& event) { #ifdef GABSTRACTBUTTON_DEBUG - dbgprintf("GAbstractButton::mouse_up_event: x=%d, y=%d, button=%u\n", event.x(), event.y(), (unsigned)event.button()); + dbgprintf("AbstractButton::mouse_up_event: x=%d, y=%d, button=%u\n", event.x(), event.y(), (unsigned)event.button()); #endif - if (event.button() == GMouseButton::Left) { + if (event.button() == MouseButton::Left) { bool was_auto_repeating = m_auto_repeat_timer->is_active(); m_auto_repeat_timer->stop(); if (is_enabled()) { @@ -144,32 +146,32 @@ void GAbstractButton::mouseup_event(GMouseEvent& event) click(); } } - GWidget::mouseup_event(event); + Widget::mouseup_event(event); } -void GAbstractButton::enter_event(Core::Event&) +void AbstractButton::enter_event(Core::Event&) { m_hovered = true; update(); } -void GAbstractButton::leave_event(Core::Event&) +void AbstractButton::leave_event(Core::Event&) { m_hovered = false; update(); } -void GAbstractButton::keydown_event(GKeyEvent& event) +void AbstractButton::keydown_event(KeyEvent& event) { if (event.key() == KeyCode::Key_Return) { click(); event.accept(); return; } - GWidget::keydown_event(event); + Widget::keydown_event(event); } -void GAbstractButton::paint_text(GPainter& painter, const Rect& rect, const Font& font, TextAlignment text_alignment) +void AbstractButton::paint_text(Painter& painter, const Rect& rect, const Font& font, TextAlignment text_alignment) { auto clipped_rect = rect.intersected(this->rect()); @@ -186,9 +188,9 @@ void GAbstractButton::paint_text(GPainter& painter, const Rect& rect, const Font painter.draw_rect(clipped_rect.inflated(6, 4), Color(140, 140, 140)); } -void GAbstractButton::change_event(GEvent& event) +void AbstractButton::change_event(Event& event) { - if (event.type() == GEvent::Type::EnabledChange) { + if (event.type() == Event::Type::EnabledChange) { if (!is_enabled()) { bool was_being_pressed = m_being_pressed; m_being_pressed = false; @@ -196,5 +198,7 @@ void GAbstractButton::change_event(GEvent& event) update(); } } - GWidget::change_event(event); + Widget::change_event(event); +} + } diff --git a/Libraries/LibGUI/GAbstractButton.h b/Libraries/LibGUI/GAbstractButton.h index 2b868b0b9dc..cb9885dde3a 100644 --- a/Libraries/LibGUI/GAbstractButton.h +++ b/Libraries/LibGUI/GAbstractButton.h @@ -30,12 +30,14 @@ #include #include -class GPainter; +namespace GUI { -class GAbstractButton : public GWidget { +class Painter; + +class AbstractButton : public Widget { C_OBJECT_ABSTRACT(GAbstractButton) public: - virtual ~GAbstractButton() override; + virtual ~AbstractButton() override; Function on_checked; @@ -62,18 +64,18 @@ public: void set_auto_repeat_interval(int interval) { m_auto_repeat_interval = interval; } protected: - explicit GAbstractButton(GWidget* parent); - GAbstractButton(const StringView&, GWidget* parent); + explicit AbstractButton(Widget* parent); + AbstractButton(const StringView&, Widget* parent); - virtual void mousedown_event(GMouseEvent&) override; - virtual void mousemove_event(GMouseEvent&) override; - virtual void mouseup_event(GMouseEvent&) override; - virtual void keydown_event(GKeyEvent&) override; + virtual void mousedown_event(MouseEvent&) override; + virtual void mousemove_event(MouseEvent&) override; + virtual void mouseup_event(MouseEvent&) override; + virtual void keydown_event(KeyEvent&) override; virtual void enter_event(Core::Event&) override; virtual void leave_event(Core::Event&) override; - virtual void change_event(GEvent&) override; + virtual void change_event(Event&) override; - void paint_text(GPainter&, const Rect&, const Font&, TextAlignment); + void paint_text(Painter&, const Rect&, const Font&, TextAlignment); private: virtual bool is_abstract_button() const final { return true; } @@ -89,10 +91,12 @@ private: RefPtr m_auto_repeat_timer; }; -template<> -inline bool Core::is(const Core::Object& object) -{ - if (!is(object)) - return false; - return to(object).is_abstract_button(); +} + +template<> +inline bool Core::is(const Core::Object& object) +{ + if (!is(object)) + return false; + return to(object).is_abstract_button(); } diff --git a/Libraries/LibGUI/GAbstractTableView.cpp b/Libraries/LibGUI/GAbstractTableView.cpp index 8dba874668b..5ab6f3947bf 100644 --- a/Libraries/LibGUI/GAbstractTableView.cpp +++ b/Libraries/LibGUI/GAbstractTableView.cpp @@ -32,10 +32,12 @@ #include #include +namespace GUI { + static const int minimum_column_width = 2; -GAbstractTableView::GAbstractTableView(GWidget* parent) - : GAbstractView(parent) +AbstractTableView::AbstractTableView(Widget* parent) + : AbstractView(parent) { set_frame_shape(FrameShape::Container); set_frame_shadow(FrameShadow::Sunken); @@ -44,11 +46,11 @@ GAbstractTableView::GAbstractTableView(GWidget* parent) set_should_hide_unnecessary_scrollbars(true); } -GAbstractTableView::~GAbstractTableView() +AbstractTableView::~AbstractTableView() { } -void GAbstractTableView::update_column_sizes() +void AbstractTableView::update_column_sizes() { if (!m_size_columns_to_fit_content) return; @@ -84,7 +86,7 @@ void GAbstractTableView::update_column_sizes() } } -void GAbstractTableView::update_content_size() +void AbstractTableView::update_content_size() { if (!model()) return set_content_size({}); @@ -101,7 +103,7 @@ void GAbstractTableView::update_content_size() set_size_occupied_by_fixed_elements({ 0, header_height() }); } -Rect GAbstractTableView::header_rect(int column_index) const +Rect AbstractTableView::header_rect(int column_index) const { if (!model()) return {}; @@ -116,7 +118,7 @@ Rect GAbstractTableView::header_rect(int column_index) const return { x_offset, 0, column_width(column_index) + horizontal_padding() * 2, header_height() }; } -void GAbstractTableView::set_hovered_header_index(int index) +void AbstractTableView::set_hovered_header_index(int index) { if (m_hovered_column_header_index == index) return; @@ -124,7 +126,7 @@ void GAbstractTableView::set_hovered_header_index(int index) update_headers(); } -void GAbstractTableView::paint_headers(GPainter& painter) +void AbstractTableView::paint_headers(Painter& painter) { if (!headers_visible()) return; @@ -141,16 +143,16 @@ void GAbstractTableView::paint_headers(GPainter& painter) bool is_key_column = model()->key_column() == column_index; Rect cell_rect(x_offset, 0, column_width + horizontal_padding() * 2, header_height()); bool pressed = column_index == m_pressed_column_header_index && m_pressed_column_header_is_pressed; - bool hovered = column_index == m_hovered_column_header_index && model()->column_metadata(column_index).sortable == GModel::ColumnMetadata::Sortable::True; + bool hovered = column_index == m_hovered_column_header_index && model()->column_metadata(column_index).sortable == Model::ColumnMetadata::Sortable::True; StylePainter::paint_button(painter, cell_rect, palette(), ButtonStyle::Normal, pressed, hovered); String text; if (is_key_column) { StringBuilder builder; builder.append(model()->column_name(column_index)); auto sort_order = model()->sort_order(); - if (sort_order == GSortOrder::Ascending) + if (sort_order == SortOrder::Ascending) builder.append(" \xc3\xb6"); - else if (sort_order == GSortOrder::Descending) + else if (sort_order == SortOrder::Descending) builder.append(" \xc3\xb7"); text = builder.to_string(); } else { @@ -164,12 +166,12 @@ void GAbstractTableView::paint_headers(GPainter& painter) } } -bool GAbstractTableView::is_column_hidden(int column) const +bool AbstractTableView::is_column_hidden(int column) const { return !column_data(column).visibility; } -void GAbstractTableView::set_column_hidden(int column, bool hidden) +void AbstractTableView::set_column_hidden(int column, bool hidden) { auto& column_data = this->column_data(column); if (column_data.visibility == !hidden) @@ -179,18 +181,18 @@ void GAbstractTableView::set_column_hidden(int column, bool hidden) update(); } -GMenu& GAbstractTableView::ensure_header_context_menu() +Menu& AbstractTableView::ensure_header_context_menu() { // FIXME: This menu needs to be rebuilt if the model is swapped out, // or if the column count/names change. if (!m_header_context_menu) { ASSERT(model()); - m_header_context_menu = GMenu::construct(); + m_header_context_menu = Menu::construct(); for (int column = 0; column < model()->column_count(); ++column) { auto& column_data = this->column_data(column); auto name = model()->column_name(column); - column_data.visibility_action = GAction::create(name, [this, column](GAction& action) { + column_data.visibility_action = Action::create(name, [this, column](Action& action) { action.set_checked(!action.is_checked()); set_column_hidden(column, !action.is_checked()); }); @@ -203,31 +205,31 @@ GMenu& GAbstractTableView::ensure_header_context_menu() return *m_header_context_menu; } -const Font& GAbstractTableView::header_font() +const Font& AbstractTableView::header_font() { return Font::default_bold_font(); } -void GAbstractTableView::set_cell_painting_delegate(int column, OwnPtr&& delegate) +void AbstractTableView::set_cell_painting_delegate(int column, OwnPtr&& delegate) { column_data(column).cell_painting_delegate = move(delegate); } -void GAbstractTableView::update_headers() +void AbstractTableView::update_headers() { Rect rect { 0, 0, frame_inner_rect().width(), header_height() }; rect.move_by(frame_thickness(), frame_thickness()); update(rect); } -GAbstractTableView::ColumnData& GAbstractTableView::column_data(int column) const +AbstractTableView::ColumnData& AbstractTableView::column_data(int column) const { if (column >= m_column_data.size()) m_column_data.resize(column + 1); return m_column_data.at(column); } -Rect GAbstractTableView::column_resize_grabbable_rect(int column) const +Rect AbstractTableView::column_resize_grabbable_rect(int column) const { if (!model()) return {}; @@ -235,7 +237,7 @@ Rect GAbstractTableView::column_resize_grabbable_rect(int column) const return { header_rect.right() - 1, header_rect.top(), 4, header_rect.height() }; } -int GAbstractTableView::column_width(int column_index) const +int AbstractTableView::column_width(int column_index) const { if (!model()) return 0; @@ -248,10 +250,10 @@ int GAbstractTableView::column_width(int column_index) const return column_data.width; } -void GAbstractTableView::mousemove_event(GMouseEvent& event) +void AbstractTableView::mousemove_event(MouseEvent& event) { if (!model()) - return GAbstractView::mousemove_event(event); + return AbstractView::mousemove_event(event); if (m_in_column_resize) { auto delta = event.position() - m_column_resize_origin; @@ -288,7 +290,7 @@ void GAbstractTableView::mousemove_event(GMouseEvent& event) bool found_hovered_header = false; for (int i = 0; i < column_count; ++i) { if (column_resize_grabbable_rect(i).contains(event.position())) { - window()->set_override_cursor(GStandardCursor::ResizeHorizontal); + window()->set_override_cursor(StandardCursor::ResizeHorizontal); set_hovered_header_index(-1); return; } @@ -300,29 +302,29 @@ void GAbstractTableView::mousemove_event(GMouseEvent& event) if (!found_hovered_header) set_hovered_header_index(-1); } - window()->set_override_cursor(GStandardCursor::None); + window()->set_override_cursor(StandardCursor::None); - GAbstractView::mousemove_event(event); + AbstractView::mousemove_event(event); } -void GAbstractTableView::mouseup_event(GMouseEvent& event) +void AbstractTableView::mouseup_event(MouseEvent& event) { auto adjusted_position = this->adjusted_position(event.position()); - if (event.button() == GMouseButton::Left) { + if (event.button() == MouseButton::Left) { if (m_in_column_resize) { if (!column_resize_grabbable_rect(m_resizing_column).contains(adjusted_position)) - window()->set_override_cursor(GStandardCursor::None); + window()->set_override_cursor(StandardCursor::None); m_in_column_resize = false; return; } if (m_pressed_column_header_index != -1) { auto header_rect = this->header_rect(m_pressed_column_header_index); if (header_rect.contains(event.position())) { - auto new_sort_order = GSortOrder::Ascending; + auto new_sort_order = SortOrder::Ascending; if (model()->key_column() == m_pressed_column_header_index) - new_sort_order = model()->sort_order() == GSortOrder::Ascending - ? GSortOrder::Descending - : GSortOrder::Ascending; + new_sort_order = model()->sort_order() == SortOrder::Ascending + ? SortOrder::Descending + : SortOrder::Ascending; model()->set_key_column_and_sort_order(m_pressed_column_header_index, new_sort_order); } m_pressed_column_header_index = -1; @@ -332,16 +334,16 @@ void GAbstractTableView::mouseup_event(GMouseEvent& event) } } - GAbstractView::mouseup_event(event); + AbstractView::mouseup_event(event); } -void GAbstractTableView::mousedown_event(GMouseEvent& event) +void AbstractTableView::mousedown_event(MouseEvent& event) { if (!model()) - return GAbstractView::mousedown_event(event); + return AbstractView::mousedown_event(event); - if (event.button() != GMouseButton::Left) - return GAbstractView::mousedown_event(event); + if (event.button() != MouseButton::Left) + return AbstractView::mousedown_event(event); if (event.y() < header_height()) { int column_count = model()->column_count(); @@ -355,7 +357,7 @@ void GAbstractTableView::mousedown_event(GMouseEvent& event) } auto header_rect = this->header_rect(i); auto column_metadata = model()->column_metadata(i); - if (header_rect.contains(event.position()) && column_metadata.sortable == GModel::ColumnMetadata::Sortable::True) { + if (header_rect.contains(event.position()) && column_metadata.sortable == Model::ColumnMetadata::Sortable::True) { m_pressed_column_header_index = i; m_pressed_column_header_is_pressed = true; update_headers(); @@ -373,10 +375,10 @@ void GAbstractTableView::mousedown_event(GMouseEvent& event) return; } - GAbstractView::mousedown_event(event); + AbstractView::mousedown_event(event); } -GModelIndex GAbstractTableView::index_at_event_position(const Point& position, bool& is_toggle) const +ModelIndex AbstractTableView::index_at_event_position(const Point& position, bool& is_toggle) const { is_toggle = false; if (!model()) @@ -396,21 +398,21 @@ GModelIndex GAbstractTableView::index_at_event_position(const Point& position, b return {}; } -GModelIndex GAbstractTableView::index_at_event_position(const Point& position) const +ModelIndex AbstractTableView::index_at_event_position(const Point& position) const { bool is_toggle; auto index = index_at_event_position(position, is_toggle); - return is_toggle ? GModelIndex() : index; + return is_toggle ? ModelIndex() : index; } -int GAbstractTableView::item_count() const +int AbstractTableView::item_count() const { if (!model()) return 0; return model()->row_count(); } -void GAbstractTableView::keydown_event(GKeyEvent& event) +void AbstractTableView::keydown_event(KeyEvent& event) { if (!model()) return; @@ -420,7 +422,7 @@ void GAbstractTableView::keydown_event(GKeyEvent& event) return; } if (event.key() == KeyCode::Key_Up) { - GModelIndex new_index; + ModelIndex new_index; if (!selection().is_empty()) { auto old_index = selection().first(); new_index = model.index(old_index.row() - 1, old_index.column()); @@ -435,7 +437,7 @@ void GAbstractTableView::keydown_event(GKeyEvent& event) return; } if (event.key() == KeyCode::Key_Down) { - GModelIndex new_index; + ModelIndex new_index; if (!selection().is_empty()) { auto old_index = selection().first(); new_index = model.index(old_index.row() + 1, old_index.column()); @@ -471,20 +473,20 @@ void GAbstractTableView::keydown_event(GKeyEvent& event) } return; } - return GWidget::keydown_event(event); + return Widget::keydown_event(event); } -void GAbstractTableView::scroll_into_view(const GModelIndex& index, Orientation orientation) +void AbstractTableView::scroll_into_view(const ModelIndex& index, Orientation orientation) { auto rect = row_rect(index.row()).translated(0, -header_height()); - GScrollableWidget::scroll_into_view(rect, orientation); + ScrollableWidget::scroll_into_view(rect, orientation); } -void GAbstractTableView::doubleclick_event(GMouseEvent& event) +void AbstractTableView::doubleclick_event(MouseEvent& event) { if (!model()) return; - if (event.button() == GMouseButton::Left) { + if (event.button() == MouseButton::Left) { if (event.y() < header_height()) return; if (!selection().is_empty()) { @@ -496,7 +498,7 @@ void GAbstractTableView::doubleclick_event(GMouseEvent& event) } } -void GAbstractTableView::context_menu_event(GContextMenuEvent& event) +void AbstractTableView::context_menu_event(ContextMenuEvent& event) { if (!model()) return; @@ -517,13 +519,13 @@ void GAbstractTableView::context_menu_event(GContextMenuEvent& event) on_context_menu_request(index, event); } -void GAbstractTableView::leave_event(Core::Event&) +void AbstractTableView::leave_event(Core::Event&) { - window()->set_override_cursor(GStandardCursor::None); + window()->set_override_cursor(StandardCursor::None); set_hovered_header_index(-1); } -Rect GAbstractTableView::content_rect(int row, int column) const +Rect AbstractTableView::content_rect(int row, int column) const { auto row_rect = this->row_rect(row); int x = 0; @@ -533,25 +535,27 @@ Rect GAbstractTableView::content_rect(int row, int column) const return { row_rect.x() + x, row_rect.y(), column_width(column) + horizontal_padding() * 2, item_height() }; } -Rect GAbstractTableView::content_rect(const GModelIndex& index) const +Rect AbstractTableView::content_rect(const ModelIndex& index) const { return content_rect(index.row(), index.column()); } -Rect GAbstractTableView::row_rect(int item_index) const +Rect AbstractTableView::row_rect(int item_index) const { return { 0, header_height() + (item_index * item_height()), max(content_size().width(), width()), item_height() }; } -Point GAbstractTableView::adjusted_position(const Point& position) const +Point AbstractTableView::adjusted_position(const Point& position) const { return position.translated(horizontal_scrollbar().value() - frame_thickness(), vertical_scrollbar().value() - frame_thickness()); } -void GAbstractTableView::did_update_model() +void AbstractTableView::did_update_model() { - GAbstractView::did_update_model(); + AbstractView::did_update_model(); update_column_sizes(); update_content_size(); update(); } + +} diff --git a/Libraries/LibGUI/GAbstractTableView.h b/Libraries/LibGUI/GAbstractTableView.h index a40b1557302..b728b3fb2b5 100644 --- a/Libraries/LibGUI/GAbstractTableView.h +++ b/Libraries/LibGUI/GAbstractTableView.h @@ -28,17 +28,19 @@ #include -class GPainter; +namespace GUI { + +class Painter; // FIXME: Rename this to something without "table cell" in the name. -class GTableCellPaintingDelegate { +class TableCellPaintingDelegate { public: - virtual ~GTableCellPaintingDelegate() {} + virtual ~TableCellPaintingDelegate() {} - virtual void paint(GPainter&, const Rect&, const Palette&, const GModel&, const GModelIndex&) = 0; + virtual void paint(Painter&, const Rect&, const Palette&, const Model&, const ModelIndex&) = 0; }; -class GAbstractTableView : public GAbstractView { +class AbstractTableView : public AbstractView { public: int item_height() const { return 16; } @@ -56,37 +58,37 @@ public: void set_size_columns_to_fit_content(bool b) { m_size_columns_to_fit_content = b; } bool size_columns_to_fit_content() const { return m_size_columns_to_fit_content; } - void set_cell_painting_delegate(int column, OwnPtr&&); + void set_cell_painting_delegate(int column, OwnPtr&&); int horizontal_padding() const { return m_horizontal_padding; } Point adjusted_position(const Point&) const; - virtual Rect content_rect(const GModelIndex&) const override; + virtual Rect content_rect(const ModelIndex&) const override; Rect content_rect(int row, int column) const; Rect row_rect(int item_index) const; - void scroll_into_view(const GModelIndex&, Orientation); + void scroll_into_view(const ModelIndex&, Orientation); - virtual GModelIndex index_at_event_position(const Point&, bool& is_toggle) const; - virtual GModelIndex index_at_event_position(const Point&) const override; + virtual ModelIndex index_at_event_position(const Point&, bool& is_toggle) const; + virtual ModelIndex index_at_event_position(const Point&) const override; protected: - virtual ~GAbstractTableView() override; - explicit GAbstractTableView(GWidget* parent); + virtual ~AbstractTableView() override; + explicit AbstractTableView(Widget* parent); virtual void did_update_model() override; - virtual void mouseup_event(GMouseEvent&) override; - virtual void mousedown_event(GMouseEvent&) override; - virtual void mousemove_event(GMouseEvent&) override; - virtual void doubleclick_event(GMouseEvent&) override; - virtual void keydown_event(GKeyEvent&) override; + virtual void mouseup_event(MouseEvent&) override; + virtual void mousedown_event(MouseEvent&) override; + virtual void mousemove_event(MouseEvent&) override; + virtual void doubleclick_event(MouseEvent&) override; + virtual void keydown_event(KeyEvent&) override; virtual void leave_event(Core::Event&) override; - virtual void context_menu_event(GContextMenuEvent&) override; + virtual void context_menu_event(ContextMenuEvent&) override; - virtual void toggle_index(const GModelIndex&) {} + virtual void toggle_index(const ModelIndex&) {} - void paint_headers(GPainter&); + void paint_headers(Painter&); Rect header_rect(int column) const; static const Font& header_font(); @@ -97,15 +99,15 @@ protected: int width { 0 }; bool has_initialized_width { false }; bool visibility { true }; - RefPtr visibility_action; - OwnPtr cell_painting_delegate; + RefPtr visibility_action; + OwnPtr cell_painting_delegate; }; ColumnData& column_data(int column) const; mutable Vector m_column_data; - GMenu& ensure_header_context_menu(); - RefPtr m_header_context_menu; + Menu& ensure_header_context_menu(); + RefPtr m_header_context_menu; Rect column_resize_grabbable_rect(int) const; int column_width(int) const; @@ -126,3 +128,5 @@ private: bool m_pressed_column_header_is_pressed { false }; int m_hovered_column_header_index { -1 }; }; + +} diff --git a/Libraries/LibGUI/GAbstractView.cpp b/Libraries/LibGUI/GAbstractView.cpp index 9c05e725059..6f1775b447c 100644 --- a/Libraries/LibGUI/GAbstractView.cpp +++ b/Libraries/LibGUI/GAbstractView.cpp @@ -34,17 +34,19 @@ #include #include -GAbstractView::GAbstractView(GWidget* parent) - : GScrollableWidget(parent) +namespace GUI { + +AbstractView::AbstractView(Widget* parent) + : ScrollableWidget(parent) , m_selection(*this) { } -GAbstractView::~GAbstractView() +AbstractView::~AbstractView() { } -void GAbstractView::set_model(RefPtr&& model) +void AbstractView::set_model(RefPtr&& model) { if (model == m_model) return; @@ -56,13 +58,13 @@ void GAbstractView::set_model(RefPtr&& model) did_update_model(); } -void GAbstractView::did_update_model() +void AbstractView::did_update_model() { if (!model() || selection().first() != m_edit_index) stop_editing(); } -void GAbstractView::did_update_selection() +void AbstractView::did_update_selection() { if (!model() || selection().first() != m_edit_index) stop_editing(); @@ -70,19 +72,19 @@ void GAbstractView::did_update_selection() on_selection(selection().first()); } -void GAbstractView::did_scroll() +void AbstractView::did_scroll() { update_edit_widget_position(); } -void GAbstractView::update_edit_widget_position() +void AbstractView::update_edit_widget_position() { if (!m_edit_widget) return; m_edit_widget->set_relative_rect(m_edit_widget_content_rect.translated(-horizontal_scrollbar().value(), -vertical_scrollbar().value())); } -void GAbstractView::begin_editing(const GModelIndex& index) +void AbstractView::begin_editing(const ModelIndex& index) { ASSERT(is_editable()); ASSERT(model()); @@ -99,7 +101,7 @@ void GAbstractView::begin_editing(const GModelIndex& index) ASSERT(aid_create_editing_delegate); m_editing_delegate = aid_create_editing_delegate(index); m_editing_delegate->bind(*model(), index); - m_editing_delegate->set_value(model()->data(index, GModel::Role::Display)); + m_editing_delegate->set_value(model()->data(index, Model::Role::Display)); m_edit_widget = m_editing_delegate->widget(); add_child(*m_edit_widget); m_edit_widget->move_to_back(); @@ -114,7 +116,7 @@ void GAbstractView::begin_editing(const GModelIndex& index) }; } -void GAbstractView::stop_editing() +void AbstractView::stop_editing() { m_edit_index = {}; if (m_edit_widget) { @@ -123,7 +125,7 @@ void GAbstractView::stop_editing() } } -void GAbstractView::select_all() +void AbstractView::select_all() { ASSERT(model()); int rows = model()->row_count(); @@ -135,13 +137,13 @@ void GAbstractView::select_all() } } -void GAbstractView::activate(const GModelIndex& index) +void AbstractView::activate(const ModelIndex& index) { if (on_activation) on_activation(index); } -void GAbstractView::activate_selected() +void AbstractView::activate_selected() { if (!on_activation) return; @@ -151,7 +153,7 @@ void GAbstractView::activate_selected() }); } -void GAbstractView::notify_selection_changed(Badge) +void AbstractView::notify_selection_changed(Badge) { did_update_selection(); if (on_selection_change) @@ -159,12 +161,12 @@ void GAbstractView::notify_selection_changed(Badge) update(); } -NonnullRefPtr GAbstractView::font_for_index(const GModelIndex& index) const +NonnullRefPtr AbstractView::font_for_index(const ModelIndex& index) const { if (!model()) return font(); - auto font_data = model()->data(index, GModel::Role::Font); + auto font_data = model()->data(index, Model::Role::Font); if (font_data.is_font()) return font_data.as_font(); @@ -174,14 +176,14 @@ NonnullRefPtr GAbstractView::font_for_index(const GModelIndex& index) cons return font(); } -void GAbstractView::mousedown_event(GMouseEvent& event) +void AbstractView::mousedown_event(MouseEvent& event) { - GScrollableWidget::mousedown_event(event); + ScrollableWidget::mousedown_event(event); if (!model()) return; - if (event.button() == GMouseButton::Left) + if (event.button() == MouseButton::Left) m_left_mousedown_position = event.position(); auto index = index_at_event_position(event.position()); @@ -191,7 +193,7 @@ void GAbstractView::mousedown_event(GMouseEvent& event) m_selection.clear(); } else if (event.modifiers() & Mod_Ctrl) { m_selection.toggle(index); - } else if (event.button() == GMouseButton::Left && m_selection.contains(index) && !m_model->drag_data_type().is_null()) { + } else if (event.button() == MouseButton::Left && m_selection.contains(index) && !m_model->drag_data_type().is_null()) { // We might be starting a drag, so don't throw away other selected items yet. m_might_drag = true; } else { @@ -201,14 +203,14 @@ void GAbstractView::mousedown_event(GMouseEvent& event) update(); } -void GAbstractView::mousemove_event(GMouseEvent& event) +void AbstractView::mousemove_event(MouseEvent& event) { if (!model() || !m_might_drag) - return GScrollableWidget::mousemove_event(event); + return ScrollableWidget::mousemove_event(event); - if (!(event.buttons() & GMouseButton::Left) || m_selection.is_empty()) { + if (!(event.buttons() & MouseButton::Left) || m_selection.is_empty()) { m_might_drag = false; - return GScrollableWidget::mousemove_event(event); + return ScrollableWidget::mousemove_event(event); } auto diff = event.position() - m_left_mousedown_position; @@ -216,13 +218,13 @@ void GAbstractView::mousemove_event(GMouseEvent& event) constexpr int drag_distance_threshold = 5; if (distance_travelled_squared <= drag_distance_threshold) - return GScrollableWidget::mousemove_event(event); + return ScrollableWidget::mousemove_event(event); auto data_type = m_model->drag_data_type(); ASSERT(!data_type.is_null()); dbg() << "Initiate drag!"; - auto drag_operation = GDragOperation::construct(); + auto drag_operation = DragOperation::construct(); RefPtr bitmap; @@ -235,14 +237,14 @@ void GAbstractView::mousemove_event(GMouseEvent& event) text_builder.append(", "); text_builder.append(text_data.to_string()); - auto drag_data = m_model->data(index, GModel::Role::DragData); + auto drag_data = m_model->data(index, Model::Role::DragData); data_builder.append(drag_data.to_string()); data_builder.append('\n'); first = false; if (!bitmap) { - GVariant icon_data = model()->data(index, GModel::Role::Icon); + Variant icon_data = model()->data(index, Model::Role::Icon); if (icon_data.is_icon()) bitmap = icon_data.as_icon().bitmap_for_size(32); } @@ -255,10 +257,10 @@ void GAbstractView::mousemove_event(GMouseEvent& event) auto outcome = drag_operation->exec(); switch (outcome) { - case GDragOperation::Outcome::Accepted: + case DragOperation::Outcome::Accepted: dbg() << "Drag was accepted!"; break; - case GDragOperation::Outcome::Cancelled: + case DragOperation::Outcome::Cancelled: dbg() << "Drag was cancelled!"; break; default: @@ -267,9 +269,9 @@ void GAbstractView::mousemove_event(GMouseEvent& event) } } -void GAbstractView::mouseup_event(GMouseEvent& event) +void AbstractView::mouseup_event(MouseEvent& event) { - GScrollableWidget::mouseup_event(event); + ScrollableWidget::mouseup_event(event); if (!model()) return; @@ -288,12 +290,12 @@ void GAbstractView::mouseup_event(GMouseEvent& event) } } -void GAbstractView::doubleclick_event(GMouseEvent& event) +void AbstractView::doubleclick_event(MouseEvent& event) { if (!model()) return; - if (event.button() != GMouseButton::Left) + if (event.button() != MouseButton::Left) return; m_might_drag = false; @@ -308,7 +310,7 @@ void GAbstractView::doubleclick_event(GMouseEvent& event) activate_selected(); } -void GAbstractView::context_menu_event(GContextMenuEvent& event) +void AbstractView::context_menu_event(ContextMenuEvent& event) { if (!model()) return; @@ -323,3 +325,5 @@ void GAbstractView::context_menu_event(GContextMenuEvent& event) if (on_context_menu_request) on_context_menu_request(index, event); } + +} diff --git a/Libraries/LibGUI/GAbstractView.h b/Libraries/LibGUI/GAbstractView.h index bf8fecc172a..e3de39c7980 100644 --- a/Libraries/LibGUI/GAbstractView.h +++ b/Libraries/LibGUI/GAbstractView.h @@ -31,19 +31,21 @@ #include #include -class GModelEditingDelegate; +namespace GUI { -class GAbstractView : public GScrollableWidget { - C_OBJECT(GAbstractView) - friend class GModel; +class ModelEditingDelegate; + +class AbstractView : public ScrollableWidget { + C_OBJECT_ABSTRACT(AbstractView) + friend class Model; public: - void set_model(RefPtr&&); - GModel* model() { return m_model.ptr(); } - const GModel* model() const { return m_model.ptr(); } + void set_model(RefPtr&&); + Model* model() { return m_model.ptr(); } + const Model* model() const { return m_model.ptr(); } - GModelSelection& selection() { return m_selection; } - const GModelSelection& selection() const { return m_selection; } + ModelSelection& selection() { return m_selection; } + const ModelSelection& selection() const { return m_selection; } void select_all(); bool is_editable() const { return m_editable; } @@ -53,51 +55,53 @@ public: virtual void did_update_model(); virtual void did_update_selection(); - virtual Rect content_rect(const GModelIndex&) const { return {}; } - virtual GModelIndex index_at_event_position(const Point&) const = 0; - void begin_editing(const GModelIndex&); + virtual Rect content_rect(const ModelIndex&) const { return {}; } + virtual ModelIndex index_at_event_position(const Point&) const = 0; + void begin_editing(const ModelIndex&); void stop_editing(); void set_activates_on_selection(bool b) { m_activates_on_selection = b; } bool activates_on_selection() const { return m_activates_on_selection; } Function on_selection_change; - Function on_activation; - Function on_selection; - Function on_context_menu_request; + Function on_activation; + Function on_selection; + Function on_context_menu_request; - Function(const GModelIndex&)> aid_create_editing_delegate; + Function(const ModelIndex&)> aid_create_editing_delegate; - void notify_selection_changed(Badge); + void notify_selection_changed(Badge); - NonnullRefPtr font_for_index(const GModelIndex&) const; + NonnullRefPtr font_for_index(const ModelIndex&) const; protected: - explicit GAbstractView(GWidget* parent); - virtual ~GAbstractView() override; + explicit AbstractView(Widget* parent); + virtual ~AbstractView() override; - virtual void mousedown_event(GMouseEvent&) override; - virtual void mousemove_event(GMouseEvent&) override; - virtual void mouseup_event(GMouseEvent&) override; - virtual void doubleclick_event(GMouseEvent&) override; - virtual void context_menu_event(GContextMenuEvent&) override; + virtual void mousedown_event(MouseEvent&) override; + virtual void mousemove_event(MouseEvent&) override; + virtual void mouseup_event(MouseEvent&) override; + virtual void doubleclick_event(MouseEvent&) override; + virtual void context_menu_event(ContextMenuEvent&) override; virtual void did_scroll() override; - void activate(const GModelIndex&); + void activate(const ModelIndex&); void activate_selected(); void update_edit_widget_position(); bool m_editable { false }; - GModelIndex m_edit_index; - RefPtr m_edit_widget; + ModelIndex m_edit_index; + RefPtr m_edit_widget; Rect m_edit_widget_content_rect; Point m_left_mousedown_position; bool m_might_drag { false }; private: - RefPtr m_model; - OwnPtr m_editing_delegate; - GModelSelection m_selection; + RefPtr m_model; + OwnPtr m_editing_delegate; + ModelSelection m_selection; bool m_activates_on_selection { false }; }; + +} diff --git a/Libraries/LibGUI/GAction.cpp b/Libraries/LibGUI/GAction.cpp index b7f0833f662..572da69c7bb 100644 --- a/Libraries/LibGUI/GAction.cpp +++ b/Libraries/LibGUI/GAction.cpp @@ -30,93 +30,95 @@ #include #include -namespace GCommonActions { +namespace GUI { -NonnullRefPtr make_open_action(Function callback, Core::Object* parent) +namespace CommonActions { + +NonnullRefPtr make_open_action(Function callback, Core::Object* parent) { - return GAction::create("Open...", { Mod_Ctrl, Key_O }, GraphicsBitmap::load_from_file("/res/icons/16x16/open.png"), move(callback), parent); + return Action::create("Open...", { Mod_Ctrl, Key_O }, GraphicsBitmap::load_from_file("/res/icons/16x16/open.png"), move(callback), parent); } -NonnullRefPtr make_move_to_front_action(Function callback, Core::Object* parent) +NonnullRefPtr make_move_to_front_action(Function callback, Core::Object* parent) { - return GAction::create("Move to front", { Mod_Ctrl | Mod_Shift, Key_Up }, GraphicsBitmap::load_from_file("/res/icons/16x16/move-to-front.png"), move(callback), parent); + return Action::create("Move to front", { Mod_Ctrl | Mod_Shift, Key_Up }, GraphicsBitmap::load_from_file("/res/icons/16x16/move-to-front.png"), move(callback), parent); } -NonnullRefPtr make_move_to_back_action(Function callback, Core::Object* parent) +NonnullRefPtr make_move_to_back_action(Function callback, Core::Object* parent) { - return GAction::create("Move to back", { Mod_Ctrl | Mod_Shift, Key_Down }, GraphicsBitmap::load_from_file("/res/icons/16x16/move-to-back.png"), move(callback), parent); + return Action::create("Move to back", { Mod_Ctrl | Mod_Shift, Key_Down }, GraphicsBitmap::load_from_file("/res/icons/16x16/move-to-back.png"), move(callback), parent); } -NonnullRefPtr make_undo_action(Function callback, Core::Object* parent) +NonnullRefPtr make_undo_action(Function callback, Core::Object* parent) { - return GAction::create("Undo", { Mod_Ctrl, Key_Z }, GraphicsBitmap::load_from_file("/res/icons/16x16/undo.png"), move(callback), parent); + return Action::create("Undo", { Mod_Ctrl, Key_Z }, GraphicsBitmap::load_from_file("/res/icons/16x16/undo.png"), move(callback), parent); } -NonnullRefPtr make_redo_action(Function callback, Core::Object* parent) +NonnullRefPtr make_redo_action(Function callback, Core::Object* parent) { - return GAction::create("Redo", { Mod_Ctrl, Key_Y }, GraphicsBitmap::load_from_file("/res/icons/16x16/redo.png"), move(callback), parent); + return Action::create("Redo", { Mod_Ctrl, Key_Y }, GraphicsBitmap::load_from_file("/res/icons/16x16/redo.png"), move(callback), parent); } -NonnullRefPtr make_delete_action(Function callback, Core::Object* parent) +NonnullRefPtr make_delete_action(Function callback, Core::Object* parent) { - return GAction::create("Delete", { Mod_None, Key_Delete }, GraphicsBitmap::load_from_file("/res/icons/16x16/delete.png"), move(callback), parent); + return Action::create("Delete", { Mod_None, Key_Delete }, GraphicsBitmap::load_from_file("/res/icons/16x16/delete.png"), move(callback), parent); } -NonnullRefPtr make_cut_action(Function callback, Core::Object* parent) +NonnullRefPtr make_cut_action(Function callback, Core::Object* parent) { - return GAction::create("Cut", { Mod_Ctrl, Key_X }, GraphicsBitmap::load_from_file("/res/icons/cut16.png"), move(callback), parent); + return Action::create("Cut", { Mod_Ctrl, Key_X }, GraphicsBitmap::load_from_file("/res/icons/cut16.png"), move(callback), parent); } -NonnullRefPtr make_copy_action(Function callback, Core::Object* parent) +NonnullRefPtr make_copy_action(Function callback, Core::Object* parent) { - return GAction::create("Copy", { Mod_Ctrl, Key_C }, GraphicsBitmap::load_from_file("/res/icons/16x16/edit-copy.png"), move(callback), parent); + return Action::create("Copy", { Mod_Ctrl, Key_C }, GraphicsBitmap::load_from_file("/res/icons/16x16/edit-copy.png"), move(callback), parent); } -NonnullRefPtr make_paste_action(Function callback, Core::Object* parent) +NonnullRefPtr make_paste_action(Function callback, Core::Object* parent) { - return GAction::create("Paste", { Mod_Ctrl, Key_V }, GraphicsBitmap::load_from_file("/res/icons/paste16.png"), move(callback), parent); + return Action::create("Paste", { Mod_Ctrl, Key_V }, GraphicsBitmap::load_from_file("/res/icons/paste16.png"), move(callback), parent); } -NonnullRefPtr make_fullscreen_action(Function callback, Core::Object* parent) +NonnullRefPtr make_fullscreen_action(Function callback, Core::Object* parent) { - return GAction::create("Fullscreen", { Mod_None, Key_F11 }, move(callback), parent); + return Action::create("Fullscreen", { Mod_None, Key_F11 }, move(callback), parent); } -NonnullRefPtr make_quit_action(Function callback) +NonnullRefPtr make_quit_action(Function callback) { - return GAction::create("Quit", { Mod_Alt, Key_F4 }, move(callback)); + return Action::create("Quit", { Mod_Alt, Key_F4 }, move(callback)); } -NonnullRefPtr make_go_back_action(Function callback, Core::Object* parent) +NonnullRefPtr make_go_back_action(Function callback, Core::Object* parent) { - return GAction::create("Go back", { Mod_Alt, Key_Left }, GraphicsBitmap::load_from_file("/res/icons/16x16/go-back.png"), move(callback), parent); + return Action::create("Go back", { Mod_Alt, Key_Left }, GraphicsBitmap::load_from_file("/res/icons/16x16/go-back.png"), move(callback), parent); } -NonnullRefPtr make_go_forward_action(Function callback, Core::Object* parent) +NonnullRefPtr make_go_forward_action(Function callback, Core::Object* parent) { - return GAction::create("Go forward", { Mod_Alt, Key_Right }, GraphicsBitmap::load_from_file("/res/icons/16x16/go-forward.png"), move(callback), parent); + return Action::create("Go forward", { Mod_Alt, Key_Right }, GraphicsBitmap::load_from_file("/res/icons/16x16/go-forward.png"), move(callback), parent); } -NonnullRefPtr make_go_home_action(Function callback, Core::Object* parent) +NonnullRefPtr make_go_home_action(Function callback, Core::Object* parent) { - return GAction::create("Go home", { Mod_Alt, Key_Home }, GraphicsBitmap::load_from_file("/res/icons/16x16/go-home.png"), move(callback), parent); + return Action::create("Go home", { Mod_Alt, Key_Home }, GraphicsBitmap::load_from_file("/res/icons/16x16/go-home.png"), move(callback), parent); } -NonnullRefPtr make_reload_action(Function callback, Core::Object* parent) +NonnullRefPtr make_reload_action(Function callback, Core::Object* parent) { - return GAction::create("Reload", { Mod_Ctrl, Key_R }, GraphicsBitmap::load_from_file("/res/icons/16x16/reload.png"), move(callback), parent); + return Action::create("Reload", { Mod_Ctrl, Key_R }, GraphicsBitmap::load_from_file("/res/icons/16x16/reload.png"), move(callback), parent); } } -GAction::GAction(const StringView& text, Function on_activation_callback, Core::Object* parent) +Action::Action(const StringView& text, Function on_activation_callback, Core::Object* parent) : Core::Object(parent) , on_activation(move(on_activation_callback)) , m_text(text) { } -GAction::GAction(const StringView& text, RefPtr&& icon, Function on_activation_callback, Core::Object* parent) +Action::Action(const StringView& text, RefPtr&& icon, Function on_activation_callback, Core::Object* parent) : Core::Object(parent) , on_activation(move(on_activation_callback)) , m_text(text) @@ -124,35 +126,35 @@ GAction::GAction(const StringView& text, RefPtr&& icon, Function { } -GAction::GAction(const StringView& text, const GShortcut& shortcut, Function on_activation_callback, Core::Object* parent) - : GAction(text, shortcut, nullptr, move(on_activation_callback), parent) +Action::Action(const StringView& text, const Shortcut& shortcut, Function on_activation_callback, Core::Object* parent) + : Action(text, shortcut, nullptr, move(on_activation_callback), parent) { } -GAction::GAction(const StringView& text, const GShortcut& shortcut, RefPtr&& icon, Function on_activation_callback, Core::Object* parent) +Action::Action(const StringView& text, const Shortcut& shortcut, RefPtr&& icon, Function on_activation_callback, Core::Object* parent) : Core::Object(parent) , on_activation(move(on_activation_callback)) , m_text(text) , m_icon(move(icon)) , m_shortcut(shortcut) { - if (parent && Core::is(*parent)) { + if (parent && Core::is(*parent)) { m_scope = ShortcutScope::WidgetLocal; - } else if (parent && Core::is(*parent)) { + } else if (parent && Core::is(*parent)) { m_scope = ShortcutScope::WindowLocal; } else { m_scope = ShortcutScope::ApplicationGlobal; - GApplication::the().register_global_shortcut_action({}, *this); + Application::the().register_global_shortcut_action({}, *this); } } -GAction::~GAction() +Action::~Action() { if (m_shortcut.is_valid() && m_scope == ShortcutScope::ApplicationGlobal) - GApplication::the().unregister_global_shortcut_action({}, *this); + Application::the().unregister_global_shortcut_action({}, *this); } -void GAction::activate(Core::Object* activator) +void Action::activate(Core::Object* activator) { if (activator) m_activator = activator->make_weak_ptr(); @@ -161,54 +163,54 @@ void GAction::activate(Core::Object* activator) m_activator = nullptr; } -void GAction::register_button(Badge, GButton& button) +void Action::register_button(Badge