gimp r27652 - in branches/gimp-2-6: . app/display



Author: martinn
Date: Sat Nov 15 08:07:43 2008
New Revision: 27652
URL: http://svn.gnome.org/viewvc/gimp?rev=27652&view=rev

Log:
Merged from trunk:

Bug 560245 â Zoom selection always centered in the Navigation tab

* app/display/gimpdisplayshell-scale.c (gimp_display_shell_scale):
Also take the image center and not only the zoom focus point into
account when deciding whether or not to center the image after
zoom.


Modified:
   branches/gimp-2-6/ChangeLog
   branches/gimp-2-6/app/display/gimpdisplayshell-scale.c

Modified: branches/gimp-2-6/app/display/gimpdisplayshell-scale.c
==============================================================================
--- branches/gimp-2-6/app/display/gimpdisplayshell-scale.c	(original)
+++ branches/gimp-2-6/app/display/gimpdisplayshell-scale.c	Sat Nov 15 08:07:43 2008
@@ -66,6 +66,12 @@
                                                           gboolean         *horizontally,
                                                           gboolean         *vertically);
 
+static void      gimp_display_shell_scale_get_image_center_viewport
+                                                         (GimpDisplayShell *shell,
+                                                          gint             *image_center_x,
+                                                          gint             *image_center_y);
+
+
 static void      gimp_display_shell_scale_get_zoom_focus (GimpDisplayShell *shell,
                                                           gdouble           new_scale,
                                                           gdouble           current_scale,
@@ -376,10 +382,14 @@
         }
       else
         {
-          gboolean starts_fitting_horizontally;
-          gboolean starts_fitting_vertically;
-          gboolean almost_centered_horizontally;
-          gboolean almost_centered_vertically;
+          gboolean starts_fitting_horiz;
+          gboolean starts_fitting_vert;
+          gboolean zoom_focus_almost_centered_horiz;
+          gboolean zoom_focus_almost_centered_vert;
+          gboolean image_center_almost_centered_horiz;
+          gboolean image_center_almost_centered_vert;
+          gint     image_center_x;
+          gint     image_center_y;
 
           gimp_display_shell_scale_get_zoom_focus (shell,
                                                    real_new_scale,
@@ -387,6 +397,9 @@
                                                    &x,
                                                    &y,
                                                    zoom_focus);
+          gimp_display_shell_scale_get_image_center_viewport (shell,
+                                                              &image_center_x,
+                                                              &image_center_y);
 
           gimp_display_shell_scale_to (shell, real_new_scale, x, y);
 
@@ -398,18 +411,27 @@
           gimp_display_shell_scale_image_starts_to_fit (shell,
                                                         real_new_scale,
                                                         current_scale,
-                                                        &starts_fitting_horizontally,
-                                                        &starts_fitting_vertically);
+                                                        &starts_fitting_horiz,
+                                                        &starts_fitting_vert);
+
           gimp_display_shell_scale_viewport_coord_almost_centered (shell,
                                                                    x,
                                                                    y,
-                                                                   &almost_centered_horizontally,
-                                                                   &almost_centered_vertically);
+                                                                   &zoom_focus_almost_centered_horiz,
+                                                                   &zoom_focus_almost_centered_vert);
+          gimp_display_shell_scale_viewport_coord_almost_centered (shell,
+                                                                   image_center_x,
+                                                                   image_center_y,
+                                                                   &image_center_almost_centered_horiz,
+                                                                   &image_center_almost_centered_vert);
+            
           gimp_display_shell_scroll_center_image (shell,
-                                                  starts_fitting_horizontally ||
-                                                  almost_centered_horizontally,
-                                                  starts_fitting_vertically ||
-                                                  almost_centered_vertically);
+                                                  starts_fitting_horiz ||
+                                                  (zoom_focus_almost_centered_horiz &&
+                                                   image_center_almost_centered_horiz),
+                                                  starts_fitting_vert ||
+                                                  (zoom_focus_almost_centered_vert &&
+                                                   image_center_almost_centered_vert));
         }
     }
 }
@@ -887,6 +909,21 @@
                   y < center_y + ALMOST_CENTERED_THRESHOLD;
 }
 
+static void
+gimp_display_shell_scale_get_image_center_viewport (GimpDisplayShell *shell,
+                                                    gint             *image_center_x,
+                                                    gint             *image_center_y)
+{
+  gint sw, sh;
+
+  gimp_display_shell_draw_get_scaled_image_size (shell,
+                                                 &sw,
+                                                 &sh);
+
+  if (image_center_x) *image_center_x = -shell->offset_x + sw / 2;
+  if (image_center_y) *image_center_y = -shell->offset_y + sh / 2;
+}
+
 /**
  * gimp_display_shell_scale_get_zoom_focus:
  * @shell:
@@ -909,15 +946,9 @@
   gint other_x, other_y;
 
   /* Calculate stops-to-fit focus point */
-  {
-    gint sw, sh;
-
-    gimp_display_shell_draw_get_scaled_image_size (shell,
-                                                   &sw,
-                                                   &sh);
-    image_center_x = -shell->offset_x + sw / 2;
-    image_center_y = -shell->offset_y + sh / 2;
-  }
+  gimp_display_shell_scale_get_image_center_viewport (shell,
+                                                      &image_center_x,
+                                                      &image_center_y);
 
   /* Calculate other focus point */
   {



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