mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 04:27:45 +00:00
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
26 changed files with 61 additions and 60 deletions
|
@ -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);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue