Dali 3D User Interface Engine
key-frames-impl.cpp
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2014 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 
18 // CLASS HEADER
20 
21 namespace Dali
22 {
23 namespace Internal
24 {
25 
27 {
28  return new KeyFrames();
29 }
30 
32  : mType(Property::NONE),
33  mKeyFrames(NULL)
34 {
35 }
36 
38 {
39 }
40 
41 
43 {
44  mType = type;
45  // Now we have a type, can create specific implementation
46  switch(type)
47  {
48  case Property::BOOLEAN:
49  {
51  break;
52  }
53  case Property::INTEGER:
54  {
56  break;
57  }
58  case Property::FLOAT:
59  {
61  break;
62  }
63  case Property::VECTOR2:
64  {
66  break;
67  }
68  case Property::VECTOR3:
69  {
71  break;
72  }
73  case Property::VECTOR4:
74  {
76  break;
77  }
78  case Property::ROTATION:
79  {
81  break;
82  }
83  default:
84  {
85  DALI_ASSERT_DEBUG(!"Type not supported");
86  break;
87  }
88  }
89 }
90 
92 {
93  return mType;
94 }
95 
96 void KeyFrames::Add(float time, Property::Value value, AlphaFunction alpha)
97 {
98  if(mType == Property::NONE)
99  {
100  CreateKeyFramesSpec(value.GetType());
101  }
102 
103  // Once we have created a type, can only add values of the same type
104  DALI_ASSERT_ALWAYS( mType == value.GetType() && "Can only add values of the same type to a KeyFrame" );
105 
107 
108  switch(mType)
109  {
110  case Property::BOOLEAN:
111  {
113  kf->AddKeyFrame(time, value.Get<bool>(), alpha);
114  break;
115  }
116  case Property::INTEGER:
117  {
119  kf->AddKeyFrame(time, value.Get<int>(), alpha);
120  break;
121  }
122  case Property::FLOAT:
123  {
125  kf->AddKeyFrame(time, value.Get<float>(), alpha);
126  break;
127  }
128  case Property::VECTOR2:
129  {
131  kf->AddKeyFrame(time, value.Get<Vector2>(), alpha);
132  break;
133  }
134  case Property::VECTOR3:
135  {
137  kf->AddKeyFrame(time, value.Get<Vector3>(), alpha);
138  break;
139  }
140  case Property::VECTOR4:
141  {
143  kf->AddKeyFrame(time, value.Get<Vector4>(), alpha);
144  break;
145  }
146  case Property::ROTATION:
147  {
149  kf->AddKeyFrame(time, value.Get<Quaternion>(), alpha);
150  break;
151  }
152  default:
153  DALI_ASSERT_DEBUG(!"Type not supported");
154  break;
155  }
156 }
157 
159 {
160  return mKeyFrames.Get();
161 }
162 
163 } // Internal
164 } // Dali
Dali Docs Home
Read more about Dali