diff options
author | Andreas Kling <awesomekling@gmail.com> | 2019-07-27 09:34:28 +0200 |
---|---|---|
committer | Andreas Kling <awesomekling@gmail.com> | 2019-07-27 09:34:28 +0200 |
commit | 7dc7f11ed8355833b2432b65c1c4ef05ee1782f8 (patch) | |
tree | 8b9965fc74ac1753d20885c687f1a57b89bc7d57 /Libraries | |
parent | 10c35d345ad07a50a5f0f48639bb84409b1f3b02 (diff) | |
download | serenity-7dc7f11ed8355833b2432b65c1c4ef05ee1782f8.zip |
GWidget: Add set_size_policy(Orientation, Policy).
This allows you to set the policy for a single orientation rather than
both at the same time.
Diffstat (limited to 'Libraries')
-rw-r--r-- | Libraries/LibGUI/GWidget.cpp | 8 | ||||
-rw-r--r-- | Libraries/LibGUI/GWidget.h | 1 |
2 files changed, 9 insertions, 0 deletions
diff --git a/Libraries/LibGUI/GWidget.cpp b/Libraries/LibGUI/GWidget.cpp index eb963b0314..16961b30b2 100644 --- a/Libraries/LibGUI/GWidget.cpp +++ b/Libraries/LibGUI/GWidget.cpp @@ -404,6 +404,14 @@ void GWidget::set_preferred_size(const Size& size) invalidate_layout(); } +void GWidget::set_size_policy(Orientation orientation, SizePolicy policy) +{ + if (orientation == Orientation::Horizontal) + set_size_policy(policy, m_vertical_size_policy); + else + set_size_policy(m_horizontal_size_policy, policy); +} + void GWidget::set_size_policy(SizePolicy horizontal_policy, SizePolicy vertical_policy) { if (m_horizontal_size_policy == horizontal_policy && m_vertical_size_policy == vertical_policy) diff --git a/Libraries/LibGUI/GWidget.h b/Libraries/LibGUI/GWidget.h index dac6a11ae7..3d4bb00e51 100644 --- a/Libraries/LibGUI/GWidget.h +++ b/Libraries/LibGUI/GWidget.h @@ -44,6 +44,7 @@ public: SizePolicy vertical_size_policy() const { return m_vertical_size_policy; } SizePolicy size_policy(Orientation orientation) { return orientation == Orientation::Horizontal ? m_horizontal_size_policy : m_vertical_size_policy; } void set_size_policy(SizePolicy horizontal_policy, SizePolicy vertical_policy); + void set_size_policy(Orientation, SizePolicy); Size preferred_size() const { return m_preferred_size; } void set_preferred_size(const Size&); |