|
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 #include "CDrawOneByOne.h" |
|
19 #include "TextureLoader.h" |
|
20 #include "DrawUtility.h" |
|
21 #include "ImagicConsts.h" |
|
22 |
|
23 #define IS_NOT_IN_ZOOM_ONEBYONE ((iDrawOneByOneTargetZoom) < (iContainer->KDoubleTapZoomOneByOne1 + 0.01f)) |
|
24 #define IS_ALMOST_ZERO (0.001) |
|
25 |
|
26 |
|
27 const float CDrawOneByOne::KMaxMagGlassZoomFactor = 2.2;//2.0; |
|
28 const float KOneByOneSlideSpeed = 0.24; |
|
29 |
|
30 |
|
31 CDrawOneByOne::CDrawOneByOne(CImagicContainerBrowser* aContainer, TInt& aCurrentIndex): |
|
32 iContainer(aContainer)//, |
|
33 { |
|
34 iMagGlassOn = EFalse; |
|
35 iMagGlassOnPrev = EFalse; |
|
36 } |
|
37 |
|
38 CDrawOneByOne::~CDrawOneByOne() |
|
39 { |
|
40 delete iMagGlass; |
|
41 } |
|
42 |
|
43 CDrawOneByOne* CDrawOneByOne::NewLC(CImagicContainerBrowser* aContainer, TInt& aCurrentIndex) |
|
44 { |
|
45 CDrawOneByOne* self = new (ELeave) CDrawOneByOne(aContainer, aCurrentIndex); |
|
46 CleanupStack::PushL(self); |
|
47 self->ConstructL(aContainer, aCurrentIndex); |
|
48 return self; |
|
49 } |
|
50 |
|
51 CDrawOneByOne* CDrawOneByOne::NewL(CImagicContainerBrowser* aContainer, TInt& aCurrentIndex) |
|
52 { |
|
53 CDrawOneByOne* self = CDrawOneByOne::NewLC(aContainer, aCurrentIndex); |
|
54 CleanupStack::Pop(); // self; |
|
55 return self; |
|
56 } |
|
57 |
|
58 void CDrawOneByOne::ConstructL(CImagicContainerBrowser* aContainer, TInt& aCurrentIndex) |
|
59 { |
|
60 iMagGlass = CDrawMagGlass::NewL(iContainer, this); |
|
61 } |
|
62 |
|
63 float CDrawOneByOne::GetMovingStep() |
|
64 { |
|
65 //iMovingStep = 0.01/(iDrawOneByOneZoom/8.0); |
|
66 iMovingStep = 0.015/(iDrawOneByOneZoom/8.0); |
|
67 return iMovingStep; |
|
68 } |
|
69 |
|
70 float CDrawOneByOne::GetImgeFlowLocation() |
|
71 { |
|
72 return iOneByOneFlow; |
|
73 } |
|
74 |
|
75 void CDrawOneByOne::SetImgeFlowLocation(float aValue) |
|
76 { |
|
77 iOneByOneFlow = aValue; |
|
78 } |
|
79 |
|
80 TDrawOneByOneXY CDrawOneByOne::GetDrawOneByOneXY() |
|
81 { |
|
82 return iDrawOneByOneXY; |
|
83 } |
|
84 |
|
85 TDrawOneByOneXY CDrawOneByOne::GetDrawOneByOneTargetXY() |
|
86 { |
|
87 return iDrawOneByOneTargetXY; |
|
88 } |
|
89 |
|
90 void CDrawOneByOne::SetDrawOneByOneTargetXY(TDrawOneByOneXY aValue) |
|
91 { |
|
92 iDrawOneByOneTargetXY = aValue; |
|
93 } |
|
94 |
|
95 void CDrawOneByOne::ChangeDrawOneByOneTargetX(float aValue) |
|
96 { |
|
97 iDrawOneByOneTargetXY.iX += aValue; |
|
98 } |
|
99 |
|
100 void CDrawOneByOne::ChangeDrawOneByOneTargetY(float aValue) |
|
101 { |
|
102 iDrawOneByOneTargetXY.iY += aValue; |
|
103 } |
|
104 |
|
105 float CDrawOneByOne::GetDrawOneByOneZoom() |
|
106 { |
|
107 return iDrawOneByOneZoom; |
|
108 } |
|
109 |
|
110 void CDrawOneByOne::SetDrawOneByOneZoom(float aValue) |
|
111 { |
|
112 iDrawOneByOneZoom = aValue; |
|
113 } |
|
114 |
|
115 float CDrawOneByOne::GetDrawOneByOneTargetZoom() |
|
116 { |
|
117 return iDrawOneByOneTargetZoom; |
|
118 } |
|
119 |
|
120 void CDrawOneByOne::SetDrawOneByOneTargetZoom(float aValue) |
|
121 { |
|
122 iDrawOneByOneTargetZoom = aValue; |
|
123 } |
|
124 |
|
125 float CDrawOneByOne::GetDrawOneByOneWidth() |
|
126 { |
|
127 return iDrawOnebyOneW; |
|
128 } |
|
129 |
|
130 void CDrawOneByOne::SetDrawOneByOneWidth(float aValue) |
|
131 { |
|
132 iDrawOnebyOneW = aValue; |
|
133 } |
|
134 |
|
135 float CDrawOneByOne::GetDrawOneByOneHeight() |
|
136 { |
|
137 return iDrawOnebyOneH; |
|
138 } |
|
139 |
|
140 void CDrawOneByOne::SetDrawOneByOneHeight(float aValue) |
|
141 { |
|
142 iDrawOnebyOneH = aValue; |
|
143 } |
|
144 |
|
145 TBool CDrawOneByOne::IsMagGlassOn() |
|
146 { |
|
147 return iMagGlassOn; |
|
148 } |
|
149 |
|
150 void CDrawOneByOne::SetMagGlassStatus(TBool aValue) |
|
151 { |
|
152 iMagGlassOn = aValue; |
|
153 iMagGlass->InitDrawMagGlass(); |
|
154 } |
|
155 |
|
156 TBool CDrawOneByOne::IsMagGlassPrevStateOn() |
|
157 { |
|
158 return iMagGlassOnPrev; |
|
159 } |
|
160 |
|
161 void CDrawOneByOne::SetMagGlassPrevStatus(TBool aValue) |
|
162 { |
|
163 iMagGlassOnPrev = aValue; |
|
164 } |
|
165 |
|
166 CDrawMagGlass* CDrawOneByOne::GetMagGlass() |
|
167 { |
|
168 return iMagGlass; |
|
169 } |
|
170 |
|
171 void CDrawOneByOne::KeyPressed() |
|
172 { |
|
173 iMenuAlpha = 1; |
|
174 } |
|
175 |
|
176 void CDrawOneByOne::KeyReleased() |
|
177 { |
|
178 iMenuAlpha = 0.99; |
|
179 } |
|
180 |
|
181 void CDrawOneByOne::KeyEvent() |
|
182 { |
|
183 //iMenuAlpha = 1; |
|
184 } |
|
185 |
|
186 /*----------------------------------------------------------------------*/ |
|
187 // Initializes one by one view |
|
188 // |
|
189 void CDrawOneByOne::InitDrawOnebyOne(TReal aDrawZoom, TReal aInPictureX, TReal aInPictureY) |
|
190 { |
|
191 DP0_IMAGIC(_L("CDrawOneByOne::InitDrawOnebyOne")); |
|
192 |
|
193 //iDrawOneByOneXY.iX = 0; |
|
194 //iDrawOneByOneXY.iY = 0; |
|
195 iDrawOneByOneXY.iX = aInPictureX; |
|
196 iDrawOneByOneXY.iY = aInPictureY; |
|
197 iDrawOneByOneTargetXY.iX = 0; |
|
198 iDrawOneByOneTargetXY.iY = 0; |
|
199 |
|
200 //iDrawOneByOneZoom = 0.1; |
|
201 //if(aDrawZoom == 1) |
|
202 iDrawOneByOneZoom = aDrawZoom; |
|
203 /*else |
|
204 iDrawOneByOneZoom = 0.4;*/ |
|
205 |
|
206 iDrawOneByOneTargetZoom = 1; |
|
207 TSize size = iContainer->Size(); |
|
208 iContainer->CalculateImageSize(iDrawOnebyOneW, iDrawOnebyOneH, (float)size.iWidth/(float)size.iHeight); |
|
209 |
|
210 iZoomingStep = 0.1 * iDrawOneByOneTargetZoom; |
|
211 iZoomingSpeed = 0.2; // unno 2.5*iTimeDiff; |
|
212 iScalingSpeed = 0.3; |
|
213 iOneByOneFlow = 0; |
|
214 iMagGlassOn = EFalse; |
|
215 iMagGlassOnPrev = EFalse; |
|
216 #ifdef HOLD_SELECTION_ONDRAG |
|
217 iContainer->iOneByOneSlideByDrag = EFalse; |
|
218 #endif |
|
219 |
|
220 iBorder = 0.03; |
|
221 iScreenW = 0; |
|
222 iScreenH = 0; |
|
223 iInPictureX = 0; |
|
224 iInPictureY = 0; |
|
225 |
|
226 //iContainer->iDrawFunction = CImagicContainerBrowser::EOneByOne; |
|
227 iContainer->SetDrawMode(CImagicContainerBrowser::EOneByOne); |
|
228 iContainer->iKeyPressedDown=EFalse; |
|
229 //iContainer->iZoomInKey=EFalse; |
|
230 //iContainer->iZoomOutKey=EFalse; |
|
231 |
|
232 |
|
233 iMagGlass->InitDrawMagGlass(); |
|
234 |
|
235 } |
|
236 /*----------------------------------------------------------------------*/ |
|
237 //Draws one by one view |
|
238 // |
|
239 void CDrawOneByOne::DrawOnebyOneL(const TSize &aSize) |
|
240 { |
|
241 DP0_IMAGIC(_L("CDrawOneByOne::DrawOnebyOne")); |
|
242 //RDebug::Print(_L("CDrawOneByOne::DrawOnebyOne")); |
|
243 |
|
244 CImageData* imageData = iContainer->iIEngine->GetImageData(iContainer->GetCurrentIndex()); |
|
245 |
|
246 // Calculate screen size |
|
247 iContainer->CalculateImageSize(iImageWidth, iImageHeight, (float)aSize.iWidth/(float)aSize.iHeight); |
|
248 |
|
249 //Interpolate current screen size into the new one |
|
250 //if(iContainer->iLastEventFromKeys) |
|
251 { |
|
252 iContainer->Interpolate(iDrawOnebyOneW, iImageWidth, 0.55); |
|
253 iContainer->Interpolate(iDrawOnebyOneH, iImageHeight, 0.55); |
|
254 } |
|
255 /*else//faster interpolation for touch bcos slide speed is also faster |
|
256 { |
|
257 iContainer->Interpolate(iDrawOnebyOneW, iImageWidth, 0.85); |
|
258 iContainer->Interpolate(iDrawOnebyOneH, iImageHeight, 0.85); |
|
259 }*/ |
|
260 //iContainer->Interpolate(iDrawOnebyOneW, iImageWidth, 0.55); |
|
261 //iContainer->Interpolate(iDrawOnebyOneH, iImageHeight, 0.55); |
|
262 |
|
263 |
|
264 //Use orthogonal projection in OneByOne mode |
|
265 glLoadIdentity(); |
|
266 glOrthof(-iDrawOnebyOneW, iDrawOnebyOneW, -iDrawOnebyOneH, iDrawOnebyOneH, -1,1); |
|
267 |
|
268 //iContainer->Interpolate(iContainer->iDisplayRotation, iContainer->iDisplayRotationTarget, 0.2); |
|
269 float tmp = iContainer->GetDisplayRotAngle(); |
|
270 iContainer->Interpolate(tmp, iContainer->GetDisplayRotTargetAngle(), 0.2); |
|
271 iContainer->SetDisplayRotAngle(tmp); |
|
272 glRotatef(iContainer->GetDisplayRotAngle(), 0,0,1); |
|
273 |
|
274 // Handle keys-----------------------> |
|
275 HandleMovingKeysOnebyOne(); |
|
276 |
|
277 // Calculate picture size |
|
278 iContainer->CalculateImageSize(iImageWidth, iImageHeight, imageData->GetAspectRatio()); |
|
279 |
|
280 //Here we check that we do not go over the picture boundaries |
|
281 CheckImageLocation(); |
|
282 |
|
283 |
|
284 //Move in picture------------------------> |
|
285 iDrawOneByOneTargetXY.iX = iInPictureX / iDrawOneByOneTargetZoom; |
|
286 iDrawOneByOneTargetXY.iY = iInPictureY / iDrawOneByOneTargetZoom; |
|
287 |
|
288 //iMovingStep = 0.01/(iDrawOneByOneZoom/8); |
|
289 |
|
290 iContainer->Interpolate(iDrawOneByOneXY.iX,iDrawOneByOneTargetXY.iX, iMovingSpeed); |
|
291 iContainer->Interpolate(iDrawOneByOneXY.iY,iDrawOneByOneTargetXY.iY, iMovingSpeed); |
|
292 |
|
293 // Zooming--------------------------------> |
|
294 if(iContainer->iKeyPressedDown) |
|
295 { |
|
296 if(iContainer->GetKeyData().iZoomInKey) |
|
297 iDrawOneByOneTargetZoom += iZoomingStep*2;//zoom in |
|
298 else if(iContainer->GetKeyData().iZoomOutKey) |
|
299 iDrawOneByOneTargetZoom -= iZoomingStep*4;//zoom out |
|
300 } |
|
301 |
|
302 |
|
303 //Limit zooming range |
|
304 iContainer->CheckLimits(iDrawOneByOneTargetZoom, CImagicContainerBrowser::KMinOneByOneZoom, CImagicContainerBrowser::KMaxOneByOneZoom); |
|
305 |
|
306 // Interpolate to new zoom value |
|
307 if(iDrawOneByOneZoom < 0.99) |
|
308 iContainer->Interpolate(iDrawOneByOneZoom, iDrawOneByOneTargetZoom, iScalingSpeed); |
|
309 else |
|
310 iContainer->Interpolate(iDrawOneByOneZoom, iDrawOneByOneTargetZoom, iZoomingSpeed); |
|
311 |
|
312 // Rotation |
|
313 iContainer->HandleRotationKeys(); |
|
314 iContainer->HandleRotation(imageData->iGridData.iRotationAngle, imageData->iGridData.iTargetRotationAngle); |
|
315 |
|
316 |
|
317 //Load image -----------------------------------> |
|
318 // Load high res picture if possible |
|
319 //if(iOneByOneFlow < IS_ALMOST_ZERO)//when not zero, images are moving |
|
320 if(iOneByOneFlow == 0)//when not zero, images are moving in oneByOne flow |
|
321 { |
|
322 iContainer->LoadHighResImage(imageData, iContainer->GetCurrentIndex()); |
|
323 } |
|
324 |
|
325 |
|
326 //Bind and Draw -------------------------------------> |
|
327 //Bind to Grid low res texture index. If high res is not available, so we have always some picture to bind and draw it |
|
328 // Determine image indexes, -1 means no image |
|
329 TInt imageIndexes[3]={-1,iContainer->GetCurrentIndex(),-1}; |
|
330 |
|
331 //Do not draw other images when not sliding and we are in zoomed into picture |
|
332 //if(iOneByOneFlow != 0)//when not zero, images are moving |
|
333 //if(!iMagGlassOn || IS_NOT_IN_ZOOM_ONEBYONE) |
|
334 { |
|
335 if (iContainer->GetCurrentIndex()>0) |
|
336 imageIndexes[0]=iContainer->GetCurrentIndex()-1; |
|
337 if (iContainer->GetCurrentIndex() < iContainer->iIEngine->GetTotalNumOfImages()-1) |
|
338 imageIndexes[2]=iContainer->GetCurrentIndex()+1; |
|
339 } |
|
340 |
|
341 //Fade side images when flow goes 70% of image width |
|
342 if(Abs(iOneByOneFlow) > 0.25) |
|
343 { |
|
344 iFadeColor=1; |
|
345 glColor4f(iFadeColor,iFadeColor,iFadeColor, 1); |
|
346 } |
|
347 if(iOneByOneFlow < 0.5) |
|
348 { |
|
349 //if(iContainer->iLastEventFromKeys) |
|
350 iContainer->Interpolate(iFadeColor, 0, 0.25); |
|
351 /*else |
|
352 iContainer->Interpolate(iFadeColor, 0, 0.35);*/ |
|
353 |
|
354 glColor4f(iFadeColor,iFadeColor,iFadeColor, 1); |
|
355 } |
|
356 |
|
357 /*if(iFadeColor == 0) |
|
358 { |
|
359 // Determine image indexes, -1 means no image |
|
360 TInt imageIndexes[3]={-1,iContainer->GetCurrentIndex(),-1}; |
|
361 }*/ |
|
362 |
|
363 //Move to zero coordinate, which is selected image coordinate |
|
364 #ifdef HOLD_SELECTION_ONDRAG |
|
365 //Stop interpolation when user is dragging |
|
366 if(iContainer->iHoldSelection == EFalse) |
|
367 { |
|
368 #endif |
|
369 if(iContainer->iLastEventFromKeys) |
|
370 iContainer->Interpolate(iOneByOneFlow, 0, KOneByOneSlideSpeed);//sliding speed |
|
371 else |
|
372 iContainer->Interpolate(iOneByOneFlow, 0, KOneByOneSlideSpeed*1.3);//sliding speed |
|
373 } |
|
374 |
|
375 //glColor4f(1,1,1, 1); |
|
376 glPushMatrix(); |
|
377 glScalef(iDrawOneByOneZoom, iDrawOneByOneZoom, iDrawOneByOneZoom); |
|
378 //Move to first image location (= current-1) |
|
379 glTranslatef(iOneByOneFlow-iContainer->KOneByOneSpacing,0,0); |
|
380 |
|
381 TInt currentIndexTexture=0; |
|
382 for(TInt i=0; i<3; i++) |
|
383 { |
|
384 // Check that image index is valid |
|
385 if (imageIndexes[i]!=-1) |
|
386 { |
|
387 //Bind to best picture |
|
388 CImageData* data=iContainer->iIEngine->GetImageData(imageIndexes[i]); |
|
389 if(i==1) |
|
390 { |
|
391 iContainer->iCurrentBindedIndex = data->iGridData.BestImage(); |
|
392 //Bind to 512 res image when not zoomed for better image scaling quality |
|
393 if(IS_NOT_IN_ZOOM_ONEBYONE && data->iGridData.iGlHQ512TextIndex!=0 && !iMagGlassOn) |
|
394 iContainer->iCurrentBindedIndex = data->iGridData.iGlHQ512TextIndex; |
|
395 } |
|
396 //Side images gets only 128x128 tn because of perf reason |
|
397 else |
|
398 iContainer->iCurrentBindedIndex = data->iGridData.iGlLQ128TextIndex; |
|
399 if(!iContainer->iCurrentBindedIndex) |
|
400 iContainer->iCurrentBindedIndex = data->iGridData.iGlLQ32TextIndex; |
|
401 |
|
402 |
|
403 //If no images ready, bind with loading tn |
|
404 if (iContainer->iCurrentBindedIndex == 0) |
|
405 iContainer->iCurrentBindedIndex = iContainer->iLoadingTextureIndex; |
|
406 |
|
407 glBindTexture(GL_TEXTURE_2D, iContainer->iCurrentBindedIndex); |
|
408 |
|
409 if(i==1){ |
|
410 currentIndexTexture=iContainer->iCurrentBindedIndex; |
|
411 } |
|
412 iContainer->SetMinMagFilterLinearDo(iContainer->iMinMagFilterSetting); |
|
413 |
|
414 //Store matrix and rotate picture |
|
415 glPushMatrix(); |
|
416 |
|
417 if(i==1 && iMagGlassOn) |
|
418 { |
|
419 glColor4f(1,1,1, 1); |
|
420 glTranslatef(iDrawOneByOneXY.iX, -iDrawOneByOneXY.iY, 0); |
|
421 glRotatef(data->iGridData.iRotationAngle, 0,0,1); |
|
422 iMagGlass->DrawMagGlass(aSize, data->GetAspectRatio()); |
|
423 } |
|
424 else |
|
425 { |
|
426 //Set Draw color to white when drawing selection or if we drag images |
|
427 if(i==1 || (iContainer->iHoldSelection && !iMagGlassOn)) |
|
428 glColor4f(1,1,1, 1); |
|
429 else//othervise "fade" images |
|
430 glColor4f(iFadeColor,iFadeColor,iFadeColor, 1); |
|
431 |
|
432 glTranslatef(-iDrawOneByOneXY.iX, iDrawOneByOneXY.iY, 0); |
|
433 glRotatef(data->iGridData.iRotationAngle, 0,0,1); |
|
434 // Set vertixes and draw |
|
435 GLfixed vertices[8]; |
|
436 iContainer->SetPictureVertices(data, vertices); |
|
437 glVertexPointer( 2, GL_FIXED, 0, vertices ); |
|
438 glDrawArrays(GL_TRIANGLE_STRIP,0,4); |
|
439 #ifdef EMPTY_IMAGE_AS_WIREFRAME |
|
440 // Draw black frame with white borders |
|
441 if (iContainer->iCurrentBindedIndex == 0) |
|
442 { |
|
443 glScalef(0.92, 0.92, 0.92); |
|
444 glColor4f(0,0,0,1); |
|
445 glDrawArrays(GL_TRIANGLE_STRIP,0,4); |
|
446 } |
|
447 #endif |
|
448 |
|
449 } |
|
450 |
|
451 #ifdef RD_FACEFRAME |
|
452 //if (i==1 && iDrawFaceFrame) DrawFaceFrame(); |
|
453 #endif |
|
454 |
|
455 //Remove rotation |
|
456 glPopMatrix(); |
|
457 } |
|
458 // Move to next image position |
|
459 glTranslatef(iContainer->KOneByOneSpacing,0,0); |
|
460 } |
|
461 glPopMatrix(); |
|
462 |
|
463 if(currentIndexTexture!=iContainer->iCurrentBindedIndex) |
|
464 { |
|
465 iContainer->iCurrentBindedIndex = currentIndexTexture; |
|
466 glBindTexture(GL_TEXTURE_2D, iContainer->iCurrentBindedIndex); |
|
467 iContainer->SetMinMagFilterLinearDo(iContainer->iMinMagFilterSetting); |
|
468 } |
|
469 |
|
470 #ifdef SCR_DRAW_DEBUG |
|
471 iDrawUtility->Update(); |
|
472 iDrawUtility->Draw(Size()); |
|
473 #endif |
|
474 |
|
475 |
|
476 |
|
477 //iContainer->iDrawUtility->DrawMenuIndicators(iContainer->Size()); |
|
478 |
|
479 |
|
480 #ifdef RD_ZOOMICON |
|
481 //Draw moving direction arrays when sliding in OnByOne mode |
|
482 if(!iMagGlassOn && iFadeColor!=0 || iOneByOneFlow != 0) |
|
483 iContainer->iDrawUtility->DrawMovingArrow(ETrue, EFalse, iContainer->Size()); |
|
484 |
|
485 //Draw moving direction arrays when zoomed in |
|
486 if (!IS_NOT_IN_ZOOM_ONEBYONE && |
|
487 (iDrawOneByOneXY.iX != iDrawOneByOneTargetXY.iX || |
|
488 iDrawOneByOneXY.iY != iDrawOneByOneTargetXY.iY || |
|
489 iDrawOneByOneZoom != iDrawOneByOneTargetZoom || |
|
490 imageData->iGridData.iRotationAngle != imageData->iGridData.iTargetRotationAngle || |
|
491 iContainer->iOnTheEdge)) |
|
492 { |
|
493 /*if(!iMagGlassOn) |
|
494 { |
|
495 iContainer->iDrawUtility->DrawMovingArrow(ETrue, !IS_NOT_IN_ZOOM_ONEBYONE, iContainer->Size()); |
|
496 }*/ |
|
497 |
|
498 iContainer->iDrawUtility->DrawZoomIcon( imageData, |
|
499 iContainer->Size(), |
|
500 -iDrawOneByOneXY.iX, |
|
501 iDrawOneByOneXY.iY, |
|
502 iDrawOnebyOneW/iImageWidth, |
|
503 iDrawOnebyOneH/iImageHeight, |
|
504 ETrue); |
|
505 } |
|
506 #endif |
|
507 |
|
508 #if 0 |
|
509 if(iMenuAlpha < 1) |
|
510 { |
|
511 iMenuAlpha-=0.3; |
|
512 if(iMenuAlpha < 0) |
|
513 iMenuAlpha = 0; |
|
514 } |
|
515 |
|
516 iContainer->iDrawUtility->DrawIcon2(iContainer->Size(), iContainer->iMenuTextureIndex, iMenuAlpha); |
|
517 #endif |
|
518 iContainer->DynamicLoadingL(); |
|
519 } |
|
520 |
|
521 |
|
522 TBool CDrawOneByOne::IsDrawingNeededOneByOne() |
|
523 { |
|
524 CImageData* imageData = iContainer->iIEngine->GetImageData(iContainer->GetCurrentIndex()); |
|
525 |
|
526 #if 0 |
|
527 if(iMenuAlpha != 0) |
|
528 { |
|
529 return ETrue; |
|
530 } |
|
531 #endif |
|
532 |
|
533 if(Abs(iOneByOneFlow) > 0.01) |
|
534 { |
|
535 DP0_IMAGIC(_L("CDrawOneByOne::IsDrawingNeededOneByOne - 2")); |
|
536 iContainer->SetMinMagFilterLinear(EFalse); |
|
537 return ETrue; |
|
538 } |
|
539 else if(iOneByOneFlow!=0) |
|
540 { |
|
541 DP0_IMAGIC(_L("CDrawOneByOne::IsDrawingNeededOneByOne - 3")); |
|
542 iOneByOneFlow=0; |
|
543 //if(imageData->iGridData.iGlHQ512TextIndex != 0) |
|
544 //iContainer->iDrawOneMoreTime = ETrue; |
|
545 iContainer->SetMinMagFilterLinear(ETrue); |
|
546 return ETrue; |
|
547 } |
|
548 |
|
549 if(iMagGlassOnPrev != iMagGlassOn) |
|
550 { |
|
551 DP0_IMAGIC(_L("CDrawOneByOne::IsDrawingNeededOneByOne - 4")); |
|
552 iMagGlassOnPrev = iMagGlassOn; |
|
553 //SetMinMagFilterLinear(ETrue); |
|
554 //iContainer->iDrawOneMoreTime = ETrue; |
|
555 return ETrue; |
|
556 } |
|
557 |
|
558 if(iMagGlassOn && (iMagGlass->GetMagGlassZoomFactor() < KMaxMagGlassZoomFactor-0.1)) |
|
559 { |
|
560 DP0_IMAGIC(_L("CDrawOneByOne::IsDrawingNeededOneByOne - 5")); |
|
561 DP1_IMAGIC(_L("CDrawOneByOne::IsDrawingNeededOneByOne - magGlass: %f"), iMagGlass->GetMagGlassZoomFactor()); |
|
562 iMagGlassOnPrev = iMagGlassOn; |
|
563 iContainer->SetMinMagFilterLinear(EFalse); |
|
564 return ETrue; |
|
565 } |
|
566 |
|
567 if(Abs(iContainer->GetDisplayRotAngle() - iContainer->GetDisplayRotTargetAngle()) > 1) |
|
568 { |
|
569 DP0_IMAGIC(_L("CDrawOneByOne::IsDrawingNeededOneByOne - 6")); |
|
570 iContainer->SetMinMagFilterLinear(EFalse); |
|
571 return ETrue; |
|
572 } |
|
573 else if(iContainer->GetDisplayRotAngle() != iContainer->GetDisplayRotTargetAngle()) |
|
574 { |
|
575 DP0_IMAGIC(_L("CDrawOneByOne::IsDrawingNeededOneByOne - 6.1")); |
|
576 iContainer->SetDisplayRotAngle(iContainer->GetDisplayRotTargetAngle()); |
|
577 iContainer->SetMinMagFilterLinear(ETrue); |
|
578 return ETrue; |
|
579 } |
|
580 |
|
581 if(Abs(imageData->iGridData.iRotationAngle - imageData->iGridData.iTargetRotationAngle) > 1) |
|
582 { |
|
583 DP0_IMAGIC(_L("CDrawOneByOne::IsDrawingNeededOneByOne - 7")); |
|
584 iContainer->SetMinMagFilterLinear(EFalse); |
|
585 return ETrue; |
|
586 } |
|
587 else if(imageData->iGridData.iRotationAngle != imageData->iGridData.iTargetRotationAngle) |
|
588 { |
|
589 DP0_IMAGIC(_L("CDrawOneByOne::IsDrawingNeededOneByOne - 7.1")); |
|
590 imageData->iGridData.iRotationAngle = imageData->iGridData.iTargetRotationAngle; |
|
591 iContainer->SetMinMagFilterLinear(ETrue); |
|
592 return ETrue; |
|
593 } |
|
594 |
|
595 if(Abs(iDrawOneByOneZoom - iDrawOneByOneTargetZoom) > 0.01) |
|
596 { |
|
597 DP0_IMAGIC(_L("CDrawOneByOne::IsDrawingNeededOneByOne - 9")); |
|
598 iContainer->SetMinMagFilterLinear(EFalse); |
|
599 return ETrue; |
|
600 } |
|
601 else if(iDrawOneByOneZoom != iDrawOneByOneTargetZoom) |
|
602 { |
|
603 DP0_IMAGIC(_L("CDrawOneByOne::IsDrawingNeededOneByOne - 9.1")); |
|
604 iDrawOneByOneZoom = iDrawOneByOneTargetZoom; |
|
605 //iContainer->iDrawOneMoreTime = ETrue; |
|
606 iContainer->SetMinMagFilterLinear(ETrue); |
|
607 return ETrue; |
|
608 } |
|
609 |
|
610 if(Abs(iDrawOneByOneXY.iX-iDrawOneByOneTargetXY.iX) > 0.001) |
|
611 { |
|
612 DP0_IMAGIC(_L("CDrawOneByOne::IsDrawingNeededOneByOne - 11")); |
|
613 iContainer->SetMinMagFilterLinear(EFalse); |
|
614 return ETrue; |
|
615 } |
|
616 else if(iDrawOneByOneXY.iX != iDrawOneByOneTargetXY.iX) |
|
617 { |
|
618 DP0_IMAGIC(_L("CDrawOneByOne::IsDrawingNeededOneByOne - 11.1")); |
|
619 iDrawOneByOneXY.iX = iDrawOneByOneTargetXY.iX; |
|
620 //iContainer->iDrawOneMoreTime = ETrue; |
|
621 iContainer->SetMinMagFilterLinear(ETrue); |
|
622 return ETrue; |
|
623 } |
|
624 |
|
625 if(Abs(iDrawOneByOneXY.iY-iDrawOneByOneTargetXY.iY) > 0.001) |
|
626 { |
|
627 DP0_IMAGIC(_L("CDrawOneByOne::IsDrawingNeededOneByOne - 12")); |
|
628 iContainer->SetMinMagFilterLinear(EFalse); |
|
629 return ETrue; |
|
630 } |
|
631 else if(iDrawOneByOneXY.iY != iDrawOneByOneTargetXY.iY) |
|
632 { |
|
633 DP0_IMAGIC(_L("CDrawOneByOne::IsDrawingNeededOneByOne - 12.1")); |
|
634 iDrawOneByOneXY.iY = iDrawOneByOneTargetXY.iY; |
|
635 //iContainer->iDrawOneMoreTime = ETrue; |
|
636 iContainer->SetMinMagFilterLinear(ETrue); |
|
637 return ETrue; |
|
638 } |
|
639 |
|
640 /*if(iPreviousTexNum != iCurrentTexNum && !iDrawOneMoreTime) |
|
641 { |
|
642 DP0_IMAGIC(_L("CDrawOneByOne::IsDrawingNeededOneByOne - 13.0")); |
|
643 //iDrawOneMoreTime = ETrue; |
|
644 SetMinMagFilterLinear(ETrue); |
|
645 return ETrue; |
|
646 }*/ |
|
647 |
|
648 /*if(imageData->GetAspectRatio() > iScreenAspectRatio && (iDrawOneByOneZoom-1) < 0.01) |
|
649 if(Abs(iDrawOnebyOneW-iImageWidth*2) > 0.01) |
|
650 { |
|
651 DP0_IMAGIC(_L("CDrawOneByOne::IsDrawingNeededOneByOne - 13.1")); |
|
652 DP2_IMAGIC(_L("CDrawOneByOne::IsDrawingNeededOneByOne - iDrawOnebyOneW: %f, iImageWidth: %f"),iDrawOnebyOneW, iImageWidth); |
|
653 SetMinMagFilterLinear(EFalse); |
|
654 //iDrawOneMoreTime = ETrue; |
|
655 return ETrue; |
|
656 } |
|
657 else if(iDrawOnebyOneW != iImageWidth*2) |
|
658 { |
|
659 DP0_IMAGIC(_L("CDrawOneByOne::IsDrawingNeededOneByOne - 13.2")); |
|
660 DP2_IMAGIC(_L("CDrawOneByOne::IsDrawingNeededOneByOne - iDrawOnebyOneW: %f, iImageWidth: %f"),iDrawOnebyOneW, iImageWidth); |
|
661 iDrawOnebyOneW = iImageWidth*2; |
|
662 iDrawOneMoreTime = ETrue; |
|
663 SetMinMagFilterLinear(ETrue); |
|
664 return ETrue; |
|
665 }*/ |
|
666 |
|
667 /* |
|
668 if(imageData->GetAspectRatio() < iContainer->iScreenAspectRatio && (iDrawOneByOneZoom-1) < 0.01) |
|
669 if(Abs(iDrawOnebyOneH-iImageHeight) > 0.01) |
|
670 { |
|
671 DP0_IMAGIC(_L("CDrawOneByOne::IsDrawingNeededOneByOne - 13.3")); |
|
672 DP2_IMAGIC(_L("CDrawOneByOne::IsDrawingNeededOneByOne - iDrawOnebyOneH: %f, iImageHeight: %f"),iDrawOnebyOneH, iImageHeight); |
|
673 iContainer->SetMinMagFilterLinear(EFalse); |
|
674 //iDrawOneMoreTime = ETrue; |
|
675 return ETrue; |
|
676 } |
|
677 else if(Abs(iDrawOnebyOneH - iImageHeight) > IS_ALMOST_ZERO) |
|
678 { |
|
679 DP0_IMAGIC(_L("CDrawOneByOne::IsDrawingNeededOneByOne - 13.4")); |
|
680 DP2_IMAGIC(_L("CDrawOneByOne::IsDrawingNeededOneByOne - iDrawOnebyOneH: %f, iImageHeight: %f"),iDrawOnebyOneH, iImageHeight); |
|
681 iDrawOnebyOneH = iImageHeight; |
|
682 //iContainer->iDrawOneMoreTime = ETrue; |
|
683 iContainer->SetMinMagFilterLinear(ETrue); |
|
684 return ETrue; |
|
685 } |
|
686 */ |
|
687 |
|
688 /*if(iContainer->iDrawOneMoreTime) |
|
689 { |
|
690 DP0_IMAGIC(_L("CDrawOneByOne::IsDrawingNeededOneByOne - 14")); |
|
691 iContainer->iDrawOneMoreTime = EFalse; |
|
692 iContainer->SetMinMagFilterLinear(ETrue);//Draw one more time to change for Linear rendering mode |
|
693 return ETrue; |
|
694 }*/ |
|
695 |
|
696 if(!iContainer->iMagFilterLinear) |
|
697 { |
|
698 DP0_IMAGIC(_L("CDrawOneByOne::IsDrawingNeededOneByOne - 15")); |
|
699 iContainer->SetMinMagFilterLinear(ETrue); |
|
700 //iContainer->iDrawOneMoreTime = ETrue; |
|
701 } |
|
702 |
|
703 if(Abs(iOneByOneFlow) < 0.7) |
|
704 if(iFadeColor > 0.1) |
|
705 { |
|
706 DP0_IMAGIC(_L("CDrawOneByOne::IsDrawingNeededOneByOne - 16")); |
|
707 iContainer->SetMinMagFilterLinear(EFalse); |
|
708 return ETrue; |
|
709 } |
|
710 else if(iFadeColor!=0) |
|
711 { |
|
712 DP0_IMAGIC(_L("CDrawOneByOne::IsDrawingNeededOneByOne - 17")); |
|
713 iFadeColor = 0; |
|
714 iContainer->SetMinMagFilterLinear(ETrue); |
|
715 return ETrue; |
|
716 } |
|
717 |
|
718 if(iContainer->iDrawNow) |
|
719 { |
|
720 DP0_IMAGIC(_L("CDrawOneByOne::IsDrawingNeededOneByOne - 1")); |
|
721 if(iMagGlassOn) |
|
722 { |
|
723 if(!iContainer->IsTouchPointThresholdExeed())//moved >2 pixel |
|
724 iContainer->SetMinMagFilterLinear(ETrue); |
|
725 else |
|
726 iContainer->SetMinMagFilterLinear(EFalse); |
|
727 } |
|
728 else |
|
729 { |
|
730 iContainer->SetMinMagFilterLinear(ETrue); |
|
731 } |
|
732 |
|
733 iContainer->iDrawNow = EFalse; |
|
734 return ETrue; |
|
735 } |
|
736 |
|
737 return EFalse; |
|
738 } |
|
739 |
|
740 //Here we check that we do not go over the picture boundaries |
|
741 void CDrawOneByOne::CheckImageLocation(/*float& aImageWidth, float& aImageHeight*/) |
|
742 { |
|
743 |
|
744 CImageData* imageData = iContainer->iIEngine->GetImageData(iContainer->GetCurrentIndex()); |
|
745 |
|
746 // Change landscape<->portrait if pic is rotated 90 or 270 |
|
747 TInt angle = imageData->iGridData.iTargetRotationAngle; |
|
748 if(angle % 90 == 0 && angle % 180 != 0) |
|
749 { |
|
750 if(imageData->GetAspectRatio() > 1) |
|
751 { |
|
752 /*iImageWidth /= imageData->GetAspectRatio(); |
|
753 iImageWidth -= (iImageWidth-iDrawOnebyOneW);*/ |
|
754 iImageHeight *= imageData->GetAspectRatio(); |
|
755 iImageHeight -= (iImageHeight-iDrawOnebyOneH); |
|
756 iImageWidth = iImageHeight / imageData->GetAspectRatio(); |
|
757 |
|
758 } |
|
759 else |
|
760 { |
|
761 /*iImageWidth/= imageData->GetAspectRatio(); |
|
762 iImageWidth-= (iImageWidth-iDrawOnebyOneW);*/ |
|
763 iImageHeight *= imageData->GetAspectRatio(); |
|
764 iImageHeight -= (iImageHeight-iDrawOnebyOneH); |
|
765 iImageWidth = iImageHeight / imageData->GetAspectRatio(); |
|
766 } |
|
767 } |
|
768 |
|
769 |
|
770 iImageWidth *= iDrawOneByOneTargetZoom; |
|
771 iImageHeight *= iDrawOneByOneTargetZoom; |
|
772 |
|
773 //Calculate location/coordinates in screen |
|
774 iInPictureX = iDrawOneByOneTargetXY.iX * iDrawOneByOneTargetZoom; |
|
775 iInPictureY = iDrawOneByOneTargetXY.iY * iDrawOneByOneTargetZoom; |
|
776 |
|
777 //Lets move in picture little bit over the border |
|
778 if(iDrawOneByOneTargetZoom==1) |
|
779 { |
|
780 iBorder=0; |
|
781 iDrawOneByOneTargetXY.iX = 0; |
|
782 iDrawOneByOneTargetXY.iY = 0; |
|
783 } |
|
784 else |
|
785 { |
|
786 iBorder=0.015; // was 0.1. Changed to 0 to limit just at the edge of image in zoom |
|
787 } |
|
788 |
|
789 //Calculate screen size |
|
790 iScreenW = iDrawOnebyOneW - iBorder; |
|
791 iScreenH = iDrawOnebyOneH - iBorder; |
|
792 |
|
793 |
|
794 if (iImageWidth > iScreenW) |
|
795 { |
|
796 if (iInPictureX-iScreenW < -iImageWidth) |
|
797 iInPictureX=-iImageWidth+iScreenW; |
|
798 if (iInPictureX+iScreenW > iImageWidth) |
|
799 iInPictureX=iImageWidth-iScreenW; |
|
800 } |
|
801 else |
|
802 { |
|
803 iInPictureX=0; |
|
804 } |
|
805 if (iImageHeight > iScreenH) |
|
806 { |
|
807 if (iInPictureY-iScreenH < -iImageHeight) |
|
808 iInPictureY=-iImageHeight+iScreenH; |
|
809 if (iInPictureY+iScreenH > iImageHeight) |
|
810 iInPictureY=iImageHeight-iScreenH; |
|
811 } |
|
812 else |
|
813 { |
|
814 iInPictureY=0; |
|
815 } |
|
816 |
|
817 if(IS_NOT_IN_ZOOM_ONEBYONE) |
|
818 { |
|
819 iInPictureY=0; |
|
820 iInPictureX=0; |
|
821 } |
|
822 } |
|
823 |
|
824 void CDrawOneByOne::HandleMovingKeysOnebyOne() |
|
825 { |
|
826 // Handle keys-----------------------> |
|
827 CKeyData keyData = iContainer->GetKeyData(); |
|
828 CKeyData touchData = iContainer->GetTouchData(); |
|
829 iFlowThresHold=0.8; |
|
830 |
|
831 //Handle keydata and touchdata |
|
832 ChangeDrawOneByOneTargetX(keyData.iRight * GetMovingStep()); |
|
833 ChangeDrawOneByOneTargetX(-keyData.iLeft * GetMovingStep()); |
|
834 ChangeDrawOneByOneTargetY(keyData.iDown * GetMovingStep()); |
|
835 ChangeDrawOneByOneTargetY(-keyData.iUp * GetMovingStep()); |
|
836 |
|
837 ChangeDrawOneByOneTargetX(touchData.iRight * GetMovingStep()); |
|
838 ChangeDrawOneByOneTargetX(-touchData.iLeft * GetMovingStep()); |
|
839 ChangeDrawOneByOneTargetY(touchData.iDown * GetMovingStep()); |
|
840 ChangeDrawOneByOneTargetY(-touchData.iUp * GetMovingStep()); |
|
841 |
|
842 if(touchData.iRight || touchData.iLeft || touchData.iDown || touchData.iUp) |
|
843 //iMovingSpeed = 2.2; |
|
844 iMovingSpeed = 100; |
|
845 else |
|
846 iMovingSpeed = 0.15; |
|
847 //iMovingSpeed = 0.01; |
|
848 |
|
849 //Calculate new index from movement keys to change picture in onebyone mode |
|
850 //but only if zooming is not done |
|
851 //And we have started sliding/moving |
|
852 #ifdef HOLD_SELECTION_ONDRAG |
|
853 if(GetDrawOneByOneTargetZoom()==1 && |
|
854 //((Abs(GetImgeFlowLocation())<0.99) || |
|
855 ((Abs(GetImgeFlowLocation())<iFlowThresHold) || |
|
856 iContainer->GetSlideByDragValue()) && |
|
857 !IsMagGlassOn()) |
|
858 |
|
859 #else |
|
860 if(iDrawOneByOneTargetZoom==1 && Abs(iOneByOneFlow)<0.2 && !iMagGlassOn) |
|
861 #endif |
|
862 { |
|
863 iContainer->SetCurrentIndex(iContainer->GetCurrentIndex() + keyData.iY); |
|
864 iContainer->SetCurrentIndex(iContainer->GetCurrentIndex() + keyData.iX); |
|
865 |
|
866 iContainer->SetCurrentIndex(iContainer->GetCurrentIndex() + touchData.iY); |
|
867 iContainer->SetCurrentIndex(iContainer->GetCurrentIndex() + touchData.iX); |
|
868 } |
|
869 |
|
870 // Check that index is in grid area |
|
871 while(iContainer->GetCurrentIndex() >= iContainer->iIEngine->GetTotalNumOfImages()) |
|
872 iContainer->SetCurrentIndex(iContainer->GetCurrentIndex() - iContainer->iIEngine->GetTotalNumOfImages()); |
|
873 while(iContainer->GetCurrentIndex() < 0) |
|
874 iContainer->SetCurrentIndex(iContainer->GetCurrentIndex() + iContainer->iIEngine->GetTotalNumOfImages()); |
|
875 |
|
876 // Update selected picture index |
|
877 if(iContainer->GetPrevIndex() != iContainer->GetCurrentIndex()) |
|
878 { |
|
879 //iContainer->iTextureLoader->ReleaseHQ512Textures(); |
|
880 |
|
881 //iMagGlassOn = EFalse; |
|
882 SetMagGlassStatus(EFalse); |
|
883 |
|
884 iContainer->iImagicAppUi->SetImageIndex(iContainer->GetCurrentIndex()); |
|
885 |
|
886 // Set new flow coordinate |
|
887 if (keyData.iLeft || touchData.iLeft) |
|
888 { |
|
889 float tmp = GetImgeFlowLocation(); |
|
890 tmp-=CImagicContainerBrowser::KOneByOneSpacing; |
|
891 SetImgeFlowLocation(tmp); |
|
892 //iOneByOneFlow-=KOneByOneSpacing; |
|
893 } |
|
894 if (keyData.iRight || touchData.iRight) |
|
895 { |
|
896 float tmp = GetImgeFlowLocation(); |
|
897 tmp+=CImagicContainerBrowser::KOneByOneSpacing; |
|
898 SetImgeFlowLocation(tmp); |
|
899 //iOneByOneFlow+=KOneByOneSpacing; |
|
900 } |
|
901 |
|
902 //Cancel SuperZoom image loading, if it was started |
|
903 iContainer->iIEngine->CancelFullSizeLoading(); |
|
904 } |
|
905 iContainer->SetPrevIndex(iContainer->GetCurrentIndex()); |
|
906 |
|
907 iContainer->ResetKeyData(); |
|
908 iContainer->ResetTouchData(); |
|
909 } |