37 Slider(
float min = 0.0f,
float max = 1.0f,
float initial_value = 0.5f,
const std::string &name =
"Slider");
110 bool contains_point(
float x,
float y,
float canvas_width,
float canvas_height)
const;
122 bool handle_mouse_button(
float x,
float y,
bool pressed,
float canvas_width,
float canvas_height);
132 void handle_mouse_drag(
float x,
float y,
float canvas_width,
float canvas_height);
141 void render(
float canvas_width,
float canvas_height,
const glm::mat4 &projection)
override;
152 bool m_dragging{
false};
158 bool m_show_value{
true};
161 float m_track_height{4.0f};
164 float m_handle_size{16.0f};
167 std::shared_ptr<Panel> m_track_bg;
170 std::shared_ptr<Panel> m_track_fill;
173 std::shared_ptr<Panel> m_handle;
176 std::shared_ptr<Text> m_label_text;
179 std::shared_ptr<Text> m_value_text;
182 std::function<void(
float)> m_on_value_changed;
185 glm::vec4 m_track_color{0.3f, 0.3f, 0.3f, 1.0f};
186 glm::vec4 m_fill_color{0.0f, 0.6f, 1.0f, 1.0f};
187 glm::vec4 m_handle_color{1.0f, 1.0f, 1.0f, 1.0f};
188 glm::vec4 m_text_color{1.0f, 1.0f, 1.0f, 1.0f};
197 void update_value_from_mouse(
float mouse_x,
float canvas_width,
float canvas_height);
void handle_mouse_drag(float x, float y, float canvas_width, float canvas_height)
Handle mouse drag.
Definition slider.cpp:82
std::shared_ptr< Text > get_label_text()
Get the label text element (for setting font).
Definition slider.hpp:92
void render(float canvas_width, float canvas_height, const glm::mat4 &projection) override
Render the slider.
Definition slider.cpp:97
std::shared_ptr< Text > get_value_text()
Get the value text element (for setting font).
Definition slider.hpp:99
float get_value() const
Get the current value.
Definition slider.hpp:56
bool handle_mouse_button(float x, float y, bool pressed, float canvas_width, float canvas_height)
Handle mouse button event.
Definition slider.cpp:68
~Slider() override=default
Destructor.
void set_value(float value)
Set the slider value.
Definition slider.cpp:36
void set_on_value_changed(std::function< void(float)> callback)
Set callback for value changes.
Definition slider.hpp:78
bool contains_point(float x, float y, float canvas_width, float canvas_height) const
Check if point is inside slider.
Definition slider.cpp:62
void set_range(float min, float max)
Set the value range.
Definition slider.cpp:51
void set_label(const std::string &label)
Set the label text.
Definition slider.cpp:57
Slider(float min=0.0f, float max=1.0f, float initial_value=0.5f, const std::string &name="Slider")
Constructor for Slider.
Definition slider.cpp:21
void set_show_value(bool show)
Set whether to show the value as text.
Definition slider.hpp:85
UIElement(const std::string &name="UIElement")
Constructor for UIElement.
Definition ui_element.cpp:10
Forward declarations for Assimp Material structure.
Definition model_loader.cpp:12
Panel UI element for displaying colored rectangles.
Text UI element for rendering text strings.
Base class for all UI elements.