Add option to lock aspect ratio in geometry effects/transitions

parent 3d53f186
......@@ -16,6 +16,7 @@ Item {
property double scaley
property double offsetx : 0
property double offsety : 0
property double lockratio : -1
onScalexChanged: canvas.requestPaint()
onScaleyChanged: canvas.requestPaint()
onOffsetxChanged: canvas.requestPaint()
......@@ -224,7 +225,7 @@ Item {
color: "transparent"
border.color: "#ffff0000"
Rectangle {
id: "tlhandle"
id: tlhandle
anchors {
top: parent.top
left: parent.left
......@@ -249,10 +250,20 @@ Item {
}
onPositionChanged: {
if (pressed) {
framesize.x = (framerect.x + (mouseX - oldMouseX) - frame.x) / root.scalex;
framesize.width = (framerect.width - (mouseX - oldMouseX)) / root.scalex;
framesize.y = (framerect.y + (mouseY - oldMouseY) - frame.y) / root.scaley;
framesize.height = (framerect.height - (mouseY - oldMouseY)) / root.scaley;
if (root.lockratio > 0) {
var delta = Math.max(mouseX - oldMouseX, mouseY - oldMouseY)
var newwidth = framerect.width - delta
var newheight = newwidth / root.lockratio
framesize.x = (framerect.x + (framerect.width - newwidth) - frame.x) / root.scalex;
framesize.width = newwidth / root.scalex;
framesize.y = (framerect.y + (framerect.height - newheight) - frame.y) / root.scaley;
framesize.height = newheight / root.scaley;
} else {
framesize.x = (framerect.x + (mouseX - oldMouseX) - frame.x) / root.scalex;
framesize.width = (framerect.width - (mouseX - oldMouseX)) / root.scalex;
framesize.y = (framerect.y + (mouseY - oldMouseY) - frame.y) / root.scaley;
framesize.height = (framerect.height - (mouseY - oldMouseY)) / root.scaley;
}
root.effectChanged()
}
}
......@@ -273,7 +284,7 @@ Item {
}
}
Rectangle {
id: "trhandle"
id: trhandle
anchors {
top: parent.top
right: parent.right
......@@ -298,9 +309,18 @@ Item {
}
onPositionChanged: {
if (pressed) {
framesize.width = (framerect.width + (mouseX - oldMouseX)) / root.scalex;
framesize.y = (framerect.y + (mouseY - oldMouseY) - frame.y) / root.scaley;
framesize.height = (framerect.height - (mouseY - oldMouseY)) / root.scaley;
if (root.lockratio > 0) {
var delta = Math.max(oldMouseX - mouseX, mouseY - oldMouseY)
var newheight = framerect.height - delta
var newwidth = newheight * root.lockratio
framesize.y = (framerect.y + (framerect.height - newheight) - frame.y) / root.scaley;
framesize.width = newwidth / root.scalex;
framesize.height = newheight / root.scaley;
} else {
framesize.width = (framerect.width + (mouseX - oldMouseX)) / root.scalex;
framesize.y = (framerect.y + (mouseY - oldMouseY) - frame.y) / root.scaley;
framesize.height = (framerect.height - (mouseY - oldMouseY)) / root.scaley;
}
root.effectChanged()
}
}
......@@ -310,7 +330,7 @@ Item {
}
}
Rectangle {
id: "blhandle"
id: blhandle
anchors {
bottom: parent.bottom
left: parent.left
......@@ -335,9 +355,18 @@ Item {
}
onPositionChanged: {
if (pressed) {
framesize.x = (framerect.x + (mouseX - oldMouseX) - frame.x) / root.scalex;
framesize.width = (framerect.width - (mouseX - oldMouseX)) / root.scalex;
framesize.height = (framerect.height + (mouseY - oldMouseY)) / root.scaley;
if (root.lockratio > 0) {
var delta = Math.max(mouseX - oldMouseX, oldMouseY - mouseY)
var newwidth = framerect.width - delta
var newheight = newwidth / root.lockratio
framesize.x = (framerect.x + (framerect.width - newwidth) - frame.x) / root.scalex;
framesize.width = newwidth / root.scalex;
framesize.height = newheight / root.scaley;
} else {
framesize.x = (framerect.x + (mouseX - oldMouseX) - frame.x) / root.scalex;
framesize.width = (framerect.width - (mouseX - oldMouseX)) / root.scalex;
framesize.height = (framerect.height + (mouseY - oldMouseY)) / root.scaley;
}
root.effectChanged()
}
}
......@@ -347,7 +376,7 @@ Item {
}
}
Rectangle {
id: "brhandle"
id: brhandle
anchors {
bottom: parent.bottom
right: parent.right
......@@ -372,8 +401,16 @@ Item {
}
onPositionChanged: {
if (pressed) {
framesize.width = (framerect.width + (mouseX - oldMouseX)) / root.scalex;
framesize.height = (framerect.height + (mouseY - oldMouseY)) / root.scaley;
if (root.lockratio > 0) {
var delta = Math.max(oldMouseX - mouseX, oldMouseY - mouseY)
var newwidth = framerect.width - delta
var newheight = newwidth / root.lockratio
framesize.width = newwidth / root.scalex;
framesize.height = newheight / root.scaley;
} else {
framesize.width = (framerect.width + (mouseX - oldMouseX)) / root.scalex;
framesize.height = (framerect.height + (mouseY - oldMouseY)) / root.scaley;
}
root.effectChanged()
}
}
......
This diff is collapsed.
......@@ -96,6 +96,7 @@ private:
DragValue *m_spinHeight;
DragValue *m_spinSize;
DragValue *m_spinOpacity;
QAction *m_originalSize;
int m_offset;
void parseKeyframes();
void rebuildKeyframes();
......@@ -160,6 +161,10 @@ private slots:
void slotCenterV();
/** @brief Moves the rect to the bottom frame border (y position = frame height - rect height). */
void slotMoveBottom();
/** @brief Un/Lock aspect ratio for size in effect parameter. */
void slotLockRatio();
void slotAdjustRectHeight();
void slotAdjustRectWidth();
signals:
void seekToPos(int);
......
This diff is collapsed.
......@@ -104,6 +104,8 @@ private:
DragValue *m_rotateY;
DragValue *m_rotateZ;
QPoint m_frameSize;
/** @brief Action switching between profile and source size. */
QAction *m_originalSize;
/** @brief True if this is a fixed parameter (no kexframes allowed). */
bool m_fixedGeom;
/** @brief True if there is only one keyframe in this geometry. */
......@@ -188,8 +190,10 @@ private slots:
void slotShowPreviousKeyFrame(bool show);
/** @brief Show / hide keyframe path in monitor scene. */
void slotShowPath(bool show);
/** @brief Eduit center points for the geometry keyframes. */
/** @brief Edit center points for the geometry keyframes. */
void slotUpdateCenters(const QVariantList &centers);
/** @brief Un/Lock aspect ratio for size in effect parameter. */
void slotLockRatio();
signals:
void seekToPos(int);
......
......@@ -948,4 +948,10 @@
<default>false</default>
</entry>
</group>
<group name="effects">
<entry name="lock_ratio" type="Bool">
<label>Lock size ratio in effects.</label>
<default>true</default>
</entry>
</group>
</kcfg>
......@@ -1655,6 +1655,15 @@ void Monitor::setUpEffectGeometry(const QRect &r, const QVariantList &list, cons
}
}
void Monitor::setEffectSceneProperty(const QString &name, const QVariant &value)
{
QQuickItem *root = m_glMonitor->rootObject();
if (!root) {
return;
}
root->setProperty(name.toUtf8().constData(), value);
}
QRect Monitor::effectRect() const
{
QQuickItem *root = m_glMonitor->rootObject();
......
......@@ -121,6 +121,8 @@ public:
int getZoneStart();
int getZoneEnd();
void setUpEffectGeometry(const QRect &r, const QVariantList &list = QVariantList(), const QVariantList &types = QVariantList());
/** @brief Set a property on the effect scene */
void setEffectSceneProperty(const QString &name, const QVariant &value);
/** @brief Returns effective display size */
QSize profileSize() const;
QRect effectRect() const;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment