X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=blobdiff_plain;f=dali-toolkit%2Finternal%2Fcontrols%2Fscroll-bar%2Fscroll-bar-impl.cpp;h=b1b09d1ecea9ebe17b09b6ae1fe04881c3a444d7;hp=c5884879e995c08c5f983175b6997e175ed60e3f;hb=f546dd5d83a968e573f8f053a01ce43df32c71a0;hpb=14455946a98df9b2f7cc5e9d5a972250da70a003 diff --git a/dali-toolkit/internal/controls/scroll-bar/scroll-bar-impl.cpp b/dali-toolkit/internal/controls/scroll-bar/scroll-bar-impl.cpp index c588487..b1b09d1 100644 --- a/dali-toolkit/internal/controls/scroll-bar/scroll-bar-impl.cpp +++ b/dali-toolkit/internal/controls/scroll-bar/scroll-bar-impl.cpp @@ -215,6 +215,11 @@ void ScrollBar::OnInitialize() { CreateDefaultIndicatorActor(); Self().SetProperty( Actor::Property::DRAW_MODE,DrawMode::OVERLAY_2D); + + DevelControl::SetAccessibilityConstructor( Self(), []( Dali::Actor actor ) { + return std::unique_ptr< Dali::Accessibility::Accessible >( + new AccessibleImpl( actor, Dali::Accessibility::Role::SCROLL_BAR ) ); + } ); } void ScrollBar::SetScrollPropertySource( Handle handle, Property::Index propertyScrollPosition, Property::Index propertyMinScrollPosition, Property::Index propertyMaxScrollPosition, Property::Index propertyScrollContentSize ) @@ -265,7 +270,7 @@ void ScrollBar::SetScrollIndicator( Actor indicator ) mIndicatorFirstShow = true; Self().Add( mIndicator ); - EnableGestureDetection( Gesture::Type( Gesture::Pan ) ); + EnableGestureDetection( GestureType::Value( GestureType::PAN ) ); PanGestureDetector detector( GetPanGestureDetector() ); detector.DetachAll(); @@ -461,7 +466,7 @@ void ScrollBar::OnPan( const PanGesture& gesture ) switch(gesture.GetState()) { - case Dali::Gesture::Started: + case Dali::GestureState::STARTED: { if( !mPanProcessTimer ) { @@ -478,7 +483,7 @@ void ScrollBar::OnPan( const PanGesture& gesture ) break; } - case Dali::Gesture::Continuing: + case Dali::GestureState::CONTINUING: { mGestureDisplacement += gesture.GetDisplacement(); @@ -689,7 +694,7 @@ void ScrollBar::SetProperty( BaseObject* object, Property::Index index, const Pr } case Toolkit::ScrollBar::Property::SCROLL_POSITION_INTERVALS: { - Property::Array* array = value.GetArray(); + const Property::Array* array = value.GetArray(); if( array ) { Dali::Vector positions; @@ -858,6 +863,50 @@ Toolkit::ScrollBar ScrollBar::New(Toolkit::ScrollBar::Direction direction) return handle; } +double ScrollBar::AccessibleImpl::GetMinimum() +{ + auto p = Toolkit::ScrollBar::DownCast( self ); + Handle scrollableHandle = GetImpl( p ).mScrollableObject.GetHandle(); + return scrollableHandle ? scrollableHandle.GetCurrentProperty< float >( GetImpl( p ).mPropertyMinScrollPosition ) : 0.0f; +} + +double ScrollBar::AccessibleImpl::GetCurrent() +{ + auto p = Toolkit::ScrollBar::DownCast( self ); + Handle scrollableHandle = GetImpl( p ).mScrollableObject.GetHandle(); + return scrollableHandle ? scrollableHandle.GetCurrentProperty< float >( GetImpl( p ).mPropertyScrollPosition ) : 0.0f; +} + +double ScrollBar::AccessibleImpl::GetMaximum() +{ + auto p = Toolkit::ScrollBar::DownCast( self ); + Handle scrollableHandle = GetImpl( p ).mScrollableObject.GetHandle(); + return scrollableHandle ? scrollableHandle.GetCurrentProperty< float >( GetImpl( p ).mPropertyMaxScrollPosition ) : 1.0f; +} + +bool ScrollBar::AccessibleImpl::SetCurrent( double current ) +{ + if( current < GetMinimum() || current > GetMaximum() ) + return false; + + auto value_before = GetCurrent(); + + auto p = Toolkit::ScrollBar::DownCast( self ); + Handle scrollableHandle = GetImpl( p ).mScrollableObject.GetHandle(); + if( !scrollableHandle ) + return false; + scrollableHandle.SetProperty( GetImpl( p ).mPropertyScrollPosition, static_cast< float >( current ) ); + + auto value_after = GetCurrent(); + + if( ( current != value_before ) && ( value_before == value_after ) ) + return false; + + return true; +} + +double ScrollBar::AccessibleImpl::GetMinimumIncrement() { return 1.0; } + } // namespace Internal } // namespace Toolkit