void CubeTransitionApp::GoToNextImage() { mNextTexture = LoadStageFillingTexture( IMAGES[ mIndex ] ); mCurrentEffect.SetTargetTexture( mNextTexture ); mIsImageLoading = false; mCurrentEffect.StartTransition( mPanPosition, mPanDisplacement ); mCurrentTexture = mNextTexture; }
bool CubeTransitionApp::OnEffectButtonClicked( Toolkit::Button button ) { mContent.Remove( mCurrentEffect ); if(mCurrentEffect == mCubeWaveEffect) { mCurrentEffect = mCubeCrossEffect; mTitle.SetProperty( TextLabel::Property::TEXT, std::string(APPLICATION_TITLE_CROSS) ); mEffectChangeButton.SetUnselectedImage( EFFECT_CROSS_IMAGE ); mEffectChangeButton.SetSelectedImage( EFFECT_CROSS_IMAGE_SELECTED ); } else if(mCurrentEffect == mCubeCrossEffect) { mCurrentEffect = mCubeFoldEffect; mTitle.SetProperty( TextLabel::Property::TEXT, std::string(APPLICATION_TITLE_FOLD) ); mEffectChangeButton.SetUnselectedImage( EFFECT_FOLD_IMAGE ); mEffectChangeButton.SetSelectedImage( EFFECT_FOLD_IMAGE_SELECTED ); } else { mCurrentEffect = mCubeWaveEffect; mTitle.SetProperty( TextLabel::Property::TEXT, std::string(APPLICATION_TITLE_WAVE) ); mEffectChangeButton.SetUnselectedImage( EFFECT_WAVE_IMAGE ); mEffectChangeButton.SetSelectedImage( EFFECT_WAVE_IMAGE_SELECTED ); } mContent.Add( mCurrentEffect ); // Set the current image to cube transition effect // only need to set at beginning or change from another effect mCurrentEffect.SetCurrentImage( mCurrentImage ); return true; }
void CubeTransitionApp::GoToNextImage() { mNextImage = LoadStageFillingImage( IMAGES[ mIndex ] ); mCurrentEffect.SetTargetImage( mNextImage ); if( mNextImage.GetLoadingState() == ResourceLoadingSucceeded ) { mIsImageLoading = false; OnImageLoaded( mNextImage ); } else { mIsImageLoading = true; mNextImage.LoadingFinishedSignal().Connect( this, &CubeTransitionApp::OnImageLoaded ); } }
// signal handler, called when the pan gesture is detected void CubeTransitionApp::OnPanGesture( Actor actor, const PanGesture& gesture ) { // does not response when the transition has not finished if( mIsImageLoading || mCubeWaveEffect.IsTransitioning() || mCubeCrossEffect.IsTransitioning() || mCubeFoldEffect.IsTransitioning() || mSlideshow ) { return; } if( gesture.state == Gesture::Continuing ) { if( gesture.displacement.x < 0) { mIndex = (mIndex + 1)%NUM_IMAGES; } else { mIndex = (mIndex + NUM_IMAGES -1)%NUM_IMAGES; } mPanPosition = gesture.position; mPanDisplacement = gesture.displacement; GoToNextImage(); } }
void CubeTransitionApp::OnImageLoaded(ResourceImage image) { mIsImageLoading = false; mCurrentEffect.StartTransition( mPanPosition, mPanDisplacement ); mCurrentImage = mNextImage; }
void CubeTransitionApp::OnInit( Application& application ) { Stage::GetCurrent().KeyEventSignal().Connect(this, &CubeTransitionApp::OnKeyEvent); // Creates a default view with a default tool bar, the view is added to the stage. mContent = DemoHelper::CreateView( application, mView, mToolBar, "", TOOLBAR_IMAGE, "" ); mContent.SetBehavior( Layer::LAYER_3D ); // Add an effect-changing button on the right of the tool bar. mEffectChangeButton = Toolkit::PushButton::New(); mEffectChangeButton.SetUnselectedImage( EFFECT_WAVE_IMAGE ); mEffectChangeButton.SetSelectedImage( EFFECT_WAVE_IMAGE_SELECTED ); mEffectChangeButton.ClickedSignal().Connect( this, &CubeTransitionApp::OnEffectButtonClicked ); mToolBar.AddControl( mEffectChangeButton, DemoHelper::DEFAULT_VIEW_STYLE.mToolBarButtonPercentage, Toolkit::Alignment::HorizontalRight, DemoHelper::DEFAULT_MODE_SWITCH_PADDING ); // Add title to the tool bar. mTitle = DemoHelper::CreateToolBarLabel( APPLICATION_TITLE_WAVE ); mToolBar.AddControl( mTitle, DemoHelper::DEFAULT_VIEW_STYLE.mToolBarTitlePercentage, Toolkit::Alignment::HorizontalCenter ); //Add an slideshow icon on the right of the title mSlideshowButton = Toolkit::PushButton::New(); mSlideshowButton.SetUnselectedImage( SLIDE_SHOW_START_ICON ); mSlideshowButton.SetSelectedImage( SLIDE_SHOW_START_ICON_SELECTED ); mSlideshowButton.ClickedSignal().Connect( this, &CubeTransitionApp::OnSildeshowButtonClicked ); mToolBar.AddControl( mSlideshowButton, DemoHelper::DEFAULT_VIEW_STYLE.mToolBarButtonPercentage, Toolkit::Alignment::HorizontalCenter, DemoHelper::DEFAULT_PLAY_PADDING ); // Set size to stage size to avoid seeing a black border on transition mViewSize = Stage::GetCurrent().GetSize(); // show the first image mCurrentImage = LoadStageFillingImage( IMAGES[mIndex] ); //use small cubes mCubeWaveEffect = Toolkit::CubeTransitionWaveEffect::New( NUM_ROWS_WAVE, NUM_COLUMNS_WAVE ); mCubeWaveEffect.SetTransitionDuration( ANIMATION_DURATION_WAVE ); mCubeWaveEffect.SetCubeDisplacement( CUBE_DISPLACEMENT_WAVE ); mCubeWaveEffect.TransitionCompletedSignal().Connect(this, &CubeTransitionApp::OnTransitionCompleted); mCubeWaveEffect.SetSize( mViewSize ); mCubeWaveEffect.SetPositionInheritanceMode( USE_PARENT_POSITION ); mCubeWaveEffect.SetCurrentImage( mCurrentImage ); // use big cubes mCubeCrossEffect = Toolkit::CubeTransitionCrossEffect::New(NUM_ROWS_CROSS, NUM_COLUMNS_CROSS ); mCubeCrossEffect.SetTransitionDuration( ANIMATION_DURATION_CROSS ); mCubeCrossEffect.SetCubeDisplacement( CUBE_DISPLACEMENT_CROSS ); mCubeCrossEffect.TransitionCompletedSignal().Connect(this, &CubeTransitionApp::OnTransitionCompleted); mCubeCrossEffect.SetSize( mViewSize ); mCubeCrossEffect.SetPositionInheritanceMode( USE_PARENT_POSITION ); mCubeCrossEffect.SetCurrentImage( mCurrentImage ); mCubeFoldEffect = Toolkit::CubeTransitionFoldEffect::New( NUM_ROWS_FOLD, NUM_COLUMNS_FOLD ); mCubeFoldEffect.SetTransitionDuration( ANIMATION_DURATION_FOLD ); mCubeFoldEffect.TransitionCompletedSignal().Connect(this, &CubeTransitionApp::OnTransitionCompleted); mCubeFoldEffect.SetSize( mViewSize ); mCubeFoldEffect.SetPositionInheritanceMode( USE_PARENT_POSITION ); mCubeFoldEffect.SetCurrentImage( mCurrentImage ); mViewTimer = Timer::New( VIEWINGTIME ); mViewTimer.TickSignal().Connect( this, &CubeTransitionApp::OnTimerTick ); mCurrentEffect = mCubeWaveEffect; mContent.Add( mCurrentEffect ); // use pan gesture to detect the cursor or finger movement mPanGestureDetector = PanGestureDetector::New(); mPanGestureDetector.DetectedSignal().Connect( this, &CubeTransitionApp::OnPanGesture ); mPanGestureDetector.Attach( mContent ); }