diff options
| author | Johan B. C. Engelen <jbc.engelen@swissonline.ch> | 2007-08-14 20:54:48 +0000 |
|---|---|---|
| committer | johanengelen <johanengelen@users.sourceforge.net> | 2007-08-14 20:54:48 +0000 |
| commit | 55d43e4e27e0ba58a47fad70957dfa989aa173ad (patch) | |
| tree | 2ccfbac1c50023d08ae32975c876fa2478c1ad2a /src/live_effects/parameter | |
| parent | Fix for bug #1752113; added set_preview_widget_active(false) to FileSaveDialo... (diff) | |
| download | inkscape-55d43e4e27e0ba58a47fad70957dfa989aa173ad.tar.gz inkscape-55d43e4e27e0ba58a47fad70957dfa989aa173ad.zip | |
Commit LivePathEffect branch to trunk!
(disabled extension/internal/bitmap/*.* in build.xml to fix compilation)
(bzr r3472)
Diffstat (limited to 'src/live_effects/parameter')
| -rw-r--r-- | src/live_effects/parameter/Makefile_insert | 18 | ||||
| -rw-r--r-- | src/live_effects/parameter/enum.h | 87 | ||||
| -rw-r--r-- | src/live_effects/parameter/makefile.in | 17 | ||||
| -rw-r--r-- | src/live_effects/parameter/parameter.cpp | 105 | ||||
| -rw-r--r-- | src/live_effects/parameter/parameter.h | 84 | ||||
| -rw-r--r-- | src/live_effects/parameter/path.cpp | 166 | ||||
| -rw-r--r-- | src/live_effects/parameter/path.h | 56 | ||||
| -rw-r--r-- | src/live_effects/parameter/point.cpp | 166 | ||||
| -rw-r--r-- | src/live_effects/parameter/point.h | 57 |
9 files changed, 756 insertions, 0 deletions
diff --git a/src/live_effects/parameter/Makefile_insert b/src/live_effects/parameter/Makefile_insert new file mode 100644 index 000000000..a737da1f0 --- /dev/null +++ b/src/live_effects/parameter/Makefile_insert @@ -0,0 +1,18 @@ +## Makefile.am fragment sourced by src/Makefile.am.
+
+live_effects/parameter/all: live_effects/parameter/liblpeparam.a
+
+live_effects/parameter/clean:
+ rm -f live_effects/parameter/liblpeparam.a $(live_effects_parameter_liblpeparam_a_OBJECTS)
+
+live_effects_parameter_liblpeparam_a_SOURCES = \
+ live_effects/parameter/parameter.cpp \
+ live_effects/parameter/parameter.h \
+ live_effects/parameter/point.cpp \
+ live_effects/parameter/point.h \
+ live_effects/parameter/enum.h \
+ live_effects/parameter/path.cpp \
+ live_effects/parameter/path.h
+
+
+
diff --git a/src/live_effects/parameter/enum.h b/src/live_effects/parameter/enum.h new file mode 100644 index 000000000..d70360a24 --- /dev/null +++ b/src/live_effects/parameter/enum.h @@ -0,0 +1,87 @@ +#ifndef INKSCAPE_LIVEPATHEFFECT_PARAMETER_ENUM_H
+#define INKSCAPE_LIVEPATHEFFECT_PARAMETER_ENUM_H
+
+/*
+ * Inkscape::LivePathEffectParameters
+ *
+* Copyright (C) Johan Engelen 2007 <j.b.c.engelen@utwente.nl>
+ *
+ * Released under GNU GPL, read the file 'COPYING' for more information
+ */
+
+#include <glib/gtypes.h>
+
+#include "ui/widget/registry.h"
+#include "ui/widget/registered-enums.h"
+#include <gtkmm/tooltips.h>
+
+#include "live_effects/parameter/parameter.h"
+#include "verbs.h"
+
+namespace Inkscape {
+
+namespace LivePathEffect {
+
+template<typename E> class EnumParam : public Parameter {
+public:
+ EnumParam( const Glib::ustring& label,
+ const Glib::ustring& tip,
+ const Glib::ustring& key,
+ const Util::EnumDataConverter<E>& c,
+ Inkscape::UI::Widget::Registry* wr, Effect* effect)
+ : Parameter(label, tip, key, wr, effect)
+ {
+ regenum = NULL;
+ enumdataconv = &c;
+ };
+ ~EnumParam() {
+ if (regenum)
+ delete regenum;
+ };
+
+ Gtk::Widget * param_getWidget() {
+ if (!regenum) {
+ regenum = new Inkscape::UI::Widget::RegisteredEnum<E>();
+ regenum->init(param_label, param_tooltip, param_key, *enumdataconv, *param_wr, param_effect->getRepr(), param_effect->getSPDoc());
+ regenum->set_undo_parameters(SP_VERB_DIALOG_LIVE_PATH_EFFECT, _("Change enum parameter"));
+ }
+ return dynamic_cast<Gtk::Widget *> (regenum->labelled);
+ };
+
+ bool param_readSVGValue(const gchar * strvalue) {
+ if (regenum)
+ regenum->combobox()->set_active_by_key(Glib::ustring(strvalue));
+ return true;
+ };
+ gchar * param_writeSVGValue() const {
+ if (regenum) {
+ gchar * str = g_strdup(regenum->combobox()->get_active_data()->key.c_str());
+ return str;
+ } else {
+ return NULL;
+ }
+ };
+
+ const Util::EnumData<E>* get_selected_data() {
+ if (regenum) {
+ return regenum->combobox()->get_active_data();
+ } else {
+ return NULL;
+ }
+ };
+
+private:
+ EnumParam(const EnumParam&);
+ EnumParam& operator=(const EnumParam&);
+
+ UI::Widget::RegisteredEnum<E> * regenum;
+
+ const Util::EnumDataConverter<E> * enumdataconv;
+};
+
+
+}; //namespace LivePathEffect
+
+}; //namespace Inkscape
+
+#endif
diff --git a/src/live_effects/parameter/makefile.in b/src/live_effects/parameter/makefile.in new file mode 100644 index 000000000..2a6294c4d --- /dev/null +++ b/src/live_effects/parameter/makefile.in @@ -0,0 +1,17 @@ +# Convenience stub makefile to call the real Makefile.
+
+@SET_MAKE@
+
+# Explicit so that it's the default rule.
+all:
+ cd ../.. && $(MAKE) live_effects/parameter/all
+
+clean %.a %.o:
+ cd ../.. && $(MAKE) live_effects/parameter/$@
+
+.PHONY: all clean
+
+OBJEXT = @OBJEXT@
+
+.SUFFIXES:
+.SUFFIXES: .a .$(OBJEXT)
diff --git a/src/live_effects/parameter/parameter.cpp b/src/live_effects/parameter/parameter.cpp new file mode 100644 index 000000000..6806a1d49 --- /dev/null +++ b/src/live_effects/parameter/parameter.cpp @@ -0,0 +1,105 @@ +#define INKSCAPE_LIVEPATHEFFECT_PARAMETER_CPP
+
+/*
+ * Copyright (C) Johan Engelen 2007 <j.b.c.engelen@utwente.nl>
+ *
+ * Released under GNU GPL, read the file 'COPYING' for more information
+ */
+
+#include "live_effects/parameter/parameter.h"
+#include "live_effects/effect.h"
+#include "svg/svg.h"
+
+#include <gtkmm.h>
+#include "ui/widget/scalar.h"
+
+#include "svg/stringstream.h"
+
+#include "verbs.h"
+
+#define noLPEREALPARAM_DEBUG
+
+namespace Inkscape {
+
+namespace LivePathEffect {
+
+
+Parameter::Parameter( const Glib::ustring& label, const Glib::ustring& tip,
+ const Glib::ustring& key, Inkscape::UI::Widget::Registry* wr,
+ Effect* effect )
+{
+ param_label = label;
+ param_tooltip = tip;
+ param_key = key;
+ param_wr = wr;
+ param_effect = effect;
+}
+
+
+
+/*###########################################
+ * REAL PARAM
+ */
+RealParam::RealParam( const Glib::ustring& label, const Glib::ustring& tip,
+ const Glib::ustring& key, Inkscape::UI::Widget::Registry* wr,
+ Effect* effect, gdouble initial_value)
+ : Parameter(label, tip, key, wr, effect)
+{
+ value = initial_value;
+ rsu = NULL;
+}
+
+RealParam::~RealParam()
+{
+ if (rsu)
+ delete rsu;
+}
+
+bool
+RealParam::param_readSVGValue(const gchar * strvalue)
+{
+ double newval;
+ unsigned int success = sp_svg_number_read_d(strvalue, &newval);
+ if (success == 1) {
+ value = newval;
+ return true;
+ }
+ return false;
+}
+
+gchar *
+RealParam::param_writeSVGValue() const
+{
+ Inkscape::SVGOStringStream os;
+ os << rsu->getS()->getValue();
+ gchar * str = g_strdup(os.str().c_str());
+ return str;
+}
+
+Gtk::Widget *
+RealParam::param_getWidget()
+{
+ if (!rsu) {
+ rsu = new Inkscape::UI::Widget::RegisteredScalar();
+ rsu->init(param_label, param_tooltip, param_key, *param_wr, param_effect->getRepr(), param_effect->getSPDoc());
+ rsu->setValue(value);
+ rsu->set_undo_parameters(SP_VERB_DIALOG_LIVE_PATH_EFFECT, _("Change scalar parameter"));
+ }
+ return dynamic_cast<Gtk::Widget *> (rsu->getS());
+}
+
+
+}; /* namespace LivePathEffect */
+
+}; /* namespace Inkscape */
+
+/*
+ Local Variables:
+ mode:c++
+ c-file-style:"stroustrup"
+ c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
+ indent-tabs-mode:nil
+ fill-column:99
+ End:
+*/
+// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :
diff --git a/src/live_effects/parameter/parameter.h b/src/live_effects/parameter/parameter.h new file mode 100644 index 000000000..327d3d153 --- /dev/null +++ b/src/live_effects/parameter/parameter.h @@ -0,0 +1,84 @@ +#ifndef INKSCAPE_LIVEPATHEFFECT_PARAMETER_H
+#define INKSCAPE_LIVEPATHEFFECT_PARAMETER_H
+
+/*
+ * Inkscape::LivePathEffectParameters
+ *
+* Copyright (C) Johan Engelen 2007 <j.b.c.engelen@utwente.nl>
+ *
+ * Released under GNU GPL, read the file 'COPYING' for more information
+ */
+
+#include <glibmm/ustring.h>
+#include <2geom/point.h>
+#include <2geom/path.h>
+
+#include "ui/widget/registry.h"
+#include "ui/widget/registered-widget.h"
+
+namespace Gtk {
+ class Widget;
+}
+
+namespace Inkscape {
+
+namespace LivePathEffect {
+
+class Effect;
+
+class Parameter {
+public:
+ Parameter(const Glib::ustring& label, const Glib::ustring& tip, const Glib::ustring& key, Inkscape::UI::Widget::Registry* wr, Effect* effect);
+ virtual ~Parameter() {};
+
+ virtual bool param_readSVGValue(const gchar * strvalue) = 0; // returns true if new value is valid / accepted.
+ virtual gchar * param_writeSVGValue() const = 0;
+
+ // This returns pointer to the parameter's widget to be put in the live-effects dialog. Must also create the
+ // necessary widget if it does not exist yet.
+ virtual Gtk::Widget * param_getWidget() = 0;
+ virtual Glib::ustring * param_getTooltip() { return ¶m_tooltip; };
+
+ Glib::ustring param_key;
+ Inkscape::UI::Widget::Registry * param_wr;
+ Glib::ustring param_label;
+
+protected:
+ Glib::ustring param_tooltip;
+
+ Effect* param_effect;
+
+private:
+ Parameter(const Parameter&);
+ Parameter& operator=(const Parameter&);
+};
+
+
+class RealParam : public Parameter {
+public:
+ RealParam( const Glib::ustring& label, const Glib::ustring& tip, const Glib::ustring& key,
+ Inkscape::UI::Widget::Registry* wr, Effect* effect, gdouble initial_value = 1.0);
+ ~RealParam();
+
+ bool param_readSVGValue(const gchar * strvalue);
+ gchar * param_writeSVGValue() const;
+
+ Gtk::Widget * param_getWidget();
+
+ inline operator gdouble()
+ { return value; };
+
+private:
+ RealParam(const RealParam&);
+ RealParam& operator=(const RealParam&);
+
+ gdouble value;
+ Inkscape::UI::Widget::RegisteredScalar * rsu;
+};
+
+
+}; //namespace LivePathEffect
+
+}; //namespace Inkscape
+
+#endif
diff --git a/src/live_effects/parameter/path.cpp b/src/live_effects/parameter/path.cpp new file mode 100644 index 000000000..90974f686 --- /dev/null +++ b/src/live_effects/parameter/path.cpp @@ -0,0 +1,166 @@ +#define INKSCAPE_LIVEPATHEFFECT_PARAMETER_PATH_CPP
+
+/*
+ * Copyright (C) Johan Engelen 2007 <j.b.c.engelen@utwente.nl>
+ *
+ * Released under GNU GPL, read the file 'COPYING' for more information
+ */
+
+#include "live_effects/parameter/path.h"
+#include "live_effects/effect.h"
+#include "live_effects/n-art-bpath-2geom.h"
+#include "svg/svg.h"
+#include <2geom/svg-path-parser.h>
+#include <2geom/sbasis-to-bezier.h>
+#include <2geom/d2.h>
+
+#include "ui/widget/point.h"
+#include "widgets/icon.h"
+#include <gtk/gtkstock.h>
+#include "selection-chemistry.h"
+
+#include "desktop.h"
+#include "inkscape.h"
+#include "message-stack.h"
+#include "verbs.h"
+#include "document.h"
+
+#define noLPEPATHPARAM_DEBUG
+
+namespace Inkscape {
+
+namespace LivePathEffect {
+
+PathParam::PathParam( const Glib::ustring& label, const Glib::ustring& tip,
+ const Glib::ustring& key, Inkscape::UI::Widget::Registry* wr,
+ Effect* effect )
+ : Parameter(label, tip, key, wr, effect)
+{
+ _widget = NULL;
+ _tooltips = NULL;
+}
+
+PathParam::~PathParam()
+{
+ if (_tooltips)
+ delete _tooltips;
+ // _widget is managed by GTK so do not delete!
+}
+
+bool
+PathParam::param_readSVGValue(const gchar * strvalue)
+{
+ if (strvalue) {
+ Geom::Piecewise<Geom::D2<Geom::SBasis> > newpath;
+ std::vector<Geom::Path> temppath = SVGD_to_2GeomPath(strvalue);
+ for (unsigned int i=0; i < temppath.size(); i++) {
+ newpath.concat( temppath[i].toPwSb() );
+ }
+ *( dynamic_cast<Geom::Piecewise<Geom::D2<Geom::SBasis> > *> (this) ) = newpath;
+ return true;
+ }
+
+ return false;
+}
+
+gchar *
+PathParam::param_writeSVGValue() const
+{
+ const std::vector<Geom::Path> temppath =
+ Geom::path_from_piecewise(* dynamic_cast<const Geom::Piecewise<Geom::D2<Geom::SBasis> > *> (this), LPE_CONVERSION_TOLERANCE);
+ gchar * svgd = SVGD_from_2GeomPath( temppath );
+ return svgd;
+}
+
+Gtk::Widget *
+PathParam::param_getWidget()
+{
+ if (!_widget) {
+ _widget = Gtk::manage(new Gtk::HBox());
+ _tooltips = new Gtk::Tooltips();
+
+ Gtk::Label* pLabel = Gtk::manage(new Gtk::Label(param_label));
+ static_cast<Gtk::HBox*>(_widget)->pack_start(*pLabel, true, true);
+ _tooltips->set_tip(*pLabel, param_tooltip);
+
+ Gtk::Widget* pIcon = Gtk::manage( sp_icon_get_icon( "draw_node", Inkscape::ICON_SIZE_BUTTON) );
+ Gtk::Button * pButton = Gtk::manage(new Gtk::Button());
+ pButton->set_relief(Gtk::RELIEF_NONE);
+ pIcon->show();
+ pButton->add(*pIcon);
+ pButton->show();
+ pButton->signal_clicked().connect(sigc::mem_fun(*this, &PathParam::on_edit_button_click));
+ static_cast<Gtk::HBox*>(_widget)->pack_start(*pButton, true, true);
+ _tooltips->set_tip(*pButton, _("Edit on-canvas"));
+#ifndef LPEPATHPARAM_DEBUG
+ pButton->set_sensitive(false);
+#endif
+
+ pIcon = Gtk::manage( sp_icon_get_icon( GTK_STOCK_PASTE, Inkscape::ICON_SIZE_BUTTON) );
+ pButton = Gtk::manage(new Gtk::Button());
+ pButton->set_relief(Gtk::RELIEF_NONE);
+ pIcon->show();
+ pButton->add(*pIcon);
+ pButton->show();
+ pButton->signal_clicked().connect(sigc::mem_fun(*this, &PathParam::on_paste_button_click));
+ static_cast<Gtk::HBox*>(_widget)->pack_start(*pButton, true, true);
+ _tooltips->set_tip(*pButton, _("Paste path"));
+
+ static_cast<Gtk::HBox*>(_widget)->show_all_children();
+
+ }
+ return dynamic_cast<Gtk::Widget *> (_widget);
+}
+
+void
+PathParam::on_edit_button_click()
+{
+ g_message("give this path to edit on canvas!");
+}
+
+void
+PathParam::on_paste_button_click()
+{
+ // check if something is in the clipboard
+ GSList * clipboard = sp_selection_get_clipboard();
+ if (clipboard == NULL || clipboard->data == NULL) {
+ SP_ACTIVE_DESKTOP->messageStack()->flash(Inkscape::WARNING_MESSAGE, _("Nothing on the clipboard."));
+ return;
+ }
+
+ Inkscape::XML::Node *repr = (Inkscape::XML::Node *) clipboard->data;
+ if (!strcmp (repr->name(), "svg:path")) {
+ const char * svgd = repr->attribute("d");
+ if (svgd) {
+ param_write_to_repr(svgd);
+ signal_path_pasted.emit();
+ sp_document_done(param_effect->getSPDoc(), SP_VERB_DIALOG_LIVE_PATH_EFFECT,
+ _("Paste path parameter"));
+ }
+ } else {
+ SP_ACTIVE_DESKTOP->messageStack()->flash(Inkscape::WARNING_MESSAGE, _("Clipboard does not contain a path."));
+ }
+
+}
+
+void
+PathParam::param_write_to_repr(const char * svgd)
+{
+ param_effect->getRepr()->setAttribute(param_key.c_str(), svgd);
+}
+
+
+}; /* namespace LivePathEffect */
+
+}; /* namespace Inkscape */
+
+/*
+ Local Variables:
+ mode:c++
+ c-file-style:"stroustrup"
+ c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
+ indent-tabs-mode:nil
+ fill-column:99
+ End:
+*/
+// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :
diff --git a/src/live_effects/parameter/path.h b/src/live_effects/parameter/path.h new file mode 100644 index 000000000..39ea9e2d8 --- /dev/null +++ b/src/live_effects/parameter/path.h @@ -0,0 +1,56 @@ +#ifndef INKSCAPE_LIVEPATHEFFECT_PARAMETER_PATH_H
+#define INKSCAPE_LIVEPATHEFFECT_PARAMETER_PATH_H
+
+/*
+ * Inkscape::LivePathEffectParameters
+ *
+* Copyright (C) Johan Engelen 2007 <j.b.c.engelen@utwente.nl>
+ *
+ * Released under GNU GPL, read the file 'COPYING' for more information
+ */
+
+#include <glib/gtypes.h>
+#include <2geom/path.h>
+
+#include "ui/widget/registry.h"
+#include <gtkmm/tooltips.h>
+
+#include "live_effects/parameter/parameter.h"
+
+#include <sigc++/sigc++.h>
+
+namespace Inkscape {
+
+namespace LivePathEffect {
+
+class PathParam : public Geom::Piecewise<Geom::D2<Geom::SBasis> >, public Parameter {
+public:
+ PathParam(const Glib::ustring& label, const Glib::ustring& tip, const Glib::ustring& key, Inkscape::UI::Widget::Registry* wr, Effect* effect);;
+ ~PathParam();
+
+ Gtk::Widget * param_getWidget();
+
+ bool param_readSVGValue(const gchar * strvalue);
+ gchar * param_writeSVGValue() const;
+
+ sigc::signal <void> signal_path_pasted;
+
+private:
+ PathParam(const PathParam&);
+ PathParam& operator=(const PathParam&);
+
+ Gtk::Widget * _widget;
+ Gtk::Tooltips * _tooltips;
+
+ void param_write_to_repr(const char * svgd);
+
+ void on_edit_button_click();
+ void on_paste_button_click();
+};
+
+
+}; //namespace LivePathEffect
+
+}; //namespace Inkscape
+
+#endif
diff --git a/src/live_effects/parameter/point.cpp b/src/live_effects/parameter/point.cpp new file mode 100644 index 000000000..8079f54eb --- /dev/null +++ b/src/live_effects/parameter/point.cpp @@ -0,0 +1,166 @@ +#define INKSCAPE_LIVEPATHEFFECT_PARAMETER_POINT_CPP
+
+/*
+ * Copyright (C) Johan Engelen 2007 <j.b.c.engelen@utwente.nl>
+ *
+ * Released under GNU GPL, read the file 'COPYING' for more information
+ */
+
+#include "live_effects/parameter/point.h"
+#include "live_effects/effect.h"
+#include "svg/svg.h"
+#include "svg/stringstream.h"
+#include <gtkmm.h>
+#include "ui/widget/point.h"
+#include "widgets/icon.h"
+
+#include "knot.h"
+#include "inkscape.h"
+#include "verbs.h"
+
+#define noLPEPOINTPARAM_DEBUG
+
+#define PRM_KNOT_COLOR_NORMAL 0xffffff00
+#define PRM_KNOT_COLOR_SELECTED 0x0000ff00
+
+namespace Inkscape {
+
+namespace LivePathEffect {
+
+PointParam::PointParam( const Glib::ustring& label, const Glib::ustring& tip,
+ const Glib::ustring& key, Inkscape::UI::Widget::Registry* wr,
+ Effect* effect )
+ : Geom::Point(0,0), Parameter(label, tip, key, wr, effect)
+{
+ _widget = NULL;
+ pointwdg = NULL;
+ knot = NULL;
+ _tooltips = NULL;
+}
+
+PointParam::~PointParam()
+{
+ if (pointwdg)
+ delete pointwdg;
+ if (_tooltips)
+ delete _tooltips;
+
+ if (knot)
+ g_object_unref (G_OBJECT (knot));
+}
+
+bool
+PointParam::param_readSVGValue(const gchar * strvalue)
+{
+ gchar ** strarray = g_strsplit(strvalue, ",", 2);
+ double newx, newy;
+ unsigned int success = sp_svg_number_read_d(strarray[0], &newx);
+ success += sp_svg_number_read_d(strarray[1], &newy);
+ g_strfreev (strarray);
+ if (success == 2) {
+ *dynamic_cast<Geom::Point *>( this ) = Geom::Point(newx, newy);
+ return true;
+ }
+ return false;
+}
+
+gchar *
+PointParam::param_writeSVGValue() const
+{
+ Inkscape::SVGOStringStream os;
+ os << pointwdg->getPoint()->getXValue() << "," << pointwdg->getPoint()->getYValue();
+ gchar * str = g_strdup(os.str().c_str());
+ return str;
+}
+
+Gtk::Widget *
+PointParam::param_getWidget()
+{
+ if (!_widget) {
+ pointwdg = new Inkscape::UI::Widget::RegisteredPoint();
+ pointwdg->init(param_label, param_tooltip, param_key, *param_wr, param_effect->getRepr(), param_effect->getSPDoc());
+ pointwdg->setValue(0.1, 0.2);
+ pointwdg->set_undo_parameters(SP_VERB_DIALOG_LIVE_PATH_EFFECT, _("Change point parameter"));
+
+ Gtk::Widget* pIcon = Gtk::manage( sp_icon_get_icon( "draw_node", Inkscape::ICON_SIZE_BUTTON) );
+ Gtk::Button * pButton = Gtk::manage(new Gtk::Button());
+ pButton->set_relief(Gtk::RELIEF_NONE);
+ pIcon->show();
+ pButton->add(*pIcon);
+ pButton->show();
+ pButton->signal_clicked().connect(sigc::mem_fun(*this, &PointParam::on_button_click));
+#ifndef LPEPOINTPARAM_DEBUG
+ pButton->set_sensitive(false);
+#endif
+
+ _widget = Gtk::manage( new Gtk::HBox() );
+ static_cast<Gtk::HBox*>(_widget)->pack_start(*pButton, true, true);
+ static_cast<Gtk::HBox*>(_widget)->pack_start(*(pointwdg->getPoint()), true, true);
+ static_cast<Gtk::HBox*>(_widget)->show_all_children();
+
+ _tooltips = new Gtk::Tooltips();
+ _tooltips->set_tip(*pButton, _("Edit on-canvas"));
+ }
+ return dynamic_cast<Gtk::Widget *> (_widget);
+}
+
+void
+PointParam::param_setValue(Geom::Point newpoint)
+{
+ *dynamic_cast<Geom::Point *>( this ) = newpoint;
+ pointwdg->setValue(newpoint[0], newpoint[1]);
+}
+
+
+// CALLBACKS:
+
+void
+PointParam::on_button_click()
+{
+ g_message("add knot to canvas on correct location :S");
+
+ if (!knot) {
+ // create the knot
+ knot = sp_knot_new (SP_ACTIVE_DESKTOP, NULL);
+ knot->setMode(SP_KNOT_MODE_XOR);
+ knot->setFill(PRM_KNOT_COLOR_NORMAL, PRM_KNOT_COLOR_NORMAL, PRM_KNOT_COLOR_NORMAL);
+ knot->setStroke(0x000000ff, 0x000000ff, 0x000000ff);
+ sp_knot_update_ctrl(knot);
+
+ // move knot to the given point
+ sp_knot_set_position (knot, &NR::Point((*this)[0], (*this)[1]), SP_KNOT_STATE_NORMAL);
+ sp_knot_show (knot);
+/*
+ // connect knot's signals
+ if ( (draggable) // it can be NULL if a node in unsnapped (eg. focus point unsnapped from center)
+ // luckily, midstops never snap to other nodes so are never unsnapped...
+ && ( (draggable->point_type == POINT_LG_MID)
+ || (draggable->point_type == POINT_RG_MID1)
+ || (draggable->point_type == POINT_RG_MID2) ) )
+ {
+ this->handler_id = g_signal_connect (G_OBJECT (this->knot), "moved", G_CALLBACK (gr_knot_moved_midpoint_handler), this);
+ } else {
+ this->handler_id = g_signal_connect (G_OBJECT (this->knot), "moved", G_CALLBACK (gr_knot_moved_handler), this);
+ }
+ g_signal_connect (G_OBJECT (this->knot), "clicked", G_CALLBACK (gr_knot_clicked_handler), this);
+ g_signal_connect (G_OBJECT (this->knot), "doubleclicked", G_CALLBACK (gr_knot_doubleclicked_handler), this);
+ g_signal_connect (G_OBJECT (this->knot), "grabbed", G_CALLBACK (gr_knot_grabbed_handler), this);
+ g_signal_connect (G_OBJECT (this->knot), "ungrabbed", G_CALLBACK (gr_knot_ungrabbed_handler), this);
+*/
+ }
+}
+
+}; /* namespace LivePathEffect */
+
+}; /* namespace Inkscape */
+
+/*
+ Local Variables:
+ mode:c++
+ c-file-style:"stroustrup"
+ c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
+ indent-tabs-mode:nil
+ fill-column:99
+ End:
+*/
+// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :
diff --git a/src/live_effects/parameter/point.h b/src/live_effects/parameter/point.h new file mode 100644 index 000000000..1240ea3d1 --- /dev/null +++ b/src/live_effects/parameter/point.h @@ -0,0 +1,57 @@ +#ifndef INKSCAPE_LIVEPATHEFFECT_PARAMETER_POINT_H
+#define INKSCAPE_LIVEPATHEFFECT_PARAMETER_POINT_H
+
+/*
+ * Inkscape::LivePathEffectParameters
+ *
+* Copyright (C) Johan Engelen 2007 <j.b.c.engelen@utwente.nl>
+ *
+ * Released under GNU GPL, read the file 'COPYING' for more information
+ */
+
+#include <glib/gtypes.h>
+#include <2geom/point.h>
+
+#include "ui/widget/registry.h"
+#include "ui/widget/registered-widget.h"
+#include <gtkmm/tooltips.h>
+
+#include "live_effects/parameter/parameter.h"
+
+struct SPKnot;
+
+namespace Inkscape {
+
+namespace LivePathEffect {
+
+
+class PointParam : public Geom::Point, public Parameter {
+public:
+ PointParam(const Glib::ustring& label, const Glib::ustring& tip, const Glib::ustring& key, Inkscape::UI::Widget::Registry* wr, Effect* effect);;
+ ~PointParam();
+
+ Gtk::Widget * param_getWidget();
+
+ bool param_readSVGValue(const gchar * strvalue);
+ gchar * param_writeSVGValue() const;
+
+ void param_setValue(Geom::Point newpoint);
+
+private:
+ PointParam(const PointParam&);
+ PointParam& operator=(const PointParam&);
+
+ Gtk::Widget * _widget;
+ Gtk::Tooltips * _tooltips;
+ Inkscape::UI::Widget::RegisteredPoint * pointwdg;
+ void on_button_click();
+
+ SPKnot *knot;
+};
+
+
+}; //namespace LivePathEffect
+
+}; //namespace Inkscape
+
+#endif
|
