From 849aad40edfc7f38e908c9783a7446eb867394b6 Mon Sep 17 00:00:00 2001 From: Adeel Kazmi Date: Tue, 25 Oct 2022 16:09:36 +0100 Subject: [PATCH] Changes required after Window::DownCast addition Change-Id: Ibf6e18fa9b05fa226846bbcd25178f9f58454fe4 --- .../dali-toolkit-test-utils/toolkit-window.cpp | 145 ++++++++++----------- .../dali-toolkit-test-utils/toolkit-window.h | 4 +- .../focus-manager/keyboard-focus-manager-impl.cpp | 4 +- 3 files changed, 75 insertions(+), 78 deletions(-) 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 2746ad9..b74a8c0 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) 2020 Samsung Electronics Co., Ltd. + * Copyright (c) 2022 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. @@ -31,7 +31,6 @@ using AdaptorImpl = Dali::Internal::Adaptor::Adaptor; namespace Dali { - class Window; /******************************************************************************** @@ -42,9 +41,8 @@ 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 @@ -55,10 +53,10 @@ Window::Window( const PositionSize& positionSize ) 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 +Dali::Window::WindowPosition Window::GetPosition() const { PositionSize positionSize = mRenderSurface.GetPositionSize(); @@ -81,24 +79,24 @@ void Window::SetPositionSize(PositionSize positionSize) { mRenderSurface.MoveResize(positionSize); - Uint16Pair newSize(positionSize.width, positionSize.height); + 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(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); } @@ -111,177 +109,176 @@ 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(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::Hide() { - GetImplementation( *this ).mVisibilityChangedSignal.Emit( *this, false ); - GetImplementation( *this ).mVisible = false; + GetImplementation(*this).mVisibilityChangedSignal.Emit(*this, false); + GetImplementation(*this).mVisible = false; } bool Window::IsVisible() const { - return GetImplementation( *this ).mVisible; + 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 { - -Window Get( Actor actor ) +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 ); -} - -Window DownCast( BaseHandle handle ) -{ - Internal::Adaptor::Window* windowImpl = nullptr; - if ( Dali::Adaptor::IsAvailable() ) - { - windowImpl = dynamic_cast( handle.GetObjectPtr()); - } - return Dali::Window( windowImpl ); + return Dali::Window(windowImpl); } void SetPositionSize(Window window, PositionSize positionSize) { - GetImplementation( window ).SetPositionSize(positionSize); + GetImplementation(window).SetPositionSize(positionSize); } int GetPhysicalOrientation(Window window) { - return GetImplementation( window ).mRotationAngle; + return GetImplementation(window).mRotationAngle; } -void AddFrameRenderedCallback( Window window, std::unique_ptr< CallbackBase > callback, int32_t frameId ) +void AddFrameRenderedCallback(Window window, std::unique_ptr callback, int32_t frameId) { - CallbackBase::Execute( *callback, frameId ); + CallbackBase::Execute(*callback, frameId); } -void AddFramePresentedCallback( Window window, std::unique_ptr< CallbackBase > callback, int32_t frameId ) +void AddFramePresentedCallback(Window window, std::unique_ptr callback, int32_t frameId) { - CallbackBase::Execute( *callback, frameId ); + CallbackBase::Execute(*callback, frameId); } -EventProcessingFinishedSignalType& EventProcessingFinishedSignal( Window window ) +EventProcessingFinishedSignalType& EventProcessingFinishedSignal(Window window) { - return GetImplementation( window ).GetScene().EventProcessingFinishedSignal(); + return GetImplementation(window).GetScene().EventProcessingFinishedSignal(); } -KeyEventGeneratedSignalType& KeyEventGeneratedSignal( Window window ) +KeyEventGeneratedSignalType& KeyEventGeneratedSignal(Window window) { - return GetImplementation( window ).KeyEventGeneratedSignal(); + return GetImplementation(window).KeyEventGeneratedSignal(); } -WheelEventSignalType& WheelEventSignal( Window window ) +WheelEventSignalType& WheelEventSignal(Window window) { - return GetImplementation( window ).WheelEventSignal(); + return GetImplementation(window).WheelEventSignal(); } -WheelEventGeneratedSignalType& WheelEventGeneratedSignal( Window window ) +WheelEventGeneratedSignalType& WheelEventGeneratedSignal(Window window) { - return GetImplementation( window ).WheelEventGeneratedSignal(); + 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 diff --git a/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-window.h b/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-window.h index 836fd1f..e9edae0 100644 --- a/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-window.h +++ b/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-window.h @@ -68,7 +68,8 @@ public: Window(const Window& handle); Window& operator=(const Window& rhs); Window(Window&& rhs); - Window& operator=(Window&& rhs); + Window& operator=(Window&& rhs); + static Window DownCast(BaseHandle handle); Integration::Scene GetScene(); Dali::RenderSurfaceInterface& GetRenderSurface(); @@ -101,7 +102,6 @@ typedef Signal WheelEventGeneratedSignalType; typedef Signal VisibilityChangedSignalType; Dali::Window Get(Actor actor); -Dali::Window DownCast(BaseHandle handle); void SetPositionSize(Window window, PositionSize positionSize); int GetPhysicalOrientation(Window window); void AddFrameRenderedCallback(Window window, std::unique_ptr callback, int32_t frameId); diff --git a/dali-toolkit/internal/focus-manager/keyboard-focus-manager-impl.cpp b/dali-toolkit/internal/focus-manager/keyboard-focus-manager-impl.cpp index bcbddec..707aa68 100644 --- a/dali-toolkit/internal/focus-manager/keyboard-focus-manager-impl.cpp +++ b/dali-toolkit/internal/focus-manager/keyboard-focus-manager-impl.cpp @@ -149,7 +149,7 @@ void KeyboardFocusManager::OnAdaptorInit() (*iter).TouchedSignal().Connect(mSlotDelegate, &KeyboardFocusManager::OnTouch); (*iter).WheelEventGeneratedSignal().Connect(mSlotDelegate, &KeyboardFocusManager::OnCustomWheelEvent); (*iter).WheelEventSignal().Connect(mSlotDelegate, &KeyboardFocusManager::OnWheelEvent); - Dali::Window window = DevelWindow::DownCast(*iter); + Window window = Window::DownCast(*iter); if(window) { window.FocusChangeSignal().Connect(mSlotDelegate, &KeyboardFocusManager::OnWindowFocusChanged); @@ -167,7 +167,7 @@ void KeyboardFocusManager::OnSceneHolderCreated(Dali::Integration::SceneHolder& sceneHolder.TouchedSignal().Connect(mSlotDelegate, &KeyboardFocusManager::OnTouch); sceneHolder.WheelEventGeneratedSignal().Connect(mSlotDelegate, &KeyboardFocusManager::OnCustomWheelEvent); sceneHolder.WheelEventSignal().Connect(mSlotDelegate, &KeyboardFocusManager::OnWheelEvent); - Dali::Window window = DevelWindow::DownCast(sceneHolder); + Window window = Window::DownCast(sceneHolder); if(window) { window.FocusChangeSignal().Connect(mSlotDelegate, &KeyboardFocusManager::OnWindowFocusChanged); -- 2.7.4