X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=examples%2Fdissolve-effect%2Fdissolve-effect-example.cpp;h=a961320f35fdca742994d76dc3d1398a169b1fe1;hb=d50be058271790767987eefc8664198146e2ebca;hp=8190a1a7e4af64345a5184ee83b1fc8c4f0146f3;hpb=79ca1d506fc1f3da22994bffc1028242a3121165;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 8190a1a..a961320 100644 --- a/examples/dissolve-effect/dissolve-effect-example.cpp +++ b/examples/dissolve-effect/dissolve-effect-example.cpp @@ -23,6 +23,7 @@ #include #include +#include using namespace Dali; @@ -36,9 +37,13 @@ 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_HIGHP_IMAGE_SELECTED( DALI_IMAGE_DIR "icon-highp-selected.png" ); const char * const EFFECT_MEDIUMP_IMAGE( DALI_IMAGE_DIR "icon-mediump.png" ); +const char * const EFFECT_MEDIUMP_IMAGE_SELECTED( DALI_IMAGE_DIR "icon-mediump-selected.png" ); const char * const PLAY_ICON( DALI_IMAGE_DIR "icon-play.png" ); +const char * const PLAY_ICON_SELECTED( DALI_IMAGE_DIR "icon-play-selected.png" ); const char * const STOP_ICON( DALI_IMAGE_DIR "icon-stop.png" ); +const char * const STOP_ICON_SELECTED( DALI_IMAGE_DIR "icon-stop-selected.png" ); const char* IMAGES[] = { @@ -77,19 +82,15 @@ const float INITIAL_DEPTH = -10.0f; /** * @brief Load an image, scaled-down to no more than the stage dimensions. * - * Uses image scaling mode ImageAttributes::ScaleToFill to resize the image at + * Uses image scaling mode SCALE_TO_FILL 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 + * and filter mode BOX_THEN_LINEAR to sample the image with * maximum quality. */ ResourceImage LoadStageFillingImage( 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 ); + return ResourceImage::New( imagePath, ImageDimensions( stageSize.x, stageSize.y ), Dali::FittingMode::SCALE_TO_FILL, Dali::SamplingMode::BOX_THEN_LINEAR ); } } // namespace @@ -156,7 +157,7 @@ private: private: Application& mApplication; - Toolkit::View mView; + Toolkit::Control mView; Toolkit::ToolBar mToolBar; Layer mContent; Toolkit::TextLabel mTitleActor; @@ -166,8 +167,8 @@ private: ImageActor mNextImage; unsigned int mIndex; - Toolkit::DissolveEffect mCurrentImageEffect; - Toolkit::DissolveEffect mNextImageEffect; + ShaderEffect mCurrentImageEffect; + ShaderEffect mNextImageEffect; bool mUseHighPrecision; Animation mAnimation; @@ -179,12 +180,8 @@ private: bool mTimerReady; unsigned int mCentralLineIndex; - Image mIconPlay; - Image mIconStop; Toolkit::PushButton mPlayStopButton; - Image mIconHighP; - Image mIconMediumP; Toolkit::PushButton mEffectChangeButton; }; @@ -207,18 +204,15 @@ DissolveEffectApp::~DissolveEffectApp() void DissolveEffectApp::OnInit( Application& application ) { - DemoHelper::RequestThemeChange(); - 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. - mIconHighP = ResourceImage::New( EFFECT_HIGHP_IMAGE ); - mIconMediumP = ResourceImage::New( EFFECT_MEDIUMP_IMAGE ); mEffectChangeButton = Toolkit::PushButton::New(); - mEffectChangeButton.SetBackgroundImage(mIconHighP); + mEffectChangeButton.SetUnselectedImage( EFFECT_HIGHP_IMAGE ); + mEffectChangeButton.SetSelectedImage( 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 ); @@ -227,10 +221,9 @@ void DissolveEffectApp::OnInit( Application& application ) mToolBar.AddControl( mTitleActor, DemoHelper::DEFAULT_VIEW_STYLE.mToolBarTitlePercentage, Toolkit::Alignment::HorizontalCenter ); // 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.SetUnselectedImage( PLAY_ICON ); + mPlayStopButton.SetSelectedImage( PLAY_ICON_SELECTED ); mPlayStopButton.ClickedSignal().Connect( this, &DissolveEffectApp::OnSildeshowButtonClicked ); mToolBar.AddControl( mPlayStopButton, DemoHelper::DEFAULT_VIEW_STYLE.mToolBarButtonPercentage, Toolkit::Alignment::HorizontalCenter, DemoHelper::DEFAULT_PLAY_PADDING ); @@ -239,8 +232,8 @@ void DissolveEffectApp::OnInit( Application& application ) mPanGestureDetector.DetectedSignal().Connect( this, &DissolveEffectApp::OnPanGesture ); // create the dissolve effect object - mCurrentImageEffect = Toolkit::DissolveEffect::New(mUseHighPrecision); - mNextImageEffect = Toolkit::DissolveEffect::New(mUseHighPrecision); + mCurrentImageEffect = Toolkit::CreateDissolveEffect(mUseHighPrecision); + mNextImageEffect = Toolkit::CreateDissolveEffect(mUseHighPrecision); mViewTimer = Timer::New( VIEWINGTIME ); mViewTimer.TickSignal().Connect( this, &DissolveEffectApp::OnTimerTick ); @@ -298,24 +291,24 @@ void DissolveEffectApp::StartTransition(Vector2 position, Vector2 displacement) { mAnimation = Animation::New(TRANSITION_DURATION); - mCurrentImageEffect.SetCentralLine(position,displacement); - mCurrentImageEffect.SetDistortion(0.0f); + Dali::Toolkit::DissolveEffectSetCentralLine( mCurrentImageEffect, position, displacement ); + mCurrentImageEffect.SetUniform("uPercentage", 0.0f); mCurrentImage.SetShaderEffect(mCurrentImageEffect); - mAnimation.AnimateTo( Property(mCurrentImageEffect, mCurrentImageEffect.GetDistortionPropertyName()), 1.0f, AlphaFunctions::Linear ); + mAnimation.AnimateTo( Property(mCurrentImageEffect, "uPercentage"), 1.0f, AlphaFunction::LINEAR ); mNextImage.SetOpacity(0.0f); - mAnimation.AnimateTo( Property( mNextImage, Actor::Property::COLOR_ALPHA ), 1.0f, AlphaFunctions::Linear ); + mAnimation.AnimateTo( Property( mNextImage, Actor::Property::COLOR_ALPHA ), 1.0f, AlphaFunction::LINEAR ); if(mUseHighPrecision) { - mNextImageEffect.SetCentralLine(position,-displacement); - mNextImageEffect.SetDistortion(1.0f); + Dali::Toolkit::DissolveEffectSetCentralLine( mNextImageEffect, position, displacement ); + mNextImageEffect.SetUniform("uPercentage", 1.0f); mNextImage.SetShaderEffect(mNextImageEffect); - mAnimation.AnimateTo( Property(mNextImageEffect, mNextImageEffect.GetDistortionPropertyName()), 0.0f, AlphaFunctions::Linear ); + mAnimation.AnimateTo( Property(mNextImageEffect, "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 ); @@ -337,16 +330,18 @@ void DissolveEffectApp::OnKeyEvent(const KeyEvent& event) bool DissolveEffectApp::OnEffectButtonClicked( Toolkit::Button button ) { mUseHighPrecision = !mUseHighPrecision; - mCurrentImageEffect = Toolkit::DissolveEffect::New(mUseHighPrecision); + mCurrentImageEffect = Dali::Toolkit::CreateDissolveEffect(mUseHighPrecision); if(mUseHighPrecision) { mTitleActor.SetProperty( TextLabel::Property::TEXT, std::string(APPLICATION_TITLE_HIGHP) ); - mEffectChangeButton.SetBackgroundImage(mIconHighP); + mEffectChangeButton.SetUnselectedImage( EFFECT_HIGHP_IMAGE ); + mEffectChangeButton.SetSelectedImage( EFFECT_HIGHP_IMAGE_SELECTED ); } else { mTitleActor.SetProperty( TextLabel::Property::TEXT, std::string(APPLICATION_TITLE_MEDIUMP) ); - mEffectChangeButton.SetBackgroundImage(mIconMediumP); + mEffectChangeButton.SetUnselectedImage( EFFECT_MEDIUMP_IMAGE ); + mEffectChangeButton.SetSelectedImage( EFFECT_MEDIUMP_IMAGE_SELECTED ); } return true; @@ -357,14 +352,16 @@ bool DissolveEffectApp::OnSildeshowButtonClicked( Toolkit::Button button ) mSlideshow = !mSlideshow; if( mSlideshow ) { - mPlayStopButton.SetBackgroundImage( mIconStop ); + mPlayStopButton.SetUnselectedImage( STOP_ICON ); + mPlayStopButton.SetSelectedImage( STOP_ICON_SELECTED ); mPanGestureDetector.Detach( mParent ); mViewTimer.Start(); mTimerReady = false; } else { - mPlayStopButton.SetBackgroundImage( mIconPlay ); + mPlayStopButton.SetUnselectedImage( PLAY_ICON ); + mPlayStopButton.SetSelectedImage( PLAY_ICON_SELECTED ); mTimerReady = true; mPanGestureDetector.Attach( mParent ); } @@ -433,7 +430,7 @@ bool DissolveEffectApp::OnTimerTick() // Entry point for Linux & Tizen applications int main( int argc, char **argv ) { - Application application = Application::New( &argc, &argv ); + Application application = Application::New( &argc, &argv, DALI_DEMO_THEME_PATH ); DissolveEffectApp test( application ); application.MainLoop();