Add input regions APIs
[platform/core/csapi/tizenfx.git] / src / Tizen.NUI / src / public / Window / Window.cs
1 /*
2  * Copyright(c) 2021 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 extern alias TizenSystemInformation;
19 using TizenSystemInformation.Tizen.System;
20
21 using System;
22 using System.ComponentModel;
23 using System.Collections.Generic;
24 using System.Runtime.InteropServices;
25
26 using Tizen.NUI.BaseComponents;
27
28 namespace Tizen.NUI
29 {
30     /// <summary>
31     /// The window class is used internally for drawing.<br />
32     /// The window has an orientation and indicator properties.<br />
33     /// </summary>
34     /// <since_tizen> 3 </since_tizen>
35     public partial class Window : BaseHandle
36     {
37         private HandleRef stageCPtr;
38         private Layer rootLayer;
39         private string windowTitle;
40         private List<Layer> childLayers = new List<Layer>();
41         private LayoutController localController;
42
43         static internal bool IsSupportedMultiWindow()
44         {
45             bool isSupported = false;
46             Information.TryGetValue("http://tizen.org/feature/opengles.surfaceless_context", out isSupported);
47             return isSupported;
48         }
49
50         internal Window(global::System.IntPtr cPtr, bool cMemoryOwn) : base(cPtr, cMemoryOwn)
51         {
52             if (Interop.Stage.IsInstalled())
53             {
54                 stageCPtr = new global::System.Runtime.InteropServices.HandleRef(this, Interop.Stage.GetCurrent());
55
56                 localController = new LayoutController(this);
57                 NUILog.Debug("layoutController id:" + localController.GetId());
58             }
59         }
60
61         /// <summary>
62         /// A helper method to get the current window where the view is added
63         /// </summary>
64         /// <param name="view">The View added to the window</param>
65         /// <returns>A Window.</returns>
66         [EditorBrowsable(EditorBrowsableState.Never)]
67         static public Window Get(View view)
68         {
69             if(view == null)
70             {
71                 NUILog.Error("if there is no view, it can not get a window");
72                 return null;
73             }
74
75             Window ret = Registry.GetManagedBaseHandleFromNativePtr(Interop.Window.Get(View.getCPtr(view))) as Window;
76             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
77             return ret;
78         }
79
80         /// <summary>
81         /// Creates a new Window.<br />
82         /// This creates an extra window in addition to the default main window<br />
83         /// </summary>
84         /// <param name="windowPosition">The position and size of the Window.</param>
85         /// <param name="isTranslucent">Whether Window is translucent.</param>
86         /// <returns>A new Window.</returns>
87         /// <since_tizen> 6 </since_tizen>
88         /// <feature> http://tizen.org/feature/opengles.surfaceless_context </feature>
89         /// <exception cref="NotSupportedException">The required feature is not supported.</exception>
90         public Window(Rectangle windowPosition = null, bool isTranslucent = false) : this(Interop.Window.New(Rectangle.getCPtr(windowPosition), "", isTranslucent), true)
91         {
92             if (IsSupportedMultiWindow() == false)
93             {
94                 NUILog.Error("This device does not support surfaceless_context. So Window cannot be created. ");
95             }
96             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
97         }
98
99         /// <summary>
100         /// Creates a new Window with a specific name.<br />
101         /// This creates an extra window in addition to the default main window<br />
102         /// </summary>
103         /// <param name="name">The name for extra window. </param>
104         /// <param name="windowPosition">The position and size of the Window.</param>
105         /// <param name="isTranslucent">Whether Window is translucent.</param>
106         /// <returns>A new Window.</returns>
107         /// <since_tizen> 6 </since_tizen>
108         /// <feature> http://tizen.org/feature/opengles.surfaceless_context </feature>
109         /// <exception cref="NotSupportedException">The required feature is not supported.</exception>
110         public Window(string name, Rectangle windowPosition = null, bool isTranslucent = false) : this(Interop.Window.New(Rectangle.getCPtr(windowPosition), name, isTranslucent), true)
111         {
112             if (IsSupportedMultiWindow() == false)
113             {
114                 NUILog.Error("This device does not support surfaceless_context. So Window cannot be created. ");
115             }
116             this.windowTitle = name;
117             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
118         }
119
120         /// <summary>
121         /// Enumeration for orientation of the window is the way in which a rectangular page is oriented for normal viewing.
122         /// </summary>
123         /// <since_tizen> 3 </since_tizen>
124         public enum WindowOrientation
125         {
126             /// <summary>
127             /// Portrait orientation. The height of the display area is greater than the width.
128             /// </summary>
129             /// <since_tizen> 3 </since_tizen>
130             Portrait = 0,
131             /// <summary>
132             /// Landscape orientation. A wide view area is needed.
133             /// </summary>
134             /// <since_tizen> 3 </since_tizen>
135             Landscape = 90,
136             /// <summary>
137             /// Portrait inverse orientation.
138             /// </summary>
139             /// <since_tizen> 3 </since_tizen>
140             PortraitInverse = 180,
141             /// <summary>
142             /// Landscape inverse orientation.
143             /// </summary>
144             /// <since_tizen> 3 </since_tizen>
145             LandscapeInverse = 270,
146             /// <summary>
147             /// No orientation. It is for the preferred orientation
148             /// Especially, NoOrientationPreference only has the effect for the preferred orientation.
149             /// It is used to unset the preferred orientation with SetPreferredOrientation.
150             /// </summary>
151             [EditorBrowsable(EditorBrowsableState.Never)]
152             NoOrientationPreference = -1
153         }
154
155         /// <summary>
156         /// Enumeration for the key grab mode for platform-level APIs.
157         /// </summary>
158         /// <since_tizen> 3 </since_tizen>
159         public enum KeyGrabMode
160         {
161             /// <summary>
162             /// Grabs a key only when on the top of the grabbing-window stack mode.
163             /// </summary>
164             Topmost = 0,
165             /// <summary>
166             /// Grabs a key together with the other client window(s) mode.
167             /// </summary>
168             Shared,
169             /// <summary>
170             /// Grabs a key exclusively regardless of the grabbing-window's position on the window stack with the possibility of overriding the grab by the other client window mode.
171             /// </summary>
172             OverrideExclusive,
173             /// <summary>
174             /// Grabs a key exclusively regardless of the grabbing-window's position on the window stack mode.
175             /// </summary>
176             Exclusive
177         };
178
179         /// <summary>
180         /// Enumeration for transition effect's state.
181         /// </summary>
182         [Obsolete("Please do not use! This will be removed. Please use Window.EffectState instead!")]
183         [EditorBrowsable(EditorBrowsableState.Never)]
184         public enum EffectStates
185         {
186             /// <summary>
187             /// None state.
188             /// </summary>
189             [Obsolete("Please do not use! This will be removed. Please use Window.EffectState.None instead!")]
190             [EditorBrowsable(EditorBrowsableState.Never)]
191             None = 0,
192             /// <summary>
193             /// Transition effect is started.
194             /// </summary>
195             [Obsolete("Please do not use! This will be removed. Please use Window.EffectState.Start instead!")]
196             [EditorBrowsable(EditorBrowsableState.Never)]
197             Start,
198             /// <summary>
199             /// Transition effect is ended.
200             /// </summary>
201             [Obsolete("Please do not use! This will be removed. Please use Window.EffectState.End instead!")]
202             [EditorBrowsable(EditorBrowsableState.Never)]
203             End,
204         }
205
206         /// <summary>
207         /// Enumeration for transition effect's state.
208         /// </summary>
209         [EditorBrowsable(EditorBrowsableState.Never)]
210         public enum EffectState
211         {
212             /// <summary>
213             /// None state.
214             /// </summary>
215             [EditorBrowsable(EditorBrowsableState.Never)]
216             None = 0,
217             /// <summary>
218             /// Transition effect is started.
219             /// </summary>
220             [EditorBrowsable(EditorBrowsableState.Never)]
221             Start,
222             /// <summary>
223             /// Transition effect is ended.
224             /// </summary>
225             [EditorBrowsable(EditorBrowsableState.Never)]
226             End,
227         }
228
229         /// <summary>
230         /// Enumeration for transition effect's type.
231         /// </summary>
232         [Obsolete("Please do not use! This will be removed. Please use Window.EffectType instead!")]
233         [EditorBrowsable(EditorBrowsableState.Never)]
234         public enum EffectTypes
235         {
236             /// <summary>
237             /// None type.
238             /// </summary>
239             [Obsolete("Please do not use! This will be removed. Please use Window.EffectType.None instead!")]
240             [EditorBrowsable(EditorBrowsableState.Never)]
241             None = 0,
242             /// <summary>
243             /// Window show effect.
244             /// </summary>
245             [Obsolete("Please do not use! This will be removed. Please use Window.EffectType.Show instead!")]
246             [EditorBrowsable(EditorBrowsableState.Never)]
247             Show,
248             /// <summary>
249             /// Window hide effect.
250             /// </summary>
251             [Obsolete("Please do not use! This will be removed. Please use Window.EffectType.Hide instead!")]
252             [EditorBrowsable(EditorBrowsableState.Never)]
253             Hide,
254         }
255
256         /// <summary>
257         /// Enumeration for transition effect's type.
258         /// </summary>
259         [EditorBrowsable(EditorBrowsableState.Never)]
260         public enum EffectType
261         {
262             /// <summary>
263             /// None type.
264             /// </summary>
265             [EditorBrowsable(EditorBrowsableState.Never)]
266             None = 0,
267             /// <summary>
268             /// Window show effect.
269             /// </summary>
270             [EditorBrowsable(EditorBrowsableState.Never)]
271             Show,
272             /// <summary>
273             /// Window hide effect.
274             /// </summary>
275             [EditorBrowsable(EditorBrowsableState.Never)]
276             Hide,
277         }
278
279         /// <summary>
280         /// Enumeration for result of window operation.
281         /// </summary>
282         internal enum OperationResult
283         {
284             /// <summary>
285             /// Failed for unknown reason
286             /// </summary>
287             UnknownError = 0,
288             /// <summary>
289             /// Succeed
290             /// </summary>
291             Succeed,
292             /// <summary>
293             /// Permission denied
294             /// </summary>
295             PermissionDenied,
296             /// <summary>
297             /// The operation is not supported.
298             /// </summary>
299             NotSupported,
300         }
301
302         /// <summary>
303         /// Enumeration for window resized mode by display server.
304         /// </summary>
305         [EditorBrowsable(EditorBrowsableState.Never)]
306         public enum ResizeDirection
307         {
308             /// <summary>
309             /// Start resizing window to the top-left edge.
310             /// </summary>
311             [EditorBrowsable(EditorBrowsableState.Never)]
312             TopLeft = 1,
313             /// <summary>
314             /// Start resizing window to the top side.
315             /// </summary>
316             [EditorBrowsable(EditorBrowsableState.Never)]
317             Top = 2,
318             /// <summary>
319             /// Start resizing window to the top-right edge.
320             /// </summary>
321             [EditorBrowsable(EditorBrowsableState.Never)]
322             TopRight = 3,
323             /// <summary>
324             /// Start resizing window to the left side.
325             /// </summary>
326             [EditorBrowsable(EditorBrowsableState.Never)]
327             Left = 4,
328             /// <summary>
329             /// Start resizing window to the right side.
330             /// </summary>
331             [EditorBrowsable(EditorBrowsableState.Never)]
332             Right = 5,
333             /// <summary>
334             /// Start resizing window to the bottom-left edge.
335             /// </summary>
336             [EditorBrowsable(EditorBrowsableState.Never)]
337             BottomLeft = 6,
338             /// <summary>
339             /// Start resizing window to the bottom side.
340             /// </summary>
341             [EditorBrowsable(EditorBrowsableState.Never)]
342             Bottom = 7,
343             /// <summary>
344             /// Start resizing window to the bottom-right edge.
345             /// </summary>
346             [EditorBrowsable(EditorBrowsableState.Never)]
347             BottomRight = 8,
348         }
349
350
351         /// <summary>
352         /// The stage instance property (read-only).<br />
353         /// Gets the current window.<br />
354         /// </summary>
355         /// <since_tizen> 3 </since_tizen>
356         public static Window Instance { get; internal set; }
357
358         /// <summary>
359         /// Gets or sets a window type.
360         /// </summary>
361         /// <since_tizen> 3 </since_tizen>
362         public WindowType Type
363         {
364             get
365             {
366                 WindowType ret = (WindowType)Interop.Window.GetType(SwigCPtr);
367                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw new InvalidOperationException("FATAL: get Exception", NDalicPINVOKE.SWIGPendingException.Retrieve());
368                 return ret;
369             }
370             set
371             {
372                 Interop.Window.SetType(SwigCPtr, (int)value);
373                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
374             }
375         }
376
377         /// <summary>
378         /// Gets/Sets a window title.
379         /// </summary>
380         /// <since_tizen> 4 </since_tizen>
381         public string Title
382         {
383             get
384             {
385                 return windowTitle;
386             }
387             set
388             {
389                 windowTitle = value;
390                 SetClass(windowTitle, "");
391             }
392         }
393
394         /// <summary>
395         /// The rendering behavior of a Window.
396         /// </summary>
397         /// <since_tizen> 5 </since_tizen>
398         public RenderingBehaviorType RenderingBehavior
399         {
400             get
401             {
402                 return GetRenderingBehavior();
403             }
404             set
405             {
406                 SetRenderingBehavior(value);
407             }
408         }
409
410         /// <summary>
411         /// The window size property (read-only).
412         /// </summary>
413         /// <since_tizen> 3 </since_tizen>
414         public Size2D Size
415         {
416             get
417             {
418                 Size2D ret = GetSize();
419                 return ret;
420             }
421         }
422
423         /// <summary>
424         /// The background color property.
425         /// </summary>
426         /// <since_tizen> 3 </since_tizen>
427         public Color BackgroundColor
428         {
429             set
430             {
431                 SetBackgroundColor(value);
432             }
433             get
434             {
435                 Color ret = GetBackgroundColor();
436                 return ret;
437             }
438         }
439
440         /// <summary>
441         /// The DPI property (read-only).<br />
442         /// Retrieves the DPI of the display device to which the Window is connected.<br />
443         /// </summary>
444         /// <since_tizen> 3 </since_tizen>
445         public Vector2 Dpi
446         {
447             get
448             {
449                 return GetDpi();
450             }
451         }
452
453         /// <summary>
454         /// The layer count property (read-only).<br />
455         /// Queries the number of on-Window layers.<br />
456         /// </summary>
457         /// <since_tizen> 3 </since_tizen>
458         public uint LayerCount
459         {
460             get
461             {
462                 return GetLayerCount();
463             }
464         }
465
466         /// <summary>
467         /// Gets or sets a size of the window.
468         /// </summary>
469         /// <exception cref="ArgumentNullException"> Thrown when value is null. </exception>
470         /// <since_tizen> 4 </since_tizen>
471         public Size2D WindowSize
472         {
473             get
474             {
475                 return GetWindowSize();
476             }
477             set
478             {
479                 SetWindowSize(value);
480             }
481         }
482
483         /// <summary>
484         /// Gets or sets a position of the window.
485         /// </summary>
486         /// <exception cref="ArgumentNullException"> Thrown when value is null. </exception>
487         /// <since_tizen> 4 </since_tizen>
488         public Position2D WindowPosition
489         {
490             get
491             {
492                 return GetPosition();
493             }
494             set
495             {
496                 SetPosition(value);
497             }
498         }
499
500         /// <summary>
501         /// Sets position and size of the window. This API guarantees that
502         /// both moving and resizing of window will appear on the screen at once.
503         /// </summary>
504         [EditorBrowsable(EditorBrowsableState.Never)]
505         public Rectangle WindowPositionSize
506         {
507             get
508             {
509                 Position2D position = GetPosition();
510                 Size2D size = GetSize();
511                 Rectangle ret = new Rectangle(position.X, position.Y, size.Width, size.Height);
512                 position.Dispose();
513                 return ret;
514             }
515             set
516             {
517                 SetPositionSize(value);
518             }
519         }
520
521         internal static Vector4 DEFAULT_BACKGROUND_COLOR
522         {
523             get
524             {
525                 global::System.IntPtr cPtr = Interop.Stage.DefaultBackgroundColorGet();
526                 Vector4 ret = (cPtr == global::System.IntPtr.Zero) ? null : new Vector4(cPtr, false);
527                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
528                 return ret;
529             }
530         }
531
532         internal static Vector4 DEBUG_BACKGROUND_COLOR
533         {
534             get
535             {
536                 global::System.IntPtr cPtr = Interop.Stage.DebugBackgroundColorGet();
537                 Vector4 ret = (cPtr == global::System.IntPtr.Zero) ? null : new Vector4(cPtr, false);
538                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
539                 return ret;
540             }
541         }
542
543         internal List<Layer> LayersChildren
544         {
545             get
546             {
547                 return childLayers;
548             }
549         }
550
551         /// <summary>
552         ///  Get the LayoutController for this Window.
553         /// </summary>
554         internal LayoutController LayoutController
555         {
556             get
557             {
558                 return localController;
559             }
560         }
561
562         /// <summary>
563         /// Feed a key-event into the window.
564         /// </summary>
565         /// <param name="keyEvent">The key event to feed.</param>
566         /// <since_tizen> 4 </since_tizen>
567         [Obsolete("Please do not use! This will be deprecated! Please use FeedKey(Key keyEvent) instead!")]
568         public static void FeedKeyEvent(Key keyEvent)
569         {
570             Interop.Window.FeedKeyEvent(Key.getCPtr(keyEvent));
571             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
572         }
573
574         /// <summary>
575         /// Sets whether the window accepts a focus or not.
576         /// </summary>
577         /// <param name="accept">If a focus is accepted or not. The default is true.</param>
578         /// <since_tizen> 3 </since_tizen>
579         public void SetAcceptFocus(bool accept)
580         {
581             Interop.Window.SetAcceptFocus(SwigCPtr, accept);
582             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
583         }
584
585         /// <summary>
586         /// Returns whether the window accepts a focus or not.
587         /// </summary>
588         /// <returns>True if the window accepts a focus, false otherwise.</returns>
589         /// <since_tizen> 3 </since_tizen>
590         public bool IsFocusAcceptable()
591         {
592             bool ret = Interop.Window.IsFocusAcceptable(SwigCPtr);
593             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
594
595             return ret;
596         }
597
598         /// <summary>
599         /// Shows the window if it is hidden.
600         /// </summary>
601         /// <since_tizen> 3 </since_tizen>
602         public void Show()
603         {
604             Interop.Window.Show(SwigCPtr);
605             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
606         }
607
608         /// <summary>
609         /// Hides the window if it is showing.
610         /// </summary>
611         /// <since_tizen> 3 </since_tizen>
612         public void Hide()
613         {
614             Interop.Window.Hide(SwigCPtr);
615             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
616         }
617
618         /// <summary>
619         /// Retrieves whether the window is visible or not.
620         /// </summary>
621         /// <returns>True if the window is visible.</returns>
622         /// <since_tizen> 3 </since_tizen>
623         public bool IsVisible()
624         {
625             bool temp = Interop.Window.IsVisible(SwigCPtr);
626             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
627             return temp;
628         }
629
630         /// <summary>
631         /// Gets the count of supported auxiliary hints of the window.
632         /// </summary>
633         /// <returns>The number of supported auxiliary hints.</returns>
634         /// <since_tizen> 3 </since_tizen>
635         public uint GetSupportedAuxiliaryHintCount()
636         {
637             uint ret = Interop.Window.GetSupportedAuxiliaryHintCount(SwigCPtr);
638             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
639             return ret;
640         }
641
642         /// <summary>
643         /// Gets the supported auxiliary hint string of the window.
644         /// </summary>
645         /// <param name="index">The index of the supported auxiliary hint lists.</param>
646         /// <returns>The auxiliary hint string of the index.</returns>
647         /// <since_tizen> 3 </since_tizen>
648         public string GetSupportedAuxiliaryHint(uint index)
649         {
650             string ret = Interop.Window.GetSupportedAuxiliaryHint(SwigCPtr, index);
651             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
652             return ret;
653         }
654
655         /// <summary>
656         /// Creates an auxiliary hint of the window.
657         /// </summary>
658         /// <param name="hint">The auxiliary hint string.</param>
659         /// <param name="value">The value string.</param>
660         /// <returns>The ID of created auxiliary hint, or 0 on failure.</returns>
661         /// <since_tizen> 3 </since_tizen>
662         public uint AddAuxiliaryHint(string hint, string value)
663         {
664             uint ret = Interop.Window.AddAuxiliaryHint(SwigCPtr, hint, value);
665             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
666             return ret;
667         }
668
669         /// <summary>
670         /// Removes an auxiliary hint of the window.
671         /// </summary>
672         /// <param name="id">The ID of the auxiliary hint.</param>
673         /// <returns>True if no error occurred, false otherwise.</returns>
674         /// <since_tizen> 3 </since_tizen>
675         public bool RemoveAuxiliaryHint(uint id)
676         {
677             bool ret = Interop.Window.RemoveAuxiliaryHint(SwigCPtr, id);
678             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
679             return ret;
680         }
681
682         /// <summary>
683         /// Changes a value of the auxiliary hint.
684         /// </summary>
685         /// <param name="id">The auxiliary hint ID.</param>
686         /// <param name="value">The value string to be set.</param>
687         /// <returns>True if no error occurred, false otherwise.</returns>
688         /// <since_tizen> 3 </since_tizen>
689         public bool SetAuxiliaryHintValue(uint id, string value)
690         {
691             bool ret = Interop.Window.SetAuxiliaryHintValue(SwigCPtr, id, value);
692             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
693             return ret;
694         }
695
696         /// <summary>
697         /// Gets a value of the auxiliary hint.
698         /// </summary>
699         /// <param name="id">The auxiliary hint ID.</param>
700         /// <returns>The string value of the auxiliary hint ID, or an empty string if none exists.</returns>
701         /// <since_tizen> 3 </since_tizen>
702         public string GetAuxiliaryHintValue(uint id)
703         {
704             string ret = Interop.Window.GetAuxiliaryHintValue(SwigCPtr, id);
705             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
706             return ret;
707         }
708
709         /// <summary>
710         /// Gets an ID of the auxiliary hint string.
711         /// </summary>
712         /// <param name="hint">The auxiliary hint string.</param>
713         /// <returns>The ID of auxiliary hint string, or 0 on failure.</returns>
714         /// <since_tizen> 3 </since_tizen>
715         public uint GetAuxiliaryHintId(string hint)
716         {
717             uint ret = Interop.Window.GetAuxiliaryHintId(SwigCPtr, hint);
718             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
719             return ret;
720         }
721
722         /// <summary>
723         /// Sets a region to accept input events.
724         /// </summary>
725         /// <param name="inputRegion">The region to accept input events.</param>
726         /// <since_tizen> 3 </since_tizen>
727         public void SetInputRegion(Rectangle inputRegion)
728         {
729             Interop.Window.SetInputRegion(SwigCPtr, Rectangle.getCPtr(inputRegion));
730             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
731         }
732
733         /// <summary>
734         /// Sets a priority level for the specified notification window.
735         /// </summary>
736         /// <param name="level">The notification window level.</param>
737         /// <returns>True if no error occurred, false otherwise.</returns>
738         /// <since_tizen> 3 </since_tizen>
739         public bool SetNotificationLevel(NotificationLevel level)
740         {
741             var ret = (OperationResult)Interop.Window.SetNotificationLevel(SwigCPtr, (int)level);
742             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
743             return ret == OperationResult.Succeed;
744         }
745
746         /// <summary>
747         /// Gets a priority level for the specified notification window.
748         /// </summary>
749         /// <returns>The notification window level.</returns>
750         /// <since_tizen> 3 </since_tizen>
751         public NotificationLevel GetNotificationLevel()
752         {
753             NotificationLevel ret = (NotificationLevel)Interop.Window.GetNotificationLevel(SwigCPtr);
754             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
755             return ret;
756         }
757
758         /// <summary>
759         /// Sets a transparent window's visual state to opaque. <br />
760         /// If a visual state of a transparent window is opaque, <br />
761         /// then the window manager could handle it as an opaque window when calculating visibility.
762         /// </summary>
763         /// <param name="opaque">Whether the window's visual state is opaque.</param>
764         /// <remarks>This will have no effect on an opaque window. <br />
765         /// It doesn't change transparent window to opaque window but lets the window manager know the visual state of the window.
766         /// </remarks>
767         /// <since_tizen> 3 </since_tizen>
768         public void SetOpaqueState(bool opaque)
769         {
770             Interop.Window.SetOpaqueState(SwigCPtr, opaque);
771             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
772         }
773
774         /// <summary>
775         /// Returns whether a transparent window's visual state is opaque or not.
776         /// </summary>
777         /// <returns>True if the window's visual state is opaque, false otherwise.</returns>
778         /// <remarks> The return value has no meaning on an opaque window. </remarks>
779         /// <since_tizen> 3 </since_tizen>
780         public bool IsOpaqueState()
781         {
782             bool ret = Interop.Window.IsOpaqueState(SwigCPtr);
783             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
784             return ret;
785         }
786
787         /// <summary>
788         /// Sets a window's screen off mode.
789         /// </summary>
790         /// <param name="screenOffMode">The screen mode.</param>
791         /// <returns>True if no error occurred, false otherwise.</returns>
792         /// <since_tizen> 4 </since_tizen>
793         public bool SetScreenOffMode(ScreenOffMode screenOffMode)
794         {
795             var ret = (OperationResult)Interop.Window.SetScreenOffMode(SwigCPtr, (int)screenOffMode);
796             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
797             return ret == OperationResult.Succeed;
798         }
799
800         /// <summary>
801         /// Gets the screen mode of the window.
802         /// </summary>
803         /// <returns>The screen off mode.</returns>
804         /// <since_tizen> 4 </since_tizen>
805         public ScreenOffMode GetScreenOffMode()
806         {
807             ScreenOffMode ret = (ScreenOffMode)Interop.Window.GetScreenOffMode(SwigCPtr);
808             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
809             return ret;
810         }
811
812         /// <summary>
813         /// Sets preferred brightness of the window.
814         /// </summary>
815         /// <param name="brightness">The preferred brightness (0 to 100).</param>
816         /// <returns>True if no error occurred, false otherwise.</returns>
817         /// <since_tizen> 3 </since_tizen>
818         public bool SetBrightness(int brightness)
819         {
820             var ret = (OperationResult)Interop.Window.SetBrightness(SwigCPtr, brightness);
821             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
822             return ret == OperationResult.Succeed;
823         }
824
825         /// <summary>
826         /// Gets the preferred brightness of the window.
827         /// </summary>
828         /// <returns>The preferred brightness.</returns>
829         /// <since_tizen> 3 </since_tizen>
830         public int GetBrightness()
831         {
832             int ret = Interop.Window.GetBrightness(SwigCPtr);
833             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
834             return ret;
835         }
836
837         /// <summary>
838         /// Sets the window name and the class string.
839         /// </summary>
840         /// <param name="name">The name of the window.</param>
841         /// <param name="klass">The class of the window.</param>
842         /// <since_tizen> 4 </since_tizen>
843         public void SetClass(string name, string klass)
844         {
845             Interop.Window.SetClass(SwigCPtr, name, klass);
846             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
847         }
848
849         /// <summary>
850         /// Raises the window to the top of the window stack.
851         /// </summary>
852         /// <since_tizen> 3 </since_tizen>
853         public void Raise()
854         {
855             Interop.Window.Raise(SwigCPtr);
856             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
857         }
858
859         /// <summary>
860         /// Lowers the window to the bottom of the window stack.
861         /// </summary>
862         /// <since_tizen> 3 </since_tizen>
863         public void Lower()
864         {
865             Interop.Window.Lower(SwigCPtr);
866             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
867         }
868
869         /// <summary>
870         /// Activates the window to the top of the window stack even it is iconified.
871         /// </summary>
872         /// <since_tizen> 3 </since_tizen>
873         public void Activate()
874         {
875             Interop.Window.Activate(SwigCPtr);
876             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
877         }
878
879         /// <summary>
880         /// Gets the default ( root ) layer.
881         /// </summary>
882         /// <returns>The root layer.</returns>
883         /// <since_tizen> 3 </since_tizen>
884         public Layer GetDefaultLayer()
885         {
886             return this.GetRootLayer();
887         }
888
889         /// <summary>
890         /// Add a child view to window.
891         /// </summary>
892         /// <param name="view">the child should be added to the window.</param>
893         /// <since_tizen> 3 </since_tizen>
894         public void Add(View view)
895         {
896             Interop.Actor.Add(Layer.getCPtr(GetRootLayer()), View.getCPtr(view));
897             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
898             this.GetRootLayer().AddViewToLayerList(view); // Maintain the children list in the Layer
899             if (null != view)
900             {
901                 view.InternalParent = this.GetRootLayer();
902             }
903         }
904
905         /// <summary>
906         /// Remove a child view from window.
907         /// </summary>
908         /// <param name="view">the child to be removed.</param>
909         /// <since_tizen> 3 </since_tizen>
910         public void Remove(View view)
911         {
912             Interop.Actor.Remove(Layer.getCPtr(GetRootLayer()), View.getCPtr(view));
913             this.GetRootLayer().RemoveViewFromLayerList(view); // Maintain the children list in the Layer
914             if (null != view)
915             {
916                 view.InternalParent = null;
917             }
918         }
919
920         /// <summary>
921         /// Retrieves the layer at a specified depth.
922         /// </summary>
923         /// <param name="depth">The layer's depth index.</param>
924         /// <returns>The layer found at the given depth.</returns>
925         /// <since_tizen> 3 </since_tizen>
926         public Layer GetLayer(uint depth)
927         {
928             if (depth < LayersChildren?.Count)
929             {
930                 Layer ret = LayersChildren?[Convert.ToInt32(depth)];
931                 return ret;
932             }
933             else
934             {
935                 return null;
936             }
937         }
938
939         /// <summary>
940         /// Destroy the window immediately.
941         /// </summary>
942         [EditorBrowsable(EditorBrowsableState.Never)]
943         public void Destroy()
944         {
945             this.Dispose();
946         }
947
948         /// <summary>
949         /// Keep rendering for at least the given amount of time.
950         /// </summary>
951         /// <param name="durationSeconds">Time to keep rendering, 0 means render at least one more frame.</param>
952         /// <since_tizen> 3 </since_tizen>
953         public void KeepRendering(float durationSeconds)
954         {
955             Interop.Stage.KeepRendering(stageCPtr, durationSeconds);
956             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
957         }
958
959         /// <summary>
960         /// Grabs the key specified by a key for a window only when a window is the topmost window.<br />
961         /// This function can be used for following example scenarios: <br />
962         /// - Mobile - Using volume up or down as zoom up or down in camera apps.<br />
963         /// </summary>
964         /// <param name="DaliKey">The key code to grab.</param>
965         /// <returns>True if the grab succeeds.</returns>
966         /// <since_tizen> 3 </since_tizen>
967         public bool GrabKeyTopmost(int DaliKey)
968         {
969             bool ret = Interop.Window.GrabKeyTopmost(HandleRef.ToIntPtr(this.SwigCPtr), DaliKey);
970             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
971             return ret;
972         }
973
974         /// <summary>
975         /// Ungrabs the key specified by a key for the window.<br />
976         /// Note: If this function is called between key down and up events of a grabbed key, an application doesn't receive the key up event.<br />
977         /// </summary>
978         /// <param name="DaliKey">The key code to ungrab.</param>
979         /// <returns>True if the ungrab succeeds.</returns>
980         /// <since_tizen> 3 </since_tizen>
981         public bool UngrabKeyTopmost(int DaliKey)
982         {
983             bool ret = Interop.Window.UngrabKeyTopmost(HandleRef.ToIntPtr(this.SwigCPtr), DaliKey);
984             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
985             return ret;
986         }
987
988         /// <summary>
989         ///  Grabs the key specified by a key for a window in a GrabMode. <br />
990         ///  Details: This function can be used for following example scenarios: <br />
991         ///  - TV - A user might want to change the volume or channel of the background TV contents while focusing on the foregrund app. <br />
992         ///  - Mobile - When a user presses the Home key, the homescreen appears regardless of the current foreground app. <br />
993         ///  - Mobile - Using the volume up or down as zoom up or down in camera apps. <br />
994         /// </summary>
995         /// <param name="DaliKey">The key code to grab.</param>
996         /// <param name="GrabMode">The grab mode for the key.</param>
997         /// <returns>True if the grab succeeds.</returns>
998         /// <since_tizen> 3 </since_tizen>
999         public bool GrabKey(int DaliKey, KeyGrabMode GrabMode)
1000         {
1001             bool ret = Interop.Window.GrabKey(HandleRef.ToIntPtr(this.SwigCPtr), DaliKey, (int)GrabMode);
1002             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1003             return ret;
1004         }
1005
1006         /// <summary>
1007         /// Ungrabs the key specified by a key for a window.<br />
1008         /// Note: If this function is called between key down and up events of a grabbed key, an application doesn't receive the key up event. <br />
1009         /// </summary>
1010         /// <param name="DaliKey">The key code to ungrab.</param>
1011         /// <returns>True if the ungrab succeeds.</returns>
1012         /// <since_tizen> 3 </since_tizen>
1013         public bool UngrabKey(int DaliKey)
1014         {
1015             bool ret = Interop.Window.UngrabKey(HandleRef.ToIntPtr(this.SwigCPtr), DaliKey);
1016             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1017             return ret;
1018         }
1019
1020         /// <summary>
1021         /// Sets the keyboard repeat information.
1022         /// </summary>
1023         /// <param name="rate">The key repeat rate value in seconds.</param>
1024         /// <param name="delay">The key repeat delay value in seconds.</param>
1025         /// <returns>True if setting the keyboard repeat succeeds.</returns>
1026         /// <since_tizen> 5 </since_tizen>
1027         public bool SetKeyboardRepeatInfo(float rate, float delay)
1028         {
1029             bool ret = Interop.Window.SetKeyboardRepeatInfo(rate, delay);
1030             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1031             return ret;
1032         }
1033
1034         /// <summary>
1035         /// Gets the keyboard repeat information.
1036         /// </summary>
1037         /// <param name="rate">The key repeat rate value in seconds.</param>
1038         /// <param name="delay">The key repeat delay value in seconds.</param>
1039         /// <returns>True if setting the keyboard repeat succeeds.</returns>
1040         /// <since_tizen> 5 </since_tizen>
1041         public bool GetKeyboardRepeatInfo(out float rate, out float delay)
1042         {
1043             bool ret = Interop.Window.GetKeyboardRepeatInfo(out rate, out delay);
1044             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1045             return ret;
1046         }
1047
1048         /// <summary>
1049         /// Adds a layer to the stage.
1050         /// </summary>
1051         /// <param name="layer">Layer to add.</param>
1052         /// <exception cref="ArgumentNullException"> Thrown when layer is null. </exception>
1053         /// <since_tizen> 3 </since_tizen>
1054         public void AddLayer(Layer layer)
1055         {
1056             Add(layer);
1057         }
1058
1059         /// <summary>
1060         /// Removes a layer from the stage.
1061         /// </summary>
1062         /// <param name="layer">Layer to remove.</param>
1063         /// <exception cref="ArgumentNullException"> Thrown when layer is null. </exception>
1064         /// <since_tizen> 3 </since_tizen>
1065         public void RemoveLayer(Layer layer)
1066         {
1067             Remove(layer);
1068         }
1069
1070         /// <summary>
1071         /// Feeds a key event into the window.
1072         /// </summary>
1073         /// <param name="keyEvent">The key event to feed.</param>
1074         /// <since_tizen> 5 </since_tizen>
1075         public void FeedKey(Key keyEvent)
1076         {
1077             Interop.Window.FeedKeyEvent(Key.getCPtr(keyEvent));
1078             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1079         }
1080
1081         /// <summary>
1082         /// Allows at least one more render, even when paused.
1083         /// The window should be shown, not minimised.
1084         /// </summary>
1085         /// <since_tizen> 4 </since_tizen>
1086         public void RenderOnce()
1087         {
1088             Interop.Window.RenderOnce(SwigCPtr);
1089             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1090         }
1091
1092         /// <summary>
1093         /// Sets whether the window is transparent or not.
1094         /// </summary>
1095         /// <param name="transparent">Whether the window is transparent or not.</param>
1096         /// <since_tizen> 5 </since_tizen>
1097         public void SetTransparency(bool transparent)
1098         {
1099             Interop.Window.SetTransparency(SwigCPtr, transparent);
1100             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1101
1102             // Setting transparency of the window should request a relayout of the tree in the case the window changes from fully transparent.
1103         }
1104
1105         /// <summary>
1106         /// Sets parent window of the window.
1107         /// After setting that, these windows do together when raise-up, lower and iconified/deiconified.
1108         /// Initially, the window is located on top of the parent. The window can go below parent by calling Lower().
1109         /// If parent's window stack is changed by calling Raise() or Lower(), child windows are located on top of the parent again.
1110         /// </summary>
1111         /// <param name="parent">The parent window.</param>
1112         /// <since_tizen> 6 </since_tizen>
1113         /// <feature> http://tizen.org/feature/opengles.surfaceless_context </feature>
1114         /// <exception cref="NotSupportedException">The required feature is not supported.</exception>
1115         public void SetParent(Window parent)
1116         {
1117             if (IsSupportedMultiWindow() == false)
1118             {
1119                 NUILog.Error("This device does not support surfaceless_context. So Window cannot be created. ");
1120             }
1121             Interop.Window.SetParent(SwigCPtr, Window.getCPtr(parent));
1122             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1123         }
1124
1125         /// <summary>
1126         /// Unsets parent window of the window.
1127         /// After unsetting, the window is disconnected his parent window.
1128         /// </summary>
1129         /// <since_tizen> 6 </since_tizen>
1130         /// <feature> http://tizen.org/feature/opengles.surfaceless_context </feature>
1131         /// <exception cref="NotSupportedException">The required feature is not supported.</exception>
1132         public void Unparent()
1133         {
1134             if (IsSupportedMultiWindow() == false)
1135             {
1136                 NUILog.Error("Fail to create window. because this device does not support opengles.surfaceless_context.");
1137             }
1138             Interop.Window.Unparent(SwigCPtr);
1139             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1140         }
1141
1142         /// <summary>
1143         /// Gets parent window of the window.
1144         /// </summary>
1145         /// <returns>The parent window of the window.</returns>
1146         /// <since_tizen> 6 </since_tizen>
1147         /// <feature> http://tizen.org/feature/opengles.surfaceless_context </feature>
1148         /// <exception cref="NotSupportedException">The required feature is not supported.</exception>
1149         [System.Diagnostics.CodeAnalysis.SuppressMessage("Design", "CA1721: Property names should not match get methods")]
1150         public Window GetParent()
1151         {
1152             if (IsSupportedMultiWindow() == false)
1153             {
1154                 NUILog.Error("This device does not support surfaceless_context. So Window cannot be created. ");
1155             }
1156             Window ret = Registry.GetManagedBaseHandleFromNativePtr(Interop.Window.GetParent(SwigCPtr)) as Window;
1157             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1158             return ret;
1159         }
1160
1161         /// This will be public opened in tizen_next after ACR done. Before ACR, need to be hidden as inhouse API.
1162         [EditorBrowsable(EditorBrowsableState.Never)]
1163         public void ObjectDump()
1164         {
1165             Layer rootLayer = GetRootLayer();
1166             foreach (View view in rootLayer.Children)
1167             {
1168                 view.ObjectDump();
1169             }
1170         }
1171
1172         internal static global::System.Runtime.InteropServices.HandleRef getCPtr(Window obj)
1173         {
1174             return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.SwigCPtr;
1175         }
1176
1177         internal static bool IsInstalled()
1178         {
1179             bool ret = Interop.Stage.IsInstalled();
1180             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1181             return ret;
1182         }
1183
1184         /// <summary>
1185         /// Adds an orientation to the list of available orientations.
1186         /// </summary>
1187         /// <param name="orientation">The available orientation to add</param>
1188         /// <since_tizen> 6 </since_tizen>
1189         public void AddAvailableOrientation(Window.WindowOrientation orientation)
1190         {
1191             Interop.Window.AddAvailableOrientation(SwigCPtr, (int)orientation);
1192             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1193         }
1194
1195         /// <summary>
1196         /// Removes an orientation from the list of available orientations.
1197         /// </summary>
1198         /// <param name="orientation">The available orientation to remove.</param>
1199         /// <since_tizen> 6 </since_tizen>
1200         public void RemoveAvailableOrientation(Window.WindowOrientation orientation)
1201         {
1202             Interop.Window.RemoveAvailableOrientation(SwigCPtr, (int)orientation);
1203             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1204         }
1205
1206         /// <summary>
1207         /// Sets a preferred orientation.
1208         /// </summary>
1209         /// <param name="orientation">The preferred orientation.</param>
1210         /// <since_tizen> 6 </since_tizen>
1211         public void SetPreferredOrientation(Window.WindowOrientation orientation)
1212         {
1213             Interop.Window.SetPreferredOrientation(SwigCPtr, (int)orientation);
1214             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1215         }
1216
1217         /// <summary>
1218         /// Gets the preferred orientation.
1219         /// </summary>
1220         /// <since_tizen> 6 </since_tizen>
1221         /// <returns>The preferred orientation if previously set, or none.</returns>
1222         public Window.WindowOrientation GetPreferredOrientation()
1223         {
1224             Window.WindowOrientation ret = (Window.WindowOrientation)Interop.Window.GetPreferredOrientation(SwigCPtr);
1225             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1226             return ret;
1227         }
1228
1229         /// <summary>
1230         /// Gets current orientation of the window.
1231         /// </summary>
1232         /// <since_tizen> 6 </since_tizen>
1233         /// <returns>The current window orientation if previously set, or none.</returns>
1234         [EditorBrowsable(EditorBrowsableState.Never)]
1235         public Window.WindowOrientation GetCurrentOrientation()
1236         {
1237             Window.WindowOrientation ret = (Window.WindowOrientation)Interop.Window.GetCurrentOrientation(SwigCPtr);
1238             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1239             return ret;
1240         }
1241
1242         /// <summary>
1243         /// Sets available orientations of the window.
1244         /// This API is for setting several orientations one time.
1245         /// </summary>
1246         /// <param name="orientations">The list of orientations.</param>
1247         /// <since_tizen> 6 </since_tizen>
1248         [EditorBrowsable(EditorBrowsableState.Never)]
1249         public void SetAvailableOrientations(List<Window.WindowOrientation> orientations)
1250         {
1251             if (null == orientations)
1252             {
1253                 throw new ArgumentNullException(nameof(orientations));
1254             }
1255
1256             PropertyArray orientationArray = new PropertyArray();
1257             for (int i = 0; i < orientations.Count; i++)
1258             {
1259                 PropertyValue value = new PropertyValue((int)orientations[i]);
1260                 orientationArray.PushBack(value);
1261                 value.Dispose();
1262             }
1263
1264             Interop.Window.SetAvailableOrientations(SwigCPtr, PropertyArray.getCPtr(orientationArray), orientations.Count);
1265             orientationArray.Dispose();
1266             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1267         }
1268
1269         /// <summary>
1270         /// Sets window position and size for specific orientation.
1271         /// This api reserves the position and size per orientation to display server.
1272         /// When the device is rotated, the window is moved/resized with the reserved position/size by display server.
1273         /// Currently, it only works when the window's type is WindowType::Ime.
1274         /// It means this function is only for IME window of internal keyboard application.
1275         /// It is only for internal keyboard application.
1276         /// This should be hidden.
1277         /// </summary>
1278         /// <param name="positionSize">The reserved position and size for the orientation.</param>
1279         /// <param name="orientation">The orientation.</param>
1280         [EditorBrowsable(EditorBrowsableState.Never)]
1281         public void SetPositionSizeWithOrientation(Rectangle positionSize, Window.WindowOrientation orientation)
1282         {
1283             Interop.Window.SetPositionSizeWithOrientation(SwigCPtr, Rectangle.getCPtr(positionSize), (int)orientation);
1284             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1285         }
1286
1287         /// <summary>
1288         /// Get native window ID
1289         /// </summary>
1290         /// <returns>native window ID</returns>
1291         [EditorBrowsable(EditorBrowsableState.Never)]
1292         public int GetNativeId()
1293         {
1294             int ret = Interop.Window.GetNativeId(SwigCPtr);
1295             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1296             return ret;
1297         }
1298
1299         internal Any GetNativeHandle()
1300         {
1301             Any ret = new Any(Interop.WindowInternal.WindowGetNativeHandle(SwigCPtr), true);
1302             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1303             return ret;
1304         }
1305
1306         internal void Add(Layer layer)
1307         {
1308             if (null == layer)
1309             {
1310                 throw new ArgumentNullException(nameof(layer));
1311             }
1312             Interop.Window.Add(SwigCPtr, Layer.getCPtr(layer));
1313             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1314
1315             LayersChildren?.Add(layer);
1316             layer.SetWindow(this);
1317         }
1318
1319         internal void Remove(Layer layer)
1320         {
1321             if (null == layer)
1322             {
1323                 throw new ArgumentNullException(nameof(layer));
1324             }
1325             Interop.Window.Remove(SwigCPtr, Layer.getCPtr(layer));
1326             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1327
1328             LayersChildren?.Remove(layer);
1329             layer.SetWindow(null);
1330         }
1331
1332         internal Vector2 GetSize()
1333         {
1334             var val = new Uint16Pair(Interop.Window.GetSize(SwigCPtr), true);
1335             Vector2 ret = new Vector2(val.GetWidth(), val.GetHeight());
1336             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1337             return ret;
1338         }
1339
1340         /// This will be public opened in next tizen after ACR done. Before ACR, need to be hidden as inhouse API.
1341         [EditorBrowsable(EditorBrowsableState.Never)]
1342         public RenderTaskList GetRenderTaskList()
1343         {
1344             RenderTaskList ret = new RenderTaskList(Interop.Stage.GetRenderTaskList(stageCPtr), true);
1345             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1346             return ret;
1347         }
1348
1349         /// <summary>
1350         /// Queries the number of on-window layers.
1351         /// </summary>
1352         /// <returns>The number of layers.</returns>
1353         /// <remarks>Note that a default layer is always provided (count >= 1).</remarks>
1354         internal uint GetLayerCount()
1355         {
1356             if (LayersChildren == null || LayersChildren.Count < 0)
1357                 return 0;
1358
1359             return (uint)LayersChildren.Count;
1360         }
1361
1362         internal Layer GetRootLayer()
1363         {
1364             // Window.IsInstalled() is actually true only when called from event thread and
1365             // Core has been initialized, not when Stage is ready.
1366             if (rootLayer == null && Window.IsInstalled())
1367             {
1368                 rootLayer = new Layer(Interop.Window.GetRootLayer(SwigCPtr), true);
1369                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1370                 LayersChildren?.Add(rootLayer);
1371                 rootLayer.SetWindow(this);
1372             }
1373             return rootLayer;
1374         }
1375
1376         internal void SetBackgroundColor(Vector4 color)
1377         {
1378             Interop.Window.SetBackgroundColor(SwigCPtr, Vector4.getCPtr(color));
1379             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1380         }
1381
1382         internal Vector4 GetBackgroundColor()
1383         {
1384             Vector4 ret = new Vector4(Interop.Window.GetBackgroundColor(SwigCPtr), true);
1385             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1386             return ret;
1387         }
1388
1389         internal Vector2 GetDpi()
1390         {
1391             Vector2 ret = new Vector2(Interop.Stage.GetDpi(stageCPtr), true);
1392             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1393             return ret;
1394         }
1395
1396         internal ObjectRegistry GetObjectRegistry()
1397         {
1398             ObjectRegistry ret = new ObjectRegistry(Interop.Stage.GetObjectRegistry(stageCPtr), true);
1399             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1400             return ret;
1401         }
1402
1403         internal void SetRenderingBehavior(RenderingBehaviorType renderingBehavior)
1404         {
1405             Interop.Stage.SetRenderingBehavior(stageCPtr, (int)renderingBehavior);
1406             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1407         }
1408
1409         internal RenderingBehaviorType GetRenderingBehavior()
1410         {
1411             RenderingBehaviorType ret = (RenderingBehaviorType)Interop.Stage.GetRenderingBehavior(stageCPtr);
1412             if (NDalicPINVOKE.SWIGPendingException.Pending)
1413                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1414             return ret;
1415         }
1416
1417         internal void SetWindowSize(Size2D size)
1418         {
1419             if (null == size)
1420             {
1421                 throw new ArgumentNullException(nameof(size));
1422             }
1423             var val = new Uint16Pair((uint)size.Width, (uint)size.Height);
1424             Interop.Window.SetSize(SwigCPtr, Uint16Pair.getCPtr(val));
1425             val.Dispose();
1426             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1427             // Resetting Window size should request a relayout of the tree.
1428         }
1429
1430         internal Size2D GetWindowSize()
1431         {
1432             var val = new Uint16Pair(Interop.Window.GetSize(SwigCPtr), true);
1433             Size2D ret = new Size2D(val.GetWidth(), val.GetHeight());
1434             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1435             return ret;
1436         }
1437
1438         internal void SetPosition(Position2D position)
1439         {
1440             if (null == position)
1441             {
1442                 throw new ArgumentNullException(nameof(position));
1443             }
1444             var val = new Uint16Pair((uint)position.X, (uint)position.Y);
1445             Interop.Window.SetPosition(SwigCPtr, Uint16Pair.getCPtr(val));
1446             val.Dispose();
1447             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1448             // Setting Position of the window should request a relayout of the tree.
1449         }
1450
1451         internal Position2D GetPosition()
1452         {
1453             var val = new Uint16Pair(Interop.Window.GetPosition(SwigCPtr), true);
1454             Position2D ret = new Position2D(val.GetX(), val.GetY());
1455             val.Dispose();
1456             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1457             return ret;
1458         }
1459
1460         internal void SetPositionSize(Rectangle positionSize)
1461         {
1462             Interop.Window.SetPositionSize(SwigCPtr, Rectangle.getCPtr(positionSize));
1463
1464             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1465
1466             // Setting Position of the window should request a relayout of the tree.
1467         }
1468
1469         /// <summary>
1470         /// Enables the floating mode of window.
1471         /// The floating mode is to support window is moved or resized by display server.
1472         /// For example, if the video-player window sets the floating mode,
1473         /// then display server changes its geometry and handles it like a popup.
1474         /// The way of handling floating mode window is decided by display server.
1475         /// A special display server(as a Tizen display server) supports this mode.
1476         /// </summary>
1477         /// <param name="enable">Enable floating mode or not.</param>
1478         [EditorBrowsable(EditorBrowsableState.Never)]
1479         public void EnableFloatingMode(bool enable)
1480         {
1481             Interop.Window.EnableFloatingMode(SwigCPtr, enable);
1482             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1483         }
1484
1485         /// <summary>
1486         /// Requests to display server for the window is moved by display server.
1487         /// It can be work with setting window floating mode.
1488         /// </summary>
1489         [EditorBrowsable(EditorBrowsableState.Never)]
1490         public void RequestMoveToServer()
1491         {
1492             Interop.Window.RequestMoveToServer(SwigCPtr);
1493             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1494         }
1495
1496         /// <summary>
1497         ///  Requests to display server for the window is resized by display server.
1498         /// It can be work with setting window floating mode.
1499         /// </summary>
1500         /// <param name="direction">It is indicated the window's side or edge for starting point.</param>
1501         [EditorBrowsable(EditorBrowsableState.Never)]
1502         public void RequestResizeToServer(ResizeDirection direction)
1503         {
1504             Interop.Window.RequestResizeToServer(SwigCPtr, (int)direction);
1505             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1506         }
1507
1508         /// <summary>
1509         /// Adds input region.
1510         /// </summary>
1511         /// <param name="inputRegion">The added region to accept input events.</param>
1512         [EditorBrowsable(EditorBrowsableState.Never)]
1513         public void AddInputRegion(Rectangle inputRegion)
1514         {
1515             Interop.Window.AddInputRegion(SwigCPtr, Rectangle.getCPtr(inputRegion));
1516             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1517         }
1518
1519         /// <summary>
1520         /// Subtracts input region.
1521         /// </summary>
1522         /// <param name="inputRegion">The subtracted region to except input events.</param>
1523         [EditorBrowsable(EditorBrowsableState.Never)]
1524         public void SubtractInputRegion(Rectangle inputRegion)
1525         {
1526             Interop.Window.SubtractInputRegion(SwigCPtr, Rectangle.getCPtr(inputRegion));
1527             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1528         }
1529
1530         /// <summary>
1531         /// Add FrameUpdateCallback
1532         /// </summary>
1533         [EditorBrowsable(EditorBrowsableState.Never)]
1534         public void AddFrameUpdateCallback(FrameUpdateCallbackInterface frameUpdateCallback)
1535         {
1536             frameUpdateCallback?.AddFrameUpdateCallback(stageCPtr, Layer.getCPtr(GetRootLayer()));
1537         }
1538
1539         /// <summary>
1540         /// Remove FrameUpdateCallback
1541         /// </summary>
1542         [EditorBrowsable(EditorBrowsableState.Never)]
1543         public void RemoveFrameUpdateCallback(FrameUpdateCallbackInterface frameUpdateCallback)
1544         {
1545             frameUpdateCallback?.RemoveFrameUpdateCallback(stageCPtr);
1546         }
1547
1548         /// <summary>
1549         /// Dispose for Window
1550         /// </summary>
1551         [EditorBrowsable(EditorBrowsableState.Never)]
1552         protected override void Dispose(DisposeTypes type)
1553         {
1554             if (disposed)
1555             {
1556                 return;
1557             }
1558
1559             if (type == DisposeTypes.Explicit)
1560             {
1561                 //Called by User
1562                 //Release your own managed resources here.
1563                 //You should release all of your own disposable objects here.
1564
1565                 if (rootLayer != null)
1566                 {
1567                     rootLayer.Dispose();
1568                 }
1569
1570                 localController?.Dispose();
1571
1572                 foreach (var layer in childLayers)
1573                 {
1574                     if (layer != null)
1575                     {
1576                         layer.Dispose();
1577                     }
1578                 }
1579
1580                 childLayers.Clear();
1581             }
1582
1583             this.DisconnectNativeSignals();
1584
1585             base.Dispose(type);
1586         }
1587
1588         /// This will not be public opened.
1589         [EditorBrowsable(EditorBrowsableState.Never)]
1590         protected override void ReleaseSwigCPtr(System.Runtime.InteropServices.HandleRef swigCPtr)
1591         {
1592             Interop.Window.DeleteWindow(swigCPtr);
1593         }
1594
1595         private static Dictionary<int, internalHookCallbackType> frameCallbackList = new Dictionary<int, internalHookCallbackType>();
1596
1597         private static readonly object locker = new object();
1598
1599         private static int key = 0;
1600
1601         private static FrameCallbackType internalHookFrameCallback = OnInternalHookFrameCallback;
1602
1603         private struct internalHookCallbackType
1604         {
1605             public FrameCallbackType userCallback;
1606             public int frameId;
1607         }
1608
1609         private static void OnInternalHookFrameCallback(int id)
1610         {
1611             lock (locker)
1612             {
1613                 if (frameCallbackList.ContainsKey(id))
1614                 {
1615                     if (frameCallbackList[id].userCallback != null)
1616                     {
1617                         frameCallbackList[id].userCallback.Invoke(frameCallbackList[id].frameId);
1618                         frameCallbackList.Remove(id);
1619                     }
1620                     else
1621                     {
1622                         NUILog.Error($"found userCallback is NULL");
1623                         frameCallbackList.Remove(id);
1624                     }
1625                 }
1626             }
1627         }
1628
1629         private int AddInterHookCallback(FrameCallbackType callback, int frameId)
1630         {
1631             if (null == callback)
1632             {
1633                 throw new ArgumentNullException(nameof(callback), "FrameCallbackType should not be null");
1634             }
1635             var assignedKey = 0;
1636             lock (locker)
1637             {
1638                 key++;
1639                 assignedKey = key;
1640                 frameCallbackList.Add(assignedKey, new internalHookCallbackType()
1641                 {
1642                     userCallback = callback,
1643                     frameId = frameId,
1644                 });
1645             }
1646             return assignedKey;
1647         }
1648
1649         /// <summary>
1650         /// Type of callback which is called when the frame rendering is done by graphics driver or when the frame is displayed on display.
1651         /// </summary>
1652         /// <param name="frameId">The Id to specify the frame. It will be passed when the callback is called.</param>
1653         [EditorBrowsable(EditorBrowsableState.Never)]
1654         public delegate void FrameCallbackType(int frameId);
1655
1656         /// <summary>
1657         /// Adds a callback that is called when the frame rendering is done by the graphics driver.
1658         /// A callback of the following type may be used:
1659         /// <code>
1660         /// void MyFunction( int frameId )
1661         /// </code>
1662         /// This callback will be deleted once it is called.
1663         /// <remarks>
1664         /// Ownership of the callback is passed onto this class
1665         /// </remarks>
1666         /// </summary>
1667         /// <param name="callback">The function to call</param>
1668         /// <param name="frameId">The Id to specify the frame. It will be passed when the callback is called.</param>
1669         /// <exception cref="ArgumentNullException">This exception can occur by the callback is null.</exception>
1670         [EditorBrowsable(EditorBrowsableState.Never)]
1671         public void AddFrameRenderedCallback(FrameCallbackType callback, int frameId)
1672         {
1673             var assignedKey = AddInterHookCallback(callback, frameId);
1674             Interop.WindowInternal.AddFrameRenderedCallback(SwigCPtr, new HandleRef(this, Marshal.GetFunctionPointerForDelegate<Delegate>(internalHookFrameCallback)), assignedKey);
1675
1676             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1677         }
1678
1679         /// <summary>
1680         /// Adds a callback that is called when the frame is displayed on the display.
1681         /// A callback of the following type may be used:
1682         /// <code>
1683         /// void MyFunction( int frameId )
1684         /// </code>
1685         /// This callback will be deleted once it is called.
1686         /// <remarks>
1687         /// Ownership of the callback is passed onto this class
1688         /// </remarks>
1689         /// </summary>
1690         /// <param name="callback">The function to call</param>
1691         /// <param name="frameId">The Id to specify the frame. It will be passed when the callback is called.</param>
1692         /// <exception cref="ArgumentNullException">This exception can occur by the callback is null.</exception>
1693         [EditorBrowsable(EditorBrowsableState.Never)]
1694         public void AddFramePresentedCallback(FrameCallbackType callback, int frameId)
1695         {
1696             var assignedKey = AddInterHookCallback(callback, frameId);
1697             Interop.WindowInternal.AddFramePresentedCallback(SwigCPtr, new HandleRef(this, Marshal.GetFunctionPointerForDelegate<Delegate>(internalHookFrameCallback)), assignedKey);
1698
1699             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1700         }
1701
1702         /// <summary>
1703         /// Search through this Window for a Layer with the given unique ID.
1704         /// </summary>
1705         /// <param name="id">The ID of the Layer to find.</param>
1706         /// <remarks>Hidden-API</remarks>
1707         /// <returns>A handle to the Layer if found, or an empty handle if not.</returns>
1708         [EditorBrowsable(EditorBrowsableState.Never)]
1709         public Layer FindLayerByID(uint id)
1710         {
1711             Layer defaultLayer = this.GetDefaultLayer();
1712             IntPtr cPtr = Interop.Actor.FindChildById(defaultLayer.SwigCPtr, id);
1713             Layer ret = this.GetInstanceSafely<Layer>(cPtr);
1714
1715             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1716             return ret;
1717         }
1718
1719     }
1720 }