mirror of
https://repo.dec05eba.com/gpu-screen-recorder-ui
synced 2026-05-07 15:19:56 +09:00
More
This commit is contained in:
27
include/GlobalHotkeys.hpp
Normal file
27
include/GlobalHotkeys.hpp
Normal file
@@ -0,0 +1,27 @@
|
||||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
#include <functional>
|
||||
#include <string>
|
||||
|
||||
namespace gsr {
|
||||
struct Hotkey {
|
||||
uint64_t key = 0;
|
||||
uint32_t modifiers = 0;
|
||||
};
|
||||
|
||||
using GlobalHotkeyCallback = std::function<void(const std::string &id)>;
|
||||
|
||||
class GlobalHotkeys {
|
||||
public:
|
||||
GlobalHotkeys() = default;
|
||||
GlobalHotkeys(const GlobalHotkeys&) = delete;
|
||||
GlobalHotkeys& operator=(const GlobalHotkeys&) = delete;
|
||||
virtual ~GlobalHotkeys() = default;
|
||||
|
||||
virtual bool bind_key_press(Hotkey hotkey, const std::string &id, GlobalHotkeyCallback callback) = 0;
|
||||
virtual void unbind_key_press(const std::string &id) = 0;
|
||||
virtual void unbind_all_keys() = 0;
|
||||
virtual void poll_events() = 0;
|
||||
};
|
||||
}
|
||||
31
include/GlobalHotkeysX11.hpp
Normal file
31
include/GlobalHotkeysX11.hpp
Normal file
@@ -0,0 +1,31 @@
|
||||
#pragma once
|
||||
|
||||
#include "GlobalHotkeys.hpp"
|
||||
#include <unordered_map>
|
||||
#include <X11/Xlib.h>
|
||||
|
||||
namespace gsr {
|
||||
class GlobalHotkeysX11 : public GlobalHotkeys {
|
||||
public:
|
||||
GlobalHotkeysX11();
|
||||
GlobalHotkeysX11(const GlobalHotkeysX11&) = delete;
|
||||
GlobalHotkeysX11& operator=(const GlobalHotkeysX11&) = delete;
|
||||
~GlobalHotkeysX11() override;
|
||||
|
||||
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;
|
||||
private:
|
||||
void call_hotkey_callback(Hotkey hotkey) const;
|
||||
private:
|
||||
struct HotkeyData {
|
||||
Hotkey hotkey;
|
||||
GlobalHotkeyCallback callback;
|
||||
};
|
||||
|
||||
Display *dpy = nullptr;
|
||||
XEvent xev;
|
||||
std::unordered_map<std::string, HotkeyData> bound_keys_by_id;
|
||||
};
|
||||
}
|
||||
@@ -10,7 +10,11 @@ namespace gsr {
|
||||
bool h264 = false;
|
||||
bool h264_software = false;
|
||||
bool hevc = false;
|
||||
bool hevc_hdr = false;
|
||||
bool hevc_10bit = false;
|
||||
bool av1 = false;
|
||||
bool av1_hdr = false;
|
||||
bool av1_10bit = false;
|
||||
bool vp8 = false;
|
||||
bool vp9 = false;
|
||||
};
|
||||
|
||||
56
include/Overlay.hpp
Normal file
56
include/Overlay.hpp
Normal file
@@ -0,0 +1,56 @@
|
||||
#pragma once
|
||||
|
||||
#include "gui/PageStack.hpp"
|
||||
#include "gui/CustomRendererWidget.hpp"
|
||||
#include "GsrInfo.hpp"
|
||||
#include "Config.hpp"
|
||||
#include "window_texture.h"
|
||||
|
||||
#include <mglpp/window/Window.hpp>
|
||||
#include <mglpp/graphics/Texture.hpp>
|
||||
#include <mglpp/graphics/Sprite.hpp>
|
||||
#include <mglpp/graphics/Rectangle.hpp>
|
||||
#include <mglpp/graphics/Text.hpp>
|
||||
|
||||
namespace gsr {
|
||||
class Overlay {
|
||||
public:
|
||||
Overlay(mgl::Window &window, std::string resources_path, GsrInfo gsr_info, egl_functions egl_funcs, mgl::Color bg_color);
|
||||
Overlay(const Overlay&) = delete;
|
||||
Overlay& operator=(const Overlay&) = delete;
|
||||
~Overlay();
|
||||
|
||||
void on_event(mgl::Event &event, mgl::Window &window);
|
||||
void draw(mgl::Window &window);
|
||||
|
||||
void show();
|
||||
void hide();
|
||||
void toggle_show();
|
||||
bool is_open() const;
|
||||
private:
|
||||
bool update_compositor_texture(const mgl_monitor *monitor);
|
||||
private:
|
||||
mgl::Window &window;
|
||||
std::string resources_path;
|
||||
GsrInfo gsr_info;
|
||||
egl_functions egl_funcs;
|
||||
mgl::Color bg_color;
|
||||
std::vector<gsr::AudioDevice> audio_devices;
|
||||
mgl::Texture window_texture_texture;
|
||||
mgl::Sprite window_texture_sprite;
|
||||
mgl::Texture screenshot_texture;
|
||||
mgl::Sprite screenshot_sprite;
|
||||
mgl::Rectangle bg_screenshot_overlay;
|
||||
WindowTexture window_texture;
|
||||
gsr::PageStack page_stack;
|
||||
mgl::Rectangle top_bar_background;
|
||||
mgl::Text top_bar_text;
|
||||
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;
|
||||
std::optional<Config> config;
|
||||
};
|
||||
}
|
||||
@@ -32,11 +32,20 @@ namespace gsr {
|
||||
mgl::Texture settings_texture;
|
||||
mgl::Texture folder_texture;
|
||||
mgl::Texture up_arrow_texture;
|
||||
mgl::Texture replay_button_texture;
|
||||
mgl::Texture record_button_texture;
|
||||
mgl::Texture stream_button_texture;
|
||||
mgl::Texture close_texture;
|
||||
mgl::Texture logo_texture;
|
||||
|
||||
double double_click_timeout_seconds = 0.4;
|
||||
|
||||
// Reloads fonts
|
||||
bool set_window_size(mgl::vec2i window_size);
|
||||
};
|
||||
|
||||
bool init_theme(const GsrInfo &gsr_info, mgl::vec2i window_size, const std::string &resources_path);
|
||||
bool init_theme(const GsrInfo &gsr_info, const std::string &resources_path);
|
||||
void deinit_theme();
|
||||
|
||||
Theme& get_theme();
|
||||
}
|
||||
@@ -15,6 +15,7 @@ namespace gsr {
|
||||
void draw(mgl::Window &window, mgl::vec2f offset) override;
|
||||
|
||||
mgl::vec2f get_size() override;
|
||||
void set_size(mgl::vec2f size);
|
||||
|
||||
std::function<void(mgl::Window &window, mgl::vec2f pos, mgl::vec2f size)> draw_handler;
|
||||
// Return true to allow other widgets to handle events
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
namespace gsr {
|
||||
class GsrPage;
|
||||
class PageStack;
|
||||
class ScrollablePage;
|
||||
|
||||
class SettingsPage : public StaticPage {
|
||||
public:
|
||||
@@ -31,7 +32,7 @@ namespace gsr {
|
||||
private:
|
||||
std::unique_ptr<RadioButton> create_view_radio_button();
|
||||
std::unique_ptr<ComboBox> create_record_area_box(const GsrInfo &gsr_info);
|
||||
std::unique_ptr<List> create_record_area(const GsrInfo &gsr_info);
|
||||
std::unique_ptr<Widget> create_record_area(const GsrInfo &gsr_info);
|
||||
std::unique_ptr<List> create_select_window();
|
||||
std::unique_ptr<Entry> create_area_width_entry();
|
||||
std::unique_ptr<Entry> create_area_height_entry();
|
||||
@@ -39,14 +40,14 @@ namespace gsr {
|
||||
std::unique_ptr<List> create_area_size_section();
|
||||
std::unique_ptr<CheckBox> create_restore_portal_session_checkbox();
|
||||
std::unique_ptr<List> create_restore_portal_session_section();
|
||||
std::unique_ptr<List> create_capture_target(const GsrInfo &gsr_info);
|
||||
std::unique_ptr<Widget> create_capture_target(const GsrInfo &gsr_info);
|
||||
std::unique_ptr<ComboBox> create_audio_track_selection_checkbox(const std::vector<AudioDevice> &audio_devices);
|
||||
std::unique_ptr<Button> create_remove_audio_track_button(List *audio_device_list_ptr);
|
||||
std::unique_ptr<List> create_audio_track(const std::vector<AudioDevice> &audio_devices);
|
||||
std::unique_ptr<Button> create_add_audio_track_button(const std::vector<AudioDevice> &audio_devices);
|
||||
std::unique_ptr<List> create_audio_track_section(const std::vector<AudioDevice> &audio_devices);
|
||||
std::unique_ptr<CheckBox> create_merge_audio_tracks_checkbox();
|
||||
std::unique_ptr<List> create_audio_device_section(const std::vector<AudioDevice> &audio_devices);
|
||||
std::unique_ptr<Widget> create_audio_device_section(const std::vector<AudioDevice> &audio_devices);
|
||||
std::unique_ptr<ComboBox> create_video_quality_box();
|
||||
std::unique_ptr<List> create_video_quality();
|
||||
std::unique_ptr<ComboBox> create_color_range_box();
|
||||
@@ -62,7 +63,9 @@ namespace gsr {
|
||||
std::unique_ptr<ComboBox> create_framerate_mode_box();
|
||||
std::unique_ptr<List> create_framerate_mode();
|
||||
std::unique_ptr<List> create_framerate_section();
|
||||
std::unique_ptr<List> create_settings(const GsrInfo &gsr_info, const std::vector<AudioDevice> &audio_devices);
|
||||
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, const std::vector<AudioDevice> &audio_devices);
|
||||
void add_widgets(const GsrInfo &gsr_info, const std::vector<AudioDevice> &audio_devices);
|
||||
|
||||
void add_page_specific_widgets();
|
||||
@@ -92,6 +95,7 @@ namespace gsr {
|
||||
std::optional<Config> &config;
|
||||
|
||||
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;
|
||||
|
||||
24
include/gui/Subsection.hpp
Normal file
24
include/gui/Subsection.hpp
Normal file
@@ -0,0 +1,24 @@
|
||||
#pragma once
|
||||
|
||||
#include "Widget.hpp"
|
||||
#include "Label.hpp"
|
||||
#include <memory>
|
||||
|
||||
namespace gsr {
|
||||
class Subsection : public Widget {
|
||||
public:
|
||||
// If size width or height is 0 then the size in that direction is the size of the widgets
|
||||
Subsection(const char *title, std::unique_ptr<Widget> inner_widget, mgl::vec2f size);
|
||||
Subsection(const Subsection&) = delete;
|
||||
Subsection& operator=(const Subsection&) = 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:
|
||||
Label label;
|
||||
std::unique_ptr<Widget> inner_widget;
|
||||
mgl::vec2f size;
|
||||
};
|
||||
}
|
||||
@@ -13,6 +13,7 @@ namespace gsr {
|
||||
friend class ScrollablePage;
|
||||
friend class List;
|
||||
friend class Page;
|
||||
friend class Subsection;
|
||||
public:
|
||||
enum class Alignment {
|
||||
START,
|
||||
|
||||
Reference in New Issue
Block a user