Author: toshok
Date: 2007-06-07 13:18:46 -0400 (Thu, 07 Jun 2007)
New Revision: 78869
Modified:
trunk/moon/src/ChangeLog
trunk/moon/src/animation.cpp
trunk/moon/src/animation.h
trunk/moon/src/demo.cpp
trunk/moon/src/runtime.cpp
trunk/moon/src/runtime.h
Log:
2007-06-07 Chris Toshok <[EMAIL PROTECTED]>
* runtime.h (Value): add COLORANIMATION to the list of types.
Also, add a Kind constructor so we can use that for nullable type
default values in the ::RegisterProperty calls. That is,
initializing the default to Value(Value::COLOR) gives you a null
default value with the COLOR type.
* runtime.cpp (Value): new Kind ctor.
* animation.cpp/.h: add ColorAnimation.
* demo.cpp (main): add a color animation that interpolates between
Red and Blue for the SolidColorBrush.
Modified: trunk/moon/src/ChangeLog
===================================================================
--- trunk/moon/src/ChangeLog 2007-06-07 17:09:35 UTC (rev 78868)
+++ trunk/moon/src/ChangeLog 2007-06-07 17:18:46 UTC (rev 78869)
@@ -1,3 +1,18 @@
+2007-06-07 Chris Toshok <[EMAIL PROTECTED]>
+
+ * runtime.h (Value): add COLORANIMATION to the list of types.
+ Also, add a Kind constructor so we can use that for nullable type
+ default values in the ::RegisterProperty calls. That is,
+ initializing the default to Value(Value::COLOR) gives you a null
+ default value with the COLOR type.
+
+ * runtime.cpp (Value): new Kind ctor.
+
+ * animation.cpp/.h: add ColorAnimation.
+
+ * demo.cpp (main): add a color animation that interpolates between
+ Red and Blue for the SolidColorBrush.
+
2007-06-07 Sebastien Pouliot <[EMAIL PROTECTED]>
* runtime.cpp: Restore alpha support. Don't call cairo_set_operator
Modified: trunk/moon/src/animation.cpp
===================================================================
--- trunk/moon/src/animation.cpp 2007-06-07 17:09:35 UTC (rev 78868)
+++ trunk/moon/src/animation.cpp 2007-06-07 17:18:46 UTC (rev 78869)
@@ -723,6 +723,83 @@
+DependencyProperty* ColorAnimation::ByProperty;
+DependencyProperty* ColorAnimation::FromProperty;
+DependencyProperty* ColorAnimation::ToProperty;
+
+ColorAnimation::ColorAnimation ()
+{
+ SetObjectType (Value::COLORANIMATION);
+}
+
+Value*
+ColorAnimation::GetCurrentValue (Value *defaultOriginValue, Value
*defaultDestinationValue,
+ AnimationClock* animationClock)
+{
+ Color *by = color_animation_get_by (this);
+ Color *from = color_animation_get_from (this);
+ Color *to = color_animation_get_to (this);
+
+ double progress = animationClock->GetCurrentProgress ();
+
+ Value *v = new Value (Color (from->r + (to->r - from->r) * progress,
+ from->g + (to->g - from->g) * progress,
+ from->b + (to->b - from->b) * progress,
+ from->a + (to->a - from->a) * progress));
+
+ // printf ("Sending %g from=%g to=%g progresss=%g\n", v->u.d, from, to,
progress);
+ return v;
+}
+
+ColorAnimation *
+color_animation_new ()
+{
+ return new ColorAnimation ();
+}
+
+void
+color_animation_set_by (ColorAnimation *da, Color by)
+{
+ da->SetValue (ColorAnimation::ByProperty, Value(by));
+}
+
+Color*
+color_animation_get_by (ColorAnimation *da)
+{
+ Value *v = da->GetValue (ColorAnimation::ByProperty);
+ return v == NULL ? NULL : v->u.color;
+}
+
+void
+color_animation_set_from (ColorAnimation *da, Color from)
+{
+ da->SetValue (ColorAnimation::FromProperty, Value(from));
+}
+
+Color*
+color_animation_get_from (ColorAnimation *da)
+{
+ Value *v = da->GetValue (ColorAnimation::FromProperty);
+ return v == NULL ? NULL : v->u.color;
+}
+
+void
+color_animation_set_to (ColorAnimation *da, Color to)
+{
+ da->SetValue (ColorAnimation::ToProperty, Value(to));
+}
+
+Color*
+color_animation_get_to (ColorAnimation *da)
+{
+ Value *v = da->GetValue (ColorAnimation::ToProperty);
+ return v == NULL ? NULL : v->u.color;
+}
+
+
+
+
+
RepeatBehavior RepeatBehavior::Forever (RepeatBehavior::FOREVER);
Duration Duration::Automatic (Duration::AUTOMATIC);
Duration Duration::Forever (Duration::FOREVER);
@@ -740,10 +817,16 @@
/* DoubleAnimation properties */
- DoubleAnimation::ByProperty = DependencyObject::Register
(Value::DOUBLEANIMATION, "By", new Value (0.0));
+ DoubleAnimation::ByProperty = DependencyObject::Register
(Value::DOUBLEANIMATION, "By", new Value (0.0));
DoubleAnimation::FromProperty = DependencyObject::Register
(Value::DOUBLEANIMATION, "From", new Value (0.0));
- DoubleAnimation::ToProperty = DependencyObject::Register
(Value::DOUBLEANIMATION, "To", new Value (0.0));
+ DoubleAnimation::ToProperty = DependencyObject::Register
(Value::DOUBLEANIMATION, "To", new Value (0.0));
+
+ /* ColorAnimation properties */
+ ColorAnimation::ByProperty = DependencyObject::Register
(Value::COLORANIMATION, "By", new Value (Value::COLOR)); // null defaults
+ ColorAnimation::FromProperty = DependencyObject::Register
(Value::COLORANIMATION, "From", new Value (Value::COLOR));
+ ColorAnimation::ToProperty = DependencyObject::Register
(Value::COLORANIMATION, "To", new Value (Value::COLOR));
+
/* Storyboard properties */
Storyboard::TargetPropertyProperty = DependencyObject::Register
(Value::STORYBOARD, "TargetProperty",
Value::STRING);
Modified: trunk/moon/src/animation.h
===================================================================
--- trunk/moon/src/animation.h 2007-06-07 17:09:35 UTC (rev 78868)
+++ trunk/moon/src/animation.h 2007-06-07 17:18:46 UTC (rev 78869)
@@ -404,6 +404,34 @@
+class ColorAnimation : public Animation/*Timeline*/ {
+ public:
+
+ ColorAnimation ();
+
+ static DependencyProperty* ByProperty;
+ static DependencyProperty* FromProperty;
+ static DependencyProperty* ToProperty;
+
+ virtual Value *GetCurrentValue (Value *defaultOriginValue, Value
*defaultDestinationValue,
+ AnimationClock* animationClock);
+};
+
+ColorAnimation * color_animation_new ();
+
+void color_animation_set_by (ColorAnimation *da, Color by);
+Color* color_animation_get_by (ColorAnimation *da);
+
+void color_animation_set_from (ColorAnimation *da, Color from);
+Color* color_animation_get_from (ColorAnimation *da);
+
+void color_animation_set_to (ColorAnimation *da, Color to);
+Color* color_animation_get_to (ColorAnimation *da);
+
+
+
+
+
class Storyboard : public ParallelTimeline {
public:
Storyboard ();
Modified: trunk/moon/src/demo.cpp
===================================================================
--- trunk/moon/src/demo.cpp 2007-06-07 17:09:35 UTC (rev 78868)
+++ trunk/moon/src/demo.cpp 2007-06-07 17:18:46 UTC (rev 78869)
@@ -181,7 +181,21 @@
DoubleAnimation *v_anim = new DoubleAnimation ();
DoubleAnimation *sx_anim = new DoubleAnimation ();
DoubleAnimation *sy_anim = new DoubleAnimation ();
+ ColorAnimation *c_anim = new ColorAnimation ();
+ // the scaled rectangle changes smoothly from Red to
+ // Blue and back again
+ global_NameScope->RegisterName ("solid-color-brush", scb);
+
+ color_animation_set_from (c_anim, Color (1.0, 0.0, 0.0, 0.5));
+ color_animation_set_to (c_anim, Color (0.0, 0.0, 1.0, 0.5));
+ timeline_set_repeat_behavior (c_anim, RepeatBehavior::Forever);
+ timeline_set_duration (c_anim, Duration::FromSeconds (5));
+ timeline_set_autoreverse (c_anim, true);
+ timeline_group_add_child (sb, c_anim);
+ storyboard_child_set_target_name (sb, c_anim,
"solid-color-brush");
+ storyboard_child_set_target_property (sb, c_anim, "Color");
+
// The rectangle rotates completely around every 4
// seconds, and stops after the second time around
global_NameScope->RegisterName ("rect-transform", r_trans);
Modified: trunk/moon/src/runtime.cpp
===================================================================
--- trunk/moon/src/runtime.cpp 2007-06-07 17:09:35 UTC (rev 78868)
+++ trunk/moon/src/runtime.cpp 2007-06-07 17:18:46 UTC (rev 78869)
@@ -116,8 +116,15 @@
Value::Value()
: k (INVALID)
{
+ Init ();
}
+Value::Value (Kind k)
+{
+ Init();
+ this->k = k;
+}
+
Value::Value(bool z)
{
Init ();
Modified: trunk/moon/src/runtime.h
===================================================================
--- trunk/moon/src/runtime.h 2007-06-07 17:09:35 UTC (rev 78868)
+++ trunk/moon/src/runtime.h 2007-06-07 17:18:46 UTC (rev 78869)
@@ -178,6 +178,7 @@
MATRIXTRANSFORM,
STORYBOARD,
DOUBLEANIMATION,
+ COLORANIMATION,
SHAPE,
ELLIPSE,
LINE,
@@ -230,6 +231,7 @@
void Init ();
Value ();
+ Value (Kind k);
Value (bool z);
Value (double d);
Value (guint64 i);
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches