Added integration API to retrieve which Scene a given actor belongs to 79/205679/4
authorRichard Huang <r.huang@samsung.com>
Wed, 8 May 2019 10:49:24 +0000 (11:49 +0100)
committerRichard Huang <r.huang@samsung.com>
Thu, 9 May 2019 15:07:58 +0000 (16:07 +0100)
Change-Id: I2d65b9122ad84dd33a2f8578cbf501aee6483930

automated-tests/src/dali/utc-Dali-Scene.cpp
dali/integration-api/scene.cpp
dali/integration-api/scene.h

index 062679c..4aedee0 100644 (file)
@@ -324,6 +324,23 @@ int UtcDaliSceneGetLayer(void)
   END_TEST;
 }
 
+int UtcDaliSceneGet(void)
+{
+  TestApplication application;
+  tet_infoline("Testing Dali::Integration::Scene::Get");
+
+  Dali::Integration::Scene scene = application.GetScene();
+
+  Actor actor = Actor::New();
+  DALI_TEST_CHECK( Dali::Integration::Scene() == Dali::Integration::Scene::Get( actor ) );
+
+  scene.Add( actor );
+
+  DALI_TEST_CHECK( scene == Dali::Integration::Scene::Get( actor ) );
+
+  END_TEST;
+}
+
 int UtcDaliSceneEventProcessingFinishedP(void)
 {
   TestApplication application;
index 0a1f690..9d89f31 100644 (file)
@@ -64,12 +64,12 @@ Scene& Scene::operator=( const Scene& rhs )
   return *this;
 }
 
-void Scene::Add( Actor& actor )
+void Scene::Add( Actor actor )
 {
   GetImplementation(*this).Add( GetImplementation(actor) );
 }
 
-void Scene::Remove( Actor& actor )
+void Scene::Remove( Actor actor )
 {
   GetImplementation(*this).Remove( GetImplementation(actor) );
 }
@@ -119,6 +119,11 @@ Integration::RenderSurface* Scene::GetSurface() const
   return GetImplementation(*this).GetSurface();
 }
 
+Integration::Scene Scene::Get( Actor actor )
+{
+  return Dali::Integration::Scene( &GetImplementation( actor ).GetScene() );
+}
+
 void Scene::QueueEvent( const Integration::Event& event )
 {
   GetImplementation(*this).QueueEvent( event );
index 3e2cbf5..f1b3059 100755 (executable)
@@ -114,7 +114,7 @@ public:
    * @pre The actor has been initialized.
    * @pre The actor does not have a parent.
    */
-  void Add(Actor& actor);
+  void Add(Actor actor);
 
   /**
    * @brief Removes a child Actor from the Scene.
@@ -123,7 +123,7 @@ public:
    * @param[in] actor The child
    * @pre The actor has been added to the stage.
    */
-  void Remove(Actor& actor);
+  void Remove(Actor actor);
 
   /**
    * @brief Returns the size of the Scene in pixels as a Vector.
@@ -194,6 +194,12 @@ public:
   Integration::RenderSurface* GetSurface() const;
 
   /**
+   * @brief Retrieve the Scene that the given actor belongs to.
+   * @return The Scene.
+   */
+  static Integration::Scene Get( Actor actor );
+
+  /**
    * This function is called when an event is queued.
    * @param[in] event A event to queue.
    */