mirror of
https://github.com/fergalmoran/ladybird.git
synced 2026-01-06 16:45:03 +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:
@@ -57,8 +57,7 @@ IRCWindow::IRCWindow(IRCClient& client, void* owner, Type type, const String& na
|
||||
if (m_type == Channel) {
|
||||
auto& member_view = container.add<GUI::TableView>();
|
||||
member_view.set_column_headers_visible(false);
|
||||
member_view.set_size_policy(GUI::SizePolicy::Fixed, GUI::SizePolicy::Fill);
|
||||
member_view.set_preferred_size(100, 0);
|
||||
member_view.set_fixed_width(100);
|
||||
member_view.set_alternating_row_colors(false);
|
||||
member_view.set_model(channel().member_model());
|
||||
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->set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed);
|
||||
m_text_box->set_preferred_size(0, 19);
|
||||
m_text_box->set_fixed_height(19);
|
||||
m_text_box->on_return_pressed = [this] {
|
||||
if (m_type == Channel)
|
||||
m_client->handle_user_input_in_channel(m_name, m_text_box->text());
|
||||
|
||||
Reference in New Issue
Block a user