1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 17:07:34 +00:00

LibGUI: Implement calculated_min_size() for Label

This commit is contained in:
thankyouverycool 2023-04-14 08:54:12 -04:00 committed by Andreas Kling
parent 479e67212a
commit 5294ef918e
2 changed files with 12 additions and 1 deletions

View file

@ -23,7 +23,7 @@ Label::Label(DeprecatedString text)
REGISTER_TEXT_WRAPPING_PROPERTY("text_wrapping", text_wrapping, set_text_wrapping);
set_preferred_size({ SpecialDimension::OpportunisticGrow });
set_min_height(22);
set_min_size({ SpecialDimension::Shrink });
set_frame_thickness(0);
set_frame_shadow(Gfx::FrameShadow::Plain);
@ -129,4 +129,14 @@ Optional<UISize> Label::calculated_preferred_size() const
return GUI::UISize(text_calculated_preferred_width(), text_calculated_preferred_height());
}
Optional<UISize> Label::calculated_min_size() const
{
int frame = frame_thickness() * 2;
int width = font().width_rounded_up("..."sv) + frame;
int height = font().pixel_size_rounded_up() + frame;
height = max(height, 22);
return UISize(width, height);
}
}