emailuis/emailui/src/FreestyleEmailUiLauncherGridVisualiser.cpp
changeset 2 5253a20d2a1e
parent 1 12c456ceeff2
child 4 e7aa27f58ae1
equal deleted inserted replaced
1:12c456ceeff2 2:5253a20d2a1e
   713 		   }
   713 		   }
   714 
   714 
   715 	    TFSLauncherGridMailboxStatus mbStatus = CheckMailboxStatusL();
   715 	    TFSLauncherGridMailboxStatus mbStatus = CheckMailboxStatusL();
   716 
   716 
   717 	    // Checks if a device has a keyboard or not.
   717 	    // Checks if a device has a keyboard or not.
   718 		if( !iKeyboardFlipOpen )
   718 		if( !IsFocusShown() )
   719 			{
   719 			{
   720 			if( mbStatus.iMailboxCount <= 0 )
   720 			if( mbStatus.iMailboxCount <= 0 )
   721 				{
   721 				{
   722 				// If no mailboxes configured, dim all mailbox related items.
   722 				// If no mailboxes configured, dim all mailbox related items.
   723 				aMenuPane->SetItemDimmed( EFsEmailUiCmdDeleteMailbox, ETrue );
   723 				aMenuPane->SetItemDimmed( EFsEmailUiCmdDeleteMailbox, ETrue );
   881 			iMailboxDeleter->DeleteMailboxL( iMailboxToDelete );
   881 			iMailboxDeleter->DeleteMailboxL( iMailboxToDelete );
   882 
   882 
   883 	    	// Hide the focus.
   883 	    	// Hide the focus.
   884 	        iAppUi.SetFocusVisibility( EFalse );
   884 	        iAppUi.SetFocusVisibility( EFalse );
   885 	        HandleButtonReleaseEvent(); // Finishes the focus removal.
   885 	        HandleButtonReleaseEvent(); // Finishes the focus removal.
       
   886 	        iStylusPopUpMenuLaunched = EFalse;
   886 			break;
   887 			break;
   887 			}
   888 			}
   888 		case EFsEmailUiCmdSync:
   889 		case EFsEmailUiCmdSync:
   889         case EFsEmailUiCmdSyncAll:
   890         case EFsEmailUiCmdSyncAll:
   890 			{
   891 			{
   991        	case KErrCancel:
   992        	case KErrCancel:
   992        		{
   993        		{
   993         	// The pop-up menu was closed. Hide the focus.
   994         	// The pop-up menu was closed. Hide the focus.
   994             iAppUi.SetFocusVisibility( EFalse );
   995             iAppUi.SetFocusVisibility( EFalse );
   995             HandleButtonReleaseEvent(); // Finishes the focus removal.
   996             HandleButtonReleaseEvent(); // Finishes the focus removal.
       
   997 	        iStylusPopUpMenuLaunched = EFalse;
   996        		break;
   998        		break;
   997        		}
   999        		}
   998         case EFsEmailUiCmdHide:
  1000         case EFsEmailUiCmdHide:
   999         case EEikCmdExit:
  1001         case EEikCmdExit:
  1000         case EAknSoftkeyExit:
  1002         case EAknSoftkeyExit:
  1114                 {
  1116                 {
  1115                 if ( iStylusPopUpMenuLaunched )
  1117                 if ( iStylusPopUpMenuLaunched )
  1116                 	{
  1118                 	{
  1117                 	// A pop-up menu was launched. Do not open the selected
  1119                 	// A pop-up menu was launched. Do not open the selected
  1118                 	// item.
  1120                 	// item.
  1119                 	iStylusPopUpMenuLaunched = EFalse;
  1121                 	iItemIdInButtonDownEvent.iLaunchSelection = EFalse;
  1120                 	break;
  1122                 	break;
  1121                 	}
  1123                 	}
  1122 
  1124 
  1123                 // Hide focus always after pointer up event.
  1125                 // Hide focus always after pointer up event.
  1124                 iAppUi.SetFocusVisibility( EFalse );
  1126                 iAppUi.SetFocusVisibility( EFalse );
  1141                 }
  1143                 }
  1142             case TPointerEvent::EDrag:
  1144             case TPointerEvent::EDrag:
  1143                 {
  1145                 {
  1144                 // if pointer is moved on to other item, decrease focused
  1146                 // if pointer is moved on to other item, decrease focused
  1145                 // item's icon.
  1147                 // item's icon.
  1146                 if( ( currentlyFocused != id ) &&
  1148                 if ( ( currentlyFocused != id ) &&
  1147                     ( iItemIdInButtonDownEvent.iItemId != KErrNotFound ) )
  1149                      ( iItemIdInButtonDownEvent.iItemId != KErrNotFound ) )
  1148                     {
  1150                     {
  1149                     iItemIdInButtonDownEvent.iLaunchSelection = EFalse;
  1151                     iItemIdInButtonDownEvent.iLaunchSelection = EFalse;
  1150                     ResizeItemIcon( ETrue );
  1152                     ResizeItemIcon( ETrue );
  1151                     }
  1153                     }
       
  1154 
  1152                 // if pointer is moved on item that has focus, increase item's
  1155                 // if pointer is moved on item that has focus, increase item's
  1153                 // icon.
  1156                 // icon.
  1154                 else if( id == iItemIdInButtonDownEvent.iItemId )
  1157                 else if ( id == iItemIdInButtonDownEvent.iItemId )
  1155                     {
  1158                     {
  1156                     iItemIdInButtonDownEvent.iLaunchSelection = ETrue;
  1159                     iItemIdInButtonDownEvent.iLaunchSelection = ETrue;
  1157                     ResizeItemIcon( EFalse );
  1160                     ResizeItemIcon( EFalse );
  1158                     }
  1161                     }
       
  1162 
  1159                 break;
  1163                 break;
  1160                 }
  1164                 }
  1161             case TPointerEvent::EButtonRepeat:
  1165             case TPointerEvent::EButtonRepeat:
  1162             	{
  1166             	{
  1163             	// Long tap.
  1167             	// Long tap.
       
  1168                 if ( currentlyFocused != id ||
       
  1169                      iItemIdInButtonDownEvent.iItemId == KErrNotFound )
       
  1170             		{
       
  1171             		// The item beneath the touch was changed during the long
       
  1172             		// tap. Thus, do not show the pop-up.
       
  1173             		break;
       
  1174             		}
       
  1175 
  1164             	// Check the type of the currently selected item.
  1176             	// Check the type of the currently selected item.
  1165     			TInt itemType = iCurrentLevel.iItems[id].iId;
  1177     			TInt itemType = iCurrentLevel.iItems[id].iId;
  1166 
  1178 
  1167 				if ( itemType == EDefaultMailboxItem ||
  1179 				if ( itemType == EDefaultMailboxItem ||
  1168 					 itemType == EOtherMailboxItems )
  1180 					 itemType == EOtherMailboxItems )
  1233     TInt result = KErrNotFound;
  1245     TInt result = KErrNotFound;
  1234 
  1246 
  1235     TInt count = iCurrentLevel.iItemVisualData.Count();
  1247     TInt count = iCurrentLevel.iItemVisualData.Count();
  1236     const TPoint pos = aEvent.PointerEvent().iParentPosition;
  1248     const TPoint pos = aEvent.PointerEvent().iParentPosition;
  1237 
  1249 
  1238     for(TInt a = 0; count > a; a++)
  1250     for ( TInt a = 0; count > a; a++ )
  1239         {
  1251         {
  1240         const TRect rect(iCurrentLevel.iItemVisualData[a].iBase->DisplayRect());
  1252         const TRect rect( iCurrentLevel.iItemVisualData[a].iBase->DisplayRect() );
  1241         if(rect.Contains( pos ))
  1253         if ( rect.Contains( pos ) )
  1242             {
  1254             {
  1243             result = a;
  1255             result = a;
  1244             break;
  1256             break;
  1245             }
  1257             }
  1246         }
  1258         }
       
  1259 
  1247     return result;
  1260     return result;
  1248     }
  1261     }
  1249 
  1262 
  1250 // ---------------------------------------------------------------------------
  1263 // ---------------------------------------------------------------------------
  1251 // CFSEmailUiLauncherGridVisualiser::SetFocusedItemL
  1264 // CFSEmailUiLauncherGridVisualiser::SetFocusedItemL
  1283         }
  1296         }
  1284     FocusItem( ETrue, iCurrentLevel.iSelected );
  1297     FocusItem( ETrue, iCurrentLevel.iSelected );
  1285 
  1298 
  1286     // Move the selector over the newly focused icon
  1299     // Move the selector over the newly focused icon
  1287     MoveSelectorToCurrentItem( aDir );
  1300     MoveSelectorToCurrentItem( aDir );
       
  1301     UpdateFocusVisibility();
  1288     }
  1302     }
  1289 
  1303 
  1290 
  1304 
  1291 void CFSEmailUiLauncherGridVisualiser::HandleRowMovement( TDirection aDir, TInt aSelected )
  1305 void CFSEmailUiLauncherGridVisualiser::HandleRowMovement( TDirection aDir, TInt aSelected )
  1292     {
  1306     {
  1539     }
  1553     }
  1540 
  1554 
  1541 void CFSEmailUiLauncherGridVisualiser::PopulateL( TLevel& aLevel )
  1555 void CFSEmailUiLauncherGridVisualiser::PopulateL( TLevel& aLevel )
  1542     {
  1556     {
  1543     FUNC_LOG;
  1557     FUNC_LOG;
       
  1558 
  1544     if ( iConstructionCompleted )
  1559     if ( iConstructionCompleted )
  1545         {
  1560         {
  1546         for( TInt i = 0; i < aLevel.iItemVisualData.Count(); i++ )
  1561         for( TInt i = 0; i < aLevel.iItemVisualData.Count(); i++ )
  1547             {
  1562             {
  1548             aLevel.iItemVisualData[i].iBase->RemoveAndDestroyAllD();
  1563             aLevel.iItemVisualData[i].iBase->RemoveAndDestroyAllD();
  1549             }
  1564             }
       
  1565 
  1550         aLevel.iItemVisualData.Reset();
  1566         aLevel.iItemVisualData.Reset();
  1551         aLevel.iItems.Reset();
  1567         aLevel.iItems.Reset();
  1552 
  1568 
  1553 // <cmail> Use layout data instead of hard-coded values
       
  1554 	    TRect mainPaneRect;
  1569 	    TRect mainPaneRect;
  1555 	    AknLayoutUtils::LayoutMetricsRect(AknLayoutUtils::EMainPane, mainPaneRect);
  1570 	    AknLayoutUtils::LayoutMetricsRect(AknLayoutUtils::EMainPane, mainPaneRect);
  1556 
  1571 
  1557 	    TAknLayoutRect scrollBarRect;
  1572 	    TAknLayoutRect scrollBarRect;
  1558 	    scrollBarRect.LayoutRect(mainPaneRect, AknLayoutScalable_Avkon::aid_size_touch_scroll_bar());
  1573 	    scrollBarRect.LayoutRect(mainPaneRect, AknLayoutScalable_Avkon::aid_size_touch_scroll_bar());
  1570 	    TAknLayoutRect gridIconRect;
  1585 	    TAknLayoutRect gridIconRect;
  1571 	    gridIconRect.LayoutRect(itemrc, AknLayoutScalable_Apps::cell_cmail_l_pane_g1(var));
  1586 	    gridIconRect.LayoutRect(itemrc, AknLayoutScalable_Apps::cell_cmail_l_pane_g1(var));
  1572 
  1587 
  1573 	    TAknLayoutText gridText;
  1588 	    TAknLayoutText gridText;
  1574 	    gridText.LayoutText(itemrc, AknLayoutScalable_Apps::cell_cmail_l_pane_t1(var));
  1589 	    gridText.LayoutText(itemrc, AknLayoutScalable_Apps::cell_cmail_l_pane_t1(var));
  1575 // </cmail>
  1590 
  1576 
  1591         if ( aLevel.iParent >= 0 )
  1577         if( aLevel.iParent >= 0 )
       
  1578             {
  1592             {
  1579             iModel->FindChildren( aLevel.iParent, aLevel.iItems );
  1593             iModel->FindChildren( aLevel.iParent, aLevel.iItems );
  1580 
  1594 
  1581             for( TInt i = 0; i < aLevel.iItems.Count(); i++ )
  1595             for ( TInt i = 0; i < aLevel.iItems.Count(); i++ )
  1582                 {
  1596                 {
  1583                 TItemVisualData newItem;
  1597                 TItemVisualData newItem;
  1584 
  1598 
  1585                 newItem.iBase = CAlfAnchorLayout::AddNewL( *iControl, aLevel.iGridLayout );
  1599                 newItem.iBase = CAlfAnchorLayout::AddNewL( *iControl, aLevel.iGridLayout );
  1586                 newItem.iBase->SetTactileFeedbackL( ETouchEventStylusDown,  ETouchFeedbackBasic );
  1600                 newItem.iBase->SetTactileFeedbackL( ETouchEventStylusDown,  ETouchFeedbackBasic );
  1587 
  1601 
  1588 // <cmail> Use layout data instead of hard-coded values
  1602                 // Set anchors for text.
  1589                 // Set anchors for text
       
  1590                 newItem.iBase->SetAnchor(
  1603                 newItem.iBase->SetAnchor(
  1591                     EAlfAnchorTopLeft,
  1604                     EAlfAnchorTopLeft,
  1592                     0,
  1605                     0,
  1593                     EAlfAnchorOriginLeft,
  1606                     EAlfAnchorOriginLeft,
  1594                     EAlfAnchorOriginTop,
  1607                     EAlfAnchorOriginTop,
  1619                     EAlfAnchorOriginLeft,
  1632                     EAlfAnchorOriginLeft,
  1620                     EAlfAnchorOriginTop,
  1633                     EAlfAnchorOriginTop,
  1621                     EAlfAnchorMetricAbsolute,
  1634                     EAlfAnchorMetricAbsolute,
  1622                     EAlfAnchorMetricAbsolute,
  1635                     EAlfAnchorMetricAbsolute,
  1623                     TAlfTimedPoint( gridIconRect.Rect().iBr.iX, gridIconRect.Rect().iBr.iY ) ); //gridIconSize/2, gridIconSize+KTopMargin ) );
  1636                     TAlfTimedPoint( gridIconRect.Rect().iBr.iX, gridIconRect.Rect().iBr.iY ) ); //gridIconSize/2, gridIconSize+KTopMargin ) );
  1624 // </cmail>
       
  1625 
  1637 
  1626                 newItem.iText = CAlfTextVisual::AddNewL( *iControl, newItem.iBase );
  1638                 newItem.iText = CAlfTextVisual::AddNewL( *iControl, newItem.iBase );
  1627                 newItem.iText->EnableShadow( EFalse );
  1639                 newItem.iText->EnableShadow( EFalse );
  1628 // <cmail> Use layout data instead of hard-coded values
  1640 
  1629 				TRgb itemColor (KRgbGray);
  1641 				TRgb itemColor( KRgbGray );
       
  1642 
  1630 			    // text #9 application grid unfocused application title texts #215
  1643 			    // text #9 application grid unfocused application title texts #215
  1631 				if( AknsUtils::GetCachedColor( AknsUtils::SkinInstance(),
  1644 				if( AknsUtils::GetCachedColor( AknsUtils::SkinInstance(),
  1632 					itemColor, KAknsIIDQsnTextColors,
  1645 					itemColor, KAknsIIDQsnTextColors,
  1633 					EAknsCIQsnTextColorsCG9 ) != KErrNone )
  1646 					EAknsCIQsnTextColorsCG9 ) != KErrNone )
  1634 					{
  1647 					{
  1635 				itemColor = gridText.Color();//iAppUi.LayoutHandler()->ListNormalStateTextSkinColor();
  1648 					itemColor = gridText.Color();
  1636 					}
  1649 					}
  1637 				newItem.iText->SetColor(itemColor);
  1650 
  1638 // </cmail>
  1651 				newItem.iText->SetColor( itemColor );
  1639 
       
  1640                 newItem.iText->SetTextL( *aLevel.iItems[i].iCaption );
  1652                 newItem.iText->SetTextL( *aLevel.iItems[i].iCaption );
  1641 
  1653 
  1642                 TAlfTimedValue opacity;
  1654                 TAlfTimedValue opacity;
  1643                 opacity.SetValueNow ( KDefaultCaptionOpacity );
  1655                 opacity.SetValueNow ( KDefaultCaptionOpacity );
  1644                 newItem.iText->SetOpacity( opacity );
  1656                 newItem.iText->SetOpacity( opacity );
  1650                 newItem.iImage = CAlfImageVisual::AddNewL( *iControl, newItem.iBase );
  1662                 newItem.iImage = CAlfImageVisual::AddNewL( *iControl, newItem.iBase );
  1651                 newItem.iImage->SetScaleMode( CAlfImageVisual::EScaleFit );
  1663                 newItem.iImage->SetScaleMode( CAlfImageVisual::EScaleFit );
  1652                 newItem.iImage->SetImage( TAlfImage( *aLevel.iItems[i].iIconTexture ) );
  1664                 newItem.iImage->SetImage( TAlfImage( *aLevel.iItems[i].iIconTexture ) );
  1653                 newItem.iImage->SetFlag( EAlfVisualFlagManualSize );
  1665                 newItem.iImage->SetFlag( EAlfVisualFlagManualSize );
  1654 
  1666 
  1655 // <cmail> Use layout data instead of hard-coded values
       
  1656                 newItem.iImage->SetSize( gridIconRect.Rect().Size() );
  1667                 newItem.iImage->SetSize( gridIconRect.Rect().Size() );
  1657                 newItem.iImage->SetScale( KScaleNotSelected );
  1668                 newItem.iImage->SetScale( KScaleNotSelected );
  1658 // </cmail>
       
  1659 
  1669 
  1660                 User::LeaveIfError( aLevel.iItemVisualData.Append( newItem ) );
  1670                 User::LeaveIfError( aLevel.iItemVisualData.Append( newItem ) );
  1661                 }
  1671                 }
  1662             }
  1672             }
  1663 
  1673 
  1664 // <cmail> Use layout data instead of hard-coded values
       
  1665         // Set columns and rows
  1674         // Set columns and rows
  1666         //iVisibleColumns = iAppUi.LayoutHandler()->GridColumnsInThisResolution();
       
  1667         //iVisibleRows = iAppUi.LayoutHandler()->GridRowsInThisResolution();
       
  1668         iVisibleRows = AknLayoutScalable_Apps::cell_cmail_l_pane_ParamLimits(var).LastRow() + 1;
  1675         iVisibleRows = AknLayoutScalable_Apps::cell_cmail_l_pane_ParamLimits(var).LastRow() + 1;
  1669         iVisibleColumns = AknLayoutScalable_Apps::cell_cmail_l_pane_ParamLimits(var).LastColumn() + 1;
  1676         iVisibleColumns = AknLayoutScalable_Apps::cell_cmail_l_pane_ParamLimits(var).LastColumn() + 1;
  1670 // </cmail>
  1677 
  1671         iRowCount = ( iCurrentLevel.iItemVisualData.Count() + iVisibleColumns - 1 ) / iVisibleColumns;
  1678         iRowCount = ( iCurrentLevel.iItemVisualData.Count() + iVisibleColumns - 1 ) / iVisibleColumns;
  1672 
  1679 
  1673         aLevel.iGridLayout->MoveToFront();
  1680         aLevel.iGridLayout->MoveToFront();
  1674         }
  1681         }
  1675     }
  1682     }
  2538         selectorPos.iY.SetMappingFunctionIdentifier( 0 );
  2545         selectorPos.iY.SetMappingFunctionIdentifier( 0 );
  2539         iSelector->SetPos( selectorPos );
  2546         iSelector->SetPos( selectorPos );
  2540         }
  2547         }
  2541     }
  2548     }
  2542 
  2549 
       
  2550 
       
  2551 // -----------------------------------------------------------------------------
       
  2552 // CFSEmailUiLauncherGridVisualiser::UpdateFocusVisibility()
       
  2553 // Updates the selector and the text color of a focused item.
       
  2554 // -----------------------------------------------------------------------------
       
  2555 //
  2543 void CFSEmailUiLauncherGridVisualiser::UpdateFocusVisibility()
  2556 void CFSEmailUiLauncherGridVisualiser::UpdateFocusVisibility()
  2544     {
  2557     {
  2545     if( iSelector )
  2558     const TBool showFocus =	( IsFocusShown() ||
       
  2559 							  iItemIdInButtonDownEvent.iItemId >= 0 );
       
  2560 
       
  2561     // Update the selector.
       
  2562     if ( iSelector )
  2546         {
  2563         {
  2547         TAlfTimedValue selectorOpacity;
  2564         TAlfTimedValue selectorOpacity;
  2548         if( IsFocusShown() || iItemIdInButtonDownEvent.iItemId >= 0 )
  2565 
       
  2566         if ( showFocus )
  2549             {
  2567             {
  2550             selectorOpacity.SetValueNow( 1 );
  2568             selectorOpacity.SetValueNow( 1 );
  2551             }
  2569             }
  2552         else
  2570         else
  2553             {
  2571             {
  2554             selectorOpacity.SetValueNow( 0 );
  2572             selectorOpacity.SetValueNow( 0 );
  2555             }
  2573             }
       
  2574 
  2556         iSelector->SetOpacity( selectorOpacity );
  2575         iSelector->SetOpacity( selectorOpacity );
  2557         }
  2576         }
  2558     }
  2577 
       
  2578     // Update the text color of the previously and newly selected items. 
       
  2579 	TRgb normalColor( KRgbGray );
       
  2580 	TRgb focusedColor( KRgbGray );
       
  2581 
       
  2582 	if ( ( AknsUtils::GetCachedColor( AknsUtils::SkinInstance(), normalColor,
       
  2583 								      KAknsIIDQsnTextColors,
       
  2584 								      EAknsCIQsnTextColorsCG9 ) != KErrNone ) ||
       
  2585 		 ( AknsUtils::GetCachedColor( AknsUtils::SkinInstance(), focusedColor,
       
  2586 									  KAknsIIDQsnTextColors,
       
  2587 									  EAknsCIQsnTextColorsCG11 ) != KErrNone ) )
       
  2588 		{
       
  2589 		// No colors available.
       
  2590 		return;
       
  2591 		}
       
  2592 
       
  2593 	CAlfTextVisual* textVisual = NULL;
       
  2594 	const TInt itemCount( iCurrentLevel.iItemVisualData.Count() );
       
  2595 
       
  2596 	// Set the colors of the captions not focused to normal and if an item is
       
  2597 	// focused, set the color of its caption using the highlighted theme color.
       
  2598 	for ( TInt i = 0; i < itemCount; ++i )
       
  2599 		{
       
  2600 		textVisual = iCurrentLevel.iItemVisualData[i].iText;
       
  2601 
       
  2602 		if ( textVisual )
       
  2603 			{
       
  2604 		    if ( showFocus && iCurrentLevel.iSelected == i )
       
  2605 		        {
       
  2606                 textVisual->SetColor( focusedColor );
       
  2607 		        }
       
  2608 		    else
       
  2609 		        {
       
  2610                 textVisual->SetColor( normalColor );
       
  2611 		        }
       
  2612 			}
       
  2613 		}
       
  2614     }
       
  2615 
  2559 
  2616 
  2560 void CFSEmailUiLauncherGridVisualiser::FlipStateChangedL( TBool aKeyboardFlipOpen )
  2617 void CFSEmailUiLauncherGridVisualiser::FlipStateChangedL( TBool aKeyboardFlipOpen )
  2561     {
  2618     {
  2562     CFsEmailUiViewBase::FlipStateChangedL( aKeyboardFlipOpen );
  2619     CFsEmailUiViewBase::FlipStateChangedL( aKeyboardFlipOpen );
  2563     UpdateFocusVisibility();
  2620     UpdateFocusVisibility();