27 #ifndef __SYNFIG_DUCKMATIC_DUCK_H
28 #define __SYNFIG_DUCKMATIC_DUCK_H
34 #include <ETL/smart_ptr>
37 #include <synfig/vector.h>
38 #include <synfig/string.h>
39 #include <synfig/real.h>
40 #include <sigc++/signal.h>
41 #include <sigc++/object.h>
42 #include <synfig/time.h>
43 #include <ETL/smart_ptr>
45 #include <synfig/transform.h>
53 #ifndef __STRING_HASH__
54 #define __STRING_HASH__
57 # ifdef FUNCTIONAL_HASH_ON_STRING
58 HASH_MAP_NAMESPACE::hash<synfig::String> hasher_;
59 # else // FUNCTIONAL_HASH_ON_STRING
60 HASH_MAP_NAMESPACE::hash<const char*> hasher_;
61 # endif // FUNCTIONAL_HASH_ON_STRING
63 size_t operator()(
const synfig::String& x)
const
65 # ifdef FUNCTIONAL_HASH_ON_STRING
67 # else // FUNCTIONAL_HASH_ON_STRING
68 return hasher_(x.c_str());
69 # endif // FUNCTIONAL_HASH_ON_STRING
88 class Duck :
public etl::shared_object
119 sigc::signal<bool,const Duck &> signal_edited_;
120 sigc::signal<void> signal_user_click_[5];
135 bool alternative_editable_;
136 bool edit_immediatelly_;
147 synfig::TransformStack transform_stack_;
149 synfig::Real scalar_;
151 synfig::Point origin_;
154 Handle axis_x_angle_duck_;
155 synfig::Angle axis_x_angle_;
158 synfig::Real axis_x_mag_;
160 Handle axis_y_angle_duck_;
161 synfig::Angle axis_y_angle_;
164 synfig::Real axis_y_mag_;
171 synfig::Point point_;
172 etl::smart_ptr<synfig::Point> shared_point_;
173 etl::smart_ptr<synfig::Angle> shared_angle_;
174 etl::smart_ptr<synfig::Real> shared_mag_;
175 synfig::Angle rotations_;
176 synfig::Point aspect_point_;
178 static int duck_count;
184 explicit Duck(
const synfig::Point &point);
185 Duck(
const synfig::Point &point,
const synfig::Point &origin);
192 {
return signal_edited_; }
194 { assert(i>=0); assert(i<5);
return signal_user_click_[i]; }
200 const synfig::GUID&
get_guid()
const {
return guid_; }
204 void set_name(
const synfig::String &x);
213 static synfig::String type_name(
Type id);
215 synfig::String type_name()
const {
return type_name(
get_type()); }
221 {
return value_desc_; }
223 { alternative_value_desc_=x; }
225 {
return alternative_value_desc_; }
232 if (alternative_value_desc_.
is_valid())
233 return is_alternative_mode ? alternative_editable_ : editable_;
241 {
return editable_; }
244 { alternative_editable_=x; }
247 {
return alternative_editable_; }
257 { edit_immediatelly_=x; }
259 {
return edit_immediatelly_; }
286 {
return exponential_; }
290 {
return track_axes_; }
295 {
return lock_aspect_; }
297 {
if (!lock_aspect_ && r) aspect_point_=point_.norm(); lock_aspect_=r; }
302 { transform_stack_=x; }
304 {
return transform_stack_; }
315 { origin_=x; origin_duck_=NULL; }
321 {
return origin_duck_?origin_duck_->get_point():origin_; }
324 {
return origin_duck_; }
327 { axis_x_angle_=a; axis_x_angle_duck_=NULL; }
329 { axis_x_angle_duck_=duck; axis_x_angle_=angle; }
331 {
return axis_x_angle_duck_?
get_sub_trans_point(axis_x_angle_duck_,
false).angle()+axis_x_angle_:axis_x_angle_; }
333 {
return axis_x_angle_duck_; }
336 { axis_x_mag_=m; axis_x_mag_duck_=NULL; }
338 { axis_x_mag_duck_=duck; }
342 {
return axis_x_mag_duck_; }
348 { axis_y_angle_=a; axis_y_angle_duck_=NULL; }
350 { axis_y_angle_duck_=duck; axis_y_angle_=angle; }
352 {
return axis_y_angle_duck_?
get_sub_trans_point(axis_y_angle_duck_,
false).angle()+axis_y_angle_:axis_y_angle_; }
354 {
return axis_y_angle_duck_; }
357 { axis_y_mag_=m; axis_y_mag_duck_=NULL; }
359 { axis_y_mag_duck_=duck; }
363 {
return axis_y_mag_duck_; }
389 {
return connect_duck_; }
395 {
return box_duck_; }
408 {
return shared_point_; }
413 {
return shared_angle_; }
418 {
return shared_mag_; }
424 {
return rotations_; };
435 void set_trans_point(
const synfig::Point &x,
const synfig::Time &time);
460 {
return static_cast<Duck::Type>(int(lhs)|int(rhs)); }
465 {
return static_cast<Duck::Type>(int(lhs)&~int(rhs)); }
469 { *
reinterpret_cast<int*
>(&lhs)|=
int(rhs);
return lhs; }
473 {
return static_cast<Duck::Type>(int(lhs)&int(rhs)); }
477 HASH_MAP_CLASS<synfig::GUID,etl::handle<studio::Duck>,synfig::GUIDHash>
479 typedef HASH_MAP_CLASS<synfig::GUID,etl::handle<studio::Duck>,synfig::GUIDHash> PARENT_TYPE;
481 std::map<synfig::GUID,etl::handle<studio::Duck> >
483 typedef std::map<synfig::GUID,etl::handle<studio::Duck> > PARENT_TYPE;