src/hbcore/gui/hbscrollbar.cpp
changeset 1 f7ac710697a9
parent 0 16d8024aca5e
child 2 06ff229162e9
equal deleted inserted replaced
0:16d8024aca5e 1:f7ac710697a9
    93 {
    93 {
    94 }
    94 }
    95 
    95 
    96 void HbScrollBarPrivate::init()
    96 void HbScrollBarPrivate::init()
    97 {
    97 {
       
    98     Q_Q(HbScrollBar);
       
    99     q->grabGesture(Qt::PanGesture);
       
   100     q->grabGesture(Qt::TapGesture);
    98 }
   101 }
    99 
   102 
   100 void HbScrollBarPrivate::createPrimitives()
   103 void HbScrollBarPrivate::createPrimitives()
   101 {
   104 {
   102     Q_Q(HbScrollBar);
   105     Q_Q(HbScrollBar);
   208         HbWidget(*new HbScrollBarPrivate, parent)
   211         HbWidget(*new HbScrollBarPrivate, parent)
   209 {
   212 {
   210     Q_D(HbScrollBar);
   213     Q_D(HbScrollBar);
   211     d->q_ptr = this;
   214     d->q_ptr = this;
   212     d->init();
   215     d->init();
   213     grabGesture(Qt::TapGesture);
       
   214     grabGesture(Qt::PanGesture);
       
   215 }
   216 }
   216 
   217 
   217 /*!
   218 /*!
   218     Constructs a scrollbar with \a orientation and \a parent.
   219     Constructs a scrollbar with \a orientation and \a parent.
   219 */
   220 */
   326 
   327 
   327     \sa HbScrollBar::value()
   328     \sa HbScrollBar::value()
   328 */
   329 */
   329 void HbScrollBar::setValue( qreal value )
   330 void HbScrollBar::setValue( qreal value )
   330 {
   331 {
   331     Q_D(HbScrollBar);
   332     Q_D(HbScrollBar);        
   332     if( value < 0.0 || value > 1.0 ) {
   333 
   333         qWarning( "HbScrollBar::setValue(%f) out of range 0.0-1.0", value );
   334     value = qBound(static_cast<qreal>(0.0), value, static_cast<qreal>(1.0));
   334         return;
       
   335     }
       
   336 
       
   337     if( !qFuzzyCompare(d->mCurrentPosition,value )) {
   335     if( !qFuzzyCompare(d->mCurrentPosition,value )) {
   338         d->mCurrentPosition = value;
   336         d->mCurrentPosition = value;
   339         d->updatePosition();
   337         d->updatePosition();
   340     }
   338     }
   341 }
   339 }
   349     \sa HbScrollBar::pageSize()
   347     \sa HbScrollBar::pageSize()
   350 */
   348 */
   351 void HbScrollBar::setPageSize( qreal size )
   349 void HbScrollBar::setPageSize( qreal size )
   352 {
   350 {
   353     Q_D(HbScrollBar);
   351     Q_D(HbScrollBar);
   354     if( size < 0.0 || size > 1.0 ) {
   352     size = qBound(static_cast<qreal>(0.0), size, static_cast<qreal>(1.0));
   355         qWarning( "HbScrollBar::setPageSize(%f) out of range 0.0-1.0", size );
       
   356         return;
       
   357     }
       
   358 
   353 
   359     if(!qFuzzyCompare(d->mPageSize,size)) {
   354     if(!qFuzzyCompare(d->mPageSize,size)) {
   360         d->mPageSize = size;
   355         d->mPageSize = size;
   361         d->sizeHelper();
   356         d->sizeHelper();
   362     }
   357     }
   449             d->repeatActionTimer.start(REPEATION_TIME, this);
   444             d->repeatActionTimer.start(REPEATION_TIME, this);
   450         } else {
   445         } else {
   451             HbWidgetFeedback::triggered(this, Hb::InstantPressed, Hb::ModifierSliderHandle);
   446             HbWidgetFeedback::triggered(this, Hb::InstantPressed, Hb::ModifierSliderHandle);
   452             initStyleOption(&opt);
   447             initStyleOption(&opt);
   453             style()->updatePrimitive(d->handleItem, HbStyle::P_ScrollBar_handle, &opt );
   448             style()->updatePrimitive(d->handleItem, HbStyle::P_ScrollBar_handle, &opt );
       
   449             emit d->core.handlePressed();
   454         }
   450         }
   455 
   451 
   456         break;
   452         break;
   457     case Qt::Vertical:
   453     case Qt::Vertical:
   458         d->mThumbPressed = (event->pos().y() >= d->handleItem->pos().y() &&
   454         d->mThumbPressed = (event->pos().y() >= d->handleItem->pos().y() &&
   474             d->repeatActionTimer.start(REPEATION_TIME, this);
   470             d->repeatActionTimer.start(REPEATION_TIME, this);
   475         } else {
   471         } else {
   476             HbWidgetFeedback::triggered(this, Hb::InstantPressed, Hb::ModifierSliderHandle);
   472             HbWidgetFeedback::triggered(this, Hb::InstantPressed, Hb::ModifierSliderHandle);
   477             initStyleOption(&opt);
   473             initStyleOption(&opt);
   478             style()->updatePrimitive(d->handleItem, HbStyle::P_ScrollBar_handle, &opt );
   474             style()->updatePrimitive(d->handleItem, HbStyle::P_ScrollBar_handle, &opt );
       
   475             emit d->core.handlePressed();
   479         }
   476         }
   480 
   477 
   481         break;
   478         break;
   482     }
   479     }
   483     event->accept();
   480     event->accept();
   497     HbStyleOptionScrollBar opt;
   494     HbStyleOptionScrollBar opt;
   498     if (d->mThumbPressed) {
   495     if (d->mThumbPressed) {
   499         d->mThumbPressed = false;
   496         d->mThumbPressed = false;
   500         HbWidgetFeedback::triggered(this, Hb::InstantReleased, Hb::ModifierSliderHandle);
   497         HbWidgetFeedback::triggered(this, Hb::InstantReleased, Hb::ModifierSliderHandle);
   501         emit valueChanged(value(), orientation());
   498         emit valueChanged(value(), orientation());
       
   499         emit d->core.handleReleased();
   502         initStyleOption(&opt);
   500         initStyleOption(&opt);
   503         style()->updatePrimitive(d->handleItem, HbStyle::P_ScrollBar_handle, &opt );
   501         style()->updatePrimitive(d->handleItem, HbStyle::P_ScrollBar_handle, &opt );
   504     } else if (d->mGroovePressed){
   502     } else if (d->mGroovePressed){
   505         HbWidgetFeedback::triggered(this, Hb::InstantReleased);
   503         HbWidgetFeedback::triggered(this, Hb::InstantReleased);
   506         d->repeatActionTimer.stop();
   504         d->repeatActionTimer.stop();