X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=blobdiff_plain;f=dali-toolkit%2Finternal%2Fvisuals%2Fvisual-base-impl.cpp;h=86d2114168ce11740c628c6b7dbc6f56cd9bcfe0;hp=58e4d38f10d85b9ad8842daf4ab6080cd1a79cda;hb=63f9b5207c2794cdc460d587723be89585872a51;hpb=92a400c3857fbf6c1e63693f22c94dcffe50e522 diff --git a/dali-toolkit/internal/visuals/visual-base-impl.cpp b/dali-toolkit/internal/visuals/visual-base-impl.cpp index 58e4d38..86d2114 100644 --- a/dali-toolkit/internal/visuals/visual-base-impl.cpp +++ b/dali-toolkit/internal/visuals/visual-base-impl.cpp @@ -84,6 +84,11 @@ const Vector2& Visual::Base::GetSize() const return mImpl->mSize; } +float Visual::Base::GetHeightForWidth( float width ) const +{ + return 0.f; +} + void Visual::Base::GetNaturalSize( Vector2& naturalSize ) const { naturalSize = Vector2::ZERO; @@ -105,18 +110,18 @@ float Visual::Base::GetDepthIndex() const void Visual::Base::SetOnStage( Actor& actor ) { + // To display the actor correctly, renderer should not be added to actor until all required resources are ready. + // Thus the calling of actor.AddRenderer() should happen inside derived class as base class does not know the exact timing. DoSetOnStage( actor ); mImpl->mRenderer.SetProperty(Renderer::Property::BLEND_PRE_MULTIPLIED_ALPHA, IsPreMultipliedAlphaEnabled()); mImpl->mRenderer.SetProperty( Renderer::Property::DEPTH_INDEX, mImpl->mDepthIndex ); - actor.AddRenderer( mImpl->mRenderer ); - mImpl->mFlags |= Impl::IS_ON_STAGE; } void Visual::Base::SetOffStage( Actor& actor ) { - if( GetIsOnStage() ) + if( IsOnStage() ) { DoSetOffStage( actor ); @@ -124,6 +129,16 @@ void Visual::Base::SetOffStage( Actor& actor ) } } +void Visual::Base::CreatePropertyMap( Property::Map& map ) const +{ + DoCreatePropertyMap( map ); + + if( mImpl->mCustomShader ) + { + mImpl->mCustomShader->CreatePropertyMap( map ); + } +} + void Visual::Base::EnablePreMultipliedAlpha( bool preMultipled ) { if(preMultipled) @@ -146,34 +161,56 @@ bool Visual::Base::IsPreMultipliedAlphaEnabled() const return mImpl->mFlags & Impl::IS_PREMULTIPLIED_ALPHA; } -void Visual::Base::DoSetOnStage( Actor& actor ) -{ -} - void Visual::Base::DoSetOffStage( Actor& actor ) { actor.RemoveRenderer( mImpl->mRenderer ); mImpl->mRenderer.Reset(); } -void Visual::Base::CreatePropertyMap( Property::Map& map ) const +bool Visual::Base::IsOnStage() const { - DoCreatePropertyMap( map ); + return mImpl->mFlags & Impl::IS_ON_STAGE; +} - if( mImpl->mCustomShader ) - { - mImpl->mCustomShader->CreatePropertyMap( map ); - } +bool Visual::Base::IsFromCache() const +{ + return mImpl->mFlags & Impl::IS_FROM_CACHE; } -bool Visual::Base::GetIsOnStage() const +void Visual::Base::SetProperty( Dali::Property::Index index, const Dali::Property::Value& propertyValue ) { - return mImpl->mFlags & Impl::IS_ON_STAGE; + DALI_ASSERT_ALWAYS( ( index > Property::INVALID_INDEX ) && + ( index > VISUAL_PROPERTY_BASE_START_INDEX ) && // Change the type of visual is not allowed. + "Property index is out of bounds" ); + + if( index < VISUAL_PROPERTY_START_INDEX ) + { + // TODO set the properties of the visual base. + } + else + { + DoSetProperty( index, propertyValue ); + } } -bool Visual::Base::GetIsFromCache() const +Dali::Property::Value Visual::Base::GetProperty( Dali::Property::Index index ) { - return mImpl->mFlags & Impl::IS_FROM_CACHE; + DALI_ASSERT_ALWAYS( ( index > Property::INVALID_INDEX ) && + ( index >= VISUAL_PROPERTY_BASE_START_INDEX ) && + "Property index is out of bounds" ); + + Dali::Property::Value value; + + if( index < VISUAL_PROPERTY_START_INDEX ) + { + // TODO retrieve the properties of the visual base. + } + else + { + value = DoGetProperty( index ); + } + + return value; } } // namespace Internal