diff options
Diffstat (limited to 'include/gui')
-rw-r--r-- | include/gui/ComboBox.hpp | 6 | ||||
-rw-r--r-- | include/gui/RadioButton.hpp | 2 | ||||
-rw-r--r-- | include/gui/ScrollablePage.hpp | 1 | ||||
-rw-r--r-- | include/gui/Widget.hpp | 2 |
4 files changed, 9 insertions, 2 deletions
diff --git a/include/gui/ComboBox.hpp b/include/gui/ComboBox.hpp index b4e7b78..ac9d02b 100644 --- a/include/gui/ComboBox.hpp +++ b/include/gui/ComboBox.hpp @@ -3,6 +3,8 @@ #include "Widget.hpp" #include <mglpp/graphics/Text.hpp> #include <mglpp/graphics/Sprite.hpp> + +#include <functional> #include <string> #include <vector> @@ -17,9 +19,11 @@ namespace gsr { void draw(mgl::Window &window, mgl::vec2f offset) override; void add_item(const std::string &text, const std::string &id); - void set_selected_item(const std::string &id); + void set_selected_item(const std::string &id, bool trigger_event = true); mgl::vec2f get_size() override; + + std::function<void(const std::string &text, const std::string &id)> on_selection_changed; private: void update_if_dirty(); float get_dropdown_arrow_height() const; diff --git a/include/gui/RadioButton.hpp b/include/gui/RadioButton.hpp index d4b1103..60f3e82 100644 --- a/include/gui/RadioButton.hpp +++ b/include/gui/RadioButton.hpp @@ -17,7 +17,7 @@ namespace gsr { void draw(mgl::Window &window, mgl::vec2f offset) override; void add_item(const std::string &text, const std::string &id); - void set_selected_item(const std::string &id); + void set_selected_item(const std::string &id, bool trigger_event = true); mgl::vec2f get_size() override; diff --git a/include/gui/ScrollablePage.hpp b/include/gui/ScrollablePage.hpp index 9d4623b..60d719f 100644 --- a/include/gui/ScrollablePage.hpp +++ b/include/gui/ScrollablePage.hpp @@ -13,6 +13,7 @@ namespace gsr { void draw(mgl::Window &window, mgl::vec2f offset) override; mgl::vec2f get_size() override; + mgl::vec2f get_inner_size() override; void set_margins(float top, float bottom, float left, float right); private: diff --git a/include/gui/Widget.hpp b/include/gui/Widget.hpp index 5b582da..498ca05 100644 --- a/include/gui/Widget.hpp +++ b/include/gui/Widget.hpp @@ -34,6 +34,8 @@ namespace gsr { virtual mgl::vec2f get_position() const; virtual mgl::vec2f get_size() = 0; + // This can be different from get_size, for example with ScrollablePage this excludes the margins + virtual mgl::vec2f get_inner_size() { return get_size(); } void set_horizontal_alignment(Alignment alignment); void set_vertical_alignment(Alignment alignment); |