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>
42 Internal::ActorPtr internal = Internal::Actor::New();
44 return Actor(internal.Get());
47 Actor Actor::DownCast(BaseHandle handle)
49 return Actor(dynamic_cast<Dali::Internal::Actor*>(handle.GetObjectPtr()));
56 Actor::Actor(const Actor& copy) = default;
58 Actor& Actor::operator=(const Actor& rhs) = default;
60 Actor::Actor(Actor&& rhs) = default;
62 Actor& Actor::operator=(Actor&& rhs) = default;
64 Layer Actor::GetLayer()
66 return GetImplementation(*this).GetLayer();
69 void Actor::Add(Actor actor)
71 GetImplementation(*this).Add(GetImplementation(actor));
74 void Actor::Remove(Actor actor)
76 GetImplementation(*this).Remove(GetImplementation(actor));
79 void Actor::Unparent()
81 GetImplementation(*this).Unparent();
84 uint32_t Actor::GetChildCount() const
86 return GetImplementation(*this).GetChildCount();
89 Actor Actor::GetChildAt(uint32_t index) const
91 Internal::ActorPtr child = GetImplementation(*this).GetChildAt(index);
92 return Actor(child.Get());
95 Actor Actor::FindChildByName(const std::string& actorName)
97 Internal::ActorPtr child = GetImplementation(*this).FindChildByName(actorName);
98 return Actor(child.Get());
101 Actor Actor::FindChildById(const uint32_t id)
103 Internal::ActorPtr child = GetImplementation(*this).FindChildById(id);
104 return Actor(child.Get());
107 Actor Actor::GetParent() const
109 Internal::Actor* parent = GetImplementation(*this).GetParent();
111 return Actor(parent);
114 Vector3 Actor::GetTargetSize() const
116 return GetImplementation(*this).GetTargetSize();
119 Vector3 Actor::GetNaturalSize() const
121 return GetImplementation(*this).GetNaturalSize();
124 void Actor::TranslateBy(const Vector3& distance)
126 GetImplementation(*this).TranslateBy(distance);
129 void Actor::RotateBy(const Radian& angle, const Vector3& axis)
131 GetImplementation(*this).RotateBy(angle, axis);
134 void Actor::RotateBy(const Quaternion& relativeRotation)
136 GetImplementation(*this).RotateBy(relativeRotation);
139 void Actor::ScaleBy(const Vector3& relativeScale)
141 GetImplementation(*this).ScaleBy(relativeScale);
144 bool Actor::ScreenToLocal(float& localX, float& localY, float screenX, float screenY) const
146 return GetImplementation(*this).ScreenToLocal(localX, localY, screenX, screenY);
151 GetImplementation(*this).Raise();
156 GetImplementation(*this).Lower();
159 void Actor::RaiseToTop()
161 GetImplementation(*this).RaiseToTop();
164 void Actor::LowerToBottom()
166 GetImplementation(*this).LowerToBottom();
169 void Actor::RaiseAbove(Actor target)
171 GetImplementation(*this).RaiseAbove(GetImplementation(target));
174 void Actor::LowerBelow(Actor target)
176 GetImplementation(*this).LowerBelow(GetImplementation(target));
179 void Actor::SetResizePolicy(ResizePolicy::Type policy, Dimension::Type dimension)
181 GetImplementation(*this).SetResizePolicy(policy, dimension);
184 ResizePolicy::Type Actor::GetResizePolicy(Dimension::Type dimension) const
186 return GetImplementation(*this).GetResizePolicy(dimension);
189 float Actor::GetHeightForWidth(float width)
191 return GetImplementation(*this).GetHeightForWidth(width);
194 float Actor::GetWidthForHeight(float height)
196 return GetImplementation(*this).GetWidthForHeight(height);
199 float Actor::GetRelayoutSize(Dimension::Type dimension) const
201 return GetImplementation(*this).GetRelayoutSize(dimension);
204 Actor::TouchEventSignalType& Actor::TouchedSignal()
206 return GetImplementation(*this).TouchedSignal();
209 Actor::HoverSignalType& Actor::HoveredSignal()
211 return GetImplementation(*this).HoveredSignal();
214 Actor::WheelEventSignalType& Actor::WheelEventSignal()
216 return GetImplementation(*this).WheelEventSignal();
219 Actor::OnSceneSignalType& Actor::OnSceneSignal()
221 return GetImplementation(*this).OnSceneSignal();
224 Actor::OffSceneSignalType& Actor::OffSceneSignal()
226 return GetImplementation(*this).OffSceneSignal();
229 uint32_t Actor::AddRenderer(Renderer& renderer)
231 return GetImplementation(*this).AddRenderer(GetImplementation(renderer));
234 uint32_t Actor::GetRendererCount() const
236 return GetImplementation(*this).GetRendererCount();
239 Renderer Actor::GetRendererAt(uint32_t index)
241 Internal::RendererPtr renderer = GetImplementation(*this).GetRendererAt(index);
242 return Renderer(renderer.Get());
245 void Actor::RemoveRenderer(Renderer& renderer)
247 GetImplementation(*this).RemoveRenderer(GetImplementation(renderer));
250 void Actor::RemoveRenderer(uint32_t index)
252 GetImplementation(*this).RemoveRenderer(index);
255 Actor::OnRelayoutSignalType& Actor::OnRelayoutSignal()
257 return GetImplementation(*this).OnRelayoutSignal();
260 Actor::LayoutDirectionChangedSignalType& Actor::LayoutDirectionChangedSignal()
262 return GetImplementation(*this).LayoutDirectionChangedSignal();
265 Actor::Actor(Internal::Actor* internal)