diff --git a/src/rect-context.cpp b/src/rect-context.cpp
index 1d62667956b84d8499a3db1a3ab6b7a19443ce4c..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.
*
ec->shape_repr = shape_repr;
Inkscape::GC::anchor(shape_repr);
sp_repr_add_listener(shape_repr, &ec_shape_repr_events, ec);
- sp_repr_synthesize_events(shape_repr, &ec_shape_repr_events, ec);
}
}
}
((SPEventContextClass *) parent_class)->setup(ec);
}
- SPItem *item = SP_DT_SELECTION(ec->desktop)->singleItem();
+ SPItem *item = sp_desktop_selection(ec->desktop)->singleItem();
if (item) {
ec->shape_knot_holder = sp_item_knot_holder(item, ec->desktop);
Inkscape::XML::Node *shape_repr = SP_OBJECT_REPR(item);
ec->shape_repr = shape_repr;
Inkscape::GC::anchor(shape_repr);
sp_repr_add_listener(shape_repr, &ec_shape_repr_events, ec);
- sp_repr_synthesize_events(shape_repr, &ec_shape_repr_events, ec);
}
}
rc->sel_changed_connection.disconnect();
- rc->sel_changed_connection = SP_DT_SELECTION(ec->desktop)->connectChanged(
+ rc->sel_changed_connection = sp_desktop_selection(ec->desktop)->connectChanged(
sigc::bind(sigc::ptr_fun(&sp_rect_context_selection_changed), (gpointer)rc)
);
@@ -272,7 +271,7 @@ static gint sp_rect_context_root_handler(SPEventContext *event_context, GdkEvent
static bool dragging;
SPDesktop *desktop = event_context->desktop;
- Inkscape::Selection *selection = SP_DT_SELECTION (desktop);
+ Inkscape::Selection *selection = sp_desktop_selection (desktop);
SPRectContext *rc = SP_RECT_CONTEXT(event_context);
@@ -299,7 +298,7 @@ static gint sp_rect_context_root_handler(SPEventContext *event_context, GdkEvent
NR::Point const button_dt(desktop->w2d(button_w));
/* Snap center */
- SnapManager const m(desktop->namedview);
+ SnapManager const &m = desktop->namedview->snap_manager;
rc->center = m.freeSnap(Inkscape::Snapper::SNAP_POINT | Inkscape::Snapper::BBOX_POINT,
button_dt, rc->item).getPoint();
@@ -307,7 +306,6 @@ static gint sp_rect_context_root_handler(SPEventContext *event_context, GdkEvent
( GDK_KEY_PRESS_MASK |
GDK_BUTTON_RELEASE_MASK |
GDK_POINTER_MOTION_MASK |
- GDK_POINTER_MOTION_HINT_MASK |
GDK_BUTTON_PRESS_MASK ),
NULL, event->button.time);
ret = TRUE;
@@ -329,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;
@@ -370,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:
@@ -393,8 +398,23 @@ static gint sp_rect_context_root_handler(SPEventContext *event_context, GdkEvent
break;
case GDK_Escape:
- SP_DT_SELECTION(desktop)->clear();
+ 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);
Inkscape::GC::release(repr);
rc.item->transform = SP_ITEM(desktop->currentRoot())->getRelativeTransform(desktop->currentLayer());
rc.item->updateRepr();
+
+ sp_canvas_force_full_redraw_after_interruptions(desktop->canvas, 5);
}
NR::Rect const r = Inkscape::snap_rectangular_box(desktop, rc.item, pt, rc.center, state);
rc->_message_context->clear();
if ( rc->item != NULL ) {
- SPDesktop * dt;
+ SPDesktop * desktop;
- dt = SP_EVENT_CONTEXT_DESKTOP(rc);
+ desktop = SP_EVENT_CONTEXT_DESKTOP(rc);
SP_OBJECT(rc->item)->updateRepr();
- SP_DT_SELECTION(dt)->set(rc->item);
- sp_document_done(SP_DT_DOCUMENT(dt));
+ sp_canvas_end_forced_full_redraws(desktop->canvas);
+
+ sp_desktop_selection(desktop)->set(rc->item);
+ sp_document_done(sp_desktop_document(desktop), SP_VERB_CONTEXT_RECT,
+ _("Create rectangle"));
rc->item = NULL;
}