|
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: Implementation of Grid view |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 // INCLUDE FILES |
|
23 #include <aknbutton.h> |
|
24 #include <StringLoader.h> |
|
25 #include <AknsBasicBackgroundControlContext.h> |
|
26 |
|
27 //Gallery Headers |
|
28 #include <glxactivemedialistregistry.h> // For medialist registry |
|
29 #include <glxcommandhandlers.hrh> // For EGlxCmdFullScreenBack |
|
30 #include <glxgridviewdata.rsg> // Gridview resource |
|
31 |
|
32 #include <mglxmedialist.h> // CGlxMedialist |
|
33 #include <glxsetappstate.h> |
|
34 #include <glxtracer.h> // For Tracer |
|
35 #include <glxlog.h> |
|
36 |
|
37 // User Includes |
|
38 #include "glxgridviewimp.h" |
|
39 #include "glxgridviewmlobserver.h" // medialist observer for Hg Grid |
|
40 #include "glxgridviewcontainer.h" |
|
41 |
|
42 // For transition effects |
|
43 #include <akntranseffect.h> |
|
44 #include <gfxtranseffect/gfxtranseffect.h> |
|
45 #include "glxgfxtranseffect.h" // For transition effects |
|
46 |
|
47 const TInt KGlxToolbarButtonUnLatched = 0; // Toolbar mark button's unlatched state defined in the rss file |
|
48 |
|
49 // ======== MEMBER FUNCTIONS ======== |
|
50 |
|
51 // --------------------------------------------------------------------------- |
|
52 // Two-phased constructor. |
|
53 // --------------------------------------------------------------------------- |
|
54 // |
|
55 CGlxGridViewImp* CGlxGridViewImp::NewL( |
|
56 MGlxMediaListFactory* aMediaListFactory, |
|
57 const TGridViewResourceIds& aResourceIds, |
|
58 TInt aViewUID, |
|
59 const TDesC& aTitle) |
|
60 { |
|
61 TRACER("CGlxGridViewImp::NewL"); |
|
62 CGlxGridViewImp* self = CGlxGridViewImp::NewLC(aMediaListFactory, |
|
63 aResourceIds, |
|
64 aViewUID, |
|
65 aTitle); |
|
66 CleanupStack::Pop(self); |
|
67 return self; |
|
68 } |
|
69 |
|
70 // --------------------------------------------------------------------------- |
|
71 // Two-phased constructor. |
|
72 // --------------------------------------------------------------------------- |
|
73 // |
|
74 CGlxGridViewImp* CGlxGridViewImp::NewLC( |
|
75 MGlxMediaListFactory* aMediaListFactory, |
|
76 const TGridViewResourceIds& aResourceIds, |
|
77 TInt aViewUID, |
|
78 const TDesC& aTitle) |
|
79 { |
|
80 TRACER("CGlxGridViewImp::NewLC()"); |
|
81 CGlxGridViewImp* self = |
|
82 new (ELeave) CGlxGridViewImp(aResourceIds, aViewUID); |
|
83 CleanupStack::PushL(self); |
|
84 self->ConstructL(aMediaListFactory, aTitle); |
|
85 return self; |
|
86 } |
|
87 |
|
88 // --------------------------------------------------------------------------- |
|
89 // C++ default constructor can NOT contain any code, that |
|
90 // might leave. |
|
91 // --------------------------------------------------------------------------- |
|
92 // |
|
93 CGlxGridViewImp::CGlxGridViewImp(const TGridViewResourceIds& aResourceIds, |
|
94 TInt aViewUID) : |
|
95 iResourceIds(aResourceIds), |
|
96 iViewUID(aViewUID), |
|
97 iPreviousFocusChangeType(NGlxListDefs::EUnknown) |
|
98 { |
|
99 TRACER("CGlxGridViewImp::CGlxGridViewImp()"); |
|
100 } |
|
101 |
|
102 // --------------------------------------------------------------------------- |
|
103 // Symbian 2nd phase constructor can leave. |
|
104 // --------------------------------------------------------------------------- |
|
105 // |
|
106 void CGlxGridViewImp::ConstructL(MGlxMediaListFactory* aMediaListFactory, |
|
107 const TDesC& aTitle) |
|
108 { |
|
109 TRACER("CGlxGridViewImp::ConstructL()"); |
|
110 BaseConstructL(iResourceIds.iViewId); |
|
111 ViewBaseConstructL(); |
|
112 MLViewBaseConstructL(aMediaListFactory, aTitle); |
|
113 |
|
114 // Get object that stores the active media list registry |
|
115 iActiveMediaListRegistry = CGlxActiveMediaListRegistry::InstanceL(); |
|
116 } |
|
117 |
|
118 // --------------------------------------------------------------------------- |
|
119 // From CAknView |
|
120 // Handles a view activation. |
|
121 // --------------------------------------------------------------------------- |
|
122 // |
|
123 void CGlxGridViewImp::DoMLViewActivateL( |
|
124 const TVwsViewId& /*aPrevViewId*/, |
|
125 TUid /* aCustomMessageId */, |
|
126 const TDesC8& aCustomMessage) |
|
127 { |
|
128 TRACER("CGlxGridViewImp::DoMLViewActivateL()"); |
|
129 |
|
130 HBufC8* activationParam = HBufC8::NewLC(KMaxUidName); |
|
131 activationParam->Des().AppendNum(KGlxActivationCmdShowAll); |
|
132 |
|
133 if (aCustomMessage.Compare(activationParam->Des()) == 0) |
|
134 { |
|
135 // Launched from Camera App, Check if there is any existing filter |
|
136 // and clear the 'MaxCount' filter, if supported to show all images. |
|
137 GLX_DEBUG1("CGlxGridViewImp::DoMLViewActivateL() - " |
|
138 "Launched From Camera"); |
|
139 CMPXFilter* filter = iMediaList->Filter(); |
|
140 if (filter && filter->IsSupported(KGlxFilterGeneralMaxCount)) |
|
141 { |
|
142 GLX_DEBUG1( "CGlxGridViewImp::DoMLViewActivateL()- " |
|
143 "Clear MaxCount filter"); |
|
144 filter->SetTObjectValueL<TInt> (KGlxFilterGeneralMaxCount, 0); |
|
145 iMediaList->SetFilterL(filter); |
|
146 } |
|
147 } |
|
148 |
|
149 |
|
150 if(StatusPane()) |
|
151 { |
|
152 StatusPane()->MakeVisible(ETrue); |
|
153 CEikStatusPane* statusPane = iEikonEnv->AppUiFactory()->StatusPane(); |
|
154 CAknTitlePane* titlePane = ( CAknTitlePane* )statusPane->ControlL( |
|
155 TUid::Uid( EEikStatusPaneUidTitle )); |
|
156 const TDesC* titleText = titlePane->Text(); |
|
157 HBufC* tempTitle = titleText->AllocLC(); |
|
158 TPtr titleptr = tempTitle->Des(); |
|
159 titleptr.Trim(); |
|
160 if(!tempTitle->Length()) |
|
161 { |
|
162 if( iTitletext ) |
|
163 { |
|
164 // Set the required Title |
|
165 titlePane->SetTextL( *iTitletext ); |
|
166 } |
|
167 } |
|
168 CleanupStack::PopAndDestroy(tempTitle); |
|
169 } |
|
170 |
|
171 GlxSetAppState::SetState(EGlxInCarouselView); |
|
172 // Setting the Context sensitive menu id |
|
173 MenuBar()->SetContextMenuTitleResourceId( iResourceIds.iOkOptionsMenuId ); |
|
174 iActiveMediaListRegistry->RegisterActiveMediaList(iMediaList); |
|
175 if(!iToolbar) |
|
176 { |
|
177 iToolbar = CAknToolbar::NewL(R_GLX_GRID_VIEW_TOOLBAR); |
|
178 SetGridToolBar(iToolbar); |
|
179 SetToolbarObserver(this); |
|
180 iToolbar->SetDimmed(ETrue); |
|
181 iToolbar->SetToolbarVisibility(ETrue); |
|
182 } |
|
183 //Create gridview container |
|
184 iGlxGridViewContainer = CGlxGridViewContainer::NewL(iMediaList, |
|
185 iUiUtility, *this, iToolbar); |
|
186 iEikonEnv->AppUi()->AddToStackL(*this,iGlxGridViewContainer); |
|
187 iUiUtility->DestroyScreenClearer(); |
|
188 |
|
189 // Start Animating the view when launched from other views |
|
190 // except if launched from Camera App. |
|
191 if (aCustomMessage.Compare(activationParam->Des()) != 0) |
|
192 { |
|
193 TUint transitionID = (iUiUtility->ViewNavigationDirection() |
|
194 == EGlxNavigationForwards) ? KActivateTransitionId |
|
195 : KFSDeActivateTransitionId; |
|
196 GfxTransEffect::BeginFullScreen( transitionID, TRect(), |
|
197 AknTransEffect::EParameterType, |
|
198 AknTransEffect::GfxTransParam( KPhotosUid, |
|
199 AknTransEffect::TParameter::EEnableEffects) ); |
|
200 iIsTransEffectStarted = ETrue; |
|
201 } |
|
202 CleanupStack::PopAndDestroy(activationParam); |
|
203 } |
|
204 |
|
205 // --------------------------------------------------------------------------- |
|
206 // From CAknView |
|
207 // View deactivation function. |
|
208 // --------------------------------------------------------------------------- |
|
209 // |
|
210 void CGlxGridViewImp::DoMLViewDeactivate() |
|
211 { |
|
212 TRACER("CGlxGridViewImp::DoMLViewDeactivate"); |
|
213 if(StatusPane()) |
|
214 { |
|
215 if(iTitletext) |
|
216 { |
|
217 delete iTitletext; |
|
218 iTitletext = NULL; |
|
219 } |
|
220 CEikStatusPane* statusPane = iEikonEnv->AppUiFactory()->StatusPane(); |
|
221 TRAP_IGNORE(CAknTitlePane* titlePane = ( CAknTitlePane* )statusPane->ControlL( |
|
222 TUid::Uid( EEikStatusPaneUidTitle )); |
|
223 iTitletext = titlePane->Text()->AllocL()); |
|
224 } |
|
225 // Deregister active media list pointer |
|
226 iActiveMediaListRegistry->DeregisterActiveMediaList(iMediaList); |
|
227 if(iToolbar) |
|
228 { |
|
229 delete iToolbar; |
|
230 iToolbar = NULL; |
|
231 //set the gridtoolbar to NULL in viewbase. |
|
232 SetGridToolBar(iToolbar); |
|
233 } |
|
234 // Destroy Grid widget before going to next view |
|
235 DestroyGridWidget(); |
|
236 } |
|
237 |
|
238 // --------------------------------------------------------------------------- |
|
239 // DestroyGridWidget |
|
240 // --------------------------------------------------------------------------- |
|
241 // |
|
242 void CGlxGridViewImp::DestroyGridWidget() |
|
243 { |
|
244 TRACER("CGlxGridViewImp::DestroyGridWidget()"); |
|
245 //while view deactivating need to remove from the control stack. |
|
246 iEikonEnv->AppUi()->RemoveFromViewStack(*this,iGlxGridViewContainer); |
|
247 delete iGlxGridViewContainer; |
|
248 iGlxGridViewContainer = NULL; |
|
249 } |
|
250 |
|
251 // --------------------------------------------------------------------------- |
|
252 // Destructor |
|
253 // --------------------------------------------------------------------------- |
|
254 // |
|
255 CGlxGridViewImp::~CGlxGridViewImp() |
|
256 { |
|
257 TRACER("CGlxGridViewImp::~CGlxGridViewImp"); |
|
258 delete iTitletext; |
|
259 if(iToolbar) |
|
260 { |
|
261 delete iToolbar; |
|
262 iToolbar = NULL; |
|
263 } |
|
264 if (iActiveMediaListRegistry) |
|
265 { |
|
266 iActiveMediaListRegistry->Close(); |
|
267 } |
|
268 } |
|
269 |
|
270 // --------------------------------------------------------------------------- |
|
271 // From CAknView |
|
272 // Returns views id. |
|
273 // --------------------------------------------------------------------------- |
|
274 TUid CGlxGridViewImp::Id() const |
|
275 { |
|
276 TRACER("CGlxGridViewImp::Id()"); |
|
277 return TUid::Uid(iViewUID); |
|
278 } |
|
279 |
|
280 // --------------------------------------------------------------------------- |
|
281 // From CAknView |
|
282 // Command handling function. |
|
283 // --------------------------------------------------------------------------- |
|
284 TBool CGlxGridViewImp::HandleViewCommandL(TInt aCommand) |
|
285 { |
|
286 TRACER("CGlxGridViewImp::HandleViewCommandL()"); |
|
287 GLX_LOG_INFO1( "CGlxGridViewImp::HandleViewCommandL(%x) entering", aCommand ); |
|
288 return iGlxGridViewContainer->HandleViewCommandL(aCommand); |
|
289 } |
|
290 |
|
291 // --------------------------------------------------------------------------- |
|
292 // From CAknView |
|
293 // HandleForegroundEventL |
|
294 // Foreground event handling function. |
|
295 // --------------------------------------------------------------------------- |
|
296 // |
|
297 void CGlxGridViewImp::HandleForegroundEventL(TBool aForeground) |
|
298 { |
|
299 TRACER("CGlxGridViewImp::HandleForegroundEventL()"); |
|
300 if(iMMCState) |
|
301 { |
|
302 iMMCState = EFalse; |
|
303 ProcessCommandL(EAknSoftkeyClose); |
|
304 } |
|
305 CAknView::HandleForegroundEventL(aForeground); |
|
306 } |
|
307 |
|
308 // --------------------------------------------------------------------------- |
|
309 // From MGlxHandleGridEvents |
|
310 // HandleGridEventsL() |
|
311 // handles processcommandL related commands |
|
312 // ----------------------------------------------------------------------------- |
|
313 // |
|
314 void CGlxGridViewImp::HandleGridEventsL(TInt aCmd) |
|
315 { |
|
316 TRACER("CGlxGridViewImp::HandleGridEventsL()"); |
|
317 //do processcmd related event handling |
|
318 if(EAknSoftkeyClose == aCmd) |
|
319 { |
|
320 iMMCState = ETrue; |
|
321 } |
|
322 ProcessCommandL(aCmd); |
|
323 } |
|
324 |
|
325 // --------------------------------------------------------------------------- |
|
326 // From MGlxHandleButtonMark |
|
327 // HandleLatchToolbar() |
|
328 // sets toolbar mark unmark status |
|
329 // ----------------------------------------------------------------------------- |
|
330 // |
|
331 void CGlxGridViewImp::HandleLatchToolbar() |
|
332 { |
|
333 TRACER("CGlxGridViewImp::HandleLatchToolbarL()"); |
|
334 CAknButton* markButton = |
|
335 static_cast<CAknButton*> (iToolbar->ControlOrNull( |
|
336 EGlxCmdStartMultipleMarking)); |
|
337 |
|
338 if(markButton) |
|
339 { |
|
340 GLX_DEBUG1("CGlxGridViewImp::HandleLatchToolbar() - UnLatch"); |
|
341 markButton->SetCurrentState( KGlxToolbarButtonUnLatched, ETrue ); |
|
342 } |
|
343 } |
|
344 // End of File |