|
1 /* |
|
2 * Copyright (c) 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: Juha Kauppinen, Mika Hokkanen |
|
13 * |
|
14 * Description: Photo Browser |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INCLUDE FILES |
|
20 #include "ImagicContainerBrowser.h" |
|
21 #include "ImagicViewBrowser.h" |
|
22 #include "TextureLoader.h" |
|
23 |
|
24 #include <e32math.h> |
|
25 #include <e32debug.h> |
|
26 #include <BitmapTransforms.h> |
|
27 #include <e32cmn.h> |
|
28 #include <hal.h> |
|
29 #include "Imagic.hrh" |
|
30 #include "project.h" |
|
31 #include <hal.h> |
|
32 #include "DrawUtility.h" |
|
33 #include "ImagicConsts.h" |
|
34 #include <PhotoBrowser.rsg> |
|
35 |
|
36 |
|
37 const float CImagicContainerBrowser::KMinOneByOneZoom = 1; |
|
38 const float CImagicContainerBrowser::KMaxOneByOneZoom = 4.2; |
|
39 const TInt CImagicContainerBrowser::KDoubleTapZoomOneByOne1 = KMinOneByOneZoom; |
|
40 const TInt CImagicContainerBrowser::KDoubleTapZoomOneByOne2 = KMaxOneByOneZoom*0.71; |
|
41 const TReal CImagicContainerBrowser::KAngle2Start128Loading = 3; |
|
42 const TReal CImagicContainerBrowser::KAngle2Start128LoadingHwAcc = 6; |
|
43 const TInt CImagicContainerBrowser::KGridSizeY = 3; |
|
44 |
|
45 /*const*/ TInt CImagicContainerBrowser::K512TNImageBuffer = 1;//number of pictures to be loaded when using dynamic loading in grid |
|
46 const TInt CImagicContainerBrowser::K128TNImageBuffer = 8;//number of pictures to be loaded when using dynamic loading in grid |
|
47 /*const*/ TInt CImagicContainerBrowser::K32TNImageBuffer = 300;//number of pictures to be loaded when using dynamic loading in grid |
|
48 /*const*/ TInt CImagicContainerBrowser::K32TNImageUnLoadBuffer = K32TNImageBuffer*3; |
|
49 |
|
50 const TReal KLoadingImageAspectRatio = 1.23; |
|
51 const TInt KNumOf32ThumbsLoadedBefore128Thumb = 10; |
|
52 |
|
53 #ifdef ADAPTIVE_FRAMERATE |
|
54 #ifdef __WINS__ |
|
55 const TInt KDisplayDrawFreq = 20000; |
|
56 const TInt KPowerSaveDisplayDrawFreq = 20000; |
|
57 const TInt KWaitTicksAfterDraw = 0; |
|
58 #else |
|
59 const TInt KDisplayDrawFreq = 60000; |
|
60 const TInt KPowerSaveDisplayDrawFreq = 135000; |
|
61 const TInt KWaitTicksAfterDraw = 0; |
|
62 #endif |
|
63 #else |
|
64 const TInt KDisplayDrawFreq = 60000;//display update freq in micro secons, 60.000us = 16.7FPS |
|
65 const TInt KPowerSaveDisplayDrawFreq = 95000;//display update freq in micro secons, 12.5FPS |
|
66 #endif |
|
67 |
|
68 const float CImagicContainerBrowser::KSpacingX = 1.2;// Picture spacing in the grid |
|
69 const float CImagicContainerBrowser::KSpacingY = 1.15;// Picture spacing in the grid |
|
70 // Space between pictures in one by one |
|
71 const float CImagicContainerBrowser::KOneByOneSpacing=1.1; |
|
72 |
|
73 const float KFindFaceSearchRange = 0.01; |
|
74 const TInt KPowerSavePeriodicDelay = 300000;//0.3s |
|
75 const TInt KTouchDelay = 1000000;//1s. longer because it scrolls even after user action |
|
76 const TInt KPowerSavePeriodicInterval = 40000000;//0.4s |
|
77 const TReal KInitDrawZoom = 0.1; |
|
78 |
|
79 #define INT_MAX ((int)(((unsigned int)-1)>>1)) |
|
80 // macro to check if OneByOne view is zooming in. +0.01f for safety |
|
81 #define IS_NOT_IN_ZOOM_ONEBYONE ((iDrawOneByOne->GetDrawOneByOneTargetZoom()) < (KDoubleTapZoomOneByOne1 + 0.01f)) |
|
82 #define IS_ALMOST_ZERO (0.001) |
|
83 |
|
84 const float KUpdatesPerSecond = 1.0/15; |
|
85 |
|
86 //App UI Feature definition flags |
|
87 #define USE_LOW_DRAW_SPEED_WHILE_LOADING |
|
88 |
|
89 |
|
90 // Texture coordinate data |
|
91 const GLfixed CImagicContainerBrowser::iGlobalTexCoords[] = |
|
92 { |
|
93 //bitmap has to be flipped over |
|
94 0, 1<<16, |
|
95 1<<16, 1<<16, |
|
96 0, 0, |
|
97 1<<16, 0 |
|
98 }; |
|
99 |
|
100 |
|
101 |
|
102 // ================= MEMBER FUNCTIONS ======================= |
|
103 |
|
104 // --------------------------------------------------------- |
|
105 // CImagicContainerBrowser::ConstructL(const TRect& aRect) |
|
106 // EPOC two phased constructor |
|
107 // --------------------------------------------------------- |
|
108 // |
|
109 void CImagicContainerBrowser::ConstructL(CImagicAppUi* aImagicAppUi, CImagicViewBrowser* aView, const TRect& /*aRect*/) |
|
110 { |
|
111 DP0_IMAGIC(_L("CImagicContainerBrowser::ConstructL++")); |
|
112 |
|
113 iDisplayDrawFreq = KDisplayDrawFreq; |
|
114 iUserInputGiven = EFalse; |
|
115 iDeleteTextures = EFalse; |
|
116 iLastEventFromKeys = EFalse; |
|
117 |
|
118 iImagicAppUi = aImagicAppUi; |
|
119 iIEngine = iImagicAppUi->GetEngine(); |
|
120 iView = aView; |
|
121 |
|
122 iDrawGrid = CDrawGrid::NewL(this, iCurrentIndex); |
|
123 iDrawOneByOne = CDrawOneByOne::NewL(this, iCurrentIndex); |
|
124 iDrawFaceBrowsing = CDrawFaceBrowsing::NewL(this, iCurrentIndex); |
|
125 |
|
126 |
|
127 #ifdef ADAPTIVE_FRAMERATE |
|
128 iWaitDrawTicks = 0; |
|
129 #endif |
|
130 |
|
131 //iPlayedWithDrag = EFalse; |
|
132 #ifdef HOLD_SELECTION_ONDRAG |
|
133 iHoldSelection = EFalse; |
|
134 iOneByOneSlideByDrag = EFalse; |
|
135 #endif |
|
136 #ifdef MOMENTUM_MOVE |
|
137 iMomentumMove = EFalse; |
|
138 #endif |
|
139 #ifdef RD_FACEFRAME |
|
140 //iDrawFaceFrame = EFalse; |
|
141 #endif |
|
142 |
|
143 // Create the native window |
|
144 CreateWindowL(); |
|
145 // Take the whole screen into use |
|
146 SetExtentToWholeScreen(); |
|
147 |
|
148 // If the device supports touch, construct long tap detector |
|
149 if ( AknLayoutUtils::PenEnabled() ) |
|
150 { |
|
151 // Enable drag events listening |
|
152 EnableDragEvents(); |
|
153 |
|
154 #ifdef USE_AVKON_LONGTAP_DETECTOR |
|
155 // Enable long tap detection |
|
156 iLongTapDetector = CAknLongTapDetector::NewL(this); |
|
157 iLongTapDetector->SetTimeDelayBeforeAnimation(200000); // Delay before animation is set to 2 seconds in this example. Defualt is 0.15 seconds |
|
158 iLongTapDetector->SetLongTapDelay(400000); // Long tap delay is set to 5 seconds in this example. Defualt is 0.8 seconds |
|
159 #endif |
|
160 #ifdef USE_AVKON_TACTILE_FEEDBACK |
|
161 iTouchFeedBack = MTouchFeedback::Instance(); |
|
162 iTouchFeedBack->SetFeedbackEnabledForThisApp(ETrue); |
|
163 #endif |
|
164 |
|
165 iGesture = CGesture::NewL(this); |
|
166 // iGesture->SetThresholdOfTap(10); // tap must have movement with 10 pixels |
|
167 // iGesture->SetThresholdOfMovement(50); // experimental value on Ivalo |
|
168 // iGesture->SetThresholdOfFastMove(100); // fast move if > 100 pixel/100ms |
|
169 // iGesture->SetMonitoringTime(100000); // 100ms |
|
170 } |
|
171 else |
|
172 { |
|
173 #ifdef USE_AVKON_LONGTAP_DETECTOR |
|
174 iLongTapDetector = NULL; |
|
175 #endif |
|
176 iGesture = NULL; |
|
177 } |
|
178 |
|
179 //Activate view |
|
180 ActivateL(); |
|
181 |
|
182 //Create critical section |
|
183 iDrawLock.CreateLocal(); |
|
184 |
|
185 //Create an active object for animating the scene, keep priority high! |
|
186 //EPriorityIdle, EPriorityLow, EPriorityStandard, EPriorityUserInput, EPriorityHigh |
|
187 iPeriodic = CPeriodic::NewL( CActive::EPriorityUserInput); |
|
188 #ifdef USE_LOW_DRAW_SPEED_WHILE_LOADING |
|
189 iPowerSavePeriodic = CPeriodic::NewL( CActive::EPriorityUserInput);//keep this high, othervice can not quarantee that draw freq drop is getting run time |
|
190 iPowerSavePeriodic->Start(KPowerSavePeriodicDelay, KPowerSavePeriodicInterval, TCallBack( CImagicContainerBrowser::PowerSaveCallBack, this ) ); |
|
191 #endif |
|
192 |
|
193 // Initialize OpenGL |
|
194 InitAfterPowerSaveL(); |
|
195 |
|
196 //Create texture loader |
|
197 iTextureLoader = new (ELeave) CTextureLoader(iImagicAppUi, this, iView, &iDrawLock); |
|
198 iTextureLoader->ConstructL(); |
|
199 |
|
200 iTextureLoader->CreateIconTextures(); |
|
201 |
|
202 iDisplayRotation = 0;//Set initial display rotation to 0. This controls the whole display rotation, not single picture |
|
203 iDisplayRotationTarget = 0;//Set initial display rotation to 0 |
|
204 |
|
205 iDrawFunction = EGrid; |
|
206 iPreferHighResLoading = EFalse; |
|
207 iDrawGrid->InitDrawGrid(); |
|
208 |
|
209 //iSelector = CRemConInterfaceSelector::NewL(); |
|
210 //iTarget = CRemConCoreApiTarget::NewL( *iSelector, *this ); |
|
211 //iSelector->OpenTargetL(); |
|
212 |
|
213 |
|
214 //Create Draw utility class |
|
215 iDrawUtility = CDrawUtility::NewL(this); |
|
216 |
|
217 DP0_IMAGIC(_L("CImagicContainerBrowser::ConstructL--")); |
|
218 } |
|
219 |
|
220 void CImagicContainerBrowser::InitAfterPowerSaveL() |
|
221 { |
|
222 OpenGLInitL(); |
|
223 InitL(); |
|
224 |
|
225 iDrawOnes = 0; |
|
226 // Load loading icon |
|
227 iLoadingTextureIndex = 0; |
|
228 #ifdef EMPTY_IMAGE_AS_BMP |
|
229 CFbsBitmap loadingBitmap; |
|
230 TInt error = loadingBitmap.Load(KLoadingFileName); |
|
231 if (error == KErrNone) |
|
232 { |
|
233 iLoadingTextureIndex = iTextureLoader->CreateTexture(&loadingBitmap, EFalse); |
|
234 } |
|
235 #endif |
|
236 |
|
237 #if 0 |
|
238 iExitTextureIndex = 0; |
|
239 CFbsBitmap exitBitmap; |
|
240 error = exitBitmap.Load(KExitFileName); |
|
241 if (error == KErrNone) |
|
242 { |
|
243 iExitTextureIndex = iTextureLoader->CreateTexture(&exitBitmap, EFalse); |
|
244 } |
|
245 |
|
246 iMenuTextureIndex = 0; |
|
247 CFbsBitmap menuBitmap; |
|
248 error = menuBitmap.Load(KMenuFileName); |
|
249 if (error == KErrNone) |
|
250 { |
|
251 iMenuTextureIndex = iTextureLoader->CreateTexture(&menuBitmap, EFalse); |
|
252 } |
|
253 #endif |
|
254 |
|
255 #ifdef SHADOW_PHOTOS |
|
256 iShadowTextureIndex = 0; |
|
257 CFbsBitmap shadowBitmap; |
|
258 error = shadowBitmap.Load(KShadowFileName); |
|
259 if (error == KErrNone) |
|
260 { |
|
261 iShadowTextureIndex = iTextureLoader->CreateTexture(&shadowBitmap, EFalse); |
|
262 } |
|
263 #endif |
|
264 |
|
265 } |
|
266 |
|
267 void CImagicContainerBrowser::InitL() |
|
268 { |
|
269 DP0_IMAGIC(_L("CImagicContainerBrowser::GridDataInit++")); |
|
270 |
|
271 #ifdef _ACCELEROMETER_SUPPORTED_ |
|
272 //iDeviceOrientation = TSensrvOrientationData::EOrientationDisplayRightUp;//Landscape |
|
273 //iDeviceOrientation = TImagicDeviceOrientation::EOrientationDisplayRightUp;//Portrait |
|
274 //iDeviceOrientation = 3;//EOrientationDisplayRightUp = Landscape |
|
275 iDeviceOrientation = iIEngine->GetDeviceOrientation(); |
|
276 #endif |
|
277 |
|
278 DP1_IMAGIC(_L("CImagicContainerBrowser::GridDataInit - Device orientation: %d"),iDeviceOrientation); |
|
279 |
|
280 iScreenImmeadetaUpdate = EFalse; |
|
281 |
|
282 iDrawNow = EFalse; |
|
283 iDynamicLoadingOn = ETrue; |
|
284 |
|
285 iNewImageAdded = EFalse; |
|
286 iPreferHighResLoading = EFalse; |
|
287 |
|
288 if(iImagicAppUi->GetImageIndex()) |
|
289 iCurrentIndex = iImagicAppUi->GetImageIndex(); |
|
290 else |
|
291 iCurrentIndex = 0; |
|
292 |
|
293 //Read user settings from database <-------------------- |
|
294 |
|
295 //Set default draw function |
|
296 iDrawFunction = EGrid; |
|
297 |
|
298 //Init key data here |
|
299 ResetKeyData(); |
|
300 |
|
301 DP0_IMAGIC(_L("CImagicContainerBrowser::GridDataInit--")); |
|
302 } |
|
303 |
|
304 |
|
305 |
|
306 void CImagicContainerBrowser::OpenGLInitL() |
|
307 { |
|
308 DP0_IMAGIC(_L("CImagicContainerBrowser::OpenGLInit++")); |
|
309 |
|
310 // Open GL hasn't been initialized |
|
311 iOpenGlInitialized = EFalse; |
|
312 |
|
313 // Describes the format, type and size of the color buffers and |
|
314 // ancillary buffers for EGLSurface |
|
315 EGLConfig config; |
|
316 |
|
317 // Get the display for drawing graphics |
|
318 iEglDisplay = eglGetDisplay( EGL_DEFAULT_DISPLAY ); |
|
319 if ( iEglDisplay == NULL ) |
|
320 { |
|
321 DP1_IMAGIC(_L("CImagicContainerBrowser::ConstructL - eglGetDisplay failed - GL Error: %d"),glGetError()); |
|
322 _LIT(KGetDisplayFailed, "eglGetDisplay failed"); |
|
323 User::Panic( KGetDisplayFailed, 0 ); |
|
324 } |
|
325 |
|
326 // Initialize display |
|
327 if ( eglInitialize( iEglDisplay, NULL, NULL ) == EGL_FALSE ) |
|
328 { |
|
329 DP1_IMAGIC(_L("CImagicContainerBrowser::ConstructL - eglInitialize failed - GL Error: %d"),glGetError()); |
|
330 _LIT(KInitializeFailed, "eglInitialize failed"); |
|
331 User::Panic( KInitializeFailed, 0 ); |
|
332 } |
|
333 |
|
334 // Pointer for EGLConfigs |
|
335 EGLConfig *configList = NULL; |
|
336 EGLint numOfConfigs = 0; |
|
337 EGLint configSize = 0; |
|
338 |
|
339 // Get the number of possible EGLConfigs |
|
340 if ( eglGetConfigs( iEglDisplay, configList, configSize, &numOfConfigs ) == EGL_FALSE ) |
|
341 { |
|
342 DP1_IMAGIC(_L("CImagicContainerBrowser::ConstructL - eglGetConfigs failed - GL Error: %d"),glGetError()); |
|
343 _LIT(KGetConfigsFailed, "eglGetConfigs failed"); |
|
344 User::Panic( KGetConfigsFailed, 0 ); |
|
345 } |
|
346 |
|
347 configSize = numOfConfigs; |
|
348 |
|
349 // Allocate memory for the configList |
|
350 configList = (EGLConfig*) User::Alloc( sizeof(EGLConfig)*configSize ); |
|
351 if ( configList == NULL ) |
|
352 { |
|
353 DP1_IMAGIC(_L("CImagicContainerBrowser::ConstructL - config alloc failed - GL Error: %d"),glGetError()); |
|
354 _LIT(KConfigAllocFailed, "config alloc failed"); |
|
355 User::Panic( KConfigAllocFailed, 0 ); |
|
356 } |
|
357 |
|
358 // Define properties for the wanted EGLSurface. To get the best possible |
|
359 // performance, choose an EGLConfig with a buffersize matching the current |
|
360 // window's display mode |
|
361 TDisplayMode DMode = Window().DisplayMode(); |
|
362 TInt BufferSize = 0; |
|
363 |
|
364 switch(DMode) |
|
365 { |
|
366 case(EColor4K): |
|
367 BufferSize = 12; |
|
368 break; |
|
369 case(EColor64K): |
|
370 BufferSize = 16; |
|
371 break; |
|
372 case(EColor16M): |
|
373 BufferSize = 24; |
|
374 break; |
|
375 case(EColor16MU): |
|
376 case(EColor16MA): |
|
377 BufferSize = 32; |
|
378 break; |
|
379 default: |
|
380 DP1_IMAGIC(_L("CImagicContainerBrowser::ConstructL - unsupported displaymode - GL Error: %d"),glGetError()); |
|
381 _LIT(KDModeError, "unsupported displaymode"); |
|
382 User::Panic( KDModeError, 0 ); |
|
383 break; |
|
384 } |
|
385 |
|
386 // Define properties for the wanted EGLSurface |
|
387 const EGLint attrib_list[] = |
|
388 { |
|
389 EGL_SURFACE_TYPE, EGL_WINDOW_BIT, |
|
390 EGL_BUFFER_SIZE, BufferSize, |
|
391 EGL_DEPTH_SIZE, 16, |
|
392 EGL_NONE |
|
393 }; |
|
394 |
|
395 |
|
396 // No configs with antialising were found. Try to get the non-antialiased config |
|
397 if ( eglChooseConfig( iEglDisplay, attrib_list, configList, configSize, &numOfConfigs ) == EGL_FALSE ) |
|
398 { |
|
399 DP1_IMAGIC(_L("CImagicContainerBrowser::ConstructL - eglChooseConfig failed - GL Error: %d"),glGetError()); |
|
400 _LIT( KChooseConfigFailed, "eglChooseConfig failed" ); |
|
401 User::Panic( KChooseConfigFailed, 0 ); |
|
402 } |
|
403 |
|
404 if ( numOfConfigs == 0 ) |
|
405 { |
|
406 DP1_IMAGIC(_L("CImagicContainerBrowser::ConstructL - Can't find the requested config. - GL Error: %d"),glGetError()); |
|
407 // No configs found without antialiasing |
|
408 _LIT( KNoConfig, "Can't find the requested config." ); |
|
409 User::Panic( KNoConfig, 0 ); |
|
410 } |
|
411 |
|
412 // Choose the best EGLConfig. EGLConfigs returned by eglChooseConfig are |
|
413 // sorted so that the best matching EGLConfig is first in the list. |
|
414 config = configList[0]; |
|
415 |
|
416 // Free configList, as it's not used anymore. |
|
417 User::Free( configList ); |
|
418 |
|
419 // Create a window where the graphics are blitted |
|
420 iEglSurface = eglCreateWindowSurface( iEglDisplay, config, &Window(), NULL ); |
|
421 if ( iEglSurface == NULL ) |
|
422 { |
|
423 DP1_IMAGIC(_L("CImagicContainerBrowser::ConstructL - eglCreateWindowSurface failed - GL Error: %d"),glGetError()); |
|
424 _LIT(KCreateWindowSurfaceFailed, "eglCreateWindowSurface failed"); |
|
425 User::Panic( KCreateWindowSurfaceFailed, 0 ); |
|
426 } |
|
427 |
|
428 // Create a rendering context |
|
429 iEglContext = eglCreateContext( iEglDisplay, config, EGL_NO_CONTEXT, NULL ); |
|
430 if ( iEglContext == NULL ) |
|
431 { |
|
432 DP1_IMAGIC(_L("CImagicContainerBrowser::ConstructL - eglCreateContext failed - GL Error: %d"),glGetError()); |
|
433 _LIT(KCreateContextFailed, "eglCreateContext failed"); |
|
434 User::Panic( KCreateContextFailed, 0 ); |
|
435 } |
|
436 |
|
437 // Make the context current. Binds context to the current rendering thread |
|
438 // and surface. |
|
439 if ( eglMakeCurrent( iEglDisplay, iEglSurface, iEglSurface, iEglContext ) == EGL_FALSE ) |
|
440 { |
|
441 DP1_IMAGIC(_L("CImagicContainerBrowser::ConstructL - eglMakeCurrent failed - GL Error: %d"),glGetError()); |
|
442 _LIT(KMakeCurrentFailed, "eglMakeCurrent failed"); |
|
443 User::Panic( KMakeCurrentFailed, 0 ); |
|
444 } |
|
445 |
|
446 #ifdef SHADOW_PHOTOS |
|
447 glClearColor(1,1,1, 0); |
|
448 #else |
|
449 glClearColor(0,0,0, 0); |
|
450 #endif |
|
451 //glClearDepth(1.0f); // Depth Buffer Setup |
|
452 glEnable(GL_DEPTH_TEST); // Enables Depth Testing |
|
453 //glDisable(GL_DEPTH_TEST); // Enables Depth Testing |
|
454 //glDepthMask(GL_FALSE); |
|
455 glDepthFunc(GL_LEQUAL); // The Type Of Depth Testing To Do |
|
456 // TODO, check the perf gain |
|
457 //glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST); // Really Nice Perspective Calculations |
|
458 glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_FASTEST); // Fast Perspective Calculations |
|
459 glShadeModel(GL_FLAT);//GL_FLAT ,GL_SMOOTH TODO, check perf if smooth is on |
|
460 //glShadeModel(GL_SMOOTH);//GL_FLAT ,GL_SMOOTH TODO, check perf if smooth is on |
|
461 //glDisable( GL_LINE_SMOOTH ); |
|
462 //glEnable with the arguments GL_LINE_SMOOTH or GL_POINT_SMOOTH. |
|
463 //glEnable(GL_POLYGON_SMOOTH); |
|
464 //glEnable(GL_POINT_SMOOTH); |
|
465 //glEnable( GL_LINE_SMOOTH ); |
|
466 //glEnable(GL_MULTISAMPLE_ARB); |
|
467 glEnable( GL_TEXTURE_2D ); |
|
468 glDisable( GL_LIGHTING );//disable for performance reasons |
|
469 //Disable alpha blending |
|
470 glDisable(GL_BLEND); |
|
471 glDisable(GL_ALPHA_TEST); |
|
472 |
|
473 |
|
474 //GLint params; |
|
475 glGetIntegerv( GL_MAX_TEXTURE_SIZE, &iGLMaxRes ); |
|
476 DP1_IMAGIC(_L("CImagicContainerBrowser::OpenGLInit - OpenGL max image Res size: %d"), iGLMaxRes); |
|
477 |
|
478 glMatrixMode( GL_MODELVIEW ); |
|
479 |
|
480 |
|
481 iOpenGlInitialized = ETrue; |
|
482 |
|
483 //Start draw timer |
|
484 DP0_IMAGIC(_L("CImagicContainerBrowser::OpenGLInit - Start Draw timer")); |
|
485 iPeriodic->Start( 100, KDisplayDrawFreq, TCallBack( CImagicContainerBrowser::DrawCallBackL, this ) ); |
|
486 |
|
487 DP0_IMAGIC(_L("CImagicContainerBrowser::OpenGLInit--")); |
|
488 } |
|
489 |
|
490 //This is called when we want to reduce screen drawing |
|
491 TInt CImagicContainerBrowser::PowerSaveCallBack(TAny *aInstance) |
|
492 { |
|
493 DP0_IMAGIC(_L("CImagicContainerBrowser::PowerSaveCallBack++")); |
|
494 |
|
495 ((CImagicContainerBrowser*) aInstance)->PowerSave(); |
|
496 |
|
497 DP0_IMAGIC(_L("CImagicContainerBrowser::PowerSaveCallBack--")); |
|
498 return 0; |
|
499 } |
|
500 |
|
501 |
|
502 void CImagicContainerBrowser::PowerSave() |
|
503 { |
|
504 iPowerSavePeriodic->Cancel(); |
|
505 |
|
506 if(iDisplayDrawFreq == KDisplayDrawFreq) |
|
507 { |
|
508 #ifndef ADAPTIVE_FRAMERATE |
|
509 iDisplayDrawFreq = KPowerSaveDisplayDrawFreq; |
|
510 DisableDisplayDraw(); |
|
511 if(iImagicAppUi->IsAppOnTop()) |
|
512 EnableDisplayDraw(); |
|
513 #endif |
|
514 } |
|
515 } |
|
516 |
|
517 TInt CImagicContainerBrowser::DisableDrawTimer( TAny* aInstance ) |
|
518 { |
|
519 DP0_IMAGIC(_L("CImagicContainerBrowser::DisableDrawTimer++")); |
|
520 |
|
521 // Get pointer to instance |
|
522 CImagicContainerBrowser* instance = (CImagicContainerBrowser*) aInstance; |
|
523 //instance->iPeriodicTimerActive = EFalse; |
|
524 instance->DisableDisplayDraw(); |
|
525 |
|
526 DP0_IMAGIC(_L("CImagicContainerBrowser::DisableDrawTimer--")); |
|
527 return 0; |
|
528 } |
|
529 |
|
530 /*----------------------------------------------------------------------*/ |
|
531 // Destructor |
|
532 CImagicContainerBrowser::~CImagicContainerBrowser() |
|
533 { |
|
534 DP0_IMAGIC(_L("CImagicContainerBrowser::~CImagicContainerBrowser++")); |
|
535 |
|
536 //delete iPeriodic; |
|
537 if(iPeriodic) |
|
538 { |
|
539 if(iPeriodic->IsActive()) |
|
540 iPeriodic->Cancel(); |
|
541 |
|
542 delete iPeriodic; |
|
543 iPeriodic = NULL; |
|
544 } |
|
545 |
|
546 delete iDrawUtility; |
|
547 |
|
548 //Cancelling CTimer... |
|
549 if(iPowerSavePeriodic) |
|
550 { |
|
551 if(iPowerSavePeriodic->IsActive()) |
|
552 iPowerSavePeriodic->Cancel(); |
|
553 |
|
554 delete iPowerSavePeriodic; |
|
555 iPowerSavePeriodic = NULL; |
|
556 } |
|
557 |
|
558 DeleteTextures(); |
|
559 iDrawLock.Close(); |
|
560 |
|
561 if(iTextureLoader) |
|
562 { |
|
563 delete iTextureLoader; |
|
564 iTextureLoader = NULL; |
|
565 } |
|
566 |
|
567 //iFloatCoordinates.Close(); |
|
568 |
|
569 #ifdef USE_AVKON_LONGTAP_DETECTOR |
|
570 if(iLongTapDetector) |
|
571 { |
|
572 delete iLongTapDetector; |
|
573 iLongTapDetector = NULL; |
|
574 } |
|
575 #endif |
|
576 |
|
577 if(iGesture) |
|
578 { |
|
579 delete iGesture; |
|
580 iGesture = NULL; |
|
581 } |
|
582 |
|
583 //Destruct all engine components |
|
584 iImagicAppUi->DestructEngine(); |
|
585 |
|
586 delete iDrawGrid; |
|
587 delete iDrawOneByOne; |
|
588 delete iDrawFaceBrowsing; |
|
589 |
|
590 DP0_IMAGIC(_L("CImagicContainerBrowser::~CImagicContainerBrowser--")); |
|
591 } |
|
592 |
|
593 /*----------------------------------------------------------------------*/ |
|
594 // CTextureManager::DeleteTextures |
|
595 // Deletes named textures by calling glDeleteTextures. |
|
596 // |
|
597 void CImagicContainerBrowser::DeleteTextures() |
|
598 { |
|
599 DP0_IMAGIC(_L("CImagicContainerBrowser::DeleteTextures++")); |
|
600 |
|
601 iIEngine->CancelFullSizeLoading(); |
|
602 |
|
603 if(iPeriodic && iPeriodic->IsActive()) |
|
604 iPeriodic->Cancel(); |
|
605 |
|
606 eglMakeCurrent( iEglDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT ); |
|
607 eglDestroySurface( iEglDisplay, iEglSurface ); |
|
608 eglDestroyContext( iEglDisplay, iEglContext ); |
|
609 eglTerminate( iEglDisplay ); |
|
610 |
|
611 //Delete OpenGL memory allocations |
|
612 TInt num = iIEngine->GetTotalNumOfImages(); |
|
613 for(TInt i=0; i < num; i++ ) |
|
614 { |
|
615 CImageData* data = iIEngine->GetImageData(i); |
|
616 |
|
617 if(data->iGridData.iGlLQ128TextIndex) |
|
618 glDeleteTextures( 1, &data->iGridData.iGlLQ128TextIndex ); |
|
619 if(data->iGridData.iGlLQ32TextIndex) |
|
620 glDeleteTextures( 1, &data->iGridData.iGlLQ32TextIndex ); |
|
621 if(data->iGridData.iGlHQ512TextIndex != 0) |
|
622 glDeleteTextures(1, &data->iGridData.iGlHQ512TextIndex); |
|
623 if(data->iGridData.iGlSuperHQTextIndex != 0) |
|
624 glDeleteTextures(1, &data->iGridData.iGlSuperHQTextIndex); |
|
625 |
|
626 data->iGridData.iGlLQ32TextIndex = 0; |
|
627 data->iGridData.iGlLQ128TextIndex = 0; |
|
628 data->iGridData.iGlHQ512TextIndex = 0; |
|
629 data->iGridData.iGlSuperHQTextIndex = 0; |
|
630 } |
|
631 |
|
632 iOpenGlInitialized = EFalse; |
|
633 |
|
634 DP0_IMAGIC(_L("CImagicContainerBrowser::DeleteTextures--")); |
|
635 } |
|
636 |
|
637 /* |
|
638 //Prepares container to filename array swap |
|
639 void CImagicContainerBrowser::SwapArrays() |
|
640 { |
|
641 DP0_IMAGIC(_L("CImagicContainerBrowser::SwapArrays++")); |
|
642 |
|
643 //Delete OpenGL memory allocations |
|
644 TInt num = iIEngine->GetTotalNumOfImages(); |
|
645 for(TInt i=0; i < num; i++ ) |
|
646 { |
|
647 CImageData* data = iIEngine->GetImageData(i); |
|
648 |
|
649 if(data->iGridData.iGlLQ128TextIndex) |
|
650 glDeleteTextures( 1, &data->iGridData.iGlLQ128TextIndex ); |
|
651 if(data->iGridData.iGlLQ32TextIndex) |
|
652 glDeleteTextures( 1, &data->iGridData.iGlLQ32TextIndex ); |
|
653 if(data->iGridData.iGlHQ512TextIndex != 0) |
|
654 glDeleteTextures(1, &data->iGridData.iGlHQ512TextIndex); |
|
655 if(data->iGridData.iGlSuperHQTextIndex != 0) |
|
656 glDeleteTextures(1, &data->iGridData.iGlSuperHQTextIndex); |
|
657 |
|
658 data->iGridData.iGlLQ32TextIndex = 0; |
|
659 data->iGridData.iGlLQ128TextIndex = 0; |
|
660 data->iGridData.iGlHQ512TextIndex = 0; |
|
661 data->iGridData.iGlSuperHQTextIndex = 0; |
|
662 } |
|
663 |
|
664 iOpenGlInitialized = EFalse; |
|
665 |
|
666 DP0_IMAGIC(_L("CImagicContainerBrowser::SwapArrays--")); |
|
667 } |
|
668 */ |
|
669 |
|
670 void CImagicContainerBrowser::InitFaceBrowsing() |
|
671 { |
|
672 iDrawFaceBrowsing->InitFaceBrowsing(); |
|
673 } |
|
674 |
|
675 |
|
676 /*----------------------------------------------------------------------*/ |
|
677 // Interpolates given value into target value with step |
|
678 // |
|
679 void CImagicContainerBrowser::Interpolate(float &aValue, const float aTarget, const float aStep) |
|
680 { |
|
681 //DP0_IMAGIC(_L("CImagicContainerBrowser::Interpolate")); |
|
682 // Calculate new value |
|
683 float diff = aTarget-aValue; |
|
684 // aValue += diff * aStep * iTimeDiff * 30; |
|
685 float timediff = Min(0.1f, iTimeDiff); // so max value of timediff is 100tick (100ms) |
|
686 aValue += diff * aStep * timediff * 30; |
|
687 |
|
688 // Check that value is in range |
|
689 if (aValue > aTarget && diff > 0) |
|
690 aValue = aTarget; |
|
691 if (aValue < aTarget && diff < 0) |
|
692 aValue = aTarget; |
|
693 } |
|
694 |
|
695 /*----------------------------------------------------------------------*/ |
|
696 // Makes sure that given value is within limits |
|
697 // |
|
698 void CImagicContainerBrowser::CheckLimits(float &aValue, const float aMin, const float aMax) |
|
699 { |
|
700 DP0_IMAGIC(_L("CImagicContainerBrowser::CheckLimits")); |
|
701 if (aValue < aMin) |
|
702 aValue = aMin; |
|
703 if (aValue > aMax) |
|
704 aValue = aMax; |
|
705 } |
|
706 |
|
707 /*----------------------------------------------------------------------*/ |
|
708 // Handle rotation keys |
|
709 // |
|
710 void CImagicContainerBrowser::HandleRotationKeys(void) |
|
711 { |
|
712 //DP0_IMAGIC(_L("CImagicContainerBrowser::HandleRotationKeys")); |
|
713 // Handle rotation |
|
714 CImageData* imageData = iIEngine->GetImageData(iCurrentIndex); |
|
715 if(imageData) |
|
716 imageData->iGridData.iTargetRotationAngle += iKeyData.iRotate*90; |
|
717 iKeyData.iRotate = 0; |
|
718 } |
|
719 |
|
720 |
|
721 TInt CImagicContainerBrowser::GetFreeRam() |
|
722 { |
|
723 TInt mem = 0; |
|
724 TInt ret = HAL::Get(HALData::EMemoryRAMFree, mem); |
|
725 DP1_IMAGIC(_L("CImagicContainerBrowser::CheckFreeRam - mem: %d"),mem); |
|
726 return mem; |
|
727 } |
|
728 |
|
729 |
|
730 |
|
731 /*----------------------------------------------------------------------*/ |
|
732 // Checks limits for iFileIndex and starts loading image when |
|
733 // new image was selected |
|
734 // |
|
735 void CImagicContainerBrowser::DynamicLoadingL() |
|
736 { |
|
737 if(!iDynamicLoadingOn && !iNewImageAdded) |
|
738 { |
|
739 DP2_IMAGIC(_L("CImagicContainerBrowser::DynamicLoadingL - return #Loading is off, iDynamicLoadingOn:%d, iNewImageAdded:%d"),iDynamicLoadingOn,iNewImageAdded); |
|
740 return; |
|
741 } |
|
742 |
|
743 // Check that loader is not running |
|
744 if(iTextureLoader->IsRunning()) |
|
745 { |
|
746 DP0_IMAGIC(_L("CImagicContainerBrowser::DynamicLoadingL - return #Loader is running")); |
|
747 |
|
748 /* if(iIsLoaderRunning > 30) |
|
749 { |
|
750 DP0_IMAGIC(_L("CImagicContainerBrowser::DynamicLoadingL - return #Loader is running >30 times in loop")); |
|
751 iIsLoaderRunning = 0; |
|
752 iDynamicLoadingOn = EFalse; |
|
753 iNewImageAdded = EFalse; |
|
754 } |
|
755 |
|
756 iIsLoaderRunning++;*/ |
|
757 |
|
758 return; |
|
759 } |
|
760 |
|
761 if(iPreferHighResLoading) |
|
762 { |
|
763 DP0_IMAGIC(_L("CImagicContainerBrowser::DynamicLoadingL - return #Prefer High res loading")); |
|
764 return; |
|
765 } |
|
766 |
|
767 DP0_IMAGIC(_L("CImagicContainerBrowser::DynamicLoadingL++")); |
|
768 |
|
769 /*TInt imageBuffer = iIEngine->IsScanningFiles() ? |
|
770 K128TNImageBuffer + KNumOf32ThumbsLoadedBefore128Thumb : |
|
771 K32TNImageBuffer;*/ |
|
772 |
|
773 TInt imageBuffer = K32TNImageBuffer; |
|
774 |
|
775 //DP0_IMAGIC(_L("CImagicContainerBrowser::DynamicLoadingL load closest unloaded image")); |
|
776 |
|
777 for (TInt i = 0;i < imageBuffer; i++) |
|
778 { |
|
779 // Check to positive and negative direction from current picture |
|
780 for (TInt j = 0; j < 2; j++) |
|
781 { |
|
782 // Calculate image index |
|
783 TInt index = iCurrentIndex + (j ? i : -i); |
|
784 |
|
785 // Check that index is valid |
|
786 if (index >= 0 && index < iIEngine->GetTotalNumOfImages()) |
|
787 { |
|
788 CImageData* imageData = iIEngine->GetImageData(index); |
|
789 // Load tiny thumbnail |
|
790 if( !imageData->iGridData.iCorrupted && |
|
791 imageData->iGridData.iGlLQ32TextIndex == 0 && |
|
792 (imageData->IsImageReady(ESize32x32) || |
|
793 imageData->IsImageReady(EExifThumb)) //&& |
|
794 //Abs(iCurrentIndex-index) <= K32TNImageBuffer |
|
795 ) |
|
796 { |
|
797 TRAPD(err, iTextureLoader->LoadL(imageData, ESize32x32)); |
|
798 if(err == KErrNone) |
|
799 { |
|
800 DP0_IMAGIC(_L("CImagicContainerBrowser::DynamicLoadingL - start loading 32x32")); |
|
801 i = imageBuffer + 1; |
|
802 iNewImageAdded = EFalse;//should be set off only when we tried to load new image |
|
803 break; //Image loading did start, break out |
|
804 } |
|
805 } |
|
806 } |
|
807 |
|
808 // Load higher resolution thumb only after couple of tiny thumbs |
|
809 TInt i2 = i - KNumOf32ThumbsLoadedBefore128Thumb; |
|
810 if (i2 < 0) |
|
811 continue; |
|
812 |
|
813 // Calculate image index |
|
814 index = iCurrentIndex + (j ? i2 : -i2); |
|
815 |
|
816 // Check that index is valid |
|
817 if (index < 0 || index >= iIEngine->GetTotalNumOfImages()) |
|
818 continue; |
|
819 |
|
820 CImageData* imageData = iIEngine->GetImageData(index); |
|
821 // Higher resolution thumbnail exist |
|
822 if(!imageData->iGridData.iCorrupted && |
|
823 imageData->iGridData.iGlLQ128TextIndex == 0 && |
|
824 (imageData->IsImageReady(ESize128x128) || |
|
825 imageData->IsImageReady(EExifThumb)) && |
|
826 Abs(iCurrentIndex-index) <= K128TNImageBuffer) |
|
827 { |
|
828 //Do not load 128 TN before tilted to flat |
|
829 if(IsHwAcceleration() && Abs(iDrawGrid->GetCurrentGridTilt()) < KAngle2Start128LoadingHwAcc) |
|
830 { |
|
831 TRAPD(err, iTextureLoader->LoadL(imageData, ESize128x128)); |
|
832 if(err == KErrNone) |
|
833 { |
|
834 DP0_IMAGIC(_L("CImagicContainerBrowser::DynamicLoadingL - start loading 128x128")); |
|
835 i = imageBuffer + 1; |
|
836 iNewImageAdded = EFalse;//should be set off only when we tried to load new image |
|
837 break; //Image loading did start, break out |
|
838 } |
|
839 } |
|
840 if(!IsHwAcceleration() && Abs(iDrawGrid->GetCurrentGridTilt()) < KAngle2Start128Loading) |
|
841 { |
|
842 TRAPD(err, iTextureLoader->LoadL(imageData, ESize128x128)); |
|
843 if(err == KErrNone) |
|
844 { |
|
845 DP0_IMAGIC(_L("CImagicContainerBrowser::DynamicLoadingL - start loading 128x128")); |
|
846 i = imageBuffer + 1; |
|
847 iNewImageAdded = EFalse;//should be set off only when we tried to load new image |
|
848 break; //Image loading did start, break out |
|
849 } |
|
850 } |
|
851 } |
|
852 } |
|
853 } |
|
854 |
|
855 iNewImageAdded = EFalse; |
|
856 |
|
857 // Wait until something new happen before continue loading |
|
858 iDynamicLoadingOn = iIEngine->IsScanningFiles(); |
|
859 |
|
860 DP0_IMAGIC(_L("CImagicContainerBrowser::DynamicLoadingL--")); |
|
861 } |
|
862 |
|
863 void CImagicContainerBrowser::NewImageAdded() |
|
864 { |
|
865 iNewImageAdded = ETrue; |
|
866 } |
|
867 |
|
868 void CImagicContainerBrowser::ImageListChanged(TInt aIndex, TBool aAdded) |
|
869 { |
|
870 if (iDrawGrid) |
|
871 iDrawGrid->UpdateImageCoordinates(aIndex); |
|
872 |
|
873 if (IsUserInputGiven()) |
|
874 { |
|
875 /* TODO if (iCurrentIndex >= aIndex) |
|
876 { |
|
877 if (aAdded) |
|
878 iCurrentIndex++; |
|
879 else |
|
880 iCurrentIndex--; |
|
881 CheckIndexLimits(iCurrentIndex); |
|
882 }*/ |
|
883 } |
|
884 iDynamicLoadingOn = ETrue; |
|
885 } |
|
886 |
|
887 /*----------------------------------------------------------------------*/ |
|
888 // Unloads images from Grid |
|
889 // |
|
890 void CImagicContainerBrowser::DynamicUnLoading() |
|
891 { |
|
892 DP0_IMAGIC(_L("CImagicContainerBrowser::DynamicUnLoading++")); |
|
893 |
|
894 CImageData* imageData = NULL; |
|
895 |
|
896 // Loop through all pictures |
|
897 for (TInt i=0; i<iIEngine->GetTotalNumOfImages(); i++) |
|
898 { |
|
899 // Check if picture is loaded |
|
900 imageData = iIEngine->GetImageData(i); |
|
901 |
|
902 if(imageData->iGridData.iGlLQ32TextIndex!=0) |
|
903 if(i<(iCurrentIndex-(K32TNImageUnLoadBuffer+1)) || i>(iCurrentIndex+(K32TNImageUnLoadBuffer+1))) |
|
904 { |
|
905 // Unload picture |
|
906 iTextureLoader->UnloadLQ32Tex( imageData ); |
|
907 DP1_IMAGIC(_L("CImagicContainerBrowser::DynamicUnLoading - Unload 32x32 [%d] texture!!!!!"),i); |
|
908 } |
|
909 if(imageData->iGridData.iGlLQ128TextIndex != 0) |
|
910 if(i<(iCurrentIndex-(K128TNImageBuffer+1)) || i>(iCurrentIndex+(K128TNImageBuffer+1))) |
|
911 { |
|
912 // Unload picture |
|
913 iTextureLoader->UnloadLQ128Tex( imageData ); |
|
914 DP1_IMAGIC(_L("CImagicContainerBrowser::DynamicUnLoading - Unload 128x128 [%d] texture!!!!!"),i); |
|
915 } |
|
916 if(imageData->iGridData.iGlHQ512TextIndex != 0 ) |
|
917 if((i < (iCurrentIndex-(K512TNImageBuffer+1))) || (i > (iCurrentIndex+(K512TNImageBuffer+1)))) |
|
918 { |
|
919 //Unload picture |
|
920 iTextureLoader->UnloadLQ512Tex( imageData ); |
|
921 DP1_IMAGIC(_L("CImagicContainerBrowser::DynamicUnLoading - Unload 512x512 [%d] texture!!!!!"),i); |
|
922 } |
|
923 |
|
924 if(imageData->iGridData.iGlSuperHQTextIndex != 0) |
|
925 if(i != iCurrentIndex) |
|
926 { |
|
927 //Unload picture |
|
928 iTextureLoader->ReleaseSuperHResTexture( imageData ); |
|
929 DP1_IMAGIC(_L("CImagicContainerBrowser::DynamicUnLoading - Unload Superresolution [%d] texture!!!!!"),i); |
|
930 } |
|
931 } |
|
932 |
|
933 DP0_IMAGIC(_L("CImagicContainerBrowser::DynamicUnLoading--")); |
|
934 } |
|
935 |
|
936 |
|
937 /*----------------------------------------------------------------------*/ |
|
938 // Calculates widht and height with aspect ratio |
|
939 // |
|
940 #if 0 |
|
941 void CImagicContainerBrowser::BubbleEffect(TInt& x, TInt& y, float& z) |
|
942 { |
|
943 if(iBubbleEffect) |
|
944 { |
|
945 // Selected image in coordinates x,y |
|
946 iSelectedX = iCurrentIndex/iGridSizeY; |
|
947 iSelectedY =- (iCurrentIndex%iGridSizeY); |
|
948 |
|
949 // Distance to selected |
|
950 iDistanceX = iSelectedX-x; |
|
951 iDistanceY = iSelectedY-y; |
|
952 // Squared |
|
953 if(iDistanceX<0) iDistanceX*= -1; |
|
954 if(iDistanceY<0) iDistanceY*= -1; |
|
955 |
|
956 // Distance |
|
957 iDiff=iDistanceX+iDistanceY; |
|
958 // Convert distance to depth |
|
959 // http://en.wikipedia.org/wiki/Gaussian_function |
|
960 /* |
|
961 if (iDiff==0) z=4.2; |
|
962 if (iDiff==1) z=3.973029769; |
|
963 if (iDiff==2) z=3.363097092; |
|
964 if (iDiff==3) z=2.547428771; |
|
965 if (iDiff==4) z=1.72667162; |
|
966 if (iDiff==5) z=1.047279277; |
|
967 if (iDiff==6) z=0.56840819; |
|
968 if (iDiff==7) z=0.27605982; |
|
969 if (iDiff==8) z=0.119975103; |
|
970 if (iDiff==9) z=0.046657785; |
|
971 if (iDiff==10) z=0.016236865; |
|
972 if (iDiff>10) z=0; |
|
973 */ |
|
974 if (iDiff==0) z=5.0; |
|
975 if (iDiff==1) z=4.2; |
|
976 if (iDiff==2) z=3.4; |
|
977 if (iDiff==3) z=2.1; |
|
978 if (iDiff==4) z=1.3; |
|
979 if (iDiff==5) z=0.8; |
|
980 if (iDiff==6) z=0.4; |
|
981 if (iDiff==7) z=0.3; |
|
982 if (iDiff>7) z=0.3; |
|
983 //if (iDiff==8) z=0.1; |
|
984 //if (iDiff==9) z=0.05; |
|
985 //if (iDiff==10) z=0.01; |
|
986 //if (iDiff>10) z=0; |
|
987 } |
|
988 } |
|
989 #endif |
|
990 |
|
991 /*----------------------------------------------------------------------*/ |
|
992 // Calculates widht and height with aspect ratio |
|
993 // |
|
994 void CImagicContainerBrowser::CalculateImageSize(float& aWidth, float& aHeight, const float aAspectRatio/*display aspectratio*/) |
|
995 { |
|
996 DP0_IMAGIC(_L("CImagicContainerBrowser::CalculateImageSize")); |
|
997 // Check picture orientation |
|
998 TBool landscape = EFalse; |
|
999 TBool tmp = EFalse; |
|
1000 CImageData* imageData = iIEngine->GetImageData(iCurrentIndex); |
|
1001 |
|
1002 if(imageData->GetAspectRatio() > 1) |
|
1003 landscape = ETrue; |
|
1004 |
|
1005 //Change landscape<->portrait if pic is rotated 90 or 270 |
|
1006 //if(imageData->iGridData.iTargetRotationAngle%90==0 && imageData->iGridData.iTargetRotationAngle%180!=0) |
|
1007 //if(Abs(imageData->iGridData.iTargetRotationAngle-90) <= 0.1 && Abs(imageData->iGridData.iTargetRotationAngle-270) <= 0.1) |
|
1008 TInt angle = imageData->iGridData.iTargetRotationAngle; |
|
1009 if(angle % 90 == 0 && angle % 180 != 0) |
|
1010 { |
|
1011 tmp=ETrue; |
|
1012 landscape = !landscape; |
|
1013 } |
|
1014 |
|
1015 //Calculate new width and height |
|
1016 aWidth=0.5; |
|
1017 aHeight=0.5; |
|
1018 |
|
1019 if(landscape) |
|
1020 { |
|
1021 //Fix aspect ratio |
|
1022 aHeight/=aAspectRatio; |
|
1023 if(imageData->GetAspectRatio() < aAspectRatio && imageData->GetAspectRatio() >= 1) |
|
1024 { |
|
1025 aHeight = aHeight * (aAspectRatio/imageData->GetAspectRatio()); |
|
1026 aWidth = aWidth * (aAspectRatio/imageData->GetAspectRatio()); |
|
1027 } |
|
1028 //If portrait picture aspect ratio is between 0.75 - 1 |
|
1029 if(imageData->GetAspectRatio() > (1.0 / aAspectRatio) && imageData->GetAspectRatio() < 1) |
|
1030 { |
|
1031 aHeight = aHeight * (aAspectRatio*imageData->GetAspectRatio()); |
|
1032 aWidth = aWidth * (aAspectRatio*imageData->GetAspectRatio()); |
|
1033 } |
|
1034 } |
|
1035 else |
|
1036 { |
|
1037 //Fix aspect ratio |
|
1038 aWidth *= aAspectRatio; |
|
1039 } |
|
1040 } |
|
1041 |
|
1042 |
|
1043 |
|
1044 /*----------------------------------------------------------------------*/ |
|
1045 // Draws one by one view |
|
1046 // |
|
1047 void CImagicContainerBrowser::GetCurrentFilenameL(TFileName& aFilename, TThumbSize aRes) |
|
1048 { |
|
1049 iIEngine->GetFileNameL(iCurrentIndex, aRes, aFilename); |
|
1050 } |
|
1051 |
|
1052 void CImagicContainerBrowser::SetCurrentFaceNro(TInt aNro) |
|
1053 { |
|
1054 iDrawFaceBrowsing->SetCurrentFaceNro(aNro); |
|
1055 } |
|
1056 |
|
1057 #if 0 |
|
1058 /*----------------------------------------------------------------------*/ |
|
1059 // Gets current screen coords |
|
1060 // |
|
1061 void CImagicContainerBrowser::ConvertScreenCoords2QvgaCoords(TPoint& aPoint, TRect& aRect) |
|
1062 { |
|
1063 CImageData* imageData = iIEngine->GetImageData(iCurrentIndex); |
|
1064 |
|
1065 TInt pictureWidth, pictureHeigth; |
|
1066 pictureWidth=320; |
|
1067 pictureHeigth=320; |
|
1068 |
|
1069 //Calculate coords from alogorith to OpenGL -0.5 - +0.5 coords and fill the array |
|
1070 float tmpX; |
|
1071 float tmpY; |
|
1072 if(imageData->GetAspectRatio() > 1) |
|
1073 { |
|
1074 //Convert from center of screen to corner coords |
|
1075 tmpX = iDrawOneByOne->GetDrawOneByOneXY().iX + 0.5; |
|
1076 tmpY = iDrawOneByOne->GetDrawOneByOneXY().iY + (0.5/imageData->GetAspectRatio()); |
|
1077 } |
|
1078 else//portrait |
|
1079 { |
|
1080 //Convert from center of screen to corner coords |
|
1081 tmpX = iDrawOneByOne->GetDrawOneByOneXY().iX + (0.5*imageData->GetAspectRatio()); |
|
1082 tmpY = iDrawOneByOne->GetDrawOneByOneXY().iY + 0.5; |
|
1083 } |
|
1084 |
|
1085 aPoint.iX = tmpX * pictureWidth; |
|
1086 aPoint.iY = tmpY * pictureHeigth; |
|
1087 |
|
1088 TInt rectWidth = pictureWidth; |
|
1089 TInt rectHeigth = pictureHeigth; |
|
1090 |
|
1091 rectWidth = rectWidth/(iDrawOneByOne->GetDrawOneByOneZoom()*2); |
|
1092 rectHeigth = rectHeigth/(iDrawOneByOne->GetDrawOneByOneZoom()*2); |
|
1093 |
|
1094 aRect.iTl.iX = aPoint.iX-(rectWidth/2); |
|
1095 aRect.iTl.iY = aPoint.iY-(rectHeigth/2); |
|
1096 aRect.iBr.iX = aPoint.iX+(rectWidth/2); |
|
1097 aRect.iBr.iY = aPoint.iY+(rectHeigth/2); |
|
1098 |
|
1099 } |
|
1100 #endif |
|
1101 |
|
1102 void CImagicContainerBrowser::LoadHighResImage(CImageData* imageData, TInt aIndex) |
|
1103 { |
|
1104 DP0_IMAGIC(_L("CImagicContainerBrowser::LoadHighResImage++")); |
|
1105 |
|
1106 //Make sure that 512 for current image is loaded |
|
1107 if(imageData->iGridData.iGlHQ512TextIndex == 0) |
|
1108 { |
|
1109 LoadHQ512Image(imageData, aIndex); |
|
1110 return; |
|
1111 } |
|
1112 |
|
1113 #ifdef SUPERZOOM |
|
1114 //Load "super zoom" image if in zoom or face browser |
|
1115 if(imageData->iGridData.iGlSuperHQTextIndex == 0 && |
|
1116 (!IS_NOT_IN_ZOOM_ONEBYONE || iDrawOneByOne->IsMagGlassOn() )) |
|
1117 { |
|
1118 //iPreferHighResLoading = ETrue; |
|
1119 TRAPD(err, iTextureLoader->LoadL(imageData, EFullSize)); |
|
1120 if( err == KErrNone || err == KErrInUse ) |
|
1121 iPreferHighResLoading = ETrue; |
|
1122 |
|
1123 /*if(err != KErrNone) |
|
1124 if(err == KErrAlreadyExists || err == KErrInUse) |
|
1125 iPreferHighResLoading = ETrue; |
|
1126 else |
|
1127 iPreferHighResLoading = EFalse;*/ |
|
1128 } |
|
1129 #endif |
|
1130 |
|
1131 CImageData* imageDataLoad = NULL; |
|
1132 //Here we load 512x512 resolution images, one to both sides of current up to limit |
|
1133 for (TInt i = 1; i <= K512TNImageBuffer; i++) |
|
1134 { |
|
1135 // Check to positive and negative direction from current picture |
|
1136 for (TInt j = 0; j < 2; j++) |
|
1137 { |
|
1138 // Calculate image index |
|
1139 TInt index = iCurrentIndex + (j ? i : -i); |
|
1140 |
|
1141 if(index >= 0 && index < iIEngine->GetTotalNumOfImages()) |
|
1142 { |
|
1143 imageDataLoad = iIEngine->GetImageData(index); |
|
1144 if(imageDataLoad == NULL) |
|
1145 break; |
|
1146 |
|
1147 if(imageDataLoad->iGridData.iGlHQ512TextIndex == 0) |
|
1148 { |
|
1149 DP1_IMAGIC(_L("CImagicContainerBrowser::LoadHighResImage -------------- Start High res image loading, index: %d"), index); |
|
1150 LoadHQ512Image(imageDataLoad, index); |
|
1151 return; |
|
1152 } |
|
1153 |
|
1154 } |
|
1155 } |
|
1156 } |
|
1157 |
|
1158 |
|
1159 DP0_IMAGIC(_L("CImagicContainerBrowser::LoadHighResImage--")); |
|
1160 } |
|
1161 |
|
1162 |
|
1163 void CImagicContainerBrowser::LoadHQ512Image(CImageData* imageData, TInt aIndex) |
|
1164 { |
|
1165 DP0_IMAGIC(_L("CImagicContainerBrowser::LoadHQ512Image++")); |
|
1166 |
|
1167 //iPreferHighResLoading = ETrue; |
|
1168 |
|
1169 if(/*iDrawOneByOne->GetDrawOneByOneZoom() > 0.99 &&*/ imageData) |
|
1170 { |
|
1171 TInt error; |
|
1172 if((imageData->iGridData.iGlLQ128TextIndex == 0) && (iCurrentIndex == aIndex)) |
|
1173 TRAPD(error, iTextureLoader->LoadL(imageData, ESize128x128)); |
|
1174 |
|
1175 if(imageData->iGridData.iGlHQ512TextIndex == 0) |
|
1176 { |
|
1177 //iPreferHighResLoading = ETrue; |
|
1178 TRAPD(err, iTextureLoader->LoadL(imageData, ESize512x512)); |
|
1179 /* if(err != KErrNone) |
|
1180 if(err == KErrAlreadyExists || err == KErrInUse) |
|
1181 iPreferHighResLoading = ETrue; |
|
1182 else |
|
1183 iPreferHighResLoading = EFalse;*/ |
|
1184 |
|
1185 if( err == KErrNone || err == KErrInUse ) |
|
1186 { |
|
1187 DP0_IMAGIC(_L("CImagicContainerBrowser::LoadHQ512Image - set dyn loading off")); |
|
1188 iPreferHighResLoading = ETrue; |
|
1189 iDynamicLoadingOn = EFalse; //set to false to be able to get run time for high res loading |
|
1190 } |
|
1191 else if(err == KErrAlreadyExists) |
|
1192 { |
|
1193 DP0_IMAGIC(_L("CImagicContainerBrowser::LoadHQ512Image - set dyn loading on")); |
|
1194 iDynamicLoadingOn = ETrue; |
|
1195 } |
|
1196 } |
|
1197 |
|
1198 } |
|
1199 |
|
1200 DP0_IMAGIC(_L("CImagicContainerBrowser::LoadHQ512Image--")); |
|
1201 } |
|
1202 |
|
1203 |
|
1204 void CImagicContainerBrowser::ShowMagGlass(const TBool aState) |
|
1205 { |
|
1206 // do nothing if it's already in the state |
|
1207 if (/*iMagGlassOn*/ iDrawOneByOne->IsMagGlassOn() == aState || !IS_NOT_IN_ZOOM_ONEBYONE) |
|
1208 return; |
|
1209 |
|
1210 iDrawOneByOne->SetMagGlassPrevStatus(iDrawOneByOne->IsMagGlassOn()); |
|
1211 iDrawOneByOne->SetMagGlassStatus(aState); |
|
1212 } |
|
1213 |
|
1214 |
|
1215 |
|
1216 void CImagicContainerBrowser::SetMinMagFilterLinear(TBool aValue) |
|
1217 { |
|
1218 if(iDrawFunction == EOneByOne || iDrawFunction == EFaceBrowsing) |
|
1219 if(IsHwAcceleration()) |
|
1220 iMinMagFilterSetting=ETrue; |
|
1221 else |
|
1222 iMinMagFilterSetting=aValue; |
|
1223 else |
|
1224 iMinMagFilterSetting=aValue; |
|
1225 } |
|
1226 |
|
1227 TBool CImagicContainerBrowser::IsHwAcceleration() |
|
1228 { |
|
1229 return (iGLMaxRes == 2048)? ETrue: EFalse; |
|
1230 } |
|
1231 |
|
1232 void CImagicContainerBrowser::SetMinMagFilterLinearDo(TBool aValue) |
|
1233 { |
|
1234 DP0_IMAGIC(_L("CImagicContainerBrowser::SetMinMagFilterLinear++")); |
|
1235 |
|
1236 CImageData* imageData = iIEngine->GetImageData(iCurrentIndex); |
|
1237 |
|
1238 if(iCurrentBindedIndex == imageData->iGridData.iGlLQ128TextIndex || |
|
1239 iCurrentBindedIndex == imageData->iGridData.iGlLQ32TextIndex) |
|
1240 { |
|
1241 DP0_IMAGIC(_L("CImagicContainerBrowser::SetMagFilterLinear - Linear")); |
|
1242 iMagFilterLinear = ETrue; |
|
1243 glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); |
|
1244 glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); |
|
1245 } |
|
1246 else if(aValue) |
|
1247 { |
|
1248 DP0_IMAGIC(_L("CImagicContainerBrowser::SetMagFilterLinear - Linear")); |
|
1249 iMagFilterLinear = ETrue; |
|
1250 glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); |
|
1251 glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); |
|
1252 } |
|
1253 else |
|
1254 { |
|
1255 DP0_IMAGIC(_L("CImagicContainerBrowser::SetMagFilterLinear - Nearest")); |
|
1256 iMagFilterLinear = EFalse; |
|
1257 glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); |
|
1258 glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); |
|
1259 } |
|
1260 |
|
1261 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); |
|
1262 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); |
|
1263 |
|
1264 |
|
1265 DP0_IMAGIC(_L("CImagicContainerBrowser::SetMinMagFilterLinear--")); |
|
1266 } |
|
1267 |
|
1268 void CImagicContainerBrowser::DrawFaceBrowsingIcon() |
|
1269 { |
|
1270 #ifdef ICONS_ENABLAD |
|
1271 if((!iMagGlassOn && iDrawFunction==EFaceBrowser) || |
|
1272 (iDrawFunction==EFaceBrowser) && (iIconTextureIndexes.Count() >= 1)) |
|
1273 { |
|
1274 iDrawUtility->DrawIcon(Size(), iIconTextureIndexes[0]); |
|
1275 SetMinMagFilterLinearDo(ETrue); |
|
1276 } |
|
1277 #endif |
|
1278 } |
|
1279 |
|
1280 void CImagicContainerBrowser::DrawZoomIcon() |
|
1281 { |
|
1282 #ifdef ICONS_ENABLAD |
|
1283 if((!iMagGlassOn && iDrawFunction==EOneByOne && (iDrawOneByOneZoom-1.0) > 0.01) && |
|
1284 (iIconTextureIndexes.Count()>=2)) |
|
1285 { |
|
1286 iDrawUtility->DrawIcon(Size(), iIconTextureIndexes[1]); |
|
1287 SetMinMagFilterLinearDo(ETrue); |
|
1288 } |
|
1289 #endif |
|
1290 } |
|
1291 |
|
1292 void CImagicContainerBrowser::SetDeleteTextures(TBool aValue) |
|
1293 { |
|
1294 DeleteTextures(); |
|
1295 iDeleteTextures = aValue; |
|
1296 } |
|
1297 |
|
1298 |
|
1299 |
|
1300 //--------------------------------------------------------------------------------- |
|
1301 //DrawCallBack for OpenGL |
|
1302 TInt CImagicContainerBrowser::DrawCallBackL( TAny* aInstance ) |
|
1303 { |
|
1304 //DP0_IMAGIC(_L("CImagicContainerBrowser::DrawCallBack")); |
|
1305 // Get pointer to instance |
|
1306 ((CImagicContainerBrowser*) aInstance)->DrawL(); |
|
1307 return 0; |
|
1308 } |
|
1309 |
|
1310 void CImagicContainerBrowser::DrawL() |
|
1311 { |
|
1312 #ifdef ADAPTIVE_FRAMERATE |
|
1313 // No drawing if timer is not zero |
|
1314 if (iWaitDrawTicks != 0) |
|
1315 { |
|
1316 if (iWaitDrawTicks > 0) |
|
1317 iWaitDrawTicks--; |
|
1318 return; |
|
1319 } |
|
1320 |
|
1321 iWaitDrawTicks = -1; |
|
1322 |
|
1323 //TInt startTick = |
|
1324 #endif |
|
1325 |
|
1326 |
|
1327 |
|
1328 if(iDeleteTextures) |
|
1329 { |
|
1330 if(iPeriodic->IsActive()) |
|
1331 iPeriodic->Cancel(); |
|
1332 DeleteTextures(); |
|
1333 |
|
1334 return; |
|
1335 } |
|
1336 |
|
1337 |
|
1338 TSize size = Size(); |
|
1339 BeginDrawing(); |
|
1340 |
|
1341 |
|
1342 |
|
1343 if(!iScreenRotateOngoing) |
|
1344 { |
|
1345 |
|
1346 // Call proper draw function |
|
1347 switch (iDrawFunction) |
|
1348 { |
|
1349 case EGrid: |
|
1350 |
|
1351 if(iIEngine->IsScanningFiles()) |
|
1352 { |
|
1353 if(iDrawOnes == 0) |
|
1354 iDrawOnes = 1;//make sure we draw screen ones when start application |
|
1355 } |
|
1356 #if 0 |
|
1357 if(iDynamicLoadingOn) |
|
1358 { |
|
1359 DP0_IMAGIC(_L("CImagicContainerBrowser::DrawCallBack - Continue Image Loading")); |
|
1360 DynamicLoadingL(); |
|
1361 } |
|
1362 |
|
1363 #endif |
|
1364 |
|
1365 if(iDrawGrid->IsDrawingNeededGrid() || iDrawOnes == 1) |
|
1366 { |
|
1367 drawZoom = 1; inPictureX = 0; inPictureY = 0; |
|
1368 iDrawGrid->DrawGridL(size); |
|
1369 EndDrawing(); |
|
1370 if(iIEngine->GetTotalNumOfImages() > 0) |
|
1371 iDrawOnes = -1; |
|
1372 } |
|
1373 |
|
1374 break; |
|
1375 |
|
1376 case EOneByOne: |
|
1377 if(iDrawOneByOne->IsDrawingNeededOneByOne()) |
|
1378 { |
|
1379 iDrawOneByOne->DrawOnebyOneL(size); |
|
1380 EndDrawing(); |
|
1381 } |
|
1382 break; |
|
1383 |
|
1384 case EFaceBrowser: |
|
1385 if(iDrawFaceBrowsing->IsDrawingNeededFaceBrowsing()) |
|
1386 { |
|
1387 iDrawFaceBrowsing->DrawFaceBrowsing(size); |
|
1388 drawZoom = 1; inPictureX = 0; inPictureY = 0; |
|
1389 iDrawFaceBrowsing->GetFBZoomAndLocation(drawZoom, inPictureX, inPictureY); |
|
1390 EndDrawing(); |
|
1391 } |
|
1392 break; |
|
1393 |
|
1394 default: |
|
1395 // Should never come here |
|
1396 break; |
|
1397 } |
|
1398 } |
|
1399 |
|
1400 #ifdef ADAPTIVE_FRAMERATE |
|
1401 iWaitDrawTicks = KWaitTicksAfterDraw; // wait 20ms |
|
1402 #endif |
|
1403 } |
|
1404 |
|
1405 void CImagicContainerBrowser::BeginDrawing() |
|
1406 { |
|
1407 // Calculate used time between two frames |
|
1408 iTimeNow = User::NTickCount(); |
|
1409 |
|
1410 #ifdef __WINS__ |
|
1411 // In the emulator the tickcount runs at 200Hz |
|
1412 iTimeDiff = (GLfloat)(iTimeNow - iLastTime)/200; |
|
1413 iLastTime = iTimeNow; |
|
1414 #else |
|
1415 // In the HW the tickcount runs at 1000Hz |
|
1416 iTimeDiff = (GLfloat)(iTimeNow - iLastTime)/1000; |
|
1417 iLastTime = iTimeNow; |
|
1418 #endif |
|
1419 |
|
1420 //Prevent screen draw while rotating screen |
|
1421 //if(!iScreenRotateOngoing) |
|
1422 { |
|
1423 // Get window size |
|
1424 //aSize = Size(); |
|
1425 |
|
1426 // Enable client state |
|
1427 glEnableClientState(GL_VERTEX_ARRAY); |
|
1428 glEnableClientState(GL_TEXTURE_COORD_ARRAY); |
|
1429 glTexCoordPointer( 2, GL_FIXED, 0, iGlobalTexCoords ); |
|
1430 } |
|
1431 |
|
1432 } |
|
1433 |
|
1434 void CImagicContainerBrowser::EndDrawing() |
|
1435 { |
|
1436 #ifdef LOADING_ANIMATION |
|
1437 // Handle loading animation |
|
1438 glColor4f(1,1,1,1); |
|
1439 iDrawUtility->Update(); |
|
1440 iDrawUtility->Draw(Size()); |
|
1441 |
|
1442 TBool tmp = iMagFilterLinear; |
|
1443 iMagFilterLinear = ETrue; |
|
1444 |
|
1445 |
|
1446 DrawFaceBrowsingIcon(); |
|
1447 DrawZoomIcon(); |
|
1448 |
|
1449 iMagFilterLinear = tmp; |
|
1450 #endif |
|
1451 |
|
1452 /*iMenuAlpha-=0.05; |
|
1453 if(iMenuAlpha < 0) |
|
1454 iMenuAlpha = 0; |
|
1455 iDrawUtility->DrawIcon2(Size(), iLoadingTextureIndex, iMenuAlpha);*/ |
|
1456 |
|
1457 |
|
1458 //Prevent screen draw while rotating screen |
|
1459 //if(!iScreenRotateOngoing) |
|
1460 { |
|
1461 // Disable client state |
|
1462 glDisableClientState(GL_VERTEX_ARRAY); |
|
1463 glDisableClientState(GL_TEXTURE_COORD_ARRAY); |
|
1464 |
|
1465 |
|
1466 // Call eglSwapBuffers, which blit the graphics to the window |
|
1467 if( !eglSwapBuffers( iEglDisplay, iEglSurface ) ) |
|
1468 { |
|
1469 _LIT(KTextOpenGlError, "ERROR in OpenGL draw: eglSwapBuffers error"); |
|
1470 CAknErrorNote* note = new ( ELeave ) CAknErrorNote(ETrue); |
|
1471 TBuf<256> text; |
|
1472 text.Format(KTextOpenGlError); |
|
1473 note->ExecuteLD( text ); |
|
1474 |
|
1475 //suspend or some other power event occurred, context lost |
|
1476 OpenGLInitL(); /* reinitialize EGL */ |
|
1477 |
|
1478 InitL(); /* reinitialize grid data */ |
|
1479 iDrawFunction = EGrid; |
|
1480 } |
|
1481 |
|
1482 // Check for errors |
|
1483 //EGLint err = eglGetError(); |
|
1484 EGLint err = glGetError(); |
|
1485 //err=EGL_CONTEXT_LOST; |
|
1486 //if(err != EGL_SUCCESS) |
|
1487 TBool init = EFalse; |
|
1488 //while(err != EGL_SUCCESS)GL_NO_ERROR |
|
1489 while(err != GL_NO_ERROR) |
|
1490 { |
|
1491 /*_LIT(KTextOpenGlError, "ERROR in OpenGL draw: %d"); |
|
1492 CAknErrorNote* note = new ( ELeave ) CAknErrorNote(ETrue); |
|
1493 TBuf<256> text; |
|
1494 text.Format(KTextOpenGlError, err); |
|
1495 note->ExecuteLD( text );*/ |
|
1496 |
|
1497 //suspend or some other power event occurred, context lost |
|
1498 /*DeleteTextures(); |
|
1499 OpenGLInitL(); |
|
1500 InitL();*/ |
|
1501 iDrawFunction = EGrid; |
|
1502 err = glGetError(); |
|
1503 init = ETrue; |
|
1504 } |
|
1505 |
|
1506 if(init) |
|
1507 { |
|
1508 DeleteTextures(); |
|
1509 OpenGLInitL(); /* reinitialize EGL */ |
|
1510 InitL(); /* reinitialize grid data */ |
|
1511 } |
|
1512 |
|
1513 // Clear buffers |
|
1514 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); |
|
1515 } |
|
1516 } |
|
1517 |
|
1518 // --------------------------------------------------------- |
|
1519 // CImagicContainerBrowser::SizeChanged() |
|
1520 // Called by framework when the view size is changed |
|
1521 // --------------------------------------------------------- |
|
1522 // |
|
1523 void CImagicContainerBrowser::SizeChanged() |
|
1524 { |
|
1525 DP0_IMAGIC(_L("CImagicContainerBrowser::SizeChanged")); |
|
1526 |
|
1527 iScreenRotateOngoing = ETrue; |
|
1528 //TSize size = this->Size(); |
|
1529 iScreenSize = this->Size(); |
|
1530 iScreenAspectRatio = (TReal)iScreenSize.iWidth / (TReal)iScreenSize.iHeight; |
|
1531 |
|
1532 // Reinitialize viewport and projection. |
|
1533 glViewport( 0, 0, iScreenSize.iWidth, iScreenSize.iHeight ); |
|
1534 |
|
1535 if(iScreenSize.iHeight > iScreenSize.iWidth) |
|
1536 {//Portrait |
|
1537 iDisplayRotation = -90; |
|
1538 iDisplayRotationTarget = 0; |
|
1539 } |
|
1540 else |
|
1541 {//Landscape |
|
1542 iDisplayRotation = 90; |
|
1543 } |
|
1544 |
|
1545 iScreenRotateOngoing = EFalse; |
|
1546 |
|
1547 iDrawNow = ETrue; |
|
1548 |
|
1549 } |
|
1550 |
|
1551 float CImagicContainerBrowser::GetDisplayRotTargetAngle() |
|
1552 { |
|
1553 return iDisplayRotationTarget; |
|
1554 } |
|
1555 |
|
1556 float CImagicContainerBrowser::GetDisplayRotAngle() |
|
1557 { |
|
1558 return iDisplayRotation; |
|
1559 } |
|
1560 |
|
1561 void CImagicContainerBrowser::SetDisplayRotAngle(float aValue) |
|
1562 { |
|
1563 iDisplayRotationTarget = aValue; |
|
1564 } |
|
1565 |
|
1566 |
|
1567 // --------------------------------------------------------- |
|
1568 // CImagicContainerBrowser::CountComponentControls() const |
|
1569 // --------------------------------------------------------- |
|
1570 // |
|
1571 TInt CImagicContainerBrowser::CountComponentControls() const |
|
1572 { |
|
1573 return 0; // return nbr of controls inside this container |
|
1574 } |
|
1575 |
|
1576 // --------------------------------------------------------- |
|
1577 // CImagicContainerBrowser::ComponentControl(TInt aIndex) const |
|
1578 // --------------------------------------------------------- |
|
1579 // |
|
1580 CCoeControl* CImagicContainerBrowser::ComponentControl(TInt /*aIndex*/) const |
|
1581 { |
|
1582 |
|
1583 return NULL; |
|
1584 } |
|
1585 |
|
1586 // --------------------------------------------------------- |
|
1587 // CImagicContainerBrowser::Draw(const TRect& aRect) const |
|
1588 // --------------------------------------------------------- |
|
1589 // |
|
1590 void CImagicContainerBrowser::Draw(const TRect& /*aRect*/) const |
|
1591 { |
|
1592 DP0_IMAGIC(_L("CImagicContainerBrowser::Draw")); |
|
1593 |
|
1594 CImagicContainerBrowser* self=const_cast<CImagicContainerBrowser*>(this); |
|
1595 self->iDrawNow = ETrue; |
|
1596 |
|
1597 /*if(iScreenImmeadetaUpdate) |
|
1598 self->DrawL();*/ |
|
1599 } |
|
1600 |
|
1601 void CImagicContainerBrowser::SetScreenImmeadetaUpdate(TBool aValue) |
|
1602 { |
|
1603 iScreenImmeadetaUpdate = aValue; |
|
1604 } |
|
1605 |
|
1606 |
|
1607 // --------------------------------------------------------- |
|
1608 // CImagicContainerBrowser::HandleControlEventL( |
|
1609 // CCoeControl* aControl,TCoeEvent aEventType) |
|
1610 // --------------------------------------------------------- |
|
1611 // |
|
1612 void CImagicContainerBrowser::HandleControlEventL(CCoeControl* /*aControl*/,TCoeEvent /*aEventType*/) |
|
1613 { |
|
1614 // Add your control event handler code here |
|
1615 } |
|
1616 |
|
1617 // --------------------------------------------------------- |
|
1618 // CImagicContainerBrowser::HandlePointerEventL( |
|
1619 // const TPointerEvent& aPointerEvent) |
|
1620 // --------------------------------------------------------- |
|
1621 // |
|
1622 void CImagicContainerBrowser::HandlePointerEventL(const TPointerEvent& aPointerEvent) |
|
1623 { |
|
1624 DP0_IMAGIC(_L("CImagicContainerBrowser::HandlePointerEventL++")); |
|
1625 |
|
1626 EnableDisplayDraw(); |
|
1627 |
|
1628 //Set normal display draw speed if we were in low draw freq |
|
1629 #ifdef USE_LOW_DRAW_SPEED_WHILE_LOADING |
|
1630 SetDrawFreqToNormal(KPowerSavePeriodicDelay); |
|
1631 #endif |
|
1632 |
|
1633 iUserInputGiven = ETrue; |
|
1634 iLastEventFromKeys = EFalse; |
|
1635 iOnTheEdge=ETrue; |
|
1636 |
|
1637 /* Lets not put this on, othervise does not work in S60 3.2 |
|
1638 // Do nothing if non-touch |
|
1639 if (!AknLayoutUtils::PenEnabled() ) |
|
1640 { |
|
1641 return; |
|
1642 } |
|
1643 */ |
|
1644 |
|
1645 #ifdef USE_AVKON_LONGTAP_DETECTOR |
|
1646 // Pass the pointer event to Long tap detector component |
|
1647 iLongTapDetector->PointerEventL(aPointerEvent); |
|
1648 #endif |
|
1649 |
|
1650 #ifdef USE_AVKON_TACTILE_FEEDBACK |
|
1651 if (aPointerEvent.iType == TPointerEvent::EButton1Down) |
|
1652 { |
|
1653 // Give feedback to user (vibration) |
|
1654 iTouchFeedBack->InstantFeedback(ETouchFeedbackBasic); |
|
1655 } |
|
1656 #endif |
|
1657 |
|
1658 if ( AknLayoutUtils::PenEnabled() ) |
|
1659 { |
|
1660 iGesture->PointerEventL(aPointerEvent); |
|
1661 } |
|
1662 |
|
1663 // Call base class HandlePointerEventL() |
|
1664 CCoeControl::HandlePointerEventL(aPointerEvent); |
|
1665 |
|
1666 SetLastTouchPoint(aPointerEvent.iPosition); |
|
1667 |
|
1668 DP0_IMAGIC(_L("CImagicContainerBrowser::HandlePointerEventL--")); |
|
1669 } |
|
1670 |
|
1671 void CImagicContainerBrowser::SetLastTouchPoint(const TPoint& aPos) |
|
1672 { |
|
1673 |
|
1674 iTouchPointThreshold = EFalse; |
|
1675 |
|
1676 if(Abs(aPos.iX-iLastTouchPoint.iX) > 2)//TODO, mika: check correct size |
|
1677 { |
|
1678 iTouchPointThreshold = ETrue; |
|
1679 } |
|
1680 if(Abs(aPos.iY-iLastTouchPoint.iY) > 2) |
|
1681 { |
|
1682 iTouchPointThreshold = ETrue; |
|
1683 } |
|
1684 |
|
1685 //Change touch point only if we moved more than 5 pixel |
|
1686 //if(changeTouchPoint) |
|
1687 iLastTouchPoint = aPos; |
|
1688 } |
|
1689 |
|
1690 TBool CImagicContainerBrowser::IsTouchPointThresholdExeed() |
|
1691 { |
|
1692 return iTouchPointThreshold; |
|
1693 } |
|
1694 |
|
1695 TPoint CImagicContainerBrowser::GetLastTouchPoint(void) |
|
1696 { |
|
1697 return iLastTouchPoint; |
|
1698 } |
|
1699 |
|
1700 // --------------------------------------------------------- |
|
1701 // CImagicContainerBrowser::HandleLongTapEventL( |
|
1702 // const TPoint& aPenEventLocation, const TPoint& aPenEventScreenLocation) |
|
1703 // --------------------------------------------------------- |
|
1704 // |
|
1705 void CImagicContainerBrowser::HandleLongTapEventL(const TPoint& /*aPenEventLocation*/, |
|
1706 const TPoint& /*aPenEventScreenLocation*/) |
|
1707 { |
|
1708 DP0_IMAGIC(_L("CImagicContainerBrowser::HandleLongTapEventL++")); |
|
1709 |
|
1710 //THIS FUNCTION IS NOT USED, USE INSTEAD DoLongTap() TO HANDLE LONG TAP EVENTS!!! |
|
1711 |
|
1712 DP0_IMAGIC(_L("CImagicContainerBrowser::HandleLongTapEventL--")); |
|
1713 } |
|
1714 |
|
1715 // --------------------------------------------------------- |
|
1716 // CImagicContainerBrowser::FindImageInScreen( |
|
1717 // const TPoint aPos, TInt& aResultIndex) |
|
1718 // --------------------------------------------------------- |
|
1719 // |
|
1720 TBool CImagicContainerBrowser::FindImageInScreen(const TPoint aPos, TInt& aResultIndex) |
|
1721 { |
|
1722 GLfloat modelview[16]; |
|
1723 glGetFloatv(GL_MODELVIEW_MATRIX, modelview); |
|
1724 |
|
1725 GLfloat projection[16]; |
|
1726 glGetFloatv(GL_PROJECTION_MATRIX, projection); |
|
1727 |
|
1728 int viewport[4]; |
|
1729 glGetIntegerv(GL_VIEWPORT, viewport); |
|
1730 |
|
1731 GLfloat x = aPos.iX; |
|
1732 GLfloat y = this->Size().iHeight - 1 - aPos.iY; |
|
1733 GLfloat objX[2], objY[2], objZ[2]; // [0] for near, [1] for far |
|
1734 |
|
1735 // Get coords in near and far plane. The coords give the ray from near to far plane. |
|
1736 gluUnProject(x,y,0.0,modelview,projection,viewport,&objX[0],&objY[0],&objZ[0]); |
|
1737 gluUnProject(x,y,1.0,modelview,projection,viewport,&objX[1],&objY[1],&objZ[1]); |
|
1738 |
|
1739 DP3_IMAGIC(_L("####### UnProject(z=0, near):X=%6.4f,Y=%6.4f,Z=%6.4f"), objX[0],objY[0],objZ[0]); |
|
1740 DP3_IMAGIC(_L("####### UnProject(z=1.0,far):X=%6.4f,Y=%6.4f,Z=%6.4f"), objX[1],objY[1],objZ[1]); |
|
1741 DP3_IMAGIC(_L("####### Device (%d):x=%6.3f,y=%6.3f,z=not known"), iCurrentIndex, x,y); |
|
1742 DP3_IMAGIC(_L("####### Current(%d):x=%6.4f,y=%6.4f"),iCurrentIndex, (iCurrentIndex / CImagicContainerBrowser::KGridSizeY) * KSpacingX, -(iCurrentIndex % CImagicContainerBrowser::KGridSizeY) * KSpacingY); |
|
1743 |
|
1744 GLfloat perspectiveDepth = objZ[0] - objZ[1]; // near value is bigger. depth = near - far. |
|
1745 |
|
1746 aResultIndex = -1; // gives invalid value if not found |
|
1747 |
|
1748 // The ray is linear. Can get xy at a depth by multiply '(a depth)/(near/far depth)' |
|
1749 TInt numOfImages = iIEngine->GetTotalNumOfImages(); |
|
1750 for (TInt i = 0; i < numOfImages; ++i) |
|
1751 { |
|
1752 GLfloat itemZ = iIEngine->GetImageData(i)->iGridData.iZ; |
|
1753 GLfloat itemDepthCoord = -itemZ - iDrawGrid->GetGridZoom(); // - objZ[0]; // camera shifted by iDrawGridZoom. perspective starts from near. |
|
1754 GLfloat itemDepth = itemDepthCoord / perspectiveDepth; |
|
1755 |
|
1756 GLfloat itemX = objX[0] + itemDepth * (objX[1] - objX[0]); // = near + u(far - near) |
|
1757 GLfloat itemY = objY[0] + itemDepth * (objY[1] - objY[0]); // = near + u(far - near) |
|
1758 |
|
1759 CImageData* imageData = iIEngine->GetImageData(i); |
|
1760 GLfloat itemScale = imageData->iGridData.iScale; |
|
1761 |
|
1762 GLfloat width = KSpacingX; // * itemScale; // TODO: check!. No need to consider scaling. Why? |
|
1763 GLfloat height = KSpacingY; // * itemScale; |
|
1764 GLfloat objx = imageData->iGridData.iX; |
|
1765 GLfloat objy = imageData->iGridData.iY; |
|
1766 //GLfloat objx = (i / CImagicContainerBrowser::KGridSizeY) * width; |
|
1767 //GLfloat objy = -(i % CImagicContainerBrowser::KGridSizeY) * height; |
|
1768 //TODO: consider aspect ratio |
|
1769 |
|
1770 DP3_IMAGIC(_L("####### UnProject: itemX=%f, itemY=%f, itemZ=%f"), itemX, itemY, itemZ); |
|
1771 DP4_IMAGIC(_L("####### UnProject: itemDepthCoord=%f, perspectiveDepth=%f, itemDepth=%f, itemScale=%f"), |
|
1772 itemDepthCoord, perspectiveDepth, itemDepth, itemScale); |
|
1773 DP4_IMAGIC(_L("#######(%d) %6.4f < x(%6.4f) < %6.4f"), i, objx-width/2, itemX, objx+width/2); |
|
1774 DP4_IMAGIC(_L("#######(%d) %6.4f < y(%6.4f) < %6.4f"), i, objy-height/2, itemY, objy+height/2); |
|
1775 |
|
1776 if (objx-width/2 <= itemX && itemX < objx + width/2) |
|
1777 { |
|
1778 if (objy-height/2 <= itemY && itemY < objy + height/2) |
|
1779 { |
|
1780 aResultIndex = i; |
|
1781 break; |
|
1782 } |
|
1783 } |
|
1784 } |
|
1785 |
|
1786 #if 0 |
|
1787 // just trial code. useful for checking unprojection results |
|
1788 z = 0.9997; // best reasonable fixed value from experience |
|
1789 gluUnProject(x,y,z,modelview,projection,viewport,&objX,&objY,&objZ); |
|
1790 RDebug::Print(_L("####### UnProject(z=%8.6f):X=%6.4f,Y=%6.4f,Z=%6.4f"), z,objX,objY,objZ); |
|
1791 #endif |
|
1792 |
|
1793 //DP1_IMAGIC(_L("####### SELECTED =====> %d"), selectedIndex); |
|
1794 |
|
1795 return (aResultIndex != -1)? ETrue: EFalse; |
|
1796 } |
|
1797 |
|
1798 // --------------------------------------------------------- |
|
1799 // CImagicContainerBrowser::GetMaxX() |
|
1800 // --------------------------------------------------------- |
|
1801 // |
|
1802 TReal CImagicContainerBrowser::GetMaxX() const |
|
1803 { |
|
1804 TInt images = iIEngine->GetTotalNumOfImages(); |
|
1805 return images > 0 ? iIEngine->GetImageData(images - 1)->iGridData.iX : 0; |
|
1806 } |
|
1807 |
|
1808 // --------------------------------------------------------- |
|
1809 // CImagicContainerBrowser::FindImageInOGl( |
|
1810 // const FloatCoords aPos, TInt& aResultIndex) |
|
1811 // --------------------------------------------------------- |
|
1812 // |
|
1813 TBool CImagicContainerBrowser::FindNearestImageInOGl(const FloatCoords aPos, TInt& aResultIndex) |
|
1814 { |
|
1815 float width = KSpacingX; |
|
1816 float height = KSpacingY; |
|
1817 float itemX = aPos.iX; |
|
1818 float itemY = aPos.iY; |
|
1819 TInt image_num = iIEngine->GetTotalNumOfImages(); |
|
1820 |
|
1821 DP2_IMAGIC(_L("1: itemXY=(%6.4f,%6.4f)"), itemX, itemY); |
|
1822 |
|
1823 itemX = Max(itemX, 0); |
|
1824 itemX = Min(itemX, GetMaxX()); //image_num / CImagicContainerBrowser::KGridSizeY) * width); |
|
1825 itemY = Max(itemY, 0); |
|
1826 itemY = Min(itemY, (CImagicContainerBrowser::KGridSizeY - 1) * height); |
|
1827 |
|
1828 DP2_IMAGIC(_L("2: itemXY=(%6.4f,%6.4f)"), itemX, itemY); |
|
1829 |
|
1830 aResultIndex = -1; // gives invalid value if not found |
|
1831 |
|
1832 // The ray is linear. Can get xy at a depth by multiply '(a depth)/(near/far depth)' |
|
1833 for (TInt i=0; i<image_num; ++i) |
|
1834 { |
|
1835 CImageData* imageData = iIEngine->GetImageData(i); |
|
1836 GLfloat itemZ = imageData->iGridData.iZ; |
|
1837 GLfloat objx = imageData->iGridData.iX; |
|
1838 GLfloat objy = -imageData->iGridData.iY; |
|
1839 //GLfloat objx = (i / iGridSizeY) * width; |
|
1840 //GLfloat objy = (i % iGridSizeY) * height; |
|
1841 |
|
1842 if (objx-width/2 <= itemX && itemX < objx + width/2) |
|
1843 { |
|
1844 if (objy-height/2 <= itemY && itemY < objy + height/2) |
|
1845 { |
|
1846 aResultIndex = i; |
|
1847 break; |
|
1848 } |
|
1849 } |
|
1850 } |
|
1851 |
|
1852 return (aResultIndex != -1)? ETrue: EFalse; |
|
1853 } |
|
1854 |
|
1855 |
|
1856 // --------------------------------------------------------- |
|
1857 // CImagicContainerBrowser::ConvertCoordsFromScreen2OGl( |
|
1858 // const TPoint aPos, FloatCoords& aCoord) |
|
1859 // --------------------------------------------------------- |
|
1860 // |
|
1861 FloatCoords CImagicContainerBrowser::ConvertCoordsFromScreen2OGl(const TPoint aPos) |
|
1862 { |
|
1863 // Calculte OpenGL coords in current image for OneByOne view |
|
1864 TSize size = this->Size(); |
|
1865 FloatCoords coord; |
|
1866 |
|
1867 // OpenGL coord (-0.5 - +0.5) = (relative position in screen) * (coordinate system) |
|
1868 coord.iX = (((float)aPos.iX / size.iWidth ) - 0.5) * (iDrawOneByOne->GetDrawOneByOneWidth() * 2); |
|
1869 coord.iY = (((float)aPos.iY / size.iHeight) - 0.5) * (iDrawOneByOne->GetDrawOneByOneHeight() * 2); |
|
1870 |
|
1871 // RDebug::Print(_L("ConvertCoordsFromScreen2OGl: aPos(%d,%d)/size(%d,%d)*ortho(%6.4f,%6.4f) = coord(%6.4f,%6.4f)"), |
|
1872 // aPos.iX, aPos.iY, size.iWidth, size.iHeight, iDrawOnebyOneW, iDrawOnebyOneH, coord.iX, coord.iY); |
|
1873 |
|
1874 // scale -> translate -> rotate when display |
|
1875 // translate -> scale on calculation. TODO: rotate needs to be considered. |
|
1876 coord.iX = (coord.iX + iDrawOneByOne->GetDrawOneByOneXY().iX) / iDrawOneByOne->GetDrawOneByOneZoom(); |
|
1877 coord.iY = (coord.iY - iDrawOneByOne->GetDrawOneByOneXY().iY) / iDrawOneByOne->GetDrawOneByOneZoom(); |
|
1878 |
|
1879 // RDebug::Print(_L("ConvertCoordsFromScreen2OGl: coord(%6.4f,%6.4f)+trans(%6.4f,%6.4f)*zoom(%6.4f)"), |
|
1880 // coord.iX, coord.iY, iDrawOneByOneX, iDrawOneByOneY, iDrawOneByOneZoom); |
|
1881 |
|
1882 return coord; |
|
1883 } |
|
1884 |
|
1885 |
|
1886 // --------------------------------------------------------- |
|
1887 // CImagicContainerBrowser::FindNearestFace( |
|
1888 // const TPoint aPos, TInt& aResultIndex) |
|
1889 // --------------------------------------------------------- |
|
1890 // |
|
1891 TBool CImagicContainerBrowser::FindNearestFace(const TPoint aPos, TInt& aResultIndex) |
|
1892 { |
|
1893 DP0_IMAGIC(_L("CImagicContainerBrowser::FindNearestFace++")); |
|
1894 |
|
1895 // number of faces in current image(iCurrentIndex). iCoordinates must be already set |
|
1896 TInt facecount = iDrawFaceBrowsing->GetFaceCount(); |
|
1897 |
|
1898 TBool isCloseEnough = EFalse; |
|
1899 TBool found = EFalse; |
|
1900 float closestDistance = 0.0; // this is actully square of distance. |
|
1901 |
|
1902 // ConvertScreenCoords2QvgaCoords(TPoint& aPoint, TRect& aRect) |
|
1903 |
|
1904 FloatCoords coord = ConvertCoordsFromScreen2OGl(aPos); |
|
1905 |
|
1906 if(!GetScreenOrientation()) |
|
1907 { |
|
1908 // swap x and y in portrait |
|
1909 float temp = coord.iX; |
|
1910 coord.iX = -coord.iY; |
|
1911 coord.iY = temp ; |
|
1912 } |
|
1913 |
|
1914 DP4_IMAGIC(_L("CImagicContainerBrowser::FindNearestFace: aPos(%d,%d) => Coord(%6.4f,%6.4f)"),aPos.iX,aPos.iY,coord.iX,coord.iY); |
|
1915 |
|
1916 for(TInt i=0; i<facecount; ++i) |
|
1917 { |
|
1918 FloatCoords tmp = iDrawFaceBrowsing->ConvertCoordsFromAlgo2OGl(i); |
|
1919 |
|
1920 DP3_IMAGIC(_L("CImagicContainerBrowser::FindNearestFace: ====> face %d(%6.4f,%6.4f)"), i, tmp.iX,tmp.iY); |
|
1921 |
|
1922 float distance; |
|
1923 float diff_x = Abs(tmp.iX - coord.iX); |
|
1924 float diff_y = Abs(tmp.iY - coord.iY); |
|
1925 |
|
1926 distance = diff_x*diff_x + diff_y*diff_y; |
|
1927 |
|
1928 DP3_IMAGIC(_L("CImagicContainerBrowser::FindNearestFace: diff x=%6.4f, y=%6.4f. distance=%8.5f)"), diff_x, diff_y, distance); |
|
1929 |
|
1930 if (distance < closestDistance || !found) |
|
1931 { |
|
1932 found = ETrue; |
|
1933 aResultIndex = i; |
|
1934 closestDistance = distance; |
|
1935 } |
|
1936 |
|
1937 if (distance < KFindFaceSearchRange) isCloseEnough = ETrue; |
|
1938 } |
|
1939 |
|
1940 DP1_IMAGIC(_L("CImagicContainerBrowser::FindNearestFace(%d)--"), isCloseEnough); |
|
1941 |
|
1942 return isCloseEnough; |
|
1943 } |
|
1944 |
|
1945 |
|
1946 // --------------------------------------------------------- |
|
1947 // CImagicContainerBrowser::HandleGestureBeganL( |
|
1948 // const TPoint& aPos) |
|
1949 // --------------------------------------------------------- |
|
1950 // |
|
1951 void CImagicContainerBrowser::HandleGestureBeganL(const TPoint& aPos) |
|
1952 { |
|
1953 DP0_IMAGIC(_L("CImagicContainerBrowser::HandleGestureBeganL")); |
|
1954 // do nothing |
|
1955 #ifdef SELECT_ON_TOUCHDOWN |
|
1956 TInt sel; |
|
1957 |
|
1958 if ((iDrawFunction == EGrid) && FindImageInScreen(aPos, sel)) { |
|
1959 iCurrentIndex = sel; |
|
1960 iDrawNow = ETrue; |
|
1961 } |
|
1962 #endif |
|
1963 |
|
1964 #ifdef MOMENTUM_MOVE |
|
1965 iMomentumMove = EFalse; |
|
1966 #endif |
|
1967 |
|
1968 #ifdef RD_FACEFRAME |
|
1969 //iDrawFaceFrame = ETrue; |
|
1970 iDrawNow = ETrue; |
|
1971 #endif |
|
1972 } |
|
1973 |
|
1974 // --------------------------------------------------------- |
|
1975 // CImagicContainerBrowser::HandleGestureMovedL( |
|
1976 // const TPoint& aPos, const TGestureType aType) |
|
1977 // --------------------------------------------------------- |
|
1978 // |
|
1979 void CImagicContainerBrowser::HandleGestureMovedL(const TPoint& aPos, const TGestureType aType) |
|
1980 { |
|
1981 DP0_IMAGIC(_L("CImagicContainerBrowser::HandleGestureMovedL++")); |
|
1982 |
|
1983 if (IS_GESTURE_TAPnDRAG(aType)) // tap&drag for zoom and rotate |
|
1984 { |
|
1985 DP0_IMAGIC(_L("IS_GESTURE_TAPnDRAG")); |
|
1986 // Gesture movement and coord movement are opposite. EFalse for no wrap |
|
1987 DoTapAndDrag(aPos, aType); |
|
1988 } |
|
1989 else if (IS_GESTURE_DRAG(aType)) // just a drag. not Tap and Drag |
|
1990 { |
|
1991 DP0_IMAGIC(_L("IS_GESTURE_DRAG")); |
|
1992 // actions for dragging |
|
1993 // This drag event occurs even finger movement is still within tap threshold |
|
1994 DoDrag(aPos, aType); |
|
1995 #ifdef HOLD_SELECTION_ONDRAG |
|
1996 iHoldSelection = ETrue; |
|
1997 #endif |
|
1998 } |
|
1999 else if (IS_GESTURE_CURSORSIMULATION(aType)) |
|
2000 { |
|
2001 DP0_IMAGIC(_L("IS_GESTURE_CURSORSIMULATION")); |
|
2002 DoCursorSimulation(aPos, aType); |
|
2003 } |
|
2004 else if (IS_GESTURE_LONGTAPPING(aType)) |
|
2005 { |
|
2006 DP0_IMAGIC(_L("IS_GESTURE_LONGTAPPING")); |
|
2007 DoLongTapping(aPos, aType); |
|
2008 } |
|
2009 |
|
2010 DP0_IMAGIC(_L("CImagicContainerBrowser::HandleGestureMovedL--")); |
|
2011 } |
|
2012 |
|
2013 // --------------------------------------------------------- |
|
2014 // CImagicContainerBrowser::HandleGestureEndedL( |
|
2015 // const TPoint& aPos, const TGestureType aType) |
|
2016 // --------------------------------------------------------- |
|
2017 // |
|
2018 void CImagicContainerBrowser::HandleGestureEndedL(const TPoint& aPos, const TGestureType aType) |
|
2019 { |
|
2020 #ifdef HOLD_SELECTION_ONDRAG |
|
2021 // User doesn't touching screen and auto-move can start |
|
2022 iHoldSelection = EFalse; |
|
2023 #endif |
|
2024 #ifdef RD_FACEFRAME |
|
2025 //iDrawFaceFrame = EFalse; |
|
2026 #endif |
|
2027 |
|
2028 // TODO: FIXME: unno temp fix endless cursor movement. |
|
2029 // These need to be set false when key was released. TODO: how to do in dragging in touch... |
|
2030 iTouchMoveData.iRight = EFalse; |
|
2031 iTouchMoveData.iLeft = EFalse; |
|
2032 iTouchMoveData.iUp = EFalse; |
|
2033 iTouchMoveData.iDown = EFalse;//*mika* |
|
2034 |
|
2035 iOnTheEdge=EFalse; |
|
2036 |
|
2037 if (IS_GESTURE_SINGLETAP(aType)) |
|
2038 { |
|
2039 DoSingleTap(aPos, aType); |
|
2040 } |
|
2041 else if (IS_GESTURE_DOUBLETAP(aType)) |
|
2042 { |
|
2043 DoDoubleTap(aPos, aType); |
|
2044 } |
|
2045 else if (IS_GESTURE_LONGTAP(aType)) |
|
2046 { |
|
2047 DoLongTap(aPos, aType); |
|
2048 } |
|
2049 else // Then DoFlick if not single/double tap |
|
2050 { |
|
2051 DoFlick(aPos, aType); |
|
2052 } |
|
2053 |
|
2054 // Disable MagGlass when user releases finger |
|
2055 ShowMagGlass(EFalse); |
|
2056 |
|
2057 //Set normal display draw speed if we were in low draw freq |
|
2058 #ifdef USE_LOW_DRAW_SPEED_WHILE_LOADING |
|
2059 SetDrawFreqToNormal(KTouchDelay); |
|
2060 #endif |
|
2061 } |
|
2062 |
|
2063 void CImagicContainerBrowser::DoTapAndDrag(const TPoint& /*aPos*/, const TGestureType aType) |
|
2064 { |
|
2065 #ifdef TAP_AND_GESTURE |
|
2066 // unno experimental code |
|
2067 if (aType & EGestureUp) |
|
2068 { |
|
2069 iTouchMoveData.iZoomOut=ETrue; |
|
2070 iDrawNow = ETrue; |
|
2071 } |
|
2072 if (aType & EGestureDown) |
|
2073 { |
|
2074 iTouchMoveData.iZoomIn=ETrue; |
|
2075 iDrawNow = ETrue; |
|
2076 } |
|
2077 if (aType & EGestureLeft) |
|
2078 { |
|
2079 iTouchMoveData.iRotate -= 1; |
|
2080 iDrawNow = ETrue; |
|
2081 } |
|
2082 if (aType & EGestureRight) |
|
2083 { |
|
2084 iTouchMoveData.iRotate += 1; |
|
2085 iDrawNow = ETrue; |
|
2086 } |
|
2087 #endif |
|
2088 } |
|
2089 |
|
2090 void CImagicContainerBrowser::DoCursorSimulation(const TPoint& /*aPos*/, const TGestureType aType) |
|
2091 { |
|
2092 DP0_IMAGIC(_L("CImagicContainerBrowser::DoCursorSimulation++")); |
|
2093 |
|
2094 TInt x = 0, y = 0; |
|
2095 TBool wrap = (iDrawFunction == EGrid)? EFalse: ETrue; |
|
2096 |
|
2097 // do nothing if it's in the mode with no cursor simulation |
|
2098 #ifndef CURSORSIMULATION_IN_GRID |
|
2099 if (iDrawFunction == EGrid) return; |
|
2100 #endif |
|
2101 |
|
2102 #ifndef CURSORSIMULATION_IN_ONEBYONE |
|
2103 #ifdef HOLD_SELECTION_ONDRAG |
|
2104 if (iDrawFunction == EOneByOne) return; |
|
2105 #else |
|
2106 if (((iDrawFunction == EOneByOne) && (!IS_NOT_IN_ZOOM_ONEBYONE))) return; |
|
2107 |
|
2108 // allow only left&right to move prev/next image. (do nothing if up or down) |
|
2109 if((iDrawFunction == EOneByOne) && ((aType & EGestureUp) || (aType & EGestureDown))) return; |
|
2110 #endif // HOLD_SELECTION_ONDRAG |
|
2111 #endif |
|
2112 |
|
2113 // cursor move for dragging |
|
2114 if (aType & EGestureUp) ++y; |
|
2115 if (aType & EGestureDown) --y; |
|
2116 if (aType & EGestureLeft) ++x; |
|
2117 if (aType & EGestureRight) --x; |
|
2118 |
|
2119 DP3_IMAGIC(_L("CImagicContainerBrowser::DoCursorSimulation : aType=%d, x=%d, y=%d"), aType, x, y); |
|
2120 |
|
2121 if (x || y) // move index only if x or y are changed |
|
2122 MoveIndex(x, y, wrap); |
|
2123 |
|
2124 DP0_IMAGIC(_L("CImagicContainerBrowser::DoCursorSimulation--")); |
|
2125 } |
|
2126 |
|
2127 void CImagicContainerBrowser::DoDrag(const TPoint& aPos, const TGestureType aType) |
|
2128 { |
|
2129 DP0_IMAGIC(_L("CImagicContainerBrowser::DoDrag++")); |
|
2130 |
|
2131 //ResetTouchData();//mika to test if "stucking" problem is fixed |
|
2132 ResetKeyData(); |
|
2133 ResetTouchData(); |
|
2134 ResetDirKeyData(); |
|
2135 |
|
2136 #ifdef HOLD_SELECTION_ONDRAG |
|
2137 float minX, maxX, minY, maxY; |
|
2138 TInt num = iIEngine->GetTotalNumOfImages(); |
|
2139 #endif |
|
2140 #ifndef CURSORSIMULATION_IN_ONEBYONE |
|
2141 TSize size = this->Size(); |
|
2142 FloatCoords coord; |
|
2143 #endif |
|
2144 |
|
2145 // do nothing if it's stationally (not beyond tap threshold) |
|
2146 if (IS_GESTURE_STATIONARY(aType)) return; |
|
2147 |
|
2148 //iDrawNow = ETrue; |
|
2149 |
|
2150 switch (iDrawFunction) |
|
2151 { |
|
2152 case EGrid: |
|
2153 #ifdef HOLD_SELECTION_ONDRAG |
|
2154 // Drag to shift view |
|
2155 coord.iX = (GLfloat)aPos.iX / 120; //160; // TODO: calc right value from z coord & scale |
|
2156 coord.iY = (GLfloat)aPos.iY / 90; //120; // TODO: calc right value from z coord & scale |
|
2157 |
|
2158 minX = -KSpacingX/2; // allow to move one-picture-size away from the edge |
|
2159 maxX = +KSpacingX/2 + GetMaxX(); |
|
2160 |
|
2161 minY = 0; // don't allow to move away from the edge |
|
2162 maxY = (CImagicContainerBrowser::KGridSizeY-1)*KSpacingY; |
|
2163 |
|
2164 if (iDrawGrid->GetGridXY().iX < minX - minX || maxX + minX < iDrawGrid->GetGridXY().iX) coord.iX /= 3; |
|
2165 if (iDrawGrid->GetGridXY().iY < minY - minY || maxY + minY < iDrawGrid->GetGridXY().iY) coord.iY /= 3; |
|
2166 |
|
2167 TGridXY tmp = iDrawGrid->GetGridXY(); |
|
2168 tmp.iX -= coord.iX; |
|
2169 tmp.iY -= coord.iY; |
|
2170 CheckLimits(tmp.iX, minX, maxX); |
|
2171 CheckLimits(tmp.iY, minY, maxY); |
|
2172 iDrawGrid->SetGridXY(tmp); |
|
2173 #endif |
|
2174 break; |
|
2175 case EOneByOne: |
|
2176 #ifndef CURSORSIMULATION_IN_ONEBYONE |
|
2177 if (!IS_NOT_IN_ZOOM_ONEBYONE) |
|
2178 { |
|
2179 // Drag only in zoomed image |
|
2180 coord.iX = (((float)aPos.iX / size.iWidth ) * (iDrawOneByOne->GetDrawOneByOneWidth() * 2)) / iDrawOneByOne->GetDrawOneByOneZoom(); |
|
2181 coord.iY = (((float)aPos.iY / size.iHeight) * (iDrawOneByOne->GetDrawOneByOneHeight() * 2)) / iDrawOneByOne->GetDrawOneByOneZoom(); |
|
2182 |
|
2183 iDrawOneByOne->ChangeDrawOneByOneTargetX(-coord.iX); |
|
2184 iDrawOneByOne->ChangeDrawOneByOneTargetY(-coord.iY); |
|
2185 } |
|
2186 #ifdef HOLD_SELECTION_ONDRAG |
|
2187 else if (!iDrawOneByOne->IsMagGlassOn() /*iMagGlassOn*/) // not in zoom, magglass off |
|
2188 { |
|
2189 // drag in x coord direction to move prev/next image |
|
2190 coord.iX = (((float)aPos.iX / size.iWidth ) * (iDrawOneByOne->GetDrawOneByOneWidth() * 2)) / iDrawOneByOne->GetDrawOneByOneZoom(); |
|
2191 //iOneByOneFlow += coord.iX; |
|
2192 float tmp = iDrawOneByOne->GetImgeFlowLocation(); |
|
2193 tmp+=coord.iX; |
|
2194 iDrawOneByOne->SetImgeFlowLocation(tmp); |
|
2195 |
|
2196 iOneByOneSlideByDrag = ETrue; |
|
2197 DP1_IMAGIC(_L("Sliding iOneByOneFlow=%6.4f"), iDrawOneByOne->GetImgeFlowLocation()); |
|
2198 } |
|
2199 #endif // HOLD_SELECTION_ONDRAG |
|
2200 #endif |
|
2201 break; |
|
2202 case EFaceBrowser: |
|
2203 // TODO: Integrate face browing and dragging! |
|
2204 |
|
2205 DP0_IMAGIC(_L("CImagicContainerBrowser::DoDrag - EFaceBrowser")); |
|
2206 //DoFlick(aPos, aType); |
|
2207 default: |
|
2208 break; |
|
2209 } |
|
2210 |
|
2211 iDrawNow = ETrue; |
|
2212 |
|
2213 DP0_IMAGIC(_L("CImagicContainerBrowser::DoDrag--")); |
|
2214 |
|
2215 } |
|
2216 |
|
2217 void CImagicContainerBrowser::DoFlick(const TPoint& aPos, const TGestureType aType) |
|
2218 { |
|
2219 DP0_IMAGIC(_L("CImagicContainerBrowser::DoFlick++")); |
|
2220 |
|
2221 //ResetTouchData();//mika to test if "stucking" problem is fixed |
|
2222 |
|
2223 #ifndef CURSORSIMULATION_IN_ONEBYONE |
|
2224 TSize size = this->Size(); |
|
2225 FloatCoords coord; |
|
2226 #endif |
|
2227 #ifdef MOMENTUM_MOVE |
|
2228 float vX, vY, tX, tY; |
|
2229 float minX, maxX; |
|
2230 #ifndef FLICK_ONLY_IN_X_IN_GRID |
|
2231 float minY, maxY; |
|
2232 #endif |
|
2233 TInt x, y, absX, absY; |
|
2234 TBool valid_x, valid_y; |
|
2235 TInt num = iIEngine->GetTotalNumOfImages(); |
|
2236 #endif |
|
2237 |
|
2238 iDrawNow = ETrue; |
|
2239 |
|
2240 switch (iDrawFunction) |
|
2241 { |
|
2242 case EGrid: |
|
2243 DP0_IMAGIC(_L("CImagicContainerBrowser::DoFlick - EGrid")); |
|
2244 #ifdef MOMENTUM_MOVE |
|
2245 // TODO: FIXME: Good value needed. Not 180. Consider non-liner speed. |
|
2246 // TODO: 128 should be the size of images in Screen (pixels) at z = 0 (not zoomed) |
|
2247 const TInt FLICKUNIT=128; // movement of 128 px/s = 1 flick unit speed |
|
2248 //const TInt FLICK_2ND_GEAR = 8; |
|
2249 const TInt FLICK_2ND_GEAR = 16; |
|
2250 const TInt FLICK_3ND_GEAR = 8; |
|
2251 x = aPos.iX; |
|
2252 y = aPos.iY; |
|
2253 absX = Abs(x); |
|
2254 absY = Abs(y); |
|
2255 |
|
2256 valid_x = (absX && (absX * 5 > absY * 3))? ETrue: EFalse; |
|
2257 valid_y = (absY && (absY * 5 > absX * 4))? ETrue: EFalse; |
|
2258 |
|
2259 if (!valid_x || (absX < FLICKUNIT / 3)) |
|
2260 { |
|
2261 vX = tX = 0.0f; |
|
2262 } |
|
2263 else if (absX < FLICKUNIT) |
|
2264 { |
|
2265 vX = ((float)x / absX) * KSpacingX; |
|
2266 tX = ( x / absX) * KSpacingX; |
|
2267 |
|
2268 if (tX>0 && iDrawGrid->GetGridTargetXY().iX < iDrawGrid->GetGridXY().iX) tX = 0; |
|
2269 if (tX<0 && iDrawGrid->GetGridTargetXY().iX > iDrawGrid->GetGridXY().iX) tX = 0; |
|
2270 } |
|
2271 else if (absX < FLICKUNIT * FLICK_2ND_GEAR) |
|
2272 { |
|
2273 vX = ((float)x / FLICKUNIT) * KSpacingX; |
|
2274 tX = ( x / FLICKUNIT) * KSpacingX; |
|
2275 } |
|
2276 else |
|
2277 { |
|
2278 float u = absX / FLICKUNIT; |
|
2279 float v = u*u - 2*FLICK_3ND_GEAR*u + FLICK_3ND_GEAR*FLICK_3ND_GEAR + FLICK_3ND_GEAR; |
|
2280 if (x < 0) v = -v; |
|
2281 vX = ((float)v) * KSpacingX; |
|
2282 tX = ( v) * KSpacingX; |
|
2283 } |
|
2284 |
|
2285 vY = (valid_y)? ((float)y / FLICKUNIT) * KSpacingY: 0.0f; |
|
2286 tY = (valid_y)? ( y / FLICKUNIT) * KSpacingY: 0.0f; |
|
2287 |
|
2288 DP4_IMAGIC(_L("vX/Y=(%6.4f, %6.4f), tX/Y=(%6.4f,%6.4f)"), vX, vY, tX, tY); |
|
2289 DP2_IMAGIC(_L("aPos.iX/Y=(%d,%d)"), aPos.iX, aPos.iY); |
|
2290 |
|
2291 iMomentumMove = ETrue; |
|
2292 |
|
2293 iMomentumSpeedX = Abs(vX); |
|
2294 //iDrawGridTargetX += (-tX); |
|
2295 TGridXY tmp = iDrawGrid->GetGridTargetXY(); |
|
2296 tmp.iX += (-tX); |
|
2297 |
|
2298 minX = -KSpacingX/2; // allow to move one-picture-size away from the edge |
|
2299 maxX = +KSpacingX/2 + GetMaxX(); |
|
2300 |
|
2301 //CheckLimits(iDrawGridTargetX, minX, maxX); |
|
2302 CheckLimits(tmp.iX, minX, maxX); |
|
2303 iDrawGrid->SetGridTargetXY(tmp); |
|
2304 |
|
2305 #ifndef FLICK_ONLY_IN_X_IN_GRID |
|
2306 iMomentumSpeedY = Abs(vY); |
|
2307 iDrawGridTargetY += (-tY); |
|
2308 minY = 0; // don't allow to move away from the edge |
|
2309 maxY = (iGridSizeY-1)*KSpacingY; |
|
2310 CheckLimits(iDrawGridTargetY, minY, maxY); |
|
2311 #else |
|
2312 iMomentumSpeedY = 0; |
|
2313 #endif |
|
2314 #endif |
|
2315 break; |
|
2316 case EOneByOne: |
|
2317 DP0_IMAGIC(_L("CImagicContainerBrowser::DoFlick - EOneByOne")); |
|
2318 |
|
2319 #ifndef CURSORSIMULATION_IN_ONEBYONE |
|
2320 vX = (float)aPos.iX / 2; // pixels of movement in 0.5 sec |
|
2321 vY = (float)aPos.iY / 2; |
|
2322 |
|
2323 coord.iX = ((vX / size.iWidth ) * (iDrawOneByOne->GetDrawOneByOneWidth() * 2)) / iDrawOneByOne->GetDrawOneByOneZoom(); |
|
2324 coord.iY = ((vY / size.iHeight) * (iDrawOneByOne->GetDrawOneByOneHeight() * 2)) / iDrawOneByOne->GetDrawOneByOneZoom(); |
|
2325 |
|
2326 iDrawOneByOne->ChangeDrawOneByOneTargetX(-coord.iX); |
|
2327 iDrawOneByOne->ChangeDrawOneByOneTargetY(-coord.iY); |
|
2328 |
|
2329 #endif |
|
2330 #ifdef HOLD_SELECTION_ONDRAG |
|
2331 // Find current index if sliding is done by dragging in OneByOne view |
|
2332 // iOneByOneSlideByDrag is set EFalse in HandleMovingKeysOneByOne() |
|
2333 // Flick is not currently affecting even though this is in DoFlick() |
|
2334 DP2_IMAGIC(_L("Checking iOneByOneSlideByDrag (%d), iOneByOneFlow=%6.4f"), iOneByOneSlideByDrag, iDrawOneByOne->GetImgeFlowLocation()); |
|
2335 if (iOneByOneSlideByDrag) |
|
2336 { |
|
2337 if (iDrawOneByOne->GetImgeFlowLocation() > +KOneByOneSpacing / 10) |
|
2338 MoveIndex(-1, 0, ETrue); |
|
2339 if (iDrawOneByOne->GetImgeFlowLocation() < -KOneByOneSpacing / 10) |
|
2340 MoveIndex(+1, 0, ETrue); |
|
2341 } |
|
2342 #endif |
|
2343 break; |
|
2344 case EFaceBrowser: |
|
2345 DP0_IMAGIC(_L("CImagicContainerBrowser::DoFlick - EFaceBrowser")); |
|
2346 if(GetScreenOrientation()) |
|
2347 { |
|
2348 if (aType & EGestureLeft) MoveIndex( 1, 0, ETrue); |
|
2349 if (aType & EGestureRight) MoveIndex(-1, 0, ETrue); |
|
2350 } |
|
2351 else |
|
2352 { |
|
2353 if (aType & EGestureDown) MoveIndex( 1, 0, ETrue); |
|
2354 if (aType & EGestureUp) MoveIndex(-1, 0, ETrue); |
|
2355 } |
|
2356 break; |
|
2357 default: |
|
2358 break; |
|
2359 } |
|
2360 |
|
2361 //ResetTouchData();//mika to test if "stucking" problem is fixed |
|
2362 |
|
2363 DP0_IMAGIC(_L("CImagicContainerBrowser::DoFlick--")); |
|
2364 } |
|
2365 |
|
2366 void CImagicContainerBrowser::DoSingleTap(const TPoint& aPos, const TGestureType /*aType*/) |
|
2367 { |
|
2368 DP0_IMAGIC(_L("CImagicContainerBrowser::DoSingleTap++")); |
|
2369 |
|
2370 //ResetTouchData();//mika to test if "stucking" problem is fixed |
|
2371 |
|
2372 TInt sel; |
|
2373 |
|
2374 switch (iDrawFunction) |
|
2375 { |
|
2376 case EGrid: |
|
2377 if (FindImageInScreen(aPos, sel)) // do nothing if user touches none |
|
2378 { |
|
2379 if (iCurrentIndex == sel) |
|
2380 { |
|
2381 SelectIndex(); // Open image if user touches current image |
|
2382 } |
|
2383 else |
|
2384 { |
|
2385 iCurrentIndex = sel; // focus touched image if it's not current one |
|
2386 iDrawNow = ETrue; |
|
2387 } |
|
2388 } |
|
2389 break; |
|
2390 case EOneByOne: |
|
2391 // TODO: Add face browsing by signle tap, maybe on zoom? |
|
2392 DP1_IMAGIC(_L("DoSingleTap:iDrawOneByOneZoom=%6.4f"), iDrawOneByOne->GetDrawOneByOneZoom()); |
|
2393 if (IS_NOT_IN_ZOOM_ONEBYONE) |
|
2394 { |
|
2395 /*TInt dx = 50 - aPos.iX; |
|
2396 TInt dy = 50 - aPos.iY; |
|
2397 |
|
2398 // start face browing if user taps at top left when face icon is shown |
|
2399 if (iFaceExists && (dx*dx + dy*dy < 50*50)) |
|
2400 iView->HandleCommandL(EImagicCmdViewFaceBrowsing); |
|
2401 else*/ |
|
2402 SelectIndex(); // exits only when non zoomed. |
|
2403 } |
|
2404 #ifdef SINGLETAP_CLOSE_IN_ZOOM |
|
2405 else |
|
2406 { |
|
2407 // Stop zooming if it's in zoom |
|
2408 //iDrawOneByOne->SetDrawOneByOneTargetZoom(KDoubleTapZoomOneByOne1);//mika, single tap disabled in zzomed in picture |
|
2409 iDrawNow = ETrue; |
|
2410 } |
|
2411 #endif |
|
2412 break; |
|
2413 case EFaceBrowser: |
|
2414 #ifdef SINGLETAP_CLOSE_IN_ZOOM |
|
2415 // TODO: FIXME. Temporary hack to start OnebyOne view. Pretend it's grid and do select action |
|
2416 //iDrawFunction = EGrid; |
|
2417 //SetDrawMode(EGrid); |
|
2418 /*SelectIndex(); |
|
2419 SetDrawMode(EOneByOne);*/ |
|
2420 |
|
2421 #endif |
|
2422 break; |
|
2423 default: |
|
2424 break; |
|
2425 } |
|
2426 |
|
2427 DP0_IMAGIC(_L("CImagicContainerBrowser::DoSingleTap--")); |
|
2428 |
|
2429 } |
|
2430 |
|
2431 void CImagicContainerBrowser::DoDoubleTap(const TPoint& aPos, const TGestureType /*aType*/) |
|
2432 { |
|
2433 DP0_IMAGIC(_L("CImagicContainerBrowser::DoDoubleTap++")); |
|
2434 |
|
2435 //ResetTouchData();//mika to test if "stucking" problem is fixed |
|
2436 |
|
2437 #ifdef DOUBLETAP_SELECT_IN_GRID |
|
2438 TInt sel; |
|
2439 #endif |
|
2440 iDrawNow = ETrue; |
|
2441 |
|
2442 switch (iDrawFunction) |
|
2443 { |
|
2444 #define TOGGLE_VALUE(tgt, val1, val2) (tgt)=((tgt)!=(val1))?(val1):(val2) |
|
2445 case EGrid: |
|
2446 #ifdef DOUBLETAP_SELECT_IN_GRID |
|
2447 if (FindImageInScreen(aPos, sel)) // do nothing if user touches none |
|
2448 { |
|
2449 iCurrentIndex = sel; // focus touched image if it's not current one |
|
2450 SelectIndex(); // Open image if user touches current image |
|
2451 } |
|
2452 #endif |
|
2453 #ifdef ENABLE_GRID_ZOOM |
|
2454 #ifdef DOUBLETAP_ZOOMGRID |
|
2455 TOGGLE_VALUE(iDrawGridTargetZoom, KDoubleTapZoomGrid1, KDoubleTapZoomGrid2); |
|
2456 #endif |
|
2457 #endif |
|
2458 break; |
|
2459 case EOneByOne: |
|
2460 #ifdef DOUBLETAP_FACEBROWSING |
|
2461 if (IS_NOT_IN_ZOOM_ONEBYONE) |
|
2462 { |
|
2463 iView->HandleCommandL(EImagicCmdViewFaceBrowsingWithCoordinates); |
|
2464 } |
|
2465 #endif |
|
2466 // toggle zooming on and off if MagGlass is off |
|
2467 if(!iDrawOneByOne->IsMagGlassOn()/*iMagGlassOn*/) |
|
2468 { |
|
2469 //TOGGLE_VALUE(iDrawOneByOneTargetZoom, KDoubleTapZoomOneByOne1, KDoubleTapZoomOneByOne2); |
|
2470 if(iDrawOneByOne->GetDrawOneByOneTargetZoom() == KDoubleTapZoomOneByOne1) |
|
2471 iDrawOneByOne->SetDrawOneByOneTargetZoom(KDoubleTapZoomOneByOne2); |
|
2472 else |
|
2473 iDrawOneByOne->SetDrawOneByOneTargetZoom(KDoubleTapZoomOneByOne1); |
|
2474 } |
|
2475 |
|
2476 if (iDrawOneByOne->GetDrawOneByOneTargetZoom() == KDoubleTapZoomOneByOne2) |
|
2477 { |
|
2478 // if we are zooming in, tapped position is set as center |
|
2479 TSize size = this->Size(); |
|
2480 float imageWidth, imageHeight; |
|
2481 CalculateImageSize(imageWidth, imageHeight, (float)size.iWidth/(float)size.iHeight); |
|
2482 |
|
2483 /*iDrawOneByOneTargetX = (2*iImageWidth) *(((float)aPos.iX / size.iWidth ) - 0.5); |
|
2484 iDrawOneByOneTargetY = (2*iImageHeight)*(((float)aPos.iY / size.iHeight) - 0.5);*/ |
|
2485 TDrawOneByOneXY tmp; |
|
2486 tmp.iX = (2*imageWidth) *(((float)aPos.iX / size.iWidth ) - 0.5); |
|
2487 tmp.iY = (2*imageHeight)*(((float)aPos.iY / size.iHeight) - 0.5); |
|
2488 iDrawOneByOne->SetDrawOneByOneTargetXY(tmp); |
|
2489 |
|
2490 /*if(!GetScreenOrientation()) |
|
2491 { |
|
2492 float tmp = iDrawOneByOneTargetX; |
|
2493 iDrawOneByOneTargetX = -iDrawOneByOneTargetY; |
|
2494 iDrawOneByOneTargetY = tmp; |
|
2495 }*/ |
|
2496 } |
|
2497 break; |
|
2498 case EFaceBrowser: |
|
2499 #ifdef DOUBLETAP_FACEBROWSING |
|
2500 // TODO: FIXME. Temporary hack to start OnebyOne view. Pretend it's grid and do select action |
|
2501 //iDrawFunction = EGrid; |
|
2502 drawZoom = 1; inPictureX = 0; inPictureY = 0; |
|
2503 iDrawFaceBrowsing->GetFBZoomAndLocation(drawZoom, inPictureX, inPictureY); |
|
2504 iDrawOneByOne->InitDrawOnebyOne(drawZoom, inPictureX, inPictureY); |
|
2505 |
|
2506 SelectIndex(); |
|
2507 SetDrawMode(EOneByOne/*EGrid*/); |
|
2508 #endif |
|
2509 break; |
|
2510 } |
|
2511 |
|
2512 DP0_IMAGIC(_L("CImagicContainerBrowser::DoDoubleTap--")); |
|
2513 } |
|
2514 |
|
2515 void CImagicContainerBrowser::DoLongTapping(const TPoint& aPos, const TGestureType aType) |
|
2516 { |
|
2517 DP1_IMAGIC(_L("CImagicContainerBrowser::DoLongTapping aPos.iX: %d"), aPos.iX); |
|
2518 DP1_IMAGIC(_L("CImagicContainerBrowser::DoLongTapping aPos.iY: %d"), aPos.iY); |
|
2519 |
|
2520 //ResetTouchData();//mika to test if "stucking" problem is fixed |
|
2521 |
|
2522 // touch movement is stationary for enough long time |
|
2523 switch (iDrawFunction) |
|
2524 { |
|
2525 case EOneByOne: |
|
2526 ShowMagGlass(ETrue); |
|
2527 break; |
|
2528 case EGrid: |
|
2529 iView->ProcessCommandL(EAknSoftkeyOptions); |
|
2530 /*TInt sel; |
|
2531 if (FindImageInScreen(aPos, sel)) // do nothing if user touches none |
|
2532 { |
|
2533 if (iCurrentIndex == sel) |
|
2534 { |
|
2535 iView->ProcessCommandL(EAknSoftkeyOptions); |
|
2536 //iView->ProcessCommandL(EImagicCmdViewBrowserShowImageInfo); |
|
2537 } |
|
2538 }*/ |
|
2539 |
|
2540 /*else if(aPos.iX > 100) |
|
2541 { |
|
2542 iView->ProcessCommandL(EAknSoftkeyOptions); |
|
2543 }*/ |
|
2544 #if 0 |
|
2545 else |
|
2546 { |
|
2547 //iView->ProcessCommandL(EAknSoftkeyOptions); |
|
2548 } |
|
2549 #endif |
|
2550 //iView->ProcessCommandL(EAknSoftkeyOptions);//TODO, options should be shown from softkeys |
|
2551 break; |
|
2552 |
|
2553 case EFaceBrowser: |
|
2554 break; |
|
2555 default: |
|
2556 // do nothing |
|
2557 break; |
|
2558 } |
|
2559 |
|
2560 iDrawNow = ETrue; |
|
2561 |
|
2562 } |
|
2563 |
|
2564 void CImagicContainerBrowser::DoLongTap(const TPoint& aPos, const TGestureType aType) |
|
2565 { |
|
2566 // do nothing so far. |
|
2567 iDrawNow = ETrue; |
|
2568 } |
|
2569 |
|
2570 // --------------------------------------------------------- |
|
2571 // CImagicContainerBrowser::MoveIndex( |
|
2572 // TInt aMoveX, TInt aMoveY, TBool aWrap) |
|
2573 // --------------------------------------------------------- |
|
2574 // |
|
2575 void CImagicContainerBrowser::MoveIndex(TInt aMoveX, TInt aMoveY, TBool aWrap) |
|
2576 { |
|
2577 DP0_IMAGIC(_L("CImagicContainerBrowser::MoveIndex++")); |
|
2578 |
|
2579 TInt num = iIEngine->GetTotalNumOfImages(); |
|
2580 // Reset key data |
|
2581 iTouchMoveData.iRight = EFalse; |
|
2582 iTouchMoveData.iLeft = EFalse; |
|
2583 iTouchMoveData.iUp = EFalse; |
|
2584 iTouchMoveData.iDown = EFalse;//*mika* |
|
2585 iTouchMoveData.iX = 0; |
|
2586 iTouchMoveData.iY = 0; |
|
2587 |
|
2588 if (aMoveX < 0) // left key press |
|
2589 { |
|
2590 if (aWrap || iCurrentIndex >= CImagicContainerBrowser::KGridSizeY) |
|
2591 { |
|
2592 if(iDrawFunction == EFaceBrowser) |
|
2593 //iFaceNro--; // prev face in face browser |
|
2594 iDrawFaceBrowsing->DecFaceNumber(); |
|
2595 else |
|
2596 { |
|
2597 iTouchMoveData.iX = aMoveX; |
|
2598 iTouchMoveData.iLeft = ETrue; |
|
2599 } |
|
2600 iDrawNow = ETrue; |
|
2601 } |
|
2602 } |
|
2603 |
|
2604 if (aMoveX > 0) // right key press |
|
2605 { |
|
2606 if (aWrap || iCurrentIndex < num - CImagicContainerBrowser::KGridSizeY) |
|
2607 { |
|
2608 if(iDrawFunction == EFaceBrowser) |
|
2609 //iFaceNro++; // next face in face browser |
|
2610 iDrawFaceBrowsing->IncFaceNumber(); |
|
2611 else |
|
2612 { |
|
2613 iTouchMoveData.iX = aMoveX; |
|
2614 iTouchMoveData.iRight = ETrue; |
|
2615 } |
|
2616 iDrawNow = ETrue; |
|
2617 } |
|
2618 } |
|
2619 |
|
2620 if (aMoveY < 0) // up key press |
|
2621 { |
|
2622 if (aWrap || iCurrentIndex % CImagicContainerBrowser::KGridSizeY > 0) |
|
2623 { |
|
2624 iTouchMoveData.iY = aMoveY; |
|
2625 iTouchMoveData.iUp = ETrue; |
|
2626 iDrawNow = ETrue; |
|
2627 } |
|
2628 } |
|
2629 |
|
2630 if (aMoveY > 0) // down key press |
|
2631 { |
|
2632 if ( aWrap || |
|
2633 ((iCurrentIndex % CImagicContainerBrowser::KGridSizeY < CImagicContainerBrowser::KGridSizeY - 1) && |
|
2634 (iCurrentIndex < num - 1))) |
|
2635 { |
|
2636 iTouchMoveData.iY = aMoveY; |
|
2637 iTouchMoveData.iDown = ETrue; |
|
2638 iDrawNow = ETrue; |
|
2639 } |
|
2640 } |
|
2641 |
|
2642 DP0_IMAGIC(_L("CImagicContainerBrowser::MoveIndex--")); |
|
2643 } |
|
2644 |
|
2645 // --------------------------------------------------------- |
|
2646 // CImagicContainerBrowser::SelectIndex( |
|
2647 // void) |
|
2648 // --------------------------------------------------------- |
|
2649 // |
|
2650 void CImagicContainerBrowser::SelectIndex(void) |
|
2651 { |
|
2652 DP0_IMAGIC(_L("CImagicContainerBrowser::SelectIndex++")); |
|
2653 |
|
2654 iDrawNow = ETrue; |
|
2655 |
|
2656 if(iDrawFunction == EGrid) |
|
2657 { |
|
2658 //Open one by one mode |
|
2659 iDrawOneByOne->InitDrawOnebyOne(KInitDrawZoom/*drawZoom*/, inPictureX, inPictureY); |
|
2660 |
|
2661 //Set Grid view |
|
2662 if(iDrawFunction == EFaceBrowser) |
|
2663 { |
|
2664 //iDrawFunction = EGrid; |
|
2665 SetDrawMode(EGrid); |
|
2666 } |
|
2667 |
|
2668 iView->SetFaceBrowsingMode(EFaceBrowserNone); |
|
2669 } |
|
2670 else if(iDrawFunction == EOneByOne) |
|
2671 { |
|
2672 /*#ifdef SUPERZOOM |
|
2673 //Unload high res textures when going back to Grid |
|
2674 CImageData* aGridData = iIEngine->GetImageData(iCurrentIndex); |
|
2675 iTextureLoader->ReleaseSuperHResTexture( aGridData ); |
|
2676 #endif*/ |
|
2677 |
|
2678 //Return to previous mode |
|
2679 iDrawGrid->InitDrawGrid(); |
|
2680 //iDrawFunction = iDrawOneByOnePreviousFunc; |
|
2681 //iDrawFunction = EGrid; |
|
2682 SetDrawMode(EGrid); |
|
2683 iView->SetFaceBrowsingMode(EFaceBrowserNone); |
|
2684 } |
|
2685 else if(iDrawFunction == EFaceBrowser) |
|
2686 { |
|
2687 iDrawGrid->InitDrawGrid(); |
|
2688 //iDrawFunction = EGrid; |
|
2689 //SetDrawMode(EGrid); |
|
2690 SetDrawMode(EOneByOne); |
|
2691 } |
|
2692 |
|
2693 DP0_IMAGIC(_L("CImagicContainerBrowser::SelectIndex--")); |
|
2694 } |
|
2695 |
|
2696 //#endif |
|
2697 |
|
2698 void CImagicContainerBrowser::SetLoadingOn(TBool aValue) |
|
2699 { |
|
2700 DP0_IMAGIC(_L("CImagicContainerBrowser::SetLoadingOn++")); |
|
2701 DP1_IMAGIC(_L("CImagicContainerBrowser::SetLoadingOn - value: %d"), aValue); |
|
2702 |
|
2703 iDynamicLoadingOn = aValue; |
|
2704 //iDrawNow = ETrue; |
|
2705 |
|
2706 DP0_IMAGIC(_L("CImagicContainerBrowser::SetLoadingOn--")); |
|
2707 } |
|
2708 |
|
2709 |
|
2710 void CImagicContainerBrowser::ImageLoadedL(TInt aError, CFbsBitmap* aBitmap, TThumbSize aResolution) |
|
2711 { |
|
2712 DP0_IMAGIC(_L("CImagicContainerBrowser::ImageLoadedL++")); |
|
2713 |
|
2714 //Check do we need to unload or load more images ------> |
|
2715 //LoadUnloadImages(); |
|
2716 DynamicUnLoading(); |
|
2717 |
|
2718 TInt mem = 0; |
|
2719 TInt ret = HAL::Get(HALData::EMemoryRAMFree, mem); |
|
2720 DP1_IMAGIC(_L("CImagicContainerBrowser::ImageLoadedL - Free RAM: %d"), mem); |
|
2721 |
|
2722 if(mem <= 16000000){ |
|
2723 DP0_IMAGIC(_L("CImagicContainerBrowser::ImageLoadedL - buffer size: 1")); |
|
2724 K512TNImageBuffer = 1; |
|
2725 } |
|
2726 if(mem <= 20000000){ |
|
2727 DP0_IMAGIC(_L("CImagicContainerBrowser::ImageLoadedL - buffer size: 2")); |
|
2728 K512TNImageBuffer = 2; |
|
2729 } |
|
2730 if(mem > 24000000){ |
|
2731 DP0_IMAGIC(_L("CImagicContainerBrowser::ImageLoadedL - buffer size: 3")); |
|
2732 K512TNImageBuffer = 3; |
|
2733 } |
|
2734 if(mem > 28000000){ |
|
2735 DP0_IMAGIC(_L("CImagicContainerBrowser::ImageLoadedL - buffer size: 4")); |
|
2736 K512TNImageBuffer = 4; |
|
2737 } |
|
2738 if(mem > 32000000){ |
|
2739 DP0_IMAGIC(_L("CImagicContainerBrowser::ImageLoadedL - buffer size: 5")); |
|
2740 K512TNImageBuffer = 5; |
|
2741 } |
|
2742 |
|
2743 if(aResolution == ESize512x512 || aResolution == EFullSize) |
|
2744 { |
|
2745 iPreferHighResLoading = EFalse; |
|
2746 iDynamicLoadingOn = ETrue; |
|
2747 DynamicLoadingL(); |
|
2748 } |
|
2749 |
|
2750 iTextureLoader->ImageLoadedL(aError, aBitmap, iGLMaxRes); |
|
2751 |
|
2752 DP0_IMAGIC(_L("CImagicContainerBrowser::ImageLoadedL--")); |
|
2753 } |
|
2754 |
|
2755 |
|
2756 //This is correcting the aspact ratio to be correct for OpengGL drawing |
|
2757 void CImagicContainerBrowser::SetPictureVertices(CImageData* aData, GLfixed* aVertices) |
|
2758 { |
|
2759 //DP0_IMAGIC(_L("CImagicContainerBrowser::SetPictureVertices")); |
|
2760 |
|
2761 GLfixed vx, vy; |
|
2762 |
|
2763 // Use real image |
|
2764 if(aData->iGridData.iGlLQ128TextIndex != 0 || |
|
2765 aData->iGridData.iGlLQ32TextIndex != 0 || |
|
2766 aData->iGridData.iGlHQ512TextIndex != 0) |
|
2767 { |
|
2768 if(aData->GetAspectRatio() > 1) |
|
2769 { |
|
2770 vx = 1<<15; |
|
2771 vy = (0.5/aData->GetAspectRatio())*(1<<16); |
|
2772 } |
|
2773 else |
|
2774 { |
|
2775 vx = (0.5*aData->GetAspectRatio())*(1<<16); |
|
2776 vy = 1<<15; |
|
2777 } |
|
2778 } |
|
2779 // Use loading image |
|
2780 else |
|
2781 { |
|
2782 vx = 24000; |
|
2783 vy = vx / KLoadingImageAspectRatio; |
|
2784 } |
|
2785 |
|
2786 aVertices[0*2+0] = -vx; |
|
2787 aVertices[0*2+1] = -vy; |
|
2788 |
|
2789 aVertices[1*2+0] = vx; |
|
2790 aVertices[1*2+1] = -vy; |
|
2791 |
|
2792 aVertices[2*2+0] = -vx; |
|
2793 aVertices[2*2+1] = vy; |
|
2794 |
|
2795 aVertices[3*2+0] = vx; |
|
2796 aVertices[3*2+1] = vy; |
|
2797 |
|
2798 } |
|
2799 |
|
2800 void CImagicContainerBrowser::DisplayDeleteQueryDialogL(TInt aResourceId) |
|
2801 { |
|
2802 CAknQueryDialog* dlg; |
|
2803 dlg = new ( ELeave ) CAknQueryDialog(); |
|
2804 TInt result = dlg->ExecuteLD( aResourceId ); |
|
2805 if(result != KErrNone) |
|
2806 { |
|
2807 //Delete file |
|
2808 DeleteImageL(); |
|
2809 } |
|
2810 } |
|
2811 |
|
2812 //Delete current image |
|
2813 void CImagicContainerBrowser::DeleteImageL() |
|
2814 { |
|
2815 DP0_IMAGIC(_L("CImagicContainerBrowser::DeleteImageL++")); |
|
2816 |
|
2817 //Delete image from engine |
|
2818 //Delete grid image from OpenGL memory |
|
2819 //TInt num = iIEngine->GetTotalNumOfImages(); |
|
2820 CImageData* data = iIEngine->GetImageData(iCurrentIndex); |
|
2821 |
|
2822 if(data->iGridData.iGlLQ128TextIndex) |
|
2823 glDeleteTextures( 1, &data->iGridData.iGlLQ128TextIndex ); |
|
2824 if(data->iGridData.iGlLQ32TextIndex) |
|
2825 glDeleteTextures( 1, &data->iGridData.iGlLQ32TextIndex ); |
|
2826 if(data->iGridData.iGlHQ512TextIndex != 0) |
|
2827 glDeleteTextures(1, &data->iGridData.iGlHQ512TextIndex); |
|
2828 if(data->iGridData.iGlSuperHQTextIndex != 0) |
|
2829 glDeleteTextures(1, &data->iGridData.iGlSuperHQTextIndex); |
|
2830 |
|
2831 data->iGridData.iGlLQ32TextIndex = 0; |
|
2832 data->iGridData.iGlLQ128TextIndex = 0; |
|
2833 data->iGridData.iGlHQ512TextIndex = 0; |
|
2834 data->iGridData.iGlSuperHQTextIndex = 0; |
|
2835 |
|
2836 //Delete image from engine |
|
2837 TInt err = iImagicAppUi->DeleteImage(iCurrentIndex); |
|
2838 if (err != KErrNone) |
|
2839 { |
|
2840 iImagicAppUi->GetImagicUtils()->ExecuteQueryDialog(R_CANNOT_DELETE_DIALOG); |
|
2841 } |
|
2842 |
|
2843 iDrawOneByOne->SetDrawOneByOneTargetZoom(1); |
|
2844 iDrawNow = ETrue; |
|
2845 |
|
2846 iDrawGrid->UpdateImageCoordinates(iCurrentIndex); |
|
2847 |
|
2848 if(iIEngine->GetTotalNumOfImages() <= 0) |
|
2849 { |
|
2850 iImagicAppUi->GetImagicUtils()->ExecuteQueryDialog(0, R_NO_IMAGES_DIALOG); |
|
2851 } |
|
2852 |
|
2853 DP0_IMAGIC(_L("CImagicContainerBrowser::DeleteImageL--")); |
|
2854 } |
|
2855 |
|
2856 |
|
2857 |
|
2858 //Returns TRUE if screen is landscape |
|
2859 TBool CImagicContainerBrowser::GetScreenOrientation() |
|
2860 { |
|
2861 //Landscape |
|
2862 #ifdef _ACCELEROMETER_SUPPORTED_ |
|
2863 //if(iDeviceOrientation == EOrientationDisplayLeftUp)//Landscape |
|
2864 if(iDeviceOrientation == EOrientationDisplayLeftUp || iDeviceOrientation == EOrientationDisplayRigthUp)//Landscape |
|
2865 { |
|
2866 DP1_IMAGIC(_L("CImagicContainerBrowser::GetScreenOrientation - Landscape: %d"),iDeviceOrientation); |
|
2867 iDeviceOrientationAngle = 0; |
|
2868 return ETrue; |
|
2869 } |
|
2870 else if(iDeviceOrientation == EOrientationDisplayDown) |
|
2871 { |
|
2872 DP1_IMAGIC(_L("CImagicContainerBrowser::GetScreenOrientation - Portrait: %d"),iDeviceOrientation); |
|
2873 iDeviceOrientationAngle = -90; |
|
2874 return EFalse; |
|
2875 } |
|
2876 #else |
|
2877 if(this->Size().iWidth > this->Size().iHeight) |
|
2878 |
|
2879 { |
|
2880 DP1_IMAGIC(_L("CImagicContainerBrowser::GetScreenOrientation - Landscape: %d"),iDeviceOrientation); |
|
2881 return ETrue; |
|
2882 } |
|
2883 else |
|
2884 { |
|
2885 DP1_IMAGIC(_L("CImagicContainerBrowser::GetScreenOrientation - Portrait: %d"),iDeviceOrientation); |
|
2886 return EFalse; |
|
2887 } |
|
2888 #endif |
|
2889 } |
|
2890 |
|
2891 //This should be called when reading touch UI events or key events to set draw freq to normal |
|
2892 void CImagicContainerBrowser::SetDrawFreqToNormal(TInt aTimerDelay) |
|
2893 { |
|
2894 DP0_IMAGIC(_L("CImagicContainerBrowser::SetDrawFreqToNormal++")); |
|
2895 |
|
2896 //Set normal display draw speed if we were in power save |
|
2897 if(iDisplayDrawFreq == KPowerSaveDisplayDrawFreq) |
|
2898 { |
|
2899 iDisplayDrawFreq = KDisplayDrawFreq; |
|
2900 DisableDisplayDraw(); |
|
2901 if(iImagicAppUi->IsAppOnTop()) |
|
2902 EnableDisplayDraw(); |
|
2903 } |
|
2904 //Reset power save timer |
|
2905 iPowerSavePeriodic->Cancel(); |
|
2906 //And start it again, but only if we are loading images |
|
2907 if(iTextureLoader->IsActiveAndRunning() && iDrawFunction == EGrid) |
|
2908 { |
|
2909 iPowerSavePeriodic->Start(/*KPowerSavePeriodicDelay*/aTimerDelay, KPowerSavePeriodicInterval, TCallBack( CImagicContainerBrowser::PowerSaveCallBack, this ) ); |
|
2910 } |
|
2911 |
|
2912 DP0_IMAGIC(_L("CImagicContainerBrowser::SetDrawFreqToNormal--")); |
|
2913 } |
|
2914 |
|
2915 void CImagicContainerBrowser::ResetZoomKeys() |
|
2916 { |
|
2917 iKeyData.iZoomInKey=EFalse; |
|
2918 iKeyData.iZoomOutKey=EFalse; |
|
2919 } |
|
2920 |
|
2921 |
|
2922 TKeyResponse CImagicContainerBrowser::OfferKeyEventL(const TKeyEvent& aKeyEvent, TEventCode aType) |
|
2923 { |
|
2924 DP0_IMAGIC(_L("CImagicContainerBrowser::OfferKeyEventL")); |
|
2925 |
|
2926 //Set normal display draw speed if we were in low draw freq |
|
2927 #ifdef USE_LOW_DRAW_SPEED_WHILE_LOADING |
|
2928 SetDrawFreqToNormal(KPowerSavePeriodicDelay); |
|
2929 #endif |
|
2930 |
|
2931 //if(iImagicAppUi->IsAppOnTop()) |
|
2932 EnableDisplayDraw(); |
|
2933 |
|
2934 iUserInputGiven = ETrue; |
|
2935 iLastEventFromKeys = ETrue; |
|
2936 |
|
2937 TKeyResponse ret = EKeyWasNotConsumed; |
|
2938 |
|
2939 // Set default values |
|
2940 TInt addValue=0; |
|
2941 TBool pressValue=EFalse; |
|
2942 ResetKeyData(); |
|
2943 ResetTouchData(); |
|
2944 ResetDirKeyData(); |
|
2945 iDrawOneByOne->ChangeDrawOneByOneTargetX(0); |
|
2946 iDrawOneByOne->ChangeDrawOneByOneTargetY(0); |
|
2947 |
|
2948 // Set button as pressed and add press counter by one |
|
2949 if (aType == EEventKey) |
|
2950 { |
|
2951 iDrawGrid->KeyEvent(); |
|
2952 iDrawOneByOne->KeyEvent(); |
|
2953 iDrawFaceBrowsing->KeyEvent(); |
|
2954 |
|
2955 iDrawNow = ETrue; |
|
2956 addValue=1; |
|
2957 pressValue=ETrue; |
|
2958 } |
|
2959 |
|
2960 if (aType == EEventKeyDown) |
|
2961 { |
|
2962 iDrawGrid->KeyPressed(); |
|
2963 iDrawOneByOne->KeyPressed(); |
|
2964 iDrawFaceBrowsing->KeyPressed(); |
|
2965 |
|
2966 /*if(iDrawFunction == EOneByOne && IS_NOT_IN_ZOOM_ONEBYONE) |
|
2967 iDrawOneByOne->InitDrawOnebyOne();*/ |
|
2968 |
|
2969 iIntheEndOfGrid = EFalse; |
|
2970 iOnTheEdge=ETrue; |
|
2971 iKeyPressedDown=ETrue; |
|
2972 pressValue=ETrue; |
|
2973 /// |
|
2974 iDrawNow = ETrue; |
|
2975 addValue=1; |
|
2976 } |
|
2977 |
|
2978 if (aType == EEventKeyUp) |
|
2979 { |
|
2980 iDrawGrid->KeyReleased(); |
|
2981 iDrawOneByOne->KeyReleased(); |
|
2982 iDrawFaceBrowsing->KeyReleased(); |
|
2983 |
|
2984 iOnTheEdge=EFalse; |
|
2985 iKeyPressedDown=EFalse; |
|
2986 pressValue=EFalse; |
|
2987 addValue=0; |
|
2988 //iKeyCounter=0; |
|
2989 |
|
2990 if(iIntheEndOfGrid) |
|
2991 iJumpOver = ETrue; |
|
2992 else |
|
2993 iJumpOver = EFalse; |
|
2994 } |
|
2995 |
|
2996 CImageData* imageData = iIEngine->GetImageData(iCurrentIndex); |
|
2997 TInt imageRotation = 0 - (TReal)imageData->GetOrientation(); |
|
2998 |
|
2999 |
|
3000 //if (aType==EEventKey /*|| aType==EEventKeyUp || aType==EEventKeyDown*/) |
|
3001 // if(iKeyCounter == 0) |
|
3002 { |
|
3003 // Assume that key will be handled |
|
3004 ret = EKeyWasConsumed; |
|
3005 |
|
3006 // Check for key |
|
3007 switch (aKeyEvent.iScanCode) |
|
3008 { |
|
3009 // Vertical movement |
|
3010 case EStdKeyDownArrow: |
|
3011 if(iDrawFunction == EOneByOne && IS_NOT_IN_ZOOM_ONEBYONE){ |
|
3012 } |
|
3013 else{ |
|
3014 iKeyData.iY+=addValue; |
|
3015 iKeyData.iDown=pressValue; |
|
3016 } |
|
3017 #ifdef _ACCELEROMETER_SUPPORTED_ |
|
3018 if((iDeviceOrientation == EOrientationDisplayDown && |
|
3019 iDrawFunction == EFaceBrowser && aType == EEventKey)) |
|
3020 { |
|
3021 iDrawFaceBrowsing->DecFaceNumber(); |
|
3022 } |
|
3023 else if( (iDrawFunction == EFaceBrowser && aType == EEventKey && |
|
3024 (imageRotation == -90 || imageRotation == -270)) ) |
|
3025 { |
|
3026 if(imageRotation == -90) |
|
3027 iDrawFaceBrowsing->DecFaceNumber(); |
|
3028 else |
|
3029 iDrawFaceBrowsing->IncFaceNumber(); |
|
3030 } |
|
3031 |
|
3032 #endif |
|
3033 ResetZoomKeys(); |
|
3034 break; |
|
3035 |
|
3036 case EStdKeyUpArrow: |
|
3037 if(iDrawFunction == EOneByOne && IS_NOT_IN_ZOOM_ONEBYONE){ |
|
3038 } |
|
3039 else{ |
|
3040 iKeyData.iY-=addValue; |
|
3041 iKeyData.iUp=pressValue; |
|
3042 } |
|
3043 #ifdef _ACCELEROMETER_SUPPORTED_ |
|
3044 if((iDeviceOrientation == EOrientationDisplayDown && |
|
3045 iDrawFunction == EFaceBrowser && aType == EEventKey)) |
|
3046 { |
|
3047 iDrawFaceBrowsing->IncFaceNumber(); |
|
3048 } |
|
3049 else if( (iDrawFunction == EFaceBrowser && aType == EEventKey && |
|
3050 (imageRotation == -90 || imageRotation == -270)) ) |
|
3051 { |
|
3052 if(imageRotation == -90) |
|
3053 iDrawFaceBrowsing->IncFaceNumber(); |
|
3054 else |
|
3055 iDrawFaceBrowsing->DecFaceNumber(); |
|
3056 } |
|
3057 |
|
3058 #endif |
|
3059 ResetZoomKeys(); |
|
3060 break; |
|
3061 |
|
3062 //Horisontal movement |
|
3063 case EStdKeyLeftArrow: |
|
3064 if( |
|
3065 #ifdef _ACCELEROMETER_SUPPORTED_ |
|
3066 (iDeviceOrientation == EOrientationDisplayLeftUp && |
|
3067 #endif |
|
3068 iDrawFunction == EFaceBrowser && aType == EEventKey) || |
|
3069 |
|
3070 (iDrawFunction == EFaceBrowser && aType == EEventKey && |
|
3071 imageRotation == (imageRotation == -90 || imageRotation == -270)) ) |
|
3072 { |
|
3073 iDrawFaceBrowsing->DecFaceNumber(); |
|
3074 } |
|
3075 iKeyData.iX-=addValue; |
|
3076 iKeyData.iLeft=pressValue; |
|
3077 ResetZoomKeys(); |
|
3078 break; |
|
3079 |
|
3080 case EStdKeyRightArrow: |
|
3081 if( |
|
3082 #ifdef _ACCELEROMETER_SUPPORTED_ |
|
3083 (iDeviceOrientation == EOrientationDisplayLeftUp && |
|
3084 #endif |
|
3085 iDrawFunction == EFaceBrowser && aType == EEventKey) || |
|
3086 |
|
3087 (iDrawFunction == EFaceBrowser && aType == EEventKey && |
|
3088 imageRotation == (imageRotation == -90 || imageRotation == -270)) ) |
|
3089 { |
|
3090 iDrawFaceBrowsing->IncFaceNumber(); |
|
3091 } |
|
3092 iKeyData.iX+=addValue; |
|
3093 iKeyData.iRight=pressValue; |
|
3094 ResetZoomKeys(); |
|
3095 break; |
|
3096 |
|
3097 // Rotation |
|
3098 #if 1 |
|
3099 case '1': |
|
3100 case 'A': |
|
3101 case EStdKeyNkp1: |
|
3102 { |
|
3103 if (/*aType==EEventKey *//*|| aType==EEventKeyUp || */aType==EEventKeyDown) |
|
3104 { |
|
3105 CImageData* imageData = iIEngine->GetImageData(iImagicAppUi->GetImageIndex()); |
|
3106 TInt rotAngle = imageData->GetOrientation(); |
|
3107 imageData->SetOrientation((rotAngle + 90)%360); |
|
3108 iIEngine->SetImageRotation(iImagicAppUi->GetImageIndex()); |
|
3109 iIEngine->SetDBChanged(imageData); |
|
3110 } |
|
3111 |
|
3112 ResetZoomKeys(); |
|
3113 ResetDirKeyData(); |
|
3114 break; |
|
3115 } |
|
3116 |
|
3117 case '3': |
|
3118 case 'S': |
|
3119 case EStdKeyNkp3: |
|
3120 { |
|
3121 if (/*aType==EEventKey *//*|| aType==EEventKeyUp || */aType==EEventKeyDown) |
|
3122 { |
|
3123 CImageData* imageData = iIEngine->GetImageData(iImagicAppUi->GetImageIndex()); |
|
3124 TInt rotAngle = imageData->GetOrientation(); |
|
3125 imageData->SetOrientation((rotAngle + 270)%360); |
|
3126 iIEngine->SetImageRotation(iImagicAppUi->GetImageIndex()); |
|
3127 iIEngine->SetDBChanged(imageData); |
|
3128 } |
|
3129 |
|
3130 ResetZoomKeys(); |
|
3131 ResetDirKeyData(); |
|
3132 break; |
|
3133 } |
|
3134 #endif |
|
3135 |
|
3136 case EStdKeySpace: |
|
3137 case EKeySpace: |
|
3138 case '0': |
|
3139 case EStdKeyNkp0: |
|
3140 #ifdef _ACCELEROMETER_SUPPORTED_ |
|
3141 //Check that accelerometer did not found by engine |
|
3142 DP0_IMAGIC(_L("CImagicContainerBrowser::OfferKeyEvent - rotate pressed")); |
|
3143 if(!iIEngine->IsAccelerometerExists() && aType == EEventKeyDown) |
|
3144 { |
|
3145 if(iIEngine->GetDeviceOrientation() == EOrientationDisplayLeftUp) |
|
3146 iIEngine->SetDeviceOrientation(EOrientationDisplayDown); |
|
3147 else if(iIEngine->GetDeviceOrientation() == EOrientationDisplayDown) |
|
3148 iIEngine->SetDeviceOrientation(EOrientationDisplayLeftUp); |
|
3149 } |
|
3150 |
|
3151 ResetZoomKeys(); |
|
3152 ResetDirKeyData(); |
|
3153 #endif |
|
3154 break; |
|
3155 |
|
3156 //case EStdKeySpace: |
|
3157 //case EKeySpace: |
|
3158 case 'M': |
|
3159 if(aType == EEventKeyDown) |
|
3160 { |
|
3161 iView->ProcessCommandL(EAknSoftkeyOptions); |
|
3162 ResetZoomKeys(); |
|
3163 ResetDirKeyData(); |
|
3164 } |
|
3165 break; |
|
3166 |
|
3167 // Zooming |
|
3168 case 'Q': |
|
3169 case EStdKeyNkpAsterisk: |
|
3170 case '*': |
|
3171 case EStdKeyIncVolume: |
|
3172 |
|
3173 ResetDirKeyData(); |
|
3174 |
|
3175 if(iDrawFunction == EOneByOne) |
|
3176 { |
|
3177 //iKeyData.iZoom+=addValue; |
|
3178 //iKeyData.iZoomIn=pressValue; |
|
3179 iKeyData.iZoomInKey=ETrue; |
|
3180 iKeyData.iZoomOutKey=EFalse; |
|
3181 } |
|
3182 if(iDrawFunction == EGrid) |
|
3183 { |
|
3184 //Open one by one mode |
|
3185 iDrawOneByOne->InitDrawOnebyOne(KInitDrawZoom/*drawZoom*/, inPictureX, inPictureY); |
|
3186 //Set Grid view |
|
3187 if(iDrawFunction == EFaceBrowser) |
|
3188 { |
|
3189 //iDrawFunction = EGrid; |
|
3190 SetDrawMode(EGrid); |
|
3191 } |
|
3192 |
|
3193 iView->SetFaceBrowsingMode(EFaceBrowserNone); |
|
3194 } |
|
3195 //ResetDirKeyData(); |
|
3196 break; |
|
3197 |
|
3198 case 'W': |
|
3199 case EStdKeyHash: |
|
3200 case '#': |
|
3201 case EStdKeyDecVolume: |
|
3202 |
|
3203 ResetDirKeyData(); |
|
3204 |
|
3205 if(iDrawFunction == EOneByOne) |
|
3206 { |
|
3207 //iKeyData.iZoom-=addValue; |
|
3208 //iKeyData.iZoomOut=pressValue; |
|
3209 iKeyData.iZoomInKey=EFalse; |
|
3210 iKeyData.iZoomOutKey=ETrue; |
|
3211 } |
|
3212 |
|
3213 if(iDrawFunction == EOneByOne && IS_NOT_IN_ZOOM_ONEBYONE && aType == EEventKeyDown) |
|
3214 { |
|
3215 /*#ifdef SUPERZOOM |
|
3216 iIEngine->CancelFullSizeLoading(); |
|
3217 |
|
3218 //Unload high res textures when going back to Grid |
|
3219 CImageData* aGridData = iIEngine->GetImageData(iCurrentIndex); |
|
3220 iTextureLoader->ReleaseSuperHResTexture( aGridData ); |
|
3221 #endif*/ |
|
3222 //Return to previous mode |
|
3223 iDrawGrid->InitDrawGrid(); |
|
3224 SetDrawMode(EGrid); |
|
3225 |
|
3226 iView->SetFaceBrowsingMode(EFaceBrowserNone); |
|
3227 } |
|
3228 //ResetDirKeyData(); |
|
3229 break; |
|
3230 |
|
3231 /*case 'F': |
|
3232 iView->HandleCommandL(EImagicCmdViewFaceBrowsing); |
|
3233 break;*/ |
|
3234 |
|
3235 case EKeyBackspace: |
|
3236 case EStdKeyBackspace: |
|
3237 iView->HandleCommandL(EImagicCmdViewBrowserDelete); |
|
3238 ResetZoomKeys(); |
|
3239 ResetDirKeyData(); |
|
3240 break; |
|
3241 |
|
3242 case 'I': |
|
3243 if(aType == EEventKeyDown) |
|
3244 { |
|
3245 iView->HandleCommandL(EImagicCmdViewBrowserShowImageInfo); |
|
3246 ResetZoomKeys(); |
|
3247 ResetDirKeyData(); |
|
3248 } |
|
3249 break; |
|
3250 |
|
3251 |
|
3252 // Selection |
|
3253 case EStdKeyEnter: |
|
3254 case EKeyEnter: |
|
3255 case EStdKeyDevice3: //rocker selection key |
|
3256 if (aType == EEventKey) |
|
3257 { |
|
3258 HandleDrawingModeSwitch(iDrawFunction); |
|
3259 } |
|
3260 ResetZoomKeys(); |
|
3261 ResetDirKeyData(); |
|
3262 break; |
|
3263 |
|
3264 default: |
|
3265 // Unknown key, it was not consumed |
|
3266 ret = EKeyWasNotConsumed; |
|
3267 ResetZoomKeys(); |
|
3268 ResetDirKeyData(); |
|
3269 break; |
|
3270 } |
|
3271 } |
|
3272 |
|
3273 DrawNow(); |
|
3274 |
|
3275 return ret; |
|
3276 } |
|
3277 |
|
3278 void CImagicContainerBrowser::HandleDrawingModeSwitch(TDrawFunction& aDrawFunction) |
|
3279 { |
|
3280 //EGrid |
|
3281 if(aDrawFunction == EGrid) |
|
3282 { |
|
3283 //Open one by one mode |
|
3284 iDrawOneByOne->InitDrawOnebyOne(KInitDrawZoom/*drawZoom*/, inPictureX, inPictureY); |
|
3285 |
|
3286 //Set Grid view |
|
3287 if(aDrawFunction == EFaceBrowser) |
|
3288 SetDrawMode(EGrid); |
|
3289 //aDrawFunction = EGrid; |
|
3290 |
|
3291 iView->SetFaceBrowsingMode(EFaceBrowserNone); |
|
3292 } |
|
3293 |
|
3294 //EOneByOne |
|
3295 else if(aDrawFunction == EOneByOne) |
|
3296 { |
|
3297 if(IS_NOT_IN_ZOOM_ONEBYONE) |
|
3298 { |
|
3299 //Return to previous mode |
|
3300 iDrawGrid->InitDrawGrid(); |
|
3301 //aDrawFunction = EGrid; |
|
3302 SetDrawMode(EGrid); |
|
3303 iView->SetFaceBrowsingMode(EFaceBrowserNone); |
|
3304 } |
|
3305 else |
|
3306 { |
|
3307 iDrawOneByOne->SetDrawOneByOneTargetZoom(1); |
|
3308 } |
|
3309 |
|
3310 } |
|
3311 |
|
3312 //EFaceBrowser |
|
3313 else if(aDrawFunction == EFaceBrowser) |
|
3314 { |
|
3315 SetDrawMode(EOneByOne); |
|
3316 //aDrawFunction = EOneByOne; |
|
3317 iDrawOneByOne->InitDrawOnebyOne(/*KInitDrawZoom*/drawZoom, inPictureX, inPictureY); |
|
3318 iView->SetFaceBrowsingMode(EFaceBrowserNone); |
|
3319 } |
|
3320 } |
|
3321 |
|
3322 void CImagicContainerBrowser::SetFullScreen() |
|
3323 { |
|
3324 SetExtentToWholeScreen(); |
|
3325 } |
|
3326 |
|
3327 void CImagicContainerBrowser::HandleRotation(float& aRotationAngle, float& aTargetRotationAngle) |
|
3328 { |
|
3329 // Force target to be in steps of 90 |
|
3330 aTargetRotationAngle=((int)(aTargetRotationAngle/90))*90; |
|
3331 |
|
3332 // Force both angles to be between 0-360 |
|
3333 while (aRotationAngle<0) aRotationAngle+=360; |
|
3334 while (aRotationAngle>360) aRotationAngle-=360; |
|
3335 while (aTargetRotationAngle<0) aTargetRotationAngle+=360; |
|
3336 while (aTargetRotationAngle>360) aTargetRotationAngle-=360; |
|
3337 |
|
3338 // Calculate difference between angles |
|
3339 float diff=aTargetRotationAngle-aRotationAngle; |
|
3340 // Limit difference to be between [-180:180] |
|
3341 while (diff<-180) diff+=360; |
|
3342 while (diff>180) diff-=360; |
|
3343 |
|
3344 // Copy paste from Interpolate, just uses diff calculated above |
|
3345 float aStep=0.26; |
|
3346 float timediff = Min(0.1f, iTimeDiff); // so max value of timediff is 100tick (100ms) |
|
3347 aRotationAngle += diff * aStep * timediff * 30; |
|
3348 |
|
3349 // Calculate new difference |
|
3350 float newDiff=aTargetRotationAngle-aRotationAngle; |
|
3351 while (newDiff<-180) newDiff+=360; |
|
3352 while (newDiff>180) newDiff-=360; |
|
3353 // If difference-angles have different signs, then we went past the target angle |
|
3354 if (diff*newDiff < 0) |
|
3355 aRotationAngle = aTargetRotationAngle; |
|
3356 } |
|
3357 |
|
3358 TBool CImagicContainerBrowser::IsOpenGLInit() |
|
3359 { |
|
3360 return iOpenGlInitialized; |
|
3361 } |
|
3362 |
|
3363 //Disables display drawing |
|
3364 void CImagicContainerBrowser::EnableDisplayDraw() |
|
3365 { |
|
3366 DP0_IMAGIC(_L("CImagicContainerBrowser::EnableDisplayDraw++")); |
|
3367 |
|
3368 if(!iPeriodic->IsActive()) |
|
3369 iPeriodic->Start( 1, iDisplayDrawFreq, TCallBack( CImagicContainerBrowser::DrawCallBackL, this ) ); |
|
3370 |
|
3371 DP0_IMAGIC(_L("CImagicContainerBrowser::EnableDisplayDraw--")); |
|
3372 } |
|
3373 |
|
3374 //Enables display drawing |
|
3375 void CImagicContainerBrowser::DisableDisplayDraw() |
|
3376 { |
|
3377 DP0_IMAGIC(_L("CImagicContainerBrowser::DisableDisplayDraw++")); |
|
3378 |
|
3379 if(iPeriodic) |
|
3380 if(iPeriodic->IsActive()) |
|
3381 { |
|
3382 iPeriodic->Cancel(); |
|
3383 //Clear buffers |
|
3384 //glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); |
|
3385 } |
|
3386 |
|
3387 DP0_IMAGIC(_L("CImagicContainerBrowser::DisableDisplayDraw--")); |
|
3388 } |
|
3389 |
|
3390 void CImagicContainerBrowser::SetDrawMode(TDrawFunction aDrawFunction) |
|
3391 { |
|
3392 DP0_IMAGIC(_L("CImagicContainerBrowser::SetDrawMode++")); |
|
3393 |
|
3394 ResetZoomKeys(); |
|
3395 ResetDirKeyData(); |
|
3396 |
|
3397 if(/*aDrawFunction == EOneByOne && */!IS_NOT_IN_ZOOM_ONEBYONE) |
|
3398 { |
|
3399 iDrawOneByOne->SetDrawOneByOneTargetZoom(1); |
|
3400 } |
|
3401 else |
|
3402 { |
|
3403 iDrawFunction = aDrawFunction; |
|
3404 } |
|
3405 |
|
3406 if(aDrawFunction == EGrid) |
|
3407 { |
|
3408 iPreferHighResLoading = EFalse; |
|
3409 #ifdef SUPERZOOM |
|
3410 iIEngine->CancelFullSizeLoading(); |
|
3411 |
|
3412 //Unload high res textures when going back to Grid |
|
3413 CImageData* aGridData = iIEngine->GetImageData(iCurrentIndex); |
|
3414 iTextureLoader->ReleaseSuperHResTexture( aGridData ); |
|
3415 #endif |
|
3416 iDrawGrid->InitDrawGrid(); |
|
3417 } |
|
3418 |
|
3419 DrawNow(); |
|
3420 |
|
3421 DP0_IMAGIC(_L("CImagicContainerBrowser::SetDrawMode--")); |
|
3422 } |
|
3423 |
|
3424 CImagicContainerBrowser::TDrawFunction CImagicContainerBrowser::GetDrawMode() |
|
3425 { |
|
3426 return iDrawFunction; |
|
3427 } |
|
3428 |
|
3429 |
|
3430 void CImagicContainerBrowser::SetBGPSStatus(TBool aValue) |
|
3431 { |
|
3432 //False = BGPS is running |
|
3433 //True = BGPS is completed |
|
3434 iTNCreationComplete = aValue; |
|
3435 } |
|
3436 |
|
3437 CTextureLoader* CImagicContainerBrowser::GetTextureLoader() |
|
3438 { |
|
3439 return iTextureLoader; |
|
3440 } |
|
3441 |
|
3442 float CImagicContainerBrowser::GetAspectRatio(TInt aIndex) |
|
3443 { |
|
3444 return iIEngine->GetImageData(aIndex)->GetAspectRatio(); |
|
3445 } |
|
3446 |
|
3447 void CImagicContainerBrowser::SetFaceCoords(RArray<TRect>& aCoordinates) |
|
3448 { |
|
3449 iDrawFaceBrowsing->SetFaceCoords(aCoordinates); |
|
3450 } |
|
3451 |
|
3452 void CImagicContainerBrowser::ClearFaceArray() |
|
3453 { |
|
3454 iDrawFaceBrowsing->ClearFaceArray(); |
|
3455 } |
|
3456 |
|
3457 void CImagicContainerBrowser::SetTextIndex(GLuint aIndex) |
|
3458 { |
|
3459 iCurrentBindedIndex = aIndex; |
|
3460 } |
|
3461 |
|
3462 #ifdef _ACCELEROMETER_SUPPORTED_ |
|
3463 |
|
3464 TImagicDeviceOrientation CImagicContainerBrowser::GetDeviceOrientation() |
|
3465 { |
|
3466 return iDeviceOrientation; |
|
3467 } |
|
3468 |
|
3469 |
|
3470 void CImagicContainerBrowser::PhoneRotated(TImagicDeviceOrientation aDeviceOrientation) |
|
3471 { |
|
3472 /*if(iDeviceOrientation == aDeviceOrientation) |
|
3473 { |
|
3474 return; |
|
3475 }*/ |
|
3476 |
|
3477 iDeviceOrientation = aDeviceOrientation; |
|
3478 |
|
3479 //iDrawGridZoom = KZoomOutMaxGrid;//Set initial zooming value when draving Grid |
|
3480 #ifdef ENABLE_GRID_ZOOM |
|
3481 #ifdef ZOOM_WHILE_ROTATING |
|
3482 if(iDrawFunction == EGrid) |
|
3483 iDrawGridTargetZoom = KZoomOutMaxGrid; |
|
3484 #endif |
|
3485 #endif |
|
3486 |
|
3487 if(iDrawFunction == EOneByOne) |
|
3488 { |
|
3489 //Set currect rotation angle immeadetly to target, except for current image index |
|
3490 TInt num = iIEngine->GetTotalNumOfImages(); |
|
3491 for(TInt i=0; i < num; i++ ) |
|
3492 { |
|
3493 if(i != iCurrentIndex) |
|
3494 { |
|
3495 CImageData* data = iIEngine->GetImageData(i); |
|
3496 data->iGridData.iRotationAngle = data->iGridData.iTargetRotationAngle; |
|
3497 } |
|
3498 } |
|
3499 } |
|
3500 else if(iDrawFunction == EFaceBrowser) |
|
3501 { |
|
3502 //Do nothing |
|
3503 } |
|
3504 else if(iDrawFunction == EGrid) |
|
3505 { |
|
3506 //Do nothing |
|
3507 } |
|
3508 |
|
3509 //DrawScreen(); |
|
3510 DrawNow(); |
|
3511 } |
|
3512 |
|
3513 #endif |
|
3514 |
|
3515 void CImagicContainerBrowser::IconTexturesLoaded(RArray<GLuint> aIconTextureIndexes) |
|
3516 { |
|
3517 for(TInt i=0; i<aIconTextureIndexes.Count(); i++) |
|
3518 { |
|
3519 iIconTextureIndexes.Append(aIconTextureIndexes[i]); |
|
3520 } |
|
3521 } |
|
3522 |
|
3523 void CImagicContainerBrowser::HandleSend2BackgroundEvent() |
|
3524 { |
|
3525 DP0_IMAGIC(_L("CImagicContainerBrowser::HandleSend2BackgroundEvent++")); |
|
3526 |
|
3527 //Cancel SuperZoom image loading, if it was started |
|
3528 iIEngine->CancelFullSizeLoading(); |
|
3529 /* |
|
3530 //Delete OpenGL memory allocations |
|
3531 TInt num = iIEngine->GetTotalNumOfImages(); |
|
3532 for(TInt i=0; i < num; i++ ) |
|
3533 { |
|
3534 CImageData* data = iIEngine->GetImageData(i); |
|
3535 |
|
3536 if(data->iGridData.iGlHQ512TextIndex != 0) |
|
3537 glDeleteTextures(1, &data->iGridData.iGlHQ512TextIndex); |
|
3538 if(data->iGridData.iGlSuperHQTextIndex != 0) |
|
3539 glDeleteTextures(1, &data->iGridData.iGlSuperHQTextIndex); |
|
3540 |
|
3541 data->iGridData.iGlHQ512TextIndex = 0; |
|
3542 data->iGridData.iGlSuperHQTextIndex = 0; |
|
3543 } |
|
3544 */ |
|
3545 |
|
3546 //Delete OpenGL memory allocations |
|
3547 TInt num = iIEngine->GetTotalNumOfImages(); |
|
3548 for(TInt i=0; i < num; i++ ) |
|
3549 { |
|
3550 CImageData* data = iIEngine->GetImageData(i); |
|
3551 |
|
3552 if(data->iGridData.iGlLQ128TextIndex) |
|
3553 glDeleteTextures( 1, &data->iGridData.iGlLQ128TextIndex ); |
|
3554 if(data->iGridData.iGlLQ32TextIndex) |
|
3555 glDeleteTextures( 1, &data->iGridData.iGlLQ32TextIndex ); |
|
3556 if(data->iGridData.iGlHQ512TextIndex != 0) |
|
3557 glDeleteTextures(1, &data->iGridData.iGlHQ512TextIndex); |
|
3558 if(data->iGridData.iGlSuperHQTextIndex != 0) |
|
3559 glDeleteTextures(1, &data->iGridData.iGlSuperHQTextIndex); |
|
3560 |
|
3561 data->iGridData.iGlLQ32TextIndex = 0; |
|
3562 data->iGridData.iGlLQ128TextIndex = 0; |
|
3563 data->iGridData.iGlHQ512TextIndex = 0; |
|
3564 data->iGridData.iGlSuperHQTextIndex = 0; |
|
3565 } |
|
3566 |
|
3567 |
|
3568 DP0_IMAGIC(_L("CImagicContainerBrowser::HandleSend2BackgroundEvent--")); |
|
3569 |
|
3570 } |
|
3571 |
|
3572 |
|
3573 /* |
|
3574 void CImagicContainerBrowser::MrccatoCommand(TRemConCoreApiOperationId aOperationId, TRemConCoreApiButtonAction aButtonAct) |
|
3575 { |
|
3576 TBool pressValue=EFalse; |
|
3577 |
|
3578 switch(aOperationId) |
|
3579 { |
|
3580 case ERemConCoreApiVolumeDown: |
|
3581 { |
|
3582 //do your own stuff |
|
3583 iKeyData.iZoom-=1; |
|
3584 iKeyData.iZoomOut=ETrue; |
|
3585 break; |
|
3586 } |
|
3587 case ERemConCoreApiVolumeUp: |
|
3588 { |
|
3589 //do your own stuff |
|
3590 iKeyData.iZoom+=1; |
|
3591 iKeyData.iZoomIn=ETrue; |
|
3592 break; |
|
3593 } |
|
3594 } |
|
3595 |
|
3596 } |
|
3597 */ |
|
3598 |
|
3599 |
|
3600 TBool CImagicContainerBrowser::GetSlideByDragValue() |
|
3601 { |
|
3602 return iOneByOneSlideByDrag; |
|
3603 } |
|
3604 |
|
3605 TInt CImagicContainerBrowser::GetCurrentIndex() |
|
3606 { |
|
3607 return iCurrentIndex; |
|
3608 } |
|
3609 |
|
3610 TInt CImagicContainerBrowser::GetPrevIndex() |
|
3611 { |
|
3612 return iPreviousIndex; |
|
3613 } |
|
3614 |
|
3615 void CImagicContainerBrowser::SetCurrentIndex(TInt aIndex) |
|
3616 { |
|
3617 CheckIndexLimits(aIndex); |
|
3618 iCurrentIndex = aIndex; |
|
3619 } |
|
3620 |
|
3621 void CImagicContainerBrowser::CheckIndexLimits(TInt &aIndex) |
|
3622 { |
|
3623 //Check that current index is in grid area |
|
3624 TInt num = iIEngine->GetTotalNumOfImages(); |
|
3625 |
|
3626 if(!iJumpOver) |
|
3627 { |
|
3628 if(aIndex >= num) |
|
3629 { |
|
3630 aIndex = num-1; |
|
3631 iIntheEndOfGrid=ETrue; |
|
3632 } |
|
3633 if(aIndex < 0) |
|
3634 { |
|
3635 aIndex = 0; |
|
3636 iIntheEndOfGrid=ETrue; |
|
3637 } |
|
3638 } |
|
3639 else//if(iJumpOver) |
|
3640 { |
|
3641 if (num) |
|
3642 { |
|
3643 aIndex %= num; |
|
3644 if (aIndex < 0) |
|
3645 aIndex = num + aIndex; |
|
3646 } |
|
3647 } |
|
3648 } |
|
3649 |
|
3650 void CImagicContainerBrowser::SetPrevIndex(TInt aIndex) |
|
3651 { |
|
3652 iPreviousIndex = aIndex; |
|
3653 } |
|
3654 |
|
3655 |
|
3656 CKeyData& CImagicContainerBrowser::GetKeyData() |
|
3657 { |
|
3658 return iKeyData; |
|
3659 } |
|
3660 |
|
3661 void CImagicContainerBrowser::SetKeyData(CKeyData aData) |
|
3662 { |
|
3663 iKeyData = aData; |
|
3664 } |
|
3665 |
|
3666 void CImagicContainerBrowser::ResetKeyData() |
|
3667 { |
|
3668 iKeyData.iRotate=0; |
|
3669 |
|
3670 iKeyData.iX=0; |
|
3671 iKeyData.iY=0; |
|
3672 } |
|
3673 |
|
3674 void CImagicContainerBrowser::ResetDirKeyData() |
|
3675 { |
|
3676 iKeyData.iUp=0; |
|
3677 iKeyData.iDown=0; |
|
3678 iKeyData.iLeft=0; |
|
3679 iKeyData.iRight=0; |
|
3680 } |
|
3681 |
|
3682 CKeyData& CImagicContainerBrowser::GetTouchData() |
|
3683 { |
|
3684 return iTouchMoveData; |
|
3685 } |
|
3686 |
|
3687 void CImagicContainerBrowser::SetTouchData(CKeyData aData) |
|
3688 { |
|
3689 iTouchMoveData = aData; |
|
3690 } |
|
3691 |
|
3692 void CImagicContainerBrowser::ResetTouchData() |
|
3693 { |
|
3694 iTouchMoveData.iRotate=0; |
|
3695 iTouchMoveData.iX=0; |
|
3696 iTouchMoveData.iY=0; |
|
3697 iTouchMoveData.iZoomInKey=0; |
|
3698 iTouchMoveData.iZoomOutKey=0; |
|
3699 iTouchMoveData.iRight = EFalse; |
|
3700 iTouchMoveData.iLeft = EFalse; |
|
3701 iTouchMoveData.iUp = EFalse; |
|
3702 iTouchMoveData.iDown = EFalse; |
|
3703 } |
|
3704 |
|
3705 |
|
3706 TInt CImagicContainerBrowser::GetGleMaxRes() |
|
3707 { |
|
3708 return iGLMaxRes; |
|
3709 } |
|
3710 |
|
3711 TBool CImagicContainerBrowser::IsUserInputGiven() |
|
3712 { |
|
3713 return iUserInputGiven; |
|
3714 } |
|
3715 |
|
3716 |
|
3717 TSize CImagicContainerBrowser::GetScreenSize() |
|
3718 { |
|
3719 return iScreenSize; |
|
3720 } |
|
3721 |
|
3722 |
|
3723 // End of File |