[gimp/cage: 53/130] app: use a GimpCanvasPassePartout for drawing the crop highlight
- From: Michael Muré <mmure src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp/cage: 53/130] app: use a GimpCanvasPassePartout for drawing the crop highlight
- Date: Thu, 30 Dec 2010 17:52:26 +0000 (UTC)
commit 15c5345ca7fed58432ab9477971465330c098ba0
Author: Michael Natterer <mitch gimp org>
Date: Fri Nov 12 19:47:51 2010 +0100
app: use a GimpCanvasPassePartout for drawing the crop highlight
and remove all old drawing logic.
app/display/gimpdisplayshell-callbacks.c | 11 -------
app/display/gimpdisplayshell-draw.c | 27 ------------------
app/display/gimpdisplayshell-draw.h | 6 ----
app/display/gimpdisplayshell-items.c | 7 +++++
app/display/gimpdisplayshell.c | 43 +++++++-----------------------
app/display/gimpdisplayshell.h | 1 +
6 files changed, 18 insertions(+), 77 deletions(-)
---
diff --git a/app/display/gimpdisplayshell-callbacks.c b/app/display/gimpdisplayshell-callbacks.c
index d2bf073..879236b 100644
--- a/app/display/gimpdisplayshell-callbacks.c
+++ b/app/display/gimpdisplayshell-callbacks.c
@@ -2307,17 +2307,6 @@ gimp_display_shell_canvas_expose_image (GimpDisplayShell *shell,
g_free (rects);
cairo_restore (cr);
-
- if (shell->highlight)
- {
- cairo_save (cr);
- gimp_display_shell_draw_highlight (shell, cr,
- image_rect.x,
- image_rect.y,
- image_rect.width,
- image_rect.height);
- cairo_restore (cr);
- }
}
gdk_region_destroy (image_region);
diff --git a/app/display/gimpdisplayshell-draw.c b/app/display/gimpdisplayshell-draw.c
index b570c48..af27310 100644
--- a/app/display/gimpdisplayshell-draw.c
+++ b/app/display/gimpdisplayshell-draw.c
@@ -234,30 +234,3 @@ gimp_display_shell_draw_checkerboard (GimpDisplayShell *shell,
cairo_set_source (cr, shell->checkerboard);
cairo_paint (cr);
}
-
-void
-gimp_display_shell_draw_highlight (GimpDisplayShell *shell,
- cairo_t *cr,
- gint x,
- gint y,
- gint w,
- gint h)
-{
- g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell));
- g_return_if_fail (shell->highlight != NULL);
- g_return_if_fail (cr != NULL);
-
- cairo_rectangle (cr, x, y, w, h);
-
- cairo_translate (cr, - shell->offset_x, - shell->offset_y);
- cairo_scale (cr, shell->scale_x, shell->scale_y);
- cairo_rectangle (cr,
- shell->highlight->x, shell->highlight->y,
- shell->highlight->width, shell->highlight->height);
-
- cairo_set_fill_rule (cr, CAIRO_FILL_RULE_EVEN_ODD);
- cairo_clip (cr);
-
- gimp_display_shell_set_passe_partout_style (shell, cr);
- cairo_paint (cr);
-}
diff --git a/app/display/gimpdisplayshell-draw.h b/app/display/gimpdisplayshell-draw.h
index 25160e8..09aecbc 100644
--- a/app/display/gimpdisplayshell-draw.h
+++ b/app/display/gimpdisplayshell-draw.h
@@ -49,12 +49,6 @@ void gimp_display_shell_draw_checkerboard (GimpDisplayShell *shell,
gint y,
gint w,
gint h);
-void gimp_display_shell_draw_highlight (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-items.c b/app/display/gimpdisplayshell-items.c
index 2b80103..500b806 100644
--- a/app/display/gimpdisplayshell-items.c
+++ b/app/display/gimpdisplayshell-items.c
@@ -27,6 +27,7 @@
#include "gimpcanvascursor.h"
#include "gimpcanvasgrid.h"
#include "gimpcanvaslayerboundary.h"
+#include "gimpcanvaspassepartout.h"
#include "gimpcanvasproxygroup.h"
#include "gimpdisplayshell.h"
#include "gimpdisplayshell-expose.h"
@@ -49,6 +50,11 @@ gimp_display_shell_items_init (GimpDisplayShell *shell)
shell->canvas_item = gimp_canvas_group_new (shell);
+ shell->passe_partout = gimp_canvas_passe_partout_new (shell, 0, 0, 0, 0);
+ gimp_canvas_item_set_visible (shell->passe_partout, FALSE);
+ gimp_display_shell_add_item (shell, shell->passe_partout);
+ g_object_unref (shell->passe_partout);
+
shell->vectors = gimp_canvas_proxy_group_new (shell);
gimp_display_shell_add_item (shell, shell->vectors);
g_object_unref (shell->vectors);
@@ -95,6 +101,7 @@ gimp_display_shell_items_free (GimpDisplayShell *shell)
g_object_unref (shell->canvas_item);
shell->canvas_item = NULL;
+ shell->passe_partout = NULL;
shell->vectors = NULL;
shell->grid = NULL;
shell->guides = NULL;
diff --git a/app/display/gimpdisplayshell.c b/app/display/gimpdisplayshell.c
index 2c3ed1d..efeb97c 100644
--- a/app/display/gimpdisplayshell.c
+++ b/app/display/gimpdisplayshell.c
@@ -1761,42 +1761,19 @@ gimp_display_shell_set_highlight (GimpDisplayShell *shell,
{
g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell));
- if (shell->highlight)
+ if (highlight)
{
- if (highlight)
- {
- cairo_region_t *old;
- cairo_region_t *new;
-
- if (memcmp (shell->highlight, highlight, sizeof (GdkRectangle)) == 0)
- return;
-
- old = cairo_region_create_rectangle ((cairo_rectangle_int_t *) shell->highlight);
-
- *shell->highlight = *highlight;
-
- new = cairo_region_create_rectangle ((cairo_rectangle_int_t *) shell->highlight);
- cairo_region_xor (old, new);
-
- gimp_display_shell_expose_region (shell, old);
-
- cairo_region_destroy (old);
- cairo_region_destroy (new);
- }
- else
- {
- g_slice_free (GdkRectangle, shell->highlight);
- shell->highlight = NULL;
-
- gimp_display_shell_expose_full (shell);
- }
+ g_object_set (shell->passe_partout,
+ "visible", TRUE,
+ "x", (gdouble) highlight->x,
+ "y", (gdouble) highlight->y,
+ "width", (gdouble) highlight->width,
+ "height", (gdouble) highlight->height,
+ NULL);
}
- else if (highlight)
+ else
{
- shell->highlight = g_slice_new (GdkRectangle);
- *shell->highlight = *highlight;
-
- gimp_display_shell_expose_full (shell);
+ gimp_canvas_item_set_visible (shell->passe_partout, FALSE);
}
}
diff --git a/app/display/gimpdisplayshell.h b/app/display/gimpdisplayshell.h
index 7cdb565..b186be0 100644
--- a/app/display/gimpdisplayshell.h
+++ b/app/display/gimpdisplayshell.h
@@ -136,6 +136,7 @@ struct _GimpDisplayShell
cairo_pattern_t *checkerboard; /* checkerboard pattern */
GimpCanvasItem *canvas_item; /* items drawn on the canvas */
+ GimpCanvasItem *passe_partout; /* item for the highlight */
GimpCanvasItem *vectors; /* item proxy of vectors */
GimpCanvasItem *grid; /* item proxy of the grid */
GimpCanvasItem *guides; /* item proxies of guides */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]