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