return false;
}
+static std::string GetButtonText( Button button )
+{
+ Property::Value value = button.GetProperty( Toolkit::Button::Property::LABEL );
+
+ Property::Map *labelProperty = value.GetMap();
+
+ std::string textLabel;
+
+ if ( labelProperty )
+ {
+ Property::Value* value = labelProperty->Find( Toolkit::TextVisual::Property::TEXT );
+ value->Get( textLabel );
+ }
+
+ return textLabel;
+}
+
struct CallbackFunctor
{
CallbackFunctor(bool* callbackFlag)
END_TEST;
}
-int UtcDaliButtonSetLabelStringP(void)
+int UtcDaliButtonSetLabelStringWithPropertyMapP(void)
{
ToolkitTestApplication application;
button.SetProperty( Toolkit::Button::Property::LABEL,
Property::Map().Add( Toolkit::Visual::Property::TYPE, Toolkit::DevelVisual::TEXT )
.Add( Toolkit::TextVisual::Property::POINT_SIZE, 15.0f )
+ .Add( Toolkit::TextVisual::Property::TEXT, "Button Label")
);
- button.SetLabelText( "Button Label" );
+ DALI_TEST_EQUALS( GetButtonText( button ), "Button Label", TEST_LOCATION );
+ END_TEST;
+}
+
+int UtcDaliButtonSetLabelWithStringP(void)
+{
+ ToolkitTestApplication application;
+
+ Button button = PushButton::New();
+
+ // Set default point size for text visual as style sheet not available.
+ button.SetProperty( Toolkit::Button::Property::LABEL,
+ Property::Map().Add( Toolkit::Visual::Property::TYPE, Toolkit::DevelVisual::TEXT )
+ .Add( Toolkit::TextVisual::Property::POINT_SIZE, 15.0f )
+ );
+
+ button.SetProperty( Toolkit::Button::Property::LABEL, "Button Label" );
- DALI_TEST_EQUALS( button.GetLabelText(), "Button Label", TEST_LOCATION );
+ DALI_TEST_EQUALS( GetButtonText( button ), "Button Label", TEST_LOCATION );
END_TEST;
}
{
ToolkitTestApplication application;
+ tet_infoline(" UtcDaliButtonSetLabelPropertyP Set text label and then set again with new text");
+
+
const std::string TEST_LABEL1 = "test label one";
const std::string TEST_LABEL2 = "test label two";
button.SetProperty( Toolkit::Button::Property::LABEL,
Property::Map().Add( Toolkit::Visual::Property::TYPE, Toolkit::DevelVisual::TEXT )
.Add( Toolkit::TextVisual::Property::POINT_SIZE, 15.0f )
+ .Add( Toolkit::TextVisual::Property::TEXT, TEST_LABEL1 )
);
- button.SetProperty( Button::Property::LABEL_TEXT, TEST_LABEL1 );
-
- std::string labelText = button.GetProperty<std::string>( Button::Property::LABEL_TEXT );
-
- DALI_TEST_EQUALS( labelText, TEST_LABEL1, TEST_LOCATION );
+ DALI_TEST_EQUALS( GetButtonText( button ), TEST_LABEL1, TEST_LOCATION );
Property::Map propertyMap;
propertyMap.Insert( Toolkit::Visual::Property::TYPE, Toolkit::DevelVisual::TEXT );
propertyMap.Insert( Toolkit::TextVisual::Property::POINT_SIZE, 15.0f );
button.SetProperty( Button::Property::LABEL, propertyMap );
- labelText = button.GetProperty<std::string>( Button::Property::LABEL_TEXT );
-
- DALI_TEST_EQUALS( labelText, TEST_LABEL2, TEST_LOCATION );
+ DALI_TEST_EQUALS( GetButtonText( button ), TEST_LABEL2, TEST_LOCATION );
END_TEST;
}
END_TEST;
}
+
+int UtcDaliButtonSetLabelTextDeprecatedPropertyP(void)
+{
+ ToolkitTestApplication application;
+ tet_infoline(" UtcDaliButtonSetLabelTextDeprecatedPropertyP");
+
+ const std::string TEST_LABEL1 = "test label one";
+ const std::string TEST_LABEL2 = "test label two";
+
+ Button button = PushButton::New();
+
+ button.SetProperty( Toolkit::Button::Property::LABEL,
+ Property::Map().Add( Toolkit::Visual::Property::TYPE, Toolkit::DevelVisual::TEXT )
+ .Add( Toolkit::TextVisual::Property::POINT_SIZE, 15.0f )
+ );
+
+ button.SetProperty( Button::Property::LABEL_TEXT, TEST_LABEL1 );
+
+ std::string labelText = button.GetProperty<std::string>( Button::Property::LABEL_TEXT );
+
+ DALI_TEST_EQUALS( labelText, TEST_LABEL1, TEST_LOCATION );
+
+ Property::Map propertyMap;
+ propertyMap.Insert( Toolkit::Visual::Property::TYPE, Toolkit::DevelVisual::TEXT );
+ propertyMap.Insert( Toolkit::TextVisual::Property::TEXT, TEST_LABEL2 );
+ propertyMap.Insert( Toolkit::TextVisual::Property::TEXT_COLOR, Color::BLUE );
+ propertyMap.Insert( Toolkit::TextVisual::Property::POINT_SIZE, 15.0f );
+ button.SetProperty( Button::Property::LABEL, propertyMap );
+
+ labelText = button.GetProperty<std::string>( Button::Property::LABEL_TEXT );
+
+ DALI_TEST_EQUALS( labelText, TEST_LABEL2, TEST_LOCATION );
+
+ END_TEST;
+}
void Button::SetLabelText( const std::string& label )
{
- Property::Map labelProperty;
- labelProperty.Add( Toolkit::Visual::Property::TYPE, Toolkit::DevelVisual::TEXT)
- .Add( Toolkit::TextVisual::Property::TEXT, label );
-
- Self().SetProperty( Toolkit::Button::Property::LABEL, labelProperty );
+ Self().SetProperty( Toolkit::Button::Property::LABEL, label );
}
std::string Button::GetLabelText() const
return textLabel;
}
-void Button::MergeLabelProperties( const Property::Map& inMap, Property::Map& outMap )
+void Button::MergeWithExistingLabelProperties( const Property::Map& inMap, Property::Map& outMap )
{
DALI_LOG_INFO( gLogButtonFilter, Debug::Verbose, "MergeLabelProperties with %d properties\n", inMap.Count() );
case Toolkit::Button::Property::LABEL:
{
- // Get a Property::Map from the property if possible.
- Property::Map* setPropertyMap = value.GetMap();
- if( setPropertyMap )
+ Property::Map outTextVisualProperties;
+ std::string textString;
+
+ if ( value.Get( textString ) )
+ {
+ 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)
+ .Add( Toolkit::TextVisual::Property::TEXT, textString );
+
+ GetImplementation( button ).MergeWithExistingLabelProperties( setPropertyMap, outTextVisualProperties );
+ }
+ else
+ {
+ // Get a Property::Map from the property if possible.
+ Property::Map* setPropertyMap = value.GetMap();
+ if( setPropertyMap )
+ {
+ GetImplementation( button ).MergeWithExistingLabelProperties( *setPropertyMap, outTextVisualProperties );
+ }
+ }
+
+ if( !outTextVisualProperties.Empty() )
{
- Property::Map textVisualProperties;
- GetImplementation( button ).MergeLabelProperties( *setPropertyMap, textVisualProperties );
- GetImplementation( button ).CreateVisualsForComponent( index, textVisualProperties, DepthIndex::CONTENT );
+ GetImplementation( button ).CreateVisualsForComponent( index, outTextVisualProperties, DepthIndex::CONTENT );
GetImplementation( button ).RelayoutRequest();
}
break;