[goocanvas/new-api] 2010-07-10 Damon Chaplin <damon gnome org>
- From: Damon Chaplin <damon src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [goocanvas/new-api] 2010-07-10 Damon Chaplin <damon gnome org>
- Date: Sat, 10 Jul 2010 12:20:55 +0000 (UTC)
commit 487aea666214dd19be2518b9a7e8177fa7ef96a0
Author: Damon Chaplin <damon gnome org>
Date: Sat Jul 10 13:20:23 2010 +0100
2010-07-10 Damon Chaplin <damon gnome org>
* src/goocanvasitemsimple.c:
* src/goocanvas.c:
* src/goocanvasstyle.c: use a GooCanvasStyleValuesMask "mask" to specify
which style properties have been set.
ChangeLog | 7 ++
demo/demo.c | 2 +-
src/goocanvas.c | 34 +++++++---
src/goocanvasitemsimple.c | 155 ++++++++++++++++++++++++++++-----------------
src/goocanvasstyle.c | 57 +++++++++++++----
src/goocanvasstyle.h | 47 +++++++++++++-
src/goocanvastext.c | 3 +-
7 files changed, 221 insertions(+), 84 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 80db886..369960f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2010-07-10 Damon Chaplin <damon gnome org>
+
+ * src/goocanvasitemsimple.c:
+ * src/goocanvas.c:
+ * src/goocanvasstyle.c: use a GooCanvasStyleValuesMask "mask" to specify
+ which style properties have been set.
+
2010-07-09 Damon Chaplin <damon gnome org>
* src/goocanvas.c (goo_canvas_set_default_style): new function to set
diff --git a/demo/demo.c b/demo/demo.c
index d61f928..598a4e0 100644
--- a/demo/demo.c
+++ b/demo/demo.c
@@ -238,7 +238,7 @@ change_style_clicked (GtkWidget *button, GooCanvas *canvas)
{
g_object_set (canvas_style,
"line-width", 2.0,
- "stroke-pattern", NULL,
+ "mask", GOO_CANVAS_STYLE_LINE_WIDTH,
NULL);
goo_canvas_set_default_style (canvas, canvas_style);
diff --git a/src/goocanvas.c b/src/goocanvas.c
index b1e396d..289a281 100644
--- a/src/goocanvas.c
+++ b/src/goocanvas.c
@@ -574,7 +574,7 @@ goo_canvas_get_default_line_width (GooCanvas *canvas)
if (!canvas)
return 2.0;
- if (canvas->style && canvas->style->line_width >= 0.0)
+ if (canvas->style && (canvas->style->mask & GOO_CANVAS_STYLE_LINE_WIDTH))
return canvas->style->line_width;
/* We use the same default as cairo when using pixels, i.e. 2 pixels.
@@ -611,18 +611,32 @@ goo_canvas_apply_style (GooCanvas *canvas,
if (!style)
return;
- if (style->stroke_pattern)
+ if ((style->mask & GOO_CANVAS_STYLE_STROKE_PATTERN) && style->stroke_pattern)
cairo_set_source (cr, style->stroke_pattern);
- cairo_set_operator (cr, style->op);
- cairo_set_antialias (cr, style->antialias);
- cairo_set_line_cap (cr, style->line_cap);
- cairo_set_line_join (cr, style->line_join);
- cairo_set_miter_limit (cr, style->line_join_miter_limit);
+ if (style->mask & GOO_CANVAS_STYLE_OPERATOR)
+ cairo_set_operator (cr, style->op);
- if (style->dash)
- cairo_set_dash (cr, style->dash->dashes, style->dash->num_dashes,
- style->dash->dash_offset);
+ if (style->mask & GOO_CANVAS_STYLE_ANTIALIAS)
+ cairo_set_antialias (cr, style->antialias);
+
+ if (style->mask & GOO_CANVAS_STYLE_LINE_CAP)
+ cairo_set_line_cap (cr, style->line_cap);
+
+ if (style->mask & GOO_CANVAS_STYLE_LINE_JOIN)
+ cairo_set_line_join (cr, style->line_join);
+
+ if (style->mask & GOO_CANVAS_STYLE_LINE_JOIN_MITER_LIMIT)
+ cairo_set_miter_limit (cr, style->line_join_miter_limit);
+
+ if (style->mask & GOO_CANVAS_STYLE_LINE_DASH)
+ {
+ if (style->dash)
+ cairo_set_dash (cr, style->dash->dashes, style->dash->num_dashes,
+ style->dash->dash_offset);
+ else
+ cairo_set_dash (cr, NULL, 0, 0.0);
+ }
}
diff --git a/src/goocanvasitemsimple.c b/src/goocanvasitemsimple.c
index bbe6730..e65c423 100644
--- a/src/goocanvasitemsimple.c
+++ b/src/goocanvasitemsimple.c
@@ -342,42 +342,52 @@ goo_canvas_item_simple_set_property (GObject *object,
break;
case PROP_FILL_RULE:
style->fill_rule = g_value_get_enum (value);
+ style->mask |= GOO_CANVAS_STYLE_FILL_RULE;
break;
case PROP_OPERATOR:
style->op = g_value_get_enum (value);
+ style->mask |= GOO_CANVAS_STYLE_OPERATOR;
break;
case PROP_ANTIALIAS:
style->antialias = g_value_get_enum (value);
+ style->mask |= GOO_CANVAS_STYLE_ANTIALIAS;
break;
/* Line style & width properties. */
case PROP_LINE_WIDTH:
style->line_width = g_value_get_double (value);
+ style->mask |= GOO_CANVAS_STYLE_LINE_WIDTH;
recompute_bounds = TRUE;
break;
case PROP_LINE_WIDTH_TOLERANCE:
style->line_width_tolerance = g_value_get_double (value);
+ style->mask |= GOO_CANVAS_STYLE_LINE_WIDTH_TOLERANCE;
need_update = FALSE;
break;
case PROP_LINE_WIDTH_IS_UNSCALED:
style->line_width_is_unscaled = g_value_get_boolean (value);
+ style->mask |= GOO_CANVAS_STYLE_LINE_WIDTH_IS_UNSCALED;
break;
case PROP_LINE_CAP:
style->line_cap = g_value_get_enum (value);
+ style->mask |= GOO_CANVAS_STYLE_LINE_CAP;
recompute_bounds = TRUE;
break;
case PROP_LINE_JOIN:
style->line_join = g_value_get_enum (value);
+ style->mask |= GOO_CANVAS_STYLE_LINE_JOIN;
recompute_bounds = TRUE;
break;
case PROP_LINE_JOIN_MITER_LIMIT:
style->line_join_miter_limit = g_value_get_double (value);
+ style->mask |= GOO_CANVAS_STYLE_LINE_JOIN_MITER_LIMIT;
recompute_bounds = TRUE;
break;
case PROP_LINE_DASH:
goo_canvas_line_dash_unref (style->dash);
style->dash = g_value_get_boxed (value);
goo_canvas_line_dash_ref (style->dash);
+ style->mask |= GOO_CANVAS_STYLE_LINE_DASH;
recompute_bounds = TRUE;
break;
@@ -390,6 +400,7 @@ goo_canvas_item_simple_set_property (GObject *object,
style->font_desc = pango_font_description_from_string (font_name);
else
style->font_desc = NULL;
+ style->mask |= GOO_CANVAS_STYLE_FONT_DESCRIPTION;
recompute_bounds = TRUE;
break;
case PROP_FONT_DESC:
@@ -400,10 +411,12 @@ goo_canvas_item_simple_set_property (GObject *object,
style->font_desc = pango_font_description_copy (font_desc);
else
style->font_desc = NULL;
+ style->mask |= GOO_CANVAS_STYLE_FONT_DESCRIPTION;
recompute_bounds = TRUE;
break;
case PROP_HINT_METRICS:
style->hint_metrics = g_value_get_enum (value);
+ style->mask |= GOO_CANVAS_STYLE_HINT_METRICS;
recompute_bounds = TRUE;
break;
@@ -1595,70 +1608,83 @@ goo_canvas_item_simple_set_stroke_options (GooCanvasItemSimple *simple,
{
static cairo_pattern_t *black_pattern = NULL;
GooCanvasStyle *style = simple->style;
+ cairo_pattern_t *pattern;
gdouble line_width;
+ /* Create the static black pattern if we haven't already created it. */
if (!black_pattern)
black_pattern = cairo_pattern_create_rgb (0.0, 0.0, 0.0);
- /* If no style is set, just reset the source to black and return TRUE so the
- default style will be used. */
- if (!style)
- {
- cairo_set_source (cr, black_pattern);
- return TRUE;
- }
+ /* The stroke pattern defaults to solid black. */
+ pattern = black_pattern;
- if (style->stroke_pattern)
- cairo_set_source (cr, style->stroke_pattern);
- else
- cairo_set_source (cr, black_pattern);
+ /* Check if the canvas has a default stroke pattern set. */
+ if (simple->canvas && simple->canvas->style
+ && (simple->canvas->style->mask & GOO_CANVAS_STYLE_STROKE_PATTERN))
+ pattern = simple->canvas->style->stroke_pattern;
- if (style->op != CAIRO_OPERATOR_OVER)
- cairo_set_operator (cr, style->op);
+ /* Check if the item has its own pattern set, which overrides the default. */
+ if (style && (style->mask & GOO_CANVAS_STYLE_STROKE_PATTERN))
+ pattern = style->stroke_pattern;
- if (style->antialias != CAIRO_ANTIALIAS_GRAY)
- cairo_set_antialias (cr, style->antialias);
+ /* Set the pattern. */
+ if (pattern)
+ cairo_set_source (cr, pattern);
- /* Determine the basic line width. */
- if (style->line_width >= 0.0)
- line_width = style->line_width;
- else
- line_width = cairo_get_line_width (cr);
+ /* If the items has a style, use the settings. Note that the default canvas
+ style settings will have already been applied, so we don't need to worry
+ about them here. */
+ if (style)
+ {
+ if (style->mask & GOO_CANVAS_STYLE_OPERATOR)
+ cairo_set_operator (cr, style->op);
- /* Add on the tolerance, when calculating bounds and hit-testing. */
- if (op == GOO_CANVAS_OPERATION_UPDATE
- || op == GOO_CANVAS_OPERATION_GET_ITEMS_AT)
- line_width += style->line_width_tolerance;
+ if (style->mask & GOO_CANVAS_STYLE_ANTIALIAS)
+ cairo_set_antialias (cr, style->antialias);
- /* If the line width is supposed to be unscaled, try to reverse the effects
- of the canvas scale. But only when painting and hit-testing. */
- if ((op == GOO_CANVAS_OPERATION_PAINT
- || op == GOO_CANVAS_OPERATION_GET_ITEMS_AT)
- && style->line_width_is_unscaled && scale > 1.0)
- line_width /= scale;
+ /* Determine the basic line width. */
+ if (style->mask & GOO_CANVAS_STYLE_LINE_WIDTH)
+ line_width = style->line_width;
+ else
+ line_width = cairo_get_line_width (cr);
- /* Set the line width. */
- cairo_set_line_width (cr, line_width);
+ /* Add on the tolerance, when calculating bounds and hit-testing. */
+ if ((op == GOO_CANVAS_OPERATION_UPDATE
+ || op == GOO_CANVAS_OPERATION_GET_ITEMS_AT)
+ && (style->mask & GOO_CANVAS_STYLE_LINE_WIDTH_TOLERANCE))
+ line_width += style->line_width_tolerance;
- if (style->line_cap != CAIRO_LINE_CAP_BUTT)
- cairo_set_line_cap (cr, style->line_cap);
+ /* If the line width is supposed to be unscaled, try to reverse the
+ effects of the canvas scale. But only when painting and hit-testing. */
+ if ((op == GOO_CANVAS_OPERATION_PAINT
+ || op == GOO_CANVAS_OPERATION_GET_ITEMS_AT)
+ && (style->mask & GOO_CANVAS_STYLE_LINE_WIDTH_IS_UNSCALED)
+ && style->line_width_is_unscaled && scale > 1.0)
+ line_width /= scale;
- if (style->line_join != CAIRO_LINE_JOIN_MITER)
- cairo_set_line_join (cr, style->line_join);
+ /* Set the line width. */
+ cairo_set_line_width (cr, line_width);
- if (style->line_join_miter_limit != 10.0)
- cairo_set_miter_limit (cr, style->line_join_miter_limit);
+ if (style->mask & GOO_CANVAS_STYLE_LINE_CAP)
+ cairo_set_line_cap (cr, style->line_cap);
- if (style->dash)
- cairo_set_dash (cr, style->dash->dashes, style->dash->num_dashes,
- style->dash->dash_offset);
+ if (style->mask & GOO_CANVAS_STYLE_LINE_JOIN)
+ cairo_set_line_join (cr, style->line_join);
- /* If the style pattern has been explicitly set to NULL return FALSE, as no
- stroke is wanted. */
- if (style->stroke_pattern_set && !style->stroke_pattern)
- return FALSE;
+ if (style->mask & GOO_CANVAS_STYLE_LINE_JOIN_MITER_LIMIT)
+ cairo_set_miter_limit (cr, style->line_join_miter_limit);
- return TRUE;
+ if (style->mask & GOO_CANVAS_STYLE_LINE_DASH)
+ {
+ if (style->dash)
+ cairo_set_dash (cr, style->dash->dashes, style->dash->num_dashes,
+ style->dash->dash_offset);
+ else
+ cairo_set_dash (cr, NULL, 0, 0.0);
+ }
+ }
+
+ return pattern ? TRUE : FALSE;
}
@@ -1667,24 +1693,37 @@ goo_canvas_item_simple_set_fill_options (GooCanvasItemSimple *simple,
cairo_t *cr)
{
GooCanvasStyle *style = simple->style;
+ cairo_pattern_t *pattern = NULL;
- /* If no style is set, just return FALSE as no fill is needed. */
- if (!style)
- return FALSE;
+ /* Check if the canvas has a default fill pattern set. */
+ if (simple->canvas && simple->canvas->style
+ && (simple->canvas->style->mask & GOO_CANVAS_STYLE_FILL_PATTERN))
+ pattern = simple->canvas->style->fill_pattern;
- if (style->fill_pattern)
- cairo_set_source (cr, style->fill_pattern);
+ /* Check if the item has its own pattern set, which overrides the default. */
+ if (style && (style->mask & GOO_CANVAS_STYLE_FILL_PATTERN))
+ pattern = style->fill_pattern;
- if (style->op != CAIRO_OPERATOR_OVER)
- cairo_set_operator (cr, style->op);
+ /* Set the pattern. */
+ if (pattern)
+ cairo_set_source (cr, pattern);
- if (style->antialias != CAIRO_ANTIALIAS_GRAY)
- cairo_set_antialias (cr, style->antialias);
+ /* If the items has a style, use the settings. Note that the default canvas
+ style settings will have already been applied, so we don't need to worry
+ about them here. */
+ if (style)
+ {
+ if (style->mask & GOO_CANVAS_STYLE_OPERATOR)
+ cairo_set_operator (cr, style->op);
- if (style->fill_rule != CAIRO_FILL_RULE_WINDING)
- cairo_set_fill_rule (cr, style->fill_rule);
+ if (style->mask & GOO_CANVAS_STYLE_ANTIALIAS)
+ cairo_set_antialias (cr, style->antialias);
+
+ if (style->mask & GOO_CANVAS_STYLE_FILL_RULE)
+ cairo_set_fill_rule (cr, style->fill_rule);
+ }
- return style->fill_pattern ? TRUE : FALSE;
+ return pattern ? TRUE : FALSE;
}
diff --git a/src/goocanvasstyle.c b/src/goocanvasstyle.c
index d23ea9a..1dfa1bd 100644
--- a/src/goocanvasstyle.c
+++ b/src/goocanvasstyle.c
@@ -9,6 +9,7 @@
#include <gtk/gtk.h>
#include "goocanvasstyle.h"
#include "goocanvasprivate.h"
+#include "goocanvasenumtypes.h"
G_DEFINE_TYPE (GooCanvasStyle, goo_canvas_style, G_TYPE_OBJECT)
@@ -44,7 +45,10 @@ enum {
PROP_STROKE_PIXBUF,
PROP_FILL_COLOR,
PROP_FILL_COLOR_RGBA,
- PROP_FILL_PIXBUF
+ PROP_FILL_PIXBUF,
+
+ /* The mask of style properties that have been set. */
+ PROP_MASK
};
@@ -57,19 +61,19 @@ goo_canvas_style_init (GooCanvasStyle *style)
style->dash = NULL;
style->font_desc = NULL;
- style->line_width = -1.0;
+ style->line_width = 2.0;
style->line_width_tolerance = 0.0;
style->line_join_miter_limit = 10.0;
- style->line_width_is_unscaled = FALSE;
- style->stroke_pattern_set = FALSE;
- style->fill_pattern_set = FALSE;
+ style->mask = 0;
+
style->op = CAIRO_OPERATOR_OVER;
style->antialias = CAIRO_ANTIALIAS_GRAY;
style->fill_rule = CAIRO_FILL_RULE_WINDING;
style->line_cap = CAIRO_LINE_CAP_BUTT;
style->line_join = CAIRO_LINE_JOIN_MITER;
style->hint_metrics = CAIRO_HINT_METRICS_OFF;
+ style->line_width_is_unscaled = FALSE;
}
@@ -102,8 +106,9 @@ goo_canvas_style_copy (GooCanvasStyle* style)
copy->line_width = style->line_width;
copy->line_width_tolerance = style->line_width_tolerance;
copy->line_join_miter_limit = style->line_join_miter_limit;
- copy->stroke_pattern_set = style->stroke_pattern_set;
- copy->fill_pattern_set = style->fill_pattern_set;
+
+ copy->mask = style->mask;
+
copy->op = style->op;
copy->antialias = style->antialias;
copy->fill_rule = style->fill_rule;
@@ -213,6 +218,10 @@ goo_canvas_style_get_property (GObject *object,
goo_canvas_get_rgba_value_from_pattern (style->fill_pattern, value);
break;
+ case PROP_MASK:
+ g_value_set_flags (value, style->mask);
+ break;
+
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@@ -227,7 +236,7 @@ goo_canvas_style_set_stroke_pattern (GooCanvasStyle *style,
cairo_pattern_destroy (style->stroke_pattern);
style->stroke_pattern = pattern;
cairo_pattern_reference (style->stroke_pattern);
- style->stroke_pattern_set = TRUE;
+ style->mask |= GOO_CANVAS_STYLE_STROKE_PATTERN;
}
@@ -238,7 +247,7 @@ goo_canvas_style_set_fill_pattern (GooCanvasStyle *style,
cairo_pattern_destroy (style->fill_pattern);
style->fill_pattern = pattern;
cairo_pattern_reference (style->fill_pattern);
- style->fill_pattern_set = TRUE;
+ style->mask |= GOO_CANVAS_STYLE_FILL_PATTERN;
}
@@ -264,37 +273,47 @@ goo_canvas_style_set_property (GObject *object,
break;
case PROP_FILL_RULE:
style->fill_rule = g_value_get_enum (value);
+ style->mask |= GOO_CANVAS_STYLE_FILL_RULE;
break;
case PROP_OPERATOR:
style->op = g_value_get_enum (value);
+ style->mask |= GOO_CANVAS_STYLE_OPERATOR;
break;
case PROP_ANTIALIAS:
style->antialias = g_value_get_enum (value);
+ style->mask |= GOO_CANVAS_STYLE_ANTIALIAS;
break;
/* Line style & width properties. */
case PROP_LINE_WIDTH:
style->line_width = g_value_get_double (value);
+ style->mask |= GOO_CANVAS_STYLE_LINE_WIDTH;
break;
case PROP_LINE_WIDTH_TOLERANCE:
style->line_width_tolerance = g_value_get_double (value);
+ style->mask |= GOO_CANVAS_STYLE_LINE_WIDTH_TOLERANCE;
break;
case PROP_LINE_WIDTH_IS_UNSCALED:
style->line_width_is_unscaled = g_value_get_boolean (value);
+ style->mask |= GOO_CANVAS_STYLE_LINE_WIDTH_IS_UNSCALED;
break;
case PROP_LINE_CAP:
style->line_cap = g_value_get_enum (value);
+ style->mask |= GOO_CANVAS_STYLE_LINE_CAP;
break;
case PROP_LINE_JOIN:
style->line_join = g_value_get_enum (value);
+ style->mask |= GOO_CANVAS_STYLE_LINE_JOIN;
break;
case PROP_LINE_JOIN_MITER_LIMIT:
style->line_join_miter_limit = g_value_get_double (value);
+ style->mask |= GOO_CANVAS_STYLE_LINE_JOIN_MITER_LIMIT;
break;
case PROP_LINE_DASH:
goo_canvas_line_dash_unref (style->dash);
style->dash = g_value_get_boxed (value);
goo_canvas_line_dash_ref (style->dash);
+ style->mask |= GOO_CANVAS_STYLE_LINE_DASH;
break;
/* Font properties. */
@@ -306,6 +325,7 @@ goo_canvas_style_set_property (GObject *object,
style->font_desc = pango_font_description_from_string (font_name);
else
style->font_desc = NULL;
+ style->mask |= GOO_CANVAS_STYLE_FONT_DESCRIPTION;
break;
case PROP_FONT_DESC:
if (style->font_desc)
@@ -315,9 +335,11 @@ goo_canvas_style_set_property (GObject *object,
style->font_desc = pango_font_description_copy (font_desc);
else
style->font_desc = NULL;
+ style->mask |= GOO_CANVAS_STYLE_FONT_DESCRIPTION;
break;
case PROP_HINT_METRICS:
style->hint_metrics = g_value_get_enum (value);
+ style->mask |= GOO_CANVAS_STYLE_HINT_METRICS;
break;
/* Convenience properties. */
@@ -353,6 +375,10 @@ goo_canvas_style_set_property (GObject *object,
cairo_pattern_destroy (pattern);
break;
+ case PROP_MASK:
+ style->mask = g_value_get_flags (value);
+ break;
+
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@@ -413,9 +439,8 @@ goo_canvas_style_class_init (GooCanvasStyleClass *klass)
g_object_class_install_property (gobject_class, PROP_LINE_WIDTH,
g_param_spec_double ("line-width",
_("Line Width"),
- _("The line width to use for the item's perimeter, or -1 to use the default line width"),
- -G_MAXDOUBLE,
- G_MAXDOUBLE, -1.0,
+ _("The line width to use for the item's perimeter"),
+ 0.0, G_MAXDOUBLE, 2.0,
G_PARAM_READWRITE));
g_object_class_install_property (gobject_class, PROP_LINE_WIDTH_TOLERANCE,
@@ -527,6 +552,14 @@ goo_canvas_style_class_init (GooCanvasStyleClass *klass)
_("The pixbuf to use to paint the interior of the item. To disable painting set the 'fill-pattern' property to NULL"),
GDK_TYPE_PIXBUF,
G_PARAM_WRITABLE));
+
+ g_object_class_install_property (gobject_class, PROP_MASK,
+ g_param_spec_flags ("mask",
+ _("Mask"),
+ _("The mask of style properties that are currently set"),
+ GOO_TYPE_CANVAS_STYLE_VALUES_MASK,
+ 0,
+ G_PARAM_READWRITE));
}
diff --git a/src/goocanvasstyle.h b/src/goocanvasstyle.h
index c8dfbc6..9dff7c3 100644
--- a/src/goocanvasstyle.h
+++ b/src/goocanvasstyle.h
@@ -13,6 +13,47 @@
G_BEGIN_DECLS
+/**
+ * GooCanvasStyleValuesMask
+ * @GOO_CANVAS_STYLE_STROKE_PATTERN: the stroke pattern has been set.
+ * @GOO_CANVAS_STYLE_FILL_PATTERN: the fill pattern has been set.
+ * @GOO_CANVAS_STYLE_FILL_RULE: the fill rule has been set.
+ * @GOO_CANVAS_STYLE_OPERATOR: the operator has been set.
+ * @GOO_CANVAS_STYLE_ANTIALIAS: the antialias setting has been set.
+ * @GOO_CANVAS_STYLE_LINE_WIDTH: the line width has been set.
+ * @GOO_CANVAS_STYLE_LINE_WIDTH_TOLERANCE: the line width tolerance has been set.
+ * @GOO_CANVAS_STYLE_LINE_WIDTH_IS_UNSCALED: the line width is unscaled flag has been set.
+ * @GOO_CANVAS_STYLE_LINE_CAP: the line cap style has been set.
+ * @GOO_CANVAS_STYLE_LINE_JOIN: the line join style has been set.
+ * @GOO_CANVAS_STYLE_LINE_JOIN_MITER_LIMIT: the miter limit of line joins has
+ * been set.
+ * @GOO_CANVAS_STYLE_LINE_DASH: the line dash pattern has been set.
+ * @GOO_CANVAS_STYLE_FONT_DESCRIPTION: the font description has been set.
+ * @GOO_CANVAS_STYLE_HINT_METRICS: the hint metrics setting has been set.
+ *
+ * Specifies which fields of a #GooCanvasStyle have been set.
+ */
+typedef enum
+{
+ GOO_CANVAS_STYLE_STROKE_PATTERN = 1 << 0,
+ GOO_CANVAS_STYLE_FILL_PATTERN = 1 << 1,
+ GOO_CANVAS_STYLE_FILL_RULE = 1 << 2,
+ GOO_CANVAS_STYLE_OPERATOR = 1 << 3,
+ GOO_CANVAS_STYLE_ANTIALIAS = 1 << 4,
+
+ GOO_CANVAS_STYLE_LINE_WIDTH = 1 << 5,
+ GOO_CANVAS_STYLE_LINE_WIDTH_TOLERANCE = 1 << 6,
+ GOO_CANVAS_STYLE_LINE_WIDTH_IS_UNSCALED = 1 << 7,
+ GOO_CANVAS_STYLE_LINE_CAP = 1 << 8,
+ GOO_CANVAS_STYLE_LINE_JOIN = 1 << 9,
+ GOO_CANVAS_STYLE_LINE_JOIN_MITER_LIMIT = 1 << 10,
+ GOO_CANVAS_STYLE_LINE_DASH = 1 << 11,
+
+ GOO_CANVAS_STYLE_FONT_DESCRIPTION = 1 << 12,
+ GOO_CANVAS_STYLE_HINT_METRICS = 1 << 13
+} GooCanvasStyleValuesMask;
+
+
#define GOO_TYPE_CANVAS_STYLE (goo_canvas_style_get_type ())
#define GOO_CANVAS_STYLE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GOO_TYPE_CANVAS_STYLE, GooCanvasStyle))
#define GOO_CANVAS_STYLE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GOO_TYPE_CANVAS_STYLE, GooCanvasStyleClass))
@@ -39,8 +80,10 @@ struct _GooCanvasStyle
gdouble line_width_tolerance;
gdouble line_join_miter_limit;
- guint stroke_pattern_set : 1;
- guint fill_pattern_set : 1;
+ /* This specifies which fields are actually set. If the STROKE_PATTERN bit
+ is set, and stroke_pattern is NULL, no stroke will be drawn. */
+ GooCanvasStyleValuesMask mask;
+
cairo_operator_t op : 6;
cairo_antialias_t antialias : 4;
cairo_fill_rule_t fill_rule : 3;
diff --git a/src/goocanvastext.c b/src/goocanvastext.c
index bd2bdf8..e13b556 100644
--- a/src/goocanvastext.c
+++ b/src/goocanvastext.c
@@ -492,7 +492,8 @@ goo_canvas_text_is_unpainted (GooCanvasText *text)
GooCanvasStyle *style = simple->style;
/* We only return TRUE if the fill pattern is explicitly set to NULL. */
- if (style && style->fill_pattern_set && !style->fill_pattern)
+ if (style && style->mask & GOO_CANVAS_STYLE_FILL_PATTERN
+ && !style->fill_pattern)
return TRUE;
return FALSE;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]