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