20
|
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: Widget Control Implementation
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
|
|
19 |
// Include Files
|
|
20 |
|
|
21 |
// Class Headers
|
|
22 |
#include "mulcoverflowcontrol.h"
|
|
23 |
|
|
24 |
#include <AknUtils.h>
|
|
25 |
// Alf Headers
|
|
26 |
#include <alf/alfenv.h>
|
|
27 |
// for dosetimage func
|
|
28 |
#include <alf/alfimageloaderutil.h>
|
|
29 |
#include <alf/alfbitmapprovider.h>
|
|
30 |
#include <alf/alfdisplay.h>
|
|
31 |
#include <alf/alfresourcepool.h> //for resource pooling
|
|
32 |
#include <alf/alfwidgetenvextension.h> //for resource pooling
|
|
33 |
#include <alf/alfutil.h>
|
|
34 |
#include <alf/alfimagevisual.h>
|
|
35 |
|
|
36 |
// Mul Headers
|
|
37 |
#include <mul/mulevent.h>
|
|
38 |
#include <mul/imulsliderwidget.h>
|
|
39 |
|
|
40 |
|
|
41 |
// Gesture Helper
|
|
42 |
#include <gesturehelper.h>
|
|
43 |
|
|
44 |
// Local Headers
|
|
45 |
#include "mulbaseelement.h"
|
|
46 |
#include "mulcoverflowao.h"
|
|
47 |
#include "mulcoverflowtemplate.h"
|
|
48 |
#include "mulcoverflowwidget.h"
|
|
49 |
#include "mulleave.h" //for leaving function
|
|
50 |
#include "mullog.h" //for logs
|
|
51 |
#include "mulassert.h"
|
|
52 |
#include "imulmodelaccessor.h"
|
|
53 |
|
|
54 |
//Gesture Helper
|
|
55 |
using namespace GestureHelper;
|
|
56 |
|
|
57 |
namespace Alf
|
|
58 |
{
|
|
59 |
|
|
60 |
struct TMulCoverFlowControlImpl
|
|
61 |
{
|
|
62 |
TMulCoverFlowControlImpl()
|
|
63 |
{
|
|
64 |
mHighlightIndex = -1;
|
|
65 |
mScreenWidth = 0;
|
|
66 |
mScreenHeight = 0;
|
|
67 |
mGestureSpeed = 0;
|
|
68 |
mCoverFlow2DTemplate = NULL;
|
|
69 |
mIsWidgetVisible = true; //by default widget is visible .
|
|
70 |
mBaseElement = NULL;
|
|
71 |
mFastScroll = false;
|
|
72 |
mNumVisibleItem = 0;
|
|
73 |
mDefaultTextureId = -1;
|
|
74 |
mBounceInProgress = false;
|
|
75 |
mDirectionChanged = false;
|
|
76 |
mDontBounce = false;
|
|
77 |
mNumberOfRepeatEvents = 0;
|
|
78 |
mIsMirrored = false;
|
|
79 |
}
|
|
80 |
|
|
81 |
/// @bug critical:avanhata:4/7/2008 you should never cache a property that is a property of
|
|
82 |
/// another class. The model exists to own this type of information. I gave this review comment
|
|
83 |
/// as "critical", since it is exactly these cached member variables that will
|
|
84 |
/// yield most of bugs and complexity. Refactor it away.
|
|
85 |
int mHighlightIndex;
|
|
86 |
|
|
87 |
int mScreenWidth;
|
|
88 |
int mScreenHeight;
|
|
89 |
bool mIsWidgetVisible;
|
|
90 |
MulBaseElement* mBaseElement;
|
|
91 |
auto_ptr<MulCoverFlowTemplate> mCoverFlow2DTemplate; // 2D cover flow template //owns
|
|
92 |
TReal32 mGestureSpeed;
|
|
93 |
bool mFastScroll; // Flag to indicate wheher in fast scroll mode or not
|
|
94 |
int mNumVisibleItem;
|
|
95 |
int mDefaultTextureId;
|
|
96 |
bool mBounceInProgress;
|
|
97 |
int mReferencePoint;
|
|
98 |
bool mDirectionChanged;
|
|
99 |
int mCurrGestureDir;
|
|
100 |
bool mDontBounce;
|
|
101 |
int mNumberOfRepeatEvents;
|
|
102 |
bool mIsLandscape;
|
|
103 |
bool mIsMirrored;
|
|
104 |
};
|
|
105 |
|
|
106 |
// ---------------------------------------------------------------------------
|
|
107 |
// MulCoverFlowControl
|
|
108 |
// ---------------------------------------------------------------------------
|
|
109 |
//
|
|
110 |
MulCoverFlowControl::MulCoverFlowControl(CAlfEnv& aEnv )
|
|
111 |
{
|
|
112 |
//Call the base class method
|
|
113 |
MUL_LOG_ENTRY_EXIT("MUL:MulCoverFlowControl::MulCoverFlowControl");
|
|
114 |
CAlfWidgetControl::construct ( aEnv);
|
|
115 |
|
|
116 |
mData.reset( new (EMM)TMulCoverFlowControlImpl );
|
|
117 |
|
|
118 |
mFeedback = MTouchFeedback::Instance();
|
|
119 |
|
|
120 |
if (AknLayoutUtils::LayoutMirrored())
|
|
121 |
{
|
|
122 |
mData->mIsMirrored = true;
|
|
123 |
}
|
|
124 |
else
|
|
125 |
{
|
|
126 |
mData->mIsMirrored = false;
|
|
127 |
}
|
|
128 |
|
|
129 |
mData->mIsLandscape = IsLandscape();
|
|
130 |
|
|
131 |
THROW_IF_LEAVES
|
|
132 |
(
|
|
133 |
/// @bug critical:avanhata:30/9/2008 this is a symbian code section. don't call throwing osn code here.
|
|
134 |
/// Throwing within a TRAP is at best undefined
|
|
135 |
mCoverFlowAo.reset( new(EMM) MulCoverFlowAo( *this ) );
|
|
136 |
|
|
137 |
mHelper.reset(GestureHelper::CGestureHelper::NewL( *this ));
|
|
138 |
mHelper->InitAlfredPointerCaptureL( aEnv, aEnv.PrimaryDisplay(), KGroupId );
|
|
139 |
mHelper->SetHoldingEnabled( EFalse );
|
|
140 |
)
|
|
141 |
}
|
|
142 |
|
|
143 |
// ---------------------------------------------------------------------------
|
|
144 |
// ~MulCoverFlowControl
|
|
145 |
// ---------------------------------------------------------------------------
|
|
146 |
//
|
|
147 |
MulCoverFlowControl::~MulCoverFlowControl()
|
|
148 |
{
|
|
149 |
MUL_LOG_ENTRY_EXIT("MUL:MulCoverFlowControl::~MulCoverFlowControl");
|
|
150 |
|
|
151 |
if( ModelAccessor() != NULL )
|
|
152 |
{
|
|
153 |
ModelAccessor()->RemoveModelObserver(this);
|
|
154 |
}
|
|
155 |
|
|
156 |
DestroySlider();
|
|
157 |
|
|
158 |
}
|
|
159 |
|
|
160 |
// ---------------------------------------------------------------------------
|
|
161 |
// makeInterface
|
|
162 |
// ---------------------------------------------------------------------------
|
|
163 |
//
|
|
164 |
IAlfInterfaceBase* MulCoverFlowControl::makeInterface( const IfId& aType )
|
|
165 |
{
|
|
166 |
MUL_LOG_ENTRY_EXIT("MUL:MulCoverFlowControl::makeInterface");
|
|
167 |
UString param(aType.mImplementationId);
|
|
168 |
return CAlfWidgetControl::makeInterface( aType );
|
|
169 |
}
|
|
170 |
|
|
171 |
// ---------------------------------------------------------------------------
|
|
172 |
// ResetShowWidgetFlag
|
|
173 |
// ---------------------------------------------------------------------------
|
|
174 |
//
|
|
175 |
void MulCoverFlowControl::ResetShowWidgetFlag( bool aNewResetValue )
|
|
176 |
{
|
|
177 |
MUL_LOG_ENTRY_EXIT("MUL:MulCoverFlowControl::ResetShowWidgetFlag");
|
|
178 |
mData->mIsWidgetVisible = aNewResetValue;
|
|
179 |
if( aNewResetValue)
|
|
180 |
{
|
|
181 |
mHelper->AddObserver(this);
|
|
182 |
}
|
|
183 |
}
|
|
184 |
|
|
185 |
// ---------------------------------------------------------------------------
|
|
186 |
// Template2D
|
|
187 |
// ---------------------------------------------------------------------------
|
|
188 |
//
|
|
189 |
MulCoverFlowTemplate* MulCoverFlowControl::Template2D()
|
|
190 |
{
|
|
191 |
MUL_LOG_ENTRY_EXIT("MUL:MulCoverFlowControl::Template2D");
|
|
192 |
return mData->mCoverFlow2DTemplate.get();
|
|
193 |
}
|
|
194 |
|
|
195 |
// ---------------------------------------------------------------------------
|
|
196 |
// IsFastScrollMode
|
|
197 |
// ---------------------------------------------------------------------------
|
|
198 |
//
|
|
199 |
bool MulCoverFlowControl::IsFastScrollMode()
|
|
200 |
{
|
|
201 |
MUL_LOG_ENTRY_EXIT("MUL:MulCoverFlowControl::IsFastScrollMode");
|
|
202 |
return mData->mFastScroll;
|
|
203 |
}
|
|
204 |
|
|
205 |
|
|
206 |
//-----------------------Event Handling API's -------------------------------
|
|
207 |
// ---------------------------------------------------------------------------
|
|
208 |
// handleEvent
|
|
209 |
// ---------------------------------------------------------------------------
|
|
210 |
//
|
|
211 |
AlfEventStatus MulCoverFlowControl::handleEvent(const TAlfEvent& aEvent)
|
|
212 |
{
|
|
213 |
MUL_LOG_ENTRY_EXIT("MUL:MulCoverFlowControl::handleEvent");
|
|
214 |
if( aEvent.IsCustomEvent() )
|
|
215 |
{
|
|
216 |
return HandleCustomEvent( aEvent );
|
|
217 |
}
|
|
218 |
else if( aEvent.IsKeyEvent() && mData->mIsWidgetVisible )
|
|
219 |
{
|
|
220 |
if(TotalModelCount() <= KMinNumItemForFastScroll ||
|
|
221 |
aEvent.KeyEvent().iRepeats == 0 )
|
|
222 |
{
|
|
223 |
return HandleKeyEvent( aEvent );
|
|
224 |
}
|
|
225 |
else
|
|
226 |
{
|
|
227 |
return HandleRepeatKeyEvent( aEvent );
|
|
228 |
}
|
|
229 |
}
|
|
230 |
else if( aEvent.IsPointerEvent() && mData->mIsWidgetVisible )
|
|
231 |
{
|
|
232 |
MUL_LOG_INFO("MUL::MulCoverFlowControl: handleEvent ::pointer event");
|
|
233 |
//commented as gives warning in armv5
|
|
234 |
//THROW_IF_LEAVES
|
|
235 |
//(
|
|
236 |
TBool result = mHelper->OfferEventL(aEvent);
|
|
237 |
MUL_LOG_INFO1("MUL::MulCoverFlowControl: handleEvent::result %d ",result);
|
|
238 |
return result ? EEventConsumed :EEventNotHandled ;
|
|
239 |
// )
|
|
240 |
}
|
|
241 |
return EEventNotHandled;
|
|
242 |
}
|
|
243 |
// ---------------------------------------------------------------------------
|
|
244 |
// HandleCustomEvent
|
|
245 |
// ---------------------------------------------------------------------------
|
|
246 |
//
|
|
247 |
AlfEventStatus MulCoverFlowControl::HandleCustomEvent( const TAlfEvent& aEvent )
|
|
248 |
{
|
|
249 |
MUL_LOG_ENTRY_EXIT("MUL:MulCoverFlowControl::HandleCustomEvent");
|
|
250 |
AlfEventStatus eventConsumed = EEventNotHandled;
|
|
251 |
switch( aEvent.CustomParameter() )
|
|
252 |
{
|
|
253 |
case ECustomEventBounceBack:
|
|
254 |
{
|
|
255 |
MUL_LOG_INFO("MUL::MulCF:Handle custom event Compensate Bounce");
|
|
256 |
mFeedback->InstantFeedback(ETouchFeedbackBasic);
|
|
257 |
mData->mBaseElement->StopDoodling(/*3*KBounceTime*/500);
|
|
258 |
if ((TotalModelCount() > 1 && mData->mNumVisibleItem == 1) ||
|
|
259 |
(TotalModelCount() > 2))
|
|
260 |
{
|
|
261 |
Env().Send(TAlfCustomEventCommand(ECustomEventScroll, this),500/*3*KBounceTime*/ + 30);
|
|
262 |
}
|
|
263 |
else
|
|
264 |
{
|
|
265 |
//start marquee in case of text is visible.
|
|
266 |
if(mData->mBaseElement->IsTextVisibile())
|
|
267 |
{
|
|
268 |
//start marquee after 1 sec (after doodle completed)
|
|
269 |
Env().Send(TAlfCustomEventCommand(
|
|
270 |
ECustomEventMarqueeStart, this),500/*3*KBounceTime*/ + KMarqueeTime1000);
|
|
271 |
}
|
|
272 |
// if only one item is there then no need to scroll.
|
|
273 |
mData->mBounceInProgress = false;
|
|
274 |
}
|
|
275 |
eventConsumed = EEventConsumed;
|
|
276 |
break;
|
|
277 |
}
|
|
278 |
case ECustomEventScroll:
|
|
279 |
{
|
|
280 |
MUL_LOG_INFO("MUL::MulCF:Handle custom event Compensate Bounce");
|
|
281 |
Env().Send(TAlfCustomEventCommand(ECustomEventBounceCompleted,this),600);
|
|
282 |
|
|
283 |
if (mData->mHighlightIndex == 0)
|
|
284 |
{
|
|
285 |
DoSetFocusIndex(TotalModelCount() -1,/*4*KBounceTime*/800);
|
|
286 |
}
|
|
287 |
else
|
|
288 |
{
|
|
289 |
DoSetFocusIndex(0,800);
|
|
290 |
}
|
|
291 |
SetSliderTickPosition();
|
|
292 |
eventConsumed = EEventConsumed;
|
|
293 |
break;
|
|
294 |
}
|
|
295 |
case ECustomEventBounceCompleted:
|
|
296 |
{
|
|
297 |
mData->mBounceInProgress = false;
|
|
298 |
eventConsumed = EEventConsumed;
|
|
299 |
break;
|
|
300 |
}
|
|
301 |
case ECustomEventMarqueeStart:
|
|
302 |
{
|
|
303 |
mData->mBaseElement->StartMarquee(mulvisualitem::KMulTitle);
|
|
304 |
eventConsumed = EEventConsumed;
|
|
305 |
break;
|
|
306 |
}
|
|
307 |
case ECustomEventTitleMarqueeFinished:
|
|
308 |
{
|
|
309 |
mData->mBaseElement->StopMarquee(mulvisualitem::KMulTitle);
|
|
310 |
eventConsumed = EEventConsumed;
|
|
311 |
break;
|
|
312 |
}
|
|
313 |
case ECustomEventDetailMarqueeStart:
|
|
314 |
{
|
|
315 |
mData->mBaseElement->StartMarquee(mulvisualitem::KMulDetail);
|
|
316 |
eventConsumed = EEventConsumed;
|
|
317 |
break;
|
|
318 |
}
|
|
319 |
case ECustomEventMarqueeFinished:
|
|
320 |
{
|
|
321 |
mData->mBaseElement->StopMarquee(mulvisualitem::KMulDetail);
|
|
322 |
eventConsumed = EEventConsumed;
|
|
323 |
break;
|
|
324 |
}
|
|
325 |
default: break;
|
|
326 |
}
|
|
327 |
return eventConsumed;
|
|
328 |
}
|
|
329 |
|
|
330 |
// ---------------------------------------------------------------------------
|
|
331 |
// HandleKeyEvent
|
|
332 |
// ---------------------------------------------------------------------------
|
|
333 |
//
|
|
334 |
AlfEventStatus MulCoverFlowControl::HandleKeyEvent( const TAlfEvent& aEvent )
|
|
335 |
{
|
|
336 |
MUL_LOG_ENTRY_EXIT("MUL:MulCoverFlowControl::HandleKeyEvent");
|
|
337 |
AlfEventStatus eventConsumed = EEventNotHandled;
|
|
338 |
if( aEvent.Code() == EEventKey)
|
|
339 |
{
|
|
340 |
switch ( aEvent.KeyEvent().iCode )
|
|
341 |
{
|
|
342 |
case EKeyEnter:
|
|
343 |
// Event when selection key is pressed .( key event )
|
|
344 |
case EKeyDeviceA:
|
|
345 |
case EKeyDevice3:
|
|
346 |
{
|
|
347 |
if(aEvent.KeyEvent().iRepeats == 0)
|
|
348 |
{
|
|
349 |
if(TotalModelCount() <= 0 && mData->mBaseElement->IsEmptyText() )
|
|
350 |
{
|
|
351 |
SetSelection(mData->mHighlightIndex);
|
|
352 |
eventConsumed = EEventConsumed;
|
|
353 |
}
|
|
354 |
else if( TotalModelCount() > 0 )
|
|
355 |
{
|
|
356 |
SetSelection(mData->mHighlightIndex);
|
|
357 |
eventConsumed = EEventConsumed;
|
|
358 |
}
|
|
359 |
break;
|
|
360 |
}
|
|
361 |
}
|
|
362 |
case EKeyRightArrow:
|
|
363 |
{
|
|
364 |
// Send event to inform that the Right Key is pressed
|
|
365 |
if (mData->mIsMirrored)
|
|
366 |
{
|
|
367 |
HandleNavigationEvent ( EEventScrollLeft );
|
|
368 |
}
|
|
369 |
else
|
|
370 |
{
|
|
371 |
HandleNavigationEvent ( EEventScrollRight );
|
|
372 |
}
|
|
373 |
eventConsumed = EEventConsumed;
|
|
374 |
break;
|
|
375 |
}
|
|
376 |
|
|
377 |
case EKeyLeftArrow:
|
|
378 |
{
|
|
379 |
// Send event to inform that the Left Key is pressed
|
|
380 |
if (mData->mIsMirrored)
|
|
381 |
{
|
|
382 |
HandleNavigationEvent ( EEventScrollRight );
|
|
383 |
}
|
|
384 |
else
|
|
385 |
{
|
|
386 |
HandleNavigationEvent ( EEventScrollLeft );
|
|
387 |
}
|
|
388 |
eventConsumed = EEventConsumed;
|
|
389 |
break;
|
|
390 |
}
|
|
391 |
case EKeyBackspace:
|
|
392 |
//case EKeyDelete:
|
|
393 |
{
|
|
394 |
CAlfWidgetControl::processEvent( TAlfEvent( ETypeRemove,mData->mHighlightIndex));
|
|
395 |
eventConsumed = EEventConsumed;
|
|
396 |
break;
|
|
397 |
}
|
|
398 |
default:
|
|
399 |
{
|
|
400 |
break;
|
|
401 |
}
|
|
402 |
}
|
|
403 |
}
|
|
404 |
|
|
405 |
else if(aEvent.Code() == EEventKeyUp)
|
|
406 |
{
|
|
407 |
mData->mNumberOfRepeatEvents = 0;
|
|
408 |
switch ( aEvent.KeyEvent().iScanCode )
|
|
409 |
{
|
|
410 |
case EStdKeyRightArrow:
|
|
411 |
case EStdKeyLeftArrow:
|
|
412 |
{
|
|
413 |
if(mData->mFastScroll)
|
|
414 |
{
|
|
415 |
HandleEnhancedStop();
|
|
416 |
eventConsumed = EEventConsumed;
|
|
417 |
}
|
|
418 |
break;
|
|
419 |
}
|
|
420 |
default:
|
|
421 |
{
|
|
422 |
break;
|
|
423 |
}
|
|
424 |
}
|
|
425 |
}
|
|
426 |
|
|
427 |
return eventConsumed;
|
|
428 |
}
|
|
429 |
|
|
430 |
// ---------------------------------------------------------------------------
|
|
431 |
// HandleRepeatKeyEvent
|
|
432 |
// ---------------------------------------------------------------------------
|
|
433 |
//
|
|
434 |
AlfEventStatus MulCoverFlowControl::HandleRepeatKeyEvent( const TAlfEvent& aEvent )
|
|
435 |
{
|
|
436 |
MUL_LOG_ENTRY_EXIT("MUL:MulCoverFlowControl::HandleHoldGestureEvents");
|
|
437 |
|
|
438 |
AlfEventStatus eventConsumed = EEventNotHandled;
|
|
439 |
if( aEvent.Code() == EEventKey)
|
|
440 |
{
|
|
441 |
switch ( aEvent.KeyEvent().iCode )
|
|
442 |
{
|
|
443 |
case EKeyRightArrow:
|
|
444 |
{
|
|
445 |
if (mData->mIsMirrored)
|
|
446 |
{
|
|
447 |
HandleFastScrollWithKeyEvents(1);
|
|
448 |
}
|
|
449 |
else
|
|
450 |
{
|
|
451 |
HandleFastScrollWithKeyEvents(-1);
|
|
452 |
}
|
|
453 |
eventConsumed = EEventConsumed;
|
|
454 |
break;
|
|
455 |
}
|
|
456 |
|
|
457 |
case EKeyLeftArrow:
|
|
458 |
{
|
|
459 |
if (mData->mIsMirrored)
|
|
460 |
{
|
|
461 |
HandleFastScrollWithKeyEvents(-1);
|
|
462 |
}
|
|
463 |
else
|
|
464 |
{
|
|
465 |
HandleFastScrollWithKeyEvents(1);
|
|
466 |
}
|
|
467 |
eventConsumed = EEventConsumed;
|
|
468 |
break;
|
|
469 |
}
|
|
470 |
default:
|
|
471 |
{
|
|
472 |
break;
|
|
473 |
}
|
|
474 |
}
|
|
475 |
}
|
|
476 |
return eventConsumed;
|
|
477 |
}
|
|
478 |
|
|
479 |
// ---------------------------------------------------------------------------
|
|
480 |
// HandleFastScrollWithKeyEvents
|
|
481 |
// ---------------------------------------------------------------------------
|
|
482 |
//
|
|
483 |
void MulCoverFlowControl::HandleFastScrollWithKeyEvents(int aDirection)
|
|
484 |
{
|
|
485 |
MUL_LOG_ENTRY_EXIT("MUL:MulCoverFlowControl::HandleFastScrollWithKeyEvents");
|
|
486 |
mData->mNumberOfRepeatEvents++;
|
|
487 |
if(mData->mNumberOfRepeatEvents == 1 )
|
|
488 |
{
|
|
489 |
CAlfWidgetControl::processEvent( TAlfEvent( ETypeFastScroll,EScrollStart ));
|
|
490 |
mData->mFastScroll = true;
|
|
491 |
mCoverFlowAo->StartMoving(1, aDirection,true,200);
|
|
492 |
}
|
|
493 |
else if(mData->mNumberOfRepeatEvents == KNumberOfRepeatsForMediumSpeed && mData->mFastScroll )
|
|
494 |
{
|
|
495 |
mCoverFlowAo->StartMoving(1, aDirection,true,150);
|
|
496 |
}
|
|
497 |
else if(mData->mNumberOfRepeatEvents == KNumberOfRepeatsForFastSpeed && mData->mFastScroll )
|
|
498 |
{
|
|
499 |
mCoverFlowAo->StartMoving(1, aDirection,true,100);
|
|
500 |
}
|
|
501 |
}
|
|
502 |
|
|
503 |
// ---------------------------------------------------------------------------
|
|
504 |
// HandleNavigationEvent
|
|
505 |
// ---------------------------------------------------------------------------
|
|
506 |
//
|
|
507 |
void MulCoverFlowControl::HandleNavigationEvent( int aEvent )
|
|
508 |
{
|
|
509 |
MUL_LOG_ENTRY_EXIT("MUL:MulCoverFlowControl::HandleNavigationEvent");
|
|
510 |
|
|
511 |
// During bounce ignore all the events
|
|
512 |
if (mData->mBounceInProgress)
|
|
513 |
{
|
|
514 |
return;
|
|
515 |
}
|
|
516 |
|
|
517 |
int highlightIndex = mData->mHighlightIndex;
|
|
518 |
int totalcount = TotalModelCount();
|
|
519 |
if(totalcount <= 0 && highlightIndex == -1 )
|
|
520 |
{
|
|
521 |
return;
|
|
522 |
}
|
|
523 |
//stop marquee if the navigation is happening.
|
|
524 |
if(mData->mBaseElement->IsTextVisibile())
|
|
525 |
{
|
|
526 |
mData->mBaseElement->StopMarquee(mulvisualitem::KMulTitle);
|
|
527 |
mData->mBaseElement->StopMarquee(mulvisualitem::KMulDetail);
|
|
528 |
}
|
|
529 |
Env().CancelCustomCommands(this);
|
|
530 |
|
|
531 |
//Update the highlight index
|
|
532 |
switch( aEvent )
|
|
533 |
{
|
|
534 |
case EEventScrollRight:
|
|
535 |
{
|
|
536 |
// boundary check
|
|
537 |
if( highlightIndex == totalcount - 1 )
|
|
538 |
{
|
|
539 |
if( !mData->mBounceInProgress && !mData->mDontBounce)
|
|
540 |
{
|
|
541 |
mData->mBounceInProgress = true;
|
|
542 |
mData->mBaseElement->StartBounce(KBounceRight);
|
|
543 |
}
|
|
544 |
else
|
|
545 |
{
|
|
546 |
mData->mBounceInProgress = false;
|
|
547 |
mData->mDontBounce = false;
|
|
548 |
highlightIndex = 0;
|
|
549 |
}
|
|
550 |
}
|
|
551 |
else
|
|
552 |
{
|
|
553 |
highlightIndex++;
|
|
554 |
}
|
|
555 |
|
|
556 |
mData->mBaseElement->SetScrollDir(EItemScrollRight);
|
|
557 |
}
|
|
558 |
break;
|
|
559 |
|
|
560 |
case EEventScrollLeft:
|
|
561 |
{
|
|
562 |
//boundary check
|
|
563 |
if( highlightIndex == 0 )
|
|
564 |
{
|
|
565 |
if( !mData->mBounceInProgress && !mData->mDontBounce)
|
|
566 |
{
|
|
567 |
mData->mBounceInProgress = true;
|
|
568 |
mData->mBaseElement->StartBounce(KBounceLeft);
|
|
569 |
}
|
|
570 |
else
|
|
571 |
{
|
|
572 |
mData->mBounceInProgress = false;
|
|
573 |
mData->mDontBounce = false;
|
|
574 |
highlightIndex = totalcount - 1;
|
|
575 |
}
|
|
576 |
}
|
|
577 |
else
|
|
578 |
{
|
|
579 |
highlightIndex--;
|
|
580 |
}
|
|
581 |
}
|
|
582 |
mData->mBaseElement->SetScrollDir(EItemScrollLeft);
|
|
583 |
break;
|
|
584 |
}
|
|
585 |
|
|
586 |
// to handle bounce checks
|
|
587 |
if( !mData->mBounceInProgress )
|
|
588 |
{
|
|
589 |
DoSetFocusIndex( highlightIndex );
|
|
590 |
SetSliderTickPosition();
|
|
591 |
}
|
|
592 |
}
|
|
593 |
// ---------------------------------------------------------------------------
|
|
594 |
// SendEventToBaseElement
|
|
595 |
// ---------------------------------------------------------------------------
|
|
596 |
//
|
|
597 |
void MulCoverFlowControl::SendEventToBaseElement( const TAlfEvent& aEvent )
|
|
598 |
{
|
|
599 |
MUL_LOG_ENTRY_EXIT("MUL:MulCoverFlowControl::SendEventToBaseElement");
|
|
600 |
mData->mBaseElement->offerEvent( *this, aEvent);
|
|
601 |
}
|
|
602 |
|
|
603 |
//----------------------------Highlight and Selection API's -----------------
|
|
604 |
|
|
605 |
// ---------------------------------------------------------------------------
|
|
606 |
// SetHighlightIndex
|
|
607 |
// ---------------------------------------------------------------------------
|
|
608 |
//
|
|
609 |
void MulCoverFlowControl::SetHighlightIndex( int aIndex, bool aUpdateSlider)
|
|
610 |
{
|
|
611 |
MUL_LOG_ENTRY_EXIT("MUL:MulCoverFlowControl::SetHighlightIndex");
|
|
612 |
// Throw Out of Bound Exception if index is negative
|
|
613 |
__MUL_ASSERT (aIndex > -1 && aIndex < TotalModelCount(), KOutOfBound);
|
|
614 |
//set the highlight in model
|
|
615 |
if(aIndex > mData->mHighlightIndex)
|
|
616 |
{
|
|
617 |
mData->mBaseElement->SetScrollDir(EItemScrollRight);
|
|
618 |
}
|
|
619 |
else
|
|
620 |
{
|
|
621 |
mData->mBaseElement->SetScrollDir(EItemScrollLeft);
|
|
622 |
}
|
|
623 |
DoSetFocusIndex( aIndex );
|
|
624 |
if (aUpdateSlider)
|
|
625 |
{
|
|
626 |
SetSliderTickPosition();
|
|
627 |
}
|
|
628 |
}
|
|
629 |
// ---------------------------------------------------------------------------
|
|
630 |
// DoSetFocusIndex
|
|
631 |
// ---------------------------------------------------------------------------
|
|
632 |
//
|
|
633 |
void MulCoverFlowControl::DoSetFocusIndex( int aNewIndex, int aAnimationTime )
|
|
634 |
{
|
|
635 |
MUL_LOG_ENTRY_EXIT("MUL:MulCoverFlowControl::DoSetFocusIndex");
|
|
636 |
|
|
637 |
if(aNewIndex < 0 )
|
|
638 |
{
|
|
639 |
return;
|
|
640 |
}
|
|
641 |
|
|
642 |
int oldindex = mData->mHighlightIndex;
|
|
643 |
IMulModelAccessor* accessor = static_cast<IMulModelAccessor*>(widget()->model());
|
|
644 |
if(accessor)
|
|
645 |
{
|
|
646 |
if( oldindex == aNewIndex )
|
|
647 |
{
|
|
648 |
accessor->SetHighlight( aNewIndex );
|
|
649 |
|
|
650 |
// When one item case to cancel the drag effect
|
|
651 |
mData->mBaseElement->StopDoodling(200);
|
|
652 |
return;
|
|
653 |
}
|
|
654 |
// handling of cancelling bounce in 2 items case
|
|
655 |
if(TotalModelCount() == 2)
|
|
656 |
{
|
|
657 |
if((mData->mBaseElement->ScrollDir() == EItemScrollRight && aNewIndex == 1 && oldindex == 2)||
|
|
658 |
(mData->mBaseElement->ScrollDir() == EItemScrollLeft && aNewIndex == 2 && oldindex == 1))
|
|
659 |
{
|
|
660 |
mData->mBaseElement->StopDoodling(200);
|
|
661 |
return;
|
|
662 |
}
|
|
663 |
}
|
|
664 |
|
|
665 |
accessor->SetHighlight( aNewIndex );
|
|
666 |
accessor->ScrollWindow( WindowTop(aNewIndex) );
|
|
667 |
|
|
668 |
// Set the new focused item
|
|
669 |
mData->mHighlightIndex = aNewIndex;
|
|
670 |
|
|
671 |
// Throw Out of Bound Exception if index is negative
|
|
672 |
__MUL_ASSERT( mData->mHighlightIndex > -1 , KOutOfBound );
|
|
673 |
mData->mBaseElement->offerEvent(*this,TAlfEvent(ETypeHighlight,aAnimationTime));
|
|
674 |
|
|
675 |
if( mData->mIsWidgetVisible )
|
|
676 |
{
|
|
677 |
// If the widget is in hidden mode no event will be sent to the application/client
|
|
678 |
CAlfWidgetControl::processEvent( TAlfEvent( ETypeHighlight,mData->mHighlightIndex));
|
|
679 |
}
|
|
680 |
}
|
|
681 |
}
|
|
682 |
|
|
683 |
// ----------------------------------------------------------------------------
|
|
684 |
// SetSelection
|
|
685 |
// ----------------------------------------------------------------------------
|
|
686 |
//
|
|
687 |
void MulCoverFlowControl::SetSelection(int aHighlight)
|
|
688 |
{
|
|
689 |
MUL_LOG_ENTRY_EXIT("MUL:MulCoverFlowControl::SetSelection");
|
|
690 |
CAlfWidgetControl::processEvent ( TAlfEvent ( ETypeSelect, aHighlight));
|
|
691 |
}
|
|
692 |
|
|
693 |
// ---------------------------------------------------------------------------
|
|
694 |
// HighlightIndex
|
|
695 |
// ---------------------------------------------------------------------------
|
|
696 |
//
|
|
697 |
int MulCoverFlowControl::HighlightIndex()
|
|
698 |
{
|
|
699 |
MUL_LOG_ENTRY_EXIT("MUL:MulCoverFlowControl::HighlightIndex");
|
|
700 |
return mData->mHighlightIndex;
|
|
701 |
}
|
|
702 |
|
|
703 |
// ---------------------------------------------------------------------------
|
|
704 |
// SetSliderTickPosition
|
|
705 |
// ---------------------------------------------------------------------------
|
|
706 |
//
|
|
707 |
void MulCoverFlowControl::SetSliderTickPosition( )
|
|
708 |
{
|
|
709 |
MUL_LOG_ENTRY_EXIT("MUL:MulCoverFlowControl::SetSliderTickPosition");
|
|
710 |
if (mData->mCoverFlow2DTemplate->IsSliderVisible())
|
|
711 |
{
|
|
712 |
IMulSliderModel* mulSliderModel = GetSliderModel();
|
|
713 |
if( mulSliderModel && mData->mHighlightIndex >= KInitialvalueZero )
|
|
714 |
{
|
|
715 |
mulSliderModel->SetPrimaryValue( mData->mHighlightIndex );
|
|
716 |
}
|
|
717 |
}
|
|
718 |
}
|
|
719 |
|
|
720 |
//----------------------Model Change Related API's----------------------------
|
|
721 |
// ----------------------------------------------------------------------------
|
|
722 |
// ModelStateChanged
|
|
723 |
// ----------------------------------------------------------------------------
|
|
724 |
//
|
|
725 |
void MulCoverFlowControl::ModelStateChanged( TMulChangedState aState, IMulVariantType& aData )
|
|
726 |
{
|
|
727 |
MUL_LOG_ENTRY_EXIT("MUL:MulCoverFlowControl::ModelStateChanged");
|
|
728 |
switch( aState )
|
|
729 |
{
|
|
730 |
case EItemUpdated:
|
|
731 |
{
|
|
732 |
int index = aData.integer();
|
|
733 |
if(TotalModelCount() < 2*mData->mNumVisibleItem+1)
|
|
734 |
{
|
|
735 |
HandleLessItemsUpdate(index);
|
|
736 |
}
|
|
737 |
else
|
|
738 |
{
|
|
739 |
int relativeIndex = 0;
|
|
740 |
if (IsIndexInVisibleWindow(index, relativeIndex))
|
|
741 |
{
|
|
742 |
UpdateCoverflowItem(index,relativeIndex);
|
|
743 |
mData->mBaseElement->CancelRotationOnUpdate(relativeIndex);
|
|
744 |
}
|
|
745 |
}
|
|
746 |
break;
|
|
747 |
}
|
|
748 |
case EHighlightChanged:
|
|
749 |
{
|
|
750 |
if (mData->mHighlightIndex != aData.integer())
|
|
751 |
{
|
|
752 |
mData->mHighlightIndex = aData.integer();
|
|
753 |
IMulModelAccessor* accessor = static_cast<IMulModelAccessor*>(widget()->model());
|
|
754 |
if( mData->mHighlightIndex == 0 )
|
|
755 |
{
|
|
756 |
mData->mBaseElement->ShowEmptyText(false);
|
|
757 |
}
|
|
758 |
if( mData->mHighlightIndex >= 0)
|
|
759 |
{
|
|
760 |
// the same things have to be done for highlight>0 and highlight = 0
|
|
761 |
// the only diff is at highlight 0 dont show empty text
|
|
762 |
accessor->ScrollWindow(WindowTop(mData->mHighlightIndex));
|
|
763 |
mData->mBaseElement->UpdateVisuals();
|
|
764 |
mData->mBaseElement->SetCounterText();
|
|
765 |
SetSliderTickPosition();
|
|
766 |
}
|
|
767 |
else
|
|
768 |
{
|
|
769 |
// remove the visualisation and hide counter.
|
|
770 |
mData->mBaseElement->RecycleIconVisuals();
|
|
771 |
mData->mBaseElement->ShowEmptyText( true );
|
|
772 |
}
|
|
773 |
}
|
|
774 |
break;
|
|
775 |
}
|
|
776 |
case EItemsInserted:
|
|
777 |
{
|
|
778 |
HandleModelCountChange();
|
|
779 |
break;
|
|
780 |
}
|
|
781 |
case EItemsRemoved:
|
|
782 |
{
|
|
783 |
HandleModelCountChange();
|
|
784 |
CAlfWidgetControl::processEvent( TAlfEvent( ETypeItemRemoved ));
|
|
785 |
break;
|
|
786 |
}
|
|
787 |
|
|
788 |
}
|
|
789 |
}
|
|
790 |
|
|
791 |
// ---------------------------------------------------------------------------
|
|
792 |
// HandleLessItemsUpdate
|
|
793 |
// ---------------------------------------------------------------------------
|
|
794 |
//
|
|
795 |
void MulCoverFlowControl::HandleLessItemsUpdate(int aIndex)
|
|
796 |
{
|
|
797 |
MUL_LOG_ENTRY_EXIT("MUL:MulCoverFlowControl::HandleLessItemsUpdate");
|
|
798 |
|
|
799 |
int highlight = mData->mHighlightIndex;
|
|
800 |
IMulModelAccessor* accessor = static_cast<IMulModelAccessor*>(widget()->model());
|
|
801 |
if(accessor)
|
|
802 |
{
|
|
803 |
highlight = accessor->Highlight();
|
|
804 |
}
|
|
805 |
|
|
806 |
if(aIndex == highlight)
|
|
807 |
{
|
|
808 |
UpdateCoverflowItem(aIndex,mData->mNumVisibleItem);
|
|
809 |
if(mData->mNumVisibleItem != 1 && TotalModelCount() == 3)
|
|
810 |
{
|
|
811 |
UpdateCoverflowItem(aIndex,mData->mNumVisibleItem + 3);
|
|
812 |
UpdateCoverflowItem(aIndex,mData->mNumVisibleItem - 3);
|
|
813 |
}
|
|
814 |
}
|
|
815 |
else
|
|
816 |
{
|
|
817 |
// fulscreen tempalte and 2d in portrait
|
|
818 |
if(mData->mNumVisibleItem == 1)
|
|
819 |
{
|
|
820 |
UpdateCoverflowItem(aIndex,mData->mNumVisibleItem+1);
|
|
821 |
UpdateCoverflowItem(aIndex,mData->mNumVisibleItem-1);
|
|
822 |
}
|
|
823 |
else
|
|
824 |
{
|
|
825 |
// 2d template landscape mode
|
|
826 |
if(TotalModelCount() == 2)
|
|
827 |
{
|
|
828 |
UpdateCoverflowItem(aIndex,mData->mNumVisibleItem+(aIndex - highlight));
|
|
829 |
}
|
|
830 |
else
|
|
831 |
{
|
|
832 |
int relativeIndex = (aIndex - highlight) + mData->mNumVisibleItem;
|
|
833 |
if(relativeIndex >= 0 && relativeIndex < 2*mData->mNumVisibleItem+1)
|
|
834 |
{
|
|
835 |
UpdateCoverflowItem(aIndex,relativeIndex);
|
|
836 |
}
|
|
837 |
relativeIndex = relativeIndex + TotalModelCount();
|
|
838 |
if(relativeIndex >= 0 && relativeIndex < 2*mData->mNumVisibleItem+1)
|
|
839 |
{
|
|
840 |
UpdateCoverflowItem(aIndex,relativeIndex);
|
|
841 |
}
|
|
842 |
|
|
843 |
relativeIndex = mData->mNumVisibleItem - (TotalModelCount() - aIndex + highlight);
|
|
844 |
if(relativeIndex >= 0 && relativeIndex < 2*mData->mNumVisibleItem+1)
|
|
845 |
{
|
|
846 |
UpdateCoverflowItem(aIndex,relativeIndex);
|
|
847 |
}
|
|
848 |
relativeIndex = relativeIndex - TotalModelCount();
|
|
849 |
if(relativeIndex >= 0 && relativeIndex < 2*mData->mNumVisibleItem+1)
|
|
850 |
{
|
|
851 |
UpdateCoverflowItem(aIndex,relativeIndex);
|
|
852 |
}
|
|
853 |
}
|
|
854 |
}
|
|
855 |
}
|
|
856 |
}
|
|
857 |
|
|
858 |
// ---------------------------------------------------------------------------
|
|
859 |
// IsIndexInVisibleWindow
|
|
860 |
// ---------------------------------------------------------------------------
|
|
861 |
//
|
|
862 |
bool MulCoverFlowControl::IsIndexInVisibleWindow(const int aIndex, int& aRelativeIndex)
|
|
863 |
{
|
|
864 |
MUL_LOG_ENTRY_EXIT("MUL:MulCoverFlowControl::IsIndexInVisibleWindow");
|
|
865 |
|
|
866 |
int totalVisual = TotalModelCount();
|
|
867 |
int noOfVisuals = mData->mNumVisibleItem;
|
|
868 |
int highlightRelativeIndex = mData->mNumVisibleItem;
|
|
869 |
int highlight = mData->mHighlightIndex;
|
|
870 |
IMulModelAccessor* accessor = static_cast<IMulModelAccessor*>(widget()->model());
|
|
871 |
if(accessor)
|
|
872 |
{
|
|
873 |
highlight = accessor->Highlight();
|
|
874 |
}
|
|
875 |
|
|
876 |
int leftIndex = highlight - noOfVisuals;
|
|
877 |
int rightIndex = highlight + noOfVisuals;
|
|
878 |
|
|
879 |
if (leftIndex >= 0)
|
|
880 |
{
|
|
881 |
if ((aIndex <= highlight) && (aIndex >= leftIndex))
|
|
882 |
{
|
|
883 |
aRelativeIndex = highlightRelativeIndex - (highlight - aIndex);
|
|
884 |
return true;
|
|
885 |
}
|
|
886 |
}
|
|
887 |
else
|
|
888 |
{
|
|
889 |
if (aIndex <= highlight)
|
|
890 |
{
|
|
891 |
aRelativeIndex = highlightRelativeIndex - (highlight - aIndex);
|
|
892 |
return true;
|
|
893 |
}
|
|
894 |
else
|
|
895 |
{
|
|
896 |
leftIndex = totalVisual + leftIndex ;
|
|
897 |
if (aIndex >= leftIndex)
|
|
898 |
{
|
|
899 |
aRelativeIndex = highlightRelativeIndex - noOfVisuals + (aIndex - leftIndex);
|
|
900 |
return true;
|
|
901 |
}
|
|
902 |
}
|
|
903 |
}
|
|
904 |
|
|
905 |
if (rightIndex < totalVisual)
|
|
906 |
{
|
|
907 |
if ((aIndex >= highlight) && (aIndex <= rightIndex))
|
|
908 |
{
|
|
909 |
aRelativeIndex = highlightRelativeIndex + (aIndex - highlight);
|
|
910 |
return true;
|
|
911 |
}
|
|
912 |
}
|
|
913 |
else
|
|
914 |
{
|
|
915 |
if (aIndex >= highlight)
|
|
916 |
{
|
|
917 |
aRelativeIndex = highlightRelativeIndex + (aIndex - highlight);
|
|
918 |
return true;
|
|
919 |
}
|
|
920 |
rightIndex = rightIndex - totalVisual;
|
|
921 |
if (aIndex <= rightIndex)
|
|
922 |
{
|
|
923 |
aRelativeIndex = highlightRelativeIndex + noOfVisuals - (rightIndex - aIndex);
|
|
924 |
return true;
|
|
925 |
}
|
|
926 |
}
|
|
927 |
|
|
928 |
return false;
|
|
929 |
}
|
|
930 |
|
|
931 |
|
|
932 |
// ---------------------------------------------------------------------------
|
|
933 |
// RelativeToAbsolute
|
|
934 |
// ---------------------------------------------------------------------------
|
|
935 |
//
|
|
936 |
int MulCoverFlowControl::RelativeToAbsolute(const int aRelativeIndex)
|
|
937 |
{
|
|
938 |
MUL_LOG_ENTRY_EXIT("MUL:MulCoverFlowControl::RelativeToAbsolute");
|
|
939 |
int highlightRelativeIndex = mData->mNumVisibleItem;
|
|
940 |
int absolute = -1;
|
|
941 |
int totalVisuals = TotalModelCount();
|
|
942 |
|
|
943 |
int highlight = mData->mHighlightIndex;
|
|
944 |
IMulModelAccessor* accessor = static_cast<IMulModelAccessor*>(widget()->model());
|
|
945 |
if(accessor)
|
|
946 |
{
|
|
947 |
highlight = accessor->Highlight();
|
|
948 |
}
|
|
949 |
|
|
950 |
if(totalVisuals <= 0)
|
|
951 |
{
|
|
952 |
// absolute index is always -1, so no need of any calculations
|
|
953 |
}
|
|
954 |
else if(totalVisuals < 2*mData->mNumVisibleItem + 1)
|
|
955 |
{
|
|
956 |
if(aRelativeIndex == highlightRelativeIndex)
|
|
957 |
{
|
|
958 |
absolute = highlight;
|
|
959 |
}
|
|
960 |
else
|
|
961 |
{
|
|
962 |
if(mData->mNumVisibleItem == 1)
|
|
963 |
{
|
|
964 |
if (totalVisuals == 1)
|
|
965 |
{
|
|
966 |
absolute = -1;
|
|
967 |
}
|
|
968 |
else if(totalVisuals == 2)
|
|
969 |
{
|
|
970 |
absolute = highlight + 1;
|
|
971 |
absolute = absolute >= totalVisuals ? 0 : absolute;
|
|
972 |
}
|
|
973 |
}
|
|
974 |
else
|
|
975 |
{
|
|
976 |
if (totalVisuals == 1)
|
|
977 |
{
|
|
978 |
absolute = -1;
|
|
979 |
}
|
|
980 |
else if(totalVisuals == 2)
|
|
981 |
{
|
|
982 |
absolute = highlight + (aRelativeIndex - highlightRelativeIndex);
|
|
983 |
absolute = absolute >= totalVisuals ? -1 : absolute;
|
|
984 |
}
|
|
985 |
else // totalvisuals > 3
|
|
986 |
{
|
|
987 |
if(aRelativeIndex - highlightRelativeIndex > 0)
|
|
988 |
{
|
|
989 |
absolute = highlight + aRelativeIndex - highlightRelativeIndex;
|
|
990 |
}
|
|
991 |
else
|
|
992 |
{
|
|
993 |
absolute = highlight + aRelativeIndex - highlightRelativeIndex
|
|
994 |
+ TotalModelCount();
|
|
995 |
}
|
|
996 |
absolute = absolute >= totalVisuals ? absolute - totalVisuals : absolute;
|
|
997 |
}
|
|
998 |
}
|
|
999 |
}
|
|
1000 |
}
|
|
1001 |
else
|
|
1002 |
{
|
|
1003 |
if(aRelativeIndex == highlightRelativeIndex)
|
|
1004 |
{
|
|
1005 |
absolute = highlight;
|
|
1006 |
}
|
|
1007 |
else if (aRelativeIndex > highlightRelativeIndex)
|
|
1008 |
{
|
|
1009 |
absolute = highlight + (aRelativeIndex - highlightRelativeIndex);
|
|
1010 |
absolute = absolute >= totalVisuals ? (absolute - totalVisuals) : absolute;
|
|
1011 |
}
|
|
1012 |
else
|
|
1013 |
{
|
|
1014 |
absolute = highlight - (highlightRelativeIndex - aRelativeIndex);
|
|
1015 |
absolute = absolute <0 ? (totalVisuals + absolute) : absolute;
|
|
1016 |
absolute = absolute > totalVisuals - 1 ? -1 : absolute;
|
|
1017 |
}
|
|
1018 |
}
|
|
1019 |
return absolute;
|
|
1020 |
}
|
|
1021 |
|
|
1022 |
|
|
1023 |
// ---------------------------------------------------------------------------
|
|
1024 |
// TotalModelCount
|
|
1025 |
// ---------------------------------------------------------------------------
|
|
1026 |
//
|
|
1027 |
int MulCoverFlowControl::TotalModelCount()
|
|
1028 |
{
|
|
1029 |
MUL_LOG_ENTRY_EXIT("MUL:MulCoverFlowControl::TotalModelCount");
|
|
1030 |
|
|
1031 |
IMulModelAccessor* accessor = static_cast<IMulModelAccessor*>(widget()->model());
|
|
1032 |
if(accessor)
|
|
1033 |
{
|
|
1034 |
return accessor->CurrentItemCount();
|
|
1035 |
}
|
|
1036 |
return -1;
|
|
1037 |
}
|
|
1038 |
|
|
1039 |
// ---------------------------------------------------------------------------
|
|
1040 |
// HandleModelCountChange
|
|
1041 |
// ---------------------------------------------------------------------------
|
|
1042 |
//
|
|
1043 |
void MulCoverFlowControl::HandleModelCountChange()
|
|
1044 |
{
|
|
1045 |
MUL_LOG_ENTRY_EXIT("MUL:MulCoverFlowControl::HandleModelCountChange");
|
|
1046 |
IMulModelAccessor* accessor = static_cast<IMulModelAccessor*>(widget()->model());
|
|
1047 |
if(accessor)
|
|
1048 |
{
|
|
1049 |
if(TotalModelCount() < (2*mData->mNumVisibleItem + 1))
|
|
1050 |
{
|
|
1051 |
mData->mBaseElement->UpdateVisuals();
|
|
1052 |
}
|
|
1053 |
mData->mBaseElement->UpdateSliderTick( TotalModelCount() );
|
|
1054 |
mData->mBaseElement->SetCounterText();
|
|
1055 |
}
|
|
1056 |
}
|
|
1057 |
|
|
1058 |
// ---------------------------------------------------------------------------
|
|
1059 |
// modelAccessor
|
|
1060 |
// ---------------------------------------------------------------------------
|
|
1061 |
//
|
|
1062 |
IMulModelAccessor* MulCoverFlowControl::ModelAccessor()
|
|
1063 |
{
|
|
1064 |
MUL_LOG_ENTRY_EXIT("MUL:MulCoverFlowControl::ModelAccessor");
|
|
1065 |
if(widget())
|
|
1066 |
{
|
|
1067 |
return static_cast<IMulModelAccessor*>(widget()->model());
|
|
1068 |
}
|
|
1069 |
return NULL;
|
|
1070 |
}
|
|
1071 |
|
|
1072 |
// ---------------------------------------------------------------------------
|
|
1073 |
// ModelChanged
|
|
1074 |
// ---------------------------------------------------------------------------
|
|
1075 |
//
|
|
1076 |
void MulCoverFlowControl::ModelChanged( IMulModelAccessor* aAccessor )
|
|
1077 |
{
|
|
1078 |
MUL_LOG_ENTRY_EXIT("MUL:MulCoverFlowControl::ModelChanged");
|
|
1079 |
Env().CancelCustomCommands(this);
|
|
1080 |
// update the highlight index as well as the no of item.
|
|
1081 |
mData->mHighlightIndex = aAccessor->Highlight();
|
|
1082 |
|
|
1083 |
CAlfLayout* main = (CAlfLayout*) mData->mBaseElement->findVisual( KMainLayoutIndex );
|
|
1084 |
TSize mainSize = main->Size().Target().AsSize();
|
|
1085 |
int width = mainSize.iWidth;
|
|
1086 |
int height = mainSize.iHeight;
|
|
1087 |
|
|
1088 |
if( width == 0 && height == 0 )
|
|
1089 |
{
|
|
1090 |
return;
|
|
1091 |
}
|
|
1092 |
else
|
|
1093 |
{
|
|
1094 |
// @todo check if we are setting a new model with the same old template,
|
|
1095 |
// then should we call CreateTemplateElement
|
|
1096 |
mData->mScreenWidth = width;
|
|
1097 |
mData->mScreenHeight = height;
|
|
1098 |
CreateTemplateElement(aAccessor->Template());
|
|
1099 |
mData->mBaseElement->CreateAndInitializeVisuals();
|
|
1100 |
aAccessor->SetVisibleWindow( 2 * mData->mCoverFlow2DTemplate->MaxVisibleCount() + 1
|
|
1101 |
,WindowTop(mData->mHighlightIndex));
|
|
1102 |
// For setting or clearing empty text if depending on the new modle count
|
|
1103 |
SendEventToBaseElement( TAlfEvent( EEventWidgetInitialized ) );
|
|
1104 |
}
|
|
1105 |
}
|
|
1106 |
|
|
1107 |
|
|
1108 |
|
|
1109 |
//-----------------Template Element Creation API's --------------------------
|
|
1110 |
|
|
1111 |
// ---------------------------------------------------------------------------
|
|
1112 |
// CreateTemplateElement
|
|
1113 |
// ---------------------------------------------------------------------------
|
|
1114 |
//
|
|
1115 |
void MulCoverFlowControl::CreateTemplateElement( mulwidget::TLogicalTemplate aTemplateName)
|
|
1116 |
{
|
|
1117 |
MUL_LOG_ENTRY_EXIT("MUL:MulCoverFlowControl::CreateTemplateElement");
|
|
1118 |
if (aTemplateName == mulwidget::KTemplate1)
|
|
1119 |
{
|
|
1120 |
mData->mCoverFlow2DTemplate.reset( new(EMM) MulCoverFlowTemplate1(*this, *mData->mBaseElement));
|
|
1121 |
}
|
|
1122 |
else if(aTemplateName == mulwidget::KTemplate4)
|
|
1123 |
{
|
|
1124 |
mData->mCoverFlow2DTemplate.reset( new(EMM) MulCoverFlowTemplate4(*this, *mData->mBaseElement));
|
|
1125 |
}
|
|
1126 |
else
|
|
1127 |
{
|
|
1128 |
// Invalid template
|
|
1129 |
return;
|
|
1130 |
}
|
|
1131 |
mData->mCoverFlow2DTemplate->CreateVisualisation(IsLandscape());
|
|
1132 |
// set holding mode to gesture helper.
|
|
1133 |
SetHoldingEnabled();
|
|
1134 |
}
|
|
1135 |
|
|
1136 |
|
|
1137 |
|
|
1138 |
//--------------Orientation Change Related API's-----------------------------
|
|
1139 |
// ---------------------------------------------------------------------------
|
|
1140 |
// VisualLayoutUpdated
|
|
1141 |
// ---------------------------------------------------------------------------
|
|
1142 |
//
|
|
1143 |
void MulCoverFlowControl::VisualLayoutUpdated (CAlfVisual& aVisual)
|
|
1144 |
{
|
|
1145 |
MUL_LOG_ENTRY_EXIT("MUL:MulCoverFlowControl::VisualLayoutUpdated");
|
|
1146 |
|
|
1147 |
TSize topLayoutSize = aVisual.Size().Target().AsSize(); ;
|
|
1148 |
int height = topLayoutSize.iHeight;
|
|
1149 |
int width = topLayoutSize.iWidth;
|
|
1150 |
|
|
1151 |
// to avoid unnecessary visual layout updated calls .
|
|
1152 |
// in order to check if the orientation has changed really or not this is done .
|
|
1153 |
if( mData->mScreenWidth == width && height == mData->mScreenHeight )
|
|
1154 |
{
|
|
1155 |
return;
|
|
1156 |
}
|
|
1157 |
|
|
1158 |
mData->mScreenWidth = width;
|
|
1159 |
mData->mScreenHeight = height;
|
|
1160 |
|
|
1161 |
|
|
1162 |
IMulModelAccessor* accessor = ModelAccessor();
|
|
1163 |
if(IsLandscape() == mData->mIsLandscape)
|
|
1164 |
{
|
|
1165 |
if(accessor)
|
|
1166 |
{
|
|
1167 |
CreateTemplateElement(accessor->Template());
|
|
1168 |
mData->mBaseElement->CreateAndInitializeVisuals();
|
|
1169 |
accessor->SetVisibleWindow( 2 * mData->mCoverFlow2DTemplate->MaxVisibleCount() + 1
|
|
1170 |
,WindowTop(mData->mHighlightIndex));
|
|
1171 |
// For setting or clearing empty text if depending on the new modle count
|
|
1172 |
SendEventToBaseElement( TAlfEvent( EEventWidgetInitialized ) );
|
|
1173 |
}
|
|
1174 |
else
|
|
1175 |
{
|
|
1176 |
// For null model
|
|
1177 |
// reset the coverflow 2d template to NULL
|
|
1178 |
mData->mCoverFlow2DTemplate.reset(NULL);
|
|
1179 |
}
|
|
1180 |
}
|
|
1181 |
else
|
|
1182 |
{
|
|
1183 |
mData->mIsLandscape = IsLandscape();
|
|
1184 |
|
|
1185 |
if(!accessor)
|
|
1186 |
{
|
|
1187 |
mData->mBaseElement->SetDefaultSize(TSize(mData->mScreenWidth,mData->mScreenHeight));
|
|
1188 |
return;
|
|
1189 |
}
|
|
1190 |
|
|
1191 |
mData->mBaseElement->OrientationChange();
|
|
1192 |
// enable or disable hold events depending on whether ECF enabled
|
|
1193 |
SetHoldingEnabled();
|
|
1194 |
}
|
|
1195 |
|
|
1196 |
}
|
|
1197 |
|
|
1198 |
// ---------------------------------------------------------------------------
|
|
1199 |
// RecycleVisuals
|
|
1200 |
// ---------------------------------------------------------------------------
|
|
1201 |
//
|
|
1202 |
void MulCoverFlowControl::RecycleVisuals()
|
|
1203 |
{
|
|
1204 |
MUL_LOG_ENTRY_EXIT("MUL:MulCoverFlowControl::RecycleVisuals");
|
|
1205 |
// reset the coverflow 2d template to NULL
|
|
1206 |
mData->mCoverFlow2DTemplate.reset(NULL);
|
|
1207 |
|
|
1208 |
if(mData->mBaseElement)
|
|
1209 |
{
|
|
1210 |
mData->mBaseElement->RecycleIconVisuals();
|
|
1211 |
mData->mHighlightIndex = -1;
|
|
1212 |
}
|
|
1213 |
}
|
|
1214 |
|
|
1215 |
//--------------------------- Gesture ----------------------------------------
|
|
1216 |
|
|
1217 |
// ---------------------------------------------------------------------------
|
|
1218 |
// SetHoldingEnabled
|
|
1219 |
// ---------------------------------------------------------------------------
|
|
1220 |
//
|
|
1221 |
void MulCoverFlowControl::SetHoldingEnabled()
|
|
1222 |
{
|
|
1223 |
MUL_LOG_ENTRY_EXIT("MUL:MulCoverFlowControl::SetHoldingEnabled");
|
|
1224 |
|
|
1225 |
mHelper->SetHoldingEnabled(EnhancedModeCondition());
|
|
1226 |
}
|
|
1227 |
|
|
1228 |
// ---------------------------------------------------------------------------
|
|
1229 |
// SetDoubleTapEnabled
|
|
1230 |
// ---------------------------------------------------------------------------
|
|
1231 |
//
|
|
1232 |
void MulCoverFlowControl::SetDoubleTapEnabled( bool aValue)
|
|
1233 |
{
|
|
1234 |
MUL_LOG_ENTRY_EXIT("MUL:MulCoverFlowControl::SetDoubleTapEnabled");
|
|
1235 |
|
|
1236 |
mHelper->SetDoubleTapEnabled( aValue );
|
|
1237 |
}
|
|
1238 |
|
|
1239 |
// ---------------------------------------------------------------------------
|
|
1240 |
// HandleGestureL
|
|
1241 |
// ---------------------------------------------------------------------------
|
|
1242 |
//
|
|
1243 |
void MulCoverFlowControl::HandleGestureL( const MGestureEvent& aEvent )
|
|
1244 |
{
|
|
1245 |
MUL_LOG_ENTRY_EXIT("MUL:MulCoverFlowControl::HandleGestureL");
|
|
1246 |
if(aEvent.IsHolding())
|
|
1247 |
{
|
|
1248 |
HandleHoldGestureEvents(aEvent);
|
|
1249 |
}
|
|
1250 |
else
|
|
1251 |
{
|
|
1252 |
HandleNormalGestureEvents(aEvent);
|
|
1253 |
}
|
|
1254 |
}
|
|
1255 |
|
|
1256 |
// ---------------------------------------------------------------------------
|
|
1257 |
// HandleNormalGestureEvents
|
|
1258 |
// ---------------------------------------------------------------------------
|
|
1259 |
//
|
|
1260 |
void MulCoverFlowControl::HandleNormalGestureEvents( const MGestureEvent& aEvent )
|
|
1261 |
{
|
|
1262 |
MUL_LOG_ENTRY_EXIT("MUL:MulCoverFlowControl::HandleNormalGestureEvents");
|
|
1263 |
|
|
1264 |
switch ( aEvent.Code(MGestureEvent::EAxisHorizontal) )
|
|
1265 |
{
|
|
1266 |
case EGestureStart:
|
|
1267 |
{
|
|
1268 |
SendFeedbackOnTouchDown(aEvent);
|
|
1269 |
}
|
|
1270 |
break;
|
|
1271 |
case EGestureDrag: // fall through
|
|
1272 |
{
|
|
1273 |
MUL_LOG_INFO("MUL::MulCoverFlowControl:HandleNormalGestureEvents EGestureDrag");
|
|
1274 |
if( aEvent.CurrentPos().iX > mData->mScreenWidth )
|
|
1275 |
{
|
|
1276 |
return;
|
|
1277 |
}
|
|
1278 |
|
|
1279 |
if(TotalModelCount() > 0 )
|
|
1280 |
{
|
|
1281 |
// if ui is on send event to applications
|
|
1282 |
if( mData->mCoverFlow2DTemplate->IsUiOnOffFlagEnabled() &&
|
|
1283 |
(mData->mBaseElement->IsUiOnMode()) )
|
|
1284 |
{
|
|
1285 |
CAlfWidgetControl::processEvent( TAlfEvent( ETypeSwitchUiStateOnDrag ));
|
|
1286 |
}
|
|
1287 |
|
|
1288 |
if (mData->mBounceInProgress && TotalModelCount() > 2)
|
|
1289 |
{
|
|
1290 |
mData->mBounceInProgress = false;
|
|
1291 |
Env().CancelCustomCommands(this);
|
|
1292 |
// bounce canceled once .dont bounce again for the next swipe.
|
|
1293 |
mData->mDontBounce = true;
|
|
1294 |
}
|
|
1295 |
|
|
1296 |
int distance = aEvent.Distance().iX ;
|
|
1297 |
mData->mCurrGestureDir = distance;//CovertDistAnceToDirection(distance);
|
|
1298 |
if (mData->mIsMirrored)
|
|
1299 |
{
|
|
1300 |
distance = -distance;
|
|
1301 |
}
|
|
1302 |
mData->mReferencePoint = aEvent.CurrentPos().iX - 10; //pointerDownPos + distanceTravelled/2;
|
|
1303 |
|
|
1304 |
mData->mBaseElement->StartDoodling(distance);
|
|
1305 |
}
|
|
1306 |
break;
|
|
1307 |
}
|
|
1308 |
|
|
1309 |
case EGestureTap:
|
|
1310 |
{
|
|
1311 |
MUL_LOG_INFO("MUL::MulCoverFlowControl:HandleNormalGestureEvents EGestureTap ");
|
|
1312 |
HandleSingleTap(aEvent);
|
|
1313 |
mFeedback->InstantFeedback(ETouchFeedbackList);
|
|
1314 |
break;
|
|
1315 |
}
|
|
1316 |
|
|
1317 |
case EGestureDoubleTap:
|
|
1318 |
{
|
|
1319 |
MUL_LOG_INFO("MUL::MulCoverFlowControl:HandleNormalGestureEvents EGestureDoubleTap ");
|
|
1320 |
if(TotalModelCount() <= 0 )
|
|
1321 |
{
|
|
1322 |
//find out whether event should be sent on double tap or not
|
|
1323 |
// in case of empty model and the feedback too.
|
|
1324 |
break;
|
|
1325 |
}
|
|
1326 |
MulDoubleTapData doubleTapData;
|
|
1327 |
// Finding the visual which has been hit .
|
|
1328 |
CAlfVisual* hitVisual = aEvent.Visual();
|
|
1329 |
if(hitVisual && (hitVisual->Tag() == KCoverflowIndicator) )
|
|
1330 |
{
|
|
1331 |
doubleTapData.mTapVisualIndex = mData->mHighlightIndex ;
|
|
1332 |
}
|
|
1333 |
else
|
|
1334 |
{
|
|
1335 |
int hitVisualIndex = GetHitVisualIndex( hitVisual );
|
|
1336 |
if( hitVisualIndex == -1 )
|
|
1337 |
{
|
|
1338 |
break;
|
|
1339 |
}
|
|
1340 |
doubleTapData.mTapVisualIndex = hitVisualIndex;
|
|
1341 |
}
|
|
1342 |
doubleTapData.mDoubleTapPoint = aEvent.CurrentPos();
|
|
1343 |
|
|
1344 |
mFeedback->InstantFeedback(ETouchFeedbackList);
|
|
1345 |
CAlfWidgetControl::processEvent ( TAlfEvent ( ETypeDoubleTap,
|
|
1346 |
uint(&doubleTapData)));
|
|
1347 |
break;
|
|
1348 |
}
|
|
1349 |
|
|
1350 |
case EGestureUnknown :
|
|
1351 |
{
|
|
1352 |
MUL_LOG_INFO("MUL::MulCoverFlowControl:HandleNormalGestureEvents EGestureUnknown");
|
|
1353 |
if(TotalModelCount() > 0 )
|
|
1354 |
{
|
|
1355 |
// this will revert to the original position if gesture get cancelled
|
|
1356 |
// with some animation time.
|
|
1357 |
// @TODO animation time should be same as set by application.
|
|
1358 |
mData->mBaseElement->StopDoodling(200);
|
|
1359 |
}
|
|
1360 |
break;
|
|
1361 |
}
|
|
1362 |
|
|
1363 |
case EGestureSwipeLeft:
|
|
1364 |
{
|
|
1365 |
MUL_LOG_INFO("MUL::MulCoverFlowControl:HandleNormalGestureEvents EGestureSwipeLeft");
|
|
1366 |
if(TotalModelCount() > 0 )
|
|
1367 |
{
|
|
1368 |
// do the calculations for changing teh higlight left or right depnding on last direction
|
|
1369 |
// and the total direction moved.
|
|
1370 |
int finalSwipeDirection = mData->mBaseElement->FinalSwipeDirection(
|
|
1371 |
TotalSwipeDistance(aEvent),EEventScrollRight);
|
|
1372 |
|
|
1373 |
HandleSwipe(finalSwipeDirection);
|
|
1374 |
}
|
|
1375 |
break;
|
|
1376 |
}
|
|
1377 |
|
|
1378 |
case EGestureSwipeRight:
|
|
1379 |
{
|
|
1380 |
MUL_LOG_INFO("MUL::MulCoverFlowControl:HandleNormalGestureEvents EGestureSwipeRight");
|
|
1381 |
if(TotalModelCount() > 0 )
|
|
1382 |
{
|
|
1383 |
int finalSwipeDirection = mData->mBaseElement->FinalSwipeDirection(
|
|
1384 |
TotalSwipeDistance(aEvent),EEventScrollLeft);
|
|
1385 |
|
|
1386 |
HandleSwipe(finalSwipeDirection);
|
|
1387 |
}
|
|
1388 |
break;
|
|
1389 |
}
|
|
1390 |
case EGestureMultiTouchStart:
|
|
1391 |
{
|
|
1392 |
MUL_LOG_INFO("MUL::MulCoverFlowControl:HandleNormalGestureEvents EGestureMultiTouchStart");
|
|
1393 |
mData->mBaseElement->StopDoodling(0);
|
|
1394 |
mFeedback->InstantFeedback(ETouchFeedbackMultiTouchRecognized);
|
|
1395 |
break;
|
|
1396 |
}
|
|
1397 |
case EGestureMultiTouchReleased:
|
|
1398 |
MUL_LOG_INFO("MUL::MulCoverFlowControl:HandleNormalGestureEvents EGestureMultiTouchReleased");
|
|
1399 |
break;
|
|
1400 |
case EGesturePinch:
|
|
1401 |
MUL_LOG_INFO("MUL::MulCoverFlowControl:HandleNormalGestureEvents EGesturePinch");
|
|
1402 |
CAlfWidgetControl::processEvent ( TAlfEvent ( ETypePinch,aEvent.PinchPercent()));
|
|
1403 |
break;
|
|
1404 |
case EGestureReleased:
|
|
1405 |
{
|
|
1406 |
MUL_LOG_INFO("MUL::MulCoverFlowControl:HandleNormalGestureEvents EGestureReleased");
|
|
1407 |
break;
|
|
1408 |
}
|
|
1409 |
default:
|
|
1410 |
break;
|
|
1411 |
} // end of switch
|
|
1412 |
}
|
|
1413 |
|
|
1414 |
// ---------------------------------------------------------------------------
|
|
1415 |
// TotalSwipeDistance
|
|
1416 |
// ---------------------------------------------------------------------------
|
|
1417 |
//
|
|
1418 |
int MulCoverFlowControl::TotalSwipeDistance( const GestureHelper::MGestureEvent& aEvent )
|
|
1419 |
{
|
|
1420 |
MUL_LOG_ENTRY_EXIT("MUL:MulCoverFlowControl::TotalSwipeDistance");
|
|
1421 |
if( aEvent.CurrentPos().iX > mData->mScreenWidth )
|
|
1422 |
{
|
|
1423 |
return aEvent.Distance().iX - (aEvent.CurrentPos().iX - mData->mScreenWidth);
|
|
1424 |
}
|
|
1425 |
return aEvent.Distance().iX;
|
|
1426 |
}
|
|
1427 |
|
|
1428 |
// ---------------------------------------------------------------------------
|
|
1429 |
// GetHitVisualIndex
|
|
1430 |
// ---------------------------------------------------------------------------
|
|
1431 |
//
|
|
1432 |
int MulCoverFlowControl::GetHitVisualIndex( CAlfVisual* aHitVisual )
|
|
1433 |
{
|
|
1434 |
MUL_LOG_ENTRY_EXIT("MUL:MulCoverFlowControl::GetHitVisualIndex");
|
|
1435 |
int visualIndex = -1;
|
|
1436 |
|
|
1437 |
if(!aHitVisual)
|
|
1438 |
{
|
|
1439 |
// no visual found
|
|
1440 |
return -1;
|
|
1441 |
}
|
|
1442 |
#ifdef _DEBUG
|
|
1443 |
const TDesC8& buffer = aHitVisual->Tag();
|
|
1444 |
#endif
|
|
1445 |
|
|
1446 |
if ((aHitVisual->Tag() != KCoverflowIcon))
|
|
1447 |
{
|
|
1448 |
visualIndex = -1;
|
|
1449 |
}
|
|
1450 |
else
|
|
1451 |
{
|
|
1452 |
if(mData->mNumVisibleItem > 1)
|
|
1453 |
{
|
|
1454 |
CAlfLayout& iconFlow =mData->mBaseElement->FlowLayout( KIconFlowLayoutIndex );
|
|
1455 |
CAlfVisual* imgVisual = NULL;
|
|
1456 |
for(int i=2; i<=4;i++)
|
|
1457 |
{
|
|
1458 |
imgVisual = iconFlow.Visual(i).FindTag(KCoverflowIcon);
|
|
1459 |
if (imgVisual == aHitVisual)
|
|
1460 |
{
|
|
1461 |
visualIndex = RelativeToAbsolute(i);
|
|
1462 |
break;
|
|
1463 |
}
|
|
1464 |
}
|
|
1465 |
}
|
|
1466 |
else
|
|
1467 |
{
|
|
1468 |
visualIndex = mData->mHighlightIndex;
|
|
1469 |
}
|
|
1470 |
}
|
|
1471 |
return visualIndex;
|
|
1472 |
}
|
|
1473 |
|
|
1474 |
|
|
1475 |
// ---------------------------------------------------------------------------
|
|
1476 |
// HandleSingleTap
|
|
1477 |
// ---------------------------------------------------------------------------
|
|
1478 |
//
|
|
1479 |
void MulCoverFlowControl::HandleSingleTap(const MGestureEvent& aEvent)
|
|
1480 |
{
|
|
1481 |
MUL_LOG_ENTRY_EXIT("MUL:MulCoverFlowControl::HandleSingleTap");
|
|
1482 |
|
|
1483 |
if(TotalModelCount() <= 0 )
|
|
1484 |
{
|
|
1485 |
// in case of empty model and null model only when the empty text is set
|
|
1486 |
// then only the selection event should be sent to the applications.
|
|
1487 |
if( mData->mBaseElement->IsEmptyText() )
|
|
1488 |
{
|
|
1489 |
SetSelection(-1);
|
|
1490 |
}
|
|
1491 |
// In case of null model and empty model if the empty text is not set then no need to calculate
|
|
1492 |
//the hit visual index . Doest serve any purpose.
|
|
1493 |
}
|
|
1494 |
else
|
|
1495 |
{
|
|
1496 |
// Finding the visual which has been hit .
|
|
1497 |
CAlfVisual* hitVisual = aEvent.Visual();
|
|
1498 |
if(hitVisual && (hitVisual->Tag() == KCoverflowIndicator) )
|
|
1499 |
{
|
|
1500 |
CAlfWidgetControl::processEvent( TAlfEvent( EVideoIconSelect ));
|
|
1501 |
return;
|
|
1502 |
}
|
|
1503 |
int hitVisualIndex = GetHitVisualIndex( hitVisual );
|
|
1504 |
if( hitVisualIndex > -1 )
|
|
1505 |
{
|
|
1506 |
if( hitVisualIndex == mData->mHighlightIndex )
|
|
1507 |
{
|
|
1508 |
SetSelection(mData->mHighlightIndex );
|
|
1509 |
}
|
|
1510 |
else
|
|
1511 |
{
|
|
1512 |
//set the highlight in model
|
|
1513 |
if(TotalModelCount() > 2 && hitVisualIndex == TotalModelCount()-1
|
|
1514 |
&& mData->mHighlightIndex == 0)
|
|
1515 |
{
|
|
1516 |
HandleNavigationEvent ( EEventScrollLeft );
|
|
1517 |
}
|
|
1518 |
else if(TotalModelCount() > 2 && mData->mHighlightIndex == TotalModelCount()-1
|
|
1519 |
&& hitVisualIndex == 0)
|
|
1520 |
{
|
|
1521 |
HandleNavigationEvent ( EEventScrollRight );
|
|
1522 |
}
|
|
1523 |
else if(hitVisualIndex > mData->mHighlightIndex)
|
|
1524 |
{
|
|
1525 |
HandleNavigationEvent ( EEventScrollRight );
|
|
1526 |
}
|
|
1527 |
else
|
|
1528 |
{
|
|
1529 |
HandleNavigationEvent ( EEventScrollLeft );
|
|
1530 |
}
|
|
1531 |
}
|
|
1532 |
}
|
|
1533 |
}
|
|
1534 |
}
|
|
1535 |
|
|
1536 |
// ---------------------------------------------------------------------------
|
|
1537 |
// SendFeedbackOnTouchDown
|
|
1538 |
// ---------------------------------------------------------------------------
|
|
1539 |
//
|
|
1540 |
void MulCoverFlowControl::SendFeedbackOnTouchDown(const MGestureEvent& aEvent)
|
|
1541 |
{
|
|
1542 |
MUL_LOG_ENTRY_EXIT("MUL:MulCoverFlowControl::SendFeedbackOnTouchDown");
|
|
1543 |
|
|
1544 |
IMulModelAccessor* modelaccessor = ModelAccessor();
|
|
1545 |
if(!modelaccessor || modelaccessor->CurrentItemCount() == 0)
|
|
1546 |
{
|
|
1547 |
return;
|
|
1548 |
}
|
|
1549 |
CAlfVisual* hitVisual = aEvent.Visual();
|
|
1550 |
if((hitVisual && hitVisual->Tag() == KCoverflowIcon) || (mData->mCoverFlow2DTemplate->IsUiOnOffFlagEnabled() ))
|
|
1551 |
{
|
|
1552 |
mFeedback->InstantFeedback(ETouchFeedbackList);
|
|
1553 |
}
|
|
1554 |
}
|
|
1555 |
// ---------------------------------------------------------------------------
|
|
1556 |
// HandleSwipe
|
|
1557 |
// Handle the swipe events (swipe left and swipe right) provided by the gesture helper.
|
|
1558 |
// Also handles the extreme doodling case (it may happen that in doodling you can move two
|
|
1559 |
// or three highlight before doing a pointer up) but gesture only gives us a swipe left and
|
|
1560 |
// swipe right event. so we have to decide the no of highlight movement to do while getting
|
|
1561 |
// left or right event.
|
|
1562 |
// Also for 2 or 3 highlight movement if the 1st or 2nd highlight movement is the cycling case
|
|
1563 |
// then we have to cancel the bounce as its already happend because of swipe. But the bounce
|
|
1564 |
// will happen if the final highlight change is a cyclic case.
|
|
1565 |
// ---------------------------------------------------------------------------
|
|
1566 |
//
|
|
1567 |
void MulCoverFlowControl::HandleSwipe(int aEvent)
|
|
1568 |
{
|
|
1569 |
MUL_LOG_ENTRY_EXIT("MUL:MulCoverFlowControl::HandleSwipe");
|
|
1570 |
int event;
|
|
1571 |
if(aEvent == EItemScrollLeft)
|
|
1572 |
{
|
|
1573 |
if (mData->mIsMirrored)
|
|
1574 |
{
|
|
1575 |
event = EEventScrollRight;
|
|
1576 |
}
|
|
1577 |
else
|
|
1578 |
{
|
|
1579 |
event = EEventScrollLeft;
|
|
1580 |
}
|
|
1581 |
}
|
|
1582 |
else if(aEvent == EItemScrollRight)
|
|
1583 |
{
|
|
1584 |
if (mData->mIsMirrored)
|
|
1585 |
{
|
|
1586 |
event = EEventScrollLeft;
|
|
1587 |
}
|
|
1588 |
else
|
|
1589 |
{
|
|
1590 |
event = EEventScrollRight;
|
|
1591 |
}
|
|
1592 |
}
|
|
1593 |
else
|
|
1594 |
{
|
|
1595 |
mData->mBaseElement->StopDoodling(200);
|
|
1596 |
return;
|
|
1597 |
}
|
|
1598 |
|
|
1599 |
if(mData->mBaseElement->NumberOfSwipes() == EDoubleSwipe || mData->mBaseElement->NumberOfSwipes() == ETripleSwipe)
|
|
1600 |
{
|
|
1601 |
// done to avoid undesirable ui behaviour when we move the pointer little back.
|
|
1602 |
// check if it can be done in another way.
|
|
1603 |
CAlfEnv& env = Env();
|
|
1604 |
TAlfRefreshMode oldRefreshMode = env.RefreshMode();
|
|
1605 |
env.SetRefreshMode(EAlfRefreshModeManual);
|
|
1606 |
if(mData->mBaseElement->NumberOfSwipes() == ETripleSwipe)
|
|
1607 |
{
|
|
1608 |
HandleNavigationEvent( event );
|
|
1609 |
}
|
|
1610 |
HandleNavigationEvent( event );
|
|
1611 |
env.SetRefreshMode(oldRefreshMode);
|
|
1612 |
}
|
|
1613 |
|
|
1614 |
HandleNavigationEvent( event );
|
|
1615 |
// Feedback for swipe event
|
|
1616 |
mFeedback->InstantFeedback(ETouchFeedbackList);
|
|
1617 |
}
|
|
1618 |
|
|
1619 |
// ---------------------------------------------------------------------------
|
|
1620 |
// HandleHoldGestureEvents
|
|
1621 |
// ---------------------------------------------------------------------------
|
|
1622 |
//
|
|
1623 |
void MulCoverFlowControl::HandleHoldGestureEvents( const MGestureEvent& aEvent )
|
|
1624 |
{
|
|
1625 |
MUL_LOG_ENTRY_EXIT("MUL:MulCoverFlowControl::HandleHoldGestureEvents");
|
|
1626 |
|
|
1627 |
switch ( aEvent.Code(MGestureEvent::EAxisHorizontal) )
|
|
1628 |
{
|
|
1629 |
case EGestureDrag:
|
|
1630 |
{
|
|
1631 |
MUL_LOG_INFO("MUL::MulCoverFlowControl:HandleHoldGestureEvents EGestureDrag");
|
|
1632 |
|
|
1633 |
ReverseDirectionInFastScroll(aEvent);
|
|
1634 |
|
|
1635 |
/// @todo The strip direction intially should start with the current gesture direction.
|
|
1636 |
// But if u keep dragging without releasing the pointer tehn the directioon should chnage whenever
|
|
1637 |
// the pointer crosses the centre of the screen.
|
|
1638 |
|
|
1639 |
// if the pointer has crossed the centre position after holding started then the
|
|
1640 |
// direction should depend on which half of teh screen
|
|
1641 |
// else
|
|
1642 |
// the direction should depend on the swipe direction
|
|
1643 |
StartMoving(aEvent);
|
|
1644 |
break;
|
|
1645 |
}
|
|
1646 |
|
|
1647 |
case EGestureReleased:
|
|
1648 |
case EGestureTap:
|
|
1649 |
{
|
|
1650 |
MUL_LOG_INFO("MUL::MulCoverFlowControl:HandleHoldGestureEvents EGestureReleased");
|
|
1651 |
HandleEnhancedStop();
|
|
1652 |
break;
|
|
1653 |
}
|
|
1654 |
|
|
1655 |
case EGestureHoldLeft:
|
|
1656 |
case EGestureHoldRight:
|
|
1657 |
{
|
|
1658 |
MUL_LOG_INFO("MUL::MulCoverFlowControl:HandleHoldGestureEvents EGestureHoldLeft");
|
|
1659 |
if( EnhancedModeCondition() )
|
|
1660 |
{
|
|
1661 |
EnhancedStarted( aEvent );
|
|
1662 |
}
|
|
1663 |
break;
|
|
1664 |
}
|
|
1665 |
|
|
1666 |
default:
|
|
1667 |
break;
|
|
1668 |
} // end of switch
|
|
1669 |
|
|
1670 |
}
|
|
1671 |
|
|
1672 |
// ---------------------------------------------------------------------------
|
|
1673 |
// ReverseDirectionInFastSrroll
|
|
1674 |
// ---------------------------------------------------------------------------
|
|
1675 |
//
|
|
1676 |
void MulCoverFlowControl::ReverseDirectionInFastScroll(const MGestureEvent& aEvent)
|
|
1677 |
{
|
|
1678 |
MUL_LOG_ENTRY_EXIT("MUL:MulCoverFlowControl::ReverseDirectionInFastScroll");
|
|
1679 |
|
|
1680 |
int distTravelled = aEvent.Distance().iX;
|
|
1681 |
int pointerDownPos = aEvent.StartPos().iX;
|
|
1682 |
int currPosition = aEvent.CurrentPos().iX;
|
|
1683 |
int prevGestureDir = ConvertDistanceToDirection(mData->mCurrGestureDir);
|
|
1684 |
|
|
1685 |
// if the distance travelled is negative i.e from right to left and the start position is on
|
|
1686 |
// the right half of the screen and the direction has not changed yet , then special case to handle reference point. and vice versa
|
|
1687 |
// case for left half of the screen.
|
|
1688 |
if( ((distTravelled < 0 && pointerDownPos > mData->mScreenWidth/2 ) || (distTravelled > 0 &&
|
|
1689 |
pointerDownPos < mData->mScreenWidth/2 )) && mData->mReferencePoint != mData->mScreenWidth/2)
|
|
1690 |
{
|
|
1691 |
if( mData->mDirectionChanged )
|
|
1692 |
{
|
|
1693 |
return;
|
|
1694 |
}
|
|
1695 |
|
|
1696 |
ChangeDirReferencePoint(currPosition,distTravelled);
|
|
1697 |
}
|
|
1698 |
else
|
|
1699 |
{
|
|
1700 |
// else the reference point will be the middle of the screen.
|
|
1701 |
|
|
1702 |
// if the direction is not equal .. just check whether it has crossed the reference point.
|
|
1703 |
// how to check whether it has crossed the reference point.
|
|
1704 |
if(( prevGestureDir < 0 && currPosition > mData->mReferencePoint )||(prevGestureDir > 0 && currPosition < mData->mReferencePoint))
|
|
1705 |
{
|
|
1706 |
mData->mCurrGestureDir *= -1;
|
|
1707 |
}
|
|
1708 |
|
|
1709 |
mData->mReferencePoint = mData->mScreenWidth/2;
|
|
1710 |
}
|
|
1711 |
}
|
|
1712 |
|
|
1713 |
// ---------------------------------------------------------------------------
|
|
1714 |
// ChangeDirReferencePoint
|
|
1715 |
// ---------------------------------------------------------------------------
|
|
1716 |
//
|
|
1717 |
void MulCoverFlowControl::ChangeDirReferencePoint(int aCurrPosition, int aDistanceTravelled )
|
|
1718 |
{
|
|
1719 |
MUL_LOG_ENTRY_EXIT("MUL:MulCoverFlowControl::ChangeDirReferencePoint");
|
|
1720 |
|
|
1721 |
int prevGestureDir = ConvertDistanceToDirection(mData->mCurrGestureDir);
|
|
1722 |
int currGestureDir = ConvertDistanceToDirection(aDistanceTravelled);
|
|
1723 |
|
|
1724 |
if( prevGestureDir != currGestureDir )
|
|
1725 |
{
|
|
1726 |
// if the direction is not equal .. just check whether it has crossed the reference point.
|
|
1727 |
// how to check whether it has crossed the reference point.
|
|
1728 |
if(( prevGestureDir < 0 && aCurrPosition > mData->mReferencePoint )||(prevGestureDir > 0 && aCurrPosition < mData->mReferencePoint))
|
|
1729 |
{
|
|
1730 |
//crossed the reference point first time .now no need to maintain the reference point .its always half of the screen
|
|
1731 |
mData->mReferencePoint = mData->mScreenWidth/2;
|
|
1732 |
mData->mDirectionChanged = true;
|
|
1733 |
mData->mCurrGestureDir = aDistanceTravelled;
|
|
1734 |
}
|
|
1735 |
else
|
|
1736 |
{
|
|
1737 |
// not crossed the reference point yet
|
|
1738 |
// still going in the same direction .
|
|
1739 |
mData->mReferencePoint = aCurrPosition - 10;
|
|
1740 |
}
|
|
1741 |
}
|
|
1742 |
else
|
|
1743 |
{
|
|
1744 |
// still going in the same direction .
|
|
1745 |
if(( prevGestureDir < 0 && aCurrPosition < mData->mScreenWidth/2 )||(prevGestureDir > 0
|
|
1746 |
&& aCurrPosition > mData->mScreenWidth/2))
|
|
1747 |
{
|
|
1748 |
mData->mReferencePoint = mData->mScreenWidth/2;
|
|
1749 |
}
|
|
1750 |
else if(Abs(mData->mCurrGestureDir) < Abs(aDistanceTravelled) )
|
|
1751 |
{
|
|
1752 |
// moving in the same direction in the increasing side towards the middle of the screen but hasnt
|
|
1753 |
// crossed the reference point yet.
|
|
1754 |
mData->mReferencePoint = aCurrPosition - 10;
|
|
1755 |
}
|
|
1756 |
}
|
|
1757 |
}
|
|
1758 |
|
|
1759 |
// ---------------------------------------------------------------------------
|
|
1760 |
// ConvertDistanceToDirection
|
|
1761 |
// ---------------------------------------------------------------------------
|
|
1762 |
//
|
|
1763 |
int MulCoverFlowControl::ConvertDistanceToDirection( int aDistance )
|
|
1764 |
{
|
|
1765 |
MUL_LOG_ENTRY_EXIT("MUL:MulCoverFlowControl::ConvertDistanceToDirection");
|
|
1766 |
return aDistance>0?1:-1;
|
|
1767 |
}
|
|
1768 |
|
|
1769 |
// ---------------------------------------------------------------------------
|
|
1770 |
// HandleEnhancedStop
|
|
1771 |
// ---------------------------------------------------------------------------
|
|
1772 |
//
|
|
1773 |
void MulCoverFlowControl::HandleEnhancedStop()
|
|
1774 |
{
|
|
1775 |
MUL_LOG_ENTRY_EXIT("MUL:MulCoverFlowControl::HandleEnhancedStop");
|
|
1776 |
|
|
1777 |
CAlfWidgetControl::processEvent( TAlfEvent( ETypeFastScroll,EScrollStop ));
|
|
1778 |
mCoverFlowAo->StopMoving();
|
|
1779 |
mData->mFastScroll = false;
|
|
1780 |
mData->mGestureSpeed = 0;
|
|
1781 |
// @TODO animation time should be same as set by the application.
|
|
1782 |
mData->mBaseElement->MoveVisuals(0,200);
|
|
1783 |
}
|
|
1784 |
|
|
1785 |
// ---------------------------------------------------------------------------
|
|
1786 |
// FastScrollTransitionTime
|
|
1787 |
// ---------------------------------------------------------------------------
|
|
1788 |
//
|
|
1789 |
int MulCoverFlowControl::FastScrollTransitionTime()
|
|
1790 |
{
|
|
1791 |
MUL_LOG_ENTRY_EXIT("MUL:MulCoverFlowControl::FastScrollTransitionTime");
|
|
1792 |
if (mData->mBounceInProgress)
|
|
1793 |
{
|
|
1794 |
return 800;
|
|
1795 |
}
|
|
1796 |
else
|
|
1797 |
{
|
|
1798 |
return mCoverFlowAo->FastScrollTransitionTime();
|
|
1799 |
}
|
|
1800 |
}
|
|
1801 |
|
|
1802 |
|
|
1803 |
// ---------------------------------------------------------------------------
|
|
1804 |
// EnhancedModeCondition
|
|
1805 |
// ---------------------------------------------------------------------------
|
|
1806 |
//
|
|
1807 |
bool MulCoverFlowControl::EnhancedModeCondition()
|
|
1808 |
{
|
|
1809 |
MUL_LOG_ENTRY_EXIT("MUL:MulCoverFlowControl::EnhancedMode");
|
|
1810 |
if( !mData->mCoverFlow2DTemplate.get() )
|
|
1811 |
{
|
|
1812 |
return false;
|
|
1813 |
}
|
|
1814 |
UString orientation = IsLandscape() ? UString(KLandscape) : UString(KPortrait);
|
|
1815 |
|
|
1816 |
// If EMulWidgetFlagFastScroll is not set,
|
|
1817 |
// or the current orientation is not landscape
|
|
1818 |
// or in teh current template enhanced mode is not supported
|
|
1819 |
if( !(((MulCoverFlowWidget*)widget())->IsFlagSet(IMulMultiItemWidget::EMulWidgetFlagFastScroll)
|
|
1820 |
&& !orientation.compare(KLandscape)
|
|
1821 |
&& mData->mCoverFlow2DTemplate->EnhancedTagParsed()) )
|
|
1822 |
{
|
|
1823 |
return false;
|
|
1824 |
}
|
|
1825 |
// If template4(i.e. ui on off mode is anabled) then if ui on mode then ecf canot be launched,so return false
|
|
1826 |
else if( mData->mCoverFlow2DTemplate->IsUiOnOffFlagEnabled() &&
|
|
1827 |
(mData->mBaseElement->IsUiOnMode()) )
|
|
1828 |
{
|
|
1829 |
return false;
|
|
1830 |
}
|
|
1831 |
else
|
|
1832 |
{
|
|
1833 |
return true; // enhanced mode enabled
|
|
1834 |
}
|
|
1835 |
}
|
|
1836 |
|
|
1837 |
// ---------------------------------------------------------------------------
|
|
1838 |
// EnhancedStarted
|
|
1839 |
// ---------------------------------------------------------------------------
|
|
1840 |
//
|
|
1841 |
void MulCoverFlowControl::EnhancedStarted(const GestureHelper::MGestureEvent& aEvent )
|
|
1842 |
{
|
|
1843 |
MUL_LOG_ENTRY_EXIT("MUL:MulCoverFlowControl::EnhancedStarted");
|
|
1844 |
CAlfWidgetControl::processEvent( TAlfEvent( ETypeFastScroll,EScrollStart ));
|
|
1845 |
mData->mFastScroll = true;
|
|
1846 |
StartMoving(aEvent);
|
|
1847 |
}
|
|
1848 |
|
|
1849 |
// ---------------------------------------------------------------------------
|
|
1850 |
// StartMoving
|
|
1851 |
// ---------------------------------------------------------------------------
|
|
1852 |
//
|
|
1853 |
void MulCoverFlowControl::StartMoving( const GestureHelper::MGestureEvent& aEvent )
|
|
1854 |
{
|
|
1855 |
MUL_LOG_ENTRY_EXIT("MUL:MulCoverFlowControl::StartMoving");
|
|
1856 |
|
|
1857 |
TRealPoint speedPoint = GestureSpeed( aEvent );
|
|
1858 |
int distance = mData->mCurrGestureDir;
|
|
1859 |
if (mData->mIsMirrored)
|
|
1860 |
{
|
|
1861 |
distance = -distance;
|
|
1862 |
}
|
|
1863 |
mCoverFlowAo->StartMoving(speedPoint.iX, ConvertDistanceToDirection(distance) );
|
|
1864 |
mData->mGestureSpeed = speedPoint.iX;
|
|
1865 |
}
|
|
1866 |
|
|
1867 |
// ---------------------------------------------------------------------------
|
|
1868 |
// GestureSpeed
|
|
1869 |
// ---------------------------------------------------------------------------
|
|
1870 |
//
|
|
1871 |
TRealPoint MulCoverFlowControl::GestureSpeed( const MGestureEvent& aEvent )
|
|
1872 |
{
|
|
1873 |
MUL_LOG_ENTRY_EXIT("MUL:MulCoverFlowControl::GestureSpeed");
|
|
1874 |
|
|
1875 |
TRect area(this->DisplayArea());
|
|
1876 |
TRect rect(TPoint(0,0),TPoint(area.Width(),area.Height()));
|
|
1877 |
return aEvent.SpeedPercent( rect );
|
|
1878 |
}
|
|
1879 |
|
|
1880 |
//--------------------Slider related functions----------------------------
|
|
1881 |
|
|
1882 |
// ---------------------------------------------------------------------------
|
|
1883 |
// CreateSliderWidget
|
|
1884 |
// ---------------------------------------------------------------------------
|
|
1885 |
//
|
|
1886 |
IAlfWidget* MulCoverFlowControl::CreateSliderWidget()
|
|
1887 |
{
|
|
1888 |
MUL_LOG_ENTRY_EXIT("MUL:MulCoverFlowControl::CreateSliderWidget");
|
|
1889 |
|
|
1890 |
IAlfWidgetFactory& widgetFactory = AlfWidgetEnvExtension::widgetFactory(Env());
|
|
1891 |
IAlfWidget* sliderWidget = widgetFactory.findWidget( KNameSliderWidget );
|
|
1892 |
|
|
1893 |
if( sliderWidget )
|
|
1894 |
{
|
|
1895 |
mSliderWidget = static_cast<IMulSliderWidget*>(sliderWidget);
|
|
1896 |
mData->mBaseElement->UpdateSliderTick( 1 );
|
|
1897 |
}
|
|
1898 |
else
|
|
1899 |
{
|
|
1900 |
// Get the template Id in Integer from your template data
|
|
1901 |
//NOTE: Set template takes int as parameter not UString
|
|
1902 |
|
|
1903 |
// Slider Widget creation
|
|
1904 |
mSliderWidget = widgetFactory.createWidget<IMulSliderWidget> ( KNameSliderWidget, KNameSliderWidget, *widget()->parent(), NULL);
|
|
1905 |
IMulSliderModel* mSliderModel = widgetFactory.createModel<IMulSliderModel> ("mulslidermodel");
|
|
1906 |
mSliderWidget->setModel(mSliderModel, true);
|
|
1907 |
mSliderModel->SetTemplate(ESliderTemplate1);
|
|
1908 |
mSliderWidget->SetHandleKeyEvent(false);
|
|
1909 |
mSliderWidget->control()->disableState(IAlfWidgetControl::Focusable);
|
|
1910 |
}
|
|
1911 |
|
|
1912 |
IAlfWidgetEventHandler* coverFlowEventHandler = static_cast<IAlfWidgetEventHandler*> (
|
|
1913 |
mData->mBaseElement->makeInterface( IAlfWidgetEventHandler::type() ) );
|
|
1914 |
|
|
1915 |
//Register the slidereventhandler and coverfloweventhandler with one another
|
|
1916 |
mSliderWidget->control()->addEventHandler((coverFlowEventHandler));
|
|
1917 |
|
|
1918 |
return mSliderWidget;
|
|
1919 |
}
|
|
1920 |
|
|
1921 |
// ---------------------------------------------------------------------------
|
|
1922 |
// GetSliderWidget
|
|
1923 |
// ---------------------------------------------------------------------------
|
|
1924 |
//
|
|
1925 |
IAlfWidget* MulCoverFlowControl::GetSliderWidget()
|
|
1926 |
{
|
|
1927 |
MUL_LOG_ENTRY_EXIT("MUL:MulCoverFlowControl::GetSliderWidget");
|
|
1928 |
|
|
1929 |
IAlfWidgetFactory& widgetFactory = AlfWidgetEnvExtension::widgetFactory(*(CAlfEnv::Static()));
|
|
1930 |
return widgetFactory.findWidget( KNameSliderWidget );
|
|
1931 |
}
|
|
1932 |
|
|
1933 |
// ---------------------------------------------------------------------------
|
|
1934 |
// GetSliderModel
|
|
1935 |
// ---------------------------------------------------------------------------
|
|
1936 |
//
|
|
1937 |
IMulSliderModel* MulCoverFlowControl::GetSliderModel()
|
|
1938 |
{
|
|
1939 |
MUL_LOG_ENTRY_EXIT("MUL:MulCoverFlowControl::GetSliderModel");
|
|
1940 |
if( mSliderWidget )
|
|
1941 |
{
|
|
1942 |
IMulSliderWidget* mulSliderWidget = static_cast<IMulSliderWidget*>(mSliderWidget);
|
|
1943 |
IMulSliderModel* mulSliderModel = static_cast<IMulSliderModel*>(mulSliderWidget->model());
|
|
1944 |
return mulSliderModel;
|
|
1945 |
}
|
|
1946 |
return NULL;
|
|
1947 |
}
|
|
1948 |
|
|
1949 |
// ---------------------------------------------------------------------------
|
|
1950 |
// DestroySlider
|
|
1951 |
// ---------------------------------------------------------------------------
|
|
1952 |
//
|
|
1953 |
void MulCoverFlowControl::DestroySlider()
|
|
1954 |
{
|
|
1955 |
MUL_LOG_ENTRY_EXIT("MUL:MulCoverFlowControl::DestroySlider");
|
|
1956 |
|
|
1957 |
MulBaseElement* baseelement = static_cast<MulBaseElement*>(findElement(KBase));
|
|
1958 |
if(baseelement)
|
|
1959 |
{
|
|
1960 |
baseelement->RemoveSliderFromLayout();
|
|
1961 |
}
|
|
1962 |
|
|
1963 |
IAlfWidgetFactory& widgetFactory = AlfWidgetEnvExtension::widgetFactory(Env());
|
|
1964 |
IAlfWidget* sliderWidget = widgetFactory.findWidget( KNameSliderWidget );
|
|
1965 |
if( sliderWidget )
|
|
1966 |
{
|
|
1967 |
IAlfElement* baseelement = findElement(KBase);
|
|
1968 |
if(baseelement)
|
|
1969 |
{
|
|
1970 |
|
|
1971 |
IAlfWidgetEventHandler* coverFlowEventHandler = static_cast<IAlfWidgetEventHandler*> (
|
|
1972 |
baseelement->makeInterface( IAlfWidgetEventHandler::type() ) );
|
|
1973 |
|
|
1974 |
if( sliderWidget->control() )
|
|
1975 |
{
|
|
1976 |
sliderWidget->control()->removeEventHandler(*(coverFlowEventHandler));
|
|
1977 |
}
|
|
1978 |
|
|
1979 |
}
|
|
1980 |
}
|
|
1981 |
}
|
|
1982 |
|
|
1983 |
// ---------------------------------------------------------------------------
|
|
1984 |
// UpdateItemAtIndex
|
|
1985 |
// ---------------------------------------------------------------------------
|
|
1986 |
//
|
|
1987 |
void MulCoverFlowControl::UpdateItemAtIndex(const int aRelativeIndex, int aAnimationTime)
|
|
1988 |
{
|
|
1989 |
MUL_LOG_ENTRY_EXIT("MUL:MulCoverFlowControl::UpdateItemAtIndex");
|
|
1990 |
int absoluteIndex = RelativeToAbsolute(aRelativeIndex);
|
|
1991 |
if(absoluteIndex >= 0)
|
|
1992 |
{
|
|
1993 |
UpdateCoverflowItem( absoluteIndex,aRelativeIndex, aAnimationTime );
|
|
1994 |
}
|
|
1995 |
else
|
|
1996 |
{
|
|
1997 |
SetBlankTexture(aRelativeIndex);
|
|
1998 |
}
|
|
1999 |
}
|
|
2000 |
|
|
2001 |
// ---------------------------------------------------------------------------
|
|
2002 |
// SetBlankTexture
|
|
2003 |
// ---------------------------------------------------------------------------
|
|
2004 |
//
|
|
2005 |
void MulCoverFlowControl::SetBlankTexture(int aRelativeIndex)
|
|
2006 |
{
|
|
2007 |
MUL_LOG_ENTRY_EXIT("MUL:MulCoverFlowControl::SetBlankTexture");
|
|
2008 |
CAlfFlowLayout& iconFlow = static_cast<CAlfFlowLayout&>(mData->mBaseElement->FlowLayout( KIconFlowLayoutIndex ));
|
|
2009 |
|
|
2010 |
CAlfDeckLayout& layout = static_cast<CAlfDeckLayout&>(iconFlow.Visual(aRelativeIndex));
|
|
2011 |
CAlfImageVisual* visual =static_cast<CAlfImageVisual*>(layout.FindTag(KCoverflowIcon));
|
|
2012 |
|
|
2013 |
CAlfTextureManager& textureMgr = Env().TextureManager();
|
|
2014 |
TAlfImage blankTexture = textureMgr.BlankTexture();
|
|
2015 |
visual->SetImage(blankTexture);
|
|
2016 |
|
|
2017 |
// remove the icon brush if any.
|
|
2018 |
mData->mBaseElement->RemoveBrushOnIcon(*visual);
|
|
2019 |
|
|
2020 |
CAlfImageVisual* indicatorVisual =static_cast<CAlfImageVisual*>(layout.FindTag(KCoverflowIndicator));
|
|
2021 |
if(indicatorVisual)
|
|
2022 |
{
|
|
2023 |
indicatorVisual->SetImage(blankTexture);
|
|
2024 |
}
|
|
2025 |
}
|
|
2026 |
|
|
2027 |
// ---------------------------------------------------------------------------
|
|
2028 |
// UpdateCoverflowItem
|
|
2029 |
// ---------------------------------------------------------------------------
|
|
2030 |
//
|
|
2031 |
void MulCoverFlowControl::UpdateCoverflowItem( int aItemIndex,int aVisualIndex, int aAnimationTime )
|
|
2032 |
{
|
|
2033 |
MUL_LOG_ENTRY_EXIT("MUL:MulCoverFlowControl::UpdateCoverflowItem");
|
|
2034 |
|
|
2035 |
CAlfFlowLayout& iconFlow = static_cast<CAlfFlowLayout&>(mData->mBaseElement->FlowLayout( KIconFlowLayoutIndex ));
|
|
2036 |
IMulModelAccessor* accessor = static_cast<IMulModelAccessor*>(widget()->model());
|
|
2037 |
|
|
2038 |
try
|
|
2039 |
{
|
|
2040 |
const MulVisualItem& item = accessor->Item(aItemIndex);
|
|
2041 |
|
|
2042 |
CAlfDeckLayout& layout = static_cast<CAlfDeckLayout&>(iconFlow.Visual(aVisualIndex));
|
|
2043 |
CAlfImageVisual* visual =static_cast<CAlfImageVisual*>(layout.FindTag(KCoverflowIcon));
|
|
2044 |
IMulVariantType* varData = item.Attribute(mulvisualitem::KMulIcon1);
|
|
2045 |
if(varData && visual)
|
|
2046 |
{
|
|
2047 |
DoSetImage(varData,visual);
|
|
2048 |
mData->mBaseElement->ApplyScaleMode(*visual);
|
|
2049 |
}
|
|
2050 |
else
|
|
2051 |
{
|
|
2052 |
if (mData->mDefaultTextureId >= 0)
|
|
2053 |
{
|
|
2054 |
const CAlfTexture* texture = Env().TextureManager().Texture (mData->mDefaultTextureId);
|
|
2055 |
if(visual)
|
|
2056 |
{
|
|
2057 |
visual->SetImage (TAlfImage (*texture));
|
|
2058 |
}
|
|
2059 |
mData->mBaseElement->ApplyScaleMode(*visual);
|
|
2060 |
}
|
|
2061 |
else
|
|
2062 |
{
|
|
2063 |
if(visual)
|
|
2064 |
{
|
|
2065 |
visual->SetImage(Env().TextureManager().BlankTexture());
|
|
2066 |
}
|
|
2067 |
}
|
|
2068 |
}
|
|
2069 |
if(mData->mCoverFlow2DTemplate->IsUiOnOffFlagEnabled() )
|
|
2070 |
{
|
|
2071 |
mData->mBaseElement->DisplayIndicatorIcon(item,aVisualIndex);
|
|
2072 |
}
|
|
2073 |
}
|
|
2074 |
catch(...)
|
|
2075 |
{
|
|
2076 |
CAlfDeckLayout& layout = static_cast<CAlfDeckLayout&>(iconFlow.Visual(aVisualIndex));
|
|
2077 |
CAlfImageVisual* visual =static_cast<CAlfImageVisual*>(layout.FindTag(KCoverflowIcon));
|
|
2078 |
if (mData->mDefaultTextureId >= 0)
|
|
2079 |
{
|
|
2080 |
const CAlfTexture* texture = Env().TextureManager().Texture (mData->mDefaultTextureId);
|
|
2081 |
visual->SetImage (TAlfImage (*texture));
|
|
2082 |
mData->mBaseElement->ApplyScaleMode(*visual);
|
|
2083 |
}
|
|
2084 |
else
|
|
2085 |
{
|
|
2086 |
visual->SetImage(Env().TextureManager().BlankTexture());
|
|
2087 |
}
|
|
2088 |
|
|
2089 |
}//catch ends
|
|
2090 |
// if the item is the highlight item then update the text if required.
|
|
2091 |
if (aVisualIndex == mData->mNumVisibleItem)
|
|
2092 |
{
|
|
2093 |
mData->mBaseElement->UpdateTextValue(aAnimationTime);
|
|
2094 |
}
|
|
2095 |
}
|
|
2096 |
|
|
2097 |
|
|
2098 |
// ---------------------------------------------------------------------------
|
|
2099 |
// DoSetImage
|
|
2100 |
// ---------------------------------------------------------------------------
|
|
2101 |
//
|
|
2102 |
void MulCoverFlowControl::DoSetImage(IMulVariantType* aData,CAlfImageVisual* aImgVisual)
|
|
2103 |
{
|
|
2104 |
MUL_LOG_ENTRY_EXIT("MUL:MulCoverFlowControl::DoSetImage");
|
|
2105 |
|
|
2106 |
if ( aData && aData->Type() == IMulVariantType::EDes)
|
|
2107 |
{
|
|
2108 |
TAlfImage image = AlfWidgetEnvExtension::resourcePool(
|
|
2109 |
aImgVisual->Env()).getImageResource((char*)(aData->DesC().Ptr()));
|
|
2110 |
if(image.HasTexture())
|
|
2111 |
{
|
|
2112 |
aImgVisual->SetImage(image);
|
|
2113 |
}
|
|
2114 |
else if(IsSVGImage(aData->DesC()))
|
|
2115 |
{
|
|
2116 |
LoadImageFromSvg(aData->DesC(),*aImgVisual);
|
|
2117 |
}
|
|
2118 |
else
|
|
2119 |
{
|
|
2120 |
// check if the texture is already loaded
|
|
2121 |
CAlfTextureManager& textureMgr = aImgVisual->Env().TextureManager();
|
|
2122 |
const TInt existingTextureId = textureMgr.TextureId( aData->DesC() );
|
|
2123 |
const CAlfTexture* texture = NULL;
|
|
2124 |
|
|
2125 |
if ( existingTextureId != KErrNotFound )
|
|
2126 |
{
|
|
2127 |
texture = textureMgr.Texture( existingTextureId );
|
|
2128 |
}
|
|
2129 |
else
|
|
2130 |
{
|
|
2131 |
TRAPD( err, texture = &( textureMgr.LoadTextureL(aData->DesC(),
|
|
2132 |
EAlfTextureFlagLoadAnimAsImage, KAlfAutoGeneratedTextureId ) ) );
|
|
2133 |
if( err != KErrNone )
|
|
2134 |
{
|
|
2135 |
// means the texture is invalid.
|
|
2136 |
//draw a blank texture here.
|
|
2137 |
texture = &( textureMgr.BlankTexture() );
|
|
2138 |
}
|
|
2139 |
}
|
|
2140 |
aImgVisual->SetImage( TAlfImage( *texture ) );
|
|
2141 |
}
|
|
2142 |
}
|
|
2143 |
else if ( aData && aData->Type ()== IMulVariantType::EInt)
|
|
2144 |
{
|
|
2145 |
const CAlfTexture* texture = Env().TextureManager().Texture (aData->integer());
|
|
2146 |
aImgVisual->SetImage (TAlfImage (*texture));
|
|
2147 |
}
|
|
2148 |
}
|
|
2149 |
|
|
2150 |
// ---------------------------------------------------------------------------
|
|
2151 |
// IsSVGImage
|
|
2152 |
// ---------------------------------------------------------------------------
|
|
2153 |
//
|
|
2154 |
bool MulCoverFlowControl::IsSVGImage(const TDesC& aImagePath)
|
|
2155 |
{
|
|
2156 |
MUL_LOG_INFO("MUL:MulCoverFlowControl::IsSVGImage");
|
|
2157 |
_LIT(KSvgFile,".svg");
|
|
2158 |
|
|
2159 |
return (KErrNotFound != aImagePath.FindC(KSvgFile));
|
|
2160 |
}
|
|
2161 |
|
|
2162 |
// ---------------------------------------------------------------------------
|
|
2163 |
// LoadImageFromSvg
|
|
2164 |
// ---------------------------------------------------------------------------
|
|
2165 |
//
|
|
2166 |
void MulCoverFlowControl::LoadImageFromSvg(const TDesC& aImagePath,
|
|
2167 |
CAlfImageVisual& aImageVisual )
|
|
2168 |
{
|
|
2169 |
MUL_LOG_INFO("MUL:MulCoverFlowControl::LoadImageFromSvg");
|
|
2170 |
|
|
2171 |
CAlfImageLoaderUtil imgLoaderUtil;
|
|
2172 |
imgLoaderUtil.SetSize (TSize (50, 50));
|
|
2173 |
|
|
2174 |
MAlfBitmapProvider* iSvgBitMapProv= imgLoaderUtil.CreateSVGImageLoaderL (aImagePath);
|
|
2175 |
CAlfTexture &texture = aImageVisual.Env().TextureManager().CreateTextureL (
|
|
2176 |
KAlfAutoGeneratedTextureId,
|
|
2177 |
iSvgBitMapProv,
|
|
2178 |
EAlfTextureFlagLoadAnimAsImage);
|
|
2179 |
aImageVisual.SetImage (TAlfImage (texture));
|
|
2180 |
|
|
2181 |
}
|
|
2182 |
|
|
2183 |
// ---------------------------------------------------------------------------
|
|
2184 |
// StoreVisibleItemCount
|
|
2185 |
// ---------------------------------------------------------------------------
|
|
2186 |
//
|
|
2187 |
void MulCoverFlowControl::StoreVisibleItemCount(int aVisibleItemCount)
|
|
2188 |
{
|
|
2189 |
MUL_LOG_ENTRY_EXIT("MUL:MulCoverFlowControl::StoreVisibleItemCount");
|
|
2190 |
mData->mNumVisibleItem = aVisibleItemCount;
|
|
2191 |
}
|
|
2192 |
|
|
2193 |
// ---------------------------------------------------------------------------
|
|
2194 |
// SetDefaultImage
|
|
2195 |
// ---------------------------------------------------------------------------
|
|
2196 |
//
|
|
2197 |
void MulCoverFlowControl::SetDefaultImage(int aTextureId)
|
|
2198 |
{
|
|
2199 |
MUL_LOG_ENTRY_EXIT("MUL:MulCoverFlowControl::SetDefaultImage");
|
|
2200 |
mData->mDefaultTextureId = aTextureId;
|
|
2201 |
}
|
|
2202 |
|
|
2203 |
// ---------------------------------------------------------------------------
|
|
2204 |
// WindowTop
|
|
2205 |
// ---------------------------------------------------------------------------
|
|
2206 |
//
|
|
2207 |
int MulCoverFlowControl::WindowTop(int aHighlightIndex)
|
|
2208 |
{
|
|
2209 |
MUL_LOG_ENTRY_EXIT("MUL:MulCoverFlowControl::WindowTop");
|
|
2210 |
int visibleItems = 2 * mData->mNumVisibleItem + 1;
|
|
2211 |
int windowTop = aHighlightIndex - (visibleItems / 2);
|
|
2212 |
IMulModelAccessor* accessor = static_cast<IMulModelAccessor*>(widget()->model());
|
|
2213 |
if(accessor)
|
|
2214 |
{
|
|
2215 |
windowTop = (windowTop + visibleItems - 1) >= TotalModelCount() ?
|
|
2216 |
TotalModelCount() - visibleItems : windowTop;
|
|
2217 |
windowTop = windowTop > 0 ? windowTop : 0;
|
|
2218 |
}
|
|
2219 |
|
|
2220 |
return windowTop;
|
|
2221 |
}
|
|
2222 |
|
|
2223 |
// ---------------------------------------------------------------------------
|
|
2224 |
// UpdateBaseElement
|
|
2225 |
// ---------------------------------------------------------------------------
|
|
2226 |
//
|
|
2227 |
void MulCoverFlowControl::UpdateBaseElement(MulBaseElement* aBaseElement)
|
|
2228 |
{
|
|
2229 |
MUL_LOG_ENTRY_EXIT("MUL:MulCoverFlowControl::UpdateBaseElement");
|
|
2230 |
mData->mBaseElement = aBaseElement;
|
|
2231 |
}
|
|
2232 |
|
|
2233 |
// ---------------------------------------------------------------------------
|
|
2234 |
// IsLandscape
|
|
2235 |
// ---------------------------------------------------------------------------
|
|
2236 |
//
|
|
2237 |
bool MulCoverFlowControl::IsLandscape()
|
|
2238 |
{
|
|
2239 |
bool ret;
|
|
2240 |
TSize ScreenSz = AlfUtil::ScreenSize();
|
|
2241 |
if (ScreenSz.iWidth > ScreenSz.iHeight)
|
|
2242 |
{
|
|
2243 |
ret = true;
|
|
2244 |
}
|
|
2245 |
else
|
|
2246 |
{
|
|
2247 |
ret = false;
|
|
2248 |
}
|
|
2249 |
return ret;
|
|
2250 |
}
|
|
2251 |
|
|
2252 |
// ---------------------------------------------------------------------------
|
|
2253 |
// Gesturehelper
|
|
2254 |
// ---------------------------------------------------------------------------
|
|
2255 |
//
|
|
2256 |
GestureHelper::CGestureHelper* MulCoverFlowControl::Gesturehelper()
|
|
2257 |
{
|
|
2258 |
return mHelper.get();
|
|
2259 |
}
|
|
2260 |
|
|
2261 |
} // namespace Alf
|
|
2262 |
|
|
2263 |
//End of file
|