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::GetRelayoutDependentOnDimension
76 bool GetRelayoutDependentOnDimension(Dimension::Type dimension, Dimension::Type dependency);
78 /// @copydoc Actor::SetDimensionDependency
79 void SetDimensionDependency(Dimension::Type dimension, Dimension::Type dependency);
81 /// @copydoc Actor::GetDimensionDependency
82 Dimension::Type GetDimensionDependency(Dimension::Type dimension) const;
84 /// @copydoc Actor::SetLayoutDirty
85 void SetLayoutDirty(bool dirty, Dimension::Type dimension);
87 /// @copydoc Actor::IsLayoutDirty
88 bool IsLayoutDirty(Dimension::Type dimension) const;
90 /// @copydoc Actor::SetNegotiatedDimension
91 void SetNegotiatedDimension(float negotiatedDimension, Dimension::Type dimension);
93 /// @copydoc Actor::GetNegotiatedDimension
94 float GetNegotiatedDimension(Dimension::Type dimension);
96 /// @copydoc Actor::SetPadding
97 void SetPadding(const Vector2& padding, Dimension::Type dimension);
99 /// @copydoc Actor::GetPadding
100 Vector2 GetPadding(Dimension::Type dimension);
102 /// @copydoc Actor::SetLayoutNegotiated
103 void SetLayoutNegotiated(bool negotiated, Dimension::Type dimension);
105 /// @copydoc Actor::IsLayoutNegotiated
106 bool IsLayoutNegotiated(Dimension::Type dimension) const;
109 ResizePolicy::Type resizePolicies[Dimension::DIMENSION_COUNT]; ///< Resize policies
110 bool useAssignedSize[Dimension::DIMENSION_COUNT]; ///< The flag to specify whether the size should be assigned to the actor
112 Dimension::Type dimensionDependencies[Dimension::DIMENSION_COUNT]; ///< A list of dimension dependencies
114 Vector2 dimensionPadding[Dimension::DIMENSION_COUNT]; ///< Padding for each dimension. X = start (e.g. left, bottom), y = end (e.g. right, top)
116 float negotiatedDimensions[Dimension::DIMENSION_COUNT]; ///< Storage for when a dimension is negotiated but before set on actor
118 float minimumSize[Dimension::DIMENSION_COUNT]; ///< The minimum size an actor can be
119 float maximumSize[Dimension::DIMENSION_COUNT]; ///< The maximum size an actor can be
121 bool dimensionNegotiated[Dimension::DIMENSION_COUNT]; ///< Has the dimension been negotiated
122 bool dimensionDirty[Dimension::DIMENSION_COUNT]; ///< Flags indicating whether the layout dimension is dirty or not
124 Vector3 sizeModeFactor; ///< Factor of size used for certain SizeModes
126 Vector2 preferredSize; ///< The preferred size of the actor
128 SizeScalePolicy::Type sizeSetPolicy : 3; ///< Policy to apply when setting size. Enough room for the enum
130 bool relayoutEnabled : 1; ///< Flag to specify if this actor should be included in size negotiation or not (defaults to true)
131 bool insideRelayout : 1; ///< Locking flag to prevent recursive relayouts on size set
132 bool relayoutRequested : 1; ///< Whether the relayout is requested.
135 } // namespace Internal
139 #endif // DALI_INTERNAL_ACTOR_RELAYOUTER_H