/*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2018 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.
namespace
{
-typedef Dali::Layer::Behavior Behavior;
-DALI_ENUM_TO_STRING_TABLE_BEGIN( Behavior )
-DALI_ENUM_TO_STRING( Dali::Layer::LAYER_2D )
-DALI_ENUM_TO_STRING( Dali::Layer::LAYER_3D )
-DALI_ENUM_TO_STRING_TABLE_END( Behavior )
+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_3D )
+DALI_ENUM_TO_STRING_TABLE_END( BEHAVIOR )
+
} // namespace
namespace Internal
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
- SceneGraph::Layer* layer = static_cast<SceneGraph::Layer*>( root->CreateNode() );
- InstallRootMessage( manager, *layer, systemLevel ); // Transfer ownership to scene-graph
-
- // Keep a raw pointer to the layer node.
- root->mNode = layer;
+ // Second-phase construction, keep a raw pointer to the layer node.
+ SceneGraph::Layer* rootLayer = static_cast<SceneGraph::Layer*>( root->CreateNode() );
+ root->mNode = rootLayer;
+ OwnerPointer< SceneGraph::Layer > transferOwnership( rootLayer );
+ InstallRootMessage( manager, transferOwnership );
// 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 ),
- mLayerList(NULL),
- mClippingBox(0,0,0,0),
- mSortFunction(Layer::ZValue),
- mBehavior(Dali::Layer::LAYER_2D),
- mIsClipping(false),
- mDepthTestDisabled(false),
- mTouchConsumed(false),
- mHoverConsumed(false)
+ mLayerList( NULL ),
+ mClippingBox( 0, 0, 0, 0 ),
+ mSortFunction( Layer::ZValue ),
+ mBehavior( Dali::Layer::LAYER_2D ),
+ mIsClipping( false ),
+ mDepthTestDisabled( true ),
+ mTouchConsumed( false ),
+ mHoverConsumed( false )
{
}
if( ( this != &target ) && OnStage() && target.OnStage() )
{
// get parameters depth
- const unsigned int targetDepth = target.GetDepth();
+ const uint32_t targetDepth = target.GetDepth();
if( GetDepth() < targetDepth )
{
MoveAbove( target );
if( ( this != &target ) && OnStage() && target.OnStage() )
{
// get parameters depth
- const unsigned int targetDepth = target.GetDepth();
+ const uint32_t targetDepth = target.GetDepth();
if( GetDepth() > targetDepth )
{
MoveBelow( target );
{
mBehavior = behavior;
- // notify update side object
+ // 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 );
}
void Layer::SetClipping(bool enabled)
StagePtr stage = Stage::GetCurrent();
if( stage )
{
- clippingBox.y = stage->GetSize().height - clippingBox.y - clippingBox.height;
+ clippingBox.y = static_cast<int32_t>( stage->GetSize().height ) - clippingBox.y - clippingBox.height;
// layerNode is being used in a separate thread; queue a message to set the value
SetClippingBoxMessage( GetEventThreadServices(), GetSceneLayerOnStage(), clippingBox );
{
mDepthTestDisabled = disable;
- // Send message .....
+ // Send message.
// layerNode is being used in a separate thread; queue a message to set the value
SetDepthTestDisabledMessage( GetEventThreadServices(), GetSceneLayerOnStage(), mDepthTestDisabled );
}
bool Layer::IsDepthTestDisabled() const
{
- return mDepthTestDisabled || (mBehavior == Dali::Layer::LAYER_2D);
+ return mDepthTestDisabled;
}
void Layer::SetSortFunction(Dali::Layer::SortFunctionType function)
SceneGraph::Node* Layer::CreateNode() const
{
- return SceneGraph::Layer::New();
+ return SceneGraph::Layer::New( mId );
}
void Layer::OnStageConnectionInternal()
Actor::GetDefaultPropertyIndices( indices ); // Actor class properties
indices.Reserve( indices.Size() + DEFAULT_PROPERTY_COUNT );
- int index = DEFAULT_DERIVED_ACTOR_PROPERTY_START_INDEX;
- for ( int i = 0; i < DEFAULT_PROPERTY_COUNT; ++i, ++index )
+ int32_t index = DEFAULT_DERIVED_ACTOR_PROPERTY_START_INDEX;
+ for ( int32_t i = 0; i < DEFAULT_PROPERTY_COUNT; ++i, ++index )
{
indices.PushBack( index );
}
Property::Index index = Property::INVALID_INDEX;
// Look for name in current class' default properties
- for( int i = 0; i < DEFAULT_PROPERTY_COUNT; ++i )
+ 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
}
case Dali::Layer::Property::CLIPPING_BOX:
{
- Rect<int> clippingBox( propertyValue.Get<Rect<int> >() );
+ Rect<int32_t> clippingBox( propertyValue.Get<Rect<int32_t> >() );
SetClippingBox( clippingBox.x, clippingBox.y, clippingBox.width, clippingBox.height );
break;
}
case Dali::Layer::Property::BEHAVIOR:
{
Behavior behavior(Dali::Layer::LAYER_2D);
- if( Scripting::GetEnumeration< Behavior >( propertyValue.Get< std::string >().c_str(), BehaviorTable, BehaviorTableCount, behavior ) )
+ if( Scripting::GetEnumeration< Behavior >( propertyValue.Get< std::string >().c_str(), BEHAVIOR_TABLE, BEHAVIOR_TABLE_COUNT, behavior ) )
{
SetBehavior( behavior );
}
}
case Dali::Layer::Property::BEHAVIOR:
{
- ret = Scripting::GetLinearEnumerationName< Behavior >( GetBehavior(), BehaviorTable, BehaviorTableCount );
+ ret = Scripting::GetLinearEnumerationName< Behavior >( GetBehavior(), BEHAVIOR_TABLE, BEHAVIOR_TABLE_COUNT );
break;
}
default:
return ret;
}
+Property::Value Layer::GetDefaultPropertyCurrentValue( Property::Index index ) const
+{
+ Property::Value ret;
+ if( index < DEFAULT_ACTOR_PROPERTY_MAX_COUNT )
+ {
+ ret = Actor::GetDefaultPropertyCurrentValue( index );
+ }
+ else
+ {
+ ret = GetDefaultProperty( index ); // Layer only has event-side properties
+ }
+
+ return ret;
+}
+
bool Layer::DoAction( BaseObject* object, const std::string& actionName, const Property::Map& /*attributes*/ )
{
bool done = false;