/*
- * Copyright (c) 2022 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2023 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.
END_TEST;
}
+int UtcDaliActorSetSize05(void)
+{
+ TestApplication application;
+
+ Actor parent = Actor::New();
+ Vector2 vector(200.0f, 200.0f);
+ DALI_TEST_CHECK(vector != parent.GetCurrentProperty<Vector2>(Actor::Property::SIZE));
+
+ parent.SetProperty(Actor::Property::SIZE, vector);
+ Vector2 size = parent.GetProperty(Actor::Property::SIZE).Get<Vector2>();
+ DALI_TEST_EQUALS(size, vector, Math::MACHINE_EPSILON_0, TEST_LOCATION);
+
+ Actor child = Actor::New();
+ DALI_TEST_CHECK(vector != child.GetCurrentProperty<Vector2>(Actor::Property::SIZE));
+ child.SetProperty(Actor::Property::SIZE, vector);
+ size = parent.GetProperty(Actor::Property::SIZE).Get<Vector2>();
+ DALI_TEST_EQUALS(size, vector, Math::MACHINE_EPSILON_0, TEST_LOCATION);
+
+ // flush the queue and render once
+ application.SendNotification();
+ application.Render();
+
+ DALI_TEST_CHECK(vector == parent.GetCurrentProperty<Vector2>(Actor::Property::SIZE));
+
+ END_TEST;
+}
+
int UtcDaliActorSetSizeIndividual(void)
{
TestApplication application;
/*
- * Copyright (c) 2021 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2023 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.
return FLT_MAX; // Default
}
-void ActorSizer::Relayouter::SetResizePolicy(ResizePolicy::Type policy, Dimension::Type dimension, Vector3& targetSize)
+void ActorSizer::Relayouter::SetResizePolicy(ResizePolicy::Type policy, Dimension::Type dimension, Vector3& targetSize, bool& targetSizeDirtyFlag)
{
ResizePolicy::Type originalWidthPolicy = GetResizePolicy(Dimension::WIDTH);
ResizePolicy::Type originalHeightPolicy = GetResizePolicy(Dimension::HEIGHT);
}
else if(originalWidthPolicy == ResizePolicy::FIXED && policy != ResizePolicy::FIXED)
{
- targetSize.width = preferredSize.width;
+ targetSize.width = preferredSize.width;
+ targetSizeDirtyFlag = true;
}
}
}
else if(originalHeightPolicy == ResizePolicy::FIXED && policy != ResizePolicy::FIXED)
{
- targetSize.height = preferredSize.height;
+ targetSize.height = preferredSize.height;
+ targetSizeDirtyFlag = true;
}
}
}
#define DALI_INTERNAL_ACTOR_RELAYOUTER_H
/*
- * Copyright (c) 2021 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2023 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.
float GetMaximumSize(Dimension::Type dimension) const;
/// @copydoc Actor::SetResizePolicy
- void SetResizePolicy(ResizePolicy::Type policy, Dimension::Type dimension, Vector3& targetSize);
+ void SetResizePolicy(ResizePolicy::Type policy, Dimension::Type dimension, Vector3& targetSize, bool& targetSizeDirtyFlag);
/// @copydoc Actor::GetRelayoutDependentOnDimension
bool GetRelayoutDependentOnDimension(Dimension::Type dimension, Dimension::Type dependency);
/*
- * Copyright (c) 2022 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2023 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.
mTargetSize(Vector3::ZERO),
mAnimatedSize(Vector3::ZERO),
mUseAnimatedSize(AnimatedSizeFlag::CLEAR),
+ mTargetSizeDirtyFlag(false),
mInsideOnSizeSet(false)
{
}
// dont allow recursive loop
DALI_ASSERT_ALWAYS(!mInsideOnSizeSet && "Cannot call SetSize from OnSizeSet");
// check that we have a node AND the new size width, height or depth is at least a little bit different from the old one
- bool changeTargetSize = false;
-
- if((fabsf(mTargetSize.width - size.width) > Math::MACHINE_EPSILON_1) ||
- (fabsf(mTargetSize.height - size.height) > Math::MACHINE_EPSILON_1) ||
- (fabsf(mTargetSize.depth - size.depth) > Math::MACHINE_EPSILON_1))
- {
- changeTargetSize = true;
- }
- else
- {
- // Check if currentSize it difference with target size.
- Vector3 currentSize = mOwner.GetCurrentSize();
- if((fabsf(mTargetSize.width - currentSize.width) > Math::MACHINE_EPSILON_1) ||
- (fabsf(mTargetSize.height - currentSize.height) > Math::MACHINE_EPSILON_1) ||
- (fabsf(mTargetSize.depth - currentSize.depth) > Math::MACHINE_EPSILON_1))
- {
- changeTargetSize = true;
- }
- }
-
- if(changeTargetSize)
+ if(mTargetSize != size || mTargetSizeDirtyFlag)
{
- mTargetSize = size;
+ mTargetSizeDirtyFlag = false;
+ mTargetSize = size;
// Update the preferred size after relayoutting
// It should be used in the next relayoutting
void ActorSizer::SetResizePolicy(ResizePolicy::Type policy, Dimension::Type dimension)
{
- EnsureRelayouter().SetResizePolicy(policy, dimension, mTargetSize);
+ EnsureRelayouter().SetResizePolicy(policy, dimension, mTargetSize, mTargetSizeDirtyFlag);
mOwner.OnSetResizePolicy(policy, dimension);
RelayoutRequest();
}
#define DALI_INTERNAL_ACTOR_SIZER_H
/*
- * Copyright (c) 2021 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2023 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.
Vector2 GetPreferredSize() const;
private:
- Internal::Actor& mOwner; // Owner of this actor sizer
- Relayouter* mRelayoutData; ///< Struct to hold optional collection of relayout variables
- Dali::Vector3 mTargetSize; ///< Event-side storage for size (not a pointer as most actors will have a size)
- Dali::Vector3 mAnimatedSize; ///< Event-side storage for size animation
- uint16_t mUseAnimatedSize; ///< Whether the size is animated.
+ Internal::Actor& mOwner; // Owner of this actor sizer
+ Relayouter* mRelayoutData; ///< Struct to hold optional collection of relayout variables
+ Dali::Vector3 mTargetSize; ///< Event-side storage for size (not a pointer as most actors will have a size)
+ Dali::Vector3 mAnimatedSize; ///< Event-side storage for size animation
+ uint16_t mUseAnimatedSize; ///< Whether the size is animated.
+ bool mTargetSizeDirtyFlag; ///< Whether the target size is dirty or not.
bool mInsideOnSizeSet : 1;
};