DALI_PROPERTY_REGISTRATION( Toolkit, Button, "disabled-state-image", STRING, DISABLED_STATE_IMAGE )
DALI_PROPERTY_REGISTRATION( Toolkit, Button, "unselected-color", VECTOR4, UNSELECTED_COLOR )
DALI_PROPERTY_REGISTRATION( Toolkit, Button, "selected-color", VECTOR4, SELECTED_COLOR )
+DALI_PROPERTY_REGISTRATION( Toolkit, Button, "label", MAP, LABEL )
+
+// Deprecated properties:
DALI_PROPERTY_REGISTRATION( Toolkit, Button, "label-text", STRING, LABEL_TEXT )
+// Signals:
DALI_SIGNAL_REGISTRATION( Toolkit, Button, "pressed", SIGNAL_PRESSED )
DALI_SIGNAL_REGISTRATION( Toolkit, Button, "released", SIGNAL_RELEASED )
DALI_SIGNAL_REGISTRATION( Toolkit, Button, "clicked", SIGNAL_CLICKED )
DALI_SIGNAL_REGISTRATION( Toolkit, Button, "state-changed", SIGNAL_STATE_CHANGED )
+// Actions:
DALI_ACTION_REGISTRATION( Toolkit, Button, "button-click", ACTION_BUTTON_CLICK )
DALI_TYPE_REGISTRATION_END()
const unsigned int INITIAL_AUTOREPEATING_DELAY( 0.15f );
const unsigned int NEXT_AUTOREPEATING_DELAY( 0.05f );
-const char* const STYLE_BUTTON_LABEL = "button.label";
-
} // unnamed namespace
Button::Button()
void Button::SetLabelText( const std::string& label )
{
- if( !mLabel || ( label != GetLabelText() ) )
- {
- // If we have a label, unparent and update it.
- if( mLabel )
- {
- mLabel.SetProperty( Toolkit::TextLabel::Property::TEXT, label );
- }
- else
- {
- // If we don't have a label, create one and set it up.
- mLabel = Toolkit::TextLabel::New( label );
- mLabel.SetProperty( Toolkit::Control::Property::STYLE_NAME, STYLE_BUTTON_LABEL );
- mLabel.SetPosition( 0.f, 0.f );
- // label should be the top of the button
- Self().Add( mLabel );
- }
-
- OnLabelSet( false );
-
- RelayoutRequest();
- }
+ Property::Map labelProperty;
+ labelProperty.Insert( "text", label );
+ ModifyLabel( labelProperty );
}
std::string Button::GetLabelText() const
return std::string();
}
+void Button::ModifyLabel( const Property::Map& properties )
+{
+ // If we don't have a label yet, create one.
+ if( !mLabel )
+ {
+ // If we don't have a label, create one and set it up.
+ // Note: The label text is set from the passed in property map after creation.
+ mLabel = Toolkit::TextLabel::New();
+ mLabel.SetPosition( 0.0f, 0.0f );
+ // label should be the top of the button
+ Self().Add( mLabel );
+ }
+
+ // Set any properties specified for the label by iterating through all property key-value pairs.
+ for( unsigned int i = 0, mapCount = properties.Count(); i < mapCount; ++i )
+ {
+ const StringValuePair& propertyPair( properties.GetPair( i ) );
+
+ // Convert the property string to a property index.
+ Property::Index setPropertyIndex = mLabel.GetPropertyIndex( propertyPair.first );
+ if( setPropertyIndex != Property::INVALID_INDEX )
+ {
+ // If the conversion worked, we have a valid property index,
+ // Set the property to the new value.
+ mLabel.SetProperty( setPropertyIndex, propertyPair.second );
+ }
+ }
+
+ // Notify derived button classes of the change.
+ OnLabelSet( false );
+
+ RelayoutRequest();
+}
+
Actor& Button::GetLabelActor()
{
return mLabel;
GetImplementation( button ).SetLabelText( value.Get< std::string >() );
break;
}
+
+ case Toolkit::Button::Property::LABEL:
+ {
+ // Get a Property::Map from the property if possible.
+ Property::Map setPropertyMap;
+ if( value.Get( setPropertyMap ) )
+ {
+ GetImplementation( button ).ModifyLabel( setPropertyMap );
+ }
+ }
+ break;
}
}
}
value = GetImplementation( button ).GetLabelText();
break;
}
+
+ case Toolkit::Button::Property::LABEL:
+ {
+ Property::Map emptyMap;
+ value = emptyMap;
+ break;
+ }
}
}
}
mLabel = label;
- mLabel.SetProperty( Toolkit::Control::Property::STYLE_NAME, STYLE_BUTTON_LABEL );
- mLabel.SetPosition( 0.f, 0.f );
+ mLabel.SetPosition( 0.0f, 0.0f );
// label should be the top of the button
Self().Add( mLabel );
public:
/**
- * @copydoc Dali::Toolkit::Button::SetDisabled( bool disabled )
+ * @copydoc Dali::Toolkit::Button::SetDisabled
*/
void SetDisabled( bool disabled );
/**
- * @copydoc Dali::Toolkit::Button::IsDisabled() const
+ * @copydoc Dali::Toolkit::Button::IsDisabled
*/
bool IsDisabled() const;
/**
- * @copydoc Dali::Toolkit::Button::SetAutoRepeating( bool autoRepeating )
+ * @copydoc Dali::Toolkit::Button::SetAutoRepeating
*/
void SetAutoRepeating( bool autoRepeating );
/**
- * @copydoc Dali::Toolkit::Button::IsAutoRepeating() const
+ * @copydoc Dali::Toolkit::Button::IsAutoRepeating
*/
bool IsAutoRepeating() const;
/**
- * @copydoc Dali::Toolkit::Button::SetInitialAutoRepeatingDelay( float initialAutoRepeatingDelay )
+ * @copydoc Dali::Toolkit::Button::SetInitialAutoRepeatingDelay
*/
void SetInitialAutoRepeatingDelay( float initialAutoRepeatingDelay );
/**
- * @copydoc Dali::Toolkit::Button::GetInitialAutoRepeatingDelay() const
+ * @copydoc Dali::Toolkit::Button::GetInitialAutoRepeatingDelay
*/
float GetInitialAutoRepeatingDelay() const;
/**
- * @copydoc Dali::Toolkit::Button::SetNextAutoRepeatingDelay( float nextAutoRepeatingDelay )
+ * @copydoc Dali::Toolkit::Button::SetNextAutoRepeatingDelay
*/
void SetNextAutoRepeatingDelay( float nextAutoRepeatingDelay );
/**
- * @copydoc Dali::Toolkit::Button::GetNextAutoRepeatingDelay() const
+ * @copydoc Dali::Toolkit::Button::GetNextAutoRepeatingDelay
*/
float GetNextAutoRepeatingDelay() const;
/**
- * @copydoc Dali::Toolkit::Button::SetTogglableButton( bool togglable )
+ * @copydoc Dali::Toolkit::Button::SetTogglableButton
*/
void SetTogglableButton( bool togglable );
/**
- * @copydoc Dali::Toolkit::Button::IsTogglableButton() const
+ * @copydoc Dali::Toolkit::Button::IsTogglableButton
*/
bool IsTogglableButton() const;
/**
- * @copydoc Dali::Toolkit::Button::SetSelected( bool selected )
+ * @copydoc Dali::Toolkit::Button::SetSelected
*/
void SetSelected( bool selected );
/**
- * @copydoc Dali::Toolkit::Button::IsSelected() const
+ * @copydoc Dali::Toolkit::Button::IsSelected
*/
bool IsSelected() const;
/**
- * @copydoc Dali::Toolkit::Button::SetAnimationTime()
+ * @copydoc Dali::Toolkit::Button::SetAnimationTime
*/
void SetAnimationTime( float animationTime );
/**
- * @copydoc Dali::Toolkit::Button::GetAnimationTime()
+ * @copydoc Dali::Toolkit::Button::GetAnimationTime
*/
float GetAnimationTime() const;
std::string GetDisabledBackgroundImageFilename() const;
/**
+ * @brief Sets the specified properties on the button label.
+ * If the label does not exist yet, it is created.
+ * The derived buttons are notified if any properties are changed.
+ * @param[in] properties A Property::Map of key-value pairs of properties to set.
+ */
+ void ModifyLabel( const Property::Map& properties );
+
+ /**
* Performs actions as requested using the action name.
* @param[in] object The object on which to perform the action.
* @param[in] actionName The action to perform.
void SetDisabledBackgroundImage( Actor image );
/**
- * @copydoc Dali::Toolkit::Button::GetButtonImage()
+ * @copydoc Dali::Toolkit::Button::GetButtonImage
*/
Actor GetButtonImage() const;
/**
- * @copydoc Dali::Toolkit::Button::GetSelectedImage()
+ * @copydoc Dali::Toolkit::Button::GetSelectedImage
*/
Actor GetSelectedImage() const;
#include <dali/public-api/images/resource-image.h>
#include <dali/public-api/math/vector2.h>
#include <dali/public-api/math/vector4.h>
+#include <dali/public-api/object/property-map.h>
#include <dali/devel-api/object/type-registry-helper.h>
#include <libintl.h>
// todo Move this to adaptor??
#define GET_LOCALE_TEXT(string) dgettext("elementary", string)
-const std::string TEXT_SELECTION_POPUP_LABEL( "textselectionpopuplabel" );
+const std::string TEXT_SELECTION_POPUP_BUTTON_STYLE_NAME( "textselectionpopupbutton" );
const Dali::Vector4 DEFAULT_OPTION_PRESSED_COLOR( Dali::Vector4( 0.24f, 0.72f, 0.8f, 1.0f ) );
#ifdef DGETTEXT_ENABLED
// 2. Set the options contents.
if( showCaption )
{
+ // PushButton layout properties.
option.SetProperty( Toolkit::PushButton::Property::LABEL_PADDING, Vector4( 24.0f, 24.0f, 14.0f, 14.0f ) );
- option.SetLabelText( button.caption );
+
+ // Label properties.
+ Property::Map buttonLabelProperties;
+ buttonLabelProperties.Insert( "text", button.caption );
+ option.SetProperty( Toolkit::Button::Property::LABEL, buttonLabelProperties );
}
if( showIcons )
{
// The image can be blank, the color can be used regardless.
option.SetSelectedImage( mPressedImage );
option.SetProperty( Toolkit::Button::Property::SELECTED_COLOR, mPressedColor );
+ option.SetProperty( Toolkit::Control::Property::STYLE_NAME, TEXT_SELECTION_POPUP_BUTTON_STYLE_NAME );
// 5 Add option to tool bar
mToolbar.AddOption( option );
UNSELECTED_STATE_IMAGE, ///< name "unselected-state-image", @see SetUnselectedImage(), type std::string
SELECTED_STATE_IMAGE, ///< name "selected-state-image", @see SetSelectedImage(), type std::string
DISABLED_STATE_IMAGE, ///< name "disabled-state-image", @see SetDisabledImage(), type std::string
- UNSELECTED_COLOR, ///< name "unselected-color", @see SetUnselectedColor(), type Vector4
- SELECTED_COLOR, ///< name "selected-color", @see SetSelectedColor(), type Vector4
+ UNSELECTED_COLOR, ///< name "unselected-color", type Vector4
+ SELECTED_COLOR, ///< name "selected-color", type Vector4
+ LABEL, ///< name "label", type Property::Map
+
+ // Deprecated properties:
LABEL_TEXT, ///< name "label-text", @see SetLabelText(), type std::string
};
};
"popup-fade-in-duration":0.25,
"popup-fade-out-duration":0.25
},
+ "textselectionpopupbutton":
+ {
+ "label":
+ {
+ "point-size":8
+ }
+ },
"scrollview":
{
"overshoot-effect-color":"B018"
"popup-fade-in-duration":0.25,
"popup-fade-out-duration":0.25
},
+ "textselectionpopupbutton":
+ {
+ "label":
+ {
+ "point-size":8
+ }
+ },
"scrollview":
{
"overshoot-effect-color":"B018"