diff --git a/Libraries/LibGUI/Widget.cpp b/Libraries/LibGUI/Widget.cpp index 5c8f72c9ff..fba0fb25fa 100644 --- a/Libraries/LibGUI/Widget.cpp +++ b/Libraries/LibGUI/Widget.cpp @@ -145,6 +145,10 @@ Widget::Widget() REGISTER_INT_PROPERTY("min_height", min_height, set_min_height); REGISTER_INT_PROPERTY("max_height", max_height, set_max_height); + REGISTER_INT_PROPERTY("fixed_width", dummy_fixed_width, set_fixed_width); + REGISTER_INT_PROPERTY("fixed_height", dummy_fixed_height, set_fixed_height); + REGISTER_SIZE_PROPERTY("fixed_size", dummy_fixed_size, set_fixed_size); + register_property( "focus_policy", [this]() -> JsonValue { auto policy = focus_policy(); diff --git a/Libraries/LibGUI/Widget.h b/Libraries/LibGUI/Widget.h index 987f8d1d49..d8c0abc0f9 100644 --- a/Libraries/LibGUI/Widget.h +++ b/Libraries/LibGUI/Widget.h @@ -138,6 +138,26 @@ public: void set_max_width(int width) { set_max_size(width, max_height()); } void set_max_height(int height) { set_max_size(max_width(), height); } + void set_fixed_size(const Gfx::IntSize& size) + { + set_min_size(size); + set_max_size(size); + } + + void set_fixed_size(int width, int height) { set_fixed_size({ width, height }); } + + void set_fixed_width(int width) + { + set_min_width(width); + set_max_width(width); + } + + void set_fixed_height(int height) + { + set_min_height(height); + set_max_height(height); + } + Gfx::IntSize preferred_size() const { return m_preferred_size; } void set_preferred_size(const Gfx::IntSize&); void set_preferred_size(int width, int height) { set_preferred_size({ width, height }); } @@ -369,6 +389,11 @@ private: bool load_from_json(const JsonObject&); + // HACK: These are used as property getters for the fixed_* size property aliases. + int dummy_fixed_width() { return 0; } + int dummy_fixed_height() { return 0; } + Gfx::IntSize dummy_fixed_size() { return {}; } + Window* m_window { nullptr }; RefPtr m_layout;