void CubeTransitionWaveEffect::OnStartTransition( Vector2 panPosition, Vector2 panDisplacement ) { float direc = mIsToNextImage ? 1.f : -1.f; CalculateSaddleSurfaceParameters( panPosition, panDisplacement*direc ); float angle = mRotateIndex * 90.0f ; Vector3 translation = mTiles[mContainerIndex][ 0 ].GetCurrentPosition()*(-2.f); unsigned int idx; unsigned int totalNum = mNumColumns* mNumRows; if( mFirstTransition && (!mIsToNextImage) ) // the first transition is transiting to previous image { for( unsigned int idx = 0; idx < totalNum; idx++ ) { mTiles[mContainerIndex][idx].SetRotation( Degree( angle), Vector3::YAXIS ); } } else if(!mChangeTurningDirection) // reset rotation, translation { for( unsigned int idx = 0; idx < totalNum; idx++ ) { mTiles[mContainerIndex][idx].MoveBy( translation ); mTiles[mContainerIndex][idx].SetRotation( Degree( angle), Vector3::YAXIS ); } } float thirdAnimationDuration = mAnimationDuration / 3.f; unsigned int anotherIndex = mContainerIndex^1; for( unsigned int y = 0; y < mNumRows; y++ ) { for( unsigned int x = 0; x < mNumColumns; x++) { idx = y*mNumColumns + x; // the delay value is within 0.f ~ 2.f*thirdAnimationDuration float delay = thirdAnimationDuration * CalculateDelay(x*mTileSize.width,y*mTileSize.height); mAnimation.RotateTo( mBoxes[idx], Degree( -angle ), Vector3::YAXIS, AlphaFunctions::EaseOutSine, delay, thirdAnimationDuration ); mAnimation.MoveBy( mBoxes[idx], Vector3(0.f,0.f,-mCubeDisplacement), AlphaFunctions::Bounce, delay, thirdAnimationDuration ); mAnimation.ColorTo( mTiles[anotherIndex][idx], HALF_BRIGHTNESS, AlphaFunctions::EaseOut, delay, thirdAnimationDuration ); mAnimation.ColorTo( mTiles[mContainerIndex][idx], FULL_BRIGHTNESS, AlphaFunctions::EaseIn, delay, thirdAnimationDuration ); } } mAnimation.Play(); mIsAnimating = true; }
void CGroupsUI::DoEvent(TEventUI& event) { if (!IsMouseEnabled() && event.Type > UIEVENT__MOUSEBEGIN && event.Type < UIEVENT__MOUSEEND) { if (m_pParent != NULL) m_pParent->DoEvent(event); else CVerticalLayoutUI::DoEvent(event); return; } if (event.Type == UIEVENT_TIMER && event.wParam == SCROLL_TIMERID) { if (delay_left_ > 0) { --delay_left_; SIZE sz = GetScrollPos(); LONG lDeltaY = (LONG)(CalculateDelay((double)delay_left_ / delay_number_) * delay_deltaY_); if ((lDeltaY > 0 && sz.cy != 0) || (lDeltaY < 0 && sz.cy != GetScrollRange().cy )) { sz.cy -= lDeltaY; SetScrollPos(sz); return; } } delay_deltaY_ = 0; delay_number_ = 0; delay_left_ = 0; m_pManager->KillTimer(this, SCROLL_TIMERID); return; } if (event.Type == UIEVENT_SCROLLWHEEL) { LONG lDeltaY = 0; if (delay_number_ > 0) lDeltaY = (LONG)(CalculateDelay((double)delay_left_ / delay_number_) * delay_deltaY_); switch (LOWORD(event.wParam)) { case SB_LINEUP: if (delay_deltaY_ >= 0) delay_deltaY_ = lDeltaY + 8; else delay_deltaY_ = lDeltaY + 12; break; case SB_LINEDOWN: if (delay_deltaY_ <= 0) delay_deltaY_ = lDeltaY - 8; else delay_deltaY_ = lDeltaY - 12; break; } if (delay_deltaY_ > 100) delay_deltaY_ = 100; else if (delay_deltaY_ < -100) delay_deltaY_ = -100; delay_number_ = (DWORD)sqrt((double)abs(delay_deltaY_)) * 5; delay_left_ = delay_number_; m_pManager->SetTimer(this, SCROLL_TIMERID, 50U); return; } CListUI::DoEvent(event); }