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