aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2024-08-10 00:45:36 +0200
committerdec05eba <dec05eba@protonmail.com>2024-08-10 00:45:36 +0200
commit4ea5ada9050d22fcb7eed67a72358bce11c9b3df (patch)
treead5f1e5956d972ad7c6948d4ba2f753d47a4b315 /include
parent1a49f86e9841035fe670f6b42a3c988f737267d2 (diff)
Settings page save settings, refactor
Diffstat (limited to 'include')
-rw-r--r--include/Config.hpp21
-rw-r--r--include/SettingsPage.hpp37
-rw-r--r--include/gui/ComboBox.hpp1
-rw-r--r--include/gui/Entry.hpp3
-rw-r--r--include/gui/List.hpp7
-rw-r--r--include/gui/Page.hpp3
-rw-r--r--include/gui/RadioButton.hpp1
-rw-r--r--include/gui/SettingsPage.hpp128
8 files changed, 155 insertions, 46 deletions
diff --git a/include/Config.hpp b/include/Config.hpp
index 154bdb0..63e7984 100644
--- a/include/Config.hpp
+++ b/include/Config.hpp
@@ -1,8 +1,10 @@
#pragma once
-#include "Utils.hpp"
#include <stdint.h>
+#include <string>
+#include <vector>
+#include <optional>
namespace gsr {
struct ConfigHotkey {
@@ -16,19 +18,15 @@ namespace gsr {
int32_t record_area_height = 0;
int32_t fps = 60;
bool merge_audio_tracks = true;
- std::vector<std::string> audio_input;
+ std::vector<std::string> audio_tracks;
std::string color_range;
- std::string quality;
+ std::string video_quality;
std::string video_codec;
std::string audio_codec;
std::string framerate_mode;
bool advanced_view = false;
bool overclock = false;
- bool show_recording_started_notifications = false;
- bool show_recording_stopped_notifications = false;
- bool show_recording_saved_notifications = true;
bool record_cursor = true;
- bool hide_window_when_recording = false;
bool restore_portal_session = true;
};
@@ -52,6 +50,8 @@ namespace gsr {
struct StreamingConfig {
RecordOptions record_options;
+ bool show_streaming_started_notifications = true;
+ bool show_streaming_stopped_notifications = true;
std::string streaming_service;
YoutubeStreamConfig youtube;
TwitchStreamConfig twitch;
@@ -61,6 +61,8 @@ namespace gsr {
struct RecordConfig {
RecordOptions record_options;
+ bool show_recording_started_notifications = true;
+ bool show_video_saved_notifications = true;
std::string save_directory;
std::string container;
ConfigHotkey start_stop_recording_hotkey;
@@ -69,6 +71,9 @@ namespace gsr {
struct ReplayConfig {
RecordOptions record_options;
+ bool show_replay_started_notifications = true;
+ bool show_replay_stopped_notifications = true;
+ bool show_replay_saved_notifications = true;
std::string save_directory;
std::string container;
int32_t replay_time = 60;
@@ -83,6 +88,6 @@ namespace gsr {
ReplayConfig replay_config;
};
- Config read_config(bool &config_empty);
+ std::optional<Config> read_config();
void save_config(Config &config);
} \ No newline at end of file
diff --git a/include/SettingsPage.hpp b/include/SettingsPage.hpp
deleted file mode 100644
index aec7bed..0000000
--- a/include/SettingsPage.hpp
+++ /dev/null
@@ -1,37 +0,0 @@
-#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/gui/ComboBox.hpp b/include/gui/ComboBox.hpp
index ac9d02b..e501132 100644
--- a/include/gui/ComboBox.hpp
+++ b/include/gui/ComboBox.hpp
@@ -20,6 +20,7 @@ namespace gsr {
void add_item(const std::string &text, const std::string &id);
void set_selected_item(const std::string &id, bool trigger_event = true);
+ const std::string& get_selected_id() const;
mgl::vec2f get_size() override;
diff --git a/include/gui/Entry.hpp b/include/gui/Entry.hpp
index c2d59ac..b8ff37a 100644
--- a/include/gui/Entry.hpp
+++ b/include/gui/Entry.hpp
@@ -20,7 +20,8 @@ namespace gsr {
mgl::vec2f get_size() override;
- void set_string(std::string str);
+ void set_text(std::string str);
+ const std::string& get_text() const;
// Return false to specify that the string should not be accepted. This reverts the string back to its previous value.
// The input can be changed by changing the input parameter and returning true.
diff --git a/include/gui/List.hpp b/include/gui/List.hpp
index 0b1350c..426a66e 100644
--- a/include/gui/List.hpp
+++ b/include/gui/List.hpp
@@ -27,8 +27,14 @@ namespace gsr {
//void remove_child_widget(Widget *widget) override;
+ // Might not take effect immediately but at the next draw iteration if inside an event loop
void add_widget(std::unique_ptr<Widget> widget);
+ // Might not take effect immediately but at the next draw iteration if inside an event loop
void remove_widget(Widget *widget);
+ // Excludes widgets from queue
+ const std::vector<std::unique_ptr<Widget>>& get_child_widgets() const;
+ // Returns nullptr if index is invalid
+ Widget* get_child_widget_by_index(size_t index) const;
mgl::vec2f get_size() override;
private:
@@ -40,5 +46,6 @@ namespace gsr {
std::vector<Widget*> remove_queue;
Orientation orientation;
Alignment content_alignment;
+ bool inside_event_handler = false;
};
} \ No newline at end of file
diff --git a/include/gui/Page.hpp b/include/gui/Page.hpp
index 47aa02b..4c63702 100644
--- a/include/gui/Page.hpp
+++ b/include/gui/Page.hpp
@@ -12,6 +12,9 @@ namespace gsr {
Page& operator=(const Page&) = delete;
virtual ~Page() = default;
+ virtual void on_navigate_to_page() {}
+ virtual void on_navigate_away_from_page() {}
+
//void remove_child_widget(Widget *widget) override;
void add_widget(std::unique_ptr<Widget> widget);
diff --git a/include/gui/RadioButton.hpp b/include/gui/RadioButton.hpp
index 60f3e82..7839c68 100644
--- a/include/gui/RadioButton.hpp
+++ b/include/gui/RadioButton.hpp
@@ -18,6 +18,7 @@ namespace gsr {
void add_item(const std::string &text, const std::string &id);
void set_selected_item(const std::string &id, bool trigger_event = true);
+ const std::string get_selected_id() const;
mgl::vec2f get_size() override;
diff --git a/include/gui/SettingsPage.hpp b/include/gui/SettingsPage.hpp
new file mode 100644
index 0000000..28689a1
--- /dev/null
+++ b/include/gui/SettingsPage.hpp
@@ -0,0 +1,128 @@
+#pragma once
+
+#include "StaticPage.hpp"
+#include "List.hpp"
+#include "ComboBox.hpp"
+#include "Entry.hpp"
+#include "RadioButton.hpp"
+#include "CheckBox.hpp"
+#include "Button.hpp"
+#include "CustomRendererWidget.hpp"
+#include "../GsrInfo.hpp"
+#include "../Config.hpp"
+
+#include <functional>
+
+namespace gsr {
+ class ScrollablePage;
+
+ class SettingsPage : public StaticPage {
+ public:
+ enum class Type {
+ REPLAY,
+ RECORD,
+ STREAM
+ };
+
+ SettingsPage(Type type, const GsrInfo &gsr_info, const std::vector<AudioDevice> &audio_devices, std::optional<Config> &config);
+ SettingsPage(const SettingsPage&) = delete;
+ SettingsPage& operator=(const SettingsPage&) = delete;
+
+ void save();
+ void on_navigate_away_from_page() override;
+
+ std::function<void()> on_back_button_handler;
+ private:
+ std::unique_ptr<Button> create_back_button();
+ std::unique_ptr<CustomRendererWidget> create_settings_icon();
+ std::unique_ptr<RadioButton> create_view_radio_button();
+ std::unique_ptr<ComboBox> create_record_area_box(const GsrInfo &gsr_info);
+ std::unique_ptr<List> create_record_area(const GsrInfo &gsr_info);
+ std::unique_ptr<List> create_select_window();
+ std::unique_ptr<Entry> create_area_width_entry();
+ std::unique_ptr<Entry> create_area_height_entry();
+ std::unique_ptr<List> create_area_size();
+ std::unique_ptr<List> create_area_size_section();
+ std::unique_ptr<CheckBox> create_restore_portal_session_checkbox();
+ std::unique_ptr<List> create_restore_portal_session_section();
+ std::unique_ptr<List> create_capture_target(const GsrInfo &gsr_info);
+ std::unique_ptr<ComboBox> create_audio_track_selection_checkbox(const std::vector<AudioDevice> &audio_devices);
+ std::unique_ptr<Button> create_remove_audio_track_button(List *audio_device_list_ptr);
+ std::unique_ptr<List> create_audio_track(const std::vector<AudioDevice> &audio_devices);
+ std::unique_ptr<Button> create_add_audio_track_button(const std::vector<AudioDevice> &audio_devices);
+ std::unique_ptr<List> create_audio_track_section(const std::vector<AudioDevice> &audio_devices);
+ std::unique_ptr<CheckBox> create_merge_audio_tracks_checkbox();
+ std::unique_ptr<List> create_audio_device_section(const std::vector<AudioDevice> &audio_devices);
+ std::unique_ptr<ComboBox> create_video_quality_box();
+ std::unique_ptr<List> create_video_quality();
+ std::unique_ptr<ComboBox> create_color_range_box();
+ std::unique_ptr<List> create_color_range();
+ std::unique_ptr<List> create_video_quality_section();
+ std::unique_ptr<ComboBox> create_video_codec_box(const GsrInfo &gsr_info);
+ std::unique_ptr<List> create_video_codec(const GsrInfo &gsr_info);
+ std::unique_ptr<ComboBox> create_audio_codec_box();
+ std::unique_ptr<List> create_audio_codec();
+ std::unique_ptr<List> create_codec_section(const GsrInfo &gsr_info);
+ std::unique_ptr<Entry> create_framerate_entry();
+ std::unique_ptr<List> create_framerate();
+ std::unique_ptr<ComboBox> create_framerate_mode_box();
+ std::unique_ptr<List> create_framerate_mode();
+ std::unique_ptr<List> create_framerate_section();
+ std::unique_ptr<List> create_settings(const GsrInfo &gsr_info, const std::vector<AudioDevice> &audio_devices);
+ void add_widgets(const gsr::GsrInfo &gsr_info, const std::vector<gsr::AudioDevice> &audio_devices);
+
+ void add_page_specific_widgets();
+
+ std::unique_ptr<List> create_save_directory(const char *label);
+ std::unique_ptr<ComboBox> create_container_box();
+ std::unique_ptr<List> create_container_section();
+ void add_replay_widgets();
+ void add_record_widgets();
+
+ std::unique_ptr<ComboBox> create_streaming_service_box();
+ std::unique_ptr<List> create_streaming_service_section();
+ std::unique_ptr<List> create_stream_key_section();
+ std::unique_ptr<List> create_stream_url_section();
+ std::unique_ptr<ComboBox> create_stream_container_box();
+ std::unique_ptr<List> create_stream_container_section();
+ void add_stream_widgets();
+
+ void save_common(RecordOptions &record_options);
+ void save_replay();
+ void save_record();
+ void save_stream();
+ private:
+ Type type;
+ std::optional<Config> &config;
+
+ ScrollablePage *content_page_ptr = nullptr;
+ List *settings_list_ptr = nullptr;
+ List *select_window_list_ptr = nullptr;
+ List *area_size_list_ptr = nullptr;
+ List *restore_portal_session_list_ptr = nullptr;
+ List *color_range_list_ptr = nullptr;
+ List *codec_list_ptr = nullptr;
+ List *framerate_mode_list_ptr = nullptr;
+ ComboBox *record_area_box_ptr = nullptr;
+ Entry *area_width_entry_ptr = nullptr;
+ Entry *area_height_entry_ptr = nullptr;
+ Entry *framerate_entry_ptr = nullptr;
+ List *audio_devices_list_ptr = nullptr;
+ CheckBox *merge_audio_tracks_checkbox_ptr = nullptr;
+ ComboBox *color_range_box_ptr = nullptr;
+ ComboBox *video_quality_box_ptr = nullptr;
+ ComboBox *video_codec_box_ptr = nullptr;
+ ComboBox *audio_codec_box_ptr = nullptr;
+ ComboBox *framerate_mode_box_ptr = nullptr;
+ RadioButton *view_radio_button_ptr = nullptr;
+ CheckBox *record_cursor_checkbox_ptr = nullptr;
+ CheckBox *restore_portal_session_checkbox_ptr = nullptr;
+ ComboBox *container_box_ptr = nullptr;
+ ComboBox *streaming_service_box_ptr = nullptr;
+ List *stream_key_list_ptr = nullptr;
+ List *stream_url_list_ptr = nullptr;
+ List *container_list_ptr = nullptr;
+
+ mgl::Text settings_title_text;
+ };
+} \ No newline at end of file