[NUI] RiveAnimationView: refines the function and parameters name
[platform/core/csapi/tizenfx.git] / test / Tizen.NUI.Samples / Tizen.NUI.Samples / Samples / RiveAnimationTest.cs
1 using Tizen.NUI.BaseComponents;
2 using Tizen.NUI.Components;
3
4 namespace Tizen.NUI.Samples
5 {
6     public class RiveAnimationTest : IExample
7     {
8         private Window window;
9         private Layer defaultLayer;
10
11         RiveAnimationView rav;
12         Button playButton, stopButton;
13         Button bounceButton, brokeButton;
14         Button fillButton, strokeButton, opacityButton;
15         Button scaleButton, rotationButton, positionButton;
16         public void Activate()
17         {
18             window = NUIApplication.GetDefaultWindow();
19             defaultLayer = window.GetDefaultLayer();
20
21             rav = new RiveAnimationView(Tizen.Applications.Application.Current.DirectoryInfo.Resource + "buggy.riv")
22             {
23                 Size = new Size(500, 500),
24                 ParentOrigin = ParentOrigin.Center,
25                 PivotPoint = PivotPoint.Center,
26                 PositionUsesPivotPoint = true,
27             };
28
29             rav.EnableAnimation("idle", true);
30
31             playButton = new Button()
32             {
33                 Size = new Size(200, 100),
34                 Position = new Position(0, 0),
35                 Text = "Play"
36             };
37             playButton.Clicked += (object source, ClickedEventArgs args) =>
38             {
39                 rav.Play();
40             };
41
42             stopButton = new Button()
43             {
44                 Size = new Size(200, 100),
45                 Position = new Position(200, 0),
46                 Text = "Stop"
47             };
48             stopButton.Clicked += (object source, ClickedEventArgs args) =>
49             {
50                 rav.Stop();
51             };
52
53             bounceButton = new Button()
54             {
55                 Size = new Size(200, 100),
56                 Position = new Position(0, 100),
57                 Text = "Bounce"
58             };
59             bounceButton.Clicked += (object source, ClickedEventArgs args) =>
60             {
61                 rav.EnableAnimation("bouncing", true);
62             };
63
64             brokeButton = new Button()
65             {
66                 Size = new Size(200, 100),
67                 Position = new Position(200, 100),
68                 Text = "Broken"
69             };
70             brokeButton.Clicked += (object source, ClickedEventArgs args) =>
71             {
72                 rav.EnableAnimation("broken", true);
73             };
74
75             fillButton = new Button()
76             {
77                 Size = new Size(200, 100),
78                 Position = new Position(0, 200),
79                 Text = "Fill"
80             };
81             fillButton.Clicked += (object source, ClickedEventArgs args) =>
82             {
83                 rav.SetShapeFillColor("grillFillColor", new Color(1.0f, 0.0f, 0.0f, 1.0f));
84             };
85
86             strokeButton = new Button()
87             {
88                 Size = new Size(200, 100),
89                 Position = new Position(200, 200),
90                 Text = "Stroke"
91             };
92             strokeButton.Clicked += (object source, ClickedEventArgs args) =>
93             {
94                 rav.SetShapeStrokeColor("grillStrokeColor", new Color(0.0f, 255.0f, 0.0f, 255.0f));
95             };
96
97             opacityButton = new Button()
98             {
99                 Size = new Size(200, 100),
100                 Position = new Position(400, 200),
101                 Text = "Opacity"
102             };
103             opacityButton.Clicked += (object source, ClickedEventArgs args) =>
104             {
105                 rav.SetNodeOpacity("front_light", 0.3f);
106             };
107
108             scaleButton = new Button()
109             {
110                 Size = new Size(200, 100),
111                 Position = new Position(0, 300),
112                 Text = "Scale"
113             };
114             scaleButton.Clicked += (object source, ClickedEventArgs args) =>
115             {
116                 rav.SetNodeScale("front_light", new Vector2(2.0f, 2.0f));
117             };
118
119             rotationButton = new Button()
120             {
121                 Size = new Size(200, 100),
122                 Position = new Position(200, 300),
123                 Text = "Rotation"
124             };
125             rotationButton.Clicked += (object source, ClickedEventArgs args) =>
126             {
127                 rav.SetNodeRotation("front_light", new Degree(45.0f));
128             };
129
130             positionButton = new Button()
131             {
132                 Size = new Size(200, 100),
133                 Position = new Position(400, 300),
134                 Text = "Position"
135             };
136             positionButton.Clicked += (object source, ClickedEventArgs args) =>
137             {
138                 rav.SetNodePosition("front_light", new Position(100.0f, -50.0f));
139             };
140
141             defaultLayer.Add(rav);
142             defaultLayer.Add(playButton);
143             defaultLayer.Add(stopButton);
144             defaultLayer.Add(bounceButton);
145             defaultLayer.Add(brokeButton);
146             defaultLayer.Add(fillButton);
147             defaultLayer.Add(strokeButton);
148             defaultLayer.Add(opacityButton);
149             defaultLayer.Add(scaleButton);
150             defaultLayer.Add(rotationButton);
151             defaultLayer.Add(positionButton);
152         }
153         public void Deactivate()
154         {
155             defaultLayer.Remove(rav);
156             defaultLayer.Remove(playButton);
157             defaultLayer.Remove(stopButton);
158             defaultLayer.Remove(bounceButton);
159             defaultLayer.Remove(brokeButton);
160             defaultLayer.Remove(fillButton);
161             defaultLayer.Remove(strokeButton);
162             defaultLayer.Remove(opacityButton);
163             defaultLayer.Remove(scaleButton);
164             defaultLayer.Remove(rotationButton);
165             defaultLayer.Remove(positionButton);
166         }
167     }
168 }