Fix property notificaition's bug for SIZE 06/220906/16
authorWonsik Jung <sidein@samsung.com>
Tue, 24 Dec 2019 11:25:25 +0000 (20:25 +0900)
committerWonsik Jung <sidein@samsung.com>
Tue, 11 Feb 2020 00:59:01 +0000 (09:59 +0900)
When the property of SIZE is changed by swapping width and height in Vector3.
property notification signal does not occur.
Because vector's length are compared.
To fix, this patch has the comparing previous and current raw data itself.

Change-Id: Idbf0029653a73c10971e751b71366811661c73b7

automated-tests/src/dali/utc-Dali-PropertyNotification.cpp
dali/internal/event/common/property-notification-impl.cpp
dali/internal/event/common/property-notification-impl.h
dali/internal/update/common/property-condition-step-functions.cpp
dali/internal/update/common/property-condition-step-functions.h
dali/internal/update/common/scene-graph-property-notification.cpp
dali/internal/update/common/scene-graph-property-notification.h

index 23f575d6da3884f5f0e15a3525b37a8254ec0d04..522ddb92228c8aa74a71aa0db2fbc32c20b59bd7 100644 (file)
@@ -168,7 +168,9 @@ int UtcDaliAddPropertyNotification(void)
   Actor actor = Actor::New();
 
   PropertyNotification notification = actor.AddPropertyNotification(Actor::Property::POSITION_X, GreaterThanCondition(100.0f));
+  PropertyNotification notification2 = actor.AddPropertyNotification(Actor::Property::SIZE, StepCondition( 1.0f, 1.0f ));
   DALI_TEST_CHECK( notification );
+  DALI_TEST_CHECK( notification2 );
   END_TEST;
 }
 
@@ -282,6 +284,18 @@ int UtcDaliAddPropertyNotificationEventSidePropertyN(void)
   END_TEST;
 }
 
+int UtcDaliAddPropertyNotificationSize(void)
+{
+  TestApplication application;
+  tet_infoline(" UtcDaliAddPropertyNotificationSize");
+
+  Actor actor = Actor::New();
+
+  PropertyNotification notification = actor.AddPropertyNotification(Actor::Property::SIZE, StepCondition( 1.0f, 1.0f ));
+  DALI_TEST_CHECK( notification );
+  END_TEST;
+}
+
 int UtcDaliPropertyNotificationGetCondition(void)
 {
   TestApplication application;
@@ -747,6 +761,46 @@ int UtcDaliPropertyNotificationVectorComponentOutside(void)
   END_TEST;
 }
 
+int UtcDaliPropertyNotificationSetSizeResultP(void)
+{
+  TestApplication application;
+  bool notifyResult;
+  tet_infoline(" UtcDaliPropertyNotificationSetSizeResultP");
+
+  Actor actor = Actor::New();
+
+  PropertyNotification notification = actor.AddPropertyNotification( Actor::Property::SIZE, StepCondition( 1.0f, 1.0f ) );
+  notification.SetNotifyMode(PropertyNotification::NotifyOnChanged);
+  gCallBackCalled = false;
+  notification.NotifySignal().Connect( &TestCallback );
+
+  actor.SetSize(100.0f, 100.0f);
+
+  application.Render(RENDER_FRAME_INTERVAL);
+  application.SendNotification();
+  application.Render(RENDER_FRAME_INTERVAL);
+  application.SendNotification();
+
+  notifyResult = notification.GetNotifyResult();
+
+  DALI_TEST_EQUALS( notifyResult, true, TEST_LOCATION );
+
+  gCallBackCalled = false;
+
+  actor.SetSize(200.0f, 200.0f);
+
+  application.Render(RENDER_FRAME_INTERVAL);
+  application.SendNotification();
+  application.Render(RENDER_FRAME_INTERVAL);
+  application.SendNotification();
+
+  notifyResult = notification.GetNotifyResult();
+
+  DALI_TEST_EQUALS( notifyResult, true, TEST_LOCATION );
+
+  END_TEST;
+}
+
 int UtcDaliPropertyConditionGetArguments(void)
 {
   TestApplication application;
index 7e407cabbabe3abfa9751c1c445c37ab6ae87136..ab1260e4fc2ac96250a3589bbe20e46a687cc4d4 100644 (file)
@@ -22,6 +22,7 @@
 #include <dali/public-api/common/dali-common.h>
 #include <dali/public-api/math/vector2.h>
 #include <dali/public-api/math/radian.h>
+#include <dali/public-api/actors/actor.h>
 #include <dali/internal/event/actors/actor-impl.h>
 #include <dali/internal/event/common/property-notification-manager.h>
 #include <dali/internal/event/common/object-impl.h>
@@ -68,7 +69,8 @@ PropertyNotification::PropertyNotification( UpdateManager& updateManager,
   mComponentIndex( componentIndex ),
   mCondition( condition ),
   mNotifyMode( Dali::PropertyNotification::NotifyOnTrue ),
-  mNotifyResult( false )
+  mNotifyResult( false ),
+  mCompare( false )
 {
   const Internal::PropertyCondition& conditionImpl = GetImplementation( condition );
 
@@ -101,6 +103,18 @@ PropertyNotification::PropertyNotification( UpdateManager& updateManager,
       }
     }
 
+  // In Size Property case, swapping components occurs sometimes.
+  // To cover swapping components, previous and current components should be compared.
+  if( mObjectPropertyIndex == Dali::Actor::Property::SIZE
+      && mObject->GetPropertyType(mObjectPropertyIndex) == Property::VECTOR3 )
+  {
+    mCompare = true;
+    for( int i = 0; i < 3; ++i )
+    {
+      mRawConditionArgs.PushBack( 0.0f );
+    }
+  }
+
     // all objects always have scene object
     CreateSceneObject();
   }
@@ -206,7 +220,8 @@ void PropertyNotification::CreateSceneObject()
                                                                    mComponentIndex,
                                                                    GetImplementation( mCondition ).type,
                                                                    mRawConditionArgs,
-                                                                   mNotifyMode );
+                                                                   mNotifyMode,
+                                                                   mCompare );
     OwnerPointer< SceneGraph::PropertyNotification > transferOwnership( const_cast<SceneGraph::PropertyNotification*>( mPropertyNotification ) );
     AddPropertyNotificationMessage( mUpdateManager, transferOwnership );
   }
index 6810b4f36ecfea4defcb741382f3778ac9612636..79ccb0766a1c70d301c4e0aa7f0bab3b3dbf3225 100644 (file)
@@ -196,6 +196,7 @@ private:
   RawArgumentContainer         mRawConditionArgs;             ///< The Raw Condition args. (float type)
   NotifyMode                   mNotifyMode;                   ///< The current notification mode.
   bool                         mNotifyResult;                 ///< The result of the last condition check that caused a signal emit
+  bool                         mCompare;                      ///< The flag of comparing previous property's raw value and current.
 };
 
 } // namespace Internal
index e305d42897010985f175bf68348142e6aef52a82..78cc1112ffe227d3490bb1961648d636ac957f39 100644 (file)
@@ -37,6 +37,9 @@ namespace
 const int32_t ARGINDEX_REF_VALUE = 0;
 const int32_t ARGINDEX_STEP_SIZE = 1;
 const int32_t ARGINDEX_CURRENT_STEP = 2;
+const int32_t ARGINDEX_FIRST_VALUE = 3;
+const int32_t ARGINDEX_SECOND_VALUE = 4;
+const int32_t ARGINDEX_THIRD_VALUE = 5;
 
 } // namespace
 
@@ -81,6 +84,21 @@ ConditionFunction Step::GetFunction(Property::Type valueType)
   return function;
 }
 
+ConditionFunction Step::GetCompareFunction( Property::Type valueType )
+{
+    ConditionFunction function = NULL;
+    if( valueType == Property::VECTOR3 )
+    {
+      function = EvalAndCompareVector3;
+    }
+    else
+    {
+      function = GetFunction( valueType );
+    }
+
+    return function;
+}
+
 bool Step::Evaluate( const float propertyValue, PropertyNotification::RawArgumentContainer& arg )
 {
   const float refValue = arg[ARGINDEX_REF_VALUE];
@@ -111,6 +129,7 @@ bool Step::EvalFloat( const Dali::PropertyInput& value, PropertyNotification::Ra
   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();
@@ -123,7 +142,26 @@ bool Step::EvalVector3( const Dali::PropertyInput& value, PropertyNotification::
   return Evaluate( propertyValue, arg );
 }
 
-bool Step::EvalVector4( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg )
+bool Step::EvalAndCompareVector3( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg )
+{
+  float propertyValue = value.GetVector3().LengthSquared();
+  bool result = Evaluate( propertyValue, arg );
+  if( result == false )
+  {
+    if( ( fabsf( arg[ARGINDEX_FIRST_VALUE] - value.GetVector3().x ) > Math::MACHINE_EPSILON_1 )
+        || ( fabsf( arg[ARGINDEX_SECOND_VALUE] - value.GetVector3().y ) > Math::MACHINE_EPSILON_1 )
+        || ( fabsf( arg[ARGINDEX_THIRD_VALUE] - value.GetVector3().z ) > Math::MACHINE_EPSILON_1 ) )
+    {
+      result = true;
+    }
+  }
+  arg[ARGINDEX_FIRST_VALUE] = value.GetVector3().x;
+  arg[ARGINDEX_SECOND_VALUE] = value.GetVector3().y;
+  arg[ARGINDEX_THIRD_VALUE] = value.GetVector3().z;
+  return result;
+}
+
+bool Step::EvalVector4( const  Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg )
 {
   const float propertyValue = value.GetVector4().LengthSquared();
   return Evaluate( propertyValue, arg );
index c500b8ea5d6d2b366c343e6aebecb549bbd3c5aa..c7a801abb80503d9d048ad2d18f1acfbece60972 100644 (file)
@@ -55,6 +55,14 @@ public:
    */
   static ConditionFunction GetFunction( Property::Type valueType );
 
+  /**
+   * @return function pointer to the correct condition function, based on
+   * the type of value being examined.
+   *
+   * This function pointer is to compare previous and current components for the swapping case.
+   */
+  static ConditionFunction GetCompareFunction( Property::Type valueType );
+
 private:
 
   static bool Evaluate( const float propertyValue, PropertyNotification::RawArgumentContainer& arg );
@@ -91,6 +99,17 @@ private:
    */
   static bool EvalVector3( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg );
 
+  /**
+   * Checks if Vector3.Length() is Outside
+   *
+   * If previous Vector3.Lenght() and current are same, the raw datas are checked with comparing these values.
+   *
+   * @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 EvalAndCompareVector3( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg );
+
   /**
    * Checks if Vector4.Length() is Outside
    * @param[in] value The value being examined.
@@ -106,7 +125,6 @@ private:
    * @return Condition result (true if condition met, false if not)
    */
   static bool EvalDefault( const Dali::PropertyInput& value, PropertyNotification::RawArgumentContainer& arg );
-
 };
 
 } // namespace SceneGraph
index 82464fc55c5e94587af588da7eccd4e8b8888546..57a78eb61dafb71d3e6d7e22fc0b53f02009e353 100644 (file)
@@ -39,9 +39,10 @@ PropertyNotification* PropertyNotification::New(Object& object,
                                                 int componentIndex,
                                                 ConditionType condition,
                                                 RawArgumentContainer& arguments,
-                                                NotifyMode notifyMode)
+                                                NotifyMode notifyMode,
+                                                bool compare)
 {
-  return new PropertyNotification( object, propertyIndex, propertyType, componentIndex, condition, arguments, notifyMode );
+  return new PropertyNotification( object, propertyIndex, propertyType, componentIndex, condition, arguments, notifyMode, compare );
 }
 
 
@@ -51,7 +52,8 @@ PropertyNotification::PropertyNotification(Object& object,
                                            int componentIndex,
                                            ConditionType condition,
                                            RawArgumentContainer& arguments,
-                                           NotifyMode notifyMode)
+                                           NotifyMode notifyMode,
+                                           bool compare)
 : mObject(&object),
   mPropertyIndex(propertyIndex),
   mPropertyType(propertyType),
@@ -89,7 +91,14 @@ PropertyNotification::PropertyNotification(Object& object,
     }
     case PropertyCondition::Step:
     {
-      mConditionFunction = Step::GetFunction(mPropertyType);
+      if( compare == true )
+      {
+        mConditionFunction = Step::GetCompareFunction(mPropertyType);
+      }
+      else
+      {
+        mConditionFunction = Step::GetFunction(mPropertyType);
+      }
       break;
     }
     case PropertyCondition::VariableStep:
@@ -147,8 +156,8 @@ bool PropertyNotification::Check( BufferIndex bufferIndex )
   }
 
   if( mValid != currentValid
-      || (currentValid && ((mConditionType == PropertyCondition::Step)
-                        || (mConditionType == PropertyCondition::VariableStep))) )
+      || ( currentValid && ( ( mConditionType == PropertyCondition::Step )
+                        || ( mConditionType == PropertyCondition::VariableStep ) ) ) )
   {
     mValid = currentValid;
     //  means don't notify so notifyRequired stays false
index 5f124b97e23ed32f6468dcdf004f1cdef6152a2d..9bc139c474574d2c1ab22b524299c73b49f9d94e 100644 (file)
@@ -65,6 +65,7 @@ public:
    * @param[in] condition The condition type (e.g. LessThan, GreaterThan...)
    * @param[in] arguments The arguments which accompany the condition.
    * @param[in] notifyMode The notification mode setting
+   * @param[in] compare The flag of comparing the previous and current data.
    * @return A new PropertyNotification object.
    */
   static PropertyNotification* New(Object& object,
@@ -73,7 +74,8 @@ public:
                                    int componentIndex,
                                    ConditionType condition,
                                    RawArgumentContainer& arguments,
-                                   NotifyMode notifyMode);
+                                   NotifyMode notifyMode,
+                                   bool compare);
 
   /**
    * Virtual destructor
@@ -121,7 +123,8 @@ protected:
                        int componentIndex,
                        ConditionType condition,
                        RawArgumentContainer& arguments,
-                       NotifyMode notifyMode);
+                       NotifyMode notifyMode,
+                       bool compare);
 
 private: