X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=blobdiff_plain;f=automated-tests%2Fsrc%2Fdali-toolkit%2Fdali-toolkit-test-utils%2Ftoolkit-window.cpp;h=d4c5807324641cb3d995818ae31ce4d948853066;hp=05c48364fed786dc3f822429ccad09f56f7324ad;hb=24a5be6815007836bdbb820a579d2f0a58a3faff;hpb=68b0edb7de863b5198ec0afeac0a7e351dd6bd24 diff --git a/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-window.cpp b/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-window.cpp index 05c4836..d4c5807 100644 --- a/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-window.cpp +++ b/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-window.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019 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. @@ -15,14 +15,19 @@ * */ +// CLASS HEADER +#include "toolkit-window-impl.h" + // EXTERNAL INCLUDES #include #include -#include #include -// INTERNAL INCLUDES -#include "toolkit-window.h" +#define DALI_WINDOW_H +#include +#include + +using AdaptorImpl = Dali::Internal::Adaptor::Adaptor; namespace Dali { @@ -38,32 +43,35 @@ namespace Internal namespace Adaptor { -class Window : public Dali::BaseObject +Window::Window( const PositionSize& positionSize ) +: SceneHolder( positionSize ), + mFocusChangeSignal(), + mVisibilityChangedSignal() { -public: - - Window() - { - } - - virtual ~Window() - { - } - - static Window* New(const PositionSize& positionSize, const std::string& name, const std::string& className, bool isTransparent) - { - return new Window(); - } +} - static Dali::Window Get( Dali::Actor actor ) - { - return Dali::Window(); - } -}; +Window* Window::New(const PositionSize& positionSize, const std::string& name, const std::string& className, bool isTransparent) +{ + return new Window( positionSize ); +} } // Adaptor } // Internal +inline Internal::Adaptor::Window& GetImplementation(Dali::Window& window) +{ + DALI_ASSERT_ALWAYS( window && "Window handle is empty" ); + BaseObject& object = window.GetBaseObject(); + return static_cast(object); +} + +inline const Internal::Adaptor::Window& GetImplementation(const Dali::Window& window) +{ + DALI_ASSERT_ALWAYS( window && "Window handle is empty" ); + const BaseObject& object = window.GetBaseObject(); + return static_cast(object); +} + Window::Window() { } @@ -72,26 +80,94 @@ Window::~Window() { } +Window::Window( const Window& copy ) = default; + +Window& Window::operator=( const Window& rhs ) = default; + +Window::Window( Window&& rhs ) = default; + +Window& Window::operator=( Window&& rhs ) = default; + Dali::Window Window::New( PositionSize windowPosition, const std::string& name, bool isTransparent ) { - Internal::Adaptor::Window* window = Internal::Adaptor::Window::New( windowPosition, name, "", isTransparent ); - return Window( window ); + return New( windowPosition, name, "", 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 ); - return Window( window ); + + Dali::Window result( window ); + + // This will also emit the window created signals + AdaptorImpl::GetImpl( AdaptorImpl::Get() ).AddWindow( window ); + + return result; +} + +Window::Window( Internal::Adaptor::Window* window ) +: BaseHandle( window ) +{ +} + +Integration::Scene Window::GetScene() +{ + return GetImplementation( *this ).GetScene(); +} + +Dali::RenderSurfaceInterface& Window::GetRenderSurface() +{ + return GetImplementation( *this ).GetRenderSurface(); +} + +void Window::Add( Actor actor ) +{ + GetImplementation( *this ).Add( actor ); +} + +void Window::Remove( Actor actor ) +{ + GetImplementation( *this ).Remove( actor ); } Dali::Layer Window::GetRootLayer() const { - return Dali::Stage::GetCurrent().GetRootLayer(); + return GetImplementation( *this ).GetRootLayer(); } -Window::Window( Internal::Adaptor::Window* window ) -: BaseHandle( window ) +void Window::SetBackgroundColor( const Vector4& color ) +{ + GetImplementation( *this ).SetBackgroundColor( color ); +} + +Vector4 Window::GetBackgroundColor() const +{ + return GetImplementation( *this ).GetBackgroundColor(); +} + +void Window::Raise() +{ + GetImplementation( *this ).mFocusChangeSignal.Emit(*this, true); +} + +void Window::Hide() +{ + GetImplementation( *this ).mVisibilityChangedSignal.Emit( *this, false ); +} + +FocusChangeSignalType& Window::FocusChangeSignal() +{ + return GetImplementation( *this ).mFocusChangeSignal; +} + +Window::KeyEventSignalType& Window::KeyEventSignal() +{ + return GetImplementation( *this ).KeyEventSignal(); +} + +Window::TouchSignalType& Window::TouchSignal() { + return GetImplementation( *this ).TouchSignal(); } namespace DevelWindow @@ -99,17 +175,54 @@ namespace DevelWindow Window Get( Actor actor ) { - return Internal::Adaptor::Window::Get( actor ); + Internal::Adaptor::Window* windowImpl = nullptr; + + if ( Dali::Adaptor::IsAvailable() ) + { + windowImpl = static_cast( AdaptorImpl::GetImpl( AdaptorImpl::Get() ).GetWindow( actor ) ); + } + + return Dali::Window( windowImpl ); +} + +Window DownCast( BaseHandle handle ) +{ + Internal::Adaptor::Window* windowImpl = nullptr; + if ( Dali::Adaptor::IsAvailable() ) + { + windowImpl = dynamic_cast( handle.GetObjectPtr()); + } + return Dali::Window( windowImpl ); +} + +void AddFrameRenderedCallback( Window window, std::unique_ptr< CallbackBase > callback, int32_t frameId ) +{ + CallbackBase::Execute( *callback, frameId ); +} + +void AddFramePresentedCallback( Window window, std::unique_ptr< CallbackBase > callback, int32_t frameId ) +{ + CallbackBase::Execute( *callback, frameId ); +} + +EventProcessingFinishedSignalType& EventProcessingFinishedSignal( Window window ) +{ + return GetImplementation( window ).GetScene().EventProcessingFinishedSignal(); +} + +KeyEventGeneratedSignalType& KeyEventGeneratedSignal( Window window ) +{ + return GetImplementation( window ).KeyEventGeneratedSignal(); } -KeyEventSignalType& KeyEventSignal( Window window ) +WheelEventSignalType& WheelEventSignal( Window window ) { - return Dali::Stage::GetCurrent().KeyEventSignal(); + return GetImplementation( window ).WheelEventSignal(); } -TouchSignalType& TouchSignal( Window window ) +VisibilityChangedSignalType& VisibilityChangedSignal( Window window ) { - return Dali::Stage::GetCurrent().TouchSignal(); + return GetImplementation( window ).mVisibilityChangedSignal; } } // namespace DevelWindow