diff --git a/src/spiral-context.cpp b/src/spiral-context.cpp
index 9944e86b4a99d76a77754acc257d34465e6fe2e7..35d5144a7881d58f8b67f87321bd848fc10b6fa6 100644 (file)
--- a/src/spiral-context.cpp
+++ b/src/spiral-context.cpp
#include "xml/node-event-vector.h"
#include "preferences.h"
#include "context-fns.h"
+#include "shape-editor.h"
static void sp_spiral_context_class_init(SPSpiralContextClass * klass);
static void sp_spiral_context_init(SPSpiralContext *spiral_context);
event_context->within_tolerance = false;
event_context->item_to_select = NULL;
- event_context->shape_repr = NULL;
- event_context->shape_knot_holder = NULL;
-
spiral_context->item = NULL;
spiral_context->revo = 3.0;
sc->sel_changed_connection.disconnect();
sc->sel_changed_connection.~connection();
+ delete ec->shape_editor;
+ ec->shape_editor = NULL;
+
/* fixme: This is necessary because we do not grab */
if (sc->item) sp_spiral_finish(sc);
- if (ec->shape_knot_holder) {
- delete ec->shape_knot_holder;
- ec->shape_knot_holder = NULL;
- }
-
- if (ec->shape_repr) { // remove old listener
- sp_repr_remove_listener_by_data(ec->shape_repr, ec);
- Inkscape::GC::release(ec->shape_repr);
- ec->shape_repr = 0;
- }
-
if (sc->_message_context) {
delete sc->_message_context;
}
G_OBJECT_CLASS(parent_class)->dispose(object);
}
-static Inkscape::XML::NodeEventVector ec_shape_repr_events = {
- NULL, /* child_added */
- NULL, /* child_removed */
- ec_shape_event_attr_changed,
- NULL, /* content_changed */
- NULL /* order_changed */
-};
-
/**
\brief Callback that processes the "changed" signal on the selection;
destroys old and creates new knotholder
@@ -166,27 +148,9 @@ sp_spiral_context_selection_changed(Inkscape::Selection *selection, gpointer dat
SPSpiralContext *sc = SP_SPIRAL_CONTEXT(data);
SPEventContext *ec = SP_EVENT_CONTEXT(sc);
- if (ec->shape_knot_holder) { // desktroy knotholder
- delete ec->shape_knot_holder;
- ec->shape_knot_holder = NULL;
- }
-
- if (ec->shape_repr) { // remove old listener
- sp_repr_remove_listener_by_data(ec->shape_repr, ec);
- Inkscape::GC::release(ec->shape_repr);
- ec->shape_repr = 0;
- }
-
+ ec->shape_editor->unset_item(SH_KNOTHOLDER);
SPItem *item = selection->singleItem();
- if (item) {
- ec->shape_knot_holder = sp_item_knot_holder(item, ec->desktop);
- Inkscape::XML::Node *shape_repr = SP_OBJECT_REPR(item);
- if (shape_repr) {
- ec->shape_repr = shape_repr;
- Inkscape::GC::anchor(shape_repr);
- sp_repr_add_listener(shape_repr, &ec_shape_repr_events, ec);
- }
- }
+ ec->shape_editor->set_item(item, SH_KNOTHOLDER);
}
static void
sp_event_context_read(ec, "revolution");
sp_event_context_read(ec, "t0");
- Inkscape::Selection *selection = sp_desktop_selection(ec->desktop);
+ ec->shape_editor = new ShapeEditor(ec->desktop);
- SPItem *item = selection->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);
- if (shape_repr) {
- ec->shape_repr = shape_repr;
- Inkscape::GC::anchor(shape_repr);
- sp_repr_add_listener(shape_repr, &ec_shape_repr_events, ec);
- }
+ ec->shape_editor->set_item(item, SH_KNOTHOLDER);
}
+ Inkscape::Selection *selection = sp_desktop_selection(ec->desktop);
sc->sel_changed_connection.disconnect();
sc->sel_changed_connection = selection->connectChanged(sigc::bind(sigc::ptr_fun(&sp_spiral_context_selection_changed), (gpointer)sc));
if (event->button.button == 1 && !event_context->space_panning) {
dragging = TRUE;
+ sp_canvas_set_snap_delay_active(desktop->canvas, true);
sc->center = Inkscape::setup_for_drag_start(desktop, event_context, event);
SnapManager &m = desktop->namedview->snap_manager;
Geom::Point const motion_w(event->motion.x, event->motion.y);
Geom::Point motion_dt(event_context->desktop->w2d(motion_w));
-
+
SnapManager &m = desktop->namedview->snap_manager;
m.setup(desktop, true, sc->item);
m.freeSnapReturnByRef(Inkscape::SnapPreferences::SNAPPOINT_NODE, motion_dt);
event_context->xp = event_context->yp = 0;
if (event->button.button == 1 && !event_context->space_panning) {
dragging = FALSE;
+ sp_canvas_set_snap_delay_active(desktop->canvas, false);
if (!event_context->within_tolerance) {
// we've been dragging, finish the spiral
sp_spiral_finish(sc);
sp_canvas_item_ungrab(SP_CANVAS_ITEM(desktop->acetate),
event->button.time);
dragging = false;
+ sp_canvas_set_snap_delay_active(desktop->canvas, false);
if (!event_context->within_tolerance) {
// we've been dragging, finish the rect
sp_spiral_finish(sc);
m.freeSnapReturnByRef(Inkscape::SnapPreferences::SNAPPOINT_NODE, pt2g);
Geom::Point const p0 = to_2geom(sp_desktop_dt2doc_xy_point(desktop, sc->center));
- Geom::Point const p1 = to_2geom(sp_desktop_dt2doc_xy_point(desktop, from_2geom(pt2g)));
-
+ Geom::Point const p1 = to_2geom(sp_desktop_dt2doc_xy_point(desktop, from_2geom(pt2g)));
+
SPSpiral *spiral = SP_SPIRAL(sc->item);
Geom::Point const delta = p1 - p0;
sp_canvas_end_forced_full_redraws(desktop->canvas);
sp_desktop_selection(desktop)->set(sc->item);
- sp_document_done(sp_desktop_document(desktop), SP_VERB_CONTEXT_SPIRAL,
+ sp_document_done(sp_desktop_document(desktop), SP_VERB_CONTEXT_SPIRAL,
_("Create spiral"));
sc->item = NULL;