src/hbcore/gui/hbscrollarea_p.cpp
changeset 28 b7da29130b0e
parent 23 e6ad4ef83b23
child 30 80e4d18b72f5
equal deleted inserted replaced
23:e6ad4ef83b23 28:b7da29130b0e
   267             mBoundaryReached = true;
   267             mBoundaryReached = true;
   268             if (mScrollFeedbackOngoing) {
   268             if (mScrollFeedbackOngoing) {
   269                 HbWidgetFeedback::triggered(q, Hb::InstantBoundaryReached);
   269                 HbWidgetFeedback::triggered(q, Hb::InstantBoundaryReached);
   270             }
   270             }
   271         }
   271         }
   272         stopScrolling(); 
   272         bool scrolled = currentPosition != newPosition;
       
   273         if (scrolled) {
       
   274             setContentPosition(-newPosition);
       
   275 
       
   276             if (mAbleToScrollX && mHorizontalScrollBar->isVisible()) {
       
   277                 updateScrollBar(Qt::Horizontal);
       
   278             }
       
   279             if (mAbleToScrollY && mVerticalScrollBar->isVisible()) {
       
   280                 updateScrollBar(Qt::Vertical);
       
   281             }
       
   282         }
       
   283 
       
   284         // if animating stopScrolling will be called from _q_animateScrollTimeout
       
   285         if (!mIsAnimating) {
       
   286             stopScrolling();
       
   287         }
       
   288 
   273         // must return here, otherwise mIsScrolling will be false
   289         // must return here, otherwise mIsScrolling will be false
   274         // below and scrollingStarted will be emitted
   290         // below and scrollingStarted will be emitted
   275         return currentPosition != newPosition;
   291         return scrolled;
   276     } else {
   292     } else {
   277         mBoundaryReached = false;
   293         mBoundaryReached = false;
   278     }
   294     }
   279 
   295 
   280     setContentPosition(-newPosition);
   296     setContentPosition(-newPosition);
   292         if (mAbleToScrollY && mVerticalScrollBarPolicy == HbScrollArea::ScrollBarAutoHide) {
   308         if (mAbleToScrollY && mVerticalScrollBarPolicy == HbScrollArea::ScrollBarAutoHide) {
   293             displayScrollBar(Qt::Vertical);
   309             displayScrollBar(Qt::Vertical);
   294         }
   310         }
   295         stopScrollbarHideTimer();
   311         stopScrollbarHideTimer();
   296 
   312 
   297     } else {
   313     }
   298 
   314 
   299         if (mAbleToScrollX && mHorizontalScrollBar->isVisible()) {
   315     if (mAbleToScrollX && mHorizontalScrollBar->isVisible()) {
   300             updateScrollBar(Qt::Horizontal);
   316         updateScrollBar(Qt::Horizontal);
   301         }
   317     }
   302 
   318     if (mAbleToScrollY && mVerticalScrollBar->isVisible()) {
   303         if (mAbleToScrollY && mVerticalScrollBar->isVisible()) {
   319         updateScrollBar(Qt::Vertical);
   304             updateScrollBar(Qt::Vertical);
   320     }
   305         }
   321 
   306     }
   322         //if we are here than content position has changed.i.e delta is not zero or
   307     //if we are here than content position has changed.i.e delta is not zero or
       
   308     //we havent reached the boundaries.
   323     //we havent reached the boundaries.
   309     return true;
   324     return true;
   310 }
   325 }
   311 
   326 
   312 void HbScrollAreaPrivate::animateScroll(QPointF speed)
   327 void HbScrollAreaPrivate::animateScroll(QPointF speed)
   898 }
   913 }
   899 
   914 
   900 void HbScrollAreaPrivate::displayScrollBar(Qt::Orientation orientation)
   915 void HbScrollAreaPrivate::displayScrollBar(Qt::Orientation orientation)
   901 {
   916 {
   902     Q_Q(HbScrollArea);
   917     Q_Q(HbScrollArea);
       
   918 
       
   919     // Layout the scrollbar
       
   920     setScrollBarMetrics(orientation);
       
   921 
   903     if (orientation == Qt::Horizontal) {
   922     if (orientation == Qt::Horizontal) {
   904 
       
   905         // Layout the scrollbar
       
   906         setScrollBarMetrics(orientation);
       
   907 
       
   908         // Activate the scrollbar
   923         // Activate the scrollbar
   909         if ( !mHorizontalScrollBar->isVisible() && q->isVisible()) {
   924         if ( !mHorizontalScrollBar->isVisible() && q->isVisible()) {
   910             mHorizontalScrollBar->setVisible(true);
   925             mHorizontalScrollBar->setVisible(true);
   911         }
   926         }
   912     }
   927     }
   913     else if (orientation == Qt::Vertical) {
   928     else if (orientation == Qt::Vertical) {
   914 
       
   915         // Layout the scrollbar
       
   916         setScrollBarMetrics(orientation);
       
   917 
       
   918         // Activate the scrollbar
   929         // Activate the scrollbar
   919         if ( !mVerticalScrollBar->isVisible() && q->isVisible()) {
   930         if ( !mVerticalScrollBar->isVisible() && q->isVisible()) {
   920             mVerticalScrollBar->setVisible(true);
   931             mVerticalScrollBar->setVisible(true);
   921         }
   932         }
   922     }
   933     }