X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=blobdiff_plain;f=dali-toolkit%2Finternal%2Fcontrols%2Fbuttons%2Ftoggle-button-impl.cpp;h=15ac51a5dc6f3708d5b169b38bc23571493c73ac;hp=b1808f5c516e46097c61b76b3ab0de4802cc0101;hb=2f976883ceece5f26123a64f85ef068c25ddfa90;hpb=f11be450471738b68f98fa4c552b3a22482ae4de diff --git a/dali-toolkit/internal/controls/buttons/toggle-button-impl.cpp b/dali-toolkit/internal/controls/buttons/toggle-button-impl.cpp old mode 100755 new mode 100644 index b1808f5..15ac51a --- a/dali-toolkit/internal/controls/buttons/toggle-button-impl.cpp +++ b/dali-toolkit/internal/controls/buttons/toggle-button-impl.cpp @@ -110,6 +110,11 @@ void ToggleButton::OnInitialize() // Toggle 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::TOGGLE_BUTTON ) ); + } ); } void ToggleButton::SetProperty( BaseObject* object, Property::Index propertyIndex, const Property::Value& value ) @@ -372,6 +377,40 @@ void ToggleButton::OnPressed() RelayoutRequest(); } +Dali::Accessibility::States ToggleButton::AccessibleImpl::CalculateStates() +{ + auto states = Button::AccessibleImpl::CalculateStates(); + auto button = Toolkit::ToggleButton::DownCast( self ); + if( button.GetProperty( Toolkit::ToggleButton::Property::CURRENT_STATE_INDEX ) ) + states[Dali::Accessibility::State::CHECKED] = true; + return states; +} + +std::string ToggleButton::AccessibleImpl::GetDescriptionRaw() +{ + auto button = Toolkit::ToggleButton::DownCast( self ); + auto index = button.GetProperty( Toolkit::ToggleButton::Property::CURRENT_STATE_INDEX ); + auto tooltips = button.GetProperty( Toolkit::ToggleButton::Property::TOOLTIPS ); + + return tooltips[index].Get(); +} + +void ToggleButton::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::CHECKED, mCurrentToggleIndex ? 1 : 0, 0 + ); + + if(Self() == Dali::Accessibility::Accessible::GetCurrentlyHighlightedActor()) + { + Dali::Accessibility::Accessible::Get(Self())->Emit(Dali::Accessibility::ObjectPropertyChangeEvent::DESCRIPTION); + } + } +} + } // namespace Internal } // namespace Toolkit