Added helper function to retrieve which window a given actor is added to 78/205678/5
authorRichard Huang <r.huang@samsung.com>
Wed, 8 May 2019 10:44:15 +0000 (11:44 +0100)
committerRichard Huang <r.huang@samsung.com>
Thu, 9 May 2019 15:07:23 +0000 (16:07 +0100)
Change-Id: I610f534ea131ec5ebc9fee5e0e0debba22d65bd4

dali/devel-api/adaptor-framework/window-devel.cpp
dali/devel-api/adaptor-framework/window-devel.h
dali/internal/adaptor/common/adaptor-impl.cpp
dali/internal/adaptor/common/adaptor-impl.h
dali/internal/window-system/common/window-impl.cpp
dali/internal/window-system/common/window-impl.h

index 9453a93..2496c21 100644 (file)
@@ -35,6 +35,11 @@ void SetPositionSize( Window window, PositionSize positionSize )
   GetImplementation( window ).SetPositionSize( positionSize );
 }
 
+Window Get( Actor actor )
+{
+  return Internal::Adaptor::Window::Get( actor );
+}
+
 EventProcessingFinishedSignalType& EventProcessingFinishedSignal( Window window )
 {
   return GetImplementation( window ).EventProcessingFinishedSignal();
index 0006b2b..e80e55a 100644 (file)
@@ -47,6 +47,14 @@ typedef Signal< void (const WheelEvent&) > WheelEventSignalType;   ///< Touched
 DALI_ADAPTOR_API void SetPositionSize( Window window, PositionSize positionSize );
 
 /**
+ * @brief Retrieve the window that the given actor is added to.
+ *
+ * @param[in] actor The actor
+ * @return The window the actor is added to or an empty handle if the actor is not added to any window.
+ */
+DALI_ADAPTOR_API Window Get( Actor actor );
+
+/**
  * @brief This signal is emitted just after the event processing is finished.
  *
  * @param[in] window The window instance
index a28c2c0..9a2d608 100755 (executable)
@@ -971,6 +971,21 @@ bool Adaptor::ProcessCoreEventsFromIdle()
   return false;
 }
 
+Dali::Internal::Adaptor::SceneHolder* Adaptor::GetWindow( Dali::Actor& actor )
+{
+  Dali::Integration::Scene scene = Dali::Integration::Scene::Get( actor );
+
+  for( auto window : mWindows )
+  {
+    if ( scene == window->GetScene() )
+    {
+      return window.Get();
+    }
+  }
+
+  return nullptr;
+}
+
 Adaptor::Adaptor(Dali::Integration::SceneHolder window, Dali::Adaptor& adaptor, Dali::RenderSurfaceInterface* surface, EnvironmentOptions* environmentOptions)
 : mResizedSignal(),
   mLanguageChangedSignal(),
index 4453269..2f32da6 100755 (executable)
@@ -295,6 +295,14 @@ public: // AdaptorInternalServices implementation
    */
   bool RemoveWindow( Dali::Internal::Adaptor::SceneHolder* childWindow );
 
+  /**
+   * @brief Retrieve the window that the given actor is added to.
+   *
+   * @param[in] actor The actor
+   * @return The window the actor is added to or a null pointer if the actor is not added to any widnow.
+   */
+  Dali::Internal::Adaptor::SceneHolder* GetWindow( Dali::Actor& actor );
+
 public:
 
   /**
index 871bdfd..dc16ab4 100644 (file)
@@ -655,6 +655,18 @@ bool Window::SetRotationObserver( RotationObserver* observer )
   return false;
 }
 
+Dali::Window Window::Get( Dali::Actor actor )
+{
+  Internal::Adaptor::Window* windowImpl = nullptr;
+
+  if ( Internal::Adaptor::Adaptor::IsAvailable() )
+  {
+    Dali::Internal::Adaptor::Adaptor& adaptor = Internal::Adaptor::Adaptor::GetImplementation( Internal::Adaptor::Adaptor::Get() );
+    windowImpl = static_cast<Internal::Adaptor::Window*>( adaptor.GetWindow( actor ) );
+  }
+
+  return Dali::Window( windowImpl );
+}
 
 } // Adaptor
 
index 31da82b..983dc2c 100644 (file)
@@ -341,6 +341,11 @@ public:
    */
   bool SetRotationObserver( RotationObserver* observer );
 
+  /**
+   * @copydoc Dali::DevelWindow::Get()
+   */
+  static Dali::Window Get( Dali::Actor actor );
+
 public: // Dali::Internal::Adaptor::SceneHolder
 
   /**