[Tizen] Add screen and client rotation itself function
[platform/core/uifw/dali-adaptor.git] / dali / internal / window-system / windows / window-base-win.h
1 #ifndef DALI_INTERNAL_WINDOWSYSTEM_WINDOW_BASE_WIN_H
2 #define DALI_INTERNAL_WINDOWSYSTEM_WINDOW_BASE_WIN_H
3
4 /*
5  * Copyright (c) 2018 Samsung Electronics Co., Ltd.
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  *
19  */
20
21 // INTERNAL INCLUDES
22 #include <dali/internal/window-system/common/window-base.h>
23 #include <dali/internal/window-system/windows/platform-implement-win.h>
24 #include <dali/internal/window-system/windows/event-system-win.h>
25
26 namespace Dali
27 {
28 namespace Internal
29 {
30 namespace Adaptor
31 {
32
33 class Window;
34 class WindowRenderSurface;
35 class WindowRenderSurfaceWin;
36
37 /**
38  * WindowBaseWin class provides an WindowBase Win32 implementation.
39  */
40 class WindowBaseWin : public WindowBase
41 {
42 public:
43
44   /**
45    * @brief Constructor
46    */
47   WindowBaseWin( PositionSize positionSize, Any surface, bool isTransparent );
48
49   /**
50    * @brief Destructor
51    */
52   virtual ~WindowBaseWin();
53
54 public:
55
56   /**
57    * Called when the window receives a delete request
58    */
59   void OnDeleteRequest();
60
61   /**
62    * @brief Called when the window gains focus.
63    */
64   void OnFocusIn( int type, TWinEventInfo *event );
65
66   /**
67    * @brief Called when the window loses focus.
68    */
69   void OnFocusOut( int type, TWinEventInfo *event );
70
71   /**
72    * @brief Called when the window is damaged.
73    */
74   void OnWindowDamaged( int type, TWinEventInfo *event );
75
76   /**
77    * @brief Called when a touch down is received.
78    */
79   void OnMouseButtonDown( int type, TWinEventInfo *event );
80
81   /**
82    * @brief Called when a touch up is received.
83    */
84   void OnMouseButtonUp( int type, TWinEventInfo *event );
85
86   /**
87    * @brief Called when a touch motion is received.
88    */
89   void OnMouseButtonMove( int type, TWinEventInfo *event );
90
91   /**
92    * @brief Called when a mouse wheel is received.
93    */
94   void OnMouseWheel( int type, TWinEventInfo *event );
95
96   /**
97    * @brief Called when a key down is received.
98    */
99   void OnKeyDown( int type, TWinEventInfo *event );
100
101   /**
102    * @brief Called when a key up is received.
103    */
104   void OnKeyUp( int type, TWinEventInfo *event );
105
106
107 public:
108
109   /**
110    * @copydoc Dali::Internal::Adaptor::WindowBase::GetNativeWindow()
111    */
112   Any GetNativeWindow() override;
113
114   /**
115    * @copydoc Dali::Internal::Adaptor::WindowBase::GetNativeWindowId()
116    */
117   int GetNativeWindowId() override;
118
119   /**
120    * @copydoc Dali::Internal::Adaptor::WindowBase::CreateEglWindow()
121    */
122   EGLNativeWindowType CreateEglWindow( int width, int height ) override;
123
124   /**
125    * @copydoc Dali::Internal::Adaptor::WindowBase::DestroyEglWindow()
126    */
127   void DestroyEglWindow() override;
128
129   /**
130    * @copydoc Dali::Internal::Adaptor::WindowBase::SetEglWindowRotation()
131    */
132   void SetEglWindowRotation( int angle ) override;
133
134   /**
135    * @copydoc Dali::Internal::Adaptor::WindowBase::SetEglWindowBufferTransform()
136    */
137   void SetEglWindowBufferTransform( int angle ) override;
138
139   /**
140    * @copydoc Dali::Internal::Adaptor::WindowBase::SetEglWindowTransform()
141    */
142   void SetEglWindowTransform( int angle ) override;
143
144   /**
145    * @copydoc Dali::Internal::Adaptor::WindowBase::ResizeEglWindow()
146    */
147   void ResizeEglWindow( PositionSize positionSize ) override;
148
149   /**
150    * @copydoc Dali::Internal::Adaptor::WindowBase::IsEglWindowRotationSupported()
151    */
152   bool IsEglWindowRotationSupported() override;
153
154   /**
155    * @copydoc Dali::Internal::Adaptor::WindowBase::Move()
156    */
157   void Move( PositionSize positionSize ) override;
158
159   /**
160    * @copydoc Dali::Internal::Adaptor::WindowBase::Resize()
161    */
162   void Resize( PositionSize positionSize ) override;
163
164   /**
165    * @copydoc Dali::Internal::Adaptor::WindowBase::MoveResize()
166    */
167   void MoveResize( PositionSize positionSize ) override;
168
169   /**
170    * @copydoc Dali::Internal::Adaptor::WindowBase::SetClass()
171    */
172   void SetClass( const std::string& name, const std::string& className ) override;
173
174   /**
175    * @copydoc Dali::Internal::Adaptor::WindowBase::Raise()
176    */
177   void Raise() override;
178
179   /**
180    * @copydoc Dali::Internal::Adaptor::WindowBase::Lower()
181    */
182   void Lower() override;
183
184   /**
185    * @copydoc Dali::Internal::Adaptor::WindowBase::Activate()
186    */
187   void Activate() override;
188
189   /**
190    * @copydoc Dali::Internal::Adaptor::WindowBase::SetAvailableAnlges()
191    */
192   void SetAvailableAnlges( const std::vector< int >& angles ) override;
193
194   /**
195    * @copydoc Dali::Internal::Adaptor::WindowBase::SetPreferredAngle()
196    */
197   void SetPreferredAngle( int angle ) override;
198
199   /**
200    * @copydoc Dali::Internal::Adaptor::WindowBase::SetAcceptFocus()
201    */
202   void SetAcceptFocus( bool accept ) override;
203
204   /**
205    * @copydoc Dali::Internal::Adaptor::WindowBase::Show()
206    */
207   void Show() override;
208
209   /**
210    * @copydoc Dali::Internal::Adaptor::WindowBase::Hide()
211    */
212   void Hide() override;
213
214   /**
215    * @copydoc Dali::Internal::Adaptor::WindowBase::GetSupportedAuxiliaryHintCount()
216    */
217   unsigned int GetSupportedAuxiliaryHintCount() const override;
218
219   /**
220    * @copydoc Dali::Internal::Adaptor::WindowBase::GetSupportedAuxiliaryHint()
221    */
222   std::string GetSupportedAuxiliaryHint( unsigned int index ) const override;
223
224   /**
225    * @copydoc Dali::Internal::Adaptor::WindowBase::AddAuxiliaryHint()
226    */
227   unsigned int AddAuxiliaryHint( const std::string& hint, const std::string& value ) override;
228
229   /**
230    * @copydoc Dali::Internal::Adaptor::WindowBase::RemoveAuxiliaryHint()
231    */
232   bool RemoveAuxiliaryHint( unsigned int id ) override;
233
234   /**
235    * @copydoc Dali::Internal::Adaptor::WindowBase::SetAuxiliaryHintValue()
236    */
237   bool SetAuxiliaryHintValue( unsigned int id, const std::string& value ) override;
238
239   /**
240    * @copydoc Dali::Internal::Adaptor::WindowBase::GetAuxiliaryHintValue()
241    */
242   std::string GetAuxiliaryHintValue( unsigned int id ) const override;
243
244   /**
245    * @copydoc Dali::Internal::Adaptor::WindowBase::GetAuxiliaryHintId()
246    */
247   unsigned int GetAuxiliaryHintId( const std::string& hint ) const override;
248
249   /**
250    * @copydoc Dali::Internal::Adaptor::WindowBase::SetInputRegion()
251    */
252   void SetInputRegion( const Rect< int >& inputRegion ) override;
253
254   /**
255    * @copydoc Dali::Internal::Adaptor::WindowBase::SetType()
256    */
257   void SetType( Dali::Window::Type type ) override;
258
259   /**
260    * @copydoc Dali::Internal::Adaptor::WindowBase::SetNotificationLevel()
261    */
262   bool SetNotificationLevel( Dali::Window::NotificationLevel::Type level ) override;
263
264   /**
265    * @copydoc Dali::Internal::Adaptor::WindowBase::GetNotificationLevel()
266    */
267   Dali::Window::NotificationLevel::Type GetNotificationLevel() const override;
268
269   /**
270    * @copydoc Dali::Internal::Adaptor::WindowBase::SetOpaqueState()
271    */
272   void SetOpaqueState( bool opaque ) override;
273
274   /**
275    * @copydoc Dali::Internal::Adaptor::WindowBase::SetScreenOffMode()
276    */
277   bool SetScreenOffMode(Dali::Window::ScreenOffMode::Type screenOffMode) override;
278
279   /**
280    * @copydoc Dali::Internal::Adaptor::WindowBase::GetScreenOffMode()
281    */
282   Dali::Window::ScreenOffMode::Type GetScreenOffMode() const override;
283
284   /**
285    * @copydoc Dali::Internal::Adaptor::WindowBase::SetBrightness()
286    */
287   bool SetBrightness( int brightness ) override;
288
289   /**
290    * @copydoc Dali::Internal::Adaptor::WindowBase::GetBrightness()
291    */
292   int GetBrightness() const override;
293
294   /**
295    * @copydoc Dali::Internal::Adaptor::WindowBase::GrabKey()
296    */
297   bool GrabKey( Dali::KEY key, KeyGrab::KeyGrabMode grabMode ) override;
298
299   /**
300    * @copydoc Dali::Internal::Adaptor::WindowBase::UngrabKey()
301    */
302   bool UngrabKey( Dali::KEY key ) override;
303
304   /**
305    * @copydoc Dali::Internal::Adaptor::WindowBase::GrabKeyList()
306    */
307   bool GrabKeyList( const Dali::Vector< Dali::KEY >& key, const Dali::Vector< KeyGrab::KeyGrabMode >& grabMode, Dali::Vector< bool >& result ) override;
308
309   /**
310    * @copydoc Dali::Internal::Adaptor::WindowBase::UngrabKeyList()
311    */
312   bool UngrabKeyList( const Dali::Vector< Dali::KEY >& key, Dali::Vector< bool >& result ) override;
313
314   /**
315    * @copydoc Dali::Internal::Adaptor::WindowBase::GetDpi()
316    */
317   void GetDpi( unsigned int& dpiHorizontal, unsigned int& dpiVertical ) override;
318
319   /**
320    * @copydoc Dali::Internal::Adaptor::WindowBase::GetScreenRotationAngle()
321    */
322   int GetScreenRotationAngle() override;
323
324   /**
325    * @copydoc Dali::Internal::Adaptor::WindowBase::SetWindowRotationAngle()
326    */
327   void SetWindowRotationAngle( int degree ) override;
328
329   /**
330    * @copydoc Dali::Internal::Adaptor::WindowBase::GetWindowRotationAngle()
331    */
332   virtual void GetWindowRotationAngle() override;
333
334   /**
335    * @copydoc Dali::Internal::Adaptor::WindowBase::WindowRotationCompleted()
336    */
337   void WindowRotationCompleted( int degree, int width, int height ) override;
338
339   /**
340    * @copydoc Dali::Internal::Adaptor::WindowBase::SetTransparency()
341    */
342   void SetTransparency( bool transparent ) override;
343
344   /**
345    * @brief Return the orientation of the surface.
346    * @return The orientation
347    */
348   virtual int GetOrientation() const override;
349
350   /**
351    * @copydoc Dali::Internal::Adaptor::WindowBase::SetParent()
352    */
353   void SetParent( WindowBase* parentWinBase ) override;
354
355   /**
356    * @copydoc  Dali::Internal::Adaptor::WindowBase::CreateFrameRenderedSyncFence()
357    */
358   int CreateFrameRenderedSyncFence() override;
359
360   /**
361    * @copydoc  Dali::Internal::Adaptor::WindowBase::CreateFramePresentedSyncFence()
362    */
363   int CreateFramePresentedSyncFence() override;
364
365 private:
366
367   /**
368    * Second stage initialization
369    */
370   void Initialize( PositionSize positionSize, Any surface, bool isTransparent );
371
372   /**
373    * @brief Get the surface id if the surface parameter is not empty
374    * @param surface Any containing a surface id, or can be empty
375    * @return surface id, or zero if surface is empty
376    */
377   uintptr_t GetSurfaceId( Any surface ) const;
378
379   /**
380    * @brief Create window
381    */
382   void CreateWinWindow( PositionSize positionSize, bool isTransparent );
383
384   /**
385    * @brief Sets up an already created window.
386    */
387   void SetWinWindow( uintptr_t surfaceId );
388
389 private:
390
391   // Undefined
392   WindowBaseWin(const WindowBaseWin&) = delete;
393
394   // Undefined
395   WindowBaseWin& operator=(const WindowBaseWin& rhs) = delete;
396
397 private:
398   void EventEntry( TWinEventInfo *event );
399
400 private:
401   WinWindowHandle                      mWin32Window;        ///< Native window handle
402   bool                                 mOwnSurface:1;       ///< Whether we own the surface (responsible for deleting it)
403   bool                                 mIsTransparent:1;    ///< Whether the window is transparent (32 bit or 24 bit)
404   bool                                 mRotationAppSet:1;
405
406   WindowsPlatform::WindowImpl mWindowImpl;
407 };
408
409 } // namespace Adaptor
410
411 } // namespace internal
412
413 } // namespace Dali
414
415 #endif // DALI_INTERNAL_WINDOWSYSTEM_WINDOW_BASE_WIN_H