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/animation/constraint-impl.h>
31 #include <dali/internal/event/rendering/renderer-impl.h>
32 #include <dali/internal/event/size-negotiation/relayout-controller-impl.h>
36 Actor::Actor() = default;
40 Internal::ActorPtr internal = Internal::Actor::New();
42 return Actor(internal.Get());
45 Actor Actor::DownCast(BaseHandle handle)
47 return Actor(dynamic_cast<Dali::Internal::Actor*>(handle.GetObjectPtr()));
50 Actor::~Actor() = default;
52 Actor::Actor(const Actor& copy) = default;
54 Actor& Actor::operator=(const Actor& rhs) = default;
56 Actor::Actor(Actor&& rhs) = default;
58 Actor& Actor::operator=(Actor&& rhs) = default;
60 Layer Actor::GetLayer()
62 return GetImplementation(*this).GetLayer();
65 void Actor::Add(Actor actor)
67 GetImplementation(*this).Add(GetImplementation(actor));
70 void Actor::Remove(Actor actor)
72 GetImplementation(*this).Remove(GetImplementation(actor));
75 void Actor::Unparent()
77 GetImplementation(*this).Unparent();
80 uint32_t Actor::GetChildCount() const
82 return GetImplementation(*this).GetChildCount();
85 Actor Actor::GetChildAt(uint32_t index) const
87 Internal::ActorPtr child = GetImplementation(*this).GetChildAt(index);
88 return Actor(child.Get());
91 Actor Actor::FindChildByName(const std::string& actorName)
93 Internal::ActorPtr child = GetImplementation(*this).FindChildByName(actorName);
94 return Actor(child.Get());
97 Actor Actor::FindChildById(const uint32_t id)
99 Internal::ActorPtr child = GetImplementation(*this).FindChildById(id);
100 return Actor(child.Get());
103 Actor Actor::GetParent() const
105 Internal::Actor* parent = GetImplementation(*this).GetParent();
107 return Actor(parent);
110 Vector3 Actor::GetTargetSize() const
112 return GetImplementation(*this).GetTargetSize();
115 Vector3 Actor::GetNaturalSize() const
117 return GetImplementation(*this).GetNaturalSize();
120 void Actor::TranslateBy(const Vector3& distance)
122 GetImplementation(*this).TranslateBy(distance);
125 void Actor::RotateBy(const Radian& angle, const Vector3& axis)
127 GetImplementation(*this).RotateBy(angle, axis);
130 void Actor::RotateBy(const Quaternion& relativeRotation)
132 GetImplementation(*this).RotateBy(relativeRotation);
135 void Actor::ScaleBy(const Vector3& relativeScale)
137 GetImplementation(*this).ScaleBy(relativeScale);
140 bool Actor::ScreenToLocal(float& localX, float& localY, float screenX, float screenY) const
142 return GetImplementation(*this).ScreenToLocal(localX, localY, screenX, screenY);
147 GetImplementation(*this).Raise();
152 GetImplementation(*this).Lower();
155 void Actor::RaiseToTop()
157 GetImplementation(*this).RaiseToTop();
160 void Actor::LowerToBottom()
162 GetImplementation(*this).LowerToBottom();
165 void Actor::RaiseAbove(Actor target)
167 GetImplementation(*this).RaiseAbove(GetImplementation(target));
170 void Actor::LowerBelow(Actor target)
172 GetImplementation(*this).LowerBelow(GetImplementation(target));
175 void Actor::SetResizePolicy(ResizePolicy::Type policy, Dimension::Type dimension)
177 GetImplementation(*this).SetResizePolicy(policy, dimension);
180 ResizePolicy::Type Actor::GetResizePolicy(Dimension::Type dimension) const
182 return GetImplementation(*this).GetResizePolicy(dimension);
185 float Actor::GetHeightForWidth(float width)
187 return GetImplementation(*this).GetHeightForWidth(width);
190 float Actor::GetWidthForHeight(float height)
192 return GetImplementation(*this).GetWidthForHeight(height);
195 float Actor::GetRelayoutSize(Dimension::Type dimension) const
197 return GetImplementation(*this).GetRelayoutSize(dimension);
200 Actor::TouchEventSignalType& Actor::TouchedSignal()
202 return GetImplementation(*this).TouchedSignal();
205 Actor::HoverSignalType& Actor::HoveredSignal()
207 return GetImplementation(*this).HoveredSignal();
210 Actor::WheelEventSignalType& Actor::WheelEventSignal()
212 return GetImplementation(*this).WheelEventSignal();
215 Actor::OnSceneSignalType& Actor::OnSceneSignal()
217 return GetImplementation(*this).OnSceneSignal();
220 Actor::OffSceneSignalType& Actor::OffSceneSignal()
222 return GetImplementation(*this).OffSceneSignal();
225 uint32_t Actor::AddRenderer(Renderer& renderer)
227 return GetImplementation(*this).AddRenderer(GetImplementation(renderer));
230 uint32_t Actor::GetRendererCount() const
232 return GetImplementation(*this).GetRendererCount();
235 Renderer Actor::GetRendererAt(uint32_t index)
237 Internal::RendererPtr renderer = GetImplementation(*this).GetRendererAt(index);
238 return Renderer(renderer.Get());
241 void Actor::RemoveRenderer(Renderer& renderer)
243 GetImplementation(*this).RemoveRenderer(GetImplementation(renderer));
246 void Actor::RemoveRenderer(uint32_t index)
248 GetImplementation(*this).RemoveRenderer(index);
251 Actor::OnRelayoutSignalType& Actor::OnRelayoutSignal()
253 return GetImplementation(*this).OnRelayoutSignal();
256 Actor::LayoutDirectionChangedSignalType& Actor::LayoutDirectionChangedSignal()
258 return GetImplementation(*this).LayoutDirectionChangedSignal();
261 Actor::Actor(Internal::Actor* internal)