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 );
}
Ejemplo n.º 2
0
  void Create( Application& application )
  {
    // Setup precalculations for button size and start positions.
    Toolkit::PushButton button;
    int index = 0;
    Vector2 stageSize = Stage::GetCurrent().GetSize();
    float buttonSize = ( stageSize.x - ( BUTTON_GAP * ( BUTTON_COLUMNS + 1 ) ) ) / BUTTON_COLUMNS;
    float yStart = ( stageSize.y - ( ( buttonSize * BUTTON_ROWS ) + ( BUTTON_GAP * ( BUTTON_ROWS - 1 ) ) ) ) / 2.0f;

    // Create a grid of buttons.
    for( int y = 0; y < BUTTON_ROWS; ++y )
    {
      for( int x = 0; x < BUTTON_COLUMNS; ++x )
      {
        // Create a button and position it.
        button = Toolkit::PushButton::New();
        button.SetParentOrigin( ParentOrigin::TOP_LEFT );
        button.SetAnchorPoint( AnchorPoint::TOP_LEFT );
        button.SetPosition( Vector3( BUTTON_GAP + ( x * ( buttonSize + BUTTON_GAP ) ), yStart + ( y * ( buttonSize + BUTTON_GAP ) ), 0.0f ) );
        button.SetSize( Vector3( buttonSize, buttonSize, 0) );
        button.SetSelectedImage( Dali::ResourceImage::New( PUSHBUTTON_PRESS_IMAGE ) );
        button.SetButtonImage( Dali::ResourceImage::New( PUSHBUTTON_BUTTON_IMAGE ) );

        // Label the button with a unique value.
        std::stringstream label;
        label << index;
        button.SetLabel( label.str() );

        // Register our custom property, and use it to store a unique number.
        // Store the index to the property so we can look it up later.
        // Note: This is much faster than looking the property up by name and should always be used if possible.
        // As all our control types are the same (PushButtons) the indecies to our unique property is the same for each one.
        Property::Value tag = ( float )index;
        mTagPropertyIndex = button.RegisterProperty( TAG_PROPERTY_NAME, tag );

        // Hook a callback when the button is clicked.
        button.ClickedSignal().Connect( this, &PropertyButtonsController::OnButtonClicked );

        // Add the button to the stage.
        Stage::GetCurrent().Add( button );
        index++;
      }
    }

    // Create the last selected button text view.
    mTagText = Toolkit::TextLabel::New( "None selected" );
    mTagText.SetParentOrigin( ParentOrigin::BOTTOM_CENTER );
    mTagText.SetAnchorPoint( AnchorPoint::BOTTOM_CENTER );
    mTagText.SetPosition( Vector3( 0.0f, -30.0f, 0.0f ) );
    Stage::GetCurrent().Add( mTagText );
  }
void EffectsViewApp::OnAppInitialize( Application& application )
{
  // The Init signal is received once (only) during the Application lifetime

  Stage stage = Stage::GetCurrent();
  stage.KeyEventSignal().Connect(this, &EffectsViewApp::OnKeyEvent);
  stage.SetBackgroundColor( Color::WHITE );

  mStageSize = stage.GetSize();

  // Creates a default view with a default tool bar.
  // The view is added to the stage.
  mContents = DemoHelper::CreateView( application, mView, mToolBar, "", TOOLBAR_IMAGE, "" );

  // Creates view change button.
  Toolkit::PushButton viewButton = Toolkit::PushButton::New();
  viewButton.SetUnselectedImage( VIEW_SWAP_IMAGE );
  viewButton.SetSelectedImage( VIEW_SWAP_SELECTED_IMAGE );
  // Connects the view change button clicked signal to the OnView method.
  viewButton.ClickedSignal().Connect( this, &EffectsViewApp::ChangeEffectSize );
  mToolBar.AddControl( viewButton, DemoHelper::DEFAULT_VIEW_STYLE.mToolBarButtonPercentage, Toolkit::Alignment::HorizontalRight, DemoHelper::DEFAULT_MODE_SWITCH_PADDING  );

  Vector2 effectsViewSize( mStageSize.width, mStageSize.height * 0.25f );
  mDropShadowView = CreateEffectsView( EffectsView::DROP_SHADOW, effectsViewSize, mEffectSize );
  mDropShadowView.SetParentOrigin( ParentOrigin::CENTER );
  mDropShadowView.SetAnchorPoint( AnchorPoint::BOTTOM_CENTER );
  mDropShadowView.SetZ( -mStageSize.height * 0.1f );
  mContents.Add( mDropShadowView );

  mEmbossView = CreateEffectsView( EffectsView::EMBOSS, effectsViewSize, mEffectSize );
  mEmbossView.SetParentOrigin( ParentOrigin::CENTER );
  mEmbossView.SetAnchorPoint( AnchorPoint::TOP_CENTER );
  mEmbossView.SetZ( mStageSize.height * 0.1f );
  mContents.Add( mEmbossView );

  SetTitle( mEffectSize );
}
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 );
}
Ejemplo n.º 5
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
  }