GWidget: Add set_preferred_size(width, height) overload.
It was annoying to always write set_preferred_size({ width, height }). :^)
This commit is contained in:
parent
5b440a72f9
commit
aa2224a2f0
Notes:
sideshowbarker
2024-07-19 13:07:09 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/aa2224a2f05
26 changed files with 61 additions and 60 deletions
Applications
About
FileManager
IRCClient
Launcher
PaintBrush
ProcessManager
Taskbar
Terminal
Demos
Games/Minesweeper
Libraries/LibGUI
|
@ -34,7 +34,7 @@ int main(int argc, char** argv)
|
|||
label->set_font(Font::default_bold_font());
|
||||
label->set_text("Serenity Operating System");
|
||||
label->set_size_policy(SizePolicy::Fill, SizePolicy::Fixed);
|
||||
label->set_preferred_size({ 0, 11 });
|
||||
label->set_preferred_size(0, 11);
|
||||
|
||||
utsname uts;
|
||||
int rc = uname(&uts);
|
||||
|
@ -43,12 +43,12 @@ int main(int argc, char** argv)
|
|||
auto* version_label = new GLabel(widget);
|
||||
version_label->set_text(String::format("Version %s", uts.release));
|
||||
version_label->set_size_policy(SizePolicy::Fill, SizePolicy::Fixed);
|
||||
version_label->set_preferred_size({ 0, 11 });
|
||||
version_label->set_preferred_size(0, 11);
|
||||
|
||||
auto* quit_button = new GButton(widget);
|
||||
quit_button->set_text("Okay");
|
||||
quit_button->set_size_policy(SizePolicy::Fixed, SizePolicy::Fixed);
|
||||
quit_button->set_preferred_size({ 100, 20 });
|
||||
quit_button->set_preferred_size(100, 20);
|
||||
quit_button->on_click = [](GButton&) {
|
||||
GApplication::the().quit(0);
|
||||
};
|
||||
|
|
|
@ -48,7 +48,7 @@ int main(int argc, char** argv)
|
|||
auto* main_toolbar = new GToolBar(widget);
|
||||
auto* location_toolbar = new GToolBar(widget);
|
||||
location_toolbar->layout()->set_margins({ 6, 3, 6, 3 });
|
||||
location_toolbar->set_preferred_size({ 0, 25 });
|
||||
location_toolbar->set_preferred_size(0, 25);
|
||||
|
||||
auto* location_label = new GLabel("Location: ", location_toolbar);
|
||||
location_label->size_to_fit();
|
||||
|
@ -60,7 +60,7 @@ int main(int argc, char** argv)
|
|||
auto file_system_model = GFileSystemModel::create("/", GFileSystemModel::Mode::DirectoriesOnly);
|
||||
tree_view->set_model(file_system_model);
|
||||
tree_view->set_size_policy(SizePolicy::Fixed, SizePolicy::Fill);
|
||||
tree_view->set_preferred_size({ 200, 0 });
|
||||
tree_view->set_preferred_size(200, 0);
|
||||
auto* directory_view = new DirectoryView(splitter);
|
||||
|
||||
auto* statusbar = new GStatusBar(widget);
|
||||
|
|
|
@ -174,7 +174,7 @@ void IRCAppWindow::setup_widgets()
|
|||
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_preferred_size({ 100, 0 });
|
||||
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()));
|
||||
};
|
||||
|
|
|
@ -34,7 +34,7 @@ IRCWindow::IRCWindow(IRCClient& client, void* owner, Type type, const String& na
|
|||
auto* member_view = new GTableView(container);
|
||||
member_view->set_headers_visible(false);
|
||||
member_view->set_size_policy(SizePolicy::Fixed, SizePolicy::Fill);
|
||||
member_view->set_preferred_size({ 100, 0 });
|
||||
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);
|
||||
|
@ -42,7 +42,7 @@ IRCWindow::IRCWindow(IRCClient& client, void* owner, Type type, const String& na
|
|||
|
||||
m_text_editor = new GTextEditor(GTextEditor::SingleLine, this);
|
||||
m_text_editor->set_size_policy(SizePolicy::Fill, SizePolicy::Fixed);
|
||||
m_text_editor->set_preferred_size({ 0, 19 });
|
||||
m_text_editor->set_preferred_size(0, 19);
|
||||
m_text_editor->on_return_pressed = [this] {
|
||||
if (m_type == Channel)
|
||||
m_client.handle_user_input_in_channel(m_name, m_text_editor->text());
|
||||
|
|
|
@ -45,7 +45,7 @@ public:
|
|||
set_tooltip(name);
|
||||
set_button_style(ButtonStyle::CoolBar);
|
||||
set_icon(GraphicsBitmap::load_from_file(icon_path));
|
||||
set_preferred_size({ 50, 50 });
|
||||
set_preferred_size(50, 50);
|
||||
set_size_policy(SizePolicy::Fixed, SizePolicy::Fixed);
|
||||
on_click = [this](GButton&) {
|
||||
pid_t child_pid = fork();
|
||||
|
|
|
@ -41,13 +41,13 @@ void ColorDialog::build()
|
|||
right_vertical_container->layout()->add_spacer();
|
||||
auto* cancel_button = new GButton("Cancel", right_vertical_container);
|
||||
cancel_button->set_size_policy(SizePolicy::Fill, SizePolicy::Fixed);
|
||||
cancel_button->set_preferred_size({ 0, 20 });
|
||||
cancel_button->set_preferred_size(0, 20);
|
||||
cancel_button->on_click = [&](auto&) {
|
||||
done(GDialog::ExecCancel);
|
||||
};
|
||||
auto* ok_button = new GButton("Okay", right_vertical_container);
|
||||
ok_button->set_size_policy(SizePolicy::Fill, SizePolicy::Fixed);
|
||||
ok_button->set_preferred_size({ 0, 20 });
|
||||
ok_button->set_preferred_size(0, 20);
|
||||
ok_button->on_click = [&](auto&) {
|
||||
done(GDialog::ExecOK);
|
||||
};
|
||||
|
@ -55,7 +55,7 @@ void ColorDialog::build()
|
|||
auto make_spinbox = [&](RGBComponent component, int initial_value) {
|
||||
auto* spinbox = new GSpinBox(left_vertical_container);
|
||||
spinbox->set_size_policy(SizePolicy::Fill, SizePolicy::Fixed);
|
||||
spinbox->set_preferred_size({ 0, 20 });
|
||||
spinbox->set_preferred_size(0, 20);
|
||||
spinbox->set_min(0);
|
||||
spinbox->set_max(255);
|
||||
spinbox->set_value(initial_value);
|
||||
|
|
|
@ -53,7 +53,7 @@ PaletteWidget::PaletteWidget(PaintableWidget& paintable_widget, GWidget* parent)
|
|||
set_background_color(Color::WarmGray);
|
||||
|
||||
set_size_policy(SizePolicy::Fill, SizePolicy::Fixed);
|
||||
set_preferred_size({ 0, 34 });
|
||||
set_preferred_size(0, 34);
|
||||
|
||||
m_secondary_color_widget = new GFrame(this);
|
||||
m_secondary_color_widget->set_frame_thickness(2);
|
||||
|
|
|
@ -41,7 +41,7 @@ ToolboxWidget::ToolboxWidget(GWidget* parent)
|
|||
set_frame_shadow(FrameShadow::Raised);
|
||||
|
||||
set_size_policy(SizePolicy::Fixed, SizePolicy::Fill);
|
||||
set_preferred_size({ 48, 0 });
|
||||
set_preferred_size(48, 0);
|
||||
|
||||
set_layout(make<GBoxLayout>(Orientation::Vertical));
|
||||
layout()->set_margins({ 4, 4, 4, 4 });
|
||||
|
@ -49,7 +49,7 @@ ToolboxWidget::ToolboxWidget(GWidget* parent)
|
|||
auto add_tool = [&](const StringView& name, const StringView& icon_name, OwnPtr<Tool>&& tool) {
|
||||
auto* button = new ToolButton(name, this, move(tool));
|
||||
button->set_size_policy(SizePolicy::Fill, SizePolicy::Fixed);
|
||||
button->set_preferred_size({ 0, 32 });
|
||||
button->set_preferred_size(0, 32);
|
||||
button->set_checkable(true);
|
||||
button->set_exclusive(true);
|
||||
|
||||
|
|
|
@ -16,7 +16,7 @@ MemoryStatsWidget::MemoryStatsWidget(GraphWidget& graph, GWidget* parent)
|
|||
if (!m_proc_memstat.open(CIODevice::OpenMode::ReadOnly))
|
||||
ASSERT_NOT_REACHED();
|
||||
set_size_policy(SizePolicy::Fill, SizePolicy::Fixed);
|
||||
set_preferred_size({ 0, 72 });
|
||||
set_preferred_size(0, 72);
|
||||
|
||||
set_layout(make<GBoxLayout>(Orientation::Vertical));
|
||||
layout()->set_margins({ 0, 8, 0, 0 });
|
||||
|
@ -26,7 +26,7 @@ MemoryStatsWidget::MemoryStatsWidget(GraphWidget& graph, GWidget* parent)
|
|||
auto* container = new GWidget(this);
|
||||
container->set_layout(make<GBoxLayout>(Orientation::Horizontal));
|
||||
container->set_size_policy(SizePolicy::Fixed, SizePolicy::Fixed);
|
||||
container->set_preferred_size({ 255, 12 });
|
||||
container->set_preferred_size(255, 12);
|
||||
auto* description_label = new GLabel(description, container);
|
||||
description_label->set_font(Font::default_bold_font());
|
||||
description_label->set_text_alignment(TextAlignment::CenterLeft);
|
||||
|
|
|
@ -41,7 +41,7 @@ int main(int argc, char** argv)
|
|||
cpu_graph_group_box->set_layout(make<GBoxLayout>(Orientation::Vertical));
|
||||
cpu_graph_group_box->layout()->set_margins({ 6, 16, 6, 6 });
|
||||
cpu_graph_group_box->set_size_policy(SizePolicy::Fill, SizePolicy::Fixed);
|
||||
cpu_graph_group_box->set_preferred_size({ 0, 120 });
|
||||
cpu_graph_group_box->set_preferred_size(0, 120);
|
||||
auto* cpu_graph = new GraphWidget(cpu_graph_group_box);
|
||||
cpu_graph->set_max(100);
|
||||
cpu_graph->set_text_color(Color::Green);
|
||||
|
@ -54,7 +54,7 @@ int main(int argc, char** argv)
|
|||
memory_graph_group_box->set_layout(make<GBoxLayout>(Orientation::Vertical));
|
||||
memory_graph_group_box->layout()->set_margins({ 6, 16, 6, 6 });
|
||||
memory_graph_group_box->set_size_policy(SizePolicy::Fill, SizePolicy::Fixed);
|
||||
memory_graph_group_box->set_preferred_size({ 0, 120 });
|
||||
memory_graph_group_box->set_preferred_size(0, 120);
|
||||
auto* memory_graph = new GraphWidget(memory_graph_group_box);
|
||||
memory_graph->set_text_color(Color::Cyan);
|
||||
memory_graph->set_graph_color(Color::from_rgb(0x00bbbb));
|
||||
|
|
|
@ -50,7 +50,7 @@ GButton* TaskbarWindow::create_button(const WindowIdentifier& identifier)
|
|||
{
|
||||
auto* button = new TaskbarButton(identifier, main_widget());
|
||||
button->set_size_policy(SizePolicy::Fixed, SizePolicy::Fixed);
|
||||
button->set_preferred_size({ 140, 22 });
|
||||
button->set_preferred_size(140, 22);
|
||||
button->set_checkable(true);
|
||||
button->set_text_alignment(TextAlignment::CenterLeft);
|
||||
return button;
|
||||
|
|
|
@ -957,7 +957,7 @@ void Terminal::set_size(u16 columns, u16 rows)
|
|||
m_pixel_height = (frame_thickness() * 2) + (m_inset * 2) + (m_rows * (font().glyph_height() + m_line_spacing)) - m_line_spacing;
|
||||
|
||||
set_size_policy(SizePolicy::Fixed, SizePolicy::Fixed);
|
||||
set_preferred_size({ m_pixel_width, m_pixel_height });
|
||||
set_preferred_size(m_pixel_width, m_pixel_height);
|
||||
|
||||
m_needs_background_fill = true;
|
||||
force_repaint();
|
||||
|
|
|
@ -98,7 +98,7 @@ GWindow* create_settings_window(Terminal& terminal, RefPtr<CConfigFile> config)
|
|||
radio_container->layout()->set_margins({ 6, 16, 6, 6 });
|
||||
radio_container->set_fill_with_background_color(true);
|
||||
radio_container->set_size_policy(SizePolicy::Fill, SizePolicy::Fixed);
|
||||
radio_container->set_preferred_size({ 100, 70 });
|
||||
radio_container->set_preferred_size(100, 70);
|
||||
|
||||
auto* sysbell_radio = new GRadioButton("Use (Audible) System Bell", radio_container);
|
||||
auto* visbell_radio = new GRadioButton("Use (Visual) Terminal Bell", radio_container);
|
||||
|
@ -113,7 +113,7 @@ GWindow* create_settings_window(Terminal& terminal, RefPtr<CConfigFile> config)
|
|||
slider_container->layout()->set_margins({ 6, 16, 6, 6 });
|
||||
slider_container->set_fill_with_background_color(true);
|
||||
slider_container->set_size_policy(SizePolicy::Fill, SizePolicy::Fixed);
|
||||
slider_container->set_preferred_size({ 100, 50 });
|
||||
slider_container->set_preferred_size(100, 50);
|
||||
auto* slider = new GSlider(Orientation::Horizontal, slider_container);
|
||||
slider->set_fill_with_background_color(true);
|
||||
slider->set_background_color(Color::WarmGray);
|
||||
|
|
|
@ -26,7 +26,7 @@ int main(int argc, char** argv)
|
|||
auto* button = new GButton(main_widget);
|
||||
button->set_text("Good-bye");
|
||||
button->set_size_policy(SizePolicy::Fill, SizePolicy::Fixed);
|
||||
button->set_preferred_size({ 0, 20 });
|
||||
button->set_preferred_size(0, 20);
|
||||
button->on_click = [&](GButton&) {
|
||||
app.quit();
|
||||
};
|
||||
|
|
|
@ -68,7 +68,7 @@ int main(int argc, char** argv)
|
|||
|
||||
auto* vertical_slider_container = new GWidget(main_widget);
|
||||
vertical_slider_container->set_size_policy(SizePolicy::Fill, SizePolicy::Fixed);
|
||||
vertical_slider_container->set_preferred_size({ 0, 100 });
|
||||
vertical_slider_container->set_preferred_size(0, 100);
|
||||
vertical_slider_container->set_layout(make<GBoxLayout>(Orientation::Horizontal));
|
||||
auto* vslider1 = new GSlider(Orientation::Vertical, vertical_slider_container);
|
||||
(void)vslider1;
|
||||
|
@ -88,13 +88,13 @@ int main(int argc, char** argv)
|
|||
|
||||
auto* scrollbar1 = new GScrollBar(Orientation::Horizontal, main_widget);
|
||||
scrollbar1->set_size_policy(SizePolicy::Fill, SizePolicy::Fixed);
|
||||
scrollbar1->set_preferred_size({ 0, 16 });
|
||||
scrollbar1->set_preferred_size(0, 16);
|
||||
scrollbar1->set_min(0);
|
||||
scrollbar1->set_max(100);
|
||||
scrollbar1->set_value(50);
|
||||
auto* scrollbar2 = new GScrollBar(Orientation::Horizontal, main_widget);
|
||||
scrollbar2->set_size_policy(SizePolicy::Fill, SizePolicy::Fixed);
|
||||
scrollbar2->set_preferred_size({ 0, 16 });
|
||||
scrollbar2->set_preferred_size(0, 16);
|
||||
scrollbar2->set_enabled(false);
|
||||
|
||||
window->show();
|
||||
|
|
|
@ -467,7 +467,7 @@ void Field::set_field_size(int rows, int columns, int mine_count)
|
|||
m_rows = rows;
|
||||
m_columns = columns;
|
||||
m_mine_count = mine_count;
|
||||
set_preferred_size({ frame_thickness() * 2 + m_columns * square_size(), frame_thickness() * 2 + m_rows * square_size() });
|
||||
set_preferred_size(frame_thickness() * 2 + m_columns * square_size(), frame_thickness() * 2 + m_rows * square_size());
|
||||
reset();
|
||||
m_on_size_changed(preferred_size());
|
||||
}
|
||||
|
|
|
@ -27,7 +27,7 @@ int main(int argc, char** argv)
|
|||
auto* container = new GWidget(widget);
|
||||
container->set_fill_with_background_color(true);
|
||||
container->set_size_policy(SizePolicy::Fill, SizePolicy::Fixed);
|
||||
container->set_preferred_size({ 0, 36 });
|
||||
container->set_preferred_size(0, 36);
|
||||
container->set_layout(make<GBoxLayout>(Orientation::Horizontal));
|
||||
auto* flag_icon_label = new GLabel(container);
|
||||
flag_icon_label->set_icon(GraphicsBitmap::load_from_file("/res/icons/minesweeper/flag.png"));
|
||||
|
@ -35,7 +35,7 @@ int main(int argc, char** argv)
|
|||
auto* face_button = new GButton(container);
|
||||
face_button->set_button_style(ButtonStyle::CoolBar);
|
||||
face_button->set_size_policy(SizePolicy::Fixed, SizePolicy::Fill);
|
||||
face_button->set_preferred_size({ 36, 0 });
|
||||
face_button->set_preferred_size(36, 0);
|
||||
auto* time_icon_label = new GLabel(container);
|
||||
time_icon_label->set_icon(GraphicsBitmap::load_from_file("/res/icons/minesweeper/timer.png"));
|
||||
auto* time_label = new GLabel(container);
|
||||
|
|
|
@ -65,16 +65,16 @@ GFilePicker::GFilePicker(Mode mode, const StringView& path, CObject* parent)
|
|||
upper_container->set_layout(make<GBoxLayout>(Orientation::Horizontal));
|
||||
upper_container->layout()->set_spacing(4);
|
||||
upper_container->set_size_policy(SizePolicy::Fill, SizePolicy::Fixed);
|
||||
upper_container->set_preferred_size({ 0, 26 });
|
||||
upper_container->set_preferred_size(0, 26);
|
||||
|
||||
auto* toolbar = new GToolBar(upper_container);
|
||||
toolbar->set_size_policy(SizePolicy::Fixed, SizePolicy::Fill);
|
||||
toolbar->set_preferred_size({ 60, 0 });
|
||||
toolbar->set_preferred_size(60, 0);
|
||||
toolbar->set_has_frame(false);
|
||||
|
||||
auto* location_textbox = new GTextBox(upper_container);
|
||||
location_textbox->set_size_policy(SizePolicy::Fill, SizePolicy::Fixed);
|
||||
location_textbox->set_preferred_size({ 0, 20 });
|
||||
location_textbox->set_preferred_size(0, 20);
|
||||
|
||||
m_view = new GTableView(vertical_container);
|
||||
m_view->set_model(GSortingProxyModel::create(*m_model));
|
||||
|
@ -116,16 +116,16 @@ GFilePicker::GFilePicker(Mode mode, const StringView& path, CObject* parent)
|
|||
lower_container->set_layout(make<GBoxLayout>(Orientation::Vertical));
|
||||
lower_container->layout()->set_spacing(4);
|
||||
lower_container->set_size_policy(SizePolicy::Fill, SizePolicy::Fixed);
|
||||
lower_container->set_preferred_size({ 0, 60 });
|
||||
lower_container->set_preferred_size(0, 60);
|
||||
|
||||
auto* filename_container = new GWidget(lower_container);
|
||||
filename_container->set_size_policy(SizePolicy::Fill, SizePolicy::Fixed);
|
||||
filename_container->set_preferred_size({ 0, 20 });
|
||||
filename_container->set_preferred_size(0, 20);
|
||||
filename_container->set_layout(make<GBoxLayout>(Orientation::Horizontal));
|
||||
auto* filename_label = new GLabel("File name:", filename_container);
|
||||
filename_label->set_text_alignment(TextAlignment::CenterLeft);
|
||||
filename_label->set_size_policy(SizePolicy::Fixed, SizePolicy::Fill);
|
||||
filename_label->set_preferred_size({ 60, 0 });
|
||||
filename_label->set_preferred_size(60, 0);
|
||||
auto* filename_textbox = new GTextBox(filename_container);
|
||||
if (m_mode == Mode::Save) {
|
||||
filename_textbox->set_text("Untitled.txt"); //TODO: replace .txt with a preferred extension
|
||||
|
@ -152,14 +152,14 @@ GFilePicker::GFilePicker(Mode mode, const StringView& path, CObject* parent)
|
|||
|
||||
auto* button_container = new GWidget(lower_container);
|
||||
button_container->set_size_policy(SizePolicy::Fill, SizePolicy::Fixed);
|
||||
button_container->set_preferred_size({ 0, 20 });
|
||||
button_container->set_preferred_size(0, 20);
|
||||
button_container->set_layout(make<GBoxLayout>(Orientation::Horizontal));
|
||||
button_container->layout()->set_spacing(4);
|
||||
button_container->layout()->add_spacer();
|
||||
|
||||
auto* cancel_button = new GButton(button_container);
|
||||
cancel_button->set_size_policy(SizePolicy::Fixed, SizePolicy::Fill);
|
||||
cancel_button->set_preferred_size({ 80, 0 });
|
||||
cancel_button->set_preferred_size(80, 0);
|
||||
cancel_button->set_text("Cancel");
|
||||
cancel_button->on_click = [this](auto&) {
|
||||
done(ExecCancel);
|
||||
|
@ -167,7 +167,7 @@ GFilePicker::GFilePicker(Mode mode, const StringView& path, CObject* parent)
|
|||
|
||||
auto* ok_button = new GButton(button_container);
|
||||
ok_button->set_size_policy(SizePolicy::Fixed, SizePolicy::Fill);
|
||||
ok_button->set_preferred_size({ 80, 0 });
|
||||
ok_button->set_preferred_size(80, 0);
|
||||
ok_button->set_text(ok_button_name(m_mode));
|
||||
ok_button->on_click = [this, filename_textbox](auto&) {
|
||||
FileSystemPath path(String::format("%s/%s", m_model->path().characters(), filename_textbox->text().characters()));
|
||||
|
@ -184,7 +184,7 @@ GFilePicker::GFilePicker(Mode mode, const StringView& path, CObject* parent)
|
|||
|
||||
auto* preview_container = new GFrame(horizontal_container);
|
||||
preview_container->set_size_policy(SizePolicy::Fixed, SizePolicy::Fill);
|
||||
preview_container->set_preferred_size({ 180, 0 });
|
||||
preview_container->set_preferred_size(180, 0);
|
||||
preview_container->set_frame_shape(FrameShape::Container);
|
||||
preview_container->set_frame_shadow(FrameShadow::Sunken);
|
||||
preview_container->set_frame_thickness(2);
|
||||
|
@ -194,16 +194,16 @@ GFilePicker::GFilePicker(Mode mode, const StringView& path, CObject* parent)
|
|||
m_preview_image_label = new GLabel(preview_container);
|
||||
m_preview_image_label->set_should_stretch_icon(true);
|
||||
m_preview_image_label->set_size_policy(SizePolicy::Fixed, SizePolicy::Fixed);
|
||||
m_preview_image_label->set_preferred_size({ 160, 160 });
|
||||
m_preview_image_label->set_preferred_size(160, 160);
|
||||
|
||||
m_preview_name_label = new GLabel(preview_container);
|
||||
m_preview_name_label->set_font(Font::default_bold_font());
|
||||
m_preview_name_label->set_size_policy(SizePolicy::Fill, SizePolicy::Fixed);
|
||||
m_preview_name_label->set_preferred_size({ 0, m_preview_name_label->font().glyph_height() });
|
||||
m_preview_name_label->set_preferred_size(0, m_preview_name_label->font().glyph_height());
|
||||
|
||||
m_preview_geometry_label = new GLabel(preview_container);
|
||||
m_preview_geometry_label->set_size_policy(SizePolicy::Fill, SizePolicy::Fixed);
|
||||
m_preview_geometry_label->set_preferred_size({ 0, m_preview_name_label->font().glyph_height() });
|
||||
m_preview_geometry_label->set_preferred_size(0, m_preview_name_label->font().glyph_height());
|
||||
}
|
||||
|
||||
GFilePicker::~GFilePicker()
|
||||
|
|
|
@ -36,15 +36,15 @@ void GInputBox::build()
|
|||
|
||||
auto* label = new GLabel(m_prompt, widget);
|
||||
label->set_size_policy(SizePolicy::Fixed, SizePolicy::Fixed);
|
||||
label->set_preferred_size({ text_width, 16 });
|
||||
label->set_preferred_size(text_width, 16);
|
||||
|
||||
m_text_editor = new GTextEditor(GTextEditor::SingleLine, widget);
|
||||
m_text_editor->set_size_policy(SizePolicy::Fill, SizePolicy::Fixed);
|
||||
m_text_editor->set_preferred_size({ 0, 19 });
|
||||
m_text_editor->set_preferred_size(0, 19);
|
||||
|
||||
auto* button_container_outer = new GWidget(widget);
|
||||
button_container_outer->set_size_policy(SizePolicy::Fill, SizePolicy::Fixed);
|
||||
button_container_outer->set_preferred_size({ 0, 20 });
|
||||
button_container_outer->set_preferred_size(0, 20);
|
||||
button_container_outer->set_layout(make<GBoxLayout>(Orientation::Vertical));
|
||||
|
||||
auto* button_container_inner = new GWidget(button_container_outer);
|
||||
|
@ -53,7 +53,7 @@ void GInputBox::build()
|
|||
|
||||
m_cancel_button = new GButton(button_container_inner);
|
||||
m_cancel_button->set_size_policy(SizePolicy::Fill, SizePolicy::Fixed);
|
||||
m_cancel_button->set_preferred_size({ 0, 20 });
|
||||
m_cancel_button->set_preferred_size(0, 20);
|
||||
m_cancel_button->set_text("Cancel");
|
||||
m_cancel_button->on_click = [this](auto&) {
|
||||
dbgprintf("GInputBox: Cancel button clicked\n");
|
||||
|
@ -62,7 +62,7 @@ void GInputBox::build()
|
|||
|
||||
m_ok_button = new GButton(button_container_inner);
|
||||
m_ok_button->set_size_policy(SizePolicy::Fill, SizePolicy::Fixed);
|
||||
m_ok_button->set_preferred_size({ 0, 20 });
|
||||
m_ok_button->set_preferred_size(0, 20);
|
||||
m_ok_button->set_text("OK");
|
||||
m_ok_button->on_click = [this](auto&) {
|
||||
dbgprintf("GInputBox: OK button clicked\n");
|
||||
|
|
|
@ -65,5 +65,5 @@ void GLabel::paint_event(GPaintEvent& event)
|
|||
void GLabel::size_to_fit()
|
||||
{
|
||||
set_size_policy(SizePolicy::Fixed, SizePolicy::Fill);
|
||||
set_preferred_size({ font().width(m_text), 0 });
|
||||
set_preferred_size(font().width(m_text), 0);
|
||||
}
|
||||
|
|
|
@ -71,14 +71,14 @@ void GMessageBox::build()
|
|||
|
||||
auto* icon_label = new GLabel(message_container);
|
||||
icon_label->set_size_policy(SizePolicy::Fixed, SizePolicy::Fixed);
|
||||
icon_label->set_preferred_size({ 32, 32 });
|
||||
icon_label->set_preferred_size(32, 32);
|
||||
icon_label->set_icon(icon());
|
||||
icon_width = icon_label->icon()->width();
|
||||
}
|
||||
|
||||
auto* label = new GLabel(m_text, message_container);
|
||||
label->set_size_policy(SizePolicy::Fill, SizePolicy::Fixed);
|
||||
label->set_preferred_size({ text_width, 16 });
|
||||
label->set_preferred_size(text_width, 16);
|
||||
|
||||
auto* button_container = new GWidget(widget);
|
||||
button_container->set_layout(make<GBoxLayout>(Orientation::Horizontal));
|
||||
|
@ -88,7 +88,7 @@ void GMessageBox::build()
|
|||
if (should_include_ok_button()) {
|
||||
auto* ok_button = new GButton(button_container);
|
||||
ok_button->set_size_policy(SizePolicy::Fill, SizePolicy::Fixed);
|
||||
ok_button->set_preferred_size({ 0, 20 });
|
||||
ok_button->set_preferred_size(0, 20);
|
||||
ok_button->set_text("OK");
|
||||
ok_button->on_click = [this](auto&) {
|
||||
dbgprintf("GMessageBox: OK button clicked\n");
|
||||
|
@ -99,7 +99,7 @@ void GMessageBox::build()
|
|||
if (should_include_cancel_button()) {
|
||||
auto* cancel_button = new GButton(button_container);
|
||||
cancel_button->set_size_policy(SizePolicy::Fill, SizePolicy::Fixed);
|
||||
cancel_button->set_preferred_size({ 0, 20 });
|
||||
cancel_button->set_preferred_size(0, 20);
|
||||
cancel_button->set_text("Cancel");
|
||||
cancel_button->on_click = [this](auto&) {
|
||||
dbgprintf("GMessageBox: Cancel button clicked\n");
|
||||
|
|
|
@ -8,7 +8,7 @@ GResizeCorner::GResizeCorner(GWidget* parent)
|
|||
: GWidget(parent)
|
||||
{
|
||||
set_size_policy(SizePolicy::Fixed, SizePolicy::Fixed);
|
||||
set_preferred_size({ 16, 16 });
|
||||
set_preferred_size(16, 16);
|
||||
m_bitmap = GraphicsBitmap::load_from_file("/res/icons/resize-corner.png");
|
||||
ASSERT(m_bitmap);
|
||||
}
|
||||
|
|
|
@ -71,9 +71,9 @@ GScrollBar::GScrollBar(Orientation orientation, GWidget* parent)
|
|||
s_right_arrow_bitmap = &CharacterBitmap::create_from_ascii(s_right_arrow_bitmap_data, 9, 9).leak_ref();
|
||||
|
||||
if (m_orientation == Orientation::Vertical) {
|
||||
set_preferred_size({ 15, 0 });
|
||||
set_preferred_size(15, 0);
|
||||
} else {
|
||||
set_preferred_size({ 0, 15 });
|
||||
set_preferred_size(0, 15);
|
||||
}
|
||||
|
||||
m_automatic_scrolling_timer.set_interval(100);
|
||||
|
|
|
@ -9,7 +9,7 @@ GStatusBar::GStatusBar(GWidget* parent)
|
|||
: GWidget(parent)
|
||||
{
|
||||
set_size_policy(SizePolicy::Fill, SizePolicy::Fixed);
|
||||
set_preferred_size({ 0, 20 });
|
||||
set_preferred_size(0, 20);
|
||||
set_layout(make<GBoxLayout>(Orientation::Horizontal));
|
||||
layout()->set_margins({ 2, 2, 2, 2 });
|
||||
layout()->set_spacing(2);
|
||||
|
|
|
@ -8,7 +8,7 @@ GToolBar::GToolBar(GWidget* parent)
|
|||
: GWidget(parent)
|
||||
{
|
||||
set_size_policy(SizePolicy::Fill, SizePolicy::Fixed);
|
||||
set_preferred_size({ 0, 28 });
|
||||
set_preferred_size(0, 28);
|
||||
set_layout(make<GBoxLayout>(Orientation::Horizontal));
|
||||
layout()->set_spacing(0);
|
||||
layout()->set_margins({ 2, 2, 2, 2 });
|
||||
|
@ -39,7 +39,7 @@ void GToolBar::add_action(GAction& action)
|
|||
button->set_size_policy(SizePolicy::Fixed, SizePolicy::Fixed);
|
||||
ASSERT(button->size_policy(Orientation::Horizontal) == SizePolicy::Fixed);
|
||||
ASSERT(button->size_policy(Orientation::Vertical) == SizePolicy::Fixed);
|
||||
button->set_preferred_size({ 24, 24 });
|
||||
button->set_preferred_size(24, 24);
|
||||
|
||||
m_items.append(move(item));
|
||||
}
|
||||
|
@ -51,7 +51,7 @@ public:
|
|||
{
|
||||
set_size_policy(SizePolicy::Fixed, SizePolicy::Fixed);
|
||||
set_background_color(Color::White);
|
||||
set_preferred_size({ 8, 22 });
|
||||
set_preferred_size(8, 22);
|
||||
}
|
||||
virtual ~SeparatorWidget() override {}
|
||||
|
||||
|
|
|
@ -46,6 +46,7 @@ public:
|
|||
|
||||
Size preferred_size() const { return m_preferred_size; }
|
||||
void set_preferred_size(const Size&);
|
||||
void set_preferred_size(int width, int height) { set_preferred_size({ width, height }); }
|
||||
|
||||
bool has_tooltip() const { return !m_tooltip.is_empty(); }
|
||||
String tooltip() const { return m_tooltip; }
|
||||
|
|
Loading…
Add table
Reference in a new issue