2 * Copyright (c) 2021 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/common/const-string.h>
29 #include <dali/internal/event/actors/actor-impl.h>
30 #include <dali/internal/event/actors/layer-impl.h>
31 #include <dali/internal/event/animation/constraint-impl.h>
32 #include <dali/internal/event/rendering/renderer-impl.h>
33 #include <dali/internal/event/size-negotiation/relayout-controller-impl.h>
37 Actor::Actor() = default;
41 Internal::ActorPtr internal = Internal::Actor::New();
43 return Actor(internal.Get());
46 Actor Actor::DownCast(BaseHandle handle)
48 return Actor(dynamic_cast<Dali::Internal::Actor*>(handle.GetObjectPtr()));
51 Actor::~Actor() = default;
53 Actor::Actor(const Actor& copy) = default;
55 Actor& Actor::operator=(const Actor& rhs) = default;
57 Actor::Actor(Actor&& rhs) = default;
59 Actor& Actor::operator=(Actor&& rhs) = default;
61 Layer Actor::GetLayer()
63 return GetImplementation(*this).GetLayer();
66 void Actor::Add(Actor actor)
68 GetImplementation(*this).Add(GetImplementation(actor));
71 void Actor::Remove(Actor actor)
73 GetImplementation(*this).Remove(GetImplementation(actor));
76 void Actor::Unparent()
78 GetImplementation(*this).Unparent();
81 uint32_t Actor::GetChildCount() const
83 return GetImplementation(*this).GetChildCount();
86 Actor Actor::GetChildAt(uint32_t index) const
88 Internal::ActorPtr child = GetImplementation(*this).GetChildAt(index);
89 return Actor(child.Get());
92 Actor Actor::FindChildByName(std::string_view actorName)
94 Internal::ActorPtr child = GetImplementation(*this).FindChildByName(Internal::ConstString(actorName));
95 return Actor(child.Get());
98 Actor Actor::FindChildById(const uint32_t id)
100 Internal::ActorPtr child = GetImplementation(*this).FindChildById(id);
101 return Actor(child.Get());
104 Actor Actor::GetParent() const
106 Internal::Actor* parent = GetImplementation(*this).GetParent();
108 return Actor(parent);
111 Vector3 Actor::GetTargetSize() const
113 return GetImplementation(*this).GetTargetSize();
116 Vector3 Actor::GetNaturalSize() const
118 return GetImplementation(*this).GetNaturalSize();
121 void Actor::TranslateBy(const Vector3& distance)
123 GetImplementation(*this).TranslateBy(distance);
126 void Actor::RotateBy(const Radian& angle, const Vector3& axis)
128 GetImplementation(*this).RotateBy(angle, axis);
131 void Actor::RotateBy(const Quaternion& relativeRotation)
133 GetImplementation(*this).RotateBy(relativeRotation);
136 void Actor::ScaleBy(const Vector3& relativeScale)
138 GetImplementation(*this).ScaleBy(relativeScale);
141 bool Actor::ScreenToLocal(float& localX, float& localY, float screenX, float screenY) const
143 return GetImplementation(*this).ScreenToLocal(localX, localY, screenX, screenY);
148 GetImplementation(*this).Raise();
153 GetImplementation(*this).Lower();
156 void Actor::RaiseToTop()
158 GetImplementation(*this).RaiseToTop();
161 void Actor::LowerToBottom()
163 GetImplementation(*this).LowerToBottom();
166 void Actor::RaiseAbove(Actor target)
168 GetImplementation(*this).RaiseAbove(GetImplementation(target));
171 void Actor::LowerBelow(Actor target)
173 GetImplementation(*this).LowerBelow(GetImplementation(target));
176 void Actor::SetResizePolicy(ResizePolicy::Type policy, Dimension::Type dimension)
178 GetImplementation(*this).SetResizePolicy(policy, dimension);
181 ResizePolicy::Type Actor::GetResizePolicy(Dimension::Type dimension) const
183 return GetImplementation(*this).GetResizePolicy(dimension);
186 float Actor::GetHeightForWidth(float width)
188 return GetImplementation(*this).GetHeightForWidth(width);
191 float Actor::GetWidthForHeight(float height)
193 return GetImplementation(*this).GetWidthForHeight(height);
196 float Actor::GetRelayoutSize(Dimension::Type dimension) const
198 return GetImplementation(*this).GetRelayoutSize(dimension);
201 Actor::TouchEventSignalType& Actor::TouchedSignal()
203 return GetImplementation(*this).TouchedSignal();
206 Actor::HoverSignalType& Actor::HoveredSignal()
208 return GetImplementation(*this).HoveredSignal();
211 Actor::WheelEventSignalType& Actor::WheelEventSignal()
213 return GetImplementation(*this).WheelEventSignal();
216 Actor::OnSceneSignalType& Actor::OnSceneSignal()
218 return GetImplementation(*this).OnSceneSignal();
221 Actor::OffSceneSignalType& Actor::OffSceneSignal()
223 return GetImplementation(*this).OffSceneSignal();
226 uint32_t Actor::AddRenderer(Renderer& renderer)
228 return GetImplementation(*this).AddRenderer(GetImplementation(renderer));
231 uint32_t Actor::GetRendererCount() const
233 return GetImplementation(*this).GetRendererCount();
236 Renderer Actor::GetRendererAt(uint32_t index)
238 Internal::RendererPtr renderer = GetImplementation(*this).GetRendererAt(index);
239 return Renderer(renderer.Get());
242 void Actor::RemoveRenderer(Renderer& renderer)
244 GetImplementation(*this).RemoveRenderer(GetImplementation(renderer));
247 void Actor::RemoveRenderer(uint32_t index)
249 GetImplementation(*this).RemoveRenderer(index);
252 Actor::OnRelayoutSignalType& Actor::OnRelayoutSignal()
254 return GetImplementation(*this).OnRelayoutSignal();
257 Actor::LayoutDirectionChangedSignalType& Actor::LayoutDirectionChangedSignal()
259 return GetImplementation(*this).LayoutDirectionChangedSignal();
262 Actor::Actor(Internal::Actor* internal)