#include <dali/internal/event/common/property-helper.h>
#include <dali/internal/event/common/stage-impl.h>
#include <dali/internal/event/common/type-info-impl.h>
+#include <dali/internal/event/common/scene-impl.h>
+#include <dali/internal/event/common/thread-local-storage.h>
#include <dali/internal/event/animation/constraint-impl.h>
#include <dali/internal/event/common/projection.h>
#include <dali/internal/event/size-negotiation/relayout-controller-impl.h>
// create node. Nodes are owned by the update manager
SceneGraph::Node* node = SceneGraph::Node::New();
OwnerPointer< SceneGraph::Node > transferOwnership( node );
- AddNodeMessage( Stage::GetCurrent()->GetUpdateManager(), transferOwnership );
+ Internal::ThreadLocalStorage* tls = Internal::ThreadLocalStorage::GetInternal();
+ AddNodeMessage( tls->GetUpdateManager(), transferOwnership );
return node;
}
const Vector2 Actor::GetCurrentScreenPosition() const
{
- StagePtr stage = Stage::GetCurrent();
- if( stage && OnStage() )
+ if( mScene && OnStage() )
{
Vector3 worldPosition = GetNode().GetWorldPosition( GetEventThreadServices().GetEventBufferIndex() );
- Vector3 cameraPosition = stage->GetDefaultCameraActor().GetNode().GetWorldPosition( GetEventThreadServices().GetEventBufferIndex() );
+ Vector3 cameraPosition = mScene->GetDefaultCameraActor().GetNode().GetWorldPosition( GetEventThreadServices().GetEventBufferIndex() );
worldPosition -= cameraPosition;
Vector3 actorSize = GetCurrentSize() * GetCurrentWorldScale();
- Vector2 halfStageSize( stage->GetSize() * 0.5f ); // World position origin is center of stage
+ Vector2 halfSceneSize( mScene->GetSize() * 0.5f ); // World position origin is center of scene
Vector3 halfActorSize( actorSize * 0.5f );
Vector3 anchorPointOffSet = halfActorSize - actorSize * ( mPositionUsesAnchorPoint ? GetCurrentAnchorPoint() : AnchorPoint::TOP_LEFT );
- return Vector2( halfStageSize.width + worldPosition.x - anchorPointOffSet.x,
- halfStageSize.height + worldPosition.y - anchorPointOffSet.y );
+ return Vector2( halfSceneSize.width + worldPosition.x - anchorPointOffSet.x,
+ halfSceneSize.height + worldPosition.y - anchorPointOffSet.y );
}
return Vector2::ZERO;
bool Actor::ScreenToLocal( float& localX, float& localY, float screenX, float screenY ) const
{
// only valid when on-stage
- StagePtr stage = Stage::GetCurrent();
- if( stage && OnStage() )
+ if( mScene && OnStage() )
{
- const RenderTaskList& taskList = stage->GetRenderTaskList();
+ const RenderTaskList& taskList = mScene->GetRenderTaskList();
Vector2 converted( screenX, screenY );
Actor::Actor( DerivedType derivedType, const SceneGraph::Node& node )
: Object( &node ),
+ mScene( nullptr ),
mParent( NULL ),
mChildren( NULL ),
mRenderers( NULL ),
// It protects us when the Actor hierarchy is modified during OnStageConnectionExternal callbacks.
ActorContainer connectionList;
- StagePtr stage = Stage::GetCurrent();
- if( stage )
+ if( mScene )
{
- stage->RequestRebuildDepthTree();
+ mScene->RequestRebuildDepthTree();
}
// This stage is atomic i.e. not interrupted by user callbacks.
ActorConstIter endIter = mChildren->end();
for( ActorIter iter = mChildren->begin(); iter != endIter; ++iter )
{
+ (*iter)->SetScene( *mScene );
(*iter)->RecursiveConnectToStage( connectionList, depth + 1 );
}
}
// It protects us when the Actor hierachy is modified during OnStageDisconnectionExternal callbacks.
ActorContainer disconnectionList;
- StagePtr stage = Stage::GetCurrent();
- if( stage )
+ if( mScene )
{
- stage->RequestRebuildDepthTree();
+ mScene->RequestRebuildDepthTree();
}
// This stage is atomic i.e. not interrupted by user callbacks
mParent = parent;
+ mScene = parent->mScene;
+
if ( EventThreadServices::IsCoreRunning() && // Don't emit signals or send messages during Core destruction
parent->OnStage() )
{
// Instruct each actor to discard pointers to the scene-graph
DisconnectFromStage();
}
+
+ mScene = nullptr;
}
}
{
if( mIsOnStage )
{
- StagePtr stage = Stage::GetCurrent();
- if( stage )
+ if( mScene )
{
- stage->RequestRebuildDepthTree();
+ mScene->RequestRebuildDepthTree();
}
}
}
}
}
+void Actor::SetScene( Scene& scene )
+{
+ mScene = &scene;
+}
+
+Scene& Actor::GetScene() const
+{
+ return *mScene;
+}
+
void Actor::SetInheritLayoutDirection( bool inherit )
{
if( mInheritLayoutDirection != inherit )