DALI_TEST_CHECK( !control.GetBackgroundActor() );
DALI_TEST_EQUALS( control.GetBackgroundColor(), Color::TRANSPARENT, TEST_LOCATION );
DALI_TEST_EQUALS( control.GetProperty( Control::PROPERTY_BACKGROUND_COLOR ).Get< Vector4 >(), Color::TRANSPARENT, TEST_LOCATION );
- DALI_TEST_CHECK( !control.GetProperty( Control::PROPERTY_BACKGROUND ).Get< Property::Map >().Count() );
+ DALI_TEST_CHECK( control.GetProperty( Control::PROPERTY_BACKGROUND ).Get< Property::Map >().Empty() );
control.SetProperty( Control::PROPERTY_BACKGROUND_COLOR, Color::RED );
DALI_TEST_CHECK( control.GetBackgroundActor() );
DALI_TEST_CHECK( !control.GetBackgroundActor() );
DALI_TEST_EQUALS( control.GetBackgroundColor(), Color::TRANSPARENT, TEST_LOCATION );
DALI_TEST_EQUALS( control.GetProperty( Control::PROPERTY_BACKGROUND_COLOR ).Get< Vector4 >(), Color::TRANSPARENT, TEST_LOCATION );
- DALI_TEST_CHECK( !control.GetProperty( Control::PROPERTY_BACKGROUND ).Get< Property::Map >().Count() );
+ DALI_TEST_CHECK( control.GetProperty( Control::PROPERTY_BACKGROUND ).Get< Property::Map >().Empty() );
END_TEST;
}
{
DALI_ASSERT_ALWAYS(mParser.GetRoot() && "Builder script not loaded");
- PropertyValueMap overrideMap;
+ Property::Map overrideMap;
Replacement replacements(overrideMap, mReplacementMap);
OptionalChild add = IsChild(*mParser.GetRoot(), sectionName);
return anim;
}
-Animation Builder::CreateAnimation( const std::string& animationName, const PropertyValueMap& map, Dali::Actor sourceActor )
+Animation Builder::CreateAnimation( const std::string& animationName, const Property::Map& map, Dali::Actor sourceActor )
{
Replacement replacement(map, mReplacementMap);
return CreateAnimation( animationName, replacement, sourceActor);
}
-Animation Builder::CreateAnimation( const std::string& animationName, const PropertyValueMap& map )
+Animation Builder::CreateAnimation( const std::string& animationName, const Property::Map& map )
{
Replacement replacement(map, mReplacementMap);
return CreateAnimation( animationName, replacement, Stage::GetCurrent().GetRootLayer() );
}
-void Builder::AddConstants( const PropertyValueMap& map )
+void Builder::AddConstants( const Property::Map& map )
{
- for(PropertyValueMap::const_iterator iter = map.begin(); iter != map.end(); ++iter)
- {
- mReplacementMap[ (*iter).first ] = (*iter).second;
- }
+ mReplacementMap.Merge( map );
}
void Builder::AddConstant( const std::string& key, const Property::Value& value )
mReplacementMap[key] = value;
}
-const PropertyValueMap& Builder::GetConstants() const
+const Property::Map& Builder::GetConstants() const
{
return mReplacementMap;
}
const Property::Value& Builder::GetConstant( const std::string& key ) const
{
- PropertyValueMap::const_iterator iter = mReplacementMap.find( key );
- if( iter != mReplacementMap.end() )
+ Property::Value* match = mReplacementMap.Find( key );
+ if( match )
{
- return (*iter).second;
+ return (*match);
}
else
{
}
}
-void Builder::LoadConstants( const TreeNode& root, PropertyValueMap& intoMap )
+void Builder::LoadConstants( const TreeNode& root, Property::Map& intoMap )
{
Replacement replacer(intoMap);
}
#if defined(DEBUG_ENABLED)
- PropertyValueMap::const_iterator iter = intoMap.find( "CONFIG_SCRIPT_LOG_LEVEL" );
- if( iter != intoMap.end() && (*iter).second.GetType() == Property::STRING )
+ Property::Value* iter = intoMap.Find( "CONFIG_SCRIPT_LOG_LEVEL" );
+ if( iter && iter->GetType() == Property::STRING )
{
- std::string logLevel( (*iter).second.Get< std::string >() );
+ std::string logLevel( iter->Get< std::string >() );
if( logLevel == "NoLogging" )
{
gFilterScript->SetLogLevel( Integration::Log::NoLogging );
}
}
-BaseHandle Builder::Create( const std::string& templateName, const PropertyValueMap& map )
+BaseHandle Builder::Create( const std::string& templateName, const Property::Map& map )
{
Replacement replacement( map, mReplacementMap );
return Create( templateName, replacement );
/**
* @copydoc Toolkit::Builder::AddConstants
*/
- void AddConstants( const PropertyValueMap& map );
+ void AddConstants( const Property::Map& map );
/**
* @copydoc Toolkit::Builder::AddConstant
/**
* @copydoc Toolkit::Builder::GetConstants
*/
- const PropertyValueMap& GetConstants() const;
+ const Property::Map& GetConstants() const;
/**
* @copydoc Toolkit::Builder::GetConstant
Animation CreateAnimation( const std::string& animationName );
/**
- * @copydoc Toolkit::Builder::CreateAnimation( const std::string& animationName, const PropertyValueMap& map );
+ * @copydoc Toolkit::Builder::CreateAnimation( const std::string& animationName, const Property::Map& map );
*/
- Animation CreateAnimation( const std::string& animationName, const PropertyValueMap& map );
+ Animation CreateAnimation( const std::string& animationName, const Property::Map& map );
/**
* @copydoc Toolkit::Builder::CreateAnimation( const std::string&,Dali::Actor);
Animation CreateAnimation( const std::string& animationName, Dali::Actor sourceActor );
/**
- * @copydoc Toolkit::Builder::CreateAnimation( const std::string&,const PropertyValueMap&,Dali::Actor);
+ * @copydoc Toolkit::Builder::CreateAnimation( const std::string&,const Property::Map&, Dali::Actor);
*/
- Animation CreateAnimation( const std::string& animationName, const PropertyValueMap& map, Dali::Actor sourceActor );
+ Animation CreateAnimation( const std::string& animationName, const Property::Map& map, Dali::Actor sourceActor );
/**
* @copydoc Toolkit::Builder::Create( const std::string& templateName );
BaseHandle Create( const std::string& templateName );
/**
- * @copydoc Toolkit::Builder::Create( const std::string& templateName, const PropertyValueMap& map );
+ * @copydoc Toolkit::Builder::Create( const std::string& templateName, const Property::Map& map );
*/
- BaseHandle Create( const std::string& templateName, const PropertyValueMap& map );
+ BaseHandle Create( const std::string& templateName, const Property::Map& map );
/**
* @copydoc Toolkit::Builder::CreateFromJson( const std::string& json );
SlotDelegate<Builder> mSlotDelegate;
- PropertyValueMap mReplacementMap;
+ Property::Map mReplacementMap;
BaseHandle Create( const std::string& templateName, const Replacement& constant );
BaseHandle DoCreate( const TreeNode& root, const TreeNode& node, Actor parent, const Replacement& replacements );
- void LoadConstants( const TreeNode& root, PropertyValueMap& intoMap );
+ void LoadConstants( const TreeNode& root, Property::Map& intoMap );
void LoadIncludes( const std::string& data );
namespace // anon
{
-PropertyValueMap::const_iterator FindReplacement( const std::string &str,
- const PropertyValueMap& overrideMap, const PropertyValueMap& defaultMap )
+Property::Value* FindReplacement( const std::string &str, const Property::Map& overrideMap, const Property::Map& defaultMap )
{
- PropertyValueMap::const_iterator ret = defaultMap.end();
+ Property::Value* ret = overrideMap.Find( str );
- PropertyValueMap::const_iterator iter = overrideMap.find( str );
-
- if( iter != overrideMap.end() )
- {
- ret = iter;
- }
- else
+ if ( !ret )
{
- PropertyValueMap::const_iterator iter = defaultMap.find( str );
+ ret = defaultMap.Find( str );
- if( iter != defaultMap.end() )
- {
- ret = iter;
- }
- else
- {
- // @ todo
- // try localized text ie dgettext. Look for colon {DOMAIN:TEXT} {LC_MESSAGE:ID_XXXX}
-
- }
+ // @ todo
+ // try localized text ie dgettext. Look for colon {DOMAIN:TEXT} {LC_MESSAGE:ID_XXXX}
}
return ret;
}
bool ResolvePartialReplacement( const std::string &initialValue, Property::Value &out,
- const PropertyValueMap& overrideMap, const PropertyValueMap& defaultMap )
+ const Property::Map& overrideMap, const Property::Map& defaultMap )
{
if( initialValue.size() >= 2 )
{
const std::string str( initialValue.substr( startPos, size ) );
- PropertyValueMap::const_iterator iter = FindReplacement( str, overrideMap, defaultMap );
+ Property::Value* value = FindReplacement( str, overrideMap, defaultMap );
- if( iter == defaultMap.end() )
+ if( !value )
{
DALI_SCRIPT_WARNING( "Cannot find replacement for '%s'\n", str.c_str() );
}
else
{
- if( Property::STRING != (*iter).second.GetType() )
+ if( Property::STRING != value->GetType() )
{
DALI_SCRIPT_WARNING( "Cannot replace substring in non string property type='%s'. Initial value '%s'\n",
PropertyTypes::GetName( out.GetType() ), initialValue.c_str() );
{
std::string newString = \
initialValue.substr(0, startPos - 1) +
- (*iter).second.Get<std::string>() +
+ value->Get< std::string >() +
initialValue.substr( startPos + size + 1 );
return ResolvePartialReplacement( newString, out, overrideMap, defaultMap );
} // namespace anon
-Replacement::Replacement( const PropertyValueMap& overrideMap, const PropertyValueMap& defaultMap )
+Replacement::Replacement( const Property::Map& overrideMap, const Property::Map& defaultMap )
: mOverrideMap( &overrideMap ), mDefaultMap( &defaultMap )
{
namespace
{
-PropertyValueMap noMap;
+Property::Map noMap;
}
-Replacement::Replacement( const PropertyValueMap& defaultMap )
+Replacement::Replacement( const Property::Map& defaultMap )
: mOverrideMap( &noMap ), mDefaultMap( &defaultMap )
{
{
OptionalString ret;
- if( node.HasSubstitution() && ((*mOverrideMap).size() || (*mDefaultMap).size()) )
+ if( node.HasSubstitution() && ((*mOverrideMap).Count() || (*mDefaultMap).Count()) )
{
OptionalString v = ::IsString( node );
if( v )
DALI_ASSERT_DEBUG( mOverrideMap && "missing map");
DALI_ASSERT_DEBUG( mDefaultMap && "missing map");
- PropertyValueMap::const_iterator iter = FindReplacement( replacementString, *mOverrideMap, *mDefaultMap );
+ Property::Value* value = FindReplacement( replacementString, *mOverrideMap, *mDefaultMap );
- if( iter == (*mDefaultMap).end() )
+ if( !value )
{
DALI_SCRIPT_WARNING("Cannot find replacement for '%s'\n", replacementString.c_str());
}
else
{
- out = (*iter).second;
+ out = *value;
#if defined(DEBUG_ENABLED)
DALI_SCRIPT_VERBOSE(" Full replacement for '%s' => to Type '%s'\n",
replacementString.c_str(),
}
}
-// template <typename T, OptionalValue<T> (*ISTYPE)( const TreeNode& node ), Property::Type TYPE>
-// OptionalValue<T> IsOfType( const TreeNode& node, const PropertyValueMap& overrideMap, const PropertyValueMap& defaultMap )
-// {
-// OptionalValue<T> ret;
-// if( OptionalString replace = HasFullReplacement( node, overrideMap, defaultMap ) )
-// {
-// Property::Value value = GetFullReplacement( *replace, overrideMap, defaultMap );
-// if( TYPE == value.GetType() )
-// {
-// ret = value.Get<T>();
-// }
-// }
-// else
-// {
-// ret = ISTYPE( node );
-// }
-// return ret;
-
-// }
-
-// OptionalFloat Replacement::IsFloat( const TreeNode & node ) const
-// {
-// return IsOfType<float, ::IsFloat, Property::FLOAT>( node, *mOverrideMap, *mDefaultMap );
-// /* OptionalFloat ret; */
-// /* if( OptionalString replace = HasFullReplacement( node ) ) */
-// /* { */
-// /* Property::Value value = GetFullReplacement( replace ); */
-// /* if( Property::FLOAT == value.GetType() ) */
-// /* { */
-// /* ret = value.Get<float>(); */
-// /* } */
-// /* } */
-// /* else */
-// /* { */
-// /* ret = IsFloat( node ); */
-// /* } */
-// /* return ret; */
-// }
-
OptionalFloat Replacement::IsFloat( const TreeNode & node ) const
{
OptionalFloat ret;
DALI_ASSERT_DEBUG( mOverrideMap && "missing map");
DALI_ASSERT_DEBUG( mDefaultMap && "missing map");
- if( node.HasSubstitution() && ((*mOverrideMap).size() || (*mDefaultMap).size()) )
+ if( node.HasSubstitution() && ((*mOverrideMap).Count() || (*mDefaultMap).Count()) )
{
if( OptionalString v = ::IsString( node ) )
{
* @param overrideMap The user overriding map
* @param defaultMap The default map to use
*/
- Replacement( const PropertyValueMap& overrideMap, const PropertyValueMap& defaultMap );
+ Replacement( const Property::Map& overrideMap, const Property::Map& defaultMap );
/*
* Constructor with default map
* Make a deep copy of the tree.
* @param overrideMap The user overriding map
*/
- Replacement( const PropertyValueMap& defaultMap );
+ Replacement( const Property::Map& defaultMap );
/* @brief Check node for a type
*
private:
// Overriding map (overrides the default map). The map is not owned.
- const PropertyValueMap* const mOverrideMap;
+ const Property::Map* const mOverrideMap;
- // Defautl map. The map is not owned.
- const PropertyValueMap* const mDefaultMap;
+ // Default map. The map is not owned.
+ const Property::Map* const mDefaultMap;
// compiler
// Replacement & operation=( Replacement& replacement );
}
TypeRegistration STYLE_MANAGER_TYPE( typeid(Dali::Toolkit::StyleManager), typeid(Dali::BaseHandle), Create, true /* Create instance at startup */ );
-/**
- * Merge two maps into one
- */
-void MergeMaps( const PropertyValueMap& a, const PropertyValueMap& b, PropertyValueMap& out )
-{
- out = a;
- for( PropertyValueMap::const_iterator it = b.begin(), itEnd = b.end(); it != itEnd; ++it )
- {
- out[ it->first ] = it->second;
- }
-}
-
} // namespace
Toolkit::StyleManager StyleManager::Get()
bool StyleManager::GetStyleConstant( const std::string& key, Property::Value& valueOut )
{
- Toolkit::PropertyValueMap::iterator valueIt = mStyleBuilderConstants.find( key );
- if( valueIt != mStyleBuilderConstants.end() )
+ Property::Value* value = mStyleBuilderConstants.Find( key );
+ if( value )
{
- valueOut = valueIt->second;
+ valueOut = *value;
return true;
}
SetTheme();
}
-Toolkit::Builder StyleManager::CreateBuilder( const PropertyValueMap& constants )
+Toolkit::Builder StyleManager::CreateBuilder( const Property::Map& constants )
{
Toolkit::Builder builder = Toolkit::Builder::New();
builder.AddConstants( constants );
else
{
// Merge theme and style constants
- PropertyValueMap constants;
- MergeMaps( mThemeBuilderConstants, mStyleBuilderConstants, constants );
+ Property::Map constants( mThemeBuilderConstants );
+ constants.Merge( mStyleBuilderConstants );
// Create it
builder = CreateBuilder( constants );
// EXTERNAL INCLUDES
#include <string>
#include <list>
+#include <dali/public-api/common/map-wrapper.h>
// INTERNAL INCLUDES
-
#include <dali/dali.h>
#include <dali-toolkit/public-api/styling/style-manager.h>
#include <dali-toolkit/public-api/builder/builder.h>
*
* @return Return the newly created builder
*/
- Toolkit::Builder CreateBuilder( const PropertyValueMap& constants );
+ Toolkit::Builder CreateBuilder( const Property::Map& constants );
/**
* @brief Load a JSON file into given builder
std::string mThemeFile; ///< The full path of the current theme file
- Toolkit::PropertyValueMap mThemeBuilderConstants; ///< Contants to give the theme builder
- Toolkit::PropertyValueMap mStyleBuilderConstants; ///< Constants specific to building styles
+ Property::Map mThemeBuilderConstants; ///< Contants to give the theme builder
+ Property::Map mStyleBuilderConstants; ///< Constants specific to building styles
BuilderMap mBuilderCache; ///< Cache of builders keyed by JSON file name
GetImpl(*this).LoadFromString( data );
}
-void Builder::AddConstants( const PropertyValueMap& map )
+void Builder::AddConstants( const Property::Map& map )
{
GetImpl(*this).AddConstants( map );
}
GetImpl(*this).AddConstant( key, value );
}
-const PropertyValueMap& Builder::GetConstants() const
+const Property::Map& Builder::GetConstants() const
{
return GetImpl(*this).GetConstants();
}
return GetImpl(*this).CreateAnimation( animationName );
}
-Animation Builder::CreateAnimation( const std::string& animationName, const PropertyValueMap& map )
+Animation Builder::CreateAnimation( const std::string& animationName, const Property::Map& map )
{
return GetImpl(*this).CreateAnimation( animationName, map );
}
return GetImpl(*this).CreateAnimation( animationName, sourceActor );
}
-Animation Builder::CreateAnimation( const std::string& animationName, const PropertyValueMap& map, Dali::Actor sourceActor )
+Animation Builder::CreateAnimation( const std::string& animationName, const Property::Map& map, Dali::Actor sourceActor )
{
return GetImpl(*this).CreateAnimation( animationName, map, sourceActor );
}
return GetImpl(*this).Create( templateName );
}
-BaseHandle Builder::Create( const std::string& templateName, const PropertyValueMap& map )
+BaseHandle Builder::Create( const std::string& templateName, const Property::Map& map )
{
return GetImpl(*this).Create( templateName, map );
}
// EXTERNAL INCLUDES
#include <dali/dali.h>
-#include <dali/public-api/common/map-wrapper.h>
namespace Dali DALI_IMPORT_API
{
class Builder;
}
-typedef std::map<std::string, Property::Value> PropertyValueMap;
-
/**
* This class provides the ability to load and style an actor tree from a string representation.
*
* @brief Adds user defined constants to all future style template or animation expansions
*
* e.g.
- * PropertyValueMap map;
+ * Property::Map map;
* map["IMAGE_DIRECTORY"] = "/usr/share/images";
* builder.AddConstants( map );
*
* @pre The Builder has been initialized.
* @param map The user defined constants used in template expansions.
*/
- void AddConstants( const PropertyValueMap& map );
+ void AddConstants( const Property::Map& map );
/**
* @brief Adds or modifies a user defined constant to all future style template or animation expansions
*
* e.g.
* @code
- * PropertyValueMap map = builder.GetConstants(); // get copy of current constants
+ * Property::Map map = builder.GetConstants(); // get copy of current constants
* map["IMAGE_DIRECTORY"] = "/usr/share/images"; // make modification
* builder.AddConstants( map ); // write back changes
* @endcode
* @pre The Builder has been initialized.
* @return A reference to the currently defined constants.
*/
- const PropertyValueMap& GetConstants() const;
+ const Property::Map& GetConstants() const;
/**
* @brief Gets a currently defined constant, or returns Property::INVALID
*
* e.g.
* @code
- * PropertyValueMap map = builder.GetConstants(); // get copy of current constants
+ * Property::Map map = builder.GetConstants(); // get copy of current constants
* map["IMAGE_DIRECTORY"] = "/usr/share/images"; // make modification
* builder.AddConstants( map ); // write back changes
* @endcode
* @brief Creates an animation from the set of known animations with user defined constants
*
* e.g.
- * PropertyValueMap map;
+ * Property::Map map;
* map["ACTOR"] = actor.GetName(); // replaces '{ACTOR} in the template
* Animation a = builder.CreateAnimation( "wobble");
*
* @param map The user defined constants used in style template expansion.
* @returns The base handle of the created object
*/
- Animation CreateAnimation( const std::string& animationName, const PropertyValueMap& map );
+ Animation CreateAnimation( const std::string& animationName, const Property::Map& map );
/**
* @brief Creates an animation from the set of known animations.
*
* The animation is applied to a specific actor.
* e.g.
- * PropertyValueMap map;
+ * Property::Map map;
* map["ACTOR"] = actor.GetName(); // replaces '{ACTOR} in the template
* Actor myInstance = builder.Create( "template-actor-tree" )
* Animation a = builder.CreateAnimation( "wobble", myInstance);
* @param sourceActor The starting point in an actor tree, from which to look for property owners
* @returns The base handle of the created object
*/
- Animation CreateAnimation( const std::string& animationName, const PropertyValueMap& map, Dali::Actor sourceActor );
+ Animation CreateAnimation( const std::string& animationName, const Property::Map& map, Dali::Actor sourceActor );
/**
* @brief Creates an object (e.g. an actor) from the set of known style templates
* @brief Creates an object from the style templates with user defined constants
*
* e.g.
- * PropertyValueMap map;
+ * Property::Map map;
* map["IMAGE_DIR"] = "/usr/share/images"; // replaces '{IMAGE_DIR} in the template
* mActor.Add( Actor::DownCast(builder.Create( "default-image", map) ) );
*
* @param map The user defined constants used in template expansion.
* @returns The base handle of the created object
*/
- BaseHandle Create( const std::string& templateName, const PropertyValueMap& map );
+ BaseHandle Create( const std::string& templateName, const Property::Map& map );
/**
* @brief Creates an object (e.g. an actor) from given json snippet
controlImpl.SetBackground( image );
}
}
- else if ( ! value.Get< Property::Map >().Count() )
+ else if ( value.Get< Property::Map >().Empty() )
{
// An empty map means the background is no longer required
controlImpl.ClearBackground();