Author: toshok
Date: 2007-06-11 13:40:52 -0400 (Mon, 11 Jun 2007)
New Revision: 79199
Modified:
trunk/moon/src/ChangeLog
trunk/moon/src/animation.cpp
trunk/moon/src/animation.h
trunk/moon/src/runtime.cpp
trunk/moon/src/value.h
Log:
2007-06-11 Chris Toshok <[EMAIL PROTECTED]>
* animation.h, animation.cpp: use KeyFrameCollection's for the
*AnimationUsingKeyFrames key frame stuff, instead of GLists.
* value.h, runtime.cpp: add Value::AsKeyFrameCollection.
Modified: trunk/moon/src/ChangeLog
===================================================================
--- trunk/moon/src/ChangeLog 2007-06-11 17:30:59 UTC (rev 79198)
+++ trunk/moon/src/ChangeLog 2007-06-11 17:40:52 UTC (rev 79199)
@@ -1,3 +1,10 @@
+2007-06-11 Chris Toshok <[EMAIL PROTECTED]>
+
+ * animation.h, animation.cpp: use KeyFrameCollection's for the
+ *AnimationUsingKeyFrames key frame stuff, instead of GLists.
+
+ * value.h, runtime.cpp: add Value::AsKeyFrameCollection.
+
2007-06-11 Jackson Harper <[EMAIL PROTECTED]>
* xaml.cpp: Make the parents of collections the Collection ghost
Modified: trunk/moon/src/animation.cpp
===================================================================
--- trunk/moon/src/animation.cpp 2007-06-11 17:30:59 UTC (rev 79198)
+++ trunk/moon/src/animation.cpp 2007-06-11 17:40:52 UTC (rev 79199)
@@ -421,6 +421,23 @@
}
+
+void
+KeyFrameCollection::Add (void *data)
+{
+ Value *value = (Value*)data;
+ Collection::Add (value->AsKeyFrame());
+}
+
+void
+KeyFrameCollection::Remove (void *data)
+{
+ Value *value = (Value*)data;
+ Collection::Remove (value->AsKeyFrame());
+}
+
+
+
DependencyProperty* DoubleKeyFrame::ValueProperty;
DoubleKeyFrame::DoubleKeyFrame ()
@@ -570,16 +587,57 @@
+DependencyProperty* DoubleAnimationUsingKeyFrames::KeyFramesProperty;
DoubleAnimationUsingKeyFrames::DoubleAnimationUsingKeyFrames()
{
key_frames = NULL;
+ KeyFrameCollection *c = new KeyFrameCollection ();
+
+ this->SetValue (DoubleAnimationUsingKeyFrames::KeyFramesProperty, Value
(c));
+
+ // Ensure that the callback OnPropertyChanged was called.
+ g_assert (c == key_frames);
}
void
+DoubleAnimationUsingKeyFrames::OnPropertyChanged (DependencyProperty *prop)
+{
+ DoubleAnimation::OnPropertyChanged (prop);
+
+ if (prop == KeyFramesProperty){
+ // The new value has already been set, so unref the old
collection
+
+ KeyFrameCollection *newcol = GetValue
(prop)->AsKeyFrameCollection();
+
+ if (newcol != key_frames){
+ if (key_frames){
+ for (GSList *l = key_frames->list; l != NULL; l
= l->next){
+ DependencyObject *dob =
(DependencyObject *) l->data;
+
+ base_unref (dob);
+ }
+ base_unref (key_frames);
+ g_slist_free (key_frames->list);
+ }
+
+ key_frames = newcol;
+ if (key_frames->closure)
+ printf ("Warning we attached a property that
was already attached\n");
+ key_frames->closure = this;
+
+ base_ref (key_frames);
+ }
+ }
+}
+
+void
DoubleAnimationUsingKeyFrames::AddKeyFrame (DoubleKeyFrame *frame)
{
- key_frames = g_list_append (key_frames, frame);
+ KeyFrameCollection *keyframes = GetValue
(DoubleAnimationUsingKeyFrames::KeyFramesProperty)->AsKeyFrameCollection ();
+
+ Value fv = Value(frame);
+ keyframes->Add (&fv);
}
void
@@ -591,7 +649,6 @@
DoubleAnimationUsingKeyFrames::GetCurrentValue (Value *defaultOriginValue,
Value *defaultDestinationValue,
AnimationClock* animationClock)
{
-
/* current segment info */
TimeSpan current_time = animationClock->GetCurrentTime();
DoubleKeyFrame *current_keyframe;
@@ -601,7 +658,8 @@
TimeSpan key_end_time;
/* figure out what segment to use (this list needs to be sorted) */
- for (GList *l = key_frames; l; l = l->next) {
+ GSList *prev = NULL;
+ for (GSList *l = key_frames->list; l; prev = l, l = l->next) {
DoubleKeyFrame *keyframe = (DoubleKeyFrame*)l->data;
key_end_time = keyframe->GetKeyTime()->GetTimeSpan();
@@ -609,8 +667,8 @@
if (key_end_time >= current_time) {
current_keyframe = keyframe;
- if (l->prev)
- previous_keyframe =
(DoubleKeyFrame*)l->prev->data;
+ if (prev)
+ previous_keyframe = (DoubleKeyFrame*)prev->data;
break;
}
@@ -647,15 +705,57 @@
+DependencyProperty* ColorAnimationUsingKeyFrames::KeyFramesProperty;
+
ColorAnimationUsingKeyFrames::ColorAnimationUsingKeyFrames()
{
key_frames = NULL;
+ KeyFrameCollection *c = new KeyFrameCollection ();
+
+ this->SetValue (ColorAnimationUsingKeyFrames::KeyFramesProperty, Value
(c));
+
+ // Ensure that the callback OnPropertyChanged was called.
+ g_assert (c == key_frames);
}
void
+ColorAnimationUsingKeyFrames::OnPropertyChanged (DependencyProperty *prop)
+{
+ ColorAnimation::OnPropertyChanged (prop);
+
+ if (prop == KeyFramesProperty){
+ // The new value has already been set, so unref the old
collection
+
+ KeyFrameCollection *newcol = GetValue
(prop)->AsKeyFrameCollection();
+
+ if (newcol != key_frames){
+ if (key_frames){
+ for (GSList *l = key_frames->list; l != NULL; l
= l->next){
+ DependencyObject *dob =
(DependencyObject *) l->data;
+
+ base_unref (dob);
+ }
+ base_unref (key_frames);
+ g_slist_free (key_frames->list);
+ }
+
+ key_frames = newcol;
+ if (key_frames->closure)
+ printf ("Warning we attached a property that
was already attached\n");
+ key_frames->closure = this;
+
+ base_ref (key_frames);
+ }
+ }
+}
+
+void
ColorAnimationUsingKeyFrames::AddKeyFrame (ColorKeyFrame *frame)
{
- key_frames = g_list_append (key_frames, frame);
+ KeyFrameCollection *keyframes = GetValue
(ColorAnimationUsingKeyFrames::KeyFramesProperty)->AsKeyFrameCollection ();
+
+ Value fv = Value(frame);
+ keyframes->Add (&fv);
}
void
@@ -667,7 +767,6 @@
ColorAnimationUsingKeyFrames::GetCurrentValue (Value *defaultOriginValue,
Value *defaultDestinationValue,
AnimationClock* animationClock)
{
-
/* current segment info */
TimeSpan current_time = animationClock->GetCurrentTime();
ColorKeyFrame *current_keyframe;
@@ -677,7 +776,8 @@
TimeSpan key_end_time;
/* figure out what segment to use (this list needs to be sorted) */
- for (GList *l = key_frames; l; l = l->next) {
+ GSList *prev = NULL;
+ for (GSList *l = key_frames->list; l; prev = l, l = l->next) {
ColorKeyFrame *keyframe = (ColorKeyFrame*)l->data;
key_end_time = keyframe->GetKeyTime()->GetTimeSpan();
@@ -685,8 +785,8 @@
if (key_end_time >= current_time) {
current_keyframe = keyframe;
- if (l->prev)
- previous_keyframe =
(ColorKeyFrame*)l->prev->data;
+ if (prev)
+ previous_keyframe = (ColorKeyFrame*)prev->data;
break;
}
@@ -725,15 +825,57 @@
+DependencyProperty* PointAnimationUsingKeyFrames::KeyFramesProperty;
+
PointAnimationUsingKeyFrames::PointAnimationUsingKeyFrames()
{
key_frames = NULL;
+ KeyFrameCollection *c = new KeyFrameCollection ();
+
+ this->SetValue (PointAnimationUsingKeyFrames::KeyFramesProperty, Value
(c));
+
+ // Ensure that the callback OnPropertyChanged was called.
+ g_assert (c == key_frames);
}
void
+PointAnimationUsingKeyFrames::OnPropertyChanged (DependencyProperty *prop)
+{
+ PointAnimation::OnPropertyChanged (prop);
+
+ if (prop == KeyFramesProperty){
+ // The new value has already been set, so unref the old
collection
+
+ KeyFrameCollection *newcol = GetValue
(prop)->AsKeyFrameCollection();
+
+ if (newcol != key_frames){
+ if (key_frames){
+ for (GSList *l = key_frames->list; l != NULL; l
= l->next){
+ DependencyObject *dob =
(DependencyObject *) l->data;
+
+ base_unref (dob);
+ }
+ base_unref (key_frames);
+ g_slist_free (key_frames->list);
+ }
+
+ key_frames = newcol;
+ if (key_frames->closure)
+ printf ("Warning we attached a property that
was already attached\n");
+ key_frames->closure = this;
+
+ base_ref (key_frames);
+ }
+ }
+}
+
+void
PointAnimationUsingKeyFrames::AddKeyFrame (PointKeyFrame *frame)
{
- key_frames = g_list_append (key_frames, frame);
+ KeyFrameCollection *keyframes = GetValue
(PointAnimationUsingKeyFrames::KeyFramesProperty)->AsKeyFrameCollection ();
+
+ Value fv = Value(frame);
+ keyframes->Add (&fv);
}
void
@@ -745,7 +887,6 @@
PointAnimationUsingKeyFrames::GetCurrentValue (Value *defaultOriginValue,
Value *defaultDestinationValue,
AnimationClock* animationClock)
{
-
/* current segment info */
TimeSpan current_time = animationClock->GetCurrentTime();
PointKeyFrame *current_keyframe;
@@ -755,7 +896,8 @@
TimeSpan key_end_time;
/* figure out what segment to use (this list needs to be sorted) */
- for (GList *l = key_frames; l; l = l->next) {
+ GSList *prev = NULL;
+ for (GSList *l = key_frames->list; l; prev = l, l = l->next) {
PointKeyFrame *keyframe = (PointKeyFrame*)l->data;
key_end_time = keyframe->GetKeyTime()->GetTimeSpan();
@@ -763,8 +905,8 @@
if (key_end_time >= current_time) {
current_keyframe = keyframe;
- if (l->prev)
- previous_keyframe =
(PointKeyFrame*)l->prev->data;
+ if (prev)
+ previous_keyframe = (PointKeyFrame*)prev->data;
break;
}
@@ -853,7 +995,9 @@
PointKeyFrame::ValueProperty = DependencyObject::Register
(Value::POINTKEYFRAME, "Value", Value::POINT);
/* KeyFrame animation properties */
- //PointAnimationUsingKeyFrames::KeyFramesProperty =
DependencyObject::Register (Value::KEYFRAME, "KeyFrames", new
Value(KeyTime::Uniform));
+ ColorAnimationUsingKeyFrames::KeyFramesProperty =
DependencyObject::Register (Value::COLORANIMATIONUSINGKEYFRAMES, "KeyFrames",
Value::KEYFRAME_COLLECTION);
+ DoubleAnimationUsingKeyFrames::KeyFramesProperty =
DependencyObject::Register (Value::DOUBLEANIMATIONUSINGKEYFRAMES, "KeyFrames",
Value::KEYFRAME_COLLECTION);
+ PointAnimationUsingKeyFrames::KeyFramesProperty =
DependencyObject::Register (Value::POINTANIMATIONUSINGKEYFRAMES, "KeyFrames",
Value::KEYFRAME_COLLECTION);
}
Modified: trunk/moon/src/animation.h
===================================================================
--- trunk/moon/src/animation.h 2007-06-11 17:30:59 UTC (rev 79198)
+++ trunk/moon/src/animation.h 2007-06-11 17:40:52 UTC (rev 79199)
@@ -241,7 +241,16 @@
+class KeyFrameCollection : public Collection {
+ public:
+ KeyFrameCollection () {}
+ virtual Value::Kind GetObjectType() { return
Value::KEYFRAME_COLLECTION; }
+ virtual void Add (void *data);
+ virtual void Remove (void *data);
+};
+
+
class DoubleKeyFrame : public KeyFrame {
public:
DoubleKeyFrame ();
@@ -362,8 +371,9 @@
virtual Value *GetCurrentValue (Value *defaultOriginValue, Value
*defaultDestinationValue,
AnimationClock* animationClock);
- private:
- GList *key_frames;
+ virtual void OnPropertyChanged (DependencyProperty *prop);
+
+ KeyFrameCollection *key_frames;
};
DoubleAnimationUsingKeyFrames* double_animation_using_key_frames_new ();
@@ -381,8 +391,9 @@
virtual Value *GetCurrentValue (Value *defaultOriginValue, Value
*defaultDestinationValue,
AnimationClock* animationClock);
- private:
- GList *key_frames;
+ virtual void OnPropertyChanged (DependencyProperty *prop);
+
+ KeyFrameCollection *key_frames;
};
ColorAnimationUsingKeyFrames* color_animation_using_key_frames_new ();
@@ -401,8 +412,9 @@
virtual Value *GetCurrentValue (Value *defaultOriginValue, Value
*defaultDestinationValue,
AnimationClock* animationClock);
- private:
- GList *key_frames;
+ virtual void OnPropertyChanged (DependencyProperty *prop);
+
+ KeyFrameCollection *key_frames;
};
PointAnimationUsingKeyFrames* point_animation_using_key_frames_new ();
Modified: trunk/moon/src/runtime.cpp
===================================================================
--- trunk/moon/src/runtime.cpp 2007-06-11 17:30:59 UTC (rev 79198)
+++ trunk/moon/src/runtime.cpp 2007-06-11 17:40:52 UTC (rev 79199)
@@ -450,6 +450,7 @@
AS_DEP_SUBCLASS_IMPL(DOUBLEANIMATIONUSINGKEYFRAMES,
DoubleAnimationUsingKeyFrames)
AS_DEP_SUBCLASS_IMPL(COLLECTION, Collection)
+AS_DEP_SUBCLASS_IMPL(KEYFRAME_COLLECTION, KeyFrameCollection)
AS_DEP_SUBCLASS_IMPL(VISUAL_COLLECTION, VisualCollection)
AS_DEP_SUBCLASS_IMPL(TRIGGER_COLLECTION, TriggerCollection)
AS_DEP_SUBCLASS_IMPL(TRIGGERACTION_COLLECTION, TriggerActionCollection)
Modified: trunk/moon/src/value.h
===================================================================
--- trunk/moon/src/value.h 2007-06-11 17:30:59 UTC (rev 79198)
+++ trunk/moon/src/value.h 2007-06-11 17:40:52 UTC (rev 79199)
@@ -85,6 +85,7 @@
class UIElement;
class Collection;
+class KeyFrameCollection;
class VisualCollection;
class TriggerCollection;
class TriggerActionCollection;
@@ -341,6 +342,7 @@
PointAnimationUsingKeyFrames* AsPointAnimationUsingKeyFrames ();
Collection* AsCollection ();
+ KeyFrameCollection* AsKeyFrameCollection ();
VisualCollection* AsVisualCollection ();
TriggerCollection* AsTriggerCollection ();
TriggerActionCollection* AsTriggerActionCollection ();
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches