From 4649783b1e89c1b8be434b373ef76b4aab52e1c7 Mon Sep 17 00:00:00 2001 From: Shaolin Date: Fri, 16 Mar 2018 23:00:32 -0300 Subject: [PATCH] UI: Add option to toggle multiview scene names --- UI/data/locale/en-US.ini | 1 + UI/forms/OBSBasicSettings.ui | 12 ++++++++++- UI/obs-app.cpp | 3 +++ UI/window-basic-settings.cpp | 10 +++++++++ UI/window-projector.cpp | 42 +++++++++++++++++++++--------------- 5 files changed, 50 insertions(+), 18 deletions(-) diff --git a/UI/data/locale/en-US.ini b/UI/data/locale/en-US.ini index 10f0bd03f..b46f1e686 100644 --- a/UI/data/locale/en-US.ini +++ b/UI/data/locale/en-US.ini @@ -573,6 +573,7 @@ Basic.Settings.General.SwitchOnDoubleClick="Transition to scene when double-clic Basic.Settings.General.StudioPortraitLayout="Enable portrait/vertical layout" Basic.Settings.General.Multiview="Multiview" Basic.Settings.General.Multiview.MouseSwitch="Click to switch between scenes" +Basic.Settings.General.Multiview.DrawSourceNames="Show scene names" Basic.Settings.General.MultiviewLayout="Multiview Layout" Basic.Settings.General.MultiviewLayout.Horizontal.Top="Horizontal, Top (8 Scenes)" Basic.Settings.General.MultiviewLayout.Horizontal.Bottom="Horizontal, Bottom (8 Scenes)" diff --git a/UI/forms/OBSBasicSettings.ui b/UI/forms/OBSBasicSettings.ui index 1406b29b9..6fbfe2a5f 100644 --- a/UI/forms/OBSBasicSettings.ui +++ b/UI/forms/OBSBasicSettings.ui @@ -627,9 +627,19 @@ + + + Basic.Settings.General.Multiview.DrawSourceNames + + + true + + + + - + Basic.Settings.General.MultiviewLayout diff --git a/UI/obs-app.cpp b/UI/obs-app.cpp index 5a318e0c3..22e6088b0 100644 --- a/UI/obs-app.cpp +++ b/UI/obs-app.cpp @@ -424,6 +424,9 @@ bool OBSApp::InitGlobalConfigDefaults() config_set_default_bool(globalConfig, "BasicWindow", "MultiviewMouseSwitch", true); + config_set_default_bool(globalConfig, "BasicWindow", + "MultiviewDrawNames", true); + #ifdef _WIN32 config_set_default_bool(globalConfig, "Audio", "DisableAudioDucking", true); diff --git a/UI/window-basic-settings.cpp b/UI/window-basic-settings.cpp index 506e74be0..639df4ae9 100644 --- a/UI/window-basic-settings.cpp +++ b/UI/window-basic-settings.cpp @@ -319,6 +319,7 @@ OBSBasicSettings::OBSBasicSettings(QWidget *parent) HookWidget(ui->doubleClickSwitch, CHECK_CHANGED, GENERAL_CHANGED); HookWidget(ui->studioPortraitLayout, CHECK_CHANGED, GENERAL_CHANGED); HookWidget(ui->multiviewMouseSwitch, CHECK_CHANGED, GENERAL_CHANGED); + HookWidget(ui->multiviewDrawNames, CHECK_CHANGED, GENERAL_CHANGED); HookWidget(ui->multiviewLayout, COMBO_CHANGED, GENERAL_CHANGED); HookWidget(ui->outputMode, COMBO_CHANGED, OUTPUTS_CHANGED); HookWidget(ui->streamType, COMBO_CHANGED, STREAM1_CHANGED); @@ -1105,6 +1106,10 @@ void OBSBasicSettings::LoadGeneralSettings() "BasicWindow", "MultiviewMouseSwitch"); ui->multiviewMouseSwitch->setChecked(multiviewMouseSwitch); + bool multiviewDrawNames = config_get_bool(GetGlobalConfig(), + "BasicWindow", "MultiviewDrawNames"); + ui->multiviewDrawNames->setChecked(multiviewDrawNames); + ui->multiviewLayout->addItem(QTStr( "Basic.Settings.General.MultiviewLayout.Horizontal.Top"), static_cast(MultiviewLayout::HORIZONTAL_TOP_8_SCENES)); @@ -2714,6 +2719,11 @@ void OBSBasicSettings::SaveGeneralSettings() "MultiviewMouseSwitch", ui->multiviewMouseSwitch->isChecked()); + if (WidgetChanged(ui->multiviewDrawNames)) + config_set_bool(GetGlobalConfig(), "BasicWindow", + "MultiviewDrawNames", + ui->multiviewDrawNames->isChecked()); + if (WidgetChanged(ui->multiviewLayout)) { config_set_int(GetGlobalConfig(), "BasicWindow", "MultiviewLayout", diff --git a/UI/window-projector.cpp b/UI/window-projector.cpp index 9c3fad50f..94b89aa1e 100644 --- a/UI/window-projector.cpp +++ b/UI/window-projector.cpp @@ -494,7 +494,8 @@ void OBSProjector::OBSRenderMultiview(void *data, uint32_t cx, uint32_t cy) /* ----------- */ // Render the label - if (!label) + if (!label || !config_get_bool(GetGlobalConfig(), + "BasicWindow", "MultiviewDrawNames")) continue; offset = labelOffset(label, quarterCX); @@ -548,14 +549,17 @@ void OBSProjector::OBSRenderMultiview(void *data, uint32_t cx, uint32_t cy) /* ----------- */ // Draw the Label - gs_matrix_push(); - gs_matrix_translate3f(labelX, labelY, 0.0f); - gs_matrix_scale3f(hiScaleX, hiScaleY, 1.0f); - drawBox(obs_source_get_width(previewLabel), - obs_source_get_height(previewLabel) + - int(halfCX * 0.015f), labelColor); - obs_source_video_render(previewLabel); - gs_matrix_pop(); + if (config_get_bool(GetGlobalConfig(), "BasicWindow", + "MultiviewDrawNames")) { + gs_matrix_push(); + gs_matrix_translate3f(labelX, labelY, 0.0f); + gs_matrix_scale3f(hiScaleX, hiScaleY, 1.0f); + drawBox(obs_source_get_width(previewLabel), + obs_source_get_height(previewLabel) + + int(halfCX * 0.015f), labelColor); + obs_source_video_render(previewLabel); + gs_matrix_pop(); + } /* ----------------------------- */ /* draw program */ @@ -576,14 +580,18 @@ void OBSProjector::OBSRenderMultiview(void *data, uint32_t cx, uint32_t cy) /* ----------- */ // Draw the Label - gs_matrix_push(); - gs_matrix_translate3f(labelX, labelY, 0.0f); - gs_matrix_scale3f(hiScaleX, hiScaleY, 1.0f); - drawBox(obs_source_get_width(programLabel), - obs_source_get_height(programLabel) + - int(halfCX * 0.015f), labelColor); - obs_source_video_render(programLabel); - gs_matrix_pop(); + if (config_get_bool(GetGlobalConfig(), "BasicWindow", + "MultiviewDrawNames")) { + gs_matrix_push(); + gs_matrix_translate3f(labelX, labelY, 0.0f); + gs_matrix_scale3f(hiScaleX, hiScaleY, 1.0f); + drawBox(obs_source_get_width(programLabel), + obs_source_get_height(programLabel) + + int(halfCX * 0.015f), labelColor); + obs_source_video_render(programLabel); + gs_matrix_pop(); + } + endRegion(); } -- GitLab