X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;ds=sidebyside;f=dali-toolkit%2Finternal%2Fcontrols%2Fbuttons%2Fcheck-box-button-impl.cpp;h=98733ea455dce629be2daabcee049ae7f3e6b075;hb=f4b327350bf7873847f8f08bb27d11361f60f759;hp=103992f1a7995640cc269c7123ddb66c0127b638;hpb=4be24b21c2acd28b5b14795afe57acbfdfd282ac;p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git 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 103992f..98733ea 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) 2020 Samsung Electronics Co., Ltd. + * Copyright (c) 2021 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. @@ -23,45 +23,38 @@ #include //INTERNAL INCLUDES -#include #include #include -#include +#include #if defined(DEBUG_ENABLED) - extern Debug::Filter* gLogButtonFilter; +extern Debug::Filter* gLogButtonFilter; #endif namespace Dali { - namespace Toolkit { - namespace Internal { - namespace { - BaseHandle Create() { return Toolkit::CheckBoxButton::New(); } -TypeRegistration mType( typeid(Toolkit::CheckBoxButton), typeid(Toolkit::Button), Create ); - - +TypeRegistration mType(typeid(Toolkit::CheckBoxButton), typeid(Toolkit::Button), Create); -} +} // namespace Dali::Toolkit::CheckBoxButton CheckBoxButton::New() { // Create the implementation, temporarily owned on stack - IntrusivePtr< CheckBoxButton > internalCheckBoxButton = new CheckBoxButton(); + IntrusivePtr internalCheckBoxButton = new CheckBoxButton(); // Pass ownership to CustomActor - Dali::Toolkit::CheckBoxButton checkBoxButton( *internalCheckBoxButton ); + Dali::Toolkit::CheckBoxButton checkBoxButton(*internalCheckBoxButton); // Second-phase init of the implementation // This can only be done after the CustomActor connection has been made... @@ -73,7 +66,7 @@ Dali::Toolkit::CheckBoxButton CheckBoxButton::New() CheckBoxButton::CheckBoxButton() : Button() { - SetTogglableButton( true ); + SetTogglableButton(true); } CheckBoxButton::~CheckBoxButton() @@ -84,29 +77,30 @@ void CheckBoxButton::OnInitialize() { Button::OnInitialize(); - DevelControl::SetAccessibilityConstructor( Self(), []( Dali::Actor actor ) { - return std::unique_ptr< Dali::Accessibility::Accessible >( - new AccessibleImpl( actor, Dali::Accessibility::Role::CHECK_BOX ) ); - } ); + DevelControl::SetAccessibilityConstructor(Self(), [](Dali::Actor actor) { + return std::unique_ptr( + new AccessibleImpl(actor, Dali::Accessibility::Role::CHECK_BOX)); + }); } 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; + auto state = Button::AccessibleImpl::CalculateStates(); + auto self = Toolkit::Button::DownCast(Self()); + if(self.GetProperty(Toolkit::Button::Property::SELECTED)) + { + state[Dali::Accessibility::State::CHECKED] = true; + } + return state; } -void CheckBoxButton::OnStateChange( State newState ) +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)) + if(Dali::Accessibility::IsUp() && (Dali::Accessibility::Accessible::GetCurrentlyHighlightedActor() == Self()) + && (newState == SELECTED_STATE || newState == UNSELECTED_STATE)) { - Dali::Accessibility::Accessible::Get(Self())->EmitStateChanged( - Dali::Accessibility::State::CHECKED, newState == SELECTED_STATE ? 1 : 0, 0 - ); + Dali::Accessibility::Accessible::Get(Self())->EmitStateChanged(Dali::Accessibility::State::CHECKED, newState == SELECTED_STATE ? 1 : 0, 0); } }