|
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 manager |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 /** |
|
22 * @internal reviewed 04/07/2007 by M Byrne |
|
23 */ |
|
24 |
|
25 #include "glxvisuallistwindow.h" |
|
26 |
|
27 #include <coemain.h> |
|
28 #include <alf/alfimagevisual.h> |
|
29 #include <alf/alfanchorlayout.h> |
|
30 #include <alf/alfenv.h> |
|
31 #include <alf/alfbrush.h> |
|
32 #include <alf/alfcontrolgroup.h> |
|
33 #include <alf/alfborderbrush.h> |
|
34 #include <alf/alfdecklayout.h> |
|
35 #include <glxlog.h> |
|
36 #include <glxtracer.h> |
|
37 #include <mpxmediageneraldefs.h> |
|
38 #include <AknUtils.h> |
|
39 #include "mglxmedialistobserver.h" |
|
40 #include "glxuiutility.h" |
|
41 #include "glxitemvisual.h" |
|
42 #include <glxtexturemanager.h> |
|
43 #include "glxvisuallistcontrol.h" |
|
44 #include <mglxanimation.h> |
|
45 #include <mglxmedialist.h> |
|
46 #include <glxthumbnailutility.h> |
|
47 #include <glxuistd.h> |
|
48 #include "glxlistwindow.h" |
|
49 #include "glxitemvisual.h" |
|
50 // ----------------------------------------------------------------------------- |
|
51 // Constructor |
|
52 // ----------------------------------------------------------------------------- |
|
53 CGlxVisualListWindow* CGlxVisualListWindow::NewL( CGlxVisualListControl* aControl, |
|
54 MGlxMediaList* aMediaList, CGlxUiUtility* aUiUtility, |
|
55 CAlfImageVisual::TScaleMode aThumbnailScaleMode ) |
|
56 { |
|
57 TRACER("CGlxVisualListWindow::NewL"); |
|
58 GLX_LOG_INFO("CGlxVisualListWindow::NewL"); |
|
59 CGlxVisualListWindow* self = new (ELeave) CGlxVisualListWindow(); |
|
60 CleanupStack::PushL( self ); |
|
61 |
|
62 self->iControl = aControl; |
|
63 self->iMediaList = aMediaList; |
|
64 self->iUiUtility = aUiUtility; |
|
65 self->iScaleMode = aThumbnailScaleMode; |
|
66 self->ConstructL(); // Construct base class |
|
67 |
|
68 CleanupStack::Pop( self ); |
|
69 return self; |
|
70 |
|
71 } |
|
72 |
|
73 |
|
74 CGlxVisualListWindow::CGlxVisualListWindow(): |
|
75 CGlxListWindow( static_cast< MGlxWindowObjectFactory& > ( *this ) ) |
|
76 { |
|
77 |
|
78 } |
|
79 |
|
80 CBase* CGlxVisualListWindow::CreateObjectL() const |
|
81 { |
|
82 TRACER("CGlxVisualListWindow::CreateObjectL"); |
|
83 GLX_LOG_INFO("CGlxVisualListWindow::CreateObjectL"); |
|
84 |
|
85 CGlxVisualObject* object = CGlxVisualObject::NewLC( *(const_cast<CGlxVisualListWindow*>(this)) ,*iMediaList ); |
|
86 CleanupStack::Pop( object ); |
|
87 return object; |
|
88 |
|
89 } |
|
90 |
|
91 |
|
92 void CGlxVisualListWindow::SetupObject(TInt aIndex, CBase& aObject ) |
|
93 { |
|
94 TRACER("CGlxVisualListWindow::SetupObject"); |
|
95 GLX_LOG_INFO("CGlxVisualListWindow::SetupObject"); |
|
96 TRAP_IGNORE(SetupObjectL( aIndex, aObject )); |
|
97 } |
|
98 // ----------------------------------------------------------------------------- |
|
99 // SetupObjectL |
|
100 // ----------------------------------------------------------------------------- |
|
101 void CGlxVisualListWindow::SetupObjectL( TInt aIndex, CBase& aObject ) |
|
102 { |
|
103 TRACER("CGlxVisualListWindow::SetupObjectL 2"); |
|
104 GLX_LOG_INFO("CGlxVisualListWindow::SetupObjectL 2"); |
|
105 CGlxVisualObject& object = static_cast< CGlxVisualObject& >( aObject ); |
|
106 // set the index |
|
107 object.SetIndex( aIndex ); |
|
108 |
|
109 // No easy way to get rid of this trap. Would be possible to do |
|
110 // multiple objects within the same trap by modifying the CGlxListWindowBase |
|
111 // but would be surprising if this TRAP is a actually a performance problem |
|
112 TSize visSize =iUiUtility->DisplaySize(); |
|
113 |
|
114 CAlfTexture* texture = NULL; |
|
115 |
|
116 // media will be null if aMedia's Properties are not available |
|
117 // so furtur operation need to be cancle |
|
118 if ( !iMediaList->Item( aIndex ).Properties() ) |
|
119 { |
|
120 texture = &iUiUtility->Env()->TextureManager().BlankTexture(); |
|
121 } |
|
122 else |
|
123 { |
|
124 TRAPD(err, texture = &iUiUtility->GlxTextureManager().CreateThumbnailTextureL( |
|
125 iMediaList->Item( aIndex ),iMediaList->IdSpaceId( aIndex ), visSize, &object )); |
|
126 if(err != KErrNone) |
|
127 { |
|
128 texture = &iUiUtility->Env()->TextureManager().BlankTexture(); |
|
129 } |
|
130 } |
|
131 // add the texture and its id for the visual object |
|
132 object.SetImage(TAlfImage( *texture )); |
|
133 |
|
134 TSize imageSize ; |
|
135 iMediaList->Item( aIndex ).GetDimensions(imageSize); |
|
136 // Set scale mode to EScaleFitInside if the Image is bigger then screen |
|
137 // or to scale the grid size thumbnails if full thumbnail is not available while fast swipe |
|
138 if ( (imageSize.iWidth >= visSize.iWidth || imageSize.iHeight >= visSize.iHeight) |
|
139 ||(texture->Size().iHeight < imageSize.iHeight && texture->Size().iWidth < imageSize.iWidth )) |
|
140 { |
|
141 object.SetScaleMode(CAlfImageVisual::EScaleFitInside); |
|
142 } |
|
143 //this will keep the image back to its normal size if the condition is not satsified. |
|
144 else |
|
145 { |
|
146 object.SetScaleMode(CAlfImageVisual::EScaleNormal); |
|
147 } |
|
148 |
|
149 // Keep the visual invisible to avoid showing wrong visual in the starting, |
|
150 // Effect control will make it visisble |
|
151 object.SetVisible( EFalse ); |
|
152 |
|
153 // notify observer |
|
154 iControl->HandleVisualAddedL( object.Visual(), aIndex ); |
|
155 } |
|
156 |
|
157 void CGlxVisualListWindow::CleanupObject(TInt /*aListIndex*/, CBase& aObject) |
|
158 { |
|
159 TRACER("CGlxVisualListWindow::CleanupObject"); |
|
160 GLX_LOG_INFO("CGlxVisualListWindow::CleanupObject"); |
|
161 CGlxVisualObject& object = static_cast< CGlxVisualObject& >( aObject ); |
|
162 |
|
163 object.Reset(); |
|
164 |
|
165 iControl->HandleVisualRemoved( object.Visual() ); |
|
166 } |
|
167 |
|
168 // ----------------------------------------------------------------------------- |
|
169 // GetObjectL |
|
170 // ----------------------------------------------------------------------------- |
|
171 CGlxVisualObject* CGlxVisualListWindow::GetObjectL( TInt aListIndex ) |
|
172 { |
|
173 TRACER("CGlxVisualListWindow::GetObjectL"); |
|
174 GLX_LOG_INFO1("CGlxVisualListWindow::GetObjectL %d", aListIndex); |
|
175 // create the object |
|
176 CGlxVisualObject* listObj = |
|
177 CGlxVisualObject::NewLC( *this, *iMediaList ); |
|
178 CleanupStack::Pop( listObj ); |
|
179 return listObj; |
|
180 } |
|
181 |
|
182 // ----------------------------------------------------------------------------- |
|
183 // CleanupObject |
|
184 // ----------------------------------------------------------------------------- |
|
185 void CGlxVisualListWindow::CleanupObject( TInt aWindowIndex ) |
|
186 { |
|
187 TRACER("CGlxVisualListWindow::CleanupObject 2"); |
|
188 GLX_LOG_INFO1("CGlxVisualListWindow::CleanupObject 2 %d",aWindowIndex); |
|
189 CGlxVisualObject* item = ObjectByIndex( aWindowIndex); |
|
190 CAlfVisual* visual = item->Visual(); |
|
191 |
|
192 iControl->HandleVisualRemoved( visual ); |
|
193 } |
|
194 |
|
195 // ----------------------------------------------------------------------------- |
|
196 // PostObjectsAdded |
|
197 // ----------------------------------------------------------------------------- |
|
198 void CGlxVisualListWindow::PostObjectsAdded( RArray<TInt>& /*aAddedAtListIndexes*/ ) |
|
199 { |
|
200 } |
|
201 |
|
202 // ----------------------------------------------------------------------------- |
|
203 // SetFocusIndexL |
|
204 // ----------------------------------------------------------------------------- |
|
205 void CGlxVisualListWindow::SetFocusIndexL( TInt aFocusIndex ) |
|
206 { |
|
207 TRACER("CGlxVisualListWindow::SetFocusIndexL"); |
|
208 GLX_LOG_INFO1("CGlxVisualListWindow::SetFocusIndexL %d",aFocusIndex); |
|
209 CGlxListWindow::SetFocusIndexL( aFocusIndex ); |
|
210 |
|
211 UpdatePositions(); |
|
212 |
|
213 } |
|
214 |
|
215 // ----------------------------------------------------------------------------- |
|
216 // UpdatePositions |
|
217 // ----------------------------------------------------------------------------- |
|
218 void CGlxVisualListWindow::UpdatePositions() |
|
219 { |
|
220 TRACER("CGlxVisualListWindow::UpdatePositions"); |
|
221 GLX_LOG_INFO("CGlxVisualListWindow::UpdatePositions"); |
|
222 // Set positions of items in the window to current list index. |
|
223 TGlxWindowIterator iterator = Iterator(); |
|
224 TInt index = 0; |
|
225 while ( KErrNotFound != ( index = iterator++ ) ) |
|
226 { |
|
227 CGlxVisualObject* visualObj = ObjectByIndex( index ); |
|
228 // set index for the visual |
|
229 visualObj->SetIndex( index ); |
|
230 // get screen size |
|
231 TSize screenSize = iUiUtility->DisplaySize(); |
|
232 // update the layout data |
|
233 visualObj->RefreshLayout(screenSize); |
|
234 } |
|
235 } |
|
236 |
|
237 // ----------------------------------------------------------------------------- |
|
238 // Layout |
|
239 // ----------------------------------------------------------------------------- |
|
240 CAlfLayout* CGlxVisualListWindow::Layout() |
|
241 { |
|
242 TRACER("CGlxVisualListWindow::Layout"); |
|
243 GLX_LOG_INFO("CGlxVisualListWindow::Layout"); |
|
244 return static_cast<CAlfLayout*>(iControl->iParentLayout); |
|
245 } |
|
246 |
|
247 // ----------------------------------------------------------------------------- |
|
248 // VisualOwner |
|
249 // ----------------------------------------------------------------------------- |
|
250 CAlfControl& CGlxVisualListWindow::VisualOwner() |
|
251 { |
|
252 TRACER("CGlxVisualListWindow::VisualOwner"); |
|
253 GLX_LOG_INFO("CGlxVisualListWindow::VisualOwner"); |
|
254 return *iControl; |
|
255 } |
|
256 |
|
257 // ----------------------------------------------------------------------------- |
|
258 // BorderBrush |
|
259 // ----------------------------------------------------------------------------- |
|
260 CAlfBrush* CGlxVisualListWindow::BorderBrush() |
|
261 { |
|
262 TRACER("CGlxVisualListWindow::BorderBrush"); |
|
263 GLX_LOG_INFO("CGlxVisualListWindow::BorderBrush"); |
|
264 return iControl->iBorderBrush; |
|
265 } |
|
266 |
|
267 // ----------------------------------------------------------------------------- |
|
268 // ThumbnailScaleMode |
|
269 // ----------------------------------------------------------------------------- |
|
270 CAlfImageVisual::TScaleMode CGlxVisualListWindow::ThumbnailScaleMode() |
|
271 { |
|
272 TRACER("CGlxVisualListWindow::ThumbnailScaleMode"); |
|
273 GLX_LOG_INFO("CGlxVisualListWindow::ThumbnailScaleMode"); |
|
274 return iScaleMode; |
|
275 } |
|
276 |
|
277 // ----------------------------------------------------------------------------- |
|
278 // Return visual object by index |
|
279 // ----------------------------------------------------------------------------- |
|
280 CGlxVisualObject* CGlxVisualListWindow::ObjectByIndex( TInt aIndex ) |
|
281 { |
|
282 TRACER("CGlxVisualListWindow::ObjectByIndex"); |
|
283 GLX_LOG_INFO("CGlxVisualListWindow::ObjectByIndex"); |
|
284 return static_cast< CGlxVisualObject* >( At( aIndex ) ); |
|
285 } |
|
286 |