[gimp/soc-2011-seamless-clone2] app: move the "get scaled image size" functions from shell-draw to -scale



commit 832bde254b390fe2fdf368cd9b39faafc8bb9e40
Author: Michael Natterer <mitch gimp org>
Date:   Thu Apr 18 19:06:17 2013 +0200

    app: move the "get scaled image size" functions from shell-draw to -scale

 app/display/gimpcanvaspassepartout.c     |   10 ++--
 app/display/gimpdisplayshell-callbacks.c |    9 ++--
 app/display/gimpdisplayshell-draw.c      |   57 ----------------------
 app/display/gimpdisplayshell-draw.h      |   54 +++++++++------------
 app/display/gimpdisplayshell-scale.c     |   77 ++++++++++++++++++++++++------
 app/display/gimpdisplayshell-scale.h     |    7 +++
 app/display/gimpdisplayshell-scroll.c    |    9 ++--
 7 files changed, 105 insertions(+), 118 deletions(-)
---
diff --git a/app/display/gimpcanvaspassepartout.c b/app/display/gimpcanvaspassepartout.c
index 0774e6f..558240b 100644
--- a/app/display/gimpcanvaspassepartout.c
+++ b/app/display/gimpcanvaspassepartout.c
@@ -28,7 +28,7 @@
 #include "gimpcanvas-style.h"
 #include "gimpcanvaspassepartout.h"
 #include "gimpdisplayshell.h"
-#include "gimpdisplayshell-draw.h"
+#include "gimpdisplayshell-scale.h"
 
 
 /*  local function prototypes  */
@@ -68,7 +68,7 @@ gimp_canvas_passe_partout_draw (GimpCanvasItem *item,
   GimpDisplayShell *shell = gimp_canvas_item_get_shell (item);
   gint              w, h;
 
-  gimp_display_shell_draw_get_scaled_image_size (shell, &w, &h);
+  gimp_display_shell_scale_get_image_size (shell, &w, &h);
   cairo_rectangle (cr, - shell->offset_x, - shell->offset_y, w, h);
 
   GIMP_CANVAS_ITEM_CLASS (parent_class)->draw (item, cr);
@@ -84,9 +84,9 @@ gimp_canvas_passe_partout_get_extents (GimpCanvasItem *item)
 
   rectangle.x = - shell->offset_x;
   rectangle.y = - shell->offset_y;
-  gimp_display_shell_draw_get_scaled_image_size (shell,
-                                                 &rectangle.width,
-                                                 &rectangle.height);
+  gimp_display_shell_scale_get_image_size (shell,
+                                           &rectangle.width,
+                                           &rectangle.height);
 
   outer = cairo_region_create_rectangle (&rectangle);
 
diff --git a/app/display/gimpdisplayshell-callbacks.c b/app/display/gimpdisplayshell-callbacks.c
index c258b0b..2481286 100644
--- a/app/display/gimpdisplayshell-callbacks.c
+++ b/app/display/gimpdisplayshell-callbacks.c
@@ -38,6 +38,7 @@
 #include "gimpdisplayshell-appearance.h"
 #include "gimpdisplayshell-callbacks.h"
 #include "gimpdisplayshell-draw.h"
+#include "gimpdisplayshell-scale.h"
 #include "gimpdisplayshell-scroll.h"
 #include "gimpdisplayshell-selection.h"
 #include "gimpdisplayshell-title.h"
@@ -170,7 +171,7 @@ gimp_display_shell_canvas_size_allocate (GtkWidget        *widget,
           gint     sw;
           gint     sh;
 
-          gimp_display_shell_draw_get_scaled_image_size (shell, &sw, &sh);
+          gimp_display_shell_scale_get_image_size (shell, &sw, &sh);
 
           center_horizontally = sw <= shell->disp_width;
           center_vertically   = sh <= shell->disp_height;
@@ -487,9 +488,9 @@ gimp_display_shell_canvas_draw_image (GimpDisplayShell *shell,
 
   image_rect.x = - shell->offset_x;
   image_rect.y = - shell->offset_y;
-  gimp_display_shell_draw_get_scaled_image_size (shell,
-                                                 &image_rect.width,
-                                                 &image_rect.height);
+  gimp_display_shell_scale_get_image_size (shell,
+                                           &image_rect.width,
+                                           &image_rect.height);
   image_region = cairo_region_create_rectangle (&image_rect);
 
   cairo_region_subtract (clear_region, image_region);
diff --git a/app/display/gimpdisplayshell-draw.c b/app/display/gimpdisplayshell-draw.c
index 2a26a19..def972d 100644
--- a/app/display/gimpdisplayshell-draw.c
+++ b/app/display/gimpdisplayshell-draw.c
@@ -28,8 +28,6 @@
 #include "display-types.h"
 
 #include "core/gimp-cairo.h"
-#include "core/gimpdrawable.h"
-#include "core/gimpimage.h"
 
 #include "gimpcanvas.h"
 #include "gimpcanvas-style.h"
@@ -38,66 +36,11 @@
 #include "gimpdisplayshell.h"
 #include "gimpdisplayshell-draw.h"
 #include "gimpdisplayshell-render.h"
-#include "gimpdisplayshell-scale.h"
-#include "gimpdisplayshell-scroll.h"
-#include "gimpdisplayshell-transform.h"
 #include "gimpdisplayxfer.h"
 
 
 /*  public functions  */
 
-/**
- * gimp_display_shell_get_scaled_image_size:
- * @shell:
- * @w:
- * @h:
- *
- * Gets the size of the rendered image after it has been scaled.
- *
- **/
-void
-gimp_display_shell_draw_get_scaled_image_size (GimpDisplayShell *shell,
-                                               gint             *w,
-                                               gint             *h)
-{
-  g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell));
-
-  gimp_display_shell_draw_get_scaled_image_size_for_scale (shell,
-                                                           gimp_zoom_model_get_factor (shell->zoom),
-                                                           w,
-                                                           h);
-}
-
-/**
- * gimp_display_shell_draw_get_scaled_image_size_for_scale:
- * @shell:
- * @scale:
- * @w:
- * @h:
- *
- **/
-void
-gimp_display_shell_draw_get_scaled_image_size_for_scale (GimpDisplayShell *shell,
-                                                         gdouble           scale,
-                                                         gint             *w,
-                                                         gint             *h)
-{
-  GimpImage *image;
-  gdouble    scale_x;
-  gdouble    scale_y;
-
-  g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell));
-
-  image = gimp_display_get_image (shell->display);
-
-  g_return_if_fail (GIMP_IS_IMAGE (image));
-
-  gimp_display_shell_calculate_scale_x_and_y (shell, scale, &scale_x, &scale_y);
-
-  if (w) *w = scale_x * gimp_image_get_width  (image);
-  if (h) *h = scale_y * gimp_image_get_height (image);
-}
-
 void
 gimp_display_shell_draw_selection_out (GimpDisplayShell *shell,
                                        cairo_t          *cr,
diff --git a/app/display/gimpdisplayshell-draw.h b/app/display/gimpdisplayshell-draw.h
index 206894e..4713d53 100644
--- a/app/display/gimpdisplayshell-draw.h
+++ b/app/display/gimpdisplayshell-draw.h
@@ -19,38 +19,28 @@
 #define __GIMP_DISPLAY_SHELL_DRAW_H__
 
 
-void   gimp_display_shell_draw_get_scaled_image_size (GimpDisplayShell   *shell,
-                                                      gint               *w,
-                                                      gint               *h);
-void   gimp_display_shell_draw_get_scaled_image_size_for_scale
-                                                     (GimpDisplayShell   *shell,
-                                                      gdouble             scale,
-                                                      gint               *w,
-                                                      gint               *h);
-
-void   gimp_display_shell_draw_selection_out         (GimpDisplayShell   *shell,
-                                                      cairo_t            *cr,
-                                                      GimpSegment        *segs,
-                                                      gint                n_segs);
-void   gimp_display_shell_draw_selection_in          (GimpDisplayShell   *shell,
-                                                      cairo_t            *cr,
-                                                      cairo_pattern_t    *mask,
-                                                      gint                index);
-
-void   gimp_display_shell_draw_background            (GimpDisplayShell   *shell,
-                                                      cairo_t            *cr);
-void   gimp_display_shell_draw_image                 (GimpDisplayShell   *shell,
-                                                      cairo_t            *cr,
-                                                      gint                x,
-                                                      gint                y,
-                                                      gint                w,
-                                                      gint                h);
-void   gimp_display_shell_draw_checkerboard          (GimpDisplayShell   *shell,
-                                                      cairo_t            *cr,
-                                                      gint                x,
-                                                      gint                y,
-                                                      gint                w,
-                                                      gint                h);
+void   gimp_display_shell_draw_selection_out (GimpDisplayShell   *shell,
+                                              cairo_t            *cr,
+                                              GimpSegment        *segs,
+                                              gint                n_segs);
+void   gimp_display_shell_draw_selection_in  (GimpDisplayShell   *shell,
+                                              cairo_t            *cr,
+                                              cairo_pattern_t    *mask,
+                                              gint                index);
+void   gimp_display_shell_draw_background    (GimpDisplayShell   *shell,
+                                              cairo_t            *cr);
+void   gimp_display_shell_draw_image         (GimpDisplayShell   *shell,
+                                              cairo_t            *cr,
+                                              gint                x,
+                                              gint                y,
+                                              gint                w,
+                                              gint                h);
+void   gimp_display_shell_draw_checkerboard  (GimpDisplayShell   *shell,
+                                              cairo_t            *cr,
+                                              gint                x,
+                                              gint                y,
+                                              gint                w,
+                                              gint                h);
 
 
 #endif /* __GIMP_DISPLAY_SHELL_DRAW_H__ */
diff --git a/app/display/gimpdisplayshell-scale.c b/app/display/gimpdisplayshell-scale.c
index 8ce8ab8..a69a6c1 100644
--- a/app/display/gimpdisplayshell-scale.c
+++ b/app/display/gimpdisplayshell-scale.c
@@ -33,11 +33,9 @@
 
 #include "gimpdisplay.h"
 #include "gimpdisplayshell.h"
-#include "gimpdisplayshell-draw.h"
 #include "gimpdisplayshell-expose.h"
 #include "gimpdisplayshell-scale.h"
 #include "gimpdisplayshell-scroll.h"
-#include "gimpdisplayshell-title.h"
 #include "gimpdisplayshell-transform.h"
 #include "gimpimagewindow.h"
 
@@ -348,6 +346,57 @@ gimp_display_shell_get_screen_resolution (GimpDisplayShell *shell,
 }
 
 /**
+ * gimp_display_shell_scale_get_image_size:
+ * @shell:
+ * @w:
+ * @h:
+ *
+ * Gets the size of the rendered image after it has been scaled.
+ *
+ **/
+void
+gimp_display_shell_scale_get_image_size (GimpDisplayShell *shell,
+                                         gint             *w,
+                                         gint             *h)
+{
+  g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell));
+
+  gimp_display_shell_scale_get_image_size_for_scale (shell,
+                                                     gimp_zoom_model_get_factor (shell->zoom),
+                                                     w, h);
+}
+
+/**
+ * gimp_display_shell_scale_get_image_size_for_scale:
+ * @shell:
+ * @scale:
+ * @w:
+ * @h:
+ *
+ **/
+void
+gimp_display_shell_scale_get_image_size_for_scale (GimpDisplayShell *shell,
+                                                   gdouble           scale,
+                                                   gint             *w,
+                                                   gint             *h)
+{
+  GimpImage *image;
+  gdouble    scale_x;
+  gdouble    scale_y;
+
+  g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell));
+
+  image = gimp_display_get_image (shell->display);
+
+  g_return_if_fail (GIMP_IS_IMAGE (image));
+
+  gimp_display_shell_calculate_scale_x_and_y (shell, scale, &scale_x, &scale_y);
+
+  if (w) *w = scale_x * gimp_image_get_width  (image);
+  if (h) *h = scale_y * gimp_image_get_height (image);
+}
+
+/**
  * gimp_display_shell_scale:
  * @shell:     the #GimpDisplayShell
  * @zoom_type: whether to zoom in, our or to a specific scale
@@ -442,7 +491,7 @@ gimp_display_shell_scale (GimpDisplayShell *shell,
                                                                    image_center_y,
                                                                    &image_center_almost_centered_horiz,
                                                                    &image_center_almost_centered_vert);
-            
+
           gimp_display_shell_scroll_center_image (shell,
                                                   starts_fitting_horiz ||
                                                   (zoom_focus_almost_centered_horiz &&
@@ -517,7 +566,7 @@ gimp_display_shell_scale_image_is_within_viewport (GimpDisplayShell *shell,
   if (! horizontally) horizontally = &horizontally_dummy;
   if (! vertically)   vertically   = &vertically_dummy;
 
-  gimp_display_shell_draw_get_scaled_image_size (shell, &sw, &sh);
+  gimp_display_shell_scale_get_image_size (shell, &sw, &sh);
 
   *horizontally = sw              <= shell->disp_width       &&
                   shell->offset_x <= 0                       &&
@@ -906,15 +955,15 @@ gimp_display_shell_scale_image_starts_to_fit (GimpDisplayShell *shell,
       gint new_scale_width;
       gint new_scale_height;
 
-      gimp_display_shell_draw_get_scaled_image_size_for_scale (shell,
-                                                               current_scale,
-                                                               &current_scale_width,
-                                                               &current_scale_height);
+      gimp_display_shell_scale_get_image_size_for_scale (shell,
+                                                         current_scale,
+                                                         &current_scale_width,
+                                                         &current_scale_height);
 
-      gimp_display_shell_draw_get_scaled_image_size_for_scale (shell,
-                                                               new_scale,
-                                                               &new_scale_width,
-                                                               &new_scale_height);
+      gimp_display_shell_scale_get_image_size_for_scale (shell,
+                                                         new_scale,
+                                                         &new_scale_width,
+                                                         &new_scale_height);
 
       *vertically   = (current_scale_width  >  shell->disp_width &&
                        new_scale_width      <= shell->disp_width);
@@ -979,9 +1028,7 @@ gimp_display_shell_scale_get_image_center_viewport (GimpDisplayShell *shell,
 {
   gint sw, sh;
 
-  gimp_display_shell_draw_get_scaled_image_size (shell,
-                                                 &sw,
-                                                 &sh);
+  gimp_display_shell_scale_get_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;
diff --git a/app/display/gimpdisplayshell-scale.h b/app/display/gimpdisplayshell-scale.h
index a654ffa..6458428 100644
--- a/app/display/gimpdisplayshell-scale.h
+++ b/app/display/gimpdisplayshell-scale.h
@@ -31,6 +31,13 @@ void     gimp_display_shell_scale_set_dot_for_dot          (GimpDisplayShell *sh
 void     gimp_display_shell_get_screen_resolution          (GimpDisplayShell *shell,
                                                             gdouble          *xres,
                                                             gdouble          *yres);
+void     gimp_display_shell_scale_get_image_size           (GimpDisplayShell *shell,
+                                                            gint             *w,
+                                                            gint             *h);
+void     gimp_display_shell_scale_get_image_size_for_scale (GimpDisplayShell *shell,
+                                                            gdouble           scale,
+                                                            gint             *w,
+                                                            gint             *h);
 
 void     gimp_display_shell_scale                          (GimpDisplayShell *shell,
                                                             GimpZoomType      zoom_type,
diff --git a/app/display/gimpdisplayshell-scroll.c b/app/display/gimpdisplayshell-scroll.c
index 1c4cce5..047b58f 100644
--- a/app/display/gimpdisplayshell-scroll.c
+++ b/app/display/gimpdisplayshell-scroll.c
@@ -35,7 +35,6 @@
 #include "gimpdisplay.h"
 #include "gimpdisplay-foreach.h"
 #include "gimpdisplayshell.h"
-#include "gimpdisplayshell-draw.h"
 #include "gimpdisplayshell-expose.h"
 #include "gimpdisplayshell-scale.h"
 #include "gimpdisplayshell-scroll.h"
@@ -295,7 +294,7 @@ gimp_display_shell_scroll_unoverscrollify (GimpDisplayShell *shell,
   *out_offset_x = in_offset_x;
   *out_offset_y = in_offset_y;
 
-  gimp_display_shell_draw_get_scaled_image_size (shell, &sw, &sh);
+  gimp_display_shell_scale_get_image_size (shell, &sw, &sh);
 
   if (in_offset_x < 0)
     {
@@ -351,7 +350,7 @@ gimp_display_shell_scroll_center_image (GimpDisplayShell *shell,
   target_offset_x = shell->offset_x;
   target_offset_y = shell->offset_y;
 
-  gimp_display_shell_draw_get_scaled_image_size (shell, &sw, &sh);
+  gimp_display_shell_scale_get_image_size (shell, &sw, &sh);
 
   if (horizontally)
     {
@@ -495,7 +494,7 @@ gimp_display_shell_scroll_setup_hscrollbar (GimpDisplayShell *shell,
       ! gimp_display_get_image (shell->display))
     return;
 
-  gimp_display_shell_draw_get_scaled_image_size (shell, &sw, NULL);
+  gimp_display_shell_scale_get_image_size (shell, &sw, NULL);
 
   if (shell->disp_width < sw)
     {
@@ -539,7 +538,7 @@ gimp_display_shell_scroll_setup_vscrollbar (GimpDisplayShell *shell,
       ! gimp_display_get_image (shell->display))
     return;
 
-  gimp_display_shell_draw_get_scaled_image_size (shell, NULL, &sh);
+  gimp_display_shell_scale_get_image_size (shell, NULL, &sh);
 
   if (shell->disp_height < sh)
     {


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