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