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: Implementation for presentation element - vertical. |
|
15 * |
|
16 */ |
|
17 |
|
18 //Toolkit Includes |
|
19 #include <avkon.mbg> |
|
20 #include <mulsliderwidget.mbg> |
|
21 |
|
22 // Alfred Client includes |
|
23 #include <alf/alfenv.h> |
|
24 #include <alf/alfroster.h> |
|
25 #include <alf/alfdisplay.h> |
|
26 #include <alf/alfbrusharray.h> |
|
27 #include <alf/alftextvisual.h> |
|
28 #include <alf/alfevent.h> |
|
29 //#include <osn/alfptrvector.h> |
|
30 #include <alf/alfframebrush.h> |
|
31 |
|
32 //Widget Model Includes |
|
33 #include <alf/alfwidgetevents.h> |
|
34 #include <alf/alfwidgetenvextension.h> |
|
35 #include <alf/ialfmodel.h> |
|
36 |
|
37 //Avkon Includes |
|
38 #include <AknUtils.h> |
|
39 #include <AknsConstants.h> |
|
40 #include <utf.h> |
|
41 #include <aknlayoutscalable_uiaccel.cdl.h> |
|
42 #include <avkon.hrh> |
|
43 //#include <math.h> |
|
44 |
|
45 //slider widget includes |
|
46 #include "mulslidervertical.h" |
|
47 #include <mul/mulevent.h> |
|
48 #include "mulsliderwidget.h" |
|
49 #include "mulslidercontrol.h" |
|
50 #include "mulslidermodel.h" |
|
51 #include "mulsliderdefinitions.h" |
|
52 #include "mulsliderutils.h" |
|
53 |
|
54 //Timer function includes |
|
55 #include "mulsliderlongtaptimer.h" |
|
56 #include <alf/alfgradientbrush.h> |
|
57 namespace Alf |
|
58 { |
|
59 // Structure to store data for the slider element class |
|
60 struct MulVerticalSliderDataImpl |
|
61 { |
|
62 bool mOperation;// Drag state |
|
63 bool mSliderHit;// button down has happened on slider visual |
|
64 float mTickInPixels;// Tick size in Pixel |
|
65 int mRangeInPixels;// Range in Pixel |
|
66 int mCurrTickInPixels;// Current Tick posion in pixels |
|
67 CAlfVisual * mVisual;// Stores the current visual hit |
|
68 TPoint mDragPoint;// Point at which drag started |
|
69 TPoint mLongTapPos;// Point at which button down happened |
|
70 int mDragStartStep;// Tick positon of Drag Start |
|
71 int mCurrTick;// Stores current tick |
|
72 int mTick;// Stores Tick Size |
|
73 int mTrackStartPoint;// Slider Track Start Point in pixel |
|
74 int mHandleGhostHieghtDelta; |
|
75 bool mOrientationLandScape; |
|
76 bool mHasBackground; // for background only created once |
|
77 int mdirection;// 0 - nomovement,1 up movement 2 down |
|
78 bool mLayoutMirrored;// RTL if True else LTR |
|
79 int mImageTextureId; // to differtiate between textures |
|
80 int mTrackTopTextureId ;// to store the auto generated texture id's |
|
81 int mTrackBottomTextureId; |
|
82 int mTrackMiddleTextureId; |
|
83 int mMarkerTextureId; |
|
84 int mZoomInTextureId; |
|
85 int mZoomOutTextureId; |
|
86 |
|
87 CAlfLayout* mMainLayout; |
|
88 CAlfLayout* mBaseSliderLayout;// Slider Background |
|
89 CAlfTexture* mTexture; |
|
90 CAlfLayout* mSliderCentre;// Track layout |
|
91 CAlfLayout* mSliderCentreGhost;// Extended touch are for track |
|
92 CAlfImageVisual* mTrackTopImage; |
|
93 CAlfImageVisual* mTrackMiddleImage; |
|
94 CAlfImageVisual* mTrackEndImage; |
|
95 CAlfImageVisual* mSliderHandle;// Slider Handle |
|
96 CAlfLayout* mSliderHandleGhost;//Extended touch are for handle |
|
97 CAlfVisual* mSliderPercentAudio;//Visula showing percentage |
|
98 CAlfImageVisual* mImagePlus;// Zoom in |
|
99 CAlfImageVisual* mImageMinus;// Zoom out |
|
100 |
|
101 |
|
102 MulVerticalSliderDataImpl() |
|
103 { |
|
104 mOperation = false; |
|
105 mSliderHit = false; |
|
106 mTickInPixels = 0; |
|
107 mRangeInPixels = 0; |
|
108 mCurrTickInPixels = 0; |
|
109 mVisual = NULL; |
|
110 mDragPoint.SetXY(0,0); |
|
111 mLongTapPos.SetXY(0,0); |
|
112 mDragStartStep = 0; |
|
113 mCurrTick = 0; |
|
114 mTick = 0; |
|
115 mTrackStartPoint = 0; |
|
116 mImageTextureId = 0; |
|
117 mTrackTopTextureId = 0; |
|
118 mTrackBottomTextureId = 0; |
|
119 mTrackMiddleTextureId = 0; |
|
120 mMarkerTextureId = 0; |
|
121 mZoomInTextureId = 0; |
|
122 mZoomOutTextureId = 0; |
|
123 mMainLayout = NULL; |
|
124 mBaseSliderLayout = NULL; |
|
125 mSliderCentre = NULL; |
|
126 mTrackTopImage = NULL; |
|
127 mTrackMiddleImage = NULL; |
|
128 mTrackEndImage = NULL; |
|
129 mSliderCentreGhost = NULL; |
|
130 mSliderHandleGhost = NULL; |
|
131 mSliderHandle = NULL; |
|
132 mSliderPercentAudio = NULL; |
|
133 mImagePlus = NULL; |
|
134 mImageMinus = NULL; |
|
135 mHandleGhostHieghtDelta = 0; |
|
136 mOrientationLandScape = false; |
|
137 mdirection = 0; |
|
138 mLayoutMirrored = false; |
|
139 mHasBackground = false; |
|
140 } |
|
141 |
|
142 }; |
|
143 |
|
144 // bitmap file path |
|
145 _LIT(KAvkonBitmapFile,"\\resource\\apps\\avkon2.mbm"); |
|
146 _LIT(KSliderBitmapFile,"\\resource\\apps\\mulsliderwidget.mif"); |
|
147 |
|
148 const TInt KAlfTrackTopTextureId = 1; |
|
149 const TInt KAlfTrackBottomTextureId = 2; |
|
150 const TInt KAlfTrackMiddleTextureId = 3; |
|
151 const TInt KAlfMarkerTextureId = 4; |
|
152 const TInt KAlfZoomInTextureId = 5; |
|
153 const TInt KAlfZoomOutTextureId = 6; |
|
154 |
|
155 // --------------------------------------------------------------------------- |
|
156 // C++ default constructor. |
|
157 // --------------------------------------------------------------------------- |
|
158 // |
|
159 MulSliderVertical::MulSliderVertical( |
|
160 CAlfWidgetControl& aControl, |
|
161 const char* aName, |
|
162 AlfCustomInitDataBase* /*aCustomData*/) |
|
163 : mData(NULL) |
|
164 { |
|
165 // Base class (AlfElement) construct |
|
166 construct(aControl, aName); |
|
167 mSliderModel = NULL; |
|
168 mSliderWidget = NULL; |
|
169 mData = new (EMM) MulVerticalSliderDataImpl; |
|
170 mPosData.reset(new(EMM)MulSliderPos); |
|
171 |
|
172 // Timer for generating tap and hold repeat events |
|
173 mLongTapTimer.reset(new (EMM) MulSliderLongTapTimer(this)); |
|
174 initializeSliderData(); |
|
175 } |
|
176 |
|
177 // --------------------------------------------------------------------------- |
|
178 // Destructor |
|
179 // --------------------------------------------------------------------------- |
|
180 // |
|
181 MulSliderVertical::~MulSliderVertical() |
|
182 { |
|
183 // Visualization Data |
|
184 if(mData) |
|
185 { |
|
186 (&control().Env())->TextureManager().UnloadTexture(mData->mTrackTopTextureId); |
|
187 (&control().Env())->TextureManager().UnloadTexture(mData->mTrackBottomTextureId); |
|
188 (&control().Env())->TextureManager().UnloadTexture(mData->mTrackTopTextureId); |
|
189 (&control().Env())->TextureManager().UnloadTexture(mData->mMarkerTextureId); |
|
190 (&control().Env())->TextureManager().UnloadTexture(mData->mZoomInTextureId); |
|
191 (&control().Env())->TextureManager().UnloadTexture(mData->mZoomOutTextureId); |
|
192 delete mData; |
|
193 } |
|
194 else |
|
195 { |
|
196 |
|
197 } |
|
198 |
|
199 }//End of Destructor |
|
200 |
|
201 // --------------------------------------------------------------------------- |
|
202 // From class MAlfInterfaceBase. |
|
203 // Getter for interfaces provided by the slider widget. |
|
204 // --------------------------------------------------------------------------- |
|
205 // |
|
206 IAlfInterfaceBase* MulSliderVertical::makeInterface( |
|
207 const IfId& aType) |
|
208 { |
|
209 IAlfInterfaceBase* interface = 0; |
|
210 UString param (aType.mImplementationId); |
|
211 if (param == IAlfWidgetEventHandler::type().mImplementationId) |
|
212 { |
|
213 return static_cast<IAlfWidgetEventHandler*>(this); |
|
214 } |
|
215 else if (param == |
|
216 IMulSliderBaseElementInternal::type().mImplementationId) |
|
217 { |
|
218 return static_cast<IMulSliderBaseElementInternal*>(this); |
|
219 } |
|
220 else |
|
221 { |
|
222 interface = AlfElement::makeInterface(aType); |
|
223 } |
|
224 return interface; |
|
225 } |
|
226 |
|
227 //-------------------------------------------------------------------------- |
|
228 // APIs from the IMulSliderBaseElement |
|
229 //-------------------------------------------------------------------------- |
|
230 |
|
231 // --------------------------------------------------------------------------- |
|
232 // Gets called when the parent layout is relayouted. |
|
233 // resets all the anchor points and updates the visualization |
|
234 // --------------------------------------------------------------------------- |
|
235 // |
|
236 void MulSliderVertical::baseLayoutSizeChanged() |
|
237 { |
|
238 mData->mMainLayout->ClearFlag(EAlfVisualFlagLayoutUpdateNotification); |
|
239 if(mData->mMainLayout) |
|
240 { |
|
241 //mData->mOrientationLandScape = mSliderModel->IsLandscape(); |
|
242 // This is a hack to resolve screen refresh issue |
|
243 control().Env().RefreshCallBack(&(control().Env())); |
|
244 // Layout the visualization with correct LCT values |
|
245 layoutVisuals(mSliderModel->GetTemplate()); |
|
246 // Convert all the user defined data to pixels |
|
247 ConvertDataToPixels(); |
|
248 // Set the thumb position to the current tick |
|
249 SetThumbPosition(); |
|
250 mData->mMainLayout->SetOpacity(mSliderWidget->GetOpacity()); |
|
251 } |
|
252 mData->mMainLayout->SetFlag(EAlfVisualFlagLayoutUpdateNotification); |
|
253 } |
|
254 |
|
255 // --------------------------------------------------------------------------- |
|
256 // From class IAlfWidgetEventHandler. |
|
257 // --------------------------------------------------------------------------- |
|
258 // |
|
259 void MulSliderVertical::setActiveStates( |
|
260 unsigned int /*aStates*/) |
|
261 { |
|
262 //do nothing |
|
263 } |
|
264 |
|
265 // --------------------------------------------------------------------------- |
|
266 // initializes Model and Widget Pointer |
|
267 // --------------------------------------------------------------------------- |
|
268 // |
|
269 void MulSliderVertical::initializeSliderData() |
|
270 { |
|
271 // initialize the Slider Widget Pointer; |
|
272 IAlfWidgetFactory& widgetFactory = |
|
273 AlfWidgetEnvExtension::widgetFactory(control().Env()); |
|
274 mSliderWidget = static_cast<MulSliderWidget *>(widgetFactory.findWidget( |
|
275 control().widget()->widgetName())); |
|
276 |
|
277 // initialize the Slider Model Pointer; |
|
278 mSliderModel =static_cast<MulSliderModel*>(mSliderWidget->model()); |
|
279 } |
|
280 |
|
281 // --------------------------------------------------------------------------- |
|
282 // set the positions and images for the visual hierarchy |
|
283 // --------------------------------------------------------------------------- |
|
284 // |
|
285 void MulSliderVertical::layoutVisuals( sliderTemplate /*aTemplateId*/) |
|
286 { |
|
287 bool relayout = false; |
|
288 if(mData->mLayoutMirrored != AknLayoutUtils::LayoutMirrored()) |
|
289 { |
|
290 mData->mOrientationLandScape = !mSliderModel->IsLandscape(); |
|
291 mData->mLayoutMirrored = AknLayoutUtils::LayoutMirrored(); |
|
292 } |
|
293 |
|
294 if( mSliderModel->IsLandscape() != mData->mOrientationLandScape ) |
|
295 { |
|
296 relayout = true; |
|
297 mData->mOrientationLandScape = mSliderModel->IsLandscape(); |
|
298 } |
|
299 if(relayout) |
|
300 { |
|
301 |
|
302 CAlfControl* ctrl = (CAlfControl*)&control(); |
|
303 TAknLayoutRect layoutRect; |
|
304 //get the lct rect for mBaseSliderLayout and set it |
|
305 // aaslider_pane(2) |
|
306 layoutRect = MulSliderUtils::GetComponentRect( |
|
307 EVSliderPane,mData->mMainLayout,KVariety2); |
|
308 mData->mBaseSliderLayout->SetRect( |
|
309 TRect( TPoint(layoutRect.Rect().iTl.iX,layoutRect.Rect().iTl.iY ), |
|
310 TSize( layoutRect.Rect().Size().iWidth, |
|
311 layoutRect.Rect().Size().iHeight ))) ; |
|
312 if(!mData->mHasBackground) |
|
313 SetBackgroundBrush(); |
|
314 // Set Position and Size for Extended touch layout for track |
|
315 mData->mSliderCentreGhost->SetRect( |
|
316 TRect( TPoint(0,0 ), |
|
317 TSize( layoutRect.Rect().Size().iWidth, |
|
318 layoutRect.Rect().Size().iHeight ))); |
|
319 |
|
320 |
|
321 //get the lct rect for mImageMinus and set it |
|
322 // aid_touch_size_slider_min(2) |
|
323 layoutRect = MulSliderUtils::GetComponentRect( |
|
324 EVSliderMinus,mData->mBaseSliderLayout,KVariety2); |
|
325 mData->mImageMinus->SetRect( |
|
326 TRect( TPoint( layoutRect.Rect().iTl.iX,layoutRect.Rect().iTl.iY ), |
|
327 TSize( layoutRect.Rect().Size().iWidth, |
|
328 layoutRect.Rect().Size().iHeight ))) ; |
|
329 |
|
330 //get the lct rect for mImagePlus and set it |
|
331 // aid_touch_size_slider_max(1) |
|
332 layoutRect = MulSliderUtils::GetComponentRect( |
|
333 EVSliderPlus, |
|
334 mData->mBaseSliderLayout, |
|
335 KVariety1); |
|
336 mData->mImagePlus->SetRect( |
|
337 TRect( TPoint( layoutRect.Rect().iTl.iX,layoutRect.Rect().iTl.iY ), |
|
338 TSize( layoutRect.Rect().Size().iWidth, |
|
339 layoutRect.Rect().Size().iHeight ))) ; |
|
340 |
|
341 //get the lct rect for mSliderHandle and set it |
|
342 //aid_touch_size_slider_marker(5) |
|
343 layoutRect = MulSliderUtils::GetComponentRect( |
|
344 EVSliderMarker, |
|
345 mData->mBaseSliderLayout, |
|
346 KVariety5); |
|
347 mData->mSliderHandle->SetRect( |
|
348 TRect( TPoint( layoutRect.Rect().iTl.iX,layoutRect.Rect().iTl.iY ), |
|
349 TSize( layoutRect.Rect().Size().iWidth, |
|
350 layoutRect.Rect().Size().iHeight ))) ; |
|
351 |
|
352 layoutRect = MulSliderUtils::GetComponentRect( |
|
353 EVSliderMarkerExtended, |
|
354 mData->mBaseSliderLayout, |
|
355 KVariety5); |
|
356 mData->mHandleGhostHieghtDelta = |
|
357 (layoutRect.Rect().Size().iHeight - mData->mSliderHandle->Size().iY.ValueNow() ); |
|
358 |
|
359 // Set Position and Size for Extended touch layout for handle |
|
360 mData->mSliderHandleGhost->SetRect( |
|
361 TRect( TPoint( mData->mBaseSliderLayout->Pos().iX.ValueNow(), |
|
362 mData->mSliderHandle->Pos().iY.ValueNow()- |
|
363 mData->mHandleGhostHieghtDelta/2), |
|
364 TSize( mData->mBaseSliderLayout->Size().iX.ValueNow(), |
|
365 layoutRect.Rect().Size().iHeight))); |
|
366 |
|
367 //get the lct rect for mSliderCentre and set it |
|
368 //aaslider_bg_pane_cp001(6) |
|
369 layoutRect = MulSliderUtils::GetComponentRect( |
|
370 EVSliderBgPane, |
|
371 mData->mBaseSliderLayout, |
|
372 KVariety6); |
|
373 mData->mSliderCentre->SetRect( |
|
374 TRect( TPoint( layoutRect.Rect().iTl.iX , |
|
375 layoutRect.Rect().iTl.iY), |
|
376 TSize( layoutRect.Rect().Size().iWidth, |
|
377 layoutRect.Rect().Size().iHeight ))); |
|
378 |
|
379 //get the lct rect for mTrackTopImage and set it |
|
380 //aaslider_bg_pane_cp001_g1(0) |
|
381 layoutRect = MulSliderUtils::GetComponentRect( |
|
382 EVSliderTop, |
|
383 mData->mSliderCentre, |
|
384 KVariety0); |
|
385 mData->mTrackTopImage->SetRect( |
|
386 TRect( TPoint(0,layoutRect.Rect().iTl.iY), |
|
387 TSize( layoutRect.Rect().Size().iWidth, |
|
388 layoutRect.Rect().Size().iHeight ))); |
|
389 |
|
390 //get the lct rect for mTrackMiddleImage and set it |
|
391 //aaslider_bg_pane_cp001_g3(0) |
|
392 layoutRect = MulSliderUtils::GetComponentRect( |
|
393 EVSliderMiddle, |
|
394 mData->mSliderCentre, |
|
395 KVariety0); |
|
396 mData->mTrackMiddleImage->SetRect( |
|
397 TRect( TPoint( 0,layoutRect.Rect().iTl.iY), |
|
398 TSize( layoutRect.Rect().Size().iWidth, |
|
399 layoutRect.Rect().Size().iHeight ))); |
|
400 |
|
401 //get the lct rect for mTrackEndImage and set it |
|
402 //aaslider_bg_pane_cp001_g2(0) |
|
403 layoutRect = MulSliderUtils::GetComponentRect( |
|
404 EVSliderEnd, |
|
405 mData->mSliderCentre, |
|
406 KVariety0); |
|
407 mData->mTrackEndImage->SetRect( |
|
408 TRect( TPoint(0,layoutRect.Rect().iTl.iY), |
|
409 TSize( layoutRect.Rect().Size().iWidth, |
|
410 layoutRect.Rect().Size().iHeight ))); |
|
411 |
|
412 if(mData->mTrackTopImage && |
|
413 mData->mTrackMiddleImage && |
|
414 mData->mTrackEndImage) |
|
415 { |
|
416 setTrackImage(); |
|
417 } |
|
418 if(mData->mSliderHandle) |
|
419 { |
|
420 mData->mImageTextureId = KAlfMarkerTextureId; |
|
421 // Create the texture from bitmap provider |
|
422 mData->mTexture = &((ctrl->Env()).TextureManager().CreateTextureL( |
|
423 KAlfAutoGeneratedTextureId/*KAlfMarkerTextureId*/, |
|
424 (MAlfBitmapProvider *)this, |
|
425 (TAlfTextureFlags)(EAlfTextureFlagRetainResolution| |
|
426 EAlfTextureFlagSkinContent))); |
|
427 TAlfImage aImage(*mData->mTexture ); |
|
428 mData->mSliderHandle->SetImage(aImage); |
|
429 |
|
430 } |
|
431 |
|
432 if(mData->mImagePlus) |
|
433 { |
|
434 mData->mImageTextureId = KAlfZoomInTextureId; |
|
435 // Create the texture from bitmap provider |
|
436 mData->mTexture = &((ctrl->Env()).TextureManager().CreateTextureL( |
|
437 KAlfAutoGeneratedTextureId/*KAlfZoomInTextureId*/, |
|
438 (MAlfBitmapProvider *)this, |
|
439 (TAlfTextureFlags)(EAlfTextureFlagRetainResolution|EAlfTextureFlagSkinContent))); |
|
440 TAlfImage aImage(*mData->mTexture ); |
|
441 mData->mImagePlus->SetImage(aImage); |
|
442 } |
|
443 |
|
444 if(mData->mImageMinus) |
|
445 { |
|
446 mData->mImageTextureId = KAlfZoomOutTextureId; |
|
447 // Create the texture from bitmap provider |
|
448 mData->mTexture = &((ctrl->Env()).TextureManager().CreateTextureL( |
|
449 KAlfAutoGeneratedTextureId/*KAlfZoomOutTextureId*/, |
|
450 (MAlfBitmapProvider *)this, |
|
451 (TAlfTextureFlags)(EAlfTextureFlagRetainResolution|EAlfTextureFlagSkinContent))); |
|
452 TAlfImage aImage(*mData->mTexture ); |
|
453 mData->mImageMinus->SetImage(aImage); |
|
454 |
|
455 } |
|
456 } |
|
457 } |
|
458 // --------------------------------------------------------------------------- |
|
459 // Used for setting images for the track |
|
460 // --------------------------------------------------------------------------- |
|
461 // |
|
462 |
|
463 void MulSliderVertical::setTrackImage() |
|
464 { |
|
465 //Review |
|
466 TInt flags = EAlfTextureFlagSkinContent; |
|
467 flags |= EAlfTextureFlagAutoSize; |
|
468 |
|
469 CAlfControl* ctrl = (CAlfControl*)&control(); |
|
470 //creating texture for topimage |
|
471 mData->mImageTextureId = KAlfTrackTopTextureId; |
|
472 mData->mTexture = &((ctrl->Env()).TextureManager().CreateTextureL( |
|
473 KAlfAutoGeneratedTextureId/*KAlfTrackTopTextureId*/, |
|
474 (MAlfBitmapProvider *)this, |
|
475 (TAlfTextureFlags)(EAlfTextureFlagRetainResolution|EAlfTextureFlagSkinContent))); |
|
476 |
|
477 TAlfImage trackTopImage(*mData->mTexture ); |
|
478 //creating texture for middleimage |
|
479 mData->mImageTextureId = KAlfTrackMiddleTextureId; |
|
480 mData->mTexture = &((ctrl->Env()).TextureManager().CreateTextureL( |
|
481 KAlfAutoGeneratedTextureId/*KAlfTrackMiddleTextureId*/, |
|
482 (MAlfBitmapProvider *)this, |
|
483 (TAlfTextureFlags)(EAlfTextureFlagRetainResolution|EAlfTextureFlagSkinContent))); |
|
484 |
|
485 TAlfImage trackMiddleImage(*mData->mTexture ); |
|
486 |
|
487 //creating texture for bottom image |
|
488 mData->mImageTextureId = KAlfTrackBottomTextureId; |
|
489 mData->mTexture = &((ctrl->Env()).TextureManager().CreateTextureL( |
|
490 KAlfAutoGeneratedTextureId/*KAlfTrackBottomTextureId*/, |
|
491 (MAlfBitmapProvider *)this, |
|
492 (TAlfTextureFlags)(EAlfTextureFlagDefault))); |
|
493 |
|
494 |
|
495 TAlfImage trackEndImage(*mData->mTexture ); |
|
496 // Set Image on visuals |
|
497 mData->mTrackTopImage->SetImage(trackTopImage); |
|
498 mData->mTrackMiddleImage->SetImage(trackMiddleImage); |
|
499 mData->mTrackEndImage->SetImage(trackEndImage); |
|
500 |
|
501 }//End of setImage |
|
502 |
|
503 // --------------------------------------------------------------------------- |
|
504 // ProvideBitmapL() |
|
505 // --------------------------------------------------------------------------- |
|
506 // |
|
507 void MulSliderVertical::ProvideBitmapL (TInt aId, CFbsBitmap *& aBitmap, CFbsBitmap *& aMaskBitmap) |
|
508 { |
|
509 TAknLayoutRect layoutRect; |
|
510 switch(mData->mImageTextureId) |
|
511 { |
|
512 case KAlfTrackTopTextureId: |
|
513 { |
|
514 AknIconUtils::CreateIconL( |
|
515 aBitmap, |
|
516 aMaskBitmap, |
|
517 KAvkonBitmapFile, |
|
518 EMbmAvkonQgn_graf_nslider_vertical_top, |
|
519 EMbmAvkonQgn_graf_nslider_vertical_top_mask ); |
|
520 |
|
521 layoutRect = MulSliderUtils::GetComponentRect( |
|
522 EVSliderTop, |
|
523 mData->mSliderCentre, |
|
524 KVariety0); |
|
525 |
|
526 AknIconUtils::SetSize( aBitmap, |
|
527 TSize(layoutRect.Rect().Size().iWidth, |
|
528 layoutRect.Rect().Size().iHeight), |
|
529 EAspectRatioNotPreserved); |
|
530 mData->mImageTextureId = 0; |
|
531 mData->mTrackTopTextureId = aId; |
|
532 } |
|
533 break; |
|
534 case KAlfTrackBottomTextureId: |
|
535 { |
|
536 AknIconUtils::CreateIconL( |
|
537 aBitmap, |
|
538 aMaskBitmap, |
|
539 KAvkonBitmapFile, |
|
540 EMbmAvkonQgn_graf_nslider_vertical_bottom, |
|
541 EMbmAvkonQgn_graf_nslider_vertical_bottom_mask ); |
|
542 |
|
543 layoutRect = MulSliderUtils::GetComponentRect( |
|
544 EVSliderEnd, |
|
545 mData->mSliderCentre, |
|
546 KVariety0); |
|
547 AknIconUtils::SetSize( aBitmap, |
|
548 TSize(layoutRect.Rect().Size().iWidth, |
|
549 layoutRect.Rect().Size().iHeight), |
|
550 EAspectRatioNotPreserved); |
|
551 mData->mImageTextureId = 0; |
|
552 mData->mTrackBottomTextureId = aId; |
|
553 } |
|
554 break; |
|
555 case KAlfTrackMiddleTextureId: |
|
556 { |
|
557 AknIconUtils::CreateIconL( |
|
558 aBitmap, |
|
559 aMaskBitmap, |
|
560 KAvkonBitmapFile, |
|
561 EMbmAvkonQgn_graf_nslider_vertical_middle, |
|
562 EMbmAvkonQgn_graf_nslider_vertical_middle_mask ); |
|
563 |
|
564 layoutRect = MulSliderUtils::GetComponentRect( |
|
565 EVSliderMiddle, |
|
566 mData->mSliderCentre, |
|
567 KVariety0); |
|
568 |
|
569 AknIconUtils::SetSize( aBitmap, |
|
570 TSize(layoutRect.Rect().Size().iWidth, |
|
571 layoutRect.Rect().Size().iHeight), |
|
572 EAspectRatioNotPreserved); |
|
573 |
|
574 mData->mImageTextureId = 0; |
|
575 mData->mTrackMiddleTextureId = aId; |
|
576 } |
|
577 break; |
|
578 |
|
579 case KAlfMarkerTextureId: |
|
580 { |
|
581 AknIconUtils::CreateIconL( |
|
582 aBitmap, |
|
583 aMaskBitmap, |
|
584 KAvkonBitmapFile, |
|
585 EMbmAvkonQgn_graf_nslider_vertical_marker, |
|
586 EMbmAvkonQgn_graf_nslider_vertical_marker_mask ); |
|
587 |
|
588 layoutRect = MulSliderUtils::GetComponentRect( |
|
589 EVSliderMarker, |
|
590 mData->mBaseSliderLayout, |
|
591 KVariety5); |
|
592 |
|
593 AknIconUtils::SetSize( aBitmap, |
|
594 TSize(layoutRect.Rect().Size().iWidth, |
|
595 layoutRect.Rect().Size().iHeight), |
|
596 EAspectRatioNotPreserved); |
|
597 |
|
598 mData->mImageTextureId = 0; |
|
599 mData->mMarkerTextureId = aId; |
|
600 } |
|
601 break; |
|
602 case KAlfZoomInTextureId: |
|
603 { |
|
604 AknIconUtils::CreateIconL( |
|
605 aBitmap, |
|
606 aMaskBitmap, |
|
607 KSliderBitmapFile, |
|
608 EMbmMulsliderwidgetQgn_indi_nslider_zoom_in, |
|
609 EMbmMulsliderwidgetQgn_indi_nslider_zoom_in_mask ); |
|
610 |
|
611 layoutRect = MulSliderUtils::GetComponentRect( |
|
612 EVSliderPlus,mData->mBaseSliderLayout,KVariety1); |
|
613 |
|
614 AknIconUtils::SetSize( aBitmap, |
|
615 TSize(layoutRect.Rect().Size().iWidth, |
|
616 layoutRect.Rect().Size().iHeight), |
|
617 EAspectRatioNotPreserved); |
|
618 mData->mImageTextureId = 0; |
|
619 mData->mZoomInTextureId = aId; |
|
620 } |
|
621 break; |
|
622 case KAlfZoomOutTextureId: |
|
623 { |
|
624 AknIconUtils::CreateIconL( |
|
625 aBitmap, |
|
626 aMaskBitmap, |
|
627 KSliderBitmapFile, |
|
628 EMbmMulsliderwidgetQgn_indi_nslider_zoom_out, |
|
629 EMbmMulsliderwidgetQgn_indi_nslider_zoom_out_mask ); |
|
630 |
|
631 layoutRect = MulSliderUtils::GetComponentRect( |
|
632 EVSliderMinus,mData->mBaseSliderLayout,KVariety2); |
|
633 |
|
634 AknIconUtils::SetSize( aBitmap, |
|
635 TSize(layoutRect.Rect().Size().iWidth, |
|
636 layoutRect.Rect().Size().iHeight), |
|
637 EAspectRatioNotPreserved); |
|
638 |
|
639 mData->mImageTextureId = 0; |
|
640 mData->mZoomOutTextureId = aId; |
|
641 } |
|
642 break; |
|
643 default: |
|
644 break; |
|
645 |
|
646 } |
|
647 |
|
648 } |
|
649 |
|
650 // --------------------------------------------------------------------------- |
|
651 // setBackgroundBrush() |
|
652 // --------------------------------------------------------------------------- |
|
653 // |
|
654 void MulSliderVertical::SetBackgroundBrush() |
|
655 { |
|
656 |
|
657 CAlfControl* ctrl = (CAlfControl*)&control(); |
|
658 // Get Slider Pane Rect (aaslider_pane(2)) and apply on mBaseSliderLayout |
|
659 TAknLayoutRect layoutRect = MulSliderUtils::GetComponentRect( |
|
660 EVSliderPane,mData->mMainLayout,2); |
|
661 |
|
662 |
|
663 TAknWindowLineLayout LayoutHandle = |
|
664 AknLayoutScalable_UiAccel:: |
|
665 aid_touch_size_slider_max(0).LayoutLine(); |
|
666 |
|
667 |
|
668 int x = LayoutHandle.il; |
|
669 TAknsItemID itemid; |
|
670 |
|
671 itemid.Set(EAknsMajorSkin, EAknsMinorQgnGrafPopupTrans); |
|
672 CAlfFrameBrush* brush = CAlfFrameBrush::NewLC((*ctrl).Env(),itemid, 0, 0); |
|
673 |
|
674 if(brush!=NULL) |
|
675 { |
|
676 TRect dispRect(layoutRect.Rect().iTl.iX, |
|
677 layoutRect.Rect().iTl.iY, |
|
678 layoutRect.Rect().Size().iWidth, |
|
679 layoutRect.Rect().Size().iHeight ); |
|
680 TRect innerRect(layoutRect.Rect().iTl.iX + x, |
|
681 layoutRect.Rect().iTl.iY + x, |
|
682 layoutRect.Rect().Size().iWidth - x , |
|
683 layoutRect.Rect().Size().iHeight - x); |
|
684 |
|
685 brush->SetFrameRectsL(innerRect,dispRect); |
|
686 brush->SetOpacity(KMinopacity); |
|
687 mData->mBaseSliderLayout->EnableBrushesL(); |
|
688 mData->mBaseSliderLayout->Brushes()->AppendL(brush, EAlfHasOwnership); |
|
689 CleanupStack::Pop(brush); |
|
690 } |
|
691 mData->mHasBackground = true; |
|
692 } |
|
693 |
|
694 // --------------------------------------------------------------------------- |
|
695 // MakeTransparent() |
|
696 // --------------------------------------------------------------------------- |
|
697 // |
|
698 void MulSliderVertical::MakeTransparent(bool aVal) |
|
699 { |
|
700 CAlfBrushArray * brushArray = mData->mBaseSliderLayout->Brushes(); |
|
701 if(aVal) |
|
702 { |
|
703 TAlfTimedValue opacity(KMinopacity); |
|
704 brushArray->At(0).SetOpacity(opacity); |
|
705 } |
|
706 else |
|
707 { |
|
708 TAlfTimedValue opacity(KMaxopacity); |
|
709 brushArray->At(0).SetOpacity(opacity); |
|
710 } |
|
711 } |
|
712 // --------------------------------------------------------------------------- |
|
713 // ConvertDataToPixels |
|
714 // --------------------------------------------------------------------------- |
|
715 // |
|
716 void MulSliderVertical::ConvertDataToPixels() |
|
717 { |
|
718 // Calculate the range in pixel values |
|
719 mData->mRangeInPixels = |
|
720 (mData->mSliderCentre->Size().iY.ValueNow() - |
|
721 mData->mSliderHandle->Size().iY.ValueNow()); |
|
722 |
|
723 if(mSliderModel->MaxRange() - mSliderModel->MinRange() != 0) |
|
724 { |
|
725 // Calculate Tick Size in Pixels |
|
726 mData->mTickInPixels = |
|
727 (mData->mSliderCentre->Size().iY.ValueNow() - |
|
728 mData->mSliderHandle->Size().iY.ValueNow()) / |
|
729 (mSliderModel->MaxRange() - mSliderModel->MinRange()) ; |
|
730 } |
|
731 // Get the track start pixel value |
|
732 mData->mTrackStartPoint = mData->mSliderCentre->Pos().iY.ValueNow() + |
|
733 mData->mSliderCentre->Size().iY.ValueNow() - |
|
734 mData->mSliderHandle->Size().iY.ValueNow() ; |
|
735 // Store current tick |
|
736 mData->mCurrTick = mSliderModel->PrimaryValue() ; |
|
737 if(mSliderModel->MaxRange()== mSliderModel->MinRange()) |
|
738 { |
|
739 mData->mTrackStartPoint= mData->mSliderCentre->Pos().iY.ValueNow(); |
|
740 } |
|
741 mData->mTick = mSliderModel->Tick(); |
|
742 } |
|
743 |
|
744 |
|
745 // --------------------------------------------------------------------------- |
|
746 // createVisualization |
|
747 // --------------------------------------------------------------------------- |
|
748 // |
|
749 void MulSliderVertical::createVisualization(sliderTemplate /*aTemplateId*/) |
|
750 { |
|
751 mData->mHasBackground = false; |
|
752 if(AknLayoutUtils::LayoutMirrored()) |
|
753 mData->mLayoutMirrored = true; |
|
754 else |
|
755 mData->mLayoutMirrored = false; |
|
756 // Create the visualization |
|
757 CAlfControl* ctrl = (CAlfControl*)&control(); |
|
758 mData->mOrientationLandScape = !mSliderModel->IsLandscape(); |
|
759 |
|
760 // Visual Hierarchy creation |
|
761 // create the mMainLayout |
|
762 mData->mMainLayout = CAlfLayout::AddNewL(*ctrl,NULL); |
|
763 // set the flag for Notifications |
|
764 mData->mMainLayout->SetFlag(EAlfVisualFlagLayoutUpdateNotification); |
|
765 //create the mBaseSliderLayout |
|
766 mData->mBaseSliderLayout = |
|
767 CAlfLayout::AddNewL(*ctrl,mData->mMainLayout); |
|
768 // create the dummy layout for slider track |
|
769 mData->mSliderCentreGhost = |
|
770 CAlfLayout::AddNewL(*ctrl,mData->mBaseSliderLayout); |
|
771 // create the dummy layout for slider handle |
|
772 mData->mSliderHandleGhost = |
|
773 CAlfLayout::AddNewL(*ctrl,mData->mBaseSliderLayout); |
|
774 |
|
775 // create the imagevisual for slider track |
|
776 mData->mSliderCentre = |
|
777 CAlfLayout::AddNewL(*ctrl,mData->mBaseSliderLayout); |
|
778 // create the imagevisual for slider handle |
|
779 mData->mSliderHandle = |
|
780 CAlfImageVisual::AddNewL(*ctrl,mData->mBaseSliderLayout); |
|
781 // create the imagevisual for plus icon |
|
782 mData->mImagePlus= |
|
783 CAlfImageVisual::AddNewL(*ctrl,mData->mBaseSliderLayout); |
|
784 // create the imagevisual for minus icon |
|
785 mData->mImageMinus = |
|
786 CAlfImageVisual::AddNewL(*ctrl,mData->mBaseSliderLayout); |
|
787 if(mData->mSliderCentre) |
|
788 { |
|
789 mData->mTrackTopImage = CAlfImageVisual::AddNewL(*ctrl,mData->mSliderCentre); |
|
790 mData->mTrackMiddleImage = CAlfImageVisual::AddNewL(*ctrl,mData->mSliderCentre); |
|
791 mData->mTrackEndImage = CAlfImageVisual::AddNewL(*ctrl,mData->mSliderCentre); |
|
792 } |
|
793 |
|
794 // Get the widget opacity and apply on root visual |
|
795 mSliderWidget->ShowWidget(mSliderWidget->GetOpacity(),0); |
|
796 } |
|
797 |
|
798 |
|
799 // --------------------------------------------------------------------------- |
|
800 // eventHandlerType |
|
801 // --------------------------------------------------------------------------- |
|
802 // |
|
803 IAlfWidgetEventHandler::AlfEventHandlerType MulSliderVertical::eventHandlerType() |
|
804 { |
|
805 return IAlfWidgetEventHandler::EPresentationEventHandler; |
|
806 } |
|
807 |
|
808 |
|
809 // --------------------------------------------------------------------------- |
|
810 // eventExecutionPhase |
|
811 // --------------------------------------------------------------------------- |
|
812 // |
|
813 IAlfWidgetEventHandler::AlfEventHandlerExecutionPhase MulSliderVertical:: |
|
814 eventExecutionPhase() |
|
815 { |
|
816 return IAlfWidgetEventHandler::ETunnellingPhaseEventHandler; |
|
817 } |
|
818 |
|
819 |
|
820 // --------------------------------------------------------------------------- |
|
821 // offerEvent |
|
822 // --------------------------------------------------------------------------- |
|
823 // |
|
824 AlfEventStatus MulSliderVertical::offerEvent( CAlfWidgetControl& /*aControl*/, |
|
825 const TAlfEvent& aEvent ) |
|
826 { |
|
827 AlfEventStatus ret=EEventNotHandled; |
|
828 if(!mSliderWidget->IsHidden()) |
|
829 { |
|
830 if(aEvent.IsCustomEvent()) |
|
831 { |
|
832 if(aEvent.CustomParameter() == EEventMissedPointerUp) |
|
833 { |
|
834 ret=EEventHandled; |
|
835 mData->mSliderHit = false; |
|
836 handlePointerUpEvent(); |
|
837 } |
|
838 } |
|
839 |
|
840 // handle key events |
|
841 else if(aEvent.IsKeyEvent() && mSliderWidget->IsKeyEnabled() ) |
|
842 { |
|
843 ret = HandleKeyEvents(aEvent); |
|
844 } |
|
845 |
|
846 // Pointer drag events and single tap events |
|
847 else if(aEvent.IsPointerEvent()) |
|
848 { |
|
849 if(mSliderWidget->GetOpacity()) |
|
850 { |
|
851 ret = HandlePointerEvents((TAlfEvent *)&aEvent); |
|
852 } |
|
853 } |
|
854 |
|
855 } |
|
856 |
|
857 return ret; |
|
858 } |
|
859 |
|
860 |
|
861 // --------------------------------------------------------------------------- |
|
862 // HandleKeyEvents |
|
863 // --------------------------------------------------------------------------- |
|
864 // |
|
865 AlfEventStatus MulSliderVertical::HandleKeyEvents(const TAlfEvent& aEvent) |
|
866 { |
|
867 AlfEventStatus ret = EEventNotHandled; |
|
868 |
|
869 |
|
870 if(aEvent.KeyEvent().iScanCode == EStdKeyUpArrow) |
|
871 { |
|
872 if(aEvent.Code() == EEventKey) |
|
873 { |
|
874 ret = EEventHandled; |
|
875 int newPos = mSliderModel->PrimaryValue() + mData->mTick; |
|
876 updateModelPrimaryValue(newPos); |
|
877 } |
|
878 } |
|
879 else if(aEvent.KeyEvent().iScanCode == EStdKeyDownArrow) |
|
880 { |
|
881 if(aEvent.Code() == EEventKey) |
|
882 { |
|
883 ret = EEventHandled; |
|
884 int newPos = mSliderModel->PrimaryValue() - mData->mTick; |
|
885 updateModelPrimaryValue(newPos); |
|
886 } |
|
887 } |
|
888 return ret; |
|
889 } |
|
890 // --------------------------------------------------------------------------- |
|
891 // Sends drag Up or Down event, according to the hit position |
|
892 // on track |
|
893 // --------------------------------------------------------------------------- |
|
894 // |
|
895 AlfEventStatus MulSliderVertical::trackVisualHit(CAlfVisual * /*aHitVisual*/) |
|
896 { |
|
897 //Find the thumb Anchor Layout. |
|
898 // Zoom Plus icon rectangle |
|
899 TAlfRealRect zoomPlus = mData->mBaseSliderLayout->DisplayRect(); |
|
900 // Slider Handle position |
|
901 TAlfTimedPoint thumbVisPos = mData->mSliderHandle->Pos(); |
|
902 TAlfTimedPoint thumbVisSize = mData->mSliderHandle->Size(); |
|
903 // Slider track display rect |
|
904 TAlfRealRect rct = mData->mSliderCentre->DisplayRect() ; |
|
905 int diff = rct.iTl.iY - zoomPlus.iTl.iY; |
|
906 //Check if click was above/to left or below/to right of thumb |
|
907 if (mData->mLongTapPos.iY - rct.iTl.iY < thumbVisPos.iY.ValueNow() + (thumbVisSize.iY.ValueNow()/2) - diff) |
|
908 { |
|
909 // Pointer down happened above Handle |
|
910 int newPos = mSliderModel->PrimaryValue() + (((thumbVisPos.iY.ValueNow() +(thumbVisSize.iY.ValueNow()/2) - diff) -(mData->mLongTapPos.iY - rct.iTl.iY))/mData->mTickInPixels); |
|
911 |
|
912 if( rct.iTl.iY > mData->mLongTapPos.iY ) |
|
913 { |
|
914 mData->mLongTapPos.iY = rct.iTl.iY + (thumbVisSize.iY.ValueNow()/2); |
|
915 } |
|
916 // Move Handle |
|
917 if(mData->mdirection !=2) |
|
918 { |
|
919 // checks if the thumb was moving up |
|
920 updateModelPrimaryValue(newPos); |
|
921 mData->mdirection = 1; |
|
922 } |
|
923 |
|
924 if(!mData->mOperation) |
|
925 { |
|
926 mData->mVisual = mData->mSliderHandle; |
|
927 initializeThumbDragData( |
|
928 mData->mLongTapPos); |
|
929 |
|
930 } |
|
931 } |
|
932 else if (mData->mLongTapPos.iY - rct.iTl.iY > (thumbVisPos.iY.ValueNow() + |
|
933 (thumbVisSize.iY.ValueNow()/2)- diff) ) |
|
934 { |
|
935 if( (rct.iTl.iY + rct.Size().iHeight < mData->mLongTapPos.iY)) |
|
936 { |
|
937 mData->mLongTapPos.iY = rct.iTl.iY+ rct.Size().iHeight - (thumbVisSize.iY.ValueNow()/2); |
|
938 } |
|
939 // Pointer down happened below Handle |
|
940 int newPos = mSliderModel->PrimaryValue() - (((mData->mLongTapPos.iY - rct.iTl.iY) -(thumbVisPos.iY.ValueNow() + (thumbVisSize.iY.ValueNow()/2)-diff))/mData->mTickInPixels); |
|
941 // Move Handle |
|
942 if(mData->mdirection !=1) |
|
943 { |
|
944 // checks if the thumb was moving down |
|
945 updateModelPrimaryValue(newPos); |
|
946 mData->mdirection = 2; |
|
947 } |
|
948 |
|
949 //mData->mLongTapStarted = false; |
|
950 if(!mData->mOperation) |
|
951 { |
|
952 mData->mVisual = mData->mSliderHandle; |
|
953 initializeThumbDragData( mData->mLongTapPos); |
|
954 |
|
955 } |
|
956 } |
|
957 else |
|
958 { |
|
959 |
|
960 } |
|
961 return EEventHandled; |
|
962 } |
|
963 |
|
964 // --------------------------------------------------------------------------- |
|
965 // handles the pointerDown event |
|
966 // |
|
967 // --------------------------------------------------------------------------- |
|
968 // |
|
969 AlfEventStatus MulSliderVertical::handlePointerDownEvent(TAlfEvent * aPntrEvent) |
|
970 { |
|
971 |
|
972 CAlfVisual * focusvisual = aPntrEvent->Visual(); |
|
973 AlfEventStatus result = EEventNotHandled; |
|
974 if (focusvisual) |
|
975 { |
|
976 mData->mVisual = focusvisual; |
|
977 if (IsSliderVisual(focusvisual)) |
|
978 { |
|
979 control().processEvent(TAlfEvent(ECustomEventIconClick)); |
|
980 mData->mSliderHit = true; |
|
981 MakeTransparent(false); |
|
982 |
|
983 // Register with the Roster to receive Long Tap Event |
|
984 control().Display()->Roster().SetPointerEventObservers( |
|
985 EAlfPointerEventReportDrag,control()); |
|
986 |
|
987 if(!mData->mOperation) |
|
988 { |
|
989 mData->mLongTapPos = aPntrEvent->PointerEvent().iParentPosition; |
|
990 //mData->mLongTapStarted = true; |
|
991 } |
|
992 |
|
993 //Page Movement |
|
994 if (focusvisual == mData->mSliderCentre || |
|
995 focusvisual == mData->mSliderCentreGhost) |
|
996 { |
|
997 result = trackVisualHit(focusvisual); |
|
998 } |
|
999 |
|
1000 // Drag |
|
1001 else if (focusvisual == mData->mSliderHandle |
|
1002 || focusvisual == mData->mSliderHandleGhost ) |
|
1003 { |
|
1004 if(focusvisual) |
|
1005 { |
|
1006 // Initialize the drag variables |
|
1007 initializeThumbDragData(aPntrEvent->PointerEvent().iParentPosition); |
|
1008 //Tactile Feedback For Thumb touch |
|
1009 MulSliderControl& sldrcntrl = static_cast<MulSliderControl&>(control()); |
|
1010 sldrcntrl.TactileEffectOnTouchandHold(); |
|
1011 } |
|
1012 result = EEventHandled; |
|
1013 } |
|
1014 // Zoom Icon Plus Clicked |
|
1015 else if (focusvisual == mData->mImagePlus || focusvisual == mData->mImageMinus ) |
|
1016 { |
|
1017 // Update the newTick |
|
1018 int newPos =0; |
|
1019 if( mData->mVisual == mData->mImagePlus) |
|
1020 { |
|
1021 newPos = mSliderModel->MaxRange(); |
|
1022 } |
|
1023 else |
|
1024 { |
|
1025 newPos = mSliderModel->MinRange(); |
|
1026 //newPos = mSliderModel->PrimaryValue() - mData->mTick; |
|
1027 } |
|
1028 updateModelPrimaryValue(newPos); |
|
1029 //return ETrue; |
|
1030 result = EEventHandled; |
|
1031 } |
|
1032 |
|
1033 }//END OF if (isSliderVisual()) |
|
1034 } |
|
1035 return result; |
|
1036 }// End Of handlePointerDownEvent |
|
1037 |
|
1038 |
|
1039 // --------------------------------------------------------------------------- |
|
1040 // HandlePointerEvents |
|
1041 // --------------------------------------------------------------------------- |
|
1042 // |
|
1043 AlfEventStatus MulSliderVertical::HandlePointerEvents(TAlfEvent* aEvent) |
|
1044 { |
|
1045 AlfEventStatus ret = EEventNotHandled; |
|
1046 if (aEvent->PointerEvent().iType == TPointerEvent::EButton1Down) |
|
1047 { |
|
1048 mData->mdirection = 0; |
|
1049 return handlePointerDownEvent(aEvent); |
|
1050 } |
|
1051 // Drag Events |
|
1052 else if (aEvent->PointerEvent().iType == TPointerEvent::EDrag) |
|
1053 { |
|
1054 // Drag on Handle |
|
1055 TAlfRealRect rct = mData->mSliderCentre->DisplayRect() ; |
|
1056 TAlfTimedPoint thumbVisSize = mData->mSliderHandle->Size(); |
|
1057 // Drag on Handle |
|
1058 if(mData->mVisual && |
|
1059 mData->mSliderHandle && mData->mSliderHandleGhost) |
|
1060 { |
|
1061 // Store the new pointer position |
|
1062 mData->mLongTapPos= aEvent->PointerEvent().iParentPosition ; |
|
1063 } |
|
1064 |
|
1065 // Calculate the distance moved from the drag start point |
|
1066 int dist = mData->mDragPoint.iY - aEvent->PointerEvent().iParentPosition.iY; |
|
1067 int precision = KRoundupvalue; |
|
1068 if(dist<0) |
|
1069 { |
|
1070 precision = -KRoundupvalue; |
|
1071 } |
|
1072 // Calculate the new tick position |
|
1073 int newPos = (int)(((float)dist / mData->mTickInPixels ) + precision) + |
|
1074 mData->mDragStartStep; |
|
1075 // Update the model hence update visualization |
|
1076 updateModelPrimaryValue(newPos); |
|
1077 //Tactile Feedback For Thumb Drag |
|
1078 MulSliderControl& sldrcntrl = static_cast<MulSliderControl&>(control()); |
|
1079 sldrcntrl.TactileEffectOnDrag(*aEvent); |
|
1080 ret = EEventHandled; |
|
1081 } |
|
1082 |
|
1083 else if(aEvent->PointerUp() ) |
|
1084 { |
|
1085 |
|
1086 // Long tap Timer not running |
|
1087 //mData->mLongTapStarted = false; |
|
1088 // Handle events for pointer up |
|
1089 if(mData->mSliderHit) |
|
1090 { |
|
1091 // checing if any of slider visual got a button down event |
|
1092 // Otherwise its a stray pointerup event , so dont handle it |
|
1093 mData->mSliderHit = false; |
|
1094 ret = EEventHandled; |
|
1095 handlePointerUpEvent(); |
|
1096 } |
|
1097 |
|
1098 } |
|
1099 |
|
1100 return ret; |
|
1101 } |
|
1102 |
|
1103 |
|
1104 // --------------------------------------------------------------------------- |
|
1105 // updateModelPrimaryValue |
|
1106 // --------------------------------------------------------------------------- |
|
1107 // |
|
1108 void MulSliderVertical::updateModelPrimaryValue(int aNewPosValue) |
|
1109 { |
|
1110 // Validate the new tick value |
|
1111 if(aNewPosValue < mSliderModel->MinRange()) |
|
1112 { |
|
1113 aNewPosValue = mSliderModel->MinRange(); |
|
1114 } |
|
1115 else if(aNewPosValue > mSliderModel->MaxRange()) |
|
1116 { |
|
1117 aNewPosValue = mSliderModel->MaxRange(); |
|
1118 } |
|
1119 if(mSliderModel->PrimaryValue() != aNewPosValue && mData->mTick != 0) |
|
1120 { |
|
1121 // Update visualization and model only if data is changed |
|
1122 mSliderModel->SetPrimaryValue(aNewPosValue); |
|
1123 mPosData.reset(new(EMM)MulSliderPos); |
|
1124 mPosData->mPreviousValue = mData->mCurrTick ; |
|
1125 mPosData->mCurrentValue= aNewPosValue; |
|
1126 mData->mCurrTick = aNewPosValue; |
|
1127 // Send event to the scrollable widget |
|
1128 TAlfEvent customevent(ETypePrimaryValueChange, |
|
1129 (uint)mPosData.get()); |
|
1130 control().processEvent(customevent); |
|
1131 } |
|
1132 } |
|
1133 |
|
1134 // --------------------------------------------------------------------------- |
|
1135 // snapPrimaryValueToTicks |
|
1136 // --------------------------------------------------------------------------- |
|
1137 // |
|
1138 void MulSliderVertical::snapPrimaryValueToTicks() |
|
1139 { |
|
1140 // If the position is not a multiple of ticks then |
|
1141 //snap to the nearest tick multiple |
|
1142 int currHandlePos = mSliderModel->PrimaryValue() - mSliderModel->MinRange(); |
|
1143 int tick = mSliderModel->Tick(); |
|
1144 int newPos = currHandlePos + mSliderModel->MinRange(); |
|
1145 if(mSliderModel->PrimaryValue() < mSliderModel->MaxRange()) |
|
1146 { |
|
1147 |
|
1148 int diff = 0; |
|
1149 if(tick > 0) //model |
|
1150 { |
|
1151 diff = currHandlePos - ((currHandlePos /tick) * tick); |
|
1152 } |
|
1153 if(diff !=0) |
|
1154 { |
|
1155 newPos = currHandlePos + tick - diff + mSliderModel->MinRange(); |
|
1156 } |
|
1157 } |
|
1158 |
|
1159 |
|
1160 // Update model |
|
1161 updateModelPrimaryValue(newPos); |
|
1162 } |
|
1163 |
|
1164 |
|
1165 // --------------------------------------------------------------------------- |
|
1166 // handles the pointerUp event |
|
1167 // |
|
1168 // --------------------------------------------------------------------------- |
|
1169 // |
|
1170 void MulSliderVertical::handlePointerUpEvent() |
|
1171 { |
|
1172 // if thumb or track is clicked, change the graphics |
|
1173 // Send event if single click has hapened |
|
1174 |
|
1175 snapPrimaryValueToTicks(); |
|
1176 MakeTransparent(true); |
|
1177 if(mData->mOperation) |
|
1178 { |
|
1179 //Somehow missed the Up event? |
|
1180 stopDrag(); |
|
1181 //Tactile Feedback For Thumb Release |
|
1182 MulSliderControl& sldrcntrl = static_cast<MulSliderControl&>(control()); |
|
1183 sldrcntrl.TactileEffectOnRelease(); |
|
1184 } |
|
1185 |
|
1186 |
|
1187 // Un-register with the roster for long tap events |
|
1188 control().Display()->Roster().SetPointerEventObservers(0, |
|
1189 control()); |
|
1190 |
|
1191 // send the event for release/poiter up |
|
1192 control().processEvent(TAlfEvent(ECustomEventIconRelease)); |
|
1193 } |
|
1194 |
|
1195 // --------------------------------------------------------------------------- |
|
1196 // Stops event handling |
|
1197 // |
|
1198 // --------------------------------------------------------------------------- |
|
1199 // |
|
1200 void MulSliderVertical::stopEvents() |
|
1201 { |
|
1202 if(mData->mSliderHit) |
|
1203 { |
|
1204 // checking if any of slider visual got a button down event |
|
1205 mData->mSliderHit = false; |
|
1206 handlePointerUpEvent(); |
|
1207 } |
|
1208 } |
|
1209 |
|
1210 // --------------------------------------------------------------------------- |
|
1211 |
|
1212 // UpdateVisualization |
|
1213 // --------------------------------------------------------------------------- |
|
1214 // |
|
1215 |
|
1216 void MulSliderVertical::updateVisualization() |
|
1217 { |
|
1218 ConvertDataToPixels(); |
|
1219 SetThumbPosition(); |
|
1220 } |
|
1221 // --------------------------------------------------------------------------- |
|
1222 // SetThumbPosition |
|
1223 // --------------------------------------------------------------------------- |
|
1224 // |
|
1225 void MulSliderVertical::SetThumbPosition() |
|
1226 { |
|
1227 // Current primary value in pixels |
|
1228 int deltaY = (mSliderModel->PrimaryValue() - mSliderModel->MinRange()) * |
|
1229 mData->mTickInPixels; |
|
1230 // Handle |
|
1231 int handleX = mData->mSliderHandle->Pos().iX.ValueNow(); |
|
1232 int ghostHandleX = mData->mSliderHandleGhost->Pos().iX.ValueNow(); |
|
1233 // Handle new pos |
|
1234 TAlfRealPoint pnt(handleX,mData->mTrackStartPoint - deltaY); |
|
1235 // Ghost Handle ( Extended) new pos |
|
1236 TAlfRealPoint pnt1(ghostHandleX,mData->mTrackStartPoint - deltaY - |
|
1237 mData->mHandleGhostHieghtDelta/2); |
|
1238 // Set the position |
|
1239 mData->mSliderHandle->SetPos(pnt,0); |
|
1240 mData->mSliderHandleGhost->SetPos(pnt1,0); |
|
1241 // Update visualization variables |
|
1242 mData->mCurrTick = mSliderModel->PrimaryValue(); |
|
1243 //mData->mMainLayout->UpdateChildrenLayout(0); |
|
1244 |
|
1245 } |
|
1246 // --------------------------------------------------------------------------- |
|
1247 // SetTextLabels |
|
1248 // --------------------------------------------------------------------------- |
|
1249 // |
|
1250 void MulSliderVertical::SetTextLabels(const char* /*aStr*/) |
|
1251 { |
|
1252 } |
|
1253 |
|
1254 // --------------------------------------------------------------------------- |
|
1255 // accept |
|
1256 // --------------------------------------------------------------------------- |
|
1257 // |
|
1258 bool MulSliderVertical::accept( CAlfWidgetControl& /*aControl*/, const TAlfEvent& aEvent ) const |
|
1259 { |
|
1260 // Accept only key or pointer events. |
|
1261 if(aEvent.IsKeyEvent()||aEvent.IsPointerEvent()) |
|
1262 { |
|
1263 return true; |
|
1264 } |
|
1265 else |
|
1266 { |
|
1267 return false; |
|
1268 } |
|
1269 } |
|
1270 |
|
1271 |
|
1272 // --------------------------------------------------------------------------- |
|
1273 // initializeThumbDragData |
|
1274 // --------------------------------------------------------------------------- |
|
1275 // |
|
1276 bool MulSliderVertical::initializeThumbDragData(const TPoint& aPointerPos) |
|
1277 { |
|
1278 TRAPD(err,control().Display()->Roster().SetPointerDragThreshold(control(), |
|
1279 TAlfXYMetric(TAlfMetric(KXToleranceInPixel,EAlfUnitPixel), |
|
1280 TAlfMetric(KYToleranceInPixel,EAlfUnitPixel))) ); |
|
1281 if(mData->mVisual && err == KErrNone) |
|
1282 { |
|
1283 mData->mOperation = EMoveItem; |
|
1284 mData->mDragPoint = aPointerPos; |
|
1285 mData->mDragStartStep = mSliderModel->PrimaryValue(); |
|
1286 } |
|
1287 else |
|
1288 { |
|
1289 |
|
1290 } |
|
1291 return ETrue; |
|
1292 } |
|
1293 |
|
1294 // --------------------------------------------------------------------------- |
|
1295 // stopDrag |
|
1296 // Stop Dragging |
|
1297 // --------------------------------------------------------------------------- |
|
1298 // |
|
1299 bool MulSliderVertical::stopDrag() |
|
1300 { |
|
1301 |
|
1302 TRAPD(err, |
|
1303 control().Display()->Roster().SetPointerEventObservers( |
|
1304 0, |
|
1305 control())); |
|
1306 if(err == KErrNone) |
|
1307 { |
|
1308 mData->mVisual = NULL; |
|
1309 mData->mOperation = ENop; |
|
1310 return ETrue; |
|
1311 } |
|
1312 return EFalse; |
|
1313 } |
|
1314 |
|
1315 |
|
1316 // --------------------------------------------------------------------------- |
|
1317 // IsSliderVisual |
|
1318 // --------------------------------------------------------------------------- |
|
1319 // |
|
1320 bool MulSliderVertical::IsSliderVisual(CAlfVisual *aVisual) |
|
1321 { |
|
1322 if(aVisual == mData->mSliderCentre|| |
|
1323 aVisual == mData->mSliderCentreGhost|| |
|
1324 aVisual == mData->mSliderHandle|| |
|
1325 aVisual == mData->mSliderHandleGhost|| |
|
1326 aVisual == mData->mImagePlus|| |
|
1327 aVisual == mData->mImageMinus) |
|
1328 { |
|
1329 return true; |
|
1330 } |
|
1331 return false; |
|
1332 } |
|
1333 |
|
1334 // --------------------------------------------------------------------------- |
|
1335 // updateTextVisualization |
|
1336 // --------------------------------------------------------------------------- |
|
1337 // |
|
1338 void MulSliderVertical::updateTextVisualization() |
|
1339 {/* |
|
1340 MulSliderModel* sliderModel = mSliderModel; |
|
1341 const char* perctext = sliderModel->GetPercentText(); |
|
1342 SetTextLabels(perctext);*/ |
|
1343 } |
|
1344 }//namespace Alf |
|
1345 |
|
1346 //End Of File |
|