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) = default;
59 Actor& Actor::operator=(const Actor& rhs) = default;
61 Actor::Actor( Actor&& rhs ) = default;
63 Actor& Actor::operator=( Actor&& rhs ) = default;
65 Layer Actor::GetLayer()
67 return GetImplementation(*this).GetLayer();
70 void Actor::Add(Actor actor)
72 GetImplementation(*this).Add(GetImplementation(actor));
75 void Actor::Remove(Actor actor)
77 GetImplementation(*this).Remove(GetImplementation(actor));
80 void Actor::Unparent()
82 GetImplementation(*this).Unparent();
85 uint32_t Actor::GetChildCount() const
87 return GetImplementation(*this).GetChildCount();
90 Actor Actor::GetChildAt( uint32_t index ) const
92 Internal::ActorPtr child = GetImplementation(*this).GetChildAt( index );
93 return Actor( child.Get() );
96 Actor Actor::FindChildByName(const std::string& actorName)
98 Internal::ActorPtr child = GetImplementation(*this).FindChildByName( actorName );
99 return Actor( child.Get() );
102 Actor Actor::FindChildById( const uint32_t id )
104 Internal::ActorPtr child = GetImplementation(*this).FindChildById( id );
105 return Actor( child.Get() );
108 Actor Actor::GetParent() const
110 Internal::Actor* parent = GetImplementation(*this).GetParent();
112 return Actor(parent);
115 Vector3 Actor::GetTargetSize() const
117 return GetImplementation(*this).GetTargetSize();
120 Vector3 Actor::GetNaturalSize() const
122 return GetImplementation(*this).GetNaturalSize();
125 void Actor::TranslateBy(const Vector3& distance)
127 GetImplementation(*this).TranslateBy(distance);
130 void Actor::RotateBy(const Radian& angle, const Vector3& axis)
132 GetImplementation(*this).RotateBy(angle, axis);
135 void Actor::RotateBy(const Quaternion& relativeRotation)
137 GetImplementation(*this).RotateBy(relativeRotation);
140 void Actor::ScaleBy(const Vector3& relativeScale)
142 GetImplementation(*this).ScaleBy(relativeScale);
145 bool Actor::ScreenToLocal(float& localX, float& localY, float screenX, float screenY) const
147 return GetImplementation(*this).ScreenToLocal(localX, localY, screenX, screenY);
152 GetImplementation( *this ).Raise();
157 GetImplementation( *this ).Lower();
160 void Actor::RaiseToTop()
162 GetImplementation( *this ).RaiseToTop();
165 void Actor::LowerToBottom()
167 GetImplementation( *this ).LowerToBottom();
170 void Actor::RaiseAbove( Actor target )
172 GetImplementation( *this ).RaiseAbove( GetImplementation( target ) );
175 void Actor::LowerBelow( Actor target )
177 GetImplementation( *this ).LowerBelow( GetImplementation( target ) );
180 void Actor::SetResizePolicy( ResizePolicy::Type policy, Dimension::Type dimension )
182 GetImplementation(*this).SetResizePolicy( policy, dimension );
185 ResizePolicy::Type Actor::GetResizePolicy( Dimension::Type dimension ) const
187 return GetImplementation(*this).GetResizePolicy( dimension );
190 float Actor::GetHeightForWidth( float width )
192 return GetImplementation(*this).GetHeightForWidth( width );
195 float Actor::GetWidthForHeight( float height )
197 return GetImplementation(*this).GetWidthForHeight( height );
200 float Actor::GetRelayoutSize( Dimension::Type dimension ) const
202 return GetImplementation(*this).GetRelayoutSize( dimension );
205 Actor::TouchSignalType& Actor::TouchedSignal()
207 DALI_LOG_WARNING_NOFN("DEPRECATION WARNING: TouchedSignal() is deprecated and will be removed from next release. Use TouchSignal() instead.\n" );
209 return GetImplementation(*this).TouchedSignal();
212 Actor::TouchDataSignalType& Actor::TouchSignal()
214 return GetImplementation( *this ).TouchSignal();
217 Actor::HoverSignalType& Actor::HoveredSignal()
219 return GetImplementation(*this).HoveredSignal();
222 Actor::WheelEventSignalType& Actor::WheelEventSignal()
224 return GetImplementation(*this).WheelEventSignal();
227 Actor::OnStageSignalType& Actor::OnStageSignal()
229 return GetImplementation(*this).OnStageSignal();
232 Actor::OffStageSignalType& Actor::OffStageSignal()
234 return GetImplementation(*this).OffStageSignal();
237 uint32_t Actor::AddRenderer( Renderer& renderer )
239 return GetImplementation(*this).AddRenderer( GetImplementation( renderer ) );
242 uint32_t Actor::GetRendererCount() const
244 return GetImplementation(*this).GetRendererCount();
247 Renderer Actor::GetRendererAt( uint32_t index )
249 Internal::RendererPtr renderer = GetImplementation(*this).GetRendererAt( index );
250 return Renderer( renderer.Get() );
253 void Actor::RemoveRenderer( Renderer& renderer )
255 GetImplementation(*this).RemoveRenderer( GetImplementation( renderer ) );
258 void Actor::RemoveRenderer( uint32_t index )
260 GetImplementation(*this).RemoveRenderer( index );
263 Actor::OnRelayoutSignalType& Actor::OnRelayoutSignal()
265 return GetImplementation(*this).OnRelayoutSignal();
268 Actor::LayoutDirectionChangedSignalType& Actor::LayoutDirectionChangedSignal()
270 return GetImplementation( *this ).LayoutDirectionChangedSignal();
273 Actor::Actor(Internal::Actor* internal)