/*
- * Copyright (c) 2015 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2016 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/integration-api/debug.h>
//INTERNAL HEARDER
+#include <dali-toolkit/public-api/visuals/visual-properties.h>
#include <dali-toolkit/internal/visuals/visual-base-data-impl.h>
-
-namespace
-{
-//custom shader
-const char * const CUSTOM_SHADER( "shader" );
-const char * const CUSTOM_VERTEX_SHADER( "vertexShader" );
-const char * const CUSTOM_FRAGMENT_SHADER( "fragmentShader" );
-const char * const CUSTOM_SUBDIVIDE_GRID_X( "subdivideGridX" );
-const char * const CUSTOM_SUBDIVIDE_GRID_Y( "subdivideGridY" );
-const char * const CUSTOM_SHADER_HINTS( "hints" ); ///< type INTEGER; (bitfield) values from enum Shader::Hint
-}
+#include <dali-toolkit/internal/visuals/visual-string-constants.h>
namespace Dali
{
namespace Internal
{
-namespace Visual
-{
-
-Base::Base( VisualFactoryCache& factoryCache )
+Visual::Base::Base( VisualFactoryCache& factoryCache )
: mImpl( new Impl() ),
mFactoryCache( factoryCache )
{
}
-Base::~Base()
+Visual::Base::~Base()
{
delete mImpl;
}
-void Base::SetCustomShader( const Property::Map& shaderMap )
+void Visual::Base::SetCustomShader( const Property::Map& shaderMap )
{
if( mImpl->mCustomShader )
{
}
else
{
- mImpl->mCustomShader = new Impl::CustomShader( shaderMap );
+ mImpl->mCustomShader = new Impl::CustomShader( shaderMap );
}
}
-void Base::Initialize( Actor& actor, const Property::Map& propertyMap )
+void Visual::Base::Initialize( Actor& actor, const Property::Map& propertyMap )
{
- Property::Value* customShaderValue = propertyMap.Find( CUSTOM_SHADER );
+ Property::Value* customShaderValue = propertyMap.Find( Toolkit::Visual::Property::SHADER, CUSTOM_SHADER );
if( customShaderValue )
{
Property::Map shaderMap;
DoInitialize( actor, propertyMap );
}
-void Base::SetSize( const Vector2& size )
+void Visual::Base::SetName( const std::string& name )
{
- mImpl->mSize = size;
+ mImpl->mName = name;
}
-const Vector2& Base::GetSize() const
+const std::string& Visual::Base::GetName()
{
- return mImpl->mSize;
+ return mImpl->mName;
}
-void Base::GetNaturalSize( Vector2& naturalSize ) const
+void Visual::Base::SetSize( const Vector2& size )
{
- naturalSize = Vector2::ZERO;
+ mImpl->mSize = size;
}
-void Base::SetClipRect( const Rect<int>& clipRect )
+const Vector2& Visual::Base::GetSize() const
{
+ return mImpl->mSize;
}
-void Base::SetOffset( const Vector2& offset )
+void Visual::Base::GetNaturalSize( Vector2& naturalSize ) const
{
- mImpl->mOffset = offset;
+ naturalSize = Vector2::ZERO;
}
-void Base::SetDepthIndex( float index )
+void Visual::Base::SetDepthIndex( float index )
{
mImpl->mDepthIndex = index;
if( mImpl->mRenderer )
}
}
-float Base::GetDepthIndex() const
+float Visual::Base::GetDepthIndex() const
{
return mImpl->mDepthIndex;
}
-void Base::SetOnStage( Actor& actor )
+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 Base::SetOffStage( Actor& actor )
+void Visual::Base::SetOffStage( Actor& actor )
{
if( GetIsOnStage() )
{
}
}
-void Base::EnablePreMultipliedAlpha( bool preMultipled )
+void Visual::Base::EnablePreMultipliedAlpha( bool preMultipled )
{
if(preMultipled)
{
}
}
-bool Base::IsPreMultipliedAlphaEnabled() const
+bool Visual::Base::IsPreMultipliedAlphaEnabled() const
{
return mImpl->mFlags & Impl::IS_PREMULTIPLIED_ALPHA;
}
-void Base::DoSetOnStage( Actor& actor )
-{
-}
-
-void Base::DoSetOffStage( Actor& actor )
+void Visual::Base::DoSetOffStage( Actor& actor )
{
actor.RemoveRenderer( mImpl->mRenderer );
mImpl->mRenderer.Reset();
}
-void Base::CreatePropertyMap( Property::Map& map ) const
+void Visual::Base::CreatePropertyMap( Property::Map& map ) const
{
DoCreatePropertyMap( map );
}
}
-bool Base::GetIsOnStage() const
+bool Visual::Base::GetIsOnStage() const
{
return mImpl->mFlags & Impl::IS_ON_STAGE;
}
-bool Base::GetIsFromCache() const
+bool Visual::Base::GetIsFromCache() const
{
return mImpl->mFlags & Impl::IS_FROM_CACHE;
}
-} // namespace Visual
+void Visual::Base::SetProperty( Dali::Property::Index index, const Dali::Property::Value& propertyValue )
+{
+ 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 );
+ }
+}
+
+Dali::Property::Value Visual::Base::GetProperty( Dali::Property::Index index )
+{
+ 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