1 #ifndef DALI_INTERNAL_ACTOR_RELAYOUTER_H
2 #define DALI_INTERNAL_ACTOR_RELAYOUTER_H
5 * Copyright (c) 2021 Samsung Electronics Co., Ltd.
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
22 #include <dali/internal/event/actors/actor-impl.h>
24 #include <dali/public-api/math/vector2.h>
25 #include <dali/public-api/math/vector3.h>
32 * Struct to do some actor specific relayouting and store related variables
34 struct ActorSizer::Relayouter
37 static constexpr Vector3 DEFAULT_SIZE_MODE_FACTOR{1.0f, 1.0f, 1.0f};
38 static constexpr Vector2 DEFAULT_PREFERRED_SIZE{0.0f, 0.0f};
39 static constexpr Vector2 DEFAULT_DIMENSION_PADDING{0.0f, 0.0f};
40 static constexpr SizeScalePolicy::Type DEFAULT_SIZE_SCALE_POLICY = SizeScalePolicy::USE_SIZE_SET;
45 /// Default Destructor
46 ~Relayouter() = default;
48 /// @copydoc Actor::GetResizePolicy
49 ResizePolicy::Type GetResizePolicy(Dimension::Type dimension) const;
51 /// @copydoc Actor::ApplySizeSetPolicy
52 Vector2 ApplySizeSetPolicy(Internal::Actor& actor, const Vector2& size);
54 /// @copydoc Actor::SetUseAssignedSize
55 void SetUseAssignedSize(bool use, Dimension::Type dimension);
57 /// @copydoc Actor::GetUseAssignedSize
58 bool GetUseAssignedSize(Dimension::Type dimension) const;
60 /// @copydoc Actor::SetMinimumSize
61 void SetMinimumSize(float size, Dimension::Type dimension);
63 /// @copydoc Actor::GetMinimumSize
64 float GetMinimumSize(Dimension::Type dimension) const;
66 /// @copydoc Actor::SetMaximumSize
67 void SetMaximumSize(float size, Dimension::Type dimension);
69 /// @copydoc Actor::GetMaximumSize
70 float GetMaximumSize(Dimension::Type dimension) const;
72 /// @copydoc Actor::SetResizePolicy
73 void SetResizePolicy(ResizePolicy::Type policy, Dimension::Type dimension, Vector3& targetSize);
75 /// @copydoc Actor::GetRelayoutDependentOnParent
76 bool GetRelayoutDependentOnParent(Dimension::Type dimension);
78 /// @copydoc Actor::GetRelayoutDependentOnChildren
79 bool GetRelayoutDependentOnChildren(Dimension::Type dimension);
81 /// @copydoc Actor::GetRelayoutDependentOnDimension
82 bool GetRelayoutDependentOnDimension(Dimension::Type dimension, Dimension::Type dependency);
84 /// @copydoc Actor::SetDimensionDependency
85 void SetDimensionDependency(Dimension::Type dimension, Dimension::Type dependency);
87 /// @copydoc Actor::GetDimensionDependency
88 Dimension::Type GetDimensionDependency(Dimension::Type dimension) const;
90 /// @copydoc Actor::SetLayoutDirty
91 void SetLayoutDirty(bool dirty, Dimension::Type dimension);
93 /// @copydoc Actor::IsLayoutDirty
94 bool IsLayoutDirty(Dimension::Type dimension) const;
96 /// @copydoc Actor::SetNegotiatedDimension
97 void SetNegotiatedDimension(float negotiatedDimension, Dimension::Type dimension);
99 /// @copydoc Actor::GetNegotiatedDimension
100 float GetNegotiatedDimension(Dimension::Type dimension);
102 /// @copydoc Actor::SetPadding
103 void SetPadding(const Vector2& padding, Dimension::Type dimension);
105 /// @copydoc Actor::GetPadding
106 Vector2 GetPadding(Dimension::Type dimension);
108 /// @copydoc Actor::SetLayoutNegotiated
109 void SetLayoutNegotiated(bool negotiated, Dimension::Type dimension);
111 /// @copydoc Actor::IsLayoutNegotiated
112 bool IsLayoutNegotiated(Dimension::Type dimension) const;
115 ResizePolicy::Type resizePolicies[Dimension::DIMENSION_COUNT]; ///< Resize policies
116 bool useAssignedSize[Dimension::DIMENSION_COUNT]; ///< The flag to specify whether the size should be assigned to the actor
118 Dimension::Type dimensionDependencies[Dimension::DIMENSION_COUNT]; ///< A list of dimension dependencies
120 Vector2 dimensionPadding[Dimension::DIMENSION_COUNT]; ///< Padding for each dimension. X = start (e.g. left, bottom), y = end (e.g. right, top)
122 float negotiatedDimensions[Dimension::DIMENSION_COUNT]; ///< Storage for when a dimension is negotiated but before set on actor
124 float minimumSize[Dimension::DIMENSION_COUNT]; ///< The minimum size an actor can be
125 float maximumSize[Dimension::DIMENSION_COUNT]; ///< The maximum size an actor can be
127 bool dimensionNegotiated[Dimension::DIMENSION_COUNT]; ///< Has the dimension been negotiated
128 bool dimensionDirty[Dimension::DIMENSION_COUNT]; ///< Flags indicating whether the layout dimension is dirty or not
130 Vector3 sizeModeFactor; ///< Factor of size used for certain SizeModes
132 Vector2 preferredSize; ///< The preferred size of the actor
134 SizeScalePolicy::Type sizeSetPolicy : 3; ///< Policy to apply when setting size. Enough room for the enum
136 bool relayoutEnabled : 1; ///< Flag to specify if this actor should be included in size negotiation or not (defaults to true)
137 bool insideRelayout : 1; ///< Locking flag to prevent recursive relayouts on size set
138 bool relayoutRequested : 1; ///< Whether the relayout is requested.
141 } // namespace Internal
145 #endif // DALI_INTERNAL_ACTOR_RELAYOUTER_H