regenerated
[moon.git] / src / animation.h
blobd653c173dafd60d9ec0e04743930420d5c92722a
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
2 /*
3 * animation.h: Animation engine
5 * Contact:
6 * Moonlight List (moonlight-list@lists.ximian.com)
8 * Copyright 2007 Novell, Inc. (http://www.novell.com)
10 * See the LICENSE file included with the distribution for details.
14 #ifndef MOON_ANIMATION_H
15 #define MOON_ANIMATION_H
17 #include <glib.h>
19 #include "trigger.h"
20 #include "collection.h"
21 #include "clock.h"
22 #include "timeline.h"
23 #include "list.h"
24 #include "point.h"
25 #include "propertypath.h"
26 #include "moon-curves.h"
27 #include "easing.h"
28 #include "applier.h"
30 // misc types
31 /* @Namespace=System.Windows.Media.Animation */
32 class KeySpline : public DependencyObject {
33 public:
34 /* @GenerateCBinding,GeneratePInvoke */
35 KeySpline ();
37 KeySpline (Point controlPoint1, Point controlPoint2);
38 KeySpline (double x1, double y1, double x2, double y2);
40 virtual void OnPropertyChanged (PropertyChangedEventArgs *args, MoonError *error);
42 void RegenerateQuadratics ();
44 double GetSplineProgress (double linearProgress);
45 /* @PropertyType=Point,ManagedPropertyType=Point,DefaultValue=Point (0\,0),ManagedFieldAccess=Internal,GenerateAccessors */
46 const static int ControlPoint1Property;
47 /* @PropertyType=Point,ManagedPropertyType=Point,DefaultValue=Point (1.0\, 1.0),ManagedFieldAccess=Internal,GenerateAccessors */
48 const static int ControlPoint2Property;
50 Point *GetControlPoint1 ();
51 void SetControlPoint1 (Point *controlPoint1);
53 Point *GetControlPoint2 ();
54 void SetControlPoint2 (Point *controlPoint2);
56 protected:
57 virtual ~KeySpline ();
60 private:
61 moon_quadratic *quadraticsArray;
64 /* @Namespace=System.Windows.Media.Animation */
65 /* @IncludeInKinds */
66 struct KeyTime {
67 enum KeyTimeType {
68 UNIFORM,
69 PERCENT,
70 TIMESPAN,
71 PACED
74 KeyTime (const KeyTime &keytime)
76 k = keytime.k;
77 percent = keytime.percent;
78 timespan = keytime.timespan;
81 KeyTime (double percent)
82 : k (PERCENT),
83 percent (percent),
84 timespan (0) { }
86 KeyTime (TimeSpan timeSpan)
87 : k (TIMESPAN),
88 timespan (timeSpan) { }
91 KeyTime (KeyTimeType kind) : k(kind) { }
93 static KeyTime FromPercent (double percent) { return KeyTime (percent); }
94 static KeyTime FromTimeSpan (TimeSpan timeSpan) { return KeyTime (timeSpan); }
96 static KeyTime Paced;
97 static KeyTime Uniform;
99 bool operator!= (const KeyTime &v) const
101 return !(*this == v);
104 bool operator== (const KeyTime &v) const
106 if (v.k != k)
107 return false;
109 switch (k) {
110 case PERCENT: return percent == v.percent;
111 case TIMESPAN: return timespan == v.timespan;
112 default: return true;
116 bool HasPercent () { return k == PERCENT; }
117 double GetPercent () { return percent; }
119 bool HasTimeSpan () { return k == TIMESPAN; }
120 TimeSpan GetTimeSpan () { return timespan; }
122 private:
123 KeyTimeType k;
124 gint32 padding;
125 double percent;
126 TimeSpan timespan;
131 // Animations (more specialized clocks and timelines) and their subclasses
133 class AnimationClock;
136 /* @Namespace=None */
137 class Animation : public Timeline {
138 public:
140 Animation () { };
142 virtual Clock *AllocateClock ();
144 virtual Value *GetCurrentValue (Value *defaultOriginValue, Value *defaultDestinationValue,
145 AnimationClock* animationClock);
146 virtual Value *GetTargetValue (Value *defaultOriginValue);
148 virtual Duration GetNaturalDurationCore (Clock* clock);
151 virtual bool Resolve (DependencyObject *target, DependencyProperty *property) { return true; };
153 /* The kind of values this animation generates */
154 virtual Type::Kind GetValueKind () { return Type::INVALID; };
156 protected:
157 virtual ~Animation () {}
160 /* @Namespace=System.Windows.Media.Animation */
161 class DoubleAnimation : public Animation {
162 public:
163 /* @PropertyType=double,Nullable,GenerateAccessors */
164 const static int ByProperty;
165 /* @PropertyType=double,Nullable,GenerateAccessors */
166 const static int FromProperty;
167 /* @PropertyType=double,Nullable,GenerateAccessors */
168 const static int ToProperty;
169 /* @PropertyType=EasingFunctionBase,ManagedPropertyType=IEasingFunction,GenerateAccessors */
170 const static int EasingFunctionProperty;
172 /* @GenerateCBinding,GeneratePInvoke */
173 DoubleAnimation ();
175 virtual Type::Kind GetValueKind () { return Type::DOUBLE; };
177 virtual void OnPropertyChanged (PropertyChangedEventArgs *args, MoonError *error);
179 virtual Value *GetTargetValue (Value *defaultOriginValue);
180 virtual Value *GetCurrentValue (Value *defaultOriginValue, Value *defaultDestinationValue,
181 AnimationClock *animationClock);
184 // Property Accessors
186 double *GetBy ();
187 void SetBy (double *pv);
188 void SetBy (double v);
190 double *GetFrom ();
191 void SetFrom (double *pv);
192 void SetFrom (double v);
194 double *GetTo ();
195 void SetTo (double *pv);
196 void SetTo (double v);
198 EasingFunctionBase* GetEasingFunction ();
199 void SetEasingFunction (EasingFunctionBase* value);
201 protected:
202 virtual ~DoubleAnimation () {}
204 private:
205 double *doubleToCached;
206 double *doubleFromCached;
207 double *doubleByCached;
208 bool hasCached;
210 void EnsureCache (void);
215 /* @Namespace=System.Windows.Media.Animation */
216 class ColorAnimation : public Animation {
217 public:
218 /* @PropertyType=Color,Nullable,GenerateAccessors */
219 const static int ByProperty;
220 /* @PropertyType=Color,Nullable,GenerateAccessors */
221 const static int FromProperty;
222 /* @PropertyType=Color,Nullable,GenerateAccessors */
223 const static int ToProperty;
224 /* @PropertyType=EasingFunctionBase,ManagedPropertyType=IEasingFunction,GenerateAccessors */
225 const static int EasingFunctionProperty;
227 /* @GenerateCBinding,GeneratePInvoke */
228 ColorAnimation ();
230 virtual Type::Kind GetValueKind () { return Type::COLOR; };
232 virtual void OnPropertyChanged (PropertyChangedEventArgs *args, MoonError *error);
234 virtual Value *GetTargetValue (Value *defaultOriginValue);
235 virtual Value *GetCurrentValue (Value *defaultOriginValue, Value *defaultDestinationValue,
236 AnimationClock *animationClock);
239 // Property Accessors
241 Color *GetBy ();
242 void SetBy (Color *pv);
243 void SetBy (Color v);
245 Color *GetFrom ();
246 void SetFrom (Color *pv);
247 void SetFrom (Color v);
249 Color *GetTo ();
250 void SetTo (Color *pv);
251 void SetTo (Color v);
253 EasingFunctionBase* GetEasingFunction ();
254 void SetEasingFunction (EasingFunctionBase* value);
256 protected:
257 virtual ~ColorAnimation () {}
259 private:
260 Color *colorToCached;
261 Color *colorFromCached;
262 Color *colorByCached;
263 bool hasCached;
265 void EnsureCache (void);
269 /* @Namespace=System.Windows.Media.Animation */
270 class PointAnimation : public Animation {
271 public:
272 /* @PropertyType=Point,Nullable,GenerateAccessors */
273 const static int ByProperty;
274 /* @PropertyType=Point,Nullable,GenerateAccessors */
275 const static int FromProperty;
276 /* @PropertyType=Point,Nullable,GenerateAccessors */
277 const static int ToProperty;
278 /* @PropertyType=EasingFunctionBase,ManagedPropertyType=IEasingFunction,GenerateAccessors */
279 const static int EasingFunctionProperty;
281 /* @GenerateCBinding,GeneratePInvoke */
282 PointAnimation ();
284 virtual Type::Kind GetValueKind () { return Type::POINT; };
286 virtual void OnPropertyChanged (PropertyChangedEventArgs *args, MoonError *error);
288 virtual Value *GetTargetValue (Value *defaultOriginValue);
289 virtual Value *GetCurrentValue (Value *defaultOriginValue, Value *defaultDestinationValue,
290 AnimationClock *animationClock);
293 // Property Accessors
295 Point *GetBy ();
296 void SetBy (Point *pv);
297 void SetBy (Point v);
299 Point *GetFrom ();
300 void SetFrom (Point *pv);
301 void SetFrom (Point v);
303 Point *GetTo ();
304 void SetTo (Point *pv);
305 void SetTo (Point v);
307 EasingFunctionBase* GetEasingFunction ();
308 void SetEasingFunction (EasingFunctionBase* value);
310 protected:
311 virtual ~PointAnimation ();
313 private:
314 Point *pointToCached;
315 Point *pointFromCached;
316 Point *pointByCached;
317 bool hasCached;
319 void EnsureCache (void);
324 /* @Namespace=None,ManagedDependencyProperties=None */
325 class KeyFrame : public DependencyObject {
326 public:
327 TimeSpan resolved_keytime;
328 bool resolved;
330 virtual Value *InterpolateValue (Value *baseValue, double keyFrameProgress);
333 // Property Accessors
335 virtual KeyTime *GetKeyTime () = 0;
336 virtual void SetKeyTime (KeyTime keytime) = 0;
337 virtual void SetKeyTime (KeyTime *keytime) = 0;
339 protected:
340 virtual ~KeyFrame ();
341 KeyFrame ();
344 /* @Namespace=None */
345 class KeyFrameCollection : public DependencyObjectCollection {
346 public:
347 GPtrArray *sorted_list;
348 bool resolved;
350 /* @GenerateCBinding,GeneratePInvoke */
351 KeyFrameCollection ();
353 virtual Type::Kind GetElementType() { return Type::KEYFRAME; }
355 virtual bool Clear ();
357 KeyFrame *GetKeyFrameForTime (TimeSpan t, KeyFrame **previous_frame);
359 virtual void OnSubPropertyChanged (DependencyProperty *prop, DependencyObject *obj, PropertyChangedEventArgs *subobj_args);
361 protected:
362 virtual bool AddedToCollection (Value *value, MoonError *error);
363 virtual void RemovedFromCollection (Value *value);
365 virtual ~KeyFrameCollection ();
368 /* @Namespace=System.Windows.Media.Animation */
369 class ColorKeyFrameCollection : public KeyFrameCollection {
370 public:
371 /* @GenerateCBinding,GeneratePInvoke */
372 ColorKeyFrameCollection ();
374 virtual Type::Kind GetElementType() { return Type::COLORKEYFRAME; }
376 protected:
377 virtual ~ColorKeyFrameCollection ();
380 /* @Namespace=System.Windows.Media.Animation */
381 class DoubleKeyFrameCollection : public KeyFrameCollection {
382 public:
383 /* @GenerateCBinding,GeneratePInvoke */
384 DoubleKeyFrameCollection ();
386 virtual Type::Kind GetElementType() { return Type::DOUBLEKEYFRAME; }
388 protected:
389 virtual ~DoubleKeyFrameCollection ();
392 /* @Namespace=System.Windows.Media.Animation */
393 class PointKeyFrameCollection : public KeyFrameCollection {
394 public:
395 /* @GenerateCBinding,GeneratePInvoke */
396 PointKeyFrameCollection ();
398 virtual Type::Kind GetElementType() { return Type::POINTKEYFRAME; }
400 protected:
401 virtual ~PointKeyFrameCollection ();
404 /* @Version=2,Namespace=System.Windows.Media.Animation */
405 class ObjectKeyFrameCollection : public KeyFrameCollection {
406 public:
407 /* @GenerateCBinding,GeneratePInvoke */
408 ObjectKeyFrameCollection ();
410 virtual Type::Kind GetElementType() { return Type::OBJECTKEYFRAME; }
412 protected:
413 virtual ~ObjectKeyFrameCollection ();
416 /* @Namespace=System.Windows.Media.Animation */
417 class DoubleKeyFrame : public KeyFrame {
418 public:
419 /* @PropertyType=double,Nullable,ManagedPropertyType=double,GenerateAccessors */
420 const static int ValueProperty;
421 /* @PropertyType=KeyTime,Nullable,ManagedPropertyType=KeyTime,GenerateAccessors */
422 const static int KeyTimeProperty;
424 /* @GenerateCBinding,GeneratePInvoke,ManagedAccess=Protected */
425 DoubleKeyFrame ();
428 // Property Accessors
430 double *GetValue ();
431 void SetValue (double *pv);
432 void SetValue (double v);
434 virtual KeyTime *GetKeyTime ();
435 virtual void SetKeyTime (KeyTime keytime);
436 virtual void SetKeyTime (KeyTime *keytime);
438 protected:
439 virtual ~DoubleKeyFrame ();
442 /* @Namespace=System.Windows.Media.Animation */
443 class ColorKeyFrame : public KeyFrame {
444 public:
445 /* @PropertyType=Color,Nullable,ManagedPropertyType=Color,GenerateAccessors */
446 const static int ValueProperty;
447 /* @PropertyType=KeyTime,Nullable,ManagedPropertyType=KeyTime,GenerateAccessors */
448 const static int KeyTimeProperty;
450 /* @GenerateCBinding,GeneratePInvoke,ManagedAccess=Protected */
451 ColorKeyFrame ();
454 // Property Accessors
456 Color *GetValue ();
457 void SetValue (Color *pv);
458 void SetValue (Color v);
460 virtual KeyTime *GetKeyTime ();
461 virtual void SetKeyTime (KeyTime keytime);
462 virtual void SetKeyTime (KeyTime *keytime);
464 protected:
465 virtual ~ColorKeyFrame ();
468 /* @Version=2,Namespace=System.Windows.Media.Animation */
469 class ObjectKeyFrame : public KeyFrame /* The managed class derives directly from DependencyObject */ {
470 public:
471 /* @GenerateCBinding,GeneratePInvoke,ManagedAccess=Protected */
472 ObjectKeyFrame ();
474 /* @PropertyType=object,GenerateAccessors,GenerateManagedAccessors=false,ManagedFieldAccess=Internal */
475 const static int ConvertedValueProperty;
476 /* @PropertyType=object,ManagedPropertyType=object */
477 const static int ValueProperty;
478 /* @PropertyType=KeyTime,Nullable,ManagedPropertyType=KeyTime,GenerateAccessors */
479 const static int KeyTimeProperty;
481 Value *GetConvertedValue ();
482 void SetConvertedValue (Value *value);
483 Value *GetValue ();
485 virtual KeyTime *GetKeyTime ();
486 virtual void SetKeyTime (KeyTime keytime);
487 virtual void SetKeyTime (KeyTime *keytime);
489 protected:
490 virtual ~ObjectKeyFrame ();
493 /* @Namespace=System.Windows.Media.Animation */
494 class PointKeyFrame : public KeyFrame {
495 public:
496 /* @PropertyType=Point,Nullable,ManagedPropertyType=Point,GenerateAccessors */
497 const static int ValueProperty;
498 /* @PropertyType=KeyTime,Nullable,ManagedPropertyType=KeyTime,GenerateAccessors */
499 const static int KeyTimeProperty;
501 /* @GenerateCBinding,GeneratePInvoke,ManagedAccess=Protected */
502 PointKeyFrame ();
505 // Property Accessors
507 Point *GetValue ();
508 void SetValue (Point *pv);
509 void SetValue (Point v);
511 virtual KeyTime *GetKeyTime ();
512 virtual void SetKeyTime (KeyTime keytime);
513 virtual void SetKeyTime (KeyTime *keytime);
515 protected:
516 virtual ~PointKeyFrame ();
521 /* @Namespace=System.Windows.Media.Animation */
522 class DiscreteDoubleKeyFrame : public DoubleKeyFrame {
523 public:
524 /* @GenerateCBinding,GeneratePInvoke */
525 DiscreteDoubleKeyFrame ();
527 virtual Value *InterpolateValue (Value *baseValue, double keyFrameProgress);
529 protected:
530 virtual ~DiscreteDoubleKeyFrame ();
536 /* @Namespace=System.Windows.Media.Animation */
537 class DiscreteColorKeyFrame : public ColorKeyFrame {
538 public:
539 /* @GenerateCBinding,GeneratePInvoke */
540 DiscreteColorKeyFrame ();
542 virtual Value *InterpolateValue (Value *baseValue, double keyFrameProgress);
544 protected:
545 virtual ~DiscreteColorKeyFrame ();
549 /* @Version=2,Namespace=System.Windows.Media.Animation */
550 class DiscreteObjectKeyFrame : public ObjectKeyFrame {
551 public:
552 /* @GenerateCBinding,GeneratePInvoke */
553 DiscreteObjectKeyFrame ();
555 virtual Value *InterpolateValue (Value *baseValue, double keyFrameProgress);
557 protected:
558 virtual ~DiscreteObjectKeyFrame ();
561 /* @Namespace=System.Windows.Media.Animation */
562 class DiscretePointKeyFrame : public PointKeyFrame {
563 public:
564 /* @GenerateCBinding,GeneratePInvoke */
565 DiscretePointKeyFrame ();
567 virtual Value *InterpolateValue (Value *baseValue, double keyFrameProgress);
569 protected:
570 virtual ~DiscretePointKeyFrame ();
574 /* @Namespace=System.Windows.Media.Animation */
575 class LinearDoubleKeyFrame : public DoubleKeyFrame {
576 public:
577 /* @GenerateCBinding,GeneratePInvoke */
578 LinearDoubleKeyFrame ();
580 virtual Value *InterpolateValue (Value *baseValue, double keyFrameProgress);
582 protected:
583 virtual ~LinearDoubleKeyFrame ();
588 /* @Namespace=System.Windows.Media.Animation */
589 class LinearColorKeyFrame : public ColorKeyFrame {
590 public:
591 /* @GenerateCBinding,GeneratePInvoke */
592 LinearColorKeyFrame ();
594 virtual Value *InterpolateValue (Value *baseValue, double keyFrameProgress);
596 protected:
597 virtual ~LinearColorKeyFrame ();
602 /* @Namespace=System.Windows.Media.Animation */
603 class LinearPointKeyFrame : public PointKeyFrame {
604 public:
605 /* @GenerateCBinding,GeneratePInvoke */
606 LinearPointKeyFrame ();
608 virtual Value *InterpolateValue (Value *baseValue, double keyFrameProgress);
610 protected:
611 virtual ~LinearPointKeyFrame ();
616 /* @Namespace=System.Windows.Media.Animation */
617 class SplineDoubleKeyFrame : public DoubleKeyFrame {
618 public:
619 /* @PropertyType=KeySpline,AutoCreateValue,GenerateAccessors */
620 const static int KeySplineProperty;
622 /* @GenerateCBinding,GeneratePInvoke */
623 SplineDoubleKeyFrame ();
625 virtual Value *InterpolateValue (Value *baseValue, double keyFrameProgress);
628 // Property Accessors
630 KeySpline *GetKeySpline ();
631 void SetKeySpline (KeySpline* value);
633 protected:
634 virtual ~SplineDoubleKeyFrame ();
639 /* @Namespace=System.Windows.Media.Animation */
640 class SplineColorKeyFrame : public ColorKeyFrame {
641 public:
642 /* @PropertyType=KeySpline,AutoCreateValue,GenerateAccessors */
643 const static int KeySplineProperty;
645 /* @GenerateCBinding,GeneratePInvoke */
646 SplineColorKeyFrame ();
648 virtual Value *InterpolateValue (Value *baseValue, double keyFrameProgress);
651 // Property Accessors
653 KeySpline *GetKeySpline ();
654 void SetKeySpline (KeySpline* value);
656 protected:
657 virtual ~SplineColorKeyFrame ();
662 /* @Namespace=System.Windows.Media.Animation */
663 class SplinePointKeyFrame : public PointKeyFrame {
664 public:
665 /* @PropertyType=KeySpline,AutoCreateValue,GenerateAccessors */
666 const static int KeySplineProperty;
668 /* @GenerateCBinding,GeneratePInvoke */
669 SplinePointKeyFrame ();
671 virtual Value *InterpolateValue (Value *baseValue, double keyFrameProgress);
674 // Property Accessors
676 KeySpline *GetKeySpline ();
677 void SetKeySpline (KeySpline* value);
679 protected:
680 virtual ~SplinePointKeyFrame ();
683 /* @Namespace=System.Windows.Media.Animation */
684 class EasingColorKeyFrame : public ColorKeyFrame {
685 public:
686 /* @PropertyType=EasingFunctionBase,ManagedPropertyType=IEasingFunction,GenerateAccessors */
687 const static int EasingFunctionProperty;
689 /* @GenerateCBinding,GeneratePInvoke */
690 EasingColorKeyFrame ();
692 virtual Value *InterpolateValue (Value *baseValue, double keyFrameProgress);
695 // Property Accessors
697 EasingFunctionBase *GetEasingFunction ();
698 void SetEasingFunction (EasingFunctionBase* value);
700 protected:
701 virtual ~EasingColorKeyFrame ();
704 /* @Namespace=System.Windows.Media.Animation */
705 class EasingDoubleKeyFrame : public DoubleKeyFrame {
706 public:
707 /* @PropertyType=EasingFunctionBase,ManagedPropertyType=IEasingFunction,GenerateAccessors */
708 const static int EasingFunctionProperty;
710 /* @GenerateCBinding,GeneratePInvoke */
711 EasingDoubleKeyFrame ();
713 virtual Value *InterpolateValue (Value *baseValue, double keyFrameProgress);
716 // Property Accessors
718 EasingFunctionBase *GetEasingFunction ();
719 void SetEasingFunction (EasingFunctionBase* value);
721 protected:
722 virtual ~EasingDoubleKeyFrame ();
725 /* @Namespace=System.Windows.Media.Animation */
726 class EasingPointKeyFrame : public PointKeyFrame {
727 public:
728 /* @PropertyType=EasingFunctionBase,ManagedPropertyType=IEasingFunction,GenerateAccessors */
729 const static int EasingFunctionProperty;
731 /* @GenerateCBinding,GeneratePInvoke */
732 EasingPointKeyFrame ();
734 virtual Value *InterpolateValue (Value *baseValue, double keyFrameProgress);
737 // Property Accessors
739 EasingFunctionBase *GetEasingFunction ();
740 void SetEasingFunction (EasingFunctionBase* value);
742 protected:
743 virtual ~EasingPointKeyFrame ();
746 /* @Namespace=System.Windows.Media.Animation */
747 /* @ContentProperty="KeyFrames" */
748 class DoubleAnimationUsingKeyFrames : public DoubleAnimation {
749 public:
750 /* @PropertyType=DoubleKeyFrameCollection,AutoCreateValue,ManagedFieldAccess=Internal,ManagedSetterAccess=Internal,GenerateAccessors */
751 const static int KeyFramesProperty;
753 /* @GenerateCBinding,GeneratePInvoke */
754 DoubleAnimationUsingKeyFrames ();
756 void AddKeyFrame (DoubleKeyFrame *frame);
757 void RemoveKeyFrame (DoubleKeyFrame *frame);
759 virtual Value *GetCurrentValue (Value *defaultOriginValue, Value *defaultDestinationValue,
760 AnimationClock *animationClock);
761 virtual bool Resolve (DependencyObject *target, DependencyProperty *property);
763 virtual Duration GetNaturalDurationCore (Clock* clock);
765 virtual bool Validate ();
768 // Property Accessors
770 DoubleKeyFrameCollection *GetKeyFrames ();
771 void SetKeyFrames (DoubleKeyFrameCollection* value);
773 protected:
774 virtual ~DoubleAnimationUsingKeyFrames ();
777 /* @Namespace=System.Windows.Media.Animation */
778 /* @ContentProperty="KeyFrames" */
779 class ColorAnimationUsingKeyFrames : public ColorAnimation {
780 public:
781 /* @PropertyType=ColorKeyFrameCollection,AutoCreateValue,ManagedFieldAccess=Internal,ManagedSetterAccess=Internal,GenerateAccessors */
782 const static int KeyFramesProperty;
784 /* @GenerateCBinding,GeneratePInvoke */
785 ColorAnimationUsingKeyFrames ();
787 void AddKeyFrame (ColorKeyFrame *frame);
788 void RemoveKeyFrame (ColorKeyFrame *frame);
790 virtual Value *GetCurrentValue (Value *defaultOriginValue, Value *defaultDestinationValue,
791 AnimationClock *animationClock);
792 virtual bool Resolve (DependencyObject *target, DependencyProperty *property);
794 virtual Duration GetNaturalDurationCore (Clock* clock);
796 virtual bool Validate ();
799 // Property Accessors
801 ColorKeyFrameCollection *GetKeyFrames ();
802 void SetKeyFrames (ColorKeyFrameCollection* value);
804 protected:
805 virtual ~ColorAnimationUsingKeyFrames ();
808 /* @Version=2 */
809 /* @Namespace=System.Windows.Media.Animation */
810 /* @ContentProperty="KeyFrames" */
811 class ObjectAnimationUsingKeyFrames : public /*Object*/Animation {
812 public:
813 /* @PropertyType=ObjectKeyFrameCollection,ManagedFieldAccess=Internal,ManagedSetterAccess=Internal,GenerateAccessors,AutoCreateValue */
814 const static int KeyFramesProperty;
816 /* @GenerateCBinding,GeneratePInvoke */
817 ObjectAnimationUsingKeyFrames ();
819 void AddKeyFrame (ObjectKeyFrame *frame);
820 void RemoveKeyFrame (ObjectKeyFrame *frame);
822 // Property accessors
823 ObjectKeyFrameCollection *GetKeyFrames ();
824 void SetKeyFrames (ObjectKeyFrameCollection* value);
826 virtual Value *GetCurrentValue (Value *defaultOriginValue, Value *defaultDestinationValue,
827 AnimationClock* animationClock);
829 virtual bool Resolve (DependencyObject *target, DependencyProperty *property);
831 virtual Duration GetNaturalDurationCore (Clock* clock);
832 virtual bool Validate ();
834 virtual Type::Kind GetValueKind () { return Type::INVALID; };
836 protected:
837 virtual ~ObjectAnimationUsingKeyFrames ();
840 /* @Namespace=System.Windows.Media.Animation */
841 /* @ContentProperty="KeyFrames" */
842 class PointAnimationUsingKeyFrames : public PointAnimation {
843 public:
844 /* @PropertyType=PointKeyFrameCollection,AutoCreateValue,ManagedFieldAccess=Internal,ManagedSetterAccess=Internal,GenerateAccessors */
845 const static int KeyFramesProperty;
847 /* @GenerateCBinding,GeneratePInvoke */
848 PointAnimationUsingKeyFrames ();
850 void AddKeyFrame (PointKeyFrame *frame);
851 void RemoveKeyFrame (PointKeyFrame *frame);
853 virtual Value *GetCurrentValue (Value *defaultOriginValue, Value *defaultDestinationValue,
854 AnimationClock *animationClock);
855 virtual bool Resolve (DependencyObject *target, DependencyProperty *property);
857 virtual Duration GetNaturalDurationCore (Clock *clock);
859 virtual bool Validate ();
862 // Property Accessors
864 PointKeyFrameCollection *GetKeyFrames ();
865 void SetKeyFrames (PointKeyFrameCollection* value);
867 protected:
868 virtual ~PointAnimationUsingKeyFrames ();
871 /* @Namespace=System.Windows.Media.Animation */
872 /* @ContentProperty="Children" */
873 class Storyboard : public ParallelTimeline {
874 public:
875 /* @PropertyType=string,Attached,GenerateAccessors,Validator=IsTimelineValidator */
876 const static int TargetNameProperty;
877 /* @PropertyType=PropertyPath,Attached,GenerateAccessors,Validator=StoryboardTargetPropertyValidator */
878 const static int TargetPropertyProperty;
880 /* @GenerateCBinding,GeneratePInvoke */
881 Storyboard ();
883 /* @GenerateCBinding,GeneratePInvoke */
884 bool BeginWithError (MoonError *error);
886 /* @GenerateCBinding,GeneratePInvoke */
887 void PauseWithError (MoonError *error);
889 /* @GenerateCBinding,GeneratePInvoke */
890 void ResumeWithError (MoonError *error);
892 /* @GenerateCBinding,GeneratePInvoke */
893 void SeekWithError (TimeSpan timespan, MoonError *error);
895 /* @GenerateCBinding,GeneratePInvoke */
896 void SeekAlignedToLastTickWithError (TimeSpan timespan, MoonError *error);
898 /* @GenerateCBinding,GeneratePInvoke */
899 void SkipToFillWithError (MoonError *error);
901 /* @GenerateCBinding,GeneratePInvoke */
902 void StopWithError (MoonError *error);
904 /* @GenerateCBinding,GeneratePInvoke */
905 TimeSpan GetCurrentTime ();
907 /* @GenerateCBinding,GeneratePInvoke */
908 int GetCurrentState ();
910 /* @GenerateCBinding,GeneratePInvoke */
911 DependencyProperty *GetTargetDependencyProperty ();
913 static void SetTargetName (DependencyObject *o, const char *targetName);
914 static const char *GetTargetName (DependencyObject *o);
915 static void SetTargetProperty (DependencyObject *o, PropertyPath *targetProperty);
916 static PropertyPath *GetTargetProperty (DependencyObject *o);
918 protected:
919 virtual ~Storyboard ();
921 private:
922 bool HookupAnimationsRecurse (Clock *clock,
923 DependencyObject *targetObject, PropertyPath *targetPropertyPath,
924 GHashTable *promoted_values,
925 MoonError *error);
928 /* @Namespace=System.Windows.Media.Animation */
929 /* @ContentProperty="Storyboard" */
930 class BeginStoryboard : public TriggerAction {
931 public:
932 /* @PropertyType=Storyboard,GenerateAccessors */
933 const static int StoryboardProperty;
935 /* @GenerateCBinding,GeneratePInvoke */
936 BeginStoryboard ();
938 virtual void Fire ();
941 // Property Accessors
943 void SetStoryboard (Storyboard *sb);
944 Storyboard *GetStoryboard ();
946 protected:
947 virtual ~BeginStoryboard ();
950 // internal WPF class gleaned from stack traces
951 class AnimationStorage {
952 public:
954 class Node : public List::Node {
955 public:
956 AnimationStorage *storage;
957 DependencyProperty *key;
959 Node (DependencyProperty *key, AnimationStorage *storage) {
960 this->key = key;
961 this->storage = storage;
964 Node *Clone () {
965 return new Node (key, storage);
969 AnimationStorage (AnimationClock *clock, Animation *timeline,
970 DependencyObject *targetobj, DependencyProperty *targetprop);
971 ~AnimationStorage ();
973 void SwitchTarget (DependencyObject *target);
974 void Enable ();
975 void Disable ();
976 void Stop ();
977 bool IsCurrentStorage ();
979 Value* GetResetValue ();
980 void SetStopValue (Value *value);
982 AnimationClock *GetClock ();
983 Animation *GetTimeline ();
985 private:
987 void ResetPropertyValue ();
988 void UpdatePropertyValue ();
989 static void update_property_value (EventObject *sender, EventArgs *calldata, gpointer data);
991 void TargetObjectDestroyed ();
992 static void target_object_destroyed (EventObject *sender, EventArgs *calldata, gpointer data);
994 void AttachUpdateHandler ();
995 void DetachUpdateHandler ();
996 void AttachTargetHandler ();
997 void DetachTargetHandler ();
998 void DetachFromProperty ();
1000 AnimationClock *clock;
1001 Animation* timeline;
1002 DependencyObject *targetobj;
1003 DependencyProperty *targetprop;
1004 Value *baseValue;
1005 Value *stopValue;
1006 bool disabled;
1009 /* @Namespace=None,ManagedDependencyProperties=None */
1010 class AnimationClock : public Clock {
1011 public:
1012 AnimationClock (Animation *timeline);
1014 Value *GetCurrentValue (Value *defaultOriginValue, Value *defaultDestinationValue);
1016 AnimationStorage *HookupStorage (DependencyObject *targetobj, DependencyProperty *targetprop);
1017 void DetachStorage ();
1019 virtual void Stop ();
1020 virtual void Begin (TimeSpan parentTime);
1022 protected:
1023 virtual ~AnimationClock ();
1025 private:
1026 Animation *timeline;
1027 AnimationStorage *storage;
1030 #endif /* MOON_ANIMATION_H */