FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
obs-studio-ftl/UI/window-projector.cpp at develop · mixer/obs-studio-ftl · GitHub
This repository was archived by the owner on Jul 21, 2020. It is now read-only.
mixer
/
obs-studio-ftl
Public archive
forked from
obsproject/obs-studio
Notifications
You must be signed in to change notification settings
Fork
12
Star
95
Code
Issues
6
Pull requests
0
Actions
Wiki
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Wiki
Security and quality
Insights
Expand file tree
Breadcrumbs
obs-studio-ftl
/
UI
/
window-projector.cpp
Copy path
More file actions
More file actions
Latest commit
History
History
History
159 lines (126 loc) · 3.69 KB
Breadcrumbs
obs-studio-ftl
/
UI
/
window-projector.cpp
Copy path
File metadata and controls
159 lines (126 loc) · 3.69 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
#
include
<
QAction
>
#
include
<
QGuiApplication
>
#
include
<
QMouseEvent
>
#
include
<
QMenu
>
#
include
<
QScreen
>
#
include
"
window-projector.hpp
"
#
include
"
display-helpers.hpp
"
#
include
"
qt-wrappers.hpp
"
#
include
"
platform.hpp
"
#
include
"
obs-app.hpp
"
OBSProjector::OBSProjector
(QWidget *widget,
obs_source_t
*source_,
bool
window)
: OBSQTDisplay (widget,
Qt::Window),
source (source_),
removedSignal (obs_source_get_signal_handler(source),
"remove", OBSSourceRemoved, this)
{
if
(!window) {
setWindowFlags
(Qt::FramelessWindowHint |
Qt::X11BypassWindowManagerHint);
}
setAttribute
(Qt::WA_DeleteOnClose,
true
);
//
disable application quit when last window closed
setAttribute
(Qt::WA_QuitOnClose,
false
);
installEventFilter
(
CreateShortcutFilter
());
auto
addDrawCallback = [
this
] ()
{
obs_display_add_draw_callback
(
GetDisplay
(), OBSRender,
this
);
obs_display_set_background_color
(
GetDisplay
(),
0x000000
);
};
connect
(
this
, &OBSQTDisplay::DisplayCreated, addDrawCallback);
bool
hideCursor =
config_get_bool
(
GetGlobalConfig
(),
"
BasicWindow
"
,
"
HideProjectorCursor
"
);
if
(hideCursor && !window) {
QPixmap
empty
(
16
,
16
);
empty.
fill
(Qt::transparent);
setCursor
(
QCursor
(empty));
}
App
()->
IncrementSleepInhibition
();
resize
(
480
,
270
);
}
OBSProjector::~OBSProjector
()
{
if
(source)
obs_source_dec_showing
(source);
App
()->
DecrementSleepInhibition
();
}
void
OBSProjector::Init
(
int
monitor,
bool
window, QString title)
{
QScreen *screen =
QGuiApplication::screens
()[monitor];
if
(!window)
setGeometry
(screen->
geometry
());
bool
alwaysOnTop =
config_get_bool
(
GetGlobalConfig
(),
"
BasicWindow
"
,
"
ProjectorAlwaysOnTop
"
);
if
(alwaysOnTop && !window)
SetAlwaysOnTop
(
this
,
true
);
if
(window)
setWindowTitle
(title);
show
();
if
(source)
obs_source_inc_showing
(source);
if
(!window) {
QAction *action =
new
QAction
(
this
);
action->
setShortcut
(Qt::Key_Escape);
addAction
(action);
connect
(action,
SIGNAL
(
triggered
()),
this
,
SLOT
(
EscapeTriggered
()));
}
savedMonitor = monitor;
isWindow = window;
}
void
OBSProjector::OBSRender
(
void
*data,
uint32_t
cx,
uint32_t
cy)
{
OBSProjector *window =
reinterpret_cast
<OBSProjector*>(data);
uint32_t
targetCX;
uint32_t
targetCY;
int
x, y;
int
newCX, newCY;
float
scale;
if
(window->
source
) {
targetCX =
std::max
(
obs_source_get_width
(window->
source
),
1u
);
targetCY =
std::max
(
obs_source_get_height
(window->
source
),
1u
);
}
else
{
struct
obs_video_info
ovi;
obs_get_video_info
(&ovi);
targetCX = ovi.
base_width
;
targetCY = ovi.
base_height
;
}
GetScaleAndCenterPos
(targetCX, targetCY, cx, cy, x, y, scale);
newCX =
int
(scale *
float
(targetCX));
newCY =
int
(scale *
float
(targetCY));
gs_viewport_push
();
gs_projection_push
();
gs_ortho
(
0
.
0f
,
float
(targetCX),
0
.
0f
,
float
(targetCY), -
100
.
0f
,
100
.
0f
);
gs_set_viewport
(x, y, newCX, newCY);
if
(window->
source
)
obs_source_video_render
(window->
source
);
else
obs_render_main_view
();
gs_projection_pop
();
gs_viewport_pop
();
}
void
OBSProjector::OBSSourceRemoved
(
void
*data,
calldata_t
*params)
{
OBSProjector *window =
reinterpret_cast
<OBSProjector*>(data);
window->
deleteLater
();
UNUSED_PARAMETER
(params);
}
void
OBSProjector::mousePressEvent
(QMouseEvent *event)
{
OBSQTDisplay::mousePressEvent
(event);
if
(event->
button
() == Qt::RightButton) {
QMenu
popup
(
this
);
popup.
addAction
(
QTStr
(
"
Close
"
),
this
,
SLOT
(
EscapeTriggered
()));
popup.
exec
(
QCursor::pos
());
}
}
void
OBSProjector::EscapeTriggered
()
{
if
(!isWindow) {
OBSBasic *main =
reinterpret_cast
<OBSBasic*>(
App
()->
GetMainWindow
());
main->
RemoveSavedProjectors
(savedMonitor);
}
deleteLater
();
}
Back
|
FazBrowse Home
|
New Git URL