Updated visuals to separate alpha channel from mixColor
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / internal / visuals / wireframe / wireframe-visual.cpp
index 396f13b..764ba27 100644 (file)
@@ -20,7 +20,7 @@
 #include "wireframe-visual.h"
 
 // INTERNAL INCLUDES
-#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-factory-impl.h>
 #include <dali-toolkit/internal/visuals/visual-factory-cache.h>
 #include <dali-toolkit/internal/visuals/visual-string-constants.h>
@@ -67,57 +67,108 @@ void main()\n
 );
 
 const char* FRAGMENT_SHADER = DALI_COMPOSE_SHADER(\n
-uniform lowp vec4 uColor;\n
+  uniform lowp vec4 uColor;\n
+  uniform lowp vec3 mixColor;\n
+  uniform lowp float opacity;\n
 \n
 void main()\n
 {\n
-  gl_FragColor = uColor;\n
+  gl_FragColor = uColor * vec4( mixColor, opacity );\n
 }\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 );
 }
 
-WireframeVisual::~WireframeVisual()
+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;
 }
 
-void WireframeVisual::DoSetProperties( const Property::Map& propertyMap )
+WireframeVisual::WireframeVisual( VisualFactoryCache& factoryCache, Visual::BasePtr actualVisual )
+: Visual::Base( factoryCache ),
+  mActualVisual( actualVisual )
 {
-  // no properties supported at the moment
 }
 
-void WireframeVisual::DoSetOnStage( Actor& actor )
+WireframeVisual::~WireframeVisual()
 {
-  InitializeRenderer();
+}
 
-  actor.AddRenderer( mImpl->mRenderer );
+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
 {
-  map.Clear();
-  map.Insert( Toolkit::VisualProperty::TYPE, Toolkit::Visual::WIREFRAME );
+  if( mActualVisual )
+  {
+    mActualVisual->CreatePropertyMap( map );
+  }
+  else
+  {
+    map.Clear();
+    map.Insert( Toolkit::DevelVisual::Property::TYPE, Toolkit::Visual::WIREFRAME );
+  }
 }
 
-void WireframeVisual::DoSetProperty( Dali::Property::Index index, const Dali::Property::Value& propertyValue )
+void WireframeVisual::DoSetProperties( const Property::Map& propertyMap )
 {
-  // TODO
+  Property::Value* mixValue = propertyMap.Find( Toolkit::DevelVisual::Property::MIX_COLOR, MIX_COLOR );
+  if( mixValue )
+  {
+    Vector4 mixColor;
+    mixValue->Get( mixColor );
+    SetMixColor( mixColor );
+  }
 }
 
-Dali::Property::Value WireframeVisual::DoGetProperty( Dali::Property::Index index )
+void WireframeVisual::DoSetOnStage( Actor& actor )
 {
-  // TODO
-  return Dali::Property::Value();
+  InitializeRenderer();
+
+  actor.AddRenderer( mImpl->mRenderer );
 }
 
 void WireframeVisual::InitializeRenderer()