// signal handler, called when the pan gesture is detected void DissolveEffectApp::OnPanGesture( Actor actor, const PanGesture& gesture ) { // does not response when the animation has not finished if( mIsTransiting || 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; } mNextImage = CreateStageFillingImageView( IMAGES[ mIndex ] ); mNextImage.SetParentOrigin( ParentOrigin::CENTER ); mNextImage.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS ); mNextImage.SetSizeScalePolicy( SizeScalePolicy::FIT_WITH_ASPECT_RATIO ); mNextImage.SetZ(INITIAL_DEPTH); mParent.Add( mNextImage ); Vector2 size = Vector2( mCurrentImage.GetCurrentSize() ); StartTransition( gesture.position / size, gesture.displacement * Vector2(1.0, size.x/size.y)); } }
void DissolveEffectApp::OnInit( Application& application ) { Stage::GetCurrent().KeyEventSignal().Connect(this, &DissolveEffectApp::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, "" ); // Add an effect-changing button on the right of the tool bar. mEffectChangeButton = Toolkit::PushButton::New(); mEffectChangeButton.SetProperty( Toolkit::Button::Property::UNSELECTED_STATE_IMAGE, EFFECT_HIGHP_IMAGE ); mEffectChangeButton.SetProperty( Toolkit::Button::Property::SELECTED_STATE_IMAGE, EFFECT_HIGHP_IMAGE_SELECTED ); mEffectChangeButton.ClickedSignal().Connect( this, &DissolveEffectApp::OnEffectButtonClicked ); mToolBar.AddControl( mEffectChangeButton, DemoHelper::DEFAULT_VIEW_STYLE.mToolBarButtonPercentage, Toolkit::Alignment::HorizontalRight, DemoHelper::DEFAULT_MODE_SWITCH_PADDING ); // Add title to the tool bar. mTitleActor = DemoHelper::CreateToolBarLabel( APPLICATION_TITLE_HIGHP ); mToolBar.AddControl( mTitleActor, DemoHelper::DEFAULT_VIEW_STYLE.mToolBarTitlePercentage, Toolkit::Alignment::HorizontalCenter ); // Add an slide-show button on the right of the title mPlayStopButton = Toolkit::PushButton::New(); mPlayStopButton.SetProperty( Toolkit::Button::Property::UNSELECTED_STATE_IMAGE, PLAY_ICON ); mPlayStopButton.SetProperty( Toolkit::Button::Property::SELECTED_STATE_IMAGE, PLAY_ICON_SELECTED ); mPlayStopButton.ClickedSignal().Connect( this, &DissolveEffectApp::OnSildeshowButtonClicked ); mToolBar.AddControl( mPlayStopButton, DemoHelper::DEFAULT_VIEW_STYLE.mToolBarButtonPercentage, Toolkit::Alignment::HorizontalCenter, DemoHelper::DEFAULT_PLAY_PADDING ); // use pan gesture to detect the cursor or finger movement mPanGestureDetector = PanGestureDetector::New(); mPanGestureDetector.DetectedSignal().Connect( this, &DissolveEffectApp::OnPanGesture ); mViewTimer = Timer::New( VIEWINGTIME ); mViewTimer.TickSignal().Connect( this, &DissolveEffectApp::OnTimerTick ); mTimerReady = true; // Set size to stage size to avoid seeing a black border on transition mParent = Actor::New(); mParent.SetSize( Stage::GetCurrent().GetSize() ); mParent.SetParentOrigin( ParentOrigin::CENTER ); mContent.Add( mParent ); // show the first image mCurrentImage = CreateStageFillingImageView( IMAGES[mIndex] ); mCurrentImage.SetParentOrigin( ParentOrigin::CENTER ); mCurrentImage.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS ); mCurrentImage.SetSizeScalePolicy( SizeScalePolicy::FIT_WITH_ASPECT_RATIO ); mParent.Add( mCurrentImage ); mPanGestureDetector.Attach( mCurrentImage ); mDissolveEffect = Dali::Toolkit::CreateDissolveEffect( mUseHighPrecision ); Property::Map emptyShaderMap; mEmptyEffect.Insert( "shader", emptyShaderMap ); }
bool DissolveEffectApp::OnTimerTick() { mTimerReady = true; if(mSlideshow) { mIndex = (mIndex + 1)%NUM_IMAGES; mNextImage = CreateStageFillingImageView( IMAGES[ mIndex ] ); mNextImage.SetParentOrigin( ParentOrigin::CENTER ); mNextImage.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS ); mNextImage.SetSizeScalePolicy( SizeScalePolicy::FIT_WITH_ASPECT_RATIO ); mNextImage.SetZ(INITIAL_DEPTH); mParent.Add( mNextImage ); switch( mCentralLineIndex%4 ) { case 0: { StartTransition(Vector2(1.0f,0.5f), Vector2(-1.0f, 0.0f)); break; } case 1: { StartTransition(Vector2(0.5f,0.0f), Vector2(0.0f, 1.0f)); break; } case 2: { StartTransition(Vector2(0.0f,0.5f), Vector2(1.0f, 0.0f)); break; } default: { StartTransition(Vector2(0.5f,1.0f), Vector2(0.0f, -1.0f)); break; } } mCentralLineIndex++; } return false; //return false to stop the timer }