Changed 'virtual' function override declarations to 'override'.
[platform/core/uifw/dali-adaptor.git] / dali / internal / window-system / android / window-base-android.h
1 #ifndef DALI_INTERNAL_WINDOWSYSTEM_ANDROID_WINDOW_BASE_ANDROID_H
2 #define DALI_INTERNAL_WINDOWSYSTEM_ANDROID_WINDOW_BASE_ANDROID_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
24 // EXTERNAL HEADERS
25 struct ANativeWindow;
26
27 namespace Dali
28 {
29 namespace Internal
30 {
31 namespace Adaptor
32 {
33
34 /**
35  * WindowBaseAndroid class provides an WindowBase Android implementation.
36  */
37 class WindowBaseAndroid : public WindowBase
38 {
39 public:
40
41   /**
42    * @brief Constructor
43    */
44   WindowBaseAndroid( PositionSize positionSize, Any surface, bool isTransparent );
45
46   /**
47    * @brief Destructor
48    */
49   virtual ~WindowBaseAndroid();
50
51 public:
52
53   /**
54    * @brief Called when the window property is changed.
55    */
56   bool OnWindowPropertyChanged( void* data, int type, void* event );
57
58   /**
59    * @brief Called when the window receives a delete request
60    */
61   void OnDeleteRequest();
62
63   /**
64    * @brief Called when the window gains focus.
65    */
66   void OnFocusIn( void* data, int type, void* event );
67
68   /**
69    * @brief Called when the window loses focus.
70    */
71   void OnFocusOut( void* data, int type, void* event );
72
73   /**
74    * @brief Called when the window is damaged.
75    */
76   void OnWindowDamaged( void* data, int type, void* event );
77
78   /**
79    * @brief Called when a touch down is received.
80    */
81   void OnMouseButtonDown( void* data, int type, void* event );
82
83   /**
84    * @brief Called when a touch up is received.
85    */
86   void OnMouseButtonUp( void* data, int type, void* event );
87
88   /**
89    * @brief Called when a touch motion is received.
90    */
91   void OnMouseButtonMove( void* data, int type, void* event );
92
93   /**
94    * @brief Called when a mouse wheel is received.
95    */
96   void OnMouseWheel( void* data, int type, void* event );
97
98   /**
99    * @brief Called when a key down is received.
100    */
101   void OnKeyDown( void* data, int type, void* event );
102
103   /**
104    * @brief Called when a key up is received.
105    */
106   void OnKeyUp( void* data, int type, void* event );
107
108   /**
109    * @brief Called when the source window notifies us the content in clipboard is selected.
110    */
111   void OnSelectionClear( void* data, int type, void* event );
112
113   /**
114    * @brief Called when the source window sends us about the selected content.
115    */
116   void OnSelectionNotify( void* data, int type, void* event );
117
118 public:
119
120   /**
121    * @copydoc Dali::Internal::Adaptor::WindowBase::GetNativeWindow()
122    */
123   Any GetNativeWindow() override;
124
125   /**
126    * @copydoc Dali::Internal::Adaptor::WindowBase::GetNativeWindowId()
127    */
128   int GetNativeWindowId() override;
129
130   /**
131    * @copydoc Dali::Internal::Adaptor::WindowBase::CreateEglWindow()
132    */
133   EGLNativeWindowType CreateEglWindow( int width, int height ) override;
134
135   /**
136    * @copydoc Dali::Internal::Adaptor::WindowBase::DestroyEglWindow()
137    */
138   void DestroyEglWindow() override;
139
140   /**
141    * @copydoc Dali::Internal::Adaptor::WindowBase::SetEglWindowRotation()
142    */
143   void SetEglWindowRotation( int angle ) override;
144
145   /**
146    * @copydoc Dali::Internal::Adaptor::WindowBase::SetEglWindowBufferTransform()
147    */
148   void SetEglWindowBufferTransform( int angle ) override;
149
150   /**
151    * @copydoc Dali::Internal::Adaptor::WindowBase::SetEglWindowTransform()
152    */
153   void SetEglWindowTransform( int angle ) override;
154
155   /**
156    * @copydoc Dali::Internal::Adaptor::WindowBase::ResizeEglWindow()
157    */
158   void ResizeEglWindow( PositionSize positionSize ) override;
159
160   /**
161    * @copydoc Dali::Internal::Adaptor::WindowBase::IsEglWindowRotationSupported()
162    */
163   bool IsEglWindowRotationSupported() override;
164
165   /**
166    * @copydoc Dali::Internal::Adaptor::WindowBase::Move()
167    */
168   void Move( PositionSize positionSize ) override;
169
170   /**
171    * @copydoc Dali::Internal::Adaptor::WindowBase::Resize()
172    */
173   void Resize( PositionSize positionSize ) override;
174
175   /**
176    * @copydoc Dali::Internal::Adaptor::WindowBase::MoveResize()
177    */
178   void MoveResize( PositionSize positionSize ) override;
179
180   /**
181    * @copydoc Dali::Internal::Adaptor::WindowBase::SetClass()
182    */
183   void SetClass( const std::string& name, const std::string& className ) override;
184
185   /**
186    * @copydoc Dali::Internal::Adaptor::WindowBase::Raise()
187    */
188   void Raise() override;
189
190   /**
191    * @copydoc Dali::Internal::Adaptor::WindowBase::Lower()
192    */
193   void Lower() override;
194
195   /**
196    * @copydoc Dali::Internal::Adaptor::WindowBase::Activate()
197    */
198   void Activate() override;
199
200   /**
201    * @copydoc Dali::Internal::Adaptor::WindowBase::SetAvailableAnlges()
202    */
203   void SetAvailableAnlges( const std::vector< int >& angles  ) override;
204
205   /**
206    * @copydoc Dali::Internal::Adaptor::WindowBase::SetPreferredAngle()
207    */
208   void SetPreferredAngle( int angle ) override;
209
210   /**
211    * @copydoc Dali::Internal::Adaptor::WindowBase::SetAcceptFocus()
212    */
213   void SetAcceptFocus( bool accept ) override;
214
215   /**
216    * @copydoc Dali::Internal::Adaptor::WindowBase::Show()
217    */
218   void Show() override;
219
220   /**
221    * @copydoc Dali::Internal::Adaptor::WindowBase::Hide()
222    */
223   void Hide() override;
224
225   /**
226    * @copydoc Dali::Internal::Adaptor::WindowBase::GetSupportedAuxiliaryHintCount()
227    */
228   unsigned int GetSupportedAuxiliaryHintCount() const override;
229
230   /**
231    * @copydoc Dali::Internal::Adaptor::WindowBase::GetSupportedAuxiliaryHint()
232    */
233   std::string GetSupportedAuxiliaryHint( unsigned int index ) const override;
234
235   /**
236    * @copydoc Dali::Internal::Adaptor::WindowBase::AddAuxiliaryHint()
237    */
238   unsigned int AddAuxiliaryHint( const std::string& hint, const std::string& value ) override;
239
240   /**
241    * @copydoc Dali::Internal::Adaptor::WindowBase::RemoveAuxiliaryHint()
242    */
243   bool RemoveAuxiliaryHint( unsigned int id ) override;
244
245   /**
246    * @copydoc Dali::Internal::Adaptor::WindowBase::SetAuxiliaryHintValue()
247    */
248   bool SetAuxiliaryHintValue( unsigned int id, const std::string& value ) override;
249
250   /**
251    * @copydoc Dali::Internal::Adaptor::WindowBase::GetAuxiliaryHintValue()
252    */
253   std::string GetAuxiliaryHintValue( unsigned int id ) const override;
254
255   /**
256    * @copydoc Dali::Internal::Adaptor::WindowBase::GetAuxiliaryHintId()
257    */
258   unsigned int GetAuxiliaryHintId( const std::string& hint ) const override;
259
260   /**
261    * @copydoc Dali::Internal::Adaptor::WindowBase::SetInputRegion()
262    */
263   void SetInputRegion( const Rect< int >& inputRegion ) override;
264
265   /**
266    * @copydoc Dali::Internal::Adaptor::WindowBase::SetType()
267    */
268   void SetType( Dali::Window::Type type ) override;
269
270   /**
271    * @copydoc Dali::Internal::Adaptor::WindowBase::SetNotificationLevel()
272    */
273   bool SetNotificationLevel( Dali::Window::NotificationLevel::Type level ) override;
274
275   /**
276    * @copydoc Dali::Internal::Adaptor::WindowBase::GetNotificationLevel()
277    */
278   Dali::Window::NotificationLevel::Type GetNotificationLevel() const override;
279
280   /**
281    * @copydoc Dali::Internal::Adaptor::WindowBase::SetOpaqueState()
282    */
283   void SetOpaqueState( bool opaque ) override;
284
285   /**
286    * @copydoc Dali::Internal::Adaptor::WindowBase::SetScreenOffMode()
287    */
288   bool SetScreenOffMode(Dali::Window::ScreenOffMode::Type screenOffMode) override;
289
290   /**
291    * @copydoc Dali::Internal::Adaptor::WindowBase::GetScreenOffMode()
292    */
293   Dali::Window::ScreenOffMode::Type GetScreenOffMode() const override;
294
295   /**
296    * @copydoc Dali::Internal::Adaptor::WindowBase::SetBrightness()
297    */
298   bool SetBrightness( int brightness ) override;
299
300   /**
301    * @copydoc Dali::Internal::Adaptor::WindowBase::GetBrightness()
302    */
303   int GetBrightness() const override;
304
305   /**
306    * @copydoc Dali::Internal::Adaptor::WindowBase::GrabKey()
307    */
308   bool GrabKey( Dali::KEY key, KeyGrab::KeyGrabMode grabMode ) override;
309
310   /**
311    * @copydoc Dali::Internal::Adaptor::WindowBase::UngrabKey()
312    */
313   bool UngrabKey( Dali::KEY key ) override;
314
315   /**
316    * @copydoc Dali::Internal::Adaptor::WindowBase::GrabKeyList()
317    */
318   bool GrabKeyList( const Dali::Vector< Dali::KEY >& key, const Dali::Vector< KeyGrab::KeyGrabMode >& grabMode, Dali::Vector< bool >& result ) override;
319
320   /**
321    * @copydoc Dali::Internal::Adaptor::WindowBase::UngrabKeyList()
322    */
323   bool UngrabKeyList( const Dali::Vector< Dali::KEY >& key, Dali::Vector< bool >& result ) override;
324
325   /**
326    * @copydoc Dali::Internal::Adaptor::WindowBase::GetDpi()
327    */
328   void GetDpi( unsigned int& dpiHorizontal, unsigned int& dpiVertical ) override;
329
330   /**
331    * @copydoc Dali::Internal::Adaptor::WindowBase::GetScreenRotationAngle()
332    */
333   int GetScreenRotationAngle() override;
334
335   /**
336    * @copydoc Dali::Internal::Adaptor::WindowBase::SetWindowRotationAngle()
337    */
338   void SetWindowRotationAngle( int degree ) override;
339
340   /**
341    * @copydoc Dali::Internal::Adaptor::WindowBase::WindowRotationCompleted()
342    */
343   void WindowRotationCompleted( int degree, int width, int height ) override;
344
345   /**
346    * @copydoc Dali::Internal::Adaptor::WindowBase::SetTransparency()
347    */
348   void SetTransparency( bool transparent ) 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   unsigned int GetSurfaceId( Any surface ) const;
378
379 protected:
380
381   // Undefined
382   WindowBaseAndroid(const WindowBaseAndroid&) = delete;
383
384   // Undefined
385   WindowBaseAndroid& operator=(const WindowBaseAndroid& rhs) = delete;
386
387 private:
388
389   ANativeWindow*                       mWindow;             ///< Native window handle
390   bool                                 mOwnSurface:1;       ///< Whether we own the surface (responsible for deleting it)
391   bool                                 mIsTransparent;      ///< Whether the window is transparent (32 bit or 24 bit)
392   bool                                 mRotationAppSet:1;
393 };
394
395 } // namespace Adaptor
396
397 } // namespace internal
398
399 } // namespace Dali
400
401 #endif // DALI_INTERNAL_WINDOWSYSTEM_ANDROID_WINDOW_BASE_ANDROID_H