/*
- * Copyright (c) 2016 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2018 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 "wireframe-visual.h"
// INTERNAL INCLUDES
-#include <dali-toolkit/devel-api/visual-factory/devel-visual-properties.h>
+#include <dali-toolkit/public-api/visuals/visual-properties.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>
);
const char* FRAGMENT_SHADER = DALI_COMPOSE_SHADER(\n
-uniform lowp vec4 uColor;\n
+ uniform lowp vec4 uColor;\n
+ uniform lowp vec3 mixColor;\n
\n
void main()\n
{\n
- gl_FragColor = uColor;\n
+ gl_FragColor = uColor * vec4( mixColor, 1.0 );\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( Toolkit::Visual::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, Visual::FittingMode::FILL ),
+ 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::Visual::Property::TYPE, Toolkit::Visual::WIREFRAME );
+ }
}
-void WireframeVisual::DoSetProperty( Dali::Property::Index index, const Dali::Property::Value& propertyValue )
+void WireframeVisual::DoCreateInstancePropertyMap( Property::Map& map ) const
{
- // TODO
+ // Do nothing
+}
+
+void WireframeVisual::DoSetProperties( const Property::Map& propertyMap )
+{
+ Property::Value* mixValue = propertyMap.Find( Toolkit::Visual::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 );
+
+ // Wireframe generated and ready to display
+ ResourceReady( Toolkit::Visual::ResourceStatus::READY );
}
void WireframeVisual::InitializeRenderer()
}
}
+Visual::Base& WireframeVisual::GetVisualObject()
+{
+ if( mActualVisual )
+ {
+ return *mActualVisual.Get();
+ }
+
+ return *this;
+}
+
} // namespace Internal
} // namespace Toolkit