END_TEST;
}
+int UtcDaliButtonSetLabelStringWithPropertyMapStringsP(void)
+{
+ ToolkitTestApplication application;
+
+ Button button = PushButton::New();
+
+ tet_infoline(" UtcDaliButtonSetLabelStringWithPropertyMapStringsP Setting Button text using String then replacing with Enum then string");
+
+ Property::Map textVisualMapInitial;
+ textVisualMapInitial["visualType"] = "TEXT";
+ textVisualMapInitial["pointSize"] = 15.0f;
+ textVisualMapInitial["text"] = "button label initial";
+
+ button.SetProperty( Button::Property::LABEL, textVisualMapInitial );
+
+ DALI_TEST_EQUALS( GetButtonText( button ), "button label initial", TEST_LOCATION );
+
+ tet_infoline(" UtcDaliButtonSetLabelStringWithPropertyMapStringsP Intermediate part of test");
+
+ Property::Map propertyMap;
+ propertyMap.Insert( Toolkit::Visual::Property::TYPE, Toolkit::DevelVisual::TEXT );
+ propertyMap.Insert( Toolkit::TextVisual::Property::TEXT, "error if this is the final text" );
+ propertyMap.Insert( Toolkit::TextVisual::Property::POINT_SIZE, 15.0f );
+
+ button.SetProperty( Button::Property::LABEL, propertyMap );
+
+ DALI_TEST_EQUALS( GetButtonText( button ), "error if this is the final text", TEST_LOCATION );
+
+ tet_infoline(" UtcDaliButtonSetLabelStringWithPropertyMapStringsP Final part of test");
+
+ Property::Map textVisualMap;
+ textVisualMap["visualType"] = "TEXT";
+ textVisualMap["pointSize"] = 15.0f;
+ textVisualMap["text"] = "Button Label";
+
+ button.SetProperty( Toolkit::Button::Property::LABEL, textVisualMap );
+
+ DALI_TEST_EQUALS( GetButtonText( button ), "Button Label", TEST_LOCATION );
+ END_TEST;
+}
+
int UtcDaliButtonSetLabelWithStringP(void)
{
ToolkitTestApplication application;
#include <dali-toolkit/devel-api/controls/control-depth-index-ranges.h>
#include <dali-toolkit/devel-api/controls/buttons/button-devel.h>
#include <dali-toolkit/devel-api/visual-factory/visual-factory.h>
+#include <dali-toolkit/internal/visuals/text/text-visual.h>
#include <dali-toolkit/devel-api/visuals/text-visual-properties.h>
#include <dali-toolkit/devel-api/visuals/visual-properties-devel.h>
DALI_LOG_INFO( gLogButtonFilter, Debug::Verbose, "Button::SetProperty Setting TextVisual with string[%s]\n", textString.c_str() );
Property::Map setPropertyMap;
- setPropertyMap.Add( Toolkit::Visual::Property::TYPE, Toolkit::DevelVisual::TEXT)
+ setPropertyMap.Add( Toolkit::Visual::Property::TYPE, Toolkit::DevelVisual::TEXT )
.Add( Toolkit::TextVisual::Property::TEXT, textString );
GetImplementation( button ).MergeWithExistingLabelProperties( setPropertyMap, outTextVisualProperties );
Property::Map* setPropertyMap = value.GetMap();
if( setPropertyMap )
{
+ TextVisual::ConvertStringKeysToIndexKeys( *setPropertyMap );
GetImplementation( button ).MergeWithExistingLabelProperties( *setPropertyMap, outTextVisualProperties );
}
}
}\n
);
+/**
+ * Return Property index for the given string key
+ * param[in] stringKey the string index key
+ * return the key as an index
+ */
+
+Dali::Property::Index StringKeyToIndexKey( const std::string& stringKey )
+{
+ Dali::Property::Index result = Property::INVALID_KEY;
+
+ if( stringKey == VISUAL_TYPE )
+ {
+ result = Toolkit::Visual::Property::TYPE;
+ }
+ else if( stringKey == TEXT_PROPERTY )
+ {
+ result = Toolkit::TextVisual::Property::TEXT;
+ }
+ else if( stringKey == FONT_FAMILY_PROPERTY )
+ {
+ result = Toolkit::TextVisual::Property::FONT_FAMILY;
+ }
+ else if( stringKey == FONT_STYLE_PROPERTY )
+ {
+ result = Toolkit::TextVisual::Property::FONT_STYLE;
+ }
+ else if( stringKey == POINT_SIZE_PROPERTY )
+ {
+ result = Toolkit::TextVisual::Property::POINT_SIZE;
+ }
+ else if( stringKey == MULTI_LINE_PROPERTY )
+ {
+ result = Toolkit::TextVisual::Property::MULTI_LINE;
+ }
+ else if( stringKey == HORIZONTAL_ALIGNMENT_PROPERTY )
+ {
+ result = Toolkit::TextVisual::Property::HORIZONTAL_ALIGNMENT;
+ }
+ else if( stringKey == VERTICAL_ALIGNMENT_PROPERTY )
+ {
+ result = Toolkit::TextVisual::Property::VERTICAL_ALIGNMENT;
+ }
+ else if( stringKey == TEXT_COLOR_PROPERTY )
+ {
+ result = Toolkit::TextVisual::Property::TEXT_COLOR;
+ }
+ else if( stringKey == ENABLE_MARKUP_PROPERTY )
+ {
+ result = Toolkit::TextVisual::Property::ENABLE_MARKUP;
+ }
+
+ return result;
+}
+
} // unnamed namespace
TextVisualPtr TextVisual::New( VisualFactoryCache& factoryCache, const Property::Map& properties )
return TextVisualPtr;
}
+void TextVisual::ConvertStringKeysToIndexKeys( Property::Map& propertyMap )
+{
+ Property::Map outMap;
+
+ for( Property::Map::SizeType index = 0u, count = propertyMap.Count(); index < count; ++index )
+ {
+ const KeyValuePair& keyValue = propertyMap.GetKeyValue( index );
+
+ Property::Index indexKey = keyValue.first.indexKey;
+
+ if ( keyValue.first.type == Property::Key::STRING )
+ {
+ indexKey = StringKeyToIndexKey( keyValue.first.stringKey );
+ }
+
+ outMap.Insert( indexKey, keyValue.second );
+ }
+
+ propertyMap = outMap;
+}
+
float TextVisual::GetHeightForWidth( float width )
{
return mController->GetHeightForWidth( width );
{
const KeyValuePair& keyValue = propertyMap.GetKeyValue( index );
- switch( keyValue.first.type )
+ Property::Index indexKey = keyValue.first.indexKey;
+
+ if( keyValue.first.type == Property::Key::STRING )
{
- case Property::Key::INDEX:
- {
- DoSetProperty( keyValue.first.indexKey, keyValue.second );
- break;
- }
- case Property::Key::STRING:
- {
- if( keyValue.first.stringKey == TEXT_PROPERTY )
- {
- DoSetProperty( Toolkit::TextVisual::Property::TEXT, keyValue.second );
- }
- else if( keyValue.first.stringKey == FONT_FAMILY_PROPERTY )
- {
- DoSetProperty( Toolkit::TextVisual::Property::FONT_FAMILY, keyValue.second );
- }
- else if( keyValue.first.stringKey == FONT_STYLE_PROPERTY )
- {
- DoSetProperty( Toolkit::TextVisual::Property::FONT_STYLE, keyValue.second );
- }
- else if( keyValue.first.stringKey == POINT_SIZE_PROPERTY )
- {
- DoSetProperty( Toolkit::TextVisual::Property::POINT_SIZE, keyValue.second );
- }
- else if( keyValue.first.stringKey == MULTI_LINE_PROPERTY )
- {
- DoSetProperty( Toolkit::TextVisual::Property::MULTI_LINE, keyValue.second );
- }
- else if( keyValue.first.stringKey == HORIZONTAL_ALIGNMENT_PROPERTY )
- {
- DoSetProperty( Toolkit::TextVisual::Property::HORIZONTAL_ALIGNMENT, keyValue.second );
- }
- else if( keyValue.first.stringKey == VERTICAL_ALIGNMENT_PROPERTY )
- {
- DoSetProperty( Toolkit::TextVisual::Property::VERTICAL_ALIGNMENT, keyValue.second );
- }
- else if( keyValue.first.stringKey == TEXT_COLOR_PROPERTY )
- {
- DoSetProperty( Toolkit::TextVisual::Property::TEXT_COLOR, keyValue.second );
- }
- else if( keyValue.first.stringKey == ENABLE_MARKUP_PROPERTY )
- {
- DoSetProperty( Toolkit::TextVisual::Property::ENABLE_MARKUP, keyValue.second );
- }
- break;
- }
+ indexKey = StringKeyToIndexKey( keyValue.first.stringKey );
}
+
+ DoSetProperty( indexKey, keyValue.second );
}
// Elide the text if it exceeds the boundaries.