-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathui.hpp
More file actions
119 lines (101 loc) · 2.85 KB
/
ui.hpp
File metadata and controls
119 lines (101 loc) · 2.85 KB
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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
#pragma once
#include "connection.hpp"
#include "video.hpp"
#include <FL/Fl.H>
#include <FL/Fl_Check_Button.H>
#include <FL/Fl_Double_Window.H>
#include <FL/Fl_Flex.H>
#include <FL/Fl_Hold_Browser.H>
#include <FL/Fl_Input.H>
#include <FL/Fl_Menu_Bar.H>
#include <FL/Fl_Secret_Input.H>
#include <FL/Fl_Spinner.H>
#include <FL/Fl_Tile.H>
#include <memory>
#include <string>
#include <vector>
inline bool is_key_global_shortcut(int key) {
switch (key) {
case FL_F + 5:
case FL_F + 9:
case FL_F + 11:
return true;
default:
return false;
}
}
class Stage : public Fl_Group {
protected:
Fl_Widget* centered = nullptr;
bool fill = false;
public:
Stage(int x, int y, int width, int height, const char* label = nullptr):
Fl_Group(x, y, width, height, label) {
align(FL_ALIGN_INSIDE | FL_ALIGN_CENTER);
labelsize(18);
resizable(this);
}
Fl_Widget* get_centered() const {
return centered;
}
bool get_fill() const {
return fill;
}
void set_centered(Fl_Widget* widget);
void set_fill(bool fill);
void resize(int x, int y, int width, int height) override;
void draw() override;
};
class ConnectionEditor : public Fl_Flex {
protected:
Fl_Input* name_input;
Fl_Input* address_input;
Fl_Secret_Input* password_input;
Fl_Spinner* bitrate_spinner;
Fl_Check_Button* client_side_mouse_check_button;
Fl_Check_Button* view_only_check_button;
Fl_Check_Button* verify_certs_check_button;
public:
ConnectionEditor(int x, int y, int width, int height, const std::string& name = {}, const ConnectionInfo& connection = {}, bool show_connect_button = false);
std::string name() const {
return name_input->value();
}
ConnectionInfo to_conn_info() const {
return {
address_input->value(),
password_input->value(),
(unsigned int) bitrate_spinner->value(),
(bool) client_side_mouse_check_button->value(),
(bool) view_only_check_button->value(),
(bool) verify_certs_check_button->value(),
};
}
};
class MainWindow : public Fl_Double_Window {
public:
MainWindow();
~MainWindow() {
if (!conn_list->parent()) {
delete conn_list;
}
}
int handle(int event) override;
void hide() override;
protected:
Fl_Flex* column;
Fl_Menu_Bar* menu_bar;
Fl_Tile* tile;
Fl_Hold_Browser* conn_list;
Stage* stage;
ConnectionEditor* conn_editor = nullptr;
VideoWindow* video_window = nullptr;
std::vector<std::unique_ptr<ConnectionInfo>> connections;
void refresh();
void handle_select_conn();
void handle_new_conn();
void handle_upload();
void handle_download();
void handle_set_bitrate();
void handle_toggle_fullscreen();
static void check_ice_state(void* data);
};