sl@0: // Copyright (c) 1995-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: // sl@0: sl@0: #include "W32STDGRAPHIC.H" sl@0: sl@0: // TWsGraphicAnimation \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ sl@0: sl@0: EXPORT_C TWsGraphicAnimation::TWsGraphicAnimation(): sl@0: TWsGraphicMsgFixedBase(TUid::Uid(ETypeId),sizeof(*this)), sl@0: iFlags(EStopped) sl@0: { sl@0: } sl@0: sl@0: EXPORT_C TBool TWsGraphicAnimation::IsPlaying() const sl@0: { sl@0: return (State() == EPlaying); sl@0: } sl@0: sl@0: EXPORT_C TBool TWsGraphicAnimation::IsStopped() const sl@0: { sl@0: return (State() == EStopped); sl@0: } sl@0: sl@0: EXPORT_C TBool TWsGraphicAnimation::IsStopping() const sl@0: { sl@0: return (State() == EStopping); sl@0: } sl@0: sl@0: EXPORT_C TBool TWsGraphicAnimation::IsPaused() const sl@0: { sl@0: return (State() == EPaused); sl@0: } sl@0: sl@0: EXPORT_C TBool TWsGraphicAnimation::Loops() const sl@0: { sl@0: switch(State()) sl@0: { sl@0: case EPlaying: sl@0: case EPaused: sl@0: return ((iFlags & ELoop) == ELoop); sl@0: default: sl@0: return EFalse; sl@0: } sl@0: } sl@0: sl@0: TUint TWsGraphicAnimation::State() const sl@0: { sl@0: return (iFlags & EStateMask); sl@0: } sl@0: sl@0: void TWsGraphicAnimation::SetState(TUint aState) sl@0: { sl@0: iFlags &= ~EStateMask; sl@0: iFlags |= (aState & EStateMask); sl@0: } sl@0: sl@0: EXPORT_C void TWsGraphicAnimation::Play(TBool aLoop) sl@0: { sl@0: switch(State()) sl@0: { sl@0: case EStopped: sl@0: case EStopping: sl@0: SetState(EPlaying); sl@0: // fall through sl@0: case EPlaying: sl@0: iPlay.UniversalTime(); //Start over again sl@0: break; sl@0: case EPaused: sl@0: SetState(EPlaying); sl@0: if(aLoop != Loops()) // can't resume a mismatch of looping attribute sl@0: { sl@0: iPlay.UniversalTime(); sl@0: } sl@0: else // resume sl@0: { sl@0: TTimeIntervalMicroSeconds delta = iPauseOrStopping.MicroSecondsFrom(iPlay); sl@0: iPlay.UniversalTime(); sl@0: iPlay = iPlay.Int64() - delta.Int64(); sl@0: break; sl@0: } sl@0: } sl@0: if(aLoop) sl@0: { sl@0: iFlags |= ELoop; sl@0: } sl@0: else sl@0: { sl@0: iFlags &= ~ELoop; sl@0: } sl@0: } sl@0: sl@0: EXPORT_C void TWsGraphicAnimation::Pause() sl@0: { sl@0: switch(State()) sl@0: { sl@0: case EPlaying: sl@0: case EStopping: sl@0: SetState(EPaused); sl@0: iPauseOrStopping.UniversalTime(); sl@0: break; sl@0: case EStopped: sl@0: case EPaused: sl@0: break; sl@0: } sl@0: } sl@0: sl@0: EXPORT_C void TWsGraphicAnimation::Stop(TBool aImmediately) sl@0: { sl@0: if(aImmediately) sl@0: { sl@0: SetState(EStopped); sl@0: } sl@0: else sl@0: { sl@0: switch(State()) sl@0: { sl@0: case EPlaying: sl@0: SetState(EStopping); sl@0: iPauseOrStopping.UniversalTime(); sl@0: break; sl@0: case EStopped: sl@0: break; sl@0: case EStopping: sl@0: iPauseOrStopping.UniversalTime(); sl@0: break; sl@0: case EPaused: sl@0: SetState(EStopping); sl@0: TTimeIntervalMicroSeconds delta = iPauseOrStopping.MicroSecondsFrom(iPlay); sl@0: iPlay.UniversalTime(); sl@0: iPlay = iPlay.Int64() - delta.Int64(); sl@0: iPauseOrStopping.UniversalTime(); sl@0: break; sl@0: } sl@0: } sl@0: }