summaryrefslogtreecommitdiff
path: root/DevTools/HackStudio/EditorWrapper.cpp
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2020-12-30 01:23:32 +0100
committerAndreas Kling <kling@serenityos.org>2020-12-30 01:36:41 +0100
commit7dc5a3ead86627d11b1bf8d243750e5e3390c067 (patch)
treebfcab42f5b00c5b368ac9ee4a288d7c0d9c4bd01 /DevTools/HackStudio/EditorWrapper.cpp
parentb2bba5ce5c06d40e2fbcfff4cf1412532f93ae6b (diff)
downloadserenity-7dc5a3ead86627d11b1bf8d243750e5e3390c067.zip
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. :^)
Diffstat (limited to 'DevTools/HackStudio/EditorWrapper.cpp')
-rw-r--r--DevTools/HackStudio/EditorWrapper.cpp9
1 files changed, 3 insertions, 6 deletions
diff --git a/DevTools/HackStudio/EditorWrapper.cpp b/DevTools/HackStudio/EditorWrapper.cpp
index e2f51cfbc5..c21396f251 100644
--- a/DevTools/HackStudio/EditorWrapper.cpp
+++ b/DevTools/HackStudio/EditorWrapper.cpp
@@ -40,21 +40,18 @@ EditorWrapper::EditorWrapper()
set_layout<GUI::VerticalBoxLayout>();
auto& label_wrapper = add<GUI::Widget>();
- label_wrapper.set_size_policy(GUI::SizePolicy::Fill, GUI::SizePolicy::Fixed);
- label_wrapper.set_preferred_size(0, 14);
+ label_wrapper.set_fixed_height(14);
label_wrapper.set_fill_with_background_color(true);
label_wrapper.set_layout<GUI::HorizontalBoxLayout>();
label_wrapper.layout()->set_margins({ 2, 0, 2, 0 });
m_filename_label = label_wrapper.add<GUI::Label>("(Untitled)");
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_preferred_size(0, 14);
+ m_filename_label->set_fixed_height(14);
m_cursor_label = label_wrapper.add<GUI::Label>("(Cursor)");
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_preferred_size(0, 14);
+ m_cursor_label->set_fixed_height(14);
m_editor = add<Editor>();
m_editor->set_ruler_visible(true);