diff options
| author | Maximilian Albert <maximilian.albert@gmail.com> | 2008-06-08 17:33:58 +0000 |
|---|---|---|
| committer | cilix42 <cilix42@users.sourceforge.net> | 2008-06-08 17:33:58 +0000 |
| commit | ad092a3d734fcec79273f957e8d86c7a9ceb767b (patch) | |
| tree | d1df1e2ac1ae259e7d8958990011fc3cba69d59a /src/knotholder.cpp | |
| parent | Add 'Mode' label and icon for regular Bezier mode in pen/pencil toolbar (diff) | |
| download | inkscape-ad092a3d734fcec79273f957e8d86c7a9ceb767b.tar.gz inkscape-ad092a3d734fcec79273f957e8d86c7a9ceb767b.zip | |
Make knotholders for LPE items finally work; each effect can now overload the addKnotHolderHandles() method to add handles which control its parameters.
There is now also a virtual onKnotUngrabbed() method for each knotholder entity which can be used to do cleanup tasks (for LPE parameters it currently writes the value to SVG, although this should probably happen automatically)
(bzr r5855)
Diffstat (limited to 'src/knotholder.cpp')
| -rw-r--r-- | src/knotholder.cpp | 29 |
1 files changed, 27 insertions, 2 deletions
diff --git a/src/knotholder.cpp b/src/knotholder.cpp index 0a3cb2957..1ca280d48 100644 --- a/src/knotholder.cpp +++ b/src/knotholder.cpp @@ -58,7 +58,16 @@ KnotHolder::KnotHolder(SPDesktop *desktop, SPItem *item, SPKnotHolderReleasedFun KnotHolder::~KnotHolder() { g_object_unref(G_OBJECT(item)); for(std::list<KnotHolderEntity *>::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 } @@ -145,7 +154,7 @@ 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); @@ -153,6 +162,16 @@ KnotHolder::knot_ungrabbed_handler() SPObject *object = (SPObject *) this->item; object->updateRepr(object->repr, SP_OBJECT_WRITE_EXT); + /* do cleanup tasks (e.g., for LPE items write the parameter values + * that were changed by dragging the handle to SVG) + */ + for(std::list<KnotHolderEntity *>::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; if (SP_IS_RECT(object)) @@ -178,6 +197,12 @@ KnotHolder::knot_ungrabbed_handler() } void +KnotHolder::add(KnotHolderEntity *e) +{ + entity.push_back(e); +} + +void KnotHolder::add_pattern_knotholder() { if ((SP_OBJECT(item)->style->fill.isPaintserver()) |
