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