From: cilix42 Date: Wed, 2 Jul 2008 17:40:36 +0000 (+0000) Subject: lpe-skeleton: add boilerplate code to create knotholder handles for LPEs X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=bf09820d782b89c56d79f070d06d7cf2682c270e;p=inkscape.git lpe-skeleton: add boilerplate code to create knotholder handles for LPEs --- diff --git a/src/live_effects/lpe-skeleton.cpp b/src/live_effects/lpe-skeleton.cpp index c1a3e2601..ff601ef70 100644 --- a/src/live_effects/lpe-skeleton.cpp +++ b/src/live_effects/lpe-skeleton.cpp @@ -37,6 +37,9 @@ LPESkeleton::LPESkeleton(LivePathEffectObject *lpeobject) : /* register all your parameters here, so Inkscape knows which parameters this effect has: */ registerParameter( dynamic_cast(&number) ); + + /* register all your knotholder handles here: */ + //registerKnotHolderHandle(new Skeleton::KnotHolderEntityAttachMyHandle(), _("help message")); } LPESkeleton::~LPESkeleton() @@ -77,6 +80,25 @@ LPESkeleton::doEffect_pwd2 (Geom::Piecewise > const & pwd return output; } +/* ######################## + * Define the classes for your knotholder handles here + */ + +namespace Skeleton { + +class KnotHolderEntityMyHandle : public KnotHolderEntity +{ +public: + virtual bool isLPEParam() { return true; } // this is always needed + + // the set() and get() methods must be implemented, click() is optional + virtual void knot_set(NR::Point const &p, NR::Point const &origin, guint state); + virtual NR::Point knot_get(); + //virtual void knot_click(guint state); +}; + +} // namespace Skeleton + /* ######################## */ } //namespace LivePathEffect diff --git a/src/live_effects/lpe-skeleton.h b/src/live_effects/lpe-skeleton.h index 532176a23..d961ad954 100644 --- a/src/live_effects/lpe-skeleton.h +++ b/src/live_effects/lpe-skeleton.h @@ -20,6 +20,15 @@ namespace Inkscape { namespace LivePathEffect { +// each knotholder handle for your LPE requires a separate class derived from KnotHolderEntity; +// define it in lpe-skeleton.cpp and register it in the effect's constructor +/** +namespace Skeleton { + // we need a separate namespace to avoid clashes with other LPEs + class KnotHolderEntityMyHandle; +} +**/ + class LPESkeleton : public Effect { public: LPESkeleton(LivePathEffectObject *lpeobject); @@ -30,6 +39,9 @@ public: // virtual std::vector doEffect_path (std::vector const & path_in); virtual Geom::Piecewise > doEffect_pwd2 (Geom::Piecewise > const & pwd2_in); + /* the knotholder entity classes (if any) must be declared friends */ + //friend class Skeleton::KnotHolderEntityMyHandle; + private: // add the parameters for your effect here: ScalarParam number;