186 iGrid->DisableSingleClick(ETrue);//enables highlight on pointer |
187 iGrid->DisableSingleClick(ETrue);//enables highlight on pointer |
187 iDeviceState.AddObserverL(*iGrid, MTsDeviceStateObserver::ESkin); |
188 iDeviceState.AddObserverL(*iGrid, MTsDeviceStateObserver::ESkin); |
188 |
189 |
189 AknListBoxLayouts::SetupStandardGrid( *iGrid ); |
190 AknListBoxLayouts::SetupStandardGrid( *iGrid ); |
190 |
191 |
|
192 // Setup layout |
|
193 LayoutGridL(); |
|
194 |
|
195 if( wasHighlight ) |
|
196 { |
|
197 iGrid->ShowHighlight(); |
|
198 } |
|
199 else |
|
200 { |
|
201 iGrid->HideHighlight(); |
|
202 } |
|
203 |
|
204 // Setup empty text |
|
205 HBufC* text = StringLoader::LoadLC( R_TS_FSW_NO_APPS ); |
|
206 iGrid->SetEmptyGridTextL( *text ); |
|
207 CleanupStack::PopAndDestroy( text ); |
|
208 |
|
209 // Setup grid observers |
|
210 if ( obs ) |
|
211 { |
|
212 iGrid->SetObserver( obs ); |
|
213 } |
|
214 iGrid->SetListBoxObserver(this); |
|
215 iGrid->SetFastSwapGridObserver(this); |
|
216 iGrid->SetContainerWindowL(*this); |
|
217 |
|
218 // Make sure that there is an ActivateL call even when we are not |
|
219 // called from ConstructL. (in order to have the grid's parent ptr set properly) |
|
220 ActivateL(); |
|
221 } |
|
222 |
|
223 |
|
224 // -------------------------------------------------------------------------- |
|
225 // CTsFastSwapArea::LayoutGridL |
|
226 // -------------------------------------------------------------------------- |
|
227 // |
|
228 void CTsFastSwapArea::LayoutGridL() |
|
229 { |
191 RArray<TAknLayoutRect> rects; |
230 RArray<TAknLayoutRect> rects; |
192 CleanupClosePushL(rects); |
231 CleanupClosePushL(rects); |
193 rects.ReserveL(KLayoutItemCount); |
232 rects.ReserveL(KLayoutItemCount); |
194 GetFastSwapAreaRects(rects); |
233 GetFastSwapAreaRects(rects); |
195 TAknLayoutRect gridAppPane = rects[0]; |
234 TAknLayoutRect gridAppPane = rects[0]; |
220 KAknsIIDQsnTextColors, EAknsCIQsnTextColorsCG19 ); |
259 KAknsIIDQsnTextColors, EAknsCIQsnTextColorsCG19 ); |
221 TRgb highlightTextColor; |
260 TRgb highlightTextColor; |
222 AknsUtils::GetCachedColor( AknsUtils::SkinInstance(), highlightTextColor, |
261 AknsUtils::GetCachedColor( AknsUtils::SkinInstance(), highlightTextColor, |
223 KAknsIIDQsnTextColors, EAknsCIQsnTextColorsCG11 ); |
262 KAknsIIDQsnTextColors, EAknsCIQsnTextColorsCG11 ); |
224 CFormattedCellListBoxData::TColors colors; |
263 CFormattedCellListBoxData::TColors colors; |
225 colors.iText = textColor; |
264 colors.iText = textColor; |
226 colors.iBack = iGrid->ItemDrawer()->BackColor(); |
265 colors.iBack = iGrid->ItemDrawer()->BackColor(); |
227 colors.iHighlightedText = highlightTextColor; |
266 colors.iHighlightedText = highlightTextColor; |
228 colors.iHighlightedBack = iGrid->ItemDrawer()->HighlightedBackColor(); |
267 colors.iHighlightedBack = iGrid->ItemDrawer()->HighlightedBackColor(); |
229 iGrid->ItemDrawer()->FormattedCellData()->SetSubCellColorsL(1, colors); |
268 iGrid->ItemDrawer()->FormattedCellData()->SetSubCellColorsL(1, colors); |
230 iGrid->SetStrokeColors(textColor, highlightTextColor); |
269 iGrid->SetStrokeColors(textColor, highlightTextColor); |
231 |
270 |
232 // Setup grid observers |
|
233 if ( obs ) |
|
234 { |
|
235 iGrid->SetObserver( obs ); |
|
236 } |
|
237 iGrid->SetListBoxObserver(this); |
|
238 iGrid->SetFastSwapGridObserver(this); |
|
239 iGrid->SetContainerWindowL(*this); |
|
240 |
|
241 if ( AknLayoutUtils::LayoutMirrored() ) |
271 if ( AknLayoutUtils::LayoutMirrored() ) |
242 { |
272 { |
243 iGridItemGap = gridItem.Rect().iTl.iX - gridNextItem.Rect().iBr.iX; |
273 iGridItemGap = gridItem.Rect().iTl.iX - gridNextItem.Rect().iBr.iX; |
244 } |
274 } |
245 else |
275 else |
256 iMaxItemsOnScreen--; |
286 iMaxItemsOnScreen--; |
257 } |
287 } |
258 } |
288 } |
259 iGridItemWidth = gridItem.Rect().Width(); |
289 iGridItemWidth = gridItem.Rect().Width(); |
260 |
290 |
|
291 // Update item drawer |
|
292 iGrid->UpdateItemDrawerLayoutDataL(); |
|
293 |
261 // Update state |
294 // Update state |
262 HandleDeviceStateChanged( EDeviceType ); |
295 HandleDeviceStateChanged( EDeviceType ); |
263 if( wasHighlight ) |
|
264 { |
|
265 iGrid->ShowHighlight(); |
|
266 } |
|
267 else |
|
268 { |
|
269 iGrid->HideHighlight(); |
|
270 } |
|
271 |
|
272 HBufC* text = StringLoader::LoadLC( R_TS_FSW_NO_APPS ); |
|
273 iGrid->SetEmptyGridTextL( *text ); |
|
274 CleanupStack::PopAndDestroy( text ); |
|
275 |
|
276 // Make sure that there is an ActivateL call even when we are not |
|
277 // called from ConstructL. (in order to have the grid's parent ptr set properly) |
|
278 ActivateL(); |
|
279 } |
296 } |
280 |
297 |
281 |
298 |
282 // -------------------------------------------------------------------------- |
299 // -------------------------------------------------------------------------- |
283 // CTsFastSwapArea::GetFastSwapAreaRects |
300 // CTsFastSwapArea::GetFastSwapAreaRects |
331 { |
348 { |
332 // Grid needs to be recreated to proper reinitilize |
349 // Grid needs to be recreated to proper reinitilize |
333 // data with new layout values |
350 // data with new layout values |
334 TInt selIdx = SelectedIndex(); |
351 TInt selIdx = SelectedIndex(); |
335 TRAPD(err, |
352 TRAPD(err, |
336 ReCreateGridL(); |
353 /*ReCreateGridL()*/ |
337 /*iEvtHandler.ReInitPhysicsL(GridWorldSize(), ViewSize(), ETrue);*/); |
354 LayoutGridL() ); |
338 if ( err != KErrNone ) |
355 if ( err != KErrNone ) |
339 { |
356 { |
340 TSLOG1( TSLOG_INFO, "ReCreateGridL leaves with %d", err ); |
357 TSLOG1( TSLOG_INFO, "LayoutGridL leaves with %d", err ); |
341 } |
358 } |
342 HandleFswContentChanged(); |
359 HandleFswContentChanged(); |
343 iGrid->SetCurrentDataIndex(selIdx); |
360 iGrid->SetCurrentDataIndex(selIdx); |
344 UpdateGrid(ETrue, EFalse); |
361 UpdateGrid(ETrue, EFalse); |
345 DrawDeferred(); |
362 DrawDeferred(); |
378 void CTsFastSwapArea::SwitchToApp( TInt aIndex ) |
395 void CTsFastSwapArea::SwitchToApp( TInt aIndex ) |
379 { |
396 { |
380 if ( aIndex >= 0 && aIndex < iArray.Count() ) |
397 if ( aIndex >= 0 && aIndex < iArray.Count() ) |
381 { |
398 { |
382 TInt wgId = iArray[aIndex]->WgId(); |
399 TInt wgId = iArray[aIndex]->WgId(); |
|
400 TUid appUid = iArray[aIndex]->AppUid(); |
383 // Move other app to foreground and then move ourselves to background. |
401 // Move other app to foreground and then move ourselves to background. |
384 // Order is important and cannot be reversed. |
402 // Order is important and cannot be reversed. |
385 iFSClient->SwitchToApp( wgId ); |
403 iFSClient->SwitchToApp( wgId ); |
386 // We do not want to come back to ts if the activated app is closed. |
404 // We do not want to come back to ts if the activated app is closed. |
387 // Therefore ts must be moved to background. Ignore orientation updates, it |
405 // Therefore ts must be moved to background. Ignore orientation updates, it |
388 // will be done after task switcher is sent to background |
406 // will be done after task switcher is sent to background |
389 iIgnoreLayoutSwitch = ETrue; |
407 iIgnoreLayoutSwitch = ETrue; |
390 CTsAppUi* appui = |
408 CTsAppUi* appui = |
391 static_cast<CTsAppUi*>( iEikonEnv->AppUi() ); |
409 static_cast<CTsAppUi*>( iEikonEnv->AppUi() ); |
392 appui->MoveAppToBackground( CTsAppUi::EActivationTransition ); |
410 appui->MoveAppToBackground( CTsAppUi::EActivationTransition, appUid, wgId ); |
393 iIgnoreLayoutSwitch = EFalse; |
411 iIgnoreLayoutSwitch = EFalse; |
394 |
412 |
395 // Orientation update |
413 // Orientation update |
396 iPrevScreenOrientation = -1; // force orientation reinit |
414 iPrevScreenOrientation = -1; // force orientation reinit |
397 iOrientationSignalTimer->Cancel(); |
415 iOrientationSignalTimer->Cancel(); |
416 { |
434 { |
417 selIdx--; |
435 selIdx--; |
418 } |
436 } |
419 TInt wgId = iArray[aIndex]->WgId(); |
437 TInt wgId = iArray[aIndex]->WgId(); |
420 iFSClient->CloseApp( wgId ); |
438 iFSClient->CloseApp( wgId ); |
|
439 iIsClosing.Append(wgId); |
421 // The fsw content will change sooner or later |
440 // The fsw content will change sooner or later |
422 // but the updated content (without the closed app) will not |
441 // but the updated content (without the closed app) will not |
423 // come very fast. It looks better to the user if the item |
442 // come very fast. It looks better to the user if the item |
424 // in the grid is removed right here, right now. |
443 // in the grid is removed right here, right now. |
425 // If the app does not close for some reason then this is |
444 // If the app does not close for some reason then this is |
687 iGrid->ScrollBarFrame()->SetScrollBarVisibilityL( |
706 iGrid->ScrollBarFrame()->SetScrollBarVisibilityL( |
688 CEikScrollBarFrame::EOff, CEikScrollBarFrame::EOff); |
707 CEikScrollBarFrame::EOff, CEikScrollBarFrame::EOff); |
689 } |
708 } |
690 |
709 |
691 // refresh the items in the grid |
710 // refresh the items in the grid |
692 iGrid->HandleItemAdditionL(); |
|
693 iEvtHandler.ReInitPhysicsL( GridWorldSize(), ViewSize(), ETrue ); |
711 iEvtHandler.ReInitPhysicsL( GridWorldSize(), ViewSize(), ETrue ); |
694 UpdateGrid( ETrue, !aSuppressAnimation ); |
712 UpdateGrid( ETrue, !aSuppressAnimation ); |
|
713 iGrid->HandleItemAdditionL(); |
695 |
714 |
696 TSLOG_OUT(); |
715 TSLOG_OUT(); |
697 } |
716 } |
698 |
717 |
699 // -------------------------------------------------------------------------- |
718 // -------------------------------------------------------------------------- |
751 // |
770 // |
752 void CTsFastSwapArea::HandleSwitchToBackgroundEvent() |
771 void CTsFastSwapArea::HandleSwitchToBackgroundEvent() |
753 { |
772 { |
754 // stop listening for changes in fsw content |
773 // stop listening for changes in fsw content |
755 iFSClient->CancelSubscribe(); |
774 iFSClient->CancelSubscribe(); |
|
775 // Hide highlight |
|
776 if ( iGrid->GridBehaviour() == CTsFastSwapGrid::ETouchOnly ) |
|
777 { |
|
778 iGrid->HideHighlight(); |
|
779 } |
756 } |
780 } |
757 |
781 |
758 // ----------------------------------------------------------------------------- |
782 // ----------------------------------------------------------------------------- |
759 // CTsFastSwapArea::HandleSwitchToForegroundEvent |
783 // CTsFastSwapArea::HandleSwitchToForegroundEvent |
760 // ----------------------------------------------------------------------------- |
784 // ----------------------------------------------------------------------------- |
762 void CTsFastSwapArea::HandleSwitchToForegroundEvent() |
786 void CTsFastSwapArea::HandleSwitchToForegroundEvent() |
763 { |
787 { |
764 TSLOG_CONTEXT( CTsFastSwapArea::HandleSwitchToForegroundEvent, TSLOG_LOCAL ); |
788 TSLOG_CONTEXT( CTsFastSwapArea::HandleSwitchToForegroundEvent, TSLOG_LOCAL ); |
765 TSLOG_IN(); |
789 TSLOG_IN(); |
766 |
790 |
|
791 iIsClosing.Reset(); |
|
792 |
|
793 CTsGridItemDrawer* itemDrawer = |
|
794 static_cast<CTsGridItemDrawer*>( iGrid->ItemDrawer() ); |
|
795 itemDrawer->SetRedrawBackground(ETrue); |
|
796 |
|
797 // Update Layout |
|
798 CTsAppUi* appUi = static_cast<CTsAppUi*>(iEikonEnv->AppUi()); |
|
799 if ( appUi && appUi->EffectsEnabled() ) |
|
800 { |
|
801 TRAP_IGNORE( LayoutGridL() ); |
|
802 } |
|
803 |
767 // Reset grid |
804 // Reset grid |
768 TRAP_IGNORE( ReCreateGridL() ); |
|
769 if ( iDeviceState.DeviceType() == CTsDeviceState::EFullTouch ) |
805 if ( iDeviceState.DeviceType() == CTsDeviceState::EFullTouch ) |
770 { |
806 { |
771 iGrid->HideHighlight(); |
807 iGrid->HideHighlight(); |
772 } |
808 } |
773 else |
809 else |
783 RestoreSelectedIndex(); |
819 RestoreSelectedIndex(); |
784 UpdateGrid(EFalse, EFalse); |
820 UpdateGrid(EFalse, EFalse); |
785 |
821 |
786 iRedrawTimer->Cancel(); |
822 iRedrawTimer->Cancel(); |
787 iRedrawTimer->After(KRedrawTime); |
823 iRedrawTimer->After(KRedrawTime); |
|
824 |
|
825 itemDrawer->SetRedrawBackground(EFalse); |
788 |
826 |
789 // give feedback |
827 // give feedback |
790 LaunchPopupFeedback(); |
828 LaunchPopupFeedback(); |
791 |
829 |
792 TSLOG_OUT(); |
830 TSLOG_OUT(); |
921 { |
959 { |
922 iKeyEvent = EFalse; |
960 iKeyEvent = EFalse; |
923 if(aPointerEvent.iType == TPointerEvent::EButton1Down) |
961 if(aPointerEvent.iType == TPointerEvent::EButton1Down) |
924 { |
962 { |
925 iTapEvent = aPointerEvent; |
963 iTapEvent = aPointerEvent; |
|
964 iGrid->EnableAknEventHandling(EFalse); |
|
965 iGrid->HandlePointerEventL(aPointerEvent); |
|
966 iGrid->EnableAknEventHandling(ETrue); |
926 } |
967 } |
927 } |
968 } |
928 |
969 |
929 // ----------------------------------------------------------------------------- |
970 // ----------------------------------------------------------------------------- |
930 // CTsFastSwapArea::SelectedIndex |
971 // CTsFastSwapArea::SelectedIndex |
1667 TPixelsAndRotation availableRect; |
1708 TPixelsAndRotation availableRect; |
1668 iEikonEnv->ScreenDevice()->GetDefaultScreenSizeAndRotation(availableRect); |
1709 iEikonEnv->ScreenDevice()->GetDefaultScreenSizeAndRotation(availableRect); |
1669 return availableRect.iPixelSize.iWidth > availableRect.iPixelSize.iHeight; |
1710 return availableRect.iPixelSize.iWidth > availableRect.iPixelSize.iHeight; |
1670 } |
1711 } |
1671 |
1712 |
|
1713 |
|
1714 // ----------------------------------------------------------------------------- |
|
1715 // CTsFastSwapArea::IsAppClosing |
|
1716 // ----------------------------------------------------------------------------- |
|
1717 // |
|
1718 TBool CTsFastSwapArea::IsAppClosing( TInt aWgId ) |
|
1719 { |
|
1720 TBool retVal(EFalse); |
|
1721 if ( iIsClosing.Count() ) |
|
1722 { |
|
1723 TInt idx = iIsClosing.Find(aWgId); |
|
1724 retVal = idx != KErrNotFound; |
|
1725 if ( retVal ) |
|
1726 { |
|
1727 iIsClosing.Remove(idx); |
|
1728 } |
|
1729 } |
|
1730 return retVal; |
|
1731 } |
|
1732 |
1672 // End of file |
1733 // End of file |