1
0
Fork 0
mirror of https://github.com/LadybirdBrowser/ladybird.git synced 2025-06-12 02:30:30 +09:00

LibGUI: Use GUI::Window::set_main_widget<WidgetType>() in clients

This commit is contained in:
Andreas Kling 2020-03-04 09:46:23 +01:00
parent 4697195645
commit 0f3e57a6fb
Notes: sideshowbarker 2024-07-19 08:54:48 +09:00
37 changed files with 203 additions and 246 deletions

View file

@ -48,9 +48,7 @@ Editor::Editor()
m_documentation_tooltip_window = GUI::Window::construct();
m_documentation_tooltip_window->set_rect(0, 0, 500, 400);
m_documentation_tooltip_window->set_window_type(GUI::WindowType::Tooltip);
m_documentation_html_view = HtmlView::construct();
m_documentation_tooltip_window->set_main_widget(m_documentation_html_view);
m_documentation_html_view = m_documentation_tooltip_window->set_main_widget<HtmlView>();
}
Editor::~Editor()

View file

@ -150,10 +150,9 @@ Locator::Locator()
m_popup_window->set_window_type(GUI::WindowType::Tooltip);
m_popup_window->set_rect(0, 0, 500, 200);
m_suggestion_view = GUI::TableView::construct();
m_suggestion_view = m_popup_window->set_main_widget<GUI::TableView>();
m_suggestion_view->set_size_columns_to_fit_content(true);
m_suggestion_view->set_headers_visible(false);
m_popup_window->set_main_widget(m_suggestion_view);
m_suggestion_view->on_activation = [this](auto& index) {
open_suggestion(index);

View file

@ -141,12 +141,11 @@ int main(int argc, char** argv)
g_window->set_rect(90, 90, 840, 600);
g_window->set_title("HackStudio");
auto widget = GUI::Widget::construct();
g_window->set_main_widget(widget);
auto& widget = g_window->set_main_widget<GUI::Widget>();
widget->set_fill_with_background_color(true);
widget->set_layout<GUI::VerticalBoxLayout>();
widget->layout()->set_spacing(0);
widget.set_fill_with_background_color(true);
widget.set_layout<GUI::VerticalBoxLayout>();
widget.layout()->set_spacing(0);
StringBuilder path;
path.append(getenv("PATH"));
@ -165,7 +164,7 @@ int main(int argc, char** argv)
g_project = Project::load_from_file("little.files");
ASSERT(g_project);
auto toolbar = widget->add<GUI::ToolBar>();
auto toolbar = widget.add<GUI::ToolBar>();
auto selected_file_names = [&] {
Vector<String> files;
@ -247,7 +246,7 @@ int main(int argc, char** argv)
project_tree_view_context_menu->add_action(add_existing_file_action);
project_tree_view_context_menu->add_action(delete_action);
auto outer_splitter = widget->add<GUI::HorizontalSplitter>();
auto outer_splitter = widget.add<GUI::HorizontalSplitter>();
g_project_tree_view = outer_splitter->add<GUI::TreeView>();
g_project_tree_view->set_model(g_project->model());
g_project_tree_view->set_size_policy(GUI::SizePolicy::Fixed, GUI::SizePolicy::Fill);
@ -448,7 +447,7 @@ int main(int argc, char** argv)
auto find_in_files_widget = s_action_tab_widget->add_tab<FindInFilesWidget>("Find in files");
auto terminal_wrapper = s_action_tab_widget->add_tab<TerminalWrapper>("Console");
auto locator = widget->add<Locator>();
auto locator = widget.add<Locator>();
auto open_locator_action = GUI::Action::create("Open Locator...", { Mod_Ctrl, Key_K }, [&](auto&) {
locator->open();

View file

@ -58,12 +58,11 @@ int main(int argc, char** argv)
window->set_title("Inspector");
window->set_rect(150, 150, 300, 500);
auto widget = GUI::Widget::construct();
window->set_main_widget(widget);
widget->set_fill_with_background_color(true);
widget->set_layout<GUI::VerticalBoxLayout>();
auto& widget = window->set_main_widget<GUI::Widget>();
widget.set_fill_with_background_color(true);
widget.set_layout<GUI::VerticalBoxLayout>();
auto splitter = widget->add<GUI::HorizontalSplitter>();
auto splitter = widget.add<GUI::HorizontalSplitter>();
RemoteProcess remote_process(pid);

View file

@ -57,14 +57,13 @@ int main(int argc, char** argv)
window->set_title("ProfileViewer");
window->set_rect(100, 100, 800, 600);
auto main_widget = GUI::Widget::construct();
window->set_main_widget(main_widget);
main_widget->set_fill_with_background_color(true);
main_widget->set_layout<GUI::VerticalBoxLayout>();
auto& main_widget = window->set_main_widget<GUI::Widget>();
main_widget.set_fill_with_background_color(true);
main_widget.set_layout<GUI::VerticalBoxLayout>();
auto timeline_widget = main_widget->add<ProfileTimelineWidget>(*profile);
auto timeline_widget = main_widget.add<ProfileTimelineWidget>(*profile);
auto tree_view = main_widget->add<GUI::TreeView>();
auto tree_view = main_widget.add<GUI::TreeView>();
tree_view->set_headers_visible(true);
tree_view->set_size_columns_to_fit_content(true);
tree_view->set_model(profile->model());

View file

@ -81,13 +81,12 @@ VBPropertiesWindow::VBPropertiesWindow()
set_title("Properties");
set_rect(780, 200, 240, 280);
auto widget = GUI::Widget::construct();
widget->set_fill_with_background_color(true);
widget->set_layout<GUI::VerticalBoxLayout>();
widget->layout()->set_margins({ 2, 2, 2, 2 });
set_main_widget(widget);
auto& widget = set_main_widget<GUI::Widget>();
widget.set_fill_with_background_color(true);
widget.set_layout<GUI::VerticalBoxLayout>();
widget.layout()->set_margins({ 2, 2, 2, 2 });
m_table_view = widget->add<GUI::TableView>();
m_table_view = widget.add<GUI::TableView>();
m_table_view->set_headers_visible(false);
m_table_view->set_editable(true);

View file

@ -106,13 +106,12 @@ RefPtr<GUI::Window> make_toolbox_window()
window->set_title("Widgets");
window->set_rect(20, 200, 80, 300);
auto widget = GUI::Widget::construct();
widget->set_fill_with_background_color(true);
widget->set_layout<GUI::VerticalBoxLayout>();
widget->layout()->set_spacing(0);
window->set_main_widget(widget);
auto& widget = window->set_main_widget<GUI::Widget>();
widget.set_fill_with_background_color(true);
widget.set_layout<GUI::VerticalBoxLayout>();
widget.layout()->set_spacing(0);
auto label_button = widget->add<GUI::Button>();
auto label_button = widget.add<GUI::Button>();
label_button->set_button_style(Gfx::ButtonStyle::CoolBar);
label_button->set_tooltip("GLabel");
label_button->set_icon(Gfx::Bitmap::load_from_file("/res/icons/vbwidgets/label.png"));
@ -121,7 +120,7 @@ RefPtr<GUI::Window> make_toolbox_window()
form->insert_widget(VBWidgetType::GLabel);
};
auto button_button = widget->add<GUI::Button>();
auto button_button = widget.add<GUI::Button>();
button_button->set_button_style(Gfx::ButtonStyle::CoolBar);
button_button->set_tooltip("GButton");
button_button->set_icon(Gfx::Bitmap::load_from_file("/res/icons/vbwidgets/button.png"));
@ -129,7 +128,7 @@ RefPtr<GUI::Window> make_toolbox_window()
if (auto* form = VBForm::current())
form->insert_widget(VBWidgetType::GButton);
};
auto spinbox_button = widget->add<GUI::Button>();
auto spinbox_button = widget.add<GUI::Button>();
spinbox_button->set_button_style(Gfx::ButtonStyle::CoolBar);
spinbox_button->set_tooltip("GSpinBox");
spinbox_button->set_icon(Gfx::Bitmap::load_from_file("/res/icons/vbwidgets/spinbox.png"));
@ -137,7 +136,7 @@ RefPtr<GUI::Window> make_toolbox_window()
if (auto* form = VBForm::current())
form->insert_widget(VBWidgetType::GSpinBox);
};
auto editor_button = widget->add<GUI::Button>();
auto editor_button = widget.add<GUI::Button>();
editor_button->set_button_style(Gfx::ButtonStyle::CoolBar);
editor_button->set_tooltip("GTextEditor");
editor_button->set_icon(Gfx::Bitmap::load_from_file("/res/icons/vbwidgets/textbox.png"));
@ -145,7 +144,7 @@ RefPtr<GUI::Window> make_toolbox_window()
if (auto* form = VBForm::current())
form->insert_widget(VBWidgetType::GTextEditor);
};
auto progress_bar_button = widget->add<GUI::Button>();
auto progress_bar_button = widget.add<GUI::Button>();
progress_bar_button->set_button_style(Gfx::ButtonStyle::CoolBar);
progress_bar_button->set_tooltip("GProgressBar");
progress_bar_button->set_icon(Gfx::Bitmap::load_from_file("/res/icons/vbwidgets/progressbar.png"));
@ -153,7 +152,7 @@ RefPtr<GUI::Window> make_toolbox_window()
if (auto* form = VBForm::current())
form->insert_widget(VBWidgetType::GProgressBar);
};
auto slider_button = widget->add<GUI::Button>();
auto slider_button = widget.add<GUI::Button>();
slider_button->set_button_style(Gfx::ButtonStyle::CoolBar);
slider_button->set_tooltip("GSlider");
slider_button->set_icon(Gfx::Bitmap::load_from_file("/res/icons/vbwidgets/slider.png"));
@ -161,7 +160,7 @@ RefPtr<GUI::Window> make_toolbox_window()
if (auto* form = VBForm::current())
form->insert_widget(VBWidgetType::GSlider);
};
auto checkbox_button = widget->add<GUI::Button>();
auto checkbox_button = widget.add<GUI::Button>();
checkbox_button->set_button_style(Gfx::ButtonStyle::CoolBar);
checkbox_button->set_tooltip("GCheckBox");
checkbox_button->set_icon(Gfx::Bitmap::load_from_file("/res/icons/vbwidgets/checkbox.png"));
@ -169,7 +168,7 @@ RefPtr<GUI::Window> make_toolbox_window()
if (auto* form = VBForm::current())
form->insert_widget(VBWidgetType::GCheckBox);
};
auto radiobutton_button = widget->add<GUI::Button>();
auto radiobutton_button = widget.add<GUI::Button>();
radiobutton_button->set_button_style(Gfx::ButtonStyle::CoolBar);
radiobutton_button->set_tooltip("GRadioButton");
radiobutton_button->set_icon(Gfx::Bitmap::load_from_file("/res/icons/filled-radio-circle.png"));
@ -177,7 +176,7 @@ RefPtr<GUI::Window> make_toolbox_window()
if (auto* form = VBForm::current())
form->insert_widget(VBWidgetType::GRadioButton);
};
auto scrollbar_button = widget->add<GUI::Button>();
auto scrollbar_button = widget.add<GUI::Button>();
scrollbar_button->set_button_style(Gfx::ButtonStyle::CoolBar);
scrollbar_button->set_tooltip("GScrollBar");
scrollbar_button->set_icon(Gfx::Bitmap::load_from_file("/res/icons/vbwidgets/scrollbar.png"));
@ -185,7 +184,7 @@ RefPtr<GUI::Window> make_toolbox_window()
if (auto* form = VBForm::current())
form->insert_widget(VBWidgetType::GScrollBar);
};
auto groupbox_button = widget->add<GUI::Button>();
auto groupbox_button = widget.add<GUI::Button>();
groupbox_button->set_button_style(Gfx::ButtonStyle::CoolBar);
groupbox_button->set_tooltip("GGroupBox");
groupbox_button->set_icon(Gfx::Bitmap::load_from_file("/res/icons/vbwidgets/groupbox.png"));