summaryrefslogtreecommitdiffstats
path: root/src/star-context.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/star-context.cpp')
-rw-r--r--src/star-context.cpp29
1 files changed, 23 insertions, 6 deletions
diff --git a/src/star-context.cpp b/src/star-context.cpp
index c5eff3c6a..3d6825e31 100644
--- a/src/star-context.cpp
+++ b/src/star-context.cpp
@@ -34,6 +34,7 @@
#include "desktop.h"
#include "desktop-style.h"
#include "message-context.h"
+#include "libnr/nr-macros.h"
#include "pixmaps/cursor-star.xpm"
#include "sp-metrics.h"
#include <glibmm/i18n.h>
@@ -51,6 +52,7 @@ static void sp_star_context_init (SPStarContext * star_context);
static void sp_star_context_dispose (GObject *object);
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);
@@ -91,6 +93,7 @@ sp_star_context_class_init (SPStarContextClass * klass)
object_class->dispose = sp_star_context_dispose;
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;
}
@@ -118,6 +121,21 @@ sp_star_context_init (SPStarContext * star_context)
new (&star_context->sel_changed_connection) sigc::connection();
}
+static void sp_star_context_finish(SPEventContext *ec)
+{
+ SPStarContext *sc = SP_STAR_CONTEXT(ec);
+ SPDesktop *desktop = ec->desktop;
+
+ sp_canvas_item_ungrab(SP_CANVAS_ITEM(desktop->acetate), GDK_CURRENT_TIME);
+ sp_star_finish(sc);
+ sc->sel_changed_connection.disconnect();
+
+ if (((SPEventContextClass *) parent_class)->finish) {
+ ((SPEventContextClass *) parent_class)->finish(ec);
+ }
+}
+
+
static void
sp_star_context_dispose (GObject *object)
{
@@ -204,9 +222,9 @@ sp_star_context_set (SPEventContext *ec, Inkscape::Preferences::Entry *val)
Glib::ustring path = val->getEntryName();
if (path == "magnitude") {
- sc->magnitude = CLAMP (val->getInt(5), 3, 1024);
+ sc->magnitude = NR_CLAMP(val->getInt(5), 3, 1024);
} else if (path == "proportion") {
- sc->proportion = CLAMP (val->getDouble(0.5), 0.01, 2.0);
+ sc->proportion = NR_CLAMP(val->getDouble(0.5), 0.01, 2.0);
} else if (path == "isflatsided") {
sc->isflatsided = val->getBool();
} else if (path == "rounded") {
@@ -235,7 +253,6 @@ static gint sp_star_context_root_handler(SPEventContext *event_context, GdkEvent
if (event->button.button == 1 && !event_context->space_panning) {
dragging = TRUE;
- sp_event_context_snap_window_open(event_context);
sc->center = Inkscape::setup_for_drag_start(desktop, event_context, event);
@@ -282,7 +299,7 @@ static gint sp_star_context_root_handler(SPEventContext *event_context, GdkEvent
event_context->xp = event_context->yp = 0;
if (event->button.button == 1 && !event_context->space_panning) {
dragging = FALSE;
- sp_event_context_snap_window_closed(event_context, false); //button release will also occur on a double-click; in that case suppress warnings
+ sp_event_context_discard_delayed_snap_event(event_context);
if (!event_context->within_tolerance) {
// we've been dragging, finish the star
sp_star_finish (sc);
@@ -335,7 +352,7 @@ static gint sp_star_context_root_handler(SPEventContext *event_context, GdkEvent
case GDK_Escape:
if (dragging) {
dragging = false;
- sp_event_context_snap_window_closed(event_context);
+ sp_event_context_discard_delayed_snap_event(event_context);
// if drawing, cancel, otherwise pass it up for deselecting
sp_star_cancel(sc);
ret = TRUE;
@@ -346,7 +363,7 @@ static gint sp_star_context_root_handler(SPEventContext *event_context, GdkEvent
sp_canvas_item_ungrab(SP_CANVAS_ITEM(desktop->acetate),
event->button.time);
dragging = false;
- sp_event_context_snap_window_closed(event_context);
+ sp_event_context_discard_delayed_snap_event(event_context);
if (!event_context->within_tolerance) {
// we've been dragging, finish the star
sp_star_finish(sc);