UI: Add crop options to scene item transform dialog

This commit is contained in:
jp9000 2016-03-30 18:45:34 -07:00
parent 02661843de
commit 02806a71f8
3 changed files with 258 additions and 64 deletions

View File

@ -275,6 +275,19 @@
</item>
</widget>
</item>
<item row="4" column="1">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>10</width>
<height>10</height>
</size>
</property>
</spacer>
</item>
<item row="5" column="0">
<widget class="QLabel" name="label_5">
<property name="text">
@ -321,19 +334,6 @@
</item>
</widget>
</item>
<item row="4" column="1">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="6" column="0">
<widget class="QLabel" name="label_6">
<property name="text">
@ -341,6 +341,61 @@
</property>
</widget>
</item>
<item row="6" column="1">
<widget class="QComboBox" name="boundsAlign">
<property name="enabled">
<bool>false</bool>
</property>
<property name="currentText">
<string>Basic.TransformWindow.Alignment.TopLeft</string>
</property>
<item>
<property name="text">
<string>Basic.TransformWindow.Alignment.TopLeft</string>
</property>
</item>
<item>
<property name="text">
<string>Basic.TransformWindow.Alignment.TopCenter</string>
</property>
</item>
<item>
<property name="text">
<string>Basic.TransformWindow.Alignment.TopRight</string>
</property>
</item>
<item>
<property name="text">
<string>Basic.TransformWindow.Alignment.CenterLeft</string>
</property>
</item>
<item>
<property name="text">
<string>Basic.TransformWindow.Alignment.Center</string>
</property>
</item>
<item>
<property name="text">
<string>Basic.TransformWindow.Alignment.CenterRight</string>
</property>
</item>
<item>
<property name="text">
<string>Basic.TransformWindow.Alignment.BottomLeft</string>
</property>
</item>
<item>
<property name="text">
<string>Basic.TransformWindow.Alignment.BottomCenter</string>
</property>
</item>
<item>
<property name="text">
<string>Basic.TransformWindow.Alignment.BottomRight</string>
</property>
</item>
</widget>
</item>
<item row="7" column="0">
<widget class="QLabel" name="label_7">
<property name="text">
@ -416,61 +471,171 @@
</layout>
</widget>
</item>
<item row="6" column="1">
<widget class="QComboBox" name="boundsAlign">
<property name="enabled">
<bool>false</bool>
<item row="8" column="1">
<spacer name="verticalSpacer_2">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="currentText">
<string>Basic.TransformWindow.Alignment.TopLeft</string>
<property name="sizeHint" stdset="0">
<size>
<width>10</width>
<height>10</height>
</size>
</property>
</spacer>
</item>
<item row="9" column="0">
<widget class="QLabel" name="label_8">
<property name="text">
<string>Basic.TransformWindow.Crop</string>
</property>
<item>
<property name="text">
<string>Basic.TransformWindow.Alignment.TopLeft</string>
</property>
</item>
<item>
<property name="text">
<string>Basic.TransformWindow.Alignment.TopCenter</string>
</property>
</item>
<item>
<property name="text">
<string>Basic.TransformWindow.Alignment.TopRight</string>
</property>
</item>
<item>
<property name="text">
<string>Basic.TransformWindow.Alignment.CenterLeft</string>
</property>
</item>
<item>
<property name="text">
<string>Basic.TransformWindow.Alignment.Center</string>
</property>
</item>
<item>
<property name="text">
<string>Basic.TransformWindow.Alignment.CenterRight</string>
</property>
</item>
<item>
<property name="text">
<string>Basic.TransformWindow.Alignment.BottomLeft</string>
</property>
</item>
<item>
<property name="text">
<string>Basic.TransformWindow.Alignment.BottomCenter</string>
</property>
</item>
<item>
<property name="text">
<string>Basic.TransformWindow.Alignment.BottomRight</string>
</property>
</item>
</widget>
</item>
<item row="9" column="1">
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="3">
<widget class="QSpinBox" name="cropRight">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>70</width>
<height>0</height>
</size>
</property>
<property name="maximum">
<number>100000</number>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label_9">
<property name="text">
<string>Left</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="buddy">
<cstring>cropLeft</cstring>
</property>
</widget>
</item>
<item row="1" column="2">
<widget class="QLabel" name="label_12">
<property name="text">
<string>Bottom</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="buddy">
<cstring>cropBottom</cstring>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QSpinBox" name="cropTop">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>70</width>
<height>0</height>
</size>
</property>
<property name="maximum">
<number>100000</number>
</property>
</widget>
</item>
<item row="1" column="3">
<widget class="QSpinBox" name="cropBottom">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>70</width>
<height>0</height>
</size>
</property>
<property name="maximum">
<number>100000</number>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_11">
<property name="text">
<string>Top</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="buddy">
<cstring>cropTop</cstring>
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="QLabel" name="label_10">
<property name="text">
<string>Right</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="buddy">
<cstring>cropRight</cstring>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QSpinBox" name="cropLeft">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>70</width>
<height>0</height>
</size>
</property>
<property name="maximum">
<number>100000</number>
</property>
</widget>
</item>
<item row="0" column="4">
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
</layout>
</item>
</layout>

View File

@ -30,6 +30,7 @@ void OBSBasicTransform::HookWidget(QWidget *widget, const char *signal,
}
#define COMBO_CHANGED SIGNAL(currentIndexChanged(int))
#define ISCROLL_CHANGED SIGNAL(valueChanged(int))
#define DSCROLL_CHANGED SIGNAL(valueChanged(double))
OBSBasicTransform::OBSBasicTransform(OBSBasic *parent)
@ -49,6 +50,10 @@ OBSBasicTransform::OBSBasicTransform(OBSBasic *parent)
HookWidget(ui->boundsAlign, COMBO_CHANGED, SLOT(OnControlChanged()));
HookWidget(ui->boundsWidth, DSCROLL_CHANGED, SLOT(OnControlChanged()));
HookWidget(ui->boundsHeight, DSCROLL_CHANGED, SLOT(OnControlChanged()));
HookWidget(ui->cropLeft, ISCROLL_CHANGED, SLOT(OnCropChanged()));
HookWidget(ui->cropRight, ISCROLL_CHANGED, SLOT(OnCropChanged()));
HookWidget(ui->cropTop, ISCROLL_CHANGED, SLOT(OnCropChanged()));
HookWidget(ui->cropBottom, ISCROLL_CHANGED, SLOT(OnCropChanged()));
installEventFilter(CreateShortcutFilter());
@ -183,7 +188,9 @@ void OBSBasicTransform::RefreshControls()
return;
obs_transform_info osi;
obs_sceneitem_crop crop;
obs_sceneitem_get_info(item, &osi);
obs_sceneitem_get_crop(item, &crop);
obs_source_t *source = obs_sceneitem_get_source(item);
float width = float(obs_source_get_width(source));
@ -204,6 +211,11 @@ void OBSBasicTransform::RefreshControls()
ui->boundsAlign->setCurrentIndex(boundsAlignIndex);
ui->boundsWidth->setValue(osi.bounds.x);
ui->boundsHeight->setValue(osi.bounds.y);
ui->cropLeft->setValue(int(crop.left));
ui->cropRight->setValue(int(crop.right));
ui->cropTop->setValue(int(crop.top));
ui->cropBottom->setValue(int(crop.bottom));
ignoreItemChange = false;
}
@ -260,3 +272,19 @@ void OBSBasicTransform::OnControlChanged()
obs_sceneitem_set_info(item, &oti);
ignoreTransformSignal = false;
}
void OBSBasicTransform::OnCropChanged()
{
if (ignoreItemChange)
return;
obs_sceneitem_crop crop;
crop.left = uint32_t(ui->cropLeft->value());
crop.right = uint32_t(ui->cropRight->value());
crop.top = uint32_t(ui->cropTop->value());
crop.bottom = uint32_t(ui->cropBottom->value());
ignoreTransformSignal = true;
obs_sceneitem_set_crop(item, &crop);
ignoreTransformSignal = false;
}

View File

@ -41,6 +41,7 @@ private slots:
void SetItemQt(OBSSceneItem newItem);
void OnBoundsType(int index);
void OnControlChanged();
void OnCropChanged();
public:
OBSBasicTransform(OBSBasic *parent);