mirror of
https://github.com/obsproject/obs-studio.git
synced 2026-09-19 09:41:32 +08:00
UI: Display aspect ratios in video settings
This commit is contained in:
@@ -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<int, int> 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<int, int> 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<int, int> 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);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user