blob: fcc378115c436e8f8e145e16572a5909ab7589d7 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
|
#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>
#include <mglpp/window/Event.hpp>
namespace gsr {
class DropdownButton;
enum class RecordingStatus {
NONE,
REPLAY,
RECORD,
STREAM
};
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:
void process_key_bindings(mgl::Event &event);
void update_gsr_process_status();
void load_program_status();
void save_program_status();
void load_program_pid();
void save_program_pid();
void recording_stopped_remove_runtime_files();
void update_ui_recording_started();
void update_ui_recording_stopped();
void on_press_start_replay(const std::string &id);
void on_press_start_record(const std::string &id);
void on_press_start_stream(const std::string &id);
bool update_compositor_texture(const mgl_monitor *monitor);
private:
using KeyBindingCallback = std::function<void()>;
struct KeyBinding {
mgl::Event::KeyEvent key_event;
KeyBindingCallback callback;
};
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;
DropdownButton *replay_dropdown_button_ptr = nullptr;
DropdownButton *record_dropdown_button_ptr = nullptr;
DropdownButton *stream_dropdown_button_ptr = nullptr;
RecordingStatus recording_status = RecordingStatus::NONE;
std::array<KeyBinding, 1> key_bindings;
};
}
|