Reduce Render::Renderer size
[platform/core/uifw/dali-core.git] / dali / internal / event / actors / actor-relayouter.h
1 #ifndef DALI_INTERNAL_ACTOR_RELAYOUTER_H
2 #define DALI_INTERNAL_ACTOR_RELAYOUTER_H
3
4 /*
5  * Copyright (c) 2021 Samsung Electronics Co., Ltd.
6  *
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
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
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.
18  *
19  */
20
21 // INTERNAL INCLUDES
22 #include <dali/internal/event/actors/actor-impl.h>
23
24 #include <dali/public-api/math/vector2.h>
25 #include <dali/public-api/math/vector3.h>
26
27 namespace Dali
28 {
29 namespace Internal
30 {
31 /**
32  * Struct to do some actor specific relayouting and store related variables
33  */
34 struct ActorSizer::Relayouter
35 {
36   // Defaults
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;
41
42   /// Constructor
43   Relayouter();
44
45   /// Default Destructor
46   ~Relayouter() = default;
47
48   /// @copydoc Actor::GetResizePolicy
49   ResizePolicy::Type GetResizePolicy(Dimension::Type dimension) const;
50
51   /// @copydoc Actor::ApplySizeSetPolicy
52   Vector2 ApplySizeSetPolicy(Internal::Actor& actor, const Vector2& size);
53
54   /// @copydoc Actor::SetUseAssignedSize
55   void SetUseAssignedSize(bool use, Dimension::Type dimension);
56
57   /// @copydoc Actor::GetUseAssignedSize
58   bool GetUseAssignedSize(Dimension::Type dimension) const;
59
60   /// @copydoc Actor::SetMinimumSize
61   void SetMinimumSize(float size, Dimension::Type dimension);
62
63   /// @copydoc Actor::GetMinimumSize
64   float GetMinimumSize(Dimension::Type dimension) const;
65
66   /// @copydoc Actor::SetMaximumSize
67   void SetMaximumSize(float size, Dimension::Type dimension);
68
69   /// @copydoc Actor::GetMaximumSize
70   float GetMaximumSize(Dimension::Type dimension) const;
71
72   /// @copydoc Actor::SetResizePolicy
73   void SetResizePolicy(ResizePolicy::Type policy, Dimension::Type dimension, Vector3& targetSize);
74
75   /// @copydoc Actor::GetRelayoutDependentOnDimension
76   bool GetRelayoutDependentOnDimension(Dimension::Type dimension, Dimension::Type dependency);
77
78   /// @copydoc Actor::SetDimensionDependency
79   void SetDimensionDependency(Dimension::Type dimension, Dimension::Type dependency);
80
81   /// @copydoc Actor::GetDimensionDependency
82   Dimension::Type GetDimensionDependency(Dimension::Type dimension) const;
83
84   /// @copydoc Actor::SetLayoutDirty
85   void SetLayoutDirty(bool dirty, Dimension::Type dimension);
86
87   /// @copydoc Actor::IsLayoutDirty
88   bool IsLayoutDirty(Dimension::Type dimension) const;
89
90   /// @copydoc Actor::SetNegotiatedDimension
91   void SetNegotiatedDimension(float negotiatedDimension, Dimension::Type dimension);
92
93   /// @copydoc Actor::GetNegotiatedDimension
94   float GetNegotiatedDimension(Dimension::Type dimension);
95
96   /// @copydoc Actor::SetPadding
97   void SetPadding(const Vector2& padding, Dimension::Type dimension);
98
99   /// @copydoc Actor::GetPadding
100   Vector2 GetPadding(Dimension::Type dimension);
101
102   /// @copydoc Actor::SetLayoutNegotiated
103   void SetLayoutNegotiated(bool negotiated, Dimension::Type dimension);
104
105   /// @copydoc Actor::IsLayoutNegotiated
106   bool IsLayoutNegotiated(Dimension::Type dimension) const;
107
108 public:
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
111
112   Dimension::Type dimensionDependencies[Dimension::DIMENSION_COUNT]; ///< A list of dimension dependencies
113
114   Vector2 dimensionPadding[Dimension::DIMENSION_COUNT]; ///< Padding for each dimension. X = start (e.g. left, bottom), y = end (e.g. right, top)
115
116   float negotiatedDimensions[Dimension::DIMENSION_COUNT]; ///< Storage for when a dimension is negotiated but before set on actor
117
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
120
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
123
124   Vector3 sizeModeFactor; ///< Factor of size used for certain SizeModes
125
126   Vector2 preferredSize; ///< The preferred size of the actor
127
128   SizeScalePolicy::Type sizeSetPolicy : 3; ///< Policy to apply when setting size. Enough room for the enum
129
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.
133 };
134
135 } // namespace Internal
136
137 } // namespace Dali
138
139 #endif // DALI_INTERNAL_ACTOR_RELAYOUTER_H