2 * Copyright(c) 2021 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
18 extern alias TizenSystemInformation;
19 using TizenSystemInformation.Tizen.System;
22 using System.ComponentModel;
23 using System.Collections.Generic;
24 using System.Runtime.InteropServices;
26 using Tizen.NUI.BaseComponents;
31 /// The window class is used internally for drawing.<br />
32 /// The window has an orientation and indicator properties.<br />
34 /// <since_tizen> 3 </since_tizen>
35 public partial class Window : BaseHandle
37 private HandleRef stageCPtr;
38 private Layer rootLayer;
39 private string windowTitle;
40 private List<Layer> childLayers = new List<Layer>();
41 private LayoutController localController;
43 static internal bool IsSupportedMultiWindow()
45 bool isSupported = false;
48 Information.TryGetValue("http://tizen.org/feature/opengles.surfaceless_context", out isSupported);
50 catch (DllNotFoundException e)
52 Tizen.Log.Fatal("NUI", $"{e}\n");
57 internal Window(global::System.IntPtr cPtr, bool cMemoryOwn) : base(cPtr, cMemoryOwn)
59 if (Interop.Stage.IsInstalled())
61 stageCPtr = new global::System.Runtime.InteropServices.HandleRef(this, Interop.Stage.GetCurrent());
63 localController = new LayoutController(this);
64 NUILog.Debug("layoutController id:" + localController.GetId());
69 /// A helper method to get the current window where the view is added
71 /// <param name="view">The View added to the window</param>
72 /// <returns>A Window.</returns>
73 [EditorBrowsable(EditorBrowsableState.Never)]
74 static public Window Get(View view)
78 NUILog.Error("if there is no view, it can not get a window");
82 //to fix memory leak issue, match the handle count with native side.
83 Window ret = view.GetInstanceSafely<Window>(Interop.Window.Get(View.getCPtr(view)));
84 if (NDalicPINVOKE.SWIGPendingException.Pending)throw NDalicPINVOKE.SWIGPendingException.Retrieve();
89 /// Creates a new Window.<br />
90 /// This creates an extra window in addition to the default main window<br />
92 /// <param name="windowPosition">The position and size of the Window.</param>
93 /// <param name="isTranslucent">Whether Window is translucent.</param>
94 /// <returns>A new Window.</returns>
95 /// <since_tizen> 6 </since_tizen>
96 /// <feature> http://tizen.org/feature/opengles.surfaceless_context </feature>
97 /// <exception cref="NotSupportedException">The required feature is not supported.</exception>
98 public Window(Rectangle windowPosition = null, bool isTranslucent = false) : this(Interop.Window.New(Rectangle.getCPtr(windowPosition), "", isTranslucent), true)
100 if (IsSupportedMultiWindow() == false)
102 NUILog.Error("This device does not support surfaceless_context. So Window cannot be created. ");
104 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
108 /// Creates a new Window with a specific name.<br />
109 /// This creates an extra window in addition to the default main window<br />
111 /// <param name="name">The name for extra window. </param>
112 /// <param name="windowPosition">The position and size of the Window.</param>
113 /// <param name="isTranslucent">Whether Window is translucent.</param>
114 /// <returns>A new Window.</returns>
115 /// <since_tizen> 6 </since_tizen>
116 /// <feature> http://tizen.org/feature/opengles.surfaceless_context </feature>
117 /// <exception cref="NotSupportedException">The required feature is not supported.</exception>
118 public Window(string name, Rectangle windowPosition = null, bool isTranslucent = false) : this(Interop.Window.New(Rectangle.getCPtr(windowPosition), name, isTranslucent), true)
120 if (IsSupportedMultiWindow() == false)
122 NUILog.Error("This device does not support surfaceless_context. So Window cannot be created. ");
124 this.windowTitle = name;
125 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
129 /// Enumeration for orientation of the window is the way in which a rectangular page is oriented for normal viewing.
131 /// <since_tizen> 3 </since_tizen>
132 public enum WindowOrientation
135 /// Portrait orientation. The height of the display area is greater than the width.
137 /// <since_tizen> 3 </since_tizen>
140 /// Landscape orientation. A wide view area is needed.
142 /// <since_tizen> 3 </since_tizen>
145 /// Portrait inverse orientation.
147 /// <since_tizen> 3 </since_tizen>
148 PortraitInverse = 180,
150 /// Landscape inverse orientation.
152 /// <since_tizen> 3 </since_tizen>
153 LandscapeInverse = 270,
155 /// No orientation. It is for the preferred orientation
156 /// Especially, NoOrientationPreference only has the effect for the preferred orientation.
157 /// It is used to unset the preferred orientation with SetPreferredOrientation.
159 [EditorBrowsable(EditorBrowsableState.Never)]
160 NoOrientationPreference = -1
164 /// Enumeration for the key grab mode for platform-level APIs.
166 /// <since_tizen> 3 </since_tizen>
167 public enum KeyGrabMode
170 /// Grabs a key only when on the top of the grabbing-window stack mode.
174 /// Grabs a key together with the other client window(s) mode.
178 /// 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.
182 /// Grabs a key exclusively regardless of the grabbing-window's position on the window stack mode.
188 /// Enumeration for transition effect's state.
190 [Obsolete("Please do not use! This will be removed. Please use Window.EffectState instead!")]
191 [EditorBrowsable(EditorBrowsableState.Never)]
192 // This is already deprecated, so suppress warning here.
193 [System.Diagnostics.CodeAnalysis.SuppressMessage("Naming", "CA1717:Only FlagsAttribute enums should have plural names", Justification = "<Pending>")]
194 public enum EffectStates
199 [Obsolete("Please do not use! This will be removed. Please use Window.EffectState.None instead!")]
200 [EditorBrowsable(EditorBrowsableState.Never)]
203 /// Transition effect is started.
205 [Obsolete("Please do not use! This will be removed. Please use Window.EffectState.Start instead!")]
206 [EditorBrowsable(EditorBrowsableState.Never)]
209 /// Transition effect is ended.
211 [Obsolete("Please do not use! This will be removed. Please use Window.EffectState.End instead!")]
212 [EditorBrowsable(EditorBrowsableState.Never)]
217 /// Enumeration for transition effect's state.
219 [EditorBrowsable(EditorBrowsableState.Never)]
220 public enum EffectState
225 [EditorBrowsable(EditorBrowsableState.Never)]
228 /// Transition effect is started.
230 [EditorBrowsable(EditorBrowsableState.Never)]
233 /// Transition effect is ended.
235 [EditorBrowsable(EditorBrowsableState.Never)]
240 /// Enumeration for transition effect's type.
242 [Obsolete("Please do not use! This will be removed. Please use Window.EffectType instead!")]
243 [EditorBrowsable(EditorBrowsableState.Never)]
244 // This is already deprecated, so suppress warning here.
245 [System.Diagnostics.CodeAnalysis.SuppressMessage("Naming", "CA1717:Only FlagsAttribute enums should have plural names", Justification = "<Pending>")]
246 public enum EffectTypes
251 [Obsolete("Please do not use! This will be removed. Please use Window.EffectType.None instead!")]
252 [EditorBrowsable(EditorBrowsableState.Never)]
255 /// Window show effect.
257 [Obsolete("Please do not use! This will be removed. Please use Window.EffectType.Show instead!")]
258 [EditorBrowsable(EditorBrowsableState.Never)]
261 /// Window hide effect.
263 [Obsolete("Please do not use! This will be removed. Please use Window.EffectType.Hide instead!")]
264 [EditorBrowsable(EditorBrowsableState.Never)]
269 /// Enumeration for transition effect's type.
271 [EditorBrowsable(EditorBrowsableState.Never)]
272 public enum EffectType
277 [EditorBrowsable(EditorBrowsableState.Never)]
280 /// Window show effect.
282 [EditorBrowsable(EditorBrowsableState.Never)]
285 /// Window hide effect.
287 [EditorBrowsable(EditorBrowsableState.Never)]
292 /// Enumeration for result of window operation.
294 internal enum OperationResult
297 /// Failed for unknown reason
305 /// Permission denied
309 /// The operation is not supported.
315 /// Enumeration for window resized mode by display server.
317 [EditorBrowsable(EditorBrowsableState.Never)]
318 public enum ResizeDirection
321 /// Start resizing window to the top-left edge.
323 [EditorBrowsable(EditorBrowsableState.Never)]
326 /// Start resizing window to the top side.
328 [EditorBrowsable(EditorBrowsableState.Never)]
331 /// Start resizing window to the top-right edge.
333 [EditorBrowsable(EditorBrowsableState.Never)]
336 /// Start resizing window to the left side.
338 [EditorBrowsable(EditorBrowsableState.Never)]
341 /// Start resizing window to the right side.
343 [EditorBrowsable(EditorBrowsableState.Never)]
346 /// Start resizing window to the bottom-left edge.
348 [EditorBrowsable(EditorBrowsableState.Never)]
351 /// Start resizing window to the bottom side.
353 [EditorBrowsable(EditorBrowsableState.Never)]
356 /// Start resizing window to the bottom-right edge.
358 [EditorBrowsable(EditorBrowsableState.Never)]
364 /// The stage instance property (read-only).<br />
365 /// Gets the current window.<br />
367 /// <since_tizen> 3 </since_tizen>
368 public static Window Instance { get; internal set; }
371 /// Gets or sets a window type.
372 /// Most of window type can be set to use WindowType, except for IME type.
373 /// IME type can be set to use one of NUIApplication's constrcutors.
375 /// <since_tizen> 3 </since_tizen>
376 public WindowType Type
380 WindowType ret = (WindowType)Interop.Window.GetType(SwigCPtr);
381 if (NDalicPINVOKE.SWIGPendingException.Pending) throw new InvalidOperationException("FATAL: get Exception", NDalicPINVOKE.SWIGPendingException.Retrieve());
386 Interop.Window.SetType(SwigCPtr, (int)value);
387 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
392 /// Gets/Sets a window title.
394 /// <since_tizen> 4 </since_tizen>
404 SetClass(windowTitle, "");
409 /// The rendering behavior of a Window.
411 /// <since_tizen> 5 </since_tizen>
412 public RenderingBehaviorType RenderingBehavior
416 return GetRenderingBehavior();
420 SetRenderingBehavior(value);
425 /// The window size property (read-only).
427 /// <since_tizen> 3 </since_tizen>
432 Size2D ret = GetSize();
438 /// The background color property.
440 /// <since_tizen> 3 </since_tizen>
441 public Color BackgroundColor
445 SetBackgroundColor(value);
449 Color ret = GetBackgroundColor();
455 /// The DPI property (read-only).<br />
456 /// Retrieves the DPI of the display device to which the Window is connected.<br />
458 /// <since_tizen> 3 </since_tizen>
468 /// The layer count property (read-only).<br />
469 /// Queries the number of on-Window layers.<br />
471 /// <since_tizen> 3 </since_tizen>
472 public uint LayerCount
476 return GetLayerCount();
481 /// Gets or sets a size of the window.
483 /// <exception cref="ArgumentNullException"> Thrown when value is null. </exception>
484 /// <since_tizen> 4 </since_tizen>
485 public Size2D WindowSize
489 return GetWindowSize();
493 SetWindowSize(value);
498 /// Gets or sets a position of the window.
500 /// <exception cref="ArgumentNullException"> Thrown when value is null. </exception>
501 /// <since_tizen> 4 </since_tizen>
502 public Position2D WindowPosition
506 return GetPosition();
515 /// Sets position and size of the window. This API guarantees that
516 /// both moving and resizing of window will appear on the screen at once.
518 [EditorBrowsable(EditorBrowsableState.Never)]
519 public Rectangle WindowPositionSize
523 Position2D position = GetPosition();
524 Size2D size = GetSize();
525 Rectangle ret = new Rectangle(position.X, position.Y, size.Width, size.Height);
531 SetPositionSize(value);
535 internal static Vector4 DEFAULT_BACKGROUND_COLOR
539 global::System.IntPtr cPtr = Interop.Stage.DefaultBackgroundColorGet();
540 Vector4 ret = (cPtr == global::System.IntPtr.Zero) ? null : new Vector4(cPtr, false);
541 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
546 internal static Vector4 DEBUG_BACKGROUND_COLOR
550 global::System.IntPtr cPtr = Interop.Stage.DebugBackgroundColorGet();
551 Vector4 ret = (cPtr == global::System.IntPtr.Zero) ? null : new Vector4(cPtr, false);
552 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
557 internal List<Layer> LayersChildren
566 /// Get the LayoutController for this Window.
568 internal LayoutController LayoutController
572 return localController;
577 /// Feed a key-event into the window.
579 /// <param name="keyEvent">The key event to feed.</param>
580 /// <since_tizen> 4 </since_tizen>
581 [Obsolete("Please do not use! This will be deprecated! Please use FeedKey(Key keyEvent) instead!")]
582 public static void FeedKeyEvent(Key keyEvent)
584 Interop.Window.FeedKeyEvent(Key.getCPtr(keyEvent));
585 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
589 /// Sets whether the window accepts a focus or not.
591 /// <param name="accept">If a focus is accepted or not. The default is true.</param>
592 /// <since_tizen> 3 </since_tizen>
593 public void SetAcceptFocus(bool accept)
595 Interop.Window.SetAcceptFocus(SwigCPtr, accept);
596 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
600 /// Returns whether the window accepts a focus or not.
602 /// <returns>True if the window accepts a focus, false otherwise.</returns>
603 /// <since_tizen> 3 </since_tizen>
604 public bool IsFocusAcceptable()
606 bool ret = Interop.Window.IsFocusAcceptable(SwigCPtr);
607 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
613 /// Shows the window if it is hidden.
615 /// <since_tizen> 3 </since_tizen>
618 Interop.Window.Show(SwigCPtr);
619 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
623 /// Hides the window if it is showing.
625 /// <since_tizen> 3 </since_tizen>
628 Interop.Window.Hide(SwigCPtr);
629 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
633 /// Retrieves whether the window is visible or not.
635 /// <returns>True if the window is visible.</returns>
636 /// <since_tizen> 3 </since_tizen>
637 public bool IsVisible()
639 bool temp = Interop.Window.IsVisible(SwigCPtr);
640 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
645 /// Gets the count of supported auxiliary hints of the window.
647 /// <returns>The number of supported auxiliary hints.</returns>
648 /// <since_tizen> 3 </since_tizen>
649 public uint GetSupportedAuxiliaryHintCount()
651 uint ret = Interop.Window.GetSupportedAuxiliaryHintCount(SwigCPtr);
652 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
657 /// Gets the supported auxiliary hint string of the window.
659 /// <param name="index">The index of the supported auxiliary hint lists.</param>
660 /// <returns>The auxiliary hint string of the index.</returns>
661 /// <since_tizen> 3 </since_tizen>
662 public string GetSupportedAuxiliaryHint(uint index)
664 string ret = Interop.Window.GetSupportedAuxiliaryHint(SwigCPtr, index);
665 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
670 /// Creates an auxiliary hint of the window.
672 /// <param name="hint">The auxiliary hint string.</param>
673 /// <param name="value">The value string.</param>
674 /// <returns>The ID of created auxiliary hint, or 0 on failure.</returns>
675 /// <since_tizen> 3 </since_tizen>
676 public uint AddAuxiliaryHint(string hint, string value)
678 uint ret = Interop.Window.AddAuxiliaryHint(SwigCPtr, hint, value);
679 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
684 /// Removes an auxiliary hint of the window.
686 /// <param name="id">The ID of the auxiliary hint.</param>
687 /// <returns>True if no error occurred, false otherwise.</returns>
688 /// <since_tizen> 3 </since_tizen>
689 public bool RemoveAuxiliaryHint(uint id)
691 bool ret = Interop.Window.RemoveAuxiliaryHint(SwigCPtr, id);
692 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
697 /// Changes a value of the auxiliary hint.
699 /// <param name="id">The auxiliary hint ID.</param>
700 /// <param name="value">The value string to be set.</param>
701 /// <returns>True if no error occurred, false otherwise.</returns>
702 /// <since_tizen> 3 </since_tizen>
703 public bool SetAuxiliaryHintValue(uint id, string value)
705 bool ret = Interop.Window.SetAuxiliaryHintValue(SwigCPtr, id, value);
706 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
711 /// Gets a value of the auxiliary hint.
713 /// <param name="id">The auxiliary hint ID.</param>
714 /// <returns>The string value of the auxiliary hint ID, or an empty string if none exists.</returns>
715 /// <since_tizen> 3 </since_tizen>
716 public string GetAuxiliaryHintValue(uint id)
718 string ret = Interop.Window.GetAuxiliaryHintValue(SwigCPtr, id);
719 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
724 /// Gets an ID of the auxiliary hint string.
726 /// <param name="hint">The auxiliary hint string.</param>
727 /// <returns>The ID of auxiliary hint string, or 0 on failure.</returns>
728 /// <since_tizen> 3 </since_tizen>
729 public uint GetAuxiliaryHintId(string hint)
731 uint ret = Interop.Window.GetAuxiliaryHintId(SwigCPtr, hint);
732 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
737 /// Sets a region to accept input events.
739 /// <param name="inputRegion">The region to accept input events.</param>
740 /// <since_tizen> 3 </since_tizen>
741 public void SetInputRegion(Rectangle inputRegion)
743 Interop.Window.IncludeInputRegion(SwigCPtr, Rectangle.getCPtr(inputRegion));
744 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
748 /// Sets a priority level for the specified notification window.
750 /// <param name="level">The notification window level.</param>
751 /// <returns>True if no error occurred, false otherwise.</returns>
752 /// <since_tizen> 3 </since_tizen>
753 public bool SetNotificationLevel(NotificationLevel level)
755 var ret = (OperationResult)Interop.Window.SetNotificationLevel(SwigCPtr, (int)level);
756 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
757 return ret == OperationResult.Succeed;
761 /// Gets a priority level for the specified notification window.
763 /// <returns>The notification window level.</returns>
764 /// <since_tizen> 3 </since_tizen>
765 public NotificationLevel GetNotificationLevel()
767 NotificationLevel ret = (NotificationLevel)Interop.Window.GetNotificationLevel(SwigCPtr);
768 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
773 /// Sets a transparent window's visual state to opaque. <br />
774 /// If a visual state of a transparent window is opaque, <br />
775 /// then the window manager could handle it as an opaque window when calculating visibility.
777 /// <param name="opaque">Whether the window's visual state is opaque.</param>
778 /// <remarks>This will have no effect on an opaque window. <br />
779 /// It doesn't change transparent window to opaque window but lets the window manager know the visual state of the window.
781 /// <since_tizen> 3 </since_tizen>
782 public void SetOpaqueState(bool opaque)
784 Interop.Window.SetOpaqueState(SwigCPtr, opaque);
785 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
789 /// Returns whether a transparent window's visual state is opaque or not.
791 /// <returns>True if the window's visual state is opaque, false otherwise.</returns>
792 /// <remarks> The return value has no meaning on an opaque window. </remarks>
793 /// <since_tizen> 3 </since_tizen>
794 public bool IsOpaqueState()
796 bool ret = Interop.Window.IsOpaqueState(SwigCPtr);
797 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
802 /// Sets a window's screen off mode.
804 /// <param name="screenOffMode">The screen mode.</param>
805 /// <returns>True if no error occurred, false otherwise.</returns>
806 /// <since_tizen> 4 </since_tizen>
807 public bool SetScreenOffMode(ScreenOffMode screenOffMode)
809 var ret = (OperationResult)Interop.Window.SetScreenOffMode(SwigCPtr, (int)screenOffMode);
810 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
811 return ret == OperationResult.Succeed;
815 /// Gets the screen mode of the window.
817 /// <returns>The screen off mode.</returns>
818 /// <since_tizen> 4 </since_tizen>
819 public ScreenOffMode GetScreenOffMode()
821 ScreenOffMode ret = (ScreenOffMode)Interop.Window.GetScreenOffMode(SwigCPtr);
822 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
827 /// Sets preferred brightness of the window.
829 /// <param name="brightness">The preferred brightness (0 to 100).</param>
830 /// <returns>True if no error occurred, false otherwise.</returns>
831 /// <since_tizen> 3 </since_tizen>
832 public bool SetBrightness(int brightness)
834 var ret = (OperationResult)Interop.Window.SetBrightness(SwigCPtr, brightness);
835 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
836 return ret == OperationResult.Succeed;
840 /// Gets the preferred brightness of the window.
842 /// <returns>The preferred brightness.</returns>
843 /// <since_tizen> 3 </since_tizen>
844 public int GetBrightness()
846 int ret = Interop.Window.GetBrightness(SwigCPtr);
847 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
852 /// Sets the window name and the class string.
854 /// <param name="name">The name of the window.</param>
855 /// <param name="klass">The class of the window.</param>
856 /// <since_tizen> 4 </since_tizen>
857 public void SetClass(string name, string klass)
859 Interop.Window.SetClass(SwigCPtr, name, klass);
860 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
864 /// Raises the window to the top of the window stack.
866 /// <since_tizen> 3 </since_tizen>
869 Interop.Window.Raise(SwigCPtr);
870 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
874 /// Lowers the window to the bottom of the window stack.
876 /// <since_tizen> 3 </since_tizen>
879 Interop.Window.Lower(SwigCPtr);
880 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
884 /// Activates the window to the top of the window stack even it is iconified.
886 /// <since_tizen> 3 </since_tizen>
887 public void Activate()
889 Interop.Window.Activate(SwigCPtr);
890 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
894 /// Gets the default ( root ) layer.
896 /// <returns>The root layer.</returns>
897 /// <since_tizen> 3 </since_tizen>
898 public Layer GetDefaultLayer()
900 return this.GetRootLayer();
904 /// Add a child view to window.
906 /// <param name="view">the child should be added to the window.</param>
907 /// <since_tizen> 3 </since_tizen>
908 public void Add(View view)
910 Interop.Actor.Add(Layer.getCPtr(GetRootLayer()), View.getCPtr(view));
911 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
912 this.GetRootLayer().AddViewToLayerList(view); // Maintain the children list in the Layer
915 view.InternalParent = this.GetRootLayer();
917 this.GetRootLayer().LayoutCount += view.LayoutCount;
922 /// Remove a child view from window.
924 /// <param name="view">the child to be removed.</param>
925 /// <since_tizen> 3 </since_tizen>
926 public void Remove(View view)
928 Interop.Actor.Remove(Layer.getCPtr(GetRootLayer()), View.getCPtr(view));
929 this.GetRootLayer().RemoveViewFromLayerList(view); // Maintain the children list in the Layer
932 view.InternalParent = null;
934 this.GetRootLayer().LayoutCount -= view.LayoutCount;
939 /// Retrieves the layer at a specified depth.
941 /// <param name="depth">The layer's depth index.</param>
942 /// <returns>The layer found at the given depth.</returns>
943 /// <since_tizen> 3 </since_tizen>
944 public Layer GetLayer(uint depth)
946 if (depth < LayersChildren?.Count)
948 Layer ret = LayersChildren?[Convert.ToInt32(depth)];
958 /// Destroy the window immediately.
960 [EditorBrowsable(EditorBrowsableState.Never)]
961 public void Destroy()
967 /// Keep rendering for at least the given amount of time.
969 /// <param name="durationSeconds">Time to keep rendering, 0 means render at least one more frame.</param>
970 /// <since_tizen> 3 </since_tizen>
971 public void KeepRendering(float durationSeconds)
973 Interop.Stage.KeepRendering(stageCPtr, durationSeconds);
974 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
978 /// Grabs the key specified by a key for a window only when a window is the topmost window.<br />
979 /// This function can be used for following example scenarios: <br />
980 /// - Mobile - Using volume up or down as zoom up or down in camera apps.<br />
982 /// <param name="DaliKey">The key code to grab.</param>
983 /// <returns>True if the grab succeeds.</returns>
984 /// <since_tizen> 3 </since_tizen>
985 public bool GrabKeyTopmost(int DaliKey)
987 bool ret = Interop.Window.GrabKeyTopmost(HandleRef.ToIntPtr(this.SwigCPtr), DaliKey);
988 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
993 /// Ungrabs the key specified by a key for the window.<br />
994 /// 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 />
996 /// <param name="DaliKey">The key code to ungrab.</param>
997 /// <returns>True if the ungrab succeeds.</returns>
998 /// <since_tizen> 3 </since_tizen>
999 public bool UngrabKeyTopmost(int DaliKey)
1001 bool ret = Interop.Window.UngrabKeyTopmost(HandleRef.ToIntPtr(this.SwigCPtr), DaliKey);
1002 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1007 /// Grabs the key specified by a key for a window in a GrabMode. <br />
1008 /// Details: This function can be used for following example scenarios: <br />
1009 /// - TV - A user might want to change the volume or channel of the background TV contents while focusing on the foregrund app. <br />
1010 /// - Mobile - When a user presses the Home key, the homescreen appears regardless of the current foreground app. <br />
1011 /// - Mobile - Using the volume up or down as zoom up or down in camera apps. <br />
1013 /// <param name="DaliKey">The key code to grab.</param>
1014 /// <param name="GrabMode">The grab mode for the key.</param>
1015 /// <returns>True if the grab succeeds.</returns>
1016 /// <since_tizen> 3 </since_tizen>
1017 public bool GrabKey(int DaliKey, KeyGrabMode GrabMode)
1019 bool ret = Interop.Window.GrabKey(HandleRef.ToIntPtr(this.SwigCPtr), DaliKey, (int)GrabMode);
1020 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1025 /// Ungrabs the key specified by a key for a window.<br />
1026 /// 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 />
1028 /// <param name="DaliKey">The key code to ungrab.</param>
1029 /// <returns>True if the ungrab succeeds.</returns>
1030 /// <since_tizen> 3 </since_tizen>
1031 public bool UngrabKey(int DaliKey)
1033 bool ret = Interop.Window.UngrabKey(HandleRef.ToIntPtr(this.SwigCPtr), DaliKey);
1034 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1039 /// Sets the keyboard repeat information.
1041 /// <param name="rate">The key repeat rate value in seconds.</param>
1042 /// <param name="delay">The key repeat delay value in seconds.</param>
1043 /// <returns>True if setting the keyboard repeat succeeds.</returns>
1044 /// <since_tizen> 5 </since_tizen>
1045 public bool SetKeyboardRepeatInfo(float rate, float delay)
1047 bool ret = Interop.Window.SetKeyboardRepeatInfo(rate, delay);
1048 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1053 /// Gets the keyboard repeat information.
1055 /// <param name="rate">The key repeat rate value in seconds.</param>
1056 /// <param name="delay">The key repeat delay value in seconds.</param>
1057 /// <returns>True if setting the keyboard repeat succeeds.</returns>
1058 /// <since_tizen> 5 </since_tizen>
1059 public bool GetKeyboardRepeatInfo(out float rate, out float delay)
1061 bool ret = Interop.Window.GetKeyboardRepeatInfo(out rate, out delay);
1062 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1067 /// Adds a layer to the stage.
1069 /// <param name="layer">Layer to add.</param>
1070 /// <exception cref="ArgumentNullException"> Thrown when layer is null. </exception>
1071 /// <since_tizen> 3 </since_tizen>
1072 public void AddLayer(Layer layer)
1078 /// Removes a layer from the stage.
1080 /// <param name="layer">Layer to remove.</param>
1081 /// <exception cref="ArgumentNullException"> Thrown when layer is null. </exception>
1082 /// <since_tizen> 3 </since_tizen>
1083 public void RemoveLayer(Layer layer)
1089 /// Feeds a key event into the window.
1091 /// <param name="keyEvent">The key event to feed.</param>
1092 /// <since_tizen> 5 </since_tizen>
1093 public void FeedKey(Key keyEvent)
1095 Interop.Window.FeedKeyEvent(SwigCPtr, Key.getCPtr(keyEvent));
1096 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1100 /// Feeds a touch point into the window.
1102 /// <param name="touchPoint">The touch point to feed.</param>
1103 /// <param name="timeStamp">The timeStamp.</param>
1104 internal void FeedTouch(TouchPoint touchPoint, int timeStamp)
1106 Interop.Window.FeedTouchPoint(SwigCPtr, TouchPoint.getCPtr(touchPoint), timeStamp);
1107 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1111 /// Feeds a wheel event into the window.
1113 /// <param name="wheelEvent">The wheel event to feed.</param>
1114 internal void FeedWheel(Wheel wheelEvent)
1116 Interop.Window.FeedWheelEvent(SwigCPtr, Wheel.getCPtr(wheelEvent));
1117 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1121 /// Allows at least one more render, even when paused.
1122 /// The window should be shown, not minimised.
1124 /// <since_tizen> 4 </since_tizen>
1125 public void RenderOnce()
1127 Interop.Window.RenderOnce(SwigCPtr);
1128 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1132 /// Sets whether the window is transparent or not.
1134 /// <param name="transparent">Whether the window is transparent or not.</param>
1135 /// <since_tizen> 5 </since_tizen>
1136 public void SetTransparency(bool transparent)
1138 Interop.Window.SetTransparency(SwigCPtr, transparent);
1139 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1141 // Setting transparency of the window should request a relayout of the tree in the case the window changes from fully transparent.
1145 /// Sets parent window of the window.
1146 /// After setting that, these windows do together when raise-up, lower and iconified/deiconified.
1147 /// Initially, the window is located on top of the parent. The window can go below parent by calling Lower().
1148 /// If parent's window stack is changed by calling Raise() or Lower(), child windows are located on top of the parent again.
1150 /// <param name="parent">The parent window.</param>
1151 /// <since_tizen> 6 </since_tizen>
1152 /// <feature> http://tizen.org/feature/opengles.surfaceless_context </feature>
1153 /// <exception cref="NotSupportedException">The required feature is not supported.</exception>
1154 public void SetParent(Window parent)
1156 if (IsSupportedMultiWindow() == false)
1158 NUILog.Error("This device does not support surfaceless_context. So Window cannot be created. ");
1160 Interop.Window.SetParent(SwigCPtr, Window.getCPtr(parent));
1161 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1165 /// Sets parent window of the window.
1166 /// After setting that, these windows do together when raise-up, lower and iconified/deiconified.
1167 /// This function has the additional flag whether the child is located above or below of the parent.
1169 /// <param name="parent">The parent window.</param>
1170 /// <param name="belowParent">The flag is whether the child is located above or below of the parent.</param>
1171 /// <feature> http://tizen.org/feature/opengles.surfaceless_context </feature>
1172 /// <exception cref="NotSupportedException">The required feature is not supported.</exception>
1173 [EditorBrowsable(EditorBrowsableState.Never)]
1174 public void SetParent(Window parent, bool belowParent)
1176 if (IsSupportedMultiWindow() == false)
1178 NUILog.Error("This device does not support surfaceless_context. So Window cannot be created. ");
1180 Interop.Window.SetParentWithStack(SwigCPtr, Window.getCPtr(parent), belowParent);
1181 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1185 /// Unsets parent window of the window.
1186 /// After unsetting, the window is disconnected his parent window.
1188 /// <since_tizen> 6 </since_tizen>
1189 /// <feature> http://tizen.org/feature/opengles.surfaceless_context </feature>
1190 /// <exception cref="NotSupportedException">The required feature is not supported.</exception>
1191 public void Unparent()
1193 if (IsSupportedMultiWindow() == false)
1195 NUILog.Error("Fail to create window. because this device does not support opengles.surfaceless_context.");
1197 Interop.Window.Unparent(SwigCPtr);
1198 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1202 /// Gets parent window of the window.
1204 /// <returns>The parent window of the window.</returns>
1205 /// <since_tizen> 6 </since_tizen>
1206 /// <feature> http://tizen.org/feature/opengles.surfaceless_context </feature>
1207 /// <exception cref="NotSupportedException">The required feature is not supported.</exception>
1208 [System.Diagnostics.CodeAnalysis.SuppressMessage("Design", "CA1721: Property names should not match get methods")]
1209 public Window GetParent()
1211 if (IsSupportedMultiWindow() == false)
1213 NUILog.Error("This device does not support surfaceless_context. So Window cannot be created. ");
1215 Window ret = this.GetInstanceSafely<Window>(Interop.Window.GetParent(SwigCPtr));
1216 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1220 /// This will be public opened in tizen_next after ACR done. Before ACR, need to be hidden as inhouse API.
1221 [EditorBrowsable(EditorBrowsableState.Never)]
1222 public void ObjectDump()
1224 Layer rootLayer = GetRootLayer();
1225 foreach (View view in rootLayer.Children)
1231 internal static bool IsInstalled()
1233 bool ret = Interop.Stage.IsInstalled();
1234 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1239 /// Adds an orientation to the list of available orientations.
1241 /// <param name="orientation">The available orientation to add</param>
1242 /// <since_tizen> 6 </since_tizen>
1243 public void AddAvailableOrientation(Window.WindowOrientation orientation)
1245 Interop.Window.AddAvailableOrientation(SwigCPtr, (int)orientation);
1246 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1250 /// Removes an orientation from the list of available orientations.
1252 /// <param name="orientation">The available orientation to remove.</param>
1253 /// <since_tizen> 6 </since_tizen>
1254 public void RemoveAvailableOrientation(Window.WindowOrientation orientation)
1256 Interop.Window.RemoveAvailableOrientation(SwigCPtr, (int)orientation);
1257 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1261 /// Sets a preferred orientation.
1263 /// <param name="orientation">The preferred orientation.</param>
1264 /// <since_tizen> 6 </since_tizen>
1265 public void SetPreferredOrientation(Window.WindowOrientation orientation)
1267 Interop.Window.SetPreferredOrientation(SwigCPtr, (int)orientation);
1268 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1272 /// Gets the preferred orientation.
1274 /// <since_tizen> 6 </since_tizen>
1275 /// <returns>The preferred orientation if previously set, or none.</returns>
1276 public Window.WindowOrientation GetPreferredOrientation()
1278 Window.WindowOrientation ret = (Window.WindowOrientation)Interop.Window.GetPreferredOrientation(SwigCPtr);
1279 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1284 /// Gets current orientation of the window.
1286 /// <since_tizen> 6 </since_tizen>
1287 /// <returns>The current window orientation if previously set, or none.</returns>
1288 [EditorBrowsable(EditorBrowsableState.Never)]
1289 public Window.WindowOrientation GetCurrentOrientation()
1291 Window.WindowOrientation ret = (Window.WindowOrientation)Interop.Window.GetCurrentOrientation(SwigCPtr);
1292 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1297 /// Sets available orientations of the window.
1298 /// This API is for setting several orientations one time.
1300 /// <param name="orientations">The list of orientations.</param>
1301 /// <since_tizen> 6 </since_tizen>
1302 [EditorBrowsable(EditorBrowsableState.Never)]
1303 public void SetAvailableOrientations(List<Window.WindowOrientation> orientations)
1305 if (null == orientations)
1307 throw new ArgumentNullException(nameof(orientations));
1310 PropertyArray orientationArray = new PropertyArray();
1311 for (int i = 0; i < orientations.Count; i++)
1313 PropertyValue value = new PropertyValue((int)orientations[i]);
1314 orientationArray.PushBack(value);
1318 Interop.Window.SetAvailableOrientations(SwigCPtr, PropertyArray.getCPtr(orientationArray), orientations.Count);
1319 orientationArray.Dispose();
1320 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1324 /// Get native window ID
1326 /// <returns>native window ID</returns>
1327 [EditorBrowsable(EditorBrowsableState.Never)]
1328 public int GetNativeId()
1330 int ret = Interop.Window.GetNativeId(SwigCPtr);
1331 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1335 internal Any GetNativeHandle()
1337 Any ret = new Any(Interop.WindowInternal.WindowGetNativeHandle(SwigCPtr), true);
1338 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1342 internal void Add(Layer layer)
1346 throw new ArgumentNullException(nameof(layer));
1348 Interop.Window.Add(SwigCPtr, Layer.getCPtr(layer));
1349 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1351 LayersChildren?.Add(layer);
1352 layer.SetWindow(this);
1355 internal void Remove(Layer layer)
1359 throw new ArgumentNullException(nameof(layer));
1361 Interop.Window.Remove(SwigCPtr, Layer.getCPtr(layer));
1362 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1364 LayersChildren?.Remove(layer);
1365 layer.SetWindow(null);
1368 internal Vector2 GetSize()
1370 var val = new Uint16Pair(Interop.Window.GetSize(SwigCPtr), true);
1371 Vector2 ret = new Vector2(val.GetWidth(), val.GetHeight());
1372 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1377 /// This will be public opened in next tizen after ACR done. Before ACR, need to be hidden as inhouse API.
1378 [EditorBrowsable(EditorBrowsableState.Never)]
1379 public RenderTaskList GetRenderTaskList()
1381 RenderTaskList ret = new RenderTaskList(Interop.Stage.GetRenderTaskList(stageCPtr), true);
1382 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1387 /// Queries the number of on-window layers.
1389 /// <returns>The number of layers.</returns>
1390 /// <remarks>Note that a default layer is always provided (count >= 1).</remarks>
1391 internal uint GetLayerCount()
1393 if (LayersChildren == null || LayersChildren.Count < 0)
1396 return (uint)LayersChildren.Count;
1399 internal Layer GetRootLayer()
1401 // Window.IsInstalled() is actually true only when called from event thread and
1402 // Core has been initialized, not when Stage is ready.
1403 if (rootLayer == null && Window.IsInstalled())
1405 rootLayer = new Layer(Interop.Window.GetRootLayer(SwigCPtr), true);
1406 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1407 LayersChildren?.Add(rootLayer);
1408 rootLayer.SetWindow(this);
1413 internal void SetBackgroundColor(Vector4 color)
1415 Interop.Window.SetBackgroundColor(SwigCPtr, Vector4.getCPtr(color));
1416 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1419 internal Vector4 GetBackgroundColor()
1421 Vector4 ret = new Vector4(Interop.Window.GetBackgroundColor(SwigCPtr), true);
1422 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1426 internal Vector2 GetDpi()
1428 Vector2 ret = new Vector2(Interop.Stage.GetDpi(stageCPtr), true);
1429 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1433 internal ObjectRegistry GetObjectRegistry()
1435 ObjectRegistry ret = new ObjectRegistry(Interop.Stage.GetObjectRegistry(stageCPtr), true);
1436 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1440 internal void SetRenderingBehavior(RenderingBehaviorType renderingBehavior)
1442 Interop.Stage.SetRenderingBehavior(stageCPtr, (int)renderingBehavior);
1443 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1446 internal RenderingBehaviorType GetRenderingBehavior()
1448 RenderingBehaviorType ret = (RenderingBehaviorType)Interop.Stage.GetRenderingBehavior(stageCPtr);
1449 if (NDalicPINVOKE.SWIGPendingException.Pending)
1450 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1454 internal void SetWindowSize(Size2D size)
1458 throw new ArgumentNullException(nameof(size));
1460 var val = new Uint16Pair((uint)size.Width, (uint)size.Height);
1461 Interop.Window.SetSize(SwigCPtr, Uint16Pair.getCPtr(val));
1463 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1464 // Resetting Window size should request a relayout of the tree.
1467 internal Size2D GetWindowSize()
1469 var val = new Uint16Pair(Interop.Window.GetSize(SwigCPtr), true);
1470 Size2D ret = new Size2D(val.GetWidth(), val.GetHeight());
1471 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1476 internal void SetPosition(Position2D position)
1478 if (null == position)
1480 throw new ArgumentNullException(nameof(position));
1482 var val = new Uint16Pair((uint)position.X, (uint)position.Y);
1483 Interop.Window.SetPosition(SwigCPtr, Uint16Pair.getCPtr(val));
1485 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1486 // Setting Position of the window should request a relayout of the tree.
1489 internal Position2D GetPosition()
1491 var val = new Uint16Pair(Interop.Window.GetPosition(SwigCPtr), true);
1492 Position2D ret = new Position2D(val.GetX(), val.GetY());
1494 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1498 internal void SetPositionSize(Rectangle positionSize)
1500 Interop.Window.SetPositionSize(SwigCPtr, Rectangle.getCPtr(positionSize));
1502 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1504 // Setting Position of the window should request a relayout of the tree.
1508 /// Enables the floating mode of window.
1509 /// The floating mode is to support window is moved or resized by display server.
1510 /// For example, if the video-player window sets the floating mode,
1511 /// then display server changes its geometry and handles it like a popup.
1512 /// The way of handling floating mode window is decided by display server.
1513 /// A special display server(as a Tizen display server) supports this mode.
1515 /// <param name="enable">Enable floating mode or not.</param>
1516 [EditorBrowsable(EditorBrowsableState.Never)]
1517 public void EnableFloatingMode(bool enable)
1519 Interop.Window.EnableFloatingMode(SwigCPtr, enable);
1520 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1524 /// Requests to display server for the window is moved by display server.
1525 /// It can be work with setting window floating mode.
1527 [EditorBrowsable(EditorBrowsableState.Never)]
1528 public void RequestMoveToServer()
1530 Interop.Window.RequestMoveToServer(SwigCPtr);
1531 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1535 /// Requests to display server for the window is resized by display server.
1536 /// It can be work with setting window floating mode.
1538 /// <param name="direction">It is indicated the window's side or edge for starting point.</param>
1539 [EditorBrowsable(EditorBrowsableState.Never)]
1540 public void RequestResizeToServer(ResizeDirection direction)
1542 Interop.Window.RequestResizeToServer(SwigCPtr, (int)direction);
1543 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1547 /// Includes input region.
1548 /// This function inlcudes input regions.
1549 /// It can be used multiple times and supports multiple regions.
1550 /// It means input region will be extended.
1551 /// This input is related to mouse and touch event.
1552 /// If device has touch screen, this function is useful.
1553 /// Otherwise device does not have that, we can use it after connecting mouse to the device.
1555 /// <param name="inputRegion">The included region to accept input events.</param>
1556 [EditorBrowsable(EditorBrowsableState.Never)]
1557 public void IncludeInputRegion(Rectangle inputRegion)
1559 Interop.Window.IncludeInputRegion(SwigCPtr, Rectangle.getCPtr(inputRegion));
1560 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1564 /// This function excludes input regions.
1565 /// It can be used multiple times and supports multiple regions.
1566 /// It means input region will be reduced.
1567 /// Nofice, should be set input area by IncludeInputRegion() before this function is used.
1568 /// This input is related to mouse and touch event.
1569 /// If device has touch screen, this function is useful.
1570 /// Otherwise device does not have that, we can use it after connecting mouse to the device.
1572 /// <param name="inputRegion">The excluded region to except input events.</param>
1573 [EditorBrowsable(EditorBrowsableState.Never)]
1574 public void ExcludeInputRegion(Rectangle inputRegion)
1576 Interop.Window.ExcludeInputRegion(SwigCPtr, Rectangle.getCPtr(inputRegion));
1577 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1581 /// Maximizes window's size.
1582 /// If this function is called with true, window will be resized with screen size.
1583 /// Otherwise window will be resized with previous size.
1584 /// It is for the window's MAX button in window's border.
1585 /// If window border is supported by display server, it is not necessary.
1587 /// <param name="max">If window is maximized or unmaximized.</param>
1588 [EditorBrowsable(EditorBrowsableState.Never)]
1589 public void Maximize(bool max)
1591 Interop.Window.Maximize(SwigCPtr, max);
1592 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1596 /// Returns whether the window is maximized or not.
1598 /// <returns>True if the window is maximized, false otherwise.</returns>
1599 [EditorBrowsable(EditorBrowsableState.Never)]
1600 public bool IsMaximized()
1602 bool ret = Interop.Window.IsMaximized(SwigCPtr);
1603 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1608 /// Minimizes window's size.
1609 /// If this function is called with true, window will be iconified.
1610 /// Otherwise window will be activated.
1611 /// It is for the window's MIN button in window border.
1612 /// If window border is supported by display server, it is not necessary.
1614 /// <param name="min">If window is minimized or unminimized.</param>
1615 [EditorBrowsable(EditorBrowsableState.Never)]
1616 public void Minimize(bool min)
1618 Interop.Window.Minimize(SwigCPtr, min);
1619 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1623 /// Returns whether the window is minimized or not.
1625 /// <returns>True if the window is minimized, false otherwise.</returns>
1626 [EditorBrowsable(EditorBrowsableState.Never)]
1627 public bool IsMinimized()
1629 bool ret = Interop.Window.IsMinimized(SwigCPtr);
1630 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1635 /// Add FrameUpdateCallback
1637 [EditorBrowsable(EditorBrowsableState.Never)]
1638 public void AddFrameUpdateCallback(FrameUpdateCallbackInterface frameUpdateCallback)
1640 frameUpdateCallback?.AddFrameUpdateCallback(stageCPtr, Layer.getCPtr(GetRootLayer()));
1644 /// Remove FrameUpdateCallback
1646 [EditorBrowsable(EditorBrowsableState.Never)]
1647 public void RemoveFrameUpdateCallback(FrameUpdateCallbackInterface frameUpdateCallback)
1649 frameUpdateCallback?.RemoveFrameUpdateCallback(stageCPtr);
1653 /// Dispose for Window
1655 [EditorBrowsable(EditorBrowsableState.Never)]
1656 protected override void Dispose(DisposeTypes type)
1663 if (type == DisposeTypes.Explicit)
1666 //Release your own managed resources here.
1667 //You should release all of your own disposable objects here.
1669 if (rootLayer != null)
1671 rootLayer.Dispose();
1674 localController?.Dispose();
1676 foreach (var layer in childLayers)
1684 childLayers.Clear();
1687 this.DisconnectNativeSignals();
1692 /// This will not be public opened.
1693 [EditorBrowsable(EditorBrowsableState.Never)]
1694 protected override void ReleaseSwigCPtr(System.Runtime.InteropServices.HandleRef swigCPtr)
1696 Interop.Window.DeleteWindow(swigCPtr);
1699 private static Dictionary<int, internalHookCallbackType> frameCallbackList = new Dictionary<int, internalHookCallbackType>();
1701 private static readonly object locker = new object();
1703 private static int key = 0;
1705 private static FrameCallbackType internalHookFrameCallback = OnInternalHookFrameCallback;
1707 private struct internalHookCallbackType
1709 public FrameCallbackType userCallback;
1713 private static void OnInternalHookFrameCallback(int id)
1717 if (frameCallbackList.ContainsKey(id))
1719 if (frameCallbackList[id].userCallback != null)
1721 frameCallbackList[id].userCallback.Invoke(frameCallbackList[id].frameId);
1722 frameCallbackList.Remove(id);
1726 NUILog.Error($"found userCallback is NULL");
1727 frameCallbackList.Remove(id);
1733 private int AddInterHookCallback(FrameCallbackType callback, int frameId)
1735 if (null == callback)
1737 throw new ArgumentNullException(nameof(callback), "FrameCallbackType should not be null");
1739 var assignedKey = 0;
1744 frameCallbackList.Add(assignedKey, new internalHookCallbackType()
1746 userCallback = callback,
1754 /// Type of callback which is called when the frame rendering is done by graphics driver or when the frame is displayed on display.
1756 /// <param name="frameId">The Id to specify the frame. It will be passed when the callback is called.</param>
1757 [EditorBrowsable(EditorBrowsableState.Never)]
1758 public delegate void FrameCallbackType(int frameId);
1761 /// Adds a callback that is called when the frame rendering is done by the graphics driver.
1762 /// A callback of the following type may be used:
1764 /// void MyFunction( int frameId )
1766 /// This callback will be deleted once it is called.
1768 /// Ownership of the callback is passed onto this class
1771 /// <param name="callback">The function to call</param>
1772 /// <param name="frameId">The Id to specify the frame. It will be passed when the callback is called.</param>
1773 /// <exception cref="ArgumentNullException">This exception can occur by the callback is null.</exception>
1774 [EditorBrowsable(EditorBrowsableState.Never)]
1775 public void AddFrameRenderedCallback(FrameCallbackType callback, int frameId)
1777 var assignedKey = AddInterHookCallback(callback, frameId);
1778 Interop.WindowInternal.AddFrameRenderedCallback(SwigCPtr, new HandleRef(this, Marshal.GetFunctionPointerForDelegate<Delegate>(internalHookFrameCallback)), assignedKey);
1780 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1784 /// Adds a callback that is called when the frame is displayed on the display.
1785 /// A callback of the following type may be used:
1787 /// void MyFunction( int frameId )
1789 /// This callback will be deleted once it is called.
1791 /// Ownership of the callback is passed onto this class
1794 /// <param name="callback">The function to call</param>
1795 /// <param name="frameId">The Id to specify the frame. It will be passed when the callback is called.</param>
1796 /// <exception cref="ArgumentNullException">This exception can occur by the callback is null.</exception>
1797 [EditorBrowsable(EditorBrowsableState.Never)]
1798 public void AddFramePresentedCallback(FrameCallbackType callback, int frameId)
1800 var assignedKey = AddInterHookCallback(callback, frameId);
1801 Interop.WindowInternal.AddFramePresentedCallback(SwigCPtr, new HandleRef(this, Marshal.GetFunctionPointerForDelegate<Delegate>(internalHookFrameCallback)), assignedKey);
1803 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1807 /// Search through this Window for a Layer with the given unique ID.
1809 /// <param name="id">The ID of the Layer to find.</param>
1810 /// <remarks>Hidden-API</remarks>
1811 /// <returns>A handle to the Layer if found, or an empty handle if not.</returns>
1812 [EditorBrowsable(EditorBrowsableState.Never)]
1813 public Layer FindLayerByID(uint id)
1815 Layer defaultLayer = this.GetDefaultLayer();
1816 IntPtr cPtr = Interop.Actor.FindChildById(defaultLayer.SwigCPtr, id);
1817 Layer ret = this.GetInstanceSafely<Layer>(cPtr);
1819 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1824 /// Get Native Window handle.
1826 /// How to get Native Window handle
1828 /// Window window = NUIApplication.GetDefaultWindow();
1829 /// var handle = window.NativeHandle;
1830 /// if(handle.IsInvalid == false)
1832 /// IntPtr nativeHandle = handle.DangerousGetHandle();
1833 /// // do something with nativeHandle
1838 /// <since_tizen> 9 </since_tizen>
1839 public SafeHandle NativeHandle
1843 return new NUI.SafeNativeWindowHandle(this);