1be77f912a63580aa77fb08390230366281abe7f
[platform/core/uifw/dali-adaptor.git] / dali / internal / window-system / common / window-base.h
1 #ifndef DALI_INTERNAL_WINDOWSYSTEM_COMMON_WINDOW_BASE_H
2 #define DALI_INTERNAL_WINDOWSYSTEM_COMMON_WINDOW_BASE_H
3
4 /*
5  * Copyright (c) 2019 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 // EXTERNAL INCLUDES
22 #include <dali/integration-api/events/key-event-integ.h>
23 #include <dali/integration-api/events/point.h>
24 #include <dali/public-api/events/wheel-event.h>
25 #include <string>
26 #include <vector>
27 #include <cstdint>
28
29 // INTERNAL INCLUDES
30 #include <dali/public-api/adaptor-framework/window.h>
31 #include <dali/public-api/adaptor-framework/key-grab.h>
32 #include <dali/public-api/adaptor-framework/style-change.h>
33 #include <dali/devel-api/adaptor-framework/window-devel.h>
34 #include <dali/internal/window-system/common/damage-observer.h>
35 #include <dali/internal/window-system/common/rotation-event.h>
36 #include <dali/internal/graphics/gles/egl-implementation.h>
37
38 namespace Dali
39 {
40 namespace Internal
41 {
42 namespace Adaptor
43 {
44
45 /**
46  * WindowBase interface
47  */
48 class WindowBase
49 {
50 public:
51
52   /**
53    * @brief Struct used to retrieve accessibility information
54    */
55   struct AccessibilityInfo
56   {
57     int gestureValue;
58     int startX;
59     int startY;
60     int endX;
61     int endY;
62     int state;
63     int eventTime;
64   };
65
66   // Window
67   typedef Signal< void ( bool ) > IconifySignalType;
68   typedef Signal< void ( bool ) > FocusSignalType;
69   typedef Signal< void ( ) > OutputSignalType;
70   typedef Signal< void ( ) > DeleteSignalType;
71   typedef Signal< void ( const DamageArea& ) > DamageSignalType;
72   typedef Signal< void ( const RotationEvent& ) > RotationSignalType;
73   typedef Signal< void ( DevelWindow::EffectState, DevelWindow::EffectType ) > TransitionEffectEventSignalType;
74
75   // Input events
76   typedef Signal< void ( Integration::Point&, uint32_t ) > TouchEventSignalType;
77   typedef Signal< void ( WheelEvent& ) > WheelEventSignalType;
78   typedef Signal< void( Integration::KeyEvent& ) > KeyEventSignalType;
79
80   // Clipboard
81   typedef Signal< void ( void* ) > SelectionSignalType;
82
83   // Accessibility
84   typedef Signal< void ( StyleChange::Type ) > StyleSignalType;
85   typedef Signal< void ( const AccessibilityInfo& ) > AccessibilitySignalType;
86
87   /**
88    * @brief Default constructor
89    */
90   WindowBase();
91
92   /**
93    * @brief Destructor
94    */
95   virtual ~WindowBase();
96
97 public:
98
99   /**
100    * @brief Get the native window handle
101    * @return The native window handle
102    */
103   virtual Any GetNativeWindow() = 0;
104
105   /**
106    * @brief Get the native window id
107    * @return The native window id
108    */
109   virtual int GetNativeWindowId() = 0;
110
111   /**
112    * @brief Create the egl window
113    */
114   virtual EGLNativeWindowType CreateEglWindow( int width, int height ) = 0;
115
116   /**
117    * @brief Destroy the egl window
118    */
119   virtual void DestroyEglWindow() = 0;
120
121   /**
122    * @brief Set the egl window rotation
123    */
124   virtual void SetEglWindowRotation( int angle ) = 0;
125
126   /**
127    * @brief Set the egl window buffer transform
128    */
129   virtual void SetEglWindowBufferTransform( int angle ) = 0;
130
131   /**
132    * @brief Set the egl window transform
133    */
134   virtual void SetEglWindowTransform( int angle ) = 0;
135
136   /**
137    * @brief Resize the egl window
138    */
139   virtual void ResizeEglWindow( Dali::PositionSize positionSize ) = 0;
140
141   /**
142    * @brief Returns whether the egl window support rotation or not
143    */
144   virtual bool IsEglWindowRotationSupported() = 0;
145
146   /**
147    * @brief Move the window
148    */
149   virtual void Move( Dali::PositionSize positionSize ) = 0;
150
151   /**
152    * @brief Resize the window
153    */
154   virtual void Resize( Dali::PositionSize positionSize ) = 0;
155
156   /**
157    * @brief Move and resize the window
158    */
159   virtual void MoveResize( Dali::PositionSize positionSize ) = 0;
160
161   /**
162    * @copydoc Dali::Window::SetClass()
163    */
164   virtual void SetClass( const std::string& name, const std::string& className ) = 0;
165
166   /**
167    * @copydoc Dali::Window::Raise()
168    */
169   virtual void Raise() = 0;
170
171   /**
172    * @copydoc Dali::Window::Lower()
173    */
174   virtual void Lower() = 0;
175
176   /**
177    * @copydoc Dali::Window::Activate()
178    */
179   virtual void Activate() = 0;
180
181   /**
182    * @copydoc Dali::Window::SetAvailableOrientations()
183    */
184   virtual void SetAvailableAnlges( const std::vector< int >& angles ) = 0;
185
186   /**
187    * @copydoc Dali::Window::SetPreferredOrientation()
188    */
189   virtual void SetPreferredAngle( int angle ) = 0;
190
191   /**
192    * @copydoc Dali::Window::SetAcceptFocus()
193    */
194   virtual void SetAcceptFocus( bool accept ) = 0;
195
196   /**
197    * @copydoc Dali::Window::Show()
198    */
199   virtual void Show() = 0;
200
201   /**
202    * @copydoc Dali::Window::Hide()
203    */
204   virtual void Hide() = 0;
205
206   /**
207    * @copydoc Dali::Window::GetSupportedAuxiliaryHintCount()
208    */
209   virtual unsigned int GetSupportedAuxiliaryHintCount() const = 0;
210
211   /**
212    * @copydoc Dali::Window::GetSupportedAuxiliaryHint()
213    */
214   virtual std::string GetSupportedAuxiliaryHint( unsigned int index ) const = 0;
215
216   /**
217    * @copydoc Dali::Window::AddAuxiliaryHint()
218    */
219   virtual unsigned int AddAuxiliaryHint( const std::string& hint, const std::string& value ) = 0;
220
221   /**
222    * @copydoc Dali::Window::RemoveAuxiliaryHint()
223    */
224   virtual bool RemoveAuxiliaryHint( unsigned int id ) = 0;
225
226   /**
227    * @copydoc Dali::Window::SetAuxiliaryHintValue()
228    */
229   virtual bool SetAuxiliaryHintValue( unsigned int id, const std::string& value ) = 0;
230
231   /**
232    * @copydoc Dali::Window::GetAuxiliaryHintValue()
233    */
234   virtual std::string GetAuxiliaryHintValue( unsigned int id ) const = 0;
235
236   /**
237    * @copydoc Dali::Window::GetAuxiliaryHintId()
238    */
239   virtual unsigned int GetAuxiliaryHintId( const std::string& hint ) const = 0;
240
241   /**
242    * @copydoc Dali::Window::SetInputRegion()
243    */
244   virtual void SetInputRegion( const Rect< int >& inputRegion ) = 0;
245
246   /**
247    * @copydoc Dali::Window::SetType()
248    */
249   virtual void SetType( Dali::Window::Type type ) = 0;
250
251   /**
252    * @copydoc Dali::Window::SetNotificationLevel()
253    */
254   virtual bool SetNotificationLevel( Dali::Window::NotificationLevel::Type level ) = 0;
255
256   /**
257    * @copydoc Dali::Window::GetNotificationLevel()
258    */
259   virtual Dali::Window::NotificationLevel::Type GetNotificationLevel() const = 0;
260
261   /**
262    * @copydoc Dali::Window::SetOpaqueState()
263    */
264   virtual void SetOpaqueState( bool opaque ) = 0;
265
266   /**
267    * @copydoc Dali::Window::SetScreenOffMode()
268    */
269   virtual bool SetScreenOffMode(Dali::Window::ScreenOffMode::Type screenOffMode) = 0;
270
271   /**
272    * @copydoc Dali::Window::GetScreenOffMode()
273    */
274   virtual Dali::Window::ScreenOffMode::Type GetScreenOffMode() const = 0;
275
276   /**
277    * @copydoc Dali::Window::SetBrightness()
278    */
279   virtual bool SetBrightness( int brightness ) = 0;
280
281   /**
282    * @copydoc Dali::Window::GetBrightness()
283    */
284   virtual int GetBrightness() const = 0;
285
286   /**
287    * @copydoc Dali::KeyGrab::GrabKey()
288    */
289   virtual bool GrabKey( Dali::KEY key, KeyGrab::KeyGrabMode grabMode ) = 0;
290
291   /**
292    * @copydoc Dali::KeyGrab::UngrabKey()
293    */
294   virtual bool UngrabKey( Dali::KEY key ) = 0;
295
296   /**
297    * @copydoc Dali::KeyGrab::GrabKeyList()
298    */
299   virtual bool GrabKeyList( const Dali::Vector< Dali::KEY >& key, const Dali::Vector< KeyGrab::KeyGrabMode >& grabMode, Dali::Vector< bool >& result ) = 0;
300
301   /**
302    * @copydoc Dali::KeyGrab::UngrabKeyList()
303    */
304   virtual bool UngrabKeyList( const Dali::Vector< Dali::KEY >& key, Dali::Vector< bool >& result ) = 0;
305
306   /**
307    * @brief Get DPI
308    * @param[out] dpiHorizontal set to the horizontal dpi
309    * @param[out] dpiVertical set to the vertical dpi
310    */
311   virtual void GetDpi( unsigned int& dpiHorizontal, unsigned int& dpiVertical ) = 0;
312
313   /**
314    * @brief Return the orientation of the surface.
315    * @return The orientation
316    */
317   virtual int GetOrientation() const = 0;
318
319   /**
320    * @brief Get the screen rotation angle of the window
321    */
322   virtual int GetScreenRotationAngle() = 0;
323
324   /**
325    * @brief Set the rotation angle of the window
326    */
327   virtual void SetWindowRotationAngle( int degree ) = 0;
328
329     /**
330    * @brief Get the rotation angle of the window
331    */
332   virtual int GetWindowRotationAngle() = 0;
333
334   /**
335    * @brief Inform the window rotation is completed
336    */
337   virtual void WindowRotationCompleted( int degree, int width, int height ) = 0;
338
339   /**
340    * @copydoc Dali::Window::SetTransparency()
341    */
342   virtual void SetTransparency( bool transparent ) = 0;
343
344   /**
345    * @copydoc Dali::Window::SetParent()
346    */
347   virtual void SetParent( WindowBase* parentWinBase ) = 0;
348
349   // Signals
350
351   /**
352    * @brief This signal is emitted when the window becomes iconified or deiconified.
353    */
354    IconifySignalType& IconifyChangedSignal();
355
356   /**
357    * @brief This signal is emitted when the window focus is changed.
358    */
359   FocusSignalType& FocusChangedSignal();
360
361   /**
362    * @brief This signal is emitted when the output is transformed.
363    */
364   OutputSignalType& OutputTransformedSignal();
365
366   /**
367    * @brief This signal is emitted when the window receives a delete request.
368    */
369   DeleteSignalType& DeleteRequestSignal();
370
371   /**
372    * @brief This signal is emitted when the window is damaged.
373    */
374   DamageSignalType& WindowDamagedSignal();
375
376   /**
377    * @brief This signal is emitted when a rotation event is recevied.
378    */
379   RotationSignalType& RotationSignal();
380
381   /**
382    * @brief This signal is emitted when a touch event is received.
383    */
384   TouchEventSignalType& TouchEventSignal();
385
386   /**
387    * @brief This signal is emitted when a mouse wheel is received.
388    */
389   WheelEventSignalType& WheelEventSignal();
390
391   /**
392    * @brief This signal is emitted when a key event is received.
393    */
394   KeyEventSignalType& KeyEventSignal();
395
396   /**
397    * @brief This signal is emitted when the source window notifies us the content in clipboard is selected.
398    */
399   SelectionSignalType& SelectionDataSendSignal();
400
401   /**
402    * @brief This signal is emitted when the source window sends us about the selected content.
403    */
404   SelectionSignalType& SelectionDataReceivedSignal();
405
406   /**
407    * @brief This signal is emitted when the style is changed.
408    */
409   StyleSignalType& StyleChangedSignal();
410
411   /**
412    * @brief This signal is emitted when an accessibility event is received.
413    */
414   AccessibilitySignalType& AccessibilitySignal();
415
416   /**
417    * @brief This signal is emitted when window's transition animation is started or ended.
418    */
419   TransitionEffectEventSignalType& TransitionEffectEventSignal();
420
421 protected:
422
423   // Undefined
424   WindowBase(const WindowBase&) = delete;
425
426   // Undefined
427   WindowBase& operator=(const WindowBase& rhs) = delete;
428
429 protected:
430
431   IconifySignalType                    mIconifyChangedSignal;
432   FocusSignalType                      mFocusChangedSignal;
433   OutputSignalType                     mOutputTransformedSignal;
434   DeleteSignalType                     mDeleteRequestSignal;
435   DamageSignalType                     mWindowDamagedSignal;
436   RotationSignalType                   mRotationSignal;
437   TouchEventSignalType                 mTouchEventSignal;
438   WheelEventSignalType                 mWheelEventSignal;
439   KeyEventSignalType                   mKeyEventSignal;
440   SelectionSignalType                  mSelectionDataSendSignal;
441   SelectionSignalType                  mSelectionDataReceivedSignal;
442   StyleSignalType                      mStyleChangedSignal;
443   AccessibilitySignalType              mAccessibilitySignal;
444   TransitionEffectEventSignalType      mTransitionEffectEventSignal;
445 };
446
447 } // namespace Adaptor
448
449 } // namespace internal
450
451 } // namespace Dali
452
453 #endif // DALI_INTERNAL_WINDOWSYSTEM_COMMON_WINDOW_BASE_H