summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 860765f)
raw | patch | inline | side by side (parent: 860765f)
author | johanengelen <johanengelen@users.sourceforge.net> | |
Fri, 21 Mar 2008 20:47:32 +0000 (20:47 +0000) | ||
committer | johanengelen <johanengelen@users.sourceforge.net> | |
Fri, 21 Mar 2008 20:47:32 +0000 (20:47 +0000) |
index 93922de952716a17f82d253823d3e70d83071982..35d0fcdbab98f2a99f7efa2211998e23125aee06 100644 (file)
PointParamKnotHolder * kh = pointparam_knot_holder_new( dt, SP_OBJECT(param_effect->getLPEObj()), param_key.c_str(), item);
if (kh) {
- pointparam_knot_holder_add_full(kh, * dynamic_cast<Geom::Point *>( this ), NULL, knot_shape, knot_mode, knot_color, param_getTooltip()->c_str() );
+ kh->add_knot(* dynamic_cast<Geom::Point *>( this ), NULL, knot_shape, knot_mode, knot_color, param_getTooltip()->c_str() );
ShapeEditor * shape_editor = SP_NODE_CONTEXT( dt->event_context )->shape_editor;
shape_editor->set_knotholder(kh);
diff --git a/src/live_effects/parameter/pointparam-knotholder.cpp b/src/live_effects/parameter/pointparam-knotholder.cpp
index faf310a6825d4a840cee18b050b9638fc3cd3ff8..51cce846fed55fcdee4883d6f144480816735fa6 100644 (file)
\r
class SPDesktop;\r
\r
-static void pointparam_knot_clicked_handler (SPKnot *knot, guint state, gpointer data);\r
-static void pointparam_knot_moved_handler(SPKnot *knot, NR::Point const *p, guint state, gpointer data);\r
+namespace Inkscape {\r
+\r
+static void pointparam_knot_clicked_handler (SPKnot *knot, guint state, PointParamKnotHolder *kh);\r
+static void pointparam_knot_moved_handler(SPKnot *knot, NR::Point const *p, guint state, PointParamKnotHolder *kh);\r
static void pointparam_knot_ungrabbed_handler (SPKnot *knot, unsigned int state, PointParamKnotHolder *kh);\r
static void pointparam_knot_holder_class_init(PointParamKnotHolderClass *klass);\r
\r
static SPKnotHolderClass *parent_class;\r
\r
/**\r
- * Registers SPKnotHolder class and returns its type number.\r
+ * Registers PointParamKnotHolder class and returns its type number.\r
*/\r
GType pointparam_knot_holder_get_type()\r
{\r
}\r
}\r
\r
-void pointparam_knot_holder_destroy(PointParamKnotHolder *kh) {\r
- g_object_unref(kh);\r
-}\r
-\r
-void pointparam_knot_holder_add_full(\r
- PointParamKnotHolder *knot_holder,\r
+void\r
+PointParamKnotHolder::add_knot (\r
Geom::Point & p,\r
- void (* knot_click) (SPItem *item, guint state),\r
+ PointParamKnotHolderClickedFunc knot_click,\r
SPKnotShapeType shape,\r
SPKnotModeType mode,\r
guint32 color,\r
const gchar *tip )\r
{\r
- g_return_if_fail(knot_holder != NULL);\r
-\r
- SPItem *item = SP_ITEM(knot_holder->item);\r
-\r
/* create new SPKnotHolderEntry */\r
SPKnotHolderEntity *e = g_new(SPKnotHolderEntity, 1);\r
- e->knot = sp_knot_new(knot_holder->desktop, tip);\r
+ e->knot = sp_knot_new(desktop, tip);\r
e->knot_set = NULL;\r
e->knot_get = NULL;\r
if (knot_click) {\r
e->knot->fill [SP_KNOT_STATE_NORMAL] = color;\r
g_object_set (G_OBJECT (e->knot->item), "fill_color", color, NULL);\r
\r
- knot_holder->entity = g_slist_append(knot_holder->entity, e);\r
+ entity = g_slist_append(entity, e);\r
\r
/* Move to current point. */\r
NR::Point dp = p * sp_item_i2d_affine(item);\r
sp_knot_set_position(e->knot, &dp, SP_KNOT_STATE_NORMAL);\r
\r
- e->handler_id = g_signal_connect(e->knot, "moved", G_CALLBACK(pointparam_knot_moved_handler), knot_holder);\r
- e->_click_handler_id = g_signal_connect(e->knot, "clicked", G_CALLBACK(pointparam_knot_clicked_handler), knot_holder);\r
- e->_ungrab_handler_id = g_signal_connect(e->knot, "ungrabbed", G_CALLBACK(pointparam_knot_ungrabbed_handler), knot_holder);\r
+ e->handler_id = g_signal_connect(e->knot, "moved", G_CALLBACK(pointparam_knot_moved_handler), this);\r
+ e->_click_handler_id = g_signal_connect(e->knot, "clicked", G_CALLBACK(pointparam_knot_clicked_handler), this);\r
+ e->_ungrab_handler_id = g_signal_connect(e->knot, "ungrabbed", G_CALLBACK(pointparam_knot_ungrabbed_handler), this);\r
\r
sp_knot_show(e->knot);\r
}\r
\r
-static void pointparam_knot_clicked_handler(SPKnot */*knot*/, guint /*state*/, gpointer data)\r
+static void pointparam_knot_clicked_handler(SPKnot */*knot*/, guint /*state*/, PointParamKnotHolder */*kh*/)\r
{\r
- SPKnotHolder *knot_holder = (SPKnotHolder *) data;\r
+\r
}\r
\r
/**\r
* \param p In desktop coordinates.\r
+ * This function does not write to XML, but tries to write directly to the PointParam to quickly live update the effect\r
*/\r
-static void pointparam_knot_moved_handler(SPKnot */*knot*/, NR::Point const */*p*/, guint /*state*/, gpointer data)\r
+static void pointparam_knot_moved_handler(SPKnot */*knot*/, NR::Point const *p, guint /*state*/, PointParamKnotHolder *kh)\r
{\r
- SPKnotHolder *knot_holder = (SPKnotHolder *) data;\r
+ NR::Matrix const i2d(sp_item_i2d_affine(kh->item));\r
+ NR::Point pos = (*p) / i2d;\r
+\r
+ Inkscape::SVGOStringStream os;\r
+ os << pos[0] << "," << pos[1];\r
+\r
+ kh->lpeobject->lpe->setParameter(kh->repr_key, os.str().c_str());\r
}\r
\r
static void pointparam_knot_ungrabbed_handler(SPKnot *knot, unsigned int /*state*/, PointParamKnotHolder *kh)\r
@@ -186,6 +187,8 @@ static void pointparam_knot_ungrabbed_handler(SPKnot *knot, unsigned int /*state
sp_document_done(SP_OBJECT_DOCUMENT (kh->lpeobject), SP_VERB_CONTEXT_LPE, _("Change LPE point parameter"));\r
}\r
\r
+} // namespace Inkscape\r
+\r
/*\r
Local Variables:\r
mode:c++\r
diff --git a/src/live_effects/parameter/pointparam-knotholder.h b/src/live_effects/parameter/pointparam-knotholder.h
index d18b75e21ccb6c0c231ac4dbc9e7f59eb298e766..ef2b2df724d9e89bb047cf7fd7142449575b5d65 100644 (file)
namespace XML {\r
class Node;\r
}\r
-}\r
\r
\r
-typedef void (* SPKnotHolderSetFunc) (SPItem *item, NR::Point const &p, NR::Point const &origin, guint state);\r
-typedef NR::Point (* SPKnotHolderGetFunc) (SPItem *item);\r
-/* fixme: Think how to make callbacks most sensitive (Lauris) */\r
-typedef void (* SPKnotHolderReleasedFunc) (SPItem *item);\r
\r
-struct PointParamKnotHolder : public SPKnotHolder {\r
+typedef void (* PointParamKnotHolderSetFunc) (SPItem *item, NR::Point const &p, NR::Point const &origin, guint state);\r
+typedef NR::Point (* PointParamKnotHolderGetFunc) (SPItem *item);\r
+typedef void (* PointParamKnotHolderClickedFunc) (SPItem *item, guint state);\r
+\r
+class PointParamKnotHolder : public SPKnotHolder {\r
+public:\r
LivePathEffectObject * lpeobject;\r
Inkscape::XML::Node * repr;\r
const gchar * repr_key;\r
+\r
+ void add_knot ( Geom::Point & p,\r
+ PointParamKnotHolderClickedFunc knot_click,\r
+ SPKnotShapeType shape,\r
+ SPKnotModeType mode,\r
+ guint32 color,\r
+ const gchar *tip );\r
};\r
\r
struct PointParamKnotHolderClass : SPKnotHolderClass {\r
};\r
\r
-/* fixme: As a temporary solution, if released is NULL knotholder flushes undo itself (Lauris) */\r
PointParamKnotHolder *pointparam_knot_holder_new(SPDesktop *desktop, SPObject *lpeobject, const gchar * key, SPItem *item);\r
\r
-void pointparam_knot_holder_destroy(PointParamKnotHolder *knots);\r
+GType pointparam_knot_holder_get_type();\r
\r
-void pointparam_knot_holder_add_full(PointParamKnotHolder *knot_holder,\r
- Geom::Point &p,\r
- void (* knot_click) (SPItem *item, guint state),\r
- SPKnotShapeType shape,\r
- SPKnotModeType mode,\r
- guint32 color,\r
- gchar const *tip);\r
\r
-GType pointparam_knot_holder_get_type();\r
+#define INKSCAPE_TYPE_POINTPARAM_KNOT_HOLDER (Inkscape::pointparam_knot_holder_get_type())\r
+\r
\r
-// FIXME: see knotholder.h\r
-void pointparam_knotholder_update_knots(SPKnotHolder *knot_holder, SPItem *item);\r
+} // namespace Inkscape\r
\r
-#define INKSCAPE_TYPE_POINTPARAM_KNOT_HOLDER (pointparam_knot_holder_get_type())\r
\r
#endif /* INKSCAPE_LPE_POINTPARAM_KNOTHOLDER_H */\r
\r