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