uifw/AvKon/src/Aknslider.cpp
branchRCL_3
changeset 19 aecbbf00d063
parent 17 a1caeb42b3a3
child 20 d48ab3b357f1
equal deleted inserted replaced
18:fcdfafb36fe7 19:aecbbf00d063
    63 // Default draw color 
    63 // Default draw color 
    64 const TInt KAknSliderDefaultDrawColor = 120;
    64 const TInt KAknSliderDefaultDrawColor = 120;
    65 const TInt KScrollRepeatTimeout = 250000; // 0.25 seconds
    65 const TInt KScrollRepeatTimeout = 250000; // 0.25 seconds
    66 const TInt KStableFeedbackIntesity = 100;
    66 const TInt KStableFeedbackIntesity = 100;
    67 const TInt KFeedbackTimeout = 100000;
    67 const TInt KFeedbackTimeout = 100000;
       
    68 const TInt KNoFeedbackTimeout = 0;
       
    69 const TInt KStepThreshold = 15;
    68 // ============================================================================
    70 // ============================================================================
    69 // Internal class to hold slider control data, primarily coming from resource.
    71 // Internal class to hold slider control data, primarily coming from resource.
    70 NONSHARABLE_CLASS( CAknSliderData ): public CBase
    72 NONSHARABLE_CLASS( CAknSliderData ): public CBase
    71     {
    73     {
    72 public:
    74 public:
   535         EMbmAvkonQgn_graf_nslider_vertical_tick_major_mask,
   537         EMbmAvkonQgn_graf_nslider_vertical_tick_major_mask,
   536         EMbmAvkonQgn_graf_nslider_marker_mask
   538         EMbmAvkonQgn_graf_nslider_marker_mask
   537         }; 
   539         }; 
   538     const TAknsItemID iconSkinIDArray[] = 
   540     const TAknsItemID iconSkinIDArray[] = 
   539         {
   541         {
   540         KAknsIIDQgnGrafNsliderVerticalTop,   //KAknsIIDNone,     
   542         KAknsIIDNone,//KAknsIIDQgnGrafNsliderVerticalTop,        
   541         KAknsIIDQgnGrafNsliderVerticalBottom,//KAknsIIDNone,
   543         KAknsIIDNone,//KAknsIIDQgnGrafNsliderVerticalBottom,
   542         KAknsIIDQgnGrafNsliderVerticalMiddle,//KAknsIIDNone,
   544         KAknsIIDNone,//KAknsIIDQgnGrafNsliderVerticalMiddle,
   543         KAknsIIDQgnGrafNsliderVerticalMarker,//KAknsIIDNone,
   545         KAknsIIDNone,// KAknsIIDQgnGrafNsliderVerticalMarker,
   544         KAknsIIDQgnGrafNsliderVerticalTickMajor,//KAknsIIDNone,
   546         KAknsIIDNone,// KAknsIIDQgnGrafNsliderVerticalTIckMajor,
   545         KAknsIIDQgnGrafNsliderVerticalMarker//KAknsIIDNone
   547         KAknsIIDNone//KAknsIIDQgnGrafNsliderVerticalMarker
   546         };
   548         };
   547         
   549         
   548     const TInt element[] = 
   550     const TInt element[] = 
   549         {
   551         {
   550         CAknSlider::EElemEmptyLeftCap,
   552         CAknSlider::EElemEmptyLeftCap,
  1495 EXPORT_C CFbsBitmap* CAknSlider::CreateBitmapL( TInt aValue, TInt aResourceId )
  1497 EXPORT_C CFbsBitmap* CAknSlider::CreateBitmapL( TInt aValue, TInt aResourceId )
  1496     {
  1498     {
  1497     TResourceReader reader;
  1499     TResourceReader reader;
  1498     CEikonEnv::Static()->CreateResourceReaderLC( reader, aResourceId );
  1500     CEikonEnv::Static()->CreateResourceReaderLC( reader, aResourceId );
  1499 
  1501 
  1500     TInt sliderType = reader.ReadInt16();
  1502     reader.ReadInt16(); // ignore layout
  1501     if ( sliderType == EAknSliderWithFeedbackStyle )
       
  1502         {
       
  1503         reader.ReadInt16(); // ignore type
       
  1504         reader.ReadInt16(); // ignore layout
       
  1505         }
       
  1506     TInt minValue = reader.ReadInt16();
  1503     TInt minValue = reader.ReadInt16();
  1507     TInt maxValue = reader.ReadInt16();
  1504     TInt maxValue = reader.ReadInt16();
  1508     CleanupStack::PopAndDestroy(); // reader
  1505     CleanupStack::PopAndDestroy(); // reader
  1509 
  1506 
  1510     return CreateBitmapL( aValue, minValue, maxValue );
  1507     return CreateBitmapL( aValue, minValue, maxValue );
  1541         TInt aValue, TInt aResourceId )
  1538         TInt aValue, TInt aResourceId )
  1542     {
  1539     {
  1543     TResourceReader reader;
  1540     TResourceReader reader;
  1544     CEikonEnv::Static()->CreateResourceReaderLC( reader, aResourceId );
  1541     CEikonEnv::Static()->CreateResourceReaderLC( reader, aResourceId );
  1545 
  1542 
  1546     TInt sliderType = reader.ReadInt16();
  1543     reader.ReadInt16(); // ignore layout
  1547     if ( sliderType == EAknSliderWithFeedbackStyle )
       
  1548         {
       
  1549         reader.ReadInt16(); // ignore type
       
  1550         reader.ReadInt16(); // ignore layout
       
  1551         }
       
  1552     TInt minValue = reader.ReadInt16();
  1544     TInt minValue = reader.ReadInt16();
  1553     TInt maxValue = reader.ReadInt16();
  1545     TInt maxValue = reader.ReadInt16();
  1554     CleanupStack::PopAndDestroy(); // reader
  1546     CleanupStack::PopAndDestroy(); // reader
  1555     
  1547     
  1556     return CreateSetStyleListBoxIconL( aValue, minValue, maxValue );
  1548     return CreateSetStyleListBoxIconL( aValue, minValue, maxValue );
  3156             {
  3148             {
  3157             case TPointerEvent::EButton1Down:
  3149             case TPointerEvent::EButton1Down:
  3158                 {
  3150                 {
  3159                 if ( touchDownArea.Contains( aEvent.iPosition ) )
  3151                 if ( touchDownArea.Contains( aEvent.iPosition ) )
  3160                     {
  3152                     {
       
  3153                     TInt stepCount = SliderData()->Range() / SliderData()->iStepSize;
       
  3154                     if ( stepCount <= KStepThreshold )
       
  3155                         {
       
  3156                         MTouchFeedback* feedback = MTouchFeedback::Instance();
       
  3157                         if ( feedback )
       
  3158                             {
       
  3159                             feedback->InstantFeedback( this, ETouchFeedbackBasicSlider, aEvent );
       
  3160                             }
       
  3161                         }
  3161                        // repeat until thumb reaches the stylus down position    
  3162                        // repeat until thumb reaches the stylus down position    
  3162                     iExt->iPenInputPos = aEvent.iPosition;
  3163                     iExt->iPenInputPos = aEvent.iPosition;
  3163 
  3164 
  3164                     // Click was inside and down slider marker area
  3165                     // Click was inside and down slider marker area
  3165                     iExt->SetFlag( CAknSliderExtension::EFlagPointerDown );
  3166                     iExt->SetFlag( CAknSliderExtension::EFlagPointerDown );
  3167                     if ( mrect.Contains( aEvent.iPosition ) )
  3168                     if ( mrect.Contains( aEvent.iPosition ) )
  3168                         {
  3169                         {
  3169                         MTouchFeedback* feedback = MTouchFeedback::Instance();
  3170                         MTouchFeedback* feedback = MTouchFeedback::Instance();
  3170                         if ( feedback )
  3171                         if ( feedback )
  3171                             {
  3172                             {
  3172                             feedback->InstantFeedback( this, ETouchFeedbackSlider, aEvent );
  3173                             feedback->InstantFeedback( this, ETouchFeedbackBasicSlider, aEvent );
  3173                             }
  3174                             }
  3174                         iExt->SetFlag( CAknSliderExtension::EFlagDraggingThumb );
  3175                         iExt->SetFlag( CAknSliderExtension::EFlagDraggingThumb );
  3175                         reportDragEvent = EDragMarkerStart;
  3176                         reportDragEvent = EDragMarkerStart;
  3176                         }                    
  3177                         }                    
  3177                     // Marker icon changes - draw
  3178                     // Marker icon changes - draw
  3254                     {
  3255                     {
  3255                     MTouchFeedback* feedback = MTouchFeedback::Instance();
  3256                     MTouchFeedback* feedback = MTouchFeedback::Instance();
  3256                     if ( feedback )
  3257                     if ( feedback )
  3257                         {
  3258                         {
  3258                         feedback->InstantFeedback( this,
  3259                         feedback->InstantFeedback( this,
  3259                                                    ETouchFeedbackSlider,
  3260                                                    ETouchFeedbackBasicSlider,
  3260                                                    ETouchFeedbackVibra,
  3261                                                    ETouchFeedbackVibra,
  3261                                                    aEvent );
  3262                                                    aEvent );
  3262                         }
  3263                         }
  3263                     }
  3264                     }
  3264                 StopFeedback();
  3265                 StopFeedback();
  3615 
  3616 
  3616     if ( sliderValue != oldSliderValue )
  3617     if ( sliderValue != oldSliderValue )
  3617         {
  3618         {
  3618         if( aFeedback )
  3619         if( aFeedback )
  3619             {
  3620             {
  3620             MTouchFeedback* feedback = MTouchFeedback::Instance();
  3621             TInt stepCount = SliderData()->Range() / SliderData()->iStepSize;
  3621             if ( feedback )
  3622             if ( stepCount > KStepThreshold )
  3622                {
  3623                 {
  3623                feedback->InstantFeedback( this, ETouchFeedbackSlider );
  3624                 if ( iExt->IsFlagSet( CAknSliderExtension::EFlagPlayingContinuousFb ))
  3624                }          
  3625                     {
       
  3626                     if ( SliderData()->iFeedbackStyle == EAknSliderFbDynamic )
       
  3627                         {
       
  3628                         ModifyFeedback();
       
  3629                         }
       
  3630                     }
       
  3631                 else
       
  3632                     {
       
  3633                     StartFeedback( NULL, KNoFeedbackTimeout );
       
  3634                     }
       
  3635                 }
       
  3636             else
       
  3637                 {
       
  3638                 MTouchFeedback* feedback = MTouchFeedback::Instance();
       
  3639                 if ( feedback )
       
  3640                     {
       
  3641                     feedback->InstantFeedback( this, ETouchFeedbackBasicSlider );
       
  3642                     }
       
  3643                 }            
  3625             }
  3644             }
  3626 
  3645 
  3627         Window().Invalidate( Rect() );
  3646         Window().Invalidate( Rect() );
  3628         }
  3647         }
  3629     }    
  3648     }    
  4188     TRgb color;
  4207     TRgb color;
  4189     TInt error;
  4208     TInt error;
  4190     if ( Layout() != EAknSettingsItemSliderLayout &&
  4209     if ( Layout() != EAknSettingsItemSliderLayout &&
  4191          Layout() != EAknSettingsItemSliderLayoutWithGraphics  &&
  4210          Layout() != EAknSettingsItemSliderLayoutWithGraphics  &&
  4192          Layout() != EAknSliderLayoutVertical &&
  4211          Layout() != EAknSliderLayoutVertical &&
  4193          Layout() != EAknSliderLayoutHorizontal &&
  4212          Layout() != EAknSliderLayoutHorizontal ) 
  4194          Layout() != EAknMIDPFormSliderLayout ) 
       
  4195         {
  4213         {
  4196         error = AknsUtils::GetCachedColor( skin, color,
  4214         error = AknsUtils::GetCachedColor( skin, color,
  4197                     KAknsIIDQsnTextColors, EAknsCIQsnTextColorsCG8 );
  4215                     KAknsIIDQsnTextColors, EAknsCIQsnTextColorsCG8 );
  4198         }
  4216         }
  4199     else
  4217     else
  4257 void CAknSlider::StartFeedback( const TPointerEvent* aPointerEvent, TTimeIntervalMicroSeconds32 aTimeout )
  4275 void CAknSlider::StartFeedback( const TPointerEvent* aPointerEvent, TTimeIntervalMicroSeconds32 aTimeout )
  4258     {
  4276     {
  4259     MTouchFeedback* feedback = MTouchFeedback::Instance();
  4277     MTouchFeedback* feedback = MTouchFeedback::Instance();
  4260     if ( feedback )
  4278     if ( feedback )
  4261         {
  4279         {
  4262         TTouchContinuousFeedback type = ETouchContinuousSmooth;
       
  4263         TInt intensity = KStableFeedbackIntesity;
  4280         TInt intensity = KStableFeedbackIntesity;
  4264         
       
  4265         if ( SliderData()->iFeedbackStyle == EAknSliderFbDynamic )
  4281         if ( SliderData()->iFeedbackStyle == EAknSliderFbDynamic )
  4266             {
  4282             {
  4267             type = ETouchDynamicSlider;
       
  4268             intensity = FeedbackIntensity();
  4283             intensity = FeedbackIntensity();
  4269             }
  4284             }
  4270         
  4285         feedback->StartFeedback( this, ETouchContinuousSlider, aPointerEvent, intensity, aTimeout );
  4271         feedback->StartFeedback( this, type, aPointerEvent, intensity, aTimeout );
       
  4272         iExt->SetFlag( CAknSliderExtension::EFlagPlayingContinuousFb );
  4286         iExt->SetFlag( CAknSliderExtension::EFlagPlayingContinuousFb );
  4273         }
  4287         }
  4274     }
  4288     }
  4275 
  4289 
  4276 // ----------------------------------------------------------------------------
  4290 // ----------------------------------------------------------------------------