Revert "Updates following rename of PropertyBuffer"
[platform/core/uifw/dali-demo.git] / examples / sparkle / sparkle-effect-example.cpp
index 1cc465a..a1444fa 100644 (file)
@@ -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.
@@ -21,6 +21,8 @@
 #include <sstream>
 #include <algorithm>
 #include <map>
+#include <random>       // std::default_random_engine
+#include <chrono>       // std::chrono::system_clock
 
 #include "shared/utility.h"
 #include "sparkle-effect.h"
@@ -85,24 +87,24 @@ private:
    */
   void OnInit( Application& application )
   {
-    Stage stage = Stage::GetCurrent();
-    stage.KeyEventSignal().Connect(this, &SparkleEffectExample::OnKeyEvent);
-    stage.SetBackgroundColor( BACKGROUND_COLOR );
+    Window window = application.GetWindow();
+    window.KeyEventSignal().Connect(this, &SparkleEffectExample::OnKeyEvent);
+    window.SetBackgroundColor( BACKGROUND_COLOR );
 
     mCircleBackground = ImageView::New( CIRCLE_BACKGROUND_IMAGE );
-    mCircleBackground.SetParentOrigin( ParentOrigin::CENTER );
-    mCircleBackground.SetAnchorPoint( AnchorPoint::CENTER );
+    mCircleBackground.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
+    mCircleBackground.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER );
 
-    stage.Add( mCircleBackground );
+    window.Add( mCircleBackground );
 
     mEffect = SparkleEffect::New();
 
     mMeshActor = CreateMeshActor();
 
-    stage.Add( mMeshActor );
+    window.Add( mMeshActor );
 
-    mMeshActor.SetPosition( ACTOR_POSITION );
-    mMeshActor.SetScale( ACTOR_SCALE );
+    mMeshActor.SetProperty( Actor::Property::POSITION, ACTOR_POSITION );
+    mMeshActor.SetProperty( Actor::Property::SCALE, ACTOR_SCALE );
 
     mTapDetector = TapGestureDetector::New();
     mTapDetector.Attach(mCircleBackground);
@@ -126,7 +128,8 @@ private:
     {
       shuffleArray[i] = i;
     }
-    std::random_shuffle(&shuffleArray[0],&shuffleArray[NUM_PARTICLE]);
+    const unsigned int seed = std::chrono::system_clock::now().time_since_epoch().count();
+    std::shuffle(&shuffleArray[0],&shuffleArray[NUM_PARTICLE], std::default_random_engine(seed));
 
     // Create vertices
 
@@ -166,8 +169,8 @@ private:
     renderer.SetTextures( textureSet );
 
     Actor meshActor = Actor::New();
-    meshActor.SetParentOrigin( ParentOrigin::CENTER );
-    meshActor.SetSize( 1, 1 );
+    meshActor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
+    meshActor.SetProperty( Actor::Property::SIZE, Vector2( 1, 1 ) );
     meshActor.AddRenderer( renderer );
 
     return meshActor;
@@ -354,9 +357,9 @@ private:
 
     // prepare the animation by setting the uniform to the required value
     mEffect.SetProperty( mEffect.GetPropertyIndex( BREAK_UNIFORM_NAME ), 1.f );
-    mMeshActor.SetScale(0.01f);
+    mMeshActor.SetProperty( Actor::Property::SCALE,0.01f);
     mEffect.SetProperty( mEffect.GetPropertyIndex( "uScale" ), 0.01f );
-    mMeshActor.SetPosition( 0.f, 0.f, 1.f );
+    mMeshActor.SetProperty( Actor::Property::POSITION, Vector3( 0.f, 0.f, 1.f ) );
 
     Animation breakAnimation = Animation::New(duration*1.5f);
     breakAnimation.AnimateTo( Property(mMeshActor, Actor::Property::SCALE), Vector3(ACTOR_SCALE,ACTOR_SCALE,ACTOR_SCALE), EaseOutSquare);
@@ -548,21 +551,11 @@ private:
   std::map< Animation, int > mTapAnimationIndexPair;
 };
 
-void RunTest( Application& application )
-{
-  SparkleEffectExample theApp( application );
-
-  application.MainLoop();
-}
-
-// Entry point for Linux & Tizen applications
-//
 int DALI_EXPORT_API main( int argc, char **argv )
 {
   Application application = Application::New( &argc, &argv );
-
-  RunTest( application );
-
+  SparkleEffectExample theApp( application );
+  application.MainLoop();
   return 0;
 }