For custom wheel events, event propagation starts from the focused actor.
[platform/core/uifw/dali-toolkit.git] / automated-tests / src / dali-toolkit / dali-toolkit-test-utils / toolkit-scene-holder.cpp
index 04afdeb..8bcb3c0 100644 (file)
@@ -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.
  *
  */
 
-#include <dali/integration-api/adaptors/scene-holder.h>
+#include <dali/integration-api/events/touch-event-integ.h>
+#include <dali/integration-api/adaptor-framework/scene-holder.h>
+
+#include <toolkit-scene-holder-impl.h>
 
 #include <dali/public-api/actors/actor.h>
 #include <dali/public-api/actors/layer.h>
-#include <dali/public-api/common/stage.h>
 #include <dali/public-api/object/base-object.h>
 
+#include <dali/integration-api/adaptor-framework/adaptor.h>
+#include <toolkit-adaptor-impl.h>
+
+using AdaptorImpl = Dali::Internal::Adaptor::Adaptor;
+
 namespace Dali
 {
 
+///////////////////////////////////////////////////////////////////////////////
+//
+// Dali::Internal::Adaptor::SceneHolder Stub
+//
+///////////////////////////////////////////////////////////////////////////////
+
 namespace Internal
 {
 
 namespace Adaptor
 {
 
-class SceneHolder: public Dali::BaseObject
+SceneHolder::SceneHolder( const Dali::Rect<int>& positionSize )
+: mRenderSurface( positionSize ),
+  mScene( Dali::Integration::Scene::New( Dali::Size( static_cast<float>( positionSize.width ), static_cast<float>( positionSize.height ) ) ) )
+{
+}
+
+SceneHolder::~SceneHolder()
+{
+  if ( Dali::Adaptor::IsAvailable() )
+  {
+    AdaptorImpl::GetImpl( AdaptorImpl::Get() ).RemoveWindow( this );
+  }
+}
+
+void SceneHolder::Add( Dali::Actor actor )
+{
+  mScene.Add( actor );
+}
+
+void SceneHolder::Remove( Dali::Actor actor )
+{
+  mScene.Remove( actor );
+}
+
+Dali::Layer SceneHolder::GetRootLayer() const
+{
+  return mScene.GetRootLayer();
+}
+
+void SceneHolder::SetBackgroundColor( Vector4 color )
+{
+  return mScene.SetBackgroundColor( color );
+}
+
+Vector4 SceneHolder::GetBackgroundColor() const
+{
+  return mScene.GetBackgroundColor();
+}
+
+void SceneHolder::FeedTouchPoint( Dali::TouchPoint& point, int timeStamp )
 {
+}
 
-};
+void SceneHolder::FeedWheelEvent( Dali::WheelEvent& wheelEvent )
+{
+}
 
-} // Adaptor
+void SceneHolder::FeedKeyEvent( Dali::KeyEvent& keyEvent )
+{
+}
 
-} // Internal
+Dali::Integration::SceneHolder::KeyEventSignalType& SceneHolder::KeyEventSignal()
+{
+  return mScene.KeyEventSignal();
+}
+
+Dali::Integration::SceneHolder::KeyEventGeneratedSignalType& SceneHolder::KeyEventGeneratedSignal()
+{
+  return mScene.KeyEventGeneratedSignal();
+}
+
+Dali::Integration::SceneHolder::TouchEventSignalType& SceneHolder::TouchedSignal()
+{
+  return mScene.TouchedSignal();
+}
+
+Dali::Integration::SceneHolder::WheelEventSignalType& SceneHolder::WheelEventSignal()
+{
+  return mScene.WheelEventSignal();
+}
+
+Dali::Integration::SceneHolder::WheelEventGeneratedSignalType& SceneHolder::WheelEventGeneratedSignal()
+{
+  return mScene.WheelEventGeneratedSignal();
+}
+
+Integration::Scene SceneHolder::GetScene()
+{
+  return mScene;
+}
+
+Dali::RenderSurfaceInterface& 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()
@@ -67,38 +168,81 @@ SceneHolder& SceneHolder::operator=( const SceneHolder& rhs )
   return *this;
 }
 
+Dali::Integration::SceneHolder SceneHolder::Get( Dali::Actor actor )
+{
+  Internal::Adaptor::SceneHolder* sceneHolderImpl = nullptr;
+
+  if ( Dali::Adaptor::IsAvailable() )
+  {
+    sceneHolderImpl = AdaptorImpl::GetImpl( AdaptorImpl::Get() ).GetWindow( actor );
+  }
+
+  return Dali::Integration::SceneHolder( sceneHolderImpl );
+}
+
 void SceneHolder::Add( Actor actor )
 {
+  GetImplementation( *this ).Add( actor );
 }
 
 void SceneHolder::Remove( Actor actor )
 {
+  GetImplementation( *this ).Remove( actor );
 }
 
-Layer SceneHolder::GetRootLayer() const
+Dali::Layer SceneHolder::GetRootLayer() const
 {
-  return Dali::Stage::GetCurrent().GetRootLayer();
+  return GetImplementation( *this ).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::TouchEventSignalType& SceneHolder::TouchedSignal()
+{
+  return GetImplementation( *this ).TouchedSignal();
+}
+
+SceneHolder::WheelEventSignalType& SceneHolder::WheelEventSignal()
+{
+  return GetImplementation( *this ).WheelEventSignal();
+}
+
+SceneHolder::WheelEventGeneratedSignalType& SceneHolder::WheelEventGeneratedSignal()
+{
+  return GetImplementation( *this ).WheelEventGeneratedSignal();
 }
 
 } // Integration