/*
- * 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.
// EXTERNAL INCLUDES
#include <dali/public-api/common/dali-common.h>
+#include <dali/devel-api/scripting/enum-helper.h>
+#include <dali/devel-api/scripting/scripting.h>
#include <dali/integration-api/debug.h>
-#include <dali/public-api/object/property-array.h>
+
+// INTERNAL INCLUDES
+#include <dali-toolkit/public-api/visuals/visual-properties.h>
+#include <dali-toolkit/internal/visuals/visual-string-constants.h>
namespace Dali
{
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 STRING for a hint from the below hint strings or an ARRAY of of hint strings
-
-/**
- * where hints should be contain strings of the following shader hints:
- * "none" | corresponds to Shader::Hint::NONE
- * "outputIsTransparent" | corresponds to Shader::Hint::OUTPUT_IS_TRANSPARENT
- * "modifiesGeometry" | corresponds to Shader::Hint::MODIFIES_GEOMETRY
- */
-Shader::Hint::Value HintFromString( std::string hintString )
-{
- if( hintString == "none" )
- {
- return Shader::Hint::NONE;
- }
- else if( hintString == "outputIsTransparent" )
- {
- return Shader::Hint::OUTPUT_IS_TRANSPARENT;
- }
- else if( hintString == "modifiesGeometry" )
- {
- return Shader::Hint::MODIFIES_GEOMETRY;
- }
- else
- {
- DALI_LOG_ERROR( "'%s' hint string is not recognised", hintString.c_str() );
- }
-
- return Shader::Hint::NONE;
-}
+DALI_ENUM_TO_STRING_TABLE_BEGIN( SHADER_HINT )
+DALI_ENUM_TO_STRING_WITH_SCOPE( Shader::Hint, NONE )
+DALI_ENUM_TO_STRING_WITH_SCOPE( Shader::Hint, OUTPUT_IS_TRANSPARENT )
+DALI_ENUM_TO_STRING_WITH_SCOPE( Shader::Hint, MODIFIES_GEOMETRY )
+DALI_ENUM_TO_STRING_TABLE_END( SHADER_HINT )
-}// unnamed namespace
+} // unnamed namespace
Internal::Visual::Base::Impl::Impl()
: mCustomShader(NULL),
mGridSize = ImageDimensions( 1, 1 );
mHints = Shader::Hint::NONE;
- Property::Value* vertexShaderValue = shaderMap.Find( CUSTOM_VERTEX_SHADER );
+ Property::Value* vertexShaderValue = shaderMap.Find( Toolkit::Visual::Shader::Property::VERTEX_SHADER, CUSTOM_VERTEX_SHADER );
if( vertexShaderValue )
{
if( !vertexShaderValue->Get( mVertexShader ) )
}
}
- Property::Value* fragmentShaderValue = shaderMap.Find( CUSTOM_FRAGMENT_SHADER );
+ Property::Value* fragmentShaderValue = shaderMap.Find( Toolkit::Visual::Shader::Property::FRAGMENT_SHADER, CUSTOM_FRAGMENT_SHADER );
if( fragmentShaderValue )
{
if( !fragmentShaderValue->Get( mFragmentShader ) )
}
}
- Property::Value* subdivideXValue = shaderMap.Find( CUSTOM_SUBDIVIDE_GRID_X );
+ Property::Value* subdivideXValue = shaderMap.Find( Toolkit::Visual::Shader::Property::SUBDIVIDE_GRID_X, CUSTOM_SUBDIVIDE_GRID_X );
if( subdivideXValue )
{
int subdivideX;
}
}
- Property::Value* subdivideYValue = shaderMap.Find( CUSTOM_SUBDIVIDE_GRID_Y );
+ Property::Value* subdivideYValue = shaderMap.Find( Toolkit::Visual::Shader::Property::SUBDIVIDE_GRID_Y, CUSTOM_SUBDIVIDE_GRID_Y );
if( subdivideYValue )
{
int subdivideY;
}
}
- Property::Value* hintsValue = shaderMap.Find( CUSTOM_SHADER_HINTS );
+ Property::Value* hintsValue = shaderMap.Find( Toolkit::Visual::Shader::Property::HINTS, CUSTOM_SHADER_HINTS );
if( hintsValue )
{
- std::string hintString;
- Property::Array hintsArray;
-
- if( hintsValue->Get( hintString ) )
- {
- mHints = HintFromString( hintString );
- }
- else if( hintsValue->Get( hintsArray ) )
- {
- int hints = Shader::Hint::NONE;
- for( Property::Array::SizeType i = 0; i < hintsArray.Count(); ++i)
- {
- Property::Value hintValue = hintsArray[ i ];
- if( hintValue.Get( hintString ) )
- {
- hints |= static_cast< int >( HintFromString( hintString ) );
- }
- else
- {
- DALI_LOG_ERROR( "'%s' parameter does not correctly specify an hint string at index %d", CUSTOM_SHADER_HINTS, i );
- }
-
- mHints = static_cast< Shader::Hint::Value >( hints );
- }
- }
- else
+ if ( ! Scripting::GetBitmaskEnumerationProperty( *hintsValue, SHADER_HINT_TABLE, SHADER_HINT_TABLE_COUNT, mHints ) )
{
- DALI_LOG_ERROR( "'%s' parameter does not correctly specify a hint string or an array of hint strings", CUSTOM_SHADER_HINTS );
+ DALI_LOG_ERROR( "'%s' parameter does not correctly specify a hint or an array of hint strings", CUSTOM_SHADER_HINTS );
}
}
}
Property::Map customShader;
if( !mVertexShader.empty() )
{
- customShader.Insert(CUSTOM_VERTEX_SHADER, mVertexShader );
+ customShader.Insert( Toolkit::Visual::Shader::Property::VERTEX_SHADER, mVertexShader );
}
if( !mFragmentShader.empty() )
{
- customShader.Insert(CUSTOM_FRAGMENT_SHADER, mFragmentShader );
+ customShader.Insert( Toolkit::Visual::Shader::Property::FRAGMENT_SHADER, mFragmentShader );
}
if( mGridSize.GetWidth() != 1 )
{
- customShader.Insert(CUSTOM_SUBDIVIDE_GRID_X, mGridSize.GetWidth() );
+ customShader.Insert( Toolkit::Visual::Shader::Property::SUBDIVIDE_GRID_X, mGridSize.GetWidth() );
}
if( mGridSize.GetHeight() != 1 )
{
- customShader.Insert(CUSTOM_SUBDIVIDE_GRID_Y, mGridSize.GetHeight() );
+ customShader.Insert( Toolkit::Visual::Shader::Property::SUBDIVIDE_GRID_Y, mGridSize.GetHeight() );
}
if( mHints != Dali::Shader::Hint::NONE )
{
- customShader.Insert(CUSTOM_SHADER_HINTS, static_cast< int >(mHints) );
+ customShader.Insert( Toolkit::Visual::Shader::Property::HINTS, static_cast< int >( mHints ) );
}
- map.Insert( CUSTOM_SHADER, customShader );
+ map.Insert( Toolkit::Visual::Property::SHADER, customShader );
}
}