[Tizen] Connect KeyEventGeneratedSignal for Get KeyEvent
[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 #include <dali/devel-api/common/stage-devel.h>
27
28 // INTERNAL INCLUDES
29 #include "test-render-surface.h"
30
31 namespace Dali
32 {
33
34 class Window;
35
36 /********************************************************************************
37  * Stub for Dali::Internal::Adaptor::Window
38  ********************************************************************************/
39
40 namespace Internal
41 {
42 namespace Adaptor
43 {
44 class Window : public Dali::BaseObject
45 {
46 public:
47
48   Window( const PositionSize& positionSize )
49   : mScene( Dali::Integration::Scene::New( Size( positionSize.width, positionSize.height ) ) ),
50     mRenderSurface( new TestRenderSurface( positionSize ) )
51   {
52     mScene.SetSurface( *mRenderSurface );
53   }
54
55   virtual ~Window()
56   {
57     delete mRenderSurface;
58     mRenderSurface = nullptr;
59   }
60
61   static Window* New(const PositionSize& positionSize, const std::string& name, const std::string& className, bool isTransparent)
62   {
63     return new Window( positionSize );
64   }
65
66   Integration::Scene mScene;
67   TestRenderSurface* mRenderSurface;
68 };
69
70 } // Adaptor
71 } // Internal
72
73 inline Internal::Adaptor::Window& GetImplementation(Dali::Window& window)
74 {
75   DALI_ASSERT_ALWAYS( window && "Window handle is empty" );
76   BaseObject& object = window.GetBaseObject();
77   return static_cast<Internal::Adaptor::Window&>(object);
78 }
79
80 Window::Window()
81 {
82 }
83
84 Window::~Window()
85 {
86 }
87
88 Window::Window(const Window& handle)
89 : BaseHandle( handle )
90 {
91 }
92
93 Window& Window::operator=(const Window& rhs)
94 {
95   BaseHandle::operator=(rhs);
96   return *this;
97 }
98
99 Dali::Window Window::New( PositionSize windowPosition, const std::string& name, bool isTransparent )
100 {
101   Internal::Adaptor::Window* window = Internal::Adaptor::Window::New( windowPosition, name, "", isTransparent );
102   return Window( window );
103 }
104
105 Dali::Window Window::New(PositionSize windowPosition, const std::string& name, const std::string& className, bool isTransparent )
106 {
107   Internal::Adaptor::Window* window = Internal::Adaptor::Window::New( windowPosition, name, className, isTransparent );
108   return Window( window );
109 }
110
111 Dali::Layer Window::GetRootLayer() const
112 {
113   return Dali::Stage::GetCurrent().GetRootLayer();
114 }
115
116 Window::Window( Internal::Adaptor::Window* window )
117 : BaseHandle( window )
118 {
119 }
120
121 Integration::Scene Window::GetScene()
122 {
123   return GetImplementation( *this ).mScene;
124 }
125
126 Integration::RenderSurface& Window::GetRenderSurface()
127 {
128   return *GetImplementation( *this ).mRenderSurface;
129 }
130
131 namespace DevelWindow
132 {
133
134 Window Get( Actor actor )
135 {
136   return Window();
137 }
138
139 EventProcessingFinishedSignalType& EventProcessingFinishedSignal( Window window )
140 {
141   return GetImplementation( window ).mScene.EventProcessingFinishedSignal();
142 }
143
144 KeyEventSignalType& KeyEventSignal( Window window )
145 {
146   return GetImplementation( window ).mScene.KeyEventSignal();
147 }
148
149 KeyEventGeneratedSignalType& KeyEventGeneratedSignal( Window window )
150 {
151   return DevelStage::KeyEventGeneratedSignal( Dali::Stage::GetCurrent() );
152 }
153
154 TouchSignalType& TouchSignal( Window window )
155 {
156   return GetImplementation( window ).mScene.TouchSignal();
157 }
158
159 WheelEventSignalType& WheelEventSignal( Window window )
160 {
161   return GetImplementation( window ).mScene.WheelEventSignal();
162 }
163
164 } // namespace DevelWindow
165
166 } // Dali