39 #include "hbeffectinternal_p.h" |
40 #include "hbeffectinternal_p.h" |
40 bool HbScrollBarPrivate::effectsLoaded = false; |
41 bool HbScrollBarPrivate::effectsLoaded = false; |
41 #endif |
42 #endif |
42 |
43 |
43 static const int REPEATION_TIME = 500; |
44 static const int REPEATION_TIME = 500; |
44 static const qreal THRESHOLD_VALUE = 2.0; |
45 static const qreal THRESHOLD_VALUE = 4.0; |
45 /*! |
46 /*! |
46 @stable |
47 @stable |
47 @hbcore |
48 @hbcore |
48 \class HbScrollBar |
49 \class HbScrollBar |
49 \brief HbScrollBar represents a scrollbar that can be used in different kinds of lists, options |
50 \brief The HbScrollBar class provides a vertical or horizontal scroll bar. |
50 menus and editors. |
51 |
51 |
52 Scroll bars indicate that more content is available than can fit within a container and |
52 A vertical scrollbar is created in this example to listview-parent and also shown: |
53 that the contents can be scrolled. A scroll bar consists of a groove and a handle (which |
|
54 is sometimes called a thumb). The position of the handle on the groove indicates the |
|
55 position of the visible content within the available contents. The size of the handle |
|
56 indicates the amount of content that is visible relative to the total. For example, a |
|
57 small handle indicates that there is a lot more content that is out of view. |
|
58 |
|
59 Scroll bars float above the content and do not need reserved space. There are two types of |
|
60 scroll bar: |
|
61 |
|
62 - <b>Indicative</b>. These scroll bars simply give an indication that the content can be |
|
63 scrolled and they do not provide features that enable scrolling (the ability to scroll |
|
64 is provided by the widget to which the scroll bar is attached). Indicative scroll bars are |
|
65 suitable for shorter lists and content that you expect the user to browse rather than to |
|
66 search for specific items. This is the default type of scroll bar. |
|
67 |
|
68 - <b>Interactive</b>. With this type of scroll bar, the user can drag the handle or press the |
|
69 groove to change the scroll position. When used in an item model view (classes derived |
|
70 from HbAbstractItemView), these scroll bars can provide index feedback (HbIndexFeedback |
|
71 class) when the user drags the scroll bar or taps on the groove. The feedback is a popup |
|
72 that shows, for example, the initial letter in an alphabetical list. Interactive scroll bars |
|
73 are particularly suitable for long lists. |
|
74 |
|
75 Call \link HbScrollBar::setInteractive() setInteractive(true)\endlink to make a scroll bar |
|
76 interactive. Call isInteractive() to discover whether a scroll bar is interactive. |
|
77 |
|
78 \image html hbscrollbar.png A list view with a vertical interactive scroll bar |
|
79 |
|
80 %HbScrollBar provides other properties that control the following aspects of a scroll bar: |
|
81 |
|
82 - <b>Value</b>. This is a real value in the range 0.0 to 1.0 that indicates how far the handle |
|
83 is from the start of the groove. For example, 0.5 means the handle is half way along the |
|
84 groove. Call setValue() to set this property. |
|
85 |
|
86 - <b>Page size</b>. This is a real value in the range 0.0 to 1.0 that indicates how much of the |
|
87 total contents are currently visible. This property also controls the size of the handle. |
|
88 For example, a page size of 0.1 indicates that one out of ten pages are visible. Call |
|
89 setPageSize() to set this property. |
|
90 |
|
91 - <b>Orientation</b>. This controls whether the scroll bar is horizontal or vertical. Call |
|
92 setOrientation() to set this property. |
|
93 |
|
94 \section _usecases_hbscrollbar Using the HbScrollBar class |
|
95 |
|
96 Although it is possible to create an HbScrollBar object directly, scroll bars are created |
|
97 automatically when you create an HbScrollArea object or one of the item view classes that |
|
98 are derived from it. This example demonstrates changing the default scroll bars |
|
99 created for an HbScrollArea object from indicative to interactive: |
53 |
100 |
54 \code |
101 \code |
55 //HbListView *listView is defined already |
102 scrollArea->verticalScrollBar()->setInteractive(true); |
56 HbScrollBar *scrollbar = new HbScrollBar(Qt::Vertical, listView); |
103 scrollArea->horizontalScrollBar()->setInteractive(true); |
57 scrollbar->show(); |
|
58 \endcode |
104 \endcode |
59 |
105 |
60 By default scrollbar is hidden. |
106 You can replace the existing scroll bars by calling HbScrollArea::setHorizontalScrollBar() |
61 */ |
107 and HbScrollArea::setVerticalScrollBar(). |
62 |
108 |
63 /*! |
109 \sa HbScrollArea, HbAbstractItemView, HbIndexFeedback |
64 \reimp |
110 */ |
|
111 |
|
112 /*! |
65 \fn int HbScrollBar::type() const |
113 \fn int HbScrollBar::type() const |
66 */ |
114 */ |
67 |
115 |
68 /*! |
116 /*! |
69 \fn void HbScrollBar::valueChanged( qreal value, Qt::Orientation orientation ) |
117 \fn void HbScrollBar::valueChanged( qreal value, Qt::Orientation orientation ); |
70 |
118 |
71 This signal is emitted when thumb position is changed by the user. |
119 This signal is emitted when the user changes the position of the handle in an interactive |
72 */ |
120 scroll bar. |
73 |
121 */ |
74 /*! |
122 |
75 \fn void valueChangeRequested( qreal value, Qt::Orientation orientation ); |
123 /*! |
76 |
124 \fn void HbScrollBar::valueChangeRequested( qreal value, Qt::Orientation orientation ); |
77 This signal is emitted when the user presses scrollbar groove. |
125 |
78 |
126 This signal is emitted when the user presses an interactive scroll bar's groove. The widget |
79 \param value, the new value of scrollbar after the change |
127 using the scroll bar must handle this signal (for example, by providing an animation that |
80 */ |
128 scrolls to the target position). |
|
129 |
|
130 \param value The value to which the user wants to scroll. |
|
131 \param orientation The scroll bar's orientation. |
|
132 |
|
133 \sa HbScrollBar::setInteractive() |
|
134 */ |
81 |
135 |
82 /*! |
136 /*! |
83 \primitives |
137 \primitives |
84 \primitive{groove} HbFrameItem representing the groove of a scrollbar. |
138 \primitive{groove} HbFrameItem representing the groove of a scroll bar. |
85 \primitive{handle} HbFrameItem representing the handle of a scrollbar. |
139 \primitive{handle} HbFrameItem representing the handle of a scroll bar. |
86 \primitive{toucharea} HbTouchArea representing the scrollbar toucharea. |
140 \primitive{toucharea} HbTouchArea representing the scroll bar toucharea. |
87 */ |
141 */ |
|
142 |
|
143 static const int TOUCHAREA_ZVALUE = 1000; |
88 |
144 |
89 HbScrollBarPrivate::HbScrollBarPrivate(): |
145 HbScrollBarPrivate::HbScrollBarPrivate(): |
90 mOrientation(Qt::Vertical), |
146 mOrientation(Qt::Vertical), |
91 mCurrentPosition(0.5), |
147 mCurrentPosition(0.5), |
92 mPageSize(1.0), |
148 mPageSize(1.0), |
110 } |
167 } |
111 |
168 |
112 void HbScrollBarPrivate::init() |
169 void HbScrollBarPrivate::init() |
113 { |
170 { |
114 Q_Q(HbScrollBar); |
171 Q_Q(HbScrollBar); |
115 q->grabGesture(Qt::PanGesture); |
172 q->setFlag(QGraphicsItem::ItemHasNoContents, true); |
116 q->grabGesture(Qt::TapGesture); |
|
117 } |
173 } |
118 |
174 |
119 void HbScrollBarPrivate::createPrimitives() |
175 void HbScrollBarPrivate::createPrimitives() |
120 { |
176 { |
121 Q_Q(HbScrollBar); |
177 Q_Q(HbScrollBar); |
122 |
178 |
123 if ( !grooveItem ) { |
179 if ( !grooveItem ) { |
124 grooveItem = q->style()->createPrimitive( HbStyle::P_ScrollBar_groove, q ); |
180 grooveItem = q->style()->createPrimitive(HbStyle::PT_FrameItem, "groove", q); |
125 grooveItem->setZValue(2); |
181 grooveItem->setZValue(2); |
126 HbStyle::setItemName( grooveItem, "groove" ); |
182 } |
127 } |
|
128 |
|
129 if ( !handleItem ) { |
183 if ( !handleItem ) { |
130 handleItem = q->style()->createPrimitive( HbStyle::P_ScrollBar_handle, q ); |
184 handleItem = q->style()->createPrimitive(HbStyle::PT_FrameItem, "handle", q); |
131 handleItem->setZValue(3); |
185 handleItem->setZValue(3); |
132 HbStyle::setItemName( handleItem, "handle" ); |
|
133 } |
186 } |
134 if( !mTouchArea ) { |
187 if( !mTouchArea ) { |
135 mTouchArea = q->style()->createPrimitive(HbStyle::P_ScrollBar_toucharea, q); |
188 mTouchArea = q->style()->createPrimitive(HbStyle::PT_TouchArea, "toucharea", q); |
|
189 mTouchArea->setFlags(QGraphicsItem::ItemIsFocusable); |
136 } |
190 } |
137 q->updatePrimitives(); |
191 q->updatePrimitives(); |
138 } |
192 } |
139 |
193 |
140 void HbScrollBarPrivate::updatePosition() |
194 void HbScrollBarPrivate::updatePosition() |
177 updatePosition(); |
231 updatePosition(); |
178 } |
232 } |
179 } |
233 } |
180 } |
234 } |
181 |
235 |
|
236 void HbScrollBarPrivate::groovePrimitiveData(HbStyleFramePrimitiveData *data) |
|
237 { |
|
238 if (mInteractive) { |
|
239 if (mGroovePressed) { |
|
240 if (mOrientation == Qt::Vertical) { |
|
241 data->frameType = HbFrameDrawer::ThreePiecesVertical; |
|
242 data->frameGraphicsName = QLatin1String("qtg_fr_scroll_v_active_frame_pressed"); |
|
243 } else { |
|
244 data->frameType = HbFrameDrawer::ThreePiecesHorizontal; |
|
245 data->frameGraphicsName = QLatin1String("qtg_fr_scroll_h_active_frame_pressed"); |
|
246 } |
|
247 } else { |
|
248 if (mOrientation == Qt::Vertical) { |
|
249 data->frameType = HbFrameDrawer::ThreePiecesVertical; |
|
250 data->frameGraphicsName = QLatin1String("qtg_fr_scroll_v_active_frame_normal"); |
|
251 } else { |
|
252 data->frameType = HbFrameDrawer::ThreePiecesHorizontal; |
|
253 data->frameGraphicsName = QLatin1String("qtg_fr_scroll_h_active_frame_normal"); |
|
254 } |
|
255 } |
|
256 } else { |
|
257 if (mOrientation == Qt::Vertical) { |
|
258 data->frameType = HbFrameDrawer::ThreePiecesVertical; |
|
259 data->frameGraphicsName = QLatin1String("qtg_fr_scroll_v_frame"); |
|
260 } else { |
|
261 data->frameType = HbFrameDrawer::ThreePiecesHorizontal; |
|
262 data->frameGraphicsName = QLatin1String("qtg_fr_scroll_h_frame"); |
|
263 } |
|
264 } |
|
265 data->fillWholeRect = true; |
|
266 } |
|
267 |
|
268 void HbScrollBarPrivate::handlePrimitiveData(HbStyleFramePrimitiveData *data) |
|
269 { |
|
270 if (mInteractive) { |
|
271 if (mThumbPressed) { |
|
272 if (mOrientation == Qt::Vertical) { |
|
273 data->frameType = HbFrameDrawer::ThreePiecesVertical; |
|
274 data->frameGraphicsName = QLatin1String("qtg_fr_scroll_v_active_handle_pressed"); |
|
275 } else { |
|
276 data->frameType = HbFrameDrawer::ThreePiecesHorizontal; |
|
277 data->frameGraphicsName = QLatin1String("qtg_fr_scroll_h_active_handle_pressed"); |
|
278 } |
|
279 } else { |
|
280 if (mOrientation == Qt::Vertical) { |
|
281 data->frameType = HbFrameDrawer::ThreePiecesVertical; |
|
282 data->frameGraphicsName = QLatin1String("qtg_fr_scroll_v_active_handle_normal"); |
|
283 } else { |
|
284 data->frameType = HbFrameDrawer::ThreePiecesHorizontal; |
|
285 data->frameGraphicsName = QLatin1String("qtg_fr_scroll_h_active_handle_normal"); |
|
286 } |
|
287 } |
|
288 } else { |
|
289 if (mOrientation == Qt::Vertical) { |
|
290 data->frameType = HbFrameDrawer::ThreePiecesVertical; |
|
291 data->frameGraphicsName = QLatin1String("qtg_fr_scroll_v_handle"); |
|
292 } else { |
|
293 data->frameType = HbFrameDrawer::ThreePiecesHorizontal; |
|
294 data->frameGraphicsName = QLatin1String("qtg_fr_scroll_h_handle"); |
|
295 } |
|
296 } |
|
297 data->fillWholeRect = true; |
|
298 } |
|
299 |
182 void HbScrollBarPrivate::loadEffects() |
300 void HbScrollBarPrivate::loadEffects() |
183 { |
301 { |
184 #if defined(HB_EFFECTS) |
302 #if defined(HB_EFFECTS) |
185 if (effectsLoaded) |
303 if (effectsLoaded) |
186 return; |
304 return; |
220 } |
338 } |
221 #endif |
339 #endif |
222 } |
340 } |
223 |
341 |
224 /*! |
342 /*! |
225 Constructs a scrollbar with \a parent. |
343 Constructs a scroll bar with the given \a parent. |
226 */ |
344 */ |
227 HbScrollBar::HbScrollBar( QGraphicsItem *parent ) : |
345 HbScrollBar::HbScrollBar( QGraphicsItem *parent ) : |
228 HbWidget(*new HbScrollBarPrivate, parent) |
346 HbWidget(*new HbScrollBarPrivate, parent) |
229 { |
347 { |
230 Q_D(HbScrollBar); |
348 Q_D(HbScrollBar); |
231 d->q_ptr = this; |
349 d->q_ptr = this; |
232 d->init(); |
350 d->init(); |
233 } |
351 } |
234 |
352 |
235 /*! |
353 /*! |
236 Constructs a scrollbar with \a orientation and \a parent. |
354 Constructs a scroll bar with the given \a orientation and \a parent. |
237 */ |
355 */ |
238 HbScrollBar::HbScrollBar( Qt::Orientation orientation, QGraphicsItem *parent ) : |
356 HbScrollBar::HbScrollBar( Qt::Orientation orientation, QGraphicsItem *parent ) : |
239 HbWidget( *new HbScrollBarPrivate, parent ) |
357 HbWidget( *new HbScrollBarPrivate, parent ) |
240 { |
358 { |
241 Q_D(HbScrollBar); |
359 Q_D(HbScrollBar); |
242 d->q_ptr = this; |
360 d->q_ptr = this; |
243 d->mOrientation = orientation; |
361 d->mOrientation = orientation; |
244 d->init(); |
362 d->init(); |
245 } |
363 } |
246 |
364 |
247 /*! |
365 /*! |
248 Destructor |
366 Destructor. |
249 */ |
367 */ |
250 HbScrollBar::~HbScrollBar() |
368 HbScrollBar::~HbScrollBar() |
251 { |
369 { |
252 } |
370 } |
253 |
371 |
254 /*! |
372 /*! |
255 Returns the value of the scrollbar. The value is in range of 0.0 to 1.0. |
373 Returns the scroll bar's \c value property. This indicates how far the handle is |
256 The value corresponds to the position of the thumb. |
374 from the start of the groove and can be in range of 0.0 to 1.0. |
257 |
375 |
258 \sa HbScrollBar::setValue() |
376 \sa HbScrollBar::setValue() |
259 */ |
377 */ |
260 qreal HbScrollBar::value() const |
378 qreal HbScrollBar::value() const |
261 { |
379 { |
262 Q_D( const HbScrollBar ); |
380 Q_D( const HbScrollBar ); |
263 return d->mCurrentPosition; |
381 return d->mCurrentPosition; |
264 } |
382 } |
265 |
383 |
266 /*! |
384 /*! |
267 Returns relative size of the visible area the scrollbar is attached to. |
385 Returns scroll bar's \c pageSize property. This is a real value in the range of 0.0 to |
268 For example if the pageSize is 0.2 it means that the overall size of the content |
386 1.0, which indicates the size of the visible content relative to the whole content. |
269 is five times larger than what is shown currently. |
387 For example, a page size of 0.2 indicates that the overall size of the content is five |
270 |
388 times larger than what is currently visible. |
271 The size is in range of 0.0 to 1.0. |
389 |
272 \sa HbScrollBar::setPageSize() |
390 \sa HbScrollBar::setPageSize() |
273 */ |
391 */ |
274 qreal HbScrollBar::pageSize() const |
392 qreal HbScrollBar::pageSize() const |
275 { |
393 { |
276 Q_D( const HbScrollBar ); |
394 Q_D( const HbScrollBar ); |
277 return d->mPageSize; |
395 return d->mPageSize; |
278 } |
396 } |
279 |
397 |
280 /*! |
398 /*! |
281 Returns the orientation of scrollbar. |
399 Returns the orientation of scroll bar. |
282 |
400 |
283 \sa HbScrollBar::setOrientation() |
401 \sa HbScrollBar::setOrientation() |
284 */ |
402 */ |
285 Qt::Orientation HbScrollBar::orientation() const |
403 Qt::Orientation HbScrollBar::orientation() const |
286 { |
404 { |
287 Q_D( const HbScrollBar ); |
405 Q_D( const HbScrollBar ); |
288 return d->mOrientation; |
406 return d->mOrientation; |
289 } |
407 } |
290 |
408 |
291 /*! |
409 /*! |
292 Returns whether scrollbar is in interactive mode. |
410 Returns true if the scroll bar is interactive and false if it is indicative. |
293 |
411 |
294 \sa HbScrollBar::setInteractive() |
412 \sa HbScrollBar::setInteractive() |
295 */ |
413 */ |
296 bool HbScrollBar::isInteractive() const |
414 bool HbScrollBar::isInteractive() const |
297 { |
415 { |
298 const Q_D(HbScrollBar); |
416 Q_D(const HbScrollBar); |
299 return d->mInteractive; |
417 return d->mInteractive; |
300 } |
418 } |
301 |
419 |
302 /*! |
420 /*! |
303 Sets the value of interactive property. If this value is set |
421 Sets the value of the scroll bar's \c interactive property, which controls whether the |
304 to true scrollbar is interactive, the user can change the scroll position by |
422 scroll bar is interactive or indicative (the default). |
305 dragging the thumb or pressing the groove. Dragging the thumb emits valueChanged |
423 |
306 signal and pressing the groove emits valueChangeRequested which means |
424 When the scroll bar is interactive, the user can drag the handle or press the groove to |
307 that the widget using scrollbars should handle the value change (for example |
425 change the scroll position. The following table lists the signals that an interactive |
308 by animating to the given target value). |
426 scroll bar emits when the user drags the handle or presses the groove. |
309 |
427 |
310 The default behavior is non interactive, |
428 <table border="1" style="border-collapse: collapse; border: solid;"> |
311 which means that the scrollbar is just indicative. |
429 <tr><th>Signal</th><th>Description</th></tr> |
|
430 <tr><td>valueChanged()</td><td>This signal is emitted when the user drags the handle.</td></tr> |
|
431 <tr><td>valueChangeRequested()</td><td>This signal is emitted when the user presses the scroll |
|
432 bar's groove. The widget using the scroll bar must handle this signal (for example, by |
|
433 providing an animation that moves to the target position).</td></tr> |
|
434 </table> |
|
435 |
|
436 \param enabled A Boolean value; true for an interactive scroll bar, false for an indicative |
|
437 scroll bar. |
312 |
438 |
313 \sa HbScrollBar::isInteractive() |
439 \sa HbScrollBar::isInteractive() |
314 */ |
440 */ |
315 void HbScrollBar::setInteractive( bool enabled ) |
441 void HbScrollBar::setInteractive( bool enabled ) |
316 { |
442 { |
317 Q_D( HbScrollBar ); |
443 Q_D( HbScrollBar ); |
318 if( d->mInteractive != enabled){ |
444 if( d->mInteractive != enabled){ |
319 d->mInteractive = enabled; |
445 d->mInteractive = enabled; |
|
446 if ( enabled ) { |
|
447 grabGesture(Qt::PanGesture); |
|
448 grabGesture(Qt::TapGesture); |
|
449 } else { |
|
450 ungrabGesture(Qt::PanGesture); |
|
451 ungrabGesture(Qt::TapGesture); |
|
452 } |
320 if(d->handleItem) { |
453 if(d->handleItem) { |
321 repolish(); |
454 repolish(); |
322 updatePrimitives(); |
455 updatePrimitives(); |
323 } |
456 } |
324 } |
457 } |
325 } |
458 } |
326 |
459 |
327 /*! |
460 /*! |
328 Sets the value of the scrollbar. The given \avalue should be from 0.0 to 1.0. |
461 Sets the scroll bar's \c value property, which controls how far the handle is from |
329 The value is used to position the thumb. |
462 the start of the groove. |
|
463 |
|
464 \param value A real value in the range 0.0 to 1.0. A value of 0.0 indicates that the |
|
465 handle is at the start of the groove and a value of 1.0 indicates that it is at the |
|
466 end. |
330 |
467 |
331 \sa HbScrollBar::value() |
468 \sa HbScrollBar::value() |
332 */ |
469 */ |
333 void HbScrollBar::setValue( qreal value ) |
470 void HbScrollBar::setValue( qreal value ) |
334 { |
471 { |
335 Q_D(HbScrollBar); |
472 Q_D(HbScrollBar); |
336 |
473 |
337 value = qBound(qreal(0.0), value, qreal(1.0)); |
474 value = qBound(qreal(0.0), value, qreal(1.0)); |
379 */ |
519 */ |
380 void HbScrollBar::updatePrimitives() |
520 void HbScrollBar::updatePrimitives() |
381 { |
521 { |
382 Q_D(HbScrollBar); |
522 Q_D(HbScrollBar); |
383 |
523 |
384 HbStyleOptionScrollBar option; |
|
385 initStyleOption(&option); |
|
386 if (d->grooveItem) { |
524 if (d->grooveItem) { |
387 style()->updatePrimitive(d->grooveItem, HbStyle::P_ScrollBar_groove, &option); |
525 HbStyleFramePrimitiveData data; |
|
526 initPrimitiveData(&data, d->grooveItem); |
|
527 style()->updatePrimitive(d->grooveItem, &data, this); |
388 } |
528 } |
389 if (d->handleItem) { |
529 if (d->handleItem) { |
390 style()->updatePrimitive(d->handleItem, HbStyle::P_ScrollBar_handle, &option); |
530 HbStyleFramePrimitiveData data; |
391 } |
531 initPrimitiveData(&data, d->handleItem); |
392 if( d->mTouchArea ) { |
532 style()->updatePrimitive(d->handleItem, &data, this); |
393 style()->updatePrimitive(d->mTouchArea, HbStyle::P_ScrollBar_toucharea, &option); |
533 } |
394 } |
534 if (d->mTouchArea) { |
395 } |
535 HbStyleTouchAreaPrimitiveData data; |
396 |
536 initPrimitiveData(&data, d->mTouchArea); |
397 /*! |
537 style()->updatePrimitive(d->mTouchArea, &data, this); |
398 \reimp |
538 d->mTouchArea->setZValue(TOUCHAREA_ZVALUE); |
399 */ |
539 } |
400 void HbScrollBar::initStyleOption( HbStyleOptionScrollBar *option ) const |
540 } |
401 { |
541 |
402 Q_D(const HbScrollBar); |
542 void HbScrollBar::initPrimitiveData(HbStylePrimitiveData *primitiveData, const QGraphicsObject *primitive) |
403 HbWidget::initStyleOption(option); |
543 { |
404 |
544 Q_D(HbScrollBar); |
405 Q_ASSERT(option); |
545 HbWidget::initPrimitiveData(primitiveData, primitive); |
406 option->orientation = d->mOrientation; |
546 QString itemName = HbStyle::itemName(primitive); |
407 option->thumbPressed = d->mThumbPressed; |
547 if (itemName == QLatin1String("groove")) { |
408 option->groovePressed = d->mGroovePressed; |
548 d->groovePrimitiveData(hbstyleprimitivedata_cast<HbStyleFramePrimitiveData*>(primitiveData)); |
409 option->interactive = d->mInteractive; |
549 } else if (itemName == QLatin1String("handle")) { |
410 } |
550 d->handlePrimitiveData(hbstyleprimitivedata_cast<HbStyleFramePrimitiveData*>(primitiveData)); |
411 |
551 } |
412 /*! |
552 } |
413 \reimp |
553 |
|
554 /*! |
|
555 Reimplemented from QGraphicsItem. |
414 */ |
556 */ |
415 void HbScrollBar::mousePressEvent( QGraphicsSceneMouseEvent *event ) |
557 void HbScrollBar::mousePressEvent( QGraphicsSceneMouseEvent *event ) |
416 { |
558 { |
417 Q_D(HbScrollBar); |
559 Q_D(HbScrollBar); |
418 QGraphicsWidget::mousePressEvent(event); |
560 QGraphicsWidget::mousePressEvent(event); |
419 |
561 |
420 if ( !d->mInteractive ) { |
562 if ( !d->mInteractive ) { |
421 return; |
563 return; |
422 } |
564 } |
423 |
|
424 HbStyleOptionScrollBar opt; |
|
425 |
565 |
426 QRectF handleBounds = d->handleItem->boundingRect(); |
566 QRectF handleBounds = d->handleItem->boundingRect(); |
427 |
567 |
428 d->mPressPosition = mapToItem(d->handleItem, event->pos()); |
568 d->mPressPosition = mapToItem(d->handleItem, event->pos()); |
429 |
569 |
471 qreal(1.0)); |
612 qreal(1.0)); |
472 |
613 |
473 d->repeatActionTimer.start(REPEATION_TIME, this); |
614 d->repeatActionTimer.start(REPEATION_TIME, this); |
474 } else { |
615 } else { |
475 HbWidgetFeedback::triggered(this, Hb::InstantPressed, Hb::ModifierSliderHandle); |
616 HbWidgetFeedback::triggered(this, Hb::InstantPressed, Hb::ModifierSliderHandle); |
476 initStyleOption(&opt); |
617 HbStyleFramePrimitiveData data; |
477 style()->updatePrimitive(d->handleItem, HbStyle::P_ScrollBar_handle, &opt ); |
618 initPrimitiveData(&data, d->handleItem); |
|
619 style()->updatePrimitive(d->handleItem, &data, this); |
478 emit d->core.handlePressed(); |
620 emit d->core.handlePressed(); |
479 } |
621 } |
480 |
622 |
481 break; |
623 break; |
482 } |
624 } |
483 event->accept(); |
625 event->accept(); |
484 } |
626 } |
485 |
627 |
486 /*! |
628 /*! |
487 \reimp |
629 Reimplemented from QGraphicsItem. |
488 */ |
630 */ |
489 void HbScrollBar::mouseReleaseEvent( QGraphicsSceneMouseEvent *event ) |
631 void HbScrollBar::mouseReleaseEvent( QGraphicsSceneMouseEvent *event ) |
490 { |
632 { |
491 Q_D(HbScrollBar); |
633 Q_D(HbScrollBar); |
492 QGraphicsWidget::mouseReleaseEvent(event); |
634 QGraphicsWidget::mouseReleaseEvent(event); |
493 |
635 |
494 if ( !d->mInteractive ) { |
636 if ( !d->mInteractive ) { |
495 return; |
637 return; |
496 } |
638 } |
497 HbStyleOptionScrollBar opt; |
|
498 if (d->mThumbPressed) { |
639 if (d->mThumbPressed) { |
499 d->mThumbPressed = false; |
640 d->mThumbPressed = false; |
500 HbWidgetFeedback::triggered(this, Hb::InstantReleased, Hb::ModifierSliderHandle); |
641 HbWidgetFeedback::triggered(this, Hb::InstantReleased, Hb::ModifierSliderHandle); |
501 emit valueChanged(value(), orientation()); |
642 emit valueChanged(value(), orientation()); |
502 emit d->core.handleReleased(); |
643 emit d->core.handleReleased(); |
503 initStyleOption(&opt); |
644 HbStyleFramePrimitiveData data; |
504 style()->updatePrimitive(d->handleItem, HbStyle::P_ScrollBar_handle, &opt ); |
645 initPrimitiveData(&data, d->handleItem); |
|
646 style()->updatePrimitive(d->handleItem, &data, this); |
505 } else if (d->mGroovePressed){ |
647 } else if (d->mGroovePressed){ |
506 HbWidgetFeedback::triggered(this, Hb::InstantReleased); |
648 HbWidgetFeedback::triggered(this, Hb::InstantReleased); |
507 d->repeatActionTimer.stop(); |
649 d->repeatActionTimer.stop(); |
508 d->mGroovePressed = false; |
650 d->mGroovePressed = false; |
509 initStyleOption(&opt); |
651 HbStyleFramePrimitiveData data; |
510 style()->updatePrimitive(d->grooveItem, HbStyle::P_ScrollBar_groove, &opt ); |
652 initPrimitiveData(&data, d->grooveItem); |
|
653 style()->updatePrimitive(d->grooveItem, &data, this); |
511 } |
654 } |
512 d->emittedPos = false; |
655 d->emittedPos = false; |
513 event->accept(); |
656 event->accept(); |
514 } |
657 } |
515 |
658 |
516 /*! |
659 /*! |
517 \reimp |
660 Reimplemented from QGraphicsItem. |
518 */ |
661 */ |
519 void HbScrollBar::mouseMoveEvent( QGraphicsSceneMouseEvent *event ) |
662 void HbScrollBar::mouseMoveEvent( QGraphicsSceneMouseEvent *event ) |
520 { |
663 { |
521 Q_D(HbScrollBar); |
664 Q_D(HbScrollBar); |
522 QGraphicsWidget::mouseMoveEvent(event); |
665 QGraphicsWidget::mouseMoveEvent(event); |