Author: toshok
Date: 2007-06-13 16:15:34 -0400 (Wed, 13 Jun 2007)
New Revision: 79499
Modified:
trunk/moon/src/ChangeLog
trunk/moon/src/animation.cpp
trunk/moon/src/animation.h
trunk/moon/src/runtime.cpp
trunk/moon/src/type.cpp
trunk/moon/src/type.cpp.in
trunk/moon/src/value.cpp
trunk/moon/src/value.h
trunk/moon/src/value.h.in
Log:
* animation.cpp, animation.h: add public storyboard methods for
begin/pause/resume/seek/stop. also start in on the spline
keyframe/KeySpline stuff.
* type.cpp: resync.
* value.cpp: resync.
* value.h: resync.
* value.h.in: add keyspline stuff.
* type.cpp.in: add keyspline stuff.
2007-06-13 Chris Toshok <[EMAIL PROTECTED]>
Modified: trunk/moon/src/ChangeLog
===================================================================
--- trunk/moon/src/ChangeLog 2007-06-13 20:11:45 UTC (rev 79498)
+++ trunk/moon/src/ChangeLog 2007-06-13 20:15:34 UTC (rev 79499)
@@ -25,6 +25,22 @@
2007-06-13 Chris Toshok <[EMAIL PROTECTED]>
+ * animation.cpp, animation.h: add public storyboard methods for
+ begin/pause/resume/seek/stop. also start in on the spline
+ keyframe/KeySpline stuff.
+
+ * type.cpp: resync.
+
+ * value.cpp: resync.
+
+ * value.h: resync.
+
+ * value.h.in: add keyspline stuff.
+
+ * type.cpp.in: add keyspline stuff.
+
+2007-06-13 Chris Toshok <[EMAIL PROTECTED]>
+
* demo.cpp: a few changes - none of the animations run forever
now. also, add some gtk events (button press/release/motion). we
pause animations on press, resume them on release.
Modified: trunk/moon/src/animation.cpp
===================================================================
--- trunk/moon/src/animation.cpp 2007-06-13 20:11:45 UTC (rev 79498)
+++ trunk/moon/src/animation.cpp 2007-06-13 20:15:34 UTC (rev 79499)
@@ -4,6 +4,7 @@
#include <malloc.h>
#include <glib.h>
#include <stdlib.h>
+#include <math.h>
#include "animation.h"
@@ -178,6 +179,37 @@
}
void
+storyboard_begin (Storyboard *sb)
+{
+ sb->Begin ();
+}
+
+void
+storyboard_pause (Storyboard *sb)
+{
+ sb->Pause ();
+}
+
+void
+storyboard_resume (Storyboard *sb)
+{
+ sb->Resume ();
+}
+
+void
+storyboard_seek (Storyboard *sb, TimeSpan ts)
+{
+ sb->Seek (ts);
+}
+
+void
+storyboard_stop (Storyboard *sb)
+{
+ sb->Stop ();
+}
+
+
+void
Storyboard::SetTargetProperty (DependencyObject *o,
char *targetProperty)
{
@@ -404,6 +436,64 @@
+
+KeySpline::KeySpline (Point controlPoint1, Point controlPoint2)
+ : controlPoint1 (controlPoint1),
+ controlPoint2 (controlPoint2)
+{
+}
+
+KeySpline::KeySpline (double x1, double y1,
+ double x2, double y2)
+ : controlPoint1 (Point (x1, y1)),
+ controlPoint2 (Point (x2, y2))
+{
+}
+
+Point
+KeySpline::GetControlPoint1 ()
+{
+ return controlPoint1;
+}
+void
+KeySpline::SetControlPoint1 (Point controlPoint1)
+{
+ this->controlPoint1 = controlPoint1;
+}
+
+Point
+KeySpline::GetControlPoint2 ()
+{
+ return controlPoint2;
+}
+void
+KeySpline::SetControlPoint2 (Point controlPoint2)
+{
+ this->controlPoint2 = controlPoint2;
+}
+
+double
+KeySpline::GetSplineProgress (double linearProgress)
+{
+ /* perform the actual cubic bezier interpolation here */
+
+ double t = linearProgress;
+ double t2 = t*t;
+ double t3 = t2*t;
+ double omt = 1.0-t;
+ double omt2 = omt*omt;
+ double omt3 = omt2*omt;
+
+ double xb = 0 * omt3 + 3 * controlPoint1.x * t * omt2 + 3 *
controlPoint2.x * t2 * omt + 1 * t3;
+ double yb = 0 * omt3 + 3 * controlPoint1.y * t * omt2 + 3 *
controlPoint2.y * t2 * omt + 1 * t3;
+
+ return sqrt (xb*xb + yb*yb);
+}
+
+
+
+
+
DependencyProperty* KeyFrame::KeyTimeProperty;
KeyFrame::KeyFrame ()
@@ -649,7 +739,14 @@
+Value*
+SplineDoubleKeyFrame::InterpolateValue (Value *baseValue, double
keyFrameProgress)
+{
+ return NULL;
+}
+
+
DependencyProperty* DoubleAnimationUsingKeyFrames::KeyFramesProperty;
DoubleAnimationUsingKeyFrames::DoubleAnimationUsingKeyFrames()
@@ -868,7 +965,10 @@
if (!current_keyframe)
printf ("time of %lld resulted in no keyframes\n");
- return current_keyframe->InterpolateValue (baseValue, progress);
+ Value *v = current_keyframe->InterpolateValue (baseValue, progress);
+ Color *c = v->AsColor();
+ printf ("-> (%f, %f, %f, %f)\n", c->r, c->g, c->b, c->a);
+ return v;
}
Duration
Modified: trunk/moon/src/animation.h
===================================================================
--- trunk/moon/src/animation.h 2007-06-13 20:11:45 UTC (rev 79498)
+++ trunk/moon/src/animation.h 2007-06-13 20:15:34 UTC (rev 79499)
@@ -7,6 +7,24 @@
G_BEGIN_DECLS
// misc types
+class KeySpline {
+ public:
+ KeySpline (Point controlPoint1, Point controlPoint2);
+ KeySpline (double x1, double y1, double x2, double y2);
+
+ double GetSplineProgress (double linearProgress);
+
+ Point GetControlPoint1 ();
+ void SetControlPoint1 (Point controlPoint1);
+
+ Point GetControlPoint2 ();
+ void SetControlPoint2 (Point controlPoint2);
+
+ private:
+ Point controlPoint1;
+ Point controlPoint2;
+};
+
struct KeyTime {
public:
enum KeyTimeType {
@@ -363,7 +381,16 @@
LinearPointKeyFrame* linear_point_key_frame_new ();
+class SplineDoubleKeyFrame : public DoubleKeyFrame {
+ public:
+ SplineDoubleKeyFrame () { }
+ Value::Kind GetObjectType () { return Value::SPLINEDOUBLEKEYFRAME; };
+ virtual Value *InterpolateValue (Value *baseValue, double
keyFrameProgress);
+};
+
+SplineDoubleKeyFrame* spline_double_key_frame_new ();
+
class DoubleAnimationUsingKeyFrames : public DoubleAnimation {
public:
DoubleAnimationUsingKeyFrames ();
@@ -461,11 +488,15 @@
};
Storyboard *storyboard_new ();
+void storyboard_begin (Storyboard *sb);
+void storyboard_pause (Storyboard *sb);
+void storyboard_resume (Storyboard *sb);
+void storyboard_seek (Storyboard *sb, TimeSpan ts);
+void storyboard_stop (Storyboard *sb);
-
class BeginStoryboard : public TriggerAction {
public:
Modified: trunk/moon/src/runtime.cpp
===================================================================
--- trunk/moon/src/runtime.cpp 2007-06-13 20:11:45 UTC (rev 79498)
+++ trunk/moon/src/runtime.cpp 2007-06-13 20:15:34 UTC (rev 79499)
@@ -406,6 +406,7 @@
RepeatBehavior* Value::AsRepeatBehavior () { checked_get_exact
(REPEATBEHAVIOR, NULL, u.repeat); }
Duration* Value::AsDuration () { checked_get_exact (DURATION, NULL,
u.duration); }
KeyTime* Value::AsKeyTime () { checked_get_exact (KEYTIME, NULL,
u.keytime); }
+KeySpline* Value::AsKeySpline () { checked_get_exact (KEYSPLINE, NULL,
u.keyspline); }
Matrix* Value::AsMatrix () { checked_get_exact (MATRIX, NULL,
u.matrix); }
/* nullable primitives (all but bool) */
Modified: trunk/moon/src/type.cpp
===================================================================
--- trunk/moon/src/type.cpp 2007-06-13 20:11:45 UTC (rev 79498)
+++ trunk/moon/src/type.cpp 2007-06-13 20:15:34 UTC (rev 79499)
@@ -40,6 +40,7 @@
Type::RegisterType ("Duration", Value::DURATION);
Type::RegisterType ("int64", Value::INT64);
Type::RegisterType ("KeyTime", Value::KEYTIME);
+ Type::RegisterType ("KeySpline", Value::KEYSPLINE);
Type::RegisterType ("double*", Value::DOUBLE_ARRAY);
Type::RegisterType ("Point*", Value::POINT_ARRAY);
Type::RegisterType ("Matrix", Value::MATRIX);
@@ -142,6 +143,7 @@
Type::RegisterType ("Shape", Value::SHAPE, Value::FRAMEWORKELEMENT);
Type::RegisterType ("SkewTransform", Value::SKEWTRANSFORM,
Value::TRANSFORM);
Type::RegisterType ("SolidColorBrush", Value::SOLIDCOLORBRUSH,
Value::BRUSH);
+ Type::RegisterType ("SplineDoubleKeyFrame",
Value::SPLINEDOUBLEKEYFRAME, Value::DOUBLEKEYFRAME);
Type::RegisterType ("Storyboard", Value::STORYBOARD,
Value::PARALLELTIMELINE);
Type::RegisterType ("StrokeCollection", Value::STROKE_COLLECTION,
Value::COLLECTION);
Type::RegisterType ("StylusPointCollection",
Value::STYLUSPOINT_COLLECTION, Value::COLLECTION);
Modified: trunk/moon/src/type.cpp.in
===================================================================
--- trunk/moon/src/type.cpp.in 2007-06-13 20:11:45 UTC (rev 79498)
+++ trunk/moon/src/type.cpp.in 2007-06-13 20:15:34 UTC (rev 79499)
@@ -35,6 +35,7 @@
Type::RegisterType ("Duration", Value::DURATION);
Type::RegisterType ("int64", Value::INT64);
Type::RegisterType ("KeyTime", Value::KEYTIME);
+ Type::RegisterType ("KeySpline", Value::KEYSPLINE);
Type::RegisterType ("double*", Value::DOUBLE_ARRAY);
Type::RegisterType ("Point*", Value::POINT_ARRAY);
Type::RegisterType ("Matrix", Value::MATRIX);
Modified: trunk/moon/src/value.cpp
===================================================================
--- trunk/moon/src/value.cpp 2007-06-13 20:11:45 UTC (rev 79498)
+++ trunk/moon/src/value.cpp 2007-06-13 20:15:34 UTC (rev 79499)
@@ -482,6 +482,12 @@
checked_get_subclass (SOLIDCOLORBRUSH, SolidColorBrush);
}
+SplineDoubleKeyFrame*
+Value::AsSplineDoubleKeyFrame ()
+{
+ checked_get_subclass (SPLINEDOUBLEKEYFRAME, SplineDoubleKeyFrame);
+}
+
Storyboard*
Value::AsStoryboard ()
{
Modified: trunk/moon/src/value.h
===================================================================
--- trunk/moon/src/value.h 2007-06-13 20:11:45 UTC (rev 79498)
+++ trunk/moon/src/value.h 2007-06-13 20:15:34 UTC (rev 79499)
@@ -13,6 +13,7 @@
struct DoubleArray;
struct Duration;
struct KeyTime;
+class KeySpline;
struct Point;
struct PointArray;
struct Rect;
@@ -101,6 +102,7 @@
class Shape;
class SkewTransform;
class SolidColorBrush;
+class SplineDoubleKeyFrame;
class Storyboard;
class StrokeCollection;
class StylusPointCollection;
@@ -145,6 +147,7 @@
DOUBLE_ARRAY,
POINT_ARRAY,
KEYTIME,
+ KEYSPLINE,
MATRIX,
DEPENDENCY_OBJECT,
@@ -223,6 +226,7 @@
SHAPE,
SKEWTRANSFORM,
SOLIDCOLORBRUSH,
+ SPLINEDOUBLEKEYFRAME,
STORYBOARD,
STROKE_COLLECTION,
STYLUSPOINT_COLLECTION,
@@ -266,6 +270,7 @@
Value (RepeatBehavior repeat);
Value (Duration duration);
Value (KeyTime keytime);
+ Value (KeySpline* keyspline);
Value (const char* s);
Value (Point *points, int count);
Value (double *values, int count);
@@ -311,6 +316,7 @@
RepeatBehavior* AsRepeatBehavior ();
Duration* AsDuration ();
KeyTime* AsKeyTime ();
+ KeySpline* AsKeySpline ();
PointArray* AsPointArray ();
DoubleArray* AsDoubleArray ();
Matrix* AsMatrix ();
@@ -391,6 +397,7 @@
Shape* AsShape ();
SkewTransform* AsSkewTransform ();
SolidColorBrush* AsSolidColorBrush ();
+ SplineDoubleKeyFrame* AsSplineDoubleKeyFrame ();
Storyboard* AsStoryboard ();
StrokeCollection* AsStrokeCollection ();
StylusPointCollection* AsStylusPointCollection ();
@@ -428,6 +435,7 @@
RepeatBehavior *repeat;
Duration *duration;
KeyTime *keytime;
+ KeySpline *keyspline;
PointArray *point_array;
DoubleArray *double_array;
Matrix* matrix;
Modified: trunk/moon/src/value.h.in
===================================================================
--- trunk/moon/src/value.h.in 2007-06-13 20:11:45 UTC (rev 79498)
+++ trunk/moon/src/value.h.in 2007-06-13 20:15:34 UTC (rev 79499)
@@ -9,6 +9,7 @@
struct DoubleArray;
struct Duration;
struct KeyTime;
+class KeySpline;
struct Point;
struct PointArray;
struct Rect;
@@ -45,6 +46,7 @@
DOUBLE_ARRAY,
POINT_ARRAY,
KEYTIME,
+ KEYSPLINE,
MATRIX,
/*DO_KINDS*/
@@ -70,6 +72,7 @@
Value (RepeatBehavior repeat);
Value (Duration duration);
Value (KeyTime keytime);
+ Value (KeySpline* keyspline);
Value (const char* s);
Value (Point *points, int count);
Value (double *values, int count);
@@ -115,6 +118,7 @@
RepeatBehavior* AsRepeatBehavior ();
Duration* AsDuration ();
KeyTime* AsKeyTime ();
+ KeySpline* AsKeySpline ();
PointArray* AsPointArray ();
DoubleArray* AsDoubleArray ();
Matrix* AsMatrix ();
@@ -136,6 +140,7 @@
RepeatBehavior *repeat;
Duration *duration;
KeyTime *keytime;
+ KeySpline *keyspline;
PointArray *point_array;
DoubleArray *double_array;
Matrix* matrix;
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches