summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--roi.c43
1 files changed, 20 insertions, 23 deletions
diff --git a/roi.c b/roi.c
index 1fac018..d8d9912 100644
--- a/roi.c
+++ b/roi.c
@@ -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;