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;
48 Information.TryGetValue("http://tizen.org/feature/opengles.surfaceless_context", out isSupported);
50 catch (DllNotFoundException e)
52 Tizen.Log.Fatal("NUI", $"{e}\n");
57 internal Window(global::System.IntPtr cPtr, bool cMemoryOwn) : base(cPtr, cMemoryOwn)
59 if (Interop.Stage.IsInstalled())
61 stageCPtr = new global::System.Runtime.InteropServices.HandleRef(this, Interop.Stage.GetCurrent());
63 localController = new LayoutController(this);
64 NUILog.Debug("layoutController id:" + localController.GetId());
69 /// A helper method to get the current window where the view is added
71 /// <param name="view">The View added to the window</param>
72 /// <returns>A Window.</returns>
73 [EditorBrowsable(EditorBrowsableState.Never)]
74 static public Window Get(View view)
78 NUILog.Error("if there is no view, it can not get a window");
82 Window ret = Registry.GetManagedBaseHandleFromNativePtr(Interop.Window.Get(View.getCPtr(view))) as Window;
83 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
88 /// Creates a new Window.<br />
89 /// This creates an extra window in addition to the default main window<br />
91 /// <param name="windowPosition">The position and size of the Window.</param>
92 /// <param name="isTranslucent">Whether Window is translucent.</param>
93 /// <returns>A new Window.</returns>
94 /// <since_tizen> 6 </since_tizen>
95 /// <feature> http://tizen.org/feature/opengles.surfaceless_context </feature>
96 /// <exception cref="NotSupportedException">The required feature is not supported.</exception>
97 public Window(Rectangle windowPosition = null, bool isTranslucent = false) : this(Interop.Window.New(Rectangle.getCPtr(windowPosition), "", isTranslucent), true)
99 if (IsSupportedMultiWindow() == false)
101 NUILog.Error("This device does not support surfaceless_context. So Window cannot be created. ");
103 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
107 /// Creates a new Window with a specific name.<br />
108 /// This creates an extra window in addition to the default main window<br />
110 /// <param name="name">The name for extra window. </param>
111 /// <param name="windowPosition">The position and size of the Window.</param>
112 /// <param name="isTranslucent">Whether Window is translucent.</param>
113 /// <returns>A new Window.</returns>
114 /// <since_tizen> 6 </since_tizen>
115 /// <feature> http://tizen.org/feature/opengles.surfaceless_context </feature>
116 /// <exception cref="NotSupportedException">The required feature is not supported.</exception>
117 public Window(string name, Rectangle windowPosition = null, bool isTranslucent = false) : this(Interop.Window.New(Rectangle.getCPtr(windowPosition), name, isTranslucent), true)
119 if (IsSupportedMultiWindow() == false)
121 NUILog.Error("This device does not support surfaceless_context. So Window cannot be created. ");
123 this.windowTitle = name;
124 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
128 /// Enumeration for orientation of the window is the way in which a rectangular page is oriented for normal viewing.
130 /// <since_tizen> 3 </since_tizen>
131 public enum WindowOrientation
134 /// Portrait orientation. The height of the display area is greater than the width.
136 /// <since_tizen> 3 </since_tizen>
139 /// Landscape orientation. A wide view area is needed.
141 /// <since_tizen> 3 </since_tizen>
144 /// Portrait inverse orientation.
146 /// <since_tizen> 3 </since_tizen>
147 PortraitInverse = 180,
149 /// Landscape inverse orientation.
151 /// <since_tizen> 3 </since_tizen>
152 LandscapeInverse = 270,
154 /// No orientation. It is for the preferred orientation
155 /// Especially, NoOrientationPreference only has the effect for the preferred orientation.
156 /// It is used to unset the preferred orientation with SetPreferredOrientation.
158 [EditorBrowsable(EditorBrowsableState.Never)]
159 NoOrientationPreference = -1
163 /// Enumeration for the key grab mode for platform-level APIs.
165 /// <since_tizen> 3 </since_tizen>
166 public enum KeyGrabMode
169 /// Grabs a key only when on the top of the grabbing-window stack mode.
173 /// Grabs a key together with the other client window(s) mode.
177 /// 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.
181 /// Grabs a key exclusively regardless of the grabbing-window's position on the window stack mode.
187 /// Enumeration for transition effect's state.
189 [Obsolete("Please do not use! This will be removed. Please use Window.EffectState instead!")]
190 [EditorBrowsable(EditorBrowsableState.Never)]
191 public enum EffectStates
196 [Obsolete("Please do not use! This will be removed. Please use Window.EffectState.None instead!")]
197 [EditorBrowsable(EditorBrowsableState.Never)]
200 /// Transition effect is started.
202 [Obsolete("Please do not use! This will be removed. Please use Window.EffectState.Start instead!")]
203 [EditorBrowsable(EditorBrowsableState.Never)]
206 /// Transition effect is ended.
208 [Obsolete("Please do not use! This will be removed. Please use Window.EffectState.End instead!")]
209 [EditorBrowsable(EditorBrowsableState.Never)]
214 /// Enumeration for transition effect's state.
216 [EditorBrowsable(EditorBrowsableState.Never)]
217 public enum EffectState
222 [EditorBrowsable(EditorBrowsableState.Never)]
225 /// Transition effect is started.
227 [EditorBrowsable(EditorBrowsableState.Never)]
230 /// Transition effect is ended.
232 [EditorBrowsable(EditorBrowsableState.Never)]
237 /// Enumeration for transition effect's type.
239 [Obsolete("Please do not use! This will be removed. Please use Window.EffectType instead!")]
240 [EditorBrowsable(EditorBrowsableState.Never)]
241 public enum EffectTypes
246 [Obsolete("Please do not use! This will be removed. Please use Window.EffectType.None instead!")]
247 [EditorBrowsable(EditorBrowsableState.Never)]
250 /// Window show effect.
252 [Obsolete("Please do not use! This will be removed. Please use Window.EffectType.Show instead!")]
253 [EditorBrowsable(EditorBrowsableState.Never)]
256 /// Window hide effect.
258 [Obsolete("Please do not use! This will be removed. Please use Window.EffectType.Hide instead!")]
259 [EditorBrowsable(EditorBrowsableState.Never)]
264 /// Enumeration for transition effect's type.
266 [EditorBrowsable(EditorBrowsableState.Never)]
267 public enum EffectType
272 [EditorBrowsable(EditorBrowsableState.Never)]
275 /// Window show effect.
277 [EditorBrowsable(EditorBrowsableState.Never)]
280 /// Window hide effect.
282 [EditorBrowsable(EditorBrowsableState.Never)]
287 /// Enumeration for result of window operation.
289 internal enum OperationResult
292 /// Failed for unknown reason
300 /// Permission denied
304 /// The operation is not supported.
310 /// Enumeration for window resized mode by display server.
312 [EditorBrowsable(EditorBrowsableState.Never)]
313 public enum ResizeDirection
316 /// Start resizing window to the top-left edge.
318 [EditorBrowsable(EditorBrowsableState.Never)]
321 /// Start resizing window to the top side.
323 [EditorBrowsable(EditorBrowsableState.Never)]
326 /// Start resizing window to the top-right edge.
328 [EditorBrowsable(EditorBrowsableState.Never)]
331 /// Start resizing window to the left side.
333 [EditorBrowsable(EditorBrowsableState.Never)]
336 /// Start resizing window to the right side.
338 [EditorBrowsable(EditorBrowsableState.Never)]
341 /// Start resizing window to the bottom-left edge.
343 [EditorBrowsable(EditorBrowsableState.Never)]
346 /// Start resizing window to the bottom side.
348 [EditorBrowsable(EditorBrowsableState.Never)]
351 /// Start resizing window to the bottom-right edge.
353 [EditorBrowsable(EditorBrowsableState.Never)]
359 /// The stage instance property (read-only).<br />
360 /// Gets the current window.<br />
362 /// <since_tizen> 3 </since_tizen>
363 public static Window Instance { get; internal set; }
366 /// Gets or sets a window type.
367 /// Most of window type can be set to use WindowType, except for IME type.
368 /// IME type can be set to use one of NUIApplication's constrcutors.
370 /// <since_tizen> 3 </since_tizen>
371 public WindowType Type
375 WindowType ret = (WindowType)Interop.Window.GetType(SwigCPtr);
376 if (NDalicPINVOKE.SWIGPendingException.Pending) throw new InvalidOperationException("FATAL: get Exception", NDalicPINVOKE.SWIGPendingException.Retrieve());
381 Interop.Window.SetType(SwigCPtr, (int)value);
382 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
387 /// Gets/Sets a window title.
389 /// <since_tizen> 4 </since_tizen>
399 SetClass(windowTitle, "");
404 /// The rendering behavior of a Window.
406 /// <since_tizen> 5 </since_tizen>
407 public RenderingBehaviorType RenderingBehavior
411 return GetRenderingBehavior();
415 SetRenderingBehavior(value);
420 /// The window size property (read-only).
422 /// <since_tizen> 3 </since_tizen>
427 Size2D ret = GetSize();
433 /// The background color property.
435 /// <since_tizen> 3 </since_tizen>
436 public Color BackgroundColor
440 SetBackgroundColor(value);
444 Color ret = GetBackgroundColor();
450 /// The DPI property (read-only).<br />
451 /// Retrieves the DPI of the display device to which the Window is connected.<br />
453 /// <since_tizen> 3 </since_tizen>
463 /// The layer count property (read-only).<br />
464 /// Queries the number of on-Window layers.<br />
466 /// <since_tizen> 3 </since_tizen>
467 public uint LayerCount
471 return GetLayerCount();
476 /// Gets or sets a size of the window.
478 /// <exception cref="ArgumentNullException"> Thrown when value is null. </exception>
479 /// <since_tizen> 4 </since_tizen>
480 public Size2D WindowSize
484 return GetWindowSize();
488 SetWindowSize(value);
493 /// Gets or sets a position of the window.
495 /// <exception cref="ArgumentNullException"> Thrown when value is null. </exception>
496 /// <since_tizen> 4 </since_tizen>
497 public Position2D WindowPosition
501 return GetPosition();
510 /// Sets position and size of the window. This API guarantees that
511 /// both moving and resizing of window will appear on the screen at once.
513 [EditorBrowsable(EditorBrowsableState.Never)]
514 public Rectangle WindowPositionSize
518 Position2D position = GetPosition();
519 Size2D size = GetSize();
520 Rectangle ret = new Rectangle(position.X, position.Y, size.Width, size.Height);
526 SetPositionSize(value);
530 internal static Vector4 DEFAULT_BACKGROUND_COLOR
534 global::System.IntPtr cPtr = Interop.Stage.DefaultBackgroundColorGet();
535 Vector4 ret = (cPtr == global::System.IntPtr.Zero) ? null : new Vector4(cPtr, false);
536 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
541 internal static Vector4 DEBUG_BACKGROUND_COLOR
545 global::System.IntPtr cPtr = Interop.Stage.DebugBackgroundColorGet();
546 Vector4 ret = (cPtr == global::System.IntPtr.Zero) ? null : new Vector4(cPtr, false);
547 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
552 internal List<Layer> LayersChildren
561 /// Get the LayoutController for this Window.
563 internal LayoutController LayoutController
567 return localController;
572 /// Feed a key-event into the window.
574 /// <param name="keyEvent">The key event to feed.</param>
575 /// <since_tizen> 4 </since_tizen>
576 [Obsolete("Please do not use! This will be deprecated! Please use FeedKey(Key keyEvent) instead!")]
577 public static void FeedKeyEvent(Key keyEvent)
579 Interop.Window.FeedKeyEvent(Key.getCPtr(keyEvent));
580 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
584 /// Sets whether the window accepts a focus or not.
586 /// <param name="accept">If a focus is accepted or not. The default is true.</param>
587 /// <since_tizen> 3 </since_tizen>
588 public void SetAcceptFocus(bool accept)
590 Interop.Window.SetAcceptFocus(SwigCPtr, accept);
591 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
595 /// Returns whether the window accepts a focus or not.
597 /// <returns>True if the window accepts a focus, false otherwise.</returns>
598 /// <since_tizen> 3 </since_tizen>
599 public bool IsFocusAcceptable()
601 bool ret = Interop.Window.IsFocusAcceptable(SwigCPtr);
602 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
608 /// Shows the window if it is hidden.
610 /// <since_tizen> 3 </since_tizen>
613 Interop.Window.Show(SwigCPtr);
614 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
618 /// Hides the window if it is showing.
620 /// <since_tizen> 3 </since_tizen>
623 Interop.Window.Hide(SwigCPtr);
624 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
628 /// Retrieves whether the window is visible or not.
630 /// <returns>True if the window is visible.</returns>
631 /// <since_tizen> 3 </since_tizen>
632 public bool IsVisible()
634 bool temp = Interop.Window.IsVisible(SwigCPtr);
635 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
640 /// Gets the count of supported auxiliary hints of the window.
642 /// <returns>The number of supported auxiliary hints.</returns>
643 /// <since_tizen> 3 </since_tizen>
644 public uint GetSupportedAuxiliaryHintCount()
646 uint ret = Interop.Window.GetSupportedAuxiliaryHintCount(SwigCPtr);
647 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
652 /// Gets the supported auxiliary hint string of the window.
654 /// <param name="index">The index of the supported auxiliary hint lists.</param>
655 /// <returns>The auxiliary hint string of the index.</returns>
656 /// <since_tizen> 3 </since_tizen>
657 public string GetSupportedAuxiliaryHint(uint index)
659 string ret = Interop.Window.GetSupportedAuxiliaryHint(SwigCPtr, index);
660 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
665 /// Creates an auxiliary hint of the window.
667 /// <param name="hint">The auxiliary hint string.</param>
668 /// <param name="value">The value string.</param>
669 /// <returns>The ID of created auxiliary hint, or 0 on failure.</returns>
670 /// <since_tizen> 3 </since_tizen>
671 public uint AddAuxiliaryHint(string hint, string value)
673 uint ret = Interop.Window.AddAuxiliaryHint(SwigCPtr, hint, value);
674 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
679 /// Removes an auxiliary hint of the window.
681 /// <param name="id">The ID of the auxiliary hint.</param>
682 /// <returns>True if no error occurred, false otherwise.</returns>
683 /// <since_tizen> 3 </since_tizen>
684 public bool RemoveAuxiliaryHint(uint id)
686 bool ret = Interop.Window.RemoveAuxiliaryHint(SwigCPtr, id);
687 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
692 /// Changes a value of the auxiliary hint.
694 /// <param name="id">The auxiliary hint ID.</param>
695 /// <param name="value">The value string to be set.</param>
696 /// <returns>True if no error occurred, false otherwise.</returns>
697 /// <since_tizen> 3 </since_tizen>
698 public bool SetAuxiliaryHintValue(uint id, string value)
700 bool ret = Interop.Window.SetAuxiliaryHintValue(SwigCPtr, id, value);
701 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
706 /// Gets a value of the auxiliary hint.
708 /// <param name="id">The auxiliary hint ID.</param>
709 /// <returns>The string value of the auxiliary hint ID, or an empty string if none exists.</returns>
710 /// <since_tizen> 3 </since_tizen>
711 public string GetAuxiliaryHintValue(uint id)
713 string ret = Interop.Window.GetAuxiliaryHintValue(SwigCPtr, id);
714 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
719 /// Gets an ID of the auxiliary hint string.
721 /// <param name="hint">The auxiliary hint string.</param>
722 /// <returns>The ID of auxiliary hint string, or 0 on failure.</returns>
723 /// <since_tizen> 3 </since_tizen>
724 public uint GetAuxiliaryHintId(string hint)
726 uint ret = Interop.Window.GetAuxiliaryHintId(SwigCPtr, hint);
727 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
732 /// Sets a region to accept input events.
734 /// <param name="inputRegion">The region to accept input events.</param>
735 /// <since_tizen> 3 </since_tizen>
736 public void SetInputRegion(Rectangle inputRegion)
738 Interop.Window.IncludeInputRegion(SwigCPtr, Rectangle.getCPtr(inputRegion));
739 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
743 /// Sets a priority level for the specified notification window.
745 /// <param name="level">The notification window level.</param>
746 /// <returns>True if no error occurred, false otherwise.</returns>
747 /// <since_tizen> 3 </since_tizen>
748 public bool SetNotificationLevel(NotificationLevel level)
750 var ret = (OperationResult)Interop.Window.SetNotificationLevel(SwigCPtr, (int)level);
751 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
752 return ret == OperationResult.Succeed;
756 /// Gets a priority level for the specified notification window.
758 /// <returns>The notification window level.</returns>
759 /// <since_tizen> 3 </since_tizen>
760 public NotificationLevel GetNotificationLevel()
762 NotificationLevel ret = (NotificationLevel)Interop.Window.GetNotificationLevel(SwigCPtr);
763 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
768 /// Sets a transparent window's visual state to opaque. <br />
769 /// If a visual state of a transparent window is opaque, <br />
770 /// then the window manager could handle it as an opaque window when calculating visibility.
772 /// <param name="opaque">Whether the window's visual state is opaque.</param>
773 /// <remarks>This will have no effect on an opaque window. <br />
774 /// It doesn't change transparent window to opaque window but lets the window manager know the visual state of the window.
776 /// <since_tizen> 3 </since_tizen>
777 public void SetOpaqueState(bool opaque)
779 Interop.Window.SetOpaqueState(SwigCPtr, opaque);
780 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
784 /// Returns whether a transparent window's visual state is opaque or not.
786 /// <returns>True if the window's visual state is opaque, false otherwise.</returns>
787 /// <remarks> The return value has no meaning on an opaque window. </remarks>
788 /// <since_tizen> 3 </since_tizen>
789 public bool IsOpaqueState()
791 bool ret = Interop.Window.IsOpaqueState(SwigCPtr);
792 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
797 /// Sets a window's screen off mode.
799 /// <param name="screenOffMode">The screen mode.</param>
800 /// <returns>True if no error occurred, false otherwise.</returns>
801 /// <since_tizen> 4 </since_tizen>
802 public bool SetScreenOffMode(ScreenOffMode screenOffMode)
804 var ret = (OperationResult)Interop.Window.SetScreenOffMode(SwigCPtr, (int)screenOffMode);
805 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
806 return ret == OperationResult.Succeed;
810 /// Gets the screen mode of the window.
812 /// <returns>The screen off mode.</returns>
813 /// <since_tizen> 4 </since_tizen>
814 public ScreenOffMode GetScreenOffMode()
816 ScreenOffMode ret = (ScreenOffMode)Interop.Window.GetScreenOffMode(SwigCPtr);
817 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
822 /// Sets preferred brightness of the window.
824 /// <param name="brightness">The preferred brightness (0 to 100).</param>
825 /// <returns>True if no error occurred, false otherwise.</returns>
826 /// <since_tizen> 3 </since_tizen>
827 public bool SetBrightness(int brightness)
829 var ret = (OperationResult)Interop.Window.SetBrightness(SwigCPtr, brightness);
830 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
831 return ret == OperationResult.Succeed;
835 /// Gets the preferred brightness of the window.
837 /// <returns>The preferred brightness.</returns>
838 /// <since_tizen> 3 </since_tizen>
839 public int GetBrightness()
841 int ret = Interop.Window.GetBrightness(SwigCPtr);
842 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
847 /// Sets the window name and the class string.
849 /// <param name="name">The name of the window.</param>
850 /// <param name="klass">The class of the window.</param>
851 /// <since_tizen> 4 </since_tizen>
852 public void SetClass(string name, string klass)
854 Interop.Window.SetClass(SwigCPtr, name, klass);
855 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
859 /// Raises the window to the top of the window stack.
861 /// <since_tizen> 3 </since_tizen>
864 Interop.Window.Raise(SwigCPtr);
865 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
869 /// Lowers the window to the bottom of the window stack.
871 /// <since_tizen> 3 </since_tizen>
874 Interop.Window.Lower(SwigCPtr);
875 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
879 /// Activates the window to the top of the window stack even it is iconified.
881 /// <since_tizen> 3 </since_tizen>
882 public void Activate()
884 Interop.Window.Activate(SwigCPtr);
885 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
889 /// Gets the default ( root ) layer.
891 /// <returns>The root layer.</returns>
892 /// <since_tizen> 3 </since_tizen>
893 public Layer GetDefaultLayer()
895 return this.GetRootLayer();
899 /// Add a child view to window.
901 /// <param name="view">the child should be added to the window.</param>
902 /// <since_tizen> 3 </since_tizen>
903 public void Add(View view)
905 Interop.Actor.Add(Layer.getCPtr(GetRootLayer()), View.getCPtr(view));
906 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
907 this.GetRootLayer().AddViewToLayerList(view); // Maintain the children list in the Layer
910 view.InternalParent = this.GetRootLayer();
912 this.GetRootLayer().LayoutCount += view.LayoutCount;
917 /// Remove a child view from window.
919 /// <param name="view">the child to be removed.</param>
920 /// <since_tizen> 3 </since_tizen>
921 public void Remove(View view)
923 Interop.Actor.Remove(Layer.getCPtr(GetRootLayer()), View.getCPtr(view));
924 this.GetRootLayer().RemoveViewFromLayerList(view); // Maintain the children list in the Layer
927 view.InternalParent = null;
929 this.GetRootLayer().LayoutCount -= view.LayoutCount;
934 /// Retrieves the layer at a specified depth.
936 /// <param name="depth">The layer's depth index.</param>
937 /// <returns>The layer found at the given depth.</returns>
938 /// <since_tizen> 3 </since_tizen>
939 public Layer GetLayer(uint depth)
941 if (depth < LayersChildren?.Count)
943 Layer ret = LayersChildren?[Convert.ToInt32(depth)];
953 /// Destroy the window immediately.
955 [EditorBrowsable(EditorBrowsableState.Never)]
956 public void Destroy()
962 /// Keep rendering for at least the given amount of time.
964 /// <param name="durationSeconds">Time to keep rendering, 0 means render at least one more frame.</param>
965 /// <since_tizen> 3 </since_tizen>
966 public void KeepRendering(float durationSeconds)
968 Interop.Stage.KeepRendering(stageCPtr, durationSeconds);
969 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
973 /// Grabs the key specified by a key for a window only when a window is the topmost window.<br />
974 /// This function can be used for following example scenarios: <br />
975 /// - Mobile - Using volume up or down as zoom up or down in camera apps.<br />
977 /// <param name="DaliKey">The key code to grab.</param>
978 /// <returns>True if the grab succeeds.</returns>
979 /// <since_tizen> 3 </since_tizen>
980 public bool GrabKeyTopmost(int DaliKey)
982 bool ret = Interop.Window.GrabKeyTopmost(HandleRef.ToIntPtr(this.SwigCPtr), DaliKey);
983 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
988 /// Ungrabs the key specified by a key for the 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 UngrabKeyTopmost(int DaliKey)
996 bool ret = Interop.Window.UngrabKeyTopmost(HandleRef.ToIntPtr(this.SwigCPtr), DaliKey);
997 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1002 /// Grabs the key specified by a key for a window in a GrabMode. <br />
1003 /// Details: This function can be used for following example scenarios: <br />
1004 /// - TV - A user might want to change the volume or channel of the background TV contents while focusing on the foregrund app. <br />
1005 /// - Mobile - When a user presses the Home key, the homescreen appears regardless of the current foreground app. <br />
1006 /// - Mobile - Using the volume up or down as zoom up or down in camera apps. <br />
1008 /// <param name="DaliKey">The key code to grab.</param>
1009 /// <param name="GrabMode">The grab mode for the key.</param>
1010 /// <returns>True if the grab succeeds.</returns>
1011 /// <since_tizen> 3 </since_tizen>
1012 public bool GrabKey(int DaliKey, KeyGrabMode GrabMode)
1014 bool ret = Interop.Window.GrabKey(HandleRef.ToIntPtr(this.SwigCPtr), DaliKey, (int)GrabMode);
1015 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1020 /// Ungrabs the key specified by a key for a window.<br />
1021 /// 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 />
1023 /// <param name="DaliKey">The key code to ungrab.</param>
1024 /// <returns>True if the ungrab succeeds.</returns>
1025 /// <since_tizen> 3 </since_tizen>
1026 public bool UngrabKey(int DaliKey)
1028 bool ret = Interop.Window.UngrabKey(HandleRef.ToIntPtr(this.SwigCPtr), DaliKey);
1029 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1034 /// Sets the keyboard repeat information.
1036 /// <param name="rate">The key repeat rate value in seconds.</param>
1037 /// <param name="delay">The key repeat delay value in seconds.</param>
1038 /// <returns>True if setting the keyboard repeat succeeds.</returns>
1039 /// <since_tizen> 5 </since_tizen>
1040 public bool SetKeyboardRepeatInfo(float rate, float delay)
1042 bool ret = Interop.Window.SetKeyboardRepeatInfo(rate, delay);
1043 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1048 /// Gets the keyboard repeat information.
1050 /// <param name="rate">The key repeat rate value in seconds.</param>
1051 /// <param name="delay">The key repeat delay value in seconds.</param>
1052 /// <returns>True if setting the keyboard repeat succeeds.</returns>
1053 /// <since_tizen> 5 </since_tizen>
1054 public bool GetKeyboardRepeatInfo(out float rate, out float delay)
1056 bool ret = Interop.Window.GetKeyboardRepeatInfo(out rate, out delay);
1057 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1062 /// Adds a layer to the stage.
1064 /// <param name="layer">Layer to add.</param>
1065 /// <exception cref="ArgumentNullException"> Thrown when layer is null. </exception>
1066 /// <since_tizen> 3 </since_tizen>
1067 public void AddLayer(Layer layer)
1073 /// Removes a layer from the stage.
1075 /// <param name="layer">Layer to remove.</param>
1076 /// <exception cref="ArgumentNullException"> Thrown when layer is null. </exception>
1077 /// <since_tizen> 3 </since_tizen>
1078 public void RemoveLayer(Layer layer)
1084 /// Feeds a key event into the window.
1086 /// <param name="keyEvent">The key event to feed.</param>
1087 /// <since_tizen> 5 </since_tizen>
1088 public void FeedKey(Key keyEvent)
1090 Interop.Window.FeedKeyEvent(SwigCPtr, Key.getCPtr(keyEvent));
1091 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1095 /// Feeds a touch point into the window.
1097 /// <param name="touchPoint">The touch point to feed.</param>
1098 /// <param name="timeStamp">The timeStamp.</param>
1099 internal void FeedTouch(TouchPoint touchPoint, int timeStamp)
1101 Interop.Window.FeedTouchPoint(SwigCPtr, TouchPoint.getCPtr(touchPoint), timeStamp);
1102 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1106 /// Feeds a wheel event into the window.
1108 /// <param name="wheelEvent">The wheel event to feed.</param>
1109 internal void FeedWheel(Wheel wheelEvent)
1111 Interop.Window.FeedWheelEvent(SwigCPtr, Wheel.getCPtr(wheelEvent));
1112 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1116 /// Allows at least one more render, even when paused.
1117 /// The window should be shown, not minimised.
1119 /// <since_tizen> 4 </since_tizen>
1120 public void RenderOnce()
1122 Interop.Window.RenderOnce(SwigCPtr);
1123 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1127 /// Sets whether the window is transparent or not.
1129 /// <param name="transparent">Whether the window is transparent or not.</param>
1130 /// <since_tizen> 5 </since_tizen>
1131 public void SetTransparency(bool transparent)
1133 Interop.Window.SetTransparency(SwigCPtr, transparent);
1134 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1136 // Setting transparency of the window should request a relayout of the tree in the case the window changes from fully transparent.
1140 /// Sets parent window of the window.
1141 /// After setting that, these windows do together when raise-up, lower and iconified/deiconified.
1142 /// Initially, the window is located on top of the parent. The window can go below parent by calling Lower().
1143 /// If parent's window stack is changed by calling Raise() or Lower(), child windows are located on top of the parent again.
1145 /// <param name="parent">The parent window.</param>
1146 /// <since_tizen> 6 </since_tizen>
1147 /// <feature> http://tizen.org/feature/opengles.surfaceless_context </feature>
1148 /// <exception cref="NotSupportedException">The required feature is not supported.</exception>
1149 public void SetParent(Window parent)
1151 if (IsSupportedMultiWindow() == false)
1153 NUILog.Error("This device does not support surfaceless_context. So Window cannot be created. ");
1155 Interop.Window.SetParent(SwigCPtr, Window.getCPtr(parent));
1156 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1160 /// Sets parent window of the window.
1161 /// After setting that, these windows do together when raise-up, lower and iconified/deiconified.
1162 /// This function has the additional flag whether the child is located above or below of the parent.
1164 /// <param name="parent">The parent window.</param>
1165 /// <param name="belowParent">The flag is whether the child is located above or below of the parent.</param>
1166 /// <feature> http://tizen.org/feature/opengles.surfaceless_context </feature>
1167 /// <exception cref="NotSupportedException">The required feature is not supported.</exception>
1168 [EditorBrowsable(EditorBrowsableState.Never)]
1169 public void SetParent(Window parent, bool belowParent)
1171 if (IsSupportedMultiWindow() == false)
1173 NUILog.Error("This device does not support surfaceless_context. So Window cannot be created. ");
1175 Interop.Window.SetParentWithStack(SwigCPtr, Window.getCPtr(parent), belowParent);
1176 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1180 /// Unsets parent window of the window.
1181 /// After unsetting, the window is disconnected his parent window.
1183 /// <since_tizen> 6 </since_tizen>
1184 /// <feature> http://tizen.org/feature/opengles.surfaceless_context </feature>
1185 /// <exception cref="NotSupportedException">The required feature is not supported.</exception>
1186 public void Unparent()
1188 if (IsSupportedMultiWindow() == false)
1190 NUILog.Error("Fail to create window. because this device does not support opengles.surfaceless_context.");
1192 Interop.Window.Unparent(SwigCPtr);
1193 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1197 /// Gets parent window of the window.
1199 /// <returns>The parent window of the window.</returns>
1200 /// <since_tizen> 6 </since_tizen>
1201 /// <feature> http://tizen.org/feature/opengles.surfaceless_context </feature>
1202 /// <exception cref="NotSupportedException">The required feature is not supported.</exception>
1203 [System.Diagnostics.CodeAnalysis.SuppressMessage("Design", "CA1721: Property names should not match get methods")]
1204 public Window GetParent()
1206 if (IsSupportedMultiWindow() == false)
1208 NUILog.Error("This device does not support surfaceless_context. So Window cannot be created. ");
1210 Window ret = Registry.GetManagedBaseHandleFromNativePtr(Interop.Window.GetParent(SwigCPtr)) as Window;
1211 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1215 /// This will be public opened in tizen_next after ACR done. Before ACR, need to be hidden as inhouse API.
1216 [EditorBrowsable(EditorBrowsableState.Never)]
1217 public void ObjectDump()
1219 Layer rootLayer = GetRootLayer();
1220 foreach (View view in rootLayer.Children)
1226 internal static bool IsInstalled()
1228 bool ret = Interop.Stage.IsInstalled();
1229 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1234 /// Adds an orientation to the list of available orientations.
1236 /// <param name="orientation">The available orientation to add</param>
1237 /// <since_tizen> 6 </since_tizen>
1238 public void AddAvailableOrientation(Window.WindowOrientation orientation)
1240 Interop.Window.AddAvailableOrientation(SwigCPtr, (int)orientation);
1241 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1245 /// Removes an orientation from the list of available orientations.
1247 /// <param name="orientation">The available orientation to remove.</param>
1248 /// <since_tizen> 6 </since_tizen>
1249 public void RemoveAvailableOrientation(Window.WindowOrientation orientation)
1251 Interop.Window.RemoveAvailableOrientation(SwigCPtr, (int)orientation);
1252 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1256 /// Sets a preferred orientation.
1258 /// <param name="orientation">The preferred orientation.</param>
1259 /// <since_tizen> 6 </since_tizen>
1260 public void SetPreferredOrientation(Window.WindowOrientation orientation)
1262 Interop.Window.SetPreferredOrientation(SwigCPtr, (int)orientation);
1263 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1267 /// Gets the preferred orientation.
1269 /// <since_tizen> 6 </since_tizen>
1270 /// <returns>The preferred orientation if previously set, or none.</returns>
1271 public Window.WindowOrientation GetPreferredOrientation()
1273 Window.WindowOrientation ret = (Window.WindowOrientation)Interop.Window.GetPreferredOrientation(SwigCPtr);
1274 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1279 /// Gets current orientation of the window.
1281 /// <since_tizen> 6 </since_tizen>
1282 /// <returns>The current window orientation if previously set, or none.</returns>
1283 [EditorBrowsable(EditorBrowsableState.Never)]
1284 public Window.WindowOrientation GetCurrentOrientation()
1286 Window.WindowOrientation ret = (Window.WindowOrientation)Interop.Window.GetCurrentOrientation(SwigCPtr);
1287 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1292 /// Sets available orientations of the window.
1293 /// This API is for setting several orientations one time.
1295 /// <param name="orientations">The list of orientations.</param>
1296 /// <since_tizen> 6 </since_tizen>
1297 [EditorBrowsable(EditorBrowsableState.Never)]
1298 public void SetAvailableOrientations(List<Window.WindowOrientation> orientations)
1300 if (null == orientations)
1302 throw new ArgumentNullException(nameof(orientations));
1305 PropertyArray orientationArray = new PropertyArray();
1306 for (int i = 0; i < orientations.Count; i++)
1308 PropertyValue value = new PropertyValue((int)orientations[i]);
1309 orientationArray.PushBack(value);
1313 Interop.Window.SetAvailableOrientations(SwigCPtr, PropertyArray.getCPtr(orientationArray), orientations.Count);
1314 orientationArray.Dispose();
1315 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1319 /// Get native window ID
1321 /// <returns>native window ID</returns>
1322 [EditorBrowsable(EditorBrowsableState.Never)]
1323 public int GetNativeId()
1325 int ret = Interop.Window.GetNativeId(SwigCPtr);
1326 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1330 internal Any GetNativeHandle()
1332 Any ret = new Any(Interop.WindowInternal.WindowGetNativeHandle(SwigCPtr), true);
1333 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1337 internal void Add(Layer layer)
1341 throw new ArgumentNullException(nameof(layer));
1343 Interop.Window.Add(SwigCPtr, Layer.getCPtr(layer));
1344 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1346 LayersChildren?.Add(layer);
1347 layer.SetWindow(this);
1350 internal void Remove(Layer layer)
1354 throw new ArgumentNullException(nameof(layer));
1356 Interop.Window.Remove(SwigCPtr, Layer.getCPtr(layer));
1357 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1359 LayersChildren?.Remove(layer);
1360 layer.SetWindow(null);
1363 internal Vector2 GetSize()
1365 var val = new Uint16Pair(Interop.Window.GetSize(SwigCPtr), true);
1366 Vector2 ret = new Vector2(val.GetWidth(), val.GetHeight());
1367 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1371 /// This will be public opened in next tizen after ACR done. Before ACR, need to be hidden as inhouse API.
1372 [EditorBrowsable(EditorBrowsableState.Never)]
1373 public RenderTaskList GetRenderTaskList()
1375 RenderTaskList ret = new RenderTaskList(Interop.Stage.GetRenderTaskList(stageCPtr), true);
1376 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1381 /// Queries the number of on-window layers.
1383 /// <returns>The number of layers.</returns>
1384 /// <remarks>Note that a default layer is always provided (count >= 1).</remarks>
1385 internal uint GetLayerCount()
1387 if (LayersChildren == null || LayersChildren.Count < 0)
1390 return (uint)LayersChildren.Count;
1393 internal Layer GetRootLayer()
1395 // Window.IsInstalled() is actually true only when called from event thread and
1396 // Core has been initialized, not when Stage is ready.
1397 if (rootLayer == null && Window.IsInstalled())
1399 rootLayer = new Layer(Interop.Window.GetRootLayer(SwigCPtr), true);
1400 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1401 LayersChildren?.Add(rootLayer);
1402 rootLayer.SetWindow(this);
1407 internal void SetBackgroundColor(Vector4 color)
1409 Interop.Window.SetBackgroundColor(SwigCPtr, Vector4.getCPtr(color));
1410 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1413 internal Vector4 GetBackgroundColor()
1415 Vector4 ret = new Vector4(Interop.Window.GetBackgroundColor(SwigCPtr), true);
1416 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1420 internal Vector2 GetDpi()
1422 Vector2 ret = new Vector2(Interop.Stage.GetDpi(stageCPtr), true);
1423 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1427 internal ObjectRegistry GetObjectRegistry()
1429 ObjectRegistry ret = new ObjectRegistry(Interop.Stage.GetObjectRegistry(stageCPtr), true);
1430 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1434 internal void SetRenderingBehavior(RenderingBehaviorType renderingBehavior)
1436 Interop.Stage.SetRenderingBehavior(stageCPtr, (int)renderingBehavior);
1437 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1440 internal RenderingBehaviorType GetRenderingBehavior()
1442 RenderingBehaviorType ret = (RenderingBehaviorType)Interop.Stage.GetRenderingBehavior(stageCPtr);
1443 if (NDalicPINVOKE.SWIGPendingException.Pending)
1444 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1448 internal void SetWindowSize(Size2D size)
1452 throw new ArgumentNullException(nameof(size));
1454 var val = new Uint16Pair((uint)size.Width, (uint)size.Height);
1455 Interop.Window.SetSize(SwigCPtr, Uint16Pair.getCPtr(val));
1457 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1458 // Resetting Window size should request a relayout of the tree.
1461 internal Size2D GetWindowSize()
1463 var val = new Uint16Pair(Interop.Window.GetSize(SwigCPtr), true);
1464 Size2D ret = new Size2D(val.GetWidth(), val.GetHeight());
1465 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1469 internal void SetPosition(Position2D position)
1471 if (null == position)
1473 throw new ArgumentNullException(nameof(position));
1475 var val = new Uint16Pair((uint)position.X, (uint)position.Y);
1476 Interop.Window.SetPosition(SwigCPtr, Uint16Pair.getCPtr(val));
1478 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1479 // Setting Position of the window should request a relayout of the tree.
1482 internal Position2D GetPosition()
1484 var val = new Uint16Pair(Interop.Window.GetPosition(SwigCPtr), true);
1485 Position2D ret = new Position2D(val.GetX(), val.GetY());
1487 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1491 internal void SetPositionSize(Rectangle positionSize)
1493 Interop.Window.SetPositionSize(SwigCPtr, Rectangle.getCPtr(positionSize));
1495 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1497 // Setting Position of the window should request a relayout of the tree.
1501 /// Enables the floating mode of window.
1502 /// The floating mode is to support window is moved or resized by display server.
1503 /// For example, if the video-player window sets the floating mode,
1504 /// then display server changes its geometry and handles it like a popup.
1505 /// The way of handling floating mode window is decided by display server.
1506 /// A special display server(as a Tizen display server) supports this mode.
1508 /// <param name="enable">Enable floating mode or not.</param>
1509 [EditorBrowsable(EditorBrowsableState.Never)]
1510 public void EnableFloatingMode(bool enable)
1512 Interop.Window.EnableFloatingMode(SwigCPtr, enable);
1513 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1517 /// Requests to display server for the window is moved by display server.
1518 /// It can be work with setting window floating mode.
1520 [EditorBrowsable(EditorBrowsableState.Never)]
1521 public void RequestMoveToServer()
1523 Interop.Window.RequestMoveToServer(SwigCPtr);
1524 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1528 /// Requests to display server for the window is resized by display server.
1529 /// It can be work with setting window floating mode.
1531 /// <param name="direction">It is indicated the window's side or edge for starting point.</param>
1532 [EditorBrowsable(EditorBrowsableState.Never)]
1533 public void RequestResizeToServer(ResizeDirection direction)
1535 Interop.Window.RequestResizeToServer(SwigCPtr, (int)direction);
1536 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1540 /// Includes input region.
1541 /// This function inlcudes input regions.
1542 /// It can be used multiple times and supports multiple regions.
1543 /// It means input region will be extended.
1544 /// This input is related to mouse and touch event.
1545 /// If device has touch screen, this function is useful.
1546 /// Otherwise device does not have that, we can use it after connecting mouse to the device.
1548 /// <param name="inputRegion">The included region to accept input events.</param>
1549 [EditorBrowsable(EditorBrowsableState.Never)]
1550 public void IncludeInputRegion(Rectangle inputRegion)
1552 Interop.Window.IncludeInputRegion(SwigCPtr, Rectangle.getCPtr(inputRegion));
1553 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1557 /// This function excludes input regions.
1558 /// It can be used multiple times and supports multiple regions.
1559 /// It means input region will be reduced.
1560 /// Nofice, should be set input area by IncludeInputRegion() before this function is used.
1561 /// This input is related to mouse and touch event.
1562 /// If device has touch screen, this function is useful.
1563 /// Otherwise device does not have that, we can use it after connecting mouse to the device.
1565 /// <param name="inputRegion">The excluded region to except input events.</param>
1566 [EditorBrowsable(EditorBrowsableState.Never)]
1567 public void ExcludeInputRegion(Rectangle inputRegion)
1569 Interop.Window.ExcludeInputRegion(SwigCPtr, Rectangle.getCPtr(inputRegion));
1570 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1574 /// Add FrameUpdateCallback
1576 [EditorBrowsable(EditorBrowsableState.Never)]
1577 public void AddFrameUpdateCallback(FrameUpdateCallbackInterface frameUpdateCallback)
1579 frameUpdateCallback?.AddFrameUpdateCallback(stageCPtr, Layer.getCPtr(GetRootLayer()));
1583 /// Remove FrameUpdateCallback
1585 [EditorBrowsable(EditorBrowsableState.Never)]
1586 public void RemoveFrameUpdateCallback(FrameUpdateCallbackInterface frameUpdateCallback)
1588 frameUpdateCallback?.RemoveFrameUpdateCallback(stageCPtr);
1592 /// Dispose for Window
1594 [EditorBrowsable(EditorBrowsableState.Never)]
1595 protected override void Dispose(DisposeTypes type)
1602 if (type == DisposeTypes.Explicit)
1605 //Release your own managed resources here.
1606 //You should release all of your own disposable objects here.
1608 if (rootLayer != null)
1610 rootLayer.Dispose();
1613 localController?.Dispose();
1615 foreach (var layer in childLayers)
1623 childLayers.Clear();
1626 this.DisconnectNativeSignals();
1631 /// This will not be public opened.
1632 [EditorBrowsable(EditorBrowsableState.Never)]
1633 protected override void ReleaseSwigCPtr(System.Runtime.InteropServices.HandleRef swigCPtr)
1635 Interop.Window.DeleteWindow(swigCPtr);
1638 private static Dictionary<int, internalHookCallbackType> frameCallbackList = new Dictionary<int, internalHookCallbackType>();
1640 private static readonly object locker = new object();
1642 private static int key = 0;
1644 private static FrameCallbackType internalHookFrameCallback = OnInternalHookFrameCallback;
1646 private struct internalHookCallbackType
1648 public FrameCallbackType userCallback;
1652 private static void OnInternalHookFrameCallback(int id)
1656 if (frameCallbackList.ContainsKey(id))
1658 if (frameCallbackList[id].userCallback != null)
1660 frameCallbackList[id].userCallback.Invoke(frameCallbackList[id].frameId);
1661 frameCallbackList.Remove(id);
1665 NUILog.Error($"found userCallback is NULL");
1666 frameCallbackList.Remove(id);
1672 private int AddInterHookCallback(FrameCallbackType callback, int frameId)
1674 if (null == callback)
1676 throw new ArgumentNullException(nameof(callback), "FrameCallbackType should not be null");
1678 var assignedKey = 0;
1683 frameCallbackList.Add(assignedKey, new internalHookCallbackType()
1685 userCallback = callback,
1693 /// Type of callback which is called when the frame rendering is done by graphics driver or when the frame is displayed on display.
1695 /// <param name="frameId">The Id to specify the frame. It will be passed when the callback is called.</param>
1696 [EditorBrowsable(EditorBrowsableState.Never)]
1697 public delegate void FrameCallbackType(int frameId);
1700 /// Adds a callback that is called when the frame rendering is done by the graphics driver.
1701 /// A callback of the following type may be used:
1703 /// void MyFunction( int frameId )
1705 /// This callback will be deleted once it is called.
1707 /// Ownership of the callback is passed onto this class
1710 /// <param name="callback">The function to call</param>
1711 /// <param name="frameId">The Id to specify the frame. It will be passed when the callback is called.</param>
1712 /// <exception cref="ArgumentNullException">This exception can occur by the callback is null.</exception>
1713 [EditorBrowsable(EditorBrowsableState.Never)]
1714 public void AddFrameRenderedCallback(FrameCallbackType callback, int frameId)
1716 var assignedKey = AddInterHookCallback(callback, frameId);
1717 Interop.WindowInternal.AddFrameRenderedCallback(SwigCPtr, new HandleRef(this, Marshal.GetFunctionPointerForDelegate<Delegate>(internalHookFrameCallback)), assignedKey);
1719 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1723 /// Adds a callback that is called when the frame is displayed on the display.
1724 /// A callback of the following type may be used:
1726 /// void MyFunction( int frameId )
1728 /// This callback will be deleted once it is called.
1730 /// Ownership of the callback is passed onto this class
1733 /// <param name="callback">The function to call</param>
1734 /// <param name="frameId">The Id to specify the frame. It will be passed when the callback is called.</param>
1735 /// <exception cref="ArgumentNullException">This exception can occur by the callback is null.</exception>
1736 [EditorBrowsable(EditorBrowsableState.Never)]
1737 public void AddFramePresentedCallback(FrameCallbackType callback, int frameId)
1739 var assignedKey = AddInterHookCallback(callback, frameId);
1740 Interop.WindowInternal.AddFramePresentedCallback(SwigCPtr, new HandleRef(this, Marshal.GetFunctionPointerForDelegate<Delegate>(internalHookFrameCallback)), assignedKey);
1742 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1746 /// Search through this Window for a Layer with the given unique ID.
1748 /// <param name="id">The ID of the Layer to find.</param>
1749 /// <remarks>Hidden-API</remarks>
1750 /// <returns>A handle to the Layer if found, or an empty handle if not.</returns>
1751 [EditorBrowsable(EditorBrowsableState.Never)]
1752 public Layer FindLayerByID(uint id)
1754 Layer defaultLayer = this.GetDefaultLayer();
1755 IntPtr cPtr = Interop.Actor.FindChildById(defaultLayer.SwigCPtr, id);
1756 Layer ret = this.GetInstanceSafely<Layer>(cPtr);
1758 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1763 /// Get Native Window handle.
1765 /// How to get Native Window handle
1767 /// Window window = NUIApplication.GetDefaultWindow();
1768 /// var handle = window.NativeHandle;
1769 /// if(handle.IsInvalid == false)
1771 /// IntPtr nativeHandle = handle.DangerousGetHandle();
1772 /// // do something with nativeHandle
1777 /// <since_tizen> 9 </since_tizen>
1778 public SafeHandle NativeHandle
1782 return new NUI.SafeNativeWindowHandle(this);