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=a8ab543a12c7f1636efa58a596753c08dc9a5f6c;hp=3bcdde3faac3fb6527324ce69cc7146c2bab5bd0;hb=6c02c5852ca329f720e4ae72d9cef2524629574c;hpb=518c9e7b5de69ff2401dffa6235a88e2dcf2bb72 diff --git a/dali-toolkit/internal/controls/buttons/button-impl.cpp b/dali-toolkit/internal/controls/buttons/button-impl.cpp index 3bcdde3..a8ab543 100644 --- a/dali-toolkit/internal/controls/buttons/button-impl.cpp +++ b/dali-toolkit/internal/controls/buttons/button-impl.cpp @@ -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() ); @@ -547,13 +544,13 @@ void Button::ButtonDown() void Button::ButtonUp() { + bool emitSignalsForPressAndReleaseAction = false; + if( DEPRESSED == mButtonPressedState ) { - bool validButtonAction = false; - if( mTogglableButton ) // Button up will change state { - validButtonAction = OnToggleReleased(); // Derived toggle buttons can override this to provide custom behaviour + emitSignalsForPressAndReleaseAction = OnToggleReleased(); // Derived toggle buttons can override this to provide custom behaviour } else { @@ -562,16 +559,20 @@ void Button::ButtonUp() { mAutoRepeatingTimer.Reset(); } - validButtonAction = true; + emitSignalsForPressAndReleaseAction = true; } + } + else if ( TOGGLE_DEPRESSED == mButtonPressedState ) + { + emitSignalsForPressAndReleaseAction = true; // toggle released after being pressed, a click + } - if ( validButtonAction ) - { - // The clicked and released signals should be emitted regardless of toggle mode. - Toolkit::Button handle( GetOwner() ); - mReleasedSignal.Emit( handle ); - mClickedSignal.Emit( handle ); - } + if ( emitSignalsForPressAndReleaseAction ) + { + // The clicked and released signals should be emitted regardless of toggle mode. + Toolkit::Button handle( GetOwner() ); + mReleasedSignal.Emit( handle ); + mClickedSignal.Emit( handle ); } } @@ -1030,6 +1031,8 @@ void Button::OnRelayout( const Vector2& size, RelayoutContainer& container ) } } + DALI_LOG_INFO( gLogButtonFilter, Debug::General, "OnRelayout selected (%s) \n", IsSelected()?"yes":"no" ); + DALI_LOG_INFO( gLogButtonFilter, Debug::General, "OnRelayout << \n"); } @@ -1218,13 +1221,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;