Added signal for layout direction 25/145525/6
authortaeyoon0.lee <taeyoon0.lee@samsung.com>
Tue, 22 Aug 2017 15:17:24 +0000 (00:17 +0900)
committertaeyoon0.lee <taeyoon0.lee@samsung.com>
Fri, 25 Aug 2017 13:46:57 +0000 (22:46 +0900)
Change-Id: Ib29281a44e6d8bdcbe6df56360b11643c0186d53

automated-tests/src/dali/utc-Dali-Actor.cpp
dali/devel-api/actors/actor-devel.cpp
dali/devel-api/actors/actor-devel.h
dali/internal/event/actors/actor-impl.cpp
dali/internal/event/actors/actor-impl.h

index bb9d9a4..98a6362 100644 (file)
@@ -51,6 +51,8 @@ bool gHoverCallBackCalled=false;
 
 static bool gTestConstraintCalled;
 
+DevelActor::LayoutDirection::Type gLayoutDirectionType;
+
 struct TestConstraint
 {
   void operator()( Vector4& color, const PropertyInputContainer& /* inputs */ )
@@ -6121,6 +6123,12 @@ int utcDaliActorVisibilityChangeSignalAfterAnimation(void)
   END_TEST;
 }
 
+
+static void LayoutDirectionChanged( Actor actor, DevelActor::LayoutDirection::Type type )
+{
+  gLayoutDirectionType = type;
+}
+
 int UtcDaliActorLayoutDirectionProperty(void)
 {
   TestApplication application;
@@ -6153,9 +6161,12 @@ int UtcDaliActorLayoutDirectionProperty(void)
   DALI_TEST_EQUALS( actor9.GetProperty< std::string >( DevelActor::Property::LAYOUT_DIRECTION ), "LTR", TEST_LOCATION );
 
   actor1.Add( actor2 );
-  actor1.SetProperty( DevelActor::Property::LAYOUT_DIRECTION, "RTL" );
+  gLayoutDirectionType = DevelActor::LayoutDirection::LTR;
+  DevelActor::LayoutDirectionChangedSignal( actor2 ).Connect( LayoutDirectionChanged );
+  actor1.SetProperty( DevelActor::Property::LAYOUT_DIRECTION, DevelActor::LayoutDirection::RTL );
   DALI_TEST_EQUALS( actor1.GetProperty< std::string >( DevelActor::Property::LAYOUT_DIRECTION ), "RTL", TEST_LOCATION );
   DALI_TEST_EQUALS( actor2.GetProperty< std::string >( DevelActor::Property::LAYOUT_DIRECTION ), "RTL", TEST_LOCATION );
+  DALI_TEST_EQUALS( gLayoutDirectionType, DevelActor::LayoutDirection::RTL, TEST_LOCATION );
 
   actor0.Add( actor1 );
   DALI_TEST_EQUALS( actor1.GetProperty< std::string >( DevelActor::Property::LAYOUT_DIRECTION ), "LTR", TEST_LOCATION );
@@ -6169,7 +6180,7 @@ int UtcDaliActorLayoutDirectionProperty(void)
   actor7.Add( actor8 );
   actor8.Add( actor9 );
   actor3.SetProperty( DevelActor::Property::LAYOUT_DIRECTION, "RTL" );
-  actor5.SetProperty( DevelActor::Property::LAYOUT_DIRECTION, "LTR" );
+  actor5.SetProperty( DevelActor::Property::LAYOUT_DIRECTION, DevelActor::LayoutDirection::LTR );
 
   DALI_TEST_EQUALS( actor8.GetProperty< bool >( DevelActor::Property::LAYOUT_DIRECTION_INHERITANCE ), true, TEST_LOCATION );
   actor8.SetProperty( DevelActor::Property::LAYOUT_DIRECTION_INHERITANCE, false );
index 38f081e..52b4cf1 100644 (file)
@@ -60,6 +60,11 @@ VisibilityChangedSignalType& VisibilityChangedSignal( Actor actor )
   return GetImplementation( actor ).VisibilityChangedSignal();
 }
 
+LayoutDirectionChangedSignalType& LayoutDirectionChangedSignal( Actor actor )
+{
+  return GetImplementation( actor ).LayoutDirectionChangedSignal();
+}
+
 } // namespace DevelActor
 
 } // namespace Dali
index 1c23a46..22085a9 100644 (file)
@@ -155,7 +155,9 @@ enum Type
 
 } // namespace
 
-typedef Signal< void ( Actor, bool, VisibilityChange::Type ) > VisibilityChangedSignalType; ///< Signal type of VisibilityChangedSignal
+typedef Signal< void ( Actor, bool, VisibilityChange::Type ) > VisibilityChangedSignalType; ///< Signal type of VisibilityChangedSignalType
+
+typedef Signal< void ( Actor, LayoutDirection::Type ) > LayoutDirectionChangedSignalType; ///< Signal type of LayoutDirectionChangedSignal
 
 /**
  * @brief Raise actor above the next highest level of actor(s).
@@ -242,6 +244,20 @@ DALI_IMPORT_API void LowerBelow( Actor actor, Dali::Actor target );
  */
 DALI_IMPORT_API VisibilityChangedSignalType& VisibilityChangedSignal( Actor actor );
 
+/**
+ * @brief This signal is emitted when the layout direction property of this or a parent actor is changed.
+ *
+ * A callback of the following type may be connected:
+ * @code
+ *   void YourCallbackName( Actor actor, LayoutDirection::Type type );
+ * @endcode
+ * actor: The actor, or child of actor, whose laytou direction has changed
+ * type: Whether the actor's layout direction property has changed or a parent's.
+ * @return The signal to connect to
+ * @pre The Actor has been initialized.
+ */
+DALI_IMPORT_API LayoutDirectionChangedSignalType& LayoutDirectionChangedSignal( Actor actor );
+
 } // namespace DevelActor
 
 } // namespace Dali
index ff11642..5a97133 100644 (file)
@@ -1994,6 +1994,15 @@ void Actor::EmitVisibilityChangedSignal( bool visible, DevelActor::VisibilityCha
   }
 }
 
+void Actor::EmitLayoutDirectionChangedSignal( DevelActor::LayoutDirection::Type type )
+{
+  if( ! mLayoutDirectionChangedSignal.Empty() )
+  {
+    Dali::Actor handle( this );
+    mLayoutDirectionChangedSignal.Emit( handle, type );
+  }
+}
+
 Dali::Actor::TouchSignalType& Actor::TouchedSignal()
 {
   return mTouchedSignal;
@@ -2034,6 +2043,11 @@ DevelActor::VisibilityChangedSignalType& Actor::VisibilityChangedSignal()
   return mVisibilityChangedSignal;
 }
 
+DevelActor::LayoutDirectionChangedSignalType& Actor::LayoutDirectionChangedSignal()
+{
+  return mLayoutDirectionChangedSignal;
+}
+
 bool Actor::DoConnectSignal( BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor )
 {
   bool connected( true );
@@ -5326,6 +5340,7 @@ void Actor::InheritLayoutDirectionRecursively( ActorPtr actor, Dali::DevelActor:
     if( actor->mLayoutDirection != direction)
     {
       actor->mLayoutDirection = direction;
+      actor->EmitLayoutDirectionChangedSignal( direction );
       actor->RelayoutRequest();
     }
 
index feef540..5b3098c 100644 (file)
@@ -1419,6 +1419,12 @@ public:
   void EmitVisibilityChangedSignal( bool visible, DevelActor::VisibilityChange::Type type );
 
   /**
+   * @brief Emits the layout direction change signal for this actor and all its children.
+   * @param[in] type Whether the actor's layout direction property has changed or a parent's.
+   */
+  void EmitLayoutDirectionChangedSignal( DevelActor::LayoutDirection::Type type );
+
+  /**
    * @copydoc Dali::Actor::TouchedSignal()
    */
   Dali::Actor::TouchSignalType& TouchedSignal();
@@ -1459,6 +1465,11 @@ public:
   DevelActor::VisibilityChangedSignalType& VisibilityChangedSignal();
 
   /**
+   * @copydoc DevelActor::LayoutDirectionChangedSignal
+   */
+  DevelActor::LayoutDirectionChangedSignalType& LayoutDirectionChangedSignal();
+
+  /**
    * Connects a callback function with the object's signals.
    * @param[in] object The object providing the signal.
    * @param[in] tracker Used to disconnect the signal.
@@ -1940,6 +1951,7 @@ protected:
   Dali::Actor::OffStageSignalType          mOffStageSignal;
   Dali::Actor::OnRelayoutSignalType        mOnRelayoutSignal;
   DevelActor::VisibilityChangedSignalType  mVisibilityChangedSignal;
+  DevelActor::LayoutDirectionChangedSignalType  mLayoutDirectionChangedSignal;
 
   Quaternion      mTargetOrientation; ///< Event-side storage for orientation
   Vector4         mTargetColor;       ///< Event-side storage for color