1 /* |
|
2 * Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: The implementation for presentation elements. |
|
15 * |
|
16 */ |
|
17 |
|
18 #include <avkon.hrh> |
|
19 #include <avkon.mbg> |
|
20 //Toolkit Includes |
|
21 // Alfred Client includes |
|
22 #include <alf/alfenv.h> |
|
23 #include <alf/alfroster.h> |
|
24 #include <alf/alfdisplay.h> |
|
25 #include <alf/alfbitmapprovider.h> |
|
26 #include <alf/alftexture.h> |
|
27 #include <alf/alfbrusharray.h> |
|
28 #include <alf/alftextvisual.h> |
|
29 #include <alf/alfevent.h> |
|
30 |
|
31 //Widget Model Includes |
|
32 #include <alf/alfwidgetevents.h> |
|
33 #include <alf/alfwidgetenvextension.h> |
|
34 #include <alf/ialfmodel.h> |
|
35 |
|
36 //Avkon Includes |
|
37 #include <AknUtils.h> |
|
38 #include <AknsConstants.h> |
|
39 #include <utf.h> |
|
40 #include <math.h> |
|
41 |
|
42 //slider widget includes |
|
43 #include <mul/mulevent.h> |
|
44 #include "mulsliderhorizontal.h" |
|
45 #include "mulsliderwidget.h" |
|
46 #include "mulslidercontrol.h" |
|
47 #include "mulslidermodel.h" |
|
48 #include "mulsliderdefinitions.h" |
|
49 |
|
50 #include "mulsliderutils.h" |
|
51 |
|
52 //Timer function includes |
|
53 #include "mulsliderlongtaptimer.h" |
|
54 |
|
55 |
|
56 namespace Alf |
|
57 { |
|
58 |
|
59 // Structure to store data for the slider element class |
|
60 |
|
61 struct MulHorizontalSliderDataImpl |
|
62 { |
|
63 |
|
64 bool mOperation;// Drag state |
|
65 float mTickInPixels;// Tick size in Pixel |
|
66 bool mIsLongTapObserverSet;// Is LongTap Event observer set |
|
67 CAlfVisual * mVisual;// Stores thje current visual hit |
|
68 TPoint mDragPoint;// Point at which drag started |
|
69 TPoint mLongTapPos;// Point at which button down happened |
|
70 bool mLongTapStarted;// Long tap timer started (true) |
|
71 int mDragStartStep;// Tick positon of Drag Start |
|
72 int mCurrTick;// Stores current tick |
|
73 int mTrackStartPoint;// Slider Track Start Point in pixel |
|
74 int mTick;// Stores Tick Size |
|
75 bool mLayoutMirrored;// |
|
76 int mdirection;// 0 - nomovement,1 left movement 2 right |
|
77 int mImageTextureId; // to differtiate between textures |
|
78 int mTrackTopTextureId;// to store the auto generated texture id's |
|
79 int mTrackBottomTextureId; |
|
80 int mTrackMiddleTextureId; |
|
81 int mMarkerTextureId; |
|
82 // Visualization Layouts |
|
83 CAlfLayout* mMainLayout; |
|
84 CAlfLayout* mBaseSliderLayout; |
|
85 CAlfLayout* mSliderCentre; |
|
86 CAlfImageVisual* mTrackLeftImage; |
|
87 CAlfImageVisual* mTrackMiddleImage; |
|
88 CAlfImageVisual* mTrackRightImage; |
|
89 CAlfLayout* mSliderCentreGhost; |
|
90 CAlfImageVisual* mSliderHandle; |
|
91 CAlfLayout* mSliderHandleGhost; |
|
92 CAlfImageVisual* mSliderProgressDownload; |
|
93 CAlfImageVisual* mSliderProgressCentre; |
|
94 CAlfTexture* mTexture; |
|
95 |
|
96 MulHorizontalSliderDataImpl() |
|
97 { |
|
98 mOperation = 0; |
|
99 mTickInPixels = 0; |
|
100 mIsLongTapObserverSet = 0; |
|
101 mDragPoint.SetXY(0,0) ; |
|
102 mLongTapPos.SetXY(0,0); |
|
103 mLongTapStarted = 0; |
|
104 mDragStartStep = 0; |
|
105 mCurrTick = 0; |
|
106 mTrackStartPoint = 0; |
|
107 mImageTextureId = 0; |
|
108 mTrackTopTextureId = 0 ; |
|
109 mTrackBottomTextureId = 0; |
|
110 mTrackMiddleTextureId = 0; |
|
111 mMarkerTextureId = 0; |
|
112 mVisual = NULL; |
|
113 mMainLayout = NULL; |
|
114 mBaseSliderLayout = NULL; |
|
115 mSliderCentre = NULL; |
|
116 mSliderHandle = NULL; |
|
117 mSliderProgressCentre = NULL; |
|
118 mBaseSliderLayout = NULL; |
|
119 mSliderCentreGhost = NULL; |
|
120 mSliderHandleGhost = NULL; |
|
121 mLayoutMirrored = false; |
|
122 mdirection = 0; |
|
123 } |
|
124 |
|
125 }; |
|
126 |
|
127 // Bitmaps for slider |
|
128 _LIT(KAvkonBitmapFile,"\\resource\\apps\\avkon2.mbm"); |
|
129 //_LIT(KImageViewerBitmapFile,"\\resource\\apps\\ImageViewer.mif"); |
|
130 // Bitmap Texture ID |
|
131 const TInt KAlfTrackTopTextureId = 1; |
|
132 const TInt KAlfTrackBottomTextureId = 2; |
|
133 const TInt KAlfTrackMiddleTextureId = 3; |
|
134 const TInt KAlfMarkerTextureId = 4; |
|
135 //const TInt KAlfMarkerSelectedTextureId = 5; |
|
136 |
|
137 // --------------------------------------------------------------------------- |
|
138 // C++ default constructor. |
|
139 // --------------------------------------------------------------------------- |
|
140 // |
|
141 MulSliderHorizontal::MulSliderHorizontal( |
|
142 CAlfWidgetControl& aControl, |
|
143 const char* aName, |
|
144 AlfCustomInitDataBase* /*aCustomData*/) |
|
145 : mData(NULL) |
|
146 { |
|
147 // Base class (AlfElement) construct |
|
148 construct(aControl, aName); |
|
149 mData = new (EMM) MulHorizontalSliderDataImpl; |
|
150 mPosData.reset(new(EMM)MulSliderPos); |
|
151 // Timer for generating tap and hold repeat events |
|
152 mLongTapTimer.reset(new (EMM) MulSliderLongTapTimer(this)); |
|
153 mDragVisual = NULL; |
|
154 mSliderModel = NULL; |
|
155 mSliderWidget = NULL; |
|
156 // Store the widget and model pointer |
|
157 initializeSliderData(); |
|
158 } |
|
159 |
|
160 // --------------------------------------------------------------------------- |
|
161 // Destructor |
|
162 // --------------------------------------------------------------------------- |
|
163 // |
|
164 MulSliderHorizontal::~MulSliderHorizontal() |
|
165 { |
|
166 if(mData) |
|
167 { |
|
168 |
|
169 (&control().Env())->TextureManager().UnloadTexture(mData->mTrackTopTextureId); |
|
170 (&control().Env())->TextureManager().UnloadTexture(mData->mTrackBottomTextureId); |
|
171 (&control().Env())->TextureManager().UnloadTexture(mData->mTrackMiddleTextureId); |
|
172 // (&control().Env())->TextureManager().UnloadTexture(KAlfMarkerSelectedTextureId); |
|
173 (&control().Env())->TextureManager().UnloadTexture(mData->mMarkerTextureId); |
|
174 // Visualization Data |
|
175 delete mData; |
|
176 } |
|
177 else |
|
178 { |
|
179 |
|
180 } |
|
181 |
|
182 }//End of Destructor |
|
183 |
|
184 // --------------------------------------------------------------------------- |
|
185 // From class MAlfInterfaceBase. |
|
186 // Getter for interfaces provided by the slider widget. |
|
187 // --------------------------------------------------------------------------- |
|
188 // |
|
189 IAlfInterfaceBase* MulSliderHorizontal::makeInterface( |
|
190 const IfId& aType) |
|
191 { |
|
192 UString param (aType.mImplementationId); |
|
193 if (param == IAlfWidgetEventHandler::type().mImplementationId) |
|
194 { |
|
195 return static_cast<IAlfWidgetEventHandler*>(this); |
|
196 } |
|
197 |
|
198 else if (param == |
|
199 IMulSliderBaseElementInternal::type().mImplementationId) |
|
200 { |
|
201 return static_cast<IMulSliderBaseElementInternal*>(this); |
|
202 } |
|
203 else |
|
204 { |
|
205 return AlfElement ::makeInterface(aType); |
|
206 } |
|
207 |
|
208 } |
|
209 |
|
210 |
|
211 //-------------------------------------------------------------------------- |
|
212 // APIs from the IMulSliderBaseElement |
|
213 //-------------------------------------------------------------------------- |
|
214 |
|
215 // --------------------------------------------------------------------------- |
|
216 // Gets called when the parent layout is relayouted. |
|
217 // resets all the anchor points and updates the visualization |
|
218 // --------------------------------------------------------------------------- |
|
219 // |
|
220 void MulSliderHorizontal::baseLayoutSizeChanged() |
|
221 { |
|
222 mData->mMainLayout->ClearFlag(EAlfVisualFlagLayoutUpdateNotification); |
|
223 if(mData->mMainLayout) |
|
224 { |
|
225 // This is a hack to resolve screen refresh issue |
|
226 control().Env().RefreshCallBack(&(control().Env())); |
|
227 // Layout the visualization with correct LCT values |
|
228 layoutVisuals(mSliderModel->GetTemplate()); |
|
229 // Convert all the user defined data to pixels |
|
230 ConvertDataToPixels(); |
|
231 // Set the thumb position to the current tick |
|
232 SetThumbPosition(); |
|
233 if(!mSliderModel->IsLandscape()) |
|
234 { |
|
235 if(mSliderWidget->GetOpacity()) |
|
236 { |
|
237 TAlfTimedValue opacity(1,0); |
|
238 mData->mMainLayout->SetOpacity(opacity); |
|
239 } |
|
240 } |
|
241 else |
|
242 { |
|
243 TAlfTimedValue opacity(0,0); |
|
244 mData->mMainLayout->SetOpacity(opacity); |
|
245 } |
|
246 } |
|
247 |
|
248 mData->mMainLayout->SetFlag(EAlfVisualFlagLayoutUpdateNotification); |
|
249 } |
|
250 |
|
251 // --------------------------------------------------------------------------- |
|
252 // From class IAlfWidgetEventHandler. |
|
253 // --------------------------------------------------------------------------- |
|
254 // |
|
255 |
|
256 |
|
257 // --------------------------------------------------------------------------- |
|
258 // Destructor |
|
259 // --------------------------------------------------------------------------- |
|
260 // |
|
261 void MulSliderHorizontal::setActiveStates( |
|
262 unsigned int /*aStates*/) |
|
263 { |
|
264 //do nothing |
|
265 } |
|
266 |
|
267 |
|
268 |
|
269 // --------------------------------------------------------------------------- |
|
270 // initializes Model and Widget Pointer |
|
271 // --------------------------------------------------------------------------- |
|
272 // |
|
273 |
|
274 void MulSliderHorizontal::initializeSliderData() |
|
275 { |
|
276 // initialize the Slider Widget Pointer; |
|
277 IAlfWidgetFactory& widgetFactory = |
|
278 AlfWidgetEnvExtension::widgetFactory(control().Env()); |
|
279 mSliderWidget = static_cast<MulSliderWidget*>(widgetFactory.findWidget( |
|
280 control().widget()->widgetName())); |
|
281 |
|
282 // initialize the Slider Model Pointer; |
|
283 mSliderModel = static_cast<MulSliderModel*>(mSliderWidget->model()); |
|
284 } |
|
285 |
|
286 // --------------------------------------------------------------------------- |
|
287 // layoutVisuals |
|
288 // --------------------------------------------------------------------------- |
|
289 // |
|
290 void MulSliderHorizontal::layoutVisuals(sliderTemplate /*aTemplateId*/) |
|
291 { |
|
292 // TAknLayoutRect to store the Lct rect |
|
293 TAknLayoutRect layoutRect; |
|
294 CAlfControl* ctrl = (CAlfControl*)&control(); |
|
295 |
|
296 //get the lct rect for mBaseSliderLayout and set it |
|
297 //aacf_slider_pane(0) |
|
298 layoutRect = MulSliderUtils::GetComponentRect( |
|
299 EHSliderPane, |
|
300 mData->mMainLayout, |
|
301 KVariety0); |
|
302 mData->mBaseSliderLayout->SetRect( |
|
303 TRect( TPoint( 0,0 ), |
|
304 TSize( layoutRect.Rect().Size().iWidth, |
|
305 layoutRect.Rect().Size().iHeight ))) ; |
|
306 |
|
307 mData->mSliderCentreGhost->SetRect( |
|
308 TRect( TPoint( 0,0 ), |
|
309 TSize( layoutRect.Rect().Size().iWidth, |
|
310 layoutRect.Rect().Size().iHeight ))) ; |
|
311 |
|
312 //get the lct rect for mSliderCentre and set it |
|
313 //aaslider_bg_pane(0) |
|
314 layoutRect = MulSliderUtils::GetComponentRect( |
|
315 EHSliderCenter, |
|
316 mData->mBaseSliderLayout, |
|
317 KVariety0); |
|
318 |
|
319 |
|
320 mData->mSliderCentre->SetRect( |
|
321 TRect( TPoint(layoutRect.Rect().iTl.iX, |
|
322 layoutRect.Rect().iTl.iY ), |
|
323 TSize( layoutRect.Rect().Size().iWidth, |
|
324 layoutRect.Rect().Size().iHeight))) ; |
|
325 |
|
326 |
|
327 |
|
328 //TAknLayoutRect handleGostRect = layoutRect; |
|
329 //get the lct rect for mSliderHandle and set it |
|
330 //aacf_slider_pane_g1(0) |
|
331 layoutRect = MulSliderUtils::GetComponentRect( |
|
332 EHSliderHandle,mData->mBaseSliderLayout,KVariety1); |
|
333 |
|
334 // This is a correction since the handle LCT data is not correct |
|
335 /* mData->mSliderHandle->SetRect( |
|
336 TRect( TPoint(handleGostRect.Rect().iTl.iX + |
|
337 (handleGostRect.Rect().Size().iWidth - |
|
338 layoutRect.Rect().Size().iWidth)/2 , |
|
339 handleGostRect.Rect().iTl.iY + |
|
340 (handleGostRect.Rect().Size().iHeight - |
|
341 layoutRect.Rect().Size().iHeight)/2 ), |
|
342 TSize( layoutRect.Rect().Size().iWidth, |
|
343 layoutRect.Rect().Size().iHeight ))) ; */ |
|
344 mData->mSliderHandle->SetRect( |
|
345 TRect( TPoint(layoutRect.Rect().iTl.iX, |
|
346 layoutRect.Rect().iTl.iY ), |
|
347 TSize( layoutRect.Rect().Size().iWidth, |
|
348 layoutRect.Rect().Size().iHeight ))) ; |
|
349 mData->mSliderHandleGhost->SetRect( |
|
350 TRect( TPoint(layoutRect.Rect().iTl.iX, |
|
351 mData->mBaseSliderLayout->Pos().iX.ValueNow() ), |
|
352 TSize( layoutRect.Rect().Size().iWidth, |
|
353 mData->mBaseSliderLayout->Size().iY.ValueNow() ))) ; |
|
354 //get the lct rect for mTrackLeftImage and set it |
|
355 //aaslider_bg_pane_g1(0) |
|
356 layoutRect = MulSliderUtils::GetComponentRect( |
|
357 EHSliderLeft,mData->mSliderCentre,0); |
|
358 |
|
359 mData->mTrackLeftImage->SetRect( |
|
360 TRect( TPoint(layoutRect.Rect().iTl.iX, |
|
361 layoutRect.Rect().iTl.iY ), |
|
362 TSize( layoutRect.Rect().Size().iWidth, |
|
363 layoutRect.Rect().Size().iHeight ))) ; |
|
364 |
|
365 //get the lct rect for mTrackMiddleImage and set it |
|
366 //aaslider_bg_pane_g2_copy1(0) |
|
367 layoutRect = MulSliderUtils::GetComponentRect( |
|
368 EHSliderCentre,mData->mSliderCentre,0); |
|
369 |
|
370 mData->mTrackMiddleImage->SetRect( |
|
371 TRect( TPoint(layoutRect.Rect().iTl.iX, |
|
372 layoutRect.Rect().iTl.iY ), |
|
373 TSize( layoutRect.Rect().Size().iWidth, |
|
374 layoutRect.Rect().Size().iHeight ))) ; |
|
375 |
|
376 //get the lct rect for mTrackRightImage and set it |
|
377 //aaslider_bg_pane_g2(0) |
|
378 layoutRect = MulSliderUtils::GetComponentRect( |
|
379 EHSliderRight,mData->mSliderCentre,0); |
|
380 |
|
381 mData->mTrackRightImage->SetRect( |
|
382 TRect( TPoint(layoutRect.Rect().iTl.iX, |
|
383 layoutRect.Rect().iTl.iY ), |
|
384 TSize( layoutRect.Rect().Size().iWidth, |
|
385 layoutRect.Rect().Size().iHeight ))) ; |
|
386 |
|
387 |
|
388 if(mData->mTrackLeftImage && |
|
389 mData->mTrackMiddleImage && |
|
390 mData->mTrackRightImage) |
|
391 { |
|
392 setTrackImage(); |
|
393 } |
|
394 |
|
395 if(mData->mSliderHandle) |
|
396 { |
|
397 mData->mImageTextureId = KAlfMarkerTextureId; |
|
398 mData->mTexture = &((ctrl->Env()).TextureManager().CreateTextureL( |
|
399 KAlfAutoGeneratedTextureId/*KAlfMarkerTextureId*/, |
|
400 (MAlfBitmapProvider *)this, |
|
401 (TAlfTextureFlags)(EAlfTextureFlagRetainResolution|EAlfTextureFlagSkinContent))); |
|
402 |
|
403 TAlfImage markerImage(*mData->mTexture ); |
|
404 mData->mSliderHandle->SetImage(markerImage); |
|
405 |
|
406 } |
|
407 |
|
408 } |
|
409 |
|
410 // --------------------------------------------------------------------------- |
|
411 // Used for setting images for the track |
|
412 // --------------------------------------------------------------------------- |
|
413 // |
|
414 |
|
415 void MulSliderHorizontal::setTrackImage() |
|
416 { |
|
417 TInt flags = EAlfTextureFlagSkinContent; |
|
418 flags |= EAlfTextureFlagAutoSize; |
|
419 CAlfControl* ctrl = (CAlfControl*)&control(); |
|
420 //create texture for leftimage |
|
421 mData->mImageTextureId = KAlfTrackTopTextureId; |
|
422 mData->mTexture = &((ctrl->Env()).TextureManager().CreateTextureL( |
|
423 KAlfAutoGeneratedTextureId/*KAlfTrackTopTextureId*/, |
|
424 (MAlfBitmapProvider *)this, |
|
425 (TAlfTextureFlags)(EAlfTextureFlagRetainResolution| |
|
426 EAlfTextureFlagSkinContent))); |
|
427 |
|
428 TAlfImage trackLeftImage(*mData->mTexture ); |
|
429 |
|
430 //create texture for middleimage |
|
431 mData->mImageTextureId = KAlfTrackMiddleTextureId; |
|
432 mData->mTexture = &((ctrl->Env()).TextureManager().CreateTextureL( |
|
433 KAlfAutoGeneratedTextureId/*KAlfTrackMiddleTextureId*/, |
|
434 (MAlfBitmapProvider *)this, |
|
435 (TAlfTextureFlags)(EAlfTextureFlagRetainResolution| |
|
436 EAlfTextureFlagSkinContent))); |
|
437 TAlfImage trackMiddleImage(*mData->mTexture ); |
|
438 //create texture for right image |
|
439 mData->mImageTextureId = KAlfTrackBottomTextureId; |
|
440 mData->mTexture = &((ctrl->Env()).TextureManager().CreateTextureL( |
|
441 KAlfAutoGeneratedTextureId/*KAlfTrackBottomTextureId*/, |
|
442 (MAlfBitmapProvider *)this, |
|
443 (TAlfTextureFlags)(EAlfTextureFlagRetainResolution| |
|
444 EAlfTextureFlagSkinContent))); |
|
445 |
|
446 TAlfImage trackRightImage(*mData->mTexture ); |
|
447 // Set Image on visuals |
|
448 if(AknLayoutUtils::LayoutMirrored()) |
|
449 { |
|
450 mData->mTrackLeftImage->SetImage(trackRightImage); |
|
451 mData->mTrackRightImage->SetImage(trackLeftImage); |
|
452 } |
|
453 else |
|
454 { |
|
455 mData->mTrackLeftImage->SetImage(trackLeftImage); |
|
456 mData->mTrackRightImage->SetImage(trackRightImage); |
|
457 } |
|
458 |
|
459 mData->mTrackMiddleImage->SetImage(trackMiddleImage); |
|
460 |
|
461 }//End of setImage |
|
462 |
|
463 // --------------------------------------------------------------------------- |
|
464 // ProvideBitmapL() |
|
465 // --------------------------------------------------------------------------- |
|
466 // |
|
467 void MulSliderHorizontal::ProvideBitmapL (TInt aId, |
|
468 CFbsBitmap *& aBitmap, |
|
469 CFbsBitmap *& aMaskBitmap) |
|
470 { |
|
471 TAknLayoutRect layoutRect; |
|
472 TRect rect; |
|
473 TSize size; |
|
474 switch(mData->mImageTextureId) |
|
475 { |
|
476 case KAlfTrackTopTextureId: |
|
477 { |
|
478 AknIconUtils::CreateIconL( |
|
479 aBitmap, |
|
480 aMaskBitmap, |
|
481 KAvkonBitmapFile, |
|
482 EMbmAvkonQgn_graf_nslider_end_left, |
|
483 EMbmAvkonQgn_graf_nslider_end_left_mask ); |
|
484 |
|
485 |
|
486 layoutRect = MulSliderUtils::GetComponentRect( |
|
487 EHSliderLeft,mData->mSliderCentre,KVariety0); |
|
488 |
|
489 AknIconUtils::SetSize( aBitmap, |
|
490 TSize(layoutRect.Rect().Size().iWidth, |
|
491 layoutRect.Rect().Size().iHeight), |
|
492 EAspectRatioNotPreserved); |
|
493 mData->mImageTextureId = 0; |
|
494 mData->mTrackTopTextureId = aId; |
|
495 } |
|
496 break; |
|
497 case KAlfTrackBottomTextureId: |
|
498 { |
|
499 AknIconUtils::CreateIconL( |
|
500 aBitmap, |
|
501 aMaskBitmap, |
|
502 KAvkonBitmapFile, |
|
503 EMbmAvkonQgn_graf_nslider_end_right, |
|
504 EMbmAvkonQgn_graf_nslider_end_right_mask ); |
|
505 layoutRect = MulSliderUtils::GetComponentRect( |
|
506 EHSliderRight, |
|
507 mData->mSliderCentre, |
|
508 KVariety0); |
|
509 |
|
510 AknIconUtils::SetSize( aBitmap, |
|
511 TSize(layoutRect.Rect().Size().iWidth, |
|
512 layoutRect.Rect().Size().iHeight), |
|
513 EAspectRatioNotPreserved); |
|
514 |
|
515 |
|
516 mData->mImageTextureId = 0; |
|
517 mData->mTrackBottomTextureId = aId; |
|
518 } |
|
519 break; |
|
520 case KAlfTrackMiddleTextureId: |
|
521 { |
|
522 AknIconUtils::CreateIconL( |
|
523 aBitmap, |
|
524 aMaskBitmap, |
|
525 KAvkonBitmapFile, |
|
526 EMbmAvkonQgn_graf_nslider_middle, |
|
527 EMbmAvkonQgn_graf_nslider_middle_mask ); |
|
528 |
|
529 //AknIconUtils::SetSize( aBitmap,TSize(304,14),EAspectRatioNotPreserved); |
|
530 layoutRect = MulSliderUtils::GetComponentRect( |
|
531 EPSliderCentre, |
|
532 mData->mSliderCentre, |
|
533 KVariety0); |
|
534 AknIconUtils::SetSize( aBitmap, |
|
535 TSize(layoutRect.Rect().Size().iWidth, |
|
536 layoutRect.Rect().Size().iHeight), |
|
537 EAspectRatioNotPreserved); |
|
538 mData->mImageTextureId = 0; |
|
539 mData->mTrackMiddleTextureId = aId; |
|
540 } |
|
541 break; |
|
542 case KAlfMarkerTextureId: |
|
543 { |
|
544 AknIconUtils::CreateIconL( |
|
545 aBitmap, |
|
546 aMaskBitmap, |
|
547 KAvkonBitmapFile, |
|
548 EMbmAvkonQgn_graf_nslider_marker, |
|
549 EMbmAvkonQgn_graf_nslider_marker_mask ); |
|
550 |
|
551 layoutRect = MulSliderUtils::GetComponentRect( |
|
552 EHSliderHandle, |
|
553 mData->mBaseSliderLayout, |
|
554 KVariety1); |
|
555 |
|
556 AknIconUtils::SetSize( aBitmap, |
|
557 TSize(layoutRect.Rect().Size().iWidth, |
|
558 layoutRect.Rect().Size().iHeight), |
|
559 EAspectRatioNotPreserved); |
|
560 mData->mImageTextureId = 0; |
|
561 mData->mMarkerTextureId = aId; |
|
562 } |
|
563 default: |
|
564 break; |
|
565 |
|
566 } |
|
567 } |
|
568 |
|
569 |
|
570 // --------------------------------------------------------------------------- |
|
571 // ConvertDataToPixels |
|
572 // --------------------------------------------------------------------------- |
|
573 // |
|
574 void MulSliderHorizontal::ConvertDataToPixels() |
|
575 { |
|
576 // Calculate the range in pixel values |
|
577 int distance = (mData->mSliderCentre->Size().iX.ValueNow() - |
|
578 mData->mSliderHandle->Size().iX.ValueNow()); |
|
579 if((mSliderModel->MaxRange() - mSliderModel->MinRange()) != 0) |
|
580 { |
|
581 // Calculate Tick Size in Pixels |
|
582 mData->mTickInPixels = |
|
583 (float)distance /(mSliderModel->MaxRange() |
|
584 - mSliderModel->MinRange()) ; |
|
585 } |
|
586 // Get the track start pixel value |
|
587 mData->mTrackStartPoint = mData->mSliderCentre->Pos().iX.ValueNow() ; |
|
588 // Store current tick |
|
589 mData->mCurrTick = mSliderModel->PrimaryValue() ; |
|
590 mData->mTick = mSliderModel->Tick(); |
|
591 } |
|
592 |
|
593 |
|
594 // --------------------------------------------------------------------------- |
|
595 // createVisualization |
|
596 // --------------------------------------------------------------------------- |
|
597 // |
|
598 void MulSliderHorizontal::createVisualization(sliderTemplate /*aTemplateId*/) |
|
599 { |
|
600 // Create the visualization |
|
601 CAlfControl* ctrl = (CAlfControl*)&control(); |
|
602 // Visual Hierarchy creation |
|
603 //creating mMainLayout |
|
604 mData->mMainLayout = CAlfLayout::AddNewL(*ctrl,NULL); |
|
605 // set the flag for Notifications and mirroring |
|
606 mData->mMainLayout->SetFlag(EAlfVisualFlagLayoutUpdateNotification); |
|
607 mData->mMainLayout->SetFlag(EAlfVisualFlagAutomaticLocaleMirroringEnabled); |
|
608 // create mBaseSliderLayout |
|
609 mData->mBaseSliderLayout = CAlfLayout::AddNewL(*ctrl,mData->mMainLayout); |
|
610 mData->mBaseSliderLayout->SetFlag(EAlfVisualFlagAutomaticLocaleMirroringEnabled); |
|
611 //create dummy layout for slider track |
|
612 mData->mSliderCentreGhost = |
|
613 CAlfLayout::AddNewL(*ctrl,mData->mBaseSliderLayout); |
|
614 //create dummy layout for slider Thumb |
|
615 // create imagevisual for slider track |
|
616 mData->mSliderCentre = |
|
617 CAlfLayout::AddNewL(*ctrl,mData->mBaseSliderLayout); |
|
618 mData->mTrackLeftImage = CAlfImageVisual::AddNewL(*ctrl,mData->mSliderCentre); |
|
619 mData->mTrackMiddleImage = CAlfImageVisual::AddNewL(*ctrl,mData->mSliderCentre); |
|
620 mData->mTrackRightImage = CAlfImageVisual::AddNewL(*ctrl,mData->mSliderCentre); |
|
621 |
|
622 // create imagevisual for slider thumb |
|
623 mData->mSliderHandle = |
|
624 CAlfImageVisual::AddNewL(*ctrl,mData->mBaseSliderLayout); |
|
625 // Attach brush and transfer its ownership to the visual. |
|
626 mData->mSliderHandleGhost = |
|
627 CAlfLayout::AddNewL(*ctrl,mData->mBaseSliderLayout); |
|
628 |
|
629 // Get the widget opacity and apply on root visual |
|
630 mSliderWidget->ShowWidget(mSliderWidget->GetOpacity(),0); |
|
631 } |
|
632 |
|
633 |
|
634 // --------------------------------------------------------------------------- |
|
635 // eventHandlerType |
|
636 // --------------------------------------------------------------------------- |
|
637 // |
|
638 IAlfWidgetEventHandler::AlfEventHandlerType MulSliderHorizontal::eventHandlerType() |
|
639 { |
|
640 return IAlfWidgetEventHandler::EPresentationEventHandler; |
|
641 } |
|
642 |
|
643 |
|
644 // --------------------------------------------------------------------------- |
|
645 // eventExecutionPhase |
|
646 // --------------------------------------------------------------------------- |
|
647 // |
|
648 IAlfWidgetEventHandler::AlfEventHandlerExecutionPhase MulSliderHorizontal::eventExecutionPhase() |
|
649 { |
|
650 return IAlfWidgetEventHandler::ETunnellingPhaseEventHandler; |
|
651 } |
|
652 |
|
653 // --------------------------------------------------------------------------- |
|
654 // offerEvent |
|
655 // --------------------------------------------------------------------------- |
|
656 // |
|
657 AlfEventStatus MulSliderHorizontal::offerEvent( CAlfWidgetControl& /*aControl*/, |
|
658 const TAlfEvent& aEvent ) |
|
659 { |
|
660 AlfEventStatus ret = EEventNotHandled; |
|
661 if(!mSliderWidget->IsHidden()) |
|
662 { |
|
663 if(aEvent.IsCustomEvent()) |
|
664 { |
|
665 if(aEvent.CustomParameter() == EEventMissedPointerUp) |
|
666 { |
|
667 mData->mLongTapStarted = false; |
|
668 ret=EEventHandled; |
|
669 handlePointerUpEvent(); |
|
670 } |
|
671 } |
|
672 // handle key events |
|
673 else if(aEvent.IsKeyEvent() && mSliderWidget->IsKeyEnabled()) |
|
674 { |
|
675 ret = HandleKeyEvents(aEvent); |
|
676 } |
|
677 // Pointer drag events and single tap events |
|
678 else if(aEvent.IsPointerEvent()) |
|
679 { |
|
680 ret = HandlePointerEvents((TAlfEvent *)&aEvent); |
|
681 } |
|
682 } |
|
683 return ret; |
|
684 } |
|
685 |
|
686 |
|
687 // --------------------------------------------------------------------------- |
|
688 // handleLongTap ( Long TapTimer calls inside its RUNL) |
|
689 // --------------------------------------------------------------------------- |
|
690 // |
|
691 AlfEventStatus MulSliderHorizontal::handleLongTap() |
|
692 { |
|
693 mData->mMainLayout->ClearFlag(EAlfVisualFlagLayoutUpdateNotification); |
|
694 //CAlfVisual * focusvisual = aEvent->Visual(); |
|
695 AlfEventStatus ret = EEventNotHandled; |
|
696 if (mData->mVisual == mData->mSliderCentre || mData->mVisual == mData->mSliderCentreGhost) |
|
697 { |
|
698 mData->mLongTapStarted = true; |
|
699 ret = trackVisualHit(mData->mVisual); |
|
700 // Handle Long tap timer tactile feedback |
|
701 MulSliderControl& sldrcntrl = static_cast<MulSliderControl&>(control()); |
|
702 sldrcntrl.TactileEffectOnTouchandHold(); |
|
703 } |
|
704 |
|
705 // ret = HandlePointerEvents(aEvent); |
|
706 mData->mMainLayout->SetFlag(EAlfVisualFlagLayoutUpdateNotification); |
|
707 return ret; |
|
708 } |
|
709 |
|
710 |
|
711 // --------------------------------------------------------------------------- |
|
712 // HandleKeyEvents |
|
713 // --------------------------------------------------------------------------- |
|
714 // |
|
715 AlfEventStatus MulSliderHorizontal::HandleKeyEvents(const TAlfEvent& aEvent) |
|
716 { |
|
717 AlfEventStatus ret = EEventNotHandled; |
|
718 int newPos = 0; |
|
719 int data = 0; |
|
720 if(AknLayoutUtils::LayoutMirrored()) |
|
721 { |
|
722 data= - mData->mTick; |
|
723 } |
|
724 else |
|
725 { |
|
726 data= mData->mTick; |
|
727 } |
|
728 if(aEvent.Code() == EEventKey ) |
|
729 { |
|
730 if(aEvent.KeyEvent().iScanCode == EStdKeyRightArrow) |
|
731 { |
|
732 ret = EEventHandled; |
|
733 newPos = mSliderModel->PrimaryValue() + data; |
|
734 updateModelPrimaryValue(newPos); |
|
735 } |
|
736 else if(aEvent.KeyEvent().iScanCode == EStdKeyLeftArrow) |
|
737 { |
|
738 ret = EEventHandled; |
|
739 newPos = mSliderModel->PrimaryValue() - data; |
|
740 updateModelPrimaryValue(newPos); |
|
741 } |
|
742 } |
|
743 return ret; |
|
744 } |
|
745 |
|
746 |
|
747 // --------------------------------------------------------------------------- |
|
748 // Sends drag Up or Down event, according to the hit position |
|
749 // on track |
|
750 // --------------------------------------------------------------------------- |
|
751 // |
|
752 AlfEventStatus MulSliderHorizontal::trackVisualHit(CAlfVisual * /*aHitVisual*/) |
|
753 { |
|
754 |
|
755 //Find the thumb Anchor Layout. |
|
756 TAlfTimedPoint thumbVisPos = mData->mSliderHandle->Pos(); |
|
757 TAlfTimedPoint thumbVisSize = mData->mSliderHandle->Size(); |
|
758 //Check if click was above/to left or below/to right of |
|
759 //thumb |
|
760 if (mData->mLongTapPos.iX < thumbVisPos.iX.ValueNow()) |
|
761 {// Pointer down happened left side of Handle |
|
762 |
|
763 int newPos = mSliderModel->PrimaryValue() - mData->mTick; |
|
764 if(mData->mLongTapStarted) |
|
765 { |
|
766 if(mData->mdirection !=2) |
|
767 { |
|
768 // Move Handle |
|
769 updateModelPrimaryValue(newPos); |
|
770 mData->mdirection = 1; |
|
771 } |
|
772 } |
|
773 } |
|
774 else if (mData->mLongTapPos.iX > (thumbVisPos.iX.ValueNow() + |
|
775 thumbVisSize.iX.ValueNow()) ) |
|
776 { |
|
777 // Pointer down happened right side of Handle |
|
778 int newPos = mSliderModel->PrimaryValue() + mData->mTick; |
|
779 if(mData->mLongTapStarted) |
|
780 { |
|
781 if(mData->mdirection !=1) |
|
782 { |
|
783 // Move Handle |
|
784 updateModelPrimaryValue(newPos); |
|
785 mData->mdirection = 2; |
|
786 } |
|
787 } |
|
788 } |
|
789 else |
|
790 { |
|
791 if(mData->mIsLongTapObserverSet) |
|
792 { |
|
793 // Stop the long tap timer |
|
794 mLongTapTimer->Stop(); |
|
795 mData->mLongTapStarted = false; |
|
796 if(AknLayoutUtils::LayoutMirrored() ) |
|
797 { |
|
798 mData->mLongTapPos.iX = mData->mMainLayout->Size().iX.ValueNow() - |
|
799 mData->mLongTapPos.iX; |
|
800 } |
|
801 mData->mIsLongTapObserverSet = EFalse; |
|
802 if(!mData->mOperation) |
|
803 { |
|
804 mData->mVisual = mData->mSliderHandle; |
|
805 initializeThumbDragData( |
|
806 mData->mLongTapPos); |
|
807 } |
|
808 } |
|
809 else |
|
810 { |
|
811 //Do Nothing. |
|
812 } |
|
813 } |
|
814 return EEventHandled; |
|
815 } |
|
816 |
|
817 |
|
818 // --------------------------------------------------------------------------- |
|
819 // handles the pointerDown event |
|
820 // |
|
821 // --------------------------------------------------------------------------- |
|
822 // |
|
823 AlfEventStatus MulSliderHorizontal::handlePointerDownEvent(TAlfEvent * aPntrEvent) |
|
824 { |
|
825 CAlfVisual * focusvisual = aPntrEvent->Visual(); |
|
826 AlfEventStatus result = EEventNotHandled; |
|
827 if (focusvisual) |
|
828 { |
|
829 mData->mVisual = focusvisual; |
|
830 |
|
831 if (IsSliderVisual(focusvisual)) |
|
832 { |
|
833 control().processEvent(TAlfEvent(ECustomEventIconClick)); |
|
834 control().Display()->Roster().SetPointerEventObservers( |
|
835 EAlfPointerEventReportDrag ,control()); |
|
836 if(!mData->mOperation) |
|
837 { |
|
838 mData->mIsLongTapObserverSet = ETrue; |
|
839 //mData->mLongTapPos = aPntrEvent->PointerEvent().iParentPosition; |
|
840 mirrorPointerPosition(aPntrEvent->PointerEvent().iParentPosition); |
|
841 mData->mLongTapStarted = true; |
|
842 mLongTapTimer->Start(); |
|
843 // Dont send custom event at pointer up |
|
844 |
|
845 } |
|
846 //Tick Movement |
|
847 if (focusvisual == mData->mSliderCentre || |
|
848 focusvisual == mData->mSliderCentreGhost) |
|
849 { |
|
850 mData->mLongTapStarted = true; |
|
851 return trackVisualHit(focusvisual); |
|
852 } |
|
853 |
|
854 // Drag |
|
855 else if (focusvisual == mData->mSliderHandle || |
|
856 focusvisual == mData->mSliderHandleGhost ) |
|
857 { |
|
858 // Initialize the drag variables |
|
859 if(!mData->mOperation) |
|
860 { |
|
861 initializeThumbDragData( |
|
862 aPntrEvent->PointerEvent().iParentPosition); |
|
863 //Tactile Feedback for thumb touch |
|
864 MulSliderControl& sldrcntrl = static_cast<MulSliderControl&>(control()); |
|
865 sldrcntrl.TactileEffectOnTouchandHold(); |
|
866 } |
|
867 |
|
868 result = EEventHandled; |
|
869 } |
|
870 } |
|
871 |
|
872 } |
|
873 return result; |
|
874 } |
|
875 |
|
876 |
|
877 // --------------------------------------------------------------------------- |
|
878 // HandlePointerEvents |
|
879 // --------------------------------------------------------------------------- |
|
880 // |
|
881 AlfEventStatus MulSliderHorizontal::HandlePointerEvents(TAlfEvent* aEvent) |
|
882 { |
|
883 AlfEventStatus ret = EEventHandled; |
|
884 if (aEvent->PointerEvent().iType == TPointerEvent::EButton1Down) |
|
885 { |
|
886 mData->mdirection = 0; |
|
887 ret = handlePointerDownEvent(aEvent); |
|
888 } |
|
889 // Drag Events |
|
890 else if (aEvent->PointerEvent().iType == TPointerEvent::EDrag) |
|
891 { |
|
892 |
|
893 if(!mData->mOperation) |
|
894 {// Drag during tap and hold on track . |
|
895 if(mData->mIsLongTapObserverSet) |
|
896 {// Store the new pointer position |
|
897 //mData->mLongTapPos=aEvent->PointerEvent().iParentPosition; |
|
898 mirrorPointerPosition(aEvent->PointerEvent().iParentPosition); |
|
899 } |
|
900 else |
|
901 { |
|
902 //Do Nothing. |
|
903 } |
|
904 } |
|
905 else |
|
906 { |
|
907 // Drag on Handle |
|
908 if(mData->mIsLongTapObserverSet && |
|
909 mData->mVisual && |
|
910 mData->mSliderHandle && |
|
911 mData->mSliderHandleGhost) |
|
912 { |
|
913 // Store the new pointer position |
|
914 mirrorPointerPosition(aEvent->PointerEvent().iParentPosition); |
|
915 } |
|
916 else |
|
917 { |
|
918 // Do nothing |
|
919 } |
|
920 int dist; |
|
921 // Calculate the distance moved from the drag start point |
|
922 if(AknLayoutUtils::LayoutMirrored()) |
|
923 { |
|
924 dist = mData->mDragPoint.iX - |
|
925 aEvent->PointerEvent().iParentPosition.iX ; |
|
926 } |
|
927 else |
|
928 { |
|
929 dist = aEvent->PointerEvent().iParentPosition.iX - |
|
930 mData->mDragPoint.iX ; |
|
931 } |
|
932 // Calculate the new tick position |
|
933 int precision = KRoundupvalue; |
|
934 if(dist<0) |
|
935 { |
|
936 precision = -KRoundupvalue; |
|
937 } |
|
938 int newPos= (int)(((float)dist / mData->mTickInPixels ) + precision) + |
|
939 mData->mDragStartStep; |
|
940 // send tactile sensitive event |
|
941 // Update the model hence update visualization |
|
942 updateModelPrimaryValue(newPos); |
|
943 } |
|
944 // Tactile Feedback for Drag |
|
945 //Tactile Feedback for thumb drag |
|
946 MulSliderControl& sldrcntrl = static_cast<MulSliderControl&>(control()); |
|
947 sldrcntrl.TactileEffectOnDrag(*aEvent); |
|
948 } |
|
949 else if(aEvent->PointerUp() ) |
|
950 { |
|
951 mData->mLongTapStarted = false; |
|
952 handlePointerUpEvent(); |
|
953 |
|
954 } |
|
955 else |
|
956 { |
|
957 //Do Nothing. |
|
958 } |
|
959 |
|
960 return ret; |
|
961 } |
|
962 |
|
963 |
|
964 // --------------------------------------------------------------------------- |
|
965 // updateModelPrimaryValue |
|
966 // --------------------------------------------------------------------------- |
|
967 // |
|
968 void MulSliderHorizontal::updateModelPrimaryValue( int aNewPosValue) |
|
969 { |
|
970 // Validate the new tick value |
|
971 if(aNewPosValue< mSliderModel->MinRange()) |
|
972 { |
|
973 aNewPosValue = mSliderModel->MinRange(); |
|
974 } |
|
975 else if(aNewPosValue > mSliderModel->MaxRange()) |
|
976 { |
|
977 aNewPosValue = mSliderModel->MaxRange(); |
|
978 } |
|
979 if(mSliderModel->PrimaryValue() != aNewPosValue && mData->mTick != 0) |
|
980 { |
|
981 // Update visualization and model only if data is changed |
|
982 mPosData.reset(new(EMM)MulSliderPos); |
|
983 mPosData->mPreviousValue = mSliderModel->PrimaryValue() ; |
|
984 mSliderModel->SetPrimaryValue(aNewPosValue); |
|
985 mPosData->mCurrentValue =aNewPosValue; |
|
986 mData->mCurrTick = aNewPosValue; |
|
987 |
|
988 // Send event to the slider widget |
|
989 TAlfEvent customevent(ETypePrimaryValueChange, |
|
990 (uint)mPosData.get()); |
|
991 control().processEvent(customevent); |
|
992 } |
|
993 } |
|
994 |
|
995 |
|
996 // --------------------------------------------------------------------------- |
|
997 // snapPrimaryValueToTicks |
|
998 // --------------------------------------------------------------------------- |
|
999 // |
|
1000 void MulSliderHorizontal::snapPrimaryValueToTicks() |
|
1001 { |
|
1002 // If the position is not a multiple of ticks then |
|
1003 //snap to the nearest tick multiple |
|
1004 |
|
1005 int currHandlePos = mSliderModel->PrimaryValue() - mSliderModel->MinRange(); |
|
1006 int tick = mSliderModel->Tick(); |
|
1007 int newPos = currHandlePos + mSliderModel->MinRange(); |
|
1008 if(mSliderModel->PrimaryValue() < mSliderModel->MaxRange()) |
|
1009 { |
|
1010 int diff = 0; |
|
1011 if(tick > 0) //model |
|
1012 { |
|
1013 diff = currHandlePos - ((currHandlePos /tick) * tick); |
|
1014 } |
|
1015 if(diff !=0) |
|
1016 { |
|
1017 newPos = currHandlePos + tick - diff + mSliderModel->MinRange(); |
|
1018 } |
|
1019 } |
|
1020 |
|
1021 // Update model |
|
1022 updateModelPrimaryValue(newPos); |
|
1023 } |
|
1024 |
|
1025 |
|
1026 // --------------------------------------------------------------------------- |
|
1027 // handlePointerUpEvent |
|
1028 // |
|
1029 // --------------------------------------------------------------------------- |
|
1030 // |
|
1031 void MulSliderHorizontal::handlePointerUpEvent() |
|
1032 { |
|
1033 // if thumb or track is clicked, change the graphics |
|
1034 // Send event if single click has hapened |
|
1035 |
|
1036 snapPrimaryValueToTicks(); |
|
1037 |
|
1038 if(mData->mOperation) |
|
1039 { |
|
1040 //Somehow missed the Up event? |
|
1041 stopDrag(); |
|
1042 //Tactile Feedback For Thumb Release |
|
1043 MulSliderControl& sldrcntrl = static_cast<MulSliderControl&>(control()); |
|
1044 sldrcntrl.TactileEffectOnRelease(); |
|
1045 } |
|
1046 if(mData->mIsLongTapObserverSet) |
|
1047 { |
|
1048 // Stop the long tap timer |
|
1049 mLongTapTimer->Stop(); |
|
1050 // Un-register with the roster for long tap events |
|
1051 control().Display()->Roster().SetPointerEventObservers(0, |
|
1052 control()); |
|
1053 mData->mIsLongTapObserverSet = EFalse; |
|
1054 } |
|
1055 else |
|
1056 { |
|
1057 //Do Nothing. |
|
1058 } |
|
1059 } |
|
1060 |
|
1061 |
|
1062 // --------------------------------------------------------------------------- |
|
1063 // UpdateVisualization |
|
1064 // --------------------------------------------------------------------------- |
|
1065 // |
|
1066 void MulSliderHorizontal::updateVisualization() |
|
1067 { |
|
1068 ConvertDataToPixels(); |
|
1069 SetThumbPosition(); |
|
1070 } |
|
1071 |
|
1072 // --------------------------------------------------------------------------- |
|
1073 //Mirror pointer position |
|
1074 // --------------------------------------------------------------------------- |
|
1075 // |
|
1076 void MulSliderHorizontal::mirrorPointerPosition(const TPoint& aPointerPos ) |
|
1077 { |
|
1078 mData->mLongTapPos = aPointerPos; |
|
1079 if(AknLayoutUtils::LayoutMirrored()) |
|
1080 { |
|
1081 mData->mLongTapPos.iX = mData->mMainLayout->Size().iX.ValueNow() - |
|
1082 mData->mLongTapPos.iX ; |
|
1083 } |
|
1084 } |
|
1085 // --------------------------------------------------------------------------- |
|
1086 // SetThumbPosition |
|
1087 // --------------------------------------------------------------------------- |
|
1088 // |
|
1089 |
|
1090 void MulSliderHorizontal::SetThumbPosition() |
|
1091 { |
|
1092 // Current primary value in pixels |
|
1093 int newTickVal = (mSliderModel->PrimaryValue() - mSliderModel->MinRange()) * |
|
1094 mData->mTickInPixels; |
|
1095 // Handle |
|
1096 int handleY = mData->mSliderHandle->Pos().iY.ValueNow(); |
|
1097 int ghostHandleY = mData->mSliderHandleGhost->Pos().iY.ValueNow(); |
|
1098 // Handle new pos |
|
1099 int widthDiff = (mData->mSliderHandleGhost->Size().iX.ValueNow() - |
|
1100 mData->mSliderHandle->Size().iX.ValueNow())/2; |
|
1101 TAlfRealPoint pnt(mData->mTrackStartPoint + newTickVal,handleY); |
|
1102 // Ghost Handle ( Extended) new pos |
|
1103 TAlfRealPoint pnt1(mData->mTrackStartPoint - |
|
1104 widthDiff/2 + newTickVal,ghostHandleY); |
|
1105 // Set the position |
|
1106 mData->mSliderHandle->SetPos(pnt,0); |
|
1107 mData->mSliderHandleGhost->SetPos(pnt1,0); |
|
1108 |
|
1109 // Update visualization variables |
|
1110 mData->mCurrTick = mSliderModel->PrimaryValue(); |
|
1111 } |
|
1112 |
|
1113 |
|
1114 // --------------------------------------------------------------------------- |
|
1115 // accept |
|
1116 // --------------------------------------------------------------------------- |
|
1117 // |
|
1118 bool MulSliderHorizontal::accept( CAlfWidgetControl& /*aControl*/, |
|
1119 const TAlfEvent& aEvent ) const |
|
1120 { |
|
1121 // Accept only key or pointer events. |
|
1122 if(aEvent.IsKeyEvent()||aEvent.IsPointerEvent()) |
|
1123 { |
|
1124 return true; |
|
1125 } |
|
1126 else |
|
1127 { |
|
1128 return false; |
|
1129 } |
|
1130 } |
|
1131 |
|
1132 |
|
1133 // --------------------------------------------------------------------------- |
|
1134 //initializeThumbDragData |
|
1135 // --------------------------------------------------------------------------- |
|
1136 // |
|
1137 bool MulSliderHorizontal::initializeThumbDragData( const TPoint& aPointerPos ) |
|
1138 { |
|
1139 TRAPD(err,control().Display()->Roster().SetPointerDragThreshold(control(), |
|
1140 TAlfXYMetric(TAlfMetric(KXToleranceInPixel,EAlfUnitPixel), |
|
1141 TAlfMetric(KYToleranceInPixel,EAlfUnitPixel))) ); |
|
1142 |
|
1143 if(mData->mVisual && err == KErrNone) |
|
1144 { |
|
1145 mData->mOperation = EMoveItem; |
|
1146 mData->mDragPoint = aPointerPos; |
|
1147 mData->mDragStartStep = mSliderModel->PrimaryValue(); |
|
1148 |
|
1149 } |
|
1150 else |
|
1151 { |
|
1152 // Do Nothing |
|
1153 } |
|
1154 return ETrue; |
|
1155 } |
|
1156 |
|
1157 |
|
1158 // --------------------------------------------------------------------------- |
|
1159 // stopDrag |
|
1160 // |
|
1161 // --------------------------------------------------------------------------- |
|
1162 // |
|
1163 bool MulSliderHorizontal::stopDrag() |
|
1164 { |
|
1165 TRAPD(err, |
|
1166 control().Display()->Roster().SetPointerEventObservers( |
|
1167 0, |
|
1168 control())); |
|
1169 if(err == KErrNone) |
|
1170 { |
|
1171 mData->mVisual = NULL; |
|
1172 mData->mOperation = ENop; |
|
1173 return ETrue; |
|
1174 } |
|
1175 return EFalse; |
|
1176 } |
|
1177 |
|
1178 |
|
1179 |
|
1180 |
|
1181 // --------------------------------------------------------------------------- |
|
1182 // IsSliderVisual |
|
1183 // |
|
1184 // --------------------------------------------------------------------------- |
|
1185 // |
|
1186 bool MulSliderHorizontal::IsSliderVisual(CAlfVisual *aVisual) |
|
1187 { |
|
1188 if(aVisual == mData->mSliderCentre|| |
|
1189 aVisual == mData->mTrackLeftImage || |
|
1190 aVisual == mData->mTrackMiddleImage || |
|
1191 aVisual == mData->mTrackRightImage || |
|
1192 aVisual == mData->mSliderCentreGhost|| |
|
1193 aVisual == mData->mSliderHandle|| |
|
1194 aVisual == mData->mSliderHandleGhost) |
|
1195 { |
|
1196 return true; |
|
1197 } |
|
1198 return false; |
|
1199 } |
|
1200 |
|
1201 void MulSliderHorizontal::updateTextVisualization() |
|
1202 { |
|
1203 |
|
1204 } |
|
1205 }//namespace Alf |
|
1206 |
|
1207 //End Of File |
|