os/mm/mmlibs/mmfw/tsrc/mmvalidationsuite/mmvalidationsuiteapp/src/MVSVideoSettingDialog.cpp
Update contrib.
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".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
14 // Part of the MVS Application for TechView
18 #include <techview/eikfpne.h>
20 #include "MVSVideoSettingDialog.h"
23 void CMVSVideoSettingDialog::SetupDialogLD(TVideoRotation aRotation,
25 const TRect& aVideoSize,
26 const TRect& aWindowRect,
27 TBool aSupportVideoPlayerUtility2,
31 CMVSVideoSettingDialog* dialog = new (ELeave) CMVSVideoSettingDialog(aRotation,
35 aSupportVideoPlayerUtility2,
38 dialog->ExecuteLD(R_MVS_VIDEO_DIALOG_VIDEOSETTING);
42 void CMVSVideoSettingDialog::PreLayoutDynInitL()
44 // Get a downcasted pointer to the controls
45 CEikChoiceList* rotation = static_cast<CEikChoiceList*>(Control(EMVSVideoRotationSettings));
48 rotation->SetCurrentItem(iRotation);
51 // default the scaling factor to the current scaling factor as used by the video playback
53 iAppUi->GetScaleFactorL(iScaleWidth, iScaleHeight, iAntiAliasFiltering);
55 CEikCheckBox* antiAliasFiltering = static_cast<CEikCheckBox*>(Control(EMVSAntiAliasFiltering));
56 if(antiAliasFiltering)
58 iAntiAliasFilteringCtl = antiAliasFiltering;
59 antiAliasFiltering->SetObserver(this);
60 antiAliasFiltering->SetState(
61 iAntiAliasFiltering ? CEikButtonBase::ESet : CEikButtonBase::EClear);
64 CEikFloatingPointEditor* editor = static_cast<CEikFloatingPointEditor*> (Control(EMVSCmdScaleWidth));
65 TReal temp(iScaleWidth);
66 editor->SetValueL(&temp);
69 editor = static_cast<CEikFloatingPointEditor*> (Control(EMVSCmdScaleHeight));
70 editor->SetValueL(&temp);
72 // default the crop region to the current crop region values as used by the video playback
74 iAppUi->GetCropRegionL(iCropRegion);
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);
85 if (!iSupportVideoPlayerUtility2)
87 // hide the video extent & window clipping rect UI elements if CVideoPlayerUtility2
89 for (TInt i = EMVSCmdSetVideoExtentTopLeftx; i <= EMVSCmdSetOverlayText; i++)
91 SetLineDimmedNow(i, ETrue);
92 SetLineNonFocusing(i);
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);
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);
117 if (iAppUi->OverlayText().Length() > 0)
119 static_cast<CEikCheckBox*>
120 (Control(EMVSCmdSetDisplayOverlayText))->SetState(CEikButtonBase::ESet);
121 static_cast<CEikEdwin*>
122 (Control(EMVSCmdSetOverlayText))->SetTextL(&iAppUi->OverlayText());
126 static_cast<CEikCheckBox*>
127 (Control(EMVSCmdSetDisplayOverlayText))->SetState(CEikButtonBase::EClear);
128 static_cast<CEikEdwin*>
129 (Control(EMVSCmdSetOverlayText))->SetTextL(NULL);
130 SetLineDimmedNow(EMVSCmdSetOverlayText, ETrue);
134 #ifdef SYMBIAN_BUILD_GCE
135 TAutoScaleType autoScaleType;
136 TInt autoScaleHorizPos;
137 TInt autoScaleVertPos;
138 iAppUi->GetAutoScale(autoScaleType, autoScaleHorizPos, autoScaleVertPos);
140 CEikChoiceList* autoScaleTypeList = static_cast<CEikChoiceList*>(Control(EMVSAutoScaleType));
141 switch (autoScaleType)
144 autoScaleTypeList->SetCurrentItem(0);
146 case EAutoScaleBestFit:
147 autoScaleTypeList->SetCurrentItem(1);
150 autoScaleTypeList->SetCurrentItem(2);
152 case EAutoScaleStretch:
153 autoScaleTypeList->SetCurrentItem(3);
157 CEikChoiceList* autoScaleHoriz = static_cast<CEikChoiceList*>(Control(EMVSAutoScaleHoriz));
158 switch (autoScaleHorizPos)
160 case EHorizontalAlignLeft:
161 autoScaleHoriz->SetCurrentItem(0);
162 static_cast<CEikNumberEditor*>(Control(EMVSAutoScaleHorizPos))->SetNumber(0);
164 case EHorizontalAlignCenter:
165 autoScaleHoriz->SetCurrentItem(1);
166 static_cast<CEikNumberEditor*>(Control(EMVSAutoScaleHorizPos))->SetNumber(0);
168 case EHorizontalAlignRight:
169 autoScaleHoriz->SetCurrentItem(2);
170 static_cast<CEikNumberEditor*>(Control(EMVSAutoScaleHorizPos))->SetNumber(0);
173 autoScaleHoriz->SetCurrentItem(3);
174 static_cast<CEikNumberEditor*>(Control(EMVSAutoScaleHorizPos))->SetNumber(autoScaleHorizPos);
178 CEikChoiceList* autoScaleVert = static_cast<CEikChoiceList*>(Control(EMVSAutoScaleVert));
179 switch (autoScaleVertPos)
181 case EVerticalAlignTop:
182 autoScaleVert->SetCurrentItem(0);
183 static_cast<CEikNumberEditor*>(Control(EMVSAutoScaleVertPos))->SetNumber(0);
185 case EVerticalAlignCenter:
186 autoScaleVert->SetCurrentItem(1);
187 static_cast<CEikNumberEditor*>(Control(EMVSAutoScaleVertPos))->SetNumber(0);
189 case EVerticalAlignBottom:
190 autoScaleVert->SetCurrentItem(2);
191 static_cast<CEikNumberEditor*>(Control(EMVSAutoScaleVertPos))->SetNumber(0);
194 autoScaleVert->SetCurrentItem(3);
195 static_cast<CEikNumberEditor*>(Control(EMVSAutoScaleVertPos))->SetNumber(autoScaleVertPos);
199 CEikCheckBox* pip = static_cast<CEikCheckBox*>(Control(EMVSPIP));
203 pip->SetObserver(this);
204 pip->SetState(iPip ? CEikButtonBase::ESet : CEikButtonBase::EClear);
207 CEikCheckBox* crp = static_cast<CEikCheckBox*>(Control(EMVSCRP));
211 crp->SetObserver(this);
212 crp->SetState(iCrp ? CEikButtonBase::ESet : CEikButtonBase::EClear);
215 #endif // SYMBIAN_BUILD_GCE
219 CMVSVideoSettingDialog::CMVSVideoSettingDialog(TVideoRotation aRotation,
221 const TRect& aVideoSize,
222 const TRect& aWindowRect,
223 TBool aSupportVideoPlayerUtility2,
226 : iRotation(aRotation),
228 iVideoExtent(aVideoSize),
229 iWindowClip(aWindowRect),
230 iSupportVideoPlayerUtility2(aSupportVideoPlayerUtility2),
234 //Nothing to do here - all done in initialisation list
238 TBool CMVSVideoSettingDialog::OkToExitL(TInt aButtonId)
242 case EMVSButtonUpdate:
248 case EMVSButtonCancel:
256 void CMVSVideoSettingDialog::HandleUpdateL()
258 // retrieve crop region value
259 iAx = static_cast<CEikNumberEditor*>
260 (Control(EMVSCmdSetTopLeftx))->Number();
262 iAy = static_cast<CEikNumberEditor*>
263 (Control(EMVSCmdSetTopLefty))->Number();
265 iBx = static_cast<CEikNumberEditor*>
266 (Control(EMVSCmdSetBottomRightx))->Number();
268 iBy = static_cast<CEikNumberEditor*>
269 (Control(EMVSCmdSetBottomRighty))->Number();
270 TRect newCrop(iAx, iAy, iBx, iBy);
271 if (newCrop != iCropRegion)
273 iAppUi->SetCropRegionL(newCrop);
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);
283 if (iScaleWidth != scaleWidth || iScaleHeight != scaleHeight || antiAlias != iAntiAliasFiltering)
285 iAppUi->SetScaleFactorL(scaleWidth, scaleHeight, antiAlias);
288 // retrieve rotation value
289 TVideoRotation newRotation(EVideoRotationNone);
290 CEikChoiceList* rotation = static_cast<CEikChoiceList*>(Control(EMVSVideoRotationSettings));
293 switch (rotation->CurrentItem())
296 newRotation = EVideoRotationNone;
300 newRotation = EVideoRotationClockwise90;
304 newRotation = EVideoRotationClockwise180;
308 newRotation = EVideoRotationClockwise270;
312 newRotation = EVideoRotationNone;
316 if (iRotation != newRotation)
318 iAppUi->SetRotationL(newRotation);
319 iRotation = newRotation;
322 #ifdef SYMBIAN_BUILD_GCE
323 // retrieves window clipping rect
324 TRect newWinClipRect;
325 RetrieveWindowClipRectFieldValues(newWinClipRect);
327 if (newWinClipRect != iWindowClip)
329 iAppUi->SetWindowClippingRect(newWinClipRect);
333 // retrieves video extent properties
334 TRect newVideoExtent;
335 RetrieveVideoExtentFieldValues(newVideoExtent);
337 if (newVideoExtent != iVideoExtent)
339 iAppUi->SetVideoExtent(newVideoExtent);
342 // retrieve overlay text
343 HBufC* overlayText = NULL;
344 if (static_cast<CEikCheckBox*>(Control(EMVSCmdSetDisplayOverlayText))->State()
345 == CEikButtonBase::ESet)
348 = static_cast<CEikEdwin*>(Control(EMVSCmdSetOverlayText))->GetTextInHBufL();
353 iAppUi->SetOverlayTextL(*overlayText);
358 iAppUi->SetOverlayTextL(KNullDesC);
361 // retrieve autoscale values
362 TAutoScaleType newAutoScaleType = EAutoScaleNone;
363 TInt newAutoScaleHorizPos = 0;
364 TInt newAutoScaleVertPos = 0;
366 CEikChoiceList* autoScaleType = static_cast<CEikChoiceList*>(Control(EMVSAutoScaleType));
370 switch (autoScaleType->CurrentItem())
373 newAutoScaleType = EAutoScaleNone;
376 newAutoScaleType = EAutoScaleBestFit;
379 newAutoScaleType = EAutoScaleClip;
382 newAutoScaleType = EAutoScaleStretch;
385 newAutoScaleType = EAutoScaleNone;
390 CEikChoiceList* autoScaleHoriz = static_cast<CEikChoiceList*>(Control(EMVSAutoScaleHoriz));
391 switch (autoScaleHoriz->CurrentItem())
394 newAutoScaleHorizPos = EHorizontalAlignLeft;
397 newAutoScaleHorizPos = EHorizontalAlignCenter;
400 newAutoScaleHorizPos = EHorizontalAlignRight;
403 newAutoScaleHorizPos = static_cast<CEikNumberEditor*>(Control(EMVSAutoScaleHorizPos))->Number();
407 CEikChoiceList* autoScaleVert = static_cast<CEikChoiceList*>(Control(EMVSAutoScaleVert));
408 switch (autoScaleVert->CurrentItem())
411 newAutoScaleVertPos = EVerticalAlignTop;
414 newAutoScaleVertPos = EVerticalAlignCenter;
417 newAutoScaleVertPos = EVerticalAlignBottom;
420 newAutoScaleVertPos = static_cast<CEikNumberEditor*>(Control(EMVSAutoScaleVertPos))->Number();
424 iAppUi->SetAutoScaleL(newAutoScaleType, newAutoScaleHorizPos, newAutoScaleVertPos);
426 CEikButtonBase::TState state = static_cast<CEikCheckBox*>(Control(EMVSPIP))->State();
427 iAppUi->SetPip(CEikButtonBase::ESet == state);
429 state = static_cast<CEikCheckBox*>(Control(EMVSCRP))->State();
430 iAppUi->SetCrp(CEikButtonBase::ESet == state);
431 #endif // SYMBIAN_BUILD_GCE
435 void CMVSVideoSettingDialog::RetrieveVideoExtentFieldValues(TRect& aVideoExtentValues) const
437 aVideoExtentValues.iTl.iX
438 = static_cast<CEikNumberEditor*>(Control(EMVSCmdSetVideoExtentTopLeftx))->Number();
440 aVideoExtentValues.iTl.iY
441 = static_cast<CEikNumberEditor*>(Control(EMVSCmdSetVideoExtentTopLefty))->Number();
443 aVideoExtentValues.iBr.iX
444 = static_cast<CEikNumberEditor*>(Control(EMVSCmdSetVideoExtentBottomRightx))->Number();
446 aVideoExtentValues.iBr.iY
447 = static_cast<CEikNumberEditor*>(Control(EMVSCmdSetVideoExtentBottomRighty))->Number();
450 void CMVSVideoSettingDialog::RetrieveWindowClipRectFieldValues(TRect& aNewVideoExtent) const
452 aNewVideoExtent.iTl.iX
453 = static_cast<CEikNumberEditor*>(Control(EMVSCmdSetWindowClipTopLeftx))->Number();
455 aNewVideoExtent.iTl.iY
456 = static_cast<CEikNumberEditor*>(Control(EMVSCmdSetWindowClipTopLefty))->Number();
458 aNewVideoExtent.iBr.iX
459 = static_cast<CEikNumberEditor*>(Control(EMVSCmdSetWindowClipBottomRightx))->Number();
461 aNewVideoExtent.iBr.iY
462 = static_cast<CEikNumberEditor*>(Control(EMVSCmdSetWindowClipBottomRighty))->Number();
465 void CMVSVideoSettingDialog::HandleControlEventL(CCoeControl *aControl, TCoeEvent aEventType)
467 CEikDialog::HandleControlEventL(aControl,aEventType);
468 if (aControl == Control(EMVSCmdSetDisplayOverlayText) && aEventType == EEventStateChanged)
470 CEikCheckBox* overlayCheckBox
471 = static_cast<CEikCheckBox*>(Control(EMVSCmdSetDisplayOverlayText));
473 TBool disableOverlayText = (overlayCheckBox->State() != CEikButtonBase::ESet);
474 SetLineDimmedNow(EMVSCmdSetOverlayText, disableOverlayText);