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