2 * Copyright (c) 2014 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.
18 #include <dali/public-api/common/dali-common.h>
19 #include <dali/public-api/math/vector2.h>
20 #include <dali/public-api/math/vector3.h>
21 #include <dali/public-api/math/vector4.h>
22 #include <dali/public-api/object/property-input.h>
23 #include <dali/internal/update/common/property-condition-functions.h>
34 // LessThan ///////////////////////////////////////////////////////////////////
36 ConditionFunction LessThan::GetFunction(Property::Type valueType)
38 ConditionFunction function = NULL;
42 case Property::BOOLEAN:
44 function = LessThan::EvalBoolean;
49 function = LessThan::EvalFloat;
52 case Property::INTEGER:
54 function = LessThan::EvalInteger;
57 case Property::VECTOR2:
59 function = LessThan::EvalVector2;
62 case Property::VECTOR3:
64 function = LessThan::EvalVector3;
67 case Property::VECTOR4:
69 function = LessThan::EvalVector4;
74 function = LessThan::EvalDefault;
82 bool LessThan::EvalBoolean( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg )
84 const float arg0 = arg[0];
85 return (value.GetBoolean() < arg0);
88 bool LessThan::EvalFloat( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg )
90 const float arg0 = arg[0];
91 return (value.GetFloat() < arg0);
94 bool LessThan::EvalInteger( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg )
96 const int arg0 = arg[0];
97 return (value.GetInteger() < arg0);
100 bool LessThan::EvalVector2( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg )
102 const float arg0 = arg[0];
103 return (value.GetVector2().LengthSquared() < arg0 * arg0);
106 bool LessThan::EvalVector3( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg )
108 const float arg0 = arg[0];
109 return (value.GetVector3().LengthSquared() < arg0 * arg0);
112 bool LessThan::EvalVector4( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg )
114 const float arg0 = arg[0];
115 return (value.GetVector4().LengthSquared() < arg0 * arg0);
118 bool LessThan::EvalDefault( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg )
123 // GreaterThan ///////////////////////////////////////////////////////////////////
125 ConditionFunction GreaterThan::GetFunction(Property::Type valueType)
127 ConditionFunction function = NULL;
131 case Property::BOOLEAN:
133 function = GreaterThan::EvalBoolean;
136 case Property::FLOAT:
138 function = GreaterThan::EvalFloat;
141 case Property::INTEGER:
143 function = GreaterThan::EvalInteger;
146 case Property::VECTOR2:
148 function = GreaterThan::EvalVector2;
151 case Property::VECTOR3:
153 function = GreaterThan::EvalVector3;
156 case Property::VECTOR4:
158 function = GreaterThan::EvalVector4;
163 function = GreaterThan::EvalDefault;
171 bool GreaterThan::EvalBoolean( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg )
173 const float arg0 = arg[0];
174 return (value.GetBoolean() > arg0);
177 bool GreaterThan::EvalFloat( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg )
179 const float arg0 = arg[0];
180 return (value.GetFloat() > arg0);
183 bool GreaterThan::EvalInteger( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg )
185 const int arg0 = arg[0];
186 return (value.GetInteger() > arg0);
189 bool GreaterThan::EvalVector2( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg )
191 const float arg0 = arg[0];
192 return (value.GetVector2().LengthSquared() > arg0 * arg0);
195 bool GreaterThan::EvalVector3( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg )
197 const float arg0 = arg[0];
198 return (value.GetVector3().LengthSquared() > arg0 * arg0);
201 bool GreaterThan::EvalVector4( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg )
203 const float arg0 = arg[0];
204 return (value.GetVector4().LengthSquared() > arg0 * arg0);
207 bool GreaterThan::EvalDefault( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg )
212 // Inside /////////////////////////////////////////////////////////////////////
214 ConditionFunction Inside::GetFunction(Property::Type valueType)
216 ConditionFunction function = NULL;
220 case Property::BOOLEAN:
222 function = Inside::EvalBoolean;
225 case Property::FLOAT:
227 function = Inside::EvalFloat;
230 case Property::INTEGER:
232 function = Inside::EvalInteger;
235 case Property::VECTOR2:
237 function = Inside::EvalVector2;
240 case Property::VECTOR3:
242 function = Inside::EvalVector3;
245 case Property::VECTOR4:
247 function = Inside::EvalVector4;
252 function = Inside::EvalDefault;
260 bool Inside::EvalBoolean( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg )
262 const bool valueBoolean = value.GetBoolean();
263 return ( (valueBoolean > arg[0]) && (valueBoolean < arg[1]) );
266 bool Inside::EvalFloat( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg )
268 const float valueFloat = value.GetFloat();
269 return ( (valueFloat > arg[0]) && (valueFloat < arg[1]) );
272 bool Inside::EvalInteger( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg )
274 const int valueInteger = value.GetInteger();
275 return ( (valueInteger > arg[0]) && (valueInteger < arg[1]) );
278 bool Inside::EvalVector2( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg )
280 const float length2 = value.GetVector2().LengthSquared();
281 return ( (length2 > arg[0]*arg[0]) && (length2 < arg[1]*arg[1]) );
284 bool Inside::EvalVector3( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg )
286 const float length2 = value.GetVector3().LengthSquared();
287 return ( (length2 > arg[0]*arg[0]) && (length2 < arg[1]*arg[1]) );
290 bool Inside::EvalVector4( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg )
292 const float length2 = value.GetVector4().LengthSquared();
293 return ( (length2 > arg[0]*arg[0]) && (length2 < arg[1]*arg[1]) );
296 bool Inside::EvalDefault( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg )
301 // Outside ////////////////////////////////////////////////////////////////////
303 ConditionFunction Outside::GetFunction(Property::Type valueType)
305 ConditionFunction function = NULL;
309 case Property::BOOLEAN:
311 function = Outside::EvalBoolean;
314 case Property::FLOAT:
316 function = Outside::EvalFloat;
319 case Property::INTEGER:
321 function = Outside::EvalInteger;
324 case Property::VECTOR2:
326 function = Outside::EvalVector2;
329 case Property::VECTOR3:
331 function = Outside::EvalVector3;
334 case Property::VECTOR4:
336 function = Outside::EvalVector4;
341 function = Outside::EvalDefault;
349 bool Outside::EvalBoolean( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg )
351 const bool valueBoolean = value.GetBoolean();
352 return ( (valueBoolean < arg[0]) || (valueBoolean > arg[1]) );
355 bool Outside::EvalFloat( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg )
357 const float valueFloat = value.GetFloat();
358 return ( (valueFloat < arg[0]) || (valueFloat > arg[1]) );
361 bool Outside::EvalInteger( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg )
363 const int valueInterger = value.GetInteger();
364 return ( (valueInterger < arg[0]) || (valueInterger > arg[1]) );
367 bool Outside::EvalVector2( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg )
369 const float length2 = value.GetVector2().LengthSquared();
370 return ( (length2 < arg[0]*arg[0]) || (length2 > arg[1]*arg[1]) );
373 bool Outside::EvalVector3( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg )
375 const float length2 = value.GetVector3().LengthSquared();
376 return ( (length2 < arg[0]*arg[0]) || (length2 > arg[1]*arg[1]) );
379 bool Outside::EvalVector4( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg )
381 const float length2 = value.GetVector4().LengthSquared();
382 return ( (length2 < arg[0]*arg[0]) || (length2 > arg[1]*arg[1]) );
385 bool Outside::EvalDefault( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg )
390 } // namespace SceneGraph
392 } // namespace Internal