[gimp] app: add group filling support to GimpCanvasItem and GimpCanvasGroup
- From: Michael Natterer <mitch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] app: add group filling support to GimpCanvasItem and GimpCanvasGroup
- Date: Mon, 27 Sep 2010 21:00:19 +0000 (UTC)
commit d7cb20b0d5083d86bfe5e95957f2e7ad63839c67
Author: Michael Natterer <mitch gimp org>
Date: Mon Sep 27 22:59:36 2010 +0200
app: add group filling support to GimpCanvasItem and GimpCanvasGroup
The code is almost identical to the group stroking feature.
app/display/gimpcanvasgroup.c | 43 +++++++++++++++++++++++++++++++-----
app/display/gimpcanvasgroup.h | 2 +
app/display/gimpcanvasitem.c | 48 ++++++++++++++++++++++++++++++++++++----
app/display/gimpcanvasitem.h | 3 ++
4 files changed, 85 insertions(+), 11 deletions(-)
---
diff --git a/app/display/gimpcanvasgroup.c b/app/display/gimpcanvasgroup.c
index 95b50a8..3079115 100644
--- a/app/display/gimpcanvasgroup.c
+++ b/app/display/gimpcanvasgroup.c
@@ -36,7 +36,8 @@
enum
{
PROP_0,
- PROP_GROUP_STROKING
+ PROP_GROUP_STROKING,
+ PROP_GROUP_FILLING
};
@@ -46,6 +47,7 @@ struct _GimpCanvasGroupPrivate
{
GList *items;
gboolean group_stroking;
+ gboolean group_filling;
};
#define GET_PRIVATE(group) \
@@ -96,6 +98,12 @@ gimp_canvas_group_class_init (GimpCanvasGroupClass *klass)
FALSE,
GIMP_PARAM_READWRITE));
+ g_object_class_install_property (object_class, PROP_GROUP_FILLING,
+ g_param_spec_boolean ("group-filling",
+ NULL, NULL,
+ FALSE,
+ GIMP_PARAM_READWRITE));
+
g_type_class_add_private (klass, sizeof (GimpCanvasGroupPrivate));
}
@@ -132,6 +140,9 @@ gimp_canvas_group_set_property (GObject *object,
case PROP_GROUP_STROKING:
private->group_stroking = g_value_get_boolean (value);
break;
+ case PROP_GROUP_FILLING:
+ private->group_filling = g_value_get_boolean (value);
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
@@ -152,6 +163,9 @@ gimp_canvas_group_get_property (GObject *object,
case PROP_GROUP_STROKING:
g_value_set_boolean (value, private->group_stroking);
break;
+ case PROP_GROUP_FILLING:
+ g_value_set_boolean (value, private->group_filling);
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
@@ -176,6 +190,9 @@ gimp_canvas_group_draw (GimpCanvasItem *item,
if (private->group_stroking)
_gimp_canvas_item_stroke (item, shell, cr);
+
+ if (private->group_filling)
+ _gimp_canvas_item_fill (item, shell, cr);
}
static GdkRegion *
@@ -192,14 +209,14 @@ gimp_canvas_group_get_extents (GimpCanvasItem *item,
GdkRegion *sub_region = gimp_canvas_item_get_extents (sub_item,
shell);
- if (region)
+ if (! region)
{
- gdk_region_union (region, sub_region);
- gdk_region_destroy (sub_region);
+ region = sub_region;
}
- else
+ else if (sub_region)
{
- region = sub_region;
+ gdk_region_union (region, sub_region);
+ gdk_region_destroy (sub_region);
}
}
@@ -227,6 +244,9 @@ gimp_canvas_group_add_item (GimpCanvasGroup *group,
if (private->group_stroking)
gimp_canvas_item_suspend_stroking (item);
+ if (private->group_filling)
+ gimp_canvas_item_suspend_filling (item);
+
private->items = g_list_append (private->items, g_object_ref (item));
}
@@ -257,3 +277,14 @@ gimp_canvas_group_set_group_stroking (GimpCanvasGroup *group,
"group-stroking", group_stroking ? TRUE : FALSE,
NULL);
}
+
+void
+gimp_canvas_group_set_group_filling (GimpCanvasGroup *group,
+ gboolean group_filling)
+{
+ g_return_if_fail (GIMP_IS_CANVAS_GROUP (group));
+
+ g_object_set (group,
+ "group-filling", group_filling ? TRUE : FALSE,
+ NULL);
+}
diff --git a/app/display/gimpcanvasgroup.h b/app/display/gimpcanvasgroup.h
index 06dc32b..28c3bc8 100644
--- a/app/display/gimpcanvasgroup.h
+++ b/app/display/gimpcanvasgroup.h
@@ -57,6 +57,8 @@ void gimp_canvas_group_remove_item (GimpCanvasGroup *group,
void gimp_canvas_group_set_group_stroking (GimpCanvasGroup *group,
gboolean group_stroking);
+void gimp_canvas_group_set_group_filling (GimpCanvasGroup *group,
+ gboolean group_filling);
#endif /* __GIMP_CANVAS_GROUP_H__ */
diff --git a/app/display/gimpcanvasitem.c b/app/display/gimpcanvasitem.c
index ed9a256..dc868a6 100644
--- a/app/display/gimpcanvasitem.c
+++ b/app/display/gimpcanvasitem.c
@@ -47,6 +47,7 @@ struct _GimpCanvasItemPrivate
cairo_line_cap_t line_cap;
gboolean highlight;
gint suspend_stroking;
+ gint suspend_filling;
};
#define GET_PRIVATE(item) \
@@ -115,6 +116,7 @@ gimp_canvas_item_init (GimpCanvasItem *item)
private->line_cap = CAIRO_LINE_CAP_ROUND;
private->highlight = FALSE;
private->suspend_stroking = 0;
+ private->suspend_filling = 0;
}
static void
@@ -255,6 +257,32 @@ gimp_canvas_item_resume_stroking (GimpCanvasItem *item)
private->suspend_stroking--;
}
+void
+gimp_canvas_item_suspend_filling (GimpCanvasItem *item)
+{
+ GimpCanvasItemPrivate *private;
+
+ g_return_if_fail (GIMP_IS_CANVAS_ITEM (item));
+
+ private = GET_PRIVATE (item);
+
+ private->suspend_filling++;
+}
+
+void
+gimp_canvas_item_resume_filling (GimpCanvasItem *item)
+{
+ GimpCanvasItemPrivate *private;
+
+ g_return_if_fail (GIMP_IS_CANVAS_ITEM (item));
+
+ private = GET_PRIVATE (item);
+
+ g_return_if_fail (private->suspend_filling > 0);
+
+ private->suspend_filling--;
+}
+
/* protected functions */
@@ -265,6 +293,9 @@ _gimp_canvas_item_stroke (GimpCanvasItem *item,
{
GimpCanvasItemPrivate *private = GET_PRIVATE (item);
+ if (private->suspend_filling > 0)
+ g_warning ("_gimp_canvas_item_stroke() on an item that is in a filling group");
+
if (private->suspend_stroking == 0)
{
cairo_set_line_cap (cr, private->line_cap);
@@ -291,10 +322,17 @@ _gimp_canvas_item_fill (GimpCanvasItem *item,
if (private->suspend_stroking > 0)
g_warning ("_gimp_canvas_item_fill() on an item that is in a stroking group");
- gimp_display_shell_set_tool_bg_style (shell, cr);
- cairo_set_line_width (cr, 2.0);
- cairo_stroke_preserve (cr);
+ 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_display_shell_set_tool_fg_style (shell, cr, private->highlight);
+ cairo_fill (cr);
+ }
+ else
+ {
+ cairo_new_sub_path (cr);
+ }
}
diff --git a/app/display/gimpcanvasitem.h b/app/display/gimpcanvasitem.h
index 4a3182e..af7598e 100644
--- a/app/display/gimpcanvasitem.h
+++ b/app/display/gimpcanvasitem.h
@@ -68,6 +68,9 @@ void gimp_canvas_item_set_highlight (GimpCanvasItem *item,
void gimp_canvas_item_suspend_stroking (GimpCanvasItem *item);
void gimp_canvas_item_resume_stroking (GimpCanvasItem *item);
+void gimp_canvas_item_suspend_filling (GimpCanvasItem *item);
+void gimp_canvas_item_resume_filling (GimpCanvasItem *item);
+
/* protected */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]