2 * Copyright(c) 2021 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
18 extern alias TizenSystemInformation;
19 using TizenSystemInformation.Tizen.System;
22 using System.ComponentModel;
23 using System.Collections.Generic;
24 using System.Runtime.InteropServices;
26 using Tizen.NUI.BaseComponents;
31 /// The window class is used internally for drawing.<br />
32 /// The window has an orientation and indicator properties.<br />
34 /// <since_tizen> 3 </since_tizen>
35 public partial class Window : BaseHandle
37 private HandleRef stageCPtr;
38 private Layer rootLayer;
39 private Layer overlayLayer;
40 private Layer borderLayer;
41 private string windowTitle;
42 private List<Layer> childLayers = new List<Layer>();
43 private LayoutController localController;
44 private Key internalLastKeyEvent;
45 private Touch internalLastTouchEvent;
47 static internal bool IsSupportedMultiWindow()
49 bool isSupported = false;
52 Information.TryGetValue("http://tizen.org/feature/opengles.surfaceless_context", out isSupported);
54 catch (DllNotFoundException e)
56 Tizen.Log.Fatal("NUI", $"{e}\n");
61 internal Window(global::System.IntPtr cPtr, bool cMemoryOwn) : base(cPtr, cMemoryOwn)
63 if (Interop.Stage.IsInstalled())
65 stageCPtr = new global::System.Runtime.InteropServices.HandleRef(this, Interop.Stage.GetCurrent());
67 localController = new LayoutController(this);
68 NUILog.Debug("layoutController id:" + localController.GetId());
73 /// A helper method to get the current window where the view is added
75 /// <param name="view">The View added to the window</param>
76 /// <returns>A Window.</returns>
77 [EditorBrowsable(EditorBrowsableState.Never)]
78 static public Window Get(View view)
82 NUILog.Error("if there is no view, it can not get a window");
86 //to fix memory leak issue, match the handle count with native side.
87 Window ret = view.GetInstanceSafely<Window>(Interop.Window.Get(View.getCPtr(view)));
88 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
93 /// Creates a new Window.<br />
94 /// This creates an extra window in addition to the default main window<br />
96 /// <param name="windowPosition">The position and size of the Window.</param>
97 /// <param name="isTranslucent">Whether Window is translucent.</param>
98 /// <returns>A new Window.</returns>
99 /// <since_tizen> 6 </since_tizen>
100 /// <feature> http://tizen.org/feature/opengles.surfaceless_context </feature>
101 /// <exception cref="NotSupportedException">The required feature is not supported.</exception>
102 public Window(Rectangle windowPosition = null, bool isTranslucent = false) : this(Interop.Window.New(Rectangle.getCPtr(windowPosition), "", isTranslucent), true)
104 if (IsSupportedMultiWindow() == false)
106 NUILog.Error("This device does not support surfaceless_context. So Window cannot be created. ");
108 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
112 /// Creates a new Window with a specific name.<br />
113 /// This creates an extra window in addition to the default main window<br />
115 /// <param name="name">The name for extra window. </param>
116 /// <param name="windowPosition">The position and size of the Window.</param>
117 /// <param name="isTranslucent">Whether Window is translucent.</param>
118 /// <returns>A new Window.</returns>
119 /// <since_tizen> 6 </since_tizen>
120 /// <feature> http://tizen.org/feature/opengles.surfaceless_context </feature>
121 /// <exception cref="NotSupportedException">The required feature is not supported.</exception>
122 public Window(string name, Rectangle windowPosition = null, bool isTranslucent = false) : this(Interop.Window.New(Rectangle.getCPtr(windowPosition), name, isTranslucent), true)
124 if (IsSupportedMultiWindow() == false)
126 NUILog.Error("This device does not support surfaceless_context. So Window cannot be created. ");
128 this.windowTitle = name;
129 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
133 /// Creates a new Window with a specific name.<br />
134 /// This creates an extra window in addition to the default main window<br />
136 /// <param name="name">The name for extra window. </param>
137 /// <param name="borderInterface"><see cref="Tizen.NUI.IBorderInterface"/>If borderInterface is null, defaultBorder is enabled.</param>
138 /// <param name="windowPosition">The position and size of the Window.</param>
139 /// <param name="isTranslucent">Whether Window is translucent.</param>
140 /// <returns>A new Window.</returns>
141 /// <feature> http://tizen.org/feature/opengles.surfaceless_context </feature>
142 /// <exception cref="NotSupportedException">The required feature is not supported.</exception>
143 [EditorBrowsable(EditorBrowsableState.Never)]
144 public Window(string name, IBorderInterface borderInterface, Rectangle windowPosition = null, bool isTranslucent = false) : this(Interop.Window.New(Rectangle.getCPtr(windowPosition), name, isTranslucent), true)
146 if (IsSupportedMultiWindow() == false)
148 NUILog.Error("This device does not support surfaceless_context. So Window cannot be created. ");
150 this.windowTitle = name;
151 this.EnableBorder(borderInterface);
152 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
157 /// Enumeration for orientation of the window is the way in which a rectangular page is oriented for normal viewing.
159 /// <since_tizen> 3 </since_tizen>
160 public enum WindowOrientation
163 /// Portrait orientation. The height of the display area is greater than the width.
165 /// <since_tizen> 3 </since_tizen>
168 /// Landscape orientation. A wide view area is needed.
170 /// <since_tizen> 3 </since_tizen>
173 /// Portrait inverse orientation.
175 /// <since_tizen> 3 </since_tizen>
176 PortraitInverse = 180,
178 /// Landscape inverse orientation.
180 /// <since_tizen> 3 </since_tizen>
181 LandscapeInverse = 270,
183 /// No orientation. It is for the preferred orientation
184 /// Especially, NoOrientationPreference only has the effect for the preferred orientation.
185 /// It is used to unset the preferred orientation with SetPreferredOrientation.
187 [EditorBrowsable(EditorBrowsableState.Never)]
188 NoOrientationPreference = -1
192 /// Enumeration for the key grab mode for platform-level APIs.
194 /// <since_tizen> 3 </since_tizen>
195 public enum KeyGrabMode
198 /// Grabs a key only when on the top of the grabbing-window stack mode.
202 /// Grabs a key together with the other client window(s) mode.
206 /// 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.
210 /// Grabs a key exclusively regardless of the grabbing-window's position on the window stack mode.
216 /// Enumeration for transition effect's state.
218 [Obsolete("Do not use this, that will be removed. Use Window.EffectState instead.")]
219 [EditorBrowsable(EditorBrowsableState.Never)]
220 // This is already deprecated, so suppress warning here.
221 [System.Diagnostics.CodeAnalysis.SuppressMessage("Naming", "CA1717:Only FlagsAttribute enums should have plural names", Justification = "<Pending>")]
222 public enum EffectStates
227 [Obsolete("Do not use this, that will be removed. Use Window.EffectState.None instead.")]
228 [EditorBrowsable(EditorBrowsableState.Never)]
231 /// Transition effect is started.
233 [Obsolete("Do not use this, that will be removed. Use Window.EffectState.Start instead.")]
234 [EditorBrowsable(EditorBrowsableState.Never)]
237 /// Transition effect is ended.
239 [Obsolete("Do not use this, that will be removed. Use Window.EffectState.End instead.")]
240 [EditorBrowsable(EditorBrowsableState.Never)]
245 /// Enumeration for transition effect's state.
247 [EditorBrowsable(EditorBrowsableState.Never)]
248 public enum EffectState
253 [EditorBrowsable(EditorBrowsableState.Never)]
256 /// Transition effect is started.
258 [EditorBrowsable(EditorBrowsableState.Never)]
261 /// Transition effect is ended.
263 [EditorBrowsable(EditorBrowsableState.Never)]
268 /// Enumeration for transition effect's type.
270 [Obsolete("Do not use this, that will be removed. Use Window.EffectType instead.")]
271 [EditorBrowsable(EditorBrowsableState.Never)]
272 // This is already deprecated, so suppress warning here.
273 [System.Diagnostics.CodeAnalysis.SuppressMessage("Naming", "CA1717:Only FlagsAttribute enums should have plural names", Justification = "<Pending>")]
274 public enum EffectTypes
279 [Obsolete("Do not use this, that will be removed. Use Window.EffectType.None instead.")]
280 [EditorBrowsable(EditorBrowsableState.Never)]
283 /// Window show effect.
285 [Obsolete("Do not use this, that will be removed. Use Window.EffectType.Show instead.")]
286 [EditorBrowsable(EditorBrowsableState.Never)]
289 /// Window hide effect.
291 [Obsolete("Do not use this, that will be removed. Use Window.EffectType.Hide instead.")]
292 [EditorBrowsable(EditorBrowsableState.Never)]
297 /// Enumeration for transition effect's type.
299 [EditorBrowsable(EditorBrowsableState.Never)]
300 public enum EffectType
305 [EditorBrowsable(EditorBrowsableState.Never)]
308 /// Window show effect.
310 [EditorBrowsable(EditorBrowsableState.Never)]
313 /// Window hide effect.
315 [EditorBrowsable(EditorBrowsableState.Never)]
320 /// Enumeration for result of window operation.
322 internal enum OperationResult
325 /// Failed for unknown reason
333 /// Permission denied
337 /// The operation is not supported.
343 /// Enumeration for window resized mode by display server.
345 [EditorBrowsable(EditorBrowsableState.Never)]
346 public enum ResizeDirection
351 [EditorBrowsable(EditorBrowsableState.Never)]
354 /// Start resizing window to the top-left edge.
356 [EditorBrowsable(EditorBrowsableState.Never)]
359 /// Start resizing window to the top side.
361 [EditorBrowsable(EditorBrowsableState.Never)]
364 /// Start resizing window to the top-right edge.
366 [EditorBrowsable(EditorBrowsableState.Never)]
369 /// Start resizing window to the left side.
371 [EditorBrowsable(EditorBrowsableState.Never)]
374 /// Start resizing window to the right side.
376 [EditorBrowsable(EditorBrowsableState.Never)]
379 /// Start resizing window to the bottom-left edge.
381 [EditorBrowsable(EditorBrowsableState.Never)]
384 /// Start resizing window to the bottom side.
386 [EditorBrowsable(EditorBrowsableState.Never)]
389 /// Start resizing window to the bottom-right edge.
391 [EditorBrowsable(EditorBrowsableState.Never)]
397 /// The stage instance property (read-only).<br />
398 /// Gets the current window.<br />
400 /// <since_tizen> 3 </since_tizen>
401 public static Window Instance { get; internal set; }
404 /// Gets or sets a window type.
405 /// Most of window type can be set to use WindowType, except for IME type.
406 /// IME type can be set to use one of NUIApplication's constrcutors.
408 /// <since_tizen> 3 </since_tizen>
409 public WindowType Type
413 WindowType ret = (WindowType)Interop.Window.GetType(SwigCPtr);
414 if (NDalicPINVOKE.SWIGPendingException.Pending) throw new InvalidOperationException("FATAL: get Exception", NDalicPINVOKE.SWIGPendingException.Retrieve());
419 Interop.Window.SetType(SwigCPtr, (int)value);
420 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
425 /// Gets/Sets a window title.
427 /// <since_tizen> 4 </since_tizen>
437 SetClass(windowTitle, "");
442 /// The rendering behavior of a Window.
444 /// <since_tizen> 5 </since_tizen>
445 public RenderingBehaviorType RenderingBehavior
449 return GetRenderingBehavior();
453 SetRenderingBehavior(value);
458 /// The window size property (read-only).
460 /// <since_tizen> 3 </since_tizen>
465 Size2D ret = GetSize();
471 /// The background color property.
473 /// <since_tizen> 3 </since_tizen>
474 public Color BackgroundColor
478 SetBackgroundColor(value);
482 Color ret = GetBackgroundColor();
488 /// The DPI property (read-only).<br />
489 /// Retrieves the DPI of the display device to which the Window is connected.<br />
491 /// <since_tizen> 3 </since_tizen>
501 /// The layer count property (read-only).<br />
502 /// Queries the number of on-Window layers.<br />
504 /// <since_tizen> 3 </since_tizen>
505 public uint LayerCount
509 return GetLayerCount();
514 /// Gets or sets a size of the window.
516 /// <exception cref="ArgumentNullException"> Thrown when value is null. </exception>
517 /// <since_tizen> 4 </since_tizen>
518 public Size2D WindowSize
522 return GetWindowSize();
526 SetWindowSize(value);
531 /// Gets or sets a position of the window.
533 /// <exception cref="ArgumentNullException"> Thrown when value is null. </exception>
534 /// <since_tizen> 4 </since_tizen>
535 public Position2D WindowPosition
539 return GetPosition();
548 /// Sets position and size of the window. This API guarantees that
549 /// both moving and resizing of window will appear on the screen at once.
551 [EditorBrowsable(EditorBrowsableState.Never)]
552 public Rectangle WindowPositionSize
556 Position2D position = GetPosition();
557 Size2D size = GetSize();
558 Rectangle ret = new Rectangle(position?.X ?? 0, position?.Y ?? 0, size?.Width ?? 0, size?.Height ?? 0);
564 SetPositionSize(value);
568 internal static Vector4 DEFAULT_BACKGROUND_COLOR
572 global::System.IntPtr cPtr = Interop.Stage.DefaultBackgroundColorGet();
573 Vector4 ret = (cPtr == global::System.IntPtr.Zero) ? null : new Vector4(cPtr, false);
574 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
579 internal static Vector4 DEBUG_BACKGROUND_COLOR
583 global::System.IntPtr cPtr = Interop.Stage.DebugBackgroundColorGet();
584 Vector4 ret = (cPtr == global::System.IntPtr.Zero) ? null : new Vector4(cPtr, false);
585 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
590 internal List<Layer> LayersChildren
599 /// Get the LayoutController for this Window.
601 internal LayoutController LayoutController
605 return localController;
610 /// Feed a key-event into the window.
612 /// <param name="keyEvent">The key event to feed.</param>
613 /// <since_tizen> 4 </since_tizen>
614 [Obsolete("Do not use this, that will be deprecated. Use FeedKey(Key keyEvent) instead.")]
615 public static void FeedKeyEvent(Key keyEvent)
617 Interop.Window.FeedKeyEvent(Key.getCPtr(keyEvent));
618 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
622 /// Sets whether the window accepts a focus or not.
624 /// <param name="accept">If a focus is accepted or not. The default is true.</param>
625 /// <since_tizen> 3 </since_tizen>
626 public void SetAcceptFocus(bool accept)
628 Interop.Window.SetAcceptFocus(SwigCPtr, accept);
629 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
633 /// Returns whether the window accepts a focus or not.
635 /// <returns>True if the window accepts a focus, false otherwise.</returns>
636 /// <since_tizen> 3 </since_tizen>
637 public bool IsFocusAcceptable()
639 bool ret = Interop.Window.IsFocusAcceptable(SwigCPtr);
640 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
646 /// Shows the window if it is hidden.
648 /// <since_tizen> 3 </since_tizen>
651 Interop.Window.Show(SwigCPtr);
652 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
656 /// Hides the window if it is showing.
658 /// <since_tizen> 3 </since_tizen>
661 Interop.Window.Hide(SwigCPtr);
662 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
666 /// Retrieves whether the window is visible or not.
668 /// <returns>True if the window is visible.</returns>
669 /// <since_tizen> 3 </since_tizen>
670 public bool IsVisible()
672 bool temp = Interop.Window.IsVisible(SwigCPtr);
673 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
678 /// Gets the count of supported auxiliary hints of the window.
680 /// <returns>The number of supported auxiliary hints.</returns>
681 /// <since_tizen> 3 </since_tizen>
682 public uint GetSupportedAuxiliaryHintCount()
684 uint ret = Interop.Window.GetSupportedAuxiliaryHintCount(SwigCPtr);
685 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
690 /// Gets the supported auxiliary hint string of the window.
692 /// <param name="index">The index of the supported auxiliary hint lists.</param>
693 /// <returns>The auxiliary hint string of the index.</returns>
694 /// <since_tizen> 3 </since_tizen>
695 public string GetSupportedAuxiliaryHint(uint index)
697 string ret = Interop.Window.GetSupportedAuxiliaryHint(SwigCPtr, index);
698 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
703 /// Creates an auxiliary hint of the window.
705 /// <param name="hint">The auxiliary hint string.</param>
706 /// <param name="value">The value string.</param>
707 /// <returns>The ID of created auxiliary hint, or 0 on failure.</returns>
708 /// <since_tizen> 3 </since_tizen>
709 public uint AddAuxiliaryHint(string hint, string value)
711 uint ret = Interop.Window.AddAuxiliaryHint(SwigCPtr, hint, value);
712 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
717 /// Removes an auxiliary hint of the window.
719 /// <param name="id">The ID of the auxiliary hint.</param>
720 /// <returns>True if no error occurred, false otherwise.</returns>
721 /// <since_tizen> 3 </since_tizen>
722 public bool RemoveAuxiliaryHint(uint id)
724 bool ret = Interop.Window.RemoveAuxiliaryHint(SwigCPtr, id);
725 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
730 /// Changes a value of the auxiliary hint.
732 /// <param name="id">The auxiliary hint ID.</param>
733 /// <param name="value">The value string to be set.</param>
734 /// <returns>True if no error occurred, false otherwise.</returns>
735 /// <since_tizen> 3 </since_tizen>
736 public bool SetAuxiliaryHintValue(uint id, string value)
738 bool ret = Interop.Window.SetAuxiliaryHintValue(SwigCPtr, id, value);
739 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
744 /// Gets a value of the auxiliary hint.
746 /// <param name="id">The auxiliary hint ID.</param>
747 /// <returns>The string value of the auxiliary hint ID, or an empty string if none exists.</returns>
748 /// <since_tizen> 3 </since_tizen>
749 public string GetAuxiliaryHintValue(uint id)
751 string ret = Interop.Window.GetAuxiliaryHintValue(SwigCPtr, id);
752 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
757 /// Gets an ID of the auxiliary hint string.
759 /// <param name="hint">The auxiliary hint string.</param>
760 /// <returns>The ID of auxiliary hint string, or 0 on failure.</returns>
761 /// <since_tizen> 3 </since_tizen>
762 public uint GetAuxiliaryHintId(string hint)
764 uint ret = Interop.Window.GetAuxiliaryHintId(SwigCPtr, hint);
765 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
770 /// Sets a region to accept input events.
772 /// <param name="inputRegion">The region to accept input events.</param>
773 /// <since_tizen> 3 </since_tizen>
774 public void SetInputRegion(Rectangle inputRegion)
776 Interop.Window.SetInputRegion(SwigCPtr, Rectangle.getCPtr(inputRegion));
777 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
781 /// Sets a priority level for the specified notification window.
783 /// <param name="level">The notification window level.</param>
784 /// <returns>True if no error occurred, false otherwise.</returns>
785 /// <since_tizen> 3 </since_tizen>
786 public bool SetNotificationLevel(NotificationLevel level)
788 var ret = (OperationResult)Interop.Window.SetNotificationLevel(SwigCPtr, (int)level);
789 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
790 return ret == OperationResult.Succeed;
794 /// Gets a priority level for the specified notification window.
796 /// <returns>The notification window level.</returns>
797 /// <since_tizen> 3 </since_tizen>
798 public NotificationLevel GetNotificationLevel()
800 NotificationLevel ret = (NotificationLevel)Interop.Window.GetNotificationLevel(SwigCPtr);
801 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
806 /// Sets a transparent window's visual state to opaque. <br />
807 /// If a visual state of a transparent window is opaque, <br />
808 /// then the window manager could handle it as an opaque window when calculating visibility.
810 /// <param name="opaque">Whether the window's visual state is opaque.</param>
811 /// <remarks>This will have no effect on an opaque window. <br />
812 /// It doesn't change transparent window to opaque window but lets the window manager know the visual state of the window.
814 /// <since_tizen> 3 </since_tizen>
815 public void SetOpaqueState(bool opaque)
817 Interop.Window.SetOpaqueState(SwigCPtr, opaque);
818 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
822 /// Returns whether a transparent window's visual state is opaque or not.
824 /// <returns>True if the window's visual state is opaque, false otherwise.</returns>
825 /// <remarks> The return value has no meaning on an opaque window. </remarks>
826 /// <since_tizen> 3 </since_tizen>
827 public bool IsOpaqueState()
829 bool ret = Interop.Window.IsOpaqueState(SwigCPtr);
830 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
835 /// Sets a window's screen off mode.
837 /// <param name="screenOffMode">The screen mode.</param>
838 /// <returns>True if no error occurred, false otherwise.</returns>
839 /// <since_tizen> 4 </since_tizen>
840 public bool SetScreenOffMode(ScreenOffMode screenOffMode)
842 var ret = (OperationResult)Interop.Window.SetScreenOffMode(SwigCPtr, (int)screenOffMode);
843 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
844 return ret == OperationResult.Succeed;
848 /// Gets the screen mode of the window.
850 /// <returns>The screen off mode.</returns>
851 /// <since_tizen> 4 </since_tizen>
852 public ScreenOffMode GetScreenOffMode()
854 ScreenOffMode ret = (ScreenOffMode)Interop.Window.GetScreenOffMode(SwigCPtr);
855 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
860 /// Sets preferred brightness of the window.
862 /// <param name="brightness">The preferred brightness (0 to 100).</param>
863 /// <returns>True if no error occurred, false otherwise.</returns>
864 /// <since_tizen> 3 </since_tizen>
865 public bool SetBrightness(int brightness)
867 var ret = (OperationResult)Interop.Window.SetBrightness(SwigCPtr, brightness);
868 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
869 return ret == OperationResult.Succeed;
873 /// Gets the preferred brightness of the window.
875 /// <returns>The preferred brightness.</returns>
876 /// <since_tizen> 3 </since_tizen>
877 public int GetBrightness()
879 int ret = Interop.Window.GetBrightness(SwigCPtr);
880 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
885 /// Sets the window name and the class string.
887 /// <param name="name">The name of the window.</param>
888 /// <param name="klass">The class of the window.</param>
889 /// <since_tizen> 4 </since_tizen>
890 public void SetClass(string name, string klass)
892 Interop.Window.SetClass(SwigCPtr, name, klass);
893 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
897 /// Raises the window to the top of the window stack.
899 /// <since_tizen> 3 </since_tizen>
902 Interop.Window.Raise(SwigCPtr);
903 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
907 /// Lowers the window to the bottom of the window stack.
909 /// <since_tizen> 3 </since_tizen>
912 Interop.Window.Lower(SwigCPtr);
913 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
917 /// Activates the window to the top of the window stack even it is iconified.
919 /// <since_tizen> 3 </since_tizen>
920 public void Activate()
922 Interop.Window.Activate(SwigCPtr);
923 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
927 /// Gets the default ( root ) layer.
929 /// <returns>The root layer.</returns>
930 /// <since_tizen> 3 </since_tizen>
931 public Layer GetDefaultLayer()
933 return this.GetRootLayer();
937 /// Gets the overlay layer.
939 /// <returns>The overlay layer.</returns>
940 [EditorBrowsable(EditorBrowsableState.Never)]
941 public Layer GetOverlayLayer()
943 // Window.IsInstalled() is actually true only when called from event thread and
944 // Core has been initialized, not when Stage is ready.
945 if (overlayLayer == null && Window.IsInstalled())
947 overlayLayer = new Layer(Interop.Window.GetOverlayLayer(SwigCPtr), true);
948 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
949 LayersChildren?.Add(overlayLayer);
950 overlayLayer.SetWindow(this);
956 /// Add a child view to window.
958 /// <param name="view">the child should be added to the window.</param>
959 /// <since_tizen> 3 </since_tizen>
960 public void Add(View view)
962 this.GetRootLayer().Add(view);
966 /// Remove a child view from window.
968 /// <param name="view">the child to be removed.</param>
969 /// <since_tizen> 3 </since_tizen>
970 public void Remove(View view)
972 this.GetRootLayer().Remove(view);
976 /// Retrieves the layer at a specified depth.
978 /// <param name="depth">The layer's depth index.</param>
979 /// <returns>The layer found at the given depth.</returns>
980 /// <since_tizen> 3 </since_tizen>
981 public Layer GetLayer(uint depth)
983 if (depth < LayersChildren?.Count)
985 Layer ret = LayersChildren?[Convert.ToInt32(depth)];
995 /// Destroy the window immediately.
997 [EditorBrowsable(EditorBrowsableState.Never)]
998 public void Destroy()
1004 /// Keep rendering for at least the given amount of time.
1006 /// <param name="durationSeconds">Time to keep rendering, 0 means render at least one more frame.</param>
1007 /// <since_tizen> 3 </since_tizen>
1008 public void KeepRendering(float durationSeconds)
1010 Interop.Stage.KeepRendering(stageCPtr, durationSeconds);
1011 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1015 /// Grabs the key specified by a key for a window only when a window is the topmost window.<br />
1016 /// This function can be used for following example scenarios: <br />
1017 /// - Mobile - Using volume up or down as zoom up or down in camera apps.<br />
1019 /// <param name="DaliKey">The key code to grab.</param>
1020 /// <returns>True if the grab succeeds.</returns>
1021 /// <since_tizen> 3 </since_tizen>
1022 public bool GrabKeyTopmost(int DaliKey)
1024 bool ret = Interop.Window.GrabKeyTopmost(HandleRef.ToIntPtr(this.SwigCPtr), DaliKey);
1025 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1030 /// Ungrabs the key specified by a key for the window.<br />
1031 /// 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 />
1033 /// <param name="DaliKey">The key code to ungrab.</param>
1034 /// <returns>True if the ungrab succeeds.</returns>
1035 /// <since_tizen> 3 </since_tizen>
1036 public bool UngrabKeyTopmost(int DaliKey)
1038 bool ret = Interop.Window.UngrabKeyTopmost(HandleRef.ToIntPtr(this.SwigCPtr), DaliKey);
1039 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1044 /// Grabs the key specified by a key for a window in a GrabMode. <br />
1045 /// Details: This function can be used for following example scenarios: <br />
1046 /// - TV - A user might want to change the volume or channel of the background TV contents while focusing on the foregrund app. <br />
1047 /// - Mobile - When a user presses the Home key, the homescreen appears regardless of the current foreground app. <br />
1048 /// - Mobile - Using the volume up or down as zoom up or down in camera apps. <br />
1050 /// <param name="DaliKey">The key code to grab.</param>
1051 /// <param name="GrabMode">The grab mode for the key.</param>
1052 /// <returns>True if the grab succeeds.</returns>
1053 /// <since_tizen> 3 </since_tizen>
1054 public bool GrabKey(int DaliKey, KeyGrabMode GrabMode)
1056 bool ret = Interop.Window.GrabKey(HandleRef.ToIntPtr(this.SwigCPtr), DaliKey, (int)GrabMode);
1057 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1062 /// Ungrabs the key specified by a key for a window.<br />
1063 /// 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 />
1065 /// <param name="DaliKey">The key code to ungrab.</param>
1066 /// <returns>True if the ungrab succeeds.</returns>
1067 /// <since_tizen> 3 </since_tizen>
1068 public bool UngrabKey(int DaliKey)
1070 bool ret = Interop.Window.UngrabKey(HandleRef.ToIntPtr(this.SwigCPtr), DaliKey);
1071 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1076 /// Sets the keyboard repeat information.
1078 /// <param name="rate">The key repeat rate value in seconds.</param>
1079 /// <param name="delay">The key repeat delay value in seconds.</param>
1080 /// <returns>True if setting the keyboard repeat succeeds.</returns>
1081 /// <since_tizen> 5 </since_tizen>
1082 public bool SetKeyboardRepeatInfo(float rate, float delay)
1084 bool ret = Interop.Window.SetKeyboardRepeatInfo(rate, delay);
1085 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1090 /// Gets the keyboard repeat information.
1092 /// <param name="rate">The key repeat rate value in seconds.</param>
1093 /// <param name="delay">The key repeat delay value in seconds.</param>
1094 /// <returns>True if setting the keyboard repeat succeeds.</returns>
1095 /// <since_tizen> 5 </since_tizen>
1096 public bool GetKeyboardRepeatInfo(out float rate, out float delay)
1098 bool ret = Interop.Window.GetKeyboardRepeatInfo(out rate, out delay);
1099 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1104 /// Adds a layer to the stage.
1106 /// <param name="layer">Layer to add.</param>
1107 /// <exception cref="ArgumentNullException"> Thrown when layer is null. </exception>
1108 /// <since_tizen> 3 </since_tizen>
1109 public void AddLayer(Layer layer)
1115 /// Removes a layer from the stage.
1117 /// <param name="layer">Layer to remove.</param>
1118 /// <exception cref="ArgumentNullException"> Thrown when layer is null. </exception>
1119 /// <since_tizen> 3 </since_tizen>
1120 public void RemoveLayer(Layer layer)
1126 /// Feeds a key event into the window.
1128 /// <param name="keyEvent">The key event to feed.</param>
1129 /// <since_tizen> 5 </since_tizen>
1130 public void FeedKey(Key keyEvent)
1132 Interop.Window.FeedKeyEvent(SwigCPtr, Key.getCPtr(keyEvent));
1133 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1137 /// Feeds a touch point into the window.
1139 /// <param name="touchPoint">The touch point to feed.</param>
1140 /// <param name="timeStamp">The timeStamp.</param>
1141 internal void FeedTouch(TouchPoint touchPoint, int timeStamp)
1143 Interop.Window.FeedTouchPoint(SwigCPtr, TouchPoint.getCPtr(touchPoint), timeStamp);
1144 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1148 /// Feeds a wheel event into the window.
1150 /// <param name="wheelEvent">The wheel event to feed.</param>
1151 internal void FeedWheel(Wheel wheelEvent)
1153 Interop.Window.FeedWheelEvent(SwigCPtr, Wheel.getCPtr(wheelEvent));
1154 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1158 /// Allows at least one more render, even when paused.
1159 /// The window should be shown, not minimised.
1161 /// <since_tizen> 4 </since_tizen>
1162 public void RenderOnce()
1164 Interop.Window.RenderOnce(SwigCPtr);
1165 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1169 /// Sets whether the window is transparent or not.
1171 /// <param name="transparent">Whether the window is transparent or not.</param>
1172 /// <since_tizen> 5 </since_tizen>
1173 public void SetTransparency(bool transparent)
1175 Interop.Window.SetTransparency(SwigCPtr, transparent);
1176 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1178 // Setting transparency of the window should request a relayout of the tree in the case the window changes from fully transparent.
1182 /// Sets parent window of the window.
1183 /// After setting that, these windows do together when raise-up, lower and iconified/deiconified.
1184 /// Initially, the window is located on top of the parent. The window can go below parent by calling Lower().
1185 /// If parent's window stack is changed by calling Raise() or Lower(), child windows are located on top of the parent again.
1187 /// <param name="parent">The parent window.</param>
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 SetParent(Window parent)
1193 if (IsSupportedMultiWindow() == false)
1195 NUILog.Error("This device does not support surfaceless_context. So Window cannot be created. ");
1197 Interop.Window.SetParent(SwigCPtr, Window.getCPtr(parent));
1198 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1202 /// Sets parent window of the window.
1203 /// After setting that, these windows do together when raise-up, lower and iconified/deiconified.
1204 /// This function has the additional flag whether the child is located above or below of the parent.
1206 /// <param name="parent">The parent window.</param>
1207 /// <param name="belowParent">The flag is whether the child is located above or below of the parent.</param>
1208 /// <feature> http://tizen.org/feature/opengles.surfaceless_context </feature>
1209 /// <exception cref="NotSupportedException">The required feature is not supported.</exception>
1210 [EditorBrowsable(EditorBrowsableState.Never)]
1211 public void SetParent(Window parent, bool belowParent)
1213 if (IsSupportedMultiWindow() == false)
1215 NUILog.Error("This device does not support surfaceless_context. So Window cannot be created. ");
1217 Interop.Window.SetParentWithStack(SwigCPtr, Window.getCPtr(parent), belowParent);
1218 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1222 /// Unsets parent window of the window.
1223 /// After unsetting, the window is disconnected his parent window.
1225 /// <since_tizen> 6 </since_tizen>
1226 /// <feature> http://tizen.org/feature/opengles.surfaceless_context </feature>
1227 /// <exception cref="NotSupportedException">The required feature is not supported.</exception>
1228 public void Unparent()
1230 if (IsSupportedMultiWindow() == false)
1232 NUILog.Error("Fail to create window. because this device does not support opengles.surfaceless_context.");
1234 Interop.Window.Unparent(SwigCPtr);
1235 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1239 /// Gets parent window of the window.
1241 /// <returns>The parent window of the window.</returns>
1242 /// <since_tizen> 6 </since_tizen>
1243 /// <feature> http://tizen.org/feature/opengles.surfaceless_context </feature>
1244 /// <exception cref="NotSupportedException">The required feature is not supported.</exception>
1245 [System.Diagnostics.CodeAnalysis.SuppressMessage("Design", "CA1721: Property names should not match get methods")]
1246 public Window GetParent()
1248 if (IsSupportedMultiWindow() == false)
1250 NUILog.Error("This device does not support surfaceless_context. So Window cannot be created. ");
1252 Window ret = this.GetInstanceSafely<Window>(Interop.Window.GetParent(SwigCPtr));
1253 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1257 /// This will be public opened in tizen_next after ACR done. Before ACR, need to be hidden as inhouse API.
1258 [EditorBrowsable(EditorBrowsableState.Never)]
1259 public void ObjectDump()
1261 Layer rootLayer = GetRootLayer();
1262 foreach (View view in rootLayer.Children)
1268 internal static bool IsInstalled()
1270 bool ret = Interop.Stage.IsInstalled();
1271 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1276 /// Adds an orientation to the list of available orientations.
1278 /// <param name="orientation">The available orientation to add</param>
1279 /// <since_tizen> 6 </since_tizen>
1280 public void AddAvailableOrientation(Window.WindowOrientation orientation)
1282 Interop.Window.AddAvailableOrientation(SwigCPtr, (int)orientation);
1283 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1287 /// Removes an orientation from the list of available orientations.
1289 /// <param name="orientation">The available orientation to remove.</param>
1290 /// <since_tizen> 6 </since_tizen>
1291 public void RemoveAvailableOrientation(Window.WindowOrientation orientation)
1293 Interop.Window.RemoveAvailableOrientation(SwigCPtr, (int)orientation);
1294 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1298 /// Sets a preferred orientation.
1300 /// <param name="orientation">The preferred orientation.</param>
1301 /// <since_tizen> 6 </since_tizen>
1302 public void SetPreferredOrientation(Window.WindowOrientation orientation)
1304 Interop.Window.SetPreferredOrientation(SwigCPtr, (int)orientation);
1305 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1309 /// Gets the preferred orientation.
1311 /// <since_tizen> 6 </since_tizen>
1312 /// <returns>The preferred orientation if previously set, or none.</returns>
1313 public Window.WindowOrientation GetPreferredOrientation()
1315 Window.WindowOrientation ret = (Window.WindowOrientation)Interop.Window.GetPreferredOrientation(SwigCPtr);
1316 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1321 /// Gets current orientation of the window.
1323 /// <since_tizen> 6 </since_tizen>
1324 /// <returns>The current window orientation if previously set, or none.</returns>
1325 [EditorBrowsable(EditorBrowsableState.Never)]
1326 public Window.WindowOrientation GetCurrentOrientation()
1328 Window.WindowOrientation ret = (Window.WindowOrientation)Interop.Window.GetCurrentOrientation(SwigCPtr);
1329 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1334 /// Sets available orientations of the window.
1335 /// This API is for setting several orientations one time.
1337 /// <param name="orientations">The list of orientations.</param>
1338 /// <since_tizen> 6 </since_tizen>
1339 [EditorBrowsable(EditorBrowsableState.Never)]
1340 public void SetAvailableOrientations(List<Window.WindowOrientation> orientations)
1342 if (null == orientations)
1344 throw new ArgumentNullException(nameof(orientations));
1347 PropertyArray orientationArray = new PropertyArray();
1348 for (int i = 0; i < orientations.Count; i++)
1350 PropertyValue value = new PropertyValue((int)orientations[i]);
1351 orientationArray.PushBack(value);
1355 Interop.Window.SetAvailableOrientations(SwigCPtr, PropertyArray.getCPtr(orientationArray), orientations.Count);
1356 orientationArray.Dispose();
1357 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1361 /// Get native window ID
1363 /// <returns>native window ID</returns>
1364 [EditorBrowsable(EditorBrowsableState.Never)]
1365 public int GetNativeId()
1367 int ret = Interop.Window.GetNativeId(SwigCPtr);
1368 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1372 internal Any GetNativeHandle()
1374 Any ret = new Any(Interop.WindowInternal.WindowGetNativeHandle(SwigCPtr), true);
1375 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1379 internal void Add(Layer layer)
1383 throw new ArgumentNullException(nameof(layer));
1388 Interop.Actor.Add(GetRootLayer().SwigCPtr, layer.SwigCPtr);
1389 if (NDalicPINVOKE.SWIGPendingException.Pending) { throw NDalicPINVOKE.SWIGPendingException.Retrieve(); }
1393 Interop.Window.Add(SwigCPtr, Layer.getCPtr(layer));
1394 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1397 LayersChildren?.Add(layer);
1398 layer.SetWindow(this);
1401 internal void Remove(Layer layer)
1405 throw new ArgumentNullException(nameof(layer));
1407 Interop.Window.Remove(SwigCPtr, Layer.getCPtr(layer));
1408 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1410 LayersChildren?.Remove(layer);
1411 layer.SetWindow(null);
1414 internal Vector2 GetSize()
1416 var val = new Uint16Pair(Interop.Window.GetSize(SwigCPtr), true);
1418 convertRealWindowSizeToBorderWindowSize(val);
1420 Vector2 ret = new Vector2(val.GetWidth(), val.GetHeight());
1421 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1426 /// This will be public opened in next tizen after ACR done. Before ACR, need to be hidden as inhouse API.
1427 [EditorBrowsable(EditorBrowsableState.Never)]
1428 public RenderTaskList GetRenderTaskList()
1430 RenderTaskList ret = new RenderTaskList(Interop.Stage.GetRenderTaskList(stageCPtr), true);
1431 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1436 /// Queries the number of on-window layers.
1438 /// <returns>The number of layers.</returns>
1439 /// <remarks>Note that a default layer is always provided (count >= 1).</remarks>
1440 internal uint GetLayerCount()
1442 if (LayersChildren == null || LayersChildren.Count < 0)
1445 return (uint)LayersChildren.Count;
1448 internal Layer GetRootLayer()
1452 if (borderLayer == null)
1454 borderLayer = GetBorderWindowRootLayer();
1455 LayersChildren?.Add(borderLayer);
1456 borderLayer.SetWindow(this);
1462 // Window.IsInstalled() is actually true only when called from event thread and
1463 // Core has been initialized, not when Stage is ready.
1464 if (rootLayer == null && Window.IsInstalled())
1466 rootLayer = new Layer(Interop.Window.GetRootLayer(SwigCPtr), true);
1467 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1468 LayersChildren?.Add(rootLayer);
1469 rootLayer.SetWindow(this);
1475 internal void SetBackgroundColor(Vector4 color)
1477 Interop.Window.SetBackgroundColor(SwigCPtr, Vector4.getCPtr(color));
1478 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1481 internal Vector4 GetBackgroundColor()
1483 Vector4 ret = new Vector4(Interop.Window.GetBackgroundColor(SwigCPtr), true);
1484 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1488 internal Vector2 GetDpi()
1490 Vector2 ret = new Vector2(Interop.Stage.GetDpi(stageCPtr), true);
1491 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1495 internal ObjectRegistry GetObjectRegistry()
1497 ObjectRegistry ret = new ObjectRegistry(Interop.Stage.GetObjectRegistry(stageCPtr), true);
1498 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1502 internal void SetRenderingBehavior(RenderingBehaviorType renderingBehavior)
1504 Interop.Stage.SetRenderingBehavior(stageCPtr, (int)renderingBehavior);
1505 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1508 internal RenderingBehaviorType GetRenderingBehavior()
1510 RenderingBehaviorType ret = (RenderingBehaviorType)Interop.Stage.GetRenderingBehavior(stageCPtr);
1511 if (NDalicPINVOKE.SWIGPendingException.Pending)
1512 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1516 internal void SetWindowSize(Size2D size)
1520 throw new ArgumentNullException(nameof(size));
1522 var val = new Uint16Pair((uint)size.Width, (uint)size.Height);
1524 convertBorderWindowSizeToRealWindowSize(val);
1526 Interop.Window.SetSize(SwigCPtr, Uint16Pair.getCPtr(val));
1528 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1529 // Resetting Window size should request a relayout of the tree.
1532 internal Size2D GetWindowSize()
1534 var val = new Uint16Pair(Interop.Window.GetSize(SwigCPtr), true);
1536 convertRealWindowSizeToBorderWindowSize(val);
1538 Size2D ret = new Size2D(val.GetWidth(), val.GetHeight());
1539 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1544 internal void SetPosition(Position2D position)
1546 if (null == position)
1548 throw new ArgumentNullException(nameof(position));
1550 var val = new Int32Pair(position.X, position.Y);
1551 Interop.Window.SetPosition(SwigCPtr, Int32Pair.getCPtr(val));
1553 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1554 // Setting Position of the window should request a relayout of the tree.
1557 internal Position2D GetPosition()
1559 var val = new Int32Pair(Interop.Window.GetPosition(SwigCPtr), true);
1560 Position2D ret = new Position2D((int)val.GetX(), (int)val.GetY());
1562 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1566 internal void SetPositionSize(Rectangle positionSize)
1568 if (positionSize == null)
1570 throw new ArgumentNullException(nameof(positionSize));
1572 var val = new Uint16Pair((uint)positionSize.Width, (uint)positionSize.Height);
1574 convertBorderWindowSizeToRealWindowSize(val);
1576 positionSize.Width = val.GetX();
1577 positionSize.Height = val.GetY();
1579 Interop.Window.SetPositionSize(SwigCPtr, Rectangle.getCPtr(positionSize));
1582 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1584 // Setting Position of the window should request a relayout of the tree.
1588 /// Enables the floating mode of window.
1589 /// The floating mode is to support window is moved or resized by display server.
1590 /// For example, if the video-player window sets the floating mode,
1591 /// then display server changes its geometry and handles it like a popup.
1592 /// The way of handling floating mode window is decided by display server.
1593 /// A special display server(as a Tizen display server) supports this mode.
1595 /// <param name="enable">Enable floating mode or not.</param>
1596 [EditorBrowsable(EditorBrowsableState.Never)]
1597 public void EnableFloatingMode(bool enable)
1599 Interop.Window.EnableFloatingMode(SwigCPtr, enable);
1600 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1604 /// Requests to display server for the window is moved by display server.
1605 /// It can be work with setting window floating mode.
1607 [EditorBrowsable(EditorBrowsableState.Never)]
1608 public void RequestMoveToServer()
1610 Interop.Window.RequestMoveToServer(SwigCPtr);
1611 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1615 /// Requests to display server for the window is resized by display server.
1616 /// It can be work with setting window floating mode.
1618 /// <param name="direction">It is indicated the window's side or edge for starting point.</param>
1619 [EditorBrowsable(EditorBrowsableState.Never)]
1620 public void RequestResizeToServer(ResizeDirection direction)
1622 Interop.Window.RequestResizeToServer(SwigCPtr, (int)direction);
1623 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1627 /// Includes input region.
1628 /// This function inlcudes input regions.
1629 /// It can be used multiple times and supports multiple regions.
1630 /// It means input region will be extended.
1631 /// This input is related to mouse and touch event.
1632 /// If device has touch screen, this function is useful.
1633 /// Otherwise device does not have that, we can use it after connecting mouse to the device.
1635 /// <param name="inputRegion">The included region to accept input events.</param>
1636 [EditorBrowsable(EditorBrowsableState.Never)]
1637 public void IncludeInputRegion(Rectangle inputRegion)
1639 Interop.Window.IncludeInputRegion(SwigCPtr, Rectangle.getCPtr(inputRegion));
1640 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1644 /// This function excludes input regions.
1645 /// It can be used multiple times and supports multiple regions.
1646 /// It means input region will be reduced.
1647 /// Nofice, should be set input area by IncludeInputRegion() before this function is used.
1648 /// This input is related to mouse and touch event.
1649 /// If device has touch screen, this function is useful.
1650 /// Otherwise device does not have that, we can use it after connecting mouse to the device.
1652 /// <param name="inputRegion">The excluded region to except input events.</param>
1653 [EditorBrowsable(EditorBrowsableState.Never)]
1654 public void ExcludeInputRegion(Rectangle inputRegion)
1656 Interop.Window.ExcludeInputRegion(SwigCPtr, Rectangle.getCPtr(inputRegion));
1657 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1661 /// Maximizes window's size.
1662 /// If this function is called with true, window will be resized with screen size.
1663 /// Otherwise window will be resized with previous size.
1664 /// It is for the window's MAX button in window's border.
1665 /// If window border is supported by display server, it is not necessary.
1667 /// <param name="max">If window is maximized or unmaximized.</param>
1668 [EditorBrowsable(EditorBrowsableState.Never)]
1669 public void Maximize(bool max)
1671 Interop.Window.Maximize(SwigCPtr, max);
1672 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1676 /// Returns whether the window is maximized or not.
1678 /// <returns>True if the window is maximized, false otherwise.</returns>
1679 [EditorBrowsable(EditorBrowsableState.Never)]
1680 public bool IsMaximized()
1682 bool ret = Interop.Window.IsMaximized(SwigCPtr);
1683 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1688 /// Sets window's maximum size.
1690 /// It is to set the maximized size when window is maximized or the window's size is increased by RequestResizeToServer().
1691 /// Although the size is set by this function, window's size can be increased over the limitation by SetPositionSize() or SetSize().
1693 /// After setting, if Maximize() is called, window is resized with the setting size and move the center.
1696 /// <param name="size">the maximum size.</param>
1697 [EditorBrowsable(EditorBrowsableState.Never)]
1698 public void SetMaximumSize(Size2D size)
1702 throw new ArgumentNullException(nameof(size));
1704 var val = new Uint16Pair((uint)size.Width, (uint)size.Height);
1706 Interop.Window.SetMaximumSize(SwigCPtr, Uint16Pair.getCPtr(val));
1708 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1712 /// Minimizes window's size.
1713 /// If this function is called with true, window will be iconified.
1714 /// Otherwise window will be activated.
1715 /// It is for the window's MIN button in window border.
1716 /// If window border is supported by display server, it is not necessary.
1718 /// <param name="min">If window is minimized or unminimized.</param>
1719 [EditorBrowsable(EditorBrowsableState.Never)]
1720 public void Minimize(bool min)
1722 Interop.Window.Minimize(SwigCPtr, min);
1723 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1727 /// Returns whether the window is minimized or not.
1729 /// <returns>True if the window is minimized, false otherwise.</returns>
1730 [EditorBrowsable(EditorBrowsableState.Never)]
1731 public bool IsMinimized()
1733 bool ret = Interop.Window.IsMinimized(SwigCPtr);
1734 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1739 /// Sets window's minimum size.
1740 /// It is to set the minimum size when window's size is decreased by RequestResizeToServer().
1741 /// Although the size is set by this function, window's size can be decreased over the limitation by SetPositionSize() or SetSize().
1743 /// <param name="size">the minimum size.</param>
1744 [EditorBrowsable(EditorBrowsableState.Never)]
1745 public void SetMimimumSize(Size2D size)
1749 throw new ArgumentNullException(nameof(size));
1751 var val = new Uint16Pair((uint)size.Width, (uint)size.Height);
1753 Interop.Window.SetMimimumSize(SwigCPtr, Uint16Pair.getCPtr(val));
1755 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1759 /// Sets the layout of the window.
1761 /// <param name="numCols">The number of columns in the layout.</param>
1762 /// <param name="numRows">The number of rows in the layout.</param>
1763 /// <param name="column">The column number of the window within the layout.</param>
1764 /// <param name="row">The row number of the window within the layout.</param>
1765 /// <param name="colSpan">The number of columns the window should span within the layout.</param>
1766 /// <param name="rowSpan">The number of rows the window should span within the layout.</param>
1767 [EditorBrowsable(EditorBrowsableState.Never)]
1768 public void SetLayout(uint numCols, uint numRows, uint column, uint row, uint colSpan, uint rowSpan)
1770 Interop.Window.SetLayout(SwigCPtr, numCols, numRows, column, row, colSpan, rowSpan);
1771 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1776 /// Sets the layout of the window.
1778 /// <param name="layoutType">The type of layout to set for the window.</param>
1779 [EditorBrowsable(EditorBrowsableState.Never)]
1780 public void SetLayout(WindowLayoutType layoutType)
1784 case WindowLayoutType.LeftHalf:
1785 Interop.Window.SetLayout(SwigCPtr, 2, 1, 0, 0, 1, 1);
1787 case WindowLayoutType.RightHalf:
1788 Interop.Window.SetLayout(SwigCPtr, 2, 1, 1, 0, 1, 1);
1791 case WindowLayoutType.TopHalf:
1792 Interop.Window.SetLayout(SwigCPtr, 1, 2, 0, 0, 1, 1);
1794 case WindowLayoutType.BottomHalf:
1795 Interop.Window.SetLayout(SwigCPtr, 1, 2, 0, 1, 1, 1);
1798 case WindowLayoutType.UpperLeftQuarter:
1799 Interop.Window.SetLayout(SwigCPtr, 2, 2, 0, 0, 1, 1);
1801 case WindowLayoutType.UpperRightQuarter:
1802 Interop.Window.SetLayout(SwigCPtr, 2, 2, 1, 0, 1, 1);
1804 case WindowLayoutType.LowerLeftQuarter:
1805 Interop.Window.SetLayout(SwigCPtr, 2, 2, 0, 1, 1, 1);
1807 case WindowLayoutType.LowerRightQuarter:
1808 Interop.Window.SetLayout(SwigCPtr, 2, 2, 1, 1, 1, 1);
1811 case WindowLayoutType.LeftThird:
1812 Interop.Window.SetLayout(SwigCPtr, 3, 1, 0, 0, 1, 1);
1814 case WindowLayoutType.CenterThird:
1815 Interop.Window.SetLayout(SwigCPtr, 3, 1, 1, 0, 1, 1);
1817 case WindowLayoutType.RightThird:
1818 Interop.Window.SetLayout(SwigCPtr, 3, 1, 2, 0, 1, 1);
1821 case WindowLayoutType.TopThird:
1822 Interop.Window.SetLayout(SwigCPtr, 1, 3, 0, 0, 1, 1);
1824 case WindowLayoutType.MiddleThird:
1825 Interop.Window.SetLayout(SwigCPtr, 1, 3, 0, 1, 1, 1);
1827 case WindowLayoutType.BottomThird:
1828 Interop.Window.SetLayout(SwigCPtr, 1, 3, 0, 2, 1, 1);
1831 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1836 /// Query whether window is rotating or not.
1838 /// <returns>True if window is rotating, false otherwise.</returns>
1839 [EditorBrowsable(EditorBrowsableState.Never)]
1840 public bool IsWindowRotating()
1842 bool ret = Interop.Window.IsWindowRotating(SwigCPtr);
1843 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1848 /// Gets the last key event the window gets.
1850 /// <returns>The last key event the window gets.</returns>
1851 [EditorBrowsable(EditorBrowsableState.Never)]
1852 public Key GetLastKeyEvent()
1854 if(internalLastKeyEvent == null)
1856 internalLastKeyEvent = new Key();
1858 Interop.Window.InternalRetrievingLastKeyEvent(SwigCPtr, internalLastKeyEvent.SwigCPtr);
1859 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1860 return internalLastKeyEvent;
1864 /// Gets the last touch event the window gets.
1866 /// <returns>The last touch event the window gets.</returns>
1867 [EditorBrowsable(EditorBrowsableState.Never)]
1868 public Touch GetLastTouchEvent()
1870 if(internalLastTouchEvent == null)
1872 internalLastTouchEvent = new Touch();
1874 Interop.Window.InternalRetrievingLastTouchEvent(SwigCPtr, internalLastTouchEvent.SwigCPtr);
1875 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1876 return internalLastTouchEvent;
1880 /// Sets the necessary for window rotation Acknowledgement.
1881 /// After this function called, SendRotationCompletedAcknowledgement() should be called to complete window rotation.
1883 /// This function is supprot that application has the window rotation acknowledgement's control.
1884 /// It means display server waits when application's rotation work is finished.
1885 /// It is useful application has the other rendering engine which works asynchronous.
1886 /// For instance, GlView.
1888 /// <param name="needAcknowledgement">the flag is true if window rotation acknowledge is sent.</param>
1889 [EditorBrowsable(EditorBrowsableState.Never)]
1890 public void SetNeedsRotationCompletedAcknowledgement(bool needAcknowledgement)
1892 Interop.Window.SetNeedsRotationCompletedAcknowledgement(SwigCPtr, needAcknowledgement);
1893 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1897 /// send the Acknowledgement to complete window rotation.
1898 /// For this function, SetNeedsRotationCompletedAcknowledgement should be already called with true.
1900 [EditorBrowsable(EditorBrowsableState.Never)]
1901 public void SendRotationCompletedAcknowledgement()
1903 Interop.Window.SendRotationCompletedAcknowledgement(SwigCPtr);
1904 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1908 /// Add FrameUpdateCallback
1910 [EditorBrowsable(EditorBrowsableState.Never)]
1911 public void AddFrameUpdateCallback(FrameUpdateCallbackInterface frameUpdateCallback)
1913 frameUpdateCallback?.AddFrameUpdateCallback(stageCPtr, Layer.getCPtr(GetRootLayer()));
1917 /// Remove FrameUpdateCallback
1919 [EditorBrowsable(EditorBrowsableState.Never)]
1920 public void RemoveFrameUpdateCallback(FrameUpdateCallbackInterface frameUpdateCallback)
1922 frameUpdateCallback?.RemoveFrameUpdateCallback(stageCPtr);
1926 /// Dispose for Window
1928 [EditorBrowsable(EditorBrowsableState.Never)]
1929 protected override void Dispose(DisposeTypes type)
1936 this.DisconnectNativeSignals();
1938 if (type == DisposeTypes.Explicit)
1941 //Release your own managed resources here.
1942 //You should release all of your own disposable objects here.
1944 if (IsBorderEnabled)
1949 foreach (var layer in childLayers)
1957 childLayers.Clear();
1959 localController?.Dispose();
1961 internalLastKeyEvent?.Dispose();
1962 internalLastKeyEvent = null;
1963 internalLastTouchEvent?.Dispose();
1964 internalLastTouchEvent = null;
1971 /// This will not be public opened.
1972 [EditorBrowsable(EditorBrowsableState.Never)]
1973 protected override void ReleaseSwigCPtr(System.Runtime.InteropServices.HandleRef swigCPtr)
1975 Interop.Window.DeleteWindow(swigCPtr);
1978 private static Dictionary<int, internalHookCallbackType> frameCallbackList = new Dictionary<int, internalHookCallbackType>();
1980 private static readonly object locker = new object();
1982 private static int key = 0;
1984 private static FrameCallbackType internalHookFrameCallback = OnInternalHookFrameCallback;
1986 private struct internalHookCallbackType
1988 public FrameCallbackType userCallback;
1992 private static void OnInternalHookFrameCallback(int id)
1996 if (frameCallbackList.ContainsKey(id))
1998 if (frameCallbackList[id].userCallback != null)
2000 frameCallbackList[id].userCallback.Invoke(frameCallbackList[id].frameId);
2001 frameCallbackList.Remove(id);
2005 NUILog.Error($"found userCallback is NULL");
2006 frameCallbackList.Remove(id);
2012 private int AddInterHookCallback(FrameCallbackType callback, int frameId)
2014 if (null == callback)
2016 throw new ArgumentNullException(nameof(callback), "FrameCallbackType should not be null");
2018 var assignedKey = 0;
2023 frameCallbackList.Add(assignedKey, new internalHookCallbackType()
2025 userCallback = callback,
2033 /// Type of callback which is called when the frame rendering is done by graphics driver or when the frame is displayed on display.
2035 /// <param name="frameId">The Id to specify the frame. It will be passed when the callback is called.</param>
2036 [EditorBrowsable(EditorBrowsableState.Never)]
2037 public delegate void FrameCallbackType(int frameId);
2040 /// Adds a callback that is called when the frame rendering is done by the graphics driver.
2041 /// A callback of the following type may be used:
2043 /// void MyFunction( int frameId )
2045 /// This callback will be deleted once it is called.
2047 /// Ownership of the callback is passed onto this class
2050 /// <param name="callback">The function to call</param>
2051 /// <param name="frameId">The Id to specify the frame. It will be passed when the callback is called.</param>
2052 /// <exception cref="ArgumentNullException">This exception can occur by the callback is null.</exception>
2053 [EditorBrowsable(EditorBrowsableState.Never)]
2054 public void AddFrameRenderedCallback(FrameCallbackType callback, int frameId)
2056 var assignedKey = AddInterHookCallback(callback, frameId);
2057 Interop.WindowInternal.AddFrameRenderedCallback(SwigCPtr, new HandleRef(this, Marshal.GetFunctionPointerForDelegate<Delegate>(internalHookFrameCallback)), assignedKey);
2059 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
2063 /// Adds a callback that is called when the frame is displayed on the display.
2064 /// A callback of the following type may be used:
2066 /// void MyFunction( int frameId )
2068 /// This callback will be deleted once it is called.
2070 /// Ownership of the callback is passed onto this class
2073 /// <param name="callback">The function to call</param>
2074 /// <param name="frameId">The Id to specify the frame. It will be passed when the callback is called.</param>
2075 /// <exception cref="ArgumentNullException">This exception can occur by the callback is null.</exception>
2076 [EditorBrowsable(EditorBrowsableState.Never)]
2077 public void AddFramePresentedCallback(FrameCallbackType callback, int frameId)
2079 var assignedKey = AddInterHookCallback(callback, frameId);
2080 Interop.WindowInternal.AddFramePresentedCallback(SwigCPtr, new HandleRef(this, Marshal.GetFunctionPointerForDelegate<Delegate>(internalHookFrameCallback)), assignedKey);
2082 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
2086 /// Search through this Window for a Layer with the given unique ID.
2088 /// <param name="id">The ID of the Layer to find.</param>
2089 /// <remarks>Hidden-API</remarks>
2090 /// <returns>A handle to the Layer if found, or an empty handle if not.</returns>
2091 [EditorBrowsable(EditorBrowsableState.Never)]
2092 public Layer FindLayerByID(uint id)
2094 Layer defaultLayer = this.GetDefaultLayer();
2095 IntPtr cPtr = Interop.Actor.FindChildById(defaultLayer.SwigCPtr, id);
2096 Layer ret = this.GetInstanceSafely<Layer>(cPtr);
2098 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
2103 /// Get Native Window handle.
2105 /// How to get Native Window handle
2107 /// Window window = NUIApplication.GetDefaultWindow();
2108 /// var handle = window.NativeHandle;
2109 /// if(handle.IsInvalid == false)
2111 /// IntPtr nativeHandle = handle.DangerousGetHandle();
2112 /// // do something with nativeHandle
2117 /// <since_tizen> 9 </since_tizen>
2118 public SafeHandle NativeHandle
2122 return new NUI.SafeNativeWindowHandle(this);