gimp r27653 - in trunk: . app/actions app/display



Author: martinn
Date: Sat Nov 15 10:24:56 2008
New Revision: 27653
URL: http://svn.gnome.org/viewvc/gimp?rev=27653&view=rev

Log:
Bug 560903 â Explicit zooming with e.g. '1' should handle
zoom-focus better

* app/display/display-enums.h: Added
GIMP_ZOOM_FOCUS_RETAIN_CENTERING_ELSE_BEST_GUESS.

* app/display/gimpdisplayshell-scale.c
(gimp_display_shell_scale_get_zoom_focus): Take the new enum into
account; if the image is centered, keep it centered, else use the
best-guess method.

* app/actions/view-commands.c (view_zoom_explicit_cmd_callback):
Use the new enum for explicit zooming.

* app/display/display-enums.c: Regenerated.


Modified:
   trunk/ChangeLog
   trunk/app/actions/view-commands.c
   trunk/app/display/display-enums.c
   trunk/app/display/display-enums.h
   trunk/app/display/gimpdisplayshell-scale.c

Modified: trunk/app/actions/view-commands.c
==============================================================================
--- trunk/app/actions/view-commands.c	(original)
+++ trunk/app/actions/view-commands.c	Sat Nov 15 10:24:56 2008
@@ -220,7 +220,7 @@
         gimp_display_shell_scale (shell,
                                   GIMP_ZOOM_TO,
                                   (gdouble) value / 10000,
-                                  GIMP_ZOOM_FOCUS_IMAGE_CENTER);
+                                  GIMP_ZOOM_FOCUS_RETAIN_CENTERING_ELSE_BEST_GUESS);
     }
 }
 

Modified: trunk/app/display/display-enums.c
==============================================================================
--- trunk/app/display/display-enums.c	(original)
+++ trunk/app/display/display-enums.c	Sat Nov 15 10:24:56 2008
@@ -171,6 +171,7 @@
     { GIMP_ZOOM_FOCUS_BEST_GUESS, "GIMP_ZOOM_FOCUS_BEST_GUESS", "best-guess" },
     { GIMP_ZOOM_FOCUS_POINTER, "GIMP_ZOOM_FOCUS_POINTER", "pointer" },
     { GIMP_ZOOM_FOCUS_IMAGE_CENTER, "GIMP_ZOOM_FOCUS_IMAGE_CENTER", "image-center" },
+    { GIMP_ZOOM_FOCUS_RETAIN_CENTERING_ELSE_BEST_GUESS, "GIMP_ZOOM_FOCUS_RETAIN_CENTERING_ELSE_BEST_GUESS", "retain-centering-else-best-guess" },
     { 0, NULL, NULL }
   };
 
@@ -179,6 +180,7 @@
     { GIMP_ZOOM_FOCUS_BEST_GUESS, "GIMP_ZOOM_FOCUS_BEST_GUESS", NULL },
     { GIMP_ZOOM_FOCUS_POINTER, "GIMP_ZOOM_FOCUS_POINTER", NULL },
     { GIMP_ZOOM_FOCUS_IMAGE_CENTER, "GIMP_ZOOM_FOCUS_IMAGE_CENTER", NULL },
+    { GIMP_ZOOM_FOCUS_RETAIN_CENTERING_ELSE_BEST_GUESS, "GIMP_ZOOM_FOCUS_RETAIN_CENTERING_ELSE_BEST_GUESS", NULL },
     { 0, NULL, NULL }
   };
 

Modified: trunk/app/display/display-enums.h
==============================================================================
--- trunk/app/display/display-enums.h	(original)
+++ trunk/app/display/display-enums.h	Sat Nov 15 10:24:56 2008
@@ -87,9 +87,20 @@
 
 typedef enum
 {
-  GIMP_ZOOM_FOCUS_BEST_GUESS,    /* Make a best guess                       */
-  GIMP_ZOOM_FOCUS_POINTER,       /* Use the mouse cursor (if within canvas) */
-  GIMP_ZOOM_FOCUS_IMAGE_CENTER   /* Use the image center                    */
+  /* Make a best guess */
+  GIMP_ZOOM_FOCUS_BEST_GUESS,
+
+  /* Use the mouse cursor (if within canvas) */
+  GIMP_ZOOM_FOCUS_POINTER,
+
+  /* Use the image center */
+  GIMP_ZOOM_FOCUS_IMAGE_CENTER,
+
+  /* If the image is centered, retain the centering. Else use
+   * _BEST_GUESS
+   */
+  GIMP_ZOOM_FOCUS_RETAIN_CENTERING_ELSE_BEST_GUESS
+
 } GimpZoomFocus;
 
 

Modified: trunk/app/display/gimpdisplayshell-scale.c
==============================================================================
--- trunk/app/display/gimpdisplayshell-scale.c	(original)
+++ trunk/app/display/gimpdisplayshell-scale.c	Sat Nov 15 10:24:56 2008
@@ -61,7 +61,7 @@
                                                           gdouble           current_scale,
                                                           gboolean         *vertically,
                                                           gboolean         *horizontally);
-static void      gimp_display_shell_scale_viewport_coord_almost_centered
+static gboolean  gimp_display_shell_scale_viewport_coord_almost_centered
                                                          (GimpDisplayShell *shell,
                                                           gint              x,
                                                           gint              y,
@@ -887,21 +887,28 @@
  * @vertically:
  *
  **/
-static void
+static gboolean
 gimp_display_shell_scale_viewport_coord_almost_centered (GimpDisplayShell *shell,
                                                          gint              x,
                                                          gint              y,
                                                          gboolean         *horizontally,
                                                          gboolean         *vertically)
 {
-  gint center_x = shell->disp_width  / 2;
-  gint center_y = shell->disp_height / 2;
+  gboolean local_horizontally;
+  gboolean local_vertically;
+  gint     center_x = shell->disp_width  / 2;
+  gint     center_y = shell->disp_height / 2;
+
+  local_horizontally = (x > center_x - ALMOST_CENTERED_THRESHOLD &&
+                        x < center_x + ALMOST_CENTERED_THRESHOLD);
 
-  *horizontally = x > center_x - ALMOST_CENTERED_THRESHOLD &&
-                  x < center_x + ALMOST_CENTERED_THRESHOLD;
+  local_vertically   = (y > center_y - ALMOST_CENTERED_THRESHOLD &&
+                        y < center_y + ALMOST_CENTERED_THRESHOLD);
 
-  *vertically   = y > center_y - ALMOST_CENTERED_THRESHOLD &&
-                  y < center_y + ALMOST_CENTERED_THRESHOLD;
+  if (horizontally) *horizontally = local_horizontally;
+  if (vertically)   *vertically   = local_vertically;
+
+  return local_horizontally && local_vertically;
 }
 
 static void
@@ -937,8 +944,9 @@
                                          gint             *y,
                                          GimpZoomFocus     zoom_focus)
 {
-  gint image_center_x, image_center_y;
-  gint other_x, other_y;
+  GimpZoomFocus real_zoom_focus = zoom_focus;
+  gint          image_center_x, image_center_y;
+  gint          other_x, other_y;
 
   /* Calculate stops-to-fit focus point */
   gimp_display_shell_scale_get_image_center_viewport (shell,
@@ -995,7 +1003,25 @@
   }
 
   /* Decide which one to use for each axis */
-  switch (zoom_focus)
+  if (zoom_focus == GIMP_ZOOM_FOCUS_RETAIN_CENTERING_ELSE_BEST_GUESS)
+    {
+      gboolean centered;
+
+      centered = gimp_display_shell_scale_viewport_coord_almost_centered (shell,
+                                                                          image_center_x,
+                                                                          image_center_y,
+                                                                          NULL,
+                                                                          NULL);
+      real_zoom_focus = (centered ?
+                         GIMP_ZOOM_FOCUS_IMAGE_CENTER :
+                         GIMP_ZOOM_FOCUS_BEST_GUESS);
+    }
+  else
+    {
+      real_zoom_focus = zoom_focus;
+    }
+
+  switch (real_zoom_focus)
     {
     case GIMP_ZOOM_FOCUS_POINTER:
       *x = other_x;



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