From 31bb8269c26a781036448ed8f8cd93cc84fb2118 Mon Sep 17 00:00:00 2001 From: Krzysztof Kosi??ski Date: Sun, 29 Nov 2009 16:33:18 +0100 Subject: First GSoC node tool commit to Bazaar (bzr r8846.1.1) --- src/display/sp-canvas-util.cpp | 7 ++++--- src/display/sp-canvas.cpp | 28 ++++++++++++++++++++-------- src/display/sp-canvas.h | 1 + 3 files changed, 25 insertions(+), 11 deletions(-) (limited to 'src/display') diff --git a/src/display/sp-canvas-util.cpp b/src/display/sp-canvas-util.cpp index 30cd0dfa0..a23b157df 100644 --- a/src/display/sp-canvas-util.cpp +++ b/src/display/sp-canvas-util.cpp @@ -112,10 +112,11 @@ void sp_canvas_item_move_to_z (SPCanvasItem * item, gint z) if (z == current_z) return; - if (z > current_z) + if (z > current_z) { sp_canvas_item_raise (item, z - current_z); - - sp_canvas_item_lower (item, current_z - z); + } else { + sp_canvas_item_lower (item, current_z - z); + } } gint diff --git a/src/display/sp-canvas.cpp b/src/display/sp-canvas.cpp index aee53838f..6d996fbe2 100644 --- a/src/display/sp-canvas.cpp +++ b/src/display/sp-canvas.cpp @@ -103,6 +103,7 @@ static void group_remove (SPCanvasGroup *group, SPCanvasItem *item); /* SPCanvasItem */ enum {ITEM_EVENT, ITEM_LAST_SIGNAL}; +enum {PROP_0, PROP_VISIBLE}; static void sp_canvas_request_update (SPCanvas *canvas); @@ -113,12 +114,11 @@ static void sp_canvas_item_init (SPCanvasItem *item); static void sp_canvas_item_dispose (GObject *object); static void sp_canvas_item_construct (SPCanvasItem *item, SPCanvasGroup *parent, gchar const *first_arg_name, va_list args); + static int emit_event (SPCanvas *canvas, GdkEvent *event); static guint item_signals[ITEM_LAST_SIGNAL] = { 0 }; -static GtkObjectClass *item_parent_class; - /** * Registers the SPCanvasItem class with Glib and returns its type number. */ @@ -151,9 +151,6 @@ sp_canvas_item_class_init (SPCanvasItemClass *klass) { GObjectClass *object_class = (GObjectClass *) klass; - /* fixme: Derive from GObject */ - item_parent_class = (GtkObjectClass*)gtk_type_class (GTK_TYPE_OBJECT); - item_signals[ITEM_EVENT] = g_signal_new ("event", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST, @@ -172,6 +169,9 @@ sp_canvas_item_class_init (SPCanvasItemClass *klass) static void sp_canvas_item_init (SPCanvasItem *item) { + // TODO items should not be visible on creation - this causes kludges with items + // that should be initially invisible; examples of such items: node handles, the CtrlRect + // used for rubberbanding, path outline, etc. item->flags |= SP_CANVAS_ITEM_VISIBLE; item->xform = Geom::Matrix(Geom::identity()); } @@ -277,7 +277,7 @@ sp_canvas_item_dispose (GObject *object) group_remove (SP_CANVAS_GROUP (item->parent), item); } - G_OBJECT_CLASS (item_parent_class)->dispose (object); + G_OBJECT_CLASS (g_type_class_peek(g_type_parent(sp_canvas_item_get_type())))->dispose (object); } /** @@ -477,6 +477,13 @@ sp_canvas_item_lower (SPCanvasItem *item, int positions) item->canvas->need_repick = TRUE; } +bool +sp_canvas_item_is_visible (SPCanvasItem *item) +{ + return item->flags & SP_CANVAS_ITEM_VISIBLE; +} + + /** * Sets visible flag on item and requests a redraw. */ @@ -542,8 +549,13 @@ sp_canvas_item_grab (SPCanvasItem *item, guint event_mask, GdkCursor *cursor, gu if (item->canvas->grabbed_item) return -1; - if (!(item->flags & SP_CANVAS_ITEM_VISIBLE)) - return -1; + // This test disallows grabbing events by an invisible item, which may be useful + // sometimes. An example is the hidden control point used for the selector component, + // where it is used for object selection and rubberbanding. There seems to be nothing + // preventing this except this test, so I removed it. + // -- Krzysztof KosiƄski, 2009.08.12 + //if (!(item->flags & SP_CANVAS_ITEM_VISIBLE)) + // return -1; if (HAS_BROKEN_MOTION_HINTS) { event_mask &= ~GDK_POINTER_MOTION_HINT_MASK; diff --git a/src/display/sp-canvas.h b/src/display/sp-canvas.h index 35e3fb5de..a2af080ef 100644 --- a/src/display/sp-canvas.h +++ b/src/display/sp-canvas.h @@ -101,6 +101,7 @@ void sp_canvas_item_affine_absolute(SPCanvasItem *item, Geom::Matrix const &aff) void sp_canvas_item_raise(SPCanvasItem *item, int positions); void sp_canvas_item_lower(SPCanvasItem *item, int positions); +bool sp_canvas_item_is_visible(SPCanvasItem *item); void sp_canvas_item_show(SPCanvasItem *item); void sp_canvas_item_hide(SPCanvasItem *item); int sp_canvas_item_grab(SPCanvasItem *item, unsigned int event_mask, GdkCursor *cursor, guint32 etime); -- cgit v1.2.3 From 1feb29aa4b344392000609e310433015454bd626 Mon Sep 17 00:00:00 2001 From: Diederik van Lierop Date: Fri, 1 Jan 2010 21:06:51 +0100 Subject: Refactor snapping of gradient handles; now behaves like all other snapping, i.e. no more snapping to imaginary infinite lines along the bounding box Fixed bugs: - https://launchpad.net/bugs/371001 (bzr r8932) --- src/display/snap-indicator.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/display') diff --git a/src/display/snap-indicator.cpp b/src/display/snap-indicator.cpp index fdea9cbbf..7df9b31ff 100644 --- a/src/display/snap-indicator.cpp +++ b/src/display/snap-indicator.cpp @@ -97,9 +97,6 @@ SnapIndicator::set_new_snaptarget(Inkscape::SnappedPoint const p) case SNAPTARGET_BBOX_EDGE: target_name = _("bounding box side"); break; - case SNAPTARGET_GRADIENTS_PARENT_BBOX: - target_name = _("bounding box"); - break; case SNAPTARGET_PAGE_BORDER: target_name = _("page border"); break; @@ -139,6 +136,9 @@ SnapIndicator::set_new_snaptarget(Inkscape::SnappedPoint const p) case SNAPTARGET_TEXT_BASELINE: target_name = _("text baseline"); break; + case SNAPTARGET_CONSTRAINED_ANGLE: + target_name = _("constrained angle"); + break; default: g_warning("Snap target has not yet been defined!"); break; -- cgit v1.2.3 From e8f4c644181a8a68e2c33e1783f77a400dc1a29f Mon Sep 17 00:00:00 2001 From: Diederik van Lierop Date: Sat, 9 Jan 2010 22:14:38 +0100 Subject: Refactoring the snapping API (making it easier to maintain and understand for the devs) (bzr r8960) --- src/display/snap-indicator.cpp | 6 +++--- src/display/snap-indicator.h | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) (limited to 'src/display') diff --git a/src/display/snap-indicator.cpp b/src/display/snap-indicator.cpp index 7df9b31ff..84bc1709b 100644 --- a/src/display/snap-indicator.cpp +++ b/src/display/snap-indicator.cpp @@ -40,7 +40,7 @@ SnapIndicator::~SnapIndicator() } void -SnapIndicator::set_new_snaptarget(Inkscape::SnappedPoint const p) +SnapIndicator::set_new_snaptarget(Inkscape::SnappedPoint const &p) { remove_snaptarget(); //only display one snaptarget at a time @@ -264,7 +264,7 @@ SnapIndicator::remove_snaptarget() } void -SnapIndicator::set_new_snapsource(std::pair const p) +SnapIndicator::set_new_snapsource(Inkscape::SnapCandidatePoint const &p) { remove_snapsource(); @@ -284,7 +284,7 @@ SnapIndicator::set_new_snapsource(std::pair const p) "shape", SP_KNOT_SHAPE_CIRCLE, NULL ); - SP_CTRL(canvasitem)->moveto(p.first); + SP_CTRL(canvasitem)->moveto(p.getPoint()); _snapsource = _desktop->add_temporary_canvasitem(canvasitem, 1000); } } diff --git a/src/display/snap-indicator.h b/src/display/snap-indicator.h index 4391ca6d6..d896042a2 100644 --- a/src/display/snap-indicator.h +++ b/src/display/snap-indicator.h @@ -26,10 +26,10 @@ public: SnapIndicator(SPDesktop *desktop); virtual ~SnapIndicator(); - void set_new_snaptarget(Inkscape::SnappedPoint const p); + void set_new_snaptarget(Inkscape::SnappedPoint const &p); void remove_snaptarget(); - void set_new_snapsource(std::pair const p); + void set_new_snapsource(Inkscape::SnapCandidatePoint const &p); void remove_snapsource(); protected: -- cgit v1.2.3 From db3380152e87e88c89691882ffb32bef78db07b0 Mon Sep 17 00:00:00 2001 From: Diederik van Lierop Date: Tue, 19 Jan 2010 21:16:06 +0100 Subject: When snapping to a bounding box, flash that bounding box together with the snap indicator (bzr r8999) --- src/display/snap-indicator.cpp | 27 ++++++++++++++++++++++++--- src/display/snap-indicator.h | 1 + 2 files changed, 25 insertions(+), 3 deletions(-) (limited to 'src/display') diff --git a/src/display/snap-indicator.cpp b/src/display/snap-indicator.cpp index 84bc1709b..54671cb28 100644 --- a/src/display/snap-indicator.cpp +++ b/src/display/snap-indicator.cpp @@ -16,7 +16,9 @@ #include "desktop.h" #include "desktop-handles.h" #include "display/sodipodi-ctrl.h" +#include "display/sodipodi-ctrlrect.h" #include "display/canvas-text.h" +#include "display/sp-canvas-util.h" #include "knot.h" #include "preferences.h" #include @@ -27,6 +29,7 @@ namespace Display { SnapIndicator::SnapIndicator(SPDesktop * desktop) : _snaptarget(NULL), _snaptarget_tooltip(NULL), + _snaptarget_bbox(NULL), _snapsource(NULL), _desktop(desktop) { @@ -216,7 +219,7 @@ SnapIndicator::set_new_snaptarget(Inkscape::SnappedPoint const &p) "anchor", GTK_ANCHOR_CENTER, "size", 10.0, "stroked", TRUE, - "stroke_color", 0xf000f0ff, + "stroke_color", 0xff0000ff, "mode", SP_KNOT_MODE_XOR, "shape", SP_KNOT_SHAPE_DIAMOND, NULL ); @@ -226,7 +229,7 @@ SnapIndicator::set_new_snaptarget(Inkscape::SnappedPoint const &p) "anchor", GTK_ANCHOR_CENTER, "size", 10.0, "stroked", TRUE, - "stroke_color", 0xf000f0ff, + "stroke_color", 0xff0000ff, "mode", SP_KNOT_MODE_XOR, "shape", SP_KNOT_SHAPE_CROSS, NULL ); @@ -245,6 +248,19 @@ SnapIndicator::set_new_snaptarget(Inkscape::SnappedPoint const &p) sp_canvastext_set_anchor((SPCanvasText* )canvas_tooltip, -1, 1); _snaptarget_tooltip = _desktop->add_temporary_canvasitem(canvas_tooltip, timeout_val); + + Geom::OptRect const bbox = p.getTargetBBox(); + if (bbox) { + SPCanvasItem* box = sp_canvas_item_new(sp_desktop_tempgroup (_desktop), + SP_TYPE_CTRLRECT, + NULL); + + SP_CTRLRECT(box)->setRectangle(*bbox); + SP_CTRLRECT(box)->setColor(0xff0000ff, 0, 0); + SP_CTRLRECT(box)->setDashed(true); + sp_canvas_item_move_to_z(box, 0); + _snaptarget_bbox = _desktop->add_temporary_canvasitem(box, timeout_val); + } } } @@ -261,6 +277,11 @@ SnapIndicator::remove_snaptarget() _snaptarget_tooltip = NULL; } + if (_snaptarget_bbox) { + _desktop->remove_temporary_canvasitem(_snaptarget_bbox); + _snaptarget_bbox = NULL; + } + } void @@ -279,7 +300,7 @@ SnapIndicator::set_new_snapsource(Inkscape::SnapCandidatePoint const &p) "anchor", GTK_ANCHOR_CENTER, "size", 6.0, "stroked", TRUE, - "stroke_color", 0xf000f0ff, + "stroke_color", 0xff0000ff, "mode", SP_KNOT_MODE_XOR, "shape", SP_KNOT_SHAPE_CIRCLE, NULL ); diff --git a/src/display/snap-indicator.h b/src/display/snap-indicator.h index d896042a2..feb118baa 100644 --- a/src/display/snap-indicator.h +++ b/src/display/snap-indicator.h @@ -35,6 +35,7 @@ public: protected: TemporaryItem *_snaptarget; TemporaryItem *_snaptarget_tooltip; + TemporaryItem *_snaptarget_bbox; TemporaryItem *_snapsource; SPDesktop *_desktop; -- cgit v1.2.3 From c4aa590bedcf358acf15bdf0d8134ae99e3be167 Mon Sep 17 00:00:00 2001 From: Diederik van Lierop Date: Sat, 23 Jan 2010 14:36:56 +0100 Subject: Remove redundancy from snapping API (type of snapsource no longer has to be specified explicitly) (bzr r9014) --- src/display/snap-indicator.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/display') diff --git a/src/display/snap-indicator.cpp b/src/display/snap-indicator.cpp index 54671cb28..dd80524f1 100644 --- a/src/display/snap-indicator.cpp +++ b/src/display/snap-indicator.cpp @@ -176,7 +176,8 @@ SnapIndicator::set_new_snaptarget(Inkscape::SnappedPoint const &p) case SNAPSOURCE_ROTATION_CENTER: source_name = _("Object rotation center"); break; - case SNAPSOURCE_HANDLE: + case SNAPSOURCE_NODE_HANDLE: + case SNAPSOURCE_OTHER_HANDLE: source_name = _("Handle"); break; case SNAPSOURCE_PATH_INTERSECTION: -- cgit v1.2.3 From e52fb9fac3f1bbd924c0ca3b6b5e214a095d44af Mon Sep 17 00:00:00 2001 From: Diederik van Lierop Date: Sat, 30 Jan 2010 23:04:33 +0100 Subject: Finally introducing the pre-snap indicator (bzr r9034) --- src/display/snap-indicator.cpp | 13 +++++++++---- src/display/snap-indicator.h | 2 +- 2 files changed, 10 insertions(+), 5 deletions(-) (limited to 'src/display') diff --git a/src/display/snap-indicator.cpp b/src/display/snap-indicator.cpp index dd80524f1..b135dd9fe 100644 --- a/src/display/snap-indicator.cpp +++ b/src/display/snap-indicator.cpp @@ -43,7 +43,7 @@ SnapIndicator::~SnapIndicator() } void -SnapIndicator::set_new_snaptarget(Inkscape::SnappedPoint const &p) +SnapIndicator::set_new_snaptarget(Inkscape::SnappedPoint const &p, bool pre_snap) { remove_snaptarget(); //only display one snaptarget at a time @@ -220,7 +220,7 @@ SnapIndicator::set_new_snaptarget(Inkscape::SnappedPoint const &p) "anchor", GTK_ANCHOR_CENTER, "size", 10.0, "stroked", TRUE, - "stroke_color", 0xff0000ff, + "stroke_color", pre_snap ? 0x7f7f7fff : 0xff0000ff, "mode", SP_KNOT_MODE_XOR, "shape", SP_KNOT_SHAPE_DIAMOND, NULL ); @@ -230,7 +230,7 @@ SnapIndicator::set_new_snaptarget(Inkscape::SnappedPoint const &p) "anchor", GTK_ANCHOR_CENTER, "size", 10.0, "stroked", TRUE, - "stroke_color", 0xff0000ff, + "stroke_color", pre_snap ? 0x7f7f7fff : 0xff0000ff, "mode", SP_KNOT_MODE_XOR, "shape", SP_KNOT_SHAPE_CROSS, NULL ); @@ -241,15 +241,20 @@ SnapIndicator::set_new_snaptarget(Inkscape::SnappedPoint const &p) SP_CTRL(canvasitem)->moveto(p.getPoint()); _snaptarget = _desktop->add_temporary_canvasitem(canvasitem, timeout_val); + // Display the tooltip, which reveals the type of snap source and the type of snap target gchar *tooltip_str = g_strconcat(source_name, _(" to "), target_name, NULL); Geom::Point tooltip_pos = p.getPoint() + _desktop->w2d(Geom::Point(15, -15)); SPCanvasItem *canvas_tooltip = sp_canvastext_new(sp_desktop_tempgroup(_desktop), _desktop, tooltip_pos, tooltip_str); + if (pre_snap) { + SP_CANVASTEXT(canvas_tooltip)->rgba = 0x7f7f7fff; + } g_free(tooltip_str); sp_canvastext_set_anchor((SPCanvasText* )canvas_tooltip, -1, 1); _snaptarget_tooltip = _desktop->add_temporary_canvasitem(canvas_tooltip, timeout_val); + // Display the bounding box, if we snapped to one Geom::OptRect const bbox = p.getTargetBBox(); if (bbox) { SPCanvasItem* box = sp_canvas_item_new(sp_desktop_tempgroup (_desktop), @@ -257,7 +262,7 @@ SnapIndicator::set_new_snaptarget(Inkscape::SnappedPoint const &p) NULL); SP_CTRLRECT(box)->setRectangle(*bbox); - SP_CTRLRECT(box)->setColor(0xff0000ff, 0, 0); + SP_CTRLRECT(box)->setColor(pre_snap ? 0x7f7f7fff : 0xff0000ff, 0, 0); SP_CTRLRECT(box)->setDashed(true); sp_canvas_item_move_to_z(box, 0); _snaptarget_bbox = _desktop->add_temporary_canvasitem(box, timeout_val); diff --git a/src/display/snap-indicator.h b/src/display/snap-indicator.h index feb118baa..259af8ae6 100644 --- a/src/display/snap-indicator.h +++ b/src/display/snap-indicator.h @@ -26,7 +26,7 @@ public: SnapIndicator(SPDesktop *desktop); virtual ~SnapIndicator(); - void set_new_snaptarget(Inkscape::SnappedPoint const &p); + void set_new_snaptarget(Inkscape::SnappedPoint const &p, bool pre_snap = false); void remove_snaptarget(); void set_new_snapsource(Inkscape::SnapCandidatePoint const &p); -- cgit v1.2.3 From 284ace6bc2e5a01cf7d1c4383278b3b9a45b4c79 Mon Sep 17 00:00:00 2001 From: Krzysztof Kosi??ski Date: Wed, 10 Feb 2010 16:46:07 +0100 Subject: Prevent the Bezier tool from introducing a redundant closing line segment when closing a path. (bzr r9079) --- src/display/curve.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src/display') diff --git a/src/display/curve.cpp b/src/display/curve.cpp index 7d7dbc987..7c3c3d480 100644 --- a/src/display/curve.cpp +++ b/src/display/curve.cpp @@ -285,7 +285,11 @@ SPCurve::closepath() void SPCurve::closepath_current() { - _pathv.back().setFinal(_pathv.back().initialPoint()); + if (_pathv.back().size() > 0 && dynamic_cast(&_pathv.back().back_open())) { + _pathv.back().erase_last(); + } else { + _pathv.back().setFinal(_pathv.back().initialPoint()); + } _pathv.back().close(true); } -- cgit v1.2.3 From df48d6409a93d60d53cc16b0a8d3625cc3ffa6f0 Mon Sep 17 00:00:00 2001 From: Diederik van Lierop Date: Wed, 17 Feb 2010 22:45:04 +0100 Subject: Fix a memory leak in sp_canvastext (bzr r9094) --- src/display/canvas-text.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src/display') diff --git a/src/display/canvas-text.cpp b/src/display/canvas-text.cpp index 1c715291f..d32bc20c3 100644 --- a/src/display/canvas-text.cpp +++ b/src/display/canvas-text.cpp @@ -91,7 +91,9 @@ sp_canvastext_destroy (GtkObject *object) SPCanvasText *canvastext = SP_CANVASTEXT (object); - canvastext->item=NULL; + g_free(canvastext->text); + canvastext->text = NULL; + canvastext->item = NULL; if (GTK_OBJECT_CLASS (parent_class_ct)->destroy) (* GTK_OBJECT_CLASS (parent_class_ct)->destroy) (object); -- cgit v1.2.3 From 99c82c93cb8e9d023cb65f5e0f6ea357db5092ba Mon Sep 17 00:00:00 2001 From: Diederik van Lierop Date: Sun, 21 Feb 2010 10:01:33 +0100 Subject: Make sure that guides always snap correctly when dropping them, and improve perseverance of snap-indicator (bzr r9103) --- src/display/snap-indicator.cpp | 11 +++++++++-- src/display/snap-indicator.h | 5 +++-- 2 files changed, 12 insertions(+), 4 deletions(-) (limited to 'src/display') diff --git a/src/display/snap-indicator.cpp b/src/display/snap-indicator.cpp index b135dd9fe..c0ed322e4 100644 --- a/src/display/snap-indicator.cpp +++ b/src/display/snap-indicator.cpp @@ -6,7 +6,7 @@ * Diederik van Lierop * * Copyright (C) Johan Engelen 2009 - * Copyright (C) Diederik van Lierop 2009 + * Copyright (C) Diederik van Lierop 2010 * * Released under GNU GPL, read the file 'COPYING' for more information */ @@ -31,6 +31,7 @@ SnapIndicator::SnapIndicator(SPDesktop * desktop) _snaptarget_tooltip(NULL), _snaptarget_bbox(NULL), _snapsource(NULL), + _snaptarget_is_presnap(false), _desktop(desktop) { } @@ -240,6 +241,7 @@ SnapIndicator::set_new_snaptarget(Inkscape::SnappedPoint const &p, bool pre_snap SP_CTRL(canvasitem)->moveto(p.getPoint()); _snaptarget = _desktop->add_temporary_canvasitem(canvasitem, timeout_val); + _snaptarget_is_presnap = pre_snap; // Display the tooltip, which reveals the type of snap source and the type of snap target gchar *tooltip_str = g_strconcat(source_name, _(" to "), target_name, NULL); @@ -271,11 +273,16 @@ SnapIndicator::set_new_snaptarget(Inkscape::SnappedPoint const &p, bool pre_snap } void -SnapIndicator::remove_snaptarget() +SnapIndicator::remove_snaptarget(bool only_if_presnap) { + if (only_if_presnap && !_snaptarget_is_presnap) { + return; + } + if (_snaptarget) { _desktop->remove_temporary_canvasitem(_snaptarget); _snaptarget = NULL; + _snaptarget_is_presnap = false; } if (_snaptarget_tooltip) { diff --git a/src/display/snap-indicator.h b/src/display/snap-indicator.h index 259af8ae6..5475f9f60 100644 --- a/src/display/snap-indicator.h +++ b/src/display/snap-indicator.h @@ -9,7 +9,7 @@ * Diederik van Lierop * * Copyright (C) Johan Engelen 2008 - * Copyright (C) Diederik van Lierop 2008 + * Copyright (C) Diederik van Lierop 2010 * * Released under GNU GPL, read the file 'COPYING' for more information */ @@ -27,7 +27,7 @@ public: virtual ~SnapIndicator(); void set_new_snaptarget(Inkscape::SnappedPoint const &p, bool pre_snap = false); - void remove_snaptarget(); + void remove_snaptarget(bool only_if_presnap = false); void set_new_snapsource(Inkscape::SnapCandidatePoint const &p); void remove_snapsource(); @@ -37,6 +37,7 @@ protected: TemporaryItem *_snaptarget_tooltip; TemporaryItem *_snaptarget_bbox; TemporaryItem *_snapsource; + bool _snaptarget_is_presnap; SPDesktop *_desktop; private: -- cgit v1.2.3 From 76e1015affb07da45fb04e3f7a5a6d9d7c5a272c Mon Sep 17 00:00:00 2001 From: Diederik van Lierop Date: Mon, 22 Feb 2010 23:18:29 +0100 Subject: 1) Making snapping behaviour for paraxial lines (in the pen tool) similar to other tools 2) Always apply the constraint when asking for a constrained snap 3) Show snap indicator when applying a constraint (bzr r9105) --- src/display/snap-indicator.cpp | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/display') diff --git a/src/display/snap-indicator.cpp b/src/display/snap-indicator.cpp index c0ed322e4..25b5090c1 100644 --- a/src/display/snap-indicator.cpp +++ b/src/display/snap-indicator.cpp @@ -143,6 +143,9 @@ SnapIndicator::set_new_snaptarget(Inkscape::SnappedPoint const &p, bool pre_snap case SNAPTARGET_CONSTRAINED_ANGLE: target_name = _("constrained angle"); break; + case SNAPTARGET_CONSTRAINT: + target_name = _("constraint"); + break; default: g_warning("Snap target has not yet been defined!"); break; -- cgit v1.2.3 From 6edc17e9611bfc1875cf3fdbaf8fb1ce3c820b89 Mon Sep 17 00:00:00 2001 From: Diederik van Lierop Date: Thu, 25 Feb 2010 22:54:44 +0100 Subject: 1) Fix moving by an integer multiple of the grid spacing (-dragging in the selector tool) 2) Allow constrained translation for 1) (with ) 3) Fix snapping to the grid when pasting 4) Show snap indicators for all of the above 5) Implement snap delay mechanism for 1) and 2) (bzr r9113) --- src/display/snap-indicator.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'src/display') diff --git a/src/display/snap-indicator.cpp b/src/display/snap-indicator.cpp index 25b5090c1..1e4ca12a8 100644 --- a/src/display/snap-indicator.cpp +++ b/src/display/snap-indicator.cpp @@ -208,6 +208,9 @@ SnapIndicator::set_new_snaptarget(Inkscape::SnappedPoint const &p, bool pre_snap case SNAPSOURCE_TEXT_BASELINE: source_name = _("Text baseline"); break; + case SNAPSOURCE_GRID_PITCH: + source_name = _("Multiple of grid spacing"); + break; default: g_warning("Snap source has not yet been defined!"); break; @@ -247,7 +250,12 @@ SnapIndicator::set_new_snaptarget(Inkscape::SnappedPoint const &p, bool pre_snap _snaptarget_is_presnap = pre_snap; // Display the tooltip, which reveals the type of snap source and the type of snap target - gchar *tooltip_str = g_strconcat(source_name, _(" to "), target_name, NULL); + gchar *tooltip_str = NULL; + if (p.getSource() != SNAPSOURCE_GRID_PITCH) { + tooltip_str = g_strconcat(source_name, _(" to "), target_name, NULL); + } else { + tooltip_str = g_strdup(source_name); + } Geom::Point tooltip_pos = p.getPoint() + _desktop->w2d(Geom::Point(15, -15)); SPCanvasItem *canvas_tooltip = sp_canvastext_new(sp_desktop_tempgroup(_desktop), _desktop, tooltip_pos, tooltip_str); -- cgit v1.2.3 From 0dff587c9dd7ac0b02fc93f58883e24cd2d4e92e Mon Sep 17 00:00:00 2001 From: Krzysztof Kosi??ski Date: Sun, 28 Feb 2010 18:38:28 +0100 Subject: Compilation fixes for Windows 64-bit by Fridrich (bzr r9118) --- src/display/curve.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/display') diff --git a/src/display/curve.cpp b/src/display/curve.cpp index 7c3c3d480..1b54c981c 100644 --- a/src/display/curve.cpp +++ b/src/display/curve.cpp @@ -51,10 +51,10 @@ SPCurve::new_from_rect(Geom::Rect const &rect) Geom::Point p = rect.corner(0); c->moveto(p); - for (int i=3; i>=0; i--) { + for (int i=3; i>=1; i--) { c->lineto(rect.corner(i)); } - c->closepath_current(); + c->closepath(); return c; } -- cgit v1.2.3 From 935b802e2c1df462ee03009b5bd0c4c9f9d373aa Mon Sep 17 00:00:00 2001 From: Diederik van Lierop Date: Sat, 6 Mar 2010 15:44:52 +0100 Subject: Fix scrolling with mouse wheel when hovering above a snap-indicator (bzr r9158) --- src/display/sp-canvas.cpp | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) (limited to 'src/display') diff --git a/src/display/sp-canvas.cpp b/src/display/sp-canvas.cpp index 6d996fbe2..658276841 100644 --- a/src/display/sp-canvas.cpp +++ b/src/display/sp-canvas.cpp @@ -114,8 +114,8 @@ static void sp_canvas_item_init (SPCanvasItem *item); static void sp_canvas_item_dispose (GObject *object); static void sp_canvas_item_construct (SPCanvasItem *item, SPCanvasGroup *parent, gchar const *first_arg_name, va_list args); - static int emit_event (SPCanvas *canvas, GdkEvent *event); +static int pick_current_item (SPCanvas *canvas, GdkEvent *event); static guint item_signals[ITEM_LAST_SIGNAL] = { 0 }; @@ -1326,6 +1326,16 @@ emit_event (SPCanvas *canvas, GdkEvent *event) if (canvas->grabbed_item && !is_descendant (canvas->current_item, canvas->grabbed_item)) { item = canvas->grabbed_item; } else { + // Make sure that current_item is up-to-date. If a snap indicator was just deleted, then + // sp_canvas_item_dispose has been called and there is no current_item specified. We need + // that though because otherwise we don't know where to send this event to, leading to a + // lost event. We can't wait for idle events to have current_item updated, we need it now! + // Otherwise, scrolling when hovering above a pre-snap indicator won't work (for example) + // See this bug report: https://bugs.launchpad.net/inkscape/+bug/522335/comments/8 + while (canvas->need_repick) { + canvas->need_repick = FALSE; + pick_current_item (canvas, (GdkEvent *) event); + } item = canvas->current_item; } @@ -1491,6 +1501,8 @@ pick_current_item (SPCanvas *canvas, GdkEvent *event) retval = emit_event (canvas, &new_event); } + + return retval; } @@ -1588,7 +1600,7 @@ static inline void request_motions(GdkWindow *w, GdkEventMotion *event) { static int sp_canvas_motion (GtkWidget *widget, GdkEventMotion *event) { - int status; + int status; SPCanvas *canvas = SP_CANVAS (widget); track_latency((GdkEvent *)event); @@ -1600,11 +1612,11 @@ sp_canvas_motion (GtkWidget *widget, GdkEventMotion *event) return FALSE; canvas->state = event->state; - pick_current_item (canvas, (GdkEvent *) event); - status = emit_event (canvas, (GdkEvent *) event); - if (event->is_hint) { - request_motions(widget->window, event); - } + pick_current_item (canvas, (GdkEvent *) event); + status = emit_event (canvas, (GdkEvent *) event); + if (event->is_hint) { + request_motions(widget->window, event); + } return status; } @@ -2095,7 +2107,7 @@ paint (SPCanvas *canvas) static int do_update (SPCanvas *canvas) { - if (!canvas->root || !canvas->pixmap_gc) // canvas may have already be destroyed by closing desktop durring interrupted display! + if (!canvas->root || !canvas->pixmap_gc) // canvas may have already be destroyed by closing desktop during interrupted display! return TRUE; /* Cause the update if necessary */ @@ -2196,6 +2208,7 @@ sp_canvas_scroll_to (SPCanvas *canvas, double cx, double cy, unsigned int clear, } else { // scrolling as part of zoom; do nothing here - the next do_update will perform full redraw } + } /** -- cgit v1.2.3 From d7f4efae8430f61f21081469626c8a460fd60b38 Mon Sep 17 00:00:00 2001 From: Diederik van Lierop Date: Fri, 12 Mar 2010 23:36:33 +0100 Subject: Fix crash in spray tool caused by rev. 9158 Fixed bugs: - https://launchpad.net/bugs/537249 (bzr r9181) --- src/display/sp-canvas.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/display') diff --git a/src/display/sp-canvas.cpp b/src/display/sp-canvas.cpp index 658276841..446066d93 100644 --- a/src/display/sp-canvas.cpp +++ b/src/display/sp-canvas.cpp @@ -1332,7 +1332,7 @@ emit_event (SPCanvas *canvas, GdkEvent *event) // lost event. We can't wait for idle events to have current_item updated, we need it now! // Otherwise, scrolling when hovering above a pre-snap indicator won't work (for example) // See this bug report: https://bugs.launchpad.net/inkscape/+bug/522335/comments/8 - while (canvas->need_repick) { + if (canvas->need_repick && !canvas->in_repick) { canvas->need_repick = FALSE; pick_current_item (canvas, (GdkEvent *) event); } -- cgit v1.2.3 From a6aa217d30fff785d2812be8b566dfa2b66c8bce Mon Sep 17 00:00:00 2001 From: Diederik van Lierop Date: Sun, 21 Mar 2010 20:46:45 +0100 Subject: Fix regression caused by rev. #9158 (selection of nodes in the node editor by dragging a rectangle using a tablet was broken) (bzr r9219) --- src/display/sp-canvas.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src/display') diff --git a/src/display/sp-canvas.cpp b/src/display/sp-canvas.cpp index 446066d93..c6778c8c5 100644 --- a/src/display/sp-canvas.cpp +++ b/src/display/sp-canvas.cpp @@ -1332,7 +1332,11 @@ emit_event (SPCanvas *canvas, GdkEvent *event) // lost event. We can't wait for idle events to have current_item updated, we need it now! // Otherwise, scrolling when hovering above a pre-snap indicator won't work (for example) // See this bug report: https://bugs.launchpad.net/inkscape/+bug/522335/comments/8 - if (canvas->need_repick && !canvas->in_repick) { + if (canvas->need_repick && !canvas->in_repick && event->type == GDK_SCROLL) { + // To avoid side effects, we'll only do this for scroll events, because this is the + // only thing we want to fix here. An example of a reported side effect is that + // otherwise selection of nodes in the node editor by dragging a rectangle using a + // tablet will break canvas->need_repick = FALSE; pick_current_item (canvas, (GdkEvent *) event); } -- cgit v1.2.3