0
0
mirror of https://github.com/obsproject/obs-studio.git synced 2024-09-19 20:32:15 +02:00

UI: Add Crop to Bounds checkbox to transform dialog

This commit is contained in:
derrod 2023-11-18 12:41:54 +01:00 committed by Lain
parent 7e456d9dea
commit 09024e9c74
3 changed files with 18 additions and 2 deletions

View File

@ -684,6 +684,7 @@ Basic.TransformWindow.BoundsAlignment="Alignment in Bounding Box"
Basic.TransformWindow.Bounds="Bounding Box Size"
Basic.TransformWindow.BoundsWidth="Bounding Box Width"
Basic.TransformWindow.BoundsHeight="Bounding Box Height"
Basic.TransformWindow.CropToBounds="Crop to Bounding Box"
Basic.TransformWindow.Crop="Crop"
Basic.TransformWindow.CropLeft="Crop Left"
Basic.TransformWindow.CropRight="Crop Right"

View File

@ -602,6 +602,16 @@
</widget>
</item>
<item row="8" column="1">
<widget class="QCheckBox" name="cropToBounds">
<property name="accessibleName">
<string>Basic.TransformWindow.BoundsAlignment</string>
</property>
<property name="text">
<string>Basic.TransformWindow.CropToBounds</string>
</property>
</widget>
</item>
<item row="9" column="1">
<spacer name="verticalSpacer_2">
<property name="orientation">
<enum>Qt::Vertical</enum>
@ -614,7 +624,7 @@
</property>
</spacer>
</item>
<item row="9" column="0">
<item row="10" column="0">
<widget class="QLabel" name="label_8">
<property name="accessibleName">
<string>Basic.TransformWindow.Crop</string>
@ -624,7 +634,7 @@
</property>
</widget>
</item>
<item row="9" column="1">
<item row="10" column="1">
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="1">
<widget class="QSpinBox" name="cropLeft">

View File

@ -71,6 +71,8 @@ OBSBasicTransform::OBSBasicTransform(OBSSceneItem item, OBSBasic *parent)
&OBSBasicTransform::OnCropChanged);
HookWidget(ui->cropBottom, ISCROLL_CHANGED,
&OBSBasicTransform::OnCropChanged);
HookWidget(ui->cropToBounds, &QCheckBox::stateChanged,
&OBSBasicTransform::OnControlChanged);
ui->buttonBox->button(QDialogButtonBox::Close)->setDefault(true);
@ -297,6 +299,7 @@ void OBSBasicTransform::RefreshControls()
ui->boundsAlign->setCurrentIndex(boundsAlignIndex);
ui->boundsWidth->setValue(osi.bounds.x);
ui->boundsHeight->setValue(osi.bounds.y);
ui->cropToBounds->setChecked(osi.crop_to_bounds);
ui->cropLeft->setValue(int(crop.left));
ui->cropRight->setValue(int(crop.right));
@ -319,6 +322,7 @@ void OBSBasicTransform::OnBoundsType(int index)
ui->boundsAlign->setEnabled(enable);
ui->boundsWidth->setEnabled(enable);
ui->boundsHeight->setEnabled(enable);
ui->cropToBounds->setEnabled(enable);
if (!ignoreItemChange) {
obs_bounds_type lastType = obs_sceneitem_get_bounds_type(item);
@ -364,6 +368,7 @@ void OBSBasicTransform::OnControlChanged()
oti.bounds_alignment = listToAlign[ui->boundsAlign->currentIndex()];
oti.bounds.x = float(ui->boundsWidth->value());
oti.bounds.y = float(ui->boundsHeight->value());
oti.crop_to_bounds = ui->cropToBounds->isChecked();
ignoreTransformSignal = true;
obs_sceneitem_set_info(item, &oti);