[AT-SPI] Fix role setting
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / internal / controls / scroll-bar / scroll-bar-impl.cpp
index c588487..b1b09d1 100644 (file)
@@ -215,6 +215,11 @@ void ScrollBar::OnInitialize()
 {
   CreateDefaultIndicatorActor();
   Self().SetProperty( Actor::Property::DRAW_MODE,DrawMode::OVERLAY_2D);
 {
   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 )
 }
 
 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 );
 
     mIndicatorFirstShow = true;
     Self().Add( mIndicator );
 
-    EnableGestureDetection( Gesture::Type( Gesture::Pan ) );
+    EnableGestureDetection( GestureType::Value( GestureType::PAN ) );
 
     PanGestureDetector detector( GetPanGestureDetector() );
     detector.DetachAll();
 
     PanGestureDetector detector( GetPanGestureDetector() );
     detector.DetachAll();
@@ -461,7 +466,7 @@ void ScrollBar::OnPan( const PanGesture& gesture )
 
     switch(gesture.GetState())
     {
 
     switch(gesture.GetState())
     {
-      case Dali::Gesture::Started:
+      case Dali::GestureState::STARTED:
       {
         if( !mPanProcessTimer )
         {
       {
         if( !mPanProcessTimer )
         {
@@ -478,7 +483,7 @@ void ScrollBar::OnPan( const PanGesture& gesture )
 
         break;
       }
 
         break;
       }
-      case Dali::Gesture::Continuing:
+      case Dali::GestureState::CONTINUING:
       {
         mGestureDisplacement += gesture.GetDisplacement();
 
       {
         mGestureDisplacement += gesture.GetDisplacement();
 
@@ -689,7 +694,7 @@ void ScrollBar::SetProperty( BaseObject* object, Property::Index index, const Pr
       }
       case Toolkit::ScrollBar::Property::SCROLL_POSITION_INTERVALS:
       {
       }
       case Toolkit::ScrollBar::Property::SCROLL_POSITION_INTERVALS:
       {
-        Property::Array* array = value.GetArray();
+        const Property::Array* array = value.GetArray();
         if( array )
         {
           Dali::Vector<float> positions;
         if( array )
         {
           Dali::Vector<float> positions;
@@ -858,6 +863,50 @@ Toolkit::ScrollBar ScrollBar::New(Toolkit::ScrollBar::Direction direction)
   return handle;
 }
 
   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
 } // namespace Internal
 
 } // namespace Toolkit