summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: cc61296)
raw | patch | inline | side by side (parent: cc61296)
author | johncoswell <johncoswell@users.sourceforge.net> | |
Sun, 5 Nov 2006 18:41:15 +0000 (18:41 +0000) | ||
committer | johncoswell <johncoswell@users.sourceforge.net> | |
Sun, 5 Nov 2006 18:41:15 +0000 (18:41 +0000) |
src/node-context.cpp | patch | blob | history | |
src/node-context.h | patch | blob | history |
diff --git a/src/node-context.cpp b/src/node-context.cpp
index 774e0813e5c4da5ceed8fe565a58ec7e10b7c739..e6ea78c624a16e00b763fe8724b9052be42d8606 100644 (file)
--- a/src/node-context.cpp
+++ b/src/node-context.cpp
node_context->rightalt = FALSE;
node_context->leftctrl = FALSE;
node_context->rightctrl = FALSE;
-
+
new (&node_context->sel_changed_connection) sigc::connection();
}
nc->added_node = false;
+ nc->current_state = SP_NODE_CONTEXT_INACTIVE;
+
if (item) {
nc->nodepath = sp_nodepath_new(ec->desktop, item, (prefs_get_int_attribute("tools.nodes", "show_handles", 1) != 0));
if ( nc->nodepath) {
event->button.y);
NR::Point const button_dt(desktop->w2d(button_w));
Inkscape::Rubberband::get()->start(desktop, button_dt);
+ nc->current_state = SP_NODE_CONTEXT_INACTIVE;
desktop->updateNow();
ret = TRUE;
}
&& ( abs( (gint) event->motion.y - event_context->yp ) < event_context->tolerance ) ) {
break; // do not drag if we're within tolerance from origin
}
-
+
// The path went away while dragging; throw away any further motion
// events until the mouse pointer is released.
if (nc->hit && (nc->nodepath == NULL)) {
break;
}
-
+
// Once the user has moved farther than tolerance from the original location
// (indicating they intend to move the object, not click), then always process the
// motion notify coordinates as given (no snapping back to origin)
event_context->within_tolerance = false;
- if (nc->nodepath && nc->hit) {
- NR::Point const delta_w(event->motion.x - nc->curvepoint_event[NR::X],
- event->motion.y - nc->curvepoint_event[NR::Y]);
- NR::Point const delta_dt(desktop->w2d(delta_w));
- sp_nodepath_curve_drag (nc->grab_node, nc->grab_t, delta_dt);
- nc->curvepoint_event[NR::X] = (gint) event->motion.x;
- nc->curvepoint_event[NR::Y] = (gint) event->motion.y;
- gobble_motion_events(GDK_BUTTON1_MASK);
- } else {
- if (Inkscape::Rubberband::get()->is_started()) {
- NR::Point const motion_w(event->motion.x,
- event->motion.y);
- NR::Point const motion_dt(desktop->w2d(motion_w));
- Inkscape::Rubberband::get()->move(motion_dt);
+ // Once we determine what the user is doing (dragging either a node or the
+ // selection rubberband), make sure we continue to perform that operation
+ // until the mouse pointer is lifted.
+ if (nc->current_state == SP_NODE_CONTEXT_INACTIVE) {
+ if (nc->nodepath && nc->hit) {
+ nc->current_state = SP_NODE_CONTEXT_NODE_DRAGGING;
+ } else {
+ nc->current_state = SP_NODE_CONTEXT_RUBBERBAND_DRAGGING;
}
}
+
+ switch (nc->current_state) {
+ case SP_NODE_CONTEXT_NODE_DRAGGING:
+ {
+ NR::Point const delta_w(event->motion.x - nc->curvepoint_event[NR::X],
+ event->motion.y - nc->curvepoint_event[NR::Y]);
+ NR::Point const delta_dt(desktop->w2d(delta_w));
+ sp_nodepath_curve_drag (nc->grab_node, nc->grab_t, delta_dt);
+ nc->curvepoint_event[NR::X] = (gint) event->motion.x;
+ nc->curvepoint_event[NR::Y] = (gint) event->motion.y;
+ gobble_motion_events(GDK_BUTTON1_MASK);
+ break;
+ }
+ case SP_NODE_CONTEXT_RUBBERBAND_DRAGGING:
+ if (Inkscape::Rubberband::get()->is_started()) {
+ NR::Point const motion_w(event->motion.x,
+ event->motion.y);
+ NR::Point const motion_dt(desktop->w2d(motion_w));
+ Inkscape::Rubberband::get()->move(motion_dt);
+ }
+ break;
+ }
+
nc->drag = TRUE;
ret = TRUE;
} else {
nc->rb_escaped = false;
nc->drag = FALSE;
nc->hit = false;
+ nc->current_state = SP_NODE_CONTEXT_INACTIVE;
break;
}
break;
NR::Maybe<NR::Rect> const b = Inkscape::Rubberband::get()->getRectangle();
if (b != NR::Nothing()) {
Inkscape::Rubberband::get()->stop();
+ nc->current_state = SP_NODE_CONTEXT_INACTIVE;
nc->rb_escaped = true;
} else {
if (nc->nodepath && nc->nodepath->selected) {
diff --git a/src/node-context.h b/src/node-context.h
index a9b4beb07614b37402a188dafff64d787230d65a..d5067a66a751dbbdeddff6448ef34ec97682f20a 100644 (file)
--- a/src/node-context.h
+++ b/src/node-context.h
#define SP_IS_NODE_CONTEXT(obj) (GTK_CHECK_TYPE ((obj), SP_TYPE_NODE_CONTEXT))
#define SP_IS_NODE_CONTEXT_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), SP_TYPE_NODE_CONTEXT))
+enum { SP_NODE_CONTEXT_INACTIVE,
+ SP_NODE_CONTEXT_NODE_DRAGGING,
+ SP_NODE_CONTEXT_RUBBERBAND_DRAGGING };
+
class SPNodeContext;
class SPNodeContextClass;
bool cursor_drag;
bool added_node;
+
+ unsigned int current_state;
};
struct SPNodeContextClass {