[gimp] app: turn GimpCanvasItem's stroke() and fill() into virtual functions
- From: Michael Natterer <mitch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] app: turn GimpCanvasItem's stroke() and fill() into virtual functions
- Date: Wed, 29 Sep 2010 21:41:13 +0000 (UTC)
commit 7b5316825c5b9fe3be4ff64ffa38d35b08d812f0
Author: Michael Natterer <mitch gimp org>
Date: Wed Sep 29 23:40:45 2010 +0200
app: turn GimpCanvasItem's stroke() and fill() into virtual functions
app/display/gimpcanvasitem.c | 54 +++++++++++++++++++++++++++++++----------
app/display/gimpcanvasitem.h | 7 +++++
2 files changed, 48 insertions(+), 13 deletions(-)
---
diff --git a/app/display/gimpcanvasitem.c b/app/display/gimpcanvasitem.c
index dc868a6..b23d6d1 100644
--- a/app/display/gimpcanvasitem.c
+++ b/app/display/gimpcanvasitem.c
@@ -72,6 +72,12 @@ static void gimp_canvas_item_real_draw (GimpCanvasItem *item,
cairo_t *cr);
static GdkRegion * gimp_canvas_item_real_get_extents (GimpCanvasItem *item,
GimpDisplayShell *shell);
+static void gimp_canvas_item_real_stroke (GimpCanvasItem *item,
+ GimpDisplayShell *shell,
+ cairo_t *cr);
+static void gimp_canvas_item_real_fill (GimpCanvasItem *item,
+ GimpDisplayShell *shell,
+ cairo_t *cr);
G_DEFINE_TYPE (GimpCanvasItem, gimp_canvas_item,
@@ -90,6 +96,8 @@ gimp_canvas_item_class_init (GimpCanvasItemClass *klass)
klass->draw = gimp_canvas_item_real_draw;
klass->get_extents = gimp_canvas_item_real_get_extents;
+ klass->stroke = gimp_canvas_item_real_stroke;
+ klass->fill = gimp_canvas_item_real_fill;
g_object_class_install_property (object_class, PROP_LINE_CAP,
g_param_spec_int ("line-cap",
@@ -180,6 +188,37 @@ gimp_canvas_item_real_get_extents (GimpCanvasItem *item,
return NULL;
}
+static void
+gimp_canvas_item_real_stroke (GimpCanvasItem *item,
+ GimpDisplayShell *shell,
+ cairo_t *cr)
+{
+ GimpCanvasItemPrivate *private = GET_PRIVATE (item);
+
+ cairo_set_line_cap (cr, private->line_cap);
+
+ gimp_display_shell_set_tool_bg_style (shell, cr);
+ cairo_stroke_preserve (cr);
+
+ gimp_display_shell_set_tool_fg_style (shell, cr, private->highlight);
+ cairo_stroke (cr);
+}
+
+static void
+gimp_canvas_item_real_fill (GimpCanvasItem *item,
+ GimpDisplayShell *shell,
+ cairo_t *cr)
+{
+ GimpCanvasItemPrivate *private = GET_PRIVATE (item);
+
+ gimp_display_shell_set_tool_bg_style (shell, cr);
+ cairo_set_line_width (cr, 2.0);
+ cairo_stroke_preserve (cr);
+
+ gimp_display_shell_set_tool_fg_style (shell, cr, private->highlight);
+ cairo_fill (cr);
+}
+
/* public functions */
@@ -298,13 +337,7 @@ _gimp_canvas_item_stroke (GimpCanvasItem *item,
if (private->suspend_stroking == 0)
{
- cairo_set_line_cap (cr, private->line_cap);
-
- gimp_display_shell_set_tool_bg_style (shell, cr);
- cairo_stroke_preserve (cr);
-
- gimp_display_shell_set_tool_fg_style (shell, cr, private->highlight);
- cairo_stroke (cr);
+ GIMP_CANVAS_ITEM_GET_CLASS (item)->stroke (item, shell, cr);
}
else
{
@@ -324,12 +357,7 @@ _gimp_canvas_item_fill (GimpCanvasItem *item,
if (private->suspend_filling == 0)
{
- gimp_display_shell_set_tool_bg_style (shell, cr);
- cairo_set_line_width (cr, 2.0);
- cairo_stroke_preserve (cr);
-
- gimp_display_shell_set_tool_fg_style (shell, cr, private->highlight);
- cairo_fill (cr);
+ GIMP_CANVAS_ITEM_GET_CLASS (item)->fill (item, shell, cr);
}
else
{
diff --git a/app/display/gimpcanvasitem.h b/app/display/gimpcanvasitem.h
index af7598e..d864be6 100644
--- a/app/display/gimpcanvasitem.h
+++ b/app/display/gimpcanvasitem.h
@@ -49,6 +49,13 @@ struct _GimpCanvasItemClass
cairo_t *cr);
GdkRegion * (* get_extents) (GimpCanvasItem *item,
GimpDisplayShell *shell);
+
+ void (* stroke) (GimpCanvasItem *item,
+ GimpDisplayShell *shell,
+ cairo_t *cr);
+ void (* fill) (GimpCanvasItem *item,
+ GimpDisplayShell *shell,
+ cairo_t *cr);
};
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]