mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 17:07:34 +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
|
@ -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->set_layout<GUI::HorizontalBoxLayout>();
|
||||
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_preferred_size(0, 24);
|
||||
m_open_button_and_recorded_sample_name_container->set_fixed_height(24);
|
||||
|
||||
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_preferred_size(24, 24);
|
||||
m_open_button->set_fixed_size(24, 24);
|
||||
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->on_click = [this](auto) {
|
||||
|
@ -124,8 +122,7 @@ SamplerWidget::SamplerWidget(TrackManager& track_manager)
|
|||
m_recorded_sample_name->set_text_alignment(Gfx::TextAlignment::CenterLeft);
|
||||
|
||||
m_wave_editor = add<WaveEditor>(m_track_manager);
|
||||
m_wave_editor->set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed);
|
||||
m_wave_editor->set_preferred_size(0, 100);
|
||||
m_wave_editor->set_fixed_height(100);
|
||||
}
|
||||
|
||||
SamplerWidget::~SamplerWidget()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue