|
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: Visual list control |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 /** |
|
22 * @internal reviewed 04/07/2007 by M Byrne |
|
23 */ |
|
24 |
|
25 #ifndef C_GLXVISUALLISTCONTROL_H |
|
26 #define C_GLXVISUALLISTCONTROL_H |
|
27 |
|
28 #include <alf/alfcontrol.h> |
|
29 #include <alf/alftimedvalue.h> |
|
30 #include <alf/alfmappingfunctions.h> |
|
31 #include <alf/alfbitmapprovider.h> |
|
32 #include <alf/alfdisplay.h> |
|
33 #include <alf/alfimagevisual.h> |
|
34 #include <alf/alfenv.h> |
|
35 #include "mglxmedialistobserver.h" |
|
36 #include "mglxmedialist.h" |
|
37 #include "glxlistwindow.h" |
|
38 #include "glxblendlayout.h" |
|
39 #include "mglxvisualobjectlayoutrefreshobserver.h" |
|
40 #include "mglxvisuallist.h" |
|
41 |
|
42 class CGlxVisualListWindow; |
|
43 //class MGlxLayout; |
|
44 class MGlxVisualListObserver; |
|
45 class CAlfBorderBrush; |
|
46 class CGlxUiUtility; |
|
47 class CGlxDefaultAttributeContext; |
|
48 class CGlxVisualIconManager; |
|
49 class MGlxLayoutObserver; |
|
50 class CAlfAnchorLayout; |
|
51 /** |
|
52 * CGlxVisualListControl |
|
53 * |
|
54 * Item visual owner control |
|
55 * |
|
56 * @author Aki Vanhatalo |
|
57 */ |
|
58 class CGlxVisualListControl : public CAlfControl, public MGlxVisualList, |
|
59 public MGlxMediaListObserver//, public MGlxVisualObjectLayoutRefreshObserver |
|
60 { |
|
61 friend class CGlxVisualListWindow; |
|
62 public: |
|
63 /** |
|
64 * Two-phased constructor. |
|
65 * @param aMediaList Media list of items the visuals represent |
|
66 * @param aEnv Alf environment for the control |
|
67 * @param aDisplay Alf display on which the control should be shown |
|
68 * @param aThumbnailScaleMode Scale mode to use for the visuals |
|
69 */ |
|
70 static CGlxVisualListControl* NewLC( MGlxMediaList& aMediaList, |
|
71 CAlfEnv& aEnv, CAlfDisplay& aDisplay, |
|
72 CAlfImageVisual::TScaleMode aThumbnailScaleMode ); |
|
73 |
|
74 /** |
|
75 * Destructor |
|
76 */ |
|
77 ~CGlxVisualListControl(); |
|
78 |
|
79 /** |
|
80 * Add reference |
|
81 * @return new new reference count |
|
82 */ |
|
83 TInt AddReference(); |
|
84 |
|
85 /** |
|
86 * Remove reference |
|
87 * @return new new reference count |
|
88 */ |
|
89 TInt RemoveReference(); |
|
90 |
|
91 /** |
|
92 * @return Media list of items the visuals represent |
|
93 */ |
|
94 const MGlxMediaList& MediaList() const; |
|
95 |
|
96 // From MGlxVisualList |
|
97 TGlxVisualListId Id() const; |
|
98 CAlfVisual* Visual(TInt aIndex); |
|
99 CGlxVisualObject* Item(TInt aListIndex); |
|
100 virtual TInt ItemCount(NGlxListDefs::TCountType aType = NGlxListDefs::ECountAll) const; |
|
101 TInt FocusIndex() const; |
|
102 CAlfControlGroup* ControlGroup() const; |
|
103 void AddObserverL(MGlxVisualListObserver* aObserver); |
|
104 void RemoveObserver(MGlxVisualListObserver* aObserver); |
|
105 TGlxViewContextId AddContextL(TInt aFrontVisibleRangeOffset, |
|
106 TInt aRearVisibleRangeOffset); |
|
107 void RemoveContext(const TGlxViewContextId& aContextId); |
|
108 void AddLayoutL(MGlxLayout* aLayout); |
|
109 void RemoveLayout(const MGlxLayout* aLayout); |
|
110 void NavigateL(TInt aIndexCount); |
|
111 TSize Size() const; |
|
112 void BringVisualsToFront(); |
|
113 void EnableAnimationL(TBool aAnimate, TInt aIndex); |
|
114 /// @ref MGlxVisualList::SetDefaultIconBehaviourL |
|
115 void SetDefaultIconBehaviourL( TBool aEnable ); |
|
116 |
|
117 void AddIconL( TInt aListIndex, const CAlfTexture& aTexture, |
|
118 NGlxIconMgrDefs::TGlxIconPosition aIconPos, |
|
119 TBool aForeground, TBool aStretch, TInt aBorderMargin, |
|
120 TReal32 aWidth = 1.0, TReal32 aHeight = 1.0 ); |
|
121 |
|
122 TBool RemoveIcon( TInt aListIndex, const CAlfTexture& aTexture ); |
|
123 void SetIconVisibility( TInt aListIndex, const CAlfTexture& aTexture, TBool aVisible ); |
|
124 |
|
125 |
|
126 |
|
127 |
|
128 // From MGlxMediaListObserver |
|
129 void HandleItemAddedL(TInt aStartIndex, TInt aEndIndex, MGlxMediaList* aList); |
|
130 void HandleMediaL(TInt aIndex, MGlxMediaList* aList); |
|
131 void HandleItemRemovedL(TInt aStartIndex, TInt aEndIndex, MGlxMediaList* aList); |
|
132 void HandleItemModifiedL(const RArray<TInt>& aItemIndexes, MGlxMediaList* aList); |
|
133 void HandleAttributesAvailableL(TInt aItemIndex, |
|
134 const RArray<TMPXAttribute>& aAttributes, MGlxMediaList* aList); |
|
135 void HandleFocusChangedL(NGlxListDefs::TFocusChangeType aType, TInt aNewIndex, TInt aOldIndex, MGlxMediaList* aList); |
|
136 void HandleItemSelectedL(TInt aIndex, TBool aSelected, MGlxMediaList* aList); |
|
137 void HandleMessageL(const CMPXMessage& aMessage, MGlxMediaList* aList); |
|
138 |
|
139 // From MHuiDisplayRefreshObserver |
|
140 // void NotifyDisplayRefreshStarted( CHuiDisplay &aDisplay ); |
|
141 |
|
142 //From |
|
143 |
|
144 void VisualObjectLayoutRefreshed(TInt aListIndex ,TSize aScreenSize ); |
|
145 /** |
|
146 * @return The thumbnail scale mode of list |
|
147 */ |
|
148 CAlfImageVisual::TScaleMode ThumbnailScaleMode(); |
|
149 |
|
150 private: |
|
151 /** |
|
152 * Constructor |
|
153 * @param aMediaList Media list of items the visuals represent |
|
154 * @param aEnv HUI environment for the control |
|
155 * @param aDisplay HUI display on which the control should be shown |
|
156 * @param aThumbnailScaleMode Scale mode to use for the visuals |
|
157 */ |
|
158 CGlxVisualListControl( MGlxMediaList& aMediaList, |
|
159 CAlfEnv& aEnv, |
|
160 CAlfImageVisual::TScaleMode aThumbnailScaleMode ); |
|
161 |
|
162 /** |
|
163 * Second-phase constructor |
|
164 */ |
|
165 void ConstructL( CAlfEnv& aEnv, CAlfDisplay& aDisplay ); |
|
166 |
|
167 /** |
|
168 * Find the range offsets for the window by combining all contexts. |
|
169 * @param aFrontOffset Variable to store the front offset. |
|
170 * @param aRearOffset Variable to store the rear offset. |
|
171 */ |
|
172 void RangeOffsets(TInt& aFrontOffset, TInt& aRearOffsets); |
|
173 /** |
|
174 * Inform observers of a visual being removed. |
|
175 * @param aVisual The visual that is being removed. |
|
176 */ |
|
177 void HandleVisualRemoved( const CAlfVisual* aVisual ); |
|
178 /** |
|
179 * Inform observers of a visual being added. |
|
180 * @param aVisual The visual that is being added. |
|
181 * @param aIndex The list index of the new visual. |
|
182 */ |
|
183 void HandleVisualAddedL( CAlfVisual* aVisual, TInt aIndex ); |
|
184 |
|
185 private: // From CAlfControl |
|
186 /** |
|
187 * Notifies the control that one of the visuals it ows has been laid out. |
|
188 * Updates observers with new size. Public in base class, but not intended |
|
189 * to be used by clients. |
|
190 */ |
|
191 void VisualLayoutUpdated( CAlfVisual& aVisual ); |
|
192 |
|
193 private: |
|
194 /** The media list (not owned) */ |
|
195 MGlxMediaList& iMediaList; |
|
196 /** The alf env (not owned) */ |
|
197 CAlfEnv& iEnv; |
|
198 /** |
|
199 * Structure to hold information about a view context. |
|
200 */ |
|
201 struct TContext |
|
202 { |
|
203 TGlxViewContextId iId; |
|
204 TInt iFrontVisibleRangeOffset; |
|
205 TInt aRearVisibleRangeOffset; |
|
206 }; |
|
207 |
|
208 private: |
|
209 /** Number of users of this object */ |
|
210 TInt iReferenceCount; |
|
211 |
|
212 /** Window of visuals in the visible part of the media list (owned) */ |
|
213 CGlxVisualListWindow* iVisualWindow; |
|
214 |
|
215 /** Border brush for visuals (owned) */ |
|
216 CAlfBorderBrush* iBorderBrush; |
|
217 |
|
218 /** Control group for the control (owned) */ |
|
219 CAlfControlGroup* iControlGroup; |
|
220 |
|
221 /** ID of the control group */ |
|
222 TInt iControlGroupId; |
|
223 |
|
224 /** Parent layout for the visuals (owned by HUI) */ |
|
225 CAlfAnchorLayout* iParentLayout; |
|
226 |
|
227 /** Current Size of the Parent Layout */ |
|
228 TSize iCurrentLayoutSize; |
|
229 // TGlxBlendLayout iLayoutBlender; |
|
230 /** Ref: UI utility */ |
|
231 CGlxUiUtility* iUiUtility; |
|
232 |
|
233 /** Blender of multiple MGlxLayouts */ |
|
234 //MGlxLayout* iLayout; |
|
235 |
|
236 /** Array of view contexts (owned) */ |
|
237 RArray<TContext> iContexts; |
|
238 |
|
239 /** ID provider for new view contexts */ |
|
240 TGlxDefaultIdProvider<TGlxViewContextId> iContextIdProvider; |
|
241 |
|
242 /** Time of last movement */ |
|
243 TTime iLastTime; |
|
244 |
|
245 /** Array of observers (owned) */ |
|
246 RPointerArray<MGlxVisualListObserver> iObservers; |
|
247 |
|
248 /// Default scale mode of image visual |
|
249 CAlfImageVisual::TScaleMode iScaleMode; |
|
250 |
|
251 /** Fetch context for attributes needed for animated GIFs (owned) */ |
|
252 CGlxDefaultAttributeContext* iAttributeContext; |
|
253 |
|
254 /// Own: the visual icon manager in case default icons are wanted |
|
255 CGlxVisualIconManager* iVisualIconManager; |
|
256 |
|
257 MGlxLayoutObserver* iLayoutObserver; |
|
258 }; |
|
259 |
|
260 #endif // C_GLXVISUALLISTCONTROL_H |
|
261 |
|
262 |
|
263 |