2 * Copyright (c) 2020 Samsung Electronics Co., Ltd.
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
19 #include <dali/public-api/actors/actor.h>
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>
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>
43 Internal::ActorPtr internal = Internal::Actor::New();
45 return Actor(internal.Get());
48 Actor Actor::DownCast( BaseHandle handle )
50 return Actor( dynamic_cast<Dali::Internal::Actor*>(handle.GetObjectPtr()) );
57 Actor::Actor(const Actor& copy)
62 Actor& Actor::operator=(const Actor& rhs)
64 BaseHandle::operator=(rhs);
68 uint32_t Actor::GetId() const
70 return GetImplementation(*this).GetId();
73 bool Actor::IsRoot() const
75 return GetImplementation(*this).IsRoot();
78 bool Actor::OnStage() const
80 return GetImplementation(*this).OnStage();
83 bool Actor::IsLayer() const
85 return GetImplementation(*this).IsLayer();
88 Layer Actor::GetLayer()
90 return GetImplementation(*this).GetLayer();
93 void Actor::Add(Actor actor)
95 GetImplementation(*this).Add(GetImplementation(actor));
98 void Actor::Remove(Actor actor)
100 GetImplementation(*this).Remove(GetImplementation(actor));
103 void Actor::Unparent()
105 GetImplementation(*this).Unparent();
108 uint32_t Actor::GetChildCount() const
110 return GetImplementation(*this).GetChildCount();
113 Actor Actor::GetChildAt( uint32_t index ) const
115 Internal::ActorPtr child = GetImplementation(*this).GetChildAt( index );
116 return Actor( child.Get() );
119 Actor Actor::FindChildByName(const std::string& actorName)
121 Internal::ActorPtr child = GetImplementation(*this).FindChildByName( actorName );
122 return Actor( child.Get() );
125 Actor Actor::FindChildById( const uint32_t id )
127 Internal::ActorPtr child = GetImplementation(*this).FindChildById( id );
128 return Actor( child.Get() );
131 Actor Actor::GetParent() const
133 Internal::Actor* parent = GetImplementation(*this).GetParent();
135 return Actor(parent);
138 void Actor::SetSize(float width, float height)
140 GetImplementation(*this).SetSize(width, height);
143 void Actor::SetSize(float width, float height, float depth)
145 GetImplementation(*this).SetSize(width, height, depth);
148 void Actor::SetSize(const Vector2& size)
150 GetImplementation(*this).SetSize( size );
153 void Actor::SetSize(const Vector3& size)
155 GetImplementation(*this).SetSize( size );
158 Vector3 Actor::GetTargetSize() const
160 return GetImplementation(*this).GetTargetSize();
163 Vector3 Actor::GetNaturalSize() const
165 return GetImplementation(*this).GetNaturalSize();
168 void Actor::SetPosition(float x, float y)
170 GetImplementation(*this).SetPosition(x, y);
173 void Actor::SetPosition(float x, float y, float z)
175 GetImplementation(*this).SetPosition(x, y, z);
178 void Actor::SetPosition(const Vector3& position)
180 GetImplementation(*this).SetPosition(position);
183 void Actor::SetX(float x)
185 GetImplementation(*this).SetX(x);
188 void Actor::SetY(float y)
190 GetImplementation(*this).SetY(y);
193 void Actor::SetZ(float z)
195 GetImplementation(*this).SetZ(z);
198 void Actor::TranslateBy(const Vector3& distance)
200 GetImplementation(*this).TranslateBy(distance);
203 void Actor::RotateBy(const Radian& angle, const Vector3& axis)
205 GetImplementation(*this).RotateBy(angle, axis);
208 void Actor::RotateBy(const Quaternion& relativeRotation)
210 GetImplementation(*this).RotateBy(relativeRotation);
213 void Actor::SetScale(float scale)
215 GetImplementation(*this).SetScale(scale);
218 void Actor::SetScale(float scaleX, float scaleY, float scaleZ)
220 GetImplementation(*this).SetScale(scaleX, scaleY, scaleZ);
223 void Actor::SetScale(const Vector3& scale)
225 GetImplementation(*this).SetScale(scale);
228 void Actor::ScaleBy(const Vector3& relativeScale)
230 GetImplementation(*this).ScaleBy(relativeScale);
233 bool Actor::ScreenToLocal(float& localX, float& localY, float screenX, float screenY) const
235 return GetImplementation(*this).ScreenToLocal(localX, localY, screenX, screenY);
238 void Actor::SetKeyboardFocusable( bool focusable )
240 GetImplementation(*this).SetKeyboardFocusable(focusable);
243 bool Actor::IsKeyboardFocusable() const
245 return GetImplementation(*this).IsKeyboardFocusable();
250 GetImplementation( *this ).Raise();
255 GetImplementation( *this ).Lower();
258 void Actor::RaiseToTop()
260 GetImplementation( *this ).RaiseToTop();
263 void Actor::LowerToBottom()
265 GetImplementation( *this ).LowerToBottom();
268 void Actor::RaiseAbove( Actor target )
270 GetImplementation( *this ).RaiseAbove( GetImplementation( target ) );
273 void Actor::LowerBelow( Actor target )
275 GetImplementation( *this ).LowerBelow( GetImplementation( target ) );
278 void Actor::SetResizePolicy( ResizePolicy::Type policy, Dimension::Type dimension )
280 GetImplementation(*this).SetResizePolicy( policy, dimension );
283 ResizePolicy::Type Actor::GetResizePolicy( Dimension::Type dimension ) const
285 return GetImplementation(*this).GetResizePolicy( dimension );
288 float Actor::GetHeightForWidth( float width )
290 return GetImplementation(*this).GetHeightForWidth( width );
293 float Actor::GetWidthForHeight( float height )
295 return GetImplementation(*this).GetWidthForHeight( height );
298 float Actor::GetRelayoutSize( Dimension::Type dimension ) const
300 return GetImplementation(*this).GetRelayoutSize( dimension );
303 int32_t Actor::GetHierarchyDepth()
305 return GetImplementation(*this).GetHierarchyDepth();
308 Actor::TouchSignalType& Actor::TouchedSignal()
310 DALI_LOG_WARNING_NOFN("DEPRECATION WARNING: TouchedSignal() is deprecated and will be removed from next release. Use TouchSignal() instead.\n" );
312 return GetImplementation(*this).TouchedSignal();
315 Actor::TouchDataSignalType& Actor::TouchSignal()
317 return GetImplementation( *this ).TouchSignal();
320 Actor::HoverSignalType& Actor::HoveredSignal()
322 return GetImplementation(*this).HoveredSignal();
325 Actor::WheelEventSignalType& Actor::WheelEventSignal()
327 return GetImplementation(*this).WheelEventSignal();
330 Actor::OnStageSignalType& Actor::OnStageSignal()
332 return GetImplementation(*this).OnStageSignal();
335 Actor::OffStageSignalType& Actor::OffStageSignal()
337 return GetImplementation(*this).OffStageSignal();
340 uint32_t Actor::AddRenderer( Renderer& renderer )
342 return GetImplementation(*this).AddRenderer( GetImplementation( renderer ) );
345 uint32_t Actor::GetRendererCount() const
347 return GetImplementation(*this).GetRendererCount();
350 Renderer Actor::GetRendererAt( uint32_t index )
352 Internal::RendererPtr renderer = GetImplementation(*this).GetRendererAt( index );
353 return Renderer( renderer.Get() );
356 void Actor::RemoveRenderer( Renderer& renderer )
358 GetImplementation(*this).RemoveRenderer( GetImplementation( renderer ) );
361 void Actor::RemoveRenderer( uint32_t index )
363 GetImplementation(*this).RemoveRenderer( index );
366 Actor::OnRelayoutSignalType& Actor::OnRelayoutSignal()
368 return GetImplementation(*this).OnRelayoutSignal();
371 Actor::LayoutDirectionChangedSignalType& Actor::LayoutDirectionChangedSignal()
373 return GetImplementation( *this ).LayoutDirectionChangedSignal();
376 Actor::Actor(Internal::Actor* internal)