1 /** \file\r
2 * Provides a class that shows a temporary indicator on the canvas of where the snap was, and what kind of snap\r
3 *\r
4 * Authors:\r
5 * Johan Engelen\r
6 *\r
7 * Copyright (C) Johan Engelen 2008 <j.b.c.engelen@utwente.nl>\r
8 *\r
9 * Released under GNU GPL, read the file 'COPYING' for more information\r
10 */\r
11 \r
12 #include "display/snap-indicator.h"\r
13 \r
14 #include "desktop.h"\r
15 #include "desktop-handles.h"\r
16 #include "display/sodipodi-ctrl.h"\r
17 #include "knot.h"\r
18 \r
19 namespace Inkscape {\r
20 namespace Display {\r
21 \r
22 /** lifetime is measured in milliseconds\r
23 */\r
24 SnapIndicator::SnapIndicator(SPDesktop * desktop)\r
25 : tempitem(NULL),\r
26 desktop(desktop)\r
27 {\r
28 }\r
29 \r
30 SnapIndicator::~SnapIndicator()\r
31 {\r
32 // remove item that might be present\r
33 remove_snappoint();\r
34 }\r
35 \r
36 void\r
37 SnapIndicator::set_new_snappoint(Geom::Point p)\r
38 {\r
39 remove_snappoint();\r
40 \r
41 SPCanvasItem * canvasitem = sp_canvas_item_new( sp_desktop_tempgroup (desktop),\r
42 SP_TYPE_CTRL,\r
43 "anchor", GTK_ANCHOR_CENTER,\r
44 "size", 6.0,\r
45 "stroked", TRUE,\r
46 "stroke_color", 0xf000f0ff,\r
47 "mode", SP_KNOT_MODE_XOR,\r
48 "shape", SP_KNOT_SHAPE_CROSS,\r
49 NULL );\r
50 SP_CTRL(canvasitem)->moveto ( p );\r
51 tempitem = desktop->add_temporary_canvasitem(canvasitem, 2000);\r
52 }\r
53 \r
54 void\r
55 SnapIndicator::remove_snappoint()\r
56 {\r
57 if (tempitem) {\r
58 desktop->remove_temporary_canvasitem(tempitem);\r
59 tempitem = NULL;\r
60 }\r
61 }\r
62 \r
63 \r
64 } //namespace Display\r
65 } /* namespace Inkscape */\r
66 \r
67 /*\r
68 Local Variables:\r
69 mode:c++\r
70 c-file-style:"stroustrup"\r
71 c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))\r
72 indent-tabs-mode:nil\r
73 fill-column:99\r
74 End:\r
75 */\r
76 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :\r