X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=blobdiff_plain;f=dali-toolkit%2Finternal%2Fcontrols%2Fbuttons%2Fcheck-box-button-impl.cpp;h=45c50579fb6a86344d7dc583ebe952573808bca8;hp=9554ccbf41c8250e7a48305079cdcdcaf42ee5ab;hb=8a647e87a01c5c78451653c1264a9eea81ac9b20;hpb=6c664b09beef66ee4e223cf30fb17ecdd6889bf7 diff --git a/dali-toolkit/internal/controls/buttons/check-box-button-impl.cpp b/dali-toolkit/internal/controls/buttons/check-box-button-impl.cpp index 9554ccb..45c5057 100644 --- a/dali-toolkit/internal/controls/buttons/check-box-button-impl.cpp +++ b/dali-toolkit/internal/controls/buttons/check-box-button-impl.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016 Samsung Electronics Co., Ltd. + * Copyright (c) 2020 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -21,7 +21,6 @@ // EXTERNAL INCLUDES #include #include -#include //INTERNAL INCLUDES #include @@ -75,6 +74,10 @@ CheckBoxButton::CheckBoxButton() : Button() { SetTogglableButton( true ); + DevelControl::SetAccessibilityConstructor( Self(), []( Dali::Actor actor ) { + return std::unique_ptr< Dali::Accessibility::Accessible >( + new AccessibleImpl( actor, Dali::Accessibility::Role::CHECK_BOX ) ); + } ); } CheckBoxButton::~CheckBoxButton() @@ -86,6 +89,25 @@ void CheckBoxButton::OnInitialize() Button::OnInitialize(); } +Dali::Accessibility::States CheckBoxButton::AccessibleImpl::CalculateStates() +{ + auto tmp = Button::AccessibleImpl::CalculateStates(); + auto slf = Toolkit::Button::DownCast( self ); + if( slf.GetProperty( Toolkit::Button::Property::SELECTED ) ) + tmp[Dali::Accessibility::State::CHECKED] = true; + return tmp; +} + +void CheckBoxButton::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, newState == SELECTED_STATE ? 1 : 0, 0 + ); + } +} } // namespace Internal