mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 10:48:11 +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
|
@ -112,8 +112,7 @@ Tab::Tab(Type type)
|
|||
toolbar.add_action(*m_reload_action);
|
||||
|
||||
m_location_box = toolbar.add<GUI::TextBox>();
|
||||
m_location_box->set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed);
|
||||
m_location_box->set_preferred_size(0, 22);
|
||||
m_location_box->set_fixed_height(22);
|
||||
m_location_box->set_placeholder("Address");
|
||||
|
||||
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->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_size_policy(GUI::SizePolicy::Fixed, GUI::SizePolicy::Fixed);
|
||||
m_bookmark_button->set_preferred_size(22, 22);
|
||||
m_bookmark_button->set_fixed_size(22, 22);
|
||||
|
||||
m_bookmark_button->on_click = [this](auto) {
|
||||
auto url = this->url().to_string();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue