X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=examples%2Fdissolve-effect%2Fdissolve-effect-example.cpp;h=c1f77861ff023281efc6b9b0ba457bc36eed591d;hb=2e1746f4559ba948ef4465efaeaf5730f984f611;hp=374ac9654ef3b1a5edc92112bf02073b2eed595b;hpb=b95d3a3ead5382e65c3dc6f695acfcf3a919f23c;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 374ac96..c1f7786 100644 --- a/examples/dissolve-effect/dissolve-effect-example.cpp +++ b/examples/dissolve-effect/dissolve-effect-example.cpp @@ -71,6 +71,25 @@ const int VIEWINGTIME = 2000; // 2 seconds const float TRANSITION_DURATION = 2.5f; //2.5 second 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 + * load time to cover the entire stage with pixels with no borders, + * and filter mode ImageAttributes::BoxThenLinear 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 ); +} + } // namespace class DissolveEffectApp : public ConnectionTracker @@ -144,7 +163,6 @@ private: ImageActor mCurrentImage; ImageActor mNextImage; unsigned int mIndex; - Constraint mSizeConstraint; Toolkit::DissolveEffect mCurrentImageEffect; Toolkit::DissolveEffect mNextImageEffect; @@ -232,12 +250,11 @@ void DissolveEffectApp::OnInit( Application& application ) mParent.SetPositionInheritanceMode( USE_PARENT_POSITION ); mContent.Add( mParent ); - mSizeConstraint= Constraint::New( Actor::Property::SCALE, LocalSource( Actor::Property::SIZE ), ParentSource( Actor::Property::SIZE ), ScaleToFitKeepAspectRatioConstraint() ); - // show the first image - mCurrentImage = ImageActor::New( ResourceImage::New( IMAGES[mIndex] ) ); + mCurrentImage = ImageActor::New( LoadStageFillingImage( IMAGES[mIndex] ) ); mCurrentImage.SetPositionInheritanceMode(USE_PARENT_POSITION_PLUS_LOCAL_POSITION); - mCurrentImage.ApplyConstraint( mSizeConstraint ); + mCurrentImage.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS ); + mCurrentImage.SetSizeScalePolicy( FIT_WITH_ASPECT_RATIO ); mParent.Add( mCurrentImage ); mPanGestureDetector.Attach( mCurrentImage ); @@ -263,10 +280,11 @@ void DissolveEffectApp::OnPanGesture( Actor actor, const PanGesture& gesture ) mIndex = (mIndex + NUM_IMAGES -1)%NUM_IMAGES; } - Image image = ResourceImage::New( IMAGES[ mIndex ] ); + Image image = LoadStageFillingImage( IMAGES[ mIndex ] ); mNextImage = ImageActor::New( image ); mNextImage.SetPositionInheritanceMode(USE_PARENT_POSITION_PLUS_LOCAL_POSITION); - mNextImage.ApplyConstraint( mSizeConstraint ); + 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() ); @@ -284,7 +302,7 @@ void DissolveEffectApp::StartTransition(Vector2 position, Vector2 displacement) mAnimation.AnimateTo( Property(mCurrentImageEffect, mCurrentImageEffect.GetDistortionPropertyName()), 1.0f, AlphaFunctions::Linear ); mNextImage.SetOpacity(0.0f); - mAnimation.OpacityTo( mNextImage, 1.0, AlphaFunctions::Linear ); + mAnimation.AnimateTo( Property( mNextImage, Actor::Property::COLOR_ALPHA ), 1.0f, AlphaFunctions::Linear ); if(mUseHighPrecision) { @@ -295,7 +313,7 @@ void DissolveEffectApp::StartTransition(Vector2 position, Vector2 displacement) } else { - mAnimation.MoveTo(mNextImage, Vector3(0.0f, 0.0f, 0.0f), AlphaFunctions::Linear); + mAnimation.AnimateTo( Property( mNextImage, Actor::Property::POSITION ), Vector3( 0.0f, 0.0f, 0.0f ), AlphaFunctions::Linear ); } mAnimation.FinishedSignal().Connect( this, &DissolveEffectApp::OnTransitionCompleted ); @@ -375,10 +393,11 @@ bool DissolveEffectApp::OnTimerTick() if(mSlideshow) { mIndex = (mIndex + 1)%NUM_IMAGES; - Image image = ResourceImage::New( IMAGES[ mIndex ] ); + Image image = LoadStageFillingImage( IMAGES[ mIndex ] ); mNextImage = ImageActor::New( image ); mNextImage.SetPositionInheritanceMode(USE_PARENT_POSITION_PLUS_LOCAL_POSITION); - mNextImage.ApplyConstraint( mSizeConstraint ); + mNextImage.SetResizePolicy( FILL_TO_PARENT, ALL_DIMENSIONS ); + mNextImage.SetSizeScalePolicy( FIT_WITH_ASPECT_RATIO ); mNextImage.SetZ(INITIAL_DEPTH); mParent.Add( mNextImage ); switch( mCentralLineIndex%4 ) @@ -410,7 +429,7 @@ bool DissolveEffectApp::OnTimerTick() return false; //return false to stop the timer } -// Entry point for Linux & SLP applications +// Entry point for Linux & Tizen applications int main( int argc, char **argv ) { Application application = Application::New( &argc, &argv );