From 7f9109091d5bf60b4e5b34ea985c320690149613 Mon Sep 17 00:00:00 2001 From: cg2121 Date: Wed, 29 Aug 2018 17:45:59 -0500 Subject: [PATCH] UI: Add ability to resize output based on source size --- UI/data/locale/en-US.ini | 5 +++++ UI/window-basic-main.cpp | 48 ++++++++++++++++++++++++++++++++++++++++ UI/window-basic-main.hpp | 2 ++ 3 files changed, 55 insertions(+) diff --git a/UI/data/locale/en-US.ini b/UI/data/locale/en-US.ini index a156eb02d..e22375bb9 100644 --- a/UI/data/locale/en-US.ini +++ b/UI/data/locale/en-US.ini @@ -865,3 +865,8 @@ About.GetInvolved="Get Involved" About.Authors="Authors" About.License="License" About.Contribute="Want to contribute?" + +# Dynamic output size +ResizeOutputSizeOfSource="Resize output (source size)" +ResizeOutputSizeOfSource.Text="The base and canvas resolution will be resized to the size of the current source." +ResizeOutputSizeOfSource.Continue="Do you want to continue?" diff --git a/UI/window-basic-main.cpp b/UI/window-basic-main.cpp index 4f8c9773c..7942af880 100644 --- a/UI/window-basic-main.cpp +++ b/UI/window-basic-main.cpp @@ -4227,6 +4227,21 @@ void OBSBasic::CreateSourcePopupMenu(int idx, bool preview) popup.addSeparator(); } + QAction *resizeOutput = popup.addAction( + QTStr("ResizeOutputSizeOfSource"), this, + SLOT(ResizeOutputSizeOfSource())); + + int width = obs_source_get_width(source); + int height = obs_source_get_height(source); + + resizeOutput->setEnabled(!(ui->streamButton->isChecked() || + ui->recordButton->isChecked() || + (replayBufferButton && + replayBufferButton->isChecked()))); + + if (width == 0 || height == 0) + resizeOutput->setEnabled(false); + popup.addMenu(AddScaleFilteringMenu(sceneItem)); popup.addSeparator(); @@ -6733,6 +6748,39 @@ void OBSBasic::on_actionShowAbout_triggered() about->setAttribute(Qt::WA_DeleteOnClose, true); } +void OBSBasic::ResizeOutputSizeOfSource() +{ + if (ui->streamButton->isChecked() || ui->recordButton->isChecked() || + (replayBufferButton && replayBufferButton->isChecked())) + return; + + QMessageBox resize_output(this); + resize_output.setText(QTStr("ResizeOutputSizeOfSource.Text") + + "\n\n" + QTStr("ResizeOutputSizeOfSource.Continue")); + QAbstractButton *Yes = resize_output.addButton(QTStr("Yes"), + QMessageBox::YesRole); + resize_output.addButton(QTStr("No"), QMessageBox::NoRole); + resize_output.setIcon(QMessageBox::Warning); + resize_output.setWindowTitle(QTStr("ResizeOutputSizeOfSource")); + resize_output.exec(); + + if (resize_output.clickedButton() != Yes) + return; + + OBSSource source = obs_sceneitem_get_source(GetCurrentSceneItem()); + + int width = obs_source_get_width(source); + int height = obs_source_get_height(source); + + config_set_uint(basicConfig, "Video", "BaseCX", width); + config_set_uint(basicConfig, "Video", "BaseCY", height); + config_set_uint(basicConfig, "Video", "OutputCX", width); + config_set_uint(basicConfig, "Video", "OutputCY", height); + + ResetVideo(); + on_actionFitToScreen_triggered(); +} + ColorSelect::ColorSelect(QWidget *parent) : QWidget(parent), ui(new Ui::ColorSelect) diff --git a/UI/window-basic-main.hpp b/UI/window-basic-main.hpp index 4bce5e886..58ca98cc5 100644 --- a/UI/window-basic-main.hpp +++ b/UI/window-basic-main.hpp @@ -742,6 +742,8 @@ private slots: void StackedMixerAreaContextMenuRequested(); + void ResizeOutputSizeOfSource(); + public slots: void on_actionResetTransform_triggered(); -- GitLab