[dali_2.3.19] Merge branch 'devel/master'
[platform/core/uifw/dali-core.git] / dali / public-api / actors / actor.cpp
1 /*
2  * Copyright (c) 2021 Samsung Electronics Co., Ltd.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  */
17
18 // CLASS HEADER
19 #include <dali/public-api/actors/actor.h>
20
21 // INTERNAL INCLUDES
22 #include <dali/public-api/actors/layer.h>
23 #include <dali/public-api/animation/constraint.h>
24 #include <dali/public-api/common/dali-common.h>
25 #include <dali/public-api/math/radian.h>
26 #include <dali/public-api/math/vector2.h>
27
28 #include <dali/internal/common/const-string.h>
29 #include <dali/internal/event/actors/actor-impl.h>
30 #include <dali/internal/event/actors/layer-impl.h>
31 #include <dali/internal/event/animation/constraint-impl.h>
32 #include <dali/internal/event/rendering/renderer-impl.h>
33 #include <dali/internal/event/size-negotiation/relayout-controller-impl.h>
34
35 namespace Dali
36 {
37 Actor::Actor() = default;
38
39 Actor Actor::New()
40 {
41   Internal::ActorPtr internal = Internal::Actor::New();
42
43   return Actor(internal.Get());
44 }
45
46 Actor Actor::DownCast(BaseHandle handle)
47 {
48   return Actor(dynamic_cast<Dali::Internal::Actor*>(handle.GetObjectPtr()));
49 }
50
51 Actor::~Actor() = default;
52
53 Actor::Actor(const Actor& copy) = default;
54
55 Actor& Actor::operator=(const Actor& rhs) = default;
56
57 Actor::Actor(Actor&& rhs) noexcept = default;
58
59 Actor& Actor::operator=(Actor&& rhs) noexcept = default;
60
61 Layer Actor::GetLayer()
62 {
63   return GetImplementation(*this).GetLayer();
64 }
65
66 void Actor::Add(Actor actor)
67 {
68   GetImplementation(*this).Add(GetImplementation(actor));
69 }
70
71 void Actor::Remove(Actor actor)
72 {
73   GetImplementation(*this).Remove(GetImplementation(actor));
74 }
75
76 void Actor::Unparent()
77 {
78   GetImplementation(*this).Unparent();
79 }
80
81 uint32_t Actor::GetChildCount() const
82 {
83   return GetImplementation(*this).GetChildCount();
84 }
85
86 Actor Actor::GetChildAt(uint32_t index) const
87 {
88   Internal::ActorPtr child = GetImplementation(*this).GetChildAt(index);
89   return Actor(child.Get());
90 }
91
92 Actor Actor::FindChildByName(std::string_view actorName)
93 {
94   Internal::ActorPtr child = GetImplementation(*this).FindChildByName(Internal::ConstString(actorName));
95   return Actor(child.Get());
96 }
97
98 Actor Actor::FindChildById(const uint32_t id)
99 {
100   Internal::ActorPtr child = GetImplementation(*this).FindChildById(id);
101   return Actor(child.Get());
102 }
103
104 Actor Actor::GetParent() const
105 {
106   Internal::Actor* parent = GetImplementation(*this).GetParent();
107
108   return Actor(parent);
109 }
110
111 Vector3 Actor::GetTargetSize() const
112 {
113   return GetImplementation(*this).GetTargetSize();
114 }
115
116 Vector3 Actor::GetNaturalSize() const
117 {
118   return GetImplementation(*this).GetNaturalSize();
119 }
120
121 void Actor::TranslateBy(const Vector3& distance)
122 {
123   GetImplementation(*this).TranslateBy(distance);
124 }
125
126 void Actor::RotateBy(const Radian& angle, const Vector3& axis)
127 {
128   GetImplementation(*this).RotateBy(angle, axis);
129 }
130
131 void Actor::RotateBy(const Quaternion& relativeRotation)
132 {
133   GetImplementation(*this).RotateBy(relativeRotation);
134 }
135
136 void Actor::ScaleBy(const Vector3& relativeScale)
137 {
138   GetImplementation(*this).ScaleBy(relativeScale);
139 }
140
141 bool Actor::ScreenToLocal(float& localX, float& localY, float screenX, float screenY) const
142 {
143   return GetImplementation(*this).ScreenToLocal(localX, localY, screenX, screenY);
144 }
145
146 void Actor::Raise()
147 {
148   GetImplementation(*this).Raise();
149 }
150
151 void Actor::Lower()
152 {
153   GetImplementation(*this).Lower();
154 }
155
156 void Actor::RaiseToTop()
157 {
158   GetImplementation(*this).RaiseToTop();
159 }
160
161 void Actor::LowerToBottom()
162 {
163   GetImplementation(*this).LowerToBottom();
164 }
165
166 void Actor::RaiseAbove(Actor target)
167 {
168   GetImplementation(*this).RaiseAbove(GetImplementation(target));
169 }
170
171 void Actor::LowerBelow(Actor target)
172 {
173   GetImplementation(*this).LowerBelow(GetImplementation(target));
174 }
175
176 void Actor::SetResizePolicy(ResizePolicy::Type policy, Dimension::Type dimension)
177 {
178   GetImplementation(*this).SetResizePolicy(policy, dimension);
179 }
180
181 ResizePolicy::Type Actor::GetResizePolicy(Dimension::Type dimension) const
182 {
183   return GetImplementation(*this).GetResizePolicy(dimension);
184 }
185
186 float Actor::GetHeightForWidth(float width)
187 {
188   return GetImplementation(*this).GetHeightForWidth(width);
189 }
190
191 float Actor::GetWidthForHeight(float height)
192 {
193   return GetImplementation(*this).GetWidthForHeight(height);
194 }
195
196 float Actor::GetRelayoutSize(Dimension::Type dimension) const
197 {
198   return GetImplementation(*this).GetRelayoutSize(dimension);
199 }
200
201 Actor::TouchEventSignalType& Actor::TouchedSignal()
202 {
203   return GetImplementation(*this).TouchedSignal();
204 }
205
206 Actor::HoverSignalType& Actor::HoveredSignal()
207 {
208   return GetImplementation(*this).HoveredSignal();
209 }
210
211 Actor::WheelEventSignalType& Actor::WheelEventSignal()
212 {
213   return GetImplementation(*this).WheelEventSignal();
214 }
215
216 Actor::OnSceneSignalType& Actor::OnSceneSignal()
217 {
218   return GetImplementation(*this).OnSceneSignal();
219 }
220
221 Actor::OffSceneSignalType& Actor::OffSceneSignal()
222 {
223   return GetImplementation(*this).OffSceneSignal();
224 }
225
226 uint32_t Actor::AddRenderer(Renderer& renderer)
227 {
228   return GetImplementation(*this).AddRenderer(GetImplementation(renderer));
229 }
230
231 uint32_t Actor::GetRendererCount() const
232 {
233   return GetImplementation(*this).GetRendererCount();
234 }
235
236 Renderer Actor::GetRendererAt(uint32_t index)
237 {
238   Internal::RendererPtr renderer = GetImplementation(*this).GetRendererAt(index);
239   return Renderer(renderer.Get());
240 }
241
242 void Actor::RemoveRenderer(Renderer& renderer)
243 {
244   GetImplementation(*this).RemoveRenderer(GetImplementation(renderer));
245 }
246
247 void Actor::RemoveRenderer(uint32_t index)
248 {
249   GetImplementation(*this).RemoveRenderer(index);
250 }
251
252 Actor::OnRelayoutSignalType& Actor::OnRelayoutSignal()
253 {
254   return GetImplementation(*this).OnRelayoutSignal();
255 }
256
257 Actor::LayoutDirectionChangedSignalType& Actor::LayoutDirectionChangedSignal()
258 {
259   return GetImplementation(*this).LayoutDirectionChangedSignal();
260 }
261
262 Actor::Actor(Internal::Actor* internal)
263 : Handle(internal)
264 {
265 }
266
267 } // namespace Dali