Author: toshok
Date: 2007-06-07 00:03:19 -0400 (Thu, 07 Jun 2007)
New Revision: 78812
Modified:
trunk/moon/src/ChangeLog
trunk/moon/src/animation.cpp
trunk/moon/src/animation.h
Log:
* animation.cpp: new dump of the animation stuff. this is much
closer in spirit and implementation to that of WPF's
timing/animation system. it's not perfect yet, but it's much,
much closer.
2007-06-06 Chris Toshok <[EMAIL PROTECTED]>
Modified: trunk/moon/src/ChangeLog
===================================================================
--- trunk/moon/src/ChangeLog 2007-06-07 03:59:29 UTC (rev 78811)
+++ trunk/moon/src/ChangeLog 2007-06-07 04:03:19 UTC (rev 78812)
@@ -1,5 +1,12 @@
2007-06-06 Chris Toshok <[EMAIL PROTECTED]>
+ * animation.cpp: new dump of the animation stuff. this is much
+ closer in spirit and implementation to that of WPF's
+ timing/animation system. it's not perfect yet, but it's much,
+ much closer.
+
+2007-06-06 Chris Toshok <[EMAIL PROTECTED]>
+
* runtime.h: make the point/color/rect copy constructors take a
ref, not a pointer. also, make the value contructors for struct
types by-value.
Modified: trunk/moon/src/animation.cpp
===================================================================
--- trunk/moon/src/animation.cpp 2007-06-07 03:59:29 UTC (rev 78811)
+++ trunk/moon/src/animation.cpp 2007-06-07 04:03:19 UTC (rev 78812)
@@ -11,20 +11,14 @@
#include "animation.h"
-/*
- * Magic number to convert a time which is relative to
- * Jan 1, 1970 into a value which is relative to Jan 1, 0001.
- */
-#define EPOCH_ADJUST ((guint64)62135596800LL)
-
-static gint64
+static guint64
get_now ()
{
struct timeval tv;
- gint64 res;
+ guint64 res;
if (gettimeofday (&tv, NULL) == 0) {
- res = (((gint64)tv.tv_sec + EPOCH_ADJUST)* 1000000 +
tv.tv_usec)*10;
+ res = ((guint64)tv.tv_sec * 1000000 + tv.tv_usec)*10;
return res;
}
@@ -33,74 +27,141 @@
}
+TimeManager* TimeManager::_instance = NULL;
+TimeManager::TimeManager ()
+ : child_clocks (NULL)
+{
+}
-Clock::Clock (Timeline *tl)
- : timeline (tl),
- parent_clock (NULL),
- child_clocks (NULL)
- //current_state(ClockStopped),
- //is_paused (FALSE)
+void
+TimeManager::Start()
{
+ current_global_time = get_now ();
+ tick_id = gtk_timeout_add (60 /* something suitably small */,
TimeManager::tick_timeout, this);
}
-Clock::Clock (Timeline *tl, Clock *clock)
- : timeline (tl),
- parent_clock (clock),
- child_clocks (NULL)
- //current_state (ClockStopped),
- //is_paused (FALSE)
+gboolean
+TimeManager::tick_timeout (gpointer data)
{
- parent_clock->child_clocks = g_list_prepend
(parent_clock->child_clocks, clock);
+ ((TimeManager*)data)->Tick ();
+ return TRUE;
}
void
-Clock::Begin ()
+TimeManager::Tick ()
{
- if (parent_clock != NULL) {
- /* XXX error */
- return;
- }
-
- start_time = get_now();
- events->Emit ("CurrentTimeInvalidated");
+ current_global_time = get_now ();
- tick_id = gtk_timeout_add (50 /* something suitably small */,
Clock::tick_timeout, this);
+ //printf ("TimeManager::Tick\n");
- for (GList *l = child_clocks; l; l = l->next) {
- ((Clock*)l->data)->Begin();
- }
+ // loop over all toplevel clocks, updating their time (and
+ // triggering them to queue up their events) using the
+ // value of current_global_time...
+
+ for (GList *l = child_clocks; l; l = l->next)
+ ((Clock*)l->data)->TimeUpdated (current_global_time);
+
+
+ // ... then cause all clocks to raise the events they've queued up
+ RaiseEnqueuedEvents ();
}
-gboolean
-Clock::tick_timeout (gpointer data)
+void
+TimeManager::RaiseEnqueuedEvents ()
{
- ((Clock*)data)->Tick ();
- return true;
+ for (GList *l = child_clocks; l; l = l->next)
+ ((Clock*)l->data)->RaiseAccumulatedEvents ();
}
void
-Clock::Tick ()
+TimeManager::AddChild (Clock *child)
{
- for (GList *l = child_clocks; l; l = l->next) {
- ((Clock*)l->data)->Tick();
- }
+ child_clocks = g_list_prepend (child_clocks, child);
+}
- events->Emit ("CurrentTimeInvalidated");
+void
+TimeManager::RemoveChild (Clock *child)
+{
+ child_clocks = g_list_remove (child_clocks, child);
}
+
+
+
+
+Clock::Clock (Timeline *tl)
+ : timeline (tl),
+ queued_events (0)
+{
+ SetObjectType (Value::CLOCK);
+}
+
void
-Clock::Pause ()
+Clock::TimeUpdated (guint64 parent_clock_time)
{
- if (parent_clock != NULL) {
- /* XXX error */
- return;
+ current_time = parent_clock_time - start_time;
+ //printf ("queueing CURRENT_TIME_INVALIDATED!\n");
+ QueueEvent (CURRENT_TIME_INVALIDATED);
+}
+
+void
+Clock::RaiseAccumulatedEvents ()
+{
+ if ((queued_events & CURRENT_TIME_INVALIDATED) != 0) {
+// printf ("EMITTING CURRENT_TIME_INVALIDATED\n");
+ events->Emit (/*this,*/ "CurrentTimeInvalidated");
}
- g_source_remove (tick_id);
+
+ if ((queued_events & SPEED_CHANGED) != 0)
+ SpeedChanged ();
+
+ /* XXX more events here, i assume */
+
+ queued_events = 0;
}
void
+Clock::QueueEvent (int event)
+{
+ queued_events |= event;
+}
+
+guint64
+Clock::GetCurrentTime ()
+{
+ return current_time;
+}
+
+double
+Clock::GetCurrentProgress ()
+{
+ // XXX this is wrong - we shouldn't call GetCurrentTime() here since it
calls get_now().
+
+// if (current_state == ClockStopped)
+// return 0.0;
+
+ guint64/*TimeSpan*/ current_time = GetCurrentTime ();
+ guint64 duration = timeline->GetValue
(Timeline::DurationProperty)->u.ui64;
+
+// printf ("Clock::GetCurrentProgress (), current_time = %llu, start_time
= %llu, current_time - start_time = %llu, duration = %llu\n", current_time,
start_time, current_time - start_time, duration);
+
+ return (double)(current_time - start_time) / duration;
+}
+
+void
+Clock::Begin (guint64 start_time)
+{
+ this->start_time = start_time;
+}
+
+void
+Clock::Pause ()
+{
+}
+
+void
Clock::Remove ()
{
}
@@ -108,79 +169,147 @@
void
Clock::Resume ()
{
- if (parent_clock != NULL) {
- /* XXX error */
- return;
- }
+}
- tick_id = gtk_timeout_add (50 /* something suitably small */,
Clock::tick_timeout, this);
+void
+Clock::Seek (/*Timespan*/guint64 timespan)
+{
}
void
-Clock::Seek (/*Timespan*/gint64 timespan)
+Clock::SeekAlignedToLastTick ()
{
- if (parent_clock != NULL) {
- /* XXX error */
- return;
- }
+}
- events->Emit ("CurrentTimeInvalidated");
+void
+Clock::SkipToFill ()
+{
}
void
-Clock::SeekAlignedToLastTick ()
+Clock::Stop ()
{
- if (parent_clock != NULL) {
- /* XXX error */
- return;
- }
+}
- events->Emit ("CurrentTimeInvalidated");
+
+
+ClockGroup::ClockGroup (TimelineGroup *timeline)
+ : timeline (timeline),
+ Clock (timeline),
+ child_clocks (NULL)
+{
+ SetObjectType (Value::CLOCKGROUP);
}
void
-Clock::SkipToFill ()
+ClockGroup::AddChild (Clock *clock)
{
- if (parent_clock != NULL) {
- /* XXX error */
- return;
+ child_clocks = g_list_append (child_clocks, clock);
+}
+
+void
+ClockGroup::RemoveChild (Clock *clock)
+{
+ child_clocks = g_list_remove (child_clocks, clock);
+}
+
+void
+ClockGroup::Begin (guint64 start_time)
+{
+ this->Clock::Begin (start_time);
+
+ for (GList *l = child_clocks; l; l = l->next) {
+ ((Clock*)l->data)->Begin (current_time);
}
+}
- events->Emit ("CurrentTimeInvalidated");
+void
+ClockGroup::TimeUpdated (guint64 parent_clock_time)
+{
+// printf ("ClockGroup::TimeUpdated\n");
+ /* recompute our current_time */
+ this->Clock::TimeUpdated (parent_clock_time);
+
+ for (GList *l = child_clocks; l; l = l->next) {
+// printf ("+ Calling child TimeUpdated\n");
+ ((Clock*)l->data)->TimeUpdated (current_time);
+ }
}
void
-Clock::Stop ()
+ClockGroup::RaiseAccumulatedEvents ()
{
- if (parent_clock != NULL) {
- /* XXX error */
- return;
+ /* raise our events */
+ this->Clock::RaiseAccumulatedEvents ();
+
+ /* now cause our children to raise theirs*/
+ for (GList *l = child_clocks; l; l = l->next) {
+// printf ("+ Calling child RaiseAccumulatedEvents\n");
+ ((Clock*)l->data)->RaiseAccumulatedEvents ();
}
+}
- g_source_remove (tick_id);
- events->Emit ("CurrentTimeInvalidated");
+
+
+AnimationStorage::AnimationStorage (AnimationClock *clock,
Animation/*Timeline*/ *timeline,
+ DependencyObject *targetobj,
DependencyProperty *targetprop)
+ : clock (clock),
+ timeline (timeline),
+ targetobj (targetobj),
+ targetprop (targetprop)
+
+{
+ clock->events->AddHandler ("CurrentTimeInvalidated",
update_property_value, this);
}
-double
-Clock::GetCurrentProgress ()
+void
+AnimationStorage::update_property_value (gpointer data)
{
-// if (current_state == ClockStopped)
-// return 0.0;
+ ((AnimationStorage*)data)->UpdatePropertyValue ();
+}
- gint64/*TimeSpan*/ current_time = GetCurrentTime ();
- gint64 duration = timeline->GetValue
(Timeline::DurationProperty)->u.i64;
+void
+AnimationStorage::UpdatePropertyValue ()
+{
+ Value *current_value = clock->GetCurrentValue (NULL/*XXX*/,
NULL/*XXX*/);
+ targetobj->SetValue (targetprop, *current_value);
+}
- return (double)current_time / duration;
+
+AnimationClock::AnimationClock (Animation/*Timeline*/ *timeline)
+ : timeline(timeline),
+ Clock (timeline)
+{
+ SetObjectType (Value::ANIMATIONCLOCK);
}
-gint64
-Clock::GetCurrentTime ()
+void
+AnimationClock::HookupStorage (DependencyObject *targetobj, DependencyProperty
*targetprop)
{
- return get_now () - start_time;
+ storage = new AnimationStorage (this, timeline, targetobj, targetprop);
}
+Value*
+AnimationClock::GetCurrentValue (Value* defaultOriginValue, Value*
defaultDestinationValue)
+{
+ return timeline->GetCurrentValue (defaultOriginValue,
defaultDestinationValue, this);
+}
+
+Value*
+Animation/*Timeline*/::GetCurrentValue (Value* defaultOriginValue, Value*
defaultDestinationValue,
+ AnimationClock* animationClock)
+{
+ return NULL;
+}
+
+// Duration
+// AnimationTimeline::GetNaturalDurationCore (Clock* clock)
+// {
+// }
+
+
/* timeline */
DependencyProperty* Timeline::AutoReverseProperty;
@@ -191,28 +320,14 @@
DependencyProperty* Timeline::SpeedRatioProperty;
Timeline::Timeline ()
- : clock (NULL)
{
}
-void
-Timeline::SetClock (Clock *new_clock)
-{
- if (clock != NULL) {
- clock->events->RemoveHandler ("CurrentTimeInvalidated",
Timeline::clock_time_changed, this);
- delete clock;
- }
- clock = new_clock;
-
- if (clock != NULL)
- clock->events->AddHandler ("CurrentTimeInvalidated",
Timeline::clock_time_changed, this);
-}
-
void
-Timeline::clock_time_changed (gpointer data)
+timeline_set_duration (Timeline *timeline, guint64 duration)
{
- ((Timeline*)data)->ClockTimeChanged();
+ timeline->SetValue (Timeline::DurationProperty, Value(duration));
}
/* timeline group */
@@ -222,18 +337,27 @@
{
}
+ClockGroup*
+TimelineGroup::CreateClock ()
+{
+ ClockGroup* group = (ClockGroup*)AllocateClock ();
+ for (GList *l = child_timelines; l ; l = l->next) {
+ group->AddChild (((Timeline*)l->data)->AllocateClock ());
+ }
+
+ return group;
+}
+
void
TimelineGroup::AddChild (Timeline *child)
{
child_timelines = g_list_prepend (child_timelines, child);
-
- child->SetClock (new Clock (child, this->clock));
}
void
TimelineGroup::RemoveChild (Timeline *child)
{
- /* nada for now */
+ child_timelines = g_list_remove (child_timelines, child);
}
void
@@ -249,6 +373,7 @@
}
+
/* storyboard */
DependencyProperty* Storyboard::TargetNameProperty;
@@ -256,65 +381,83 @@
Storyboard::Storyboard ()
{
+ SetObjectType (Value::STORYBOARD);
}
void
+Storyboard::HookupAnimationsRecurse (Clock *clock)
+{
+ switch (clock->GetObjectType ()) {
+ case Value::ANIMATIONCLOCK: {
+ AnimationClock *ac = (AnimationClock*)clock;
+
+ char *targetProperty = storyboard_child_get_target_property
(this, ac->GetTimeline());
+ if (!targetProperty)
+ return;
+
+ char *targetName = storyboard_child_get_target_name (this,
ac->GetTimeline());
+ if (!targetName)
+ return;
+
+ DependencyObject *o = FindName (targetName);
+ if (!o)
+ return;
+
+ DependencyProperty *prop = o->GetDependencyProperty
(targetProperty);
+ if (!prop)
+ return;
+
+
+ ac->HookupStorage (o, prop);
+ break;
+ }
+ case Value::CLOCKGROUP: {
+ ClockGroup *cg = (ClockGroup*)clock;
+ for (GList *l = cg->child_clocks; l; l = l->next)
+ HookupAnimationsRecurse ((Clock*)l->data);
+ break;
+ }
+ }
+}
+
+void
Storyboard::Begin ()
{
- clock->Begin ();
+ root_clock = CreateClock ();
+
+ // walk the clock tree hooking up the correct properties and creating
AnimationStorage's
+ HookupAnimationsRecurse (root_clock);
+
+ /* hack to make storyboards work.. we need to attach them to
TimeManager's list of clocks */
+ TimeManager::Instance()->AddChild (root_clock);
+
+ root_clock->Begin (TimeManager::GetCurrentGlobalTime());
}
void
Storyboard::Pause ()
{
- clock->Pause ();
+ root_clock->Pause ();
}
void
Storyboard::Resume ()
{
- clock->Resume ();
+ root_clock->Resume ();
}
void
-Storyboard::Seek (/*Timespan*/gint64 timespan)
+Storyboard::Seek (/*Timespan*/guint64 timespan)
{
- clock->Seek (timespan);
+ root_clock->Seek (timespan);
}
void
Storyboard::Stop ()
{
- clock->Stop ();
+ root_clock->Stop ();
}
-void
-Storyboard::ClockTimeChanged ()
-{
- for (GList *l = child_timelines; l; l = l->next) {
-
- char *targetProperty = storyboard_child_get_target_property
(this, ((Timeline*)l->data));
- if (!targetProperty)
- continue;
-
- char *targetName = storyboard_child_get_target_name (this,
((Timeline*)l->data));
- if (!targetName)
- continue;
-
-#if notyet
- DependencyObject *o = name_scope.LookupObject (targetName);
- if (!o)
- continue;
-
- DependencyProperty *prop = o->GetDependencyProperty
(targetProperty);
- if (!prop)
- continue;
-
- o->SetValue (prop, child_timeline.GetCurrentValue ());
-#endif
- }
-}
-
Storyboard *
storyboard_new ()
{
@@ -340,7 +483,7 @@
}
void
-storyboard_seek (Storyboard *sb, /*Timespan*/gint64 timespan)
+storyboard_seek (Storyboard *sb, /*Timespan*/guint64 timespan)
{
sb->Seek (timespan);
}
@@ -356,7 +499,7 @@
DependencyObject *o,
char *targetProperty)
{
- o->SetValue (Storyboard::TargetPropertyProperty, targetProperty);
+ o->SetValue (Storyboard::TargetPropertyProperty, Value
(targetProperty));
}
char*
@@ -372,7 +515,7 @@
DependencyObject *o,
char *targetName)
{
- o->SetValue (Storyboard::TargetNameProperty, targetName);
+ o->SetValue (Storyboard::TargetNameProperty, Value (targetName));
}
char*
@@ -398,8 +541,27 @@
DoubleAnimation::DoubleAnimation ()
{
+ SetObjectType (Value::DOUBLEANIMATION);
}
+Value*
+DoubleAnimation::GetCurrentValue (Value *defaultOriginValue, Value
*defaultDestinationValue,
+ AnimationClock* animationClock)
+{
+ double by = double_animation_get_by (this);
+ double from = double_animation_get_from (this);
+ double to = double_animation_get_to (this);
+
+ double progress = animationClock->GetCurrentProgress ();
+
+// printf ("in GetCurrentValue, by = %f, from = %f, to = %f\n", by, from,
to);
+// printf ("Progress = %lf\n", progress);
+
+// // XXX we should really use "by" here...
+// printf ("returning %f\n", from + (to-from) * progress);
+ return new Value (from + (to-from) * progress);
+}
+
DoubleAnimation *
double_animation_new ()
{
@@ -419,15 +581,48 @@
return v == NULL ? 0.0 : v->u.d;
}
+void
+double_animation_set_from (DoubleAnimation *da, double by)
+{
+ da->SetValue (DoubleAnimation::FromProperty, Value(by));
+}
+double
+double_animation_get_from (DoubleAnimation *da)
+{
+ Value *v = da->GetValue (DoubleAnimation::FromProperty);
+ return v == NULL ? 0.0 : v->u.d;
+}
+void
+double_animation_set_to (DoubleAnimation *da, double by)
+{
+ da->SetValue (DoubleAnimation::ToProperty, Value(by));
+}
+
+double
+double_animation_get_to (DoubleAnimation *da)
+{
+ Value *v = da->GetValue (DoubleAnimation::ToProperty);
+ return v == NULL ? 0.0 : v->u.d;
+}
+
+
+guint64
+duration_from_seconds (int seconds)
+{
+ return (guint64)seconds * 10000000;
+}
+
+RepeatBehavior RepeatBehavior::Forever (RepeatBehavior::FOREVER);
+
void
animation_init ()
{
/* Timeline properties */
Timeline::AutoReverseProperty = DependencyObject::Register
(Value::TIMELINE, "AutoReverse", new Value (false));
- Timeline::BeginTimeProperty = DependencyObject::Register
(Value::TIMELINE, "BeginTime", new Value (0));
- Timeline::DurationProperty = DependencyObject::Register
(Value::TIMELINE, "Duration", new Value (0));
+ Timeline::BeginTimeProperty = DependencyObject::Register
(Value::TIMELINE, "BeginTime", new Value ((guint64)0));
+ Timeline::DurationProperty = DependencyObject::Register
(Value::TIMELINE, "Duration", new Value ((guint64)0));
//DependencyObject::Register (DependencyObject::TIMELINE,
"FillBehavior", new Value (0));
//DependencyObject::Register (DependencyObject::TIMELINE,
"RepeatBehavior", new Value (0));
//DependencyObject::Register (DependencyObject::TIMELINE, "SpeedRatio",
new Value (0));
Modified: trunk/moon/src/animation.h
===================================================================
--- trunk/moon/src/animation.h 2007-06-07 03:59:29 UTC (rev 78811)
+++ trunk/moon/src/animation.h 2007-06-07 04:03:19 UTC (rev 78812)
@@ -2,48 +2,187 @@
G_BEGIN_DECLS
+// misc types
+struct RepeatBehavior {
+ public:
+ RepeatBehavior (RepeatBehavior *repeat)
+ : k (repeat->k),
+ duration (repeat->duration),
+ count (repeat->count)
+ {
+ }
+
+ RepeatBehavior (double count)
+ {
+ k = COUNT;
+ }
+
+ RepeatBehavior (guint64/*TimeSpan*/ duration)
+ {
+ k = DURATION;
+ }
+
+ static RepeatBehavior Forever;
+
+ bool operator!= (const RepeatBehavior &v) const
+ {
+ return !(*this == v);
+ }
+
+ bool operator== (const RepeatBehavior &v) const
+ {
+ if (v.k != k)
+ return false;
+
+ switch (k) {
+ case DURATION: return duration == v.duration;
+ case COUNT: return count == v.count;
+ case FOREVER: return true;
+ }
+ }
+
+ double GetCount () { return count; }
+ guint64/*TimeSpan*/ GetDuration() { return duration; }
+
+ bool HasCount() { return k == COUNT; }
+ bool HasDuration () { return k == DURATION; }
+
+ private:
+ enum RepeatKind {
+ COUNT,
+ DURATION,
+ FOREVER
+ };
+
+ RepeatKind k;
+ double count;
+ guint64/*TimeSpan*/ duration;
+
+ RepeatBehavior (RepeatKind kind) : k(kind) { };
+};
+
+
+
+
+
+// our root level time manager (basically the object that registers
+// the gtk_timeout and drives all Clock objects
+class Clock;
+
+class TimeManager {
+ public:
+ void Start ();
+
+ void Tick ();
+
+ static TimeManager* Instance()
+ {
+ if (_instance == NULL) _instance = new TimeManager ();
+ return _instance;
+ }
+
+ static guint64 GetCurrentGlobalTime () { return
Instance()->current_global_time; }
+
+ void AddChild (Clock *clock);
+ void RemoveChild (Clock *clock);
+
+ private:
+ TimeManager ();
+
+ void RaiseEnqueuedEvents ();
+
+ static TimeManager *_instance;
+
+ GList *child_clocks; // XXX should we just have a ClockGroup?
+
+ guint64 current_global_time;
+ static gboolean tick_timeout (gpointer data);
+ gint tick_id;
+};
+
+
+
+
+
+//
+// Clocks and timelines
+//
+
+
class Timeline;
-class DependencyObject;
+class TimelineGroup;
-/* this merges WPF's Clock and ClockController */
class Clock : public DependencyObject {
public:
+ enum {
+ CURRENT_GLOBAL_SPEED_INVALIDATED = 0x01,
+ CURRENT_STATE_INVALIDATED = 0x02,
+ CURRENT_TIME_INVALIDATED = 0x04,
+ REMOVE_REQUESTED = 0x08,
+ SPEED_CHANGED = 0x10
+ };
+
Clock (Timeline *timeline);
- Clock (Timeline *timeline, Clock *clock);
- void Begin ();
+ virtual void SpeedChanged () { };
+
+ virtual void Begin (guint64 parent_time);
void Pause ();
void Remove ();
void Resume ();
- void Seek (gint64/*TimeSpan*/ timespan);
+ void Seek (guint64/*TimeSpan*/ timespan);
void SeekAlignedToLastTick ();
void SkipToFill ();
void Stop ();
double GetCurrentProgress ();
- gint64 GetCurrentTime ();
+ guint64 GetCurrentTime ();
+ Timeline *GetTimeline () { return timeline; }
- static long current_global_time;
+ virtual void RaiseAccumulatedEvents ();
+ virtual void TimeUpdated (guint64 parent_time);
+ protected:
+ guint64/*TimeSpan*/ current_time;
+ guint64/*TimeSpan*/ start_time; /* the time we actually started. used
for computing CurrentTime */
+ void QueueEvent (int event);
+ private:
+ Timeline *timeline;
+ int queued_events;
Clock *parent_clock;
- GList *child_clocks;
+};
- gint tick_id;
- void Tick ();
- static gboolean tick_timeout (gpointer data);
- Timeline *timeline;
- gint64/*TimeSpan*/ start_time; /* the time we actually started. used
for computing CurrentTime */
+
+
+class ClockGroup : public Clock {
+ public:
+ ClockGroup (TimelineGroup *timeline);
+
+ virtual void Begin (guint64 parent_time);
+
+ void AddChild (Clock *clock);
+ void RemoveChild (Clock *clock);
+
+ virtual void RaiseAccumulatedEvents ();
+ virtual void TimeUpdated (guint64 parent_time);
+
+ GList *child_clocks;
+
+ private:
+ TimelineGroup *timeline;
};
+
+
+
+
class Timeline : public DependencyObject {
public:
Timeline ();
- void SetClock (Clock *new_clock);
-
static DependencyProperty* AutoReverseProperty;
static DependencyProperty* BeginTimeProperty;
static DependencyProperty* DurationProperty;
@@ -51,21 +190,23 @@
static DependencyProperty* RepeatBehaviorProperty;
static DependencyProperty* SpeedRatioProperty;
- protected:
- virtual void ClockTimeChanged () { }
-
- static void clock_time_changed (gpointer data);
- Clock *clock;
+ virtual Clock* AllocateClock () { return new Clock (this); }
};
+void timeline_set_duration (Timeline *timeline, guint64 duration);
-class Animation : public Timeline {
-};
+
+
+
class TimelineGroup : public Timeline {
public:
TimelineGroup ();
+ virtual Clock *AllocateClock () { return new ClockGroup (this); }
+
+ ClockGroup *CreateClock ();
+
/* we use these dependency properties:
Timeline Children - XXX shouldn't that be TimelineCollection?
*/
@@ -80,6 +221,9 @@
+
+
+
class ParallelTimeline : public TimelineGroup {
public:
ParallelTimeline () { }
@@ -87,6 +231,98 @@
+
+
+//
+// Animations (more specialized clocks and timelines) and their subclasses
+//
+class Animation;
+class AnimationClock;
+
+// internal WPF class gleaned from stack traces
+class AnimationStorage {
+ public:
+ AnimationStorage (AnimationClock *clock, Animation/*Timeline*/
*timeline,
+ DependencyObject *targetobj, DependencyProperty
*targetprop);
+
+ private:
+ void UpdatePropertyValue ();
+ static void update_property_value (gpointer data);
+
+ AnimationClock *clock;
+ Animation/*Timeline*/* timeline;
+ DependencyObject *targetobj;
+ DependencyProperty *targetprop;
+};
+
+
+
+
+
+class Animation/*Timeline*/;
+
+class AnimationClock : public Clock {
+ public:
+ AnimationClock (Animation/*Timeline*/ *timeline);
+
+ Value *GetCurrentValue (Value *defaultOriginValue, Value
*defaultDestinationValue);
+
+ void HookupStorage (DependencyObject *targetobj, DependencyProperty
*targetprop);
+ private:
+ Animation/*Timeline*/ *timeline;
+ AnimationStorage *storage;
+};
+
+
+
+
+
+/* this is called AnimationTimeline in wpf */
+class Animation/*Timeline*/ : public Timeline {
+ public:
+
+ Animation/*Timeline*/ () { };
+
+ virtual Clock *AllocateClock () { return new AnimationClock (this); }
+
+ virtual Value *GetCurrentValue (Value *defaultOriginValue, Value
*defaultDestinationValue,
+ AnimationClock* animationClock);
+
+ // Duration GetNaturalDurationCore (Clock* clock);
+};
+
+
+
+
+
+class DoubleAnimation : public Animation/*Timeline*/ {
+ public:
+
+ DoubleAnimation ();
+
+ static DependencyProperty* ByProperty;
+ static DependencyProperty* FromProperty;
+ static DependencyProperty* ToProperty;
+
+ virtual Value *GetCurrentValue (Value *defaultOriginValue, Value
*defaultDestinationValue,
+ AnimationClock* animationClock);
+};
+
+DoubleAnimation * double_animation_new ();
+
+void double_animation_set_by (DoubleAnimation *da, double by);
+double double_animation_get_by (DoubleAnimation *da);
+
+void double_animation_set_from (DoubleAnimation *da, double from);
+double double_animation_get_from (DoubleAnimation *da);
+
+void double_animation_set_to (DoubleAnimation *da, double to);
+double double_animation_get_to (DoubleAnimation *da);
+
+
+
+
+
class Storyboard : public ParallelTimeline {
public:
Storyboard ();
@@ -94,7 +330,7 @@
void Begin ();
void Pause ();
void Resume ();
- void Seek (/*Timespan*/gint64 timespan);
+ void Seek (/*Timespan*/guint64 timespan);
void Stop ();
static DependencyProperty* TargetNameProperty;
@@ -102,9 +338,12 @@
// XXX event Completed
- virtual void ClockTimeChanged ();
+/* virtual void ClockTimeChanged (); */
private:
+ void HookupAnimationsRecurse (Clock *clock);
+ Clock *root_clock;
+
gboolean Tick ();
static gboolean storyboard_tick (gpointer data);
};
@@ -113,7 +352,7 @@
void storyboard_begin (Storyboard *sb);
void storyboard_pause (Storyboard *sb);
void storyboard_resume (Storyboard *sb);
-void storyboard_seek (Storyboard *sb, /*Timespan*/gint64 timespan);
+void storyboard_seek (Storyboard *sb, /*Timespan*/guint64 timespan);
void storyboard_stop (Storyboard *sb);
void storyboard_child_set_target_property (Storyboard *sb,
@@ -130,6 +369,10 @@
char* storyboard_child_get_target_name (Storyboard *sb,
DependencyObject *o);
+
+
+
+
class BeginStoryboard : public TriggerAction {
public:
@@ -143,25 +386,8 @@
BeginStoryboard *begin_storyboard_new ();
-class DoubleAnimation : public Animation {
- public:
- DoubleAnimation ();
+// XXX this should instead be TimeSpan.FromSeconds, or something.
+guint64 duration_from_seconds (int seconds);
- static DependencyProperty* ByProperty;
- static DependencyProperty* FromProperty;
- static DependencyProperty* ToProperty;
-};
-
-DoubleAnimation * double_animation_new ();
-
-void double_animation_set_by (DoubleAnimation *da, double by);
-double double_animation_get_by (DoubleAnimation *da);
-
-void double_animation_set_from (DoubleAnimation *da, double from);
-double double_animation_get_from (DoubleAnimation *da);
-
-void double_animation_set_to (DoubleAnimation *da, double to);
-double double_animation_get_to (DoubleAnimation *da);
-
G_END_DECLS
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches