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

LibGUI: Make Label padding work with left/right aligned text

The previous text_rect() algorithm only produced the right result for
horizontally centered labels.

This adds some missing padding to GUI::Statusbar which we've apparently
needed for some time. :^)
This commit is contained in:
Andreas Kling 2021-07-27 23:55:42 +02:00
parent 0c53c2dfa2
commit 3d4f93cf8d

View file

@ -67,12 +67,7 @@ void Label::set_text(String text)
Gfx::IntRect Label::text_rect() const
{
int indent = 0;
if (frame_thickness() > 0)
indent = font().glyph_width('x') / 2;
auto rect = frame_inner_rect();
rect.set_width(rect.width() - indent * 2);
return rect;
return frame_inner_rect().shrunken(frame_thickness() > 0 ? font().glyph_width('x') : 0, 0);
}
void Label::paint_event(PaintEvent& event)