]> git.sur5r.net Git - glabels/commitdiff
Add some selection slop to barcode and text objects
authorJim Evins <evins@snaught.com>
Sat, 4 Dec 2010 04:18:55 +0000 (23:18 -0500)
committerJim Evins <evins@snaught.com>
Sat, 4 Dec 2010 04:18:55 +0000 (23:18 -0500)
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.

src/label-barcode.c
src/label-text.c

index f39b2f2b72706aeaf8a9d5b4fbe19887cf1c6fcb..04cd61a1a6ecb94dee28f0f761a67938041ce8bc 100644 (file)
@@ -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;
index 1cb38ae5c9ea490beba2219f9300e14f42c5e26e..403c7df49fe88bce8667074ec5ed1628ed0a402a 100644 (file)
@@ -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;