/** * Invoked upon creation of application * @param[in] application The application instance */ void Create( Application& application ) { Stage::GetCurrent().KeyEventSignal().Connect(this, &ExampleController::OnKeyEvent); mStageSize = Stage::GetCurrent().GetSize(); // The Init signal is received once (only) during the Application lifetime // Hide the indicator bar application.GetWindow().ShowIndicator( Dali::Window::INVISIBLE ); // Creates a default view with a default tool bar. // The view is added to the stage. Toolkit::ToolBar toolBar; mContent = DemoHelper::CreateView( application, mView, toolBar, BACKGROUND_IMAGE, TOOLBAR_IMAGE, APPLICATION_TITLE ); mContent.SetLeaveRequired(true); mContent.TouchSignal().Connect( this, &ExampleController::OnTouched ); // Create magnifier (controlled by human touch) Layer overlay = Layer::New(); overlay.SetSensitive(false); overlay.SetParentOrigin( ParentOrigin::CENTER ); overlay.SetSize(mStageSize); Stage::GetCurrent().Add(overlay); mMagnifier = Toolkit::Magnifier::New(); mMagnifier.SetSourceActor( mView ); mMagnifier.SetSize( MAGNIFIER_SIZE * mStageSize.width ); // Size of magnifier is in relation to stage width mMagnifier.SetProperty( Toolkit::Magnifier::Property::MAGNIFICATION_FACTOR, MAGNIFICATION_FACTOR ); mMagnifier.SetScale(Vector3::ZERO); overlay.Add( mMagnifier ); // Apply constraint to animate the position of the magnifier. Constraint constraint = Constraint::New<Vector3>( mMagnifier, Actor::Property::POSITION, ConfinementConstraint(Vector3( 0.5f, 0.5f, 0.0f ), Vector2::ONE * MAGNIFIER_INDENT, Vector2::ONE * MAGNIFIER_INDENT) ); constraint.AddSource( LocalSource(Actor::Property::SIZE) ); constraint.AddSource( LocalSource(Actor::Property::PARENT_ORIGIN) ); constraint.AddSource( LocalSource(Actor::Property::ANCHOR_POINT) ); constraint.AddSource( ParentSource(Actor::Property::SIZE) ); constraint.SetRemoveAction(Constraint::Discard); constraint.Apply(); // Create bouncing magnifier automatically bounces around screen. mBouncingMagnifier = Toolkit::Magnifier::New(); mBouncingMagnifier.SetSourceActor( mView ); mBouncingMagnifier.SetSize( MAGNIFIER_SIZE * mStageSize.width ); // Size of magnifier is in relation to stage width mBouncingMagnifier.SetProperty( Toolkit::Magnifier::Property::MAGNIFICATION_FACTOR, MAGNIFICATION_FACTOR ); overlay.Add( mBouncingMagnifier ); mAnimationTimeProperty = mBouncingMagnifier.RegisterProperty("animationTime", 0.0f); ContinueAnimation(); // Apply constraint to animate the position of the magnifier. constraint = Constraint::New<Vector3>( mBouncingMagnifier, Actor::Property::POSITION, MagnifierPathConstraint(mStageSize, mStageSize * 0.5f) ); constraint.AddSource( LocalSource(Actor::Property::SIZE) ); constraint.AddSource( LocalSource(mAnimationTimeProperty) ); constraint.Apply(); // Apply constraint to animate the source of the magnifier. constraint = Constraint::New<Vector3>( mBouncingMagnifier, Toolkit::Magnifier::Property::SOURCE_POSITION, MagnifierPathConstraint(mStageSize) ); constraint.AddSource( LocalSource(Actor::Property::SIZE) ); constraint.AddSource( LocalSource(mAnimationTimeProperty) ); constraint.Apply(); }
/** * This method gets called once the main loop of application is up and running */ void OnInit(Application& app) { // The Init signal is received once (only) during the Application lifetime Stage::GetCurrent().KeyEventSignal().Connect(this, &MotionStretchExampleApp::OnKeyEvent); // Creates a default view with a default tool bar. // The view is added to the stage. mContentLayer = DemoHelper::CreateView( mApplication, mView, mToolBar, BACKGROUND_IMAGE_PATH, TOOLBAR_IMAGE, APPLICATION_TITLE ); //Add an slideshow icon on the right of the title mActorEffectsButton = Toolkit::PushButton::New(); mActorEffectsButton.SetUnselectedImage( EFFECTS_OFF_ICON ); mActorEffectsButton.SetSelectedImage( EFFECTS_OFF_ICON_SELECTED ); mActorEffectsButton.ClickedSignal().Connect( this, &MotionStretchExampleApp::OnEffectButtonClicked ); mToolBar.AddControl( mActorEffectsButton, DemoHelper::DEFAULT_VIEW_STYLE.mToolBarButtonPercentage, Toolkit::Alignment::HorizontalCenter, DemoHelper::DEFAULT_PLAY_PADDING ); // Creates a mode button. // Create a effect toggle button. (right of toolbar) Toolkit::PushButton layoutButton = Toolkit::PushButton::New(); layoutButton.SetUnselectedImage( LAYOUT_IMAGE ); layoutButton.SetSelectedImage( LAYOUT_IMAGE_SELECTED ); layoutButton.ClickedSignal().Connect( this, &MotionStretchExampleApp::OnLayoutButtonClicked); layoutButton.SetLeaveRequired( true ); mToolBar.AddControl( layoutButton, DemoHelper::DEFAULT_VIEW_STYLE.mToolBarButtonPercentage, Toolkit::Alignment::HorizontalRight, DemoHelper::DEFAULT_MODE_SWITCH_PADDING ); // Input mTapGestureDetector = TapGestureDetector::New(); mTapGestureDetector.Attach( mContentLayer ); mTapGestureDetector.DetectedSignal().Connect( this, &MotionStretchExampleApp::OnTap ); // set initial orientation Dali::Window winHandle = app.GetWindow(); winHandle.AddAvailableOrientation( Dali::Window::PORTRAIT ); winHandle.AddAvailableOrientation( Dali::Window::LANDSCAPE ); winHandle.AddAvailableOrientation( Dali::Window::PORTRAIT_INVERSE ); winHandle.AddAvailableOrientation( Dali::Window::LANDSCAPE_INVERSE ); // winHandle.GetOrientation().ChangedSignal().Connect( this, &MotionStretchExampleApp::OnOrientationChanged ); unsigned int degrees = 0; Rotate( static_cast< DeviceOrientation >( degrees ) ); /////////////////////////////////////////////////////// // // Motion stretched actor // mMotionStretchImageView = ImageView::New( MOTION_STRETCH_ACTOR_IMAGE1 ); mMotionStretchImageView.SetParentOrigin( ParentOrigin::CENTER ); mMotionStretchImageView.SetAnchorPoint( AnchorPoint::CENTER ); mMotionStretchImageView.SetSize( MOTION_STRETCH_ACTOR_WIDTH, MOTION_STRETCH_ACTOR_HEIGHT ); mContentLayer.Add( mMotionStretchImageView ); // Create shader used for doing motion stretch mMotionStretchEffect = Toolkit::CreateMotionStretchEffect(); Toolkit::SetMotionStretchProperties( mMotionStretchImageView ); mMotionStretchImageView.SetProperty( Toolkit::ImageView::Property::IMAGE, mMotionStretchEffect ); }
/** * This method gets called once the main loop of application is up and running */ void OnInit(Application& app) { // The Init signal is received once (only) during the Application lifetime Stage::GetCurrent().KeyEventSignal().Connect(this, &MotionBlurExampleApp::OnKeyEvent); // Creates a default view with a default tool bar. // The view is added to the stage. mContentLayer = DemoHelper::CreateView( mApplication, mView, mToolBar, BACKGROUND_IMAGE_PATH, TOOLBAR_IMAGE, APPLICATION_TITLE ); //Add an effects icon on the right of the title mActorEffectsButton = Toolkit::PushButton::New(); mActorEffectsButton.SetUnselectedImage( EFFECTS_OFF_ICON ); mActorEffectsButton.SetSelectedImage( EFFECTS_OFF_ICON_SELECTED ); mActorEffectsButton.ClickedSignal().Connect( this, &MotionBlurExampleApp::OnEffectButtonClicked ); mToolBar.AddControl( mActorEffectsButton, DemoHelper::DEFAULT_VIEW_STYLE.mToolBarButtonPercentage, Toolkit::Alignment::HorizontalCenter, DemoHelper::DEFAULT_PLAY_PADDING ); // Creates a mode button. // Create a effect toggle button. (right of toolbar) Toolkit::PushButton layoutButton = Toolkit::PushButton::New(); layoutButton.SetUnselectedImage( LAYOUT_IMAGE ); layoutButton.SetSelectedImage( LAYOUT_IMAGE_SELECTED ); layoutButton.ClickedSignal().Connect( this, &MotionBlurExampleApp::OnLayoutButtonClicked); layoutButton.SetLeaveRequired( true ); mToolBar.AddControl( layoutButton, DemoHelper::DEFAULT_VIEW_STYLE.mToolBarButtonPercentage, Toolkit::Alignment::HorizontalRight, DemoHelper::DEFAULT_MODE_SWITCH_PADDING ); // Input mTapGestureDetector = TapGestureDetector::New(); mTapGestureDetector.Attach( mContentLayer ); mTapGestureDetector.DetectedSignal().Connect( this, &MotionBlurExampleApp::OnTap ); Dali::Window winHandle = app.GetWindow(); winHandle.AddAvailableOrientation( Dali::Window::PORTRAIT ); winHandle.AddAvailableOrientation( Dali::Window::LANDSCAPE ); winHandle.AddAvailableOrientation( Dali::Window::PORTRAIT_INVERSE ); winHandle.AddAvailableOrientation( Dali::Window::LANDSCAPE_INVERSE ); // set initial orientation unsigned int degrees = 0; Rotate( static_cast< DeviceOrientation >( degrees ) ); /////////////////////////////////////////////////////// // // Motion blurred actor // // Scale down actor to fit on very low resolution screens with space to interact: Size stageSize = Stage::GetCurrent().GetSize(); mMotionBlurActorSize = Size( std::min( stageSize.x * 0.3f, MOTION_BLUR_ACTOR_WIDTH ), std::min( stageSize.y * 0.3f, MOTION_BLUR_ACTOR_HEIGHT ) ); mMotionBlurActorSize = Size( std::min( mMotionBlurActorSize.x, mMotionBlurActorSize.y ), std::min( mMotionBlurActorSize.x, mMotionBlurActorSize.y ) ); mMotionBlurEffect = CreateMotionBlurEffect(); mMotionBlurImageView = ImageView::New(); SetImageFittedInBox( mMotionBlurImageView, mMotionBlurEffect, MOTION_BLUR_ACTOR_IMAGE1, mMotionBlurActorSize.x, mMotionBlurActorSize.y ); mMotionBlurImageView.SetParentOrigin( ParentOrigin::CENTER ); mMotionBlurImageView.SetSize(mMotionBlurActorSize.x, mMotionBlurActorSize.y); mContentLayer.Add( mMotionBlurImageView ); // Create shader used for doing motion blur mMotionBlurEffect = CreateMotionBlurEffect(); // set actor shader to the blur one Toolkit::SetMotionBlurProperties( mMotionBlurImageView, MOTION_BLUR_NUM_SAMPLES ); #ifdef MULTIPLE_MOTION_BLURRED_ACTORS /////////////////////////////////////////////////////// // // Motion blurred actor 2 // mMotionBlurImageView2 = ImageView::New(image); mMotionBlurImageView2.SetParentOrigin( ParentOrigin::CENTER ); mMotionBlurImageView2.SetSize(mMotionBlurActorSize.x, mMotionBlurActorSize.y); mMotionBlurImageView2.SetPosition(mMotionBlurActorSize.x * 1.1f, 0.0f); mMotionBlurImageView.Add( mMotionBlurImageView2 ); // set actor shader to the blur one Toolkit::SetMotionBlurProperties( mMotionBlurImageView2, MOTION_BLUR_NUM_SAMPLES ); mMotionBlurImageView2.SetProperty( Toolkit::ImageView::Property::IMAGE, mMotionBlurEffect ); /////////////////////////////////////////////////////// // // Motion blurred actor 3 // mMotionBlurImageView3 = ImageView::New(image); mMotionBlurImageView3.SetParentOrigin( ParentOrigin::CENTER ); mMotionBlurImageView3.SetSize(mMotionBlurActorSize.x, mMotionBlurActorSize.y); mMotionBlurImageView3.SetPosition(-mMotionBlurActorSize.x * 1.1f, 0.0f); mMotionBlurImageView.Add( mMotionBlurImageView3 ); // set actor shader to the blur one Toolkit::SetMotionBlurProperties( mMotionBlurImageView3, MOTION_BLUR_NUM_SAMPLES ); mMotionBlurImageView3.SetProperty( Toolkit::ImageView::Property::IMAGE, mMotionBlurEffect ); /////////////////////////////////////////////////////// // // Motion blurred actor 4 // mMotionBlurImageView4 = ImageView::New(image); mMotionBlurImageView4.SetParentOrigin( ParentOrigin::CENTER ); mMotionBlurImageView4.SetSize(mMotionBlurActorSize.x, mMotionBlurActorSize.y); mMotionBlurImageView4.SetPosition(0.0f, mMotionBlurActorSize.y * 1.1f); mMotionBlurImageView.Add( mMotionBlurImageView4 ); // set actor shader to the blur one Toolkit::SetMotionBlurProperties( mMotionBlurImageView4, MOTION_BLUR_NUM_SAMPLES ); mMotionBlurImageView4.SetProperty( Toolkit::ImageView::Property::IMAGE, mMotionBlurEffect ); /////////////////////////////////////////////////////// // // Motion blurred actor 5 // mMotionBlurImageView5 = ImageView::New(image); mMotionBlurImageView5.SetParentOrigin( ParentOrigin::CENTER ); mMotionBlurImageView5.SetSize(mMotionBlurActorSize.x, mMotionBlurActorSize.y); mMotionBlurImageView5.SetPosition(0.0f, -mMotionBlurActorSize.y * 1.1f); mMotionBlurImageView.Add( mMotionBlurImageView5 ); // set actor shader to the blur one Toolkit::SetMotionBlurProperties( mMotionBlurImageView5, MOTION_BLUR_NUM_SAMPLES ); mMotionBlurImageView5.SetProperty( Toolkit::ImageView::Property::IMAGE, mMotionBlurEffect ); #endif //#ifdef MULTIPLE_MOTION_BLURRED_ACTORS }