X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=dali-toolkit%2Finternal%2Fcontrols%2Fbuttons%2Fpush-button-impl.cpp;h=dea0ee03935b842f03b1e799965ef3da1d59ad52;hb=refs%2Fchanges%2F06%2F301106%2F9;hp=2958766945d4b9381aa6ffdf645082ea377541fb;hpb=8e3fd25cab9b478aa0d0668d0a186b6fa93c10f6;p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git diff --git a/dali-toolkit/internal/controls/buttons/push-button-impl.cpp b/dali-toolkit/internal/controls/buttons/push-button-impl.cpp index 2958766..dea0ee0 100644 --- a/dali-toolkit/internal/controls/buttons/push-button-impl.cpp +++ b/dali-toolkit/internal/controls/buttons/push-button-impl.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Samsung Electronics Co., Ltd. + * Copyright (c) 2023 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. @@ -95,10 +95,12 @@ void PushButton::OnInitialize() Actor self = Self(); self.SetProperty(Actor::Property::LEAVE_REQUIRED, true); - DevelControl::SetAccessibilityConstructor(self, [](Dali::Actor actor) { - return std::unique_ptr( - new AccessibleImpl(actor, Dali::Accessibility::Role::PUSH_BUTTON)); - }); + self.SetProperty(DevelControl::Property::ACCESSIBILITY_ROLE, Dali::Accessibility::Role::PUSH_BUTTON); +} + +DevelControl::ControlAccessible* PushButton::CreateAccessibleObject() +{ + return new PushButtonAccessible(Self()); } void PushButton::SetIconAlignment(const PushButton::IconAlignment iconAlignment) @@ -194,10 +196,10 @@ Property::Value PushButton::GetProperty(BaseObject* object, Property::Index prop return value; } -Dali::Accessibility::States PushButton::AccessibleImpl::CalculateStates() +Dali::Accessibility::States PushButton::PushButtonAccessible::CalculateStates() { - auto state = Button::AccessibleImpl::CalculateStates(); - auto self = Toolkit::Button::DownCast(Self()); + auto state = Button::ButtonAccessible::CalculateStates(); + auto self = Toolkit::Button::DownCast(Self()); state[Dali::Accessibility::State::PRESSED] = self.GetProperty(Toolkit::Button::Property::SELECTED); return state; } @@ -205,14 +207,17 @@ Dali::Accessibility::States PushButton::AccessibleImpl::CalculateStates() void PushButton::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)) + if((Dali::Accessibility::Accessible::GetCurrentlyHighlightedActor() == Self()) && (newState == SELECTED_STATE || newState == UNSELECTED_STATE)) { - Dali::Accessibility::Accessible::Get(Self())->EmitStateChanged(Dali::Accessibility::State::PRESSED, newState == SELECTED_STATE ? 1 : 0, 0); - - if(Self().GetProperty(Toolkit::Button::Property::TOGGLABLE)) + auto* accessible = GetAccessibleObject(); + if(DALI_LIKELY(accessible)) { - Dali::Accessibility::Accessible::Get(Self())->EmitStateChanged(Dali::Accessibility::State::CHECKED, newState == SELECTED_STATE ? 1 : 0, 0); + accessible->EmitStateChanged(Dali::Accessibility::State::PRESSED, newState == SELECTED_STATE ? 1 : 0, 0); + + if(Self().GetProperty(Toolkit::Button::Property::TOGGLABLE)) + { + accessible->EmitStateChanged(Dali::Accessibility::State::CHECKED, newState == SELECTED_STATE ? 1 : 0, 0); + } } } }