summaryrefslogtreecommitdiffstats
path: root/src/star-context.cpp
diff options
context:
space:
mode:
authorMatthew Petroff <matthew@mpetroff.net>2013-09-20 17:05:24 +0000
committerMatthew Petroff <matthew@mpetroff.net>2013-09-20 17:05:24 +0000
commit48b4ee48e518d65c3c5e49369a747c2aa4b0081b (patch)
tree7159f8bc67d3f96ae43c42c32cacec6f7813f6fa /src/star-context.cpp
parentFix bug in rectangle toolbar. (diff)
parentFix grids after C++ification. Patch from Markus Engel (diff)
downloadinkscape-48b4ee48e518d65c3c5e49369a747c2aa4b0081b.tar.gz
inkscape-48b4ee48e518d65c3c5e49369a747c2aa4b0081b.zip
Merge from trunk.
(bzr r12475.1.29)
Diffstat (limited to 'src/star-context.cpp')
-rw-r--r--src/star-context.cpp365
1 files changed, 162 insertions, 203 deletions
diff --git a/src/star-context.cpp b/src/star-context.cpp
index d4996e189..30112cbe9 100644
--- a/src/star-context.cpp
+++ b/src/star-context.cpp
@@ -49,94 +49,64 @@
using Inkscape::DocumentUndo;
-static void sp_star_context_dispose (GObject *object);
+#include "tool-factory.h"
-static void sp_star_context_setup (SPEventContext *ec);
-static void sp_star_context_finish(SPEventContext *ec);
-static void sp_star_context_set (SPEventContext *ec, Inkscape::Preferences::Entry *val);
-static gint sp_star_context_root_handler (SPEventContext *ec, GdkEvent *event);
+namespace {
+ SPEventContext* createStarContext() {
+ return new SPStarContext();
+ }
-static void sp_star_drag (SPStarContext * sc, Geom::Point p, guint state);
-static void sp_star_finish (SPStarContext * sc);
-static void sp_star_cancel(SPStarContext * sc);
-
-G_DEFINE_TYPE(SPStarContext, sp_star_context, SP_TYPE_EVENT_CONTEXT);
-
-static void
-sp_star_context_class_init (SPStarContextClass * klass)
-{
- GObjectClass *object_class = G_OBJECT_CLASS(klass);
- SPEventContextClass *event_context_class = SP_EVENT_CONTEXT_CLASS(klass);
-
- object_class->dispose = sp_star_context_dispose;
+ bool starContextRegistered = ToolFactory::instance().registerObject("/tools/shapes/star", createStarContext);
+}
- event_context_class->setup = sp_star_context_setup;
- event_context_class->finish = sp_star_context_finish;
- event_context_class->set = sp_star_context_set;
- event_context_class->root_handler = sp_star_context_root_handler;
+const std::string& SPStarContext::getPrefsPath() {
+ return SPStarContext::prefsPath;
}
-static void
-sp_star_context_init (SPStarContext * star_context)
-{
- SPEventContext *event_context = SP_EVENT_CONTEXT (star_context);
+const std::string SPStarContext::prefsPath = "/tools/shapes/star";
- event_context->cursor_shape = cursor_star_xpm;
- event_context->hot_x = 4;
- event_context->hot_y = 4;
- event_context->xp = 0;
- event_context->yp = 0;
- event_context->tolerance = 0;
- event_context->within_tolerance = false;
- event_context->item_to_select = NULL;
- event_context->tool_url = "/tools/shapes/star";
+SPStarContext::SPStarContext() : SPEventContext() {
+ this->randomized = 0;
+ this->rounded = 0;
- star_context->item = NULL;
+ this->cursor_shape = cursor_star_xpm;
+ this->hot_x = 4;
+ this->hot_y = 4;
+ this->xp = 0;
+ this->yp = 0;
+ this->tolerance = 0;
+ this->within_tolerance = false;
+ this->item_to_select = NULL;
+ //this->tool_url = "/tools/shapes/star";
- star_context->magnitude = 5;
- star_context->proportion = 0.5;
- star_context->isflatsided = false;
+ this->star = NULL;
- new (&star_context->sel_changed_connection) sigc::connection();
+ this->magnitude = 5;
+ this->proportion = 0.5;
+ this->isflatsided = false;
}
-static void sp_star_context_finish(SPEventContext *ec)
-{
- SPStarContext *sc = SP_STAR_CONTEXT(ec);
- SPDesktop *desktop = ec->desktop;
-
+void SPStarContext::finish() {
sp_canvas_item_ungrab(SP_CANVAS_ITEM(desktop->acetate), GDK_CURRENT_TIME);
- sp_star_finish(sc);
- sc->sel_changed_connection.disconnect();
-
- if ((SP_EVENT_CONTEXT_CLASS(sp_star_context_parent_class))->finish) {
- (SP_EVENT_CONTEXT_CLASS(sp_star_context_parent_class))->finish(ec);
- }
-}
+ this->finishItem();
+ this->sel_changed_connection.disconnect();
-static void
-sp_star_context_dispose (GObject *object)
-{
- SPEventContext *ec = SP_EVENT_CONTEXT (object);
- SPStarContext *sc = SP_STAR_CONTEXT (object);
+ SPEventContext::finish();
+}
- ec->enableGrDrag(false);
+SPStarContext::~SPStarContext() {
+ this->enableGrDrag(false);
- sc->sel_changed_connection.disconnect();
- sc->sel_changed_connection.~connection();
+ this->sel_changed_connection.disconnect();
- delete ec->shape_editor;
- ec->shape_editor = NULL;
+ delete this->shape_editor;
+ this->shape_editor = NULL;
/* fixme: This is necessary because we do not grab */
- if (sc->item) sp_star_finish (sc);
-
- if (sc->_message_context) {
- delete sc->_message_context;
+ if (this->star) {
+ this->finishItem();
}
-
- G_OBJECT_CLASS (sp_star_context_parent_class)->dispose (object);
}
/**
@@ -145,101 +115,85 @@ sp_star_context_dispose (GObject *object)
*
* @param selection Should not be NULL.
*/
-static void sp_star_context_selection_changed (Inkscape::Selection * selection, gpointer data)
-{
+void SPStarContext::selection_changed(Inkscape::Selection* selection) {
g_assert (selection != NULL);
- SPStarContext *sc = SP_STAR_CONTEXT (data);
- SPEventContext *ec = SP_EVENT_CONTEXT (sc);
-
- ec->shape_editor->unset_item(SH_KNOTHOLDER);
- SPItem *item = selection->singleItem();
- ec->shape_editor->set_item(item, SH_KNOTHOLDER);
+ this->shape_editor->unset_item(SH_KNOTHOLDER);
+ this->shape_editor->set_item(selection->singleItem(), SH_KNOTHOLDER);
}
-static void
-sp_star_context_setup (SPEventContext *ec)
-{
- SPStarContext *sc = SP_STAR_CONTEXT (ec);
+void SPStarContext::setup() {
+ SPEventContext::setup();
- if ((SP_EVENT_CONTEXT_CLASS(sp_star_context_parent_class))->setup)
- (SP_EVENT_CONTEXT_CLASS(sp_star_context_parent_class))->setup (ec);
+ sp_event_context_read(this, "magnitude");
+ sp_event_context_read(this, "proportion");
+ sp_event_context_read(this, "isflatsided");
+ sp_event_context_read(this, "rounded");
+ sp_event_context_read(this, "randomized");
- sp_event_context_read (ec, "magnitude");
- sp_event_context_read (ec, "proportion");
- sp_event_context_read (ec, "isflatsided");
- sp_event_context_read (ec, "rounded");
- sp_event_context_read (ec, "randomized");
+ this->shape_editor = new ShapeEditor(this->desktop);
- ec->shape_editor = new ShapeEditor(ec->desktop);
+ SPItem *item = sp_desktop_selection(this->desktop)->singleItem();
+ if (item) {
+ this->shape_editor->set_item(item, SH_KNOTHOLDER);
+ }
- SPItem *item = sp_desktop_selection(ec->desktop)->singleItem();
- if (item) {
- ec->shape_editor->set_item(item, SH_KNOTHOLDER);
- }
-
- Inkscape::Selection *selection = sp_desktop_selection(ec->desktop);
- sc->sel_changed_connection.disconnect();
- sc->sel_changed_connection = selection->connectChanged(sigc::bind(sigc::ptr_fun(&sp_star_context_selection_changed), (gpointer)sc));
+ Inkscape::Selection *selection = sp_desktop_selection(this->desktop);
+
+ this->sel_changed_connection.disconnect();
- Inkscape::Preferences *prefs = Inkscape::Preferences::get();
- if (prefs->getBool("/tools/shapes/selcue")) {
- ec->enableSelectionCue();
- }
+ this->sel_changed_connection = selection->connectChanged(sigc::mem_fun(this, &SPStarContext::selection_changed));
- if (prefs->getBool("/tools/shapes/gradientdrag")) {
- ec->enableGrDrag();
- }
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ if (prefs->getBool("/tools/shapes/selcue")) {
+ this->enableSelectionCue();
+ }
- sc->_message_context = new Inkscape::MessageContext((ec->desktop)->messageStack());
+ if (prefs->getBool("/tools/shapes/gradientdrag")) {
+ this->enableGrDrag();
+ }
}
-static void
-sp_star_context_set (SPEventContext *ec, Inkscape::Preferences::Entry *val)
-{
- SPStarContext *sc = SP_STAR_CONTEXT (ec);
- Glib::ustring path = val->getEntryName();
+void SPStarContext::set(const Inkscape::Preferences::Entry& val) {
+ Glib::ustring path = val.getEntryName();
if (path == "magnitude") {
- sc->magnitude = CLAMP(val->getInt(5), 3, 1024);
+ this->magnitude = CLAMP(val.getInt(5), 3, 1024);
} else if (path == "proportion") {
- sc->proportion = CLAMP(val->getDouble(0.5), 0.01, 2.0);
+ this->proportion = CLAMP(val.getDouble(0.5), 0.01, 2.0);
} else if (path == "isflatsided") {
- sc->isflatsided = val->getBool();
+ this->isflatsided = val.getBool();
} else if (path == "rounded") {
- sc->rounded = val->getDouble();
+ this->rounded = val.getDouble();
} else if (path == "randomized") {
- sc->randomized = val->getDouble();
+ this->randomized = val.getDouble();
}
}
-static gint sp_star_context_root_handler(SPEventContext *event_context, GdkEvent *event)
-{
- static gboolean dragging;
+bool SPStarContext::root_handler(GdkEvent* event) {
+ static bool dragging;
- SPDesktop *desktop = event_context->desktop;
+ SPDesktop *desktop = this->desktop;
Inkscape::Selection *selection = sp_desktop_selection (desktop);
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
- SPStarContext *sc = SP_STAR_CONTEXT (event_context);
-
- event_context->tolerance = prefs->getIntLimited("/options/dragtolerance/value", 0, 0, 100);
+ this->tolerance = prefs->getIntLimited("/options/dragtolerance/value", 0, 0, 100);
gint ret = FALSE;
switch (event->type) {
case GDK_BUTTON_PRESS:
- if (event->button.button == 1 && !event_context->space_panning) {
-
- dragging = TRUE;
+ if (event->button.button == 1 && !this->space_panning) {
+ dragging = true;
- sc->center = Inkscape::setup_for_drag_start(desktop, event_context, event);
+ this->center = Inkscape::setup_for_drag_start(desktop, this, event);
/* Snap center */
SnapManager &m = desktop->namedview->snap_manager;
m.setup(desktop, true);
- m.freeSnapReturnByRef(sc->center, Inkscape::SNAPSOURCE_NODE_HANDLE);
+ m.freeSnapReturnByRef(this->center, Inkscape::SNAPSOURCE_NODE_HANDLE);
m.unSetup();
+
sp_canvas_item_grab(SP_CANVAS_ITEM(desktop->acetate),
GDK_KEY_PRESS_MASK | GDK_BUTTON_RELEASE_MASK |
GDK_POINTER_MOTION_MASK |
@@ -249,28 +203,28 @@ static gint sp_star_context_root_handler(SPEventContext *event_context, GdkEvent
ret = TRUE;
}
break;
- case GDK_MOTION_NOTIFY:
- if (dragging && (event->motion.state & GDK_BUTTON1_MASK) && !event_context->space_panning) {
- if ( event_context->within_tolerance
- && ( abs( (gint) event->motion.x - event_context->xp ) < event_context->tolerance )
- && ( abs( (gint) event->motion.y - event_context->yp ) < event_context->tolerance ) ) {
+ case GDK_MOTION_NOTIFY:
+ if (dragging && (event->motion.state & GDK_BUTTON1_MASK) && !this->space_panning) {
+ if ( this->within_tolerance
+ && ( abs( (gint) event->motion.x - this->xp ) < this->tolerance )
+ && ( abs( (gint) event->motion.y - this->yp ) < this->tolerance ) ) {
break; // do not drag if we're within tolerance from origin
}
// Once the user has moved farther than tolerance from the original location
// (indicating they intend to draw, not click), then always process the
// motion notify coordinates as given (no snapping back to origin)
- event_context->within_tolerance = false;
+ this->within_tolerance = false;
Geom::Point const motion_w(event->motion.x, event->motion.y);
Geom::Point motion_dt(desktop->w2d(motion_w));
- sp_star_drag (sc, motion_dt, event->motion.state);
+ this->drag(motion_dt, event->motion.state);
gobble_motion_events(GDK_BUTTON1_MASK);
ret = TRUE;
- } else if (!sp_event_context_knot_mouseover(event_context)) {
+ } else if (!sp_event_context_knot_mouseover(this)) {
SnapManager &m = desktop->namedview->snap_manager;
m.setup(desktop);
@@ -282,30 +236,34 @@ static gint sp_star_context_root_handler(SPEventContext *event_context, GdkEvent
}
break;
case GDK_BUTTON_RELEASE:
- event_context->xp = event_context->yp = 0;
- if (event->button.button == 1 && !event_context->space_panning) {
- dragging = FALSE;
- sp_event_context_discard_delayed_snap_event(event_context);
- if (!event_context->within_tolerance) {
+ this->xp = this->yp = 0;
+
+ if (event->button.button == 1 && !this->space_panning) {
+ dragging = false;
+
+ sp_event_context_discard_delayed_snap_event(this);
+
+ if (!this->within_tolerance) {
// we've been dragging, finish the star
- sp_star_finish (sc);
- } else if (event_context->item_to_select) {
+ this->finishItem();
+ } else if (this->item_to_select) {
// no dragging, select clicked item if any
if (event->button.state & GDK_SHIFT_MASK) {
- selection->toggle(event_context->item_to_select);
+ selection->toggle(this->item_to_select);
} else {
- selection->set(event_context->item_to_select);
+ selection->set(this->item_to_select);
}
} else {
// click in an empty space
selection->clear();
}
- event_context->item_to_select = NULL;
+ this->item_to_select = NULL;
ret = TRUE;
sp_canvas_item_ungrab(SP_CANVAS_ITEM (desktop->acetate), event->button.time);
}
break;
+
case GDK_KEY_PRESS:
switch (get_group0_keyval(&event->key)) {
case GDK_KEY_Alt_R:
@@ -315,11 +273,12 @@ static gint sp_star_context_root_handler(SPEventContext *event_context, GdkEvent
case GDK_KEY_Shift_R:
case GDK_KEY_Meta_L: // Meta is when you press Shift+Alt (at least on my machine)
case GDK_KEY_Meta_R:
- sp_event_show_modifier_tip(event_context->defaultMessageContext(), event,
+ sp_event_show_modifier_tip(this->defaultMessageContext(), event,
_("<b>Ctrl</b>: snap angle; keep rays radial"),
NULL,
NULL);
break;
+
case GDK_KEY_Up:
case GDK_KEY_Down:
case GDK_KEY_KP_Up:
@@ -328,6 +287,7 @@ static gint sp_star_context_root_handler(SPEventContext *event_context, GdkEvent
if (!MOD__CTRL_ONLY(event))
ret = TRUE;
break;
+
case GDK_KEY_x:
case GDK_KEY_X:
if (MOD__ALT_ONLY(event)) {
@@ -335,38 +295,44 @@ static gint sp_star_context_root_handler(SPEventContext *event_context, GdkEvent
ret = TRUE;
}
break;
+
case GDK_KEY_Escape:
if (dragging) {
dragging = false;
- sp_event_context_discard_delayed_snap_event(event_context);
+ sp_event_context_discard_delayed_snap_event(this);
// if drawing, cancel, otherwise pass it up for deselecting
- sp_star_cancel(sc);
+ this->cancel();
ret = TRUE;
}
break;
+
case GDK_KEY_space:
if (dragging) {
- sp_canvas_item_ungrab(SP_CANVAS_ITEM(desktop->acetate),
- event->button.time);
+ sp_canvas_item_ungrab(SP_CANVAS_ITEM(desktop->acetate), event->button.time);
+
dragging = false;
- sp_event_context_discard_delayed_snap_event(event_context);
- if (!event_context->within_tolerance) {
+
+ sp_event_context_discard_delayed_snap_event(this);
+
+ if (!this->within_tolerance) {
// we've been dragging, finish the star
- sp_star_finish(sc);
+ this->finishItem();
}
// do not return true, so that space would work switching to selector
}
break;
+
case GDK_KEY_Delete:
case GDK_KEY_KP_Delete:
case GDK_KEY_BackSpace:
- ret = event_context->deleteSelectedDrag(MOD__CTRL_ONLY(event));
+ ret = this->deleteSelectedDrag(MOD__CTRL_ONLY(event));
break;
default:
break;
}
break;
+
case GDK_KEY_RELEASE:
switch (get_group0_keyval (&event->key)) {
case GDK_KEY_Alt_L:
@@ -377,65 +343,66 @@ static gint sp_star_context_root_handler(SPEventContext *event_context, GdkEvent
case GDK_KEY_Shift_R:
case GDK_KEY_Meta_L: // Meta is when you press Shift+Alt
case GDK_KEY_Meta_R:
- event_context->defaultMessageContext()->clear();
+ this->defaultMessageContext()->clear();
break;
+
default:
break;
}
break;
+
default:
break;
}
if (!ret) {
- if ((SP_EVENT_CONTEXT_CLASS(sp_star_context_parent_class))->root_handler)
- ret = (SP_EVENT_CONTEXT_CLASS(sp_star_context_parent_class))->root_handler (event_context, event);
+ ret = SPEventContext::root_handler(event);
}
return ret;
}
-static void sp_star_drag(SPStarContext *sc, Geom::Point p, guint state)
+void SPStarContext::drag(Geom::Point p, guint state)
{
- SPDesktop *desktop = SP_EVENT_CONTEXT(sc)->desktop;
+ SPDesktop *desktop = this->desktop;
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
int const snaps = prefs->getInt("/options/rotationsnapsperpi/value", 12);
- if (!sc->item) {
-
- if (Inkscape::have_viable_layer(desktop, sc->_message_context) == false) {
+ if (!this->star) {
+ if (Inkscape::have_viable_layer(desktop, this->message_context) == false) {
return;
}
// Create object
- Inkscape::XML::Document *xml_doc = SP_EVENT_CONTEXT_DOCUMENT(sc)->getReprDoc();
+ Inkscape::XML::Document *xml_doc = this->desktop->doc()->getReprDoc();
Inkscape::XML::Node *repr = xml_doc->createElement("svg:path");
repr->setAttribute("sodipodi:type", "star");
// Set style
sp_desktop_apply_style_tool(desktop, repr, "/tools/shapes/star", false);
- sc->item = SP_ITEM(desktop->currentLayer()->appendChildRepr(repr));
+ this->star = SP_STAR(desktop->currentLayer()->appendChildRepr(repr));
+
Inkscape::GC::release(repr);
- sc->item->transform = SP_ITEM(desktop->currentLayer())->i2doc_affine().inverse();
- sc->item->updateRepr();
+ this->star->transform = SP_ITEM(desktop->currentLayer())->i2doc_affine().inverse();
+ this->star->updateRepr();
desktop->canvas->forceFullRedrawAfterInterruptions(5);
}
/* Snap corner point with no constraints */
SnapManager &m = desktop->namedview->snap_manager;
- m.setup(desktop, true, sc->item);
+
+ m.setup(desktop, true, this->star);
Geom::Point pt2g = p;
m.freeSnapReturnByRef(pt2g, Inkscape::SNAPSOURCE_NODE_HANDLE);
m.unSetup();
- Geom::Point const p0 = desktop->dt2doc(sc->center);
- Geom::Point const p1 = desktop->dt2doc(pt2g);
- SPStar *star = SP_STAR(sc->item);
+ Geom::Point const p0 = desktop->dt2doc(this->center);
+ Geom::Point const p1 = desktop->dt2doc(pt2g);
- double const sides = (gdouble) sc->magnitude;
+ double const sides = (gdouble) this->magnitude;
Geom::Point const d = p1 - p0;
Geom::Coord const r1 = Geom::L2(d);
double arg1 = atan2(d);
@@ -445,14 +412,14 @@ static void sp_star_drag(SPStarContext *sc, Geom::Point p, guint state)
arg1 = sp_round(arg1, M_PI / snaps);
}
- sp_star_position_set(star, sc->magnitude, p0, r1, r1 * sc->proportion,
- arg1, arg1 + M_PI / sides, sc->isflatsided, sc->rounded, sc->randomized);
+ sp_star_position_set(this->star, this->magnitude, p0, r1, r1 * this->proportion,
+ arg1, arg1 + M_PI / sides, this->isflatsided, this->rounded, this->randomized);
/* status text */
Inkscape::Util::Quantity q = Inkscape::Util::Quantity(r1, "px");
GString *rads = g_string_new(q.string(*desktop->namedview->doc_units).c_str());
- sc->_message_context->setF(Inkscape::IMMEDIATE_MESSAGE,
- ( sc->isflatsided?
+ this->message_context->setF(Inkscape::IMMEDIATE_MESSAGE,
+ ( this->isflatsided?
_("<b>Polygon</b>: radius %s, angle %5g&#176;; with <b>Ctrl</b> to snap angle")
: _("<b>Star</b>: radius %s, angle %5g&#176;; with <b>Ctrl</b> to snap angle") ),
rads->str, sp_round((arg1) * 180 / M_PI, 0.0001));
@@ -460,55 +427,47 @@ static void sp_star_drag(SPStarContext *sc, Geom::Point p, guint state)
g_string_free(rads, FALSE);
}
-static void
-sp_star_finish (SPStarContext * sc)
-{
- sc->_message_context->clear();
+void SPStarContext::finishItem() {
+ this->message_context->clear();
- if (sc->item != NULL) {
- SPStar *star = SP_STAR(sc->item);
- if (star->r[1] == 0) {
- sp_star_cancel(sc); // Don't allow the creating of zero sized arc, for example when the start and and point snap to the snap grid point
+ if (this->star != NULL) {
+ if (this->star->r[1] == 0) {
+ // Don't allow the creating of zero sized arc, for example
+ // when the start and and point snap to the snap grid point
+ this->cancel();
return;
}
// Set transform center, so that odd stars rotate correctly
// LP #462157
- sc->item->setCenter(sc->center);
-
- SPDesktop *desktop = SP_EVENT_CONTEXT(sc)->desktop;
- SPObject *object = SP_OBJECT(sc->item);
-
- (SP_SHAPE(sc->item))->setShape();
-
- object->updateRepr(SP_OBJECT_WRITE_EXT);
+ this->star->setCenter(this->center);
+ this->star->set_shape();
+ this->star->updateRepr(SP_OBJECT_WRITE_EXT);
+ this->star->doWriteTransform(this->star->getRepr(), this->star->transform, NULL, true);
desktop->canvas->endForcedFullRedraws();
- sp_desktop_selection(desktop)->set(sc->item);
+ sp_desktop_selection(desktop)->set(this->star);
DocumentUndo::done(sp_desktop_document(desktop), SP_VERB_CONTEXT_STAR,
_("Create star"));
- sc->item = NULL;
+ this->star = NULL;
}
}
-static void sp_star_cancel(SPStarContext *sc)
-{
- SPDesktop *desktop = SP_EVENT_CONTEXT(sc)->desktop;
-
+void SPStarContext::cancel() {
sp_desktop_selection(desktop)->clear();
sp_canvas_item_ungrab(SP_CANVAS_ITEM(desktop->acetate), 0);
- if (sc->item != NULL) {
- SP_OBJECT(sc->item)->deleteObject();
- sc->item = NULL;
+ if (this->star != NULL) {
+ this->star->deleteObject();
+ this->star = NULL;
}
- sc->within_tolerance = false;
- sc->xp = 0;
- sc->yp = 0;
- sc->item_to_select = NULL;
+ this->within_tolerance = false;
+ this->xp = 0;
+ this->yp = 0;
+ this->item_to_select = NULL;
desktop->canvas->endForcedFullRedraws();