1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 05:07:35 +00:00

LibGUI: Use preferred_size to emulate old is_shrink_to_fit

This commit is contained in:
FrHun 2022-06-12 22:18:52 +02:00 committed by Sam Atkins
parent bd277939a1
commit 2600669b73
2 changed files with 6 additions and 7 deletions

View file

@ -1193,12 +1193,11 @@ bool Widget::has_focus_within() const
return window->focused_widget() == &effective_focus_widget || is_ancestor_of(*window->focused_widget());
}
void Widget::set_shrink_to_fit(bool b)
void Widget::set_shrink_to_fit(bool shrink_to_fit)
{
if (m_shrink_to_fit == b)
return;
m_shrink_to_fit = b;
invalidate_layout();
// This function is deprecated, and soon to be removed, it is only still here to ease the transition to UIDimensions
if (shrink_to_fit)
set_preferred_size(SpecialDimension::Fit);
}
bool Widget::has_pending_drop() const

View file

@ -312,8 +312,9 @@ public:
bool load_from_gml(StringView);
bool load_from_gml(StringView, RefPtr<Core::Object> (*unregistered_child_handler)(String const&));
// FIXME: remove this when all uses of shrink_to_fit are eliminated
void set_shrink_to_fit(bool);
bool is_shrink_to_fit() const { return m_shrink_to_fit; }
bool is_shrink_to_fit() const { return preferred_width().is_shrink() || preferred_height().is_shrink(); }
bool has_pending_drop() const;
@ -402,7 +403,6 @@ private:
bool m_updates_enabled { true };
bool m_accepts_emoji_input { false };
bool m_accepts_command_palette { true };
bool m_shrink_to_fit { false };
bool m_default_font { true };
NonnullRefPtr<Gfx::PaletteImpl> m_palette;