35 Toggle(
const std::string &label =
"Toggle",
const std::string &name =
"Toggle");
68 inline std::shared_ptr<Text>
get_text() {
return m_text; }
75 inline void set_on_toggle(std::function<
void(
bool)> callback) { m_on_toggle = callback; }
93 bool contains_point(
float x,
float y,
float canvas_width,
float canvas_height)
const;
104 bool handle_click(
float x,
float y,
float canvas_width,
float canvas_height);
113 void render(
float canvas_width,
float canvas_height,
const glm::mat4 &projection)
override;
120 bool m_checked{
false};
123 float m_box_size{20.0f};
126 std::shared_ptr<Panel> m_box_bg;
129 std::shared_ptr<Panel> m_checkmark;
132 std::shared_ptr<Text> m_text;
135 std::function<void(
bool)> m_on_toggle;
138 glm::vec4 m_bg_color{0.2f, 0.2f, 0.2f, 1.0f};
139 glm::vec4 m_check_color{0.0f, 1.0f, 0.0f, 1.0f};
140 glm::vec4 m_text_color{1.0f, 1.0f, 1.0f, 1.0f};
~Toggle() override=default
Destructor.
bool is_checked() const
Get the toggle state.
Definition toggle.hpp:54
bool contains_point(float x, float y, float canvas_width, float canvas_height) const
Check if point is inside toggle.
Definition toggle.cpp:44
Toggle(const std::string &label="Toggle", const std::string &name="Toggle")
Constructor for Toggle.
Definition toggle.cpp:17
void set_box_size(float size)
Set checkbox size (default 20x20).
Definition toggle.hpp:82
void set_label(const std::string &label)
Set the label text.
Definition toggle.cpp:37
void set_checked(bool checked)
Set the toggle state.
Definition toggle.cpp:27
std::shared_ptr< Text > get_text()
Get the internal text element (for setting font).
Definition toggle.hpp:68
bool handle_click(float x, float y, float canvas_width, float canvas_height)
Handle mouse click.
Definition toggle.cpp:49
void set_on_toggle(std::function< void(bool)> callback)
Set the callback for state changes.
Definition toggle.hpp:75
void render(float canvas_width, float canvas_height, const glm::mat4 &projection) override
Render the toggle.
Definition toggle.cpp:61
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.