aboutsummaryrefslogtreecommitdiff
path: root/include/gui
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2024-08-07 20:32:59 +0200
committerdec05eba <dec05eba@protonmail.com>2024-08-07 20:32:59 +0200
commitb709805cfac4d1fe1bfe28e497a3e48e224372a8 (patch)
tree82f4bb638805dd58017d933fafd2143eb8019637 /include/gui
parent2ea32e11093a4d057338c02abbff4807446ff8de (diff)
Move settings ui to SettingsPage class, show different widgets for different settings page, show different widgets depending on combobox selections
Diffstat (limited to 'include/gui')
-rw-r--r--include/gui/ComboBox.hpp6
-rw-r--r--include/gui/RadioButton.hpp2
-rw-r--r--include/gui/ScrollablePage.hpp1
-rw-r--r--include/gui/Widget.hpp2
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);