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