2 * Copyright(c) 2021 Samsung Electronics Co., Ltd.
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
18 extern alias TizenSystemInformation;
19 using TizenSystemInformation.Tizen.System;
22 using System.ComponentModel;
23 using System.Collections.Generic;
24 using System.Runtime.InteropServices;
26 using Tizen.NUI.BaseComponents;
31 /// The window class is used internally for drawing.<br />
32 /// The window has an orientation and indicator properties.<br />
34 /// <since_tizen> 3 </since_tizen>
35 public partial class Window : BaseHandle
37 private HandleRef stageCPtr;
38 private Layer rootLayer;
39 private string windowTitle;
40 private List<Layer> childLayers = new List<Layer>();
41 private LayoutController localController;
43 static internal bool IsSupportedMultiWindow()
45 bool isSupported = false;
46 Information.TryGetValue("http://tizen.org/feature/opengles.surfaceless_context", out isSupported);
50 internal Window(global::System.IntPtr cPtr, bool cMemoryOwn) : base(cPtr, cMemoryOwn)
52 if (Interop.Stage.IsInstalled())
54 stageCPtr = new global::System.Runtime.InteropServices.HandleRef(this, Interop.Stage.GetCurrent());
56 localController = new LayoutController(this);
57 NUILog.Debug("layoutController id:" + localController.GetId());
62 /// Creates a new Window.<br />
63 /// This creates an extra window in addition to the default main window<br />
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)
73 if (IsSupportedMultiWindow() == false)
75 NUILog.Error("This device does not support surfaceless_context. So Window cannot be created. ");
77 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
81 /// Creates a new Window with a specific name.<br />
82 /// This creates an extra window in addition to the default main window<br />
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)
93 if (IsSupportedMultiWindow() == false)
95 NUILog.Error("This device does not support surfaceless_context. So Window cannot be created. ");
97 this.windowTitle = name;
98 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
102 /// Enumeration for orientation of the window is the way in which a rectangular page is oriented for normal viewing.
104 /// <since_tizen> 3 </since_tizen>
105 public enum WindowOrientation
108 /// Portrait orientation. The height of the display area is greater than the width.
110 /// <since_tizen> 3 </since_tizen>
113 /// Landscape orientation. A wide view area is needed.
115 /// <since_tizen> 3 </since_tizen>
118 /// Portrait inverse orientation.
120 /// <since_tizen> 3 </since_tizen>
121 PortraitInverse = 180,
123 /// Landscape inverse orientation.
125 /// <since_tizen> 3 </since_tizen>
126 LandscapeInverse = 270,
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.
132 [EditorBrowsable(EditorBrowsableState.Never)]
133 NoOrientationPreference = -1
137 /// Enumeration for the key grab mode for platform-level APIs.
139 /// <since_tizen> 3 </since_tizen>
140 public enum KeyGrabMode
143 /// Grabs a key only when on the top of the grabbing-window stack mode.
147 /// Grabs a key together with the other client window(s) mode.
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.
155 /// Grabs a key exclusively regardless of the grabbing-window's position on the window stack mode.
161 /// Enumeration for transition effect's state.
163 [Obsolete("Please do not use! This will be removed. Please use Window.EffectState instead!")]
164 [EditorBrowsable(EditorBrowsableState.Never)]
165 public enum EffectStates
170 [Obsolete("Please do not use! This will be removed. Please use Window.EffectState.None instead!")]
171 [EditorBrowsable(EditorBrowsableState.Never)]
174 /// Transition effect is started.
176 [Obsolete("Please do not use! This will be removed. Please use Window.EffectState.Start instead!")]
177 [EditorBrowsable(EditorBrowsableState.Never)]
180 /// Transition effect is ended.
182 [Obsolete("Please do not use! This will be removed. Please use Window.EffectState.End instead!")]
183 [EditorBrowsable(EditorBrowsableState.Never)]
188 /// Enumeration for transition effect's state.
190 [EditorBrowsable(EditorBrowsableState.Never)]
191 public enum EffectState
196 [EditorBrowsable(EditorBrowsableState.Never)]
199 /// Transition effect is started.
201 [EditorBrowsable(EditorBrowsableState.Never)]
204 /// Transition effect is ended.
206 [EditorBrowsable(EditorBrowsableState.Never)]
211 /// Enumeration for transition effect's type.
213 [Obsolete("Please do not use! This will be removed. Please use Window.EffectType instead!")]
214 [EditorBrowsable(EditorBrowsableState.Never)]
215 public enum EffectTypes
220 [Obsolete("Please do not use! This will be removed. Please use Window.EffectType.None instead!")]
221 [EditorBrowsable(EditorBrowsableState.Never)]
224 /// Window show effect.
226 [Obsolete("Please do not use! This will be removed. Please use Window.EffectType.Show instead!")]
227 [EditorBrowsable(EditorBrowsableState.Never)]
230 /// Window hide effect.
232 [Obsolete("Please do not use! This will be removed. Please use Window.EffectType.Hide instead!")]
233 [EditorBrowsable(EditorBrowsableState.Never)]
238 /// Enumeration for transition effect's type.
240 [EditorBrowsable(EditorBrowsableState.Never)]
241 public enum EffectType
246 [EditorBrowsable(EditorBrowsableState.Never)]
249 /// Window show effect.
251 [EditorBrowsable(EditorBrowsableState.Never)]
254 /// Window hide effect.
256 [EditorBrowsable(EditorBrowsableState.Never)]
261 /// Enumeration for result of window operation.
263 internal enum OperationResult
266 /// Failed for unknown reason
274 /// Permission denied
278 /// The operation is not supported.
284 /// Enumeration for window resized mode by display server.
286 [EditorBrowsable(EditorBrowsableState.Never)]
287 public enum ResizeDirection
290 /// Start resizing window to the top-left edge.
292 [EditorBrowsable(EditorBrowsableState.Never)]
295 /// Start resizing window to the top side.
297 [EditorBrowsable(EditorBrowsableState.Never)]
300 /// Start resizing window to the top-right edge.
302 [EditorBrowsable(EditorBrowsableState.Never)]
305 /// Start resizing window to the left side.
307 [EditorBrowsable(EditorBrowsableState.Never)]
310 /// Start resizing window to the right side.
312 [EditorBrowsable(EditorBrowsableState.Never)]
315 /// Start resizing window to the bottom-left edge.
317 [EditorBrowsable(EditorBrowsableState.Never)]
320 /// Start resizing window to the bottom side.
322 [EditorBrowsable(EditorBrowsableState.Never)]
325 /// Start resizing window to the bottom-right edge.
327 [EditorBrowsable(EditorBrowsableState.Never)]
333 /// The stage instance property (read-only).<br />
334 /// Gets the current window.<br />
336 /// <since_tizen> 3 </since_tizen>
337 public static Window Instance { get; internal set; }
340 /// Gets or sets a window type.
342 /// <since_tizen> 3 </since_tizen>
343 public WindowType Type
347 WindowType ret = (WindowType)Interop.Window.GetType(SwigCPtr);
348 if (NDalicPINVOKE.SWIGPendingException.Pending) throw new InvalidOperationException("FATAL: get Exception", NDalicPINVOKE.SWIGPendingException.Retrieve());
353 Interop.Window.SetType(SwigCPtr, (int)value);
354 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
359 /// Gets/Sets a window title.
361 /// <since_tizen> 4 </since_tizen>
371 SetClass(windowTitle, "");
376 /// The rendering behavior of a Window.
378 /// <since_tizen> 5 </since_tizen>
379 public RenderingBehaviorType RenderingBehavior
383 return GetRenderingBehavior();
387 SetRenderingBehavior(value);
392 /// The window size property (read-only).
394 /// <since_tizen> 3 </since_tizen>
399 Size2D ret = GetSize();
405 /// The background color property.
407 /// <since_tizen> 3 </since_tizen>
408 public Color BackgroundColor
412 SetBackgroundColor(value);
416 Color ret = GetBackgroundColor();
422 /// The DPI property (read-only).<br />
423 /// Retrieves the DPI of the display device to which the Window is connected.<br />
425 /// <since_tizen> 3 </since_tizen>
435 /// The layer count property (read-only).<br />
436 /// Queries the number of on-Window layers.<br />
438 /// <since_tizen> 3 </since_tizen>
439 public uint LayerCount
443 return GetLayerCount();
448 /// Gets or sets a size of the window.
450 /// <exception cref="ArgumentNullException"> Thrown when value is null. </exception>
451 /// <since_tizen> 4 </since_tizen>
452 public Size2D WindowSize
456 return GetWindowSize();
460 SetWindowSize(value);
465 /// Gets or sets a position of the window.
467 /// <exception cref="ArgumentNullException"> Thrown when value is null. </exception>
468 /// <since_tizen> 4 </since_tizen>
469 public Position2D WindowPosition
473 return GetPosition();
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.
485 [EditorBrowsable(EditorBrowsableState.Never)]
486 public Rectangle WindowPositionSize
490 Position2D position = GetPosition();
491 Size2D size = GetSize();
492 Rectangle ret = new Rectangle(position.X, position.Y, size.Width, size.Height);
498 SetPositionSize(value);
502 internal static Vector4 DEFAULT_BACKGROUND_COLOR
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();
513 internal static Vector4 DEBUG_BACKGROUND_COLOR
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();
524 internal List<Layer> LayersChildren
533 /// Get the LayoutController for this Window.
535 internal LayoutController LayoutController
539 return localController;
544 /// Feed a key-event into the window.
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)
551 Interop.Window.FeedKeyEvent(Key.getCPtr(keyEvent));
552 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
556 /// Sets whether the window accepts a focus or not.
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)
562 Interop.Window.SetAcceptFocus(SwigCPtr, accept);
563 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
567 /// Returns whether the window accepts a focus or not.
569 /// <returns>True if the window accepts a focus, false otherwise.</returns>
570 /// <since_tizen> 3 </since_tizen>
571 public bool IsFocusAcceptable()
573 bool ret = Interop.Window.IsFocusAcceptable(SwigCPtr);
574 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
580 /// Shows the window if it is hidden.
582 /// <since_tizen> 3 </since_tizen>
585 Interop.Window.Show(SwigCPtr);
586 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
590 /// Hides the window if it is showing.
592 /// <since_tizen> 3 </since_tizen>
595 Interop.Window.Hide(SwigCPtr);
596 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
600 /// Retrieves whether the window is visible or not.
602 /// <returns>True if the window is visible.</returns>
603 /// <since_tizen> 3 </since_tizen>
604 public bool IsVisible()
606 bool temp = Interop.Window.IsVisible(SwigCPtr);
607 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
612 /// Gets the count of supported auxiliary hints of the window.
614 /// <returns>The number of supported auxiliary hints.</returns>
615 /// <since_tizen> 3 </since_tizen>
616 public uint GetSupportedAuxiliaryHintCount()
618 uint ret = Interop.Window.GetSupportedAuxiliaryHintCount(SwigCPtr);
619 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
624 /// Gets the supported auxiliary hint string of the window.
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)
631 string ret = Interop.Window.GetSupportedAuxiliaryHint(SwigCPtr, index);
632 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
637 /// Creates an auxiliary hint of the window.
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)
645 uint ret = Interop.Window.AddAuxiliaryHint(SwigCPtr, hint, value);
646 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
651 /// Removes an auxiliary hint of the window.
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)
658 bool ret = Interop.Window.RemoveAuxiliaryHint(SwigCPtr, id);
659 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
664 /// Changes a value of the auxiliary hint.
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)
672 bool ret = Interop.Window.SetAuxiliaryHintValue(SwigCPtr, id, value);
673 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
678 /// Gets a value of the auxiliary hint.
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)
685 string ret = Interop.Window.GetAuxiliaryHintValue(SwigCPtr, id);
686 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
691 /// Gets an ID of the auxiliary hint string.
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)
698 uint ret = Interop.Window.GetAuxiliaryHintId(SwigCPtr, hint);
699 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
704 /// Sets a region to accept input events.
706 /// <param name="inputRegion">The region to accept input events.</param>
707 /// <since_tizen> 3 </since_tizen>
708 public void SetInputRegion(Rectangle inputRegion)
710 Interop.Window.SetInputRegion(SwigCPtr, Rectangle.getCPtr(inputRegion));
711 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
715 /// Sets a priority level for the specified notification window.
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)
722 var ret = (OperationResult)Interop.Window.SetNotificationLevel(SwigCPtr, (int)level);
723 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
724 return ret == OperationResult.Succeed;
728 /// Gets a priority level for the specified notification window.
730 /// <returns>The notification window level.</returns>
731 /// <since_tizen> 3 </since_tizen>
732 public NotificationLevel GetNotificationLevel()
734 NotificationLevel ret = (NotificationLevel)Interop.Window.GetNotificationLevel(SwigCPtr);
735 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
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.
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.
748 /// <since_tizen> 3 </since_tizen>
749 public void SetOpaqueState(bool opaque)
751 Interop.Window.SetOpaqueState(SwigCPtr, opaque);
752 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
756 /// Returns whether a transparent window's visual state is opaque or not.
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()
763 bool ret = Interop.Window.IsOpaqueState(SwigCPtr);
764 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
769 /// Sets a window's screen off mode.
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)
776 var ret = (OperationResult)Interop.Window.SetScreenOffMode(SwigCPtr, (int)screenOffMode);
777 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
778 return ret == OperationResult.Succeed;
782 /// Gets the screen mode of the window.
784 /// <returns>The screen off mode.</returns>
785 /// <since_tizen> 4 </since_tizen>
786 public ScreenOffMode GetScreenOffMode()
788 ScreenOffMode ret = (ScreenOffMode)Interop.Window.GetScreenOffMode(SwigCPtr);
789 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
794 /// Sets preferred brightness of the window.
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)
801 var ret = (OperationResult)Interop.Window.SetBrightness(SwigCPtr, brightness);
802 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
803 return ret == OperationResult.Succeed;
807 /// Gets the preferred brightness of the window.
809 /// <returns>The preferred brightness.</returns>
810 /// <since_tizen> 3 </since_tizen>
811 public int GetBrightness()
813 int ret = Interop.Window.GetBrightness(SwigCPtr);
814 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
819 /// Sets the window name and the class string.
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)
826 Interop.Window.SetClass(SwigCPtr, name, klass);
827 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
831 /// Raises the window to the top of the window stack.
833 /// <since_tizen> 3 </since_tizen>
836 Interop.Window.Raise(SwigCPtr);
837 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
841 /// Lowers the window to the bottom of the window stack.
843 /// <since_tizen> 3 </since_tizen>
846 Interop.Window.Lower(SwigCPtr);
847 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
851 /// Activates the window to the top of the window stack even it is iconified.
853 /// <since_tizen> 3 </since_tizen>
854 public void Activate()
856 Interop.Window.Activate(SwigCPtr);
857 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
861 /// Gets the default ( root ) layer.
863 /// <returns>The root layer.</returns>
864 /// <since_tizen> 3 </since_tizen>
865 public Layer GetDefaultLayer()
867 return this.GetRootLayer();
871 /// Add a child view to window.
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)
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
882 view.InternalParent = this.GetRootLayer();
887 /// Remove a child view from window.
889 /// <param name="view">the child to be removed.</param>
890 /// <since_tizen> 3 </since_tizen>
891 public void Remove(View view)
893 Interop.Actor.Remove(Layer.getCPtr(GetRootLayer()), View.getCPtr(view));
894 this.GetRootLayer().RemoveViewFromLayerList(view); // Maintain the children list in the Layer
897 view.InternalParent = null;
902 /// Retrieves the layer at a specified depth.
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)
909 if (depth < LayersChildren?.Count)
911 Layer ret = LayersChildren?[Convert.ToInt32(depth)];
921 /// Destroy the window immediately.
923 [EditorBrowsable(EditorBrowsableState.Never)]
924 public void Destroy()
930 /// Keep rendering for at least the given amount of time.
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)
936 Interop.Stage.KeepRendering(stageCPtr, durationSeconds);
937 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
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 />
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)
950 bool ret = Interop.Window.GrabKeyTopmost(HandleRef.ToIntPtr(this.SwigCPtr), DaliKey);
951 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
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 />
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)
964 bool ret = Interop.Window.UngrabKeyTopmost(HandleRef.ToIntPtr(this.SwigCPtr), DaliKey);
965 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
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 />
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)
982 bool ret = Interop.Window.GrabKey(HandleRef.ToIntPtr(this.SwigCPtr), DaliKey, (int)GrabMode);
983 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
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 />
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)
996 bool ret = Interop.Window.UngrabKey(HandleRef.ToIntPtr(this.SwigCPtr), DaliKey);
997 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1002 /// Sets the keyboard repeat information.
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)
1010 bool ret = Interop.Window.SetKeyboardRepeatInfo(rate, delay);
1011 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1016 /// Gets the keyboard repeat information.
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)
1024 bool ret = Interop.Window.GetKeyboardRepeatInfo(out rate, out delay);
1025 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1030 /// Adds a layer to the stage.
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)
1041 /// Removes a layer from the stage.
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)
1052 /// Feeds a key event into the window.
1054 /// <param name="keyEvent">The key event to feed.</param>
1055 /// <since_tizen> 5 </since_tizen>
1056 public void FeedKey(Key keyEvent)
1058 Interop.Window.FeedKeyEvent(Key.getCPtr(keyEvent));
1059 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1063 /// Allows at least one more render, even when paused.
1064 /// The window should be shown, not minimised.
1066 /// <since_tizen> 4 </since_tizen>
1067 public void RenderOnce()
1069 Interop.Window.RenderOnce(SwigCPtr);
1070 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1074 /// Sets whether the window is transparent or not.
1076 /// <param name="transparent">Whether the window is transparent or not.</param>
1077 /// <since_tizen> 5 </since_tizen>
1078 public void SetTransparency(bool transparent)
1080 Interop.Window.SetTransparency(SwigCPtr, transparent);
1081 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1083 // Setting transparency of the window should request a relayout of the tree in the case the window changes from fully transparent.
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.
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)
1098 if (IsSupportedMultiWindow() == false)
1100 NUILog.Error("This device does not support surfaceless_context. So Window cannot be created. ");
1102 Interop.Window.SetParent(SwigCPtr, Window.getCPtr(parent));
1103 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1107 /// Unsets parent window of the window.
1108 /// After unsetting, the window is disconnected his parent window.
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()
1115 if (IsSupportedMultiWindow() == false)
1117 NUILog.Error("Fail to create window. because this device does not support opengles.surfaceless_context.");
1119 Interop.Window.Unparent(SwigCPtr);
1120 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1124 /// Gets parent window of the window.
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()
1133 if (IsSupportedMultiWindow() == false)
1135 NUILog.Error("This device does not support surfaceless_context. So Window cannot be created. ");
1137 Window ret = Registry.GetManagedBaseHandleFromNativePtr(Interop.Window.GetParent(SwigCPtr)) as Window;
1138 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
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()
1146 Layer rootLayer = GetRootLayer();
1147 foreach (View view in rootLayer.Children)
1153 internal static global::System.Runtime.InteropServices.HandleRef getCPtr(Window obj)
1155 return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.SwigCPtr;
1158 internal static bool IsInstalled()
1160 bool ret = Interop.Stage.IsInstalled();
1161 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1166 /// Adds an orientation to the list of available orientations.
1168 /// <param name="orientation">The available orientation to add</param>
1169 /// <since_tizen> 6 </since_tizen>
1170 public void AddAvailableOrientation(Window.WindowOrientation orientation)
1172 Interop.Window.AddAvailableOrientation(SwigCPtr, (int)orientation);
1173 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1177 /// Removes an orientation from the list of available orientations.
1179 /// <param name="orientation">The available orientation to remove.</param>
1180 /// <since_tizen> 6 </since_tizen>
1181 public void RemoveAvailableOrientation(Window.WindowOrientation orientation)
1183 Interop.Window.RemoveAvailableOrientation(SwigCPtr, (int)orientation);
1184 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1188 /// Sets a preferred orientation.
1190 /// <param name="orientation">The preferred orientation.</param>
1191 /// <since_tizen> 6 </since_tizen>
1192 public void SetPreferredOrientation(Window.WindowOrientation orientation)
1194 Interop.Window.SetPreferredOrientation(SwigCPtr, (int)orientation);
1195 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1199 /// Gets the preferred orientation.
1201 /// <since_tizen> 6 </since_tizen>
1202 /// <returns>The preferred orientation if previously set, or none.</returns>
1203 public Window.WindowOrientation GetPreferredOrientation()
1205 Window.WindowOrientation ret = (Window.WindowOrientation)Interop.Window.GetPreferredOrientation(SwigCPtr);
1206 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1211 /// Gets current orientation of the window.
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()
1218 Window.WindowOrientation ret = (Window.WindowOrientation)Interop.Window.GetCurrentOrientation(SwigCPtr);
1219 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1224 /// Sets available orientations of the window.
1225 /// This API is for setting several orientations one time.
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)
1232 if (null == orientations)
1234 throw new ArgumentNullException(nameof(orientations));
1237 PropertyArray orientationArray = new PropertyArray();
1238 for (int i = 0; i < orientations.Count; i++)
1240 PropertyValue value = new PropertyValue((int)orientations[i]);
1241 orientationArray.PushBack(value);
1245 Interop.Window.SetAvailableOrientations(SwigCPtr, PropertyArray.getCPtr(orientationArray), orientations.Count);
1246 orientationArray.Dispose();
1247 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
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.
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)
1264 Interop.Window.SetPositionSizeWithOrientation(SwigCPtr, Rectangle.getCPtr(positionSize), (int)orientation);
1265 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1269 /// Get native window ID
1271 /// <returns>native window ID</returns>
1272 [EditorBrowsable(EditorBrowsableState.Never)]
1273 public int GetNativeId()
1275 int ret = Interop.Window.GetNativeId(SwigCPtr);
1276 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1280 internal Any GetNativeHandle()
1282 Any ret = new Any(Interop.WindowInternal.WindowGetNativeHandle(SwigCPtr), true);
1283 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1287 internal void Add(Layer layer)
1291 throw new ArgumentNullException(nameof(layer));
1293 Interop.Window.Add(SwigCPtr, Layer.getCPtr(layer));
1294 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1296 LayersChildren?.Add(layer);
1297 layer.SetWindow(this);
1300 internal void Remove(Layer layer)
1304 throw new ArgumentNullException(nameof(layer));
1306 Interop.Window.Remove(SwigCPtr, Layer.getCPtr(layer));
1307 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1309 LayersChildren?.Remove(layer);
1310 layer.SetWindow(null);
1313 internal Vector2 GetSize()
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();
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()
1325 RenderTaskList ret = new RenderTaskList(Interop.Stage.GetRenderTaskList(stageCPtr), true);
1326 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1331 /// Queries the number of on-window layers.
1333 /// <returns>The number of layers.</returns>
1334 /// <remarks>Note that a default layer is always provided (count >= 1).</remarks>
1335 internal uint GetLayerCount()
1337 if (LayersChildren == null || LayersChildren.Count < 0)
1340 return (uint)LayersChildren.Count;
1343 internal Layer GetRootLayer()
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())
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);
1357 internal void SetBackgroundColor(Vector4 color)
1359 Interop.Window.SetBackgroundColor(SwigCPtr, Vector4.getCPtr(color));
1360 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1363 internal Vector4 GetBackgroundColor()
1365 Vector4 ret = new Vector4(Interop.Window.GetBackgroundColor(SwigCPtr), true);
1366 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1370 internal Vector2 GetDpi()
1372 Vector2 ret = new Vector2(Interop.Stage.GetDpi(stageCPtr), true);
1373 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1377 internal ObjectRegistry GetObjectRegistry()
1379 ObjectRegistry ret = new ObjectRegistry(Interop.Stage.GetObjectRegistry(stageCPtr), true);
1380 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1384 internal void SetRenderingBehavior(RenderingBehaviorType renderingBehavior)
1386 Interop.Stage.SetRenderingBehavior(stageCPtr, (int)renderingBehavior);
1387 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1390 internal RenderingBehaviorType GetRenderingBehavior()
1392 RenderingBehaviorType ret = (RenderingBehaviorType)Interop.Stage.GetRenderingBehavior(stageCPtr);
1393 if (NDalicPINVOKE.SWIGPendingException.Pending)
1394 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1398 internal void SetWindowSize(Size2D size)
1402 throw new ArgumentNullException(nameof(size));
1404 var val = new Uint16Pair((uint)size.Width, (uint)size.Height);
1405 Interop.Window.SetSize(SwigCPtr, Uint16Pair.getCPtr(val));
1407 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1408 // Resetting Window size should request a relayout of the tree.
1411 internal Size2D GetWindowSize()
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();
1419 internal void SetPosition(Position2D position)
1421 if (null == position)
1423 throw new ArgumentNullException(nameof(position));
1425 var val = new Uint16Pair((uint)position.X, (uint)position.Y);
1426 Interop.Window.SetPosition(SwigCPtr, Uint16Pair.getCPtr(val));
1428 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1429 // Setting Position of the window should request a relayout of the tree.
1432 internal Position2D GetPosition()
1434 var val = new Uint16Pair(Interop.Window.GetPosition(SwigCPtr), true);
1435 Position2D ret = new Position2D(val.GetX(), val.GetY());
1437 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1441 internal void SetPositionSize(Rectangle positionSize)
1443 Interop.Window.SetPositionSize(SwigCPtr, Rectangle.getCPtr(positionSize));
1445 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1447 // Setting Position of the window should request a relayout of the tree.
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.
1458 /// <param name="enable">Enable floating mode or not.</param>
1459 [EditorBrowsable(EditorBrowsableState.Never)]
1460 public void EnableFloatingMode(bool enable)
1462 Interop.Window.EnableFloatingMode(SwigCPtr, enable);
1463 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1467 /// Requests to display server for the window is moved by display server.
1468 /// It can be work with setting window floating mode.
1470 [EditorBrowsable(EditorBrowsableState.Never)]
1471 public void RequestMoveToServer()
1473 Interop.Window.RequestMoveToServer(SwigCPtr);
1474 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1478 /// Requests to display server for the window is resized by display server.
1479 /// It can be work with setting window floating mode.
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)
1485 Interop.Window.RequestResizeToServer(SwigCPtr, (int)direction);
1486 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1490 /// Add FrameUpdateCallback
1492 [EditorBrowsable(EditorBrowsableState.Never)]
1493 public void AddFrameUpdateCallback(FrameUpdateCallbackInterface frameUpdateCallback)
1495 frameUpdateCallback?.AddFrameUpdateCallback(stageCPtr, Layer.getCPtr(GetRootLayer()));
1499 /// Remove FrameUpdateCallback
1501 [EditorBrowsable(EditorBrowsableState.Never)]
1502 public void RemoveFrameUpdateCallback(FrameUpdateCallbackInterface frameUpdateCallback)
1504 frameUpdateCallback?.RemoveFrameUpdateCallback(stageCPtr);
1508 /// Dispose for Window
1510 [EditorBrowsable(EditorBrowsableState.Never)]
1511 protected override void Dispose(DisposeTypes type)
1518 if (type == DisposeTypes.Explicit)
1521 //Release your own managed resources here.
1522 //You should release all of your own disposable objects here.
1524 if (rootLayer != null)
1526 rootLayer.Dispose();
1529 localController?.Dispose();
1531 foreach (var layer in childLayers)
1539 childLayers.Clear();
1542 this.DisconnectNativeSignals();
1547 /// This will not be public opened.
1548 [EditorBrowsable(EditorBrowsableState.Never)]
1549 protected override void ReleaseSwigCPtr(System.Runtime.InteropServices.HandleRef swigCPtr)
1551 Interop.Window.DeleteWindow(swigCPtr);
1554 private static Dictionary<int, internalHookCallbackType> frameCallbackList = new Dictionary<int, internalHookCallbackType>();
1556 private static readonly object locker = new object();
1558 private static int key = 0;
1560 private static FrameCallbackType internalHookFrameCallback = OnInternalHookFrameCallback;
1562 private struct internalHookCallbackType
1564 public FrameCallbackType userCallback;
1568 private static void OnInternalHookFrameCallback(int id)
1572 if (frameCallbackList.ContainsKey(id))
1574 if (frameCallbackList[id].userCallback != null)
1576 frameCallbackList[id].userCallback.Invoke(frameCallbackList[id].frameId);
1577 frameCallbackList.Remove(id);
1581 NUILog.Error($"found userCallback is NULL");
1582 frameCallbackList.Remove(id);
1588 private int AddInterHookCallback(FrameCallbackType callback, int frameId)
1590 if (null == callback)
1592 throw new ArgumentNullException(nameof(callback), "FrameCallbackType should not be null");
1594 var assignedKey = 0;
1599 frameCallbackList.Add(assignedKey, new internalHookCallbackType()
1601 userCallback = callback,
1609 /// Type of callback which is called when the frame rendering is done by graphics driver or when the frame is displayed on display.
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);
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:
1619 /// void MyFunction( int frameId )
1621 /// This callback will be deleted once it is called.
1623 /// Ownership of the callback is passed onto this class
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)
1632 var assignedKey = AddInterHookCallback(callback, frameId);
1633 Interop.WindowInternal.AddFrameRenderedCallback(SwigCPtr, new HandleRef(this, Marshal.GetFunctionPointerForDelegate<Delegate>(internalHookFrameCallback)), assignedKey);
1635 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
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:
1642 /// void MyFunction( int frameId )
1644 /// This callback will be deleted once it is called.
1646 /// Ownership of the callback is passed onto this class
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)
1655 var assignedKey = AddInterHookCallback(callback, frameId);
1656 Interop.WindowInternal.AddFramePresentedCallback(SwigCPtr, new HandleRef(this, Marshal.GetFunctionPointerForDelegate<Delegate>(internalHookFrameCallback)), assignedKey);
1658 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1662 /// Search through this Window for a Layer with the given unique ID.
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)
1670 Layer defaultLayer = this.GetDefaultLayer();
1671 IntPtr cPtr = Interop.Actor.FindChildById(defaultLayer.SwigCPtr, id);
1672 Layer ret = this.GetInstanceSafely<Layer>(cPtr);
1674 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();