|
1 /* |
|
2 * Copyright (c) 2007-2008 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: base element Implementation |
|
15 * |
|
16 */ |
|
17 |
|
18 // Include Files |
|
19 // Class Headers |
|
20 #include "mulbaseelement.h" |
|
21 |
|
22 #include <AknUtils.h> |
|
23 // Alf Headers |
|
24 #include <alf/alfbatchbuffer.h> |
|
25 #include <alf/alfbrusharray.h> |
|
26 #include <alf/alfgradientbrush.h> |
|
27 #include <alf/alfviewportlayout.h> |
|
28 #include <alf/alftextvisual.h> |
|
29 #include <alf/alfimagevisual.h> |
|
30 #include <alf/alfutil.h> |
|
31 #include <alf/alftransformation.h> |
|
32 |
|
33 // Mul Headers |
|
34 #include "mul/mulmodelutility.h" |
|
35 #include "imulmodelaccessor.h" |
|
36 #include <mul/imulsliderwidget.h> |
|
37 #include <mul/mulevent.h> |
|
38 #include "mulassert.h" |
|
39 #include "mulleave.h" |
|
40 #include "mullog.h" //for logs |
|
41 |
|
42 // Local Cover Flow Headers |
|
43 #include "mulcoverflowcontrol.h" |
|
44 #include "mulcoverflowtemplate.h" |
|
45 |
|
46 namespace Alf |
|
47 { |
|
48 //Internal base element structure implementation |
|
49 struct TMulBaseElementImpl |
|
50 { |
|
51 |
|
52 UString mEmptyText; // empty text to be displayed when number of items is 0. |
|
53 |
|
54 int mPadding; //Padding between item |
|
55 |
|
56 TMulCoverFlowItem mHighlightItemStruct; |
|
57 TMulCoverFlowItem mItemStruct; |
|
58 int mVisibleCount; |
|
59 int mScrollAnimationTime; // animation time for highlight transition set by the application. |
|
60 bool mUiOn; // true if in UiOnMode |
|
61 |
|
62 bool mTextVisible; // not suppose to be displayed in template 4 |
|
63 |
|
64 |
|
65 // To keep a pointer of iconFlow layout.Not owned, created at construction. |
|
66 // The below 4 layouts will never be null. No need to validate before using |
|
67 CAlfFlowLayout* mIconFlowLayout; |
|
68 CAlfLayout* mTextLayout; |
|
69 CAlfFlowLayout* mVerticalFlow; |
|
70 CAlfLayout* mSliderLayout ; // stores visual of the slider widget |
|
71 |
|
72 // Can be null when the template doesnt have counter. |
|
73 CAlfTextVisual* mCounterVisual ; |
|
74 CAlfTextVisual* mEmptyTextVisual; |
|
75 |
|
76 //Stores current slider opacity. |
|
77 float mSliderOpacity; |
|
78 TItemScroll mScrollDir; |
|
79 float mEmptyTextOpacity; |
|
80 // whether to apply default fit mode(fitinside) or not. |
|
81 // if false apply default fit mode , else based on the image size. |
|
82 bool mFitMode; |
|
83 |
|
84 // different visuals color properties |
|
85 TMulVisualColorProperty mIconBgColor; |
|
86 TMulVisualColorProperty mCounterColor; |
|
87 TMulVisualColorProperty mTextColor; |
|
88 TMulRotationProperty mRotation; |
|
89 |
|
90 bool mChangeSize; |
|
91 // whether user has swiped multiple times. |
|
92 TNumberofSwipes mNumSwipes; |
|
93 // total number of digits in counter visual at every highlight. |
|
94 int mNumOfDigitsInCounter; |
|
95 // marquee animation time |
|
96 int mMarqueeAnimTime; |
|
97 // Titletext extents |
|
98 TSize mTitleExt; |
|
99 // Detailtext extents |
|
100 TSize mDetailExt; |
|
101 //Dummy text visual for getting text extents |
|
102 CAlfTextVisual* mDummyVisual; |
|
103 bool mIsMirrored; |
|
104 |
|
105 //Constructor of the structure |
|
106 TMulBaseElementImpl() |
|
107 { |
|
108 //Intialisation |
|
109 mPadding = -1; |
|
110 mNumOfDigitsInCounter = -1; |
|
111 mVisibleCount = 0; |
|
112 mScrollAnimationTime = 200; |
|
113 mEmptyText = ""; |
|
114 mCounterVisual = NULL; |
|
115 mIconFlowLayout = NULL; |
|
116 mTextLayout = NULL; |
|
117 mVerticalFlow = NULL; |
|
118 mSliderLayout = NULL; |
|
119 mEmptyTextVisual = NULL; |
|
120 mSliderOpacity = 0.0f; |
|
121 mTextVisible = true; |
|
122 mScrollDir = EItemNoDirection; |
|
123 mEmptyTextOpacity = 0.0f; |
|
124 mFitMode = false; |
|
125 mUiOn = false; |
|
126 mChangeSize = false; |
|
127 mNumSwipes = ESingleSwipe; |
|
128 mMarqueeAnimTime = 0; |
|
129 mDummyVisual = NULL; |
|
130 mIsMirrored = false; |
|
131 } |
|
132 ~TMulBaseElementImpl() |
|
133 { |
|
134 } |
|
135 }; //end of the structure |
|
136 |
|
137 |
|
138 // --------------------------------------------------------------------------- |
|
139 // MulBaseElement |
|
140 // --------------------------------------------------------------------------- |
|
141 // |
|
142 MulBaseElement::MulBaseElement( CAlfWidgetControl& aControl, |
|
143 const char* aName ) |
|
144 { |
|
145 MUL_LOG_ENTRY_EXIT("aakash::MulBaseElement::MulBaseElement"); |
|
146 mData.reset( new (EMM)TMulBaseElementImpl ); |
|
147 //Call the base class method |
|
148 construct( aControl,aName ); |
|
149 CreateBaseLayoutStructure(); |
|
150 (static_cast<MulCoverFlowControl&>(aControl)).UpdateBaseElement(this); |
|
151 if (AknLayoutUtils::LayoutMirrored()) |
|
152 { |
|
153 mData->mIsMirrored = true; |
|
154 } |
|
155 else |
|
156 { |
|
157 mData->mIsMirrored = false; |
|
158 } |
|
159 } |
|
160 |
|
161 // --------------------------------------------------------------------------- |
|
162 // ~MulBaseElement |
|
163 // --------------------------------------------------------------------------- |
|
164 // |
|
165 MulBaseElement::~MulBaseElement() |
|
166 { |
|
167 // Nothing to delete . |
|
168 } |
|
169 |
|
170 // --------------------------------------------------------------------------- |
|
171 // accept |
|
172 // --------------------------------------------------------------------------- |
|
173 // |
|
174 bool MulBaseElement::accept( CAlfWidgetControl& /*aControl*/, |
|
175 const TAlfEvent& aEvent ) const |
|
176 { |
|
177 MUL_LOG_ENTRY_EXIT("aakash::MulBaseElement::accept"); |
|
178 uint eventID; |
|
179 if(!aEvent.IsCustomEvent()) |
|
180 { |
|
181 return false; |
|
182 } |
|
183 eventID = aEvent.CustomParameter(); |
|
184 |
|
185 //Events handled by the base element |
|
186 if( eventID == ETypeHighlight |
|
187 || eventID == EEventWidgetInitialized |
|
188 || eventID == ETypePrimaryValueChange ) |
|
189 { |
|
190 return true; |
|
191 } |
|
192 else |
|
193 { |
|
194 return false; |
|
195 } |
|
196 } |
|
197 |
|
198 // --------------------------------------------------------------------------- |
|
199 // offerEvent |
|
200 // --------------------------------------------------------------------------- |
|
201 // |
|
202 AlfEventStatus MulBaseElement::offerEvent( CAlfWidgetControl& aControl, |
|
203 const TAlfEvent& aEvent ) |
|
204 { |
|
205 MUL_LOG_ENTRY_EXIT("aakash::MulBaseElement::offerEvent"); |
|
206 if ( !accept( aControl, aEvent ) ) |
|
207 { |
|
208 //return false; |
|
209 return EEventNotHandled; |
|
210 } |
|
211 |
|
212 uint eventID = aEvent.CustomParameter(); |
|
213 |
|
214 MulCoverFlowControl* coverflowControl = static_cast<MulCoverFlowControl*>(&control()); |
|
215 |
|
216 if( eventID == EEventWidgetInitialized ) |
|
217 { |
|
218 // some of the member variable needs to be reset |
|
219 // to support dynamic template change with model change. |
|
220 mData->mNumOfDigitsInCounter = -1; |
|
221 |
|
222 UpdateTextAndCounter(); |
|
223 CalculatePadding(); |
|
224 ArrangeItems(); |
|
225 // Show empty text if coverflow is empty |
|
226 int totalModelCount = coverflowControl->TotalModelCount(); |
|
227 IMulModelAccessor* model = coverflowControl->ModelAccessor(); |
|
228 if( (totalModelCount <= 0) || (model == NULL)) |
|
229 { |
|
230 ShowEmptyText( true ); |
|
231 return EEventConsumed; |
|
232 } |
|
233 else |
|
234 { |
|
235 ShowEmptyText( false ); |
|
236 } |
|
237 return EEventConsumed; |
|
238 } |
|
239 |
|
240 else if( eventID == ETypeHighlight ) |
|
241 { |
|
242 // Update the text and counter values according to the new highlight |
|
243 int newHighlight = coverflowControl->HighlightIndex(); |
|
244 int animationTime = aEvent.CustomEventData(); |
|
245 animationTime = animationTime > 0 ? animationTime : mData->mScrollAnimationTime; |
|
246 |
|
247 if(mData->mScrollDir != EItemNoDirection) |
|
248 { |
|
249 if(coverflowControl->IsFastScrollMode()) |
|
250 { |
|
251 animationTime = coverflowControl->FastScrollTransitionTime(); |
|
252 SetHighlight(newHighlight,animationTime); |
|
253 } |
|
254 else |
|
255 { |
|
256 SetHighlight(newHighlight,animationTime ); |
|
257 } |
|
258 } |
|
259 else |
|
260 { |
|
261 //@TODO: update all the items |
|
262 animationTime = KZeroAnimation; |
|
263 SetHighlight(newHighlight,animationTime); |
|
264 } |
|
265 |
|
266 UpdateTextAndCounter(animationTime); |
|
267 |
|
268 return EEventConsumed; |
|
269 } |
|
270 else if( eventID == ETypePrimaryValueChange ) |
|
271 { |
|
272 IMulSliderModel* mulSliderModel = coverflowControl->GetSliderModel(); |
|
273 if( mulSliderModel ) |
|
274 { |
|
275 int primaryValue = mulSliderModel->PrimaryValue(); |
|
276 coverflowControl->SetHighlightIndex( primaryValue , false); |
|
277 } |
|
278 return EEventConsumed; |
|
279 } |
|
280 |
|
281 return EEventNotHandled; |
|
282 } |
|
283 |
|
284 // --------------------------------------------------------------------------- |
|
285 // setActiveStates |
|
286 // --------------------------------------------------------------------------- |
|
287 // |
|
288 void MulBaseElement::setActiveStates( unsigned int /*aStates*/ ) |
|
289 { |
|
290 //No implementation required |
|
291 } |
|
292 |
|
293 //----------------- Creating the visuals and layout structure ---------------- |
|
294 |
|
295 |
|
296 // --------------------------------------------------------------------------- |
|
297 // CreateBaseLayoutStructure |
|
298 // --------------------------------------------------------------------------- |
|
299 // |
|
300 void MulBaseElement::CreateBaseLayoutStructure() |
|
301 { |
|
302 THROW_IF_LEAVES |
|
303 ( |
|
304 MUL_LOG_ENTRY_EXIT("aakash::MulBaseElement::CreateBaseLayoutStructure"); |
|
305 |
|
306 CAlfLayout* main = CAlfLayout::AddNewL(control()); |
|
307 |
|
308 // set this flag, to recieve layout change events ,that are handled |
|
309 // by the ovverriden VisualLayoutUpdated method of the alfwidgetcontrol. |
|
310 main->SetFlags( EAlfVisualFlagLayoutUpdateNotification ); |
|
311 main->SetTagL( mainlayout ); |
|
312 main->SetFlag(EAlfVisualFlagAutomaticLocaleMirroringEnabled); |
|
313 main->SetClipping(ETrue); |
|
314 |
|
315 CAlfDeckLayout* deckLayout = CAlfDeckLayout::AddNewL( (CAlfControl &)control(),main); |
|
316 deckLayout->SetTagL( decklayout ); |
|
317 deckLayout->SetFlag( EAlfVisualFlagManualLayout ); |
|
318 |
|
319 CAlfGradientBrush* deckBrush = CAlfGradientBrush::NewL( control().Env() ); |
|
320 // Set the brush colour |
|
321 deckBrush->SetColor( KRgbBlack ); |
|
322 deckLayout->EnableBrushesL( ETrue ); |
|
323 // Apply brush and set the opacity . |
|
324 deckLayout->Brushes()->AppendL( deckBrush, EAlfHasOwnership ); |
|
325 deckLayout->SetFlag(EAlfVisualFlagAutomaticLocaleMirroringEnabled); |
|
326 deckLayout->SetClipping(ETrue); |
|
327 |
|
328 |
|
329 // Create a vertical flow layout which has two horizontal layouts |
|
330 mData->mVerticalFlow = CAlfFlowLayout::AddNewL((CAlfControl&)control(), deckLayout ); |
|
331 |
|
332 // Set the Layout Direction |
|
333 mData->mVerticalFlow->SetFlowDirection( CAlfFlowLayout::EFlowVertical ); |
|
334 mData->mVerticalFlow->SetFlag( EAlfVisualFlagManualLayout ); |
|
335 mData->mVerticalFlow->SetTagL( verticalflowlayout ); |
|
336 mData->mVerticalFlow->SetFlag(EAlfVisualFlagAutomaticLocaleMirroringEnabled); |
|
337 |
|
338 // Create flow layout,all the item visuals are added to this layout. |
|
339 // make this layout as the child to the vertical flow layout at index 1. |
|
340 mData->mIconFlowLayout = CAlfFlowLayout::AddNewL( (CAlfControl&)control(), mData->mVerticalFlow ); |
|
341 |
|
342 // Set the Layout Direction |
|
343 mData->mIconFlowLayout->SetFlowDirection( CAlfFlowLayout::EFlowHorizontal ); |
|
344 mData->mIconFlowLayout->SetTagL( iconflowlayout ); |
|
345 mData->mIconFlowLayout->SetFlag(EAlfVisualFlagAutomaticLocaleMirroringEnabled); |
|
346 |
|
347 // stores visuals of all the items(text visuals) |
|
348 mData->mTextLayout = CAlfLayout::AddNewL((CAlfControl&)control(),mData->mVerticalFlow); |
|
349 mData->mTextLayout->SetTagL( textflowlayout ); |
|
350 mData->mTextLayout->SetFlag(EAlfVisualFlagIgnorePointer); |
|
351 mData->mTextLayout->SetFlag( EAlfVisualFlagManualLayout ); |
|
352 mData->mTextLayout->SetFlag(EAlfVisualFlagAutomaticLocaleMirroringEnabled); |
|
353 //Add main layout to the base visual tree |
|
354 addVisualTree( main, KInitialvalueZero ); |
|
355 |
|
356 ); |
|
357 } |
|
358 |
|
359 // --------------------------------------------------------------------------- |
|
360 // SetDefaultSize |
|
361 // --------------------------------------------------------------------------- |
|
362 // |
|
363 void MulBaseElement::SetDefaultSize( TSize aSize ) |
|
364 { |
|
365 MUL_LOG_ENTRY_EXIT("aakash::MulBaseElement::SetDefaultSize"); |
|
366 CAlfLayout* main = (CAlfLayout*)findVisual( KMainLayoutIndex ); |
|
367 main->SetSize(aSize ); |
|
368 CAlfDeckLayout& deckLayout = static_cast<CAlfDeckLayout&> (main->Visual(KMainLayoutIndex) ); |
|
369 deckLayout.SetSize(aSize); |
|
370 CAlfVisual* backgroundVisual = deckLayout.FindTag(backgroundvisual); |
|
371 if(backgroundVisual) |
|
372 { |
|
373 backgroundVisual->SetSize(aSize); |
|
374 } |
|
375 if( mData->mEmptyTextVisual && mData->mEmptyTextOpacity == 1 ) |
|
376 { |
|
377 mData->mEmptyTextVisual->SetSize(aSize); |
|
378 } |
|
379 } |
|
380 |
|
381 // --------------------------------------------------------------------------- |
|
382 // TextAnchorLayout |
|
383 // --------------------------------------------------------------------------- |
|
384 // |
|
385 CAlfLayout& MulBaseElement::TextLayout() |
|
386 { |
|
387 __MUL_ASSERT( mData->mTextLayout != 0,KNullPointer); |
|
388 return *mData->mTextLayout; |
|
389 } |
|
390 |
|
391 |
|
392 //----------------------Empty text related visualisation--------------------- |
|
393 // --------------------------------------------------------------------------- |
|
394 // SetEmptyText |
|
395 // --------------------------------------------------------------------------- |
|
396 // |
|
397 void MulBaseElement::SetEmptyText( const UString& aDefaultText ) |
|
398 { |
|
399 MUL_LOG_ENTRY_EXIT("aakash::MulBaseElement::SetEmptyText"); |
|
400 |
|
401 mData->mEmptyText = aDefaultText; |
|
402 int totalModelCount = ((MulCoverFlowControl*)&control())->TotalModelCount(); |
|
403 |
|
404 if( mData->mEmptyTextVisual ) |
|
405 { |
|
406 THROW_IF_LEAVES |
|
407 ( |
|
408 TBuf<KTempBufferSize> desc; |
|
409 |
|
410 MulModelUtility::ConvertUStringToTDes(mData->mEmptyText, desc); |
|
411 mData->mEmptyTextVisual->SetTextL(desc); |
|
412 ); |
|
413 } |
|
414 |
|
415 if( totalModelCount <= KInitialvalueZero ) |
|
416 { |
|
417 ShowEmptyText( true ); |
|
418 } |
|
419 } |
|
420 |
|
421 // --------------------------------------------------------------------------- |
|
422 // ShowEmptyText |
|
423 // --------------------------------------------------------------------------- |
|
424 // |
|
425 void MulBaseElement::ShowEmptyText( bool aShowText ) |
|
426 { |
|
427 MUL_LOG_ENTRY_EXIT("aakash::MulBaseElement::ShowEmptyText"); |
|
428 |
|
429 // If the application has not set any empty text , then no need to do anything |
|
430 if( mData->mEmptyText.isEmpty() ) |
|
431 { |
|
432 if( aShowText ) |
|
433 { |
|
434 ShowHideVisualsForEmptyText(false); |
|
435 HandleSizeChangeOnMain(); |
|
436 } |
|
437 else |
|
438 { |
|
439 ShowHideVisualsForEmptyText(true); |
|
440 } |
|
441 return; |
|
442 } |
|
443 |
|
444 if( aShowText ) |
|
445 { |
|
446 if( !mData->mEmptyTextVisual ) |
|
447 { |
|
448 CreateEmptyTextVisualisation(); |
|
449 } |
|
450 |
|
451 // This function is called twice only when an empty model is set and the app sets the empty text twice . |
|
452 ShowHideVisualsForEmptyText(false); |
|
453 if( mData->mEmptyTextOpacity == KBackGroundOpacity && mData->mEmptyTextVisual ) |
|
454 { |
|
455 mData->mEmptyTextVisual->SetOpacity(KHighlightOpacity); |
|
456 mData->mEmptyTextOpacity = KHighlightOpacity; |
|
457 } |
|
458 HandleSizeChangeOnMain(); |
|
459 |
|
460 } |
|
461 else |
|
462 { |
|
463 ShowHideVisualsForEmptyText(true); |
|
464 if( mData->mEmptyTextVisual && mData->mEmptyTextOpacity == 1 ) |
|
465 { |
|
466 mData->mEmptyTextVisual->SetOpacity(KBackGroundOpacity); |
|
467 mData->mEmptyTextOpacity = KBackGroundOpacity; |
|
468 } |
|
469 } |
|
470 } |
|
471 |
|
472 // --------------------------------------------------------------------------- |
|
473 // HandleSizeChangeOnMain() |
|
474 // --------------------------------------------------------------------------- |
|
475 // |
|
476 void MulBaseElement::HandleSizeChangeOnMain() |
|
477 { |
|
478 MUL_LOG_ENTRY_EXIT("aakash::MulBaseElement::HandleSizeChangeOnMain"); |
|
479 |
|
480 IMulModelAccessor* model = ((MulCoverFlowControl*)&control())->ModelAccessor(); |
|
481 CAlfLayout* main = (CAlfLayout*)findVisual( KMainLayoutIndex ); |
|
482 TSize topLayoutSize = main->Size().Target().AsSize(); ; |
|
483 |
|
484 if( !model ) |
|
485 { |
|
486 if (topLayoutSize != TSize(0,0)) |
|
487 { |
|
488 SetDefaultSize(topLayoutSize); |
|
489 } |
|
490 else |
|
491 { |
|
492 SetDefaultSize( control().DisplayArea().Size() ); |
|
493 } |
|
494 |
|
495 } |
|
496 else |
|
497 { |
|
498 SetDefaultSize(topLayoutSize); |
|
499 } |
|
500 } |
|
501 |
|
502 // --------------------------------------------------------------------------- |
|
503 // IsEmptyText |
|
504 // --------------------------------------------------------------------------- |
|
505 // |
|
506 bool MulBaseElement::IsEmptyText() |
|
507 { |
|
508 return !(mData->mEmptyText.isEmpty()); |
|
509 } |
|
510 // --------------------------------------------------------------------------- |
|
511 // ShowHideVisualsForEmptyText |
|
512 // --------------------------------------------------------------------------- |
|
513 // |
|
514 void MulBaseElement::ShowHideVisualsForEmptyText( bool aShow ) |
|
515 { |
|
516 MUL_LOG_ENTRY_EXIT("aakash::MulBaseElement::ShowHideVisualsForEmptyText"); |
|
517 |
|
518 if( !aShow ) |
|
519 { |
|
520 SetTextVisualOpacity( KBackGroundOpacity ); |
|
521 SetCounterTextOpacity( KBackGroundOpacity); |
|
522 } |
|
523 else |
|
524 { |
|
525 if(mData->mTextVisible) |
|
526 { |
|
527 SetTextVisualOpacity( KHighlightOpacity ); |
|
528 } |
|
529 // if ui on off template is enabled then reset the counter |
|
530 // opacity depending on the current ui on/off value |
|
531 if( Template2D()->IsUiOnOffFlagEnabled() ) |
|
532 { |
|
533 ResetUiOnOff(); |
|
534 } |
|
535 else |
|
536 { |
|
537 SetCounterTextOpacity( KHighlightOpacity); |
|
538 } |
|
539 } |
|
540 } |
|
541 |
|
542 // --------------------------------------------------------------------------- |
|
543 // CreateEmptyTextVisualisation |
|
544 // --------------------------------------------------------------------------- |
|
545 // |
|
546 void MulBaseElement::CreateEmptyTextVisualisation() |
|
547 { |
|
548 MUL_LOG_ENTRY_EXIT("aakash::MulBaseElement::CreateEmptyTextVisualisation"); |
|
549 |
|
550 if( !mData->mEmptyTextVisual ) |
|
551 { |
|
552 THROW_IF_LEAVES |
|
553 ( |
|
554 CAlfLayout* main = static_cast<CAlfLayout*>(findVisual( KMainLayoutIndex )); |
|
555 mData->mEmptyTextVisual = CAlfTextVisual::AddNewL(control(),main); |
|
556 |
|
557 TBuf<KTempBufferSize> desc; |
|
558 |
|
559 MulModelUtility::ConvertUStringToTDes(mData->mEmptyText, desc); |
|
560 mData->mEmptyTextVisual->SetTextL(desc); |
|
561 mData->mEmptyTextVisual->SetTagL(KEmptyText); |
|
562 mData->mEmptyTextVisual->SetWrapping(CAlfTextVisual::ELineWrapBreak); |
|
563 |
|
564 TInt fontId =control().Env().TextStyleManager() |
|
565 .CreatePlatformTextStyleL(EAknLogicalFontSecondaryFont,-1); |
|
566 // check if user has set any different color for text. |
|
567 if (mData->mTextColor.mIsColorSet) |
|
568 { |
|
569 // apply the color set by the application |
|
570 mData->mEmptyTextVisual->SetColor(mData->mTextColor.mColor); |
|
571 } |
|
572 else |
|
573 { |
|
574 // apply the default color |
|
575 mData->mEmptyTextVisual->SetColor(KRgbWhite); |
|
576 } |
|
577 |
|
578 mData->mEmptyTextVisual->SetLineSpacing(KTextRowsz); |
|
579 mData->mEmptyTextVisual->SetTextStyle(fontId); |
|
580 mData->mEmptyTextVisual->SetFlag(EAlfVisualFlagIgnorePointer); |
|
581 ); |
|
582 |
|
583 } |
|
584 } |
|
585 |
|
586 |
|
587 |
|
588 // --------------------------------------------------------------------------- |
|
589 // DisplayIndicatorIcon |
|
590 // --------------------------------------------------------------------------- |
|
591 // |
|
592 void MulBaseElement::DisplayIndicatorIcon(const MulVisualItem & aVisualItem, int aIndex) |
|
593 { |
|
594 MUL_LOG_ENTRY_EXIT("aakash::MulBaseElement::DisplayIndicatorIcon"); |
|
595 CAlfDeckLayout& layout = static_cast<CAlfDeckLayout&>(mData->mIconFlowLayout->Visual(aIndex)); |
|
596 CAlfImageVisual* visual =static_cast<CAlfImageVisual*>(layout.FindTag(KCoverflowIndicator)); |
|
597 IMulVariantType* varData = aVisualItem.Attribute(mulvisualitem::KMulIndicator2); |
|
598 |
|
599 if(varData) |
|
600 { |
|
601 if(!visual) |
|
602 { |
|
603 visual = CreateIndicatorIconVisual(layout); |
|
604 } |
|
605 ((MulCoverFlowControl*)&control())->DoSetImage(varData,visual); |
|
606 visual->ClearFlag(EAlfVisualFlagIgnorePointer); |
|
607 } |
|
608 |
|
609 else if(visual) |
|
610 { |
|
611 CAlfTextureManager& textureMgr = control().Env().TextureManager(); |
|
612 TAlfImage image = TAlfImage(textureMgr.BlankTexture()); |
|
613 visual->SetImage(image); |
|
614 visual->SetFlag(EAlfVisualFlagIgnorePointer); |
|
615 } |
|
616 |
|
617 } |
|
618 |
|
619 // --------------------------------------------------------------------------- |
|
620 // CreateIndicatorIconVisual |
|
621 // --------------------------------------------------------------------------- |
|
622 // |
|
623 CAlfImageVisual* MulBaseElement::CreateIndicatorIconVisual(CAlfDeckLayout& aLayout) |
|
624 { |
|
625 MUL_LOG_ENTRY_EXIT("aakash::MulBaseElement::CreateIndicatorIconVisual"); |
|
626 CAlfImageVisual* indicatorVisual = CAlfImageVisual::AddNewL(control(), &aLayout); |
|
627 indicatorVisual->SetTagL(KCoverflowIndicator); |
|
628 SetIndicatorDimensions(*indicatorVisual); |
|
629 indicatorVisual->SetScaleMode(CAlfImageVisual::EScaleNormal); |
|
630 |
|
631 return indicatorVisual; |
|
632 } |
|
633 |
|
634 // --------------------------------------------------------------------------- |
|
635 // SetIndicatorDimensions |
|
636 // --------------------------------------------------------------------------- |
|
637 // |
|
638 void MulBaseElement::SetIndicatorDimensions(CAlfImageVisual& aIndicatorVisual) |
|
639 { |
|
640 MUL_LOG_ENTRY_EXIT("aakash::MulBaseElement::SetIndicatorDimensions"); |
|
641 TMulCoverFlowItem indicatorDimensions = Template2D()->IndicatorDimension(); |
|
642 aIndicatorVisual.SetPos(TAlfRealPoint(indicatorDimensions.posx,indicatorDimensions.posy)); |
|
643 aIndicatorVisual.SetSize(TAlfRealSize(indicatorDimensions.width ,indicatorDimensions.height)); |
|
644 } |
|
645 |
|
646 // --------------------------------------------------------------------------- |
|
647 // StoreVisualDimensions |
|
648 // --------------------------------------------------------------------------- |
|
649 // |
|
650 void MulBaseElement::StoreVisualDimensions( TMulCoverFlowItem aHighlightItemDimensions, TMulCoverFlowItem aNonHighlightItemDimensions,int aVisibleIconCount ) |
|
651 { |
|
652 MUL_LOG_ENTRY_EXIT("aakash::MulBaseElement::StoreVisualDimensions"); |
|
653 mData->mHighlightItemStruct = aHighlightItemDimensions; |
|
654 mData->mItemStruct = aNonHighlightItemDimensions; |
|
655 mData->mVisibleCount = aVisibleIconCount; |
|
656 ((MulCoverFlowControl*)&control())->StoreVisibleItemCount(mData->mVisibleCount); |
|
657 if (mData->mVisibleCount > 1) |
|
658 { |
|
659 mData->mChangeSize = true; |
|
660 } |
|
661 else |
|
662 { |
|
663 mData->mChangeSize = false; |
|
664 } |
|
665 } |
|
666 |
|
667 // --------------------------------------------------------------------------- |
|
668 // StoreTextVisibility |
|
669 // --------------------------------------------------------------------------- |
|
670 // |
|
671 void MulBaseElement::StoreTextVisibility( bool aIsTextVisible ) |
|
672 { |
|
673 MUL_LOG_ENTRY_EXIT("aakash::MulBaseElement::StoreTextVisibility"); |
|
674 mData->mTextVisible = aIsTextVisible; |
|
675 } |
|
676 |
|
677 |
|
678 // --------------------------------------------------------------------------- |
|
679 // IsTextVisibile |
|
680 // --------------------------------------------------------------------------- |
|
681 // |
|
682 bool MulBaseElement::IsTextVisibile( )const |
|
683 { |
|
684 MUL_LOG_ENTRY_EXIT("aakash::MulBaseElement::IsTextVisible"); |
|
685 return mData->mTextVisible ; |
|
686 } |
|
687 |
|
688 |
|
689 // --------------------------------------------------------------------------- |
|
690 // OrientationChange |
|
691 // --------------------------------------------------------------------------- |
|
692 // |
|
693 void MulBaseElement::OrientationChange() |
|
694 { |
|
695 MUL_LOG_ENTRY_EXIT("aakash::MulBaseElement::OrientationChange"); |
|
696 |
|
697 mData->mVerticalFlow->SetOpacity(0); |
|
698 if (mData->mDummyVisual) |
|
699 { |
|
700 // deleting since the textextents being zero. |
|
701 mData->mDummyVisual->RemoveAndDestroyAllD(); |
|
702 mData->mDummyVisual = NULL; |
|
703 } |
|
704 |
|
705 // update the attribute of visuals |
|
706 Template2D()->CreateVisualisation(((MulCoverFlowControl*)&control())->IsLandscape(),true); |
|
707 |
|
708 CalculatePadding(); |
|
709 CreateAndInitializeVisuals(true); |
|
710 |
|
711 // Redraw the visuals after orientation changes |
|
712 int totalModelCount = ((MulCoverFlowControl*)&control())->TotalModelCount(); |
|
713 if( totalModelCount == 0 ) |
|
714 { |
|
715 CAlfLayout* main = (CAlfLayout*)findVisual( KMainLayoutIndex ); |
|
716 SetDefaultSize(main->Size().ValueNow().AsSize()); |
|
717 } |
|
718 ArrangeItems(); |
|
719 SetNewCounterPosition(Template2D()->CounterDimensions(),true); |
|
720 UpdateRotation(); |
|
721 mData->mVerticalFlow->SetOpacity(1); |
|
722 } |
|
723 |
|
724 |
|
725 //------------------Counter and Text related---------------------------------- |
|
726 |
|
727 // --------------------------------------------------------------------------- |
|
728 // CreateCounterVisual |
|
729 // --------------------------------------------------------------------------- |
|
730 // |
|
731 CAlfTextVisual& MulBaseElement::CounterVisual() |
|
732 { |
|
733 MUL_LOG_ENTRY_EXIT("aakash::MulBaseElement::CounterVisual"); |
|
734 __MUL_ASSERT( mData->mVerticalFlow != 0,KNullPointer); |
|
735 |
|
736 mData->mCounterVisual = &CreateTextVisual(KCoverflowCounter,*mData->mVerticalFlow); |
|
737 mData->mCounterVisual->SetAlign(EAlfAlignHCenter,EAlfAlignVCenter); |
|
738 return *mData->mCounterVisual; |
|
739 } |
|
740 |
|
741 // --------------------------------------------------------------------------- |
|
742 // CreateVisual |
|
743 // --------------------------------------------------------------------------- |
|
744 // |
|
745 CAlfTextVisual& MulBaseElement::CreateTextVisual(const TDesC8& aName, |
|
746 CAlfLayout& aLayout) |
|
747 { |
|
748 MUL_LOG_ENTRY_EXIT("aakash::MulBaseElement::CreateTextVisual"); |
|
749 |
|
750 CAlfTextVisual* textVisual =static_cast<CAlfTextVisual*>(aLayout.FindTag(aName)); |
|
751 |
|
752 if(textVisual == NULL) |
|
753 { |
|
754 THROW_IF_LEAVES |
|
755 ( |
|
756 textVisual = CAlfTextVisual::AddNewL( (CAlfControl &)control(),&aLayout); |
|
757 textVisual->SetTagL(aName); |
|
758 ); |
|
759 textVisual->SetFlag(EAlfVisualFlagIgnorePointer); |
|
760 textVisual->SetFlag(EAlfVisualFlagClipping); |
|
761 } |
|
762 return *textVisual; |
|
763 } |
|
764 |
|
765 |
|
766 // --------------------------------------------------------------------------- |
|
767 // UpdateTextAndCounter |
|
768 // --------------------------------------------------------------------------- |
|
769 // |
|
770 void MulBaseElement::UpdateTextAndCounter(int animationTime) |
|
771 { |
|
772 MUL_LOG_ENTRY_EXIT("aakash::MulBaseElement::UpdateTextAndCounter"); |
|
773 |
|
774 UpdateTextValue(animationTime); |
|
775 |
|
776 //After highlight is changed then the counter text should be updated |
|
777 SetCounterText(); |
|
778 } |
|
779 |
|
780 // --------------------------------------------------------------------------- |
|
781 // SetCounterTextOpacity |
|
782 // --------------------------------------------------------------------------- |
|
783 // |
|
784 void MulBaseElement::SetCounterTextOpacity( int aOpacity) |
|
785 { |
|
786 MUL_LOG_ENTRY_EXIT("aakash::MulBaseElement::SetCounterTextOpacity"); |
|
787 if(mData->mCounterVisual) |
|
788 { |
|
789 mData->mCounterVisual->SetOpacity( aOpacity ); |
|
790 } |
|
791 } |
|
792 |
|
793 |
|
794 // --------------------------------------------------------------------------- |
|
795 // ResetUiOnOff |
|
796 // --------------------------------------------------------------------------- |
|
797 // |
|
798 void MulBaseElement::ResetUiOnOff(int aTransitionTime) |
|
799 { |
|
800 MUL_LOG_ENTRY_EXIT("aakash::MulBaseElement::ResetUiOnOff"); |
|
801 |
|
802 int totalModelCount = ((MulCoverFlowControl*)&control())->TotalModelCount(); |
|
803 if(mData->mCounterVisual && Template2D() && Template2D()->IsUiOnOffFlagEnabled() && totalModelCount>0 ) |
|
804 { |
|
805 int opacity = mData->mUiOn? KHighlightOpacity: KBackGroundOpacity; |
|
806 mData->mCounterVisual->SetOpacity( TAlfTimedValue(opacity,aTransitionTime) ); |
|
807 // Every time In template4 Ui on off mode toggles we should set the enable holding flag |
|
808 // to gesture helper to recieve the hold events. |
|
809 ((MulCoverFlowControl*)&control())->SetHoldingEnabled(); |
|
810 } |
|
811 } |
|
812 |
|
813 // --------------------------------------------------------------------------- |
|
814 // UIOnOffMode |
|
815 // --------------------------------------------------------------------------- |
|
816 // |
|
817 void MulBaseElement::UIOnOffMode(bool aUiOn, int aTransitionTime) |
|
818 { |
|
819 MUL_LOG_ENTRY_EXIT("aakash::MulBaseElement::UIOnOffMode"); |
|
820 |
|
821 mData->mUiOn = aUiOn; |
|
822 ResetUiOnOff( aTransitionTime ); |
|
823 } |
|
824 |
|
825 // --------------------------------------------------------------------------- |
|
826 // IsUiOnMode |
|
827 // --------------------------------------------------------------------------- |
|
828 // |
|
829 bool MulBaseElement::IsUiOnMode() |
|
830 { |
|
831 return mData->mUiOn; |
|
832 } |
|
833 |
|
834 |
|
835 // --------------------------------------------------------------------------- |
|
836 // SetTextVisualOpacity |
|
837 // --------------------------------------------------------------------------- |
|
838 // |
|
839 void MulBaseElement::SetTextVisualOpacity( int aOpacity , int aTransitionTime ) |
|
840 { |
|
841 MUL_LOG_ENTRY_EXIT("aakash::MulBaseElement::SetTextVisualOpacity"); |
|
842 if(mData->mTextLayout) |
|
843 { |
|
844 mData->mTextLayout->SetOpacity(TAlfTimedValue (aOpacity,aTransitionTime)); |
|
845 } |
|
846 } |
|
847 |
|
848 // --------------------------------------------------------------------------- |
|
849 // UpdateTextValue |
|
850 // --------------------------------------------------------------------------- |
|
851 // |
|
852 void MulBaseElement::UpdateTextValue(int aAnimationTime) |
|
853 { |
|
854 MUL_LOG_ENTRY_EXIT("Mul::MulBaseElement::UpdateTextValue"); |
|
855 if( !mData->mTextVisible ) |
|
856 { |
|
857 return; |
|
858 } |
|
859 |
|
860 IMulModelAccessor* modelAccessor = ((MulCoverFlowControl*)&control())->ModelAccessor(); |
|
861 int highlightindex = static_cast<MulCoverFlowControl*>(&control())->HighlightIndex(); |
|
862 |
|
863 if(highlightindex>=0 ) |
|
864 { |
|
865 //set text to title |
|
866 try |
|
867 { |
|
868 const MulVisualItem& item = modelAccessor->Item(highlightindex); |
|
869 IMulVariantType* varData = item.Attribute(mulvisualitem::KMulTitle); |
|
870 MUL_LOG_INFO("MUL::UpdateTextValue::UpdateTiltle"); |
|
871 SetTextToVisual( mulvisualitem::KMulTitle, varData ); |
|
872 |
|
873 // SetVirtualSize if required. |
|
874 SetVirtualViewPortSize(mulvisualitem::KMulTitle); |
|
875 } |
|
876 catch(...) |
|
877 { |
|
878 IMulVariantType* varData = NULL; |
|
879 SetTextToVisual( mulvisualitem::KMulTitle, varData ); |
|
880 } |
|
881 |
|
882 //set text to detail |
|
883 try |
|
884 { |
|
885 const MulVisualItem& item = modelAccessor->Item(highlightindex); |
|
886 IMulVariantType* varData = item.Attribute(mulvisualitem::KMulDetail); |
|
887 MUL_LOG_INFO("MUL::UpdateTextValue::UpdateDetail"); |
|
888 SetTextToVisual( mulvisualitem::KMulDetail, varData ); |
|
889 |
|
890 // SetVirtualSize if required. |
|
891 SetVirtualViewPortSize(mulvisualitem::KMulDetail); |
|
892 } |
|
893 catch(...) |
|
894 { |
|
895 IMulVariantType* varData = NULL; |
|
896 SetTextToVisual( mulvisualitem::KMulDetail,varData ); |
|
897 } |
|
898 |
|
899 // Cancel if any command is in process before start marquee. |
|
900 CancelAllCommands(); |
|
901 |
|
902 // Before orientaion change stop marquee on the text |
|
903 if(!((static_cast<MulCoverFlowControl&>(control())).IsFastScrollMode())) |
|
904 { |
|
905 control().Env().Send( |
|
906 TAlfCustomEventCommand(ECustomEventMarqueeStart, |
|
907 &control()), KMarqueeTime1000 + aAnimationTime); |
|
908 |
|
909 } |
|
910 } |
|
911 } |
|
912 // --------------------------------------------------------------------------- |
|
913 // SetTextToVisual |
|
914 // --------------------------------------------------------------------------- |
|
915 // |
|
916 void MulBaseElement::SetTextToVisual( mulvisualitem::TVisualAttribute aName,IMulVariantType* aText ) |
|
917 { |
|
918 MUL_LOG_ENTRY_EXIT("Mul::MulBaseElement::SetTextToVisual"); |
|
919 |
|
920 if(mData->mTextLayout) |
|
921 { |
|
922 CAlfTextVisual* textVisual = |
|
923 static_cast<CAlfTextVisual*> (mData->mTextLayout->FindTag( IdToTag(aName) )); |
|
924 |
|
925 if(textVisual) |
|
926 { |
|
927 if ( aText ) |
|
928 { |
|
929 // set text to visual |
|
930 THROW_IF_LEAVES |
|
931 ( |
|
932 MUL_LOG_INFO("MUL::SetTextToVisual::Set New Data"); |
|
933 textVisual->SetTextL(aText->DesC()); |
|
934 textVisual->SetWrapping(CAlfTextVisual::ELineWrapTruncate); |
|
935 ); |
|
936 // A workaround till the text visual starts giving the correct text extents value. |
|
937 if(!mData->mDummyVisual) |
|
938 { |
|
939 mData->mDummyVisual = CAlfTextVisual::AddNewL(control(), NULL); |
|
940 mData->mDummyVisual->SetWrapping(CAlfTextVisual::ELineWrapManual); |
|
941 mData->mDummyVisual->SetOpacity(0); |
|
942 mData->mDummyVisual->SetFlags(EAlfVisualFlagIgnorePointer); |
|
943 } |
|
944 |
|
945 // Setting the style same as our text visual. |
|
946 mData->mDummyVisual->SetTextStyle(textVisual->TextStyle()); |
|
947 mData->mDummyVisual->SetTextL(aText->DesC()); // Setting the text |
|
948 |
|
949 if(aName == mulvisualitem::KMulDetail) |
|
950 { |
|
951 mData->mDetailExt = mData->mDummyVisual->TextExtents(); |
|
952 } |
|
953 else |
|
954 { |
|
955 mData->mTitleExt = mData->mDummyVisual->TextExtents(); |
|
956 } |
|
957 } |
|
958 else |
|
959 { |
|
960 // reset to null value . |
|
961 THROW_IF_LEAVES |
|
962 ( |
|
963 textVisual->SetTextL(_L("")); |
|
964 ); |
|
965 } |
|
966 } |
|
967 else |
|
968 { |
|
969 mData->mTextLayout->SetOpacity(TAlfTimedValue(KBackGroundOpacity,0)); |
|
970 } |
|
971 } |
|
972 } |
|
973 |
|
974 // --------------------------------------------------------------------------- |
|
975 // SetVirtualViewPortSize() |
|
976 // --------------------------------------------------------------------------- |
|
977 // |
|
978 void MulBaseElement::SetVirtualViewPortSize(mulvisualitem::TVisualAttribute aName) |
|
979 { |
|
980 MUL_LOG_ENTRY_EXIT("Mul::MulBaseElement::SetVirtualViewPortSize"); |
|
981 CAlfViewportLayout* viewportLayout = NULL ; |
|
982 CAlfTextVisual* text = NULL ; |
|
983 TSize textExtent ; |
|
984 TSize parentSize; |
|
985 if (aName == mulvisualitem::KMulDetail) |
|
986 { |
|
987 viewportLayout = static_cast<CAlfViewportLayout*>( |
|
988 mData->mTextLayout->FindTag(KDetailViewPortLayout)); |
|
989 if(!viewportLayout) |
|
990 { |
|
991 return; // return if no viewport |
|
992 } |
|
993 textExtent = mData->mDetailExt; |
|
994 parentSize = Template2D()->DetailWindowSize(); |
|
995 |
|
996 } |
|
997 else |
|
998 { |
|
999 viewportLayout = static_cast<CAlfViewportLayout*>( |
|
1000 mData->mTextLayout->FindTag(KTitleViewPortLayout)); |
|
1001 if(!viewportLayout) |
|
1002 { |
|
1003 return; // return if no viewport |
|
1004 } |
|
1005 textExtent = mData->mTitleExt; |
|
1006 parentSize = Template2D()->TitleWindowSize(); |
|
1007 |
|
1008 } |
|
1009 text = static_cast<CAlfTextVisual*>( |
|
1010 viewportLayout->FindTag( IdToTag(aName) )); |
|
1011 if(!text) |
|
1012 { |
|
1013 return; // if text visual is not found we will not set viewportsize. |
|
1014 } |
|
1015 |
|
1016 viewportLayout->SetViewportPos((TAlfRealPoint(0, 0)), 0); |
|
1017 viewportLayout->SetVirtualSize( |
|
1018 (TAlfRealPoint(parentSize.iWidth, parentSize.iHeight)),0); |
|
1019 |
|
1020 //Tollerance is 15 pixel, it might happen that |
|
1021 // the text is big but while wrapping it not filling the whole |
|
1022 // width of the layout because the remaining space is less to |
|
1023 // accomodate a character. |
|
1024 // As for QFN_PRIMARY the max character width is 15 pixel |
|
1025 // so I am keeping tollerance as 15 |
|
1026 // @TODO: Insted of hard coding to 15 pixel use max charecter |
|
1027 // width for QFN_PRIMARY. |
|
1028 if ((parentSize.iWidth - textExtent.iWidth) > 15) |
|
1029 { |
|
1030 text->SetAlign(EAlfAlignHCenter, EAlfAlignVCenter); |
|
1031 } |
|
1032 else |
|
1033 { |
|
1034 text->SetAlign(EAlfAlignHLocale,EAlfAlignVCenter); |
|
1035 } |
|
1036 } |
|
1037 |
|
1038 // --------------------------------------------------------------------------- |
|
1039 // StartMarquee() |
|
1040 // --------------------------------------------------------------------------- |
|
1041 // |
|
1042 void MulBaseElement::StartMarquee(mulvisualitem::TVisualAttribute aName) |
|
1043 { |
|
1044 MUL_LOG_ENTRY_EXIT("Mul::MulBaseElement::StartMarquee"); |
|
1045 // start marquee. |
|
1046 int widthOffScreen = 0; |
|
1047 CAlfViewportLayout* viewportLayout = NULL ; |
|
1048 CAlfTextVisual* text = NULL ; |
|
1049 TSize textExtent ; |
|
1050 TSize parentSize; |
|
1051 int maxCharWidth ; |
|
1052 if (aName == mulvisualitem::KMulDetail) |
|
1053 { |
|
1054 viewportLayout =static_cast<CAlfViewportLayout*>( |
|
1055 mData->mTextLayout->FindTag(KDetailViewPortLayout)); |
|
1056 if(!viewportLayout) |
|
1057 { |
|
1058 return;// return if no viewport |
|
1059 } |
|
1060 textExtent = mData->mDetailExt; |
|
1061 parentSize = Template2D()->DetailWindowSize(); |
|
1062 maxCharWidth = Template2D()->DetailMaxCharWidth(); |
|
1063 } |
|
1064 else |
|
1065 { |
|
1066 viewportLayout = static_cast<CAlfViewportLayout*>( |
|
1067 mData->mTextLayout->FindTag(KTitleViewPortLayout)); |
|
1068 if(!viewportLayout) |
|
1069 { |
|
1070 return;// return if no viewport |
|
1071 } |
|
1072 textExtent = mData->mTitleExt; |
|
1073 parentSize = Template2D()->TitleWindowSize(); |
|
1074 maxCharWidth = Template2D()->TitleMaxCharWidth(); |
|
1075 } |
|
1076 text = static_cast<CAlfTextVisual*>( |
|
1077 viewportLayout->FindTag( IdToTag(aName) )); |
|
1078 if(!text) |
|
1079 { |
|
1080 return; // if no text. |
|
1081 } |
|
1082 |
|
1083 text->SetWrapping(CAlfTextVisual::ELineWrapManual); |
|
1084 |
|
1085 widthOffScreen= textExtent.iWidth - parentSize.iWidth; |
|
1086 int nDbMaxChars = (widthOffScreen/(2*maxCharWidth)) + 1; |
|
1087 |
|
1088 // Schedule a update event, when the visual has finished marquee text scrolling. |
|
1089 if (aName == mulvisualitem::KMulDetail) |
|
1090 { |
|
1091 if (nDbMaxChars > 0 ) |
|
1092 { |
|
1093 viewportLayout->SetVirtualSize( |
|
1094 (TAlfRealPoint(textExtent.iWidth, parentSize.iHeight)),0); |
|
1095 // to avoid negative time value |
|
1096 mData->mMarqueeAnimTime = (nDbMaxChars*KMarqueeTime1000); |
|
1097 viewportLayout->SetViewportPos((TAlfRealPoint(widthOffScreen , 0)), |
|
1098 nDbMaxChars * KMarqueeTime1000); |
|
1099 // delay after completion of the marquee for titlte. |
|
1100 mData->mMarqueeAnimTime += KMarqueeTime1000; |
|
1101 control().Env().Send( |
|
1102 TAlfCustomEventCommand(ECustomEventMarqueeFinished, |
|
1103 static_cast<CAlfControl*>(&(control()))), |
|
1104 mData->mMarqueeAnimTime); |
|
1105 } |
|
1106 } |
|
1107 else |
|
1108 { |
|
1109 // reset the marquee animation time |
|
1110 mData->mMarqueeAnimTime = 0; |
|
1111 if(nDbMaxChars > 0) |
|
1112 { |
|
1113 viewportLayout->SetVirtualSize( |
|
1114 (TAlfRealPoint(textExtent.iWidth, parentSize.iHeight)),0); |
|
1115 |
|
1116 // to avoid negative time value |
|
1117 mData->mMarqueeAnimTime = (nDbMaxChars*KMarqueeTime1000); |
|
1118 viewportLayout->SetViewportPos((TAlfRealPoint(widthOffScreen , 0)), |
|
1119 nDbMaxChars * KMarqueeTime1000); |
|
1120 // delay after completion of the marquee for titlte. |
|
1121 mData->mMarqueeAnimTime += KMarqueeTime1000; |
|
1122 control().Env().Send( |
|
1123 TAlfCustomEventCommand(ECustomEventTitleMarqueeFinished, |
|
1124 static_cast<CAlfControl*>(&(control()))), |
|
1125 mData->mMarqueeAnimTime ); |
|
1126 // delay before start the marquee for detail. |
|
1127 mData->mMarqueeAnimTime += KMarqueeTime1000; |
|
1128 } |
|
1129 control().Env().Send( |
|
1130 TAlfCustomEventCommand(ECustomEventDetailMarqueeStart, |
|
1131 (&(control()))), mData->mMarqueeAnimTime ); |
|
1132 } |
|
1133 } |
|
1134 |
|
1135 // --------------------------------------------------------------------------- |
|
1136 // StopMarquee() |
|
1137 // --------------------------------------------------------------------------- |
|
1138 // |
|
1139 void MulBaseElement::StopMarquee(mulvisualitem::TVisualAttribute aName) |
|
1140 { |
|
1141 MUL_LOG_ENTRY_EXIT("Mul::MulBaseElement::StopMarquee"); |
|
1142 CAlfViewportLayout* viewPortLayout = NULL; |
|
1143 CAlfTextVisual* text = NULL; |
|
1144 TSize parentSize; |
|
1145 if (aName == mulvisualitem::KMulDetail) |
|
1146 { |
|
1147 viewPortLayout = |
|
1148 static_cast<CAlfViewportLayout*>(mData->mTextLayout->FindTag(KDetailViewPortLayout)); |
|
1149 parentSize = Template2D()->DetailWindowSize(); |
|
1150 } |
|
1151 else |
|
1152 { |
|
1153 viewPortLayout = |
|
1154 static_cast<CAlfViewportLayout*>(mData->mTextLayout->FindTag(KTitleViewPortLayout)); |
|
1155 parentSize = Template2D()->TitleWindowSize(); |
|
1156 } |
|
1157 if(!viewPortLayout) |
|
1158 { |
|
1159 return; |
|
1160 } |
|
1161 text = static_cast<CAlfTextVisual*>(viewPortLayout->FindTag( IdToTag(aName) )); |
|
1162 if(!text) |
|
1163 { |
|
1164 return; |
|
1165 } |
|
1166 const TDesC textDesc = text->Text(); |
|
1167 if(!textDesc.Length()) |
|
1168 { |
|
1169 return; |
|
1170 } |
|
1171 |
|
1172 viewPortLayout->SetViewportPos((TAlfRealPoint(0, 0)), 0); |
|
1173 viewPortLayout->SetVirtualSize((TAlfRealPoint(parentSize.iWidth, parentSize.iHeight)),0); |
|
1174 text->SetWrapping(CAlfTextVisual::ELineWrapTruncate); |
|
1175 |
|
1176 } |
|
1177 |
|
1178 // --------------------------------------------------------------------------- |
|
1179 // CancelAllCommands |
|
1180 // --------------------------------------------------------------------------- |
|
1181 // |
|
1182 void MulBaseElement::CancelAllCommands( ) |
|
1183 { |
|
1184 MUL_LOG_ENTRY_EXIT("Mul::MulBaseElement::CancelAllCommands"); |
|
1185 CAlfWidgetControl * cntrl = &control(); |
|
1186 control().Env().CancelCustomCommands( cntrl, ECustomEventMarqueeFinished); |
|
1187 control().Env().CancelCustomCommands( cntrl, ECustomEventMarqueeStart); |
|
1188 control().Env().CancelCustomCommands( cntrl, ECustomEventTitleMarqueeFinished); |
|
1189 control().Env().CancelCustomCommands( cntrl, ECustomEventDetailMarqueeStart); |
|
1190 } |
|
1191 |
|
1192 // --------------------------------------------------------------------------- |
|
1193 // SetCounterText |
|
1194 // --------------------------------------------------------------------------- |
|
1195 // |
|
1196 void MulBaseElement::SetCounterText( int /*aTransitionTime*/ ) |
|
1197 { |
|
1198 MUL_LOG_ENTRY_EXIT("aakash::MulBaseElement::SetCounterText"); |
|
1199 |
|
1200 if( mData->mCounterVisual ) |
|
1201 { |
|
1202 SetNewCounterPosition(Template2D()->CounterDimensions()); |
|
1203 int totalModelCount = ((MulCoverFlowControl*)&control())->TotalModelCount(); |
|
1204 int currHighlightIndex = ((MulCoverFlowControl*)&control())->HighlightIndex(); |
|
1205 |
|
1206 // this code will work for model count upto 99999. |
|
1207 // done for performance improvement , no need to calculate |
|
1208 // no of digits in highlight index and total model count. |
|
1209 auto_ptr<HBufC> countbuffer(HBufC::NewL (12)); |
|
1210 |
|
1211 //settin value for counter text visual |
|
1212 /// @bug critical:avanhata:7/7/2008 in arabic/hebrew the text should flow |
|
1213 /// from right to left (totalCount / highlight) => the string format needs |
|
1214 /// to come from a resource file, and use stringloader (and arabic indic number |
|
1215 /// conversion if stringloader does not do it automatically) |
|
1216 countbuffer->Des().AppendNum(currHighlightIndex+1); |
|
1217 countbuffer->Des().Append(KSlash); |
|
1218 countbuffer->Des().AppendNum(totalModelCount); |
|
1219 |
|
1220 mData->mCounterVisual->SetTextL(*countbuffer); |
|
1221 } |
|
1222 } |
|
1223 |
|
1224 //-------------------------------------------------------------------------- |
|
1225 // SetNewCounterPosition |
|
1226 //-------------------------------------------------------------------------- |
|
1227 // |
|
1228 void MulBaseElement::SetNewCounterPosition( const TMulCoverFlowItem& aCounterLctDimension, bool aOrientationChanged) |
|
1229 { |
|
1230 MUL_LOG_ENTRY_EXIT("aakash::MulBaseElement::SetNewCounterPosition"); |
|
1231 MulCoverFlowControl* coverflowControl = ((MulCoverFlowControl*)&control()); |
|
1232 int totalModelCount = coverflowControl->TotalModelCount(); |
|
1233 int currHighlightIndex = coverflowControl->HighlightIndex(); |
|
1234 |
|
1235 if( totalModelCount > 0 && currHighlightIndex >= 0 ) |
|
1236 { |
|
1237 int numOfDigits = NumberOfDigits(totalModelCount); |
|
1238 numOfDigits += NumberOfDigits(currHighlightIndex); |
|
1239 |
|
1240 if( mData->mNumOfDigitsInCounter!= numOfDigits || aOrientationChanged ) |
|
1241 { |
|
1242 mData->mNumOfDigitsInCounter = numOfDigits; |
|
1243 int maxCharWidth = coverflowControl->Template2D()->CounterMaxCharWidth(); |
|
1244 int numOfPixels = numOfDigits*maxCharWidth + 20; // 10 is the tolerance. |
|
1245 |
|
1246 int rightPosx =0; |
|
1247 int leftPosx = 0; |
|
1248 // if mirroring is enabled(ie for RTL Language) |
|
1249 if (mData->mIsMirrored) |
|
1250 { |
|
1251 CAlfLayout* main = (CAlfLayout*)findVisual( KMainLayoutIndex ); |
|
1252 TSize topLayoutSize = main->Size().Target().AsSize(); |
|
1253 rightPosx = topLayoutSize.iWidth - aCounterLctDimension.posx ; |
|
1254 leftPosx = rightPosx - numOfPixels; |
|
1255 } |
|
1256 else |
|
1257 { |
|
1258 rightPosx = aCounterLctDimension.posx + aCounterLctDimension.width; |
|
1259 leftPosx = rightPosx - numOfPixels; |
|
1260 } |
|
1261 mData->mCounterVisual->SetPos(TAlfRealPoint(leftPosx,aCounterLctDimension.posy)); |
|
1262 mData->mCounterVisual->SetSize(TAlfRealPoint(numOfPixels ,aCounterLctDimension.height)); |
|
1263 } |
|
1264 } |
|
1265 } |
|
1266 // --------------------------------------------------------------------------- |
|
1267 // NumberOfDigits |
|
1268 // --------------------------------------------------------------------------- |
|
1269 // |
|
1270 int MulBaseElement::NumberOfDigits(int aNumber) |
|
1271 { |
|
1272 MUL_LOG_ENTRY_EXIT("aakash::MulBaseElement::NumberOfDigits"); |
|
1273 int num_digits = 0; |
|
1274 int number = aNumber; |
|
1275 do |
|
1276 { |
|
1277 num_digits++; |
|
1278 number/=10; |
|
1279 } |
|
1280 while ( number > 0 ); |
|
1281 |
|
1282 return num_digits; |
|
1283 } |
|
1284 |
|
1285 // --------------------------------------------------------------------------- |
|
1286 // ApplyScaleMode |
|
1287 // --------------------------------------------------------------------------- |
|
1288 // |
|
1289 void MulBaseElement::ApplyScaleMode( CAlfImageVisual& aImageVisual) |
|
1290 { |
|
1291 MUL_LOG_ENTRY_EXIT("aakash::MulBaseElement::ApplyScaleMode"); |
|
1292 CAlfImageVisual::TScaleMode scaleMode; |
|
1293 |
|
1294 if (mData->mFitMode) |
|
1295 { |
|
1296 if(aImageVisual.Image().HasTexture()) |
|
1297 { |
|
1298 CAlfTexture* texture = const_cast<CAlfTexture*>(&aImageVisual.Image().Texture()); |
|
1299 TInt imageWidth = texture->Size().iWidth; |
|
1300 TInt imageHeight = texture->Size().iHeight; |
|
1301 // when animation is not complete sizes will not be correct. |
|
1302 // so sizes are taken from template |
|
1303 if(imageWidth == 0 || imageHeight == 0) |
|
1304 { |
|
1305 scaleMode = CAlfImageVisual::EScaleFitInside; |
|
1306 } |
|
1307 else if( imageWidth <= mData->mHighlightItemStruct.width && |
|
1308 imageHeight <= mData->mHighlightItemStruct.height ) |
|
1309 { |
|
1310 scaleMode = CAlfImageVisual::EScaleNormal; |
|
1311 } |
|
1312 else |
|
1313 { |
|
1314 scaleMode = CAlfImageVisual::EScaleFitInside; |
|
1315 } |
|
1316 } |
|
1317 else |
|
1318 { |
|
1319 scaleMode = CAlfImageVisual::EScaleFitInside; |
|
1320 } |
|
1321 } |
|
1322 else |
|
1323 { |
|
1324 // Apply default scale mode |
|
1325 scaleMode = CAlfImageVisual::EScaleFitInside; |
|
1326 } |
|
1327 |
|
1328 if (aImageVisual.ScaleMode() != scaleMode) |
|
1329 { |
|
1330 aImageVisual.SetScaleMode( scaleMode ); |
|
1331 } |
|
1332 ApplyBrushOnIcon( aImageVisual ); |
|
1333 } |
|
1334 |
|
1335 // --------------------------------------------------------------------------- |
|
1336 // ApplyBrushOnIcon |
|
1337 // --------------------------------------------------------------------------- |
|
1338 // |
|
1339 void MulBaseElement::ApplyBrushOnIcon( CAlfImageVisual& aImageVisual ) |
|
1340 { |
|
1341 MUL_LOG_ENTRY_EXIT("aakash::MulBaseElement::ApplyBrushOnIcon"); |
|
1342 if( mData->mIconBgColor.mIsColorSet ) |
|
1343 { |
|
1344 aImageVisual.EnableBrushesL(ETrue); |
|
1345 CAlfBrushArray* brushArray = aImageVisual.Brushes(); |
|
1346 if( (brushArray->Count()==0)) |
|
1347 { |
|
1348 CAlfGradientBrush* brush = CAlfGradientBrush::NewL(aImageVisual.Env()); |
|
1349 brush->SetColor( mData->mIconBgColor.mColor ); |
|
1350 aImageVisual.Brushes()->AppendL( brush, EAlfHasOwnership ); |
|
1351 } |
|
1352 else |
|
1353 { |
|
1354 CAlfGradientBrush* brush = static_cast<CAlfGradientBrush*>(&brushArray->At(0)); |
|
1355 if ( brush->Color(0) != mData->mIconBgColor.mColor ) |
|
1356 { |
|
1357 brush->SetColor( mData->mIconBgColor.mColor ); |
|
1358 } |
|
1359 } |
|
1360 } |
|
1361 } |
|
1362 |
|
1363 // --------------------------------------------------------------------------- |
|
1364 // RemoveBrushOnIcon |
|
1365 // --------------------------------------------------------------------------- |
|
1366 // |
|
1367 void MulBaseElement::RemoveBrushOnIcon( CAlfImageVisual& aImageVisual ) |
|
1368 { |
|
1369 MUL_LOG_ENTRY_EXIT("aakash::MulBaseElement::RemoveBrushOnIcon"); |
|
1370 CAlfBrushArray* brushArray = aImageVisual.Brushes(); |
|
1371 if(brushArray && (brushArray->Count()!=0)) |
|
1372 { |
|
1373 brushArray->Remove(0); |
|
1374 } |
|
1375 } |
|
1376 |
|
1377 // --------------------------------------------------------------------------- |
|
1378 // Template2D |
|
1379 // --------------------------------------------------------------------------- |
|
1380 // |
|
1381 MulCoverFlowTemplate* MulBaseElement::Template2D() |
|
1382 { |
|
1383 MUL_LOG_ENTRY_EXIT("aakash::MulBaseElement::Template2D"); |
|
1384 return ((MulCoverFlowControl*)&control())->Template2D(); |
|
1385 } |
|
1386 |
|
1387 // --------------------------------------------------------------------------- |
|
1388 // SetScrollAnimationTime |
|
1389 // --------------------------------------------------------------------------- |
|
1390 // |
|
1391 void MulBaseElement::SetScrollAnimationTime( int aScrollAnimationTime ) |
|
1392 { |
|
1393 MUL_LOG_ENTRY_EXIT("aakash::MulBaseElement::SetScrollAnimationTime"); |
|
1394 mData->mScrollAnimationTime = aScrollAnimationTime; |
|
1395 } |
|
1396 |
|
1397 // --------------------------------------------------------------------------- |
|
1398 // ArrangeItems |
|
1399 // --------------------------------------------------------------------------- |
|
1400 // |
|
1401 void MulBaseElement::ArrangeItems() |
|
1402 { |
|
1403 MUL_LOG_ENTRY_EXIT("aakash::MulBaseElement::ArrangeItems"); |
|
1404 |
|
1405 control().Env().BatchBufferHandler().SetAutoFlushMode(EAlfAutoFlushOnlyForced); |
|
1406 |
|
1407 int totalVisual = 2*mData->mVisibleCount + 1; |
|
1408 int highlightIndex = mData->mVisibleCount; |
|
1409 CAlfImageVisual* imageVisual = NULL; |
|
1410 |
|
1411 |
|
1412 int posX = mData->mHighlightItemStruct.posx - mData->mVisibleCount*(mData->mItemStruct.width + mData->mPadding); |
|
1413 |
|
1414 TAlfRealPoint highlightItemSize(mData->mHighlightItemStruct.width, mData->mHighlightItemStruct.height); |
|
1415 TAlfRealPoint nonHighlightItemSize(mData->mItemStruct.width, mData->mItemStruct.height); |
|
1416 |
|
1417 for (int i=0; i < totalVisual ; i++) |
|
1418 { |
|
1419 CAlfVisual& deckLayout = mData->mIconFlowLayout->Visual(i); |
|
1420 imageVisual = (CAlfImageVisual*)deckLayout.FindTag(KCoverflowIcon); |
|
1421 |
|
1422 if (i != highlightIndex) |
|
1423 { |
|
1424 deckLayout.SetPos( TAlfRealPoint(posX,mData->mItemStruct.posy)); |
|
1425 deckLayout.SetSize(nonHighlightItemSize); |
|
1426 imageVisual->SetSize(nonHighlightItemSize); |
|
1427 posX = posX + mData->mItemStruct.width + mData->mPadding; |
|
1428 } |
|
1429 else |
|
1430 { |
|
1431 deckLayout.SetPos( TAlfRealPoint(mData->mHighlightItemStruct.posx,mData->mHighlightItemStruct.posy)); |
|
1432 deckLayout.SetSize(highlightItemSize); |
|
1433 imageVisual->SetSize(highlightItemSize); |
|
1434 posX = posX + mData->mHighlightItemStruct.width + mData->mPadding; |
|
1435 } |
|
1436 if (mData->mFitMode) |
|
1437 { |
|
1438 ApplyScaleMode(*imageVisual); |
|
1439 } |
|
1440 CAlfImageVisual* indicatorVisual =static_cast<CAlfImageVisual*>(deckLayout.FindTag(KCoverflowIndicator)); |
|
1441 if (indicatorVisual) |
|
1442 { |
|
1443 SetIndicatorDimensions(*indicatorVisual); |
|
1444 } |
|
1445 |
|
1446 } |
|
1447 |
|
1448 control().Env().BatchBufferHandler().FlushBatchBuffer(); |
|
1449 control().Env().BatchBufferHandler().SetAutoFlushMode(EAlfAutoFlushDeferred); |
|
1450 |
|
1451 } |
|
1452 |
|
1453 // --------------------------------------------------------------------------- |
|
1454 // SetScrollDir |
|
1455 // --------------------------------------------------------------------------- |
|
1456 // |
|
1457 void MulBaseElement::SetScrollDir( TItemScroll aScrollDir ) |
|
1458 { |
|
1459 MUL_LOG_ENTRY_EXIT("aakash::MulBaseElement::SetScrollDir"); |
|
1460 mData->mScrollDir = aScrollDir; |
|
1461 } |
|
1462 |
|
1463 // --------------------------------------------------------------------------- |
|
1464 // SetScrollDir |
|
1465 // --------------------------------------------------------------------------- |
|
1466 // |
|
1467 TItemScroll MulBaseElement::ScrollDir() |
|
1468 { |
|
1469 MUL_LOG_ENTRY_EXIT("aakash::MulBaseElement::ScrollDir"); |
|
1470 return mData->mScrollDir; |
|
1471 } |
|
1472 |
|
1473 // --------------------------------------------------------------------------- |
|
1474 // CalculatePadding |
|
1475 // --------------------------------------------------------------------------- |
|
1476 // |
|
1477 void MulBaseElement::CalculatePadding() |
|
1478 { |
|
1479 MUL_LOG_ENTRY_EXIT("aakash::MulBaseElement::CalculatePadding"); |
|
1480 |
|
1481 // The vector has already been created when the template was set. |
|
1482 if( mData->mVisibleCount == 1) |
|
1483 { |
|
1484 if( mData->mHighlightItemStruct.posx > KInitialvalueZero ) |
|
1485 { |
|
1486 mData->mPadding = mData->mHighlightItemStruct.posx; |
|
1487 } |
|
1488 else |
|
1489 { |
|
1490 // full screen template ..photos |
|
1491 // padding between the highlight and non highlight item is considered to be 2 pixel for |
|
1492 // full screen template as only one visual is visible. |
|
1493 mData->mPadding = 2; |
|
1494 } |
|
1495 } |
|
1496 else |
|
1497 { |
|
1498 int startx = mData->mHighlightItemStruct.posx+ mData->mHighlightItemStruct.width; |
|
1499 mData->mPadding = mData->mItemStruct.posx - startx; |
|
1500 } |
|
1501 } |
|
1502 |
|
1503 |
|
1504 // --------------------------------------------------------------------------- |
|
1505 // GetIconSize |
|
1506 // --------------------------------------------------------------------------- |
|
1507 // |
|
1508 void MulBaseElement::GetIconSize( mulwidget::TLogicalTemplate aTemplateId, |
|
1509 mulvisualitem::TVisualAttribute aAttribute, int& aHeight, int& aWidth) |
|
1510 { |
|
1511 MUL_LOG_ENTRY_EXIT("aakash::MulBaseElement::GetIconSize"); |
|
1512 |
|
1513 bool isLandscape = ((MulCoverFlowControl*)&control())->IsLandscape(); |
|
1514 switch(aTemplateId) |
|
1515 { |
|
1516 case mulwidget::KTemplate1: |
|
1517 { |
|
1518 MulCoverFlowTemplate1::GetIconSize(aAttribute,isLandscape,aHeight,aWidth); |
|
1519 } |
|
1520 break; |
|
1521 case mulwidget::KTemplate4: |
|
1522 { |
|
1523 MulCoverFlowTemplate4::GetIconSize(aAttribute,isLandscape,aHeight,aWidth); |
|
1524 } |
|
1525 break; |
|
1526 default: |
|
1527 { |
|
1528 // Invalid template id |
|
1529 // raise exception |
|
1530 __MUL_ASSERT(false,KInvalidTemplate); |
|
1531 } |
|
1532 break; |
|
1533 } |
|
1534 } |
|
1535 |
|
1536 |
|
1537 // --------------------------------------------------------------------------- |
|
1538 // ShowWidget |
|
1539 // --------------------------------------------------------------------------- |
|
1540 // |
|
1541 void MulBaseElement::ShowWidget( bool aShow, int aTransitionTime ) |
|
1542 { |
|
1543 MUL_LOG_ENTRY_EXIT("aakash::MulBaseElement::ShowWidget"); |
|
1544 float opacity ; |
|
1545 CAlfLayout* main = (CAlfLayout*) findVisual( KMainLayoutIndex ); |
|
1546 |
|
1547 if( aShow ) |
|
1548 { |
|
1549 opacity = KHighlightOpacity; |
|
1550 } |
|
1551 else |
|
1552 { |
|
1553 opacity = KBackGroundOpacity; |
|
1554 } |
|
1555 main->SetOpacity(TAlfTimedValue(opacity,aTransitionTime)); |
|
1556 } |
|
1557 |
|
1558 // --------------------------------------------------------------------------- |
|
1559 // makeInterface |
|
1560 // --------------------------------------------------------------------------- |
|
1561 // |
|
1562 IAlfInterfaceBase* MulBaseElement::makeInterface( const IfId& aType ) |
|
1563 { |
|
1564 MUL_LOG_ENTRY_EXIT("aakash::MulBaseElement::makeInterface"); |
|
1565 UString param(aType.mImplementationId); |
|
1566 |
|
1567 if(param == MulBaseElement::Type().mImplementationId ) |
|
1568 { |
|
1569 return static_cast<IAlfElement*>(this); |
|
1570 } |
|
1571 else if(param == IAlfWidgetEventHandler::type().mImplementationId ) |
|
1572 { |
|
1573 return static_cast<IAlfWidgetEventHandler*>(this); |
|
1574 } |
|
1575 else |
|
1576 { |
|
1577 return AlfElement::makeInterface(aType); |
|
1578 } |
|
1579 } |
|
1580 |
|
1581 // --------------------------------------------------------------------------- |
|
1582 // setEventHandlerData |
|
1583 // --------------------------------------------------------------------------- |
|
1584 // |
|
1585 void MulBaseElement::setEventHandlerData( const AlfWidgetEventHandlerInitData& /*aData*/ ) |
|
1586 { |
|
1587 //No implementation required |
|
1588 } |
|
1589 |
|
1590 // --------------------------------------------------------------------------- |
|
1591 // eventHandlerData |
|
1592 // --------------------------------------------------------------------------- |
|
1593 // |
|
1594 AlfWidgetEventHandlerInitData* MulBaseElement::eventHandlerData() |
|
1595 { |
|
1596 return NULL; |
|
1597 } |
|
1598 |
|
1599 // ---------------------------------------------------------------------------- |
|
1600 // eventHandlerType |
|
1601 // ---------------------------------------------------------------------------- |
|
1602 // |
|
1603 IAlfWidgetEventHandler::AlfEventHandlerType MulBaseElement::eventHandlerType() |
|
1604 { |
|
1605 return IAlfWidgetEventHandler::ELogicalEventHandler ; |
|
1606 } |
|
1607 // ---------------------------------------------------------------------------- |
|
1608 // eventExecutionPhase |
|
1609 // ---------------------------------------------------------------------------- |
|
1610 // |
|
1611 |
|
1612 IAlfWidgetEventHandler::AlfEventHandlerExecutionPhase MulBaseElement::eventExecutionPhase() |
|
1613 { |
|
1614 return EBubblingPhaseEventHandler; |
|
1615 } |
|
1616 |
|
1617 //------------------------Slider related Api's ------------------------- |
|
1618 |
|
1619 //-------------------------------------------------------------------------- |
|
1620 // UpdateSliderTick |
|
1621 //-------------------------------------------------------------------------- |
|
1622 // |
|
1623 void MulBaseElement::UpdateSliderTick(int aUpdateTick) |
|
1624 { |
|
1625 MUL_LOG_ENTRY_EXIT("aakash::MulBaseElement::MulBaseElement"); |
|
1626 IMulSliderModel* mulSliderModel = ((MulCoverFlowControl*)&control())->GetSliderModel(); |
|
1627 if( mulSliderModel && Template2D()->IsSliderVisible() ) |
|
1628 { |
|
1629 // Creating a reference Visual Item |
|
1630 //@todo remove const from Data api in slider model |
|
1631 const MulVisualItem& item = mulSliderModel->Data(); |
|
1632 //auto_ptr<MulVisualItem> tempItem( new (EMM) MulVisualItem()); |
|
1633 MulVisualItem* tempItem = const_cast<MulVisualItem*> (&item); |
|
1634 |
|
1635 tempItem->SetAttribute( mulvisualitem::KMulMaxRange, --aUpdateTick ); |
|
1636 tempItem->SetAttribute (mulvisualitem::KMulMinRange, 0); |
|
1637 tempItem->SetAttribute ( mulvisualitem::KMulTick,1); |
|
1638 |
|
1639 // Add the newly created visual item to the model |
|
1640 // Model takes the ownership of the visual item |
|
1641 mulSliderModel->SetData(*tempItem); |
|
1642 } |
|
1643 |
|
1644 // Set the opacity to the slider widget after verifyiny all the conditions. |
|
1645 SetSliderOpacity(); |
|
1646 } |
|
1647 //-------------------------------------------------------------------------- |
|
1648 // SetSliderOpacity |
|
1649 //-------------------------------------------------------------------------- |
|
1650 // |
|
1651 void MulBaseElement::SetSliderOpacity() |
|
1652 { |
|
1653 MUL_LOG_ENTRY_EXIT("aakash::MulBaseElement::SetSliderOpacity"); |
|
1654 |
|
1655 if (mData->mSliderLayout) |
|
1656 { |
|
1657 if ( Template2D()->IsSliderVisible() ) |
|
1658 { |
|
1659 if( static_cast<MulCoverFlowControl&>(control()).TotalModelCount() > 1 && mData->mSliderOpacity == KBackGroundOpacity) |
|
1660 { |
|
1661 ShowSlider(true); |
|
1662 } |
|
1663 else if((static_cast<MulCoverFlowControl&>(control()).TotalModelCount() <= 1) && mData->mSliderOpacity == KHighlightOpacity) |
|
1664 { |
|
1665 ShowSlider(false); |
|
1666 } |
|
1667 } |
|
1668 else if(mData->mSliderOpacity == KHighlightOpacity) |
|
1669 { |
|
1670 ShowSlider(false); |
|
1671 } |
|
1672 } |
|
1673 } |
|
1674 |
|
1675 //-------------------------------------------------------------------------- |
|
1676 //CreateSlider |
|
1677 //-------------------------------------------------------------------------- |
|
1678 // |
|
1679 void MulBaseElement::CreateSlider() |
|
1680 { |
|
1681 MUL_LOG_ENTRY_EXIT("aakash::MulBaseElement::CreateSlider"); |
|
1682 if ( Template2D()->IsSliderVisible() ) |
|
1683 { |
|
1684 MulCoverFlowControl* coverflowControl = static_cast<MulCoverFlowControl*>(&control()); |
|
1685 IAlfWidget* sliderwidget = coverflowControl->GetSliderWidget(); |
|
1686 if(!sliderwidget) |
|
1687 { |
|
1688 ConstructSliderWidget(); |
|
1689 } |
|
1690 |
|
1691 const TMulCoverFlowItem sliderStruct = Template2D()->SliderDimension(); |
|
1692 mData->mSliderLayout->SetPos(TAlfRealPoint(sliderStruct.posx,sliderStruct.posy)); |
|
1693 mData->mSliderLayout->SetSize(TAlfRealPoint(sliderStruct.width,sliderStruct.height)); |
|
1694 int totalModelCount = coverflowControl->TotalModelCount(); |
|
1695 if( totalModelCount > 1 ) |
|
1696 { |
|
1697 UpdateSliderTick(totalModelCount); |
|
1698 coverflowControl->SetSliderTickPosition(); |
|
1699 ShowSlider(true); |
|
1700 } |
|
1701 else |
|
1702 { |
|
1703 ShowSlider(false); |
|
1704 } |
|
1705 mData->mSliderLayout->UpdateChildrenLayout(); |
|
1706 } |
|
1707 else |
|
1708 { |
|
1709 if (!mData->mSliderLayout) |
|
1710 { |
|
1711 return; |
|
1712 } |
|
1713 ShowSlider(false); |
|
1714 } |
|
1715 } |
|
1716 |
|
1717 //-------------------------------------------------------------------------- |
|
1718 //ConstructSliderWidget |
|
1719 //-------------------------------------------------------------------------- |
|
1720 void MulBaseElement::ConstructSliderWidget() |
|
1721 { |
|
1722 MUL_LOG_ENTRY_EXIT("aakash::MulBaseElement::ConstructSliderWidget"); |
|
1723 IAlfWidget* alfSliderWidget = ((MulCoverFlowControl*)&control())->CreateSliderWidget(); |
|
1724 IMulSliderWidget* mulSliderWidget = static_cast<IMulSliderWidget*>(alfSliderWidget); |
|
1725 mData->mSliderLayout = const_cast<CAlfLayout*>(&mulSliderWidget->ContainerLayout()); |
|
1726 mData->mVerticalFlow->Insert(mData->mSliderLayout, mData->mVerticalFlow->Count()); |
|
1727 } |
|
1728 |
|
1729 |
|
1730 //-------------------------------------------------------------------------- |
|
1731 //ShowSlider |
|
1732 //-------------------------------------------------------------------------- |
|
1733 void MulBaseElement::ShowSlider(bool aFlag) |
|
1734 { |
|
1735 MUL_LOG_ENTRY_EXIT("aakash::MulBaseElement::ShowSlider"); |
|
1736 if(mData->mSliderLayout) |
|
1737 { |
|
1738 IAlfWidget* alfSliderWidget = ((MulCoverFlowControl*)&control())->GetSliderWidget(); |
|
1739 IMulSliderWidget* mulSliderWidget = static_cast<IMulSliderWidget*>(alfSliderWidget); |
|
1740 mulSliderWidget->ShowWidget(aFlag); |
|
1741 if(aFlag) |
|
1742 { |
|
1743 mData->mSliderLayout->SetOpacity(TAlfTimedValue(KHighlightOpacity)); |
|
1744 mData->mSliderOpacity = KHighlightOpacity; |
|
1745 } |
|
1746 else |
|
1747 { |
|
1748 mData->mSliderLayout->SetOpacity(TAlfTimedValue(KBackGroundOpacity)); |
|
1749 mData->mSliderOpacity = KBackGroundOpacity; |
|
1750 } |
|
1751 } |
|
1752 } |
|
1753 |
|
1754 |
|
1755 //-------------------------------------------------------------------------- |
|
1756 // StartBounce |
|
1757 //-------------------------------------------------------------------------- |
|
1758 void MulBaseElement::StartBounce(int aBounceDirection) |
|
1759 { |
|
1760 int bounceDistance = (mData->mHighlightItemStruct.width/4) * aBounceDirection; |
|
1761 control().Env().Send(TAlfCustomEventCommand(ECustomEventBounceBack,&control()),KBounceTime); |
|
1762 StartDoodling(bounceDistance,KBounceTime); |
|
1763 } |
|
1764 |
|
1765 |
|
1766 // --------------------------------------------------------------------------- |
|
1767 // CalculateDistanceChangeFactor |
|
1768 // --------------------------------------------------------------------------- |
|
1769 // |
|
1770 int MulBaseElement::CalculateDistanceChangeFactor() |
|
1771 { |
|
1772 MUL_LOG_ENTRY_EXIT("aakash::MulBaseElement::CalculateDistanceChangeFactor"); |
|
1773 |
|
1774 int firstVisualMidPoint = mData->mHighlightItemStruct.posx + (mData->mHighlightItemStruct.width/2); |
|
1775 int secVisualMidPoint = mData->mItemStruct.posx + (mData->mItemStruct.width/2); |
|
1776 |
|
1777 return Abs(secVisualMidPoint-firstVisualMidPoint); |
|
1778 } |
|
1779 |
|
1780 |
|
1781 // --------------------------------------------------------------------------- |
|
1782 // SetBackground |
|
1783 // --------------------------------------------------------------------------- |
|
1784 // |
|
1785 void MulBaseElement::SetBackground(const TRgb& aColor) |
|
1786 { |
|
1787 MUL_LOG_ENTRY_EXIT("aakash::MulBaseElement::SetBackground"); |
|
1788 |
|
1789 CAlfLayout* main = static_cast<CAlfLayout*>(findVisual( KMainLayoutIndex )); |
|
1790 CAlfDeckLayout& deckLayout = static_cast<CAlfDeckLayout&> (main->Visual(KMainLayoutIndex) ); |
|
1791 |
|
1792 CAlfVisual* oldVisual = deckLayout.FindTag(backgroundvisual); |
|
1793 if(oldVisual) |
|
1794 { |
|
1795 CAlfImageVisual* imageVisual = static_cast<CAlfImageVisual*>(oldVisual); |
|
1796 if(imageVisual->Image().HasTexture()) |
|
1797 { |
|
1798 const CAlfTexture& textureToUnload = imageVisual->Image().Texture(); |
|
1799 CAlfTextureManager& textureMgr = control().Env().TextureManager(); |
|
1800 textureMgr.UnloadTexture(textureToUnload.Id()); |
|
1801 } |
|
1802 |
|
1803 deckLayout.Remove( oldVisual ); |
|
1804 oldVisual->RemoveAndDestroyAllD(); |
|
1805 } |
|
1806 |
|
1807 deckLayout.EnableBrushesL( ETrue ); |
|
1808 CAlfBrushArray* brushArray = deckLayout.Brushes(); |
|
1809 if(brushArray) |
|
1810 { |
|
1811 if( brushArray->Count()!=0) |
|
1812 { |
|
1813 CAlfGradientBrush& brush = static_cast<CAlfGradientBrush&>(brushArray->At(0)); |
|
1814 brush.SetColor( aColor ); |
|
1815 } |
|
1816 else |
|
1817 { |
|
1818 THROW_IF_LEAVES |
|
1819 ( |
|
1820 CAlfGradientBrush* brush = CAlfGradientBrush::NewL( control().Env() ); |
|
1821 // Set the brush colour |
|
1822 brush->SetColor( aColor ); |
|
1823 // Apply brush and set the opacity . |
|
1824 deckLayout.Brushes()->AppendL( brush, EAlfHasOwnership ); |
|
1825 ); |
|
1826 } |
|
1827 } |
|
1828 } |
|
1829 |
|
1830 // --------------------------------------------------------------------------- |
|
1831 // SetBackground |
|
1832 // --------------------------------------------------------------------------- |
|
1833 // |
|
1834 void MulBaseElement::SetBackground(const TAknsItemID& aIID) |
|
1835 { |
|
1836 MUL_LOG_ENTRY_EXIT("aakash::MulBaseElement::SetBackground"); |
|
1837 |
|
1838 CAlfLayout* main = static_cast<CAlfLayout*>(findVisual( KMainLayoutIndex )); |
|
1839 CAlfDeckLayout& deckLayout = static_cast<CAlfDeckLayout&> (main->Visual(KMainLayoutIndex) ); |
|
1840 |
|
1841 CAlfBrushArray* brushArray = deckLayout.Brushes(); |
|
1842 if(brushArray) |
|
1843 { |
|
1844 if( brushArray->Count()!=0) |
|
1845 { |
|
1846 brushArray->Reset(); |
|
1847 } |
|
1848 } |
|
1849 |
|
1850 TAlfRealSize layoutSize = deckLayout.Size().ValueNow(); |
|
1851 const TAlfImage image(aIID,TSize(layoutSize),EAspectRatioPreserved,NULL,-1,-1,0.f,0.f,1.f, |
|
1852 1.f, TAlfTextureFlags(EAlfTextureFlagAutoSize | EAlfTextureFlagSkinContent), |
|
1853 KAlfAutoGeneratedTextureId,NULL); |
|
1854 |
|
1855 CAlfVisual* oldVisual = deckLayout.FindTag(backgroundvisual); |
|
1856 if(oldVisual) |
|
1857 { |
|
1858 CAlfImageVisual* imageVisual = static_cast<CAlfImageVisual*>(oldVisual); |
|
1859 if(imageVisual->Image().HasTexture()) |
|
1860 { |
|
1861 const CAlfTexture& textureToUnload = imageVisual->Image().Texture(); |
|
1862 CAlfTextureManager& textureMgr = control().Env().TextureManager(); |
|
1863 textureMgr.UnloadTexture(textureToUnload.Id()); |
|
1864 } |
|
1865 imageVisual->SetImage(image); |
|
1866 } |
|
1867 else |
|
1868 { |
|
1869 THROW_IF_LEAVES |
|
1870 ( |
|
1871 CAlfImageVisual* imagevisual(CAlfImageVisual::AddNewL((CAlfControl&)control(), &deckLayout)); |
|
1872 deckLayout.MoveVisualToBack(*imagevisual); |
|
1873 imagevisual->SetImage(image); |
|
1874 imagevisual->SetFlag(EAlfVisualFlagIgnorePointer); |
|
1875 imagevisual->SetPos(TPoint(0,0)); |
|
1876 imagevisual->SetSize(layoutSize); |
|
1877 imagevisual->SetOpacity( KHighlightOpacity ); |
|
1878 imagevisual->SetTagL( backgroundvisual ); |
|
1879 ); |
|
1880 } |
|
1881 } |
|
1882 |
|
1883 // --------------------------------------------------------------------------- |
|
1884 // SetItemBrush |
|
1885 // --------------------------------------------------------------------------- |
|
1886 // |
|
1887 void MulBaseElement::SetItemBrush(const TRgb& aColor) |
|
1888 { |
|
1889 MUL_LOG_ENTRY_EXIT("aakash::MulBaseElement::SetItemBrush"); |
|
1890 mData->mIconBgColor.mIsColorSet = true; |
|
1891 mData->mIconBgColor.mColor = aColor; |
|
1892 |
|
1893 int itemCount = 2*mData->mVisibleCount + 1; |
|
1894 |
|
1895 itemCount = itemCount > mData->mIconFlowLayout->Count() ? mData->mIconFlowLayout->Count() : itemCount; |
|
1896 |
|
1897 for(int i =0 ;i<itemCount;i++) |
|
1898 { |
|
1899 CAlfVisual& visual = mData->mIconFlowLayout->Visual( i ); |
|
1900 CAlfImageVisual* imageVisual = ( CAlfImageVisual* )visual.FindTag(KCoverflowIcon); |
|
1901 ApplyBrushOnIcon( *imageVisual); |
|
1902 } |
|
1903 } |
|
1904 |
|
1905 |
|
1906 // --------------------------------------------------------------------------- |
|
1907 // SetTextColor |
|
1908 // --------------------------------------------------------------------------- |
|
1909 // |
|
1910 void MulBaseElement::SetTextColor(TTextVisualType aVisualType, const TRgb& aColor) |
|
1911 { |
|
1912 MUL_LOG_ENTRY_EXIT("aakash::MulBaseElement::SetTextColor"); |
|
1913 |
|
1914 switch(aVisualType) |
|
1915 { |
|
1916 case ECounterVisual: |
|
1917 { |
|
1918 // save the values set by the application |
|
1919 mData->mCounterColor.mIsColorSet = true; |
|
1920 mData->mCounterColor.mColor = aColor; |
|
1921 |
|
1922 // apply the property if the visuals are already created |
|
1923 if(mData->mCounterVisual) |
|
1924 { |
|
1925 mData->mCounterVisual->SetColor(aColor); |
|
1926 } |
|
1927 break; |
|
1928 } |
|
1929 case ETilteDetailTextVisual: |
|
1930 { |
|
1931 // save the values set by the application |
|
1932 mData->mTextColor.mIsColorSet = true; |
|
1933 mData->mTextColor.mColor = aColor; |
|
1934 |
|
1935 // apply the property if the visuals are already created |
|
1936 CAlfTextVisual* titleTextVisual =static_cast<CAlfTextVisual*>(mData->mTextLayout->FindTag(KCoverflowTitle)); |
|
1937 if(titleTextVisual) |
|
1938 { |
|
1939 titleTextVisual->SetColor(aColor); |
|
1940 } |
|
1941 CAlfViewportLayout* viewPortLayout =static_cast<CAlfViewportLayout*>(mData->mTextLayout->FindTag(KDetailViewPortLayout)); |
|
1942 if(viewPortLayout) |
|
1943 { |
|
1944 CAlfTextVisual* detailTextVisual =static_cast<CAlfTextVisual*>(viewPortLayout->FindTag(KCoverflowDetail)); |
|
1945 if(detailTextVisual) |
|
1946 { |
|
1947 detailTextVisual->SetColor(aColor); |
|
1948 } |
|
1949 } |
|
1950 // Apply the same color for empty text also |
|
1951 if(mData->mEmptyTextVisual) |
|
1952 { |
|
1953 mData->mEmptyTextVisual->SetColor(aColor); |
|
1954 } |
|
1955 break; |
|
1956 } |
|
1957 default: |
|
1958 break; |
|
1959 } |
|
1960 } |
|
1961 |
|
1962 // --------------------------------------------------------------------------- |
|
1963 // TextColor |
|
1964 // --------------------------------------------------------------------------- |
|
1965 // |
|
1966 TMulVisualColorProperty MulBaseElement::TextColor(TTextVisualType aVisualType) |
|
1967 { |
|
1968 MUL_LOG_ENTRY_EXIT("aakash::MulBaseElement::TextColor"); |
|
1969 TMulVisualColorProperty colorProperty; |
|
1970 |
|
1971 switch(aVisualType) |
|
1972 { |
|
1973 case ECounterVisual: |
|
1974 { |
|
1975 colorProperty = mData->mCounterColor; |
|
1976 break; |
|
1977 } |
|
1978 case ETilteDetailTextVisual: |
|
1979 { |
|
1980 colorProperty = mData->mTextColor; |
|
1981 break; |
|
1982 } |
|
1983 default: |
|
1984 break; |
|
1985 } |
|
1986 return colorProperty; |
|
1987 } |
|
1988 |
|
1989 // --------------------------------------------------------------------------- |
|
1990 // FlowLayout |
|
1991 // --------------------------------------------------------------------------- |
|
1992 // |
|
1993 CAlfLayout& MulBaseElement::FlowLayout( int aLayoutIndex ) |
|
1994 { |
|
1995 MUL_LOG_ENTRY_EXIT("aakash::MulBaseElement::FlowLayout"); |
|
1996 |
|
1997 return static_cast<CAlfLayout&>(mData->mVerticalFlow->Visual( aLayoutIndex )); |
|
1998 } |
|
1999 |
|
2000 // --------------------------------------------------------------------------- |
|
2001 // SetFitMode |
|
2002 // --------------------------------------------------------------------------- |
|
2003 // |
|
2004 void MulBaseElement::SetFitMode(bool aFlag) |
|
2005 { |
|
2006 MUL_LOG_ENTRY_EXIT("aakash::MulBaseElement::SetFitMode"); |
|
2007 mData->mFitMode = aFlag; |
|
2008 } |
|
2009 |
|
2010 // ---------------------------------------------------------------------------- |
|
2011 // CreateAndInitializeVisuals |
|
2012 // ---------------------------------------------------------------------------- |
|
2013 // |
|
2014 void MulBaseElement::CreateAndInitializeVisuals(bool aIsOrientationChange) |
|
2015 { |
|
2016 MUL_LOG_ENTRY_EXIT("aakash::MulBaseElement::CreateAndInitializeVisuals"); |
|
2017 CreateVisuals(); |
|
2018 |
|
2019 // Specific to template 4 don't update the visuals |
|
2020 // during orientation change |
|
2021 // done for performance improvement. |
|
2022 if (!(aIsOrientationChange &&mData->mFitMode)) |
|
2023 { |
|
2024 UpdateVisuals(); |
|
2025 CreateSlider(); |
|
2026 } |
|
2027 |
|
2028 // For template 4 set model case |
|
2029 // cancel the rotation if any. |
|
2030 if (!aIsOrientationChange && mData->mFitMode) |
|
2031 { |
|
2032 if (mData->mRotation.mIsApplied) |
|
2033 { |
|
2034 if (mData->mRotation.mIndex >= 0) |
|
2035 { |
|
2036 CancelRotation(mData->mRotation.mIndex); |
|
2037 } |
|
2038 else |
|
2039 { |
|
2040 // rotation applied on highlight index. |
|
2041 // so cancel it. |
|
2042 mData->mRotation.mIndex = 1; |
|
2043 CancelRotation(mData->mRotation.mIndex); |
|
2044 } |
|
2045 } |
|
2046 } |
|
2047 } |
|
2048 |
|
2049 // ---------------------------------------------------------------------------- |
|
2050 // CreateVisuals |
|
2051 // ---------------------------------------------------------------------------- |
|
2052 // |
|
2053 void MulBaseElement::CreateVisuals() |
|
2054 { |
|
2055 MUL_LOG_ENTRY_EXIT("aakash::MulBaseElement::CreateVisuals"); |
|
2056 int totalVisual = 2*mData->mVisibleCount + 1; |
|
2057 int visualIndex = 0; |
|
2058 |
|
2059 // if there are less visuals than required tehn create the extra visauls and |
|
2060 // set opacity 1 for already existing visuals |
|
2061 if(totalVisual > mData->mIconFlowLayout->Count()) |
|
2062 { |
|
2063 visualIndex = mData->mIconFlowLayout->Count(); |
|
2064 for(; visualIndex < totalVisual;visualIndex++) |
|
2065 { |
|
2066 CreateIconStructure(mData->mIconFlowLayout); |
|
2067 } |
|
2068 } |
|
2069 // if the number of visuals are more, then set opacity 0 for the extra visuals |
|
2070 else if (totalVisual < mData->mIconFlowLayout->Count()) |
|
2071 { |
|
2072 IMulModelAccessor* accessor = ((MulCoverFlowControl*)&control())->ModelAccessor(); |
|
2073 if(accessor) |
|
2074 { |
|
2075 if(accessor->CurrentItemCount() < totalVisual) |
|
2076 { |
|
2077 for(; visualIndex < totalVisual;visualIndex++) |
|
2078 { |
|
2079 CAlfVisual& visual = mData->mIconFlowLayout->Visual(visualIndex); |
|
2080 static_cast<MulCoverFlowControl&>(control()).UpdateItemAtIndex(visualIndex); |
|
2081 } |
|
2082 } |
|
2083 |
|
2084 CAlfTextureManager& textureMgr = control().Env().TextureManager(); |
|
2085 TAlfImage image = TAlfImage(textureMgr.BlankTexture()); |
|
2086 // position those visuals to some other location. |
|
2087 int posX = mData->mHighlightItemStruct.posx + totalVisual * mData->mHighlightItemStruct.width; |
|
2088 for(; visualIndex < mData->mIconFlowLayout->Count();visualIndex++) |
|
2089 { |
|
2090 CAlfVisual& visual = mData->mIconFlowLayout->Visual(visualIndex); |
|
2091 visual.SetPos(TAlfRealPoint(posX,mData->mHighlightItemStruct.posy)); |
|
2092 CAlfImageVisual* imageVisual = static_cast<CAlfImageVisual*>(visual.FindTag(KCoverflowIcon)); |
|
2093 // remove the icon brush if any. |
|
2094 RemoveBrushOnIcon(*imageVisual); |
|
2095 imageVisual->SetImage(image); |
|
2096 CAlfImageVisual* indicatorVisual =static_cast<CAlfImageVisual*>(visual.FindTag(KCoverflowIndicator)); |
|
2097 if(indicatorVisual) |
|
2098 { |
|
2099 indicatorVisual->SetImage(image); |
|
2100 } |
|
2101 } |
|
2102 } |
|
2103 } |
|
2104 } |
|
2105 |
|
2106 // ---------------------------------------------------------------------------- |
|
2107 // UpdateVisuals |
|
2108 // ---------------------------------------------------------------------------- |
|
2109 // |
|
2110 void MulBaseElement::UpdateVisuals() |
|
2111 { |
|
2112 MUL_LOG_ENTRY_EXIT("aakash::MulBaseElement::UpdateVisuals"); |
|
2113 int totalVisual = 2*mData->mVisibleCount + 1; |
|
2114 MulCoverFlowControl* coverflowControl = static_cast<MulCoverFlowControl*>(&control()); |
|
2115 IMulModelAccessor* accessor = coverflowControl->ModelAccessor(); |
|
2116 if(accessor) |
|
2117 { |
|
2118 for(int i = 0; i < totalVisual; i++) |
|
2119 { |
|
2120 CAlfVisual& visual = mData->mIconFlowLayout->Visual(i); |
|
2121 coverflowControl->UpdateItemAtIndex(i); |
|
2122 } |
|
2123 } |
|
2124 } |
|
2125 |
|
2126 // ---------------------------------------------------------------------------- |
|
2127 // CreateIconStructure |
|
2128 // ---------------------------------------------------------------------------- |
|
2129 // |
|
2130 CAlfVisual* MulBaseElement::CreateIconStructure(CAlfLayout* aParentLayout) |
|
2131 { |
|
2132 MUL_LOG_ENTRY_EXIT("aakash::MulBaseElement::CreateIconStructure"); |
|
2133 //create the deck layout. |
|
2134 CAlfDeckLayout* deck =CAlfDeckLayout::AddNewL((CAlfControl &)control(),aParentLayout); |
|
2135 CAlfImageVisual* imageVisual =CAlfImageVisual::AddNewL((CAlfControl &)control(),deck); |
|
2136 imageVisual->SetTagL(KCoverflowIcon); |
|
2137 deck->SetFlag( EAlfVisualFlagManualLayout ); |
|
2138 return deck; |
|
2139 } |
|
2140 |
|
2141 |
|
2142 // ---------------------------------------------------------------------------- |
|
2143 // SetHighlight |
|
2144 // This function is used to change the highlight by 1 with animation. |
|
2145 // This function also takes care whether we need to change the size or only the position. |
|
2146 // it takes into consideration the current direction and the current highlight index. |
|
2147 // The logic is , we are always keeping the highlight visual index fixed (its equal to |
|
2148 // the no of visible item in the screen), Depending on the scroll direction we reorder |
|
2149 // the last or first visual and then position all visuals keeping the highlight visual |
|
2150 // in its position. Then update the last or 1st visual with appropriate data. |
|
2151 // ---------------------------------------------------------------------------- |
|
2152 // |
|
2153 void MulBaseElement::SetHighlight(int /*aHighlightIndex*/, int aAnimationTime) |
|
2154 { |
|
2155 MUL_LOG_ENTRY_EXIT("aakash::MulBaseElement::SetHighlight"); |
|
2156 int totalVisual = 2*mData->mVisibleCount + 1; |
|
2157 int highlightIndex = mData->mVisibleCount; |
|
2158 CAlfVisual* deckLayout = NULL; |
|
2159 CAlfVisual* imageVisual = NULL; |
|
2160 |
|
2161 int highlightPosX = mData->mHighlightItemStruct.posx; |
|
2162 |
|
2163 if(mData->mScrollDir == EItemScrollLeft) |
|
2164 { |
|
2165 CancelRotation(totalVisual - 1); |
|
2166 control().Env().BatchBufferHandler().SetAutoFlushMode(EAlfAutoFlushOnlyForced); |
|
2167 deckLayout = (CAlfVisual*)&mData->mIconFlowLayout->Visual(totalVisual - 1); |
|
2168 mData->mIconFlowLayout->Reorder(*deckLayout,0); |
|
2169 |
|
2170 int posX = highlightPosX - mData->mVisibleCount*(mData->mItemStruct.width + mData->mPadding); |
|
2171 deckLayout->SetPos( TAlfRealPoint(posX,mData->mItemStruct.posy)); |
|
2172 posX = posX + mData->mItemStruct.width + mData->mPadding; |
|
2173 for (int i=1; i < totalVisual ; i++) |
|
2174 { |
|
2175 deckLayout = (CAlfVisual*)&mData->mIconFlowLayout->Visual(i); |
|
2176 imageVisual = deckLayout->FindTag(KCoverflowIcon); |
|
2177 if (i != highlightIndex) |
|
2178 { |
|
2179 deckLayout->SetPos( TAlfTimedPoint(posX,mData->mItemStruct.posy,aAnimationTime)); |
|
2180 posX = posX + mData->mItemStruct.width + mData->mPadding; |
|
2181 |
|
2182 // Change the size if required |
|
2183 if((i == highlightIndex+1 || i == highlightIndex-1) && mData->mChangeSize) |
|
2184 { |
|
2185 deckLayout->SetSize(TAlfTimedPoint(mData->mItemStruct.width,mData->mItemStruct.height,aAnimationTime)); |
|
2186 imageVisual->SetSize(TAlfTimedPoint(mData->mItemStruct.width,mData->mItemStruct.height,aAnimationTime)); |
|
2187 } |
|
2188 } |
|
2189 else |
|
2190 { |
|
2191 deckLayout->SetPos( TAlfTimedPoint(highlightPosX,mData->mHighlightItemStruct.posy,aAnimationTime)); |
|
2192 posX = posX + mData->mHighlightItemStruct.width + mData->mPadding; |
|
2193 |
|
2194 // Change the size if required |
|
2195 if(mData->mChangeSize) |
|
2196 { |
|
2197 deckLayout->SetSize(TAlfTimedPoint(mData->mHighlightItemStruct.width, |
|
2198 mData->mHighlightItemStruct.height, |
|
2199 aAnimationTime)); |
|
2200 imageVisual->SetSize(TAlfTimedPoint(mData->mHighlightItemStruct.width, |
|
2201 mData->mHighlightItemStruct.height, |
|
2202 aAnimationTime)); |
|
2203 } |
|
2204 } |
|
2205 } |
|
2206 control().Env().BatchBufferHandler().FlushBatchBuffer(); |
|
2207 control().Env().BatchBufferHandler().SetAutoFlushMode(EAlfAutoFlushDeferred); |
|
2208 ((MulCoverFlowControl*)&control())->UpdateItemAtIndex(0, aAnimationTime); |
|
2209 |
|
2210 } |
|
2211 else if (mData->mScrollDir == EItemScrollRight) |
|
2212 { |
|
2213 CancelRotation(0); |
|
2214 control().Env().BatchBufferHandler().SetAutoFlushMode(EAlfAutoFlushOnlyForced); |
|
2215 deckLayout = (CAlfVisual*)&mData->mIconFlowLayout->Visual(0); |
|
2216 mData->mIconFlowLayout->Reorder(*deckLayout,totalVisual-1); |
|
2217 |
|
2218 int posX = highlightPosX - mData->mVisibleCount*(mData->mItemStruct.width + mData->mPadding); |
|
2219 |
|
2220 for (int i=0; i < totalVisual-1 ; i++) |
|
2221 { |
|
2222 deckLayout = (CAlfVisual*)&mData->mIconFlowLayout->Visual(i); |
|
2223 imageVisual = deckLayout->FindTag(KCoverflowIcon); |
|
2224 |
|
2225 if (i != highlightIndex) |
|
2226 { |
|
2227 deckLayout->SetPos( TAlfTimedPoint(posX,mData->mItemStruct.posy,aAnimationTime)); |
|
2228 posX = posX + mData->mItemStruct.width + mData->mPadding; |
|
2229 // Change the size if required |
|
2230 if((i == highlightIndex+1 || i == highlightIndex-1) && mData->mChangeSize) |
|
2231 { |
|
2232 deckLayout->SetSize(TAlfTimedPoint(mData->mItemStruct.width,mData->mItemStruct.height,aAnimationTime)); |
|
2233 imageVisual->SetSize(TAlfTimedPoint(mData->mItemStruct.width,mData->mItemStruct.height,aAnimationTime)); |
|
2234 } |
|
2235 } |
|
2236 else |
|
2237 { |
|
2238 deckLayout->SetPos( TAlfTimedPoint(highlightPosX,mData->mHighlightItemStruct.posy,aAnimationTime)); |
|
2239 posX = posX + mData->mHighlightItemStruct.width + mData->mPadding; |
|
2240 // Change the size if required |
|
2241 if(mData->mChangeSize) |
|
2242 { |
|
2243 deckLayout->SetSize(TAlfTimedPoint(mData->mHighlightItemStruct.width, |
|
2244 mData->mHighlightItemStruct.height, |
|
2245 aAnimationTime)); |
|
2246 imageVisual->SetSize(TAlfTimedPoint(mData->mHighlightItemStruct.width, |
|
2247 mData->mHighlightItemStruct.height, |
|
2248 aAnimationTime)); |
|
2249 } |
|
2250 } |
|
2251 } |
|
2252 deckLayout = (CAlfVisual*)&mData->mIconFlowLayout->Visual(totalVisual-1); |
|
2253 deckLayout->SetPos( TAlfRealPoint(posX,mData->mItemStruct.posy)); |
|
2254 control().Env().BatchBufferHandler().FlushBatchBuffer(); |
|
2255 control().Env().BatchBufferHandler().SetAutoFlushMode(EAlfAutoFlushDeferred); |
|
2256 ((MulCoverFlowControl*)&control())->UpdateItemAtIndex(totalVisual-1, aAnimationTime); |
|
2257 } |
|
2258 |
|
2259 } |
|
2260 |
|
2261 // ---------------------------------------------------------------------------- |
|
2262 // StartDoodling |
|
2263 // This function is used in doodling case. it calls the appropriate function to |
|
2264 // handle doodling based on whether we have to only change the position or both |
|
2265 // position and size. |
|
2266 // ---------------------------------------------------------------------------- |
|
2267 // |
|
2268 void MulBaseElement::StartDoodling(int aDistance, int aAnimationTime) |
|
2269 { |
|
2270 MUL_LOG_ENTRY_EXIT("aakash::MulBaseElement::StartDoodling"); |
|
2271 if (mData->mChangeSize) |
|
2272 { |
|
2273 MoveVisualsWithSizeChange(aDistance,aAnimationTime); |
|
2274 } |
|
2275 else |
|
2276 { |
|
2277 MoveVisuals(aDistance,aAnimationTime); |
|
2278 } |
|
2279 } |
|
2280 |
|
2281 // ---------------------------------------------------------------------------- |
|
2282 // StopDoodling |
|
2283 // it calls when we get a gestureunknown or to do a bounce back. |
|
2284 // it basically repositions the visuals based on current highlight. |
|
2285 // it simply calls a startdoodling function with 0 distance and with |
|
2286 // animation time if required. |
|
2287 // ---------------------------------------------------------------------------- |
|
2288 // |
|
2289 void MulBaseElement::StopDoodling(int aAnimationTime) |
|
2290 { |
|
2291 MUL_LOG_ENTRY_EXIT("aakash::MulBaseElement::StopDoodling"); |
|
2292 StartDoodling(0,aAnimationTime); |
|
2293 } |
|
2294 |
|
2295 |
|
2296 // ---------------------------------------------------------------------------- |
|
2297 // MoveVisuals |
|
2298 // This function is used in doodling when only position needs to be change, usefull |
|
2299 // in potrait where 1 visible item is in the screen. |
|
2300 // The logic is to change the position of all visuals by doodling distance. |
|
2301 // ---------------------------------------------------------------------------- |
|
2302 // |
|
2303 void MulBaseElement::MoveVisuals(int aDistance, int aAnimationTime) |
|
2304 { |
|
2305 MUL_LOG_ENTRY_EXIT("aakash::MulBaseElement::MoveVisuals"); |
|
2306 CancelRotation(); |
|
2307 |
|
2308 control().Env().BatchBufferHandler().SetAutoFlushMode(EAlfAutoFlushOnlyForced); |
|
2309 int totalVisual = 2*mData->mVisibleCount + 1; |
|
2310 int highlightIndex = mData->mVisibleCount; |
|
2311 |
|
2312 int highlightPosX = mData->mHighlightItemStruct.posx; |
|
2313 |
|
2314 highlightPosX += aDistance; |
|
2315 |
|
2316 int posX = highlightPosX - mData->mVisibleCount*(mData->mItemStruct.width + mData->mPadding); |
|
2317 for (int i=0; i < totalVisual ; i++) |
|
2318 { |
|
2319 CAlfVisual& deckLayout = mData->mIconFlowLayout->Visual(i); |
|
2320 |
|
2321 if (i != mData->mVisibleCount) |
|
2322 { |
|
2323 deckLayout.SetPos( TAlfTimedPoint(posX,mData->mItemStruct.posy,aAnimationTime)); |
|
2324 posX = posX + mData->mItemStruct.width + mData->mPadding; |
|
2325 } |
|
2326 else |
|
2327 { |
|
2328 deckLayout.SetPos( TAlfTimedPoint(highlightPosX,mData->mHighlightItemStruct.posy,aAnimationTime)); |
|
2329 posX = posX + mData->mHighlightItemStruct.width + mData->mPadding; |
|
2330 } |
|
2331 } |
|
2332 control().Env().BatchBufferHandler().FlushBatchBuffer(); |
|
2333 control().Env().BatchBufferHandler().SetAutoFlushMode(EAlfAutoFlushDeferred); |
|
2334 } |
|
2335 |
|
2336 // ---------------------------------------------------------------------------- |
|
2337 // NumberOfSwipe |
|
2338 // ---------------------------------------------------------------------------- |
|
2339 // |
|
2340 TNumberofSwipes MulBaseElement::NumberOfSwipes() |
|
2341 { |
|
2342 MUL_LOG_ENTRY_EXIT("aakash::MulBaseElement::NumberOfSwipes"); |
|
2343 return mData->mNumSwipes; |
|
2344 } |
|
2345 |
|
2346 // ---------------------------------------------------------------------------- |
|
2347 // FinalSwipeDirection |
|
2348 // ---------------------------------------------------------------------------- |
|
2349 // |
|
2350 int MulBaseElement::FinalSwipeDirection(int aDistance, int aLastSwipeDirection) |
|
2351 { |
|
2352 MUL_LOG_ENTRY_EXIT("aakash::MulBaseElement::FinalSwipeDirection"); |
|
2353 |
|
2354 int NewHighlightPos = NearestPoint(FinalMidPoints(ReferenceMidPoints(),aDistance),aLastSwipeDirection); |
|
2355 |
|
2356 int scrollDir = EItemNoDirection; |
|
2357 mData->mNumSwipes = ESingleSwipe; |
|
2358 |
|
2359 // now depending on the new highlight position make a decission |
|
2360 // whether to double swipe or single swipe and in which direction. |
|
2361 if(mData->mVisibleCount == 1) |
|
2362 { |
|
2363 switch(NewHighlightPos) |
|
2364 { |
|
2365 case 0: |
|
2366 { |
|
2367 scrollDir = EItemScrollLeft; |
|
2368 } |
|
2369 break; |
|
2370 case 2: |
|
2371 { |
|
2372 scrollDir = EItemScrollRight; |
|
2373 } |
|
2374 break; |
|
2375 case 1: |
|
2376 default: |
|
2377 break; |
|
2378 } |
|
2379 } |
|
2380 else |
|
2381 { |
|
2382 switch(NewHighlightPos) |
|
2383 { |
|
2384 case 0: |
|
2385 { |
|
2386 mData->mNumSwipes = ETripleSwipe; // triple swipe |
|
2387 scrollDir = EItemScrollLeft; |
|
2388 } |
|
2389 break; |
|
2390 case 1: |
|
2391 { |
|
2392 mData->mNumSwipes = EDoubleSwipe; |
|
2393 scrollDir = EItemScrollLeft; |
|
2394 } |
|
2395 break; |
|
2396 case 2: |
|
2397 { |
|
2398 scrollDir = EItemScrollLeft; |
|
2399 } |
|
2400 break; |
|
2401 case 4: |
|
2402 { |
|
2403 scrollDir = EItemScrollRight; |
|
2404 } |
|
2405 break; |
|
2406 case 5: |
|
2407 { |
|
2408 mData->mNumSwipes = EDoubleSwipe; |
|
2409 scrollDir = EItemScrollRight; |
|
2410 } |
|
2411 break; |
|
2412 case 6: |
|
2413 { |
|
2414 mData->mNumSwipes = ETripleSwipe; // triple swipe |
|
2415 scrollDir = EItemScrollRight; |
|
2416 } |
|
2417 break; |
|
2418 case 3: |
|
2419 default: |
|
2420 break; |
|
2421 } |
|
2422 } |
|
2423 return scrollDir; |
|
2424 } |
|
2425 |
|
2426 // ---------------------------------------------------------------------------- |
|
2427 // NearestPoint |
|
2428 // ---------------------------------------------------------------------------- |
|
2429 // |
|
2430 int MulBaseElement::NearestPoint(std::vector<int> aFinalMidPoints,int aLastSwipeDirection) |
|
2431 { |
|
2432 int referencePoint = mData->mHighlightItemStruct.posx + mData->mHighlightItemStruct.width/2; |
|
2433 int i = 0; |
|
2434 while(i < aFinalMidPoints.size()) |
|
2435 { |
|
2436 int temp = aFinalMidPoints[i]; |
|
2437 if(aFinalMidPoints[i] > referencePoint) |
|
2438 { |
|
2439 break; |
|
2440 } |
|
2441 i++; |
|
2442 } |
|
2443 |
|
2444 if(aLastSwipeDirection == EEventScrollLeft) |
|
2445 { |
|
2446 return --i; |
|
2447 } |
|
2448 return i; |
|
2449 } |
|
2450 |
|
2451 // ---------------------------------------------------------------------------- |
|
2452 // ReferenceMidPoints |
|
2453 // ---------------------------------------------------------------------------- |
|
2454 // |
|
2455 std::vector<int> MulBaseElement::ReferenceMidPoints() |
|
2456 { |
|
2457 std::vector<int> referenceMidPoints; |
|
2458 int highlightMidPoint = mData->mHighlightItemStruct.posx + mData->mHighlightItemStruct.width/2; |
|
2459 int differnce = mData->mHighlightItemStruct.width/2 |
|
2460 + mData->mPadding + mData->mItemStruct.width/2 ; |
|
2461 |
|
2462 int doubleDiff = mData->mPadding + mData->mItemStruct.width; |
|
2463 if(mData->mVisibleCount != 1) |
|
2464 { |
|
2465 referenceMidPoints.push_back(highlightMidPoint - (differnce |
|
2466 + 2 * doubleDiff)); |
|
2467 |
|
2468 referenceMidPoints.push_back(highlightMidPoint - (differnce |
|
2469 + doubleDiff)); |
|
2470 } |
|
2471 referenceMidPoints.push_back(highlightMidPoint - differnce); |
|
2472 referenceMidPoints.push_back(highlightMidPoint); |
|
2473 referenceMidPoints.push_back(highlightMidPoint + differnce); |
|
2474 |
|
2475 if(mData->mVisibleCount != 1) |
|
2476 { |
|
2477 referenceMidPoints.push_back(highlightMidPoint + (differnce |
|
2478 + 2 * doubleDiff)); |
|
2479 |
|
2480 referenceMidPoints.push_back(highlightMidPoint + (differnce |
|
2481 + doubleDiff)); |
|
2482 } |
|
2483 return referenceMidPoints; |
|
2484 } |
|
2485 |
|
2486 // ---------------------------------------------------------------------------- |
|
2487 // FinalMidPoints |
|
2488 // ---------------------------------------------------------------------------- |
|
2489 // |
|
2490 std::vector<int> MulBaseElement::FinalMidPoints(std::vector<int> aReferenceMidPoints,int aDistance) |
|
2491 { |
|
2492 std::vector<int> newMidPoints; |
|
2493 for(int i = 0; i < aReferenceMidPoints.size(); i++) |
|
2494 { |
|
2495 newMidPoints.push_back(aReferenceMidPoints[i] + aDistance); |
|
2496 int temp = newMidPoints[i]; |
|
2497 } |
|
2498 return newMidPoints; |
|
2499 } |
|
2500 |
|
2501 // ---------------------------------------------------------------------------- |
|
2502 // MoveVisualsWithSizeChange |
|
2503 // This function used when during doodling size changes also required. |
|
2504 // ie in case of landscape and visible items are 3 during doodling position as well |
|
2505 // as size change requird. |
|
2506 // The basic logic is we are keeping a reference distance for a complete highlight |
|
2507 // change (that means the highlight becomes nonhighlight and vice versa). so at |
|
2508 // any point of time there will be only two visuals whose size needs to be change. |
|
2509 // one to grow and other to shrink. so we calculate the % of grow and shrink of |
|
2510 // visual keeping the doodling distance and reference distance into consideration. |
|
2511 // ---------------------------------------------------------------------------- |
|
2512 // |
|
2513 void MulBaseElement::MoveVisualsWithSizeChange(int aDistance, int aAnimationTime) |
|
2514 { |
|
2515 MUL_LOG_ENTRY_EXIT("aakash::MulBaseElement::MoveVisualsWithSizeChange"); |
|
2516 int totalVisual = 2*mData->mVisibleCount + 1; |
|
2517 int highlightIndex = mData->mVisibleCount; |
|
2518 CAlfVisual* imageVisual = NULL; |
|
2519 int visualIndexToShrink = -1; |
|
2520 int visualIndexToGrow = -1; |
|
2521 int updateSpecialIndex = -1; |
|
2522 int distancefactor = CalculateDistanceChangeFactor (); |
|
2523 |
|
2524 int highlightPosX = mData->mHighlightItemStruct.posx; |
|
2525 highlightPosX += aDistance; |
|
2526 |
|
2527 |
|
2528 if (Abs(aDistance) < distancefactor) |
|
2529 { |
|
2530 // user has doodled to change the highlight by 1.Single swipe. |
|
2531 if (aDistance < 0) |
|
2532 { |
|
2533 visualIndexToGrow = highlightIndex +1; |
|
2534 } |
|
2535 else if (aDistance > 0) |
|
2536 { |
|
2537 visualIndexToGrow = highlightIndex -1; |
|
2538 } |
|
2539 else |
|
2540 { |
|
2541 // for stop doodling case |
|
2542 visualIndexToGrow = highlightIndex - 1; |
|
2543 updateSpecialIndex = highlightIndex + 1; |
|
2544 } |
|
2545 visualIndexToShrink = highlightIndex; |
|
2546 } |
|
2547 else |
|
2548 { |
|
2549 // user has doodled to change the highlight by 2. Double swipe. |
|
2550 if (aDistance < 0) |
|
2551 { |
|
2552 visualIndexToShrink = highlightIndex +1; |
|
2553 visualIndexToGrow = highlightIndex +2; |
|
2554 aDistance +=distancefactor; |
|
2555 } |
|
2556 else |
|
2557 { |
|
2558 visualIndexToShrink = highlightIndex -1; |
|
2559 visualIndexToGrow = highlightIndex -2; |
|
2560 aDistance -=distancefactor; |
|
2561 } |
|
2562 } |
|
2563 int changeInPosY = (((mData->mItemStruct.posy - mData->mHighlightItemStruct.posy)*Abs(aDistance))/distancefactor); |
|
2564 int changeInWidth = (((mData->mHighlightItemStruct.width - mData->mItemStruct.width)*Abs(aDistance))/distancefactor); |
|
2565 int changeInHeight = (((mData->mHighlightItemStruct.height - mData->mItemStruct.height)*Abs(aDistance))/distancefactor); |
|
2566 |
|
2567 |
|
2568 int posX = highlightPosX - mData->mVisibleCount*(mData->mItemStruct.width + mData->mPadding); |
|
2569 for (int i=0; i < totalVisual && i < mData->mIconFlowLayout->Count(); i++) |
|
2570 { |
|
2571 CAlfVisual& deckLayout = mData->mIconFlowLayout->Visual(i); |
|
2572 if (i == visualIndexToShrink) |
|
2573 { |
|
2574 int posY = mData->mHighlightItemStruct.posy + changeInPosY; |
|
2575 int width =mData->mHighlightItemStruct.width - changeInWidth; |
|
2576 int height =mData->mHighlightItemStruct.height - changeInHeight; |
|
2577 deckLayout.SetPos( TAlfTimedPoint(posX,posY,aAnimationTime)); |
|
2578 imageVisual = deckLayout.FindTag(KCoverflowIcon); |
|
2579 deckLayout.SetSize(TAlfTimedPoint(width,height,aAnimationTime)); |
|
2580 imageVisual->SetSize(TAlfTimedPoint(width,height,aAnimationTime)); |
|
2581 posX = posX + width + mData->mPadding; |
|
2582 } |
|
2583 else if (i == visualIndexToGrow) |
|
2584 { |
|
2585 int posY = mData->mItemStruct.posy - changeInPosY; |
|
2586 int width = mData->mItemStruct.width + changeInWidth; |
|
2587 int height = mData->mItemStruct.height + changeInHeight; |
|
2588 deckLayout.SetPos( TAlfTimedPoint(posX,posY,aAnimationTime)); |
|
2589 imageVisual = deckLayout.FindTag(KCoverflowIcon); |
|
2590 deckLayout.SetSize(TAlfTimedPoint(width,height,aAnimationTime)); |
|
2591 imageVisual->SetSize(TAlfTimedPoint(width,height,aAnimationTime)); |
|
2592 posX = posX + width + mData->mPadding; |
|
2593 } |
|
2594 else if (i == updateSpecialIndex) |
|
2595 { |
|
2596 deckLayout.SetPos( TAlfTimedPoint(posX,mData->mItemStruct.posy,aAnimationTime)); |
|
2597 imageVisual = deckLayout.FindTag(KCoverflowIcon); |
|
2598 deckLayout.SetSize(TAlfTimedPoint(mData->mItemStruct.width,mData->mItemStruct.height,aAnimationTime)); |
|
2599 imageVisual->SetSize(TAlfTimedPoint(mData->mItemStruct.width,mData->mItemStruct.height,aAnimationTime)); |
|
2600 posX = posX + mData->mItemStruct.width + mData->mPadding; |
|
2601 } |
|
2602 else |
|
2603 { |
|
2604 deckLayout.SetPos( TAlfTimedPoint(posX,mData->mItemStruct.posy,aAnimationTime)); |
|
2605 posX = posX + mData->mItemStruct.width + mData->mPadding; |
|
2606 } |
|
2607 } |
|
2608 } |
|
2609 |
|
2610 // ---------------------------------------------------------------------------- |
|
2611 //RecycleIconVisuals |
|
2612 // ---------------------------------------------------------------------------- |
|
2613 // |
|
2614 void MulBaseElement::RecycleIconVisuals() |
|
2615 { |
|
2616 MUL_LOG_ENTRY_EXIT("aakash::MulBaseElement::RecycleIconVisuals"); |
|
2617 CAlfTextureManager& textureMgr = control().Env().TextureManager(); |
|
2618 TAlfImage image = TAlfImage(textureMgr.BlankTexture()); |
|
2619 |
|
2620 for(int i=0; i<mData->mIconFlowLayout->Count(); i++) |
|
2621 { |
|
2622 CAlfVisual& visual = mData->mIconFlowLayout->Visual(i); |
|
2623 CAlfImageVisual* imageVisual = static_cast<CAlfImageVisual*>(visual.FindTag(KCoverflowIcon)); |
|
2624 // remove the icon brush if any. |
|
2625 RemoveBrushOnIcon(*imageVisual); |
|
2626 imageVisual->SetImage(image); |
|
2627 |
|
2628 CAlfImageVisual* indicatorVisual =static_cast<CAlfImageVisual*>(visual.FindTag(KCoverflowIndicator)); |
|
2629 if(indicatorVisual) |
|
2630 { |
|
2631 indicatorVisual->SetImage(image); |
|
2632 } |
|
2633 } |
|
2634 // cancel the rotation if any. |
|
2635 if (mData->mRotation.mIsApplied) |
|
2636 { |
|
2637 if (mData->mRotation.mIndex >= 0) |
|
2638 { |
|
2639 CancelRotation(mData->mRotation.mIndex); |
|
2640 } |
|
2641 else |
|
2642 { |
|
2643 // rotation applied on highlight index. |
|
2644 // so cancel it. |
|
2645 mData->mRotation.mIndex = 1; |
|
2646 CancelRotation(mData->mRotation.mIndex); |
|
2647 } |
|
2648 } |
|
2649 } |
|
2650 |
|
2651 // ---------------------------------------------------------------------------- |
|
2652 //IdToTag |
|
2653 // ---------------------------------------------------------------------------- |
|
2654 // |
|
2655 const TDesC8& MulBaseElement::IdToTag( int aId ) |
|
2656 { |
|
2657 MUL_LOG_ENTRY_EXIT("aakash::MulBaseElement::IdToTag"); |
|
2658 switch( aId ) |
|
2659 { |
|
2660 case mulvisualitem::KMulIcon1 : |
|
2661 { |
|
2662 return KCoverflowIcon; |
|
2663 } |
|
2664 case mulvisualitem::KMulTitle : |
|
2665 { |
|
2666 return KCoverflowTitle; |
|
2667 } |
|
2668 case mulvisualitem::KMulDetail : |
|
2669 { |
|
2670 return KCoverflowDetail; |
|
2671 } |
|
2672 case mulvisualitem::KMulIndicator2 : |
|
2673 { |
|
2674 return KCoverflowIndicator; |
|
2675 } |
|
2676 default: |
|
2677 { |
|
2678 return KInvalidID; |
|
2679 } |
|
2680 } |
|
2681 } |
|
2682 |
|
2683 // --------------------------------------------------------------------------- |
|
2684 // RemoveSliderFromLayout |
|
2685 // --------------------------------------------------------------------------- |
|
2686 // |
|
2687 void MulBaseElement::RemoveSliderFromLayout() |
|
2688 { |
|
2689 MUL_LOG_ENTRY_EXIT("aakash::MulBaseElement::RemoveSliderFromLayout"); |
|
2690 IAlfWidget* slider = (static_cast<MulCoverFlowControl&>(control())).GetSliderWidget(); |
|
2691 if(slider && slider->control()) |
|
2692 { |
|
2693 IMulSliderWidget* sliderwidget = static_cast<IMulSliderWidget*>(slider); |
|
2694 CAlfLayout* sliderContlyt = const_cast<CAlfLayout*>(sliderwidget->control()->ContainerLayout(NULL)); |
|
2695 mData->mVerticalFlow->Remove(sliderContlyt); |
|
2696 } |
|
2697 |
|
2698 } |
|
2699 |
|
2700 // --------------------------------------------------------------------------- |
|
2701 // RotateImage |
|
2702 // --------------------------------------------------------------------------- |
|
2703 // |
|
2704 void MulBaseElement::RotateImage(IMulWidget::TMulRotation aDirection,TSize aImageSize,int aAnimationTime,bool aAdjustSize) |
|
2705 { |
|
2706 MUL_LOG_ENTRY_EXIT("aakash::MulBaseElement::RotateImage"); |
|
2707 |
|
2708 __MUL_ASSERT( mData->mIconFlowLayout->Count() != 0,KNullPointer); |
|
2709 |
|
2710 if (Template2D()->IsUiOnOffFlagEnabled()) |
|
2711 { |
|
2712 CAlfVisual& visual = mData->mIconFlowLayout->Visual(1); |
|
2713 CAlfImageVisual* imageVisual = static_cast<CAlfImageVisual*>(visual.FindTag(KCoverflowIcon)); |
|
2714 |
|
2715 if (!aAdjustSize) |
|
2716 { |
|
2717 // Take care the case where rotation was |
|
2718 // applied to the previous highlight index |
|
2719 // cancel the rotation on that visual |
|
2720 CancelRotation(mData->mRotation.mIndex); |
|
2721 |
|
2722 switch(aDirection) |
|
2723 { |
|
2724 case IMulWidget::ERotateLeft: |
|
2725 { |
|
2726 mData->mRotation.mImageAngle = (mData->mRotation.mImageAngle + 90)%360; |
|
2727 imageVisual->EnableTransformationL(); |
|
2728 imageVisual->Transformation().Rotate(TAlfTimedValue(90,aAnimationTime)); |
|
2729 mData->mRotation.mIsApplied = true; |
|
2730 break; |
|
2731 } |
|
2732 case IMulWidget::ERotateRight: |
|
2733 { |
|
2734 mData->mRotation.mImageAngle = (mData->mRotation.mImageAngle - 90)%360; |
|
2735 imageVisual->EnableTransformationL(); |
|
2736 imageVisual->Transformation().Rotate(TAlfTimedValue(-90,aAnimationTime)); |
|
2737 mData->mRotation.mIsApplied = true; |
|
2738 break; |
|
2739 } |
|
2740 default: |
|
2741 break; |
|
2742 } |
|
2743 // store the actual texture size of image to be rotated. |
|
2744 mData->mRotation.mTextureSize = aImageSize; |
|
2745 } |
|
2746 |
|
2747 AdjustVisualSizeInRotation(imageVisual, aAnimationTime); |
|
2748 } |
|
2749 } |
|
2750 |
|
2751 // --------------------------------------------------------------------------- |
|
2752 // AdjustVisualSizeInRotation |
|
2753 // --------------------------------------------------------------------------- |
|
2754 // |
|
2755 void MulBaseElement::AdjustVisualSizeInRotation(CAlfImageVisual* aVisual,int aAnimationTime) |
|
2756 { |
|
2757 MUL_LOG_ENTRY_EXIT("aakash::MulBaseElement::AdjustVisualSizeInRotation"); |
|
2758 |
|
2759 bool isLandScape = static_cast<MulCoverFlowControl&>(control()).IsLandscape(); |
|
2760 int shortEdge = !isLandScape ? mData->mHighlightItemStruct.width : mData->mHighlightItemStruct.height; |
|
2761 |
|
2762 if( mData->mRotation.mTextureSize.iWidth <= shortEdge && mData->mRotation.mTextureSize.iHeight <= shortEdge) |
|
2763 { |
|
2764 return; |
|
2765 } |
|
2766 else |
|
2767 { |
|
2768 switch(Abs(mData->mRotation.mImageAngle)) |
|
2769 { |
|
2770 case 90: |
|
2771 case 270: |
|
2772 { |
|
2773 HandleRotationOnVerticalAxis(aVisual,aAnimationTime); |
|
2774 } |
|
2775 break; |
|
2776 case 0: |
|
2777 case 180: |
|
2778 { |
|
2779 HandleRotationOnHorizontalAxis(aVisual,aAnimationTime); |
|
2780 } |
|
2781 break; |
|
2782 default: |
|
2783 break; |
|
2784 } |
|
2785 } |
|
2786 } |
|
2787 |
|
2788 // --------------------------------------------------------------------------- |
|
2789 // HandleRotationOnVerticalAxis |
|
2790 // --------------------------------------------------------------------------- |
|
2791 // |
|
2792 void MulBaseElement::HandleRotationOnVerticalAxis(CAlfImageVisual* aVisual,int aAnimationTime) |
|
2793 { |
|
2794 MUL_LOG_ENTRY_EXIT("aakash::MulBaseElement::HandleRotationOnVerticalAxis"); |
|
2795 |
|
2796 bool isLandScape = static_cast<MulCoverFlowControl&>(control()).IsLandscape(); |
|
2797 int longEdge = isLandScape ? mData->mHighlightItemStruct.width : mData->mHighlightItemStruct.height; |
|
2798 int shortEdge = !isLandScape ? mData->mHighlightItemStruct.width : mData->mHighlightItemStruct.height; |
|
2799 |
|
2800 if (isLandScape) |
|
2801 { |
|
2802 if(mData->mRotation.mTextureSize.iWidth > shortEdge) |
|
2803 { |
|
2804 // make the visual of shortEdge size and fit the image by width. |
|
2805 aVisual->SetPos(TAlfRealPoint(longEdge/2 - shortEdge/2,0),aAnimationTime); |
|
2806 aVisual->SetSize(TAlfRealSize(shortEdge,shortEdge),aAnimationTime); |
|
2807 aVisual->SetScaleMode(CAlfImageVisual::EScaleFitWidth); |
|
2808 } |
|
2809 else |
|
2810 { |
|
2811 //imageHeight > shortEdge and imageWidth < shortEdge |
|
2812 if (mData->mRotation.mTextureSize.iHeight > longEdge) |
|
2813 { |
|
2814 aVisual->SetPos(TAlfRealPoint(longEdge/2 - shortEdge/2,shortEdge/2 -longEdge/2),aAnimationTime); |
|
2815 aVisual->SetSize(TAlfRealSize(shortEdge,longEdge),aAnimationTime); |
|
2816 } |
|
2817 else |
|
2818 { |
|
2819 aVisual->SetPos(TAlfRealPoint(longEdge/2 - shortEdge/2,shortEdge/2 - mData->mRotation.mTextureSize.iHeight/2),aAnimationTime); |
|
2820 aVisual->SetSize(TAlfRealSize(shortEdge,mData->mRotation.mTextureSize.iHeight),aAnimationTime); |
|
2821 } |
|
2822 aVisual->SetScaleMode(CAlfImageVisual::EScaleFitHeight); |
|
2823 } |
|
2824 } |
|
2825 else |
|
2826 { |
|
2827 if(mData->mRotation.mTextureSize.iHeight > shortEdge) |
|
2828 { |
|
2829 // make the visual of shortEdge size and fit the image by height. |
|
2830 aVisual->SetPos(TAlfRealPoint(0,longEdge/2 - shortEdge/2),aAnimationTime); |
|
2831 aVisual->SetSize(TAlfRealSize(shortEdge,shortEdge),aAnimationTime); |
|
2832 aVisual->SetScaleMode(CAlfImageVisual::EScaleFitHeight); |
|
2833 } |
|
2834 else |
|
2835 { |
|
2836 //imageWidth > shortEdge and imageHeight < shortEdge |
|
2837 if (mData->mRotation.mTextureSize.iWidth > longEdge) |
|
2838 { |
|
2839 aVisual->SetPos(TAlfRealPoint(shortEdge/2 - longEdge/2,longEdge/2 - shortEdge/2),aAnimationTime); |
|
2840 aVisual->SetSize(TAlfRealSize(longEdge,shortEdge),aAnimationTime); |
|
2841 } |
|
2842 else |
|
2843 { |
|
2844 aVisual->SetPos(TAlfRealPoint(shortEdge/2 - mData->mRotation.mTextureSize.iWidth/2,longEdge/2 - shortEdge/2),aAnimationTime); |
|
2845 aVisual->SetSize(TAlfRealSize(mData->mRotation.mTextureSize.iWidth,shortEdge),aAnimationTime); |
|
2846 } |
|
2847 // @todo check if this effective height after fit by width can ever be more than |
|
2848 // the shorter edge. If yes then this fit mode should be chnged to fit inside(check this) |
|
2849 aVisual->SetScaleMode(CAlfImageVisual::EScaleFitWidth); |
|
2850 } |
|
2851 } |
|
2852 } |
|
2853 |
|
2854 // --------------------------------------------------------------------------- |
|
2855 // HandleRotationOnHorizontalAxis |
|
2856 // --------------------------------------------------------------------------- |
|
2857 // |
|
2858 void MulBaseElement::HandleRotationOnHorizontalAxis(CAlfImageVisual* aVisual,int aAnimationTime) |
|
2859 { |
|
2860 MUL_LOG_ENTRY_EXIT("aakash::MulBaseElement::HandleRotationOnHorizontalAxis"); |
|
2861 |
|
2862 aVisual->SetPos(TAlfRealPoint(0,0),aAnimationTime); |
|
2863 aVisual->SetSize(TAlfRealSize(mData->mHighlightItemStruct.width,mData->mHighlightItemStruct.height),aAnimationTime); |
|
2864 ApplyScaleMode(*aVisual); |
|
2865 } |
|
2866 |
|
2867 // --------------------------------------------------------------------------- |
|
2868 // CancelRotation |
|
2869 // --------------------------------------------------------------------------- |
|
2870 // |
|
2871 void MulBaseElement::CancelRotation(int aIndex) |
|
2872 { |
|
2873 MUL_LOG_ENTRY_EXIT("aakash::MulBaseElement::CancelRotation"); |
|
2874 |
|
2875 if (mData->mRotation.mIsApplied) |
|
2876 { |
|
2877 if (mData->mRotation.mIndex >= 0) |
|
2878 { |
|
2879 // revert it back |
|
2880 mData->mRotation.mImageAngle = 0; |
|
2881 CAlfVisual& deckLayout = mData->mIconFlowLayout->Visual(mData->mRotation.mIndex); |
|
2882 CAlfImageVisual* imageVisual = static_cast<CAlfImageVisual*>(deckLayout.FindTag(KCoverflowIcon)); |
|
2883 imageVisual->EnableTransformationL(); |
|
2884 imageVisual->Transformation().LoadIdentity(); |
|
2885 // reset the rotation property |
|
2886 mData->mRotation.mIsApplied = false; |
|
2887 mData->mRotation.mIndex = -1; |
|
2888 imageVisual->SetPos(TAlfRealPoint(0,0)); |
|
2889 imageVisual->SetSize(TAlfRealSize(mData->mHighlightItemStruct.width,mData->mHighlightItemStruct.height)); |
|
2890 ApplyScaleMode(*imageVisual); |
|
2891 } |
|
2892 else |
|
2893 { |
|
2894 mData->mRotation.mIndex = aIndex; |
|
2895 } |
|
2896 } |
|
2897 } |
|
2898 |
|
2899 // --------------------------------------------------------------------------- |
|
2900 // CancelRotationOnUpdate |
|
2901 // --------------------------------------------------------------------------- |
|
2902 // |
|
2903 void MulBaseElement::CancelRotationOnUpdate(int aIndex) |
|
2904 { |
|
2905 MUL_LOG_ENTRY_EXIT("aakash::MulBaseElement::CancelRotationOnUpdate"); |
|
2906 |
|
2907 if (mData->mRotation.mIsApplied) |
|
2908 { |
|
2909 if (mData->mRotation.mIndex < 0 || mData->mRotation.mIndex == aIndex) |
|
2910 { |
|
2911 // revert it back |
|
2912 mData->mRotation.mImageAngle = 0; |
|
2913 CAlfVisual& deckLayout = mData->mIconFlowLayout->Visual(aIndex); |
|
2914 CAlfImageVisual* imageVisual = static_cast<CAlfImageVisual*>(deckLayout.FindTag(KCoverflowIcon)); |
|
2915 imageVisual->EnableTransformationL(); |
|
2916 imageVisual->Transformation().LoadIdentity(); |
|
2917 // reset the rotation property |
|
2918 mData->mRotation.mIsApplied = false; |
|
2919 mData->mRotation.mIndex = -1; |
|
2920 imageVisual->SetPos(TAlfRealPoint(0,0)); |
|
2921 imageVisual->SetSize(TAlfRealSize(mData->mHighlightItemStruct.width,mData->mHighlightItemStruct.height)); |
|
2922 ApplyScaleMode(*imageVisual); |
|
2923 } |
|
2924 } |
|
2925 } |
|
2926 |
|
2927 // --------------------------------------------------------------------------- |
|
2928 // UpdateRotation |
|
2929 // --------------------------------------------------------------------------- |
|
2930 // |
|
2931 void MulBaseElement::UpdateRotation() |
|
2932 { |
|
2933 MUL_LOG_ENTRY_EXIT("aakash::MulBaseElement::UpdateRotation"); |
|
2934 |
|
2935 if (mData->mRotation.mIsApplied) |
|
2936 { |
|
2937 // rotation applied on the highlight item. |
|
2938 if (mData->mRotation.mIndex < 0) |
|
2939 { |
|
2940 RotateImage(IMulWidget::ERotateLeft,TSize(0,0),0,true); |
|
2941 } |
|
2942 } |
|
2943 } |
|
2944 |
|
2945 } //namespace Alf |
|
2946 |
|
2947 //End of file |