diff --git a/UI/data/locale/en-US.ini b/UI/data/locale/en-US.ini index 2a08ca869256baabb70ebe1763d8b70491a9977b..b62fdf06568c461e21a0cf68e0af5e5be31ce86f 100644 --- a/UI/data/locale/en-US.ini +++ b/UI/data/locale/en-US.ini @@ -92,6 +92,7 @@ Calculating="Calculating..." Fullscreen="Fullscreen" Windowed="Windowed" Percent="Percent" +AspectRatio="Aspect Ratio %1:%2" # warning if program already open AlreadyRunning.Title="OBS is already running" diff --git a/UI/forms/OBSBasicSettings.ui b/UI/forms/OBSBasicSettings.ui index a5e03b6840269e5210513e3695554773d99977b9..e5cabc0442413994e72302d3db6e2728e53d79ec 100644 --- a/UI/forms/OBSBasicSettings.ui +++ b/UI/forms/OBSBasicSettings.ui @@ -7,7 +7,7 @@ 0 0 981 - 748 + 726 @@ -28,7 +28,7 @@ - + @@ -151,8 +151,8 @@ 0 0 - 803 - 977 + 806 + 1254 @@ -1206,8 +1206,8 @@ 0 0 - 601 - 631 + 813 + 761 @@ -2345,8 +2345,8 @@ 9 0 - 221 - 21 + 236 + 25 @@ -3715,8 +3715,8 @@ 0 0 - 555 - 469 + 767 + 582 @@ -4200,22 +4200,42 @@ - - - true - - - - - - false - - - true + + + 6 - + + + + + 0 + 0 + + + + true + + + + + + false + + + true + + + + + + + AspectRatio + + + + - + Basic.Settings.Video.ScaledResolution @@ -4225,17 +4245,7 @@ - - - - true - - - - - - - + Basic.Settings.Video.DownscaleFilter @@ -4245,14 +4255,14 @@ - + true - + @@ -4283,7 +4293,7 @@ - + 1 @@ -4454,7 +4464,7 @@ - + @@ -4473,6 +4483,36 @@ + + + + 6 + + + + + + 0 + 0 + + + + true + + + + + + + + + + AspectRatio + + + + + @@ -4531,8 +4571,8 @@ 0 0 - 803 - 781 + 791 + 970 @@ -5485,8 +5525,6 @@ peakMeterType monitoringDevice disableAudioDucking - baseResolution - outputResolution downscaleFilter fpsType fpsCommon diff --git a/UI/window-basic-settings.cpp b/UI/window-basic-settings.cpp index 3809becb7af3ad05f6bbb8a1049799673677f155..d688336386ca850ffb9e09f7624c370b28eb1b29 100644 --- a/UI/window-basic-settings.cpp +++ b/UI/window-basic-settings.cpp @@ -760,6 +760,8 @@ OBSBasicSettings::OBSBasicSettings(QWidget *parent) UpdateAutomaticReplayBufferCheckboxes(); + on_baseResolution_editTextChanged(ui->baseResolution->currentText()); + App()->DisableHotkeys(); } @@ -1315,10 +1317,13 @@ void OBSBasicSettings::ResetDownscales(uint32_t cx, uint32_t cy) float outputAspect = float(out_cx) / float(out_cy); bool closeAspect = close_float(baseAspect, outputAspect, 0.01f); - if (closeAspect) + if (closeAspect) { ui->outputResolution->lineEdit()->setText(oldOutputRes); - else + on_outputResolution_editTextChanged(oldOutputRes); + } else { ui->outputResolution->lineEdit()->setText(bestScale.c_str()); + on_outputResolution_editTextChanged(bestScale.c_str()); + } ui->outputResolution->blockSignals(false); @@ -3745,6 +3750,25 @@ static bool ValidResolutions(Ui::OBSBasicSettings *ui) return true; } +static int gcd(int a, int b) +{ + return b == 0 ? a : gcd(b, a % b); +} + +static std::tuple aspect_ratio(int cx, int cy) +{ + int common = gcd(cx, cy); + int newCX = cx / common; + int newCY = cy / common; + + if (newCX == 8 && newCY == 5) { + newCX = 16; + newCY = 10; + } + + return std::make_tuple(newCX, newCY); +} + void OBSBasicSettings::RecalcOutputResPixels(const char *resText) { uint32_t newCX; @@ -3754,6 +3778,13 @@ void OBSBasicSettings::RecalcOutputResPixels(const char *resText) if (newCX && newCY) { outputCX = newCX; outputCY = newCY; + + std::tuple aspect = aspect_ratio(outputCX, outputCY); + + ui->scaledAspect->setText( + QTStr("AspectRatio") + .arg(QString::number(std::get<0>(aspect)), + QString::number(std::get<1>(aspect)))); } } @@ -3785,6 +3816,14 @@ void OBSBasicSettings::on_baseResolution_editTextChanged(const QString &text) uint32_t cx, cy; ConvertResText(QT_TO_UTF8(baseResolution), cx, cy); + + std::tuple aspect = aspect_ratio(cx, cy); + + ui->baseAspect->setText( + QTStr("AspectRatio") + .arg(QString::number(std::get<0>(aspect)), + QString::number(std::get<1>(aspect)))); + ResetDownscales(cx, cy); } }