Merge "Clean up the code to build successfully on macOS" into devel/master
[platform/core/uifw/dali-core.git] / dali / public-api / actors / actor.cpp
1 /*
2  * Copyright (c) 2020 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/event/actors/actor-impl.h>
29 #include <dali/internal/event/actors/layer-impl.h>
30 #include <dali/internal/event/animation/constraint-impl.h>
31 #include <dali/internal/event/rendering/renderer-impl.h>
32 #include <dali/internal/event/size-negotiation/relayout-controller-impl.h>
33
34 namespace Dali
35 {
36 Actor::Actor() = default;
37
38 Actor Actor::New()
39 {
40   Internal::ActorPtr internal = Internal::Actor::New();
41
42   return Actor(internal.Get());
43 }
44
45 Actor Actor::DownCast(BaseHandle handle)
46 {
47   return Actor(dynamic_cast<Dali::Internal::Actor*>(handle.GetObjectPtr()));
48 }
49
50 Actor::~Actor() = default;
51
52 Actor::Actor(const Actor& copy) = default;
53
54 Actor& Actor::operator=(const Actor& rhs) = default;
55
56 Actor::Actor(Actor&& rhs) = default;
57
58 Actor& Actor::operator=(Actor&& rhs) = default;
59
60 Layer Actor::GetLayer()
61 {
62   return GetImplementation(*this).GetLayer();
63 }
64
65 void Actor::Add(Actor actor)
66 {
67   GetImplementation(*this).Add(GetImplementation(actor));
68 }
69
70 void Actor::Remove(Actor actor)
71 {
72   GetImplementation(*this).Remove(GetImplementation(actor));
73 }
74
75 void Actor::Unparent()
76 {
77   GetImplementation(*this).Unparent();
78 }
79
80 uint32_t Actor::GetChildCount() const
81 {
82   return GetImplementation(*this).GetChildCount();
83 }
84
85 Actor Actor::GetChildAt(uint32_t index) const
86 {
87   Internal::ActorPtr child = GetImplementation(*this).GetChildAt(index);
88   return Actor(child.Get());
89 }
90
91 Actor Actor::FindChildByName(const std::string& actorName)
92 {
93   Internal::ActorPtr child = GetImplementation(*this).FindChildByName(actorName);
94   return Actor(child.Get());
95 }
96
97 Actor Actor::FindChildById(const uint32_t id)
98 {
99   Internal::ActorPtr child = GetImplementation(*this).FindChildById(id);
100   return Actor(child.Get());
101 }
102
103 Actor Actor::GetParent() const
104 {
105   Internal::Actor* parent = GetImplementation(*this).GetParent();
106
107   return Actor(parent);
108 }
109
110 Vector3 Actor::GetTargetSize() const
111 {
112   return GetImplementation(*this).GetTargetSize();
113 }
114
115 Vector3 Actor::GetNaturalSize() const
116 {
117   return GetImplementation(*this).GetNaturalSize();
118 }
119
120 void Actor::TranslateBy(const Vector3& distance)
121 {
122   GetImplementation(*this).TranslateBy(distance);
123 }
124
125 void Actor::RotateBy(const Radian& angle, const Vector3& axis)
126 {
127   GetImplementation(*this).RotateBy(angle, axis);
128 }
129
130 void Actor::RotateBy(const Quaternion& relativeRotation)
131 {
132   GetImplementation(*this).RotateBy(relativeRotation);
133 }
134
135 void Actor::ScaleBy(const Vector3& relativeScale)
136 {
137   GetImplementation(*this).ScaleBy(relativeScale);
138 }
139
140 bool Actor::ScreenToLocal(float& localX, float& localY, float screenX, float screenY) const
141 {
142   return GetImplementation(*this).ScreenToLocal(localX, localY, screenX, screenY);
143 }
144
145 void Actor::Raise()
146 {
147   GetImplementation(*this).Raise();
148 }
149
150 void Actor::Lower()
151 {
152   GetImplementation(*this).Lower();
153 }
154
155 void Actor::RaiseToTop()
156 {
157   GetImplementation(*this).RaiseToTop();
158 }
159
160 void Actor::LowerToBottom()
161 {
162   GetImplementation(*this).LowerToBottom();
163 }
164
165 void Actor::RaiseAbove(Actor target)
166 {
167   GetImplementation(*this).RaiseAbove(GetImplementation(target));
168 }
169
170 void Actor::LowerBelow(Actor target)
171 {
172   GetImplementation(*this).LowerBelow(GetImplementation(target));
173 }
174
175 void Actor::SetResizePolicy(ResizePolicy::Type policy, Dimension::Type dimension)
176 {
177   GetImplementation(*this).SetResizePolicy(policy, dimension);
178 }
179
180 ResizePolicy::Type Actor::GetResizePolicy(Dimension::Type dimension) const
181 {
182   return GetImplementation(*this).GetResizePolicy(dimension);
183 }
184
185 float Actor::GetHeightForWidth(float width)
186 {
187   return GetImplementation(*this).GetHeightForWidth(width);
188 }
189
190 float Actor::GetWidthForHeight(float height)
191 {
192   return GetImplementation(*this).GetWidthForHeight(height);
193 }
194
195 float Actor::GetRelayoutSize(Dimension::Type dimension) const
196 {
197   return GetImplementation(*this).GetRelayoutSize(dimension);
198 }
199
200 Actor::TouchEventSignalType& Actor::TouchedSignal()
201 {
202   return GetImplementation(*this).TouchedSignal();
203 }
204
205 Actor::HoverSignalType& Actor::HoveredSignal()
206 {
207   return GetImplementation(*this).HoveredSignal();
208 }
209
210 Actor::WheelEventSignalType& Actor::WheelEventSignal()
211 {
212   return GetImplementation(*this).WheelEventSignal();
213 }
214
215 Actor::OnSceneSignalType& Actor::OnSceneSignal()
216 {
217   return GetImplementation(*this).OnSceneSignal();
218 }
219
220 Actor::OffSceneSignalType& Actor::OffSceneSignal()
221 {
222   return GetImplementation(*this).OffSceneSignal();
223 }
224
225 uint32_t Actor::AddRenderer(Renderer& renderer)
226 {
227   return GetImplementation(*this).AddRenderer(GetImplementation(renderer));
228 }
229
230 uint32_t Actor::GetRendererCount() const
231 {
232   return GetImplementation(*this).GetRendererCount();
233 }
234
235 Renderer Actor::GetRendererAt(uint32_t index)
236 {
237   Internal::RendererPtr renderer = GetImplementation(*this).GetRendererAt(index);
238   return Renderer(renderer.Get());
239 }
240
241 void Actor::RemoveRenderer(Renderer& renderer)
242 {
243   GetImplementation(*this).RemoveRenderer(GetImplementation(renderer));
244 }
245
246 void Actor::RemoveRenderer(uint32_t index)
247 {
248   GetImplementation(*this).RemoveRenderer(index);
249 }
250
251 Actor::OnRelayoutSignalType& Actor::OnRelayoutSignal()
252 {
253   return GetImplementation(*this).OnRelayoutSignal();
254 }
255
256 Actor::LayoutDirectionChangedSignalType& Actor::LayoutDirectionChangedSignal()
257 {
258   return GetImplementation(*this).LayoutDirectionChangedSignal();
259 }
260
261 Actor::Actor(Internal::Actor* internal)
262 : Handle(internal)
263 {
264 }
265
266 } // namespace Dali