diff options
author | Benjamin Franzke <benjaminfranzke@googlemail.com> | 2012-03-31 15:04:44 +0200 |
---|---|---|
committer | Benjamin Franzke <benjaminfranzke@googlemail.com> | 2012-03-31 15:04:44 +0200 |
commit | 6a12f38c470d59d84c0d04378370917aa055bda7 (patch) | |
tree | dc1b630f1e5f71ef44dc0ad643e8bb771dd58b50 | |
parent | 106dcee278f780280d167cfb25a87a383e1fd4ee (diff) | |
download | cv-6a12f38c470d59d84c0d04378370917aa055bda7.tar.gz cv-6a12f38c470d59d84c0d04378370917aa055bda7.tar.bz2 cv-6a12f38c470d59d84c0d04378370917aa055bda7.zip |
roi: Use gtk_render_{frame,background} for rubberband
-rw-r--r-- | roi.c | 43 |
1 files changed, 20 insertions, 23 deletions
@@ -111,9 +111,10 @@ do_roi(struct roi *roi) gboolean motion_notify_event(GtkWidget *widget, GdkEventMotion *event, gpointer userdata) { + GtkStyleContext *context; struct roi *roi = userdata; GdkWindow *win = gtk_widget_get_window(widget); - GdkRectangle rect; + cairo_rectangle_t rect; cairo_t *cr; rect.x = roi->motion.x; @@ -122,40 +123,36 @@ motion_notify_event(GtkWidget *widget, GdkEventMotion *event, gpointer userdata) rect.height = event->y - roi->motion.y; /* gdk_window_begin_paint_rect(win, &rect); */ - cr = gdk_cairo_create(win); - cairo_set_line_width(cr, 2.0); + context = gtk_widget_get_style_context(widget); + gtk_style_context_save(context); + gtk_style_context_add_class(context, GTK_STYLE_CLASS_RUBBERBAND); + + cr = gdk_cairo_create(win); + cairo_save(cr); gdk_cairo_set_source_pixbuf(cr, roi->input, 0, 0); cairo_rectangle(cr, roi->previous_draw.x, roi->previous_draw.y, - roi->previous_draw.width, - roi->previous_draw.height); - cairo_fill_preserve(cr); - cairo_stroke(cr); + roi->previous_draw.width+1, + roi->previous_draw.height+1); + cairo_clip(cr); + cairo_paint(cr); + cairo_restore(cr); roi->previous_draw.x = roi->motion.x; roi->previous_draw.y = roi->motion.y; roi->previous_draw.width = event->x - roi->motion.x; roi->previous_draw.height = event->y - roi->motion.y; -#if 0 - const double dashed[] = {1.0}; - cairo_set_dash(cr, dashed, 1, 0); -#endif - - cairo_rectangle(cr, - roi->previous_draw.x, - roi->previous_draw.y, - roi->previous_draw.width, - roi->previous_draw.height); - - cairo_set_source_rgba(cr, 0.0, 0.0, 0.5, 0.3); - cairo_stroke_preserve(cr); - cairo_set_source_rgba(cr, 0.0, 0.0, 0.5, 0.5); - cairo_fill(cr); - + cairo_rectangle(cr, rect.x, rect.y, rect.width, rect.height); + cairo_clip(cr); + gtk_render_background(context, cr, + rect.x, rect.y, rect.width, rect.height); + gtk_render_frame(context, cr, + rect.x, rect.y, rect.width, rect.height); cairo_destroy(cr); + gtk_style_context_restore(context); /* gdk_window_end_paint(win); */ return TRUE; |