mirror of
https://github.com/zhenyan121/Cubed.git
synced 2026-08-08 17:57:02 +08:00
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:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user