2 * Copyright(c) 2021 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
18 extern alias TizenSystemInformation;
19 using TizenSystemInformation.Tizen.System;
22 using System.ComponentModel;
23 using System.Collections.Generic;
24 using System.Runtime.InteropServices;
26 using Tizen.NUI.BaseComponents;
31 /// The window class is used internally for drawing.<br />
32 /// The window has an orientation and indicator properties.<br />
34 /// <since_tizen> 3 </since_tizen>
35 public partial class Window : BaseHandle
37 private HandleRef stageCPtr;
38 private Layer rootLayer;
39 private string windowTitle;
40 private List<Layer> childLayers = new List<Layer>();
41 private LayoutController localController;
43 static internal bool IsSupportedMultiWindow()
45 bool isSupported = false;
48 Information.TryGetValue("http://tizen.org/feature/opengles.surfaceless_context", out isSupported);
50 catch (DllNotFoundException e)
52 Tizen.Log.Fatal("NUI", $"{e}\n");
57 internal Window(global::System.IntPtr cPtr, bool cMemoryOwn) : base(cPtr, cMemoryOwn)
59 if (Interop.Stage.IsInstalled())
61 stageCPtr = new global::System.Runtime.InteropServices.HandleRef(this, Interop.Stage.GetCurrent());
63 localController = new LayoutController(this);
64 NUILog.Debug("layoutController id:" + localController.GetId());
69 /// A helper method to get the current window where the view is added
71 /// <param name="view">The View added to the window</param>
72 /// <returns>A Window.</returns>
73 [EditorBrowsable(EditorBrowsableState.Never)]
74 static public Window Get(View view)
78 NUILog.Error("if there is no view, it can not get a window");
82 Window ret = Registry.GetManagedBaseHandleFromNativePtr(Interop.Window.Get(View.getCPtr(view))) as Window;
83 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
88 /// Creates a new Window.<br />
89 /// This creates an extra window in addition to the default main window<br />
91 /// <param name="windowPosition">The position and size of the Window.</param>
92 /// <param name="isTranslucent">Whether Window is translucent.</param>
93 /// <returns>A new Window.</returns>
94 /// <since_tizen> 6 </since_tizen>
95 /// <feature> http://tizen.org/feature/opengles.surfaceless_context </feature>
96 /// <exception cref="NotSupportedException">The required feature is not supported.</exception>
97 public Window(Rectangle windowPosition = null, bool isTranslucent = false) : this(Interop.Window.New(Rectangle.getCPtr(windowPosition), "", isTranslucent), true)
99 if (IsSupportedMultiWindow() == false)
101 NUILog.Error("This device does not support surfaceless_context. So Window cannot be created. ");
103 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
107 /// Creates a new Window with a specific name.<br />
108 /// This creates an extra window in addition to the default main window<br />
110 /// <param name="name">The name for extra window. </param>
111 /// <param name="windowPosition">The position and size of the Window.</param>
112 /// <param name="isTranslucent">Whether Window is translucent.</param>
113 /// <returns>A new Window.</returns>
114 /// <since_tizen> 6 </since_tizen>
115 /// <feature> http://tizen.org/feature/opengles.surfaceless_context </feature>
116 /// <exception cref="NotSupportedException">The required feature is not supported.</exception>
117 public Window(string name, Rectangle windowPosition = null, bool isTranslucent = false) : this(Interop.Window.New(Rectangle.getCPtr(windowPosition), name, isTranslucent), true)
119 if (IsSupportedMultiWindow() == false)
121 NUILog.Error("This device does not support surfaceless_context. So Window cannot be created. ");
123 this.windowTitle = name;
124 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
128 /// Enumeration for orientation of the window is the way in which a rectangular page is oriented for normal viewing.
130 /// <since_tizen> 3 </since_tizen>
131 public enum WindowOrientation
134 /// Portrait orientation. The height of the display area is greater than the width.
136 /// <since_tizen> 3 </since_tizen>
139 /// Landscape orientation. A wide view area is needed.
141 /// <since_tizen> 3 </since_tizen>
144 /// Portrait inverse orientation.
146 /// <since_tizen> 3 </since_tizen>
147 PortraitInverse = 180,
149 /// Landscape inverse orientation.
151 /// <since_tizen> 3 </since_tizen>
152 LandscapeInverse = 270,
154 /// No orientation. It is for the preferred orientation
155 /// Especially, NoOrientationPreference only has the effect for the preferred orientation.
156 /// It is used to unset the preferred orientation with SetPreferredOrientation.
158 [EditorBrowsable(EditorBrowsableState.Never)]
159 NoOrientationPreference = -1
163 /// Enumeration for the key grab mode for platform-level APIs.
165 /// <since_tizen> 3 </since_tizen>
166 public enum KeyGrabMode
169 /// Grabs a key only when on the top of the grabbing-window stack mode.
173 /// Grabs a key together with the other client window(s) mode.
177 /// Grabs a key exclusively regardless of the grabbing-window's position on the window stack with the possibility of overriding the grab by the other client window mode.
181 /// Grabs a key exclusively regardless of the grabbing-window's position on the window stack mode.
187 /// Enumeration for transition effect's state.
189 [Obsolete("Please do not use! This will be removed. Please use Window.EffectState instead!")]
190 [EditorBrowsable(EditorBrowsableState.Never)]
191 // This is already deprecated, so suppress warning here.
192 [System.Diagnostics.CodeAnalysis.SuppressMessage("Naming", "CA1717:Only FlagsAttribute enums should have plural names", Justification = "<Pending>")]
193 public enum EffectStates
198 [Obsolete("Please do not use! This will be removed. Please use Window.EffectState.None instead!")]
199 [EditorBrowsable(EditorBrowsableState.Never)]
202 /// Transition effect is started.
204 [Obsolete("Please do not use! This will be removed. Please use Window.EffectState.Start instead!")]
205 [EditorBrowsable(EditorBrowsableState.Never)]
208 /// Transition effect is ended.
210 [Obsolete("Please do not use! This will be removed. Please use Window.EffectState.End instead!")]
211 [EditorBrowsable(EditorBrowsableState.Never)]
216 /// Enumeration for transition effect's state.
218 [EditorBrowsable(EditorBrowsableState.Never)]
219 public enum EffectState
224 [EditorBrowsable(EditorBrowsableState.Never)]
227 /// Transition effect is started.
229 [EditorBrowsable(EditorBrowsableState.Never)]
232 /// Transition effect is ended.
234 [EditorBrowsable(EditorBrowsableState.Never)]
239 /// Enumeration for transition effect's type.
241 [Obsolete("Please do not use! This will be removed. Please use Window.EffectType instead!")]
242 [EditorBrowsable(EditorBrowsableState.Never)]
243 // This is already deprecated, so suppress warning here.
244 [System.Diagnostics.CodeAnalysis.SuppressMessage("Naming", "CA1717:Only FlagsAttribute enums should have plural names", Justification = "<Pending>")]
245 public enum EffectTypes
250 [Obsolete("Please do not use! This will be removed. Please use Window.EffectType.None instead!")]
251 [EditorBrowsable(EditorBrowsableState.Never)]
254 /// Window show effect.
256 [Obsolete("Please do not use! This will be removed. Please use Window.EffectType.Show instead!")]
257 [EditorBrowsable(EditorBrowsableState.Never)]
260 /// Window hide effect.
262 [Obsolete("Please do not use! This will be removed. Please use Window.EffectType.Hide instead!")]
263 [EditorBrowsable(EditorBrowsableState.Never)]
268 /// Enumeration for transition effect's type.
270 [EditorBrowsable(EditorBrowsableState.Never)]
271 public enum EffectType
276 [EditorBrowsable(EditorBrowsableState.Never)]
279 /// Window show effect.
281 [EditorBrowsable(EditorBrowsableState.Never)]
284 /// Window hide effect.
286 [EditorBrowsable(EditorBrowsableState.Never)]
291 /// Enumeration for result of window operation.
293 internal enum OperationResult
296 /// Failed for unknown reason
304 /// Permission denied
308 /// The operation is not supported.
314 /// Enumeration for window resized mode by display server.
316 [EditorBrowsable(EditorBrowsableState.Never)]
317 public enum ResizeDirection
320 /// Start resizing window to the top-left edge.
322 [EditorBrowsable(EditorBrowsableState.Never)]
325 /// Start resizing window to the top side.
327 [EditorBrowsable(EditorBrowsableState.Never)]
330 /// Start resizing window to the top-right edge.
332 [EditorBrowsable(EditorBrowsableState.Never)]
335 /// Start resizing window to the left side.
337 [EditorBrowsable(EditorBrowsableState.Never)]
340 /// Start resizing window to the right side.
342 [EditorBrowsable(EditorBrowsableState.Never)]
345 /// Start resizing window to the bottom-left edge.
347 [EditorBrowsable(EditorBrowsableState.Never)]
350 /// Start resizing window to the bottom side.
352 [EditorBrowsable(EditorBrowsableState.Never)]
355 /// Start resizing window to the bottom-right edge.
357 [EditorBrowsable(EditorBrowsableState.Never)]
363 /// The stage instance property (read-only).<br />
364 /// Gets the current window.<br />
366 /// <since_tizen> 3 </since_tizen>
367 public static Window Instance { get; internal set; }
370 /// Gets or sets a window type.
371 /// Most of window type can be set to use WindowType, except for IME type.
372 /// IME type can be set to use one of NUIApplication's constrcutors.
374 /// <since_tizen> 3 </since_tizen>
375 public WindowType Type
379 WindowType ret = (WindowType)Interop.Window.GetType(SwigCPtr);
380 if (NDalicPINVOKE.SWIGPendingException.Pending) throw new InvalidOperationException("FATAL: get Exception", NDalicPINVOKE.SWIGPendingException.Retrieve());
385 Interop.Window.SetType(SwigCPtr, (int)value);
386 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
391 /// Gets/Sets a window title.
393 /// <since_tizen> 4 </since_tizen>
403 SetClass(windowTitle, "");
408 /// The rendering behavior of a Window.
410 /// <since_tizen> 5 </since_tizen>
411 public RenderingBehaviorType RenderingBehavior
415 return GetRenderingBehavior();
419 SetRenderingBehavior(value);
424 /// The window size property (read-only).
426 /// <since_tizen> 3 </since_tizen>
431 Size2D ret = GetSize();
437 /// The background color property.
439 /// <since_tizen> 3 </since_tizen>
440 public Color BackgroundColor
444 SetBackgroundColor(value);
448 Color ret = GetBackgroundColor();
454 /// The DPI property (read-only).<br />
455 /// Retrieves the DPI of the display device to which the Window is connected.<br />
457 /// <since_tizen> 3 </since_tizen>
467 /// The layer count property (read-only).<br />
468 /// Queries the number of on-Window layers.<br />
470 /// <since_tizen> 3 </since_tizen>
471 public uint LayerCount
475 return GetLayerCount();
480 /// Gets or sets a size of the window.
482 /// <exception cref="ArgumentNullException"> Thrown when value is null. </exception>
483 /// <since_tizen> 4 </since_tizen>
484 public Size2D WindowSize
488 return GetWindowSize();
492 SetWindowSize(value);
497 /// Gets or sets a position of the window.
499 /// <exception cref="ArgumentNullException"> Thrown when value is null. </exception>
500 /// <since_tizen> 4 </since_tizen>
501 public Position2D WindowPosition
505 return GetPosition();
514 /// Sets position and size of the window. This API guarantees that
515 /// both moving and resizing of window will appear on the screen at once.
517 [EditorBrowsable(EditorBrowsableState.Never)]
518 public Rectangle WindowPositionSize
522 Position2D position = GetPosition();
523 Size2D size = GetSize();
524 Rectangle ret = new Rectangle(position.X, position.Y, size.Width, size.Height);
530 SetPositionSize(value);
534 internal static Vector4 DEFAULT_BACKGROUND_COLOR
538 global::System.IntPtr cPtr = Interop.Stage.DefaultBackgroundColorGet();
539 Vector4 ret = (cPtr == global::System.IntPtr.Zero) ? null : new Vector4(cPtr, false);
540 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
545 internal static Vector4 DEBUG_BACKGROUND_COLOR
549 global::System.IntPtr cPtr = Interop.Stage.DebugBackgroundColorGet();
550 Vector4 ret = (cPtr == global::System.IntPtr.Zero) ? null : new Vector4(cPtr, false);
551 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
556 internal List<Layer> LayersChildren
565 /// Get the LayoutController for this Window.
567 internal LayoutController LayoutController
571 return localController;
576 /// Feed a key-event into the window.
578 /// <param name="keyEvent">The key event to feed.</param>
579 /// <since_tizen> 4 </since_tizen>
580 [Obsolete("Please do not use! This will be deprecated! Please use FeedKey(Key keyEvent) instead!")]
581 public static void FeedKeyEvent(Key keyEvent)
583 Interop.Window.FeedKeyEvent(Key.getCPtr(keyEvent));
584 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
588 /// Sets whether the window accepts a focus or not.
590 /// <param name="accept">If a focus is accepted or not. The default is true.</param>
591 /// <since_tizen> 3 </since_tizen>
592 public void SetAcceptFocus(bool accept)
594 Interop.Window.SetAcceptFocus(SwigCPtr, accept);
595 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
599 /// Returns whether the window accepts a focus or not.
601 /// <returns>True if the window accepts a focus, false otherwise.</returns>
602 /// <since_tizen> 3 </since_tizen>
603 public bool IsFocusAcceptable()
605 bool ret = Interop.Window.IsFocusAcceptable(SwigCPtr);
606 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
612 /// Shows the window if it is hidden.
614 /// <since_tizen> 3 </since_tizen>
617 Interop.Window.Show(SwigCPtr);
618 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
622 /// Hides the window if it is showing.
624 /// <since_tizen> 3 </since_tizen>
627 Interop.Window.Hide(SwigCPtr);
628 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
632 /// Retrieves whether the window is visible or not.
634 /// <returns>True if the window is visible.</returns>
635 /// <since_tizen> 3 </since_tizen>
636 public bool IsVisible()
638 bool temp = Interop.Window.IsVisible(SwigCPtr);
639 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
644 /// Gets the count of supported auxiliary hints of the window.
646 /// <returns>The number of supported auxiliary hints.</returns>
647 /// <since_tizen> 3 </since_tizen>
648 public uint GetSupportedAuxiliaryHintCount()
650 uint ret = Interop.Window.GetSupportedAuxiliaryHintCount(SwigCPtr);
651 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
656 /// Gets the supported auxiliary hint string of the window.
658 /// <param name="index">The index of the supported auxiliary hint lists.</param>
659 /// <returns>The auxiliary hint string of the index.</returns>
660 /// <since_tizen> 3 </since_tizen>
661 public string GetSupportedAuxiliaryHint(uint index)
663 string ret = Interop.Window.GetSupportedAuxiliaryHint(SwigCPtr, index);
664 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
669 /// Creates an auxiliary hint of the window.
671 /// <param name="hint">The auxiliary hint string.</param>
672 /// <param name="value">The value string.</param>
673 /// <returns>The ID of created auxiliary hint, or 0 on failure.</returns>
674 /// <since_tizen> 3 </since_tizen>
675 public uint AddAuxiliaryHint(string hint, string value)
677 uint ret = Interop.Window.AddAuxiliaryHint(SwigCPtr, hint, value);
678 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
683 /// Removes an auxiliary hint of the window.
685 /// <param name="id">The ID of the auxiliary hint.</param>
686 /// <returns>True if no error occurred, false otherwise.</returns>
687 /// <since_tizen> 3 </since_tizen>
688 public bool RemoveAuxiliaryHint(uint id)
690 bool ret = Interop.Window.RemoveAuxiliaryHint(SwigCPtr, id);
691 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
696 /// Changes a value of the auxiliary hint.
698 /// <param name="id">The auxiliary hint ID.</param>
699 /// <param name="value">The value string to be set.</param>
700 /// <returns>True if no error occurred, false otherwise.</returns>
701 /// <since_tizen> 3 </since_tizen>
702 public bool SetAuxiliaryHintValue(uint id, string value)
704 bool ret = Interop.Window.SetAuxiliaryHintValue(SwigCPtr, id, value);
705 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
710 /// Gets a value of the auxiliary hint.
712 /// <param name="id">The auxiliary hint ID.</param>
713 /// <returns>The string value of the auxiliary hint ID, or an empty string if none exists.</returns>
714 /// <since_tizen> 3 </since_tizen>
715 public string GetAuxiliaryHintValue(uint id)
717 string ret = Interop.Window.GetAuxiliaryHintValue(SwigCPtr, id);
718 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
723 /// Gets an ID of the auxiliary hint string.
725 /// <param name="hint">The auxiliary hint string.</param>
726 /// <returns>The ID of auxiliary hint string, or 0 on failure.</returns>
727 /// <since_tizen> 3 </since_tizen>
728 public uint GetAuxiliaryHintId(string hint)
730 uint ret = Interop.Window.GetAuxiliaryHintId(SwigCPtr, hint);
731 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
736 /// Sets a region to accept input events.
738 /// <param name="inputRegion">The region to accept input events.</param>
739 /// <since_tizen> 3 </since_tizen>
740 public void SetInputRegion(Rectangle inputRegion)
742 Interop.Window.IncludeInputRegion(SwigCPtr, Rectangle.getCPtr(inputRegion));
743 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
747 /// Sets a priority level for the specified notification window.
749 /// <param name="level">The notification window level.</param>
750 /// <returns>True if no error occurred, false otherwise.</returns>
751 /// <since_tizen> 3 </since_tizen>
752 public bool SetNotificationLevel(NotificationLevel level)
754 var ret = (OperationResult)Interop.Window.SetNotificationLevel(SwigCPtr, (int)level);
755 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
756 return ret == OperationResult.Succeed;
760 /// Gets a priority level for the specified notification window.
762 /// <returns>The notification window level.</returns>
763 /// <since_tizen> 3 </since_tizen>
764 public NotificationLevel GetNotificationLevel()
766 NotificationLevel ret = (NotificationLevel)Interop.Window.GetNotificationLevel(SwigCPtr);
767 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
772 /// Sets a transparent window's visual state to opaque. <br />
773 /// If a visual state of a transparent window is opaque, <br />
774 /// then the window manager could handle it as an opaque window when calculating visibility.
776 /// <param name="opaque">Whether the window's visual state is opaque.</param>
777 /// <remarks>This will have no effect on an opaque window. <br />
778 /// It doesn't change transparent window to opaque window but lets the window manager know the visual state of the window.
780 /// <since_tizen> 3 </since_tizen>
781 public void SetOpaqueState(bool opaque)
783 Interop.Window.SetOpaqueState(SwigCPtr, opaque);
784 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
788 /// Returns whether a transparent window's visual state is opaque or not.
790 /// <returns>True if the window's visual state is opaque, false otherwise.</returns>
791 /// <remarks> The return value has no meaning on an opaque window. </remarks>
792 /// <since_tizen> 3 </since_tizen>
793 public bool IsOpaqueState()
795 bool ret = Interop.Window.IsOpaqueState(SwigCPtr);
796 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
801 /// Sets a window's screen off mode.
803 /// <param name="screenOffMode">The screen mode.</param>
804 /// <returns>True if no error occurred, false otherwise.</returns>
805 /// <since_tizen> 4 </since_tizen>
806 public bool SetScreenOffMode(ScreenOffMode screenOffMode)
808 var ret = (OperationResult)Interop.Window.SetScreenOffMode(SwigCPtr, (int)screenOffMode);
809 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
810 return ret == OperationResult.Succeed;
814 /// Gets the screen mode of the window.
816 /// <returns>The screen off mode.</returns>
817 /// <since_tizen> 4 </since_tizen>
818 public ScreenOffMode GetScreenOffMode()
820 ScreenOffMode ret = (ScreenOffMode)Interop.Window.GetScreenOffMode(SwigCPtr);
821 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
826 /// Sets preferred brightness of the window.
828 /// <param name="brightness">The preferred brightness (0 to 100).</param>
829 /// <returns>True if no error occurred, false otherwise.</returns>
830 /// <since_tizen> 3 </since_tizen>
831 public bool SetBrightness(int brightness)
833 var ret = (OperationResult)Interop.Window.SetBrightness(SwigCPtr, brightness);
834 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
835 return ret == OperationResult.Succeed;
839 /// Gets the preferred brightness of the window.
841 /// <returns>The preferred brightness.</returns>
842 /// <since_tizen> 3 </since_tizen>
843 public int GetBrightness()
845 int ret = Interop.Window.GetBrightness(SwigCPtr);
846 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
851 /// Sets the window name and the class string.
853 /// <param name="name">The name of the window.</param>
854 /// <param name="klass">The class of the window.</param>
855 /// <since_tizen> 4 </since_tizen>
856 public void SetClass(string name, string klass)
858 Interop.Window.SetClass(SwigCPtr, name, klass);
859 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
863 /// Raises the window to the top of the window stack.
865 /// <since_tizen> 3 </since_tizen>
868 Interop.Window.Raise(SwigCPtr);
869 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
873 /// Lowers the window to the bottom of the window stack.
875 /// <since_tizen> 3 </since_tizen>
878 Interop.Window.Lower(SwigCPtr);
879 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
883 /// Activates the window to the top of the window stack even it is iconified.
885 /// <since_tizen> 3 </since_tizen>
886 public void Activate()
888 Interop.Window.Activate(SwigCPtr);
889 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
893 /// Gets the default ( root ) layer.
895 /// <returns>The root layer.</returns>
896 /// <since_tizen> 3 </since_tizen>
897 public Layer GetDefaultLayer()
899 return this.GetRootLayer();
903 /// Add a child view to window.
905 /// <param name="view">the child should be added to the window.</param>
906 /// <since_tizen> 3 </since_tizen>
907 public void Add(View view)
909 Interop.Actor.Add(Layer.getCPtr(GetRootLayer()), View.getCPtr(view));
910 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
911 this.GetRootLayer().AddViewToLayerList(view); // Maintain the children list in the Layer
914 view.InternalParent = this.GetRootLayer();
916 this.GetRootLayer().LayoutCount += view.LayoutCount;
921 /// Remove a child view from window.
923 /// <param name="view">the child to be removed.</param>
924 /// <since_tizen> 3 </since_tizen>
925 public void Remove(View view)
927 Interop.Actor.Remove(Layer.getCPtr(GetRootLayer()), View.getCPtr(view));
928 this.GetRootLayer().RemoveViewFromLayerList(view); // Maintain the children list in the Layer
931 view.InternalParent = null;
933 this.GetRootLayer().LayoutCount -= view.LayoutCount;
938 /// Retrieves the layer at a specified depth.
940 /// <param name="depth">The layer's depth index.</param>
941 /// <returns>The layer found at the given depth.</returns>
942 /// <since_tizen> 3 </since_tizen>
943 public Layer GetLayer(uint depth)
945 if (depth < LayersChildren?.Count)
947 Layer ret = LayersChildren?[Convert.ToInt32(depth)];
957 /// Destroy the window immediately.
959 [EditorBrowsable(EditorBrowsableState.Never)]
960 public void Destroy()
966 /// Keep rendering for at least the given amount of time.
968 /// <param name="durationSeconds">Time to keep rendering, 0 means render at least one more frame.</param>
969 /// <since_tizen> 3 </since_tizen>
970 public void KeepRendering(float durationSeconds)
972 Interop.Stage.KeepRendering(stageCPtr, durationSeconds);
973 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
977 /// Grabs the key specified by a key for a window only when a window is the topmost window.<br />
978 /// This function can be used for following example scenarios: <br />
979 /// - Mobile - Using volume up or down as zoom up or down in camera apps.<br />
981 /// <param name="DaliKey">The key code to grab.</param>
982 /// <returns>True if the grab succeeds.</returns>
983 /// <since_tizen> 3 </since_tizen>
984 public bool GrabKeyTopmost(int DaliKey)
986 bool ret = Interop.Window.GrabKeyTopmost(HandleRef.ToIntPtr(this.SwigCPtr), DaliKey);
987 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
992 /// Ungrabs the key specified by a key for the window.<br />
993 /// 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 />
995 /// <param name="DaliKey">The key code to ungrab.</param>
996 /// <returns>True if the ungrab succeeds.</returns>
997 /// <since_tizen> 3 </since_tizen>
998 public bool UngrabKeyTopmost(int DaliKey)
1000 bool ret = Interop.Window.UngrabKeyTopmost(HandleRef.ToIntPtr(this.SwigCPtr), DaliKey);
1001 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1006 /// Grabs the key specified by a key for a window in a GrabMode. <br />
1007 /// Details: This function can be used for following example scenarios: <br />
1008 /// - TV - A user might want to change the volume or channel of the background TV contents while focusing on the foregrund app. <br />
1009 /// - Mobile - When a user presses the Home key, the homescreen appears regardless of the current foreground app. <br />
1010 /// - Mobile - Using the volume up or down as zoom up or down in camera apps. <br />
1012 /// <param name="DaliKey">The key code to grab.</param>
1013 /// <param name="GrabMode">The grab mode for the key.</param>
1014 /// <returns>True if the grab succeeds.</returns>
1015 /// <since_tizen> 3 </since_tizen>
1016 public bool GrabKey(int DaliKey, KeyGrabMode GrabMode)
1018 bool ret = Interop.Window.GrabKey(HandleRef.ToIntPtr(this.SwigCPtr), DaliKey, (int)GrabMode);
1019 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1024 /// Ungrabs the key specified by a key for a window.<br />
1025 /// 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 />
1027 /// <param name="DaliKey">The key code to ungrab.</param>
1028 /// <returns>True if the ungrab succeeds.</returns>
1029 /// <since_tizen> 3 </since_tizen>
1030 public bool UngrabKey(int DaliKey)
1032 bool ret = Interop.Window.UngrabKey(HandleRef.ToIntPtr(this.SwigCPtr), DaliKey);
1033 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1038 /// Sets the keyboard repeat information.
1040 /// <param name="rate">The key repeat rate value in seconds.</param>
1041 /// <param name="delay">The key repeat delay value in seconds.</param>
1042 /// <returns>True if setting the keyboard repeat succeeds.</returns>
1043 /// <since_tizen> 5 </since_tizen>
1044 public bool SetKeyboardRepeatInfo(float rate, float delay)
1046 bool ret = Interop.Window.SetKeyboardRepeatInfo(rate, delay);
1047 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1052 /// Gets the keyboard repeat information.
1054 /// <param name="rate">The key repeat rate value in seconds.</param>
1055 /// <param name="delay">The key repeat delay value in seconds.</param>
1056 /// <returns>True if setting the keyboard repeat succeeds.</returns>
1057 /// <since_tizen> 5 </since_tizen>
1058 public bool GetKeyboardRepeatInfo(out float rate, out float delay)
1060 bool ret = Interop.Window.GetKeyboardRepeatInfo(out rate, out delay);
1061 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1066 /// Adds a layer to the stage.
1068 /// <param name="layer">Layer to add.</param>
1069 /// <exception cref="ArgumentNullException"> Thrown when layer is null. </exception>
1070 /// <since_tizen> 3 </since_tizen>
1071 public void AddLayer(Layer layer)
1077 /// Removes a layer from the stage.
1079 /// <param name="layer">Layer to remove.</param>
1080 /// <exception cref="ArgumentNullException"> Thrown when layer is null. </exception>
1081 /// <since_tizen> 3 </since_tizen>
1082 public void RemoveLayer(Layer layer)
1088 /// Feeds a key event into the window.
1090 /// <param name="keyEvent">The key event to feed.</param>
1091 /// <since_tizen> 5 </since_tizen>
1092 public void FeedKey(Key keyEvent)
1094 Interop.Window.FeedKeyEvent(SwigCPtr, Key.getCPtr(keyEvent));
1095 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1099 /// Feeds a touch point into the window.
1101 /// <param name="touchPoint">The touch point to feed.</param>
1102 /// <param name="timeStamp">The timeStamp.</param>
1103 internal void FeedTouch(TouchPoint touchPoint, int timeStamp)
1105 Interop.Window.FeedTouchPoint(SwigCPtr, TouchPoint.getCPtr(touchPoint), timeStamp);
1106 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1110 /// Feeds a wheel event into the window.
1112 /// <param name="wheelEvent">The wheel event to feed.</param>
1113 internal void FeedWheel(Wheel wheelEvent)
1115 Interop.Window.FeedWheelEvent(SwigCPtr, Wheel.getCPtr(wheelEvent));
1116 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1120 /// Allows at least one more render, even when paused.
1121 /// The window should be shown, not minimised.
1123 /// <since_tizen> 4 </since_tizen>
1124 public void RenderOnce()
1126 Interop.Window.RenderOnce(SwigCPtr);
1127 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1131 /// Sets whether the window is transparent or not.
1133 /// <param name="transparent">Whether the window is transparent or not.</param>
1134 /// <since_tizen> 5 </since_tizen>
1135 public void SetTransparency(bool transparent)
1137 Interop.Window.SetTransparency(SwigCPtr, transparent);
1138 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1140 // Setting transparency of the window should request a relayout of the tree in the case the window changes from fully transparent.
1144 /// Sets parent window of the window.
1145 /// After setting that, these windows do together when raise-up, lower and iconified/deiconified.
1146 /// Initially, the window is located on top of the parent. The window can go below parent by calling Lower().
1147 /// If parent's window stack is changed by calling Raise() or Lower(), child windows are located on top of the parent again.
1149 /// <param name="parent">The parent window.</param>
1150 /// <since_tizen> 6 </since_tizen>
1151 /// <feature> http://tizen.org/feature/opengles.surfaceless_context </feature>
1152 /// <exception cref="NotSupportedException">The required feature is not supported.</exception>
1153 public void SetParent(Window parent)
1155 if (IsSupportedMultiWindow() == false)
1157 NUILog.Error("This device does not support surfaceless_context. So Window cannot be created. ");
1159 Interop.Window.SetParent(SwigCPtr, Window.getCPtr(parent));
1160 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1164 /// Sets parent window of the window.
1165 /// After setting that, these windows do together when raise-up, lower and iconified/deiconified.
1166 /// This function has the additional flag whether the child is located above or below of the parent.
1168 /// <param name="parent">The parent window.</param>
1169 /// <param name="belowParent">The flag is whether the child is located above or below of the parent.</param>
1170 /// <feature> http://tizen.org/feature/opengles.surfaceless_context </feature>
1171 /// <exception cref="NotSupportedException">The required feature is not supported.</exception>
1172 [EditorBrowsable(EditorBrowsableState.Never)]
1173 public void SetParent(Window parent, bool belowParent)
1175 if (IsSupportedMultiWindow() == false)
1177 NUILog.Error("This device does not support surfaceless_context. So Window cannot be created. ");
1179 Interop.Window.SetParentWithStack(SwigCPtr, Window.getCPtr(parent), belowParent);
1180 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1184 /// Unsets parent window of the window.
1185 /// After unsetting, the window is disconnected his parent window.
1187 /// <since_tizen> 6 </since_tizen>
1188 /// <feature> http://tizen.org/feature/opengles.surfaceless_context </feature>
1189 /// <exception cref="NotSupportedException">The required feature is not supported.</exception>
1190 public void Unparent()
1192 if (IsSupportedMultiWindow() == false)
1194 NUILog.Error("Fail to create window. because this device does not support opengles.surfaceless_context.");
1196 Interop.Window.Unparent(SwigCPtr);
1197 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1201 /// Gets parent window of the window.
1203 /// <returns>The parent window of the window.</returns>
1204 /// <since_tizen> 6 </since_tizen>
1205 /// <feature> http://tizen.org/feature/opengles.surfaceless_context </feature>
1206 /// <exception cref="NotSupportedException">The required feature is not supported.</exception>
1207 [System.Diagnostics.CodeAnalysis.SuppressMessage("Design", "CA1721: Property names should not match get methods")]
1208 public Window GetParent()
1210 if (IsSupportedMultiWindow() == false)
1212 NUILog.Error("This device does not support surfaceless_context. So Window cannot be created. ");
1214 Window ret = Registry.GetManagedBaseHandleFromNativePtr(Interop.Window.GetParent(SwigCPtr)) as Window;
1215 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1219 /// This will be public opened in tizen_next after ACR done. Before ACR, need to be hidden as inhouse API.
1220 [EditorBrowsable(EditorBrowsableState.Never)]
1221 public void ObjectDump()
1223 Layer rootLayer = GetRootLayer();
1224 foreach (View view in rootLayer.Children)
1230 internal static bool IsInstalled()
1232 bool ret = Interop.Stage.IsInstalled();
1233 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1238 /// Adds an orientation to the list of available orientations.
1240 /// <param name="orientation">The available orientation to add</param>
1241 /// <since_tizen> 6 </since_tizen>
1242 public void AddAvailableOrientation(Window.WindowOrientation orientation)
1244 Interop.Window.AddAvailableOrientation(SwigCPtr, (int)orientation);
1245 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1249 /// Removes an orientation from the list of available orientations.
1251 /// <param name="orientation">The available orientation to remove.</param>
1252 /// <since_tizen> 6 </since_tizen>
1253 public void RemoveAvailableOrientation(Window.WindowOrientation orientation)
1255 Interop.Window.RemoveAvailableOrientation(SwigCPtr, (int)orientation);
1256 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1260 /// Sets a preferred orientation.
1262 /// <param name="orientation">The preferred orientation.</param>
1263 /// <since_tizen> 6 </since_tizen>
1264 public void SetPreferredOrientation(Window.WindowOrientation orientation)
1266 Interop.Window.SetPreferredOrientation(SwigCPtr, (int)orientation);
1267 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1271 /// Gets the preferred orientation.
1273 /// <since_tizen> 6 </since_tizen>
1274 /// <returns>The preferred orientation if previously set, or none.</returns>
1275 public Window.WindowOrientation GetPreferredOrientation()
1277 Window.WindowOrientation ret = (Window.WindowOrientation)Interop.Window.GetPreferredOrientation(SwigCPtr);
1278 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1283 /// Gets current orientation of the window.
1285 /// <since_tizen> 6 </since_tizen>
1286 /// <returns>The current window orientation if previously set, or none.</returns>
1287 [EditorBrowsable(EditorBrowsableState.Never)]
1288 public Window.WindowOrientation GetCurrentOrientation()
1290 Window.WindowOrientation ret = (Window.WindowOrientation)Interop.Window.GetCurrentOrientation(SwigCPtr);
1291 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1296 /// Sets available orientations of the window.
1297 /// This API is for setting several orientations one time.
1299 /// <param name="orientations">The list of orientations.</param>
1300 /// <since_tizen> 6 </since_tizen>
1301 [EditorBrowsable(EditorBrowsableState.Never)]
1302 public void SetAvailableOrientations(List<Window.WindowOrientation> orientations)
1304 if (null == orientations)
1306 throw new ArgumentNullException(nameof(orientations));
1309 PropertyArray orientationArray = new PropertyArray();
1310 for (int i = 0; i < orientations.Count; i++)
1312 PropertyValue value = new PropertyValue((int)orientations[i]);
1313 orientationArray.PushBack(value);
1317 Interop.Window.SetAvailableOrientations(SwigCPtr, PropertyArray.getCPtr(orientationArray), orientations.Count);
1318 orientationArray.Dispose();
1319 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1323 /// Get native window ID
1325 /// <returns>native window ID</returns>
1326 [EditorBrowsable(EditorBrowsableState.Never)]
1327 public int GetNativeId()
1329 int ret = Interop.Window.GetNativeId(SwigCPtr);
1330 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1334 internal Any GetNativeHandle()
1336 Any ret = new Any(Interop.WindowInternal.WindowGetNativeHandle(SwigCPtr), true);
1337 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1341 internal void Add(Layer layer)
1345 throw new ArgumentNullException(nameof(layer));
1347 Interop.Window.Add(SwigCPtr, Layer.getCPtr(layer));
1348 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1350 LayersChildren?.Add(layer);
1351 layer.SetWindow(this);
1354 internal void Remove(Layer layer)
1358 throw new ArgumentNullException(nameof(layer));
1360 Interop.Window.Remove(SwigCPtr, Layer.getCPtr(layer));
1361 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1363 LayersChildren?.Remove(layer);
1364 layer.SetWindow(null);
1367 internal Vector2 GetSize()
1369 var val = new Uint16Pair(Interop.Window.GetSize(SwigCPtr), true);
1370 Vector2 ret = new Vector2(val.GetWidth(), val.GetHeight());
1371 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1376 /// This will be public opened in next tizen after ACR done. Before ACR, need to be hidden as inhouse API.
1377 [EditorBrowsable(EditorBrowsableState.Never)]
1378 public RenderTaskList GetRenderTaskList()
1380 RenderTaskList ret = new RenderTaskList(Interop.Stage.GetRenderTaskList(stageCPtr), true);
1381 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1386 /// Queries the number of on-window layers.
1388 /// <returns>The number of layers.</returns>
1389 /// <remarks>Note that a default layer is always provided (count >= 1).</remarks>
1390 internal uint GetLayerCount()
1392 if (LayersChildren == null || LayersChildren.Count < 0)
1395 return (uint)LayersChildren.Count;
1398 internal Layer GetRootLayer()
1400 // Window.IsInstalled() is actually true only when called from event thread and
1401 // Core has been initialized, not when Stage is ready.
1402 if (rootLayer == null && Window.IsInstalled())
1404 rootLayer = new Layer(Interop.Window.GetRootLayer(SwigCPtr), true);
1405 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1406 LayersChildren?.Add(rootLayer);
1407 rootLayer.SetWindow(this);
1412 internal void SetBackgroundColor(Vector4 color)
1414 Interop.Window.SetBackgroundColor(SwigCPtr, Vector4.getCPtr(color));
1415 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1418 internal Vector4 GetBackgroundColor()
1420 Vector4 ret = new Vector4(Interop.Window.GetBackgroundColor(SwigCPtr), true);
1421 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1425 internal Vector2 GetDpi()
1427 Vector2 ret = new Vector2(Interop.Stage.GetDpi(stageCPtr), true);
1428 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1432 internal ObjectRegistry GetObjectRegistry()
1434 ObjectRegistry ret = new ObjectRegistry(Interop.Stage.GetObjectRegistry(stageCPtr), true);
1435 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1439 internal void SetRenderingBehavior(RenderingBehaviorType renderingBehavior)
1441 Interop.Stage.SetRenderingBehavior(stageCPtr, (int)renderingBehavior);
1442 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1445 internal RenderingBehaviorType GetRenderingBehavior()
1447 RenderingBehaviorType ret = (RenderingBehaviorType)Interop.Stage.GetRenderingBehavior(stageCPtr);
1448 if (NDalicPINVOKE.SWIGPendingException.Pending)
1449 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1453 internal void SetWindowSize(Size2D size)
1457 throw new ArgumentNullException(nameof(size));
1459 var val = new Uint16Pair((uint)size.Width, (uint)size.Height);
1460 Interop.Window.SetSize(SwigCPtr, Uint16Pair.getCPtr(val));
1462 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1463 // Resetting Window size should request a relayout of the tree.
1466 internal Size2D GetWindowSize()
1468 var val = new Uint16Pair(Interop.Window.GetSize(SwigCPtr), true);
1469 Size2D ret = new Size2D(val.GetWidth(), val.GetHeight());
1470 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1475 internal void SetPosition(Position2D position)
1477 if (null == position)
1479 throw new ArgumentNullException(nameof(position));
1481 var val = new Uint16Pair((uint)position.X, (uint)position.Y);
1482 Interop.Window.SetPosition(SwigCPtr, Uint16Pair.getCPtr(val));
1484 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1485 // Setting Position of the window should request a relayout of the tree.
1488 internal Position2D GetPosition()
1490 var val = new Uint16Pair(Interop.Window.GetPosition(SwigCPtr), true);
1491 Position2D ret = new Position2D(val.GetX(), val.GetY());
1493 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1497 internal void SetPositionSize(Rectangle positionSize)
1499 Interop.Window.SetPositionSize(SwigCPtr, Rectangle.getCPtr(positionSize));
1501 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1503 // Setting Position of the window should request a relayout of the tree.
1507 /// Enables the floating mode of window.
1508 /// The floating mode is to support window is moved or resized by display server.
1509 /// For example, if the video-player window sets the floating mode,
1510 /// then display server changes its geometry and handles it like a popup.
1511 /// The way of handling floating mode window is decided by display server.
1512 /// A special display server(as a Tizen display server) supports this mode.
1514 /// <param name="enable">Enable floating mode or not.</param>
1515 [EditorBrowsable(EditorBrowsableState.Never)]
1516 public void EnableFloatingMode(bool enable)
1518 Interop.Window.EnableFloatingMode(SwigCPtr, enable);
1519 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1523 /// Requests to display server for the window is moved by display server.
1524 /// It can be work with setting window floating mode.
1526 [EditorBrowsable(EditorBrowsableState.Never)]
1527 public void RequestMoveToServer()
1529 Interop.Window.RequestMoveToServer(SwigCPtr);
1530 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1534 /// Requests to display server for the window is resized by display server.
1535 /// It can be work with setting window floating mode.
1537 /// <param name="direction">It is indicated the window's side or edge for starting point.</param>
1538 [EditorBrowsable(EditorBrowsableState.Never)]
1539 public void RequestResizeToServer(ResizeDirection direction)
1541 Interop.Window.RequestResizeToServer(SwigCPtr, (int)direction);
1542 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1546 /// Includes input region.
1547 /// This function inlcudes input regions.
1548 /// It can be used multiple times and supports multiple regions.
1549 /// It means input region will be extended.
1550 /// This input is related to mouse and touch event.
1551 /// If device has touch screen, this function is useful.
1552 /// Otherwise device does not have that, we can use it after connecting mouse to the device.
1554 /// <param name="inputRegion">The included region to accept input events.</param>
1555 [EditorBrowsable(EditorBrowsableState.Never)]
1556 public void IncludeInputRegion(Rectangle inputRegion)
1558 Interop.Window.IncludeInputRegion(SwigCPtr, Rectangle.getCPtr(inputRegion));
1559 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1563 /// This function excludes input regions.
1564 /// It can be used multiple times and supports multiple regions.
1565 /// It means input region will be reduced.
1566 /// Nofice, should be set input area by IncludeInputRegion() before this function is used.
1567 /// This input is related to mouse and touch event.
1568 /// If device has touch screen, this function is useful.
1569 /// Otherwise device does not have that, we can use it after connecting mouse to the device.
1571 /// <param name="inputRegion">The excluded region to except input events.</param>
1572 [EditorBrowsable(EditorBrowsableState.Never)]
1573 public void ExcludeInputRegion(Rectangle inputRegion)
1575 Interop.Window.ExcludeInputRegion(SwigCPtr, Rectangle.getCPtr(inputRegion));
1576 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1580 /// Maximizes window's size.
1581 /// If this function is called with true, window will be resized with screen size.
1582 /// Otherwise window will be resized with previous size.
1583 /// It is for the window's MAX button in window's border.
1584 /// If window border is supported by display server, it is not necessary.
1586 /// <param name="max">If window is maximized or unmaximized.</param>
1587 [EditorBrowsable(EditorBrowsableState.Never)]
1588 public void Maximize(bool max)
1590 Interop.Window.Maximize(SwigCPtr, max);
1591 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1595 /// Returns whether the window is maximized or not.
1597 /// <returns>True if the window is maximized, false otherwise.</returns>
1598 [EditorBrowsable(EditorBrowsableState.Never)]
1599 public bool IsMaximized()
1601 bool ret = Interop.Window.IsMaximized(SwigCPtr);
1602 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1607 /// Minimizes window's size.
1608 /// If this function is called with true, window will be iconified.
1609 /// Otherwise window will be activated.
1610 /// It is for the window's MIN button in window border.
1611 /// If window border is supported by display server, it is not necessary.
1613 /// <param name="min">If window is minimized or unminimized.</param>
1614 [EditorBrowsable(EditorBrowsableState.Never)]
1615 public void Minimize(bool min)
1617 Interop.Window.Minimize(SwigCPtr, min);
1618 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1622 /// Returns whether the window is minimized or not.
1624 /// <returns>True if the window is minimized, false otherwise.</returns>
1625 [EditorBrowsable(EditorBrowsableState.Never)]
1626 public bool IsMinimized()
1628 bool ret = Interop.Window.IsMinimized(SwigCPtr);
1629 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1634 /// Add FrameUpdateCallback
1636 [EditorBrowsable(EditorBrowsableState.Never)]
1637 public void AddFrameUpdateCallback(FrameUpdateCallbackInterface frameUpdateCallback)
1639 frameUpdateCallback?.AddFrameUpdateCallback(stageCPtr, Layer.getCPtr(GetRootLayer()));
1643 /// Remove FrameUpdateCallback
1645 [EditorBrowsable(EditorBrowsableState.Never)]
1646 public void RemoveFrameUpdateCallback(FrameUpdateCallbackInterface frameUpdateCallback)
1648 frameUpdateCallback?.RemoveFrameUpdateCallback(stageCPtr);
1652 /// Dispose for Window
1654 [EditorBrowsable(EditorBrowsableState.Never)]
1655 protected override void Dispose(DisposeTypes type)
1662 if (type == DisposeTypes.Explicit)
1665 //Release your own managed resources here.
1666 //You should release all of your own disposable objects here.
1668 if (rootLayer != null)
1670 rootLayer.Dispose();
1673 localController?.Dispose();
1675 foreach (var layer in childLayers)
1683 childLayers.Clear();
1686 this.DisconnectNativeSignals();
1691 /// This will not be public opened.
1692 [EditorBrowsable(EditorBrowsableState.Never)]
1693 protected override void ReleaseSwigCPtr(System.Runtime.InteropServices.HandleRef swigCPtr)
1695 Interop.Window.DeleteWindow(swigCPtr);
1698 private static Dictionary<int, internalHookCallbackType> frameCallbackList = new Dictionary<int, internalHookCallbackType>();
1700 private static readonly object locker = new object();
1702 private static int key = 0;
1704 private static FrameCallbackType internalHookFrameCallback = OnInternalHookFrameCallback;
1706 private struct internalHookCallbackType
1708 public FrameCallbackType userCallback;
1712 private static void OnInternalHookFrameCallback(int id)
1716 if (frameCallbackList.ContainsKey(id))
1718 if (frameCallbackList[id].userCallback != null)
1720 frameCallbackList[id].userCallback.Invoke(frameCallbackList[id].frameId);
1721 frameCallbackList.Remove(id);
1725 NUILog.Error($"found userCallback is NULL");
1726 frameCallbackList.Remove(id);
1732 private int AddInterHookCallback(FrameCallbackType callback, int frameId)
1734 if (null == callback)
1736 throw new ArgumentNullException(nameof(callback), "FrameCallbackType should not be null");
1738 var assignedKey = 0;
1743 frameCallbackList.Add(assignedKey, new internalHookCallbackType()
1745 userCallback = callback,
1753 /// Type of callback which is called when the frame rendering is done by graphics driver or when the frame is displayed on display.
1755 /// <param name="frameId">The Id to specify the frame. It will be passed when the callback is called.</param>
1756 [EditorBrowsable(EditorBrowsableState.Never)]
1757 public delegate void FrameCallbackType(int frameId);
1760 /// Adds a callback that is called when the frame rendering is done by the graphics driver.
1761 /// A callback of the following type may be used:
1763 /// void MyFunction( int frameId )
1765 /// This callback will be deleted once it is called.
1767 /// Ownership of the callback is passed onto this class
1770 /// <param name="callback">The function to call</param>
1771 /// <param name="frameId">The Id to specify the frame. It will be passed when the callback is called.</param>
1772 /// <exception cref="ArgumentNullException">This exception can occur by the callback is null.</exception>
1773 [EditorBrowsable(EditorBrowsableState.Never)]
1774 public void AddFrameRenderedCallback(FrameCallbackType callback, int frameId)
1776 var assignedKey = AddInterHookCallback(callback, frameId);
1777 Interop.WindowInternal.AddFrameRenderedCallback(SwigCPtr, new HandleRef(this, Marshal.GetFunctionPointerForDelegate<Delegate>(internalHookFrameCallback)), assignedKey);
1779 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1783 /// Adds a callback that is called when the frame is displayed on the display.
1784 /// A callback of the following type may be used:
1786 /// void MyFunction( int frameId )
1788 /// This callback will be deleted once it is called.
1790 /// Ownership of the callback is passed onto this class
1793 /// <param name="callback">The function to call</param>
1794 /// <param name="frameId">The Id to specify the frame. It will be passed when the callback is called.</param>
1795 /// <exception cref="ArgumentNullException">This exception can occur by the callback is null.</exception>
1796 [EditorBrowsable(EditorBrowsableState.Never)]
1797 public void AddFramePresentedCallback(FrameCallbackType callback, int frameId)
1799 var assignedKey = AddInterHookCallback(callback, frameId);
1800 Interop.WindowInternal.AddFramePresentedCallback(SwigCPtr, new HandleRef(this, Marshal.GetFunctionPointerForDelegate<Delegate>(internalHookFrameCallback)), assignedKey);
1802 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1806 /// Search through this Window for a Layer with the given unique ID.
1808 /// <param name="id">The ID of the Layer to find.</param>
1809 /// <remarks>Hidden-API</remarks>
1810 /// <returns>A handle to the Layer if found, or an empty handle if not.</returns>
1811 [EditorBrowsable(EditorBrowsableState.Never)]
1812 public Layer FindLayerByID(uint id)
1814 Layer defaultLayer = this.GetDefaultLayer();
1815 IntPtr cPtr = Interop.Actor.FindChildById(defaultLayer.SwigCPtr, id);
1816 Layer ret = this.GetInstanceSafely<Layer>(cPtr);
1818 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1823 /// Get Native Window handle.
1825 /// How to get Native Window handle
1827 /// Window window = NUIApplication.GetDefaultWindow();
1828 /// var handle = window.NativeHandle;
1829 /// if(handle.IsInvalid == false)
1831 /// IntPtr nativeHandle = handle.DangerousGetHandle();
1832 /// // do something with nativeHandle
1837 /// <since_tizen> 9 </since_tizen>
1838 public SafeHandle NativeHandle
1842 return new NUI.SafeNativeWindowHandle(this);