os/mm/mmlibs/mmfw/tsrc/mmvalidationsuite/mmvalidationsuiteapp/src/MVSVideoSettingDialog.cpp
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/mm/mmlibs/mmfw/tsrc/mmvalidationsuite/mmvalidationsuiteapp/src/MVSVideoSettingDialog.cpp Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,476 @@
1.4 +// Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
1.5 +// All rights reserved.
1.6 +// This component and the accompanying materials are made available
1.7 +// under the terms of "Eclipse Public License v1.0"
1.8 +// which accompanies this distribution, and is available
1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
1.10 +//
1.11 +// Initial Contributors:
1.12 +// Nokia Corporation - initial contribution.
1.13 +//
1.14 +// Contributors:
1.15 +//
1.16 +// Description:
1.17 +// Part of the MVS Application for TechView
1.18 +//
1.19 +
1.20 +#include <e32math.h>
1.21 +#include <techview/eikfpne.h>
1.22 +
1.23 +#include "MVSVideoSettingDialog.h"
1.24 +#include "MVSApp.hrh"
1.25 +
1.26 +void CMVSVideoSettingDialog::SetupDialogLD(TVideoRotation aRotation,
1.27 + CMVSAppUi* aAppUi,
1.28 + const TRect& aVideoSize,
1.29 + const TRect& aWindowRect,
1.30 + TBool aSupportVideoPlayerUtility2,
1.31 + TBool aPip,
1.32 + TBool aCrp)
1.33 + {
1.34 + CMVSVideoSettingDialog* dialog = new (ELeave) CMVSVideoSettingDialog(aRotation,
1.35 + aAppUi,
1.36 + aVideoSize,
1.37 + aWindowRect,
1.38 + aSupportVideoPlayerUtility2,
1.39 + aPip,
1.40 + aCrp);
1.41 + dialog->ExecuteLD(R_MVS_VIDEO_DIALOG_VIDEOSETTING);
1.42 + }
1.43 +
1.44 +
1.45 +void CMVSVideoSettingDialog::PreLayoutDynInitL()
1.46 + {
1.47 + // Get a downcasted pointer to the controls
1.48 + CEikChoiceList* rotation = static_cast<CEikChoiceList*>(Control(EMVSVideoRotationSettings));
1.49 + if(rotation)
1.50 + {
1.51 + rotation->SetCurrentItem(iRotation);
1.52 + }
1.53 +
1.54 + // default the scaling factor to the current scaling factor as used by the video playback
1.55 + // utility
1.56 + iAppUi->GetScaleFactorL(iScaleWidth, iScaleHeight, iAntiAliasFiltering);
1.57 +
1.58 + CEikCheckBox* antiAliasFiltering = static_cast<CEikCheckBox*>(Control(EMVSAntiAliasFiltering));
1.59 + if(antiAliasFiltering)
1.60 + {
1.61 + iAntiAliasFilteringCtl = antiAliasFiltering;
1.62 + antiAliasFiltering->SetObserver(this);
1.63 + antiAliasFiltering->SetState(
1.64 + iAntiAliasFiltering ? CEikButtonBase::ESet : CEikButtonBase::EClear);
1.65 + }
1.66 +
1.67 + CEikFloatingPointEditor* editor = static_cast<CEikFloatingPointEditor*> (Control(EMVSCmdScaleWidth));
1.68 + TReal temp(iScaleWidth);
1.69 + editor->SetValueL(&temp);
1.70 +
1.71 + temp = iScaleHeight;
1.72 + editor = static_cast<CEikFloatingPointEditor*> (Control(EMVSCmdScaleHeight));
1.73 + editor->SetValueL(&temp);
1.74 +
1.75 + // default the crop region to the current crop region values as used by the video playback
1.76 + // utility
1.77 + iAppUi->GetCropRegionL(iCropRegion);
1.78 +
1.79 + static_cast<CEikNumberEditor*>
1.80 + (Control(EMVSCmdSetTopLeftx))->SetNumber(iCropRegion.iTl.iX);
1.81 + static_cast<CEikNumberEditor*>
1.82 + (Control(EMVSCmdSetTopLefty))->SetNumber(iCropRegion.iTl.iY);
1.83 + static_cast<CEikNumberEditor*>
1.84 + (Control(EMVSCmdSetBottomRightx))->SetNumber(iCropRegion.iBr.iX);
1.85 + static_cast<CEikNumberEditor*>
1.86 + (Control(EMVSCmdSetBottomRighty))->SetNumber(iCropRegion.iBr.iY);
1.87 +
1.88 + if (!iSupportVideoPlayerUtility2)
1.89 + {
1.90 + // hide the video extent & window clipping rect UI elements if CVideoPlayerUtility2
1.91 + // is not in effect
1.92 + for (TInt i = EMVSCmdSetVideoExtentTopLeftx; i <= EMVSCmdSetOverlayText; i++)
1.93 + {
1.94 + SetLineDimmedNow(i, ETrue);
1.95 + SetLineNonFocusing(i);
1.96 + }
1.97 + }
1.98 + else
1.99 + {
1.100 + // default the video extent to values currently set in the application
1.101 + static_cast<CEikNumberEditor*>
1.102 + (Control(EMVSCmdSetVideoExtentTopLeftx))->SetNumber(iVideoExtent.iTl.iX);
1.103 + static_cast<CEikNumberEditor*>
1.104 + (Control(EMVSCmdSetVideoExtentTopLefty))->SetNumber(iVideoExtent.iTl.iY);
1.105 + static_cast<CEikNumberEditor*>
1.106 + (Control(EMVSCmdSetVideoExtentBottomRightx))->SetNumber(iVideoExtent.iBr.iX);
1.107 + static_cast<CEikNumberEditor*>
1.108 + (Control(EMVSCmdSetVideoExtentBottomRighty))->SetNumber(iVideoExtent.iBr.iY);
1.109 +
1.110 + // default the window clipping rect to values currently set in the application
1.111 + static_cast<CEikNumberEditor*>
1.112 + (Control(EMVSCmdSetWindowClipTopLeftx))->SetNumber(iWindowClip.iTl.iX);
1.113 + static_cast<CEikNumberEditor*>
1.114 + (Control(EMVSCmdSetWindowClipTopLefty))->SetNumber(iWindowClip.iTl.iY);
1.115 + static_cast<CEikNumberEditor*>
1.116 + (Control(EMVSCmdSetWindowClipBottomRightx))->SetNumber(iWindowClip.iBr.iX);
1.117 + static_cast<CEikNumberEditor*>
1.118 + (Control(EMVSCmdSetWindowClipBottomRighty))->SetNumber(iWindowClip.iBr.iY);
1.119 +
1.120 + if (iAppUi->OverlayText().Length() > 0)
1.121 + {
1.122 + static_cast<CEikCheckBox*>
1.123 + (Control(EMVSCmdSetDisplayOverlayText))->SetState(CEikButtonBase::ESet);
1.124 + static_cast<CEikEdwin*>
1.125 + (Control(EMVSCmdSetOverlayText))->SetTextL(&iAppUi->OverlayText());
1.126 + }
1.127 + else
1.128 + {
1.129 + static_cast<CEikCheckBox*>
1.130 + (Control(EMVSCmdSetDisplayOverlayText))->SetState(CEikButtonBase::EClear);
1.131 + static_cast<CEikEdwin*>
1.132 + (Control(EMVSCmdSetOverlayText))->SetTextL(NULL);
1.133 + SetLineDimmedNow(EMVSCmdSetOverlayText, ETrue);
1.134 + }
1.135 + }
1.136 +
1.137 +#ifdef SYMBIAN_BUILD_GCE
1.138 + TAutoScaleType autoScaleType;
1.139 + TInt autoScaleHorizPos;
1.140 + TInt autoScaleVertPos;
1.141 + iAppUi->GetAutoScale(autoScaleType, autoScaleHorizPos, autoScaleVertPos);
1.142 +
1.143 + CEikChoiceList* autoScaleTypeList = static_cast<CEikChoiceList*>(Control(EMVSAutoScaleType));
1.144 + switch (autoScaleType)
1.145 + {
1.146 + case EAutoScaleNone:
1.147 + autoScaleTypeList->SetCurrentItem(0);
1.148 + break;
1.149 + case EAutoScaleBestFit:
1.150 + autoScaleTypeList->SetCurrentItem(1);
1.151 + break;
1.152 + case EAutoScaleClip:
1.153 + autoScaleTypeList->SetCurrentItem(2);
1.154 + break;
1.155 + case EAutoScaleStretch:
1.156 + autoScaleTypeList->SetCurrentItem(3);
1.157 + break;
1.158 + }
1.159 +
1.160 + CEikChoiceList* autoScaleHoriz = static_cast<CEikChoiceList*>(Control(EMVSAutoScaleHoriz));
1.161 + switch (autoScaleHorizPos)
1.162 + {
1.163 + case EHorizontalAlignLeft:
1.164 + autoScaleHoriz->SetCurrentItem(0);
1.165 + static_cast<CEikNumberEditor*>(Control(EMVSAutoScaleHorizPos))->SetNumber(0);
1.166 + break;
1.167 + case EHorizontalAlignCenter:
1.168 + autoScaleHoriz->SetCurrentItem(1);
1.169 + static_cast<CEikNumberEditor*>(Control(EMVSAutoScaleHorizPos))->SetNumber(0);
1.170 + break;
1.171 + case EHorizontalAlignRight:
1.172 + autoScaleHoriz->SetCurrentItem(2);
1.173 + static_cast<CEikNumberEditor*>(Control(EMVSAutoScaleHorizPos))->SetNumber(0);
1.174 + break;
1.175 + default:
1.176 + autoScaleHoriz->SetCurrentItem(3);
1.177 + static_cast<CEikNumberEditor*>(Control(EMVSAutoScaleHorizPos))->SetNumber(autoScaleHorizPos);
1.178 + break;
1.179 + }
1.180 +
1.181 + CEikChoiceList* autoScaleVert = static_cast<CEikChoiceList*>(Control(EMVSAutoScaleVert));
1.182 + switch (autoScaleVertPos)
1.183 + {
1.184 + case EVerticalAlignTop:
1.185 + autoScaleVert->SetCurrentItem(0);
1.186 + static_cast<CEikNumberEditor*>(Control(EMVSAutoScaleVertPos))->SetNumber(0);
1.187 + break;
1.188 + case EVerticalAlignCenter:
1.189 + autoScaleVert->SetCurrentItem(1);
1.190 + static_cast<CEikNumberEditor*>(Control(EMVSAutoScaleVertPos))->SetNumber(0);
1.191 + break;
1.192 + case EVerticalAlignBottom:
1.193 + autoScaleVert->SetCurrentItem(2);
1.194 + static_cast<CEikNumberEditor*>(Control(EMVSAutoScaleVertPos))->SetNumber(0);
1.195 + break;
1.196 + default:
1.197 + autoScaleVert->SetCurrentItem(3);
1.198 + static_cast<CEikNumberEditor*>(Control(EMVSAutoScaleVertPos))->SetNumber(autoScaleVertPos);
1.199 + break;
1.200 + }
1.201 +
1.202 + CEikCheckBox* pip = static_cast<CEikCheckBox*>(Control(EMVSPIP));
1.203 +
1.204 + if(pip)
1.205 + {
1.206 + pip->SetObserver(this);
1.207 + pip->SetState(iPip ? CEikButtonBase::ESet : CEikButtonBase::EClear);
1.208 + }
1.209 +
1.210 + CEikCheckBox* crp = static_cast<CEikCheckBox*>(Control(EMVSCRP));
1.211 +
1.212 + if(crp)
1.213 + {
1.214 + crp->SetObserver(this);
1.215 + crp->SetState(iCrp ? CEikButtonBase::ESet : CEikButtonBase::EClear);
1.216 + }
1.217 +
1.218 +#endif // SYMBIAN_BUILD_GCE
1.219 + }
1.220 +
1.221 +
1.222 +CMVSVideoSettingDialog::CMVSVideoSettingDialog(TVideoRotation aRotation,
1.223 + CMVSAppUi* aAppUi,
1.224 + const TRect& aVideoSize,
1.225 + const TRect& aWindowRect,
1.226 + TBool aSupportVideoPlayerUtility2,
1.227 + TBool aPip,
1.228 + TBool aCrp)
1.229 + : iRotation(aRotation),
1.230 + iAppUi(aAppUi),
1.231 + iVideoExtent(aVideoSize),
1.232 + iWindowClip(aWindowRect),
1.233 + iSupportVideoPlayerUtility2(aSupportVideoPlayerUtility2),
1.234 + iPip(aPip),
1.235 + iCrp(aCrp)
1.236 + {
1.237 + //Nothing to do here - all done in initialisation list
1.238 + }
1.239 +
1.240 +
1.241 +TBool CMVSVideoSettingDialog::OkToExitL(TInt aButtonId)
1.242 + {
1.243 + switch(aButtonId)
1.244 + {
1.245 + case EMVSButtonUpdate:
1.246 + {
1.247 + HandleUpdateL();
1.248 + break;
1.249 + }
1.250 +
1.251 + case EMVSButtonCancel:
1.252 + default: //cancel
1.253 + break;
1.254 + }
1.255 +
1.256 + return ETrue;
1.257 + }
1.258 +
1.259 +void CMVSVideoSettingDialog::HandleUpdateL()
1.260 + {
1.261 + // retrieve crop region value
1.262 + iAx = static_cast<CEikNumberEditor*>
1.263 + (Control(EMVSCmdSetTopLeftx))->Number();
1.264 +
1.265 + iAy = static_cast<CEikNumberEditor*>
1.266 + (Control(EMVSCmdSetTopLefty))->Number();
1.267 +
1.268 + iBx = static_cast<CEikNumberEditor*>
1.269 + (Control(EMVSCmdSetBottomRightx))->Number();
1.270 +
1.271 + iBy = static_cast<CEikNumberEditor*>
1.272 + (Control(EMVSCmdSetBottomRighty))->Number();
1.273 + TRect newCrop(iAx, iAy, iBx, iBy);
1.274 + if (newCrop != iCropRegion)
1.275 + {
1.276 + iAppUi->SetCropRegionL(newCrop);
1.277 + }
1.278 +
1.279 + // retrieve scale factor
1.280 + TReal32 scaleWidth = TReal32(static_cast<CEikFloatingPointEditor*>
1.281 + (Control(EMVSCmdScaleWidth))->Value());
1.282 + TReal32 scaleHeight = TReal32(static_cast<CEikFloatingPointEditor*>
1.283 + (Control(EMVSCmdScaleHeight))->Value());
1.284 + TBool antiAlias = (iAntiAliasFilteringCtl->State() == CEikButtonBase::ESet);
1.285 +
1.286 + if (iScaleWidth != scaleWidth || iScaleHeight != scaleHeight || antiAlias != iAntiAliasFiltering)
1.287 + {
1.288 + iAppUi->SetScaleFactorL(scaleWidth, scaleHeight, antiAlias);
1.289 + }
1.290 +
1.291 + // retrieve rotation value
1.292 + TVideoRotation newRotation(EVideoRotationNone);
1.293 + CEikChoiceList* rotation = static_cast<CEikChoiceList*>(Control(EMVSVideoRotationSettings));
1.294 + if(rotation)
1.295 + {
1.296 + switch (rotation->CurrentItem())
1.297 + {
1.298 + case 0:
1.299 + newRotation = EVideoRotationNone;
1.300 + break;
1.301 +
1.302 + case 1:
1.303 + newRotation = EVideoRotationClockwise90;
1.304 + break;
1.305 +
1.306 + case 2:
1.307 + newRotation = EVideoRotationClockwise180;
1.308 + break;
1.309 +
1.310 + case 3:
1.311 + newRotation = EVideoRotationClockwise270;
1.312 + break;
1.313 +
1.314 + default:
1.315 + newRotation = EVideoRotationNone;
1.316 + break;
1.317 + }
1.318 + }
1.319 + if (iRotation != newRotation)
1.320 + {
1.321 + iAppUi->SetRotationL(newRotation);
1.322 + iRotation = newRotation;
1.323 + }
1.324 +
1.325 +#ifdef SYMBIAN_BUILD_GCE
1.326 + // retrieves window clipping rect
1.327 + TRect newWinClipRect;
1.328 + RetrieveWindowClipRectFieldValues(newWinClipRect);
1.329 +
1.330 + if (newWinClipRect != iWindowClip)
1.331 + {
1.332 + iAppUi->SetWindowClippingRect(newWinClipRect);
1.333 + }
1.334 +
1.335 +
1.336 + // retrieves video extent properties
1.337 + TRect newVideoExtent;
1.338 + RetrieveVideoExtentFieldValues(newVideoExtent);
1.339 +
1.340 + if (newVideoExtent != iVideoExtent)
1.341 + {
1.342 + iAppUi->SetVideoExtent(newVideoExtent);
1.343 + }
1.344 +
1.345 + // retrieve overlay text
1.346 + HBufC* overlayText = NULL;
1.347 + if (static_cast<CEikCheckBox*>(Control(EMVSCmdSetDisplayOverlayText))->State()
1.348 + == CEikButtonBase::ESet)
1.349 + {
1.350 + overlayText
1.351 + = static_cast<CEikEdwin*>(Control(EMVSCmdSetOverlayText))->GetTextInHBufL();
1.352 + }
1.353 +
1.354 + if (overlayText)
1.355 + {
1.356 + iAppUi->SetOverlayTextL(*overlayText);
1.357 + delete overlayText;
1.358 + }
1.359 + else
1.360 + {
1.361 + iAppUi->SetOverlayTextL(KNullDesC);
1.362 + }
1.363 +
1.364 + // retrieve autoscale values
1.365 + TAutoScaleType newAutoScaleType = EAutoScaleNone;
1.366 + TInt newAutoScaleHorizPos = 0;
1.367 + TInt newAutoScaleVertPos = 0;
1.368 +
1.369 + CEikChoiceList* autoScaleType = static_cast<CEikChoiceList*>(Control(EMVSAutoScaleType));
1.370 +
1.371 + if (autoScaleType)
1.372 + {
1.373 + switch (autoScaleType->CurrentItem())
1.374 + {
1.375 + case 0:
1.376 + newAutoScaleType = EAutoScaleNone;
1.377 + break;
1.378 + case 1:
1.379 + newAutoScaleType = EAutoScaleBestFit;
1.380 + break;
1.381 + case 2:
1.382 + newAutoScaleType = EAutoScaleClip;
1.383 + break;
1.384 + case 3:
1.385 + newAutoScaleType = EAutoScaleStretch;
1.386 + break;
1.387 + default:
1.388 + newAutoScaleType = EAutoScaleNone;
1.389 + break;
1.390 + }
1.391 + }
1.392 +
1.393 + CEikChoiceList* autoScaleHoriz = static_cast<CEikChoiceList*>(Control(EMVSAutoScaleHoriz));
1.394 + switch (autoScaleHoriz->CurrentItem())
1.395 + {
1.396 + case 0:
1.397 + newAutoScaleHorizPos = EHorizontalAlignLeft;
1.398 + break;
1.399 + case 1:
1.400 + newAutoScaleHorizPos = EHorizontalAlignCenter;
1.401 + break;
1.402 + case 2:
1.403 + newAutoScaleHorizPos = EHorizontalAlignRight;
1.404 + break;
1.405 + default:
1.406 + newAutoScaleHorizPos = static_cast<CEikNumberEditor*>(Control(EMVSAutoScaleHorizPos))->Number();
1.407 + break;
1.408 + }
1.409 +
1.410 + CEikChoiceList* autoScaleVert = static_cast<CEikChoiceList*>(Control(EMVSAutoScaleVert));
1.411 + switch (autoScaleVert->CurrentItem())
1.412 + {
1.413 + case 0:
1.414 + newAutoScaleVertPos = EVerticalAlignTop;
1.415 + break;
1.416 + case 1:
1.417 + newAutoScaleVertPos = EVerticalAlignCenter;
1.418 + break;
1.419 + case 2:
1.420 + newAutoScaleVertPos = EVerticalAlignBottom;
1.421 + break;
1.422 + default:
1.423 + newAutoScaleVertPos = static_cast<CEikNumberEditor*>(Control(EMVSAutoScaleVertPos))->Number();
1.424 + break;
1.425 + }
1.426 +
1.427 + iAppUi->SetAutoScaleL(newAutoScaleType, newAutoScaleHorizPos, newAutoScaleVertPos);
1.428 +
1.429 + CEikButtonBase::TState state = static_cast<CEikCheckBox*>(Control(EMVSPIP))->State();
1.430 + iAppUi->SetPip(CEikButtonBase::ESet == state);
1.431 +
1.432 + state = static_cast<CEikCheckBox*>(Control(EMVSCRP))->State();
1.433 + iAppUi->SetCrp(CEikButtonBase::ESet == state);
1.434 +#endif // SYMBIAN_BUILD_GCE
1.435 + }
1.436 +
1.437 +
1.438 +void CMVSVideoSettingDialog::RetrieveVideoExtentFieldValues(TRect& aVideoExtentValues) const
1.439 + {
1.440 + aVideoExtentValues.iTl.iX
1.441 + = static_cast<CEikNumberEditor*>(Control(EMVSCmdSetVideoExtentTopLeftx))->Number();
1.442 +
1.443 + aVideoExtentValues.iTl.iY
1.444 + = static_cast<CEikNumberEditor*>(Control(EMVSCmdSetVideoExtentTopLefty))->Number();
1.445 +
1.446 + aVideoExtentValues.iBr.iX
1.447 + = static_cast<CEikNumberEditor*>(Control(EMVSCmdSetVideoExtentBottomRightx))->Number();
1.448 +
1.449 + aVideoExtentValues.iBr.iY
1.450 + = static_cast<CEikNumberEditor*>(Control(EMVSCmdSetVideoExtentBottomRighty))->Number();
1.451 + }
1.452 +
1.453 +void CMVSVideoSettingDialog::RetrieveWindowClipRectFieldValues(TRect& aNewVideoExtent) const
1.454 + {
1.455 + aNewVideoExtent.iTl.iX
1.456 + = static_cast<CEikNumberEditor*>(Control(EMVSCmdSetWindowClipTopLeftx))->Number();
1.457 +
1.458 + aNewVideoExtent.iTl.iY
1.459 + = static_cast<CEikNumberEditor*>(Control(EMVSCmdSetWindowClipTopLefty))->Number();
1.460 +
1.461 + aNewVideoExtent.iBr.iX
1.462 + = static_cast<CEikNumberEditor*>(Control(EMVSCmdSetWindowClipBottomRightx))->Number();
1.463 +
1.464 + aNewVideoExtent.iBr.iY
1.465 + = static_cast<CEikNumberEditor*>(Control(EMVSCmdSetWindowClipBottomRighty))->Number();
1.466 + }
1.467 +
1.468 +void CMVSVideoSettingDialog::HandleControlEventL(CCoeControl *aControl, TCoeEvent aEventType)
1.469 + {
1.470 + CEikDialog::HandleControlEventL(aControl,aEventType);
1.471 + if (aControl == Control(EMVSCmdSetDisplayOverlayText) && aEventType == EEventStateChanged)
1.472 + {
1.473 + CEikCheckBox* overlayCheckBox
1.474 + = static_cast<CEikCheckBox*>(Control(EMVSCmdSetDisplayOverlayText));
1.475 +
1.476 + TBool disableOverlayText = (overlayCheckBox->State() != CEikButtonBase::ESet);
1.477 + SetLineDimmedNow(EMVSCmdSetOverlayText, disableOverlayText);
1.478 + }
1.479 + }