[dali_2.3.21] Merge branch 'devel/master'
[platform/core/uifw/dali-toolkit.git] / automated-tests / src / dali-toolkit / dali-toolkit-test-utils / toolkit-window.cpp
index 9ab5021..b770e14 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2024 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.
@@ -22,6 +22,7 @@
 #include <dali/public-api/actors/actor.h>
 #include <dali/public-api/actors/layer.h>
 #include <dali/public-api/object/base-object.h>
+#include <dali/public-api/render-tasks/render-task-list.h>
 
 #define DALI_WINDOW_H
 #include <dali/integration-api/adaptor-framework/adaptor.h>
@@ -31,7 +32,6 @@ using AdaptorImpl = Dali::Internal::Adaptor::Adaptor;
 
 namespace Dali
 {
-
 class Window;
 
 /********************************************************************************
@@ -42,34 +42,62 @@ namespace Internal
 {
 namespace Adaptor
 {
-
-Window::Window( const PositionSize& positionSize )
-: SceneHolder( positionSize ),
+Window::Window(const PositionSize& positionSize)
+: SceneHolder(positionSize),
   mFocusChangeSignal(),
   mResizeSignal(),
   mRotationAngle(90), // dummy angle for test coverage
+  mVisible(true),
   mVisibilityChangedSignal()
 {
 }
 
 Window* Window::New(const PositionSize& positionSize, const std::string& name, const std::string& className, bool isTransparent)
 {
-  return new Window( positionSize );
+  return new Window(positionSize);
+}
+
+Dali::Window::WindowPosition Window::GetPosition() const
+{
+  PositionSize positionSize = mRenderSurface.GetPositionSize();
+
+  return Dali::Window::WindowPosition(positionSize.x, positionSize.y);
+}
+
+PositionSize Window::GetPositionSize() const
+{
+  return mRenderSurface.GetPositionSize();
+}
+
+Dali::Window::WindowSize Window::GetSize() const
+{
+  PositionSize positionSize = mRenderSurface.GetPositionSize();
+
+  return Dali::Window::WindowSize(positionSize.width, positionSize.height);
+}
+
+void Window::SetPositionSize(PositionSize positionSize)
+{
+  mRenderSurface.MoveResize(positionSize);
+
+  Uint16Pair   newSize(positionSize.width, positionSize.height);
+  Dali::Window handle(this);
+  mResizeSignal.Emit(handle, newSize);
 }
 
-} // Adaptor
-} // Internal
+} // namespace Adaptor
+} // namespace Internal
 
 inline Internal::Adaptor::Window& GetImplementation(Dali::Window& window)
 {
-  DALI_ASSERT_ALWAYS( window && "Window handle is empty" );
+  DALI_ASSERT_ALWAYS(window && "Window handle is empty");
   BaseObject& object = window.GetBaseObject();
   return static_cast<Internal::Adaptor::Window&>(object);
 }
 
 inline const Internal::Adaptor::Window& GetImplementation(const Dali::Window& window)
 {
-  DALI_ASSERT_ALWAYS( window && "Window handle is empty" );
+  DALI_ASSERT_ALWAYS(window && "Window handle is empty");
   const BaseObject& object = window.GetBaseObject();
   return static_cast<const Internal::Adaptor::Window&>(object);
 }
@@ -82,167 +110,187 @@ Window::~Window()
 {
 }
 
-Window::Window( const Window& copy ) = default;
+Window::Window(const Window& copy) = default;
 
-Window& Window::operator=( const Window& rhs ) = default;
+Window& Window::operator=(const Window& rhs) = default;
 
-Window::Window( Window&& rhs ) = default;
+Window::Window(Window&& rhs) = default;
 
-Window& Window::operator=( Window&& rhs ) = default;
+Window& Window::operator=(Window&& rhs) = default;
 
-Dali::Window Window::New( PositionSize windowPosition, const std::string& name, bool isTransparent )
+Dali::Window Window::New(PositionSize windowPosition, const std::string& name, bool isTransparent)
 {
-  return New( windowPosition, name, "", isTransparent );
+  return New(windowPosition, name, "", isTransparent);
 }
 
-Dali::Window Window::New(PositionSize windowPosition, const std::string& name, const std::string& className, bool isTransparent )
+Dali::Window Window::New(PositionSize windowPosition, const std::string& name, const std::string& className, bool isTransparent)
 {
-  Internal::Adaptor::Window* window = Internal::Adaptor::Window::New( windowPosition, name, className, isTransparent );
+  Internal::Adaptor::Window* window = Internal::Adaptor::Window::New(windowPosition, name, className, isTransparent);
 
-  Dali::Window result( window );
+  Dali::Window result(window);
 
   // This will also emit the window created signals
-  AdaptorImpl::GetImpl( AdaptorImpl::Get() ).AddWindow( window );
+  AdaptorImpl::GetImpl(AdaptorImpl::Get()).AddWindow(window);
 
   return result;
 }
 
-Window::Window( Internal::Adaptor::Window* window )
-: BaseHandle( window )
+Window Window::DownCast(BaseHandle handle)
+{
+  Internal::Adaptor::Window* windowImpl = nullptr;
+  if(Dali::Adaptor::IsAvailable())
+  {
+    windowImpl = dynamic_cast<Dali::Internal::Adaptor::Window*>(handle.GetObjectPtr());
+  }
+  return Dali::Window(windowImpl);
+}
+
+Window::Window(Internal::Adaptor::Window* window)
+: BaseHandle(window)
 {
 }
 
 Integration::Scene Window::GetScene()
 {
-  return GetImplementation( *this ).GetScene();
+  return GetImplementation(*this).GetScene();
 }
 
 Dali::RenderSurfaceInterface& Window::GetRenderSurface()
 {
-  return GetImplementation( *this ).GetRenderSurface();
+  return GetImplementation(*this).GetRenderSurface();
 }
 
-void Window::Add( Actor actor )
+void Window::Add(Actor actor)
 {
-  GetImplementation( *this ).Add( actor );
+  GetImplementation(*this).Add(actor);
 }
 
-void Window::Remove( Actor actor )
+void Window::Remove(Actor actor)
 {
-  GetImplementation( *this ).Remove( actor );
+  GetImplementation(*this).Remove(actor);
 }
 
 Dali::Layer Window::GetRootLayer() const
 {
-  return GetImplementation( *this ).GetRootLayer();
+  return GetImplementation(*this).GetRootLayer();
 }
 
-void Window::SetBackgroundColor( const Vector4& color )
+void Window::SetBackgroundColor(const Vector4& color)
 {
-  GetImplementation( *this ).SetBackgroundColor( color );
+  GetImplementation(*this).SetBackgroundColor(color);
 }
 
 Vector4 Window::GetBackgroundColor() const
 {
-  return GetImplementation( *this ).GetBackgroundColor();
+  return GetImplementation(*this).GetBackgroundColor();
 }
 
 void Window::Raise()
 {
-  GetImplementation( *this ).mFocusChangeSignal.Emit(*this, true);
+  GetImplementation(*this).mFocusChangeSignal.Emit(*this, true);
+}
+
+void Window::Show()
+{
+  GetImplementation(*this).mVisible = true;
+  GetImplementation(*this).mVisibilityChangedSignal.Emit(*this, true);
 }
 
 void Window::Hide()
 {
-  GetImplementation( *this ).mVisibilityChangedSignal.Emit( *this, false );
+  GetImplementation(*this).mVisible = false;
+  GetImplementation(*this).mVisibilityChangedSignal.Emit(*this, false);
+}
+
+bool Window::IsVisible() const
+{
+  return GetImplementation(*this).mVisible;
 }
 
 FocusChangeSignalType& Window::FocusChangeSignal()
 {
-  return GetImplementation( *this ).mFocusChangeSignal;
+  return GetImplementation(*this).mFocusChangeSignal;
 }
 
 ResizeSignalType& Window::ResizeSignal()
 {
-  return GetImplementation( *this ).mResizeSignal;
+  return GetImplementation(*this).mResizeSignal;
 }
 
 Window::KeyEventSignalType& Window::KeyEventSignal()
 {
-  return GetImplementation( *this ).KeyEventSignal();
+  return GetImplementation(*this).KeyEventSignal();
 }
 
 Window::TouchEventSignalType& Window::TouchedSignal()
 {
-  return GetImplementation( *this ).TouchedSignal();
+  return GetImplementation(*this).TouchedSignal();
 }
 
-namespace DevelWindow
+Dali::RenderTaskList Window::GetRenderTaskList()
 {
+  return GetImplementation(*this).GetRenderTaskList();
+}
 
-Window Get( Actor actor )
+namespace DevelWindow
+{
+Window Get(Actor actor)
 {
   Internal::Adaptor::Window* windowImpl = nullptr;
 
-  if ( Dali::Adaptor::IsAvailable() )
+  if(Dali::Adaptor::IsAvailable())
   {
-    windowImpl = static_cast<Internal::Adaptor::Window*>( AdaptorImpl::GetImpl( AdaptorImpl::Get() ).GetWindow( actor ) );
+    windowImpl = static_cast<Internal::Adaptor::Window*>(AdaptorImpl::GetImpl(AdaptorImpl::Get()).GetWindow(actor));
   }
 
-  return Dali::Window( windowImpl );
+  return Dali::Window(windowImpl);
 }
 
-Window DownCast( BaseHandle handle )
+void SetPositionSize(Window window, PositionSize positionSize)
 {
-  Internal::Adaptor::Window* windowImpl = nullptr;
-  if ( Dali::Adaptor::IsAvailable() )
-  {
-    windowImpl = dynamic_cast<Dali::Internal::Adaptor::Window*>( handle.GetObjectPtr());
-  }
-  return Dali::Window( windowImpl );
+  GetImplementation(window).SetPositionSize(positionSize);
 }
 
-void SetPositionSize(Window window, PositionSize positionSize)
+int GetPhysicalOrientation(Window window)
 {
-  Uint16Pair newSize(positionSize.width, positionSize.height);
-  GetImplementation( window ).mResizeSignal.Emit(window,newSize);
+  return GetImplementation(window).mRotationAngle;
 }
 
-int GetPhysicalOrientation(Window window)
+void AddFrameRenderedCallback(Window window, std::unique_ptr<CallbackBase> callback, int32_t frameId)
 {
-  return GetImplementation( window ).mRotationAngle;
+  CallbackBase::Execute(*callback, frameId);
 }
 
-void AddFrameRenderedCallback( Window window, std::unique_ptr< CallbackBase > callback, int32_t frameId )
+void AddFramePresentedCallback(Window window, std::unique_ptr<CallbackBase> callback, int32_t frameId)
 {
-  CallbackBase::Execute( *callback, frameId );
+  CallbackBase::Execute(*callback, frameId);
 }
 
-void AddFramePresentedCallback( Window window, std::unique_ptr< CallbackBase > callback, int32_t frameId )
+EventProcessingFinishedSignalType& EventProcessingFinishedSignal(Window window)
 {
-  CallbackBase::Execute( *callback, frameId );
+  return GetImplementation(window).GetScene().EventProcessingFinishedSignal();
 }
 
-EventProcessingFinishedSignalType& EventProcessingFinishedSignal( Window window )
+KeyEventGeneratedSignalType& KeyEventGeneratedSignal(Window window)
 {
-  return GetImplementation( window ).GetScene().EventProcessingFinishedSignal();
+  return GetImplementation(window).KeyEventGeneratedSignal();
 }
 
-KeyEventGeneratedSignalType& KeyEventGeneratedSignal( Window window )
+WheelEventSignalType& WheelEventSignal(Window window)
 {
-  return GetImplementation( window ).KeyEventGeneratedSignal();
+  return GetImplementation(window).WheelEventSignal();
 }
 
-WheelEventSignalType& WheelEventSignal( Window window )
+WheelEventGeneratedSignalType& WheelEventGeneratedSignal(Window window)
 {
-  return GetImplementation( window ).WheelEventSignal();
+  return GetImplementation(window).WheelEventGeneratedSignal();
 }
 
-VisibilityChangedSignalType& VisibilityChangedSignal( Window window )
+VisibilityChangedSignalType& VisibilityChangedSignal(Window window)
 {
-  return GetImplementation( window ).mVisibilityChangedSignal;
+  return GetImplementation(window).mVisibilityChangedSignal;
 }
 
 } // namespace DevelWindow
 
-} // Dali
+} // namespace Dali