aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMahmoud Badri <mahmoud.badri@qt.io>2024-02-02 14:20:37 +0200
committerMahmoud Badri <mahmoud.badri@qt.io>2024-02-02 12:26:42 +0000
commit85f32353a974091a3198d5b847479e1d95e5cf53 (patch)
tree3d59ade17ea3398897f85360480755b72801f159
parentf985b1b09108efb5606771a447c1b5bcf7c9464a (diff)
EffectComposer: Fix pan/zoom not working after adding a node
Also increase max zoom level to 3 instead of 2 Change-Id: Ia642bc65c0f902a0aff8fd81fc6f623981f2b249 Reviewed-by: Miikka Heikkinen <miikka.heikkinen@qt.io>
-rw-r--r--share/qtcreator/qmldesigner/effectComposerQmlSources/EffectComposerPreview.qml88
1 files changed, 44 insertions, 44 deletions
diff --git a/share/qtcreator/qmldesigner/effectComposerQmlSources/EffectComposerPreview.qml b/share/qtcreator/qmldesigner/effectComposerQmlSources/EffectComposerPreview.qml
index 251b429a4d..892132a39f 100644
--- a/share/qtcreator/qmldesigner/effectComposerQmlSources/EffectComposerPreview.qml
+++ b/share/qtcreator/qmldesigner/effectComposerQmlSources/EffectComposerPreview.qml
@@ -84,7 +84,7 @@ Column {
anchors.verticalCenter: parent.verticalCenter
HelperWidgets.AbstractButton {
- enabled: sourceImage.scale < 2
+ enabled: sourceImage.scale < 3
style: StudioTheme.Values.viewBarButtonStyle
buttonIcon: StudioTheme.Constants.zoomIn_medium
tooltip: qsTr("Zoom In")
@@ -174,64 +174,64 @@ Column {
height: root.height - y
clip: true
- Item { // Source item as a canvas (render target) for effect
- id: source
+ MouseArea {
+ id: mouseArea
+
anchors.fill: parent
- layer.enabled: true
- layer.mipmap: true
- layer.smooth: true
+ acceptedButtons: Qt.LeftButton
- MouseArea {
- id: mouseArea
+ property real pressX: 0
+ property real pressY: 0
+ property bool panning: false
- anchors.fill: parent
- acceptedButtons: Qt.LeftButton
+ onPressed: {
+ pressX = mouseX - sourceImage.x
+ pressY = mouseY - sourceImage.y
+ panning = true
+ }
- property real pressX: 0
- property real pressY: 0
- property bool panning: false
+ onReleased: {
+ panning = false
+ }
- onPressed: {
- pressX = mouseX - sourceImage.x
- pressY = mouseY - sourceImage.y
- panning = true
- }
+ onWheel: (wheel) => {
+ let prevScale = sourceImage.scale
- onReleased: {
- panning = false
+ if (wheel.angleDelta.y > 0) {
+ if (sourceImage.scale < 3)
+ sourceImage.scale += .2
+ } else {
+ if (sourceImage.scale > .4)
+ sourceImage.scale -= .2
}
- onWheel: (wheel) => {
- let prevScale = sourceImage.scale
+ let dScale = sourceImage.scale - prevScale
- if (wheel.angleDelta.y > 0) {
- if (sourceImage.scale < 2)
- sourceImage.scale += .2
- } else {
- if (sourceImage.scale > .4)
- sourceImage.scale -= .2
- }
+ sourceImage.x += (sourceImage.x + sourceImage.width * .5 - wheel.x) * dScale;
+ sourceImage.y += (sourceImage.y + sourceImage.height * .5 - wheel.y) * dScale;
- let dScale = sourceImage.scale - prevScale
+ sourceImage.checkBounds()
+ }
- sourceImage.x += (sourceImage.x + sourceImage.width * .5 - wheel.x) * dScale;
- sourceImage.y += (sourceImage.y + sourceImage.height * .5 - wheel.y) * dScale;
+ Timer { // pan timer
+ running: parent.panning
+ interval: 16
+ repeat: true
+ onTriggered: {
+ sourceImage.x = mouseArea.mouseX - mouseArea.pressX
+ sourceImage.y = mouseArea.mouseY - mouseArea.pressY
sourceImage.checkBounds()
}
-
- Timer { // pan timer
- running: parent.panning
- interval: 16
- repeat: true
-
- onTriggered: {
- sourceImage.x = mouseArea.mouseX - mouseArea.pressX
- sourceImage.y = mouseArea.mouseY - mouseArea.pressY
- sourceImage.checkBounds()
- }
- }
}
+ }
+
+ Item { // Source item as a canvas (render target) for effect
+ id: source
+ anchors.fill: parent
+ layer.enabled: true
+ layer.mipmap: true
+ layer.smooth: true
Image {
id: sourceImage