2 * Copyright (c) 2016 Samsung Electronics Co., Ltd.
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 #include <dali/dali.h>
18 #include <test-animation-data.h>
25 TestAnimationData::TestAnimationData()
29 TestAnimationData::~TestAnimationData()
33 TestAnimationData::AnimationDataElement::AnimationDataElement()
34 : alphaFunction( AlphaFunction::DEFAULT ),
35 timePeriodDelay( 0.0f ),
36 timePeriodDuration( 1.0f )
40 void TestAnimationData::Add( AnimationDataElement* animationDataElement )
42 mAnimationDataList.PushBack( animationDataElement );
45 std::size_t TestAnimationData::Size() const
47 return mAnimationDataList.Size();
50 void TestAnimationData::Clear()
52 AnimationDataList::Iterator end = mAnimationDataList.End();
53 for( AnimationDataList::Iterator iter = mAnimationDataList.Begin(); iter != end; ++iter )
57 mAnimationDataList.Clear();
61 void NewAnimator( const Property::Map& map, TestAnimationData::AnimationDataElement& element )
63 // Now set the properties, or create children
64 for( unsigned int i = 0, animationMapCount = map.Count(); i < animationMapCount; ++i )
66 const StringValuePair& pair( map.GetPair( i ) );
67 const std::string& key( pair.first );
68 const Property::Value& value( pair.second );
70 if( key == "actor" || key == "target" )
72 element.target = value.Get< std::string >();
74 else if( key == "property" )
76 element.property = value.Get< std::string >();
78 else if( key == "value" )
80 element.value = value;
82 else if( key == "alphaFunction" )
84 std::string alphaFunctionValue = value.Get< std::string >();
86 if( alphaFunctionValue == "LINEAR" )
88 element.alphaFunction = AlphaFunction::LINEAR;
90 else if( alphaFunctionValue == "REVERSE" )
92 element.alphaFunction = AlphaFunction::REVERSE;
94 else if( alphaFunctionValue == "EASE_IN_SQUARE" )
96 element.alphaFunction = AlphaFunction::EASE_IN_SQUARE;
98 else if( alphaFunctionValue == "EASE_OUT_SQUARE" )
100 element.alphaFunction = AlphaFunction::EASE_OUT_SQUARE;
102 else if( alphaFunctionValue == "EASE_IN" )
104 element.alphaFunction = AlphaFunction::EASE_IN;
106 else if( alphaFunctionValue == "EASE_OUT" )
108 element.alphaFunction = AlphaFunction::EASE_OUT;
110 else if( alphaFunctionValue == "EASE_IN_OUT" )
112 element.alphaFunction = AlphaFunction::EASE_IN_OUT;
114 else if( alphaFunctionValue == "EASE_IN_SINE" )
116 element.alphaFunction = AlphaFunction::EASE_IN_SINE;
118 else if( alphaFunctionValue == "EASE_OUT_SINE" )
120 element.alphaFunction = AlphaFunction::EASE_OUT_SINE;
122 else if( alphaFunctionValue == "EASE_IN_OUT_SINE" )
124 element.alphaFunction = AlphaFunction::EASE_IN_OUT_SINE;
126 else if( alphaFunctionValue == "BOUNCE" )
128 element.alphaFunction = AlphaFunction::BOUNCE;
130 else if( alphaFunctionValue == "SIN" )
132 element.alphaFunction = AlphaFunction::SIN;
134 else if( alphaFunctionValue == "EASE_OUT_BACK" )
136 element.alphaFunction = AlphaFunction::EASE_OUT_BACK;
139 else if( key == "timePeriod" )
141 Property::Map timeMap = value.Get< Property::Map >();
142 for( unsigned int i = 0; i < timeMap.Count(); ++i )
144 const StringValuePair& pair( timeMap.GetPair( i ) );
145 if( pair.first == "delay" )
147 element.timePeriodDelay = pair.second.Get< float >();
149 else if( pair.first == "duration" )
151 element.timePeriodDuration = pair.second.Get< float >();
155 else if( key == "animator" )
157 if( value.GetType() == Property::MAP )
159 const Property::Map* map = value.GetMap();
160 const Property::Map& mapref = *map;
161 NewAnimator( mapref, element ); // Merge the map into element
167 void NewAnimation( const Property::Map& map, TestAnimationData& outputAnimationData )
169 TestAnimationData::AnimationDataElement* element = new TestAnimationData::AnimationDataElement();
170 NewAnimator( map, *element );
172 outputAnimationData.Add( element );
175 void NewAnimation( const Property::Array& array, TestAnimationData& outputAnimationData )
177 for(unsigned int i=0; i<array.Size(); ++i )
179 TestAnimationData::AnimationDataElement* element = new TestAnimationData::AnimationDataElement();
180 const Property::Value& value = array.GetElementAt(i);
181 if( value.GetType() == Property::MAP )
183 const Property::Map* map = value.GetMap();
184 NewAnimator( *map, *element );
185 outputAnimationData.Add( element );