gimp r26470 - in trunk: . app/display



Author: martinn
Date: Sun Aug 10 07:23:14 2008
New Revision: 26470
URL: http://svn.gnome.org/viewvc/gimp?rev=26470&view=rev

Log:
2008-08-10  Martin Nordholts  <martinn svn gnome org>

	Put functions to center the image in the display shell where they
	belong, and give them proper names.

	* app/display/gimpdisplayshell-scale.[ch]: Get rid of functions
	and use the new names.

	* app/display/gimpdisplayshell-scroll.[ch]: Put the functions here
	and call them gimp_display_shell_scroll_center_image() and
	gimp_display_shell_scroll_center_image_on_next_size_allocate().

	* app/display/gimpdisplayshell.c:
	* app/display/gimpdisplayshell-handlers.c: Use the new names.


Modified:
   trunk/ChangeLog
   trunk/app/display/gimpdisplayshell-handlers.c
   trunk/app/display/gimpdisplayshell-scale.c
   trunk/app/display/gimpdisplayshell-scale.h
   trunk/app/display/gimpdisplayshell-scroll.c
   trunk/app/display/gimpdisplayshell-scroll.h
   trunk/app/display/gimpdisplayshell.c

Modified: trunk/app/display/gimpdisplayshell-handlers.c
==============================================================================
--- trunk/app/display/gimpdisplayshell-handlers.c	(original)
+++ trunk/app/display/gimpdisplayshell-handlers.c	Sun Aug 10 07:23:14 2008
@@ -492,7 +492,7 @@
        * has change size
        */
       gimp_display_shell_shrink_wrap (shell, FALSE);
-      gimp_display_shell_center_image_on_next_size_allocate (shell);
+      gimp_display_shell_scroll_center_image_on_next_size_allocate (shell);
     }
   else
     {

Modified: trunk/app/display/gimpdisplayshell-scale.c
==============================================================================
--- trunk/app/display/gimpdisplayshell-scale.c	(original)
+++ trunk/app/display/gimpdisplayshell-scale.c	Sun Aug 10 07:23:14 2008
@@ -452,7 +452,7 @@
                      (gdouble) shell->disp_height / (gdouble) image_height);
 
   gimp_display_shell_scale (shell, GIMP_ZOOM_TO, zoom_factor);
-  gimp_display_shell_center_image (shell, TRUE, TRUE);
+  gimp_display_shell_scroll_center_image (shell, TRUE, TRUE);
 }
 
 /**
@@ -491,97 +491,7 @@
                      (gdouble) shell->disp_height / (gdouble) image_height);
 
   gimp_display_shell_scale (shell, GIMP_ZOOM_TO, zoom_factor);
-  gimp_display_shell_center_image (shell, TRUE, TRUE);
-}
-
-/**
- * gimp_display_shell_center_image:
- * @shell:
- * @horizontally:
- * @vertically:
- *
- * Centers the image in the display shell on the desired axes.
- *
- **/
-void
-gimp_display_shell_center_image (GimpDisplayShell *shell,
-                                 gboolean          horizontally,
-                                 gboolean          vertically)
-{
-  gint sw, sh;
-  gint target_offset_x, target_offset_y;
-
-  g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell));
-
-  if (! shell->display)
-    return;
-
-  target_offset_x = shell->offset_x;
-  target_offset_y = shell->offset_y;
-
-  gimp_display_shell_get_scaled_image_size (shell, &sw, &sh);
-
-  if (horizontally)
-    {
-      if (sw < shell->disp_width)
-        {
-          target_offset_x = -(shell->disp_width - sw) / 2;
-        }
-      else
-        {
-          target_offset_x = (sw - shell->disp_width) / 2;
-        }
-    }
-
-  if (vertically)
-    {
-      if (sh < shell->disp_height)
-        {
-          target_offset_y = -(shell->disp_height - sh) / 2;
-        }
-      else
-        {
-          target_offset_y = (sh - shell->disp_height) / 2;
-        }
-    }
-
-  /* Note that we can't use gimp_display_shell_scroll_private() here
-   * because that would expose the image twice, causing unwanted
-   * flicker.
-   */
-  gimp_display_shell_scale_by_values (shell, gimp_zoom_model_get_factor (shell->zoom),
-                                      target_offset_x, target_offset_y,
-                                      FALSE);
-}
-
-static void
-gimp_display_shell_size_allocate_center_image_callback (GimpDisplayShell *shell,
-                                                        GtkAllocation    *allocation,
-                                                        GtkWidget        *canvas)
-{
-  gimp_display_shell_center_image (shell, TRUE, TRUE);
-
-  g_signal_handlers_disconnect_by_func (canvas,
-                                        gimp_display_shell_size_allocate_center_image_callback,
-                                        shell);
-}
-
-/**
- * gimp_display_shell_center_image_on_next_size_allocate:
- * @shell:
- *
- * Centers the image in the display as soon as the canvas has got its
- * new size
- *
- **/
-void
-gimp_display_shell_center_image_on_next_size_allocate (GimpDisplayShell *shell)
-{
-  g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell));
-
-  g_signal_connect_swapped (shell->canvas, "size-allocate",
-                            G_CALLBACK (gimp_display_shell_size_allocate_center_image_callback),
-                            shell);
+  gimp_display_shell_scroll_center_image (shell, TRUE, TRUE);
 }
 
 /**

Modified: trunk/app/display/gimpdisplayshell-scale.h
==============================================================================
--- trunk/app/display/gimpdisplayshell-scale.h	(original)
+++ trunk/app/display/gimpdisplayshell-scale.h	Sun Aug 10 07:23:14 2008
@@ -38,11 +38,6 @@
                                                  gdouble           y);
 void   gimp_display_shell_scale_fit_in          (GimpDisplayShell *shell);
 void   gimp_display_shell_scale_fill            (GimpDisplayShell *shell);
-void   gimp_display_shell_center_image          (GimpDisplayShell *shell,
-                                                 gboolean          horizontally,
-                                                 gboolean          vertically);
-void   gimp_display_shell_center_image_on_next_size_allocate
-                                                (GimpDisplayShell *shell);
 void   gimp_display_shell_scale_by_values       (GimpDisplayShell *shell,
                                                  gdouble           scale,
                                                  gint              offset_x,

Modified: trunk/app/display/gimpdisplayshell-scroll.c
==============================================================================
--- trunk/app/display/gimpdisplayshell-scroll.c	(original)
+++ trunk/app/display/gimpdisplayshell-scroll.c	Sun Aug 10 07:23:14 2008
@@ -205,6 +205,96 @@
 }
 
 /**
+ * gimp_display_shell_scroll_center_image:
+ * @shell:
+ * @horizontally:
+ * @vertically:
+ *
+ * Centers the image in the display shell on the desired axes.
+ *
+ **/
+void
+gimp_display_shell_scroll_center_image (GimpDisplayShell *shell,
+                                        gboolean          horizontally,
+                                        gboolean          vertically)
+{
+  gint sw, sh;
+  gint target_offset_x, target_offset_y;
+
+  g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell));
+
+  if (! shell->display)
+    return;
+
+  target_offset_x = shell->offset_x;
+  target_offset_y = shell->offset_y;
+
+  gimp_display_shell_get_scaled_image_size (shell, &sw, &sh);
+
+  if (horizontally)
+    {
+      if (sw < shell->disp_width)
+        {
+          target_offset_x = -(shell->disp_width - sw) / 2;
+        }
+      else
+        {
+          target_offset_x = (sw - shell->disp_width) / 2;
+        }
+    }
+
+  if (vertically)
+    {
+      if (sh < shell->disp_height)
+        {
+          target_offset_y = -(shell->disp_height - sh) / 2;
+        }
+      else
+        {
+          target_offset_y = (sh - shell->disp_height) / 2;
+        }
+    }
+
+  /* Note that we can't use gimp_display_shell_scroll_private() here
+   * because that would expose the image twice, causing unwanted
+   * flicker.
+   */
+  gimp_display_shell_scale_by_values (shell, gimp_zoom_model_get_factor (shell->zoom),
+                                      target_offset_x, target_offset_y,
+                                      FALSE);
+}
+
+static void
+gimp_display_shell_scroll_center_image_callback (GimpDisplayShell *shell,
+                                                 GtkAllocation    *allocation,
+                                                 GtkWidget        *canvas)
+{
+  gimp_display_shell_scroll_center_image (shell, TRUE, TRUE);
+
+  g_signal_handlers_disconnect_by_func (canvas,
+                                        gimp_display_shell_scroll_center_image_callback,
+                                        shell);
+}
+
+/**
+ * gimp_display_shell_scroll_center_image_on_next_size_allocate:
+ * @shell:
+ *
+ * Centers the image in the display as soon as the canvas has got its
+ * new size
+ *
+ **/
+void
+gimp_display_shell_scroll_center_image_on_next_size_allocate (GimpDisplayShell *shell)
+{
+  g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell));
+
+  g_signal_connect_swapped (shell->canvas, "size-allocate",
+                            G_CALLBACK (gimp_display_shell_scroll_center_image_callback),
+                            shell);
+}
+
+/**
  * gimp_display_shell_get_scaled_viewport:
  * @shell:
  * @x:

Modified: trunk/app/display/gimpdisplayshell-scroll.h
==============================================================================
--- trunk/app/display/gimpdisplayshell-scroll.h	(original)
+++ trunk/app/display/gimpdisplayshell-scroll.h	Sun Aug 10 07:23:14 2008
@@ -26,6 +26,13 @@
 
 void   gimp_display_shell_scroll_clamp_offsets           (GimpDisplayShell       *shell);
 
+void   gimp_display_shell_scroll_center_image            (GimpDisplayShell       *shell,
+                                                          gboolean                horizontally,
+                                                          gboolean                vertically);
+
+void   gimp_display_shell_scroll_center_image_on_next_size_allocate
+                                                         (GimpDisplayShell *shell);
+
 void   gimp_display_shell_get_scaled_viewport            (const GimpDisplayShell *shell,
                                                           gint                   *x,
                                                           gint                   *y,

Modified: trunk/app/display/gimpdisplayshell.c
==============================================================================
--- trunk/app/display/gimpdisplayshell.c	(original)
+++ trunk/app/display/gimpdisplayshell.c	Sun Aug 10 07:23:14 2008
@@ -1206,7 +1206,7 @@
       gimp_display_shell_connect (shell);
 
       /* after connecting to the image we want to center it */
-      gimp_display_shell_center_image_on_next_size_allocate (shell);
+      gimp_display_shell_scroll_center_image_on_next_size_allocate (shell);
     }
   else
     {
@@ -1345,9 +1345,9 @@
   center_horizontally = sw < shell->disp_width;
   center_vertically   = sh < shell->disp_height;
 
-  gimp_display_shell_center_image (shell,
-                                   center_horizontally,
-                                   center_vertically);
+  gimp_display_shell_scroll_center_image (shell,
+                                          center_horizontally,
+                                          center_vertically);
 
   g_signal_handlers_disconnect_by_func (canvas,
                                         gimp_display_shell_center_image_callback,



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