From ad092a3d734fcec79273f957e8d86c7a9ceb767b Mon Sep 17 00:00:00 2001 From: Maximilian Albert Date: Sun, 8 Jun 2008 17:33:58 +0000 Subject: 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) --- src/live_effects/effect.cpp | 30 ++++++++++++++++++++++++------ 1 file changed, 24 insertions(+), 6 deletions(-) (limited to 'src/live_effects/effect.cpp') diff --git a/src/live_effects/effect.cpp b/src/live_effects/effect.cpp index 0749e4e93..db395c81b 100644 --- a/src/live_effects/effect.cpp +++ b/src/live_effects/effect.cpp @@ -321,21 +321,39 @@ Effect::registerParameter(Parameter * param) param_vector.push_back(param); } +// TODO: Does it still make sense to use this? E.g., should we keep a list of knotholder entities +// in the effect itself and add them here in a semi-automatic manner (similarly to how it is +// done with parameters) instead of adding each one separately in the overloaded function +// addKnotHolderHandles()? void Effect::registerKnotHolderHandle(SPKnotHolderSetFunc set_func, SPKnotHolderGetFunc get_func) { - knotholder_func_vector.push_back(std::make_pair(set_func, get_func)); + //knotholder_func_vector.push_back(std::make_pair(set_func, get_func)); } -// TODO: allow for adding click_functions and description strings, too void -Effect::addHandles(KnotHolder *knotholder) { - std::vector >::iterator i; - for (i = knotholder_func_vector.begin(); i != knotholder_func_vector.end(); ++i) { - //knotholder->add(i->first, i->second, NULL, ("")); +Effect::addPointParamHandles(KnotHolder *knotholder, SPDesktop *desktop, SPItem *item) { + using namespace std; + for (std::vector::iterator p = param_vector.begin(); p != param_vector.end(); ++p) { + if ((*p)->paramType() == Inkscape::LivePathEffect::POINT_PARAM) { + g_print ("Parameter is of type PointParam\n"); + KnotHolderEntity *e = dynamic_cast(*p); + e->create(desktop, item, knotholder); + knotholder->add(e); + } else { + g_print ("Parameter is *not* of type PointParam\n"); + } } } +/** + * Virtual method to add knotholder handles for LPE items + */ +void +Effect::addKnotHolderHandles(KnotHolder *knotholder, SPDesktop *desktop, SPItem *item) +{ +} + /** * This *creates* a new widget, management of deletion should be done by the caller */ -- cgit v1.2.3