2 * Copyright(c) 2021 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
18 extern alias TizenSystemInformation;
19 using TizenSystemInformation.Tizen.System;
22 using System.ComponentModel;
23 using System.Collections.Generic;
24 using System.Runtime.InteropServices;
26 using Tizen.NUI.BaseComponents;
31 /// The window class is used internally for drawing.<br />
32 /// The window has an orientation and indicator properties.<br />
34 /// <since_tizen> 3 </since_tizen>
35 public partial class Window : BaseHandle
37 private HandleRef stageCPtr;
38 private Layer rootLayer;
39 private Layer borderLayer;
40 private string windowTitle;
41 private List<Layer> childLayers = new List<Layer>();
42 private LayoutController localController;
44 static internal bool IsSupportedMultiWindow()
46 bool isSupported = false;
49 Information.TryGetValue("http://tizen.org/feature/opengles.surfaceless_context", out isSupported);
51 catch (DllNotFoundException e)
53 Tizen.Log.Fatal("NUI", $"{e}\n");
58 internal Window(global::System.IntPtr cPtr, bool cMemoryOwn) : base(cPtr, cMemoryOwn)
60 if (Interop.Stage.IsInstalled())
62 stageCPtr = new global::System.Runtime.InteropServices.HandleRef(this, Interop.Stage.GetCurrent());
64 localController = new LayoutController(this);
65 NUILog.Debug("layoutController id:" + localController.GetId());
70 /// A helper method to get the current window where the view is added
72 /// <param name="view">The View added to the window</param>
73 /// <returns>A Window.</returns>
74 [EditorBrowsable(EditorBrowsableState.Never)]
75 static public Window Get(View view)
79 NUILog.Error("if there is no view, it can not get a window");
83 //to fix memory leak issue, match the handle count with native side.
84 Window ret = view.GetInstanceSafely<Window>(Interop.Window.Get(View.getCPtr(view)));
85 if (NDalicPINVOKE.SWIGPendingException.Pending)throw NDalicPINVOKE.SWIGPendingException.Retrieve();
90 /// Creates a new Window.<br />
91 /// This creates an extra window in addition to the default main window<br />
93 /// <param name="windowPosition">The position and size of the Window.</param>
94 /// <param name="isTranslucent">Whether Window is translucent.</param>
95 /// <returns>A new Window.</returns>
96 /// <since_tizen> 6 </since_tizen>
97 /// <feature> http://tizen.org/feature/opengles.surfaceless_context </feature>
98 /// <exception cref="NotSupportedException">The required feature is not supported.</exception>
99 public Window(Rectangle windowPosition = null, bool isTranslucent = false) : this(Interop.Window.New(Rectangle.getCPtr(windowPosition), "", isTranslucent), true)
101 if (IsSupportedMultiWindow() == false)
103 NUILog.Error("This device does not support surfaceless_context. So Window cannot be created. ");
105 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
109 /// Creates a new Window with a specific name.<br />
110 /// This creates an extra window in addition to the default main window<br />
112 /// <param name="name">The name for extra window. </param>
113 /// <param name="windowPosition">The position and size of the Window.</param>
114 /// <param name="isTranslucent">Whether Window is translucent.</param>
115 /// <returns>A new Window.</returns>
116 /// <since_tizen> 6 </since_tizen>
117 /// <feature> http://tizen.org/feature/opengles.surfaceless_context </feature>
118 /// <exception cref="NotSupportedException">The required feature is not supported.</exception>
119 public Window(string name, Rectangle windowPosition = null, bool isTranslucent = false) : this(Interop.Window.New(Rectangle.getCPtr(windowPosition), name, isTranslucent), true)
121 if (IsSupportedMultiWindow() == false)
123 NUILog.Error("This device does not support surfaceless_context. So Window cannot be created. ");
125 this.windowTitle = name;
126 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
130 /// Creates a new Window with a specific name.<br />
131 /// This creates an extra window in addition to the default main window<br />
133 /// <param name="name">The name for extra window. </param>
134 /// <param name="borderInterface"><see cref="Tizen.NUI.IBorderInterface"/>If borderInterface is null, defaultBorder is enabled.</param>
135 /// <param name="windowPosition">The position and size of the Window.</param>
136 /// <param name="isTranslucent">Whether Window is translucent.</param>
137 /// <returns>A new Window.</returns>
138 /// <feature> http://tizen.org/feature/opengles.surfaceless_context </feature>
139 /// <exception cref="NotSupportedException">The required feature is not supported.</exception>
140 [EditorBrowsable(EditorBrowsableState.Never)]
141 public Window(string name, IBorderInterface borderInterface, Rectangle windowPosition = null, bool isTranslucent = false) : this(Interop.Window.New(Rectangle.getCPtr(windowPosition), name, isTranslucent), true)
143 if (IsSupportedMultiWindow() == false)
145 NUILog.Error("This device does not support surfaceless_context. So Window cannot be created. ");
147 this.windowTitle = name;
148 this.EnableBorder(borderInterface);
149 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
154 /// Enumeration for orientation of the window is the way in which a rectangular page is oriented for normal viewing.
156 /// <since_tizen> 3 </since_tizen>
157 public enum WindowOrientation
160 /// Portrait orientation. The height of the display area is greater than the width.
162 /// <since_tizen> 3 </since_tizen>
165 /// Landscape orientation. A wide view area is needed.
167 /// <since_tizen> 3 </since_tizen>
170 /// Portrait inverse orientation.
172 /// <since_tizen> 3 </since_tizen>
173 PortraitInverse = 180,
175 /// Landscape inverse orientation.
177 /// <since_tizen> 3 </since_tizen>
178 LandscapeInverse = 270,
180 /// No orientation. It is for the preferred orientation
181 /// Especially, NoOrientationPreference only has the effect for the preferred orientation.
182 /// It is used to unset the preferred orientation with SetPreferredOrientation.
184 [EditorBrowsable(EditorBrowsableState.Never)]
185 NoOrientationPreference = -1
189 /// Enumeration for the key grab mode for platform-level APIs.
191 /// <since_tizen> 3 </since_tizen>
192 public enum KeyGrabMode
195 /// Grabs a key only when on the top of the grabbing-window stack mode.
199 /// Grabs a key together with the other client window(s) mode.
203 /// 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.
207 /// Grabs a key exclusively regardless of the grabbing-window's position on the window stack mode.
213 /// Enumeration for transition effect's state.
215 [Obsolete("Do not use this, that will be removed. Use Window.EffectState instead.")]
216 [EditorBrowsable(EditorBrowsableState.Never)]
217 // This is already deprecated, so suppress warning here.
218 [System.Diagnostics.CodeAnalysis.SuppressMessage("Naming", "CA1717:Only FlagsAttribute enums should have plural names", Justification = "<Pending>")]
219 public enum EffectStates
224 [Obsolete("Do not use this, that will be removed. Use Window.EffectState.None instead.")]
225 [EditorBrowsable(EditorBrowsableState.Never)]
228 /// Transition effect is started.
230 [Obsolete("Do not use this, that will be removed. Use Window.EffectState.Start instead.")]
231 [EditorBrowsable(EditorBrowsableState.Never)]
234 /// Transition effect is ended.
236 [Obsolete("Do not use this, that will be removed. Use Window.EffectState.End instead.")]
237 [EditorBrowsable(EditorBrowsableState.Never)]
242 /// Enumeration for transition effect's state.
244 [EditorBrowsable(EditorBrowsableState.Never)]
245 public enum EffectState
250 [EditorBrowsable(EditorBrowsableState.Never)]
253 /// Transition effect is started.
255 [EditorBrowsable(EditorBrowsableState.Never)]
258 /// Transition effect is ended.
260 [EditorBrowsable(EditorBrowsableState.Never)]
265 /// Enumeration for transition effect's type.
267 [Obsolete("Do not use this, that will be removed. Use Window.EffectType instead.")]
268 [EditorBrowsable(EditorBrowsableState.Never)]
269 // This is already deprecated, so suppress warning here.
270 [System.Diagnostics.CodeAnalysis.SuppressMessage("Naming", "CA1717:Only FlagsAttribute enums should have plural names", Justification = "<Pending>")]
271 public enum EffectTypes
276 [Obsolete("Do not use this, that will be removed. Use Window.EffectType.None instead.")]
277 [EditorBrowsable(EditorBrowsableState.Never)]
280 /// Window show effect.
282 [Obsolete("Do not use this, that will be removed. Use Window.EffectType.Show instead.")]
283 [EditorBrowsable(EditorBrowsableState.Never)]
286 /// Window hide effect.
288 [Obsolete("Do not use this, that will be removed. Use Window.EffectType.Hide instead.")]
289 [EditorBrowsable(EditorBrowsableState.Never)]
294 /// Enumeration for transition effect's type.
296 [EditorBrowsable(EditorBrowsableState.Never)]
297 public enum EffectType
302 [EditorBrowsable(EditorBrowsableState.Never)]
305 /// Window show effect.
307 [EditorBrowsable(EditorBrowsableState.Never)]
310 /// Window hide effect.
312 [EditorBrowsable(EditorBrowsableState.Never)]
317 /// Enumeration for result of window operation.
319 internal enum OperationResult
322 /// Failed for unknown reason
330 /// Permission denied
334 /// The operation is not supported.
340 /// Enumeration for window resized mode by display server.
342 [EditorBrowsable(EditorBrowsableState.Never)]
343 public enum ResizeDirection
348 [EditorBrowsable(EditorBrowsableState.Never)]
351 /// Start resizing window to the top-left edge.
353 [EditorBrowsable(EditorBrowsableState.Never)]
356 /// Start resizing window to the top side.
358 [EditorBrowsable(EditorBrowsableState.Never)]
361 /// Start resizing window to the top-right edge.
363 [EditorBrowsable(EditorBrowsableState.Never)]
366 /// Start resizing window to the left side.
368 [EditorBrowsable(EditorBrowsableState.Never)]
371 /// Start resizing window to the right side.
373 [EditorBrowsable(EditorBrowsableState.Never)]
376 /// Start resizing window to the bottom-left edge.
378 [EditorBrowsable(EditorBrowsableState.Never)]
381 /// Start resizing window to the bottom side.
383 [EditorBrowsable(EditorBrowsableState.Never)]
386 /// Start resizing window to the bottom-right edge.
388 [EditorBrowsable(EditorBrowsableState.Never)]
394 /// The stage instance property (read-only).<br />
395 /// Gets the current window.<br />
397 /// <since_tizen> 3 </since_tizen>
398 public static Window Instance { get; internal set; }
401 /// Gets or sets a window type.
402 /// Most of window type can be set to use WindowType, except for IME type.
403 /// IME type can be set to use one of NUIApplication's constrcutors.
405 /// <since_tizen> 3 </since_tizen>
406 public WindowType Type
410 WindowType ret = (WindowType)Interop.Window.GetType(SwigCPtr);
411 if (NDalicPINVOKE.SWIGPendingException.Pending) throw new InvalidOperationException("FATAL: get Exception", NDalicPINVOKE.SWIGPendingException.Retrieve());
416 Interop.Window.SetType(SwigCPtr, (int)value);
417 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
422 /// Gets/Sets a window title.
424 /// <since_tizen> 4 </since_tizen>
434 SetClass(windowTitle, "");
439 /// The rendering behavior of a Window.
441 /// <since_tizen> 5 </since_tizen>
442 public RenderingBehaviorType RenderingBehavior
446 return GetRenderingBehavior();
450 SetRenderingBehavior(value);
455 /// The window size property (read-only).
457 /// <since_tizen> 3 </since_tizen>
462 Size2D ret = GetSize();
468 /// The background color property.
470 /// <since_tizen> 3 </since_tizen>
471 public Color BackgroundColor
475 SetBackgroundColor(value);
479 Color ret = GetBackgroundColor();
485 /// The DPI property (read-only).<br />
486 /// Retrieves the DPI of the display device to which the Window is connected.<br />
488 /// <since_tizen> 3 </since_tizen>
498 /// The layer count property (read-only).<br />
499 /// Queries the number of on-Window layers.<br />
501 /// <since_tizen> 3 </since_tizen>
502 public uint LayerCount
506 return GetLayerCount();
511 /// Gets or sets a size of the window.
513 /// <exception cref="ArgumentNullException"> Thrown when value is null. </exception>
514 /// <since_tizen> 4 </since_tizen>
515 public Size2D WindowSize
519 return GetWindowSize();
523 SetWindowSize(value);
528 /// Gets or sets a position of the window.
530 /// <exception cref="ArgumentNullException"> Thrown when value is null. </exception>
531 /// <since_tizen> 4 </since_tizen>
532 public Position2D WindowPosition
536 return GetPosition();
545 /// Sets position and size of the window. This API guarantees that
546 /// both moving and resizing of window will appear on the screen at once.
548 [EditorBrowsable(EditorBrowsableState.Never)]
549 public Rectangle WindowPositionSize
553 Position2D position = GetPosition();
554 Size2D size = GetSize();
555 Rectangle ret = new Rectangle(position.X, position.Y, size.Width, size.Height);
561 SetPositionSize(value);
565 internal static Vector4 DEFAULT_BACKGROUND_COLOR
569 global::System.IntPtr cPtr = Interop.Stage.DefaultBackgroundColorGet();
570 Vector4 ret = (cPtr == global::System.IntPtr.Zero) ? null : new Vector4(cPtr, false);
571 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
576 internal static Vector4 DEBUG_BACKGROUND_COLOR
580 global::System.IntPtr cPtr = Interop.Stage.DebugBackgroundColorGet();
581 Vector4 ret = (cPtr == global::System.IntPtr.Zero) ? null : new Vector4(cPtr, false);
582 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
587 internal List<Layer> LayersChildren
596 /// Get the LayoutController for this Window.
598 internal LayoutController LayoutController
602 return localController;
607 /// Feed a key-event into the window.
609 /// <param name="keyEvent">The key event to feed.</param>
610 /// <since_tizen> 4 </since_tizen>
611 [Obsolete("Do not use this, that will be deprecated. Use FeedKey(Key keyEvent) instead.")]
612 public static void FeedKeyEvent(Key keyEvent)
614 Interop.Window.FeedKeyEvent(Key.getCPtr(keyEvent));
615 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
619 /// Sets whether the window accepts a focus or not.
621 /// <param name="accept">If a focus is accepted or not. The default is true.</param>
622 /// <since_tizen> 3 </since_tizen>
623 public void SetAcceptFocus(bool accept)
625 Interop.Window.SetAcceptFocus(SwigCPtr, accept);
626 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
630 /// Returns whether the window accepts a focus or not.
632 /// <returns>True if the window accepts a focus, false otherwise.</returns>
633 /// <since_tizen> 3 </since_tizen>
634 public bool IsFocusAcceptable()
636 bool ret = Interop.Window.IsFocusAcceptable(SwigCPtr);
637 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
643 /// Shows the window if it is hidden.
645 /// <since_tizen> 3 </since_tizen>
648 Interop.Window.Show(SwigCPtr);
649 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
653 /// Hides the window if it is showing.
655 /// <since_tizen> 3 </since_tizen>
658 Interop.Window.Hide(SwigCPtr);
659 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
663 /// Retrieves whether the window is visible or not.
665 /// <returns>True if the window is visible.</returns>
666 /// <since_tizen> 3 </since_tizen>
667 public bool IsVisible()
669 bool temp = Interop.Window.IsVisible(SwigCPtr);
670 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
675 /// Gets the count of supported auxiliary hints of the window.
677 /// <returns>The number of supported auxiliary hints.</returns>
678 /// <since_tizen> 3 </since_tizen>
679 public uint GetSupportedAuxiliaryHintCount()
681 uint ret = Interop.Window.GetSupportedAuxiliaryHintCount(SwigCPtr);
682 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
687 /// Gets the supported auxiliary hint string of the window.
689 /// <param name="index">The index of the supported auxiliary hint lists.</param>
690 /// <returns>The auxiliary hint string of the index.</returns>
691 /// <since_tizen> 3 </since_tizen>
692 public string GetSupportedAuxiliaryHint(uint index)
694 string ret = Interop.Window.GetSupportedAuxiliaryHint(SwigCPtr, index);
695 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
700 /// Creates an auxiliary hint of the window.
702 /// <param name="hint">The auxiliary hint string.</param>
703 /// <param name="value">The value string.</param>
704 /// <returns>The ID of created auxiliary hint, or 0 on failure.</returns>
705 /// <since_tizen> 3 </since_tizen>
706 public uint AddAuxiliaryHint(string hint, string value)
708 uint ret = Interop.Window.AddAuxiliaryHint(SwigCPtr, hint, value);
709 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
714 /// Removes an auxiliary hint of the window.
716 /// <param name="id">The ID of the auxiliary hint.</param>
717 /// <returns>True if no error occurred, false otherwise.</returns>
718 /// <since_tizen> 3 </since_tizen>
719 public bool RemoveAuxiliaryHint(uint id)
721 bool ret = Interop.Window.RemoveAuxiliaryHint(SwigCPtr, id);
722 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
727 /// Changes a value of the auxiliary hint.
729 /// <param name="id">The auxiliary hint ID.</param>
730 /// <param name="value">The value string to be set.</param>
731 /// <returns>True if no error occurred, false otherwise.</returns>
732 /// <since_tizen> 3 </since_tizen>
733 public bool SetAuxiliaryHintValue(uint id, string value)
735 bool ret = Interop.Window.SetAuxiliaryHintValue(SwigCPtr, id, value);
736 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
741 /// Gets a value of the auxiliary hint.
743 /// <param name="id">The auxiliary hint ID.</param>
744 /// <returns>The string value of the auxiliary hint ID, or an empty string if none exists.</returns>
745 /// <since_tizen> 3 </since_tizen>
746 public string GetAuxiliaryHintValue(uint id)
748 string ret = Interop.Window.GetAuxiliaryHintValue(SwigCPtr, id);
749 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
754 /// Gets an ID of the auxiliary hint string.
756 /// <param name="hint">The auxiliary hint string.</param>
757 /// <returns>The ID of auxiliary hint string, or 0 on failure.</returns>
758 /// <since_tizen> 3 </since_tizen>
759 public uint GetAuxiliaryHintId(string hint)
761 uint ret = Interop.Window.GetAuxiliaryHintId(SwigCPtr, hint);
762 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
767 /// Sets a region to accept input events.
769 /// <param name="inputRegion">The region to accept input events.</param>
770 /// <since_tizen> 3 </since_tizen>
771 public void SetInputRegion(Rectangle inputRegion)
773 Interop.Window.IncludeInputRegion(SwigCPtr, Rectangle.getCPtr(inputRegion));
774 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
778 /// Sets a priority level for the specified notification window.
780 /// <param name="level">The notification window level.</param>
781 /// <returns>True if no error occurred, false otherwise.</returns>
782 /// <since_tizen> 3 </since_tizen>
783 public bool SetNotificationLevel(NotificationLevel level)
785 var ret = (OperationResult)Interop.Window.SetNotificationLevel(SwigCPtr, (int)level);
786 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
787 return ret == OperationResult.Succeed;
791 /// Gets a priority level for the specified notification window.
793 /// <returns>The notification window level.</returns>
794 /// <since_tizen> 3 </since_tizen>
795 public NotificationLevel GetNotificationLevel()
797 NotificationLevel ret = (NotificationLevel)Interop.Window.GetNotificationLevel(SwigCPtr);
798 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
803 /// Sets a transparent window's visual state to opaque. <br />
804 /// If a visual state of a transparent window is opaque, <br />
805 /// then the window manager could handle it as an opaque window when calculating visibility.
807 /// <param name="opaque">Whether the window's visual state is opaque.</param>
808 /// <remarks>This will have no effect on an opaque window. <br />
809 /// It doesn't change transparent window to opaque window but lets the window manager know the visual state of the window.
811 /// <since_tizen> 3 </since_tizen>
812 public void SetOpaqueState(bool opaque)
814 Interop.Window.SetOpaqueState(SwigCPtr, opaque);
815 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
819 /// Returns whether a transparent window's visual state is opaque or not.
821 /// <returns>True if the window's visual state is opaque, false otherwise.</returns>
822 /// <remarks> The return value has no meaning on an opaque window. </remarks>
823 /// <since_tizen> 3 </since_tizen>
824 public bool IsOpaqueState()
826 bool ret = Interop.Window.IsOpaqueState(SwigCPtr);
827 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
832 /// Sets a window's screen off mode.
834 /// <param name="screenOffMode">The screen mode.</param>
835 /// <returns>True if no error occurred, false otherwise.</returns>
836 /// <since_tizen> 4 </since_tizen>
837 public bool SetScreenOffMode(ScreenOffMode screenOffMode)
839 var ret = (OperationResult)Interop.Window.SetScreenOffMode(SwigCPtr, (int)screenOffMode);
840 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
841 return ret == OperationResult.Succeed;
845 /// Gets the screen mode of the window.
847 /// <returns>The screen off mode.</returns>
848 /// <since_tizen> 4 </since_tizen>
849 public ScreenOffMode GetScreenOffMode()
851 ScreenOffMode ret = (ScreenOffMode)Interop.Window.GetScreenOffMode(SwigCPtr);
852 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
857 /// Sets preferred brightness of the window.
859 /// <param name="brightness">The preferred brightness (0 to 100).</param>
860 /// <returns>True if no error occurred, false otherwise.</returns>
861 /// <since_tizen> 3 </since_tizen>
862 public bool SetBrightness(int brightness)
864 var ret = (OperationResult)Interop.Window.SetBrightness(SwigCPtr, brightness);
865 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
866 return ret == OperationResult.Succeed;
870 /// Gets the preferred brightness of the window.
872 /// <returns>The preferred brightness.</returns>
873 /// <since_tizen> 3 </since_tizen>
874 public int GetBrightness()
876 int ret = Interop.Window.GetBrightness(SwigCPtr);
877 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
882 /// Sets the window name and the class string.
884 /// <param name="name">The name of the window.</param>
885 /// <param name="klass">The class of the window.</param>
886 /// <since_tizen> 4 </since_tizen>
887 public void SetClass(string name, string klass)
889 Interop.Window.SetClass(SwigCPtr, name, klass);
890 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
894 /// Raises the window to the top of the window stack.
896 /// <since_tizen> 3 </since_tizen>
899 Interop.Window.Raise(SwigCPtr);
900 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
904 /// Lowers the window to the bottom of the window stack.
906 /// <since_tizen> 3 </since_tizen>
909 Interop.Window.Lower(SwigCPtr);
910 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
914 /// Activates the window to the top of the window stack even it is iconified.
916 /// <since_tizen> 3 </since_tizen>
917 public void Activate()
919 Interop.Window.Activate(SwigCPtr);
920 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
924 /// Gets the default ( root ) layer.
926 /// <returns>The root layer.</returns>
927 /// <since_tizen> 3 </since_tizen>
928 public Layer GetDefaultLayer()
930 return this.GetRootLayer();
934 /// Add a child view to window.
936 /// <param name="view">the child should be added to the window.</param>
937 /// <since_tizen> 3 </since_tizen>
938 public void Add(View view)
940 this.GetRootLayer().Add(view);
944 /// Remove a child view from window.
946 /// <param name="view">the child to be removed.</param>
947 /// <since_tizen> 3 </since_tizen>
948 public void Remove(View view)
950 this.GetRootLayer().Remove(view);
954 /// Retrieves the layer at a specified depth.
956 /// <param name="depth">The layer's depth index.</param>
957 /// <returns>The layer found at the given depth.</returns>
958 /// <since_tizen> 3 </since_tizen>
959 public Layer GetLayer(uint depth)
961 if (depth < LayersChildren?.Count)
963 Layer ret = LayersChildren?[Convert.ToInt32(depth)];
973 /// Destroy the window immediately.
975 [EditorBrowsable(EditorBrowsableState.Never)]
976 public void Destroy()
982 /// Keep rendering for at least the given amount of time.
984 /// <param name="durationSeconds">Time to keep rendering, 0 means render at least one more frame.</param>
985 /// <since_tizen> 3 </since_tizen>
986 public void KeepRendering(float durationSeconds)
988 Interop.Stage.KeepRendering(stageCPtr, durationSeconds);
989 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
993 /// Grabs the key specified by a key for a window only when a window is the topmost window.<br />
994 /// This function can be used for following example scenarios: <br />
995 /// - Mobile - Using volume up or down as zoom up or down in camera apps.<br />
997 /// <param name="DaliKey">The key code to grab.</param>
998 /// <returns>True if the grab succeeds.</returns>
999 /// <since_tizen> 3 </since_tizen>
1000 public bool GrabKeyTopmost(int DaliKey)
1002 bool ret = Interop.Window.GrabKeyTopmost(HandleRef.ToIntPtr(this.SwigCPtr), DaliKey);
1003 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1008 /// Ungrabs the key specified by a key for the window.<br />
1009 /// 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 />
1011 /// <param name="DaliKey">The key code to ungrab.</param>
1012 /// <returns>True if the ungrab succeeds.</returns>
1013 /// <since_tizen> 3 </since_tizen>
1014 public bool UngrabKeyTopmost(int DaliKey)
1016 bool ret = Interop.Window.UngrabKeyTopmost(HandleRef.ToIntPtr(this.SwigCPtr), DaliKey);
1017 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1022 /// Grabs the key specified by a key for a window in a GrabMode. <br />
1023 /// Details: This function can be used for following example scenarios: <br />
1024 /// - TV - A user might want to change the volume or channel of the background TV contents while focusing on the foregrund app. <br />
1025 /// - Mobile - When a user presses the Home key, the homescreen appears regardless of the current foreground app. <br />
1026 /// - Mobile - Using the volume up or down as zoom up or down in camera apps. <br />
1028 /// <param name="DaliKey">The key code to grab.</param>
1029 /// <param name="GrabMode">The grab mode for the key.</param>
1030 /// <returns>True if the grab succeeds.</returns>
1031 /// <since_tizen> 3 </since_tizen>
1032 public bool GrabKey(int DaliKey, KeyGrabMode GrabMode)
1034 bool ret = Interop.Window.GrabKey(HandleRef.ToIntPtr(this.SwigCPtr), DaliKey, (int)GrabMode);
1035 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1040 /// Ungrabs the key specified by a key for a window.<br />
1041 /// 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 />
1043 /// <param name="DaliKey">The key code to ungrab.</param>
1044 /// <returns>True if the ungrab succeeds.</returns>
1045 /// <since_tizen> 3 </since_tizen>
1046 public bool UngrabKey(int DaliKey)
1048 bool ret = Interop.Window.UngrabKey(HandleRef.ToIntPtr(this.SwigCPtr), DaliKey);
1049 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1054 /// Sets the keyboard repeat information.
1056 /// <param name="rate">The key repeat rate value in seconds.</param>
1057 /// <param name="delay">The key repeat delay value in seconds.</param>
1058 /// <returns>True if setting the keyboard repeat succeeds.</returns>
1059 /// <since_tizen> 5 </since_tizen>
1060 public bool SetKeyboardRepeatInfo(float rate, float delay)
1062 bool ret = Interop.Window.SetKeyboardRepeatInfo(rate, delay);
1063 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1068 /// Gets the keyboard repeat information.
1070 /// <param name="rate">The key repeat rate value in seconds.</param>
1071 /// <param name="delay">The key repeat delay value in seconds.</param>
1072 /// <returns>True if setting the keyboard repeat succeeds.</returns>
1073 /// <since_tizen> 5 </since_tizen>
1074 public bool GetKeyboardRepeatInfo(out float rate, out float delay)
1076 bool ret = Interop.Window.GetKeyboardRepeatInfo(out rate, out delay);
1077 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1082 /// Adds a layer to the stage.
1084 /// <param name="layer">Layer to add.</param>
1085 /// <exception cref="ArgumentNullException"> Thrown when layer is null. </exception>
1086 /// <since_tizen> 3 </since_tizen>
1087 public void AddLayer(Layer layer)
1093 /// Removes a layer from the stage.
1095 /// <param name="layer">Layer to remove.</param>
1096 /// <exception cref="ArgumentNullException"> Thrown when layer is null. </exception>
1097 /// <since_tizen> 3 </since_tizen>
1098 public void RemoveLayer(Layer layer)
1104 /// Feeds a key event into the window.
1106 /// <param name="keyEvent">The key event to feed.</param>
1107 /// <since_tizen> 5 </since_tizen>
1108 public void FeedKey(Key keyEvent)
1110 Interop.Window.FeedKeyEvent(SwigCPtr, Key.getCPtr(keyEvent));
1111 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1115 /// Feeds a touch point into the window.
1117 /// <param name="touchPoint">The touch point to feed.</param>
1118 /// <param name="timeStamp">The timeStamp.</param>
1119 internal void FeedTouch(TouchPoint touchPoint, int timeStamp)
1121 Interop.Window.FeedTouchPoint(SwigCPtr, TouchPoint.getCPtr(touchPoint), timeStamp);
1122 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1126 /// Feeds a wheel event into the window.
1128 /// <param name="wheelEvent">The wheel event to feed.</param>
1129 internal void FeedWheel(Wheel wheelEvent)
1131 Interop.Window.FeedWheelEvent(SwigCPtr, Wheel.getCPtr(wheelEvent));
1132 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1136 /// Allows at least one more render, even when paused.
1137 /// The window should be shown, not minimised.
1139 /// <since_tizen> 4 </since_tizen>
1140 public void RenderOnce()
1142 Interop.Window.RenderOnce(SwigCPtr);
1143 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1147 /// Sets whether the window is transparent or not.
1149 /// <param name="transparent">Whether the window is transparent or not.</param>
1150 /// <since_tizen> 5 </since_tizen>
1151 public void SetTransparency(bool transparent)
1153 Interop.Window.SetTransparency(SwigCPtr, transparent);
1154 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1156 // Setting transparency of the window should request a relayout of the tree in the case the window changes from fully transparent.
1160 /// Sets parent window of the window.
1161 /// After setting that, these windows do together when raise-up, lower and iconified/deiconified.
1162 /// Initially, the window is located on top of the parent. The window can go below parent by calling Lower().
1163 /// If parent's window stack is changed by calling Raise() or Lower(), child windows are located on top of the parent again.
1165 /// <param name="parent">The parent window.</param>
1166 /// <since_tizen> 6 </since_tizen>
1167 /// <feature> http://tizen.org/feature/opengles.surfaceless_context </feature>
1168 /// <exception cref="NotSupportedException">The required feature is not supported.</exception>
1169 public void SetParent(Window parent)
1171 if (IsSupportedMultiWindow() == false)
1173 NUILog.Error("This device does not support surfaceless_context. So Window cannot be created. ");
1175 Interop.Window.SetParent(SwigCPtr, Window.getCPtr(parent));
1176 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1180 /// Sets parent window of the window.
1181 /// After setting that, these windows do together when raise-up, lower and iconified/deiconified.
1182 /// This function has the additional flag whether the child is located above or below of the parent.
1184 /// <param name="parent">The parent window.</param>
1185 /// <param name="belowParent">The flag is whether the child is located above or below of the parent.</param>
1186 /// <feature> http://tizen.org/feature/opengles.surfaceless_context </feature>
1187 /// <exception cref="NotSupportedException">The required feature is not supported.</exception>
1188 [EditorBrowsable(EditorBrowsableState.Never)]
1189 public void SetParent(Window parent, bool belowParent)
1191 if (IsSupportedMultiWindow() == false)
1193 NUILog.Error("This device does not support surfaceless_context. So Window cannot be created. ");
1195 Interop.Window.SetParentWithStack(SwigCPtr, Window.getCPtr(parent), belowParent);
1196 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1200 /// Unsets parent window of the window.
1201 /// After unsetting, the window is disconnected his parent window.
1203 /// <since_tizen> 6 </since_tizen>
1204 /// <feature> http://tizen.org/feature/opengles.surfaceless_context </feature>
1205 /// <exception cref="NotSupportedException">The required feature is not supported.</exception>
1206 public void Unparent()
1208 if (IsSupportedMultiWindow() == false)
1210 NUILog.Error("Fail to create window. because this device does not support opengles.surfaceless_context.");
1212 Interop.Window.Unparent(SwigCPtr);
1213 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1217 /// Gets parent window of the window.
1219 /// <returns>The parent window of the window.</returns>
1220 /// <since_tizen> 6 </since_tizen>
1221 /// <feature> http://tizen.org/feature/opengles.surfaceless_context </feature>
1222 /// <exception cref="NotSupportedException">The required feature is not supported.</exception>
1223 [System.Diagnostics.CodeAnalysis.SuppressMessage("Design", "CA1721: Property names should not match get methods")]
1224 public Window GetParent()
1226 if (IsSupportedMultiWindow() == false)
1228 NUILog.Error("This device does not support surfaceless_context. So Window cannot be created. ");
1230 Window ret = this.GetInstanceSafely<Window>(Interop.Window.GetParent(SwigCPtr));
1231 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1235 /// This will be public opened in tizen_next after ACR done. Before ACR, need to be hidden as inhouse API.
1236 [EditorBrowsable(EditorBrowsableState.Never)]
1237 public void ObjectDump()
1239 Layer rootLayer = GetRootLayer();
1240 foreach (View view in rootLayer.Children)
1246 internal static bool IsInstalled()
1248 bool ret = Interop.Stage.IsInstalled();
1249 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1254 /// Adds an orientation to the list of available orientations.
1256 /// <param name="orientation">The available orientation to add</param>
1257 /// <since_tizen> 6 </since_tizen>
1258 public void AddAvailableOrientation(Window.WindowOrientation orientation)
1260 Interop.Window.AddAvailableOrientation(SwigCPtr, (int)orientation);
1261 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1265 /// Removes an orientation from the list of available orientations.
1267 /// <param name="orientation">The available orientation to remove.</param>
1268 /// <since_tizen> 6 </since_tizen>
1269 public void RemoveAvailableOrientation(Window.WindowOrientation orientation)
1271 Interop.Window.RemoveAvailableOrientation(SwigCPtr, (int)orientation);
1272 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1276 /// Sets a preferred orientation.
1278 /// <param name="orientation">The preferred orientation.</param>
1279 /// <since_tizen> 6 </since_tizen>
1280 public void SetPreferredOrientation(Window.WindowOrientation orientation)
1282 Interop.Window.SetPreferredOrientation(SwigCPtr, (int)orientation);
1283 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1287 /// Gets the preferred orientation.
1289 /// <since_tizen> 6 </since_tizen>
1290 /// <returns>The preferred orientation if previously set, or none.</returns>
1291 public Window.WindowOrientation GetPreferredOrientation()
1293 Window.WindowOrientation ret = (Window.WindowOrientation)Interop.Window.GetPreferredOrientation(SwigCPtr);
1294 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1299 /// Gets current orientation of the window.
1301 /// <since_tizen> 6 </since_tizen>
1302 /// <returns>The current window orientation if previously set, or none.</returns>
1303 [EditorBrowsable(EditorBrowsableState.Never)]
1304 public Window.WindowOrientation GetCurrentOrientation()
1306 Window.WindowOrientation ret = (Window.WindowOrientation)Interop.Window.GetCurrentOrientation(SwigCPtr);
1307 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1312 /// Sets available orientations of the window.
1313 /// This API is for setting several orientations one time.
1315 /// <param name="orientations">The list of orientations.</param>
1316 /// <since_tizen> 6 </since_tizen>
1317 [EditorBrowsable(EditorBrowsableState.Never)]
1318 public void SetAvailableOrientations(List<Window.WindowOrientation> orientations)
1320 if (null == orientations)
1322 throw new ArgumentNullException(nameof(orientations));
1325 PropertyArray orientationArray = new PropertyArray();
1326 for (int i = 0; i < orientations.Count; i++)
1328 PropertyValue value = new PropertyValue((int)orientations[i]);
1329 orientationArray.PushBack(value);
1333 Interop.Window.SetAvailableOrientations(SwigCPtr, PropertyArray.getCPtr(orientationArray), orientations.Count);
1334 orientationArray.Dispose();
1335 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1339 /// Get native window ID
1341 /// <returns>native window ID</returns>
1342 [EditorBrowsable(EditorBrowsableState.Never)]
1343 public int GetNativeId()
1345 int ret = Interop.Window.GetNativeId(SwigCPtr);
1346 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1350 internal Any GetNativeHandle()
1352 Any ret = new Any(Interop.WindowInternal.WindowGetNativeHandle(SwigCPtr), true);
1353 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1357 internal void Add(Layer layer)
1361 throw new ArgumentNullException(nameof(layer));
1366 Interop.Actor.Add(GetBorderWindowRootLayer().SwigCPtr, layer.SwigCPtr);
1367 if (NDalicPINVOKE.SWIGPendingException.Pending) { throw NDalicPINVOKE.SWIGPendingException.Retrieve(); }
1371 Interop.Window.Add(SwigCPtr, Layer.getCPtr(layer));
1372 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1375 LayersChildren?.Add(layer);
1376 layer.SetWindow(this);
1379 internal void Remove(Layer layer)
1383 throw new ArgumentNullException(nameof(layer));
1385 Interop.Window.Remove(SwigCPtr, Layer.getCPtr(layer));
1386 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1388 LayersChildren?.Remove(layer);
1389 layer.SetWindow(null);
1392 internal Vector2 GetSize()
1394 var val = new Uint16Pair(Interop.Window.GetSize(SwigCPtr), true);
1396 convertRealWindowSizeToBorderWindowSize(val);
1398 Vector2 ret = new Vector2(val.GetWidth(), val.GetHeight());
1399 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1404 /// This will be public opened in next tizen after ACR done. Before ACR, need to be hidden as inhouse API.
1405 [EditorBrowsable(EditorBrowsableState.Never)]
1406 public RenderTaskList GetRenderTaskList()
1408 RenderTaskList ret = new RenderTaskList(Interop.Stage.GetRenderTaskList(stageCPtr), true);
1409 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1414 /// Queries the number of on-window layers.
1416 /// <returns>The number of layers.</returns>
1417 /// <remarks>Note that a default layer is always provided (count >= 1).</remarks>
1418 internal uint GetLayerCount()
1420 if (LayersChildren == null || LayersChildren.Count < 0)
1423 return (uint)LayersChildren.Count;
1426 internal Layer GetRootLayer()
1430 if(borderLayer == null)
1432 borderLayer = GetBorderWindowRootLayer();
1433 LayersChildren?.Add(borderLayer);
1434 borderLayer.SetWindow(this);
1440 // Window.IsInstalled() is actually true only when called from event thread and
1441 // Core has been initialized, not when Stage is ready.
1442 if (rootLayer == null && Window.IsInstalled())
1444 rootLayer = new Layer(Interop.Window.GetRootLayer(SwigCPtr), true);
1445 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1446 LayersChildren?.Add(rootLayer);
1447 rootLayer.SetWindow(this);
1453 internal void SetBackgroundColor(Vector4 color)
1455 Interop.Window.SetBackgroundColor(SwigCPtr, Vector4.getCPtr(color));
1456 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1459 internal Vector4 GetBackgroundColor()
1461 Vector4 ret = new Vector4(Interop.Window.GetBackgroundColor(SwigCPtr), true);
1462 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1466 internal Vector2 GetDpi()
1468 Vector2 ret = new Vector2(Interop.Stage.GetDpi(stageCPtr), true);
1469 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1473 internal ObjectRegistry GetObjectRegistry()
1475 ObjectRegistry ret = new ObjectRegistry(Interop.Stage.GetObjectRegistry(stageCPtr), true);
1476 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1480 internal void SetRenderingBehavior(RenderingBehaviorType renderingBehavior)
1482 Interop.Stage.SetRenderingBehavior(stageCPtr, (int)renderingBehavior);
1483 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1486 internal RenderingBehaviorType GetRenderingBehavior()
1488 RenderingBehaviorType ret = (RenderingBehaviorType)Interop.Stage.GetRenderingBehavior(stageCPtr);
1489 if (NDalicPINVOKE.SWIGPendingException.Pending)
1490 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1494 internal void SetWindowSize(Size2D size)
1498 throw new ArgumentNullException(nameof(size));
1500 var val = new Uint16Pair((uint)size.Width, (uint)size.Height);
1502 convertBorderWindowSizeToRealWindowSize(val);
1504 Interop.Window.SetSize(SwigCPtr, Uint16Pair.getCPtr(val));
1506 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1507 // Resetting Window size should request a relayout of the tree.
1510 internal Size2D GetWindowSize()
1512 var val = new Uint16Pair(Interop.Window.GetSize(SwigCPtr), true);
1514 convertRealWindowSizeToBorderWindowSize(val);
1516 Size2D ret = new Size2D(val.GetWidth(), val.GetHeight());
1517 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1522 internal void SetPosition(Position2D position)
1524 if (null == position)
1526 throw new ArgumentNullException(nameof(position));
1528 var val = new Uint16Pair((uint)position.X, (uint)position.Y);
1529 Interop.Window.SetPosition(SwigCPtr, Uint16Pair.getCPtr(val));
1531 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1532 // Setting Position of the window should request a relayout of the tree.
1535 internal Position2D GetPosition()
1537 var val = new Uint16Pair(Interop.Window.GetPosition(SwigCPtr), true);
1538 Position2D ret = new Position2D(val.GetX(), val.GetY());
1540 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1544 internal void SetPositionSize(Rectangle positionSize)
1546 if (positionSize == null)
1548 throw new ArgumentNullException(nameof(positionSize));
1550 var val = new Uint16Pair((uint)positionSize.Width, (uint)positionSize.Height);
1552 convertBorderWindowSizeToRealWindowSize(val);
1554 positionSize.Width = val.GetX();
1555 positionSize.Height = val.GetY();
1557 Interop.Window.SetPositionSize(SwigCPtr, Rectangle.getCPtr(positionSize));
1560 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1562 // Setting Position of the window should request a relayout of the tree.
1566 /// Enables the floating mode of window.
1567 /// The floating mode is to support window is moved or resized by display server.
1568 /// For example, if the video-player window sets the floating mode,
1569 /// then display server changes its geometry and handles it like a popup.
1570 /// The way of handling floating mode window is decided by display server.
1571 /// A special display server(as a Tizen display server) supports this mode.
1573 /// <param name="enable">Enable floating mode or not.</param>
1574 [EditorBrowsable(EditorBrowsableState.Never)]
1575 public void EnableFloatingMode(bool enable)
1577 Interop.Window.EnableFloatingMode(SwigCPtr, enable);
1578 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1582 /// Requests to display server for the window is moved by display server.
1583 /// It can be work with setting window floating mode.
1585 [EditorBrowsable(EditorBrowsableState.Never)]
1586 public void RequestMoveToServer()
1588 Interop.Window.RequestMoveToServer(SwigCPtr);
1589 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1593 /// Requests to display server for the window is resized by display server.
1594 /// It can be work with setting window floating mode.
1596 /// <param name="direction">It is indicated the window's side or edge for starting point.</param>
1597 [EditorBrowsable(EditorBrowsableState.Never)]
1598 public void RequestResizeToServer(ResizeDirection direction)
1600 Interop.Window.RequestResizeToServer(SwigCPtr, (int)direction);
1601 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1605 /// Includes input region.
1606 /// This function inlcudes input regions.
1607 /// It can be used multiple times and supports multiple regions.
1608 /// It means input region will be extended.
1609 /// This input is related to mouse and touch event.
1610 /// If device has touch screen, this function is useful.
1611 /// Otherwise device does not have that, we can use it after connecting mouse to the device.
1613 /// <param name="inputRegion">The included region to accept input events.</param>
1614 [EditorBrowsable(EditorBrowsableState.Never)]
1615 public void IncludeInputRegion(Rectangle inputRegion)
1617 Interop.Window.IncludeInputRegion(SwigCPtr, Rectangle.getCPtr(inputRegion));
1618 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1622 /// This function excludes input regions.
1623 /// It can be used multiple times and supports multiple regions.
1624 /// It means input region will be reduced.
1625 /// Nofice, should be set input area by IncludeInputRegion() before this function is used.
1626 /// This input is related to mouse and touch event.
1627 /// If device has touch screen, this function is useful.
1628 /// Otherwise device does not have that, we can use it after connecting mouse to the device.
1630 /// <param name="inputRegion">The excluded region to except input events.</param>
1631 [EditorBrowsable(EditorBrowsableState.Never)]
1632 public void ExcludeInputRegion(Rectangle inputRegion)
1634 Interop.Window.ExcludeInputRegion(SwigCPtr, Rectangle.getCPtr(inputRegion));
1635 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1639 /// Maximizes window's size.
1640 /// If this function is called with true, window will be resized with screen size.
1641 /// Otherwise window will be resized with previous size.
1642 /// It is for the window's MAX button in window's border.
1643 /// If window border is supported by display server, it is not necessary.
1645 /// <param name="max">If window is maximized or unmaximized.</param>
1646 [EditorBrowsable(EditorBrowsableState.Never)]
1647 public void Maximize(bool max)
1649 Interop.Window.Maximize(SwigCPtr, max);
1650 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1654 /// Returns whether the window is maximized or not.
1656 /// <returns>True if the window is maximized, false otherwise.</returns>
1657 [EditorBrowsable(EditorBrowsableState.Never)]
1658 public bool IsMaximized()
1660 bool ret = Interop.Window.IsMaximized(SwigCPtr);
1661 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1666 /// Sets window's maximum size.
1668 /// It is to set the maximized size when window is maximized or the window's size is increased by RequestResizeToServer().
1669 /// Although the size is set by this function, window's size can be increased over the limitation by SetPositionSize() or SetSize().
1671 /// After setting, if Maximize() is called, window is resized with the setting size and move the center.
1674 /// <param name="size">the maximum size.</param>
1675 [EditorBrowsable(EditorBrowsableState.Never)]
1676 public void SetMaximumSize(Size2D size)
1680 throw new ArgumentNullException(nameof(size));
1682 var val = new Uint16Pair((uint)size.Width, (uint)size.Height);
1684 Interop.Window.SetMaximumSize(SwigCPtr, Uint16Pair.getCPtr(val));
1686 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1690 /// Minimizes window's size.
1691 /// If this function is called with true, window will be iconified.
1692 /// Otherwise window will be activated.
1693 /// It is for the window's MIN button in window border.
1694 /// If window border is supported by display server, it is not necessary.
1696 /// <param name="min">If window is minimized or unminimized.</param>
1697 [EditorBrowsable(EditorBrowsableState.Never)]
1698 public void Minimize(bool min)
1700 Interop.Window.Minimize(SwigCPtr, min);
1701 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1705 /// Returns whether the window is minimized or not.
1707 /// <returns>True if the window is minimized, false otherwise.</returns>
1708 [EditorBrowsable(EditorBrowsableState.Never)]
1709 public bool IsMinimized()
1711 bool ret = Interop.Window.IsMinimized(SwigCPtr);
1712 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1717 /// Sets window's minimum size.
1718 /// It is to set the minimum size when window's size is decreased by RequestResizeToServer().
1719 /// Although the size is set by this function, window's size can be decreased over the limitation by SetPositionSize() or SetSize().
1721 /// <param name="size">the minimum size.</param>
1722 [EditorBrowsable(EditorBrowsableState.Never)]
1723 public void SetMimimumSize(Size2D size)
1727 throw new ArgumentNullException(nameof(size));
1729 var val = new Uint16Pair((uint)size.Width, (uint)size.Height);
1731 Interop.Window.SetMimimumSize(SwigCPtr, Uint16Pair.getCPtr(val));
1733 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1737 /// Query whether window is rotating or not.
1739 /// <returns>True if window is rotating, false otherwise.</returns>
1740 [EditorBrowsable(EditorBrowsableState.Never)]
1741 public bool IsWindowRotating()
1743 bool ret = Interop.Window.IsWindowRotating(SwigCPtr);
1744 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1749 /// Gets the last key event the window gets.
1751 /// <returns>The last key event the window gets.</returns>
1752 [EditorBrowsable(EditorBrowsableState.Never)]
1753 public Key GetLastKeyEvent()
1755 Key ret = new Key(Interop.Window.GetLastKeyEvent(SwigCPtr), false);
1756 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1761 /// Gets the last touch event the window gets.
1763 /// <returns>The last touch event the window gets.</returns>
1764 [EditorBrowsable(EditorBrowsableState.Never)]
1765 public Touch GetLastTouchEvent()
1767 Touch ret = new Touch(Interop.Window.GetLastTouchEvent(SwigCPtr), false);
1768 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1773 /// Add FrameUpdateCallback
1775 [EditorBrowsable(EditorBrowsableState.Never)]
1776 public void AddFrameUpdateCallback(FrameUpdateCallbackInterface frameUpdateCallback)
1778 frameUpdateCallback?.AddFrameUpdateCallback(stageCPtr, Layer.getCPtr(GetRootLayer()));
1782 /// Remove FrameUpdateCallback
1784 [EditorBrowsable(EditorBrowsableState.Never)]
1785 public void RemoveFrameUpdateCallback(FrameUpdateCallbackInterface frameUpdateCallback)
1787 frameUpdateCallback?.RemoveFrameUpdateCallback(stageCPtr);
1791 /// Dispose for Window
1793 [EditorBrowsable(EditorBrowsableState.Never)]
1794 protected override void Dispose(DisposeTypes type)
1801 if (type == DisposeTypes.Explicit)
1804 //Release your own managed resources here.
1805 //You should release all of your own disposable objects here.
1807 if (IsBorderEnabled)
1812 foreach (var layer in childLayers)
1820 childLayers.Clear();
1822 localController?.Dispose();
1825 this.DisconnectNativeSignals();
1830 /// This will not be public opened.
1831 [EditorBrowsable(EditorBrowsableState.Never)]
1832 protected override void ReleaseSwigCPtr(System.Runtime.InteropServices.HandleRef swigCPtr)
1834 Interop.Window.DeleteWindow(swigCPtr);
1837 private static Dictionary<int, internalHookCallbackType> frameCallbackList = new Dictionary<int, internalHookCallbackType>();
1839 private static readonly object locker = new object();
1841 private static int key = 0;
1843 private static FrameCallbackType internalHookFrameCallback = OnInternalHookFrameCallback;
1845 private struct internalHookCallbackType
1847 public FrameCallbackType userCallback;
1851 private static void OnInternalHookFrameCallback(int id)
1855 if (frameCallbackList.ContainsKey(id))
1857 if (frameCallbackList[id].userCallback != null)
1859 frameCallbackList[id].userCallback.Invoke(frameCallbackList[id].frameId);
1860 frameCallbackList.Remove(id);
1864 NUILog.Error($"found userCallback is NULL");
1865 frameCallbackList.Remove(id);
1871 private int AddInterHookCallback(FrameCallbackType callback, int frameId)
1873 if (null == callback)
1875 throw new ArgumentNullException(nameof(callback), "FrameCallbackType should not be null");
1877 var assignedKey = 0;
1882 frameCallbackList.Add(assignedKey, new internalHookCallbackType()
1884 userCallback = callback,
1892 /// Type of callback which is called when the frame rendering is done by graphics driver or when the frame is displayed on display.
1894 /// <param name="frameId">The Id to specify the frame. It will be passed when the callback is called.</param>
1895 [EditorBrowsable(EditorBrowsableState.Never)]
1896 public delegate void FrameCallbackType(int frameId);
1899 /// Adds a callback that is called when the frame rendering is done by the graphics driver.
1900 /// A callback of the following type may be used:
1902 /// void MyFunction( int frameId )
1904 /// This callback will be deleted once it is called.
1906 /// Ownership of the callback is passed onto this class
1909 /// <param name="callback">The function to call</param>
1910 /// <param name="frameId">The Id to specify the frame. It will be passed when the callback is called.</param>
1911 /// <exception cref="ArgumentNullException">This exception can occur by the callback is null.</exception>
1912 [EditorBrowsable(EditorBrowsableState.Never)]
1913 public void AddFrameRenderedCallback(FrameCallbackType callback, int frameId)
1915 var assignedKey = AddInterHookCallback(callback, frameId);
1916 Interop.WindowInternal.AddFrameRenderedCallback(SwigCPtr, new HandleRef(this, Marshal.GetFunctionPointerForDelegate<Delegate>(internalHookFrameCallback)), assignedKey);
1918 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1922 /// Adds a callback that is called when the frame is displayed on the display.
1923 /// A callback of the following type may be used:
1925 /// void MyFunction( int frameId )
1927 /// This callback will be deleted once it is called.
1929 /// Ownership of the callback is passed onto this class
1932 /// <param name="callback">The function to call</param>
1933 /// <param name="frameId">The Id to specify the frame. It will be passed when the callback is called.</param>
1934 /// <exception cref="ArgumentNullException">This exception can occur by the callback is null.</exception>
1935 [EditorBrowsable(EditorBrowsableState.Never)]
1936 public void AddFramePresentedCallback(FrameCallbackType callback, int frameId)
1938 var assignedKey = AddInterHookCallback(callback, frameId);
1939 Interop.WindowInternal.AddFramePresentedCallback(SwigCPtr, new HandleRef(this, Marshal.GetFunctionPointerForDelegate<Delegate>(internalHookFrameCallback)), assignedKey);
1941 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1945 /// Search through this Window for a Layer with the given unique ID.
1947 /// <param name="id">The ID of the Layer to find.</param>
1948 /// <remarks>Hidden-API</remarks>
1949 /// <returns>A handle to the Layer if found, or an empty handle if not.</returns>
1950 [EditorBrowsable(EditorBrowsableState.Never)]
1951 public Layer FindLayerByID(uint id)
1953 Layer defaultLayer = this.GetDefaultLayer();
1954 IntPtr cPtr = Interop.Actor.FindChildById(defaultLayer.SwigCPtr, id);
1955 Layer ret = this.GetInstanceSafely<Layer>(cPtr);
1957 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1962 /// Get Native Window handle.
1964 /// How to get Native Window handle
1966 /// Window window = NUIApplication.GetDefaultWindow();
1967 /// var handle = window.NativeHandle;
1968 /// if(handle.IsInvalid == false)
1970 /// IntPtr nativeHandle = handle.DangerousGetHandle();
1971 /// // do something with nativeHandle
1976 /// <since_tizen> 9 </since_tizen>
1977 public SafeHandle NativeHandle
1981 return new NUI.SafeNativeWindowHandle(this);