summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDiederik van Lierop <mail@diedenrezi.nl>2009-07-08 20:48:55 +0000
committerdvlierop2 <dvlierop2@users.sourceforge.net>2009-07-08 20:48:55 +0000
commit339b9147b242dfdf4a7d789e48f8232e7fa87a5e (patch)
tree318e291e6e214a34c90dcad23f858a18a2fce868 /src
parentWhen translating too many nodes, a convex hull is used for snapping. This is ... (diff)
downloadinkscape-339b9147b242dfdf4a7d789e48f8232e7fa87a5e.tar.gz
inkscape-339b9147b242dfdf4a7d789e48f8232e7fa87a5e.zip
Don't create rectangles that have a zero x or y dimension. When snapping for example to the same point twice then just cancel the rect creation (Fixes bug #375975). And while we're at it, make the rectangle tool escapeable by pressing esc. See also rev. #21706 which was similar but applied to ellipses instead.
(bzr r8237)
Diffstat (limited to 'src')
-rw-r--r--src/rect-context.cpp43
1 files changed, 38 insertions, 5 deletions
diff --git a/src/rect-context.cpp b/src/rect-context.cpp
index c05f00759..51b5f2e85 100644
--- a/src/rect-context.cpp
+++ b/src/rect-context.cpp
@@ -57,6 +57,7 @@ static gint sp_rect_context_item_handler(SPEventContext *event_context, SPItem *
static void sp_rect_drag(SPRectContext &rc, Geom::Point const pt, guint state);
static void sp_rect_finish(SPRectContext *rc);
+static void sp_rect_cancel(SPRectContext *rc);
static SPEventContextClass *parent_class;
@@ -372,9 +373,14 @@ static gint sp_rect_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_rect_cancel(rc);
+ ret = TRUE;
+ }
+ break;
case GDK_space:
if (dragging) {
@@ -503,9 +509,13 @@ static void sp_rect_finish(SPRectContext *rc)
rc->_message_context->clear();
if ( rc->item != NULL ) {
- SPDesktop * desktop;
+ SPRect *rect = SP_RECT(rc->item);
+ if (rect->width.computed == 0 || rect->height.computed == 0) {
+ sp_rect_cancel(rc); // Don't allow the creating of zero sized rectangle, for example when the start and and point snap to the snap grid point
+ return;
+ }
- desktop = SP_EVENT_CONTEXT_DESKTOP(rc);
+ SPDesktop *desktop = SP_EVENT_CONTEXT_DESKTOP(rc);
SP_OBJECT(rc->item)->updateRepr();
@@ -519,6 +529,29 @@ static void sp_rect_finish(SPRectContext *rc)
}
}
+static void sp_rect_cancel(SPRectContext *rc)
+{
+ SPDesktop *desktop = SP_EVENT_CONTEXT(rc)->desktop;
+
+ sp_desktop_selection(desktop)->clear();
+ sp_canvas_item_ungrab(SP_CANVAS_ITEM(desktop->acetate), 0);
+
+ if (rc->item != NULL) {
+ SP_OBJECT(rc->item)->deleteObject();
+ rc->item = NULL;
+ }
+
+ rc->within_tolerance = false;
+ rc->xp = 0;
+ rc->yp = 0;
+ rc->item_to_select = NULL;
+
+ sp_canvas_end_forced_full_redraws(desktop->canvas);
+
+ sp_document_cancel(sp_desktop_document(desktop));
+}
+
+
/*
Local Variables:
mode:c++