Code

Add checkbox for LPEs to temporarily disable them on canvas (but keep them applied...
[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 struct SPDesktop;
17 struct SPItem;
19 namespace Gtk {
20     class Widget;
21     class Tooltips;
22 }
24 namespace Inkscape {
26 namespace NodePath {
27     class Path ;
28 }
30 namespace UI {
31 namespace Widget {
32     class Registry;
33 }
34 }
36 namespace LivePathEffect {
38 class Effect;
40 class Parameter {
41 public:
42     Parameter(  const Glib::ustring& label,
43                 const Glib::ustring& tip,
44                 const Glib::ustring& key,
45                 Inkscape::UI::Widget::Registry* wr,
46                 Effect* effect);
47     virtual ~Parameter() {};
49     virtual bool param_readSVGValue(const gchar * strvalue) = 0;   // returns true if new value is valid / accepted.
50     virtual gchar * param_writeSVGValue() const = 0;
52     virtual void param_set_default() = 0;
54     // This creates a new widget (newed with Gtk::manage(new ...);)
55     virtual Gtk::Widget * param_newWidget(Gtk::Tooltips * tooltips) = 0;
57     virtual Glib::ustring * param_getTooltip() { return &param_tooltip; };
59     virtual void param_editOncanvas(SPItem * /*item*/, SPDesktop * /*dt*/) {};
60     virtual void param_setup_nodepath(Inkscape::NodePath::Path */*np*/) {};
62     virtual void param_transform_multiply(Geom::Matrix const& /*postmul*/, bool /*set*/) {};
64     Glib::ustring param_key;
65     Inkscape::UI::Widget::Registry * param_wr;
66     Glib::ustring param_label;
68     bool oncanvas_editable;
70 protected:
71     Glib::ustring param_tooltip;
73     Effect* param_effect;
75     void param_write_to_repr(const char * svgd);
77 private:
78     Parameter(const Parameter&);
79     Parameter& operator=(const Parameter&);
80 };
83 class ScalarParam : public Parameter {
84 public:
85     ScalarParam(  const Glib::ustring& label,
86                 const Glib::ustring& tip,
87                 const Glib::ustring& key,
88                 Inkscape::UI::Widget::Registry* wr,
89                 Effect* effect,
90                 gdouble default_value = 1.0);
91     virtual ~ScalarParam();
93     virtual bool param_readSVGValue(const gchar * strvalue);
94     virtual gchar * param_writeSVGValue() const;
96     virtual void param_set_default();
97     void param_set_value(gdouble val);
98     void param_make_integer(bool yes = true);
99     void param_set_range(gdouble min, gdouble max);
100     void param_set_digits(unsigned digits);
101     void param_set_increments(double step, double page);
103     virtual Gtk::Widget * param_newWidget(Gtk::Tooltips * tooltips);
105     inline operator gdouble()
106         { return value; };
108 protected:
109     gdouble value;
110     gdouble min;
111     gdouble max;
112     bool integer;
113     gdouble defvalue;
114     unsigned digits;
115     double inc_step;
116     double inc_page;
118 private:
119     ScalarParam(const ScalarParam&);
120     ScalarParam& operator=(const ScalarParam&);
121 };
123 } //namespace LivePathEffect
125 } //namespace Inkscape
127 #endif
129 /*
130   Local Variables:
131   mode:c++
132   c-file-style:"stroustrup"
133   c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
134   indent-tabs-mode:nil
135   fill-column:99
136   End:
137 */
138 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :