summaryrefslogtreecommitdiffstats
path: root/src/live_effects/parameter
diff options
context:
space:
mode:
authorMaximilian Albert <maximilian.albert@gmail.com>2008-07-29 14:49:40 +0000
committercilix42 <cilix42@users.sourceforge.net>2008-07-29 14:49:40 +0000
commit70a05bc08bae10f00ba33415f5162b71e110d3b4 (patch)
treebbf0ab490b347aeec457d47828cbcabfcb3c54bd /src/live_effects/parameter
parentadded new translation from Martin Srebotnjak (diff)
downloadinkscape-70a05bc08bae10f00ba33415f5162b71e110d3b4.tar.gz
inkscape-70a05bc08bae10f00ba33415f5162b71e110d3b4.zip
LPE knotholder refactoring: PointParams are not knotholder entities any more; instead, every parameter type can now return entities (and then forget about them)
(bzr r6446)
Diffstat (limited to 'src/live_effects/parameter')
-rw-r--r--src/live_effects/parameter/parameter.h3
-rw-r--r--src/live_effects/parameter/point.cpp35
-rw-r--r--src/live_effects/parameter/point.h9
3 files changed, 36 insertions, 11 deletions
diff --git a/src/live_effects/parameter/parameter.h b/src/live_effects/parameter/parameter.h
index 3b3b14673..02d520fe4 100644
--- a/src/live_effects/parameter/parameter.h
+++ b/src/live_effects/parameter/parameter.h
@@ -12,6 +12,7 @@
#include <glibmm/ustring.h>
#include <2geom/forward.h>
+class KnotHolder;
struct SPDesktop;
struct SPItem;
@@ -56,6 +57,8 @@ public:
virtual Glib::ustring * param_getTooltip() { return &param_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*/) {};
diff --git a/src/live_effects/parameter/point.cpp b/src/live_effects/parameter/point.cpp
index 69e2520c2..7889bf164 100644
--- a/src/live_effects/parameter/point.cpp
+++ b/src/live_effects/parameter/point.cpp
@@ -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 */
diff --git a/src/live_effects/parameter/point.h b/src/live_effects/parameter/point.h
index 90c318b5e..0334db7e0 100644
--- a/src/live_effects/parameter/point.h
+++ b/src/live_effects/parameter/point.h
@@ -23,7 +23,7 @@ namespace Inkscape {
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,
@@ -45,6 +45,7 @@ public:
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*/);
@@ -54,11 +55,9 @@ public:
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: