X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=src%2Fknotholder.cpp;h=eeddf2eb083d8d57fc87eccd53f4fd4d866d5c44;hb=8d358698ecbf192ba7c6dc05d4f7de7592753d9f;hp=0a3cb295769138d99112eba3a52f891570c20c60;hpb=22478c338befd595999937d2349133f8a8551134;p=inkscape.git diff --git a/src/knotholder.cpp b/src/knotholder.cpp index 0a3cb2957..eeddf2eb0 100644 --- a/src/knotholder.cpp +++ b/src/knotholder.cpp @@ -29,6 +29,7 @@ #include "box3d.h" #include "sp-pattern.h" #include "style.h" +#include "live_effects/lpeobject.h" #include "xml/repr.h" // for debugging only @@ -58,7 +59,16 @@ KnotHolder::KnotHolder(SPDesktop *desktop, SPItem *item, SPKnotHolderReleasedFun KnotHolder::~KnotHolder() { g_object_unref(G_OBJECT(item)); for(std::list::iterator i = entity.begin(); i != entity.end(); ++i) { - delete *i; + KnotHolderEntity* e = (*i); + if (!e->isLPEParam()) { + // knotholder entity may be deleted + delete (*i); + } else { + // we must not delete the entity since it's an LPE parameter, + // but the handle should be destroyed + g_object_unref(e->knot); + } + (*i) = NULL; } entity.clear(); // this shouldn't be necessary, though } @@ -70,7 +80,7 @@ KnotHolder::~KnotHolder() { void KnotHolder::update_knots() { - NR::Matrix const i2d(sp_item_i2d_affine(item)); + NR::Matrix const i2d(from_2geom(sp_item_i2d_affine(item))); for(std::list::iterator i = entity.begin(); i != entity.end(); ++i) { KnotHolderEntity *e = *i; @@ -131,8 +141,8 @@ KnotHolder::knot_moved_handler(SPKnot *knot, NR::Point const *p, guint state) for(std::list::iterator i = this->entity.begin(); i != this->entity.end(); ++i) { KnotHolderEntity *e = *i; if (e->knot == knot) { - NR::Point const q = *p / sp_item_i2d_affine(item); - e->knot_set(q, e->knot->drag_origin / sp_item_i2d_affine(item), state); + NR::Point const q = *p / from_2geom(sp_item_i2d_affine(item)); + e->knot_set(q, e->knot->drag_origin / from_2geom(sp_item_i2d_affine(item)), state); break; } } @@ -145,13 +155,34 @@ KnotHolder::knot_moved_handler(SPKnot *knot, NR::Point const *p, guint state) } void -KnotHolder::knot_ungrabbed_handler() +KnotHolder::knot_ungrabbed_handler(SPKnot *knot) { if (this->released) { this->released(this->item); } else { SPObject *object = (SPObject *) this->item; - object->updateRepr(object->repr, SP_OBJECT_WRITE_EXT); + object->updateRepr(); + + /* do cleanup tasks (e.g., for LPE items write the parameter values + * that were changed by dragging the handle to SVG) + */ + if (SP_IS_LPE_ITEM(item)) { + // This writes all parameters to SVG. Is this sufficiently efficient or should we only write + // the ones that were changed (e.g., via the individual handles' onKnotUngrabbed() method? + Inkscape::LivePathEffect::Effect *lpe = sp_lpe_item_get_current_lpe(SP_LPE_ITEM(item)); + if (lpe) { + LivePathEffectObject *lpeobj = lpe->getLPEObj(); + SP_OBJECT(lpeobj)->updateRepr(); + } + } + // this was once used to write individual parameter values to SVG but this is now done globally above; + // we leave the calls to onKnotUngrabbed, anyway, in case any other cleanup tasks need to be done + for(std::list::iterator i = this->entity.begin(); i != this->entity.end(); ++i) { + KnotHolderEntity *e = *i; + if (e->knot == knot) { + e->onKnotUngrabbed(); // for most KnotHolderEntitys this does nothing + } + } unsigned int object_verb = SP_VERB_NONE; @@ -177,6 +208,12 @@ KnotHolder::knot_ungrabbed_handler() } } +void +KnotHolder::add(KnotHolderEntity *e) +{ + entity.push_back(e); +} + void KnotHolder::add_pattern_knotholder() {