summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 61c8559)
raw | patch | inline | side by side (parent: 61c8559)
author | dvlierop2 <dvlierop2@users.sourceforge.net> | |
Thu, 9 Jul 2009 21:16:23 +0000 (21:16 +0000) | ||
committer | dvlierop2 <dvlierop2@users.sourceforge.net> | |
Thu, 9 Jul 2009 21:16:23 +0000 (21:16 +0000) |
src/sp-spiral.cpp | patch | blob | history | |
src/spiral-context.cpp | patch | blob | history | |
src/star-context.cpp | patch | blob | history |
diff --git a/src/sp-spiral.cpp b/src/sp-spiral.cpp
index 872607c275da938770a17b1521edb441899737eb..71906fcc0c3b65d394e6333dd163c7640a7ddaed 100644 (file)
--- a/src/sp-spiral.cpp
+++ b/src/sp-spiral.cpp
spiral->cy = cy;
spiral->exp = exp;
spiral->revo = revo;
- spiral->rad = MAX (rad, 0.001);
+ spiral->rad = MAX (rad, 0.0);
spiral->arg = arg;
spiral->t0 = CLAMP(t0, 0.0, 0.999);
diff --git a/src/spiral-context.cpp b/src/spiral-context.cpp
index cd90ac1cf15362830cb1e07857100d1a7d213457..2f65b0ba9f3ea4c1f255a5a38c8aaa44d58f62a9 100644 (file)
--- a/src/spiral-context.cpp
+++ b/src/spiral-context.cpp
static void sp_spiral_drag(SPSpiralContext *sc, Geom::Point p, guint state);
static void sp_spiral_finish(SPSpiralContext *sc);
+static void sp_spiral_cancel(SPSpiralContext *sc);
static SPEventContextClass *parent_class;
}
break;
case GDK_Escape:
- sp_desktop_selection(desktop)->clear();
- //TODO: make dragging escapable by Esc
- break;
+ if (dragging) {
+ dragging = false;
+ sp_event_context_snap_window_closed(event_context);
+ // if drawing, cancel, otherwise pass it up for deselecting
+ sp_spiral_cancel(sc);
+ ret = TRUE;
+ }
+ break;
case GDK_space:
if (dragging) {
dragging = false;
sp_event_context_snap_window_closed(event_context);
if (!event_context->within_tolerance) {
- // we've been dragging, finish the rect
+ // we've been dragging, finish the spiral
sp_spiral_finish(sc);
}
// do not return true, so that space would work switching to selector
sc->_message_context->clear();
if (sc->item != NULL) {
- SPDesktop *desktop = SP_EVENT_CONTEXT(sc)->desktop;
- SPSpiral *spiral = SP_SPIRAL(sc->item);
+ SPSpiral *spiral = SP_SPIRAL(sc->item);
+ if (spiral->rad == 0) {
+ sp_spiral_cancel(sc); // Don't allow the creating of zero sized spiral, for example when the start and and point snap to the snap grid point
+ return;
+ }
+
+ SPDesktop *desktop = SP_EVENT_CONTEXT(sc)->desktop;
sp_shape_set_shape(SP_SHAPE(spiral));
SP_OBJECT(spiral)->updateRepr(SP_OBJECT_WRITE_EXT);
}
}
+static void sp_spiral_cancel(SPSpiralContext *sc)
+{
+ SPDesktop *desktop = SP_EVENT_CONTEXT(sc)->desktop;
+
+ 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;
+ }
+
+ sc->within_tolerance = false;
+ sc->xp = 0;
+ sc->yp = 0;
+ sc->item_to_select = NULL;
+
+ sp_canvas_end_forced_full_redraws(desktop->canvas);
+
+ sp_document_cancel(sp_desktop_document(desktop));
+}
/*
Local Variables:
diff --git a/src/star-context.cpp b/src/star-context.cpp
index a004426081af848b10bcbc15851afa57b04f3b60..c5eff3c6a89b3622feefa0c521349af5b8a968a7 100644 (file)
--- a/src/star-context.cpp
+++ b/src/star-context.cpp
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);
static SPEventContextClass * parent_class;
@@ -332,10 +333,14 @@ static gint sp_star_context_root_handler(SPEventContext *event_context, GdkEvent
}
break;
case GDK_Escape:
- sp_desktop_selection(desktop)->clear();
- //TODO: make dragging escapable by Esc
- break;
-
+ if (dragging) {
+ dragging = false;
+ sp_event_context_snap_window_closed(event_context);
+ // if drawing, cancel, otherwise pass it up for deselecting
+ sp_star_cancel(sc);
+ ret = TRUE;
+ }
+ break;
case GDK_space:
if (dragging) {
sp_canvas_item_ungrab(SP_CANVAS_ITEM(desktop->acetate),
@@ -343,7 +348,7 @@ static gint sp_star_context_root_handler(SPEventContext *event_context, GdkEvent
dragging = false;
sp_event_context_snap_window_closed(event_context);
if (!event_context->within_tolerance) {
- // we've been dragging, finish the rect
+ // we've been dragging, finish the star
sp_star_finish(sc);
}
// do not return true, so that space would work switching to selector
sc->_message_context->clear();
if (sc->item != NULL) {
- SPDesktop *desktop = SP_EVENT_CONTEXT(sc)->desktop;
+ 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
+ return;
+ }
+
+ SPDesktop *desktop = SP_EVENT_CONTEXT(sc)->desktop;
SPObject *object = SP_OBJECT(sc->item);
sp_shape_set_shape(SP_SHAPE(sc->item));
}
}
+static void sp_star_cancel(SPStarContext *sc)
+{
+ SPDesktop *desktop = SP_EVENT_CONTEXT(sc)->desktop;
+
+ 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;
+ }
+
+ sc->within_tolerance = false;
+ sc->xp = 0;
+ sc->yp = 0;
+ sc->item_to_select = NULL;
+
+ sp_canvas_end_forced_full_redraws(desktop->canvas);
+
+ sp_document_cancel(sp_desktop_document(desktop));
+}
+
/*
Local Variables:
mode:c++