Applying changes to Scene::New()
[platform/core/uifw/dali-toolkit.git] / automated-tests / src / dali-toolkit / dali-toolkit-test-utils / toolkit-window.cpp
1 /*
2  * Copyright (c) 2019 Samsung Electronics Co., Ltd.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  */
17
18 // CLASS HEADER
19 #include "toolkit-window.h"
20
21 // EXTERNAL INCLUDES
22 #include <dali/public-api/actors/actor.h>
23 #include <dali/public-api/actors/layer.h>
24 #include <dali/public-api/common/stage.h>
25 #include <dali/public-api/object/base-object.h>
26
27 // INTERNAL INCLUDES
28 #include "test-render-surface.h"
29
30 namespace Dali
31 {
32
33 class Window;
34
35 /********************************************************************************
36  * Stub for Dali::Internal::Adaptor::Window
37  ********************************************************************************/
38
39 namespace Internal
40 {
41 namespace Adaptor
42 {
43 class Window : public Dali::BaseObject
44 {
45 public:
46
47   Window( const PositionSize& positionSize )
48   : mRenderSurface( positionSize ),
49     mScene( Dali::Integration::Scene::New( mRenderSurface ) )
50   {
51   }
52
53   virtual ~Window() = default;
54
55   static Window* New(const PositionSize& positionSize, const std::string& name, const std::string& className, bool isTransparent)
56   {
57     return new Window( positionSize );
58   }
59
60   TestRenderSurface mRenderSurface;
61   Integration::Scene mScene;
62 };
63
64 } // Adaptor
65 } // Internal
66
67 inline Internal::Adaptor::Window& GetImplementation(Dali::Window& window)
68 {
69   DALI_ASSERT_ALWAYS( window && "Window handle is empty" );
70   BaseObject& object = window.GetBaseObject();
71   return static_cast<Internal::Adaptor::Window&>(object);
72 }
73
74 Window::Window()
75 {
76 }
77
78 Window::~Window()
79 {
80 }
81
82 Window::Window(const Window& handle)
83 : BaseHandle( handle )
84 {
85 }
86
87 Window& Window::operator=(const Window& rhs)
88 {
89   BaseHandle::operator=(rhs);
90   return *this;
91 }
92
93 Dali::Window Window::New( PositionSize windowPosition, const std::string& name, bool isTransparent )
94 {
95   Internal::Adaptor::Window* window = Internal::Adaptor::Window::New( windowPosition, name, "", isTransparent );
96   return Window( window );
97 }
98
99 Dali::Window Window::New(PositionSize windowPosition, const std::string& name, const std::string& className, bool isTransparent )
100 {
101   Internal::Adaptor::Window* window = Internal::Adaptor::Window::New( windowPosition, name, className, isTransparent );
102   return Window( window );
103 }
104
105 Dali::Layer Window::GetRootLayer() const
106 {
107   return Dali::Stage::GetCurrent().GetRootLayer();
108 }
109
110 Window::Window( Internal::Adaptor::Window* window )
111 : BaseHandle( window )
112 {
113 }
114
115 Integration::Scene Window::GetScene()
116 {
117   return GetImplementation( *this ).mScene;
118 }
119
120 Integration::RenderSurface& Window::GetRenderSurface()
121 {
122   return GetImplementation( *this ).mRenderSurface;
123 }
124
125 namespace DevelWindow
126 {
127
128 Window Get( Actor actor )
129 {
130   return Window();
131 }
132
133 EventProcessingFinishedSignalType& EventProcessingFinishedSignal( Window window )
134 {
135   return GetImplementation( window ).mScene.EventProcessingFinishedSignal();
136 }
137
138 KeyEventSignalType& KeyEventSignal( Window window )
139 {
140   return GetImplementation( window ).mScene.KeyEventSignal();
141 }
142
143 TouchSignalType& TouchSignal( Window window )
144 {
145   return GetImplementation( window ).mScene.TouchSignal();
146 }
147
148 WheelEventSignalType& WheelEventSignal( Window window )
149 {
150   return GetImplementation( window ).mScene.WheelEventSignal();
151 }
152
153 } // namespace DevelWindow
154
155 } // Dali