X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=dali-toolkit%2Finternal%2Fcontrols%2Fbuttons%2Fpush-button-impl.cpp;h=70e7261514c922f012750c1e99af4dc54c3fc117;hb=HEAD;hp=2dc4385f19794dc2daf4f84fc8b1cb035953b513;hpb=92cbca2f5bd2e15fa589448d4c884b71f4fef03c;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 2dc4385..70e7261 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,27 +196,28 @@ Property::Value PushButton::GetProperty(BaseObject* object, Property::Index prop return value; } -Dali::Accessibility::States PushButton::AccessibleImpl::CalculateStates() +Dali::Accessibility::States PushButton::PushButtonAccessible::CalculateStates() { - auto tmp = Button::AccessibleImpl::CalculateStates(); - auto slf = Toolkit::Button::DownCast(Self()); - tmp[Dali::Accessibility::State::PRESSED] = slf.GetProperty(Toolkit::Button::Property::SELECTED); - return tmp; + auto state = Button::ButtonAccessible::CalculateStates(); + auto self = Toolkit::Button::DownCast(Self()); + state[Dali::Accessibility::State::PRESSED] = self.GetProperty(Toolkit::Button::Property::SELECTED); + return state; } 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(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) && accessible->IsHighlighted()) { - 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); + } } } }