From b3a97840ef9163145f3adc947cf1c6679911d754 Mon Sep 17 00:00:00 2001 From: Jiyun Yang Date: Thu, 22 Aug 2019 17:15:44 +0900 Subject: [PATCH] Support scene holder instead of window in keyinput/keyboard focus Change-Id: I22682ef91158a9f2f8850379b04a9dc601057883 Signed-off-by: Jiyun Yang --- .../src/dali-toolkit-internal/CMakeLists.txt | 1 + .../src/dali-toolkit-styling/CMakeLists.txt | 1 + .../dali-toolkit-test-utils/toolkit-adaptor-impl.h | 2 + .../dali-toolkit-test-utils/toolkit-adaptor.cpp | 14 ++- .../toolkit-scene-holder-impl.h | 94 +++++++++++++++++ .../toolkit-scene-holder.cpp | 117 +++++++++++++++++++-- .../dali-toolkit-test-utils/toolkit-window.cpp | 36 ++++--- .../focus-manager/keyboard-focus-manager-impl.cpp | 21 ++-- .../focus-manager/keyboard-focus-manager-impl.h | 13 ++- .../focus-manager/keyinput-focus-manager-impl.cpp | 16 +-- .../focus-manager/keyinput-focus-manager-impl.h | 13 ++- 11 files changed, 277 insertions(+), 51 deletions(-) create mode 100644 automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-scene-holder-impl.h diff --git a/automated-tests/src/dali-toolkit-internal/CMakeLists.txt b/automated-tests/src/dali-toolkit-internal/CMakeLists.txt index 4037aac..984e177 100755 --- a/automated-tests/src/dali-toolkit-internal/CMakeLists.txt +++ b/automated-tests/src/dali-toolkit-internal/CMakeLists.txt @@ -52,6 +52,7 @@ LIST(APPEND TC_SOURCES ../dali-toolkit/dali-toolkit-test-utils/toolkit-tts-player.cpp ../dali-toolkit/dali-toolkit-test-utils/toolkit-vector-animation-renderer.cpp ../dali-toolkit/dali-toolkit-test-utils/toolkit-window.cpp + ../dali-toolkit/dali-toolkit-test-utils/toolkit-scene-holder.cpp ../dali-toolkit/dali-toolkit-test-utils/dali-test-suite-utils.cpp ../dali-toolkit/dali-toolkit-test-utils/dali-toolkit-test-suite-utils.cpp ../dali-toolkit/dali-toolkit-test-utils/dummy-control.cpp diff --git a/automated-tests/src/dali-toolkit-styling/CMakeLists.txt b/automated-tests/src/dali-toolkit-styling/CMakeLists.txt index 1c62f77..0b08ff4 100644 --- a/automated-tests/src/dali-toolkit-styling/CMakeLists.txt +++ b/automated-tests/src/dali-toolkit-styling/CMakeLists.txt @@ -38,6 +38,7 @@ LIST(APPEND TC_SOURCES ../dali-toolkit/dali-toolkit-test-utils/toolkit-video-player.cpp ../dali-toolkit/dali-toolkit-test-utils/toolkit-virtual-keyboard.cpp ../dali-toolkit/dali-toolkit-test-utils/toolkit-window.cpp + ../dali-toolkit/dali-toolkit-test-utils/toolkit-scene-holder.cpp ../dali-toolkit/dali-toolkit-test-utils/dummy-control.cpp ../dali-toolkit/dali-toolkit-test-utils/dali-test-suite-utils.cpp ../dali-toolkit/dali-toolkit-test-utils/dali-toolkit-test-suite-utils.cpp diff --git a/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-adaptor-impl.h b/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-adaptor-impl.h index dd7f469..e4b7bd7 100644 --- a/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-adaptor-impl.h +++ b/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-adaptor-impl.h @@ -76,6 +76,7 @@ public: Dali::RenderSurfaceInterface& GetSurface(); Dali::WindowContainer GetWindows(); + Dali::SceneHolderList GetSceneHolders(); Dali::Adaptor::AdaptorSignalType& ResizedSignal(); Dali::Adaptor::AdaptorSignalType& LanguageChangedSignal(); @@ -88,6 +89,7 @@ private: Vector mCallbacks; Dali::WindowContainer mWindows; + Dali::SceneHolderList mSceneHolders; Dali::Adaptor::AdaptorSignalType mResizedSignal; Dali::Adaptor::AdaptorSignalType mLanguageChangedSignal; Dali::Adaptor::WindowCreatedSignalType mWindowCreatedSignal; diff --git a/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-adaptor.cpp b/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-adaptor.cpp index 9071613..fc9f1e7 100644 --- a/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-adaptor.cpp +++ b/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-adaptor.cpp @@ -24,6 +24,7 @@ #include #include +#include #include #include @@ -98,7 +99,8 @@ void Adaptor::Start( Dali::Window window ) if ( window ) { mWindows.push_back( window ); - mWindowCreatedSignal.Emit( window ); + + mSceneHolders.emplace_back( static_cast( &window.GetBaseObject() ) ); } } @@ -141,6 +143,11 @@ Dali::WindowContainer Adaptor::GetWindows() return mWindows; } +Dali::SceneHolderList Adaptor::GetSceneHolders() +{ + return mSceneHolders; +} + Dali::Adaptor::AdaptorSignalType& Adaptor::ResizedSignal() { return mResizedSignal; @@ -235,6 +242,11 @@ Dali::WindowContainer Adaptor::GetWindows() const return mImpl->GetWindows(); } +Dali::SceneHolderList Adaptor::GetSceneHolders() const +{ + return mImpl->GetSceneHolders(); +} + Any Adaptor::GetNativeWindowHandle() { Any window; diff --git a/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-scene-holder-impl.h b/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-scene-holder-impl.h new file mode 100644 index 0000000..62c432e --- /dev/null +++ b/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-scene-holder-impl.h @@ -0,0 +1,94 @@ +#ifndef DALI_TOOLKIT_SCENE_HOLDER_IMPL_H +#define DALI_TOOLKIT_SCENE_HOLDER_IMPL_H + +/* + * Copyright (c) 2019 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. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#include + +#include +#include +#include + +namespace Dali +{ + +namespace Internal +{ + +namespace Adaptor +{ + +class SceneHolder : public Dali::BaseObject +{ +public: + + SceneHolder( const Dali::Rect& positionSize ); + + virtual ~SceneHolder(); + + Dali::Layer GetRootLayer() const; + + void SetBackgroundColor( Vector4 color ); + + Vector4 GetBackgroundColor() const; + + void FeedTouchPoint( Dali::TouchPoint& point, int timeStamp ); + + void FeedWheelEvent( Dali::WheelEvent& wheelEvent ); + + void FeedKeyEvent( Dali::KeyEvent& keyEvent ); + + Dali::Integration::SceneHolder::KeyEventSignalType& KeyEventSignal(); + + Dali::Integration::SceneHolder::KeyEventGeneratedSignalType& KeyEventGeneratedSignal(); + + Dali::Integration::SceneHolder::TouchSignalType& TouchSignal(); + + Dali::Integration::SceneHolder::WheelEventSignalType& WheelEventSignal(); + + Integration::Scene GetScene(); + + Integration::RenderSurface& GetRenderSurface(); + +private: + + TestRenderSurface mRenderSurface; + Integration::Scene mScene; +}; + +} // namespace Adaptor + +} // namespace Internal + +inline Internal::Adaptor::SceneHolder& GetImplementation( Dali::Integration::SceneHolder& sceneHolder ) +{ + DALI_ASSERT_ALWAYS( sceneHolder && "SceneHolder handle is empty" ); + BaseObject& object = sceneHolder.GetBaseObject(); + return static_cast( object ); +} + +inline const Internal::Adaptor::SceneHolder& GetImplementation( const Dali::Integration::SceneHolder& sceneHolder ) +{ + DALI_ASSERT_ALWAYS( sceneHolder && "SceneHolder handle is empty" ); + const BaseObject& object = sceneHolder.GetBaseObject(); + return static_cast( object ); +} + +} // namespace Dali + +#endif // DALI_TOOLKIT_SCENE_HOLDER_IMPL_H diff --git a/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-scene-holder.cpp b/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-scene-holder.cpp index 04afdeb..98ea7dc 100644 --- a/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-scene-holder.cpp +++ b/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-scene-holder.cpp @@ -15,36 +15,112 @@ * */ +#include #include +#include + #include #include #include #include +#include +#include + namespace Dali { +/////////////////////////////////////////////////////////////////////////////// +// +// Dali::Internal::Adaptor::SceneHolder Stub +// +/////////////////////////////////////////////////////////////////////////////// + namespace Internal { namespace Adaptor { -class SceneHolder: public Dali::BaseObject +SceneHolder::SceneHolder( const Dali::Rect& positionSize ) +: mRenderSurface( positionSize ), + mScene( Dali::Integration::Scene::New( mRenderSurface ) ) +{ +} + +SceneHolder::~SceneHolder() { +} -}; +void SceneHolder::SetBackgroundColor( Vector4 color ) +{ + return mScene.SetBackgroundColor( color ); +} -} // Adaptor +Vector4 SceneHolder::GetBackgroundColor() const +{ + return mScene.GetBackgroundColor(); +} -} // Internal +void SceneHolder::FeedTouchPoint( Dali::TouchPoint& point, int timeStamp ) +{ +} + +void SceneHolder::FeedWheelEvent( Dali::WheelEvent& wheelEvent ) +{ +} + +void SceneHolder::FeedKeyEvent( Dali::KeyEvent& keyEvent ) +{ +} + +Dali::Integration::SceneHolder::KeyEventSignalType& SceneHolder::KeyEventSignal() +{ + return mScene.KeyEventSignal(); +} + +Dali::Integration::SceneHolder::KeyEventGeneratedSignalType& SceneHolder::KeyEventGeneratedSignal() +{ + return mScene.KeyEventGeneratedSignal(); +} + +Dali::Integration::SceneHolder::TouchSignalType& SceneHolder::TouchSignal() +{ + return mScene.TouchSignal(); +} + +Dali::Integration::SceneHolder::WheelEventSignalType& SceneHolder::WheelEventSignal() +{ + return mScene.WheelEventSignal(); +} + +Integration::Scene SceneHolder::GetScene() +{ + return mScene; +} + +Integration::RenderSurface& SceneHolder::GetRenderSurface() +{ + return mRenderSurface; +} + +} // namespace Adaptor + +} // namespace Internal + +/////////////////////////////////////////////////////////////////////////////// +// +// Dali::Integration::SceneHolder Stub +// +/////////////////////////////////////////////////////////////////////////////// namespace Integration { SceneHolder::SceneHolder() { + // Dali::Internal::Adaptor::Adaptor::Get().WindowCreatedSignal().Emit( *this ); } SceneHolder::~SceneHolder() @@ -75,30 +151,59 @@ void SceneHolder::Remove( Actor actor ) { } -Layer SceneHolder::GetRootLayer() const +Dali::Layer SceneHolder::GetRootLayer() const { return Dali::Stage::GetCurrent().GetRootLayer(); } void SceneHolder::SetBackgroundColor( Vector4 color ) { + GetImplementation( *this ).SetBackgroundColor( color ); } Vector4 SceneHolder::GetBackgroundColor() const { - return Dali::Stage::GetCurrent().GetBackgroundColor(); + return GetImplementation( *this ).GetBackgroundColor(); } void SceneHolder::FeedTouchPoint( Dali::TouchPoint& point, int timeStamp ) { + GetImplementation( *this ).FeedTouchPoint( point, timeStamp ); } void SceneHolder::FeedWheelEvent( Dali::WheelEvent& wheelEvent ) { + GetImplementation( *this ).FeedWheelEvent( wheelEvent ); } void SceneHolder::FeedKeyEvent( Dali::KeyEvent& keyEvent ) { + GetImplementation( *this ).FeedKeyEvent( keyEvent ); +} + +SceneHolder::KeyEventSignalType& SceneHolder::KeyEventSignal() +{ + return GetImplementation( *this ).KeyEventSignal(); +} + +SceneHolder::KeyEventGeneratedSignalType& SceneHolder::KeyEventGeneratedSignal() +{ + return GetImplementation( *this ).KeyEventGeneratedSignal(); +} + +SceneHolder::TouchSignalType& SceneHolder::TouchSignal() +{ + return GetImplementation( *this ).TouchSignal(); +} + +SceneHolder::WheelEventSignalType& SceneHolder::WheelEventSignal() +{ + return GetImplementation( *this ).WheelEventSignal(); +} + +SceneHolder SceneHolder::Get( Actor actor ) +{ + return SceneHolder(); } } // Integration 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 2b15b2b..506bee8 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 @@ -24,6 +24,9 @@ #include #include +#include +#include + #define DALI_WINDOW_H #include #include @@ -46,13 +49,12 @@ namespace Internal { namespace Adaptor { -class Window : public Dali::BaseObject +class Window : public SceneHolder { public: Window( const PositionSize& positionSize ) - : mRenderSurface( positionSize ), - mScene( Dali::Integration::Scene::New( mRenderSurface ) ) + : SceneHolder( positionSize ) { } @@ -62,9 +64,6 @@ public: { return new Window( positionSize ); } - - TestRenderSurface mRenderSurface; - Integration::Scene mScene; }; } // Adaptor @@ -104,10 +103,13 @@ Dali::Window Window::New( PositionSize windowPosition, const std::string& name, 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 ); - Dali::Window newWindow = Window( window ); - Dali::Adaptor::WindowCreatedSignalType& windowCreatedSignal = AdaptorImpl::Get().WindowCreatedSignal(); - windowCreatedSignal.Emit( newWindow ); - return Window( window ); + + Dali::Window result( window ); + + Dali::Integration::SceneHolder sceneHolder( static_cast( window ) ); + Dali::Internal::Adaptor::Adaptor::Get().WindowCreatedSignal().Emit( sceneHolder ); + + return result; } Dali::Layer Window::GetRootLayer() const @@ -122,12 +124,12 @@ Window::Window( Internal::Adaptor::Window* window ) Integration::Scene Window::GetScene() { - return GetImplementation( *this ).mScene; + return GetImplementation( *this ).GetScene(); } Integration::RenderSurface& Window::GetRenderSurface() { - return GetImplementation( *this ).mRenderSurface; + return GetImplementation( *this ).GetRenderSurface(); } namespace DevelWindow @@ -140,27 +142,27 @@ Window Get( Actor actor ) EventProcessingFinishedSignalType& EventProcessingFinishedSignal( Window window ) { - return GetImplementation( window ).mScene.EventProcessingFinishedSignal(); + return GetImplementation( window ).GetScene().EventProcessingFinishedSignal(); } KeyEventSignalType& KeyEventSignal( Window window ) { - return GetImplementation( window ).mScene.KeyEventSignal(); + return GetImplementation( window ).KeyEventSignal(); } KeyEventGeneratedSignalType& KeyEventGeneratedSignal( Window window ) { - return GetImplementation( window ).mScene.KeyEventGeneratedSignal(); + return GetImplementation( window ).KeyEventGeneratedSignal(); } TouchSignalType& TouchSignal( Window window ) { - return GetImplementation( window ).mScene.TouchSignal(); + return GetImplementation( window ).TouchSignal(); } WheelEventSignalType& WheelEventSignal( Window window ) { - return GetImplementation( window ).mScene.WheelEventSignal(); + return GetImplementation( window ).WheelEventSignal(); } } // namespace DevelWindow 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 09f71b3..7117686 100644 --- a/dali-toolkit/internal/focus-manager/keyboard-focus-manager-impl.cpp +++ b/dali-toolkit/internal/focus-manager/keyboard-focus-manager-impl.cpp @@ -23,7 +23,6 @@ #include #include #include -#include #include #include #include @@ -142,23 +141,23 @@ void KeyboardFocusManager::OnAdaptorInit() { if( Adaptor::IsAvailable() ) { - // Retrieve all the existing widnows - Dali::WindowContainer windows = Adaptor::Get().GetWindows(); - for ( auto iter = windows.begin(); iter != windows.end(); ++iter ) + // Retrieve all the existing scene holders + Dali::SceneHolderList sceneHolders = Adaptor::Get().GetSceneHolders(); + for( auto iter = sceneHolders.begin(); iter != sceneHolders.end(); ++iter ) { - DevelWindow::KeyEventSignal( *iter ).Connect( mSlotDelegate, &KeyboardFocusManager::OnKeyEvent); - DevelWindow::TouchSignal( *iter ).Connect( mSlotDelegate, &KeyboardFocusManager::OnTouch); + ( *iter ).KeyEventSignal().Connect( mSlotDelegate, &KeyboardFocusManager::OnKeyEvent ); + ( *iter ).TouchSignal().Connect( mSlotDelegate, &KeyboardFocusManager::OnTouch ); } - // Get notified when any new window is created afterwards - Adaptor::Get().WindowCreatedSignal().Connect( mSlotDelegate, &KeyboardFocusManager::OnWindowCreated); + // Get notified when any new scene holder is created afterwards + Adaptor::Get().WindowCreatedSignal().Connect( mSlotDelegate, &KeyboardFocusManager::OnSceneHolderCreated ); } } -void KeyboardFocusManager::OnWindowCreated( Dali::Window& window ) +void KeyboardFocusManager::OnSceneHolderCreated( Dali::Integration::SceneHolder& sceneHolder ) { - DevelWindow::KeyEventSignal( window ).Connect( mSlotDelegate, &KeyboardFocusManager::OnKeyEvent); - DevelWindow::TouchSignal( window ).Connect( mSlotDelegate, &KeyboardFocusManager::OnTouch); + sceneHolder.KeyEventSignal().Connect( mSlotDelegate, &KeyboardFocusManager::OnKeyEvent ); + sceneHolder.TouchSignal().Connect( mSlotDelegate, &KeyboardFocusManager::OnTouch ); } KeyboardFocusManager::~KeyboardFocusManager() diff --git a/dali-toolkit/internal/focus-manager/keyboard-focus-manager-impl.h b/dali-toolkit/internal/focus-manager/keyboard-focus-manager-impl.h index 967e9e1..ff79634 100644 --- a/dali-toolkit/internal/focus-manager/keyboard-focus-manager-impl.h +++ b/dali-toolkit/internal/focus-manager/keyboard-focus-manager-impl.h @@ -30,7 +30,12 @@ namespace Dali { -class Window; +namespace Integration +{ + +class SceneHolder; + +} // namespace Integration namespace Toolkit { @@ -183,10 +188,10 @@ private: void OnAdaptorInit(); /** - * This will be called when a new wndow is created - * @param window The new window + * This will be called when a new scene holder is created + * @param sceneHolder The new scene holder */ - void OnWindowCreated( Dali::Window& window ); + void OnSceneHolderCreated( Dali::Integration::SceneHolder& sceneHolder ); /** * Get configuration from StyleManager. diff --git a/dali-toolkit/internal/focus-manager/keyinput-focus-manager-impl.cpp b/dali-toolkit/internal/focus-manager/keyinput-focus-manager-impl.cpp index 71bc352..57e0d86 100644 --- a/dali-toolkit/internal/focus-manager/keyinput-focus-manager-impl.cpp +++ b/dali-toolkit/internal/focus-manager/keyinput-focus-manager-impl.cpp @@ -23,8 +23,8 @@ #include #include #include -#include #include +#include // INTERNAL INCLUDES #include @@ -53,23 +53,23 @@ KeyInputFocusManager::KeyInputFocusManager() mCurrentFocusControl() { // Retrieve all the existing widnows - Dali::WindowContainer windows = Adaptor::Get().GetWindows(); - for ( auto iter = windows.begin(); iter != windows.end(); ++iter ) + Dali::SceneHolderList sceneHolders = Adaptor::Get().GetSceneHolders(); + for( auto iter = sceneHolders.begin(); iter != sceneHolders.end(); ++iter ) { - DevelWindow::KeyEventGeneratedSignal( *iter ).Connect( mSlotDelegate, &KeyInputFocusManager::OnKeyEvent); + ( *iter ).KeyEventGeneratedSignal().Connect( mSlotDelegate, &KeyInputFocusManager::OnKeyEvent ); } - // Get notified when any new window is created afterwards - Adaptor::Get().WindowCreatedSignal().Connect( mSlotDelegate, &KeyInputFocusManager::OnWindowCreated); + // Get notified when any new scene holder is created afterwards + Adaptor::Get().WindowCreatedSignal().Connect( mSlotDelegate, &KeyInputFocusManager::OnSceneHolderCreated ); } KeyInputFocusManager::~KeyInputFocusManager() { } -void KeyInputFocusManager::OnWindowCreated( Dali::Window& window ) +void KeyInputFocusManager::OnSceneHolderCreated( Dali::Integration::SceneHolder& sceneHolder ) { - DevelWindow::KeyEventGeneratedSignal( window ).Connect( mSlotDelegate, &KeyInputFocusManager::OnKeyEvent); + sceneHolder.KeyEventGeneratedSignal().Connect( mSlotDelegate, &KeyInputFocusManager::OnKeyEvent ); } void KeyInputFocusManager::SetFocus( Toolkit::Control control ) diff --git a/dali-toolkit/internal/focus-manager/keyinput-focus-manager-impl.h b/dali-toolkit/internal/focus-manager/keyinput-focus-manager-impl.h index 0f066c5..ab83e37 100644 --- a/dali-toolkit/internal/focus-manager/keyinput-focus-manager-impl.h +++ b/dali-toolkit/internal/focus-manager/keyinput-focus-manager-impl.h @@ -30,7 +30,12 @@ namespace Dali { -class Window; +namespace Integration +{ + +class SceneHolder; + +} // namespace Integration namespace Toolkit { @@ -93,10 +98,10 @@ protected: private: /** - * This will be called when a new window is created - * @param window The new window + * This will be called when a new scene holder is created + * @param sceneHolder The new scene holder */ - void OnWindowCreated( Dali::Window& window ); + void OnSceneHolderCreated( Dali::Integration::SceneHolder& sceneHolder ); /** * Callback for the key event when no actor in the stage has gained the key input focus -- 2.7.4