mirror of
				https://github.com/RGBCube/serenity
				synced 2025-10-31 04:12:43 +00:00 
			
		
		
		
	LibGUI: Rewrite layout system in terms of min and max sizes
This patch removes size policies and preferred sizes, and replaces them
with min-size and max-size for each widget.
Box layout now works in 3 passes:
    1) Set all items (widgets/spacers) to their min-size
    2) Distribute remaining space evenly, respecting max-size
    3) Place widgets one after the other, adding spacing in between
I've also added convenience helpers for setting a fixed size (which is
the same as setting min-size and max-size to the same value.)
This significantly reduces the verbosity of widget layout and makes GML
a bit more pleasant to write, too. :^)
			
			
This commit is contained in:
		
							parent
							
								
									b2bba5ce5c
								
							
						
					
					
						commit
						7dc5a3ead8
					
				
					 83 changed files with 444 additions and 957 deletions
				
			
		|  | @ -51,8 +51,7 @@ BookmarksBarWidget::BookmarksBarWidget(const String& bookmarks_file, bool enable | ||||||
|     set_layout<GUI::HorizontalBoxLayout>(); |     set_layout<GUI::HorizontalBoxLayout>(); | ||||||
|     layout()->set_spacing(0); |     layout()->set_spacing(0); | ||||||
| 
 | 
 | ||||||
|     set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed); |     set_fixed_height(20); | ||||||
|     set_preferred_size(0, 20); |  | ||||||
| 
 | 
 | ||||||
|     if (!enabled) |     if (!enabled) | ||||||
|         set_visible(false); |         set_visible(false); | ||||||
|  | @ -60,8 +59,7 @@ BookmarksBarWidget::BookmarksBarWidget(const String& bookmarks_file, bool enable | ||||||
|     m_additional = GUI::Button::construct(); |     m_additional = GUI::Button::construct(); | ||||||
|     m_additional->set_button_style(Gfx::ButtonStyle::CoolBar); |     m_additional->set_button_style(Gfx::ButtonStyle::CoolBar); | ||||||
|     m_additional->set_text(">"); |     m_additional->set_text(">"); | ||||||
|     m_additional->set_size_policy(GUI::SizePolicy::Fixed, GUI::SizePolicy::Fixed); |     m_additional->set_fixed_size(14, 20); | ||||||
|     m_additional->set_preferred_size(14, 20); |  | ||||||
|     m_additional->set_focus_policy(GUI::FocusPolicy::TabFocus); |     m_additional->set_focus_policy(GUI::FocusPolicy::TabFocus); | ||||||
|     m_additional->on_click = [this](auto) { |     m_additional->on_click = [this](auto) { | ||||||
|         if (m_additional_menu) { |         if (m_additional_menu) { | ||||||
|  | @ -134,9 +132,8 @@ void BookmarksBarWidget::model_did_update(unsigned) | ||||||
| 
 | 
 | ||||||
|         button.set_button_style(Gfx::ButtonStyle::CoolBar); |         button.set_button_style(Gfx::ButtonStyle::CoolBar); | ||||||
|         button.set_text(title); |         button.set_text(title); | ||||||
|         button.set_size_policy(GUI::SizePolicy::Fixed, GUI::SizePolicy::Fixed); |  | ||||||
|         button.set_icon(Gfx::Bitmap::load_from_file("/res/icons/16x16/filetype-html.png")); |         button.set_icon(Gfx::Bitmap::load_from_file("/res/icons/16x16/filetype-html.png")); | ||||||
|         button.set_preferred_size(font().width(title) + 32, 20); |         button.set_fixed_size(font().width(title) + 32, 20); | ||||||
|         button.set_relative_rect(rect); |         button.set_relative_rect(rect); | ||||||
|         button.set_focus_policy(GUI::FocusPolicy::TabFocus); |         button.set_focus_policy(GUI::FocusPolicy::TabFocus); | ||||||
|         button.set_tooltip(url); |         button.set_tooltip(url); | ||||||
|  |  | ||||||
|  | @ -62,8 +62,7 @@ ConsoleWidget::ConsoleWidget() | ||||||
| 
 | 
 | ||||||
|     auto& bottom_container = add<GUI::Widget>(); |     auto& bottom_container = add<GUI::Widget>(); | ||||||
|     bottom_container.set_layout<GUI::HorizontalBoxLayout>(); |     bottom_container.set_layout<GUI::HorizontalBoxLayout>(); | ||||||
|     bottom_container.set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed); |     bottom_container.set_fixed_height(22); | ||||||
|     bottom_container.set_preferred_size(0, 22); |  | ||||||
| 
 | 
 | ||||||
|     m_input = bottom_container.add<GUI::TextBox>(); |     m_input = bottom_container.add<GUI::TextBox>(); | ||||||
|     m_input->set_syntax_highlighter(make<GUI::JSSyntaxHighlighter>()); |     m_input->set_syntax_highlighter(make<GUI::JSSyntaxHighlighter>()); | ||||||
|  | @ -112,8 +111,7 @@ ConsoleWidget::ConsoleWidget() | ||||||
|     set_focus_proxy(m_input); |     set_focus_proxy(m_input); | ||||||
| 
 | 
 | ||||||
|     auto& clear_button = bottom_container.add<GUI::Button>(); |     auto& clear_button = bottom_container.add<GUI::Button>(); | ||||||
|     clear_button.set_size_policy(GUI::SizePolicy::Fixed, GUI::SizePolicy::Fixed); |     clear_button.set_fixed_size(22, 22); | ||||||
|     clear_button.set_preferred_size(22, 22); |  | ||||||
|     clear_button.set_icon(Gfx::Bitmap::load_from_file("/res/icons/16x16/delete.png")); |     clear_button.set_icon(Gfx::Bitmap::load_from_file("/res/icons/16x16/delete.png")); | ||||||
|     clear_button.set_tooltip("Clear the console output"); |     clear_button.set_tooltip("Clear the console output"); | ||||||
|     clear_button.on_click = [this](auto) { |     clear_button.on_click = [this](auto) { | ||||||
|  |  | ||||||
|  | @ -70,8 +70,7 @@ DownloadWidget::DownloadWidget(const URL& url) | ||||||
|     layout.set_margins({ 4, 4, 4, 4 }); |     layout.set_margins({ 4, 4, 4, 4 }); | ||||||
| 
 | 
 | ||||||
|     auto& animation_container = add<GUI::Widget>(); |     auto& animation_container = add<GUI::Widget>(); | ||||||
|     animation_container.set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed); |     animation_container.set_fixed_height(32); | ||||||
|     animation_container.set_preferred_size(0, 32); |  | ||||||
|     auto& animation_layout = animation_container.set_layout<GUI::HorizontalBoxLayout>(); |     auto& animation_layout = animation_container.set_layout<GUI::HorizontalBoxLayout>(); | ||||||
| 
 | 
 | ||||||
|     auto& browser_image = animation_container.add<GUI::ImageWidget>(); |     auto& browser_image = animation_container.add<GUI::ImageWidget>(); | ||||||
|  | @ -80,29 +79,24 @@ DownloadWidget::DownloadWidget(const URL& url) | ||||||
| 
 | 
 | ||||||
|     auto& source_label = add<GUI::Label>(String::formatted("From: {}", url)); |     auto& source_label = add<GUI::Label>(String::formatted("From: {}", url)); | ||||||
|     source_label.set_text_alignment(Gfx::TextAlignment::CenterLeft); |     source_label.set_text_alignment(Gfx::TextAlignment::CenterLeft); | ||||||
|     source_label.set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed); |     source_label.set_fixed_height(16); | ||||||
|     source_label.set_preferred_size(0, 16); |  | ||||||
| 
 | 
 | ||||||
|     m_progress_bar = add<GUI::ProgressBar>(); |     m_progress_bar = add<GUI::ProgressBar>(); | ||||||
|     m_progress_bar->set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed); |     m_progress_bar->set_fixed_height(20); | ||||||
|     m_progress_bar->set_preferred_size(0, 20); |  | ||||||
| 
 | 
 | ||||||
|     m_progress_label = add<GUI::Label>(); |     m_progress_label = add<GUI::Label>(); | ||||||
|     m_progress_label->set_text_alignment(Gfx::TextAlignment::CenterLeft); |     m_progress_label->set_text_alignment(Gfx::TextAlignment::CenterLeft); | ||||||
|     m_progress_label->set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed); |     m_progress_label->set_fixed_height(16); | ||||||
|     m_progress_label->set_preferred_size(0, 16); |  | ||||||
| 
 | 
 | ||||||
|     auto& destination_label = add<GUI::Label>(String::formatted("To: {}", m_destination_path)); |     auto& destination_label = add<GUI::Label>(String::formatted("To: {}", m_destination_path)); | ||||||
|     destination_label.set_text_alignment(Gfx::TextAlignment::CenterLeft); |     destination_label.set_text_alignment(Gfx::TextAlignment::CenterLeft); | ||||||
|     destination_label.set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed); |     destination_label.set_fixed_height(16); | ||||||
|     destination_label.set_preferred_size(0, 16); |  | ||||||
| 
 | 
 | ||||||
|     auto& button_container = add<GUI::Widget>(); |     auto& button_container = add<GUI::Widget>(); | ||||||
|     auto& button_container_layout = button_container.set_layout<GUI::HorizontalBoxLayout>(); |     auto& button_container_layout = button_container.set_layout<GUI::HorizontalBoxLayout>(); | ||||||
|     button_container_layout.add_spacer(); |     button_container_layout.add_spacer(); | ||||||
|     m_cancel_button = button_container.add<GUI::Button>("Cancel"); |     m_cancel_button = button_container.add<GUI::Button>("Cancel"); | ||||||
|     m_cancel_button->set_size_policy(GUI::SizePolicy::Fixed, GUI::SizePolicy::Fixed); |     m_cancel_button->set_fixed_size(100, 22); | ||||||
|     m_cancel_button->set_preferred_size(100, 22); |  | ||||||
|     m_cancel_button->on_click = [this](auto) { |     m_cancel_button->on_click = [this](auto) { | ||||||
|         bool success = m_download->stop(); |         bool success = m_download->stop(); | ||||||
|         ASSERT(success); |         ASSERT(success); | ||||||
|  | @ -111,8 +105,7 @@ DownloadWidget::DownloadWidget(const URL& url) | ||||||
| 
 | 
 | ||||||
|     m_close_button = button_container.add<GUI::Button>("OK"); |     m_close_button = button_container.add<GUI::Button>("OK"); | ||||||
|     m_close_button->set_enabled(false); |     m_close_button->set_enabled(false); | ||||||
|     m_close_button->set_size_policy(GUI::SizePolicy::Fixed, GUI::SizePolicy::Fixed); |     m_close_button->set_fixed_size(100, 22); | ||||||
|     m_close_button->set_preferred_size(100, 22); |  | ||||||
|     m_close_button->on_click = [this](auto) { |     m_close_button->on_click = [this](auto) { | ||||||
|         window()->close(); |         window()->close(); | ||||||
|     }; |     }; | ||||||
|  |  | ||||||
|  | @ -112,8 +112,7 @@ Tab::Tab(Type type) | ||||||
|     toolbar.add_action(*m_reload_action); |     toolbar.add_action(*m_reload_action); | ||||||
| 
 | 
 | ||||||
|     m_location_box = toolbar.add<GUI::TextBox>(); |     m_location_box = toolbar.add<GUI::TextBox>(); | ||||||
|     m_location_box->set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed); |     m_location_box->set_fixed_height(22); | ||||||
|     m_location_box->set_preferred_size(0, 22); |  | ||||||
|     m_location_box->set_placeholder("Address"); |     m_location_box->set_placeholder("Address"); | ||||||
| 
 | 
 | ||||||
|     m_location_box->on_return_pressed = [this] { |     m_location_box->on_return_pressed = [this] { | ||||||
|  | @ -130,8 +129,7 @@ Tab::Tab(Type type) | ||||||
|     m_bookmark_button = toolbar.add<GUI::Button>(); |     m_bookmark_button = toolbar.add<GUI::Button>(); | ||||||
|     m_bookmark_button->set_button_style(Gfx::ButtonStyle::CoolBar); |     m_bookmark_button->set_button_style(Gfx::ButtonStyle::CoolBar); | ||||||
|     m_bookmark_button->set_icon(Gfx::Bitmap::load_from_file("/res/icons/16x16/bookmark-contour.png")); |     m_bookmark_button->set_icon(Gfx::Bitmap::load_from_file("/res/icons/16x16/bookmark-contour.png")); | ||||||
|     m_bookmark_button->set_size_policy(GUI::SizePolicy::Fixed, GUI::SizePolicy::Fixed); |     m_bookmark_button->set_fixed_size(22, 22); | ||||||
|     m_bookmark_button->set_preferred_size(22, 22); |  | ||||||
| 
 | 
 | ||||||
|     m_bookmark_button->on_click = [this](auto) { |     m_bookmark_button->on_click = [this](auto) { | ||||||
|         auto url = this->url().to_string(); |         auto url = this->url().to_string(); | ||||||
|  |  | ||||||
|  | @ -59,55 +59,46 @@ AddEventDialog::AddEventDialog(Core::DateTime date_time, Window* parent_window) | ||||||
| 
 | 
 | ||||||
|     auto& top_container = widget.add<GUI::Widget>(); |     auto& top_container = widget.add<GUI::Widget>(); | ||||||
|     top_container.set_layout<GUI::VerticalBoxLayout>(); |     top_container.set_layout<GUI::VerticalBoxLayout>(); | ||||||
|     top_container.set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed); |     top_container.set_fixed_height(45); | ||||||
|     top_container.set_preferred_size(0, 45); |  | ||||||
|     top_container.layout()->set_margins({ 4, 4, 4, 4 }); |     top_container.layout()->set_margins({ 4, 4, 4, 4 }); | ||||||
| 
 | 
 | ||||||
|     auto& add_label = top_container.add<GUI::Label>("Add title & date:"); |     auto& add_label = top_container.add<GUI::Label>("Add title & date:"); | ||||||
|     add_label.set_text_alignment(Gfx::TextAlignment::CenterLeft); |     add_label.set_text_alignment(Gfx::TextAlignment::CenterLeft); | ||||||
|     add_label.set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed); |     add_label.set_fixed_height(14); | ||||||
|     add_label.set_preferred_size(0, 14); |  | ||||||
|     add_label.set_font(Gfx::Font::default_bold_font()); |     add_label.set_font(Gfx::Font::default_bold_font()); | ||||||
| 
 | 
 | ||||||
|     auto& event_title_textbox = top_container.add<GUI::TextBox>(); |     auto& event_title_textbox = top_container.add<GUI::TextBox>(); | ||||||
|     event_title_textbox.set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed); |     event_title_textbox.set_fixed_height(20); | ||||||
|     event_title_textbox.set_preferred_size(0, 20); |  | ||||||
| 
 | 
 | ||||||
|     auto& middle_container = widget.add<GUI::Widget>(); |     auto& middle_container = widget.add<GUI::Widget>(); | ||||||
|     middle_container.set_layout<GUI::HorizontalBoxLayout>(); |     middle_container.set_layout<GUI::HorizontalBoxLayout>(); | ||||||
|     middle_container.set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed); |     middle_container.set_fixed_height(25); | ||||||
|     middle_container.set_preferred_size(0, 25); |  | ||||||
|     middle_container.layout()->set_margins({ 4, 4, 4, 4 }); |     middle_container.layout()->set_margins({ 4, 4, 4, 4 }); | ||||||
| 
 | 
 | ||||||
|     auto& starting_month_combo = middle_container.add<GUI::ComboBox>(); |     auto& starting_month_combo = middle_container.add<GUI::ComboBox>(); | ||||||
|     starting_month_combo.set_only_allow_values_from_model(true); |     starting_month_combo.set_only_allow_values_from_model(true); | ||||||
|     starting_month_combo.set_size_policy(GUI::SizePolicy::Fixed, GUI::SizePolicy::Fixed); |     starting_month_combo.set_fixed_size(50, 20); | ||||||
|     starting_month_combo.set_preferred_size(50, 20); |  | ||||||
|     starting_month_combo.set_model(MonthListModel::create()); |     starting_month_combo.set_model(MonthListModel::create()); | ||||||
|     starting_month_combo.set_selected_index(m_date_time.month() - 1); |     starting_month_combo.set_selected_index(m_date_time.month() - 1); | ||||||
| 
 | 
 | ||||||
|     auto& starting_day_combo = middle_container.add<GUI::SpinBox>(); |     auto& starting_day_combo = middle_container.add<GUI::SpinBox>(); | ||||||
|     starting_day_combo.set_size_policy(GUI::SizePolicy::Fixed, GUI::SizePolicy::Fixed); |     starting_day_combo.set_fixed_size(40, 20); | ||||||
|     starting_day_combo.set_preferred_size(40, 20); |  | ||||||
|     starting_day_combo.set_value(m_date_time.day()); |     starting_day_combo.set_value(m_date_time.day()); | ||||||
|     starting_day_combo.set_min(1); |     starting_day_combo.set_min(1); | ||||||
| 
 | 
 | ||||||
|     auto& starting_year_combo = middle_container.add<GUI::SpinBox>(); |     auto& starting_year_combo = middle_container.add<GUI::SpinBox>(); | ||||||
|     starting_year_combo.set_size_policy(GUI::SizePolicy::Fixed, GUI::SizePolicy::Fixed); |     starting_year_combo.set_fixed_size(55, 20); | ||||||
|     starting_year_combo.set_preferred_size(55, 20); |  | ||||||
|     starting_year_combo.set_range(0, 9999); |     starting_year_combo.set_range(0, 9999); | ||||||
|     starting_year_combo.set_value(m_date_time.year()); |     starting_year_combo.set_value(m_date_time.year()); | ||||||
| 
 | 
 | ||||||
|     widget.layout()->add_spacer(); |     widget.layout()->add_spacer(); | ||||||
| 
 | 
 | ||||||
|     auto& button_container = widget.add<GUI::Widget>(); |     auto& button_container = widget.add<GUI::Widget>(); | ||||||
|     button_container.set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed); |     button_container.set_fixed_height(20); | ||||||
|     button_container.set_preferred_size(0, 20); |  | ||||||
|     button_container.set_layout<GUI::HorizontalBoxLayout>(); |     button_container.set_layout<GUI::HorizontalBoxLayout>(); | ||||||
|     button_container.layout()->add_spacer(); |     button_container.layout()->add_spacer(); | ||||||
|     auto& ok_button = button_container.add<GUI::Button>("OK"); |     auto& ok_button = button_container.add<GUI::Button>("OK"); | ||||||
|     ok_button.set_size_policy(GUI::SizePolicy::Fixed, GUI::SizePolicy::Fixed); |     ok_button.set_fixed_size(80, 20); | ||||||
|     ok_button.set_preferred_size(80, 20); |  | ||||||
|     ok_button.on_click = [this](auto) { |     ok_button.on_click = [this](auto) { | ||||||
|         dbgln("TODO: Add event icon on specific tile"); |         dbgln("TODO: Add event icon on specific tile"); | ||||||
|         done(Dialog::ExecOK); |         done(Dialog::ExecOK); | ||||||
|  |  | ||||||
|  | @ -134,8 +134,7 @@ int main(int argc, char** argv) | ||||||
| 
 | 
 | ||||||
|     toolbar.add_action(prev_date_action); |     toolbar.add_action(prev_date_action); | ||||||
|     selected_calendar_button = toolbar.add<GUI::Button>(calendar_widget.selected_calendar_text()); |     selected_calendar_button = toolbar.add<GUI::Button>(calendar_widget.selected_calendar_text()); | ||||||
|     selected_calendar_button->set_size_policy(GUI::SizePolicy::Fixed, GUI::SizePolicy::Fill); |     selected_calendar_button->set_fixed_width(70); | ||||||
|     selected_calendar_button->set_preferred_size(70, 0); |  | ||||||
|     selected_calendar_button->set_button_style(Gfx::ButtonStyle::CoolBar); |     selected_calendar_button->set_button_style(Gfx::ButtonStyle::CoolBar); | ||||||
|     selected_calendar_button->set_font(Gfx::Font::default_bold_fixed_width_font()); |     selected_calendar_button->set_font(Gfx::Font::default_bold_fixed_width_font()); | ||||||
|     selected_calendar_button->on_click = [&](auto) { |     selected_calendar_button->on_click = [&](auto) { | ||||||
|  |  | ||||||
|  | @ -6,8 +6,7 @@ | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     @GUI::Widget { |     @GUI::Widget { | ||||||
|         vertical_size_policy: "Fixed" |         fixed_height: 44 | ||||||
|         preferred_height: 44 |  | ||||||
| 
 | 
 | ||||||
|         layout: @GUI::HorizontalBoxLayout { |         layout: @GUI::HorizontalBoxLayout { | ||||||
|             spacing: 10 |             spacing: 10 | ||||||
|  | @ -24,8 +23,7 @@ | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     @GUI::Widget { |     @GUI::Widget { | ||||||
|         vertical_size_policy: "Fixed" |         fixed_height: 18 | ||||||
|         preferred_height: 18 |  | ||||||
| 
 | 
 | ||||||
|         layout: @GUI::HorizontalBoxLayout { |         layout: @GUI::HorizontalBoxLayout { | ||||||
|         } |         } | ||||||
|  | @ -33,8 +31,7 @@ | ||||||
|         @GUI::Label { |         @GUI::Label { | ||||||
|             text: "Executable path:" |             text: "Executable path:" | ||||||
|             text_alignment: "CenterLeft" |             text_alignment: "CenterLeft" | ||||||
|             horizontal_size_policy: "Fixed" |             fixed_width: 90 | ||||||
|             preferred_width: 90 |  | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|         @GUI::LinkLabel { |         @GUI::LinkLabel { | ||||||
|  | @ -44,8 +41,7 @@ | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     @GUI::Widget { |     @GUI::Widget { | ||||||
|         vertical_size_policy: "Fixed" |         fixed_height: 18 | ||||||
|         preferred_height: 18 |  | ||||||
| 
 | 
 | ||||||
|         layout: @GUI::HorizontalBoxLayout { |         layout: @GUI::HorizontalBoxLayout { | ||||||
|         } |         } | ||||||
|  | @ -53,8 +49,7 @@ | ||||||
|         @GUI::Label { |         @GUI::Label { | ||||||
|             text: "Coredump path:" |             text: "Coredump path:" | ||||||
|             text_alignment: "CenterLeft" |             text_alignment: "CenterLeft" | ||||||
|             horizontal_size_policy: "Fixed" |             fixed_width: 90 | ||||||
|             preferred_width: 90 |  | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|         @GUI::LinkLabel { |         @GUI::LinkLabel { | ||||||
|  | @ -64,8 +59,7 @@ | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     @GUI::Widget { |     @GUI::Widget { | ||||||
|         vertical_size_policy: "Fixed" |         fixed_height: 18 | ||||||
|         preferred_height: 18 |  | ||||||
| 
 | 
 | ||||||
|         layout: @GUI::HorizontalBoxLayout { |         layout: @GUI::HorizontalBoxLayout { | ||||||
|         } |         } | ||||||
|  | @ -82,27 +76,20 @@ | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     @GUI::Widget { |     @GUI::Widget { | ||||||
|         vertical_size_policy: "Fixed" |         fixed_height: 32 | ||||||
|         preferred_height: 32 |  | ||||||
| 
 | 
 | ||||||
|         layout: @GUI::HorizontalBoxLayout { |         layout: @GUI::HorizontalBoxLayout { | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|         // HACK: We need something like Layout::add_spacer() in GML! :^) |         // HACK: We need something like Layout::add_spacer() in GML! :^) | ||||||
|         @GUI::Widget { |         @GUI::Widget { | ||||||
|             horizontal_size_policy: "Fixed" |  | ||||||
|             vertical_size_policy: "Fill" |  | ||||||
|             preferred_width: 377 |  | ||||||
|             preferred_height: 0 |  | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|         @GUI::Button { |         @GUI::Button { | ||||||
|             name: "close_button" |             name: "close_button" | ||||||
|             text: "Close" |             text: "Close" | ||||||
|             horizontal_size_policy: "Fixed" |             fixed_width: 70 | ||||||
|             vertical_size_policy: "Fixed" |             fixed_height: 22 | ||||||
|             preferred_width: 70 |  | ||||||
|             preferred_height: 22 |  | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
| } | } | ||||||
|  |  | ||||||
|  | @ -101,26 +101,22 @@ void DisplaySettingsWidget::create_frame() | ||||||
|     /// Wallpaper Preview /////////////////////////////////////////////////////////////////////////
 |     /// Wallpaper Preview /////////////////////////////////////////////////////////////////////////
 | ||||||
| 
 | 
 | ||||||
|     m_monitor_widget = settings_content.add<MonitorWidget>(); |     m_monitor_widget = settings_content.add<MonitorWidget>(); | ||||||
|     m_monitor_widget->set_size_policy(GUI::SizePolicy::Fixed, GUI::SizePolicy::Fixed); |     m_monitor_widget->set_fixed_size(338, 248); | ||||||
|     m_monitor_widget->set_preferred_size(338, 248); |  | ||||||
| 
 | 
 | ||||||
|     /// Wallpaper Row /////////////////////////////////////////////////////////////////////////////
 |     /// Wallpaper Row /////////////////////////////////////////////////////////////////////////////
 | ||||||
| 
 | 
 | ||||||
|     auto& wallpaper_selection_container = settings_content.add<GUI::Widget>(); |     auto& wallpaper_selection_container = settings_content.add<GUI::Widget>(); | ||||||
|     wallpaper_selection_container.set_layout<GUI::HorizontalBoxLayout>(); |     wallpaper_selection_container.set_layout<GUI::HorizontalBoxLayout>(); | ||||||
|     wallpaper_selection_container.layout()->set_margins({ 0, 4, 0, 0 }); |     wallpaper_selection_container.layout()->set_margins({ 0, 4, 0, 0 }); | ||||||
|     wallpaper_selection_container.set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed); |     wallpaper_selection_container.set_fixed_height(22); | ||||||
|     wallpaper_selection_container.set_preferred_size(0, 22); |  | ||||||
| 
 | 
 | ||||||
|     auto& wallpaper_label = wallpaper_selection_container.add<GUI::Label>(); |     auto& wallpaper_label = wallpaper_selection_container.add<GUI::Label>(); | ||||||
|     wallpaper_label.set_text_alignment(Gfx::TextAlignment::CenterLeft); |     wallpaper_label.set_text_alignment(Gfx::TextAlignment::CenterLeft); | ||||||
|     wallpaper_label.set_size_policy(GUI::SizePolicy::Fixed, GUI::SizePolicy::Fill); |     wallpaper_label.set_fixed_width(70); | ||||||
|     wallpaper_label.set_preferred_size({ 70, 0 }); |  | ||||||
|     wallpaper_label.set_text("Wallpaper:"); |     wallpaper_label.set_text("Wallpaper:"); | ||||||
| 
 | 
 | ||||||
|     m_wallpaper_combo = wallpaper_selection_container.add<GUI::ComboBox>(); |     m_wallpaper_combo = wallpaper_selection_container.add<GUI::ComboBox>(); | ||||||
|     m_wallpaper_combo->set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed); |     m_wallpaper_combo->set_fixed_height(22); | ||||||
|     m_wallpaper_combo->set_preferred_size(0, 22); |  | ||||||
|     m_wallpaper_combo->set_only_allow_values_from_model(true); |     m_wallpaper_combo->set_only_allow_values_from_model(true); | ||||||
|     m_wallpaper_combo->set_model(*GUI::ItemListModel<AK::String>::create(m_wallpapers)); |     m_wallpaper_combo->set_model(*GUI::ItemListModel<AK::String>::create(m_wallpapers)); | ||||||
|     m_wallpaper_combo->on_change = [this](auto& text, const GUI::ModelIndex& index) { |     m_wallpaper_combo->on_change = [this](auto& text, const GUI::ModelIndex& index) { | ||||||
|  | @ -149,8 +145,7 @@ void DisplaySettingsWidget::create_frame() | ||||||
|     button.set_tooltip("Select Wallpaper from file system."); |     button.set_tooltip("Select Wallpaper from file system."); | ||||||
|     button.set_icon(Gfx::Bitmap::load_from_file("/res/icons/16x16/open.png")); |     button.set_icon(Gfx::Bitmap::load_from_file("/res/icons/16x16/open.png")); | ||||||
|     button.set_button_style(Gfx::ButtonStyle::CoolBar); |     button.set_button_style(Gfx::ButtonStyle::CoolBar); | ||||||
|     button.set_size_policy(GUI::SizePolicy::Fixed, GUI::SizePolicy::Fixed); |     button.set_fixed_size(22, 22); | ||||||
|     button.set_preferred_size(22, 22); |  | ||||||
|     button.on_click = [this](auto) { |     button.on_click = [this](auto) { | ||||||
|         Optional<String> open_path = GUI::FilePicker::get_open_filepath(root_widget()->window(), "Select wallpaper from file system."); |         Optional<String> open_path = GUI::FilePicker::get_open_filepath(root_widget()->window(), "Select wallpaper from file system."); | ||||||
| 
 | 
 | ||||||
|  | @ -167,18 +162,15 @@ void DisplaySettingsWidget::create_frame() | ||||||
|     auto& mode_selection_container = settings_content.add<GUI::Widget>(); |     auto& mode_selection_container = settings_content.add<GUI::Widget>(); | ||||||
|     mode_selection_container.set_layout<GUI::HorizontalBoxLayout>(); |     mode_selection_container.set_layout<GUI::HorizontalBoxLayout>(); | ||||||
|     mode_selection_container.layout()->set_margins({ 0, 4, 0, 0 }); |     mode_selection_container.layout()->set_margins({ 0, 4, 0, 0 }); | ||||||
|     mode_selection_container.set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed); |     mode_selection_container.set_fixed_height(22); | ||||||
|     mode_selection_container.set_preferred_size(0, 22); |  | ||||||
| 
 | 
 | ||||||
|     auto& mode_label = mode_selection_container.add<GUI::Label>(); |     auto& mode_label = mode_selection_container.add<GUI::Label>(); | ||||||
|     mode_label.set_text_alignment(Gfx::TextAlignment::CenterLeft); |     mode_label.set_text_alignment(Gfx::TextAlignment::CenterLeft); | ||||||
|     mode_label.set_size_policy(GUI::SizePolicy::Fixed, GUI::SizePolicy::Fill); |     mode_label.set_fixed_width(70); | ||||||
|     mode_label.set_preferred_size({ 70, 0 }); |  | ||||||
|     mode_label.set_text("Mode:"); |     mode_label.set_text("Mode:"); | ||||||
| 
 | 
 | ||||||
|     m_mode_combo = mode_selection_container.add<GUI::ComboBox>(); |     m_mode_combo = mode_selection_container.add<GUI::ComboBox>(); | ||||||
|     m_mode_combo->set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed); |     m_mode_combo->set_fixed_height(22); | ||||||
|     m_mode_combo->set_preferred_size(0, 22); |  | ||||||
|     m_mode_combo->set_only_allow_values_from_model(true); |     m_mode_combo->set_only_allow_values_from_model(true); | ||||||
|     m_mode_combo->set_model(*GUI::ItemListModel<AK::String>::create(m_modes)); |     m_mode_combo->set_model(*GUI::ItemListModel<AK::String>::create(m_modes)); | ||||||
|     m_mode_combo->on_change = [this](auto&, const GUI::ModelIndex& index) { |     m_mode_combo->on_change = [this](auto&, const GUI::ModelIndex& index) { | ||||||
|  | @ -190,18 +182,15 @@ void DisplaySettingsWidget::create_frame() | ||||||
| 
 | 
 | ||||||
|     auto& resolution_selection_container = settings_content.add<GUI::Widget>(); |     auto& resolution_selection_container = settings_content.add<GUI::Widget>(); | ||||||
|     resolution_selection_container.set_layout<GUI::HorizontalBoxLayout>(); |     resolution_selection_container.set_layout<GUI::HorizontalBoxLayout>(); | ||||||
|     resolution_selection_container.set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed); |     resolution_selection_container.set_fixed_height(22); | ||||||
|     resolution_selection_container.set_preferred_size(0, 22); |  | ||||||
| 
 | 
 | ||||||
|     auto& m_resolution_label = resolution_selection_container.add<GUI::Label>(); |     auto& m_resolution_label = resolution_selection_container.add<GUI::Label>(); | ||||||
|     m_resolution_label.set_text_alignment(Gfx::TextAlignment::CenterLeft); |     m_resolution_label.set_text_alignment(Gfx::TextAlignment::CenterLeft); | ||||||
|     m_resolution_label.set_size_policy(GUI::SizePolicy::Fixed, GUI::SizePolicy::Fill); |     m_resolution_label.set_fixed_width(70); | ||||||
|     m_resolution_label.set_preferred_size({ 70, 0 }); |  | ||||||
|     m_resolution_label.set_text("Resolution:"); |     m_resolution_label.set_text("Resolution:"); | ||||||
| 
 | 
 | ||||||
|     m_resolution_combo = resolution_selection_container.add<GUI::ComboBox>(); |     m_resolution_combo = resolution_selection_container.add<GUI::ComboBox>(); | ||||||
|     m_resolution_combo->set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed); |     m_resolution_combo->set_fixed_height(22); | ||||||
|     m_resolution_combo->set_preferred_size(0, 22); |  | ||||||
|     m_resolution_combo->set_only_allow_values_from_model(true); |     m_resolution_combo->set_only_allow_values_from_model(true); | ||||||
|     m_resolution_combo->set_model(*GUI::ItemListModel<Gfx::IntSize>::create(m_resolutions)); |     m_resolution_combo->set_model(*GUI::ItemListModel<Gfx::IntSize>::create(m_resolutions)); | ||||||
|     m_resolution_combo->on_change = [this](auto&, const GUI::ModelIndex& index) { |     m_resolution_combo->on_change = [this](auto&, const GUI::ModelIndex& index) { | ||||||
|  | @ -213,19 +202,16 @@ void DisplaySettingsWidget::create_frame() | ||||||
| 
 | 
 | ||||||
|     auto& color_selection_container = settings_content.add<GUI::Widget>(); |     auto& color_selection_container = settings_content.add<GUI::Widget>(); | ||||||
|     color_selection_container.set_layout<GUI::HorizontalBoxLayout>(); |     color_selection_container.set_layout<GUI::HorizontalBoxLayout>(); | ||||||
|     color_selection_container.set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed); |     color_selection_container.set_fixed_height(22); | ||||||
|     color_selection_container.set_preferred_size(0, 22); |  | ||||||
| 
 | 
 | ||||||
|     auto& color_label = color_selection_container.add<GUI::Label>(); |     auto& color_label = color_selection_container.add<GUI::Label>(); | ||||||
|     color_label.set_text_alignment(Gfx::TextAlignment::CenterLeft); |     color_label.set_text_alignment(Gfx::TextAlignment::CenterLeft); | ||||||
|     color_label.set_size_policy(GUI::SizePolicy::Fixed, GUI::SizePolicy::Fill); |     color_label.set_fixed_width(70); | ||||||
|     color_label.set_preferred_size({ 70, 0 }); |  | ||||||
|     color_label.set_text("Color:"); |     color_label.set_text("Color:"); | ||||||
| 
 | 
 | ||||||
|     m_color_input = color_selection_container.add<GUI::ColorInput>(); |     m_color_input = color_selection_container.add<GUI::ColorInput>(); | ||||||
|     m_color_input->set_color_has_alpha_channel(false); |     m_color_input->set_color_has_alpha_channel(false); | ||||||
|     m_color_input->set_size_policy(GUI::SizePolicy::Fixed, GUI::SizePolicy::Fill); |     m_color_input->set_fixed_width(90); | ||||||
|     m_color_input->set_preferred_size(90, 0); |  | ||||||
|     m_color_input->set_color_picker_title("Select color for desktop"); |     m_color_input->set_color_picker_title("Select color for desktop"); | ||||||
|     m_color_input->on_change = [this] { |     m_color_input->on_change = [this] { | ||||||
|         m_monitor_widget->set_background_color(m_color_input->color()); |         m_monitor_widget->set_background_color(m_color_input->color()); | ||||||
|  | @ -237,14 +223,11 @@ void DisplaySettingsWidget::create_frame() | ||||||
|     auto& bottom_widget = settings_content.add<GUI::Widget>(); |     auto& bottom_widget = settings_content.add<GUI::Widget>(); | ||||||
|     bottom_widget.set_layout<GUI::HorizontalBoxLayout>(); |     bottom_widget.set_layout<GUI::HorizontalBoxLayout>(); | ||||||
|     bottom_widget.layout()->add_spacer(); |     bottom_widget.layout()->add_spacer(); | ||||||
|     //bottom_widget.layout()->set_margins({ 4, 10, 4, 10 });
 |     bottom_widget.set_fixed_height(22); | ||||||
|     bottom_widget.set_size_policy(Orientation::Vertical, GUI::SizePolicy::Fixed); |  | ||||||
|     bottom_widget.set_preferred_size(1, 22); |  | ||||||
| 
 | 
 | ||||||
|     auto& ok_button = bottom_widget.add<GUI::Button>(); |     auto& ok_button = bottom_widget.add<GUI::Button>(); | ||||||
|     ok_button.set_text("OK"); |     ok_button.set_text("OK"); | ||||||
|     ok_button.set_size_policy(Orientation::Horizontal, GUI::SizePolicy::Fixed); |     ok_button.set_fixed_size(60, 22); | ||||||
|     ok_button.set_preferred_size(60, 22); |  | ||||||
|     ok_button.on_click = [this](auto) { |     ok_button.on_click = [this](auto) { | ||||||
|         send_settings_to_window_server(); |         send_settings_to_window_server(); | ||||||
|         GUI::Application::the()->quit(); |         GUI::Application::the()->quit(); | ||||||
|  | @ -252,16 +235,14 @@ void DisplaySettingsWidget::create_frame() | ||||||
| 
 | 
 | ||||||
|     auto& cancel_button = bottom_widget.add<GUI::Button>(); |     auto& cancel_button = bottom_widget.add<GUI::Button>(); | ||||||
|     cancel_button.set_text("Cancel"); |     cancel_button.set_text("Cancel"); | ||||||
|     cancel_button.set_size_policy(Orientation::Horizontal, GUI::SizePolicy::Fixed); |     cancel_button.set_fixed_size(60, 22); | ||||||
|     cancel_button.set_preferred_size(60, 22); |  | ||||||
|     cancel_button.on_click = [](auto) { |     cancel_button.on_click = [](auto) { | ||||||
|         GUI::Application::the()->quit(); |         GUI::Application::the()->quit(); | ||||||
|     }; |     }; | ||||||
| 
 | 
 | ||||||
|     auto& apply_button = bottom_widget.add<GUI::Button>(); |     auto& apply_button = bottom_widget.add<GUI::Button>(); | ||||||
|     apply_button.set_text("Apply"); |     apply_button.set_text("Apply"); | ||||||
|     apply_button.set_size_policy(Orientation::Horizontal, GUI::SizePolicy::Fixed); |     apply_button.set_fixed_size(60, 22); | ||||||
|     apply_button.set_preferred_size(60, 22); |  | ||||||
|     apply_button.on_click = [this](auto) { |     apply_button.on_click = [this](auto) { | ||||||
|         send_settings_to_window_server(); |         send_settings_to_window_server(); | ||||||
|     }; |     }; | ||||||
|  |  | ||||||
|  | @ -19,8 +19,7 @@ | ||||||
| 
 | 
 | ||||||
|             @GUI::TextBox { |             @GUI::TextBox { | ||||||
|                 name: "location_textbox" |                 name: "location_textbox" | ||||||
|                 vertical_size_policy: "Fixed" |                 fixed_height: 22 | ||||||
|                 preferred_height: 22 |  | ||||||
|             } |             } | ||||||
|         } |         } | ||||||
|         @GUI::ToolBar { |         @GUI::ToolBar { | ||||||
|  | @ -37,8 +36,7 @@ | ||||||
| 
 | 
 | ||||||
|         @GUI::TreeView { |         @GUI::TreeView { | ||||||
|             name: "tree_view" |             name: "tree_view" | ||||||
|             horizontal_size_policy: "Fixed" |             fixed_width: 175 | ||||||
|             preferred_width: 175 |  | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  | @ -63,25 +63,20 @@ PropertiesDialog::PropertiesDialog(const String& path, bool disable_rename, Wind | ||||||
|     general_tab.layout()->set_margins({ 12, 8, 12, 8 }); |     general_tab.layout()->set_margins({ 12, 8, 12, 8 }); | ||||||
|     general_tab.layout()->set_spacing(10); |     general_tab.layout()->set_spacing(10); | ||||||
| 
 | 
 | ||||||
|     general_tab.layout()->add_spacer(); |  | ||||||
| 
 |  | ||||||
|     auto& file_container = general_tab.add<GUI::Widget>(); |     auto& file_container = general_tab.add<GUI::Widget>(); | ||||||
|     file_container.set_layout<GUI::HorizontalBoxLayout>(); |     file_container.set_layout<GUI::HorizontalBoxLayout>(); | ||||||
|     file_container.set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed); |  | ||||||
|     file_container.layout()->set_spacing(20); |     file_container.layout()->set_spacing(20); | ||||||
|     file_container.set_preferred_size(0, 34); |     file_container.set_fixed_height(34); | ||||||
| 
 | 
 | ||||||
|     m_icon = file_container.add<GUI::ImageWidget>(); |     m_icon = file_container.add<GUI::ImageWidget>(); | ||||||
|     m_icon->set_size_policy(GUI::SizePolicy::Fixed, GUI::SizePolicy::Fixed); |     m_icon->set_fixed_size(32, 32); | ||||||
|     m_icon->set_preferred_size(32, 32); |  | ||||||
| 
 | 
 | ||||||
|     m_name = lexical_path.basename(); |     m_name = lexical_path.basename(); | ||||||
|     m_path = lexical_path.string(); |     m_path = lexical_path.string(); | ||||||
|     m_parent_path = lexical_path.dirname(); |     m_parent_path = lexical_path.dirname(); | ||||||
| 
 | 
 | ||||||
|     m_name_box = file_container.add<GUI::TextBox>(); |     m_name_box = file_container.add<GUI::TextBox>(); | ||||||
|     m_name_box->set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed); |     m_name_box->set_fixed_height(22); | ||||||
|     m_name_box->set_preferred_size({ 0, 22 }); |  | ||||||
|     m_name_box->set_text(m_name); |     m_name_box->set_text(m_name); | ||||||
|     m_name_box->set_mode(disable_rename ? GUI::TextBox::Mode::DisplayOnly : GUI::TextBox::Mode::Editable); |     m_name_box->set_mode(disable_rename ? GUI::TextBox::Mode::DisplayOnly : GUI::TextBox::Mode::Editable); | ||||||
|     m_name_box->on_change = [&]() { |     m_name_box->on_change = [&]() { | ||||||
|  | @ -151,8 +146,7 @@ PropertiesDialog::PropertiesDialog(const String& path, bool disable_rename, Wind | ||||||
| 
 | 
 | ||||||
|     auto& button_widget = main_widget.add<GUI::Widget>(); |     auto& button_widget = main_widget.add<GUI::Widget>(); | ||||||
|     button_widget.set_layout<GUI::HorizontalBoxLayout>(); |     button_widget.set_layout<GUI::HorizontalBoxLayout>(); | ||||||
|     button_widget.set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed); |     button_widget.set_fixed_height(24); | ||||||
|     button_widget.set_preferred_size(0, 24); |  | ||||||
|     button_widget.layout()->set_spacing(5); |     button_widget.layout()->set_spacing(5); | ||||||
| 
 | 
 | ||||||
|     button_widget.layout()->add_spacer(); |     button_widget.layout()->add_spacer(); | ||||||
|  | @ -237,8 +231,7 @@ void PropertiesDialog::make_permission_checkboxes(GUI::Widget& parent, Permissio | ||||||
| { | { | ||||||
|     auto& widget = parent.add<GUI::Widget>(); |     auto& widget = parent.add<GUI::Widget>(); | ||||||
|     widget.set_layout<GUI::HorizontalBoxLayout>(); |     widget.set_layout<GUI::HorizontalBoxLayout>(); | ||||||
|     widget.set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed); |     widget.set_fixed_height(16); | ||||||
|     widget.set_preferred_size(0, 16); |  | ||||||
|     widget.layout()->set_spacing(10); |     widget.layout()->set_spacing(10); | ||||||
| 
 | 
 | ||||||
|     auto& label = widget.add<GUI::Label>(label_string); |     auto& label = widget.add<GUI::Label>(label_string); | ||||||
|  | @ -277,13 +270,11 @@ void PropertiesDialog::make_property_value_pairs(const Vector<PropertyValuePair> | ||||||
|     for (auto pair : pairs) { |     for (auto pair : pairs) { | ||||||
|         auto& label_container = parent.add<GUI::Widget>(); |         auto& label_container = parent.add<GUI::Widget>(); | ||||||
|         label_container.set_layout<GUI::HorizontalBoxLayout>(); |         label_container.set_layout<GUI::HorizontalBoxLayout>(); | ||||||
|         label_container.set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed); |         label_container.set_fixed_height(14); | ||||||
|         label_container.set_preferred_size(0, 14); |  | ||||||
|         label_container.layout()->set_spacing(12); |         label_container.layout()->set_spacing(12); | ||||||
| 
 | 
 | ||||||
|         auto& label_property = label_container.add<GUI::Label>(pair.property); |         auto& label_property = label_container.add<GUI::Label>(pair.property); | ||||||
|         label_property.set_text_alignment(Gfx::TextAlignment::CenterLeft); |         label_property.set_text_alignment(Gfx::TextAlignment::CenterLeft); | ||||||
|         label_property.set_size_policy(GUI::SizePolicy::Fixed, GUI::SizePolicy::Fill); |  | ||||||
| 
 | 
 | ||||||
|         if (!pair.link.has_value()) { |         if (!pair.link.has_value()) { | ||||||
|             label_container.add<GUI::Label>(pair.value).set_text_alignment(Gfx::TextAlignment::CenterLeft); |             label_container.add<GUI::Label>(pair.value).set_text_alignment(Gfx::TextAlignment::CenterLeft); | ||||||
|  | @ -300,24 +291,18 @@ void PropertiesDialog::make_property_value_pairs(const Vector<PropertyValuePair> | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     for (auto label : property_labels) |     for (auto label : property_labels) | ||||||
|         label->set_preferred_size({ max_width, 0 }); |         label->set_fixed_width(max_width); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| GUI::Button& PropertiesDialog::make_button(String text, GUI::Widget& parent) | GUI::Button& PropertiesDialog::make_button(String text, GUI::Widget& parent) | ||||||
| { | { | ||||||
|     auto& button = parent.add<GUI::Button>(text); |     auto& button = parent.add<GUI::Button>(text); | ||||||
|     button.set_size_policy(GUI::SizePolicy::Fixed, GUI::SizePolicy::Fixed); |     button.set_fixed_size(70, 22); | ||||||
|     button.set_preferred_size(70, 22); |  | ||||||
|     return button; |     return button; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void PropertiesDialog::make_divider(GUI::Widget& parent) | void PropertiesDialog::make_divider(GUI::Widget& parent) | ||||||
| { | { | ||||||
|     parent.layout()->add_spacer(); |  | ||||||
| 
 |  | ||||||
|     auto& divider = parent.add<GUI::Frame>(); |     auto& divider = parent.add<GUI::Frame>(); | ||||||
|     divider.set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed); |     divider.set_fixed_height(2); | ||||||
|     divider.set_preferred_size({ 0, 2 }); |  | ||||||
| 
 |  | ||||||
|     parent.layout()->add_spacer(); |  | ||||||
| } | } | ||||||
|  |  | ||||||
|  | @ -54,38 +54,32 @@ FontEditorWidget::FontEditorWidget(const String& path, RefPtr<Gfx::Font>&& edite | ||||||
|     main_container.set_layout<GUI::HorizontalBoxLayout>(); |     main_container.set_layout<GUI::HorizontalBoxLayout>(); | ||||||
|     main_container.layout()->set_margins({ 4, 4, 4, 4 }); |     main_container.layout()->set_margins({ 4, 4, 4, 4 }); | ||||||
|     main_container.set_background_role(Gfx::ColorRole::SyntaxKeyword); |     main_container.set_background_role(Gfx::ColorRole::SyntaxKeyword); | ||||||
|     main_container.set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fill); |  | ||||||
| 
 | 
 | ||||||
|     // Top-Left Glyph Editor and info
 |     // Top-Left Glyph Editor and info
 | ||||||
|     auto& editor_container = main_container.add<GUI::Widget>(); |     auto& editor_container = main_container.add<GUI::Widget>(); | ||||||
|     editor_container.set_layout<GUI::VerticalBoxLayout>(); |     editor_container.set_layout<GUI::VerticalBoxLayout>(); | ||||||
|     editor_container.layout()->set_margins({ 4, 4, 4, 4 }); |     editor_container.layout()->set_margins({ 4, 4, 4, 4 }); | ||||||
|     editor_container.set_background_role(Gfx::ColorRole::SyntaxKeyword); |     editor_container.set_background_role(Gfx::ColorRole::SyntaxKeyword); | ||||||
|     editor_container.set_size_policy(GUI::SizePolicy::Fixed, GUI::SizePolicy::Fill); |  | ||||||
| 
 | 
 | ||||||
|     m_glyph_editor_widget = editor_container.add<GlyphEditorWidget>(*m_edited_font); |     m_glyph_editor_widget = editor_container.add<GlyphEditorWidget>(*m_edited_font); | ||||||
|     m_glyph_editor_widget->set_size_policy(GUI::SizePolicy::Fixed, GUI::SizePolicy::Fixed); |     m_glyph_editor_widget->set_fixed_size(m_glyph_editor_widget->preferred_width(), m_glyph_editor_widget->preferred_height()); | ||||||
|     m_glyph_editor_widget->set_preferred_size(m_glyph_editor_widget->preferred_width(), m_glyph_editor_widget->preferred_height()); |  | ||||||
| 
 | 
 | ||||||
|     editor_container.set_preferred_size(m_glyph_editor_widget->preferred_width(), 0); |     editor_container.set_fixed_width(m_glyph_editor_widget->preferred_width()); | ||||||
| 
 | 
 | ||||||
|     auto& glyph_width_label = editor_container.add<GUI::Label>(); |     auto& glyph_width_label = editor_container.add<GUI::Label>(); | ||||||
|     glyph_width_label.set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed); |     glyph_width_label.set_fixed_height(22); | ||||||
|     glyph_width_label.set_preferred_size(0, 22); |  | ||||||
|     glyph_width_label.set_text_alignment(Gfx::TextAlignment::CenterLeft); |     glyph_width_label.set_text_alignment(Gfx::TextAlignment::CenterLeft); | ||||||
|     glyph_width_label.set_text("Glyph width:"); |     glyph_width_label.set_text("Glyph width:"); | ||||||
| 
 | 
 | ||||||
|     auto& glyph_width_spinbox = editor_container.add<GUI::SpinBox>(); |     auto& glyph_width_spinbox = editor_container.add<GUI::SpinBox>(); | ||||||
|     glyph_width_spinbox.set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed); |     glyph_width_spinbox.set_fixed_height(22); | ||||||
|     glyph_width_spinbox.set_preferred_size(0, 22); |  | ||||||
|     glyph_width_spinbox.set_min(0); |     glyph_width_spinbox.set_min(0); | ||||||
|     glyph_width_spinbox.set_max(32); |     glyph_width_spinbox.set_max(32); | ||||||
|     glyph_width_spinbox.set_value(0); |     glyph_width_spinbox.set_value(0); | ||||||
|     glyph_width_spinbox.set_enabled(!m_edited_font->is_fixed_width()); |     glyph_width_spinbox.set_enabled(!m_edited_font->is_fixed_width()); | ||||||
| 
 | 
 | ||||||
|     auto& info_label = editor_container.add<GUI::Label>(); |     auto& info_label = editor_container.add<GUI::Label>(); | ||||||
|     info_label.set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed); |     info_label.set_fixed_height(22); | ||||||
|     info_label.set_preferred_size(0, 22); |  | ||||||
|     info_label.set_text_alignment(Gfx::TextAlignment::CenterLeft); |     info_label.set_text_alignment(Gfx::TextAlignment::CenterLeft); | ||||||
|     info_label.set_text("info_label"); |     info_label.set_text("info_label"); | ||||||
| 
 | 
 | ||||||
|  | @ -94,50 +88,41 @@ FontEditorWidget::FontEditorWidget(const String& path, RefPtr<Gfx::Font>&& edite | ||||||
|     auto& map_and_test_container = main_container.add<GUI::Widget>(); |     auto& map_and_test_container = main_container.add<GUI::Widget>(); | ||||||
|     map_and_test_container.set_layout<GUI::VerticalBoxLayout>(); |     map_and_test_container.set_layout<GUI::VerticalBoxLayout>(); | ||||||
|     map_and_test_container.layout()->set_margins({ 4, 4, 4, 4 }); |     map_and_test_container.layout()->set_margins({ 4, 4, 4, 4 }); | ||||||
|     map_and_test_container.set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fill); |  | ||||||
| 
 | 
 | ||||||
|     m_glyph_map_widget = map_and_test_container.add<GlyphMapWidget>(*m_edited_font); |     m_glyph_map_widget = map_and_test_container.add<GlyphMapWidget>(*m_edited_font); | ||||||
|     m_glyph_map_widget->set_size_policy(GUI::SizePolicy::Fixed, GUI::SizePolicy::Fixed); |     m_glyph_map_widget->set_fixed_size(m_glyph_map_widget->preferred_width(), m_glyph_map_widget->preferred_height()); | ||||||
|     m_glyph_map_widget->set_preferred_size(m_glyph_map_widget->preferred_width(), m_glyph_map_widget->preferred_height()); |  | ||||||
| 
 | 
 | ||||||
|     auto& font_mtest_group_box = map_and_test_container.add<GUI::GroupBox>(); |     auto& font_mtest_group_box = map_and_test_container.add<GUI::GroupBox>(); | ||||||
|     font_mtest_group_box.set_layout<GUI::VerticalBoxLayout>(); |     font_mtest_group_box.set_layout<GUI::VerticalBoxLayout>(); | ||||||
|     font_mtest_group_box.layout()->set_margins({ 5, 15, 5, 5 }); |     font_mtest_group_box.layout()->set_margins({ 5, 15, 5, 5 }); | ||||||
|     font_mtest_group_box.set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed); |     font_mtest_group_box.set_fixed_height(2 * m_edited_font->glyph_height() + 50); | ||||||
|     font_mtest_group_box.set_preferred_size(0, 2 * m_edited_font->glyph_height() + 50); |  | ||||||
|     font_mtest_group_box.set_title("Test"); |     font_mtest_group_box.set_title("Test"); | ||||||
| 
 | 
 | ||||||
|     auto& demo_label_1 = font_mtest_group_box.add<GUI::Label>(); |     auto& demo_label_1 = font_mtest_group_box.add<GUI::Label>(); | ||||||
|     demo_label_1.set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fill); |  | ||||||
|     demo_label_1.set_font(m_edited_font); |     demo_label_1.set_font(m_edited_font); | ||||||
|     demo_label_1.set_text("quick fox jumps nightly above wizard."); |     demo_label_1.set_text("quick fox jumps nightly above wizard."); | ||||||
| 
 | 
 | ||||||
|     auto& demo_label_2 = font_mtest_group_box.add<GUI::Label>(); |     auto& demo_label_2 = font_mtest_group_box.add<GUI::Label>(); | ||||||
|     demo_label_2.set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fill); |  | ||||||
|     demo_label_2.set_font(m_edited_font); |     demo_label_2.set_font(m_edited_font); | ||||||
|     demo_label_2.set_text("QUICK FOX JUMPS NIGHTLY ABOVE WIZARD!"); |     demo_label_2.set_text("QUICK FOX JUMPS NIGHTLY ABOVE WIZARD!"); | ||||||
| 
 | 
 | ||||||
|     auto& font_metadata_group_box = map_and_test_container.add<GUI::GroupBox>(); |     auto& font_metadata_group_box = map_and_test_container.add<GUI::GroupBox>(); | ||||||
|     font_metadata_group_box.set_layout<GUI::VerticalBoxLayout>(); |     font_metadata_group_box.set_layout<GUI::VerticalBoxLayout>(); | ||||||
|     font_metadata_group_box.layout()->set_margins({ 5, 15, 5, 5 }); |     font_metadata_group_box.layout()->set_margins({ 5, 15, 5, 5 }); | ||||||
|     font_metadata_group_box.set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed); |     font_metadata_group_box.set_fixed_height(275); | ||||||
|     font_metadata_group_box.set_preferred_size(0, 275); |  | ||||||
|     font_metadata_group_box.set_title("Font metadata"); |     font_metadata_group_box.set_title("Font metadata"); | ||||||
| 
 | 
 | ||||||
|     //// Name Row
 |     //// Name Row
 | ||||||
|     auto& namecontainer = font_metadata_group_box.add<GUI::Widget>(); |     auto& namecontainer = font_metadata_group_box.add<GUI::Widget>(); | ||||||
|     namecontainer.set_layout<GUI::HorizontalBoxLayout>(); |     namecontainer.set_layout<GUI::HorizontalBoxLayout>(); | ||||||
|     namecontainer.set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed); |     namecontainer.set_fixed_height(22); | ||||||
|     namecontainer.set_preferred_size(0, 22); |  | ||||||
| 
 | 
 | ||||||
|     auto& name_label = namecontainer.add<GUI::Label>(); |     auto& name_label = namecontainer.add<GUI::Label>(); | ||||||
|     name_label.set_size_policy(GUI::SizePolicy::Fixed, GUI::SizePolicy::Fill); |     name_label.set_fixed_width(100); | ||||||
|     name_label.set_preferred_size(100, 0); |  | ||||||
|     name_label.set_text_alignment(Gfx::TextAlignment::CenterLeft); |     name_label.set_text_alignment(Gfx::TextAlignment::CenterLeft); | ||||||
|     name_label.set_text("Name:"); |     name_label.set_text("Name:"); | ||||||
| 
 | 
 | ||||||
|     auto& name_textbox = namecontainer.add<GUI::TextBox>(); |     auto& name_textbox = namecontainer.add<GUI::TextBox>(); | ||||||
|     name_textbox.set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fill); |  | ||||||
|     name_textbox.set_text(m_edited_font->name()); |     name_textbox.set_text(m_edited_font->name()); | ||||||
|     name_textbox.on_change = [&] { |     name_textbox.on_change = [&] { | ||||||
|         m_edited_font->set_name(name_textbox.text()); |         m_edited_font->set_name(name_textbox.text()); | ||||||
|  | @ -146,17 +131,14 @@ FontEditorWidget::FontEditorWidget(const String& path, RefPtr<Gfx::Font>&& edite | ||||||
|     //// Family Row
 |     //// Family Row
 | ||||||
|     auto& family_container = font_metadata_group_box.add<GUI::Widget>(); |     auto& family_container = font_metadata_group_box.add<GUI::Widget>(); | ||||||
|     family_container.set_layout<GUI::HorizontalBoxLayout>(); |     family_container.set_layout<GUI::HorizontalBoxLayout>(); | ||||||
|     family_container.set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed); |     family_container.set_fixed_height(22); | ||||||
|     family_container.set_preferred_size(0, 22); |  | ||||||
| 
 | 
 | ||||||
|     auto& family_label = family_container.add<GUI::Label>(); |     auto& family_label = family_container.add<GUI::Label>(); | ||||||
|     family_label.set_size_policy(GUI::SizePolicy::Fixed, GUI::SizePolicy::Fill); |     family_label.set_fixed_width(100); | ||||||
|     family_label.set_preferred_size(100, 0); |  | ||||||
|     family_label.set_text_alignment(Gfx::TextAlignment::CenterLeft); |     family_label.set_text_alignment(Gfx::TextAlignment::CenterLeft); | ||||||
|     family_label.set_text("Family:"); |     family_label.set_text("Family:"); | ||||||
| 
 | 
 | ||||||
|     auto& family_textbox = family_container.add<GUI::TextBox>(); |     auto& family_textbox = family_container.add<GUI::TextBox>(); | ||||||
|     family_textbox.set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fill); |  | ||||||
|     family_textbox.set_text(m_edited_font->family()); |     family_textbox.set_text(m_edited_font->family()); | ||||||
|     family_textbox.on_change = [&] { |     family_textbox.on_change = [&] { | ||||||
|         m_edited_font->set_family(family_textbox.text()); |         m_edited_font->set_family(family_textbox.text()); | ||||||
|  | @ -165,17 +147,14 @@ FontEditorWidget::FontEditorWidget(const String& path, RefPtr<Gfx::Font>&& edite | ||||||
|     //// Presentation size Row
 |     //// Presentation size Row
 | ||||||
|     auto& presentation_size_container = font_metadata_group_box.add<GUI::Widget>(); |     auto& presentation_size_container = font_metadata_group_box.add<GUI::Widget>(); | ||||||
|     presentation_size_container.set_layout<GUI::HorizontalBoxLayout>(); |     presentation_size_container.set_layout<GUI::HorizontalBoxLayout>(); | ||||||
|     presentation_size_container.set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed); |     presentation_size_container.set_fixed_height(22); | ||||||
|     presentation_size_container.set_preferred_size(0, 22); |  | ||||||
| 
 | 
 | ||||||
|     auto& presentation_size_label = presentation_size_container.add<GUI::Label>(); |     auto& presentation_size_label = presentation_size_container.add<GUI::Label>(); | ||||||
|     presentation_size_label.set_size_policy(GUI::SizePolicy::Fixed, GUI::SizePolicy::Fill); |     presentation_size_label.set_fixed_width(100); | ||||||
|     presentation_size_label.set_preferred_size(100, 0); |  | ||||||
|     presentation_size_label.set_text_alignment(Gfx::TextAlignment::CenterLeft); |     presentation_size_label.set_text_alignment(Gfx::TextAlignment::CenterLeft); | ||||||
|     presentation_size_label.set_text("Presentation size:"); |     presentation_size_label.set_text("Presentation size:"); | ||||||
| 
 | 
 | ||||||
|     auto& presentation_size_spinbox = presentation_size_container.add<GUI::SpinBox>(); |     auto& presentation_size_spinbox = presentation_size_container.add<GUI::SpinBox>(); | ||||||
|     presentation_size_spinbox.set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fill); |  | ||||||
|     presentation_size_spinbox.set_min(0); |     presentation_size_spinbox.set_min(0); | ||||||
|     presentation_size_spinbox.set_max(255); |     presentation_size_spinbox.set_max(255); | ||||||
|     presentation_size_spinbox.set_value(m_edited_font->presentation_size()); |     presentation_size_spinbox.set_value(m_edited_font->presentation_size()); | ||||||
|  | @ -183,17 +162,14 @@ FontEditorWidget::FontEditorWidget(const String& path, RefPtr<Gfx::Font>&& edite | ||||||
|     //// Weight Row
 |     //// Weight Row
 | ||||||
|     auto& weight_container = font_metadata_group_box.add<GUI::Widget>(); |     auto& weight_container = font_metadata_group_box.add<GUI::Widget>(); | ||||||
|     weight_container.set_layout<GUI::HorizontalBoxLayout>(); |     weight_container.set_layout<GUI::HorizontalBoxLayout>(); | ||||||
|     weight_container.set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed); |     weight_container.set_fixed_height(22); | ||||||
|     weight_container.set_preferred_size(0, 22); |  | ||||||
| 
 | 
 | ||||||
|     auto& weight_label = weight_container.add<GUI::Label>(); |     auto& weight_label = weight_container.add<GUI::Label>(); | ||||||
|     weight_label.set_size_policy(GUI::SizePolicy::Fixed, GUI::SizePolicy::Fill); |     weight_label.set_fixed_width(100); | ||||||
|     weight_label.set_preferred_size(100, 0); |  | ||||||
|     weight_label.set_text_alignment(Gfx::TextAlignment::CenterLeft); |     weight_label.set_text_alignment(Gfx::TextAlignment::CenterLeft); | ||||||
|     weight_label.set_text("Weight:"); |     weight_label.set_text("Weight:"); | ||||||
| 
 | 
 | ||||||
|     auto& weight_spinbox = weight_container.add<GUI::SpinBox>(); |     auto& weight_spinbox = weight_container.add<GUI::SpinBox>(); | ||||||
|     weight_spinbox.set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fill); |  | ||||||
|     weight_spinbox.set_min(0); |     weight_spinbox.set_min(0); | ||||||
|     weight_spinbox.set_max(65535); |     weight_spinbox.set_max(65535); | ||||||
|     weight_spinbox.set_value(m_edited_font->weight()); |     weight_spinbox.set_value(m_edited_font->weight()); | ||||||
|  | @ -201,17 +177,14 @@ FontEditorWidget::FontEditorWidget(const String& path, RefPtr<Gfx::Font>&& edite | ||||||
|     //// Glyph spacing Row
 |     //// Glyph spacing Row
 | ||||||
|     auto& glyph_spacing_container = font_metadata_group_box.add<GUI::Widget>(); |     auto& glyph_spacing_container = font_metadata_group_box.add<GUI::Widget>(); | ||||||
|     glyph_spacing_container.set_layout<GUI::HorizontalBoxLayout>(); |     glyph_spacing_container.set_layout<GUI::HorizontalBoxLayout>(); | ||||||
|     glyph_spacing_container.set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed); |     glyph_spacing_container.set_fixed_height(22); | ||||||
|     glyph_spacing_container.set_preferred_size(0, 22); |  | ||||||
| 
 | 
 | ||||||
|     auto& glyph_spacing = glyph_spacing_container.add<GUI::Label>(); |     auto& glyph_spacing = glyph_spacing_container.add<GUI::Label>(); | ||||||
|     glyph_spacing.set_size_policy(GUI::SizePolicy::Fixed, GUI::SizePolicy::Fill); |     glyph_spacing.set_fixed_width(100); | ||||||
|     glyph_spacing.set_preferred_size(100, 0); |  | ||||||
|     glyph_spacing.set_text_alignment(Gfx::TextAlignment::CenterLeft); |     glyph_spacing.set_text_alignment(Gfx::TextAlignment::CenterLeft); | ||||||
|     glyph_spacing.set_text("Glyph spacing:"); |     glyph_spacing.set_text("Glyph spacing:"); | ||||||
| 
 | 
 | ||||||
|     auto& spacing_spinbox = glyph_spacing_container.add<GUI::SpinBox>(); |     auto& spacing_spinbox = glyph_spacing_container.add<GUI::SpinBox>(); | ||||||
|     spacing_spinbox.set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fill); |  | ||||||
|     spacing_spinbox.set_min(0); |     spacing_spinbox.set_min(0); | ||||||
|     spacing_spinbox.set_max(255); |     spacing_spinbox.set_max(255); | ||||||
|     spacing_spinbox.set_value(m_edited_font->glyph_spacing()); |     spacing_spinbox.set_value(m_edited_font->glyph_spacing()); | ||||||
|  | @ -219,17 +192,14 @@ FontEditorWidget::FontEditorWidget(const String& path, RefPtr<Gfx::Font>&& edite | ||||||
|     //// Glyph Height Row
 |     //// Glyph Height Row
 | ||||||
|     auto& glyph_height_container = font_metadata_group_box.add<GUI::Widget>(); |     auto& glyph_height_container = font_metadata_group_box.add<GUI::Widget>(); | ||||||
|     glyph_height_container.set_layout<GUI::HorizontalBoxLayout>(); |     glyph_height_container.set_layout<GUI::HorizontalBoxLayout>(); | ||||||
|     glyph_height_container.set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed); |     glyph_height_container.set_fixed_height(22); | ||||||
|     glyph_height_container.set_preferred_size(0, 22); |  | ||||||
| 
 | 
 | ||||||
|     auto& glyph_height = glyph_height_container.add<GUI::Label>(); |     auto& glyph_height = glyph_height_container.add<GUI::Label>(); | ||||||
|     glyph_height.set_size_policy(GUI::SizePolicy::Fixed, GUI::SizePolicy::Fill); |     glyph_height.set_fixed_width(100); | ||||||
|     glyph_height.set_preferred_size(100, 0); |  | ||||||
|     glyph_height.set_text_alignment(Gfx::TextAlignment::CenterLeft); |     glyph_height.set_text_alignment(Gfx::TextAlignment::CenterLeft); | ||||||
|     glyph_height.set_text("Glyph height:"); |     glyph_height.set_text("Glyph height:"); | ||||||
| 
 | 
 | ||||||
|     auto& glyph_height_spinbox = glyph_height_container.add<GUI::SpinBox>(); |     auto& glyph_height_spinbox = glyph_height_container.add<GUI::SpinBox>(); | ||||||
|     glyph_height_spinbox.set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fill); |  | ||||||
|     glyph_height_spinbox.set_min(0); |     glyph_height_spinbox.set_min(0); | ||||||
|     glyph_height_spinbox.set_max(255); |     glyph_height_spinbox.set_max(255); | ||||||
|     glyph_height_spinbox.set_value(m_edited_font->glyph_height()); |     glyph_height_spinbox.set_value(m_edited_font->glyph_height()); | ||||||
|  | @ -238,17 +208,14 @@ FontEditorWidget::FontEditorWidget(const String& path, RefPtr<Gfx::Font>&& edite | ||||||
|     //// Glyph width Row
 |     //// Glyph width Row
 | ||||||
|     auto& glyph_weight_container = font_metadata_group_box.add<GUI::Widget>(); |     auto& glyph_weight_container = font_metadata_group_box.add<GUI::Widget>(); | ||||||
|     glyph_weight_container.set_layout<GUI::HorizontalBoxLayout>(); |     glyph_weight_container.set_layout<GUI::HorizontalBoxLayout>(); | ||||||
|     glyph_weight_container.set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed); |     glyph_weight_container.set_fixed_height(22); | ||||||
|     glyph_weight_container.set_preferred_size(0, 22); |  | ||||||
| 
 | 
 | ||||||
|     auto& glyph_header_width_label = glyph_weight_container.add<GUI::Label>(); |     auto& glyph_header_width_label = glyph_weight_container.add<GUI::Label>(); | ||||||
|     glyph_header_width_label.set_size_policy(GUI::SizePolicy::Fixed, GUI::SizePolicy::Fill); |     glyph_header_width_label.set_fixed_width(100); | ||||||
|     glyph_header_width_label.set_preferred_size(100, 0); |  | ||||||
|     glyph_header_width_label.set_text_alignment(Gfx::TextAlignment::CenterLeft); |     glyph_header_width_label.set_text_alignment(Gfx::TextAlignment::CenterLeft); | ||||||
|     glyph_header_width_label.set_text("Glyph width:"); |     glyph_header_width_label.set_text("Glyph width:"); | ||||||
| 
 | 
 | ||||||
|     auto& glyph_header_width_spinbox = glyph_weight_container.add<GUI::SpinBox>(); |     auto& glyph_header_width_spinbox = glyph_weight_container.add<GUI::SpinBox>(); | ||||||
|     glyph_header_width_spinbox.set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fill); |  | ||||||
|     glyph_header_width_spinbox.set_min(0); |     glyph_header_width_spinbox.set_min(0); | ||||||
|     glyph_header_width_spinbox.set_max(255); |     glyph_header_width_spinbox.set_max(255); | ||||||
|     glyph_header_width_spinbox.set_value(m_edited_font->glyph_fixed_width()); |     glyph_header_width_spinbox.set_value(m_edited_font->glyph_fixed_width()); | ||||||
|  | @ -257,18 +224,14 @@ FontEditorWidget::FontEditorWidget(const String& path, RefPtr<Gfx::Font>&& edite | ||||||
|     //// Baseline Row
 |     //// Baseline Row
 | ||||||
|     auto& baseline_container = font_metadata_group_box.add<GUI::Widget>(); |     auto& baseline_container = font_metadata_group_box.add<GUI::Widget>(); | ||||||
|     baseline_container.set_layout<GUI::HorizontalBoxLayout>(); |     baseline_container.set_layout<GUI::HorizontalBoxLayout>(); | ||||||
|     baseline_container.set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed); |     baseline_container.set_fixed_height(22); | ||||||
|     baseline_container.set_preferred_size(0, 22); |  | ||||||
| 
 | 
 | ||||||
|     auto& baseline_label = baseline_container.add<GUI::Label>(); |     auto& baseline_label = baseline_container.add<GUI::Label>(); | ||||||
|     baseline_label.set_size_policy(GUI::SizePolicy::Fixed, GUI::SizePolicy::Fill); |     baseline_label.set_fixed_width(100); | ||||||
|     baseline_label.set_preferred_size(100, 0); |  | ||||||
|     baseline_label.set_text_alignment(Gfx::TextAlignment::CenterLeft); |     baseline_label.set_text_alignment(Gfx::TextAlignment::CenterLeft); | ||||||
|     baseline_label.set_text("Baseline:"); |     baseline_label.set_text("Baseline:"); | ||||||
| 
 | 
 | ||||||
|     auto& baseline_spinbox = baseline_container.add<GUI::SpinBox>(); |     auto& baseline_spinbox = baseline_container.add<GUI::SpinBox>(); | ||||||
|     baseline_spinbox.set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fill); |  | ||||||
|     baseline_spinbox.set_preferred_size(100, 0); |  | ||||||
|     baseline_spinbox.set_min(0); |     baseline_spinbox.set_min(0); | ||||||
|     baseline_spinbox.set_max(m_edited_font->glyph_height() - 1); |     baseline_spinbox.set_max(m_edited_font->glyph_height() - 1); | ||||||
|     baseline_spinbox.set_value(m_edited_font->baseline()); |     baseline_spinbox.set_value(m_edited_font->baseline()); | ||||||
|  | @ -276,26 +239,21 @@ FontEditorWidget::FontEditorWidget(const String& path, RefPtr<Gfx::Font>&& edite | ||||||
|     //// Mean line Row
 |     //// Mean line Row
 | ||||||
|     auto& mean_line_container = font_metadata_group_box.add<GUI::Widget>(); |     auto& mean_line_container = font_metadata_group_box.add<GUI::Widget>(); | ||||||
|     mean_line_container.set_layout<GUI::HorizontalBoxLayout>(); |     mean_line_container.set_layout<GUI::HorizontalBoxLayout>(); | ||||||
|     mean_line_container.set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed); |     mean_line_container.set_fixed_height(22); | ||||||
|     mean_line_container.set_preferred_size(0, 22); |  | ||||||
| 
 | 
 | ||||||
|     auto& mean_line_label = mean_line_container.add<GUI::Label>(); |     auto& mean_line_label = mean_line_container.add<GUI::Label>(); | ||||||
|     mean_line_label.set_size_policy(GUI::SizePolicy::Fixed, GUI::SizePolicy::Fill); |     mean_line_label.set_fixed_width(100); | ||||||
|     mean_line_label.set_preferred_size(100, 0); |  | ||||||
|     mean_line_label.set_text_alignment(Gfx::TextAlignment::CenterLeft); |     mean_line_label.set_text_alignment(Gfx::TextAlignment::CenterLeft); | ||||||
|     mean_line_label.set_text("Mean Line:"); |     mean_line_label.set_text("Mean Line:"); | ||||||
| 
 | 
 | ||||||
|     auto& mean_line_spinbox = mean_line_container.add<GUI::SpinBox>(); |     auto& mean_line_spinbox = mean_line_container.add<GUI::SpinBox>(); | ||||||
|     mean_line_spinbox.set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fill); |  | ||||||
|     mean_line_spinbox.set_preferred_size(100, 0); |  | ||||||
|     mean_line_spinbox.set_min(0); |     mean_line_spinbox.set_min(0); | ||||||
|     mean_line_spinbox.set_max(m_edited_font->glyph_height() - 1); |     mean_line_spinbox.set_max(m_edited_font->glyph_height() - 1); | ||||||
|     mean_line_spinbox.set_value(m_edited_font->mean_line()); |     mean_line_spinbox.set_value(m_edited_font->mean_line()); | ||||||
| 
 | 
 | ||||||
|     //// Fixed checkbox Row
 |     //// Fixed checkbox Row
 | ||||||
|     auto& fixed_width_checkbox = font_metadata_group_box.add<GUI::CheckBox>(); |     auto& fixed_width_checkbox = font_metadata_group_box.add<GUI::CheckBox>(); | ||||||
|     fixed_width_checkbox.set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed); |     fixed_width_checkbox.set_fixed_height(22); | ||||||
|     fixed_width_checkbox.set_preferred_size(0, 22); |  | ||||||
|     fixed_width_checkbox.set_text("Fixed width"); |     fixed_width_checkbox.set_text("Fixed width"); | ||||||
|     fixed_width_checkbox.set_checked(m_edited_font->is_fixed_width()); |     fixed_width_checkbox.set_checked(m_edited_font->is_fixed_width()); | ||||||
| 
 | 
 | ||||||
|  | @ -303,20 +261,17 @@ FontEditorWidget::FontEditorWidget(const String& path, RefPtr<Gfx::Font>&& edite | ||||||
|     auto& bottom_container = add<GUI::Widget>(); |     auto& bottom_container = add<GUI::Widget>(); | ||||||
|     bottom_container.set_layout<GUI::HorizontalBoxLayout>(); |     bottom_container.set_layout<GUI::HorizontalBoxLayout>(); | ||||||
|     bottom_container.layout()->set_margins({ 8, 0, 8, 8 }); |     bottom_container.layout()->set_margins({ 8, 0, 8, 8 }); | ||||||
|     bottom_container.set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed); |     bottom_container.set_fixed_height(32); | ||||||
|     bottom_container.set_preferred_size(0, 32); |  | ||||||
| 
 | 
 | ||||||
|     bottom_container.layout()->add_spacer(); |     bottom_container.layout()->add_spacer(); | ||||||
| 
 | 
 | ||||||
|     auto& save_button = bottom_container.add<GUI::Button>(); |     auto& save_button = bottom_container.add<GUI::Button>(); | ||||||
|     save_button.set_size_policy(GUI::SizePolicy::Fixed, GUI::SizePolicy::Fill); |     save_button.set_fixed_size(80, 22); | ||||||
|     save_button.set_preferred_size(80, 0); |  | ||||||
|     save_button.set_text("Save"); |     save_button.set_text("Save"); | ||||||
|     save_button.on_click = [this](auto) { save_as(m_path); }; |     save_button.on_click = [this](auto) { save_as(m_path); }; | ||||||
| 
 | 
 | ||||||
|     auto& quit_button = bottom_container.add<GUI::Button>(); |     auto& quit_button = bottom_container.add<GUI::Button>(); | ||||||
|     quit_button.set_size_policy(GUI::SizePolicy::Fixed, GUI::SizePolicy::Fill); |     quit_button.set_fixed_size(80, 22); | ||||||
|     quit_button.set_preferred_size(80, 0); |  | ||||||
|     quit_button.set_text("Quit"); |     quit_button.set_text("Quit"); | ||||||
|     quit_button.on_click = [](auto) { |     quit_button.on_click = [](auto) { | ||||||
|         exit(0); |         exit(0); | ||||||
|  |  | ||||||
|  | @ -124,8 +124,7 @@ int main(int argc, char* argv[]) | ||||||
|     search_view.layout()->set_margins({ 4, 4, 4, 4 }); |     search_view.layout()->set_margins({ 4, 4, 4, 4 }); | ||||||
|     auto& search_box = search_view.add<GUI::TextBox>(); |     auto& search_box = search_view.add<GUI::TextBox>(); | ||||||
|     auto& search_list_view = search_view.add<GUI::ListView>(); |     auto& search_list_view = search_view.add<GUI::ListView>(); | ||||||
|     search_box.set_preferred_size(0, 20); |     search_box.set_fixed_height(20); | ||||||
|     search_box.set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed); |  | ||||||
|     search_box.set_placeholder("Search..."); |     search_box.set_placeholder("Search..."); | ||||||
|     search_box.on_change = [&] { |     search_box.on_change = [&] { | ||||||
|         if (auto model = search_list_view.model()) { |         if (auto model = search_list_view.model()) { | ||||||
|  | @ -138,8 +137,7 @@ int main(int argc, char* argv[]) | ||||||
|     search_list_view.model()->update(); |     search_list_view.model()->update(); | ||||||
| 
 | 
 | ||||||
|     tree_view.set_model(model); |     tree_view.set_model(model); | ||||||
|     left_tab_bar.set_size_policy(GUI::SizePolicy::Fixed, GUI::SizePolicy::Fill); |     left_tab_bar.set_fixed_width(200); | ||||||
|     left_tab_bar.set_preferred_size(200, 500); |  | ||||||
| 
 | 
 | ||||||
|     auto& page_view = splitter.add<Web::OutOfProcessWebView>(); |     auto& page_view = splitter.add<Web::OutOfProcessWebView>(); | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -333,8 +333,7 @@ void IRCAppWindow::setup_widgets() | ||||||
|     m_window_list->set_alternating_row_colors(false); |     m_window_list->set_alternating_row_colors(false); | ||||||
|     m_window_list->set_model(m_client->client_window_list_model()); |     m_window_list->set_model(m_client->client_window_list_model()); | ||||||
|     m_window_list->set_activates_on_selection(true); |     m_window_list->set_activates_on_selection(true); | ||||||
|     m_window_list->set_size_policy(GUI::SizePolicy::Fixed, GUI::SizePolicy::Fill); |     m_window_list->set_fixed_width(100); | ||||||
|     m_window_list->set_preferred_size(100, 0); |  | ||||||
|     m_window_list->on_activation = [this](auto& index) { |     m_window_list->on_activation = [this](auto& index) { | ||||||
|         set_active_window(m_client->window_at(index.row())); |         set_active_window(m_client->window_at(index.row())); | ||||||
|     }; |     }; | ||||||
|  |  | ||||||
|  | @ -57,8 +57,7 @@ IRCWindow::IRCWindow(IRCClient& client, void* owner, Type type, const String& na | ||||||
|     if (m_type == Channel) { |     if (m_type == Channel) { | ||||||
|         auto& member_view = container.add<GUI::TableView>(); |         auto& member_view = container.add<GUI::TableView>(); | ||||||
|         member_view.set_column_headers_visible(false); |         member_view.set_column_headers_visible(false); | ||||||
|         member_view.set_size_policy(GUI::SizePolicy::Fixed, GUI::SizePolicy::Fill); |         member_view.set_fixed_width(100); | ||||||
|         member_view.set_preferred_size(100, 0); |  | ||||||
|         member_view.set_alternating_row_colors(false); |         member_view.set_alternating_row_colors(false); | ||||||
|         member_view.set_model(channel().member_model()); |         member_view.set_model(channel().member_model()); | ||||||
|         member_view.set_activates_on_selection(true); |         member_view.set_activates_on_selection(true); | ||||||
|  | @ -189,8 +188,7 @@ IRCWindow::IRCWindow(IRCClient& client, void* owner, Type type, const String& na | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     m_text_box = add<GUI::TextBox>(); |     m_text_box = add<GUI::TextBox>(); | ||||||
|     m_text_box->set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed); |     m_text_box->set_fixed_height(19); | ||||||
|     m_text_box->set_preferred_size(0, 19); |  | ||||||
|     m_text_box->on_return_pressed = [this] { |     m_text_box->on_return_pressed = [this] { | ||||||
|         if (m_type == Channel) |         if (m_type == Channel) | ||||||
|             m_client->handle_user_input_in_channel(m_name, m_text_box->text()); |             m_client->handle_user_input_in_channel(m_name, m_text_box->text()); | ||||||
|  |  | ||||||
|  | @ -49,7 +49,6 @@ void KeyboardMapperWidget::create_frame() | ||||||
| { | { | ||||||
|     set_fill_with_background_color(true); |     set_fill_with_background_color(true); | ||||||
|     set_layout<GUI::VerticalBoxLayout>(); |     set_layout<GUI::VerticalBoxLayout>(); | ||||||
|     set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fill); |  | ||||||
|     layout()->set_margins({ 4, 4, 4, 4 }); |     layout()->set_margins({ 4, 4, 4, 4 }); | ||||||
| 
 | 
 | ||||||
|     auto& main_widget = add<GUI::Widget>(); |     auto& main_widget = add<GUI::Widget>(); | ||||||
|  | @ -105,14 +104,12 @@ void KeyboardMapperWidget::create_frame() | ||||||
|     // Action Buttons
 |     // Action Buttons
 | ||||||
|     auto& bottom_widget = add<GUI::Widget>(); |     auto& bottom_widget = add<GUI::Widget>(); | ||||||
|     bottom_widget.set_layout<GUI::HorizontalBoxLayout>(); |     bottom_widget.set_layout<GUI::HorizontalBoxLayout>(); | ||||||
|     bottom_widget.set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed); |     bottom_widget.set_fixed_height(40); | ||||||
|     bottom_widget.set_preferred_size(0, 40); |  | ||||||
| 
 | 
 | ||||||
|     // Map Selection
 |     // Map Selection
 | ||||||
|     m_map_group = bottom_widget.add<GUI::Widget>(); |     m_map_group = bottom_widget.add<GUI::Widget>(); | ||||||
|     m_map_group->set_layout<GUI::HorizontalBoxLayout>(); |     m_map_group->set_layout<GUI::HorizontalBoxLayout>(); | ||||||
|     m_map_group->set_size_policy(GUI::SizePolicy::Fixed, GUI::SizePolicy::Fill); |     m_map_group->set_fixed_width(250); | ||||||
|     m_map_group->set_preferred_size(250, 0); |  | ||||||
| 
 | 
 | ||||||
|     auto& radio_map = m_map_group->add<GUI::RadioButton>("Default"); |     auto& radio_map = m_map_group->add<GUI::RadioButton>("Default"); | ||||||
|     radio_map.set_name("map"); |     radio_map.set_name("map"); | ||||||
|  | @ -139,8 +136,7 @@ void KeyboardMapperWidget::create_frame() | ||||||
| 
 | 
 | ||||||
|     auto& ok_button = bottom_widget.add<GUI::Button>(); |     auto& ok_button = bottom_widget.add<GUI::Button>(); | ||||||
|     ok_button.set_text("Save"); |     ok_button.set_text("Save"); | ||||||
|     ok_button.set_size_policy(GUI::SizePolicy::Fixed, GUI::SizePolicy::Fill); |     ok_button.set_fixed_width(80); | ||||||
|     ok_button.set_preferred_size(80, 0); |  | ||||||
|     ok_button.on_click = [this](auto) { |     ok_button.on_click = [this](auto) { | ||||||
|         save(); |         save(); | ||||||
|     }; |     }; | ||||||
|  |  | ||||||
|  | @ -126,18 +126,15 @@ int main(int argc, char** argv) | ||||||
| 
 | 
 | ||||||
|     auto& character_map_file_selection_container = root_widget.add<GUI::Widget>(); |     auto& character_map_file_selection_container = root_widget.add<GUI::Widget>(); | ||||||
|     character_map_file_selection_container.set_layout<GUI::HorizontalBoxLayout>(); |     character_map_file_selection_container.set_layout<GUI::HorizontalBoxLayout>(); | ||||||
|     character_map_file_selection_container.set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed); |     character_map_file_selection_container.set_fixed_height(22); | ||||||
|     character_map_file_selection_container.set_preferred_size(0, 22); |  | ||||||
| 
 | 
 | ||||||
|     auto& character_map_file_label = character_map_file_selection_container.add<GUI::Label>(); |     auto& character_map_file_label = character_map_file_selection_container.add<GUI::Label>(); | ||||||
|     character_map_file_label.set_text_alignment(Gfx::TextAlignment::CenterLeft); |     character_map_file_label.set_text_alignment(Gfx::TextAlignment::CenterLeft); | ||||||
|     character_map_file_label.set_size_policy(GUI::SizePolicy::Fixed, GUI::SizePolicy::Fill); |     character_map_file_label.set_fixed_width(130); | ||||||
|     character_map_file_label.set_preferred_size({ 130, 0 }); |  | ||||||
|     character_map_file_label.set_text("Character Mapping File:"); |     character_map_file_label.set_text("Character Mapping File:"); | ||||||
| 
 | 
 | ||||||
|     auto& character_map_file_combo = character_map_file_selection_container.add<GUI::ComboBox>(); |     auto& character_map_file_combo = character_map_file_selection_container.add<GUI::ComboBox>(); | ||||||
|     character_map_file_combo.set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed); |     character_map_file_combo.set_fixed_height(22); | ||||||
|     character_map_file_combo.set_preferred_size(0, 22); |  | ||||||
|     character_map_file_combo.set_only_allow_values_from_model(true); |     character_map_file_combo.set_only_allow_values_from_model(true); | ||||||
|     character_map_file_combo.set_model(*CharacterMapFileListModel::create(character_map_files)); |     character_map_file_combo.set_model(*CharacterMapFileListModel::create(character_map_files)); | ||||||
|     character_map_file_combo.set_selected_index(initial_keymap_index); |     character_map_file_combo.set_selected_index(initial_keymap_index); | ||||||
|  | @ -163,29 +160,25 @@ int main(int argc, char** argv) | ||||||
|     auto& bottom_widget = root_widget.add<GUI::Widget>(); |     auto& bottom_widget = root_widget.add<GUI::Widget>(); | ||||||
|     bottom_widget.set_layout<GUI::HorizontalBoxLayout>(); |     bottom_widget.set_layout<GUI::HorizontalBoxLayout>(); | ||||||
|     bottom_widget.layout()->add_spacer(); |     bottom_widget.layout()->add_spacer(); | ||||||
|     bottom_widget.set_size_policy(Orientation::Vertical, GUI::SizePolicy::Fixed); |     bottom_widget.set_fixed_height(22); | ||||||
|     bottom_widget.set_preferred_size(1, 22); |  | ||||||
| 
 | 
 | ||||||
|     auto& apply_button = bottom_widget.add<GUI::Button>(); |     auto& apply_button = bottom_widget.add<GUI::Button>(); | ||||||
|     apply_button.set_text("Apply"); |     apply_button.set_text("Apply"); | ||||||
|     apply_button.set_size_policy(Orientation::Horizontal, GUI::SizePolicy::Fixed); |     apply_button.set_fixed_width(60); | ||||||
|     apply_button.set_preferred_size(60, 22); |  | ||||||
|     apply_button.on_click = [&](auto) { |     apply_button.on_click = [&](auto) { | ||||||
|         apply_settings(false); |         apply_settings(false); | ||||||
|     }; |     }; | ||||||
| 
 | 
 | ||||||
|     auto& ok_button = bottom_widget.add<GUI::Button>(); |     auto& ok_button = bottom_widget.add<GUI::Button>(); | ||||||
|     ok_button.set_text("OK"); |     ok_button.set_text("OK"); | ||||||
|     ok_button.set_size_policy(Orientation::Horizontal, GUI::SizePolicy::Fixed); |     ok_button.set_fixed_width(60); | ||||||
|     ok_button.set_preferred_size(60, 22); |  | ||||||
|     ok_button.on_click = [&](auto) { |     ok_button.on_click = [&](auto) { | ||||||
|         apply_settings(true); |         apply_settings(true); | ||||||
|     }; |     }; | ||||||
| 
 | 
 | ||||||
|     auto& cancel_button = bottom_widget.add<GUI::Button>(); |     auto& cancel_button = bottom_widget.add<GUI::Button>(); | ||||||
|     cancel_button.set_text("Cancel"); |     cancel_button.set_text("Cancel"); | ||||||
|     cancel_button.set_size_policy(Orientation::Horizontal, GUI::SizePolicy::Fixed); |     cancel_button.set_fixed_width(60); | ||||||
|     cancel_button.set_preferred_size(60, 22); |  | ||||||
|     cancel_button.on_click = [&](auto) { |     cancel_button.on_click = [&](auto) { | ||||||
|         app->quit(); |         app->quit(); | ||||||
|     }; |     }; | ||||||
|  |  | ||||||
|  | @ -47,8 +47,7 @@ KnobsWidget::KnobsWidget(TrackManager& track_manager, MainWidget& main_widget) | ||||||
| 
 | 
 | ||||||
|     m_labels_container = add<GUI::Widget>(); |     m_labels_container = add<GUI::Widget>(); | ||||||
|     m_labels_container->set_layout<GUI::HorizontalBoxLayout>(); |     m_labels_container->set_layout<GUI::HorizontalBoxLayout>(); | ||||||
|     m_labels_container->set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed); |     m_labels_container->set_fixed_height(20); | ||||||
|     m_labels_container->set_preferred_size(0, 20); |  | ||||||
| 
 | 
 | ||||||
|     m_octave_label = m_labels_container->add<GUI::Label>("Octave"); |     m_octave_label = m_labels_container->add<GUI::Label>("Octave"); | ||||||
|     m_wave_label = m_labels_container->add<GUI::Label>("Wave"); |     m_wave_label = m_labels_container->add<GUI::Label>("Wave"); | ||||||
|  | @ -60,8 +59,7 @@ KnobsWidget::KnobsWidget(TrackManager& track_manager, MainWidget& main_widget) | ||||||
| 
 | 
 | ||||||
|     m_values_container = add<GUI::Widget>(); |     m_values_container = add<GUI::Widget>(); | ||||||
|     m_values_container->set_layout<GUI::HorizontalBoxLayout>(); |     m_values_container->set_layout<GUI::HorizontalBoxLayout>(); | ||||||
|     m_values_container->set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed); |     m_values_container->set_fixed_height(10); | ||||||
|     m_values_container->set_preferred_size(0, 10); |  | ||||||
| 
 | 
 | ||||||
|     m_octave_value = m_values_container->add<GUI::Label>(String::number(m_track_manager.octave())); |     m_octave_value = m_values_container->add<GUI::Label>(String::number(m_track_manager.octave())); | ||||||
|     m_wave_value = m_values_container->add<GUI::Label>(wave_strings[m_track_manager.current_track().wave()]); |     m_wave_value = m_values_container->add<GUI::Label>(wave_strings[m_track_manager.current_track().wave()]); | ||||||
|  |  | ||||||
|  | @ -46,29 +46,25 @@ MainWidget::MainWidget(TrackManager& track_manager) | ||||||
|     set_fill_with_background_color(true); |     set_fill_with_background_color(true); | ||||||
| 
 | 
 | ||||||
|     m_wave_widget = add<WaveWidget>(track_manager); |     m_wave_widget = add<WaveWidget>(track_manager); | ||||||
|     m_wave_widget->set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed); |     m_wave_widget->set_fixed_height(100); | ||||||
|     m_wave_widget->set_preferred_size(0, 100); |  | ||||||
| 
 | 
 | ||||||
|     m_tab_widget = add<GUI::TabWidget>(); |     m_tab_widget = add<GUI::TabWidget>(); | ||||||
|     m_roll_widget = m_tab_widget->add_tab<RollWidget>("Piano Roll", track_manager); |     m_roll_widget = m_tab_widget->add_tab<RollWidget>("Piano Roll", track_manager); | ||||||
| 
 | 
 | ||||||
|     m_roll_widget->set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fill); |     m_roll_widget->set_fixed_height(300); | ||||||
|     m_roll_widget->set_preferred_size(0, 300); |  | ||||||
| 
 | 
 | ||||||
|     m_tab_widget->add_tab<SamplerWidget>("Sampler", track_manager); |     m_tab_widget->add_tab<SamplerWidget>("Sampler", track_manager); | ||||||
| 
 | 
 | ||||||
|     m_keys_and_knobs_container = add<GUI::Widget>(); |     m_keys_and_knobs_container = add<GUI::Widget>(); | ||||||
|     m_keys_and_knobs_container->set_layout<GUI::HorizontalBoxLayout>(); |     m_keys_and_knobs_container->set_layout<GUI::HorizontalBoxLayout>(); | ||||||
|     m_keys_and_knobs_container->layout()->set_spacing(2); |     m_keys_and_knobs_container->layout()->set_spacing(2); | ||||||
|     m_keys_and_knobs_container->set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed); |     m_keys_and_knobs_container->set_fixed_height(100); | ||||||
|     m_keys_and_knobs_container->set_preferred_size(0, 100); |  | ||||||
|     m_keys_and_knobs_container->set_fill_with_background_color(true); |     m_keys_and_knobs_container->set_fill_with_background_color(true); | ||||||
| 
 | 
 | ||||||
|     m_keys_widget = m_keys_and_knobs_container->add<KeysWidget>(track_manager); |     m_keys_widget = m_keys_and_knobs_container->add<KeysWidget>(track_manager); | ||||||
| 
 | 
 | ||||||
|     m_knobs_widget = m_keys_and_knobs_container->add<KnobsWidget>(track_manager, *this); |     m_knobs_widget = m_keys_and_knobs_container->add<KnobsWidget>(track_manager, *this); | ||||||
|     m_knobs_widget->set_size_policy(GUI::SizePolicy::Fixed, GUI::SizePolicy::Fill); |     m_knobs_widget->set_fixed_width(350); | ||||||
|     m_knobs_widget->set_preferred_size(350, 0); |  | ||||||
| 
 | 
 | ||||||
|     m_roll_widget->set_keys_widget(m_keys_widget); |     m_roll_widget->set_keys_widget(m_keys_widget); | ||||||
| } | } | ||||||
|  |  | ||||||
|  | @ -99,12 +99,10 @@ SamplerWidget::SamplerWidget(TrackManager& track_manager) | ||||||
|     m_open_button_and_recorded_sample_name_container = add<GUI::Widget>(); |     m_open_button_and_recorded_sample_name_container = add<GUI::Widget>(); | ||||||
|     m_open_button_and_recorded_sample_name_container->set_layout<GUI::HorizontalBoxLayout>(); |     m_open_button_and_recorded_sample_name_container->set_layout<GUI::HorizontalBoxLayout>(); | ||||||
|     m_open_button_and_recorded_sample_name_container->layout()->set_spacing(10); |     m_open_button_and_recorded_sample_name_container->layout()->set_spacing(10); | ||||||
|     m_open_button_and_recorded_sample_name_container->set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed); |     m_open_button_and_recorded_sample_name_container->set_fixed_height(24); | ||||||
|     m_open_button_and_recorded_sample_name_container->set_preferred_size(0, 24); |  | ||||||
| 
 | 
 | ||||||
|     m_open_button = m_open_button_and_recorded_sample_name_container->add<GUI::Button>(); |     m_open_button = m_open_button_and_recorded_sample_name_container->add<GUI::Button>(); | ||||||
|     m_open_button->set_size_policy(GUI::SizePolicy::Fixed, GUI::SizePolicy::Fixed); |     m_open_button->set_fixed_size(24, 24); | ||||||
|     m_open_button->set_preferred_size(24, 24); |  | ||||||
|     m_open_button->set_focus_policy(GUI::FocusPolicy::TabFocus); |     m_open_button->set_focus_policy(GUI::FocusPolicy::TabFocus); | ||||||
|     m_open_button->set_icon(Gfx::Bitmap::load_from_file("/res/icons/16x16/open.png")); |     m_open_button->set_icon(Gfx::Bitmap::load_from_file("/res/icons/16x16/open.png")); | ||||||
|     m_open_button->on_click = [this](auto) { |     m_open_button->on_click = [this](auto) { | ||||||
|  | @ -124,8 +122,7 @@ SamplerWidget::SamplerWidget(TrackManager& track_manager) | ||||||
|     m_recorded_sample_name->set_text_alignment(Gfx::TextAlignment::CenterLeft); |     m_recorded_sample_name->set_text_alignment(Gfx::TextAlignment::CenterLeft); | ||||||
| 
 | 
 | ||||||
|     m_wave_editor = add<WaveEditor>(m_track_manager); |     m_wave_editor = add<WaveEditor>(m_track_manager); | ||||||
|     m_wave_editor->set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed); |     m_wave_editor->set_fixed_height(100); | ||||||
|     m_wave_editor->set_preferred_size(0, 100); |  | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| SamplerWidget::~SamplerWidget() | SamplerWidget::~SamplerWidget() | ||||||
|  |  | ||||||
|  | @ -131,18 +131,15 @@ GUI::Widget* BrushTool::get_properties_widget() | ||||||
|         m_properties_widget->set_layout<GUI::VerticalBoxLayout>(); |         m_properties_widget->set_layout<GUI::VerticalBoxLayout>(); | ||||||
| 
 | 
 | ||||||
|         auto& size_container = m_properties_widget->add<GUI::Widget>(); |         auto& size_container = m_properties_widget->add<GUI::Widget>(); | ||||||
|         size_container.set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed); |         size_container.set_fixed_height(20); | ||||||
|         size_container.set_preferred_size(0, 20); |  | ||||||
|         size_container.set_layout<GUI::HorizontalBoxLayout>(); |         size_container.set_layout<GUI::HorizontalBoxLayout>(); | ||||||
| 
 | 
 | ||||||
|         auto& size_label = size_container.add<GUI::Label>("Size:"); |         auto& size_label = size_container.add<GUI::Label>("Size:"); | ||||||
|         size_label.set_text_alignment(Gfx::TextAlignment::CenterLeft); |         size_label.set_text_alignment(Gfx::TextAlignment::CenterLeft); | ||||||
|         size_label.set_size_policy(GUI::SizePolicy::Fixed, GUI::SizePolicy::Fixed); |         size_label.set_fixed_size(80, 20); | ||||||
|         size_label.set_preferred_size(80, 20); |  | ||||||
| 
 | 
 | ||||||
|         auto& size_slider = size_container.add<GUI::HorizontalSlider>(); |         auto& size_slider = size_container.add<GUI::HorizontalSlider>(); | ||||||
|         size_slider.set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed); |         size_slider.set_fixed_height(20); | ||||||
|         size_slider.set_preferred_size(0, 20); |  | ||||||
|         size_slider.set_range(1, 100); |         size_slider.set_range(1, 100); | ||||||
|         size_slider.set_value(m_size); |         size_slider.set_value(m_size); | ||||||
|         size_slider.on_value_changed = [this](int value) { |         size_slider.on_value_changed = [this](int value) { | ||||||
|  | @ -150,18 +147,15 @@ GUI::Widget* BrushTool::get_properties_widget() | ||||||
|         }; |         }; | ||||||
| 
 | 
 | ||||||
|         auto& hardness_container = m_properties_widget->add<GUI::Widget>(); |         auto& hardness_container = m_properties_widget->add<GUI::Widget>(); | ||||||
|         hardness_container.set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed); |         hardness_container.set_fixed_height(20); | ||||||
|         hardness_container.set_preferred_size(0, 20); |  | ||||||
|         hardness_container.set_layout<GUI::HorizontalBoxLayout>(); |         hardness_container.set_layout<GUI::HorizontalBoxLayout>(); | ||||||
| 
 | 
 | ||||||
|         auto& hardness_label = hardness_container.add<GUI::Label>("Hardness:"); |         auto& hardness_label = hardness_container.add<GUI::Label>("Hardness:"); | ||||||
|         hardness_label.set_text_alignment(Gfx::TextAlignment::CenterLeft); |         hardness_label.set_text_alignment(Gfx::TextAlignment::CenterLeft); | ||||||
|         hardness_label.set_size_policy(GUI::SizePolicy::Fixed, GUI::SizePolicy::Fixed); |         hardness_label.set_fixed_size(80, 20); | ||||||
|         hardness_label.set_preferred_size(80, 20); |  | ||||||
| 
 | 
 | ||||||
|         auto& hardness_slider = hardness_container.add<GUI::HorizontalSlider>(); |         auto& hardness_slider = hardness_container.add<GUI::HorizontalSlider>(); | ||||||
|         hardness_slider.set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed); |         hardness_slider.set_fixed_height(20); | ||||||
|         hardness_slider.set_preferred_size(0, 20); |  | ||||||
|         hardness_slider.set_range(1, 99); |         hardness_slider.set_range(1, 99); | ||||||
|         hardness_slider.set_value(m_hardness); |         hardness_slider.set_value(m_hardness); | ||||||
|         hardness_slider.on_value_changed = [this](int value) { |         hardness_slider.on_value_changed = [this](int value) { | ||||||
|  |  | ||||||
|  | @ -111,18 +111,15 @@ GUI::Widget* BucketTool::get_properties_widget() | ||||||
|         m_properties_widget->set_layout<GUI::VerticalBoxLayout>(); |         m_properties_widget->set_layout<GUI::VerticalBoxLayout>(); | ||||||
| 
 | 
 | ||||||
|         auto& threshold_container = m_properties_widget->add<GUI::Widget>(); |         auto& threshold_container = m_properties_widget->add<GUI::Widget>(); | ||||||
|         threshold_container.set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed); |         threshold_container.set_fixed_height(20); | ||||||
|         threshold_container.set_preferred_size(0, 20); |  | ||||||
|         threshold_container.set_layout<GUI::HorizontalBoxLayout>(); |         threshold_container.set_layout<GUI::HorizontalBoxLayout>(); | ||||||
| 
 | 
 | ||||||
|         auto& threshold_label = threshold_container.add<GUI::Label>("Threshold:"); |         auto& threshold_label = threshold_container.add<GUI::Label>("Threshold:"); | ||||||
|         threshold_label.set_text_alignment(Gfx::TextAlignment::CenterLeft); |         threshold_label.set_text_alignment(Gfx::TextAlignment::CenterLeft); | ||||||
|         threshold_label.set_size_policy(GUI::SizePolicy::Fixed, GUI::SizePolicy::Fixed); |         threshold_label.set_fixed_size(80, 20); | ||||||
|         threshold_label.set_preferred_size(80, 20); |  | ||||||
| 
 | 
 | ||||||
|         auto& threshold_slider = threshold_container.add<GUI::HorizontalSlider>(); |         auto& threshold_slider = threshold_container.add<GUI::HorizontalSlider>(); | ||||||
|         threshold_slider.set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed); |         threshold_slider.set_fixed_height(20); | ||||||
|         threshold_slider.set_preferred_size(0, 20); |  | ||||||
|         threshold_slider.set_range(0, 100); |         threshold_slider.set_range(0, 100); | ||||||
|         threshold_slider.set_value(m_threshold); |         threshold_slider.set_value(m_threshold); | ||||||
|         threshold_slider.on_value_changed = [this](int value) { |         threshold_slider.on_value_changed = [this](int value) { | ||||||
|  |  | ||||||
|  | @ -82,7 +82,6 @@ private: | ||||||
|             for (size_t column = 0; column < columns; ++column) { |             for (size_t column = 0; column < columns; ++column) { | ||||||
|                 if (index < columns * rows) { |                 if (index < columns * rows) { | ||||||
|                     auto& textbox = horizontal_container.template add<GUI::TextBox>(); |                     auto& textbox = horizontal_container.template add<GUI::TextBox>(); | ||||||
|                     textbox.set_preferred_size({ 30, 50 }); |  | ||||||
|                     textbox.on_change = [&, row = row, column = column] { |                     textbox.on_change = [&, row = row, column = column] { | ||||||
|                         auto& element = m_matrix.elements()[row][column]; |                         auto& element = m_matrix.elements()[row][column]; | ||||||
|                         char* endptr = nullptr; |                         char* endptr = nullptr; | ||||||
|  |  | ||||||
|  | @ -46,36 +46,30 @@ LayerPropertiesWidget::LayerPropertiesWidget() | ||||||
|     layout.set_margins({ 10, 20, 10, 10 }); |     layout.set_margins({ 10, 20, 10, 10 }); | ||||||
| 
 | 
 | ||||||
|     auto& name_container = group_box.add<GUI::Widget>(); |     auto& name_container = group_box.add<GUI::Widget>(); | ||||||
|     name_container.set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed); |     name_container.set_fixed_height(20); | ||||||
|     name_container.set_preferred_size(0, 20); |  | ||||||
|     name_container.set_layout<GUI::HorizontalBoxLayout>(); |     name_container.set_layout<GUI::HorizontalBoxLayout>(); | ||||||
| 
 | 
 | ||||||
|     auto& name_label = name_container.add<GUI::Label>("Name:"); |     auto& name_label = name_container.add<GUI::Label>("Name:"); | ||||||
|     name_label.set_text_alignment(Gfx::TextAlignment::CenterLeft); |     name_label.set_text_alignment(Gfx::TextAlignment::CenterLeft); | ||||||
|     name_label.set_size_policy(GUI::SizePolicy::Fixed, GUI::SizePolicy::Fixed); |     name_label.set_fixed_size(80, 20); | ||||||
|     name_label.set_preferred_size(80, 20); |  | ||||||
| 
 | 
 | ||||||
|     m_name_textbox = name_container.add<GUI::TextBox>(); |     m_name_textbox = name_container.add<GUI::TextBox>(); | ||||||
|     m_name_textbox->set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed); |     m_name_textbox->set_fixed_height(20); | ||||||
|     m_name_textbox->set_preferred_size(0, 20); |  | ||||||
|     m_name_textbox->on_change = [this] { |     m_name_textbox->on_change = [this] { | ||||||
|         if (m_layer) |         if (m_layer) | ||||||
|             m_layer->set_name(m_name_textbox->text()); |             m_layer->set_name(m_name_textbox->text()); | ||||||
|     }; |     }; | ||||||
| 
 | 
 | ||||||
|     auto& opacity_container = group_box.add<GUI::Widget>(); |     auto& opacity_container = group_box.add<GUI::Widget>(); | ||||||
|     opacity_container.set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed); |     opacity_container.set_fixed_height(20); | ||||||
|     opacity_container.set_preferred_size(0, 20); |  | ||||||
|     opacity_container.set_layout<GUI::HorizontalBoxLayout>(); |     opacity_container.set_layout<GUI::HorizontalBoxLayout>(); | ||||||
| 
 | 
 | ||||||
|     auto& opacity_label = opacity_container.add<GUI::Label>("Opacity:"); |     auto& opacity_label = opacity_container.add<GUI::Label>("Opacity:"); | ||||||
|     opacity_label.set_text_alignment(Gfx::TextAlignment::CenterLeft); |     opacity_label.set_text_alignment(Gfx::TextAlignment::CenterLeft); | ||||||
|     opacity_label.set_size_policy(GUI::SizePolicy::Fixed, GUI::SizePolicy::Fixed); |     opacity_label.set_fixed_size(80, 20); | ||||||
|     opacity_label.set_preferred_size(80, 20); |  | ||||||
| 
 | 
 | ||||||
|     m_opacity_slider = opacity_container.add<GUI::HorizontalSlider>(); |     m_opacity_slider = opacity_container.add<GUI::HorizontalSlider>(); | ||||||
|     m_opacity_slider->set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed); |     m_opacity_slider->set_fixed_height(20); | ||||||
|     m_opacity_slider->set_preferred_size(0, 20); |  | ||||||
|     m_opacity_slider->set_range(0, 100); |     m_opacity_slider->set_range(0, 100); | ||||||
|     m_opacity_slider->on_value_changed = [this](int value) { |     m_opacity_slider->on_value_changed = [this](int value) { | ||||||
|         if (m_layer) |         if (m_layer) | ||||||
|  | @ -83,8 +77,7 @@ LayerPropertiesWidget::LayerPropertiesWidget() | ||||||
|     }; |     }; | ||||||
| 
 | 
 | ||||||
|     m_visibility_checkbox = group_box.add<GUI::CheckBox>("Visible"); |     m_visibility_checkbox = group_box.add<GUI::CheckBox>("Visible"); | ||||||
|     m_visibility_checkbox->set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed); |     m_visibility_checkbox->set_fixed_height(20); | ||||||
|     m_visibility_checkbox->set_preferred_size(0, 20); |  | ||||||
|     m_visibility_checkbox->on_checked = [this](bool checked) { |     m_visibility_checkbox->on_checked = [this](bool checked) { | ||||||
|         if (m_layer) |         if (m_layer) | ||||||
|             m_layer->set_visible(checked); |             m_layer->set_visible(checked); | ||||||
|  |  | ||||||
|  | @ -79,8 +79,7 @@ PaletteWidget::PaletteWidget(ImageEditor& editor) | ||||||
|     set_frame_thickness(0); |     set_frame_thickness(0); | ||||||
|     set_fill_with_background_color(true); |     set_fill_with_background_color(true); | ||||||
| 
 | 
 | ||||||
|     set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed); |     set_fixed_height(34); | ||||||
|     set_preferred_size(0, 34); |  | ||||||
| 
 | 
 | ||||||
|     m_secondary_color_widget = add<GUI::Frame>(); |     m_secondary_color_widget = add<GUI::Frame>(); | ||||||
|     m_secondary_color_widget->set_relative_rect({ 2, 2, 60, 31 }); |     m_secondary_color_widget->set_relative_rect({ 2, 2, 60, 31 }); | ||||||
|  |  | ||||||
|  | @ -106,18 +106,15 @@ GUI::Widget* PenTool::get_properties_widget() | ||||||
|         m_properties_widget->set_layout<GUI::VerticalBoxLayout>(); |         m_properties_widget->set_layout<GUI::VerticalBoxLayout>(); | ||||||
| 
 | 
 | ||||||
|         auto& thickness_container = m_properties_widget->add<GUI::Widget>(); |         auto& thickness_container = m_properties_widget->add<GUI::Widget>(); | ||||||
|         thickness_container.set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed); |         thickness_container.set_fixed_height(20); | ||||||
|         thickness_container.set_preferred_size(0, 20); |  | ||||||
|         thickness_container.set_layout<GUI::HorizontalBoxLayout>(); |         thickness_container.set_layout<GUI::HorizontalBoxLayout>(); | ||||||
| 
 | 
 | ||||||
|         auto& thickness_label = thickness_container.add<GUI::Label>("Thickness:"); |         auto& thickness_label = thickness_container.add<GUI::Label>("Thickness:"); | ||||||
|         thickness_label.set_text_alignment(Gfx::TextAlignment::CenterLeft); |         thickness_label.set_text_alignment(Gfx::TextAlignment::CenterLeft); | ||||||
|         thickness_label.set_size_policy(GUI::SizePolicy::Fixed, GUI::SizePolicy::Fixed); |         thickness_label.set_fixed_size(80, 20); | ||||||
|         thickness_label.set_preferred_size(80, 20); |  | ||||||
| 
 | 
 | ||||||
|         auto& thickness_slider = thickness_container.add<GUI::HorizontalSlider>(); |         auto& thickness_slider = thickness_container.add<GUI::HorizontalSlider>(); | ||||||
|         thickness_slider.set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed); |         thickness_slider.set_fixed_height(20); | ||||||
|         thickness_slider.set_preferred_size(0, 20); |  | ||||||
|         thickness_slider.set_range(1, 20); |         thickness_slider.set_range(1, 20); | ||||||
|         thickness_slider.set_value(m_thickness); |         thickness_slider.set_value(m_thickness); | ||||||
|         thickness_slider.on_value_changed = [this](int value) { |         thickness_slider.on_value_changed = [this](int value) { | ||||||
|  |  | ||||||
|  | @ -138,18 +138,15 @@ GUI::Widget* SprayTool::get_properties_widget() | ||||||
|         m_properties_widget->set_layout<GUI::VerticalBoxLayout>(); |         m_properties_widget->set_layout<GUI::VerticalBoxLayout>(); | ||||||
| 
 | 
 | ||||||
|         auto& thickness_container = m_properties_widget->add<GUI::Widget>(); |         auto& thickness_container = m_properties_widget->add<GUI::Widget>(); | ||||||
|         thickness_container.set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed); |         thickness_container.set_fixed_height(20); | ||||||
|         thickness_container.set_preferred_size(0, 20); |  | ||||||
|         thickness_container.set_layout<GUI::HorizontalBoxLayout>(); |         thickness_container.set_layout<GUI::HorizontalBoxLayout>(); | ||||||
| 
 | 
 | ||||||
|         auto& thickness_label = thickness_container.add<GUI::Label>("Thickness:"); |         auto& thickness_label = thickness_container.add<GUI::Label>("Thickness:"); | ||||||
|         thickness_label.set_text_alignment(Gfx::TextAlignment::CenterLeft); |         thickness_label.set_text_alignment(Gfx::TextAlignment::CenterLeft); | ||||||
|         thickness_label.set_size_policy(GUI::SizePolicy::Fixed, GUI::SizePolicy::Fixed); |         thickness_label.set_fixed_size(80, 20); | ||||||
|         thickness_label.set_preferred_size(80, 20); |  | ||||||
| 
 | 
 | ||||||
|         auto& thickness_slider = thickness_container.add<GUI::HorizontalSlider>(); |         auto& thickness_slider = thickness_container.add<GUI::HorizontalSlider>(); | ||||||
|         thickness_slider.set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed); |         thickness_slider.set_fixed_height(20); | ||||||
|         thickness_slider.set_preferred_size(0, 20); |  | ||||||
|         thickness_slider.set_range(1, 20); |         thickness_slider.set_range(1, 20); | ||||||
|         thickness_slider.set_value(m_thickness); |         thickness_slider.set_value(m_thickness); | ||||||
|         thickness_slider.on_value_changed = [this](int value) { |         thickness_slider.on_value_changed = [this](int value) { | ||||||
|  | @ -157,18 +154,15 @@ GUI::Widget* SprayTool::get_properties_widget() | ||||||
|         }; |         }; | ||||||
| 
 | 
 | ||||||
|         auto& density_container = m_properties_widget->add<GUI::Widget>(); |         auto& density_container = m_properties_widget->add<GUI::Widget>(); | ||||||
|         density_container.set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed); |         density_container.set_fixed_height(20); | ||||||
|         density_container.set_preferred_size(0, 20); |  | ||||||
|         density_container.set_layout<GUI::HorizontalBoxLayout>(); |         density_container.set_layout<GUI::HorizontalBoxLayout>(); | ||||||
| 
 | 
 | ||||||
|         auto& density_label = density_container.add<GUI::Label>("Density:"); |         auto& density_label = density_container.add<GUI::Label>("Density:"); | ||||||
|         density_label.set_text_alignment(Gfx::TextAlignment::CenterLeft); |         density_label.set_text_alignment(Gfx::TextAlignment::CenterLeft); | ||||||
|         density_label.set_size_policy(GUI::SizePolicy::Fixed, GUI::SizePolicy::Fixed); |         density_label.set_fixed_size(80, 20); | ||||||
|         density_label.set_preferred_size(80, 20); |  | ||||||
| 
 | 
 | ||||||
|         auto& density_slider = density_container.add<GUI::HorizontalSlider>(); |         auto& density_slider = density_container.add<GUI::HorizontalSlider>(); | ||||||
|         density_slider.set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed); |         density_slider.set_fixed_height(30); | ||||||
|         density_slider.set_preferred_size(0, 30); |  | ||||||
|         density_slider.set_range(1, 100); |         density_slider.set_range(1, 100); | ||||||
|         density_slider.set_value(m_density); |         density_slider.set_value(m_density); | ||||||
|         density_slider.on_value_changed = [this](int value) { |         density_slider.on_value_changed = [this](int value) { | ||||||
|  |  | ||||||
|  | @ -96,8 +96,7 @@ ToolboxWidget::ToolboxWidget() | ||||||
|     set_frame_shape(Gfx::FrameShape::Panel); |     set_frame_shape(Gfx::FrameShape::Panel); | ||||||
|     set_frame_shadow(Gfx::FrameShadow::Raised); |     set_frame_shadow(Gfx::FrameShadow::Raised); | ||||||
| 
 | 
 | ||||||
|     set_size_policy(GUI::SizePolicy::Fixed, GUI::SizePolicy::Fill); |     set_fixed_width(48); | ||||||
|     set_preferred_size(48, 0); |  | ||||||
| 
 | 
 | ||||||
|     set_layout<GUI::VerticalBoxLayout>(); |     set_layout<GUI::VerticalBoxLayout>(); | ||||||
|     layout()->set_margins({ 4, 4, 4, 4 }); |     layout()->set_margins({ 4, 4, 4, 4 }); | ||||||
|  | @ -119,8 +118,7 @@ void ToolboxWidget::setup_tools() | ||||||
|     auto add_tool = [&](const StringView& name, const StringView& icon_name, const GUI::Shortcut& shortcut, NonnullOwnPtr<Tool> tool) -> ToolButton& { |     auto add_tool = [&](const StringView& name, const StringView& icon_name, const GUI::Shortcut& shortcut, NonnullOwnPtr<Tool> tool) -> ToolButton& { | ||||||
|         m_tools.append(tool.ptr()); |         m_tools.append(tool.ptr()); | ||||||
|         auto& button = add<ToolButton>(*this, name, shortcut, move(tool)); |         auto& button = add<ToolButton>(*this, name, shortcut, move(tool)); | ||||||
|         button.set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed); |         button.set_fixed_height(32); | ||||||
|         button.set_preferred_size(0, 32); |  | ||||||
|         button.set_checkable(true); |         button.set_checkable(true); | ||||||
|         button.set_icon(Gfx::Bitmap::load_from_file(String::formatted("/res/icons/pixelpaint/{}.png", icon_name))); |         button.set_icon(Gfx::Bitmap::load_from_file(String::formatted("/res/icons/pixelpaint/{}.png", icon_name))); | ||||||
|         return button; |         return button; | ||||||
|  |  | ||||||
|  | @ -90,8 +90,7 @@ int main(int argc, char** argv) | ||||||
| 
 | 
 | ||||||
|     auto& right_panel = horizontal_container.add<GUI::Widget>(); |     auto& right_panel = horizontal_container.add<GUI::Widget>(); | ||||||
|     right_panel.set_fill_with_background_color(true); |     right_panel.set_fill_with_background_color(true); | ||||||
|     right_panel.set_size_policy(GUI::SizePolicy::Fixed, GUI::SizePolicy::Fill); |     right_panel.set_fixed_width(230); | ||||||
|     right_panel.set_preferred_size(230, 0); |  | ||||||
|     right_panel.set_layout<GUI::VerticalBoxLayout>(); |     right_panel.set_layout<GUI::VerticalBoxLayout>(); | ||||||
| 
 | 
 | ||||||
|     auto& layer_list_widget = right_panel.add<PixelPaint::LayerListWidget>(); |     auto& layer_list_widget = right_panel.add<PixelPaint::LayerListWidget>(); | ||||||
|  |  | ||||||
|  | @ -50,12 +50,10 @@ SoundPlayerWidget::SoundPlayerWidget(GUI::Window& window, NonnullRefPtr<Audio::C | ||||||
|     m_elapsed->set_frame_shape(Gfx::FrameShape::Container); |     m_elapsed->set_frame_shape(Gfx::FrameShape::Container); | ||||||
|     m_elapsed->set_frame_shadow(Gfx::FrameShadow::Sunken); |     m_elapsed->set_frame_shadow(Gfx::FrameShadow::Sunken); | ||||||
|     m_elapsed->set_frame_thickness(2); |     m_elapsed->set_frame_thickness(2); | ||||||
|     m_elapsed->set_size_policy(GUI::SizePolicy::Fixed, GUI::SizePolicy::Fill); |     m_elapsed->set_fixed_width(80); | ||||||
|     m_elapsed->set_preferred_size(80, 0); |  | ||||||
| 
 | 
 | ||||||
|     auto& sample_widget_container = status_widget.add<GUI::Widget>(); |     auto& sample_widget_container = status_widget.add<GUI::Widget>(); | ||||||
|     sample_widget_container.set_layout<GUI::HorizontalBoxLayout>(); |     sample_widget_container.set_layout<GUI::HorizontalBoxLayout>(); | ||||||
|     sample_widget_container.set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fill); |  | ||||||
| 
 | 
 | ||||||
|     m_sample_widget = sample_widget_container.add<SampleWidget>(); |     m_sample_widget = sample_widget_container.add<SampleWidget>(); | ||||||
| 
 | 
 | ||||||
|  | @ -63,8 +61,7 @@ SoundPlayerWidget::SoundPlayerWidget(GUI::Window& window, NonnullRefPtr<Audio::C | ||||||
|     m_remaining->set_frame_shape(Gfx::FrameShape::Container); |     m_remaining->set_frame_shape(Gfx::FrameShape::Container); | ||||||
|     m_remaining->set_frame_shadow(Gfx::FrameShadow::Sunken); |     m_remaining->set_frame_shadow(Gfx::FrameShadow::Sunken); | ||||||
|     m_remaining->set_frame_thickness(2); |     m_remaining->set_frame_thickness(2); | ||||||
|     m_remaining->set_size_policy(GUI::SizePolicy::Fixed, GUI::SizePolicy::Fill); |     m_remaining->set_fixed_width(80); | ||||||
|     m_remaining->set_preferred_size(80, 0); |  | ||||||
| 
 | 
 | ||||||
|     m_slider = add<Slider>(Orientation::Horizontal); |     m_slider = add<Slider>(Orientation::Horizontal); | ||||||
|     m_slider->set_min(0); |     m_slider->set_min(0); | ||||||
|  | @ -74,8 +71,7 @@ SoundPlayerWidget::SoundPlayerWidget(GUI::Window& window, NonnullRefPtr<Audio::C | ||||||
|     auto& control_widget = add<GUI::Widget>(); |     auto& control_widget = add<GUI::Widget>(); | ||||||
|     control_widget.set_fill_with_background_color(true); |     control_widget.set_fill_with_background_color(true); | ||||||
|     control_widget.set_layout<GUI::HorizontalBoxLayout>(); |     control_widget.set_layout<GUI::HorizontalBoxLayout>(); | ||||||
|     control_widget.set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed); |     control_widget.set_fixed_height(30); | ||||||
|     control_widget.set_preferred_size(0, 30); |  | ||||||
|     control_widget.layout()->set_margins({ 10, 2, 10, 2 }); |     control_widget.layout()->set_margins({ 10, 2, 10, 2 }); | ||||||
|     control_widget.layout()->set_spacing(10); |     control_widget.layout()->set_spacing(10); | ||||||
| 
 | 
 | ||||||
|  | @ -96,8 +92,7 @@ SoundPlayerWidget::SoundPlayerWidget(GUI::Window& window, NonnullRefPtr<Audio::C | ||||||
|     m_status->set_frame_shadow(Gfx::FrameShadow::Raised); |     m_status->set_frame_shadow(Gfx::FrameShadow::Raised); | ||||||
|     m_status->set_frame_thickness(4); |     m_status->set_frame_thickness(4); | ||||||
|     m_status->set_text_alignment(Gfx::TextAlignment::CenterLeft); |     m_status->set_text_alignment(Gfx::TextAlignment::CenterLeft); | ||||||
|     m_status->set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed); |     m_status->set_fixed_height(18); | ||||||
|     m_status->set_preferred_size(0, 18); |  | ||||||
|     m_status->set_text("No file open!"); |     m_status->set_text("No file open!"); | ||||||
| 
 | 
 | ||||||
|     update_position(0); |     update_position(0); | ||||||
|  |  | ||||||
|  | @ -72,14 +72,12 @@ CellTypeDialog::CellTypeDialog(const Vector<Position>& positions, Sheet& sheet, | ||||||
|     setup_tabs(tab_widget, positions, sheet); |     setup_tabs(tab_widget, positions, sheet); | ||||||
| 
 | 
 | ||||||
|     auto& buttonbox = main_widget.add<GUI::Widget>(); |     auto& buttonbox = main_widget.add<GUI::Widget>(); | ||||||
|     buttonbox.set_preferred_size({ 0, 20 }); |     buttonbox.set_fixed_height(20); | ||||||
|     buttonbox.set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed); |  | ||||||
|     auto& button_layout = buttonbox.set_layout<GUI::HorizontalBoxLayout>(); |     auto& button_layout = buttonbox.set_layout<GUI::HorizontalBoxLayout>(); | ||||||
|     button_layout.set_spacing(10); |     button_layout.set_spacing(10); | ||||||
|     button_layout.add_spacer(); |     button_layout.add_spacer(); | ||||||
|     auto& ok_button = buttonbox.add<GUI::Button>("OK"); |     auto& ok_button = buttonbox.add<GUI::Button>("OK"); | ||||||
|     ok_button.set_preferred_size({ 80, 0 }); |     ok_button.set_fixed_width(80); | ||||||
|     ok_button.set_size_policy(GUI::SizePolicy::Fixed, GUI::SizePolicy::Fill); |  | ||||||
|     ok_button.on_click = [&](auto) { done(ExecOK); }; |     ok_button.on_click = [&](auto) { done(ExecOK); }; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | @ -155,8 +153,7 @@ void CellTypeDialog::setup_tabs(GUI::TabWidget& tabs, const Vector<Position>& po | ||||||
|         left_side.set_layout<GUI::VerticalBoxLayout>(); |         left_side.set_layout<GUI::VerticalBoxLayout>(); | ||||||
|         auto& right_side = type_tab.add<GUI::Widget>(); |         auto& right_side = type_tab.add<GUI::Widget>(); | ||||||
|         right_side.set_layout<GUI::VerticalBoxLayout>(); |         right_side.set_layout<GUI::VerticalBoxLayout>(); | ||||||
|         right_side.set_preferred_size(170, 0); |         right_side.set_fixed_width(170); | ||||||
|         right_side.set_size_policy(GUI::SizePolicy::Fixed, GUI::SizePolicy::Fill); |  | ||||||
| 
 | 
 | ||||||
|         auto& type_list = left_side.add<GUI::ListView>(); |         auto& type_list = left_side.add<GUI::ListView>(); | ||||||
|         type_list.set_model(*GUI::ItemListModel<String>::create(g_types)); |         type_list.set_model(*GUI::ItemListModel<String>::create(g_types)); | ||||||
|  | @ -179,10 +176,8 @@ void CellTypeDialog::setup_tabs(GUI::TabWidget& tabs, const Vector<Position>& po | ||||||
|             if (m_length > -1) |             if (m_length > -1) | ||||||
|                 spinbox.set_value(m_length); |                 spinbox.set_value(m_length); | ||||||
| 
 | 
 | ||||||
|             checkbox.set_preferred_size(0, 20); |             checkbox.set_fixed_height(20); | ||||||
|             spinbox.set_preferred_size(0, 20); |             spinbox.set_fixed_height(20); | ||||||
|             checkbox.set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed); |  | ||||||
|             spinbox.set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed); |  | ||||||
| 
 | 
 | ||||||
|             checkbox.on_checked = [&](auto checked) { |             checkbox.on_checked = [&](auto checked) { | ||||||
|                 spinbox.set_enabled(checked); |                 spinbox.set_enabled(checked); | ||||||
|  | @ -203,10 +198,8 @@ void CellTypeDialog::setup_tabs(GUI::TabWidget& tabs, const Vector<Position>& po | ||||||
|             editor.set_enabled(!m_format.is_empty()); |             editor.set_enabled(!m_format.is_empty()); | ||||||
|             editor.set_text(m_format); |             editor.set_text(m_format); | ||||||
| 
 | 
 | ||||||
|             checkbox.set_preferred_size(0, 20); |             checkbox.set_fixed_height(20); | ||||||
|             editor.set_preferred_size(0, 20); |             editor.set_fixed_height(20); | ||||||
|             checkbox.set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed); |  | ||||||
|             editor.set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed); |  | ||||||
| 
 | 
 | ||||||
|             checkbox.on_checked = [&](auto checked) { |             checkbox.on_checked = [&](auto checked) { | ||||||
|                 editor.set_enabled(checked); |                 editor.set_enabled(checked); | ||||||
|  | @ -229,16 +222,14 @@ void CellTypeDialog::setup_tabs(GUI::TabWidget& tabs, const Vector<Position>& po | ||||||
|             auto& horizontal_alignment_selection_container = alignment_tab.add<GUI::Widget>(); |             auto& horizontal_alignment_selection_container = alignment_tab.add<GUI::Widget>(); | ||||||
|             horizontal_alignment_selection_container.set_layout<GUI::HorizontalBoxLayout>(); |             horizontal_alignment_selection_container.set_layout<GUI::HorizontalBoxLayout>(); | ||||||
|             horizontal_alignment_selection_container.layout()->set_margins({ 0, 4, 0, 0 }); |             horizontal_alignment_selection_container.layout()->set_margins({ 0, 4, 0, 0 }); | ||||||
|             horizontal_alignment_selection_container.set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed); |             horizontal_alignment_selection_container.set_fixed_height(22); | ||||||
|             horizontal_alignment_selection_container.set_preferred_size(0, 22); |  | ||||||
| 
 | 
 | ||||||
|             auto& horizontal_alignment_label = horizontal_alignment_selection_container.add<GUI::Label>(); |             auto& horizontal_alignment_label = horizontal_alignment_selection_container.add<GUI::Label>(); | ||||||
|             horizontal_alignment_label.set_text_alignment(Gfx::TextAlignment::CenterLeft); |             horizontal_alignment_label.set_text_alignment(Gfx::TextAlignment::CenterLeft); | ||||||
|             horizontal_alignment_label.set_text("Horizontal Text Alignment"); |             horizontal_alignment_label.set_text("Horizontal Text Alignment"); | ||||||
| 
 | 
 | ||||||
|             auto& horizontal_combobox = alignment_tab.add<GUI::ComboBox>(); |             auto& horizontal_combobox = alignment_tab.add<GUI::ComboBox>(); | ||||||
|             horizontal_combobox.set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed); |             horizontal_combobox.set_fixed_height(22); | ||||||
|             horizontal_combobox.set_preferred_size(0, 22); |  | ||||||
|             horizontal_combobox.set_only_allow_values_from_model(true); |             horizontal_combobox.set_only_allow_values_from_model(true); | ||||||
|             horizontal_combobox.set_model(*GUI::ItemListModel<String>::create(g_horizontal_alignments)); |             horizontal_combobox.set_model(*GUI::ItemListModel<String>::create(g_horizontal_alignments)); | ||||||
|             horizontal_combobox.set_selected_index((int)m_horizontal_alignment); |             horizontal_combobox.set_selected_index((int)m_horizontal_alignment); | ||||||
|  | @ -264,16 +255,14 @@ void CellTypeDialog::setup_tabs(GUI::TabWidget& tabs, const Vector<Position>& po | ||||||
|             auto& vertical_alignment_container = alignment_tab.add<GUI::Widget>(); |             auto& vertical_alignment_container = alignment_tab.add<GUI::Widget>(); | ||||||
|             vertical_alignment_container.set_layout<GUI::HorizontalBoxLayout>(); |             vertical_alignment_container.set_layout<GUI::HorizontalBoxLayout>(); | ||||||
|             vertical_alignment_container.layout()->set_margins({ 0, 4, 0, 0 }); |             vertical_alignment_container.layout()->set_margins({ 0, 4, 0, 0 }); | ||||||
|             vertical_alignment_container.set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed); |             vertical_alignment_container.set_fixed_height(22); | ||||||
|             vertical_alignment_container.set_preferred_size(0, 22); |  | ||||||
| 
 | 
 | ||||||
|             auto& vertical_alignment_label = vertical_alignment_container.add<GUI::Label>(); |             auto& vertical_alignment_label = vertical_alignment_container.add<GUI::Label>(); | ||||||
|             vertical_alignment_label.set_text_alignment(Gfx::TextAlignment::CenterLeft); |             vertical_alignment_label.set_text_alignment(Gfx::TextAlignment::CenterLeft); | ||||||
|             vertical_alignment_label.set_text("Vertical Text Alignment"); |             vertical_alignment_label.set_text("Vertical Text Alignment"); | ||||||
| 
 | 
 | ||||||
|             auto& vertical_combobox = alignment_tab.add<GUI::ComboBox>(); |             auto& vertical_combobox = alignment_tab.add<GUI::ComboBox>(); | ||||||
|             vertical_combobox.set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed); |             vertical_combobox.set_fixed_height(22); | ||||||
|             vertical_combobox.set_preferred_size(0, 22); |  | ||||||
|             vertical_combobox.set_only_allow_values_from_model(true); |             vertical_combobox.set_only_allow_values_from_model(true); | ||||||
|             vertical_combobox.set_model(*GUI::ItemListModel<String>::create(g_vertical_alignments)); |             vertical_combobox.set_model(*GUI::ItemListModel<String>::create(g_vertical_alignments)); | ||||||
|             vertical_combobox.set_selected_index((int)m_vertical_alignment); |             vertical_combobox.set_selected_index((int)m_vertical_alignment); | ||||||
|  | @ -303,8 +292,7 @@ void CellTypeDialog::setup_tabs(GUI::TabWidget& tabs, const Vector<Position>& po | ||||||
|             auto& static_formatting_container = colors_tab.add<GUI::Widget>(); |             auto& static_formatting_container = colors_tab.add<GUI::Widget>(); | ||||||
|             static_formatting_container.set_layout<GUI::VerticalBoxLayout>(); |             static_formatting_container.set_layout<GUI::VerticalBoxLayout>(); | ||||||
|             static_formatting_container.layout()->set_margins({ 0, 0, 0, 0 }); |             static_formatting_container.layout()->set_margins({ 0, 0, 0, 0 }); | ||||||
|             static_formatting_container.set_preferred_size(0, 44); |             static_formatting_container.set_fixed_height(44); | ||||||
|             static_formatting_container.set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed); |  | ||||||
| 
 | 
 | ||||||
|             // Foreground
 |             // Foreground
 | ||||||
|             { |             { | ||||||
|  | @ -312,16 +300,14 @@ void CellTypeDialog::setup_tabs(GUI::TabWidget& tabs, const Vector<Position>& po | ||||||
|                 auto& foreground_container = static_formatting_container.add<GUI::Widget>(); |                 auto& foreground_container = static_formatting_container.add<GUI::Widget>(); | ||||||
|                 foreground_container.set_layout<GUI::HorizontalBoxLayout>(); |                 foreground_container.set_layout<GUI::HorizontalBoxLayout>(); | ||||||
|                 foreground_container.layout()->set_margins({ 0, 4, 0, 0 }); |                 foreground_container.layout()->set_margins({ 0, 4, 0, 0 }); | ||||||
|                 foreground_container.set_preferred_size(0, 22); |                 foreground_container.set_fixed_height(22); | ||||||
|                 foreground_container.set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed); |  | ||||||
| 
 | 
 | ||||||
|                 auto& foreground_label = foreground_container.add<GUI::Label>(); |                 auto& foreground_label = foreground_container.add<GUI::Label>(); | ||||||
|                 foreground_label.set_text_alignment(Gfx::TextAlignment::CenterLeft); |                 foreground_label.set_text_alignment(Gfx::TextAlignment::CenterLeft); | ||||||
|                 foreground_label.set_text("Static Foreground Color"); |                 foreground_label.set_text("Static Foreground Color"); | ||||||
| 
 | 
 | ||||||
|                 auto& foreground_selector = foreground_container.add<GUI::ColorInput>(); |                 auto& foreground_selector = foreground_container.add<GUI::ColorInput>(); | ||||||
|                 foreground_selector.set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed); |                 foreground_selector.set_fixed_height(22); | ||||||
|                 foreground_selector.set_preferred_size(0, 22); |  | ||||||
|                 if (m_static_format.foreground_color.has_value()) |                 if (m_static_format.foreground_color.has_value()) | ||||||
|                     foreground_selector.set_color(m_static_format.foreground_color.value()); |                     foreground_selector.set_color(m_static_format.foreground_color.value()); | ||||||
|                 foreground_selector.on_change = [&]() { |                 foreground_selector.on_change = [&]() { | ||||||
|  | @ -335,16 +321,14 @@ void CellTypeDialog::setup_tabs(GUI::TabWidget& tabs, const Vector<Position>& po | ||||||
|                 auto& background_container = static_formatting_container.add<GUI::Widget>(); |                 auto& background_container = static_formatting_container.add<GUI::Widget>(); | ||||||
|                 background_container.set_layout<GUI::HorizontalBoxLayout>(); |                 background_container.set_layout<GUI::HorizontalBoxLayout>(); | ||||||
|                 background_container.layout()->set_margins({ 0, 4, 0, 0 }); |                 background_container.layout()->set_margins({ 0, 4, 0, 0 }); | ||||||
|                 background_container.set_preferred_size(0, 22); |                 background_container.set_fixed_height(22); | ||||||
|                 background_container.set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed); |  | ||||||
| 
 | 
 | ||||||
|                 auto& background_label = background_container.add<GUI::Label>(); |                 auto& background_label = background_container.add<GUI::Label>(); | ||||||
|                 background_label.set_text_alignment(Gfx::TextAlignment::CenterLeft); |                 background_label.set_text_alignment(Gfx::TextAlignment::CenterLeft); | ||||||
|                 background_label.set_text("Static Background Color"); |                 background_label.set_text("Static Background Color"); | ||||||
| 
 | 
 | ||||||
|                 auto& background_selector = background_container.add<GUI::ColorInput>(); |                 auto& background_selector = background_container.add<GUI::ColorInput>(); | ||||||
|                 background_selector.set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed); |                 background_selector.set_fixed_height(22); | ||||||
|                 background_selector.set_preferred_size(0, 22); |  | ||||||
|                 if (m_static_format.background_color.has_value()) |                 if (m_static_format.background_color.has_value()) | ||||||
|                     background_selector.set_color(m_static_format.background_color.value()); |                     background_selector.set_color(m_static_format.background_color.value()); | ||||||
|                 background_selector.on_change = [&]() { |                 background_selector.on_change = [&]() { | ||||||
|  |  | ||||||
|  | @ -11,10 +11,7 @@ | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     @GUI::Widget { |     @GUI::Widget { | ||||||
|         vertical_size_policy: "Fixed" |         fixed_height: 20 | ||||||
|         horizontal_size_policy: "Fill" |  | ||||||
|         preferred_width: 0 |  | ||||||
|         preferred_height: 20 |  | ||||||
| 
 | 
 | ||||||
|         layout: @GUI::HorizontalBoxLayout { |         layout: @GUI::HorizontalBoxLayout { | ||||||
|             spacing: 10 |             spacing: 10 | ||||||
|  | @ -23,19 +20,15 @@ | ||||||
|         @GUI::Button { |         @GUI::Button { | ||||||
|             name: "add_button" |             name: "add_button" | ||||||
|             text: "Add" |             text: "Add" | ||||||
|             horizontal_size_policy: "Fixed" |             fixed_width: 100 | ||||||
|             vertical_size_policy: "Fixed" |             fixed_height: 20 | ||||||
|             preferred_width: 100 |  | ||||||
|             preferred_height: 20 |  | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|         @GUI::Button { |         @GUI::Button { | ||||||
|             name: "remove_button" |             name: "remove_button" | ||||||
|             text: "Remove" |             text: "Remove" | ||||||
|             horizontal_size_policy: "Fixed" |             fixed_width: 100 | ||||||
|             vertical_size_policy: "Fixed" |             fixed_height: 20 | ||||||
|             preferred_width: 100 |  | ||||||
|             preferred_height: 20 |  | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
| } | } | ||||||
|  |  | ||||||
|  | @ -8,22 +8,17 @@ | ||||||
|             spacing: 10 |             spacing: 10 | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|         vertical_size_policy: "Fixed" |         fixed_height: 25 | ||||||
|         preferred_height: 25 |  | ||||||
| 
 | 
 | ||||||
|         @GUI::Label { |         @GUI::Label { | ||||||
|             text: "if..." |             text: "if..." | ||||||
|             horizontal_size_policy: "Fixed" |             fixed_width: 40 | ||||||
|             vertical_size_policy: "Fixed" |             fixed_height: 25 | ||||||
|             preferred_width: 40 |  | ||||||
|             preferred_height: 25 |  | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|         @GUI::TextEditor { |         @GUI::TextEditor { | ||||||
|             name: "formula_editor" |             name: "formula_editor" | ||||||
|             horizontal_size_policy: "Fill" |             fixed_height: 25 | ||||||
|             vertical_size_policy: "Fixed" |  | ||||||
|             preferred_height: 25 |  | ||||||
|             tooltip: "Use 'value' to refer to the current cell's value" |             tooltip: "Use 'value' to refer to the current cell's value" | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
|  | @ -33,21 +28,17 @@ | ||||||
|             spacing: 10 |             spacing: 10 | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|         vertical_size_policy: "Fixed" |         fixed_height: 25 | ||||||
|         preferred_height: 25 |  | ||||||
| 
 | 
 | ||||||
|         @GUI::Label { |         @GUI::Label { | ||||||
|             text: "Foreground..." |             text: "Foreground..." | ||||||
|             horizontal_size_policy: "Fixed" |             fixed_width: 150 | ||||||
|             vertical_size_policy: "Fixed" |             fixed_height: 25 | ||||||
|             preferred_width: 150 |  | ||||||
|             preferred_height: 25 |  | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|         @GUI::ColorInput { |         @GUI::ColorInput { | ||||||
|             name: "foreground_input" |             name: "foreground_input" | ||||||
|             vertical_size_policy: "Fixed" |             fixed_height: 25 | ||||||
|             preferred_height: 25 |  | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|  | @ -56,21 +47,17 @@ | ||||||
|             spacing: 10 |             spacing: 10 | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|         vertical_size_policy: "Fixed" |         fixed_height: 25 | ||||||
|         preferred_height: 25 |  | ||||||
| 
 | 
 | ||||||
|         @GUI::Label { |         @GUI::Label { | ||||||
|             text: "Background..." |             text: "Background..." | ||||||
|             horizontal_size_policy: "Fixed" |             fixed_width: 150 | ||||||
|             vertical_size_policy: "Fixed" |             fixed_height: 25 | ||||||
|             preferred_width: 150 |  | ||||||
|             preferred_height: 25 |  | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|         @GUI::ColorInput { |         @GUI::ColorInput { | ||||||
|             name: "background_input" |             name: "background_input" | ||||||
|             vertical_size_policy: "Fixed" |             fixed_height: 25 | ||||||
|             preferred_height: 25 |  | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
| } | } | ||||||
|  |  | ||||||
|  | @ -93,8 +93,7 @@ HelpWindow::HelpWindow(GUI::Window* parent) | ||||||
|     auto& splitter = widget.add<GUI::HorizontalSplitter>(); |     auto& splitter = widget.add<GUI::HorizontalSplitter>(); | ||||||
|     auto& left_frame = splitter.add<GUI::Frame>(); |     auto& left_frame = splitter.add<GUI::Frame>(); | ||||||
|     left_frame.set_layout<GUI::VerticalBoxLayout>().set_margins({ 0, 0, 0, 0 }); |     left_frame.set_layout<GUI::VerticalBoxLayout>().set_margins({ 0, 0, 0, 0 }); | ||||||
|     left_frame.set_preferred_size(100, 0); |     left_frame.set_fixed_width(100); | ||||||
|     left_frame.set_size_policy(GUI::SizePolicy::Fixed, GUI::SizePolicy::Fill); |  | ||||||
|     m_listview = left_frame.add<GUI::ListView>(); |     m_listview = left_frame.add<GUI::ListView>(); | ||||||
|     m_listview->set_activates_on_selection(true); |     m_listview->set_activates_on_selection(true); | ||||||
|     m_listview->set_model(HelpListModel::create()); |     m_listview->set_model(HelpListModel::create()); | ||||||
|  |  | ||||||
|  | @ -51,15 +51,12 @@ SpreadsheetWidget::SpreadsheetWidget(NonnullRefPtrVector<Sheet>&& sheets, bool s | ||||||
| 
 | 
 | ||||||
|     auto& top_bar = container.add<GUI::Frame>(); |     auto& top_bar = container.add<GUI::Frame>(); | ||||||
|     top_bar.set_layout<GUI::HorizontalBoxLayout>().set_spacing(1); |     top_bar.set_layout<GUI::HorizontalBoxLayout>().set_spacing(1); | ||||||
|     top_bar.set_preferred_size(0, 26); |     top_bar.set_fixed_height(26); | ||||||
|     top_bar.set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed); |  | ||||||
|     auto& current_cell_label = top_bar.add<GUI::Label>(""); |     auto& current_cell_label = top_bar.add<GUI::Label>(""); | ||||||
|     current_cell_label.set_preferred_size(50, 0); |     current_cell_label.set_fixed_width(50); | ||||||
|     current_cell_label.set_size_policy(GUI::SizePolicy::Fixed, GUI::SizePolicy::Fill); |  | ||||||
| 
 | 
 | ||||||
|     auto& help_button = top_bar.add<GUI::Button>("🛈"); |     auto& help_button = top_bar.add<GUI::Button>("🛈"); | ||||||
|     help_button.set_preferred_size(20, 20); |     help_button.set_fixed_size(20, 20); | ||||||
|     help_button.set_size_policy(GUI::SizePolicy::Fixed, GUI::SizePolicy::Fixed); |  | ||||||
|     help_button.on_click = [&](auto) { |     help_button.on_click = [&](auto) { | ||||||
|         auto docs = m_selected_view->sheet().gather_documentation(); |         auto docs = m_selected_view->sheet().gather_documentation(); | ||||||
|         auto help_window = HelpWindow::the(); |         auto help_window = HelpWindow::the(); | ||||||
|  | @ -89,7 +86,6 @@ SpreadsheetWidget::SpreadsheetWidget(NonnullRefPtrVector<Sheet>&& sheets, bool s | ||||||
|     inline_widget.set_layout<GUI::VerticalBoxLayout>().set_margins({ 4, 4, 4, 4 }); |     inline_widget.set_layout<GUI::VerticalBoxLayout>().set_margins({ 4, 4, 4, 4 }); | ||||||
|     inline_widget.set_frame_shape(Gfx::FrameShape::Box); |     inline_widget.set_frame_shape(Gfx::FrameShape::Box); | ||||||
|     m_inline_documentation_label = inline_widget.add<GUI::Label>(); |     m_inline_documentation_label = inline_widget.add<GUI::Label>(); | ||||||
|     m_inline_documentation_label->set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fill); |  | ||||||
|     m_inline_documentation_label->set_fill_with_background_color(true); |     m_inline_documentation_label->set_fill_with_background_color(true); | ||||||
|     m_inline_documentation_label->set_autosize(false); |     m_inline_documentation_label->set_autosize(false); | ||||||
|     m_inline_documentation_label->set_text_alignment(Gfx::TextAlignment::CenterLeft); |     m_inline_documentation_label->set_text_alignment(Gfx::TextAlignment::CenterLeft); | ||||||
|  |  | ||||||
|  | @ -192,8 +192,7 @@ static RefPtr<GUI::Window> create_settings_window(TerminalWidget& terminal) | ||||||
|     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.set_layout<GUI::VerticalBoxLayout>(); | ||||||
|     radio_container.layout()->set_margins({ 6, 16, 6, 6 }); |     radio_container.layout()->set_margins({ 6, 16, 6, 6 }); | ||||||
|     radio_container.set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed); |     radio_container.set_fixed_height(80); | ||||||
|     radio_container.set_preferred_size(100, 80); |  | ||||||
| 
 | 
 | ||||||
|     auto& sysbell_radio = radio_container.add<GUI::RadioButton>("Use (Audible) System Bell"); |     auto& sysbell_radio = radio_container.add<GUI::RadioButton>("Use (Audible) System Bell"); | ||||||
|     auto& visbell_radio = radio_container.add<GUI::RadioButton>("Use (Visual) Terminal Bell"); |     auto& visbell_radio = radio_container.add<GUI::RadioButton>("Use (Visual) Terminal Bell"); | ||||||
|  | @ -224,8 +223,7 @@ static RefPtr<GUI::Window> create_settings_window(TerminalWidget& terminal) | ||||||
|     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.set_layout<GUI::VerticalBoxLayout>(); | ||||||
|     slider_container.layout()->set_margins({ 6, 16, 6, 6 }); |     slider_container.layout()->set_margins({ 6, 16, 6, 6 }); | ||||||
|     slider_container.set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed); |     slider_container.set_fixed_height(50); | ||||||
|     slider_container.set_preferred_size(100, 50); |  | ||||||
|     auto& slider = slider_container.add<GUI::HorizontalSlider>(); |     auto& slider = slider_container.add<GUI::HorizontalSlider>(); | ||||||
| 
 | 
 | ||||||
|     slider.on_value_changed = [&terminal](int value) { |     slider.on_value_changed = [&terminal](int value) { | ||||||
|  | @ -238,8 +236,7 @@ static RefPtr<GUI::Window> create_settings_window(TerminalWidget& terminal) | ||||||
|     auto& spinbox_container = settings.add<GUI::GroupBox>("Scroll Length"); |     auto& spinbox_container = settings.add<GUI::GroupBox>("Scroll Length"); | ||||||
|     spinbox_container.set_layout<GUI::VerticalBoxLayout>(); |     spinbox_container.set_layout<GUI::VerticalBoxLayout>(); | ||||||
|     spinbox_container.layout()->set_margins({ 6, 16, 6, 6 }); |     spinbox_container.layout()->set_margins({ 6, 16, 6, 6 }); | ||||||
|     spinbox_container.set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed); |     spinbox_container.set_fixed_height(46); | ||||||
|     spinbox_container.set_preferred_size(100, 46); |  | ||||||
| 
 | 
 | ||||||
|     auto& spinbox = spinbox_container.add<GUI::SpinBox>(); |     auto& spinbox = spinbox_container.add<GUI::SpinBox>(); | ||||||
|     spinbox.set_min(1); |     spinbox.set_min(1); | ||||||
|  | @ -251,8 +248,7 @@ static RefPtr<GUI::Window> create_settings_window(TerminalWidget& terminal) | ||||||
|     auto& history_size_spinbox_container = settings.add<GUI::GroupBox>("Maximum scrollback history lines"); |     auto& history_size_spinbox_container = settings.add<GUI::GroupBox>("Maximum scrollback history lines"); | ||||||
|     history_size_spinbox_container.set_layout<GUI::VerticalBoxLayout>(); |     history_size_spinbox_container.set_layout<GUI::VerticalBoxLayout>(); | ||||||
|     history_size_spinbox_container.layout()->set_margins({ 6, 16, 6, 6 }); |     history_size_spinbox_container.layout()->set_margins({ 6, 16, 6, 6 }); | ||||||
|     history_size_spinbox_container.set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed); |     history_size_spinbox_container.set_fixed_height(46); | ||||||
|     history_size_spinbox_container.set_preferred_size(100, 46); |  | ||||||
| 
 | 
 | ||||||
|     auto& history_size_spinbox = history_size_spinbox_container.add<GUI::SpinBox>(); |     auto& history_size_spinbox = history_size_spinbox_container.add<GUI::SpinBox>(); | ||||||
|     history_size_spinbox.set_range(0, 40960); |     history_size_spinbox.set_range(0, 40960); | ||||||
|  | @ -281,12 +277,10 @@ static RefPtr<GUI::Window> create_find_window(TerminalWidget& terminal) | ||||||
|     auto& find = search.add<GUI::Widget>(); |     auto& find = search.add<GUI::Widget>(); | ||||||
|     find.set_layout<GUI::HorizontalBoxLayout>(); |     find.set_layout<GUI::HorizontalBoxLayout>(); | ||||||
|     find.layout()->set_margins({ 4, 4, 4, 4 }); |     find.layout()->set_margins({ 4, 4, 4, 4 }); | ||||||
|     find.set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed); |     find.set_fixed_height(30); | ||||||
|     find.set_preferred_height(30); |  | ||||||
| 
 | 
 | ||||||
|     auto& find_textbox = find.add<GUI::TextBox>(); |     auto& find_textbox = find.add<GUI::TextBox>(); | ||||||
|     find_textbox.set_horizontal_size_policy(GUI::SizePolicy::Fixed); |     find_textbox.set_fixed_width(230); | ||||||
|     find_textbox.set_preferred_width(230); |  | ||||||
|     find_textbox.set_focus(true); |     find_textbox.set_focus(true); | ||||||
|     if (terminal.has_selection()) { |     if (terminal.has_selection()) { | ||||||
|         String selected_text = terminal.selected_text(); |         String selected_text = terminal.selected_text(); | ||||||
|  | @ -294,12 +288,10 @@ static RefPtr<GUI::Window> create_find_window(TerminalWidget& terminal) | ||||||
|         find_textbox.set_text(selected_text); |         find_textbox.set_text(selected_text); | ||||||
|     } |     } | ||||||
|     auto& find_backwards = find.add<GUI::Button>(); |     auto& find_backwards = find.add<GUI::Button>(); | ||||||
|     find_backwards.set_horizontal_size_policy(GUI::SizePolicy::Fixed); |     find_backwards.set_fixed_width(25); | ||||||
|     find_backwards.set_preferred_width(25); |  | ||||||
|     find_backwards.set_icon(Gfx::Bitmap::load_from_file("/res/icons/16x16/upward-triangle.png")); |     find_backwards.set_icon(Gfx::Bitmap::load_from_file("/res/icons/16x16/upward-triangle.png")); | ||||||
|     auto& find_forwards = find.add<GUI::Button>(); |     auto& find_forwards = find.add<GUI::Button>(); | ||||||
|     find_forwards.set_horizontal_size_policy(GUI::SizePolicy::Fixed); |     find_forwards.set_fixed_width(25); | ||||||
|     find_forwards.set_preferred_width(25); |  | ||||||
|     find_forwards.set_icon(Gfx::Bitmap::load_from_file("/res/icons/16x16/downward-triangle.png")); |     find_forwards.set_icon(Gfx::Bitmap::load_from_file("/res/icons/16x16/downward-triangle.png")); | ||||||
| 
 | 
 | ||||||
|     find_textbox.on_return_pressed = [&]() { |     find_textbox.on_return_pressed = [&]() { | ||||||
|  | @ -307,11 +299,9 @@ static RefPtr<GUI::Window> create_find_window(TerminalWidget& terminal) | ||||||
|     }; |     }; | ||||||
| 
 | 
 | ||||||
|     auto& match_case = search.add<GUI::CheckBox>("Case sensitive"); |     auto& match_case = search.add<GUI::CheckBox>("Case sensitive"); | ||||||
|     match_case.set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed); |     match_case.set_fixed_height(22); | ||||||
|     match_case.set_preferred_size(0, 22); |  | ||||||
|     auto& wrap_around = search.add<GUI::CheckBox>("Wrap around"); |     auto& wrap_around = search.add<GUI::CheckBox>("Wrap around"); | ||||||
|     wrap_around.set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed); |     wrap_around.set_fixed_height(22); | ||||||
|     wrap_around.set_preferred_size(0, 22); |  | ||||||
| 
 | 
 | ||||||
|     find_backwards.on_click = [&](auto) { |     find_backwards.on_click = [&](auto) { | ||||||
|         auto needle = find_textbox.text(); |         auto needle = find_textbox.text(); | ||||||
|  |  | ||||||
|  | @ -246,8 +246,7 @@ TextEditorWidget::TextEditorWidget() | ||||||
|     }; |     }; | ||||||
| 
 | 
 | ||||||
|     m_find_regex_button = m_find_widget->add<GUI::Button>(".*"); |     m_find_regex_button = m_find_widget->add<GUI::Button>(".*"); | ||||||
|     m_find_regex_button->set_size_policy(GUI::SizePolicy::Fixed, GUI::SizePolicy::Fill); |     m_find_regex_button->set_fixed_width(20); | ||||||
|     m_find_regex_button->set_preferred_size(20, 0); |  | ||||||
|     m_find_regex_button->set_action(*m_find_regex_action); |     m_find_regex_button->set_action(*m_find_regex_action); | ||||||
| 
 | 
 | ||||||
|     m_find_textbox->on_escape_pressed = [this] { |     m_find_textbox->on_escape_pressed = [this] { | ||||||
|  |  | ||||||
|  | @ -27,9 +27,7 @@ | ||||||
|         name: "find_replace_widget" |         name: "find_replace_widget" | ||||||
|         visible: false |         visible: false | ||||||
|         fill_with_background_color: true |         fill_with_background_color: true | ||||||
|         horizontal_size_policy: "Fill" |         fixed_height: 48 | ||||||
|         vertical_size_policy: "Fixed" |  | ||||||
|         preferred_height: 48 |  | ||||||
| 
 | 
 | ||||||
|         layout: @GUI::VerticalBoxLayout { |         layout: @GUI::VerticalBoxLayout { | ||||||
|             margins: [2, 2, 2, 4] |             margins: [2, 2, 2, 4] | ||||||
|  | @ -38,9 +36,7 @@ | ||||||
|         @GUI::Widget { |         @GUI::Widget { | ||||||
|             name: "find_widget" |             name: "find_widget" | ||||||
|             fill_with_background_color: true |             fill_with_background_color: true | ||||||
|             horizontal_size_policy: "Fill" |             fixed_height: 22 | ||||||
|             vertical_size_policy: "Fixed" |  | ||||||
|             preferred_height: 22 |  | ||||||
| 
 | 
 | ||||||
|             layout: @GUI::HorizontalBoxLayout { |             layout: @GUI::HorizontalBoxLayout { | ||||||
|             } |             } | ||||||
|  | @ -48,26 +44,20 @@ | ||||||
|             @GUI::Button { |             @GUI::Button { | ||||||
|                 name: "find_previous_button" |                 name: "find_previous_button" | ||||||
|                 text: "Find previous" |                 text: "Find previous" | ||||||
|                 horizontal_size_policy: "Fixed" |                 fixed_width: 150 | ||||||
|                 vertical_size_policy: "Fill" |  | ||||||
|                 preferred_width: 150 |  | ||||||
|             } |             } | ||||||
| 
 | 
 | ||||||
|             @GUI::Button { |             @GUI::Button { | ||||||
|                 name: "find_next_button" |                 name: "find_next_button" | ||||||
|                 text: "Find next" |                 text: "Find next" | ||||||
|                 horizontal_size_policy: "Fixed" |                 fixed_width: 150 | ||||||
|                 vertical_size_policy: "Fill" |  | ||||||
|                 preferred_width: 150 |  | ||||||
|             } |             } | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|         @GUI::Widget { |         @GUI::Widget { | ||||||
|             name: "replace_widget" |             name: "replace_widget" | ||||||
|             fill_with_background_color: true |             fill_with_background_color: true | ||||||
|             horizontal_size_policy: "Fill" |             fixed_height: 22 | ||||||
|             vertical_size_policy: "Fixed" |  | ||||||
|             preferred_height: 22 |  | ||||||
| 
 | 
 | ||||||
|             layout: @GUI::HorizontalBoxLayout { |             layout: @GUI::HorizontalBoxLayout { | ||||||
|             } |             } | ||||||
|  | @ -75,25 +65,19 @@ | ||||||
|             @GUI::Button { |             @GUI::Button { | ||||||
|                 name: "replace_previous_button" |                 name: "replace_previous_button" | ||||||
|                 text: "Replace previous" |                 text: "Replace previous" | ||||||
|                 horizontal_size_policy: "Fixed" |                 fixed_width: 100 | ||||||
|                 vertical_size_policy: "Fill" |  | ||||||
|                 preferred_width: 100 |  | ||||||
|             } |             } | ||||||
| 
 | 
 | ||||||
|             @GUI::Button { |             @GUI::Button { | ||||||
|                 name: "replace_next_button" |                 name: "replace_next_button" | ||||||
|                 text: "Replace next" |                 text: "Replace next" | ||||||
|                 horizontal_size_policy: "Fixed" |                 fixed_width: 100 | ||||||
|                 vertical_size_policy: "Fill" |  | ||||||
|                 preferred_width: 100 |  | ||||||
|             } |             } | ||||||
| 
 | 
 | ||||||
|             @GUI::Button { |             @GUI::Button { | ||||||
|                 name: "replace_all_button" |                 name: "replace_all_button" | ||||||
|                 text: "Replace all" |                 text: "Replace all" | ||||||
|                 horizontal_size_policy: "Fixed" |                 fixed_width: 100 | ||||||
|                 vertical_size_policy: "Fill" |  | ||||||
|                 preferred_width: 100 |  | ||||||
|             } |             } | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  | @ -99,13 +99,11 @@ int main(int argc, char** argv) | ||||||
|     main_widget.set_layout<GUI::VerticalBoxLayout>(); |     main_widget.set_layout<GUI::VerticalBoxLayout>(); | ||||||
| 
 | 
 | ||||||
|     auto& preview_widget = main_widget.add<ThemeEditor::PreviewWidget>(app->palette()); |     auto& preview_widget = main_widget.add<ThemeEditor::PreviewWidget>(app->palette()); | ||||||
|     preview_widget.set_preferred_size(480, 360); |     preview_widget.set_fixed_size(480, 360); | ||||||
|     preview_widget.set_size_policy(GUI::SizePolicy::Fixed, GUI::SizePolicy::Fixed); |  | ||||||
| 
 | 
 | ||||||
|     auto& horizontal_container = main_widget.add<GUI::Widget>(); |     auto& horizontal_container = main_widget.add<GUI::Widget>(); | ||||||
|     horizontal_container.set_layout<GUI::HorizontalBoxLayout>(); |     horizontal_container.set_layout<GUI::HorizontalBoxLayout>(); | ||||||
|     horizontal_container.set_preferred_size(480, 20); |     horizontal_container.set_fixed_size(480, 20); | ||||||
|     horizontal_container.set_size_policy(GUI::SizePolicy::Fixed, GUI::SizePolicy::Fixed); |  | ||||||
| 
 | 
 | ||||||
|     auto& combo_box = horizontal_container.add<GUI::ComboBox>(); |     auto& combo_box = horizontal_container.add<GUI::ComboBox>(); | ||||||
|     auto& color_input = horizontal_container.add<GUI::ColorInput>(); |     auto& color_input = horizontal_container.add<GUI::ColorInput>(); | ||||||
|  |  | ||||||
|  | @ -136,6 +136,5 @@ void TextWidget::wrap_and_set_height() | ||||||
| 
 | 
 | ||||||
|     m_lines = lines; |     m_lines = lines; | ||||||
| 
 | 
 | ||||||
|     set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed); |     set_fixed_height(m_lines.size() * m_line_height + frame_thickness() * 2); | ||||||
|     set_preferred_size(0, m_lines.size() * m_line_height + frame_thickness() * 2); |  | ||||||
| } | } | ||||||
|  |  | ||||||
|  | @ -148,7 +148,6 @@ int main(int argc, char** argv) | ||||||
|     background.set_layout<GUI::VerticalBoxLayout>(); |     background.set_layout<GUI::VerticalBoxLayout>(); | ||||||
|     background.layout()->set_margins({ 16, 8, 16, 8 }); |     background.layout()->set_margins({ 16, 8, 16, 8 }); | ||||||
|     background.layout()->set_spacing(8); |     background.layout()->set_spacing(8); | ||||||
|     background.set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fill); |  | ||||||
| 
 | 
 | ||||||
|     //
 |     //
 | ||||||
|     // header
 |     // header
 | ||||||
|  | @ -158,8 +157,7 @@ int main(int argc, char** argv) | ||||||
|     header.set_font(Gfx::Font::load_from_file("/res/fonts/PebbletonBold14.font")); |     header.set_font(Gfx::Font::load_from_file("/res/fonts/PebbletonBold14.font")); | ||||||
|     header.set_text("Welcome to SerenityOS!"); |     header.set_text("Welcome to SerenityOS!"); | ||||||
|     header.set_text_alignment(Gfx::TextAlignment::CenterLeft); |     header.set_text_alignment(Gfx::TextAlignment::CenterLeft); | ||||||
|     header.set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed); |     header.set_fixed_height(30); | ||||||
|     header.set_preferred_size(0, 30); |  | ||||||
| 
 | 
 | ||||||
|     //
 |     //
 | ||||||
|     // main section
 |     // main section
 | ||||||
|  | @ -169,17 +167,14 @@ int main(int argc, char** argv) | ||||||
|     main_section.set_layout<GUI::HorizontalBoxLayout>(); |     main_section.set_layout<GUI::HorizontalBoxLayout>(); | ||||||
|     main_section.layout()->set_margins({ 0, 0, 0, 0 }); |     main_section.layout()->set_margins({ 0, 0, 0, 0 }); | ||||||
|     main_section.layout()->set_spacing(8); |     main_section.layout()->set_spacing(8); | ||||||
|     main_section.set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fill); |  | ||||||
| 
 | 
 | ||||||
|     auto& menu = main_section.add<GUI::Widget>(); |     auto& menu = main_section.add<GUI::Widget>(); | ||||||
|     menu.set_layout<GUI::VerticalBoxLayout>(); |     menu.set_layout<GUI::VerticalBoxLayout>(); | ||||||
|     menu.layout()->set_margins({ 0, 0, 0, 0 }); |     menu.layout()->set_margins({ 0, 0, 0, 0 }); | ||||||
|     menu.layout()->set_spacing(4); |     menu.layout()->set_spacing(4); | ||||||
|     menu.set_size_policy(GUI::SizePolicy::Fixed, GUI::SizePolicy::Fill); |     menu.set_fixed_width(100); | ||||||
|     menu.set_preferred_size(100, 0); |  | ||||||
| 
 | 
 | ||||||
|     auto& stack = main_section.add<GUI::StackWidget>(); |     auto& stack = main_section.add<GUI::StackWidget>(); | ||||||
|     stack.set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fill); |  | ||||||
| 
 | 
 | ||||||
|     bool first = true; |     bool first = true; | ||||||
|     for (auto& page : pages) { |     for (auto& page : pages) { | ||||||
|  | @ -187,18 +182,15 @@ int main(int argc, char** argv) | ||||||
|         content.set_layout<GUI::VerticalBoxLayout>(); |         content.set_layout<GUI::VerticalBoxLayout>(); | ||||||
|         content.layout()->set_margins({ 0, 0, 0, 0 }); |         content.layout()->set_margins({ 0, 0, 0, 0 }); | ||||||
|         content.layout()->set_spacing(8); |         content.layout()->set_spacing(8); | ||||||
|         content.set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fill); |  | ||||||
| 
 | 
 | ||||||
|         auto& title_box = content.add<GUI::Widget>(); |         auto& title_box = content.add<GUI::Widget>(); | ||||||
|         title_box.set_layout<GUI::HorizontalBoxLayout>(); |         title_box.set_layout<GUI::HorizontalBoxLayout>(); | ||||||
|         title_box.layout()->set_spacing(4); |         title_box.layout()->set_spacing(4); | ||||||
|         title_box.set_preferred_size(0, 16); |         title_box.set_fixed_height(16); | ||||||
|         title_box.set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed); |  | ||||||
| 
 | 
 | ||||||
|         if (!page.icon.is_empty()) { |         if (!page.icon.is_empty()) { | ||||||
|             auto& icon = title_box.add<GUI::ImageWidget>(); |             auto& icon = title_box.add<GUI::ImageWidget>(); | ||||||
|             icon.set_preferred_size(16, 16); |             icon.set_fixed_size(16, 16); | ||||||
|             icon.set_size_policy(GUI::SizePolicy::Fixed, GUI::SizePolicy::Fixed); |  | ||||||
|             icon.load_from_file(page.icon); |             icon.load_from_file(page.icon); | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|  | @ -206,8 +198,7 @@ int main(int argc, char** argv) | ||||||
|         content_title.set_font(Gfx::Font::default_bold_font()); |         content_title.set_font(Gfx::Font::default_bold_font()); | ||||||
|         content_title.set_text(page.title); |         content_title.set_text(page.title); | ||||||
|         content_title.set_text_alignment(Gfx::TextAlignment::CenterLeft); |         content_title.set_text_alignment(Gfx::TextAlignment::CenterLeft); | ||||||
|         content_title.set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed); |         content_title.set_fixed_height(10); | ||||||
|         content_title.set_preferred_size(0, 10); |  | ||||||
| 
 | 
 | ||||||
|         for (auto& paragraph : page.content) { |         for (auto& paragraph : page.content) { | ||||||
|             auto& content_text = content.add<TextWidget>(); |             auto& content_text = content.add<TextWidget>(); | ||||||
|  | @ -222,8 +213,7 @@ int main(int argc, char** argv) | ||||||
|         menu_option.set_font(Gfx::Font::default_font()); |         menu_option.set_font(Gfx::Font::default_font()); | ||||||
|         menu_option.set_text(page.menu_name); |         menu_option.set_text(page.menu_name); | ||||||
|         menu_option.set_text_alignment(Gfx::TextAlignment::CenterLeft); |         menu_option.set_text_alignment(Gfx::TextAlignment::CenterLeft); | ||||||
|         menu_option.set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed); |         menu_option.set_fixed_height(20); | ||||||
|         menu_option.set_preferred_size(0, 20); |  | ||||||
|         menu_option.set_checkable(true); |         menu_option.set_checkable(true); | ||||||
|         menu_option.set_exclusive(true); |         menu_option.set_exclusive(true); | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -68,8 +68,7 @@ int main([[maybe_unused]] int argc, [[maybe_unused]] char** argv, [[maybe_unused | ||||||
| 
 | 
 | ||||||
|     auto& button = main_widget.add<GUI::Button>(); |     auto& button = main_widget.add<GUI::Button>(); | ||||||
|     button.set_text("Good-bye"); |     button.set_text("Good-bye"); | ||||||
|     button.set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed); |     button.set_fixed_height(20); | ||||||
|     button.set_preferred_size(0, 20); |  | ||||||
|     button.on_click = [&](auto) { |     button.on_click = [&](auto) { | ||||||
|         app->quit(); |         app->quit(); | ||||||
|     }; |     }; | ||||||
|  |  | ||||||
|  | @ -68,8 +68,7 @@ int main(int argc, char** argv) | ||||||
| 
 | 
 | ||||||
|     auto& button = main_widget.add<GUI::Button>(); |     auto& button = main_widget.add<GUI::Button>(); | ||||||
|     button.set_text("Good-bye"); |     button.set_text("Good-bye"); | ||||||
|     button.set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed); |     button.set_fixed_height(20); | ||||||
|     button.set_preferred_size(0, 20); |  | ||||||
|     button.on_click = [&](auto) { |     button.on_click = [&](auto) { | ||||||
|         app->quit(); |         app->quit(); | ||||||
|     }; |     }; | ||||||
|  |  | ||||||
|  | @ -125,23 +125,19 @@ int main(int argc, char** argv) | ||||||
|     auto& tab_widget = root_widget.add<GUI::TabWidget>(); |     auto& tab_widget = root_widget.add<GUI::TabWidget>(); | ||||||
| 
 | 
 | ||||||
|     auto& tab_basic = tab_widget.add_tab<GUI::Widget>("Basic"); |     auto& tab_basic = tab_widget.add_tab<GUI::Widget>("Basic"); | ||||||
|     tab_basic.set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fill); |  | ||||||
|     tab_basic.set_layout<GUI::VerticalBoxLayout>(); |     tab_basic.set_layout<GUI::VerticalBoxLayout>(); | ||||||
|     tab_basic.layout()->set_margins({ 8, 8, 8, 8 }); |     tab_basic.layout()->set_margins({ 8, 8, 8, 8 }); | ||||||
|     tab_basic.layout()->set_spacing(8); |     tab_basic.layout()->set_spacing(8); | ||||||
| 
 | 
 | ||||||
|     auto& radio_group_box = tab_basic.add<GUI::GroupBox>(); |     auto& radio_group_box = tab_basic.add<GUI::GroupBox>(); | ||||||
|     radio_group_box.set_layout<GUI::HorizontalBoxLayout>(); |     radio_group_box.set_layout<GUI::HorizontalBoxLayout>(); | ||||||
|     radio_group_box.set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fill); |  | ||||||
|     radio_group_box.layout()->set_margins({ 4, 4, 4, 4 }); |     radio_group_box.layout()->set_margins({ 4, 4, 4, 4 }); | ||||||
| 
 | 
 | ||||||
|     auto& radio_button_vert_container = radio_group_box.add<GUI::Widget>(); |     auto& radio_button_vert_container = radio_group_box.add<GUI::Widget>(); | ||||||
|     radio_button_vert_container.set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fill); |  | ||||||
|     radio_button_vert_container.set_layout<GUI::VerticalBoxLayout>(); |     radio_button_vert_container.set_layout<GUI::VerticalBoxLayout>(); | ||||||
|     radio_button_vert_container.layout()->set_margins({ 4, 9, 4, 4 }); |     radio_button_vert_container.layout()->set_margins({ 4, 9, 4, 4 }); | ||||||
| 
 | 
 | ||||||
|     auto& radio_button_container = radio_button_vert_container.add<GUI::Widget>(); |     auto& radio_button_container = radio_button_vert_container.add<GUI::Widget>(); | ||||||
|     radio_button_container.set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fill); |  | ||||||
|     radio_button_container.set_layout<GUI::HorizontalBoxLayout>(); |     radio_button_container.set_layout<GUI::HorizontalBoxLayout>(); | ||||||
| 
 | 
 | ||||||
|     auto& radio1 = radio_button_container.add<GUI::RadioButton>("RadioButton 1"); |     auto& radio1 = radio_button_container.add<GUI::RadioButton>("RadioButton 1"); | ||||||
|  | @ -151,32 +147,26 @@ int main(int argc, char** argv) | ||||||
|     radio3.set_enabled(false); |     radio3.set_enabled(false); | ||||||
| 
 | 
 | ||||||
|     auto& checklabelspin_container = tab_basic.add<GUI::Widget>(); |     auto& checklabelspin_container = tab_basic.add<GUI::Widget>(); | ||||||
|     checklabelspin_container.set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fill); |  | ||||||
|     checklabelspin_container.set_layout<GUI::HorizontalBoxLayout>(); |     checklabelspin_container.set_layout<GUI::HorizontalBoxLayout>(); | ||||||
| 
 | 
 | ||||||
|     auto& check_group_box = checklabelspin_container.add<GUI::GroupBox>(); |     auto& check_group_box = checklabelspin_container.add<GUI::GroupBox>(); | ||||||
|     check_group_box.set_layout<GUI::HorizontalBoxLayout>(); |     check_group_box.set_layout<GUI::HorizontalBoxLayout>(); | ||||||
|     check_group_box.set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fill); |  | ||||||
|     check_group_box.layout()->set_margins({ 4, 12, 4, 4 }); |     check_group_box.layout()->set_margins({ 4, 12, 4, 4 }); | ||||||
| 
 | 
 | ||||||
|     auto& checkbox_container = check_group_box.add<GUI::Widget>(); |     auto& checkbox_container = check_group_box.add<GUI::Widget>(); | ||||||
|     checkbox_container.set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fill); |  | ||||||
|     checkbox_container.set_layout<GUI::VerticalBoxLayout>(); |     checkbox_container.set_layout<GUI::VerticalBoxLayout>(); | ||||||
|     checkbox_container.layout()->set_margins({ 4, 4, 4, 4 }); |     checkbox_container.layout()->set_margins({ 4, 4, 4, 4 }); | ||||||
| 
 | 
 | ||||||
|     auto& label_container = check_group_box.add<GUI::Widget>(); |     auto& label_container = check_group_box.add<GUI::Widget>(); | ||||||
|     label_container.set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fill); |  | ||||||
|     label_container.set_layout<GUI::VerticalBoxLayout>(); |     label_container.set_layout<GUI::VerticalBoxLayout>(); | ||||||
|     label_container.layout()->set_margins({ 4, 4, 4, 4 }); |     label_container.layout()->set_margins({ 4, 4, 4, 4 }); | ||||||
| 
 | 
 | ||||||
|     auto& spin_group_box = checklabelspin_container.add<GUI::GroupBox>(); |     auto& spin_group_box = checklabelspin_container.add<GUI::GroupBox>(); | ||||||
|     spin_group_box.set_layout<GUI::HorizontalBoxLayout>(); |     spin_group_box.set_layout<GUI::HorizontalBoxLayout>(); | ||||||
|     spin_group_box.set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fill); |  | ||||||
|     spin_group_box.layout()->set_margins({ 4, 4, 4, 4 }); |     spin_group_box.layout()->set_margins({ 4, 4, 4, 4 }); | ||||||
|     spin_group_box.set_title("Spin boxes"); |     spin_group_box.set_title("Spin boxes"); | ||||||
| 
 | 
 | ||||||
|     auto& spin_container = spin_group_box.add<GUI::Widget>(); |     auto& spin_container = spin_group_box.add<GUI::Widget>(); | ||||||
|     spin_container.set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fill); |  | ||||||
|     spin_container.set_layout<GUI::VerticalBoxLayout>(); |     spin_container.set_layout<GUI::VerticalBoxLayout>(); | ||||||
|     spin_container.layout()->set_margins({ 4, 12, 4, 4 }); |     spin_container.layout()->set_margins({ 4, 12, 4, 4 }); | ||||||
| 
 | 
 | ||||||
|  | @ -194,15 +184,12 @@ int main(int argc, char** argv) | ||||||
|     spinbox2.set_enabled(false); |     spinbox2.set_enabled(false); | ||||||
| 
 | 
 | ||||||
|     auto& button_container = tab_basic.add<GUI::Widget>(); |     auto& button_container = tab_basic.add<GUI::Widget>(); | ||||||
|     button_container.set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fill); |  | ||||||
|     button_container.set_layout<GUI::HorizontalBoxLayout>(); |     button_container.set_layout<GUI::HorizontalBoxLayout>(); | ||||||
| 
 | 
 | ||||||
|     auto& button_vert1_container = button_container.add<GUI::Widget>(); |     auto& button_vert1_container = button_container.add<GUI::Widget>(); | ||||||
|     button_vert1_container.set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fill); |  | ||||||
|     button_vert1_container.set_layout<GUI::VerticalBoxLayout>(); |     button_vert1_container.set_layout<GUI::VerticalBoxLayout>(); | ||||||
| 
 | 
 | ||||||
|     auto& button_vert2_container = button_container.add<GUI::Widget>(); |     auto& button_vert2_container = button_container.add<GUI::Widget>(); | ||||||
|     button_vert2_container.set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fill); |  | ||||||
|     button_vert2_container.set_layout<GUI::VerticalBoxLayout>(); |     button_vert2_container.set_layout<GUI::VerticalBoxLayout>(); | ||||||
| 
 | 
 | ||||||
|     auto& button1 = button_vert1_container.add<GUI::Button>("Button 1"); |     auto& button1 = button_vert1_container.add<GUI::Button>("Button 1"); | ||||||
|  | @ -216,17 +203,14 @@ int main(int argc, char** argv) | ||||||
| 
 | 
 | ||||||
|     auto& text_group_box = tab_basic.add<GUI::GroupBox>(); |     auto& text_group_box = tab_basic.add<GUI::GroupBox>(); | ||||||
|     text_group_box.set_layout<GUI::HorizontalBoxLayout>(); |     text_group_box.set_layout<GUI::HorizontalBoxLayout>(); | ||||||
|     text_group_box.set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fill); |  | ||||||
|     text_group_box.set_title("Text boxes"); |     text_group_box.set_title("Text boxes"); | ||||||
|     text_group_box.layout()->set_margins({ 8, 4, 8, 4 }); |     text_group_box.layout()->set_margins({ 8, 4, 8, 4 }); | ||||||
| 
 | 
 | ||||||
|     auto& textbox_vert1_container = text_group_box.add<GUI::Widget>(); |     auto& textbox_vert1_container = text_group_box.add<GUI::Widget>(); | ||||||
|     textbox_vert1_container.set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fill); |  | ||||||
|     textbox_vert1_container.set_layout<GUI::VerticalBoxLayout>(); |     textbox_vert1_container.set_layout<GUI::VerticalBoxLayout>(); | ||||||
|     textbox_vert1_container.layout()->set_margins({ 1, 12, 1, 4 }); |     textbox_vert1_container.layout()->set_margins({ 1, 12, 1, 4 }); | ||||||
| 
 | 
 | ||||||
|     auto& textbox_vert2_container = text_group_box.add<GUI::Widget>(); |     auto& textbox_vert2_container = text_group_box.add<GUI::Widget>(); | ||||||
|     textbox_vert2_container.set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fill); |  | ||||||
|     textbox_vert2_container.set_layout<GUI::VerticalBoxLayout>(); |     textbox_vert2_container.set_layout<GUI::VerticalBoxLayout>(); | ||||||
|     textbox_vert2_container.layout()->set_margins({ 1, 12, 1, 4 }); |     textbox_vert2_container.layout()->set_margins({ 1, 12, 1, 4 }); | ||||||
| 
 | 
 | ||||||
|  | @ -243,28 +227,23 @@ int main(int argc, char** argv) | ||||||
|     textbox4.set_mode(GUI::TextEditor::DisplayOnly); |     textbox4.set_mode(GUI::TextEditor::DisplayOnly); | ||||||
| 
 | 
 | ||||||
|     auto& combocolor_container = tab_basic.add<GUI::Widget>(); |     auto& combocolor_container = tab_basic.add<GUI::Widget>(); | ||||||
|     combocolor_container.set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fill); |  | ||||||
|     combocolor_container.set_layout<GUI::HorizontalBoxLayout>(); |     combocolor_container.set_layout<GUI::HorizontalBoxLayout>(); | ||||||
| 
 | 
 | ||||||
|     auto& combo_group_box = combocolor_container.add<GUI::GroupBox>(); |     auto& combo_group_box = combocolor_container.add<GUI::GroupBox>(); | ||||||
|     combo_group_box.set_layout<GUI::HorizontalBoxLayout>(); |     combo_group_box.set_layout<GUI::HorizontalBoxLayout>(); | ||||||
|     combo_group_box.set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fill); |  | ||||||
|     combo_group_box.layout()->set_margins({ 4, 4, 4, 4 }); |     combo_group_box.layout()->set_margins({ 4, 4, 4, 4 }); | ||||||
|     combo_group_box.set_title("Combo boxes"); |     combo_group_box.set_title("Combo boxes"); | ||||||
| 
 | 
 | ||||||
|     auto& color_group_box = combocolor_container.add<GUI::GroupBox>(); |     auto& color_group_box = combocolor_container.add<GUI::GroupBox>(); | ||||||
|     color_group_box.set_layout<GUI::HorizontalBoxLayout>(); |     color_group_box.set_layout<GUI::HorizontalBoxLayout>(); | ||||||
|     color_group_box.set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fill); |  | ||||||
|     color_group_box.layout()->set_margins({ 4, 4, 4, 4 }); |     color_group_box.layout()->set_margins({ 4, 4, 4, 4 }); | ||||||
|     color_group_box.set_title("Color pickers"); |     color_group_box.set_title("Color pickers"); | ||||||
| 
 | 
 | ||||||
|     auto& combo_container = combo_group_box.add<GUI::Widget>(); |     auto& combo_container = combo_group_box.add<GUI::Widget>(); | ||||||
|     combo_container.set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fill); |  | ||||||
|     combo_container.set_layout<GUI::VerticalBoxLayout>(); |     combo_container.set_layout<GUI::VerticalBoxLayout>(); | ||||||
|     combo_container.layout()->set_margins({ 4, 12, 4, 4 }); |     combo_container.layout()->set_margins({ 4, 12, 4, 4 }); | ||||||
| 
 | 
 | ||||||
|     auto& color_container = color_group_box.add<GUI::Widget>(); |     auto& color_container = color_group_box.add<GUI::Widget>(); | ||||||
|     color_container.set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fill); |  | ||||||
|     color_container.set_layout<GUI::VerticalBoxLayout>(); |     color_container.set_layout<GUI::VerticalBoxLayout>(); | ||||||
|     color_container.layout()->set_margins({ 4, 12, 4, 4 }); |     color_container.layout()->set_margins({ 4, 12, 4, 4 }); | ||||||
| 
 | 
 | ||||||
|  | @ -283,23 +262,19 @@ int main(int argc, char** argv) | ||||||
|     combobox2.set_enabled(false); |     combobox2.set_enabled(false); | ||||||
| 
 | 
 | ||||||
|     auto& color_input_enabled = color_container.add<GUI::ColorInput>(); |     auto& color_input_enabled = color_container.add<GUI::ColorInput>(); | ||||||
|     color_input_enabled.set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fill); |  | ||||||
|     color_input_enabled.set_color(Color::from_string("#961605ff").value()); |     color_input_enabled.set_color(Color::from_string("#961605ff").value()); | ||||||
|     color_input_enabled.set_color_picker_title("Select color for desktop"); |     color_input_enabled.set_color_picker_title("Select color for desktop"); | ||||||
| 
 | 
 | ||||||
|     auto& color_input_disabled = color_container.add<GUI::ColorInput>(); |     auto& color_input_disabled = color_container.add<GUI::ColorInput>(); | ||||||
|     color_input_disabled.set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fill); |  | ||||||
|     color_input_disabled.set_color(Color::from_string("#961605ff").value()); |     color_input_disabled.set_color(Color::from_string("#961605ff").value()); | ||||||
|     color_input_disabled.set_enabled(false); |     color_input_disabled.set_enabled(false); | ||||||
| 
 | 
 | ||||||
|     auto& tab_others = tab_widget.add_tab<GUI::Widget>("Sliders"); |     auto& tab_others = tab_widget.add_tab<GUI::Widget>("Sliders"); | ||||||
|     tab_others.set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fill); |  | ||||||
|     tab_others.set_layout<GUI::VerticalBoxLayout>(); |     tab_others.set_layout<GUI::VerticalBoxLayout>(); | ||||||
|     tab_others.layout()->set_margins({ 8, 8, 8, 8 }); |     tab_others.layout()->set_margins({ 8, 8, 8, 8 }); | ||||||
|     tab_others.layout()->set_spacing(8); |     tab_others.layout()->set_spacing(8); | ||||||
| 
 | 
 | ||||||
|     auto& vert_slider_group_box = tab_others.add<GUI::GroupBox>(); |     auto& vert_slider_group_box = tab_others.add<GUI::GroupBox>(); | ||||||
|     vert_slider_group_box.set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fill); |  | ||||||
|     vert_slider_group_box.set_layout<GUI::HorizontalBoxLayout>(); |     vert_slider_group_box.set_layout<GUI::HorizontalBoxLayout>(); | ||||||
|     vert_slider_group_box.layout()->set_margins({ 4, 28, 4, 4 }); |     vert_slider_group_box.layout()->set_margins({ 4, 28, 4, 4 }); | ||||||
|     vert_slider_group_box.set_title("Vertical sliders"); |     vert_slider_group_box.set_title("Vertical sliders"); | ||||||
|  | @ -315,18 +290,15 @@ int main(int argc, char** argv) | ||||||
|     vslider3.set_tooltip("Proportional"); |     vslider3.set_tooltip("Proportional"); | ||||||
| 
 | 
 | ||||||
|     auto& horizontal_slider_group_box = tab_others.add<GUI::GroupBox>(); |     auto& horizontal_slider_group_box = tab_others.add<GUI::GroupBox>(); | ||||||
|     horizontal_slider_group_box.set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fill); |  | ||||||
|     horizontal_slider_group_box.set_layout<GUI::VerticalBoxLayout>(); |     horizontal_slider_group_box.set_layout<GUI::VerticalBoxLayout>(); | ||||||
|     horizontal_slider_group_box.layout()->set_margins({ 4, 12, 4, 4 }); |     horizontal_slider_group_box.layout()->set_margins({ 4, 12, 4, 4 }); | ||||||
|     horizontal_slider_group_box.set_title("Horizontal sliders"); |     horizontal_slider_group_box.set_title("Horizontal sliders"); | ||||||
| 
 | 
 | ||||||
|     auto& horizontal_slider_container = horizontal_slider_group_box.add<GUI::Widget>(); |     auto& horizontal_slider_container = horizontal_slider_group_box.add<GUI::Widget>(); | ||||||
|     horizontal_slider_container.set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fill); |  | ||||||
|     horizontal_slider_container.set_layout<GUI::HorizontalBoxLayout>(); |     horizontal_slider_container.set_layout<GUI::HorizontalBoxLayout>(); | ||||||
|     horizontal_slider_container.layout()->set_margins({ 4, 4, 4, 4 }); |     horizontal_slider_container.layout()->set_margins({ 4, 4, 4, 4 }); | ||||||
| 
 | 
 | ||||||
|     auto& horizontal_slider_container2 = horizontal_slider_group_box.add<GUI::Widget>(); |     auto& horizontal_slider_container2 = horizontal_slider_group_box.add<GUI::Widget>(); | ||||||
|     horizontal_slider_container2.set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fill); |  | ||||||
|     horizontal_slider_container2.set_layout<GUI::HorizontalBoxLayout>(); |     horizontal_slider_container2.set_layout<GUI::HorizontalBoxLayout>(); | ||||||
|     horizontal_slider_container2.layout()->set_margins({ 4, 4, 4, 4 }); |     horizontal_slider_container2.layout()->set_margins({ 4, 4, 4, 4 }); | ||||||
| 
 | 
 | ||||||
|  | @ -339,8 +311,7 @@ int main(int argc, char** argv) | ||||||
|     slider3.set_knob_size_mode(GUI::Slider::KnobSizeMode::Proportional); |     slider3.set_knob_size_mode(GUI::Slider::KnobSizeMode::Proportional); | ||||||
| 
 | 
 | ||||||
|     auto& progress1 = horizontal_slider_container2.add<GUI::ProgressBar>(); |     auto& progress1 = horizontal_slider_container2.add<GUI::ProgressBar>(); | ||||||
|     progress1.set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed); |     progress1.set_fixed_height(28); | ||||||
|     progress1.set_preferred_size(0, 28); |  | ||||||
| 
 | 
 | ||||||
|     slider1.on_value_changed = [&](int value) { |     slider1.on_value_changed = [&](int value) { | ||||||
|         progress1.set_value(value); |         progress1.set_value(value); | ||||||
|  | @ -354,7 +325,6 @@ int main(int argc, char** argv) | ||||||
|     }; |     }; | ||||||
| 
 | 
 | ||||||
|     auto& scroll_group_box = tab_others.add<GUI::GroupBox>(); |     auto& scroll_group_box = tab_others.add<GUI::GroupBox>(); | ||||||
|     scroll_group_box.set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fill); |  | ||||||
|     scroll_group_box.set_layout<GUI::VerticalBoxLayout>(); |     scroll_group_box.set_layout<GUI::VerticalBoxLayout>(); | ||||||
|     scroll_group_box.layout()->set_margins({ 12, 12, 12, 12 }); |     scroll_group_box.layout()->set_margins({ 12, 12, 12, 12 }); | ||||||
|     scroll_group_box.set_title("Scrollbars"); |     scroll_group_box.set_title("Scrollbars"); | ||||||
|  | @ -362,8 +332,7 @@ int main(int argc, char** argv) | ||||||
|     scroll_group_box.layout()->add_spacer(); |     scroll_group_box.layout()->add_spacer(); | ||||||
| 
 | 
 | ||||||
|     auto& scrollbar1 = scroll_group_box.add<GUI::ScrollBar>(Orientation::Horizontal); |     auto& scrollbar1 = scroll_group_box.add<GUI::ScrollBar>(Orientation::Horizontal); | ||||||
|     scrollbar1.set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed); |     scrollbar1.set_fixed_height(16); | ||||||
|     scrollbar1.set_preferred_size(0, 16); |  | ||||||
|     scrollbar1.set_min(0); |     scrollbar1.set_min(0); | ||||||
|     scrollbar1.set_max(100); |     scrollbar1.set_max(100); | ||||||
|     scrollbar1.set_value(50); |     scrollbar1.set_value(50); | ||||||
|  | @ -371,14 +340,12 @@ int main(int argc, char** argv) | ||||||
|     scroll_group_box.layout()->add_spacer(); |     scroll_group_box.layout()->add_spacer(); | ||||||
| 
 | 
 | ||||||
|     auto& scrollbar2 = scroll_group_box.add<GUI::ScrollBar>(Orientation::Horizontal); |     auto& scrollbar2 = scroll_group_box.add<GUI::ScrollBar>(Orientation::Horizontal); | ||||||
|     scrollbar2.set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed); |     scrollbar2.set_fixed_height(16); | ||||||
|     scrollbar2.set_preferred_size(0, 16); |  | ||||||
|     scrollbar2.set_enabled(false); |     scrollbar2.set_enabled(false); | ||||||
| 
 | 
 | ||||||
|     scroll_group_box.layout()->add_spacer(); |     scroll_group_box.layout()->add_spacer(); | ||||||
| 
 | 
 | ||||||
|     auto& tab_modals = tab_widget.add_tab<GUI::Widget>("Modals"); |     auto& tab_modals = tab_widget.add_tab<GUI::Widget>("Modals"); | ||||||
|     tab_modals.set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fill); |  | ||||||
|     tab_modals.set_layout<GUI::VerticalBoxLayout>(); |     tab_modals.set_layout<GUI::VerticalBoxLayout>(); | ||||||
|     tab_modals.layout()->set_margins({ 8, 8, 8, 8 }); |     tab_modals.layout()->set_margins({ 8, 8, 8, 8 }); | ||||||
|     tab_modals.layout()->set_spacing(8); |     tab_modals.layout()->set_spacing(8); | ||||||
|  | @ -386,19 +353,16 @@ int main(int argc, char** argv) | ||||||
|     GUI::MessageBox::Type msg_box_type = GUI::MessageBox::Type::Error; |     GUI::MessageBox::Type msg_box_type = GUI::MessageBox::Type::Error; | ||||||
| 
 | 
 | ||||||
|     auto& msgbox_group_container = tab_modals.add<GUI::GroupBox>("Message boxes"); |     auto& msgbox_group_container = tab_modals.add<GUI::GroupBox>("Message boxes"); | ||||||
|     msgbox_group_container.set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fill); |  | ||||||
|     msgbox_group_container.set_layout<GUI::VerticalBoxLayout>(); |     msgbox_group_container.set_layout<GUI::VerticalBoxLayout>(); | ||||||
|     msgbox_group_container.layout()->set_margins({ 4, 12, 4, 2 }); |     msgbox_group_container.layout()->set_margins({ 4, 12, 4, 2 }); | ||||||
| 
 | 
 | ||||||
|     auto& msgbox_radio_container = msgbox_group_container.add<GUI::Widget>(); |     auto& msgbox_radio_container = msgbox_group_container.add<GUI::Widget>(); | ||||||
|     msgbox_radio_container.set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fill); |  | ||||||
|     msgbox_radio_container.set_layout<GUI::HorizontalBoxLayout>(); |     msgbox_radio_container.set_layout<GUI::HorizontalBoxLayout>(); | ||||||
|     msgbox_radio_container.layout()->set_margins({ 4, 12, 4, 4 }); |     msgbox_radio_container.layout()->set_margins({ 4, 12, 4, 4 }); | ||||||
| 
 | 
 | ||||||
|     auto& icon_group_box = msgbox_radio_container.add<GUI::GroupBox>("Icon"); |     auto& icon_group_box = msgbox_radio_container.add<GUI::GroupBox>("Icon"); | ||||||
|     icon_group_box.set_layout<GUI::VerticalBoxLayout>(); |     icon_group_box.set_layout<GUI::VerticalBoxLayout>(); | ||||||
|     icon_group_box.layout()->set_margins({ 4, 16, 4, 4 }); |     icon_group_box.layout()->set_margins({ 4, 16, 4, 4 }); | ||||||
|     icon_group_box.set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fill); |  | ||||||
| 
 | 
 | ||||||
|     auto& radio_none = icon_group_box.add<GUI::RadioButton>("None"); |     auto& radio_none = icon_group_box.add<GUI::RadioButton>("None"); | ||||||
|     radio_none.on_checked = [&](bool) { |     radio_none.on_checked = [&](bool) { | ||||||
|  | @ -425,7 +389,6 @@ int main(int argc, char** argv) | ||||||
|     auto& button_group_box = msgbox_radio_container.add<GUI::GroupBox>("Buttons"); |     auto& button_group_box = msgbox_radio_container.add<GUI::GroupBox>("Buttons"); | ||||||
|     button_group_box.set_layout<GUI::VerticalBoxLayout>(); |     button_group_box.set_layout<GUI::VerticalBoxLayout>(); | ||||||
|     button_group_box.layout()->set_margins({ 4, 16, 4, 4 }); |     button_group_box.layout()->set_margins({ 4, 16, 4, 4 }); | ||||||
|     button_group_box.set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fill); |  | ||||||
| 
 | 
 | ||||||
|     GUI::MessageBox::InputType msg_box_input_type = GUI::MessageBox::InputType::OKCancel; |     GUI::MessageBox::InputType msg_box_input_type = GUI::MessageBox::InputType::OKCancel; | ||||||
| 
 | 
 | ||||||
|  | @ -448,24 +411,20 @@ int main(int argc, char** argv) | ||||||
|     }; |     }; | ||||||
| 
 | 
 | ||||||
|     auto& msgbox_text_container = msgbox_group_container.add<GUI::Widget>(); |     auto& msgbox_text_container = msgbox_group_container.add<GUI::Widget>(); | ||||||
|     msgbox_text_container.set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed); |  | ||||||
|     msgbox_text_container.set_layout<GUI::VerticalBoxLayout>(); |     msgbox_text_container.set_layout<GUI::VerticalBoxLayout>(); | ||||||
|     msgbox_text_container.set_preferred_size(0, 100); |     msgbox_text_container.set_fixed_height(100); | ||||||
|     msgbox_text_container.layout()->set_margins({ 4, 8, 4, 8 }); |     msgbox_text_container.layout()->set_margins({ 4, 8, 4, 8 }); | ||||||
| 
 | 
 | ||||||
|     auto& title_textbox = msgbox_text_container.add<GUI::TextBox>(); |     auto& title_textbox = msgbox_text_container.add<GUI::TextBox>(); | ||||||
|     title_textbox.set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed); |     title_textbox.set_fixed_height(24); | ||||||
|     title_textbox.set_preferred_size(0, 24); |  | ||||||
|     title_textbox.set_text("Demo Title"); |     title_textbox.set_text("Demo Title"); | ||||||
| 
 | 
 | ||||||
|     auto& content_textbox = msgbox_text_container.add<GUI::TextBox>(); |     auto& content_textbox = msgbox_text_container.add<GUI::TextBox>(); | ||||||
|     content_textbox.set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed); |     content_textbox.set_fixed_height(24); | ||||||
|     content_textbox.set_preferred_size(0, 24); |  | ||||||
|     content_textbox.set_text("Demo text for message box."); |     content_textbox.set_text("Demo text for message box."); | ||||||
| 
 | 
 | ||||||
|     auto& msgbox_button = msgbox_text_container.add<GUI::Button>("Create"); |     auto& msgbox_button = msgbox_text_container.add<GUI::Button>("Create"); | ||||||
|     msgbox_button.set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed); |     msgbox_button.set_fixed_height(30); | ||||||
|     msgbox_button.set_preferred_size(0, 30); |  | ||||||
|     msgbox_button.on_click = [&](auto) { |     msgbox_button.on_click = [&](auto) { | ||||||
|         GUI::MessageBox::show(window, content_textbox.text(), title_textbox.text(), msg_box_type, msg_box_input_type); |         GUI::MessageBox::show(window, content_textbox.text(), title_textbox.text(), msg_box_type, msg_box_input_type); | ||||||
|     }; |     }; | ||||||
|  | @ -473,8 +432,7 @@ int main(int argc, char** argv) | ||||||
|     auto& input_group_box = tab_modals.add<GUI::GroupBox>("Input boxes"); |     auto& input_group_box = tab_modals.add<GUI::GroupBox>("Input boxes"); | ||||||
|     input_group_box.set_layout<GUI::VerticalBoxLayout>(); |     input_group_box.set_layout<GUI::VerticalBoxLayout>(); | ||||||
|     input_group_box.layout()->set_margins({ 4, 12, 4, 4 }); |     input_group_box.layout()->set_margins({ 4, 12, 4, 4 }); | ||||||
|     input_group_box.set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed); |     input_group_box.set_fixed_height(160); | ||||||
|     input_group_box.set_preferred_size(0, 160); |  | ||||||
| 
 | 
 | ||||||
|     input_group_box.layout()->add_spacer(); |     input_group_box.layout()->add_spacer(); | ||||||
| 
 | 
 | ||||||
|  | @ -484,13 +442,11 @@ int main(int argc, char** argv) | ||||||
|     input_group_box.layout()->add_spacer(); |     input_group_box.layout()->add_spacer(); | ||||||
| 
 | 
 | ||||||
|     auto& input_button_container = input_group_box.add<GUI::Widget>(); |     auto& input_button_container = input_group_box.add<GUI::Widget>(); | ||||||
|     input_button_container.set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fill); |  | ||||||
|     input_button_container.set_layout<GUI::VerticalBoxLayout>(); |     input_button_container.set_layout<GUI::VerticalBoxLayout>(); | ||||||
|     input_button_container.layout()->set_margins({ 4, 0, 4, 0 }); |     input_button_container.layout()->set_margins({ 4, 0, 4, 0 }); | ||||||
| 
 | 
 | ||||||
|     auto& input_button = input_button_container.add<GUI::Button>("Input..."); |     auto& input_button = input_button_container.add<GUI::Button>("Input..."); | ||||||
|     input_button.set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed); |     input_button.set_fixed_height(30); | ||||||
|     input_button.set_preferred_size(0, 30); |  | ||||||
|     String value; |     String value; | ||||||
|     input_button.on_click = [&](auto) { |     input_button.on_click = [&](auto) { | ||||||
|         if (GUI::InputBox::show(value, window, "Enter input:", "Input Box") == GUI::InputBox::ExecOK && !value.is_empty()) |         if (GUI::InputBox::show(value, window, "Enter input:", "Input Box") == GUI::InputBox::ExecOK && !value.is_empty()) | ||||||
|  | @ -498,7 +454,6 @@ int main(int argc, char** argv) | ||||||
|     }; |     }; | ||||||
| 
 | 
 | ||||||
|     auto& tab_image = tab_widget.add_tab<GUI::Widget>("Images"); |     auto& tab_image = tab_widget.add_tab<GUI::Widget>("Images"); | ||||||
|     tab_image.set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fill); |  | ||||||
|     tab_image.set_layout<GUI::VerticalBoxLayout>(); |     tab_image.set_layout<GUI::VerticalBoxLayout>(); | ||||||
|     tab_image.layout()->set_margins({ 8, 8, 8, 8 }); |     tab_image.layout()->set_margins({ 8, 8, 8, 8 }); | ||||||
|     tab_image.layout()->set_spacing(8); |     tab_image.layout()->set_spacing(8); | ||||||
|  | @ -511,14 +466,12 @@ int main(int argc, char** argv) | ||||||
|     gif_animation_image.load_from_file("/res/graphics/download-animation.gif"); |     gif_animation_image.load_from_file("/res/graphics/download-animation.gif"); | ||||||
| 
 | 
 | ||||||
|     auto& tab_cursors = tab_widget.add_tab<GUI::Widget>("Cursors"); |     auto& tab_cursors = tab_widget.add_tab<GUI::Widget>("Cursors"); | ||||||
|     tab_cursors.set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fill); |  | ||||||
|     tab_cursors.set_layout<GUI::VerticalBoxLayout>(); |     tab_cursors.set_layout<GUI::VerticalBoxLayout>(); | ||||||
|     tab_cursors.layout()->set_margins({ 8, 8, 8, 8 }); |     tab_cursors.layout()->set_margins({ 8, 8, 8, 8 }); | ||||||
|     tab_cursors.layout()->set_spacing(8); |     tab_cursors.layout()->set_spacing(8); | ||||||
| 
 | 
 | ||||||
|     auto& cursor_group_box = tab_cursors.add<GUI::GroupBox>("Cursor"); |     auto& cursor_group_box = tab_cursors.add<GUI::GroupBox>("Cursor"); | ||||||
|     cursor_group_box.set_layout<GUI::VerticalBoxLayout>(); |     cursor_group_box.set_layout<GUI::VerticalBoxLayout>(); | ||||||
|     cursor_group_box.set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fill); |  | ||||||
|     cursor_group_box.layout()->set_margins({ 4, 12, 4, 4 }); |     cursor_group_box.layout()->set_margins({ 4, 12, 4, 4 }); | ||||||
| 
 | 
 | ||||||
|     auto& radio_cursor_none = cursor_group_box.add<GUI::RadioButton>("None"); |     auto& radio_cursor_none = cursor_group_box.add<GUI::RadioButton>("None"); | ||||||
|  |  | ||||||
|  | @ -48,11 +48,9 @@ DisassemblyWidget::DisassemblyWidget() | ||||||
| 
 | 
 | ||||||
|     m_top_container = add<GUI::Widget>(); |     m_top_container = add<GUI::Widget>(); | ||||||
|     m_top_container->set_layout<GUI::HorizontalBoxLayout>(); |     m_top_container->set_layout<GUI::HorizontalBoxLayout>(); | ||||||
|     m_top_container->set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed); |     m_top_container->set_fixed_height(20); | ||||||
|     m_top_container->set_preferred_size(0, 20); |  | ||||||
| 
 | 
 | ||||||
|     m_function_name_label = m_top_container->add<GUI::Label>(""); |     m_function_name_label = m_top_container->add<GUI::Label>(""); | ||||||
|     m_function_name_label->set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fill); |  | ||||||
| 
 | 
 | ||||||
|     m_disassembly_view = add<GUI::TableView>(); |     m_disassembly_view = add<GUI::TableView>(); | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -40,21 +40,18 @@ EditorWrapper::EditorWrapper() | ||||||
|     set_layout<GUI::VerticalBoxLayout>(); |     set_layout<GUI::VerticalBoxLayout>(); | ||||||
| 
 | 
 | ||||||
|     auto& label_wrapper = add<GUI::Widget>(); |     auto& label_wrapper = add<GUI::Widget>(); | ||||||
|     label_wrapper.set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed); |     label_wrapper.set_fixed_height(14); | ||||||
|     label_wrapper.set_preferred_size(0, 14); |  | ||||||
|     label_wrapper.set_fill_with_background_color(true); |     label_wrapper.set_fill_with_background_color(true); | ||||||
|     label_wrapper.set_layout<GUI::HorizontalBoxLayout>(); |     label_wrapper.set_layout<GUI::HorizontalBoxLayout>(); | ||||||
|     label_wrapper.layout()->set_margins({ 2, 0, 2, 0 }); |     label_wrapper.layout()->set_margins({ 2, 0, 2, 0 }); | ||||||
| 
 | 
 | ||||||
|     m_filename_label = label_wrapper.add<GUI::Label>("(Untitled)"); |     m_filename_label = label_wrapper.add<GUI::Label>("(Untitled)"); | ||||||
|     m_filename_label->set_text_alignment(Gfx::TextAlignment::CenterLeft); |     m_filename_label->set_text_alignment(Gfx::TextAlignment::CenterLeft); | ||||||
|     m_filename_label->set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed); |     m_filename_label->set_fixed_height(14); | ||||||
|     m_filename_label->set_preferred_size(0, 14); |  | ||||||
| 
 | 
 | ||||||
|     m_cursor_label = label_wrapper.add<GUI::Label>("(Cursor)"); |     m_cursor_label = label_wrapper.add<GUI::Label>("(Cursor)"); | ||||||
|     m_cursor_label->set_text_alignment(Gfx::TextAlignment::CenterRight); |     m_cursor_label->set_text_alignment(Gfx::TextAlignment::CenterRight); | ||||||
|     m_cursor_label->set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed); |     m_cursor_label->set_fixed_height(14); | ||||||
|     m_cursor_label->set_preferred_size(0, 14); |  | ||||||
| 
 | 
 | ||||||
|     m_editor = add<Editor>(); |     m_editor = add<Editor>(); | ||||||
|     m_editor->set_ruler_visible(true); |     m_editor->set_ruler_visible(true); | ||||||
|  |  | ||||||
|  | @ -138,15 +138,12 @@ FindInFilesWidget::FindInFilesWidget() | ||||||
| 
 | 
 | ||||||
|     auto& top_container = add<Widget>(); |     auto& top_container = add<Widget>(); | ||||||
|     top_container.set_layout<GUI::HorizontalBoxLayout>(); |     top_container.set_layout<GUI::HorizontalBoxLayout>(); | ||||||
|     top_container.set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed); |     top_container.set_fixed_height(20); | ||||||
|     top_container.set_preferred_size(0, 20); |  | ||||||
| 
 | 
 | ||||||
|     m_textbox = top_container.add<GUI::TextBox>(); |     m_textbox = top_container.add<GUI::TextBox>(); | ||||||
|     m_textbox->set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fill); |  | ||||||
| 
 | 
 | ||||||
|     m_button = top_container.add<GUI::Button>("Find in files"); |     m_button = top_container.add<GUI::Button>("Find in files"); | ||||||
|     m_button->set_size_policy(GUI::SizePolicy::Fixed, GUI::SizePolicy::Fill); |     m_button->set_fixed_width(100); | ||||||
|     m_button->set_preferred_size(100, 0); |  | ||||||
| 
 | 
 | ||||||
|     m_result_view = add<GUI::TableView>(); |     m_result_view = add<GUI::TableView>(); | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -54,16 +54,14 @@ GitWidget::GitWidget(const LexicalPath& repo_root) | ||||||
| 
 | 
 | ||||||
|     auto& refresh_button = unstaged_header.add<GUI::Button>(); |     auto& refresh_button = unstaged_header.add<GUI::Button>(); | ||||||
|     refresh_button.set_icon(Gfx::Bitmap::load_from_file("/res/icons/16x16/reload.png")); |     refresh_button.set_icon(Gfx::Bitmap::load_from_file("/res/icons/16x16/reload.png")); | ||||||
|     refresh_button.set_preferred_size({ 16, 16 }); |     refresh_button.set_fixed_size(16, 16); | ||||||
|     refresh_button.set_size_policy(GUI::SizePolicy::Fixed, GUI::SizePolicy::Fixed); |  | ||||||
|     refresh_button.set_tooltip("refresh"); |     refresh_button.set_tooltip("refresh"); | ||||||
|     refresh_button.on_click = [this](int) { refresh(); }; |     refresh_button.on_click = [this](int) { refresh(); }; | ||||||
| 
 | 
 | ||||||
|     auto& unstaged_label = unstaged_header.add<GUI::Label>(); |     auto& unstaged_label = unstaged_header.add<GUI::Label>(); | ||||||
|     unstaged_label.set_text("Unstaged"); |     unstaged_label.set_text("Unstaged"); | ||||||
| 
 | 
 | ||||||
|     unstaged_header.set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed); |     unstaged_header.set_fixed_height(20); | ||||||
|     unstaged_header.set_preferred_size(0, 20); |  | ||||||
|     m_unstaged_files = unstaged.add<GitFilesView>( |     m_unstaged_files = unstaged.add<GitFilesView>( | ||||||
|         [this](const auto& file) { stage_file(file); }, |         [this](const auto& file) { stage_file(file); }, | ||||||
|         Gfx::Bitmap::load_from_file("/res/icons/16x16/plus.png").release_nonnull()); |         Gfx::Bitmap::load_from_file("/res/icons/16x16/plus.png").release_nonnull()); | ||||||
|  | @ -80,16 +78,14 @@ GitWidget::GitWidget(const LexicalPath& repo_root) | ||||||
| 
 | 
 | ||||||
|     auto& commit_button = staged_header.add<GUI::Button>(); |     auto& commit_button = staged_header.add<GUI::Button>(); | ||||||
|     commit_button.set_icon(Gfx::Bitmap::load_from_file("/res/icons/16x16/commit.png")); |     commit_button.set_icon(Gfx::Bitmap::load_from_file("/res/icons/16x16/commit.png")); | ||||||
|     commit_button.set_preferred_size({ 16, 16 }); |     commit_button.set_fixed_size(16, 16); | ||||||
|     commit_button.set_size_policy(GUI::SizePolicy::Fixed, GUI::SizePolicy::Fixed); |  | ||||||
|     commit_button.set_tooltip("commit"); |     commit_button.set_tooltip("commit"); | ||||||
|     commit_button.on_click = [this](int) { commit(); }; |     commit_button.on_click = [this](int) { commit(); }; | ||||||
| 
 | 
 | ||||||
|     auto& staged_label = staged_header.add<GUI::Label>(); |     auto& staged_label = staged_header.add<GUI::Label>(); | ||||||
|     staged_label.set_text("Staged"); |     staged_label.set_text("Staged"); | ||||||
| 
 | 
 | ||||||
|     staged_header.set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed); |     staged_header.set_fixed_height(20); | ||||||
|     staged_header.set_preferred_size(0, 20); |  | ||||||
|     m_staged_files = staged.add<GitFilesView>( |     m_staged_files = staged.add<GitFilesView>( | ||||||
|         [this](const auto& file) { unstage_file(file); }, |         [this](const auto& file) { unstage_file(file); }, | ||||||
|         Gfx::Bitmap::load_from_file("/res/icons/16x16/minus.png").release_nonnull()); |         Gfx::Bitmap::load_from_file("/res/icons/16x16/minus.png").release_nonnull()); | ||||||
|  |  | ||||||
|  | @ -100,8 +100,7 @@ HackStudioWidget::HackStudioWidget(const String& path_to_project) | ||||||
|     auto& outer_splitter = add<GUI::HorizontalSplitter>(); |     auto& outer_splitter = add<GUI::HorizontalSplitter>(); | ||||||
| 
 | 
 | ||||||
|     auto& left_hand_splitter = outer_splitter.add<GUI::VerticalSplitter>(); |     auto& left_hand_splitter = outer_splitter.add<GUI::VerticalSplitter>(); | ||||||
|     left_hand_splitter.set_size_policy(GUI::SizePolicy::Fixed, GUI::SizePolicy::Fill); |     left_hand_splitter.set_fixed_width(150); | ||||||
|     left_hand_splitter.set_preferred_size(150, 0); |  | ||||||
|     create_project_tree_view(left_hand_splitter); |     create_project_tree_view(left_hand_splitter); | ||||||
|     m_project_tree_view_context_menu = create_project_tree_view_context_menu(); |     m_project_tree_view_context_menu = create_project_tree_view_context_menu(); | ||||||
| 
 | 
 | ||||||
|  | @ -494,8 +493,8 @@ NonnullRefPtr<GUI::Action> HackStudioWidget::create_add_terminal_action() | ||||||
| 
 | 
 | ||||||
| void HackStudioWidget::reveal_action_tab(GUI::Widget& widget) | void HackStudioWidget::reveal_action_tab(GUI::Widget& widget) | ||||||
| { | { | ||||||
|     if (m_action_tab_widget->preferred_size().height() < 200) |     if (m_action_tab_widget->min_height() < 200) | ||||||
|         m_action_tab_widget->set_preferred_size(0, 200); |         m_action_tab_widget->set_fixed_height(200); | ||||||
|     m_action_tab_widget->set_active_widget(&widget); |     m_action_tab_widget->set_active_widget(&widget); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | @ -617,7 +616,7 @@ void HackStudioWidget::run(TerminalWrapper& wrapper) | ||||||
| 
 | 
 | ||||||
| void HackStudioWidget::hide_action_tabs() | void HackStudioWidget::hide_action_tabs() | ||||||
| { | { | ||||||
|     m_action_tab_widget->set_preferred_size(0, 24); |     m_action_tab_widget->set_fixed_height(24); | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| Project& HackStudioWidget::project() | Project& HackStudioWidget::project() | ||||||
|  | @ -673,7 +672,7 @@ void HackStudioWidget::create_form_editor(GUI::Widget& parent) | ||||||
|     m_form_inner_container = parent.add<GUI::Widget>(); |     m_form_inner_container = parent.add<GUI::Widget>(); | ||||||
|     m_form_inner_container->set_layout<GUI::HorizontalBoxLayout>(); |     m_form_inner_container->set_layout<GUI::HorizontalBoxLayout>(); | ||||||
|     auto& form_widgets_toolbar = m_form_inner_container->add<GUI::ToolBar>(Orientation::Vertical, 26); |     auto& form_widgets_toolbar = m_form_inner_container->add<GUI::ToolBar>(Orientation::Vertical, 26); | ||||||
|     form_widgets_toolbar.set_preferred_size(38, 0); |     form_widgets_toolbar.set_fixed_width(38); | ||||||
| 
 | 
 | ||||||
|     GUI::ActionGroup tool_actions; |     GUI::ActionGroup tool_actions; | ||||||
|     tool_actions.set_exclusive(true); |     tool_actions.set_exclusive(true); | ||||||
|  | @ -710,8 +709,7 @@ void HackStudioWidget::create_form_editor(GUI::Widget& parent) | ||||||
|     m_form_editor_widget = form_editor_inner_splitter.add<FormEditorWidget>(); |     m_form_editor_widget = form_editor_inner_splitter.add<FormEditorWidget>(); | ||||||
| 
 | 
 | ||||||
|     auto& form_editing_pane_container = form_editor_inner_splitter.add<GUI::VerticalSplitter>(); |     auto& form_editing_pane_container = form_editor_inner_splitter.add<GUI::VerticalSplitter>(); | ||||||
|     form_editing_pane_container.set_size_policy(GUI::SizePolicy::Fixed, GUI::SizePolicy::Fill); |     form_editing_pane_container.set_fixed_width(190); | ||||||
|     form_editing_pane_container.set_preferred_size(190, 0); |  | ||||||
|     form_editing_pane_container.set_layout<GUI::VerticalBoxLayout>(); |     form_editing_pane_container.set_layout<GUI::VerticalBoxLayout>(); | ||||||
| 
 | 
 | ||||||
|     auto add_properties_pane = [&](auto& text, auto& pane_widget) { |     auto add_properties_pane = [&](auto& text, auto& pane_widget) { | ||||||
|  | @ -721,8 +719,7 @@ void HackStudioWidget::create_form_editor(GUI::Widget& parent) | ||||||
|         label.set_fill_with_background_color(true); |         label.set_fill_with_background_color(true); | ||||||
|         label.set_text_alignment(Gfx::TextAlignment::CenterLeft); |         label.set_text_alignment(Gfx::TextAlignment::CenterLeft); | ||||||
|         label.set_font(Gfx::Font::default_bold_font()); |         label.set_font(Gfx::Font::default_bold_font()); | ||||||
|         label.set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed); |         label.set_fixed_height(16); | ||||||
|         label.set_preferred_size(0, 16); |  | ||||||
|         wrapper.add_child(pane_widget); |         wrapper.add_child(pane_widget); | ||||||
|     }; |     }; | ||||||
| 
 | 
 | ||||||
|  | @ -803,14 +800,13 @@ void HackStudioWidget::create_action_tab(GUI::Widget& parent) | ||||||
| { | { | ||||||
|     m_action_tab_widget = parent.add<GUI::TabWidget>(); |     m_action_tab_widget = parent.add<GUI::TabWidget>(); | ||||||
| 
 | 
 | ||||||
|     m_action_tab_widget->set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed); |     m_action_tab_widget->set_fixed_height(24); | ||||||
|     m_action_tab_widget->set_preferred_size(0, 24); |  | ||||||
|     m_action_tab_widget->on_change = [this](auto&) { |     m_action_tab_widget->on_change = [this](auto&) { | ||||||
|         on_action_tab_change(); |         on_action_tab_change(); | ||||||
| 
 | 
 | ||||||
|         static bool first_time = true; |         static bool first_time = true; | ||||||
|         if (!first_time) |         if (!first_time) | ||||||
|             m_action_tab_widget->set_preferred_size(0, 200); |             m_action_tab_widget->set_fixed_height(200); | ||||||
|         first_time = false; |         first_time = false; | ||||||
|     }; |     }; | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -69,8 +69,7 @@ private: | ||||||
| Locator::Locator() | Locator::Locator() | ||||||
| { | { | ||||||
|     set_layout<GUI::VerticalBoxLayout>(); |     set_layout<GUI::VerticalBoxLayout>(); | ||||||
|     set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed); |     set_fixed_height(20); | ||||||
|     set_preferred_size(0, 20); |  | ||||||
|     m_textbox = add<GUI::TextBox>(); |     m_textbox = add<GUI::TextBox>(); | ||||||
|     m_textbox->on_change = [this] { |     m_textbox->on_change = [this] { | ||||||
|         update_suggestions(); |         update_suggestions(); | ||||||
|  |  | ||||||
|  | @ -128,8 +128,7 @@ int main(int argc, char** argv) | ||||||
|     auto& tree_view = splitter.add<GUI::TreeView>(); |     auto& tree_view = splitter.add<GUI::TreeView>(); | ||||||
|     tree_view.set_model(remote_process.object_graph_model()); |     tree_view.set_model(remote_process.object_graph_model()); | ||||||
|     tree_view.set_activates_on_selection(true); |     tree_view.set_activates_on_selection(true); | ||||||
|     tree_view.set_size_policy(GUI::SizePolicy::Fixed, GUI::SizePolicy::Fill); |     tree_view.set_fixed_width(286); | ||||||
|     tree_view.set_preferred_size(286, 0); |  | ||||||
| 
 | 
 | ||||||
|     auto& properties_tree_view = splitter.add<GUI::TreeView>(); |     auto& properties_tree_view = splitter.add<GUI::TreeView>(); | ||||||
|     properties_tree_view.set_editable(true); |     properties_tree_view.set_editable(true); | ||||||
|  |  | ||||||
|  | @ -33,8 +33,7 @@ ProfileTimelineWidget::ProfileTimelineWidget(Profile& profile) | ||||||
| { | { | ||||||
|     set_background_color(Color::White); |     set_background_color(Color::White); | ||||||
|     set_fill_with_background_color(true); |     set_fill_with_background_color(true); | ||||||
|     set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed); |     set_fixed_height(80); | ||||||
|     set_preferred_size(0, 80); |  | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| ProfileTimelineWidget::~ProfileTimelineWidget() | ProfileTimelineWidget::~ProfileTimelineWidget() | ||||||
|  |  | ||||||
|  | @ -176,8 +176,7 @@ static bool prompt_to_stop_profiling(pid_t pid, const String& process_name) | ||||||
|     }); |     }); | ||||||
| 
 | 
 | ||||||
|     auto& stop_button = widget.add<GUI::Button>("Stop"); |     auto& stop_button = widget.add<GUI::Button>("Stop"); | ||||||
|     stop_button.set_size_policy(GUI::SizePolicy::Fixed, GUI::SizePolicy::Fixed); |     stop_button.set_fixed_size(140, 22); | ||||||
|     stop_button.set_preferred_size(140, 22); |  | ||||||
|     stop_button.on_click = [&](auto) { |     stop_button.on_click = [&](auto) { | ||||||
|         GUI::Application::the()->quit(); |         GUI::Application::the()->quit(); | ||||||
|     }; |     }; | ||||||
|  |  | ||||||
|  | @ -509,9 +509,9 @@ void Field::set_field_size(size_t rows, size_t columns, size_t mine_count) | ||||||
|     m_rows = rows; |     m_rows = rows; | ||||||
|     m_columns = columns; |     m_columns = columns; | ||||||
|     m_mine_count = mine_count; |     m_mine_count = mine_count; | ||||||
|     set_preferred_size(frame_thickness() * 2 + m_columns * square_size(), frame_thickness() * 2 + m_rows * square_size()); |     set_fixed_size(frame_thickness() * 2 + m_columns * square_size(), frame_thickness() * 2 + m_rows * square_size()); | ||||||
|     reset(); |     reset(); | ||||||
|     m_on_size_changed(preferred_size()); |     m_on_size_changed(min_size()); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void Field::set_single_chording(bool enabled) | void Field::set_single_chording(bool enabled) | ||||||
|  |  | ||||||
|  | @ -83,8 +83,7 @@ int main(int argc, char** argv) | ||||||
| 
 | 
 | ||||||
|     auto& container = widget.add<GUI::Widget>(); |     auto& container = widget.add<GUI::Widget>(); | ||||||
|     container.set_fill_with_background_color(true); |     container.set_fill_with_background_color(true); | ||||||
|     container.set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed); |     container.set_fixed_height(36); | ||||||
|     container.set_preferred_size(0, 36); |  | ||||||
|     container.set_layout<GUI::HorizontalBoxLayout>(); |     container.set_layout<GUI::HorizontalBoxLayout>(); | ||||||
| 
 | 
 | ||||||
|     auto& flag_image = container.add<GUI::ImageWidget>(); |     auto& flag_image = container.add<GUI::ImageWidget>(); | ||||||
|  | @ -93,15 +92,14 @@ int main(int argc, char** argv) | ||||||
|     auto& flag_label = container.add<GUI::Label>(); |     auto& flag_label = container.add<GUI::Label>(); | ||||||
|     auto& face_button = container.add<GUI::Button>(); |     auto& face_button = container.add<GUI::Button>(); | ||||||
|     face_button.set_button_style(Gfx::ButtonStyle::CoolBar); |     face_button.set_button_style(Gfx::ButtonStyle::CoolBar); | ||||||
|     face_button.set_size_policy(GUI::SizePolicy::Fixed, GUI::SizePolicy::Fill); |     face_button.set_fixed_width(36); | ||||||
|     face_button.set_preferred_size(36, 0); |  | ||||||
| 
 | 
 | ||||||
|     auto& time_image = container.add<GUI::ImageWidget>(); |     auto& time_image = container.add<GUI::ImageWidget>(); | ||||||
|     time_image.load_from_file("/res/icons/minesweeper/timer.png"); |     time_image.load_from_file("/res/icons/minesweeper/timer.png"); | ||||||
| 
 | 
 | ||||||
|     auto& time_label = container.add<GUI::Label>(); |     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()); |         size.set_height(size.height() + container.min_size().height()); | ||||||
|         window->resize(size); |         window->resize(size); | ||||||
|     }); |     }); | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -57,19 +57,16 @@ AboutDialog::AboutDialog(const StringView& name, const Gfx::Bitmap* icon, Window | ||||||
|     banner_image.load_from_file("/res/graphics/brand-banner.png"); |     banner_image.load_from_file("/res/graphics/brand-banner.png"); | ||||||
| 
 | 
 | ||||||
|     auto& content_container = widget.add<Widget>(); |     auto& content_container = widget.add<Widget>(); | ||||||
|     content_container.set_size_policy(SizePolicy::Fill, SizePolicy::Fill); |  | ||||||
|     content_container.set_layout<HorizontalBoxLayout>(); |     content_container.set_layout<HorizontalBoxLayout>(); | ||||||
| 
 | 
 | ||||||
|     auto& left_container = content_container.add<Widget>(); |     auto& left_container = content_container.add<Widget>(); | ||||||
|     left_container.set_size_policy(SizePolicy::Fixed, SizePolicy::Fill); |     left_container.set_fixed_width(60); | ||||||
|     left_container.set_preferred_size(60, 0); |  | ||||||
|     left_container.set_layout<VerticalBoxLayout>(); |     left_container.set_layout<VerticalBoxLayout>(); | ||||||
|     left_container.layout()->set_margins({ 0, 12, 0, 0 }); |     left_container.layout()->set_margins({ 0, 12, 0, 0 }); | ||||||
| 
 | 
 | ||||||
|     if (icon) { |     if (icon) { | ||||||
|         auto& icon_wrapper = left_container.add<Widget>(); |         auto& icon_wrapper = left_container.add<Widget>(); | ||||||
|         icon_wrapper.set_size_policy(SizePolicy::Fixed, SizePolicy::Fixed); |         icon_wrapper.set_fixed_size(32, 48); | ||||||
|         icon_wrapper.set_preferred_size(32, 48); |  | ||||||
|         icon_wrapper.set_layout<VerticalBoxLayout>(); |         icon_wrapper.set_layout<VerticalBoxLayout>(); | ||||||
| 
 | 
 | ||||||
|         auto& icon_image = icon_wrapper.add<ImageWidget>(); |         auto& icon_image = icon_wrapper.add<ImageWidget>(); | ||||||
|  | @ -83,8 +80,7 @@ AboutDialog::AboutDialog(const StringView& name, const Gfx::Bitmap* icon, Window | ||||||
|     auto make_label = [&](const StringView& text, bool bold = false) { |     auto make_label = [&](const StringView& text, bool bold = false) { | ||||||
|         auto& label = right_container.add<Label>(text); |         auto& label = right_container.add<Label>(text); | ||||||
|         label.set_text_alignment(Gfx::TextAlignment::CenterLeft); |         label.set_text_alignment(Gfx::TextAlignment::CenterLeft); | ||||||
|         label.set_size_policy(SizePolicy::Fill, SizePolicy::Fixed); |         label.set_fixed_height(14); | ||||||
|         label.set_preferred_size(0, 14); |  | ||||||
|         if (bold) |         if (bold) | ||||||
|             label.set_font(Gfx::Font::default_bold_font()); |             label.set_font(Gfx::Font::default_bold_font()); | ||||||
|     }; |     }; | ||||||
|  | @ -98,13 +94,11 @@ AboutDialog::AboutDialog(const StringView& name, const Gfx::Bitmap* icon, Window | ||||||
|     right_container.layout()->add_spacer(); |     right_container.layout()->add_spacer(); | ||||||
| 
 | 
 | ||||||
|     auto& button_container = right_container.add<Widget>(); |     auto& button_container = right_container.add<Widget>(); | ||||||
|     button_container.set_size_policy(SizePolicy::Fill, SizePolicy::Fixed); |     button_container.set_fixed_height(23); | ||||||
|     button_container.set_preferred_size(0, 23); |  | ||||||
|     button_container.set_layout<HorizontalBoxLayout>(); |     button_container.set_layout<HorizontalBoxLayout>(); | ||||||
|     button_container.layout()->add_spacer(); |     button_container.layout()->add_spacer(); | ||||||
|     auto& ok_button = button_container.add<Button>("OK"); |     auto& ok_button = button_container.add<Button>("OK"); | ||||||
|     ok_button.set_size_policy(SizePolicy::Fixed, SizePolicy::Fixed); |     ok_button.set_fixed_size(80, 23); | ||||||
|     ok_button.set_preferred_size(80, 23); |  | ||||||
|     ok_button.on_click = [this](auto) { |     ok_button.on_click = [this](auto) { | ||||||
|         done(Dialog::ExecOK); |         done(Dialog::ExecOK); | ||||||
|     }; |     }; | ||||||
|  |  | ||||||
|  | @ -350,7 +350,7 @@ void AbstractTableView::layout_headers() | ||||||
|         int y = frame_thickness(); |         int y = frame_thickness(); | ||||||
|         int width = AK::max(content_width(), rect().width() - frame_thickness() * 2 - row_header_width - vertical_scrollbar_width); |         int width = AK::max(content_width(), rect().width() - frame_thickness() * 2 - row_header_width - vertical_scrollbar_width); | ||||||
| 
 | 
 | ||||||
|         column_header().set_relative_rect(x, y, width, column_header().preferred_size().height()); |         column_header().set_relative_rect(x, y, width, column_header().min_size().height()); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     if (row_header().is_visible()) { |     if (row_header().is_visible()) { | ||||||
|  | @ -361,7 +361,7 @@ void AbstractTableView::layout_headers() | ||||||
|         int y = frame_thickness() + column_header_height - vertical_scrollbar().value(); |         int y = frame_thickness() + column_header_height - vertical_scrollbar().value(); | ||||||
|         int height = AK::max(content_height(), rect().height() - frame_thickness() * 2 - column_header_height - horizontal_scrollbar_height); |         int height = AK::max(content_height(), rect().height() - frame_thickness() * 2 - column_header_height - horizontal_scrollbar_height); | ||||||
| 
 | 
 | ||||||
|         row_header().set_relative_rect(x, y, row_header().preferred_size().width(), height); |         row_header().set_relative_rect(x, y, row_header().min_size().width(), height); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     if (row_header().is_visible() && column_header().is_visible()) { |     if (row_header().is_visible() && column_header().is_visible()) { | ||||||
|  |  | ||||||
|  | @ -43,169 +43,124 @@ BoxLayout::BoxLayout(Orientation orientation) | ||||||
| 
 | 
 | ||||||
| void BoxLayout::run(Widget& widget) | void BoxLayout::run(Widget& widget) | ||||||
| { | { | ||||||
|     bool should_log = false; |  | ||||||
| #ifdef GBOXLAYOUT_DEBUG |  | ||||||
|     should_log = true; |  | ||||||
| #endif |  | ||||||
|     if (should_log) |  | ||||||
|         dbgprintf("BoxLayout: running layout on %s{%p}, entry count: %zu\n", widget.class_name(), &widget, m_entries.size()); |  | ||||||
| 
 |  | ||||||
|     if (m_entries.is_empty()) |     if (m_entries.is_empty()) | ||||||
|         return; |         return; | ||||||
| 
 | 
 | ||||||
|     Gfx::IntSize available_size = widget.size(); |     struct Item { | ||||||
|     int number_of_entries_with_fixed_size = 0; |         Widget* widget { nullptr }; | ||||||
|  |         int min_size { -1 }; | ||||||
|  |         int max_size { -1 }; | ||||||
|  |         int size { 0 }; | ||||||
|  |         bool final { false }; | ||||||
|  |     }; | ||||||
| 
 | 
 | ||||||
|     int number_of_visible_entries = 0; |     Vector<Item, 32> items; | ||||||
| 
 |  | ||||||
|     if (should_log) |  | ||||||
|         dbgprintf("BoxLayout:  Starting with available size: %s\n", available_size.to_string().characters()); |  | ||||||
| 
 | 
 | ||||||
|     for (size_t i = 0; i < m_entries.size(); ++i) { |     for (size_t i = 0; i < m_entries.size(); ++i) { | ||||||
|         auto& entry = m_entries[i]; |         auto& entry = m_entries[i]; | ||||||
|         if (entry.type == Entry::Type::Spacer) { |         if (entry.type == Entry::Type::Spacer) { | ||||||
|             ++number_of_visible_entries; |             items.append(Item { nullptr, -1, -1 }); | ||||||
|  |             continue; | ||||||
|         } |         } | ||||||
|         if (!entry.widget) |         if (!entry.widget) | ||||||
|             continue; |             continue; | ||||||
| 
 |  | ||||||
|         if (!entry.widget->is_visible()) |         if (!entry.widget->is_visible()) | ||||||
|             continue; |             continue; | ||||||
|         ++number_of_visible_entries; |         auto min_size = entry.widget->min_size(); | ||||||
|         if (entry.widget && entry.widget->size_policy(orientation()) == SizePolicy::Fixed) { |         auto max_size = entry.widget->max_size(); | ||||||
|             if (should_log) { |         items.append(Item { entry.widget.ptr(), min_size.primary_size_for_orientation(orientation()), max_size.primary_size_for_orientation(orientation()) }); | ||||||
|                 dbgprintf("BoxLayout:   Subtracting for fixed %s{%p}, size: %s\n", entry.widget->class_name(), entry.widget.ptr(), entry.widget->preferred_size().to_string().characters()); |  | ||||||
|                 dbgprintf("BoxLayout:     Available size before: %s\n", available_size.to_string().characters()); |  | ||||||
|             } |  | ||||||
|             available_size -= entry.widget->preferred_size(); |  | ||||||
|             if (should_log) |  | ||||||
|                 dbgprintf("BoxLayout:     Available size  after: %s\n", available_size.to_string().characters()); |  | ||||||
|             ++number_of_entries_with_fixed_size; |  | ||||||
|         } |  | ||||||
|         available_size -= { spacing(), spacing() }; |  | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     available_size += { spacing(), spacing() }; |     if (items.is_empty()) | ||||||
|  |         return; | ||||||
| 
 | 
 | ||||||
|     available_size -= { margins().left() + margins().right(), margins().top() + margins().bottom() }; |     int available_size = widget.size().primary_size_for_orientation(orientation()) - spacing() * (items.size() - 1); | ||||||
|  |     int unfinished_items = items.size(); | ||||||
| 
 | 
 | ||||||
|     if (should_log) |     if (orientation() == Gfx::Orientation::Horizontal) | ||||||
|         dbgprintf("BoxLayout:  Number of visible: %d/%zu\n", number_of_visible_entries, m_entries.size()); |         available_size -= margins().left() + margins().right(); | ||||||
|  |     else | ||||||
|  |         available_size -= margins().top() + margins().bottom(); | ||||||
| 
 | 
 | ||||||
|     int number_of_entries_with_automatic_size = number_of_visible_entries - number_of_entries_with_fixed_size; |     // Pass 1: Set all items to their minimum size.
 | ||||||
|  |     for (auto& item : items) { | ||||||
|  |         item.size = 0; | ||||||
|  |         if (item.min_size >= 0) | ||||||
|  |             item.size = item.min_size; | ||||||
|  |         available_size -= item.size; | ||||||
| 
 | 
 | ||||||
|     if (should_log) |         if (item.min_size >= 0 && item.max_size >= 0 && item.min_size == item.max_size) { | ||||||
|         dbgprintf("BoxLayout:   available_size=%s, fixed=%d, fill=%d\n", available_size.to_string().characters(), number_of_entries_with_fixed_size, number_of_entries_with_automatic_size); |             // Fixed-size items finish immediately in the first pass.
 | ||||||
| 
 |             item.final = true; | ||||||
|     Gfx::IntSize automatic_size; |             --unfinished_items; | ||||||
| 
 |  | ||||||
|     int remaining_size = 0; |  | ||||||
|     int number_of_entries_with_automatic_size_remaining = number_of_entries_with_automatic_size; |  | ||||||
| 
 |  | ||||||
|     if (number_of_entries_with_automatic_size) { |  | ||||||
|         if (m_orientation == Orientation::Horizontal) { |  | ||||||
|             automatic_size.set_width(available_size.width() / number_of_entries_with_automatic_size); |  | ||||||
|             automatic_size.set_height(widget.height()); |  | ||||||
| 
 |  | ||||||
|             remaining_size = available_size.width(); |  | ||||||
|         } else { |  | ||||||
|             automatic_size.set_width(widget.width()); |  | ||||||
|             automatic_size.set_height(available_size.height() / number_of_entries_with_automatic_size); |  | ||||||
| 
 |  | ||||||
|             remaining_size = available_size.height(); |  | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     if (should_log) |     // Pass 2: Distribute remaining available size evenly, respecting each item's maximum size.
 | ||||||
|         dbgprintf("BoxLayout:   automatic_size=%s\n", automatic_size.to_string().characters()); |     while (unfinished_items && available_size > 0) { | ||||||
|  |         int slice = available_size / unfinished_items; | ||||||
|  |         available_size = 0; | ||||||
| 
 | 
 | ||||||
|  |         for (auto& item : items) { | ||||||
|  |             if (item.final) | ||||||
|  |                 continue; | ||||||
|  | 
 | ||||||
|  |             int item_size_with_full_slice = item.size + slice; | ||||||
|  |             item.size = item_size_with_full_slice; | ||||||
|  | 
 | ||||||
|  |             if (item.max_size >= 0) | ||||||
|  |                 item.size = min(item.max_size, item_size_with_full_slice); | ||||||
|  | 
 | ||||||
|  |             // If the slice was more than we needed, return remained to available_size.
 | ||||||
|  |             int remainder_to_give_back = item_size_with_full_slice - item.size; | ||||||
|  |             available_size += remainder_to_give_back; | ||||||
|  | 
 | ||||||
|  |             if (item.max_size >= 0 && item.size == item.max_size) { | ||||||
|  |                 // We've hit the item's max size. Don't give it any more space.
 | ||||||
|  |                 item.final = true; | ||||||
|  |                 --unfinished_items; | ||||||
|  |             } | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     // Pass 3: Place the widgets.
 | ||||||
|     int current_x = margins().left(); |     int current_x = margins().left(); | ||||||
|     int current_y = margins().top(); |     int current_y = margins().top(); | ||||||
| 
 | 
 | ||||||
|     for (size_t i = 0; i < m_entries.size(); ++i) { |     for (auto& item : items) { | ||||||
|         auto& entry = m_entries[i]; |         Gfx::IntRect rect { current_x, current_y, 0, 0 }; | ||||||
|         if (entry.type == Entry::Type::Spacer) { |  | ||||||
|             current_x += automatic_size.width(); |  | ||||||
|             current_y += automatic_size.height(); |  | ||||||
|             continue; |  | ||||||
|         } |  | ||||||
| 
 | 
 | ||||||
|         if (!entry.widget) |         rect.set_primary_size_for_orientation(orientation(), item.size); | ||||||
|             continue; |  | ||||||
|         if (!entry.widget->is_visible()) |  | ||||||
|             continue; |  | ||||||
|         Gfx::IntRect rect(current_x, current_y, 0, 0); |  | ||||||
|         if (entry.layout) { |  | ||||||
|             // FIXME: Implement recursive layout.
 |  | ||||||
|             ASSERT_NOT_REACHED(); |  | ||||||
|         } |  | ||||||
|         ASSERT(entry.widget); |  | ||||||
| 
 | 
 | ||||||
|         if (entry.widget->size_policy(Orientation::Vertical) == SizePolicy::Fixed) { |         if (item.widget) { | ||||||
|             rect.set_width(widget.width()); |             int secondary = widget.size().secondary_size_for_orientation(orientation()); | ||||||
|             rect.set_height(entry.widget->preferred_size().height()); |             if (orientation() == Gfx::Orientation::Horizontal) | ||||||
|         } else { |                 secondary -= margins().top() + margins().bottom(); | ||||||
|             if (orientation() == Orientation::Horizontal) |  | ||||||
|                 rect.set_height(widget.height()); |  | ||||||
|             else |             else | ||||||
|                 rect.set_height(remaining_size / number_of_entries_with_automatic_size_remaining); |                 secondary -= margins().left() + margins().right(); | ||||||
|         } |  | ||||||
| 
 | 
 | ||||||
|         if (entry.widget->size_policy(Orientation::Horizontal) == SizePolicy::Fixed) { |             int min_secondary = item.widget->min_size().secondary_size_for_orientation(orientation()); | ||||||
|             rect.set_width(entry.widget->preferred_size().width()); |             int max_secondary = item.widget->max_size().secondary_size_for_orientation(orientation()); | ||||||
|             rect.set_height(widget.height()); |             if (min_secondary >= 0) | ||||||
|         } else { |                 secondary = max(secondary, min_secondary); | ||||||
|             if (orientation() == Orientation::Horizontal) |             if (max_secondary >= 0) | ||||||
|                 rect.set_width(remaining_size / number_of_entries_with_automatic_size_remaining); |                 secondary = min(secondary, max_secondary); | ||||||
|             else |  | ||||||
|                 rect.set_width(widget.width()); |  | ||||||
|         } |  | ||||||
| 
 | 
 | ||||||
|         if (orientation() == Orientation::Horizontal) { |             rect.set_secondary_size_for_orientation(orientation(), secondary); | ||||||
|             if (entry.widget->size_policy(Orientation::Vertical) == SizePolicy::Fill) |  | ||||||
|                 rect.set_height(widget.height() - margins().top() - margins().bottom()); |  | ||||||
|         } else { |  | ||||||
|             if (entry.widget->size_policy(Orientation::Horizontal) == SizePolicy::Fill) |  | ||||||
|                 rect.set_width(widget.width() - margins().left() - margins().right()); |  | ||||||
|         } |  | ||||||
| 
 | 
 | ||||||
|         // Apply min/max constraints to filled widgets.
 |             if (orientation() == Gfx::Orientation::Horizontal) | ||||||
|         if (entry.widget->size_policy(Orientation::Horizontal) == SizePolicy::Fill) { |  | ||||||
|             if (entry.widget->min_size().width() >= 0) |  | ||||||
|                 rect.set_width(max(entry.widget->min_size().width(), rect.width())); |  | ||||||
|             if (entry.widget->max_size().width() >= 0) |  | ||||||
|                 rect.set_width(min(entry.widget->max_size().width(), rect.width())); |  | ||||||
|         } |  | ||||||
|         if (entry.widget->size_policy(Orientation::Vertical) == SizePolicy::Fill) { |  | ||||||
|             if (entry.widget->min_size().height() >= 0) |  | ||||||
|                 rect.set_height(max(entry.widget->min_size().height(), rect.height())); |  | ||||||
|             if (entry.widget->max_size().height() >= 0) |  | ||||||
|                 rect.set_height(min(entry.widget->max_size().height(), rect.height())); |  | ||||||
|         } |  | ||||||
| 
 |  | ||||||
|         if (orientation() == Orientation::Horizontal) |  | ||||||
|                 rect.center_vertically_within(widget.rect()); |                 rect.center_vertically_within(widget.rect()); | ||||||
|             else |             else | ||||||
|                 rect.center_horizontally_within(widget.rect()); |                 rect.center_horizontally_within(widget.rect()); | ||||||
| 
 | 
 | ||||||
|         if (should_log) |             item.widget->set_relative_rect(rect); | ||||||
|             dbgprintf("BoxLayout: apply, %s{%p} <- %s\n", entry.widget->class_name(), entry.widget.ptr(), rect.to_string().characters()); |  | ||||||
| 
 |  | ||||||
|         entry.widget->set_relative_rect(rect); |  | ||||||
| 
 |  | ||||||
|         if (orientation() == Orientation::Horizontal) { |  | ||||||
|             if (entry.widget->size_policy(Orientation::Horizontal) == SizePolicy::Fill) { |  | ||||||
|                 remaining_size -= rect.width(); |  | ||||||
|                 --number_of_entries_with_automatic_size_remaining; |  | ||||||
|         } |         } | ||||||
|  | 
 | ||||||
|  |         if (orientation() == Gfx::Orientation::Horizontal) | ||||||
|             current_x += rect.width() + spacing(); |             current_x += rect.width() + spacing(); | ||||||
|         } else { |         else | ||||||
|             if (entry.widget->size_policy(Orientation::Vertical) == SizePolicy::Fill) { |  | ||||||
|                 remaining_size -= rect.height(); |  | ||||||
|                 --number_of_entries_with_automatic_size_remaining; |  | ||||||
|             } |  | ||||||
|             current_y += rect.height() + spacing(); |             current_y += rect.height() + spacing(); | ||||||
|     } |     } | ||||||
| } | } | ||||||
| } | 
 | ||||||
| } | } | ||||||
|  |  | ||||||
|  | @ -74,12 +74,10 @@ void BreadcrumbBar::append_segment(const String& text, const Gfx::Bitmap* icon, | ||||||
|             on_segment_click(index); |             on_segment_click(index); | ||||||
|     }; |     }; | ||||||
| 
 | 
 | ||||||
|     button.set_size_policy(SizePolicy::Fixed, SizePolicy::Fixed); |  | ||||||
| 
 |  | ||||||
|     auto button_text_width = button.font().width(text); |     auto button_text_width = button.font().width(text); | ||||||
|     auto icon_width = icon ? icon->width() : 0; |     auto icon_width = icon ? icon->width() : 0; | ||||||
|     auto icon_padding = icon ? 4 : 0; |     auto icon_padding = icon ? 4 : 0; | ||||||
|     button.set_preferred_size(button_text_width + icon_width + icon_padding + 16, 16 + 8); |     button.set_fixed_size(button_text_width + icon_width + icon_padding + 16, 16 + 8); | ||||||
| 
 | 
 | ||||||
|     Segment segment { icon, text, data, button.make_weak_ptr<GUI::Button>() }; |     Segment segment { icon, text, data, button.make_weak_ptr<GUI::Button>() }; | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -66,8 +66,7 @@ Calendar::Calendar(Core::DateTime date_time) | ||||||
| 
 | 
 | ||||||
|     m_day_name_container = add<GUI::Widget>(); |     m_day_name_container = add<GUI::Widget>(); | ||||||
|     m_day_name_container->set_layout<GUI::HorizontalBoxLayout>(); |     m_day_name_container->set_layout<GUI::HorizontalBoxLayout>(); | ||||||
|     m_day_name_container->set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed); |     m_day_name_container->set_fixed_height(16); | ||||||
|     m_day_name_container->set_preferred_size(0, 16); |  | ||||||
|     m_day_name_container->layout()->set_spacing(0); |     m_day_name_container->layout()->set_spacing(0); | ||||||
|     m_day_name_container->set_fill_with_background_color(true); |     m_day_name_container->set_fill_with_background_color(true); | ||||||
|     m_day_name_container->set_background_role(Gfx::ColorRole::HoverHighlight); |     m_day_name_container->set_background_role(Gfx::ColorRole::HoverHighlight); | ||||||
|  |  | ||||||
|  | @ -180,7 +180,6 @@ void ColorPicker::build_ui() | ||||||
|     auto& tab_widget = root_container.add<GUI::TabWidget>(); |     auto& tab_widget = root_container.add<GUI::TabWidget>(); | ||||||
| 
 | 
 | ||||||
|     auto& tab_palette = tab_widget.add_tab<Widget>("Palette"); |     auto& tab_palette = tab_widget.add_tab<Widget>("Palette"); | ||||||
|     tab_palette.set_size_policy(SizePolicy::Fill, SizePolicy::Fill); |  | ||||||
|     tab_palette.set_layout<VerticalBoxLayout>(); |     tab_palette.set_layout<VerticalBoxLayout>(); | ||||||
|     tab_palette.layout()->set_margins({ 4, 4, 4, 4 }); |     tab_palette.layout()->set_margins({ 4, 4, 4, 4 }); | ||||||
|     tab_palette.layout()->set_spacing(4); |     tab_palette.layout()->set_spacing(4); | ||||||
|  | @ -188,7 +187,6 @@ void ColorPicker::build_ui() | ||||||
|     build_ui_palette(tab_palette); |     build_ui_palette(tab_palette); | ||||||
| 
 | 
 | ||||||
|     auto& tab_custom_color = tab_widget.add_tab<Widget>("Custom Color"); |     auto& tab_custom_color = tab_widget.add_tab<Widget>("Custom Color"); | ||||||
|     tab_custom_color.set_size_policy(SizePolicy::Fill, SizePolicy::Fill); |  | ||||||
|     tab_custom_color.set_layout<VerticalBoxLayout>(); |     tab_custom_color.set_layout<VerticalBoxLayout>(); | ||||||
|     tab_custom_color.layout()->set_margins({ 4, 4, 4, 4 }); |     tab_custom_color.layout()->set_margins({ 4, 4, 4, 4 }); | ||||||
|     tab_custom_color.layout()->set_spacing(4); |     tab_custom_color.layout()->set_spacing(4); | ||||||
|  | @ -196,23 +194,20 @@ void ColorPicker::build_ui() | ||||||
|     build_ui_custom(tab_custom_color); |     build_ui_custom(tab_custom_color); | ||||||
| 
 | 
 | ||||||
|     auto& button_container = root_container.add<Widget>(); |     auto& button_container = root_container.add<Widget>(); | ||||||
|     button_container.set_size_policy(SizePolicy::Fill, SizePolicy::Fixed); |     button_container.set_fixed_height(22); | ||||||
|     button_container.set_preferred_size(0, 22); |  | ||||||
|     button_container.set_layout<HorizontalBoxLayout>(); |     button_container.set_layout<HorizontalBoxLayout>(); | ||||||
|     button_container.layout()->set_spacing(4); |     button_container.layout()->set_spacing(4); | ||||||
|     button_container.layout()->add_spacer(); |     button_container.layout()->add_spacer(); | ||||||
| 
 | 
 | ||||||
|     auto& ok_button = button_container.add<Button>(); |     auto& ok_button = button_container.add<Button>(); | ||||||
|     ok_button.set_size_policy(SizePolicy::Fixed, SizePolicy::Fill); |     ok_button.set_fixed_width(80); | ||||||
|     ok_button.set_preferred_size(80, 0); |  | ||||||
|     ok_button.set_text("OK"); |     ok_button.set_text("OK"); | ||||||
|     ok_button.on_click = [this](auto) { |     ok_button.on_click = [this](auto) { | ||||||
|         done(ExecOK); |         done(ExecOK); | ||||||
|     }; |     }; | ||||||
| 
 | 
 | ||||||
|     auto& cancel_button = button_container.add<Button>(); |     auto& cancel_button = button_container.add<Button>(); | ||||||
|     cancel_button.set_size_policy(SizePolicy::Fixed, SizePolicy::Fill); |     cancel_button.set_fixed_width(80); | ||||||
|     cancel_button.set_preferred_size(80, 0); |  | ||||||
|     cancel_button.set_text("Cancel"); |     cancel_button.set_text("Cancel"); | ||||||
|     cancel_button.on_click = [this](auto) { |     cancel_button.on_click = [this](auto) { | ||||||
|         done(ExecCancel); |         done(ExecCancel); | ||||||
|  | @ -231,7 +226,6 @@ void ColorPicker::build_ui_palette(Widget& root_container) | ||||||
|     for (int r = 0; r < 4; r++) { |     for (int r = 0; r < 4; r++) { | ||||||
|         auto& colors_row = root_container.add<Widget>(); |         auto& colors_row = root_container.add<Widget>(); | ||||||
|         colors_row.set_layout<HorizontalBoxLayout>(); |         colors_row.set_layout<HorizontalBoxLayout>(); | ||||||
|         colors_row.set_size_policy(SizePolicy::Fill, SizePolicy::Fill); |  | ||||||
| 
 | 
 | ||||||
|         for (int i = 0; i < 8; i++) { |         for (int i = 0; i < 8; i++) { | ||||||
|             create_color_button(colors_row, colors[r][i]); |             create_color_button(colors_row, colors[r][i]); | ||||||
|  | @ -254,8 +248,7 @@ void ColorPicker::build_ui_custom(Widget& root_container) | ||||||
| 
 | 
 | ||||||
|     // Left Side
 |     // Left Side
 | ||||||
|     m_custom_color = horizontal_container.add<CustomColorWidget>(m_color); |     m_custom_color = horizontal_container.add<CustomColorWidget>(m_color); | ||||||
|     m_custom_color->set_size_policy(SizePolicy::Fixed, SizePolicy::Fixed); |     m_custom_color->set_fixed_size(299, 260); | ||||||
|     m_custom_color->set_preferred_size(299, 260); |  | ||||||
|     m_custom_color->on_pick = [this](Color color) { |     m_custom_color->on_pick = [this](Color color) { | ||||||
|         if (m_color == color) |         if (m_color == color) | ||||||
|             return; |             return; | ||||||
|  | @ -266,17 +259,15 @@ void ColorPicker::build_ui_custom(Widget& root_container) | ||||||
| 
 | 
 | ||||||
|     // Right Side
 |     // Right Side
 | ||||||
|     auto& vertical_container = horizontal_container.add<Widget>(); |     auto& vertical_container = horizontal_container.add<Widget>(); | ||||||
|     vertical_container.set_size_policy(SizePolicy::Fixed, SizePolicy::Fill); |  | ||||||
|     vertical_container.set_layout<VerticalBoxLayout>(); |     vertical_container.set_layout<VerticalBoxLayout>(); | ||||||
|     vertical_container.layout()->set_margins({ 8, 0, 0, 0 }); |     vertical_container.layout()->set_margins({ 8, 0, 0, 0 }); | ||||||
|     vertical_container.set_preferred_size(128, 0); |     vertical_container.set_fixed_width(128); | ||||||
| 
 | 
 | ||||||
|     auto& preview_container = vertical_container.add<Frame>(); |     auto& preview_container = vertical_container.add<Frame>(); | ||||||
|     preview_container.set_size_policy(SizePolicy::Fill, SizePolicy::Fixed); |  | ||||||
|     preview_container.set_layout<VerticalBoxLayout>(); |     preview_container.set_layout<VerticalBoxLayout>(); | ||||||
|     preview_container.layout()->set_margins({ 2, 2, 2, 2 }); |     preview_container.layout()->set_margins({ 2, 2, 2, 2 }); | ||||||
|     preview_container.layout()->set_spacing(0); |     preview_container.layout()->set_spacing(0); | ||||||
|     preview_container.set_preferred_size(0, 128); |     preview_container.set_fixed_height(128); | ||||||
| 
 | 
 | ||||||
|     // Current color
 |     // Current color
 | ||||||
|     preview_container.add<ColorPreview>(m_color); |     preview_container.add<ColorPreview>(m_color); | ||||||
|  | @ -289,17 +280,14 @@ void ColorPicker::build_ui_custom(Widget& root_container) | ||||||
|     // HTML
 |     // HTML
 | ||||||
|     auto& html_container = vertical_container.add<GUI::Widget>(); |     auto& html_container = vertical_container.add<GUI::Widget>(); | ||||||
|     html_container.set_layout<GUI::HorizontalBoxLayout>(); |     html_container.set_layout<GUI::HorizontalBoxLayout>(); | ||||||
|     html_container.set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed); |     html_container.set_fixed_height(22); | ||||||
|     html_container.set_preferred_size(0, 22); |  | ||||||
| 
 | 
 | ||||||
|     auto& html_label = html_container.add<GUI::Label>(); |     auto& html_label = html_container.add<GUI::Label>(); | ||||||
|     html_label.set_text_alignment(Gfx::TextAlignment::CenterLeft); |     html_label.set_text_alignment(Gfx::TextAlignment::CenterLeft); | ||||||
|     html_label.set_size_policy(GUI::SizePolicy::Fixed, GUI::SizePolicy::Fill); |     html_label.set_fixed_width(48); | ||||||
|     html_label.set_preferred_size({ 48, 0 }); |  | ||||||
|     html_label.set_text("HTML:"); |     html_label.set_text("HTML:"); | ||||||
| 
 | 
 | ||||||
|     m_html_text = html_container.add<GUI::TextBox>(); |     m_html_text = html_container.add<GUI::TextBox>(); | ||||||
|     m_html_text->set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fill); |  | ||||||
|     m_html_text->set_text(m_color_has_alpha_channel ? m_color.to_string() : m_color.to_string_without_alpha()); |     m_html_text->set_text(m_color_has_alpha_channel ? m_color.to_string() : m_color.to_string_without_alpha()); | ||||||
|     m_html_text->on_change = [this]() { |     m_html_text->on_change = [this]() { | ||||||
|         auto color_name = m_html_text->text(); |         auto color_name = m_html_text->text(); | ||||||
|  | @ -321,17 +309,14 @@ void ColorPicker::build_ui_custom(Widget& root_container) | ||||||
|     auto make_spinbox = [&](RGBComponent component, int initial_value) { |     auto make_spinbox = [&](RGBComponent component, int initial_value) { | ||||||
|         auto& rgb_container = vertical_container.add<GUI::Widget>(); |         auto& rgb_container = vertical_container.add<GUI::Widget>(); | ||||||
|         rgb_container.set_layout<GUI::HorizontalBoxLayout>(); |         rgb_container.set_layout<GUI::HorizontalBoxLayout>(); | ||||||
|         rgb_container.set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed); |         rgb_container.set_fixed_height(22); | ||||||
|         rgb_container.set_preferred_size(0, 22); |  | ||||||
| 
 | 
 | ||||||
|         auto& rgb_label = rgb_container.add<GUI::Label>(); |         auto& rgb_label = rgb_container.add<GUI::Label>(); | ||||||
|         rgb_label.set_text_alignment(Gfx::TextAlignment::CenterLeft); |         rgb_label.set_text_alignment(Gfx::TextAlignment::CenterLeft); | ||||||
|         rgb_label.set_size_policy(GUI::SizePolicy::Fixed, GUI::SizePolicy::Fill); |         rgb_label.set_fixed_width(48); | ||||||
|         rgb_label.set_preferred_size({ 48, 0 }); |  | ||||||
| 
 | 
 | ||||||
|         auto& spinbox = rgb_container.add<SpinBox>(); |         auto& spinbox = rgb_container.add<SpinBox>(); | ||||||
|         spinbox.set_size_policy(SizePolicy::Fill, SizePolicy::Fixed); |         spinbox.set_fixed_height(20); | ||||||
|         spinbox.set_preferred_size(0, 20); |  | ||||||
|         spinbox.set_min(0); |         spinbox.set_min(0); | ||||||
|         spinbox.set_max(255); |         spinbox.set_max(255); | ||||||
|         spinbox.set_value(initial_value); |         spinbox.set_value(initial_value); | ||||||
|  | @ -395,7 +380,6 @@ void ColorPicker::create_color_button(Widget& container, unsigned rgb) | ||||||
|     Color color = Color::from_rgb(rgb); |     Color color = Color::from_rgb(rgb); | ||||||
| 
 | 
 | ||||||
|     auto& widget = container.add<ColorButton>(*this, color); |     auto& widget = container.add<ColorButton>(*this, color); | ||||||
|     widget.set_size_policy(SizePolicy::Fill, SizePolicy::Fill); |  | ||||||
|     widget.on_click = [this](Color color) { |     widget.on_click = [this](Color color) { | ||||||
|         for (auto& value : m_color_widgets) { |         for (auto& value : m_color_widgets) { | ||||||
|             value->set_selected(false); |             value->set_selected(false); | ||||||
|  | @ -465,18 +449,16 @@ CustomColorWidget::CustomColorWidget(Color color) | ||||||
|     set_layout<HorizontalBoxLayout>(); |     set_layout<HorizontalBoxLayout>(); | ||||||
| 
 | 
 | ||||||
|     m_color_field = add<ColorField>(color); |     m_color_field = add<ColorField>(color); | ||||||
|     m_color_field->set_size_policy(SizePolicy::Fixed, SizePolicy::Fixed); |  | ||||||
|     auto size = 256 + (m_color_field->frame_thickness() * 2); |     auto size = 256 + (m_color_field->frame_thickness() * 2); | ||||||
|     m_color_field->set_preferred_size(size, size); |     m_color_field->set_fixed_size(size, size); | ||||||
|     m_color_field->on_pick = [this](Color color) { |     m_color_field->on_pick = [this](Color color) { | ||||||
|         if (on_pick) |         if (on_pick) | ||||||
|             on_pick(color); |             on_pick(color); | ||||||
|     }; |     }; | ||||||
| 
 | 
 | ||||||
|     m_color_slider = add<ColorSlider>(color.to_hsv().hue); |     m_color_slider = add<ColorSlider>(color.to_hsv().hue); | ||||||
|     m_color_slider->set_size_policy(SizePolicy::Fixed, SizePolicy::Fixed); |  | ||||||
|     auto slider_width = 24 + (m_color_slider->frame_thickness() * 2); |     auto slider_width = 24 + (m_color_slider->frame_thickness() * 2); | ||||||
|     m_color_slider->set_preferred_size(slider_width, size); |     m_color_slider->set_fixed_size(slider_width, size); | ||||||
|     m_color_slider->on_pick = [this](double value) { |     m_color_slider->on_pick = [this](double value) { | ||||||
|         m_color_field->set_hue_from_pick(value); |         m_color_field->set_hue_from_pick(value); | ||||||
|     }; |     }; | ||||||
|  |  | ||||||
|  | @ -106,17 +106,14 @@ FilePicker::FilePicker(Window* parent_window, Mode mode, Options options, const | ||||||
|     auto& upper_container = vertical_container.add<Widget>(); |     auto& upper_container = vertical_container.add<Widget>(); | ||||||
|     upper_container.set_layout<HorizontalBoxLayout>(); |     upper_container.set_layout<HorizontalBoxLayout>(); | ||||||
|     upper_container.layout()->set_spacing(2); |     upper_container.layout()->set_spacing(2); | ||||||
|     upper_container.set_size_policy(SizePolicy::Fill, SizePolicy::Fixed); |     upper_container.set_fixed_height(26); | ||||||
|     upper_container.set_preferred_size(0, 26); |  | ||||||
| 
 | 
 | ||||||
|     auto& toolbar = upper_container.add<ToolBar>(); |     auto& toolbar = upper_container.add<ToolBar>(); | ||||||
|     toolbar.set_size_policy(SizePolicy::Fixed, SizePolicy::Fill); |     toolbar.set_fixed_width(165); | ||||||
|     toolbar.set_preferred_size(165, 0); |  | ||||||
|     toolbar.set_has_frame(false); |     toolbar.set_has_frame(false); | ||||||
| 
 | 
 | ||||||
|     m_location_textbox = upper_container.add<TextBox>(); |     m_location_textbox = upper_container.add<TextBox>(); | ||||||
|     m_location_textbox->set_size_policy(SizePolicy::Fill, SizePolicy::Fixed); |     m_location_textbox->set_fixed_height(22); | ||||||
|     m_location_textbox->set_preferred_size(0, 22); |  | ||||||
|     m_location_textbox->set_text(path); |     m_location_textbox->set_text(path); | ||||||
| 
 | 
 | ||||||
|     m_view = vertical_container.add<MultiView>(); |     m_view = vertical_container.add<MultiView>(); | ||||||
|  | @ -176,17 +173,14 @@ FilePicker::FilePicker(Window* parent_window, Mode mode, Options options, const | ||||||
|     auto& lower_container = vertical_container.add<Widget>(); |     auto& lower_container = vertical_container.add<Widget>(); | ||||||
|     lower_container.set_layout<VerticalBoxLayout>(); |     lower_container.set_layout<VerticalBoxLayout>(); | ||||||
|     lower_container.layout()->set_spacing(4); |     lower_container.layout()->set_spacing(4); | ||||||
|     lower_container.set_size_policy(SizePolicy::Fill, SizePolicy::Fixed); |     lower_container.set_fixed_height(48); | ||||||
|     lower_container.set_preferred_size(0, 48); |  | ||||||
| 
 | 
 | ||||||
|     auto& filename_container = lower_container.add<Widget>(); |     auto& filename_container = lower_container.add<Widget>(); | ||||||
|     filename_container.set_size_policy(SizePolicy::Fill, SizePolicy::Fixed); |     filename_container.set_fixed_height(22); | ||||||
|     filename_container.set_preferred_size(0, 22); |  | ||||||
|     filename_container.set_layout<HorizontalBoxLayout>(); |     filename_container.set_layout<HorizontalBoxLayout>(); | ||||||
|     auto& filename_label = filename_container.add<Label>("File name:"); |     auto& filename_label = filename_container.add<Label>("File name:"); | ||||||
|     filename_label.set_text_alignment(Gfx::TextAlignment::CenterLeft); |     filename_label.set_text_alignment(Gfx::TextAlignment::CenterLeft); | ||||||
|     filename_label.set_size_policy(SizePolicy::Fixed, SizePolicy::Fill); |     filename_label.set_fixed_width(60); | ||||||
|     filename_label.set_preferred_size(60, 0); |  | ||||||
|     m_filename_textbox = filename_container.add<TextBox>(); |     m_filename_textbox = filename_container.add<TextBox>(); | ||||||
|     m_filename_textbox->set_focus(true); |     m_filename_textbox->set_focus(true); | ||||||
|     if (m_mode == Mode::Save) { |     if (m_mode == Mode::Save) { | ||||||
|  | @ -214,23 +208,20 @@ FilePicker::FilePicker(Window* parent_window, Mode mode, Options options, const | ||||||
|     }; |     }; | ||||||
| 
 | 
 | ||||||
|     auto& button_container = lower_container.add<Widget>(); |     auto& button_container = lower_container.add<Widget>(); | ||||||
|     button_container.set_size_policy(SizePolicy::Fill, SizePolicy::Fixed); |     button_container.set_fixed_height(22); | ||||||
|     button_container.set_preferred_size(0, 22); |  | ||||||
|     button_container.set_layout<HorizontalBoxLayout>(); |     button_container.set_layout<HorizontalBoxLayout>(); | ||||||
|     button_container.layout()->set_spacing(4); |     button_container.layout()->set_spacing(4); | ||||||
|     button_container.layout()->add_spacer(); |     button_container.layout()->add_spacer(); | ||||||
| 
 | 
 | ||||||
|     auto& cancel_button = button_container.add<Button>(); |     auto& cancel_button = button_container.add<Button>(); | ||||||
|     cancel_button.set_size_policy(SizePolicy::Fixed, SizePolicy::Fill); |     cancel_button.set_fixed_width(80); | ||||||
|     cancel_button.set_preferred_size(80, 0); |  | ||||||
|     cancel_button.set_text("Cancel"); |     cancel_button.set_text("Cancel"); | ||||||
|     cancel_button.on_click = [this](auto) { |     cancel_button.on_click = [this](auto) { | ||||||
|         done(ExecCancel); |         done(ExecCancel); | ||||||
|     }; |     }; | ||||||
| 
 | 
 | ||||||
|     auto& ok_button = button_container.add<Button>(); |     auto& ok_button = button_container.add<Button>(); | ||||||
|     ok_button.set_size_policy(SizePolicy::Fixed, SizePolicy::Fill); |     ok_button.set_fixed_width(80); | ||||||
|     ok_button.set_preferred_size(80, 0); |  | ||||||
|     ok_button.set_text(ok_button_name(m_mode)); |     ok_button.set_text(ok_button_name(m_mode)); | ||||||
|     ok_button.on_click = [this](auto) { |     ok_button.on_click = [this](auto) { | ||||||
|         on_file_return(); |         on_file_return(); | ||||||
|  | @ -253,24 +244,21 @@ FilePicker::FilePicker(Window* parent_window, Mode mode, Options options, const | ||||||
|     if (!((unsigned)options & (unsigned)Options::DisablePreview)) { |     if (!((unsigned)options & (unsigned)Options::DisablePreview)) { | ||||||
|         m_preview_container = horizontal_container.add<Frame>(); |         m_preview_container = horizontal_container.add<Frame>(); | ||||||
|         m_preview_container->set_visible(false); |         m_preview_container->set_visible(false); | ||||||
|         m_preview_container->set_size_policy(SizePolicy::Fixed, SizePolicy::Fill); |         m_preview_container->set_fixed_width(180); | ||||||
|         m_preview_container->set_preferred_size(180, 0); |  | ||||||
|         m_preview_container->set_layout<VerticalBoxLayout>(); |         m_preview_container->set_layout<VerticalBoxLayout>(); | ||||||
|         m_preview_container->layout()->set_margins({ 8, 8, 8, 8 }); |         m_preview_container->layout()->set_margins({ 8, 8, 8, 8 }); | ||||||
| 
 | 
 | ||||||
|         m_preview_image = m_preview_container->add<ImageWidget>(); |         m_preview_image = m_preview_container->add<ImageWidget>(); | ||||||
|         m_preview_image->set_should_stretch(true); |         m_preview_image->set_should_stretch(true); | ||||||
|         m_preview_image->set_auto_resize(false); |         m_preview_image->set_auto_resize(false); | ||||||
|         m_preview_image->set_preferred_size(160, 160); |         m_preview_image->set_fixed_size(160, 160); | ||||||
| 
 | 
 | ||||||
|         m_preview_name_label = m_preview_container->add<Label>(); |         m_preview_name_label = m_preview_container->add<Label>(); | ||||||
|         m_preview_name_label->set_font(Gfx::Font::default_bold_font()); |         m_preview_name_label->set_font(Gfx::Font::default_bold_font()); | ||||||
|         m_preview_name_label->set_size_policy(SizePolicy::Fill, SizePolicy::Fixed); |         m_preview_name_label->set_fixed_height(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 = m_preview_container->add<Label>(); |         m_preview_geometry_label = m_preview_container->add<Label>(); | ||||||
|         m_preview_geometry_label->set_size_policy(SizePolicy::Fill, SizePolicy::Fixed); |         m_preview_geometry_label->set_fixed_height(m_preview_name_label->font().glyph_height()); | ||||||
|         m_preview_geometry_label->set_preferred_size(0, m_preview_name_label->font().glyph_height()); |  | ||||||
|     } |     } | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -45,11 +45,9 @@ HeaderView::HeaderView(AbstractTableView& table_view, Gfx::Orientation orientati | ||||||
|     set_font(Gfx::Font::default_bold_font()); |     set_font(Gfx::Font::default_bold_font()); | ||||||
| 
 | 
 | ||||||
|     if (m_orientation == Gfx::Orientation::Horizontal) { |     if (m_orientation == Gfx::Orientation::Horizontal) { | ||||||
|         set_size_policy(SizePolicy::Fill, SizePolicy::Fixed); |         set_fixed_height(16); | ||||||
|         set_preferred_size(0, 16); |  | ||||||
|     } else { |     } else { | ||||||
|         set_size_policy(SizePolicy::Fixed, SizePolicy::Fill); |         set_fixed_width(40); | ||||||
|         set_preferred_size(40, 0); |  | ||||||
|     } |     } | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -39,7 +39,6 @@ ImageWidget::ImageWidget(const StringView&) | ||||||
|     set_frame_thickness(0); |     set_frame_thickness(0); | ||||||
|     set_frame_shadow(Gfx::FrameShadow::Plain); |     set_frame_shadow(Gfx::FrameShadow::Plain); | ||||||
|     set_frame_shape(Gfx::FrameShape::NoFrame); |     set_frame_shape(Gfx::FrameShape::NoFrame); | ||||||
|     set_size_policy(GUI::SizePolicy::Fixed, GUI::SizePolicy::Fixed); |  | ||||||
|     set_auto_resize(true); |     set_auto_resize(true); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | @ -54,7 +53,7 @@ void ImageWidget::set_bitmap(const Gfx::Bitmap* bitmap) | ||||||
| 
 | 
 | ||||||
|     m_bitmap = bitmap; |     m_bitmap = bitmap; | ||||||
|     if (m_bitmap && m_auto_resize) |     if (m_bitmap && m_auto_resize) | ||||||
|         set_preferred_size(m_bitmap->width(), m_bitmap->height()); |         set_fixed_size(m_bitmap->size()); | ||||||
| 
 | 
 | ||||||
|     update(); |     update(); | ||||||
| } | } | ||||||
|  | @ -64,7 +63,7 @@ void ImageWidget::set_auto_resize(bool value) | ||||||
|     m_auto_resize = value; |     m_auto_resize = value; | ||||||
| 
 | 
 | ||||||
|     if (m_bitmap) |     if (m_bitmap) | ||||||
|         set_preferred_size(m_bitmap->width(), m_bitmap->height()); |         set_fixed_size(m_bitmap->size()); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void ImageWidget::animate() | void ImageWidget::animate() | ||||||
|  |  | ||||||
|  | @ -74,20 +74,16 @@ void InputBox::build() | ||||||
|     widget.layout()->set_spacing(6); |     widget.layout()->set_spacing(6); | ||||||
| 
 | 
 | ||||||
|     auto& label_editor_container = widget.add<Widget>(); |     auto& label_editor_container = widget.add<Widget>(); | ||||||
|     label_editor_container.set_size_policy(SizePolicy::Fill, SizePolicy::Fill); |  | ||||||
|     label_editor_container.set_layout<HorizontalBoxLayout>(); |     label_editor_container.set_layout<HorizontalBoxLayout>(); | ||||||
| 
 | 
 | ||||||
|     auto& label = label_editor_container.add<Label>(m_prompt); |     auto& label = label_editor_container.add<Label>(m_prompt); | ||||||
|     label.set_size_policy(SizePolicy::Fixed, SizePolicy::Fixed); |     label.set_fixed_size(text_width, 16); | ||||||
|     label.set_preferred_size(text_width, 16); |  | ||||||
| 
 | 
 | ||||||
|     m_text_editor = label_editor_container.add<TextBox>(); |     m_text_editor = label_editor_container.add<TextBox>(); | ||||||
|     m_text_editor->set_size_policy(SizePolicy::Fill, SizePolicy::Fixed); |     m_text_editor->set_fixed_height(19); | ||||||
|     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_fixed_height(20); | ||||||
|     button_container_outer.set_preferred_size(0, 20); |  | ||||||
|     button_container_outer.set_layout<VerticalBoxLayout>(); |     button_container_outer.set_layout<VerticalBoxLayout>(); | ||||||
| 
 | 
 | ||||||
|     auto& button_container_inner = button_container_outer.add<Widget>(); |     auto& button_container_inner = button_container_outer.add<Widget>(); | ||||||
|  | @ -97,8 +93,7 @@ void InputBox::build() | ||||||
|     button_container_inner.layout()->add_spacer(); |     button_container_inner.layout()->add_spacer(); | ||||||
| 
 | 
 | ||||||
|     m_ok_button = button_container_inner.add<Button>(); |     m_ok_button = button_container_inner.add<Button>(); | ||||||
|     m_ok_button->set_size_policy(SizePolicy::Fill, SizePolicy::Fixed); |     m_ok_button->set_fixed_height(20); | ||||||
|     m_ok_button->set_preferred_size(0, 20); |  | ||||||
|     m_ok_button->set_text("OK"); |     m_ok_button->set_text("OK"); | ||||||
|     m_ok_button->on_click = [this](auto) { |     m_ok_button->on_click = [this](auto) { | ||||||
|         dbgprintf("GUI::InputBox: OK button clicked\n"); |         dbgprintf("GUI::InputBox: OK button clicked\n"); | ||||||
|  | @ -107,8 +102,7 @@ void InputBox::build() | ||||||
|     }; |     }; | ||||||
| 
 | 
 | ||||||
|     m_cancel_button = button_container_inner.add<Button>(); |     m_cancel_button = button_container_inner.add<Button>(); | ||||||
|     m_cancel_button->set_size_policy(SizePolicy::Fill, SizePolicy::Fixed); |     m_cancel_button->set_fixed_height(20); | ||||||
|     m_cancel_button->set_preferred_size(0, 20); |  | ||||||
|     m_cancel_button->set_text("Cancel"); |     m_cancel_button->set_text("Cancel"); | ||||||
|     m_cancel_button->on_click = [this](auto) { |     m_cancel_button->on_click = [this](auto) { | ||||||
|         dbgprintf("GUI::InputBox: Cancel button clicked\n"); |         dbgprintf("GUI::InputBox: Cancel button clicked\n"); | ||||||
|  |  | ||||||
|  | @ -119,8 +119,7 @@ void Label::paint_event(PaintEvent& event) | ||||||
| 
 | 
 | ||||||
| void Label::size_to_fit() | void Label::size_to_fit() | ||||||
| { | { | ||||||
|     set_size_policy(SizePolicy::Fixed, SizePolicy::Fill); |     set_fixed_width(font().width(m_text)); | ||||||
|     set_preferred_size(font().width(m_text), 0); |  | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| } | } | ||||||
|  |  | ||||||
|  | @ -123,21 +123,18 @@ void MessageBox::build() | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     auto& label = message_container.add<Label>(m_text); |     auto& label = message_container.add<Label>(m_text); | ||||||
|     label.set_size_policy(SizePolicy::Fill, SizePolicy::Fixed); |     label.set_fixed_height(16); | ||||||
|     label.set_preferred_size(text_width, 16); |  | ||||||
|     if (m_type != Type::None) |     if (m_type != Type::None) | ||||||
|         label.set_text_alignment(Gfx::TextAlignment::CenterLeft); |         label.set_text_alignment(Gfx::TextAlignment::CenterLeft); | ||||||
| 
 | 
 | ||||||
|     auto& button_container = widget.add<Widget>(); |     auto& button_container = widget.add<Widget>(); | ||||||
|     button_container.set_layout<HorizontalBoxLayout>(); |     button_container.set_layout<HorizontalBoxLayout>(); | ||||||
|     button_container.set_size_policy(SizePolicy::Fill, SizePolicy::Fixed); |     button_container.set_fixed_height(24); | ||||||
|     button_container.set_preferred_size(0, 24); |  | ||||||
|     button_container.layout()->set_spacing(8); |     button_container.layout()->set_spacing(8); | ||||||
| 
 | 
 | ||||||
|     auto add_button = [&](String label, Dialog::ExecResult result) { |     auto add_button = [&](String label, Dialog::ExecResult result) { | ||||||
|         auto& button = button_container.add<Button>(); |         auto& button = button_container.add<Button>(); | ||||||
|         button.set_size_policy(SizePolicy::Fixed, SizePolicy::Fill); |         button.set_fixed_width(96); | ||||||
|         button.set_preferred_size(96, 0); |  | ||||||
|         button.set_text(label); |         button.set_text(label); | ||||||
|         button.on_click = [this, label, result](auto) { |         button.on_click = [this, label, result](auto) { | ||||||
|             done(result); |             done(result); | ||||||
|  |  | ||||||
|  | @ -64,15 +64,13 @@ ProcessChooser::ProcessChooser(const StringView& window_title, const StringView& | ||||||
|     m_table_view->on_activation = [this](const ModelIndex& index) { set_pid_from_index_and_close(index); }; |     m_table_view->on_activation = [this](const ModelIndex& index) { set_pid_from_index_and_close(index); }; | ||||||
| 
 | 
 | ||||||
|     auto& button_container = widget.add<GUI::Widget>(); |     auto& button_container = widget.add<GUI::Widget>(); | ||||||
|     button_container.set_preferred_size(0, 30); |     button_container.set_fixed_height(30); | ||||||
|     button_container.set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed); |  | ||||||
|     button_container.set_layout<GUI::HorizontalBoxLayout>(); |     button_container.set_layout<GUI::HorizontalBoxLayout>(); | ||||||
|     button_container.layout()->set_margins({ 0, 0, 4, 0 }); |     button_container.layout()->set_margins({ 0, 0, 4, 0 }); | ||||||
|     button_container.layout()->add_spacer(); |     button_container.layout()->add_spacer(); | ||||||
| 
 | 
 | ||||||
|     auto& select_button = button_container.add<GUI::Button>(m_button_label); |     auto& select_button = button_container.add<GUI::Button>(m_button_label); | ||||||
|     select_button.set_size_policy(GUI::SizePolicy::Fixed, GUI::SizePolicy::Fixed); |     select_button.set_fixed_size(80, 24); | ||||||
|     select_button.set_preferred_size(80, 24); |  | ||||||
|     select_button.on_click = [this](auto) { |     select_button.on_click = [this](auto) { | ||||||
|         if (m_table_view->selection().is_empty()) { |         if (m_table_view->selection().is_empty()) { | ||||||
|             GUI::MessageBox::show(this, "No process selected!", m_window_title, GUI::MessageBox::Type::Error); |             GUI::MessageBox::show(this, "No process selected!", m_window_title, GUI::MessageBox::Type::Error); | ||||||
|  | @ -82,8 +80,7 @@ ProcessChooser::ProcessChooser(const StringView& window_title, const StringView& | ||||||
|         set_pid_from_index_and_close(index); |         set_pid_from_index_and_close(index); | ||||||
|     }; |     }; | ||||||
|     auto& cancel_button = button_container.add<GUI::Button>("Cancel"); |     auto& cancel_button = button_container.add<GUI::Button>("Cancel"); | ||||||
|     cancel_button.set_size_policy(GUI::SizePolicy::Fixed, GUI::SizePolicy::Fixed); |     cancel_button.set_fixed_size(80, 24); | ||||||
|     cancel_button.set_preferred_size(80, 24); |  | ||||||
|     cancel_button.on_click = [this](auto) { |     cancel_button.on_click = [this](auto) { | ||||||
|         done(ExecCancel); |         done(ExecCancel); | ||||||
|     }; |     }; | ||||||
|  |  | ||||||
|  | @ -79,8 +79,7 @@ ResizeCorner::ResizeCorner() | ||||||
| { | { | ||||||
|     set_override_cursor(Gfx::StandardCursor::ResizeDiagonalTLBR); |     set_override_cursor(Gfx::StandardCursor::ResizeDiagonalTLBR); | ||||||
|     set_background_role(ColorRole::Button); |     set_background_role(ColorRole::Button); | ||||||
|     set_size_policy(SizePolicy::Fixed, SizePolicy::Fixed); |     set_fixed_size(16, 18); | ||||||
|     set_preferred_size(16, 18); |  | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| ResizeCorner::~ResizeCorner() | ResizeCorner::~ResizeCorner() | ||||||
|  |  | ||||||
|  | @ -100,9 +100,9 @@ ScrollBar::ScrollBar(Orientation orientation) | ||||||
|         s_right_arrow_bitmap = &Gfx::CharacterBitmap::create_from_ascii(s_right_arrow_bitmap_data, 9, 9).leak_ref(); |         s_right_arrow_bitmap = &Gfx::CharacterBitmap::create_from_ascii(s_right_arrow_bitmap_data, 9, 9).leak_ref(); | ||||||
| 
 | 
 | ||||||
|     if (m_orientation == Orientation::Vertical) { |     if (m_orientation == Orientation::Vertical) { | ||||||
|         set_preferred_size(16, 0); |         set_fixed_height(16); | ||||||
|     } else { |     } else { | ||||||
|         set_preferred_size(0, 16); |         set_fixed_width(16); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     m_automatic_scrolling_timer->set_interval(100); |     m_automatic_scrolling_timer->set_interval(100); | ||||||
|  |  | ||||||
|  | @ -71,20 +71,20 @@ void ScrollableWidget::mousewheel_event(MouseEvent& event) | ||||||
| void ScrollableWidget::custom_layout() | void ScrollableWidget::custom_layout() | ||||||
| { | { | ||||||
|     auto inner_rect = frame_inner_rect_for_size(size()); |     auto inner_rect = frame_inner_rect_for_size(size()); | ||||||
|     int height_wanted_by_horizontal_scrollbar = m_horizontal_scrollbar->is_visible() ? m_horizontal_scrollbar->preferred_size().height() : 0; |     int height_wanted_by_horizontal_scrollbar = m_horizontal_scrollbar->is_visible() ? m_horizontal_scrollbar->min_height() : 0; | ||||||
|     int width_wanted_by_vertical_scrollbar = m_vertical_scrollbar->is_visible() ? m_vertical_scrollbar->preferred_size().width() : 0; |     int width_wanted_by_vertical_scrollbar = m_vertical_scrollbar->is_visible() ? m_vertical_scrollbar->min_width() : 0; | ||||||
| 
 | 
 | ||||||
|     m_vertical_scrollbar->set_relative_rect( |     m_vertical_scrollbar->set_relative_rect( | ||||||
|         inner_rect.right() + 1 - m_vertical_scrollbar->preferred_size().width(), |         inner_rect.right() + 1 - m_vertical_scrollbar->min_width(), | ||||||
|         inner_rect.top(), |         inner_rect.top(), | ||||||
|         m_vertical_scrollbar->preferred_size().width(), |         m_vertical_scrollbar->min_width(), | ||||||
|         inner_rect.height() - height_wanted_by_horizontal_scrollbar); |         inner_rect.height() - height_wanted_by_horizontal_scrollbar); | ||||||
| 
 | 
 | ||||||
|     m_horizontal_scrollbar->set_relative_rect( |     m_horizontal_scrollbar->set_relative_rect( | ||||||
|         inner_rect.left(), |         inner_rect.left(), | ||||||
|         inner_rect.bottom() + 1 - m_horizontal_scrollbar->preferred_size().height(), |         inner_rect.bottom() + 1 - m_horizontal_scrollbar->min_height(), | ||||||
|         inner_rect.width() - width_wanted_by_vertical_scrollbar, |         inner_rect.width() - width_wanted_by_vertical_scrollbar, | ||||||
|         m_horizontal_scrollbar->preferred_size().height()); |         m_horizontal_scrollbar->min_height()); | ||||||
| 
 | 
 | ||||||
|     m_corner_widget->set_visible(m_vertical_scrollbar->is_visible() && m_horizontal_scrollbar->is_visible()); |     m_corner_widget->set_visible(m_vertical_scrollbar->is_visible() && m_horizontal_scrollbar->is_visible()); | ||||||
|     if (m_corner_widget->is_visible()) { |     if (m_corner_widget->is_visible()) { | ||||||
|  |  | ||||||
|  | @ -183,11 +183,14 @@ void Splitter::mousemove_event(MouseEvent& event) | ||||||
|         new_second_resizee_size.set_primary_size_for_orientation(m_orientation, new_second_resizee_size.primary_size_for_orientation(m_orientation) + correction); |         new_second_resizee_size.set_primary_size_for_orientation(m_orientation, new_second_resizee_size.primary_size_for_orientation(m_orientation) + correction); | ||||||
|         new_first_resizee_size.set_primary_size_for_orientation(m_orientation, new_first_resizee_size.primary_size_for_orientation(m_orientation) - correction); |         new_first_resizee_size.set_primary_size_for_orientation(m_orientation, new_first_resizee_size.primary_size_for_orientation(m_orientation) - correction); | ||||||
|     } |     } | ||||||
|     m_first_resizee->set_preferred_size(new_first_resizee_size); |  | ||||||
|     m_second_resizee->set_preferred_size(new_second_resizee_size); |  | ||||||
| 
 | 
 | ||||||
|     m_first_resizee->set_size_policy(m_orientation, SizePolicy::Fixed); |     if (m_orientation == Orientation::Horizontal) { | ||||||
|     m_second_resizee->set_size_policy(m_orientation, SizePolicy::Fill); |         m_first_resizee->set_fixed_width(new_first_resizee_size.width()); | ||||||
|  |         m_second_resizee->set_fixed_width(-1); | ||||||
|  |     } else { | ||||||
|  |         m_first_resizee->set_fixed_height(new_first_resizee_size.height()); | ||||||
|  |         m_second_resizee->set_fixed_height(-1); | ||||||
|  |     } | ||||||
| 
 | 
 | ||||||
|     invalidate_layout(); |     invalidate_layout(); | ||||||
| } | } | ||||||
|  |  | ||||||
|  | @ -37,8 +37,7 @@ namespace GUI { | ||||||
| 
 | 
 | ||||||
| StatusBar::StatusBar(int label_count) | StatusBar::StatusBar(int label_count) | ||||||
| { | { | ||||||
|     set_size_policy(SizePolicy::Fill, SizePolicy::Fixed); |     set_fixed_height(18); | ||||||
|     set_preferred_size(0, 18); |  | ||||||
|     set_layout<HorizontalBoxLayout>(); |     set_layout<HorizontalBoxLayout>(); | ||||||
|     layout()->set_margins({ 0, 0, 0, 0 }); |     layout()->set_margins({ 0, 0, 0, 0 }); | ||||||
|     layout()->set_spacing(2); |     layout()->set_spacing(2); | ||||||
|  |  | ||||||
|  | @ -40,11 +40,9 @@ ToolBar::ToolBar(Orientation orientation, int button_size) | ||||||
|     : m_button_size(button_size) |     : m_button_size(button_size) | ||||||
| { | { | ||||||
|     if (orientation == Orientation::Horizontal) { |     if (orientation == Orientation::Horizontal) { | ||||||
|         set_size_policy(SizePolicy::Fill, SizePolicy::Fixed); |         set_fixed_height(button_size + 8); | ||||||
|         set_preferred_size(0, button_size + 8); |  | ||||||
|     } else { |     } else { | ||||||
|         set_size_policy(SizePolicy::Fixed, SizePolicy::Fill); |         set_fixed_width(button_size + 8); | ||||||
|         set_preferred_size(button_size + 8, 0); |  | ||||||
|     } |     } | ||||||
|     set_layout<BoxLayout>(orientation); |     set_layout<BoxLayout>(orientation); | ||||||
|     layout()->set_spacing(0); |     layout()->set_spacing(0); | ||||||
|  | @ -74,7 +72,6 @@ private: | ||||||
|         else |         else | ||||||
|             set_text(action.text()); |             set_text(action.text()); | ||||||
|         set_button_style(Gfx::ButtonStyle::CoolBar); |         set_button_style(Gfx::ButtonStyle::CoolBar); | ||||||
|         set_size_policy(SizePolicy::Fixed, SizePolicy::Fixed); |  | ||||||
|     } |     } | ||||||
|     String tooltip(const Action& action) const |     String tooltip(const Action& action) const | ||||||
|     { |     { | ||||||
|  | @ -96,7 +93,7 @@ void ToolBar::add_action(Action& action) | ||||||
|     item->action = action; |     item->action = action; | ||||||
| 
 | 
 | ||||||
|     auto& button = add<ToolBarButton>(action); |     auto& button = add<ToolBarButton>(action); | ||||||
|     button.set_preferred_size(m_button_size + 8, m_button_size + 8); |     button.set_fixed_size(m_button_size + 8, m_button_size + 8); | ||||||
| 
 | 
 | ||||||
|     m_items.append(move(item)); |     m_items.append(move(item)); | ||||||
| } | } | ||||||
|  | @ -106,8 +103,7 @@ class SeparatorWidget final : public Widget { | ||||||
| public: | public: | ||||||
|     SeparatorWidget() |     SeparatorWidget() | ||||||
|     { |     { | ||||||
|         set_size_policy(SizePolicy::Fixed, SizePolicy::Fixed); |         set_fixed_size(8, 18); | ||||||
|         set_preferred_size(8, 18); |  | ||||||
|     } |     } | ||||||
|     virtual ~SeparatorWidget() override { } |     virtual ~SeparatorWidget() override { } | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -72,18 +72,15 @@ void ToolBarContainer::recompute_preferred_size() | ||||||
|         if (!toolbar.is_visible()) |         if (!toolbar.is_visible()) | ||||||
|             continue; |             continue; | ||||||
|         ++visible_toolbar_count; |         ++visible_toolbar_count; | ||||||
|         if (m_orientation == Gfx::Orientation::Horizontal) |         preferred_size += toolbar.min_size().secondary_size_for_orientation(m_orientation); | ||||||
|             preferred_size += toolbar.preferred_size().height(); |  | ||||||
|         else |  | ||||||
|             preferred_size += toolbar.preferred_size().width(); |  | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     preferred_size += (visible_toolbar_count - 1) * 2; |     preferred_size += (visible_toolbar_count - 1) * 2; | ||||||
| 
 | 
 | ||||||
|     if (m_orientation == Gfx::Orientation::Horizontal) |     if (m_orientation == Gfx::Orientation::Horizontal) | ||||||
|         set_preferred_size(0, preferred_size); |         set_fixed_height(preferred_size); | ||||||
|     else |     else | ||||||
|         set_preferred_size(preferred_size, 0); |         set_fixed_width(preferred_size); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| ToolBarContainer::ToolBarContainer(Gfx::Orientation orientation) | ToolBarContainer::ToolBarContainer(Gfx::Orientation orientation) | ||||||
|  | @ -95,11 +92,6 @@ ToolBarContainer::ToolBarContainer(Gfx::Orientation orientation) | ||||||
|     set_frame_shape(Gfx::FrameShape::Box); |     set_frame_shape(Gfx::FrameShape::Box); | ||||||
|     set_frame_shadow(Gfx::FrameShadow::Sunken); |     set_frame_shadow(Gfx::FrameShadow::Sunken); | ||||||
| 
 | 
 | ||||||
|     if (m_orientation == Gfx::Orientation::Horizontal) |  | ||||||
|         set_size_policy(SizePolicy::Fill, SizePolicy::Fixed); |  | ||||||
|     else |  | ||||||
|         set_size_policy(SizePolicy::Fixed, SizePolicy::Fill); |  | ||||||
| 
 |  | ||||||
|     auto& layout = set_layout<VerticalBoxLayout>(); |     auto& layout = set_layout<VerticalBoxLayout>(); | ||||||
|     layout.set_spacing(2); |     layout.set_spacing(2); | ||||||
|     layout.set_margins({ 2, 2, 2, 2 }); |     layout.set_margins({ 2, 2, 2, 2 }); | ||||||
|  |  | ||||||
|  | @ -132,11 +132,6 @@ Widget::Widget() | ||||||
|     REGISTER_BOOL_PROPERTY("focused", is_focused, set_focus); |     REGISTER_BOOL_PROPERTY("focused", is_focused, set_focus); | ||||||
|     REGISTER_BOOL_PROPERTY("enabled", is_enabled, set_enabled); |     REGISTER_BOOL_PROPERTY("enabled", is_enabled, set_enabled); | ||||||
|     REGISTER_STRING_PROPERTY("tooltip", tooltip, set_tooltip); |     REGISTER_STRING_PROPERTY("tooltip", tooltip, set_tooltip); | ||||||
|     REGISTER_SIZE_PROPERTY("preferred_size", preferred_size, set_preferred_size); |  | ||||||
|     REGISTER_INT_PROPERTY("preferred_width", preferred_width, set_preferred_width); |  | ||||||
|     REGISTER_INT_PROPERTY("preferred_height", preferred_height, set_preferred_height); |  | ||||||
|     REGISTER_SIZE_POLICY_PROPERTY("horizontal_size_policy", horizontal_size_policy, set_horizontal_size_policy); |  | ||||||
|     REGISTER_SIZE_POLICY_PROPERTY("vertical_size_policy", vertical_size_policy, set_vertical_size_policy); |  | ||||||
| 
 | 
 | ||||||
|     REGISTER_SIZE_PROPERTY("min_size", min_size, set_min_size); |     REGISTER_SIZE_PROPERTY("min_size", min_size, set_min_size); | ||||||
|     REGISTER_SIZE_PROPERTY("max_size", max_size, set_max_size); |     REGISTER_SIZE_PROPERTY("max_size", max_size, set_max_size); | ||||||
|  | @ -686,31 +681,6 @@ void Widget::set_max_size(const Gfx::IntSize& size) | ||||||
|     invalidate_layout(); |     invalidate_layout(); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void Widget::set_preferred_size(const Gfx::IntSize& size) |  | ||||||
| { |  | ||||||
|     if (m_preferred_size == size) |  | ||||||
|         return; |  | ||||||
|     m_preferred_size = size; |  | ||||||
|     invalidate_layout(); |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| void Widget::set_size_policy(Orientation orientation, SizePolicy policy) |  | ||||||
| { |  | ||||||
|     if (orientation == Orientation::Horizontal) |  | ||||||
|         set_size_policy(policy, m_vertical_size_policy); |  | ||||||
|     else |  | ||||||
|         set_size_policy(m_horizontal_size_policy, policy); |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| void Widget::set_size_policy(SizePolicy horizontal_policy, SizePolicy vertical_policy) |  | ||||||
| { |  | ||||||
|     if (m_horizontal_size_policy == horizontal_policy && m_vertical_size_policy == vertical_policy) |  | ||||||
|         return; |  | ||||||
|     m_horizontal_size_policy = horizontal_policy; |  | ||||||
|     m_vertical_size_policy = vertical_policy; |  | ||||||
|     invalidate_layout(); |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| void Widget::invalidate_layout() | void Widget::invalidate_layout() | ||||||
| { | { | ||||||
|     if (window()) |     if (window()) | ||||||
|  |  | ||||||
|  | @ -112,14 +112,6 @@ public: | ||||||
|         return layout; |         return layout; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     SizePolicy horizontal_size_policy() const { return m_horizontal_size_policy; } |  | ||||||
|     SizePolicy vertical_size_policy() const { return m_vertical_size_policy; } |  | ||||||
|     SizePolicy size_policy(Orientation orientation) { return orientation == Orientation::Horizontal ? m_horizontal_size_policy : m_vertical_size_policy; } |  | ||||||
|     void set_size_policy(SizePolicy horizontal_policy, SizePolicy vertical_policy); |  | ||||||
|     void set_size_policy(Orientation, SizePolicy); |  | ||||||
|     void set_horizontal_size_policy(SizePolicy policy) { set_size_policy(policy, vertical_size_policy()); } |  | ||||||
|     void set_vertical_size_policy(SizePolicy policy) { set_size_policy(horizontal_size_policy(), policy); } |  | ||||||
| 
 |  | ||||||
|     Gfx::IntSize min_size() const { return m_min_size; } |     Gfx::IntSize min_size() const { return m_min_size; } | ||||||
|     void set_min_size(const Gfx::IntSize&); |     void set_min_size(const Gfx::IntSize&); | ||||||
|     void set_min_size(int width, int height) { set_min_size({ width, height }); } |     void set_min_size(int width, int height) { set_min_size({ width, height }); } | ||||||
|  | @ -158,15 +150,6 @@ public: | ||||||
|         set_max_height(height); |         set_max_height(height); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     Gfx::IntSize preferred_size() const { return m_preferred_size; } |  | ||||||
|     void set_preferred_size(const Gfx::IntSize&); |  | ||||||
|     void set_preferred_size(int width, int height) { set_preferred_size({ width, height }); } |  | ||||||
| 
 |  | ||||||
|     int preferred_width() const { return preferred_size().width(); } |  | ||||||
|     int preferred_height() const { return preferred_size().height(); } |  | ||||||
|     void set_preferred_width(int w) { set_preferred_size(w, preferred_height()); } |  | ||||||
|     void set_preferred_height(int h) { set_preferred_size(preferred_width(), h); } |  | ||||||
| 
 |  | ||||||
|     bool has_tooltip() const { return !m_tooltip.is_empty(); } |     bool has_tooltip() const { return !m_tooltip.is_empty(); } | ||||||
|     String tooltip() const { return m_tooltip; } |     String tooltip() const { return m_tooltip; } | ||||||
|     void set_tooltip(const StringView&); |     void set_tooltip(const StringView&); | ||||||
|  | @ -405,9 +388,6 @@ private: | ||||||
|     NonnullRefPtr<Gfx::Font> m_font; |     NonnullRefPtr<Gfx::Font> m_font; | ||||||
|     String m_tooltip; |     String m_tooltip; | ||||||
| 
 | 
 | ||||||
|     SizePolicy m_horizontal_size_policy { SizePolicy::Fill }; |  | ||||||
|     SizePolicy m_vertical_size_policy { SizePolicy::Fill }; |  | ||||||
|     Gfx::IntSize m_preferred_size; |  | ||||||
|     Gfx::IntSize m_min_size { -1, -1 }; |     Gfx::IntSize m_min_size { -1, -1 }; | ||||||
|     Gfx::IntSize m_max_size { -1, -1 }; |     Gfx::IntSize m_max_size { -1, -1 }; | ||||||
|     Margins m_content_margins; |     Margins m_content_margins; | ||||||
|  |  | ||||||
|  | @ -542,10 +542,10 @@ void Window::set_main_widget(Widget* widget) | ||||||
|     if (m_main_widget) { |     if (m_main_widget) { | ||||||
|         add_child(*widget); |         add_child(*widget); | ||||||
|         auto new_window_rect = rect(); |         auto new_window_rect = rect(); | ||||||
|         if (m_main_widget->horizontal_size_policy() == SizePolicy::Fixed) |         if (m_main_widget->min_width() >= 0) | ||||||
|             new_window_rect.set_width(m_main_widget->preferred_size().width()); |             new_window_rect.set_width(max(new_window_rect.width(), m_main_widget->min_width())); | ||||||
|         if (m_main_widget->vertical_size_policy() == SizePolicy::Fixed) |         if (m_main_widget->min_height() >= 0) | ||||||
|             new_window_rect.set_height(m_main_widget->preferred_size().height()); |             new_window_rect.set_height(max(new_window_rect.height(), m_main_widget->min_height())); | ||||||
|         set_rect(new_window_rect); |         set_rect(new_window_rect); | ||||||
|         m_main_widget->set_relative_rect({ {}, new_window_rect.size() }); |         m_main_widget->set_relative_rect({ {}, new_window_rect.size() }); | ||||||
|         m_main_widget->set_window(this); |         m_main_widget->set_window(this); | ||||||
|  |  | ||||||
|  | @ -908,8 +908,7 @@ void TerminalWidget::terminal_did_resize(u16 columns, u16 rows) | ||||||
|     m_pixel_height = (frame_thickness() * 2) + (m_inset * 2) + (rows * (font().glyph_height() + m_line_spacing)); |     m_pixel_height = (frame_thickness() * 2) + (m_inset * 2) + (rows * (font().glyph_height() + m_line_spacing)); | ||||||
| 
 | 
 | ||||||
|     if (m_automatic_size_policy) { |     if (m_automatic_size_policy) { | ||||||
|         set_size_policy(GUI::SizePolicy::Fixed, GUI::SizePolicy::Fixed); |         set_fixed_size(m_pixel_width, m_pixel_height); | ||||||
|         set_preferred_size(m_pixel_width, m_pixel_height); |  | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     m_needs_background_fill = true; |     m_needs_background_fill = true; | ||||||
|  |  | ||||||
|  | @ -75,7 +75,6 @@ public: | ||||||
| 
 | 
 | ||||||
|         m_root_container = m_slider_window->set_main_widget<GUI::Label>(); |         m_root_container = m_slider_window->set_main_widget<GUI::Label>(); | ||||||
|         m_root_container->set_fill_with_background_color(true); |         m_root_container->set_fill_with_background_color(true); | ||||||
|         m_root_container->set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fill); |  | ||||||
|         m_root_container->set_layout<GUI::VerticalBoxLayout>(); |         m_root_container->set_layout<GUI::VerticalBoxLayout>(); | ||||||
|         m_root_container->layout()->set_margins({ 0, 4, 0, 4 }); |         m_root_container->layout()->set_margins({ 0, 4, 0, 4 }); | ||||||
|         m_root_container->layout()->set_spacing(0); |         m_root_container->layout()->set_spacing(0); | ||||||
|  | @ -84,8 +83,7 @@ public: | ||||||
|         m_root_container->set_frame_shadow(Gfx::FrameShadow::Raised); |         m_root_container->set_frame_shadow(Gfx::FrameShadow::Raised); | ||||||
| 
 | 
 | ||||||
|         m_percent_box = m_root_container->add<GUI::CheckBox>("\xE2\x84\xB9"); |         m_percent_box = m_root_container->add<GUI::CheckBox>("\xE2\x84\xB9"); | ||||||
|         m_percent_box->set_size_policy(GUI::SizePolicy::Fixed, GUI::SizePolicy::Fixed); |         m_percent_box->set_fixed_size(27, 16); | ||||||
|         m_percent_box->set_preferred_size(27, 16); |  | ||||||
|         m_percent_box->set_checked(false); |         m_percent_box->set_checked(false); | ||||||
|         m_percent_box->set_tooltip("Show percent"); |         m_percent_box->set_tooltip("Show percent"); | ||||||
|         m_percent_box->on_checked = [&](bool show_percent) { |         m_percent_box->on_checked = [&](bool show_percent) { | ||||||
|  | @ -105,7 +103,6 @@ public: | ||||||
|         m_slider->set_max(20); |         m_slider->set_max(20); | ||||||
|         m_slider->set_value(0); |         m_slider->set_value(0); | ||||||
|         m_slider->set_knob_size_mode(GUI::Slider::KnobSizeMode::Proportional); |         m_slider->set_knob_size_mode(GUI::Slider::KnobSizeMode::Proportional); | ||||||
|         m_slider->set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fill); |  | ||||||
|         m_slider->on_value_changed = [&](int value) { |         m_slider->on_value_changed = [&](int value) { | ||||||
|             int volume = clamp((20 - value) * 5, 0, 100); |             int volume = clamp((20 - value) * 5, 0, 100); | ||||||
|             float volume_log = ((volume / 100.0f) * (volume / 100.0f)) * 100.0f; |             float volume_log = ((volume / 100.0f) * (volume / 100.0f)) * 100.0f; | ||||||
|  | @ -114,8 +111,7 @@ public: | ||||||
|         }; |         }; | ||||||
| 
 | 
 | ||||||
|         m_mute_box = m_root_container->add<GUI::CheckBox>("\xE2\x9D\x8C"); |         m_mute_box = m_root_container->add<GUI::CheckBox>("\xE2\x9D\x8C"); | ||||||
|         m_mute_box->set_size_policy(GUI::SizePolicy::Fixed, GUI::SizePolicy::Fixed); |         m_mute_box->set_fixed_size(27, 16); | ||||||
|         m_mute_box->set_preferred_size(27, 16); |  | ||||||
|         m_mute_box->set_checked(false); |         m_mute_box->set_checked(false); | ||||||
|         m_mute_box->set_tooltip("Mute"); |         m_mute_box->set_tooltip("Mute"); | ||||||
|         m_mute_box->on_checked = [&](bool is_muted) { |         m_mute_box->on_checked = [&](bool is_muted) { | ||||||
|  |  | ||||||
|  | @ -69,7 +69,6 @@ public: | ||||||
| 
 | 
 | ||||||
|         auto& root_container = m_calendar_window->set_main_widget<GUI::Label>(); |         auto& root_container = m_calendar_window->set_main_widget<GUI::Label>(); | ||||||
|         root_container.set_fill_with_background_color(true); |         root_container.set_fill_with_background_color(true); | ||||||
|         root_container.set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fill); |  | ||||||
|         root_container.set_layout<GUI::VerticalBoxLayout>(); |         root_container.set_layout<GUI::VerticalBoxLayout>(); | ||||||
|         root_container.layout()->set_margins({ 0, 2, 0, 2 }); |         root_container.layout()->set_margins({ 0, 2, 0, 2 }); | ||||||
|         root_container.layout()->set_spacing(0); |         root_container.layout()->set_spacing(0); | ||||||
|  | @ -78,15 +77,13 @@ public: | ||||||
|         root_container.set_frame_shadow(Gfx::FrameShadow::Raised); |         root_container.set_frame_shadow(Gfx::FrameShadow::Raised); | ||||||
| 
 | 
 | ||||||
|         auto& navigation_container = root_container.add<GUI::Widget>(); |         auto& navigation_container = root_container.add<GUI::Widget>(); | ||||||
|         navigation_container.set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed); |         navigation_container.set_fixed_height(24); | ||||||
|         navigation_container.set_preferred_size(0, 24); |  | ||||||
|         navigation_container.set_layout<GUI::HorizontalBoxLayout>(); |         navigation_container.set_layout<GUI::HorizontalBoxLayout>(); | ||||||
|         navigation_container.layout()->set_margins({ 2, 2, 3, 2 }); |         navigation_container.layout()->set_margins({ 2, 2, 3, 2 }); | ||||||
| 
 | 
 | ||||||
|         m_prev_date = navigation_container.add<GUI::Button>(); |         m_prev_date = navigation_container.add<GUI::Button>(); | ||||||
|         m_prev_date->set_button_style(Gfx::ButtonStyle::CoolBar); |         m_prev_date->set_button_style(Gfx::ButtonStyle::CoolBar); | ||||||
|         m_prev_date->set_size_policy(GUI::SizePolicy::Fixed, GUI::SizePolicy::Fixed); |         m_prev_date->set_fixed_size(24, 24); | ||||||
|         m_prev_date->set_preferred_size(24, 24); |  | ||||||
|         m_prev_date->set_icon(Gfx::Bitmap::load_from_file("/res/icons/16x16/go-back.png")); |         m_prev_date->set_icon(Gfx::Bitmap::load_from_file("/res/icons/16x16/go-back.png")); | ||||||
|         m_prev_date->on_click = [&](auto) { |         m_prev_date->on_click = [&](auto) { | ||||||
|             unsigned int target_month = m_calendar->selected_month(); |             unsigned int target_month = m_calendar->selected_month(); | ||||||
|  | @ -108,8 +105,7 @@ public: | ||||||
| 
 | 
 | ||||||
|         m_selected_calendar_button = navigation_container.add<GUI::Button>(); |         m_selected_calendar_button = navigation_container.add<GUI::Button>(); | ||||||
|         m_selected_calendar_button->set_button_style(Gfx::ButtonStyle::CoolBar); |         m_selected_calendar_button->set_button_style(Gfx::ButtonStyle::CoolBar); | ||||||
|         m_selected_calendar_button->set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed); |         m_selected_calendar_button->set_fixed_height(24); | ||||||
|         m_selected_calendar_button->set_preferred_size(0, 24); |  | ||||||
|         m_selected_calendar_button->on_click = [&](auto) { |         m_selected_calendar_button->on_click = [&](auto) { | ||||||
|             m_calendar->toggle_mode(); |             m_calendar->toggle_mode(); | ||||||
|             m_selected_calendar_button->set_text(m_calendar->selected_calendar_text(GUI::Calendar::LongNames)); |             m_selected_calendar_button->set_text(m_calendar->selected_calendar_text(GUI::Calendar::LongNames)); | ||||||
|  | @ -117,8 +113,7 @@ public: | ||||||
| 
 | 
 | ||||||
|         m_next_date = navigation_container.add<GUI::Button>(); |         m_next_date = navigation_container.add<GUI::Button>(); | ||||||
|         m_next_date->set_button_style(Gfx::ButtonStyle::CoolBar); |         m_next_date->set_button_style(Gfx::ButtonStyle::CoolBar); | ||||||
|         m_next_date->set_size_policy(GUI::SizePolicy::Fixed, GUI::SizePolicy::Fixed); |         m_next_date->set_fixed_size(24, 24); | ||||||
|         m_next_date->set_preferred_size(24, 24); |  | ||||||
|         m_next_date->set_icon(Gfx::Bitmap::load_from_file("/res/icons/16x16/go-forward.png")); |         m_next_date->set_icon(Gfx::Bitmap::load_from_file("/res/icons/16x16/go-forward.png")); | ||||||
|         m_next_date->on_click = [&](auto) { |         m_next_date->on_click = [&](auto) { | ||||||
|             unsigned int target_month = m_calendar->selected_month(); |             unsigned int target_month = m_calendar->selected_month(); | ||||||
|  | @ -139,19 +134,16 @@ public: | ||||||
|         }; |         }; | ||||||
| 
 | 
 | ||||||
|         auto& divider1_container = root_container.add<GUI::Widget>(); |         auto& divider1_container = root_container.add<GUI::Widget>(); | ||||||
|         divider1_container.set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed); |         divider1_container.set_fixed_height(2); | ||||||
|         divider1_container.set_preferred_size(0, 2); |  | ||||||
|         divider1_container.set_layout<GUI::HorizontalBoxLayout>(); |         divider1_container.set_layout<GUI::HorizontalBoxLayout>(); | ||||||
|         divider1_container.layout()->set_margins({ 2, 0, 3, 0 }); |         divider1_container.layout()->set_margins({ 2, 0, 3, 0 }); | ||||||
| 
 | 
 | ||||||
|         auto& divider1 = divider1_container.add<GUI::Frame>(); |         auto& divider1 = divider1_container.add<GUI::Frame>(); | ||||||
|         divider1.set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed); |         divider1.set_fixed_height(2); | ||||||
|         divider1.set_preferred_size(0, 2); |  | ||||||
|         divider1.set_frame_shape(Gfx::FrameShape::Panel); |         divider1.set_frame_shape(Gfx::FrameShape::Panel); | ||||||
| 
 | 
 | ||||||
|         auto& calendar_frame_container = root_container.add<GUI::Widget>(); |         auto& calendar_frame_container = root_container.add<GUI::Widget>(); | ||||||
|         calendar_frame_container.set_layout<GUI::HorizontalBoxLayout>(); |         calendar_frame_container.set_layout<GUI::HorizontalBoxLayout>(); | ||||||
|         calendar_frame_container.set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fill); |  | ||||||
|         calendar_frame_container.layout()->set_margins({ 4, 4, 5, 4 }); |         calendar_frame_container.layout()->set_margins({ 4, 4, 5, 4 }); | ||||||
| 
 | 
 | ||||||
|         auto& calendar_frame = calendar_frame_container.add<GUI::Frame>(); |         auto& calendar_frame = calendar_frame_container.add<GUI::Frame>(); | ||||||
|  | @ -170,27 +162,23 @@ public: | ||||||
|         }; |         }; | ||||||
| 
 | 
 | ||||||
|         auto& divider2_container = root_container.add<GUI::Widget>(); |         auto& divider2_container = root_container.add<GUI::Widget>(); | ||||||
|         divider2_container.set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed); |         divider2_container.set_fixed_height(2); | ||||||
|         divider2_container.set_preferred_size(0, 2); |  | ||||||
|         divider2_container.set_layout<GUI::HorizontalBoxLayout>(); |         divider2_container.set_layout<GUI::HorizontalBoxLayout>(); | ||||||
|         divider2_container.layout()->set_margins({ 2, 0, 3, 0 }); |         divider2_container.layout()->set_margins({ 2, 0, 3, 0 }); | ||||||
| 
 | 
 | ||||||
|         auto& divider2 = divider2_container.add<GUI::Frame>(); |         auto& divider2 = divider2_container.add<GUI::Frame>(); | ||||||
|         divider2.set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed); |         divider2.set_fixed_height(2); | ||||||
|         divider2.set_preferred_size(0, 2); |  | ||||||
|         divider2.set_frame_shape(Gfx::FrameShape::Panel); |         divider2.set_frame_shape(Gfx::FrameShape::Panel); | ||||||
| 
 | 
 | ||||||
|         auto& settings_container = root_container.add<GUI::Widget>(); |         auto& settings_container = root_container.add<GUI::Widget>(); | ||||||
|         settings_container.set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed); |         settings_container.set_fixed_height(24); | ||||||
|         settings_container.set_preferred_size(0, 24); |  | ||||||
|         settings_container.set_layout<GUI::HorizontalBoxLayout>(); |         settings_container.set_layout<GUI::HorizontalBoxLayout>(); | ||||||
|         settings_container.layout()->set_margins({ 2, 2, 3, 2 }); |         settings_container.layout()->set_margins({ 2, 2, 3, 2 }); | ||||||
|         settings_container.layout()->add_spacer(); |         settings_container.layout()->add_spacer(); | ||||||
| 
 | 
 | ||||||
|         m_jump_to_button = settings_container.add<GUI::Button>(); |         m_jump_to_button = settings_container.add<GUI::Button>(); | ||||||
|         m_jump_to_button->set_button_style(Gfx::ButtonStyle::CoolBar); |         m_jump_to_button->set_button_style(Gfx::ButtonStyle::CoolBar); | ||||||
|         m_jump_to_button->set_size_policy(GUI::SizePolicy::Fixed, GUI::SizePolicy::Fixed); |         m_jump_to_button->set_fixed_size(24, 24); | ||||||
|         m_jump_to_button->set_preferred_size(24, 24); |  | ||||||
|         m_jump_to_button->set_icon(Gfx::Bitmap::load_from_file("/res/icons/16x16/calendar-date.png")); |         m_jump_to_button->set_icon(Gfx::Bitmap::load_from_file("/res/icons/16x16/calendar-date.png")); | ||||||
|         m_jump_to_button->set_tooltip("Jump to today"); |         m_jump_to_button->set_tooltip("Jump to today"); | ||||||
|         m_jump_to_button->on_click = [this](auto) { |         m_jump_to_button->on_click = [this](auto) { | ||||||
|  | @ -199,11 +187,10 @@ public: | ||||||
| 
 | 
 | ||||||
|         m_calendar_launcher = settings_container.add<GUI::Button>(); |         m_calendar_launcher = settings_container.add<GUI::Button>(); | ||||||
|         m_calendar_launcher->set_button_style(Gfx::ButtonStyle::CoolBar); |         m_calendar_launcher->set_button_style(Gfx::ButtonStyle::CoolBar); | ||||||
|         m_calendar_launcher->set_size_policy(GUI::SizePolicy::Fixed, GUI::SizePolicy::Fixed); |         m_calendar_launcher->set_fixed_size(24, 24); | ||||||
|         m_calendar_launcher->set_preferred_size(24, 24); |  | ||||||
|         m_calendar_launcher->set_icon(Gfx::Bitmap::load_from_file("/res/icons/16x16/app-calendar.png")); |         m_calendar_launcher->set_icon(Gfx::Bitmap::load_from_file("/res/icons/16x16/app-calendar.png")); | ||||||
|         m_calendar_launcher->set_tooltip("Calendar"); |         m_calendar_launcher->set_tooltip("Calendar"); | ||||||
|         m_calendar_launcher->on_click = [this](auto) { |         m_calendar_launcher->on_click = [](auto) { | ||||||
|             pid_t pid; |             pid_t pid; | ||||||
|             const char* argv[] = { "Calendar", nullptr }; |             const char* argv[] = { "Calendar", nullptr }; | ||||||
|             if ((errno = posix_spawn(&pid, "/bin/Calendar", nullptr, nullptr, const_cast<char**>(argv), environ))) { |             if ((errno = posix_spawn(&pid, "/bin/Calendar", nullptr, nullptr, const_cast<char**>(argv), environ))) { | ||||||
|  |  | ||||||
|  | @ -105,8 +105,7 @@ NotificationWindow::NotificationWindow(const String& text, const String& title, | ||||||
|     text_label.set_text_alignment(Gfx::TextAlignment::CenterLeft); |     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_fixed_width(36); | ||||||
|     right_container.set_preferred_size(36, 0); |  | ||||||
|     right_container.set_layout<GUI::HorizontalBoxLayout>(); |     right_container.set_layout<GUI::HorizontalBoxLayout>(); | ||||||
| 
 | 
 | ||||||
|     on_close_request = [this] { |     on_close_request = [this] { | ||||||
|  |  | ||||||
|  | @ -75,8 +75,7 @@ ShutdownDialog::ShutdownDialog() | ||||||
| 
 | 
 | ||||||
|     auto& header = main.add<GUI::Label>(); |     auto& header = main.add<GUI::Label>(); | ||||||
|     header.set_text("What would you like to do?"); |     header.set_text("What would you like to do?"); | ||||||
|     header.set_preferred_size(0, 16); |     header.set_fixed_height(16); | ||||||
|     header.set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed); |  | ||||||
|     header.set_font(Gfx::Font::default_bold_font()); |     header.set_font(Gfx::Font::default_bold_font()); | ||||||
| 
 | 
 | ||||||
|     for (size_t i = 0; i < options.size(); i++) { |     for (size_t i = 0; i < options.size(); i++) { | ||||||
|  |  | ||||||
|  | @ -96,7 +96,6 @@ TaskbarWindow::~TaskbarWindow() | ||||||
| void TaskbarWindow::create_quick_launch_bar() | void TaskbarWindow::create_quick_launch_bar() | ||||||
| { | { | ||||||
|     auto& quick_launch_bar = main_widget()->add<GUI::Frame>(); |     auto& quick_launch_bar = main_widget()->add<GUI::Frame>(); | ||||||
|     quick_launch_bar.set_size_policy(GUI::SizePolicy::Fixed, GUI::SizePolicy::Fixed); |  | ||||||
|     quick_launch_bar.set_layout<GUI::HorizontalBoxLayout>(); |     quick_launch_bar.set_layout<GUI::HorizontalBoxLayout>(); | ||||||
|     quick_launch_bar.layout()->set_spacing(0); |     quick_launch_bar.layout()->set_spacing(0); | ||||||
|     quick_launch_bar.layout()->set_margins({ 3, 0, 3, 0 }); |     quick_launch_bar.layout()->set_margins({ 3, 0, 3, 0 }); | ||||||
|  | @ -116,9 +115,9 @@ void TaskbarWindow::create_quick_launch_bar() | ||||||
|         if (!af->is_valid()) |         if (!af->is_valid()) | ||||||
|             continue; |             continue; | ||||||
|         auto app_executable = af->executable(); |         auto app_executable = af->executable(); | ||||||
|  |         const int button_size = 24; | ||||||
|         auto& button = quick_launch_bar.add<GUI::Button>(); |         auto& button = quick_launch_bar.add<GUI::Button>(); | ||||||
|         button.set_size_policy(GUI::SizePolicy::Fixed, GUI::SizePolicy::Fixed); |         button.set_fixed_size(button_size, button_size); | ||||||
|         button.set_preferred_size(24, 24); |  | ||||||
|         button.set_button_style(Gfx::ButtonStyle::CoolBar); |         button.set_button_style(Gfx::ButtonStyle::CoolBar); | ||||||
|         button.set_icon(af->icon().bitmap_for_size(16)); |         button.set_icon(af->icon().bitmap_for_size(16)); | ||||||
|         button.set_tooltip(af->name()); |         button.set_tooltip(af->name()); | ||||||
|  | @ -143,10 +142,10 @@ void TaskbarWindow::create_quick_launch_bar() | ||||||
|         if (!first) |         if (!first) | ||||||
|             total_width += quick_launch_bar.layout()->spacing(); |             total_width += quick_launch_bar.layout()->spacing(); | ||||||
|         first = false; |         first = false; | ||||||
|         total_width += button.preferred_width(); |         total_width += button_size; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     quick_launch_bar.set_preferred_size(total_width, 24); |     quick_launch_bar.set_fixed_size(total_width, 24); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void TaskbarWindow::on_screen_rect_change(const Gfx::IntRect& rect) | void TaskbarWindow::on_screen_rect_change(const Gfx::IntRect& rect) | ||||||
|  | @ -158,9 +157,8 @@ void TaskbarWindow::on_screen_rect_change(const Gfx::IntRect& rect) | ||||||
| NonnullRefPtr<GUI::Button> TaskbarWindow::create_button(const WindowIdentifier& identifier) | NonnullRefPtr<GUI::Button> TaskbarWindow::create_button(const WindowIdentifier& identifier) | ||||||
| { | { | ||||||
|     auto& button = main_widget()->add<TaskbarButton>(identifier); |     auto& button = main_widget()->add<TaskbarButton>(identifier); | ||||||
|     button.set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fill); |     button.set_min_size(20, 23); | ||||||
|     button.set_min_size({ 20, 22 }); |     button.set_max_size(140, 23); | ||||||
|     button.set_max_size({ 140, 22 }); |  | ||||||
|     button.set_text_alignment(Gfx::TextAlignment::CenterLeft); |     button.set_text_alignment(Gfx::TextAlignment::CenterLeft); | ||||||
|     button.set_icon(*m_default_icon); |     button.set_icon(*m_default_icon); | ||||||
|     return button; |     return button; | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Andreas Kling
						Andreas Kling