gimp r26611 - in trunk: . app/display



Author: martinn
Date: Sun Aug 17 07:21:41 2008
New Revision: 26611
URL: http://svn.gnome.org/viewvc/gimp?rev=26611&view=rev

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

	* app/display/gimpdisplayshell.[ch]
	(gimp_display_shell_configure_event): When applying the centering
	logic we need to know the size of the new canvas, so instead of
	having it here, only make sure that this logic is run on the next
	canvas size-allocate.

	* app/display/gimpdisplayshell-callbacks.c
	(gimp_display_shell_canvas_size_allocate): If the size-allocate
	comes from a top level window resize, apply centering logic.


Modified:
   trunk/ChangeLog
   trunk/app/display/gimpdisplayshell-callbacks.c
   trunk/app/display/gimpdisplayshell.c
   trunk/app/display/gimpdisplayshell.h

Modified: trunk/app/display/gimpdisplayshell-callbacks.c
==============================================================================
--- trunk/app/display/gimpdisplayshell-callbacks.c	(original)
+++ trunk/app/display/gimpdisplayshell-callbacks.c	Sun Aug 17 07:21:41 2008
@@ -302,6 +302,28 @@
       shell->disp_width  = allocation->width;
       shell->disp_height = allocation->height;
 
+      /* When we size-allocate due to resize of the top level window,
+       * we want some additional logic
+       */
+      if (shell->size_allocate_from_configure_event)
+        {
+          gint sw;
+          gint sh;
+          gboolean center_horizontally;
+          gboolean center_vertically;
+
+          gimp_display_shell_draw_get_scaled_image_size (shell, &sw, &sh);
+
+          center_horizontally = sw <= shell->disp_width;
+          center_vertically   = sh <= shell->disp_height;
+
+          gimp_display_shell_scroll_center_image (shell,
+                                                  center_horizontally,
+                                                  center_vertically);
+
+          shell->size_allocate_from_configure_event = FALSE;
+        }
+
       gimp_display_shell_scroll_clamp_and_update (shell);
 
       gimp_display_shell_scaled (shell);

Modified: trunk/app/display/gimpdisplayshell.c
==============================================================================
--- trunk/app/display/gimpdisplayshell.c	(original)
+++ trunk/app/display/gimpdisplayshell.c	Sun Aug 17 07:21:41 2008
@@ -329,6 +329,8 @@
   shell->zoom_on_resize         = FALSE;
   shell->show_transform_preview = FALSE;
 
+  shell->size_allocate_from_configure_event = FALSE;
+
   shell->options                = g_object_new (GIMP_TYPE_DISPLAY_OPTIONS, NULL);
   shell->fullscreen_options     = g_object_new (GIMP_TYPE_DISPLAY_OPTIONS_FULLSCREEN, NULL);
   shell->no_image_options       = g_object_new (GIMP_TYPE_DISPLAY_OPTIONS_NO_IMAGE, NULL);
@@ -594,29 +596,15 @@
   if (GTK_WIDGET_CLASS (parent_class)->configure_event)
     GTK_WIDGET_CLASS (parent_class)->configure_event (widget, cevent);
 
-  /* Only run this stuff if the size changed */
+  /* If the window size has changed, make sure additoinal logic is run
+   * on size-allocate
+   */
   if (shell->display        &&
       shell->display->image &&
       (cevent->width  != current_width ||
        cevent->height != current_height))
     {
-      gint sw;
-      gint sh;
-      gboolean center_horizontally;
-      gboolean center_vertically;
-
-      gimp_display_shell_draw_get_scaled_image_size (shell, &sw, &sh);
-
-      center_horizontally = sw <= shell->disp_width;
-      center_vertically   = sh <= shell->disp_height;
-
-      /* If the image fits within the display shell canvas on a given
-       * axis, center the image on that axis. We know that the canvas
-       * will get a size-allocate if we get here.
-       */
-      gimp_display_shell_scroll_center_image_on_next_size_allocate (shell,
-                                                                    center_horizontally,
-                                                                    center_vertically);
+      shell->size_allocate_from_configure_event = TRUE;
     }
 
   return TRUE;

Modified: trunk/app/display/gimpdisplayshell.h
==============================================================================
--- trunk/app/display/gimpdisplayshell.h	(original)
+++ trunk/app/display/gimpdisplayshell.h	Sun Aug 17 07:21:41 2008
@@ -168,6 +168,8 @@
   gboolean           zoom_on_resize;
   gboolean           show_transform_preview;
 
+  gboolean           size_allocate_from_configure_event;
+
   GimpDisplayOptions *options;
   GimpDisplayOptions *fullscreen_options;
   GimpDisplayOptions *no_image_options;



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