X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=blobdiff_plain;f=dali-toolkit%2Finternal%2Fcontrols%2Fslider%2Fslider-impl.cpp;h=fdbbbd9307f84040c9594112dc19ec69505ad3bc;hp=8cac5edfbc7ed07171ae60e6c4d503b58459698f;hb=HEAD;hpb=fa3f750c6878eb126034d7958458dc3a1f67924f diff --git a/dali-toolkit/internal/controls/slider/slider-impl.cpp b/dali-toolkit/internal/controls/slider/slider-impl.cpp index 8cac5ed..20b498c 100644 --- a/dali-toolkit/internal/controls/slider/slider-impl.cpp +++ b/dali-toolkit/internal/controls/slider/slider-impl.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Samsung Electronics Co., Ltd. + * Copyright (c) 2024 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. @@ -202,16 +202,17 @@ void Slider::OnInitialize() // Size the Slider actor to a default self.SetProperty(Actor::Property::SIZE, Vector2(DEFAULT_HIT_REGION.x, DEFAULT_HIT_REGION.y)); - // Set the Slider to be highlightable in Screen Reader mode - self.SetProperty(Toolkit::DevelControl::Property::ACCESSIBILITY_HIGHLIGHTABLE, true); - // Connect to the touch signal self.TouchedSignal().Connect(this, &Slider::OnTouch); - DevelControl::SetAccessibilityConstructor(self, [](Dali::Actor actor) { - return std::unique_ptr( - new AccessibleImpl(actor, Dali::Accessibility::Role::SLIDER)); - }); + // Accessibility + self.SetProperty(DevelControl::Property::ACCESSIBILITY_ROLE, Dali::Accessibility::Role::SLIDER); + self.SetProperty(DevelControl::Property::ACCESSIBILITY_HIGHLIGHTABLE, true); +} + +DevelControl::ControlAccessible* Slider::CreateAccessibleObject() +{ + return new SliderAccessible(Self()); } void Slider::OnRelayout(const Vector2& size, RelayoutContainer& container) @@ -861,14 +862,16 @@ float Slider::SnapToMark(float value) for(MarkList::SizeType i = 0; i < mMarks.Count(); ++i) { const Property::Value& propertyValue = mMarks[i]; - propertyValue.Get(mark); - mark = MapValuePercentage(mark); - - float dist = fabsf(mark - value); - if(dist < closestDist) + if(propertyValue.Get(mark)) { - closestDist = dist; - closestMark = mark; + mark = MapValuePercentage(mark); + + float dist = fabsf(mark - value); + if(dist < closestDist) + { + closestDist = dist; + closestMark = mark; + } } } @@ -890,22 +893,24 @@ bool Slider::MarkReached(float value, int& outIndex) current = head + (tail - head) / 2; const Property::Value& propertyValue = mMarks[current]; - propertyValue.Get(mark); - mark = MapValuePercentage(mark); - - if(fabsf(mark - value) < MARK_TOLERANCE) + if(propertyValue.Get(mark)) { - outIndex = current; - return true; - } + mark = MapValuePercentage(mark); - if(value < mark) - { - tail = current - 1; - } - else - { - head = current + 1; + if(fabsf(mark - value) < MARK_TOLERANCE) + { + outIndex = current; + return true; + } + + if(value < mark) + { + tail = current - 1; + } + else + { + head = current + 1; + } } } @@ -948,9 +953,11 @@ void Slider::SetValue(float value) { mValue = value; DisplayValue(mValue, true); - if(Self() == Dali::Accessibility::Accessible::GetCurrentlyHighlightedActor()) + + auto accessible = GetAccessibleObject(); + if(DALI_LIKELY(accessible) && accessible->IsHighlighted()) { - Control::Impl::GetAccessibilityObject(Self())->Emit(Dali::Accessibility::ObjectPropertyChangeEvent::VALUE); + accessible->Emit(Dali::Accessibility::ObjectPropertyChangeEvent::VALUE); } } @@ -1411,30 +1418,35 @@ Property::Value Slider::GetProperty(BaseObject* object, Property::Index property return value; } -double Slider::AccessibleImpl::GetMinimum() +double Slider::SliderAccessible::GetMinimum() const { auto self = Toolkit::Slider::DownCast(Self()); return self.GetProperty(Toolkit::Slider::Property::LOWER_BOUND).Get(); } -double Slider::AccessibleImpl::GetCurrent() +double Slider::SliderAccessible::GetCurrent() const { auto self = Toolkit::Slider::DownCast(Self()); return self.GetProperty(Toolkit::Slider::Property::VALUE).Get(); } -double Slider::AccessibleImpl::GetMaximum() +std::string Slider::SliderAccessible::GetValueText() const +{ + return {}; // Text mode is not used at the moment +} + +double Slider::SliderAccessible::GetMaximum() const { auto self = Toolkit::Slider::DownCast(Self()); return self.GetProperty(Toolkit::Slider::Property::UPPER_BOUND).Get(); } -bool Slider::AccessibleImpl::SetCurrent(double current) +bool Slider::SliderAccessible::SetCurrent(double current) { if(current < GetMinimum() || current > GetMaximum()) return false; - auto self = Toolkit::Slider::DownCast(Self()); + auto self = Toolkit::Slider::DownCast(Self()); auto& impl = Toolkit::GetImpl(self); const float prev = self.GetProperty(Toolkit::Slider::Property::VALUE); @@ -1477,7 +1489,7 @@ bool Slider::AccessibleImpl::SetCurrent(double current) return true; } -double Slider::AccessibleImpl::GetMinimumIncrement() +double Slider::SliderAccessible::GetMinimumIncrement() const { auto self = Toolkit::Slider::DownCast(Self());