TEST_FUNCTION( UtcDaliPropertyNotificationVectorComponentOutside, POSITIVE_TC_IDX );
TEST_FUNCTION( UtcDaliPropertyConditionGetArguments, POSITIVE_TC_IDX );
TEST_FUNCTION( UtcDaliPropertyConditionGetArgumentsConst, POSITIVE_TC_IDX );
+TEST_FUNCTION( UtcDaliPropertyNotificationStep, POSITIVE_TC_IDX );
+TEST_FUNCTION( UtcDaliPropertyNotificationVariableStep, POSITIVE_TC_IDX );
class TestClass : public ConnectionTracker
{
Property::Value value = argumentsRef1[0];
DALI_TEST_EQUALS( value.Get<float>(), 50.0f, TEST_LOCATION );
}
+
+static void UtcDaliPropertyNotificationStep()
+{
+ TestApplication application;
+ tet_infoline(" UtcDaliPropertyNotificationStep");
+
+ Actor actor = Actor::New();
+ Stage::GetCurrent().Add(actor);
+
+ const float step = 100.0f;
+ // float
+ PropertyNotification notification = actor.AddPropertyNotification( Actor::POSITION, 0, StepCondition(step, 50.0f) );
+ notification.NotifySignal().Connect( &TestCallback );
+
+ // set initial position
+ actor.SetPosition(Vector3(0.0f, 0.0f, 0.0f));
+ Wait(application, DEFAULT_WAIT_PERIOD);
+
+ // test both directions
+ for( int i = 1 ; i < 10 ; ++i )
+ {
+ // Move x to negative position
+ gCallBackCalled = false;
+ actor.SetPosition(Vector3((i * step), 0.0f, 0.0f));
+ Wait(application, DEFAULT_WAIT_PERIOD);
+ DALI_TEST_CHECK( gCallBackCalled );
+ }
+
+ for( int i = 1 ; i < 10 ; ++i )
+ {
+ // Move x to negative position
+ gCallBackCalled = false;
+ actor.SetPosition(Vector3(-(i * step), 0.0f, 0.0f));
+ Wait(application, DEFAULT_WAIT_PERIOD);
+ DALI_TEST_CHECK( gCallBackCalled );
+ }
+}
+
+static void UtcDaliPropertyNotificationVariableStep()
+{
+ TestApplication application;
+ tet_infoline(" UtcDaliPropertyNotificationStep");
+
+ Actor actor = Actor::New();
+ Stage::GetCurrent().Add(actor);
+
+ std::vector<float> values;
+
+ const float averageStep = 100.0f;
+
+ for( int i = 1 ; i < 10 ; i++ )
+ {
+ values.push_back(i * averageStep + (i % 2 == 0 ? -(averageStep * 0.2f) : (averageStep * 0.2f)));
+ }
+ // float
+ PropertyNotification notification = actor.AddPropertyNotification( Actor::POSITION, 0, VariableStepCondition(values) );
+ notification.NotifySignal().Connect( &TestCallback );
+
+ // set initial position lower than first position in list
+ actor.SetPosition(Vector3(values[0] - averageStep, 0.0f, 0.0f));
+ Wait(application, DEFAULT_WAIT_PERIOD);
+
+ for( int i = 0 ; i < values.size() - 1 ; ++i )
+ {
+ gCallBackCalled = false;
+ // set position half way between the current values
+ float position = values[i] + (0.5f * (values[i + 1] - values[i]));
+ actor.SetPosition(Vector3(position, 0.0f, 0.0f));
+ Wait(application, DEFAULT_WAIT_PERIOD);
+ DALI_TEST_CHECK( gCallBackCalled );
+ }
+}
*/
PropertyCondition OutsideCondition(float arg0, float arg1);
+/**
+ * @brief Detects when a property changes by stepAmount from initialValue, in both positive and negative directions. This will continue checking for multiples of stepAmount
+ *
+ * property type:
+ * float (float)
+ * vector2 (the 2D length)
+ * vector3 (the 3D length)
+ * vector4 (the 4D length)
+ * @param[in] stepAmount The step size required to trigger condition
+ * @param[in] initialValue The initial value to step from
+ * @return A property condition function object
+ */
+PropertyCondition StepCondition(float stepAmount, float initialValue = 0.0f);
+
+/**
+ * @brief Receive notifications as a property goes above/below the inputted values. Values must be ordered and can be either ascending or descending
+ *
+ * property type:
+ * float (float)
+ * vector2 (the 2D length)
+ * vector3 (the 3D length)
+ * vector4 (the 4D length)
+ * @param[in] steps List of values to receive notifications for as a property crosses them
+ * @return A property condition function object
+ */
+PropertyCondition VariableStepCondition(const std::vector<float>& steps);
+
} // namespace Dali
/**
* @brief Sets the Notification mode. This determines how the property
* notification should respond to the result of a condition.
*
- * @param[in] mode Notification mode
+ * @param[in] mode Notification mode (Default is PropertyNotification::NotifyOnTrue)
*/
void SetNotifyMode( NotifyMode mode );
LessThan, ///< Magnitude of type is less than float value (arg0).
GreaterThan, ///< Magnitude of type is greater than float value (arg0).
Inside, ///< Magnitude of type is within float values (arg0 & arg1).
- Outside ///< Magnitude of type is outside float values (arg0 & arg1).
+ Outside, ///< Magnitude of type is outside float values (arg0 & arg1).
+ Step, ///< Value of type has crossed a step amount
+ VariableStep ///< Similar to step, except user can define a list of steps from reference value
};
typedef Dali::PropertyCondition::ArgumentContainer ArgumentContainer;
$(internal_src_dir)/update/common/discard-queue.cpp \
$(internal_src_dir)/update/common/property-base.cpp \
$(internal_src_dir)/update/common/property-condition-functions.cpp \
+ $(internal_src_dir)/update/common/property-condition-step-functions.cpp \
+ $(internal_src_dir)/update/common/property-condition-variable-step-functions.cpp \
$(internal_src_dir)/update/common/property-owner.cpp \
$(internal_src_dir)/update/common/scene-graph-buffers.cpp \
$(internal_src_dir)/update/common/scene-graph-property-notification.cpp \
return function;
}
-bool LessThan::EvalBoolean( const Dali::PropertyInput& value, const PropertyNotification::RawArgumentContainer& arg )
+bool LessThan::EvalBoolean( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg )
{
const float arg0 = arg[0];
return (value.GetBoolean() < arg0);
}
-bool LessThan::EvalFloat( const Dali::PropertyInput& value, const PropertyNotification::RawArgumentContainer& arg )
+bool LessThan::EvalFloat( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg )
{
const float arg0 = arg[0];
return (value.GetFloat() < arg0);
}
-bool LessThan::EvalVector2( const Dali::PropertyInput& value, const PropertyNotification::RawArgumentContainer& arg )
+bool LessThan::EvalVector2( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg )
{
const float arg0 = arg[0];
return (value.GetVector2().LengthSquared() < arg0 * arg0);
}
-bool LessThan::EvalVector3( const Dali::PropertyInput& value, const PropertyNotification::RawArgumentContainer& arg )
+bool LessThan::EvalVector3( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg )
{
const float arg0 = arg[0];
return (value.GetVector3().LengthSquared() < arg0 * arg0);
}
-bool LessThan::EvalVector4( const Dali::PropertyInput& value, const PropertyNotification::RawArgumentContainer& arg )
+bool LessThan::EvalVector4( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg )
{
const float arg0 = arg[0];
return (value.GetVector4().LengthSquared() < arg0 * arg0);
}
-bool LessThan::EvalDefault( const Dali::PropertyInput& value, const PropertyNotification::RawArgumentContainer& arg )
+bool LessThan::EvalDefault( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg )
{
return false;
}
return function;
}
-bool GreaterThan::EvalBoolean( const Dali::PropertyInput& value, const PropertyNotification::RawArgumentContainer& arg )
+bool GreaterThan::EvalBoolean( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg )
{
const float arg0 = arg[0];
return (value.GetBoolean() > arg0);
}
-bool GreaterThan::EvalFloat( const Dali::PropertyInput& value, const PropertyNotification::RawArgumentContainer& arg )
+bool GreaterThan::EvalFloat( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg )
{
const float arg0 = arg[0];
return (value.GetFloat() > arg0);
}
-bool GreaterThan::EvalVector2( const Dali::PropertyInput& value, const PropertyNotification::RawArgumentContainer& arg )
+bool GreaterThan::EvalVector2( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg )
{
const float arg0 = arg[0];
return (value.GetVector2().LengthSquared() > arg0 * arg0);
}
-bool GreaterThan::EvalVector3( const Dali::PropertyInput& value, const PropertyNotification::RawArgumentContainer& arg )
+bool GreaterThan::EvalVector3( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg )
{
const float arg0 = arg[0];
return (value.GetVector3().LengthSquared() > arg0 * arg0);
}
-bool GreaterThan::EvalVector4( const Dali::PropertyInput& value, const PropertyNotification::RawArgumentContainer& arg )
+bool GreaterThan::EvalVector4( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg )
{
const float arg0 = arg[0];
return (value.GetVector4().LengthSquared() > arg0 * arg0);
}
-bool GreaterThan::EvalDefault( const Dali::PropertyInput& value, const PropertyNotification::RawArgumentContainer& arg )
+bool GreaterThan::EvalDefault( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg )
{
return false;
}
return function;
}
-bool Inside::EvalBoolean( const Dali::PropertyInput& value, const PropertyNotification::RawArgumentContainer& arg )
+bool Inside::EvalBoolean( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg )
{
const bool valueBoolean = value.GetBoolean();
return ( (valueBoolean > arg[0]) && (valueBoolean < arg[1]) );
}
-bool Inside::EvalFloat( const Dali::PropertyInput& value, const PropertyNotification::RawArgumentContainer& arg )
+bool Inside::EvalFloat( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg )
{
const float valueFloat = value.GetFloat();
return ( (valueFloat > arg[0]) && (valueFloat < arg[1]) );
}
-bool Inside::EvalVector2( const Dali::PropertyInput& value, const PropertyNotification::RawArgumentContainer& arg )
+bool Inside::EvalVector2( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg )
{
const float length2 = value.GetVector2().LengthSquared();
return ( (length2 > arg[0]*arg[0]) && (length2 < arg[1]*arg[1]) );
}
-bool Inside::EvalVector3( const Dali::PropertyInput& value, const PropertyNotification::RawArgumentContainer& arg )
+bool Inside::EvalVector3( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg )
{
const float length2 = value.GetVector3().LengthSquared();
return ( (length2 > arg[0]*arg[0]) && (length2 < arg[1]*arg[1]) );
}
-bool Inside::EvalVector4( const Dali::PropertyInput& value, const PropertyNotification::RawArgumentContainer& arg )
+bool Inside::EvalVector4( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg )
{
const float length2 = value.GetVector4().LengthSquared();
return ( (length2 > arg[0]*arg[0]) && (length2 < arg[1]*arg[1]) );
}
-bool Inside::EvalDefault( const Dali::PropertyInput& value, const PropertyNotification::RawArgumentContainer& arg )
+bool Inside::EvalDefault( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg )
{
return false;
}
return function;
}
-bool Outside::EvalBoolean( const Dali::PropertyInput& value, const PropertyNotification::RawArgumentContainer& arg )
+bool Outside::EvalBoolean( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg )
{
const bool valueBoolean = value.GetBoolean();
return ( (valueBoolean < arg[0]) || (valueBoolean > arg[1]) );
}
-bool Outside::EvalFloat( const Dali::PropertyInput& value, const PropertyNotification::RawArgumentContainer& arg )
+bool Outside::EvalFloat( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg )
{
const float valueFloat = value.GetFloat();
return ( (valueFloat < arg[0]) || (valueFloat > arg[1]) );
}
-bool Outside::EvalVector2( const Dali::PropertyInput& value, const PropertyNotification::RawArgumentContainer& arg )
+bool Outside::EvalVector2( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg )
{
const float length2 = value.GetVector2().LengthSquared();
return ( (length2 < arg[0]*arg[0]) || (length2 > arg[1]*arg[1]) );
}
-bool Outside::EvalVector3( const Dali::PropertyInput& value, const PropertyNotification::RawArgumentContainer& arg )
+bool Outside::EvalVector3( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg )
{
const float length2 = value.GetVector3().LengthSquared();
return ( (length2 < arg[0]*arg[0]) || (length2 > arg[1]*arg[1]) );
}
-bool Outside::EvalVector4( const Dali::PropertyInput& value, const PropertyNotification::RawArgumentContainer& arg )
+bool Outside::EvalVector4( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg )
{
const float length2 = value.GetVector4().LengthSquared();
return ( (length2 < arg[0]*arg[0]) || (length2 > arg[1]*arg[1]) );
}
-bool Outside::EvalDefault( const Dali::PropertyInput& value, const PropertyNotification::RawArgumentContainer& arg )
+bool Outside::EvalDefault( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg )
{
return false;
}
#include <dali/public-api/object/property-value.h>
#include <dali/internal/update/common/scene-graph-property-notification.h>
+// OTHER CONDITITION INCLUDES
+#include <dali/internal/update/common/property-condition-step-functions.h>
+#include <dali/internal/update/common/property-condition-variable-step-functions.h>
+
namespace Dali
{
* @param[in] arg The supplied arguments for the condition.
* @return Condition result (true if condition met, false if not)
*/
- static bool EvalBoolean( const Dali::PropertyInput& value, const PropertyNotification::RawArgumentContainer& arg );
+ static bool EvalBoolean( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg );
/**
* Checks if float is LessThan
* @param[in] arg The supplied arguments for the condition.
* @return Condition result (true if condition met, false if not)
*/
- static bool EvalFloat( const Dali::PropertyInput& value, const PropertyNotification::RawArgumentContainer& arg );
+ static bool EvalFloat( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg );
/**
* Checks if Vector2.Length() is LessThan
* @param[in] arg The supplied arguments for the condition.
* @return Condition result (true if condition met, false if not)
*/
- static bool EvalVector2( const Dali::PropertyInput& value, const PropertyNotification::RawArgumentContainer& arg );
+ static bool EvalVector2( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg );
/**
* Checks if Vector3.Length() is LessThan
* @param[in] arg The supplied arguments for the condition.
* @return Condition result (true if condition met, false if not)
*/
- static bool EvalVector3( const Dali::PropertyInput& value, const PropertyNotification::RawArgumentContainer& arg );
+ static bool EvalVector3( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg );
/**
* Checks if Vector4.Length() is LessThan
* @param[in] arg The supplied arguments for the condition.
* @return Condition result (true if condition met, false if not)
*/
- static bool EvalVector4( const Dali::PropertyInput& value, const PropertyNotification::RawArgumentContainer& arg );
+ static bool EvalVector4( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg );
/**
* Default check for other types
* @param[in] arg The supplied arguments for the condition.
* @return Condition result (true if condition met, false if not)
*/
- static bool EvalDefault( const Dali::PropertyInput& value, const PropertyNotification::RawArgumentContainer& arg );
+ static bool EvalDefault( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg );
};
* Checks if a Property is "Greater Than" the argument:
*
* bool => false (0.0) or true (1.0) is greater than arg0.
- * float => value is grVector2eater than arg0.
+ * float => value is greater than arg0.
* Vector2 => 2 dimensional length of vector is greater than arg0.
* Vector3 => 3 dimensional length of vector is greater than arg0.
* Vector4 => 4 dimensional length of vector is greater than arg0.
* @param[in] arg The supplied arguments for the condition.
* @return Condition result (true if condition met, false if not)
*/
- static bool EvalBoolean( const Dali::PropertyInput& value, const PropertyNotification::RawArgumentContainer& arg );
+ static bool EvalBoolean( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg );
/**
* Checks if float is GreaterThan
* @param[in] arg The supplied arguments for the condition.
* @return Condition result (true if condition met, false if not)
*/
- static bool EvalFloat( const Dali::PropertyInput& value, const PropertyNotification::RawArgumentContainer& arg );
+ static bool EvalFloat( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg );
/**
* Checks if Vector2.Length() is GreaterThan
* @param[in] arg The supplied arguments for the condition.
* @return Condition result (true if condition met, false if not)
*/
- static bool EvalVector2( const Dali::PropertyInput& value, const PropertyNotification::RawArgumentContainer& arg );
+ static bool EvalVector2( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg );
/**
* Checks if Vector3.Length() is GreaterThan
* @param[in] arg The supplied arguments for the condition.
* @return Condition result (true if condition met, false if not)
*/
- static bool EvalVector3( const Dali::PropertyInput& value, const PropertyNotification::RawArgumentContainer& arg );
+ static bool EvalVector3( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg );
/**
* Checks if Vector4.Length() is GreaterThan
* @param[in] arg The supplied arguments for the condition.
* @return Condition result (true if condition met, false if not)
*/
- static bool EvalVector4( const Dali::PropertyInput& value, const PropertyNotification::RawArgumentContainer& arg );
+ static bool EvalVector4( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg );
/**
* Default check for other types.
* @param[in] arg The supplied arguments for the condition.
* @return Condition result (true if condition met, false if not)
*/
- static bool EvalDefault( const Dali::PropertyInput& value, const PropertyNotification::RawArgumentContainer& arg );
+ static bool EvalDefault( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg );
};
* Checks if a Property is "Inside" the two arguments:
*
* bool => false (0.0) or true (1.0) is inside arg0.
- * float => value is inside arg0.
- * Vector2 => 2 dimensional length of vector is inside arg0.
- * Vector3 => 3 dimensional length of vector is inside arg0.
- * Vector4 => 4 dimensional length of vector is inside arg0.
+ * float => value is between arg0 and arg1.
+ * Vector2 => 2 dimensional length of vector is between arg0 and arg1.
+ * Vector3 => 3 dimensional length of vector is between arg0 and arg1.
+ * Vector4 => 4 dimensional length of vector is between arg0 and arg1.
* Default => return false.
*/
class Inside
* @param[in] arg The supplied arguments for the condition.
* @return Condition result (true if condition met, false if not)
*/
- static bool EvalBoolean( const Dali::PropertyInput& value, const PropertyNotification::RawArgumentContainer& arg );
+ static bool EvalBoolean( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg );
/**
* Checks if float is Inside
* @param[in] arg The supplied arguments for the condition.
* @return Condition result (true if condition met, false if not)
*/
- static bool EvalFloat( const Dali::PropertyInput& value, const PropertyNotification::RawArgumentContainer& arg );
+ static bool EvalFloat( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg );
/**
* Checks if Vector2.Length() is Inside
* @param[in] arg The supplied arguments for the condition.
* @return Condition result (true if condition met, false if not)
*/
- static bool EvalVector2( const Dali::PropertyInput& value, const PropertyNotification::RawArgumentContainer& arg );
+ static bool EvalVector2( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg );
/**
* Checks if Vector3.Length() is Inside
* @param[in] arg The supplied arguments for the condition.
* @return Condition result (true if condition met, false if not)
*/
- static bool EvalVector3( const Dali::PropertyInput& value, const PropertyNotification::RawArgumentContainer& arg );
+ static bool EvalVector3( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg );
/**
* Checks if Vector4.Length() is Inside
* @param[in] arg The supplied arguments for the condition.
* @return Condition result (true if condition met, false if not)
*/
- static bool EvalVector4( const Dali::PropertyInput& value, const PropertyNotification::RawArgumentContainer& arg );
+ static bool EvalVector4( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg );
/**
* Default check for other types.
* @param[in] arg The supplied arguments for the condition.
* @return Condition result (true if condition met, false if not)
*/
- static bool EvalDefault( const Dali::PropertyInput& value, const PropertyNotification::RawArgumentContainer& arg );
+ static bool EvalDefault( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg );
};
* Checks if a Property is "Outside" the two arguments:
*
* bool => false (0.0) or true (1.0) is outside arg0.
- * float => value is inside arg0.
- * Vector2 => 2 dimensional length of vector is outside arg0.
- * Vector3 => 3 dimensional length of vector is outside arg0.
- * Vector4 => 4 dimensional length of vector is outside arg0.
+ * float => value is outside arg0 and arg1.
+ * Vector2 => 2 dimensional length of vector is outside arg0 and arg1.
+ * Vector3 => 3 dimensional length of vector is outside arg0 and arg1.
+ * Vector4 => 4 dimensional length of vector is outside arg0 and arg1.
* Default => return false.
*/
class Outside
* @param[in] arg The supplied arguments for the condition.
* @return Condition result (true if condition met, false if not)
*/
- static bool EvalBoolean( const Dali::PropertyInput& value, const PropertyNotification::RawArgumentContainer& arg );
+ static bool EvalBoolean( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg );
/**
* Checks if float is Outside
* @param[in] arg The supplied arguments for the condition.
* @return Condition result (true if condition met, false if not)
*/
- static bool EvalFloat( const Dali::PropertyInput& value, const PropertyNotification::RawArgumentContainer& arg );
+ static bool EvalFloat( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg );
/**
* Checks if Vector2.Length() is Outside
* @param[in] arg The supplied arguments for the condition.
* @return Condition result (true if condition met, false if not)
*/
- static bool EvalVector2( const Dali::PropertyInput& value, const PropertyNotification::RawArgumentContainer& arg );
+ static bool EvalVector2( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg );
/**
* Checks if Vector3.Length() is Outside
* @param[in] arg The supplied arguments for the condition.
* @return Condition result (true if condition met, false if not)
*/
- static bool EvalVector3( const Dali::PropertyInput& value, const PropertyNotification::RawArgumentContainer& arg );
+ static bool EvalVector3( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg );
/**
* Checks if Vector4.Length() is Outside
* @param[in] arg The supplied arguments for the condition.
* @return Condition result (true if condition met, false if not)
*/
- static bool EvalVector4( const Dali::PropertyInput& value, const PropertyNotification::RawArgumentContainer& arg );
+ static bool EvalVector4( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg );
/**
* Default check for other types.
* @param[in] arg The supplied arguments for the condition.
* @return Condition result (true if condition met, false if not)
*/
- static bool EvalDefault( const Dali::PropertyInput& value, const PropertyNotification::RawArgumentContainer& arg );
+ static bool EvalDefault( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg );
};
--- /dev/null
+//
+// Copyright (c) 2014 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Flora License, Version 1.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://floralicense.org/license/
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an AS IS BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+#include <dali/public-api/common/dali-common.h>
+#include <dali/public-api/math/vector2.h>
+#include <dali/public-api/math/vector3.h>
+#include <dali/public-api/math/vector4.h>
+#include <dali/public-api/object/property-input.h>
+#include <dali/internal/update/common/property-condition-step-functions.h>
+
+namespace Dali
+{
+
+namespace Internal
+{
+
+namespace SceneGraph
+{
+
+namespace
+{
+
+const int ARGINDEX_REF_VALUE = 0;
+const int ARGINDEX_STEP_SIZE = 1;
+const int ARGINDEX_CURRENT_STEP = 2;
+
+} // namespace
+
+ConditionFunction Step::GetFunction(Property::Type valueType)
+{
+ ConditionFunction function = NULL;
+
+ switch(valueType)
+ {
+ case Property::FLOAT:
+ {
+ function = EvalFloat;
+ break;
+ }
+ case Property::VECTOR2:
+ {
+ function = EvalVector2;
+ break;
+ }
+ case Property::VECTOR3:
+ {
+ function = EvalVector3;
+ break;
+ }
+ case Property::VECTOR4:
+ {
+ function = EvalVector4;
+ break;
+ }
+ default:
+ {
+ function = EvalDefault;
+ break;
+ }
+ } // end switch
+
+ return function;
+}
+
+bool Step::Evaluate( const float propertyValue, PropertyNotification::RawArgumentContainer& arg )
+{
+ const float refValue = arg[ARGINDEX_REF_VALUE];
+ const float step = arg[ARGINDEX_STEP_SIZE];
+ const int currentStep = static_cast<int>(arg[ARGINDEX_CURRENT_STEP]);
+ const float distance = (propertyValue - refValue);
+ // step is actual 1.0f / step so can multiply instead of dividing
+ const int newStep = static_cast<int>(floorf(distance * step));
+
+ if( newStep != currentStep )
+ {
+ // in new section
+ arg[ARGINDEX_CURRENT_STEP] = static_cast<float>(newStep);
+ return true;
+ }
+ return false;
+}
+
+bool Step::EvalFloat( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg )
+{
+ const float propertyValue = value.GetFloat();
+ return Evaluate( propertyValue, arg );
+}
+
+bool Step::EvalVector2( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg )
+{
+ const float propertyValue = value.GetVector2().LengthSquared();
+ return Evaluate( propertyValue, arg );
+}
+
+bool Step::EvalVector3( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg )
+{
+ float propertyValue = value.GetVector3().LengthSquared();
+ return Evaluate( propertyValue, arg );
+}
+
+bool Step::EvalVector4( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg )
+{
+ const float propertyValue = value.GetVector4().LengthSquared();
+ return Evaluate( propertyValue, arg );
+}
+
+bool Step::EvalDefault( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg )
+{
+ return false;
+}
+
+} // namespace SceneGraph
+
+} // namespace Internal
+
+} // namespace Dali
--- /dev/null
+#ifndef __DALI_INTERNAL_SCENE_GRAPH_PROPERTY_CONDITION_STEP_FUNCTIONS_H__
+#define __DALI_INTERNAL_SCENE_GRAPH_PROPERTY_CONDITION_STEP_FUNCTIONS_H__
+
+//
+// Copyright (c) 2014 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Flora License, Version 1.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://floralicense.org/license/
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an AS IS BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+// INTERNAL INCLUDES
+#include <dali/public-api/object/property-value.h>
+#include <dali/internal/update/common/scene-graph-property-notification.h>
+
+namespace Dali
+{
+
+namespace Internal
+{
+
+class ProxyObject;
+class PropertyNotification;
+
+namespace SceneGraph
+{
+
+/**
+ * Step condition class,
+ * Checks if a Property has stepped a certain amount from the reference point
+ *
+ * float => value has stepped arg1 amount from arg0.
+ * Vector2 => 2 dimensional length of vector has stepped arg1 amount from arg0.
+ * Vector3 => 3 dimensional length of vector has stepped arg1 amount from arg0.
+ * Vector4 => 4 dimensional length of vector has stepped arg1 amount from arg0.
+ * Default => return false.
+ */
+class Step
+{
+
+public:
+
+ /**
+ * @return function pointer to the correct condition function, based on
+ * the type of value being examined.
+ */
+ static ConditionFunction GetFunction( Property::Type valueType );
+
+private:
+
+ static bool Evaluate( const float propertyValue, PropertyNotification::RawArgumentContainer& arg );
+
+ /**
+ * Checks if float is Outside
+ * @param[in] value The value being examined.
+ * @param[in] arg The supplied arguments for the condition.
+ * @return Condition result (true if condition met, false if not)
+ */
+ static bool EvalFloat( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg );
+
+ /**
+ * Checks if Vector2.Length() is Outside
+ * @param[in] value The value being examined.
+ * @param[in] arg The supplied arguments for the condition.
+ * @return Condition result (true if condition met, false if not)
+ */
+ static bool EvalVector2( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg );
+
+ /**
+ * Checks if Vector3.Length() is Outside
+ * @param[in] value The value being examined.
+ * @param[in] arg The supplied arguments for the condition.
+ * @return Condition result (true if condition met, false if not)
+ */
+ static bool EvalVector3( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg );
+
+ /**
+ * Checks if Vector4.Length() is Outside
+ * @param[in] value The value being examined.
+ * @param[in] arg The supplied arguments for the condition.
+ * @return Condition result (true if condition met, false if not)
+ */
+ static bool EvalVector4( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg );
+
+ /**
+ * Default check for other types.
+ * @param[in] value The value being examined.
+ * @param[in] arg The supplied arguments for the condition.
+ * @return Condition result (true if condition met, false if not)
+ */
+ static bool EvalDefault( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg );
+
+};
+
+} // namespace SceneGraph
+
+} // namespace Internal
+
+} // namespace Dali
+
+#endif // __DALI_INTERNAL_SCENE_GRAPH_PROPERTY_CONDITION_STEP_FUNCTIONS_H__
--- /dev/null
+//
+// Copyright (c) 2014 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Flora License, Version 1.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://floralicense.org/license/
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an AS IS BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+#include <dali/public-api/common/dali-common.h>
+#include <dali/public-api/math/vector2.h>
+#include <dali/public-api/math/vector3.h>
+#include <dali/public-api/math/vector4.h>
+#include <dali/public-api/object/property-input.h>
+#include <dali/internal/update/common/property-condition-variable-step-functions.h>
+
+namespace Dali
+{
+
+namespace Internal
+{
+
+namespace SceneGraph
+{
+
+namespace
+{
+
+const int ARGINDEX_STEP_INDEX = 0;
+const int ARGINDEX_LIST_SIZE = 1;
+const int ARGINDEX_LIST_START = 2;
+
+}
+
+ConditionFunction VariableStep::GetFunction( Property::Type valueType )
+{
+ ConditionFunction function = NULL;
+
+ switch( valueType )
+ {
+ case Property::FLOAT:
+ {
+ function = EvalFloat;
+ break;
+ }
+ case Property::VECTOR2:
+ {
+ function = EvalVector2;
+ break;
+ }
+ case Property::VECTOR3:
+ {
+ function = EvalVector3;
+ break;
+ }
+ case Property::VECTOR4:
+ {
+ function = EvalVector4;
+ break;
+ }
+ default:
+ {
+ function = EvalDefault;
+ break;
+ }
+ } // end switch
+
+ return function;
+}
+
+bool VariableStep::Evaluate( const float propertyValue, PropertyNotification::RawArgumentContainer& arg )
+{
+ const int currentIndex = arg[ARGINDEX_STEP_INDEX];
+ const int numSteps = arg[ARGINDEX_LIST_SIZE];
+ const float first = arg[ARGINDEX_LIST_START];
+ const float last = arg[ARGINDEX_LIST_START + (numSteps - 1)];
+ const bool ascending = (last > first) ? true : false;
+ int newIndex = currentIndex;
+
+ // avoid loop if property currently not within any of the range values
+ if( ascending )
+ {
+ if( propertyValue < first )
+ {
+ newIndex = -1;
+ }
+ else if( propertyValue >= last )
+ {
+ newIndex = numSteps - 1;
+ }
+ }
+ else
+ {
+ // increments are in negative direction
+ if( propertyValue > first )
+ {
+ newIndex = -1;
+ }
+ else if( propertyValue <= last )
+ {
+ newIndex = numSteps - 1;
+ }
+ }
+ int i = 0;
+ for( i = 0 ; i < numSteps - 1 ; ++i )
+ {
+ const float arg1 = arg[ARGINDEX_LIST_START + i];
+ const float arg2 = arg[ARGINDEX_LIST_START + (i + 1)];
+ if( ascending )
+ {
+ if( ( propertyValue >= arg1 )
+ && ( propertyValue < arg2 ) )
+ {
+ newIndex = i;
+ break;
+ }
+ }
+ else
+ {
+ // increments are in negative direction
+ if( ( propertyValue > arg2 )
+ && ( propertyValue <= arg1 ) )
+ {
+ newIndex = i;
+ break;
+ }
+ }
+ }
+ if( newIndex != currentIndex )
+ {
+ // have changed to new step
+ arg[ARGINDEX_STEP_INDEX] = static_cast<float>(newIndex);
+ return true;
+ }
+ return false;
+}
+
+bool VariableStep::EvalFloat( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg )
+{
+ const float propertyValue = value.GetFloat();
+ return Evaluate( propertyValue, arg );
+}
+
+bool VariableStep::EvalVector2( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg )
+{
+ const float propertyValue = value.GetVector2().LengthSquared();
+ return Evaluate( propertyValue, arg );
+}
+
+bool VariableStep::EvalVector3( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg )
+{
+ float propertyValue = value.GetVector3().LengthSquared();
+ return Evaluate( propertyValue, arg );
+}
+
+bool VariableStep::EvalVector4( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg )
+{
+ const float propertyValue = value.GetVector4().LengthSquared();
+ return Evaluate( propertyValue, arg );
+}
+
+bool VariableStep::EvalDefault( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg )
+{
+ return false;
+}
+
+} // namespace SceneGraph
+
+} // namespace Internal
+
+} // namespace Dali
--- /dev/null
+#ifndef __DALI_INTERNAL_SCENE_GRAPH_PROPERTY_CONDITION_VARIABLE_STEP_FUNCTIONS_H__
+#define __DALI_INTERNAL_SCENE_GRAPH_PROPERTY_CONDITION_VARIABLE_STEP_FUNCTIONS_H__
+
+//
+// Copyright (c) 2014 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Flora License, Version 1.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://floralicense.org/license/
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an AS IS BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+// INTERNAL INCLUDES
+#include <dali/public-api/object/property-value.h>
+#include <dali/internal/update/common/scene-graph-property-notification.h>
+
+namespace Dali
+{
+
+namespace Internal
+{
+
+class ProxyObject;
+class PropertyNotification;
+
+namespace SceneGraph
+{
+
+/**
+ * VariableStep condition class,
+ * Uses a list of values, this condition notifies when the Property crosses between different values
+ *
+ * float => value has stepped arg1 amount from arg0.
+ * Vector2 => 2 dimensional length of vector has stepped arg1 amount from arg0.
+ * Vector3 => 3 dimensional length of vector has stepped arg1 amount from arg0.
+ * Vector4 => 4 dimensional length of vector has stepped arg1 amount from arg0.
+ * Default => return false.
+ */
+class VariableStep
+{
+
+public:
+
+ /**
+ * @return function pointer to the correct condition function, based on
+ * the type of value being examined.
+ */
+ static ConditionFunction GetFunction( Property::Type valueType );
+
+private:
+
+ /**
+ * Helper function used to evaluate our property
+ *
+ *
+ */
+ static bool Evaluate( const float propertyValue, PropertyNotification::RawArgumentContainer& arg );
+
+ /**
+ * Checks if float is Outside
+ * @param[in] value The value being examined.
+ * @param[in] arg The supplied arguments for the condition.
+ * @return Condition result (true if condition met, false if not)
+ */
+ static bool EvalFloat( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg );
+
+ /**
+ * Checks if Vector2.Length() is Outside
+ * @param[in] value The value being examined.
+ * @param[in] arg The supplied arguments for the condition.
+ * @return Condition result (true if condition met, false if not)
+ */
+ static bool EvalVector2( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg );
+
+ /**
+ * Checks if Vector3.Length() is Outside
+ * @param[in] value The value being examined.
+ * @param[in] arg The supplied arguments for the condition.
+ * @return Condition result (true if condition met, false if not)
+ */
+ static bool EvalVector3( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg );
+
+ /**
+ * Checks if Vector4.Length() is Outside
+ * @param[in] value The value being examined.
+ * @param[in] arg The supplied arguments for the condition.
+ * @return Condition result (true if condition met, false if not)
+ */
+ static bool EvalVector4( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg );
+
+ /**
+ * Default check for other types.
+ * @param[in] value The value being examined.
+ * @param[in] arg The supplied arguments for the condition.
+ * @return Condition result (true if condition met, false if not)
+ */
+ static bool EvalDefault( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg );
+
+};
+
+} // namespace SceneGraph
+
+} // namespace Internal
+
+} // namespace Dali
+
+#endif // __DALI_INTERNAL_SCENE_GRAPH_PROPERTY_CONDITION_VARIABLE_STEP_FUNCTIONS_H__
Property::Type propertyType,
int componentIndex,
ConditionType condition,
- const RawArgumentContainer& arguments,
+ RawArgumentContainer& arguments,
NotifyMode notifyMode)
{
return new PropertyNotification( proxy, propertyIndex, propertyType, componentIndex, condition, arguments, notifyMode );
Property::Type propertyType,
int componentIndex,
ConditionType condition,
- const RawArgumentContainer& arguments,
+ RawArgumentContainer& arguments,
NotifyMode notifyMode)
: mProxy(&proxy),
mPropertyIndex(propertyIndex),
mConditionFunction = Outside::GetFunction(mPropertyType);
break;
}
+ case PropertyCondition::Step:
+ {
+ mConditionFunction = Step::GetFunction(mPropertyType);
+ break;
+ }
+ case PropertyCondition::VariableStep:
+ {
+ mConditionFunction = VariableStep::GetFunction(mPropertyType);
+ break;
+ }
case PropertyCondition::False:
{
mConditionFunction = PropertyNotification::EvalFalse;
{
}
-bool PropertyNotification::EvalFalse( const Dali::PropertyInput& value, const RawArgumentContainer& arg )
+bool PropertyNotification::EvalFalse( const Dali::PropertyInput& value, RawArgumentContainer& arg )
{
return false;
}
typedef OwnerContainer< PropertyNotification* > PropertyNotificationContainer;
typedef PropertyNotificationContainer::Iterator PropertyNotificationIter;
typedef PropertyNotificationContainer::ConstIterator PropertyNotificationConstIter;
-typedef bool(*ConditionFunction)(const Dali::PropertyInput& value, const Dali::Internal::PropertyNotification::RawArgumentContainer& args);
+typedef bool(*ConditionFunction)(const Dali::PropertyInput& value, Dali::Internal::PropertyNotification::RawArgumentContainer& args);
/**
* PropertyNotifications are used to inspect properties of scene graph objects, as part of a scene
Property::Type propertyType,
int componentIndex,
ConditionType condition,
- const RawArgumentContainer& arguments,
+ RawArgumentContainer& arguments,
NotifyMode notifyMode);
/**
Property::Type propertyType,
int componentIndex,
ConditionType condition,
- const RawArgumentContainer& arguments,
+ RawArgumentContainer& arguments,
NotifyMode notifyMode);
private:
* @param[in] arg The supplied arguments for the condition.
* @return Condition result (true if condition met, false if not)
*/
- static bool EvalFalse( const Dali::PropertyInput& value, const Dali::Internal::PropertyNotification::RawArgumentContainer& arg );
+ static bool EvalFalse( const Dali::PropertyInput& value, Dali::Internal::PropertyNotification::RawArgumentContainer& arg );
// Undefined
PropertyNotification(const PropertyNotification&);
const PropertyInputImpl* mProperty; ///< The scene graph property
int mComponentIndex; ///< Used for accessing float components of Vector3/4
ConditionType mConditionType; ///< The ConditionType
- const RawArgumentContainer mArguments; ///< The arguments.
+ RawArgumentContainer mArguments; ///< The arguments.
bool mValid; ///< Whether this property notification is currently valid or not.
char mNotifyValidity[2]; ///< Whether to notify on invalid and/or valid
ConditionFunction mConditionFunction; ///< The Condition Function pointer to be evaluated.
return condition;
}
+PropertyCondition StepCondition(float stepAmount, float referenceValue)
+{
+ PropertyCondition condition;
+ GetImplementation(condition).type = Internal::PropertyCondition::Step;
+ GetImplementation(condition).arguments.push_back(Property::Value(referenceValue));
+ GetImplementation(condition).arguments.push_back(Property::Value(1.0f / stepAmount));
+ GetImplementation(condition).arguments.push_back(Property::Value(0.0f)); // current step
+
+ return condition;
+}
+
+PropertyCondition VariableStepCondition(const std::vector<float>& stepAmount)
+{
+ PropertyCondition condition;
+ GetImplementation(condition).type = Internal::PropertyCondition::VariableStep;
+ GetImplementation(condition).arguments.push_back(Property::Value(0.0f)); // current step
+ int size = stepAmount.size();
+ GetImplementation(condition).arguments.push_back(Property::Value(static_cast<float>(size))); // store number of steps
+ for( std::vector<float>::const_iterator it = stepAmount.begin(), endIt = stepAmount.end(); it != endIt; ++it )
+ {
+ GetImplementation(condition).arguments.push_back(Property::Value( *it ));
+ }
+
+ return condition;
+}
+
} // namespace Dali