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