From 8841ed7ccb5284d5022dc3a59de7ad9a4f657b0e Mon Sep 17 00:00:00 2001 From: Ferran Sole Date: Thu, 24 Nov 2016 15:43:22 +0000 Subject: [PATCH] Changes following "Changed bubble effect to use new texture API" Change-Id: I1e329a43d1d6026bdfe41facd67d8228561ae713 --- examples/bubble-effect/bubble-effect-example.cpp | 26 ++++++++++++++---------- examples/new-window/new-window-example.cpp | 4 ++-- 2 files changed, 17 insertions(+), 13 deletions(-) diff --git a/examples/bubble-effect/bubble-effect-example.cpp b/examples/bubble-effect/bubble-effect-example.cpp index 5cb3625..8de8a42 100644 --- a/examples/bubble-effect/bubble-effect-example.cpp +++ b/examples/bubble-effect/bubble-effect-example.cpp @@ -62,7 +62,6 @@ class BubbleEffectExample : public ConnectionTracker public: BubbleEffectExample(Application &app) : mApp(app), - mBackgroundImage(), mBackground(), mBubbleEmitter(), mEmitAnimation(), @@ -128,11 +127,11 @@ private: // Create and initialize the BubbleEmitter object mBubbleEmitter = Toolkit::BubbleEmitter::New( stageSize, - DemoHelper::LoadImage( BUBBLE_SHAPE_IMAGES[mCurrentBubbleShapeImageId] ), + DemoHelper::LoadTexture( BUBBLE_SHAPE_IMAGES[mCurrentBubbleShapeImageId] ), DEFAULT_NUMBER_OF_BUBBLES, DEFAULT_BUBBLE_SIZE); - mBackgroundImage = DemoHelper::LoadStageFillingImage( BACKGROUND_IMAGES[mCurrentBackgroundImageId] ); - mBubbleEmitter.SetBackground( mBackgroundImage, mHSVDelta ); + + mBubbleEmitter.SetBackground( DemoHelper::LoadStageFillingTexture( BACKGROUND_IMAGES[mCurrentBackgroundImageId] ), mHSVDelta ); // Get the root actor of all bubbles, and add it to stage. Actor bubbleRoot = mBubbleEmitter.GetRootActor(); @@ -140,8 +139,10 @@ private: bubbleRoot.SetZ(0.1f); // Make sure the bubbles displayed on top og the background. content.Add( bubbleRoot ); - // Add the background image actor to stage - mBackground.SetBackgroundImage( mBackgroundImage ); + // Set the application background + mBackground.SetProperty( Toolkit::Control::Property::BACKGROUND, Dali::Property::Map() + .Add( Dali::Toolkit::Visual::Property::TYPE, Dali::Toolkit::Visual::IMAGE ) + .Add( Dali::Toolkit::ImageVisual::Property::URL, BACKGROUND_IMAGES[mCurrentBackgroundImageId] )); // Set up the timer to emit bubble regularly when the finger is touched down but not moved mTimerForBubbleEmission = Timer::New( mTimerInterval ); @@ -251,15 +252,19 @@ private: { if(button == mChangeBackgroundButton) { - mBackgroundImage = DemoHelper::LoadStageFillingImage( BACKGROUND_IMAGES[ ++mCurrentBackgroundImageId % NUM_BACKGROUND_IMAGES ] ); + mCurrentBackgroundImageId = (mCurrentBackgroundImageId+1) % NUM_BACKGROUND_IMAGES; - mBubbleEmitter.SetBackground( mBackgroundImage, mHSVDelta ); + //Update bubble emitter background + mBubbleEmitter.SetBackground( DemoHelper::LoadStageFillingTexture( BACKGROUND_IMAGES[ mCurrentBackgroundImageId ] ), mHSVDelta ); - mBackground.SetBackgroundImage( mBackgroundImage ); + // Set the application background + mBackground.SetProperty( Toolkit::Control::Property::BACKGROUND, Dali::Property::Map() + .Add( Dali::Toolkit::Visual::Property::TYPE, Dali::Toolkit::Visual::IMAGE ) + .Add( Dali::Toolkit::ImageVisual::Property::URL, BACKGROUND_IMAGES[mCurrentBackgroundImageId] )); } else if( button == mChangeBubbleShapeButton ) { - mBubbleEmitter.SetShapeImage( DemoHelper::LoadImage( BUBBLE_SHAPE_IMAGES[ ++mCurrentBubbleShapeImageId % NUM_BUBBLE_SHAPE_IMAGES ] ) ); + mBubbleEmitter.SetBubbleShape( DemoHelper::LoadTexture( BUBBLE_SHAPE_IMAGES[ ++mCurrentBubbleShapeImageId % NUM_BUBBLE_SHAPE_IMAGES ] ) ); } return true; } @@ -281,7 +286,6 @@ private: private: Application& mApp; - Image mBackgroundImage; Dali::Toolkit::Control mBackground; Toolkit::BubbleEmitter mBubbleEmitter; diff --git a/examples/new-window/new-window-example.cpp b/examples/new-window/new-window-example.cpp index 08dff10..7e6c625 100644 --- a/examples/new-window/new-window-example.cpp +++ b/examples/new-window/new-window-example.cpp @@ -243,10 +243,10 @@ void NewWindowController::Destroy( Application& app ) void NewWindowController::AddBubbles( Actor& parentActor, const Vector2& stageSize) { mEmitter = Toolkit::BubbleEmitter::New( stageSize, - DemoHelper::LoadImage( DEMO_IMAGE_DIR "bubble-ball.png" ), + DemoHelper::LoadTexture( DEMO_IMAGE_DIR "bubble-ball.png" ), 200, Vector2( 5.0f, 5.0f ) ); - Image background = DemoHelper::LoadImage(BACKGROUND_IMAGE); + Texture background = DemoHelper::LoadTexture(BACKGROUND_IMAGE); mEmitter.SetBackground( background, Vector3(0.5f, 0.f,0.5f) ); mEmitter.SetBubbleDensity( 9.f ); Actor bubbleRoot = mEmitter.GetRootActor(); -- 2.7.4