2 * Copyright (c) 2020 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
19 #include <dali/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-parent.h>
41 #include <dali/internal/event/actors/actor-property-handler.h>
42 #include <dali/internal/event/actors/actor-relayouter.h>
43 #include <dali/internal/event/actors/camera-actor-impl.h>
44 #include <dali/internal/event/common/event-thread-services.h>
45 #include <dali/internal/event/common/projection.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/size-negotiation/relayout-controller-impl.h>
55 #include <dali/internal/update/nodes/node-messages.h>
57 using Dali::Internal::SceneGraph::AnimatableProperty;
58 using Dali::Internal::SceneGraph::Node;
59 using Dali::Internal::SceneGraph::PropertyBase;
61 #if defined(DEBUG_ENABLED)
62 Debug::Filter* gLogFilter = Debug::Filter::New(Debug::NoLogging, false, "LOG_DEPTH_TIMER");
69 namespace // unnamed namespace
74 * We want to discourage the use of property strings (minimize string comparisons),
75 * particularly for the default properties.
76 * Name Type writable animatable constraint-input enum for index-checking
78 DALI_PROPERTY_TABLE_BEGIN
79 DALI_PROPERTY("parentOrigin", VECTOR3, true, false, true, Dali::Actor::Property::PARENT_ORIGIN)
80 DALI_PROPERTY("parentOriginX", FLOAT, true, false, true, Dali::Actor::Property::PARENT_ORIGIN_X)
81 DALI_PROPERTY("parentOriginY", FLOAT, true, false, true, Dali::Actor::Property::PARENT_ORIGIN_Y)
82 DALI_PROPERTY("parentOriginZ", FLOAT, true, false, true, Dali::Actor::Property::PARENT_ORIGIN_Z)
83 DALI_PROPERTY("anchorPoint", VECTOR3, true, false, true, Dali::Actor::Property::ANCHOR_POINT)
84 DALI_PROPERTY("anchorPointX", FLOAT, true, false, true, Dali::Actor::Property::ANCHOR_POINT_X)
85 DALI_PROPERTY("anchorPointY", FLOAT, true, false, true, Dali::Actor::Property::ANCHOR_POINT_Y)
86 DALI_PROPERTY("anchorPointZ", FLOAT, true, false, true, Dali::Actor::Property::ANCHOR_POINT_Z)
87 DALI_PROPERTY("size", VECTOR3, true, true, true, Dali::Actor::Property::SIZE)
88 DALI_PROPERTY("sizeWidth", FLOAT, true, true, true, Dali::Actor::Property::SIZE_WIDTH)
89 DALI_PROPERTY("sizeHeight", FLOAT, true, true, true, Dali::Actor::Property::SIZE_HEIGHT)
90 DALI_PROPERTY("sizeDepth", FLOAT, true, true, true, Dali::Actor::Property::SIZE_DEPTH)
91 DALI_PROPERTY("position", VECTOR3, true, true, true, Dali::Actor::Property::POSITION)
92 DALI_PROPERTY("positionX", FLOAT, true, true, true, Dali::Actor::Property::POSITION_X)
93 DALI_PROPERTY("positionY", FLOAT, true, true, true, Dali::Actor::Property::POSITION_Y)
94 DALI_PROPERTY("positionZ", FLOAT, true, true, true, Dali::Actor::Property::POSITION_Z)
95 DALI_PROPERTY("worldPosition", VECTOR3, false, false, true, Dali::Actor::Property::WORLD_POSITION)
96 DALI_PROPERTY("worldPositionX", FLOAT, false, false, true, Dali::Actor::Property::WORLD_POSITION_X)
97 DALI_PROPERTY("worldPositionY", FLOAT, false, false, true, Dali::Actor::Property::WORLD_POSITION_Y)
98 DALI_PROPERTY("worldPositionZ", FLOAT, false, false, true, Dali::Actor::Property::WORLD_POSITION_Z)
99 DALI_PROPERTY("orientation", ROTATION, true, true, true, Dali::Actor::Property::ORIENTATION)
100 DALI_PROPERTY("worldOrientation", ROTATION, false, false, true, Dali::Actor::Property::WORLD_ORIENTATION)
101 DALI_PROPERTY("scale", VECTOR3, true, true, true, Dali::Actor::Property::SCALE)
102 DALI_PROPERTY("scaleX", FLOAT, true, true, true, Dali::Actor::Property::SCALE_X)
103 DALI_PROPERTY("scaleY", FLOAT, true, true, true, Dali::Actor::Property::SCALE_Y)
104 DALI_PROPERTY("scaleZ", FLOAT, true, true, true, Dali::Actor::Property::SCALE_Z)
105 DALI_PROPERTY("worldScale", VECTOR3, false, false, true, Dali::Actor::Property::WORLD_SCALE)
106 DALI_PROPERTY("visible", BOOLEAN, true, true, true, Dali::Actor::Property::VISIBLE)
107 DALI_PROPERTY("color", VECTOR4, true, true, true, Dali::Actor::Property::COLOR)
108 DALI_PROPERTY("colorRed", FLOAT, true, true, true, Dali::Actor::Property::COLOR_RED)
109 DALI_PROPERTY("colorGreen", FLOAT, true, true, true, Dali::Actor::Property::COLOR_GREEN)
110 DALI_PROPERTY("colorBlue", FLOAT, true, true, true, Dali::Actor::Property::COLOR_BLUE)
111 DALI_PROPERTY("colorAlpha", FLOAT, true, true, true, Dali::Actor::Property::COLOR_ALPHA)
112 DALI_PROPERTY("worldColor", VECTOR4, false, false, true, Dali::Actor::Property::WORLD_COLOR)
113 DALI_PROPERTY("worldMatrix", MATRIX, false, false, true, Dali::Actor::Property::WORLD_MATRIX)
114 DALI_PROPERTY("name", STRING, true, false, false, Dali::Actor::Property::NAME)
115 DALI_PROPERTY("sensitive", BOOLEAN, true, false, false, Dali::Actor::Property::SENSITIVE)
116 DALI_PROPERTY("leaveRequired", BOOLEAN, true, false, false, Dali::Actor::Property::LEAVE_REQUIRED)
117 DALI_PROPERTY("inheritOrientation", BOOLEAN, true, false, false, Dali::Actor::Property::INHERIT_ORIENTATION)
118 DALI_PROPERTY("inheritScale", BOOLEAN, true, false, false, Dali::Actor::Property::INHERIT_SCALE)
119 DALI_PROPERTY("colorMode", INTEGER, true, false, false, Dali::Actor::Property::COLOR_MODE)
120 DALI_PROPERTY("drawMode", INTEGER, true, false, false, Dali::Actor::Property::DRAW_MODE)
121 DALI_PROPERTY("sizeModeFactor", VECTOR3, true, false, false, Dali::Actor::Property::SIZE_MODE_FACTOR)
122 DALI_PROPERTY("widthResizePolicy", STRING, true, false, false, Dali::Actor::Property::WIDTH_RESIZE_POLICY)
123 DALI_PROPERTY("heightResizePolicy", STRING, true, false, false, Dali::Actor::Property::HEIGHT_RESIZE_POLICY)
124 DALI_PROPERTY("sizeScalePolicy", INTEGER, true, false, false, Dali::Actor::Property::SIZE_SCALE_POLICY)
125 DALI_PROPERTY("widthForHeight", BOOLEAN, true, false, false, Dali::Actor::Property::WIDTH_FOR_HEIGHT)
126 DALI_PROPERTY("heightForWidth", BOOLEAN, true, false, false, Dali::Actor::Property::HEIGHT_FOR_WIDTH)
127 DALI_PROPERTY("padding", VECTOR4, true, false, false, Dali::Actor::Property::PADDING)
128 DALI_PROPERTY("minimumSize", VECTOR2, true, false, false, Dali::Actor::Property::MINIMUM_SIZE)
129 DALI_PROPERTY("maximumSize", VECTOR2, true, false, false, Dali::Actor::Property::MAXIMUM_SIZE)
130 DALI_PROPERTY("inheritPosition", BOOLEAN, true, false, false, Dali::Actor::Property::INHERIT_POSITION)
131 DALI_PROPERTY("clippingMode", STRING, true, false, false, Dali::Actor::Property::CLIPPING_MODE)
132 DALI_PROPERTY("layoutDirection", STRING, true, false, false, Dali::Actor::Property::LAYOUT_DIRECTION)
133 DALI_PROPERTY("inheritLayoutDirection", BOOLEAN, true, false, false, Dali::Actor::Property::INHERIT_LAYOUT_DIRECTION)
134 DALI_PROPERTY("opacity", FLOAT, true, true, true, Dali::Actor::Property::OPACITY)
135 DALI_PROPERTY("screenPosition", VECTOR2, false, false, false, Dali::Actor::Property::SCREEN_POSITION)
136 DALI_PROPERTY("positionUsesAnchorPoint", BOOLEAN, true, false, false, Dali::Actor::Property::POSITION_USES_ANCHOR_POINT)
137 DALI_PROPERTY("culled", BOOLEAN, false, false, true, Dali::Actor::Property::CULLED)
138 DALI_PROPERTY("id", INTEGER, false, false, false, Dali::Actor::Property::ID)
139 DALI_PROPERTY("hierarchyDepth", INTEGER, false, false, false, Dali::Actor::Property::HIERARCHY_DEPTH)
140 DALI_PROPERTY("isRoot", BOOLEAN, false, false, false, Dali::Actor::Property::IS_ROOT)
141 DALI_PROPERTY("isLayer", BOOLEAN, false, false, false, Dali::Actor::Property::IS_LAYER)
142 DALI_PROPERTY("connectedToScene", BOOLEAN, false, false, false, Dali::Actor::Property::CONNECTED_TO_SCENE)
143 DALI_PROPERTY("keyboardFocusable", BOOLEAN, true, false, false, Dali::Actor::Property::KEYBOARD_FOCUSABLE)
144 DALI_PROPERTY("siblingOrder", INTEGER, true, false, false, Dali::DevelActor::Property::SIBLING_ORDER)
145 DALI_PROPERTY("updateSizeHint", VECTOR2, true, false, false, Dali::DevelActor::Property::UPDATE_SIZE_HINT)
146 DALI_PROPERTY("captureAllTouchAfterStart", BOOLEAN, true, false, false, Dali::DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START)
147 DALI_PROPERTY("touchArea", VECTOR2, true, false, false, Dali::DevelActor::Property::TOUCH_AREA)
148 DALI_PROPERTY("blendEquation", INTEGER, true, false, false, Dali::DevelActor::Property::BLEND_EQUATION)
149 DALI_PROPERTY_TABLE_END(DEFAULT_ACTOR_PROPERTY_START_INDEX, ActorDefaultProperties)
153 static constexpr std::string_view SIGNAL_HOVERED = "hovered";
154 static constexpr std::string_view SIGNAL_WHEEL_EVENT = "wheelEvent";
155 static constexpr std::string_view SIGNAL_ON_SCENE = "onScene";
156 static constexpr std::string_view SIGNAL_OFF_SCENE = "offScene";
157 static constexpr std::string_view SIGNAL_ON_RELAYOUT = "onRelayout";
158 static constexpr std::string_view SIGNAL_TOUCHED = "touched";
159 static constexpr std::string_view SIGNAL_VISIBILITY_CHANGED = "visibilityChanged";
160 static constexpr std::string_view SIGNAL_LAYOUT_DIRECTION_CHANGED = "layoutDirectionChanged";
161 static constexpr std::string_view SIGNAL_CHILD_ADDED = "childAdded";
162 static constexpr std::string_view SIGNAL_CHILD_REMOVED = "childRemoved";
166 static constexpr std::string_view ACTION_SHOW = "show";
167 static constexpr std::string_view ACTION_HIDE = "hide";
169 BaseHandle CreateActor()
171 return Dali::Actor::New();
174 TypeRegistration mType(typeid(Dali::Actor), typeid(Dali::Handle), CreateActor, ActorDefaultProperties);
176 SignalConnectorType signalConnector2(mType, std::string(SIGNAL_HOVERED), &Actor::DoConnectSignal);
177 SignalConnectorType signalConnector3(mType, std::string(SIGNAL_WHEEL_EVENT), &Actor::DoConnectSignal);
178 SignalConnectorType signalConnector4(mType, std::string(SIGNAL_ON_SCENE), &Actor::DoConnectSignal);
179 SignalConnectorType signalConnector5(mType, std::string(SIGNAL_OFF_SCENE), &Actor::DoConnectSignal);
180 SignalConnectorType signalConnector6(mType, std::string(SIGNAL_ON_RELAYOUT), &Actor::DoConnectSignal);
181 SignalConnectorType signalConnector7(mType, std::string(SIGNAL_TOUCHED), &Actor::DoConnectSignal);
182 SignalConnectorType signalConnector8(mType, std::string(SIGNAL_VISIBILITY_CHANGED), &Actor::DoConnectSignal);
183 SignalConnectorType signalConnector9(mType, std::string(SIGNAL_LAYOUT_DIRECTION_CHANGED), &Actor::DoConnectSignal);
184 SignalConnectorType signalConnector10(mType, std::string(SIGNAL_CHILD_ADDED), &Actor::DoConnectSignal);
185 SignalConnectorType signalConnector11(mType, std::string(SIGNAL_CHILD_REMOVED), &Actor::DoConnectSignal);
187 TypeAction a1(mType, std::string(ACTION_SHOW), &Actor::DoAction);
188 TypeAction a2(mType, std::string(ACTION_HIDE), &Actor::DoAction);
191 * @brief Extract a given dimension from a Vector2
193 * @param[in] values The values to extract from
194 * @param[in] dimension The dimension to extract
195 * @return Return the value for the dimension
197 constexpr float GetDimensionValue(const Vector2& values, Dimension::Type dimension)
201 case Dimension::WIDTH:
205 case Dimension::HEIGHT:
207 return values.height;
218 * @brief Extract a given dimension from a Vector3
220 * @param[in] values The values to extract from
221 * @param[in] dimension The dimension to extract
222 * @return Return the value for the dimension
224 float GetDimensionValue(const Vector3& values, Dimension::Type dimension)
226 return GetDimensionValue(values.GetVectorXY(), dimension);
229 /// Helper for emitting a signal
230 template<typename Signal, typename Event>
231 bool EmitConsumingSignal(Actor& actor, Signal& signal, const Event& event)
233 bool consumed = false;
237 Dali::Actor handle(&actor);
238 consumed = signal.Emit(handle, event);
244 /// Helper for emitting signals with multiple parameters
245 template<typename Signal, typename... Param>
246 void EmitSignal(Actor& actor, Signal& signal, Param... params)
250 Dali::Actor handle(&actor);
251 signal.Emit(handle, params...);
255 bool ScreenToLocalInternal(
256 const Matrix& viewMatrix,
257 const Matrix& projectionMatrix,
258 const Matrix& worldMatrix,
259 const Viewport& viewport,
260 const Vector3& currentSize,
266 // Get the ModelView matrix
268 Matrix::Multiply(modelView, worldMatrix, viewMatrix);
270 // Calculate the inverted ModelViewProjection matrix; this will be used for 2 unprojects
271 Matrix invertedMvp(false /*don't init*/);
272 Matrix::Multiply(invertedMvp, modelView, projectionMatrix);
273 bool success = invertedMvp.Invert();
275 // Convert to GL coordinates
276 Vector4 screenPos(screenX - static_cast<float>(viewport.x), static_cast<float>(viewport.height) - screenY - static_cast<float>(viewport.y), 0.f, 1.f);
281 success = Unproject(screenPos, invertedMvp, static_cast<float>(viewport.width), static_cast<float>(viewport.height), nearPos);
288 success = Unproject(screenPos, invertedMvp, static_cast<float>(viewport.width), static_cast<float>(viewport.height), farPos);
294 if(XyPlaneIntersect(nearPos, farPos, local))
296 Vector3 size = currentSize;
297 localX = local.x + size.x * 0.5f;
298 localY = local.y + size.y * 0.5f;
309 } // unnamed namespace
311 ActorPtr Actor::New()
313 // pass a reference to actor, actor does not own its node
314 ActorPtr actor(new Actor(BASIC, *CreateNode()));
316 // Second-phase construction
322 const SceneGraph::Node* Actor::CreateNode()
324 // create node. Nodes are owned by the update manager
325 SceneGraph::Node* node = SceneGraph::Node::New();
326 OwnerPointer<SceneGraph::Node> transferOwnership(node);
327 Internal::ThreadLocalStorage* tls = Internal::ThreadLocalStorage::GetInternal();
329 DALI_ASSERT_ALWAYS(tls && "ThreadLocalStorage is null");
331 AddNodeMessage(tls->GetUpdateManager(), transferOwnership);
336 void Actor::SetName(const std::string& name)
340 // ATTENTION: string for debug purposes is not thread safe.
341 DALI_LOG_SET_OBJECT_STRING(const_cast<SceneGraph::Node*>(&GetNode()), name);
344 uint32_t Actor::GetId() const
346 return GetNode().GetId();
349 Dali::Layer Actor::GetLayer()
353 // Short-circuit for Layer derived actors
356 layer = Dali::Layer(static_cast<Dali::Internal::Layer*>(this)); // static cast as we trust the flag
359 // Find the immediate Layer parent
360 for(Actor* parent = GetParent(); !layer && parent != nullptr; parent = parent->GetParent())
362 if(parent->IsLayer())
364 layer = Dali::Layer(static_cast<Dali::Internal::Layer*>(parent)); // static cast as we trust the flag
371 void Actor::Unparent()
375 // Remove this actor from the parent. The remove will put a relayout request in for
376 // the parent if required
377 mParent->Remove(*this);
378 // mParent is now NULL!
382 void Actor::SetParentOrigin(const Vector3& origin)
384 // node is being used in a separate thread; queue a message to set the value & base value
385 SetParentOriginMessage(GetEventThreadServices(), GetNode(), origin);
387 // Cache for event-thread access
390 // not allocated, check if different from default
391 if(ParentOrigin::DEFAULT != origin)
393 mParentOrigin = new Vector3(origin);
398 // check if different from current costs more than just set
399 *mParentOrigin = origin;
403 const Vector3& Actor::GetCurrentParentOrigin() const
405 // Cached for event-thread access
406 return (mParentOrigin) ? *mParentOrigin : ParentOrigin::DEFAULT;
409 void Actor::SetAnchorPoint(const Vector3& anchor)
411 // node is being used in a separate thread; queue a message to set the value & base value
412 SetAnchorPointMessage(GetEventThreadServices(), GetNode(), anchor);
414 // Cache for event-thread access
417 // not allocated, check if different from default
418 if(AnchorPoint::DEFAULT != anchor)
420 mAnchorPoint = new Vector3(anchor);
425 // check if different from current costs more than just set
426 *mAnchorPoint = anchor;
430 const Vector3& Actor::GetCurrentAnchorPoint() const
432 // Cached for event-thread access
433 return (mAnchorPoint) ? *mAnchorPoint : AnchorPoint::DEFAULT;
436 void Actor::SetPosition(float x, float y)
438 SetPosition(Vector3(x, y, 0.0f));
441 void Actor::SetPosition(float x, float y, float z)
443 SetPosition(Vector3(x, y, z));
446 void Actor::SetPosition(const Vector3& position)
448 mTargetPosition = position;
450 // node is being used in a separate thread; queue a message to set the value & base value
451 SceneGraph::NodeTransformPropertyMessage<Vector3>::Send(GetEventThreadServices(), &GetNode(), &GetNode().mPosition, &SceneGraph::TransformManagerPropertyHandler<Vector3>::Bake, position);
454 void Actor::SetX(float x)
456 mTargetPosition.x = x;
458 // node is being used in a separate thread; queue a message to set the value & base value
459 SceneGraph::NodeTransformComponentMessage<Vector3>::Send(GetEventThreadServices(), &GetNode(), &GetNode().mPosition, &SceneGraph::TransformManagerPropertyHandler<Vector3>::BakeX, x);
462 void Actor::SetY(float y)
464 mTargetPosition.y = y;
466 // node is being used in a separate thread; queue a message to set the value & base value
467 SceneGraph::NodeTransformComponentMessage<Vector3>::Send(GetEventThreadServices(), &GetNode(), &GetNode().mPosition, &SceneGraph::TransformManagerPropertyHandler<Vector3>::BakeY, y);
470 void Actor::SetZ(float z)
472 mTargetPosition.z = z;
474 // node is being used in a separate thread; queue a message to set the value & base value
475 SceneGraph::NodeTransformComponentMessage<Vector3>::Send(GetEventThreadServices(), &GetNode(), &GetNode().mPosition, &SceneGraph::TransformManagerPropertyHandler<Vector3>::BakeZ, z);
478 void Actor::TranslateBy(const Vector3& distance)
480 mTargetPosition += distance;
482 // node is being used in a separate thread; queue a message to set the value & base value
483 SceneGraph::NodeTransformPropertyMessage<Vector3>::Send(GetEventThreadServices(), &GetNode(), &GetNode().mPosition, &SceneGraph::TransformManagerPropertyHandler<Vector3>::BakeRelative, distance);
486 const Vector3& Actor::GetCurrentPosition() const
488 // node is being used in a separate thread; copy the value from the previous update
489 return GetNode().GetPosition(GetEventThreadServices().GetEventBufferIndex());
492 const Vector3& Actor::GetCurrentWorldPosition() const
494 // node is being used in a separate thread; copy the value from the previous update
495 return GetNode().GetWorldPosition(GetEventThreadServices().GetEventBufferIndex());
498 const Vector2 Actor::GetCurrentScreenPosition() const
500 if(mScene && OnScene())
502 Vector3 worldPosition = GetNode().GetWorldPosition(GetEventThreadServices().GetEventBufferIndex());
503 Vector3 cameraPosition = mScene->GetDefaultCameraActor().GetNode().GetWorldPosition(GetEventThreadServices().GetEventBufferIndex());
504 worldPosition -= cameraPosition;
506 Vector3 actorSize = GetCurrentSize() * GetCurrentWorldScale();
507 Vector2 halfSceneSize(mScene->GetSize() * 0.5f); // World position origin is center of scene
508 Vector3 halfActorSize(actorSize * 0.5f);
509 Vector3 anchorPointOffSet = halfActorSize - actorSize * (mPositionUsesAnchorPoint ? GetCurrentAnchorPoint() : AnchorPoint::TOP_LEFT);
511 return Vector2(halfSceneSize.width + worldPosition.x - anchorPointOffSet.x,
512 halfSceneSize.height + worldPosition.y - anchorPointOffSet.y);
515 return Vector2::ZERO;
518 void Actor::SetInheritPosition(bool inherit)
520 if(mInheritPosition != inherit)
522 // non animatable so keep local copy
523 mInheritPosition = inherit;
524 SetInheritPositionMessage(GetEventThreadServices(), GetNode(), inherit);
528 void Actor::SetOrientation(const Radian& angle, const Vector3& axis)
530 Vector3 normalizedAxis(axis.x, axis.y, axis.z);
531 normalizedAxis.Normalize();
533 Quaternion orientation(angle, normalizedAxis);
535 SetOrientation(orientation);
538 void Actor::SetOrientation(const Quaternion& orientation)
540 mTargetOrientation = orientation;
542 // node is being used in a separate thread; queue a message to set the value & base value
543 SceneGraph::NodeTransformPropertyMessage<Quaternion>::Send(GetEventThreadServices(), &GetNode(), &GetNode().mOrientation, &SceneGraph::TransformManagerPropertyHandler<Quaternion>::Bake, orientation);
546 void Actor::RotateBy(const Radian& angle, const Vector3& axis)
548 RotateBy(Quaternion(angle, axis));
551 void Actor::RotateBy(const Quaternion& relativeRotation)
553 mTargetOrientation *= Quaternion(relativeRotation);
555 // node is being used in a separate thread; queue a message to set the value & base value
556 SceneGraph::NodeTransformPropertyMessage<Quaternion>::Send(GetEventThreadServices(), &GetNode(), &GetNode().mOrientation, &SceneGraph::TransformManagerPropertyHandler<Quaternion>::BakeRelative, relativeRotation);
559 const Quaternion& Actor::GetCurrentOrientation() const
561 // node is being used in a separate thread; copy the value from the previous update
562 return GetNode().GetOrientation(GetEventThreadServices().GetEventBufferIndex());
565 const Quaternion& Actor::GetCurrentWorldOrientation() const
567 // node is being used in a separate thread; copy the value from the previous update
568 return GetNode().GetWorldOrientation(GetEventThreadServices().GetEventBufferIndex());
571 void Actor::SetScale(float scale)
573 SetScale(Vector3(scale, scale, scale));
576 void Actor::SetScale(float x, float y, float z)
578 SetScale(Vector3(x, y, z));
581 void Actor::SetScale(const Vector3& scale)
583 mTargetScale = scale;
585 // node is being used in a separate thread; queue a message to set the value & base value
586 SceneGraph::NodeTransformPropertyMessage<Vector3>::Send(GetEventThreadServices(), &GetNode(), &GetNode().mScale, &SceneGraph::TransformManagerPropertyHandler<Vector3>::Bake, scale);
589 void Actor::SetScaleX(float x)
593 // node is being used in a separate thread; queue a message to set the value & base value
594 SceneGraph::NodeTransformComponentMessage<Vector3>::Send(GetEventThreadServices(), &GetNode(), &GetNode().mScale, &SceneGraph::TransformManagerPropertyHandler<Vector3>::BakeX, x);
597 void Actor::SetScaleY(float y)
601 // node is being used in a separate thread; queue a message to set the value & base value
602 SceneGraph::NodeTransformComponentMessage<Vector3>::Send(GetEventThreadServices(), &GetNode(), &GetNode().mScale, &SceneGraph::TransformManagerPropertyHandler<Vector3>::BakeY, y);
605 void Actor::SetScaleZ(float z)
609 // node is being used in a separate thread; queue a message to set the value & base value
610 SceneGraph::NodeTransformComponentMessage<Vector3>::Send(GetEventThreadServices(), &GetNode(), &GetNode().mScale, &SceneGraph::TransformManagerPropertyHandler<Vector3>::BakeZ, z);
613 void Actor::ScaleBy(const Vector3& relativeScale)
615 mTargetScale *= relativeScale;
617 // node is being used in a separate thread; queue a message to set the value & base value
618 SceneGraph::NodeTransformPropertyMessage<Vector3>::Send(GetEventThreadServices(), &GetNode(), &GetNode().mScale, &SceneGraph::TransformManagerPropertyHandler<Vector3>::BakeRelativeMultiply, relativeScale);
621 const Vector3& Actor::GetCurrentScale() const
623 // node is being used in a separate thread; copy the value from the previous update
624 return GetNode().GetScale(GetEventThreadServices().GetEventBufferIndex());
627 const Vector3& Actor::GetCurrentWorldScale() const
629 // node is being used in a separate thread; copy the value from the previous update
630 return GetNode().GetWorldScale(GetEventThreadServices().GetEventBufferIndex());
633 void Actor::SetInheritScale(bool inherit)
635 if(mInheritScale != inherit)
637 // non animatable so keep local copy
638 mInheritScale = inherit;
639 // node is being used in a separate thread; queue a message to set the value
640 SetInheritScaleMessage(GetEventThreadServices(), GetNode(), inherit);
644 Matrix Actor::GetCurrentWorldMatrix() const
646 return GetNode().GetWorldMatrix(0);
649 void Actor::SetVisible(bool visible)
651 SetVisibleInternal(visible, SendMessage::TRUE);
654 bool Actor::IsVisible() const
656 // node is being used in a separate thread; copy the value from the previous update
657 return GetNode().IsVisible(GetEventThreadServices().GetEventBufferIndex());
660 void Actor::SetOpacity(float opacity)
662 mTargetColor.a = opacity;
664 // node is being used in a separate thread; queue a message to set the value & base value
665 SceneGraph::NodePropertyComponentMessage<Vector4>::Send(GetEventThreadServices(), &GetNode(), &GetNode().mColor, &AnimatableProperty<Vector4>::BakeW, opacity);
667 RequestRenderingMessage(GetEventThreadServices().GetUpdateManager());
670 float Actor::GetCurrentOpacity() const
672 // node is being used in a separate thread; copy the value from the previous update
673 return GetNode().GetOpacity(GetEventThreadServices().GetEventBufferIndex());
676 const Vector4& Actor::GetCurrentWorldColor() const
678 return GetNode().GetWorldColor(GetEventThreadServices().GetEventBufferIndex());
681 void Actor::SetColor(const Vector4& color)
683 mTargetColor = color;
685 // node is being used in a separate thread; queue a message to set the value & base value
686 SceneGraph::NodePropertyMessage<Vector4>::Send(GetEventThreadServices(), &GetNode(), &GetNode().mColor, &AnimatableProperty<Vector4>::Bake, color);
688 RequestRenderingMessage(GetEventThreadServices().GetUpdateManager());
691 void Actor::SetColorRed(float red)
693 mTargetColor.r = red;
695 // node is being used in a separate thread; queue a message to set the value & base value
696 SceneGraph::NodePropertyComponentMessage<Vector4>::Send(GetEventThreadServices(), &GetNode(), &GetNode().mColor, &AnimatableProperty<Vector4>::BakeX, red);
698 RequestRenderingMessage(GetEventThreadServices().GetUpdateManager());
701 void Actor::SetColorGreen(float green)
703 mTargetColor.g = green;
705 // node is being used in a separate thread; queue a message to set the value & base value
706 SceneGraph::NodePropertyComponentMessage<Vector4>::Send(GetEventThreadServices(), &GetNode(), &GetNode().mColor, &AnimatableProperty<Vector4>::BakeY, green);
708 RequestRenderingMessage(GetEventThreadServices().GetUpdateManager());
711 void Actor::SetColorBlue(float blue)
713 mTargetColor.b = blue;
715 // node is being used in a separate thread; queue a message to set the value & base value
716 SceneGraph::NodePropertyComponentMessage<Vector4>::Send(GetEventThreadServices(), &GetNode(), &GetNode().mColor, &AnimatableProperty<Vector4>::BakeZ, blue);
718 RequestRenderingMessage(GetEventThreadServices().GetUpdateManager());
721 const Vector4& Actor::GetCurrentColor() const
723 // node is being used in a separate thread; copy the value from the previous update
724 return GetNode().GetColor(GetEventThreadServices().GetEventBufferIndex());
727 void Actor::SetInheritOrientation(bool inherit)
729 if(mInheritOrientation != inherit)
731 // non animatable so keep local copy
732 mInheritOrientation = inherit;
733 // node is being used in a separate thread; queue a message to set the value
734 SetInheritOrientationMessage(GetEventThreadServices(), GetNode(), inherit);
738 void Actor::SetSizeModeFactor(const Vector3& factor)
742 mRelayoutData->sizeModeFactor = factor;
745 const Vector3& Actor::GetSizeModeFactor() const
749 return mRelayoutData->sizeModeFactor;
752 return Relayouter::DEFAULT_SIZE_MODE_FACTOR;
755 void Actor::SetColorMode(ColorMode colorMode)
757 // non animatable so keep local copy
758 mColorMode = colorMode;
759 // node is being used in a separate thread; queue a message to set the value
760 SetColorModeMessage(GetEventThreadServices(), GetNode(), colorMode);
763 void Actor::SetSize(float width, float height)
765 SetSize(Vector2(width, height));
768 void Actor::SetSize(float width, float height, float depth)
770 SetSize(Vector3(width, height, depth));
773 void Actor::SetSize(const Vector2& size)
775 SetSize(Vector3(size.width, size.height, 0.f));
778 void Actor::SetSizeInternal(const Vector2& size)
780 SetSizeInternal(Vector3(size.width, size.height, 0.f));
783 void Actor::SetSize(const Vector3& size)
785 if(IsRelayoutEnabled() && !mRelayoutData->insideRelayout)
787 // TODO we cannot just ignore the given Z but that means rewrite the size negotiation!!
788 SetPreferredSize(size.GetVectorXY());
792 SetSizeInternal(size);
796 void Actor::SetSizeInternal(const Vector3& size)
798 // dont allow recursive loop
799 DALI_ASSERT_ALWAYS(!mInsideOnSizeSet && "Cannot call SetSize from OnSizeSet");
800 // 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
801 if((fabsf(mTargetSize.width - size.width) > Math::MACHINE_EPSILON_1) ||
802 (fabsf(mTargetSize.height - size.height) > Math::MACHINE_EPSILON_1) ||
803 (fabsf(mTargetSize.depth - size.depth) > Math::MACHINE_EPSILON_1))
807 // node is being used in a separate thread; queue a message to set the value & base value
808 SceneGraph::NodeTransformPropertyMessage<Vector3>::Send(GetEventThreadServices(), &GetNode(), &GetNode().mSize, &SceneGraph::TransformManagerPropertyHandler<Vector3>::Bake, mTargetSize);
810 // Notification for derived classes
811 mInsideOnSizeSet = true;
812 OnSizeSet(mTargetSize);
813 mInsideOnSizeSet = false;
815 // Raise a relayout request if the flag is not locked
816 if(mRelayoutData && !mRelayoutData->insideRelayout)
823 void Actor::SetWidth(float width)
825 if(IsRelayoutEnabled() && !mRelayoutData->insideRelayout)
827 SetResizePolicy(ResizePolicy::FIXED, Dimension::WIDTH);
828 mRelayoutData->preferredSize.width = width;
832 mTargetSize.width = width;
834 // node is being used in a separate thread; queue a message to set the value & base value
835 SceneGraph::NodeTransformComponentMessage<Vector3>::Send(GetEventThreadServices(), &GetNode(), &GetNode().mSize, &SceneGraph::TransformManagerPropertyHandler<Vector3>::BakeX, width);
838 mUseAnimatedSize &= ~AnimatedSizeFlag::WIDTH;
843 void Actor::SetHeight(float height)
845 if(IsRelayoutEnabled() && !mRelayoutData->insideRelayout)
847 SetResizePolicy(ResizePolicy::FIXED, Dimension::HEIGHT);
848 mRelayoutData->preferredSize.height = height;
852 mTargetSize.height = height;
854 // node is being used in a separate thread; queue a message to set the value & base value
855 SceneGraph::NodeTransformComponentMessage<Vector3>::Send(GetEventThreadServices(), &GetNode(), &GetNode().mSize, &SceneGraph::TransformManagerPropertyHandler<Vector3>::BakeY, height);
858 mUseAnimatedSize &= ~AnimatedSizeFlag::HEIGHT;
863 void Actor::SetDepth(float depth)
865 mTargetSize.depth = depth;
867 mUseAnimatedSize &= ~AnimatedSizeFlag::DEPTH;
869 // node is being used in a separate thread; queue a message to set the value & base value
870 SceneGraph::NodeTransformComponentMessage<Vector3>::Send(GetEventThreadServices(), &GetNode(), &GetNode().mSize, &SceneGraph::TransformManagerPropertyHandler<Vector3>::BakeZ, depth);
873 Vector3 Actor::GetTargetSize() const
875 Vector3 size = mTargetSize;
877 if(mUseAnimatedSize & AnimatedSizeFlag::WIDTH)
879 // Should return animated size if size is animated
880 size.width = mAnimatedSize.width;
884 // Should return preferred size if size is fixed as set by SetSize
885 if(GetResizePolicy(Dimension::WIDTH) == ResizePolicy::FIXED)
887 size.width = GetPreferredSize().width;
891 if(mUseAnimatedSize & AnimatedSizeFlag::HEIGHT)
893 size.height = mAnimatedSize.height;
897 if(GetResizePolicy(Dimension::HEIGHT) == ResizePolicy::FIXED)
899 size.height = GetPreferredSize().height;
903 if(mUseAnimatedSize & AnimatedSizeFlag::DEPTH)
905 size.depth = mAnimatedSize.depth;
911 const Vector3& Actor::GetCurrentSize() const
913 // node is being used in a separate thread; copy the value from the previous update
914 return GetNode().GetSize(GetEventThreadServices().GetEventBufferIndex());
917 Vector3 Actor::GetNaturalSize() const
919 // It is up to deriving classes to return the appropriate natural size
920 return Vector3(0.0f, 0.0f, 0.0f);
923 void Actor::SetResizePolicy(ResizePolicy::Type policy, Dimension::Type dimension)
925 EnsureRelayouter().SetResizePolicy(policy, dimension, mTargetSize);
927 OnSetResizePolicy(policy, dimension);
929 // Trigger relayout on this control
933 ResizePolicy::Type Actor::GetResizePolicy(Dimension::Type dimension) const
937 return mRelayoutData->GetResizePolicy(dimension);
940 return ResizePolicy::DEFAULT;
943 void Actor::SetSizeScalePolicy(SizeScalePolicy::Type policy)
947 mRelayoutData->sizeSetPolicy = policy;
949 // Trigger relayout on this control
953 SizeScalePolicy::Type Actor::GetSizeScalePolicy() const
957 return mRelayoutData->sizeSetPolicy;
960 return Relayouter::DEFAULT_SIZE_SCALE_POLICY;
963 void Actor::SetDimensionDependency(Dimension::Type dimension, Dimension::Type dependency)
965 EnsureRelayouter().SetDimensionDependency(dimension, dependency);
968 Dimension::Type Actor::GetDimensionDependency(Dimension::Type dimension) const
972 return mRelayoutData->GetDimensionDependency(dimension);
975 return Dimension::ALL_DIMENSIONS; // Default
978 void Actor::SetRelayoutEnabled(bool relayoutEnabled)
980 // If relayout data has not been allocated yet and the client is requesting
981 // to disable it, do nothing
982 if(mRelayoutData || relayoutEnabled)
986 DALI_ASSERT_DEBUG(mRelayoutData && "mRelayoutData not created");
988 mRelayoutData->relayoutEnabled = relayoutEnabled;
992 bool Actor::IsRelayoutEnabled() const
994 // Assume that if relayout data has not been allocated yet then
995 // relayout is disabled
996 return mRelayoutData && mRelayoutData->relayoutEnabled;
999 void Actor::SetLayoutDirty(bool dirty, Dimension::Type dimension)
1001 EnsureRelayouter().SetLayoutDirty(dirty, dimension);
1004 bool Actor::IsLayoutDirty(Dimension::Type dimension) const
1006 return mRelayoutData && mRelayoutData->IsLayoutDirty(dimension);
1009 bool Actor::RelayoutPossible(Dimension::Type dimension) const
1011 return mRelayoutData && mRelayoutData->relayoutEnabled && !IsLayoutDirty(dimension);
1014 bool Actor::RelayoutRequired(Dimension::Type dimension) const
1016 return mRelayoutData && mRelayoutData->relayoutEnabled && IsLayoutDirty(dimension);
1019 uint32_t Actor::AddRenderer(Renderer& renderer)
1023 mRenderers = new RendererContainer;
1026 if(mIsBlendEquationSet)
1028 renderer.SetBlendEquation(static_cast<DevelBlendEquation::Type>(mBlendEquation));
1031 uint32_t index = static_cast<uint32_t>(mRenderers->size()); // 4,294,967,295 renderers per actor
1032 RendererPtr rendererPtr = RendererPtr(&renderer);
1033 mRenderers->push_back(rendererPtr);
1034 AttachRendererMessage(GetEventThreadServices(), GetNode(), renderer.GetRendererSceneObject());
1038 uint32_t Actor::GetRendererCount() const
1040 uint32_t rendererCount(0);
1043 rendererCount = static_cast<uint32_t>(mRenderers->size()); // 4,294,967,295 renderers per actor
1046 return rendererCount;
1049 RendererPtr Actor::GetRendererAt(uint32_t index)
1051 RendererPtr renderer;
1052 if(index < GetRendererCount())
1054 renderer = (*mRenderers)[index];
1060 void Actor::RemoveRenderer(Renderer& renderer)
1064 RendererIter end = mRenderers->end();
1065 for(RendererIter iter = mRenderers->begin(); iter != end; ++iter)
1067 if((*iter).Get() == &renderer)
1069 mRenderers->erase(iter);
1070 DetachRendererMessage(GetEventThreadServices(), GetNode(), renderer.GetRendererSceneObject());
1077 void Actor::RemoveRenderer(uint32_t index)
1079 if(index < GetRendererCount())
1081 RendererPtr renderer = (*mRenderers)[index];
1082 DetachRendererMessage(GetEventThreadServices(), GetNode(), renderer.Get()->GetRendererSceneObject());
1083 mRenderers->erase(mRenderers->begin() + index);
1087 void Actor::SetBlendEquation(DevelBlendEquation::Type blendEquation)
1089 if(Dali::Capabilities::IsBlendEquationSupported(blendEquation))
1091 if(mBlendEquation != blendEquation)
1093 mBlendEquation = blendEquation;
1094 uint32_t rendererCount = GetRendererCount();
1095 for(uint32_t i = 0; i < rendererCount; ++i)
1097 RendererPtr renderer = GetRendererAt(i);
1098 renderer->SetBlendEquation(static_cast<DevelBlendEquation::Type>(blendEquation));
1101 mIsBlendEquationSet = true;
1105 DALI_LOG_ERROR("Invalid blend equation is entered.\n");
1109 DevelBlendEquation::Type Actor::GetBlendEquation() const
1111 return mBlendEquation;
1114 void Actor::SetDrawMode(DrawMode::Type drawMode)
1116 // this flag is not animatable so keep the value
1117 mDrawMode = drawMode;
1119 // node is being used in a separate thread; queue a message to set the value
1120 SetDrawModeMessage(GetEventThreadServices(), GetNode(), drawMode);
1123 bool Actor::ScreenToLocal(float& localX, float& localY, float screenX, float screenY) const
1125 // only valid when on-stage
1126 if(mScene && OnScene())
1128 const RenderTaskList& taskList = mScene->GetRenderTaskList();
1130 Vector2 converted(screenX, screenY);
1132 // do a reverse traversal of all lists (as the default onscreen one is typically the last one)
1133 uint32_t taskCount = taskList.GetTaskCount();
1134 for(uint32_t i = taskCount; i > 0; --i)
1136 RenderTaskPtr task = taskList.GetTask(i - 1);
1137 if(ScreenToLocal(*task, localX, localY, screenX, screenY))
1139 // found a task where this conversion was ok so return
1147 bool Actor::ScreenToLocal(const RenderTask& renderTask, float& localX, float& localY, float screenX, float screenY) const
1149 bool retval = false;
1150 // only valid when on-stage
1153 CameraActor* camera = renderTask.GetCameraActor();
1157 renderTask.GetViewport(viewport);
1159 // need to translate coordinates to render tasks coordinate space
1160 Vector2 converted(screenX, screenY);
1161 if(renderTask.TranslateCoordinates(converted))
1163 retval = ScreenToLocal(camera->GetViewMatrix(), camera->GetProjectionMatrix(), viewport, localX, localY, converted.x, converted.y);
1170 bool Actor::ScreenToLocal(const Matrix& viewMatrix, const Matrix& projectionMatrix, const Viewport& viewport, float& localX, float& localY, float screenX, float screenY) const
1172 return OnScene() && ScreenToLocalInternal(viewMatrix, projectionMatrix, GetNode().GetWorldMatrix(0), viewport, GetCurrentSize(), localX, localY, screenX, screenY);
1175 ActorGestureData& Actor::GetGestureData()
1177 // Likely scenario is that once gesture-data is created for this actor, the actor will require
1178 // that gesture for its entire life-time so no need to destroy it until the actor is destroyed
1179 if(nullptr == mGestureData)
1181 mGestureData = new ActorGestureData;
1183 return *mGestureData;
1186 bool Actor::IsGestureRequired(GestureType::Value type) const
1188 return mGestureData && mGestureData->IsGestureRequired(type);
1191 bool Actor::EmitInterceptTouchEventSignal(const Dali::TouchEvent& touch)
1193 return EmitConsumingSignal(*this, mInterceptTouchedSignal, touch);
1196 bool Actor::EmitTouchEventSignal(const Dali::TouchEvent& touch)
1198 return EmitConsumingSignal(*this, mTouchedSignal, touch);
1201 bool Actor::EmitHoverEventSignal(const Dali::HoverEvent& event)
1203 return EmitConsumingSignal(*this, mHoveredSignal, event);
1206 bool Actor::EmitWheelEventSignal(const Dali::WheelEvent& event)
1208 return EmitConsumingSignal(*this, mWheelEventSignal, event);
1211 void Actor::EmitVisibilityChangedSignal(bool visible, DevelActor::VisibilityChange::Type type)
1213 EmitSignal(*this, mVisibilityChangedSignal, visible, type);
1216 void Actor::EmitLayoutDirectionChangedSignal(LayoutDirection::Type type)
1218 EmitSignal(*this, mLayoutDirectionChangedSignal, type);
1221 DevelActor::ChildChangedSignalType& Actor::ChildAddedSignal()
1223 return mParentImpl.ChildAddedSignal();
1226 DevelActor::ChildChangedSignalType& Actor::ChildRemovedSignal()
1228 return mParentImpl.ChildRemovedSignal();
1231 DevelActor::ChildOrderChangedSignalType& Actor::ChildOrderChangedSignal()
1233 return mParentImpl.ChildOrderChangedSignal();
1236 bool Actor::DoConnectSignal(BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor)
1238 bool connected(true);
1239 Actor* actor = static_cast<Actor*>(object); // TypeRegistry guarantees that this is the correct type.
1241 std::string_view name(signalName);
1243 if(name == SIGNAL_HOVERED)
1245 actor->HoveredSignal().Connect(tracker, functor);
1247 else if(signalName == SIGNAL_WHEEL_EVENT)
1249 actor->WheelEventSignal().Connect(tracker, functor);
1251 else if(name == SIGNAL_ON_SCENE)
1253 actor->OnSceneSignal().Connect(tracker, functor);
1255 else if(name == SIGNAL_OFF_SCENE)
1257 actor->OffSceneSignal().Connect(tracker, functor);
1259 else if(name == SIGNAL_ON_RELAYOUT)
1261 actor->OnRelayoutSignal().Connect(tracker, functor);
1263 else if(name == SIGNAL_TOUCHED)
1265 actor->TouchedSignal().Connect(tracker, functor);
1267 else if(name == SIGNAL_VISIBILITY_CHANGED)
1269 actor->VisibilityChangedSignal().Connect(tracker, functor);
1271 else if(name == SIGNAL_LAYOUT_DIRECTION_CHANGED)
1273 actor->LayoutDirectionChangedSignal().Connect(tracker, functor);
1275 else if(name == SIGNAL_CHILD_ADDED)
1277 actor->ChildAddedSignal().Connect(tracker, functor);
1279 else if(name == SIGNAL_CHILD_REMOVED)
1281 actor->ChildRemovedSignal().Connect(tracker, functor);
1285 // signalName does not match any signal
1292 Actor::Actor(DerivedType derivedType, const SceneGraph::Node& node)
1297 mRenderers(nullptr),
1298 mParentOrigin(nullptr),
1299 mAnchorPoint(nullptr),
1300 mRelayoutData(nullptr),
1301 mGestureData(nullptr),
1302 mInterceptTouchedSignal(),
1305 mWheelEventSignal(),
1308 mOnRelayoutSignal(),
1309 mVisibilityChangedSignal(),
1310 mLayoutDirectionChangedSignal(),
1311 mTargetOrientation(Quaternion::IDENTITY),
1312 mTargetColor(Color::WHITE),
1313 mTargetSize(Vector3::ZERO),
1314 mTargetPosition(Vector3::ZERO),
1315 mTargetScale(Vector3::ONE),
1316 mAnimatedSize(Vector3::ZERO),
1317 mTouchArea(Vector2::ZERO),
1321 mUseAnimatedSize(AnimatedSizeFlag::CLEAR),
1322 mIsRoot(ROOT_LAYER == derivedType),
1323 mIsLayer(LAYER == derivedType || ROOT_LAYER == derivedType),
1326 mLeaveRequired(false),
1327 mKeyboardFocusable(false),
1328 mOnSceneSignalled(false),
1329 mInsideOnSizeSet(false),
1330 mInheritPosition(true),
1331 mInheritOrientation(true),
1332 mInheritScale(true),
1333 mPositionUsesAnchorPoint(true),
1335 mInheritLayoutDirection(true),
1336 mCaptureAllTouchAfterStart(false),
1337 mLayoutDirection(LayoutDirection::LEFT_TO_RIGHT),
1338 mDrawMode(DrawMode::NORMAL),
1339 mColorMode(Node::DEFAULT_COLOR_MODE),
1340 mClippingMode(ClippingMode::DISABLED),
1341 mBlendEquation(DevelBlendEquation::ADD),
1342 mIsBlendEquationSet(false)
1346 void Actor::Initialize()
1350 GetEventThreadServices().RegisterObject(this);
1355 // Remove mParent pointers from children even if we're destroying core,
1356 // to guard against GetParent() & Unparent() calls from CustomActor destructors.
1360 // Guard to allow handle destruction after Core has been destroyed
1361 if(EventThreadServices::IsCoreRunning())
1363 // Root layer will destroy its node in its own destructor
1366 DestroyNodeMessage(GetEventThreadServices().GetUpdateManager(), GetNode());
1368 GetEventThreadServices().UnregisterObject(this);
1372 // Cleanup optional gesture data
1373 delete mGestureData;
1375 // Cleanup optional parent origin and anchor
1376 delete mParentOrigin;
1377 delete mAnchorPoint;
1379 // Delete optional relayout data
1380 delete mRelayoutData;
1383 void Actor::Add(Actor& child)
1385 mParentImpl.Add(child);
1388 void Actor::Remove(Actor& child)
1390 mParentImpl.Remove(child);
1393 uint32_t Actor::GetChildCount() const
1395 return mParentImpl.GetChildCount();
1398 ActorPtr Actor::GetChildAt(uint32_t index) const
1400 return mParentImpl.GetChildAt(index);
1403 ActorContainer& Actor::GetChildrenInternal()
1405 return mParentImpl.GetChildrenInternal();
1408 ActorPtr Actor::FindChildByName(const std::string& actorName)
1410 return mParentImpl.FindChildByName(actorName);
1413 ActorPtr Actor::FindChildById(const uint32_t id)
1415 return mParentImpl.FindChildById(id);
1418 void Actor::UnparentChildren()
1420 mParentImpl.UnparentChildren();
1423 void Actor::ConnectToScene(uint32_t parentDepth)
1425 // This container is used instead of walking the Actor hierarchy.
1426 // It protects us when the Actor hierarchy is modified during OnSceneConnectionExternal callbacks.
1427 ActorContainer connectionList;
1431 mScene->RequestRebuildDepthTree();
1434 // This stage is atomic i.e. not interrupted by user callbacks.
1435 RecursiveConnectToScene(connectionList, parentDepth + 1);
1437 // Notify applications about the newly connected actors.
1438 for(const auto& actor : connectionList)
1440 actor->NotifyStageConnection();
1446 void Actor::RecursiveConnectToScene(ActorContainer& connectionList, uint32_t depth)
1448 DALI_ASSERT_ALWAYS(!OnScene());
1451 mDepth = static_cast<uint16_t>(depth); // overflow ignored, not expected in practice
1453 ConnectToSceneGraph();
1455 // Notification for internal derived classes
1456 OnSceneConnectionInternal();
1458 // This stage is atomic; avoid emitting callbacks until all Actors are connected
1459 connectionList.push_back(ActorPtr(this));
1461 // Recursively connect children
1462 if(GetChildCount() > 0)
1464 for(const auto& child : mParentImpl.GetChildrenInternal())
1466 child->SetScene(*mScene);
1467 child->RecursiveConnectToScene(connectionList, depth + 1);
1473 * This method is called when the Actor is connected to the Stage.
1474 * The parent must have added its Node to the scene-graph.
1475 * The child must connect its Node to the parent's Node.
1476 * This is recursive; the child calls ConnectToScene() for its children.
1478 void Actor::ConnectToSceneGraph()
1480 DALI_ASSERT_DEBUG(mParent != NULL);
1482 // Reparent Node in next Update
1483 ConnectNodeMessage(GetEventThreadServices().GetUpdateManager(), GetParent()->GetNode(), GetNode());
1485 // Request relayout on all actors that are added to the scenegraph
1488 // Notification for Object::Observers
1492 void Actor::NotifyStageConnection()
1494 // Actors can be removed (in a callback), before the on-stage stage is reported.
1495 // The actor may also have been reparented, in which case mOnSceneSignalled will be true.
1496 if(OnScene() && !mOnSceneSignalled)
1498 // Notification for external (CustomActor) derived classes
1499 OnSceneConnectionExternal(mDepth);
1501 if(!mOnSceneSignal.Empty())
1503 Dali::Actor handle(this);
1504 mOnSceneSignal.Emit(handle);
1507 // Guard against Remove during callbacks
1510 mOnSceneSignalled = true; // signal required next time Actor is removed
1515 void Actor::DisconnectFromStage()
1517 // This container is used instead of walking the Actor hierachy.
1518 // It protects us when the Actor hierachy is modified during OnSceneDisconnectionExternal callbacks.
1519 ActorContainer disconnectionList;
1523 mScene->RequestRebuildDepthTree();
1526 // This stage is atomic i.e. not interrupted by user callbacks
1527 RecursiveDisconnectFromStage(disconnectionList);
1529 // Notify applications about the newly disconnected actors.
1530 for(const auto& actor : disconnectionList)
1532 actor->NotifyStageDisconnection();
1536 void Actor::RecursiveDisconnectFromStage(ActorContainer& disconnectionList)
1538 // need to change state first so that internals relying on IsOnScene() inside OnSceneDisconnectionInternal() get the correct value
1541 // Recursively disconnect children
1542 if(GetChildCount() > 0)
1544 for(const auto& child : mParentImpl.GetChildrenInternal())
1546 child->RecursiveDisconnectFromStage(disconnectionList);
1550 // This stage is atomic; avoid emitting callbacks until all Actors are disconnected
1551 disconnectionList.push_back(ActorPtr(this));
1553 // Notification for internal derived classes
1554 OnSceneDisconnectionInternal();
1556 DisconnectFromSceneGraph();
1560 * This method is called by an actor or its parent, before a node removal message is sent.
1561 * This is recursive; the child calls DisconnectFromStage() for its children.
1563 void Actor::DisconnectFromSceneGraph()
1565 // Notification for Object::Observers
1566 OnSceneObjectRemove();
1569 void Actor::NotifyStageDisconnection()
1571 // Actors can be added (in a callback), before the off-stage state is reported.
1572 // Also if the actor was added & removed before mOnSceneSignalled was set, then we don't notify here.
1573 // only do this step if there is a stage, i.e. Core is not being shut down
1574 if(EventThreadServices::IsCoreRunning() && !OnScene() && mOnSceneSignalled)
1576 // Notification for external (CustomeActor) derived classes
1577 OnSceneDisconnectionExternal();
1579 if(!mOffSceneSignal.Empty())
1581 Dali::Actor handle(this);
1582 mOffSceneSignal.Emit(handle);
1585 // Guard against Add during callbacks
1588 mOnSceneSignalled = false; // signal required next time Actor is added
1593 bool Actor::IsNodeConnected() const
1595 bool connected(false);
1599 if(IsRoot() || GetNode().GetParent())
1608 // This method initiates traversal of the actor tree using depth-first
1609 // traversal to set a depth index based on traversal order. It sends a
1610 // single message to update manager to update all the actor's nodes in
1611 // this tree with the depth index. The sceneGraphNodeDepths vector's
1612 // elements are ordered by depth, and could be used to reduce sorting
1613 // in the update thread.
1614 void Actor::RebuildDepthTree()
1616 DALI_LOG_TIMER_START(depthTimer);
1618 // Vector of scene-graph nodes and their depths to send to UpdateManager
1619 // in a single message
1620 OwnerPointer<SceneGraph::NodeDepths> sceneGraphNodeDepths(new SceneGraph::NodeDepths());
1622 int32_t depthIndex = 1;
1623 DepthTraverseActorTree(sceneGraphNodeDepths, depthIndex);
1625 SetDepthIndicesMessage(GetEventThreadServices().GetUpdateManager(), sceneGraphNodeDepths);
1626 DALI_LOG_TIMER_END(depthTimer, gLogFilter, Debug::Concise, "Depth tree traversal time: ");
1629 void Actor::DepthTraverseActorTree(OwnerPointer<SceneGraph::NodeDepths>& sceneGraphNodeDepths, int32_t& depthIndex)
1631 mSortedDepth = depthIndex * DevelLayer::SIBLING_ORDER_MULTIPLIER;
1632 sceneGraphNodeDepths->Add(const_cast<SceneGraph::Node*>(&GetNode()), mSortedDepth);
1634 // Create/add to children of this node
1635 if(GetChildCount() > 0)
1637 for(const auto& child : mParentImpl.GetChildrenInternal())
1639 Actor* childActor = child.Get();
1641 childActor->DepthTraverseActorTree(sceneGraphNodeDepths, depthIndex);
1646 void Actor::SetDefaultProperty(Property::Index index, const Property::Value& property)
1648 PropertyHandler::SetDefaultProperty(*this, index, property);
1651 // TODO: This method needs to be removed
1652 void Actor::SetSceneGraphProperty(Property::Index index, const PropertyMetadata& entry, const Property::Value& value)
1654 PropertyHandler::SetSceneGraphProperty(index, entry, value, GetEventThreadServices(), GetNode());
1657 Property::Value Actor::GetDefaultProperty(Property::Index index) const
1659 Property::Value value;
1661 if(!GetCachedPropertyValue(index, value))
1663 // If property value is not stored in the event-side, then it must be a scene-graph only property
1664 GetCurrentPropertyValue(index, value);
1670 Property::Value Actor::GetDefaultPropertyCurrentValue(Property::Index index) const
1672 Property::Value value;
1674 if(!GetCurrentPropertyValue(index, value))
1676 // If unable to retrieve scene-graph property value, then it must be an event-side only property
1677 GetCachedPropertyValue(index, value);
1683 void Actor::OnNotifyDefaultPropertyAnimation(Animation& animation, Property::Index index, const Property::Value& value, Animation::Type animationType)
1685 PropertyHandler::OnNotifyDefaultPropertyAnimation(*this, animation, index, value, animationType);
1688 const PropertyBase* Actor::GetSceneObjectAnimatableProperty(Property::Index index) const
1690 const PropertyBase* property = PropertyHandler::GetSceneObjectAnimatableProperty(index, GetNode());
1693 // not our property, ask base
1694 property = Object::GetSceneObjectAnimatableProperty(index);
1700 const PropertyInputImpl* Actor::GetSceneObjectInputProperty(Property::Index index) const
1702 const PropertyInputImpl* property = PropertyHandler::GetSceneObjectInputProperty(index, GetNode());
1705 // reuse animatable property getter as animatable properties are inputs as well
1706 // animatable property chains back to Object::GetSceneObjectInputProperty() so all properties get covered
1707 property = GetSceneObjectAnimatableProperty(index);
1713 int32_t Actor::GetPropertyComponentIndex(Property::Index index) const
1715 int32_t componentIndex = PropertyHandler::GetPropertyComponentIndex(index);
1716 if(Property::INVALID_COMPONENT_INDEX == componentIndex)
1719 componentIndex = Object::GetPropertyComponentIndex(index);
1722 return componentIndex;
1729 mParent->RaiseChild(*this);
1733 DALI_LOG_WARNING("Actor must have a parent, Sibling order not changed.\n");
1741 mParent->LowerChild(*this);
1745 DALI_LOG_WARNING("Actor must have a parent, Sibling order not changed.\n");
1749 void Actor::RaiseToTop()
1753 mParent->RaiseChildToTop(*this);
1757 DALI_LOG_WARNING("Actor must have a parent, Sibling order not changed.\n");
1761 void Actor::LowerToBottom()
1765 mParent->LowerChildToBottom(*this);
1769 DALI_LOG_WARNING("Actor must have a parent, Sibling order not changed.\n");
1773 void Actor::RaiseAbove(Internal::Actor& target)
1777 mParent->RaiseChildAbove(*this, target);
1781 DALI_LOG_WARNING("Actor must have a parent, Sibling order not changed.\n");
1785 void Actor::LowerBelow(Internal::Actor& target)
1789 mParent->LowerChildBelow(*this, target);
1793 DALI_LOG_WARNING("Actor must have a parent, Sibling order not changed.\n");
1797 void Actor::SetParent(ActorParent* parent)
1801 DALI_ASSERT_ALWAYS(!mParent && "Actor cannot have 2 parents");
1804 Actor* parentActor = static_cast<Actor*>(parent);
1805 mScene = parentActor->mScene;
1807 if(EventThreadServices::IsCoreRunning() && // Don't emit signals or send messages during Core destruction
1808 parentActor->OnScene())
1810 // Instruct each actor to create a corresponding node in the scene graph
1811 ConnectToScene(parentActor->GetHierarchyDepth());
1814 // Resolve the name and index for the child properties if any
1815 ResolveChildProperties();
1817 else // parent being set to NULL
1819 DALI_ASSERT_ALWAYS(mParent != nullptr && "Actor should have a parent");
1823 if(EventThreadServices::IsCoreRunning() && // Don't emit signals or send messages during Core destruction
1826 // Disconnect the Node & its children from the scene-graph.
1827 DisconnectNodeMessage(GetEventThreadServices().GetUpdateManager(), GetNode());
1829 // Instruct each actor to discard pointers to the scene-graph
1830 DisconnectFromStage();
1837 bool Actor::DoAction(BaseObject* object, const std::string& actionName, const Property::Map& /* attributes */)
1840 Actor* actor = dynamic_cast<Actor*>(object);
1844 std::string_view name(actionName);
1845 if(name == ACTION_SHOW)
1847 actor->SetVisible(true);
1850 else if(name == ACTION_HIDE)
1852 actor->SetVisible(false);
1860 Rect<> Actor::CalculateScreenExtents() const
1862 auto screenPosition = GetCurrentScreenPosition();
1863 Vector3 size = GetCurrentSize() * GetCurrentWorldScale();
1864 Vector3 anchorPointOffSet = size * (mPositionUsesAnchorPoint ? GetCurrentAnchorPoint() : AnchorPoint::TOP_LEFT);
1865 Vector2 position = Vector2(screenPosition.x - anchorPointOffSet.x, screenPosition.y - anchorPointOffSet.y);
1866 return {position.x, position.y, size.x, size.y};
1869 bool Actor::GetCachedPropertyValue(Property::Index index, Property::Value& value) const
1871 return PropertyHandler::GetCachedPropertyValue(*this, index, value);
1874 bool Actor::GetCurrentPropertyValue(Property::Index index, Property::Value& value) const
1876 return PropertyHandler::GetCurrentPropertyValue(*this, index, value);
1879 Actor::Relayouter& Actor::EnsureRelayouter()
1881 // Assign relayouter
1884 mRelayoutData = new Relayouter();
1887 return *mRelayoutData;
1890 bool Actor::RelayoutDependentOnParent(Dimension::Type dimension)
1892 // Check if actor is dependent on parent
1893 for(uint32_t i = 0; i < Dimension::DIMENSION_COUNT; ++i)
1895 if((dimension & (1 << i)))
1897 const ResizePolicy::Type resizePolicy = GetResizePolicy(static_cast<Dimension::Type>(1 << i));
1898 if(resizePolicy == ResizePolicy::FILL_TO_PARENT || resizePolicy == ResizePolicy::SIZE_RELATIVE_TO_PARENT || resizePolicy == ResizePolicy::SIZE_FIXED_OFFSET_FROM_PARENT)
1908 bool Actor::RelayoutDependentOnChildren(Dimension::Type dimension)
1910 // Check if actor is dependent on children
1911 for(uint32_t i = 0; i < Dimension::DIMENSION_COUNT; ++i)
1913 if((dimension & (1 << i)))
1915 const ResizePolicy::Type resizePolicy = GetResizePolicy(static_cast<Dimension::Type>(1 << i));
1916 switch(resizePolicy)
1918 case ResizePolicy::FIT_TO_CHILDREN:
1919 case ResizePolicy::USE_NATURAL_SIZE: // i.e. For things that calculate their size based on children
1935 bool Actor::RelayoutDependentOnChildrenBase(Dimension::Type dimension)
1937 return Actor::RelayoutDependentOnChildren(dimension);
1940 bool Actor::RelayoutDependentOnDimension(Dimension::Type dimension, Dimension::Type dependentDimension)
1942 // Check each possible dimension and see if it is dependent on the input one
1943 for(uint32_t i = 0; i < Dimension::DIMENSION_COUNT; ++i)
1945 if(dimension & (1 << i))
1947 return mRelayoutData->resizePolicies[i] == ResizePolicy::DIMENSION_DEPENDENCY && mRelayoutData->dimensionDependencies[i] == dependentDimension;
1954 void Actor::SetNegotiatedDimension(float negotiatedDimension, Dimension::Type dimension)
1956 for(uint32_t i = 0; i < Dimension::DIMENSION_COUNT; ++i)
1958 if(dimension & (1 << i))
1960 mRelayoutData->negotiatedDimensions[i] = negotiatedDimension;
1965 float Actor::GetNegotiatedDimension(Dimension::Type dimension) const
1967 // If more than one dimension is requested, just return the first one found
1968 for(uint32_t i = 0; i < Dimension::DIMENSION_COUNT; ++i)
1970 if((dimension & (1 << i)))
1972 return mRelayoutData->negotiatedDimensions[i];
1976 return 0.0f; // Default
1979 void Actor::SetPadding(const Vector2& padding, Dimension::Type dimension)
1981 EnsureRelayouter().SetPadding(padding, dimension);
1984 Vector2 Actor::GetPadding(Dimension::Type dimension) const
1988 // If more than one dimension is requested, just return the first one found
1989 for(uint32_t i = 0; i < Dimension::DIMENSION_COUNT; ++i)
1991 if((dimension & (1 << i)))
1993 return mRelayoutData->dimensionPadding[i];
1998 return Relayouter::DEFAULT_DIMENSION_PADDING;
2001 void Actor::SetLayoutNegotiated(bool negotiated, Dimension::Type dimension)
2003 EnsureRelayouter().SetLayoutNegotiated(negotiated, dimension);
2006 bool Actor::IsLayoutNegotiated(Dimension::Type dimension) const
2008 return mRelayoutData && mRelayoutData->IsLayoutNegotiated(dimension);
2011 float Actor::GetHeightForWidthBase(float width)
2013 float height = 0.0f;
2015 const Vector3 naturalSize = GetNaturalSize();
2016 if(naturalSize.width > 0.0f)
2018 height = naturalSize.height * width / naturalSize.width;
2020 else // we treat 0 as 1:1 aspect ratio
2028 float Actor::GetWidthForHeightBase(float height)
2032 const Vector3 naturalSize = GetNaturalSize();
2033 if(naturalSize.height > 0.0f)
2035 width = naturalSize.width * height / naturalSize.height;
2037 else // we treat 0 as 1:1 aspect ratio
2045 float Actor::CalculateChildSizeBase(const Dali::Actor& child, Dimension::Type dimension)
2047 // Fill to parent, taking size mode factor into account
2048 switch(child.GetResizePolicy(dimension))
2050 case ResizePolicy::FILL_TO_PARENT:
2052 return GetLatestSize(dimension);
2055 case ResizePolicy::SIZE_RELATIVE_TO_PARENT:
2057 return GetLatestSize(dimension) * GetDimensionValue(child.GetProperty<Vector3>(Dali::Actor::Property::SIZE_MODE_FACTOR), dimension);
2060 case ResizePolicy::SIZE_FIXED_OFFSET_FROM_PARENT:
2062 return GetLatestSize(dimension) + GetDimensionValue(child.GetProperty<Vector3>(Dali::Actor::Property::SIZE_MODE_FACTOR), dimension);
2067 return GetLatestSize(dimension);
2072 float Actor::CalculateChildSize(const Dali::Actor& child, Dimension::Type dimension)
2074 // Can be overridden in derived class
2075 return CalculateChildSizeBase(child, dimension);
2078 float Actor::GetHeightForWidth(float width)
2080 // Can be overridden in derived class
2081 return GetHeightForWidthBase(width);
2084 float Actor::GetWidthForHeight(float height)
2086 // Can be overridden in derived class
2087 return GetWidthForHeightBase(height);
2090 float Actor::GetLatestSize(Dimension::Type dimension) const
2092 return IsLayoutNegotiated(dimension) ? GetNegotiatedDimension(dimension) : GetSize(dimension);
2095 float Actor::GetRelayoutSize(Dimension::Type dimension) const
2097 Vector2 padding = GetPadding(dimension);
2099 return GetLatestSize(dimension) + padding.x + padding.y;
2102 float Actor::NegotiateFromParent(Dimension::Type dimension)
2104 Actor* parent = GetParent();
2107 Vector2 padding(GetPadding(dimension));
2108 Vector2 parentPadding(parent->GetPadding(dimension));
2109 return parent->CalculateChildSize(Dali::Actor(this), dimension) - parentPadding.x - parentPadding.y - padding.x - padding.y;
2115 float Actor::NegotiateFromChildren(Dimension::Type dimension)
2117 float maxDimensionPoint = 0.0f;
2119 for(uint32_t i = 0, count = GetChildCount(); i < count; ++i)
2121 ActorPtr child = GetChildAt(i);
2123 if(!child->RelayoutDependentOnParent(dimension))
2125 // Calculate the min and max points that the children range across
2126 float childPosition = GetDimensionValue(child->GetTargetPosition(), dimension);
2127 float dimensionSize = child->GetRelayoutSize(dimension);
2128 maxDimensionPoint = std::max(maxDimensionPoint, childPosition + dimensionSize);
2132 return maxDimensionPoint;
2135 float Actor::GetSize(Dimension::Type dimension) const
2137 return GetDimensionValue(mTargetSize, dimension);
2140 float Actor::GetNaturalSize(Dimension::Type dimension) const
2142 return GetDimensionValue(GetNaturalSize(), dimension);
2145 float Actor::CalculateSize(Dimension::Type dimension, const Vector2& maximumSize)
2147 switch(GetResizePolicy(dimension))
2149 case ResizePolicy::USE_NATURAL_SIZE:
2151 return GetNaturalSize(dimension);
2154 case ResizePolicy::FIXED:
2156 return GetDimensionValue(GetPreferredSize(), dimension);
2159 case ResizePolicy::USE_ASSIGNED_SIZE:
2161 return GetDimensionValue(maximumSize, dimension);
2164 case ResizePolicy::FILL_TO_PARENT:
2165 case ResizePolicy::SIZE_RELATIVE_TO_PARENT:
2166 case ResizePolicy::SIZE_FIXED_OFFSET_FROM_PARENT:
2168 return NegotiateFromParent(dimension);
2171 case ResizePolicy::FIT_TO_CHILDREN:
2173 return NegotiateFromChildren(dimension);
2176 case ResizePolicy::DIMENSION_DEPENDENCY:
2178 const Dimension::Type dimensionDependency = GetDimensionDependency(dimension);
2181 if(dimension == Dimension::WIDTH && dimensionDependency == Dimension::HEIGHT)
2183 return GetWidthForHeight(GetNegotiatedDimension(Dimension::HEIGHT));
2186 if(dimension == Dimension::HEIGHT && dimensionDependency == Dimension::WIDTH)
2188 return GetHeightForWidth(GetNegotiatedDimension(Dimension::WIDTH));
2200 return 0.0f; // Default
2203 Vector2 Actor::ApplySizeSetPolicy(const Vector2& size)
2205 return mRelayoutData->ApplySizeSetPolicy(*this, size);
2208 void Actor::SetNegotiatedSize(RelayoutContainer& container)
2210 // Do the set actor size
2211 Vector2 negotiatedSize(GetLatestSize(Dimension::WIDTH), GetLatestSize(Dimension::HEIGHT));
2213 // Adjust for size set policy
2214 negotiatedSize = ApplySizeSetPolicy(negotiatedSize);
2216 // Lock the flag to stop recursive relayouts on set size
2217 mRelayoutData->insideRelayout = true;
2218 SetSize(negotiatedSize);
2219 mRelayoutData->insideRelayout = false;
2221 // Clear flags for all dimensions
2222 SetLayoutDirty(false);
2224 // Give deriving classes a chance to respond
2225 OnRelayout(negotiatedSize, container);
2227 if(!mOnRelayoutSignal.Empty())
2229 Dali::Actor handle(this);
2230 mOnRelayoutSignal.Emit(handle);
2234 void Actor::NegotiateSize(const Vector2& allocatedSize, RelayoutContainer& container)
2236 Relayouter::NegotiateSize(*this, allocatedSize, container);
2239 void Actor::SetUseAssignedSize(bool use, Dimension::Type dimension)
2243 mRelayoutData->SetUseAssignedSize(use, dimension);
2247 bool Actor::GetUseAssignedSize(Dimension::Type dimension) const
2249 return mRelayoutData && mRelayoutData->GetUseAssignedSize(dimension);
2252 void Actor::RelayoutRequest(Dimension::Type dimension)
2254 Internal::RelayoutController* relayoutController = Internal::RelayoutController::Get();
2255 if(relayoutController)
2257 Dali::Actor self(this);
2258 relayoutController->RequestRelayout(self, dimension);
2262 void Actor::SetPreferredSize(const Vector2& size)
2264 EnsureRelayouter().SetPreferredSize(*this, size);
2267 Vector2 Actor::GetPreferredSize() const
2271 return Vector2(mRelayoutData->preferredSize);
2274 return Relayouter::DEFAULT_PREFERRED_SIZE;
2277 void Actor::SetMinimumSize(float size, Dimension::Type dimension)
2279 EnsureRelayouter().SetMinimumSize(size, dimension);
2283 float Actor::GetMinimumSize(Dimension::Type dimension) const
2287 return mRelayoutData->GetMinimumSize(dimension);
2290 return 0.0f; // Default
2293 void Actor::SetMaximumSize(float size, Dimension::Type dimension)
2295 EnsureRelayouter().SetMaximumSize(size, dimension);
2299 float Actor::GetMaximumSize(Dimension::Type dimension) const
2303 return mRelayoutData->GetMaximumSize(dimension);
2306 return FLT_MAX; // Default
2309 void Actor::SetVisibleInternal(bool visible, SendMessage::Type sendMessage)
2311 if(mVisible != visible)
2313 if(sendMessage == SendMessage::TRUE)
2315 // node is being used in a separate thread; queue a message to set the value & base value
2316 SceneGraph::NodePropertyMessage<bool>::Send(GetEventThreadServices(), &GetNode(), &GetNode().mVisible, &AnimatableProperty<bool>::Bake, visible);
2318 RequestRenderingMessage(GetEventThreadServices().GetUpdateManager());
2323 // Emit the signal on this actor and all its children
2324 EmitVisibilityChangedSignalRecursively(visible, DevelActor::VisibilityChange::SELF);
2328 void Actor::SetSiblingOrderOfChild(Actor& child, uint32_t order)
2330 mParentImpl.SetSiblingOrderOfChild(child, order);
2333 uint32_t Actor::GetSiblingOrderOfChild(const Actor& child) const
2335 return mParentImpl.GetSiblingOrderOfChild(child);
2338 void Actor::RaiseChild(Actor& child)
2340 mParentImpl.RaiseChild(child);
2343 void Actor::LowerChild(Actor& child)
2345 mParentImpl.LowerChild(child);
2348 void Actor::RaiseChildToTop(Actor& child)
2350 mParentImpl.RaiseChildToTop(child);
2353 void Actor::LowerChildToBottom(Actor& child)
2355 mParentImpl.LowerChildToBottom(child);
2358 void Actor::RaiseChildAbove(Actor& child, Actor& target)
2360 mParentImpl.RaiseChildAbove(child, target);
2363 void Actor::LowerChildBelow(Actor& child, Actor& target)
2365 mParentImpl.LowerChildBelow(child, target);
2368 void Actor::SetInheritLayoutDirection(bool inherit)
2370 if(mInheritLayoutDirection != inherit)
2372 mInheritLayoutDirection = inherit;
2374 if(inherit && mParent)
2376 InheritLayoutDirectionRecursively(GetParent()->mLayoutDirection);
2381 void Actor::InheritLayoutDirectionRecursively(Dali::LayoutDirection::Type direction, bool set)
2383 if(mInheritLayoutDirection || set)
2385 if(mLayoutDirection != direction)
2387 mLayoutDirection = direction;
2388 EmitLayoutDirectionChangedSignal(direction);
2392 if(GetChildCount() > 0)
2394 for(const auto& child : mParentImpl.GetChildrenInternal())
2396 child->InheritLayoutDirectionRecursively(direction);
2402 void Actor::SetUpdateSizeHint(const Vector2& updateSizeHint)
2404 // node is being used in a separate thread; queue a message to set the value & base value
2405 SceneGraph::NodePropertyMessage<Vector3>::Send(GetEventThreadServices(), &GetNode(), &GetNode().mUpdateSizeHint, &AnimatableProperty<Vector3>::Bake, Vector3(updateSizeHint.width, updateSizeHint.height, 0.f));
2408 void Actor::EmitVisibilityChangedSignalRecursively(bool visible,
2409 DevelActor::VisibilityChange::Type type)
2411 EmitVisibilityChangedSignal(visible, type);
2413 if(GetChildCount() > 0)
2415 for(auto& child : mParentImpl.GetChildrenInternal())
2417 child->EmitVisibilityChangedSignalRecursively(visible, DevelActor::VisibilityChange::PARENT);
2422 } // namespace Internal