Пример #1
0
void Application::ReplaceWindow(PositionSize windowPosition, const std::string& name)
{
  Dali::Window newWindow = Dali::Window::New( windowPosition, name, mWindowMode == Dali::Application::TRANSPARENT );
  Window& windowImpl = GetImplementation(newWindow);
  windowImpl.SetAdaptor(*mAdaptor);
  newWindow.ShowIndicator(Dali::Window::INVISIBLE);
  Dali::RenderSurface* renderSurface = windowImpl.GetSurface();

  Any nativeWindow = newWindow.GetNativeHandle();
  Internal::Adaptor::Adaptor::GetImplementation( *mAdaptor ).ReplaceSurface(nativeWindow, *renderSurface);
  mWindow = newWindow;
}
Пример #2
0
  /**
   * 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
  }