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=b770e14ccfc737b77941f997c94d6f1ca2be98ed;hp=1424f1ad8098ca6cb715e23dbe41c73ed95a3637;hb=HEAD;hpb=65f6c9e91e0efbee208894b4cb1f9334a129b628 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 1424f1a..b770e14 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) 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. @@ -21,21 +21,17 @@ // EXTERNAL INCLUDES #include #include -#include #include +#include #define DALI_WINDOW_H -#include +#include #include -// INTERNAL INCLUDES -#include "test-render-surface.h" - using AdaptorImpl = Dali::Internal::Adaptor::Adaptor; namespace Dali { - class Window; /******************************************************************************** @@ -46,30 +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); } -} // Adaptor -} // Internal +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); +} + +} // 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(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(object); } @@ -82,88 +110,187 @@ Window::~Window() { } -Window::Window(const Window& handle) -: BaseHandle( handle ) +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) { + return New(windowPosition, name, "", isTransparent); } -Window& Window::operator=(const Window& rhs) +Dali::Window Window::New(PositionSize windowPosition, const std::string& name, const std::string& className, bool isTransparent) { - BaseHandle::operator=(rhs); - return *this; + Internal::Adaptor::Window* window = Internal::Adaptor::Window::New(windowPosition, name, className, isTransparent); + + Dali::Window result(window); + + // This will also emit the window created signals + AdaptorImpl::GetImpl(AdaptorImpl::Get()).AddWindow(window); + + return result; } -Dali::Window Window::New( PositionSize windowPosition, const std::string& name, bool isTransparent ) +Window Window::DownCast(BaseHandle handle) { - return New( windowPosition, name, "", isTransparent ); + Internal::Adaptor::Window* windowImpl = nullptr; + if(Dali::Adaptor::IsAvailable()) + { + windowImpl = dynamic_cast(handle.GetObjectPtr()); + } + return Dali::Window(windowImpl); } -Dali::Window Window::New(PositionSize windowPosition, const std::string& name, const std::string& className, bool isTransparent ) +Window::Window(Internal::Adaptor::Window* window) +: BaseHandle(window) { - Internal::Adaptor::Window* window = Internal::Adaptor::Window::New( windowPosition, name, className, isTransparent ); +} - Dali::Window result( window ); +Integration::Scene Window::GetScene() +{ + return GetImplementation(*this).GetScene(); +} - // This will also emit the window created signals - AdaptorImpl::GetImpl( AdaptorImpl::Get() ).AddWindow( window ); +Dali::RenderSurfaceInterface& Window::GetRenderSurface() +{ + return GetImplementation(*this).GetRenderSurface(); +} - return result; +void Window::Add(Actor actor) +{ + GetImplementation(*this).Add(actor); } -Window::Window( Internal::Adaptor::Window* window ) -: BaseHandle( window ) +void Window::Remove(Actor actor) { + GetImplementation(*this).Remove(actor); } -Integration::Scene Window::GetScene() +Dali::Layer Window::GetRootLayer() const { - return GetImplementation( *this ).GetScene(); + return GetImplementation(*this).GetRootLayer(); } -Integration::RenderSurface& Window::GetRenderSurface() +void Window::SetBackgroundColor(const Vector4& color) { - return GetImplementation( *this ).GetRenderSurface(); + GetImplementation(*this).SetBackgroundColor(color); } -namespace DevelWindow +Vector4 Window::GetBackgroundColor() const +{ + return GetImplementation(*this).GetBackgroundColor(); +} + +void Window::Raise() +{ + GetImplementation(*this).mFocusChangeSignal.Emit(*this, true); +} + +void Window::Show() +{ + GetImplementation(*this).mVisible = true; + GetImplementation(*this).mVisibilityChangedSignal.Emit(*this, true); +} + +void Window::Hide() +{ + 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; +} + +ResizeSignalType& Window::ResizeSignal() +{ + return GetImplementation(*this).mResizeSignal; +} + +Window::KeyEventSignalType& Window::KeyEventSignal() +{ + return GetImplementation(*this).KeyEventSignal(); +} + +Window::TouchEventSignalType& Window::TouchedSignal() { + return GetImplementation(*this).TouchedSignal(); +} -Window Get( Actor actor ) +Dali::RenderTaskList Window::GetRenderTaskList() +{ + return GetImplementation(*this).GetRenderTaskList(); +} + +namespace DevelWindow +{ +Window Get(Actor actor) { Internal::Adaptor::Window* windowImpl = nullptr; - if ( Dali::Adaptor::IsAvailable() ) + if(Dali::Adaptor::IsAvailable()) { - windowImpl = static_cast( AdaptorImpl::GetImpl( AdaptorImpl::Get() ).GetWindow( actor ) ); + windowImpl = static_cast(AdaptorImpl::GetImpl(AdaptorImpl::Get()).GetWindow(actor)); } - return Dali::Window( windowImpl ); + return Dali::Window(windowImpl); +} + +void SetPositionSize(Window window, PositionSize positionSize) +{ + GetImplementation(window).SetPositionSize(positionSize); } -EventProcessingFinishedSignalType& EventProcessingFinishedSignal( Window window ) +int GetPhysicalOrientation(Window window) { - return GetImplementation( window ).GetScene().EventProcessingFinishedSignal(); + return GetImplementation(window).mRotationAngle; } -KeyEventSignalType& KeyEventSignal( Window window ) +void AddFrameRenderedCallback(Window window, std::unique_ptr callback, int32_t frameId) { - return GetImplementation( window ).KeyEventSignal(); + CallbackBase::Execute(*callback, frameId); } -KeyEventGeneratedSignalType& KeyEventGeneratedSignal( Window window ) +void AddFramePresentedCallback(Window window, std::unique_ptr callback, int32_t frameId) { - return GetImplementation( window ).KeyEventGeneratedSignal(); + CallbackBase::Execute(*callback, frameId); } -TouchSignalType& TouchSignal( Window window ) +EventProcessingFinishedSignalType& EventProcessingFinishedSignal(Window window) { - return GetImplementation( window ).TouchSignal(); + return GetImplementation(window).GetScene().EventProcessingFinishedSignal(); } -WheelEventSignalType& WheelEventSignal( Window window ) +KeyEventGeneratedSignalType& KeyEventGeneratedSignal(Window window) { - return GetImplementation( window ).WheelEventSignal(); + return GetImplementation(window).KeyEventGeneratedSignal(); } + +WheelEventSignalType& WheelEventSignal(Window window) +{ + return GetImplementation(window).WheelEventSignal(); +} + +WheelEventGeneratedSignalType& WheelEventGeneratedSignal(Window window) +{ + return GetImplementation(window).WheelEventGeneratedSignal(); +} + +VisibilityChangedSignalType& VisibilityChangedSignal(Window window) +{ + return GetImplementation(window).mVisibilityChangedSignal; +} + } // namespace DevelWindow -} // Dali +} // namespace Dali