auto& actorImpl = GetImplementation(actor);
DALI_TEST_EQUALS(testActorImpl.IsRelayoutEnabled(), false, TEST_LOCATION);
- DALI_TEST_CHECK(true);
+
+ // With no relayouting, there are no default dependencies
+ DALI_TEST_EQUALS(actorImpl.RelayoutDependentOnParent(Dimension::ALL_DIMENSIONS), false, TEST_LOCATION);
+
+ // But, current broken behaviour is to depend on children. Retain this behaviour for now.
+ DALI_TEST_EQUALS(testActorImpl.RelayoutDependentOnChildren(Dimension::ALL_DIMENSIONS), true, TEST_LOCATION);
actor.SetResizePolicy(ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS);
actor[Dali::Actor::Property::SIZE] = Vector2(150.0f, 100.0f); // Should automatically set preferred size
int UtcDaliCustomActorImplRelayoutDependentOnChildrenBase(void)
{
TestApplication application;
- Test::TestCustomActor custom = Test::TestCustomActor::NewNegoSize();
- custom.SetResizePolicy(Dali::ResizePolicy::FIT_TO_CHILDREN, Dali::Dimension::ALL_DIMENSIONS);
+ Test::TestCustomActor customNego = Test::TestCustomActor::NewNegoSize();
+ Test::TestCustomActor customNotNego = Test::TestCustomActor::New();
+
+ // A custom actor with default flags has relayouting enabled on initialization,
+ // and the default resize policy is USE_NATURAL_SIZE.
+ bool v = customNego.TestRelayoutDependentOnChildrenBase(Dali::Dimension::ALL_DIMENSIONS);
+ DALI_TEST_CHECK(v == true);
- bool v = custom.TestRelayoutDependentOnChildrenBase(Dali::Dimension::ALL_DIMENSIONS);
+ // A custom actor with size negotiation explicitly switched off has no relayouting,
+ // and will not have any relayout dependencies. However, default resize policy when
+ // there is no relayouting is to return USE_NATURAL_SIZE, so this will actually return true,
+ // and is consistent.
+ v = customNotNego.TestRelayoutDependentOnChildrenBase(Dali::Dimension::ALL_DIMENSIONS);
DALI_TEST_CHECK(v == true);
+ customNego.SetResizePolicy(Dali::ResizePolicy::FIT_TO_CHILDREN, Dali::Dimension::ALL_DIMENSIONS);
+ customNotNego.SetResizePolicy(Dali::ResizePolicy::FIT_TO_CHILDREN, Dali::Dimension::ALL_DIMENSIONS);
+
+ v = customNego.TestRelayoutDependentOnChildrenBase(Dali::Dimension::ALL_DIMENSIONS);
+ DALI_TEST_CHECK(v == true);
+ v = customNotNego.TestRelayoutDependentOnChildrenBase(Dali::Dimension::ALL_DIMENSIONS);
+ DALI_TEST_CHECK(v == true);
+
+ application.SendNotification();
+ application.Render();
+
+ customNego.SetResizePolicy(Dali::ResizePolicy::FIXED, Dali::Dimension::ALL_DIMENSIONS);
+ customNotNego.SetResizePolicy(Dali::ResizePolicy::FIXED, Dali::Dimension::ALL_DIMENSIONS);
+ v = customNego.TestRelayoutDependentOnChildrenBase(Dali::Dimension::WIDTH);
+ DALI_TEST_CHECK(v == false);
+ v = customNego.TestRelayoutDependentOnChildrenBase(Dali::Dimension::HEIGHT);
+ DALI_TEST_CHECK(v == false);
+ v = customNotNego.TestRelayoutDependentOnChildrenBase(Dali::Dimension::WIDTH);
+ DALI_TEST_CHECK(v == false);
+ v = customNotNego.TestRelayoutDependentOnChildrenBase(Dali::Dimension::HEIGHT);
+ DALI_TEST_CHECK(v == false);
+
application.SendNotification();
application.Render();
- custom.SetResizePolicy(Dali::ResizePolicy::FIXED, Dali::Dimension::ALL_DIMENSIONS);
- v = custom.TestRelayoutDependentOnChildrenBase(Dali::Dimension::WIDTH);
+ customNego.SetResizePolicy(Dali::ResizePolicy::USE_NATURAL_SIZE, Dali::Dimension::WIDTH);
+ customNotNego.SetResizePolicy(Dali::ResizePolicy::USE_NATURAL_SIZE, Dali::Dimension::HEIGHT);
+ v = customNego.TestRelayoutDependentOnChildrenBase(Dali::Dimension::WIDTH);
+ DALI_TEST_CHECK(v == true);
+ v = customNego.TestRelayoutDependentOnChildrenBase(Dali::Dimension::HEIGHT);
DALI_TEST_CHECK(v == false);
+ v = customNotNego.TestRelayoutDependentOnChildrenBase(Dali::Dimension::WIDTH);
+ DALI_TEST_CHECK(v == false);
+ v = customNotNego.TestRelayoutDependentOnChildrenBase(Dali::Dimension::HEIGHT);
+ DALI_TEST_CHECK(v == true);
END_TEST;
}
}
}
-bool ActorSizer::Relayouter::GetRelayoutDependentOnParent(Dimension::Type dimension)
-{
- // Check if actor is dependent on parent
- for(uint32_t i = 0; i < Dimension::DIMENSION_COUNT; ++i)
- {
- if((dimension & (1 << i)))
- {
- const ResizePolicy::Type resizePolicy = GetResizePolicy(static_cast<Dimension::Type>(1 << i));
- if(resizePolicy == ResizePolicy::FILL_TO_PARENT || resizePolicy == ResizePolicy::SIZE_RELATIVE_TO_PARENT || resizePolicy == ResizePolicy::SIZE_FIXED_OFFSET_FROM_PARENT)
- {
- return true;
- }
- }
- }
- return false;
-}
-
-bool ActorSizer::Relayouter::GetRelayoutDependentOnChildren(Dimension::Type dimension)
-{
- // Check if actor is dependent on children
- for(uint32_t i = 0; i < Dimension::DIMENSION_COUNT; ++i)
- {
- if((dimension & (1 << i)))
- {
- const ResizePolicy::Type resizePolicy = GetResizePolicy(static_cast<Dimension::Type>(1 << i));
- if(resizePolicy == ResizePolicy::FIT_TO_CHILDREN || resizePolicy == ResizePolicy::USE_NATURAL_SIZE)
- {
- return true;
- }
- break;
- }
- }
-
- return false;
-}
-
bool ActorSizer::Relayouter::GetRelayoutDependentOnDimension(Dimension::Type dimension, Dimension::Type dependency)
{
// Check each possible dimension and see if it is dependent on the input one
/// @copydoc Actor::SetResizePolicy
void SetResizePolicy(ResizePolicy::Type policy, Dimension::Type dimension, Vector3& targetSize);
- /// @copydoc Actor::GetRelayoutDependentOnParent
- bool GetRelayoutDependentOnParent(Dimension::Type dimension);
-
- /// @copydoc Actor::GetRelayoutDependentOnChildren
- bool GetRelayoutDependentOnChildren(Dimension::Type dimension);
-
/// @copydoc Actor::GetRelayoutDependentOnDimension
bool GetRelayoutDependentOnDimension(Dimension::Type dimension, Dimension::Type dependency);
return 0.0f;
}
-/**
- * @brief Default relayout dependent on parent when relayout is not setuped before.
- */
-static constexpr bool DEFAULT_RELAYOUT_DEPENDENT_ON_PARENT = ((Dali::ResizePolicy::DEFAULT == Dali::ResizePolicy::FILL_TO_PARENT) ||
- (Dali::ResizePolicy::DEFAULT == Dali::ResizePolicy::SIZE_RELATIVE_TO_PARENT) ||
- (Dali::ResizePolicy::DEFAULT == Dali::ResizePolicy::SIZE_FIXED_OFFSET_FROM_PARENT));
-
-/**
- * @brief Default relayout dependent on child when relayout is not setuped before.
- */
-static constexpr bool DEFAULT_RELAYOUT_DEPENDENT_ON_CHILD = ((Dali::ResizePolicy::DEFAULT == Dali::ResizePolicy::FIT_TO_CHILDREN) ||
- (Dali::ResizePolicy::DEFAULT == Dali::ResizePolicy::USE_NATURAL_SIZE));
-
} // namespace
namespace Dali::Internal
bool ActorSizer::RelayoutDependentOnParent(Dimension::Type dimension)
{
- return mRelayoutData ? mRelayoutData->GetRelayoutDependentOnParent(dimension) : DEFAULT_RELAYOUT_DEPENDENT_ON_PARENT;
+ // If there is no relayouting, GetResizePolicy returns Default, which is USE_NATURAL_SIZE. This
+ // will keep the existing behaviour, and return false.
+
+ // Check if actor is dependent on parent
+ for(uint32_t i = 0; i < Dimension::DIMENSION_COUNT; ++i)
+ {
+ if((dimension & (1 << i)))
+ {
+ const ResizePolicy::Type resizePolicy = GetResizePolicy(static_cast<Dimension::Type>(1 << i));
+ if(resizePolicy == ResizePolicy::FILL_TO_PARENT || resizePolicy == ResizePolicy::SIZE_RELATIVE_TO_PARENT || resizePolicy == ResizePolicy::SIZE_FIXED_OFFSET_FROM_PARENT)
+ {
+ return true;
+ }
+ }
+ }
+
+ return false;
}
bool ActorSizer::RelayoutDependentOnChildrenBase(Dimension::Type dimension)
{
- return mRelayoutData ? mRelayoutData->GetRelayoutDependentOnChildren(dimension) : DEFAULT_RELAYOUT_DEPENDENT_ON_CHILD;
+ // If there is no relayouting, GetResizePolicy returns Default, which is USE_NATURAL_SIZE.
+ // This means this will return true when there is no relayouting, but that seems
+ // counter-intuitive. Will keep current behaviour for now, as it is consistent.
+
+ // Check if actor is dependent on children
+ for(uint32_t i = 0; i < Dimension::DIMENSION_COUNT; ++i)
+ {
+ if((dimension & (1 << i)))
+ {
+ const ResizePolicy::Type resizePolicy = GetResizePolicy(static_cast<Dimension::Type>(1 << i));
+ switch(resizePolicy)
+ {
+ case ResizePolicy::FIT_TO_CHILDREN:
+ case ResizePolicy::USE_NATURAL_SIZE: // i.e. For things that calculate their size based on children
+ {
+ return true;
+ }
+
+ default:
+ {
+ break;
+ }
+ }
+ }
+ }
+
+ return false;
}
bool ActorSizer::RelayoutDependentOnDimension(Dimension::Type dimension, Dimension::Type dependentDimension)