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