Update the preferred size after relayoutting
[platform/core/uifw/dali-core.git] / dali / internal / event / actors / actor-property-handler.cpp
index 02fc9ce..cce13c8 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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.
@@ -25,6 +25,7 @@
 #include <dali/devel-api/actors/actor-devel.h>
 
 #include <dali/internal/event/actors/actor-impl.h>
+#include <dali/internal/event/actors/actor-relayouter.h>
 #include <dali/internal/event/common/property-helper.h>
 #include <dali/internal/update/nodes/node-declarations.h>
 #include <dali/internal/update/nodes/node-messages.h>
@@ -536,7 +537,7 @@ void Actor::PropertyHandler::SetDefaultProperty(Internal::Actor& actor, Property
 
       if(Scripting::GetEnumerationProperty<LayoutDirection::Type>(property, LAYOUT_DIRECTION_TABLE, LAYOUT_DIRECTION_TABLE_COUNT, direction))
       {
-        actor.InheritLayoutDirectionRecursively(direction, true);
+        actor.mParentImpl.InheritLayoutDirectionRecursively(direction, true);
       }
       break;
     }
@@ -577,12 +578,12 @@ void Actor::PropertyHandler::SetDefaultProperty(Internal::Actor& actor, Property
       break;
     }
 
-    case Dali::DevelActor::Property::TOUCH_AREA:
+    case Dali::DevelActor::Property::TOUCH_AREA_OFFSET:
     {
-      Vector2 vec2Value;
-      if(property.Get(vec2Value))
+      Rect<int> rectValue;
+      if(property.Get(rectValue))
       {
-        actor.SetTouchArea(vec2Value);
+        actor.SetTouchAreaOffset(rectValue);
       }
       break;
     }
@@ -597,6 +598,26 @@ void Actor::PropertyHandler::SetDefaultProperty(Internal::Actor& actor, Property
       break;
     }
 
+    case Dali::DevelActor::Property::TOUCH_FOCUSABLE:
+    {
+      bool value = false;
+      if(property.Get(value))
+      {
+        actor.SetTouchFocusable(value);
+      }
+      break;
+    }
+
+    case Dali::DevelActor::Property::KEYBOARD_FOCUSABLE_CHILDREN:
+    {
+      bool value = false;
+      if(property.Get(value))
+      {
+        actor.SetKeyboardFocusableChildren(value);
+      }
+      break;
+    }
+
     default:
     {
       // this can happen in the case of a non-animatable default property so just do nothing
@@ -781,6 +802,12 @@ void Actor::PropertyHandler::OnNotifyDefaultPropertyAnimation(Internal::Actor& a
             actor.mAnimatedSize    = actor.mTargetSize;
             actor.mUseAnimatedSize = AnimatedSizeFlag::WIDTH | AnimatedSizeFlag::HEIGHT | AnimatedSizeFlag::DEPTH;
 
+            if(actor.mRelayoutData && !actor.mRelayoutData->relayoutRequested)
+            {
+              actor.mRelayoutData->preferredSize.width  = actor.mAnimatedSize.width;
+              actor.mRelayoutData->preferredSize.height = actor.mAnimatedSize.height;
+            }
+
             // Notify deriving classes
             actor.OnSizeAnimation(animation, actor.mTargetSize);
           }
@@ -794,6 +821,11 @@ void Actor::PropertyHandler::OnNotifyDefaultPropertyAnimation(Internal::Actor& a
             actor.mAnimatedSize.width = actor.mTargetSize.width;
             actor.mUseAnimatedSize |= AnimatedSizeFlag::WIDTH;
 
+            if(actor.mRelayoutData && !actor.mRelayoutData->relayoutRequested)
+            {
+              actor.mRelayoutData->preferredSize.width = actor.mAnimatedSize.width;
+            }
+
             // Notify deriving classes
             actor.OnSizeAnimation(animation, actor.mTargetSize);
           }
@@ -807,6 +839,11 @@ void Actor::PropertyHandler::OnNotifyDefaultPropertyAnimation(Internal::Actor& a
             actor.mAnimatedSize.height = actor.mTargetSize.height;
             actor.mUseAnimatedSize |= AnimatedSizeFlag::HEIGHT;
 
+            if(actor.mRelayoutData && !actor.mRelayoutData->relayoutRequested)
+            {
+              actor.mRelayoutData->preferredSize.height = actor.mAnimatedSize.height;
+            }
+
             // Notify deriving classes
             actor.OnSizeAnimation(animation, actor.mTargetSize);
           }
@@ -937,6 +974,12 @@ void Actor::PropertyHandler::OnNotifyDefaultPropertyAnimation(Internal::Actor& a
             actor.mAnimatedSize    = actor.mTargetSize;
             actor.mUseAnimatedSize = AnimatedSizeFlag::WIDTH | AnimatedSizeFlag::HEIGHT | AnimatedSizeFlag::DEPTH;
 
+            if(actor.mRelayoutData && !actor.mRelayoutData->relayoutRequested)
+            {
+              actor.mRelayoutData->preferredSize.width  = actor.mAnimatedSize.width;
+              actor.mRelayoutData->preferredSize.height = actor.mAnimatedSize.height;
+            }
+
             // Notify deriving classes
             actor.OnSizeAnimation(animation, actor.mTargetSize);
           }
@@ -950,6 +993,11 @@ void Actor::PropertyHandler::OnNotifyDefaultPropertyAnimation(Internal::Actor& a
             actor.mAnimatedSize.width = actor.mTargetSize.width;
             actor.mUseAnimatedSize |= AnimatedSizeFlag::WIDTH;
 
+            if(actor.mRelayoutData && !actor.mRelayoutData->relayoutRequested)
+            {
+              actor.mRelayoutData->preferredSize.width = actor.mAnimatedSize.width;
+            }
+
             // Notify deriving classes
             actor.OnSizeAnimation(animation, actor.mTargetSize);
           }
@@ -963,6 +1011,11 @@ void Actor::PropertyHandler::OnNotifyDefaultPropertyAnimation(Internal::Actor& a
             actor.mAnimatedSize.height = actor.mTargetSize.height;
             actor.mUseAnimatedSize |= AnimatedSizeFlag::HEIGHT;
 
+            if(actor.mRelayoutData && !actor.mRelayoutData->relayoutRequested)
+            {
+              actor.mRelayoutData->preferredSize.height = actor.mAnimatedSize.height;
+            }
+
             // Notify deriving classes
             actor.OnSizeAnimation(animation, actor.mTargetSize);
           }
@@ -1634,9 +1687,9 @@ bool Actor::PropertyHandler::GetCachedPropertyValue(const Internal::Actor& actor
       break;
     }
 
-    case Dali::DevelActor::Property::TOUCH_AREA:
+    case Dali::DevelActor::Property::TOUCH_AREA_OFFSET:
     {
-      value = actor.GetTouchArea();
+      value = actor.GetTouchAreaOffset();
       break;
     }
 
@@ -1646,6 +1699,18 @@ bool Actor::PropertyHandler::GetCachedPropertyValue(const Internal::Actor& actor
       break;
     }
 
+    case Dali::DevelActor::Property::TOUCH_FOCUSABLE:
+    {
+      value = actor.IsTouchFocusable();
+      break;
+    }
+
+    case Dali::DevelActor::Property::KEYBOARD_FOCUSABLE_CHILDREN:
+    {
+      value = actor.AreChildrenKeyBoardFocusable();
+      break;
+    }
+
     default:
     {
       // Must be a scene-graph only property