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 overlayLayer;
40 private Layer borderLayer;
41 private string windowTitle;
42 private List<Layer> childLayers = new List<Layer>();
43 private LayoutController localController;
45 static internal bool IsSupportedMultiWindow()
47 bool isSupported = false;
50 Information.TryGetValue("http://tizen.org/feature/opengles.surfaceless_context", out isSupported);
52 catch (DllNotFoundException e)
54 Tizen.Log.Fatal("NUI", $"{e}\n");
59 internal Window(global::System.IntPtr cPtr, bool cMemoryOwn) : base(cPtr, cMemoryOwn)
61 if (Interop.Stage.IsInstalled())
63 stageCPtr = new global::System.Runtime.InteropServices.HandleRef(this, Interop.Stage.GetCurrent());
65 localController = new LayoutController(this);
66 NUILog.Debug("layoutController id:" + localController.GetId());
71 /// A helper method to get the current window where the view is added
73 /// <param name="view">The View added to the window</param>
74 /// <returns>A Window.</returns>
75 [EditorBrowsable(EditorBrowsableState.Never)]
76 static public Window Get(View view)
80 NUILog.Error("if there is no view, it can not get a window");
84 //to fix memory leak issue, match the handle count with native side.
85 Window ret = view.GetInstanceSafely<Window>(Interop.Window.Get(View.getCPtr(view)));
86 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
91 /// Creates a new Window.<br />
92 /// This creates an extra window in addition to the default main window<br />
94 /// <param name="windowPosition">The position and size of the Window.</param>
95 /// <param name="isTranslucent">Whether Window is translucent.</param>
96 /// <returns>A new Window.</returns>
97 /// <since_tizen> 6 </since_tizen>
98 /// <feature> http://tizen.org/feature/opengles.surfaceless_context </feature>
99 /// <exception cref="NotSupportedException">The required feature is not supported.</exception>
100 public Window(Rectangle windowPosition = null, bool isTranslucent = false) : this(Interop.Window.New(Rectangle.getCPtr(windowPosition), "", isTranslucent), true)
102 if (IsSupportedMultiWindow() == false)
104 NUILog.Error("This device does not support surfaceless_context. So Window cannot be created. ");
106 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
110 /// Creates a new Window with a specific name.<br />
111 /// This creates an extra window in addition to the default main window<br />
113 /// <param name="name">The name for extra window. </param>
114 /// <param name="windowPosition">The position and size of the Window.</param>
115 /// <param name="isTranslucent">Whether Window is translucent.</param>
116 /// <returns>A new Window.</returns>
117 /// <since_tizen> 6 </since_tizen>
118 /// <feature> http://tizen.org/feature/opengles.surfaceless_context </feature>
119 /// <exception cref="NotSupportedException">The required feature is not supported.</exception>
120 public Window(string name, Rectangle windowPosition = null, bool isTranslucent = false) : this(Interop.Window.New(Rectangle.getCPtr(windowPosition), name, isTranslucent), true)
122 if (IsSupportedMultiWindow() == false)
124 NUILog.Error("This device does not support surfaceless_context. So Window cannot be created. ");
126 this.windowTitle = name;
127 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
131 /// Creates a new Window with a specific name.<br />
132 /// This creates an extra window in addition to the default main window<br />
134 /// <param name="name">The name for extra window. </param>
135 /// <param name="borderInterface"><see cref="Tizen.NUI.IBorderInterface"/>If borderInterface is null, defaultBorder is enabled.</param>
136 /// <param name="windowPosition">The position and size of the Window.</param>
137 /// <param name="isTranslucent">Whether Window is translucent.</param>
138 /// <returns>A new Window.</returns>
139 /// <feature> http://tizen.org/feature/opengles.surfaceless_context </feature>
140 /// <exception cref="NotSupportedException">The required feature is not supported.</exception>
141 [EditorBrowsable(EditorBrowsableState.Never)]
142 public Window(string name, IBorderInterface borderInterface, Rectangle windowPosition = null, bool isTranslucent = false) : this(Interop.Window.New(Rectangle.getCPtr(windowPosition), name, isTranslucent), true)
144 if (IsSupportedMultiWindow() == false)
146 NUILog.Error("This device does not support surfaceless_context. So Window cannot be created. ");
148 this.windowTitle = name;
149 this.EnableBorder(borderInterface);
150 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
155 /// Enumeration for orientation of the window is the way in which a rectangular page is oriented for normal viewing.
157 /// <since_tizen> 3 </since_tizen>
158 public enum WindowOrientation
161 /// Portrait orientation. The height of the display area is greater than the width.
163 /// <since_tizen> 3 </since_tizen>
166 /// Landscape orientation. A wide view area is needed.
168 /// <since_tizen> 3 </since_tizen>
171 /// Portrait inverse orientation.
173 /// <since_tizen> 3 </since_tizen>
174 PortraitInverse = 180,
176 /// Landscape inverse orientation.
178 /// <since_tizen> 3 </since_tizen>
179 LandscapeInverse = 270,
181 /// No orientation. It is for the preferred orientation
182 /// Especially, NoOrientationPreference only has the effect for the preferred orientation.
183 /// It is used to unset the preferred orientation with SetPreferredOrientation.
185 [EditorBrowsable(EditorBrowsableState.Never)]
186 NoOrientationPreference = -1
190 /// Enumeration for the key grab mode for platform-level APIs.
192 /// <since_tizen> 3 </since_tizen>
193 public enum KeyGrabMode
196 /// Grabs a key only when on the top of the grabbing-window stack mode.
200 /// Grabs a key together with the other client window(s) mode.
204 /// 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.
208 /// Grabs a key exclusively regardless of the grabbing-window's position on the window stack mode.
214 /// Enumeration for transition effect's state.
216 [Obsolete("Do not use this, that will be removed. Use Window.EffectState instead.")]
217 [EditorBrowsable(EditorBrowsableState.Never)]
218 // This is already deprecated, so suppress warning here.
219 [System.Diagnostics.CodeAnalysis.SuppressMessage("Naming", "CA1717:Only FlagsAttribute enums should have plural names", Justification = "<Pending>")]
220 public enum EffectStates
225 [Obsolete("Do not use this, that will be removed. Use Window.EffectState.None instead.")]
226 [EditorBrowsable(EditorBrowsableState.Never)]
229 /// Transition effect is started.
231 [Obsolete("Do not use this, that will be removed. Use Window.EffectState.Start instead.")]
232 [EditorBrowsable(EditorBrowsableState.Never)]
235 /// Transition effect is ended.
237 [Obsolete("Do not use this, that will be removed. Use Window.EffectState.End instead.")]
238 [EditorBrowsable(EditorBrowsableState.Never)]
243 /// Enumeration for transition effect's state.
245 [EditorBrowsable(EditorBrowsableState.Never)]
246 public enum EffectState
251 [EditorBrowsable(EditorBrowsableState.Never)]
254 /// Transition effect is started.
256 [EditorBrowsable(EditorBrowsableState.Never)]
259 /// Transition effect is ended.
261 [EditorBrowsable(EditorBrowsableState.Never)]
266 /// Enumeration for transition effect's type.
268 [Obsolete("Do not use this, that will be removed. Use Window.EffectType instead.")]
269 [EditorBrowsable(EditorBrowsableState.Never)]
270 // This is already deprecated, so suppress warning here.
271 [System.Diagnostics.CodeAnalysis.SuppressMessage("Naming", "CA1717:Only FlagsAttribute enums should have plural names", Justification = "<Pending>")]
272 public enum EffectTypes
277 [Obsolete("Do not use this, that will be removed. Use Window.EffectType.None instead.")]
278 [EditorBrowsable(EditorBrowsableState.Never)]
281 /// Window show effect.
283 [Obsolete("Do not use this, that will be removed. Use Window.EffectType.Show instead.")]
284 [EditorBrowsable(EditorBrowsableState.Never)]
287 /// Window hide effect.
289 [Obsolete("Do not use this, that will be removed. Use Window.EffectType.Hide instead.")]
290 [EditorBrowsable(EditorBrowsableState.Never)]
295 /// Enumeration for transition effect's type.
297 [EditorBrowsable(EditorBrowsableState.Never)]
298 public enum EffectType
303 [EditorBrowsable(EditorBrowsableState.Never)]
306 /// Window show effect.
308 [EditorBrowsable(EditorBrowsableState.Never)]
311 /// Window hide effect.
313 [EditorBrowsable(EditorBrowsableState.Never)]
318 /// Enumeration for result of window operation.
320 internal enum OperationResult
323 /// Failed for unknown reason
331 /// Permission denied
335 /// The operation is not supported.
341 /// Enumeration for window resized mode by display server.
343 [EditorBrowsable(EditorBrowsableState.Never)]
344 public enum ResizeDirection
349 [EditorBrowsable(EditorBrowsableState.Never)]
352 /// Start resizing window to the top-left edge.
354 [EditorBrowsable(EditorBrowsableState.Never)]
357 /// Start resizing window to the top side.
359 [EditorBrowsable(EditorBrowsableState.Never)]
362 /// Start resizing window to the top-right edge.
364 [EditorBrowsable(EditorBrowsableState.Never)]
367 /// Start resizing window to the left side.
369 [EditorBrowsable(EditorBrowsableState.Never)]
372 /// Start resizing window to the right side.
374 [EditorBrowsable(EditorBrowsableState.Never)]
377 /// Start resizing window to the bottom-left edge.
379 [EditorBrowsable(EditorBrowsableState.Never)]
382 /// Start resizing window to the bottom side.
384 [EditorBrowsable(EditorBrowsableState.Never)]
387 /// Start resizing window to the bottom-right edge.
389 [EditorBrowsable(EditorBrowsableState.Never)]
395 /// The stage instance property (read-only).<br />
396 /// Gets the current window.<br />
398 /// <since_tizen> 3 </since_tizen>
399 public static Window Instance { get; internal set; }
402 /// Gets or sets a window type.
403 /// Most of window type can be set to use WindowType, except for IME type.
404 /// IME type can be set to use one of NUIApplication's constrcutors.
406 /// <since_tizen> 3 </since_tizen>
407 public WindowType Type
411 WindowType ret = (WindowType)Interop.Window.GetType(SwigCPtr);
412 if (NDalicPINVOKE.SWIGPendingException.Pending) throw new InvalidOperationException("FATAL: get Exception", NDalicPINVOKE.SWIGPendingException.Retrieve());
417 Interop.Window.SetType(SwigCPtr, (int)value);
418 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
423 /// Gets/Sets a window title.
425 /// <since_tizen> 4 </since_tizen>
435 SetClass(windowTitle, "");
440 /// The rendering behavior of a Window.
442 /// <since_tizen> 5 </since_tizen>
443 public RenderingBehaviorType RenderingBehavior
447 return GetRenderingBehavior();
451 SetRenderingBehavior(value);
456 /// The window size property (read-only).
458 /// <since_tizen> 3 </since_tizen>
463 Size2D ret = GetSize();
469 /// The background color property.
471 /// <since_tizen> 3 </since_tizen>
472 public Color BackgroundColor
476 SetBackgroundColor(value);
480 Color ret = GetBackgroundColor();
486 /// The DPI property (read-only).<br />
487 /// Retrieves the DPI of the display device to which the Window is connected.<br />
489 /// <since_tizen> 3 </since_tizen>
499 /// The layer count property (read-only).<br />
500 /// Queries the number of on-Window layers.<br />
502 /// <since_tizen> 3 </since_tizen>
503 public uint LayerCount
507 return GetLayerCount();
512 /// Gets or sets a size of the window.
514 /// <exception cref="ArgumentNullException"> Thrown when value is null. </exception>
515 /// <since_tizen> 4 </since_tizen>
516 public Size2D WindowSize
520 return GetWindowSize();
524 SetWindowSize(value);
529 /// Gets or sets a position of the window.
531 /// <exception cref="ArgumentNullException"> Thrown when value is null. </exception>
532 /// <since_tizen> 4 </since_tizen>
533 public Position2D WindowPosition
537 return GetPosition();
546 /// Sets position and size of the window. This API guarantees that
547 /// both moving and resizing of window will appear on the screen at once.
549 [EditorBrowsable(EditorBrowsableState.Never)]
550 public Rectangle WindowPositionSize
554 Position2D position = GetPosition();
555 Size2D size = GetSize();
556 Rectangle ret = new Rectangle(position?.X ?? 0, position?.Y ?? 0, size?.Width ?? 0, size?.Height ?? 0);
562 SetPositionSize(value);
566 internal static Vector4 DEFAULT_BACKGROUND_COLOR
570 global::System.IntPtr cPtr = Interop.Stage.DefaultBackgroundColorGet();
571 Vector4 ret = (cPtr == global::System.IntPtr.Zero) ? null : new Vector4(cPtr, false);
572 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
577 internal static Vector4 DEBUG_BACKGROUND_COLOR
581 global::System.IntPtr cPtr = Interop.Stage.DebugBackgroundColorGet();
582 Vector4 ret = (cPtr == global::System.IntPtr.Zero) ? null : new Vector4(cPtr, false);
583 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
588 internal List<Layer> LayersChildren
597 /// Get the LayoutController for this Window.
599 internal LayoutController LayoutController
603 return localController;
608 /// Feed a key-event into the window.
610 /// <param name="keyEvent">The key event to feed.</param>
611 /// <since_tizen> 4 </since_tizen>
612 [Obsolete("Do not use this, that will be deprecated. Use FeedKey(Key keyEvent) instead.")]
613 public static void FeedKeyEvent(Key keyEvent)
615 Interop.Window.FeedKeyEvent(Key.getCPtr(keyEvent));
616 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
620 /// Sets whether the window accepts a focus or not.
622 /// <param name="accept">If a focus is accepted or not. The default is true.</param>
623 /// <since_tizen> 3 </since_tizen>
624 public void SetAcceptFocus(bool accept)
626 Interop.Window.SetAcceptFocus(SwigCPtr, accept);
627 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
631 /// Returns whether the window accepts a focus or not.
633 /// <returns>True if the window accepts a focus, false otherwise.</returns>
634 /// <since_tizen> 3 </since_tizen>
635 public bool IsFocusAcceptable()
637 bool ret = Interop.Window.IsFocusAcceptable(SwigCPtr);
638 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
644 /// Shows the window if it is hidden.
646 /// <since_tizen> 3 </since_tizen>
649 Interop.Window.Show(SwigCPtr);
650 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
654 /// Hides the window if it is showing.
656 /// <since_tizen> 3 </since_tizen>
659 Interop.Window.Hide(SwigCPtr);
660 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
664 /// Retrieves whether the window is visible or not.
666 /// <returns>True if the window is visible.</returns>
667 /// <since_tizen> 3 </since_tizen>
668 public bool IsVisible()
670 bool temp = Interop.Window.IsVisible(SwigCPtr);
671 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
676 /// Gets the count of supported auxiliary hints of the window.
678 /// <returns>The number of supported auxiliary hints.</returns>
679 /// <since_tizen> 3 </since_tizen>
680 public uint GetSupportedAuxiliaryHintCount()
682 uint ret = Interop.Window.GetSupportedAuxiliaryHintCount(SwigCPtr);
683 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
688 /// Gets the supported auxiliary hint string of the window.
690 /// <param name="index">The index of the supported auxiliary hint lists.</param>
691 /// <returns>The auxiliary hint string of the index.</returns>
692 /// <since_tizen> 3 </since_tizen>
693 public string GetSupportedAuxiliaryHint(uint index)
695 string ret = Interop.Window.GetSupportedAuxiliaryHint(SwigCPtr, index);
696 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
701 /// Creates an auxiliary hint of the window.
703 /// <param name="hint">The auxiliary hint string.</param>
704 /// <param name="value">The value string.</param>
705 /// <returns>The ID of created auxiliary hint, or 0 on failure.</returns>
706 /// <since_tizen> 3 </since_tizen>
707 public uint AddAuxiliaryHint(string hint, string value)
709 uint ret = Interop.Window.AddAuxiliaryHint(SwigCPtr, hint, value);
710 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
715 /// Removes an auxiliary hint of the window.
717 /// <param name="id">The ID of the auxiliary hint.</param>
718 /// <returns>True if no error occurred, false otherwise.</returns>
719 /// <since_tizen> 3 </since_tizen>
720 public bool RemoveAuxiliaryHint(uint id)
722 bool ret = Interop.Window.RemoveAuxiliaryHint(SwigCPtr, id);
723 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
728 /// Changes a value of the auxiliary hint.
730 /// <param name="id">The auxiliary hint ID.</param>
731 /// <param name="value">The value string to be set.</param>
732 /// <returns>True if no error occurred, false otherwise.</returns>
733 /// <since_tizen> 3 </since_tizen>
734 public bool SetAuxiliaryHintValue(uint id, string value)
736 bool ret = Interop.Window.SetAuxiliaryHintValue(SwigCPtr, id, value);
737 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
742 /// Gets a value of the auxiliary hint.
744 /// <param name="id">The auxiliary hint ID.</param>
745 /// <returns>The string value of the auxiliary hint ID, or an empty string if none exists.</returns>
746 /// <since_tizen> 3 </since_tizen>
747 public string GetAuxiliaryHintValue(uint id)
749 string ret = Interop.Window.GetAuxiliaryHintValue(SwigCPtr, id);
750 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
755 /// Gets an ID of the auxiliary hint string.
757 /// <param name="hint">The auxiliary hint string.</param>
758 /// <returns>The ID of auxiliary hint string, or 0 on failure.</returns>
759 /// <since_tizen> 3 </since_tizen>
760 public uint GetAuxiliaryHintId(string hint)
762 uint ret = Interop.Window.GetAuxiliaryHintId(SwigCPtr, hint);
763 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
768 /// Sets a region to accept input events.
770 /// <param name="inputRegion">The region to accept input events.</param>
771 /// <since_tizen> 3 </since_tizen>
772 public void SetInputRegion(Rectangle inputRegion)
774 Interop.Window.SetInputRegion(SwigCPtr, Rectangle.getCPtr(inputRegion));
775 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
779 /// Sets a priority level for the specified notification window.
781 /// <param name="level">The notification window level.</param>
782 /// <returns>True if no error occurred, false otherwise.</returns>
783 /// <since_tizen> 3 </since_tizen>
784 public bool SetNotificationLevel(NotificationLevel level)
786 var ret = (OperationResult)Interop.Window.SetNotificationLevel(SwigCPtr, (int)level);
787 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
788 return ret == OperationResult.Succeed;
792 /// Gets a priority level for the specified notification window.
794 /// <returns>The notification window level.</returns>
795 /// <since_tizen> 3 </since_tizen>
796 public NotificationLevel GetNotificationLevel()
798 NotificationLevel ret = (NotificationLevel)Interop.Window.GetNotificationLevel(SwigCPtr);
799 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
804 /// Sets a transparent window's visual state to opaque. <br />
805 /// If a visual state of a transparent window is opaque, <br />
806 /// then the window manager could handle it as an opaque window when calculating visibility.
808 /// <param name="opaque">Whether the window's visual state is opaque.</param>
809 /// <remarks>This will have no effect on an opaque window. <br />
810 /// It doesn't change transparent window to opaque window but lets the window manager know the visual state of the window.
812 /// <since_tizen> 3 </since_tizen>
813 public void SetOpaqueState(bool opaque)
815 Interop.Window.SetOpaqueState(SwigCPtr, opaque);
816 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
820 /// Returns whether a transparent window's visual state is opaque or not.
822 /// <returns>True if the window's visual state is opaque, false otherwise.</returns>
823 /// <remarks> The return value has no meaning on an opaque window. </remarks>
824 /// <since_tizen> 3 </since_tizen>
825 public bool IsOpaqueState()
827 bool ret = Interop.Window.IsOpaqueState(SwigCPtr);
828 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
833 /// Sets a window's screen off mode.
835 /// <param name="screenOffMode">The screen mode.</param>
836 /// <returns>True if no error occurred, false otherwise.</returns>
837 /// <since_tizen> 4 </since_tizen>
838 public bool SetScreenOffMode(ScreenOffMode screenOffMode)
840 var ret = (OperationResult)Interop.Window.SetScreenOffMode(SwigCPtr, (int)screenOffMode);
841 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
842 return ret == OperationResult.Succeed;
846 /// Gets the screen mode of the window.
848 /// <returns>The screen off mode.</returns>
849 /// <since_tizen> 4 </since_tizen>
850 public ScreenOffMode GetScreenOffMode()
852 ScreenOffMode ret = (ScreenOffMode)Interop.Window.GetScreenOffMode(SwigCPtr);
853 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
858 /// Sets preferred brightness of the window.
860 /// <param name="brightness">The preferred brightness (0 to 100).</param>
861 /// <returns>True if no error occurred, false otherwise.</returns>
862 /// <since_tizen> 3 </since_tizen>
863 public bool SetBrightness(int brightness)
865 var ret = (OperationResult)Interop.Window.SetBrightness(SwigCPtr, brightness);
866 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
867 return ret == OperationResult.Succeed;
871 /// Gets the preferred brightness of the window.
873 /// <returns>The preferred brightness.</returns>
874 /// <since_tizen> 3 </since_tizen>
875 public int GetBrightness()
877 int ret = Interop.Window.GetBrightness(SwigCPtr);
878 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
883 /// Sets the window name and the class string.
885 /// <param name="name">The name of the window.</param>
886 /// <param name="klass">The class of the window.</param>
887 /// <since_tizen> 4 </since_tizen>
888 public void SetClass(string name, string klass)
890 Interop.Window.SetClass(SwigCPtr, name, klass);
891 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
895 /// Raises the window to the top of the window stack.
897 /// <since_tizen> 3 </since_tizen>
900 Interop.Window.Raise(SwigCPtr);
901 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
905 /// Lowers the window to the bottom of the window stack.
907 /// <since_tizen> 3 </since_tizen>
910 Interop.Window.Lower(SwigCPtr);
911 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
915 /// Activates the window to the top of the window stack even it is iconified.
917 /// <since_tizen> 3 </since_tizen>
918 public void Activate()
920 Interop.Window.Activate(SwigCPtr);
921 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
925 /// Gets the default ( root ) layer.
927 /// <returns>The root layer.</returns>
928 /// <since_tizen> 3 </since_tizen>
929 public Layer GetDefaultLayer()
931 return this.GetRootLayer();
935 /// Gets the overlay layer.
937 /// <returns>The overlay layer.</returns>
938 [EditorBrowsable(EditorBrowsableState.Never)]
939 public Layer GetOverlayLayer()
941 // Window.IsInstalled() is actually true only when called from event thread and
942 // Core has been initialized, not when Stage is ready.
943 if (overlayLayer == null && Window.IsInstalled())
945 overlayLayer = new Layer(Interop.Window.GetOverlayLayer(SwigCPtr), true);
946 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
947 LayersChildren?.Add(overlayLayer);
948 overlayLayer.SetWindow(this);
954 /// Add a child view to window.
956 /// <param name="view">the child should be added to the window.</param>
957 /// <since_tizen> 3 </since_tizen>
958 public void Add(View view)
960 this.GetRootLayer().Add(view);
964 /// Remove a child view from window.
966 /// <param name="view">the child to be removed.</param>
967 /// <since_tizen> 3 </since_tizen>
968 public void Remove(View view)
970 this.GetRootLayer().Remove(view);
974 /// Retrieves the layer at a specified depth.
976 /// <param name="depth">The layer's depth index.</param>
977 /// <returns>The layer found at the given depth.</returns>
978 /// <since_tizen> 3 </since_tizen>
979 public Layer GetLayer(uint depth)
981 if (depth < LayersChildren?.Count)
983 Layer ret = LayersChildren?[Convert.ToInt32(depth)];
993 /// Destroy the window immediately.
995 [EditorBrowsable(EditorBrowsableState.Never)]
996 public void Destroy()
1002 /// Keep rendering for at least the given amount of time.
1004 /// <param name="durationSeconds">Time to keep rendering, 0 means render at least one more frame.</param>
1005 /// <since_tizen> 3 </since_tizen>
1006 public void KeepRendering(float durationSeconds)
1008 Interop.Stage.KeepRendering(stageCPtr, durationSeconds);
1009 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1013 /// Grabs the key specified by a key for a window only when a window is the topmost window.<br />
1014 /// This function can be used for following example scenarios: <br />
1015 /// - Mobile - Using volume up or down as zoom up or down in camera apps.<br />
1017 /// <param name="DaliKey">The key code to grab.</param>
1018 /// <returns>True if the grab succeeds.</returns>
1019 /// <since_tizen> 3 </since_tizen>
1020 public bool GrabKeyTopmost(int DaliKey)
1022 bool ret = Interop.Window.GrabKeyTopmost(HandleRef.ToIntPtr(this.SwigCPtr), DaliKey);
1023 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1028 /// Ungrabs the key specified by a key for the window.<br />
1029 /// 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 />
1031 /// <param name="DaliKey">The key code to ungrab.</param>
1032 /// <returns>True if the ungrab succeeds.</returns>
1033 /// <since_tizen> 3 </since_tizen>
1034 public bool UngrabKeyTopmost(int DaliKey)
1036 bool ret = Interop.Window.UngrabKeyTopmost(HandleRef.ToIntPtr(this.SwigCPtr), DaliKey);
1037 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1042 /// Grabs the key specified by a key for a window in a GrabMode. <br />
1043 /// Details: This function can be used for following example scenarios: <br />
1044 /// - TV - A user might want to change the volume or channel of the background TV contents while focusing on the foregrund app. <br />
1045 /// - Mobile - When a user presses the Home key, the homescreen appears regardless of the current foreground app. <br />
1046 /// - Mobile - Using the volume up or down as zoom up or down in camera apps. <br />
1048 /// <param name="DaliKey">The key code to grab.</param>
1049 /// <param name="GrabMode">The grab mode for the key.</param>
1050 /// <returns>True if the grab succeeds.</returns>
1051 /// <since_tizen> 3 </since_tizen>
1052 public bool GrabKey(int DaliKey, KeyGrabMode GrabMode)
1054 bool ret = Interop.Window.GrabKey(HandleRef.ToIntPtr(this.SwigCPtr), DaliKey, (int)GrabMode);
1055 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1060 /// Ungrabs the key specified by a key for a window.<br />
1061 /// 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 />
1063 /// <param name="DaliKey">The key code to ungrab.</param>
1064 /// <returns>True if the ungrab succeeds.</returns>
1065 /// <since_tizen> 3 </since_tizen>
1066 public bool UngrabKey(int DaliKey)
1068 bool ret = Interop.Window.UngrabKey(HandleRef.ToIntPtr(this.SwigCPtr), DaliKey);
1069 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1074 /// Sets the keyboard repeat information.
1076 /// <param name="rate">The key repeat rate value in seconds.</param>
1077 /// <param name="delay">The key repeat delay value in seconds.</param>
1078 /// <returns>True if setting the keyboard repeat succeeds.</returns>
1079 /// <since_tizen> 5 </since_tizen>
1080 public bool SetKeyboardRepeatInfo(float rate, float delay)
1082 bool ret = Interop.Window.SetKeyboardRepeatInfo(rate, delay);
1083 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1088 /// Gets the keyboard repeat information.
1090 /// <param name="rate">The key repeat rate value in seconds.</param>
1091 /// <param name="delay">The key repeat delay value in seconds.</param>
1092 /// <returns>True if setting the keyboard repeat succeeds.</returns>
1093 /// <since_tizen> 5 </since_tizen>
1094 public bool GetKeyboardRepeatInfo(out float rate, out float delay)
1096 bool ret = Interop.Window.GetKeyboardRepeatInfo(out rate, out delay);
1097 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1102 /// Adds a layer to the stage.
1104 /// <param name="layer">Layer to add.</param>
1105 /// <exception cref="ArgumentNullException"> Thrown when layer is null. </exception>
1106 /// <since_tizen> 3 </since_tizen>
1107 public void AddLayer(Layer layer)
1113 /// Removes a layer from the stage.
1115 /// <param name="layer">Layer to remove.</param>
1116 /// <exception cref="ArgumentNullException"> Thrown when layer is null. </exception>
1117 /// <since_tizen> 3 </since_tizen>
1118 public void RemoveLayer(Layer layer)
1124 /// Feeds a key event into the window.
1126 /// <param name="keyEvent">The key event to feed.</param>
1127 /// <since_tizen> 5 </since_tizen>
1128 public void FeedKey(Key keyEvent)
1130 Interop.Window.FeedKeyEvent(SwigCPtr, Key.getCPtr(keyEvent));
1131 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1135 /// Feeds a touch point into the window.
1137 /// <param name="touchPoint">The touch point to feed.</param>
1138 /// <param name="timeStamp">The timeStamp.</param>
1139 internal void FeedTouch(TouchPoint touchPoint, int timeStamp)
1141 Interop.Window.FeedTouchPoint(SwigCPtr, TouchPoint.getCPtr(touchPoint), timeStamp);
1142 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1146 /// Feeds a wheel event into the window.
1148 /// <param name="wheelEvent">The wheel event to feed.</param>
1149 internal void FeedWheel(Wheel wheelEvent)
1151 Interop.Window.FeedWheelEvent(SwigCPtr, Wheel.getCPtr(wheelEvent));
1152 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1156 /// Allows at least one more render, even when paused.
1157 /// The window should be shown, not minimised.
1159 /// <since_tizen> 4 </since_tizen>
1160 public void RenderOnce()
1162 Interop.Window.RenderOnce(SwigCPtr);
1163 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1167 /// Sets whether the window is transparent or not.
1169 /// <param name="transparent">Whether the window is transparent or not.</param>
1170 /// <since_tizen> 5 </since_tizen>
1171 public void SetTransparency(bool transparent)
1173 Interop.Window.SetTransparency(SwigCPtr, transparent);
1174 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1176 // Setting transparency of the window should request a relayout of the tree in the case the window changes from fully transparent.
1180 /// Sets parent window of the window.
1181 /// After setting that, these windows do together when raise-up, lower and iconified/deiconified.
1182 /// Initially, the window is located on top of the parent. The window can go below parent by calling Lower().
1183 /// If parent's window stack is changed by calling Raise() or Lower(), child windows are located on top of the parent again.
1185 /// <param name="parent">The parent window.</param>
1186 /// <since_tizen> 6 </since_tizen>
1187 /// <feature> http://tizen.org/feature/opengles.surfaceless_context </feature>
1188 /// <exception cref="NotSupportedException">The required feature is not supported.</exception>
1189 public void SetParent(Window parent)
1191 if (IsSupportedMultiWindow() == false)
1193 NUILog.Error("This device does not support surfaceless_context. So Window cannot be created. ");
1195 Interop.Window.SetParent(SwigCPtr, Window.getCPtr(parent));
1196 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1200 /// Sets parent window of the window.
1201 /// After setting that, these windows do together when raise-up, lower and iconified/deiconified.
1202 /// This function has the additional flag whether the child is located above or below of the parent.
1204 /// <param name="parent">The parent window.</param>
1205 /// <param name="belowParent">The flag is whether the child is located above or below of the parent.</param>
1206 /// <feature> http://tizen.org/feature/opengles.surfaceless_context </feature>
1207 /// <exception cref="NotSupportedException">The required feature is not supported.</exception>
1208 [EditorBrowsable(EditorBrowsableState.Never)]
1209 public void SetParent(Window parent, bool belowParent)
1211 if (IsSupportedMultiWindow() == false)
1213 NUILog.Error("This device does not support surfaceless_context. So Window cannot be created. ");
1215 Interop.Window.SetParentWithStack(SwigCPtr, Window.getCPtr(parent), belowParent);
1216 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1220 /// Unsets parent window of the window.
1221 /// After unsetting, the window is disconnected his parent window.
1223 /// <since_tizen> 6 </since_tizen>
1224 /// <feature> http://tizen.org/feature/opengles.surfaceless_context </feature>
1225 /// <exception cref="NotSupportedException">The required feature is not supported.</exception>
1226 public void Unparent()
1228 if (IsSupportedMultiWindow() == false)
1230 NUILog.Error("Fail to create window. because this device does not support opengles.surfaceless_context.");
1232 Interop.Window.Unparent(SwigCPtr);
1233 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1237 /// Gets parent window of the window.
1239 /// <returns>The parent window of the window.</returns>
1240 /// <since_tizen> 6 </since_tizen>
1241 /// <feature> http://tizen.org/feature/opengles.surfaceless_context </feature>
1242 /// <exception cref="NotSupportedException">The required feature is not supported.</exception>
1243 [System.Diagnostics.CodeAnalysis.SuppressMessage("Design", "CA1721: Property names should not match get methods")]
1244 public Window GetParent()
1246 if (IsSupportedMultiWindow() == false)
1248 NUILog.Error("This device does not support surfaceless_context. So Window cannot be created. ");
1250 Window ret = this.GetInstanceSafely<Window>(Interop.Window.GetParent(SwigCPtr));
1251 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1255 /// This will be public opened in tizen_next after ACR done. Before ACR, need to be hidden as inhouse API.
1256 [EditorBrowsable(EditorBrowsableState.Never)]
1257 public void ObjectDump()
1259 Layer rootLayer = GetRootLayer();
1260 foreach (View view in rootLayer.Children)
1266 internal static bool IsInstalled()
1268 bool ret = Interop.Stage.IsInstalled();
1269 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1274 /// Adds an orientation to the list of available orientations.
1276 /// <param name="orientation">The available orientation to add</param>
1277 /// <since_tizen> 6 </since_tizen>
1278 public void AddAvailableOrientation(Window.WindowOrientation orientation)
1280 Interop.Window.AddAvailableOrientation(SwigCPtr, (int)orientation);
1281 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1285 /// Removes an orientation from the list of available orientations.
1287 /// <param name="orientation">The available orientation to remove.</param>
1288 /// <since_tizen> 6 </since_tizen>
1289 public void RemoveAvailableOrientation(Window.WindowOrientation orientation)
1291 Interop.Window.RemoveAvailableOrientation(SwigCPtr, (int)orientation);
1292 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1296 /// Sets a preferred orientation.
1298 /// <param name="orientation">The preferred orientation.</param>
1299 /// <since_tizen> 6 </since_tizen>
1300 public void SetPreferredOrientation(Window.WindowOrientation orientation)
1302 Interop.Window.SetPreferredOrientation(SwigCPtr, (int)orientation);
1303 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1307 /// Gets the preferred orientation.
1309 /// <since_tizen> 6 </since_tizen>
1310 /// <returns>The preferred orientation if previously set, or none.</returns>
1311 public Window.WindowOrientation GetPreferredOrientation()
1313 Window.WindowOrientation ret = (Window.WindowOrientation)Interop.Window.GetPreferredOrientation(SwigCPtr);
1314 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1319 /// Gets current orientation of the window.
1321 /// <since_tizen> 6 </since_tizen>
1322 /// <returns>The current window orientation if previously set, or none.</returns>
1323 [EditorBrowsable(EditorBrowsableState.Never)]
1324 public Window.WindowOrientation GetCurrentOrientation()
1326 Window.WindowOrientation ret = (Window.WindowOrientation)Interop.Window.GetCurrentOrientation(SwigCPtr);
1327 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1332 /// Sets available orientations of the window.
1333 /// This API is for setting several orientations one time.
1335 /// <param name="orientations">The list of orientations.</param>
1336 /// <since_tizen> 6 </since_tizen>
1337 [EditorBrowsable(EditorBrowsableState.Never)]
1338 public void SetAvailableOrientations(List<Window.WindowOrientation> orientations)
1340 if (null == orientations)
1342 throw new ArgumentNullException(nameof(orientations));
1345 PropertyArray orientationArray = new PropertyArray();
1346 for (int i = 0; i < orientations.Count; i++)
1348 PropertyValue value = new PropertyValue((int)orientations[i]);
1349 orientationArray.PushBack(value);
1353 Interop.Window.SetAvailableOrientations(SwigCPtr, PropertyArray.getCPtr(orientationArray), orientations.Count);
1354 orientationArray.Dispose();
1355 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1359 /// Get native window ID
1361 /// <returns>native window ID</returns>
1362 [EditorBrowsable(EditorBrowsableState.Never)]
1363 public int GetNativeId()
1365 int ret = Interop.Window.GetNativeId(SwigCPtr);
1366 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1370 internal Any GetNativeHandle()
1372 Any ret = new Any(Interop.WindowInternal.WindowGetNativeHandle(SwigCPtr), true);
1373 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1377 internal void Add(Layer layer)
1381 throw new ArgumentNullException(nameof(layer));
1386 Interop.Actor.Add(GetRootLayer().SwigCPtr, layer.SwigCPtr);
1387 if (NDalicPINVOKE.SWIGPendingException.Pending) { throw NDalicPINVOKE.SWIGPendingException.Retrieve(); }
1391 Interop.Window.Add(SwigCPtr, Layer.getCPtr(layer));
1392 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1395 LayersChildren?.Add(layer);
1396 layer.SetWindow(this);
1399 internal void Remove(Layer layer)
1403 throw new ArgumentNullException(nameof(layer));
1405 Interop.Window.Remove(SwigCPtr, Layer.getCPtr(layer));
1406 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1408 LayersChildren?.Remove(layer);
1409 layer.SetWindow(null);
1412 internal Vector2 GetSize()
1414 var val = new Uint16Pair(Interop.Window.GetSize(SwigCPtr), true);
1416 convertRealWindowSizeToBorderWindowSize(val);
1418 Vector2 ret = new Vector2(val.GetWidth(), val.GetHeight());
1419 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1424 /// This will be public opened in next tizen after ACR done. Before ACR, need to be hidden as inhouse API.
1425 [EditorBrowsable(EditorBrowsableState.Never)]
1426 public RenderTaskList GetRenderTaskList()
1428 RenderTaskList ret = new RenderTaskList(Interop.Stage.GetRenderTaskList(stageCPtr), true);
1429 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1434 /// Queries the number of on-window layers.
1436 /// <returns>The number of layers.</returns>
1437 /// <remarks>Note that a default layer is always provided (count >= 1).</remarks>
1438 internal uint GetLayerCount()
1440 if (LayersChildren == null || LayersChildren.Count < 0)
1443 return (uint)LayersChildren.Count;
1446 internal Layer GetRootLayer()
1450 if (borderLayer == null)
1452 borderLayer = GetBorderWindowRootLayer();
1453 LayersChildren?.Add(borderLayer);
1454 borderLayer.SetWindow(this);
1460 // Window.IsInstalled() is actually true only when called from event thread and
1461 // Core has been initialized, not when Stage is ready.
1462 if (rootLayer == null && Window.IsInstalled())
1464 rootLayer = new Layer(Interop.Window.GetRootLayer(SwigCPtr), true);
1465 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1466 LayersChildren?.Add(rootLayer);
1467 rootLayer.SetWindow(this);
1473 internal void SetBackgroundColor(Vector4 color)
1475 Interop.Window.SetBackgroundColor(SwigCPtr, Vector4.getCPtr(color));
1476 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1479 internal Vector4 GetBackgroundColor()
1481 Vector4 ret = new Vector4(Interop.Window.GetBackgroundColor(SwigCPtr), true);
1482 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1486 internal Vector2 GetDpi()
1488 Vector2 ret = new Vector2(Interop.Stage.GetDpi(stageCPtr), true);
1489 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1493 internal ObjectRegistry GetObjectRegistry()
1495 ObjectRegistry ret = new ObjectRegistry(Interop.Stage.GetObjectRegistry(stageCPtr), true);
1496 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1500 internal void SetRenderingBehavior(RenderingBehaviorType renderingBehavior)
1502 Interop.Stage.SetRenderingBehavior(stageCPtr, (int)renderingBehavior);
1503 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1506 internal RenderingBehaviorType GetRenderingBehavior()
1508 RenderingBehaviorType ret = (RenderingBehaviorType)Interop.Stage.GetRenderingBehavior(stageCPtr);
1509 if (NDalicPINVOKE.SWIGPendingException.Pending)
1510 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1514 internal void SetWindowSize(Size2D size)
1518 throw new ArgumentNullException(nameof(size));
1520 var val = new Uint16Pair((uint)size.Width, (uint)size.Height);
1522 convertBorderWindowSizeToRealWindowSize(val);
1524 Interop.Window.SetSize(SwigCPtr, Uint16Pair.getCPtr(val));
1526 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1527 // Resetting Window size should request a relayout of the tree.
1530 internal Size2D GetWindowSize()
1532 var val = new Uint16Pair(Interop.Window.GetSize(SwigCPtr), true);
1534 convertRealWindowSizeToBorderWindowSize(val);
1536 Size2D ret = new Size2D(val.GetWidth(), val.GetHeight());
1537 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1542 internal void SetPosition(Position2D position)
1544 if (null == position)
1546 throw new ArgumentNullException(nameof(position));
1548 var val = new Int32Pair(position.X, position.Y);
1549 Interop.Window.SetPosition(SwigCPtr, Int32Pair.getCPtr(val));
1551 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1552 // Setting Position of the window should request a relayout of the tree.
1555 internal Position2D GetPosition()
1557 var val = new Int32Pair(Interop.Window.GetPosition(SwigCPtr), true);
1558 Position2D ret = new Position2D((int)val.GetX(), (int)val.GetY());
1560 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1564 internal void SetPositionSize(Rectangle positionSize)
1566 if (positionSize == null)
1568 throw new ArgumentNullException(nameof(positionSize));
1570 var val = new Uint16Pair((uint)positionSize.Width, (uint)positionSize.Height);
1572 convertBorderWindowSizeToRealWindowSize(val);
1574 positionSize.Width = val.GetX();
1575 positionSize.Height = val.GetY();
1577 Interop.Window.SetPositionSize(SwigCPtr, Rectangle.getCPtr(positionSize));
1580 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1582 // Setting Position of the window should request a relayout of the tree.
1586 /// Enables the floating mode of window.
1587 /// The floating mode is to support window is moved or resized by display server.
1588 /// For example, if the video-player window sets the floating mode,
1589 /// then display server changes its geometry and handles it like a popup.
1590 /// The way of handling floating mode window is decided by display server.
1591 /// A special display server(as a Tizen display server) supports this mode.
1593 /// <param name="enable">Enable floating mode or not.</param>
1594 [EditorBrowsable(EditorBrowsableState.Never)]
1595 public void EnableFloatingMode(bool enable)
1597 Interop.Window.EnableFloatingMode(SwigCPtr, enable);
1598 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1602 /// Requests to display server for the window is moved by display server.
1603 /// It can be work with setting window floating mode.
1605 [EditorBrowsable(EditorBrowsableState.Never)]
1606 public void RequestMoveToServer()
1608 Interop.Window.RequestMoveToServer(SwigCPtr);
1609 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1613 /// Requests to display server for the window is resized by display server.
1614 /// It can be work with setting window floating mode.
1616 /// <param name="direction">It is indicated the window's side or edge for starting point.</param>
1617 [EditorBrowsable(EditorBrowsableState.Never)]
1618 public void RequestResizeToServer(ResizeDirection direction)
1620 Interop.Window.RequestResizeToServer(SwigCPtr, (int)direction);
1621 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1625 /// Includes input region.
1626 /// This function inlcudes input regions.
1627 /// It can be used multiple times and supports multiple regions.
1628 /// It means input region will be extended.
1629 /// This input is related to mouse and touch event.
1630 /// If device has touch screen, this function is useful.
1631 /// Otherwise device does not have that, we can use it after connecting mouse to the device.
1633 /// <param name="inputRegion">The included region to accept input events.</param>
1634 [EditorBrowsable(EditorBrowsableState.Never)]
1635 public void IncludeInputRegion(Rectangle inputRegion)
1637 Interop.Window.IncludeInputRegion(SwigCPtr, Rectangle.getCPtr(inputRegion));
1638 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1642 /// This function excludes input regions.
1643 /// It can be used multiple times and supports multiple regions.
1644 /// It means input region will be reduced.
1645 /// Nofice, should be set input area by IncludeInputRegion() before this function is used.
1646 /// This input is related to mouse and touch event.
1647 /// If device has touch screen, this function is useful.
1648 /// Otherwise device does not have that, we can use it after connecting mouse to the device.
1650 /// <param name="inputRegion">The excluded region to except input events.</param>
1651 [EditorBrowsable(EditorBrowsableState.Never)]
1652 public void ExcludeInputRegion(Rectangle inputRegion)
1654 Interop.Window.ExcludeInputRegion(SwigCPtr, Rectangle.getCPtr(inputRegion));
1655 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1659 /// Maximizes window's size.
1660 /// If this function is called with true, window will be resized with screen size.
1661 /// Otherwise window will be resized with previous size.
1662 /// It is for the window's MAX button in window's border.
1663 /// If window border is supported by display server, it is not necessary.
1665 /// <param name="max">If window is maximized or unmaximized.</param>
1666 [EditorBrowsable(EditorBrowsableState.Never)]
1667 public void Maximize(bool max)
1669 Interop.Window.Maximize(SwigCPtr, max);
1670 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1674 /// Returns whether the window is maximized or not.
1676 /// <returns>True if the window is maximized, false otherwise.</returns>
1677 [EditorBrowsable(EditorBrowsableState.Never)]
1678 public bool IsMaximized()
1680 bool ret = Interop.Window.IsMaximized(SwigCPtr);
1681 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1686 /// Sets window's maximum size.
1688 /// It is to set the maximized size when window is maximized or the window's size is increased by RequestResizeToServer().
1689 /// Although the size is set by this function, window's size can be increased over the limitation by SetPositionSize() or SetSize().
1691 /// After setting, if Maximize() is called, window is resized with the setting size and move the center.
1694 /// <param name="size">the maximum size.</param>
1695 [EditorBrowsable(EditorBrowsableState.Never)]
1696 public void SetMaximumSize(Size2D size)
1700 throw new ArgumentNullException(nameof(size));
1702 var val = new Uint16Pair((uint)size.Width, (uint)size.Height);
1704 Interop.Window.SetMaximumSize(SwigCPtr, Uint16Pair.getCPtr(val));
1706 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1710 /// Minimizes window's size.
1711 /// If this function is called with true, window will be iconified.
1712 /// Otherwise window will be activated.
1713 /// It is for the window's MIN button in window border.
1714 /// If window border is supported by display server, it is not necessary.
1716 /// <param name="min">If window is minimized or unminimized.</param>
1717 [EditorBrowsable(EditorBrowsableState.Never)]
1718 public void Minimize(bool min)
1720 Interop.Window.Minimize(SwigCPtr, min);
1721 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1725 /// Returns whether the window is minimized or not.
1727 /// <returns>True if the window is minimized, false otherwise.</returns>
1728 [EditorBrowsable(EditorBrowsableState.Never)]
1729 public bool IsMinimized()
1731 bool ret = Interop.Window.IsMinimized(SwigCPtr);
1732 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1737 /// Sets window's minimum size.
1738 /// It is to set the minimum size when window's size is decreased by RequestResizeToServer().
1739 /// Although the size is set by this function, window's size can be decreased over the limitation by SetPositionSize() or SetSize().
1741 /// <param name="size">the minimum size.</param>
1742 [EditorBrowsable(EditorBrowsableState.Never)]
1743 public void SetMimimumSize(Size2D size)
1747 throw new ArgumentNullException(nameof(size));
1749 var val = new Uint16Pair((uint)size.Width, (uint)size.Height);
1751 Interop.Window.SetMimimumSize(SwigCPtr, Uint16Pair.getCPtr(val));
1753 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1757 /// Sets the layout of the window.
1759 /// <param name="numCols">The number of columns in the layout.</param>
1760 /// <param name="numRows">The number of rows in the layout.</param>
1761 /// <param name="column">The column number of the window within the layout.</param>
1762 /// <param name="row">The row number of the window within the layout.</param>
1763 /// <param name="colSpan">The number of columns the window should span within the layout.</param>
1764 /// <param name="rowSpan">The number of rows the window should span within the layout.</param>
1765 [EditorBrowsable(EditorBrowsableState.Never)]
1766 public void SetLayout(uint numCols, uint numRows, uint column, uint row, uint colSpan, uint rowSpan)
1768 Interop.Window.SetLayout(SwigCPtr, numCols, numRows, column, row, colSpan, rowSpan);
1769 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1774 /// Sets the layout of the window.
1776 /// <param name="layoutType">The type of layout to set for the window.</param>
1777 [EditorBrowsable(EditorBrowsableState.Never)]
1778 public void SetLayout(WindowLayoutType layoutType)
1782 case WindowLayoutType.LeftHalf:
1783 Interop.Window.SetLayout(SwigCPtr, 2, 1, 0, 0, 1, 1);
1785 case WindowLayoutType.RightHalf:
1786 Interop.Window.SetLayout(SwigCPtr, 2, 1, 1, 0, 1, 1);
1789 case WindowLayoutType.TopHalf:
1790 Interop.Window.SetLayout(SwigCPtr, 1, 2, 0, 0, 1, 1);
1792 case WindowLayoutType.BottomHalf:
1793 Interop.Window.SetLayout(SwigCPtr, 1, 2, 0, 1, 1, 1);
1796 case WindowLayoutType.UpperLeftQuarter:
1797 Interop.Window.SetLayout(SwigCPtr, 2, 2, 0, 0, 1, 1);
1799 case WindowLayoutType.UpperRightQuarter:
1800 Interop.Window.SetLayout(SwigCPtr, 2, 2, 1, 0, 1, 1);
1802 case WindowLayoutType.LowerLeftQuarter:
1803 Interop.Window.SetLayout(SwigCPtr, 2, 2, 0, 1, 1, 1);
1805 case WindowLayoutType.LowerRightQuarter:
1806 Interop.Window.SetLayout(SwigCPtr, 2, 2, 1, 1, 1, 1);
1809 case WindowLayoutType.LeftThird:
1810 Interop.Window.SetLayout(SwigCPtr, 3, 1, 0, 0, 1, 1);
1812 case WindowLayoutType.CenterThird:
1813 Interop.Window.SetLayout(SwigCPtr, 3, 1, 1, 0, 1, 1);
1815 case WindowLayoutType.RightThird:
1816 Interop.Window.SetLayout(SwigCPtr, 3, 1, 2, 0, 1, 1);
1819 case WindowLayoutType.TopThird:
1820 Interop.Window.SetLayout(SwigCPtr, 1, 3, 0, 0, 1, 1);
1822 case WindowLayoutType.MiddleThird:
1823 Interop.Window.SetLayout(SwigCPtr, 1, 3, 0, 1, 1, 1);
1825 case WindowLayoutType.BottomThird:
1826 Interop.Window.SetLayout(SwigCPtr, 1, 3, 0, 2, 1, 1);
1829 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1834 /// Query whether window is rotating or not.
1836 /// <returns>True if window is rotating, false otherwise.</returns>
1837 [EditorBrowsable(EditorBrowsableState.Never)]
1838 public bool IsWindowRotating()
1840 bool ret = Interop.Window.IsWindowRotating(SwigCPtr);
1841 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1846 /// Gets the last key event the window gets.
1848 /// <returns>The last key event the window gets.</returns>
1849 [EditorBrowsable(EditorBrowsableState.Never)]
1850 public Key GetLastKeyEvent()
1852 Key ret = new Key(Interop.Window.GetLastKeyEvent(SwigCPtr), false);
1853 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1858 /// Gets the last touch event the window gets.
1860 /// <returns>The last touch event the window gets.</returns>
1861 [EditorBrowsable(EditorBrowsableState.Never)]
1862 public Touch GetLastTouchEvent()
1864 Touch ret = new Touch(Interop.Window.GetLastTouchEvent(SwigCPtr), false);
1865 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1870 /// Sets the necessary for window rotation Acknowledgement.
1871 /// After this function called, SendRotationCompletedAcknowledgement() should be called to complete window rotation.
1873 /// This function is supprot that application has the window rotation acknowledgement's control.
1874 /// It means display server waits when application's rotation work is finished.
1875 /// It is useful application has the other rendering engine which works asynchronous.
1876 /// For instance, GlView.
1878 /// <param name="needAcknowledgement">the flag is true if window rotation acknowledge is sent.</param>
1879 [EditorBrowsable(EditorBrowsableState.Never)]
1880 public void SetNeedsRotationCompletedAcknowledgement(bool needAcknowledgement)
1882 Interop.Window.SetNeedsRotationCompletedAcknowledgement(SwigCPtr, needAcknowledgement);
1883 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1887 /// send the Acknowledgement to complete window rotation.
1888 /// For this function, SetNeedsRotationCompletedAcknowledgement should be already called with true.
1890 [EditorBrowsable(EditorBrowsableState.Never)]
1891 public void SendRotationCompletedAcknowledgement()
1893 Interop.Window.SendRotationCompletedAcknowledgement(SwigCPtr);
1894 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1898 /// Add FrameUpdateCallback
1900 [EditorBrowsable(EditorBrowsableState.Never)]
1901 public void AddFrameUpdateCallback(FrameUpdateCallbackInterface frameUpdateCallback)
1903 frameUpdateCallback?.AddFrameUpdateCallback(stageCPtr, Layer.getCPtr(GetRootLayer()));
1907 /// Remove FrameUpdateCallback
1909 [EditorBrowsable(EditorBrowsableState.Never)]
1910 public void RemoveFrameUpdateCallback(FrameUpdateCallbackInterface frameUpdateCallback)
1912 frameUpdateCallback?.RemoveFrameUpdateCallback(stageCPtr);
1916 /// Dispose for Window
1918 [EditorBrowsable(EditorBrowsableState.Never)]
1919 protected override void Dispose(DisposeTypes type)
1926 this.DisconnectNativeSignals();
1928 if (type == DisposeTypes.Explicit)
1931 //Release your own managed resources here.
1932 //You should release all of your own disposable objects here.
1934 if (IsBorderEnabled)
1939 foreach (var layer in childLayers)
1947 childLayers.Clear();
1949 localController?.Dispose();
1956 /// This will not be public opened.
1957 [EditorBrowsable(EditorBrowsableState.Never)]
1958 protected override void ReleaseSwigCPtr(System.Runtime.InteropServices.HandleRef swigCPtr)
1960 Interop.Window.DeleteWindow(swigCPtr);
1963 private static Dictionary<int, internalHookCallbackType> frameCallbackList = new Dictionary<int, internalHookCallbackType>();
1965 private static readonly object locker = new object();
1967 private static int key = 0;
1969 private static FrameCallbackType internalHookFrameCallback = OnInternalHookFrameCallback;
1971 private struct internalHookCallbackType
1973 public FrameCallbackType userCallback;
1977 private static void OnInternalHookFrameCallback(int id)
1981 if (frameCallbackList.ContainsKey(id))
1983 if (frameCallbackList[id].userCallback != null)
1985 frameCallbackList[id].userCallback.Invoke(frameCallbackList[id].frameId);
1986 frameCallbackList.Remove(id);
1990 NUILog.Error($"found userCallback is NULL");
1991 frameCallbackList.Remove(id);
1997 private int AddInterHookCallback(FrameCallbackType callback, int frameId)
1999 if (null == callback)
2001 throw new ArgumentNullException(nameof(callback), "FrameCallbackType should not be null");
2003 var assignedKey = 0;
2008 frameCallbackList.Add(assignedKey, new internalHookCallbackType()
2010 userCallback = callback,
2018 /// Type of callback which is called when the frame rendering is done by graphics driver or when the frame is displayed on display.
2020 /// <param name="frameId">The Id to specify the frame. It will be passed when the callback is called.</param>
2021 [EditorBrowsable(EditorBrowsableState.Never)]
2022 public delegate void FrameCallbackType(int frameId);
2025 /// Adds a callback that is called when the frame rendering is done by the graphics driver.
2026 /// A callback of the following type may be used:
2028 /// void MyFunction( int frameId )
2030 /// This callback will be deleted once it is called.
2032 /// Ownership of the callback is passed onto this class
2035 /// <param name="callback">The function to call</param>
2036 /// <param name="frameId">The Id to specify the frame. It will be passed when the callback is called.</param>
2037 /// <exception cref="ArgumentNullException">This exception can occur by the callback is null.</exception>
2038 [EditorBrowsable(EditorBrowsableState.Never)]
2039 public void AddFrameRenderedCallback(FrameCallbackType callback, int frameId)
2041 var assignedKey = AddInterHookCallback(callback, frameId);
2042 Interop.WindowInternal.AddFrameRenderedCallback(SwigCPtr, new HandleRef(this, Marshal.GetFunctionPointerForDelegate<Delegate>(internalHookFrameCallback)), assignedKey);
2044 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
2048 /// Adds a callback that is called when the frame is displayed on the display.
2049 /// A callback of the following type may be used:
2051 /// void MyFunction( int frameId )
2053 /// This callback will be deleted once it is called.
2055 /// Ownership of the callback is passed onto this class
2058 /// <param name="callback">The function to call</param>
2059 /// <param name="frameId">The Id to specify the frame. It will be passed when the callback is called.</param>
2060 /// <exception cref="ArgumentNullException">This exception can occur by the callback is null.</exception>
2061 [EditorBrowsable(EditorBrowsableState.Never)]
2062 public void AddFramePresentedCallback(FrameCallbackType callback, int frameId)
2064 var assignedKey = AddInterHookCallback(callback, frameId);
2065 Interop.WindowInternal.AddFramePresentedCallback(SwigCPtr, new HandleRef(this, Marshal.GetFunctionPointerForDelegate<Delegate>(internalHookFrameCallback)), assignedKey);
2067 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
2071 /// Search through this Window for a Layer with the given unique ID.
2073 /// <param name="id">The ID of the Layer to find.</param>
2074 /// <remarks>Hidden-API</remarks>
2075 /// <returns>A handle to the Layer if found, or an empty handle if not.</returns>
2076 [EditorBrowsable(EditorBrowsableState.Never)]
2077 public Layer FindLayerByID(uint id)
2079 Layer defaultLayer = this.GetDefaultLayer();
2080 IntPtr cPtr = Interop.Actor.FindChildById(defaultLayer.SwigCPtr, id);
2081 Layer ret = this.GetInstanceSafely<Layer>(cPtr);
2083 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
2088 /// Get Native Window handle.
2090 /// How to get Native Window handle
2092 /// Window window = NUIApplication.GetDefaultWindow();
2093 /// var handle = window.NativeHandle;
2094 /// if(handle.IsInvalid == false)
2096 /// IntPtr nativeHandle = handle.DangerousGetHandle();
2097 /// // do something with nativeHandle
2102 /// <since_tizen> 9 </since_tizen>
2103 public SafeHandle NativeHandle
2107 return new NUI.SafeNativeWindowHandle(this);