diff --git a/src/rect-context.cpp b/src/rect-context.cpp
index f1494646341f08b87dba252a36bb5bf943f7b77e..c8f9bf0f101d0b1e2cc9e3b50a79bf49b5f3dc13 100644 (file)
--- a/src/rect-context.cpp
+++ b/src/rect-context.cpp
* Lauris Kaplinski <lauris@kaplinski.com>
* bulia byak <buliabyak@users.sf.net>
*
+ * Copyright (C) 2006 Johan Engelen <johan@shouraizou.nl>
* Copyright (C) 2000-2005 authors
* Copyright (C) 2000-2001 Ximian, Inc.
*
#include "desktop-style.h"
#include "message-context.h"
#include "pixmaps/cursor-rect.xpm"
-#include "pixmaps/cursor-rect.pixbuf"
#include "rect-context.h"
#include "sp-metrics.h"
#include <glibmm/i18n.h>
SPEventContext *event_context = SP_EVENT_CONTEXT(rect_context);
event_context->cursor_shape = cursor_rect_xpm;
- event_context->cursor_pixbuf = gdk_pixbuf_new_from_inline(
- -1,
- cursor_rect_pixbuf,
- FALSE,
- NULL);
event_context->hot_x = 4;
event_context->hot_y = 4;
event_context->xp = 0;
@@ -332,8 +327,13 @@ static gint sp_rect_context_root_handler(SPEventContext *event_context, GdkEvent
NR::Point const motion_w(event->motion.x,
event->motion.y);
- NR::Point const motion_dt(desktop->w2d(motion_w));
+ NR::Point motion_dt(desktop->w2d(motion_w));
+
+ SnapManager const &m = desktop->namedview->snap_manager;
+ motion_dt = m.freeSnap(Inkscape::Snapper::BBOX_POINT | Inkscape::Snapper::SNAP_POINT, motion_dt, rc->item).getPoint();
+
sp_rect_drag(*rc, motion_dt, event->motion.state);
+
ret = TRUE;
}
break;
@@ -373,10 +373,12 @@ static gint sp_rect_context_root_handler(SPEventContext *event_context, GdkEvent
case GDK_Shift_R:
case GDK_Meta_L: // Meta is when you press Shift+Alt (at least on my machine)
case GDK_Meta_R:
- sp_event_show_modifier_tip (event_context->defaultMessageContext(), event,
- _("<b>Ctrl</b>: make square or integer-ratio rect, lock a rounded corner circular"),
- _("<b>Shift</b>: draw around the starting point"),
- NULL);
+ if (!dragging){
+ sp_event_show_modifier_tip (event_context->defaultMessageContext(), event,
+ _("<b>Ctrl</b>: make square or integer-ratio rect, lock a rounded corner circular"),
+ _("<b>Shift</b>: draw around the starting point"),
+ NULL);
+ }
break;
case GDK_Up:
case GDK_Down:
@@ -398,6 +400,21 @@ static gint sp_rect_context_root_handler(SPEventContext *event_context, GdkEvent
case GDK_Escape:
sp_desktop_selection(desktop)->clear();
//TODO: make dragging escapable by Esc
+ break;
+
+ case GDK_space:
+ if (dragging) {
+ sp_canvas_item_ungrab(SP_CANVAS_ITEM(desktop->acetate),
+ event->button.time);
+ dragging = false;
+ if (!event_context->within_tolerance) {
+ // we've been dragging, finish the rect
+ sp_rect_finish(rc);
+ }
+ // do not return true, so that space would work switching to selector
+ }
+ break;
+
default:
break;
}
}
/* Create object */
- Inkscape::XML::Node *repr = sp_repr_new("svg:rect");
+ Inkscape::XML::Document *xml_doc = sp_document_repr_doc(SP_EVENT_CONTEXT_DOCUMENT(&rc));
+ Inkscape::XML::Node *repr = xml_doc->createElement("svg:rect");
/* Set style */
sp_desktop_apply_style_tool (desktop, repr, "tools.shapes.rect", false);