X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=dali-toolkit%2Finternal%2Fcontrols%2Fbuttons%2Fcheck-box-button-impl.cpp;h=3fcaae26aa0667ef9ef9a350dfcb24d59087ae25;hb=9c1f4310db72879676b5aca2875fbf67b97a4b0a;hp=b8907f0daf794fccfc5ead1e781105e841e334b3;hpb=e5dbcae1f8ee31b14d675793ab86161eeeefb029;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 b8907f0..3fcaae2 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) 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. @@ -21,50 +21,40 @@ // EXTERNAL INCLUDES #include #include -#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 { - -const float ANIMATION_TIME( 0.26f ); // EFL checkbox tick time - Will be replaced by stylable tranisitions - 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... @@ -76,55 +66,41 @@ Dali::Toolkit::CheckBoxButton CheckBoxButton::New() CheckBoxButton::CheckBoxButton() : Button() { - SetTogglableButton( true ); - - SetAnimationTime( ANIMATION_TIME ); + SetTogglableButton(true); } CheckBoxButton::~CheckBoxButton() { } -void CheckBoxButton::FadeImageTo( Actor actor , float opacity ) -{ - if( actor ) - { - Dali::Animation transitionAnimation = GetTransitionAnimation(); - - if( transitionAnimation ) - { - transitionAnimation.AnimateTo( Property( actor, Actor::Property::COLOR_ALPHA ), opacity ); - } - } -} - void CheckBoxButton::OnInitialize() { Button::OnInitialize(); -} -void CheckBoxButton::PrepareForTransitionIn( Actor actor ) -{ - // Set Toolkit::Button::Property::SELECTED_VISUAL and Toolkit::Button::Property::UNSELECTED_VISUAL to opacity 0 - // Then get and start animation + DevelControl::SetAccessibilityConstructor(Self(), [](Dali::Actor actor) { + return std::make_unique(actor, Dali::Accessibility::Role::CHECK_BOX); + }); } -void CheckBoxButton::PrepareForTransitionOut( Actor actor ) +Dali::Accessibility::States CheckBoxButton::CheckBoxButtonAccessible::CalculateStates() { - // Set Toolkit::Button::Property::SELECTED_VISUAL and Toolkit::Button::Property::UNSELECTED_VISUAL to opacity 1 - // Then get and start animation -} - -void CheckBoxButton::OnTransitionIn( Actor actor ) -{ - // Only transition selected and unselected visual, background doesn't change. - // Start Fade animation to 1 + auto state = Button::ButtonAccessible::CalculateStates(); + auto self = Toolkit::Button::DownCast(Self()); + if(self.GetProperty(Toolkit::Button::Property::SELECTED)) + { + state[Dali::Accessibility::State::CHECKED] = true; + } + return state; } -void CheckBoxButton::OnTransitionOut( Actor actor ) +void CheckBoxButton::OnStateChange(State newState) { - // Only transition selected and unselected visual, background doesn't change. - // Start Fade animation to 0 + // TODO: replace it with OnPropertySet hook once Button::Property::SELECTED will be consistently used + 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); + } } } // namespace Internal