Skip to content

ImageViewer: Implement a "snap to" zoom mode for Pinch/Spread gestures#9533

Closed
NiLuJe wants to merge 0 commit into
koreader:masterfrom
NiLuJe:master
Closed

ImageViewer: Implement a "snap to" zoom mode for Pinch/Spread gestures#9533
NiLuJe wants to merge 0 commit into
koreader:masterfrom
NiLuJe:master

Conversation

@NiLuJe

@NiLuJe NiLuJe commented Sep 20, 2022

Copy link
Copy Markdown
Member

And use it, for pinches, when the image is smaller than the screen, and for spreads, when we spread outside of the image's bounds (more or less).

Followup to #9529 ;).

Also, document an unfortunate quirk of the distance field for two_finger_pan/swipe, which requires ugliness in our existing handlers for it; and minor code cleanups.


This change is Reviewable

@NiLuJe

NiLuJe commented Sep 20, 2022

Copy link
Copy Markdown
Member Author

It doesn't feel half bad, so, RFC ;).

@NiLuJe

NiLuJe commented Sep 20, 2022

Copy link
Copy Markdown
Member Author

It's slightly awkward on large screens because you can do a fairly large snap to pinch, but the inverse is not necessarily true because there's more screen space, so even a fully extended spread (which is awkward) won't necessarily correct for it.

@poire-z poire-z left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not really what I had in mind in #9529 (comment) - but why not :)
(What I had in mind would need knowing the distance between fingers at start - and the one at end - which I guess is/was not available and why I couldn't do much initially when I made ImageViewer.)

Comment thread frontend/device/gesturedetector.lua Outdated
Comment thread frontend/ui/widget/imageviewer.lua Outdated
Comment thread frontend/ui/widget/imageviewer.lua Outdated
@NiLuJe

NiLuJe commented Sep 20, 2022

Copy link
Copy Markdown
Member Author

(What I had in mind would need knowing the distance between fingers at start - and the one at end - which I guess is/was not available and why I couldn't do much initially when I made ImageViewer.)

We do know that (it's not exported, but we have the info). But I'm not quite getting what you meant, though.
(What I'm getting sounds like the sum of the travel distance of both fingers, which is already what distance is set to).

Or did you mean applying a zoom factor that would match the ratio between the span between the starting position of the fingers and the span between the ending position of the fingers? (because, again, that would probably very much match what we do with distance already).

@poire-z

poire-z commented Sep 20, 2022

Copy link
Copy Markdown
Contributor

Or did you mean applying a zoom factor that would match the ratio between the span between the starting position of the fingers and the span between the ending position of the fingers? (because, again, that would probably very much match what we do with distance already).

Yes. I think that's it.
If at start my fingers are separated by 3cm, and at end by 5cm (so, spread), the image should be scaled by 5/3: these 3 cm should become 5cm. the parts of the image I had my fingers on at start should move to where I had my fingers at end/lift time.

@NiLuJe

NiLuJe commented Sep 20, 2022

Copy link
Copy Markdown
Member Author

Yes. I think that's it.

Eh, I'll try. It feels like it should behave relatively closely to what we do with distance, but who knows ;o).

@poire-z

poire-z commented Sep 20, 2022

Copy link
Copy Markdown
Contributor

(But that's my naive expectation ;) i'm happy with what we have since some days ago - and it's quite possible doing it according to this naive expectation will feel more bothering.)

@NiLuJe

NiLuJe commented Sep 21, 2022

Copy link
Copy Markdown
Member Author

Yeah, tried it, it didn't work out ;p. (It lead to large jumps, which makes sense, pinched fingers make for a very small rectangle, so the ratio is bound to be high).

@NiLuJe

NiLuJe commented Sep 21, 2022

Copy link
Copy Markdown
Member Author

Made it configurable to see if it actually makes that much difference ;o).

(It would appear that: not so much on the H2O ^^).

@NiLuJe

NiLuJe commented Sep 21, 2022

Copy link
Copy Markdown
Member Author

I'll do more tests tomorrow, but, yeah, probably not worth bothering about, after all ^^.

(Was a fun experiment, though).

I'll probably do a different PR w/ just the code cleanups, and archive the code in a branch.

@poire-z

poire-z commented Sep 21, 2022

Copy link
Copy Markdown
Contributor

Tested this PR with its state as this time, and may be I messed my patching, but it feels quite strange and buggy:

  • sometimes, consecutive pinches zoom in then out then in then out
  • other strange zooms that feels like my gesture wasn't recognized (and also, possibly a lot more toggling of the bottom menu, like more touch/releases recognized as a tap)

That was with the default new setting checked and untouched (didn't try unchecked).

@poire-z

poire-z commented Sep 21, 2022

Copy link
Copy Markdown
Contributor
  • sometimes, consecutive pinches zoom in then out then in then out

I got this with some SVG image (the first on in my SVG test suite EPUB) - so it's possible this affects only SVG, which get their scale_factor handled a bit specifically (image_wg always getting scale_factor=1).
I also couldn't reproduce it with other SVG images :/
(Just had a quick test this morning, didn't have the time to update and apply this PR on a clean/recent nightly.)

@NiLuJe

NiLuJe commented Sep 21, 2022

Copy link
Copy Markdown
Member Author

Yeah, agree that it's usually close enough to the current behavior when it works, and when it doesn't, it's actively irritating ^^.

@NiLuJe

NiLuJe commented Sep 21, 2022

Copy link
Copy Markdown
Member Author

Superseded by #9544

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants