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