2 * Copyright (c) 2014 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/degree.h>
26 #include <dali/public-api/math/radian.h>
27 #include <dali/public-api/math/vector2.h>
29 #include <dali/internal/event/actors/actor-impl.h>
30 #include <dali/internal/event/actors/layer-impl.h>
31 #include <dali/internal/event/actor-attachments/actor-attachment-impl.h>
32 #include <dali/internal/event/animation/constraint-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 const std::string& Actor::GetName() const
70 return GetImplementation(*this).GetName();
73 void Actor::SetName(const std::string& name)
75 GetImplementation(*this).SetName(name);
78 unsigned int Actor::GetId() const
80 return GetImplementation(*this).GetId();
83 bool Actor::IsRoot() const
85 return GetImplementation(*this).IsRoot();
88 bool Actor::OnStage() const
90 return GetImplementation(*this).OnStage();
93 bool Actor::IsLayer() const
95 return GetImplementation(*this).IsLayer();
98 Layer Actor::GetLayer()
100 return GetImplementation(*this).GetLayer();
103 void Actor::Add(Actor actor)
105 GetImplementation(*this).Add(GetImplementation(actor));
108 void Actor::Insert(unsigned int index, Actor actor)
110 GetImplementation(*this).Insert(index, GetImplementation(actor));
113 void Actor::Remove(Actor actor)
115 GetImplementation(*this).Remove(GetImplementation(actor));
118 void Actor::Unparent()
120 GetImplementation(*this).Unparent();
123 unsigned int Actor::GetChildCount() const
125 return GetImplementation(*this).GetChildCount();
128 Actor Actor::GetChildAt(unsigned int index) const
130 return GetImplementation(*this).GetChildAt(index);
133 Actor Actor::FindChildByName(const std::string& actorName)
135 Internal::ActorPtr child = GetImplementation(*this).FindChildByName(actorName);
136 return Actor(child.Get());
139 Actor Actor::FindChildById(const unsigned int id)
141 Internal::ActorPtr child = GetImplementation(*this).FindChildById(id);
142 return Actor(child.Get());
145 Actor Actor::GetParent() const
147 Internal::Actor* parent = GetImplementation(*this).GetParent();
149 return Actor(parent);
152 void Actor::SetParentOrigin(const Vector3& origin)
154 GetImplementation(*this).SetParentOrigin(origin);
157 Vector3 Actor::GetCurrentParentOrigin() const
159 return GetImplementation(*this).GetCurrentParentOrigin();
162 void Actor::SetAnchorPoint(const Vector3& anchorPoint)
164 GetImplementation(*this).SetAnchorPoint(anchorPoint);
167 Vector3 Actor::GetCurrentAnchorPoint() const
169 return GetImplementation(*this).GetCurrentAnchorPoint();
172 void Actor::SetSize(float width, float height)
174 GetImplementation(*this).SetSize(width, height);
177 void Actor::SetSize(float width, float height, float depth)
179 GetImplementation(*this).SetSize(width, height, depth);
182 void Actor::SetSize(const Vector2& size)
184 GetImplementation(*this).SetSize(size);
187 void Actor::SetSize(const Vector3& size)
189 GetImplementation(*this).SetSize(size);
192 Vector3 Actor::GetSize() const
194 return GetImplementation(*this).GetSize();
197 Vector3 Actor::GetCurrentSize() const
199 return GetImplementation(*this).GetCurrentSize();
202 Vector3 Actor::GetNaturalSize() const
204 return GetImplementation(*this).GetNaturalSize();
207 void Actor::SetPosition(float x, float y)
209 GetImplementation(*this).SetPosition(x, y);
212 void Actor::SetPosition(float x, float y, float z)
214 GetImplementation(*this).SetPosition(x, y, z);
217 void Actor::SetPosition(const Vector3& position)
219 GetImplementation(*this).SetPosition(position);
222 void Actor::SetX(float x)
224 GetImplementation(*this).SetX(x);
227 void Actor::SetY(float y)
229 GetImplementation(*this).SetY(y);
232 void Actor::SetZ(float z)
234 GetImplementation(*this).SetZ(z);
237 void Actor::TranslateBy(const Vector3& distance)
239 GetImplementation(*this).TranslateBy(distance);
242 Vector3 Actor::GetCurrentPosition() const
244 return GetImplementation(*this).GetCurrentPosition();
247 Vector3 Actor::GetCurrentWorldPosition() const
249 return GetImplementation(*this).GetCurrentWorldPosition();
252 void Actor::SetPositionInheritanceMode( PositionInheritanceMode mode )
254 GetImplementation(*this).SetPositionInheritanceMode( mode );
257 PositionInheritanceMode Actor::GetPositionInheritanceMode() const
259 return GetImplementation(*this).GetPositionInheritanceMode();
262 void Actor::SetOrientation(const Degree& angle, const Vector3& axis)
264 GetImplementation(*this).SetOrientation(Radian(angle), axis);
267 void Actor::SetOrientation(const Radian& angle, const Vector3& axis)
269 GetImplementation(*this).SetOrientation(angle, axis);
272 void Actor::SetOrientation(const Quaternion& orientation)
274 GetImplementation(*this).SetOrientation(orientation);
277 void Actor::RotateBy(const Degree& angle, const Vector3& axis)
279 GetImplementation(*this).RotateBy(Radian(angle), axis);
282 void Actor::RotateBy(const Radian& angle, const Vector3& axis)
284 GetImplementation(*this).RotateBy(angle, axis);
287 void Actor::RotateBy(const Quaternion& relativeRotation)
289 GetImplementation(*this).RotateBy(relativeRotation);
292 Quaternion Actor::GetCurrentOrientation() const
294 return GetImplementation(*this).GetCurrentOrientation();
297 void Actor::SetInheritOrientation(bool inherit)
299 GetImplementation(*this).SetInheritOrientation(inherit);
302 bool Actor::IsOrientationInherited() const
304 return GetImplementation(*this).IsOrientationInherited();
307 Quaternion Actor::GetCurrentWorldOrientation() const
309 return GetImplementation(*this).GetCurrentWorldOrientation();
312 void Actor::SetScale(float scale)
314 GetImplementation(*this).SetScale(scale);
317 void Actor::SetScale(float scaleX, float scaleY, float scaleZ)
319 GetImplementation(*this).SetScale(scaleX, scaleY, scaleZ);
322 void Actor::SetScale(const Vector3& scale)
324 GetImplementation(*this).SetScale(scale);
327 void Actor::ScaleBy(const Vector3& relativeScale)
329 GetImplementation(*this).ScaleBy(relativeScale);
332 Vector3 Actor::GetCurrentScale() const
334 return GetImplementation(*this).GetCurrentScale();
337 Vector3 Actor::GetCurrentWorldScale() const
339 return GetImplementation(*this).GetCurrentWorldScale();
342 void Actor::SetInheritScale( bool inherit )
344 GetImplementation(*this).SetInheritScale( inherit );
347 bool Actor::IsScaleInherited() const
349 return GetImplementation(*this).IsScaleInherited();
352 void Actor::SetSizeMode(SizeMode mode)
354 GetImplementation(*this).SetSizeMode(mode);
357 SizeMode Actor::GetSizeMode() const
359 return GetImplementation(*this).GetSizeMode();
362 void Actor::SetSizeModeFactor(const Vector3& factor)
364 GetImplementation(*this).SetSizeModeFactor(factor);
367 Vector3 Actor::GetSizeModeFactor() const
369 return GetImplementation(*this).GetSizeModeFactor();
372 Matrix Actor::GetCurrentWorldMatrix() const
374 return GetImplementation(*this).GetCurrentWorldMatrix();
377 void Actor::SetVisible(bool visible)
379 GetImplementation(*this).SetVisible(visible);
382 bool Actor::IsVisible() const
384 return GetImplementation(*this).IsVisible();
387 void Actor::SetOpacity(float opacity)
389 GetImplementation(*this).SetOpacity(opacity);
392 float Actor::GetCurrentOpacity() const
394 return GetImplementation(*this).GetCurrentOpacity();
397 void Actor::SetColor(const Vector4& color)
399 GetImplementation(*this).SetColor(color);
402 Vector4 Actor::GetCurrentColor() const
404 return GetImplementation(*this).GetCurrentColor();
407 void Actor::SetColorMode( ColorMode colorMode )
409 GetImplementation(*this).SetColorMode(colorMode);
412 ColorMode Actor::GetColorMode() const
414 return GetImplementation(*this).GetColorMode();
417 Vector4 Actor::GetCurrentWorldColor() const
419 return GetImplementation(*this).GetCurrentWorldColor();
422 void Actor::SetDrawMode( DrawMode::Type drawMode )
424 GetImplementation(*this).SetDrawMode( drawMode );
427 DrawMode::Type Actor::GetDrawMode() const
429 return GetImplementation(*this).GetDrawMode();
432 void Actor::SetSensitive(bool sensitive)
434 GetImplementation(*this).SetSensitive(sensitive);
437 bool Actor::IsSensitive() const
439 return GetImplementation(*this).IsSensitive();
442 bool Actor::ScreenToLocal(float& localX, float& localY, float screenX, float screenY) const
444 return GetImplementation(*this).ScreenToLocal(localX, localY, screenX, screenY);
447 void Actor::SetLeaveRequired(bool required)
449 GetImplementation(*this).SetLeaveRequired(required);
452 bool Actor::GetLeaveRequired() const
454 return GetImplementation(*this).GetLeaveRequired();
457 void Actor::SetKeyboardFocusable( bool focusable )
459 GetImplementation(*this).SetKeyboardFocusable(focusable);
462 bool Actor::IsKeyboardFocusable() const
464 return GetImplementation(*this).IsKeyboardFocusable();
467 Actor::TouchSignalType& Actor::TouchedSignal()
469 return GetImplementation(*this).TouchedSignal();
472 Actor::HoverSignalType& Actor::HoveredSignal()
474 return GetImplementation(*this).HoveredSignal();
477 Actor::MouseWheelEventSignalType& Actor::MouseWheelEventSignal()
479 return GetImplementation(*this).MouseWheelEventSignal();
482 Actor::OnStageSignalType& Actor::OnStageSignal()
484 return GetImplementation(*this).OnStageSignal();
487 Actor::OffStageSignalType& Actor::OffStageSignal()
489 return GetImplementation(*this).OffStageSignal();
492 Actor::Actor(Internal::Actor* internal)
497 void UnparentAndReset( Actor& actor )