Merge "(Partial update) Fix surface damage area" into devel/master
[platform/core/uifw/dali-adaptor.git] / dali / devel-api / adaptor-framework / window-devel.h
1 #ifndef DALI_WINDOW_DEVEL_H
2 #define DALI_WINDOW_DEVEL_H
3
4 /*
5  * Copyright (c) 2020 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 <memory>
23
24 // INTERNAL INCLUDES
25 #include <dali/public-api/common/vector-wrapper.h>
26 #include <dali/public-api/adaptor-framework/window.h>
27
28 namespace Dali
29 {
30 class KeyEvent;
31 class TouchEvent;
32 class WheelEvent;
33 class RenderTaskList;
34
35 namespace DevelWindow
36 {
37 /**
38  * @brief Enumeration for transition effect's state.
39  */
40 enum class EffectState
41 {
42   NONE = 0,    ///< None state
43   START,       ///< Transition effect is started.
44   END          ///< Transition effect is ended.
45 };
46
47 /**
48  * @brief Enumeration for transition effect's type.
49  */
50 enum class  EffectType
51 {
52   NONE = 0,    ///< None type
53   SHOW,        ///< Window show effect.
54   HIDE,        ///< Window hide effect.
55 };
56
57 typedef Signal< void () > EventProcessingFinishedSignalType;       ///< Event Processing finished signal type
58
59 typedef Signal< void (const KeyEvent&) > KeyEventSignalType;       ///< Key event signal type
60
61 typedef Signal< void (const TouchEvent&) > TouchEventSignalType;   ///< Touch signal type
62
63 typedef Signal< void (const WheelEvent&) > WheelEventSignalType;   ///< Touched signal type
64
65 typedef Signal< void ( Window, bool ) > VisibilityChangedSignalType; ///< Visibility changed signal type
66
67 typedef Signal< void (Window, EffectState, EffectType) > TransitionEffectEventSignalType; ///< Effect signal type and state
68
69 typedef Signal< void () > KeyboardRepeatSettingsChangedSignalType;  ///< Keyboard repeat settings changed signal type
70
71 /**
72  * @brief Creates an initialized handle to a new Window.
73  *
74  * @param[in] surface Can be a window or pixmap.
75  * @param[in] windowPosition The position and size of the Window
76  * @param[in] name The Window title
77  * @param[in] isTransparent Whether Window is transparent
78  * @return A new window
79  * @note This creates an extra window in addition to the default main window
80 */
81 DALI_ADAPTOR_API Window New(Any surface, PositionSize windowPosition, const std::string& name, bool isTransparent = false);
82
83 /**
84  * @brief Creates an initialized handle to a new Window.
85  *
86  * @param[in] surface Can be a window or pixmap.
87  * @param[in] windowPosition The position and size of the Window
88  * @param[in] name The Window title
89  * @param[in] className The Window class name
90  * @param[in] isTransparent Whether Window is transparent
91  * @note This creates an extra window in addition to the default main window
92  * @return A new Window
93  */
94 DALI_ADAPTOR_API Window New(Any surface, PositionSize windowPosition, const std::string& name, const std::string& className, bool isTransparent = false);
95
96 /**
97  * @brief Sets position and size of the window. This API guarantees that both moving and resizing of window will appear on the screen at once.
98  *
99  * @param[in] window The window instance
100  * @param[in] positionSize The new window position and size
101  */
102 DALI_ADAPTOR_API void SetPositionSize( Window window, PositionSize positionSize );
103
104 /**
105  * @brief Retrieve the window that the given actor is added to.
106  *
107  * @param[in] actor The actor
108  * @return The window the actor is added to or an empty handle if the actor is not added to any window.
109  */
110 DALI_ADAPTOR_API Window Get( Actor actor );
111
112 /**
113  * @brief This signal is emitted just after the event processing is finished.
114  *
115  * @param[in] window The window instance
116  * @return The signal to connect to
117  */
118 DALI_ADAPTOR_API EventProcessingFinishedSignalType& EventProcessingFinishedSignal( Window window );
119
120 /**
121  * @brief This signal is emitted when wheel event is received.
122  *
123  * A callback of the following type may be connected:
124  * @code
125  *   void YourCallbackName(const WheelEvent& event);
126  * @endcode
127  * @param[in] window The window instance
128  * @return The signal to connect to
129  */
130 DALI_ADAPTOR_API WheelEventSignalType& WheelEventSignal( Window window );
131
132 /**
133  * @brief This signal is emitted when the window is shown or hidden.
134  *
135  * A callback of the following type may be connected:
136  * @code
137  *   void YourCallbackName( Window window, bool visible );
138  * @endcode
139  * @param[in] window The window instance
140  * @return The signal to connect to
141  */
142 DALI_ADAPTOR_API VisibilityChangedSignalType& VisibilityChangedSignal( Window window );
143
144 /**
145  * @brief This signal is emitted for transition effect.
146  *
147  * The transition animation is appeared when the window is shown/hidden.
148  * When the animation is started, START signal is emitted.
149  * Then the animation is ended, END signal is emitted, too.
150  * A callback of the following type may be connected:
151  * @code
152  *   void YourCallbackName( Window window, EffectState state, EffectType type );
153  * @endcode
154  * @param[in] window The window instance
155  * @return The signal to connect to
156  */
157 DALI_ADAPTOR_API TransitionEffectEventSignalType& TransitionEffectEventSignal( Window window );
158
159 /**
160  * @brief This signal is emitted just after the keyboard repeat setting is changed globally.
161  *
162  * @param[in] window The window instance
163  * @return The signal to connect to
164  */
165 DALI_ADAPTOR_API KeyboardRepeatSettingsChangedSignalType& KeyboardRepeatSettingsChangedSignal( Window window );
166
167 /**
168  * @brief Sets parent window of the window.
169  *
170  * After setting that, these windows do together when raise-up, lower and iconified/deiconified.
171  * Initially, the window is located on top of the parent. The window can go below parent by calling Lower().
172  * If parent's window stack is changed by calling Raise() or Lower(), child windows are located on top of the parent again.
173  *
174  * @param[in] window The window instance
175  * @param[in] parent The parent window instance
176  */
177 DALI_ADAPTOR_API void SetParent( Window window, Window parent );
178
179 /**
180  * @brief Unsets parent window of the window.
181  *
182  * After unsetting, the window is disconnected his parent window.
183  *
184  * @param[in] window The window instance
185  */
186 DALI_ADAPTOR_API void Unparent( Window window );
187
188 /**
189  * @brief Gets parent window of the window.
190  *
191  * @param[in] window The window instance
192  * @return The parent window of the window
193  */
194 DALI_ADAPTOR_API Window GetParent( Window window );
195
196 /**
197  * @brief Downcast sceneHolder to window
198  *
199  * @param[in] handle The handle need to downcast
200  * @return The window cast from SceneHolder
201  */
202 DALI_ADAPTOR_API Window DownCast(  BaseHandle handle );
203
204 /**
205  * @brief Gets current orientation of the window.
206  *
207  * @param[in] window The window instance
208  * @return The current window orientation if previously set, or none
209  */
210 DALI_ADAPTOR_API Dali::Window::WindowOrientation GetCurrentOrientation( Window window );
211
212 /**
213  * @brief Sets available orientations of the window.
214  *
215  * This API is for setting several orientations one time.
216  *
217  * @param[in] window The window instance
218  * @param[in] orientations The available orientation list to add
219  */
220 DALI_ADAPTOR_API void SetAvailableOrientations( Window window, const Dali::Vector<Dali::Window::WindowOrientation>& orientations );
221
222 /**
223  * @brief Gets current window ID.
224  *
225  * @param[in] window The window instance
226  */
227 DALI_ADAPTOR_API int32_t GetNativeId( Window window );
228
229 /**
230  * @brief Adds a callback that is called when the frame rendering is done by the graphics driver.
231  *
232  * @param[in] window The window instance
233  * @param[in] callback The function to call
234  * @param[in] frameId The Id to specify the frame. It will be passed when the callback is called.
235  *
236  * @note A callback of the following type may be used:
237  * @code
238  *   void MyFunction( int frameId );
239  * @endcode
240  * This callback will be deleted once it is called.
241  *
242  * @note Ownership of the callback is passed onto this class.
243  */
244 DALI_ADAPTOR_API void AddFrameRenderedCallback( Window window, std::unique_ptr< CallbackBase > callback, int32_t frameId );
245
246 /**
247  * @brief Adds a callback that is called when the frame is displayed on the display.
248  *
249  * @param[in] window The window instance
250  * @param[in] callback The function to call
251  * @param[in] frameId The Id to specify the frame. It will be passed when the callback is called.
252  *
253  * @note A callback of the following type may be used:
254  * @code
255  *   void MyFunction( int frameId );
256  * @endcode
257  * This callback will be deleted once it is called.
258  *
259  * @note Ownership of the callback is passed onto this class.
260  */
261 DALI_ADAPTOR_API void AddFramePresentedCallback( Window window, std::unique_ptr< CallbackBase > callback, int32_t frameId );
262
263 } // namespace DevelWindow
264
265 } // namespace Dali
266
267 #endif // DALI_WINDOW_DEVEL_H