From 56977666e724bbd56ac013bfbd0c071963478e3f Mon Sep 17 00:00:00 2001 From: zhenyan121 <3367366583@qq.com> Date: Tue, 21 Jul 2026 20:21:13 +0800 Subject: [PATCH] fix(ui label): account for background offset in width/height --- src/ui/label.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/ui/label.cpp b/src/ui/label.cpp index 6fefd37..eb37ef9 100644 --- a/src/ui/label.cpp +++ b/src/ui/label.cpp @@ -21,6 +21,7 @@ Label& Label::set_scale(float scale) { Label& Label::set_background(std::unique_ptr background) { m_background = std::move(background); + m_background->set_offset({-3, -3}); return *this; } Widget* Label::get_background() { return m_background.get(); } @@ -59,17 +60,17 @@ const TextStyle& Label::text_style() const { return m_text; } float Label::width() const { if (m_fill_width || m_fill_parent) { - return Widget::width(); + return Widget::width() + 6.0f; } - return Widget::width() * m_scale; + return Widget::width() * m_scale + 6.0f; } float Label::height() const { if (m_fill_height || m_fill_parent) { - return Widget::height(); + return Widget::height() + 6.0f; } - return Widget::height() * m_scale; + return Widget::height() * m_scale + 6.0f; } float Label::real_width() const { return m_real_width; } float Label::real_height() const { return m_real_height; }