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("Please do not use! This will be removed. Please 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("Please do not use! This will be removed. Please use Window.EffectState.None instead!")]
225 [EditorBrowsable(EditorBrowsableState.Never)]
228 /// Transition effect is started.
230 [Obsolete("Please do not use! This will be removed. Please use Window.EffectState.Start instead!")]
231 [EditorBrowsable(EditorBrowsableState.Never)]
234 /// Transition effect is ended.
236 [Obsolete("Please do not use! This will be removed. Please 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("Please do not use! This will be removed. Please 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("Please do not use! This will be removed. Please use Window.EffectType.None instead!")]
277 [EditorBrowsable(EditorBrowsableState.Never)]
280 /// Window show effect.
282 [Obsolete("Please do not use! This will be removed. Please use Window.EffectType.Show instead!")]
283 [EditorBrowsable(EditorBrowsableState.Never)]
286 /// Window hide effect.
288 [Obsolete("Please do not use! This will be removed. Please 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("Please do not use! This will be deprecated! Please 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 Interop.Actor.Add(Layer.getCPtr(GetRootLayer()), View.getCPtr(view));
941 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
942 this.GetRootLayer().AddViewToLayerList(view); // Maintain the children list in the Layer
945 view.InternalParent = this.GetRootLayer();
947 this.GetRootLayer().LayoutCount += view.LayoutCount;
952 /// Remove a child view from window.
954 /// <param name="view">the child to be removed.</param>
955 /// <since_tizen> 3 </since_tizen>
956 public void Remove(View view)
958 Interop.Actor.Remove(Layer.getCPtr(GetRootLayer()), View.getCPtr(view));
959 this.GetRootLayer().RemoveViewFromLayerList(view); // Maintain the children list in the Layer
962 view.InternalParent = null;
964 this.GetRootLayer().LayoutCount -= view.LayoutCount;
969 /// Retrieves the layer at a specified depth.
971 /// <param name="depth">The layer's depth index.</param>
972 /// <returns>The layer found at the given depth.</returns>
973 /// <since_tizen> 3 </since_tizen>
974 public Layer GetLayer(uint depth)
976 if (depth < LayersChildren?.Count)
978 Layer ret = LayersChildren?[Convert.ToInt32(depth)];
988 /// Destroy the window immediately.
990 [EditorBrowsable(EditorBrowsableState.Never)]
991 public void Destroy()
997 /// Keep rendering for at least the given amount of time.
999 /// <param name="durationSeconds">Time to keep rendering, 0 means render at least one more frame.</param>
1000 /// <since_tizen> 3 </since_tizen>
1001 public void KeepRendering(float durationSeconds)
1003 Interop.Stage.KeepRendering(stageCPtr, durationSeconds);
1004 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1008 /// Grabs the key specified by a key for a window only when a window is the topmost window.<br />
1009 /// This function can be used for following example scenarios: <br />
1010 /// - Mobile - Using volume up or down as zoom up or down in camera apps.<br />
1012 /// <param name="DaliKey">The key code to grab.</param>
1013 /// <returns>True if the grab succeeds.</returns>
1014 /// <since_tizen> 3 </since_tizen>
1015 public bool GrabKeyTopmost(int DaliKey)
1017 bool ret = Interop.Window.GrabKeyTopmost(HandleRef.ToIntPtr(this.SwigCPtr), DaliKey);
1018 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1023 /// Ungrabs the key specified by a key for the window.<br />
1024 /// 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 />
1026 /// <param name="DaliKey">The key code to ungrab.</param>
1027 /// <returns>True if the ungrab succeeds.</returns>
1028 /// <since_tizen> 3 </since_tizen>
1029 public bool UngrabKeyTopmost(int DaliKey)
1031 bool ret = Interop.Window.UngrabKeyTopmost(HandleRef.ToIntPtr(this.SwigCPtr), DaliKey);
1032 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1037 /// Grabs the key specified by a key for a window in a GrabMode. <br />
1038 /// Details: This function can be used for following example scenarios: <br />
1039 /// - TV - A user might want to change the volume or channel of the background TV contents while focusing on the foregrund app. <br />
1040 /// - Mobile - When a user presses the Home key, the homescreen appears regardless of the current foreground app. <br />
1041 /// - Mobile - Using the volume up or down as zoom up or down in camera apps. <br />
1043 /// <param name="DaliKey">The key code to grab.</param>
1044 /// <param name="GrabMode">The grab mode for the key.</param>
1045 /// <returns>True if the grab succeeds.</returns>
1046 /// <since_tizen> 3 </since_tizen>
1047 public bool GrabKey(int DaliKey, KeyGrabMode GrabMode)
1049 bool ret = Interop.Window.GrabKey(HandleRef.ToIntPtr(this.SwigCPtr), DaliKey, (int)GrabMode);
1050 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1055 /// Ungrabs the key specified by a key for a window.<br />
1056 /// 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 />
1058 /// <param name="DaliKey">The key code to ungrab.</param>
1059 /// <returns>True if the ungrab succeeds.</returns>
1060 /// <since_tizen> 3 </since_tizen>
1061 public bool UngrabKey(int DaliKey)
1063 bool ret = Interop.Window.UngrabKey(HandleRef.ToIntPtr(this.SwigCPtr), DaliKey);
1064 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1069 /// Sets the keyboard repeat information.
1071 /// <param name="rate">The key repeat rate value in seconds.</param>
1072 /// <param name="delay">The key repeat delay value in seconds.</param>
1073 /// <returns>True if setting the keyboard repeat succeeds.</returns>
1074 /// <since_tizen> 5 </since_tizen>
1075 public bool SetKeyboardRepeatInfo(float rate, float delay)
1077 bool ret = Interop.Window.SetKeyboardRepeatInfo(rate, delay);
1078 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1083 /// Gets the keyboard repeat information.
1085 /// <param name="rate">The key repeat rate value in seconds.</param>
1086 /// <param name="delay">The key repeat delay value in seconds.</param>
1087 /// <returns>True if setting the keyboard repeat succeeds.</returns>
1088 /// <since_tizen> 5 </since_tizen>
1089 public bool GetKeyboardRepeatInfo(out float rate, out float delay)
1091 bool ret = Interop.Window.GetKeyboardRepeatInfo(out rate, out delay);
1092 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1097 /// Adds a layer to the stage.
1099 /// <param name="layer">Layer to add.</param>
1100 /// <exception cref="ArgumentNullException"> Thrown when layer is null. </exception>
1101 /// <since_tizen> 3 </since_tizen>
1102 public void AddLayer(Layer layer)
1108 /// Removes a layer from the stage.
1110 /// <param name="layer">Layer to remove.</param>
1111 /// <exception cref="ArgumentNullException"> Thrown when layer is null. </exception>
1112 /// <since_tizen> 3 </since_tizen>
1113 public void RemoveLayer(Layer layer)
1119 /// Feeds a key event into the window.
1121 /// <param name="keyEvent">The key event to feed.</param>
1122 /// <since_tizen> 5 </since_tizen>
1123 public void FeedKey(Key keyEvent)
1125 Interop.Window.FeedKeyEvent(SwigCPtr, Key.getCPtr(keyEvent));
1126 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1130 /// Feeds a touch point into the window.
1132 /// <param name="touchPoint">The touch point to feed.</param>
1133 /// <param name="timeStamp">The timeStamp.</param>
1134 internal void FeedTouch(TouchPoint touchPoint, int timeStamp)
1136 Interop.Window.FeedTouchPoint(SwigCPtr, TouchPoint.getCPtr(touchPoint), timeStamp);
1137 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1141 /// Feeds a wheel event into the window.
1143 /// <param name="wheelEvent">The wheel event to feed.</param>
1144 internal void FeedWheel(Wheel wheelEvent)
1146 Interop.Window.FeedWheelEvent(SwigCPtr, Wheel.getCPtr(wheelEvent));
1147 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1151 /// Allows at least one more render, even when paused.
1152 /// The window should be shown, not minimised.
1154 /// <since_tizen> 4 </since_tizen>
1155 public void RenderOnce()
1157 Interop.Window.RenderOnce(SwigCPtr);
1158 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1162 /// Sets whether the window is transparent or not.
1164 /// <param name="transparent">Whether the window is transparent or not.</param>
1165 /// <since_tizen> 5 </since_tizen>
1166 public void SetTransparency(bool transparent)
1168 Interop.Window.SetTransparency(SwigCPtr, transparent);
1169 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1171 // Setting transparency of the window should request a relayout of the tree in the case the window changes from fully transparent.
1175 /// Sets parent window of the window.
1176 /// After setting that, these windows do together when raise-up, lower and iconified/deiconified.
1177 /// Initially, the window is located on top of the parent. The window can go below parent by calling Lower().
1178 /// If parent's window stack is changed by calling Raise() or Lower(), child windows are located on top of the parent again.
1180 /// <param name="parent">The parent window.</param>
1181 /// <since_tizen> 6 </since_tizen>
1182 /// <feature> http://tizen.org/feature/opengles.surfaceless_context </feature>
1183 /// <exception cref="NotSupportedException">The required feature is not supported.</exception>
1184 public void SetParent(Window parent)
1186 if (IsSupportedMultiWindow() == false)
1188 NUILog.Error("This device does not support surfaceless_context. So Window cannot be created. ");
1190 Interop.Window.SetParent(SwigCPtr, Window.getCPtr(parent));
1191 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1195 /// Sets parent window of the window.
1196 /// After setting that, these windows do together when raise-up, lower and iconified/deiconified.
1197 /// This function has the additional flag whether the child is located above or below of the parent.
1199 /// <param name="parent">The parent window.</param>
1200 /// <param name="belowParent">The flag is whether the child is located above or below of the parent.</param>
1201 /// <feature> http://tizen.org/feature/opengles.surfaceless_context </feature>
1202 /// <exception cref="NotSupportedException">The required feature is not supported.</exception>
1203 [EditorBrowsable(EditorBrowsableState.Never)]
1204 public void SetParent(Window parent, bool belowParent)
1206 if (IsSupportedMultiWindow() == false)
1208 NUILog.Error("This device does not support surfaceless_context. So Window cannot be created. ");
1210 Interop.Window.SetParentWithStack(SwigCPtr, Window.getCPtr(parent), belowParent);
1211 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1215 /// Unsets parent window of the window.
1216 /// After unsetting, the window is disconnected his parent window.
1218 /// <since_tizen> 6 </since_tizen>
1219 /// <feature> http://tizen.org/feature/opengles.surfaceless_context </feature>
1220 /// <exception cref="NotSupportedException">The required feature is not supported.</exception>
1221 public void Unparent()
1223 if (IsSupportedMultiWindow() == false)
1225 NUILog.Error("Fail to create window. because this device does not support opengles.surfaceless_context.");
1227 Interop.Window.Unparent(SwigCPtr);
1228 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1232 /// Gets parent window of the window.
1234 /// <returns>The parent window of the window.</returns>
1235 /// <since_tizen> 6 </since_tizen>
1236 /// <feature> http://tizen.org/feature/opengles.surfaceless_context </feature>
1237 /// <exception cref="NotSupportedException">The required feature is not supported.</exception>
1238 [System.Diagnostics.CodeAnalysis.SuppressMessage("Design", "CA1721: Property names should not match get methods")]
1239 public Window GetParent()
1241 if (IsSupportedMultiWindow() == false)
1243 NUILog.Error("This device does not support surfaceless_context. So Window cannot be created. ");
1245 Window ret = this.GetInstanceSafely<Window>(Interop.Window.GetParent(SwigCPtr));
1246 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1250 /// This will be public opened in tizen_next after ACR done. Before ACR, need to be hidden as inhouse API.
1251 [EditorBrowsable(EditorBrowsableState.Never)]
1252 public void ObjectDump()
1254 Layer rootLayer = GetRootLayer();
1255 foreach (View view in rootLayer.Children)
1261 internal static bool IsInstalled()
1263 bool ret = Interop.Stage.IsInstalled();
1264 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1269 /// Adds an orientation to the list of available orientations.
1271 /// <param name="orientation">The available orientation to add</param>
1272 /// <since_tizen> 6 </since_tizen>
1273 public void AddAvailableOrientation(Window.WindowOrientation orientation)
1275 Interop.Window.AddAvailableOrientation(SwigCPtr, (int)orientation);
1276 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1280 /// Removes an orientation from the list of available orientations.
1282 /// <param name="orientation">The available orientation to remove.</param>
1283 /// <since_tizen> 6 </since_tizen>
1284 public void RemoveAvailableOrientation(Window.WindowOrientation orientation)
1286 Interop.Window.RemoveAvailableOrientation(SwigCPtr, (int)orientation);
1287 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1291 /// Sets a preferred orientation.
1293 /// <param name="orientation">The preferred orientation.</param>
1294 /// <since_tizen> 6 </since_tizen>
1295 public void SetPreferredOrientation(Window.WindowOrientation orientation)
1297 Interop.Window.SetPreferredOrientation(SwigCPtr, (int)orientation);
1298 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1302 /// Gets the preferred orientation.
1304 /// <since_tizen> 6 </since_tizen>
1305 /// <returns>The preferred orientation if previously set, or none.</returns>
1306 public Window.WindowOrientation GetPreferredOrientation()
1308 Window.WindowOrientation ret = (Window.WindowOrientation)Interop.Window.GetPreferredOrientation(SwigCPtr);
1309 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1314 /// Gets current orientation of the window.
1316 /// <since_tizen> 6 </since_tizen>
1317 /// <returns>The current window orientation if previously set, or none.</returns>
1318 [EditorBrowsable(EditorBrowsableState.Never)]
1319 public Window.WindowOrientation GetCurrentOrientation()
1321 Window.WindowOrientation ret = (Window.WindowOrientation)Interop.Window.GetCurrentOrientation(SwigCPtr);
1322 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1327 /// Sets available orientations of the window.
1328 /// This API is for setting several orientations one time.
1330 /// <param name="orientations">The list of orientations.</param>
1331 /// <since_tizen> 6 </since_tizen>
1332 [EditorBrowsable(EditorBrowsableState.Never)]
1333 public void SetAvailableOrientations(List<Window.WindowOrientation> orientations)
1335 if (null == orientations)
1337 throw new ArgumentNullException(nameof(orientations));
1340 PropertyArray orientationArray = new PropertyArray();
1341 for (int i = 0; i < orientations.Count; i++)
1343 PropertyValue value = new PropertyValue((int)orientations[i]);
1344 orientationArray.PushBack(value);
1348 Interop.Window.SetAvailableOrientations(SwigCPtr, PropertyArray.getCPtr(orientationArray), orientations.Count);
1349 orientationArray.Dispose();
1350 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1354 /// Get native window ID
1356 /// <returns>native window ID</returns>
1357 [EditorBrowsable(EditorBrowsableState.Never)]
1358 public int GetNativeId()
1360 int ret = Interop.Window.GetNativeId(SwigCPtr);
1361 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1365 internal Any GetNativeHandle()
1367 Any ret = new Any(Interop.WindowInternal.WindowGetNativeHandle(SwigCPtr), true);
1368 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1372 internal void Add(Layer layer)
1376 throw new ArgumentNullException(nameof(layer));
1381 Interop.Actor.Add(GetBorderWindowRootLayer().SwigCPtr, layer.SwigCPtr);
1382 if (NDalicPINVOKE.SWIGPendingException.Pending) { throw NDalicPINVOKE.SWIGPendingException.Retrieve(); }
1386 Interop.Window.Add(SwigCPtr, Layer.getCPtr(layer));
1387 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1390 LayersChildren?.Add(layer);
1391 layer.SetWindow(this);
1394 internal void Remove(Layer layer)
1398 throw new ArgumentNullException(nameof(layer));
1400 Interop.Window.Remove(SwigCPtr, Layer.getCPtr(layer));
1401 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1403 LayersChildren?.Remove(layer);
1404 layer.SetWindow(null);
1407 internal Vector2 GetSize()
1409 var val = new Uint16Pair(Interop.Window.GetSize(SwigCPtr), true);
1411 convertRealWindowSizeToBorderWindowSize(val);
1413 Vector2 ret = new Vector2(val.GetWidth(), val.GetHeight());
1414 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1419 /// This will be public opened in next tizen after ACR done. Before ACR, need to be hidden as inhouse API.
1420 [EditorBrowsable(EditorBrowsableState.Never)]
1421 public RenderTaskList GetRenderTaskList()
1423 RenderTaskList ret = new RenderTaskList(Interop.Stage.GetRenderTaskList(stageCPtr), true);
1424 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1429 /// Queries the number of on-window layers.
1431 /// <returns>The number of layers.</returns>
1432 /// <remarks>Note that a default layer is always provided (count >= 1).</remarks>
1433 internal uint GetLayerCount()
1435 if (LayersChildren == null || LayersChildren.Count < 0)
1438 return (uint)LayersChildren.Count;
1441 internal Layer GetRootLayer()
1445 if(borderLayer == null)
1447 borderLayer = GetBorderWindowRootLayer();
1448 LayersChildren?.Add(borderLayer);
1449 borderLayer.SetWindow(this);
1455 // Window.IsInstalled() is actually true only when called from event thread and
1456 // Core has been initialized, not when Stage is ready.
1457 if (rootLayer == null && Window.IsInstalled())
1459 rootLayer = new Layer(Interop.Window.GetRootLayer(SwigCPtr), true);
1460 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1461 LayersChildren?.Add(rootLayer);
1462 rootLayer.SetWindow(this);
1468 internal void SetBackgroundColor(Vector4 color)
1470 Interop.Window.SetBackgroundColor(SwigCPtr, Vector4.getCPtr(color));
1471 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1474 internal Vector4 GetBackgroundColor()
1476 Vector4 ret = new Vector4(Interop.Window.GetBackgroundColor(SwigCPtr), true);
1477 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1481 internal Vector2 GetDpi()
1483 Vector2 ret = new Vector2(Interop.Stage.GetDpi(stageCPtr), true);
1484 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1488 internal ObjectRegistry GetObjectRegistry()
1490 ObjectRegistry ret = new ObjectRegistry(Interop.Stage.GetObjectRegistry(stageCPtr), true);
1491 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1495 internal void SetRenderingBehavior(RenderingBehaviorType renderingBehavior)
1497 Interop.Stage.SetRenderingBehavior(stageCPtr, (int)renderingBehavior);
1498 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1501 internal RenderingBehaviorType GetRenderingBehavior()
1503 RenderingBehaviorType ret = (RenderingBehaviorType)Interop.Stage.GetRenderingBehavior(stageCPtr);
1504 if (NDalicPINVOKE.SWIGPendingException.Pending)
1505 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1509 internal void SetWindowSize(Size2D size)
1513 throw new ArgumentNullException(nameof(size));
1515 var val = new Uint16Pair((uint)size.Width, (uint)size.Height);
1517 convertBorderWindowSizeToRealWindowSize(val);
1519 Interop.Window.SetSize(SwigCPtr, Uint16Pair.getCPtr(val));
1521 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1522 // Resetting Window size should request a relayout of the tree.
1525 internal Size2D GetWindowSize()
1527 var val = new Uint16Pair(Interop.Window.GetSize(SwigCPtr), true);
1529 convertRealWindowSizeToBorderWindowSize(val);
1531 Size2D ret = new Size2D(val.GetWidth(), val.GetHeight());
1532 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1537 internal void SetPosition(Position2D position)
1539 if (null == position)
1541 throw new ArgumentNullException(nameof(position));
1543 var val = new Uint16Pair((uint)position.X, (uint)position.Y);
1544 Interop.Window.SetPosition(SwigCPtr, Uint16Pair.getCPtr(val));
1546 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1547 // Setting Position of the window should request a relayout of the tree.
1550 internal Position2D GetPosition()
1552 var val = new Uint16Pair(Interop.Window.GetPosition(SwigCPtr), true);
1553 Position2D ret = new Position2D(val.GetX(), val.GetY());
1555 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1559 internal void SetPositionSize(Rectangle positionSize)
1561 if (positionSize == null)
1563 throw new ArgumentNullException(nameof(positionSize));
1565 var val = new Uint16Pair((uint)positionSize.Width, (uint)positionSize.Height);
1567 convertBorderWindowSizeToRealWindowSize(val);
1569 positionSize.Width = val.GetX();
1570 positionSize.Height = val.GetY();
1572 Interop.Window.SetPositionSize(SwigCPtr, Rectangle.getCPtr(positionSize));
1574 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1576 // Setting Position of the window should request a relayout of the tree.
1580 /// Enables the floating mode of window.
1581 /// The floating mode is to support window is moved or resized by display server.
1582 /// For example, if the video-player window sets the floating mode,
1583 /// then display server changes its geometry and handles it like a popup.
1584 /// The way of handling floating mode window is decided by display server.
1585 /// A special display server(as a Tizen display server) supports this mode.
1587 /// <param name="enable">Enable floating mode or not.</param>
1588 [EditorBrowsable(EditorBrowsableState.Never)]
1589 public void EnableFloatingMode(bool enable)
1591 Interop.Window.EnableFloatingMode(SwigCPtr, enable);
1592 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1596 /// Requests to display server for the window is moved by display server.
1597 /// It can be work with setting window floating mode.
1599 [EditorBrowsable(EditorBrowsableState.Never)]
1600 public void RequestMoveToServer()
1602 Interop.Window.RequestMoveToServer(SwigCPtr);
1603 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1607 /// Requests to display server for the window is resized by display server.
1608 /// It can be work with setting window floating mode.
1610 /// <param name="direction">It is indicated the window's side or edge for starting point.</param>
1611 [EditorBrowsable(EditorBrowsableState.Never)]
1612 public void RequestResizeToServer(ResizeDirection direction)
1614 Interop.Window.RequestResizeToServer(SwigCPtr, (int)direction);
1615 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1619 /// Includes input region.
1620 /// This function inlcudes input regions.
1621 /// It can be used multiple times and supports multiple regions.
1622 /// It means input region will be extended.
1623 /// This input is related to mouse and touch event.
1624 /// If device has touch screen, this function is useful.
1625 /// Otherwise device does not have that, we can use it after connecting mouse to the device.
1627 /// <param name="inputRegion">The included region to accept input events.</param>
1628 [EditorBrowsable(EditorBrowsableState.Never)]
1629 public void IncludeInputRegion(Rectangle inputRegion)
1631 Interop.Window.IncludeInputRegion(SwigCPtr, Rectangle.getCPtr(inputRegion));
1632 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1636 /// This function excludes input regions.
1637 /// It can be used multiple times and supports multiple regions.
1638 /// It means input region will be reduced.
1639 /// Nofice, should be set input area by IncludeInputRegion() before this function is used.
1640 /// This input is related to mouse and touch event.
1641 /// If device has touch screen, this function is useful.
1642 /// Otherwise device does not have that, we can use it after connecting mouse to the device.
1644 /// <param name="inputRegion">The excluded region to except input events.</param>
1645 [EditorBrowsable(EditorBrowsableState.Never)]
1646 public void ExcludeInputRegion(Rectangle inputRegion)
1648 Interop.Window.ExcludeInputRegion(SwigCPtr, Rectangle.getCPtr(inputRegion));
1649 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1653 /// Maximizes window's size.
1654 /// If this function is called with true, window will be resized with screen size.
1655 /// Otherwise window will be resized with previous size.
1656 /// It is for the window's MAX button in window's border.
1657 /// If window border is supported by display server, it is not necessary.
1659 /// <param name="max">If window is maximized or unmaximized.</param>
1660 [EditorBrowsable(EditorBrowsableState.Never)]
1661 public void Maximize(bool max)
1663 Interop.Window.Maximize(SwigCPtr, max);
1664 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1668 /// Returns whether the window is maximized or not.
1670 /// <returns>True if the window is maximized, false otherwise.</returns>
1671 [EditorBrowsable(EditorBrowsableState.Never)]
1672 public bool IsMaximized()
1674 bool ret = Interop.Window.IsMaximized(SwigCPtr);
1675 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1680 /// Minimizes window's size.
1681 /// If this function is called with true, window will be iconified.
1682 /// Otherwise window will be activated.
1683 /// It is for the window's MIN button in window border.
1684 /// If window border is supported by display server, it is not necessary.
1686 /// <param name="min">If window is minimized or unminimized.</param>
1687 [EditorBrowsable(EditorBrowsableState.Never)]
1688 public void Minimize(bool min)
1690 Interop.Window.Minimize(SwigCPtr, min);
1691 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1695 /// Returns whether the window is minimized or not.
1697 /// <returns>True if the window is minimized, false otherwise.</returns>
1698 [EditorBrowsable(EditorBrowsableState.Never)]
1699 public bool IsMinimized()
1701 bool ret = Interop.Window.IsMinimized(SwigCPtr);
1702 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1707 /// Add FrameUpdateCallback
1709 [EditorBrowsable(EditorBrowsableState.Never)]
1710 public void AddFrameUpdateCallback(FrameUpdateCallbackInterface frameUpdateCallback)
1712 frameUpdateCallback?.AddFrameUpdateCallback(stageCPtr, Layer.getCPtr(GetRootLayer()));
1716 /// Remove FrameUpdateCallback
1718 [EditorBrowsable(EditorBrowsableState.Never)]
1719 public void RemoveFrameUpdateCallback(FrameUpdateCallbackInterface frameUpdateCallback)
1721 frameUpdateCallback?.RemoveFrameUpdateCallback(stageCPtr);
1725 /// Dispose for Window
1727 [EditorBrowsable(EditorBrowsableState.Never)]
1728 protected override void Dispose(DisposeTypes type)
1735 if (type == DisposeTypes.Explicit)
1738 //Release your own managed resources here.
1739 //You should release all of your own disposable objects here.
1741 if (IsBorderEnabled)
1746 foreach (var layer in childLayers)
1754 childLayers.Clear();
1756 localController?.Dispose();
1759 this.DisconnectNativeSignals();
1764 /// This will not be public opened.
1765 [EditorBrowsable(EditorBrowsableState.Never)]
1766 protected override void ReleaseSwigCPtr(System.Runtime.InteropServices.HandleRef swigCPtr)
1768 Interop.Window.DeleteWindow(swigCPtr);
1771 private static Dictionary<int, internalHookCallbackType> frameCallbackList = new Dictionary<int, internalHookCallbackType>();
1773 private static readonly object locker = new object();
1775 private static int key = 0;
1777 private static FrameCallbackType internalHookFrameCallback = OnInternalHookFrameCallback;
1779 private struct internalHookCallbackType
1781 public FrameCallbackType userCallback;
1785 private static void OnInternalHookFrameCallback(int id)
1789 if (frameCallbackList.ContainsKey(id))
1791 if (frameCallbackList[id].userCallback != null)
1793 frameCallbackList[id].userCallback.Invoke(frameCallbackList[id].frameId);
1794 frameCallbackList.Remove(id);
1798 NUILog.Error($"found userCallback is NULL");
1799 frameCallbackList.Remove(id);
1805 private int AddInterHookCallback(FrameCallbackType callback, int frameId)
1807 if (null == callback)
1809 throw new ArgumentNullException(nameof(callback), "FrameCallbackType should not be null");
1811 var assignedKey = 0;
1816 frameCallbackList.Add(assignedKey, new internalHookCallbackType()
1818 userCallback = callback,
1826 /// Type of callback which is called when the frame rendering is done by graphics driver or when the frame is displayed on display.
1828 /// <param name="frameId">The Id to specify the frame. It will be passed when the callback is called.</param>
1829 [EditorBrowsable(EditorBrowsableState.Never)]
1830 public delegate void FrameCallbackType(int frameId);
1833 /// Adds a callback that is called when the frame rendering is done by the graphics driver.
1834 /// A callback of the following type may be used:
1836 /// void MyFunction( int frameId )
1838 /// This callback will be deleted once it is called.
1840 /// Ownership of the callback is passed onto this class
1843 /// <param name="callback">The function to call</param>
1844 /// <param name="frameId">The Id to specify the frame. It will be passed when the callback is called.</param>
1845 /// <exception cref="ArgumentNullException">This exception can occur by the callback is null.</exception>
1846 [EditorBrowsable(EditorBrowsableState.Never)]
1847 public void AddFrameRenderedCallback(FrameCallbackType callback, int frameId)
1849 var assignedKey = AddInterHookCallback(callback, frameId);
1850 Interop.WindowInternal.AddFrameRenderedCallback(SwigCPtr, new HandleRef(this, Marshal.GetFunctionPointerForDelegate<Delegate>(internalHookFrameCallback)), assignedKey);
1852 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1856 /// Adds a callback that is called when the frame is displayed on the display.
1857 /// A callback of the following type may be used:
1859 /// void MyFunction( int frameId )
1861 /// This callback will be deleted once it is called.
1863 /// Ownership of the callback is passed onto this class
1866 /// <param name="callback">The function to call</param>
1867 /// <param name="frameId">The Id to specify the frame. It will be passed when the callback is called.</param>
1868 /// <exception cref="ArgumentNullException">This exception can occur by the callback is null.</exception>
1869 [EditorBrowsable(EditorBrowsableState.Never)]
1870 public void AddFramePresentedCallback(FrameCallbackType callback, int frameId)
1872 var assignedKey = AddInterHookCallback(callback, frameId);
1873 Interop.WindowInternal.AddFramePresentedCallback(SwigCPtr, new HandleRef(this, Marshal.GetFunctionPointerForDelegate<Delegate>(internalHookFrameCallback)), assignedKey);
1875 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1879 /// Search through this Window for a Layer with the given unique ID.
1881 /// <param name="id">The ID of the Layer to find.</param>
1882 /// <remarks>Hidden-API</remarks>
1883 /// <returns>A handle to the Layer if found, or an empty handle if not.</returns>
1884 [EditorBrowsable(EditorBrowsableState.Never)]
1885 public Layer FindLayerByID(uint id)
1887 Layer defaultLayer = this.GetDefaultLayer();
1888 IntPtr cPtr = Interop.Actor.FindChildById(defaultLayer.SwigCPtr, id);
1889 Layer ret = this.GetInstanceSafely<Layer>(cPtr);
1891 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1896 /// Get Native Window handle.
1898 /// How to get Native Window handle
1900 /// Window window = NUIApplication.GetDefaultWindow();
1901 /// var handle = window.NativeHandle;
1902 /// if(handle.IsInvalid == false)
1904 /// IntPtr nativeHandle = handle.DangerousGetHandle();
1905 /// // do something with nativeHandle
1910 /// <since_tizen> 9 </since_tizen>
1911 public SafeHandle NativeHandle
1915 return new NUI.SafeNativeWindowHandle(this);