7e0c3dca494668967e60533cfba394b4bf2a61c0
[platform/core/uifw/dali-adaptor.git] / dali / devel-api / adaptor-framework / window-devel.cpp
1 /*
2  * Copyright (c) 2023 Samsung Electronics Co., Ltd.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  */
17
18 // EXTERNAL INCLUDES
19 #include <dali/public-api/adaptor-framework/window-enumerations.h>
20 #include <dali/public-api/events/key-event.h>
21 #include <dali/public-api/events/wheel-event.h>
22
23 // INTERNAL INCLUDES
24 #include <dali/devel-api/adaptor-framework/window-devel.h>
25 #include <dali/internal/window-system/common/window-impl.h>
26
27 namespace Dali
28 {
29 namespace DevelWindow
30 {
31 Window New(Any surface, PositionSize windowPosition, const std::string& name, bool isTransparent)
32 {
33   return DevelWindow::New(surface, windowPosition, name, "", isTransparent);
34 }
35
36 Window New(Any surface, PositionSize windowPosition, const std::string& name, const std::string& className, bool isTransparent)
37 {
38   Window newWindow;
39
40   const bool isAdaptorAvailable = Dali::Adaptor::IsAvailable();
41   bool       isNewWindowAllowed = true;
42
43   if(isAdaptorAvailable)
44   {
45     Dali::Adaptor& adaptor = Internal::Adaptor::Adaptor::Get();
46     isNewWindowAllowed     = Internal::Adaptor::Adaptor::GetImplementation(adaptor).IsMultipleWindowSupported();
47   }
48
49   if(isNewWindowAllowed)
50   {
51     Internal::Adaptor::Window* window = Internal::Adaptor::Window::New(surface, windowPosition, name, className, WindowType::NORMAL, isTransparent);
52
53     Integration::SceneHolder sceneHolder = Integration::SceneHolder(window);
54     if(isAdaptorAvailable)
55     {
56       Dali::Adaptor& adaptor = Internal::Adaptor::Adaptor::Get();
57       Internal::Adaptor::Adaptor::GetImplementation(adaptor).AddWindow(sceneHolder);
58     }
59     newWindow = Window(window);
60   }
61   else
62   {
63     DALI_LOG_ERROR("This device can't support multiple windows.\n");
64   }
65
66   return newWindow;
67 }
68
69 void SetPositionSize(Window window, PositionSize positionSize)
70 {
71   GetImplementation(window).SetPositionSize(positionSize);
72 }
73
74 Window Get(Actor actor)
75 {
76   return Internal::Adaptor::Window::Get(actor);
77 }
78
79 EventProcessingFinishedSignalType& EventProcessingFinishedSignal(Window window)
80 {
81   return GetImplementation(window).EventProcessingFinishedSignal();
82 }
83
84 WheelEventSignalType& WheelEventSignal(Window window)
85 {
86   return GetImplementation(window).WheelEventSignal();
87 }
88
89 VisibilityChangedSignalType& VisibilityChangedSignal(Window window)
90 {
91   return GetImplementation(window).VisibilityChangedSignal();
92 }
93
94 TransitionEffectEventSignalType& TransitionEffectEventSignal(Window window)
95 {
96   return GetImplementation(window).TransitionEffectEventSignal();
97 }
98
99 KeyboardRepeatSettingsChangedSignalType& KeyboardRepeatSettingsChangedSignal(Window window)
100 {
101   return GetImplementation(window).KeyboardRepeatSettingsChangedSignal();
102 }
103
104 AuxiliaryMessageSignalType& AuxiliaryMessageSignal(Window window)
105 {
106   return GetImplementation(window).AuxiliaryMessageSignal();
107 }
108
109 AccessibilityHighlightSignalType& AccessibilityHighlightSignal(Window window)
110 {
111   return GetImplementation(window).AccessibilityHighlightSignal();
112 }
113
114 MovedSignalType& MovedSignal(Window window)
115 {
116   return GetImplementation(window).MovedSignal();
117 }
118
119 OrientationChangedSignalType& OrientationChangedSignal(Window window)
120 {
121   return GetImplementation(window).OrientationChangedSignal();
122 }
123
124 MoveCompletedSignalType& MoveCompletedSignal(Window window)
125 {
126   return GetImplementation(window).MoveCompletedSignal();
127 }
128
129 ResizeCompletedSignalType& ResizeCompletedSignal(Window window)
130 {
131   return GetImplementation(window).ResizeCompletedSignal();
132 }
133
134 void SetParent(Window window, Window parent)
135 {
136   GetImplementation(window).SetParent(parent);
137 }
138
139 void SetParent(Window window, Window parent, bool belowParent)
140 {
141   GetImplementation(window).SetParent(parent, belowParent);
142 }
143
144 void Unparent(Window window)
145 {
146   GetImplementation(window).Unparent();
147 }
148
149 Window GetParent(Window window)
150 {
151   return GetImplementation(window).GetParent();
152 }
153
154 WindowOrientation GetCurrentOrientation(Window window)
155 {
156   return GetImplementation(window).GetCurrentOrientation();
157 }
158
159 int GetPhysicalOrientation(Window window)
160 {
161   return GetImplementation(window).GetPhysicalOrientation();
162 }
163
164 void SetAvailableOrientations(Window window, const Dali::Vector<WindowOrientation>& orientations)
165 {
166   GetImplementation(window).SetAvailableOrientations(orientations);
167 }
168
169 int32_t GetNativeId(Window window)
170 {
171   return GetImplementation(window).GetNativeId();
172 }
173
174 void AddFrameRenderedCallback(Window window, std::unique_ptr<CallbackBase> callback, int32_t frameId)
175 {
176   GetImplementation(window).AddFrameRenderedCallback(std::move(callback), frameId);
177 }
178
179 void AddFramePresentedCallback(Window window, std::unique_ptr<CallbackBase> callback, int32_t frameId)
180 {
181   GetImplementation(window).AddFramePresentedCallback(std::move(callback), frameId);
182 }
183
184 void SetPositionSizeWithOrientation(Window window, PositionSize positionSize, WindowOrientation orientation)
185 {
186   GetImplementation(window).SetPositionSizeWithOrientation(positionSize, orientation);
187 }
188
189 void RequestMoveToServer(Window window)
190 {
191   GetImplementation(window).RequestMoveToServer();
192 }
193
194 void RequestResizeToServer(Window window, WindowResizeDirection direction)
195 {
196   GetImplementation(window).RequestResizeToServer(direction);
197 }
198
199 void EnableFloatingMode(Window window, bool enable)
200 {
201   GetImplementation(window).EnableFloatingMode(enable);
202 }
203
204 bool IsFloatingModeEnabled(Window window)
205 {
206   return GetImplementation(window).IsFloatingModeEnabled();
207 }
208
209 void IncludeInputRegion(Window window, const Rect<int>& inputRegion)
210 {
211   GetImplementation(window).IncludeInputRegion(inputRegion);
212 }
213
214 void ExcludeInputRegion(Window window, const Rect<int>& inputRegion)
215 {
216   GetImplementation(window).ExcludeInputRegion(inputRegion);
217 }
218
219 void SetNeedsRotationCompletedAcknowledgement(Window window, bool needAcknowledgement)
220 {
221   GetImplementation(window).SetNeedsRotationCompletedAcknowledgement(needAcknowledgement);
222 }
223
224 void SendRotationCompletedAcknowledgement(Window window)
225 {
226   GetImplementation(window).SendRotationCompletedAcknowledgement();
227 }
228
229 void FeedTouchPoint(Window window, const Dali::TouchPoint& point, int32_t timeStamp)
230 {
231   Integration::Point convertedPoint(point);
232   GetImplementation(window).FeedTouchPoint(convertedPoint, timeStamp);
233 }
234
235 void FeedWheelEvent(Window window, const Dali::WheelEvent& wheelEvent)
236 {
237   Integration::WheelEvent convertedEvent(static_cast<Integration::WheelEvent::Type>(wheelEvent.GetType()), wheelEvent.GetDirection(), wheelEvent.GetModifiers(), wheelEvent.GetPoint(), wheelEvent.GetDelta(), wheelEvent.GetTime());
238   GetImplementation(window).FeedWheelEvent(convertedEvent);
239 }
240
241 void FeedKeyEvent(Window window, const Dali::KeyEvent& keyEvent)
242 {
243   Integration::KeyEvent convertedEvent(keyEvent.GetKeyName(), keyEvent.GetLogicalKey(), keyEvent.GetKeyString(), keyEvent.GetKeyCode(), keyEvent.GetKeyModifier(), keyEvent.GetTime(), static_cast<Integration::KeyEvent::State>(keyEvent.GetState()), keyEvent.GetCompose(), keyEvent.GetDeviceName(), keyEvent.GetDeviceClass(), keyEvent.GetDeviceSubclass());
244   GetImplementation(window).FeedKeyEvent(convertedEvent);
245 }
246
247 void Maximize(Window window, bool maximize)
248 {
249   GetImplementation(window).Maximize(maximize);
250 }
251
252 bool IsMaximized(Window window)
253 {
254   return GetImplementation(window).IsMaximized();
255 }
256
257 void SetMaximumSize(Window window, Dali::Window::WindowSize size)
258 {
259   GetImplementation(window).SetMaximumSize(size);
260 }
261
262 void Minimize(Window window, bool miniimize)
263 {
264   GetImplementation(window).Minimize(miniimize);
265 }
266
267 bool IsMinimized(Window window)
268 {
269   return GetImplementation(window).IsMinimized();
270 }
271
272 void SetMimimumSize(Window window, Dali::Window::WindowSize size)
273 {
274   GetImplementation(window).SetMimimumSize(size);
275 }
276
277 bool IsWindowRotating(Window window)
278 {
279   return GetImplementation(window).IsWindowRotating();
280 }
281
282 const KeyEvent& GetLastKeyEvent(Window window)
283 {
284   return GetImplementation(window).GetLastKeyEvent();
285 }
286
287 const TouchEvent& GetLastTouchEvent(Window window)
288 {
289   return GetImplementation(window).GetLastTouchEvent();
290 }
291
292 InterceptKeyEventSignalType& InterceptKeyEventSignal(Window window)
293 {
294   return GetImplementation(window).InterceptKeyEventSignal();
295 }
296
297 MouseInOutEventSignalType& MouseInOutEventSignal(Window window)
298 {
299   return GetImplementation(window).MouseInOutEventSignal();
300 }
301
302 } // namespace DevelWindow
303
304 } // namespace Dali