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;
47 case Property::INTEGER:
49 function = LessThan::EvalInteger;
52 case Property::UNSIGNED_INTEGER:
54 function = LessThan::EvalUnsignedInteger;
59 function = LessThan::EvalFloat;
62 case Property::VECTOR2:
64 function = LessThan::EvalVector2;
67 case Property::VECTOR3:
69 function = LessThan::EvalVector3;
72 case Property::VECTOR4:
74 function = LessThan::EvalVector4;
79 function = LessThan::EvalDefault;
87 bool LessThan::EvalBoolean( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg )
89 const float arg0 = arg[0];
90 return (value.GetBoolean() < arg0);
93 bool LessThan::EvalInteger( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg )
95 const int arg0 = arg[0];
96 return (value.GetInteger() < arg0);
99 bool LessThan::EvalUnsignedInteger( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg )
101 const unsigned int arg0 = arg[0];
102 return (value.GetUnsignedInteger() < arg0);
105 bool LessThan::EvalFloat( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg )
107 const float arg0 = arg[0];
108 return (value.GetFloat() < arg0);
111 bool LessThan::EvalVector2( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg )
113 const float arg0 = arg[0];
114 return (value.GetVector2().LengthSquared() < arg0 * arg0);
117 bool LessThan::EvalVector3( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg )
119 const float arg0 = arg[0];
120 return (value.GetVector3().LengthSquared() < arg0 * arg0);
123 bool LessThan::EvalVector4( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg )
125 const float arg0 = arg[0];
126 return (value.GetVector4().LengthSquared() < arg0 * arg0);
129 bool LessThan::EvalDefault( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg )
134 // GreaterThan ///////////////////////////////////////////////////////////////////
136 ConditionFunction GreaterThan::GetFunction(Property::Type valueType)
138 ConditionFunction function = NULL;
142 case Property::BOOLEAN:
144 function = GreaterThan::EvalBoolean;
147 case Property::INTEGER:
149 function = GreaterThan::EvalInteger;
152 case Property::UNSIGNED_INTEGER:
154 function = GreaterThan::EvalUnsignedInteger;
157 case Property::FLOAT:
159 function = GreaterThan::EvalFloat;
162 case Property::VECTOR2:
164 function = GreaterThan::EvalVector2;
167 case Property::VECTOR3:
169 function = GreaterThan::EvalVector3;
172 case Property::VECTOR4:
174 function = GreaterThan::EvalVector4;
179 function = GreaterThan::EvalDefault;
187 bool GreaterThan::EvalBoolean( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg )
189 const float arg0 = arg[0];
190 return (value.GetBoolean() > arg0);
193 bool GreaterThan::EvalInteger( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg )
195 const int arg0 = arg[0];
196 return (value.GetInteger() > arg0);
199 bool GreaterThan::EvalUnsignedInteger( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg )
201 const unsigned int arg0 = arg[0];
202 return (value.GetUnsignedInteger() > arg0);
205 bool GreaterThan::EvalFloat( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg )
207 const float arg0 = arg[0];
208 return (value.GetFloat() > arg0);
211 bool GreaterThan::EvalVector2( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg )
213 const float arg0 = arg[0];
214 return (value.GetVector2().LengthSquared() > arg0 * arg0);
217 bool GreaterThan::EvalVector3( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg )
219 const float arg0 = arg[0];
220 return (value.GetVector3().LengthSquared() > arg0 * arg0);
223 bool GreaterThan::EvalVector4( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg )
225 const float arg0 = arg[0];
226 return (value.GetVector4().LengthSquared() > arg0 * arg0);
229 bool GreaterThan::EvalDefault( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg )
234 // Inside /////////////////////////////////////////////////////////////////////
236 ConditionFunction Inside::GetFunction(Property::Type valueType)
238 ConditionFunction function = NULL;
242 case Property::BOOLEAN:
244 function = Inside::EvalBoolean;
247 case Property::INTEGER:
249 function = Inside::EvalInteger;
252 case Property::UNSIGNED_INTEGER:
254 function = Inside::EvalUnsignedInteger;
257 case Property::FLOAT:
259 function = Inside::EvalFloat;
262 case Property::VECTOR2:
264 function = Inside::EvalVector2;
267 case Property::VECTOR3:
269 function = Inside::EvalVector3;
272 case Property::VECTOR4:
274 function = Inside::EvalVector4;
279 function = Inside::EvalDefault;
287 bool Inside::EvalBoolean( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg )
289 const bool valueBoolean = value.GetBoolean();
290 return ( (valueBoolean > arg[0]) && (valueBoolean < arg[1]) );
293 bool Inside::EvalInteger( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg )
295 const int valueInteger = value.GetInteger();
296 return ( (valueInteger > arg[0]) && (valueInteger < arg[1]) );
299 bool Inside::EvalUnsignedInteger( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg )
301 const unsigned int valueUInt = value.GetUnsignedInteger();
302 return ( (valueUInt > arg[0]) && (valueUInt < arg[1]) );
305 bool Inside::EvalFloat( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg )
307 const float valueFloat = value.GetFloat();
308 return ( (valueFloat > arg[0]) && (valueFloat < arg[1]) );
311 bool Inside::EvalVector2( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg )
313 const float length2 = value.GetVector2().LengthSquared();
314 return ( (length2 > arg[0]*arg[0]) && (length2 < arg[1]*arg[1]) );
317 bool Inside::EvalVector3( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg )
319 const float length2 = value.GetVector3().LengthSquared();
320 return ( (length2 > arg[0]*arg[0]) && (length2 < arg[1]*arg[1]) );
323 bool Inside::EvalVector4( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg )
325 const float length2 = value.GetVector4().LengthSquared();
326 return ( (length2 > arg[0]*arg[0]) && (length2 < arg[1]*arg[1]) );
329 bool Inside::EvalDefault( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg )
334 // Outside ////////////////////////////////////////////////////////////////////
336 ConditionFunction Outside::GetFunction(Property::Type valueType)
338 ConditionFunction function = NULL;
342 case Property::BOOLEAN:
344 function = Outside::EvalBoolean;
347 case Property::INTEGER:
349 function = Outside::EvalInteger;
352 case Property::UNSIGNED_INTEGER:
354 function = Outside::EvalUnsignedInteger;
357 case Property::FLOAT:
359 function = Outside::EvalFloat;
362 case Property::VECTOR2:
364 function = Outside::EvalVector2;
367 case Property::VECTOR3:
369 function = Outside::EvalVector3;
372 case Property::VECTOR4:
374 function = Outside::EvalVector4;
379 function = Outside::EvalDefault;
387 bool Outside::EvalBoolean( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg )
389 const bool valueBoolean = value.GetBoolean();
390 return ( (valueBoolean < arg[0]) || (valueBoolean > arg[1]) );
393 bool Outside::EvalInteger( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg )
395 const int valueInteger = value.GetInteger();
396 return ( (valueInteger < arg[0]) || (valueInteger > arg[1]) );
399 bool Outside::EvalUnsignedInteger( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg )
401 const unsigned int valueUInt = value.GetUnsignedInteger();
402 return ( (valueUInt < arg[0]) || (valueUInt > arg[1]) );
405 bool Outside::EvalFloat( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg )
407 const float valueFloat = value.GetFloat();
408 return ( (valueFloat < arg[0]) || (valueFloat > arg[1]) );
411 bool Outside::EvalVector2( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg )
413 const float length2 = value.GetVector2().LengthSquared();
414 return ( (length2 < arg[0]*arg[0]) || (length2 > arg[1]*arg[1]) );
417 bool Outside::EvalVector3( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg )
419 const float length2 = value.GetVector3().LengthSquared();
420 return ( (length2 < arg[0]*arg[0]) || (length2 > arg[1]*arg[1]) );
423 bool Outside::EvalVector4( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg )
425 const float length2 = value.GetVector4().LengthSquared();
426 return ( (length2 < arg[0]*arg[0]) || (length2 > arg[1]*arg[1]) );
429 bool Outside::EvalDefault( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg )
434 } // namespace SceneGraph
436 } // namespace Internal