X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=blobdiff_plain;f=dali-toolkit%2Finternal%2Fcontrols%2Fbuttons%2Fbutton-impl.cpp;h=79ac7dbaebff0afc2f8867c608642c7b54c68683;hp=0c7005b4e0d346c00de716389a6033f6d136937f;hb=a41e7c198d4b694ce2f5af2e5a6b2ca255ed5819;hpb=aaf4d0fc389f5dea68d99ce68413c18a472f7e4e diff --git a/dali-toolkit/internal/controls/buttons/button-impl.cpp b/dali-toolkit/internal/controls/buttons/button-impl.cpp index 0c7005b..79ac7db 100644 --- a/dali-toolkit/internal/controls/buttons/button-impl.cpp +++ b/dali-toolkit/internal/controls/buttons/button-impl.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016 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. @@ -39,6 +39,7 @@ #include #include #include +#include #include #include @@ -348,11 +349,7 @@ bool Button::IsSelected() const 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 @@ -372,7 +369,7 @@ 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() ); @@ -983,7 +980,7 @@ void Button::OnRelayout( const Vector2& size, RelayoutContainer& container ) Property::Map visualTransform; visualTransform.Add( Toolkit::DevelVisual::Transform::Property::SIZE, size ) - .Add( Toolkit::DevelVisual::Transform::Property::OFFSET_SIZE_MODE, Vector4( 0.0f, 0.0f, 1.0f, 1.0f) ); // Use relative size + .Add( Toolkit::DevelVisual::Transform::Property::SIZE_POLICY, Vector2( DevelVisual::Transform::Policy::ABSOLUTE, DevelVisual::Transform::Policy::ABSOLUTE ) ); currentBackGroundVisual.SetTransformAndSize( visualTransform, size ); } @@ -996,7 +993,8 @@ void Button::OnRelayout( const Vector2& size, RelayoutContainer& container ) visualTransform.Add( Toolkit::DevelVisual::Transform::Property::SIZE, visualSize ) .Add( Toolkit::DevelVisual::Transform::Property::OFFSET, visualPosition ) - .Add( Toolkit::DevelVisual::Transform::Property::OFFSET_SIZE_MODE, Vector4( 1.0f, 1.0f, 1.0f, 1.0f) ) // Use absolute size + .Add( Toolkit::DevelVisual::Transform::Property::OFFSET_POLICY, Vector2( DevelVisual::Transform::Policy::ABSOLUTE, DevelVisual::Transform::Policy::ABSOLUTE ) ) + .Add( Toolkit::DevelVisual::Transform::Property::SIZE_POLICY, Vector2( DevelVisual::Transform::Policy::ABSOLUTE, DevelVisual::Transform::Policy::ABSOLUTE ) ) .Add( Toolkit::DevelVisual::Transform::Property::ORIGIN, Toolkit::Align::TOP_BEGIN ) .Add( Toolkit::DevelVisual::Transform::Property::ANCHOR_POINT, visualAnchorPoint ); @@ -1026,7 +1024,8 @@ void Button::OnRelayout( const Vector2& size, RelayoutContainer& container ) Property::Map textVisualTransform; textVisualTransform.Add( Toolkit::DevelVisual::Transform::Property::SIZE, preSize ) .Add( Toolkit::DevelVisual::Transform::Property::OFFSET, labelPosition ) - .Add( Toolkit::DevelVisual::Transform::Property::OFFSET_SIZE_MODE, Vector4( 1.0f, 1.0f, 1.0f,1.0f ) ) // Use absolute size + .Add( Toolkit::DevelVisual::Transform::Property::OFFSET_POLICY, Vector2( DevelVisual::Transform::Policy::ABSOLUTE, DevelVisual::Transform::Policy::ABSOLUTE ) ) + .Add( Toolkit::DevelVisual::Transform::Property::SIZE_POLICY, Vector2( DevelVisual::Transform::Policy::ABSOLUTE, DevelVisual::Transform::Policy::ABSOLUTE ) ) .Add( Toolkit::DevelVisual::Transform::Property::ORIGIN, Toolkit::Align::TOP_BEGIN ) .Add( Toolkit::DevelVisual::Transform::Property::ANCHOR_POINT, visualAnchorPoint ); @@ -1224,13 +1223,33 @@ void Button::SetProperty( BaseObject* object, Property::Index index, const Prope 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 ) + { + TextVisual::ConvertStringKeysToIndexKeys( *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;