|
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 CGlxZoomControl |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INCLUDE FILES |
|
20 |
|
21 #include "glxzoomcontrol.h" |
|
22 |
|
23 // INCLUDES |
|
24 #include <data_caging_path_literals.hrh> |
|
25 #include <eikbtgpc.h> //For CEikButtonGroupContainer |
|
26 #include <ExifRead.h> |
|
27 |
|
28 //Alf Headers |
|
29 #include <alf/alfviewportlayout.h> // For CAlfViewPortLayout |
|
30 #include <alf/alfimagevisual.h> // For CAlfImageVisual |
|
31 #include <alf/alfcontrolgroup.h> // For CAlfControlGroup |
|
32 #include <alf/alfdisplay.h> // For CAlfDisplay |
|
33 #include <alf/alfroster.h> // For CAlfRoster |
|
34 #include <alf/alfutil.h> // For AlfUtil |
|
35 // Antariksh |
|
36 #include <mul/imulsliderwidget.h> // For Slider Widget |
|
37 #include <mul/mulevent.h> // For Slider events |
|
38 |
|
39 #include <gesturehelper.h> |
|
40 #include <e32math.h> |
|
41 |
|
42 using namespace GestureHelper; |
|
43 |
|
44 //Gallery Headers |
|
45 #include <glxuiutility.h> |
|
46 #include <glxattributecontext.h> |
|
47 #include <glxtracer.h> // For Tracer |
|
48 #include <glxlog.h> // For Log |
|
49 #include <glxtexturemanager.h> // For Creating Texture |
|
50 #include <glxuistd.h> // For Fetch Context Priority |
|
51 #include <mglxmedialist.h> // For MGlxMediaList |
|
52 #include <mglxuicommandhandler.h> // For MGlxUiCommandHandler |
|
53 |
|
54 #include "glxtv.h" // for CGlxTv |
|
55 // LOCAL CONSTANTS AND MACROS |
|
56 const TReal KGlxOpacityOpaque = 1.0; |
|
57 const TInt KGlxMaxExifSize = 0x10000; |
|
58 const TReal KGlxOpacityTransparent = 0.0; |
|
59 //zoom delay for animation while hdmi cable, |
|
60 //is connected and zoom is initiated |
|
61 const TInt KZoomDelay = 150000; |
|
62 //Zoom level for the animation , assuming the innitial level is 1. |
|
63 const TReal KGlxZoomLevel = 1.5; |
|
64 const TInt KGlxMinSmallImageZoomLevel =100; |
|
65 |
|
66 const TInt KGlxDecodingThreshold = 3000000; // pixels |
|
67 |
|
68 |
|
69 // ============================ MEMBER FUNCTIONS =============================== |
|
70 |
|
71 // ----------------------------------------------------------------------------- |
|
72 // CGlxZoomControl::CGlxZoomControl |
|
73 // C++ default constructor can NOT contain any code, that might leave. |
|
74 // ----------------------------------------------------------------------------- |
|
75 // |
|
76 CGlxZoomControl::CGlxZoomControl(MGlxUiCommandHandler& aCommandHandler, |
|
77 MGlxMediaList& aMediaList,CEikButtonGroupContainer& aZoomBackKeys, |
|
78 IMulSliderWidget& aSliderWidget, GestureHelper::CGestureHelper* aGestureHelper) : |
|
79 iMediaList(aMediaList), iGestureHelper(aGestureHelper), |
|
80 iZoomSliderWidget(aSliderWidget), iZoomBackKey(&aZoomBackKeys), |
|
81 iCommandHandler(aCommandHandler) |
|
82 { |
|
83 TRACER("CGlxZoomControl::CGlxZoomControl"); |
|
84 } |
|
85 |
|
86 // ----------------------------------------------------------------------------- |
|
87 // CGlxZoomControl::ConstructL |
|
88 // Symbian 2nd phase constructor can leave. |
|
89 // ----------------------------------------------------------------------------- |
|
90 // |
|
91 void CGlxZoomControl::ConstructL() |
|
92 { |
|
93 TRACER("CGlxZoomControl::ConstructL()"); |
|
94 iAttributeContext = CGlxDefaultAttributeContext::NewL(); |
|
95 iAttributeContext->AddAttributeL(KGlxMediaGeneralDimensions); |
|
96 iMediaList.AddContextL( iAttributeContext, KGlxFetchContextPriorityLow ); |
|
97 iUiUtility = CGlxUiUtility::UtilityL(); |
|
98 iEnv = iUiUtility->Env(); |
|
99 iDisplay = iUiUtility->Display(); |
|
100 iTextureMgr = &iUiUtility->GlxTextureManager(); |
|
101 iScreenSize = ScreenSize(); |
|
102 |
|
103 iDisplay->SetVisibleArea(TRect(TPoint(0,0),iScreenSize)); |
|
104 CAlfControl::ConstructL(*iEnv); |
|
105 |
|
106 //Func creating black background and visual that has to zoomed |
|
107 CreateZoomVisualL(); |
|
108 |
|
109 iControlGroup = &iEnv->NewControlGroupL(0x119); |
|
110 iControlGroup->AppendL(this); |
|
111 |
|
112 iDisplay->Roster().ShowL( *iControlGroup); |
|
113 |
|
114 // Hide the Zoom at the construction |
|
115 ShowZoom(EFalse); |
|
116 iZoomActive = EFalse; |
|
117 //To know if HDMi cable is connected. |
|
118 iGlxTvOut = CGlxTv::NewL(*this); |
|
119 iTimer = CPeriodic::NewL( CActive::EPriorityStandard ); |
|
120 } |
|
121 |
|
122 // ----------------------------------------------------------------------------- |
|
123 // ScreenSize : gets the screensize, Note that , this is not stored in member variable as |
|
124 // Screen rect can change based on orientation |
|
125 // ----------------------------------------------------------------------------- |
|
126 // |
|
127 TSize CGlxZoomControl::ScreenSize() |
|
128 { |
|
129 TRACER("CGlxZoomControl::ScreenSize()"); |
|
130 return AlfUtil::ScreenSize(); |
|
131 } |
|
132 |
|
133 // ----------------------------------------------------------------------------- |
|
134 // ShowZoom |
|
135 // ----------------------------------------------------------------------------- |
|
136 // |
|
137 void CGlxZoomControl::ShowZoom(TBool aShow) |
|
138 { |
|
139 TRACER("CGlxZoomControl::ShowZoom()"); |
|
140 if (aShow) |
|
141 { |
|
142 iViewPort->SetOpacity(KGlxOpacityOpaque); |
|
143 iGestureHelper->AddObserver(this); |
|
144 } |
|
145 else |
|
146 { |
|
147 iViewPort->SetOpacity(KGlxOpacityTransparent); |
|
148 } |
|
149 } |
|
150 |
|
151 // ----------------------------------------------------------------------------- |
|
152 // CreateZoomVisual |
|
153 // ----------------------------------------------------------------------------- |
|
154 // |
|
155 void CGlxZoomControl::CreateZoomVisualL() |
|
156 { |
|
157 TRACER("CGlxZoomControl::CreateZoomVisualL()"); |
|
158 |
|
159 CAlfTexture *blackoutTexture = &(iTextureMgr->CreateFlatColourTextureL(KRgbBlack)); |
|
160 CleanupStack::PushL(blackoutTexture); |
|
161 |
|
162 iViewPort = CAlfViewportLayout::AddNewL(*this); |
|
163 //Create the Image visual ,which holds the texture,which is complete black in color |
|
164 CAlfImageVisual *blackoutImageVisual = CAlfImageVisual::AddNewL(*this,iViewPort); |
|
165 CleanupStack::PushL(blackoutImageVisual); |
|
166 |
|
167 // Visual is larger than the screen to deal with control transformations that |
|
168 // may show areas usually outside the normal screen coordinates |
|
169 TInt16 blackImageSize =(iScreenSize.iWidth > iScreenSize.iHeight) ?iScreenSize.iWidth:iScreenSize.iHeight; |
|
170 blackoutImageVisual->SetImage(TAlfImage(*blackoutTexture)); |
|
171 blackoutImageVisual->SetFlag(EAlfVisualFlagManualLayout); |
|
172 blackoutImageVisual->SetSize(TAlfRealSize(blackImageSize, blackImageSize)); |
|
173 blackoutImageVisual->SetPos(TAlfRealPoint(0, 0)); |
|
174 CleanupStack::Pop(blackoutImageVisual); |
|
175 CleanupStack::Pop(blackoutTexture); |
|
176 |
|
177 // VisualLayoutUpdated |
|
178 // Enable scrolling of the Viewport. |
|
179 // The content area of a layout can be thought to be larger than the real visible size. |
|
180 // Scrolling changes which portion of the layout’s content is actually visible at the moment. |
|
181 iViewPort->SetFlag(EAlfVisualFlagLayoutUpdateNotification); |
|
182 iViewPort->SetVirtualSize(TAlfRealSize(iScreenSize.iWidth,iScreenSize.iHeight), 0); |
|
183 iViewPort->SetViewportSize(TAlfRealSize(iScreenSize.iWidth,iScreenSize.iHeight), 0); |
|
184 iViewPort->SetViewportPos(TAlfRealPoint(0,0), 0); |
|
185 iViewPort->SetClipping(EFalse); |
|
186 iViewPort->SetOrigin( EAlfVisualHOriginLeft, EAlfVisualVOriginTop ); |
|
187 |
|
188 //Enable scrolling of the Viewport. |
|
189 //The content area of a layout can be thought to be larger than the real visible size. |
|
190 //Scrolling changes which portion of the layout’s content is actually visible at the moment. |
|
191 iViewPort->EnableScrollingL(); |
|
192 iViewPort->EnableTransformationL(); |
|
193 |
|
194 iImageVisual = CAlfImageVisual::AddNewL(*this,iViewPort); |
|
195 iImageVisual->SetScaleMode(CAlfImageVisual::EScaleFitInside); |
|
196 |
|
197 iEventHandler = CGlxZoomPanEventHandler::NewL(*this); |
|
198 |
|
199 } |
|
200 |
|
201 // ----------------------------------------------------------------------------- |
|
202 // CGlxZoomControl::NewL |
|
203 // Two-phased constructor. |
|
204 // ----------------------------------------------------------------------------- |
|
205 // |
|
206 EXPORT_C CGlxZoomControl* CGlxZoomControl::NewL( |
|
207 MGlxUiCommandHandler& aCommandHandler, |
|
208 MGlxMediaList& aMediaList,CEikButtonGroupContainer& aZoomKeys, |
|
209 IMulSliderWidget& aSliderWidget, GestureHelper::CGestureHelper* aGestureHelper) |
|
210 { |
|
211 TRACER("CGlxZoomControl::NewL"); |
|
212 CGlxZoomControl* self = new (ELeave) CGlxZoomControl(aCommandHandler, |
|
213 aMediaList,aZoomKeys,aSliderWidget,aGestureHelper); |
|
214 |
|
215 CleanupStack::PushL(self); |
|
216 self->ConstructL(); |
|
217 |
|
218 CleanupStack::Pop(self); |
|
219 return self; |
|
220 } |
|
221 |
|
222 // ----------------------------------------------------------------------------- |
|
223 // Destructor |
|
224 // ----------------------------------------------------------------------------- |
|
225 // |
|
226 CGlxZoomControl::~CGlxZoomControl() |
|
227 { |
|
228 TRACER("CGlxZoomControl::~CGlxZoomControl()"); |
|
229 if(iTimer->IsActive()) |
|
230 { |
|
231 iTimer->Cancel(); |
|
232 } |
|
233 delete iTimer; |
|
234 if(iEventHandler) |
|
235 { |
|
236 delete iEventHandler; |
|
237 iEventHandler = NULL ; |
|
238 } |
|
239 |
|
240 if(iViewPort) |
|
241 { |
|
242 iViewPort->RemoveAndDestroyAllD(); |
|
243 iViewPort = NULL; |
|
244 } |
|
245 iMediaList.RemoveContext(iAttributeContext); |
|
246 delete iAttributeContext; |
|
247 if(iImageTexture) |
|
248 { |
|
249 delete iImageTexture; |
|
250 iImageTexture=NULL; |
|
251 } |
|
252 iDisplay->Roster().Hide(*iControlGroup); |
|
253 if ( iControlGroup ) |
|
254 { |
|
255 iControlGroup->Remove(this); |
|
256 iEnv->DeleteControlGroup(0x119); |
|
257 iControlGroup = NULL; |
|
258 } |
|
259 if ( iUiUtility ) |
|
260 { |
|
261 iUiUtility->Close(); |
|
262 } |
|
263 } |
|
264 |
|
265 // ----------------------------------------------------------------------------- |
|
266 // ActivateL:Activates the Zoom Control,set the image visual ,do the initial setup |
|
267 // ----------------------------------------------------------------------------- |
|
268 // |
|
269 EXPORT_C void CGlxZoomControl::ActivateL(TInt aInitialZoomRatio, TZoomStartMode aStartMode, |
|
270 TInt aFocusIndex, TGlxMedia& aItem, TPoint* aZoomFocus) |
|
271 { |
|
272 TRACER("CGlxZoomControl::ActivateL()"); |
|
273 if ( !iZoomActive ) |
|
274 { |
|
275 //This Varaiable updates that we are in zoom state now. |
|
276 iZoomActive = ETrue; |
|
277 //To Retrive the image details |
|
278 TMPXAttribute thumbNailAttribute(0,0); |
|
279 TGlxIdSpaceId idspace = iMediaList.IdSpaceId( aFocusIndex ); |
|
280 //Get the texture Created in fullscreen View. |
|
281 iImageTexture = &(iTextureMgr->CreateNewTextureForMediaL( |
|
282 ScreenSize(),aItem, idspace, this )); |
|
283 iImageVisual->SetImage(*iImageTexture); |
|
284 |
|
285 if(iGlxTvOut->IsConnected()) |
|
286 { |
|
287 StartZoomAnimation(); |
|
288 } |
|
289 else |
|
290 { |
|
291 ShowZoom(ETrue); |
|
292 iZoomSliderWidget.AddEventHandler(*this); |
|
293 iZoomSliderWidget.SetHandleKeyEvent(EFalse); |
|
294 iZoomSliderModel = (IMulSliderModel*) iZoomSliderWidget.model(); |
|
295 // Get size, return value tells us if it was available |
|
296 //We need this Value to calculate the size of the visual/Layout corresponding to the Zoom factor |
|
297 TSize imageSize; |
|
298 aItem.GetDimensions( imageSize ); |
|
299 TSize maxVirtualImageSize = imageSize; |
|
300 |
|
301 if (KGlxDecodingThreshold < (imageSize.iWidth * imageSize.iHeight)) |
|
302 { |
|
303 TReal areaRatio = TReal(imageSize.iWidth*imageSize.iHeight)/KGlxDecodingThreshold ; |
|
304 |
|
305 TReal sideRatio; |
|
306 Math::Sqrt(sideRatio, areaRatio); |
|
307 |
|
308 |
|
309 maxVirtualImageSize.iHeight = imageSize.iHeight / sideRatio ; |
|
310 maxVirtualImageSize.iWidth = imageSize.iWidth / sideRatio ; |
|
311 |
|
312 } |
|
313 |
|
314 TInt initialZoomRatio = GetIntialZoomLevel(maxVirtualImageSize); |
|
315 iZoomSliderModel->SetMinRange(initialZoomRatio); |
|
316 |
|
317 iEventHandler->SetZoomActivated(ETrue); |
|
318 iEventHandler->ActivateZoom(initialZoomRatio, |
|
319 maxVirtualImageSize, |
|
320 aStartMode, |
|
321 iZoomSliderModel->MinRange(), |
|
322 iZoomSliderModel->MaxRange(), |
|
323 maxVirtualImageSize, |
|
324 aZoomFocus); |
|
325 |
|
326 TRAP_IGNORE(iImageTexture = |
|
327 &(iTextureMgr->CreateZoomedTextureL(aItem,thumbNailAttribute,idspace,this))); |
|
328 |
|
329 //This is for handling the alaram interrupt events,that causes the phone to freeze. |
|
330 CEikButtonGroupContainer* cba = CEikButtonGroupContainer::Current(); |
|
331 if (NULL != cba) |
|
332 { |
|
333 if (cba->IsVisible()) |
|
334 { |
|
335 cba->ActivateL(); |
|
336 } |
|
337 } |
|
338 } |
|
339 } |
|
340 } |
|
341 // --------------------------------------------------------------------------- |
|
342 // StartZoomAnimation |
|
343 // --------------------------------------------------------------------------- |
|
344 // |
|
345 void CGlxZoomControl::StartZoomAnimation() |
|
346 { |
|
347 TRACER("CGlxZoomControl::StartZoomAnimation()"); |
|
348 iZoomIn = ETrue; |
|
349 //Set zoom visible but not enable the gesturehelper events |
|
350 iViewPort->SetOpacity(KGlxOpacityOpaque); |
|
351 TAlfTimedValue timedvalue; |
|
352 //using KGlxOpacityOpaque for the value 1 , assuming the initial zoom level as 1. |
|
353 timedvalue.SetValueNow(KGlxOpacityOpaque); |
|
354 timedvalue.SetTarget(KGlxZoomLevel,KZoomDelay/1000); |
|
355 iImageVisual->SetScale(timedvalue); |
|
356 iTimer->Cancel(); |
|
357 iTimer->Start(KZoomDelay,KZoomDelay,TCallBack( TimeOut,this )); |
|
358 } |
|
359 // --------------------------------------------------------------------------- |
|
360 // TimeOut |
|
361 // --------------------------------------------------------------------------- |
|
362 // |
|
363 TInt CGlxZoomControl::TimeOut(TAny* aSelf) |
|
364 { |
|
365 TRACER("CGlxZoomControl::TimeOut"); |
|
366 if(aSelf) |
|
367 { |
|
368 CGlxZoomControl* self = static_cast <CGlxZoomControl*> (aSelf); |
|
369 self->ActivateFullscreen(); |
|
370 } |
|
371 return KErrNone; |
|
372 } |
|
373 // --------------------------------------------------------------------------- |
|
374 // ActivateZoomAnimation |
|
375 // --------------------------------------------------------------------------- |
|
376 // |
|
377 void CGlxZoomControl::ActivateFullscreen() |
|
378 { |
|
379 TRACER("CGlxZoomControl::ActivateFullscreen"); |
|
380 if(iZoomIn) |
|
381 { |
|
382 iZoomIn = EFalse; |
|
383 TAlfTimedValue timedvalue; |
|
384 timedvalue.SetValueNow(KGlxZoomLevel); |
|
385 timedvalue.SetTarget(KGlxOpacityOpaque,KZoomDelay/1000); |
|
386 iImageVisual->SetScale(timedvalue); |
|
387 } |
|
388 else |
|
389 { |
|
390 if(iTimer->IsActive()) |
|
391 { |
|
392 iTimer->Cancel(); |
|
393 } |
|
394 //once the animation is done come back to fullscreen. |
|
395 HandleZoomOutL(KGlxZoomOutCommand); |
|
396 } |
|
397 } |
|
398 |
|
399 // ----------------------------------------------------------------------------------- |
|
400 // Deactivate:Remove the screen furniture ,cancel the timers if any |
|
401 // ---------------------------------------------------------------------------------- |
|
402 // |
|
403 EXPORT_C void CGlxZoomControl::Deactivate() |
|
404 { |
|
405 TRACER("CGlxZoomControl::Deactivate()"); |
|
406 |
|
407 if ( iZoomActive ) |
|
408 { |
|
409 if(iTimer->IsActive()) |
|
410 { |
|
411 iTimer->Cancel(); |
|
412 } |
|
413 iZoomSliderWidget.ShowWidget( EFalse, 0 ); |
|
414 iZoomSliderWidget.RemoveEventHandler(*this); |
|
415 iZoomBackKey->MakeVisible( EFalse ); |
|
416 iTextureMgr->RemoveZoomList(); |
|
417 |
|
418 iImageVisual->SetImage(*iImageTexture); |
|
419 iEventHandler->DeactivateZoom(); |
|
420 CleanUpVisual(); |
|
421 |
|
422 iZoomActive = EFalse; |
|
423 iEventHandler->SetZoomActivated(EFalse); |
|
424 } |
|
425 // Hide the Zoom View |
|
426 ShowZoom(EFalse); |
|
427 } |
|
428 |
|
429 // ----------------------------------------------------------------------------------- |
|
430 // HandleZoomForegroundEventL:Zoom Foreground event handling function |
|
431 // ---------------------------------------------------------------------------------- |
|
432 // |
|
433 EXPORT_C void CGlxZoomControl::HandleZoomForegroundEvent(TBool aForeground) |
|
434 { |
|
435 TRACER("CGlxZoomControl::HandleZoomForegroundEventL()"); |
|
436 if (!aForeground) |
|
437 { |
|
438 iEventHandler->CancelZoomPanTimer(); |
|
439 } |
|
440 } |
|
441 |
|
442 // ----------------------------------------------------------------------------- |
|
443 // CleanUpVisual:reset the values of the variables. |
|
444 // ----------------------------------------------------------------------------- |
|
445 // |
|
446 void CGlxZoomControl::CleanUpVisual() |
|
447 { |
|
448 TRACER("CGlxZoomControl::CleanUpVisual() "); |
|
449 } |
|
450 // ----------------------------------------------------------------------------- |
|
451 // Activated |
|
452 // ----------------------------------------------------------------------------- |
|
453 // |
|
454 EXPORT_C TBool CGlxZoomControl::Activated() |
|
455 { |
|
456 TRACER("CGlxZoomControl::Activated"); |
|
457 return iZoomActive; |
|
458 } |
|
459 |
|
460 // ----------------------------------------------------------------------------- |
|
461 // OfferEventL |
|
462 // ----------------------------------------------------------------------------- |
|
463 // |
|
464 TBool CGlxZoomControl::OfferEventL(const TAlfEvent &aEvent) |
|
465 { |
|
466 TRACER("CGlxZoomControl::OfferEventL()"); |
|
467 |
|
468 GLX_LOG_INFO1("OfferEventL 2: iZoomEnabled = %d ", iZoomActive ); |
|
469 // All the events related to the keys and pointers will be coming to this offerevent |
|
470 return iEventHandler->HandleEventL(aEvent) ; |
|
471 } |
|
472 |
|
473 |
|
474 // ----------------------------------------------------------------------------- |
|
475 // offerEvent |
|
476 // ----------------------------------------------------------------------------- |
|
477 // |
|
478 AlfEventStatus CGlxZoomControl::offerEvent( CAlfWidgetControl& /*aControl*/, |
|
479 const TAlfEvent& aEvent) |
|
480 { |
|
481 TRACER("CGlxZoomControl::OfferEvent( CAlfWidgetControl& /*aControl*/)"); |
|
482 // All the events which are related to slider widget will be coming |
|
483 // to this offerevent. |
|
484 AlfEventStatus eventStatus = EEventNotHandled; |
|
485 |
|
486 TBool consumed = iEventHandler->HandleEvent(aEvent); |
|
487 if ( consumed ) |
|
488 { |
|
489 eventStatus = EEventConsumed; |
|
490 } |
|
491 |
|
492 return eventStatus; |
|
493 } |
|
494 |
|
495 |
|
496 // ----------------------------------------------------------------------------- |
|
497 // TextureContentChangedL |
|
498 // ----------------------------------------------------------------------------- |
|
499 // |
|
500 void CGlxZoomControl::TextureContentChangedL( TBool /*aHasContent*/ , CAlfTexture* aNewTexture) |
|
501 { |
|
502 TRACER("CGlxZoomControl::TextureContentChangedL "); |
|
503 //if both the textures are null that means we do not have memory to |
|
504 //decode and show anything. So try and check if the fullscreen texture |
|
505 //is created by now if not then go to fullscreen view. |
|
506 |
|
507 if(aNewTexture == NULL) |
|
508 { |
|
509 if(iImageTexture == NULL) |
|
510 { |
|
511 TSize TextureSize = ScreenSize(); |
|
512 TInt focus = iMediaList.FocusIndex(); |
|
513 TGlxMedia item = iMediaList.Item( focus ); |
|
514 TGlxIdSpaceId idspace = iMediaList.IdSpaceId( focus ); |
|
515 |
|
516 CAlfTexture* newTexture = NULL; |
|
517 //Get the texture Created in fullscreen View. |
|
518 TRAPD(errtexture, newTexture = &(iTextureMgr->CreateNewTextureForMediaL( |
|
519 TextureSize,item, idspace, this ))); |
|
520 |
|
521 if(errtexture != KErrNone) |
|
522 { |
|
523 GLX_LOG_INFO( "CGlxTextureManagerImpl::HandleBitmapDecodedL::CreateNewTextureForMediaL Failed"); |
|
524 //Exit zoom and goto fullscreen |
|
525 HandleZoomOutL(KGlxZoomOutCommand); |
|
526 } |
|
527 else |
|
528 { |
|
529 //show the fullscreen texture. |
|
530 iImageTexture = newTexture; |
|
531 iImageVisual->SetImage( *iImageTexture ); |
|
532 } |
|
533 } |
|
534 else |
|
535 { |
|
536 //show the existing first level decoded image texture in case second level |
|
537 //decoding fails |
|
538 iImageVisual->SetImage( *iImageTexture ); |
|
539 } |
|
540 } |
|
541 else |
|
542 { |
|
543 iImageTexture = aNewTexture; |
|
544 iImageVisual->SetImage( *iImageTexture ); |
|
545 } |
|
546 } |
|
547 |
|
548 // ----------------------------------------------------------------------------- |
|
549 // VisualLayoutUpdated:updates the co-ordinates when phone is tilted |
|
550 // ----------------------------------------------------------------------------- |
|
551 // |
|
552 void CGlxZoomControl::VisualLayoutUpdated(CAlfVisual& aVisual) |
|
553 { |
|
554 TRACER("CGlxZoomControl::VisualLayoutUpdated "); |
|
555 // Callback comes to this function when there is a resolution change |
|
556 TRect rect; |
|
557 rect = AlfUtil::ScreenSize(); |
|
558 if ( (rect.Width() != iScreenSize.iWidth) && ( rect.Height() != iScreenSize.iHeight) && (Activated()) ) |
|
559 { |
|
560 //notify slider about Orientation Change |
|
561 iZoomSliderWidget.ContainerLayout().Owner().VisualLayoutUpdated(aVisual); |
|
562 //when the Phone is tilted,Height becomes the width and vice versa. So update with the new dimensions |
|
563 iScreenSize.iWidth = rect.Width(); |
|
564 iScreenSize.iHeight = rect.Height(); |
|
565 iDisplay->SetVisibleArea(TRect(TPoint(0,0),iScreenSize)); |
|
566 |
|
567 //[TODO]: Use the Maths engine ro arrive at this figure (virtual and viewport sizes). else there might be problems in fringe conditions |
|
568 iViewPort->SetVirtualSize(TAlfRealSize(iScreenSize.iWidth,iScreenSize.iHeight), 0); |
|
569 iViewPort->SetViewportSize(TAlfRealSize(iScreenSize.iWidth,iScreenSize.iHeight), 0); |
|
570 |
|
571 iEventHandler->OrientationChanged(rect); |
|
572 } |
|
573 } |
|
574 |
|
575 // --------------------------------------------------------------------------- |
|
576 // ShowUi |
|
577 // --------------------------------------------------------------------------- |
|
578 // |
|
579 void CGlxZoomControl::ShowUi(TBool aShow) |
|
580 { |
|
581 TRACER("CGlxZoomControl::ShowUi "); |
|
582 |
|
583 if (aShow) |
|
584 { |
|
585 iEventHandler->SetZoomUiState(EUiOn); |
|
586 } |
|
587 else |
|
588 { |
|
589 iEventHandler->SetZoomUiState(EUiOff); |
|
590 } |
|
591 |
|
592 iZoomBackKey->MakeVisible( aShow ); |
|
593 iZoomSliderWidget.ShowWidget( aShow, 0 ); |
|
594 } |
|
595 |
|
596 // --------------------------------------------------------------------------- |
|
597 // From IAlfWidgetEventHandler.. |
|
598 // --------------------------------------------------------------------------- |
|
599 // |
|
600 bool CGlxZoomControl::accept( CAlfWidgetControl& /*aControl*/, |
|
601 const TAlfEvent& /*aEvent*/) const |
|
602 { |
|
603 TRACER("CGlxZoomControl::accept "); |
|
604 return ETrue; |
|
605 } |
|
606 |
|
607 // --------------------------------------------------------------------------- |
|
608 // From IAlfWidgetEventHandler.. |
|
609 // --------------------------------------------------------------------------- |
|
610 // |
|
611 void CGlxZoomControl::setEventHandlerData( |
|
612 const AlfWidgetEventHandlerInitData& /*aData*/) |
|
613 { |
|
614 TRACER("CGlxZoomControl::setEventHandlerData "); |
|
615 } |
|
616 // --------------------------------------------------------------------------- |
|
617 // From IAlfWidgetEventHandler.. |
|
618 // --------------------------------------------------------------------------- |
|
619 // |
|
620 |
|
621 AlfWidgetEventHandlerInitData* CGlxZoomControl::eventHandlerData() |
|
622 { |
|
623 TRACER("CGlxZoomControl::eventHandlerData "); |
|
624 return NULL; |
|
625 } |
|
626 // --------------------------------------------------------------------------- |
|
627 // From IAlfWidgetEventHandler. |
|
628 // --------------------------------------------------------------------------- |
|
629 // |
|
630 |
|
631 void CGlxZoomControl::setActiveStates( unsigned int /*aStates*/ ) |
|
632 { |
|
633 TRACER("CGlxZoomControl::setActiveStates "); |
|
634 } |
|
635 // --------------------------------------------------------------------------- |
|
636 // From IAlfWidgetEventHandler. |
|
637 // --------------------------------------------------------------------------- |
|
638 // |
|
639 |
|
640 IAlfInterfaceBase* CGlxZoomControl::makeInterface( const IfId& /*aType*/ ) |
|
641 { |
|
642 TRACER("CGlxZoomControl::makeInterface Enter/Exit"); |
|
643 return NULL; |
|
644 } |
|
645 //---------------------------------------------------------------------------------- |
|
646 // eventHandlerType |
|
647 //---------------------------------------------------------------------------------- |
|
648 // |
|
649 IAlfWidgetEventHandler::AlfEventHandlerType CGlxZoomControl::eventHandlerType() |
|
650 { |
|
651 TRACER("CGlxZoomControl::eventHandlerType Enter/Exit"); |
|
652 return IAlfWidgetEventHandler::ELogicalEventHandler; |
|
653 } |
|
654 |
|
655 //---------------------------------------------------------------------------------- |
|
656 // eventExecutionPhase |
|
657 //---------------------------------------------------------------------------------- |
|
658 // |
|
659 IAlfWidgetEventHandler::AlfEventHandlerExecutionPhase CGlxZoomControl::eventExecutionPhase() |
|
660 { |
|
661 TRACER("CGlxZoomControl::eventExecutionPhase Enter/Exit"); |
|
662 return EBubblingPhaseEventHandler; |
|
663 } |
|
664 |
|
665 //---------------------------------------------------------------------------------- |
|
666 // GetOrientationL: to retreive orientation from the exif tags in the file |
|
667 //---------------------------------------------------------------------------------- |
|
668 // |
|
669 TUint16 CGlxZoomControl::GetOrientationL(const TDesC& aFileName) |
|
670 { |
|
671 TRACER("CGlxZoomControl::GetOrientationL()"); |
|
672 //Get Exif Metadata and the orientation tag from the file first |
|
673 RFs fs; |
|
674 CleanupClosePushL(fs); |
|
675 User::LeaveIfError(fs.Connect()); |
|
676 |
|
677 RFile file; |
|
678 CleanupClosePushL(file); |
|
679 User::LeaveIfError(file.Open(fs, |
|
680 aFileName, EFileRead)); |
|
681 |
|
682 TInt size; |
|
683 User::LeaveIfError(file.Size(size)); |
|
684 if ( KGlxMaxExifSize < size ) |
|
685 { |
|
686 size = KGlxMaxExifSize; |
|
687 } |
|
688 TUint16 orientation = 0; |
|
689 HBufC8* exifData = HBufC8::NewLC(size); |
|
690 TPtr8 ptr(exifData->Des()); |
|
691 User::LeaveIfError(file.Read(ptr)); |
|
692 CExifRead* exifReader = NULL; |
|
693 TRAPD(exifErr,exifReader = CExifRead::NewL(*exifData, CExifRead::ENoJpeg)); |
|
694 if(exifErr == KErrNone) |
|
695 { |
|
696 CleanupStack::PushL(exifReader); |
|
697 |
|
698 TInt readErr = exifReader->GetOrientation(orientation); |
|
699 if(readErr != KErrNone) |
|
700 { |
|
701 orientation = 0; |
|
702 } |
|
703 CleanupStack::PopAndDestroy(exifReader); |
|
704 } |
|
705 CleanupStack::PopAndDestroy(exifData); |
|
706 //Close and pop file Session |
|
707 CleanupStack::PopAndDestroy(&file); |
|
708 CleanupStack::PopAndDestroy(&fs); |
|
709 return orientation; |
|
710 |
|
711 } |
|
712 |
|
713 // ----------------------------------------------------------------------------- |
|
714 // UpdateViewPort |
|
715 // ----------------------------------------------------------------------------- |
|
716 // |
|
717 void CGlxZoomControl::UpdateViewPort(TPoint& aViewPortTopLeft, |
|
718 TInt aTransitionTime, |
|
719 TSize *apViewPortDimension, |
|
720 TInt aPrimarySliderRatio) |
|
721 { |
|
722 TRACER("void CGlxZoomControl::UpdateViewPort"); |
|
723 |
|
724 iViewPort->SetViewportPos(aViewPortTopLeft,aTransitionTime); |
|
725 |
|
726 if (apViewPortDimension) |
|
727 { |
|
728 iViewPort->SetVirtualSize(*apViewPortDimension,0); |
|
729 } |
|
730 |
|
731 if(aPrimarySliderRatio >= 0) |
|
732 { |
|
733 iZoomSliderModel->SetPrimaryValue(aPrimarySliderRatio); |
|
734 } |
|
735 } |
|
736 |
|
737 // ----------------------------------------------------------------------------- |
|
738 // HandleShowUi |
|
739 // ----------------------------------------------------------------------------- |
|
740 // |
|
741 void CGlxZoomControl::HandleShowUi( TBool aShow) |
|
742 { |
|
743 TRACER("void CGlxZoomControl::HandleShowUi"); |
|
744 ShowUi(aShow); |
|
745 } |
|
746 |
|
747 |
|
748 |
|
749 // ----------------------------------------------------------------------------- |
|
750 // HandleSetViewPort |
|
751 // ----------------------------------------------------------------------------- |
|
752 // |
|
753 void CGlxZoomControl::HandleViewPortParametersChanged(TPoint& aViewPortTopLeft , |
|
754 TInt aTransitionTime , |
|
755 TSize *apViewPortDimension , |
|
756 TInt aPrimarySliderLevel ) |
|
757 { |
|
758 TRACER("void CGlxZoomControl::HandleSetViewPort"); |
|
759 UpdateViewPort(aViewPortTopLeft, aTransitionTime, apViewPortDimension, |
|
760 aPrimarySliderLevel); |
|
761 } |
|
762 |
|
763 // ----------------------------------------------------------------------------- |
|
764 // HandleZoomOut |
|
765 // ----------------------------------------------------------------------------- |
|
766 // |
|
767 void CGlxZoomControl::HandleZoomOutL(TInt aCommandId) |
|
768 { |
|
769 TRACER("void CGlxZoomControl::HandleZoomOut"); |
|
770 iCommandHandler.HandleCommandL(aCommandId, this); |
|
771 } |
|
772 |
|
773 |
|
774 // ----------------------------------------------------------------------------- |
|
775 // HandlePointerEventsL |
|
776 // ----------------------------------------------------------------------------- |
|
777 // |
|
778 TBool CGlxZoomControl::HandlePointerEventsL(const TAlfEvent &aEvent) |
|
779 { |
|
780 TRACER("void CGlxZoomControl::HandlePointerEventsL"); |
|
781 |
|
782 return iGestureHelper->OfferEventL(aEvent); |
|
783 |
|
784 } |
|
785 |
|
786 // ----------------------------------------------------------------------------- |
|
787 // HandleGestureL |
|
788 // ----------------------------------------------------------------------------- |
|
789 // |
|
790 void CGlxZoomControl::HandleGestureL( const GestureHelper::MGestureEvent& aEvent ) |
|
791 { |
|
792 TRACER("void CGlxZoomControl::HandleGestureL"); |
|
793 |
|
794 TGestureCode code = aEvent.Code(MGestureEvent::EAxisBoth); |
|
795 GLX_LOG_INFO1("_PHOTOS_LOG_: void CGlxZoomControl::HandleGestureL Code : %d", code); |
|
796 |
|
797 // Todo: This switch should go into the event handler. |
|
798 switch (code) |
|
799 { |
|
800 case EGestureDrag: |
|
801 iEventHandler->HandleDragEvent(aEvent); |
|
802 break; |
|
803 case EGestureTap: |
|
804 iEventHandler->HandleSingleTap(aEvent); |
|
805 break; |
|
806 case EGesturePinch: |
|
807 iEventHandler->HandlePinchEventL(aEvent); |
|
808 break; |
|
809 case EGestureDoubleTap: |
|
810 iEventHandler->HandleDoubleTap(aEvent); |
|
811 break; |
|
812 case EGestureReleased: |
|
813 iEventHandler->HandleGestureReleased(aEvent); |
|
814 break; |
|
815 default : |
|
816 break; |
|
817 } |
|
818 iEventHandler->SetPreviousEventCode(code); |
|
819 } |
|
820 |
|
821 TInt CGlxZoomControl::GetIntialZoomLevel(TSize& aSize ) |
|
822 { |
|
823 TRACER("CGlxZoomControl::IntialZoomLevel"); |
|
824 |
|
825 TRect rect = AlfUtil::ScreenSize(); |
|
826 TUint8 initialZoomLevel; |
|
827 |
|
828 if( rect.Width()>= aSize.iWidth && rect.Height() >= aSize.iHeight) |
|
829 { |
|
830 //if Both the Width and Height are lesser than the screen size,the initial Zoom Level will be 100 |
|
831 initialZoomLevel = KGlxMinSmallImageZoomLevel; |
|
832 } |
|
833 else |
|
834 { |
|
835 //Calculate (Display Area Width) /Image Width * 100 |
|
836 //Calculate (Display Area Height) /Image Height * 100 |
|
837 //Choose the Minimum Of the above. |
|
838 TReal32 imageWidthRatio = ((TReal32) rect.Width()/ aSize.iWidth )*100.0F; |
|
839 TReal32 imageHeightRatio = ((TReal32)rect.Height()/ aSize.iHeight )*100.0F; |
|
840 initialZoomLevel = Min(imageWidthRatio,imageHeightRatio); |
|
841 } |
|
842 return initialZoomLevel; |
|
843 } |
|
844 // ----------------------------------------------------------------------------- |
|
845 // HandleTvStatusChangedL |
|
846 // ----------------------------------------------------------------------------- |
|
847 void CGlxZoomControl::HandleTvStatusChangedL( TTvChangeType aChangeType ) |
|
848 { |
|
849 TRACER("CGlxZoomControl::HandleTvStatusChangedL()"); |
|
850 if ( aChangeType == ETvConnectionChanged ) |
|
851 { |
|
852 if ( iGlxTvOut->IsConnected() ) |
|
853 { |
|
854 //go to fullscreen. |
|
855 HandleZoomOutL(KGlxZoomOutCommand); |
|
856 } |
|
857 } |
|
858 } |
|
859 |
|
860 |
|
861 // End of File |