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>
27 #include <dali/public-api/common/constants.h>
28 #include <dali/public-api/common/dali-common.h>
29 #include <dali/public-api/math/radian.h>
30 #include <dali/public-api/math/vector2.h>
31 #include <dali/public-api/math/vector3.h>
32 #include <dali/public-api/object/type-registry.h>
34 #include <dali/devel-api/actors/actor-devel.h>
35 #include <dali/devel-api/actors/layer-devel.h>
36 #include <dali/devel-api/common/capabilities.h>
38 #include <dali/integration-api/debug.h>
40 #include <dali/internal/event/actors/actor-coords.h>
41 #include <dali/internal/event/actors/actor-parent.h>
42 #include <dali/internal/event/actors/actor-property-handler.h>
43 #include <dali/internal/event/actors/actor-relayouter.h>
44 #include <dali/internal/event/actors/camera-actor-impl.h>
45 #include <dali/internal/event/common/event-thread-services.h>
46 #include <dali/internal/event/common/property-helper.h>
47 #include <dali/internal/event/common/scene-impl.h>
48 #include <dali/internal/event/common/stage-impl.h>
49 #include <dali/internal/event/common/thread-local-storage.h>
50 #include <dali/internal/event/common/type-info-impl.h>
51 #include <dali/internal/event/events/actor-gesture-data.h>
52 #include <dali/internal/event/render-tasks/render-task-impl.h>
53 #include <dali/internal/event/render-tasks/render-task-list-impl.h>
54 #include <dali/internal/event/rendering/renderer-impl.h>
55 #include <dali/internal/event/size-negotiation/relayout-controller-impl.h>
56 #include <dali/internal/update/manager/update-manager.h>
57 #include <dali/internal/update/nodes/node-messages.h>
59 using Dali::Internal::SceneGraph::AnimatableProperty;
60 using Dali::Internal::SceneGraph::Node;
61 using Dali::Internal::SceneGraph::PropertyBase;
63 #if defined(DEBUG_ENABLED)
64 Debug::Filter* gLogFilter = Debug::Filter::New(Debug::NoLogging, false, "LOG_DEPTH_TIMER");
71 namespace // unnamed namespace
76 * We want to discourage the use of property strings (minimize string comparisons),
77 * particularly for the default properties.
78 * Name Type writable animatable constraint-input enum for index-checking
80 DALI_PROPERTY_TABLE_BEGIN
81 DALI_PROPERTY("parentOrigin", VECTOR3, true, false, true, Dali::Actor::Property::PARENT_ORIGIN)
82 DALI_PROPERTY("parentOriginX", FLOAT, true, false, true, Dali::Actor::Property::PARENT_ORIGIN_X)
83 DALI_PROPERTY("parentOriginY", FLOAT, true, false, true, Dali::Actor::Property::PARENT_ORIGIN_Y)
84 DALI_PROPERTY("parentOriginZ", FLOAT, true, false, true, Dali::Actor::Property::PARENT_ORIGIN_Z)
85 DALI_PROPERTY("anchorPoint", VECTOR3, true, false, true, Dali::Actor::Property::ANCHOR_POINT)
86 DALI_PROPERTY("anchorPointX", FLOAT, true, false, true, Dali::Actor::Property::ANCHOR_POINT_X)
87 DALI_PROPERTY("anchorPointY", FLOAT, true, false, true, Dali::Actor::Property::ANCHOR_POINT_Y)
88 DALI_PROPERTY("anchorPointZ", FLOAT, true, false, true, Dali::Actor::Property::ANCHOR_POINT_Z)
89 DALI_PROPERTY("size", VECTOR3, true, true, true, Dali::Actor::Property::SIZE)
90 DALI_PROPERTY("sizeWidth", FLOAT, true, true, true, Dali::Actor::Property::SIZE_WIDTH)
91 DALI_PROPERTY("sizeHeight", FLOAT, true, true, true, Dali::Actor::Property::SIZE_HEIGHT)
92 DALI_PROPERTY("sizeDepth", FLOAT, true, true, true, Dali::Actor::Property::SIZE_DEPTH)
93 DALI_PROPERTY("position", VECTOR3, true, true, true, Dali::Actor::Property::POSITION)
94 DALI_PROPERTY("positionX", FLOAT, true, true, true, Dali::Actor::Property::POSITION_X)
95 DALI_PROPERTY("positionY", FLOAT, true, true, true, Dali::Actor::Property::POSITION_Y)
96 DALI_PROPERTY("positionZ", FLOAT, true, true, true, Dali::Actor::Property::POSITION_Z)
97 DALI_PROPERTY("worldPosition", VECTOR3, false, false, true, Dali::Actor::Property::WORLD_POSITION)
98 DALI_PROPERTY("worldPositionX", FLOAT, false, false, true, Dali::Actor::Property::WORLD_POSITION_X)
99 DALI_PROPERTY("worldPositionY", FLOAT, false, false, true, Dali::Actor::Property::WORLD_POSITION_Y)
100 DALI_PROPERTY("worldPositionZ", FLOAT, false, false, true, Dali::Actor::Property::WORLD_POSITION_Z)
101 DALI_PROPERTY("orientation", ROTATION, true, true, true, Dali::Actor::Property::ORIENTATION)
102 DALI_PROPERTY("worldOrientation", ROTATION, false, false, true, Dali::Actor::Property::WORLD_ORIENTATION)
103 DALI_PROPERTY("scale", VECTOR3, true, true, true, Dali::Actor::Property::SCALE)
104 DALI_PROPERTY("scaleX", FLOAT, true, true, true, Dali::Actor::Property::SCALE_X)
105 DALI_PROPERTY("scaleY", FLOAT, true, true, true, Dali::Actor::Property::SCALE_Y)
106 DALI_PROPERTY("scaleZ", FLOAT, true, true, true, Dali::Actor::Property::SCALE_Z)
107 DALI_PROPERTY("worldScale", VECTOR3, false, false, true, Dali::Actor::Property::WORLD_SCALE)
108 DALI_PROPERTY("visible", BOOLEAN, true, true, true, Dali::Actor::Property::VISIBLE)
109 DALI_PROPERTY("color", VECTOR4, true, true, true, Dali::Actor::Property::COLOR)
110 DALI_PROPERTY("colorRed", FLOAT, true, true, true, Dali::Actor::Property::COLOR_RED)
111 DALI_PROPERTY("colorGreen", FLOAT, true, true, true, Dali::Actor::Property::COLOR_GREEN)
112 DALI_PROPERTY("colorBlue", FLOAT, true, true, true, Dali::Actor::Property::COLOR_BLUE)
113 DALI_PROPERTY("colorAlpha", FLOAT, true, true, true, Dali::Actor::Property::COLOR_ALPHA)
114 DALI_PROPERTY("worldColor", VECTOR4, false, false, true, Dali::Actor::Property::WORLD_COLOR)
115 DALI_PROPERTY("worldMatrix", MATRIX, false, false, true, Dali::Actor::Property::WORLD_MATRIX)
116 DALI_PROPERTY("name", STRING, true, false, false, Dali::Actor::Property::NAME)
117 DALI_PROPERTY("sensitive", BOOLEAN, true, false, false, Dali::Actor::Property::SENSITIVE)
118 DALI_PROPERTY("leaveRequired", BOOLEAN, true, false, false, Dali::Actor::Property::LEAVE_REQUIRED)
119 DALI_PROPERTY("inheritOrientation", BOOLEAN, true, false, false, Dali::Actor::Property::INHERIT_ORIENTATION)
120 DALI_PROPERTY("inheritScale", BOOLEAN, true, false, false, Dali::Actor::Property::INHERIT_SCALE)
121 DALI_PROPERTY("colorMode", INTEGER, true, false, false, Dali::Actor::Property::COLOR_MODE)
122 DALI_PROPERTY("drawMode", INTEGER, true, false, false, Dali::Actor::Property::DRAW_MODE)
123 DALI_PROPERTY("sizeModeFactor", VECTOR3, true, false, false, Dali::Actor::Property::SIZE_MODE_FACTOR)
124 DALI_PROPERTY("widthResizePolicy", STRING, true, false, false, Dali::Actor::Property::WIDTH_RESIZE_POLICY)
125 DALI_PROPERTY("heightResizePolicy", STRING, true, false, false, Dali::Actor::Property::HEIGHT_RESIZE_POLICY)
126 DALI_PROPERTY("sizeScalePolicy", INTEGER, true, false, false, Dali::Actor::Property::SIZE_SCALE_POLICY)
127 DALI_PROPERTY("widthForHeight", BOOLEAN, true, false, false, Dali::Actor::Property::WIDTH_FOR_HEIGHT)
128 DALI_PROPERTY("heightForWidth", BOOLEAN, true, false, false, Dali::Actor::Property::HEIGHT_FOR_WIDTH)
129 DALI_PROPERTY("padding", VECTOR4, true, false, false, Dali::Actor::Property::PADDING)
130 DALI_PROPERTY("minimumSize", VECTOR2, true, false, false, Dali::Actor::Property::MINIMUM_SIZE)
131 DALI_PROPERTY("maximumSize", VECTOR2, true, false, false, Dali::Actor::Property::MAXIMUM_SIZE)
132 DALI_PROPERTY("inheritPosition", BOOLEAN, true, false, false, Dali::Actor::Property::INHERIT_POSITION)
133 DALI_PROPERTY("clippingMode", STRING, true, false, false, Dali::Actor::Property::CLIPPING_MODE)
134 DALI_PROPERTY("layoutDirection", STRING, true, false, false, Dali::Actor::Property::LAYOUT_DIRECTION)
135 DALI_PROPERTY("inheritLayoutDirection", BOOLEAN, true, false, false, Dali::Actor::Property::INHERIT_LAYOUT_DIRECTION)
136 DALI_PROPERTY("opacity", FLOAT, true, true, true, Dali::Actor::Property::OPACITY)
137 DALI_PROPERTY("screenPosition", VECTOR2, false, false, false, Dali::Actor::Property::SCREEN_POSITION)
138 DALI_PROPERTY("positionUsesAnchorPoint", BOOLEAN, true, false, false, Dali::Actor::Property::POSITION_USES_ANCHOR_POINT)
139 DALI_PROPERTY("culled", BOOLEAN, false, false, true, Dali::Actor::Property::CULLED)
140 DALI_PROPERTY("id", INTEGER, false, false, false, Dali::Actor::Property::ID)
141 DALI_PROPERTY("hierarchyDepth", INTEGER, false, false, false, Dali::Actor::Property::HIERARCHY_DEPTH)
142 DALI_PROPERTY("isRoot", BOOLEAN, false, false, false, Dali::Actor::Property::IS_ROOT)
143 DALI_PROPERTY("isLayer", BOOLEAN, false, false, false, Dali::Actor::Property::IS_LAYER)
144 DALI_PROPERTY("connectedToScene", BOOLEAN, false, false, false, Dali::Actor::Property::CONNECTED_TO_SCENE)
145 DALI_PROPERTY("keyboardFocusable", BOOLEAN, true, false, false, Dali::Actor::Property::KEYBOARD_FOCUSABLE)
146 DALI_PROPERTY("siblingOrder", INTEGER, true, false, false, Dali::DevelActor::Property::SIBLING_ORDER)
147 DALI_PROPERTY("updateSizeHint", VECTOR2, true, false, false, Dali::DevelActor::Property::UPDATE_SIZE_HINT)
148 DALI_PROPERTY("captureAllTouchAfterStart", BOOLEAN, true, false, false, Dali::DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START)
149 DALI_PROPERTY("touchAreaOffset", RECTANGLE, true, false, false, Dali::DevelActor::Property::TOUCH_AREA_OFFSET)
150 DALI_PROPERTY("blendEquation", INTEGER, true, false, false, Dali::DevelActor::Property::BLEND_EQUATION)
151 DALI_PROPERTY("touchFocusable", BOOLEAN, true, false, false, Dali::DevelActor::Property::TOUCH_FOCUSABLE)
152 DALI_PROPERTY("keyboardFocusableChildren", BOOLEAN, true, false, false, Dali::DevelActor::Property::KEYBOARD_FOCUSABLE_CHILDREN)
153 DALI_PROPERTY_TABLE_END(DEFAULT_ACTOR_PROPERTY_START_INDEX, ActorDefaultProperties)
157 static constexpr std::string_view SIGNAL_HOVERED = "hovered";
158 static constexpr std::string_view SIGNAL_WHEEL_EVENT = "wheelEvent";
159 static constexpr std::string_view SIGNAL_ON_SCENE = "onScene";
160 static constexpr std::string_view SIGNAL_OFF_SCENE = "offScene";
161 static constexpr std::string_view SIGNAL_ON_RELAYOUT = "onRelayout";
162 static constexpr std::string_view SIGNAL_TOUCHED = "touched";
163 static constexpr std::string_view SIGNAL_VISIBILITY_CHANGED = "visibilityChanged";
164 static constexpr std::string_view SIGNAL_LAYOUT_DIRECTION_CHANGED = "layoutDirectionChanged";
165 static constexpr std::string_view SIGNAL_CHILD_ADDED = "childAdded";
166 static constexpr std::string_view SIGNAL_CHILD_REMOVED = "childRemoved";
170 static constexpr std::string_view ACTION_SHOW = "show";
171 static constexpr std::string_view ACTION_HIDE = "hide";
173 BaseHandle CreateActor()
175 return Dali::Actor::New();
178 TypeRegistration mType(typeid(Dali::Actor), typeid(Dali::Handle), CreateActor, ActorDefaultProperties);
180 SignalConnectorType signalConnector2(mType, std::string(SIGNAL_HOVERED), &Actor::DoConnectSignal);
181 SignalConnectorType signalConnector3(mType, std::string(SIGNAL_WHEEL_EVENT), &Actor::DoConnectSignal);
182 SignalConnectorType signalConnector4(mType, std::string(SIGNAL_ON_SCENE), &Actor::DoConnectSignal);
183 SignalConnectorType signalConnector5(mType, std::string(SIGNAL_OFF_SCENE), &Actor::DoConnectSignal);
184 SignalConnectorType signalConnector6(mType, std::string(SIGNAL_ON_RELAYOUT), &Actor::DoConnectSignal);
185 SignalConnectorType signalConnector7(mType, std::string(SIGNAL_TOUCHED), &Actor::DoConnectSignal);
186 SignalConnectorType signalConnector8(mType, std::string(SIGNAL_VISIBILITY_CHANGED), &Actor::DoConnectSignal);
187 SignalConnectorType signalConnector9(mType, std::string(SIGNAL_LAYOUT_DIRECTION_CHANGED), &Actor::DoConnectSignal);
188 SignalConnectorType signalConnector10(mType, std::string(SIGNAL_CHILD_ADDED), &Actor::DoConnectSignal);
189 SignalConnectorType signalConnector11(mType, std::string(SIGNAL_CHILD_REMOVED), &Actor::DoConnectSignal);
191 TypeAction a1(mType, std::string(ACTION_SHOW), &Actor::DoAction);
192 TypeAction a2(mType, std::string(ACTION_HIDE), &Actor::DoAction);
195 * @brief Extract a given dimension from a Vector2
197 * @param[in] values The values to extract from
198 * @param[in] dimension The dimension to extract
199 * @return Return the value for the dimension
201 constexpr float GetDimensionValue(const Vector2& values, Dimension::Type dimension)
205 case Dimension::WIDTH:
209 case Dimension::HEIGHT:
211 return values.height;
222 * @brief Extract a given dimension from a Vector3
224 * @param[in] values The values to extract from
225 * @param[in] dimension The dimension to extract
226 * @return Return the value for the dimension
228 float GetDimensionValue(const Vector3& values, Dimension::Type dimension)
230 return GetDimensionValue(values.GetVectorXY(), dimension);
233 /// Helper for emitting a signal
234 template<typename Signal, typename Event>
235 bool EmitConsumingSignal(Actor& actor, Signal& signal, const Event& event)
237 bool consumed = false;
241 Dali::Actor handle(&actor);
242 consumed = signal.Emit(handle, event);
248 /// Helper for emitting signals with multiple parameters
249 template<typename Signal, typename... Param>
250 void EmitSignal(Actor& actor, Signal& signal, Param... params)
254 Dali::Actor handle(&actor);
255 signal.Emit(handle, params...);
259 } // unnamed namespace
261 ActorPtr Actor::New()
263 // pass a reference to actor, actor does not own its node
264 ActorPtr actor(new Actor(BASIC, *CreateNode()));
266 // Second-phase construction
272 const SceneGraph::Node* Actor::CreateNode()
274 // create node. Nodes are owned by the update manager
275 SceneGraph::Node* node = SceneGraph::Node::New();
276 OwnerPointer<SceneGraph::Node> transferOwnership(node);
277 Internal::ThreadLocalStorage* tls = Internal::ThreadLocalStorage::GetInternal();
279 DALI_ASSERT_ALWAYS(tls && "ThreadLocalStorage is null");
281 AddNodeMessage(tls->GetUpdateManager(), transferOwnership);
286 void Actor::SetName(std::string_view name)
288 mName = ConstString(name);
290 // ATTENTION: string for debug purposes is not thread safe.
291 DALI_LOG_SET_OBJECT_STRING(const_cast<SceneGraph::Node*>(&GetNode()), mName.GetCString());
294 uint32_t Actor::GetId() const
296 return GetNode().GetId();
299 Dali::Layer Actor::GetLayer()
303 // Short-circuit for Layer derived actors
306 layer = Dali::Layer(static_cast<Dali::Internal::Layer*>(this)); // static cast as we trust the flag
309 // Find the immediate Layer parent
310 for(Actor* parent = GetParent(); !layer && parent != nullptr; parent = parent->GetParent())
312 if(parent->IsLayer())
314 layer = Dali::Layer(static_cast<Dali::Internal::Layer*>(parent)); // static cast as we trust the flag
321 void Actor::Unparent()
325 // Remove this actor from the parent. The remove will put a relayout request in for
326 // the parent if required
327 mParent->Remove(*this);
328 // mParent is now NULL!
332 void Actor::SetParentOrigin(const Vector3& origin)
334 // node is being used in a separate thread; queue a message to set the value & base value
335 SetParentOriginMessage(GetEventThreadServices(), GetNode(), origin);
337 // Cache for event-thread access
340 // not allocated, check if different from default
341 if(ParentOrigin::DEFAULT != origin)
343 mParentOrigin = new Vector3(origin);
348 // check if different from current costs more than just set
349 *mParentOrigin = origin;
353 const Vector3& Actor::GetCurrentParentOrigin() const
355 // Cached for event-thread access
356 return (mParentOrigin) ? *mParentOrigin : ParentOrigin::DEFAULT;
359 void Actor::SetAnchorPoint(const Vector3& anchor)
361 // node is being used in a separate thread; queue a message to set the value & base value
362 SetAnchorPointMessage(GetEventThreadServices(), GetNode(), anchor);
364 // Cache for event-thread access
367 // not allocated, check if different from default
368 if(AnchorPoint::DEFAULT != anchor)
370 mAnchorPoint = new Vector3(anchor);
375 // check if different from current costs more than just set
376 *mAnchorPoint = anchor;
380 const Vector3& Actor::GetCurrentAnchorPoint() const
382 // Cached for event-thread access
383 return (mAnchorPoint) ? *mAnchorPoint : AnchorPoint::DEFAULT;
386 void Actor::SetPosition(float x, float y)
388 SetPosition(Vector3(x, y, 0.0f));
391 void Actor::SetPosition(float x, float y, float z)
393 SetPosition(Vector3(x, y, z));
396 void Actor::SetPosition(const Vector3& position)
398 mTargetPosition = position;
400 // node is being used in a separate thread; queue a message to set the value & base value
401 SceneGraph::NodeTransformPropertyMessage<Vector3>::Send(GetEventThreadServices(), &GetNode(), &GetNode().mPosition, &SceneGraph::TransformManagerPropertyHandler<Vector3>::Bake, position);
404 void Actor::SetX(float x)
406 mTargetPosition.x = x;
408 // node is being used in a separate thread; queue a message to set the value & base value
409 SceneGraph::NodeTransformComponentMessage<Vector3>::Send(GetEventThreadServices(), &GetNode(), &GetNode().mPosition, &SceneGraph::TransformManagerPropertyHandler<Vector3>::BakeX, x);
412 void Actor::SetY(float y)
414 mTargetPosition.y = y;
416 // node is being used in a separate thread; queue a message to set the value & base value
417 SceneGraph::NodeTransformComponentMessage<Vector3>::Send(GetEventThreadServices(), &GetNode(), &GetNode().mPosition, &SceneGraph::TransformManagerPropertyHandler<Vector3>::BakeY, y);
420 void Actor::SetZ(float z)
422 mTargetPosition.z = z;
424 // node is being used in a separate thread; queue a message to set the value & base value
425 SceneGraph::NodeTransformComponentMessage<Vector3>::Send(GetEventThreadServices(), &GetNode(), &GetNode().mPosition, &SceneGraph::TransformManagerPropertyHandler<Vector3>::BakeZ, z);
428 void Actor::TranslateBy(const Vector3& distance)
430 mTargetPosition += distance;
432 // node is being used in a separate thread; queue a message to set the value & base value
433 SceneGraph::NodeTransformPropertyMessage<Vector3>::Send(GetEventThreadServices(), &GetNode(), &GetNode().mPosition, &SceneGraph::TransformManagerPropertyHandler<Vector3>::BakeRelative, distance);
436 const Vector3& Actor::GetCurrentPosition() const
438 // node is being used in a separate thread; copy the value from the previous update
439 return GetNode().GetPosition(GetEventThreadServices().GetEventBufferIndex());
442 const Vector3& Actor::GetCurrentWorldPosition() const
444 // node is being used in a separate thread; copy the value from the previous update
445 return GetNode().GetWorldPosition(GetEventThreadServices().GetEventBufferIndex());
448 const Vector2 Actor::GetCurrentScreenPosition() const
450 if(mScene && OnScene())
452 Vector3 worldPosition = GetNode().GetWorldPosition(GetEventThreadServices().GetEventBufferIndex());
453 Vector3 cameraPosition = mScene->GetDefaultCameraActor().GetNode().GetWorldPosition(GetEventThreadServices().GetEventBufferIndex());
454 worldPosition -= cameraPosition;
456 Vector3 actorSize = GetCurrentSize() * GetCurrentWorldScale();
457 Vector2 halfSceneSize(mScene->GetSize() * 0.5f); // World position origin is center of scene
458 Vector3 halfActorSize(actorSize * 0.5f);
459 Vector3 anchorPointOffSet = halfActorSize - actorSize * (mPositionUsesAnchorPoint ? GetCurrentAnchorPoint() : AnchorPoint::TOP_LEFT);
461 return Vector2(halfSceneSize.width + worldPosition.x - anchorPointOffSet.x,
462 halfSceneSize.height + worldPosition.y - anchorPointOffSet.y);
465 return Vector2::ZERO;
468 void Actor::SetInheritPosition(bool inherit)
470 if(mInheritPosition != inherit)
472 // non animatable so keep local copy
473 mInheritPosition = inherit;
474 SetInheritPositionMessage(GetEventThreadServices(), GetNode(), inherit);
478 void Actor::SetOrientation(const Radian& angle, const Vector3& axis)
480 Vector3 normalizedAxis(axis.x, axis.y, axis.z);
481 normalizedAxis.Normalize();
483 Quaternion orientation(angle, normalizedAxis);
485 SetOrientation(orientation);
488 void Actor::SetOrientation(const Quaternion& orientation)
490 mTargetOrientation = orientation;
492 // node is being used in a separate thread; queue a message to set the value & base value
493 SceneGraph::NodeTransformPropertyMessage<Quaternion>::Send(GetEventThreadServices(), &GetNode(), &GetNode().mOrientation, &SceneGraph::TransformManagerPropertyHandler<Quaternion>::Bake, orientation);
496 void Actor::RotateBy(const Radian& angle, const Vector3& axis)
498 RotateBy(Quaternion(angle, axis));
501 void Actor::RotateBy(const Quaternion& relativeRotation)
503 mTargetOrientation *= Quaternion(relativeRotation);
505 // node is being used in a separate thread; queue a message to set the value & base value
506 SceneGraph::NodeTransformPropertyMessage<Quaternion>::Send(GetEventThreadServices(), &GetNode(), &GetNode().mOrientation, &SceneGraph::TransformManagerPropertyHandler<Quaternion>::BakeRelative, relativeRotation);
509 const Quaternion& Actor::GetCurrentOrientation() const
511 // node is being used in a separate thread; copy the value from the previous update
512 return GetNode().GetOrientation(GetEventThreadServices().GetEventBufferIndex());
515 const Quaternion& Actor::GetCurrentWorldOrientation() const
517 // node is being used in a separate thread; copy the value from the previous update
518 return GetNode().GetWorldOrientation(GetEventThreadServices().GetEventBufferIndex());
521 void Actor::SetScale(float scale)
523 SetScale(Vector3(scale, scale, scale));
526 void Actor::SetScale(float x, float y, float z)
528 SetScale(Vector3(x, y, z));
531 void Actor::SetScale(const Vector3& scale)
533 mTargetScale = scale;
535 // node is being used in a separate thread; queue a message to set the value & base value
536 SceneGraph::NodeTransformPropertyMessage<Vector3>::Send(GetEventThreadServices(), &GetNode(), &GetNode().mScale, &SceneGraph::TransformManagerPropertyHandler<Vector3>::Bake, scale);
539 void Actor::SetScaleX(float x)
543 // node is being used in a separate thread; queue a message to set the value & base value
544 SceneGraph::NodeTransformComponentMessage<Vector3>::Send(GetEventThreadServices(), &GetNode(), &GetNode().mScale, &SceneGraph::TransformManagerPropertyHandler<Vector3>::BakeX, x);
547 void Actor::SetScaleY(float y)
551 // node is being used in a separate thread; queue a message to set the value & base value
552 SceneGraph::NodeTransformComponentMessage<Vector3>::Send(GetEventThreadServices(), &GetNode(), &GetNode().mScale, &SceneGraph::TransformManagerPropertyHandler<Vector3>::BakeY, y);
555 void Actor::SetScaleZ(float z)
559 // node is being used in a separate thread; queue a message to set the value & base value
560 SceneGraph::NodeTransformComponentMessage<Vector3>::Send(GetEventThreadServices(), &GetNode(), &GetNode().mScale, &SceneGraph::TransformManagerPropertyHandler<Vector3>::BakeZ, z);
563 void Actor::ScaleBy(const Vector3& relativeScale)
565 mTargetScale *= relativeScale;
567 // node is being used in a separate thread; queue a message to set the value & base value
568 SceneGraph::NodeTransformPropertyMessage<Vector3>::Send(GetEventThreadServices(), &GetNode(), &GetNode().mScale, &SceneGraph::TransformManagerPropertyHandler<Vector3>::BakeRelativeMultiply, relativeScale);
571 const Vector3& Actor::GetCurrentScale() const
573 // node is being used in a separate thread; copy the value from the previous update
574 return GetNode().GetScale(GetEventThreadServices().GetEventBufferIndex());
577 const Vector3& Actor::GetCurrentWorldScale() const
579 // node is being used in a separate thread; copy the value from the previous update
580 return GetNode().GetWorldScale(GetEventThreadServices().GetEventBufferIndex());
583 void Actor::SetInheritScale(bool inherit)
585 if(mInheritScale != inherit)
587 // non animatable so keep local copy
588 mInheritScale = inherit;
589 // node is being used in a separate thread; queue a message to set the value
590 SetInheritScaleMessage(GetEventThreadServices(), GetNode(), inherit);
594 Matrix Actor::GetCurrentWorldMatrix() const
596 return GetNode().GetWorldMatrix(0);
599 void Actor::SetVisible(bool visible)
601 SetVisibleInternal(visible, SendMessage::TRUE);
604 bool Actor::IsVisible() const
606 // node is being used in a separate thread; copy the value from the previous update
607 return GetNode().IsVisible(GetEventThreadServices().GetEventBufferIndex());
610 void Actor::SetOpacity(float opacity)
612 mTargetColor.a = opacity;
614 // node is being used in a separate thread; queue a message to set the value & base value
615 SceneGraph::NodePropertyComponentMessage<Vector4>::Send(GetEventThreadServices(), &GetNode(), &GetNode().mColor, &AnimatableProperty<Vector4>::BakeW, opacity);
617 RequestRenderingMessage(GetEventThreadServices().GetUpdateManager());
620 float Actor::GetCurrentOpacity() const
622 // node is being used in a separate thread; copy the value from the previous update
623 return GetNode().GetOpacity(GetEventThreadServices().GetEventBufferIndex());
626 const Vector4& Actor::GetCurrentWorldColor() const
628 return GetNode().GetWorldColor(GetEventThreadServices().GetEventBufferIndex());
631 void Actor::SetColor(const Vector4& color)
633 mTargetColor = color;
635 // node is being used in a separate thread; queue a message to set the value & base value
636 SceneGraph::NodePropertyMessage<Vector4>::Send(GetEventThreadServices(), &GetNode(), &GetNode().mColor, &AnimatableProperty<Vector4>::Bake, color);
638 RequestRenderingMessage(GetEventThreadServices().GetUpdateManager());
641 void Actor::SetColorRed(float red)
643 mTargetColor.r = red;
645 // node is being used in a separate thread; queue a message to set the value & base value
646 SceneGraph::NodePropertyComponentMessage<Vector4>::Send(GetEventThreadServices(), &GetNode(), &GetNode().mColor, &AnimatableProperty<Vector4>::BakeX, red);
648 RequestRenderingMessage(GetEventThreadServices().GetUpdateManager());
651 void Actor::SetColorGreen(float green)
653 mTargetColor.g = green;
655 // node is being used in a separate thread; queue a message to set the value & base value
656 SceneGraph::NodePropertyComponentMessage<Vector4>::Send(GetEventThreadServices(), &GetNode(), &GetNode().mColor, &AnimatableProperty<Vector4>::BakeY, green);
658 RequestRenderingMessage(GetEventThreadServices().GetUpdateManager());
661 void Actor::SetColorBlue(float blue)
663 mTargetColor.b = blue;
665 // node is being used in a separate thread; queue a message to set the value & base value
666 SceneGraph::NodePropertyComponentMessage<Vector4>::Send(GetEventThreadServices(), &GetNode(), &GetNode().mColor, &AnimatableProperty<Vector4>::BakeZ, blue);
668 RequestRenderingMessage(GetEventThreadServices().GetUpdateManager());
671 const Vector4& Actor::GetCurrentColor() const
673 // node is being used in a separate thread; copy the value from the previous update
674 return GetNode().GetColor(GetEventThreadServices().GetEventBufferIndex());
677 void Actor::SetInheritOrientation(bool inherit)
679 if(mInheritOrientation != inherit)
681 // non animatable so keep local copy
682 mInheritOrientation = inherit;
683 // node is being used in a separate thread; queue a message to set the value
684 SetInheritOrientationMessage(GetEventThreadServices(), GetNode(), inherit);
688 void Actor::SetSizeModeFactor(const Vector3& factor)
692 mRelayoutData->sizeModeFactor = factor;
695 const Vector3& Actor::GetSizeModeFactor() const
699 return mRelayoutData->sizeModeFactor;
702 return Relayouter::DEFAULT_SIZE_MODE_FACTOR;
705 void Actor::SetColorMode(ColorMode colorMode)
707 // non animatable so keep local copy
708 mColorMode = colorMode;
709 // node is being used in a separate thread; queue a message to set the value
710 SetColorModeMessage(GetEventThreadServices(), GetNode(), colorMode);
713 void Actor::SetSize(float width, float height)
715 SetSize(Vector2(width, height));
718 void Actor::SetSize(float width, float height, float depth)
720 SetSize(Vector3(width, height, depth));
723 void Actor::SetSize(const Vector2& size)
725 SetSize(Vector3(size.width, size.height, 0.f));
728 void Actor::SetSizeInternal(const Vector2& size)
730 SetSizeInternal(Vector3(size.width, size.height, 0.f));
733 void Actor::SetSize(const Vector3& size)
735 if(IsRelayoutEnabled() && !mRelayoutData->insideRelayout)
737 // TODO we cannot just ignore the given Z but that means rewrite the size negotiation!!
738 SetPreferredSize(size.GetVectorXY());
742 SetSizeInternal(size);
746 void Actor::SetSizeInternal(const Vector3& size)
748 // dont allow recursive loop
749 DALI_ASSERT_ALWAYS(!mInsideOnSizeSet && "Cannot call SetSize from OnSizeSet");
750 // check that we have a node AND the new size width, height or depth is at least a little bit different from the old one
751 Vector3 currentSize = GetCurrentSize();
753 if((fabsf(mTargetSize.width - size.width) > Math::MACHINE_EPSILON_1) ||
754 (fabsf(mTargetSize.height - size.height) > Math::MACHINE_EPSILON_1) ||
755 (fabsf(mTargetSize.depth - size.depth) > Math::MACHINE_EPSILON_1) ||
756 (fabsf(mTargetSize.width - currentSize.width) > Math::MACHINE_EPSILON_1) ||
757 (fabsf(mTargetSize.height - currentSize.height) > Math::MACHINE_EPSILON_1) ||
758 (fabsf(mTargetSize.depth - currentSize.depth) > Math::MACHINE_EPSILON_1))
762 // node is being used in a separate thread; queue a message to set the value & base value
763 SceneGraph::NodeTransformPropertyMessage<Vector3>::Send(GetEventThreadServices(), &GetNode(), &GetNode().mSize, &SceneGraph::TransformManagerPropertyHandler<Vector3>::Bake, mTargetSize);
765 // Notification for derived classes
766 mInsideOnSizeSet = true;
767 OnSizeSet(mTargetSize);
768 mInsideOnSizeSet = false;
770 // Raise a relayout request if the flag is not locked
771 if(mRelayoutData && !mRelayoutData->insideRelayout)
778 void Actor::SetWidth(float width)
780 if(IsRelayoutEnabled() && !mRelayoutData->insideRelayout)
782 SetResizePolicy(ResizePolicy::FIXED, Dimension::WIDTH);
783 mRelayoutData->preferredSize.width = width;
787 mTargetSize.width = width;
789 // node is being used in a separate thread; queue a message to set the value & base value
790 SceneGraph::NodeTransformComponentMessage<Vector3>::Send(GetEventThreadServices(), &GetNode(), &GetNode().mSize, &SceneGraph::TransformManagerPropertyHandler<Vector3>::BakeX, width);
793 mUseAnimatedSize &= ~AnimatedSizeFlag::WIDTH;
798 void Actor::SetHeight(float height)
800 if(IsRelayoutEnabled() && !mRelayoutData->insideRelayout)
802 SetResizePolicy(ResizePolicy::FIXED, Dimension::HEIGHT);
803 mRelayoutData->preferredSize.height = height;
807 mTargetSize.height = height;
809 // node is being used in a separate thread; queue a message to set the value & base value
810 SceneGraph::NodeTransformComponentMessage<Vector3>::Send(GetEventThreadServices(), &GetNode(), &GetNode().mSize, &SceneGraph::TransformManagerPropertyHandler<Vector3>::BakeY, height);
813 mUseAnimatedSize &= ~AnimatedSizeFlag::HEIGHT;
818 void Actor::SetDepth(float depth)
820 mTargetSize.depth = depth;
822 mUseAnimatedSize &= ~AnimatedSizeFlag::DEPTH;
824 // node is being used in a separate thread; queue a message to set the value & base value
825 SceneGraph::NodeTransformComponentMessage<Vector3>::Send(GetEventThreadServices(), &GetNode(), &GetNode().mSize, &SceneGraph::TransformManagerPropertyHandler<Vector3>::BakeZ, depth);
828 Vector3 Actor::GetTargetSize() const
830 Vector3 size = mTargetSize;
832 if(mUseAnimatedSize & AnimatedSizeFlag::WIDTH)
834 // Should return animated size if size is animated
835 size.width = mAnimatedSize.width;
839 // Should return preferred size if size is fixed as set by SetSize
840 if(GetResizePolicy(Dimension::WIDTH) == ResizePolicy::FIXED)
842 size.width = GetPreferredSize().width;
846 if(mUseAnimatedSize & AnimatedSizeFlag::HEIGHT)
848 size.height = mAnimatedSize.height;
852 if(GetResizePolicy(Dimension::HEIGHT) == ResizePolicy::FIXED)
854 size.height = GetPreferredSize().height;
858 if(mUseAnimatedSize & AnimatedSizeFlag::DEPTH)
860 size.depth = mAnimatedSize.depth;
866 const Vector3& Actor::GetCurrentSize() const
868 // node is being used in a separate thread; copy the value from the previous update
869 return GetNode().GetSize(GetEventThreadServices().GetEventBufferIndex());
872 Vector3 Actor::GetNaturalSize() const
874 // It is up to deriving classes to return the appropriate natural size
875 return Vector3(0.0f, 0.0f, 0.0f);
878 void Actor::SetResizePolicy(ResizePolicy::Type policy, Dimension::Type dimension)
880 EnsureRelayouter().SetResizePolicy(policy, dimension, mTargetSize);
882 OnSetResizePolicy(policy, dimension);
884 // Trigger relayout on this control
888 ResizePolicy::Type Actor::GetResizePolicy(Dimension::Type dimension) const
892 return mRelayoutData->GetResizePolicy(dimension);
895 return ResizePolicy::DEFAULT;
898 void Actor::SetSizeScalePolicy(SizeScalePolicy::Type policy)
902 mRelayoutData->sizeSetPolicy = policy;
904 // Trigger relayout on this control
908 SizeScalePolicy::Type Actor::GetSizeScalePolicy() const
912 return mRelayoutData->sizeSetPolicy;
915 return Relayouter::DEFAULT_SIZE_SCALE_POLICY;
918 void Actor::SetDimensionDependency(Dimension::Type dimension, Dimension::Type dependency)
920 EnsureRelayouter().SetDimensionDependency(dimension, dependency);
923 Dimension::Type Actor::GetDimensionDependency(Dimension::Type dimension) const
927 return mRelayoutData->GetDimensionDependency(dimension);
930 return Dimension::ALL_DIMENSIONS; // Default
933 void Actor::SetRelayoutEnabled(bool relayoutEnabled)
935 // If relayout data has not been allocated yet and the client is requesting
936 // to disable it, do nothing
937 if(mRelayoutData || relayoutEnabled)
941 DALI_ASSERT_DEBUG(mRelayoutData && "mRelayoutData not created");
943 mRelayoutData->relayoutEnabled = relayoutEnabled;
947 bool Actor::IsRelayoutEnabled() const
949 // Assume that if relayout data has not been allocated yet then
950 // relayout is disabled
951 return mRelayoutData && mRelayoutData->relayoutEnabled;
954 void Actor::SetLayoutDirty(bool dirty, Dimension::Type dimension)
956 EnsureRelayouter().SetLayoutDirty(dirty, dimension);
959 bool Actor::IsLayoutDirty(Dimension::Type dimension) const
961 return mRelayoutData && mRelayoutData->IsLayoutDirty(dimension);
964 bool Actor::RelayoutPossible(Dimension::Type dimension) const
966 return mRelayoutData && mRelayoutData->relayoutEnabled && !IsLayoutDirty(dimension);
969 bool Actor::RelayoutRequired(Dimension::Type dimension) const
971 return mRelayoutData && mRelayoutData->relayoutEnabled && IsLayoutDirty(dimension);
974 uint32_t Actor::AddRenderer(Renderer& renderer)
978 mRenderers = new RendererContainer;
981 if(mIsBlendEquationSet)
983 renderer.SetBlendEquation(static_cast<DevelBlendEquation::Type>(mBlendEquation));
986 uint32_t index = static_cast<uint32_t>(mRenderers->size()); // 4,294,967,295 renderers per actor
987 RendererPtr rendererPtr = RendererPtr(&renderer);
988 mRenderers->push_back(rendererPtr);
989 AttachRendererMessage(GetEventThreadServices().GetUpdateManager(), GetNode(), renderer.GetRendererSceneObject());
993 uint32_t Actor::GetRendererCount() const
995 uint32_t rendererCount(0);
998 rendererCount = static_cast<uint32_t>(mRenderers->size()); // 4,294,967,295 renderers per actor
1001 return rendererCount;
1004 RendererPtr Actor::GetRendererAt(uint32_t index)
1006 RendererPtr renderer;
1007 if(index < GetRendererCount())
1009 renderer = (*mRenderers)[index];
1015 void Actor::RemoveRenderer(Renderer& renderer)
1019 RendererIter end = mRenderers->end();
1020 for(RendererIter iter = mRenderers->begin(); iter != end; ++iter)
1022 if((*iter).Get() == &renderer)
1024 mRenderers->erase(iter);
1025 DetachRendererMessage(GetEventThreadServices(), GetNode(), renderer.GetRendererSceneObject());
1032 void Actor::RemoveRenderer(uint32_t index)
1034 if(index < GetRendererCount())
1036 RendererPtr renderer = (*mRenderers)[index];
1037 DetachRendererMessage(GetEventThreadServices(), GetNode(), renderer.Get()->GetRendererSceneObject());
1038 mRenderers->erase(mRenderers->begin() + index);
1042 void Actor::SetBlendEquation(DevelBlendEquation::Type blendEquation)
1044 if(Dali::Capabilities::IsBlendEquationSupported(blendEquation))
1046 if(mBlendEquation != blendEquation)
1048 mBlendEquation = blendEquation;
1049 uint32_t rendererCount = GetRendererCount();
1050 for(uint32_t i = 0; i < rendererCount; ++i)
1052 RendererPtr renderer = GetRendererAt(i);
1053 renderer->SetBlendEquation(static_cast<DevelBlendEquation::Type>(blendEquation));
1056 mIsBlendEquationSet = true;
1060 DALI_LOG_ERROR("Invalid blend equation is entered.\n");
1064 DevelBlendEquation::Type Actor::GetBlendEquation() const
1066 return mBlendEquation;
1069 void Actor::SetTransparent(bool transparent)
1071 SetTransparentMessage(GetEventThreadServices(), GetNode(), transparent);
1074 bool Actor::IsTransparent() const
1076 return GetNode().IsTransparent();
1079 void Actor::SetDrawMode(DrawMode::Type drawMode)
1081 // this flag is not animatable so keep the value
1082 mDrawMode = drawMode;
1084 // node is being used in a separate thread; queue a message to set the value
1085 SetDrawModeMessage(GetEventThreadServices(), GetNode(), drawMode);
1088 bool Actor::ScreenToLocal(float& localX, float& localY, float screenX, float screenY) const
1090 return mScene && OnScene() && ConvertScreenToLocalRenderTaskList(mScene->GetRenderTaskList(), GetNode().GetWorldMatrix(0), GetCurrentSize(), localX, localY, screenX, screenY);
1093 bool Actor::ScreenToLocal(const RenderTask& renderTask, float& localX, float& localY, float screenX, float screenY) const
1095 return OnScene() && ConvertScreenToLocalRenderTask(renderTask, GetNode().GetWorldMatrix(0), GetCurrentSize(), localX, localY, screenX, screenY);
1098 bool Actor::ScreenToLocal(const Matrix& viewMatrix, const Matrix& projectionMatrix, const Viewport& viewport, float& localX, float& localY, float screenX, float screenY) const
1100 return OnScene() && ConvertScreenToLocal(viewMatrix, projectionMatrix, GetNode().GetWorldMatrix(0), GetCurrentSize(), viewport, localX, localY, screenX, screenY);
1103 ActorGestureData& Actor::GetGestureData()
1105 // Likely scenario is that once gesture-data is created for this actor, the actor will require
1106 // that gesture for its entire life-time so no need to destroy it until the actor is destroyed
1107 if(nullptr == mGestureData)
1109 mGestureData = new ActorGestureData;
1111 return *mGestureData;
1114 bool Actor::IsGestureRequired(GestureType::Value type) const
1116 return mGestureData && mGestureData->IsGestureRequired(type);
1119 bool Actor::EmitInterceptTouchEventSignal(const Dali::TouchEvent& touch)
1121 return EmitConsumingSignal(*this, mInterceptTouchedSignal, touch);
1124 bool Actor::EmitTouchEventSignal(const Dali::TouchEvent& touch)
1126 return EmitConsumingSignal(*this, mTouchedSignal, touch);
1129 bool Actor::EmitHoverEventSignal(const Dali::HoverEvent& event)
1131 return EmitConsumingSignal(*this, mHoveredSignal, event);
1134 bool Actor::EmitWheelEventSignal(const Dali::WheelEvent& event)
1136 return EmitConsumingSignal(*this, mWheelEventSignal, event);
1139 void Actor::EmitVisibilityChangedSignal(bool visible, DevelActor::VisibilityChange::Type type)
1141 EmitSignal(*this, mVisibilityChangedSignal, visible, type);
1144 void Actor::EmitLayoutDirectionChangedSignal(LayoutDirection::Type type)
1146 EmitSignal(*this, mLayoutDirectionChangedSignal, type);
1149 DevelActor::ChildChangedSignalType& Actor::ChildAddedSignal()
1151 return mParentImpl.ChildAddedSignal();
1154 DevelActor::ChildChangedSignalType& Actor::ChildRemovedSignal()
1156 return mParentImpl.ChildRemovedSignal();
1159 DevelActor::ChildOrderChangedSignalType& Actor::ChildOrderChangedSignal()
1161 return mParentImpl.ChildOrderChangedSignal();
1164 bool Actor::DoConnectSignal(BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor)
1166 bool connected(true);
1167 Actor* actor = static_cast<Actor*>(object); // TypeRegistry guarantees that this is the correct type.
1169 std::string_view name(signalName);
1171 if(name == SIGNAL_HOVERED)
1173 actor->HoveredSignal().Connect(tracker, functor);
1175 else if(signalName == SIGNAL_WHEEL_EVENT)
1177 actor->WheelEventSignal().Connect(tracker, functor);
1179 else if(name == SIGNAL_ON_SCENE)
1181 actor->OnSceneSignal().Connect(tracker, functor);
1183 else if(name == SIGNAL_OFF_SCENE)
1185 actor->OffSceneSignal().Connect(tracker, functor);
1187 else if(name == SIGNAL_ON_RELAYOUT)
1189 actor->OnRelayoutSignal().Connect(tracker, functor);
1191 else if(name == SIGNAL_TOUCHED)
1193 actor->TouchedSignal().Connect(tracker, functor);
1195 else if(name == SIGNAL_VISIBILITY_CHANGED)
1197 actor->VisibilityChangedSignal().Connect(tracker, functor);
1199 else if(name == SIGNAL_LAYOUT_DIRECTION_CHANGED)
1201 actor->LayoutDirectionChangedSignal().Connect(tracker, functor);
1203 else if(name == SIGNAL_CHILD_ADDED)
1205 actor->ChildAddedSignal().Connect(tracker, functor);
1207 else if(name == SIGNAL_CHILD_REMOVED)
1209 actor->ChildRemovedSignal().Connect(tracker, functor);
1213 // signalName does not match any signal
1220 Actor::Actor(DerivedType derivedType, const SceneGraph::Node& node)
1225 mRenderers(nullptr),
1226 mParentOrigin(nullptr),
1227 mAnchorPoint(nullptr),
1228 mRelayoutData(nullptr),
1229 mGestureData(nullptr),
1230 mInterceptTouchedSignal(),
1233 mWheelEventSignal(),
1236 mOnRelayoutSignal(),
1237 mVisibilityChangedSignal(),
1238 mLayoutDirectionChangedSignal(),
1239 mTargetOrientation(Quaternion::IDENTITY),
1240 mTargetColor(Color::WHITE),
1241 mTargetSize(Vector3::ZERO),
1242 mTargetPosition(Vector3::ZERO),
1243 mTargetScale(Vector3::ONE),
1244 mAnimatedSize(Vector3::ZERO),
1245 mTouchAreaOffset(0, 0, 0, 0),
1249 mUseAnimatedSize(AnimatedSizeFlag::CLEAR),
1250 mIsRoot(ROOT_LAYER == derivedType),
1251 mIsLayer(LAYER == derivedType || ROOT_LAYER == derivedType),
1254 mLeaveRequired(false),
1255 mKeyboardFocusable(false),
1256 mKeyboardFocusableChildren(true),
1257 mTouchFocusable(false),
1258 mOnSceneSignalled(false),
1259 mInsideOnSizeSet(false),
1260 mInheritPosition(true),
1261 mInheritOrientation(true),
1262 mInheritScale(true),
1263 mPositionUsesAnchorPoint(true),
1265 mInheritLayoutDirection(true),
1266 mCaptureAllTouchAfterStart(false),
1267 mIsBlendEquationSet(false),
1268 mNeedGesturePropagation(false),
1269 mLayoutDirection(LayoutDirection::LEFT_TO_RIGHT),
1270 mDrawMode(DrawMode::NORMAL),
1271 mColorMode(Node::DEFAULT_COLOR_MODE),
1272 mClippingMode(ClippingMode::DISABLED),
1273 mBlendEquation(DevelBlendEquation::ADD)
1277 void Actor::Initialize()
1281 GetEventThreadServices().RegisterObject(this);
1286 // Remove mParent pointers from children even if we're destroying core,
1287 // to guard against GetParent() & Unparent() calls from CustomActor destructors.
1291 // Guard to allow handle destruction after Core has been destroyed
1292 if(EventThreadServices::IsCoreRunning())
1294 // Root layer will destroy its node in its own destructor
1297 DestroyNodeMessage(GetEventThreadServices().GetUpdateManager(), GetNode());
1299 GetEventThreadServices().UnregisterObject(this);
1303 // Cleanup optional gesture data
1304 delete mGestureData;
1306 // Cleanup optional parent origin and anchor
1307 delete mParentOrigin;
1308 delete mAnchorPoint;
1310 // Delete optional relayout data
1311 delete mRelayoutData;
1314 void Actor::Add(Actor& child, bool notify)
1316 mParentImpl.Add(child, notify);
1319 void Actor::Remove(Actor& child, bool notify)
1321 mParentImpl.Remove(child, notify);
1324 void Actor::SwitchParent(Actor& newParent)
1326 if(this == &newParent)
1328 DALI_LOG_ERROR("Cannot add actor to itself");
1332 if(!this->OnScene() || !newParent.OnScene())
1334 DALI_LOG_ERROR("Both of current parent and new parent must be on Scene");
1338 newParent.Add(*this, false);
1341 uint32_t Actor::GetChildCount() const
1343 return mParentImpl.GetChildCount();
1346 ActorPtr Actor::GetChildAt(uint32_t index) const
1348 return mParentImpl.GetChildAt(index);
1351 ActorContainer& Actor::GetChildrenInternal()
1353 return mParentImpl.GetChildrenInternal();
1356 ActorPtr Actor::FindChildByName(ConstString actorName)
1358 return mParentImpl.FindChildByName(actorName);
1361 ActorPtr Actor::FindChildById(const uint32_t id)
1363 return mParentImpl.FindChildById(id);
1366 void Actor::UnparentChildren()
1368 mParentImpl.UnparentChildren();
1371 void Actor::ConnectToScene(uint32_t parentDepth, bool notify)
1373 // This container is used instead of walking the Actor hierarchy.
1374 // It protects us when the Actor hierarchy is modified during OnSceneConnectionExternal callbacks.
1375 ActorContainer connectionList;
1379 mScene->RequestRebuildDepthTree();
1382 // This stage is atomic i.e. not interrupted by user callbacks.
1383 RecursiveConnectToScene(connectionList, parentDepth + 1);
1385 // Notify applications about the newly connected actors.
1386 for(const auto& actor : connectionList)
1388 actor->NotifyStageConnection(notify);
1394 void Actor::RecursiveConnectToScene(ActorContainer& connectionList, uint32_t depth)
1396 DALI_ASSERT_ALWAYS(!OnScene());
1399 mDepth = static_cast<uint16_t>(depth); // overflow ignored, not expected in practice
1401 ConnectToSceneGraph();
1403 // Notification for internal derived classes
1404 OnSceneConnectionInternal();
1406 // This stage is atomic; avoid emitting callbacks until all Actors are connected
1407 connectionList.push_back(ActorPtr(this));
1409 // Recursively connect children
1410 if(GetChildCount() > 0)
1412 for(const auto& child : mParentImpl.GetChildrenInternal())
1414 child->SetScene(*mScene);
1415 child->RecursiveConnectToScene(connectionList, depth + 1);
1421 * This method is called when the Actor is connected to the Stage.
1422 * The parent must have added its Node to the scene-graph.
1423 * The child must connect its Node to the parent's Node.
1424 * This is recursive; the child calls ConnectToScene() for its children.
1426 void Actor::ConnectToSceneGraph()
1428 DALI_ASSERT_DEBUG(mParent != NULL);
1430 // Reparent Node in next Update
1431 ConnectNodeMessage(GetEventThreadServices().GetUpdateManager(), GetParent()->GetNode(), GetNode());
1433 // Request relayout on all actors that are added to the scenegraph
1436 // Notification for Object::Observers
1440 void Actor::NotifyStageConnection(bool notify)
1442 // Actors can be removed (in a callback), before the on-stage stage is reported.
1443 // The actor may also have been reparented, in which case mOnSceneSignalled will be true.
1444 if(OnScene() && !mOnSceneSignalled)
1448 // Notification for external (CustomActor) derived classes
1449 OnSceneConnectionExternal(mDepth);
1451 if(!mOnSceneSignal.Empty())
1453 Dali::Actor handle(this);
1454 mOnSceneSignal.Emit(handle);
1458 // Guard against Remove during callbacks
1461 mOnSceneSignalled = true; // signal required next time Actor is removed
1466 void Actor::DisconnectFromStage(bool notify)
1468 // This container is used instead of walking the Actor hierachy.
1469 // It protects us when the Actor hierachy is modified during OnSceneDisconnectionExternal callbacks.
1470 ActorContainer disconnectionList;
1474 mScene->RequestRebuildDepthTree();
1477 // This stage is atomic i.e. not interrupted by user callbacks
1478 RecursiveDisconnectFromStage(disconnectionList);
1480 // Notify applications about the newly disconnected actors.
1481 for(const auto& actor : disconnectionList)
1483 actor->NotifyStageDisconnection(notify);
1487 void Actor::RecursiveDisconnectFromStage(ActorContainer& disconnectionList)
1489 // need to change state first so that internals relying on IsOnScene() inside OnSceneDisconnectionInternal() get the correct value
1492 // Recursively disconnect children
1493 if(GetChildCount() > 0)
1495 for(const auto& child : mParentImpl.GetChildrenInternal())
1497 child->RecursiveDisconnectFromStage(disconnectionList);
1501 // This stage is atomic; avoid emitting callbacks until all Actors are disconnected
1502 disconnectionList.push_back(ActorPtr(this));
1504 // Notification for internal derived classes
1505 OnSceneDisconnectionInternal();
1507 DisconnectFromSceneGraph();
1511 * This method is called by an actor or its parent, before a node removal message is sent.
1512 * This is recursive; the child calls DisconnectFromStage() for its children.
1514 void Actor::DisconnectFromSceneGraph()
1516 // Notification for Object::Observers
1517 OnSceneObjectRemove();
1520 void Actor::NotifyStageDisconnection(bool notify)
1522 // Actors can be added (in a callback), before the off-stage state is reported.
1523 // Also if the actor was added & removed before mOnSceneSignalled was set, then we don't notify here.
1524 // only do this step if there is a stage, i.e. Core is not being shut down
1525 if(EventThreadServices::IsCoreRunning() && !OnScene() && mOnSceneSignalled)
1529 // Notification for external (CustomeActor) derived classes
1530 OnSceneDisconnectionExternal();
1532 if(!mOffSceneSignal.Empty())
1534 Dali::Actor handle(this);
1535 mOffSceneSignal.Emit(handle);
1539 // Guard against Add during callbacks
1542 mOnSceneSignalled = false; // signal required next time Actor is added
1547 bool Actor::IsNodeConnected() const
1549 bool connected(false);
1553 if(IsRoot() || GetNode().GetParent())
1562 // This method initiates traversal of the actor tree using depth-first
1563 // traversal to set a depth index based on traversal order. It sends a
1564 // single message to update manager to update all the actor's nodes in
1565 // this tree with the depth index. The sceneGraphNodeDepths vector's
1566 // elements are ordered by depth, and could be used to reduce sorting
1567 // in the update thread.
1568 void Actor::RebuildDepthTree()
1570 DALI_LOG_TIMER_START(depthTimer);
1572 // Vector of scene-graph nodes and their depths to send to UpdateManager
1573 // in a single message
1574 OwnerPointer<SceneGraph::NodeDepths> sceneGraphNodeDepths(new SceneGraph::NodeDepths());
1576 int32_t depthIndex = 1;
1577 DepthTraverseActorTree(sceneGraphNodeDepths, depthIndex);
1579 SetDepthIndicesMessage(GetEventThreadServices().GetUpdateManager(), sceneGraphNodeDepths);
1580 DALI_LOG_TIMER_END(depthTimer, gLogFilter, Debug::Concise, "Depth tree traversal time: ");
1583 void Actor::DepthTraverseActorTree(OwnerPointer<SceneGraph::NodeDepths>& sceneGraphNodeDepths, int32_t& depthIndex)
1585 mSortedDepth = depthIndex * DevelLayer::SIBLING_ORDER_MULTIPLIER;
1586 sceneGraphNodeDepths->Add(const_cast<SceneGraph::Node*>(&GetNode()), mSortedDepth);
1588 // Create/add to children of this node
1589 if(GetChildCount() > 0)
1591 for(const auto& child : mParentImpl.GetChildrenInternal())
1593 Actor* childActor = child.Get();
1595 childActor->DepthTraverseActorTree(sceneGraphNodeDepths, depthIndex);
1600 void Actor::SetDefaultProperty(Property::Index index, const Property::Value& property)
1602 PropertyHandler::SetDefaultProperty(*this, index, property);
1605 // TODO: This method needs to be removed
1606 void Actor::SetSceneGraphProperty(Property::Index index, const PropertyMetadata& entry, const Property::Value& value)
1608 PropertyHandler::SetSceneGraphProperty(index, entry, value, GetEventThreadServices(), GetNode());
1611 Property::Value Actor::GetDefaultProperty(Property::Index index) const
1613 Property::Value value;
1615 if(!GetCachedPropertyValue(index, value))
1617 // If property value is not stored in the event-side, then it must be a scene-graph only property
1618 GetCurrentPropertyValue(index, value);
1624 Property::Value Actor::GetDefaultPropertyCurrentValue(Property::Index index) const
1626 Property::Value value;
1628 if(!GetCurrentPropertyValue(index, value))
1630 // If unable to retrieve scene-graph property value, then it must be an event-side only property
1631 GetCachedPropertyValue(index, value);
1637 void Actor::OnNotifyDefaultPropertyAnimation(Animation& animation, Property::Index index, const Property::Value& value, Animation::Type animationType)
1639 PropertyHandler::OnNotifyDefaultPropertyAnimation(*this, animation, index, value, animationType);
1642 const PropertyBase* Actor::GetSceneObjectAnimatableProperty(Property::Index index) const
1644 const PropertyBase* property = PropertyHandler::GetSceneObjectAnimatableProperty(index, GetNode());
1647 // not our property, ask base
1648 property = Object::GetSceneObjectAnimatableProperty(index);
1654 const PropertyInputImpl* Actor::GetSceneObjectInputProperty(Property::Index index) const
1656 const PropertyInputImpl* property = PropertyHandler::GetSceneObjectInputProperty(index, GetNode());
1659 // reuse animatable property getter as animatable properties are inputs as well
1660 // animatable property chains back to Object::GetSceneObjectInputProperty() so all properties get covered
1661 property = GetSceneObjectAnimatableProperty(index);
1667 int32_t Actor::GetPropertyComponentIndex(Property::Index index) const
1669 int32_t componentIndex = PropertyHandler::GetPropertyComponentIndex(index);
1670 if(Property::INVALID_COMPONENT_INDEX == componentIndex)
1673 componentIndex = Object::GetPropertyComponentIndex(index);
1676 return componentIndex;
1679 const SceneGraph::Node& Actor::GetNode() const
1681 return *static_cast<const SceneGraph::Node*>(mUpdateObject);
1688 mParent->RaiseChild(*this);
1692 DALI_LOG_WARNING("Actor must have a parent, Sibling order not changed.\n");
1700 mParent->LowerChild(*this);
1704 DALI_LOG_WARNING("Actor must have a parent, Sibling order not changed.\n");
1708 void Actor::RaiseToTop()
1712 mParent->RaiseChildToTop(*this);
1716 DALI_LOG_WARNING("Actor must have a parent, Sibling order not changed.\n");
1720 void Actor::LowerToBottom()
1724 mParent->LowerChildToBottom(*this);
1728 DALI_LOG_WARNING("Actor must have a parent, Sibling order not changed.\n");
1732 void Actor::RaiseAbove(Internal::Actor& target)
1736 mParent->RaiseChildAbove(*this, target);
1740 DALI_LOG_WARNING("Actor must have a parent, Sibling order not changed.\n");
1744 void Actor::LowerBelow(Internal::Actor& target)
1748 mParent->LowerChildBelow(*this, target);
1752 DALI_LOG_WARNING("Actor must have a parent, Sibling order not changed.\n");
1756 void Actor::SetParent(ActorParent* parent, bool notify)
1760 DALI_ASSERT_ALWAYS(!mParent && "Actor cannot have 2 parents");
1763 Actor* parentActor = static_cast<Actor*>(parent);
1764 mScene = parentActor->mScene;
1766 if(EventThreadServices::IsCoreRunning() && // Don't emit signals or send messages during Core destruction
1767 parentActor->OnScene())
1769 // Instruct each actor to create a corresponding node in the scene graph
1770 ConnectToScene(parentActor->GetHierarchyDepth(), notify);
1773 // Resolve the name and index for the child properties if any
1774 ResolveChildProperties();
1776 else // parent being set to NULL
1778 DALI_ASSERT_ALWAYS(mParent != nullptr && "Actor should have a parent");
1782 if(EventThreadServices::IsCoreRunning() && // Don't emit signals or send messages during Core destruction
1785 // Disconnect the Node & its children from the scene-graph.
1786 DisconnectNodeMessage(GetEventThreadServices().GetUpdateManager(), GetNode());
1788 // Instruct each actor to discard pointers to the scene-graph
1789 DisconnectFromStage(notify);
1796 bool Actor::DoAction(BaseObject* object, const std::string& actionName, const Property::Map& /* attributes */)
1799 Actor* actor = dynamic_cast<Actor*>(object);
1803 std::string_view name(actionName);
1804 if(name == ACTION_SHOW)
1806 actor->SetVisible(true);
1809 else if(name == ACTION_HIDE)
1811 actor->SetVisible(false);
1819 Rect<> Actor::CalculateScreenExtents() const
1821 auto screenPosition = GetCurrentScreenPosition();
1822 Vector3 size = GetCurrentSize() * GetCurrentWorldScale();
1823 Vector3 anchorPointOffSet = size * (mPositionUsesAnchorPoint ? GetCurrentAnchorPoint() : AnchorPoint::TOP_LEFT);
1824 Vector2 position = Vector2(screenPosition.x - anchorPointOffSet.x, screenPosition.y - anchorPointOffSet.y);
1825 return {position.x, position.y, size.x, size.y};
1828 void Actor::SetNeedGesturePropagation(bool propagation)
1830 mNeedGesturePropagation = propagation;
1833 bool Actor::NeedGesturePropagation()
1835 return mNeedGesturePropagation;
1838 bool Actor::GetCachedPropertyValue(Property::Index index, Property::Value& value) const
1840 return PropertyHandler::GetCachedPropertyValue(*this, index, value);
1843 bool Actor::GetCurrentPropertyValue(Property::Index index, Property::Value& value) const
1845 return PropertyHandler::GetCurrentPropertyValue(*this, index, value);
1848 Actor::Relayouter& Actor::EnsureRelayouter()
1850 // Assign relayouter
1853 mRelayoutData = new Relayouter();
1856 return *mRelayoutData;
1859 bool Actor::RelayoutDependentOnParent(Dimension::Type dimension)
1861 // Check if actor is dependent on parent
1862 for(uint32_t i = 0; i < Dimension::DIMENSION_COUNT; ++i)
1864 if((dimension & (1 << i)))
1866 const ResizePolicy::Type resizePolicy = GetResizePolicy(static_cast<Dimension::Type>(1 << i));
1867 if(resizePolicy == ResizePolicy::FILL_TO_PARENT || resizePolicy == ResizePolicy::SIZE_RELATIVE_TO_PARENT || resizePolicy == ResizePolicy::SIZE_FIXED_OFFSET_FROM_PARENT)
1877 bool Actor::RelayoutDependentOnChildren(Dimension::Type dimension)
1879 // Check if actor is dependent on children
1880 for(uint32_t i = 0; i < Dimension::DIMENSION_COUNT; ++i)
1882 if((dimension & (1 << i)))
1884 const ResizePolicy::Type resizePolicy = GetResizePolicy(static_cast<Dimension::Type>(1 << i));
1885 switch(resizePolicy)
1887 case ResizePolicy::FIT_TO_CHILDREN:
1888 case ResizePolicy::USE_NATURAL_SIZE: // i.e. For things that calculate their size based on children
1904 bool Actor::RelayoutDependentOnChildrenBase(Dimension::Type dimension)
1906 return Actor::RelayoutDependentOnChildren(dimension);
1909 bool Actor::RelayoutDependentOnDimension(Dimension::Type dimension, Dimension::Type dependentDimension)
1911 // Check each possible dimension and see if it is dependent on the input one
1912 for(uint32_t i = 0; i < Dimension::DIMENSION_COUNT; ++i)
1914 if(dimension & (1 << i))
1916 return mRelayoutData->resizePolicies[i] == ResizePolicy::DIMENSION_DEPENDENCY && mRelayoutData->dimensionDependencies[i] == dependentDimension;
1923 void Actor::SetNegotiatedDimension(float negotiatedDimension, Dimension::Type dimension)
1925 for(uint32_t i = 0; i < Dimension::DIMENSION_COUNT; ++i)
1927 if(dimension & (1 << i))
1929 mRelayoutData->negotiatedDimensions[i] = negotiatedDimension;
1934 float Actor::GetNegotiatedDimension(Dimension::Type dimension) const
1936 // If more than one dimension is requested, just return the first one found
1937 for(uint32_t i = 0; i < Dimension::DIMENSION_COUNT; ++i)
1939 if((dimension & (1 << i)))
1941 return mRelayoutData->negotiatedDimensions[i];
1945 return 0.0f; // Default
1948 void Actor::SetPadding(const Vector2& padding, Dimension::Type dimension)
1950 EnsureRelayouter().SetPadding(padding, dimension);
1953 Vector2 Actor::GetPadding(Dimension::Type dimension) const
1957 // If more than one dimension is requested, just return the first one found
1958 for(uint32_t i = 0; i < Dimension::DIMENSION_COUNT; ++i)
1960 if((dimension & (1 << i)))
1962 return mRelayoutData->dimensionPadding[i];
1967 return Relayouter::DEFAULT_DIMENSION_PADDING;
1970 void Actor::SetLayoutNegotiated(bool negotiated, Dimension::Type dimension)
1972 EnsureRelayouter().SetLayoutNegotiated(negotiated, dimension);
1975 bool Actor::IsLayoutNegotiated(Dimension::Type dimension) const
1977 return mRelayoutData && mRelayoutData->IsLayoutNegotiated(dimension);
1980 float Actor::GetHeightForWidthBase(float width)
1982 float height = 0.0f;
1984 const Vector3 naturalSize = GetNaturalSize();
1985 if(naturalSize.width > 0.0f)
1987 height = naturalSize.height * width / naturalSize.width;
1989 else // we treat 0 as 1:1 aspect ratio
1997 float Actor::GetWidthForHeightBase(float height)
2001 const Vector3 naturalSize = GetNaturalSize();
2002 if(naturalSize.height > 0.0f)
2004 width = naturalSize.width * height / naturalSize.height;
2006 else // we treat 0 as 1:1 aspect ratio
2014 float Actor::CalculateChildSizeBase(const Dali::Actor& child, Dimension::Type dimension)
2016 // Fill to parent, taking size mode factor into account
2017 switch(child.GetResizePolicy(dimension))
2019 case ResizePolicy::FILL_TO_PARENT:
2021 return GetLatestSize(dimension);
2024 case ResizePolicy::SIZE_RELATIVE_TO_PARENT:
2026 return GetLatestSize(dimension) * GetDimensionValue(child.GetProperty<Vector3>(Dali::Actor::Property::SIZE_MODE_FACTOR), dimension);
2029 case ResizePolicy::SIZE_FIXED_OFFSET_FROM_PARENT:
2031 return GetLatestSize(dimension) + GetDimensionValue(child.GetProperty<Vector3>(Dali::Actor::Property::SIZE_MODE_FACTOR), dimension);
2036 return GetLatestSize(dimension);
2041 float Actor::CalculateChildSize(const Dali::Actor& child, Dimension::Type dimension)
2043 // Can be overridden in derived class
2044 return CalculateChildSizeBase(child, dimension);
2047 float Actor::GetHeightForWidth(float width)
2049 // Can be overridden in derived class
2050 return GetHeightForWidthBase(width);
2053 float Actor::GetWidthForHeight(float height)
2055 // Can be overridden in derived class
2056 return GetWidthForHeightBase(height);
2059 float Actor::GetLatestSize(Dimension::Type dimension) const
2061 return IsLayoutNegotiated(dimension) ? GetNegotiatedDimension(dimension) : GetSize(dimension);
2064 float Actor::GetRelayoutSize(Dimension::Type dimension) const
2066 Vector2 padding = GetPadding(dimension);
2068 return GetLatestSize(dimension) + padding.x + padding.y;
2071 float Actor::NegotiateFromParent(Dimension::Type dimension)
2073 Actor* parent = GetParent();
2076 Vector2 padding(GetPadding(dimension));
2077 Vector2 parentPadding(parent->GetPadding(dimension));
2078 return parent->CalculateChildSize(Dali::Actor(this), dimension) - parentPadding.x - parentPadding.y - padding.x - padding.y;
2084 float Actor::NegotiateFromChildren(Dimension::Type dimension)
2086 float maxDimensionPoint = 0.0f;
2088 for(uint32_t i = 0, count = GetChildCount(); i < count; ++i)
2090 ActorPtr child = GetChildAt(i);
2092 if(!child->RelayoutDependentOnParent(dimension))
2094 // Calculate the min and max points that the children range across
2095 float childPosition = GetDimensionValue(child->GetTargetPosition(), dimension);
2096 float dimensionSize = child->GetRelayoutSize(dimension);
2097 maxDimensionPoint = std::max(maxDimensionPoint, childPosition + dimensionSize);
2101 return maxDimensionPoint;
2104 float Actor::GetSize(Dimension::Type dimension) const
2106 return GetDimensionValue(mTargetSize, dimension);
2109 float Actor::GetNaturalSize(Dimension::Type dimension) const
2111 return GetDimensionValue(GetNaturalSize(), dimension);
2114 float Actor::CalculateSize(Dimension::Type dimension, const Vector2& maximumSize)
2116 switch(GetResizePolicy(dimension))
2118 case ResizePolicy::USE_NATURAL_SIZE:
2120 return GetNaturalSize(dimension);
2123 case ResizePolicy::FIXED:
2125 return GetDimensionValue(GetPreferredSize(), dimension);
2128 case ResizePolicy::USE_ASSIGNED_SIZE:
2130 return GetDimensionValue(maximumSize, dimension);
2133 case ResizePolicy::FILL_TO_PARENT:
2134 case ResizePolicy::SIZE_RELATIVE_TO_PARENT:
2135 case ResizePolicy::SIZE_FIXED_OFFSET_FROM_PARENT:
2137 return NegotiateFromParent(dimension);
2140 case ResizePolicy::FIT_TO_CHILDREN:
2142 return NegotiateFromChildren(dimension);
2145 case ResizePolicy::DIMENSION_DEPENDENCY:
2147 const Dimension::Type dimensionDependency = GetDimensionDependency(dimension);
2150 if(dimension == Dimension::WIDTH && dimensionDependency == Dimension::HEIGHT)
2152 return GetWidthForHeight(GetNegotiatedDimension(Dimension::HEIGHT));
2155 if(dimension == Dimension::HEIGHT && dimensionDependency == Dimension::WIDTH)
2157 return GetHeightForWidth(GetNegotiatedDimension(Dimension::WIDTH));
2169 return 0.0f; // Default
2172 Vector2 Actor::ApplySizeSetPolicy(const Vector2& size)
2174 return mRelayoutData->ApplySizeSetPolicy(*this, size);
2177 void Actor::SetNegotiatedSize(RelayoutContainer& container)
2179 // Do the set actor size
2180 Vector2 negotiatedSize(GetLatestSize(Dimension::WIDTH), GetLatestSize(Dimension::HEIGHT));
2182 // Adjust for size set policy
2183 negotiatedSize = ApplySizeSetPolicy(negotiatedSize);
2185 // Lock the flag to stop recursive relayouts on set size
2186 mRelayoutData->insideRelayout = true;
2187 SetSize(negotiatedSize);
2188 mRelayoutData->insideRelayout = false;
2190 // Clear flags for all dimensions
2191 SetLayoutDirty(false);
2193 // Give deriving classes a chance to respond
2194 OnRelayout(negotiatedSize, container);
2196 if(!mOnRelayoutSignal.Empty())
2198 Dali::Actor handle(this);
2199 mOnRelayoutSignal.Emit(handle);
2203 void Actor::NegotiateSize(const Vector2& allocatedSize, RelayoutContainer& container)
2205 Relayouter::NegotiateSize(*this, allocatedSize, container);
2208 void Actor::SetUseAssignedSize(bool use, Dimension::Type dimension)
2212 mRelayoutData->SetUseAssignedSize(use, dimension);
2216 bool Actor::GetUseAssignedSize(Dimension::Type dimension) const
2218 return mRelayoutData && mRelayoutData->GetUseAssignedSize(dimension);
2221 void Actor::RelayoutRequest(Dimension::Type dimension)
2223 Internal::RelayoutController* relayoutController = Internal::RelayoutController::Get();
2224 if(relayoutController)
2226 Dali::Actor self(this);
2227 relayoutController->RequestRelayout(self, dimension);
2231 void Actor::SetPreferredSize(const Vector2& size)
2233 EnsureRelayouter().SetPreferredSize(*this, size);
2236 Vector2 Actor::GetPreferredSize() const
2240 return Vector2(mRelayoutData->preferredSize);
2243 return Relayouter::DEFAULT_PREFERRED_SIZE;
2246 void Actor::SetMinimumSize(float size, Dimension::Type dimension)
2248 EnsureRelayouter().SetMinimumSize(size, dimension);
2252 float Actor::GetMinimumSize(Dimension::Type dimension) const
2256 return mRelayoutData->GetMinimumSize(dimension);
2259 return 0.0f; // Default
2262 void Actor::SetMaximumSize(float size, Dimension::Type dimension)
2264 EnsureRelayouter().SetMaximumSize(size, dimension);
2268 float Actor::GetMaximumSize(Dimension::Type dimension) const
2272 return mRelayoutData->GetMaximumSize(dimension);
2275 return FLT_MAX; // Default
2278 void Actor::SetVisibleInternal(bool visible, SendMessage::Type sendMessage)
2280 if(mVisible != visible)
2282 if(sendMessage == SendMessage::TRUE)
2284 // node is being used in a separate thread; queue a message to set the value & base value
2285 SceneGraph::NodePropertyMessage<bool>::Send(GetEventThreadServices(), &GetNode(), &GetNode().mVisible, &AnimatableProperty<bool>::Bake, visible);
2287 RequestRenderingMessage(GetEventThreadServices().GetUpdateManager());
2292 // Emit the signal on this actor and all its children
2293 EmitVisibilityChangedSignalRecursively(visible, DevelActor::VisibilityChange::SELF);
2297 void Actor::SetSiblingOrderOfChild(Actor& child, uint32_t order)
2299 mParentImpl.SetSiblingOrderOfChild(child, order);
2302 uint32_t Actor::GetSiblingOrderOfChild(const Actor& child) const
2304 return mParentImpl.GetSiblingOrderOfChild(child);
2307 void Actor::RaiseChild(Actor& child)
2309 mParentImpl.RaiseChild(child);
2312 void Actor::LowerChild(Actor& child)
2314 mParentImpl.LowerChild(child);
2317 void Actor::RaiseChildToTop(Actor& child)
2319 mParentImpl.RaiseChildToTop(child);
2322 void Actor::LowerChildToBottom(Actor& child)
2324 mParentImpl.LowerChildToBottom(child);
2327 void Actor::RaiseChildAbove(Actor& child, Actor& target)
2329 mParentImpl.RaiseChildAbove(child, target);
2332 void Actor::LowerChildBelow(Actor& child, Actor& target)
2334 mParentImpl.LowerChildBelow(child, target);
2337 void Actor::SetInheritLayoutDirection(bool inherit)
2339 if(mInheritLayoutDirection != inherit)
2341 mInheritLayoutDirection = inherit;
2343 if(inherit && mParent)
2345 InheritLayoutDirectionRecursively(GetParent()->mLayoutDirection);
2350 void Actor::InheritLayoutDirectionRecursively(Dali::LayoutDirection::Type direction, bool set)
2352 if(mInheritLayoutDirection || set)
2354 if(mLayoutDirection != direction)
2356 mLayoutDirection = direction;
2357 EmitLayoutDirectionChangedSignal(direction);
2361 if(GetChildCount() > 0)
2363 for(const auto& child : mParentImpl.GetChildrenInternal())
2365 child->InheritLayoutDirectionRecursively(direction);
2371 void Actor::SetUpdateSizeHint(const Vector2& updateSizeHint)
2373 // node is being used in a separate thread; queue a message to set the value & base value
2374 SceneGraph::NodePropertyMessage<Vector3>::Send(GetEventThreadServices(), &GetNode(), &GetNode().mUpdateSizeHint, &AnimatableProperty<Vector3>::Bake, Vector3(updateSizeHint.width, updateSizeHint.height, 0.f));
2377 void Actor::EmitVisibilityChangedSignalRecursively(bool visible,
2378 DevelActor::VisibilityChange::Type type)
2380 EmitVisibilityChangedSignal(visible, type);
2382 if(GetChildCount() > 0)
2384 for(auto& child : mParentImpl.GetChildrenInternal())
2386 child->EmitVisibilityChangedSignalRecursively(visible, DevelActor::VisibilityChange::PARENT);
2391 } // namespace Internal