uifw/ganes/src/HgScroller.cpp
branchRCL_3
changeset 9 0aa5fbdfbc30
parent 8 71dd06cfe933
child 10 3d340a0166ff
equal deleted inserted replaced
8:71dd06cfe933 9:0aa5fbdfbc30
   171     if( IsDisplayed( aIndex ) )
   171     if( IsDisplayed( aIndex ) )
   172         DrawDeferred();
   172         DrawDeferred();
   173     }
   173     }
   174 
   174 
   175 // -----------------------------------------------------------------------------
   175 // -----------------------------------------------------------------------------
   176 // CHgScroller::RefreshScreen()
   176 // CHgScroller::FirstIndexOnScreen()
   177 // -----------------------------------------------------------------------------
   177 // -----------------------------------------------------------------------------
   178 //
   178 //
   179 EXPORT_C TInt CHgScroller::FirstIndexOnScreen()
   179 EXPORT_C TInt CHgScroller::FirstIndexOnScreen()
   180     {
   180     {
   181     return CurrentIndex();
   181     return CurrentIndex();
   182     }
   182     }
   183 
   183 
   184 // -----------------------------------------------------------------------------
   184 // -----------------------------------------------------------------------------
   185 // CHgScroller::RefreshScreen()
   185 // CHgScroller::SetFirstIndexOnScreen()
       
   186 // -----------------------------------------------------------------------------
       
   187 //
       
   188 EXPORT_C void CHgScroller::SetFirstIndexOnScreen( TInt aFirstIndexOnScreen )
       
   189     {
       
   190     FitTopItemToView( aFirstIndexOnScreen );
       
   191     }
       
   192 
       
   193 // -----------------------------------------------------------------------------
       
   194 // CHgScroller::ItemsOnScreen()
   186 // -----------------------------------------------------------------------------
   195 // -----------------------------------------------------------------------------
   187 //
   196 //
   188 EXPORT_C TInt CHgScroller::ItemsOnScreen()
   197 EXPORT_C TInt CHgScroller::ItemsOnScreen()
   189     {
   198     {
   190     return iItemsOnScreen;
   199     return iItemsOnScreen;
   191     }
   200     }
   192 
   201 
   193 // -----------------------------------------------------------------------------
   202 // -----------------------------------------------------------------------------
   194 // CHgScroller::RefreshScreen()
   203 // CHgScroller::SelectedIndex()
   195 // -----------------------------------------------------------------------------
   204 // -----------------------------------------------------------------------------
   196 //
   205 //
   197 EXPORT_C TInt CHgScroller::SelectedIndex()
   206 EXPORT_C TInt CHgScroller::SelectedIndex()
   198     {
   207     {
   199     return iSelectedIndex;
   208     return iSelectedIndex;
   200     }
   209     }
   201 
   210 
   202 // -----------------------------------------------------------------------------
   211 // -----------------------------------------------------------------------------
   203 // CHgScroller::RefreshScreen()
   212 // CHgScroller::SetSelectedIndex()
   204 // -----------------------------------------------------------------------------
   213 // -----------------------------------------------------------------------------
   205 //
   214 //
   206 EXPORT_C void CHgScroller::SetSelectedIndex( TInt aIndex )
   215 EXPORT_C void CHgScroller::SetSelectedIndex( TInt aIndex )
   207     {
   216     {
   208     if( aIndex >= 0 && aIndex < iItems.Count() )
   217     if( aIndex >= 0 && aIndex < iItems.Count() )
   290 // CHgScroller::GetMarkedItemsL()
   299 // CHgScroller::GetMarkedItemsL()
   291 // -----------------------------------------------------------------------------
   300 // -----------------------------------------------------------------------------
   292 //
   301 //
   293 EXPORT_C void CHgScroller::GetMarkedItemsL( RArray<TInt>& aIndexes )
   302 EXPORT_C void CHgScroller::GetMarkedItemsL( RArray<TInt>& aIndexes )
   294     {
   303     {
       
   304     ::CleanupClosePushL(aIndexes);
   295     for(TInt i = 0; i < iItems.Count(); ++i)
   305     for(TInt i = 0; i < iItems.Count(); ++i)
   296         {
   306         {
   297         if(iItems[i]->Flags() & CHgItem::EHgItemFlagMarked )
   307         if(iItems[i]->Flags() & CHgItem::EHgItemFlagMarked )
   298             {
   308             {
   299             aIndexes.AppendL( i );
   309             aIndexes.AppendL( i );
   300             }
   310             }
   301         }
   311         }
       
   312     CleanupStack::Pop(&aIndexes);
   302     }
   313     }
   303 
   314 
   304 // -----------------------------------------------------------------------------
   315 // -----------------------------------------------------------------------------
   305 // CHgScroller::EnableScrollBufferL()
   316 // CHgScroller::EnableScrollBufferL()
   306 // -----------------------------------------------------------------------------
   317 // -----------------------------------------------------------------------------
   608     {
   619     {
   609     TBool sbHandles = EFalse;
   620     TBool sbHandles = EFalse;
   610     if( iScrollbar )
   621     if( iScrollbar )
   611         {
   622         {
   612         sbHandles = iScrollbar->HandlePointerEventL( aEvent );
   623         sbHandles = iScrollbar->HandlePointerEventL( aEvent );
       
   624         
       
   625         if(  sbHandles 
       
   626                 && iPhysics 
       
   627                 && iPhysics->OngoingPhysicsAction() == CAknPhysics::EAknPhysicsActionFlicking )
       
   628             {
       
   629             iPhysics->StopPhysics();
       
   630             iScrollbar->Reset();
       
   631             MTouchFeedback* feedback = MTouchFeedback::Instance();
       
   632             if ( feedback )
       
   633                 {
       
   634                 feedback->InstantFeedback( this, ETouchFeedbackList, aEvent );
       
   635                 }
       
   636             return sbHandles;
       
   637             }
       
   638         
   613         if ( sbHandles && !iScrollbar->IsStatic() )
   639         if ( sbHandles && !iScrollbar->IsStatic() )
   614             {
   640             {
   615             MTouchFeedback* feedback = MTouchFeedback::Instance();
   641             MTouchFeedback* feedback = MTouchFeedback::Instance();
   616             // Start drag
   642             // Start drag
   617             if( aEvent.iType == TPointerEvent::EButton1Down )
   643             if( aEvent.iType == TPointerEvent::EButton1Down )
   632                     {
   658                     {
   633                     TTimeIntervalMicroSeconds32 timeout( 300000 );
   659                     TTimeIntervalMicroSeconds32 timeout( 300000 );
   634                     feedback->StartFeedback( this, 
   660                     feedback->StartFeedback( this, 
   635                                              ETouchContinuousSlider, 
   661                                              ETouchContinuousSlider, 
   636                                              &aEvent, 
   662                                              &aEvent, 
   637                                              KIntensity, // intensity 50%
   663                                              KIntensity, // intensity
   638                                              timeout );
   664                                              timeout );
   639                     }
   665                     }
   640                 }
   666                 }
   641             // End drag
   667             // End drag
   642             else if( aEvent.iType == TPointerEvent::EButton1Up )
   668             else if( aEvent.iType == TPointerEvent::EButton1Up )
   743 // CHgScroller::HandleUpEventL()
   769 // CHgScroller::HandleUpEventL()
   744 // -----------------------------------------------------------------------------
   770 // -----------------------------------------------------------------------------
   745 //
   771 //
   746 void CHgScroller::HandleUpEventL( const TPointerEvent& aEvent )
   772 void CHgScroller::HandleUpEventL( const TPointerEvent& aEvent )
   747     {
   773     {
   748     MTouchFeedback* feedback = MTouchFeedback::Instance();
       
   749     TTouchFeedbackType type = ETouchFeedbackVibra;
       
   750     if( iPanning )
   774     if( iPanning )
   751         {
   775         {
   752         // enable physics
   776         // enable physics
   753         TPoint drag = iStart - aEvent.iPosition;
   777         TPoint drag = iStart - aEvent.iPosition;
   754         if(iLandscapeScrolling && AknLayoutUtils::LayoutMirrored())
   778         if(iLandscapeScrolling && AknLayoutUtils::LayoutMirrored())
   755             drag = -drag;
   779             drag = -drag;
   756         iPhysics->StartPhysics(drag, iStartTime);
   780         iPhysics->StartPhysics(drag, iStartTime);
   757         if ( feedback && iPhysics->OngoingPhysicsAction() == CAknPhysics::EAknPhysicsActionFlicking )
       
   758             {
       
   759             feedback->InstantFeedback( this, ETouchFeedbackFlick, type, aEvent );
       
   760             }
       
   761         }
   781         }
   762     else
   782     else
   763         {
   783         {
   764         HandleSelectionL();
   784         HandleSelectionL();
       
   785         MTouchFeedback* feedback = MTouchFeedback::Instance();
   765         if ( feedback && iSelectedIndex != KErrNotFound )
   786         if ( feedback && iSelectedIndex != KErrNotFound )
   766             {
   787             {
   767             feedback->InstantFeedback( this, ETouchFeedbackList, type, aEvent );
   788             feedback->InstantFeedback( this, ETouchFeedbackList, ETouchFeedbackVibra, aEvent );
   768             }
   789             }
   769         }
   790         }
   770     }
   791     }
   771 
   792 
   772 // -----------------------------------------------------------------------------
   793 // -----------------------------------------------------------------------------
  1014 // CHgScroller::ScrollBarPositionChanged()
  1035 // CHgScroller::ScrollBarPositionChanged()
  1015 // -----------------------------------------------------------------------------
  1036 // -----------------------------------------------------------------------------
  1016 //
  1037 //
  1017 void CHgScroller::ScrollBarPositionChanged( const TPoint& aNewPosition )
  1038 void CHgScroller::ScrollBarPositionChanged( const TPoint& aNewPosition )
  1018     {
  1039     {
       
  1040     if( iPhysics->OngoingPhysicsAction() == CAknPhysics::EAknPhysicsActionFlicking )
       
  1041         return;
       
  1042     
  1019     iViewPosition = aNewPosition;
  1043     iViewPosition = aNewPosition;
  1020     iPhysics->StopPhysics();
  1044     iPhysics->StopPhysics();
  1021     
  1045     
  1022     if( iScrollBarType == EHgScrollerTimeStrip )
  1046     if( iScrollBarType == EHgScrollerTimeStrip )
  1023         {
  1047         {
  1086     if(newRow != iCurrentRow)
  1110     if(newRow != iCurrentRow)
  1087         {
  1111         {
  1088         iCurrentRow = newRow;
  1112         iCurrentRow = newRow;
  1089         
  1113         
  1090         TBool needsFeedback = 
  1114         TBool needsFeedback = 
  1091                 ( iCurrentRow >= 0 && iCurrentRow <= iItems.Count() )
  1115                 ( CurrentIndex() > 0 && CurrentIndex() <= iItems.Count() )
  1092                 || ( iItems.Count() - iCurrentRow > ItemsOnScreen() );
  1116                 || ( iItems.Count() - CurrentIndex() > ItemsOnScreen() );
  1093         
  1117         
  1094         TInt action = iPhysics->OngoingPhysicsAction();
  1118         TInt action = iPhysics->OngoingPhysicsAction();
  1095         if( action !=  CAknPhysics::EAknPhysicsActionNone && needsFeedback )
  1119         if( action !=  CAknPhysics::EAknPhysicsActionNone && needsFeedback )
  1096             {
  1120             {
  1097             TTouchFeedbackType type( ETouchFeedbackVibra );
  1121             TTouchFeedbackType type( ETouchFeedbackVibra );