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 Layer borderLayer;
40 private string windowTitle;
41 private List<Layer> childLayers = new List<Layer>();
42 private LayoutController localController;
44 static internal bool IsSupportedMultiWindow()
46 bool isSupported = false;
49 Information.TryGetValue("http://tizen.org/feature/opengles.surfaceless_context", out isSupported);
51 catch (DllNotFoundException e)
53 Tizen.Log.Fatal("NUI", $"{e}\n");
57 #if NUI_PROPERTY_CHANGE_DEBUG
58 private bool flag1 = false;
60 internal Window(global::System.IntPtr cPtr, bool cMemoryOwn) : base(cPtr, cMemoryOwn)
62 if (Interop.Stage.IsInstalled())
64 stageCPtr = new global::System.Runtime.InteropServices.HandleRef(this, Interop.Stage.GetCurrent());
66 localController = new LayoutController(this);
67 NUILog.Debug("layoutController id:" + localController.GetId());
69 #if NUI_PROPERTY_CHANGE_DEBUG
70 Tizen.Log.Fatal("NUITEST", $"Window constructor called!");
74 var curTh = global::System.Threading.Thread.CurrentThread.ManagedThreadId;
75 Tizen.Log.Fatal("NUITEST", $"current threadID : {curTh}");
78 this.KeyEvent += TestWindowKeyEventHandler;
79 Tizen.Log.Fatal("NUITEST", $"TestWindowKeyEventHandler() added");
87 #if NUI_PROPERTY_CHANGE_DEBUG
88 private void TestWindowKeyEventHandler(object o, Window.KeyEventArgs e)
90 if(e.Key.State == Key.StateType.Down && e.Key.KeyPressedName == "1")
92 #if NUI_PROPERTY_CHANGE_1
93 Tizen.Log.Fatal("NUITEST", $"### (FIXED) currently used View's properties ###");
95 Tizen.Log.Fatal("NUITEST", $"### currently used View's properties ###");
97 Tizen.Log.Fatal("NUITEST", $"PropertyValueConstructor: {Tizen.NUI.PropertyValue.PropertyValueConstructor}");
98 Tizen.Log.Fatal("NUITEST", $"SizeGetter: {View.SizeGetter}, SizeSetter: {View.SizeSetter}");
99 Tizen.Log.Fatal("NUITEST", $"Size2DGetter: {View.Size2DGetter}, Size2DSetter: {View.Size2DSetter}");
100 Tizen.Log.Fatal("NUITEST", $"SizeWidthGetter: {View.SizeWidthGetter}, SizeWidthSetter: {View.SizeWidthSetter}");
101 Tizen.Log.Fatal("NUITEST", $"SizeHeightGetter: {View.SizeHeightGetter}, SizeHeightSetter: {View.SizeHeightSetter}");
102 Tizen.Log.Fatal("NUITEST", $"PositionGetter: {View.PositionGetter}, PositionSetter: {View.PositionSetter}");
103 Tizen.Log.Fatal("NUITEST", $"Position2DGetter: {View.Position2DGetter}, Position2DSetter: {View.Position2DSetter}");
104 Tizen.Log.Fatal("NUITEST", $"PositionXGetter: {View.PositionXGetter}, PositionXSetter: {View.PositionXSetter}");
105 Tizen.Log.Fatal("NUITEST", $"PositionYGetter: {View.PositionYGetter}, PositionYSetter: {View.PositionYSetter}");
106 Tizen.Log.Fatal("NUITEST", $"PositionZGetter: {View.PositionZGetter}, PositionZSetter: {View.PositionZSetter}");
107 Tizen.Log.Fatal("NUITEST", $"MaximumSizeGetter: {View.MaximumSizeGetter}, MaximumSizeSetter: {View.MaximumSizeSetter}");
108 Tizen.Log.Fatal("NUITEST", $"MinimumSizeGetter: {View.MinimumSizeGetter}, MinimumSizeSetter: {View.MinimumSizeSetter}");
114 /// A helper method to get the current window where the view is added
116 /// <param name="view">The View added to the window</param>
117 /// <returns>A Window.</returns>
118 [EditorBrowsable(EditorBrowsableState.Never)]
119 static public Window Get(View view)
123 NUILog.Error("if there is no view, it can not get a window");
127 //to fix memory leak issue, match the handle count with native side.
128 Window ret = view.GetInstanceSafely<Window>(Interop.Window.Get(View.getCPtr(view)));
129 if (NDalicPINVOKE.SWIGPendingException.Pending)throw NDalicPINVOKE.SWIGPendingException.Retrieve();
134 /// Creates a new Window.<br />
135 /// This creates an extra window in addition to the default main window<br />
137 /// <param name="windowPosition">The position and size of the Window.</param>
138 /// <param name="isTranslucent">Whether Window is translucent.</param>
139 /// <returns>A new Window.</returns>
140 /// <since_tizen> 6 </since_tizen>
141 /// <feature> http://tizen.org/feature/opengles.surfaceless_context </feature>
142 /// <exception cref="NotSupportedException">The required feature is not supported.</exception>
143 public Window(Rectangle windowPosition = null, bool isTranslucent = false) : this(Interop.Window.New(Rectangle.getCPtr(windowPosition), "", isTranslucent), true)
145 if (IsSupportedMultiWindow() == false)
147 NUILog.Error("This device does not support surfaceless_context. So Window cannot be created. ");
149 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
153 /// Creates a new Window with a specific name.<br />
154 /// This creates an extra window in addition to the default main window<br />
156 /// <param name="name">The name for extra window. </param>
157 /// <param name="windowPosition">The position and size of the Window.</param>
158 /// <param name="isTranslucent">Whether Window is translucent.</param>
159 /// <returns>A new Window.</returns>
160 /// <since_tizen> 6 </since_tizen>
161 /// <feature> http://tizen.org/feature/opengles.surfaceless_context </feature>
162 /// <exception cref="NotSupportedException">The required feature is not supported.</exception>
163 public Window(string name, Rectangle windowPosition = null, bool isTranslucent = false) : this(Interop.Window.New(Rectangle.getCPtr(windowPosition), name, isTranslucent), true)
165 if (IsSupportedMultiWindow() == false)
167 NUILog.Error("This device does not support surfaceless_context. So Window cannot be created. ");
169 this.windowTitle = name;
170 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
174 /// Creates a new Window with a specific name.<br />
175 /// This creates an extra window in addition to the default main window<br />
177 /// <param name="name">The name for extra window. </param>
178 /// <param name="borderInterface"><see cref="Tizen.NUI.IBorderInterface"/>If borderInterface is null, defaultBorder is enabled.</param>
179 /// <param name="windowPosition">The position and size of the Window.</param>
180 /// <param name="isTranslucent">Whether Window is translucent.</param>
181 /// <returns>A new Window.</returns>
182 /// <feature> http://tizen.org/feature/opengles.surfaceless_context </feature>
183 /// <exception cref="NotSupportedException">The required feature is not supported.</exception>
184 [EditorBrowsable(EditorBrowsableState.Never)]
185 public Window(string name, IBorderInterface borderInterface, Rectangle windowPosition = null, bool isTranslucent = false) : this(Interop.Window.New(Rectangle.getCPtr(windowPosition), name, isTranslucent), true)
187 if (IsSupportedMultiWindow() == false)
189 NUILog.Error("This device does not support surfaceless_context. So Window cannot be created. ");
191 this.windowTitle = name;
192 this.EnableBorder(borderInterface);
193 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
198 /// Enumeration for orientation of the window is the way in which a rectangular page is oriented for normal viewing.
200 /// <since_tizen> 3 </since_tizen>
201 public enum WindowOrientation
204 /// Portrait orientation. The height of the display area is greater than the width.
206 /// <since_tizen> 3 </since_tizen>
209 /// Landscape orientation. A wide view area is needed.
211 /// <since_tizen> 3 </since_tizen>
214 /// Portrait inverse orientation.
216 /// <since_tizen> 3 </since_tizen>
217 PortraitInverse = 180,
219 /// Landscape inverse orientation.
221 /// <since_tizen> 3 </since_tizen>
222 LandscapeInverse = 270,
224 /// No orientation. It is for the preferred orientation
225 /// Especially, NoOrientationPreference only has the effect for the preferred orientation.
226 /// It is used to unset the preferred orientation with SetPreferredOrientation.
228 [EditorBrowsable(EditorBrowsableState.Never)]
229 NoOrientationPreference = -1
233 /// Enumeration for the key grab mode for platform-level APIs.
235 /// <since_tizen> 3 </since_tizen>
236 public enum KeyGrabMode
239 /// Grabs a key only when on the top of the grabbing-window stack mode.
243 /// Grabs a key together with the other client window(s) mode.
247 /// 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.
251 /// Grabs a key exclusively regardless of the grabbing-window's position on the window stack mode.
257 /// Enumeration for transition effect's state.
259 [Obsolete("Do not use this, that will be removed. Use Window.EffectState instead.")]
260 [EditorBrowsable(EditorBrowsableState.Never)]
261 // This is already deprecated, so suppress warning here.
262 [System.Diagnostics.CodeAnalysis.SuppressMessage("Naming", "CA1717:Only FlagsAttribute enums should have plural names", Justification = "<Pending>")]
263 public enum EffectStates
268 [Obsolete("Do not use this, that will be removed. Use Window.EffectState.None instead.")]
269 [EditorBrowsable(EditorBrowsableState.Never)]
272 /// Transition effect is started.
274 [Obsolete("Do not use this, that will be removed. Use Window.EffectState.Start instead.")]
275 [EditorBrowsable(EditorBrowsableState.Never)]
278 /// Transition effect is ended.
280 [Obsolete("Do not use this, that will be removed. Use Window.EffectState.End instead.")]
281 [EditorBrowsable(EditorBrowsableState.Never)]
286 /// Enumeration for transition effect's state.
288 [EditorBrowsable(EditorBrowsableState.Never)]
289 public enum EffectState
294 [EditorBrowsable(EditorBrowsableState.Never)]
297 /// Transition effect is started.
299 [EditorBrowsable(EditorBrowsableState.Never)]
302 /// Transition effect is ended.
304 [EditorBrowsable(EditorBrowsableState.Never)]
309 /// Enumeration for transition effect's type.
311 [Obsolete("Do not use this, that will be removed. Use Window.EffectType instead.")]
312 [EditorBrowsable(EditorBrowsableState.Never)]
313 // This is already deprecated, so suppress warning here.
314 [System.Diagnostics.CodeAnalysis.SuppressMessage("Naming", "CA1717:Only FlagsAttribute enums should have plural names", Justification = "<Pending>")]
315 public enum EffectTypes
320 [Obsolete("Do not use this, that will be removed. Use Window.EffectType.None instead.")]
321 [EditorBrowsable(EditorBrowsableState.Never)]
324 /// Window show effect.
326 [Obsolete("Do not use this, that will be removed. Use Window.EffectType.Show instead.")]
327 [EditorBrowsable(EditorBrowsableState.Never)]
330 /// Window hide effect.
332 [Obsolete("Do not use this, that will be removed. Use Window.EffectType.Hide instead.")]
333 [EditorBrowsable(EditorBrowsableState.Never)]
338 /// Enumeration for transition effect's type.
340 [EditorBrowsable(EditorBrowsableState.Never)]
341 public enum EffectType
346 [EditorBrowsable(EditorBrowsableState.Never)]
349 /// Window show effect.
351 [EditorBrowsable(EditorBrowsableState.Never)]
354 /// Window hide effect.
356 [EditorBrowsable(EditorBrowsableState.Never)]
361 /// Enumeration for result of window operation.
363 internal enum OperationResult
366 /// Failed for unknown reason
374 /// Permission denied
378 /// The operation is not supported.
384 /// Enumeration for window resized mode by display server.
386 [EditorBrowsable(EditorBrowsableState.Never)]
387 public enum ResizeDirection
392 [EditorBrowsable(EditorBrowsableState.Never)]
395 /// Start resizing window to the top-left edge.
397 [EditorBrowsable(EditorBrowsableState.Never)]
400 /// Start resizing window to the top side.
402 [EditorBrowsable(EditorBrowsableState.Never)]
405 /// Start resizing window to the top-right edge.
407 [EditorBrowsable(EditorBrowsableState.Never)]
410 /// Start resizing window to the left side.
412 [EditorBrowsable(EditorBrowsableState.Never)]
415 /// Start resizing window to the right side.
417 [EditorBrowsable(EditorBrowsableState.Never)]
420 /// Start resizing window to the bottom-left edge.
422 [EditorBrowsable(EditorBrowsableState.Never)]
425 /// Start resizing window to the bottom side.
427 [EditorBrowsable(EditorBrowsableState.Never)]
430 /// Start resizing window to the bottom-right edge.
432 [EditorBrowsable(EditorBrowsableState.Never)]
438 /// The stage instance property (read-only).<br />
439 /// Gets the current window.<br />
441 /// <since_tizen> 3 </since_tizen>
442 public static Window Instance { get; internal set; }
445 /// Gets or sets a window type.
446 /// Most of window type can be set to use WindowType, except for IME type.
447 /// IME type can be set to use one of NUIApplication's constrcutors.
449 /// <since_tizen> 3 </since_tizen>
450 public WindowType Type
454 WindowType ret = (WindowType)Interop.Window.GetType(SwigCPtr);
455 if (NDalicPINVOKE.SWIGPendingException.Pending) throw new InvalidOperationException("FATAL: get Exception", NDalicPINVOKE.SWIGPendingException.Retrieve());
460 Interop.Window.SetType(SwigCPtr, (int)value);
461 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
466 /// Gets/Sets a window title.
468 /// <since_tizen> 4 </since_tizen>
478 SetClass(windowTitle, "");
483 /// The rendering behavior of a Window.
485 /// <since_tizen> 5 </since_tizen>
486 public RenderingBehaviorType RenderingBehavior
490 return GetRenderingBehavior();
494 SetRenderingBehavior(value);
499 /// The window size property (read-only).
501 /// <since_tizen> 3 </since_tizen>
506 Size2D ret = GetSize();
512 /// The background color property.
514 /// <since_tizen> 3 </since_tizen>
515 public Color BackgroundColor
519 SetBackgroundColor(value);
523 Color ret = GetBackgroundColor();
529 /// The DPI property (read-only).<br />
530 /// Retrieves the DPI of the display device to which the Window is connected.<br />
532 /// <since_tizen> 3 </since_tizen>
542 /// The layer count property (read-only).<br />
543 /// Queries the number of on-Window layers.<br />
545 /// <since_tizen> 3 </since_tizen>
546 public uint LayerCount
550 return GetLayerCount();
555 /// Gets or sets a size of the window.
557 /// <exception cref="ArgumentNullException"> Thrown when value is null. </exception>
558 /// <since_tizen> 4 </since_tizen>
559 public Size2D WindowSize
563 return GetWindowSize();
567 SetWindowSize(value);
572 /// Gets or sets a position of the window.
574 /// <exception cref="ArgumentNullException"> Thrown when value is null. </exception>
575 /// <since_tizen> 4 </since_tizen>
576 public Position2D WindowPosition
580 return GetPosition();
589 /// Sets position and size of the window. This API guarantees that
590 /// both moving and resizing of window will appear on the screen at once.
592 [EditorBrowsable(EditorBrowsableState.Never)]
593 public Rectangle WindowPositionSize
597 Position2D position = GetPosition();
598 Size2D size = GetSize();
599 Rectangle ret = new Rectangle(position.X, position.Y, size.Width, size.Height);
605 SetPositionSize(value);
609 internal static Vector4 DEFAULT_BACKGROUND_COLOR
613 global::System.IntPtr cPtr = Interop.Stage.DefaultBackgroundColorGet();
614 Vector4 ret = (cPtr == global::System.IntPtr.Zero) ? null : new Vector4(cPtr, false);
615 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
620 internal static Vector4 DEBUG_BACKGROUND_COLOR
624 global::System.IntPtr cPtr = Interop.Stage.DebugBackgroundColorGet();
625 Vector4 ret = (cPtr == global::System.IntPtr.Zero) ? null : new Vector4(cPtr, false);
626 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
631 internal List<Layer> LayersChildren
640 /// Get the LayoutController for this Window.
642 internal LayoutController LayoutController
646 return localController;
651 /// Feed a key-event into the window.
653 /// <param name="keyEvent">The key event to feed.</param>
654 /// <since_tizen> 4 </since_tizen>
655 [Obsolete("Do not use this, that will be deprecated. Use FeedKey(Key keyEvent) instead.")]
656 public static void FeedKeyEvent(Key keyEvent)
658 Interop.Window.FeedKeyEvent(Key.getCPtr(keyEvent));
659 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
663 /// Sets whether the window accepts a focus or not.
665 /// <param name="accept">If a focus is accepted or not. The default is true.</param>
666 /// <since_tizen> 3 </since_tizen>
667 public void SetAcceptFocus(bool accept)
669 Interop.Window.SetAcceptFocus(SwigCPtr, accept);
670 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
674 /// Returns whether the window accepts a focus or not.
676 /// <returns>True if the window accepts a focus, false otherwise.</returns>
677 /// <since_tizen> 3 </since_tizen>
678 public bool IsFocusAcceptable()
680 bool ret = Interop.Window.IsFocusAcceptable(SwigCPtr);
681 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
687 /// Shows the window if it is hidden.
689 /// <since_tizen> 3 </since_tizen>
692 Interop.Window.Show(SwigCPtr);
693 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
697 /// Hides the window if it is showing.
699 /// <since_tizen> 3 </since_tizen>
702 Interop.Window.Hide(SwigCPtr);
703 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
707 /// Retrieves whether the window is visible or not.
709 /// <returns>True if the window is visible.</returns>
710 /// <since_tizen> 3 </since_tizen>
711 public bool IsVisible()
713 bool temp = Interop.Window.IsVisible(SwigCPtr);
714 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
719 /// Gets the count of supported auxiliary hints of the window.
721 /// <returns>The number of supported auxiliary hints.</returns>
722 /// <since_tizen> 3 </since_tizen>
723 public uint GetSupportedAuxiliaryHintCount()
725 uint ret = Interop.Window.GetSupportedAuxiliaryHintCount(SwigCPtr);
726 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
731 /// Gets the supported auxiliary hint string of the window.
733 /// <param name="index">The index of the supported auxiliary hint lists.</param>
734 /// <returns>The auxiliary hint string of the index.</returns>
735 /// <since_tizen> 3 </since_tizen>
736 public string GetSupportedAuxiliaryHint(uint index)
738 string ret = Interop.Window.GetSupportedAuxiliaryHint(SwigCPtr, index);
739 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
744 /// Creates an auxiliary hint of the window.
746 /// <param name="hint">The auxiliary hint string.</param>
747 /// <param name="value">The value string.</param>
748 /// <returns>The ID of created auxiliary hint, or 0 on failure.</returns>
749 /// <since_tizen> 3 </since_tizen>
750 public uint AddAuxiliaryHint(string hint, string value)
752 uint ret = Interop.Window.AddAuxiliaryHint(SwigCPtr, hint, value);
753 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
758 /// Removes an auxiliary hint of the window.
760 /// <param name="id">The ID of the auxiliary hint.</param>
761 /// <returns>True if no error occurred, false otherwise.</returns>
762 /// <since_tizen> 3 </since_tizen>
763 public bool RemoveAuxiliaryHint(uint id)
765 bool ret = Interop.Window.RemoveAuxiliaryHint(SwigCPtr, id);
766 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
771 /// Changes a value of the auxiliary hint.
773 /// <param name="id">The auxiliary hint ID.</param>
774 /// <param name="value">The value string to be set.</param>
775 /// <returns>True if no error occurred, false otherwise.</returns>
776 /// <since_tizen> 3 </since_tizen>
777 public bool SetAuxiliaryHintValue(uint id, string value)
779 bool ret = Interop.Window.SetAuxiliaryHintValue(SwigCPtr, id, value);
780 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
785 /// Gets a value of the auxiliary hint.
787 /// <param name="id">The auxiliary hint ID.</param>
788 /// <returns>The string value of the auxiliary hint ID, or an empty string if none exists.</returns>
789 /// <since_tizen> 3 </since_tizen>
790 public string GetAuxiliaryHintValue(uint id)
792 string ret = Interop.Window.GetAuxiliaryHintValue(SwigCPtr, id);
793 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
798 /// Gets an ID of the auxiliary hint string.
800 /// <param name="hint">The auxiliary hint string.</param>
801 /// <returns>The ID of auxiliary hint string, or 0 on failure.</returns>
802 /// <since_tizen> 3 </since_tizen>
803 public uint GetAuxiliaryHintId(string hint)
805 uint ret = Interop.Window.GetAuxiliaryHintId(SwigCPtr, hint);
806 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
811 /// Sets a region to accept input events.
813 /// <param name="inputRegion">The region to accept input events.</param>
814 /// <since_tizen> 3 </since_tizen>
815 public void SetInputRegion(Rectangle inputRegion)
817 Interop.Window.IncludeInputRegion(SwigCPtr, Rectangle.getCPtr(inputRegion));
818 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
822 /// Sets a priority level for the specified notification window.
824 /// <param name="level">The notification window level.</param>
825 /// <returns>True if no error occurred, false otherwise.</returns>
826 /// <since_tizen> 3 </since_tizen>
827 public bool SetNotificationLevel(NotificationLevel level)
829 var ret = (OperationResult)Interop.Window.SetNotificationLevel(SwigCPtr, (int)level);
830 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
831 return ret == OperationResult.Succeed;
835 /// Gets a priority level for the specified notification window.
837 /// <returns>The notification window level.</returns>
838 /// <since_tizen> 3 </since_tizen>
839 public NotificationLevel GetNotificationLevel()
841 NotificationLevel ret = (NotificationLevel)Interop.Window.GetNotificationLevel(SwigCPtr);
842 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
847 /// Sets a transparent window's visual state to opaque. <br />
848 /// If a visual state of a transparent window is opaque, <br />
849 /// then the window manager could handle it as an opaque window when calculating visibility.
851 /// <param name="opaque">Whether the window's visual state is opaque.</param>
852 /// <remarks>This will have no effect on an opaque window. <br />
853 /// It doesn't change transparent window to opaque window but lets the window manager know the visual state of the window.
855 /// <since_tizen> 3 </since_tizen>
856 public void SetOpaqueState(bool opaque)
858 Interop.Window.SetOpaqueState(SwigCPtr, opaque);
859 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
863 /// Returns whether a transparent window's visual state is opaque or not.
865 /// <returns>True if the window's visual state is opaque, false otherwise.</returns>
866 /// <remarks> The return value has no meaning on an opaque window. </remarks>
867 /// <since_tizen> 3 </since_tizen>
868 public bool IsOpaqueState()
870 bool ret = Interop.Window.IsOpaqueState(SwigCPtr);
871 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
876 /// Sets a window's screen off mode.
878 /// <param name="screenOffMode">The screen mode.</param>
879 /// <returns>True if no error occurred, false otherwise.</returns>
880 /// <since_tizen> 4 </since_tizen>
881 public bool SetScreenOffMode(ScreenOffMode screenOffMode)
883 var ret = (OperationResult)Interop.Window.SetScreenOffMode(SwigCPtr, (int)screenOffMode);
884 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
885 return ret == OperationResult.Succeed;
889 /// Gets the screen mode of the window.
891 /// <returns>The screen off mode.</returns>
892 /// <since_tizen> 4 </since_tizen>
893 public ScreenOffMode GetScreenOffMode()
895 ScreenOffMode ret = (ScreenOffMode)Interop.Window.GetScreenOffMode(SwigCPtr);
896 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
901 /// Sets preferred brightness of the window.
903 /// <param name="brightness">The preferred brightness (0 to 100).</param>
904 /// <returns>True if no error occurred, false otherwise.</returns>
905 /// <since_tizen> 3 </since_tizen>
906 public bool SetBrightness(int brightness)
908 var ret = (OperationResult)Interop.Window.SetBrightness(SwigCPtr, brightness);
909 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
910 return ret == OperationResult.Succeed;
914 /// Gets the preferred brightness of the window.
916 /// <returns>The preferred brightness.</returns>
917 /// <since_tizen> 3 </since_tizen>
918 public int GetBrightness()
920 int ret = Interop.Window.GetBrightness(SwigCPtr);
921 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
926 /// Sets the window name and the class string.
928 /// <param name="name">The name of the window.</param>
929 /// <param name="klass">The class of the window.</param>
930 /// <since_tizen> 4 </since_tizen>
931 public void SetClass(string name, string klass)
933 Interop.Window.SetClass(SwigCPtr, name, klass);
934 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
938 /// Raises the window to the top of the window stack.
940 /// <since_tizen> 3 </since_tizen>
943 Interop.Window.Raise(SwigCPtr);
944 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
948 /// Lowers the window to the bottom of the window stack.
950 /// <since_tizen> 3 </since_tizen>
953 Interop.Window.Lower(SwigCPtr);
954 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
958 /// Activates the window to the top of the window stack even it is iconified.
960 /// <since_tizen> 3 </since_tizen>
961 public void Activate()
963 Interop.Window.Activate(SwigCPtr);
964 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
968 /// Gets the default ( root ) layer.
970 /// <returns>The root layer.</returns>
971 /// <since_tizen> 3 </since_tizen>
972 public Layer GetDefaultLayer()
974 return this.GetRootLayer();
978 /// Add a child view to window.
980 /// <param name="view">the child should be added to the window.</param>
981 /// <since_tizen> 3 </since_tizen>
982 public void Add(View view)
984 this.GetRootLayer().Add(view);
988 /// Remove a child view from window.
990 /// <param name="view">the child to be removed.</param>
991 /// <since_tizen> 3 </since_tizen>
992 public void Remove(View view)
994 this.GetRootLayer().Remove(view);
998 /// Retrieves the layer at a specified depth.
1000 /// <param name="depth">The layer's depth index.</param>
1001 /// <returns>The layer found at the given depth.</returns>
1002 /// <since_tizen> 3 </since_tizen>
1003 public Layer GetLayer(uint depth)
1005 if (depth < LayersChildren?.Count)
1007 Layer ret = LayersChildren?[Convert.ToInt32(depth)];
1017 /// Destroy the window immediately.
1019 [EditorBrowsable(EditorBrowsableState.Never)]
1020 public void Destroy()
1026 /// Keep rendering for at least the given amount of time.
1028 /// <param name="durationSeconds">Time to keep rendering, 0 means render at least one more frame.</param>
1029 /// <since_tizen> 3 </since_tizen>
1030 public void KeepRendering(float durationSeconds)
1032 Interop.Stage.KeepRendering(stageCPtr, durationSeconds);
1033 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1037 /// Grabs the key specified by a key for a window only when a window is the topmost window.<br />
1038 /// This function can be used for following example scenarios: <br />
1039 /// - Mobile - Using volume up or down as zoom up or down in camera apps.<br />
1041 /// <param name="DaliKey">The key code to grab.</param>
1042 /// <returns>True if the grab succeeds.</returns>
1043 /// <since_tizen> 3 </since_tizen>
1044 public bool GrabKeyTopmost(int DaliKey)
1046 bool ret = Interop.Window.GrabKeyTopmost(HandleRef.ToIntPtr(this.SwigCPtr), DaliKey);
1047 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1052 /// Ungrabs the key specified by a key for the window.<br />
1053 /// 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 />
1055 /// <param name="DaliKey">The key code to ungrab.</param>
1056 /// <returns>True if the ungrab succeeds.</returns>
1057 /// <since_tizen> 3 </since_tizen>
1058 public bool UngrabKeyTopmost(int DaliKey)
1060 bool ret = Interop.Window.UngrabKeyTopmost(HandleRef.ToIntPtr(this.SwigCPtr), DaliKey);
1061 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1066 /// Grabs the key specified by a key for a window in a GrabMode. <br />
1067 /// Details: This function can be used for following example scenarios: <br />
1068 /// - TV - A user might want to change the volume or channel of the background TV contents while focusing on the foregrund app. <br />
1069 /// - Mobile - When a user presses the Home key, the homescreen appears regardless of the current foreground app. <br />
1070 /// - Mobile - Using the volume up or down as zoom up or down in camera apps. <br />
1072 /// <param name="DaliKey">The key code to grab.</param>
1073 /// <param name="GrabMode">The grab mode for the key.</param>
1074 /// <returns>True if the grab succeeds.</returns>
1075 /// <since_tizen> 3 </since_tizen>
1076 public bool GrabKey(int DaliKey, KeyGrabMode GrabMode)
1078 bool ret = Interop.Window.GrabKey(HandleRef.ToIntPtr(this.SwigCPtr), DaliKey, (int)GrabMode);
1079 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1084 /// Ungrabs the key specified by a key for a window.<br />
1085 /// 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 />
1087 /// <param name="DaliKey">The key code to ungrab.</param>
1088 /// <returns>True if the ungrab succeeds.</returns>
1089 /// <since_tizen> 3 </since_tizen>
1090 public bool UngrabKey(int DaliKey)
1092 bool ret = Interop.Window.UngrabKey(HandleRef.ToIntPtr(this.SwigCPtr), DaliKey);
1093 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1098 /// Sets the keyboard repeat information.
1100 /// <param name="rate">The key repeat rate value in seconds.</param>
1101 /// <param name="delay">The key repeat delay value in seconds.</param>
1102 /// <returns>True if setting the keyboard repeat succeeds.</returns>
1103 /// <since_tizen> 5 </since_tizen>
1104 public bool SetKeyboardRepeatInfo(float rate, float delay)
1106 bool ret = Interop.Window.SetKeyboardRepeatInfo(rate, delay);
1107 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1112 /// Gets the keyboard repeat information.
1114 /// <param name="rate">The key repeat rate value in seconds.</param>
1115 /// <param name="delay">The key repeat delay value in seconds.</param>
1116 /// <returns>True if setting the keyboard repeat succeeds.</returns>
1117 /// <since_tizen> 5 </since_tizen>
1118 public bool GetKeyboardRepeatInfo(out float rate, out float delay)
1120 bool ret = Interop.Window.GetKeyboardRepeatInfo(out rate, out delay);
1121 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1126 /// Adds a layer to the stage.
1128 /// <param name="layer">Layer to add.</param>
1129 /// <exception cref="ArgumentNullException"> Thrown when layer is null. </exception>
1130 /// <since_tizen> 3 </since_tizen>
1131 public void AddLayer(Layer layer)
1137 /// Removes a layer from the stage.
1139 /// <param name="layer">Layer to remove.</param>
1140 /// <exception cref="ArgumentNullException"> Thrown when layer is null. </exception>
1141 /// <since_tizen> 3 </since_tizen>
1142 public void RemoveLayer(Layer layer)
1148 /// Feeds a key event into the window.
1150 /// <param name="keyEvent">The key event to feed.</param>
1151 /// <since_tizen> 5 </since_tizen>
1152 public void FeedKey(Key keyEvent)
1154 Interop.Window.FeedKeyEvent(SwigCPtr, Key.getCPtr(keyEvent));
1155 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1159 /// Feeds a touch point into the window.
1161 /// <param name="touchPoint">The touch point to feed.</param>
1162 /// <param name="timeStamp">The timeStamp.</param>
1163 internal void FeedTouch(TouchPoint touchPoint, int timeStamp)
1165 Interop.Window.FeedTouchPoint(SwigCPtr, TouchPoint.getCPtr(touchPoint), timeStamp);
1166 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1170 /// Feeds a wheel event into the window.
1172 /// <param name="wheelEvent">The wheel event to feed.</param>
1173 internal void FeedWheel(Wheel wheelEvent)
1175 Interop.Window.FeedWheelEvent(SwigCPtr, Wheel.getCPtr(wheelEvent));
1176 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1180 /// Allows at least one more render, even when paused.
1181 /// The window should be shown, not minimised.
1183 /// <since_tizen> 4 </since_tizen>
1184 public void RenderOnce()
1186 Interop.Window.RenderOnce(SwigCPtr);
1187 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1191 /// Sets whether the window is transparent or not.
1193 /// <param name="transparent">Whether the window is transparent or not.</param>
1194 /// <since_tizen> 5 </since_tizen>
1195 public void SetTransparency(bool transparent)
1197 Interop.Window.SetTransparency(SwigCPtr, transparent);
1198 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1200 // Setting transparency of the window should request a relayout of the tree in the case the window changes from fully transparent.
1204 /// Sets parent window of the window.
1205 /// After setting that, these windows do together when raise-up, lower and iconified/deiconified.
1206 /// Initially, the window is located on top of the parent. The window can go below parent by calling Lower().
1207 /// If parent's window stack is changed by calling Raise() or Lower(), child windows are located on top of the parent again.
1209 /// <param name="parent">The parent window.</param>
1210 /// <since_tizen> 6 </since_tizen>
1211 /// <feature> http://tizen.org/feature/opengles.surfaceless_context </feature>
1212 /// <exception cref="NotSupportedException">The required feature is not supported.</exception>
1213 public void SetParent(Window parent)
1215 if (IsSupportedMultiWindow() == false)
1217 NUILog.Error("This device does not support surfaceless_context. So Window cannot be created. ");
1219 Interop.Window.SetParent(SwigCPtr, Window.getCPtr(parent));
1220 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1224 /// Sets parent window of the window.
1225 /// After setting that, these windows do together when raise-up, lower and iconified/deiconified.
1226 /// This function has the additional flag whether the child is located above or below of the parent.
1228 /// <param name="parent">The parent window.</param>
1229 /// <param name="belowParent">The flag is whether the child is located above or below of the parent.</param>
1230 /// <feature> http://tizen.org/feature/opengles.surfaceless_context </feature>
1231 /// <exception cref="NotSupportedException">The required feature is not supported.</exception>
1232 [EditorBrowsable(EditorBrowsableState.Never)]
1233 public void SetParent(Window parent, bool belowParent)
1235 if (IsSupportedMultiWindow() == false)
1237 NUILog.Error("This device does not support surfaceless_context. So Window cannot be created. ");
1239 Interop.Window.SetParentWithStack(SwigCPtr, Window.getCPtr(parent), belowParent);
1240 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1244 /// Unsets parent window of the window.
1245 /// After unsetting, the window is disconnected his parent window.
1247 /// <since_tizen> 6 </since_tizen>
1248 /// <feature> http://tizen.org/feature/opengles.surfaceless_context </feature>
1249 /// <exception cref="NotSupportedException">The required feature is not supported.</exception>
1250 public void Unparent()
1252 if (IsSupportedMultiWindow() == false)
1254 NUILog.Error("Fail to create window. because this device does not support opengles.surfaceless_context.");
1256 Interop.Window.Unparent(SwigCPtr);
1257 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1261 /// Gets parent window of the window.
1263 /// <returns>The parent window of the window.</returns>
1264 /// <since_tizen> 6 </since_tizen>
1265 /// <feature> http://tizen.org/feature/opengles.surfaceless_context </feature>
1266 /// <exception cref="NotSupportedException">The required feature is not supported.</exception>
1267 [System.Diagnostics.CodeAnalysis.SuppressMessage("Design", "CA1721: Property names should not match get methods")]
1268 public Window GetParent()
1270 if (IsSupportedMultiWindow() == false)
1272 NUILog.Error("This device does not support surfaceless_context. So Window cannot be created. ");
1274 Window ret = this.GetInstanceSafely<Window>(Interop.Window.GetParent(SwigCPtr));
1275 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1279 /// This will be public opened in tizen_next after ACR done. Before ACR, need to be hidden as inhouse API.
1280 [EditorBrowsable(EditorBrowsableState.Never)]
1281 public void ObjectDump()
1283 Layer rootLayer = GetRootLayer();
1284 foreach (View view in rootLayer.Children)
1290 internal static bool IsInstalled()
1292 bool ret = Interop.Stage.IsInstalled();
1293 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1298 /// Adds an orientation to the list of available orientations.
1300 /// <param name="orientation">The available orientation to add</param>
1301 /// <since_tizen> 6 </since_tizen>
1302 public void AddAvailableOrientation(Window.WindowOrientation orientation)
1304 Interop.Window.AddAvailableOrientation(SwigCPtr, (int)orientation);
1305 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1309 /// Removes an orientation from the list of available orientations.
1311 /// <param name="orientation">The available orientation to remove.</param>
1312 /// <since_tizen> 6 </since_tizen>
1313 public void RemoveAvailableOrientation(Window.WindowOrientation orientation)
1315 Interop.Window.RemoveAvailableOrientation(SwigCPtr, (int)orientation);
1316 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1320 /// Sets a preferred orientation.
1322 /// <param name="orientation">The preferred orientation.</param>
1323 /// <since_tizen> 6 </since_tizen>
1324 public void SetPreferredOrientation(Window.WindowOrientation orientation)
1326 Interop.Window.SetPreferredOrientation(SwigCPtr, (int)orientation);
1327 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1331 /// Gets the preferred orientation.
1333 /// <since_tizen> 6 </since_tizen>
1334 /// <returns>The preferred orientation if previously set, or none.</returns>
1335 public Window.WindowOrientation GetPreferredOrientation()
1337 Window.WindowOrientation ret = (Window.WindowOrientation)Interop.Window.GetPreferredOrientation(SwigCPtr);
1338 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1343 /// Gets current orientation of the window.
1345 /// <since_tizen> 6 </since_tizen>
1346 /// <returns>The current window orientation if previously set, or none.</returns>
1347 [EditorBrowsable(EditorBrowsableState.Never)]
1348 public Window.WindowOrientation GetCurrentOrientation()
1350 Window.WindowOrientation ret = (Window.WindowOrientation)Interop.Window.GetCurrentOrientation(SwigCPtr);
1351 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1356 /// Sets available orientations of the window.
1357 /// This API is for setting several orientations one time.
1359 /// <param name="orientations">The list of orientations.</param>
1360 /// <since_tizen> 6 </since_tizen>
1361 [EditorBrowsable(EditorBrowsableState.Never)]
1362 public void SetAvailableOrientations(List<Window.WindowOrientation> orientations)
1364 if (null == orientations)
1366 throw new ArgumentNullException(nameof(orientations));
1369 PropertyArray orientationArray = new PropertyArray();
1370 for (int i = 0; i < orientations.Count; i++)
1372 PropertyValue value = new PropertyValue((int)orientations[i]);
1373 orientationArray.PushBack(value);
1377 Interop.Window.SetAvailableOrientations(SwigCPtr, PropertyArray.getCPtr(orientationArray), orientations.Count);
1378 orientationArray.Dispose();
1379 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1383 /// Get native window ID
1385 /// <returns>native window ID</returns>
1386 [EditorBrowsable(EditorBrowsableState.Never)]
1387 public int GetNativeId()
1389 int ret = Interop.Window.GetNativeId(SwigCPtr);
1390 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1394 internal Any GetNativeHandle()
1396 Any ret = new Any(Interop.WindowInternal.WindowGetNativeHandle(SwigCPtr), true);
1397 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1401 internal void Add(Layer layer)
1405 throw new ArgumentNullException(nameof(layer));
1410 Interop.Actor.Add(GetBorderWindowRootLayer().SwigCPtr, layer.SwigCPtr);
1411 if (NDalicPINVOKE.SWIGPendingException.Pending) { throw NDalicPINVOKE.SWIGPendingException.Retrieve(); }
1415 Interop.Window.Add(SwigCPtr, Layer.getCPtr(layer));
1416 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1419 LayersChildren?.Add(layer);
1420 layer.SetWindow(this);
1423 internal void Remove(Layer layer)
1427 throw new ArgumentNullException(nameof(layer));
1429 Interop.Window.Remove(SwigCPtr, Layer.getCPtr(layer));
1430 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1432 LayersChildren?.Remove(layer);
1433 layer.SetWindow(null);
1436 internal Vector2 GetSize()
1438 var val = new Uint16Pair(Interop.Window.GetSize(SwigCPtr), true);
1440 convertRealWindowSizeToBorderWindowSize(val);
1442 Vector2 ret = new Vector2(val.GetWidth(), val.GetHeight());
1443 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1448 /// This will be public opened in next tizen after ACR done. Before ACR, need to be hidden as inhouse API.
1449 [EditorBrowsable(EditorBrowsableState.Never)]
1450 public RenderTaskList GetRenderTaskList()
1452 RenderTaskList ret = new RenderTaskList(Interop.Stage.GetRenderTaskList(stageCPtr), true);
1453 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1458 /// Queries the number of on-window layers.
1460 /// <returns>The number of layers.</returns>
1461 /// <remarks>Note that a default layer is always provided (count >= 1).</remarks>
1462 internal uint GetLayerCount()
1464 if (LayersChildren == null || LayersChildren.Count < 0)
1467 return (uint)LayersChildren.Count;
1470 internal Layer GetRootLayer()
1474 if(borderLayer == null)
1476 borderLayer = GetBorderWindowRootLayer();
1477 LayersChildren?.Add(borderLayer);
1478 borderLayer.SetWindow(this);
1484 // Window.IsInstalled() is actually true only when called from event thread and
1485 // Core has been initialized, not when Stage is ready.
1486 if (rootLayer == null && Window.IsInstalled())
1488 rootLayer = new Layer(Interop.Window.GetRootLayer(SwigCPtr), true);
1489 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1490 LayersChildren?.Add(rootLayer);
1491 rootLayer.SetWindow(this);
1497 internal void SetBackgroundColor(Vector4 color)
1499 Interop.Window.SetBackgroundColor(SwigCPtr, Vector4.getCPtr(color));
1500 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1503 internal Vector4 GetBackgroundColor()
1505 Vector4 ret = new Vector4(Interop.Window.GetBackgroundColor(SwigCPtr), true);
1506 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1510 internal Vector2 GetDpi()
1512 Vector2 ret = new Vector2(Interop.Stage.GetDpi(stageCPtr), true);
1513 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1517 internal ObjectRegistry GetObjectRegistry()
1519 ObjectRegistry ret = new ObjectRegistry(Interop.Stage.GetObjectRegistry(stageCPtr), true);
1520 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1524 internal void SetRenderingBehavior(RenderingBehaviorType renderingBehavior)
1526 Interop.Stage.SetRenderingBehavior(stageCPtr, (int)renderingBehavior);
1527 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1530 internal RenderingBehaviorType GetRenderingBehavior()
1532 RenderingBehaviorType ret = (RenderingBehaviorType)Interop.Stage.GetRenderingBehavior(stageCPtr);
1533 if (NDalicPINVOKE.SWIGPendingException.Pending)
1534 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1538 internal void SetWindowSize(Size2D size)
1542 throw new ArgumentNullException(nameof(size));
1544 var val = new Uint16Pair((uint)size.Width, (uint)size.Height);
1546 convertBorderWindowSizeToRealWindowSize(val);
1548 Interop.Window.SetSize(SwigCPtr, Uint16Pair.getCPtr(val));
1550 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1551 // Resetting Window size should request a relayout of the tree.
1554 internal Size2D GetWindowSize()
1556 var val = new Uint16Pair(Interop.Window.GetSize(SwigCPtr), true);
1558 convertRealWindowSizeToBorderWindowSize(val);
1560 Size2D ret = new Size2D(val.GetWidth(), val.GetHeight());
1561 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1566 internal void SetPosition(Position2D position)
1568 if (null == position)
1570 throw new ArgumentNullException(nameof(position));
1572 var val = new IntPair(position.X, position.Y);
1573 Interop.Window.SetPosition(SwigCPtr, IntPair.getCPtr(val));
1575 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1576 // Setting Position of the window should request a relayout of the tree.
1579 internal Position2D GetPosition()
1581 var val = new IntPair(Interop.Window.GetPosition(SwigCPtr), true);
1582 Position2D ret = new Position2D((int)val.GetX(), (int)val.GetY());
1584 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1588 internal void SetPositionSize(Rectangle positionSize)
1590 if (positionSize == null)
1592 throw new ArgumentNullException(nameof(positionSize));
1594 var val = new Uint16Pair((uint)positionSize.Width, (uint)positionSize.Height);
1596 convertBorderWindowSizeToRealWindowSize(val);
1598 positionSize.Width = val.GetX();
1599 positionSize.Height = val.GetY();
1601 Interop.Window.SetPositionSize(SwigCPtr, Rectangle.getCPtr(positionSize));
1604 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1606 // Setting Position of the window should request a relayout of the tree.
1610 /// Enables the floating mode of window.
1611 /// The floating mode is to support window is moved or resized by display server.
1612 /// For example, if the video-player window sets the floating mode,
1613 /// then display server changes its geometry and handles it like a popup.
1614 /// The way of handling floating mode window is decided by display server.
1615 /// A special display server(as a Tizen display server) supports this mode.
1617 /// <param name="enable">Enable floating mode or not.</param>
1618 [EditorBrowsable(EditorBrowsableState.Never)]
1619 public void EnableFloatingMode(bool enable)
1621 Interop.Window.EnableFloatingMode(SwigCPtr, enable);
1622 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1626 /// Requests to display server for the window is moved by display server.
1627 /// It can be work with setting window floating mode.
1629 [EditorBrowsable(EditorBrowsableState.Never)]
1630 public void RequestMoveToServer()
1632 Interop.Window.RequestMoveToServer(SwigCPtr);
1633 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1637 /// Requests to display server for the window is resized by display server.
1638 /// It can be work with setting window floating mode.
1640 /// <param name="direction">It is indicated the window's side or edge for starting point.</param>
1641 [EditorBrowsable(EditorBrowsableState.Never)]
1642 public void RequestResizeToServer(ResizeDirection direction)
1644 Interop.Window.RequestResizeToServer(SwigCPtr, (int)direction);
1645 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1649 /// Includes input region.
1650 /// This function inlcudes input regions.
1651 /// It can be used multiple times and supports multiple regions.
1652 /// It means input region will be extended.
1653 /// This input is related to mouse and touch event.
1654 /// If device has touch screen, this function is useful.
1655 /// Otherwise device does not have that, we can use it after connecting mouse to the device.
1657 /// <param name="inputRegion">The included region to accept input events.</param>
1658 [EditorBrowsable(EditorBrowsableState.Never)]
1659 public void IncludeInputRegion(Rectangle inputRegion)
1661 Interop.Window.IncludeInputRegion(SwigCPtr, Rectangle.getCPtr(inputRegion));
1662 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1666 /// This function excludes input regions.
1667 /// It can be used multiple times and supports multiple regions.
1668 /// It means input region will be reduced.
1669 /// Nofice, should be set input area by IncludeInputRegion() before this function is used.
1670 /// This input is related to mouse and touch event.
1671 /// If device has touch screen, this function is useful.
1672 /// Otherwise device does not have that, we can use it after connecting mouse to the device.
1674 /// <param name="inputRegion">The excluded region to except input events.</param>
1675 [EditorBrowsable(EditorBrowsableState.Never)]
1676 public void ExcludeInputRegion(Rectangle inputRegion)
1678 Interop.Window.ExcludeInputRegion(SwigCPtr, Rectangle.getCPtr(inputRegion));
1679 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1683 /// Maximizes window's size.
1684 /// If this function is called with true, window will be resized with screen size.
1685 /// Otherwise window will be resized with previous size.
1686 /// It is for the window's MAX button in window's border.
1687 /// If window border is supported by display server, it is not necessary.
1689 /// <param name="max">If window is maximized or unmaximized.</param>
1690 [EditorBrowsable(EditorBrowsableState.Never)]
1691 public void Maximize(bool max)
1693 Interop.Window.Maximize(SwigCPtr, max);
1694 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1698 /// Returns whether the window is maximized or not.
1700 /// <returns>True if the window is maximized, false otherwise.</returns>
1701 [EditorBrowsable(EditorBrowsableState.Never)]
1702 public bool IsMaximized()
1704 bool ret = Interop.Window.IsMaximized(SwigCPtr);
1705 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1710 /// Sets window's maximum size.
1712 /// It is to set the maximized size when window is maximized or the window's size is increased by RequestResizeToServer().
1713 /// Although the size is set by this function, window's size can be increased over the limitation by SetPositionSize() or SetSize().
1715 /// After setting, if Maximize() is called, window is resized with the setting size and move the center.
1718 /// <param name="size">the maximum size.</param>
1719 [EditorBrowsable(EditorBrowsableState.Never)]
1720 public void SetMaximumSize(Size2D size)
1724 throw new ArgumentNullException(nameof(size));
1726 var val = new Uint16Pair((uint)size.Width, (uint)size.Height);
1728 Interop.Window.SetMaximumSize(SwigCPtr, Uint16Pair.getCPtr(val));
1730 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1734 /// Minimizes window's size.
1735 /// If this function is called with true, window will be iconified.
1736 /// Otherwise window will be activated.
1737 /// It is for the window's MIN button in window border.
1738 /// If window border is supported by display server, it is not necessary.
1740 /// <param name="min">If window is minimized or unminimized.</param>
1741 [EditorBrowsable(EditorBrowsableState.Never)]
1742 public void Minimize(bool min)
1744 Interop.Window.Minimize(SwigCPtr, min);
1745 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1749 /// Returns whether the window is minimized or not.
1751 /// <returns>True if the window is minimized, false otherwise.</returns>
1752 [EditorBrowsable(EditorBrowsableState.Never)]
1753 public bool IsMinimized()
1755 bool ret = Interop.Window.IsMinimized(SwigCPtr);
1756 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1761 /// Sets window's minimum size.
1762 /// It is to set the minimum size when window's size is decreased by RequestResizeToServer().
1763 /// Although the size is set by this function, window's size can be decreased over the limitation by SetPositionSize() or SetSize().
1765 /// <param name="size">the minimum size.</param>
1766 [EditorBrowsable(EditorBrowsableState.Never)]
1767 public void SetMimimumSize(Size2D size)
1771 throw new ArgumentNullException(nameof(size));
1773 var val = new Uint16Pair((uint)size.Width, (uint)size.Height);
1775 Interop.Window.SetMimimumSize(SwigCPtr, Uint16Pair.getCPtr(val));
1777 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1781 /// Query whether window is rotating or not.
1783 /// <returns>True if window is rotating, false otherwise.</returns>
1784 [EditorBrowsable(EditorBrowsableState.Never)]
1785 public bool IsWindowRotating()
1787 bool ret = Interop.Window.IsWindowRotating(SwigCPtr);
1788 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1793 /// Gets the last key event the window gets.
1795 /// <returns>The last key event the window gets.</returns>
1796 [EditorBrowsable(EditorBrowsableState.Never)]
1797 public Key GetLastKeyEvent()
1799 Key ret = new Key(Interop.Window.GetLastKeyEvent(SwigCPtr), false);
1800 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1805 /// Gets the last touch event the window gets.
1807 /// <returns>The last touch event the window gets.</returns>
1808 [EditorBrowsable(EditorBrowsableState.Never)]
1809 public Touch GetLastTouchEvent()
1811 Touch ret = new Touch(Interop.Window.GetLastTouchEvent(SwigCPtr), false);
1812 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1817 /// Add FrameUpdateCallback
1819 [EditorBrowsable(EditorBrowsableState.Never)]
1820 public void AddFrameUpdateCallback(FrameUpdateCallbackInterface frameUpdateCallback)
1822 frameUpdateCallback?.AddFrameUpdateCallback(stageCPtr, Layer.getCPtr(GetRootLayer()));
1826 /// Remove FrameUpdateCallback
1828 [EditorBrowsable(EditorBrowsableState.Never)]
1829 public void RemoveFrameUpdateCallback(FrameUpdateCallbackInterface frameUpdateCallback)
1831 frameUpdateCallback?.RemoveFrameUpdateCallback(stageCPtr);
1835 /// Dispose for Window
1837 [EditorBrowsable(EditorBrowsableState.Never)]
1838 protected override void Dispose(DisposeTypes type)
1845 if (type == DisposeTypes.Explicit)
1848 //Release your own managed resources here.
1849 //You should release all of your own disposable objects here.
1851 if (IsBorderEnabled)
1856 foreach (var layer in childLayers)
1864 childLayers.Clear();
1866 localController?.Dispose();
1869 this.DisconnectNativeSignals();
1874 /// This will not be public opened.
1875 [EditorBrowsable(EditorBrowsableState.Never)]
1876 protected override void ReleaseSwigCPtr(System.Runtime.InteropServices.HandleRef swigCPtr)
1878 Interop.Window.DeleteWindow(swigCPtr);
1881 private static Dictionary<int, internalHookCallbackType> frameCallbackList = new Dictionary<int, internalHookCallbackType>();
1883 private static readonly object locker = new object();
1885 private static int key = 0;
1887 private static FrameCallbackType internalHookFrameCallback = OnInternalHookFrameCallback;
1889 private struct internalHookCallbackType
1891 public FrameCallbackType userCallback;
1895 private static void OnInternalHookFrameCallback(int id)
1899 if (frameCallbackList.ContainsKey(id))
1901 if (frameCallbackList[id].userCallback != null)
1903 frameCallbackList[id].userCallback.Invoke(frameCallbackList[id].frameId);
1904 frameCallbackList.Remove(id);
1908 NUILog.Error($"found userCallback is NULL");
1909 frameCallbackList.Remove(id);
1915 private int AddInterHookCallback(FrameCallbackType callback, int frameId)
1917 if (null == callback)
1919 throw new ArgumentNullException(nameof(callback), "FrameCallbackType should not be null");
1921 var assignedKey = 0;
1926 frameCallbackList.Add(assignedKey, new internalHookCallbackType()
1928 userCallback = callback,
1936 /// Type of callback which is called when the frame rendering is done by graphics driver or when the frame is displayed on display.
1938 /// <param name="frameId">The Id to specify the frame. It will be passed when the callback is called.</param>
1939 [EditorBrowsable(EditorBrowsableState.Never)]
1940 public delegate void FrameCallbackType(int frameId);
1943 /// Adds a callback that is called when the frame rendering is done by the graphics driver.
1944 /// A callback of the following type may be used:
1946 /// void MyFunction( int frameId )
1948 /// This callback will be deleted once it is called.
1950 /// Ownership of the callback is passed onto this class
1953 /// <param name="callback">The function to call</param>
1954 /// <param name="frameId">The Id to specify the frame. It will be passed when the callback is called.</param>
1955 /// <exception cref="ArgumentNullException">This exception can occur by the callback is null.</exception>
1956 [EditorBrowsable(EditorBrowsableState.Never)]
1957 public void AddFrameRenderedCallback(FrameCallbackType callback, int frameId)
1959 var assignedKey = AddInterHookCallback(callback, frameId);
1960 Interop.WindowInternal.AddFrameRenderedCallback(SwigCPtr, new HandleRef(this, Marshal.GetFunctionPointerForDelegate<Delegate>(internalHookFrameCallback)), assignedKey);
1962 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1966 /// Adds a callback that is called when the frame is displayed on the display.
1967 /// A callback of the following type may be used:
1969 /// void MyFunction( int frameId )
1971 /// This callback will be deleted once it is called.
1973 /// Ownership of the callback is passed onto this class
1976 /// <param name="callback">The function to call</param>
1977 /// <param name="frameId">The Id to specify the frame. It will be passed when the callback is called.</param>
1978 /// <exception cref="ArgumentNullException">This exception can occur by the callback is null.</exception>
1979 [EditorBrowsable(EditorBrowsableState.Never)]
1980 public void AddFramePresentedCallback(FrameCallbackType callback, int frameId)
1982 var assignedKey = AddInterHookCallback(callback, frameId);
1983 Interop.WindowInternal.AddFramePresentedCallback(SwigCPtr, new HandleRef(this, Marshal.GetFunctionPointerForDelegate<Delegate>(internalHookFrameCallback)), assignedKey);
1985 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1989 /// Search through this Window for a Layer with the given unique ID.
1991 /// <param name="id">The ID of the Layer to find.</param>
1992 /// <remarks>Hidden-API</remarks>
1993 /// <returns>A handle to the Layer if found, or an empty handle if not.</returns>
1994 [EditorBrowsable(EditorBrowsableState.Never)]
1995 public Layer FindLayerByID(uint id)
1997 Layer defaultLayer = this.GetDefaultLayer();
1998 IntPtr cPtr = Interop.Actor.FindChildById(defaultLayer.SwigCPtr, id);
1999 Layer ret = this.GetInstanceSafely<Layer>(cPtr);
2001 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
2006 /// Get Native Window handle.
2008 /// How to get Native Window handle
2010 /// Window window = NUIApplication.GetDefaultWindow();
2011 /// var handle = window.NativeHandle;
2012 /// if(handle.IsInvalid == false)
2014 /// IntPtr nativeHandle = handle.DangerousGetHandle();
2015 /// // do something with nativeHandle
2020 /// <since_tizen> 9 </since_tizen>
2021 public SafeHandle NativeHandle
2025 return new NUI.SafeNativeWindowHandle(this);