diff --git a/LibGUI/GBoxLayout.cpp b/LibGUI/GBoxLayout.cpp index 8e5ecad875..f226ff2404 100644 --- a/LibGUI/GBoxLayout.cpp +++ b/LibGUI/GBoxLayout.cpp @@ -13,23 +13,6 @@ GBoxLayout::~GBoxLayout() { } -#if 0 -Size GLayout::compute_preferred_size() const -{ - -} - - -static Size compute_preferred_size(GLayout::Entry& entry) -{ - if (entry.layout) - return entry.layout->compute_preferred_size(); - else { - return entry.widget->preferred_size(); - } -} -#endif - void GBoxLayout::run(GWidget& widget) { bool should_log = false; @@ -59,14 +42,18 @@ void GBoxLayout::run(GWidget& widget) printf("GBoxLayout: Subtracting for fixed %s{%p}, size: %s\n", entry.widget->class_name(), entry.widget.ptr(), entry.widget->preferred_size().to_string().characters()); printf("GBoxLayout: Available size before: %s\n", available_size.to_string().characters()); } - available_size -= entry.widget->preferred_size(); if (should_log) printf("GBoxLayout: Available size after: %s\n", available_size.to_string().characters()); ++number_of_entries_with_fixed_size; } + available_size -= { spacing(), spacing() }; } + available_size += { spacing(), spacing() }; + + available_size -= { margins().left() + margins().right(), margins().top() + margins().bottom() }; + if (should_log) printf("GBoxLayout: Number of visible: %d/%d\n", number_of_visible_entries, m_entries.size()); diff --git a/LibGUI/GInputBox.cpp b/LibGUI/GInputBox.cpp index bf315861f7..d401a66b62 100644 --- a/LibGUI/GInputBox.cpp +++ b/LibGUI/GInputBox.cpp @@ -24,7 +24,7 @@ void GInputBox::build() int text_width = widget->font().width(m_prompt); - set_rect(x(), y(), text_width + 80, 120); + set_rect(x(), y(), text_width + 80, 80); widget->set_layout(make(Orientation::Vertical)); widget->set_fill_with_background_color(true); @@ -41,6 +41,8 @@ void GInputBox::build() m_text_editor->set_preferred_size({ 0, 16 }); auto* button_container_outer = new GWidget(widget); + button_container_outer->set_size_policy(SizePolicy::Fill, SizePolicy::Fixed); + button_container_outer->set_preferred_size({ 0, 16 }); button_container_outer->set_layout(make(Orientation::Vertical)); auto* button_container_inner = new GWidget(button_container_outer); diff --git a/SharedGraphics/Size.h b/SharedGraphics/Size.h index 62cf8b1c4b..469bb7aaf9 100644 --- a/SharedGraphics/Size.h +++ b/SharedGraphics/Size.h @@ -39,6 +39,13 @@ public: return *this; } + Size& operator+=(const Size& other) + { + m_width += other.m_width; + m_height += other.m_height; + return *this; + } + operator WSAPI_Size() const; String to_string() const { return String::format("[%d,%d]", m_width, m_height); }