+/**
+ * @brief Extract a given dimension from a Vector3
+ *
+ * @param[in] values The values to extract from
+ * @param[in] dimension The dimension to extract
+ * @return Return the value for the dimension
+ */
+float Actor::Relayouter::GetDimensionValue(const Vector3& values, const Dimension::Type dimension)
+{
+ return ::GetDimensionValue(values.GetVectorXY(), dimension);
+}
+
+float Actor::Relayouter::CalculateSize(Actor& actor, Dimension::Type dimension, const Vector2& maximumSize)
+{
+ switch(actor.GetResizePolicy(dimension))
+ {
+ case ResizePolicy::USE_NATURAL_SIZE:
+ {
+ return actor.GetNaturalSize(dimension);
+ }
+
+ case ResizePolicy::FIXED:
+ {
+ return ::GetDimensionValue(actor.GetPreferredSize(), dimension);
+ }
+
+ case ResizePolicy::USE_ASSIGNED_SIZE:
+ {
+ return ::GetDimensionValue(maximumSize, dimension);
+ }
+
+ case ResizePolicy::FILL_TO_PARENT:
+ case ResizePolicy::SIZE_RELATIVE_TO_PARENT:
+ case ResizePolicy::SIZE_FIXED_OFFSET_FROM_PARENT:
+ {
+ return NegotiateDimensionFromParent(actor, dimension);
+ }
+
+ case ResizePolicy::FIT_TO_CHILDREN:
+ {
+ return NegotiateDimensionFromChildren(actor, dimension);
+ }
+
+ case ResizePolicy::DIMENSION_DEPENDENCY:
+ {
+ const Dimension::Type dimensionDependency = actor.GetDimensionDependency(dimension);
+
+ // Custom rules
+ if(dimension == Dimension::WIDTH && dimensionDependency == Dimension::HEIGHT)
+ {
+ return actor.GetWidthForHeight(actor.GetNegotiatedDimension(Dimension::HEIGHT));
+ }
+
+ if(dimension == Dimension::HEIGHT && dimensionDependency == Dimension::WIDTH)
+ {
+ return actor.GetHeightForWidth(actor.GetNegotiatedDimension(Dimension::WIDTH));
+ }
+
+ break;
+ }
+
+ default:
+ {
+ break;
+ }
+ }
+
+ return 0.0f; // Default
+}
+
+float Actor::Relayouter::CalculateChildSize(Actor& actor, const Actor& child, Dimension::Type dimension)
+{
+ // Fill to parent, taking size mode factor into account
+ switch(child.GetResizePolicy(dimension))
+ {
+ case ResizePolicy::FILL_TO_PARENT:
+ {
+ return actor.GetLatestSize(dimension);
+ }
+
+ case ResizePolicy::SIZE_RELATIVE_TO_PARENT:
+ {
+ Property::Value value = child.GetProperty(Dali::Actor::Property::SIZE_MODE_FACTOR);
+ Vector3 childSizeModeFactor = value.Get<Vector3>();
+ return actor.GetLatestSize(dimension) * GetDimensionValue(childSizeModeFactor, dimension);
+ }
+
+ case ResizePolicy::SIZE_FIXED_OFFSET_FROM_PARENT:
+ {
+ Property::Value value = child.GetProperty(Dali::Actor::Property::SIZE_MODE_FACTOR);
+ Vector3 childSizeModeFactor = value.Get<Vector3>();
+ return actor.GetLatestSize(dimension) + GetDimensionValue(childSizeModeFactor, dimension);
+ }
+
+ default:
+ {
+ return actor.GetLatestSize(dimension);
+ }
+ }
+}
+