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