From 933f5787d0739d3cd01f46227bae54ec247351b0 Mon Sep 17 00:00:00 2001 From: jp9000 Date: Sun, 22 Jun 2014 17:37:06 -0700 Subject: [PATCH] UI: Change transform value 'scale' to 'size' There's no reason to represent this value in terms of scale. Scale is a useless value for users to use. What are they going to enter, 0.5? 2.0? 0.25? Even if it can be subject to change by the source itself, and even if it's still converted to scale internally, having it display the base source size value is much more ideal for the user. --- build/data/obs-studio/locale/en.txt | 2 +- obs/forms/OBSBasicTransform.ui | 48 ++++++++++++++++++++--------- obs/window-basic-transform.cpp | 20 ++++++++---- 3 files changed, 48 insertions(+), 22 deletions(-) diff --git a/build/data/obs-studio/locale/en.txt b/build/data/obs-studio/locale/en.txt index fb1d3d05f..3bf3b72b4 100644 --- a/build/data/obs-studio/locale/en.txt +++ b/build/data/obs-studio/locale/en.txt @@ -73,7 +73,7 @@ Basic.PropertiesWindow.AutoSelectFormat="%1 (unsupported; autoselect: %2)" Basic.TransformWindow="Scene Item Transform" Basic.TransformWindow.Position="Position" Basic.TransformWindow.Rotation="Rotation" -Basic.TransformWindow.Scale="Scale" +Basic.TransformWindow.Size="Size" Basic.TransformWindow.Alignment="Positional Alignment" Basic.TransformWindow.BoundsType="Bounding Box Type" Basic.TransformWindow.BoundsAlignment="Alignment in Bounding Box" diff --git a/obs/forms/OBSBasicTransform.ui b/obs/forms/OBSBasicTransform.ui index a242bf97a..f48d3e13d 100644 --- a/obs/forms/OBSBasicTransform.ui +++ b/obs/forms/OBSBasicTransform.ui @@ -76,11 +76,14 @@ 0 + + 4 + - -9001.000000000000000 + -90001.000000000000000 - 9001.000000000000000 + 90001.000000000000000 @@ -92,11 +95,14 @@ 0 + + 4 + - -9001.000000000000000 + -90001.000000000000000 - 9001.000000000000000 + 90001.000000000000000 @@ -138,7 +144,7 @@ - Basic.TransformWindow.Scale + Basic.TransformWindow.Size @@ -164,40 +170,46 @@ 0 - + 100 0 + + 4 + - -9001.000000000000000 + -90001.000000000000000 - 9001.000000000000000 + 90001.000000000000000 - 0.010000000000000 + 1.000000000000000 - + 100 0 + + 4 + - -9001.000000000000000 + -90001.000000000000000 - 9001.000000000000000 + 90001.000000000000000 - 0.010000000000000 + 1.000000000000000 @@ -368,11 +380,14 @@ 0 + + 4 + 1.000000000000000 - 9001.000000000000000 + 90001.000000000000000 @@ -387,11 +402,14 @@ 0 + + 4 + 1.000000000000000 - 9001.000000000000000 + 90001.000000000000000 diff --git a/obs/window-basic-transform.cpp b/obs/window-basic-transform.cpp index 998d2fe2a..f68ce24b1 100644 --- a/obs/window-basic-transform.cpp +++ b/obs/window-basic-transform.cpp @@ -44,8 +44,8 @@ OBSBasicTransform::OBSBasicTransform(OBSBasic *parent) HookWidget(ui->positionX, DSCROLL_CHANGED, SLOT(OnControlChanged())); HookWidget(ui->positionY, DSCROLL_CHANGED, SLOT(OnControlChanged())); HookWidget(ui->rotation, DSCROLL_CHANGED, SLOT(OnControlChanged())); - HookWidget(ui->scaleX, DSCROLL_CHANGED, SLOT(OnControlChanged())); - HookWidget(ui->scaleY, DSCROLL_CHANGED, SLOT(OnControlChanged())); + HookWidget(ui->sizeX, DSCROLL_CHANGED, SLOT(OnControlChanged())); + HookWidget(ui->sizeY, DSCROLL_CHANGED, SLOT(OnControlChanged())); HookWidget(ui->align, COMBO_CHANGED, SLOT(OnControlChanged())); HookWidget(ui->boundsType, COMBO_CHANGED, SLOT(OnBoundsType(int))); HookWidget(ui->boundsAlign, COMBO_CHANGED, SLOT(OnControlChanged())); @@ -185,6 +185,10 @@ void OBSBasicTransform::RefreshControls() obs_sceneitem_info osi; obs_sceneitem_get_info(item, &osi); + obs_source_t source = obs_sceneitem_getsource(item); + float width = float(obs_source_getwidth(source)); + float height = float(obs_source_getheight(source)); + int alignIndex = AlignToList(osi.alignment); int boundsAlignIndex = AlignToList(osi.bounds_alignment); @@ -192,8 +196,8 @@ void OBSBasicTransform::RefreshControls() ui->positionX->setValue(osi.pos.x); ui->positionY->setValue(osi.pos.y); ui->rotation->setValue(osi.rot); - ui->scaleX->setValue(osi.scale.x); - ui->scaleY->setValue(osi.scale.y); + ui->sizeX->setValue(osi.scale.x * width); + ui->sizeY->setValue(osi.scale.y * height); ui->align->setCurrentIndex(alignIndex); ui->boundsType->setCurrentIndex(int(osi.bounds_type)); @@ -235,12 +239,16 @@ void OBSBasicTransform::OnControlChanged() if (ignoreItemChange) return; + obs_source_t source = obs_sceneitem_getsource(item); + double width = double(obs_source_getwidth(source)); + double height = double(obs_source_getheight(source)); + obs_sceneitem_info osi; osi.pos.x = float(ui->positionX->value()); osi.pos.y = float(ui->positionY->value()); osi.rot = float(ui->rotation->value()); - osi.scale.x = float(ui->scaleX->value()); - osi.scale.y = float(ui->scaleY->value()); + osi.scale.x = float(ui->sizeX->value() / width); + osi.scale.y = float(ui->sizeY->value() / height); osi.alignment = listToAlign[ui->align->currentIndex()]; osi.bounds_type = (obs_bounds_type)ui->boundsType->currentIndex();