sl@0: // Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: // All rights reserved. sl@0: // This component and the accompanying materials are made available sl@0: // under the terms of "Eclipse Public License v1.0" sl@0: // which accompanies this distribution, and is available sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: // sl@0: // Initial Contributors: sl@0: // Nokia Corporation - initial contribution. sl@0: // sl@0: // Contributors: sl@0: // sl@0: // Description: sl@0: // Part of the MVS Application for TechView sl@0: // sl@0: sl@0: #include sl@0: #include sl@0: sl@0: #include "MVSVideoSettingDialog.h" sl@0: #include "MVSApp.hrh" sl@0: sl@0: void CMVSVideoSettingDialog::SetupDialogLD(TVideoRotation aRotation, sl@0: CMVSAppUi* aAppUi, sl@0: const TRect& aVideoSize, sl@0: const TRect& aWindowRect, sl@0: TBool aSupportVideoPlayerUtility2, sl@0: TBool aPip, sl@0: TBool aCrp) sl@0: { sl@0: CMVSVideoSettingDialog* dialog = new (ELeave) CMVSVideoSettingDialog(aRotation, sl@0: aAppUi, sl@0: aVideoSize, sl@0: aWindowRect, sl@0: aSupportVideoPlayerUtility2, sl@0: aPip, sl@0: aCrp); sl@0: dialog->ExecuteLD(R_MVS_VIDEO_DIALOG_VIDEOSETTING); sl@0: } sl@0: sl@0: sl@0: void CMVSVideoSettingDialog::PreLayoutDynInitL() sl@0: { sl@0: // Get a downcasted pointer to the controls sl@0: CEikChoiceList* rotation = static_cast(Control(EMVSVideoRotationSettings)); sl@0: if(rotation) sl@0: { sl@0: rotation->SetCurrentItem(iRotation); sl@0: } sl@0: sl@0: // default the scaling factor to the current scaling factor as used by the video playback sl@0: // utility sl@0: iAppUi->GetScaleFactorL(iScaleWidth, iScaleHeight, iAntiAliasFiltering); sl@0: sl@0: CEikCheckBox* antiAliasFiltering = static_cast(Control(EMVSAntiAliasFiltering)); sl@0: if(antiAliasFiltering) sl@0: { sl@0: iAntiAliasFilteringCtl = antiAliasFiltering; sl@0: antiAliasFiltering->SetObserver(this); sl@0: antiAliasFiltering->SetState( sl@0: iAntiAliasFiltering ? CEikButtonBase::ESet : CEikButtonBase::EClear); sl@0: } sl@0: sl@0: CEikFloatingPointEditor* editor = static_cast (Control(EMVSCmdScaleWidth)); sl@0: TReal temp(iScaleWidth); sl@0: editor->SetValueL(&temp); sl@0: sl@0: temp = iScaleHeight; sl@0: editor = static_cast (Control(EMVSCmdScaleHeight)); sl@0: editor->SetValueL(&temp); sl@0: sl@0: // default the crop region to the current crop region values as used by the video playback sl@0: // utility sl@0: iAppUi->GetCropRegionL(iCropRegion); sl@0: sl@0: static_cast sl@0: (Control(EMVSCmdSetTopLeftx))->SetNumber(iCropRegion.iTl.iX); sl@0: static_cast sl@0: (Control(EMVSCmdSetTopLefty))->SetNumber(iCropRegion.iTl.iY); sl@0: static_cast sl@0: (Control(EMVSCmdSetBottomRightx))->SetNumber(iCropRegion.iBr.iX); sl@0: static_cast sl@0: (Control(EMVSCmdSetBottomRighty))->SetNumber(iCropRegion.iBr.iY); sl@0: sl@0: if (!iSupportVideoPlayerUtility2) sl@0: { sl@0: // hide the video extent & window clipping rect UI elements if CVideoPlayerUtility2 sl@0: // is not in effect sl@0: for (TInt i = EMVSCmdSetVideoExtentTopLeftx; i <= EMVSCmdSetOverlayText; i++) sl@0: { sl@0: SetLineDimmedNow(i, ETrue); sl@0: SetLineNonFocusing(i); sl@0: } sl@0: } sl@0: else sl@0: { sl@0: // default the video extent to values currently set in the application sl@0: static_cast sl@0: (Control(EMVSCmdSetVideoExtentTopLeftx))->SetNumber(iVideoExtent.iTl.iX); sl@0: static_cast sl@0: (Control(EMVSCmdSetVideoExtentTopLefty))->SetNumber(iVideoExtent.iTl.iY); sl@0: static_cast sl@0: (Control(EMVSCmdSetVideoExtentBottomRightx))->SetNumber(iVideoExtent.iBr.iX); sl@0: static_cast sl@0: (Control(EMVSCmdSetVideoExtentBottomRighty))->SetNumber(iVideoExtent.iBr.iY); sl@0: sl@0: // default the window clipping rect to values currently set in the application sl@0: static_cast sl@0: (Control(EMVSCmdSetWindowClipTopLeftx))->SetNumber(iWindowClip.iTl.iX); sl@0: static_cast sl@0: (Control(EMVSCmdSetWindowClipTopLefty))->SetNumber(iWindowClip.iTl.iY); sl@0: static_cast sl@0: (Control(EMVSCmdSetWindowClipBottomRightx))->SetNumber(iWindowClip.iBr.iX); sl@0: static_cast sl@0: (Control(EMVSCmdSetWindowClipBottomRighty))->SetNumber(iWindowClip.iBr.iY); sl@0: sl@0: if (iAppUi->OverlayText().Length() > 0) sl@0: { sl@0: static_cast sl@0: (Control(EMVSCmdSetDisplayOverlayText))->SetState(CEikButtonBase::ESet); sl@0: static_cast sl@0: (Control(EMVSCmdSetOverlayText))->SetTextL(&iAppUi->OverlayText()); sl@0: } sl@0: else sl@0: { sl@0: static_cast sl@0: (Control(EMVSCmdSetDisplayOverlayText))->SetState(CEikButtonBase::EClear); sl@0: static_cast sl@0: (Control(EMVSCmdSetOverlayText))->SetTextL(NULL); sl@0: SetLineDimmedNow(EMVSCmdSetOverlayText, ETrue); sl@0: } sl@0: } sl@0: sl@0: #ifdef SYMBIAN_BUILD_GCE sl@0: TAutoScaleType autoScaleType; sl@0: TInt autoScaleHorizPos; sl@0: TInt autoScaleVertPos; sl@0: iAppUi->GetAutoScale(autoScaleType, autoScaleHorizPos, autoScaleVertPos); sl@0: sl@0: CEikChoiceList* autoScaleTypeList = static_cast(Control(EMVSAutoScaleType)); sl@0: switch (autoScaleType) sl@0: { sl@0: case EAutoScaleNone: sl@0: autoScaleTypeList->SetCurrentItem(0); sl@0: break; sl@0: case EAutoScaleBestFit: sl@0: autoScaleTypeList->SetCurrentItem(1); sl@0: break; sl@0: case EAutoScaleClip: sl@0: autoScaleTypeList->SetCurrentItem(2); sl@0: break; sl@0: case EAutoScaleStretch: sl@0: autoScaleTypeList->SetCurrentItem(3); sl@0: break; sl@0: } sl@0: sl@0: CEikChoiceList* autoScaleHoriz = static_cast(Control(EMVSAutoScaleHoriz)); sl@0: switch (autoScaleHorizPos) sl@0: { sl@0: case EHorizontalAlignLeft: sl@0: autoScaleHoriz->SetCurrentItem(0); sl@0: static_cast(Control(EMVSAutoScaleHorizPos))->SetNumber(0); sl@0: break; sl@0: case EHorizontalAlignCenter: sl@0: autoScaleHoriz->SetCurrentItem(1); sl@0: static_cast(Control(EMVSAutoScaleHorizPos))->SetNumber(0); sl@0: break; sl@0: case EHorizontalAlignRight: sl@0: autoScaleHoriz->SetCurrentItem(2); sl@0: static_cast(Control(EMVSAutoScaleHorizPos))->SetNumber(0); sl@0: break; sl@0: default: sl@0: autoScaleHoriz->SetCurrentItem(3); sl@0: static_cast(Control(EMVSAutoScaleHorizPos))->SetNumber(autoScaleHorizPos); sl@0: break; sl@0: } sl@0: sl@0: CEikChoiceList* autoScaleVert = static_cast(Control(EMVSAutoScaleVert)); sl@0: switch (autoScaleVertPos) sl@0: { sl@0: case EVerticalAlignTop: sl@0: autoScaleVert->SetCurrentItem(0); sl@0: static_cast(Control(EMVSAutoScaleVertPos))->SetNumber(0); sl@0: break; sl@0: case EVerticalAlignCenter: sl@0: autoScaleVert->SetCurrentItem(1); sl@0: static_cast(Control(EMVSAutoScaleVertPos))->SetNumber(0); sl@0: break; sl@0: case EVerticalAlignBottom: sl@0: autoScaleVert->SetCurrentItem(2); sl@0: static_cast(Control(EMVSAutoScaleVertPos))->SetNumber(0); sl@0: break; sl@0: default: sl@0: autoScaleVert->SetCurrentItem(3); sl@0: static_cast(Control(EMVSAutoScaleVertPos))->SetNumber(autoScaleVertPos); sl@0: break; sl@0: } sl@0: sl@0: CEikCheckBox* pip = static_cast(Control(EMVSPIP)); sl@0: sl@0: if(pip) sl@0: { sl@0: pip->SetObserver(this); sl@0: pip->SetState(iPip ? CEikButtonBase::ESet : CEikButtonBase::EClear); sl@0: } sl@0: sl@0: CEikCheckBox* crp = static_cast(Control(EMVSCRP)); sl@0: sl@0: if(crp) sl@0: { sl@0: crp->SetObserver(this); sl@0: crp->SetState(iCrp ? CEikButtonBase::ESet : CEikButtonBase::EClear); sl@0: } sl@0: sl@0: #endif // SYMBIAN_BUILD_GCE sl@0: } sl@0: sl@0: sl@0: CMVSVideoSettingDialog::CMVSVideoSettingDialog(TVideoRotation aRotation, sl@0: CMVSAppUi* aAppUi, sl@0: const TRect& aVideoSize, sl@0: const TRect& aWindowRect, sl@0: TBool aSupportVideoPlayerUtility2, sl@0: TBool aPip, sl@0: TBool aCrp) sl@0: : iRotation(aRotation), sl@0: iAppUi(aAppUi), sl@0: iVideoExtent(aVideoSize), sl@0: iWindowClip(aWindowRect), sl@0: iSupportVideoPlayerUtility2(aSupportVideoPlayerUtility2), sl@0: iPip(aPip), sl@0: iCrp(aCrp) sl@0: { sl@0: //Nothing to do here - all done in initialisation list sl@0: } sl@0: sl@0: sl@0: TBool CMVSVideoSettingDialog::OkToExitL(TInt aButtonId) sl@0: { sl@0: switch(aButtonId) sl@0: { sl@0: case EMVSButtonUpdate: sl@0: { sl@0: HandleUpdateL(); sl@0: break; sl@0: } sl@0: sl@0: case EMVSButtonCancel: sl@0: default: //cancel sl@0: break; sl@0: } sl@0: sl@0: return ETrue; sl@0: } sl@0: sl@0: void CMVSVideoSettingDialog::HandleUpdateL() sl@0: { sl@0: // retrieve crop region value sl@0: iAx = static_cast sl@0: (Control(EMVSCmdSetTopLeftx))->Number(); sl@0: sl@0: iAy = static_cast sl@0: (Control(EMVSCmdSetTopLefty))->Number(); sl@0: sl@0: iBx = static_cast sl@0: (Control(EMVSCmdSetBottomRightx))->Number(); sl@0: sl@0: iBy = static_cast sl@0: (Control(EMVSCmdSetBottomRighty))->Number(); sl@0: TRect newCrop(iAx, iAy, iBx, iBy); sl@0: if (newCrop != iCropRegion) sl@0: { sl@0: iAppUi->SetCropRegionL(newCrop); sl@0: } sl@0: sl@0: // retrieve scale factor sl@0: TReal32 scaleWidth = TReal32(static_cast sl@0: (Control(EMVSCmdScaleWidth))->Value()); sl@0: TReal32 scaleHeight = TReal32(static_cast sl@0: (Control(EMVSCmdScaleHeight))->Value()); sl@0: TBool antiAlias = (iAntiAliasFilteringCtl->State() == CEikButtonBase::ESet); sl@0: sl@0: if (iScaleWidth != scaleWidth || iScaleHeight != scaleHeight || antiAlias != iAntiAliasFiltering) sl@0: { sl@0: iAppUi->SetScaleFactorL(scaleWidth, scaleHeight, antiAlias); sl@0: } sl@0: sl@0: // retrieve rotation value sl@0: TVideoRotation newRotation(EVideoRotationNone); sl@0: CEikChoiceList* rotation = static_cast(Control(EMVSVideoRotationSettings)); sl@0: if(rotation) sl@0: { sl@0: switch (rotation->CurrentItem()) sl@0: { sl@0: case 0: sl@0: newRotation = EVideoRotationNone; sl@0: break; sl@0: sl@0: case 1: sl@0: newRotation = EVideoRotationClockwise90; sl@0: break; sl@0: sl@0: case 2: sl@0: newRotation = EVideoRotationClockwise180; sl@0: break; sl@0: sl@0: case 3: sl@0: newRotation = EVideoRotationClockwise270; sl@0: break; sl@0: sl@0: default: sl@0: newRotation = EVideoRotationNone; sl@0: break; sl@0: } sl@0: } sl@0: if (iRotation != newRotation) sl@0: { sl@0: iAppUi->SetRotationL(newRotation); sl@0: iRotation = newRotation; sl@0: } sl@0: sl@0: #ifdef SYMBIAN_BUILD_GCE sl@0: // retrieves window clipping rect sl@0: TRect newWinClipRect; sl@0: RetrieveWindowClipRectFieldValues(newWinClipRect); sl@0: sl@0: if (newWinClipRect != iWindowClip) sl@0: { sl@0: iAppUi->SetWindowClippingRect(newWinClipRect); sl@0: } sl@0: sl@0: sl@0: // retrieves video extent properties sl@0: TRect newVideoExtent; sl@0: RetrieveVideoExtentFieldValues(newVideoExtent); sl@0: sl@0: if (newVideoExtent != iVideoExtent) sl@0: { sl@0: iAppUi->SetVideoExtent(newVideoExtent); sl@0: } sl@0: sl@0: // retrieve overlay text sl@0: HBufC* overlayText = NULL; sl@0: if (static_cast(Control(EMVSCmdSetDisplayOverlayText))->State() sl@0: == CEikButtonBase::ESet) sl@0: { sl@0: overlayText sl@0: = static_cast(Control(EMVSCmdSetOverlayText))->GetTextInHBufL(); sl@0: } sl@0: sl@0: if (overlayText) sl@0: { sl@0: iAppUi->SetOverlayTextL(*overlayText); sl@0: delete overlayText; sl@0: } sl@0: else sl@0: { sl@0: iAppUi->SetOverlayTextL(KNullDesC); sl@0: } sl@0: sl@0: // retrieve autoscale values sl@0: TAutoScaleType newAutoScaleType = EAutoScaleNone; sl@0: TInt newAutoScaleHorizPos = 0; sl@0: TInt newAutoScaleVertPos = 0; sl@0: sl@0: CEikChoiceList* autoScaleType = static_cast(Control(EMVSAutoScaleType)); sl@0: sl@0: if (autoScaleType) sl@0: { sl@0: switch (autoScaleType->CurrentItem()) sl@0: { sl@0: case 0: sl@0: newAutoScaleType = EAutoScaleNone; sl@0: break; sl@0: case 1: sl@0: newAutoScaleType = EAutoScaleBestFit; sl@0: break; sl@0: case 2: sl@0: newAutoScaleType = EAutoScaleClip; sl@0: break; sl@0: case 3: sl@0: newAutoScaleType = EAutoScaleStretch; sl@0: break; sl@0: default: sl@0: newAutoScaleType = EAutoScaleNone; sl@0: break; sl@0: } sl@0: } sl@0: sl@0: CEikChoiceList* autoScaleHoriz = static_cast(Control(EMVSAutoScaleHoriz)); sl@0: switch (autoScaleHoriz->CurrentItem()) sl@0: { sl@0: case 0: sl@0: newAutoScaleHorizPos = EHorizontalAlignLeft; sl@0: break; sl@0: case 1: sl@0: newAutoScaleHorizPos = EHorizontalAlignCenter; sl@0: break; sl@0: case 2: sl@0: newAutoScaleHorizPos = EHorizontalAlignRight; sl@0: break; sl@0: default: sl@0: newAutoScaleHorizPos = static_cast(Control(EMVSAutoScaleHorizPos))->Number(); sl@0: break; sl@0: } sl@0: sl@0: CEikChoiceList* autoScaleVert = static_cast(Control(EMVSAutoScaleVert)); sl@0: switch (autoScaleVert->CurrentItem()) sl@0: { sl@0: case 0: sl@0: newAutoScaleVertPos = EVerticalAlignTop; sl@0: break; sl@0: case 1: sl@0: newAutoScaleVertPos = EVerticalAlignCenter; sl@0: break; sl@0: case 2: sl@0: newAutoScaleVertPos = EVerticalAlignBottom; sl@0: break; sl@0: default: sl@0: newAutoScaleVertPos = static_cast(Control(EMVSAutoScaleVertPos))->Number(); sl@0: break; sl@0: } sl@0: sl@0: iAppUi->SetAutoScaleL(newAutoScaleType, newAutoScaleHorizPos, newAutoScaleVertPos); sl@0: sl@0: CEikButtonBase::TState state = static_cast(Control(EMVSPIP))->State(); sl@0: iAppUi->SetPip(CEikButtonBase::ESet == state); sl@0: sl@0: state = static_cast(Control(EMVSCRP))->State(); sl@0: iAppUi->SetCrp(CEikButtonBase::ESet == state); sl@0: #endif // SYMBIAN_BUILD_GCE sl@0: } sl@0: sl@0: sl@0: void CMVSVideoSettingDialog::RetrieveVideoExtentFieldValues(TRect& aVideoExtentValues) const sl@0: { sl@0: aVideoExtentValues.iTl.iX sl@0: = static_cast(Control(EMVSCmdSetVideoExtentTopLeftx))->Number(); sl@0: sl@0: aVideoExtentValues.iTl.iY sl@0: = static_cast(Control(EMVSCmdSetVideoExtentTopLefty))->Number(); sl@0: sl@0: aVideoExtentValues.iBr.iX sl@0: = static_cast(Control(EMVSCmdSetVideoExtentBottomRightx))->Number(); sl@0: sl@0: aVideoExtentValues.iBr.iY sl@0: = static_cast(Control(EMVSCmdSetVideoExtentBottomRighty))->Number(); sl@0: } sl@0: sl@0: void CMVSVideoSettingDialog::RetrieveWindowClipRectFieldValues(TRect& aNewVideoExtent) const sl@0: { sl@0: aNewVideoExtent.iTl.iX sl@0: = static_cast(Control(EMVSCmdSetWindowClipTopLeftx))->Number(); sl@0: sl@0: aNewVideoExtent.iTl.iY sl@0: = static_cast(Control(EMVSCmdSetWindowClipTopLefty))->Number(); sl@0: sl@0: aNewVideoExtent.iBr.iX sl@0: = static_cast(Control(EMVSCmdSetWindowClipBottomRightx))->Number(); sl@0: sl@0: aNewVideoExtent.iBr.iY sl@0: = static_cast(Control(EMVSCmdSetWindowClipBottomRighty))->Number(); sl@0: } sl@0: sl@0: void CMVSVideoSettingDialog::HandleControlEventL(CCoeControl *aControl, TCoeEvent aEventType) sl@0: { sl@0: CEikDialog::HandleControlEventL(aControl,aEventType); sl@0: if (aControl == Control(EMVSCmdSetDisplayOverlayText) && aEventType == EEventStateChanged) sl@0: { sl@0: CEikCheckBox* overlayCheckBox sl@0: = static_cast(Control(EMVSCmdSetDisplayOverlayText)); sl@0: sl@0: TBool disableOverlayText = (overlayCheckBox->State() != CEikButtonBase::ESet); sl@0: SetLineDimmedNow(EMVSCmdSetOverlayText, disableOverlayText); sl@0: } sl@0: }