Skip to content

Commit c8f5107

Browse files
committed
Magnify on short tap
Previously magnifying required holding your finger on the screen. This was not very discoverable. Allow magnifying on short tap (a click). Coordinates will be set to the position of the tap and subsequent drags will move the magnified area until finger is raised and the view is again unmagnified. Short tap while magnified will 'zoom out' without changing position. Hopefully this change will make magnify simpler to use for those who don't already know how it works. Big thanks to a friend of mine who was wondering what magnify button does. I'm very glad you asked. I would not have found out this shortcoming without that. :) Signed-off-by: Tomi Leppänen <[email protected]>
1 parent ca12ade commit c8f5107

File tree

1 file changed

+29
-10
lines changed

1 file changed

+29
-10
lines changed

qml/pages/Game.qml

+29-10
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
* Patience Deck is a collection of patience games.
3-
* Copyright (C) 2020-2022 Tomi Leppänen
3+
* Copyright (C) 2020-2023 Tomi Leppänen
44
*
55
* This program is free software: you can redistribute it and/or modify
66
* it under the terms of the GNU General Public License as published by
@@ -167,13 +167,7 @@ Page {
167167
backgroundColor: settings.backgroundColor
168168
highlightColor: Theme.rgba(Theme.highlightColor, Theme.opacityLow)
169169

170-
transform: Scale {
171-
id: magnifyTransform
172-
origin {
173-
x: Math.floor(magnifyArea.mouseX)
174-
y: Math.floor(magnifyArea.mouseY)
175-
}
176-
}
170+
transform: Scale { id: magnifyTransform }
177171
doubleResolution: magnifyArea.pressed || animateShrink.running || animateGrow.running
178172

179173
layer.enabled: pullDownMenu.active
@@ -214,8 +208,33 @@ Page {
214208
}
215209
enabled: toolbar.magnify
216210
preventStealing: true
217-
onPressed: animateGrow.running = true
218-
onReleased: animateShrink.running = true
211+
onPressed: {
212+
clickTimer.running = true
213+
if (magnifyTransform.xScale < 2) {
214+
animateGrow.running = true
215+
}
216+
}
217+
onReleased: if (magnifyTransform.xScale === 2 || !clickTimer.running) animateShrink.running = true
218+
onEnabledChanged: if (!enabled) animateShrink.running = true
219+
220+
Timer {
221+
id: clickTimer
222+
interval: 100
223+
}
224+
225+
Binding {
226+
target: magnifyTransform
227+
property: "origin.x"
228+
value: Math.floor(magnifyArea.mouseX)
229+
when: magnifyArea.pressed && (magnifyTransform.xScale === 1 || !clickTimer.running)
230+
}
231+
232+
Binding {
233+
target: magnifyTransform
234+
property: "origin.y"
235+
value: Math.floor(magnifyArea.mouseY)
236+
when: magnifyArea.pressed && (magnifyTransform.xScale === 1 || !clickTimer.running)
237+
}
219238
}
220239
}
221240

0 commit comments

Comments
 (0)