diff options
author | Jasmine Hassan <[email protected]> | 2012-10-18 15:24:25 +0200 |
---|---|---|
committer | Jasmine Hassan <[email protected]> | 2012-11-14 09:42:33 +0200 |
commit | 250d31f0d9f533dee96c91859c54883179a896eb (patch) | |
tree | 803a0de24e012d2fbbfad0fb471f7d3cc348ec6b | |
parent | d602f60fa4df0d2913e2d6b45f32c4bb1020583a (diff) | |
download | caja-250d31f0d9f533dee96c91859c54883179a896eb.tar.bz2 caja-250d31f0d9f533dee96c91859c54883179a896eb.tar.xz |
[eel] add an 'outline-stippling' property to the rect item
http://git.gnome.org/browse/nautilus/commit/?id=b453aaacb0b17392eacacd8a9e378b7227da6413
-rw-r--r-- | eel/eel-canvas-rect-ellipse.c | 24 | ||||
-rw-r--r-- | eel/eel-canvas-rect-ellipse.h | 2 |
2 files changed, 26 insertions, 0 deletions
diff --git a/eel/eel-canvas-rect-ellipse.c b/eel/eel-canvas-rect-ellipse.c index 7e2a6df8..9d738243 100644 --- a/eel/eel-canvas-rect-ellipse.c +++ b/eel/eel-canvas-rect-ellipse.c @@ -60,6 +60,7 @@ enum PROP_OUTLINE_COLOR, PROP_OUTLINE_COLOR_GDK, PROP_OUTLINE_COLOR_RGBA, + PROP_OUTLINE_STIPPLING, PROP_WIDTH_PIXELS, PROP_WIDTH_UNITS }; @@ -204,6 +205,11 @@ eel_canvas_re_class_init (EelCanvasREClass *klass) g_param_spec_uint ("outline-color-rgba", NULL, NULL, 0, G_MAXUINT, 0, G_PARAM_READWRITE)); + g_object_class_install_property + (gobject_class, + PROP_OUTLINE_STIPPLING, + g_param_spec_boolean ("outline-stippling", NULL, NULL, + FALSE, G_PARAM_READWRITE)); g_object_class_install_property (gobject_class, PROP_WIDTH_PIXELS, @@ -441,6 +447,12 @@ eel_canvas_re_set_property (GObject *object, eel_canvas_item_request_redraw (item); break; + case PROP_OUTLINE_STIPPLING: + re->outline_stippling = g_value_get_boolean (value); + + eel_canvas_item_request_redraw (item); + break; + case PROP_WIDTH_PIXELS: re->width = g_value_get_uint (value); re->width_pixels = TRUE; @@ -526,6 +538,10 @@ eel_canvas_re_get_property (GObject *object, g_value_set_uint (value, re->outline_color); break; + case PROP_OUTLINE_STIPPLING: + g_value_set_boolean (value, re->outline_stippling); + break; + default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec); break; @@ -751,6 +767,8 @@ eel_canvas_set_source_color (cairo_t *cr, ((rgba >> 0) & 0xff) / 255.); } +#define DASH_ON 0.8 +#define DASH_OFF 1.7 static void eel_canvas_rect_draw (EelCanvasItem *item, GdkDrawable *drawable, GdkEventExpose *expose) { @@ -802,6 +820,12 @@ eel_canvas_rect_draw (EelCanvasItem *item, GdkDrawable *drawable, GdkEventExpose cairo_set_line_width (cr, (int) (re->width * re->item.canvas->pixels_per_unit + 0.5)); } + if (re->outline_stippling) { + double dash[2] = { DASH_ON, DASH_OFF }; + + cairo_set_dash (cr, dash, G_N_ELEMENTS (dash), 0); + } + cairo_rectangle (cr, cx1 + 0.5, cy1 + 0.5, cx2 - cx1, diff --git a/eel/eel-canvas-rect-ellipse.h b/eel/eel-canvas-rect-ellipse.h index 7166df8f..aaccf560 100644 --- a/eel/eel-canvas-rect-ellipse.h +++ b/eel/eel-canvas-rect-ellipse.h @@ -87,6 +87,8 @@ extern "C" { guint fill_color; /* Fill color, RGBA */ guint outline_color; /* Outline color, RGBA */ + gboolean outline_stippling; + /* Configuration flags */ unsigned int fill_set : 1; /* Is fill color set? */ |