Updated header files to new format too
[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) 2021 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/integration-api/events/wheel-event-integ.h>
25 #include <cstdint>
26 #include <string>
27 #include <vector>
28
29 // INTERNAL INCLUDES
30 #include <dali/devel-api/adaptor-framework/window-devel.h>
31 #include <dali/internal/graphics/gles/egl-implementation.h>
32 #include <dali/internal/window-system/common/damage-observer.h>
33 #include <dali/internal/window-system/common/rotation-event.h>
34 #include <dali/public-api/adaptor-framework/key-grab.h>
35 #include <dali/public-api/adaptor-framework/style-change.h>
36 #include <dali/public-api/adaptor-framework/window-enumerations.h>
37 #include <dali/public-api/adaptor-framework/window.h>
38
39 namespace Dali
40 {
41 namespace Internal
42 {
43 namespace Adaptor
44 {
45 /**
46  * WindowBase interface
47  */
48 class WindowBase
49 {
50 public:
51   /**
52    * @brief Struct used to retrieve accessibility information
53    */
54   struct AccessibilityInfo
55   {
56     int gestureValue;
57     int startX;
58     int startY;
59     int endX;
60     int endY;
61     int state;
62     int eventTime;
63   };
64
65   // Window
66   typedef Signal<void(bool)>                                IconifySignalType;
67   typedef Signal<void(bool)>                                FocusSignalType;
68   typedef Signal<void()>                                    OutputSignalType;
69   typedef Signal<void()>                                    DeleteSignalType;
70   typedef Signal<void(const DamageArea&)>                   DamageSignalType;
71   typedef Signal<void(const RotationEvent&)>                RotationSignalType;
72   typedef Signal<void(WindowEffectState, WindowEffectType)> TransitionEffectEventSignalType;
73   typedef Signal<void()>                                    KeyboardRepeatSettingsChangedSignalType;
74   typedef Signal<void()>                                    WindowRedrawRequestSignalType;
75
76   // Input events
77   typedef Signal<void(Integration::Point&, uint32_t)> TouchEventSignalType;
78   typedef Signal<void(Integration::WheelEvent&)>      WheelEventSignalType;
79   typedef Signal<void(Integration::KeyEvent&)>        KeyEventSignalType;
80
81   // Clipboard
82   typedef Signal<void(void*)> SelectionSignalType;
83
84   // Accessibility
85   typedef Signal<void(StyleChange::Type)>        StyleSignalType;
86   typedef Signal<void(const AccessibilityInfo&)> AccessibilitySignalType;
87
88   /**
89    * @brief Default constructor
90    */
91   WindowBase();
92
93   /**
94    * @brief Destructor
95    */
96   virtual ~WindowBase();
97
98 public:
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::WindowType type) = 0;
250
251   /**
252    * @copydoc Dali::Window::SetNotificationLevel()
253    */
254   virtual bool SetNotificationLevel(Dali::WindowNotificationLevel level) = 0;
255
256   /**
257    * @copydoc Dali::Window::GetNotificationLevel()
258    */
259   virtual Dali::WindowNotificationLevel 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(WindowScreenOffMode screenOffMode) = 0;
270
271   /**
272    * @copydoc Dali::Window::GetScreenOffMode()
273    */
274   virtual WindowScreenOffMode 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 Inform the window rotation is completed
331    */
332   virtual void WindowRotationCompleted(int degree, int width, int height) = 0;
333
334   /**
335    * @copydoc Dali::Window::SetTransparency()
336    */
337   virtual void SetTransparency(bool transparent) = 0;
338
339   /**
340    * @copydoc Dali::Window::SetParent()
341    */
342   virtual void SetParent(WindowBase* parentWinBase) = 0;
343
344   /**
345    * @brief Create a sync fence that can tell the frame is rendered by the graphics driver.
346    * @return The file descriptor that tells when it is rendered.
347    */
348   virtual int CreateFrameRenderedSyncFence() = 0;
349
350   /**
351    * @brief Create a sync fence that can tell the frame is presented by the display server.
352    * @return The file descriptor that tells when it is presented.
353    */
354   virtual int CreateFramePresentedSyncFence() = 0;
355
356   // Signals
357
358   /**
359    * @brief This signal is emitted when the window becomes iconified or deiconified.
360    */
361   IconifySignalType& IconifyChangedSignal();
362
363   /**
364    * @brief This signal is emitted when the window focus is changed.
365    */
366   FocusSignalType& FocusChangedSignal();
367
368   /**
369    * @brief This signal is emitted when the output is transformed.
370    */
371   OutputSignalType& OutputTransformedSignal();
372
373   /**
374    * @brief This signal is emitted when the window receives a delete request.
375    */
376   DeleteSignalType& DeleteRequestSignal();
377
378   /**
379    * @brief This signal is emitted when the window is damaged.
380    */
381   DamageSignalType& WindowDamagedSignal();
382
383   /**
384    * @brief This signal is emitted when a rotation event is recevied.
385    */
386   RotationSignalType& RotationSignal();
387
388   /**
389    * @brief This signal is emitted when a touch event is received.
390    */
391   TouchEventSignalType& TouchEventSignal();
392
393   /**
394    * @brief This signal is emitted when a mouse wheel is received.
395    */
396   WheelEventSignalType& WheelEventSignal();
397
398   /**
399    * @brief This signal is emitted when a key event is received.
400    */
401   KeyEventSignalType& KeyEventSignal();
402
403   /**
404    * @brief This signal is emitted when the source window notifies us the content in clipboard is selected.
405    */
406   SelectionSignalType& SelectionDataSendSignal();
407
408   /**
409    * @brief This signal is emitted when the source window sends us about the selected content.
410    */
411   SelectionSignalType& SelectionDataReceivedSignal();
412
413   /**
414    * @brief This signal is emitted when the style is changed.
415    */
416   StyleSignalType& StyleChangedSignal();
417
418   /**
419    * @brief This signal is emitted when an accessibility event is received.
420    */
421   AccessibilitySignalType& AccessibilitySignal();
422
423   /**
424    * @brief This signal is emitted when window's transition animation is started or ended.
425    */
426   TransitionEffectEventSignalType& TransitionEffectEventSignal();
427
428   /**
429    * @brief This signal is emitted when the keyboard repeat is changed.
430    */
431   KeyboardRepeatSettingsChangedSignalType& KeyboardRepeatSettingsChangedSignal();
432
433   /**
434    * @brief This signal is emitted when the window redraw is requested.
435    */
436   WindowRedrawRequestSignalType& WindowRedrawRequestSignal();
437
438 protected:
439   // Undefined
440   WindowBase(const WindowBase&) = delete;
441
442   // Undefined
443   WindowBase& operator=(const WindowBase& rhs) = delete;
444
445 protected:
446   IconifySignalType                       mIconifyChangedSignal;
447   FocusSignalType                         mFocusChangedSignal;
448   OutputSignalType                        mOutputTransformedSignal;
449   DeleteSignalType                        mDeleteRequestSignal;
450   DamageSignalType                        mWindowDamagedSignal;
451   RotationSignalType                      mRotationSignal;
452   TouchEventSignalType                    mTouchEventSignal;
453   WheelEventSignalType                    mWheelEventSignal;
454   KeyEventSignalType                      mKeyEventSignal;
455   SelectionSignalType                     mSelectionDataSendSignal;
456   SelectionSignalType                     mSelectionDataReceivedSignal;
457   StyleSignalType                         mStyleChangedSignal;
458   AccessibilitySignalType                 mAccessibilitySignal;
459   TransitionEffectEventSignalType         mTransitionEffectEventSignal;
460   KeyboardRepeatSettingsChangedSignalType mKeyboardRepeatSettingsChangedSignal;
461   WindowRedrawRequestSignalType           mWindowRedrawRequestSignal;
462 };
463
464 } // namespace Adaptor
465
466 } // namespace Internal
467
468 } // namespace Dali
469
470 #endif // DALI_INTERNAL_WINDOWSYSTEM_COMMON_WINDOW_BASE_H