/*
- * 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.
}// end LOCAL_STUFF
-// This example shows the usage of BubbleEmitter which displays lots of moving bubbles on the stage.
+// This example shows the usage of BubbleEmitter which displays lots of moving bubbles on the window.
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 ),
// The Init signal is received once (only) during the Application lifetime
void Create(Application& app)
{
- Stage stage = Stage::GetCurrent();
- Vector2 stageSize = stage.GetSize();
+ Window window = app.GetWindow();
+ Vector2 windowSize = window.GetSize();
- stage.KeyEventSignal().Connect(this, &BubbleEffectExample::OnKeyEvent);
+ window.KeyEventSignal().Connect(this, &BubbleEffectExample::OnKeyEvent);
// Creates a default view with a default tool bar.
- // The view is added to the stage.
+ // The view is added to the window.
Toolkit::ToolBar toolBar;
Layer content = DemoHelper::CreateView( app,
mBackground,
// 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,
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,
DemoHelper::DEFAULT_MODE_SWITCH_PADDING );
// Create and initialize the BubbleEmitter object
- mBubbleEmitter = Toolkit::BubbleEmitter::New( stageSize,
- DemoHelper::LoadImage( BUBBLE_SHAPE_IMAGES[mCurrentBubbleShapeImageId] ),
+ mBubbleEmitter = Toolkit::BubbleEmitter::New( windowSize,
+ DemoHelper::LoadTexture( BUBBLE_SHAPE_IMAGES[mCurrentBubbleShapeImageId] ),
DEFAULT_NUMBER_OF_BUBBLES,
DEFAULT_BUBBLE_SIZE);
- mBackgroundImage = DemoHelper::LoadStageFillingImage( BACKGROUND_IMAGES[mCurrentBackgroundImageId] );
- mBubbleEmitter.SetBackground( mBackgroundImage, mHSVDelta );
- // Get the root actor of all bubbles, and add it to stage.
+ mBubbleEmitter.SetBackground( DemoHelper::LoadWindowFillingTexture( window.GetSize(), BACKGROUND_IMAGES[mCurrentBackgroundImageId] ), mHSVDelta );
+
+ // Get the root actor of all bubbles, and add it to window.
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 );
{
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::LoadWindowFillingTexture( mApp.GetWindow().GetSize(), 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( DemoHelper::LoadImage( BUBBLE_SHAPE_IMAGES[ ++mCurrentBubbleShapeImageId % NUM_BUBBLE_SHAPE_IMAGES ] ) );
+ mBubbleEmitter.SetBubbleShape( DemoHelper::LoadTexture( BUBBLE_SHAPE_IMAGES[ ++mCurrentBubbleShapeImageId % NUM_BUBBLE_SHAPE_IMAGES ] ) );
}
return true;
}
private:
Application& mApp;
- Image mBackgroundImage;
Dali::Toolkit::Control mBackground;
Toolkit::BubbleEmitter mBubbleEmitter;
/*****************************************************************************/
-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;
}