Wireframe visual provides correct natural size in debug rendering
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / internal / visuals / wireframe / wireframe-visual.cpp
index 52a7710..5fd3160 100644 (file)
@@ -77,13 +77,36 @@ void main()\n
 
 }
 
-WireframeVisualPtr WireframeVisual::New( VisualFactoryCache& factoryCache )
+WireframeVisualPtr WireframeVisual::New( VisualFactoryCache& factoryCache, const Property::Map& properties )
 {
-  return new WireframeVisual( factoryCache );
+  Visual::BasePtr emtptyVisual;
+
+  return New(factoryCache, emtptyVisual, properties);
 }
 
-WireframeVisual::WireframeVisual( VisualFactoryCache& factoryCache )
-: Visual::Base( factoryCache )
+WireframeVisualPtr WireframeVisual::New( VisualFactoryCache& factoryCache, Visual::BasePtr actualVisual )
+{
+  return new WireframeVisual( factoryCache, actualVisual );
+}
+
+WireframeVisualPtr WireframeVisual::New( VisualFactoryCache& factoryCache, Visual::BasePtr actualVisual, const Property::Map& properties )
+{
+  WireframeVisualPtr wireframeVisual( new WireframeVisual( factoryCache, actualVisual ) );
+
+  // Instead of calling SetProperties, looking for the only valid property 'transform'
+  Property::Value* transformValue = properties.Find( DevelVisual::Property::TRANSFORM, TRANSFORM );
+  Property::Map transformMap;
+  if( transformValue && transformValue->Get( transformMap ) )
+  {
+    wireframeVisual->SetTransformAndSize( transformMap, Vector2::ZERO );
+  }
+
+  return wireframeVisual;
+}
+
+WireframeVisual::WireframeVisual( VisualFactoryCache& factoryCache, Visual::BasePtr actualVisual )
+: Visual::Base( factoryCache ),
+  mActualVisual( actualVisual )
 {
 }
 
@@ -91,6 +114,43 @@ WireframeVisual::~WireframeVisual()
 {
 }
 
+float WireframeVisual::GetHeightForWidth( float width )
+{
+  if( mActualVisual )
+  {
+    return mActualVisual->GetHeightForWidth( width );
+  }
+  else
+  {
+    return Visual::Base::GetHeightForWidth( width );
+  }
+}
+
+void WireframeVisual::GetNaturalSize( Vector2& naturalSize )
+{
+  if( mActualVisual )
+  {
+    mActualVisual->GetNaturalSize( naturalSize );
+  }
+  else
+  {
+    Visual::Base::GetNaturalSize( naturalSize );
+  }
+}
+
+void WireframeVisual::DoCreatePropertyMap( Property::Map& map ) const
+{
+  if( mActualVisual )
+  {
+    mActualVisual->CreatePropertyMap( map );
+  }
+  else
+  {
+    map.Clear();
+    map.Insert( Toolkit::DevelVisual::Property::TYPE, Toolkit::Visual::WIREFRAME );
+  }
+}
+
 void WireframeVisual::DoSetProperties( const Property::Map& propertyMap )
 {
   // no properties supported at the moment
@@ -103,12 +163,6 @@ void WireframeVisual::DoSetOnStage( Actor& actor )
   actor.AddRenderer( mImpl->mRenderer );
 }
 
-void WireframeVisual::DoCreatePropertyMap( Property::Map& map ) const
-{
-  map.Clear();
-  map.Insert( Toolkit::DevelVisual::Property::TYPE, Toolkit::Visual::WIREFRAME );
-}
-
 void WireframeVisual::InitializeRenderer()
 {
   Shader shader = mFactoryCache.GetShader( VisualFactoryCache::WIREFRAME_SHADER );