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() );
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
{
{
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 );
}
}
labelPosition.y = labelVisualPadding.height;
}
+ Vector2 preSize = Vector2( static_cast< int >( remainingSpaceForText.x ), static_cast< int >( remainingSpaceForText.y ));
+
DALI_LOG_INFO( gLogButtonFilter, Debug::General, "OnRelayout text Size(%f,%f) text Position(%f,%f) \n", remainingSpaceForText.width, remainingSpaceForText.height, labelPosition.x, labelPosition.y);
+ DALI_LOG_INFO( gLogButtonFilter, Debug::General, "OnRelayout text Size -- (%f,%f) text Position(%f,%f) \n", preSize.width, preSize.height, labelPosition.x, labelPosition.y);
+
+
Property::Map textVisualTransform;
- textVisualTransform.Add( Toolkit::DevelVisual::Transform::Property::SIZE, remainingSpaceForText)
+ 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::ORIGIN, Toolkit::Align::TOP_BEGIN )
}
}
+ DALI_LOG_INFO( gLogButtonFilter, Debug::General, "OnRelayout selected (%s) \n", IsSelected()?"yes":"no" );
+
DALI_LOG_INFO( gLogButtonFilter, Debug::General, "OnRelayout << \n");
}
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;