aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/AudioPlayer.hpp22
-rw-r--r--include/Config.hpp93
-rw-r--r--include/CursorTracker/CursorTracker.hpp23
-rw-r--r--include/CursorTracker/CursorTrackerWayland.hpp43
-rw-r--r--include/CursorTracker/CursorTrackerX11.hpp20
-rw-r--r--include/GlobalHotkeys/GlobalHotkeys.hpp (renamed from include/GlobalHotkeys.hpp)21
-rw-r--r--include/GlobalHotkeys/GlobalHotkeysJoystick.hpp72
-rw-r--r--include/GlobalHotkeys/GlobalHotkeysLinux.hpp (renamed from include/GlobalHotkeysLinux.hpp)16
-rw-r--r--include/GlobalHotkeys/GlobalHotkeysX11.hpp (renamed from include/GlobalHotkeysX11.hpp)5
-rw-r--r--include/GsrInfo.hpp31
-rw-r--r--include/Hotplug.hpp33
-rw-r--r--include/Overlay.hpp124
-rw-r--r--include/Process.hpp16
-rw-r--r--include/RegionSelector.hpp53
-rw-r--r--include/Rpc.hpp34
-rw-r--r--include/SafeVector.hpp137
-rw-r--r--include/Theme.hpp16
-rw-r--r--include/Utils.hpp6
-rw-r--r--include/WindowSelector.hpp33
-rw-r--r--include/WindowUtils.hpp42
-rw-r--r--include/gui/Button.hpp10
-rw-r--r--include/gui/DropdownButton.hpp3
-rw-r--r--include/gui/GlobalSettingsPage.hpp110
-rw-r--r--include/gui/GsrPage.hpp5
-rw-r--r--include/gui/Image.hpp29
-rw-r--r--include/gui/List.hpp5
-rw-r--r--include/gui/Page.hpp4
-rw-r--r--include/gui/RadioButton.hpp6
-rw-r--r--include/gui/ScreenshotSettingsPage.hpp76
-rw-r--r--include/gui/ScrollablePage.hpp1
-rw-r--r--include/gui/SettingsPage.hpp115
-rw-r--r--include/gui/Subsection.hpp5
-rw-r--r--include/gui/Utils.hpp5
-rw-r--r--include/gui/Widget.hpp6
34 files changed, 1078 insertions, 142 deletions
diff --git a/include/AudioPlayer.hpp b/include/AudioPlayer.hpp
new file mode 100644
index 0000000..22c3be8
--- /dev/null
+++ b/include/AudioPlayer.hpp
@@ -0,0 +1,22 @@
+#pragma once
+
+#include <thread>
+
+namespace gsr {
+ // Only plays raw stereo PCM audio in 48000hz in s16le format.
+ // Use this command to convert an audio file (input.wav) to a format playable by this class (output.pcm):
+ // ffmpeg -i input.wav -f s16le -acodec pcm_s16le -ar 48000 output.pcm
+ class AudioPlayer {
+ public:
+ AudioPlayer() = default;
+ ~AudioPlayer();
+ AudioPlayer(const AudioPlayer&) = delete;
+ AudioPlayer& operator=(const AudioPlayer&) = delete;
+
+ bool play(const char *filepath);
+ private:
+ std::thread thread;
+ bool stop_playing_audio = false;
+ int audio_file_fd = -1;
+ };
+} \ No newline at end of file
diff --git a/include/Config.hpp b/include/Config.hpp
index 6044ab8..7c2aeda 100644
--- a/include/Config.hpp
+++ b/include/Config.hpp
@@ -6,12 +6,36 @@
#include <vector>
#include <optional>
+#define GSR_CONFIG_FILE_VERSION 2
+
namespace gsr {
- struct GsrInfo;
+ struct SupportedCaptureOptions;
+
+ enum class ReplayStartupMode {
+ DONT_TURN_ON_AUTOMATICALLY,
+ TURN_ON_AT_SYSTEM_STARTUP,
+ TURN_ON_AT_FULLSCREEN,
+ TURN_ON_AT_POWER_SUPPLY_CONNECTED
+ };
+
+ ReplayStartupMode replay_startup_string_to_type(const char *startup_mode_str);
struct ConfigHotkey {
- int64_t keysym = 0;
- uint32_t modifiers = 0;
+ int64_t key = 0; // Mgl key
+ uint32_t modifiers = 0; // HotkeyModifier
+
+ bool operator==(const ConfigHotkey &other) const;
+ bool operator!=(const ConfigHotkey &other) const;
+
+ std::string to_string(bool spaces = true, bool modifier_side = true) const;
+ };
+
+ struct AudioTrack {
+ std::vector<std::string> audio_inputs; // ids
+ bool application_audio_invert = false;
+
+ bool operator==(const AudioTrack &other) const;
+ bool operator!=(const AudioTrack &other) const;
};
struct RecordOptions {
@@ -21,16 +45,17 @@ namespace gsr {
int32_t video_width = 0;
int32_t video_height = 0;
int32_t fps = 60;
- int32_t video_bitrate = 15000;
- bool merge_audio_tracks = true;
- bool application_audio_invert = false;
+ int32_t video_bitrate = 8000;
+ bool merge_audio_tracks = true; // TODO: Remove in the future
+ bool application_audio_invert = false; // TODO: Remove in the future
bool change_video_resolution = false;
- std::vector<std::string> audio_tracks;
+ std::vector<std::string> audio_tracks; // ids, TODO: Remove in the future
+ std::vector<AudioTrack> audio_tracks_list;
std::string color_range = "limited";
std::string video_quality = "very_high";
std::string video_codec = "auto";
std::string audio_codec = "opus";
- std::string framerate_mode = "vfr";
+ std::string framerate_mode = "auto";
bool advanced_view = false;
bool overclock = false;
bool record_cursor = true;
@@ -38,8 +63,12 @@ namespace gsr {
};
struct MainConfig {
- int32_t config_file_version = 0;
+ int32_t config_file_version = GSR_CONFIG_FILE_VERSION;
bool software_encoding_warning_shown = false;
+ std::string hotkeys_enable_option = "enable_hotkeys";
+ std::string joystick_hotkeys_enable_option = "disable_hotkeys";
+ std::string tint_color;
+ ConfigHotkey show_hide_hotkey;
};
struct YoutubeStreamConfig {
@@ -50,6 +79,10 @@ namespace gsr {
std::string stream_key;
};
+ struct RumbleStreamConfig {
+ std::string stream_key;
+ };
+
struct CustomStreamConfig {
std::string url;
std::string container = "flv";
@@ -62,8 +95,9 @@ namespace gsr {
std::string streaming_service = "twitch";
YoutubeStreamConfig youtube;
TwitchStreamConfig twitch;
+ RumbleStreamConfig rumble;
CustomStreamConfig custom;
- ConfigHotkey start_stop_recording_hotkey;
+ ConfigHotkey start_stop_hotkey;
};
struct RecordConfig {
@@ -71,35 +105,62 @@ namespace gsr {
bool save_video_in_game_folder = false;
bool show_recording_started_notifications = true;
bool show_video_saved_notifications = true;
+ bool show_video_paused_notifications = true;
std::string save_directory;
std::string container = "mp4";
- ConfigHotkey start_stop_recording_hotkey;
- ConfigHotkey pause_unpause_recording_hotkey;
+ ConfigHotkey start_stop_hotkey;
+ ConfigHotkey pause_unpause_hotkey;
};
struct ReplayConfig {
RecordOptions record_options;
std::string turn_on_replay_automatically_mode = "dont_turn_on_automatically";
bool save_video_in_game_folder = false;
+ bool restart_replay_on_save = false;
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 = "mp4";
int32_t replay_time = 60;
- ConfigHotkey start_stop_recording_hotkey;
- ConfigHotkey save_recording_hotkey;
+ std::string replay_storage = "ram";
+ ConfigHotkey start_stop_hotkey;
+ ConfigHotkey save_hotkey;
+ ConfigHotkey save_1_min_hotkey;
+ ConfigHotkey save_10_min_hotkey;
+ };
+
+ struct ScreenshotConfig {
+ std::string record_area_option = "screen";
+ int32_t image_width = 0;
+ int32_t image_height = 0;
+ bool change_image_resolution = false;
+ std::string image_quality = "very_high";
+ std::string image_format = "jpg";
+ bool record_cursor = true;
+ bool restore_portal_session = true;
+
+ bool save_screenshot_in_game_folder = false;
+ bool show_screenshot_saved_notifications = true;
+ std::string save_directory;
+ ConfigHotkey take_screenshot_hotkey;
+ ConfigHotkey take_screenshot_region_hotkey;
};
struct Config {
- Config(const GsrInfo &gsr_info);
+ Config(const SupportedCaptureOptions &capture_options);
+ bool operator==(const Config &other);
+ bool operator!=(const Config &other);
+
+ void set_hotkeys_to_default();
MainConfig main_config;
StreamingConfig streaming_config;
RecordConfig record_config;
ReplayConfig replay_config;
+ ScreenshotConfig screenshot_config;
};
- std::optional<Config> read_config(const GsrInfo &gsr_info);
+ std::optional<Config> read_config(const SupportedCaptureOptions &capture_options);
void save_config(Config &config);
} \ No newline at end of file
diff --git a/include/CursorTracker/CursorTracker.hpp b/include/CursorTracker/CursorTracker.hpp
new file mode 100644
index 0000000..ff7374f
--- /dev/null
+++ b/include/CursorTracker/CursorTracker.hpp
@@ -0,0 +1,23 @@
+#pragma once
+
+#include <optional>
+#include <string>
+#include <mglpp/system/vec.hpp>
+
+namespace gsr {
+ struct CursorInfo {
+ mgl::vec2i position;
+ std::string monitor_name;
+ };
+
+ class CursorTracker {
+ public:
+ CursorTracker() = default;
+ CursorTracker(const CursorTracker&) = delete;
+ CursorTracker& operator=(const CursorTracker&) = delete;
+ virtual ~CursorTracker() = default;
+
+ virtual void update() = 0;
+ virtual std::optional<CursorInfo> get_latest_cursor_info() = 0;
+ };
+} \ No newline at end of file
diff --git a/include/CursorTracker/CursorTrackerWayland.hpp b/include/CursorTracker/CursorTrackerWayland.hpp
new file mode 100644
index 0000000..1eeee83
--- /dev/null
+++ b/include/CursorTracker/CursorTrackerWayland.hpp
@@ -0,0 +1,43 @@
+#pragma once
+
+#include "CursorTracker.hpp"
+#include <stdint.h>
+#include <vector>
+
+struct wl_display;
+struct wl_registry;
+struct wl_output;
+struct zxdg_output_manager_v1;
+struct zxdg_output_v1;
+
+namespace gsr {
+ struct WaylandOutput {
+ uint32_t wl_name;
+ struct wl_output *output;
+ struct zxdg_output_v1 *xdg_output;
+ mgl::vec2i pos;
+ mgl::vec2i size;
+ int32_t transform;
+ std::string name;
+ };
+
+ class CursorTrackerWayland : public CursorTracker {
+ public:
+ CursorTrackerWayland(const char *card_path);
+ CursorTrackerWayland(const CursorTrackerWayland&) = delete;
+ CursorTrackerWayland& operator=(const CursorTrackerWayland&) = delete;
+ ~CursorTrackerWayland();
+
+ void update() override;
+ std::optional<CursorInfo> get_latest_cursor_info() override;
+
+ std::vector<WaylandOutput> monitors;
+ struct zxdg_output_manager_v1 *xdg_output_manager = nullptr;
+ private:
+ void set_monitor_outputs_from_xdg_output(struct wl_display *dpy);
+ private:
+ int drm_fd = -1;
+ mgl::vec2i latest_cursor_position; // Position of the cursor within the monitor
+ int latest_crtc_id = -1;
+ };
+} \ No newline at end of file
diff --git a/include/CursorTracker/CursorTrackerX11.hpp b/include/CursorTracker/CursorTrackerX11.hpp
new file mode 100644
index 0000000..66618c4
--- /dev/null
+++ b/include/CursorTracker/CursorTrackerX11.hpp
@@ -0,0 +1,20 @@
+#pragma once
+
+#include "CursorTracker.hpp"
+
+typedef struct _XDisplay Display;
+
+namespace gsr {
+ class CursorTrackerX11 : public CursorTracker {
+ public:
+ CursorTrackerX11(Display *dpy);
+ CursorTrackerX11(const CursorTrackerX11&) = delete;
+ CursorTrackerX11& operator=(const CursorTrackerX11&) = delete;
+ ~CursorTrackerX11() = default;
+
+ void update() override {}
+ std::optional<CursorInfo> get_latest_cursor_info() override;
+ private:
+ Display *dpy = nullptr;
+ };
+} \ No newline at end of file
diff --git a/include/GlobalHotkeys.hpp b/include/GlobalHotkeys/GlobalHotkeys.hpp
index 662113e..2927fa7 100644
--- a/include/GlobalHotkeys.hpp
+++ b/include/GlobalHotkeys/GlobalHotkeys.hpp
@@ -4,10 +4,25 @@
#include <functional>
#include <string>
+namespace mgl {
+ class Event;
+}
+
namespace gsr {
+ enum HotkeyModifier : uint32_t {
+ HOTKEY_MOD_LSHIFT = 1 << 0,
+ HOTKEY_MOD_RSHIFT = 1 << 1,
+ HOTKEY_MOD_LCTRL = 1 << 2,
+ HOTKEY_MOD_RCTRL = 1 << 3,
+ HOTKEY_MOD_LALT = 1 << 4,
+ HOTKEY_MOD_RALT = 1 << 5,
+ HOTKEY_MOD_LSUPER = 1 << 6,
+ HOTKEY_MOD_RSUPER = 1 << 7
+ };
+
struct Hotkey {
- uint64_t key = 0;
- uint32_t modifiers = 0;
+ uint32_t key = 0; // X11 keysym
+ uint32_t modifiers = 0; // HotkeyModifier
};
using GlobalHotkeyCallback = std::function<void(const std::string &id)>;
@@ -24,5 +39,7 @@ namespace gsr {
virtual void unbind_all_keys() {}
virtual bool bind_action(const std::string &id, GlobalHotkeyCallback callback) { (void)id; (void)callback; return false; };
virtual void poll_events() = 0;
+ // Returns true if the event wasn't consumed (if the event didn't match a key that has been bound)
+ virtual bool on_event(mgl::Event &event) { (void)event; return true; }
};
} \ No newline at end of file
diff --git a/include/GlobalHotkeys/GlobalHotkeysJoystick.hpp b/include/GlobalHotkeys/GlobalHotkeysJoystick.hpp
new file mode 100644
index 0000000..0177d29
--- /dev/null
+++ b/include/GlobalHotkeys/GlobalHotkeysJoystick.hpp
@@ -0,0 +1,72 @@
+#pragma once
+
+#include "GlobalHotkeys.hpp"
+#include "../Hotplug.hpp"
+#include <unordered_map>
+#include <thread>
+#include <poll.h>
+#include <linux/joystick.h>
+
+namespace gsr {
+ static constexpr int max_js_poll_fd = 16;
+
+ class GlobalHotkeysJoystick : public GlobalHotkeys {
+ class GlobalHotkeysJoystickHotplugDelegate;
+ public:
+ GlobalHotkeysJoystick() = default;
+ GlobalHotkeysJoystick(const GlobalHotkeysJoystick&) = delete;
+ GlobalHotkeysJoystick& operator=(const GlobalHotkeysJoystick&) = delete;
+ ~GlobalHotkeysJoystick() override;
+
+ bool start();
+ // Currently valid ids:
+ // save_replay
+ // save_1_min_replay
+ // save_10_min_replay
+ // take_screenshot
+ // toggle_record
+ // toggle_replay
+ // toggle_show
+ bool bind_action(const std::string &id, GlobalHotkeyCallback callback) override;
+ void poll_events() override;
+ private:
+ void read_events();
+ void process_js_event(int fd, js_event &event);
+ bool add_device(const char *dev_input_filepath, bool print_error = true);
+ bool remove_device(const char *dev_input_filepath);
+ bool remove_poll_fd(int index);
+ // Returns -1 if not found
+ int get_poll_fd_index_by_dev_input_id(int dev_input_id) const;
+ private:
+ struct ExtraData {
+ int dev_input_id = 0;
+ };
+
+ std::unordered_map<std::string, GlobalHotkeyCallback> bound_actions_by_id;
+ std::thread read_thread;
+
+ pollfd poll_fd[max_js_poll_fd];
+ ExtraData extra_data[max_js_poll_fd];
+ int num_poll_fd = 0;
+ int event_fd = -1;
+ int event_index = -1;
+
+ bool playstation_button_pressed = false;
+ bool up_pressed = false;
+ bool down_pressed = false;
+ bool left_pressed = false;
+ bool right_pressed = false;
+ bool l3_button_pressed = false;
+ bool r3_button_pressed = false;
+
+ bool save_replay = false;
+ bool save_1_min_replay = false;
+ bool save_10_min_replay = false;
+ bool take_screenshot = false;
+ bool toggle_record = false;
+ bool toggle_replay = false;
+ bool toggle_show = false;
+ int hotplug_poll_index = -1;
+ Hotplug hotplug;
+ };
+} \ No newline at end of file
diff --git a/include/GlobalHotkeysLinux.hpp b/include/GlobalHotkeys/GlobalHotkeysLinux.hpp
index 62da74e..959d095 100644
--- a/include/GlobalHotkeysLinux.hpp
+++ b/include/GlobalHotkeys/GlobalHotkeysLinux.hpp
@@ -7,18 +7,28 @@
namespace gsr {
class GlobalHotkeysLinux : public GlobalHotkeys {
public:
- GlobalHotkeysLinux();
+ enum class GrabType {
+ ALL,
+ VIRTUAL
+ };
+
+ GlobalHotkeysLinux(GrabType grab_type);
GlobalHotkeysLinux(const GlobalHotkeysLinux&) = delete;
GlobalHotkeysLinux& operator=(const GlobalHotkeysLinux&) = delete;
~GlobalHotkeysLinux() override;
bool start();
- bool bind_action(const std::string &id, GlobalHotkeyCallback callback) override;
+ bool bind_key_press(Hotkey hotkey, const std::string &id, GlobalHotkeyCallback callback) override;
+ void unbind_all_keys() override;
void poll_events() override;
private:
+ void close_fds();
+ private:
pid_t process_id = 0;
- int pipes[2];
+ int read_pipes[2];
+ int write_pipes[2];
FILE *read_file = nullptr;
std::unordered_map<std::string, GlobalHotkeyCallback> bound_actions_by_id;
+ GrabType grab_type;
};
} \ No newline at end of file
diff --git a/include/GlobalHotkeysX11.hpp b/include/GlobalHotkeys/GlobalHotkeysX11.hpp
index 427e9f0..610399a 100644
--- a/include/GlobalHotkeysX11.hpp
+++ b/include/GlobalHotkeys/GlobalHotkeysX11.hpp
@@ -12,12 +12,15 @@ namespace gsr {
GlobalHotkeysX11& operator=(const GlobalHotkeysX11&) = delete;
~GlobalHotkeysX11() override;
+ // Hotkey key is a KeySym (XK_z for example) and modifiers is a bitmask of X11 modifier masks (for example ShiftMask | Mod1Mask)
bool bind_key_press(Hotkey hotkey, const std::string &id, GlobalHotkeyCallback callback) override;
void unbind_key_press(const std::string &id) override;
void unbind_all_keys() override;
void poll_events() override;
+ bool on_event(mgl::Event &event) override;
private:
- void call_hotkey_callback(Hotkey hotkey) const;
+ // Returns true if a key bind has been registered for the hotkey
+ bool call_hotkey_callback(Hotkey hotkey) const;
private:
struct HotkeyData {
Hotkey hotkey;
diff --git a/include/GsrInfo.hpp b/include/GsrInfo.hpp
index cd6292c..156125b 100644
--- a/include/GsrInfo.hpp
+++ b/include/GsrInfo.hpp
@@ -2,6 +2,7 @@
#include <string>
#include <vector>
+#include <stdint.h>
#include <mglpp/system/vec.hpp>
@@ -19,15 +20,35 @@ namespace gsr {
bool vp9 = false;
};
+ struct SupportedImageFormats {
+ bool jpeg = false;
+ bool png = false;
+ };
+
struct GsrMonitor {
std::string name;
mgl::vec2i size;
};
+ struct GsrVersion {
+ uint8_t major = 0;
+ uint8_t minor = 0;
+ uint8_t patch = 0;
+
+ bool operator>(const GsrVersion &other) const;
+ bool operator>=(const GsrVersion &other) const;
+ bool operator<(const GsrVersion &other) const;
+ bool operator<=(const GsrVersion &other) const;
+ bool operator==(const GsrVersion &other) const;
+ bool operator!=(const GsrVersion &other) const;
+
+ std::string to_string() const;
+ };
+
struct SupportedCaptureOptions {
bool window = false;
+ bool region = false;
bool focused = false;
- bool screen = false;
bool portal = false;
std::vector<GsrMonitor> monitors;
};
@@ -41,24 +62,27 @@ namespace gsr {
struct SystemInfo {
DisplayServer display_server = DisplayServer::UNKNOWN;
bool supports_app_audio = false;
+ GsrVersion gsr_version;
};
enum class GpuVendor {
UNKNOWN,
AMD,
INTEL,
- NVIDIA
+ NVIDIA,
+ BROADCOM
};
struct GpuInfo {
GpuVendor vendor = GpuVendor::UNKNOWN;
+ std::string card_path;
};
struct GsrInfo {
SystemInfo system_info;
GpuInfo gpu_info;
SupportedVideoCodecs supported_video_codecs;
- SupportedCaptureOptions supported_capture_options;
+ SupportedImageFormats supported_image_formats;
};
enum class GsrInfoExitStatus {
@@ -78,4 +102,5 @@ namespace gsr {
std::vector<AudioDevice> get_audio_devices();
std::vector<std::string> get_application_audio();
+ SupportedCaptureOptions get_supported_capture_options(const GsrInfo &gsr_info);
} \ No newline at end of file
diff --git a/include/Hotplug.hpp b/include/Hotplug.hpp
new file mode 100644
index 0000000..38fe25d
--- /dev/null
+++ b/include/Hotplug.hpp
@@ -0,0 +1,33 @@
+#pragma once
+
+#include <functional>
+
+namespace gsr {
+ enum class HotplugAction {
+ ADD,
+ REMOVE
+ };
+
+ using HotplugEventCallback = std::function<void(HotplugAction hotplug_action, const char *devname)>;
+
+ class Hotplug {
+ public:
+ Hotplug() = default;
+ Hotplug(const Hotplug&) = delete;
+ Hotplug& operator=(const Hotplug&) = delete;
+ ~Hotplug();
+
+ bool start();
+ int steal_fd();
+ void process_event_data(int fd, const HotplugEventCallback &callback);
+ private:
+ void parse_netlink_data(const char *line, const HotplugEventCallback &callback);
+ private:
+ int fd = -1;
+ bool started = false;
+ bool event_is_add = false;
+ bool event_is_remove = false;
+ bool subsystem_is_input = false;
+ char event_data[1024];
+ };
+} \ No newline at end of file
diff --git a/include/Overlay.hpp b/include/Overlay.hpp
index 580759c..3de89c2 100644
--- a/include/Overlay.hpp
+++ b/include/Overlay.hpp
@@ -5,6 +5,12 @@
#include "GsrInfo.hpp"
#include "Config.hpp"
#include "window_texture.h"
+#include "WindowUtils.hpp"
+#include "GlobalHotkeys/GlobalHotkeysJoystick.hpp"
+#include "AudioPlayer.hpp"
+#include "RegionSelector.hpp"
+#include "WindowSelector.hpp"
+#include "CursorTracker/CursorTracker.hpp"
#include <mglpp/window/Window.hpp>
#include <mglpp/window/Event.hpp>
@@ -14,8 +20,11 @@
#include <mglpp/graphics/Text.hpp>
#include <mglpp/system/Clock.hpp>
+#include <array>
+
namespace gsr {
class DropdownButton;
+ class GlobalHotkeys;
enum class RecordingStatus {
NONE,
@@ -28,18 +37,18 @@ namespace gsr {
NONE,
RECORD,
REPLAY,
- STREAM
+ STREAM,
+ SCREENSHOT
};
class Overlay {
public:
- Overlay(std::string resources_path, GsrInfo gsr_info, egl_functions egl_funcs);
+ Overlay(std::string resources_path, GsrInfo gsr_info, SupportedCaptureOptions capture_options, egl_functions egl_funcs);
Overlay(const Overlay&) = delete;
Overlay& operator=(const Overlay&) = delete;
~Overlay();
void handle_events();
- void on_event(mgl::Event &event);
// Returns false if not visible
bool draw();
@@ -51,17 +60,47 @@ namespace gsr {
void toggle_stream();
void toggle_replay();
void save_replay();
- void show_notification(const char *str, double timeout_seconds, mgl::Color icon_color, mgl::Color bg_color, NotificationType notification_type);
+ void save_replay_1_min();
+ void save_replay_10_min();
+ void take_screenshot();
+ void take_screenshot_region();
+ void show_notification(const char *str, double timeout_seconds, mgl::Color icon_color, mgl::Color bg_color, NotificationType notification_type, const char *capture_target = nullptr);
bool is_open() const;
+ bool should_exit(std::string &reason) const;
+ void exit();
+ void go_back_to_old_ui();
+
+ const Config& get_config() const;
+
+ void unbind_all_keyboard_hotkeys();
+ void rebind_all_keyboard_hotkeys();
private:
+ void handle_keyboard_mapping_event();
+ void on_event(mgl::Event &event);
+
+ void create_frontpage_ui_components();
+ void xi_setup();
+ void handle_xi_events();
void process_key_bindings(mgl::Event &event);
+ void grab_mouse_and_keyboard();
+ void xi_setup_fake_cursor();
+
+ void close_gpu_screen_recorder_output();
void update_notification_process_status();
+ void save_video_in_current_game_directory(const char *video_filepath, NotificationType notification_type);
+ void on_replay_saved(const char *replay_saved_filepath);
+ void process_gsr_output();
+ void on_gsr_process_error(int exit_code, NotificationType notification_type);
void update_gsr_process_status();
+ void update_gsr_screenshot_process_status();
void replay_status_update_status();
void update_focused_fullscreen_status();
void update_power_supply_status();
+ void update_system_startup_status();
+
+ void on_stop_recording(int exit_code, const std::string &video_filepath);
void update_ui_recording_paused();
void update_ui_recording_unpaused();
@@ -75,11 +114,17 @@ namespace gsr {
void update_ui_replay_started();
void update_ui_replay_stopped();
+ void prepare_gsr_output_for_reading();
void on_press_save_replay();
- void on_press_start_replay(bool disable_notification);
- void on_press_start_record();
- void on_press_start_stream();
- bool update_compositor_texture(const mgl_monitor *monitor);
+ void on_press_save_replay_1_min_replay();
+ void on_press_save_replay_10_min_replay();
+ bool on_press_start_replay(bool disable_notification, bool finished_selection);
+ void on_press_start_record(bool finished_selection);
+ void on_press_start_stream(bool finished_selection);
+ void on_press_take_screenshot(bool finished_selection, bool force_region_capture);
+ bool update_compositor_texture(const Monitor &monitor);
+
+ std::string get_capture_target(const std::string &capture_target, const SupportedCaptureOptions &capture_options);
void force_window_on_top();
private:
@@ -94,11 +139,20 @@ namespace gsr {
std::string resources_path;
GsrInfo gsr_info;
egl_functions egl_funcs;
+ Config config;
+
+ bool visible = false;
+
mgl::Texture window_texture_texture;
mgl::Sprite window_texture_sprite;
mgl::Texture screenshot_texture;
mgl::Sprite screenshot_sprite;
mgl::Rectangle bg_screenshot_overlay;
+
+ mgl::Texture cursor_texture;
+ mgl::Sprite cursor_sprite;
+ mgl::vec2i cursor_hotspot;
+
WindowTexture window_texture;
PageStack page_stack;
mgl::Rectangle top_bar_background;
@@ -106,14 +160,18 @@ namespace gsr {
mgl::Sprite logo_sprite;
CustomRendererWidget close_button_widget;
bool close_button_pressed_inside = false;
- bool visible = false;
uint64_t default_cursor = 0;
+
pid_t gpu_screen_recorder_process = -1;
pid_t notification_process = -1;
- Config config;
+ int gpu_screen_recorder_process_output_fd = -1;
+ FILE *gpu_screen_recorder_process_output_file = nullptr;
+ pid_t gpu_screen_recorder_screenshot_process = -1;
+
DropdownButton *replay_dropdown_button_ptr = nullptr;
DropdownButton *record_dropdown_button_ptr = nullptr;
DropdownButton *stream_dropdown_button_ptr = nullptr;
+
mgl::Clock force_window_on_top_clock;
RecordingStatus recording_status = RecordingStatus::NONE;
@@ -124,6 +182,52 @@ namespace gsr {
bool power_supply_connected = false;
bool focused_window_is_fullscreen = false;
+ std::string record_filepath;
+ std::string screenshot_filepath;
+
+ Display *xi_display = nullptr;
+ int xi_opcode = 0;
+ XEvent *xi_input_xev = nullptr;
+ XEvent *xi_output_xev = nullptr;
+
std::array<KeyBinding, 1> key_bindings;
+ bool drawn_first_frame = false;
+
+ bool do_exit = false;
+ std::string exit_reason;
+
+ mgl::vec2i window_size = { 1280, 720 };
+ mgl::vec2i window_pos = { 0, 0 };
+
+ mgl::Clock show_overlay_clock;
+ double show_overlay_timeout_seconds = 0.0;
+
+ std::unique_ptr<GlobalHotkeys> global_hotkeys = nullptr;
+ std::unique_ptr<GlobalHotkeysJoystick> global_hotkeys_js = nullptr;
+ Display *x11_mapping_display = nullptr;
+ XEvent x11_mapping_xev;
+
+ mgl::Clock replay_save_clock;
+ bool replay_save_show_notification = false;
+ ReplayStartupMode replay_startup_mode = ReplayStartupMode::TURN_ON_AT_SYSTEM_STARTUP;
+ bool try_replay_startup = true;
+ bool replay_recording = false;
+ int replay_save_duration_min = 0;
+
+ AudioPlayer audio_player;
+
+ RegionSelector region_selector;
+ bool start_region_capture = false;
+ std::function<void()> on_region_selected;
+
+ WindowSelector window_selector;
+ bool start_window_capture = false;
+ std::function<void()> on_window_selected;
+
+ std::string recording_capture_target;
+ std::string screenshot_capture_target;
+
+ std::unique_ptr<CursorTracker> cursor_tracker;
+ mgl::Clock cursor_tracker_update_clock;
};
} \ No newline at end of file
diff --git a/include/Process.hpp b/include/Process.hpp
index 125a880..1789fb1 100644
--- a/include/Process.hpp
+++ b/include/Process.hpp
@@ -1,6 +1,7 @@
#pragma once
#include <sys/types.h>
+#include <string>
namespace gsr {
enum class GsrMode {
@@ -11,9 +12,14 @@ namespace gsr {
};
// Arguments ending with NULL
- bool exec_program_daemonized(const char **args);
- // Arguments ending with NULL
- pid_t exec_program(const char **args);
- // |output_buffer| should be at least PATH_MAX in size
- bool read_cmdline_arg0(const char *filepath, char *output_buffer);
+ bool exec_program_daemonized(const char **args, bool debug = true);
+ // Arguments ending with NULL. |read_fd| can be NULL
+ pid_t exec_program(const char **args, int *read_fd, bool debug = true);
+ // Arguments ending with NULL. Returns the exit status of the program or -1 on error
+ int exec_program_get_stdout(const char **args, std::string &result, bool debug = true);
+ // Arguments ending with NULL. Returns the exit status of the program or -1 on error.
+ // This works the same as |exec_program_get_stdout|, except on flatpak where this runs the program on the
+ // host machine with flatpak-spawn --host
+ int exec_program_on_host_get_stdout(const char **args, std::string &result, bool debug = true);
+ pid_t pidof(const char *process_name, pid_t ignore_pid);
} \ No newline at end of file
diff --git a/include/RegionSelector.hpp b/include/RegionSelector.hpp
new file mode 100644
index 0000000..ef0bc0e
--- /dev/null
+++ b/include/RegionSelector.hpp
@@ -0,0 +1,53 @@
+#pragma once
+
+#include "WindowUtils.hpp"
+#include <mglpp/system/vec.hpp>
+#include <mglpp/graphics/Color.hpp>
+#include <vector>
+
+#include <X11/Xlib.h>
+
+namespace gsr {
+ struct Region {
+ mgl::vec2i pos;
+ mgl::vec2i size;
+ };
+
+ class RegionSelector {
+ public:
+ RegionSelector();
+ RegionSelector(const RegionSelector&) = delete;
+ RegionSelector& operator=(const RegionSelector&) = delete;
+ ~RegionSelector();
+
+ bool start(mgl::Color border_color);
+ void stop();
+ bool is_started() const;
+
+ bool failed() const;
+ bool poll_events();
+ bool take_selection();
+ bool take_canceled();
+ Region get_selection() const;
+ private:
+ void on_button_press(const void *de);
+ void on_button_release(const void *de);
+ void on_mouse_motion(const void *de);
+ private:
+ Display *dpy = nullptr;
+ unsigned long region_window = 0;
+ unsigned long cursor_window = 0;
+ unsigned long region_window_colormap = 0;
+ int xi_opcode = 0;
+ GC region_gc = nullptr;
+ GC cursor_gc = nullptr;
+
+ Region region;
+ bool selecting_region = false;
+ bool selected = false;
+ bool canceled = false;
+ bool is_wayland = false;
+ std::vector<Monitor> monitors;
+ mgl::vec2i cursor_pos;
+ };
+} \ No newline at end of file
diff --git a/include/Rpc.hpp b/include/Rpc.hpp
new file mode 100644
index 0000000..d6db218
--- /dev/null
+++ b/include/Rpc.hpp
@@ -0,0 +1,34 @@
+#pragma once
+
+#include <stddef.h>
+#include <functional>
+#include <unordered_map>
+#include <string>
+
+typedef struct _IO_FILE FILE;
+
+namespace gsr {
+ using RpcCallback = std::function<void(const std::string &name)>;
+
+ class Rpc {
+ public:
+ Rpc() = default;
+ Rpc(const Rpc&) = delete;
+ Rpc& operator=(const Rpc&) = delete;
+ ~Rpc();
+
+ bool create(const char *name);
+ bool open(const char *name);
+ bool write(const char *str, size_t size);
+ void poll();
+
+ bool add_handler(const std::string &name, RpcCallback callback);
+ private:
+ bool open_filepath(const char *filepath);
+ private:
+ int fd = 0;
+ FILE *file = nullptr;
+ std::string fifo_filepath;
+ std::unordered_map<std::string, RpcCallback> handlers_by_name;
+ };
+} \ No newline at end of file
diff --git a/include/SafeVector.hpp b/include/SafeVector.hpp
index 6cb4725..63125ad 100644
--- a/include/SafeVector.hpp
+++ b/include/SafeVector.hpp
@@ -1,8 +1,15 @@
#pragma once
#include <vector>
-#include <memory>
#include <functional>
+#include <assert.h>
+#include "gui/Widget.hpp"
+
+template <typename T>
+struct SafeVectorItem {
+ T item;
+ bool alive = false;
+};
// A vector that can be modified while iterating
template <typename T>
@@ -10,64 +17,84 @@ class SafeVector {
public:
using PointerType = typename std::pointer_traits<T>::element_type*;
+ SafeVector() = default;
+ SafeVector(const SafeVector&) = delete;
+ SafeVector& operator=(const SafeVector&) = delete;
+ ~SafeVector() {
+ clear();
+ }
+
void push_back(T item) {
- data.push_back(std::move(item));
+ data.push_back({std::move(item), true});
+ ++num_items_alive;
}
// Safe to call when vector is empty
// TODO: Make this iterator safe
void pop_back() {
- if(!data.empty())
+ if(!data.empty()) {
+ gsr::add_widget_to_remove(std::move(data.back().item));
data.pop_back();
+ --num_items_alive;
+ }
}
// Might not remove the data immediately if inside for_each loop.
// In that case the item is removed at the end of the loop.
void remove(PointerType item_to_remove) {
- if(for_each_depth == 0)
+ if(for_each_depth == 0) {
remove_item(item_to_remove);
- else
- remove_queue.push_back(item_to_remove);
+ return;
+ }
+
+ SafeVectorItem<T> *item = get_item(item_to_remove);
+ if(item && item->alive) {
+ item->alive = false;
+ --num_items_alive;
+ has_items_to_remove = true;
+ }
}
// Safe to call when vector is empty, in which case it returns nullptr
T* back() {
- if(data.empty())
- return nullptr;
- else
- return &data.back();
+ for(auto it = data.rbegin(), end = data.rend(); it != end; ++it) {
+ if(it->alive)
+ return &it->item;
+ }
+ return nullptr;
}
// TODO: Make this iterator safe
void clear() {
+ for(auto &item : data) {
+ gsr::add_widget_to_remove(std::move(item.item));
+ }
data.clear();
- remove_queue.clear();
+ num_items_alive = 0;
}
// Return true from |callback| to continue. This function returns false if |callback| returned false
- bool for_each(std::function<bool(T &t)> callback) {
+ bool for_each(std::function<bool(T &t)> callback, bool include_dead = false) {
bool result = true;
++for_each_depth;
for(size_t i = 0; i < data.size(); ++i) {
- result = callback(data[i]);
- if(!result)
- break;
+ if(data[i].alive || include_dead) {
+ result = callback(data[i].item);
+ if(!result)
+ break;
+ }
}
--for_each_depth;
- if(for_each_depth == 0) {
- for(PointerType item_to_remove : remove_queue) {
- remove_item(item_to_remove);
- }
- remove_queue.clear();
- }
+ if(for_each_depth == 0)
+ remove_dead_items();
return result;
}
// Return true from |callback| to continue. This function returns false if |callback| returned false
- bool for_each_reverse(std::function<bool(T &t)> callback) {
+ bool for_each_reverse(std::function<bool(T &t)> callback, bool include_dead = false) {
bool result = true;
++for_each_depth;
@@ -80,50 +107,84 @@ public:
if(i < 0)
break;
- result = callback(data[i]);
- if(!result)
- break;
+ if(data[i].alive || include_dead) {
+ result = callback(data[i].item);
+ if(!result)
+ break;
+ }
--i;
}
--for_each_depth;
- if(for_each_depth == 0) {
- for(PointerType item_to_remove : remove_queue) {
- remove_item(item_to_remove);
- }
- remove_queue.clear();
- }
+ if(for_each_depth == 0)
+ remove_dead_items();
return result;
}
T& operator[](size_t index) {
- return data[index];
+ assert(index < data.size());
+ return data[index].item;
}
const T& operator[](size_t index) const {
- return data[index];
+ assert(index < data.size());
+ return data[index].item;
}
size_t size() const {
- return data.size();
+ return (size_t)num_items_alive;
}
bool empty() const {
- return data.empty();
+ return num_items_alive == 0;
+ }
+
+ void replace_item(PointerType item_to_replace, T new_item) {
+ SafeVectorItem<T> *item = get_item(item_to_replace);
+ if(item->alive) {
+ gsr::add_widget_to_remove(std::move(item->item));
+ item->item = std::move(new_item);
+ }
}
private:
void remove_item(PointerType item_to_remove) {
for(auto it = data.begin(), end = data.end(); it != end; ++it) {
- if(&*(*it) == item_to_remove) {
+ if(&*(it->item) == item_to_remove) {
+ gsr::add_widget_to_remove(std::move(it->item));
data.erase(it);
+ --num_items_alive;
return;
}
}
}
+
+ SafeVectorItem<T>* get_item(PointerType item_to_remove) {
+ for(auto &item : data) {
+ if(&*(item.item) == item_to_remove)
+ return &item;
+ }
+ return nullptr;
+ }
+
+ void remove_dead_items() {
+ if(!has_items_to_remove)
+ return;
+
+ for(auto it = data.begin(); it != data.end();) {
+ if(it->alive) {
+ ++it;
+ } else {
+ gsr::add_widget_to_remove(std::move(it->item));
+ it = data.erase(it);
+ }
+ }
+ has_items_to_remove = false;
+ }
private:
- std::vector<T> data;
- std::vector<PointerType> remove_queue;
+ std::vector<SafeVectorItem<T>> data;
int for_each_depth = 0;
+ int num_items_alive = 0;
+ bool has_items_to_remove = false;
}; \ No newline at end of file
diff --git a/include/Theme.hpp b/include/Theme.hpp
index 23bcbb7..1390182 100644
--- a/include/Theme.hpp
+++ b/include/Theme.hpp
@@ -8,6 +8,7 @@
#include <string>
namespace gsr {
+ struct Config;
struct GsrInfo;
struct Theme {
@@ -26,6 +27,8 @@ namespace gsr {
mgl::Texture combobox_arrow_texture;
mgl::Texture settings_texture;
+ mgl::Texture settings_small_texture;
+ mgl::Texture settings_extra_small_texture;
mgl::Texture folder_texture;
mgl::Texture up_arrow_texture;
mgl::Texture replay_button_texture;
@@ -39,6 +42,17 @@ namespace gsr {
mgl::Texture stop_texture;
mgl::Texture pause_texture;
mgl::Texture save_texture;
+ mgl::Texture screenshot_texture;
+ mgl::Texture trash_texture;
+
+ mgl::Texture ps4_home_texture;
+ mgl::Texture ps4_options_texture;
+ mgl::Texture ps4_dpad_up_texture;
+ mgl::Texture ps4_dpad_down_texture;
+ mgl::Texture ps4_dpad_left_texture;
+ mgl::Texture ps4_dpad_right_texture;
+ mgl::Texture ps4_cross_texture;
+ mgl::Texture ps4_triangle_texture;
double double_click_timeout_seconds = 0.4;
@@ -56,7 +70,7 @@ namespace gsr {
mgl::Color text_color = mgl::Color(255, 255, 255);
};
- bool init_color_theme(const GsrInfo &gsr_info);
+ bool init_color_theme(const Config &config, const GsrInfo &gsr_info);
void deinit_color_theme();
ColorTheme& get_color_theme();
} \ No newline at end of file
diff --git a/include/Utils.hpp b/include/Utils.hpp
index e7bb3bc..3d3c029 100644
--- a/include/Utils.hpp
+++ b/include/Utils.hpp
@@ -4,7 +4,6 @@
#include <string_view>
#include <map>
#include <string>
-#include <optional>
namespace gsr {
struct KeyValue {
@@ -15,6 +14,9 @@ namespace gsr {
using StringSplitCallback = std::function<bool(std::string_view line)>;
void string_split_char(std::string_view str, char delimiter, StringSplitCallback callback_func);
+ bool starts_with(std::string_view str, const char *substr);
+ bool ends_with(std::string_view str, const char *substr);
+ std::string strip(const std::string &str);
std::string get_home_dir();
std::string get_config_dir();
@@ -24,6 +26,8 @@ namespace gsr {
std::map<std::string, std::string> get_xdg_variables();
std::string get_videos_dir();
+ std::string get_pictures_dir();
+
// Returns 0 on success
int create_directory_recursive(char *path);
bool file_get_content(const char *filepath, std::string &file_content);
diff --git a/include/WindowSelector.hpp b/include/WindowSelector.hpp
new file mode 100644
index 0000000..ab4a85d
--- /dev/null
+++ b/include/WindowSelector.hpp
@@ -0,0 +1,33 @@
+#pragma once
+
+#include <X11/Xlib.h>
+
+#include <mglpp/graphics/Color.hpp>
+
+namespace gsr {
+ class WindowSelector {
+ public:
+ WindowSelector();
+ WindowSelector(const WindowSelector&) = delete;
+ WindowSelector& operator=(const WindowSelector&) = delete;
+ ~WindowSelector();
+
+ bool start(mgl::Color border_color);
+ void stop();
+ bool is_started() const;
+
+ bool failed() const;
+ bool poll_events();
+ bool take_selection();
+ bool take_canceled();
+ Window get_selection() const;
+ private:
+ Display *dpy = nullptr;
+ Cursor crosshair_cursor = None;
+ Colormap border_window_colormap = None;
+ Window border_window = None;
+ Window selected_window = None;
+ bool selected = false;
+ bool canceled = false;
+ };
+} \ No newline at end of file
diff --git a/include/WindowUtils.hpp b/include/WindowUtils.hpp
new file mode 100644
index 0000000..5c4d39a
--- /dev/null
+++ b/include/WindowUtils.hpp
@@ -0,0 +1,42 @@
+#pragma once
+
+#include <mglpp/system/vec.hpp>
+#include <string>
+#include <vector>
+#include <optional>
+#include <X11/Xlib.h>
+
+namespace gsr {
+ enum class WindowCaptureType {
+ FOCUSED,
+ CURSOR
+ };
+
+ struct Monitor {
+ mgl::vec2i position;
+ mgl::vec2i size;
+ std::string name;
+ };
+
+ std::optional<std::string> get_window_title(Display *dpy, Window window);
+ Window get_focused_window(Display *dpy, WindowCaptureType cap_type);
+ std::string get_focused_window_name(Display *dpy, WindowCaptureType window_capture_type);
+ std::string get_window_name_at_position(Display *dpy, mgl::vec2i position, Window ignore_window);
+ std::string get_window_name_at_cursor_position(Display *dpy, Window ignore_window);
+ void set_window_size_not_resizable(Display *dpy, Window window, int width, int height);
+ Window window_get_target_window_child(Display *display, Window window);
+ mgl::vec2i get_cursor_position(Display *dpy, Window *window);
+ mgl::vec2i create_window_get_center_position(Display *display);
+ std::string get_window_manager_name(Display *display);
+ bool is_compositor_running(Display *dpy, int screen);
+ std::vector<Monitor> get_monitors(Display *dpy);
+ void xi_grab_all_mouse_devices(Display *dpy);
+ void xi_ungrab_all_mouse_devices(Display *dpy);
+ void xi_warp_all_mouse_devices(Display *dpy, mgl::vec2i position);
+ void window_set_fullscreen(Display *dpy, Window window, bool fullscreen);
+ bool window_is_fullscreen(Display *display, Window window);
+ bool set_window_wm_state(Display *dpy, Window window, Atom atom);
+ void make_window_click_through(Display *display, Window window);
+ bool make_window_sticky(Display *dpy, Window window);
+ bool hide_window_from_taskbar(Display *dpy, Window window);
+} \ No newline at end of file
diff --git a/include/gui/Button.hpp b/include/gui/Button.hpp
index bc1dd94..f412521 100644
--- a/include/gui/Button.hpp
+++ b/include/gui/Button.hpp
@@ -5,6 +5,7 @@
#include <mglpp/graphics/Color.hpp>
#include <mglpp/graphics/Text.hpp>
+#include <mglpp/graphics/Sprite.hpp>
namespace gsr {
class Button : public Widget {
@@ -20,15 +21,24 @@ namespace gsr {
mgl::vec2f get_size() override;
void set_border_scale(float scale);
+ void set_icon_padding_scale(float scale);
+ void set_bg_hover_color(mgl::Color color);
+ void set_icon(mgl::Texture *texture);
const std::string& get_text() const;
void set_text(std::string str);
std::function<void()> on_click;
private:
+ void scale_sprite_to_button_size();
+ float get_button_height();
+ private:
mgl::vec2f size;
mgl::Color bg_color;
+ mgl::Color bg_hover_color;
mgl::Text text;
+ mgl::Sprite sprite;
float border_scale = 0.0015f;
+ float icon_padding_scale = 1.0f;
};
} \ No newline at end of file
diff --git a/include/gui/DropdownButton.hpp b/include/gui/DropdownButton.hpp
index cbbcda2..f613d86 100644
--- a/include/gui/DropdownButton.hpp
+++ b/include/gui/DropdownButton.hpp
@@ -20,6 +20,8 @@ namespace gsr {
void add_item(const std::string &text, const std::string &id, const std::string &description = "");
void set_item_label(const std::string &id, const std::string &new_label);
void set_item_icon(const std::string &id, mgl::Texture *texture);
+ void set_item_description(const std::string &id, const std::string &new_description);
+ void set_item_enabled(const std::string &id, bool enabled);
void set_description(std::string description_text);
void set_activated(bool activated);
@@ -35,6 +37,7 @@ namespace gsr {
mgl::Text description_text;
mgl::Texture *icon_texture = nullptr;
std::string id;
+ bool enabled = true;
};
std::vector<Item> items;
diff --git a/include/gui/GlobalSettingsPage.hpp b/include/gui/GlobalSettingsPage.hpp
new file mode 100644
index 0000000..d96397d
--- /dev/null
+++ b/include/gui/GlobalSettingsPage.hpp
@@ -0,0 +1,110 @@
+#pragma once
+
+#include "StaticPage.hpp"
+#include "../GsrInfo.hpp"
+#include "../Config.hpp"
+
+#include <functional>
+#include <mglpp/window/Event.hpp>
+
+namespace gsr {
+ class Overlay;
+ class GsrPage;
+ class PageStack;
+ class ScrollablePage;
+ class Subsection;
+ class RadioButton;
+ class Button;
+ class List;
+ class CustomRendererWidget;
+
+ enum ConfigureHotkeyType {
+ NONE,
+ REPLAY_START_STOP,
+ REPLAY_SAVE,
+ REPLAY_SAVE_1_MIN,
+ REPLAY_SAVE_10_MIN,
+ RECORD_START_STOP,
+ RECORD_PAUSE_UNPAUSE,
+ STREAM_START_STOP,
+ TAKE_SCREENSHOT,
+ TAKE_SCREENSHOT_REGION,
+ SHOW_HIDE
+ };
+
+ class GlobalSettingsPage : public StaticPage {
+ public:
+ GlobalSettingsPage(Overlay *overlay, const GsrInfo *gsr_info, Config &config, PageStack *page_stack);
+ GlobalSettingsPage(const GlobalSettingsPage&) = delete;
+ GlobalSettingsPage& operator=(const GlobalSettingsPage&) = delete;
+
+ void load();
+ void save();
+ void on_navigate_away_from_page() override;
+
+ bool on_event(mgl::Event &event, mgl::Window &window, mgl::vec2f offset) override;
+
+ std::function<void(bool enable, int exit_status)> on_startup_changed;
+ std::function<void(const char *reason)> on_click_exit_program_button;
+ std::function<void(const char *hotkey_option)> on_keyboard_hotkey_changed;
+ std::function<void(const char *hotkey_option)> on_joystick_hotkey_changed;
+ std::function<void()> on_page_closed;
+ private:
+ void load_hotkeys();
+
+ std::unique_ptr<Subsection> create_appearance_subsection(ScrollablePage *parent_page);
+ std::unique_ptr<Subsection> create_startup_subsection(ScrollablePage *parent_page);
+ std::unique_ptr<RadioButton> create_enable_keyboard_hotkeys_button();
+ std::unique_ptr<RadioButton> create_enable_joystick_hotkeys_button();
+ std::unique_ptr<List> create_show_hide_hotkey_options();
+ std::unique_ptr<List> create_replay_hotkey_options();
+ std::unique_ptr<List> create_replay_partial_save_hotkey_options();
+ std::unique_ptr<List> create_record_hotkey_options();
+ std::unique_ptr<List> create_stream_hotkey_options();
+ std::unique_ptr<List> create_screenshot_hotkey_options();
+ std::unique_ptr<List> create_screenshot_region_hotkey_options();
+ std::unique_ptr<List> create_hotkey_control_buttons();
+ std::unique_ptr<Subsection> create_keyboard_hotkey_subsection(ScrollablePage *parent_page);
+ std::unique_ptr<Subsection> create_controller_hotkey_subsection(ScrollablePage *parent_page);
+ std::unique_ptr<Button> create_exit_program_button();
+ std::unique_ptr<Button> create_go_back_to_old_ui_button();
+ std::unique_ptr<Subsection> create_application_options_subsection(ScrollablePage *parent_page);
+ std::unique_ptr<Subsection> create_application_info_subsection(ScrollablePage *parent_page);
+ void add_widgets();
+
+ Button* configure_hotkey_get_button_by_active_type();
+ ConfigHotkey* configure_hotkey_get_config_by_active_type();
+ void for_each_config_hotkey(std::function<void(ConfigHotkey *config_hotkey)> callback);
+ void configure_hotkey_start(ConfigureHotkeyType hotkey_type);
+ void configure_hotkey_cancel();
+ void configure_hotkey_stop_and_save();
+ private:
+ Overlay *overlay = nullptr;
+ Config &config;
+ const GsrInfo *gsr_info = nullptr;
+
+ GsrPage *content_page_ptr = nullptr;
+ PageStack *page_stack = nullptr;
+ RadioButton *tint_color_radio_button_ptr = nullptr;
+ RadioButton *startup_radio_button_ptr = nullptr;
+ RadioButton *enable_keyboard_hotkeys_radio_button_ptr = nullptr;
+ RadioButton *enable_joystick_hotkeys_radio_button_ptr = nullptr;
+
+ Button *turn_replay_on_off_button_ptr = nullptr;
+ Button *save_replay_button_ptr = nullptr;
+ Button *save_replay_1_min_button_ptr = nullptr;
+ Button *save_replay_10_min_button_ptr = nullptr;
+ Button *start_stop_recording_button_ptr = nullptr;
+ Button *pause_unpause_recording_button_ptr = nullptr;
+ Button *start_stop_streaming_button_ptr = nullptr;
+ Button *take_screenshot_button_ptr = nullptr;
+ Button *take_screenshot_region_button_ptr = nullptr;
+ Button *show_hide_button_ptr = nullptr;
+
+ ConfigHotkey configure_config_hotkey;
+ ConfigureHotkeyType configure_hotkey_type = ConfigureHotkeyType::NONE;
+
+ CustomRendererWidget *hotkey_overlay_ptr = nullptr;
+ std::string hotkey_configure_action_name;
+ };
+} \ No newline at end of file
diff --git a/include/gui/GsrPage.hpp b/include/gui/GsrPage.hpp
index 1d298f4..76c28a6 100644
--- a/include/gui/GsrPage.hpp
+++ b/include/gui/GsrPage.hpp
@@ -9,7 +9,7 @@
namespace gsr {
class GsrPage : public Page {
public:
- GsrPage();
+ GsrPage(const char *top_text, const char *bottom_text);
GsrPage(const GsrPage&) = delete;
GsrPage& operator=(const GsrPage&) = delete;
@@ -42,7 +42,8 @@ namespace gsr {
float margin_bottom_scale = 0.0f;
float margin_left_scale = 0.0f;
float margin_right_scale = 0.0f;
- mgl::Text label_text;
+ mgl::Text top_text;
+ mgl::Text bottom_text;
std::vector<ButtonItem> buttons;
};
} \ No newline at end of file
diff --git a/include/gui/Image.hpp b/include/gui/Image.hpp
new file mode 100644
index 0000000..d72c5c1
--- /dev/null
+++ b/include/gui/Image.hpp
@@ -0,0 +1,29 @@
+#pragma once
+
+#include "Widget.hpp"
+
+#include <mglpp/graphics/Sprite.hpp>
+
+namespace gsr {
+ class Image : public Widget {
+ public:
+ enum class ScaleBehavior {
+ SCALE,
+ CLAMP
+ };
+
+ // Set size to {0.0f, 0.0f} for no limit. The image is scaled to the size while keeping its aspect ratio
+ Image(mgl::Texture *texture, mgl::vec2f size, ScaleBehavior scale_behavior);
+ Image(const Image&) = delete;
+ Image& operator=(const Image&) = delete;
+
+ bool on_event(mgl::Event &event, mgl::Window &window, mgl::vec2f offset) override;
+ void draw(mgl::Window &window, mgl::vec2f offset) override;
+
+ mgl::vec2f get_size() override;
+ private:
+ mgl::Sprite sprite;
+ mgl::vec2f size;
+ ScaleBehavior scale_behavior;
+ };
+} \ No newline at end of file
diff --git a/include/gui/List.hpp b/include/gui/List.hpp
index 72c5353..f79d165 100644
--- a/include/gui/List.hpp
+++ b/include/gui/List.hpp
@@ -21,19 +21,20 @@ namespace gsr {
List(Orientation orientation, Alignment content_alignment = Alignment::START);
List(const List&) = delete;
List& operator=(const List&) = delete;
+ virtual ~List() override;
bool on_event(mgl::Event &event, mgl::Window &window, mgl::vec2f offset) override;
void draw(mgl::Window &window, mgl::vec2f offset) override;
- //void remove_child_widget(Widget *widget) override;
-
void add_widget(std::unique_ptr<Widget> widget);
void remove_widget(Widget *widget);
+ void replace_widget(Widget *widget, std::unique_ptr<Widget> new_widget);
void clear();
// Return true from |callback| to continue
void for_each_child_widget(std::function<bool(std::unique_ptr<Widget> &widget)> callback);
// Returns nullptr if index is invalid
Widget* get_child_widget_by_index(size_t index) const;
+ size_t get_num_children() const;
void set_spacing(float spacing);
diff --git a/include/gui/Page.hpp b/include/gui/Page.hpp
index 0d8536a..00a53c6 100644
--- a/include/gui/Page.hpp
+++ b/include/gui/Page.hpp
@@ -10,13 +10,11 @@ namespace gsr {
Page() = default;
Page(const Page&) = delete;
Page& operator=(const Page&) = delete;
- virtual ~Page() = default;
+ virtual ~Page() override;
virtual void on_navigate_to_page() {}
virtual void on_navigate_away_from_page() {}
- //void remove_child_widget(Widget *widget) override;
-
virtual void add_widget(std::unique_ptr<Widget> widget);
protected:
SafeVector<std::unique_ptr<Widget>> widgets;
diff --git a/include/gui/RadioButton.hpp b/include/gui/RadioButton.hpp
index a009eab..e319aa0 100644
--- a/include/gui/RadioButton.hpp
+++ b/include/gui/RadioButton.hpp
@@ -23,11 +23,13 @@ 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, bool trigger_event_even_if_selection_not_changed = true);
- const std::string get_selected_id() const;
+ const std::string& get_selected_id() const;
+ const std::string& get_selected_text() const;
mgl::vec2f get_size() override;
- std::function<void(const std::string &text, const std::string &id)> on_selection_changed;
+ // Return false to revert the change
+ std::function<bool(const std::string &text, const std::string &id)> on_selection_changed;
private:
void update_if_dirty();
private:
diff --git a/include/gui/ScreenshotSettingsPage.hpp b/include/gui/ScreenshotSettingsPage.hpp
new file mode 100644
index 0000000..db66d66
--- /dev/null
+++ b/include/gui/ScreenshotSettingsPage.hpp
@@ -0,0 +1,76 @@
+#pragma once
+
+#include "StaticPage.hpp"
+#include "List.hpp"
+#include "ComboBox.hpp"
+#include "Entry.hpp"
+#include "CheckBox.hpp"
+#include "../GsrInfo.hpp"
+#include "../Config.hpp"
+
+namespace gsr {
+ class PageStack;
+ class GsrPage;
+ class ScrollablePage;
+ class Button;
+
+ class ScreenshotSettingsPage : public StaticPage {
+ public:
+ ScreenshotSettingsPage(const GsrInfo *gsr_info, Config &config, PageStack *page_stack);
+ ScreenshotSettingsPage(const ScreenshotSettingsPage&) = delete;
+ ScreenshotSettingsPage& operator=(const ScreenshotSettingsPage&) = delete;
+
+ void load();
+ void save();
+ void on_navigate_away_from_page() override;
+ private:
+ std::unique_ptr<ComboBox> create_record_area_box();
+ std::unique_ptr<Widget> create_record_area();
+ std::unique_ptr<Entry> create_image_width_entry();
+ std::unique_ptr<Entry> create_image_height_entry();
+ std::unique_ptr<List> create_image_resolution();
+ std::unique_ptr<List> create_image_resolution_section();
+ std::unique_ptr<CheckBox> create_restore_portal_session_checkbox();
+ std::unique_ptr<List> create_restore_portal_session_section();
+ std::unique_ptr<Widget> create_change_image_resolution_section();
+ std::unique_ptr<Widget> create_capture_target_section();
+ std::unique_ptr<List> create_image_quality_section();
+ std::unique_ptr<Widget> create_record_cursor_section();
+ std::unique_ptr<Widget> create_image_section();
+ std::unique_ptr<List> create_save_directory(const char *label);
+ std::unique_ptr<ComboBox> create_image_format_box();
+ std::unique_ptr<List> create_image_format_section();
+ std::unique_ptr<Widget> create_file_info_section();
+ std::unique_ptr<CheckBox> create_save_screenshot_in_game_folder();
+ std::unique_ptr<Widget> create_general_section();
+ std::unique_ptr<Widget> create_notifications_section();
+ std::unique_ptr<Widget> create_settings();
+ void add_widgets();
+
+ void save(RecordOptions &record_options);
+ private:
+ Config &config;
+ const GsrInfo *gsr_info = nullptr;
+ SupportedCaptureOptions capture_options;
+
+ GsrPage *content_page_ptr = nullptr;
+ ScrollablePage *settings_scrollable_page_ptr = nullptr;
+ List *image_resolution_list_ptr = nullptr;
+ List *restore_portal_session_list_ptr = nullptr;
+ List *color_range_list_ptr = nullptr;
+ Widget *image_format_ptr = nullptr;
+ ComboBox *record_area_box_ptr = nullptr;
+ Entry *image_width_entry_ptr = nullptr;
+ Entry *image_height_entry_ptr = nullptr;
+ CheckBox *record_cursor_checkbox_ptr = nullptr;
+ CheckBox *restore_portal_session_checkbox_ptr = nullptr;
+ CheckBox *change_image_resolution_checkbox_ptr = nullptr;
+ ComboBox *image_quality_box_ptr = nullptr;
+ ComboBox *image_format_box_ptr = nullptr;
+ Button *save_directory_button_ptr = nullptr;
+ CheckBox *save_screenshot_in_game_folder_checkbox_ptr = nullptr;
+ CheckBox *show_screenshot_saved_notification_checkbox_ptr = nullptr;
+
+ PageStack *page_stack = nullptr;
+ };
+} \ No newline at end of file
diff --git a/include/gui/ScrollablePage.hpp b/include/gui/ScrollablePage.hpp
index 452d0e9..54ec2cb 100644
--- a/include/gui/ScrollablePage.hpp
+++ b/include/gui/ScrollablePage.hpp
@@ -12,6 +12,7 @@ namespace gsr {
ScrollablePage(mgl::vec2f size);
ScrollablePage(const ScrollablePage&) = delete;
ScrollablePage& operator=(const ScrollablePage&) = delete;
+ virtual ~ScrollablePage() override;
bool on_event(mgl::Event &event, mgl::Window &window, mgl::vec2f offset) override;
void draw(mgl::Window &window, mgl::vec2f offset) override;
diff --git a/include/gui/SettingsPage.hpp b/include/gui/SettingsPage.hpp
index f18ff65..1810de5 100644
--- a/include/gui/SettingsPage.hpp
+++ b/include/gui/SettingsPage.hpp
@@ -10,12 +10,20 @@
#include "../GsrInfo.hpp"
#include "../Config.hpp"
+#include <functional>
+
namespace gsr {
class GsrPage;
class PageStack;
class ScrollablePage;
class Label;
class LineSeparator;
+ class Subsection;
+
+ enum class AudioDeviceType {
+ OUTPUT,
+ INPUT
+ };
class SettingsPage : public StaticPage {
public:
@@ -25,18 +33,19 @@ namespace gsr {
STREAM
};
- SettingsPage(Type type, const GsrInfo &gsr_info, Config &config, PageStack *page_stack);
+ SettingsPage(Type type, const GsrInfo *gsr_info, Config &config, PageStack *page_stack);
SettingsPage(const SettingsPage&) = delete;
SettingsPage& operator=(const SettingsPage&) = delete;
- void load(const GsrInfo &gsr_info);
+ void load();
void save();
void on_navigate_away_from_page() override;
+
+ std::function<void()> on_config_changed;
private:
std::unique_ptr<RadioButton> create_view_radio_button();
- std::unique_ptr<ComboBox> create_record_area_box(const GsrInfo &gsr_info);
- std::unique_ptr<Widget> create_record_area(const GsrInfo &gsr_info);
- std::unique_ptr<List> create_select_window();
+ std::unique_ptr<ComboBox> create_record_area_box();
+ std::unique_ptr<Widget> create_record_area();
std::unique_ptr<Entry> create_area_width_entry();
std::unique_ptr<Entry> create_area_height_entry();
std::unique_ptr<List> create_area_size();
@@ -48,30 +57,32 @@ namespace gsr {
std::unique_ptr<CheckBox> create_restore_portal_session_checkbox();
std::unique_ptr<List> create_restore_portal_session_section();
std::unique_ptr<Widget> create_change_video_resolution_section();
- std::unique_ptr<Widget> create_capture_target(const GsrInfo &gsr_info);
- std::unique_ptr<ComboBox> create_audio_device_selection_combobox();
- std::unique_ptr<Button> create_remove_audio_device_button(List *audio_device_list_ptr);
- std::unique_ptr<List> create_audio_device();
- std::unique_ptr<Button> create_add_audio_device_button();
- std::unique_ptr<ComboBox> create_application_audio_selection_combobox();
- std::unique_ptr<List> create_application_audio();
- std::unique_ptr<List> create_custom_application_audio();
- std::unique_ptr<Button> create_add_application_audio_button();
- std::unique_ptr<Button> create_add_custom_application_audio_button();
- std::unique_ptr<List> create_add_audio_buttons();
- std::unique_ptr<List> create_audio_track_track_section();
- std::unique_ptr<CheckBox> create_merge_audio_tracks_checkbox();
+ std::unique_ptr<Widget> create_capture_target_section();
+ std::unique_ptr<ComboBox> create_audio_device_selection_combobox(AudioDeviceType device_type);
+ std::unique_ptr<Button> create_remove_audio_device_button(List *audio_input_list_ptr, List *audio_device_list_ptr);
+ std::unique_ptr<List> create_audio_device(AudioDeviceType device_type, List *audio_input_list_ptr);
+ std::unique_ptr<Button> create_add_audio_track_button();
+ std::unique_ptr<Button> create_add_audio_output_device_button(List *audio_input_list_ptr);
+ std::unique_ptr<Button> create_add_audio_input_device_button(List *audio_input_list_ptr);
+ std::unique_ptr<ComboBox> create_application_audio_selection_combobox(List *application_audio_row);
+ std::unique_ptr<List> create_application_audio(List *audio_input_list_ptr);
+ std::unique_ptr<List> create_custom_application_audio(List *audio_input_list_ptr);
+ std::unique_ptr<Button> create_add_application_audio_button(List *audio_input_list_ptr);
+ std::unique_ptr<List> create_add_audio_buttons(List *audio_input_list_ptr);
+ std::unique_ptr<List> create_audio_input_section();
std::unique_ptr<CheckBox> create_application_audio_invert_checkbox();
- std::unique_ptr<Widget> create_audio_track_section();
+ std::unique_ptr<List> create_audio_track_title_and_remove(Subsection *audio_track_subsection, const char *title);
+ std::unique_ptr<Subsection> create_audio_track_section(Widget *parent_widget);
+ std::unique_ptr<List> create_audio_track_section_list();
std::unique_ptr<Widget> create_audio_section();
std::unique_ptr<List> create_video_quality_box();
- std::unique_ptr<Entry> create_video_bitrate_entry();
+ std::unique_ptr<List> create_video_bitrate_entry();
std::unique_ptr<List> create_video_bitrate();
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_video_codec_box();
+ std::unique_ptr<List> create_video_codec();
std::unique_ptr<ComboBox> create_audio_codec_box();
std::unique_ptr<List> create_audio_codec();
std::unique_ptr<Entry> create_framerate_entry();
@@ -80,24 +91,29 @@ namespace gsr {
std::unique_ptr<List> create_framerate_mode();
std::unique_ptr<List> create_framerate_section();
std::unique_ptr<Widget> create_record_cursor_section();
- std::unique_ptr<Widget> create_video_section(const GsrInfo &gsr_info);
- std::unique_ptr<Widget> create_settings(const GsrInfo &gsr_info);
- void add_widgets(const GsrInfo &gsr_info);
+ std::unique_ptr<Widget> create_video_section();
+ std::unique_ptr<Widget> create_settings();
+ void add_widgets();
- void add_page_specific_widgets(const GsrInfo &gsr_info);
+ 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();
- std::unique_ptr<Entry> create_replay_time_entry();
+ std::unique_ptr<List> create_replay_time_entry();
std::unique_ptr<List> create_replay_time();
- std::unique_ptr<RadioButton> create_start_replay_automatically(const GsrInfo &gsr_info);
- std::unique_ptr<CheckBox> create_save_replay_in_game_folder(const GsrInfo &gsr_info);
- std::unique_ptr<Label> create_estimated_file_size();
- void update_estimated_file_size();
- std::unique_ptr<CheckBox> create_save_recording_in_game_folder(const GsrInfo &gsr_info);
- void add_replay_widgets(const GsrInfo &gsr_info);
- void add_record_widgets(const GsrInfo &gsr_info);
+ std::unique_ptr<List> create_replay_storage();
+ std::unique_ptr<RadioButton> create_start_replay_automatically();
+ std::unique_ptr<CheckBox> create_save_replay_in_game_folder();
+ std::unique_ptr<CheckBox> create_restart_replay_on_save();
+ std::unique_ptr<Label> create_estimated_replay_file_size();
+ void update_estimated_replay_file_size(const std::string &replay_storage_type);
+ void update_replay_time_text();
+ std::unique_ptr<CheckBox> create_save_recording_in_game_folder();
+ std::unique_ptr<Label> create_estimated_record_file_size();
+ void update_estimated_record_file_size();
+ void add_replay_widgets();
+ void add_record_widgets();
std::unique_ptr<ComboBox> create_streaming_service_box();
std::unique_ptr<List> create_streaming_service_section();
@@ -105,28 +121,31 @@ namespace gsr {
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(const GsrInfo &gsr_info);
+ void add_stream_widgets();
- void load_audio_tracks(const RecordOptions &record_options, const GsrInfo &gsr_info);
- void load_common(RecordOptions &record_options, const GsrInfo &gsr_info);
- void load_replay(const GsrInfo &gsr_info);
- void load_record(const GsrInfo &gsr_info);
- void load_stream(const GsrInfo &gsr_info);
+ void load_audio_tracks(const RecordOptions &record_options);
+ void load_common(RecordOptions &record_options);
+ void load_replay();
+ void load_record();
+ void load_stream();
void save_common(RecordOptions &record_options);
void save_replay();
void save_record();
void save_stream();
+
+ void view_changed(bool advanced_view, Subsection *notifications_subsection_ptr);
private:
Type type;
Config &config;
+ const GsrInfo *gsr_info = nullptr;
std::vector<AudioDevice> audio_devices;
std::vector<std::string> application_audio;
+ SupportedCaptureOptions capture_options;
GsrPage *content_page_ptr = nullptr;
ScrollablePage *settings_scrollable_page_ptr = nullptr;
List *settings_list_ptr = nullptr;
- List *select_window_list_ptr = nullptr;
List *area_size_list_ptr = nullptr;
List *video_resolution_list_ptr = nullptr;
List *restore_portal_session_list_ptr = nullptr;
@@ -142,11 +161,6 @@ namespace gsr {
Entry *framerate_entry_ptr = nullptr;
Entry *video_bitrate_entry_ptr = nullptr;
List *video_bitrate_list_ptr = nullptr;
- List *audio_track_list_ptr = nullptr;
- Button *add_application_audio_button_ptr = nullptr;
- Button *add_custom_application_audio_button_ptr = nullptr;
- CheckBox *merge_audio_tracks_checkbox_ptr = nullptr;
- CheckBox *application_audio_invert_checkbox_ptr = nullptr;
CheckBox *change_video_resolution_checkbox_ptr = nullptr;
ComboBox *color_range_box_ptr = nullptr;
ComboBox *video_quality_box_ptr = nullptr;
@@ -162,6 +176,7 @@ namespace gsr {
List *stream_url_list_ptr = nullptr;
List *container_list_ptr = nullptr;
CheckBox *save_replay_in_game_folder_ptr = nullptr;
+ CheckBox *restart_replay_on_save = nullptr;
Label *estimated_file_size_ptr = nullptr;
CheckBox *show_replay_started_notification_checkbox_ptr = nullptr;
CheckBox *show_replay_stopped_notification_checkbox_ptr = nullptr;
@@ -169,17 +184,21 @@ namespace gsr {
CheckBox *save_recording_in_game_folder_ptr = nullptr;
CheckBox *show_recording_started_notification_checkbox_ptr = nullptr;
CheckBox *show_video_saved_notification_checkbox_ptr = nullptr;
+ CheckBox *show_video_paused_notification_checkbox_ptr = nullptr;
CheckBox *show_streaming_started_notification_checkbox_ptr = nullptr;
CheckBox *show_streaming_stopped_notification_checkbox_ptr = nullptr;
Button *save_directory_button_ptr = nullptr;
Entry *twitch_stream_key_entry_ptr = nullptr;
Entry *youtube_stream_key_entry_ptr = nullptr;
+ Entry *rumble_stream_key_entry_ptr = nullptr;
Entry *stream_url_entry_ptr = nullptr;
Entry *replay_time_entry_ptr = nullptr;
+ RadioButton *replay_storage_button_ptr = nullptr;
+ Label *replay_time_label_ptr = nullptr;
RadioButton *turn_on_replay_automatically_mode_ptr = nullptr;
+ Subsection *audio_section_ptr = nullptr;
+ List *audio_track_section_list_ptr = nullptr;
PageStack *page_stack = nullptr;
-
- mgl::Text settings_title_text;
};
} \ No newline at end of file
diff --git a/include/gui/Subsection.hpp b/include/gui/Subsection.hpp
index 4da6baf..88953d2 100644
--- a/include/gui/Subsection.hpp
+++ b/include/gui/Subsection.hpp
@@ -11,15 +11,20 @@ namespace gsr {
Subsection(const char *title, std::unique_ptr<Widget> inner_widget, mgl::vec2f size);
Subsection(const Subsection&) = delete;
Subsection& operator=(const Subsection&) = delete;
+ virtual ~Subsection() override;
bool on_event(mgl::Event &event, mgl::Window &window, mgl::vec2f offset) override;
void draw(mgl::Window &window, mgl::vec2f offset) override;
mgl::vec2f get_size() override;
mgl::vec2f get_inner_size() override;
+
+ Widget* get_inner_widget();
+ void set_bg_color(mgl::Color color);
private:
Label label;
std::unique_ptr<Widget> inner_widget;
mgl::vec2f size;
+ mgl::Color bg_color{25, 30, 34};
};
} \ No newline at end of file
diff --git a/include/gui/Utils.hpp b/include/gui/Utils.hpp
index 6963bc5..542e4ea 100644
--- a/include/gui/Utils.hpp
+++ b/include/gui/Utils.hpp
@@ -3,9 +3,6 @@
#include <mglpp/system/vec.hpp>
#include <mglpp/graphics/Color.hpp>
-#include <functional>
-#include <string_view>
-
namespace mgl {
class Window;
}
@@ -15,4 +12,6 @@ namespace gsr {
void draw_rectangle_outline(mgl::Window &window, mgl::vec2f pos, mgl::vec2f size, mgl::Color color, float border_size);
double get_frame_delta_seconds();
void set_frame_delta_seconds(double frame_delta);
+ mgl::vec2f scale_keep_aspect_ratio(mgl::vec2f from, mgl::vec2f to);
+ mgl::vec2f clamp_keep_aspect_ratio(mgl::vec2f from, mgl::vec2f to);
} \ No newline at end of file
diff --git a/include/gui/Widget.hpp b/include/gui/Widget.hpp
index 57424cd..131e756 100644
--- a/include/gui/Widget.hpp
+++ b/include/gui/Widget.hpp
@@ -1,6 +1,7 @@
#pragma once
#include <mglpp/system/vec.hpp>
+#include <memory>
namespace mgl {
class Event;
@@ -31,8 +32,6 @@ namespace gsr {
virtual void draw(mgl::Window &window, mgl::vec2f offset) = 0;
virtual void set_position(mgl::vec2f position);
- //virtual void remove_child_widget(Widget *widget) { (void)widget; }
-
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
@@ -61,4 +60,7 @@ namespace gsr {
bool visible = true;
};
+
+ void add_widget_to_remove(std::unique_ptr<Widget> widget);
+ void remove_widgets_to_be_removed();
} \ No newline at end of file