63 const TInt KNumMinRowSpace = 2; |
63 const TInt KNumMinRowSpace = 2; |
64 const TInt KColSpace = 20; |
64 const TInt KColSpace = 20; |
65 const TInt KRightmargin = 20; |
65 const TInt KRightmargin = 20; |
66 const TInt KMinTagSize = 77; |
66 const TInt KMinTagSize = 77; |
67 const TInt KTagScreenHeight = 460; |
67 const TInt KTagScreenHeight = 460; |
68 const TInt KDragHoldTime = 500; |
68 const TReal KBoundaryMargin = 0.1; //10% = 10/100 = 0.1 |
69 |
69 const TInt KFastCloudMovement = 100; //Transition time to move cloud view |
|
70 const TInt KSlowCloudMovement = 1000; //Transition time to move cloud view |
70 |
71 |
71 // --------------------------------------------------------------------------- |
72 // --------------------------------------------------------------------------- |
72 // Two-phased constructor. |
73 // Two-phased constructor. |
73 // --------------------------------------------------------------------------- |
74 // --------------------------------------------------------------------------- |
74 // |
75 // |
406 |
410 |
407 iViewPortLayout->SetViewportSize(TAlfRealSize(iTagScreenWidth,iTagScreenHeight), 0); |
411 iViewPortLayout->SetViewportSize(TAlfRealSize(iTagScreenWidth,iTagScreenHeight), 0); |
408 iViewPortLayout->SetSize(TAlfRealSize(iTagScreenWidth,iTagScreenHeight), 0); |
412 iViewPortLayout->SetSize(TAlfRealSize(iTagScreenWidth,iTagScreenHeight), 0); |
409 iViewPortSize.iWidth = iTagScreenWidth; |
413 iViewPortSize.iWidth = iTagScreenWidth; |
410 iViewPortSize.iHeight = iTagScreenHeight; |
414 iViewPortSize.iHeight = iTagScreenHeight; |
411 iViewPortLayout->SetViewportPos(TAlfRealPoint(0, 0),1000); |
415 iViewPortLayout->SetViewportPos(TAlfRealPoint(0, 0), KSlowCloudMovement); |
412 |
416 |
413 iViewPortPosition.iX =0; |
417 iViewPortPosition.iX =0; |
414 iViewPortPosition.iY =0; |
418 iViewPortPosition.iY =0; |
415 |
419 |
416 iScrollEventData.mSpan = iViewPortVirtualSize.iHeight ; |
420 iScrollEventData.mSpan = iViewPortVirtualSize.iHeight ; |
1432 TBool CGlxCloudViewControl::HandlePointerEventL( const TAlfEvent &aEvent ) |
1410 TBool CGlxCloudViewControl::HandlePointerEventL( const TAlfEvent &aEvent ) |
1433 { |
1411 { |
1434 TRACER("GLX_CLOUD::CGlxCloudViewControl::HandlePointerEventL"); |
1412 TRACER("GLX_CLOUD::CGlxCloudViewControl::HandlePointerEventL"); |
1435 CAlfVisual* tappedvisual = aEvent.Visual(); |
1413 CAlfVisual* tappedvisual = aEvent.Visual(); |
1436 TBool consumed = EFalse; |
1414 TBool consumed = EFalse; |
|
1415 |
1437 if(aEvent.PointerEvent().iType == TPointerEvent::EButton1Down) |
1416 if(aEvent.PointerEvent().iType == TPointerEvent::EButton1Down) |
1438 { |
1417 { |
|
1418 //reset variables & Physics simulator |
|
1419 iPhysics->StopPhysics(); |
|
1420 iPhysics->ResetFriction(); |
|
1421 iDragging = EFalse; |
|
1422 iPhysicsStarted = EFalse; |
|
1423 iStartTime.HomeTime(); |
|
1424 iViewDragged = EFalse; |
|
1425 Display()->Roster().SetPointerEventObservers( |
|
1426 EAlfPointerEventReportDrag + EAlfPointerEventReportLongTap |
|
1427 + EAlfPointerEventReportUnhandled, *this); |
|
1428 Display()->Roster().DisableLongTapEventsWhenDragging(*this); |
|
1429 |
1439 if(tappedvisual) |
1430 if(tappedvisual) |
1440 { |
1431 { |
1441 for(TInt index=0;index<iLayout->Count();index++) |
1432 for(TInt index=0;index<iLayout->Count();index++) |
1442 { |
1433 { |
1443 CAlfVisual* layoutvisual = &(iLayout->Visual(index)); |
1434 CAlfVisual* layoutvisual = &(iLayout->Visual(index)); |
1444 //if the tapped visual is same as the visual in the layout then focus that visual |
1435 //if the tapped visual is same as the visual in the layout then focus that visual |
1445 if(layoutvisual == tappedvisual) |
1436 if(layoutvisual == tappedvisual) |
1446 { |
1437 { |
1447 TInt focus = iMediaList.FocusIndex(); |
1438 TInt focus = iMediaList.FocusIndex(); |
1448 //if the visual is already focused then for next tap open the next view |
1439 if (index != focus) |
1449 if( focus == index ) |
|
1450 { |
1440 { |
1451 iTouchFeedback->InstantFeedback( ETouchFeedbackBasic ); |
1441 iTouchFeedback->InstantFeedback(ETouchFeedbackBasic); |
1452 iObserverEnterKeyEvent.HandleEnterKeyEventL( (TInt)EAknCmdOpen ); |
1442 iMediaList.SetFocusL(NGlxListDefs::EAbsolute, index); |
1453 consumed = ETrue; |
1443 SetFocusColor(); |
1454 } |
1444 } |
1455 else if( index!= focus ) |
1445 consumed = ETrue; |
|
1446 break; |
|
1447 } |
|
1448 } |
|
1449 } |
|
1450 } |
|
1451 else if (aEvent.PointerEvent().iType == TPointerEvent::EDrag) |
|
1452 { |
|
1453 GLX_LOG_INFO("GLX_CLOUD :: CGlxCloudViewControl::HandlePointerEventL(EDrag) event"); |
|
1454 iTouchFeedback->InstantFeedback(ETouchFeedbackBasic); |
|
1455 |
|
1456 consumed = HandleDragL(aEvent.PointerEvent()); |
|
1457 } |
|
1458 else if (aEvent.PointerUp()) |
|
1459 { |
|
1460 Display()->Roster().SetPointerEventObservers(0, *this); |
|
1461 consumed = ETrue; |
|
1462 |
|
1463 //Check if dragging actually happened using iViewDragged |
|
1464 if (iDragging && iViewDragged) |
|
1465 { |
|
1466 iDragging = EFalse; |
|
1467 TPoint drag = iStart - aEvent.PointerEvent().iPosition; |
|
1468 iPhysics->StartPhysics(drag, iStartTime); |
|
1469 iPhysicsStarted = ETrue; |
|
1470 } |
|
1471 //If dragging not happened consider it as Tapped event |
|
1472 else if (tappedvisual && !iViewDragged) |
|
1473 { |
|
1474 for (TInt index = 0; index < iLayout->Count(); index++) |
|
1475 { |
|
1476 CAlfVisual* layoutvisual = &(iLayout->Visual(index)); |
|
1477 //if the tapped visual is same as the visual in the layout then focus that visual |
|
1478 if (layoutvisual == tappedvisual) |
|
1479 { |
|
1480 TInt focus = iMediaList.FocusIndex(); |
|
1481 if (index != focus) |
1456 { |
1482 { |
1457 iTouchFeedback->InstantFeedback( ETouchFeedbackBasic ); |
1483 iTouchFeedback->InstantFeedback( ETouchFeedbackBasic ); |
1458 TInt focusrowindex = iFocusRowIndex; |
1484 TInt focusrowindex = iFocusRowIndex; |
1459 iMediaList.SetFocusL (NGlxListDefs::EAbsolute, |
1485 iMediaList.SetFocusL(NGlxListDefs::EAbsolute, index); |
1460 index); |
|
1461 SetFocusColor(); |
1486 SetFocusColor(); |
1462 iFocusRowIndex = RowNumber (iMediaList.FocusIndex ()); |
1487 iFocusRowIndex = RowNumber (iMediaList.FocusIndex ()); |
1463 if( iFocusRowIndex > focusrowindex) |
1488 if( iFocusRowIndex > focusrowindex) |
1464 { |
1489 { |
1465 GLX_LOG_INFO("GLX_CLOUD :: CGlxCloudViewControl::HandleDragL,b4 movedown"); |
1490 GLX_LOG_INFO("GLX_CLOUD :: CGlxCloudViewControl::HandleDragL,b4 movedown"); |
1471 GLX_LOG_INFO("GLX_CLOUD :: CGlxCloudViewControl::HandleDragL,b4 moveup"); |
1496 GLX_LOG_INFO("GLX_CLOUD :: CGlxCloudViewControl::HandleDragL,b4 moveup"); |
1472 iScrollDirection = 1; |
1497 iScrollDirection = 1; |
1473 MoveUpIfRequired(); |
1498 MoveUpIfRequired(); |
1474 } |
1499 } |
1475 } |
1500 } |
|
1501 |
|
1502 iTouchFeedback->InstantFeedback(ETouchFeedbackBasic); |
|
1503 iObserverEnterKeyEvent.HandleEnterKeyEventL((TInt) EAknCmdOpen); |
1476 consumed = ETrue; |
1504 consumed = ETrue; |
1477 Display()->Roster().SetPointerEventObservers( EAlfPointerEventReportDrag |
|
1478 + EAlfPointerEventReportLongTap |
|
1479 + EAlfPointerEventReportUnhandled, *this ); |
|
1480 Display()->Roster().DisableLongTapEventsWhenDragging(*this); |
|
1481 break; |
1505 break; |
1482 } |
1506 } |
1483 } |
1507 } |
1484 } |
1508 } |
1485 } |
1509 iViewDragged = EFalse; |
1486 |
|
1487 else if (aEvent.PointerEvent().iType == TPointerEvent::EDrag) |
|
1488 { |
|
1489 GLX_LOG_INFO("GLX_CLOUD :: CGlxCloudViewControl::HandlePointerEventL(EDrag) event"); |
|
1490 iTouchFeedback->InstantFeedback( ETouchFeedbackBasic ); |
|
1491 consumed = HandleDragL(aEvent.PointerEvent()); |
|
1492 } |
|
1493 else if (aEvent.PointerUp()) |
|
1494 { |
|
1495 |
|
1496 Env().CancelCustomCommands(this,ECustomEventFocusDragScroll); |
|
1497 Display()->Roster().SetPointerEventObservers(0, *this); |
|
1498 consumed = ETrue; |
|
1499 } |
1510 } |
1500 return consumed; |
1511 return consumed; |
1501 } |
1512 } |
1502 |
1513 |
1503 // --------------------------------------------------------------------------- |
1514 // --------------------------------------------------------------------------- |
1504 // HandleDragL() |
1515 // HandleDragL() |
1505 // --------------------------------------------------------------------------- |
1516 // --------------------------------------------------------------------------- |
1506 // |
1517 // |
1507 TBool CGlxCloudViewControl::HandleDragL(const TPointerEvent& aPointerEvent) |
1518 TBool CGlxCloudViewControl::HandleDragL(const TPointerEvent& aPointerEvent) |
1508 { |
1519 { |
1509 TRACER("GLX_CLOUD::CGlxCloudViewControl::HandleDragL"); |
1520 TBool consumed(EFalse); |
1510 TBool consumed = EFalse; |
1521 |
1511 TInt itemindex = GetAbsoluteIndex(aPointerEvent.iPosition); |
1522 // If Physics Emulation is going on, no need to entertain drag event |
1512 TInt focus = iMediaList.FocusIndex(); |
1523 if (iPhysicsStarted) |
1513 TInt focusrowindex = iFocusRowIndex; |
1524 return consumed; |
1514 |
1525 |
1515 //if index is not NULL then focus the tag and move the viewport down if necessary |
1526 //Simply ignore the first drag event as there is huge difference between position |
1516 if ( itemindex != KErrNotFound ) |
1527 //coordinates in drag event and corordinates in normal pointer down / up events |
1517 { |
1528 if (!iDragging) |
1518 if (focus != itemindex ) |
1529 { |
1519 { |
1530 //Note the current position for future reference |
1520 iTouchFeedback->InstantFeedback( ETouchFeedbackSensitive ); |
1531 iStart = aPointerEvent.iPosition; |
1521 iMediaList.SetFocusL (NGlxListDefs::EAbsolute,itemindex); |
1532 iPrev = iStart; |
1522 iFocusRowIndex = RowNumber (iMediaList.FocusIndex ()); |
1533 iDragging = ETrue; |
1523 GLX_LOG_INFO1("GLX_CLOUD :: CGlxCloudViewControl::HandleDragL,focusrowindex = %d",iFocusRowIndex); |
1534 return consumed; |
1524 if( iFocusRowIndex > focusrowindex) |
1535 } |
1525 { |
1536 |
1526 GLX_LOG_INFO("GLX_CLOUD :: CGlxCloudViewControl::HandleDragL,b4 movedown"); |
1537 TRect rect; |
1527 iScrollDirection = 0; |
1538 AknLayoutUtils::LayoutMetricsRect(AknLayoutUtils::EMainPane, rect); |
1528 MoveDownIfRequired(); |
1539 TInt cntrlTopYLimit = rect.iTl.iY; |
1529 } |
1540 TInt cntrlBottomYLimit = rect.iBr.iY; |
1530 else if( iFocusRowIndex < focusrowindex ) |
1541 TInt delta = iPrev.iY - aPointerEvent.iPosition.iY; |
1531 { |
1542 |
1532 GLX_LOG_INFO("GLX_CLOUD :: CGlxCloudViewControl::HandleDragL,b4 moveup"); |
1543 //Check for physics threshold, before regidterting drag corordinates |
1533 iScrollDirection = 1; |
1544 TInt deltaAbs = delta < 0 ? -delta : delta; |
1534 MoveUpIfRequired(); |
1545 TBool panning = deltaAbs >= iPhysics->DragThreshold(); |
1535 } |
1546 if (panning) |
1536 } |
1547 { |
1537 consumed = ETrue; |
1548 TPoint deltaPt = iPrev - aPointerEvent.iPosition; |
1538 } |
1549 iPhysics->RegisterPanningPosition(deltaPt); |
1539 |
1550 iPrev = aPointerEvent.iPosition; |
1540 TRect screenstartrect; |
1551 iViewDragged = ETrue; |
1541 //the starting rect of the visible screen |
1552 } |
1542 screenstartrect.SetRect(0,0,iTagScreenWidth,2*KRowHeight); |
1553 consumed = ETrue; |
1543 |
1554 |
1544 TRect screenendrect; |
1555 //Calculate margin after which we might get pointer out of screen, and we might not |
1545 //the end rect of the visible screen |
1556 //get further pointer events. Also This is currently only 10% of total delta we can find, |
1546 screenendrect.SetRect(0,(iTagScreenHeight-(2*KRowHeight)),iTagScreenWidth,iTagScreenHeight); |
1557 //to get margin corresponding to movement of user flicking speed |
1547 |
1558 //This implies higher speed - higher margin |
1548 //dragging down |
1559 //Lower speed - 0 margin |
1549 if(screenendrect.Contains(aPointerEvent.iPosition)) |
1560 TInt deltaMargin = deltaAbs * KBoundaryMargin; |
1550 { |
1561 |
1551 iIsDragging = 1; |
1562 //Code to predict future movement if same delta movement we might get in future |
1552 Env().Send(TAlfCustomEventCommand(ECustomEventFocusDragScroll, |
1563 //For flick event down - If the movement goes below screen, start physics |
1553 this),KDragHoldTime); |
1564 //or For flick event up - If the movement goes above screen, start physics |
1554 } |
1565 if (((delta < 0) && (aPointerEvent.iPosition.iY - delta >= cntrlBottomYLimit - deltaMargin)) |
1555 //dragging up |
1566 || ((delta > 0) && (aPointerEvent.iPosition.iY - delta <= cntrlTopYLimit + deltaMargin))) |
1556 else if (screenstartrect.Contains(aPointerEvent.iPosition)) |
1567 { |
1557 { |
1568 iPhysicsStarted = ETrue; |
1558 iIsDragging = 2; |
1569 } |
1559 Env().Send(TAlfCustomEventCommand(ECustomEventFocusDragScroll, |
1570 |
1560 this),KDragHoldTime); |
1571 //If found that possibly in next move it might go out of bounds, start physics |
1561 } |
1572 //emulation |
|
1573 if (iPhysicsStarted && iDragging) |
|
1574 { |
|
1575 TPoint drag = iStart - aPointerEvent.iPosition; |
|
1576 iPhysics->StartPhysics(drag, iStartTime); |
|
1577 iDragging = EFalse; |
|
1578 } |
1562 |
1579 |
1563 return consumed; |
1580 return consumed; |
1564 } |
1581 } |
1565 |
1582 |
1566 // --------------------------------------------------------------------------- |
1583 // --------------------------------------------------------------------------- |
1682 { |
1699 { |
1683 GLX_LOG_INFO("GLX_CLOUD :: CGlxCloudViewControl::offerEvent(EEventScrollDown) event"); |
1700 GLX_LOG_INFO("GLX_CLOUD :: CGlxCloudViewControl::offerEvent(EEventScrollDown) event"); |
1684 TInt steps = TInt(aEvent.CustomEventData()); |
1701 TInt steps = TInt(aEvent.CustomEventData()); |
1685 UpdateScrollBar(steps,EFalse); |
1702 UpdateScrollBar(steps,EFalse); |
1686 Scroll(); |
1703 Scroll(); |
|
1704 iPhysics->StopPhysics(); |
|
1705 |
1687 status = EEventHandled; |
1706 status = EEventHandled; |
1688 } |
1707 } |
1689 break; |
1708 break; |
1690 case EEventScrollPageUp: |
1709 case EEventScrollPageUp: |
1691 { |
1710 { |
1692 GLX_LOG_INFO("GLX_CLOUD :: CGlxCloudViewControl::offerEvent(EEventScrollPageUp) event"); |
1711 GLX_LOG_INFO("GLX_CLOUD :: CGlxCloudViewControl::offerEvent(EEventScrollPageUp) event"); |
1693 UpdateScrollBar(-iScrollEventData.mViewLength); |
1712 UpdateScrollBar(-iScrollEventData.mViewLength); |
1694 Scroll(); |
1713 Scroll(); |
1695 status = EEventHandled; |
1714 iPhysics->StopPhysics(); |
|
1715 status = EEventHandled; |
1696 } |
1716 } |
1697 break; |
1717 break; |
1698 case EEventScrollPageDown: |
1718 case EEventScrollPageDown: |
1699 { |
1719 { |
1700 GLX_LOG_INFO("GLX_CLOUD :: CGlxCloudViewControl::offerEvent(EEventScrollPageDown) event"); |
1720 GLX_LOG_INFO("GLX_CLOUD :: CGlxCloudViewControl::offerEvent(EEventScrollPageDown) event"); |
1701 UpdateScrollBar(iScrollEventData.mViewLength); |
1721 UpdateScrollBar(iScrollEventData.mViewLength); |
1702 Scroll(); |
1722 Scroll(); |
|
1723 iPhysics->StopPhysics(); |
1703 status = EEventHandled; |
1724 status = EEventHandled; |
1704 } |
1725 } |
1705 break; |
1726 break; |
1706 }//end switch |
1727 }//end switch |
1707 } |
1728 } |
1753 baseelement->makeInterface (IAlfWidgetEventHandler::type())); |
1774 baseelement->makeInterface (IAlfWidgetEventHandler::type())); |
1754 //pass the custom event to scrollbar element so as to scroll to the required position |
1775 //pass the custom event to scrollbar element so as to scroll to the required position |
1755 iScrollbarElement->offerEvent(*(iScrollBarWidget->control()),customevent); |
1776 iScrollbarElement->offerEvent(*(iScrollBarWidget->control()),customevent); |
1756 GLX_LOG_INFO1("GLX_CLOUD ::CGlxCloudViewControl::Scroll(),position %d ",iScrollEventData.mViewStartPos); |
1777 GLX_LOG_INFO1("GLX_CLOUD ::CGlxCloudViewControl::Scroll(),position %d ",iScrollEventData.mViewStartPos); |
1757 iViewPortPosition.iY = iScrollEventData.mViewStartPos; |
1778 iViewPortPosition.iY = iScrollEventData.mViewStartPos; |
1758 iViewPortLayout->SetViewportPos (iViewPortPosition,1000); |
1779 iViewPortLayout->SetViewportPos(iViewPortPosition, KSlowCloudMovement); |
1759 } |
1780 } |
1760 |
1781 |
1761 // --------------------------------------------------------------------------- |
1782 // --------------------------------------------------------------------------- |
1762 // UpdateScrollBar() |
1783 // UpdateScrollBar() |
1763 // --------------------------------------------------------------------------- |
1784 // --------------------------------------------------------------------------- |
1840 { |
1861 { |
1841 UpdateLayout(); |
1862 UpdateLayout(); |
1842 FetchAttributeFromCacheL(); |
1863 FetchAttributeFromCacheL(); |
1843 //generate row structures and draw rows on screen |
1864 //generate row structures and draw rows on screen |
1844 UpdateRowDataL (); |
1865 UpdateRowDataL (); |
1845 } |
1866 |
1846 } |
1867 InitPhysicsL(); |
1847 } |
1868 } |
|
1869 } |
|
1870 } |
|
1871 |
|
1872 // --------------------------------------------------------------------------- |
|
1873 // InitPhysicsL() |
|
1874 // --------------------------------------------------------------------------- |
|
1875 // |
|
1876 void CGlxCloudViewControl::InitPhysicsL() |
|
1877 { |
|
1878 //Update physics with new total layout, viewable size and our landscape mode |
|
1879 iPhysics->InitPhysicsL(TSize(iViewPortVirtualSize.iWidth, |
|
1880 iViewPortVirtualSize.iHeight), TSize(iTagScreenWidth, |
|
1881 iTagScreenHeight), EFalse); |
|
1882 |
|
1883 //Note: Physics viewposition must always be mid of viewable screen size to get best result |
|
1884 //I learned the hard way |
|
1885 iViewPosition.SetXY(iTagScreenWidth / 2, iTagScreenHeight / 2); |
|
1886 } |
|
1887 |
|
1888 // --------------------------------------------------------------------------- |
|
1889 // ViewPositionChanged() |
|
1890 // --------------------------------------------------------------------------- |
|
1891 // |
|
1892 void CGlxCloudViewControl::ViewPositionChanged(const TPoint& aNewPosition, |
|
1893 TBool aDrawNow, TUint /*aFlags*/) |
|
1894 { |
|
1895 iViewPosition = aNewPosition; |
|
1896 iViewPortPosition.iY = iViewPosition.iY - iTagScreenHeight / 2; |
|
1897 if (aDrawNow) |
|
1898 { |
|
1899 iViewPortLayout->SetViewportPos(iViewPortPosition, KFastCloudMovement); |
1848 |
1900 |
|
1901 iScrollEventData.mViewStartPos = iViewPortPosition.iY; |
|
1902 Scroll(); |
|
1903 } |
|
1904 } |
|
1905 |
|
1906 // --------------------------------------------------------------------------- |
|
1907 // PhysicEmulationEnded() |
|
1908 // --------------------------------------------------------------------------- |
|
1909 // |
|
1910 void CGlxCloudViewControl::PhysicEmulationEnded() |
|
1911 { |
|
1912 iPhysicsStarted = EFalse; |
|
1913 } |
|
1914 |
|
1915 // --------------------------------------------------------------------------- |
|
1916 // ViewPosition() |
|
1917 // --------------------------------------------------------------------------- |
|
1918 // |
|
1919 TPoint CGlxCloudViewControl::ViewPosition() const |
|
1920 { |
|
1921 return iViewPosition; |
|
1922 } |
|
1923 |
|
1924 // --------------------------------------------------------------------------- |
|
1925 // IsLandscape() |
|
1926 // --------------------------------------------------------------------------- |
|
1927 // |
|
1928 TBool CGlxCloudViewControl::IsLandscape() |
|
1929 { |
|
1930 TRect rect; |
|
1931 AknLayoutUtils::LayoutMetricsRect(AknLayoutUtils::EScreen, rect); |
|
1932 if(rect.Width() > rect.Height()) |
|
1933 { |
|
1934 return ETrue; |
|
1935 } |
|
1936 else |
|
1937 { |
|
1938 return EFalse; |
|
1939 } |
|
1940 } |
1849 //End of file |
1941 //End of file |