X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=examples%2Fbubble-effect%2Fbubble-effect-example.cpp;h=a668384efc387661067b6e16c723f582c06bb19c;hb=1a473d5189ca7e7d55aca3a64a8a4ff2dc3b6c67;hp=878e933dfbc94ce61975bac7ed983dd40676315e;hpb=a30bcc247f2726235baaba0406f829ddf0815d91;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 878e933..a668384 100644 --- a/examples/bubble-effect/bubble-effect-example.cpp +++ b/examples/bubble-effect/bubble-effect-example.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016 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. @@ -56,7 +56,7 @@ const unsigned int DEFAULT_NUMBER_OF_BUBBLES( 1000 ); }// 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: @@ -91,13 +91,13 @@ private: // 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, @@ -108,35 +108,35 @@ 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, - Toolkit::Alignment::HorizontalRight, + Toolkit::Alignment::HORIZONTAL_RIGHT, 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, - Toolkit::Alignment::HorizontalLeft, + Toolkit::Alignment::HORIZONTAL_LEFT, DemoHelper::DEFAULT_MODE_SWITCH_PADDING ); // Create and initialize the BubbleEmitter object - mBubbleEmitter = Toolkit::BubbleEmitter::New( stageSize, + mBubbleEmitter = Toolkit::BubbleEmitter::New( windowSize, DemoHelper::LoadTexture( BUBBLE_SHAPE_IMAGES[mCurrentBubbleShapeImageId] ), DEFAULT_NUMBER_OF_BUBBLES, DEFAULT_BUBBLE_SIZE); - mBubbleEmitter.SetBackground( DemoHelper::LoadStageFillingTexture( BACKGROUND_IMAGES[mCurrentBackgroundImageId] ), mHSVDelta ); + mBubbleEmitter.SetBackground( DemoHelper::LoadWindowFillingTexture( window.GetSize(), BACKGROUND_IMAGES[mCurrentBackgroundImageId] ), mHSVDelta ); - // Get the root actor of all bubbles, and add it to stage. + // 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 ); // Set the application background @@ -147,7 +147,7 @@ private: mTimerForBubbleEmission.TickSignal().Connect(this, &BubbleEffectExample::OnTimerTick); // Connect the callback to the touch signal on the background - mBackground.TouchSignal().Connect( this, &BubbleEffectExample::OnTouch ); + mBackground.TouchedSignal().Connect( this, &BubbleEffectExample::OnTouch ); } @@ -202,7 +202,7 @@ private: } // Callback function of the touch signal on the background - bool OnTouch(Dali::Actor actor, const Dali::TouchData& event) + bool OnTouch(Dali::Actor actor, const Dali::TouchEvent& event) { switch( event.GetState( 0 ) ) { @@ -253,7 +253,7 @@ private: mCurrentBackgroundImageId = (mCurrentBackgroundImageId+1) % NUM_BACKGROUND_IMAGES; //Update bubble emitter background - mBubbleEmitter.SetBackground( DemoHelper::LoadStageFillingTexture( BACKGROUND_IMAGES[ mCurrentBackgroundImageId ] ), mHSVDelta ); + mBubbleEmitter.SetBackground( DemoHelper::LoadWindowFillingTexture( mApp.GetWindow().GetSize(), BACKGROUND_IMAGES[ mCurrentBackgroundImageId ] ), mHSVDelta ); // Set the application background mBackground.SetProperty( Toolkit::Control::Property::BACKGROUND, BACKGROUND_IMAGES[ mCurrentBackgroundImageId ] ); @@ -270,7 +270,7 @@ private: */ void OnKeyEvent(const KeyEvent& event) { - if(event.state == KeyEvent::Down) + if(event.GetState() == KeyEvent::DOWN) { if( IsKey( event, Dali::DALI_KEY_ESCAPE) || IsKey( event, Dali::DALI_KEY_BACK) ) { @@ -305,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; }