[Tizen] Revert the change for 0x0 size of the actor
[platform/core/uifw/dali-core.git] / dali / internal / event / actors / actor-impl.cpp
index a3504e5..2065436 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2018 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2020 Samsung Electronics Co., Ltd.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -1314,6 +1314,9 @@ void Actor::SetSizeScalePolicy( SizeScalePolicy::Type policy )
   EnsureRelayoutData();
 
   mRelayoutData->sizeSetPolicy = policy;
+
+  // Trigger relayout on this control
+  RelayoutRequest();
 }
 
 SizeScalePolicy::Type Actor::GetSizeScalePolicy() const
@@ -1779,7 +1782,7 @@ ActorGestureData& Actor::GetGestureData()
   return *mGestureData;
 }
 
-bool Actor::IsGestureRequred( Gesture::Type type ) const
+bool Actor::IsGestureRequred( DevelGesture::Type type ) const
 {
   return mGestureData && mGestureData->IsGestureRequred( type );
 }
@@ -2080,9 +2083,13 @@ Actor::~Actor()
   // Guard to allow handle destruction after Core has been destroyed
   if( EventThreadServices::IsCoreRunning() )
   {
-    DestroyNodeMessage( GetEventThreadServices().GetUpdateManager(), GetNode() );
+    // Root layer will destroy its node in its own destructor
+    if ( !mIsRoot )
+    {
+      DestroyNodeMessage( GetEventThreadServices().GetUpdateManager(), GetNode() );
 
-    GetEventThreadServices().UnregisterObject( this );
+      GetEventThreadServices().UnregisterObject( this );
+    }
   }
 
   // Cleanup optional gesture data
@@ -2489,7 +2496,16 @@ void Actor::SetDefaultProperty( Property::Index index, const Property::Value& pr
 
     case Dali::Actor::Property::COLOR:
     {
-      SetColor( property.Get< Vector4 >() );
+      Property::Type type = property.GetType();
+      if( type == Property::VECTOR3 )
+      {
+        Vector3 color = property.Get< Vector3 >();
+        SetColor( Vector4( color.r, color.g, color.b, 1.0f ) );
+      }
+      else if( type == Property::VECTOR4 )
+      {
+        SetColor( property.Get< Vector4 >() );
+      }
       break;
     }
 
@@ -2914,6 +2930,19 @@ void Actor::OnNotifyDefaultPropertyAnimation( Animation& animation, Property::In
         {
           if( value.Get( mTargetSize ) )
           {
+            if( mRelayoutData )
+            {
+              if( GetResizePolicy( Dimension::WIDTH ) == ResizePolicy::FIXED )
+              {
+                mRelayoutData->preferredSize.width = mTargetSize.width;
+              }
+
+              if( GetResizePolicy( Dimension::HEIGHT ) == ResizePolicy::FIXED )
+              {
+                mRelayoutData->preferredSize.height = mTargetSize.height;
+              }
+            }
+
             // Notify deriving classes
             OnSizeAnimation( animation, mTargetSize );
           }
@@ -2924,6 +2953,11 @@ void Actor::OnNotifyDefaultPropertyAnimation( Animation& animation, Property::In
         {
           if( value.Get( mTargetSize.width ) )
           {
+            if( mRelayoutData && GetResizePolicy( Dimension::WIDTH ) == ResizePolicy::FIXED )
+            {
+              mRelayoutData->preferredSize.width = mTargetSize.width;
+            }
+
             // Notify deriving classes
             OnSizeAnimation( animation, mTargetSize );
           }
@@ -2934,6 +2968,11 @@ void Actor::OnNotifyDefaultPropertyAnimation( Animation& animation, Property::In
         {
           if( value.Get( mTargetSize.height ) )
           {
+            if( mRelayoutData && GetResizePolicy( Dimension::HEIGHT ) == ResizePolicy::FIXED )
+            {
+              mRelayoutData->preferredSize.height = mTargetSize.height;
+            }
+
             // Notify deriving classes
             OnSizeAnimation( animation, mTargetSize );
           }
@@ -3058,6 +3097,19 @@ void Actor::OnNotifyDefaultPropertyAnimation( Animation& animation, Property::In
         {
           if( AdjustValue< Vector3 >( mTargetSize, value ) )
           {
+            if( mRelayoutData )
+            {
+              if( GetResizePolicy( Dimension::WIDTH ) == ResizePolicy::FIXED )
+              {
+                mRelayoutData->preferredSize.width = mTargetSize.width;
+              }
+
+              if( GetResizePolicy( Dimension::HEIGHT ) == ResizePolicy::FIXED )
+              {
+                mRelayoutData->preferredSize.height = mTargetSize.height;
+              }
+            }
+
             // Notify deriving classes
             OnSizeAnimation( animation, mTargetSize );
           }
@@ -3068,6 +3120,11 @@ void Actor::OnNotifyDefaultPropertyAnimation( Animation& animation, Property::In
         {
           if( AdjustValue< float >( mTargetSize.width, value ) )
           {
+            if( mRelayoutData && GetResizePolicy( Dimension::WIDTH ) == ResizePolicy::FIXED )
+            {
+              mRelayoutData->preferredSize.width = mTargetSize.width;
+            }
+
             // Notify deriving classes
             OnSizeAnimation( animation, mTargetSize );
           }
@@ -3078,6 +3135,11 @@ void Actor::OnNotifyDefaultPropertyAnimation( Animation& animation, Property::In
         {
           if( AdjustValue< float >( mTargetSize.height, value ) )
           {
+            if( mRelayoutData && GetResizePolicy( Dimension::HEIGHT ) == ResizePolicy::FIXED )
+            {
+              mRelayoutData->preferredSize.height = mTargetSize.height;
+            }
+
             // Notify deriving classes
             OnSizeAnimation( animation, mTargetSize );
           }
@@ -3465,6 +3527,15 @@ bool Actor::DoAction( BaseObject* object, const std::string& actionName, const P
   return done;
 }
 
+Rect<> Actor::CalculateScreenExtents( ) const
+{
+  auto screenPosition = GetCurrentScreenPosition();
+  Vector3 size = GetCurrentSize() * GetCurrentWorldScale();
+  Vector3 anchorPointOffSet = size * ( mPositionUsesAnchorPoint ? GetCurrentAnchorPoint() : AnchorPoint::TOP_LEFT );
+  Vector2 position = Vector2( screenPosition.x - anchorPointOffSet.x, screenPosition.y - anchorPointOffSet.y );
+  return { position.x, position.y, size.x, size.y };
+}
+
 bool Actor::GetCachedPropertyValue( Property::Index index, Property::Value& value ) const
 {
   bool valueSet = true;
@@ -4622,6 +4693,10 @@ void Actor::SetPreferredSize( const Vector2& size )
 {
   EnsureRelayoutData();
 
+  // If valid width or height, then set the resize policy to FIXED
+  // A 0 width or height may also be required so if the resize policy has not been changed, i.e. is still set to DEFAULT,
+  // then change to FIXED as well
+
   if( size.width > 0.0f )
   {
     SetResizePolicy( ResizePolicy::FIXED, Dimension::WIDTH );