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 SnapIndicator::SnapIndicator(SPDesktop * desktop)\r
23 : tempitem(NULL),\r
24 desktop(desktop)\r
25 {\r
26 }\r
27 \r
28 SnapIndicator::~SnapIndicator()\r
29 {\r
30 // remove item that might be present\r
31 remove_snappoint();\r
32 }\r
33 \r
34 void\r
35 SnapIndicator::set_new_snappoint(Geom::Point p)\r
36 {\r
37 remove_snappoint();\r
38 \r
39 bool enabled = false; // TODO add preference for snap indicator.\r
40 if (enabled) {\r
41 // TODO add many different kinds of snap indicator :-)\r
42 SPCanvasItem * canvasitem = sp_canvas_item_new( sp_desktop_tempgroup (desktop),\r
43 SP_TYPE_CTRL,\r
44 "anchor", GTK_ANCHOR_CENTER,\r
45 "size", 10.0,\r
46 "stroked", TRUE,\r
47 "stroke_color", 0xf000f0ff,\r
48 "mode", SP_KNOT_MODE_XOR,\r
49 "shape", SP_KNOT_SHAPE_CROSS,\r
50 NULL );\r
51 SP_CTRL(canvasitem)->moveto ( p );\r
52 tempitem = desktop->add_temporary_canvasitem(canvasitem, 1000); // TODO add preference for snap indicator timeout\r
53 }\r
54 }\r
55 \r
56 void\r
57 SnapIndicator::remove_snappoint()\r
58 {\r
59 if (tempitem) {\r
60 desktop->remove_temporary_canvasitem(tempitem);\r
61 tempitem = NULL;\r
62 }\r
63 }\r
64 \r
65 \r
66 } //namespace Display\r
67 } /* namespace Inkscape */\r
68 \r
69 /*\r
70 Local Variables:\r
71 mode:c++\r
72 c-file-style:"stroustrup"\r
73 c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))\r
74 indent-tabs-mode:nil\r
75 fill-column:99\r
76 End:\r
77 */\r
78 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :\r