summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 4351a73)
raw | patch | inline | side by side (parent: 4351a73)
author | cilix42 <cilix42@users.sourceforge.net> | |
Tue, 29 Jul 2008 14:51:39 +0000 (14:51 +0000) | ||
committer | cilix42 <cilix42@users.sourceforge.net> | |
Tue, 29 Jul 2008 14:51:39 +0000 (14:51 +0000) |
14 files changed:
index 9cdc908de15f1623b9531b5bb11a2cd436a59ebb..e0d0ca8e8ccbb27af8a33e1066ff93f61f0fe74d 100644 (file)
--- a/src/knot-holder-entity.h
+++ b/src/knot-holder-entity.h
SPKnotModeType mode = SP_KNOT_MODE_XOR,
guint32 color = 0xffffff00);
- /* 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; }
+ /* derived classes used for LPE knotholder handles use this to indicate that they
+ must not be deleted when a knotholder is destroyed */
+ // TODO: it would be nice to ditch this but then we need to dynamically create instances of different
+ // KnotHolderEntity classes in Effect::addKnotHolderEntities. How to do this???
+ virtual bool isDeletable() { return true; }
/* the get/set/click handlers are virtual functions; each handler class for a knot
should be derived from KnotHolderEntity and override these functions */
sigc::connection _ungrabbed_connection;
};
+// derived KnotHolderEntity class for LPEs
+class LPEKnotHolderEntity : public KnotHolderEntity {
+ virtual bool isDeletable() { return false; }
+};
+
/* pattern manipulation */
class PatternKnotHolderEntityXY : public KnotHolderEntity {
diff --git a/src/knotholder.cpp b/src/knotholder.cpp
index f2bbbfbc06803e4932137d3f6d8c4b97d82cd1c1..ae9737b325165e8d151b2dd4967aa130f6c98fd1 100644 (file)
--- a/src/knotholder.cpp
+++ b/src/knotholder.cpp
g_object_unref(G_OBJECT(item));
for(std::list<KnotHolderEntity *>::iterator i = entity.begin(); i != entity.end(); ++i) {
KnotHolderEntity* e = (*i);
- if (!e->isLPEParam()) {
- // knotholder entity may be deleted
+ if (e->isDeletable()) {
delete (*i);
} else {
- // we must not delete the entity since it's an LPE parameter,
+ // we must not delete the entity (since it's attached to an LPE parameter),
// but the handle should be destroyed
g_object_unref(e->knot);
}
(*i) = NULL;
}
- entity.clear(); // this shouldn't be necessary, though
+ entity.clear(); // is this necessary?
}
/**
index c4bbc31e10d57198c30bfed72b856171908a3257..467b1417d79fc4315503339dfc3dde4a5bc43b8a 100644 (file)
using namespace Inkscape::LivePathEffect;
// add handles provided by the effect itself
+ addKnotHolderEntities(knotholder, desktop, item);
+
+ // add handles provided by the effect's parameters (if any)
+ for (std::vector<Parameter *>::iterator p = param_vector.begin(); p != param_vector.end(); ++p) {
+ (*p)->addKnotHolderEntities(knotholder, desktop, item);
+ }
+}
+
+void
+Effect::addKnotHolderEntities(KnotHolder *knotholder, SPDesktop *desktop, SPItem *item) {
+ // TODO: The entities in kh_entity_vector are already instantiated during the call
+ // to registerKnotHolderHandle(), but they are recreated here. Also, we must not
+ // delete them when the knotholder is destroyed, whence the clumsy function
+ // isDeletable(). If we could create entities of different classes dynamically,
+ // this would be much nicer. How to do this?
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;
entity->create(desktop, item, knotholder, descr);
knotholder->add(entity);
}
-
- // add handles provided by the effect's parameters (if any)
- for (std::vector<Parameter *>::iterator p = param_vector.begin(); p != param_vector.end(); ++p) {
- (*p)->addKnotHolderEntities(knotholder, desktop, item);
- }
}
void
index b6386169c77a1e977f86fc901204713cd4868467..2798f88ce8cc4817995da27e21a3aa81ed750e54 100644 (file)
// (but spiro lpe still needs it!)
virtual LPEPathFlashType pathFlashType() { return DEFAULT; }
void addHandles(KnotHolder *knotholder, SPDesktop *desktop, SPItem *item);
- void addPointParamHandles(KnotHolder *knotholder, SPDesktop *desktop, SPItem *item);
void addHelperPaths(SPLPEItem *lpeitem, SPDesktop *desktop);
inline bool providesOwnFlashPaths() {
void registerKnotHolderHandle(KnotHolderEntity* entity, const char* descr);
Parameter * getNextOncanvasEditableParam();
+ void addKnotHolderEntities(KnotHolder *knotholder, SPDesktop *desktop, SPItem *item);
virtual void addHelperPathsImpl(SPLPEItem *lpeitem, SPDesktop *desktop);
std::vector<Parameter *> param_vector;
Effect& operator=(const Effect&);
};
-
} //namespace LivePathEffect
} //namespace Inkscape
index c7c7b526216039e5f577ada9be13fde1277d6923..41c11fc5e3f5fe6a9016e852565d1ed2a75ba646 100644 (file)
namespace AB {
-class KnotHolderEntityLeftEnd : public KnotHolderEntity
+class KnotHolderEntityLeftEnd : public LPEKnotHolderEntity
{
public:
- virtual bool isLPEParam() { return true; }
-
virtual void knot_set(NR::Point const &p, NR::Point const &origin, guint state);
virtual NR::Point knot_get();
};
-class KnotHolderEntityRightEnd : public KnotHolderEntity
+class KnotHolderEntityRightEnd : public LPEKnotHolderEntity
{
public:
- virtual bool isLPEParam() { return true; }
-
virtual void knot_set(NR::Point const &p, NR::Point const &origin, guint state);
virtual NR::Point knot_get();
};
index 948da335ad9841dac1301e91525aaf48d047818f..142b6eb64039f0b0b3a01b477d54f6a70b91466f 100644 (file)
namespace CR {
-class KnotHolderEntityAngle : public KnotHolderEntity
+class KnotHolderEntityAngle : public LPEKnotHolderEntity
{
public:
- virtual bool isLPEParam() { return true; }
-
virtual void knot_set(NR::Point const &p, NR::Point const &origin, guint state);
virtual NR::Point knot_get();
};
index dba0f3a8db579b61ce917dc1db0b2645ae99c130..e0e15626300a9ef159f964f05e8e591049abb38f 100644 (file)
namespace Pl {
-class KnotHolderEntityLeftEnd : public KnotHolderEntity
+class KnotHolderEntityLeftEnd : public LPEKnotHolderEntity
{
public:
- virtual bool isLPEParam() { return true; }
-
virtual void knot_set(NR::Point const &p, NR::Point const &origin, guint state);
virtual NR::Point knot_get();
};
-class KnotHolderEntityRightEnd : public KnotHolderEntity
+class KnotHolderEntityRightEnd : public LPEKnotHolderEntity
{
public:
- virtual bool isLPEParam() { return true; }
-
virtual void knot_set(NR::Point const &p, NR::Point const &origin, guint state);
virtual NR::Point knot_get();
};
index bcfe57614002efdf2f74c66531d9f1fdb062fe58..c4146a1d9baff9a3aa80adb40a064ab27bb1fef6 100644 (file)
namespace LivePathEffect {
namespace PB {
-class KnotHolderEntityLeftEnd : public KnotHolderEntity
+class KnotHolderEntityLeftEnd : public LPEKnotHolderEntity
{
public:
- virtual bool isLPEParam() { return true; }
-
virtual void knot_set(NR::Point const &p, NR::Point const &origin, guint state);
virtual NR::Point knot_get();
};
-class KnotHolderEntityRightEnd : public KnotHolderEntity
+class KnotHolderEntityRightEnd : public LPEKnotHolderEntity
{
public:
- virtual bool isLPEParam() { return true; }
-
virtual void knot_set(NR::Point const &p, NR::Point const &origin, guint state);
virtual NR::Point knot_get();
};
index 9aa26e05d0097e08714aea16ca5cd9bdfcdee308..e3397a20eb27b556c54726227a74e2cafc663d53 100644 (file)
namespace PP {
-class KnotHolderEntityOffset : public KnotHolderEntity
+class KnotHolderEntityOffset : public LPEKnotHolderEntity
{
public:
- virtual bool isLPEParam() { return true; }
-
virtual void knot_set(NR::Point const &p, NR::Point const &origin, guint state);
virtual NR::Point knot_get();
};
index 59a034196921db6596d92b7e8e69974e1bf196ba..5fc4ba6f2ffb3e9bc850fad8f7a6cf065b4772e3 100644 (file)
/**
namespace Skeleton {
-class KnotHolderEntityMyHandle : public KnotHolderEntity
+class KnotHolderEntityMyHandle : public LPEKnotHolderEntity
{
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();
index 83f73cf8bb092284ce7c71a7bdb03da0eb2e4211..33188382c5a5c33680f8f3a51d1803c049d6189c 100644 (file)
namespace TtC {
-class KnotHolderEntityAttachPt : public KnotHolderEntity
+class KnotHolderEntityAttachPt : public LPEKnotHolderEntity
{
public:
- virtual bool isLPEParam() { return true; }
-
virtual void knot_set(NR::Point const &p, NR::Point const &origin, guint state);
virtual NR::Point knot_get();
};
-class KnotHolderEntityLeftEnd : public KnotHolderEntity
+class KnotHolderEntityLeftEnd : public LPEKnotHolderEntity
{
public:
- virtual bool isLPEParam() { return true; }
-
virtual void knot_set(NR::Point const &p, NR::Point const &origin, guint state);
virtual NR::Point knot_get();
};
-class KnotHolderEntityRightEnd : public KnotHolderEntity
+class KnotHolderEntityRightEnd : public LPEKnotHolderEntity
{
public:
- virtual bool isLPEParam() { return true; }
-
virtual void knot_set(NR::Point const &p, NR::Point const &origin, guint state);
virtual NR::Point knot_get();
};
index eed16725d96bffa3a667aaf36117b3b1e8eb1421..0a782d4ecf44eccd5a2484a62f8d13e90232a892 100644 (file)
@@ -152,7 +152,7 @@ PointParam::set_oncanvas_looks(SPKnotShapeType shape, SPKnotModeType mode, guint
knot_color = color;
}
-class PointParamKnotHolderEntity : public KnotHolderEntity {
+class PointParamKnotHolderEntity : public LPEKnotHolderEntity {
public:
PointParamKnotHolderEntity(PointParam *p) { this->pparam = p; }
virtual ~PointParamKnotHolderEntity() {}
index bad138c9c9889520d8bb246e4ed1b635ff05b553..9718b232b288ce3ddf00a4b0f56005756dc89fa0 100644 (file)
virtual void addKnotHolderEntities(KnotHolder *knotholder, SPDesktop *desktop, SPItem *item);
- // TODO: ditch this!
- virtual bool isLPEParam() { return true; }
-
private:
PointParam(const PointParam&);
PointParam& operator=(const PointParam&);
diff --git a/src/live_effects/parameter/pointparam-knotholder.cpp b/src/live_effects/parameter/pointparam-knotholder.cpp
index 3ab07a9517710e21b184169f360a31330dbe9c68..d92532e327a16ac4d9f2401c30b6d7c0ea139ae9 100644 (file)
g_object_unref(G_OBJECT(this->lpeobject));
}
-class KnotHolderEntityPointParam : public KnotHolderEntity {
+class KnotHolderEntityPointParam : public LPEKnotHolderEntity {
public:
virtual NR::Point knot_get();
virtual void knot_set(NR::Point const &p, NR::Point const &origin, guint state);