From: Jim Evins Date: Sat, 4 Dec 2010 04:18:55 +0000 (-0500) Subject: Add some selection slop to barcode and text objects X-Git-Tag: glabels-2_3_1~89 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=dc41a686c30e7e80eb3e54cacba4c2af94e678f8;p=glabels Add some selection slop to barcode and text objects Add a 4 pixel slop area around barcode lines and text glyphs in object_at methods of barcode and text objects. This will hopefully make selecting these objects less frustrating while still allowing selection of background objects through the negative space of these objects. --- diff --git a/src/label-barcode.c b/src/label-barcode.c index f39b2f2b..04cd61a1 100644 --- a/src/label-barcode.c +++ b/src/label-barcode.c @@ -41,6 +41,8 @@ #define HANDLE_OUTLINE_RGBA_ARGS 0.5, 0.5, 0.5, 0.75 #define HANDLE_OUTLINE_WIDTH_PIXELS 2.0 +#define SELECTION_SLOP_PIXELS 4.0 + /*========================================================*/ /* Private types. */ @@ -493,6 +495,7 @@ object_at (glLabelObject *object, glLabelBarcodeStyle *style; glTextNode *text_node; gchar *text; + gdouble scale_x, scale_y; gl_label_object_get_size (object, &w, &h); @@ -526,16 +529,36 @@ object_at (glLabelObject *object, return TRUE; } - } - if (gl_label_object_is_selected (object)) - { - cairo_new_path (cr); - cairo_rectangle (cr, 0, 0, w, h); + scale_x = 1.0; + scale_y = 1.0; + cairo_device_to_user_distance (cr, &scale_x, &scale_y); + + cairo_set_line_width (cr, 2*SELECTION_SLOP_PIXELS*scale_x); + if (cairo_in_stroke (cr, x, y)) { return TRUE; } + + + if (gl_label_object_is_selected (object)) + { + cairo_new_path (cr); + cairo_rectangle (cr, 0, 0, w, h); + + scale_x = 1.0; + scale_y = 1.0; + cairo_device_to_user_distance (cr, &scale_x, &scale_y); + + cairo_set_line_width (cr, (HANDLE_OUTLINE_WIDTH_PIXELS + 2*SELECTION_SLOP_PIXELS)*scale_x); + + if (cairo_in_stroke (cr, x, y)) + { + return TRUE; + } + } + } return FALSE; diff --git a/src/label-text.c b/src/label-text.c index 1cb38ae5..403c7df4 100644 --- a/src/label-text.c +++ b/src/label-text.c @@ -43,6 +43,8 @@ #define HANDLE_OUTLINE_RGBA_ARGS 0.5, 0.5, 0.5, 0.75 #define HANDLE_OUTLINE_WIDTH_PIXELS 2.0 +#define SELECTION_SLOP_PIXELS 4.0 + /*========================================================*/ /* Private types. */ @@ -1203,6 +1205,7 @@ object_at (glLabelObject *object, gdouble y) { gdouble w, h; + gdouble scale_x, scale_y; gl_label_object_get_size (object, &w, &h); @@ -1214,16 +1217,37 @@ object_at (glLabelObject *object, { return TRUE; } - } - if (gl_label_object_is_selected (object)) - { - cairo_new_path (cr); - cairo_rectangle (cr, 0, 0, w, h); + + scale_x = 1.0; + scale_y = 1.0; + cairo_device_to_user_distance (cr, &scale_x, &scale_y); + + cairo_set_line_width (cr, 2*SELECTION_SLOP_PIXELS*scale_x); + if (cairo_in_stroke (cr, x, y)) { return TRUE; } + + + if (gl_label_object_is_selected (object)) + { + cairo_new_path (cr); + cairo_rectangle (cr, 0, 0, w, h); + + scale_x = 1.0; + scale_y = 1.0; + cairo_device_to_user_distance (cr, &scale_x, &scale_y); + + cairo_set_line_width (cr, 2*SELECTION_SLOP_PIXELS*scale_x); + + if (cairo_in_stroke (cr, x, y)) + { + return TRUE; + } + } + } return FALSE;