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 );
}
}
Dali::Toolkit::RadioButton radioButtonChild = Dali::Toolkit::RadioButton::DownCast( parent.GetChildAt( i ) );
if( radioButtonChild && radioButtonChild != Self() )
{
- radioButtonChild.SetSelected( false );
+ radioButtonChild.SetProperty( Toolkit::Button::Property::SELECTED, false );
}
}
}
firstFit = InsertNode( mRoot->child[1], blockWidth, blockHeight );
}
- if( firstFit != NULL )
- {
- firstFit->occupied = true;
- packPositionX = firstFit->rectArea.x;
- packPositionY = firstFit->rectArea.y;
- }
+ DALI_ASSERT_ALWAYS( firstFit != NULL && "It should never happen!")
+
+ firstFit->occupied = true;
+ packPositionX = firstFit->rectArea.x;
+ packPositionY = firstFit->rectArea.y;
}
void AtlasPacker::GrowNode( SizeType blockWidth, SizeType blockHeight )
}\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.
*/
static TextVisualPtr New( VisualFactoryCache& factoryCache, const Property::Map& properties );
+ /**
+ * @brief Converts all strings keys in property map to index keys. Property Map can then be merged correctly.
+ * @param[in,out] propertyMap containing string keys or a mix of strings and indexes. Will be changed to index keys.
+ */
+ static void ConvertStringKeysToIndexKeys( Property::Map& propertyMap );
+
public: // from Visual::Base
/**
#define __DALI_TOOLKIT_CHECK_BOX_BUTTON_H__
/*
- * Copyright (c) 2015 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2017 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.
* {
* CheckBoxButton button = CheckBoxButton::New();
* button.SetParentOrigin( ParentOrigin::CENTER );
- * button.SetLabelText( "Check" );
+ * button.SetProperty( Button::Property::LABEL, "Check" );
* button.SetSize( 200, 40 );
* button.SetBackgroundColor( Color::WHITE );
* Stage::GetCurrent().Add( button );
#define __DALI_TOOLKIT_PUSH_BUTTON_H__
/*
- * Copyright (c) 2015 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2017 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.
* {
* PushButton button = PushButton::New();
* button.SetParentOrigin( ParentOrigin::CENTER );
- * button.SetLabelText( "Press" );
+ * button.SetProperty( Button::Property::LABEL, "Press" );
* Stage::GetCurrent().Add( button );
*
* // Connect to button signals emitted by the button
/*
- * Copyright (c) 2015 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2017 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.
RadioButton RadioButton::New( const std::string& label )
{
RadioButton radioButton = Internal::RadioButton::New();
- radioButton.SetLabelText( label );
+ radioButton.SetProperty( Toolkit::Button::Property::LABEL, label );
return radioButton;
}
#define __DALI_TOOLKIT_RADIO_BUTTON_H__
/*
- * Copyright (c) 2015 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2017 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.
*
* Radio buttons are designed to select one of many option at the same time.
*
- * Every button have its own \e label and \e state, which can be modified by Button::SetLabelText and Button::SetSelected.
+ * Every button have its own \e label and \e state, which can be modified by Button::Property::LABEL and Button::Property::SELECTED.
*
* RadioButton can change its current state using Button::SetSelected.
*
*
* // Make the first RadioButton and add it to its parent
* RadioButton button1 = RadioButton::New();
- * button1.SetLabelText( "button1" );
+ * button1.SetProperty( Button::Property::LABEL, "button1" );
* button1.SetBackgroundColor( Color::WHITE );
* button1.SetPosition( 0, -40 );
* radioGroup.Add( button1 );
*
* // Make more RadioButtons and add them to their parent
* RadioButton button2 = RadioButton::New();
- * button2.SetLabelText( "button2" );
+ * button2.SetProperty( Toolkit::Button::Property::LABEL, "button2" );
* button2.SetBackgroundColor( Color::WHITE );
* button2.SetPosition( 0, 40 );
* radioGroup.Add( button2 );