894 |
892 |
895 |
893 |
896 EXPORT_C void CAknDoubleSpanScrollBar::SizeChanged() |
894 EXPORT_C void CAknDoubleSpanScrollBar::SizeChanged() |
897 { |
895 { |
898 CAknPointerEventModifier* modifier = iAvkonAppUiBase ? iAvkonAppUiBase->PointerEventModifier() : NULL; |
896 CAknPointerEventModifier* modifier = iAvkonAppUiBase ? iAvkonAppUiBase->PointerEventModifier() : NULL; |
899 |
897 |
900 if (iExtension) |
898 if (iExtension) |
901 { |
899 { |
902 CAknDoubleSpanScrollBarExtension* extension = static_cast<CAknDoubleSpanScrollBarExtension*> (iExtension); |
900 CAknDoubleSpanScrollBarExtension* extension = static_cast<CAknDoubleSpanScrollBarExtension*> (iExtension); |
903 if ( modifier && IsVisible() && !( extension->iExtensionType & ENoExpandedTouchArea ) ) |
901 if ( modifier && IsVisible() && !( extension->iExtensionType & ENoExpandedTouchArea ) ) |
904 { |
902 { |
905 modifier->Update( *this, ExtensionArea() ); |
903 modifier->Update( *this, ExtensionArea() ); |
906 } |
904 } |
907 } |
905 } |
908 else |
906 else |
909 { |
907 { |
910 if ( modifier && IsVisible() ) |
908 if ( modifier && IsVisible() ) |
911 { |
909 { |
912 modifier->Update( *this, ExtensionArea() ); |
910 modifier->Update( *this, ExtensionArea() ); |
913 } |
911 } |
914 } |
912 } |
915 |
913 |
916 AknsUtils::RegisterControlPosition( this ); |
914 AknsUtils::RegisterControlPosition( this ); |
917 if (iExtension) |
915 if (iExtension) |
918 { |
916 { |
919 CAknDoubleSpanScrollBarExtension* extension = static_cast<CAknDoubleSpanScrollBarExtension*> (iExtension); |
917 CAknDoubleSpanScrollBarExtension* extension = static_cast<CAknDoubleSpanScrollBarExtension*> (iExtension); |
1043 // clear the pointer down info on pen up and hide info popup |
1041 // clear the pointer down info on pen up and hide info popup |
1044 TInt lastPointerDownOn = extension->iPointerDownOn; |
1042 TInt lastPointerDownOn = extension->iPointerDownOn; |
1045 // The real span area available (as pixels) |
1043 // The real span area available (as pixels) |
1046 scrollSpanPix -= thumbSpanPix; |
1044 scrollSpanPix -= thumbSpanPix; |
1047 |
1045 |
1048 |
1046 |
1049 // touch release on thumb |
1047 // touch release on thumb |
1050 TBool thumbPressed = |
1048 TBool thumbPressed = |
1051 ( position < (thumbPositionPix + thumbSpanPix) |
1049 ( position < (thumbPositionPix + thumbSpanPix) |
1052 && position > thumbPositionPix ); |
1050 && position > thumbPositionPix ); |
1053 if ( thumbPressed && |
1051 if ( thumbPressed && |
1054 aPointerEvent.iType == TPointerEvent::EButton1Up && |
1052 aPointerEvent.iType == TPointerEvent::EButton1Up && |
1055 thumbSpan < scrollSpan ) |
1053 thumbSpan < scrollSpan ) |
|
1054 { |
|
1055 MTouchFeedback* feedback = MTouchFeedback::Instance(); |
|
1056 |
|
1057 CCoeControl* parent = Parent(); |
|
1058 TBool feedbackEnabled = !IsDimmed() && IsVisible(); |
|
1059 if (parent && feedbackEnabled) |
1056 { |
1060 { |
1057 MTouchFeedback* feedback = MTouchFeedback::Instance(); |
1061 // check the same for the parent |
1058 |
1062 feedbackEnabled = !parent->IsDimmed() && parent->IsVisible(); |
1059 CCoeControl* parent = Parent(); |
|
1060 TBool feedbackEnabled = !IsDimmed() && IsVisible(); |
|
1061 if (parent && feedbackEnabled) |
|
1062 { |
|
1063 // check the same for the parent |
|
1064 feedbackEnabled = !parent->IsDimmed() && parent->IsVisible(); |
|
1065 } |
|
1066 if ( feedback && feedbackEnabled ) |
|
1067 { |
|
1068 feedback->InstantFeedback( this, |
|
1069 ETouchFeedbackSlider, |
|
1070 ETouchFeedbackVibra, |
|
1071 aPointerEvent ); |
|
1072 } |
|
1073 } |
1063 } |
1074 |
1064 if ( feedback && feedbackEnabled ) |
|
1065 { |
|
1066 feedback->InstantFeedback( this, |
|
1067 ETouchFeedbackSlider, |
|
1068 ETouchFeedbackVibra, |
|
1069 aPointerEvent ); |
|
1070 } |
|
1071 } |
|
1072 |
|
1073 if ( aPointerEvent.iType == TPointerEvent::EButton1Up ) |
|
1074 { |
|
1075 extension->iPointerDownOn = CEikScrollBar::ENone; |
|
1076 |
|
1077 // Highlight off always when the pointer is lifted |
|
1078 indicator->SetHandleHighlight( EFalse ); |
|
1079 indicator->DrawDeferred(); |
|
1080 indicator->SetBackgroudHighlight( EFalse ); |
|
1081 |
|
1082 if ( extension->iPopupController ) |
|
1083 { |
|
1084 extension->iPopupController->HideInfoPopupNote(); |
|
1085 extension->iShowPopup = EFalse; |
|
1086 } |
|
1087 } |
1075 // check that scroll bar is useful |
1088 // check that scroll bar is useful |
1076 if (thumbSpan < scrollSpan) |
1089 if (thumbSpan < scrollSpan) |
1077 { |
1090 { |
1078 // check where the pointer down occured |
1091 // check where the pointer down occured |
1079 if(aPointerEvent.iType == TPointerEvent::EButton1Down ) |
1092 if(aPointerEvent.iType == TPointerEvent::EButton1Down ) |
1109 { |
1122 { |
1110 extension->iPointerDownOn = CEikScrollBar::EIncreaseShaft; |
1123 extension->iPointerDownOn = CEikScrollBar::EIncreaseShaft; |
1111 } |
1124 } |
1112 } |
1125 } |
1113 |
1126 |
1114 if (aPointerEvent.iType == TPointerEvent::EButton1Up) |
|
1115 { |
|
1116 extension->iPointerDownOn = CEikScrollBar::ENone; |
|
1117 |
|
1118 // Highlight off always when the pointer is lifted |
|
1119 indicator->SetHandleHighlight( EFalse ); |
|
1120 indicator->DrawDeferred(); |
|
1121 indicator->SetBackgroudHighlight( EFalse ); |
|
1122 |
|
1123 if ( extension->iPopupController ) |
|
1124 { |
|
1125 extension->iPopupController->HideInfoPopupNote(); |
|
1126 extension->iShowPopup = EFalse; |
|
1127 } |
|
1128 } |
|
1129 |
|
1130 // respond to the pointer event |
1127 // respond to the pointer event |
1131 switch(extension->iPointerDownOn) |
1128 switch(extension->iPointerDownOn) |
1132 { |
1129 { |
1133 case CEikScrollBar::EDecreaseShaft: |
1130 case CEikScrollBar::EDecreaseShaft: |
1134 case CEikScrollBar::EIncreaseShaft: |
1131 case CEikScrollBar::EIncreaseShaft: |
1261 { |
1258 { |
1262 MTouchFeedback* feedback = MTouchFeedback::Instance(); |
1259 MTouchFeedback* feedback = MTouchFeedback::Instance(); |
1263 |
1260 |
1264 if ( feedback ) |
1261 if ( feedback ) |
1265 { |
1262 { |
1266 TTouchFeedbackType fbType = TTouchFeedbackType( |
1263 TTouchFeedbackType fbType = TTouchFeedbackType( |
1267 ETouchFeedbackAudio | |
1264 ETouchFeedbackAudio | |
1268 ETouchFeedbackVibra ); |
1265 ETouchFeedbackVibra ); |
1269 |
1266 |
1270 feedback->InstantFeedback( this, ETouchFeedbackSlider, fbType, aPointerEvent ); |
1267 feedback->InstantFeedback( this, ETouchFeedbackSlider, fbType, aPointerEvent ); |
1271 } |
1268 } |
1272 } |
1269 } |
1273 |
1270 |
1274 if( aPointerEvent.iType == TPointerEvent::EDrag |
1271 if( aPointerEvent.iType == TPointerEvent::EDrag |
1275 || aPointerEvent.iType == TPointerEvent::EButtonRepeat ) |
1272 || aPointerEvent.iType == TPointerEvent::EButtonRepeat ) |
1276 { |
1273 { |
1277 // performace improving. Too many drag event received, handling every single event |
1274 // performace improving. Too many drag event received, handling every single event |
1278 // will use too much CPU time. |
1275 // will use too much CPU time. |
1279 TTime now; |
1276 TTime now; |
1280 now.HomeTime(); |
1277 now.HomeTime(); |
1281 if ( extension->iDragged && |
1278 if ( extension->iDragged && |
1282 now.MicroSecondsFrom( extension->iLastDrag ) |
1279 now.MicroSecondsFrom( extension->iLastDrag ) |
1283 < KScrollDragTimeout ) |
1280 < KScrollDragTimeout ) |
1284 { |
1281 { |
1285 break; // ignore drag for this time |
1282 break; // ignore drag for this time |
1286 } |
1283 } |
1287 extension->iDragged = ETrue; // after this time, iLastDragged has value. |
1284 extension->iDragged = ETrue; // after this time, iLastDragged has value. |
1288 extension->iLastDrag = now; |
1285 extension->iLastDrag = now; |
1289 |
1286 |
1290 thumbPositionPix = position - extension->iPointerOffsetFromThumb; |
1287 thumbPositionPix = position - extension->iPointerOffsetFromThumb; |
1291 TInt oldPosition = thumbPosition; |
1288 TInt oldPosition = thumbPosition; |
1292 TReal newPosition = thumbPositionPix * ( scrollSpan - thumbSpan ) / (TReal)scrollSpanPix; |
1289 TReal newPosition = thumbPositionPix * ( scrollSpan - thumbSpan ) / (TReal)scrollSpanPix; |
1293 thumbPosition = newPosition; |
1290 thumbPosition = newPosition; |
1294 |
1291 |
1302 thumbPosition = Max(0, thumbPosition); |
1299 thumbPosition = Max(0, thumbPosition); |
1303 thumbPosition = Min((scrollSpan - thumbSpan), thumbPosition); |
1300 thumbPosition = Min((scrollSpan - thumbSpan), thumbPosition); |
1304 |
1301 |
1305 if(thumbPosition != oldPosition) |
1302 if(thumbPosition != oldPosition) |
1306 { |
1303 { |
1307 // Smooth continuous tactile feedback is produced |
|
1308 // during thumb dragging. The tactile feedback API |
|
1309 // filters out possible re-startings of the effect. |
|
1310 MTouchFeedback* feedback = MTouchFeedback::Instance(); |
|
1311 |
|
1312 if ( feedback ) |
|
1313 { |
|
1314 TTimeIntervalMicroSeconds32 timeout( 300000 ); |
|
1315 feedback->StartFeedback( this, |
|
1316 ETouchContinuousSlider, |
|
1317 &aPointerEvent, |
|
1318 KIntensity, // intensity 100% |
|
1319 timeout ); |
|
1320 } |
|
1321 extension->SetModelThumbPosition(thumbPosition); |
1304 extension->SetModelThumbPosition(thumbPosition); |
1322 indicator->SetIndicatorValues(scrollSpan, thumbPosition, thumbSpan, 0, 0); |
1305 indicator->SetIndicatorValues(scrollSpan, thumbPosition, thumbSpan, 0, 0); |
1323 |
1306 |
1324 if(indicator->DrawBackgroundState()) |
1307 if(indicator->DrawBackgroundState()) |
1325 indicator->DrawNow(); |
1308 indicator->DrawNow(); |
2343 { |
2315 { |
2344 // Usage of hard-coded parent rectangle is acceptable since we're |
2316 // Usage of hard-coded parent rectangle is acceptable since we're |
2345 // interested in only about the ratio between scrollbar and extension. |
2317 // interested in only about the ratio between scrollbar and extension. |
2346 TAknLayoutRect layoutRect; |
2318 TAknLayoutRect layoutRect; |
2347 layoutRect.LayoutRect( TRect( 0, 0, 200, 200 ), AknLayoutScalable_Avkon::listscroll_gen_pane( 0 ).LayoutLine() ); |
2319 layoutRect.LayoutRect( TRect( 0, 0, 200, 200 ), AknLayoutScalable_Avkon::listscroll_gen_pane( 0 ).LayoutLine() ); |
2348 |
2320 |
2349 TRect parent( layoutRect.Rect() ); // parent of both extension and scrollbar |
2321 TRect parent( layoutRect.Rect() ); // parent of both extension and scrollbar |
2350 |
2322 |
2351 layoutRect.LayoutRect( parent, AknLayoutScalable_Avkon::scroll_pane( 0 ).LayoutLine() ); |
2323 layoutRect.LayoutRect( parent, AknLayoutScalable_Avkon::scroll_pane( 0 ).LayoutLine() ); |
2352 |
2324 |
2353 TRect scrollbar( layoutRect.Rect() ); |
2325 TRect scrollbar( layoutRect.Rect() ); |
2354 |
2326 |
2355 CAknDoubleSpanScrollBarExtension* extension1 = static_cast<CAknDoubleSpanScrollBarExtension*> (iExtension); |
2327 CAknDoubleSpanScrollBarExtension* extension1 = static_cast<CAknDoubleSpanScrollBarExtension*> (iExtension); |
2356 if( extension1->iExtensionType & ENormalExpandedTouchArea ) |
2328 if( extension1->iExtensionType & ENormalExpandedTouchArea ) |
2357 layoutRect.LayoutRect( parent, AknLayoutScalable_Avkon::aid_size_touch_scroll_bar( 0 ).LayoutLine() ); |
2329 layoutRect.LayoutRect( parent, AknLayoutScalable_Avkon::aid_size_touch_scroll_bar( 0 ).LayoutLine() ); |
2358 else if( extension1->iExtensionType & EScaleExpandedTouchArea ) |
2330 else if( extension1->iExtensionType & EScaleExpandedTouchArea ) |
2359 layoutRect.LayoutRect( parent, AknLayoutScalable_Avkon::aid_size_touch_scroll_bar_cale( 0 ).LayoutLine() ); |
2331 layoutRect.LayoutRect( parent, AknLayoutScalable_Avkon::aid_size_touch_scroll_bar_cale( 0 ).LayoutLine() ); |
2360 else |
2332 else |
2361 layoutRect.LayoutRect( parent, AknLayoutScalable_Avkon::aid_size_touch_scroll_bar( 0 ).LayoutLine() ); |
2333 layoutRect.LayoutRect( parent, AknLayoutScalable_Avkon::aid_size_touch_scroll_bar( 0 ).LayoutLine() ); |
2362 TRect extension( layoutRect.Rect() ); |
2334 TRect extension( layoutRect.Rect() ); |
2363 |
2335 |
2364 TRect area; |
2336 TRect area; |
2365 |
2337 |
2366 if ( iParentControl ) |
2338 if ( iParentControl ) |
2367 { |
2339 { |
2368 CCoeControl* windowOwningParent = iParentControl; |
2340 CCoeControl* windowOwningParent = iParentControl; |
2369 while ( windowOwningParent && !windowOwningParent->OwnsWindow() ) |
2341 while ( windowOwningParent && !windowOwningParent->OwnsWindow() ) |
2370 { |
2342 { |
2371 windowOwningParent = windowOwningParent->Parent(); |
2343 windowOwningParent = windowOwningParent->Parent(); |
2372 } |
2344 } |
2373 |
2345 |
2374 if ( windowOwningParent ) |
2346 if ( windowOwningParent ) |
2375 { |
2347 { |
2376 TInt xGap = 0; |
2348 TInt xGap = 0; |
2377 TRect scrollBarRect = Rect(); |
2349 TRect scrollBarRect = Rect(); |
2378 TRect parentRect = windowOwningParent->Rect(); |
2350 TRect parentRect = windowOwningParent->Rect(); |
2379 |
2351 |
2380 if ( OwnsWindow() ) |
2352 if ( OwnsWindow() ) |
2381 { |
2353 { |
2382 scrollBarRect.Move( Position().iX - |
2354 scrollBarRect.Move( Position().iX - |
2383 windowOwningParent->Position().iX, 0 ); |
2355 windowOwningParent->Position().iX, 0 ); |
2384 } |
2356 } |
2385 if ( iOrientation == CEikScrollBar::EVertical ) |
2357 if ( iOrientation == CEikScrollBar::EVertical ) |
2386 { |
2358 { |
2387 // left to right layout in use |
2359 // left to right layout in use |
2388 if ( !AknLayoutUtils::LayoutMirrored() ) |
2360 if ( !AknLayoutUtils::LayoutMirrored() ) |
2389 { |
2361 { |
2390 xGap = parentRect.iBr.iX - scrollBarRect.iBr.iX; |
2362 xGap = parentRect.iBr.iX - scrollBarRect.iBr.iX; |
2391 if ( Abs( xGap ) < scrollBarRect.Width() ) |
2363 if ( Abs( xGap ) < scrollBarRect.Width() ) |
2392 { |
2364 { |
2393 extension.iBr.iX += xGap; |
2365 extension.iBr.iX += xGap; |
2394 } |
2366 } |
2395 } |
2367 } |
2396 // right to left layout in use |
2368 // right to left layout in use |
2397 else |
2369 else |
2398 { |
2370 { |
2399 xGap = parentRect.iTl.iX - scrollBarRect.iTl.iX; |
2371 xGap = parentRect.iTl.iX - scrollBarRect.iTl.iX; |
2400 if ( Abs( xGap ) < scrollBarRect.Width() ) |
2372 if ( Abs( xGap ) < scrollBarRect.Width() ) |
2401 { |
2373 { |
2402 extension.iTl.iX += xGap; |
2374 extension.iTl.iX += xGap; |
2403 } |
2375 } |
2404 } |
2376 } |
2405 } |
2377 } |
2406 else |
2378 else |
2407 { |
2379 { |
2408 xGap = parentRect.iBr.iY - scrollBarRect.iBr.iY; |
2380 xGap = parentRect.iBr.iY - scrollBarRect.iBr.iY; |
2409 if ( Abs( xGap ) < scrollBarRect.Height() ) |
2381 if ( Abs( xGap ) < scrollBarRect.Height() ) |
2410 { |
2382 { |
2411 extension.iBr.iY += xGap; |
2383 extension.iBr.iY += xGap; |
2412 } |
2384 } |
2413 } |
2385 } |
2414 } |
2386 } |
2415 } |
2387 } |
2416 |
2388 |
2417 if ( iOrientation == CEikScrollBar::EVertical ) |
2389 if ( iOrientation == CEikScrollBar::EVertical ) |
2418 { |
2390 { |
2419 area.iTl.iX = extension.iTl.iX - scrollbar.iTl.iX; |
2391 area.iTl.iX = extension.iTl.iX - scrollbar.iTl.iX; |
2420 area.iTl.iY = scrollbar.iTl.iY - extension.iTl.iY; |
2392 area.iTl.iY = scrollbar.iTl.iY - extension.iTl.iY; |
2421 area.iBr.iX = area.iTl.iX + extension.Width(); |
2393 area.iBr.iX = area.iTl.iX + extension.Width(); |