aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/Config.hpp31
-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)0
-rw-r--r--include/GlobalHotkeys/GlobalHotkeysJoystick.hpp (renamed from include/GlobalHotkeysJoystick.hpp)10
-rw-r--r--include/GlobalHotkeys/GlobalHotkeysLinux.hpp (renamed from include/GlobalHotkeysLinux.hpp)2
-rw-r--r--include/GlobalHotkeys/GlobalHotkeysX11.hpp (renamed from include/GlobalHotkeysX11.hpp)0
-rw-r--r--include/Overlay.hpp41
-rw-r--r--include/RegionSelector.hpp1
-rw-r--r--include/SafeVector.hpp137
-rw-r--r--include/Theme.hpp5
-rw-r--r--include/Utils.hpp3
-rw-r--r--include/WindowSelector.hpp33
-rw-r--r--include/WindowUtils.hpp2
-rw-r--r--include/gui/Button.hpp2
-rw-r--r--include/gui/DropdownButton.hpp2
-rw-r--r--include/gui/GlobalSettingsPage.hpp8
-rw-r--r--include/gui/List.hpp5
-rw-r--r--include/gui/Page.hpp4
-rw-r--r--include/gui/RadioButton.hpp3
-rw-r--r--include/gui/ScreenshotSettingsPage.hpp2
-rw-r--r--include/gui/ScrollablePage.hpp1
-rw-r--r--include/gui/SettingsPage.hpp51
-rw-r--r--include/gui/Subsection.hpp5
-rw-r--r--include/gui/Widget.hpp6
26 files changed, 355 insertions, 85 deletions
diff --git a/include/Config.hpp b/include/Config.hpp
index 1e2e9cb..7c2aeda 100644
--- a/include/Config.hpp
+++ b/include/Config.hpp
@@ -6,7 +6,7 @@
#include <vector>
#include <optional>
-#define GSR_CONFIG_FILE_VERSION 1
+#define GSR_CONFIG_FILE_VERSION 2
namespace gsr {
struct SupportedCaptureOptions;
@@ -30,6 +30,14 @@ namespace gsr {
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 {
std::string record_area_option = "screen";
int32_t record_area_width = 0;
@@ -37,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; // Currently unused for streaming because all known streaming sites only support 1 audio track
- 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;
@@ -70,6 +79,10 @@ namespace gsr {
std::string stream_key;
};
+ struct RumbleStreamConfig {
+ std::string stream_key;
+ };
+
struct CustomStreamConfig {
std::string url;
std::string container = "flv";
@@ -82,6 +95,7 @@ namespace gsr {
std::string streaming_service = "twitch";
YoutubeStreamConfig youtube;
TwitchStreamConfig twitch;
+ RumbleStreamConfig rumble;
CustomStreamConfig custom;
ConfigHotkey start_stop_hotkey;
};
@@ -91,6 +105,7 @@ 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_hotkey;
@@ -108,8 +123,11 @@ namespace gsr {
std::string save_directory;
std::string container = "mp4";
int32_t replay_time = 60;
+ std::string replay_storage = "ram";
ConfigHotkey start_stop_hotkey;
ConfigHotkey save_hotkey;
+ ConfigHotkey save_1_min_hotkey;
+ ConfigHotkey save_10_min_hotkey;
};
struct ScreenshotConfig {
@@ -126,6 +144,7 @@ namespace gsr {
bool show_screenshot_saved_notifications = true;
std::string save_directory;
ConfigHotkey take_screenshot_hotkey;
+ ConfigHotkey take_screenshot_region_hotkey;
};
struct Config {
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 2927fa7..2927fa7 100644
--- a/include/GlobalHotkeys.hpp
+++ b/include/GlobalHotkeys/GlobalHotkeys.hpp
diff --git a/include/GlobalHotkeysJoystick.hpp b/include/GlobalHotkeys/GlobalHotkeysJoystick.hpp
index 1effe3c..0177d29 100644
--- a/include/GlobalHotkeysJoystick.hpp
+++ b/include/GlobalHotkeys/GlobalHotkeysJoystick.hpp
@@ -1,7 +1,7 @@
#pragma once
#include "GlobalHotkeys.hpp"
-#include "Hotplug.hpp"
+#include "../Hotplug.hpp"
#include <unordered_map>
#include <thread>
#include <poll.h>
@@ -21,9 +21,12 @@ namespace gsr {
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:
@@ -53,11 +56,16 @@ namespace gsr {
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;
};
diff --git a/include/GlobalHotkeysLinux.hpp b/include/GlobalHotkeys/GlobalHotkeysLinux.hpp
index c9428de..959d095 100644
--- a/include/GlobalHotkeysLinux.hpp
+++ b/include/GlobalHotkeys/GlobalHotkeysLinux.hpp
@@ -22,6 +22,8 @@ namespace gsr {
void unbind_all_keys() override;
void poll_events() override;
private:
+ void close_fds();
+ private:
pid_t process_id = 0;
int read_pipes[2];
int write_pipes[2];
diff --git a/include/GlobalHotkeysX11.hpp b/include/GlobalHotkeys/GlobalHotkeysX11.hpp
index 610399a..610399a 100644
--- a/include/GlobalHotkeysX11.hpp
+++ b/include/GlobalHotkeys/GlobalHotkeysX11.hpp
diff --git a/include/Overlay.hpp b/include/Overlay.hpp
index 5ed7f51..3de89c2 100644
--- a/include/Overlay.hpp
+++ b/include/Overlay.hpp
@@ -6,9 +6,11 @@
#include "Config.hpp"
#include "window_texture.h"
#include "WindowUtils.hpp"
-#include "GlobalHotkeysJoystick.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>
@@ -58,11 +60,15 @@ namespace gsr {
void toggle_stream();
void toggle_replay();
void save_replay();
+ void save_replay_1_min();
+ void save_replay_10_min();
void take_screenshot();
- void show_notification(const char *str, double timeout_seconds, mgl::Color icon_color, mgl::Color bg_color, NotificationType notification_type);
+ 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;
@@ -84,7 +90,8 @@ namespace gsr {
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 update_gsr_replay_save();
+ 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();
@@ -93,7 +100,7 @@ namespace gsr {
void update_power_supply_status();
void update_system_startup_status();
- void on_stop_recording(int exit_code);
+ void on_stop_recording(int exit_code, const std::string &video_filepath);
void update_ui_recording_paused();
void update_ui_recording_unpaused();
@@ -107,13 +114,18 @@ namespace gsr {
void update_ui_replay_started();
void update_ui_replay_stopped();
+ void prepare_gsr_output_for_reading();
void on_press_save_replay();
- bool on_press_start_replay(bool disable_notification, bool finished_region_selection);
- void on_press_start_record(bool finished_region_selection);
- void on_press_start_stream(bool finished_region_selection);
- void on_press_take_screenshot(bool finished_region_selection);
+ 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:
using KeyBindingCallback = std::function<void()>;
@@ -199,10 +211,23 @@ namespace gsr {
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/RegionSelector.hpp b/include/RegionSelector.hpp
index 0465302..ef0bc0e 100644
--- a/include/RegionSelector.hpp
+++ b/include/RegionSelector.hpp
@@ -26,7 +26,6 @@ namespace gsr {
bool failed() const;
bool poll_events();
- bool is_selected() const;
bool take_selection();
bool take_canceled();
Region get_selection() const;
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 bda8dd4..1390182 100644
--- a/include/Theme.hpp
+++ b/include/Theme.hpp
@@ -28,6 +28,7 @@ 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;
@@ -42,12 +43,16 @@ namespace gsr {
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;
diff --git a/include/Utils.hpp b/include/Utils.hpp
index 19700df..3d3c029 100644
--- a/include/Utils.hpp
+++ b/include/Utils.hpp
@@ -14,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();
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
index e31eeb2..5c4d39a 100644
--- a/include/WindowUtils.hpp
+++ b/include/WindowUtils.hpp
@@ -15,6 +15,7 @@ namespace gsr {
struct Monitor {
mgl::vec2i position;
mgl::vec2i size;
+ std::string name;
};
std::optional<std::string> get_window_title(Display *dpy, Window window);
@@ -23,6 +24,7 @@ namespace gsr {
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);
diff --git a/include/gui/Button.hpp b/include/gui/Button.hpp
index 7070457..f412521 100644
--- a/include/gui/Button.hpp
+++ b/include/gui/Button.hpp
@@ -21,6 +21,7 @@ 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);
@@ -38,5 +39,6 @@ namespace gsr {
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 486e811..f613d86 100644
--- a/include/gui/DropdownButton.hpp
+++ b/include/gui/DropdownButton.hpp
@@ -21,6 +21,7 @@ namespace gsr {
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);
@@ -36,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
index c261ab6..d96397d 100644
--- a/include/gui/GlobalSettingsPage.hpp
+++ b/include/gui/GlobalSettingsPage.hpp
@@ -22,10 +22,13 @@ namespace gsr {
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
};
@@ -55,9 +58,11 @@ namespace gsr {
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);
@@ -87,10 +92,13 @@ namespace gsr {
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;
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 16d638e..e319aa0 100644
--- a/include/gui/RadioButton.hpp
+++ b/include/gui/RadioButton.hpp
@@ -23,7 +23,8 @@ 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;
diff --git a/include/gui/ScreenshotSettingsPage.hpp b/include/gui/ScreenshotSettingsPage.hpp
index 1cfbf00..db66d66 100644
--- a/include/gui/ScreenshotSettingsPage.hpp
+++ b/include/gui/ScreenshotSettingsPage.hpp
@@ -26,7 +26,6 @@ namespace gsr {
private:
std::unique_ptr<ComboBox> create_record_area_box();
std::unique_ptr<Widget> create_record_area();
- std::unique_ptr<List> create_select_window();
std::unique_ptr<Entry> create_image_width_entry();
std::unique_ptr<Entry> create_image_height_entry();
std::unique_ptr<List> create_image_resolution();
@@ -56,7 +55,6 @@ namespace gsr {
GsrPage *content_page_ptr = nullptr;
ScrollablePage *settings_scrollable_page_ptr = nullptr;
- List *select_window_list_ptr = nullptr;
List *image_resolution_list_ptr = nullptr;
List *restore_portal_session_list_ptr = nullptr;
List *color_range_list_ptr = nullptr;
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 b9f5cde..1810de5 100644
--- a/include/gui/SettingsPage.hpp
+++ b/include/gui/SettingsPage.hpp
@@ -18,6 +18,12 @@ namespace gsr {
class ScrollablePage;
class Label;
class LineSeparator;
+ class Subsection;
+
+ enum class AudioDeviceType {
+ OUTPUT,
+ INPUT
+ };
class SettingsPage : public StaticPage {
public:
@@ -40,7 +46,6 @@ namespace gsr {
std::unique_ptr<RadioButton> create_view_radio_button();
std::unique_ptr<ComboBox> create_record_area_box();
std::unique_ptr<Widget> create_record_area();
- 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();
@@ -53,20 +58,22 @@ namespace gsr {
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_section();
- 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_split_audio_checkbox();
+ 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<List> create_video_bitrate_entry();
@@ -95,11 +102,12 @@ namespace gsr {
std::unique_ptr<List> create_container_section();
std::unique_ptr<List> create_replay_time_entry();
std::unique_ptr<List> create_replay_time();
+ 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();
+ 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();
@@ -125,6 +133,8 @@ namespace gsr {
void save_replay();
void save_record();
void save_stream();
+
+ void view_changed(bool advanced_view, Subsection *notifications_subsection_ptr);
private:
Type type;
Config &config;
@@ -136,7 +146,6 @@ namespace gsr {
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;
@@ -152,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 *split_audio_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;
@@ -180,15 +184,20 @@ 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;
};
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/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