X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=examples%2Fbubble-effect%2Fbubble-effect-example.cpp;h=444f8d725762f1ed705cc39d84e43d9ba69eee6a;hb=2e182925204bf3ef9f2a36cbfbf998e79fbafaf5;hp=fbd83dba40d840ecf7bea4a7b8b7d06a16646a83;hpb=661bf429a56def085e118b5c7a48ae48ee41c86e;p=platform%2Fcore%2Fuifw%2Fdali-demo.git diff --git a/examples/bubble-effect/bubble-effect-example.cpp b/examples/bubble-effect/bubble-effect-example.cpp index fbd83db..444f8d7 100644 --- a/examples/bubble-effect/bubble-effect-example.cpp +++ b/examples/bubble-effect/bubble-effect-example.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Samsung Electronics Co., Ltd. + * Copyright (c) 2019 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. @@ -19,6 +19,7 @@ #include #include #include "shared/view.h" +#include "shared/utility.h" using namespace Dali; @@ -53,20 +54,6 @@ const unsigned int NUM_BUBBLE_SHAPE_IMAGES( sizeof( BUBBLE_SHAPE_IMAGES ) / size const Vector2 DEFAULT_BUBBLE_SIZE( 10.f, 30.f ); const unsigned int DEFAULT_NUMBER_OF_BUBBLES( 1000 ); -/** - * @brief Load an image, scaled-down to no more than the stage dimensions. - * - * Uses image scaling mode FittingMode::SCALE_TO_FILL to resize the image at - * load time to cover the entire stage with pixels with no borders, - * and filter mode BOX_THEN_LINEAR to sample the image with - * maximum quality. - */ -ResourceImage LoadStageFillingImage( const char * const imagePath ) -{ - Size stageSize = Stage::GetCurrent().GetSize(); - return ResourceImage::New( imagePath, Dali::ImageDimensions( stageSize.x, stageSize.y ), Dali::FittingMode::SCALE_TO_FILL, Dali::SamplingMode::BOX_THEN_LINEAR ); -} - }// end LOCAL_STUFF // This example shows the usage of BubbleEmitter which displays lots of moving bubbles on the stage. @@ -75,7 +62,17 @@ class BubbleEffectExample : public ConnectionTracker public: BubbleEffectExample(Application &app) : mApp(app), + mBackground(), + mBubbleEmitter(), + mEmitAnimation(), + mChangeBackgroundButton(), + mChangeBubbleShapeButton(), + mTimerForBubbleEmission(), mHSVDelta( Vector3( 0.f, 0.f, 0.5f ) ), + mCurrentTouchPosition(), + mEmitPosition(), + mAnimateComponentCount( 0 ), + mNonMovementCount( 0 ), mTimerInterval( 16 ), mCurrentBackgroundImageId( 0 ), mCurrentBubbleShapeImageId( 0 ), @@ -111,8 +108,8 @@ private: // Add a button to change background. (right of toolbar) mChangeBackgroundButton = Toolkit::PushButton::New(); - mChangeBackgroundButton.SetUnselectedImage( CHANGE_BACKGROUND_ICON ); - mChangeBackgroundButton.SetSelectedImage( CHANGE_BACKGROUND_ICON_SELECTED ); + mChangeBackgroundButton.SetProperty( Toolkit::Button::Property::UNSELECTED_BACKGROUND_VISUAL, CHANGE_BACKGROUND_ICON ); + mChangeBackgroundButton.SetProperty( Toolkit::Button::Property::SELECTED_BACKGROUND_VISUAL, CHANGE_BACKGROUND_ICON_SELECTED ); mChangeBackgroundButton.ClickedSignal().Connect( this, &BubbleEffectExample::OnChangeIconClicked ); toolBar.AddControl( mChangeBackgroundButton, DemoHelper::DEFAULT_VIEW_STYLE.mToolBarButtonPercentage, @@ -120,8 +117,8 @@ private: DemoHelper::DEFAULT_MODE_SWITCH_PADDING ); // Add a button to change bubble shape. ( left of bar ) mChangeBubbleShapeButton = Toolkit::PushButton::New(); - mChangeBubbleShapeButton.SetUnselectedImage( CHANGE_BUBBLE_SHAPE_ICON ); - mChangeBubbleShapeButton.SetSelectedImage( CHANGE_BUBBLE_SHAPE_ICON_SELECTED ); + mChangeBubbleShapeButton.SetProperty( Toolkit::Button::Property::UNSELECTED_BACKGROUND_VISUAL, CHANGE_BUBBLE_SHAPE_ICON ); + mChangeBubbleShapeButton.SetProperty( Toolkit::Button::Property::SELECTED_BACKGROUND_VISUAL, CHANGE_BUBBLE_SHAPE_ICON_SELECTED ); mChangeBubbleShapeButton.ClickedSignal().Connect( this, &BubbleEffectExample::OnChangeIconClicked ); toolBar.AddControl( mChangeBubbleShapeButton, DemoHelper::DEFAULT_VIEW_STYLE.mToolBarButtonPercentage, @@ -130,20 +127,20 @@ private: // Create and initialize the BubbleEmitter object mBubbleEmitter = Toolkit::BubbleEmitter::New( stageSize, - ResourceImage::New( BUBBLE_SHAPE_IMAGES[mCurrentBubbleShapeImageId] ), + DemoHelper::LoadTexture( BUBBLE_SHAPE_IMAGES[mCurrentBubbleShapeImageId] ), DEFAULT_NUMBER_OF_BUBBLES, DEFAULT_BUBBLE_SIZE); - mBackgroundImage = 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(); - bubbleRoot.SetParentOrigin(ParentOrigin::CENTER); - bubbleRoot.SetZ(0.1f); // Make sure the bubbles displayed on top og the background. + bubbleRoot.SetProperty( Actor::Property::PARENT_ORIGIN,ParentOrigin::CENTER); + bubbleRoot.SetProperty( Actor::Property::POSITION_Z, 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, BACKGROUND_IMAGES[ mCurrentBackgroundImageId ] ); // Set up the timer to emit bubble regularly when the finger is touched down but not moved mTimerForBubbleEmission = Timer::New( mTimerInterval ); @@ -253,15 +250,17 @@ private: { if(button == mChangeBackgroundButton) { - mBackgroundImage = 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, BACKGROUND_IMAGES[ mCurrentBackgroundImageId ] ); } else if( button == mChangeBubbleShapeButton ) { - mBubbleEmitter.SetShapeImage( ResourceImage::New( BUBBLE_SHAPE_IMAGES[ ++mCurrentBubbleShapeImageId % NUM_BUBBLE_SHAPE_IMAGES ] ) ); + mBubbleEmitter.SetBubbleShape( DemoHelper::LoadTexture( BUBBLE_SHAPE_IMAGES[ ++mCurrentBubbleShapeImageId % NUM_BUBBLE_SHAPE_IMAGES ] ) ); } return true; } @@ -283,7 +282,6 @@ private: private: Application& mApp; - Image mBackgroundImage; Dali::Toolkit::Control mBackground; Toolkit::BubbleEmitter mBubbleEmitter; @@ -307,20 +305,10 @@ private: /*****************************************************************************/ -static void -RunTest(Application& app) -{ - BubbleEffectExample theApp(app); - app.MainLoop(); -} - -/*****************************************************************************/ - int DALI_EXPORT_API main(int argc, char **argv) { Application app = Application::New(&argc, &argv, DEMO_THEME_PATH); - - RunTest(app); - + BubbleEffectExample theApp(app); + app.MainLoop(); return 0; }