From: buliabyak Date: Thu, 8 Jan 2009 05:37:37 +0000 (+0000) Subject: switch to using shape_editor, instead of separate knotholders and listeners; fixes... X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=a832584a456279eae69530a8e1e28f0b873ecc0f;p=inkscape.git switch to using shape_editor, instead of separate knotholders and listeners; fixes a lot of crashes, simplifies code --- diff --git a/src/arc-context.cpp b/src/arc-context.cpp index d7982e979..3c8a50192 100644 --- a/src/arc-context.cpp +++ b/src/arc-context.cpp @@ -40,6 +40,7 @@ #include "desktop-style.h" #include "context-fns.h" #include "verbs.h" +#include "shape-editor.h" #include "arc-context.h" @@ -103,9 +104,6 @@ static void sp_arc_context_init(SPArcContext *arc_context) event_context->within_tolerance = false; event_context->item_to_select = NULL; - event_context->shape_repr = NULL; - event_context->shape_knot_holder = NULL; - arc_context->item = NULL; new (&arc_context->sel_changed_connection) sigc::connection(); @@ -121,16 +119,8 @@ static void sp_arc_context_dispose(GObject *object) ac->sel_changed_connection.disconnect(); ac->sel_changed_connection.~connection(); - 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; - } + delete ec->shape_editor; + ec->shape_editor = NULL; /* fixme: This is necessary because we do not grab */ if (ac->item) { @@ -142,14 +132,6 @@ static void sp_arc_context_dispose(GObject *object) 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. @@ -159,27 +141,9 @@ void sp_arc_context_selection_changed(Inkscape::Selection * selection, gpointer SPArcContext *ac = SP_ARC_CONTEXT(data); SPEventContext *ec = SP_EVENT_CONTEXT(ac); - 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; - } - - SPItem *item = selection ? selection->singleItem() : NULL; - 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->unset_item(SH_KNOTHOLDER); + SPItem *item = selection->singleItem(); + ec->shape_editor->set_item(item, SH_KNOTHOLDER); } static void sp_arc_context_setup(SPEventContext *ec) @@ -191,16 +155,11 @@ static void sp_arc_context_setup(SPEventContext *ec) ((SPEventContextClass *) parent_class)->setup(ec); } - SPItem *item = selection->singleItem(); + ec->shape_editor = new ShapeEditor(ec->desktop); + 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); } ac->sel_changed_connection.disconnect(); diff --git a/src/box3d-context.cpp b/src/box3d-context.cpp index 404723231..2d20318e3 100644 --- a/src/box3d-context.cpp +++ b/src/box3d-context.cpp @@ -47,6 +47,7 @@ #include "box3d-side.h" #include "document-private.h" #include "line-geometry.h" +#include "shape-editor.h" static void sp_box3d_context_class_init(Box3DContextClass *klass); static void sp_box3d_context_init(Box3DContext *box3d_context); @@ -108,9 +109,6 @@ static void sp_box3d_context_init(Box3DContext *box3d_context) event_context->within_tolerance = false; event_context->item_to_select = NULL; - event_context->shape_repr = NULL; - event_context->shape_knot_holder = NULL; - box3d_context->item = NULL; box3d_context->ctrl_dragged = false; @@ -134,22 +132,14 @@ static void sp_box3d_context_dispose(GObject *object) bc->sel_changed_connection.disconnect(); bc->sel_changed_connection.~connection(); + delete ec->shape_editor; + ec->shape_editor = NULL; + /* fixme: This is necessary because we do not grab */ if (bc->item) { sp_box3d_finish(bc); } - 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 (bc->_message_context) { delete bc->_message_context; } @@ -157,14 +147,6 @@ static void sp_box3d_context_dispose(GObject *object) 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 @@ -174,27 +156,9 @@ static void sp_box3d_context_selection_changed(Inkscape::Selection *selection, g Box3DContext *bc = SP_BOX3D_CONTEXT(data); SPEventContext *ec = SP_EVENT_CONTEXT(bc); - if (ec->shape_knot_holder) { // destroy 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; - } - - 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->unset_item(SH_KNOTHOLDER); + SPItem *item = selection->singleItem(); + ec->shape_editor->set_item(item, SH_KNOTHOLDER); if (selection->perspList().size() == 1) { // selecting a single box changes the current perspective @@ -230,15 +194,11 @@ static void sp_box3d_context_setup(SPEventContext *ec) sp_box3d_context_check_for_persp_in_defs(sp_desktop_document (ec->desktop)); + ec->shape_editor = new ShapeEditor(ec->desktop); + 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); } bc->sel_changed_connection.disconnect(); diff --git a/src/flood-context.cpp b/src/flood-context.cpp index a45ec5dfe..7b6223384 100644 --- a/src/flood-context.cpp +++ b/src/flood-context.cpp @@ -46,6 +46,7 @@ #include "preferences.h" #include "context-fns.h" #include "rubberband.h" +#include "shape-editor.h" #include "display/nr-arena-item.h" #include "display/nr-arena.h" @@ -133,9 +134,6 @@ static void sp_flood_context_init(SPFloodContext *flood_context) event_context->within_tolerance = false; event_context->item_to_select = NULL; - event_context->shape_repr = NULL; - event_context->shape_knot_holder = NULL; - flood_context->item = NULL; new (&flood_context->sel_changed_connection) sigc::connection(); @@ -149,17 +147,14 @@ static void sp_flood_context_dispose(GObject *object) rc->sel_changed_connection.disconnect(); rc->sel_changed_connection.~connection(); + delete ec->shape_editor; + ec->shape_editor = NULL; + /* fixme: This is necessary because we do not grab */ if (rc->item) { sp_flood_finish(rc); } - 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 (rc->_message_context) { delete rc->_message_context; } @@ -167,14 +162,6 @@ static void sp_flood_context_dispose(GObject *object) 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 @@ -184,21 +171,9 @@ void sp_flood_context_selection_changed(Inkscape::Selection *selection, gpointer SPFloodContext *rc = SP_FLOOD_CONTEXT(data); SPEventContext *ec = SP_EVENT_CONTEXT(rc); - 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; - } - - SPItem *item = selection->singleItem(); - if (item) { - 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->unset_item(SH_KNOTHOLDER); + SPItem *item = selection->singleItem(); + ec->shape_editor->set_item(item, SH_KNOTHOLDER); } static void sp_flood_context_setup(SPEventContext *ec) @@ -209,14 +184,11 @@ static void sp_flood_context_setup(SPEventContext *ec) ((SPEventContextClass *) parent_class)->setup(ec); } + ec->shape_editor = new ShapeEditor(ec->desktop); + SPItem *item = sp_desktop_selection(ec->desktop)->singleItem(); if (item) { - 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); } rc->sel_changed_connection.disconnect(); diff --git a/src/rect-context.cpp b/src/rect-context.cpp index 1d8e8c12b..65292851b 100644 --- a/src/rect-context.cpp +++ b/src/rect-context.cpp @@ -41,6 +41,7 @@ #include "xml/node-event-vector.h" #include "preferences.h" #include "context-fns.h" +#include "shape-editor.h" //static const double goldenratio = 1.61803398874989484820; // golden ratio @@ -107,9 +108,6 @@ static void sp_rect_context_init(SPRectContext *rect_context) event_context->within_tolerance = false; event_context->item_to_select = NULL; - event_context->shape_repr = NULL; - event_context->shape_knot_holder = NULL; - rect_context->item = NULL; rect_context->rx = 0.0; @@ -128,22 +126,14 @@ static void sp_rect_context_dispose(GObject *object) rc->sel_changed_connection.disconnect(); rc->sel_changed_connection.~connection(); + delete ec->shape_editor; + ec->shape_editor = NULL; + /* fixme: This is necessary because we do not grab */ if (rc->item) { sp_rect_finish(rc); } - 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 (rc->_message_context) { delete rc->_message_context; } @@ -151,14 +141,6 @@ static void sp_rect_context_dispose(GObject *object) 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 @@ -168,27 +150,9 @@ void sp_rect_context_selection_changed(Inkscape::Selection *selection, gpointer SPRectContext *rc = SP_RECT_CONTEXT(data); SPEventContext *ec = SP_EVENT_CONTEXT(rc); - if (ec->shape_knot_holder) { // destroy 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; - } - - 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->unset_item(SH_KNOTHOLDER); + SPItem *item = selection->singleItem(); + ec->shape_editor->set_item(item, SH_KNOTHOLDER); } static void sp_rect_context_setup(SPEventContext *ec) @@ -199,15 +163,11 @@ static void sp_rect_context_setup(SPEventContext *ec) ((SPEventContextClass *) parent_class)->setup(ec); } + ec->shape_editor = new ShapeEditor(ec->desktop); + 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); } rc->sel_changed_connection.disconnect(); diff --git a/src/spiral-context.cpp b/src/spiral-context.cpp index 9944e86b4..ce9ea1e03 100644 --- a/src/spiral-context.cpp +++ b/src/spiral-context.cpp @@ -41,6 +41,7 @@ #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); @@ -104,9 +105,6 @@ 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; @@ -127,20 +125,12 @@ sp_spiral_context_dispose(GObject *object) 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; } @@ -148,14 +138,6 @@ sp_spiral_context_dispose(GObject *object) 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; - } - - 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->unset_item(SH_KNOTHOLDER); + SPItem *item = selection->singleItem(); + ec->shape_editor->set_item(item, SH_KNOTHOLDER); } static void @@ -201,19 +165,14 @@ sp_spiral_context_setup(SPEventContext *ec) 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)); diff --git a/src/star-context.cpp b/src/star-context.cpp index 33224d7fd..9dc2db296 100644 --- a/src/star-context.cpp +++ b/src/star-context.cpp @@ -43,6 +43,7 @@ #include "xml/node-event-vector.h" #include "object-edit.h" #include "context-fns.h" +#include "shape-editor.h" #include "star-context.h" @@ -108,9 +109,6 @@ sp_star_context_init (SPStarContext * star_context) event_context->within_tolerance = false; event_context->item_to_select = NULL; - event_context->shape_repr = NULL; - event_context->shape_knot_holder = NULL; - star_context->item = NULL; star_context->magnitude = 5; @@ -131,16 +129,8 @@ sp_star_context_dispose (GObject *object) sc->sel_changed_connection.disconnect(); sc->sel_changed_connection.~connection(); - 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; - } + delete ec->shape_editor; + ec->shape_editor = NULL; /* fixme: This is necessary because we do not grab */ if (sc->item) sp_star_finish (sc); @@ -152,14 +142,6 @@ sp_star_context_dispose (GObject *object) 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 @@ -173,27 +155,9 @@ sp_star_context_selection_changed (Inkscape::Selection * selection, gpointer dat SPStarContext *sc = SP_STAR_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; - } - - 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->unset_item(SH_KNOTHOLDER); + SPItem *item = selection->singleItem(); + ec->shape_editor->set_item(item, SH_KNOTHOLDER); } static void @@ -210,19 +174,14 @@ sp_star_context_setup (SPEventContext *ec) sp_event_context_read (ec, "rounded"); sp_event_context_read (ec, "randomized"); - Inkscape::Selection *selection = sp_desktop_selection(ec->desktop); + ec->shape_editor = new ShapeEditor(ec->desktop); - 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); - } - } + SPItem *item = sp_desktop_selection(ec->desktop)->singleItem(); + if (item) { + 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_star_context_selection_changed), (gpointer)sc)); diff --git a/src/text-context.cpp b/src/text-context.cpp index 96fa716cf..ad9211cba 100644 --- a/src/text-context.cpp +++ b/src/text-context.cpp @@ -49,6 +49,7 @@ #include "sp-metrics.h" #include "context-fns.h" #include "verbs.h" +#include "shape-editor.h" #include "text-editing.h" @@ -131,9 +132,6 @@ sp_text_context_init(SPTextContext *tc) event_context->tolerance = 0; event_context->within_tolerance = false; - event_context->shape_repr = NULL; - event_context->shape_knot_holder = NULL; - tc->imc = NULL; tc->text = NULL; @@ -171,6 +169,10 @@ sp_text_context_dispose(GObject *obj) tc->style_set_connection.~connection(); tc->sel_changed_connection.~connection(); tc->sel_modified_connection.~connection(); + + delete ec->shape_editor; + ec->shape_editor = NULL; + tc->text_sel_end.~iterator(); tc->text_sel_start.~iterator(); tc->text_selection_quads.~vector(); @@ -183,26 +185,8 @@ sp_text_context_dispose(GObject *obj) } Inkscape::Rubberband::get(ec->desktop)->stop(); - - 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; - } } -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 */ -}; - static void sp_text_context_setup(SPEventContext *ec) { @@ -259,15 +243,11 @@ sp_text_context_setup(SPEventContext *ec) if (((SPEventContextClass *) parent_class)->setup) ((SPEventContextClass *) parent_class)->setup(ec); + ec->shape_editor = new ShapeEditor(ec->desktop); + SPItem *item = sp_desktop_selection(ec->desktop)->singleItem(); if (item && SP_IS_FLOWTEXT (item) && SP_FLOWTEXT(item)->has_internal_frame()) { - ec->shape_knot_holder = sp_item_knot_holder(item, ec->desktop); - Inkscape::XML::Node *shape_repr = SP_OBJECT_REPR(SP_FLOWTEXT(item)->get_frame(NULL)); - 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); } tc->sel_changed_connection = sp_desktop_selection(desktop)->connectChanged( @@ -1449,26 +1429,10 @@ sp_text_context_selection_changed(Inkscape::Selection *selection, SPTextContext SPEventContext *ec = SP_EVENT_CONTEXT(tc); - if (ec->shape_knot_holder) { // destroy 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; - } - - SPItem *item = selection->singleItem(); + ec->shape_editor->unset_item(SH_KNOTHOLDER); + SPItem *item = selection->singleItem(); if (item && SP_IS_FLOWTEXT (item) && SP_FLOWTEXT(item)->has_internal_frame()) { - ec->shape_knot_holder = sp_item_knot_holder(item, ec->desktop); - Inkscape::XML::Node *shape_repr = SP_OBJECT_REPR(SP_FLOWTEXT(item)->get_frame(NULL)); - 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); } if (tc->text && (item != tc->text)) { diff --git a/src/vanishing-point.cpp b/src/vanishing-point.cpp index c57232c74..10f80fef1 100644 --- a/src/vanishing-point.cpp +++ b/src/vanishing-point.cpp @@ -21,6 +21,7 @@ #include "event-context.h" #include "xml/repr.h" #include "perspective-line.h" +#include "shape-editor.h" #include "knotholder.h" // FIXME: can we avoid direct access to KnotHolder::update_knots? @@ -614,8 +615,8 @@ VPDrag::updateBoxHandles () SPEventContext *ec = inkscape_active_event_context(); g_assert (ec != NULL); - if (ec->shape_knot_holder != NULL) { - ec->shape_knot_holder->update_knots(); + if (ec->shape_editor != NULL) { + ec->shape_editor->update_knotholder(); } }