#include <dali/public-api/object/type-registry.h>
#include <dali/devel-api/actors/actor-devel.h>
-#include <dali/devel-api/actors/layer-devel.h>
#include <dali/devel-api/common/capabilities.h>
#include <dali/integration-api/debug.h>
mScene->RequestRebuildDepthTree();
}
- // This stage is atomic i.e. not interrupted by user callbacks.
- RecursiveConnectToScene(connectionList, parentDepth + 1);
+ // This stage is not interrupted by user callbacks.
+ mParentImpl.RecursiveConnectToScene(connectionList, parentDepth + 1);
// Notify applications about the newly connected actors.
for(const auto& actor : connectionList)
RelayoutRequest();
}
-void Actor::RecursiveConnectToScene(ActorContainer& connectionList, uint32_t depth)
-{
- DALI_ASSERT_ALWAYS(!OnScene());
-
- mIsOnScene = true;
- mDepth = static_cast<uint16_t>(depth); // overflow ignored, not expected in practice
-
- ConnectToSceneGraph();
-
- // Notification for internal derived classes
- OnSceneConnectionInternal();
-
- // This stage is atomic; avoid emitting callbacks until all Actors are connected
- connectionList.push_back(ActorPtr(this));
-
- // Recursively connect children
- if(GetChildCount() > 0)
- {
- for(const auto& child : mParentImpl.GetChildrenInternal())
- {
- child->SetScene(*mScene);
- child->RecursiveConnectToScene(connectionList, depth + 1);
- }
- }
-}
-
/**
* This method is called when the Actor is connected to the Stage.
* The parent must have added its Node to the scene-graph.
mScene->RequestRebuildDepthTree();
}
- // This stage is atomic i.e. not interrupted by user callbacks
- RecursiveDisconnectFromStage(disconnectionList);
+ // This stage is not interrupted by user callbacks
+ mParentImpl.RecursiveDisconnectFromScene(disconnectionList);
// Notify applications about the newly disconnected actors.
for(const auto& actor : disconnectionList)
}
}
-void Actor::RecursiveDisconnectFromStage(ActorContainer& disconnectionList)
-{
- // need to change state first so that internals relying on IsOnScene() inside OnSceneDisconnectionInternal() get the correct value
- mIsOnScene = false;
-
- // Recursively disconnect children
- if(GetChildCount() > 0)
- {
- for(const auto& child : mParentImpl.GetChildrenInternal())
- {
- child->RecursiveDisconnectFromStage(disconnectionList);
- }
- }
-
- // This stage is atomic; avoid emitting callbacks until all Actors are disconnected
- disconnectionList.push_back(ActorPtr(this));
-
- // Notification for internal derived classes
- OnSceneDisconnectionInternal();
-
- DisconnectFromSceneGraph();
-}
-
/**
* This method is called by an actor or its parent, before a node removal message is sent.
* This is recursive; the child calls DisconnectFromStage() for its children.
bool Actor::IsNodeConnected() const
{
- bool connected(false);
-
- if(OnScene())
- {
- if(IsRoot() || GetNode().GetParent())
- {
- connected = true;
- }
- }
-
- return connected;
+ return OnScene() && (IsRoot() || GetNode().GetParent());
}
// This method initiates traversal of the actor tree using depth-first
OwnerPointer<SceneGraph::NodeDepths> sceneGraphNodeDepths(new SceneGraph::NodeDepths());
int32_t depthIndex = 1;
- DepthTraverseActorTree(sceneGraphNodeDepths, depthIndex);
+ mParentImpl.DepthTraverseActorTree(sceneGraphNodeDepths, depthIndex);
SetDepthIndicesMessage(GetEventThreadServices().GetUpdateManager(), sceneGraphNodeDepths);
DALI_LOG_TIMER_END(depthTimer, gLogFilter, Debug::Concise, "Depth tree traversal time: ");
}
-void Actor::DepthTraverseActorTree(OwnerPointer<SceneGraph::NodeDepths>& sceneGraphNodeDepths, int32_t& depthIndex)
-{
- mSortedDepth = depthIndex * DevelLayer::SIBLING_ORDER_MULTIPLIER;
- sceneGraphNodeDepths->Add(const_cast<SceneGraph::Node*>(&GetNode()), mSortedDepth);
-
- // Create/add to children of this node
- if(GetChildCount() > 0)
- {
- for(const auto& child : mParentImpl.GetChildrenInternal())
- {
- Actor* childActor = child.Get();
- ++depthIndex;
- childActor->DepthTraverseActorTree(sceneGraphNodeDepths, depthIndex);
- }
- }
-}
-
void Actor::SetDefaultProperty(Property::Index index, const Property::Value& property)
{
PropertyHandler::SetDefaultProperty(*this, index, property);
float Actor::GetHeightForWidthBase(float width)
{
- float height = 0.0f;
-
const Vector3 naturalSize = GetNaturalSize();
- if(naturalSize.width > 0.0f)
- {
- height = naturalSize.height * width / naturalSize.width;
- }
- else // we treat 0 as 1:1 aspect ratio
- {
- height = width;
- }
-
- return height;
+ return naturalSize.width > 0.0f ? naturalSize.height * width / naturalSize.width : width;
}
float Actor::GetWidthForHeightBase(float height)
{
- float width = 0.0f;
-
const Vector3 naturalSize = GetNaturalSize();
- if(naturalSize.height > 0.0f)
- {
- width = naturalSize.width * height / naturalSize.height;
- }
- else // we treat 0 as 1:1 aspect ratio
- {
- width = height;
- }
-
- return width;
+ return naturalSize.height > 0.0f ? naturalSize.width * height / naturalSize.height : height;
}
float Actor::CalculateChildSizeBase(const Dali::Actor& child, Dimension::Type dimension)
Vector2 Actor::GetPreferredSize() const
{
- if(mRelayoutData)
- {
- return Vector2(mRelayoutData->preferredSize);
- }
-
- return Relayouter::DEFAULT_PREFERRED_SIZE;
+ return mRelayoutData ? Vector2(mRelayoutData->preferredSize) : Relayouter::DEFAULT_PREFERRED_SIZE;
}
void Actor::SetMinimumSize(float size, Dimension::Type dimension)
float Actor::GetMinimumSize(Dimension::Type dimension) const
{
- if(mRelayoutData)
- {
- return mRelayoutData->GetMinimumSize(dimension);
- }
-
- return 0.0f; // Default
+ return mRelayoutData ? mRelayoutData->GetMinimumSize(dimension) : 0.0f;
}
void Actor::SetMaximumSize(float size, Dimension::Type dimension)
float Actor::GetMaximumSize(Dimension::Type dimension) const
{
- if(mRelayoutData)
- {
- return mRelayoutData->GetMaximumSize(dimension);
- }
-
- return FLT_MAX; // Default
+ return mRelayoutData ? mRelayoutData->GetMaximumSize(dimension) : FLT_MAX;
}
void Actor::SetVisibleInternal(bool visible, SendMessage::Type sendMessage)
mVisible = visible;
// Emit the signal on this actor and all its children
- EmitVisibilityChangedSignalRecursively(visible, DevelActor::VisibilityChange::SELF);
+ mParentImpl.EmitVisibilityChangedSignalRecursively(visible, DevelActor::VisibilityChange::SELF);
}
}
if(inherit && mParent)
{
- InheritLayoutDirectionRecursively(GetParent()->mLayoutDirection);
- }
- }
-}
-
-void Actor::InheritLayoutDirectionRecursively(Dali::LayoutDirection::Type direction, bool set)
-{
- if(mInheritLayoutDirection || set)
- {
- if(mLayoutDirection != direction)
- {
- mLayoutDirection = direction;
- EmitLayoutDirectionChangedSignal(direction);
- RelayoutRequest();
- }
-
- if(GetChildCount() > 0)
- {
- for(const auto& child : mParentImpl.GetChildrenInternal())
- {
- child->InheritLayoutDirectionRecursively(direction);
- }
+ mParentImpl.InheritLayoutDirectionRecursively(GetParent()->mLayoutDirection);
}
}
}
SceneGraph::NodePropertyMessage<Vector3>::Send(GetEventThreadServices(), &GetNode(), &GetNode().mUpdateSizeHint, &AnimatableProperty<Vector3>::Bake, Vector3(updateSizeHint.width, updateSizeHint.height, 0.f));
}
-void Actor::EmitVisibilityChangedSignalRecursively(bool visible,
- DevelActor::VisibilityChange::Type type)
-{
- EmitVisibilityChangedSignal(visible, type);
-
- if(GetChildCount() > 0)
- {
- for(auto& child : mParentImpl.GetChildrenInternal())
- {
- child->EmitVisibilityChangedSignalRecursively(visible, DevelActor::VisibilityChange::PARENT);
- }
- }
-}
-
} // namespace Internal
} // namespace Dali
*
* @return The depth used for hit-testing and renderer sorting
*/
- uint32_t GetSortingDepth()
+ inline uint32_t GetSortingDepth()
{
return mSortedDepth;
}
+ /**
+ * Set the actor's sorted depth. Used during recreation of depth tree
+ * @param[in] sortedDepth the new sorted depth
+ */
+ inline void SetSortingDepth(uint32_t sortedDepth)
+ {
+ mSortedDepth = sortedDepth;
+ }
+
public:
// Size negotiation virtual functions
void ConnectToScene(uint32_t parentDepth, bool notify);
/**
- * Helper for ConnectToScene, to recursively connect a tree of actors.
- * This is atomic i.e. not interrupted by user callbacks.
- * @param[in] depth The depth in the hierarchy of the actor
- * @param[out] connectionList On return, the list of connected actors which require notification.
- */
- void RecursiveConnectToScene(ActorContainer& connectionList, uint32_t depth);
-
- /**
* Connect the Node associated with this Actor to the scene-graph.
*/
void ConnectToSceneGraph();
void DisconnectFromStage(bool notify);
/**
- * Helper for DisconnectFromStage, to recursively disconnect a tree of actors.
- * This is atomic i.e. not interrupted by user callbacks.
- * @param[out] disconnectionList On return, the list of disconnected actors which require notification.
- */
- void RecursiveDisconnectFromStage(ActorContainer& disconnectionList);
-
- /**
* Disconnect the Node associated with this Actor from the scene-graph.
*/
void DisconnectFromSceneGraph();
*/
void RebuildDepthTree();
-protected:
- /**
- * Traverse the actor tree, inserting actors into the depth tree in sibling order.
- * @param[in] sceneGraphNodeDepths A vector capturing the nodes and their depth index
- * @param[in,out] depthIndex The current depth index (traversal index)
- */
- void DepthTraverseActorTree(OwnerPointer<SceneGraph::NodeDepths>& sceneGraphNodeDepths, int32_t& depthIndex);
-
public:
// Default property extensions from Object
}
/**
- * @brief Propagates layout direction recursively.
- * @param[in] direction New layout direction.
- */
- void InheritLayoutDirectionRecursively(Dali::LayoutDirection::Type direction, bool set = false);
-
- /**
* @brief Sets the update size hint of an actor.
* @param [in] updateSizeHint The update size hint.
*/
void SetUpdateSizeHint(const Vector2& updateSizeHint);
- /**
- * @brief Recursively emits the visibility-changed-signal on the actor tree.
- *
- * @param[in] visible The new visibility of the actor
- * @param[in] type Whether the actor's visible property has changed or a parent's
- */
- void EmitVisibilityChangedSignalRecursively(bool visible,
- DevelActor::VisibilityChange::Type type);
-
protected:
ActorParentImpl mParentImpl; ///< Implementation of ActorParent;
ActorParent* mParent; ///< Each actor (except the root) can have one parent
#include <dali/internal/event/actors/actor-parent.h>
// INTERNAL INCLUDES
+#include <dali/devel-api/actors/layer-devel.h>
#include <dali/internal/event/actors/actor-impl.h>
#include <dali/internal/event/common/scene-impl.h>
#include <dali/public-api/common/vector-wrapper.h>
EmitChildAddedSignal(child);
}
- child.InheritLayoutDirectionRecursively(mOwner.GetLayoutDirection());
+ child.mParentImpl.InheritLayoutDirectionRecursively(mOwner.GetLayoutDirection());
// Only put in a relayout request if there is a suitable dependency
if(mOwner.RelayoutDependentOnChildren())
}
}
+void ActorParentImpl::DepthTraverseActorTree(OwnerPointer<SceneGraph::NodeDepths>& sceneGraphNodeDepths,
+ int32_t& depthIndex)
+{
+ uint32_t sortedDepth = depthIndex * DevelLayer::SIBLING_ORDER_MULTIPLIER;
+ mOwner.SetSortingDepth(sortedDepth);
+ sceneGraphNodeDepths->Add(const_cast<SceneGraph::Node*>(&mOwner.GetNode()), sortedDepth);
+
+ // Create/add to children of this node
+ if(mChildren)
+ {
+ for(const auto& actor : *mChildren)
+ {
+ ++depthIndex;
+ actor->mParentImpl.DepthTraverseActorTree(sceneGraphNodeDepths, depthIndex);
+ }
+ }
+}
+
+void ActorParentImpl::RecursiveConnectToScene(ActorContainer& connectionList, uint32_t depth)
+{
+ DALI_ASSERT_ALWAYS(!mOwner.OnScene());
+
+ mOwner.mIsOnScene = true;
+ mOwner.mDepth = static_cast<uint16_t>(depth); // overflow ignored, not expected in practice
+ mOwner.ConnectToSceneGraph();
+
+ // Notification for internal derived classes
+ mOwner.OnSceneConnectionInternal();
+
+ // This stage is atomic; avoid emitting callbacks until all Actors are connected
+ connectionList.push_back(ActorPtr(&mOwner));
+
+ // Recursively connect children
+ if(mChildren)
+ {
+ for(const auto& actor : *mChildren)
+ {
+ actor->SetScene(*mOwner.mScene);
+ actor->mParentImpl.RecursiveConnectToScene(connectionList, depth + 1);
+ }
+ }
+}
+
+void ActorParentImpl::RecursiveDisconnectFromScene(ActorContainer& disconnectionList)
+{
+ // need to change state first so that internals relying on IsOnScene() inside OnSceneDisconnectionInternal() get the correct value
+ mOwner.mIsOnScene = false;
+
+ // Recursively disconnect children
+ if(mChildren)
+ {
+ for(const auto& actor : *mChildren)
+ {
+ actor->mParentImpl.RecursiveDisconnectFromScene(disconnectionList);
+ }
+ }
+
+ // This stage is atomic; avoid emitting callbacks until all Actors are disconnected
+ disconnectionList.push_back(ActorPtr(&mOwner));
+
+ // Notification for internal derived classes
+ mOwner.OnSceneDisconnectionInternal();
+ mOwner.DisconnectFromSceneGraph();
+}
+
+void ActorParentImpl::InheritLayoutDirectionRecursively(Dali::LayoutDirection::Type direction, bool set)
+{
+ if(mOwner.mInheritLayoutDirection || set)
+ {
+ if(mOwner.mLayoutDirection != direction)
+ {
+ mOwner.mLayoutDirection = direction;
+ mOwner.EmitLayoutDirectionChangedSignal(direction);
+ mOwner.RelayoutRequest();
+ }
+
+ if(mChildren)
+ {
+ for(const auto& child : *mChildren)
+ {
+ child->mParentImpl.InheritLayoutDirectionRecursively(direction);
+ }
+ }
+ }
+}
+
+void ActorParentImpl::EmitVisibilityChangedSignalRecursively(
+ bool visible,
+ DevelActor::VisibilityChange::Type type)
+{
+ mOwner.EmitVisibilityChangedSignal(visible, type);
+
+ if(mChildren)
+ {
+ for(const auto& child : *mChildren)
+ {
+ child->mParentImpl.EmitVisibilityChangedSignalRecursively(visible, DevelActor::VisibilityChange::PARENT);
+ }
+ }
+}
+
void ActorParentImpl::EmitChildAddedSignal(Actor& child)
{
EmitSignal(child, mChildAddedSignal);
// INTERNAL INCLUDES
#include <dali/devel-api/actors/actor-devel.h>
#include <dali/internal/common/const-string.h>
+#include <dali/internal/common/owner-pointer.h>
#include <dali/internal/event/actors/actor-declarations.h>
#include <dali/internal/event/actors/actor-parent.h>
+#include <dali/internal/update/nodes/node-declarations.h>
// EXTERNAL INCLUDES
#include <string>
return mChildOrderChangedSignal;
}
+ /**
+ * Traverse the actor tree, inserting actors into the depth tree in sibling order.
+ * @param[in] sceneGraphNodeDepths A vector capturing the nodes and their depth index
+ * @param[in,out] depthIndex The current depth index (traversal index)
+ */
+ void DepthTraverseActorTree(OwnerPointer<SceneGraph::NodeDepths>& sceneGraphNodeDepths, int32_t& depthIndex);
+
+ /**
+ * Helper to recursively connect a tree of actors.
+ * This is not interrupted by user callbacks
+ * @param[in] depth The depth in the hierarchy of the actor
+ * @param[out] connectionList On return, the list of connected actors which require notification.
+ */
+ void RecursiveConnectToScene(ActorContainer& connectionList, uint32_t depth);
+
+ /**
+ * Helper to recursively disconnect a tree of actors.
+ * This is not interrupted by user callbacks.
+ * @param[out] disconnectionList On return, the list of disconnected actors which require notification.
+ */
+ void RecursiveDisconnectFromScene(ActorContainer& disconnectionList);
+
+ /**
+ * @brief Propagates layout direction recursively.
+ * @param[in] direction New layout direction.
+ */
+ void InheritLayoutDirectionRecursively(Dali::LayoutDirection::Type direction, bool set = false);
+
+ /**
+ * @brief Recursively emits the visibility-changed-signal on the actor tree.
+ *
+ * @param[in] visible The new visibility of the actor
+ * @param[in] type Whether the actor's visible property has changed or a parent's
+ */
+ void EmitVisibilityChangedSignalRecursively(bool visible,
+ DevelActor::VisibilityChange::Type type);
+
private:
/**
* @brief Emits the ChildAdded signal for this actor
if(Scripting::GetEnumerationProperty<LayoutDirection::Type>(property, LAYOUT_DIRECTION_TABLE, LAYOUT_DIRECTION_TABLE_COUNT, direction))
{
- actor.InheritLayoutDirectionRecursively(direction, true);
+ actor.mParentImpl.InheritLayoutDirectionRecursively(direction, true);
}
break;
}