|
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 #ifndef IMAGICCONTAINERBROWSER_H |
|
19 #define IMAGICCONTAINERBROWSER_H |
|
20 |
|
21 //#define ADAPTIVE_FRAMERATE // adaptive frame rate |
|
22 #define MOMENTUM_MOVE |
|
23 #define DOUBLETAP_FACEBROWSING |
|
24 #define DOUBLETAP_SELECT_IN_GRID |
|
25 #define SINGLETAP_CLOSE_IN_ZOOM |
|
26 #define FLICK_ONLY_IN_X_IN_GRID |
|
27 #define HOLD_SELECTION_ONDRAG |
|
28 #undef CURSORSIMULATION_IN_GRID |
|
29 #undef CURSORSIMULATION_IN_ONEBYONE |
|
30 #undef CURSORSIMULATION_IN_FACEBROWSER |
|
31 #undef SELECT_ON_TOUCHDOWN |
|
32 #undef TAP_AND_GESTURE |
|
33 //#undef DOUBLETAP_ZOOMGRID |
|
34 #undef USE_AVKON_LONGTAP_DETECTOR |
|
35 |
|
36 //#undef RD_FACEFRAME |
|
37 #define RD_FACEFRAME |
|
38 #define RD_ZOOMICON |
|
39 |
|
40 // INCLUDES |
|
41 #include <coecntrl.h> |
|
42 #include <aknnotewrappers.h> |
|
43 #include <aknlongtapdetector.h> |
|
44 #include <GLES\egl.h> |
|
45 #include "ImagicAppUi.h" |
|
46 #include <HWRMLight.h> |
|
47 #include "Gesture.h" |
|
48 #include "ImagicUtils.h" |
|
49 #include "DrawableInterface.h" |
|
50 #include "DrawUtility.h" |
|
51 #include "CDrawGrid.h" |
|
52 #include "CDrawOneByOne.h" |
|
53 #include "CDrawFaceBrowsing.h" |
|
54 #include "CDrawMagGlass.h" |
|
55 |
|
56 |
|
57 #ifdef USE_AVKON_TACTILE_FEEDBACK |
|
58 #include <touchfeedback.h> |
|
59 #include <touchlogicalfeedback.h> |
|
60 #endif |
|
61 |
|
62 //#define VERTICES_PER_LINE 32 |
|
63 |
|
64 |
|
65 // FORWARD DECLARATIONS |
|
66 class CImagicViewBrowser; |
|
67 class CImagicAppUi; |
|
68 class CGLImageHandler; |
|
69 class CTextureLoader; |
|
70 class CDrawUtility; |
|
71 class CDrawGrid; |
|
72 class CDrawOneByOne; |
|
73 class CDrawFaceBrowsing; |
|
74 class CDrawMagGlass; |
|
75 |
|
76 |
|
77 |
|
78 // Variables telling how many times keys has been pressed |
|
79 class CKeyData |
|
80 { |
|
81 public: |
|
82 //void ResetData(); |
|
83 |
|
84 //these variables hold number of key presses as long they are consumed |
|
85 //value must be reset after usage |
|
86 TInt iX,iY; // Movement keys |
|
87 TInt iRotate; // Rotation keys |
|
88 //TInt iZoom; // Zooming keys |
|
89 |
|
90 // Tells if button is currently pressed |
|
91 TBool iLeft,iRight; |
|
92 TBool iUp,iDown; |
|
93 //TBool iZoomIn, iZoomOut; |
|
94 TBool iZoomInKey, iZoomOutKey; |
|
95 }; |
|
96 |
|
97 |
|
98 // CLASS DECLARATION |
|
99 |
|
100 /** |
|
101 * CImagicContainerBrowser container control class. |
|
102 * |
|
103 */ |
|
104 class CImagicContainerBrowser : public CCoeControl, MCoeControlObserver |
|
105 , MAknLongTapDetectorCallBack |
|
106 , MGestureCallBack |
|
107 { |
|
108 public: // Constructors and destructor |
|
109 |
|
110 //Drawing functions |
|
111 enum TDrawFunction |
|
112 { |
|
113 EGrid, |
|
114 EOneByOne, |
|
115 EFaceBrowser, |
|
116 ELastDrawFunction |
|
117 }; |
|
118 |
|
119 //Grid Drawing modes |
|
120 enum TGridMode |
|
121 { |
|
122 EListof3 = 1, |
|
123 EListof5, |
|
124 ESquare |
|
125 }; |
|
126 |
|
127 /** |
|
128 * EPOC default constructor. |
|
129 * @param aRect Frame rectangle for container. |
|
130 */ |
|
131 void ConstructL(CImagicAppUi* aImagicAppUi, CImagicViewBrowser* aView, const TRect& aRect); |
|
132 |
|
133 /** |
|
134 * Destructor. |
|
135 */ |
|
136 ~CImagicContainerBrowser(); |
|
137 |
|
138 //void SetBitmapArrayL(CFbsBitmap* aBitmap); |
|
139 void ImageLoadedL(TInt aError, CFbsBitmap* aBitmap, TThumbSize aResolution/*, TInt aLoadedImageIndex*/); |
|
140 |
|
141 TKeyResponse OfferKeyEventL(const TKeyEvent& aKeyEvent, TEventCode aType); |
|
142 // Handle any tap on the screen |
|
143 void HandlePointerEventL(const TPointerEvent& aPointerEvent); |
|
144 |
|
145 // From MAknLongTapDetectorCallBack |
|
146 void HandleLongTapEventL(const TPoint& aPenEventLocation, const TPoint& aPenEventScreenLocation); |
|
147 void HandleGestureBeganL(const TPoint& aPos); |
|
148 void HandleGestureMovedL(const TPoint& aPos, const TGestureType aType); |
|
149 void HandleGestureEndedL(const TPoint& aPos, const TGestureType aType); |
|
150 |
|
151 void DoTapAndDrag(const TPoint& aPos, const TGestureType aType); |
|
152 void DoCursorSimulation(const TPoint& aPos, const TGestureType aType); |
|
153 void DoDrag(const TPoint& aPos, const TGestureType aType); |
|
154 void DoFlick(const TPoint& aPos, const TGestureType aType); |
|
155 void DoSingleTap(const TPoint& aPos, const TGestureType aType); |
|
156 void DoDoubleTap(const TPoint& aPos, const TGestureType aType); |
|
157 void DoLongTapping(const TPoint& aPos, const TGestureType aType); |
|
158 void DoLongTap(const TPoint& aPos, const TGestureType aType); |
|
159 |
|
160 |
|
161 void SetFullScreen(); |
|
162 void SetBitmapFromArrayL(); |
|
163 TBool IsOpenGLInit(); |
|
164 void OpenGLInitL(); |
|
165 void InitL(); |
|
166 void DeleteTextures(); |
|
167 void DisableDisplayDraw(); |
|
168 void EnableDisplayDraw(); |
|
169 //void SetGridMode(TGridMode aDrawMode); |
|
170 void SetDrawMode(TDrawFunction aDrawFunction); |
|
171 TDrawFunction GetDrawMode(); |
|
172 void SetBGPSStatus(TBool aValue); |
|
173 //void SetTNCreationStarted(TBool aValue); |
|
174 void DeleteImageL(); |
|
175 CTextureLoader* GetTextureLoader(); |
|
176 void DisplayDeleteQueryDialogL(TInt aResourceId); |
|
177 float GetAspectRatio(TInt aIndex); |
|
178 void SetFaceCoords(RArray<TRect>& aCoordinates); |
|
179 void ClearFaceArray(); |
|
180 //void SwapArrays(); |
|
181 void SetLoadingOn(TBool aValue); |
|
182 void DynamicLoadingL(); |
|
183 void SetDeleteTextures(TBool aValue); |
|
184 //void InitFaceBrowsing(); |
|
185 //MRemConCoreApiTargetObserver |
|
186 //void MrccatoCommand(TRemConCoreApiOperationId aOperationId, TRemConCoreApiButtonAction aButtonAct); |
|
187 |
|
188 private: // Functions from base classes |
|
189 |
|
190 /** |
|
191 * From CoeControl,SizeChanged. |
|
192 */ |
|
193 void SizeChanged(); |
|
194 |
|
195 /** |
|
196 * From CoeControl,CountComponentControls. |
|
197 */ |
|
198 TInt CountComponentControls() const; |
|
199 |
|
200 /** |
|
201 * From CCoeControl,ComponentControl. |
|
202 */ |
|
203 CCoeControl* ComponentControl(TInt aIndex) const; |
|
204 |
|
205 /** |
|
206 * From CCoeControl,Draw. |
|
207 */ |
|
208 void Draw(const TRect& aRect) const; |
|
209 |
|
210 /** |
|
211 * From CCoeControl, HandleControlEventL. |
|
212 */ |
|
213 // event handling section |
|
214 // e.g Listbox events |
|
215 void HandleControlEventL(CCoeControl* aControl,TCoeEvent aEventType); |
|
216 |
|
217 /** |
|
218 * Callback function for the CPeriodic. Calculates the current frame, keeps the background |
|
219 * light from turning off and orders the CSlideshow to do the rendering for each frame. |
|
220 *@param aInstance Pointer to this instance of CSlideshowContainer.*/ |
|
221 static TInt DrawCallBackL( TAny* aInstance ); |
|
222 void DrawL(); |
|
223 void BeginDrawing(); |
|
224 void EndDrawing(); |
|
225 |
|
226 /*----------------------------------------------------------------------*/ |
|
227 void CheckLimits(float &aValue, const float aMin, const float aMax); |
|
228 void SetPictureVertices(CImageData* aData, GLfixed *aVertices); |
|
229 void HandleRotationKeys(void); |
|
230 //void HandleMovingKeysOnebyOne(); |
|
231 |
|
232 |
|
233 //void BubbleEffect(TInt& x, TInt& y, float& z); |
|
234 |
|
235 static TInt DisableDrawTimer( TAny* aInstance ); |
|
236 static TInt PowerSaveCallBack(TAny *aAnyPtr); |
|
237 void PowerSave(); |
|
238 void CheckIndexLimits(TInt &aIndex); |
|
239 void SetQvgaCoordinates(const TPoint &aPoint, const TSize &aSize); |
|
240 void CalculateImageSize2(float& width, float& height, const float aAspectRatio); |
|
241 void InitDrawMagGlass(); |
|
242 void DrawMagGlass(const TSize &aScreenPhysicalSize, TReal aImageAspectRatio); |
|
243 void DrawCross(const TSize &aScreenPhysicalSize, const TReal aImageAspectRatio); |
|
244 void SetMinMagFilterLinear(TBool aValue); |
|
245 void SetMinMagFilterLinearDo(TBool aValue); |
|
246 |
|
247 |
|
248 void MoveIndex(TInt aMoveX, TInt aMoveY, TBool aWrap = ETrue); |
|
249 void SelectIndex(void); |
|
250 FloatCoords ConvertCoordsFromScreen2OGl(const TPoint aPos); |
|
251 TBool FindImageInGrid(const TPoint aPos, TInt& aResultIndex); |
|
252 TInt GetFreeRam(); |
|
253 TBool FindImageInScreen(const TPoint aPos, TInt& aResultIndex); |
|
254 TBool FindNearestImageInOGl(const FloatCoords aPos, TInt& aResultIndex); |
|
255 TBool SetMinMagFilter(CImageData* aImageData, TBool aMagFilterLinear, TInt aIndex); |
|
256 void ShowMagGlass(const TBool aState); |
|
257 |
|
258 void LoadHQ512Image(CImageData* imageData, TInt aIndex); |
|
259 void DrawFaceBrowsingIcon(); |
|
260 void DrawZoomIcon(); |
|
261 void SetMinMagFiltering(); |
|
262 void ResetZoomKeys(); |
|
263 void ResetDirKeyData(); |
|
264 void HandleDrawingModeSwitch(TDrawFunction& aDrawFunction); |
|
265 void LoadHighResImage(CImageData* imageData, TInt aIndex); |
|
266 //void CheckIndexLimits(TInt &aIndex); |
|
267 |
|
268 public: |
|
269 void SetDrawFreqToNormal(TInt aTimerDelay); |
|
270 TInt UpdateScreenDrawFreq(); |
|
271 void CalculateImageSize(float& width, float& height, const float aAspectRatio); |
|
272 void HandleRotation(float& aRotationAngle, float& aTargetRotationAngle); |
|
273 void SetCurrentFaceNro(TInt aNro); |
|
274 void GetCurrentFilenameL(TFileName& aFilename, TThumbSize aRes); |
|
275 void ConvertScreenCoords2QvgaCoords(TPoint& aPoint, TRect& aRect); |
|
276 TBool FindNearestFace(const TPoint aPos, TInt& aResultIndex); |
|
277 void SetLastTouchPoint(const TPoint& aPos); |
|
278 TPoint GetLastTouchPoint(void); |
|
279 void SetTextIndex(GLuint aIndex); |
|
280 void IconTexturesLoaded(RArray<GLuint> aIconTexIndex); |
|
281 void Interpolate(float &aValue, const float aTarget, const float aStep); |
|
282 TBool GetScreenOrientation(); |
|
283 void InitAfterPowerSaveL(); |
|
284 void NewImageAdded(); |
|
285 void ImageListChanged(TInt aIndex, TBool bAdded); |
|
286 #ifdef _ACCELEROMETER_SUPPORTED_ |
|
287 TImagicDeviceOrientation CImagicContainerBrowser::GetDeviceOrientation(); |
|
288 void PhoneRotated(TImagicDeviceOrientation aDeviceOrientation); |
|
289 #endif |
|
290 TBool IsHwAcceleration(); |
|
291 void HandleSend2BackgroundEvent(); |
|
292 void InitFaceBrowsing(); |
|
293 TBool IsTouchPointThresholdExeed(); |
|
294 float GetDisplayRotTargetAngle(); |
|
295 float GetDisplayRotAngle(); |
|
296 void SetDisplayRotAngle(float aValue); |
|
297 TReal GetMaxX() const; |
|
298 |
|
299 CKeyData& GetKeyData(); |
|
300 void SetKeyData(CKeyData aData); |
|
301 void ResetKeyData(); |
|
302 |
|
303 CKeyData& GetTouchData(); |
|
304 void SetTouchData(CKeyData aData); |
|
305 void ResetTouchData(); |
|
306 |
|
307 TBool GetSlideByDragValue(); |
|
308 TInt GetCurrentIndex(); |
|
309 TInt GetPrevIndex(); |
|
310 void SetCurrentIndex(TInt aIndex); |
|
311 void SetPrevIndex(TInt aIndex); |
|
312 TInt GetGleMaxRes(); |
|
313 void ResetHighResLoading(); |
|
314 void DynamicUnLoading(); |
|
315 TBool IsUserInputGiven(); |
|
316 TSize GetScreenSize(); |
|
317 void SetScreenImmeadetaUpdate(TBool aValue); |
|
318 |
|
319 /*----------------------------------------------------------------------*/ |
|
320 |
|
321 private: //data |
|
322 CImagicAppUi* iImagicAppUi;//App UI class pointer |
|
323 CIEEngine* iIEngine; |
|
324 CImagicViewBrowser* iView;//Browser view class pointer |
|
325 //CTextureLoader* iTextureLoader; |
|
326 CGesture* iGesture; |
|
327 CDrawUtility* iDrawUtility; |
|
328 |
|
329 friend class CTextureLoader; |
|
330 CTextureLoader* iTextureLoader; |
|
331 friend class CDrawGrid; |
|
332 CDrawGrid* iDrawGrid; |
|
333 friend class CDrawOneByOne; |
|
334 CDrawOneByOne* iDrawOneByOne; |
|
335 friend class CDrawFaceBrowsing; |
|
336 CDrawFaceBrowsing* iDrawFaceBrowsing; |
|
337 friend class CDrawMagGlass; |
|
338 //CDrawMagGlass* iDrawMagGlass; |
|
339 |
|
340 |
|
341 |
|
342 |
|
343 private: //data |
|
344 /*----------------------------------------------------------------------*/ |
|
345 //OpenGL valiables |
|
346 //Flag that indicates if OpenGL ES has been initialized or not. |
|
347 TBool iOpenGlInitialized; |
|
348 //Display where the OpenGL ES window surface resides. |
|
349 EGLDisplay iEglDisplay; |
|
350 //Window surface where the OpenGL ES rendering is blitted to. |
|
351 EGLSurface iEglSurface; |
|
352 // OpenGL ES rendering context. |
|
353 EGLContext iEglContext; |
|
354 //Active object that is the timing source for the animation. |
|
355 CPeriodic* iPeriodic; |
|
356 CPeriodic* iPowerSavePeriodic; |
|
357 /*----------------------------------------------------------------------*/ |
|
358 |
|
359 //Variables used to calculate time |
|
360 GLfloat iLastTime; |
|
361 GLfloat iTimeNow; |
|
362 GLfloat iTimeDiff; |
|
363 |
|
364 /*----------------------------------------------------------------------*/ |
|
365 //Variables for OneByOne init |
|
366 TBool iOnTheEdge; |
|
367 TBool iTouchPointThreshold; |
|
368 TBool iKeyPressedDown; |
|
369 |
|
370 /*----------------------------------------------------------------------*/ |
|
371 TInt iCurrentIndex;// Selected picture index |
|
372 TInt iPreviousIndex;// One before selected picture index |
|
373 |
|
374 /*----------------------------------------------------------------------*/ |
|
375 |
|
376 |
|
377 //Draw function enum, OneByOne and Grid implemented, add here more when new draw function are created |
|
378 enum TDrawFunction iDrawFunction; |
|
379 |
|
380 |
|
381 //Struct for KeyData, this struct holds all data for key events handling |
|
382 CKeyData iTouchMoveData; |
|
383 CKeyData iKeyData; |
|
384 |
|
385 float iDisplayRotation;//This controls the whole display rotation, not single picture |
|
386 float iDisplayRotationTarget;//Display target rotation angle |
|
387 TBool iScreenRotateOngoing; |
|
388 TReal iScreenAspectRatio; |
|
389 TSize iScreenSize; |
|
390 |
|
391 TBool iTNCreationComplete; // Set TRue if TNs are created |
|
392 RCriticalSection iDrawLock; |
|
393 |
|
394 //Texture related variables |
|
395 GLuint iCurrentBindedIndex; |
|
396 TInt iLoadingTextureIndex; // texture to draw if no image exist |
|
397 TInt iExitTextureIndex; // texture to draw if no image exist |
|
398 TInt iMenuTextureIndex; // texture to draw if no image exist |
|
399 #ifdef SHADOW_PHOTOS |
|
400 TInt iShadowTextureIndex; |
|
401 #endif |
|
402 TInt iDisplayDrawFreq; |
|
403 GLint iGLMaxRes;//OpenGL max texture resolution |
|
404 |
|
405 // CRemConInterfaceSelector* iSelector; |
|
406 // CRemConCoreApiTarget* iTarget; |
|
407 |
|
408 //When set on drawing is enabled |
|
409 TBool iDrawNow; |
|
410 |
|
411 //Image loading related flags |
|
412 TBool iDynamicLoadingOn;//Set on for dynamic loading |
|
413 TBool iNewImageAdded;//New image added to array |
|
414 TInt iIsLoaderRunning; |
|
415 |
|
416 TBool iMagFilterLinear;//Set on when linear filtering is wanted |
|
417 |
|
418 RArray<GLuint> iIconTextureIndexes;//Array to hold icon textures |
|
419 TBool iMinMagFilterSetting; |
|
420 TBool iPreferHighResLoading;//Set this on when want to load high resolution image(stops loading low res images) |
|
421 |
|
422 |
|
423 #ifdef USE_AVKON_LONGTAP_DETECTOR |
|
424 CAknLongTapDetector* iLongTapDetector; |
|
425 #endif |
|
426 #ifdef USE_AVKON_TACTILE_FEEDBACK |
|
427 MTouchFeedback* iTouchFeedBack; |
|
428 #endif |
|
429 |
|
430 TPoint iLastTouchPoint; |
|
431 |
|
432 #ifdef HOLD_SELECTION_ONDRAG |
|
433 TBool iHoldSelection; |
|
434 TBool iOneByOneSlideByDrag; |
|
435 #endif |
|
436 #ifdef MOMENTUM_MOVE |
|
437 TBool iMomentumMove; |
|
438 float iMomentumSpeedX; |
|
439 float iMomentumSpeedY; |
|
440 #endif |
|
441 |
|
442 TReal iDeviceOrientationAngle; |
|
443 #ifdef _ACCELEROMETER_SUPPORTED_ |
|
444 TImagicDeviceOrientation iDeviceOrientation; |
|
445 TImagicDeviceOrientation iDeviceOrientationPrev; |
|
446 #else |
|
447 TBool iDeviceOrientation; |
|
448 #endif |
|
449 |
|
450 #ifdef ADAPTIVE_FRAMERATE |
|
451 TInt iWaitDrawTicks; |
|
452 #endif |
|
453 |
|
454 //Remove these |
|
455 TBool iIntheEndOfGrid; |
|
456 TBool iJumpOver; |
|
457 TInt iDrawOnes; |
|
458 |
|
459 TBool iUserInputGiven; |
|
460 TBool iDeleteTextures; |
|
461 TBool iScreenImmeadetaUpdate; |
|
462 |
|
463 TReal drawZoom; |
|
464 TReal inPictureX; |
|
465 TReal inPictureY; |
|
466 |
|
467 TBool iLastEventFromKeys; |
|
468 |
|
469 //Class consts |
|
470 static const GLfixed iGlobalTexCoords[4*2]; |
|
471 static const float KMinOneByOneZoom; |
|
472 static const float KMaxOneByOneZoom; |
|
473 static const TInt KDoubleTapZoomOneByOne1; |
|
474 static const TInt KDoubleTapZoomOneByOne2; |
|
475 static const TReal KAngle2Start128Loading; |
|
476 static const TReal KAngle2Start128LoadingHwAcc; |
|
477 static const float KSpacingX;// Picture spacing in the grid |
|
478 static const float KSpacingY;// Picture spacing in the grid |
|
479 static const float KSpacingYTarget; |
|
480 static const float KSpacingXTarget; |
|
481 // Space between pictures in one by one |
|
482 static const float KOneByOneSpacing; |
|
483 static const TInt KGridSizeY; |
|
484 |
|
485 static /*const*/ TInt K512TNImageBuffer; |
|
486 static const TInt K128TNImageBuffer; |
|
487 static /*const*/ TInt K32TNImageBuffer; |
|
488 static /*const*/ TInt K32TNImageUnLoadBuffer; |
|
489 |
|
490 }; |
|
491 |
|
492 #endif |
|
493 |
|
494 // End of File |