diff --git a/src/pen-context.cpp b/src/pen-context.cpp
index 1762d668c00d3ba7ccffaffe10b47b25b3eacaf8..1447173320c6cfd0b8b578eb168d65b23a824637 100644 (file)
--- a/src/pen-context.cpp
+++ b/src/pen-context.cpp
static int pen_next_paraxial_direction(const SPPenContext *const pc, Geom::Point const &pt, Geom::Point const &origin, guint state);
static void pen_set_to_nearest_horiz_vert(const SPPenContext *const pc, Geom::Point &pt, guint const state);
-static Geom::Point pen_get_intermediate_horiz_vert(const SPPenContext *const pc, Geom::Point const &pt, guint const state);
static int pen_last_paraxial_dir = 0; // last used direction in horizontal/vertical mode; 0 = horizontal, 1 = vertical
pc->c1 = NULL;
pc->cl0 = NULL;
pc->cl1 = NULL;
-
+
pc->events_disabled = 0;
pc->num_clicks = 0;
}
static void
-pen_cancel (SPPenContext *const pc)
+pen_cancel (SPPenContext *const pc)
{
pc->num_clicks = 0;
pc->state = SP_PEN_CONTEXT_STOP;
{
SPPenContext *pc = SP_PEN_CONTEXT(ec);
+ sp_event_context_discard_delayed_snap_event(ec);
+
if (pc->npoints != 0) {
pen_cancel (pc);
}
@@ -332,7 +333,7 @@ spdc_endpoint_snap_handle(SPPenContext const *const pc, Geom::Point &p, guint co
}
}
-static gint
+static gint
sp_pen_context_item_handler(SPEventContext *ec, SPItem *item, GdkEvent *event)
{
SPPenContext *const pc = SP_PEN_CONTEXT(ec);
@@ -417,7 +418,7 @@ static gint pen_handle_button_press(SPPenContext *const pc, GdkEventButton const
SPDrawContext * const dc = SP_DRAW_CONTEXT(pc);
SPDesktop * const desktop = SP_EVENT_CONTEXT_DESKTOP(dc);
Geom::Point const event_w(bevent.x, bevent.y);
- Geom::Point const event_dt(desktop->w2d(event_w));
+ Geom::Point event_dt(desktop->w2d(event_w));
SPEventContext *event_context = SP_EVENT_CONTEXT(pc);
gint ret = FALSE;
@@ -453,7 +454,7 @@ static gint pen_handle_button_press(SPPenContext *const pc, GdkEventButton const
case SP_PEN_CONTEXT_CLOSE:
break;
case SP_PEN_CONTEXT_STOP:
- /* This is allowed, if we just cancelled curve */
+ /* This is allowed, if we just canceled curve */
pc->state = SP_PEN_CONTEXT_POINT;
break;
default:
@@ -463,22 +464,28 @@ static gint pen_handle_button_press(SPPenContext *const pc, GdkEventButton const
case SP_PEN_CONTEXT_MODE_DRAG:
switch (pc->state) {
case SP_PEN_CONTEXT_STOP:
- /* This is allowed, if we just cancelled curve */
+ /* This is allowed, if we just canceled curve */
case SP_PEN_CONTEXT_POINT:
if (pc->npoints == 0) {
- if (bevent.state & GDK_CONTROL_MASK) {
- spdc_create_single_dot(event_context, event_dt, "/tools/freehand/pen", bevent.state);
- ret = TRUE;
- break;
- }
+ Geom::Point p;
+ if ((bevent.state & GDK_CONTROL_MASK) && (pc->polylines_only || pc->polylines_paraxial)) {
+ p = event_dt;
+ if (!(bevent.state & GDK_SHIFT_MASK)) {
+ SnapManager &m = desktop->namedview->snap_manager;
+ m.setup(desktop);
+ m.freeSnapReturnByRef(Inkscape::SnapPreferences::SNAPPOINT_NODE, p, Inkscape::SNAPSOURCE_HANDLE);
+ }
+ spdc_create_single_dot(event_context, p, "/tools/freehand/pen", bevent.state);
+ ret = TRUE;
+ break;
+ }
// TODO: Perhaps it would be nicer to rearrange the following case
// distinction so that the case of a waiting LPE is treated separately
/* Set start anchor */
pc->sa = anchor;
- Geom::Point p;
if (anchor && !sp_pen_context_has_waiting_LPE(pc)) {
/* Adjust point to anchor if needed; if we have a waiting LPE, we need
a fresh path to be created so don't continue an existing one */
@@ -531,9 +538,6 @@ static gint pen_handle_button_press(SPPenContext *const pc, GdkEventButton const
p = event_dt;
spdc_endpoint_snap(pc, p, bevent.state); /* Snap node only if not hitting anchor. */
spdc_pen_set_subsequent_point(pc, p, true);
- if (pc->polylines_only) {
- spdc_pen_finish_segment(pc, p, bevent.state);
- }
}
}
// allow scrolling
return FALSE;
}
-
+
if (pc->events_disabled) {
// skip motion events if pen events are disabled
return FALSE;
ret = TRUE;
break;
case SP_PEN_CONTEXT_STOP:
- /* This is allowed, if we just cancelled curve */
+ /* This is allowed, if we just canceled curve */
pc->state = SP_PEN_CONTEXT_POINT;
ret = TRUE;
break;
@@ -777,10 +781,8 @@ pen_handle_button_release(SPPenContext *const pc, GdkEventButton const &revent)
switch (pc->state) {
case SP_PEN_CONTEXT_POINT:
case SP_PEN_CONTEXT_CONTROL:
- if (!pc->polylines_only) {
- spdc_endpoint_snap(pc, p, revent.state);
- spdc_pen_finish_segment(pc, p, revent.state);
- }
+ spdc_endpoint_snap(pc, p, revent.state);
+ spdc_pen_finish_segment(pc, p, revent.state);
break;
case SP_PEN_CONTEXT_CLOSE:
spdc_endpoint_snap(pc, p, revent.state);
pen_handle_2button_press(SPPenContext *const pc, GdkEventButton const &bevent)
{
gint ret = FALSE;
- if (pc->npoints != 0 && bevent.button != 2) {
+ // only end on LMB double click. Otherwise horizontal scrolling causes ending of the path
+ if (pc->npoints != 0 && bevent.button == 1) {
spdc_pen_finish(pc, FALSE);
ret = TRUE;
}
static gint
pen_handle_key_press(SPPenContext *const pc, GdkEvent *event)
{
- gint ret = FALSE;
+
+ gint ret = FALSE;
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
gdouble const nudge = prefs->getDoubleLimited("/options/nudgedistance/value", 2, 0, 1000); // in px
}
break;
+/* TODO: this is not yet enabled?? looks like some traces of the Geometry tool
case GDK_P:
case GDK_p:
if (MOD__SHIFT_ONLY) {
ret = TRUE;
}
break;
+*/
case GDK_U:
case GDK_u:
* Show the status message for the current line/curve segment.
* This type of message always shows angle/distance as the last
* two parameters ("angle %3.2f°, distance %s").
- */
+ */
static void
spdc_pen_set_angle_distance_status_message(SPPenContext *const pc, Geom::Point const p, int pc_point_to_compare, gchar const *message)
{
pc->num_clicks = 0;
pen_disable_events(pc);
-
+
SPDesktop *const desktop = pc->desktop;
pc->_message_context->clear();
desktop->messageStack()->flash(Inkscape::NORMAL_MESSAGE, _("Drawing finished"));
static void
pen_enable_events(SPPenContext *const pc) {
g_return_if_fail(pc->events_disabled != 0);
-
+
pc->events_disabled--;
}
@@ -1439,17 +1445,6 @@ void pen_set_to_nearest_horiz_vert(const SPPenContext *const pc, Geom::Point &pt
}
}
-Geom::Point pen_get_intermediate_horiz_vert(const SPPenContext *const pc, Geom::Point const &pt)
-{
- Geom::Point const &origin = pc->p[0];
-
- if (pen_last_paraxial_dir == 0) {
- return Geom::Point (origin[Geom::X], pt[Geom::Y]);
- } else {
- return Geom::Point (pt[Geom::X], origin[Geom::Y]);
- }
-}
-
/*
Local Variables:
mode:c++