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