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