From 2f7981f1cb3d1f639659523d64e6e931729f6c8f Mon Sep 17 00:00:00 2001 From: Steven Kirk Date: Tue, 16 Dec 2014 03:29:28 +0100 Subject: [PATCH] Added an animated rotation. To do this had to move Animatable to the bottom of the class hierarchy to allow Transform to inherit from it. --- Perspex.Animation/Animatable.cs | 3 +-- Perspex.Animation/Animate.cs | 1 - Perspex.Animation/Perspex.Animation.csproj | 20 ------------------- Perspex.Controls/Control.cs | 2 +- Perspex.Input/Perspex.Input.csproj | 4 ++++ .../Perspex.Interactivity.csproj | 4 ++++ Perspex.Layout/Perspex.Layout.csproj | 4 ++++ .../Perspex.SceneGraph.UnitTests.csproj | 4 ++++ Perspex.SceneGraph/Media/Transform.cs | 3 ++- Perspex.SceneGraph/Perspex.SceneGraph.csproj | 4 ++++ Perspex.SceneGraph/Visual.cs | 3 ++- TestApplication/Program.cs | 11 +++++++++- 12 files changed, 36 insertions(+), 27 deletions(-) diff --git a/Perspex.Animation/Animatable.cs b/Perspex.Animation/Animatable.cs index dc513a7ea6..26cd832020 100644 --- a/Perspex.Animation/Animatable.cs +++ b/Perspex.Animation/Animatable.cs @@ -8,9 +8,8 @@ namespace Perspex.Animation { using System.Linq; using System.Reactive.Linq; - using Perspex.Input; - public class Animatable : InputElement + public class Animatable : PerspexObject { private PropertyTransitions propertyTransitions; diff --git a/Perspex.Animation/Animate.cs b/Perspex.Animation/Animate.cs index 744e9f0843..ac08c6a2ab 100644 --- a/Perspex.Animation/Animate.cs +++ b/Perspex.Animation/Animate.cs @@ -9,7 +9,6 @@ namespace Perspex.Animation using System; using System.Linq; using System.Reactive.Linq; - using Perspex.Input; using Perspex.Threading; public static class Animate diff --git a/Perspex.Animation/Perspex.Animation.csproj b/Perspex.Animation/Perspex.Animation.csproj index 622ce4bcd5..a4f59c5059 100644 --- a/Perspex.Animation/Perspex.Animation.csproj +++ b/Perspex.Animation/Perspex.Animation.csproj @@ -39,26 +39,6 @@ {b09b78d8-9b26-48b0-9149-d64a2f120f3f} Perspex.Base - - {62024b2d-53eb-4638-b26b-85eeaa54866e} - Perspex.Input - - - {6b0ed19d-a08b-461c-a9d9-a9ee40b0c06b} - Perspex.Interactivity - - - {42472427-4774-4c81-8aff-9f27b8e31721} - Perspex.Layout - - - {eb582467-6abb-43a1-b052-e981ba910e3a} - Perspex.SceneGraph - - - {f1baa01a-f176-4c6a-b39d-5b40bb1b148f} - Perspex.Styling - diff --git a/Perspex.Controls/Control.cs b/Perspex.Controls/Control.cs index 8131e5581c..3c3f6f795e 100644 --- a/Perspex.Controls/Control.cs +++ b/Perspex.Controls/Control.cs @@ -16,7 +16,7 @@ namespace Perspex.Controls using Perspex.Styling; using Splat; - public class Control : Animatable, IStyleable, IStyleHost + public class Control : InputElement, IStyleable, IStyleHost { public static readonly PerspexProperty BackgroundProperty = PerspexProperty.Register("Background"); diff --git a/Perspex.Input/Perspex.Input.csproj b/Perspex.Input/Perspex.Input.csproj index 16b62eed54..239a4aeedf 100644 --- a/Perspex.Input/Perspex.Input.csproj +++ b/Perspex.Input/Perspex.Input.csproj @@ -35,6 +35,10 @@ + + {d211e587-d8bc-45b9-95a4-f297c8fa5200} + Perspex.Animation + {B09B78D8-9B26-48B0-9149-D64A2F120F3F} Perspex.Base diff --git a/Perspex.Interactivity/Perspex.Interactivity.csproj b/Perspex.Interactivity/Perspex.Interactivity.csproj index 6f30c8ed23..b8faffa4c6 100644 --- a/Perspex.Interactivity/Perspex.Interactivity.csproj +++ b/Perspex.Interactivity/Perspex.Interactivity.csproj @@ -35,6 +35,10 @@ + + {d211e587-d8bc-45b9-95a4-f297c8fa5200} + Perspex.Animation + {B09B78D8-9B26-48B0-9149-D64A2F120F3F} Perspex.Base diff --git a/Perspex.Layout/Perspex.Layout.csproj b/Perspex.Layout/Perspex.Layout.csproj index d771d3da3a..879599971c 100644 --- a/Perspex.Layout/Perspex.Layout.csproj +++ b/Perspex.Layout/Perspex.Layout.csproj @@ -39,6 +39,10 @@ {415e048e-4611-4815-9cf2-d774e29079ac} NGenerics + + {d211e587-d8bc-45b9-95a4-f297c8fa5200} + Perspex.Animation + {B09B78D8-9B26-48B0-9149-D64A2F120F3F} Perspex.Base diff --git a/Perspex.SceneGraph.UnitTests/Perspex.SceneGraph.UnitTests.csproj b/Perspex.SceneGraph.UnitTests/Perspex.SceneGraph.UnitTests.csproj index faec5d7788..41b7df7496 100644 --- a/Perspex.SceneGraph.UnitTests/Perspex.SceneGraph.UnitTests.csproj +++ b/Perspex.SceneGraph.UnitTests/Perspex.SceneGraph.UnitTests.csproj @@ -60,6 +60,10 @@ + + {d211e587-d8bc-45b9-95a4-f297c8fa5200} + Perspex.Animation + {b09b78d8-9b26-48b0-9149-d64a2f120f3f} Perspex.Base diff --git a/Perspex.SceneGraph/Media/Transform.cs b/Perspex.SceneGraph/Media/Transform.cs index 0f8ba46c5c..fa8fc6abe6 100644 --- a/Perspex.SceneGraph/Media/Transform.cs +++ b/Perspex.SceneGraph/Media/Transform.cs @@ -7,8 +7,9 @@ namespace Perspex.Media { using System; + using Perspex.Animation; - public abstract class Transform : PerspexObject, ITransform + public abstract class Transform : Animatable, ITransform { public event EventHandler Changed; diff --git a/Perspex.SceneGraph/Perspex.SceneGraph.csproj b/Perspex.SceneGraph/Perspex.SceneGraph.csproj index 40b9cd6492..81cba21aaa 100644 --- a/Perspex.SceneGraph/Perspex.SceneGraph.csproj +++ b/Perspex.SceneGraph/Perspex.SceneGraph.csproj @@ -35,6 +35,10 @@ + + {d211e587-d8bc-45b9-95a4-f297c8fa5200} + Perspex.Animation + {B09B78D8-9B26-48B0-9149-D64A2F120F3F} Perspex.Base diff --git a/Perspex.SceneGraph/Visual.cs b/Perspex.SceneGraph/Visual.cs index d4a0d67228..3edb0d72f1 100644 --- a/Perspex.SceneGraph/Visual.cs +++ b/Perspex.SceneGraph/Visual.cs @@ -11,11 +11,12 @@ namespace Perspex using System.Collections.Specialized; using System.Linq; using System.Reactive.Linq; + using Perspex.Animation; using Perspex.Media; using Perspex.Rendering; using Splat; - public class Visual : PerspexObject, IVisual + public class Visual : Animatable, IVisual { public static readonly PerspexProperty ClipToBoundsProperty = PerspexProperty.Register("ClipToBounds"); diff --git a/TestApplication/Program.cs b/TestApplication/Program.cs index e8bc66a733..436aa0bdfa 100644 --- a/TestApplication/Program.cs +++ b/TestApplication/Program.cs @@ -466,6 +466,7 @@ namespace TestApplication { Rectangle rect1; Rectangle rect2; + RotateTransform rotate; Button button1; var result = new TabItem @@ -501,7 +502,13 @@ namespace TestApplication HorizontalAlignment = HorizontalAlignment.Center, VerticalAlignment = VerticalAlignment.Center, Fill = Brushes.Coral, - RenderTransform = new RotateTransform(), + RenderTransform = (rotate = new RotateTransform + { + PropertyTransitions = new PropertyTransitions + { + RotateTransform.AngleProperty.Transition(500), + } + }), PropertyTransitions = new PropertyTransitions { Rectangle.WidthProperty.Transition(300), @@ -525,10 +532,12 @@ namespace TestApplication if (rect2.Width == 100) { rect2.Width = rect2.Height = 400; + rotate.Angle = 180; } else { rect2.Width = rect2.Height = 100; + rotate.Angle = 0; } };