mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-12 11:09:18 +00:00
LibGUI: Use new layout system for basic widgets
This commit is contained in:
parent
bfbaad9f41
commit
19fac58e49
Notes:
sideshowbarker
2024-07-17 11:29:41 +09:00
Author: https://github.com/frhun
Commit: 19fac58e49
Pull-request: https://github.com/SerenityOS/serenity/pull/14261
Reviewed-by: https://github.com/AtkinsSJ ✅
Reviewed-by: https://github.com/MacDue
Reviewed-by: https://github.com/mjz19910
17 changed files with 85 additions and 18 deletions
|
@ -23,6 +23,8 @@ Label::Label(String text)
|
|||
REGISTER_TEXT_ALIGNMENT_PROPERTY("text_alignment", text_alignment, set_text_alignment);
|
||||
REGISTER_TEXT_WRAPPING_PROPERTY("text_wrapping", text_wrapping, set_text_wrapping);
|
||||
|
||||
set_preferred_size({ SpecialDimension::OpportunisticGrow, 22 });
|
||||
|
||||
set_frame_thickness(0);
|
||||
set_frame_shadow(Gfx::FrameShadow::Plain);
|
||||
set_frame_shape(Gfx::FrameShape::NoFrame);
|
||||
|
@ -112,10 +114,15 @@ void Label::size_to_fit()
|
|||
set_fixed_width(font().width(m_text) + m_autosize_padding * 2);
|
||||
}
|
||||
|
||||
int Label::preferred_height() const
|
||||
int Label::text_calculated_preferred_height() const
|
||||
{
|
||||
// FIXME: The 4 is taken from Gfx::Painter and should be available as
|
||||
// a constant instead.
|
||||
return Gfx::TextLayout(&font(), Utf8View { m_text }, text_rect()).bounding_rect(Gfx::TextWrapping::Wrap, 4).height();
|
||||
}
|
||||
|
||||
Optional<UISize> Label::calculated_preferred_size() const
|
||||
{
|
||||
return GUI::UISize(SpecialDimension::Grow, text_calculated_preferred_height());
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue