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/internal/event/actors/actor-impl.h>
26 #include <dali/public-api/common/constants.h>
27 #include <dali/public-api/common/dali-common.h>
28 #include <dali/public-api/math/radian.h>
29 #include <dali/public-api/math/vector2.h>
30 #include <dali/public-api/math/vector3.h>
31 #include <dali/public-api/object/type-registry.h>
33 #include <dali/devel-api/actors/actor-devel.h>
34 #include <dali/devel-api/common/capabilities.h>
36 #include <dali/integration-api/debug.h>
38 #include <dali/internal/event/actors/actor-coords.h>
39 #include <dali/internal/event/actors/actor-parent.h>
40 #include <dali/internal/event/actors/actor-property-handler.h>
41 #include <dali/internal/event/actors/camera-actor-impl.h>
42 #include <dali/internal/event/common/event-thread-services.h>
43 #include <dali/internal/event/common/property-helper.h>
44 #include <dali/internal/event/common/scene-impl.h>
45 #include <dali/internal/event/common/stage-impl.h>
46 #include <dali/internal/event/common/thread-local-storage.h>
47 #include <dali/internal/event/common/type-info-impl.h>
48 #include <dali/internal/event/events/actor-gesture-data.h>
49 #include <dali/internal/event/render-tasks/render-task-impl.h>
50 #include <dali/internal/event/render-tasks/render-task-list-impl.h>
51 #include <dali/internal/event/rendering/renderer-impl.h>
52 #include <dali/internal/update/manager/update-manager.h>
53 #include <dali/internal/update/nodes/node-messages.h>
54 #include <dali/public-api/size-negotiation/relayout-container.h>
56 using Dali::Internal::SceneGraph::AnimatableProperty;
57 using Dali::Internal::SceneGraph::Node;
58 using Dali::Internal::SceneGraph::PropertyBase;
60 #if defined(DEBUG_ENABLED)
61 Debug::Filter* gLogFilter = Debug::Filter::New(Debug::NoLogging, false, "LOG_DEPTH_TIMER");
68 namespace // unnamed namespace
73 * We want to discourage the use of property strings (minimize string comparisons),
74 * particularly for the default properties.
75 * Name Type writable animatable constraint-input enum for index-checking
77 DALI_PROPERTY_TABLE_BEGIN
78 DALI_PROPERTY("parentOrigin", VECTOR3, true, false, true, Dali::Actor::Property::PARENT_ORIGIN)
79 DALI_PROPERTY("parentOriginX", FLOAT, true, false, true, Dali::Actor::Property::PARENT_ORIGIN_X)
80 DALI_PROPERTY("parentOriginY", FLOAT, true, false, true, Dali::Actor::Property::PARENT_ORIGIN_Y)
81 DALI_PROPERTY("parentOriginZ", FLOAT, true, false, true, Dali::Actor::Property::PARENT_ORIGIN_Z)
82 DALI_PROPERTY("anchorPoint", VECTOR3, true, false, true, Dali::Actor::Property::ANCHOR_POINT)
83 DALI_PROPERTY("anchorPointX", FLOAT, true, false, true, Dali::Actor::Property::ANCHOR_POINT_X)
84 DALI_PROPERTY("anchorPointY", FLOAT, true, false, true, Dali::Actor::Property::ANCHOR_POINT_Y)
85 DALI_PROPERTY("anchorPointZ", FLOAT, true, false, true, Dali::Actor::Property::ANCHOR_POINT_Z)
86 DALI_PROPERTY("size", VECTOR3, true, true, true, Dali::Actor::Property::SIZE)
87 DALI_PROPERTY("sizeWidth", FLOAT, true, true, true, Dali::Actor::Property::SIZE_WIDTH)
88 DALI_PROPERTY("sizeHeight", FLOAT, true, true, true, Dali::Actor::Property::SIZE_HEIGHT)
89 DALI_PROPERTY("sizeDepth", FLOAT, true, true, true, Dali::Actor::Property::SIZE_DEPTH)
90 DALI_PROPERTY("position", VECTOR3, true, true, true, Dali::Actor::Property::POSITION)
91 DALI_PROPERTY("positionX", FLOAT, true, true, true, Dali::Actor::Property::POSITION_X)
92 DALI_PROPERTY("positionY", FLOAT, true, true, true, Dali::Actor::Property::POSITION_Y)
93 DALI_PROPERTY("positionZ", FLOAT, true, true, true, Dali::Actor::Property::POSITION_Z)
94 DALI_PROPERTY("worldPosition", VECTOR3, false, false, true, Dali::Actor::Property::WORLD_POSITION)
95 DALI_PROPERTY("worldPositionX", FLOAT, false, false, true, Dali::Actor::Property::WORLD_POSITION_X)
96 DALI_PROPERTY("worldPositionY", FLOAT, false, false, true, Dali::Actor::Property::WORLD_POSITION_Y)
97 DALI_PROPERTY("worldPositionZ", FLOAT, false, false, true, Dali::Actor::Property::WORLD_POSITION_Z)
98 DALI_PROPERTY("orientation", ROTATION, true, true, true, Dali::Actor::Property::ORIENTATION)
99 DALI_PROPERTY("worldOrientation", ROTATION, false, false, true, Dali::Actor::Property::WORLD_ORIENTATION)
100 DALI_PROPERTY("scale", VECTOR3, true, true, true, Dali::Actor::Property::SCALE)
101 DALI_PROPERTY("scaleX", FLOAT, true, true, true, Dali::Actor::Property::SCALE_X)
102 DALI_PROPERTY("scaleY", FLOAT, true, true, true, Dali::Actor::Property::SCALE_Y)
103 DALI_PROPERTY("scaleZ", FLOAT, true, true, true, Dali::Actor::Property::SCALE_Z)
104 DALI_PROPERTY("worldScale", VECTOR3, false, false, true, Dali::Actor::Property::WORLD_SCALE)
105 DALI_PROPERTY("visible", BOOLEAN, true, true, true, Dali::Actor::Property::VISIBLE)
106 DALI_PROPERTY("color", VECTOR4, true, true, true, Dali::Actor::Property::COLOR)
107 DALI_PROPERTY("colorRed", FLOAT, true, true, true, Dali::Actor::Property::COLOR_RED)
108 DALI_PROPERTY("colorGreen", FLOAT, true, true, true, Dali::Actor::Property::COLOR_GREEN)
109 DALI_PROPERTY("colorBlue", FLOAT, true, true, true, Dali::Actor::Property::COLOR_BLUE)
110 DALI_PROPERTY("colorAlpha", FLOAT, true, true, true, Dali::Actor::Property::COLOR_ALPHA)
111 DALI_PROPERTY("worldColor", VECTOR4, false, false, true, Dali::Actor::Property::WORLD_COLOR)
112 DALI_PROPERTY("worldMatrix", MATRIX, false, false, true, Dali::Actor::Property::WORLD_MATRIX)
113 DALI_PROPERTY("name", STRING, true, false, false, Dali::Actor::Property::NAME)
114 DALI_PROPERTY("sensitive", BOOLEAN, true, false, false, Dali::Actor::Property::SENSITIVE)
115 DALI_PROPERTY("leaveRequired", BOOLEAN, true, false, false, Dali::Actor::Property::LEAVE_REQUIRED)
116 DALI_PROPERTY("inheritOrientation", BOOLEAN, true, false, false, Dali::Actor::Property::INHERIT_ORIENTATION)
117 DALI_PROPERTY("inheritScale", BOOLEAN, true, false, false, Dali::Actor::Property::INHERIT_SCALE)
118 DALI_PROPERTY("colorMode", INTEGER, true, false, false, Dali::Actor::Property::COLOR_MODE)
119 DALI_PROPERTY("drawMode", INTEGER, true, false, false, Dali::Actor::Property::DRAW_MODE)
120 DALI_PROPERTY("sizeModeFactor", VECTOR3, true, false, false, Dali::Actor::Property::SIZE_MODE_FACTOR)
121 DALI_PROPERTY("widthResizePolicy", STRING, true, false, false, Dali::Actor::Property::WIDTH_RESIZE_POLICY)
122 DALI_PROPERTY("heightResizePolicy", STRING, true, false, false, Dali::Actor::Property::HEIGHT_RESIZE_POLICY)
123 DALI_PROPERTY("sizeScalePolicy", INTEGER, true, false, false, Dali::Actor::Property::SIZE_SCALE_POLICY)
124 DALI_PROPERTY("widthForHeight", BOOLEAN, true, false, false, Dali::Actor::Property::WIDTH_FOR_HEIGHT)
125 DALI_PROPERTY("heightForWidth", BOOLEAN, true, false, false, Dali::Actor::Property::HEIGHT_FOR_WIDTH)
126 DALI_PROPERTY("padding", VECTOR4, true, false, false, Dali::Actor::Property::PADDING)
127 DALI_PROPERTY("minimumSize", VECTOR2, true, false, false, Dali::Actor::Property::MINIMUM_SIZE)
128 DALI_PROPERTY("maximumSize", VECTOR2, true, false, false, Dali::Actor::Property::MAXIMUM_SIZE)
129 DALI_PROPERTY("inheritPosition", BOOLEAN, true, false, false, Dali::Actor::Property::INHERIT_POSITION)
130 DALI_PROPERTY("clippingMode", STRING, true, false, false, Dali::Actor::Property::CLIPPING_MODE)
131 DALI_PROPERTY("layoutDirection", STRING, true, false, false, Dali::Actor::Property::LAYOUT_DIRECTION)
132 DALI_PROPERTY("inheritLayoutDirection", BOOLEAN, true, false, false, Dali::Actor::Property::INHERIT_LAYOUT_DIRECTION)
133 DALI_PROPERTY("opacity", FLOAT, true, true, true, Dali::Actor::Property::OPACITY)
134 DALI_PROPERTY("screenPosition", VECTOR2, false, false, false, Dali::Actor::Property::SCREEN_POSITION)
135 DALI_PROPERTY("positionUsesAnchorPoint", BOOLEAN, true, false, false, Dali::Actor::Property::POSITION_USES_ANCHOR_POINT)
136 DALI_PROPERTY("culled", BOOLEAN, false, false, true, Dali::Actor::Property::CULLED)
137 DALI_PROPERTY("id", INTEGER, false, false, false, Dali::Actor::Property::ID)
138 DALI_PROPERTY("hierarchyDepth", INTEGER, false, false, false, Dali::Actor::Property::HIERARCHY_DEPTH)
139 DALI_PROPERTY("isRoot", BOOLEAN, false, false, false, Dali::Actor::Property::IS_ROOT)
140 DALI_PROPERTY("isLayer", BOOLEAN, false, false, false, Dali::Actor::Property::IS_LAYER)
141 DALI_PROPERTY("connectedToScene", BOOLEAN, false, false, false, Dali::Actor::Property::CONNECTED_TO_SCENE)
142 DALI_PROPERTY("keyboardFocusable", BOOLEAN, true, false, false, Dali::Actor::Property::KEYBOARD_FOCUSABLE)
143 DALI_PROPERTY("siblingOrder", INTEGER, true, false, false, Dali::DevelActor::Property::SIBLING_ORDER)
144 DALI_PROPERTY("updateSizeHint", VECTOR2, true, false, false, Dali::DevelActor::Property::UPDATE_SIZE_HINT)
145 DALI_PROPERTY("captureAllTouchAfterStart", BOOLEAN, true, false, false, Dali::DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START)
146 DALI_PROPERTY("touchAreaOffset", RECTANGLE, true, false, false, Dali::DevelActor::Property::TOUCH_AREA_OFFSET)
147 DALI_PROPERTY("blendEquation", INTEGER, true, false, false, Dali::DevelActor::Property::BLEND_EQUATION)
148 DALI_PROPERTY("touchFocusable", BOOLEAN, true, false, false, Dali::DevelActor::Property::TOUCH_FOCUSABLE)
149 DALI_PROPERTY("keyboardFocusableChildren", BOOLEAN, true, false, false, Dali::DevelActor::Property::KEYBOARD_FOCUSABLE_CHILDREN)
150 DALI_PROPERTY("userInteractionEnabled", BOOLEAN, true, false, false, Dali::DevelActor::Property::USER_INTERACTION_ENABLED)
151 DALI_PROPERTY_TABLE_END(DEFAULT_ACTOR_PROPERTY_START_INDEX, ActorDefaultProperties)
155 static constexpr std::string_view SIGNAL_HOVERED = "hovered";
156 static constexpr std::string_view SIGNAL_WHEEL_EVENT = "wheelEvent";
157 static constexpr std::string_view SIGNAL_ON_SCENE = "onScene";
158 static constexpr std::string_view SIGNAL_OFF_SCENE = "offScene";
159 static constexpr std::string_view SIGNAL_ON_RELAYOUT = "onRelayout";
160 static constexpr std::string_view SIGNAL_TOUCHED = "touched";
161 static constexpr std::string_view SIGNAL_VISIBILITY_CHANGED = "visibilityChanged";
162 static constexpr std::string_view SIGNAL_LAYOUT_DIRECTION_CHANGED = "layoutDirectionChanged";
163 static constexpr std::string_view SIGNAL_CHILD_ADDED = "childAdded";
164 static constexpr std::string_view SIGNAL_CHILD_REMOVED = "childRemoved";
168 static constexpr std::string_view ACTION_SHOW = "show";
169 static constexpr std::string_view ACTION_HIDE = "hide";
171 BaseHandle CreateActor()
173 return Dali::Actor::New();
177 * Connects a callback function with the object's signals.
178 * @param[in] object The object providing the signal.
179 * @param[in] tracker Used to disconnect the signal.
180 * @param[in] signalName The signal to connect to.
181 * @param[in] functor A newly allocated FunctorDelegate.
182 * @return True if the signal was connected.
183 * @post If a signal was connected, ownership of functor was passed to CallbackBase. Otherwise the caller is responsible for deleting the unused functor.
185 static bool DoConnectSignal(BaseObject* object,
186 ConnectionTrackerInterface* tracker,
187 const std::string& signalName,
188 FunctorDelegate* functor)
190 bool connected(true);
191 Actor* actor = static_cast<Actor*>(object); // TypeRegistry guarantees that this is the correct type.
193 std::string_view name(signalName);
195 if(name == SIGNAL_HOVERED)
197 actor->HoveredSignal().Connect(tracker, functor);
199 else if(signalName == SIGNAL_WHEEL_EVENT)
201 actor->WheelEventSignal().Connect(tracker, functor);
203 else if(name == SIGNAL_ON_SCENE)
205 actor->OnSceneSignal().Connect(tracker, functor);
207 else if(name == SIGNAL_OFF_SCENE)
209 actor->OffSceneSignal().Connect(tracker, functor);
211 else if(name == SIGNAL_ON_RELAYOUT)
213 actor->OnRelayoutSignal().Connect(tracker, functor);
215 else if(name == SIGNAL_TOUCHED)
217 actor->TouchedSignal().Connect(tracker, functor);
219 else if(name == SIGNAL_VISIBILITY_CHANGED)
221 actor->VisibilityChangedSignal().Connect(tracker, functor);
223 else if(name == SIGNAL_LAYOUT_DIRECTION_CHANGED)
225 actor->LayoutDirectionChangedSignal().Connect(tracker, functor);
227 else if(name == SIGNAL_CHILD_ADDED)
229 actor->ChildAddedSignal().Connect(tracker, functor);
231 else if(name == SIGNAL_CHILD_REMOVED)
233 actor->ChildRemovedSignal().Connect(tracker, functor);
237 // signalName does not match any signal
245 * Performs actions as requested using the action name.
246 * @param[in] object The object on which to perform the action.
247 * @param[in] actionName The action to perform.
248 * @param[in] attributes The attributes with which to perfrom this action.
249 * @return true if the action was done.
251 bool DoAction(BaseObject* object,
252 const std::string& actionName,
253 const Property::Map& attributes)
256 Actor* actor = dynamic_cast<Actor*>(object);
260 std::string_view name(actionName);
261 if(name == ACTION_SHOW)
263 actor->SetVisible(true);
266 else if(name == ACTION_HIDE)
268 actor->SetVisible(false);
276 TypeRegistration mType(typeid(Dali::Actor), typeid(Dali::Handle), CreateActor, ActorDefaultProperties);
278 SignalConnectorType signalConnector2(mType, std::string(SIGNAL_HOVERED), &DoConnectSignal);
279 SignalConnectorType signalConnector3(mType, std::string(SIGNAL_WHEEL_EVENT), &DoConnectSignal);
280 SignalConnectorType signalConnector4(mType, std::string(SIGNAL_ON_SCENE), &DoConnectSignal);
281 SignalConnectorType signalConnector5(mType, std::string(SIGNAL_OFF_SCENE), &DoConnectSignal);
282 SignalConnectorType signalConnector6(mType, std::string(SIGNAL_ON_RELAYOUT), &DoConnectSignal);
283 SignalConnectorType signalConnector7(mType, std::string(SIGNAL_TOUCHED), &DoConnectSignal);
284 SignalConnectorType signalConnector8(mType, std::string(SIGNAL_VISIBILITY_CHANGED), &DoConnectSignal);
285 SignalConnectorType signalConnector9(mType, std::string(SIGNAL_LAYOUT_DIRECTION_CHANGED), &DoConnectSignal);
286 SignalConnectorType signalConnector10(mType, std::string(SIGNAL_CHILD_ADDED), &DoConnectSignal);
287 SignalConnectorType signalConnector11(mType, std::string(SIGNAL_CHILD_REMOVED), &DoConnectSignal);
289 TypeAction a1(mType, std::string(ACTION_SHOW), &DoAction);
290 TypeAction a2(mType, std::string(ACTION_HIDE), &DoAction);
292 /// Helper for emitting a signal
293 template<typename Signal, typename Event>
294 bool EmitConsumingSignal(Actor& actor, Signal& signal, const Event& event)
296 bool consumed = false;
300 Dali::Actor handle(&actor);
301 consumed = signal.Emit(handle, event);
307 /// Helper for emitting signals with multiple parameters
308 template<typename Signal, typename... Param>
309 void EmitSignal(Actor& actor, Signal& signal, Param... params)
313 Dali::Actor handle(&actor);
314 signal.Emit(handle, params...);
318 using ActorParentSiblingOrderMethod = void (ActorParent::*)(Actor&);
319 using ActorParentSiblingOrderMethodWithTarget = void (ActorParent::*)(Actor&, Actor&);
321 /// Helper to check and call actor sibling methods in ActorParent
322 void CheckParentAndCall(ActorParent* parent, Actor& actor, ActorParentSiblingOrderMethod memberFunction)
326 (parent->*memberFunction)(actor);
330 DALI_LOG_WARNING("Actor must have a parent, Sibling order not changed.\n");
334 /// Helper to check and call actor sibling methods with a target parameter in ActorParent
335 void CheckParentAndCall(ActorParent* parent, Actor& actor, Actor& target, ActorParentSiblingOrderMethodWithTarget memberFunction)
339 (parent->*memberFunction)(actor, target);
343 DALI_LOG_WARNING("Actor must have a parent, Sibling order not changed.\n");
347 } // unnamed namespace
349 ActorPtr Actor::New()
351 // pass a reference to actor, actor does not own its node
352 ActorPtr actor(new Actor(BASIC, *CreateNode()));
354 // Second-phase construction
360 const SceneGraph::Node* Actor::CreateNode()
362 // create node. Nodes are owned by the update manager
363 SceneGraph::Node* node = SceneGraph::Node::New();
364 OwnerPointer<SceneGraph::Node> transferOwnership(node);
365 Internal::ThreadLocalStorage* tls = Internal::ThreadLocalStorage::GetInternal();
367 DALI_ASSERT_ALWAYS(tls && "ThreadLocalStorage is null");
369 AddNodeMessage(tls->GetUpdateManager(), transferOwnership);
374 void Actor::SetName(std::string_view name)
376 mName = ConstString(name);
378 // ATTENTION: string for debug purposes is not thread safe.
379 DALI_LOG_SET_OBJECT_STRING(const_cast<SceneGraph::Node*>(&GetNode()), mName.GetCString());
382 uint32_t Actor::GetId() const
384 return GetNode().GetId();
387 Dali::Layer Actor::GetLayer()
391 // Short-circuit for Layer derived actors
394 layer = Dali::Layer(static_cast<Dali::Internal::Layer*>(this)); // static cast as we trust the flag
397 // Find the immediate Layer parent
398 for(Actor* parent = GetParent(); !layer && parent != nullptr; parent = parent->GetParent())
400 if(parent->IsLayer())
402 layer = Dali::Layer(static_cast<Dali::Internal::Layer*>(parent)); // static cast as we trust the flag
409 void Actor::Unparent()
413 // Remove this actor from the parent. The remove will put a relayout request in for
414 // the parent if required
415 mParent->Remove(*this);
416 // mParent is now NULL!
420 void Actor::SetParentOrigin(const Vector3& origin)
422 // node is being used in a separate thread; queue a message to set the value & base value
423 SetParentOriginMessage(GetEventThreadServices(), GetNode(), origin);
425 // Cache for event-thread access
428 // not allocated, check if different from default
429 if(ParentOrigin::DEFAULT != origin)
431 mParentOrigin = new Vector3(origin);
436 // check if different from current costs more than just set
437 *mParentOrigin = origin;
441 const Vector3& Actor::GetCurrentParentOrigin() const
443 // Cached for event-thread access
444 return (mParentOrigin) ? *mParentOrigin : ParentOrigin::DEFAULT;
447 void Actor::SetAnchorPoint(const Vector3& anchor)
449 // node is being used in a separate thread; queue a message to set the value & base value
450 SetAnchorPointMessage(GetEventThreadServices(), GetNode(), anchor);
452 // Cache for event-thread access
455 // not allocated, check if different from default
456 if(AnchorPoint::DEFAULT != anchor)
458 mAnchorPoint = new Vector3(anchor);
463 // check if different from current costs more than just set
464 *mAnchorPoint = anchor;
468 const Vector3& Actor::GetCurrentAnchorPoint() const
470 // Cached for event-thread access
471 return (mAnchorPoint) ? *mAnchorPoint : AnchorPoint::DEFAULT;
474 void Actor::SetPosition(float x, float y)
476 SetPosition(Vector3(x, y, 0.0f));
479 void Actor::SetPosition(float x, float y, float z)
481 SetPosition(Vector3(x, y, z));
484 void Actor::SetPosition(const Vector3& position)
486 mTargetPosition = position;
488 // node is being used in a separate thread; queue a message to set the value & base value
489 SceneGraph::NodeTransformPropertyMessage<Vector3>::Send(GetEventThreadServices(), &GetNode(), &GetNode().mPosition, &SceneGraph::TransformManagerPropertyHandler<Vector3>::Bake, position);
492 void Actor::SetX(float x)
494 mTargetPosition.x = x;
496 // node is being used in a separate thread; queue a message to set the value & base value
497 SceneGraph::NodeTransformComponentMessage<Vector3>::Send(GetEventThreadServices(), &GetNode(), &GetNode().mPosition, &SceneGraph::TransformManagerPropertyHandler<Vector3>::BakeX, x);
500 void Actor::SetY(float y)
502 mTargetPosition.y = y;
504 // node is being used in a separate thread; queue a message to set the value & base value
505 SceneGraph::NodeTransformComponentMessage<Vector3>::Send(GetEventThreadServices(), &GetNode(), &GetNode().mPosition, &SceneGraph::TransformManagerPropertyHandler<Vector3>::BakeY, y);
508 void Actor::SetZ(float z)
510 mTargetPosition.z = z;
512 // node is being used in a separate thread; queue a message to set the value & base value
513 SceneGraph::NodeTransformComponentMessage<Vector3>::Send(GetEventThreadServices(), &GetNode(), &GetNode().mPosition, &SceneGraph::TransformManagerPropertyHandler<Vector3>::BakeZ, z);
516 void Actor::TranslateBy(const Vector3& distance)
518 mTargetPosition += distance;
520 // node is being used in a separate thread; queue a message to set the value & base value
521 SceneGraph::NodeTransformPropertyMessage<Vector3>::Send(GetEventThreadServices(), &GetNode(), &GetNode().mPosition, &SceneGraph::TransformManagerPropertyHandler<Vector3>::BakeRelative, distance);
524 const Vector3& Actor::GetCurrentPosition() const
526 // node is being used in a separate thread; copy the value from the previous update
527 return GetNode().GetPosition(GetEventThreadServices().GetEventBufferIndex());
530 const Vector3& Actor::GetCurrentWorldPosition() const
532 // node is being used in a separate thread; copy the value from the previous update
533 return GetNode().GetWorldPosition(GetEventThreadServices().GetEventBufferIndex());
536 const Vector2 Actor::GetCurrentScreenPosition() const
540 BufferIndex bufferIndex = GetEventThreadServices().GetEventBufferIndex();
541 return CalculateActorScreenPosition(*this, bufferIndex);
543 return Vector2::ZERO;
546 void Actor::SetInheritPosition(bool inherit)
548 if(mInheritPosition != inherit)
550 // non animatable so keep local copy
551 mInheritPosition = inherit;
552 SetInheritPositionMessage(GetEventThreadServices(), GetNode(), inherit);
556 void Actor::SetOrientation(const Radian& angle, const Vector3& axis)
558 Vector3 normalizedAxis(axis.x, axis.y, axis.z);
559 normalizedAxis.Normalize();
561 Quaternion orientation(angle, normalizedAxis);
563 SetOrientation(orientation);
566 void Actor::SetOrientation(const Quaternion& orientation)
568 mTargetOrientation = orientation;
570 // node is being used in a separate thread; queue a message to set the value & base value
571 SceneGraph::NodeTransformPropertyMessage<Quaternion>::Send(GetEventThreadServices(), &GetNode(), &GetNode().mOrientation, &SceneGraph::TransformManagerPropertyHandler<Quaternion>::Bake, orientation);
574 void Actor::RotateBy(const Radian& angle, const Vector3& axis)
576 RotateBy(Quaternion(angle, axis));
579 void Actor::RotateBy(const Quaternion& relativeRotation)
581 mTargetOrientation *= Quaternion(relativeRotation);
583 // node is being used in a separate thread; queue a message to set the value & base value
584 SceneGraph::NodeTransformPropertyMessage<Quaternion>::Send(GetEventThreadServices(), &GetNode(), &GetNode().mOrientation, &SceneGraph::TransformManagerPropertyHandler<Quaternion>::BakeRelative, relativeRotation);
587 const Quaternion& Actor::GetCurrentOrientation() const
589 // node is being used in a separate thread; copy the value from the previous update
590 return GetNode().GetOrientation(GetEventThreadServices().GetEventBufferIndex());
593 const Quaternion& Actor::GetCurrentWorldOrientation() const
595 // node is being used in a separate thread; copy the value from the previous update
596 return GetNode().GetWorldOrientation(GetEventThreadServices().GetEventBufferIndex());
599 void Actor::SetScale(float scale)
601 SetScale(Vector3(scale, scale, scale));
604 void Actor::SetScale(float x, float y, float z)
606 SetScale(Vector3(x, y, z));
609 void Actor::SetScale(const Vector3& scale)
611 mTargetScale = scale;
613 // node is being used in a separate thread; queue a message to set the value & base value
614 SceneGraph::NodeTransformPropertyMessage<Vector3>::Send(GetEventThreadServices(), &GetNode(), &GetNode().mScale, &SceneGraph::TransformManagerPropertyHandler<Vector3>::Bake, scale);
617 void Actor::SetScaleX(float x)
621 // node is being used in a separate thread; queue a message to set the value & base value
622 SceneGraph::NodeTransformComponentMessage<Vector3>::Send(GetEventThreadServices(), &GetNode(), &GetNode().mScale, &SceneGraph::TransformManagerPropertyHandler<Vector3>::BakeX, x);
625 void Actor::SetScaleY(float y)
629 // node is being used in a separate thread; queue a message to set the value & base value
630 SceneGraph::NodeTransformComponentMessage<Vector3>::Send(GetEventThreadServices(), &GetNode(), &GetNode().mScale, &SceneGraph::TransformManagerPropertyHandler<Vector3>::BakeY, y);
633 void Actor::SetScaleZ(float z)
637 // node is being used in a separate thread; queue a message to set the value & base value
638 SceneGraph::NodeTransformComponentMessage<Vector3>::Send(GetEventThreadServices(), &GetNode(), &GetNode().mScale, &SceneGraph::TransformManagerPropertyHandler<Vector3>::BakeZ, z);
641 void Actor::ScaleBy(const Vector3& relativeScale)
643 mTargetScale *= relativeScale;
645 // node is being used in a separate thread; queue a message to set the value & base value
646 SceneGraph::NodeTransformPropertyMessage<Vector3>::Send(GetEventThreadServices(), &GetNode(), &GetNode().mScale, &SceneGraph::TransformManagerPropertyHandler<Vector3>::BakeRelativeMultiply, relativeScale);
649 const Vector3& Actor::GetCurrentScale() const
651 // node is being used in a separate thread; copy the value from the previous update
652 return GetNode().GetScale(GetEventThreadServices().GetEventBufferIndex());
655 const Vector3& Actor::GetCurrentWorldScale() const
657 // node is being used in a separate thread; copy the value from the previous update
658 return GetNode().GetWorldScale(GetEventThreadServices().GetEventBufferIndex());
661 void Actor::SetInheritScale(bool inherit)
663 if(mInheritScale != inherit)
665 // non animatable so keep local copy
666 mInheritScale = inherit;
667 // node is being used in a separate thread; queue a message to set the value
668 SetInheritScaleMessage(GetEventThreadServices(), GetNode(), inherit);
672 Matrix Actor::GetCurrentWorldMatrix() const
674 return GetNode().GetWorldMatrix(0);
677 void Actor::SetVisible(bool visible)
679 SetVisibleInternal(visible, SendMessage::TRUE);
682 bool Actor::IsVisible() const
684 // node is being used in a separate thread; copy the value from the previous update
685 return GetNode().IsVisible(GetEventThreadServices().GetEventBufferIndex());
688 void Actor::SetOpacity(float opacity)
690 mTargetColor.a = opacity;
692 // node is being used in a separate thread; queue a message to set the value & base value
693 SceneGraph::NodePropertyComponentMessage<Vector4>::Send(GetEventThreadServices(), &GetNode(), &GetNode().mColor, &AnimatableProperty<Vector4>::BakeW, opacity);
695 RequestRenderingMessage(GetEventThreadServices().GetUpdateManager());
698 float Actor::GetCurrentOpacity() const
700 // node is being used in a separate thread; copy the value from the previous update
701 return GetNode().GetOpacity(GetEventThreadServices().GetEventBufferIndex());
704 const Vector4& Actor::GetCurrentWorldColor() const
706 return GetNode().GetWorldColor(GetEventThreadServices().GetEventBufferIndex());
709 void Actor::SetColor(const Vector4& color)
711 mTargetColor = color;
713 // node is being used in a separate thread; queue a message to set the value & base value
714 SceneGraph::NodePropertyMessage<Vector4>::Send(GetEventThreadServices(), &GetNode(), &GetNode().mColor, &AnimatableProperty<Vector4>::Bake, color);
716 RequestRenderingMessage(GetEventThreadServices().GetUpdateManager());
719 void Actor::SetColorRed(float red)
721 mTargetColor.r = red;
723 // node is being used in a separate thread; queue a message to set the value & base value
724 SceneGraph::NodePropertyComponentMessage<Vector4>::Send(GetEventThreadServices(), &GetNode(), &GetNode().mColor, &AnimatableProperty<Vector4>::BakeX, red);
726 RequestRenderingMessage(GetEventThreadServices().GetUpdateManager());
729 void Actor::SetColorGreen(float green)
731 mTargetColor.g = green;
733 // node is being used in a separate thread; queue a message to set the value & base value
734 SceneGraph::NodePropertyComponentMessage<Vector4>::Send(GetEventThreadServices(), &GetNode(), &GetNode().mColor, &AnimatableProperty<Vector4>::BakeY, green);
736 RequestRenderingMessage(GetEventThreadServices().GetUpdateManager());
739 void Actor::SetColorBlue(float blue)
741 mTargetColor.b = blue;
743 // node is being used in a separate thread; queue a message to set the value & base value
744 SceneGraph::NodePropertyComponentMessage<Vector4>::Send(GetEventThreadServices(), &GetNode(), &GetNode().mColor, &AnimatableProperty<Vector4>::BakeZ, blue);
746 RequestRenderingMessage(GetEventThreadServices().GetUpdateManager());
749 const Vector4& Actor::GetCurrentColor() const
751 // node is being used in a separate thread; copy the value from the previous update
752 return GetNode().GetColor(GetEventThreadServices().GetEventBufferIndex());
755 void Actor::SetInheritOrientation(bool inherit)
757 if(mInheritOrientation != inherit)
759 // non animatable so keep local copy
760 mInheritOrientation = inherit;
761 // node is being used in a separate thread; queue a message to set the value
762 SetInheritOrientationMessage(GetEventThreadServices(), GetNode(), inherit);
766 void Actor::SetSizeModeFactor(const Vector3& factor)
768 mSizer.SetSizeModeFactor(factor);
771 const Vector3& Actor::GetSizeModeFactor() const
773 return mSizer.GetSizeModeFactor();
776 void Actor::SetColorMode(ColorMode colorMode)
778 // non animatable so keep local copy
779 mColorMode = colorMode;
780 // node is being used in a separate thread; queue a message to set the value
781 SetColorModeMessage(GetEventThreadServices(), GetNode(), colorMode);
784 void Actor::SetSize(float width, float height)
786 SetSize(Vector2(width, height));
789 void Actor::SetSize(float width, float height, float depth)
791 SetSize(Vector3(width, height, depth));
794 void Actor::SetSize(const Vector2& size)
796 SetSize(Vector3(size.width, size.height, 0.f));
799 void Actor::SetSize(const Vector3& size)
801 mSizer.SetSize(size);
804 void Actor::SetWidth(float width)
806 mSizer.SetWidth(width);
809 void Actor::SetHeight(float height)
811 mSizer.SetHeight(height);
814 void Actor::SetDepth(float depth)
816 mSizer.SetDepth(depth);
817 // node is being used in a separate thread; queue a message to set the value & base value
818 SceneGraph::NodeTransformComponentMessage<Vector3>::Send(GetEventThreadServices(), &GetNode(), &GetNode().mSize, &SceneGraph::TransformManagerPropertyHandler<Vector3>::BakeZ, depth);
821 Vector3 Actor::GetTargetSize() const
823 return mSizer.GetTargetSize();
826 const Vector3& Actor::GetCurrentSize() const
828 // node is being used in a separate thread; copy the value from the previous update
829 return GetNode().GetSize(GetEventThreadServices().GetEventBufferIndex());
832 Vector3 Actor::GetNaturalSize() const
834 // It is up to deriving classes to return the appropriate natural size
835 return Vector3(0.0f, 0.0f, 0.0f);
838 void Actor::SetResizePolicy(ResizePolicy::Type policy, Dimension::Type dimension)
840 mSizer.SetResizePolicy(policy, dimension);
843 ResizePolicy::Type Actor::GetResizePolicy(Dimension::Type dimension) const
845 return mSizer.GetResizePolicy(dimension);
848 void Actor::SetRelayoutEnabled(bool relayoutEnabled)
850 mSizer.SetRelayoutEnabled(relayoutEnabled);
853 bool Actor::IsRelayoutEnabled() const
855 return mSizer.IsRelayoutEnabled();
858 void Actor::SetLayoutDirty(bool dirty, Dimension::Type dimension)
860 mSizer.SetLayoutDirty(dirty, dimension);
863 bool Actor::IsLayoutDirty(Dimension::Type dimension) const
865 return mSizer.IsLayoutDirty(dimension);
868 bool Actor::RelayoutPossible(Dimension::Type dimension) const
870 return mSizer.RelayoutPossible(dimension);
873 bool Actor::RelayoutRequired(Dimension::Type dimension) const
875 return mSizer.RelayoutRequired(dimension);
878 uint32_t Actor::AddRenderer(Renderer& renderer)
882 mRenderers = new RendererContainer(GetEventThreadServices());
884 return mRenderers->Add(GetNode(), renderer, mIsBlendEquationSet, mBlendEquation);
887 uint32_t Actor::GetRendererCount() const
889 return mRenderers ? mRenderers->GetCount() : 0u;
892 RendererPtr Actor::GetRendererAt(uint32_t index)
894 return mRenderers ? mRenderers->GetRendererAt(index) : nullptr;
897 void Actor::RemoveRenderer(Renderer& renderer)
901 mRenderers->Remove(GetNode(), renderer);
905 void Actor::RemoveRenderer(uint32_t index)
909 mRenderers->Remove(GetNode(), index);
913 void Actor::SetBlendEquation(DevelBlendEquation::Type blendEquation)
915 if(Dali::Capabilities::IsBlendEquationSupported(blendEquation))
917 if(mBlendEquation != blendEquation)
919 mBlendEquation = blendEquation;
922 mRenderers->SetBlending(blendEquation);
925 mIsBlendEquationSet = true;
929 DALI_LOG_ERROR("Invalid blend equation is entered.\n");
933 DevelBlendEquation::Type Actor::GetBlendEquation() const
935 return mBlendEquation;
938 void Actor::SetTransparent(bool transparent)
940 SetTransparentMessage(GetEventThreadServices(), GetNode(), transparent);
943 bool Actor::IsTransparent() const
945 return GetNode().IsTransparent();
948 void Actor::SetDrawMode(DrawMode::Type drawMode)
950 // this flag is not animatable so keep the value
951 mDrawMode = drawMode;
953 // node is being used in a separate thread; queue a message to set the value
954 SetDrawModeMessage(GetEventThreadServices(), GetNode(), drawMode);
957 bool Actor::ScreenToLocal(float& localX, float& localY, float screenX, float screenY) const
959 return mScene && OnScene() && ConvertScreenToLocalRenderTaskList(mScene->GetRenderTaskList(), GetNode().GetWorldMatrix(0), GetCurrentSize(), localX, localY, screenX, screenY);
962 bool Actor::ScreenToLocal(const RenderTask& renderTask, float& localX, float& localY, float screenX, float screenY) const
964 return OnScene() && ConvertScreenToLocalRenderTask(renderTask, GetNode().GetWorldMatrix(0), GetCurrentSize(), localX, localY, screenX, screenY);
967 bool Actor::ScreenToLocal(const Matrix& viewMatrix, const Matrix& projectionMatrix, const Viewport& viewport, float& localX, float& localY, float screenX, float screenY) const
969 return OnScene() && ConvertScreenToLocal(viewMatrix, projectionMatrix, GetNode().GetWorldMatrix(0), GetCurrentSize(), viewport, localX, localY, screenX, screenY);
972 ActorGestureData& Actor::GetGestureData()
974 // Likely scenario is that once gesture-data is created for this actor, the actor will require
975 // that gesture for its entire life-time so no need to destroy it until the actor is destroyed
976 if(nullptr == mGestureData)
978 mGestureData = new ActorGestureData;
980 return *mGestureData;
983 bool Actor::IsGestureRequired(GestureType::Value type) const
985 return mGestureData && mGestureData->IsGestureRequired(type);
988 bool Actor::EmitInterceptTouchEventSignal(const Dali::TouchEvent& touch)
990 return EmitConsumingSignal(*this, mInterceptTouchedSignal, touch);
993 bool Actor::EmitTouchEventSignal(const Dali::TouchEvent& touch)
995 return EmitConsumingSignal(*this, mTouchedSignal, touch);
998 bool Actor::EmitHoverEventSignal(const Dali::HoverEvent& event)
1000 return EmitConsumingSignal(*this, mHoveredSignal, event);
1003 bool Actor::EmitWheelEventSignal(const Dali::WheelEvent& event)
1005 return EmitConsumingSignal(*this, mWheelEventSignal, event);
1008 void Actor::EmitVisibilityChangedSignal(bool visible, DevelActor::VisibilityChange::Type type)
1010 EmitSignal(*this, mVisibilityChangedSignal, visible, type);
1013 void Actor::EmitLayoutDirectionChangedSignal(LayoutDirection::Type type)
1015 EmitSignal(*this, mLayoutDirectionChangedSignal, type);
1018 DevelActor::ChildChangedSignalType& Actor::ChildAddedSignal()
1020 return mParentImpl.ChildAddedSignal();
1023 DevelActor::ChildChangedSignalType& Actor::ChildRemovedSignal()
1025 return mParentImpl.ChildRemovedSignal();
1028 DevelActor::ChildOrderChangedSignalType& Actor::ChildOrderChangedSignal()
1030 return mParentImpl.ChildOrderChangedSignal();
1033 Actor::Actor(DerivedType derivedType, const SceneGraph::Node& node)
1039 mRenderers(nullptr),
1040 mParentOrigin(nullptr),
1041 mAnchorPoint(nullptr),
1042 mGestureData(nullptr),
1043 mInterceptTouchedSignal(),
1046 mWheelEventSignal(),
1049 mOnRelayoutSignal(),
1050 mVisibilityChangedSignal(),
1051 mLayoutDirectionChangedSignal(),
1052 mTargetOrientation(Quaternion::IDENTITY),
1053 mTargetColor(Color::WHITE),
1054 mTargetPosition(Vector3::ZERO),
1055 mTargetScale(Vector3::ONE),
1056 mTouchAreaOffset(0, 0, 0, 0),
1060 mIsRoot(ROOT_LAYER == derivedType),
1061 mIsLayer(LAYER == derivedType || ROOT_LAYER == derivedType),
1064 mLeaveRequired(false),
1065 mKeyboardFocusable(false),
1066 mKeyboardFocusableChildren(true),
1067 mTouchFocusable(false),
1068 mOnSceneSignalled(false),
1069 mInheritPosition(true),
1070 mInheritOrientation(true),
1071 mInheritScale(true),
1072 mPositionUsesAnchorPoint(true),
1074 mInheritLayoutDirection(true),
1075 mCaptureAllTouchAfterStart(false),
1076 mIsBlendEquationSet(false),
1077 mNeedGesturePropagation(false),
1078 mUserInteractionEnabled(true),
1079 mLayoutDirection(LayoutDirection::LEFT_TO_RIGHT),
1080 mDrawMode(DrawMode::NORMAL),
1081 mColorMode(Node::DEFAULT_COLOR_MODE),
1082 mClippingMode(ClippingMode::DISABLED),
1083 mBlendEquation(DevelBlendEquation::ADD)
1087 void Actor::Initialize()
1091 GetEventThreadServices().RegisterObject(this);
1096 // Remove mParent pointers from children even if we're destroying core,
1097 // to guard against GetParent() & Unparent() calls from CustomActor destructors.
1101 // Guard to allow handle destruction after Core has been destroyed
1102 if(EventThreadServices::IsCoreRunning())
1104 // Root layer will destroy its node in its own destructor
1107 DestroyNodeMessage(GetEventThreadServices().GetUpdateManager(), GetNode());
1109 GetEventThreadServices().UnregisterObject(this);
1113 // Cleanup optional gesture data
1114 delete mGestureData;
1116 // Cleanup optional parent origin and anchor
1117 delete mParentOrigin;
1118 delete mAnchorPoint;
1121 void Actor::Add(Actor& child, bool notify)
1123 mParentImpl.Add(child, notify);
1126 void Actor::Remove(Actor& child, bool notify)
1128 mParentImpl.Remove(child, notify);
1131 void Actor::SwitchParent(Actor& newParent)
1133 if(this == &newParent)
1135 DALI_LOG_ERROR("Cannot add actor to itself");
1139 if(!this->OnScene() || !newParent.OnScene())
1141 DALI_LOG_ERROR("Both of current parent and new parent must be on Scene");
1145 newParent.Add(*this, false);
1148 uint32_t Actor::GetChildCount() const
1150 return mParentImpl.GetChildCount();
1153 ActorPtr Actor::GetChildAt(uint32_t index) const
1155 return mParentImpl.GetChildAt(index);
1158 ActorContainer& Actor::GetChildrenInternal()
1160 return mParentImpl.GetChildrenInternal();
1163 ActorPtr Actor::FindChildByName(ConstString actorName)
1165 return mParentImpl.FindChildByName(actorName);
1168 ActorPtr Actor::FindChildById(const uint32_t id)
1170 return mParentImpl.FindChildById(id);
1173 void Actor::UnparentChildren()
1175 mParentImpl.UnparentChildren();
1178 void Actor::ConnectToScene(uint32_t parentDepth, bool notify)
1180 // This container is used instead of walking the Actor hierarchy.
1181 // It protects us when the Actor hierarchy is modified during OnSceneConnectionExternal callbacks.
1182 ActorContainer connectionList;
1186 mScene->RequestRebuildDepthTree();
1189 // This stage is not interrupted by user callbacks.
1190 mParentImpl.RecursiveConnectToScene(connectionList, parentDepth + 1);
1192 // Notify applications about the newly connected actors.
1193 for(const auto& actor : connectionList)
1195 actor->NotifyStageConnection(notify);
1202 * This method is called when the Actor is connected to the Stage.
1203 * The parent must have added its Node to the scene-graph.
1204 * The child must connect its Node to the parent's Node.
1205 * This is recursive; the child calls ConnectToScene() for its children.
1207 void Actor::ConnectToSceneGraph()
1209 DALI_ASSERT_DEBUG(mParent != NULL);
1211 // Reparent Node in next Update
1212 ConnectNodeMessage(GetEventThreadServices().GetUpdateManager(), GetParent()->GetNode(), GetNode());
1214 // Request relayout on all actors that are added to the scenegraph
1217 // Notification for Object::Observers
1221 void Actor::NotifyStageConnection(bool notify)
1223 // Actors can be removed (in a callback), before the on-stage stage is reported.
1224 // The actor may also have been reparented, in which case mOnSceneSignalled will be true.
1225 if(OnScene() && !mOnSceneSignalled)
1229 // Notification for external (CustomActor) derived classes
1230 OnSceneConnectionExternal(mDepth);
1232 if(!mOnSceneSignal.Empty())
1234 Dali::Actor handle(this);
1235 mOnSceneSignal.Emit(handle);
1239 // Guard against Remove during callbacks
1242 mOnSceneSignalled = true; // signal required next time Actor is removed
1247 void Actor::DisconnectFromStage(bool notify)
1249 // This container is used instead of walking the Actor hierachy.
1250 // It protects us when the Actor hierachy is modified during OnSceneDisconnectionExternal callbacks.
1251 ActorContainer disconnectionList;
1255 mScene->RequestRebuildDepthTree();
1258 // This stage is not interrupted by user callbacks
1259 mParentImpl.RecursiveDisconnectFromScene(disconnectionList);
1261 // Notify applications about the newly disconnected actors.
1262 for(const auto& actor : disconnectionList)
1264 actor->NotifyStageDisconnection(notify);
1269 * This method is called by an actor or its parent, before a node removal message is sent.
1270 * This is recursive; the child calls DisconnectFromStage() for its children.
1272 void Actor::DisconnectFromSceneGraph()
1274 // Notification for Object::Observers
1275 OnSceneObjectRemove();
1278 void Actor::NotifyStageDisconnection(bool notify)
1280 // Actors can be added (in a callback), before the off-stage state is reported.
1281 // Also if the actor was added & removed before mOnSceneSignalled was set, then we don't notify here.
1282 // only do this step if there is a stage, i.e. Core is not being shut down
1283 if(EventThreadServices::IsCoreRunning() && !OnScene() && mOnSceneSignalled)
1287 // Notification for external (CustomeActor) derived classes
1288 OnSceneDisconnectionExternal();
1290 if(!mOffSceneSignal.Empty())
1292 Dali::Actor handle(this);
1293 mOffSceneSignal.Emit(handle);
1297 // Guard against Add during callbacks
1300 mOnSceneSignalled = false; // signal required next time Actor is added
1305 bool Actor::IsNodeConnected() const
1307 return OnScene() && (IsRoot() || GetNode().GetParent());
1310 // This method initiates traversal of the actor tree using depth-first
1311 // traversal to set a depth index based on traversal order. It sends a
1312 // single message to update manager to update all the actor's nodes in
1313 // this tree with the depth index. The sceneGraphNodeDepths vector's
1314 // elements are ordered by depth, and could be used to reduce sorting
1315 // in the update thread.
1316 void Actor::RebuildDepthTree()
1318 DALI_LOG_TIMER_START(depthTimer);
1320 // Vector of scene-graph nodes and their depths to send to UpdateManager
1321 // in a single message
1322 OwnerPointer<SceneGraph::NodeDepths> sceneGraphNodeDepths(new SceneGraph::NodeDepths());
1324 int32_t depthIndex = 1;
1325 mParentImpl.DepthTraverseActorTree(sceneGraphNodeDepths, depthIndex);
1327 SetDepthIndicesMessage(GetEventThreadServices().GetUpdateManager(), sceneGraphNodeDepths);
1328 DALI_LOG_TIMER_END(depthTimer, gLogFilter, Debug::Concise, "Depth tree traversal time: ");
1331 void Actor::SetDefaultProperty(Property::Index index, const Property::Value& property)
1333 PropertyHandler::SetDefaultProperty(*this, index, property);
1336 // TODO: This method needs to be removed
1337 void Actor::SetSceneGraphProperty(Property::Index index, const PropertyMetadata& entry, const Property::Value& value)
1339 PropertyHandler::SetSceneGraphProperty(index, entry, value, GetEventThreadServices(), GetNode());
1342 Property::Value Actor::GetDefaultProperty(Property::Index index) const
1344 Property::Value value;
1346 if(!GetCachedPropertyValue(index, value))
1348 // If property value is not stored in the event-side, then it must be a scene-graph only property
1349 GetCurrentPropertyValue(index, value);
1355 Property::Value Actor::GetDefaultPropertyCurrentValue(Property::Index index) const
1357 Property::Value value;
1359 if(!GetCurrentPropertyValue(index, value))
1361 // If unable to retrieve scene-graph property value, then it must be an event-side only property
1362 GetCachedPropertyValue(index, value);
1368 void Actor::OnNotifyDefaultPropertyAnimation(Animation& animation, Property::Index index, const Property::Value& value, Animation::Type animationType)
1370 PropertyHandler::OnNotifyDefaultPropertyAnimation(*this, animation, index, value, animationType);
1373 const PropertyBase* Actor::GetSceneObjectAnimatableProperty(Property::Index index) const
1375 const PropertyBase* property = PropertyHandler::GetSceneObjectAnimatableProperty(index, GetNode());
1378 // not our property, ask base
1379 property = Object::GetSceneObjectAnimatableProperty(index);
1385 const PropertyInputImpl* Actor::GetSceneObjectInputProperty(Property::Index index) const
1387 const PropertyInputImpl* property = PropertyHandler::GetSceneObjectInputProperty(index, GetNode());
1390 // reuse animatable property getter as animatable properties are inputs as well
1391 // animatable property chains back to Object::GetSceneObjectInputProperty() so all properties get covered
1392 property = GetSceneObjectAnimatableProperty(index);
1398 int32_t Actor::GetPropertyComponentIndex(Property::Index index) const
1400 int32_t componentIndex = PropertyHandler::GetPropertyComponentIndex(index);
1401 if(Property::INVALID_COMPONENT_INDEX == componentIndex)
1404 componentIndex = Object::GetPropertyComponentIndex(index);
1407 return componentIndex;
1410 const SceneGraph::Node& Actor::GetNode() const
1412 return *static_cast<const SceneGraph::Node*>(mUpdateObject);
1417 CheckParentAndCall(mParent, *this, &ActorParent::RaiseChild);
1422 CheckParentAndCall(mParent, *this, &ActorParent::LowerChild);
1425 void Actor::RaiseToTop()
1427 CheckParentAndCall(mParent, *this, &ActorParent::RaiseChildToTop);
1430 void Actor::LowerToBottom()
1432 CheckParentAndCall(mParent, *this, &ActorParent::LowerChildToBottom);
1435 void Actor::RaiseAbove(Internal::Actor& target)
1437 CheckParentAndCall(mParent, *this, target, &ActorParent::RaiseChildAbove);
1440 void Actor::LowerBelow(Internal::Actor& target)
1442 CheckParentAndCall(mParent, *this, target, &ActorParent::LowerChildBelow);
1445 void Actor::SetParent(ActorParent* parent, bool notify)
1449 DALI_ASSERT_ALWAYS(!mParent && "Actor cannot have 2 parents");
1452 Actor* parentActor = static_cast<Actor*>(parent);
1453 mScene = parentActor->mScene;
1455 if(EventThreadServices::IsCoreRunning() && // Don't emit signals or send messages during Core destruction
1456 parentActor->OnScene())
1458 // Instruct each actor to create a corresponding node in the scene graph
1459 ConnectToScene(parentActor->GetHierarchyDepth(), notify);
1462 // Resolve the name and index for the child properties if any
1463 ResolveChildProperties();
1465 else // parent being set to NULL
1467 DALI_ASSERT_ALWAYS(mParent != nullptr && "Actor should have a parent");
1471 if(EventThreadServices::IsCoreRunning() && // Don't emit signals or send messages during Core destruction
1474 // Disconnect the Node & its children from the scene-graph.
1475 DisconnectNodeMessage(GetEventThreadServices().GetUpdateManager(), GetNode());
1477 // Instruct each actor to discard pointers to the scene-graph
1478 DisconnectFromStage(notify);
1485 Rect<> Actor::CalculateScreenExtents() const
1487 auto screenPosition = GetCurrentScreenPosition();
1488 BufferIndex bufferIndex = GetEventThreadServices().GetEventBufferIndex();
1489 return CalculateActorScreenExtents(*this, screenPosition, bufferIndex);
1492 Vector3 Actor::GetAnchorPointForPosition() const
1494 return (mPositionUsesAnchorPoint ? GetCurrentAnchorPoint() : AnchorPoint::TOP_LEFT);
1497 bool Actor::GetCachedPropertyValue(Property::Index index, Property::Value& value) const
1499 return PropertyHandler::GetCachedPropertyValue(*this, index, value);
1502 bool Actor::GetCurrentPropertyValue(Property::Index index, Property::Value& value) const
1504 return PropertyHandler::GetCurrentPropertyValue(*this, index, value);
1507 bool Actor::RelayoutDependentOnParent(Dimension::Type dimension)
1509 return mSizer.RelayoutDependentOnParent(dimension);
1512 bool Actor::RelayoutDependentOnChildren(Dimension::Type dimension)
1514 return mSizer.RelayoutDependentOnChildrenBase(dimension);
1517 bool Actor::RelayoutDependentOnDimension(Dimension::Type dimension, Dimension::Type dependentDimension)
1519 return mSizer.RelayoutDependentOnDimension(dimension, dependentDimension);
1522 void Actor::SetPadding(const Vector2& padding, Dimension::Type dimension)
1524 mSizer.SetPadding(padding, dimension);
1527 Vector2 Actor::GetPadding(Dimension::Type dimension) const
1529 return mSizer.GetPadding(dimension);
1532 void Actor::SetLayoutNegotiated(bool negotiated, Dimension::Type dimension)
1534 mSizer.SetLayoutNegotiated(negotiated, dimension);
1537 bool Actor::IsLayoutNegotiated(Dimension::Type dimension) const
1539 return mSizer.IsLayoutNegotiated(dimension);
1542 float Actor::GetHeightForWidthBase(float width)
1544 // Can be overridden in derived class
1545 return mSizer.GetHeightForWidthBase(width);
1548 float Actor::GetWidthForHeightBase(float height)
1550 // Can be overridden in derived class
1551 return mSizer.GetWidthForHeightBase(height);
1554 float Actor::CalculateChildSizeBase(const Dali::Actor& child, Dimension::Type dimension)
1556 // Can be overridden in derived class
1557 return mSizer.CalculateChildSizeBase(child, dimension);
1560 bool Actor::RelayoutDependentOnChildrenBase(Dimension::Type dimension)
1562 return mSizer.RelayoutDependentOnChildrenBase(dimension);
1565 float Actor::CalculateChildSize(const Dali::Actor& child, Dimension::Type dimension)
1567 // Can be overridden in derived class
1568 return mSizer.CalculateChildSizeBase(child, dimension);
1571 float Actor::GetHeightForWidth(float width)
1573 // Can be overridden in derived class
1574 return mSizer.GetHeightForWidthBase(width);
1577 float Actor::GetWidthForHeight(float height)
1579 // Can be overridden in derived class
1580 return mSizer.GetWidthForHeightBase(height);
1583 float Actor::GetRelayoutSize(Dimension::Type dimension) const
1585 return mSizer.GetRelayoutSize(dimension);
1588 void Actor::NegotiateSize(const Vector2& allocatedSize, RelayoutContainer& container)
1590 mSizer.NegotiateSize(allocatedSize, container);
1593 void Actor::RelayoutRequest(Dimension::Type dimension)
1595 mSizer.RelayoutRequest(dimension);
1598 void Actor::SetMinimumSize(float size, Dimension::Type dimension)
1600 mSizer.SetMinimumSize(size, dimension);
1603 float Actor::GetMinimumSize(Dimension::Type dimension) const
1605 return mSizer.GetMinimumSize(dimension);
1608 void Actor::SetMaximumSize(float size, Dimension::Type dimension)
1610 mSizer.SetMaximumSize(size, dimension);
1613 float Actor::GetMaximumSize(Dimension::Type dimension) const
1615 return mSizer.GetMaximumSize(dimension);
1618 void Actor::SetVisibleInternal(bool visible, SendMessage::Type sendMessage)
1620 if(mVisible != visible)
1622 if(sendMessage == SendMessage::TRUE)
1624 // node is being used in a separate thread; queue a message to set the value & base value
1625 SceneGraph::NodePropertyMessage<bool>::Send(GetEventThreadServices(), &GetNode(), &GetNode().mVisible, &AnimatableProperty<bool>::Bake, visible);
1627 RequestRenderingMessage(GetEventThreadServices().GetUpdateManager());
1632 // Emit the signal on this actor and all its children
1633 mParentImpl.EmitVisibilityChangedSignalRecursively(visible, DevelActor::VisibilityChange::SELF);
1637 void Actor::SetSiblingOrderOfChild(Actor& child, uint32_t order)
1639 mParentImpl.SetSiblingOrderOfChild(child, order);
1642 uint32_t Actor::GetSiblingOrderOfChild(const Actor& child) const
1644 return mParentImpl.GetSiblingOrderOfChild(child);
1647 void Actor::RaiseChild(Actor& child)
1649 mParentImpl.RaiseChild(child);
1652 void Actor::LowerChild(Actor& child)
1654 mParentImpl.LowerChild(child);
1657 void Actor::RaiseChildToTop(Actor& child)
1659 mParentImpl.RaiseChildToTop(child);
1662 void Actor::LowerChildToBottom(Actor& child)
1664 mParentImpl.LowerChildToBottom(child);
1667 void Actor::RaiseChildAbove(Actor& child, Actor& target)
1669 mParentImpl.RaiseChildAbove(child, target);
1672 void Actor::LowerChildBelow(Actor& child, Actor& target)
1674 mParentImpl.LowerChildBelow(child, target);
1677 void Actor::SetInheritLayoutDirection(bool inherit)
1679 if(mInheritLayoutDirection != inherit)
1681 mInheritLayoutDirection = inherit;
1683 if(inherit && mParent)
1685 mParentImpl.InheritLayoutDirectionRecursively(GetParent()->mLayoutDirection);
1690 void Actor::SetUpdateSizeHint(const Vector2& updateSizeHint)
1692 // node is being used in a separate thread; queue a message to set the value & base value
1693 SceneGraph::NodePropertyMessage<Vector3>::Send(GetEventThreadServices(), &GetNode(), &GetNode().mUpdateSizeHint, &AnimatableProperty<Vector3>::Bake, Vector3(updateSizeHint.width, updateSizeHint.height, 0.f));
1696 } // namespace Internal