#include <dali/integration-api/debug.h>
//INTERNAL HEARDER
-#include <dali-toolkit/devel-api/visual-factory/devel-visual-properties.h>
+#include <dali-toolkit/devel-api/visuals/visual-properties-devel.h>
#include <dali-toolkit/internal/visuals/visual-base-data-impl.h>
#include <dali-toolkit/internal/visuals/visual-string-constants.h>
+namespace
+{
+#if defined(DEBUG_ENABLED)
+Debug::Filter* gVisualBaseLogFilter = Debug::Filter::New( Debug::NoLogging, false, "LOG_VISUAL_BASE" );
+#endif
+}
+
namespace Dali
{
void Visual::Base::SetProperties( const Property::Map& propertyMap )
{
- Property::Value* customShaderValue = propertyMap.Find( VisualProperty::SHADER, CUSTOM_SHADER );
- if( customShaderValue )
+ for( size_t i = 0; i < propertyMap.Count(); ++i )
{
- Property::Map shaderMap;
- if( customShaderValue->Get( shaderMap ) )
+ const KeyValuePair& pair = propertyMap.GetKeyValue( i );
+ const Property::Key& key = pair.first;
+ const Property::Value& value = pair.second;
+ switch( key.indexKey )
{
- SetCustomShader( shaderMap );
- }
- }
-
- Property::Value* transform = propertyMap.Find( Toolkit::Visual::DevelProperty::TRANSFORM, TRANSFORM );
- if( transform )
- {
- Property::Map map;
- if( transform->Get( map ) )
- {
- mImpl->mTransform.SetPropertyMap( map );
+ case DevelVisual::Property::SHADER:
+ {
+ Property::Map shaderMap;
+ if( value.Get( shaderMap ) )
+ {
+ SetCustomShader( shaderMap );
+ }
+ break;
+ }
+
+ case DevelVisual::Property::TRANSFORM:
+ {
+ Property::Map map;
+ if( value.Get( map ) )
+ {
+ mImpl->mTransform.SetPropertyMap( map );
+ }
+ break;
+ }
+
+ case DevelVisual::Property::PREMULTIPLIED_ALPHA:
+ {
+ bool premultipliedAlpha = false;
+ if( value.Get( premultipliedAlpha ) )
+ {
+ EnablePreMultipliedAlpha( premultipliedAlpha );
+ }
+ break;
+ }
}
}
{
mImpl->mControlSize = controlSize;
mImpl->mTransform.SetPropertyMap( transform );
+
+#if defined(DEBUG_ENABLED)
+ std::ostringstream oss;
+ oss << transform;
+ DALI_LOG_INFO( gVisualBaseLogFilter, Debug::General, "Visual::Base::SetTransformAndSize(%s) - [\e[1;32mtransform: %s controlSize: (%3.1f, %3.1f)]\e[0m\n",
+ GetName().c_str(), oss.str().c_str(), controlSize.x, controlSize.y );
+#endif
+
OnSetTransform();
}
return mImpl->mName;
}
-float Visual::Base::GetHeightForWidth( float width ) const
+float Visual::Base::GetHeightForWidth( float width )
{
- return 0.f;
+ float aspectCorrectedHeight = 0.f;
+ Vector2 naturalSize;
+ GetNaturalSize( naturalSize );
+ if( naturalSize.width )
+ {
+ aspectCorrectedHeight = naturalSize.height * width / naturalSize.width;
+ }
+ return aspectCorrectedHeight;
+}
+
+float Visual::Base::GetWidthForHeight( float height )
+{
+ float aspectCorrectedWidth = 0.f;
+ Vector2 naturalSize;
+ GetNaturalSize( naturalSize );
+ if( naturalSize.height > 0.0f )
+ {
+ aspectCorrectedWidth = naturalSize.width * height / naturalSize.height;
+ }
+ return aspectCorrectedWidth;
}
void Visual::Base::GetNaturalSize( Vector2& naturalSize )
Property::Map transform;
mImpl->mTransform.GetPropertyMap( transform );
- map.Insert( Toolkit::Visual::DevelProperty::TRANSFORM, transform );
+ map.Insert( DevelVisual::Property::TRANSFORM, transform );
+
+ bool premultipliedAlpha( IsPreMultipliedAlphaEnabled() );
+ map.Insert( DevelVisual::Property::PREMULTIPLIED_ALPHA, premultipliedAlpha );
}
void Visual::Base::EnablePreMultipliedAlpha( bool preMultipled )
{
- if(preMultipled)
+ if( preMultipled )
{
mImpl->mFlags |= Impl::IS_PREMULTIPLIED_ALPHA;
}
return mImpl->mFlags & Impl::IS_FROM_CACHE;
}
+Renderer Visual::Base::GetRenderer()
+{
+ return mImpl->mRenderer;
+}
+
} // namespace Internal
} // namespace Toolkit