57546f75eede4b2c7f54bc89c8dd96fa9141f741
[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(SwigCPtr, Key.getCPtr(keyEvent));
1091             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1092         }
1093
1094         /// <summary>
1095         /// Feeds a touch point into the window.
1096         /// </summary>
1097         /// <param name="touchPoint">The touch point to feed.</param>
1098         /// <param name="timeStamp">The timeStamp.</param>
1099         internal void FeedTouch(TouchPoint touchPoint, int timeStamp)
1100         {
1101             Interop.Window.FeedTouchPoint(SwigCPtr, TouchPoint.getCPtr(touchPoint), timeStamp);
1102             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1103         }
1104
1105         /// <summary>
1106         /// Feeds a wheel event into the window.
1107         /// </summary>
1108         /// <param name="wheelEvent">The wheel event to feed.</param>
1109         internal void FeedWheel(Wheel wheelEvent)
1110         {
1111             Interop.Window.FeedWheelEvent(SwigCPtr, Wheel.getCPtr(wheelEvent));
1112             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1113         }
1114
1115         /// <summary>
1116         /// Allows at least one more render, even when paused.
1117         /// The window should be shown, not minimised.
1118         /// </summary>
1119         /// <since_tizen> 4 </since_tizen>
1120         public void RenderOnce()
1121         {
1122             Interop.Window.RenderOnce(SwigCPtr);
1123             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1124         }
1125
1126         /// <summary>
1127         /// Sets whether the window is transparent or not.
1128         /// </summary>
1129         /// <param name="transparent">Whether the window is transparent or not.</param>
1130         /// <since_tizen> 5 </since_tizen>
1131         public void SetTransparency(bool transparent)
1132         {
1133             Interop.Window.SetTransparency(SwigCPtr, transparent);
1134             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1135
1136             // Setting transparency of the window should request a relayout of the tree in the case the window changes from fully transparent.
1137         }
1138
1139         /// <summary>
1140         /// Sets parent window of the window.
1141         /// After setting that, these windows do together when raise-up, lower and iconified/deiconified.
1142         /// Initially, the window is located on top of the parent. The window can go below parent by calling Lower().
1143         /// If parent's window stack is changed by calling Raise() or Lower(), child windows are located on top of the parent again.
1144         /// </summary>
1145         /// <param name="parent">The parent window.</param>
1146         /// <since_tizen> 6 </since_tizen>
1147         /// <feature> http://tizen.org/feature/opengles.surfaceless_context </feature>
1148         /// <exception cref="NotSupportedException">The required feature is not supported.</exception>
1149         public void SetParent(Window parent)
1150         {
1151             if (IsSupportedMultiWindow() == false)
1152             {
1153                 NUILog.Error("This device does not support surfaceless_context. So Window cannot be created. ");
1154             }
1155             Interop.Window.SetParent(SwigCPtr, Window.getCPtr(parent));
1156             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1157         }
1158
1159         /// <summary>
1160         /// Sets parent window of the window.
1161         /// After setting that, these windows do together when raise-up, lower and iconified/deiconified.
1162         /// This function has the additional flag whether the child is located above or below of the parent.
1163         /// </summary>
1164         /// <param name="parent">The parent window.</param>
1165         /// <param name="belowParent">The flag is whether the child is located above or below of the parent.</param>
1166         /// <feature> http://tizen.org/feature/opengles.surfaceless_context </feature>
1167         /// <exception cref="NotSupportedException">The required feature is not supported.</exception>
1168         [EditorBrowsable(EditorBrowsableState.Never)]
1169         public void SetParent(Window parent, bool belowParent)
1170         {
1171             if (IsSupportedMultiWindow() == false)
1172             {
1173                 NUILog.Error("This device does not support surfaceless_context. So Window cannot be created. ");
1174             }
1175             Interop.Window.SetParentWithStack(SwigCPtr, Window.getCPtr(parent), belowParent);
1176             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1177         }
1178
1179         /// <summary>
1180         /// Unsets parent window of the window.
1181         /// After unsetting, the window is disconnected his parent window.
1182         /// </summary>
1183         /// <since_tizen> 6 </since_tizen>
1184         /// <feature> http://tizen.org/feature/opengles.surfaceless_context </feature>
1185         /// <exception cref="NotSupportedException">The required feature is not supported.</exception>
1186         public void Unparent()
1187         {
1188             if (IsSupportedMultiWindow() == false)
1189             {
1190                 NUILog.Error("Fail to create window. because this device does not support opengles.surfaceless_context.");
1191             }
1192             Interop.Window.Unparent(SwigCPtr);
1193             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1194         }
1195
1196         /// <summary>
1197         /// Gets parent window of the window.
1198         /// </summary>
1199         /// <returns>The parent window of the window.</returns>
1200         /// <since_tizen> 6 </since_tizen>
1201         /// <feature> http://tizen.org/feature/opengles.surfaceless_context </feature>
1202         /// <exception cref="NotSupportedException">The required feature is not supported.</exception>
1203         [System.Diagnostics.CodeAnalysis.SuppressMessage("Design", "CA1721: Property names should not match get methods")]
1204         public Window GetParent()
1205         {
1206             if (IsSupportedMultiWindow() == false)
1207             {
1208                 NUILog.Error("This device does not support surfaceless_context. So Window cannot be created. ");
1209             }
1210             Window ret = Registry.GetManagedBaseHandleFromNativePtr(Interop.Window.GetParent(SwigCPtr)) as Window;
1211             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1212             return ret;
1213         }
1214
1215         /// This will be public opened in tizen_next after ACR done. Before ACR, need to be hidden as inhouse API.
1216         [EditorBrowsable(EditorBrowsableState.Never)]
1217         public void ObjectDump()
1218         {
1219             Layer rootLayer = GetRootLayer();
1220             foreach (View view in rootLayer.Children)
1221             {
1222                 view.ObjectDump();
1223             }
1224         }
1225
1226         internal static bool IsInstalled()
1227         {
1228             bool ret = Interop.Stage.IsInstalled();
1229             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1230             return ret;
1231         }
1232
1233         /// <summary>
1234         /// Adds an orientation to the list of available orientations.
1235         /// </summary>
1236         /// <param name="orientation">The available orientation to add</param>
1237         /// <since_tizen> 6 </since_tizen>
1238         public void AddAvailableOrientation(Window.WindowOrientation orientation)
1239         {
1240             Interop.Window.AddAvailableOrientation(SwigCPtr, (int)orientation);
1241             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1242         }
1243
1244         /// <summary>
1245         /// Removes an orientation from the list of available orientations.
1246         /// </summary>
1247         /// <param name="orientation">The available orientation to remove.</param>
1248         /// <since_tizen> 6 </since_tizen>
1249         public void RemoveAvailableOrientation(Window.WindowOrientation orientation)
1250         {
1251             Interop.Window.RemoveAvailableOrientation(SwigCPtr, (int)orientation);
1252             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1253         }
1254
1255         /// <summary>
1256         /// Sets a preferred orientation.
1257         /// </summary>
1258         /// <param name="orientation">The preferred orientation.</param>
1259         /// <since_tizen> 6 </since_tizen>
1260         public void SetPreferredOrientation(Window.WindowOrientation orientation)
1261         {
1262             Interop.Window.SetPreferredOrientation(SwigCPtr, (int)orientation);
1263             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1264         }
1265
1266         /// <summary>
1267         /// Gets the preferred orientation.
1268         /// </summary>
1269         /// <since_tizen> 6 </since_tizen>
1270         /// <returns>The preferred orientation if previously set, or none.</returns>
1271         public Window.WindowOrientation GetPreferredOrientation()
1272         {
1273             Window.WindowOrientation ret = (Window.WindowOrientation)Interop.Window.GetPreferredOrientation(SwigCPtr);
1274             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1275             return ret;
1276         }
1277
1278         /// <summary>
1279         /// Gets current orientation of the window.
1280         /// </summary>
1281         /// <since_tizen> 6 </since_tizen>
1282         /// <returns>The current window orientation if previously set, or none.</returns>
1283         [EditorBrowsable(EditorBrowsableState.Never)]
1284         public Window.WindowOrientation GetCurrentOrientation()
1285         {
1286             Window.WindowOrientation ret = (Window.WindowOrientation)Interop.Window.GetCurrentOrientation(SwigCPtr);
1287             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1288             return ret;
1289         }
1290
1291         /// <summary>
1292         /// Sets available orientations of the window.
1293         /// This API is for setting several orientations one time.
1294         /// </summary>
1295         /// <param name="orientations">The list of orientations.</param>
1296         /// <since_tizen> 6 </since_tizen>
1297         [EditorBrowsable(EditorBrowsableState.Never)]
1298         public void SetAvailableOrientations(List<Window.WindowOrientation> orientations)
1299         {
1300             if (null == orientations)
1301             {
1302                 throw new ArgumentNullException(nameof(orientations));
1303             }
1304
1305             PropertyArray orientationArray = new PropertyArray();
1306             for (int i = 0; i < orientations.Count; i++)
1307             {
1308                 PropertyValue value = new PropertyValue((int)orientations[i]);
1309                 orientationArray.PushBack(value);
1310                 value.Dispose();
1311             }
1312
1313             Interop.Window.SetAvailableOrientations(SwigCPtr, PropertyArray.getCPtr(orientationArray), orientations.Count);
1314             orientationArray.Dispose();
1315             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1316         }
1317
1318         /// <summary>
1319         /// Get native window ID
1320         /// </summary>
1321         /// <returns>native window ID</returns>
1322         [EditorBrowsable(EditorBrowsableState.Never)]
1323         public int GetNativeId()
1324         {
1325             int ret = Interop.Window.GetNativeId(SwigCPtr);
1326             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1327             return ret;
1328         }
1329
1330         internal Any GetNativeHandle()
1331         {
1332             Any ret = new Any(Interop.WindowInternal.WindowGetNativeHandle(SwigCPtr), true);
1333             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1334             return ret;
1335         }
1336
1337         internal void Add(Layer layer)
1338         {
1339             if (null == layer)
1340             {
1341                 throw new ArgumentNullException(nameof(layer));
1342             }
1343             Interop.Window.Add(SwigCPtr, Layer.getCPtr(layer));
1344             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1345
1346             LayersChildren?.Add(layer);
1347             layer.SetWindow(this);
1348         }
1349
1350         internal void Remove(Layer layer)
1351         {
1352             if (null == layer)
1353             {
1354                 throw new ArgumentNullException(nameof(layer));
1355             }
1356             Interop.Window.Remove(SwigCPtr, Layer.getCPtr(layer));
1357             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1358
1359             LayersChildren?.Remove(layer);
1360             layer.SetWindow(null);
1361         }
1362
1363         internal Vector2 GetSize()
1364         {
1365             var val = new Uint16Pair(Interop.Window.GetSize(SwigCPtr), true);
1366             Vector2 ret = new Vector2(val.GetWidth(), val.GetHeight());
1367             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1368             return ret;
1369         }
1370
1371         /// This will be public opened in next tizen after ACR done. Before ACR, need to be hidden as inhouse API.
1372         [EditorBrowsable(EditorBrowsableState.Never)]
1373         public RenderTaskList GetRenderTaskList()
1374         {
1375             RenderTaskList ret = new RenderTaskList(Interop.Stage.GetRenderTaskList(stageCPtr), true);
1376             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1377             return ret;
1378         }
1379
1380         /// <summary>
1381         /// Queries the number of on-window layers.
1382         /// </summary>
1383         /// <returns>The number of layers.</returns>
1384         /// <remarks>Note that a default layer is always provided (count >= 1).</remarks>
1385         internal uint GetLayerCount()
1386         {
1387             if (LayersChildren == null || LayersChildren.Count < 0)
1388                 return 0;
1389
1390             return (uint)LayersChildren.Count;
1391         }
1392
1393         internal Layer GetRootLayer()
1394         {
1395             // Window.IsInstalled() is actually true only when called from event thread and
1396             // Core has been initialized, not when Stage is ready.
1397             if (rootLayer == null && Window.IsInstalled())
1398             {
1399                 rootLayer = new Layer(Interop.Window.GetRootLayer(SwigCPtr), true);
1400                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1401                 LayersChildren?.Add(rootLayer);
1402                 rootLayer.SetWindow(this);
1403             }
1404             return rootLayer;
1405         }
1406
1407         internal void SetBackgroundColor(Vector4 color)
1408         {
1409             Interop.Window.SetBackgroundColor(SwigCPtr, Vector4.getCPtr(color));
1410             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1411         }
1412
1413         internal Vector4 GetBackgroundColor()
1414         {
1415             Vector4 ret = new Vector4(Interop.Window.GetBackgroundColor(SwigCPtr), true);
1416             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1417             return ret;
1418         }
1419
1420         internal Vector2 GetDpi()
1421         {
1422             Vector2 ret = new Vector2(Interop.Stage.GetDpi(stageCPtr), true);
1423             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1424             return ret;
1425         }
1426
1427         internal ObjectRegistry GetObjectRegistry()
1428         {
1429             ObjectRegistry ret = new ObjectRegistry(Interop.Stage.GetObjectRegistry(stageCPtr), true);
1430             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1431             return ret;
1432         }
1433
1434         internal void SetRenderingBehavior(RenderingBehaviorType renderingBehavior)
1435         {
1436             Interop.Stage.SetRenderingBehavior(stageCPtr, (int)renderingBehavior);
1437             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1438         }
1439
1440         internal RenderingBehaviorType GetRenderingBehavior()
1441         {
1442             RenderingBehaviorType ret = (RenderingBehaviorType)Interop.Stage.GetRenderingBehavior(stageCPtr);
1443             if (NDalicPINVOKE.SWIGPendingException.Pending)
1444                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1445             return ret;
1446         }
1447
1448         internal void SetWindowSize(Size2D size)
1449         {
1450             if (null == size)
1451             {
1452                 throw new ArgumentNullException(nameof(size));
1453             }
1454             var val = new Uint16Pair((uint)size.Width, (uint)size.Height);
1455             Interop.Window.SetSize(SwigCPtr, Uint16Pair.getCPtr(val));
1456             val.Dispose();
1457             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1458             // Resetting Window size should request a relayout of the tree.
1459         }
1460
1461         internal Size2D GetWindowSize()
1462         {
1463             var val = new Uint16Pair(Interop.Window.GetSize(SwigCPtr), true);
1464             Size2D ret = new Size2D(val.GetWidth(), val.GetHeight());
1465             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1466             return ret;
1467         }
1468
1469         internal void SetPosition(Position2D position)
1470         {
1471             if (null == position)
1472             {
1473                 throw new ArgumentNullException(nameof(position));
1474             }
1475             var val = new Uint16Pair((uint)position.X, (uint)position.Y);
1476             Interop.Window.SetPosition(SwigCPtr, Uint16Pair.getCPtr(val));
1477             val.Dispose();
1478             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1479             // Setting Position of the window should request a relayout of the tree.
1480         }
1481
1482         internal Position2D GetPosition()
1483         {
1484             var val = new Uint16Pair(Interop.Window.GetPosition(SwigCPtr), true);
1485             Position2D ret = new Position2D(val.GetX(), val.GetY());
1486             val.Dispose();
1487             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1488             return ret;
1489         }
1490
1491         internal void SetPositionSize(Rectangle positionSize)
1492         {
1493             Interop.Window.SetPositionSize(SwigCPtr, Rectangle.getCPtr(positionSize));
1494
1495             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1496
1497             // Setting Position of the window should request a relayout of the tree.
1498         }
1499
1500         /// <summary>
1501         /// Enables the floating mode of window.
1502         /// The floating mode is to support window is moved or resized by display server.
1503         /// For example, if the video-player window sets the floating mode,
1504         /// then display server changes its geometry and handles it like a popup.
1505         /// The way of handling floating mode window is decided by display server.
1506         /// A special display server(as a Tizen display server) supports this mode.
1507         /// </summary>
1508         /// <param name="enable">Enable floating mode or not.</param>
1509         [EditorBrowsable(EditorBrowsableState.Never)]
1510         public void EnableFloatingMode(bool enable)
1511         {
1512             Interop.Window.EnableFloatingMode(SwigCPtr, enable);
1513             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1514         }
1515
1516         /// <summary>
1517         /// Requests to display server for the window is moved by display server.
1518         /// It can be work with setting window floating mode.
1519         /// </summary>
1520         [EditorBrowsable(EditorBrowsableState.Never)]
1521         public void RequestMoveToServer()
1522         {
1523             Interop.Window.RequestMoveToServer(SwigCPtr);
1524             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1525         }
1526
1527         /// <summary>
1528         ///  Requests to display server for the window is resized by display server.
1529         /// It can be work with setting window floating mode.
1530         /// </summary>
1531         /// <param name="direction">It is indicated the window's side or edge for starting point.</param>
1532         [EditorBrowsable(EditorBrowsableState.Never)]
1533         public void RequestResizeToServer(ResizeDirection direction)
1534         {
1535             Interop.Window.RequestResizeToServer(SwigCPtr, (int)direction);
1536             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1537         }
1538
1539         /// <summary>
1540         /// Includes input region.
1541         /// This function inlcudes input regions.
1542         /// It can be used multiple times and supports multiple regions.
1543         /// It means input region will be extended.
1544         /// This input is related to mouse and touch event.
1545         /// If device has touch screen, this function is useful.
1546         /// Otherwise device does not have that, we can use it after connecting mouse to the device.
1547         /// </summary>
1548         /// <param name="inputRegion">The included region to accept input events.</param>
1549         [EditorBrowsable(EditorBrowsableState.Never)]
1550         public void IncludeInputRegion(Rectangle inputRegion)
1551         {
1552             Interop.Window.IncludeInputRegion(SwigCPtr, Rectangle.getCPtr(inputRegion));
1553             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1554         }
1555
1556         /// <summary>
1557         /// This function excludes input regions.
1558         /// It can be used multiple times and supports multiple regions.
1559         /// It means input region will be reduced.
1560         /// Nofice, should be set input area by IncludeInputRegion() before this function is used.
1561         /// This input is related to mouse and touch event.
1562         /// If device has touch screen, this function is useful.
1563         /// Otherwise device does not have that, we can use it after connecting mouse to the device.
1564         /// </summary>
1565         /// <param name="inputRegion">The excluded region to except input events.</param>
1566         [EditorBrowsable(EditorBrowsableState.Never)]
1567         public void ExcludeInputRegion(Rectangle inputRegion)
1568         {
1569             Interop.Window.ExcludeInputRegion(SwigCPtr, Rectangle.getCPtr(inputRegion));
1570             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1571         }
1572
1573         /// <summary>
1574         /// Add FrameUpdateCallback
1575         /// </summary>
1576         [EditorBrowsable(EditorBrowsableState.Never)]
1577         public void AddFrameUpdateCallback(FrameUpdateCallbackInterface frameUpdateCallback)
1578         {
1579             frameUpdateCallback?.AddFrameUpdateCallback(stageCPtr, Layer.getCPtr(GetRootLayer()));
1580         }
1581
1582         /// <summary>
1583         /// Remove FrameUpdateCallback
1584         /// </summary>
1585         [EditorBrowsable(EditorBrowsableState.Never)]
1586         public void RemoveFrameUpdateCallback(FrameUpdateCallbackInterface frameUpdateCallback)
1587         {
1588             frameUpdateCallback?.RemoveFrameUpdateCallback(stageCPtr);
1589         }
1590
1591         /// <summary>
1592         /// Dispose for Window
1593         /// </summary>
1594         [EditorBrowsable(EditorBrowsableState.Never)]
1595         protected override void Dispose(DisposeTypes type)
1596         {
1597             if (disposed)
1598             {
1599                 return;
1600             }
1601
1602             if (type == DisposeTypes.Explicit)
1603             {
1604                 //Called by User
1605                 //Release your own managed resources here.
1606                 //You should release all of your own disposable objects here.
1607
1608                 if (rootLayer != null)
1609                 {
1610                     rootLayer.Dispose();
1611                 }
1612
1613                 localController?.Dispose();
1614
1615                 foreach (var layer in childLayers)
1616                 {
1617                     if (layer != null)
1618                     {
1619                         layer.Dispose();
1620                     }
1621                 }
1622
1623                 childLayers.Clear();
1624             }
1625
1626             this.DisconnectNativeSignals();
1627
1628             base.Dispose(type);
1629         }
1630
1631         /// This will not be public opened.
1632         [EditorBrowsable(EditorBrowsableState.Never)]
1633         protected override void ReleaseSwigCPtr(System.Runtime.InteropServices.HandleRef swigCPtr)
1634         {
1635             Interop.Window.DeleteWindow(swigCPtr);
1636         }
1637
1638         private static Dictionary<int, internalHookCallbackType> frameCallbackList = new Dictionary<int, internalHookCallbackType>();
1639
1640         private static readonly object locker = new object();
1641
1642         private static int key = 0;
1643
1644         private static FrameCallbackType internalHookFrameCallback = OnInternalHookFrameCallback;
1645
1646         private struct internalHookCallbackType
1647         {
1648             public FrameCallbackType userCallback;
1649             public int frameId;
1650         }
1651
1652         private static void OnInternalHookFrameCallback(int id)
1653         {
1654             lock (locker)
1655             {
1656                 if (frameCallbackList.ContainsKey(id))
1657                 {
1658                     if (frameCallbackList[id].userCallback != null)
1659                     {
1660                         frameCallbackList[id].userCallback.Invoke(frameCallbackList[id].frameId);
1661                         frameCallbackList.Remove(id);
1662                     }
1663                     else
1664                     {
1665                         NUILog.Error($"found userCallback is NULL");
1666                         frameCallbackList.Remove(id);
1667                     }
1668                 }
1669             }
1670         }
1671
1672         private int AddInterHookCallback(FrameCallbackType callback, int frameId)
1673         {
1674             if (null == callback)
1675             {
1676                 throw new ArgumentNullException(nameof(callback), "FrameCallbackType should not be null");
1677             }
1678             var assignedKey = 0;
1679             lock (locker)
1680             {
1681                 key++;
1682                 assignedKey = key;
1683                 frameCallbackList.Add(assignedKey, new internalHookCallbackType()
1684                 {
1685                     userCallback = callback,
1686                     frameId = frameId,
1687                 });
1688             }
1689             return assignedKey;
1690         }
1691
1692         /// <summary>
1693         /// Type of callback which is called when the frame rendering is done by graphics driver or when the frame is displayed on display.
1694         /// </summary>
1695         /// <param name="frameId">The Id to specify the frame. It will be passed when the callback is called.</param>
1696         [EditorBrowsable(EditorBrowsableState.Never)]
1697         public delegate void FrameCallbackType(int frameId);
1698
1699         /// <summary>
1700         /// Adds a callback that is called when the frame rendering is done by the graphics driver.
1701         /// A callback of the following type may be used:
1702         /// <code>
1703         /// void MyFunction( int frameId )
1704         /// </code>
1705         /// This callback will be deleted once it is called.
1706         /// <remarks>
1707         /// Ownership of the callback is passed onto this class
1708         /// </remarks>
1709         /// </summary>
1710         /// <param name="callback">The function to call</param>
1711         /// <param name="frameId">The Id to specify the frame. It will be passed when the callback is called.</param>
1712         /// <exception cref="ArgumentNullException">This exception can occur by the callback is null.</exception>
1713         [EditorBrowsable(EditorBrowsableState.Never)]
1714         public void AddFrameRenderedCallback(FrameCallbackType callback, int frameId)
1715         {
1716             var assignedKey = AddInterHookCallback(callback, frameId);
1717             Interop.WindowInternal.AddFrameRenderedCallback(SwigCPtr, new HandleRef(this, Marshal.GetFunctionPointerForDelegate<Delegate>(internalHookFrameCallback)), assignedKey);
1718
1719             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1720         }
1721
1722         /// <summary>
1723         /// Adds a callback that is called when the frame is displayed on the display.
1724         /// A callback of the following type may be used:
1725         /// <code>
1726         /// void MyFunction( int frameId )
1727         /// </code>
1728         /// This callback will be deleted once it is called.
1729         /// <remarks>
1730         /// Ownership of the callback is passed onto this class
1731         /// </remarks>
1732         /// </summary>
1733         /// <param name="callback">The function to call</param>
1734         /// <param name="frameId">The Id to specify the frame. It will be passed when the callback is called.</param>
1735         /// <exception cref="ArgumentNullException">This exception can occur by the callback is null.</exception>
1736         [EditorBrowsable(EditorBrowsableState.Never)]
1737         public void AddFramePresentedCallback(FrameCallbackType callback, int frameId)
1738         {
1739             var assignedKey = AddInterHookCallback(callback, frameId);
1740             Interop.WindowInternal.AddFramePresentedCallback(SwigCPtr, new HandleRef(this, Marshal.GetFunctionPointerForDelegate<Delegate>(internalHookFrameCallback)), assignedKey);
1741
1742             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1743         }
1744
1745         /// <summary>
1746         /// Search through this Window for a Layer with the given unique ID.
1747         /// </summary>
1748         /// <param name="id">The ID of the Layer to find.</param>
1749         /// <remarks>Hidden-API</remarks>
1750         /// <returns>A handle to the Layer if found, or an empty handle if not.</returns>
1751         [EditorBrowsable(EditorBrowsableState.Never)]
1752         public Layer FindLayerByID(uint id)
1753         {
1754             Layer defaultLayer = this.GetDefaultLayer();
1755             IntPtr cPtr = Interop.Actor.FindChildById(defaultLayer.SwigCPtr, id);
1756             Layer ret = this.GetInstanceSafely<Layer>(cPtr);
1757
1758             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1759             return ret;
1760         }
1761
1762         /// <summary>
1763         /// Get Native Window handle.
1764         /// <example>
1765         /// How to get Native Window handle
1766         /// <code>
1767         /// Window window = NUIApplication.GetDefaultWindow();
1768         /// var handle = window.NativeHandle;
1769         /// if(handle.IsInvalid == false)
1770         /// {
1771         ///     IntPtr nativeHandle = handle.DangerousGetHandle();
1772         ///     // do something with nativeHandle
1773         /// }
1774         /// </code>
1775         /// </example>
1776         /// </summary>
1777         /// <since_tizen> 9 </since_tizen>
1778         public SafeHandle NativeHandle
1779         {
1780             get
1781             {
1782                 return new NUI.SafeNativeWindowHandle(this);
1783             }
1784         }
1785     }
1786 }