diff --git a/obs/forms/OBSBasicTransform.ui b/obs/forms/OBSBasicTransform.ui index f48d3e13d..7f49ffaf5 100644 --- a/obs/forms/OBSBasicTransform.ui +++ b/obs/forms/OBSBasicTransform.ui @@ -275,6 +275,19 @@ + + + + Qt::Vertical + + + + 10 + 10 + + + + @@ -321,19 +334,6 @@ - - - - Qt::Vertical - - - - 20 - 20 - - - - @@ -341,6 +341,61 @@ + + + + false + + + Basic.TransformWindow.Alignment.TopLeft + + + + Basic.TransformWindow.Alignment.TopLeft + + + + + Basic.TransformWindow.Alignment.TopCenter + + + + + Basic.TransformWindow.Alignment.TopRight + + + + + Basic.TransformWindow.Alignment.CenterLeft + + + + + Basic.TransformWindow.Alignment.Center + + + + + Basic.TransformWindow.Alignment.CenterRight + + + + + Basic.TransformWindow.Alignment.BottomLeft + + + + + Basic.TransformWindow.Alignment.BottomCenter + + + + + Basic.TransformWindow.Alignment.BottomRight + + + + @@ -416,61 +471,171 @@ - - - - false + + + + Qt::Vertical - - Basic.TransformWindow.Alignment.TopLeft + + + 10 + 10 + + + + + + + + Basic.TransformWindow.Crop - - - Basic.TransformWindow.Alignment.TopLeft - - - - - Basic.TransformWindow.Alignment.TopCenter - - - - - Basic.TransformWindow.Alignment.TopRight - - - - - Basic.TransformWindow.Alignment.CenterLeft - - - - - Basic.TransformWindow.Alignment.Center - - - - - Basic.TransformWindow.Alignment.CenterRight - - - - - Basic.TransformWindow.Alignment.BottomLeft - - - - - Basic.TransformWindow.Alignment.BottomCenter - - - - - Basic.TransformWindow.Alignment.BottomRight - - + + + + + + + 0 + 0 + + + + + 70 + 0 + + + + 100000 + + + + + + + Left + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + cropLeft + + + + + + + Bottom + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + cropBottom + + + + + + + + 0 + 0 + + + + + 70 + 0 + + + + 100000 + + + + + + + + 0 + 0 + + + + + 70 + 0 + + + + 100000 + + + + + + + Top + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + cropTop + + + + + + + Right + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + cropRight + + + + + + + + 0 + 0 + + + + + 70 + 0 + + + + 100000 + + + + + + + Qt::Horizontal + + + + 0 + 0 + + + + + + diff --git a/obs/window-basic-transform.cpp b/obs/window-basic-transform.cpp index f9f9d9843..57ad6304f 100644 --- a/obs/window-basic-transform.cpp +++ b/obs/window-basic-transform.cpp @@ -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; +} diff --git a/obs/window-basic-transform.hpp b/obs/window-basic-transform.hpp index c8e2e4045..9764f28f6 100644 --- a/obs/window-basic-transform.hpp +++ b/obs/window-basic-transform.hpp @@ -41,6 +41,7 @@ private slots: void SetItemQt(OBSSceneItem newItem); void OnBoundsType(int index); void OnControlChanged(); + void OnCropChanged(); public: OBSBasicTransform(OBSBasic *parent);