mirror of
				https://github.com/RGBCube/serenity
				synced 2025-10-31 06:32:44 +00:00 
			
		
		
		
	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! :^)
This commit is contained in:
		
							parent
							
								
									2d39da5405
								
							
						
					
					
						commit
						c5bd9d4ed1
					
				
					 337 changed files with 5400 additions and 4816 deletions
				
			
		|  | @ -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<GVBoxLayout>()); | ||||
|     widget->set_layout(make<GUI::VBoxLayout>()); | ||||
|     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); | ||||
|  |  | |||
|  | @ -35,12 +35,12 @@ | |||
| #include <LibHTML/DOMTreeModel.h> | ||||
| #include <LibHTML/StylePropertiesModel.h> | ||||
| 
 | ||||
| InspectorWidget::InspectorWidget(GWidget* parent) | ||||
|     : GWidget(parent) | ||||
| InspectorWidget::InspectorWidget(GUI::Widget* parent) | ||||
|     : GUI::Widget(parent) | ||||
| { | ||||
|     set_layout(make<GVBoxLayout>()); | ||||
|     auto splitter = GSplitter::construct(Orientation::Vertical, this); | ||||
|     m_dom_tree_view = GTreeView::construct(splitter); | ||||
|     set_layout(make<GUI::VBoxLayout>()); | ||||
|     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<Node*>(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); | ||||
| } | ||||
|  |  | |||
|  | @ -27,10 +27,13 @@ | |||
| #include <LibGUI/GWidget.h> | ||||
| 
 | ||||
| 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<GTreeView> m_dom_tree_view; | ||||
|     RefPtr<GTableView> m_style_table_view; | ||||
|     RefPtr<GTableView> m_computed_style_table_view; | ||||
|     RefPtr<GUI::TreeView> m_dom_tree_view; | ||||
|     RefPtr<GUI::TableView> m_style_table_view; | ||||
|     RefPtr<GUI::TableView> m_computed_style_table_view; | ||||
|     RefPtr<Document> m_document; | ||||
| }; | ||||
|  |  | |||
|  | @ -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<GVBoxLayout>()); | ||||
|     widget->set_layout(make<GUI::VBoxLayout>()); | ||||
|     widget->layout()->set_spacing(0); | ||||
| 
 | ||||
|     auto toolbar = GToolBar::construct(widget); | ||||
|     auto toolbar = GUI::ToolBar::construct(widget); | ||||
|     auto html_widget = HtmlView::construct(widget); | ||||
| 
 | ||||
|     History<URL> history; | ||||
| 
 | ||||
|     RefPtr<GAction> go_back_action; | ||||
|     RefPtr<GAction> go_forward_action; | ||||
|     RefPtr<GUI::Action> go_back_action; | ||||
|     RefPtr<GUI::Action> 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<bool> 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<bool> 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<bool> 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<GMenuBar>(); | ||||
|     auto menubar = make<GUI::MenuBar>(); | ||||
| 
 | ||||
|     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<GWindow> dom_inspector_window; | ||||
|     RefPtr<GUI::Window> 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)); | ||||
| 
 | ||||
|  |  | |||
|  | @ -30,16 +30,16 @@ | |||
| #include <LibGUI/GLabel.h> | ||||
| #include <LibGUI/GTextBox.h> | ||||
| 
 | ||||
| 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); | ||||
|  |  | |||
|  | @ -31,47 +31,49 @@ | |||
| #include <AK/Vector.h> | ||||
| #include <LibGUI/GWidget.h> | ||||
| 
 | ||||
| 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<GTextBox> m_entry; | ||||
|     RefPtr<GLabel> m_label; | ||||
|     RefPtr<GUI::TextBox> m_entry; | ||||
|     RefPtr<GUI::Label> m_label; | ||||
| 
 | ||||
|     RefPtr<GButton> m_digit_button[10]; | ||||
|     RefPtr<GButton> m_mem_add_button; | ||||
|     RefPtr<GButton> m_mem_save_button; | ||||
|     RefPtr<GButton> m_mem_recall_button; | ||||
|     RefPtr<GButton> m_mem_clear_button; | ||||
|     RefPtr<GButton> m_clear_button; | ||||
|     RefPtr<GButton> m_clear_error_button; | ||||
|     RefPtr<GButton> m_backspace_button; | ||||
|     RefPtr<GButton> m_decimal_point_button; | ||||
|     RefPtr<GButton> m_sign_button; | ||||
|     RefPtr<GButton> m_add_button; | ||||
|     RefPtr<GButton> m_subtract_button; | ||||
|     RefPtr<GButton> m_multiply_button; | ||||
|     RefPtr<GButton> m_divide_button; | ||||
|     RefPtr<GButton> m_sqrt_button; | ||||
|     RefPtr<GButton> m_inverse_button; | ||||
|     RefPtr<GButton> m_percent_button; | ||||
|     RefPtr<GButton> m_equals_button; | ||||
|     RefPtr<GUI::Button> m_digit_button[10]; | ||||
|     RefPtr<GUI::Button> m_mem_add_button; | ||||
|     RefPtr<GUI::Button> m_mem_save_button; | ||||
|     RefPtr<GUI::Button> m_mem_recall_button; | ||||
|     RefPtr<GUI::Button> m_mem_clear_button; | ||||
|     RefPtr<GUI::Button> m_clear_button; | ||||
|     RefPtr<GUI::Button> m_clear_error_button; | ||||
|     RefPtr<GUI::Button> m_backspace_button; | ||||
|     RefPtr<GUI::Button> m_decimal_point_button; | ||||
|     RefPtr<GUI::Button> m_sign_button; | ||||
|     RefPtr<GUI::Button> m_add_button; | ||||
|     RefPtr<GUI::Button> m_subtract_button; | ||||
|     RefPtr<GUI::Button> m_multiply_button; | ||||
|     RefPtr<GUI::Button> m_divide_button; | ||||
|     RefPtr<GUI::Button> m_sqrt_button; | ||||
|     RefPtr<GUI::Button> m_inverse_button; | ||||
|     RefPtr<GUI::Button> m_percent_button; | ||||
|     RefPtr<GUI::Button> m_equals_button; | ||||
| }; | ||||
|  |  | |||
|  | @ -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<GMenuBar>(); | ||||
|     auto menubar = make<GUI::MenuBar>(); | ||||
| 
 | ||||
|     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)); | ||||
| 
 | ||||
|  |  | |||
|  | @ -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) { | ||||
|  |  | |||
|  | @ -30,7 +30,7 @@ | |||
| #include <LibCore/CHttpJob.h> | ||||
| #include <LibGUI/GModel.h> | ||||
| 
 | ||||
| class BoardListModel final : public GModel { | ||||
| class BoardListModel final : public GUI::Model { | ||||
| public: | ||||
|     enum Column { | ||||
|         Board, | ||||
|  | @ -40,11 +40,11 @@ public: | |||
|     static NonnullRefPtr<BoardListModel> 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: | ||||
|  |  | |||
|  | @ -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) { | ||||
|  |  | |||
|  | @ -30,7 +30,7 @@ | |||
| #include <LibCore/CHttpJob.h> | ||||
| #include <LibGUI/GModel.h> | ||||
| 
 | ||||
| class ThreadCatalogModel final : public GModel { | ||||
| class ThreadCatalogModel final : public GUI::Model { | ||||
| public: | ||||
|     enum Column { | ||||
|         ThreadNumber, | ||||
|  | @ -45,11 +45,11 @@ public: | |||
|     static NonnullRefPtr<ThreadCatalogModel> 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; } | ||||
|  |  | |||
|  | @ -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<GVBoxLayout>()); | ||||
|     widget->set_layout(make<GUI::VBoxLayout>()); | ||||
| 
 | ||||
|     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<ThreadCatalogModel*>(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<GMenuBar>(); | ||||
|     auto menubar = make<GUI::MenuBar>(); | ||||
| 
 | ||||
|     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)); | ||||
| 
 | ||||
|  |  | |||
|  | @ -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<GVBoxLayout>()); | ||||
|     m_root_widget = GUI::Widget::construct(); | ||||
|     m_root_widget->set_layout(make<GUI::VBoxLayout>()); | ||||
|     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<GVBoxLayout>()); | ||||
|     auto background_content = GUI::Widget::construct(background_splitter.ptr()); | ||||
|     background_content->set_layout(make<GUI::VBoxLayout>()); | ||||
|     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<AK::String>::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<GVBoxLayout>()); | ||||
|     auto settings_content = GUI::Widget::construct(settings_splitter.ptr()); | ||||
|     settings_content->set_layout(make<GUI::VBoxLayout>()); | ||||
|     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<Size>::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<GHBoxLayout>()); | ||||
|     auto bottom_widget = GUI::Widget::construct(m_root_widget.ptr()); | ||||
|     bottom_widget->set_layout(make<GUI::HBoxLayout>()); | ||||
|     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<WindowServer::SetResolution>(m_selected_resolution); | ||||
|         GUI::WindowServerConnection::the().send_sync<WindowServer::SetResolution>(m_selected_resolution); | ||||
|     } else { | ||||
|         dbg() << "Invalid tab index " << tab_index; | ||||
|     } | ||||
|  |  | |||
|  | @ -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<Core::ConfigFile> m_wm_config; | ||||
|     RefPtr<GWidget> m_root_widget; | ||||
|     RefPtr<GUI::Widget> m_root_widget; | ||||
|     Vector<Size> m_resolutions; | ||||
|     Vector<String> m_wallpapers; | ||||
|     RefPtr<GLabel> m_wallpaper_preview; | ||||
|     RefPtr<GUI::Label> m_wallpaper_preview; | ||||
| 
 | ||||
|     Size m_selected_resolution; | ||||
|     String m_selected_wallpaper; | ||||
|  |  | |||
|  | @ -31,18 +31,18 @@ | |||
| #include <LibGUI/GModel.h> | ||||
| 
 | ||||
| template<typename T> | ||||
| class ItemListModel final : public GModel { | ||||
| class ItemListModel final : public GUI::Model { | ||||
| public: | ||||
|     static NonnullRefPtr<ItemListModel> create(Vector<T>& data) { return adopt(*new ItemListModel<T>(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()); | ||||
|  |  | |||
|  | @ -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<GMenuBar>(); | ||||
|     auto menubar = make<GUI::MenuBar>(); | ||||
| 
 | ||||
|     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)); | ||||
| 
 | ||||
|  |  | |||
|  | @ -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); | ||||
|         } | ||||
| 
 | ||||
|  |  | |||
|  | @ -34,7 +34,7 @@ | |||
| #include <LibGUI/GTableView.h> | ||||
| #include <sys/stat.h> | ||||
| 
 | ||||
| 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<void(const StringView&)> on_path_change; | ||||
|     Function<void(GAbstractView&)> on_selection_change; | ||||
|     Function<void(const GAbstractView&, const GModelIndex&, const GContextMenuEvent&)> on_context_menu_request; | ||||
|     Function<void(GUI::AbstractView&)> on_selection_change; | ||||
|     Function<void(const GUI::AbstractView&, const GUI::ModelIndex&, const GUI::ContextMenuEvent&)> on_context_menu_request; | ||||
|     Function<void(const StringView&)> on_status_message; | ||||
|     Function<void(int done, int total)> 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<GFileSystemModel> m_model; | ||||
|     NonnullRefPtr<GUI::FileSystemModel> m_model; | ||||
|     int m_path_history_position { 0 }; | ||||
|     Vector<String> m_path_history; | ||||
|     void add_path_to_history(const StringView& path); | ||||
| 
 | ||||
|     RefPtr<GTableView> m_table_view; | ||||
|     RefPtr<GItemView> m_item_view; | ||||
|     RefPtr<GColumnsView> m_columns_view; | ||||
|     RefPtr<GUI::TableView> m_table_view; | ||||
|     RefPtr<GUI::ItemView> m_item_view; | ||||
|     RefPtr<GUI::ColumnsView> m_columns_view; | ||||
| }; | ||||
|  |  | |||
|  | @ -35,15 +35,15 @@ | |||
| #include <stdio.h> | ||||
| #include <unistd.h> | ||||
| 
 | ||||
| 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<GVBoxLayout>()); | ||||
|     auto main_widget = GUI::Widget::construct(); | ||||
|     main_widget->set_layout(make<GUI::VBoxLayout>()); | ||||
|     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<GVBoxLayout>()); | ||||
|     auto general_tab = GUI::Widget::construct(tab_widget.ptr()); | ||||
|     general_tab->set_layout(make<GUI::VBoxLayout>()); | ||||
|     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<GHBoxLayout>()); | ||||
|     file_container->set_size_policy(SizePolicy::Fill, SizePolicy::Fixed); | ||||
|     auto file_container = GUI::Widget::construct(general_tab.ptr()); | ||||
|     file_container->set_layout(make<GUI::HBoxLayout>()); | ||||
|     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<u32>(user_pw->pw_uid)) }); | ||||
|     properties.append({ "Group:", String::format("%s (%lu)", group_pw->pw_name, static_cast<u32>(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<GHBoxLayout>()); | ||||
|     button_widget->set_size_policy(SizePolicy::Fill, SizePolicy::Fixed); | ||||
|     auto button_widget = GUI::Widget::construct(main_widget.ptr()); | ||||
|     button_widget->set_layout(make<GUI::HBoxLayout>()); | ||||
|     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<GWidget>& parent, PermissionMasks masks, String label_string, mode_t mode) | ||||
| void PropertiesDialog::make_permission_checkboxes(NonnullRefPtr<GUI::Widget>& parent, PermissionMasks masks, String label_string, mode_t mode) | ||||
| { | ||||
|     auto widget = GWidget::construct(parent.ptr()); | ||||
|     widget->set_layout(make<GHBoxLayout>()); | ||||
|     widget->set_size_policy(SizePolicy::Fill, SizePolicy::Fixed); | ||||
|     auto widget = GUI::Widget::construct(parent.ptr()); | ||||
|     widget->set_layout(make<GUI::HBoxLayout>()); | ||||
|     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<PropertyValuePair>& pairs, NonnullRefPtr<GWidget>& parent) | ||||
| void PropertiesDialog::make_property_value_pairs(const Vector<PropertyValuePair>& pairs, NonnullRefPtr<GUI::Widget>& parent) | ||||
| { | ||||
|     int max_width = 0; | ||||
|     Vector<NonnullRefPtr<GLabel>> property_labels; | ||||
|     Vector<NonnullRefPtr<GUI::Label>> property_labels; | ||||
| 
 | ||||
|     property_labels.ensure_capacity(pairs.size()); | ||||
|     for (auto pair : pairs) { | ||||
|         auto label_container = GWidget::construct(parent.ptr()); | ||||
|         label_container->set_layout(make<GHBoxLayout>()); | ||||
|         label_container->set_size_policy(SizePolicy::Fill, SizePolicy::Fixed); | ||||
|         auto label_container = GUI::Widget::construct(parent.ptr()); | ||||
|         label_container->set_layout(make<GUI::HBoxLayout>()); | ||||
|         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<PropertyValuePair> | |||
|         label->set_preferred_size({ max_width, 0 }); | ||||
| } | ||||
| 
 | ||||
| NonnullRefPtr<GButton> PropertiesDialog::make_button(String text, NonnullRefPtr<GWidget>& parent) | ||||
| NonnullRefPtr<GUI::Button> PropertiesDialog::make_button(String text, NonnullRefPtr<GUI::Widget>& 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<GWidget>& parent) | ||||
| void PropertiesDialog::make_divider(NonnullRefPtr<GUI::Widget>& 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); | ||||
|  |  | |||
|  | @ -34,13 +34,13 @@ | |||
| #include <LibGUI/GLabel.h> | ||||
| #include <LibGUI/GTextBox.h> | ||||
| 
 | ||||
| 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<GButton> make_button(String, NonnullRefPtr<GWidget>&); | ||||
|     void make_divider(NonnullRefPtr<GWidget>&); | ||||
|     void make_property_value_pairs(const Vector<PropertyValuePair>& pairs, NonnullRefPtr<GWidget>& parent); | ||||
|     void make_permission_checkboxes(NonnullRefPtr<GWidget>& parent, PermissionMasks, String label_string, mode_t mode); | ||||
|     NonnullRefPtr<GUI::Button> make_button(String, NonnullRefPtr<GUI::Widget>&); | ||||
|     void make_divider(NonnullRefPtr<GUI::Widget>&); | ||||
|     void make_property_value_pairs(const Vector<PropertyValuePair>& pairs, NonnullRefPtr<GUI::Widget>& parent); | ||||
|     void make_permission_checkboxes(NonnullRefPtr<GUI::Widget>& 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<GButton> m_apply_button; | ||||
|     RefPtr<GTextBox> m_name_box; | ||||
|     RefPtr<GLabel> m_icon; | ||||
|     GUI::FileSystemModel& m_model; | ||||
|     RefPtr<GUI::Button> m_apply_button; | ||||
|     RefPtr<GUI::TextBox> m_name_box; | ||||
|     RefPtr<GUI::Label> m_icon; | ||||
|     String m_name; | ||||
|     String m_path; | ||||
|     mode_t m_mode; | ||||
|  |  | |||
|  | @ -74,14 +74,14 @@ int main(int argc, char** argv) | |||
| 
 | ||||
|     RefPtr<Core::ConfigFile> 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<GVBoxLayout>()); | ||||
|     auto widget = GUI::Widget::construct(); | ||||
|     widget->set_layout(make<GUI::VBoxLayout>()); | ||||
|     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<GAction> view_as_table_action; | ||||
|     RefPtr<GAction> view_as_icons_action; | ||||
|     RefPtr<GAction> view_as_columns_action; | ||||
|     RefPtr<GUI::Action> view_as_table_action; | ||||
|     RefPtr<GUI::Action> view_as_icons_action; | ||||
|     RefPtr<GUI::Action> 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<GActionGroup>(); | ||||
|     auto view_type_action_group = make<GUI::ActionGroup>(); | ||||
|     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<String> 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<String> 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<String> 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<String> 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<String> 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<GMenuBar>(); | ||||
|     auto menubar = make<GUI::MenuBar>(); | ||||
| 
 | ||||
|     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(); | ||||
|  |  | |||
|  | @ -38,8 +38,8 @@ | |||
| #include <LibGUI/GTextBox.h> | ||||
| #include <stdlib.h> | ||||
| 
 | ||||
| FontEditorWidget::FontEditorWidget(const String& path, RefPtr<Font>&& edited_font, GWidget* parent) | ||||
|     : GWidget(parent) | ||||
| FontEditorWidget::FontEditorWidget(const String& path, RefPtr<Font>&& 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<Font>&& 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); | ||||
|     }; | ||||
|  |  | |||
|  | @ -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<Font>&&, GWidget* parent = nullptr); | ||||
|     FontEditorWidget(const String& path, RefPtr<Font>&&, GUI::Widget* parent = nullptr); | ||||
|     RefPtr<Font> m_edited_font; | ||||
| 
 | ||||
|     GlyphMapWidget* m_glyph_map_widget { nullptr }; | ||||
|  |  | |||
|  | @ -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}]} | ||||
|  |  | |||
|  | @ -27,8 +27,8 @@ | |||
| #include "GlyphEditorWidget.h" | ||||
| #include <LibGUI/GPainter.h> | ||||
| 
 | ||||
| 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; | ||||
|  |  | |||
|  | @ -27,7 +27,7 @@ | |||
| #include <AK/Function.h> | ||||
| #include <LibGUI/GFrame.h> | ||||
| 
 | ||||
| class GlyphEditorWidget final : public GFrame { | ||||
| class GlyphEditorWidget final : public GUI::Frame { | ||||
|     C_OBJECT(GlyphEditorWidget) | ||||
| public: | ||||
|     virtual ~GlyphEditorWidget() override; | ||||
|  | @ -44,12 +44,12 @@ public: | |||
|     Function<void(u8)> 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<Font> m_font; | ||||
|     u8 m_glyph { 0 }; | ||||
|  |  | |||
|  | @ -28,8 +28,8 @@ | |||
| #include <LibDraw/Palette.h> | ||||
| #include <LibGUI/GPainter.h> | ||||
| 
 | ||||
| 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) { | ||||
|  |  | |||
|  | @ -29,7 +29,7 @@ | |||
| #include <AK/Function.h> | ||||
| #include <LibGUI/GFrame.h> | ||||
| 
 | ||||
| class GlyphMapWidget final : public GFrame { | ||||
| class GlyphMapWidget final : public GUI::Frame { | ||||
|     C_OBJECT(GlyphMapWidget) | ||||
| public: | ||||
|     virtual ~GlyphMapWidget() override; | ||||
|  | @ -51,9 +51,9 @@ public: | |||
|     Function<void(u8)> 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; | ||||
| 
 | ||||
|  |  | |||
|  | @ -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<GMenuBar>(); | ||||
|     auto menubar = make<GUI::MenuBar>(); | ||||
| 
 | ||||
|     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)); | ||||
| 
 | ||||
|  |  | |||
|  | @ -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<const ManualNode*>(index.internal_data()); | ||||
|     switch (role) { | ||||
|  |  | |||
|  | @ -30,7 +30,7 @@ | |||
| #include <AK/String.h> | ||||
| #include <LibGUI/GModel.h> | ||||
| 
 | ||||
| class ManualModel final : public GModel { | ||||
| class ManualModel final : public GUI::Model { | ||||
| public: | ||||
|     static NonnullRefPtr<ManualModel> 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(); | ||||
|  |  | |||
|  | @ -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<GVBoxLayout>()); | ||||
|     auto widget = GUI::Widget::construct(); | ||||
|     widget->set_layout(make<GUI::VBoxLayout>()); | ||||
|     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<GAction> go_back_action; | ||||
|     RefPtr<GAction> go_forward_action; | ||||
|     RefPtr<GUI::Action> go_back_action; | ||||
|     RefPtr<GUI::Action> 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<GMenuBar>(); | ||||
|     auto menubar = make<GUI::MenuBar>(); | ||||
| 
 | ||||
|     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)); | ||||
|  |  | |||
|  | @ -41,8 +41,8 @@ | |||
| #include <stdio.h> | ||||
| #include <unistd.h> | ||||
| 
 | ||||
| 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); | ||||
| } | ||||
|  |  | |||
|  | @ -34,7 +34,7 @@ | |||
| #include <LibDraw/TextAlignment.h> | ||||
| #include <LibGUI/GScrollableWidget.h> | ||||
| 
 | ||||
| class HexEditor : public GScrollableWidget { | ||||
| class HexEditor : public GUI::ScrollableWidget { | ||||
|     C_OBJECT(HexEditor) | ||||
| public: | ||||
|     enum EditMode { | ||||
|  | @ -65,13 +65,13 @@ public: | |||
|     Function<void()> 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,8 +97,8 @@ 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(); | ||||
|  |  | |||
|  | @ -46,7 +46,7 @@ | |||
| 
 | ||||
| HexEditorWidget::HexEditorWidget() | ||||
| { | ||||
|     set_layout(make<GVBoxLayout>()); | ||||
|     set_layout(make<GUI::VBoxLayout>()); | ||||
|     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<String> open_path = GFilePicker::get_open_filepath(); | ||||
|     m_open_action = GUI::CommonActions::make_open_action([this](auto&) { | ||||
|         Optional<String> 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<String> 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<String> 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<GMenuBar>(); | ||||
|     auto app_menu = GMenu::construct("Hex Editor"); | ||||
|     auto menubar = make<GUI::MenuBar>(); | ||||
|     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; | ||||
| } | ||||
|  |  | |||
|  | @ -34,10 +34,13 @@ | |||
| #include <LibGUI/GWidget.h> | ||||
| #include <LibGUI/GWindow.h> | ||||
| 
 | ||||
| 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<GAction> m_new_action; | ||||
|     RefPtr<GAction> m_open_action; | ||||
|     RefPtr<GAction> m_save_action; | ||||
|     RefPtr<GAction> m_save_as_action; | ||||
|     RefPtr<GAction> m_goto_decimal_offset_action; | ||||
|     RefPtr<GAction> m_goto_hex_offset_action; | ||||
|     RefPtr<GUI::Action> m_new_action; | ||||
|     RefPtr<GUI::Action> m_open_action; | ||||
|     RefPtr<GUI::Action> m_save_action; | ||||
|     RefPtr<GUI::Action> m_save_as_action; | ||||
|     RefPtr<GUI::Action> m_goto_decimal_offset_action; | ||||
|     RefPtr<GUI::Action> m_goto_hex_offset_action; | ||||
| 
 | ||||
|     RefPtr<GStatusBar> m_statusbar; | ||||
|     RefPtr<GUI::StatusBar> m_statusbar; | ||||
| 
 | ||||
|     bool m_document_dirty { false }; | ||||
| }; | ||||
|  |  | |||
|  | @ -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(); | ||||
|  |  | |||
|  | @ -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<GMenuBar>(); | ||||
|     auto app_menu = GMenu::construct("IRC Client"); | ||||
|     app_menu->add_action(GCommonActions::make_quit_action([](auto&) { | ||||
|     auto menubar = make<GUI::MenuBar>(); | ||||
|     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<GVBoxLayout>()); | ||||
|     widget->set_layout(make<GUI::VBoxLayout>()); | ||||
|     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<GVBoxLayout>()); | ||||
|     auto outer_container = GUI::Widget::construct(widget.ptr()); | ||||
|     outer_container->set_layout(make<GUI::VBoxLayout>()); | ||||
|     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(); | ||||
|     }; | ||||
|  |  | |||
|  | @ -31,11 +31,12 @@ | |||
| #include <LibGUI/GWidget.h> | ||||
| #include <LibGUI/GWindow.h> | ||||
| 
 | ||||
| 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<GStackWidget> m_container; | ||||
|     RefPtr<GTableView> m_window_list; | ||||
|     RefPtr<GAction> m_join_action; | ||||
|     RefPtr<GAction> m_part_action; | ||||
|     RefPtr<GAction> m_whois_action; | ||||
|     RefPtr<GAction> m_open_query_action; | ||||
|     RefPtr<GAction> m_close_query_action; | ||||
|     RefPtr<GAction> m_change_nick_action; | ||||
|     RefPtr<GUI::StackWidget> m_container; | ||||
|     RefPtr<GUI::TableView> m_window_list; | ||||
|     RefPtr<GUI::Action> m_join_action; | ||||
|     RefPtr<GUI::Action> m_part_action; | ||||
|     RefPtr<GUI::Action> m_whois_action; | ||||
|     RefPtr<GUI::Action> m_open_query_action; | ||||
|     RefPtr<GUI::Action> m_close_query_action; | ||||
|     RefPtr<GUI::Action> m_change_nick_action; | ||||
| }; | ||||
|  |  | |||
|  | @ -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()) { | ||||
|  |  | |||
|  | @ -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<IRCChannelMemberListModel> 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: | ||||
|  |  | |||
|  | @ -35,32 +35,32 @@ | |||
| #include <LibGUI/GTextEditor.h> | ||||
| #include <LibHTML/HtmlView.h> | ||||
| 
 | ||||
| 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<GVBoxLayout>()); | ||||
|     set_layout(make<GUI::VBoxLayout>()); | ||||
| 
 | ||||
|     // 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) | ||||
|  |  | |||
|  | @ -28,14 +28,17 @@ | |||
| 
 | ||||
| #include <LibGUI/GWidget.h> | ||||
| 
 | ||||
| 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<HtmlView> m_html_view; | ||||
|     RefPtr<GTextEditor> m_text_editor; | ||||
|     RefPtr<GUI::TextEditor> m_text_editor; | ||||
|     RefPtr<IRCLogBuffer> m_log_buffer; | ||||
|     int m_unread_count { 0 }; | ||||
| }; | ||||
|  |  | |||
|  | @ -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()) { | ||||
|  |  | |||
|  | @ -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<IRCWindowListModel> 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: | ||||
|  |  | |||
|  | @ -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"); | ||||
|  |  | |||
|  | @ -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)); | ||||
|  |  | |||
|  | @ -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"; } | ||||
|  |  | |||
|  | @ -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); | ||||
|             }); | ||||
|  |  | |||
|  | @ -30,20 +30,22 @@ | |||
| #include <LibDraw/Point.h> | ||||
| #include <LibGUI/GActionGroup.h> | ||||
| 
 | ||||
| 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<GMenu> m_context_menu; | ||||
|     RefPtr<GUI::Menu> m_context_menu; | ||||
|     int m_thickness { 1 }; | ||||
|     GActionGroup m_thickness_actions; | ||||
|     GUI::ActionGroup m_thickness_actions; | ||||
|     Mode m_mode { Mode::Outline }; | ||||
| }; | ||||
|  |  | |||
|  | @ -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<GAction> eraser_color_toggler = GAction::create("Use secondary color", [&](GAction& action) { | ||||
|         NonnullRefPtr<GUI::Action> 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); | ||||
|             }); | ||||
|  |  | |||
|  | @ -30,24 +30,26 @@ | |||
| #include <LibDraw/Point.h> | ||||
| #include <LibGUI/GActionGroup.h> | ||||
| 
 | ||||
| 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<GMenu> m_context_menu; | ||||
|     RefPtr<GUI::Menu> m_context_menu; | ||||
| 
 | ||||
|     bool m_use_secondary_color { true }; | ||||
|     int m_thickness { 1 }; | ||||
|     GActionGroup m_thickness_actions; | ||||
|     GUI::ActionGroup m_thickness_actions; | ||||
| }; | ||||
|  |  | |||
|  | @ -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); | ||||
|             }); | ||||
|  |  | |||
|  | @ -30,29 +30,31 @@ | |||
| #include <LibDraw/Point.h> | ||||
| #include <LibGUI/GActionGroup.h> | ||||
| 
 | ||||
| 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<GMenu> m_context_menu; | ||||
|     GActionGroup m_thickness_actions; | ||||
|     RefPtr<GUI::Menu> m_context_menu; | ||||
|     GUI::ActionGroup m_thickness_actions; | ||||
|     int m_thickness { 1 }; | ||||
|     bool m_constrain_angle { false }; | ||||
| }; | ||||
|  |  | |||
|  | @ -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) | ||||
|  |  | |||
|  | @ -29,12 +29,12 @@ | |||
| #include <LibGUI/GWidget.h> | ||||
| 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<GraphicsBitmap> m_bitmap; | ||||
| 
 | ||||
|  |  | |||
|  | @ -29,11 +29,11 @@ | |||
| #include <LibGUI/GBoxLayout.h> | ||||
| #include <LibGUI/GColorPicker.h> | ||||
| 
 | ||||
| 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<GVBoxLayout>()); | ||||
|     color_container->set_layout(make<GUI::VBoxLayout>()); | ||||
|     color_container->layout()->set_spacing(1); | ||||
| 
 | ||||
|     auto top_color_container = GWidget::construct(color_container.ptr()); | ||||
|     top_color_container->set_layout(make<GHBoxLayout>()); | ||||
|     auto top_color_container = GUI::Widget::construct(color_container.ptr()); | ||||
|     top_color_container->set_layout(make<GUI::HBoxLayout>()); | ||||
|     top_color_container->layout()->set_spacing(1); | ||||
| 
 | ||||
|     auto bottom_color_container = GWidget::construct(color_container.ptr()); | ||||
|     bottom_color_container->set_layout(make<GHBoxLayout>()); | ||||
|     auto bottom_color_container = GUI::Widget::construct(color_container.ptr()); | ||||
|     bottom_color_container->set_layout(make<GUI::HBoxLayout>()); | ||||
|     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(); | ||||
|  |  | |||
|  | @ -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<GFrame> m_primary_color_widget; | ||||
|     RefPtr<GFrame> m_secondary_color_widget; | ||||
|     RefPtr<GUI::Frame> m_primary_color_widget; | ||||
|     RefPtr<GUI::Frame> m_secondary_color_widget; | ||||
| }; | ||||
|  |  | |||
|  | @ -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); | ||||
|             }); | ||||
|  |  | |||
|  | @ -30,23 +30,25 @@ | |||
| #include <LibDraw/Point.h> | ||||
| #include <LibGUI/GActionGroup.h> | ||||
| 
 | ||||
| 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<GMenu> m_context_menu; | ||||
|     RefPtr<GUI::Menu> m_context_menu; | ||||
|     int m_thickness { 1 }; | ||||
|     GActionGroup m_thickness_actions; | ||||
|     GUI::ActionGroup m_thickness_actions; | ||||
| }; | ||||
|  |  | |||
|  | @ -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); | ||||
| } | ||||
|  |  | |||
|  | @ -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"; } | ||||
|  |  | |||
|  | @ -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; | ||||
|         })); | ||||
|     } | ||||
|  |  | |||
|  | @ -29,20 +29,22 @@ | |||
| #include "Tool.h" | ||||
| #include <LibDraw/Point.h> | ||||
| 
 | ||||
| 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<GMenu> m_context_menu; | ||||
|     RefPtr<GUI::Menu> m_context_menu; | ||||
|     Mode m_mode { Mode::Outline }; | ||||
| }; | ||||
|  |  | |||
|  | @ -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); | ||||
|             }); | ||||
|  |  | |||
|  | @ -31,17 +31,19 @@ | |||
| #include <LibGUI/GActionGroup.h> | ||||
| #include <LibGUI/GPainter.h> | ||||
| 
 | ||||
| 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<Core::Timer> m_timer; | ||||
|     Point m_last_pos; | ||||
|     Color m_color; | ||||
|     RefPtr<GMenu> m_context_menu; | ||||
|     GActionGroup m_thickness_actions; | ||||
|     RefPtr<GUI::Menu> m_context_menu; | ||||
|     GUI::ActionGroup m_thickness_actions; | ||||
|     int m_thickness { 1 }; | ||||
| }; | ||||
|  |  | |||
|  | @ -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(); } | ||||
|  |  | |||
|  | @ -38,11 +38,11 @@ | |||
| #include <LibGUI/GBoxLayout.h> | ||||
| #include <LibGUI/GButton.h> | ||||
| 
 | ||||
| class ToolButton final : public GButton { | ||||
| class ToolButton final : public GUI::Button { | ||||
|     C_OBJECT(ToolButton) | ||||
| public: | ||||
|     ToolButton(const String& name, GWidget* parent, OwnPtr<Tool>&& tool) | ||||
|         : GButton(parent) | ||||
|     ToolButton(const String& name, GUI::Widget* parent, OwnPtr<Tool>&& 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<Tool> 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<GVBoxLayout>()); | ||||
|     set_layout(make<GUI::VBoxLayout>()); | ||||
|     layout()->set_margins({ 4, 4, 4, 4 }); | ||||
| 
 | ||||
|     auto add_tool = [&](const StringView& name, const StringView& icon_name, OwnPtr<Tool>&& 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); | ||||
|  |  | |||
|  | @ -28,9 +28,9 @@ | |||
| 
 | ||||
| #include <LibGUI/GFrame.h> | ||||
| 
 | ||||
| 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; | ||||
| }; | ||||
|  |  | |||
|  | @ -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<GHBoxLayout>()); | ||||
|     horizontal_container->set_layout(make<GUI::HBoxLayout>()); | ||||
|     horizontal_container->layout()->set_spacing(0); | ||||
| 
 | ||||
|     new ToolboxWidget(horizontal_container); | ||||
| 
 | ||||
|     auto vertical_container = GWidget::construct(horizontal_container.ptr()); | ||||
|     vertical_container->set_layout(make<GVBoxLayout>()); | ||||
|     auto vertical_container = GUI::Widget::construct(horizontal_container.ptr()); | ||||
|     vertical_container->set_layout(make<GUI::VBoxLayout>()); | ||||
|     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<GMenuBar>(); | ||||
|     auto app_menu = GMenu::construct("PaintBrush"); | ||||
|     auto menubar = make<GUI::MenuBar>(); | ||||
|     auto app_menu = GUI::Menu::construct("PaintBrush"); | ||||
| 
 | ||||
|     app_menu->add_action(GCommonActions::make_open_action([&](auto&) { | ||||
|         Optional<String> open_path = GFilePicker::get_open_filepath(); | ||||
|     app_menu->add_action(GUI::CommonActions::make_open_action([&](auto&) { | ||||
|         Optional<String> 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)); | ||||
| 
 | ||||
|  |  | |||
|  | @ -29,8 +29,8 @@ | |||
| #include "AudioEngine.h" | ||||
| #include <LibGUI/GPainter.h> | ||||
| 
 | ||||
| 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; | ||||
|  |  | |||
|  | @ -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; | ||||
| 
 | ||||
|  |  | |||
|  | @ -32,43 +32,43 @@ | |||
| #include <LibGUI/GLabel.h> | ||||
| #include <LibGUI/GSlider.h> | ||||
| 
 | ||||
| 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<GVBoxLayout>()); | ||||
|     set_layout(make<GUI::VBoxLayout>()); | ||||
|     set_fill_with_background_color(true); | ||||
| 
 | ||||
|     m_labels_container = GWidget::construct(this); | ||||
|     m_labels_container->set_layout(make<GHBoxLayout>()); | ||||
|     m_labels_container->set_size_policy(SizePolicy::Fill, SizePolicy::Fixed); | ||||
|     m_labels_container = GUI::Widget::construct(this); | ||||
|     m_labels_container->set_layout(make<GUI::HBoxLayout>()); | ||||
|     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<GHBoxLayout>()); | ||||
|     m_values_container->set_size_policy(SizePolicy::Fill, SizePolicy::Fixed); | ||||
|     m_values_container = GUI::Widget::construct(this); | ||||
|     m_values_container->set_layout(make<GUI::HBoxLayout>()); | ||||
|     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<GHBoxLayout>()); | ||||
|     m_knobs_container = GUI::Widget::construct(this); | ||||
|     m_knobs_container->set_layout(make<GUI::HBoxLayout>()); | ||||
| 
 | ||||
|     // 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) { | ||||
|  |  | |||
|  | @ -29,12 +29,15 @@ | |||
| 
 | ||||
| #include <LibGUI/GFrame.h> | ||||
| 
 | ||||
| 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<GWidget> m_labels_container; | ||||
|     RefPtr<GLabel> m_octave_label; | ||||
|     RefPtr<GLabel> m_wave_label; | ||||
|     RefPtr<GLabel> m_decay_label; | ||||
|     RefPtr<GLabel> m_delay_label; | ||||
|     RefPtr<GUI::Widget> m_labels_container; | ||||
|     RefPtr<GUI::Label> m_octave_label; | ||||
|     RefPtr<GUI::Label> m_wave_label; | ||||
|     RefPtr<GUI::Label> m_decay_label; | ||||
|     RefPtr<GUI::Label> m_delay_label; | ||||
| 
 | ||||
|     RefPtr<GWidget> m_values_container; | ||||
|     RefPtr<GLabel> m_octave_value; | ||||
|     RefPtr<GLabel> m_wave_value; | ||||
|     RefPtr<GLabel> m_decay_value; | ||||
|     RefPtr<GLabel> m_delay_value; | ||||
|     RefPtr<GUI::Widget> m_values_container; | ||||
|     RefPtr<GUI::Label> m_octave_value; | ||||
|     RefPtr<GUI::Label> m_wave_value; | ||||
|     RefPtr<GUI::Label> m_decay_value; | ||||
|     RefPtr<GUI::Label> m_delay_value; | ||||
| 
 | ||||
|     RefPtr<GWidget> m_knobs_container; | ||||
|     RefPtr<GSlider> m_octave_knob; | ||||
|     RefPtr<GSlider> m_wave_knob; | ||||
|     RefPtr<GSlider> m_decay_knob; | ||||
|     RefPtr<GSlider> m_delay_knob; | ||||
|     RefPtr<GUI::Widget> m_knobs_container; | ||||
|     RefPtr<GUI::Slider> m_octave_knob; | ||||
|     RefPtr<GUI::Slider> m_wave_knob; | ||||
|     RefPtr<GUI::Slider> m_decay_knob; | ||||
|     RefPtr<GUI::Slider> m_delay_knob; | ||||
| 
 | ||||
|     bool m_change_octave { true }; | ||||
| }; | ||||
|  |  | |||
|  | @ -36,30 +36,30 @@ | |||
| MainWidget::MainWidget(AudioEngine& audio_engine) | ||||
|     : m_audio_engine(audio_engine) | ||||
| { | ||||
|     set_layout(make<GVBoxLayout>()); | ||||
|     set_layout(make<GUI::VBoxLayout>()); | ||||
|     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<GHBoxLayout>()); | ||||
|     m_keys_and_knobs_container = GUI::Widget::construct(this); | ||||
|     m_keys_and_knobs_container->set_layout(make<GUI::HBoxLayout>()); | ||||
|     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; | ||||
| 
 | ||||
|  |  | |||
|  | @ -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<WaveWidget> m_wave_widget; | ||||
|     RefPtr<RollWidget> m_roll_widget; | ||||
|     RefPtr<GWidget> m_keys_and_knobs_container; | ||||
|     RefPtr<GUI::Widget> m_keys_and_knobs_container; | ||||
|     RefPtr<KeysWidget> m_keys_widget; | ||||
|     RefPtr<KnobsWidget> m_knobs_widget; | ||||
| 
 | ||||
|  |  | |||
|  | @ -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<double>(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; | ||||
|  |  | |||
|  | @ -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; | ||||
| 
 | ||||
|  |  | |||
|  | @ -30,8 +30,8 @@ | |||
| #include <LibGUI/GPainter.h> | ||||
| #include <limits> | ||||
| 
 | ||||
| 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); | ||||
| } | ||||
|  |  | |||
|  | @ -29,18 +29,17 @@ | |||
| 
 | ||||
| #include <LibGUI/GFrame.h> | ||||
| 
 | ||||
| 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; | ||||
| 
 | ||||
|  |  | |||
|  | @ -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<GMenuBar>(); | ||||
|     auto menubar = make<GUI::MenuBar>(); | ||||
| 
 | ||||
|     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)); | ||||
| 
 | ||||
|  |  | |||
|  | @ -31,8 +31,8 @@ | |||
| #include <LibGUI/GPainter.h> | ||||
| #include <LibGUI/GWindow.h> | ||||
| 
 | ||||
| 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; | ||||
|         } | ||||
| 
 | ||||
|  |  | |||
|  | @ -28,10 +28,9 @@ | |||
| 
 | ||||
| #include <LibGUI/GFrame.h> | ||||
| 
 | ||||
| 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<void(int)> 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(); | ||||
| 
 | ||||
|  |  | |||
|  | @ -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<GMenuBar>(); | ||||
|     auto menubar = make<GUI::MenuBar>(); | ||||
| 
 | ||||
|     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); | ||||
|  |  | |||
|  | @ -29,8 +29,8 @@ | |||
| #include <LibGUI/GPainter.h> | ||||
| #include <LibM/math.h> | ||||
| 
 | ||||
| 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); | ||||
|  |  | |||
|  | @ -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<ABuffer> m_buffer; | ||||
| }; | ||||
|  |  | |||
|  | @ -32,37 +32,37 @@ | |||
| #include <LibGUI/GMessageBox.h> | ||||
| #include <LibM/math.h> | ||||
| 
 | ||||
| SoundPlayerWidget::SoundPlayerWidget(GWindow& window, NonnullRefPtr<AClientConnection> connection) | ||||
| SoundPlayerWidget::SoundPlayerWidget(GUI::Window& window, NonnullRefPtr<AClientConnection> connection) | ||||
|     : m_window(window) | ||||
|     , m_connection(connection) | ||||
|     , m_manager(connection) | ||||
| { | ||||
|     set_fill_with_background_color(true); | ||||
|     set_layout(make<GVBoxLayout>()); | ||||
|     set_layout(make<GUI::VBoxLayout>()); | ||||
|     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<GHBoxLayout>()); | ||||
|     status_widget->set_layout(make<GUI::HBoxLayout>()); | ||||
| 
 | ||||
|     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<GHBoxLayout>()); | ||||
|     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<GUI::HBoxLayout>()); | ||||
|     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, NonnullRefPtr<AClientConne | |||
|     m_slider->set_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<GHBoxLayout>()); | ||||
|     control_widget->set_size_policy(SizePolicy::Fill, SizePolicy::Fixed); | ||||
|     control_widget->set_layout(make<GUI::HBoxLayout>()); | ||||
|     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<AWavLoader> loader = make<AWavLoader>(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; | ||||
|     } | ||||
| 
 | ||||
|  |  | |||
|  | @ -34,7 +34,7 @@ | |||
| #include <LibGUI/GWidget.h> | ||||
| #include <LibGUI/GWindow.h> | ||||
| 
 | ||||
| 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<AClientConnection>); | ||||
|     explicit SoundPlayerWidget(GUI::Window&, NonnullRefPtr<AClientConnection>); | ||||
| 
 | ||||
|     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<AClientConnection> m_connection; | ||||
|     PlaybackManager m_manager; | ||||
|     float m_sample_ratio; | ||||
|     RefPtr<GLabel> m_status; | ||||
|     RefPtr<GLabel> m_elapsed; | ||||
|     RefPtr<GLabel> m_remaining; | ||||
|     RefPtr<GUI::Label> m_status; | ||||
|     RefPtr<GUI::Label> m_elapsed; | ||||
|     RefPtr<GUI::Label> m_remaining; | ||||
|     RefPtr<Slider> m_slider; | ||||
|     RefPtr<SampleWidget> m_sample_widget; | ||||
|     RefPtr<GraphicsBitmap> m_play_icon { GraphicsBitmap::load_from_file("/res/icons/16x16/play.png") }; | ||||
|     RefPtr<GraphicsBitmap> m_pause_icon { GraphicsBitmap::load_from_file("/res/icons/16x16/pause.png") }; | ||||
|     RefPtr<GButton> m_play; | ||||
|     RefPtr<GButton> m_stop; | ||||
|     RefPtr<GUI::Button> m_play; | ||||
|     RefPtr<GUI::Button> m_stop; | ||||
| }; | ||||
|  |  | |||
|  | @ -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<GMenuBar>(); | ||||
|     auto app_menu = GMenu::construct("SoundPlayer"); | ||||
|     auto menubar = make<GUI::MenuBar>(); | ||||
|     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<String> path = GFilePicker::get_open_filepath("Open wav file..."); | ||||
|     app_menu->add_action(GUI::CommonActions::make_open_action([&](auto&) { | ||||
|         Optional<String> 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)); | ||||
|  |  | |||
|  | @ -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) { | ||||
|  |  | |||
|  | @ -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)); | ||||
| 
 | ||||
|  |  | |||
|  | @ -30,7 +30,7 @@ | |||
| #include <AK/Vector.h> | ||||
| #include <LibGUI/GModel.h> | ||||
| 
 | ||||
| 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<DevicesModel> 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: | ||||
|  |  | |||
|  | @ -27,8 +27,8 @@ | |||
| #include "GraphWidget.h" | ||||
| #include <LibGUI/GPainter.h> | ||||
| 
 | ||||
| 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); | ||||
|  |  | |||
|  | @ -27,7 +27,7 @@ | |||
| #include <AK/CircularQueue.h> | ||||
| #include <LibGUI/GFrame.h> | ||||
| 
 | ||||
| class GraphWidget final : public GFrame { | ||||
| class GraphWidget final : public GUI::Frame { | ||||
|     C_OBJECT(GraphWidget) | ||||
| public: | ||||
|     virtual ~GraphWidget() override; | ||||
|  | @ -41,9 +41,9 @@ public: | |||
|     Function<String(int value, int max)> 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<int, 4000> m_values; | ||||
|  |  | |||
|  | @ -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<GVBoxLayout>()); | ||||
|     set_layout(make<GUI::VBoxLayout>()); | ||||
|     layout()->set_margins({ 0, 8, 0, 0 }); | ||||
|     layout()->set_spacing(3); | ||||
| 
 | ||||
|     auto build_widgets_for_label = [this](const String& description) -> RefPtr<GLabel> { | ||||
|         auto container = GWidget::construct(this); | ||||
|         container->set_layout(make<GHBoxLayout>()); | ||||
|         container->set_size_policy(SizePolicy::Fixed, SizePolicy::Fixed); | ||||
|     auto build_widgets_for_label = [this](const String& description) -> RefPtr<GUI::Label> { | ||||
|         auto container = GUI::Widget::construct(this); | ||||
|         container->set_layout(make<GUI::HBoxLayout>()); | ||||
|         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; | ||||
|     }; | ||||
|  |  | |||
|  | @ -28,10 +28,13 @@ | |||
| 
 | ||||
| #include <LibGUI/GWidget.h> | ||||
| 
 | ||||
| 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<GLabel> m_user_physical_pages_label; | ||||
|     RefPtr<GLabel> m_supervisor_physical_pages_label; | ||||
|     RefPtr<GLabel> m_kmalloc_label; | ||||
|     RefPtr<GLabel> m_kmalloc_count_label; | ||||
|     RefPtr<GUI::Label> m_user_physical_pages_label; | ||||
|     RefPtr<GUI::Label> m_supervisor_physical_pages_label; | ||||
|     RefPtr<GUI::Label> m_kmalloc_label; | ||||
|     RefPtr<GUI::Label> m_kmalloc_count_label; | ||||
| }; | ||||
|  |  | |||
|  | @ -30,24 +30,24 @@ | |||
| #include <LibGUI/GJsonArrayModel.h> | ||||
| #include <LibGUI/GTableView.h> | ||||
| 
 | ||||
| NetworkStatisticsWidget::NetworkStatisticsWidget(GWidget* parent) | ||||
|     : GLazyWidget(parent) | ||||
| NetworkStatisticsWidget::NetworkStatisticsWidget(GUI::Widget* parent) | ||||
|     : GUI::LazyWidget(parent) | ||||
| { | ||||
|     on_first_show = [this](auto&) { | ||||
|         set_layout(make<GVBoxLayout>()); | ||||
|         set_layout(make<GUI::VBoxLayout>()); | ||||
|         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<GVBoxLayout>()); | ||||
|         auto adapters_group_box = GUI::GroupBox::construct("Adapters", this); | ||||
|         adapters_group_box->set_layout(make<GUI::VBoxLayout>()); | ||||
|         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<GJsonArrayModel::FieldSpec> net_adapters_fields; | ||||
|         Vector<GUI::JsonArrayModel::FieldSpec> 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<GVBoxLayout>()); | ||||
|         auto sockets_group_box = GUI::GroupBox::construct("Sockets", this); | ||||
|         sockets_group_box->set_layout(make<GUI::VBoxLayout>()); | ||||
|         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<GJsonArrayModel::FieldSpec> net_tcp_fields; | ||||
|         Vector<GUI::JsonArrayModel::FieldSpec> 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] { | ||||
|  |  | |||
|  | @ -29,18 +29,20 @@ | |||
| #include <LibCore/CTimer.h> | ||||
| #include <LibGUI/GLazyWidget.h> | ||||
| 
 | ||||
| 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<GTableView> m_adapter_table_view; | ||||
|     RefPtr<GTableView> m_socket_table_view; | ||||
|     RefPtr<GUI::TableView> m_adapter_table_view; | ||||
|     RefPtr<GUI::TableView> m_socket_table_view; | ||||
|     RefPtr<Core::Timer> m_update_timer; | ||||
| }; | ||||
|  |  | |||
|  | @ -29,15 +29,15 @@ | |||
| #include <LibGUI/GJsonArrayModel.h> | ||||
| #include <LibGUI/GTableView.h> | ||||
| 
 | ||||
| ProcessFileDescriptorMapWidget::ProcessFileDescriptorMapWidget(GWidget* parent) | ||||
|     : GWidget(parent) | ||||
| ProcessFileDescriptorMapWidget::ProcessFileDescriptorMapWidget(GUI::Widget* parent) | ||||
|     : GUI::Widget(parent) | ||||
| { | ||||
|     set_layout(make<GVBoxLayout>()); | ||||
|     set_layout(make<GUI::VBoxLayout>()); | ||||
|     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<GJsonArrayModel::FieldSpec> pid_fds_fields; | ||||
|     Vector<GUI::JsonArrayModel::FieldSpec> 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<GJsonArrayModel*>(m_table_view->model())->set_json_path(String::format("/proc/%d/fds", m_pid)); | ||||
|     static_cast<GUI::JsonArrayModel*>(m_table_view->model())->set_json_path(String::format("/proc/%d/fds", m_pid)); | ||||
| } | ||||
|  |  | |||
|  | @ -28,9 +28,11 @@ | |||
| 
 | ||||
| #include <LibGUI/GWidget.h> | ||||
| 
 | ||||
| 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<GTableView> m_table_view; | ||||
|     RefPtr<GUI::TableView> m_table_view; | ||||
|     pid_t m_pid { -1 }; | ||||
| }; | ||||
|  |  | |||
Some files were not shown because too many files have changed in this diff Show more
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Andreas Kling
						Andreas Kling