summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: ad2c65f)
raw | patch | inline | side by side (parent: ad2c65f)
author | cilix42 <cilix42@users.sourceforge.net> | |
Tue, 29 Jul 2008 14:49:40 +0000 (14:49 +0000) | ||
committer | cilix42 <cilix42@users.sourceforge.net> | |
Tue, 29 Jul 2008 14:49:40 +0000 (14:49 +0000) |
index a29b71f4d8a722a0a73c06593627f21e24690aa6..9cdc908de15f1623b9531b5bb11a2cd436a59ebb 100644 (file)
--- a/src/knot-holder-entity.h
+++ b/src/knot-holder-entity.h
/* derived classes like PointParam for LPEs use this, e.g., to indicate that we must not call
delete on their pointer when a knotholder is destroyed */
+ // TODO: purge this now that PointParams are not KnotHolderEntities any more!
virtual bool isLPEParam() { return false; }
/* the get/set/click handlers are virtual functions; each handler class for a knot
index 289d22172b22544c180cd0390e99da1d585c539f..c4bbc31e10d57198c30bfed72b856171908a3257 100644 (file)
*/
void
Effect::addHandles(KnotHolder *knotholder, SPDesktop *desktop, SPItem *item) {
+ using namespace Inkscape::LivePathEffect;
+
+ // add handles provided by the effect itself
std::vector<std::pair<KnotHolderEntity*, const char*> >::iterator i;
for (i = kh_entity_vector.begin(); i != kh_entity_vector.end(); ++i) {
KnotHolderEntity *entity = i->first;
@@ -430,18 +433,10 @@ Effect::addHandles(KnotHolder *knotholder, SPDesktop *desktop, SPItem *item) {
entity->create(desktop, item, knotholder, descr);
knotholder->add(entity);
}
-}
-void
-Effect::addPointParamHandles(KnotHolder *knotholder, SPDesktop *desktop, SPItem *item) {
- using namespace Inkscape::LivePathEffect;
+ // add handles provided by the effect's parameters (if any)
for (std::vector<Parameter *>::iterator p = param_vector.begin(); p != param_vector.end(); ++p) {
- if ( Inkscape::LivePathEffect::PointParam *pparam = dynamic_cast<Inkscape::LivePathEffect::PointParam*>(*p) ) {
- KnotHolderEntity *e = dynamic_cast<KnotHolderEntity *>(*p);
- e->create(desktop, item, knotholder, pparam->handleTip(),
- pparam->knotShape(), pparam->knotMode(), pparam->knotColor());
- knotholder->add(e);
- }
+ (*p)->addKnotHolderEntities(knotholder, desktop, item);
}
}
}
}
+// TODO: take _all_ parameters into account, not only PointParams
bool
Effect::providesKnotholder()
{
index 3b3b1467395429eecc851ca4fd874d1942953e98..02d520fe4c9d0c968ee1fc40b720cc1500986145 100644 (file)
#include <glibmm/ustring.h>
#include <2geom/forward.h>
+class KnotHolder;
struct SPDesktop;
struct SPItem;
virtual Glib::ustring * param_getTooltip() { return ¶m_tooltip; };
+ virtual void addKnotHolderEntities(KnotHolder *knotholder, SPDesktop *desktop, SPItem *item) {}
+
virtual void param_editOncanvas(SPItem * /*item*/, SPDesktop * /*dt*/) {};
virtual void param_setup_nodepath(Inkscape::NodePath::Path */*np*/) {};
index 69e2520c2a5f1e21625ffcaaddfc82551d375052..7889bf1642e60ac3b7f7b5ed6644e14a786094db 100644 (file)
@@ -152,23 +152,46 @@ PointParam::set_oncanvas_looks(SPKnotShapeType shape, SPKnotModeType mode, guint
knot_color = color;
}
+class PointParamKnotHolderEntity : public KnotHolderEntity {
+public:
+ PointParamKnotHolderEntity(PointParam *p) { this->pparam = p; }
+ virtual ~PointParamKnotHolderEntity() {}
+
+ 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);
+
+private:
+ PointParam *pparam;
+};
+
void
-PointParam::knot_set(NR::Point const &p, NR::Point const &/*origin*/, guint /*state*/)
+PointParamKnotHolderEntity::knot_set(NR::Point const &p, NR::Point const &/*origin*/, guint /*state*/)
{
- param_setValue(p.to_2geom());
+ pparam->param_setValue(p.to_2geom());
sp_lpe_item_update_patheffect(SP_LPE_ITEM(item), false, false);
}
NR::Point
-PointParam::knot_get()
+PointParamKnotHolderEntity::knot_get()
+{
+ return *pparam;
+}
+
+void
+PointParamKnotHolderEntity::knot_click(guint /*state*/)
{
- return *this;
+ g_print ("This is the handle associated to parameter '%s'\n", pparam->param_key.c_str());
}
void
-PointParam::knot_click(guint /*state*/)
+PointParam::addKnotHolderEntities(KnotHolder *knotholder, SPDesktop *desktop, SPItem *item)
{
- g_print ("This is the handle associated to the parameter '%s'\n", param_key.c_str());
+ PointParamKnotHolderEntity *e = new PointParamKnotHolderEntity(this);
+ // TODO: can we ditch handleTip() etc. because we have access to handle_tip etc. itself???
+ e->create(desktop, item, knotholder, handleTip(), knotShape(), knotMode(), knotColor());
+ knotholder->add(e);
+
}
} /* namespace LivePathEffect */
index 90c318b5ee19919938e09e680912fe9cb93b28c6..0334db7e0f3baac5b25f1838e36a4c2403278872 100644 (file)
namespace LivePathEffect {
-class PointParam : public Geom::Point, public Parameter, public KnotHolderEntity {
+class PointParam : public Geom::Point, public Parameter {
public:
PointParam( const Glib::ustring& label,
const Glib::ustring& tip,
void param_set_and_write_new_value(Geom::Point newpoint);
+ // TODO: ditch this
virtual void param_editOncanvas(SPItem * item, SPDesktop * dt);
virtual void param_transform_multiply(Geom::Matrix const& /*postmul*/, bool /*set*/);
SPKnotModeType knotMode() { return knot_mode; }
guint32 knotColor() { return knot_color; }
- /* these are overloaded from KnotHolderEntity */
- 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);
+ virtual void addKnotHolderEntities(KnotHolder *knotholder, SPDesktop *desktop, SPItem *item);
+ // TODO: ditch this!
virtual bool isLPEParam() { return true; }
private:
diff --git a/src/object-edit.cpp b/src/object-edit.cpp
index 9245166ca79de6116c044ef44fd2ac7cb6afd8c7..52c5d42cce1961cbe0e9eb1897d5a4e344751f07 100644 (file)
--- a/src/object-edit.cpp
+++ b/src/object-edit.cpp
KnotHolder *knot_holder = new KnotHolder(desktop, item, NULL);
Inkscape::LivePathEffect::Effect *effect = sp_lpe_item_get_current_lpe(SP_LPE_ITEM(item));
- effect->addPointParamHandles(knot_holder, desktop, item);
effect->addHandles(knot_holder, desktop, item);
return knot_holder;