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: Active Palette 2 Model* |
|
15 */ |
|
16 |
|
17 |
|
18 /** |
|
19 * @file ActivePalette2Model.cpp |
|
20 * Active Palette 2 Model |
|
21 */ |
|
22 |
|
23 // INCLUDE FILES |
|
24 #include <activepalette2eventdata.h> |
|
25 #include <activepalette2observer.h> |
|
26 #include <activepalette2itemvisible.h> |
|
27 #include <activepalette2genericpluginint.h> |
|
28 |
|
29 #include "ActivePalette2Item.h" |
|
30 #include "ActivePalette2Model.h" |
|
31 #include "ActivePalette2ModelObserver.h" |
|
32 #include "ActivePalette2Logger.h" |
|
33 #include "ActivePalette2Cfg.h" |
|
34 #include "activepalette2configuration.h" |
|
35 #include "ActivePalette2Utils.h" |
|
36 |
|
37 |
|
38 // ----------------------------------------------------------------------------- |
|
39 // TRendererCallBacks::TRendererCallBacks() |
|
40 // ----------------------------------------------------------------------------- |
|
41 // |
|
42 TRendererCallBacks::TRendererCallBacks() |
|
43 : iTooltipTimer(NULL), |
|
44 iFocusTimer(NULL), |
|
45 iItemScrollTimer(NULL), |
|
46 iAppearanceTimer(NULL), |
|
47 iTooltipDescriptive(NULL), |
|
48 iFocusDescriptive(NULL), |
|
49 iItemScrollDescriptive(NULL), |
|
50 iAppearanceDescriptive(NULL) |
|
51 { |
|
52 // no implementation needed |
|
53 } |
|
54 |
|
55 |
|
56 |
|
57 |
|
58 // ================= MEMBER FUNCTIONS ======================= |
|
59 |
|
60 // ----------------------------------------------------------------------------- |
|
61 // CActivePalette2Model::NewL() |
|
62 // 2 phase construction |
|
63 // ----------------------------------------------------------------------------- |
|
64 // |
|
65 CActivePalette2Model* CActivePalette2Model::NewL( |
|
66 MActivePalette2ModelObserver& aModelObserver, |
|
67 TSize aItemSize, |
|
68 const TRendererCallBacks& aCallbacks, |
|
69 CActivePalette2Configuration* aConfiguration /*=NULL*/ ) |
|
70 { |
|
71 CActivePalette2Model * self = |
|
72 new (ELeave) CActivePalette2Model( aModelObserver, |
|
73 aItemSize, |
|
74 aCallbacks, |
|
75 aConfiguration ); |
|
76 CleanupStack::PushL(self); |
|
77 self->ConstructL(); |
|
78 CleanupStack::Pop(); // this |
|
79 return self; |
|
80 } |
|
81 |
|
82 // ----------------------------------------------------------------------------- |
|
83 // CActivePalette2Model::CActivePalette2Model() |
|
84 // C++ Constuctor |
|
85 // ----------------------------------------------------------------------------- |
|
86 // |
|
87 CActivePalette2Model::CActivePalette2Model( |
|
88 MActivePalette2ModelObserver& aModelObserver, |
|
89 TSize aItemSize, |
|
90 const TRendererCallBacks& aCallbacks, |
|
91 CActivePalette2Configuration* aConfiguration ) |
|
92 : iPreviousItemID(KInvalidId), |
|
93 iFocusedItemID(KInvalidId), |
|
94 iPaletteMoveCurrentOffset(0), |
|
95 iPaletteMoveOffsetTotalFrames(NAP2Cfg::KPaletteAppearFrames), |
|
96 iPaletteMoveAnimationDuration(NAP2Cfg::KPaletteAppearTotalTime / KMicrosecondsPerMillisecond), |
|
97 iAnimState(EPaletteAnimIdle), |
|
98 iCallbacks(aCallbacks), |
|
99 iModelObserver(aModelObserver), |
|
100 iItemSize(aItemSize), |
|
101 iTooltipConfig() |
|
102 { |
|
103 LOGTEXT( _L( "CActivePalette2Model::CActivePalette2Model entered" )); |
|
104 if( aConfiguration ) |
|
105 { |
|
106 aConfiguration->TooltipConfiguration( iTooltipConfig ); |
|
107 } |
|
108 else |
|
109 { |
|
110 iTooltipConfig.iPreshowDelay = NAP2Cfg::KTooltipPreshowDelay; |
|
111 iTooltipConfig.iFullshowPeriod = NAP2Cfg::KTooltipFullshowPeriod; |
|
112 iTooltipConfig.iTimerTickLength = NAP2Cfg::KTooltipTimerTickLength; |
|
113 iTooltipConfig.iTransitionSpeed = NAP2Cfg::KTooltipShowSpeed; |
|
114 iTooltipConfig.iTransitionFrames = KErrNotSupported; |
|
115 } |
|
116 LOGTEXT( _L( "CActivePalette2Model::CActivePalette2Model left" )); |
|
117 } |
|
118 |
|
119 |
|
120 // ----------------------------------------------------------------------------- |
|
121 // CActivePalette2Model::ConstructL(void) |
|
122 // 2nd phase constructor |
|
123 // ----------------------------------------------------------------------------- |
|
124 // |
|
125 void CActivePalette2Model::ConstructL(void) |
|
126 { |
|
127 iTooltipTimer = CPeriodic::NewL(CActive::EPriorityHigh); // high priority for smooth animation |
|
128 iFocusChangeTimer = CPeriodic::NewL(CActive::EPriorityHigh); |
|
129 iItemScrollTimer = CPeriodic::NewL(CActive::EPriorityHigh); |
|
130 iItemAnimTimer = CPeriodic::NewL(CActive::EPriorityHigh); |
|
131 iPaletteMoveTimer = CPeriodic::NewL(CActive::EPriorityHigh); |
|
132 } |
|
133 |
|
134 // ----------------------------------------------------------------------------- |
|
135 // CActivePalette2Model::~CActivePalette2Model() |
|
136 // Destructor |
|
137 // ----------------------------------------------------------------------------- |
|
138 // |
|
139 CActivePalette2Model::~CActivePalette2Model() |
|
140 { |
|
141 LOGTEXT( _L( "CActivePalette2Model::~CActivePalette2Model entered" )); |
|
142 |
|
143 if (iTooltipTimer) |
|
144 { |
|
145 iTooltipTimer->Cancel(); |
|
146 delete iTooltipTimer; |
|
147 } |
|
148 |
|
149 if (iFocusChangeTimer) |
|
150 { |
|
151 iFocusChangeTimer->Cancel(); |
|
152 delete iFocusChangeTimer; |
|
153 } |
|
154 |
|
155 if (iItemScrollTimer) |
|
156 { |
|
157 iItemScrollTimer->Cancel(); |
|
158 delete iItemScrollTimer; |
|
159 } |
|
160 |
|
161 if (iItemAnimTimer) |
|
162 { |
|
163 iItemAnimTimer->Cancel(); |
|
164 delete iItemAnimTimer; |
|
165 } |
|
166 |
|
167 if (iPaletteMoveTimer) |
|
168 { |
|
169 iPaletteMoveTimer->Cancel(); |
|
170 delete iPaletteMoveTimer; |
|
171 } |
|
172 |
|
173 iItemsArray.ResetAndDestroy(); |
|
174 iItemsArray.Close(); |
|
175 iVisibilityArray.Reset(); |
|
176 iVisibilityArray.Close(); |
|
177 |
|
178 LOGTEXT( _L( "CActivePalette2Model::~CActivePalette2Model left" )); |
|
179 } |
|
180 |
|
181 |
|
182 // ----------------------------------------------------------------------------- |
|
183 // CActivePalette2Model::FindItem() |
|
184 // item data management |
|
185 // ----------------------------------------------------------------------------- |
|
186 // |
|
187 CActivePalette2Item* CActivePalette2Model::FindItem(const TInt aItemId) const |
|
188 { |
|
189 TInt index = ItemIndexFromId(aItemId); |
|
190 |
|
191 if ( ValidItemIndex(index) ) |
|
192 { |
|
193 return static_cast<CActivePalette2Item *>(iItemsArray[index]); |
|
194 } |
|
195 else |
|
196 { |
|
197 return NULL; |
|
198 } |
|
199 } |
|
200 |
|
201 // ----------------------------------------------------------------------------- |
|
202 // CActivePalette2Model::DoInstallItemL() |
|
203 // ----------------------------------------------------------------------------- |
|
204 // |
|
205 TInt CActivePalette2Model::DoInstallItemL(TInt aItemId, |
|
206 TBool aVisible, |
|
207 const TUid& aPluginUid, |
|
208 const TDesC8& aCustomDataDes, |
|
209 TInt aCustomDataInt) |
|
210 { |
|
211 // check if item ID is unique |
|
212 if ( ItemIndexFromId(aItemId) != KInvalidItemIndex ) |
|
213 { |
|
214 return KErrArgument; |
|
215 } |
|
216 |
|
217 // item and plugin instantiate |
|
218 CActivePalette2Item* item = CActivePalette2Item::NewLC(aItemId,aPluginUid, *this); |
|
219 |
|
220 item->InitPluginL(aCustomDataDes, aCustomDataInt); |
|
221 |
|
222 User::LeaveIfError(iItemsArray.Append(item)); |
|
223 User::LeaveIfError(iVisibilityArray.Append(aVisible)); |
|
224 |
|
225 CleanupStack::Pop(item); |
|
226 |
|
227 if ( aVisible ) |
|
228 { |
|
229 EnforceConstraints(); |
|
230 } |
|
231 |
|
232 return KErrNone; |
|
233 } |
|
234 |
|
235 // ----------------------------------------------------------------------------- |
|
236 // CActivePalette2Model::RemoveItem() |
|
237 // ----------------------------------------------------------------------------- |
|
238 // |
|
239 TInt CActivePalette2Model::RemoveItem(const TInt aItemId) |
|
240 { |
|
241 LOGTEXT1( _L( "CActivePalette2Model::RemoveItem entered, Item ID: %d" ), |
|
242 aItemId); |
|
243 |
|
244 TInt res(KErrNone); |
|
245 |
|
246 CActivePalette2Item* item = FindItem(aItemId); |
|
247 TInt index = ItemIndexFromId(aItemId); |
|
248 |
|
249 if (item) // valid item |
|
250 { |
|
251 iItemsArray.Remove(index); // unregister |
|
252 iVisibilityArray.Remove(index); |
|
253 |
|
254 // destroy item |
|
255 CBase::Delete(item); // implies plugin shutodown and DLL unload |
|
256 |
|
257 EnforceConstraints(); |
|
258 } |
|
259 else |
|
260 { |
|
261 res = KErrArgument; |
|
262 } |
|
263 |
|
264 LOGTEXT1( _L( "CActivePalette2Model::RemoveItem left, res %d" ), res); |
|
265 |
|
266 return res; |
|
267 } |
|
268 |
|
269 // ----------------------------------------------------------------------------- |
|
270 // CActivePalette2Model::HandleItemSelected() |
|
271 // ----------------------------------------------------------------------------- |
|
272 // |
|
273 void CActivePalette2Model::HandleItemSelected(const TInt aItemIndex) |
|
274 { |
|
275 LOGTEXT1( _L( "CActivePalette2Model::HandleItemSelected entered, Item ID: %d" ), |
|
276 aItemIndex); |
|
277 |
|
278 if ( ValidItemIndex(aItemIndex) ) |
|
279 { |
|
280 CActivePalette2Item* item = iItemsArray[aItemIndex]; |
|
281 if (item) |
|
282 { |
|
283 TInt err; |
|
284 |
|
285 LOGTEXT( _L( "... calling plugin's HandleItemSelectedL" )); |
|
286 |
|
287 TRAP(err, item->Plugin().HandleItemSelectedL()); |
|
288 |
|
289 LOGTEXT1( _L( "... res : %d" ), err); |
|
290 |
|
291 if (KErrNone != err) |
|
292 { |
|
293 // leave during item selection handling, invoke callback now |
|
294 NotifyItemComplete(*item, err, KNullDesC8, KActivePaletteNoDataInt); |
|
295 } |
|
296 } |
|
297 else |
|
298 { |
|
299 LOGTEXT( _L( "... INTERNAL FAULT: item object not found" )); |
|
300 } |
|
301 } |
|
302 |
|
303 LOGTEXT( _L( "CActivePalette2Model::HandleItemSelected left" )); |
|
304 } |
|
305 |
|
306 // ----------------------------------------------------------------------------- |
|
307 // CActivePalette2Model::DispatchMessage() |
|
308 // ----------------------------------------------------------------------------- |
|
309 // |
|
310 TInt CActivePalette2Model::DispatchMessage(const TInt aItemId, const TInt aMessageID, const TDesC8& aDataDes, const TInt aDataInt) |
|
311 { |
|
312 LOGTEXT2( _L( "CActivePalette2Model::DispatchMessgage entered, Item ID: %d, Message ID : %d" ), |
|
313 aItemId, aMessageID); |
|
314 |
|
315 TInt res; |
|
316 CActivePalette2Item* item = FindItem(aItemId); |
|
317 if (item) |
|
318 { |
|
319 TInt err; |
|
320 |
|
321 LOGTEXT( _L( "...calling plugin's HandleMessageL" )); |
|
322 |
|
323 TRAP(err, item->Plugin().HandleMessageL(aMessageID, aDataDes, aDataInt)); |
|
324 |
|
325 LOGTEXT1( _L( "... res : %d" ), err); |
|
326 |
|
327 res = err; // retransmit error code |
|
328 } |
|
329 else |
|
330 { |
|
331 res = KErrArgument; |
|
332 } |
|
333 |
|
334 LOGTEXT1( _L( "CActivePalette2Model::DispatchMessgage left, res %d" ), res); |
|
335 |
|
336 return res; |
|
337 } |
|
338 |
|
339 // ----------------------------------------------------------------------------- |
|
340 // CActivePalette2Model::Observer() |
|
341 // ----------------------------------------------------------------------------- |
|
342 // |
|
343 MActivePalette2ModelObserver& CActivePalette2Model::Observer(void) const |
|
344 { |
|
345 return iModelObserver; |
|
346 } |
|
347 |
|
348 // ----------------------------------------------------------------------------- |
|
349 // CActivePalette2Model::ItemIndexFromId() |
|
350 // ----------------------------------------------------------------------------- |
|
351 // |
|
352 TInt CActivePalette2Model::ItemIndexFromId(const TInt aItemId) const |
|
353 { |
|
354 TInt res = KInvalidItemIndex; |
|
355 TInt currentItemIndex = 0; |
|
356 |
|
357 while ( res == KInvalidItemIndex && ValidItemIndex(currentItemIndex) ) |
|
358 { |
|
359 if ( iItemsArray[currentItemIndex]->ItemId() == aItemId ) |
|
360 { |
|
361 res = currentItemIndex; |
|
362 } |
|
363 else |
|
364 { |
|
365 currentItemIndex++; |
|
366 } |
|
367 } |
|
368 |
|
369 return res; |
|
370 } |
|
371 |
|
372 |
|
373 |
|
374 |
|
375 |
|
376 // ----------------------------------------------------------------------------- |
|
377 // CActivePalette2Model::TooltipText() |
|
378 // ----------------------------------------------------------------------------- |
|
379 // |
|
380 TDesC* CActivePalette2Model::TooltipText() |
|
381 { |
|
382 if ( ValidItemIndex(iFocusedItem) ) |
|
383 { |
|
384 CActivePalette2Item& api = static_cast<CActivePalette2Item &> (*iItemsArray[iFocusedItem]); |
|
385 return api.Tooltip(); |
|
386 } |
|
387 else |
|
388 { |
|
389 return NULL; |
|
390 } |
|
391 } |
|
392 |
|
393 // ----------------------------------------------------------------------------- |
|
394 // CActivePalette2Model::ShowTooltip() |
|
395 // ----------------------------------------------------------------------------- |
|
396 // |
|
397 TBool CActivePalette2Model::ShowTooltip() |
|
398 { |
|
399 return iShowTooltip; |
|
400 } |
|
401 |
|
402 // ----------------------------------------------------------------------------- |
|
403 // CActivePalette2Model::TooltipCurrentFrame() |
|
404 // ----------------------------------------------------------------------------- |
|
405 // |
|
406 TInt CActivePalette2Model::TooltipCurrentFrame() |
|
407 { |
|
408 return iTooltipCurrentFrame; |
|
409 } |
|
410 |
|
411 // ----------------------------------------------------------------------------- |
|
412 // CActivePalette2Model::TooltipTotalFrames() |
|
413 // ----------------------------------------------------------------------------- |
|
414 // |
|
415 TInt CActivePalette2Model::TooltipTotalFrames() |
|
416 { |
|
417 return iTooltipTotalFrames; |
|
418 } |
|
419 |
|
420 // ----------------------------------------------------------------------------- |
|
421 // CActivePalette2Model::TooltipScreenPosition() |
|
422 // ----------------------------------------------------------------------------- |
|
423 // |
|
424 TInt CActivePalette2Model::TooltipScreenPosition() |
|
425 { |
|
426 return FocusedItem(); |
|
427 } |
|
428 |
|
429 // ----------------------------------------------------------------------------- |
|
430 // CActivePalette2Model::CompelTooltip() |
|
431 // ----------------------------------------------------------------------------- |
|
432 // |
|
433 void CActivePalette2Model::CompelTooltip() |
|
434 { |
|
435 TInt tooltip_width = iModelObserver.TooltipUpdated(); |
|
436 |
|
437 if( iTooltipConfig.iTransitionFrames > 0 ) |
|
438 iTooltipTotalFrames = iTooltipConfig.iTransitionFrames; |
|
439 else |
|
440 iTooltipTotalFrames = tooltip_width / iTooltipConfig.iTransitionSpeed; |
|
441 |
|
442 TooltipSetState( ETooltipRise ); |
|
443 } |
|
444 |
|
445 // ----------------------------------------------------------------------------- |
|
446 // CActivePalette2Tooltip::RemoveTooltip(void) |
|
447 // ----------------------------------------------------------------------------- |
|
448 // |
|
449 void CActivePalette2Model::RemoveTooltip(void) |
|
450 { |
|
451 TooltipSetState(ETooltipNone); |
|
452 } |
|
453 |
|
454 // ----------------------------------------------------------------------------- |
|
455 // CActivePalette2Tooltip::TooltipSteadyAniAction() |
|
456 // ----------------------------------------------------------------------------- |
|
457 // |
|
458 TInt CActivePalette2Model::TooltipSteadyAniAction(void) |
|
459 { |
|
460 // start shrinking |
|
461 TooltipSetState(ETooltipSet); |
|
462 return KCallbackFinished; |
|
463 } |
|
464 |
|
465 // ----------------------------------------------------------------------------- |
|
466 // CActivePalette2Tooltip::TooltipRiseAniAction() |
|
467 // ----------------------------------------------------------------------------- |
|
468 // |
|
469 TInt CActivePalette2Model::TooltipRiseAniAction(void) |
|
470 { |
|
471 TInt res = KCallbackFinished; |
|
472 |
|
473 iShowTooltip = ETrue; |
|
474 |
|
475 if ( iCallbacks.iTooltipTimer ) |
|
476 { |
|
477 if (iTooltipCurrentFrame >= iTooltipTotalFrames) |
|
478 { |
|
479 TooltipSetState(ETooltipSteady); |
|
480 } |
|
481 else |
|
482 { |
|
483 res = KCallbackCallAgain; |
|
484 iTooltipCurrentFrame++; |
|
485 } |
|
486 |
|
487 iCallbacks.iTooltipTimer->TooltipAnimated(); |
|
488 } |
|
489 else if ( iCallbacks.iTooltipDescriptive ) |
|
490 { |
|
491 TInt duration( (iTooltipTotalFrames*iTooltipConfig.iTimerTickLength) / KMicrosecondsPerMillisecond ); |
|
492 iCallbacks.iTooltipDescriptive->AnimateTooltip( ETrue, duration ); |
|
493 iTooltipTimer->Cancel(); |
|
494 } |
|
495 else |
|
496 { |
|
497 // just for Lint. |
|
498 } |
|
499 |
|
500 return res; |
|
501 } |
|
502 |
|
503 // ----------------------------------------------------------------------------- |
|
504 // CActivePalette2Tooltip::TooltipDisappearAniAction() |
|
505 // ----------------------------------------------------------------------------- |
|
506 // |
|
507 TInt CActivePalette2Model::TooltipDisappearAniAction(void) |
|
508 { |
|
509 TInt res = KCallbackFinished; |
|
510 |
|
511 if ( iCallbacks.iTooltipTimer ) |
|
512 { |
|
513 if (iTooltipCurrentFrame <= 0) |
|
514 { |
|
515 TooltipSetState(ETooltipNone); |
|
516 } |
|
517 else |
|
518 { |
|
519 res = KCallbackCallAgain; |
|
520 iTooltipCurrentFrame--; |
|
521 } |
|
522 |
|
523 if ( iCallbacks.iTooltipTimer ) |
|
524 { |
|
525 iCallbacks.iTooltipTimer->TooltipAnimated(); |
|
526 } |
|
527 } |
|
528 else if ( iCallbacks.iTooltipDescriptive ) |
|
529 { |
|
530 TInt duration( (iTooltipTotalFrames*iTooltipConfig.iTimerTickLength) / KMicrosecondsPerMillisecond ); |
|
531 iCallbacks.iTooltipDescriptive->AnimateTooltip( EFalse, duration ); |
|
532 iTooltipTimer->Cancel(); |
|
533 } |
|
534 else |
|
535 { |
|
536 // just for Lint. |
|
537 } |
|
538 |
|
539 return res; |
|
540 } |
|
541 |
|
542 // ----------------------------------------------------------------------------- |
|
543 // CActivePalette2Tooltip::TooltipTimerCallback() |
|
544 // ----------------------------------------------------------------------------- |
|
545 // |
|
546 TInt CActivePalette2Model::TooltipTimerCallback(TAny* aPtr) |
|
547 { |
|
548 CActivePalette2Model* self = (CActivePalette2Model*) aPtr; |
|
549 TInt res = KCallbackFinished; |
|
550 |
|
551 switch (self->iTooltipState) |
|
552 { |
|
553 case ETooltipSteady: |
|
554 res = self->TooltipSteadyAniAction(); |
|
555 break; |
|
556 |
|
557 case ETooltipRise: |
|
558 res = self->TooltipRiseAniAction(); |
|
559 break; |
|
560 |
|
561 case ETooltipSet: |
|
562 res = self->TooltipDisappearAniAction(); |
|
563 break; |
|
564 |
|
565 default: |
|
566 break; |
|
567 } |
|
568 |
|
569 return res; |
|
570 } |
|
571 |
|
572 // ----------------------------------------------------------------------------- |
|
573 // CActivePalette2Tooltip::TooltipSetState() |
|
574 // ----------------------------------------------------------------------------- |
|
575 // |
|
576 void CActivePalette2Model::TooltipSetState(TTooltipState aState) |
|
577 { |
|
578 iTooltipTimer->Cancel(); |
|
579 TBool isOk = ETrue; |
|
580 |
|
581 switch (aState) |
|
582 { |
|
583 case ETooltipNone: |
|
584 iTooltipTimer->Cancel(); |
|
585 if ( iShowTooltip || iTooltipCurrentFrame > 0 ) |
|
586 { |
|
587 iShowTooltip = EFalse; |
|
588 iTooltipCurrentFrame = 0; |
|
589 iModelObserver.ShowTooltipUpdated(); |
|
590 } |
|
591 break; |
|
592 |
|
593 case ETooltipSteady: |
|
594 iTooltipTimer->Start( |
|
595 iTooltipConfig.iFullshowPeriod, |
|
596 iTooltipConfig.iFullshowPeriod, |
|
597 TCallBack(&CActivePalette2Model::TooltipTimerCallback,(TAny *)this)); |
|
598 break; |
|
599 |
|
600 case ETooltipRise: |
|
601 iTooltipCurrentFrame = 0; |
|
602 iTooltipTimer->Start( |
|
603 iTooltipConfig.iPreshowDelay, |
|
604 iTooltipConfig.iTimerTickLength, |
|
605 TCallBack(&CActivePalette2Model::TooltipTimerCallback,(TAny *)this)); |
|
606 break; |
|
607 |
|
608 case ETooltipSet: |
|
609 // iTooltipCurrentFrame = 0; |
|
610 iTooltipTimer->Start( |
|
611 iTooltipConfig.iTimerTickLength, |
|
612 iTooltipConfig.iTimerTickLength, |
|
613 TCallBack(&CActivePalette2Model::TooltipTimerCallback,(TAny *)this)); |
|
614 break; |
|
615 |
|
616 default: |
|
617 isOk = EFalse; |
|
618 break; |
|
619 } |
|
620 |
|
621 if (isOk) |
|
622 { |
|
623 iTooltipState = aState; |
|
624 } |
|
625 } |
|
626 |
|
627 // ----------------------------------------------------------------------------- |
|
628 // CActivePalette2Model::FocusChangeComplete() |
|
629 // ----------------------------------------------------------------------------- |
|
630 // |
|
631 void CActivePalette2Model::AnimateTooltipRendererComplete() |
|
632 { |
|
633 switch (iTooltipState) |
|
634 { |
|
635 case ETooltipRise: |
|
636 TooltipSetState(ETooltipSteady); |
|
637 break; |
|
638 |
|
639 case ETooltipSet: |
|
640 TooltipSetState(ETooltipNone); |
|
641 break; |
|
642 |
|
643 default: |
|
644 case ETooltipNone: |
|
645 case ETooltipSteady: |
|
646 break; |
|
647 } |
|
648 } |
|
649 |
|
650 |
|
651 // ----------------------------------------------------------------------------- |
|
652 // CActivePalette2Model::CountItemsOnScreen() |
|
653 // ----------------------------------------------------------------------------- |
|
654 // |
|
655 TInt CActivePalette2Model::CountItemsOnScreen(void) |
|
656 { |
|
657 return iNoItemsOnScreen; |
|
658 } |
|
659 |
|
660 // ----------------------------------------------------------------------------- |
|
661 // CActivePalette2Model::ShowTopScrollIndicator() |
|
662 // ----------------------------------------------------------------------------- |
|
663 // |
|
664 TBool CActivePalette2Model::ShowTopScrollIndicator(void) |
|
665 { |
|
666 return iShowTopScrollArrow; |
|
667 } |
|
668 |
|
669 // ----------------------------------------------------------------------------- |
|
670 // CActivePalette2Model::ShowBottomScrollIndicator() |
|
671 // ----------------------------------------------------------------------------- |
|
672 // |
|
673 TBool CActivePalette2Model::ShowBottomScrollIndicator(void) |
|
674 { |
|
675 return iShowBottomScrollArrow; |
|
676 } |
|
677 |
|
678 // ----------------------------------------------------------------------------- |
|
679 // CActivePalette2Model::InitialiseConstraints() |
|
680 // ----------------------------------------------------------------------------- |
|
681 // |
|
682 void CActivePalette2Model::InitialiseConstraints(void) |
|
683 { |
|
684 iTopItemOnScreen = FindVisibleItem(0); |
|
685 |
|
686 iFocusedItem = iTopItemOnScreen; |
|
687 |
|
688 iNoVisibleItems = CountVisibleItems(0); |
|
689 |
|
690 iNoItemsOnScreen = Min(NAP2Cfg::KMaxNofItemsInView, iNoVisibleItems); |
|
691 } |
|
692 |
|
693 // ----------------------------------------------------------------------------- |
|
694 // CActivePalette2Model::EnforceConstraints() |
|
695 // ----------------------------------------------------------------------------- |
|
696 // |
|
697 void CActivePalette2Model::EnforceConstraints(void) |
|
698 { |
|
699 CompleteAnyItemBasedAnimations(); |
|
700 |
|
701 iNoVisibleItems = CountVisibleItems(0); |
|
702 |
|
703 iNoItemsOnScreen = Min(NAP2Cfg::KMaxNofItemsInView, iNoVisibleItems); |
|
704 |
|
705 iTopItemOnScreen = FindVisibleItem(iTopItemOnScreen); |
|
706 |
|
707 if(CountVisibleItems(iTopItemOnScreen) < iNoItemsOnScreen) |
|
708 { |
|
709 iTopItemOnScreen = FindVisibleItem(0); |
|
710 |
|
711 if ( iNoVisibleItems > iNoItemsOnScreen ) |
|
712 { |
|
713 while ( CountVisibleItems(iTopItemOnScreen) < iNoItemsOnScreen ) |
|
714 { |
|
715 iTopItemOnScreen = FindVisibleItem(iTopItemOnScreen + 1); |
|
716 } |
|
717 } |
|
718 } |
|
719 |
|
720 if ( iNoVisibleItems > 0 ) |
|
721 { |
|
722 if ( iFocusedItem < 0 ) |
|
723 { |
|
724 iFocusedItem = FindVisibleItem(0); |
|
725 } |
|
726 |
|
727 if ( iFocusedItem >= iItemsArray.Count() ) |
|
728 { |
|
729 iFocusedItem = PreviousVisibleItem(iItemsArray.Count() - 1); |
|
730 } |
|
731 |
|
732 if ( ValidItemIndex(iFocusedItem) ) |
|
733 { |
|
734 if ( !iVisibilityArray[iFocusedItem] ) |
|
735 { |
|
736 TInt previousFocusedItem = iFocusedItem; |
|
737 |
|
738 iFocusedItem = FindVisibleItem(iFocusedItem); |
|
739 |
|
740 if ( iFocusedItem == KInvalidItemIndex ) |
|
741 { |
|
742 iFocusedItem = PreviousVisibleItem(previousFocusedItem); |
|
743 } |
|
744 |
|
745 if ( iFocusedItem == KInvalidItemIndex ) |
|
746 { |
|
747 iFocusedItem = FindVisibleItem(0); |
|
748 } |
|
749 } |
|
750 } |
|
751 |
|
752 if ( iFocusedItem < iTopItemOnScreen ) |
|
753 { |
|
754 iTopItemOnScreen = iFocusedItem; |
|
755 } |
|
756 else |
|
757 { |
|
758 while ( iFocusedItem > BottomItemOnScreen() ) |
|
759 { |
|
760 iTopItemOnScreen = FindVisibleItem(iTopItemOnScreen + 1); |
|
761 } |
|
762 } |
|
763 } |
|
764 else |
|
765 { |
|
766 iFocusedItem = KInvalidItemIndex; |
|
767 } |
|
768 |
|
769 ItemsUpdated(); |
|
770 FocusedItemUpdated(); |
|
771 } |
|
772 |
|
773 // ----------------------------------------------------------------------------- |
|
774 // CActivePalette2Model::CompleteAnyItemBasedAnimations() |
|
775 // ----------------------------------------------------------------------------- |
|
776 // |
|
777 void CActivePalette2Model::CompleteAnyItemBasedAnimations() |
|
778 { |
|
779 switch (iAnimState) |
|
780 { |
|
781 case EPaletteAnimItemScroll: |
|
782 case EPaletteAnimFocusChange: |
|
783 case EPaletteAnimItemAnim: |
|
784 SetAnimState(EPaletteAnimIdle); |
|
785 break; |
|
786 |
|
787 default: |
|
788 // do nothing |
|
789 break; |
|
790 } |
|
791 } |
|
792 |
|
793 // ----------------------------------------------------------------------------- |
|
794 // CActivePalette2Model::BottomItemOnScreen() |
|
795 // ----------------------------------------------------------------------------- |
|
796 // |
|
797 TInt CActivePalette2Model::BottomItemOnScreen(void) |
|
798 { |
|
799 TInt bottomItemOnScreen = iTopItemOnScreen; |
|
800 |
|
801 for(TInt i = 1; i < iNoItemsOnScreen; i++) |
|
802 { |
|
803 bottomItemOnScreen = FindVisibleItem(bottomItemOnScreen + 1); |
|
804 } |
|
805 |
|
806 return bottomItemOnScreen; |
|
807 } |
|
808 |
|
809 // ----------------------------------------------------------------------------- |
|
810 // CActivePalette2Model::FindVisibleItem() |
|
811 // ----------------------------------------------------------------------------- |
|
812 // |
|
813 TInt CActivePalette2Model::FindVisibleItem(TInt aStartingItem) |
|
814 { |
|
815 TInt result = KInvalidItemIndex; |
|
816 TInt currentItem = aStartingItem; |
|
817 TBool found = EFalse; |
|
818 TInt arraySize = iVisibilityArray.Count(); |
|
819 |
|
820 if ( aStartingItem != KInvalidItemIndex ) |
|
821 { |
|
822 while(!found && currentItem < arraySize) |
|
823 { |
|
824 if(iVisibilityArray[currentItem]) |
|
825 { |
|
826 result = currentItem; |
|
827 found = ETrue; |
|
828 } |
|
829 else |
|
830 { |
|
831 currentItem++; |
|
832 } |
|
833 } |
|
834 } |
|
835 |
|
836 return result; |
|
837 } |
|
838 |
|
839 // ----------------------------------------------------------------------------- |
|
840 // CActivePalette2Model::PreviousVisibleItem() |
|
841 // ----------------------------------------------------------------------------- |
|
842 // |
|
843 TInt CActivePalette2Model::PreviousVisibleItem(TInt aStartingItem) |
|
844 { |
|
845 TInt result = KInvalidItemIndex; |
|
846 TInt currentItem = aStartingItem; |
|
847 TBool found = EFalse; |
|
848 |
|
849 if ( aStartingItem != KInvalidItemIndex ) |
|
850 { |
|
851 while(!found && currentItem >= 0) |
|
852 { |
|
853 if(iVisibilityArray[currentItem]) |
|
854 { |
|
855 result = currentItem; |
|
856 found = ETrue; |
|
857 } |
|
858 else |
|
859 { |
|
860 currentItem--; |
|
861 } |
|
862 } |
|
863 } |
|
864 |
|
865 return result; |
|
866 } |
|
867 |
|
868 // ----------------------------------------------------------------------------- |
|
869 // CActivePalette2Model::CountVisibleItems() |
|
870 // ----------------------------------------------------------------------------- |
|
871 // |
|
872 TInt CActivePalette2Model::CountVisibleItems(TInt aStartingItem) |
|
873 { |
|
874 TInt result = 0; |
|
875 TInt currentItem = aStartingItem; |
|
876 TInt arraySize = iVisibilityArray.Count(); |
|
877 |
|
878 if ( aStartingItem != KInvalidItemIndex ) |
|
879 { |
|
880 while(currentItem < arraySize) |
|
881 { |
|
882 if(iVisibilityArray[currentItem]) |
|
883 { |
|
884 result++; |
|
885 } |
|
886 currentItem++; |
|
887 } |
|
888 } |
|
889 else |
|
890 { |
|
891 result = KInvalidItemIndex; |
|
892 } |
|
893 |
|
894 return result; |
|
895 } |
|
896 |
|
897 // ----------------------------------------------------------------------------- |
|
898 // CActivePalette2Model::ItemIndexFromScreenPos() |
|
899 // ----------------------------------------------------------------------------- |
|
900 // |
|
901 TInt CActivePalette2Model::ItemIndexFromScreenPos(TInt aScreenPos) |
|
902 { |
|
903 TInt result = KInvalidItemIndex; |
|
904 |
|
905 if ( aScreenPos >= 0 && iNoItemsOnScreen > 0 && aScreenPos < NAP2Cfg::KMaxNofItemsInView + 1 ) |
|
906 { |
|
907 result = iOnScreenItemIndex[aScreenPos]; |
|
908 } |
|
909 |
|
910 return result; |
|
911 } |
|
912 |
|
913 // ----------------------------------------------------------------------------- |
|
914 // CActivePalette2Model::ItemFromScreenPos() |
|
915 // ----------------------------------------------------------------------------- |
|
916 // |
|
917 CActivePalette2Item* CActivePalette2Model::ItemFromScreenPos(TInt aScreenPos) |
|
918 { |
|
919 CActivePalette2Item* result = NULL; |
|
920 |
|
921 TInt itemIndex = ItemIndexFromScreenPos(aScreenPos); |
|
922 |
|
923 if ( itemIndex != KInvalidItemIndex ) |
|
924 { |
|
925 result = iItemsArray[itemIndex]; |
|
926 } |
|
927 |
|
928 return result; |
|
929 } |
|
930 |
|
931 |
|
932 // ----------------------------------------------------------------------------- |
|
933 // CActivePalette2Model::ScreenPosFromItemIndex() |
|
934 // ----------------------------------------------------------------------------- |
|
935 // |
|
936 TInt CActivePalette2Model::ScreenPosFromItemIndex(TInt aItem) |
|
937 { |
|
938 TInt result = KInvalidScreenPos; |
|
939 TInt currentItem = iTopItemOnScreen; |
|
940 TInt currentScreenPos = 0; |
|
941 TBool found = EFalse; |
|
942 |
|
943 if ( aItem >= iItemsArray.Count() ) |
|
944 { |
|
945 result = iNoItemsOnScreen; |
|
946 } |
|
947 else if ( aItem < 0) |
|
948 { |
|
949 result = NAP2Cfg::KScreenPosAboveTop; |
|
950 } |
|
951 else |
|
952 { |
|
953 while ( !found && currentScreenPos < iNoItemsOnScreen ) |
|
954 { |
|
955 if ( aItem == currentItem ) |
|
956 { |
|
957 found = ETrue; |
|
958 } |
|
959 else |
|
960 { |
|
961 currentItem = FindVisibleItem(currentItem + 1); |
|
962 currentScreenPos++; |
|
963 } |
|
964 } |
|
965 |
|
966 if ( found ) |
|
967 { |
|
968 result = currentScreenPos; |
|
969 } |
|
970 } |
|
971 |
|
972 return result; |
|
973 } |
|
974 |
|
975 |
|
976 // ----------------------------------------------------------------------------- |
|
977 // CActivePalette2Model::FocusedItem() |
|
978 // ----------------------------------------------------------------------------- |
|
979 // |
|
980 TInt CActivePalette2Model::FocusedItem() |
|
981 { |
|
982 return ScreenPosFromItemIndex(iFocusedItem); |
|
983 } |
|
984 |
|
985 // ----------------------------------------------------------------------------- |
|
986 // CActivePalette2Model::FocusCurrentOffset() |
|
987 // ----------------------------------------------------------------------------- |
|
988 // |
|
989 TInt CActivePalette2Model::FocusCurrentOffset() |
|
990 { |
|
991 return iFocusedCurrentOffset; |
|
992 } |
|
993 |
|
994 // ----------------------------------------------------------------------------- |
|
995 // CActivePalette2Model::FocusCurrentTotalOffsetFrames() |
|
996 // ----------------------------------------------------------------------------- |
|
997 // |
|
998 TInt CActivePalette2Model::FocusCurrentTotalOffsetFrames() |
|
999 { |
|
1000 return NAP2Cfg::KFocusChangeFrames; |
|
1001 } |
|
1002 |
|
1003 // ----------------------------------------------------------------------------- |
|
1004 // CActivePalette2Model::PaletteAppearingCurrentFrame() |
|
1005 // ----------------------------------------------------------------------------- |
|
1006 // |
|
1007 TInt CActivePalette2Model::PaletteAppearingCurrentFrame() |
|
1008 { |
|
1009 return iPaletteMoveCurrentOffset; |
|
1010 } |
|
1011 |
|
1012 // ----------------------------------------------------------------------------- |
|
1013 // CActivePalette2Model::PaletteAppearingTotalFrames() |
|
1014 // ----------------------------------------------------------------------------- |
|
1015 // |
|
1016 TInt CActivePalette2Model::PaletteAppearingTotalFrames() |
|
1017 { |
|
1018 return iPaletteMoveOffsetTotalFrames; |
|
1019 } |
|
1020 |
|
1021 // ----------------------------------------------------------------------------- |
|
1022 // CActivePalette2Model::ProcessInputEvent() |
|
1023 // ----------------------------------------------------------------------------- |
|
1024 // |
|
1025 TBool CActivePalette2Model::ProcessInputEvent(TActivePalette2InputEvent aEvent) |
|
1026 { |
|
1027 TBool eventConsumed = EFalse; |
|
1028 |
|
1029 if ( PaletteActive() ) |
|
1030 { |
|
1031 SetAnimState(EPaletteAnimIdle); |
|
1032 |
|
1033 switch(aEvent) |
|
1034 { |
|
1035 case EAP2InputUp: |
|
1036 RemoveTooltip(); |
|
1037 |
|
1038 iFocusChangeTargetItem = PreviousVisibleItem(iFocusedItem - 1); |
|
1039 |
|
1040 if ( iFocusChangeTargetItem != KInvalidItemIndex && iFocusChangeTargetItem != iFocusedItem ) |
|
1041 { |
|
1042 if ( ScreenPosFromItemIndex(iFocusedItem) == 0 ) |
|
1043 { |
|
1044 // Item scroll |
|
1045 iTopItemOnScreen = iFocusChangeTargetItem; |
|
1046 iFocusedItem = iFocusChangeTargetItem; |
|
1047 |
|
1048 iItemScrollCurrentOffset = NAP2Cfg::KItemScrollFrames; |
|
1049 |
|
1050 ItemsUpdated(); |
|
1051 |
|
1052 ScrollItems(-1); |
|
1053 } |
|
1054 else |
|
1055 { |
|
1056 // Focus change |
|
1057 ChangeFocus(); |
|
1058 |
|
1059 eventConsumed = ETrue; |
|
1060 } |
|
1061 } |
|
1062 else |
|
1063 { |
|
1064 iFocusChangeTargetItem = PreviousVisibleItem(iItemsArray.Count() - 1); |
|
1065 |
|
1066 if ( iFocusChangeTargetItem != KInvalidItemIndex && iFocusChangeTargetItem != iFocusedItem ) |
|
1067 { |
|
1068 // Focus wrap |
|
1069 TInt screenPos = iNoItemsOnScreen - 1; |
|
1070 iTopItemOnScreen = iFocusChangeTargetItem; |
|
1071 |
|
1072 while ( screenPos > 0 ) |
|
1073 { |
|
1074 iTopItemOnScreen = PreviousVisibleItem(iTopItemOnScreen-1); |
|
1075 screenPos--; |
|
1076 } |
|
1077 |
|
1078 ItemsUpdated(); |
|
1079 |
|
1080 iFocusedItem = iItemsArray.Count(); |
|
1081 |
|
1082 ChangeFocus(); |
|
1083 |
|
1084 eventConsumed = ETrue; |
|
1085 } |
|
1086 } |
|
1087 break; |
|
1088 case EAP2InputDown: |
|
1089 RemoveTooltip(); |
|
1090 |
|
1091 iFocusChangeTargetItem = FindVisibleItem(iFocusedItem + 1); |
|
1092 |
|
1093 if ( iFocusChangeTargetItem != KInvalidItemIndex && iFocusChangeTargetItem != iFocusedItem ) |
|
1094 { |
|
1095 if ( ScreenPosFromItemIndex(iFocusedItem) == (iNoItemsOnScreen - 1)) |
|
1096 { |
|
1097 // Item scroll |
|
1098 iItemScrollCurrentOffset = 0; |
|
1099 |
|
1100 ScrollItems(+1); |
|
1101 } |
|
1102 else |
|
1103 { |
|
1104 // Focus change |
|
1105 ChangeFocus(); |
|
1106 } |
|
1107 |
|
1108 eventConsumed = ETrue; |
|
1109 } |
|
1110 else |
|
1111 { |
|
1112 // wrap focus to top |
|
1113 iFocusChangeTargetItem = FindVisibleItem(0); |
|
1114 |
|
1115 if ( iFocusChangeTargetItem != KInvalidItemIndex && iFocusChangeTargetItem != iFocusedItem ) |
|
1116 { |
|
1117 iTopItemOnScreen = iFocusChangeTargetItem; |
|
1118 ItemsUpdated(); |
|
1119 iFocusedItem = -1; |
|
1120 |
|
1121 ChangeFocus(); |
|
1122 } |
|
1123 } |
|
1124 |
|
1125 break; |
|
1126 |
|
1127 case EAP2InputSelect: |
|
1128 RemoveTooltip(); |
|
1129 |
|
1130 if ( iFocusedItem >= 0 && iFocusedItem < iItemsArray.Count()) |
|
1131 { |
|
1132 if ( iVisibilityArray[iFocusedItem] ) |
|
1133 { |
|
1134 TActivePalette2EventData res(PrepareEventData(*iItemsArray[iFocusedItem], KErrNone)); |
|
1135 |
|
1136 if ( iModelObserver.APObserver() ) |
|
1137 { |
|
1138 iModelObserver.APObserver()->NotifyItemSelected(res); |
|
1139 } |
|
1140 |
|
1141 HandleItemSelected(iFocusedItem); |
|
1142 |
|
1143 eventConsumed = ETrue; |
|
1144 } |
|
1145 } |
|
1146 break; |
|
1147 } |
|
1148 } |
|
1149 |
|
1150 return eventConsumed; |
|
1151 } |
|
1152 |
|
1153 |
|
1154 // ----------------------------------------------------------------------------- |
|
1155 // CActivePalette2Model::ScrollItems() |
|
1156 // ----------------------------------------------------------------------------- |
|
1157 // |
|
1158 void CActivePalette2Model::ScrollItems(TInt aDirection) |
|
1159 { |
|
1160 SetAnimState(EPaletteAnimItemScroll); |
|
1161 |
|
1162 if ( iCallbacks.iItemScrollTimer ) |
|
1163 { |
|
1164 iItemScrollDirection = aDirection; |
|
1165 |
|
1166 iItemScrollTimer->Start( |
|
1167 NAP2Cfg::KItemScrollTimerTickLength, |
|
1168 NAP2Cfg::KItemScrollTimerTickLength, |
|
1169 TCallBack(&CActivePalette2Model::ItemScrollTimerCallback,(TAny *)this)); |
|
1170 } |
|
1171 else if ( iCallbacks.iItemScrollDescriptive ) |
|
1172 { |
|
1173 iCallbacks.iItemScrollDescriptive->AnimateItemScroll(aDirection, NAP2Cfg::KItemScrollTotalTime / KMicrosecondsPerMillisecond); |
|
1174 } |
|
1175 else |
|
1176 { |
|
1177 // just for Lint. |
|
1178 } |
|
1179 } |
|
1180 |
|
1181 // ----------------------------------------------------------------------------- |
|
1182 // CActivePalette2Model::ChangeFocus() |
|
1183 // ----------------------------------------------------------------------------- |
|
1184 // |
|
1185 void CActivePalette2Model::ChangeFocus() |
|
1186 { |
|
1187 if ( iCallbacks.iFocusTimer ) |
|
1188 { |
|
1189 if ( iFocusedItem < iFocusChangeTargetItem ) |
|
1190 { |
|
1191 iFocusedCurrentOffset = 0; |
|
1192 iFocusChangeDirection = +1; |
|
1193 } |
|
1194 else |
|
1195 { |
|
1196 iFocusedCurrentOffset = NAP2Cfg::KFocusChangeFrames; |
|
1197 iFocusChangeDirection = -1; |
|
1198 iFocusedItem = iFocusChangeTargetItem; |
|
1199 } |
|
1200 |
|
1201 SetAnimState(EPaletteAnimFocusChange); |
|
1202 iFocusChangeTimer->Start( |
|
1203 NAP2Cfg::KFocusChangeTimerTickLength, |
|
1204 NAP2Cfg::KFocusChangeTimerTickLength, |
|
1205 TCallBack(&CActivePalette2Model::FocusChangeTimerCallback,(TAny *)this)); |
|
1206 } |
|
1207 else if ( iCallbacks.iFocusDescriptive ) |
|
1208 { |
|
1209 SetAnimState(EPaletteAnimFocusChange); |
|
1210 iCallbacks.iFocusDescriptive->AnimateFocus(ScreenPosFromItemIndex(iFocusedItem), ScreenPosFromItemIndex(iFocusChangeTargetItem), NAP2Cfg::KFocusChangeTotalTime / KMicrosecondsPerMillisecond); |
|
1211 } |
|
1212 else |
|
1213 { |
|
1214 // lint |
|
1215 } |
|
1216 } |
|
1217 |
|
1218 |
|
1219 |
|
1220 |
|
1221 |
|
1222 // ----------------------------------------------------------------------------- |
|
1223 // CActivePalette2Model::ItemAnimInfo() |
|
1224 // ----------------------------------------------------------------------------- |
|
1225 // |
|
1226 CActivePalettePluginBase::TPluginAnimationInfo CActivePalette2Model::ItemAnimInfo() |
|
1227 { |
|
1228 return iAniItemInfo; |
|
1229 } |
|
1230 |
|
1231 |
|
1232 // ----------------------------------------------------------------------------- |
|
1233 // CActivePalette2Model::SetPaletteVisibility() |
|
1234 // ----------------------------------------------------------------------------- |
|
1235 // |
|
1236 TInt CActivePalette2Model::SetPaletteVisibility(TBool aVisible, TBool aAnimated, TInt aDelayedStartMilliseconds) |
|
1237 { |
|
1238 // Check if we're already in an appearance animation |
|
1239 if ( iAnimState == EPaletteAnimAppearing |
|
1240 && iCallbacks.iAppearanceDescriptive ) |
|
1241 { |
|
1242 // If so, update state |
|
1243 iPaletteMoveCurrentOffset = iCallbacks.iAppearanceDescriptive->GuessCurrentAppearanceFrame(); |
|
1244 |
|
1245 if ( iPaletteMoveCurrentOffset < 0 || iPaletteMoveCurrentOffset > iPaletteMoveOffsetTotalFrames ) |
|
1246 { |
|
1247 iPaletteMoveOffsetTotalFrames = iPaletteMoveOffsetTotalFrames; |
|
1248 } |
|
1249 } |
|
1250 |
|
1251 |
|
1252 if ( aAnimated || aDelayedStartMilliseconds > 0) |
|
1253 { |
|
1254 if ( aVisible ) |
|
1255 { |
|
1256 if ( iPaletteMoveOffsetTotalFrames > iPaletteMoveCurrentOffset ) |
|
1257 { |
|
1258 RemoveTooltip(); |
|
1259 SetAnimState(EPaletteAnimAppearing); |
|
1260 iModelObserver.PaletteAppearingUpdated(); |
|
1261 |
|
1262 if ( aAnimated ) |
|
1263 { |
|
1264 iPaletteMoveAnimationDirection = +1; |
|
1265 } |
|
1266 else |
|
1267 { |
|
1268 iPaletteMoveAnimationDirection = +iPaletteMoveOffsetTotalFrames; |
|
1269 } |
|
1270 |
|
1271 iPaletteMoveTimer->Cancel(); |
|
1272 iPaletteMoveTimer->Start(Max(1, aDelayedStartMilliseconds * KMicrosecondsPerMillisecond), |
|
1273 NAP2Cfg::KPaletteAppearTimerTickLength, |
|
1274 TCallBack(&CActivePalette2Model::PaletteAnimTimerCallback,(TAny*)this)); |
|
1275 } |
|
1276 else if ( aAnimated && 0 >= iPaletteMoveAnimationDirection ) |
|
1277 { |
|
1278 iPaletteMoveAnimationDirection = +1; |
|
1279 } |
|
1280 } |
|
1281 else |
|
1282 { |
|
1283 if ( iPaletteMoveCurrentOffset > 0 ) |
|
1284 { |
|
1285 RemoveTooltip(); |
|
1286 SetAnimState(EPaletteAnimAppearing); |
|
1287 iModelObserver.PaletteAppearingUpdated(); |
|
1288 |
|
1289 if ( aAnimated ) |
|
1290 { |
|
1291 iPaletteMoveAnimationDirection = -1; |
|
1292 } |
|
1293 else |
|
1294 { |
|
1295 iPaletteMoveAnimationDirection = -iPaletteMoveOffsetTotalFrames; |
|
1296 } |
|
1297 |
|
1298 |
|
1299 iPaletteMoveTimer->Cancel(); |
|
1300 iPaletteMoveTimer->Start(Max(1, aDelayedStartMilliseconds * KMicrosecondsPerMillisecond), |
|
1301 NAP2Cfg::KPaletteAppearTimerTickLength, |
|
1302 TCallBack(&CActivePalette2Model::PaletteAnimTimerCallback,(TAny*)this)); |
|
1303 } |
|
1304 //Start fix for ERCK-77PCZJ |
|
1305 else |
|
1306 { |
|
1307 iPaletteMoveAnimationDirection = -iPaletteMoveOffsetTotalFrames; |
|
1308 SetAnimState(EPaletteAnimIdle); |
|
1309 } |
|
1310 //End fix ERCK-77PCZJ |
|
1311 } |
|
1312 } |
|
1313 else |
|
1314 { |
|
1315 if ( aVisible ) |
|
1316 { |
|
1317 if ( iPaletteMoveOffsetTotalFrames != iPaletteMoveCurrentOffset ) |
|
1318 { |
|
1319 RemoveTooltip(); |
|
1320 SetAnimState(EPaletteAnimIdle); |
|
1321 iPaletteMoveCurrentOffset = iPaletteMoveOffsetTotalFrames; |
|
1322 iModelObserver.PaletteAppearingUpdated(); |
|
1323 } |
|
1324 } |
|
1325 else |
|
1326 { |
|
1327 if ( iPaletteMoveCurrentOffset != 0 ) |
|
1328 { |
|
1329 RemoveTooltip(); |
|
1330 SetAnimState(EPaletteAnimIdle); |
|
1331 iPaletteMoveCurrentOffset = 0; |
|
1332 iModelObserver.PaletteAppearingUpdated(); |
|
1333 } |
|
1334 //Start fix for ERCK-77PCZJ |
|
1335 else |
|
1336 { |
|
1337 iPaletteMoveAnimationDirection = -iPaletteMoveOffsetTotalFrames; |
|
1338 SetAnimState(EPaletteAnimIdle); |
|
1339 } |
|
1340 //End fix ERCK-77PCZJ |
|
1341 } |
|
1342 } |
|
1343 |
|
1344 return KErrNone; |
|
1345 } |
|
1346 |
|
1347 |
|
1348 |
|
1349 // ----------------------------------------------------------------------------- |
|
1350 // CActivePalette2Model::NotifyItemComplete() |
|
1351 // ----------------------------------------------------------------------------- |
|
1352 // |
|
1353 void CActivePalette2Model::NotifyItemComplete(const CActivePalette2Item& aItem, |
|
1354 TInt aResult, |
|
1355 const TDesC8& aDataDes, |
|
1356 TInt aDataInt) |
|
1357 { |
|
1358 if ( iModelObserver.APObserver() ) |
|
1359 { |
|
1360 TActivePalette2EventData evt(PrepareEventData(aItem, aResult)); |
|
1361 iModelObserver.APObserver()->NotifyItemComplete(evt, aDataDes, aDataInt); |
|
1362 } |
|
1363 } |
|
1364 |
|
1365 // ----------------------------------------------------------------------------- |
|
1366 // CActivePalette2Model::NotifyMessage() |
|
1367 // ----------------------------------------------------------------------------- |
|
1368 // |
|
1369 void CActivePalette2Model::NotifyMessage(const CActivePalette2Item& aItem, |
|
1370 const TInt aResult, |
|
1371 const TInt aMessageID, |
|
1372 const TDesC8& aDataDes, |
|
1373 TInt aDataInt) |
|
1374 { |
|
1375 if ( iModelObserver.APObserver() ) |
|
1376 { |
|
1377 TActivePalette2EventData eventData = PrepareEventData(aItem, aResult); |
|
1378 iModelObserver.APObserver()->NotifyMessage(eventData, aMessageID, aDataDes, aDataInt); |
|
1379 } |
|
1380 } |
|
1381 |
|
1382 |
|
1383 // ----------------------------------------------------------------------------- |
|
1384 // CActivePalette2Model::NotifyGraphicsChanged() |
|
1385 // ----------------------------------------------------------------------------- |
|
1386 // |
|
1387 void CActivePalette2Model::NotifyGraphicsChanged(const CActivePalette2Item& /*aItem*/, |
|
1388 const TBool aIsIconChanged, |
|
1389 const TBool aIsTooltipChanged) |
|
1390 { |
|
1391 if ( aIsTooltipChanged ) |
|
1392 { |
|
1393 RemoveTooltip(); |
|
1394 } |
|
1395 |
|
1396 if ( aIsIconChanged ) |
|
1397 { |
|
1398 ItemsUpdated(); |
|
1399 } |
|
1400 } |
|
1401 |
|
1402 // ----------------------------------------------------------------------------- |
|
1403 // CActivePalette2Model::PrepareEventData() |
|
1404 // ----------------------------------------------------------------------------- |
|
1405 // |
|
1406 TActivePalette2EventData CActivePalette2Model::PrepareEventData(const CActivePalette2Item& aItem, |
|
1407 TInt aResult) |
|
1408 { |
|
1409 TActivePalette2EventData evt |
|
1410 ( |
|
1411 aResult, |
|
1412 aItem.ItemId(), |
|
1413 iPreviousItemID, |
|
1414 aItem.ItemId(), |
|
1415 aItem.PluginUid() |
|
1416 ); |
|
1417 |
|
1418 return evt; |
|
1419 } |
|
1420 |
|
1421 // ----------------------------------------------------------------------------- |
|
1422 // CActivePalette2Model::SetItemVisibility() |
|
1423 // ----------------------------------------------------------------------------- |
|
1424 // |
|
1425 TInt CActivePalette2Model::SetItemVisibility(const TInt aItemId, const TBool aIsVisible) |
|
1426 { |
|
1427 TInt index = ItemIndexFromId(aItemId); |
|
1428 TInt res = KErrNotFound; |
|
1429 |
|
1430 if ( ValidItemIndex(index) ) |
|
1431 { |
|
1432 if ( iVisibilityArray[index] != aIsVisible ) |
|
1433 { |
|
1434 iVisibilityArray[index] = aIsVisible; |
|
1435 EnforceConstraints(); |
|
1436 } |
|
1437 res = KErrNone; |
|
1438 } |
|
1439 |
|
1440 return res; |
|
1441 } |
|
1442 |
|
1443 // ----------------------------------------------------------------------------- |
|
1444 // CActivePalette2Model::GetItemVisibility() |
|
1445 // ----------------------------------------------------------------------------- |
|
1446 // |
|
1447 TInt CActivePalette2Model::GetItemVisibility(const TInt aItemId, TBool &aIsVisible) const |
|
1448 { |
|
1449 TInt index = ItemIndexFromId(aItemId); |
|
1450 TInt res = KErrNone; |
|
1451 |
|
1452 if ( ValidItemIndex(index) ) |
|
1453 { |
|
1454 aIsVisible = iVisibilityArray[index]; |
|
1455 } |
|
1456 else |
|
1457 { |
|
1458 res = KErrArgument; |
|
1459 } |
|
1460 |
|
1461 return res; |
|
1462 } |
|
1463 |
|
1464 // ----------------------------------------------------------------------------- |
|
1465 // CActivePalette2Model::GetAvailablePlugins() |
|
1466 // ----------------------------------------------------------------------------- |
|
1467 // |
|
1468 TInt CActivePalette2Model::GetAvailablePlugins(RArray<TUid>& aPluginList) const |
|
1469 { |
|
1470 aPluginList.Reset(); |
|
1471 |
|
1472 // Generic plugin always available |
|
1473 aPluginList.Append(TUid::Uid(KActivePalette2GenericPluginUID)); |
|
1474 |
|
1475 AppendPluginIdIfAvailable(aPluginList, TUid::Uid(KPrintPluginUid), TFileName(KPrintPluginDLLName)); |
|
1476 AppendPluginIdIfAvailable(aPluginList, TUid::Uid(KPrintIntentPluginUid), TFileName(KPrintIntentPluginDLLName)); |
|
1477 AppendPluginIdIfAvailable(aPluginList, TUid::Uid(KOnlineSharingPluginUid), TFileName(KOnlineSharingPluginDLLName)); |
|
1478 #ifdef ACTIVEPALETTE_SUPPORT_PLUGIN_CAM |
|
1479 AppendPluginIdIfAvailable(aPluginList, TUid::Uid(KCamAPPluginUid), TFileName(KCamAPluginDLLName)); |
|
1480 #endif |
|
1481 |
|
1482 return KErrNone; |
|
1483 } |
|
1484 |
|
1485 // ----------------------------------------------------------------------------- |
|
1486 // CActivePalette2Model::AppendPluginIdIfAvailable() |
|
1487 // ----------------------------------------------------------------------------- |
|
1488 // |
|
1489 void CActivePalette2Model::AppendPluginIdIfAvailable(RArray<TUid>& aPluginList, const TUid aDllUid, const TFileName aDllFileName) const |
|
1490 { |
|
1491 RLibrary dll; |
|
1492 |
|
1493 TInt err = dll.Load(aDllFileName); |
|
1494 |
|
1495 if ( err == KErrNone ) |
|
1496 { |
|
1497 aPluginList.Append(aDllUid); |
|
1498 } |
|
1499 |
|
1500 dll.Close(); |
|
1501 } |
|
1502 |
|
1503 // ----------------------------------------------------------------------------- |
|
1504 // CActivePalette2Model::SetPaletteVisibilityAnimationDuration() |
|
1505 // ----------------------------------------------------------------------------- |
|
1506 // |
|
1507 TInt CActivePalette2Model::SetPaletteVisibilityAnimationDuration(TInt aTimeInMilliSeconds) |
|
1508 { |
|
1509 iPaletteMoveAnimationDuration = aTimeInMilliSeconds; |
|
1510 |
|
1511 TInt targetTotalFrames = (aTimeInMilliSeconds * KMicrosecondsPerMillisecond) / NAP2Cfg::KPaletteAppearTimerTickLength; |
|
1512 |
|
1513 if ( targetTotalFrames < 1 ) |
|
1514 { |
|
1515 targetTotalFrames = 1; |
|
1516 } |
|
1517 |
|
1518 // update current frame |
|
1519 if ( iPaletteMoveCurrentOffset == iPaletteMoveOffsetTotalFrames ) |
|
1520 { |
|
1521 iPaletteMoveCurrentOffset = targetTotalFrames; |
|
1522 } |
|
1523 else if ( iPaletteMoveCurrentOffset > 0 && iPaletteMoveOffsetTotalFrames > 0) |
|
1524 { |
|
1525 iPaletteMoveCurrentOffset = (iPaletteMoveCurrentOffset * targetTotalFrames) / iPaletteMoveOffsetTotalFrames; |
|
1526 } |
|
1527 else |
|
1528 { |
|
1529 iPaletteMoveCurrentOffset = 0; |
|
1530 } |
|
1531 |
|
1532 iPaletteMoveOffsetTotalFrames = targetTotalFrames; |
|
1533 |
|
1534 // double check we're in range |
|
1535 if ( iPaletteMoveCurrentOffset < 0 ) |
|
1536 { |
|
1537 iPaletteMoveCurrentOffset = 0; |
|
1538 } |
|
1539 |
|
1540 if ( iPaletteMoveCurrentOffset > iPaletteMoveOffsetTotalFrames ) |
|
1541 { |
|
1542 iPaletteMoveCurrentOffset = iPaletteMoveOffsetTotalFrames; |
|
1543 } |
|
1544 |
|
1545 return KErrNone; |
|
1546 } |
|
1547 |
|
1548 // ----------------------------------------------------------------------------- |
|
1549 // CActivePalette2Model::GetItemList() |
|
1550 // ----------------------------------------------------------------------------- |
|
1551 // |
|
1552 TInt CActivePalette2Model::GetItemList(RArray<TActivePalette2ItemVisible>& aItemVisibleList) const |
|
1553 { |
|
1554 aItemVisibleList.Reset(); |
|
1555 |
|
1556 TInt currentItem = 0; |
|
1557 TInt totalItems = iItemsArray.Count(); |
|
1558 |
|
1559 while ( currentItem < totalItems ) |
|
1560 { |
|
1561 aItemVisibleList.Append( |
|
1562 TActivePalette2ItemVisible( |
|
1563 iItemsArray[currentItem]->ItemId(), |
|
1564 iVisibilityArray[currentItem])); |
|
1565 currentItem++; |
|
1566 } |
|
1567 |
|
1568 return KErrNone; |
|
1569 } |
|
1570 |
|
1571 // ----------------------------------------------------------------------------- |
|
1572 // CActivePalette2Model::SetItemList() |
|
1573 // ----------------------------------------------------------------------------- |
|
1574 // |
|
1575 TInt CActivePalette2Model::SetItemList(const RArray<TActivePalette2ItemVisible>& aItemVisibleList) |
|
1576 { |
|
1577 TInt res = KErrNone; |
|
1578 TInt currentItem = 0; |
|
1579 TInt totalItems = iItemsArray.Count(); |
|
1580 TInt totalInputItems = aItemVisibleList.Count(); |
|
1581 TInt destIndex = 0; |
|
1582 |
|
1583 TInt focusedItemId = 0; |
|
1584 |
|
1585 // Backup the current focused item |
|
1586 if ( ValidItemIndex(iFocusedItem) ) |
|
1587 { |
|
1588 focusedItemId = iItemsArray[iFocusedItem]->ItemId(); |
|
1589 } |
|
1590 |
|
1591 // Check that there aren't any invalid IDs in the list |
|
1592 while ( currentItem < totalInputItems && res == KErrNone ) |
|
1593 { |
|
1594 TInt itemId = aItemVisibleList[currentItem].ItemId(); |
|
1595 TInt foundIndex = ItemIndexFromId(itemId); |
|
1596 |
|
1597 if ( foundIndex == KInvalidItemIndex ) |
|
1598 { |
|
1599 res = KErrNotFound; |
|
1600 } |
|
1601 |
|
1602 currentItem++; |
|
1603 } |
|
1604 |
|
1605 // Rearrange the item & visibility lists |
|
1606 currentItem = 0; |
|
1607 while ( currentItem < totalInputItems && destIndex < totalItems && res == KErrNone ) |
|
1608 { |
|
1609 TInt itemId = aItemVisibleList[currentItem].ItemId(); |
|
1610 TBool visible = aItemVisibleList[currentItem].Visible(); |
|
1611 |
|
1612 TInt foundIndex = ItemIndexFromId(itemId); |
|
1613 |
|
1614 if ( foundIndex >= currentItem ) |
|
1615 { |
|
1616 iItemsArray.Insert(iItemsArray[foundIndex], destIndex); |
|
1617 iItemsArray.Remove(foundIndex + 1); |
|
1618 |
|
1619 iVisibilityArray.Insert(visible, destIndex); |
|
1620 iVisibilityArray.Remove(foundIndex + 1); |
|
1621 |
|
1622 destIndex++; |
|
1623 } |
|
1624 |
|
1625 currentItem++; |
|
1626 } |
|
1627 |
|
1628 // Update the focus |
|
1629 if ( res == KErrNone ) |
|
1630 { |
|
1631 iFocusedItem = ItemIndexFromId(focusedItemId); |
|
1632 |
|
1633 EnforceConstraints(); |
|
1634 } |
|
1635 |
|
1636 return res; |
|
1637 } |
|
1638 |
|
1639 // ----------------------------------------------------------------------------- |
|
1640 // CActivePalette2Model::GetPaletteVisibilityAnimationDuration() |
|
1641 // ----------------------------------------------------------------------------- |
|
1642 // |
|
1643 TInt CActivePalette2Model::GetPaletteVisibilityAnimationDuration(TInt& aTimeInMilliseconds) const |
|
1644 { |
|
1645 aTimeInMilliseconds = iPaletteMoveAnimationDuration; |
|
1646 return KErrNone; |
|
1647 } |
|
1648 |
|
1649 // ----------------------------------------------------------------------------- |
|
1650 // CActivePalette2Model::SetCurrentItem() |
|
1651 // ----------------------------------------------------------------------------- |
|
1652 // |
|
1653 TInt CActivePalette2Model::SetCurrentItem(const TInt aItemId) |
|
1654 { |
|
1655 TInt err = KErrNotFound; |
|
1656 TInt index = ItemIndexFromId(aItemId); |
|
1657 |
|
1658 if ( ValidItemIndex(index) ) |
|
1659 { |
|
1660 err = KErrGeneral; |
|
1661 |
|
1662 if ( iVisibilityArray[index] ) |
|
1663 { |
|
1664 iFocusedItem = index; |
|
1665 |
|
1666 EnforceConstraints(); |
|
1667 |
|
1668 err = KErrNone; |
|
1669 } |
|
1670 } |
|
1671 |
|
1672 return err; |
|
1673 } |
|
1674 |
|
1675 // ----------------------------------------------------------------------------- |
|
1676 // CActivePalette2Model::GetCurrentItem() |
|
1677 // ----------------------------------------------------------------------------- |
|
1678 // |
|
1679 TInt CActivePalette2Model::GetCurrentItem(TInt& aItemId) const |
|
1680 { |
|
1681 TInt err = KErrGeneral; |
|
1682 |
|
1683 if ( ValidItemIndex(iFocusedItem) ) |
|
1684 { |
|
1685 if ( iItemsArray[iFocusedItem] ) |
|
1686 { |
|
1687 aItemId = iItemsArray[iFocusedItem]->ItemId(); |
|
1688 |
|
1689 err = KErrNone; |
|
1690 } |
|
1691 } |
|
1692 return err; |
|
1693 } |
|
1694 |
|
1695 // ----------------------------------------------------------------------------- |
|
1696 // CActivePalette2Model::ItemsUpdated() |
|
1697 // ----------------------------------------------------------------------------- |
|
1698 // |
|
1699 void CActivePalette2Model::ItemsUpdated() |
|
1700 { |
|
1701 RemoveTooltip(); |
|
1702 |
|
1703 // Update cached data |
|
1704 TInt onScreenPos = 0; |
|
1705 TInt onScreenIndex = iTopItemOnScreen; |
|
1706 |
|
1707 while ( onScreenIndex != KInvalidItemIndex && onScreenPos < (NAP2Cfg::KMaxNofItemsInView + 1)) |
|
1708 { |
|
1709 iOnScreenItemIndex[onScreenPos] = onScreenIndex; |
|
1710 onScreenIndex = FindVisibleItem(onScreenIndex + 1); |
|
1711 onScreenPos++; |
|
1712 } |
|
1713 |
|
1714 while (onScreenPos < (NAP2Cfg::KMaxNofItemsInView + 1)) |
|
1715 { |
|
1716 iOnScreenItemIndex[onScreenPos] = KInvalidItemIndex; |
|
1717 onScreenPos++; |
|
1718 } |
|
1719 |
|
1720 iShowTopScrollArrow = iTopItemOnScreen > FindVisibleItem(0); |
|
1721 iShowBottomScrollArrow = CountVisibleItems(iTopItemOnScreen) > iNoItemsOnScreen; |
|
1722 |
|
1723 iModelObserver.ItemsUpdated(); |
|
1724 } |
|
1725 |
|
1726 |
|
1727 |
|
1728 // ----------------------------------------------------------------------------- |
|
1729 // CActivePalette2Model::ItemScrollOffset() |
|
1730 // ----------------------------------------------------------------------------- |
|
1731 // |
|
1732 TInt CActivePalette2Model::ItemScrollOffset() |
|
1733 { |
|
1734 return iItemScrollCurrentOffset; |
|
1735 } |
|
1736 |
|
1737 |
|
1738 // ----------------------------------------------------------------------------- |
|
1739 // CActivePalette2Model::ItemScrollTotalFrames() |
|
1740 // ----------------------------------------------------------------------------- |
|
1741 // |
|
1742 TInt CActivePalette2Model::ItemScrollTotalFrames() |
|
1743 { |
|
1744 return NAP2Cfg::KItemScrollFrames; |
|
1745 } |
|
1746 |
|
1747 // ----------------------------------------------------------------------------- |
|
1748 // CActivePalette2Model::SetAnimState() |
|
1749 // ----------------------------------------------------------------------------- |
|
1750 // |
|
1751 void CActivePalette2Model::SetAnimState(TPaletteAnimState aNewState) |
|
1752 { |
|
1753 if ( iAnimState != aNewState ) |
|
1754 { |
|
1755 // Exit old state |
|
1756 switch ( iAnimState ) |
|
1757 { |
|
1758 case EPaletteAnimItemScroll: |
|
1759 ItemScrollComplete(); |
|
1760 break; |
|
1761 |
|
1762 case EPaletteAnimFocusChange: |
|
1763 FocusChangeComplete(); |
|
1764 break; |
|
1765 |
|
1766 case EPaletteAnimItemAnim: |
|
1767 ItemAnimationComplete(); |
|
1768 break; |
|
1769 |
|
1770 case EPaletteAnimAppearing: |
|
1771 PaletteAnimComplete(); |
|
1772 break; |
|
1773 |
|
1774 case EPaletteAnimIdle: |
|
1775 default: |
|
1776 // do nothing; |
|
1777 break; |
|
1778 } |
|
1779 |
|
1780 // Enter new state |
|
1781 switch ( aNewState ) |
|
1782 { |
|
1783 case EPaletteAnimItemScroll: |
|
1784 break; |
|
1785 |
|
1786 case EPaletteAnimFocusChange: |
|
1787 break; |
|
1788 |
|
1789 case EPaletteAnimItemAnim: |
|
1790 StartItemAnimation(); |
|
1791 break; |
|
1792 |
|
1793 case EPaletteAnimAppearing: |
|
1794 break; |
|
1795 |
|
1796 case EPaletteAnimIdle: |
|
1797 default: |
|
1798 // do nothing; |
|
1799 break; |
|
1800 } |
|
1801 |
|
1802 iAnimState = aNewState; |
|
1803 } |
|
1804 } |
|
1805 |
|
1806 // ----------------------------------------------------------------------------- |
|
1807 // CActivePalette2Model::PaletteActive() |
|
1808 // ----------------------------------------------------------------------------- |
|
1809 // |
|
1810 TBool CActivePalette2Model::PaletteActive() |
|
1811 { |
|
1812 return ( iAnimState != EPaletteAnimAppearing && iPaletteMoveCurrentOffset == iPaletteMoveOffsetTotalFrames); |
|
1813 } |
|
1814 |
|
1815 // ----------------------------------------------------------------------------- |
|
1816 // CActivePalette2Model::ValidItemIndex() |
|
1817 // ----------------------------------------------------------------------------- |
|
1818 // |
|
1819 TBool CActivePalette2Model::ValidItemIndex(TInt aItemIndex) const |
|
1820 { |
|
1821 return (aItemIndex >= 0 && aItemIndex < iItemsArray.Count()); |
|
1822 } |
|
1823 |
|
1824 // ----------------------------------------------------------------------------- |
|
1825 // CActivePalette2Model::SendMessage() |
|
1826 // ----------------------------------------------------------------------------- |
|
1827 // |
|
1828 TInt CActivePalette2Model::SendMessage(TInt aItemId, TInt aMessageId, const TDesC8& aDataDes) |
|
1829 { |
|
1830 return DispatchMessage(aItemId,aMessageId,aDataDes,KActivePaletteNoDataInt); |
|
1831 } |
|
1832 |
|
1833 // ----------------------------------------------------------------------------- |
|
1834 // CActivePalette2Model::SendMessage() |
|
1835 // ----------------------------------------------------------------------------- |
|
1836 // |
|
1837 TInt CActivePalette2Model::SendMessage(TInt aItemId, TInt aMessageId, TInt aDataInt) |
|
1838 { |
|
1839 return DispatchMessage(aItemId,aMessageId,KNullDesC8,aDataInt); |
|
1840 } |
|
1841 |
|
1842 // ----------------------------------------------------------------------------- |
|
1843 // CActivePalette2Model::InstallItemL() |
|
1844 // ----------------------------------------------------------------------------- |
|
1845 // |
|
1846 TInt CActivePalette2Model::InstallItemL(const TActivePalette2ItemVisible& aItemVisible, |
|
1847 const TUid& aPluginUid, |
|
1848 const TDesC8& aCustomDataDes) |
|
1849 { |
|
1850 return DoInstallItemL(aItemVisible.ItemId(), |
|
1851 aItemVisible.Visible(), |
|
1852 aPluginUid,aCustomDataDes, |
|
1853 KActivePaletteNoDataInt); |
|
1854 } |
|
1855 |
|
1856 // ----------------------------------------------------------------------------- |
|
1857 // CActivePalette2Model::InstallItemL() |
|
1858 // ----------------------------------------------------------------------------- |
|
1859 // |
|
1860 TInt CActivePalette2Model::InstallItemL(const TActivePalette2ItemVisible& aItemVisible, |
|
1861 const TUid& aPluginUid, |
|
1862 TInt aCustomDataInt) |
|
1863 { |
|
1864 return DoInstallItemL(aItemVisible.ItemId(), |
|
1865 aItemVisible.Visible(), |
|
1866 aPluginUid, |
|
1867 KNullDesC8, |
|
1868 aCustomDataInt); |
|
1869 } |
|
1870 |
|
1871 // ----------------------------------------------------------------------------- |
|
1872 // CActivePalette2Model::InstallItemL() |
|
1873 // ----------------------------------------------------------------------------- |
|
1874 // |
|
1875 TInt CActivePalette2Model::InstallItemL(const TActivePalette2ItemVisible& aItemVisible, |
|
1876 const TUid& aPluginUid, |
|
1877 TInt aCustomDataInt, |
|
1878 const TDesC8& aCustomDataDes) |
|
1879 { |
|
1880 return DoInstallItemL(aItemVisible.ItemId(), |
|
1881 aItemVisible.Visible(), |
|
1882 aPluginUid, |
|
1883 aCustomDataDes, |
|
1884 aCustomDataInt); |
|
1885 } |
|
1886 |
|
1887 // ----------------------------------------------------------------------------- |
|
1888 // CActivePalette2Model::ItemSize() |
|
1889 // ----------------------------------------------------------------------------- |
|
1890 // |
|
1891 TSize CActivePalette2Model::ItemSize() |
|
1892 { |
|
1893 return iItemSize; |
|
1894 } |
|
1895 |
|
1896 // ----------------------------------------------------------------------------- |
|
1897 // CActivePalette2Model::LocateTo() |
|
1898 // ----------------------------------------------------------------------------- |
|
1899 // |
|
1900 void CActivePalette2Model::LocateTo(const TPoint& /*aTopLeft*/) |
|
1901 { |
|
1902 // unused |
|
1903 } |
|
1904 |
|
1905 // ----------------------------------------------------------------------------- |
|
1906 // CActivePalette2Model::Location() |
|
1907 // ----------------------------------------------------------------------------- |
|
1908 // |
|
1909 TPoint CActivePalette2Model::Location() const |
|
1910 { |
|
1911 // unused |
|
1912 return TPoint(0,0); |
|
1913 } |
|
1914 |
|
1915 // ----------------------------------------------------------------------------- |
|
1916 // CActivePalette2Model::CoeControl() |
|
1917 // ----------------------------------------------------------------------------- |
|
1918 // |
|
1919 CCoeControl* CActivePalette2Model::CoeControl() |
|
1920 { |
|
1921 // unused |
|
1922 return NULL; |
|
1923 } |
|
1924 |
|
1925 // ----------------------------------------------------------------------------- |
|
1926 // CActivePalette2Model::HuiControl() |
|
1927 // ----------------------------------------------------------------------------- |
|
1928 // |
|
1929 CHuiControl* CActivePalette2Model::HuiControl() |
|
1930 { |
|
1931 // unused |
|
1932 return NULL; |
|
1933 } |
|
1934 |
|
1935 // ----------------------------------------------------------------------------- |
|
1936 // CActivePalette2Model::SetGc() |
|
1937 // ----------------------------------------------------------------------------- |
|
1938 // |
|
1939 void CActivePalette2Model::SetGc(CBitmapContext* /*aGc*/) |
|
1940 { |
|
1941 // unused |
|
1942 } |
|
1943 |
|
1944 // ----------------------------------------------------------------------------- |
|
1945 // CActivePalette2Model::RenderActivePalette() |
|
1946 // ----------------------------------------------------------------------------- |
|
1947 // |
|
1948 void CActivePalette2Model::RenderActivePalette(const TRect& /*aRect*/) const |
|
1949 { |
|
1950 // unused |
|
1951 } |
|
1952 |
|
1953 // ----------------------------------------------------------------------------- |
|
1954 // CActivePalette2Model::SetObserver() |
|
1955 // ----------------------------------------------------------------------------- |
|
1956 // |
|
1957 void CActivePalette2Model::SetObserver(MActivePalette2Observer* /*aObserver*/) |
|
1958 { |
|
1959 // unused |
|
1960 } |
|
1961 |
|
1962 // ----------------------------------------------------------------------------- |
|
1963 // CActivePalette2Model::SetNavigationKeys() |
|
1964 // ----------------------------------------------------------------------------- |
|
1965 // |
|
1966 void CActivePalette2Model::SetNavigationKeys(const TActivePalette2NavigationKeys& /*aNavigationKeys*/) |
|
1967 { |
|
1968 // unused |
|
1969 } |
|
1970 |
|
1971 // ----------------------------------------------------------------------------- |
|
1972 // CActivePalette2Model::AnimateAppearanceRendererComplete() |
|
1973 // ----------------------------------------------------------------------------- |
|
1974 // |
|
1975 void CActivePalette2Model::AnimateAppearanceRendererComplete() |
|
1976 { |
|
1977 if ( iAnimState == EPaletteAnimAppearing ) |
|
1978 { |
|
1979 SetAnimState(EPaletteAnimIdle); |
|
1980 iModelObserver.PaletteAppearingUpdated(); |
|
1981 } |
|
1982 } |
|
1983 |
|
1984 // ----------------------------------------------------------------------------- |
|
1985 // CActivePalette2Model::AnimateItemScrollRendererComplete() |
|
1986 // ----------------------------------------------------------------------------- |
|
1987 // |
|
1988 void CActivePalette2Model::AnimateItemScrollRendererComplete() |
|
1989 { |
|
1990 if ( iAnimState == EPaletteAnimItemScroll ) |
|
1991 { |
|
1992 SetAnimState(EPaletteAnimItemAnim); |
|
1993 } |
|
1994 } |
|
1995 |
|
1996 // ----------------------------------------------------------------------------- |
|
1997 // CActivePalette2Model::SetFocusedItem() |
|
1998 // ----------------------------------------------------------------------------- |
|
1999 // |
|
2000 void CActivePalette2Model::FocusedItemUpdated() |
|
2001 { |
|
2002 if ( ValidItemIndex(iFocusedItem) ) |
|
2003 { |
|
2004 TInt currentID = iItemsArray[iFocusedItem]->ItemId(); |
|
2005 |
|
2006 iPreviousItemID = iFocusedItemID; |
|
2007 iFocusedItemID = currentID; |
|
2008 |
|
2009 if ( iModelObserver.APObserver() ) |
|
2010 { |
|
2011 iModelObserver.APObserver()->NotifyItemFocused(iPreviousItemID, iFocusedItemID); |
|
2012 } |
|
2013 |
|
2014 if ( iCallbacks.iFocusTimer ) |
|
2015 { |
|
2016 iCallbacks.iFocusTimer->FocusUpdated(); |
|
2017 } |
|
2018 } |
|
2019 } |
|
2020 |
|
2021 |
|
2022 |
|
2023 |
|
2024 |
|
2025 |
|
2026 |
|
2027 |
|
2028 // ----------------------------------------------------------------------------- |
|
2029 // CActivePalette2Model::StartItemAnimation() |
|
2030 // ----------------------------------------------------------------------------- |
|
2031 // |
|
2032 void CActivePalette2Model::StartItemAnimation() |
|
2033 { |
|
2034 CompelTooltip(); |
|
2035 |
|
2036 CActivePalettePluginBase::TPluginAnimationInfo animConfig; |
|
2037 |
|
2038 animConfig.iFrameSize = ActivePalette2Utils::APDimensionSize( ActivePalette2Utils::EItemSize ); |
|
2039 animConfig.iNofFrames = NAP2Cfg::KItemAnimNoFrames; |
|
2040 animConfig.iFrameTimeGapMs = NAP2Cfg::KItemAnimFrameDuration; |
|
2041 |
|
2042 iAniItem = iItemsArray[iFocusedItem]; |
|
2043 iAniItemScreenPos = ScreenPosFromItemIndex(iFocusedItem); |
|
2044 |
|
2045 iAnimationFrame = 0; |
|
2046 |
|
2047 TRAP_IGNORE(iAniItem->Plugin().PrepareAniFramesL( |
|
2048 CActivePalettePluginBase::EAniFocused, |
|
2049 iAniItemInfo, |
|
2050 animConfig, |
|
2051 iAniItem->Icon(), |
|
2052 iAniItem->Mask())); |
|
2053 |
|
2054 iItemAnimTimer->Start(iAniItemInfo.iFrameTimeGapMs, iAniItemInfo.iFrameTimeGapMs, |
|
2055 TCallBack(&CActivePalette2Model::ItemAnimTimerCallback,(TAny*)this)); |
|
2056 |
|
2057 } |
|
2058 |
|
2059 // ----------------------------------------------------------------------------- |
|
2060 // CActivePalette2Model::ItemAnimTimerCallback() |
|
2061 // ----------------------------------------------------------------------------- |
|
2062 // |
|
2063 TInt CActivePalette2Model::ItemAnimTimerCallback(TAny* aPtr) |
|
2064 { |
|
2065 CActivePalette2Model* self = (CActivePalette2Model*) aPtr; |
|
2066 |
|
2067 if ( self ) |
|
2068 { |
|
2069 return self->ItemAnimAction(); |
|
2070 } |
|
2071 else |
|
2072 { |
|
2073 return KCallbackFinished; |
|
2074 } |
|
2075 } |
|
2076 |
|
2077 // ----------------------------------------------------------------------------- |
|
2078 // CActivePalette2Model::ItemAnimAction() |
|
2079 // ----------------------------------------------------------------------------- |
|
2080 // |
|
2081 TInt CActivePalette2Model::ItemAnimAction() |
|
2082 { |
|
2083 TInt res = KCallbackCallAgain; |
|
2084 |
|
2085 if ( iAnimationFrame > iAniItemInfo.iNofFrames) |
|
2086 { |
|
2087 res = KCallbackFinished; |
|
2088 SetAnimState(EPaletteAnimIdle); |
|
2089 } |
|
2090 else |
|
2091 { |
|
2092 iModelObserver.ItemAnimated(iAniItemScreenPos, iAniItem, iAnimationFrame); |
|
2093 iAnimationFrame++; |
|
2094 } |
|
2095 |
|
2096 return res; |
|
2097 } |
|
2098 |
|
2099 // ----------------------------------------------------------------------------- |
|
2100 // CActivePalette2Model::ItemAnimationComplete() |
|
2101 // ----------------------------------------------------------------------------- |
|
2102 // |
|
2103 void CActivePalette2Model::ItemAnimationComplete() |
|
2104 { |
|
2105 iItemAnimTimer->Cancel(); |
|
2106 iModelObserver.ItemAnimationComplete(iAniItemScreenPos, iAniItem); |
|
2107 iAniItem = NULL; |
|
2108 iAniItemScreenPos = KInvalidScreenPos; |
|
2109 } |
|
2110 |
|
2111 |
|
2112 |
|
2113 |
|
2114 |
|
2115 |
|
2116 // ----------------------------------------------------------------------------- |
|
2117 // CActivePalette2Model::ItemScrollTimerCallback() |
|
2118 // ----------------------------------------------------------------------------- |
|
2119 // |
|
2120 TInt CActivePalette2Model::ItemScrollTimerCallback(TAny* aPtr) |
|
2121 { |
|
2122 CActivePalette2Model* self = (CActivePalette2Model*) aPtr; |
|
2123 |
|
2124 if ( self ) |
|
2125 { |
|
2126 return self->ItemScrollAction(); |
|
2127 } |
|
2128 else |
|
2129 { |
|
2130 return KCallbackFinished; |
|
2131 } |
|
2132 } |
|
2133 |
|
2134 // ----------------------------------------------------------------------------- |
|
2135 // CActivePalette2Model::ItemScrollAction() |
|
2136 // ----------------------------------------------------------------------------- |
|
2137 // |
|
2138 TInt CActivePalette2Model::ItemScrollAction() |
|
2139 { |
|
2140 TInt res = KCallbackCallAgain; |
|
2141 |
|
2142 iItemScrollCurrentOffset += iItemScrollDirection; |
|
2143 |
|
2144 if ( iItemScrollCurrentOffset <= 0 || iItemScrollCurrentOffset >= NAP2Cfg::KItemScrollFrames ) |
|
2145 { |
|
2146 res = KCallbackFinished; |
|
2147 SetAnimState(EPaletteAnimItemAnim); |
|
2148 } |
|
2149 else |
|
2150 { |
|
2151 if ( iCallbacks.iItemScrollTimer ) |
|
2152 { |
|
2153 iCallbacks.iItemScrollTimer->ItemsScrolled(); |
|
2154 } |
|
2155 } |
|
2156 |
|
2157 return res; |
|
2158 } |
|
2159 |
|
2160 // ----------------------------------------------------------------------------- |
|
2161 // CActivePalette2Model::ItemScrollComplete() |
|
2162 // ----------------------------------------------------------------------------- |
|
2163 // |
|
2164 void CActivePalette2Model::ItemScrollComplete() |
|
2165 { |
|
2166 iItemScrollTimer->Cancel(); |
|
2167 |
|
2168 iItemScrollCurrentOffset = 0; |
|
2169 |
|
2170 if ( iFocusedItem != iFocusChangeTargetItem ) |
|
2171 { |
|
2172 iFocusedItem = iFocusChangeTargetItem; |
|
2173 iTopItemOnScreen = FindVisibleItem(iTopItemOnScreen + 1); |
|
2174 ItemsUpdated(); |
|
2175 } |
|
2176 else |
|
2177 { |
|
2178 if ( iCallbacks.iItemScrollTimer ) |
|
2179 { |
|
2180 iCallbacks.iItemScrollTimer->ItemsScrolled(); |
|
2181 } |
|
2182 } |
|
2183 } |
|
2184 |
|
2185 |
|
2186 |
|
2187 |
|
2188 |
|
2189 // ----------------------------------------------------------------------------- |
|
2190 // CActivePalette2Model::PaletteAnimTimerCallback() |
|
2191 // ----------------------------------------------------------------------------- |
|
2192 // |
|
2193 TInt CActivePalette2Model::PaletteAnimTimerCallback(TAny* aPtr) |
|
2194 { |
|
2195 CActivePalette2Model* self = (CActivePalette2Model*) aPtr; |
|
2196 |
|
2197 if ( self ) |
|
2198 { |
|
2199 return self->PaletteAnimAction(); |
|
2200 } |
|
2201 else |
|
2202 { |
|
2203 return KCallbackFinished; |
|
2204 } |
|
2205 } |
|
2206 |
|
2207 // ----------------------------------------------------------------------------- |
|
2208 // CActivePalette2Model::PaletteAnimAction() |
|
2209 // ----------------------------------------------------------------------------- |
|
2210 // |
|
2211 TInt CActivePalette2Model::PaletteAnimAction() |
|
2212 { |
|
2213 TInt res = KCallbackCallAgain; |
|
2214 |
|
2215 iPaletteMoveCurrentOffset += iPaletteMoveAnimationDirection; |
|
2216 |
|
2217 if ( (iPaletteMoveCurrentOffset <= 0) || (iPaletteMoveCurrentOffset >= iPaletteMoveOffsetTotalFrames)) |
|
2218 { |
|
2219 res = KCallbackFinished; |
|
2220 SetAnimState(EPaletteAnimIdle); |
|
2221 iModelObserver.PaletteAppearingUpdated(); |
|
2222 } |
|
2223 else |
|
2224 { |
|
2225 iModelObserver.PaletteAppearingUpdated(); |
|
2226 |
|
2227 if ( iCallbacks.iAppearanceDescriptive ) |
|
2228 { |
|
2229 iPaletteMoveTimer->Cancel(); |
|
2230 |
|
2231 if ( iPaletteMoveAnimationDirection > 0 ) |
|
2232 { |
|
2233 // Palette is appearing |
|
2234 iCallbacks.iAppearanceDescriptive->AnimateAppearance(ETrue, |
|
2235 (iPaletteMoveAnimationDuration * (iPaletteMoveOffsetTotalFrames - iPaletteMoveCurrentOffset)) |
|
2236 / iPaletteMoveOffsetTotalFrames); |
|
2237 } |
|
2238 else |
|
2239 { |
|
2240 // Palette is disappearing |
|
2241 iCallbacks.iAppearanceDescriptive->AnimateAppearance(EFalse, |
|
2242 (iPaletteMoveAnimationDuration * (iPaletteMoveCurrentOffset)) |
|
2243 / iPaletteMoveOffsetTotalFrames); |
|
2244 } |
|
2245 |
|
2246 res = KCallbackFinished; |
|
2247 } |
|
2248 } |
|
2249 |
|
2250 return res; |
|
2251 } |
|
2252 |
|
2253 // ----------------------------------------------------------------------------- |
|
2254 // CActivePalette2Model::PaletteAnimComplete() |
|
2255 // ----------------------------------------------------------------------------- |
|
2256 // |
|
2257 void CActivePalette2Model::PaletteAnimComplete() |
|
2258 { |
|
2259 iPaletteMoveTimer->Cancel(); |
|
2260 |
|
2261 if ( iPaletteMoveAnimationDirection > 0 ) |
|
2262 { |
|
2263 iPaletteMoveCurrentOffset = iPaletteMoveOffsetTotalFrames; |
|
2264 } |
|
2265 else |
|
2266 { |
|
2267 iPaletteMoveCurrentOffset = 0; |
|
2268 } |
|
2269 } |
|
2270 |
|
2271 |
|
2272 |
|
2273 |
|
2274 |
|
2275 |
|
2276 |
|
2277 |
|
2278 // ----------------------------------------------------------------------------- |
|
2279 // CActivePalette2Model::AnimateFocusRendererComplete() |
|
2280 // ----------------------------------------------------------------------------- |
|
2281 // |
|
2282 void CActivePalette2Model::AnimateFocusRendererComplete() |
|
2283 { |
|
2284 // Check we're expecting call |
|
2285 if ( iAnimState == EPaletteAnimFocusChange ) |
|
2286 { |
|
2287 SetAnimState(EPaletteAnimItemAnim); |
|
2288 } |
|
2289 } |
|
2290 |
|
2291 // ----------------------------------------------------------------------------- |
|
2292 // CActivePalette2Model::FocusChangeTimerCallback() |
|
2293 // ----------------------------------------------------------------------------- |
|
2294 // |
|
2295 TInt CActivePalette2Model::FocusChangeTimerCallback(TAny* aPtr) |
|
2296 { |
|
2297 CActivePalette2Model* self = (CActivePalette2Model*) aPtr; |
|
2298 |
|
2299 if ( self ) |
|
2300 { |
|
2301 return self->FocusChangeAction(); |
|
2302 } |
|
2303 else |
|
2304 { |
|
2305 return KCallbackFinished; |
|
2306 } |
|
2307 } |
|
2308 |
|
2309 // ----------------------------------------------------------------------------- |
|
2310 // CActivePalette2Model::FocusChangeAction() |
|
2311 // ----------------------------------------------------------------------------- |
|
2312 // |
|
2313 TInt CActivePalette2Model::FocusChangeAction() |
|
2314 { |
|
2315 TInt res = KCallbackCallAgain; |
|
2316 |
|
2317 iFocusedCurrentOffset += iFocusChangeDirection; |
|
2318 |
|
2319 if ( iFocusedCurrentOffset <= 0 || iFocusedCurrentOffset >= NAP2Cfg::KFocusChangeFrames ) |
|
2320 { |
|
2321 res = KCallbackFinished; |
|
2322 SetAnimState(EPaletteAnimItemAnim); |
|
2323 } |
|
2324 else |
|
2325 { |
|
2326 if ( iCallbacks.iFocusTimer ) |
|
2327 { |
|
2328 iCallbacks.iFocusTimer->FocusAnimated(); |
|
2329 } |
|
2330 } |
|
2331 |
|
2332 return res; |
|
2333 } |
|
2334 |
|
2335 // ----------------------------------------------------------------------------- |
|
2336 // CActivePalette2Model::FocusChangeComplete() |
|
2337 // ----------------------------------------------------------------------------- |
|
2338 // |
|
2339 void CActivePalette2Model::FocusChangeComplete() |
|
2340 { |
|
2341 iFocusChangeTimer->Cancel(); |
|
2342 |
|
2343 iFocusedItem = iFocusChangeTargetItem; |
|
2344 iFocusedCurrentOffset = 0; |
|
2345 |
|
2346 FocusedItemUpdated(); |
|
2347 } |
|
2348 |
|
2349 |
|
2350 // End of File |
|