Add Window::SetLayout method
[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) 2022 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  * WindowBaseAndroid class provides an WindowBase Android implementation.
35  */
36 class WindowBaseAndroid : public WindowBase
37 {
38 public:
39   /**
40    * @brief Constructor
41    */
42   WindowBaseAndroid(PositionSize positionSize, Any surface, bool isTransparent);
43
44   /**
45    * @brief Destructor
46    */
47   virtual ~WindowBaseAndroid();
48
49 public:
50   /**
51    * @brief Called when the window property is changed.
52    */
53   bool OnWindowPropertyChanged(void* data, int type, void* event);
54
55   /**
56    * @brief Called when the window receives a delete request
57    */
58   void OnDeleteRequest();
59
60   /**
61    * @brief Called when the window gains focus.
62    */
63   void OnFocusIn(void* data, int type, void* event);
64
65   /**
66    * @brief Called when the window loses focus.
67    */
68   void OnFocusOut(void* data, int type, void* event);
69
70   /**
71    * @brief Called when the window is damaged.
72    */
73   void OnWindowDamaged(void* data, int type, void* event);
74
75   /**
76    * @brief Called when a touch down is received.
77    */
78   void OnMouseButtonDown(void* data, int type, void* event);
79
80   /**
81    * @brief Called when a touch up is received.
82    */
83   void OnMouseButtonUp(void* data, int type, void* event);
84
85   /**
86    * @brief Called when a touch motion is received.
87    */
88   void OnMouseButtonMove(void* data, int type, void* event);
89
90   /**
91    * @brief Called when a mouse wheel is received.
92    */
93   void OnMouseWheel(void* data, int type, void* event);
94
95   /**
96    * @brief Called when a key down is received.
97    */
98   void OnKeyDown(void* data, int type, void* event);
99
100   /**
101    * @brief Called when a key up is received.
102    */
103   void OnKeyUp(void* data, int type, void* event);
104
105   /**
106    * @brief Called when the source window notifies us the content in clipboard is selected.
107    */
108   void OnSelectionClear(void* data, int type, void* event);
109
110   /**
111    * @brief Called when the source window sends us about the selected content.
112    */
113   void OnSelectionNotify(void* data, int type, void* event);
114
115 public:
116   /**
117    * @copydoc Dali::Internal::Adaptor::WindowBase::GetNativeWindow()
118    */
119   Any GetNativeWindow() override;
120
121   /**
122    * @copydoc Dali::Internal::Adaptor::WindowBase::GetNativeWindowId()
123    */
124   int GetNativeWindowId() override;
125
126   /**
127    * @copydoc Dali::Internal::Adaptor::WindowBase::GetNativeWindowResourceId()
128    */
129   std::string GetNativeWindowResourceId() override;
130
131   /**
132    * @copydoc Dali::Internal::Adaptor::WindowBase::CreateEglWindow()
133    */
134   EGLNativeWindowType CreateEglWindow(int width, int height) override;
135
136   /**
137    * @copydoc Dali::Internal::Adaptor::WindowBase::DestroyEglWindow()
138    */
139   void DestroyEglWindow() override;
140
141   /**
142    * @copydoc Dali::Internal::Adaptor::WindowBase::SetEglWindowRotation()
143    */
144   void SetEglWindowRotation(int angle) override;
145
146   /**
147    * @copydoc Dali::Internal::Adaptor::WindowBase::SetEglWindowBufferTransform()
148    */
149   void SetEglWindowBufferTransform(int angle) override;
150
151   /**
152    * @copydoc Dali::Internal::Adaptor::WindowBase::SetEglWindowTransform()
153    */
154   void SetEglWindowTransform(int angle) override;
155
156   /**
157    * @copydoc Dali::Internal::Adaptor::WindowBase::ResizeEglWindow()
158    */
159   void ResizeEglWindow(PositionSize positionSize) override;
160
161   /**
162    * @copydoc Dali::Internal::Adaptor::WindowBase::IsEglWindowRotationSupported()
163    */
164   bool IsEglWindowRotationSupported() override;
165
166   /**
167    * @copydoc Dali::Internal::Adaptor::WindowBase::Move()
168    */
169   void Move(PositionSize positionSize) override;
170
171   /**
172    * @copydoc Dali::Internal::Adaptor::WindowBase::Resize()
173    */
174   void Resize(PositionSize positionSize) override;
175
176   /**
177    * @copydoc Dali::Internal::Adaptor::WindowBase::MoveResize()
178    */
179   void MoveResize(PositionSize positionSize) override;
180
181  /**
182    * @copydoc Dali::Internal::Adaptor::WindowBase::SetLayout()
183    */
184   void SetLayout(unsigned int numCols, unsigned int numRows, unsigned int column, unsigned int row, unsigned int colSpan, unsigned int rowSpan) override;
185
186   /**
187    * @copydoc Dali::Internal::Adaptor::WindowBase::SetClass()
188    */
189   void SetClass(const std::string& name, const std::string& className) override;
190
191   /**
192    * @copydoc Dali::Internal::Adaptor::WindowBase::Raise()
193    */
194   void Raise() override;
195
196   /**
197    * @copydoc Dali::Internal::Adaptor::WindowBase::Lower()
198    */
199   void Lower() override;
200
201   /**
202    * @copydoc Dali::Internal::Adaptor::WindowBase::Activate()
203    */
204   void Activate() override;
205
206   /**
207    * @copydoc Dali::Internal::Adaptor::WindowBase::Maximize()
208    */
209   void Maximize(bool maximize) override;
210
211   /**
212    * @copydoc Dali::Internal::Adaptor::WindowBase::IsMaximized()
213    */
214   bool IsMaximized() const override;
215
216   /**
217    * @copydoc Dali::Internal::Adaptor::WindowBase::SetMaximumSize()
218    */
219   void SetMaximumSize(Dali::Window::WindowSize size) override;
220
221   /**
222    * @copydoc Dali::Internal::Adaptor::WindowBase::Minimize()
223    */
224   void Minimize(bool minimize) override;
225
226   /**
227    * @copydoc Dali::Internal::Adaptor::WindowBase::IsMinimized()
228    */
229   bool IsMinimized() const override;
230
231   /**
232    * @copydoc Dali::Internal::Adaptor::WindowBase::SetMimimumSize()
233    */
234   void SetMimimumSize(Dali::Window::WindowSize size) override;
235
236   /**
237    * @copydoc Dali::Internal::Adaptor::WindowBase::SetAvailableAnlges()
238    */
239   void SetAvailableAnlges(const std::vector<int>& angles) override;
240
241   /**
242    * @copydoc Dali::Internal::Adaptor::WindowBase::SetPreferredAngle()
243    */
244   void SetPreferredAngle(int angle) override;
245
246   /**
247    * @copydoc Dali::Internal::Adaptor::WindowBase::SetAcceptFocus()
248    */
249   void SetAcceptFocus(bool accept) override;
250
251   /**
252    * @copydoc Dali::Internal::Adaptor::WindowBase::Show()
253    */
254   void Show() override;
255
256   /**
257    * @copydoc Dali::Internal::Adaptor::WindowBase::Hide()
258    */
259   void Hide() override;
260
261   /**
262    * @copydoc Dali::Internal::Adaptor::WindowBase::GetSupportedAuxiliaryHintCount()
263    */
264   unsigned int GetSupportedAuxiliaryHintCount() const override;
265
266   /**
267    * @copydoc Dali::Internal::Adaptor::WindowBase::GetSupportedAuxiliaryHint()
268    */
269   std::string GetSupportedAuxiliaryHint(unsigned int index) const override;
270
271   /**
272    * @copydoc Dali::Internal::Adaptor::WindowBase::AddAuxiliaryHint()
273    */
274   unsigned int AddAuxiliaryHint(const std::string& hint, const std::string& value) override;
275
276   /**
277    * @copydoc Dali::Internal::Adaptor::WindowBase::RemoveAuxiliaryHint()
278    */
279   bool RemoveAuxiliaryHint(unsigned int id) override;
280
281   /**
282    * @copydoc Dali::Internal::Adaptor::WindowBase::SetAuxiliaryHintValue()
283    */
284   bool SetAuxiliaryHintValue(unsigned int id, const std::string& value) override;
285
286   /**
287    * @copydoc Dali::Internal::Adaptor::WindowBase::GetAuxiliaryHintValue()
288    */
289   std::string GetAuxiliaryHintValue(unsigned int id) const override;
290
291   /**
292    * @copydoc Dali::Internal::Adaptor::WindowBase::GetAuxiliaryHintId()
293    */
294   unsigned int GetAuxiliaryHintId(const std::string& hint) const override;
295
296   /**
297    * @copydoc Dali::Internal::Adaptor::WindowBase::SetInputRegion()
298    */
299   void SetInputRegion(const Rect<int>& inputRegion) override;
300
301   /**
302    * @copydoc Dali::Internal::Adaptor::WindowBase::SetType()
303    */
304   void SetType(Dali::WindowType type) override;
305
306   /**
307    * @copydoc Dali::Internal::Adaptor::WindowBase::GetType()
308    */
309   Dali::WindowType GetType() const override;
310
311   /**
312    * @copydoc Dali::Internal::Adaptor::WindowBase::SetNotificationLevel()
313    */
314   Dali::WindowOperationResult SetNotificationLevel(Dali::WindowNotificationLevel level) override;
315
316   /**
317    * @copydoc Dali::Internal::Adaptor::WindowBase::GetNotificationLevel()
318    */
319   Dali::WindowNotificationLevel GetNotificationLevel() const override;
320
321   /**
322    * @copydoc Dali::Internal::Adaptor::WindowBase::SetOpaqueState()
323    */
324   void SetOpaqueState(bool opaque) override;
325
326   /**
327    * @copydoc Dali::Internal::Adaptor::WindowBase::SetScreenOffMode()
328    */
329   Dali::WindowOperationResult SetScreenOffMode(WindowScreenOffMode screenOffMode) override;
330
331   /**
332    * @copydoc Dali::Internal::Adaptor::WindowBase::GetScreenOffMode()
333    */
334   WindowScreenOffMode GetScreenOffMode() const override;
335
336   /**
337    * @copydoc Dali::Internal::Adaptor::WindowBase::SetBrightness()
338    */
339   Dali::WindowOperationResult SetBrightness(int brightness) override;
340
341   /**
342    * @copydoc Dali::Internal::Adaptor::WindowBase::GetBrightness()
343    */
344   int GetBrightness() const override;
345
346   /**
347    * @copydoc Dali::Internal::Adaptor::WindowBase::GrabKey()
348    */
349   bool GrabKey(Dali::KEY key, KeyGrab::KeyGrabMode grabMode) override;
350
351   /**
352    * @copydoc Dali::Internal::Adaptor::WindowBase::UngrabKey()
353    */
354   bool UngrabKey(Dali::KEY key) override;
355
356   /**
357    * @copydoc Dali::Internal::Adaptor::WindowBase::GrabKeyList()
358    */
359   bool GrabKeyList(const Dali::Vector<Dali::KEY>& key, const Dali::Vector<KeyGrab::KeyGrabMode>& grabMode, Dali::Vector<bool>& result) override;
360
361   /**
362    * @copydoc Dali::Internal::Adaptor::WindowBase::UngrabKeyList()
363    */
364   bool UngrabKeyList(const Dali::Vector<Dali::KEY>& key, Dali::Vector<bool>& result) override;
365
366   /**
367    * @copydoc Dali::Internal::Adaptor::WindowBase::GetDpi()
368    */
369   void GetDpi(unsigned int& dpiHorizontal, unsigned int& dpiVertical) override;
370
371   /**
372    * @copydoc Dali::Internal::Adaptor::WindowBase::GetScreenRotationAngle()
373    */
374   int GetScreenRotationAngle() override;
375
376   /**
377    * @copydoc Dali::Internal::Adaptor::WindowBase::SetWindowRotationAngle()
378    */
379   void SetWindowRotationAngle(int degree) override;
380
381   /**
382    * @copydoc Dali::Internal::Adaptor::WindowBase::WindowRotationCompleted()
383    */
384   void WindowRotationCompleted(int degree, int width, int height) override;
385
386   /**
387    * @copydoc Dali::Internal::Adaptor::WindowBase::SetTransparency()
388    */
389   void SetTransparency(bool transparent) override;
390
391   /**
392    * @copydoc  Dali::Internal::Adaptor::WindowBase::SetParent()
393    */
394   void SetParent(WindowBase* parentWinBase, bool belowParent) override;
395
396   /**
397    * @copydoc  Dali::Internal::Adaptor::WindowBase::CreateFrameRenderedSyncFence()
398    */
399   int CreateFrameRenderedSyncFence() override;
400
401   /**
402    * @copydoc  Dali::Internal::Adaptor::WindowBase::CreateFramePresentedSyncFence()
403    */
404   int CreateFramePresentedSyncFence() override;
405
406   /**
407    * @copydoc Dali::Internal::Adaptor::WindowBase::GetWindowRotationAngle()
408    */
409   int GetWindowRotationAngle() const override;
410
411   /**
412    * @copydoc Dali::Internal::Adaptor::WindowBase::SetPositionSizeWithAngle()
413    */
414   void SetPositionSizeWithAngle(PositionSize positionSize, int angle) override;
415
416   /**
417    * @copydoc Dali::Internal::Adaptor::WindowBase::InitializeIme()
418    */
419   void InitializeIme() override;
420
421   /**
422    * @copydoc Dali::Internal::Adaptor::WindowBase::ImeWindowReadyToRender()
423    */
424   void ImeWindowReadyToRender() override;
425
426   /**
427    *
428    * @copydoc Dali::Internal::Adaptor::WindowBase::RequestMoveToServer()
429    */
430   void RequestMoveToServer() override;
431
432   /**
433    * @copydoc Dali::Internal::Adaptor::WindowBase::RequestResizeToServer()
434    */
435   void RequestResizeToServer(WindowResizeDirection direction) override;
436
437   /**
438    * @copydoc Dali::Internal::Adaptor::WindowBase::EnableFloatingMode()
439    */
440   void EnableFloatingMode(bool enable) override;
441
442   /**
443    * @copydoc Dali::Internal::Adaptor::WindowBase::IsFloatingModeEnabled()
444    */
445   bool IsFloatingModeEnabled() const override;
446
447   /**
448    * @copydoc Dali::Internal::Adaptor::WindowBase::IncludeInputRegion()
449    */
450   void IncludeInputRegion(const Rect<int>& inputRegion) override;
451
452   /**
453    * @copydoc Dali::Internal::Adaptor::WindowBase::ExcludeInputRegion()
454    */
455   void ExcludeInputRegion(const Rect<int>& inputRegion) override;
456
457 private:
458   /**
459    * Second stage initialization
460    */
461   void Initialize(PositionSize positionSize, Any surface, bool isTransparent);
462
463   /**
464    * @brief Get the surface id if the surface parameter is not empty
465    * @param surface Any containing a surface id, or can be empty
466    * @return surface id, or zero if surface is empty
467    */
468   unsigned int GetSurfaceId(Any surface) const;
469
470 protected:
471   // Undefined
472   WindowBaseAndroid(const WindowBaseAndroid&) = delete;
473
474   // Undefined
475   WindowBaseAndroid& operator=(const WindowBaseAndroid& rhs) = delete;
476
477 private:
478   ANativeWindow* mWindow;         ///< Native window handle
479   bool           mOwnSurface : 1; ///< Whether we own the surface (responsible for deleting it)
480   bool           mIsTransparent;  ///< Whether the window is transparent (32 bit or 24 bit)
481   bool           mRotationAppSet : 1;
482 };
483
484 } // namespace Adaptor
485
486 } // namespace Internal
487
488 } // namespace Dali
489
490 #endif // DALI_INTERNAL_WINDOWSYSTEM_ANDROID_WINDOW_BASE_ANDROID_H