Code

Make knotholders for LPE items finally work; each effect can now overload the addKnot...
[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/forward.h>
15 struct SPDesktop;
16 struct SPItem;
18 namespace Gtk {
19     class Widget;
20     class Tooltips;
21 }
23 namespace Inkscape {
25 namespace NodePath {
26     class Path ;
27 }
29 namespace UI {
30 namespace Widget {
31     class Registry;
32 }
33 }
35 namespace LivePathEffect {
37 class Effect;
39 enum ParamType {
40     GENERAL_PARAM,
41     SCALAR_PARAM,
42     BOOL_PARAM,
43     PATH_PARAM,
44     POINT_PARAM,
45     RANDOM_PARAM,
46     ENUM_PARAM,
47     INVALID_PARAM
48 };
50 class Parameter {
51 public:
52     Parameter(  const Glib::ustring& label,
53                 const Glib::ustring& tip,
54                 const Glib::ustring& key,
55                 Inkscape::UI::Widget::Registry* wr,
56                 Effect* effect);
57     virtual ~Parameter() {};
59     virtual bool param_readSVGValue(const gchar * strvalue) = 0;   // returns true if new value is valid / accepted.
60     virtual gchar * param_getSVGValue() const = 0;
61     void write_to_SVG() { param_write_to_repr(param_getSVGValue()); }
62  
63     virtual void param_set_default() = 0;
65     void printTypeName();
66     virtual ParamType paramType() { return GENERAL_PARAM; }
68     // This creates a new widget (newed with Gtk::manage(new ...);)
69     virtual Gtk::Widget * param_newWidget(Gtk::Tooltips * tooltips) = 0;
71     virtual Glib::ustring * param_getTooltip() { return &param_tooltip; };
73     virtual void param_editOncanvas(SPItem * /*item*/, SPDesktop * /*dt*/) {};
74     virtual void param_setup_nodepath(Inkscape::NodePath::Path */*np*/) {};
76     virtual void param_transform_multiply(Geom::Matrix const& /*postmul*/, bool /*set*/) {};
78     Glib::ustring param_key;
79     Inkscape::UI::Widget::Registry * param_wr;
80     Glib::ustring param_label;
82     bool oncanvas_editable;
84 protected:
85     Glib::ustring param_tooltip;
87     Effect* param_effect;
89     void param_write_to_repr(const char * svgd);
91 private:
92     Parameter(const Parameter&);
93     Parameter& operator=(const Parameter&);
94 };
97 class ScalarParam : public Parameter {
98 public:
99     ScalarParam(  const Glib::ustring& label,
100                 const Glib::ustring& tip,
101                 const Glib::ustring& key,
102                 Inkscape::UI::Widget::Registry* wr,
103                 Effect* effect,
104                 gdouble default_value = 1.0);
105     virtual ~ScalarParam();
107     virtual ParamType paramType() { return SCALAR_PARAM; }
109     virtual bool param_readSVGValue(const gchar * strvalue);
110     virtual gchar * param_getSVGValue() const;
112     virtual void param_set_default();
113     void param_set_value(gdouble val);
114     void param_make_integer(bool yes = true);
115     void param_set_range(gdouble min, gdouble max);
116     void param_set_digits(unsigned digits);
117     void param_set_increments(double step, double page);
119     virtual Gtk::Widget * param_newWidget(Gtk::Tooltips * tooltips);
121     inline operator gdouble()
122         { return value; };
124 protected:
125     gdouble value;
126     gdouble min;
127     gdouble max;
128     bool integer;
129     gdouble defvalue;
130     unsigned digits;
131     double inc_step;
132     double inc_page;
134 private:
135     ScalarParam(const ScalarParam&);
136     ScalarParam& operator=(const ScalarParam&);
137 };
139 } //namespace LivePathEffect
141 } //namespace Inkscape
143 #endif
145 /*
146   Local Variables:
147   mode:c++
148   c-file-style:"stroustrup"
149   c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
150   indent-tabs-mode:nil
151   fill-column:99
152   End:
153 */
154 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :