UI: Add option to snap to vertical/horizontal center

Allows users to snap sources to the horizontal or vertical centers of
the screen.  Off by default.

Closes jp9000/obs-studio#528
This commit is contained in:
Jeremiah Senkpiel
2016-04-06 18:10:39 -07:00
committed by jp9000
parent ad70d023c4
commit 5911b26578
5 changed files with 52 additions and 0 deletions

View File

@@ -268,6 +268,7 @@ OBSBasicSettings::OBSBasicSettings(QWidget *parent)
HookWidget(ui->warnBeforeStreamStop, CHECK_CHANGED, GENERAL_CHANGED);
HookWidget(ui->snappingEnabled, CHECK_CHANGED, GENERAL_CHANGED);
HookWidget(ui->screenSnapping, CHECK_CHANGED, GENERAL_CHANGED);
HookWidget(ui->centerSnapping, CHECK_CHANGED, GENERAL_CHANGED);
HookWidget(ui->snapDistance, SCROLL_CHANGED, GENERAL_CHANGED);
HookWidget(ui->outputMode, COMBO_CHANGED, OUTPUTS_CHANGED);
HookWidget(ui->streamType, COMBO_CHANGED, STREAM1_CHANGED);
@@ -774,6 +775,10 @@ void OBSBasicSettings::LoadGeneralSettings()
"BasicWindow", "ScreenSnapping");
ui->screenSnapping->setChecked(screenSnapping);
bool centerSnapping = config_get_bool(GetGlobalConfig(),
"BasicWindow", "CenterSnapping");
ui->centerSnapping->setChecked(centerSnapping);
double snapDistance = config_get_double(GetGlobalConfig(),
"BasicWindow", "SnapDistance");
ui->snapDistance->setValue(snapDistance);
@@ -2062,6 +2067,10 @@ void OBSBasicSettings::SaveGeneralSettings()
config_set_bool(GetGlobalConfig(), "BasicWindow",
"ScreenSnapping",
ui->screenSnapping->isChecked());
if (WidgetChanged(ui->centerSnapping))
config_set_bool(GetGlobalConfig(), "BasicWindow",
"CenterSnapping",
ui->centerSnapping->isChecked());
if (WidgetChanged(ui->snapDistance))
config_set_double(GetGlobalConfig(), "BasicWindow",
"SnapDistance",