From cb04c11b2c29d973cdda9b0336024946bb3ca93d Mon Sep 17 00:00:00 2001 From: dec05eba Date: Wed, 11 Sep 2024 19:19:10 +0200 Subject: Make checkbox nicer --- include/Theme.hpp | 2 ++ include/gui/CheckBox.hpp | 7 ++++++- include/gui/ScrollablePage.hpp | 4 ++++ 3 files changed, 12 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/Theme.hpp b/include/Theme.hpp index df25268..1db389a 100644 --- a/include/Theme.hpp +++ b/include/Theme.hpp @@ -37,6 +37,8 @@ namespace gsr { mgl::Texture stream_button_texture; mgl::Texture close_texture; mgl::Texture logo_texture; + mgl::Texture checkbox_circle_texture; + mgl::Texture checkbox_background_texture; double double_click_timeout_seconds = 0.4; diff --git a/include/gui/CheckBox.hpp b/include/gui/CheckBox.hpp index 19ffaf6..8703794 100644 --- a/include/gui/CheckBox.hpp +++ b/include/gui/CheckBox.hpp @@ -4,6 +4,7 @@ #include #include +#include namespace gsr { class CheckBox : public Widget { @@ -17,12 +18,16 @@ namespace gsr { mgl::vec2f get_size() override; - void set_checked(bool checked); + void set_checked(bool checked, bool animated = false); bool is_checked() const; private: + void apply_animation(); mgl::vec2f get_checkbox_size(); private: mgl::Text text; + mgl::Sprite background_sprite; + mgl::Sprite circle_sprite; bool checked = false; + float toggle_animation_value = 0.0f; }; } \ No newline at end of file diff --git a/include/gui/ScrollablePage.hpp b/include/gui/ScrollablePage.hpp index ade7c67..452d0e9 100644 --- a/include/gui/ScrollablePage.hpp +++ b/include/gui/ScrollablePage.hpp @@ -24,6 +24,10 @@ namespace gsr { void reset_scroll(); private: + void apply_animation(); + void limit_scroll(double child_height); + void limit_scroll_cursor(mgl::Window &window, double child_height, double scrollbar_empty_space); + void draw_scrollbar(); float get_scrollbar_width() const; private: mgl::vec2f size; -- cgit v1.2.3