[gnome-photos/wip/rishi/gesture-zoom: 7/12] image-view, preview-view: Allow disabling the zoom animation



commit 0e5213dd9fe0958c2df863ad4b87ea087991f05d
Author: Debarshi Ray <debarshir gnome org>
Date:   Mon Oct 16 15:19:01 2017 +0200

    image-view, preview-view: Allow disabling the zoom animation
    
    A subsequent commit will add support for zooming with touch gestures.
    The content needs to stick to the touch points while the gesture is
    active, which isn't possible if it is animating between different zoom
    levels.
    
    The animation is still useful for smooth zooming using keyboard and
    mouse events which use relatively widely spaced, discrete incremental
    levels.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=783922

 src/photos-image-view.c   |   12 ++++++------
 src/photos-image-view.h   |    8 ++++++--
 src/photos-preview-view.c |    8 ++++----
 3 files changed, 16 insertions(+), 12 deletions(-)
---
diff --git a/src/photos-image-view.c b/src/photos-image-view.c
index 6dadbee..aae1484 100644
--- a/src/photos-image-view.c
+++ b/src/photos-image-view.c
@@ -807,7 +807,7 @@ photos_image_view_set_property (GObject *object, guint prop_id, const GValue *va
         gboolean best_fit;
 
         best_fit = g_value_get_boolean (value);
-        photos_image_view_set_best_fit (self, best_fit);
+        photos_image_view_set_best_fit (self, best_fit, TRUE);
         break;
       }
 
@@ -861,7 +861,7 @@ photos_image_view_set_property (GObject *object, guint prop_id, const GValue *va
         gdouble zoom;
 
         zoom = g_value_get_double (value);
-        photos_image_view_set_zoom (self, zoom);
+        photos_image_view_set_zoom (self, zoom, TRUE);
         break;
       }
 
@@ -1045,7 +1045,7 @@ photos_image_view_get_zoom (PhotosImageView *self)
 
 
 void
-photos_image_view_set_best_fit (PhotosImageView *self, gboolean best_fit)
+photos_image_view_set_best_fit (PhotosImageView *self, gboolean best_fit, gboolean enable_animation)
 {
   g_return_if_fail (PHOTOS_IS_IMAGE_VIEW (self));
 
@@ -1063,7 +1063,7 @@ photos_image_view_set_best_fit (PhotosImageView *self, gboolean best_fit)
 
       photos_image_view_calculate_best_fit_zoom (self, &self->zoom, &zoom_scaled);
 
-      if (photos_image_view_needs_zoom_animation (self))
+      if (enable_animation && photos_image_view_needs_zoom_animation (self))
         {
           photos_image_view_start_zoom_animation (self);
         }
@@ -1146,7 +1146,7 @@ photos_image_view_set_node (PhotosImageView *self, GeglNode *node)
 
 
 void
-photos_image_view_set_zoom (PhotosImageView *self, gdouble zoom)
+photos_image_view_set_zoom (PhotosImageView *self, gdouble zoom, gboolean enable_animation)
 {
   g_return_if_fail (PHOTOS_IS_IMAGE_VIEW (self));
   g_return_if_fail (zoom > 0.0);
@@ -1160,7 +1160,7 @@ photos_image_view_set_zoom (PhotosImageView *self, gdouble zoom)
   self->best_fit = FALSE;
   self->zoom = zoom;
 
-  if (photos_image_view_needs_zoom_animation (self))
+  if (enable_animation && photos_image_view_needs_zoom_animation (self))
     {
       photos_image_view_start_zoom_animation (self);
     }
diff --git a/src/photos-image-view.h b/src/photos-image-view.h
index 5cf0e82..f425bfc 100644
--- a/src/photos-image-view.h
+++ b/src/photos-image-view.h
@@ -43,11 +43,15 @@ gdouble             photos_image_view_get_y              (PhotosImageView *self)
 
 gdouble             photos_image_view_get_zoom           (PhotosImageView *self);
 
-void                photos_image_view_set_best_fit       (PhotosImageView *self, gboolean best_fit);
+void                photos_image_view_set_best_fit       (PhotosImageView *self,
+                                                          gboolean best_fit,
+                                                          gboolean enable_animation);
 
 void                photos_image_view_set_node           (PhotosImageView *self, GeglNode *node);
 
-void                photos_image_view_set_zoom           (PhotosImageView *self, gdouble zoom);
+void                photos_image_view_set_zoom           (PhotosImageView *self,
+                                                          gdouble zoom,
+                                                          gboolean enable_animation);
 
 G_END_DECLS
 
diff --git a/src/photos-preview-view.c b/src/photos-preview-view.c
index 7a8619c..771036a 100644
--- a/src/photos-preview-view.c
+++ b/src/photos-preview-view.c
@@ -843,7 +843,7 @@ photos_preview_view_zoom_best_fit (PhotosPreviewView *self)
 
   view_container = gtk_stack_get_visible_child (GTK_STACK (self->stack));
   view = photos_preview_view_get_view_from_view_container (view_container);
-  photos_image_view_set_best_fit (PHOTOS_IMAGE_VIEW (view), TRUE);
+  photos_image_view_set_best_fit (PHOTOS_IMAGE_VIEW (view), TRUE, TRUE);
   g_simple_action_set_enabled (G_SIMPLE_ACTION (self->zoom_best_fit_action), FALSE);
   g_simple_action_set_enabled (G_SIMPLE_ACTION (self->zoom_out_action), FALSE);
   photos_preview_nav_buttons_set_auto_hide (self->nav_buttons, TRUE);
@@ -884,7 +884,7 @@ photos_preview_view_zoom_in (PhotosPreviewView *self, GVariant *parameter)
   zoom = photos_image_view_get_zoom (PHOTOS_IMAGE_VIEW (view));
   zoom *= zoom_factor_for_delta;
 
-  photos_image_view_set_zoom (PHOTOS_IMAGE_VIEW (view), zoom);
+  photos_image_view_set_zoom (PHOTOS_IMAGE_VIEW (view), zoom, TRUE);
 
   g_simple_action_set_enabled (G_SIMPLE_ACTION (self->zoom_best_fit_action), TRUE);
   g_simple_action_set_enabled (G_SIMPLE_ACTION (self->zoom_out_action), TRUE);
@@ -925,7 +925,7 @@ photos_preview_view_zoom_out (PhotosPreviewView *self, GVariant *parameter)
 
   if (zoom < self->zoom_best_fit || photos_utils_equal_double (self->zoom_best_fit, zoom))
     {
-      photos_image_view_set_best_fit (PHOTOS_IMAGE_VIEW (view), TRUE);
+      photos_image_view_set_best_fit (PHOTOS_IMAGE_VIEW (view), TRUE, TRUE);
       g_simple_action_set_enabled (G_SIMPLE_ACTION (self->zoom_best_fit_action), FALSE);
       g_simple_action_set_enabled (G_SIMPLE_ACTION (self->zoom_out_action), FALSE);
       photos_preview_nav_buttons_set_auto_hide (self->nav_buttons, TRUE);
@@ -933,7 +933,7 @@ photos_preview_view_zoom_out (PhotosPreviewView *self, GVariant *parameter)
     }
   else
     {
-      photos_image_view_set_zoom (PHOTOS_IMAGE_VIEW (view), zoom);
+      photos_image_view_set_zoom (PHOTOS_IMAGE_VIEW (view), zoom, TRUE);
     }
 }
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]