2 * Copyright(c) 2019 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;
21 using System.ComponentModel;
22 using System.Collections.Generic;
23 using global::System.Runtime.InteropServices;
24 using Tizen.NUI.BaseComponents;
29 /// The window class is used internally for drawing.<br />
30 /// The window has an orientation and indicator properties.<br />
32 /// <since_tizen> 3 </since_tizen>
33 public partial class Window : BaseHandle
35 private static readonly Window instance = Application.Instance?.GetWindow();
36 private global::System.Runtime.InteropServices.HandleRef stageCPtr;
37 private Layer _rootLayer;
38 private string _windowTitle;
39 private List<Layer> _childLayers = new List<Layer>();
40 private LayoutController localController;
42 private bool IsSupportedMultiWindow()
44 bool isSupported = false;
45 Information.TryGetValue("http://tizen.org/feature/opengles.surfaceless_context", out isSupported);
49 internal Window(global::System.IntPtr cPtr, bool cMemoryOwn) : base(Interop.Window.Window_SWIGUpcast(cPtr), cMemoryOwn)
51 if (Interop.Stage.Stage_IsInstalled())
53 stageCPtr = new global::System.Runtime.InteropServices.HandleRef(this, Interop.Stage.Stage_GetCurrent());
55 localController = new LayoutController(this);
56 NUILog.Debug("layoutController id:" + localController.GetId());
61 /// Creates a new Window.<br />
62 /// This creates an extra window in addition to the default main window<br />
64 /// <param name="windowPosition">The position and size of the Window.</param>
65 /// <param name="isTranslucent">Whether Window is translucent.</param>
66 /// <returns>A new Window.</returns>
67 /// <since_tizen> 6 </since_tizen>
68 /// <feature> http://tizen.org/feature/opengles.surfaceless_context </feature>
69 /// <exception cref="NotSupportedException">The required feature is not supported.</exception>
70 public Window(Rectangle windowPosition = null, bool isTranslucent = false) : this(Interop.Window.Window_New__SWIG_0(Rectangle.getCPtr(windowPosition), "", isTranslucent), true)
72 if (IsSupportedMultiWindow() == false)
74 NUILog.Error("This device does not support surfaceless_context. So Window cannot be created. ");
76 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
80 /// Creates a new Window with a specific name.<br />
81 /// This creates an extra window in addition to the default main window<br />
83 /// <param name="name">The name for extra window. </param>
84 /// <param name="windowPosition">The position and size of the Window.</param>
85 /// <param name="isTranslucent">Whether Window is translucent.</param>
86 /// <returns>A new Window.</returns>
87 /// <since_tizen> 6 </since_tizen>
88 /// <feature> http://tizen.org/feature/opengles.surfaceless_context </feature>
89 /// <exception cref="NotSupportedException">The required feature is not supported.</exception>
90 public Window(string name, Rectangle windowPosition = null, bool isTranslucent = false) : this(Interop.Window.Window_New__SWIG_0(Rectangle.getCPtr(windowPosition), name, isTranslucent), true)
92 if (IsSupportedMultiWindow() == false)
94 NUILog.Error("This device does not support surfaceless_context. So Window cannot be created. ");
96 this._windowTitle = name;
97 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
101 /// Enumeration for orientation of the window is the way in which a rectangular page is oriented for normal viewing.
103 /// <since_tizen> 3 </since_tizen>
104 public enum WindowOrientation
107 /// Portrait orientation. The height of the display area is greater than the width.
109 /// <since_tizen> 3 </since_tizen>
112 /// Landscape orientation. A wide view area is needed.
114 /// <since_tizen> 3 </since_tizen>
117 /// Portrait inverse orientation.
119 /// <since_tizen> 3 </since_tizen>
120 PortraitInverse = 180,
122 /// Landscape inverse orientation.
124 /// <since_tizen> 3 </since_tizen>
125 LandscapeInverse = 270,
127 /// No orientation. It is for the preferred orientation
128 /// Especially, NoOrientationPreference only has the effect for the preferred orientation.
129 /// It is used to unset the preferred orientation with SetPreferredOrientation.
131 [EditorBrowsable(EditorBrowsableState.Never)]
132 NoOrientationPreference = -1
136 /// Enumeration for the key grab mode for platform-level APIs.
138 /// <since_tizen> 3 </since_tizen>
139 public enum KeyGrabMode
142 /// Grabs a key only when on the top of the grabbing-window stack mode.
146 /// Grabs a key together with the other client window(s) mode.
150 /// 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.
154 /// Grabs a key exclusively regardless of the grabbing-window's position on the window stack mode.
160 /// Enumeration for transition effect's state.
162 [EditorBrowsable(EditorBrowsableState.Never)]
163 public enum EffectStates
168 [EditorBrowsable(EditorBrowsableState.Never)]
171 /// Transition effect is started.
173 [EditorBrowsable(EditorBrowsableState.Never)]
176 /// Transition effect is ended.
178 [EditorBrowsable(EditorBrowsableState.Never)]
183 /// Enumeration for transition effect's type.
185 [EditorBrowsable(EditorBrowsableState.Never)]
186 public enum EffectTypes
191 [EditorBrowsable(EditorBrowsableState.Never)]
194 /// Window show effect.
196 [EditorBrowsable(EditorBrowsableState.Never)]
199 /// Window hide effect.
201 [EditorBrowsable(EditorBrowsableState.Never)]
206 /// The stage instance property (read-only).<br />
207 /// Gets the current window.<br />
209 /// <since_tizen> 3 </since_tizen>
210 public static Window Instance
219 /// Gets or sets a window type.
221 /// <since_tizen> 3 </since_tizen>
222 public WindowType Type
226 WindowType ret = (WindowType)Interop.Window.GetType(swigCPtr);
227 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
232 Interop.Window.SetType(swigCPtr, (int)value);
233 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
238 /// Gets/Sets a window title.
240 /// <since_tizen> 4 </since_tizen>
249 _windowTitle = value;
250 SetClass(_windowTitle, "");
255 /// The rendering behavior of a Window.
257 /// <since_tizen> 5 </since_tizen>
258 public RenderingBehaviorType RenderingBehavior
262 return GetRenderingBehavior();
266 SetRenderingBehavior(value);
271 /// The window size property (read-only).
273 /// <since_tizen> 3 </since_tizen>
278 Size2D ret = GetSize();
284 /// The background color property.
286 /// <since_tizen> 3 </since_tizen>
287 public Color BackgroundColor
291 SetBackgroundColor(value);
295 Color ret = GetBackgroundColor();
301 /// The DPI property (read-only).<br />
302 /// Retrieves the DPI of the display device to which the Window is connected.<br />
304 /// <since_tizen> 3 </since_tizen>
314 /// The layer count property (read-only).<br />
315 /// Queries the number of on-Window layers.<br />
317 /// <since_tizen> 3 </since_tizen>
318 public uint LayerCount
322 return GetLayerCount();
327 /// Gets or sets a size of the window.
329 /// <since_tizen> 4 </since_tizen>
330 public Size2D WindowSize
334 return GetWindowSize();
338 SetWindowSize(value);
343 /// Gets or sets a position of the window.
345 /// <since_tizen> 4 </since_tizen>
346 public Position2D WindowPosition
350 return GetPosition();
359 /// Sets position and size of the window. This API guarantees that
360 /// both moving and resizing of window will appear on the screen at once.
362 [EditorBrowsable(EditorBrowsableState.Never)]
363 public Rectangle WindowPositionSize
367 Position2D position = GetPosition();
368 Size2D size = GetSize();
369 Rectangle ret = new Rectangle(position.X, position.Y, size.Width, size.Height);
374 SetPositionSize(value);
378 internal static Vector4 DEFAULT_BACKGROUND_COLOR
382 global::System.IntPtr cPtr = Interop.Stage.Stage_DEFAULT_BACKGROUND_COLOR_get();
383 Vector4 ret = (cPtr == global::System.IntPtr.Zero) ? null : new Vector4(cPtr, false);
384 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
389 internal static Vector4 DEBUG_BACKGROUND_COLOR
393 global::System.IntPtr cPtr = Interop.Stage.Stage_DEBUG_BACKGROUND_COLOR_get();
394 Vector4 ret = (cPtr == global::System.IntPtr.Zero) ? null : new Vector4(cPtr, false);
395 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
400 internal List<Layer> LayersChildren
409 /// Get the LayoutController for this Window.
411 internal LayoutController LayoutController
415 return localController;
420 /// Feed a key-event into the window.
422 /// <param name="keyEvent">The key event to feed.</param>
423 /// <since_tizen> 4 </since_tizen>
424 [Obsolete("Please do not use! This will be deprecated! Please use FeedKey(Key keyEvent) instead!")]
425 public static void FeedKeyEvent(Key keyEvent)
427 Interop.Window.Window_FeedKeyEvent(Key.getCPtr(keyEvent));
428 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
432 /// Sets whether the window accepts a focus or not.
434 /// <param name="accept">If a focus is accepted or not. The default is true.</param>
435 /// <since_tizen> 3 </since_tizen>
436 public void SetAcceptFocus(bool accept)
438 Interop.Window.SetAcceptFocus(swigCPtr, accept);
439 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
443 /// Returns whether the window accepts a focus or not.
445 /// <returns>True if the window accepts a focus, false otherwise.</returns>
446 /// <since_tizen> 3 </since_tizen>
447 public bool IsFocusAcceptable()
449 bool ret = Interop.Window.IsFocusAcceptable(swigCPtr);
450 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
456 /// Shows the window if it is hidden.
458 /// <since_tizen> 3 </since_tizen>
461 Interop.Window.Show(swigCPtr);
462 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
466 /// Hides the window if it is showing.
468 /// <since_tizen> 3 </since_tizen>
471 Interop.Window.Hide(swigCPtr);
472 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
476 /// Retrieves whether the window is visible or not.
478 /// <returns>True if the window is visible.</returns>
479 /// <since_tizen> 3 </since_tizen>
480 public bool IsVisible()
482 bool temp = Interop.Window.IsVisible(swigCPtr);
483 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
488 /// Gets the count of supported auxiliary hints of the window.
490 /// <returns>The number of supported auxiliary hints.</returns>
491 /// <since_tizen> 3 </since_tizen>
492 public uint GetSupportedAuxiliaryHintCount()
494 uint ret = Interop.Window.GetSupportedAuxiliaryHintCount(swigCPtr);
495 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
500 /// Gets the supported auxiliary hint string of the window.
502 /// <param name="index">The index of the supported auxiliary hint lists.</param>
503 /// <returns>The auxiliary hint string of the index.</returns>
504 /// <since_tizen> 3 </since_tizen>
505 public string GetSupportedAuxiliaryHint(uint index)
507 string ret = Interop.Window.GetSupportedAuxiliaryHint(swigCPtr, index);
508 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
513 /// Creates an auxiliary hint of the window.
515 /// <param name="hint">The auxiliary hint string.</param>
516 /// <param name="value">The value string.</param>
517 /// <returns>The ID of created auxiliary hint, or 0 on failure.</returns>
518 /// <since_tizen> 3 </since_tizen>
519 public uint AddAuxiliaryHint(string hint, string value)
521 uint ret = Interop.Window.AddAuxiliaryHint(swigCPtr, hint, value);
522 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
527 /// Removes an auxiliary hint of the window.
529 /// <param name="id">The ID of the auxiliary hint.</param>
530 /// <returns>True if no error occurred, false otherwise.</returns>
531 /// <since_tizen> 3 </since_tizen>
532 public bool RemoveAuxiliaryHint(uint id)
534 bool ret = Interop.Window.RemoveAuxiliaryHint(swigCPtr, id);
535 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
540 /// Changes a value of the auxiliary hint.
542 /// <param name="id">The auxiliary hint ID.</param>
543 /// <param name="value">The value string to be set.</param>
544 /// <returns>True if no error occurred, false otherwise.</returns>
545 /// <since_tizen> 3 </since_tizen>
546 public bool SetAuxiliaryHintValue(uint id, string value)
548 bool ret = Interop.Window.SetAuxiliaryHintValue(swigCPtr, id, value);
549 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
554 /// Gets a value of the auxiliary hint.
556 /// <param name="id">The auxiliary hint ID.</param>
557 /// <returns>The string value of the auxiliary hint ID, or an empty string if none exists.</returns>
558 /// <since_tizen> 3 </since_tizen>
559 public string GetAuxiliaryHintValue(uint id)
561 string ret = Interop.Window.GetAuxiliaryHintValue(swigCPtr, id);
562 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
567 /// Gets an ID of the auxiliary hint string.
569 /// <param name="hint">The auxiliary hint string.</param>
570 /// <returns>The ID of auxiliary hint string, or 0 on failure.</returns>
571 /// <since_tizen> 3 </since_tizen>
572 public uint GetAuxiliaryHintId(string hint)
574 uint ret = Interop.Window.GetAuxiliaryHintId(swigCPtr, hint);
575 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
580 /// Sets a region to accept input events.
582 /// <param name="inputRegion">The region to accept input events.</param>
583 /// <since_tizen> 3 </since_tizen>
584 public void SetInputRegion(Rectangle inputRegion)
586 Interop.Window.SetInputRegion(swigCPtr, Rectangle.getCPtr(inputRegion));
587 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
591 /// Sets a priority level for the specified notification window.
593 /// <param name="level">The notification window level.</param>
594 /// <returns>True if no error occurred, false otherwise.</returns>
595 /// <since_tizen> 3 </since_tizen>
596 public bool SetNotificationLevel(NotificationLevel level)
598 bool ret = Interop.Window.SetNotificationLevel(swigCPtr, (int)level);
599 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
604 /// Gets a priority level for the specified notification window.
606 /// <returns>The notification window level.</returns>
607 /// <since_tizen> 3 </since_tizen>
608 public NotificationLevel GetNotificationLevel()
610 NotificationLevel ret = (NotificationLevel)Interop.Window.GetNotificationLevel(swigCPtr);
611 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
616 /// Sets a transparent window's visual state to opaque. <br />
617 /// If a visual state of a transparent window is opaque, <br />
618 /// then the window manager could handle it as an opaque window when calculating visibility.
620 /// <param name="opaque">Whether the window's visual state is opaque.</param>
621 /// <remarks>This will have no effect on an opaque window. <br />
622 /// It doesn't change transparent window to opaque window but lets the window manager know the visual state of the window.
624 /// <since_tizen> 3 </since_tizen>
625 public void SetOpaqueState(bool opaque)
627 Interop.Window.SetOpaqueState(swigCPtr, opaque);
628 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
632 /// Returns whether a transparent window's visual state is opaque or not.
634 /// <returns>True if the window's visual state is opaque, false otherwise.</returns>
635 /// <remarks> The return value has no meaning on an opaque window. </remarks>
636 /// <since_tizen> 3 </since_tizen>
637 public bool IsOpaqueState()
639 bool ret = Interop.Window.IsOpaqueState(swigCPtr);
640 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
645 /// Sets a window's screen off mode.
647 /// <param name="screenOffMode">The screen mode.</param>
648 /// <returns>True if no error occurred, false otherwise.</returns>
649 /// <since_tizen> 4 </since_tizen>
650 public bool SetScreenOffMode(ScreenOffMode screenOffMode)
652 bool ret = Interop.Window.SetScreenOffMode(swigCPtr, (int)screenOffMode);
653 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
658 /// Gets the screen mode of the window.
660 /// <returns>The screen off mode.</returns>
661 /// <since_tizen> 4 </since_tizen>
662 public ScreenOffMode GetScreenOffMode()
664 ScreenOffMode ret = (ScreenOffMode)Interop.Window.GetScreenOffMode(swigCPtr);
665 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
670 /// Sets preferred brightness of the window.
672 /// <param name="brightness">The preferred brightness (0 to 100).</param>
673 /// <returns>True if no error occurred, false otherwise.</returns>
674 /// <since_tizen> 3 </since_tizen>
675 public bool SetBrightness(int brightness)
677 bool ret = Interop.Window.SetBrightness(swigCPtr, brightness);
678 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
683 /// Gets the preferred brightness of the window.
685 /// <returns>The preferred brightness.</returns>
686 /// <since_tizen> 3 </since_tizen>
687 public int GetBrightness()
689 int ret = Interop.Window.GetBrightness(swigCPtr);
690 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
695 /// Sets the window name and the class string.
697 /// <param name="name">The name of the window.</param>
698 /// <param name="klass">The class of the window.</param>
699 /// <since_tizen> 4 </since_tizen>
700 public void SetClass(string name, string klass)
702 Interop.Window.Window_SetClass(swigCPtr, name, klass);
703 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
707 /// Raises the window to the top of the window stack.
709 /// <since_tizen> 3 </since_tizen>
712 Interop.Window.Window_Raise(swigCPtr);
713 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
717 /// Lowers the window to the bottom of the window stack.
719 /// <since_tizen> 3 </since_tizen>
722 Interop.Window.Window_Lower(swigCPtr);
723 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
727 /// Activates the window to the top of the window stack even it is iconified.
729 /// <since_tizen> 3 </since_tizen>
730 public void Activate()
732 Interop.Window.Window_Activate(swigCPtr);
733 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
737 /// Gets the default ( root ) layer.
739 /// <returns>The root layer.</returns>
740 /// <since_tizen> 3 </since_tizen>
741 public Layer GetDefaultLayer()
743 return this.GetRootLayer();
747 /// Add a child view to window.
749 /// <param name="view">the child should be added to the window.</param>
750 /// <since_tizen> 3 </since_tizen>
751 public void Add(View view)
753 Interop.Actor.Actor_Add(Layer.getCPtr(GetRootLayer()), View.getCPtr(view));
754 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
755 this.GetRootLayer().AddViewToLayerList(view); // Maintain the children list in the Layer
756 view.InternalParent = this.GetRootLayer();
760 /// Remove a child view from window.
762 /// <param name="view">the child to be removed.</param>
763 /// <since_tizen> 3 </since_tizen>
764 public void Remove(View view)
766 Interop.Actor.Actor_Remove(Layer.getCPtr(GetRootLayer()), View.getCPtr(view));
767 this.GetRootLayer().RemoveViewFromLayerList(view); // Maintain the children list in the Layer
768 view.InternalParent = null;
772 /// Retrieves the layer at a specified depth.
774 /// <param name="depth">The layer's depth index.</param>
775 /// <returns>The layer found at the given depth.</returns>
776 /// <since_tizen> 3 </since_tizen>
777 public Layer GetLayer(uint depth)
779 if (depth < LayersChildren?.Count)
781 Layer ret = LayersChildren?[Convert.ToInt32(depth)];
791 /// Destroy the window immediately.
793 [EditorBrowsable(EditorBrowsableState.Never)]
794 public void Destroy()
800 /// Keep rendering for at least the given amount of time.
802 /// <param name="durationSeconds">Time to keep rendering, 0 means render at least one more frame.</param>
803 /// <since_tizen> 3 </since_tizen>
804 public void KeepRendering(float durationSeconds)
806 Interop.Stage.Stage_KeepRendering(stageCPtr, durationSeconds);
807 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
811 /// Grabs the key specified by a key for a window only when a window is the topmost window.<br />
812 /// This function can be used for following example scenarios: <br />
813 /// - Mobile - Using volume up or down as zoom up or down in camera apps.<br />
815 /// <param name="DaliKey">The key code to grab.</param>
816 /// <returns>True if the grab succeeds.</returns>
817 /// <since_tizen> 3 </since_tizen>
818 public bool GrabKeyTopmost(int DaliKey)
820 bool ret = Interop.Window.GrabKeyTopmost(HandleRef.ToIntPtr(this.swigCPtr), DaliKey);
821 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
826 /// Ungrabs the key specified by a key for the window.<br />
827 /// 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 />
829 /// <param name="DaliKey">The key code to ungrab.</param>
830 /// <returns>True if the ungrab succeeds.</returns>
831 /// <since_tizen> 3 </since_tizen>
832 public bool UngrabKeyTopmost(int DaliKey)
834 bool ret = Interop.Window.UngrabKeyTopmost(HandleRef.ToIntPtr(this.swigCPtr), DaliKey);
835 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
840 /// Grabs the key specified by a key for a window in a GrabMode. <br />
841 /// Details: This function can be used for following example scenarios: <br />
842 /// - TV - A user might want to change the volume or channel of the background TV contents while focusing on the foregrund app. <br />
843 /// - Mobile - When a user presses the Home key, the homescreen appears regardless of the current foreground app. <br />
844 /// - Mobile - Using the volume up or down as zoom up or down in camera apps. <br />
846 /// <param name="DaliKey">The key code to grab.</param>
847 /// <param name="GrabMode">The grab mode for the key.</param>
848 /// <returns>True if the grab succeeds.</returns>
849 /// <since_tizen> 3 </since_tizen>
850 public bool GrabKey(int DaliKey, KeyGrabMode GrabMode)
852 bool ret = Interop.Window.GrabKey(HandleRef.ToIntPtr(this.swigCPtr), DaliKey, (int)GrabMode);
853 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
858 /// Ungrabs the key specified by a key for a window.<br />
859 /// 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 />
861 /// <param name="DaliKey">The key code to ungrab.</param>
862 /// <returns>True if the ungrab succeeds.</returns>
863 /// <since_tizen> 3 </since_tizen>
864 public bool UngrabKey(int DaliKey)
866 bool ret = Interop.Window.UngrabKey(HandleRef.ToIntPtr(this.swigCPtr), DaliKey);
867 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
872 /// Sets the keyboard repeat information.
874 /// <param name="rate">The key repeat rate value in seconds.</param>
875 /// <param name="delay">The key repeat delay value in seconds.</param>
876 /// <returns>True if setting the keyboard repeat succeeds.</returns>
877 /// <since_tizen> 5 </since_tizen>
878 public bool SetKeyboardRepeatInfo(float rate, float delay)
880 bool ret = Interop.Window.SetKeyboardRepeatInfo(rate, delay);
881 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
886 /// Gets the keyboard repeat information.
888 /// <param name="rate">The key repeat rate value in seconds.</param>
889 /// <param name="delay">The key repeat delay value in seconds.</param>
890 /// <returns>True if setting the keyboard repeat succeeds.</returns>
891 /// <since_tizen> 5 </since_tizen>
892 public bool GetKeyboardRepeatInfo(out float rate, out float delay)
894 bool ret = Interop.Window.GetKeyboardRepeatInfo(out rate, out delay);
895 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
900 /// Adds a layer to the stage.
902 /// <param name="layer">Layer to add.</param>
903 /// <since_tizen> 3 </since_tizen>
904 public void AddLayer(Layer layer)
910 /// Removes a layer from the stage.
912 /// <param name="layer">Layer to remove.</param>
913 /// <since_tizen> 3 </since_tizen>
914 public void RemoveLayer(Layer layer)
920 /// Feeds a key event into the window.
922 /// <param name="keyEvent">The key event to feed.</param>
923 /// <since_tizen> 5 </since_tizen>
924 public void FeedKey(Key keyEvent)
926 Interop.Window.Window_FeedKeyEvent(Key.getCPtr(keyEvent));
927 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
931 /// Allows at least one more render, even when paused.
932 /// The window should be shown, not minimised.
934 /// <since_tizen> 4 </since_tizen>
935 public void RenderOnce()
937 Interop.Window.Window_RenderOnce(swigCPtr);
938 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
942 /// Sets whether the window is transparent or not.
944 /// <param name="transparent">Whether the window is transparent or not.</param>
945 /// <since_tizen> 5 </since_tizen>
946 public void SetTransparency(bool transparent)
948 Interop.Window.SetTransparency(swigCPtr, transparent);
949 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
951 // Setting transparency of the window should request a relayout of the tree in the case the window changes from fully transparent.
955 /// Sets parent window of the window.
956 /// After setting that, these windows do together when raise-up, lower and iconified/deiconified.
957 /// Initially, the window is located on top of the parent. The window can go below parent by calling Lower().
958 /// If parent's window stack is changed by calling Raise() or Lower(), child windows are located on top of the parent again.
960 /// <param name="parent">The parent window.</param>
961 /// <since_tizen> 6 </since_tizen>
962 /// <feature> http://tizen.org/feature/opengles.surfaceless_context </feature>
963 /// <exception cref="NotSupportedException">The required feature is not supported.</exception>
964 public void SetParent(Window parent)
966 if (IsSupportedMultiWindow() == false)
968 NUILog.Error("This device does not support surfaceless_context. So Window cannot be created. ");
970 Interop.Window.SetParent(swigCPtr, Window.getCPtr(parent));
971 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
975 /// Unsets parent window of the window.
976 /// After unsetting, the window is disconnected his parent window.
978 /// <since_tizen> 6 </since_tizen>
979 /// <feature> http://tizen.org/feature/opengles.surfaceless_context </feature>
980 /// <exception cref="NotSupportedException">The required feature is not supported.</exception>
981 public void Unparent()
983 if (IsSupportedMultiWindow() == false)
985 NUILog.Error("Fail to create window. because this device does not support opengles.surfaceless_context.");
987 Interop.Window.Unparent(swigCPtr);
988 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
992 /// Gets parent window of the window.
994 /// <returns>The parent window of the window.</returns>
995 /// <since_tizen> 6 </since_tizen>
996 /// <feature> http://tizen.org/feature/opengles.surfaceless_context </feature>
997 /// <exception cref="NotSupportedException">The required feature is not supported.</exception>
998 public Window GetParent()
1000 if (IsSupportedMultiWindow() == false)
1002 NUILog.Error("This device does not support surfaceless_context. So Window cannot be created. ");
1004 Window ret = Registry.GetManagedBaseHandleFromNativePtr(Interop.Window.GetParent(swigCPtr)) as Window;
1005 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1009 /// This will be public opened in tizen_next after ACR done. Before ACR, need to be hidden as inhouse API.
1010 [EditorBrowsable(EditorBrowsableState.Never)]
1011 public void ObjectDump()
1013 Layer rootLayer = GetRootLayer();
1014 foreach (View view in rootLayer.Children)
1020 internal static global::System.Runtime.InteropServices.HandleRef getCPtr(Window obj)
1022 return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
1025 internal static bool IsInstalled()
1027 bool ret = Interop.Stage.Stage_IsInstalled();
1028 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1033 /// Adds an orientation to the list of available orientations.
1035 /// <param name="orientation">The available orientation to add</param>
1036 /// <since_tizen> 6 </since_tizen>
1037 public void AddAvailableOrientation(Window.WindowOrientation orientation)
1039 Interop.Window.Window_AddAvailableOrientation(swigCPtr, (int)orientation);
1040 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1044 /// Removes an orientation from the list of available orientations.
1046 /// <param name="orientation">The available orientation to remove.</param>
1047 /// <since_tizen> 6 </since_tizen>
1048 public void RemoveAvailableOrientation(Window.WindowOrientation orientation)
1050 Interop.Window.Window_RemoveAvailableOrientation(swigCPtr, (int)orientation);
1051 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1055 /// Sets a preferred orientation.
1057 /// <param name="orientation">The preferred orientation.</param>
1058 /// <since_tizen> 6 </since_tizen>
1059 public void SetPreferredOrientation(Window.WindowOrientation orientation)
1061 Interop.Window.Window_SetPreferredOrientation(swigCPtr, (int)orientation);
1062 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1066 /// Gets the preferred orientation.
1068 /// <since_tizen> 6 </since_tizen>
1069 /// <returns>The preferred orientation if previously set, or none.</returns>
1070 public Window.WindowOrientation GetPreferredOrientation()
1072 Window.WindowOrientation ret = (Window.WindowOrientation)Interop.Window.Window_GetPreferredOrientation(swigCPtr);
1073 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1078 /// Gets current orientation of the window.
1080 /// <since_tizen> 6 </since_tizen>
1081 /// <returns>The current window orientation if previously set, or none.</returns>
1082 [EditorBrowsable(EditorBrowsableState.Never)]
1083 public Window.WindowOrientation GetCurrentOrientation()
1085 Window.WindowOrientation ret = (Window.WindowOrientation)Interop.Window.Window_GetCurrentOrientation(swigCPtr);
1086 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1091 /// Sets available orientations of the window.
1092 /// This API is for setting several orientations one time.
1094 /// <param name="orientations">The list of orientations.</param>
1095 /// <since_tizen> 6 </since_tizen>
1096 [EditorBrowsable(EditorBrowsableState.Never)]
1097 public void SetAvailableOrientations(List<Window.WindowOrientation> orientations)
1099 PropertyArray orientationArray = new PropertyArray();
1100 for (int i = 0; i < orientations.Count; i++)
1102 orientationArray.PushBack(new PropertyValue((int)orientations[i]));
1105 Interop.Window.Window_SetAvailableOrientations(swigCPtr, PropertyArray.getCPtr(orientationArray));
1106 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1110 /// Get native window ID
1112 /// <returns>native window ID</returns>
1113 [EditorBrowsable(EditorBrowsableState.Never)]
1114 public int GetNativeId()
1116 int ret = Interop.Window.GetNativeId(swigCPtr);
1117 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1121 internal Any GetNativeHandle()
1123 Any ret = new Any(Interop.WindowInternal.Window_GetNativeHandle(swigCPtr), true);
1124 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1128 internal void Add(Layer layer)
1130 Interop.Window.Add(swigCPtr, Layer.getCPtr(layer));
1131 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1133 LayersChildren?.Add(layer);
1134 layer.SetWindow(this);
1137 internal void Remove(Layer layer)
1139 Interop.Window.Remove(swigCPtr, Layer.getCPtr(layer));
1140 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1142 LayersChildren?.Remove(layer);
1143 layer.SetWindow(null);
1146 internal Vector2 GetSize()
1148 var val = new Uint16Pair(Interop.Window.GetSize(swigCPtr), false);
1149 Vector2 ret = new Vector2(val.GetWidth(), val.GetHeight());
1150 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1154 internal RenderTaskList GetRenderTaskList()
1156 RenderTaskList ret = new RenderTaskList(Interop.Stage.Stage_GetRenderTaskList(stageCPtr), true);
1157 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1162 /// Queries the number of on-window layers.
1164 /// <returns>The number of layers.</returns>
1165 /// <remarks>Note that a default layer is always provided (count >= 1).</remarks>
1166 internal uint GetLayerCount()
1168 if (LayersChildren == null || LayersChildren.Count < 0)
1171 return (uint)LayersChildren.Count;
1174 internal Layer GetRootLayer()
1176 // Window.IsInstalled() is actually true only when called from event thread and
1177 // Core has been initialized, not when Stage is ready.
1178 if (_rootLayer == null && Window.IsInstalled())
1180 _rootLayer = new Layer(Interop.Window.GetRootLayer(swigCPtr), true);
1181 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1182 LayersChildren?.Add(_rootLayer);
1183 _rootLayer.SetWindow(this);
1188 internal void SetBackgroundColor(Vector4 color)
1190 Interop.Window.SetBackgroundColor(swigCPtr, Vector4.getCPtr(color));
1191 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1194 internal Vector4 GetBackgroundColor()
1196 Vector4 ret = new Vector4(Interop.Window.GetBackgroundColor(swigCPtr), true);
1197 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1201 internal Vector2 GetDpi()
1203 Vector2 ret = new Vector2(Interop.Stage.Stage_GetDpi(stageCPtr), true);
1204 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1208 internal ObjectRegistry GetObjectRegistry()
1210 ObjectRegistry ret = new ObjectRegistry(Interop.Stage.Stage_GetObjectRegistry(stageCPtr), true);
1211 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1215 internal void SetRenderingBehavior(RenderingBehaviorType renderingBehavior)
1217 Interop.Stage.Stage_SetRenderingBehavior(stageCPtr, (int)renderingBehavior);
1218 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1221 internal RenderingBehaviorType GetRenderingBehavior()
1223 RenderingBehaviorType ret = (RenderingBehaviorType)Interop.Stage.Stage_GetRenderingBehavior(stageCPtr);
1224 if (NDalicPINVOKE.SWIGPendingException.Pending)
1225 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1229 internal void SetWindowSize(Size2D size)
1231 var val = new Uint16Pair((uint)size.Width, (uint)size.Height);
1232 Interop.Window.SetSize(swigCPtr, Uint16Pair.getCPtr(val));
1234 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1236 // Resetting Window size should request a relayout of the tree.
1239 internal Size2D GetWindowSize()
1241 var val = new Uint16Pair(Interop.Window.GetSize(swigCPtr), false);
1242 Size2D ret = new Size2D(val.GetWidth(), val.GetHeight());
1244 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1248 internal void SetPosition(Position2D position)
1250 var val = new Uint16Pair((uint)position.X, (uint)position.Y);
1251 Interop.Window.SetPosition(swigCPtr, Uint16Pair.getCPtr(val));
1253 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1254 // Setting Position of the window should request a relayout of the tree.
1257 internal Position2D GetPosition()
1259 var val = new Uint16Pair(Interop.Window.GetPosition(swigCPtr), true);
1260 Position2D ret = new Position2D(val.GetX(), val.GetY());
1262 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1266 internal void SetPositionSize(Rectangle positionSize)
1268 Interop.Window.Window_SetPositionSize(swigCPtr, Rectangle.getCPtr(positionSize));
1270 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1272 // Setting Position of the window should request a relayout of the tree.
1276 /// Add FrameCallback
1278 [EditorBrowsable(EditorBrowsableState.Never)]
1279 public void AddFrameCallback(FrameCallbackInterface frameCallback)
1281 frameCallback?.AddFrameCallback(stageCPtr, Layer.getCPtr(GetRootLayer()));
1285 /// Remove FrameCallback
1287 [EditorBrowsable(EditorBrowsableState.Never)]
1288 public void RemoveFrameCallback(FrameCallbackInterface frameCallback)
1290 frameCallback?.RemoveFrameCallback(stageCPtr);
1294 /// Dispose for Window
1296 [EditorBrowsable(EditorBrowsableState.Never)]
1297 protected override void Dispose(DisposeTypes type)
1304 if (type == DisposeTypes.Explicit)
1307 //Release your own managed resources here.
1308 //You should release all of your own disposable objects here.
1310 if (_rootLayer != null)
1312 _rootLayer.Dispose();
1315 localController?.Dispose();
1317 foreach (var layer in _childLayers)
1325 _childLayers.Clear();
1328 this.DisconnectNativeSignals();
1333 /// This will not be public opened.
1334 [EditorBrowsable(EditorBrowsableState.Never)]
1335 protected override void ReleaseSwigCPtr(System.Runtime.InteropServices.HandleRef swigCPtr)
1337 Interop.Window.delete_Window(swigCPtr);
1340 private static Dictionary<int, internalHookCallbackType> frameCallbackList = new Dictionary<int, internalHookCallbackType>();
1342 private static readonly object locker = new object();
1344 private static int key = 0;
1346 private static FrameCallbackType internalHookFrameCallback = OnInternalHookFrameCallback;
1348 private struct internalHookCallbackType
1350 public FrameCallbackType userCallback;
1354 private static void OnInternalHookFrameCallback(int id)
1358 if (frameCallbackList.ContainsKey(id))
1360 if (frameCallbackList[id].userCallback != null)
1362 frameCallbackList[id].userCallback.Invoke(frameCallbackList[id].frameId);
1363 frameCallbackList.Remove(id);
1367 NUILog.Error($"found userCallback is NULL");
1368 frameCallbackList.Remove(id);
1374 private int AddInterHookCallback(FrameCallbackType callback, int frameId)
1376 if (null == callback)
1378 throw new ArgumentNullException(nameof(callback), "FrameCallbackType should not be null");
1380 var assignedKey = 0;
1385 frameCallbackList.Add(assignedKey, new internalHookCallbackType()
1387 userCallback = callback,
1395 /// Type of callback which is called when the frame rendering is done by graphics driver or when the frame is displayed on display.
1397 /// <param name="frameId">The Id to specify the frame. It will be passed when the callback is called.</param>
1398 [EditorBrowsable(EditorBrowsableState.Never)]
1399 public delegate void FrameCallbackType(int frameId);
1402 /// Adds a callback that is called when the frame rendering is done by the graphics driver.
1403 /// A callback of the following type may be used:
1405 /// void MyFunction( int frameId )
1407 /// This callback will be deleted once it is called.
1409 /// Ownership of the callback is passed onto this class
1412 /// <param name="callback">The function to call</param>
1413 /// <param name="frameId">The Id to specify the frame. It will be passed when the callback is called.</param>
1414 /// <exception cref="ArgumentNullException">This exception can occur by the callback is null.</exception>
1415 [EditorBrowsable(EditorBrowsableState.Never)]
1416 public void AddFrameRenderedCallback(FrameCallbackType callback, int frameId)
1418 var assignedKey = AddInterHookCallback(callback, frameId);
1419 Interop.WindowInternal.AddFrameRenderedCallback(swigCPtr, new HandleRef(this, Marshal.GetFunctionPointerForDelegate<Delegate>(internalHookFrameCallback)), assignedKey);
1421 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1425 /// Adds a callback that is called when the frame is displayed on the display.
1426 /// A callback of the following type may be used:
1428 /// void MyFunction( int frameId )
1430 /// This callback will be deleted once it is called.
1432 /// Ownership of the callback is passed onto this class
1435 /// <param name="callback">The function to call</param>
1436 /// <param name="frameId">The Id to specify the frame. It will be passed when the callback is called.</param>
1437 /// <exception cref="ArgumentNullException">This exception can occur by the callback is null.</exception>
1438 [EditorBrowsable(EditorBrowsableState.Never)]
1439 public void AddFramePresentedCallback(FrameCallbackType callback, int frameId)
1441 var assignedKey = AddInterHookCallback(callback, frameId);
1442 Interop.WindowInternal.AddFramePresentedCallback(swigCPtr, new HandleRef(this, Marshal.GetFunctionPointerForDelegate<Delegate>(internalHookFrameCallback)), assignedKey);
1444 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();