diff --git a/Userland/Libraries/LibGUI/Widget.cpp b/Userland/Libraries/LibGUI/Widget.cpp index d613aed0bd..80cfc8265f 100644 --- a/Userland/Libraries/LibGUI/Widget.cpp +++ b/Userland/Libraries/LibGUI/Widget.cpp @@ -780,16 +780,18 @@ void Widget::set_font_fixed_width(bool fixed_width) set_font(Gfx::FontDatabase::the().get(Gfx::FontDatabase::the().default_font().family(), m_font->presentation_size(), m_font->weight(), m_font->slope())); } -void Widget::set_min_size(Gfx::IntSize const& size) +void Widget::set_min_size(UISize const& size) { + VERIFY(size.width().is_one_of(SpecialDimension::Regular, SpecialDimension::Shrink)); if (m_min_size == size) return; m_min_size = size; invalidate_layout(); } -void Widget::set_max_size(Gfx::IntSize const& size) +void Widget::set_max_size(UISize const& size) { + VERIFY(size.width().is_one_of(SpecialDimension::Regular, SpecialDimension::Grow)); if (m_max_size == size) return; m_max_size = size; diff --git a/Userland/Libraries/LibGUI/Widget.h b/Userland/Libraries/LibGUI/Widget.h index 449872a876..12bc8e7519 100644 --- a/Userland/Libraries/LibGUI/Widget.h +++ b/Userland/Libraries/LibGUI/Widget.h @@ -18,6 +18,7 @@ #include #include #include +#include #include #include #include @@ -80,40 +81,43 @@ public: return layout; } - Gfx::IntSize min_size() const { return m_min_size; } - void set_min_size(Gfx::IntSize const&); - void set_min_size(int width, int height) { set_min_size({ width, height }); } + UISize min_size() const { return m_min_size; } + void set_min_size(UISize const&); + void set_min_size(UIDimension width, UIDimension height) { set_min_size({ width, height }); } - int min_width() const { return m_min_size.width(); } - int min_height() const { return m_min_size.height(); } - void set_min_width(int width) { set_min_size(width, min_height()); } - void set_min_height(int height) { set_min_size(min_width(), height); } + UIDimension min_width() const { return m_min_size.width(); } + UIDimension min_height() const { return m_min_size.height(); } + void set_min_width(UIDimension width) { set_min_size(width, min_height()); } + void set_min_height(UIDimension height) { set_min_size(min_width(), height); } - Gfx::IntSize max_size() const { return m_max_size; } - void set_max_size(Gfx::IntSize const&); - void set_max_size(int width, int height) { set_max_size({ width, height }); } + UISize max_size() const { return m_max_size; } + void set_max_size(UISize const&); + void set_max_size(UIDimension width, UIDimension height) { set_max_size({ width, height }); } - int max_width() const { return m_max_size.width(); } - int max_height() const { return m_max_size.height(); } - void set_max_width(int width) { set_max_size(width, max_height()); } - void set_max_height(int height) { set_max_size(max_width(), height); } + UIDimension max_width() const { return m_max_size.width(); } + UIDimension max_height() const { return m_max_size.height(); } + void set_max_width(UIDimension width) { set_max_size(width, max_height()); } + void set_max_height(UIDimension height) { set_max_size(max_width(), height); } - void set_fixed_size(Gfx::IntSize const& size) + void set_fixed_size(UISize const& size) { + VERIFY(size.has_only_int_values()); set_min_size(size); set_max_size(size); } - void set_fixed_size(int width, int height) { set_fixed_size({ width, height }); } + void set_fixed_size(UIDimension width, UIDimension height) { set_fixed_size({ width, height }); } - void set_fixed_width(int width) + void set_fixed_width(UIDimension width) { + VERIFY(width.is_int()); set_min_width(width); set_max_width(width); } - void set_fixed_height(int height) + void set_fixed_height(UIDimension height) { + VERIFY(height.is_int()); set_min_height(height); set_max_height(height); } @@ -377,8 +381,8 @@ private: NonnullRefPtr m_font; String m_tooltip; - Gfx::IntSize m_min_size { -1, -1 }; - Gfx::IntSize m_max_size { -1, -1 }; + UISize m_min_size { SpecialDimension::Shrink }; + UISize m_max_size { SpecialDimension::Grow }; Margins m_grabbable_margins; bool m_fill_with_background_color { false };