/*
- * Copyright (c) 2018 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2019 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
#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>
DALI_PROPERTY( "inheritOrientation", BOOLEAN, true, false, false, Dali::Actor::Property::INHERIT_ORIENTATION )
DALI_PROPERTY( "inheritScale", BOOLEAN, true, false, false, Dali::Actor::Property::INHERIT_SCALE )
DALI_PROPERTY( "colorMode", STRING, true, false, false, Dali::Actor::Property::COLOR_MODE )
-DALI_PROPERTY( "positionInheritance", STRING, true, false, false, Dali::Actor::Property::POSITION_INHERITANCE )
+DALI_PROPERTY( "reservedProperty01", STRING, true, false, false, Dali::Actor::Property::RESERVED_PROPERTY_01 ) // This property was removed, but to keep binary compatibility and TypeRegister test app, remain it here.
DALI_PROPERTY( "drawMode", STRING, true, false, false, Dali::Actor::Property::DRAW_MODE )
DALI_PROPERTY( "sizeModeFactor", VECTOR3, true, false, false, Dali::Actor::Property::SIZE_MODE_FACTOR )
DALI_PROPERTY( "widthResizePolicy", STRING, true, false, false, Dali::Actor::Property::WIDTH_RESIZE_POLICY )
DALI_ENUM_TO_STRING( USE_OWN_MULTIPLY_PARENT_ALPHA )
DALI_ENUM_TO_STRING_TABLE_END( COLOR_MODE )
-DALI_ENUM_TO_STRING_TABLE_BEGIN( POSITION_INHERITANCE_MODE )
-DALI_ENUM_TO_STRING( INHERIT_PARENT_POSITION )
-DALI_ENUM_TO_STRING( USE_PARENT_POSITION )
-DALI_ENUM_TO_STRING( USE_PARENT_POSITION_PLUS_LOCAL_POSITION )
-DALI_ENUM_TO_STRING( DONT_INHERIT_POSITION )
-DALI_ENUM_TO_STRING_TABLE_END( POSITION_INHERITANCE_MODE )
-
DALI_ENUM_TO_STRING_TABLE_BEGIN( DRAW_MODE )
DALI_ENUM_TO_STRING_WITH_SCOPE( DrawMode, NORMAL )
DALI_ENUM_TO_STRING_WITH_SCOPE( DrawMode, OVERLAY_2D )
-DALI_ENUM_TO_STRING_WITH_SCOPE( DrawMode, STENCIL )
DALI_ENUM_TO_STRING_TABLE_END( DRAW_MODE )
DALI_ENUM_TO_STRING_TABLE_BEGIN( RESIZE_POLICY )
// 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;
}
-void Actor::SetPositionInheritanceMode( PositionInheritanceMode mode )
-{
- // this flag is not animatable so keep the value
- mPositionInheritanceMode = mode;
- // node is being used in a separate thread; queue a message to set the value
- SetInheritPositionMessage( GetEventThreadServices(), GetNode(), mode == INHERIT_PARENT_POSITION );
-}
-
-PositionInheritanceMode Actor::GetPositionInheritanceMode() const
-{
- // Cached for event-thread access
- return mPositionInheritanceMode;
-}
-
void Actor::SetInheritPosition( bool inherit )
{
if( mInheritPosition != inherit )
EnsureRelayoutData();
mRelayoutData->sizeSetPolicy = policy;
+
+ // Trigger relayout on this control
+ RelayoutRequest();
}
SizeScalePolicy::Type Actor::GetSizeScalePolicy() const
{
// this flag is not animatable so keep the value
mDrawMode = drawMode;
- if( drawMode != DrawMode::STENCIL )
- {
- // node is being used in a separate thread; queue a message to set the value
- SetDrawModeMessage( GetEventThreadServices(), GetNode(), drawMode );
- }
+
+ // node is being used in a separate thread; queue a message to set the value
+ SetDrawModeMessage( GetEventThreadServices(), GetNode(), drawMode );
}
DrawMode::Type Actor::GetDrawMode() const
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 );
return *mGestureData;
}
-bool Actor::IsGestureRequred( Gesture::Type type ) const
+bool Actor::IsGestureRequred( DevelGesture::Type type ) const
{
return mGestureData && mGestureData->IsGestureRequred( type );
}
Actor::Actor( DerivedType derivedType, const SceneGraph::Node& node )
: Object( &node ),
+ mScene( nullptr ),
mParent( NULL ),
mChildren( NULL ),
mRenderers( NULL ),
mInheritLayoutDirection( true ),
mLayoutDirection( LayoutDirection::LEFT_TO_RIGHT ),
mDrawMode( DrawMode::NORMAL ),
- mPositionInheritanceMode( Node::DEFAULT_POSITION_INHERITANCE_MODE ),
mColorMode( Node::DEFAULT_COLOR_MODE ),
mClippingMode( ClippingMode::DISABLED )
{
// Guard to allow handle destruction after Core has been destroyed
if( EventThreadServices::IsCoreRunning() )
{
- DestroyNodeMessage( GetEventThreadServices().GetUpdateManager(), GetNode() );
+ // Root layer will destroy its node in its own destructor
+ if ( !mIsRoot )
+ {
+ DestroyNodeMessage( GetEventThreadServices().GetUpdateManager(), GetNode() );
- GetEventThreadServices().UnregisterObject( this );
+ GetEventThreadServices().UnregisterObject( this );
+ }
}
// Cleanup optional gesture data
// 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
break;
}
- case Dali::Actor::Property::POSITION_INHERITANCE:
- {
- PositionInheritanceMode mode = mPositionInheritanceMode;
- if( Scripting::GetEnumerationProperty< PositionInheritanceMode >( property, POSITION_INHERITANCE_MODE_TABLE, POSITION_INHERITANCE_MODE_TABLE_COUNT, mode ) )
- {
- SetPositionInheritanceMode( mode );
- }
- break;
- }
-
case Dali::Actor::Property::DRAW_MODE:
{
DrawMode::Type mode = mDrawMode;
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;
}
}
return done;
}
+Rect<> Actor::CalculateScreenExtents( ) const
+{
+ auto screenPosition = GetCurrentScreenPosition();
+ Vector3 size = GetCurrentSize() * GetCurrentWorldScale();
+ Vector3 anchorPointOffSet = size * ( mPositionUsesAnchorPoint ? GetCurrentAnchorPoint() : AnchorPoint::TOP_LEFT );
+ Vector2 position = Vector2( screenPosition.x - anchorPointOffSet.x, screenPosition.y - anchorPointOffSet.y );
+ return { position.x, position.y, size.x, size.y };
+}
+
bool Actor::GetCachedPropertyValue( Property::Index index, Property::Value& value ) const
{
bool valueSet = true;
break;
}
- case Dali::Actor::Property::POSITION_INHERITANCE:
- {
- value = Scripting::GetLinearEnumerationName< PositionInheritanceMode >( GetPositionInheritanceMode(), POSITION_INHERITANCE_MODE_TABLE, POSITION_INHERITANCE_MODE_TABLE_COUNT );
- break;
- }
-
case Dali::Actor::Property::DRAW_MODE:
{
value = Scripting::GetEnumerationName< DrawMode::Type >( GetDrawMode(), DRAW_MODE_TABLE, DRAW_MODE_TABLE_COUNT );
{
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 )