X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=dali%2Finternal%2Fevent%2Factors%2Flayer-impl.cpp;h=e3c0bea717c9fad3bb26bfe4fa52d5c52bb7c0e0;hb=647f5b051fe0930336dd202bd41084201c5de6b9;hp=990ed78f1cd20cb20fcd3f8c200db9b7d25d2fbf;hpb=6e7f48188a239b060512231cc6acbe821c703caa;p=platform%2Fcore%2Fuifw%2Fdali-core.git diff --git a/dali/internal/event/actors/layer-impl.cpp b/dali/internal/event/actors/layer-impl.cpp index 990ed78..e3c0bea 100644 --- a/dali/internal/event/actors/layer-impl.cpp +++ b/dali/internal/event/actors/layer-impl.cpp @@ -1,5 +1,5 @@ /* - * 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. @@ -35,12 +35,14 @@ namespace Dali 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 @@ -53,24 +55,24 @@ namespace // Name Type writable animatable constraint-input enum for index-checking DALI_PROPERTY_TABLE_BEGIN -DALI_PROPERTY( "clipping-enable", BOOLEAN, true, false, true, Dali::Layer::Property::CLIPPING_ENABLE ) -DALI_PROPERTY( "clipping-box", RECTANGLE, true, false, true, Dali::Layer::Property::CLIPPING_BOX ) +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 const char* const ACTION_RAISE = "raise"; const char* const ACTION_LOWER = "lower"; -const char* const ACTION_RAISE_TO_TOP = "raise-to-top"; -const char* const ACTION_LOWER_TO_BOTTOM = "lower-to-bottom"; +const char* const ACTION_RAISE_TO_TOP = "raiseToTop"; +const char* const ACTION_LOWER_TO_BOTTOM = "lowerToBottom"; BaseHandle Create() { 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 ); @@ -90,16 +92,15 @@ LayerPtr Layer::New() 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( 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( 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; @@ -109,6 +110,7 @@ LayerPtr Layer::NewRoot( LayerList& layerList, UpdateManager& manager, bool syst // layer-list must be set for the root layer root->mLayerList = &layerList; + layerList.SetRootLayer( &(*root) ); layerList.RegisterLayer( *root ); return root; @@ -116,13 +118,14 @@ LayerPtr Layer::NewRoot( LayerList& layerList, UpdateManager& manager, bool syst Layer::Layer( Actor::DerivedType type ) : Actor( type ), - mLayerList(NULL), - mClippingBox(0,0,0,0), - mSortFunction(Layer::ZValue), - 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 ) { } @@ -161,7 +164,7 @@ void Layer::RaiseAbove( const Internal::Layer& 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 ) { MoveAbove( target ); @@ -175,7 +178,7 @@ void Layer::LowerBelow( const Internal::Layer& 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 ); @@ -221,8 +224,10 @@ void Layer::SetBehavior( Dali::Layer::Behavior behavior ) { 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) @@ -252,7 +257,7 @@ void Layer::SetClippingBox(int x, int y, int width, int height) StagePtr stage = Stage::GetCurrent(); if( stage ) { - clippingBox.y = stage->GetSize().height - clippingBox.y - clippingBox.height; + clippingBox.y = static_cast( 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 ); @@ -266,7 +271,7 @@ void Layer::SetDepthTestDisabled( bool disable ) { 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 ); } @@ -274,7 +279,7 @@ void Layer::SetDepthTestDisabled( bool disable ) bool Layer::IsDepthTestDisabled() const { - return mDepthTestDisabled || (mBehavior == Dali::Layer::LAYER_2D); + return mDepthTestDisabled; } void Layer::SetSortFunction(Dali::Layer::SortFunctionType function) @@ -310,7 +315,7 @@ bool Layer::IsHoverConsumed() const SceneGraph::Node* Layer::CreateNode() const { - return SceneGraph::Layer::New(); + return SceneGraph::Layer::New( mId ); } void Layer::OnStageConnectionInternal() @@ -349,110 +354,6 @@ const SceneGraph::Layer& Layer::GetSceneLayerOnStage() const 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 ); - - int index = DEFAULT_DERIVED_ACTOR_PROPERTY_START_INDEX; - for ( int 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( int 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; -} - void Layer::SetDefaultProperty( Property::Index index, const Property::Value& propertyValue ) { if( index < DEFAULT_ACTOR_PROPERTY_MAX_COUNT ) @@ -470,14 +371,14 @@ void Layer::SetDefaultProperty( Property::Index index, const Property::Value& pr } case Dali::Layer::Property::CLIPPING_BOX: { - Rect clippingBox( propertyValue.Get >() ); + Rect clippingBox( propertyValue.Get >() ); 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 ); } @@ -516,7 +417,7 @@ Property::Value Layer::GetDefaultProperty( Property::Index index ) const } case Dali::Layer::Property::BEHAVIOR: { - ret = Scripting::GetLinearEnumerationName< Behavior >( GetBehavior(), BehaviorTable, BehaviorTableCount ); + ret = Scripting::GetLinearEnumerationName< Behavior >( GetBehavior(), BEHAVIOR_TABLE, BEHAVIOR_TABLE_COUNT ); break; } default: @@ -530,6 +431,21 @@ Property::Value Layer::GetDefaultProperty( Property::Index index ) const 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;