Code

Status bar tips for VP draggers
[inkscape.git] / src / knot.cpp
index c8d2f2065256800e47f79d6693d8ae1d940ee642..3cc5324d4315f90342e068747f55aaccc1bf12d3 100644 (file)
@@ -31,7 +31,7 @@
 
 
 #define KNOT_EVENT_MASK (GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | \
-                        GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | \
+                        GDK_POINTER_MOTION_MASK | \
                         GDK_KEY_PRESS_MASK | GDK_KEY_RELEASE_MASK)
 
 static bool nograb = false;
@@ -62,7 +62,6 @@ static void sp_knot_init(SPKnot *knot);
 static void sp_knot_dispose(GObject *object);
 
 static int sp_knot_handler(SPCanvasItem *item, GdkEvent *event, SPKnot *knot);
-static void sp_knot_set_flag(SPKnot *knot, guint flag, bool set);
 static void sp_knot_set_ctrl_state(SPKnot *knot);
 
 static GObjectClass *parent_class;
@@ -196,6 +195,7 @@ static void sp_knot_init(SPKnot *knot)
     knot->mode = SP_KNOT_MODE_XOR;
     knot->tip = NULL;
     knot->_event_handler_id = 0;
+    knot->pressure = 0;
 
     knot->fill[SP_KNOT_STATE_NORMAL] = 0xffffff00;
     knot->fill[SP_KNOT_STATE_MOUSEOVER] = 0xff0000ff;
@@ -287,19 +287,19 @@ static int sp_knot_handler(SPCanvasItem *item, GdkEvent *event, SPKnot *knot)
     g_assert(knot != NULL);
     g_assert(SP_IS_KNOT(knot));
 
-    g_object_ref(knot);
-    tolerance = prefs_get_int_attribute_limited("options.dragtolerance", "value", 0, 0, 100);
+    /* Run client universal event handler, if present */
 
     gboolean consumed = FALSE;
 
-    /* Run client universal event handler, if present */
-
     g_signal_emit(knot, knot_signals[EVENT], 0, event, &consumed);
 
     if (consumed) {
         return TRUE;
     }
 
+    g_object_ref(knot);
+    tolerance = prefs_get_int_attribute_limited("options.dragtolerance", "value", 0, 0, 100);
+
     switch (event->type) {
        case GDK_2BUTTON_PRESS:
             if (event->button.button == 1) {
@@ -311,14 +311,15 @@ static int sp_knot_handler(SPCanvasItem *item, GdkEvent *event, SPKnot *knot)
             }
             break;
        case GDK_BUTTON_PRESS:
-            if (event->button.button == 1) {
+            if (event->button.button == 1 && !knot->desktop->event_context->space_panning) {
                 NR::Point const p = knot->desktop->w2d(NR::Point(event->button.x, event->button.y));
                 sp_knot_start_dragging(knot, p, (gint) event->button.x, (gint) event->button.y, event->button.time);
                 consumed = TRUE;
             }
             break;
        case GDK_BUTTON_RELEASE:
-            if (event->button.button == 1) {
+            if (event->button.button == 1 && !knot->desktop->event_context->space_panning) {
+                knot->pressure = 0;
                 if (transform_escaped) {
                     transform_escaped = false;
                     consumed = TRUE;
@@ -346,7 +347,7 @@ static int sp_knot_handler(SPCanvasItem *item, GdkEvent *event, SPKnot *knot)
             }
             break;
        case GDK_MOTION_NOTIFY:
-            if (grabbed) {
+            if (grabbed && !knot->desktop->event_context->space_panning) {
                 consumed = TRUE;
 
                 if ( within_tolerance
@@ -360,6 +361,11 @@ static int sp_knot_handler(SPCanvasItem *item, GdkEvent *event, SPKnot *knot)
                 // motion notify coordinates as given (no snapping back to origin)
                 within_tolerance = false;
 
+                if (gdk_event_get_axis (event, GDK_AXIS_PRESSURE, &knot->pressure))
+                    knot->pressure = CLAMP (knot->pressure, 0, 1);
+                else
+                    knot->pressure = 0.5;
+
                 if (!moved) {
                     g_signal_emit(knot,
                                   knot_signals[GRABBED], 0,
@@ -373,6 +379,7 @@ static int sp_knot_handler(SPCanvasItem *item, GdkEvent *event, SPKnot *knot)
                 NR::Point p = motion_dt - knot->grabbed_rel_pos;
                 sp_knot_request_position (knot, &p, event->motion.state);
                 knot->desktop->scroll_to_point (&motion_dt);
+                knot->desktop->set_coordinate_status(knot->pos); // display the coordinate of knot, not cursor - they may be different!
                 moved = TRUE;
             }
             break;
@@ -582,7 +589,7 @@ NR::Point sp_knot_position(SPKnot const *knot)
 /**
  * Set flag in knot, with side effects.
  */
-static void sp_knot_set_flag(SPKnot *knot, guint flag, bool set)
+void sp_knot_set_flag(SPKnot *knot, guint flag, bool set)
 {
     g_assert(knot != NULL);
     g_assert(SP_IS_KNOT(knot));