DALI_TYPE_REGISTRATION_BEGIN( Toolkit::PushButton, Toolkit::Button, Create )
-DALI_PROPERTY_REGISTRATION( Toolkit, PushButton, "unselectedIcon", STRING, UNSELECTED_ICON )
-DALI_PROPERTY_REGISTRATION( Toolkit, PushButton, "selectedIcon", STRING, SELECTED_ICON )
-DALI_PROPERTY_REGISTRATION( Toolkit, PushButton, "iconAlignment", STRING, ICON_ALIGNMENT )
DALI_PROPERTY_REGISTRATION( Toolkit, PushButton, "labelPadding", STRING, LABEL_PADDING )
DALI_PROPERTY_REGISTRATION( Toolkit, PushButton, "iconPadding", STRING, ICON_PADDING )
DALI_TYPE_REGISTRATION_END()
-/*
- * Table to define Text-to-enum conversions for IconAlignment.
- */
-const Dali::Scripting::StringEnum IconAlignmentTable[] = {
- { "LEFT", Toolkit::Internal::PushButton::LEFT },
- { "RIGHT", Toolkit::Internal::PushButton::RIGHT },
- { "TOP", Toolkit::Internal::PushButton::TOP },
- { "BOTTOM", Toolkit::Internal::PushButton::BOTTOM },
-}; const unsigned int IconAlignmentTableCount = sizeof( IconAlignmentTable ) / sizeof( IconAlignmentTable[0] );
-
} // unnamed namespace
namespace
// Push button requires the Leave event.
Actor self = Self();
self.SetProperty( Actor::Property::LEAVE_REQUIRED, true );
+
+ DevelControl::SetAccessibilityConstructor( self, []( Dali::Actor actor ) {
+ return std::unique_ptr< Dali::Accessibility::Accessible >(
+ new AccessibleImpl( actor, Dali::Accessibility::Role::PUSH_BUTTON ) );
+ } );
}
void PushButton::SetIconAlignment( const PushButton::IconAlignment iconAlignment )
switch ( propertyIndex )
{
- case Toolkit::PushButton::Property::UNSELECTED_ICON:
- {
- pushButtonImpl.CreateVisualsForComponent( Toolkit::Button::Property::UNSELECTED_VISUAL, value, DepthIndex::CONTENT );
- break;
- }
- case Toolkit::PushButton::Property::SELECTED_ICON:
- {
- pushButtonImpl.CreateVisualsForComponent( Toolkit::Button::Property::SELECTED_VISUAL, value, DepthIndex::CONTENT );
- break;
- }
- case Toolkit::PushButton::Property::ICON_ALIGNMENT:
- {
- IconAlignment iconAlignment;
- if( Scripting::GetEnumeration< IconAlignment >( value.Get< std::string >().c_str(), IconAlignmentTable, IconAlignmentTableCount, iconAlignment ) )
- {
- pushButtonImpl.SetIconAlignment( iconAlignment );
- }
- break;
- }
case Toolkit::PushButton::Property::LABEL_PADDING:
{
Vector4 padding ( value.Get< Vector4 >() );
switch ( propertyIndex )
{
- case Toolkit::PushButton::Property::UNSELECTED_ICON:
- {
- //value = pushButtonImpl.GetIcon( UNSELECTED_DECORATION );
- break;
- }
- case Toolkit::PushButton::Property::SELECTED_ICON:
- {
- //value = pushButtonImpl.GetIcon( UNSELECTED_DECORATION );
- break;
- }
- case Toolkit::PushButton::Property::ICON_ALIGNMENT:
- {
- value = Scripting::GetLinearEnumerationName< IconAlignment >( pushButtonImpl.GetIconAlignment(), IconAlignmentTable, IconAlignmentTableCount );
- break;
- }
case Toolkit::PushButton::Property::LABEL_PADDING:
{
Padding padding = pushButtonImpl.Button::GetLabelPadding();
return value;
}
+Dali::Accessibility::States PushButton::AccessibleImpl::CalculateStates()
+{
+ auto tmp = Button::AccessibleImpl::CalculateStates();
+ auto slf = Toolkit::Button::DownCast( self );
+ tmp[Dali::Accessibility::State::PRESSED] = slf.GetProperty<bool>( Toolkit::Button::Property::SELECTED );
+ return tmp;
+}
+
+void PushButton::OnStateChange( State newState )
+{
+ // TODO: replace it with OnPropertySet hook once Button::Property::SELECTED will be consistently used
+ if (Dali::Accessibility::IsUp() && (newState == SELECTED_STATE || newState == UNSELECTED_STATE))
+ {
+ Dali::Accessibility::Accessible::Get(Self())->EmitStateChanged(
+ Dali::Accessibility::State::PRESSED, newState == SELECTED_STATE ? 1 : 0, 0
+ );
+
+ if (Self().GetProperty<bool>(Toolkit::Button::Property::TOGGLABLE))
+ {
+ Dali::Accessibility::Accessible::Get(Self())->EmitStateChanged(
+ Dali::Accessibility::State::CHECKED, newState == SELECTED_STATE ? 1 : 0, 0
+ );
+ }
+ }
+}
+
} // namespace Internal
} // namespace Toolkit