0
0
mirror of https://github.com/obsproject/obs-studio.git synced 2024-09-20 04:42:18 +02:00

UI: Move multiview setting checks from draw path

This commit is contained in:
Shaolin 2018-03-19 23:27:44 -03:00
parent b8966802ef
commit 5b642c14de
2 changed files with 41 additions and 23 deletions

View File

@ -2719,28 +2719,37 @@ void OBSBasicSettings::SaveGeneralSettings()
main->ResetUI(); main->ResetUI();
} }
if (WidgetChanged(ui->multiviewMouseSwitch)) bool multiviewChanged = false;
if (WidgetChanged(ui->multiviewMouseSwitch)) {
config_set_bool(GetGlobalConfig(), "BasicWindow", config_set_bool(GetGlobalConfig(), "BasicWindow",
"MultiviewMouseSwitch", "MultiviewMouseSwitch",
ui->multiviewMouseSwitch->isChecked()); ui->multiviewMouseSwitch->isChecked());
multiviewChanged = true;
}
if (WidgetChanged(ui->multiviewDrawNames)) if (WidgetChanged(ui->multiviewDrawNames)) {
config_set_bool(GetGlobalConfig(), "BasicWindow", config_set_bool(GetGlobalConfig(), "BasicWindow",
"MultiviewDrawNames", "MultiviewDrawNames",
ui->multiviewDrawNames->isChecked()); ui->multiviewDrawNames->isChecked());
multiviewChanged = true;
}
if (WidgetChanged(ui->multiviewDrawAreas)) if (WidgetChanged(ui->multiviewDrawAreas)) {
config_set_bool(GetGlobalConfig(), "BasicWindow", config_set_bool(GetGlobalConfig(), "BasicWindow",
"MultiviewDrawAreas", "MultiviewDrawAreas",
ui->multiviewDrawAreas->isChecked()); ui->multiviewDrawAreas->isChecked());
multiviewChanged = true;
}
if (WidgetChanged(ui->multiviewLayout)) { if (WidgetChanged(ui->multiviewLayout)) {
config_set_int(GetGlobalConfig(), "BasicWindow", config_set_int(GetGlobalConfig(), "BasicWindow",
"MultiviewLayout", "MultiviewLayout",
ui->multiviewLayout->currentData().toInt()); ui->multiviewLayout->currentData().toInt());
multiviewChanged = true;
OBSProjector::UpdateMultiviewProjectors();
} }
if (multiviewChanged)
OBSProjector::UpdateMultiviewProjectors();
} }
void OBSBasicSettings::SaveStream1Settings() void OBSBasicSettings::SaveStream1Settings()

View File

@ -11,7 +11,8 @@
static QList<OBSProjector *> windowedProjectors; static QList<OBSProjector *> windowedProjectors;
static QList<OBSProjector *> multiviewProjectors; static QList<OBSProjector *> multiviewProjectors;
static bool updatingMultiview = false; static bool updatingMultiview = false, drawLabel, drawSafeArea, mouseSwitching,
transitionOnDoubleClick;
static MultiviewLayout multiviewLayout; static MultiviewLayout multiviewLayout;
OBSProjector::OBSProjector(QWidget *widget, obs_source_t *source_, int monitor, OBSProjector::OBSProjector(QWidget *widget, obs_source_t *source_, int monitor,
@ -473,7 +474,6 @@ void OBSProjector::OBSRenderMultiview(void *data, uint32_t cx, uint32_t cy)
for (size_t i = 0; i < 8; i++) { for (size_t i = 0; i < 8; i++) {
OBSSource src = OBSGetStrongRef(window->multiviewScenes[i]); OBSSource src = OBSGetStrongRef(window->multiviewScenes[i]);
obs_source *label = window->multiviewLabels[i + 2];
// Handle all the offsets // Handle all the offsets
calcBaseSource(i); calcBaseSource(i);
@ -507,8 +507,11 @@ void OBSProjector::OBSRenderMultiview(void *data, uint32_t cx, uint32_t cy)
/* ----------- */ /* ----------- */
// Render the label // Render the label
if (!label || !config_get_bool(GetGlobalConfig(), if (!drawLabel)
"BasicWindow", "MultiviewDrawNames")) continue;
obs_source *label = window->multiviewLabels[i + 2];
if (!label)
continue; continue;
offset = labelOffset(label, quarterCX); offset = labelOffset(label, quarterCX);
@ -550,8 +553,7 @@ void OBSProjector::OBSRenderMultiview(void *data, uint32_t cx, uint32_t cy)
obs_source_video_render(previewSrc); obs_source_video_render(previewSrc);
else else
obs_render_main_texture(); obs_render_main_texture();
if (config_get_bool(GetGlobalConfig(), "BasicWindow", if (drawSafeArea) {
"MultiviewDrawAreas")) {
renderVB(window->actionSafeMargin, targetCX, targetCY, renderVB(window->actionSafeMargin, targetCX, targetCY,
outerColor); outerColor);
renderVB(window->graphicsSafeMargin, targetCX, targetCY, renderVB(window->graphicsSafeMargin, targetCX, targetCY,
@ -568,8 +570,7 @@ void OBSProjector::OBSRenderMultiview(void *data, uint32_t cx, uint32_t cy)
/* ----------- */ /* ----------- */
// Draw the Label // Draw the Label
if (config_get_bool(GetGlobalConfig(), "BasicWindow", if (drawLabel) {
"MultiviewDrawNames")) {
gs_matrix_push(); gs_matrix_push();
gs_matrix_translate3f(labelX, labelY, 0.0f); gs_matrix_translate3f(labelX, labelY, 0.0f);
gs_matrix_scale3f(hiScaleX, hiScaleY, 1.0f); gs_matrix_scale3f(hiScaleX, hiScaleY, 1.0f);
@ -599,8 +600,7 @@ void OBSProjector::OBSRenderMultiview(void *data, uint32_t cx, uint32_t cy)
/* ----------- */ /* ----------- */
// Draw the Label // Draw the Label
if (config_get_bool(GetGlobalConfig(), "BasicWindow", if (drawLabel) {
"MultiviewDrawNames")) {
gs_matrix_push(); gs_matrix_push();
gs_matrix_translate3f(labelX, labelY, 0.0f); gs_matrix_translate3f(labelX, labelY, 0.0f);
gs_matrix_scale3f(hiScaleX, hiScaleY, 1.0f); gs_matrix_scale3f(hiScaleX, hiScaleY, 1.0f);
@ -778,12 +778,10 @@ void OBSProjector::mouseDoubleClickEvent(QMouseEvent *event)
{ {
OBSQTDisplay::mouseDoubleClickEvent(event); OBSQTDisplay::mouseDoubleClickEvent(event);
if (!config_get_bool(GetGlobalConfig(), "BasicWindow", if (!mouseSwitching)
"MultiviewMouseSwitch"))
return; return;
if (!config_get_bool(GetGlobalConfig(), "BasicWindow", if (!transitionOnDoubleClick)
"TransitionOnDoubleClick"))
return; return;
OBSBasic *main = (OBSBasic*)obs_frontend_get_main_window(); OBSBasic *main = (OBSBasic*)obs_frontend_get_main_window();
@ -813,11 +811,10 @@ void OBSProjector::mousePressEvent(QMouseEvent *event)
popup.exec(QCursor::pos()); popup.exec(QCursor::pos());
} }
if (event->button() == Qt::LeftButton) { if (!mouseSwitching)
if (!config_get_bool(GetGlobalConfig(), "BasicWindow", return;
"MultiviewMouseSwitch"))
return;
if (event->button() == Qt::LeftButton) {
int pos = getSourceByPosition(event->x(), event->y()); int pos = getSourceByPosition(event->x(), event->y());
if (pos < 0) if (pos < 0)
return; return;
@ -882,6 +879,18 @@ void OBSProjector::UpdateMultiview()
multiviewLayout = static_cast<MultiviewLayout>(config_get_int( multiviewLayout = static_cast<MultiviewLayout>(config_get_int(
GetGlobalConfig(), "BasicWindow", "MultiviewLayout")); GetGlobalConfig(), "BasicWindow", "MultiviewLayout"));
drawLabel = config_get_bool(GetGlobalConfig(),
"BasicWindow", "MultiviewDrawNames");
drawSafeArea = config_get_bool(GetGlobalConfig(), "BasicWindow",
"MultiviewDrawAreas");
mouseSwitching = config_get_bool(GetGlobalConfig(), "BasicWindow",
"MultiviewMouseSwitch");
transitionOnDoubleClick = config_get_bool(GetGlobalConfig(),
"BasicWindow", "TransitionOnDoubleClick");
} }
void OBSProjector::UpdateProjectorTitle(QString name) void OBSProjector::UpdateProjectorTitle(QString name)