mirror of
https://github.com/SerenityOS/serenity.git
synced 2025-01-23 01:41:59 -05:00
LibGUI: Use GUI::Window::set_main_widget<WidgetType>() in clients
This commit is contained in:
parent
4697195645
commit
0f3e57a6fb
37 changed files with 203 additions and 246 deletions
|
@ -70,8 +70,7 @@ int main(int argc, char** argv)
|
|||
window->set_title("Font Editor");
|
||||
window->set_rect({ 50, 50, 390, 342 });
|
||||
|
||||
auto font_editor = FontEditorWidget::construct(path, move(edited_font));
|
||||
window->set_main_widget(font_editor);
|
||||
window->set_main_widget<FontEditorWidget>(path, move(edited_font));
|
||||
window->show();
|
||||
window->set_icon(Gfx::Bitmap::load_from_file("/res/icons/16x16/app-font-editor.png"));
|
||||
|
||||
|
|
|
@ -46,11 +46,10 @@ int main(int argc, char** argv)
|
|||
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);
|
||||
auto& hex_editor_widget = window->set_main_widget<HexEditorWidget>();
|
||||
|
||||
window->on_close_request = [&]() -> GUI::Window::CloseRequestDecision {
|
||||
if (hex_editor_widget->request_close())
|
||||
if (hex_editor_widget.request_close())
|
||||
return GUI::Window::CloseRequestDecision::Close;
|
||||
return GUI::Window::CloseRequestDecision::StayOpen;
|
||||
};
|
||||
|
@ -59,7 +58,7 @@ int main(int argc, char** argv)
|
|||
window->set_icon(Gfx::Bitmap::load_from_file("/res/icons/16x16/app-hexeditor.png"));
|
||||
|
||||
if (argc >= 2)
|
||||
hex_editor_widget->open_file(argv[1]);
|
||||
hex_editor_widget.open_file(argv[1]);
|
||||
|
||||
return app.exec();
|
||||
}
|
||||
|
|
|
@ -179,13 +179,12 @@ void IRCAppWindow::setup_menus()
|
|||
|
||||
void IRCAppWindow::setup_widgets()
|
||||
{
|
||||
auto widget = GUI::Widget::construct();
|
||||
set_main_widget(widget);
|
||||
widget->set_fill_with_background_color(true);
|
||||
widget->set_layout<GUI::VerticalBoxLayout>();
|
||||
widget->layout()->set_spacing(0);
|
||||
auto& widget = set_main_widget<GUI::Widget>();
|
||||
widget.set_fill_with_background_color(true);
|
||||
widget.set_layout<GUI::VerticalBoxLayout>();
|
||||
widget.layout()->set_spacing(0);
|
||||
|
||||
auto toolbar = widget->add<GUI::ToolBar>();
|
||||
auto toolbar = widget.add<GUI::ToolBar>();
|
||||
toolbar->set_has_frame(false);
|
||||
toolbar->add_action(*m_change_nick_action);
|
||||
toolbar->add_separator();
|
||||
|
@ -196,7 +195,7 @@ void IRCAppWindow::setup_widgets()
|
|||
toolbar->add_action(*m_open_query_action);
|
||||
toolbar->add_action(*m_close_query_action);
|
||||
|
||||
auto outer_container = widget->add<GUI::Widget>();
|
||||
auto outer_container = widget.add<GUI::Widget>();
|
||||
outer_container->set_layout<GUI::VerticalBoxLayout>();
|
||||
outer_container->layout()->set_margins({ 2, 0, 2, 2 });
|
||||
|
||||
|
|
|
@ -58,14 +58,13 @@ int main(int argc, char** argv)
|
|||
window->set_rect(100, 100, 640, 480);
|
||||
window->set_icon(Gfx::Bitmap::load_from_file("/res/icons/16x16/app-paintbrush.png"));
|
||||
|
||||
auto horizontal_container = GUI::Widget::construct();
|
||||
window->set_main_widget(horizontal_container);
|
||||
horizontal_container->set_layout<GUI::HorizontalBoxLayout>();
|
||||
horizontal_container->layout()->set_spacing(0);
|
||||
auto& horizontal_container = window->set_main_widget<GUI::Widget>();
|
||||
horizontal_container.set_layout<GUI::HorizontalBoxLayout>();
|
||||
horizontal_container.layout()->set_spacing(0);
|
||||
|
||||
horizontal_container->add<ToolboxWidget>();
|
||||
horizontal_container.add<ToolboxWidget>();
|
||||
|
||||
auto vertical_container = horizontal_container->add<GUI::Widget>();
|
||||
auto vertical_container = horizontal_container.add<GUI::Widget>();
|
||||
vertical_container->set_layout<GUI::VerticalBoxLayout>();
|
||||
vertical_container->layout()->set_spacing(0);
|
||||
|
||||
|
|
|
@ -52,8 +52,7 @@ int main(int argc, char** argv)
|
|||
AudioEngine audio_engine;
|
||||
|
||||
auto window = GUI::Window::construct();
|
||||
auto main_widget = MainWidget::construct(audio_engine);
|
||||
window->set_main_widget(main_widget);
|
||||
auto& main_widget = window->set_main_widget<MainWidget>(audio_engine);
|
||||
window->set_title("Piano");
|
||||
window->set_rect(90, 90, 840, 600);
|
||||
window->set_icon(Gfx::Bitmap::load_from_file("/res/icons/16x16/app-piano.png"));
|
||||
|
@ -74,7 +73,7 @@ int main(int argc, char** argv)
|
|||
for (;;) {
|
||||
audio_engine.fill_buffer(buffer);
|
||||
audio->write(reinterpret_cast<u8*>(buffer.data()), buffer_size);
|
||||
Core::EventLoop::current().post_event(*main_widget, make<Core::CustomEvent>(0));
|
||||
Core::EventLoop::current().post_event(main_widget, make<Core::CustomEvent>(0));
|
||||
Core::EventLoop::wake();
|
||||
|
||||
if (need_to_write_wav) {
|
||||
|
|
|
@ -87,22 +87,21 @@ int main(int argc, char** argv)
|
|||
}
|
||||
|
||||
auto window = GUI::Window::construct();
|
||||
auto widget = QSWidget::construct();
|
||||
widget->set_path(path);
|
||||
widget->set_bitmap(*bitmap);
|
||||
auto& widget = window->set_main_widget<QSWidget>();
|
||||
widget.set_path(path);
|
||||
widget.set_bitmap(*bitmap);
|
||||
|
||||
auto update_window_title = [&](int scale) {
|
||||
window->set_title(String::format("QuickShow: %s %s %d%%", widget->path().characters(), widget->bitmap()->size().to_string().characters(), scale));
|
||||
window->set_title(String::format("QuickShow: %s %s %d%%", widget.path().characters(), widget.bitmap()->size().to_string().characters(), scale));
|
||||
};
|
||||
|
||||
window->set_double_buffering_enabled(true);
|
||||
update_window_title(100);
|
||||
window->set_rect(200, 200, bitmap->width(), bitmap->height());
|
||||
|
||||
widget->on_scale_change = [&](int scale) {
|
||||
widget.on_scale_change = [&](int scale) {
|
||||
update_window_title(scale);
|
||||
};
|
||||
window->set_main_widget(widget);
|
||||
|
||||
window->show();
|
||||
|
||||
|
|
|
@ -66,24 +66,24 @@ int main(int argc, char** argv)
|
|||
|
||||
auto menubar = make<GUI::MenuBar>();
|
||||
auto app_menu = GUI::Menu::construct("SoundPlayer");
|
||||
auto player = SoundPlayerWidget::construct(window, audio_client);
|
||||
auto& player = window->set_main_widget<SoundPlayerWidget>(window, audio_client);
|
||||
|
||||
if (argc > 1) {
|
||||
String path = argv[1];
|
||||
player->open_file(path);
|
||||
player->manager().play();
|
||||
player.open_file(path);
|
||||
player.manager().play();
|
||||
}
|
||||
|
||||
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());
|
||||
player.hide_scope(action.is_checked());
|
||||
});
|
||||
hide_scope->set_checkable(true);
|
||||
|
||||
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());
|
||||
player.open_file(path.value());
|
||||
}
|
||||
}));
|
||||
app_menu->add_action(move(hide_scope));
|
||||
|
@ -101,8 +101,6 @@ int main(int argc, char** argv)
|
|||
menubar->add_menu(move(help_menu));
|
||||
app.set_menubar(move(menubar));
|
||||
|
||||
window->set_main_widget(player);
|
||||
window->show();
|
||||
|
||||
return app.exec();
|
||||
}
|
||||
|
|
|
@ -69,14 +69,13 @@ PowerDialog::PowerDialog()
|
|||
set_title("SerenityOS");
|
||||
set_icon(Gfx::Bitmap::load_from_file("/res/icons/16x16/power.png"));
|
||||
|
||||
auto main = GUI::Widget::construct();
|
||||
set_main_widget(main);
|
||||
main->set_layout<GUI::VerticalBoxLayout>();
|
||||
main->layout()->set_margins({ 8, 8, 8, 8 });
|
||||
main->layout()->set_spacing(8);
|
||||
main->set_fill_with_background_color(true);
|
||||
auto& main = set_main_widget<GUI::Widget>();
|
||||
main.set_layout<GUI::VerticalBoxLayout>();
|
||||
main.layout()->set_margins({ 8, 8, 8, 8 });
|
||||
main.layout()->set_spacing(8);
|
||||
main.set_fill_with_background_color(true);
|
||||
|
||||
auto header = main->add<GUI::Label>();
|
||||
auto header = main.add<GUI::Label>();
|
||||
header->set_text("What would you like to do?");
|
||||
header->set_preferred_size(0, 16);
|
||||
header->set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed);
|
||||
|
@ -84,7 +83,7 @@ PowerDialog::PowerDialog()
|
|||
|
||||
for (size_t i = 0; i < options.size(); i++) {
|
||||
auto action = options[i];
|
||||
auto radio = main->add<GUI::RadioButton>();
|
||||
auto radio = main.add<GUI::RadioButton>();
|
||||
radio->set_enabled(action.enabled);
|
||||
radio->set_text(action.title);
|
||||
|
||||
|
@ -98,7 +97,7 @@ PowerDialog::PowerDialog()
|
|||
}
|
||||
}
|
||||
|
||||
auto button_box = main->add<GUI::Widget>();
|
||||
auto button_box = main.add<GUI::Widget>();
|
||||
button_box->set_layout<GUI::HorizontalBoxLayout>();
|
||||
button_box->layout()->set_spacing(8);
|
||||
|
||||
|
|
|
@ -115,13 +115,12 @@ int main(int argc, char** argv)
|
|||
window->set_title("System Monitor");
|
||||
window->set_rect(20, 200, 680, 400);
|
||||
|
||||
auto keeper = GUI::Widget::construct();
|
||||
window->set_main_widget(keeper);
|
||||
keeper->set_layout<GUI::VerticalBoxLayout>();
|
||||
keeper->set_fill_with_background_color(true);
|
||||
keeper->layout()->set_margins({ 4, 4, 4, 4 });
|
||||
auto& keeper = window->set_main_widget<GUI::Widget>();
|
||||
keeper.set_layout<GUI::VerticalBoxLayout>();
|
||||
keeper.set_fill_with_background_color(true);
|
||||
keeper.layout()->set_margins({ 4, 4, 4, 4 });
|
||||
|
||||
auto tabwidget = keeper->add<GUI::TabWidget>();
|
||||
auto tabwidget = keeper.add<GUI::TabWidget>();
|
||||
|
||||
auto process_container_splitter = tabwidget->add_tab<GUI::VerticalSplitter>("Processes");
|
||||
|
||||
|
|
|
@ -46,15 +46,14 @@ TaskbarWindow::TaskbarWindow()
|
|||
|
||||
GUI::Desktop::the().on_rect_change = [this](const Gfx::Rect& rect) { on_screen_rect_change(rect); };
|
||||
|
||||
auto widget = GUI::Frame::construct();
|
||||
widget->set_fill_with_background_color(true);
|
||||
widget->set_layout<GUI::HorizontalBoxLayout>();
|
||||
widget->layout()->set_margins({ 3, 2, 3, 2 });
|
||||
widget->layout()->set_spacing(3);
|
||||
widget->set_frame_thickness(1);
|
||||
widget->set_frame_shape(Gfx::FrameShape::Panel);
|
||||
widget->set_frame_shadow(Gfx::FrameShadow::Raised);
|
||||
set_main_widget(widget);
|
||||
auto& widget = set_main_widget<GUI::Frame>();
|
||||
widget.set_fill_with_background_color(true);
|
||||
widget.set_layout<GUI::HorizontalBoxLayout>();
|
||||
widget.layout()->set_margins({ 3, 2, 3, 2 });
|
||||
widget.layout()->set_spacing(3);
|
||||
widget.set_frame_thickness(1);
|
||||
widget.set_frame_shape(Gfx::FrameShape::Panel);
|
||||
widget.set_frame_shadow(Gfx::FrameShadow::Raised);
|
||||
|
||||
WindowList::the().aid_create_button = [this](auto& identifier) {
|
||||
return create_button(identifier);
|
||||
|
|
|
@ -134,14 +134,13 @@ RefPtr<GUI::Window> create_settings_window(TerminalWidget& terminal)
|
|||
window->set_rect(50, 50, 200, 140);
|
||||
window->set_modal(true);
|
||||
|
||||
auto settings = GUI::Widget::construct();
|
||||
window->set_main_widget(settings);
|
||||
settings->set_fill_with_background_color(true);
|
||||
settings->set_background_role(ColorRole::Button);
|
||||
settings->set_layout<GUI::VerticalBoxLayout>();
|
||||
settings->layout()->set_margins({ 4, 4, 4, 4 });
|
||||
auto& settings = window->set_main_widget<GUI::Widget>();
|
||||
settings.set_fill_with_background_color(true);
|
||||
settings.set_background_role(ColorRole::Button);
|
||||
settings.set_layout<GUI::VerticalBoxLayout>();
|
||||
settings.layout()->set_margins({ 4, 4, 4, 4 });
|
||||
|
||||
auto radio_container = settings->add<GUI::GroupBox>("Bell Mode");
|
||||
auto radio_container = settings.add<GUI::GroupBox>("Bell Mode");
|
||||
radio_container->set_layout<GUI::VerticalBoxLayout>();
|
||||
radio_container->layout()->set_margins({ 6, 16, 6, 6 });
|
||||
radio_container->set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed);
|
||||
|
@ -155,7 +154,7 @@ RefPtr<GUI::Window> create_settings_window(TerminalWidget& terminal)
|
|||
terminal.set_should_beep(checked);
|
||||
};
|
||||
|
||||
auto slider_container = settings->add<GUI::GroupBox>("Background Opacity");
|
||||
auto slider_container = settings.add<GUI::GroupBox>("Background Opacity");
|
||||
slider_container->set_layout<GUI::VerticalBoxLayout>();
|
||||
slider_container->layout()->set_margins({ 6, 16, 6, 6 });
|
||||
slider_container->set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed);
|
||||
|
@ -227,24 +226,23 @@ int main(int argc, char** argv)
|
|||
window->set_double_buffering_enabled(false);
|
||||
|
||||
RefPtr<Core::ConfigFile> config = Core::ConfigFile::get_for_app("Terminal");
|
||||
auto terminal = TerminalWidget::construct(ptm_fd, true, config);
|
||||
terminal->on_command_exit = [&] {
|
||||
auto& terminal = window->set_main_widget<TerminalWidget>(ptm_fd, true, config);
|
||||
terminal.on_command_exit = [&] {
|
||||
app.quit(0);
|
||||
};
|
||||
terminal->on_title_change = [&](auto& title) {
|
||||
terminal.on_title_change = [&](auto& title) {
|
||||
window->set_title(title);
|
||||
};
|
||||
window->set_main_widget(terminal);
|
||||
window->move_to(300, 300);
|
||||
terminal->apply_size_increments_to_window(*window);
|
||||
terminal.apply_size_increments_to_window(*window);
|
||||
window->show();
|
||||
window->set_icon(Gfx::Bitmap::load_from_file("/res/icons/16x16/app-terminal.png"));
|
||||
terminal->set_should_beep(config->read_bool_entry("Window", "AudibleBeep", false));
|
||||
terminal.set_should_beep(config->read_bool_entry("Window", "AudibleBeep", false));
|
||||
|
||||
RefPtr<GUI::Window> settings_window;
|
||||
|
||||
auto new_opacity = config->read_num_entry("Window", "Opacity", 255);
|
||||
terminal->set_opacity(new_opacity);
|
||||
terminal.set_opacity(new_opacity);
|
||||
window->set_has_alpha_channel(new_opacity < 255);
|
||||
|
||||
auto menubar = make<GUI::MenuBar>();
|
||||
|
@ -259,7 +257,7 @@ int main(int argc, char** argv)
|
|||
app_menu->add_action(GUI::Action::create("Settings...", Gfx::Bitmap::load_from_file("/res/icons/gear16.png"),
|
||||
[&](const GUI::Action&) {
|
||||
if (!settings_window) {
|
||||
settings_window = create_settings_window(*terminal);
|
||||
settings_window = create_settings_window(terminal);
|
||||
settings_window->on_close_request = [&] {
|
||||
settings_window = nullptr;
|
||||
return GUI::Window::CloseRequestDecision::Close;
|
||||
|
@ -276,8 +274,8 @@ int main(int argc, char** argv)
|
|||
menubar->add_menu(move(app_menu));
|
||||
|
||||
auto edit_menu = GUI::Menu::construct("Edit");
|
||||
edit_menu->add_action(terminal->copy_action());
|
||||
edit_menu->add_action(terminal->paste_action());
|
||||
edit_menu->add_action(terminal.copy_action());
|
||||
edit_menu->add_action(terminal.paste_action());
|
||||
menubar->add_menu(move(edit_menu));
|
||||
|
||||
GUI::ActionGroup font_action_group;
|
||||
|
@ -286,16 +284,16 @@ int main(int argc, char** argv)
|
|||
GFontDatabase::the().for_each_fixed_width_font([&](const StringView& font_name) {
|
||||
auto action = GUI::Action::create(font_name, [&](GUI::Action& action) {
|
||||
action.set_checked(true);
|
||||
terminal->set_font(GFontDatabase::the().get_by_name(action.text()));
|
||||
terminal.set_font(GFontDatabase::the().get_by_name(action.text()));
|
||||
auto metadata = GFontDatabase::the().get_metadata_by_name(action.text());
|
||||
ASSERT(metadata.has_value());
|
||||
config->write_entry("Text", "Font", metadata.value().path);
|
||||
config->sync();
|
||||
terminal->force_repaint();
|
||||
terminal.force_repaint();
|
||||
});
|
||||
font_action_group.add_action(*action);
|
||||
action->set_checkable(true);
|
||||
if (terminal->font().name() == font_name)
|
||||
if (terminal.font().name() == font_name)
|
||||
action->set_checked(true);
|
||||
font_menu->add_action(*action);
|
||||
});
|
||||
|
|
|
@ -46,19 +46,18 @@ int main(int argc, char** argv)
|
|||
window->set_title("Text Editor");
|
||||
window->set_rect(20, 200, 640, 400);
|
||||
|
||||
auto text_widget = TextEditorWidget::construct();
|
||||
window->set_main_widget(text_widget);
|
||||
auto& text_widget = window->set_main_widget<TextEditorWidget>();
|
||||
|
||||
text_widget->editor().set_focus(true);
|
||||
text_widget.editor().set_focus(true);
|
||||
|
||||
window->on_close_request = [&]() -> GUI::Window::CloseRequestDecision {
|
||||
if (text_widget->request_close())
|
||||
if (text_widget.request_close())
|
||||
return GUI::Window::CloseRequestDecision::Close;
|
||||
return GUI::Window::CloseRequestDecision::StayOpen;
|
||||
};
|
||||
|
||||
if (argc >= 2)
|
||||
text_widget->open_sesame(argv[1]);
|
||||
text_widget.open_sesame(argv[1]);
|
||||
|
||||
window->show();
|
||||
window->set_icon(Gfx::Bitmap::load_from_file("/res/icons/TextEditor16.png"));
|
||||
|
|
|
@ -161,19 +161,18 @@ int main(int argc, char** argv)
|
|||
window->set_resizable(true);
|
||||
window->set_rect(window_rect);
|
||||
|
||||
auto background = BackgroundWidget::construct();
|
||||
window->set_main_widget(background);
|
||||
background->set_fill_with_background_color(false);
|
||||
background->set_layout<GUI::VerticalBoxLayout>();
|
||||
background->layout()->set_margins({ 16, 8, 16, 8 });
|
||||
background->layout()->set_spacing(8);
|
||||
background->set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fill);
|
||||
auto& background = window->set_main_widget<BackgroundWidget>();
|
||||
background.set_fill_with_background_color(false);
|
||||
background.set_layout<GUI::VerticalBoxLayout>();
|
||||
background.layout()->set_margins({ 16, 8, 16, 8 });
|
||||
background.layout()->set_spacing(8);
|
||||
background.set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fill);
|
||||
|
||||
//
|
||||
// header
|
||||
//
|
||||
|
||||
auto header = background->add<GUI::Label>();
|
||||
auto header = background.add<GUI::Label>();
|
||||
header->set_font(Gfx::Font::load_from_file("/res/fonts/PebbletonBold11.font"));
|
||||
header->set_text("Welcome to SerenityOS!");
|
||||
header->set_text_alignment(Gfx::TextAlignment::CenterLeft);
|
||||
|
@ -184,7 +183,7 @@ int main(int argc, char** argv)
|
|||
// main section
|
||||
//
|
||||
|
||||
auto main_section = background->add<GUI::Widget>();
|
||||
auto main_section = background.add<GUI::Widget>();
|
||||
main_section->set_layout<GUI::HorizontalBoxLayout>();
|
||||
main_section->layout()->set_margins({ 0, 0, 0, 0 });
|
||||
main_section->layout()->set_spacing(8);
|
||||
|
|
|
@ -246,14 +246,13 @@ int main(int argc, char** argv)
|
|||
window->set_resizable(false);
|
||||
window->set_rect(100, 100, 640, 400);
|
||||
|
||||
auto fire = Fire::construct();
|
||||
window->set_main_widget(fire);
|
||||
auto& fire = window->set_main_widget<Fire>();
|
||||
|
||||
auto time = fire->add<GUI::Label>();
|
||||
auto time = fire.add<GUI::Label>();
|
||||
time->set_relative_rect({ 0, 4, 40, 10 });
|
||||
time->move_by({ window->width() - time->width(), 0 });
|
||||
time->set_foreground_color(Color::from_rgb(0x444444));
|
||||
fire->set_stat_label(time);
|
||||
fire.set_stat_label(time);
|
||||
|
||||
window->show();
|
||||
window->set_icon(Gfx::Bitmap::load_from_file("/res/icons/16x16/app-demo.png"));
|
||||
|
|
|
@ -48,51 +48,50 @@ int main(int argc, char** argv)
|
|||
window->set_rect(100, 100, 320, 620);
|
||||
window->set_title("Widget Gallery");
|
||||
|
||||
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>();
|
||||
main_widget->layout()->set_margins({ 4, 4, 4, 4 });
|
||||
auto& main_widget = window->set_main_widget<GUI::Widget>();
|
||||
main_widget.set_fill_with_background_color(true);
|
||||
main_widget.set_layout<GUI::VerticalBoxLayout>();
|
||||
main_widget.layout()->set_margins({ 4, 4, 4, 4 });
|
||||
|
||||
auto checkbox1 = main_widget->add<GUI::CheckBox>("GCheckBox 1");
|
||||
auto checkbox1 = main_widget.add<GUI::CheckBox>("GCheckBox 1");
|
||||
(void)checkbox1;
|
||||
auto checkbox2 = main_widget->add<GUI::CheckBox>("GCheckBox 2");
|
||||
auto checkbox2 = main_widget.add<GUI::CheckBox>("GCheckBox 2");
|
||||
checkbox2->set_enabled(false);
|
||||
|
||||
auto radio1 = main_widget->add<GUI::RadioButton>("GRadioButton 1");
|
||||
auto radio1 = main_widget.add<GUI::RadioButton>("GRadioButton 1");
|
||||
(void)radio1;
|
||||
auto radio2 = main_widget->add<GUI::RadioButton>("GRadioButton 2");
|
||||
auto radio2 = main_widget.add<GUI::RadioButton>("GRadioButton 2");
|
||||
radio2->set_enabled(false);
|
||||
|
||||
auto button1 = main_widget->add<GUI::Button>("GButton 1");
|
||||
auto button1 = main_widget.add<GUI::Button>("GButton 1");
|
||||
(void)button1;
|
||||
auto button2 = main_widget->add<GUI::Button>("GButton 2");
|
||||
auto button2 = main_widget.add<GUI::Button>("GButton 2");
|
||||
button2->set_enabled(false);
|
||||
|
||||
auto progress1 = main_widget->add<GUI::ProgressBar>();
|
||||
auto progress1 = main_widget.add<GUI::ProgressBar>();
|
||||
auto timer = progress1->add<Core::Timer>(100, [&] {
|
||||
progress1->set_value(progress1->value() + 1);
|
||||
if (progress1->value() == progress1->max())
|
||||
progress1->set_value(progress1->min());
|
||||
});
|
||||
|
||||
auto label1 = main_widget->add<GUI::Label>("GLabel 1");
|
||||
auto label1 = main_widget.add<GUI::Label>("GLabel 1");
|
||||
(void)label1;
|
||||
auto label2 = main_widget->add<GUI::Label>("GLabel 2");
|
||||
auto label2 = main_widget.add<GUI::Label>("GLabel 2");
|
||||
label2->set_enabled(false);
|
||||
|
||||
auto textbox1 = main_widget->add<GUI::TextBox>();
|
||||
auto textbox1 = main_widget.add<GUI::TextBox>();
|
||||
textbox1->set_text("GTextBox 1");
|
||||
auto textbox2 = main_widget->add<GUI::TextBox>();
|
||||
auto textbox2 = main_widget.add<GUI::TextBox>();
|
||||
textbox2->set_text("GTextBox 2");
|
||||
textbox2->set_enabled(false);
|
||||
|
||||
auto spinbox1 = main_widget->add<GUI::SpinBox>();
|
||||
auto spinbox1 = main_widget.add<GUI::SpinBox>();
|
||||
(void)spinbox1;
|
||||
auto spinbox2 = main_widget->add<GUI::SpinBox>();
|
||||
auto spinbox2 = main_widget.add<GUI::SpinBox>();
|
||||
spinbox2->set_enabled(false);
|
||||
|
||||
auto vertical_slider_container = main_widget->add<GUI::Widget>();
|
||||
auto vertical_slider_container = main_widget.add<GUI::Widget>();
|
||||
vertical_slider_container->set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed);
|
||||
vertical_slider_container->set_preferred_size(0, 100);
|
||||
vertical_slider_container->set_layout<GUI::HorizontalBoxLayout>();
|
||||
|
@ -104,21 +103,21 @@ int main(int argc, char** argv)
|
|||
vslider3->set_max(5);
|
||||
vslider3->set_knob_size_mode(GUI::Slider::KnobSizeMode::Proportional);
|
||||
|
||||
auto slider1 = main_widget->add<GUI::HorizontalSlider>();
|
||||
auto slider1 = main_widget.add<GUI::HorizontalSlider>();
|
||||
(void)slider1;
|
||||
auto slider2 = main_widget->add<GUI::HorizontalSlider>();
|
||||
auto slider2 = main_widget.add<GUI::HorizontalSlider>();
|
||||
slider2->set_enabled(false);
|
||||
auto slider3 = main_widget->add<GUI::HorizontalSlider>();
|
||||
auto slider3 = main_widget.add<GUI::HorizontalSlider>();
|
||||
slider3->set_max(5);
|
||||
slider3->set_knob_size_mode(GUI::Slider::KnobSizeMode::Proportional);
|
||||
|
||||
auto scrollbar1 = main_widget->add<GUI::ScrollBar>(Orientation::Horizontal);
|
||||
auto scrollbar1 = main_widget.add<GUI::ScrollBar>(Orientation::Horizontal);
|
||||
scrollbar1->set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed);
|
||||
scrollbar1->set_preferred_size(0, 16);
|
||||
scrollbar1->set_min(0);
|
||||
scrollbar1->set_max(100);
|
||||
scrollbar1->set_value(50);
|
||||
auto scrollbar2 = main_widget->add<GUI::ScrollBar>(Orientation::Horizontal);
|
||||
auto scrollbar2 = main_widget.add<GUI::ScrollBar>(Orientation::Horizontal);
|
||||
scrollbar2->set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed);
|
||||
scrollbar2->set_preferred_size(0, 16);
|
||||
scrollbar2->set_enabled(false);
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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());
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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"));
|
||||
|
|
|
@ -57,12 +57,11 @@ int main(int argc, char** argv)
|
|||
window->set_title("Minesweeper");
|
||||
window->set_rect(100, 100, 139, 175);
|
||||
|
||||
auto widget = GUI::Widget::construct();
|
||||
window->set_main_widget(widget);
|
||||
widget->set_layout<GUI::VerticalBoxLayout>();
|
||||
widget->layout()->set_spacing(0);
|
||||
auto& widget = window->set_main_widget<GUI::Widget>();
|
||||
widget.set_layout<GUI::VerticalBoxLayout>();
|
||||
widget.layout()->set_spacing(0);
|
||||
|
||||
auto container = widget->add<GUI::Widget>();
|
||||
auto container = widget.add<GUI::Widget>();
|
||||
container->set_fill_with_background_color(true);
|
||||
container->set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed);
|
||||
container->set_preferred_size(0, 36);
|
||||
|
@ -77,7 +76,7 @@ int main(int argc, char** argv)
|
|||
auto time_icon_label = container->add<GUI::Label>();
|
||||
time_icon_label->set_icon(Gfx::Bitmap::load_from_file("/res/icons/minesweeper/timer.png"));
|
||||
auto time_label = container->add<GUI::Label>();
|
||||
auto field = widget->add<Field>(*flag_label, *time_label, *face_button, [&](auto size) {
|
||||
auto field = widget.add<Field>(*flag_label, *time_label, *face_button, [&](auto size) {
|
||||
size.set_height(size.height() + container->preferred_size().height());
|
||||
window->resize(size);
|
||||
});
|
||||
|
|
|
@ -55,15 +55,14 @@ int main(int argc, char** argv)
|
|||
window->set_title("Snake");
|
||||
window->set_rect(100, 100, 320, 320);
|
||||
|
||||
auto game = SnakeGame::construct();
|
||||
window->set_main_widget(game);
|
||||
auto& game = window->set_main_widget<SnakeGame>();
|
||||
|
||||
auto menubar = make<GUI::MenuBar>();
|
||||
|
||||
auto app_menu = GUI::Menu::construct("Snake");
|
||||
|
||||
app_menu->add_action(GUI::Action::create("New game", { Mod_None, Key_F2 }, [&](const GUI::Action&) {
|
||||
game->reset();
|
||||
game.reset();
|
||||
}));
|
||||
app_menu->add_action(GUI::CommonActions::make_quit_action([](auto&) {
|
||||
GUI::Application::the().quit(0);
|
||||
|
|
|
@ -42,12 +42,11 @@ AboutDialog::AboutDialog(const StringView& name, const Gfx::Bitmap* icon, Core::
|
|||
set_title(String::format("About %s", m_name.characters()));
|
||||
set_resizable(false);
|
||||
|
||||
auto widget = Widget::construct();
|
||||
set_main_widget(widget);
|
||||
widget->set_fill_with_background_color(true);
|
||||
widget->set_layout<HorizontalBoxLayout>();
|
||||
auto& widget = set_main_widget<Widget>();
|
||||
widget.set_fill_with_background_color(true);
|
||||
widget.set_layout<HorizontalBoxLayout>();
|
||||
|
||||
auto left_container = widget->add<Widget>();
|
||||
auto left_container = widget.add<Widget>();
|
||||
left_container->set_size_policy(SizePolicy::Fixed, SizePolicy::Fill);
|
||||
left_container->set_preferred_size(48, 0);
|
||||
left_container->set_layout<VerticalBoxLayout>();
|
||||
|
@ -57,7 +56,7 @@ AboutDialog::AboutDialog(const StringView& name, const Gfx::Bitmap* icon, Core::
|
|||
icon_label->set_preferred_size(40, 40);
|
||||
left_container->layout()->add_spacer();
|
||||
|
||||
auto right_container = widget->add<Widget>();
|
||||
auto right_container = widget.add<Widget>();
|
||||
right_container->set_layout<VerticalBoxLayout>();
|
||||
right_container->layout()->set_margins({ 0, 4, 4, 4 });
|
||||
|
||||
|
|
|
@ -122,13 +122,12 @@ private:
|
|||
TooltipWindow()
|
||||
{
|
||||
set_window_type(WindowType::Tooltip);
|
||||
m_label = Label::construct();
|
||||
m_label = set_main_widget<Label>();
|
||||
m_label->set_background_color(Color::from_rgb(0xdac7b5));
|
||||
m_label->set_fill_with_background_color(true);
|
||||
m_label->set_frame_thickness(1);
|
||||
m_label->set_frame_shape(Gfx::FrameShape::Container);
|
||||
m_label->set_frame_shadow(Gfx::FrameShadow::Plain);
|
||||
set_main_widget(m_label);
|
||||
}
|
||||
|
||||
RefPtr<Label> m_label;
|
||||
|
|
|
@ -48,16 +48,15 @@ ColorPicker::~ColorPicker()
|
|||
|
||||
void ColorPicker::build()
|
||||
{
|
||||
auto horizontal_container = Widget::construct();
|
||||
horizontal_container->set_fill_with_background_color(true);
|
||||
horizontal_container->set_layout<HorizontalBoxLayout>();
|
||||
horizontal_container->layout()->set_margins({ 4, 4, 4, 4 });
|
||||
set_main_widget(horizontal_container);
|
||||
auto& horizontal_container = set_main_widget<Widget>();
|
||||
horizontal_container.set_fill_with_background_color(true);
|
||||
horizontal_container.set_layout<HorizontalBoxLayout>();
|
||||
horizontal_container.layout()->set_margins({ 4, 4, 4, 4 });
|
||||
|
||||
auto left_vertical_container = horizontal_container->add<Widget>();
|
||||
auto left_vertical_container = horizontal_container.add<Widget>();
|
||||
left_vertical_container->set_layout<VerticalBoxLayout>();
|
||||
|
||||
auto right_vertical_container = horizontal_container->add<Widget>();
|
||||
auto right_vertical_container = horizontal_container.add<Widget>();
|
||||
right_vertical_container->set_layout<VerticalBoxLayout>();
|
||||
|
||||
enum RGBComponent {
|
||||
|
|
|
@ -60,9 +60,8 @@ ComboBox::ComboBox()
|
|||
// FIXME: This is obviously not a tooltip window, but it's the closest thing to what we want atm.
|
||||
m_list_window->set_window_type(WindowType::Tooltip);
|
||||
|
||||
m_list_view = ListView::construct();
|
||||
m_list_view = m_list_window->set_main_widget<ListView>();
|
||||
m_list_view->horizontal_scrollbar().set_visible(false);
|
||||
m_list_window->set_main_widget(m_list_view);
|
||||
|
||||
m_list_view->on_selection = [this](auto& index) {
|
||||
ASSERT(model());
|
||||
|
|
|
@ -81,13 +81,12 @@ FilePicker::FilePicker(Mode mode, const StringView& file_name, const StringView&
|
|||
{
|
||||
set_title(m_mode == Mode::Open ? "Open File" : "Save File");
|
||||
set_rect(200, 200, 700, 400);
|
||||
auto horizontal_container = Widget::construct();
|
||||
set_main_widget(horizontal_container);
|
||||
horizontal_container->set_layout<HorizontalBoxLayout>();
|
||||
horizontal_container->layout()->set_margins({ 4, 4, 4, 4 });
|
||||
horizontal_container->set_fill_with_background_color(true);
|
||||
auto& horizontal_container = set_main_widget<Widget>();
|
||||
horizontal_container.set_layout<HorizontalBoxLayout>();
|
||||
horizontal_container.layout()->set_margins({ 4, 4, 4, 4 });
|
||||
horizontal_container.set_fill_with_background_color(true);
|
||||
|
||||
auto vertical_container = horizontal_container->add<Widget>();
|
||||
auto vertical_container = horizontal_container.add<Widget>();
|
||||
vertical_container->set_layout<VerticalBoxLayout>();
|
||||
vertical_container->layout()->set_spacing(4);
|
||||
|
||||
|
@ -236,7 +235,7 @@ FilePicker::FilePicker(Mode mode, const StringView& file_name, const StringView&
|
|||
}
|
||||
};
|
||||
|
||||
auto preview_container = horizontal_container->add<Frame>();
|
||||
auto preview_container = horizontal_container.add<Frame>();
|
||||
preview_container->set_size_policy(SizePolicy::Fixed, SizePolicy::Fill);
|
||||
preview_container->set_preferred_size(180, 0);
|
||||
preview_container->set_layout<VerticalBoxLayout>();
|
||||
|
|
|
@ -48,30 +48,29 @@ InputBox::~InputBox()
|
|||
|
||||
void InputBox::build()
|
||||
{
|
||||
auto widget = Widget::construct();
|
||||
set_main_widget(widget);
|
||||
auto& widget = set_main_widget<Widget>();
|
||||
|
||||
int text_width = widget->font().width(m_prompt);
|
||||
int title_width = widget->font().width(title()) + 24 /* icon, plus a little padding -- not perfect */;
|
||||
int text_width = widget.font().width(m_prompt);
|
||||
int title_width = widget.font().width(title()) + 24 /* icon, plus a little padding -- not perfect */;
|
||||
int max_width = AK::max(text_width, title_width);
|
||||
|
||||
set_rect(x(), y(), max_width + 80, 80);
|
||||
|
||||
widget->set_layout<VerticalBoxLayout>();
|
||||
widget->set_fill_with_background_color(true);
|
||||
widget.set_layout<VerticalBoxLayout>();
|
||||
widget.set_fill_with_background_color(true);
|
||||
|
||||
widget->layout()->set_margins({ 8, 8, 8, 8 });
|
||||
widget->layout()->set_spacing(8);
|
||||
widget.layout()->set_margins({ 8, 8, 8, 8 });
|
||||
widget.layout()->set_spacing(8);
|
||||
|
||||
auto label = widget->add<Label>(m_prompt);
|
||||
auto label = widget.add<Label>(m_prompt);
|
||||
label->set_size_policy(SizePolicy::Fixed, SizePolicy::Fixed);
|
||||
label->set_preferred_size(text_width, 16);
|
||||
|
||||
m_text_editor = widget->add<TextBox>();
|
||||
m_text_editor = widget.add<TextBox>();
|
||||
m_text_editor->set_size_policy(SizePolicy::Fill, SizePolicy::Fixed);
|
||||
m_text_editor->set_preferred_size(0, 19);
|
||||
|
||||
auto button_container_outer = widget->add<Widget>();
|
||||
auto button_container_outer = widget.add<Widget>();
|
||||
button_container_outer->set_size_policy(SizePolicy::Fill, SizePolicy::Fixed);
|
||||
button_container_outer->set_preferred_size(0, 20);
|
||||
button_container_outer->set_layout<VerticalBoxLayout>();
|
||||
|
|
|
@ -91,21 +91,20 @@ bool MessageBox::should_include_no_button() const
|
|||
|
||||
void MessageBox::build()
|
||||
{
|
||||
auto widget = Widget::construct();
|
||||
set_main_widget(widget);
|
||||
auto& widget = set_main_widget<Widget>();
|
||||
|
||||
int text_width = widget->font().width(m_text);
|
||||
int text_width = widget.font().width(m_text);
|
||||
int icon_width = 0;
|
||||
|
||||
widget->set_layout<VerticalBoxLayout>();
|
||||
widget->set_fill_with_background_color(true);
|
||||
widget.set_layout<VerticalBoxLayout>();
|
||||
widget.set_fill_with_background_color(true);
|
||||
|
||||
widget->layout()->set_margins({ 0, 15, 0, 15 });
|
||||
widget->layout()->set_spacing(15);
|
||||
widget.layout()->set_margins({ 0, 15, 0, 15 });
|
||||
widget.layout()->set_spacing(15);
|
||||
|
||||
RefPtr<Widget> message_container = widget;
|
||||
if (m_type != Type::None) {
|
||||
message_container = widget->add<Widget>();
|
||||
message_container = widget.add<Widget>();
|
||||
message_container->set_layout<HorizontalBoxLayout>();
|
||||
message_container->layout()->set_margins({ 8, 0, 8, 0 });
|
||||
message_container->layout()->set_spacing(8);
|
||||
|
@ -121,7 +120,7 @@ void MessageBox::build()
|
|||
label->set_size_policy(SizePolicy::Fill, SizePolicy::Fixed);
|
||||
label->set_preferred_size(text_width, 16);
|
||||
|
||||
auto button_container = widget->add<Widget>();
|
||||
auto button_container = widget.add<Widget>();
|
||||
button_container->set_layout<HorizontalBoxLayout>();
|
||||
button_container->layout()->set_spacing(5);
|
||||
button_container->layout()->set_margins({ 15, 0, 15, 0 });
|
||||
|
|
|
@ -94,8 +94,7 @@ int main(int argc, char** argv)
|
|||
window->set_window_type(GUI::WindowType::MenuApplet);
|
||||
window->resize(12, 16);
|
||||
|
||||
auto widget = AudioWidget::construct();
|
||||
window->set_main_widget(widget);
|
||||
window->set_main_widget<AudioWidget>();
|
||||
window->show();
|
||||
|
||||
if (unveil("/res", "r") < 0) {
|
||||
|
|
|
@ -128,8 +128,7 @@ int main(int argc, char** argv)
|
|||
window->set_window_type(GUI::WindowType::MenuApplet);
|
||||
window->resize(30, 16);
|
||||
|
||||
auto widget = GraphWidget::construct();
|
||||
window->set_main_widget(widget);
|
||||
window->set_main_widget<GraphWidget>();
|
||||
window->show();
|
||||
|
||||
if (unveil("/res", "r") < 0) {
|
||||
|
|
|
@ -106,10 +106,8 @@ int main(int argc, char** argv)
|
|||
window->set_title("Clock");
|
||||
window->set_window_type(GUI::WindowType::MenuApplet);
|
||||
|
||||
auto widget = ClockWidget::construct();
|
||||
|
||||
window->resize(widget->get_width(), 16);
|
||||
window->set_main_widget(widget);
|
||||
auto& widget = window->set_main_widget<ClockWidget>();
|
||||
window->resize(widget.get_width(), 16);
|
||||
window->show();
|
||||
|
||||
if (unveil("/res", "r") < 0) {
|
||||
|
|
|
@ -92,10 +92,8 @@ int main(int argc, char** argv)
|
|||
window->set_title("UserName");
|
||||
window->set_window_type(GUI::WindowType::MenuApplet);
|
||||
|
||||
auto widget = UserNameWidget::construct();
|
||||
|
||||
window->resize(widget->get_width(), 16);
|
||||
window->set_main_widget(widget);
|
||||
auto& widget = window->set_main_widget<UserNameWidget>();
|
||||
window->resize(widget.get_width(), 16);
|
||||
window->show();
|
||||
|
||||
if (pledge("stdio shared_buffer rpath", nullptr) < 0) {
|
||||
|
|
|
@ -61,14 +61,14 @@ NotificationWindow::NotificationWindow(const String& text, const String& title)
|
|||
|
||||
m_original_rect = rect;
|
||||
|
||||
auto widget = GUI::Widget::construct();
|
||||
widget->set_fill_with_background_color(true);
|
||||
auto& widget = set_main_widget<GUI::Widget>();
|
||||
widget.set_fill_with_background_color(true);
|
||||
|
||||
widget->set_layout<GUI::HorizontalBoxLayout>();
|
||||
widget->layout()->set_margins({ 4, 4, 4, 4 });
|
||||
widget->layout()->set_spacing(4);
|
||||
widget.set_layout<GUI::HorizontalBoxLayout>();
|
||||
widget.layout()->set_margins({ 4, 4, 4, 4 });
|
||||
widget.layout()->set_spacing(4);
|
||||
|
||||
auto left_container = widget->add<GUI::Widget>();
|
||||
auto left_container = widget.add<GUI::Widget>();
|
||||
left_container->set_layout<GUI::VerticalBoxLayout>();
|
||||
|
||||
auto title_label = left_container->add<GUI::Label>(title);
|
||||
|
@ -77,7 +77,7 @@ NotificationWindow::NotificationWindow(const String& text, const String& title)
|
|||
auto text_label = left_container->add<GUI::Label>(text);
|
||||
text_label->set_text_alignment(Gfx::TextAlignment::CenterLeft);
|
||||
|
||||
auto right_container = widget->add<GUI::Widget>();
|
||||
auto right_container = widget.add<GUI::Widget>();
|
||||
right_container->set_size_policy(GUI::SizePolicy::Fixed, GUI::SizePolicy::Fill);
|
||||
right_container->set_preferred_size(40, 0);
|
||||
right_container->set_layout<GUI::HorizontalBoxLayout>();
|
||||
|
@ -87,8 +87,6 @@ NotificationWindow::NotificationWindow(const String& text, const String& title)
|
|||
s_windows.remove(this);
|
||||
close();
|
||||
};
|
||||
|
||||
set_main_widget(widget);
|
||||
}
|
||||
|
||||
NotificationWindow::~NotificationWindow()
|
||||
|
|
|
@ -64,13 +64,12 @@ int main(int argc, char** argv)
|
|||
auto document = parse_html_document(html);
|
||||
|
||||
auto window = GUI::Window::construct();
|
||||
auto widget = HtmlView::construct();
|
||||
widget->set_document(document);
|
||||
if (!widget->document()->title().is_null())
|
||||
window->set_title(String::format("%s - HTML", widget->document()->title().characters()));
|
||||
auto& widget = window->set_main_widget<HtmlView>();
|
||||
widget.set_document(document);
|
||||
if (!widget.document()->title().is_null())
|
||||
window->set_title(String::format("%s - HTML", widget.document()->title().characters()));
|
||||
else
|
||||
window->set_title("HTML");
|
||||
window->set_main_widget(widget);
|
||||
window->show();
|
||||
|
||||
auto menubar = make<GUI::MenuBar>();
|
||||
|
|
Loading…
Reference in a new issue