summaryrefslogtreecommitdiffstats
path: root/src/display
diff options
context:
space:
mode:
authorJohan B. C. Engelen <jbc.engelen@swissonline.ch>2008-03-02 22:01:12 +0000
committerjohanengelen <johanengelen@users.sourceforge.net>2008-03-02 22:01:12 +0000
commit017e93e3dae0be363c6b9caf71d68dc4d1055bc9 (patch)
tree70d3afe3e23ab28effaa8f94c1c977e2a7c2aa11 /src/display
parent* [INTL: sk] (trunk) Updated Slovak translation (diff)
downloadinkscape-017e93e3dae0be363c6b9caf71d68dc4d1055bc9.tar.gz
inkscape-017e93e3dae0be363c6b9caf71d68dc4d1055bc9.zip
remove flashing test indicator on pointparam.
remove some leftover code from point param code remove test pointparam from LPEKnot added SnapIndicator added SnapIndicator to SPDesktop, and a call from guidesnapping to display a snapindicator when a guide is snapped. fix canvas-temporary-item-list.cpp (bzr r4931)
Diffstat (limited to 'src/display')
-rw-r--r--src/display/Makefile_insert2
-rw-r--r--src/display/canvas-temporary-item-list.cpp10
-rw-r--r--src/display/display-forward.h6
-rw-r--r--src/display/snap-indicator.cpp76
-rw-r--r--src/display/snap-indicator.h53
5 files changed, 142 insertions, 5 deletions
diff --git a/src/display/Makefile_insert b/src/display/Makefile_insert
index 61cb02155..d7b0fb608 100644
--- a/src/display/Makefile_insert
+++ b/src/display/Makefile_insert
@@ -55,6 +55,8 @@ display_libspdisplay_a_SOURCES = \
display/nr-plain-stuff-gdk.h \
display/nr-plain-stuff.cpp \
display/nr-plain-stuff.h \
+ display/snap-indicator.cpp \
+ display/snap-indicator.h \
display/sodipodi-ctrl.cpp \
display/sodipodi-ctrl.h \
display/sodipodi-ctrlrect.cpp \
diff --git a/src/display/canvas-temporary-item-list.cpp b/src/display/canvas-temporary-item-list.cpp
index 5b92e1828..54e81a1f0 100644
--- a/src/display/canvas-temporary-item-list.cpp
+++ b/src/display/canvas-temporary-item-list.cpp
@@ -37,11 +37,11 @@ TemporaryItemList::~TemporaryItemList()
TemporaryItem *
TemporaryItemList::add_item(SPCanvasItem *item, guint lifetime)
{
- if (lifetime > 100) { // beware of strange things happening due to very short timeouts
- TemporaryItem * tempitem = new TemporaryItem(item, lifetime);
- itemlist.push_back(tempitem);
- tempitem->signal_timeout.connect( sigc::mem_fun(*this, &TemporaryItemList::_item_timeout) );
- }
+ // beware of strange things happening due to very short timeouts
+ TemporaryItem * tempitem = new TemporaryItem(item, lifetime);
+ itemlist.push_back(tempitem);
+ tempitem->signal_timeout.connect( sigc::mem_fun(*this, &TemporaryItemList::_item_timeout) );
+ return tempitem;
}
void
diff --git a/src/display/display-forward.h b/src/display/display-forward.h
index a28b7d03a..191aac61f 100644
--- a/src/display/display-forward.h
+++ b/src/display/display-forward.h
@@ -11,6 +11,12 @@ struct SPCanvasGroup;
struct SPCanvasGroupClass;
struct SPCurve;
+namespace Inkscape {
+namespace Display {
+ class TemporaryItem;
+ class TemporaryItemList;
+}
+}
#define SP_TYPE_CANVAS_ITEM (sp_canvas_item_get_type())
#define SP_CANVAS_ITEM(obj) (GTK_CHECK_CAST((obj), SP_TYPE_CANVAS_ITEM, SPCanvasItem))
diff --git a/src/display/snap-indicator.cpp b/src/display/snap-indicator.cpp
new file mode 100644
index 000000000..1d005ceb8
--- /dev/null
+++ b/src/display/snap-indicator.cpp
@@ -0,0 +1,76 @@
+/** \file
+ * Provides a class that shows a temporary indicator on the canvas of where the snap was, and what kind of snap
+ *
+ * Authors:
+ * Johan Engelen
+ *
+ * Copyright (C) Johan Engelen 2008 <j.b.c.engelen@utwente.nl>
+ *
+ * Released under GNU GPL, read the file 'COPYING' for more information
+ */
+
+#include "display/snap-indicator.h"
+
+#include "desktop.h"
+#include "desktop-handles.h"
+#include "display/sodipodi-ctrl.h"
+#include "knot.h"
+
+namespace Inkscape {
+namespace Display {
+
+/** lifetime is measured in milliseconds
+ */
+SnapIndicator::SnapIndicator(SPDesktop * desktop)
+ : tempitem(NULL),
+ desktop(desktop)
+{
+}
+
+SnapIndicator::~SnapIndicator()
+{
+ // remove item that might be present
+ remove_snappoint();
+}
+
+void
+SnapIndicator::set_new_snappoint(Geom::Point p)
+{
+ remove_snappoint();
+
+ SPCanvasItem * canvasitem = sp_canvas_item_new( sp_desktop_tempgroup (desktop),
+ SP_TYPE_CTRL,
+ "anchor", GTK_ANCHOR_CENTER,
+ "size", 6.0,
+ "stroked", TRUE,
+ "stroke_color", 0xf000f0ff,
+ "mode", SP_KNOT_MODE_XOR,
+ "shape", SP_KNOT_SHAPE_CROSS,
+ NULL );
+ SP_CTRL(canvasitem)->moveto ( p );
+ tempitem = desktop->add_temporary_canvasitem(canvasitem, 2000);
+}
+
+void
+SnapIndicator::remove_snappoint()
+{
+ if (tempitem) {
+ desktop->remove_temporary_canvasitem(tempitem);
+ tempitem = NULL;
+ }
+}
+
+
+} //namespace Display
+} /* namespace Inkscape */
+
+/*
+ Local Variables:
+ mode:c++
+ c-file-style:"stroustrup"
+ c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
+ indent-tabs-mode:nil
+ fill-column:99
+ End:
+*/
+// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :
diff --git a/src/display/snap-indicator.h b/src/display/snap-indicator.h
new file mode 100644
index 000000000..bedeb492b
--- /dev/null
+++ b/src/display/snap-indicator.h
@@ -0,0 +1,53 @@
+#ifndef INKSCAPE_DISPLAY_SNAP_INDICATOR_H
+#define INKSCAPE_DISPLAY_SNAP_INDICATOR_H
+
+/** \file
+ * Provides a class that shows a temporary indicator on the canvas of where the snap was, and what kind of snap
+ *
+ * Authors:
+ * Johan Engelen
+ *
+ * Copyright (C) Johan Engelen 2008 <j.b.c.engelen@utwente.nl>
+ *
+ * Released under GNU GPL, read the file 'COPYING' for more information
+ */
+
+#include "forward.h"
+#include "display/display-forward.h"
+#include <2geom/point.h>
+
+namespace Inkscape {
+namespace Display {
+
+class SnapIndicator {
+public:
+ SnapIndicator(SPDesktop *desktop);
+ virtual ~SnapIndicator();
+
+ void set_new_snappoint(Geom::Point p);
+ void remove_snappoint();
+
+protected:
+ TemporaryItem * tempitem;
+ SPDesktop *desktop;
+
+private:
+ SnapIndicator(const SnapIndicator&);
+ SnapIndicator& operator=(const SnapIndicator&);
+};
+
+} //namespace Display
+} //namespace Inkscape
+
+#endif
+
+/*
+ Local Variables:
+ mode:c++
+ c-file-style:"stroustrup"
+ c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
+ indent-tabs-mode:nil
+ fill-column:99
+ End:
+*/
+// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :