X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=examples%2Fdissolve-effect%2Fdissolve-effect-example.cpp;h=bcc7e570f8d0e21b2556b0aa8f935ad6dae7f006;hb=1b19fd140ff139b5854a1a62447faf31b175d8f6;hp=8d0f90f49cd21608930f15e345c2d407eaca89d1;hpb=f2a8bae920f84890d8c6585152917eb4b832fe94;p=platform%2Fcore%2Fuifw%2Fdali-demo.git diff --git a/examples/dissolve-effect/dissolve-effect-example.cpp b/examples/dissolve-effect/dissolve-effect-example.cpp index 8d0f90f..bcc7e57 100644 --- a/examples/dissolve-effect/dissolve-effect-example.cpp +++ b/examples/dissolve-effect/dissolve-effect-example.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Samsung Electronics Co., Ltd. + * Copyright (c) 2020 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -21,73 +21,85 @@ // INTERNAL INCLUDES #include "shared/view.h" -#include #include +#include +#include +#include using namespace Dali; +using Dali::Toolkit::TextLabel; + // LOCAL STUFF namespace { - -const char * const TOOLBAR_IMAGE( DALI_IMAGE_DIR "top-bar.png" ); -const char * const APPLICATION_TITLE_HIGHP( "Dissolve Effect(highp)" ); -const char * const APPLICATION_TITLE_MEDIUMP( "Dissolve Effect(mediump)" ); -const char * const EFFECT_HIGHP_IMAGE( DALI_IMAGE_DIR "icon-highp.png" ); -const char * const EFFECT_MEDIUMP_IMAGE( DALI_IMAGE_DIR "icon-mediump.png" ); -const char * const PLAY_ICON( DALI_IMAGE_DIR "icon-play.png" ); -const char * const STOP_ICON( DALI_IMAGE_DIR "icon-stop.png" ); +const char* const TOOLBAR_IMAGE(DEMO_IMAGE_DIR "top-bar.png"); +const char* const APPLICATION_TITLE_HIGHP("Dissolve Effect(highp)"); +const char* const APPLICATION_TITLE_MEDIUMP("Dissolve Effect(mediump)"); +const char* const EFFECT_HIGHP_IMAGE(DEMO_IMAGE_DIR "icon-highp.png"); +const char* const EFFECT_HIGHP_IMAGE_SELECTED(DEMO_IMAGE_DIR "icon-highp-selected.png"); +const char* const EFFECT_MEDIUMP_IMAGE(DEMO_IMAGE_DIR "icon-mediump.png"); +const char* const EFFECT_MEDIUMP_IMAGE_SELECTED(DEMO_IMAGE_DIR "icon-mediump-selected.png"); +const char* const PLAY_ICON(DEMO_IMAGE_DIR "icon-play.png"); +const char* const PLAY_ICON_SELECTED(DEMO_IMAGE_DIR "icon-play-selected.png"); +const char* const STOP_ICON(DEMO_IMAGE_DIR "icon-stop.png"); +const char* const STOP_ICON_SELECTED(DEMO_IMAGE_DIR "icon-stop-selected.png"); const char* IMAGES[] = -{ - DALI_IMAGE_DIR "gallery-large-1.jpg", - DALI_IMAGE_DIR "gallery-large-2.jpg", - DALI_IMAGE_DIR "gallery-large-3.jpg", - DALI_IMAGE_DIR "gallery-large-4.jpg", - DALI_IMAGE_DIR "gallery-large-5.jpg", - DALI_IMAGE_DIR "gallery-large-6.jpg", - DALI_IMAGE_DIR "gallery-large-7.jpg", - DALI_IMAGE_DIR "gallery-large-8.jpg", - DALI_IMAGE_DIR "gallery-large-9.jpg", - DALI_IMAGE_DIR "gallery-large-10.jpg", - DALI_IMAGE_DIR "gallery-large-11.jpg", - DALI_IMAGE_DIR "gallery-large-12.jpg", - DALI_IMAGE_DIR "gallery-large-13.jpg", - DALI_IMAGE_DIR "gallery-large-14.jpg", - DALI_IMAGE_DIR "gallery-large-15.jpg", - DALI_IMAGE_DIR "gallery-large-16.jpg", - DALI_IMAGE_DIR "gallery-large-17.jpg", - DALI_IMAGE_DIR "gallery-large-18.jpg", - DALI_IMAGE_DIR "gallery-large-19.jpg", - DALI_IMAGE_DIR "gallery-large-20.jpg", - DALI_IMAGE_DIR "gallery-large-21.jpg", + { + DEMO_IMAGE_DIR "gallery-large-1.jpg", + DEMO_IMAGE_DIR "gallery-large-2.jpg", + DEMO_IMAGE_DIR "gallery-large-3.jpg", + DEMO_IMAGE_DIR "gallery-large-4.jpg", + DEMO_IMAGE_DIR "gallery-large-5.jpg", + DEMO_IMAGE_DIR "gallery-large-6.jpg", + DEMO_IMAGE_DIR "gallery-large-7.jpg", + DEMO_IMAGE_DIR "gallery-large-8.jpg", + DEMO_IMAGE_DIR "gallery-large-9.jpg", + DEMO_IMAGE_DIR "gallery-large-10.jpg", + DEMO_IMAGE_DIR "gallery-large-11.jpg", + DEMO_IMAGE_DIR "gallery-large-12.jpg", + DEMO_IMAGE_DIR "gallery-large-13.jpg", + DEMO_IMAGE_DIR "gallery-large-14.jpg", + DEMO_IMAGE_DIR "gallery-large-15.jpg", + DEMO_IMAGE_DIR "gallery-large-16.jpg", + DEMO_IMAGE_DIR "gallery-large-17.jpg", + DEMO_IMAGE_DIR "gallery-large-18.jpg", + DEMO_IMAGE_DIR "gallery-large-19.jpg", + DEMO_IMAGE_DIR "gallery-large-20.jpg", + DEMO_IMAGE_DIR "gallery-large-21.jpg", }; -const int NUM_IMAGES( sizeof(IMAGES) / sizeof(IMAGES[0]) ); +const int NUM_IMAGES(sizeof(IMAGES) / sizeof(IMAGES[0])); // The duration of the current image staying on screen when slideshow is on const int VIEWINGTIME = 2000; // 2 seconds const float TRANSITION_DURATION = 2.5f; //2.5 second -const float INITIAL_DEPTH = -10.0f; +const float INITIAL_DEPTH = 10.0f; /** - * @brief Load an image, scaled-down to no more than the stage dimensions. + * @brief Create an image view with an image which would be scaled-down to no more than the window dimensions. * - * Uses image scaling mode ImageAttributes::ScaleToFill to resize the image at - * load time to cover the entire stage with pixels with no borders, - * and filter mode ImageAttributes::BoxThenLinear to sample the image with - * maximum quality. + * Uses image scaling mode SCALE_TO_FILL to resize the image at + * load time to cover the entire window with pixels with no borders, + * and filter mode BOX_THEN_LINEAR to sample the image with maximum quality. */ -ResourceImage LoadStageFillingImage( const char * const imagePath ) +Toolkit::ImageView CreateWindowFillingImageView(const Vector2& windowSize, const char* const imagePath) { - Size stageSize = Stage::GetCurrent().GetSize(); - ImageAttributes attributes; - attributes.SetSize( stageSize.x, stageSize.y ); - attributes.SetFilterMode( ImageAttributes::BoxThenLinear ); - attributes.SetScalingMode( ImageAttributes::ScaleToFill ); - return ResourceImage::New( imagePath, attributes ); + Toolkit::ImageView imageView = Toolkit::ImageView::New(); + Property::Map map; + map[Toolkit::Visual::Property::TYPE] = Toolkit::Visual::IMAGE; + map[Toolkit::ImageVisual::Property::URL] = imagePath; + map[Toolkit::ImageVisual::Property::DESIRED_WIDTH] = windowSize.x; + map[Toolkit::ImageVisual::Property::DESIRED_HEIGHT] = windowSize.y; + map[Toolkit::ImageVisual::Property::FITTING_MODE] = FittingMode::SCALE_TO_FILL; + map[Toolkit::ImageVisual::Property::SAMPLING_MODE] = SamplingMode::BOX_THEN_LINEAR; + map[Toolkit::ImageVisual::Property::SYNCHRONOUS_LOADING] = true; + imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, map); + + return imageView; } } // namespace @@ -95,27 +107,25 @@ ResourceImage LoadStageFillingImage( const char * const imagePath ) class DissolveEffectApp : public ConnectionTracker { public: - /** * Constructor * @param application class, stored as reference */ - DissolveEffectApp( Application& application ); + DissolveEffectApp(Application& application); ~DissolveEffectApp(); private: - /** * This method gets called once the main loop of application is up and running */ - void OnInit( Application& application ); + void OnInit(Application& application); /** * PanGesture callback. This method gets called when the pan gesture is detected. * @param[in] actor The actor receiving the pan gesture. * @param[in] gesture The detected pan gesture. */ - void OnPanGesture( Actor actor, const PanGesture& gesture ); + void OnPanGesture(Actor actor, const PanGesture& gesture); /** * Set up the animations for transition @@ -128,13 +138,13 @@ private: * Change the precision of the effect shader when the effect button is clicked * @param[in] button The handle of the clicked button */ - bool OnEffectButtonClicked( Toolkit::Button button ); + bool OnEffectButtonClicked(Toolkit::Button button); /** * Callback function of slideshow button * Start or stop the automatical image display when the slideshow button is clicked * @param[in] button The handle of the clicked button */ - bool OnSildeshowButtonClicked( Toolkit::Button button ); + bool OnSildeshowButtonClicked(Toolkit::Button button); /** * Callback function of cube transition completed signal * @param[in] effect The cube effect used for the transition @@ -153,49 +163,45 @@ private: void OnKeyEvent(const KeyEvent& event); private: - Application& mApplication; - Toolkit::View mView; - Toolkit::ToolBar mToolBar; - Layer mContent; - Toolkit::TextView mTitleActor; - Actor mParent; - - ImageActor mCurrentImage; - ImageActor mNextImage; - unsigned int mIndex; - - Toolkit::DissolveEffect mCurrentImageEffect; - Toolkit::DissolveEffect mNextImageEffect; - bool mUseHighPrecision; - Animation mAnimation; - - PanGestureDetector mPanGestureDetector; - bool mIsTransiting; - - bool mSlideshow; - Timer mViewTimer; - bool mTimerReady; - unsigned int mCentralLineIndex; - - Image mIconPlay; - Image mIconStop; - Toolkit::PushButton mPlayStopButton; - - Image mIconHighP; - Image mIconMediumP; - Toolkit::PushButton mEffectChangeButton; + Application& mApplication; + Toolkit::Control mView; + Toolkit::ToolBar mToolBar; + Layer mContent; + Toolkit::TextLabel mTitleActor; + Actor mParent; + + Toolkit::ImageView mCurrentImage; + Toolkit::ImageView mNextImage; + unsigned int mIndex; + + Property::Map mDissolveEffect; + Property::Map mEmptyEffect; + + bool mUseHighPrecision; + Animation mAnimation; + + PanGestureDetector mPanGestureDetector; + bool mIsTransiting; + + bool mSlideshow; + Timer mViewTimer; + bool mTimerReady; + unsigned int mCentralLineIndex; + + Toolkit::PushButton mPlayStopButton; + Toolkit::PushButton mEffectChangeButton; }; -DissolveEffectApp::DissolveEffectApp( Application& application ) -: mApplication( application ), - mIndex( 0 ), +DissolveEffectApp::DissolveEffectApp(Application& application) +: mApplication(application), + mIndex(0), mUseHighPrecision(true), - mIsTransiting( false ), - mSlideshow( false ), - mTimerReady( false ), - mCentralLineIndex( 0 ) + mIsTransiting(false), + mSlideshow(false), + mTimerReady(false), + mCentralLineIndex(0) { - mApplication.InitSignal().Connect( this, &DissolveEffectApp::OnInit ); + mApplication.InitSignal().Connect(this, &DissolveEffectApp::OnInit); } DissolveEffectApp::~DissolveEffectApp() @@ -203,94 +209,90 @@ DissolveEffectApp::~DissolveEffectApp() //Nothing to do } -void DissolveEffectApp::OnInit( Application& application ) +void DissolveEffectApp::OnInit(Application& application) { - Stage::GetCurrent().KeyEventSignal().Connect(this, &DissolveEffectApp::OnKeyEvent); + auto window = application.GetWindow(); + Vector2 windowSize = window.GetSize(); + window.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, "" ); + // Creates a default view with a default tool bar, the view is added to the window. + mContent = DemoHelper::CreateView(application, mView, mToolBar, "", TOOLBAR_IMAGE, ""); // Add an effect-changing button on the right of the tool bar. - mIconHighP = ResourceImage::New( EFFECT_HIGHP_IMAGE ); - mIconMediumP = ResourceImage::New( EFFECT_MEDIUMP_IMAGE ); mEffectChangeButton = Toolkit::PushButton::New(); - mEffectChangeButton.SetBackgroundImage(mIconHighP); - mEffectChangeButton.ClickedSignal().Connect( this, &DissolveEffectApp::OnEffectButtonClicked ); - mToolBar.AddControl( mEffectChangeButton, DemoHelper::DEFAULT_VIEW_STYLE.mToolBarButtonPercentage, Toolkit::Alignment::HorizontalRight, DemoHelper::DEFAULT_MODE_SWITCH_PADDING ); + mEffectChangeButton.SetProperty(Toolkit::Button::Property::UNSELECTED_BACKGROUND_VISUAL, EFFECT_HIGHP_IMAGE); + mEffectChangeButton.SetProperty(Toolkit::Button::Property::SELECTED_BACKGROUND_VISUAL, EFFECT_HIGHP_IMAGE_SELECTED); + mEffectChangeButton.ClickedSignal().Connect(this, &DissolveEffectApp::OnEffectButtonClicked); + mToolBar.AddControl(mEffectChangeButton, DemoHelper::DEFAULT_VIEW_STYLE.mToolBarButtonPercentage, Toolkit::Alignment::HORIZONTAL_RIGHT, DemoHelper::DEFAULT_MODE_SWITCH_PADDING); // Add title to the tool bar. - mTitleActor = Toolkit::TextView::New(); - mTitleActor.SetText( APPLICATION_TITLE_HIGHP ); - mTitleActor.SetStyleToCurrentText(DemoHelper::GetDefaultTextStyle()); - mToolBar.AddControl( mTitleActor, DemoHelper::DEFAULT_VIEW_STYLE.mToolBarTitlePercentage, Toolkit::Alignment::HorizontalCenter ); + mTitleActor = DemoHelper::CreateToolBarLabel(APPLICATION_TITLE_HIGHP); + mToolBar.AddControl(mTitleActor, DemoHelper::DEFAULT_VIEW_STYLE.mToolBarTitlePercentage, Toolkit::Alignment::HORIZONTAL_CENTER); // Add an slide-show button on the right of the title - mIconPlay = ResourceImage::New( PLAY_ICON ); - mIconStop = ResourceImage::New( STOP_ICON ); mPlayStopButton = Toolkit::PushButton::New(); - mPlayStopButton.SetBackgroundImage( mIconPlay ); - mPlayStopButton.ClickedSignal().Connect( this, &DissolveEffectApp::OnSildeshowButtonClicked ); - mToolBar.AddControl( mPlayStopButton, DemoHelper::DEFAULT_VIEW_STYLE.mToolBarButtonPercentage, Toolkit::Alignment::HorizontalCenter, DemoHelper::DEFAULT_PLAY_PADDING ); + mPlayStopButton.SetProperty(Toolkit::Button::Property::UNSELECTED_BACKGROUND_VISUAL, PLAY_ICON); + mPlayStopButton.SetProperty(Toolkit::Button::Property::SELECTED_BACKGROUND_VISUAL, PLAY_ICON_SELECTED); + mPlayStopButton.ClickedSignal().Connect(this, &DissolveEffectApp::OnSildeshowButtonClicked); + mToolBar.AddControl(mPlayStopButton, DemoHelper::DEFAULT_VIEW_STYLE.mToolBarButtonPercentage, Toolkit::Alignment::HORIZONTAL_CENTER, DemoHelper::DEFAULT_PLAY_PADDING); // use pan gesture to detect the cursor or finger movement mPanGestureDetector = PanGestureDetector::New(); - mPanGestureDetector.DetectedSignal().Connect( this, &DissolveEffectApp::OnPanGesture ); - - // create the dissolve effect object - mCurrentImageEffect = Toolkit::DissolveEffect::New(mUseHighPrecision); - mNextImageEffect = Toolkit::DissolveEffect::New(mUseHighPrecision); + mPanGestureDetector.DetectedSignal().Connect(this, &DissolveEffectApp::OnPanGesture); - mViewTimer = Timer::New( VIEWINGTIME ); - mViewTimer.TickSignal().Connect( this, &DissolveEffectApp::OnTimerTick ); + 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 + // Set size to window size to avoid seeing a black border on transition mParent = Actor::New(); - mParent.SetSize( Stage::GetCurrent().GetSize() ); - mParent.SetPositionInheritanceMode( USE_PARENT_POSITION ); - mContent.Add( mParent ); + mParent.SetProperty(Actor::Property::SIZE, windowSize); + mParent.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER); + mContent.Add(mParent); // show the first image - mCurrentImage = ImageActor::New( LoadStageFillingImage( IMAGES[mIndex] ) ); - mCurrentImage.SetRelayoutEnabled( false ); - mCurrentImage.SetPositionInheritanceMode(USE_PARENT_POSITION_PLUS_LOCAL_POSITION); - mCurrentImage.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS ); - mCurrentImage.SetSizeScalePolicy( FIT_WITH_ASPECT_RATIO ); - mParent.Add( mCurrentImage ); - - mPanGestureDetector.Attach( mCurrentImage ); + mCurrentImage = CreateWindowFillingImageView(windowSize, IMAGES[mIndex]); + mCurrentImage.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER); + mCurrentImage.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS); + mCurrentImage.SetProperty(Actor::Property::SIZE_SCALE_POLICY, SizeScalePolicy::FIT_WITH_ASPECT_RATIO); + mParent.Add(mCurrentImage); + + mPanGestureDetector.Attach(mCurrentImage); + + mDissolveEffect = Dali::Toolkit::CreateDissolveEffect(mUseHighPrecision); + Property::Map emptyShaderMap; + mEmptyEffect.Insert("shader", emptyShaderMap); } // signal handler, called when the pan gesture is detected -void DissolveEffectApp::OnPanGesture( Actor actor, const PanGesture& gesture ) +void DissolveEffectApp::OnPanGesture(Actor actor, const PanGesture& gesture) { // does not response when the animation has not finished - if( mIsTransiting || mSlideshow ) + if(mIsTransiting || mSlideshow) { return; } - if( gesture.state == Gesture::Continuing ) + if(gesture.GetState() == GestureState::CONTINUING) { - if( gesture.displacement.x < 0) + const Vector2& displacement = gesture.GetDisplacement(); + if(displacement.x < 0) { - mIndex = (mIndex + 1)%NUM_IMAGES; + mIndex = (mIndex + 1) % NUM_IMAGES; } else { - mIndex = (mIndex + NUM_IMAGES -1)%NUM_IMAGES; + mIndex = (mIndex + NUM_IMAGES - 1) % NUM_IMAGES; } - Image image = LoadStageFillingImage( IMAGES[ mIndex ] ); - mNextImage = ImageActor::New( image ); - mNextImage.SetRelayoutEnabled( false ); - mNextImage.SetPositionInheritanceMode(USE_PARENT_POSITION_PLUS_LOCAL_POSITION); - mNextImage.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS ); - mNextImage.SetSizeScalePolicy( 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)); + mNextImage = CreateWindowFillingImageView(mApplication.GetWindow().GetSize(), IMAGES[mIndex]); + mNextImage.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER); + mNextImage.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS); + mNextImage.SetProperty(Actor::Property::SIZE_SCALE_POLICY, SizeScalePolicy::FIT_WITH_ASPECT_RATIO); + mNextImage.SetProperty(Actor::Property::POSITION_Z, INITIAL_DEPTH); + mParent.Add(mNextImage); + Vector2 size = Vector2(mCurrentImage.GetCurrentProperty(Actor::Property::SIZE)); + StartTransition(gesture.GetPosition() / size, displacement * Vector2(1.0, size.x / size.y)); } } @@ -298,91 +300,94 @@ void DissolveEffectApp::StartTransition(Vector2 position, Vector2 displacement) { mAnimation = Animation::New(TRANSITION_DURATION); - mCurrentImageEffect.SetCentralLine(position,displacement); - mCurrentImageEffect.SetDistortion(0.0f); - mCurrentImage.SetShaderEffect(mCurrentImageEffect); - mAnimation.AnimateTo( Property(mCurrentImageEffect, mCurrentImageEffect.GetDistortionPropertyName()), 1.0f, AlphaFunctions::Linear ); + Dali::Toolkit::DissolveEffectSetCentralLine(mCurrentImage, position, displacement, 0.0f); + mCurrentImage.SetProperty(Toolkit::ImageView::Property::IMAGE, mDissolveEffect); + mAnimation.AnimateTo(Property(mCurrentImage, "uPercentage"), 1.0f, AlphaFunction::LINEAR); - mNextImage.SetOpacity(0.0f); - mAnimation.AnimateTo( Property( mNextImage, Actor::Property::COLOR_ALPHA ), 1.0f, AlphaFunctions::Linear ); + mNextImage.SetProperty(Actor::Property::OPACITY, 0.0f); + mAnimation.AnimateTo(Property(mNextImage, Actor::Property::COLOR_ALPHA), 1.0f, AlphaFunction::LINEAR); if(mUseHighPrecision) { - mNextImageEffect.SetCentralLine(position,-displacement); - mNextImageEffect.SetDistortion(1.0f); - mNextImage.SetShaderEffect(mNextImageEffect); - mAnimation.AnimateTo( Property(mNextImageEffect, mNextImageEffect.GetDistortionPropertyName()), 0.0f, AlphaFunctions::Linear ); + Dali::Toolkit::DissolveEffectSetCentralLine(mNextImage, position, displacement, 1.0f); + mNextImage.SetProperty(Toolkit::ImageView::Property::IMAGE, mDissolveEffect); + mAnimation.AnimateTo(Property(mNextImage, "uPercentage"), 0.0f, AlphaFunction::LINEAR); } else { - mAnimation.AnimateTo( Property( mNextImage, Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), AlphaFunctions::Linear ); + mAnimation.AnimateTo(Property(mNextImage, Actor::Property::POSITION), Vector3(0.0f, 0.0f, 0.0f), AlphaFunction::LINEAR); } - mAnimation.FinishedSignal().Connect( this, &DissolveEffectApp::OnTransitionCompleted ); + mAnimation.FinishedSignal().Connect(this, &DissolveEffectApp::OnTransitionCompleted); mAnimation.Play(); mIsTransiting = true; } void DissolveEffectApp::OnKeyEvent(const KeyEvent& event) { - if(event.state == KeyEvent::Down) + if(event.GetState() == KeyEvent::DOWN) { - if( IsKey( event, Dali::DALI_KEY_ESCAPE) || IsKey( event, Dali::DALI_KEY_BACK) ) + if(IsKey(event, Dali::DALI_KEY_ESCAPE) || IsKey(event, Dali::DALI_KEY_BACK)) { mApplication.Quit(); } } } -bool DissolveEffectApp::OnEffectButtonClicked( Toolkit::Button button ) +bool DissolveEffectApp::OnEffectButtonClicked(Toolkit::Button button) { mUseHighPrecision = !mUseHighPrecision; - mCurrentImageEffect = Toolkit::DissolveEffect::New(mUseHighPrecision); + mDissolveEffect = Dali::Toolkit::CreateDissolveEffect(mUseHighPrecision); if(mUseHighPrecision) { - mTitleActor.SetText( APPLICATION_TITLE_HIGHP ); - mEffectChangeButton.SetBackgroundImage(mIconHighP); + mTitleActor.SetProperty(TextLabel::Property::TEXT, std::string(APPLICATION_TITLE_HIGHP)); + mEffectChangeButton.SetProperty(Toolkit::Button::Property::UNSELECTED_BACKGROUND_VISUAL, EFFECT_HIGHP_IMAGE); + mEffectChangeButton.SetProperty(Toolkit::Button::Property::SELECTED_BACKGROUND_VISUAL, EFFECT_HIGHP_IMAGE_SELECTED); } else { - mTitleActor.SetText( APPLICATION_TITLE_MEDIUMP ); - mEffectChangeButton.SetBackgroundImage(mIconMediumP); + mTitleActor.SetProperty(TextLabel::Property::TEXT, std::string(APPLICATION_TITLE_MEDIUMP)); + mEffectChangeButton.SetProperty(Toolkit::Button::Property::UNSELECTED_BACKGROUND_VISUAL, EFFECT_MEDIUMP_IMAGE); + mEffectChangeButton.SetProperty(Toolkit::Button::Property::SELECTED_BACKGROUND_VISUAL, EFFECT_MEDIUMP_IMAGE_SELECTED); } - mTitleActor.SetStyleToCurrentText(DemoHelper::GetDefaultTextStyle()); return true; } -bool DissolveEffectApp::OnSildeshowButtonClicked( Toolkit::Button button ) +bool DissolveEffectApp::OnSildeshowButtonClicked(Toolkit::Button button) { mSlideshow = !mSlideshow; - if( mSlideshow ) + if(mSlideshow) { - mPlayStopButton.SetBackgroundImage( mIconStop ); - mPanGestureDetector.Detach( mParent ); + mPlayStopButton.SetProperty(Toolkit::Button::Property::UNSELECTED_BACKGROUND_VISUAL, STOP_ICON); + mPlayStopButton.SetProperty(Toolkit::Button::Property::SELECTED_BACKGROUND_VISUAL, STOP_ICON_SELECTED); + mPanGestureDetector.Detach(mParent); mViewTimer.Start(); mTimerReady = false; } else { - mPlayStopButton.SetBackgroundImage( mIconPlay ); + mPlayStopButton.SetProperty(Toolkit::Button::Property::UNSELECTED_BACKGROUND_VISUAL, PLAY_ICON); + mPlayStopButton.SetProperty(Toolkit::Button::Property::SELECTED_BACKGROUND_VISUAL, PLAY_ICON_SELECTED); mTimerReady = true; - mPanGestureDetector.Attach( mParent ); + mPanGestureDetector.Attach(mParent); } return true; } -void DissolveEffectApp::OnTransitionCompleted( Animation& source ) +void DissolveEffectApp::OnTransitionCompleted(Animation& source) { - mCurrentImage.RemoveShaderEffect(); - mNextImage.RemoveShaderEffect(); - mParent.Remove( mCurrentImage ); - mPanGestureDetector.Detach( mCurrentImage ); + if(mUseHighPrecision) + { + mNextImage.SetProperty(Toolkit::ImageView::Property::IMAGE, mEmptyEffect); + } + mParent.Remove(mCurrentImage); + mPanGestureDetector.Detach(mCurrentImage); mCurrentImage = mNextImage; - mPanGestureDetector.Attach( mCurrentImage ); + mPanGestureDetector.Attach(mCurrentImage); mIsTransiting = false; - if( mSlideshow) + if(mSlideshow) { mViewTimer.Start(); mTimerReady = false; @@ -394,48 +399,45 @@ bool DissolveEffectApp::OnTimerTick() mTimerReady = true; if(mSlideshow) { - mIndex = (mIndex + 1)%NUM_IMAGES; - Image image = LoadStageFillingImage( IMAGES[ mIndex ] ); - mNextImage = ImageActor::New( image ); - mNextImage.SetPositionInheritanceMode(USE_PARENT_POSITION_PLUS_LOCAL_POSITION); - mNextImage.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS ); - mNextImage.SetSizeScalePolicy( FIT_WITH_ASPECT_RATIO ); - mNextImage.SetZ(INITIAL_DEPTH); - mParent.Add( mNextImage ); - switch( mCentralLineIndex%4 ) + mIndex = (mIndex + 1) % NUM_IMAGES; + mNextImage = CreateWindowFillingImageView(mApplication.GetWindow().GetSize(), IMAGES[mIndex]); + mNextImage.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER); + mNextImage.SetResizePolicy(ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS); + mNextImage.SetProperty(Actor::Property::SIZE_SCALE_POLICY, SizeScalePolicy::FIT_WITH_ASPECT_RATIO); + mNextImage.SetProperty(Actor::Property::POSITION_Z, INITIAL_DEPTH); + mParent.Add(mNextImage); + switch(mCentralLineIndex % 4) { case 0: { - StartTransition(Vector2(1.0f,0.5f), Vector2(-1.0f, 0.0f)); + 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)); + 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)); + StartTransition(Vector2(0.0f, 0.5f), Vector2(1.0f, 0.0f)); break; } default: { - StartTransition(Vector2(0.5f,1.0f), Vector2(0.0f, -1.0f)); + StartTransition(Vector2(0.5f, 1.0f), Vector2(0.0f, -1.0f)); break; } - } mCentralLineIndex++; } - return false; //return false to stop the timer + return false; //return false to stop the timer } -// Entry point for Linux & Tizen applications -int main( int argc, char **argv ) +int DALI_EXPORT_API main(int argc, char** argv) { - Application application = Application::New( &argc, &argv ); - DissolveEffectApp test( application ); + Application application = Application::New(&argc, &argv, DEMO_THEME_PATH); + DissolveEffectApp test(application); application.MainLoop(); return 0;