feat(ui): support scaling of labels and images

Modify width() and height() methods to multiply by m_scale for both Label and Image. Rename internal dimensions to m_real_width and m_real_height for clarity. Adjust Button foreground position to vertically center when label is scaled.
This commit is contained in:
2026-07-13 11:40:27 +08:00
parent b5e0bb9290
commit 1fa3b9cce8
5 changed files with 10 additions and 9 deletions

View File

@@ -30,8 +30,8 @@ void Label::update_vertices() {
m_offset_x = textmesh.min_x;
m_offset_y = textmesh.min_y;
m_width = textmesh.width;
m_height = textmesh.height;
m_real_width = textmesh.width;
m_real_height = textmesh.height;
m_data.update_sum();
m_data.upload();
@@ -39,8 +39,8 @@ void Label::update_vertices() {
const UIVertexData& Label::data() const { return m_data; }
const TextStyle& Label::text_style() const { return m_text; }
float Label::width() const { return m_width; }
float Label::height() const { return m_height; }
float Label::width() const { return m_real_width * m_scale; }
float Label::height() const { return m_real_height * m_scale; }
float Label::offset_x() const { return m_offset_x; }
float Label::offset_y() const { return m_offset_y; }