[glabels] Add some selection slop to barcode and text objects



commit dc41a686c30e7e80eb3e54cacba4c2af94e678f8
Author: Jim Evins <evins snaught com>
Date:   Fri Dec 3 23:18:55 2010 -0500

    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.

 src/label-barcode.c |   33 ++++++++++++++++++++++++++++-----
 src/label-text.c    |   34 +++++++++++++++++++++++++++++-----
 2 files changed, 57 insertions(+), 10 deletions(-)
---
diff --git a/src/label-barcode.c b/src/label-barcode.c
index f39b2f2..04cd61a 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 1cb38ae..403c7df 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;



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]