X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=dali-toolkit%2Finternal%2Fcontrols%2Fbuttons%2Fcheck-box-button-impl.cpp;h=8308ce1665891040196254486bd3b762b184a49d;hb=8135447dde34dce2e12480c1290f48a4d1dfa702;hp=9c898c777a3ecf8ab57b4bfde24e14b2819a491a;hpb=87f440c3d0367ca5a7027eef8d01d79b8703cf05;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 9c898c7..8308ce1 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) 2014 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. @@ -19,39 +19,42 @@ #include "check-box-button-impl.h" // EXTERNAL INCLUDES +#include #include -// INTERNAL INCLUDES -#include "check-box-button-default-painter-impl.h" +//INTERNAL INCLUDES +#include +#include +#include + +#if defined(DEBUG_ENABLED) +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... @@ -63,16 +66,41 @@ Dali::Toolkit::CheckBoxButton CheckBoxButton::New() CheckBoxButton::CheckBoxButton() : Button() { - // Creates specific painter. - ButtonPainterPtr painter = new CheckBoxButtonDefaultPainter(); - SetPainter( painter ); - - SetTogglableButton( true ); + SetTogglableButton(true); } CheckBoxButton::~CheckBoxButton() { - SetPainter( NULL ); +} + +void CheckBoxButton::OnInitialize() +{ + Button::OnInitialize(); + + 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; +} + +void CheckBoxButton::OnStateChange(State newState) +{ + // 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