From: johanengelen Date: Fri, 16 Jan 2009 22:06:40 +0000 (+0000) Subject: work a bit on snapindicator: added switch statement for different types X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=abac96a58638236025e60f4dca3848bb294c6672;p=inkscape.git work a bit on snapindicator: added switch statement for different types --- diff --git a/src/display/snap-indicator.cpp b/src/display/snap-indicator.cpp index e48f48ced..d642816af 100644 --- a/src/display/snap-indicator.cpp +++ b/src/display/snap-indicator.cpp @@ -51,22 +51,36 @@ SnapIndicator::set_new_snaptarget(Inkscape::SnappedPoint const p) Inkscape::Preferences *prefs = Inkscape::Preferences::get(); bool value = prefs->getBool("/options/snapindicator/value", true); - + if (value) { - // TODO add many different kinds of snap indicator :-) - // For this we should use p->getTarget() to find out what has snapped - // and adjust the shape of the snapindicator accordingly, e.g. a cross - // when snapping to an intersection, a circle when snapping to a node, etc. - SPCanvasItem * canvasitem = sp_canvas_item_new( sp_desktop_tempgroup (_desktop), - SP_TYPE_CTRL, - "anchor", GTK_ANCHOR_CENTER, - "size", 10.0, - "stroked", TRUE, - "stroke_color", 0xf000f0ff, - "mode", SP_KNOT_MODE_XOR, - "shape", SP_KNOT_SHAPE_CROSS, - NULL ); - + SPCanvasItem * canvasitem = NULL; + switch (p.getTarget()) { + /// @todo add the different kinds of snapindicator visuals + case SNAPTARGET_GRID: + case SNAPTARGET_GRID_INTERSECTION: + case SNAPTARGET_GUIDE: + case SNAPTARGET_GUIDE_INTERSECTION: + case SNAPTARGET_GRID_GUIDE_INTERSECTION: + case SNAPTARGET_NODE: + case SNAPTARGET_PATH: + case SNAPTARGET_PATH_INTERSECTION: + case SNAPTARGET_BBOX_CORNER: + case SNAPTARGET_BBOX_EDGE: + case SNAPTARGET_GRADIENT: + case SNAPTARGET_UNDEFINED: + default: + canvasitem = sp_canvas_item_new(sp_desktop_tempgroup (_desktop), + SP_TYPE_CTRL, + "anchor", GTK_ANCHOR_CENTER, + "size", 10.0, + "stroked", TRUE, + "stroke_color", 0xf000f0ff, + "mode", SP_KNOT_MODE_XOR, + "shape", SP_KNOT_SHAPE_CROSS, + NULL ); + break; + } + SP_CTRL(canvasitem)->moveto(p.getPoint()); remove_snapsource(); // Don't set both the source and target indicators, as these will overlap _snaptarget = _desktop->add_temporary_canvasitem(canvasitem, 1000); // TODO add preference for snap indicator timeout diff --git a/src/snapped-point.h b/src/snapped-point.h index dbd672bdf..254d573df 100644 --- a/src/snapped-point.h +++ b/src/snapped-point.h @@ -77,7 +77,7 @@ public: Geom::Point getTransformation() const {return _transformation;} void setTransformation(Geom::Point const t) {_transformation = t;} void setTarget(SnapTargetType const target) {_target = target;} - SnapTargetType getTarget() {return _target;} + SnapTargetType getTarget() const {return _target;} bool isOtherSnapBetter(SnappedPoint const &other_one, bool weighted) const;