refactor(ui/slider): improve track/thumb initialization and validation

Rename track/thumb accessors from set_track/set_thumb to get_track/get_thumb.
Add private init methods and a constant THUMB_WIDTH.
Add validation to set_width with log and assert.
Modify set_height to assume non-null m_thumb.
This commit is contained in:
2026-07-14 21:19:56 +08:00
parent a6fbbe8e1e
commit 4653ae9f06
2 changed files with 27 additions and 13 deletions

View File

@@ -10,15 +10,13 @@ public:
Slider& set_slider(float* value, const float& min, const float& max);
Image& set_track();
Image& set_thumb();
Image& get_track();
Image& get_thumb();
float width() const override;
float height() const override;
Slider& set_scale(float scale);
Slider& set_width(float width);
Slider& set_height(float h);
@@ -26,6 +24,11 @@ public:
bool handle_mouse_button_event(const MouseButtonEvent& e) override;
private:
static constexpr float THUMB_WIDTH = 5.0f;
void init_track();
void init_thumb();
void update_value(float mouse_x);
void on_update(float) override;