Code

LPE: implement 'edit next LPE parameter'. Accessible through key '7'.
[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 LivePathEffect {
30 class Effect;
32 class Parameter {
33 public:
34     Parameter(  const Glib::ustring& label,
35                 const Glib::ustring& tip,
36                 const Glib::ustring& key,
37                 Inkscape::UI::Widget::Registry* wr,
38                 Effect* effect);
39     virtual ~Parameter() {};
41     virtual bool param_readSVGValue(const gchar * strvalue) = 0;   // returns true if new value is valid / accepted.
42     virtual gchar * param_writeSVGValue() const = 0;
44     virtual void param_set_default() = 0;
46     // This returns pointer to the parameter's widget to be put in the live-effects dialog. Must also create the
47     // necessary widget if it does not exist yet.
48     virtual Gtk::Widget * param_getWidget() = 0;
49     virtual Glib::ustring * param_getTooltip() { return &param_tooltip; };
51     virtual void param_editOncanvas(SPItem * item, SPDesktop * dt) { return; };
53     Glib::ustring param_key;
54     Inkscape::UI::Widget::Registry * param_wr;
55     Glib::ustring param_label;
57     bool oncanvas_editable;
59 protected:
60     Glib::ustring param_tooltip;
62     Effect* param_effect;
64 private:
65     Parameter(const Parameter&);
66     Parameter& operator=(const Parameter&);
67 };
70 class ScalarParam : public Parameter {
71 public:
72     ScalarParam(  const Glib::ustring& label,
73                 const Glib::ustring& tip,
74                 const Glib::ustring& key, 
75                 Inkscape::UI::Widget::Registry* wr,
76                 Effect* effect,
77                 gdouble default_value = 1.0);
78     virtual ~ScalarParam();
80     virtual bool param_readSVGValue(const gchar * strvalue);
81     virtual gchar * param_writeSVGValue() const;
83     virtual void param_set_default();
84     void param_set_value(gdouble val);
85     void param_make_integer(bool yes = true);
86     void param_set_range(gdouble min, gdouble max);
87     void param_set_digits(unsigned digits);
88     void param_set_increments(double step, double page);
90     virtual Gtk::Widget * param_getWidget();
92     inline operator gdouble()
93         { return value; };
95 protected:
96     gdouble value;
97     gdouble min;
98     gdouble max;
99     bool integer;
100     gdouble defvalue;
101     Inkscape::UI::Widget::RegisteredScalar * rsu;
102     unsigned digits;
103     double inc_step;
104     double inc_page;
106 private:
107     ScalarParam(const ScalarParam&);
108     ScalarParam& operator=(const ScalarParam&);
109 };
111 } //namespace LivePathEffect
113 } //namespace Inkscape
115 #endif