|
1 // Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // Part of the MVS Application for TechView |
|
15 // |
|
16 |
|
17 #include <e32math.h> |
|
18 #include <techview/eikfpne.h> |
|
19 |
|
20 #include "MVSVideoSettingDialog.h" |
|
21 #include "MVSApp.hrh" |
|
22 |
|
23 void CMVSVideoSettingDialog::SetupDialogLD(TVideoRotation aRotation, |
|
24 CMVSAppUi* aAppUi, |
|
25 const TRect& aVideoSize, |
|
26 const TRect& aWindowRect, |
|
27 TBool aSupportVideoPlayerUtility2, |
|
28 TBool aPip, |
|
29 TBool aCrp) |
|
30 { |
|
31 CMVSVideoSettingDialog* dialog = new (ELeave) CMVSVideoSettingDialog(aRotation, |
|
32 aAppUi, |
|
33 aVideoSize, |
|
34 aWindowRect, |
|
35 aSupportVideoPlayerUtility2, |
|
36 aPip, |
|
37 aCrp); |
|
38 dialog->ExecuteLD(R_MVS_VIDEO_DIALOG_VIDEOSETTING); |
|
39 } |
|
40 |
|
41 |
|
42 void CMVSVideoSettingDialog::PreLayoutDynInitL() |
|
43 { |
|
44 // Get a downcasted pointer to the controls |
|
45 CEikChoiceList* rotation = static_cast<CEikChoiceList*>(Control(EMVSVideoRotationSettings)); |
|
46 if(rotation) |
|
47 { |
|
48 rotation->SetCurrentItem(iRotation); |
|
49 } |
|
50 |
|
51 // default the scaling factor to the current scaling factor as used by the video playback |
|
52 // utility |
|
53 iAppUi->GetScaleFactorL(iScaleWidth, iScaleHeight, iAntiAliasFiltering); |
|
54 |
|
55 CEikCheckBox* antiAliasFiltering = static_cast<CEikCheckBox*>(Control(EMVSAntiAliasFiltering)); |
|
56 if(antiAliasFiltering) |
|
57 { |
|
58 iAntiAliasFilteringCtl = antiAliasFiltering; |
|
59 antiAliasFiltering->SetObserver(this); |
|
60 antiAliasFiltering->SetState( |
|
61 iAntiAliasFiltering ? CEikButtonBase::ESet : CEikButtonBase::EClear); |
|
62 } |
|
63 |
|
64 CEikFloatingPointEditor* editor = static_cast<CEikFloatingPointEditor*> (Control(EMVSCmdScaleWidth)); |
|
65 TReal temp(iScaleWidth); |
|
66 editor->SetValueL(&temp); |
|
67 |
|
68 temp = iScaleHeight; |
|
69 editor = static_cast<CEikFloatingPointEditor*> (Control(EMVSCmdScaleHeight)); |
|
70 editor->SetValueL(&temp); |
|
71 |
|
72 // default the crop region to the current crop region values as used by the video playback |
|
73 // utility |
|
74 iAppUi->GetCropRegionL(iCropRegion); |
|
75 |
|
76 static_cast<CEikNumberEditor*> |
|
77 (Control(EMVSCmdSetTopLeftx))->SetNumber(iCropRegion.iTl.iX); |
|
78 static_cast<CEikNumberEditor*> |
|
79 (Control(EMVSCmdSetTopLefty))->SetNumber(iCropRegion.iTl.iY); |
|
80 static_cast<CEikNumberEditor*> |
|
81 (Control(EMVSCmdSetBottomRightx))->SetNumber(iCropRegion.iBr.iX); |
|
82 static_cast<CEikNumberEditor*> |
|
83 (Control(EMVSCmdSetBottomRighty))->SetNumber(iCropRegion.iBr.iY); |
|
84 |
|
85 if (!iSupportVideoPlayerUtility2) |
|
86 { |
|
87 // hide the video extent & window clipping rect UI elements if CVideoPlayerUtility2 |
|
88 // is not in effect |
|
89 for (TInt i = EMVSCmdSetVideoExtentTopLeftx; i <= EMVSCmdSetOverlayText; i++) |
|
90 { |
|
91 SetLineDimmedNow(i, ETrue); |
|
92 SetLineNonFocusing(i); |
|
93 } |
|
94 } |
|
95 else |
|
96 { |
|
97 // default the video extent to values currently set in the application |
|
98 static_cast<CEikNumberEditor*> |
|
99 (Control(EMVSCmdSetVideoExtentTopLeftx))->SetNumber(iVideoExtent.iTl.iX); |
|
100 static_cast<CEikNumberEditor*> |
|
101 (Control(EMVSCmdSetVideoExtentTopLefty))->SetNumber(iVideoExtent.iTl.iY); |
|
102 static_cast<CEikNumberEditor*> |
|
103 (Control(EMVSCmdSetVideoExtentBottomRightx))->SetNumber(iVideoExtent.iBr.iX); |
|
104 static_cast<CEikNumberEditor*> |
|
105 (Control(EMVSCmdSetVideoExtentBottomRighty))->SetNumber(iVideoExtent.iBr.iY); |
|
106 |
|
107 // default the window clipping rect to values currently set in the application |
|
108 static_cast<CEikNumberEditor*> |
|
109 (Control(EMVSCmdSetWindowClipTopLeftx))->SetNumber(iWindowClip.iTl.iX); |
|
110 static_cast<CEikNumberEditor*> |
|
111 (Control(EMVSCmdSetWindowClipTopLefty))->SetNumber(iWindowClip.iTl.iY); |
|
112 static_cast<CEikNumberEditor*> |
|
113 (Control(EMVSCmdSetWindowClipBottomRightx))->SetNumber(iWindowClip.iBr.iX); |
|
114 static_cast<CEikNumberEditor*> |
|
115 (Control(EMVSCmdSetWindowClipBottomRighty))->SetNumber(iWindowClip.iBr.iY); |
|
116 |
|
117 if (iAppUi->OverlayText().Length() > 0) |
|
118 { |
|
119 static_cast<CEikCheckBox*> |
|
120 (Control(EMVSCmdSetDisplayOverlayText))->SetState(CEikButtonBase::ESet); |
|
121 static_cast<CEikEdwin*> |
|
122 (Control(EMVSCmdSetOverlayText))->SetTextL(&iAppUi->OverlayText()); |
|
123 } |
|
124 else |
|
125 { |
|
126 static_cast<CEikCheckBox*> |
|
127 (Control(EMVSCmdSetDisplayOverlayText))->SetState(CEikButtonBase::EClear); |
|
128 static_cast<CEikEdwin*> |
|
129 (Control(EMVSCmdSetOverlayText))->SetTextL(NULL); |
|
130 SetLineDimmedNow(EMVSCmdSetOverlayText, ETrue); |
|
131 } |
|
132 } |
|
133 |
|
134 #ifdef SYMBIAN_BUILD_GCE |
|
135 TAutoScaleType autoScaleType; |
|
136 TInt autoScaleHorizPos; |
|
137 TInt autoScaleVertPos; |
|
138 iAppUi->GetAutoScale(autoScaleType, autoScaleHorizPos, autoScaleVertPos); |
|
139 |
|
140 CEikChoiceList* autoScaleTypeList = static_cast<CEikChoiceList*>(Control(EMVSAutoScaleType)); |
|
141 switch (autoScaleType) |
|
142 { |
|
143 case EAutoScaleNone: |
|
144 autoScaleTypeList->SetCurrentItem(0); |
|
145 break; |
|
146 case EAutoScaleBestFit: |
|
147 autoScaleTypeList->SetCurrentItem(1); |
|
148 break; |
|
149 case EAutoScaleClip: |
|
150 autoScaleTypeList->SetCurrentItem(2); |
|
151 break; |
|
152 case EAutoScaleStretch: |
|
153 autoScaleTypeList->SetCurrentItem(3); |
|
154 break; |
|
155 } |
|
156 |
|
157 CEikChoiceList* autoScaleHoriz = static_cast<CEikChoiceList*>(Control(EMVSAutoScaleHoriz)); |
|
158 switch (autoScaleHorizPos) |
|
159 { |
|
160 case EHorizontalAlignLeft: |
|
161 autoScaleHoriz->SetCurrentItem(0); |
|
162 static_cast<CEikNumberEditor*>(Control(EMVSAutoScaleHorizPos))->SetNumber(0); |
|
163 break; |
|
164 case EHorizontalAlignCenter: |
|
165 autoScaleHoriz->SetCurrentItem(1); |
|
166 static_cast<CEikNumberEditor*>(Control(EMVSAutoScaleHorizPos))->SetNumber(0); |
|
167 break; |
|
168 case EHorizontalAlignRight: |
|
169 autoScaleHoriz->SetCurrentItem(2); |
|
170 static_cast<CEikNumberEditor*>(Control(EMVSAutoScaleHorizPos))->SetNumber(0); |
|
171 break; |
|
172 default: |
|
173 autoScaleHoriz->SetCurrentItem(3); |
|
174 static_cast<CEikNumberEditor*>(Control(EMVSAutoScaleHorizPos))->SetNumber(autoScaleHorizPos); |
|
175 break; |
|
176 } |
|
177 |
|
178 CEikChoiceList* autoScaleVert = static_cast<CEikChoiceList*>(Control(EMVSAutoScaleVert)); |
|
179 switch (autoScaleVertPos) |
|
180 { |
|
181 case EVerticalAlignTop: |
|
182 autoScaleVert->SetCurrentItem(0); |
|
183 static_cast<CEikNumberEditor*>(Control(EMVSAutoScaleVertPos))->SetNumber(0); |
|
184 break; |
|
185 case EVerticalAlignCenter: |
|
186 autoScaleVert->SetCurrentItem(1); |
|
187 static_cast<CEikNumberEditor*>(Control(EMVSAutoScaleVertPos))->SetNumber(0); |
|
188 break; |
|
189 case EVerticalAlignBottom: |
|
190 autoScaleVert->SetCurrentItem(2); |
|
191 static_cast<CEikNumberEditor*>(Control(EMVSAutoScaleVertPos))->SetNumber(0); |
|
192 break; |
|
193 default: |
|
194 autoScaleVert->SetCurrentItem(3); |
|
195 static_cast<CEikNumberEditor*>(Control(EMVSAutoScaleVertPos))->SetNumber(autoScaleVertPos); |
|
196 break; |
|
197 } |
|
198 |
|
199 CEikCheckBox* pip = static_cast<CEikCheckBox*>(Control(EMVSPIP)); |
|
200 |
|
201 if(pip) |
|
202 { |
|
203 pip->SetObserver(this); |
|
204 pip->SetState(iPip ? CEikButtonBase::ESet : CEikButtonBase::EClear); |
|
205 } |
|
206 |
|
207 CEikCheckBox* crp = static_cast<CEikCheckBox*>(Control(EMVSCRP)); |
|
208 |
|
209 if(crp) |
|
210 { |
|
211 crp->SetObserver(this); |
|
212 crp->SetState(iCrp ? CEikButtonBase::ESet : CEikButtonBase::EClear); |
|
213 } |
|
214 |
|
215 #endif // SYMBIAN_BUILD_GCE |
|
216 } |
|
217 |
|
218 |
|
219 CMVSVideoSettingDialog::CMVSVideoSettingDialog(TVideoRotation aRotation, |
|
220 CMVSAppUi* aAppUi, |
|
221 const TRect& aVideoSize, |
|
222 const TRect& aWindowRect, |
|
223 TBool aSupportVideoPlayerUtility2, |
|
224 TBool aPip, |
|
225 TBool aCrp) |
|
226 : iRotation(aRotation), |
|
227 iAppUi(aAppUi), |
|
228 iVideoExtent(aVideoSize), |
|
229 iWindowClip(aWindowRect), |
|
230 iSupportVideoPlayerUtility2(aSupportVideoPlayerUtility2), |
|
231 iPip(aPip), |
|
232 iCrp(aCrp) |
|
233 { |
|
234 //Nothing to do here - all done in initialisation list |
|
235 } |
|
236 |
|
237 |
|
238 TBool CMVSVideoSettingDialog::OkToExitL(TInt aButtonId) |
|
239 { |
|
240 switch(aButtonId) |
|
241 { |
|
242 case EMVSButtonUpdate: |
|
243 { |
|
244 HandleUpdateL(); |
|
245 break; |
|
246 } |
|
247 |
|
248 case EMVSButtonCancel: |
|
249 default: //cancel |
|
250 break; |
|
251 } |
|
252 |
|
253 return ETrue; |
|
254 } |
|
255 |
|
256 void CMVSVideoSettingDialog::HandleUpdateL() |
|
257 { |
|
258 // retrieve crop region value |
|
259 iAx = static_cast<CEikNumberEditor*> |
|
260 (Control(EMVSCmdSetTopLeftx))->Number(); |
|
261 |
|
262 iAy = static_cast<CEikNumberEditor*> |
|
263 (Control(EMVSCmdSetTopLefty))->Number(); |
|
264 |
|
265 iBx = static_cast<CEikNumberEditor*> |
|
266 (Control(EMVSCmdSetBottomRightx))->Number(); |
|
267 |
|
268 iBy = static_cast<CEikNumberEditor*> |
|
269 (Control(EMVSCmdSetBottomRighty))->Number(); |
|
270 TRect newCrop(iAx, iAy, iBx, iBy); |
|
271 if (newCrop != iCropRegion) |
|
272 { |
|
273 iAppUi->SetCropRegionL(newCrop); |
|
274 } |
|
275 |
|
276 // retrieve scale factor |
|
277 TReal32 scaleWidth = TReal32(static_cast<CEikFloatingPointEditor*> |
|
278 (Control(EMVSCmdScaleWidth))->Value()); |
|
279 TReal32 scaleHeight = TReal32(static_cast<CEikFloatingPointEditor*> |
|
280 (Control(EMVSCmdScaleHeight))->Value()); |
|
281 TBool antiAlias = (iAntiAliasFilteringCtl->State() == CEikButtonBase::ESet); |
|
282 |
|
283 if (iScaleWidth != scaleWidth || iScaleHeight != scaleHeight || antiAlias != iAntiAliasFiltering) |
|
284 { |
|
285 iAppUi->SetScaleFactorL(scaleWidth, scaleHeight, antiAlias); |
|
286 } |
|
287 |
|
288 // retrieve rotation value |
|
289 TVideoRotation newRotation(EVideoRotationNone); |
|
290 CEikChoiceList* rotation = static_cast<CEikChoiceList*>(Control(EMVSVideoRotationSettings)); |
|
291 if(rotation) |
|
292 { |
|
293 switch (rotation->CurrentItem()) |
|
294 { |
|
295 case 0: |
|
296 newRotation = EVideoRotationNone; |
|
297 break; |
|
298 |
|
299 case 1: |
|
300 newRotation = EVideoRotationClockwise90; |
|
301 break; |
|
302 |
|
303 case 2: |
|
304 newRotation = EVideoRotationClockwise180; |
|
305 break; |
|
306 |
|
307 case 3: |
|
308 newRotation = EVideoRotationClockwise270; |
|
309 break; |
|
310 |
|
311 default: |
|
312 newRotation = EVideoRotationNone; |
|
313 break; |
|
314 } |
|
315 } |
|
316 if (iRotation != newRotation) |
|
317 { |
|
318 iAppUi->SetRotationL(newRotation); |
|
319 iRotation = newRotation; |
|
320 } |
|
321 |
|
322 #ifdef SYMBIAN_BUILD_GCE |
|
323 // retrieves window clipping rect |
|
324 TRect newWinClipRect; |
|
325 RetrieveWindowClipRectFieldValues(newWinClipRect); |
|
326 |
|
327 if (newWinClipRect != iWindowClip) |
|
328 { |
|
329 iAppUi->SetWindowClippingRect(newWinClipRect); |
|
330 } |
|
331 |
|
332 |
|
333 // retrieves video extent properties |
|
334 TRect newVideoExtent; |
|
335 RetrieveVideoExtentFieldValues(newVideoExtent); |
|
336 |
|
337 if (newVideoExtent != iVideoExtent) |
|
338 { |
|
339 iAppUi->SetVideoExtent(newVideoExtent); |
|
340 } |
|
341 |
|
342 // retrieve overlay text |
|
343 HBufC* overlayText = NULL; |
|
344 if (static_cast<CEikCheckBox*>(Control(EMVSCmdSetDisplayOverlayText))->State() |
|
345 == CEikButtonBase::ESet) |
|
346 { |
|
347 overlayText |
|
348 = static_cast<CEikEdwin*>(Control(EMVSCmdSetOverlayText))->GetTextInHBufL(); |
|
349 } |
|
350 |
|
351 if (overlayText) |
|
352 { |
|
353 iAppUi->SetOverlayTextL(*overlayText); |
|
354 delete overlayText; |
|
355 } |
|
356 else |
|
357 { |
|
358 iAppUi->SetOverlayTextL(KNullDesC); |
|
359 } |
|
360 |
|
361 // retrieve autoscale values |
|
362 TAutoScaleType newAutoScaleType = EAutoScaleNone; |
|
363 TInt newAutoScaleHorizPos = 0; |
|
364 TInt newAutoScaleVertPos = 0; |
|
365 |
|
366 CEikChoiceList* autoScaleType = static_cast<CEikChoiceList*>(Control(EMVSAutoScaleType)); |
|
367 |
|
368 if (autoScaleType) |
|
369 { |
|
370 switch (autoScaleType->CurrentItem()) |
|
371 { |
|
372 case 0: |
|
373 newAutoScaleType = EAutoScaleNone; |
|
374 break; |
|
375 case 1: |
|
376 newAutoScaleType = EAutoScaleBestFit; |
|
377 break; |
|
378 case 2: |
|
379 newAutoScaleType = EAutoScaleClip; |
|
380 break; |
|
381 case 3: |
|
382 newAutoScaleType = EAutoScaleStretch; |
|
383 break; |
|
384 default: |
|
385 newAutoScaleType = EAutoScaleNone; |
|
386 break; |
|
387 } |
|
388 } |
|
389 |
|
390 CEikChoiceList* autoScaleHoriz = static_cast<CEikChoiceList*>(Control(EMVSAutoScaleHoriz)); |
|
391 switch (autoScaleHoriz->CurrentItem()) |
|
392 { |
|
393 case 0: |
|
394 newAutoScaleHorizPos = EHorizontalAlignLeft; |
|
395 break; |
|
396 case 1: |
|
397 newAutoScaleHorizPos = EHorizontalAlignCenter; |
|
398 break; |
|
399 case 2: |
|
400 newAutoScaleHorizPos = EHorizontalAlignRight; |
|
401 break; |
|
402 default: |
|
403 newAutoScaleHorizPos = static_cast<CEikNumberEditor*>(Control(EMVSAutoScaleHorizPos))->Number(); |
|
404 break; |
|
405 } |
|
406 |
|
407 CEikChoiceList* autoScaleVert = static_cast<CEikChoiceList*>(Control(EMVSAutoScaleVert)); |
|
408 switch (autoScaleVert->CurrentItem()) |
|
409 { |
|
410 case 0: |
|
411 newAutoScaleVertPos = EVerticalAlignTop; |
|
412 break; |
|
413 case 1: |
|
414 newAutoScaleVertPos = EVerticalAlignCenter; |
|
415 break; |
|
416 case 2: |
|
417 newAutoScaleVertPos = EVerticalAlignBottom; |
|
418 break; |
|
419 default: |
|
420 newAutoScaleVertPos = static_cast<CEikNumberEditor*>(Control(EMVSAutoScaleVertPos))->Number(); |
|
421 break; |
|
422 } |
|
423 |
|
424 iAppUi->SetAutoScaleL(newAutoScaleType, newAutoScaleHorizPos, newAutoScaleVertPos); |
|
425 |
|
426 CEikButtonBase::TState state = static_cast<CEikCheckBox*>(Control(EMVSPIP))->State(); |
|
427 iAppUi->SetPip(CEikButtonBase::ESet == state); |
|
428 |
|
429 state = static_cast<CEikCheckBox*>(Control(EMVSCRP))->State(); |
|
430 iAppUi->SetCrp(CEikButtonBase::ESet == state); |
|
431 #endif // SYMBIAN_BUILD_GCE |
|
432 } |
|
433 |
|
434 |
|
435 void CMVSVideoSettingDialog::RetrieveVideoExtentFieldValues(TRect& aVideoExtentValues) const |
|
436 { |
|
437 aVideoExtentValues.iTl.iX |
|
438 = static_cast<CEikNumberEditor*>(Control(EMVSCmdSetVideoExtentTopLeftx))->Number(); |
|
439 |
|
440 aVideoExtentValues.iTl.iY |
|
441 = static_cast<CEikNumberEditor*>(Control(EMVSCmdSetVideoExtentTopLefty))->Number(); |
|
442 |
|
443 aVideoExtentValues.iBr.iX |
|
444 = static_cast<CEikNumberEditor*>(Control(EMVSCmdSetVideoExtentBottomRightx))->Number(); |
|
445 |
|
446 aVideoExtentValues.iBr.iY |
|
447 = static_cast<CEikNumberEditor*>(Control(EMVSCmdSetVideoExtentBottomRighty))->Number(); |
|
448 } |
|
449 |
|
450 void CMVSVideoSettingDialog::RetrieveWindowClipRectFieldValues(TRect& aNewVideoExtent) const |
|
451 { |
|
452 aNewVideoExtent.iTl.iX |
|
453 = static_cast<CEikNumberEditor*>(Control(EMVSCmdSetWindowClipTopLeftx))->Number(); |
|
454 |
|
455 aNewVideoExtent.iTl.iY |
|
456 = static_cast<CEikNumberEditor*>(Control(EMVSCmdSetWindowClipTopLefty))->Number(); |
|
457 |
|
458 aNewVideoExtent.iBr.iX |
|
459 = static_cast<CEikNumberEditor*>(Control(EMVSCmdSetWindowClipBottomRightx))->Number(); |
|
460 |
|
461 aNewVideoExtent.iBr.iY |
|
462 = static_cast<CEikNumberEditor*>(Control(EMVSCmdSetWindowClipBottomRighty))->Number(); |
|
463 } |
|
464 |
|
465 void CMVSVideoSettingDialog::HandleControlEventL(CCoeControl *aControl, TCoeEvent aEventType) |
|
466 { |
|
467 CEikDialog::HandleControlEventL(aControl,aEventType); |
|
468 if (aControl == Control(EMVSCmdSetDisplayOverlayText) && aEventType == EEventStateChanged) |
|
469 { |
|
470 CEikCheckBox* overlayCheckBox |
|
471 = static_cast<CEikCheckBox*>(Control(EMVSCmdSetDisplayOverlayText)); |
|
472 |
|
473 TBool disableOverlayText = (overlayCheckBox->State() != CEikButtonBase::ESet); |
|
474 SetLineDimmedNow(EMVSCmdSetOverlayText, disableOverlayText); |
|
475 } |
|
476 } |