aboutsummaryrefslogtreecommitdiff
path: root/include
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
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')
-rw-r--r--include/SettingsPage.hpp37
-rw-r--r--include/Theme.hpp1
-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
6 files changed, 47 insertions, 2 deletions
diff --git a/include/SettingsPage.hpp b/include/SettingsPage.hpp
new file mode 100644
index 0000000..aec7bed
--- /dev/null
+++ b/include/SettingsPage.hpp
@@ -0,0 +1,37 @@
+#pragma once
+
+#include "gui/StaticPage.hpp"
+#include "GsrInfo.hpp"
+
+#include <functional>
+
+namespace gsr {
+ class ScrollablePage;
+ class List;
+
+ class SettingsPage {
+ public:
+ enum class Type {
+ REPLAY,
+ RECORD,
+ STREAM
+ };
+
+ SettingsPage(Type type, const GsrInfo &gsr_info, const std::vector<AudioDevice> &audio_devices, std::function<void()> back_button_callback);
+ SettingsPage(const SettingsPage&) = delete;
+ SettingsPage& operator=(const SettingsPage&) = delete;
+
+ Page& get_page();
+ private:
+ void add_widgets(const gsr::GsrInfo &gsr_info, const std::vector<gsr::AudioDevice> &audio_devices, std::function<void()> back_button_callback);
+ void add_page_specific_widgets();
+ void add_replay_widgets();
+ void add_record_widgets();
+ void add_stream_widgets();
+ private:
+ StaticPage page;
+ ScrollablePage *content_page_ptr = nullptr;
+ List *settings_list_ptr = nullptr;
+ Type type;
+ };
+} \ No newline at end of file
diff --git a/include/Theme.hpp b/include/Theme.hpp
index a28c249..ced85bd 100644
--- a/include/Theme.hpp
+++ b/include/Theme.hpp
@@ -15,6 +15,7 @@ namespace gsr {
Theme(const Theme&) = delete;
Theme& operator=(const Theme&) = delete;
+ float window_width = 0.0f;
float window_height = 0.0f;
mgl::Color tint_color = mgl::Color(118, 185, 0);
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);