typedef Layer::Behavior Behavior;
DALI_ENUM_TO_STRING_TABLE_BEGIN( BEHAVIOR )
-DALI_ENUM_TO_STRING_WITH_SCOPE( Layer, LAYER_2D )
+DALI_ENUM_TO_STRING_WITH_SCOPE( Layer, LAYER_UI )
DALI_ENUM_TO_STRING_WITH_SCOPE( Layer, LAYER_3D )
DALI_ENUM_TO_STRING_TABLE_END( BEHAVIOR )
DALI_PROPERTY( "clippingEnable", BOOLEAN, true, false, true, Dali::Layer::Property::CLIPPING_ENABLE )
DALI_PROPERTY( "clippingBox", RECTANGLE, true, false, true, Dali::Layer::Property::CLIPPING_BOX )
DALI_PROPERTY( "behavior", STRING, true, false, false, Dali::Layer::Property::BEHAVIOR )
-DALI_PROPERTY_TABLE_END( DEFAULT_DERIVED_ACTOR_PROPERTY_START_INDEX )
+DALI_PROPERTY_TABLE_END( DEFAULT_DERIVED_ACTOR_PROPERTY_START_INDEX, LayerDefaultProperties )
// Actions
return Dali::Layer::New();
}
-TypeRegistration mType( typeid( Dali::Layer ), typeid( Dali::Actor ), Create );
+TypeRegistration mType( typeid( Dali::Layer ), typeid( Dali::Actor ), Create, LayerDefaultProperties );
TypeAction a1( mType, ACTION_RAISE, &Layer::DoAction );
TypeAction a2( mType, ACTION_LOWER, &Layer::DoAction );
LayerPtr Layer::New()
{
- LayerPtr layer( new Layer( Actor::LAYER ) );
+ // create node, nodes are owned by UpdateManager
+ SceneGraph::Layer* layerNode = SceneGraph::Layer::New();
+ OwnerPointer< SceneGraph::Node > transferOwnership( layerNode );
+ AddNodeMessage( Stage::GetCurrent()->GetUpdateManager(), transferOwnership );
+ LayerPtr layer( new Layer( Actor::LAYER, *layerNode ) );
// Second-phase construction
layer->Initialize();
return layer;
}
-LayerPtr Layer::NewRoot( LayerList& layerList, UpdateManager& manager, bool systemLevel )
+LayerPtr Layer::NewRoot( LayerList& layerList, UpdateManager& manager )
{
- LayerPtr root( new Layer( Actor::ROOT_LAYER ) );
-
- // Second-phase construction, keep a raw pointer to the layer node.
- SceneGraph::Layer* rootLayer = static_cast<SceneGraph::Layer*>( root->CreateNode() );
- root->mNode = rootLayer;
+ // create node, nodes are owned by UpdateManager
+ SceneGraph::Layer* rootLayer = SceneGraph::Layer::New();
OwnerPointer< SceneGraph::Layer > transferOwnership( rootLayer );
- InstallRootMessage( manager, transferOwnership, systemLevel );
+ InstallRootMessage( manager, transferOwnership );
+
+ LayerPtr root( new Layer( Actor::ROOT_LAYER, *rootLayer ) );
// root actor is immediately considered to be on-stage
root->mIsOnStage = true;
// layer-list must be set for the root layer
root->mLayerList = &layerList;
+ layerList.SetRootLayer( &(*root) );
layerList.RegisterLayer( *root );
return root;
}
-Layer::Layer( Actor::DerivedType type )
-: Actor( type ),
+Layer::Layer( Actor::DerivedType type, const SceneGraph::Layer& layer )
+: Actor( type, layer ),
mLayerList( NULL ),
mClippingBox( 0, 0, 0, 0 ),
mSortFunction( Layer::ZValue ),
- mBehavior( Dali::Layer::LAYER_2D ),
+ mBehavior( Dali::Layer::LAYER_UI ),
mIsClipping( false ),
mDepthTestDisabled( true ),
mTouchConsumed( false ),
// Notify update side object.
SetBehaviorMessage( GetEventThreadServices(), GetSceneLayerOnStage(), behavior );
- // By default, disable depth test for LAYER_2D, and enable for LAYER_3D.
- SetDepthTestDisabled( mBehavior == Dali::Layer::LAYER_2D );
+ // By default, disable depth test for LAYER_UI, and enable for LAYER_3D.
+ SetDepthTestDisabled( mBehavior == Dali::Layer::LAYER_UI );
}
void Layer::SetClipping(bool enabled)
return mHoverConsumed;
}
-SceneGraph::Node* Layer::CreateNode() const
-{
- return SceneGraph::Layer::New( mId );
-}
-
void Layer::OnStageConnectionInternal()
{
if ( !mIsRoot )
const SceneGraph::Layer& Layer::GetSceneLayerOnStage() const
{
- DALI_ASSERT_DEBUG( mNode != NULL );
- return dynamic_cast< const SceneGraph::Layer& >( *mNode );
-}
-
-unsigned int Layer::GetDefaultPropertyCount() const
-{
- return Actor::GetDefaultPropertyCount() + DEFAULT_PROPERTY_COUNT;
-}
-
-void Layer::GetDefaultPropertyIndices( Property::IndexContainer& indices ) const
-{
- Actor::GetDefaultPropertyIndices( indices ); // Actor class properties
- indices.Reserve( indices.Size() + DEFAULT_PROPERTY_COUNT );
-
- int32_t index = DEFAULT_DERIVED_ACTOR_PROPERTY_START_INDEX;
- for ( int32_t i = 0; i < DEFAULT_PROPERTY_COUNT; ++i, ++index )
- {
- indices.PushBack( index );
- }
-}
-
-bool Layer::IsDefaultPropertyWritable( Property::Index index ) const
-{
- if( index < DEFAULT_ACTOR_PROPERTY_MAX_COUNT )
- {
- return Actor::IsDefaultPropertyWritable( index );
- }
-
- return DEFAULT_PROPERTY_DETAILS[ index - DEFAULT_DERIVED_ACTOR_PROPERTY_START_INDEX ].writable;
-}
-
-bool Layer::IsDefaultPropertyAnimatable( Property::Index index ) const
-{
- if( index < DEFAULT_ACTOR_PROPERTY_MAX_COUNT )
- {
- return Actor::IsDefaultPropertyAnimatable( index );
- }
-
- return DEFAULT_PROPERTY_DETAILS[ index - DEFAULT_DERIVED_ACTOR_PROPERTY_START_INDEX ].animatable;
-}
-
-bool Layer::IsDefaultPropertyAConstraintInput( Property::Index index ) const
-{
- if( index < DEFAULT_ACTOR_PROPERTY_MAX_COUNT )
- {
- return Actor::IsDefaultPropertyAConstraintInput( index );
- }
-
- return DEFAULT_PROPERTY_DETAILS[ index - DEFAULT_DERIVED_ACTOR_PROPERTY_START_INDEX ].constraintInput;
-}
-
-Property::Type Layer::GetDefaultPropertyType( Property::Index index ) const
-{
- if( index < DEFAULT_ACTOR_PROPERTY_MAX_COUNT )
- {
- return Actor::GetDefaultPropertyType( index );
- }
-
- index -= DEFAULT_DERIVED_ACTOR_PROPERTY_START_INDEX;
-
- if ( ( index >= 0 ) && ( index < DEFAULT_PROPERTY_COUNT ) )
- {
- return DEFAULT_PROPERTY_DETAILS[index].type;
- }
-
- // index out-of-bounds
- return Property::NONE;
-}
-
-const char* Layer::GetDefaultPropertyName( Property::Index index ) const
-{
- if( index < DEFAULT_ACTOR_PROPERTY_MAX_COUNT )
- {
- return Actor::GetDefaultPropertyName( index );
- }
-
- index -= DEFAULT_DERIVED_ACTOR_PROPERTY_START_INDEX;
- if ( ( index >= 0 ) && ( index < DEFAULT_PROPERTY_COUNT ) )
- {
- return DEFAULT_PROPERTY_DETAILS[index].name;
- }
-
- return NULL;
-}
-
-Property::Index Layer::GetDefaultPropertyIndex(const std::string& name) const
-{
- Property::Index index = Property::INVALID_INDEX;
-
- // Look for name in current class' default properties
- for( int32_t i = 0; i < DEFAULT_PROPERTY_COUNT; ++i )
- {
- const Internal::PropertyDetails* property = &DEFAULT_PROPERTY_DETAILS[i];
- if( 0 == name.compare( property->name ) ) // dont want to convert rhs to string
- {
- index = i + DEFAULT_DERIVED_ACTOR_PROPERTY_START_INDEX;
- break;
- }
- }
- if( Property::INVALID_INDEX == index )
- {
- // If not found, check in base class
- index = Actor::GetDefaultPropertyIndex( name );
- }
-
- return index;
+ return static_cast< const SceneGraph::Layer& >( GetNode() ); // we know our node is a layer node
}
void Layer::SetDefaultProperty( Property::Index index, const Property::Value& propertyValue )
}
case Dali::Layer::Property::BEHAVIOR:
{
- Behavior behavior(Dali::Layer::LAYER_2D);
+ Behavior behavior(Dali::Layer::LAYER_UI);
if( Scripting::GetEnumeration< Behavior >( propertyValue.Get< std::string >().c_str(), BEHAVIOR_TABLE, BEHAVIOR_TABLE_COUNT, behavior ) )
{
SetBehavior( behavior );