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