gimp r27654 - in branches/gimp-2-6: . app/actions app/display



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

Log:
Merged from trunk:

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.


Modified:
   branches/gimp-2-6/ChangeLog
   branches/gimp-2-6/app/actions/view-commands.c
   branches/gimp-2-6/app/display/display-enums.c
   branches/gimp-2-6/app/display/display-enums.h
   branches/gimp-2-6/app/display/gimpdisplayshell-scale.c

Modified: branches/gimp-2-6/app/actions/view-commands.c
==============================================================================
--- branches/gimp-2-6/app/actions/view-commands.c	(original)
+++ branches/gimp-2-6/app/actions/view-commands.c	Sat Nov 15 10:30:36 2008
@@ -218,7 +218,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: branches/gimp-2-6/app/display/display-enums.c
==============================================================================
--- branches/gimp-2-6/app/display/display-enums.c	(original)
+++ branches/gimp-2-6/app/display/display-enums.c	Sat Nov 15 10:30:36 2008
@@ -166,6 +166,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 }
   };
 
@@ -174,6 +175,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: branches/gimp-2-6/app/display/display-enums.h
==============================================================================
--- branches/gimp-2-6/app/display/display-enums.h	(original)
+++ branches/gimp-2-6/app/display/display-enums.h	Sat Nov 15 10:30:36 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: 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 10:30:36 2008
@@ -59,7 +59,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,
@@ -892,21 +892,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
@@ -942,8 +949,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,
@@ -1000,7 +1008,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]