refactor(ui): move scale property to subclasses and fix resize event handling

Remove scale from base Widget class and add per-type set_scale/scale methods to Button, Image, and Label. Dispatch separate WindowResizeEvent alongside existing FrameBufferResizeEvent. Correct centering calculations from `+` to `-` in main menu and world UI managers.
This commit is contained in:
2026-07-13 13:06:09 +08:00
parent 1fa3b9cce8
commit e8157ab549
12 changed files with 59 additions and 39 deletions

View File

@@ -15,7 +15,10 @@ Label& Label::set_color(Color color) {
m_text.color = color;
return *this;
}
Label& Label::set_scale(float scale) {
m_scale = scale;
return *this;
}
void Label::update(float dt) { on_update(dt); }
void Label::on_update(float dt) { (void)dt; }
@@ -43,5 +46,5 @@ 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; }
float Label::scale() const { return m_scale; }
} // namespace Cubed