After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 783922 - Support GtkGestureZoom for zooming
Support GtkGestureZoom for zooming
Status: RESOLVED FIXED
Product: gnome-photos
Classification: Applications
Component: general
unspecified
Other All
: Normal enhancement
: ---
Assigned To: GNOME photos maintainer(s)
GNOME photos maintainer(s)
Depends on:
Blocks:
 
 
Reported: 2017-06-18 12:44 UTC by Debarshi Ray
Modified: 2017-10-17 09:10 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Add zoom gesture support for tablets (1.43 KB, patch)
2017-09-02 09:52 UTC, Jan-Michael Brummer
none Details | Review
Add zoom gesture support for tablets v2 (5.98 KB, patch)
2017-09-12 18:49 UTC, Jan-Michael Brummer
none Details | Review
Make the zoom-in/out GActions more flexible (16.94 KB, patch)
2017-10-11 22:30 UTC, Debarshi Ray
none Details | Review
image-view: Split out the code to check valid allocation and extent (2.11 KB, patch)
2017-10-17 08:24 UTC, Debarshi Ray
committed Details | Review
image-view, preview-view: Re-work the zoom animation implementation (10.13 KB, patch)
2017-10-17 08:25 UTC, Debarshi Ray
committed Details | Review
image-view, preview-view: Allow disabling the zoom animation (6.20 KB, patch)
2017-10-17 08:25 UTC, Debarshi Ray
committed Details | Review
Encode the origin of the zoom event in the zoom-in/out GActions (18.03 KB, patch)
2017-10-17 08:26 UTC, Debarshi Ray
committed Details | Review
preview-view: Consolidate zoom calculation from GAction activations (6.07 KB, patch)
2017-10-17 08:27 UTC, Debarshi Ray
committed Details | Review
Prepare the zoom-* GActions for touch gestures (14.68 KB, patch)
2017-10-17 08:27 UTC, Debarshi Ray
committed Details | Review
Add PhotosGestureZoom (13.04 KB, patch)
2017-10-17 08:28 UTC, Debarshi Ray
committed Details | Review
preview-view: Use touch gestures for zooming (5.37 KB, patch)
2017-10-17 08:28 UTC, Debarshi Ray
committed Details | Review

Description Debarshi Ray 2017-06-18 12:44:30 UTC
Now that the application supports zooming (bug 742662), it would be nice if one could use a gesture for doing so.
Comment 1 Jan-Michael Brummer 2017-09-02 09:52:08 UTC
Created attachment 358973 [details] [review]
Add zoom gesture support for tablets

Please review attached patch which adds zoom gesture support.
Comment 2 Debarshi Ray 2017-09-12 08:22:14 UTC
Review of attachment 358973 [details] [review]:

Thanks for the patch! Looks very good for a first attempt. The only problem is that the zoom gesture doesn't get disabled along with the rest of zoom controls. That's because the PhotosImageView only implements the zooming mechanism. The policy of when to zoom and by how much is elsewhere.

::: src/photos-image-view.c
@@ +791,3 @@
+photos_image_view_zoom_scale_changed_cb(GtkGestureZoom *gesture, gdouble scale, PhotosImageView *self)
+{
+  photos_image_view_set_zoom(self, scale);

I wonder if we need to disable/tweak our built-in animation between zoom levels. Right now, the image doesn't seem to stick to the fingers when zooming in and out using the gesture.

@@ +813,3 @@
   self->best_fit = TRUE;
+
+  zoom = gtk_gesture_zoom_new(GTK_WIDGET(self));

It will be better to put this in PhotosPreview or PhotosPreviewNavButtons with the rest of the zoom policy logic.
Comment 3 Jan-Michael Brummer 2017-09-12 18:49:03 UTC
Created attachment 359655 [details] [review]
Add zoom gesture support for tablets v2
Comment 4 Jan-Michael Brummer 2017-09-12 18:50:32 UTC
Update patch based on your review:

V2:
 - Moved zoom gesture support to photos-preview-nav-buttons
 - Keep track of zoom size
 - Show zoom controls if required
Comment 5 Jan-Michael Brummer 2017-09-15 08:43:37 UTC
@Debarshi Ray: Do you have time for another review?
Comment 6 Debarshi Ray 2017-10-10 11:54:57 UTC
Review of attachment 359655 [details] [review]:

I finally got around to trying this on a touch screen. Some comments below:

::: src/photos-preview-nav-buttons.c
@@ +465,3 @@
+
+  self->zoom = self->initial_zoom * scale;
+  photos_preview_view_set_zoom (preview_view, self->zoom);

This doesn't work through the GActions for zooming. That means that all the logic to hide/show the overlaid controls and the minimum zoom threshold don't come into play.

How well does this work with ImageView's built-in animation when zooming in/out? After playing around a bit, I have a feeling that we need to turn off the animation for gestures (by setting the duration to 0).

We might also have to tweak the parameters accepted by our GActions. Currently they are step-based, where 1 step is equivalent to one key press, or one step of the scroll wheel. A zoom factor is then used to actually change the zoom. However, for gestures, we directly get the zoom factor from the gesture as a factor of the initial gesture. Therefore, instead of a simple double, we might need to extend the parameter to be more expressive.

::: src/photos-preview-view.h
@@ +55,3 @@
 void                   photos_preview_view_set_node               (PhotosPreviewView *self, GeglNode *node);
 
+void                   photos_preview_view_set_zoom               (PhotosPreviewView *self, gdouble zoom);

I'd also suggest moving the GtkGestureZoom into PreviewView, where the rest of the zooming interactions are handled.

The PreviewNavButtons is a helper to drive the overlaid controls, and the gestures that it has are there to control their visibility. It'd be nice if we can minimize (or even get rid of) calls to PreviewView from PreviewNavButtons to have a strictly parent to child relationship.
Comment 7 Debarshi Ray 2017-10-11 22:30:48 UTC
Created attachment 361384 [details] [review]
Make the zoom-in/out GActions more flexible

A proof-of-concept that makes app.zoom-in/out more flexible by making them accept an a{sv} instead of a double. The a{sv} lets us explicitly encode the type of event that triggered the zoom so that the "backed" (ie. the GAction implementation) can handle them accordingly.
Comment 8 Debarshi Ray 2017-10-17 08:24:55 UTC
Created attachment 361718 [details] [review]
image-view: Split out the code to check valid allocation and extent
Comment 9 Debarshi Ray 2017-10-17 08:25:27 UTC
Created attachment 361719 [details] [review]
image-view, preview-view: Re-work the zoom animation implementation
Comment 10 Debarshi Ray 2017-10-17 08:25:55 UTC
Created attachment 361720 [details] [review]
image-view, preview-view: Allow disabling the zoom animation
Comment 11 Debarshi Ray 2017-10-17 08:26:40 UTC
Created attachment 361722 [details] [review]
Encode the origin of the zoom event in the zoom-in/out GActions
Comment 12 Debarshi Ray 2017-10-17 08:27:08 UTC
Created attachment 361723 [details] [review]
preview-view: Consolidate zoom calculation from GAction activations
Comment 13 Debarshi Ray 2017-10-17 08:27:43 UTC
Created attachment 361724 [details] [review]
Prepare the zoom-* GActions for touch gestures
Comment 14 Debarshi Ray 2017-10-17 08:28:17 UTC
Created attachment 361725 [details] [review]
Add PhotosGestureZoom
Comment 15 Debarshi Ray 2017-10-17 08:28:49 UTC
Created attachment 361726 [details] [review]
preview-view: Use touch gestures for zooming
Comment 16 Debarshi Ray 2017-10-17 09:10:23 UTC
Jan, I adjusted your patch on top of the other plumbing changes and pushed to master. Thank you for working on this!