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