|
1 /* |
|
2 * Copyright (c) 2008-2009 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: Carousel control class |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 #ifndef C_GLXCLOUDVIEWCONTROL_H |
|
22 #define C_GLXCLOUDVIEWCONTROL_H |
|
23 |
|
24 // INCLUDES |
|
25 |
|
26 #include <alf/ialfwidgeteventhandler.h> |
|
27 #include <osn/ustring.h> |
|
28 #include <alf/alfscrollevents.h> |
|
29 #include <alf/ialfscrollbarwidget.h> |
|
30 |
|
31 //use includes |
|
32 #include <mglxmedialistobserver.h> |
|
33 #include "glxcontainerinfobubble.h" |
|
34 #include "glxcloudinfo.h" |
|
35 #include <alf/alfeventhandler.h> |
|
36 |
|
37 #include <AknLayout2Def.h> |
|
38 using namespace Alf; |
|
39 |
|
40 |
|
41 // FORWARD DECLARATION |
|
42 class MMPXViewUtility; |
|
43 class MGlxUiCommandHandler; |
|
44 class CAlfAnchorLayout; |
|
45 class CAlfViewportLayout; |
|
46 class CAlfControl; |
|
47 class MGlxMediaList; |
|
48 class CGlxDefaultAttributeContext; |
|
49 class MMPXCollectionUtility; |
|
50 class CGlxContainerInfoBubble; |
|
51 class MTouchFeedback; |
|
52 class MGlxCloudViewMskObserver; |
|
53 class MGlxEnterKeyEventObserver; |
|
54 class MGlxCloudViewLayoutObserver; |
|
55 |
|
56 enum TTagEventType |
|
57 { |
|
58 ECustomEventFocusDragScroll |
|
59 }; |
|
60 /** |
|
61 * CGlxCloudViewControl |
|
62 * Alf-based Cloud control |
|
63 * Creates a weighted list of items based on the associations. |
|
64 * |
|
65 */ |
|
66 |
|
67 class CGlxCloudViewControl : public CAlfControl,public IAlfWidgetEventHandler |
|
68 ,public MGlxMediaListObserver |
|
69 { |
|
70 public: |
|
71 |
|
72 /** |
|
73 * Perform the two phase construction |
|
74 * @param aEnv - Env Variable of Alf |
|
75 * @param aEmptyText - Specifies the text for the empty list |
|
76 * @param aMediaList - medialist from which attributes will be fetched |
|
77 * @return Pointer to newly created object |
|
78 */ |
|
79 static CGlxCloudViewControl *NewL(CAlfDisplay& aDisplay, CAlfEnv &aEnv, |
|
80 MGlxMediaList& aMediaList, const TDesC& aEmptyText |
|
81 ,MGlxCloudViewMskObserver& aObserver |
|
82 ,MGlxEnterKeyEventObserver& aObserverEnterKeyEvent, |
|
83 CAlfAnchorLayout *aAnchorLayout,MGlxCloudViewLayoutObserver& aLayoutObserver); |
|
84 |
|
85 /** |
|
86 * Perform the two phase construction |
|
87 * @param aEnv - Env Variable of Alf |
|
88 * @param aEmptyText - Specifies the text for the empty list |
|
89 * @param aMediaList - medialist from which attributes will be fetched |
|
90 * @return Pointer to newly created object |
|
91 */ |
|
92 static CGlxCloudViewControl *NewLC(CAlfDisplay& aDisplay, CAlfEnv &aEnv, |
|
93 MGlxMediaList& aMediaList, const TDesC& aEmptyText |
|
94 ,MGlxCloudViewMskObserver& aObserver |
|
95 ,MGlxEnterKeyEventObserver& aObserverEnterKeyEvent, |
|
96 CAlfAnchorLayout *aAnchorLayout,MGlxCloudViewLayoutObserver& aLayoutObserver); |
|
97 |
|
98 /** |
|
99 * Destroy the object and release all memory objects |
|
100 */ |
|
101 ~CGlxCloudViewControl(); |
|
102 |
|
103 public: |
|
104 /** |
|
105 * Used to identify event handlers that are capable of handling |
|
106 * a specified key or custom event. Pointer event handlers cannot be |
|
107 * identified directly, since they are dependent on the presentation. |
|
108 * Therefore, pointer event handlers should be associated with |
|
109 * a custom event ID that can be used to simulate the actual pointer event. |
|
110 * |
|
111 * @since S60 ?S60_version |
|
112 * @param aEvent The event. |
|
113 * @return <code>ETrue</code> if the event can be processed. Otherwise <code>EFalse</code>. |
|
114 */ |
|
115 bool accept ( CAlfWidgetControl& aControl, const TAlfEvent& aEvent ) const; |
|
116 |
|
117 /** |
|
118 * @see IAlfWidgetEventHandler |
|
119 */ |
|
120 virtual AlfEventStatus offerEvent ( CAlfWidgetControl& aControl, const TAlfEvent& aEvent ); |
|
121 |
|
122 |
|
123 /** |
|
124 * Sets AlfWidgetEventHandlerInitData to event handler. |
|
125 * |
|
126 * @param aData A data structure which contains for example id of the event |
|
127 * handler. |
|
128 */ |
|
129 virtual void setEventHandlerData( const AlfWidgetEventHandlerInitData& /*aData*/ ) |
|
130 { |
|
131 } |
|
132 |
|
133 /** |
|
134 * Defines the widget states, where the event handler is active. |
|
135 * By default, if this method is not called, the event handler is expected |
|
136 * to be active in all states. |
|
137 * |
|
138 * @param aStates A bitmask defining the widget states, where the event |
|
139 * handler is active. The low 16 bits are reserved for the states |
|
140 * defined by the framework in <TODO: add reference>. The high 16 bits are |
|
141 * available for states defined by the client code. |
|
142 */ |
|
143 void setActiveStates ( unsigned int aStates ); |
|
144 |
|
145 IAlfInterfaceBase* makeInterface ( const IfId& aType ); |
|
146 |
|
147 /** |
|
148 * Returns the type of EventHandler. |
|
149 * @see IAlfWidgetEventHandler::AlfEventHandlerType |
|
150 * |
|
151 * @return The type of event handler. |
|
152 */ |
|
153 AlfEventHandlerType eventHandlerType(); |
|
154 |
|
155 /** |
|
156 * Returns information about the phase in the event handling cycle in |
|
157 * which the event hadler will be executed. |
|
158 * @see IAlfWidgetEventHandler::AlfEventHandlerExecutionPhase |
|
159 * |
|
160 * @return Event handler execution phase. |
|
161 */ |
|
162 AlfEventHandlerExecutionPhase eventExecutionPhase(); |
|
163 |
|
164 /** |
|
165 * Returns AlfWidgetEventHandlerInitData. |
|
166 * |
|
167 * @return A pointer to AlfWidgetEventHandlerInitData structure which contains |
|
168 * for example id of the event handler. |
|
169 */ |
|
170 virtual AlfWidgetEventHandlerInitData* eventHandlerData() |
|
171 { |
|
172 return NULL; |
|
173 } |
|
174 |
|
175 /** |
|
176 * initialises data for scrollbar model |
|
177 * @param scrollbar widget |
|
178 */ |
|
179 void InitializeScrollBar(IAlfScrollBarWidget* aScrollBarWidget); |
|
180 |
|
181 private: |
|
182 /** |
|
183 * Perform the two phase construction |
|
184 * @param aEvent - key Event to handle |
|
185 * @return EKeyWasConsumed if key event is processed, |
|
186 * otherwise EKeyWasNotConsumed |
|
187 */ |
|
188 TBool OfferEventL(const TAlfEvent &aEvent); |
|
189 |
|
190 /** |
|
191 * @function HandleKeyUp |
|
192 * |
|
193 */ |
|
194 void HandleKeyUpL(); |
|
195 |
|
196 |
|
197 /** |
|
198 * @since S60 3.2 |
|
199 * |
|
200 */ |
|
201 void HandleLayoutFocusChange(); |
|
202 |
|
203 /** |
|
204 * @since S60 3.2 |
|
205 * |
|
206 */ |
|
207 void HandleKeyDownL(); |
|
208 /** |
|
209 /** |
|
210 * @since S60 3.2 |
|
211 * |
|
212 */ |
|
213 void UpdateLayout(); |
|
214 |
|
215 /** |
|
216 * Displays the empty cloud view when there are no tags to diplay |
|
217 */ |
|
218 void DisplayEmptyCloudViewL(); |
|
219 |
|
220 |
|
221 /** |
|
222 * constructor |
|
223 * @param aEnv - Env Variable of Alf |
|
224 * @param aMediaList - medialist from which attributes will be fetched |
|
225 * @param aMediaList - medialist from which attributes will be fetched |
|
226 */ |
|
227 CGlxCloudViewControl(CAlfEnv &aEnv, |
|
228 MGlxMediaList& aMediaList,MGlxCloudViewMskObserver& aObserver,MGlxEnterKeyEventObserver& aObserverEnterKeyEvent |
|
229 ,MGlxCloudViewLayoutObserver& aLayoutObserver); |
|
230 |
|
231 /** |
|
232 * Perform the two phase construction |
|
233 * @param aStartPoint - start point for draeing the row |
|
234 * @param aRowHeight - height of the row |
|
235 * @param aRowStartIndex - start index of row |
|
236 * @param aRowEndIndex- Index upto which items will be drawn |
|
237 * @return |
|
238 */ |
|
239 TInt LayoutVisibleRows(TPoint aStartPoint,TInt aRowStartIndex, TInt |
|
240 aRowEndIndex); |
|
241 |
|
242 |
|
243 |
|
244 /** |
|
245 * Perform the two phase construction |
|
246 * @param aStartRowIndex - row index |
|
247 * @return |
|
248 */ |
|
249 void LayoutVisibleArea(/*TInt aStartRowIndex*/); |
|
250 |
|
251 /** |
|
252 * returns the rownumber for a particular index. |
|
253 * @param aItemIndex - row index |
|
254 * @return rownum |
|
255 */ |
|
256 TInt RowNumber(TInt aItemIndex) const; |
|
257 |
|
258 /** |
|
259 * Updates the focus whenever there is a change in focus of the item. |
|
260 */ |
|
261 void FocusUpdate(); |
|
262 |
|
263 /** |
|
264 * Perform the second phase of two phase construction |
|
265 * @param aEmptyText - Specifies the text for the empty list |
|
266 */ |
|
267 void ConstructL(const TDesC& aEmptyText,CAlfDisplay& aDisplay,CAlfAnchorLayout *aAnchorLayout); |
|
268 |
|
269 /** |
|
270 * Updates Row Structure |
|
271 * |
|
272 */ |
|
273 void UpdateRowDataL(); |
|
274 |
|
275 |
|
276 /** |
|
277 * Returns maximum value of usage Count |
|
278 * |
|
279 */ |
|
280 TInt MaxUsageCount(); |
|
281 |
|
282 |
|
283 /** |
|
284 * @param aIndex - Media List Index |
|
285 * Returns usage count for a given index |
|
286 * */ |
|
287 TInt UsageCount(TInt aIndex); |
|
288 |
|
289 |
|
290 |
|
291 /** |
|
292 * @function FetchAttributeFromCacheL |
|
293 * |
|
294 * */ |
|
295 void FetchAttributeFromCacheL(); |
|
296 |
|
297 |
|
298 /** |
|
299 * Utility method to add a TGlxCloudInfo struct into iCloudInfo array |
|
300 * @param aCloudInfo The next item to add into iCloudinfo |
|
301 * @param aRowHeight value of aCloudInfo.iRowHeight |
|
302 * @param aStartIndex value of aCloudInfo.iStartIndex |
|
303 * @param aEndIndex value of aCloudInfo.iEndIndex |
|
304 * */ |
|
305 void AppendToCloudArrayL( TGlxCloudInfo& aCloudInfo, |
|
306 const TInt& aStartIndex, const TInt& aEndIndex ); |
|
307 |
|
308 private: |
|
309 |
|
310 /** |
|
311 * Sets focused item color |
|
312 **/ |
|
313 void SetFocusColor(); |
|
314 |
|
315 |
|
316 /** |
|
317 * Set the middle point of the infobuble |
|
318 **/ |
|
319 void SetBubleMidPoint(TPoint& aMidPoint); |
|
320 |
|
321 /** |
|
322 * Create the infobublecontainer |
|
323 **/ |
|
324 void CreateBubleContainer(); |
|
325 |
|
326 /** |
|
327 * Move the viewport up depending on the condition |
|
328 * |
|
329 **/ |
|
330 void MoveUpIfRequired(); |
|
331 |
|
332 /** |
|
333 * Move the viewport down depending on the condition |
|
334 **/ |
|
335 void MoveDownIfRequired(); |
|
336 |
|
337 /** |
|
338 * calculate the mid point of the bubble |
|
339 **/ |
|
340 void CalculateBubleMidPoint(); |
|
341 |
|
342 public: |
|
343 |
|
344 void HandleItemAddedL(TInt aStartIndex, TInt aEndIndex, |
|
345 MGlxMediaList* aList); |
|
346 |
|
347 /** |
|
348 * Notification that media object is now available for an item |
|
349 * @param Index of the item |
|
350 * @param aList List that this callback relates to |
|
351 */ |
|
352 void HandleMediaL(TInt aListIndex, MGlxMediaList* aList); |
|
353 |
|
354 |
|
355 /** |
|
356 * Notification that media item was removed from the list |
|
357 * @param aStartIndex First item that was removed |
|
358 * @param aEndIndex Last item that was removed |
|
359 * @param aList List that this callback relates to |
|
360 */ |
|
361 void HandleItemRemovedL(TInt aStartIndex, TInt aEndIndex, |
|
362 MGlxMediaList* aList); |
|
363 |
|
364 /** |
|
365 * Notification that media item was changed |
|
366 * @param aItemIndexes Indexes of items that were changed |
|
367 * @param aList List that this callback relates to |
|
368 */ |
|
369 void HandleItemModifiedL(const RArray<TInt>& aItemIndexes, |
|
370 MGlxMediaList* aList); |
|
371 |
|
372 /** |
|
373 * Notification that an attribute is available |
|
374 * @param aItemIndex Index of the for which the thumbnail is available |
|
375 * @param aAttributes Array of attributes that have become available |
|
376 * @param aList List that this callback relates to |
|
377 */ |
|
378 void HandleAttributesAvailableL(TInt aItemIndex, |
|
379 const RArray<TMPXAttribute>& aAttributes, MGlxMediaList* aList); |
|
380 |
|
381 /** |
|
382 * Notification that focus has moved |
|
383 * @param aType the direction of the focus change |
|
384 * @param aNewIndex the new index after the focus change |
|
385 * @param aOldIndex the old index before the focus change |
|
386 * @param aList List that this callback relates to |
|
387 */ |
|
388 void HandleFocusChangedL(NGlxListDefs::TFocusChangeType aType, TInt aNewIndex, |
|
389 TInt aOldIndex, MGlxMediaList* aList); |
|
390 |
|
391 /** |
|
392 * Notification that an item has been selected/deselected |
|
393 * @param aIndex Index of the item that has been selected/deselected |
|
394 * @param aSelected Boolean to indicate selection/deselection |
|
395 * @param aList List that the selection relates to |
|
396 */ |
|
397 void HandleItemSelectedL(TInt aIndex, TBool aSelected, MGlxMediaList* aList); |
|
398 |
|
399 /** |
|
400 * Notification from the collection. E.g. Items added/modified/deleted and progress notifications |
|
401 * @param aMessage Message notification from the collection |
|
402 * @param aList List that the notification relates to |
|
403 */ |
|
404 void HandleMessageL(const CMPXMessage& aMessage, MGlxMediaList* aList); |
|
405 |
|
406 /** |
|
407 * Notification from the collection that the medialist is populated |
|
408 * @param aList List that the notification relates to |
|
409 */ |
|
410 void HandlePopulatedL(MGlxMediaList* /*aList*/); |
|
411 |
|
412 /** |
|
413 * Notification from the collection. E.g. Items added/modified/deleted and progress notifications |
|
414 * @param aIndex Index of the item for which property needs to be set |
|
415 * @param aScale Scale parameter to decide the properties of item |
|
416 */ |
|
417 void SetPropertiesL(TInt aIndex, TInt aScale); |
|
418 |
|
419 /** |
|
420 * Called whenever the resolution is changed |
|
421 */ |
|
422 void VisualLayoutUpdated(CAlfVisual & aVisual); |
|
423 |
|
424 private: |
|
425 |
|
426 /** |
|
427 * Handle the pointer event |
|
428 * @param aEvent event describing the gesture |
|
429 */ |
|
430 TBool HandlePointerEventL( const TAlfEvent &aEvent ); |
|
431 |
|
432 /** |
|
433 * Handles the drag events |
|
434 * @param pointer event generated because of drag |
|
435 * @return returns whether the pointer event is consumed or not |
|
436 */ |
|
437 TBool HandleDragL(const TPointerEvent& aPointerEvent); |
|
438 |
|
439 /** |
|
440 * checks the visual on which the drag event is generated |
|
441 * @param position where the drag event has ocuured |
|
442 * @return the index of the visual that needs to be focused |
|
443 */ |
|
444 TInt GetAbsoluteIndex(const TPoint& aPosition); |
|
445 |
|
446 /** |
|
447 * Checks which visual lies below/above the focused item and sets the focus |
|
448 * @param the row number that needs to be checked for getting the overlaping visual |
|
449 */ |
|
450 void SetRelativeFocusL(TInt aRowNumber); |
|
451 |
|
452 /** |
|
453 * Updates layout when orientation is changed |
|
454 */ |
|
455 void UpdateLayoutL(); |
|
456 |
|
457 private: |
|
458 /** |
|
459 * Send the scroll custom event to scrollbar widget |
|
460 */ |
|
461 void Scroll(); |
|
462 |
|
463 /** |
|
464 * decide the scrollbar new position |
|
465 * @param number of steps which is used to determine the amout to be scrolled |
|
466 */ |
|
467 void UpdateScrollBar(TInt aNumberOfSteps, TBool aDiff = ETrue); |
|
468 |
|
469 /** |
|
470 * Display the scrollbar only if there are items |
|
471 * @param visibility |
|
472 */ |
|
473 void DisplayScrollBar(); |
|
474 |
|
475 private: |
|
476 |
|
477 // The Alf Environment |
|
478 CAlfEnv& iEnv; |
|
479 |
|
480 //Parent layout for viewportayout |
|
481 CAlfAnchorLayout* iViewPortParentLayout; |
|
482 |
|
483 //ViewPortLayout |
|
484 CAlfViewportLayout* iViewPortLayout; |
|
485 |
|
486 //Anchor layout for tags |
|
487 CAlfAnchorLayout *iLayout; |
|
488 |
|
489 //medialist not owned |
|
490 MGlxMediaList& iMediaList; |
|
491 |
|
492 //Array of Cloud visuals. |
|
493 RPointerArray <CAlfTextVisual> iLabels; |
|
494 |
|
495 // Array for information of cloud visuals. |
|
496 RArray <TGlxCloudInfo> iCloudInfo; |
|
497 |
|
498 //Ui Utility |
|
499 CGlxUiUtility* iUiUtility; |
|
500 |
|
501 // Visual for empty string display |
|
502 CAlfTextVisual *iEmptyString; |
|
503 |
|
504 // FocusIndex keeps track of the focussed item |
|
505 TInt iScrollDirection; |
|
506 |
|
507 // FocusIndex keeps track of the focussed row |
|
508 TInt iFocusRowIndex; |
|
509 |
|
510 // EndRowindex keeps track of the end row |
|
511 TInt iEndRowIndex; |
|
512 |
|
513 //keeps track of the end row |
|
514 TInt iLayoutIndex; |
|
515 |
|
516 // initiates bubble container |
|
517 CGlxContainerInfoBubble *iBubbleContainer; |
|
518 |
|
519 |
|
520 // Fetch context for list item attributes |
|
521 CGlxDefaultAttributeContext* iAttributeContext; |
|
522 |
|
523 // for storing screen height |
|
524 TInt iScreenHeight; |
|
525 |
|
526 // List event observer |
|
527 MGlxCloudViewMskObserver& iObserver; |
|
528 |
|
529 // stores the text for empty view |
|
530 HBufC* iEmptyText; |
|
531 |
|
532 //Viewport position |
|
533 TAlfRealPoint iViewPortPosition; |
|
534 |
|
535 //observer to inform "open" command cloudviewimp class so that it opens the next view |
|
536 MGlxEnterKeyEventObserver& iObserverEnterKeyEvent; |
|
537 |
|
538 //observer to inform command cloudviewimp class that layout is changed |
|
539 MGlxCloudViewLayoutObserver& iLayoutObserver; |
|
540 //Viewport size |
|
541 TAlfRealSize iViewPortSize; |
|
542 |
|
543 //Viewport virtual size |
|
544 TAlfRealSize iViewPortVirtualSize; |
|
545 |
|
546 //Width of the screen in which is available for tags to fit in |
|
547 TInt iTagScreenWidth; |
|
548 |
|
549 //Height of the screen in which is available for tags to fit in |
|
550 TInt iTagScreenHeight; |
|
551 |
|
552 //Touch feedback instance |
|
553 MTouchFeedback* iTouchFeedback; |
|
554 |
|
555 //parent layout for all the layout's |
|
556 CAlfLayout* iParentLayout; |
|
557 |
|
558 //data structure for scrollbar |
|
559 ScrollModelChangedEventData iScrollEventData; |
|
560 |
|
561 //scrollbar element |
|
562 IAlfWidgetEventHandler *iScrollbarElement; |
|
563 |
|
564 //scrollbar widget |
|
565 IAlfScrollBarWidget *iScrollBarWidget; |
|
566 |
|
567 //direction of dragging |
|
568 TInt iIsDragging; |
|
569 |
|
570 TAknWindowLineLayout iScrollPaneHandle; |
|
571 |
|
572 }; |
|
573 |
|
574 #endif // C_GLXCLOUDVIEWCONTROL_H |
|
575 |