Fix bugs in previous commit that caused FTBFS in synfig and ETL FTBFS with older...
[synfig.git] / synfig-core / tags / synfig_0_61_04 / synfig-core / src / synfig / paramdesc.h
1 /* === S Y N F I G ========================================================= */
2 /*!     \file paramdesc.h
3 **      \brief ParamDesc Class Implementation
4 **
5 **      $Id: paramdesc.h,v 1.1.1.1 2005/01/04 01:23:14 darco Exp $
6 **
7 **      \legal
8 **      Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
9 **
10 **      This package is free software; you can redistribute it and/or
11 **      modify it under the terms of the GNU General Public License as
12 **      published by the Free Software Foundation; either version 2 of
13 **      the License, or (at your option) any later version.
14 **
15 **      This package is distributed in the hope that it will be useful,
16 **      but WITHOUT ANY WARRANTY; without even the implied warranty of
17 **      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 **      General Public License for more details.
19 **      \endlegal
20 */
21 /* ========================================================================= */
22
23 /* === S T A R T =========================================================== */
24
25 #ifndef __SYNFIG_PARAMDESC_H
26 #define __SYNFIG_PARAMDESC_H
27
28 /* === H E A D E R S ======================================================= */
29
30 #include "string.h"
31 #include "real.h"
32 #include "color.h"
33 #include <list>
34
35 /* === M A C R O S ========================================================= */
36
37 /* === T Y P E D E F S ===================================================== */
38
39 /* === C L A S S E S & S T R U C T S ======================================= */
40
41 namespace synfig {
42
43 class ValueBase;
44         
45 /*!     \class ParamDesc
46 **      \brief Parameter Description Class
47 **      \todo writeme
48 */
49 class ParamDesc
50 {
51 public:
52
53         //! \writeme
54         struct EnumData
55         {
56                 int value;
57                 String name;
58                 String local_name;
59                 EnumData(int value, const String &name, const String &local_name):
60                         value(value),
61                         name(name),
62                         local_name(local_name)
63                 {
64                 }
65         };
66         
67         /*
68  --     ** -- D A T A -------------------------------------------------------------
69         */
70
71 private:
72         String name_;                   //! The actual parameter name
73         String local_name_;     //! Localized name
74         String desc_;                   //! Short description of parameter (Think tooltops)
75         String group_;                  //! Which group this parameter is a member of (optional)
76         String hint_;                   //! Parameter hint
77         String origin_;                 //! Parameter origin
78         String connect_;
79         String box_;
80         Real scalar_;                   //! Scalar value for visual editing
81         bool critical_;
82         bool hidden_;
83         bool invisible_duck_;
84         bool is_distance_;
85         bool animation_only_;
86
87         std::list<EnumData> enum_list_;
88         
89         /*
90  --     ** -- C O N S T R U C T O R S ---------------------------------------------
91         */
92
93 public:
94
95         ParamDesc(const String &a="IM_A_BUG_SO_REPORT_ME"):
96                 name_                   (a),
97                 local_name_             (a),
98                 scalar_                 (1.0),
99                 critical_               (true),
100                 hidden_                 (false),
101                 invisible_duck_ (false),
102                 is_distance_    (false),
103                 animation_only_ (false)
104         { }
105
106         ParamDesc(const ValueBase&, const String &a);
107
108         ParamDesc(synfig::Color::BlendMethod, const String &a);
109
110
111         /*
112  --     ** -- M E M B E R   F U N C T I O N S -------------------------------------
113         */
114
115 public:
116
117         //! \writeme
118         const std::list<EnumData> &get_enum_list()const { return enum_list_; }
119         
120         //! Sets the localized name of the parameter.
121         ParamDesc &set_local_name(const String &n) { local_name_=n; return *this; }
122
123         //! Sets the localized description of the parameter.
124         ParamDesc &set_description(const String &d) { desc_=d; return *this; }
125
126         //! Sets the group that this parameter is a member of
127         ParamDesc &set_group(const String &n) { group_=n; return *this; }
128
129         //! Sets a "hint" for the parameter.
130         ParamDesc &set_hint(const String &h) { hint_=h; return *this; }
131
132         //! \writeme
133         ParamDesc &set_connect(const String &h) { connect_=h; return *this; }
134
135         //! \writeme
136         ParamDesc &set_box(const String &h) { box_=h; return *this; }
137
138         //! Sets a flag regarding the duck visibility
139         ParamDesc &set_invisible_duck(bool x=true) { invisible_duck_=x; return *this; }
140
141         //! Returns the flag regarding duck visibility
142         bool get_invisible_duck() { return invisible_duck_; }
143
144         
145         //! \writeme
146         ParamDesc &set_animation_only(bool x=true) { animation_only_=x; return *this; }
147
148         //! \writeme
149         bool get_animation_only() { return animation_only_; }
150
151         
152         //! Sets which parameter is to be used as the origin when the user edits visually.
153         ParamDesc &set_origin(const String &h) { origin_=h; return *this; }
154
155         //! Sets the scalar value for the parameter
156         /*! This value determines how the value is to be presented
157         **      to the user when editing visually. */
158         ParamDesc &set_scalar(const Real &n) { scalar_=n; return *this; }
159         ParamDesc &set_scalar(const String &h) { hint_=h; return *this; }
160
161         //!     Marks the parameter as not necessary for saving or copying
162         ParamDesc &not_critical() { critical_=false; return *this; }
163
164         //!     \writeme
165         ParamDesc &hidden() { hidden_=true; return *this; }
166
167         //!     Marks the parameter as only readable. Implies not_critical()
168         /*!     \todo This function needs to be written, as it is only a stub */
169         ParamDesc &read_only() { return *this; }
170
171         //!     Marks the parameter as only writable. Implies not_critical()
172         /*!     \todo This function needs to be written, as it is only a stub */
173         ParamDesc &write_only() { return *this; }
174
175         //! Adds a description of a possible enumeration value
176         /*!     Only relevant if the parameter is of an integer type and hint set to \c "enum" . */
177         ParamDesc &add_enum_value(int val, const String &enum_name,const String &enum_local_name)
178                 { enum_list_.push_back(EnumData(val,enum_name,enum_local_name)); return *this; }
179
180         //! Returns the localized name of the parameter
181         const String &get_local_name()const { return local_name_; }
182
183         //! Returns the name of the parameter
184         const String &get_name()const { return name_; }
185
186         //! Returns the localized description of the parameter
187         const String &get_description()const { return desc_; }
188
189         //! Returns the paramater's group
190         const String &get_group()const { return group_; }
191
192         //! Returns a "hint" about the parameter, regarding how it is to be displayed to the user
193         const String &get_hint()const { return hint_; }
194
195         //! Returns the name of the parameter that is defined as the "origin". Used for visual editing.
196         const String &get_origin()const { return origin_; }
197
198         //! \writeme
199         const String &get_connect()const { return connect_; }
200
201                 //! \writeme
202         const String &get_box()const { return box_; }
203
204         //! Returns the scalar value for the parameter. Used for visual editing.
205         const Real &get_scalar()const { return scalar_; }
206
207         //! Returns \c true if the layer is critical, \c false otherwise.
208         bool get_critical()const { return critical_; }
209
210         //! Returns \c true if the layer is hidden, \c false otherwise.
211         bool get_hidden()const { return hidden_; }
212
213         
214         
215         ParamDesc& set_is_distance(bool x=true) { is_distance_=x; return *this;}
216         bool get_is_distance()const { return is_distance_; }
217 }; // END of class ParamDesc
218
219 class ParamVocab : public std::list< ParamDesc >
220 {
221 };
222
223 }; // END of namespace synfig
224
225 /* === E N D =============================================================== */
226
227 #endif