Code

correctly transform LPE path and point parameters with the SPItem's transform
[inkscape.git] / src / live_effects / parameter / parameter.h
1 #ifndef INKSCAPE_LIVEPATHEFFECT_PARAMETER_H
2 #define INKSCAPE_LIVEPATHEFFECT_PARAMETER_H
4 /*
5  * Inkscape::LivePathEffectParameters
6  *
7 * Copyright (C) Johan Engelen 2007 <j.b.c.engelen@utwente.nl>
8  *
9  * Released under GNU GPL, read the file 'COPYING' for more information
10  */
12 #include <glibmm/ustring.h>
13 #include <2geom/point.h>
14 #include <2geom/path.h>
16 #include "ui/widget/registry.h"
17 #include "ui/widget/registered-widget.h"
19 struct SPDesktop;
20 struct SPItem;
22 namespace Gtk {
23     class Widget;
24 }
26 namespace Inkscape {
28 namespace NodePath {
29     class Path ;
30 }
32 namespace LivePathEffect {
34 class Effect;
36 class Parameter {
37 public:
38     Parameter(  const Glib::ustring& label,
39                 const Glib::ustring& tip,
40                 const Glib::ustring& key,
41                 Inkscape::UI::Widget::Registry* wr,
42                 Effect* effect);
43     virtual ~Parameter() {};
45     virtual bool param_readSVGValue(const gchar * strvalue) = 0;   // returns true if new value is valid / accepted.
46     virtual gchar * param_writeSVGValue() const = 0;
48     virtual void param_set_default() = 0;
50     // This returns pointer to the parameter's widget to be put in the live-effects dialog. Must also create the
51     // necessary widget if it does not exist yet.
52     virtual Gtk::Widget * param_getWidget() = 0;
53     virtual Glib::ustring * param_getTooltip() { return &param_tooltip; };
55     virtual void param_editOncanvas(SPItem * /*item*/, SPDesktop * /*dt*/) {};
56     virtual void param_setup_nodepath(Inkscape::NodePath::Path */*np*/) {};
58     virtual void param_transform_multiply(Geom::Matrix const& /*postmul*/, bool /*set*/) {};
60     Glib::ustring param_key;
61     Inkscape::UI::Widget::Registry * param_wr;
62     Glib::ustring param_label;
64     bool oncanvas_editable;
66 protected:
67     Glib::ustring param_tooltip;
69     Effect* param_effect;
71     void param_write_to_repr(const char * svgd);
73 private:
74     Parameter(const Parameter&);
75     Parameter& operator=(const Parameter&);
76 };
79 class ScalarParam : public Parameter {
80 public:
81     ScalarParam(  const Glib::ustring& label,
82                 const Glib::ustring& tip,
83                 const Glib::ustring& key,
84                 Inkscape::UI::Widget::Registry* wr,
85                 Effect* effect,
86                 gdouble default_value = 1.0);
87     virtual ~ScalarParam();
89     virtual bool param_readSVGValue(const gchar * strvalue);
90     virtual gchar * param_writeSVGValue() const;
92     virtual void param_set_default();
93     void param_set_value(gdouble val);
94     void param_make_integer(bool yes = true);
95     void param_set_range(gdouble min, gdouble max);
96     void param_set_digits(unsigned digits);
97     void param_set_increments(double step, double page);
99     virtual Gtk::Widget * param_getWidget();
101     inline operator gdouble()
102         { return value; };
104 protected:
105     gdouble value;
106     gdouble min;
107     gdouble max;
108     bool integer;
109     gdouble defvalue;
110     Inkscape::UI::Widget::RegisteredScalar * rsu;
111     unsigned digits;
112     double inc_step;
113     double inc_page;
115 private:
116     ScalarParam(const ScalarParam&);
117     ScalarParam& operator=(const ScalarParam&);
118 };
120 } //namespace LivePathEffect
122 } //namespace Inkscape
124 #endif
126 /*
127   Local Variables:
128   mode:c++
129   c-file-style:"stroustrup"
130   c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
131   indent-tabs-mode:nil
132   fill-column:99
133   End:
134 */
135 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :