99e7834a20f0861531fda10bf753b0cb7367a026
[platform/core/csapi/tizenfx.git] / src / Tizen.NUI / src / public / Visuals / VisualAnimator.cs
1 /*
2  * Copyright(c) 2019 Samsung Electronics Co., Ltd.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  */
17 using System.Text;
18
19 namespace Tizen.NUI
20 {
21     //temporary fix for TCT
22     /// <summary>
23     /// A class encapsulating the property map of the transition data.
24     /// </summary>
25     /// <since_tizen> 3 </since_tizen>
26     public class VisualAnimator : VisualMap
27     {
28         private string _alphaFunction = null;
29         private int _startTime = 0;
30         private int _endTime = 0;
31         private string _target = null;
32         private string _propertyIndex = null;
33         private object _destinationValue = null;
34
35         /// <summary>
36         /// Create VisualAnimator object.
37         /// </summary>
38         /// <since_tizen> 3 </since_tizen>
39         public VisualAnimator() : base()
40         {
41         }
42
43         /// <summary>
44         /// Sets and Gets the AlphaFunction of this transition.
45         /// </summary>
46         /// <since_tizen> 3 </since_tizen>
47         public AlphaFunction.BuiltinFunctions AlphaFunction
48         {
49             get
50             {
51                 return _alphaFunction.GetValueByDescription<AlphaFunction.BuiltinFunctions>();
52             }
53             set
54             {
55                 _alphaFunction = value.GetDescription();
56             }
57         }
58
59         /// <summary>
60         /// Sets and Gets the StartTime of this transition.
61         /// </summary>
62         /// <since_tizen> 3 </since_tizen>
63         public int StartTime
64         {
65             get
66             {
67                 return _startTime;
68             }
69             set
70             {
71                 _startTime = value;
72             }
73         }
74
75         /// <summary>
76         /// Sets and Gets the EndTime of this transition.
77         /// </summary>
78         /// <since_tizen> 3 </since_tizen>
79         public int EndTime
80         {
81             get
82             {
83                 return _endTime;
84             }
85             set
86             {
87                 _endTime = value;
88             }
89         }
90
91         /// <summary>
92         /// Sets and Gets the Target of this transition.
93         /// </summary>
94         /// <since_tizen> 3 </since_tizen>
95         public string Target
96         {
97             get
98             {
99                 return _target;
100             }
101             set
102             {
103                 _target = value;
104             }
105         }
106
107         /// <summary>
108         /// Sets and Gets the PropertyIndex of this transition.
109         /// </summary>
110         /// <since_tizen> 3 </since_tizen>
111         public string PropertyIndex
112         {
113             get
114             {
115                 return _propertyIndex;
116             }
117             set
118             {
119                 _propertyIndex = value;
120             }
121         }
122
123         /// <summary>
124         /// Sets and Gets the DestinationValue of this transition.
125         /// </summary>
126         /// <since_tizen> 3 </since_tizen>
127         public object DestinationValue
128         {
129             get
130             {
131                 return _destinationValue;
132             }
133             set
134             {
135                 _destinationValue = value;
136             }
137         }
138
139         /// <summary>
140         /// Compose the out visual map.
141         /// </summary>
142         /// <since_tizen> 3 </since_tizen>
143         protected override void ComposingPropertyMap()
144         {
145             PropertyMap _animator = new PropertyMap();
146             _animator.Add("alphaFunction", new PropertyValue(_alphaFunction));
147
148             PropertyMap _timePeriod = new PropertyMap();
149             _timePeriod.Add("duration", new PropertyValue((_endTime - _startTime) / 1000.0f));
150             _timePeriod.Add("delay", new PropertyValue(_startTime / 1000.0f));
151             _animator.Add("timePeriod", new PropertyValue(_timePeriod));
152
153             StringBuilder sb = new StringBuilder(_propertyIndex);
154             sb[0] = (char)(sb[0] | 0x20);
155             string _str = sb.ToString();
156
157             PropertyValue val = PropertyValue.CreateFromObject(_destinationValue);
158
159             PropertyMap _transition = new PropertyMap();
160             _transition.Add("target", new PropertyValue(_target));
161             _transition.Add("property", new PropertyValue(_str));
162             _transition.Add("targetValue", val);
163             _transition.Add("animator", new PropertyValue(_animator));
164
165             _outputVisualMap = _transition;
166             base.ComposingPropertyMap();
167         }
168     }
169     //temporary fix for TCT
170 }