[gimp/gimp-2-10] app: add gimp_display_shell_show_image()



commit e5d1f5ac4b85430bdb23aebc5579d8e3df730b09
Author: Ell <ell_se yahoo com>
Date:   Sat Aug 10 22:00:14 2019 +0300

    app: add gimp_display_shell_show_image()
    
    ... which controls whether or not the image is rendered by the
    shell.  We'll use this to hide the image while showing its
    transform preview in the next commits.
    
    (cherry picked from commit 539d666ae23e35c85d11fc0e2619bcfe1bb6dcda)

 app/display/gimpdisplayshell-callbacks.c | 21 ++++++++++++---------
 app/display/gimpdisplayshell.c           | 16 ++++++++++++++++
 app/display/gimpdisplayshell.h           |  6 ++++++
 3 files changed, 34 insertions(+), 9 deletions(-)
---
diff --git a/app/display/gimpdisplayshell-callbacks.c b/app/display/gimpdisplayshell-callbacks.c
index bfbaf09a84..fb4d69f1d1 100644
--- a/app/display/gimpdisplayshell-callbacks.c
+++ b/app/display/gimpdisplayshell-callbacks.c
@@ -494,17 +494,20 @@ gimp_display_shell_canvas_draw_image (GimpDisplayShell *shell,
       gimp_display_shell_draw_checkerboard (shell, cr);
       cairo_restore (cr);
 
-      cairo_set_matrix (cr, &matrix);
-
-      for (i = 0; i < clip_rectangles->num_rectangles; i++)
+      if (shell->show_image)
         {
-          cairo_rectangle_t rect = clip_rectangles->rectangles[i];
+          cairo_set_matrix (cr, &matrix);
+
+          for (i = 0; i < clip_rectangles->num_rectangles; i++)
+            {
+              cairo_rectangle_t rect = clip_rectangles->rectangles[i];
 
-          gimp_display_shell_draw_image (shell, cr,
-                                         floor (rect.x),
-                                         floor (rect.y),
-                                         ceil (rect.width),
-                                         ceil (rect.height));
+              gimp_display_shell_draw_image (shell, cr,
+                                             floor (rect.x),
+                                             floor (rect.y),
+                                             ceil (rect.width),
+                                             ceil (rect.height));
+            }
         }
     }
 
diff --git a/app/display/gimpdisplayshell.c b/app/display/gimpdisplayshell.c
index 6135874e20..aee598a969 100644
--- a/app/display/gimpdisplayshell.c
+++ b/app/display/gimpdisplayshell.c
@@ -326,6 +326,8 @@ gimp_display_shell_init (GimpDisplayShell *shell)
   shell->scale_x     = 1.0;
   shell->scale_y     = 1.0;
 
+  shell->show_image  = TRUE;
+
   gimp_display_shell_items_init (shell);
 
   shell->icon_size       = 128;
@@ -1784,6 +1786,20 @@ gimp_display_shell_mask_bounds (GimpDisplayShell *shell,
   return (*width > 0) && (*height > 0);
 }
 
+void
+gimp_display_shell_set_show_image (GimpDisplayShell *shell,
+                                   gboolean          show_image)
+{
+  g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell));
+
+  if (show_image != shell->show_image)
+    {
+      shell->show_image = show_image;
+
+      gimp_display_shell_expose_full (shell);
+    }
+}
+
 void
 gimp_display_shell_flush (GimpDisplayShell *shell,
                           gboolean          now)
diff --git a/app/display/gimpdisplayshell.h b/app/display/gimpdisplayshell.h
index acaf6e8b8e..e938bb5035 100644
--- a/app/display/gimpdisplayshell.h
+++ b/app/display/gimpdisplayshell.h
@@ -91,6 +91,8 @@ struct _GimpDisplayShell
 
   gboolean           proximity;        /*  is a device in proximity           */
 
+  gboolean           show_image;       /*  whether to show the image          */
+
   Selection         *selection;        /*  Selection (marching ants)          */
 
   GList             *children;
@@ -297,6 +299,10 @@ gboolean          gimp_display_shell_mask_bounds   (GimpDisplayShell   *shell,
                                                     gint               *width,
                                                     gint               *height);
 
+void              gimp_display_shell_set_show_image
+                                                   (GimpDisplayShell   *shell,
+                                                    gboolean            show_image);
+
 void              gimp_display_shell_flush         (GimpDisplayShell   *shell,
                                                     gboolean            now);
 


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