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 using System.ComponentModel;
19 using System.Collections.Generic;
20 using System.Runtime.InteropServices;
21 using Tizen.NUI.BaseComponents;
26 /// The window class is used internally for drawing.<br />
27 /// The window has an orientation and indicator properties.<br />
29 /// <since_tizen> 3 </since_tizen>
30 public partial class Window : BaseHandle
32 private static readonly Window instance = Application.Instance?.GetWindow();
33 private global::System.Runtime.InteropServices.HandleRef swigCPtr;
34 private global::System.Runtime.InteropServices.HandleRef stageCPtr;
35 private Layer _rootLayer;
36 private string _windowTitle;
37 private List<Layer> _childLayers = new List<Layer>();
38 private LayoutController localController;
40 internal Window(global::System.IntPtr cPtr, bool cMemoryOwn) : base(Interop.Window.Window_SWIGUpcast(cPtr), cMemoryOwn)
42 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
43 if (Interop.Stage.Stage_IsInstalled())
45 stageCPtr = new global::System.Runtime.InteropServices.HandleRef(this, Interop.Stage.Stage_GetCurrent());
47 localController = new LayoutController(this);
48 NUILog.Debug("layoutController id:" + localController.GetId() );
53 /// Creates a new Window.<br />
54 /// This creates an extra window in addition to the default main window<br />
56 /// <param name="windowPosition">The position and size of the Window.</param>
57 /// <param name="isTranslucent">Whether Window is translucent.</param>
58 /// <returns>A new Window.</returns>
59 /// <since_tizen> 6 </since_tizen>
60 public Window(Rectangle windowPosition = null , bool isTranslucent = false) : this(Interop.Window.Window_New__SWIG_0(Rectangle.getCPtr(windowPosition), "", isTranslucent), true)
62 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
66 /// Creates a new Window.<br />
67 /// This creates an extra window in addition to the default main window<br />
69 /// <param name="name">The name for extra window. </param>
70 /// <param name="windowPosition">The position and size of the Window.</param>
71 /// <param name="isTranslucent">Whether Window is translucent.</param>
72 /// <returns>A new Window.</returns>
73 /// <since_tizen> 6 </since_tizen>
74 public Window(string name, Rectangle windowPosition = null, bool isTranslucent = false) : this(Interop.Window.Window_New__SWIG_0(Rectangle.getCPtr(windowPosition), name, isTranslucent), true)
76 this._windowTitle = name;
77 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
81 /// Enumeration for orientation of the window is the way in which a rectangular page is oriented for normal viewing.
83 /// <since_tizen> 3 </since_tizen>
84 public enum WindowOrientation
87 /// Portrait orientation. The height of the display area is greater than the width.
89 /// <since_tizen> 3 </since_tizen>
92 /// Landscape orientation. A wide view area is needed.
94 /// <since_tizen> 3 </since_tizen>
97 /// Portrait inverse orientation.
99 /// <since_tizen> 3 </since_tizen>
100 PortraitInverse = 180,
102 /// Landscape inverse orientation.
104 /// <since_tizen> 3 </since_tizen>
105 LandscapeInverse = 270
109 /// Enumeration for the key grab mode for platform-level APIs.
111 /// <since_tizen> 3 </since_tizen>
112 public enum KeyGrabMode
115 /// Grabs a key only when on the top of the grabbing-window stack mode.
119 /// Grabs a key together with the other client window(s) mode.
123 /// 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.
127 /// Grabs a key exclusively regardless of the grabbing-window's position on the window stack mode.
133 /// Enumeration for transition effect's state.
135 [EditorBrowsable(EditorBrowsableState.Never)]
136 public enum EffectStates
141 [EditorBrowsable(EditorBrowsableState.Never)]
144 /// Transition effect is started.
146 [EditorBrowsable(EditorBrowsableState.Never)]
149 /// Transition effect is ended.
151 [EditorBrowsable(EditorBrowsableState.Never)]
156 /// Enumeration for transition effect's type.
158 [EditorBrowsable(EditorBrowsableState.Never)]
159 public enum EffectTypes
164 [EditorBrowsable(EditorBrowsableState.Never)]
167 /// Window show effect.
169 [EditorBrowsable(EditorBrowsableState.Never)]
172 /// Window hide effect.
174 [EditorBrowsable(EditorBrowsableState.Never)]
179 /// Enumeration for opacity of the indicator.
181 internal enum IndicatorBackgroundOpacity
189 /// Enumeration for visible mode of the indicator.
191 internal enum IndicatorVisibleMode
199 /// The stage instance property (read-only).<br />
200 /// Gets the current window.<br />
202 /// <since_tizen> 3 </since_tizen>
203 public static Window Instance
212 /// Gets or sets a window type.
214 /// <since_tizen> 3 </since_tizen>
215 public WindowType Type
219 WindowType ret = (WindowType)Interop.Window.GetType(swigCPtr);
220 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
225 Interop.Window.SetType(swigCPtr, (int)value);
226 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
231 /// Gets/Sets a window title.
233 /// <since_tizen> 4 </since_tizen>
242 _windowTitle = value;
243 SetClass(_windowTitle, "");
248 /// The rendering behavior of a Window.
250 /// <since_tizen> 5 </since_tizen>
251 public RenderingBehaviorType RenderingBehavior
255 return GetRenderingBehavior();
259 SetRenderingBehavior(value);
264 /// The window size property (read-only).
266 /// <since_tizen> 3 </since_tizen>
271 Size2D ret = GetSize();
277 /// The background color property.
279 /// <since_tizen> 3 </since_tizen>
280 public Color BackgroundColor
284 SetBackgroundColor(value);
288 Color ret = GetBackgroundColor();
294 /// The DPI property (read-only).<br />
295 /// Retrieves the DPI of the display device to which the Window is connected.<br />
297 /// <since_tizen> 3 </since_tizen>
307 /// The layer count property (read-only).<br />
308 /// Queries the number of on-Window layers.<br />
310 /// <since_tizen> 3 </since_tizen>
311 public uint LayerCount
315 return GetLayerCount();
320 /// Gets or sets a size of the window.
322 /// <since_tizen> 4 </since_tizen>
323 public Size2D WindowSize
327 return GetWindowSize();
331 SetWindowSize(value);
336 /// Gets or sets a position of the window.
338 /// <since_tizen> 4 </since_tizen>
339 public Position2D WindowPosition
343 return GetPosition();
352 /// Sets position and size of the window. This API guarantees that
353 /// both moving and resizing of window will appear on the screen at once.
355 [EditorBrowsable(EditorBrowsableState.Never)]
356 public Rectangle WindowPositionSize
360 Position2D position = GetPosition();
361 Size2D size = GetSize();
362 Rectangle ret = new Rectangle(position.X, position.Y, size.Width, size.Height);
367 SetPositionSize(value);
371 internal static Vector4 DEFAULT_BACKGROUND_COLOR
375 global::System.IntPtr cPtr = Interop.Stage.Stage_DEFAULT_BACKGROUND_COLOR_get();
376 Vector4 ret = (cPtr == global::System.IntPtr.Zero) ? null : new Vector4(cPtr, false);
377 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
382 internal static Vector4 DEBUG_BACKGROUND_COLOR
386 global::System.IntPtr cPtr = Interop.Stage.Stage_DEBUG_BACKGROUND_COLOR_get();
387 Vector4 ret = (cPtr == global::System.IntPtr.Zero) ? null : new Vector4(cPtr, false);
388 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
393 internal List<Layer> LayersChildren
402 /// Get the LayoutController for this Window.
404 internal LayoutController LayoutController
408 return localController;
413 /// Feed a key-event into the window.
415 /// <param name="keyEvent">The key event to feed.</param>
416 /// <since_tizen> 4 </since_tizen>
417 [Obsolete("Please do not use! This will be deprecated! Please use FeedKey(Key keyEvent) instead!")]
418 public static void FeedKeyEvent(Key keyEvent)
420 Interop.Window.Window_FeedKeyEvent(Key.getCPtr(keyEvent));
421 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
425 /// Sets whether the window accepts a focus or not.
427 /// <param name="accept">If a focus is accepted or not. The default is true.</param>
428 /// <since_tizen> 3 </since_tizen>
429 public void SetAcceptFocus(bool accept)
431 Interop.Window.SetAcceptFocus(swigCPtr, accept);
432 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
436 /// Returns whether the window accepts a focus or not.
438 /// <returns>True if the window accepts a focus, false otherwise.</returns>
439 /// <since_tizen> 3 </since_tizen>
440 public bool IsFocusAcceptable()
442 bool ret = Interop.Window.IsFocusAcceptable(swigCPtr);
443 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
449 /// Shows the window if it is hidden.
451 /// <since_tizen> 3 </since_tizen>
454 Interop.Window.Show(swigCPtr);
455 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
459 /// Hides the window if it is showing.
461 /// <since_tizen> 3 </since_tizen>
464 Interop.Window.Hide(swigCPtr);
465 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
469 /// Retrieves whether the window is visible or not.
471 /// <returns>True if the window is visible.</returns>
472 /// <since_tizen> 3 </since_tizen>
473 public bool IsVisible()
475 bool temp = Interop.Window.IsVisible(swigCPtr);
476 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
481 /// Gets the count of supported auxiliary hints of the window.
483 /// <returns>The number of supported auxiliary hints.</returns>
484 /// <since_tizen> 3 </since_tizen>
485 public uint GetSupportedAuxiliaryHintCount()
487 uint ret = Interop.Window.GetSupportedAuxiliaryHintCount(swigCPtr);
488 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
493 /// Gets the supported auxiliary hint string of the window.
495 /// <param name="index">The index of the supported auxiliary hint lists.</param>
496 /// <returns>The auxiliary hint string of the index.</returns>
497 /// <since_tizen> 3 </since_tizen>
498 public string GetSupportedAuxiliaryHint(uint index)
500 string ret = Interop.Window.GetSupportedAuxiliaryHint(swigCPtr, index);
501 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
506 /// Creates an auxiliary hint of the window.
508 /// <param name="hint">The auxiliary hint string.</param>
509 /// <param name="value">The value string.</param>
510 /// <returns>The ID of created auxiliary hint, or 0 on failure.</returns>
511 /// <since_tizen> 3 </since_tizen>
512 public uint AddAuxiliaryHint(string hint, string value)
514 uint ret = Interop.Window.AddAuxiliaryHint(swigCPtr, hint, value);
515 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
520 /// Removes an auxiliary hint of the window.
522 /// <param name="id">The ID of the auxiliary hint.</param>
523 /// <returns>True if no error occurred, false otherwise.</returns>
524 /// <since_tizen> 3 </since_tizen>
525 public bool RemoveAuxiliaryHint(uint id)
527 bool ret = Interop.Window.RemoveAuxiliaryHint(swigCPtr, id);
528 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
533 /// Changes a value of the auxiliary hint.
535 /// <param name="id">The auxiliary hint ID.</param>
536 /// <param name="value">The value string to be set.</param>
537 /// <returns>True if no error occurred, false otherwise.</returns>
538 /// <since_tizen> 3 </since_tizen>
539 public bool SetAuxiliaryHintValue(uint id, string value)
541 bool ret = Interop.Window.SetAuxiliaryHintValue(swigCPtr, id, value);
542 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
547 /// Gets a value of the auxiliary hint.
549 /// <param name="id">The auxiliary hint ID.</param>
550 /// <returns>The string value of the auxiliary hint ID, or an empty string if none exists.</returns>
551 /// <since_tizen> 3 </since_tizen>
552 public string GetAuxiliaryHintValue(uint id)
554 string ret = Interop.Window.GetAuxiliaryHintValue(swigCPtr, id);
555 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
560 /// Gets an ID of the auxiliary hint string.
562 /// <param name="hint">The auxiliary hint string.</param>
563 /// <returns>The ID of auxiliary hint string, or 0 on failure.</returns>
564 /// <since_tizen> 3 </since_tizen>
565 public uint GetAuxiliaryHintId(string hint)
567 uint ret = Interop.Window.GetAuxiliaryHintId(swigCPtr, hint);
568 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
573 /// Sets a region to accept input events.
575 /// <param name="inputRegion">The region to accept input events.</param>
576 /// <since_tizen> 3 </since_tizen>
577 public void SetInputRegion(Rectangle inputRegion)
579 Interop.Window.SetInputRegion(swigCPtr, Rectangle.getCPtr(inputRegion));
580 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
584 /// Sets a priority level for the specified notification window.
586 /// <param name="level">The notification window level.</param>
587 /// <returns>True if no error occurred, false otherwise.</returns>
588 /// <since_tizen> 3 </since_tizen>
589 public bool SetNotificationLevel(NotificationLevel level)
591 bool ret = Interop.Window.SetNotificationLevel(swigCPtr, (int)level);
592 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
597 /// Gets a priority level for the specified notification window.
599 /// <returns>The notification window level.</returns>
600 /// <since_tizen> 3 </since_tizen>
601 public NotificationLevel GetNotificationLevel()
603 NotificationLevel ret = (NotificationLevel)Interop.Window.GetNotificationLevel(swigCPtr);
604 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
609 /// Sets a transparent window's visual state to opaque. <br />
610 /// If a visual state of a transparent window is opaque, <br />
611 /// then the window manager could handle it as an opaque window when calculating visibility.
613 /// <param name="opaque">Whether the window's visual state is opaque.</param>
614 /// <remarks>This will have no effect on an opaque window. <br />
615 /// It doesn't change transparent window to opaque window but lets the window manager know the visual state of the window.
617 /// <since_tizen> 3 </since_tizen>
618 public void SetOpaqueState(bool opaque)
620 Interop.Window.SetOpaqueState(swigCPtr, opaque);
621 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
625 /// Returns whether a transparent window's visual state is opaque or not.
627 /// <returns>True if the window's visual state is opaque, false otherwise.</returns>
628 /// <remarks> The return value has no meaning on an opaque window. </remarks>
629 /// <since_tizen> 3 </since_tizen>
630 public bool IsOpaqueState()
632 bool ret = Interop.Window.IsOpaqueState(swigCPtr);
633 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
638 /// Sets a window's screen off mode.
640 /// <param name="screenOffMode">The screen mode.</param>
641 /// <returns>True if no error occurred, false otherwise.</returns>
642 /// <since_tizen> 4 </since_tizen>
643 public bool SetScreenOffMode(ScreenOffMode screenOffMode)
645 bool ret = Interop.Window.SetScreenOffMode(swigCPtr, (int)screenOffMode);
646 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
651 /// Gets the screen mode of the window.
653 /// <returns>The screen off mode.</returns>
654 /// <since_tizen> 4 </since_tizen>
655 public ScreenOffMode GetScreenOffMode()
657 ScreenOffMode ret = (ScreenOffMode)Interop.Window.GetScreenOffMode(swigCPtr);
658 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
663 /// Sets preferred brightness of the window.
665 /// <param name="brightness">The preferred brightness (0 to 100).</param>
666 /// <returns>True if no error occurred, false otherwise.</returns>
667 /// <since_tizen> 3 </since_tizen>
668 public bool SetBrightness(int brightness)
670 bool ret = Interop.Window.SetBrightness(swigCPtr, brightness);
671 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
676 /// Gets the preferred brightness of the window.
678 /// <returns>The preferred brightness.</returns>
679 /// <since_tizen> 3 </since_tizen>
680 public int GetBrightness()
682 int ret = Interop.Window.GetBrightness(swigCPtr);
683 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
688 /// Sets the window name and the class string.
690 /// <param name="name">The name of the window.</param>
691 /// <param name="klass">The class of the window.</param>
692 /// <since_tizen> 4 </since_tizen>
693 public void SetClass(string name, string klass)
695 Interop.Window.Window_SetClass(swigCPtr, name, klass);
696 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
700 /// Raises the window to the top of the window stack.
702 /// <since_tizen> 3 </since_tizen>
705 Interop.Window.Window_Raise(swigCPtr);
706 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
710 /// Lowers the window to the bottom of the window stack.
712 /// <since_tizen> 3 </since_tizen>
715 Interop.Window.Window_Lower(swigCPtr);
716 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
720 /// Activates the window to the top of the window stack even it is iconified.
722 /// <since_tizen> 3 </since_tizen>
723 public void Activate()
725 Interop.Window.Window_Activate(swigCPtr);
726 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
730 /// Gets the default ( root ) layer.
732 /// <returns>The root layer.</returns>
733 /// <since_tizen> 3 </since_tizen>
734 public Layer GetDefaultLayer()
736 return this.GetRootLayer();
740 /// Add a child view to window.
742 /// <param name="view">the child should be added to the window.</param>
743 /// <since_tizen> 3 </since_tizen>
744 public void Add(View view)
746 Interop.Actor.Actor_Add(Layer.getCPtr(GetRootLayer()), View.getCPtr(view));
747 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
748 this.GetRootLayer().AddViewToLayerList(view); // Maintain the children list in the Layer
749 view.InternalParent = this.GetRootLayer();
753 /// Remove a child view from window.
755 /// <param name="view">the child to be removed.</param>
756 /// <since_tizen> 3 </since_tizen>
757 public void Remove(View view)
759 Interop.Actor.Actor_Remove(Layer.getCPtr(GetRootLayer()), View.getCPtr(view));
760 this.GetRootLayer().RemoveViewFromLayerList(view); // Maintain the children list in the Layer
761 view.InternalParent = null;
765 /// Retrieves the layer at a specified depth.
767 /// <param name="depth">The layer's depth index.</param>
768 /// <returns>The layer found at the given depth.</returns>
769 /// <since_tizen> 3 </since_tizen>
770 public Layer GetLayer(uint depth)
772 if (depth < LayersChildren?.Count)
774 Layer ret = LayersChildren?[Convert.ToInt32(depth)];
784 /// Destroy the window immediately.
786 [EditorBrowsable(EditorBrowsableState.Never)]
787 public void Destroy()
793 /// Keep rendering for at least the given amount of time.
795 /// <param name="durationSeconds">Time to keep rendering, 0 means render at least one more frame.</param>
796 /// <since_tizen> 3 </since_tizen>
797 public void KeepRendering(float durationSeconds)
799 Interop.Stage.Stage_KeepRendering(stageCPtr, durationSeconds);
800 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
804 /// Grabs the key specified by a key for a window only when a window is the topmost window.<br />
805 /// This function can be used for following example scenarios: <br />
806 /// - Mobile - Using volume up or down as zoom up or down in camera apps.<br />
808 /// <param name="DaliKey">The key code to grab.</param>
809 /// <returns>True if the grab succeeds.</returns>
810 /// <since_tizen> 3 </since_tizen>
811 public bool GrabKeyTopmost(int DaliKey)
813 bool ret = Interop.Window.GrabKeyTopmost(HandleRef.ToIntPtr(this.swigCPtr), DaliKey);
814 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
819 /// Ungrabs the key specified by a key for the window.<br />
820 /// 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 />
822 /// <param name="DaliKey">The key code to ungrab.</param>
823 /// <returns>True if the ungrab succeeds.</returns>
824 /// <since_tizen> 3 </since_tizen>
825 public bool UngrabKeyTopmost(int DaliKey)
827 bool ret = Interop.Window.UngrabKeyTopmost(HandleRef.ToIntPtr(this.swigCPtr), DaliKey);
828 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
833 /// Grabs the key specified by a key for a window in a GrabMode. <br />
834 /// Details: This function can be used for following example scenarios: <br />
835 /// - TV - A user might want to change the volume or channel of the background TV contents while focusing on the foregrund app. <br />
836 /// - Mobile - When a user presses the Home key, the homescreen appears regardless of the current foreground app. <br />
837 /// - Mobile - Using the volume up or down as zoom up or down in camera apps. <br />
839 /// <param name="DaliKey">The key code to grab.</param>
840 /// <param name="GrabMode">The grab mode for the key.</param>
841 /// <returns>True if the grab succeeds.</returns>
842 /// <since_tizen> 3 </since_tizen>
843 public bool GrabKey(int DaliKey, KeyGrabMode GrabMode)
845 bool ret = Interop.Window.GrabKey(HandleRef.ToIntPtr(this.swigCPtr), DaliKey, (int)GrabMode);
846 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
851 /// Ungrabs the key specified by a key for a window.<br />
852 /// 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 />
854 /// <param name="DaliKey">The key code to ungrab.</param>
855 /// <returns>True if the ungrab succeeds.</returns>
856 /// <since_tizen> 3 </since_tizen>
857 public bool UngrabKey(int DaliKey)
859 bool ret = Interop.Window.UngrabKey(HandleRef.ToIntPtr(this.swigCPtr), DaliKey);
860 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
865 /// Sets the keyboard repeat information.
867 /// <param name="rate">The key repeat rate value in seconds.</param>
868 /// <param name="delay">The key repeat delay value in seconds.</param>
869 /// <returns>True if setting the keyboard repeat succeeds.</returns>
870 /// <since_tizen> 5 </since_tizen>
871 public bool SetKeyboardRepeatInfo(float rate, float delay)
873 bool ret = Interop.Window.SetKeyboardRepeatInfo(rate, delay);
874 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
879 /// Gets the keyboard repeat information.
881 /// <param name="rate">The key repeat rate value in seconds.</param>
882 /// <param name="delay">The key repeat delay value in seconds.</param>
883 /// <returns>True if setting the keyboard repeat succeeds.</returns>
884 /// <since_tizen> 5 </since_tizen>
885 public bool GetKeyboardRepeatInfo(out float rate, out float delay)
887 bool ret = Interop.Window.GetKeyboardRepeatInfo(out rate, out delay);
888 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
893 /// Adds a layer to the stage.
895 /// <param name="layer">Layer to add.</param>
896 /// <since_tizen> 3 </since_tizen>
897 public void AddLayer(Layer layer)
899 Interop.Window.Add(swigCPtr, Layer.getCPtr(layer));
900 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
902 LayersChildren?.Add(layer);
903 layer.SetWindow(this);
907 /// Removes a layer from the stage.
909 /// <param name="layer">Layer to remove.</param>
910 /// <since_tizen> 3 </since_tizen>
911 public void RemoveLayer(Layer layer)
913 Interop.Window.Remove(swigCPtr, Layer.getCPtr(layer));
914 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
916 LayersChildren?.Remove(layer);
917 layer.SetWindow(null);
921 /// Feeds a key event into the window.
923 /// <param name="keyEvent">The key event to feed.</param>
924 /// <since_tizen> 5 </since_tizen>
925 public void FeedKey(Key keyEvent)
927 Interop.Window.Window_FeedKeyEvent(Key.getCPtr(keyEvent));
928 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
932 /// Allows at least one more render, even when paused.
933 /// The window should be shown, not minimised.
935 /// <since_tizen> 4 </since_tizen>
936 public void RenderOnce()
938 Interop.Window.Window_RenderOnce(swigCPtr);
939 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
943 /// Sets whether the window is transparent or not.
945 /// <param name="transparent">Whether the window is transparent or not.</param>
946 /// <since_tizen> 5 </since_tizen>
947 public void SetTransparency(bool transparent)
949 Interop.Window.SetTransparency(swigCPtr, transparent);
950 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
952 // Setting transparency of the window should request a relayout of the tree in the case the window changes from fully transparent.
956 /// Sets parent window of the window.
957 /// After setting that, these windows do together when raise-up, lower and iconified/deiconified.
958 /// Initially, the window is located on top of the parent. The window can go below parent by calling Lower().
959 /// If parent's window stack is changed by calling Raise() or Lower(), child windows are located on top of the parent again.
961 /// <param name="parent">The parent window.</param>
962 /// <since_tizen> 6 </since_tizen>
963 public void SetParent(Window parent)
965 Interop.Window.SetParent(swigCPtr, Window.getCPtr(parent));
966 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
970 /// Unsets parent window of the window.
971 /// After unsetting, the window is disconnected his parent window.
973 /// <since_tizen> 6 </since_tizen>
974 public void Unparent()
976 Interop.Window.Unparent(swigCPtr);
977 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
981 /// Gets parent window of the window.
983 /// <returns>The parent window of the window.</returns>
984 /// <since_tizen> 6 </since_tizen>
985 public Window GetParent()
987 Window ret = Registry.GetManagedBaseHandleFromNativePtr(Interop.Window.GetParent(swigCPtr)) as Window;
988 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
992 internal static global::System.Runtime.InteropServices.HandleRef getCPtr(Window obj)
994 return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
997 internal static Window GetCurrent()
999 Window ret = new Window(Interop.Stage.Stage_GetCurrent(), true);
1000 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1004 internal static bool IsInstalled()
1006 bool ret = Interop.Stage.Stage_IsInstalled();
1007 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1011 internal void ShowIndicator(Window.IndicatorVisibleMode visibleMode)
1013 Interop.WindowInternal.Window_ShowIndicator(swigCPtr, (int)visibleMode);
1014 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1017 internal void SetIndicatorBackgroundOpacity(Window.IndicatorBackgroundOpacity opacity)
1019 Interop.WindowInternal.Window_SetIndicatorBgOpacity(swigCPtr, (int)opacity);
1020 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1023 internal void RotateIndicator(Window.WindowOrientation orientation)
1025 Interop.WindowInternal.Window_RotateIndicator(swigCPtr, (int)orientation);
1026 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1030 /// Adds an orientation to the list of available orientations.
1032 /// <param name="orientation">The available orientation to add</param>
1033 /// <since_tizen> 6 </since_tizen>
1034 public void AddAvailableOrientation(Window.WindowOrientation orientation)
1036 Interop.Window.Window_AddAvailableOrientation(swigCPtr, (int)orientation);
1037 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1041 /// Removes an orientation from the list of available orientations.
1043 /// <param name="orientation">The available orientation to remove.</param>
1044 /// <since_tizen> 6 </since_tizen>
1045 public void RemoveAvailableOrientation(Window.WindowOrientation orientation)
1047 Interop.Window.Window_RemoveAvailableOrientation(swigCPtr, (int)orientation);
1048 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1052 /// Sets a preferred orientation.
1054 /// <param name="orientation">The preferred orientation.</param>
1055 /// <since_tizen> 6 </since_tizen>
1056 public void SetPreferredOrientation(Window.WindowOrientation orientation)
1058 Interop.Window.Window_SetPreferredOrientation(swigCPtr, (int)orientation);
1059 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1063 /// Gets the preferred orientation.
1065 /// <since_tizen> 6 </since_tizen>
1066 /// <returns>The preferred orientation if previously set, or none.</returns>
1067 public Window.WindowOrientation GetPreferredOrientation()
1069 Window.WindowOrientation ret = (Window.WindowOrientation)Interop.Window.Window_GetPreferredOrientation(swigCPtr);
1070 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1074 internal Any GetNativeHandle()
1076 Any ret = new Any(Interop.WindowInternal.Window_GetNativeHandle(swigCPtr), true);
1077 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1081 internal void Add(Layer layer)
1083 Interop.Window.Add(swigCPtr, Layer.getCPtr(layer));
1084 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1086 LayersChildren?.Add(layer);
1087 layer.SetWindow(this);
1090 internal void Remove(Layer layer)
1092 Interop.Window.Remove(swigCPtr, Layer.getCPtr(layer));
1093 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1095 LayersChildren?.Remove(layer);
1096 layer.SetWindow(null);
1099 internal Vector2 GetSize()
1101 var val = new Uint16Pair(Interop.Window.GetSize(swigCPtr), false);
1102 Vector2 ret = new Vector2(val.GetWidth(), val.GetHeight());
1103 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1107 internal RenderTaskList GetRenderTaskList()
1109 RenderTaskList ret = new RenderTaskList(Interop.Stage.Stage_GetRenderTaskList(stageCPtr), true);
1110 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1115 /// Queries the number of on-window layers.
1117 /// <returns>The number of layers.</returns>
1118 /// <remarks>Note that a default layer is always provided (count >= 1).</remarks>
1119 internal uint GetLayerCount()
1121 if (LayersChildren == null || LayersChildren.Count < 0)
1124 return (uint) LayersChildren.Count;
1127 internal Layer GetRootLayer()
1129 // Window.IsInstalled() is actually true only when called from event thread and
1130 // Core has been initialized, not when Stage is ready.
1131 if (_rootLayer == null && Window.IsInstalled())
1133 _rootLayer = new Layer(Interop.Window.GetRootLayer(swigCPtr), true);
1134 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1135 LayersChildren?.Add(_rootLayer);
1136 _rootLayer.SetWindow(this);
1141 internal void SetBackgroundColor(Vector4 color)
1143 Interop.Window.SetBackgroundColor(swigCPtr, Vector4.getCPtr(color));
1144 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1147 internal Vector4 GetBackgroundColor()
1149 Vector4 ret = new Vector4(Interop.Window.GetBackgroundColor(swigCPtr), true);
1150 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1154 internal Vector2 GetDpi()
1156 Vector2 ret = new Vector2(Interop.Stage.Stage_GetDpi(stageCPtr), true);
1157 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1161 internal ObjectRegistry GetObjectRegistry()
1163 ObjectRegistry ret = new ObjectRegistry(Interop.Stage.Stage_GetObjectRegistry(stageCPtr), true);
1164 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1168 internal void SetRenderingBehavior(RenderingBehaviorType renderingBehavior)
1170 Interop.Stage.Stage_SetRenderingBehavior(stageCPtr, (int)renderingBehavior);
1171 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1174 internal RenderingBehaviorType GetRenderingBehavior()
1176 RenderingBehaviorType ret = (RenderingBehaviorType)Interop.Stage.Stage_GetRenderingBehavior(stageCPtr);
1177 if (NDalicPINVOKE.SWIGPendingException.Pending)
1178 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1182 internal void SetWindowSize(Size2D size)
1184 var val = new Uint16Pair((uint)size.Width, (uint)size.Height);
1185 Interop.Window.SetSize(swigCPtr, Uint16Pair.getCPtr(val));
1187 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1189 // Resetting Window size should request a relayout of the tree.
1192 internal Size2D GetWindowSize()
1194 var val = new Uint16Pair(Interop.Window.GetSize(swigCPtr), false);
1195 Size2D ret = new Size2D(val.GetWidth(), val.GetHeight());
1197 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1201 internal void SetPosition(Position2D position)
1203 var val = new Uint16Pair((uint)position.X, (uint)position.Y);
1204 Interop.Window.SetPosition(swigCPtr, Uint16Pair.getCPtr(val));
1206 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1207 // Setting Position of the window should request a relayout of the tree.
1210 internal Position2D GetPosition()
1212 var val = new Uint16Pair(Interop.Window.GetPosition(swigCPtr), true);
1213 Position2D ret = new Position2D(val.GetX(), val.GetY());
1215 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1219 internal void SetPositionSize(Rectangle positionSize)
1221 Interop.Window.Window_SetPositionSize(swigCPtr, Rectangle.getCPtr(positionSize));
1223 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1225 // Setting Position of the window should request a relayout of the tree.
1229 /// Dispose for Window
1231 [EditorBrowsable(EditorBrowsableState.Never)]
1232 protected override void Dispose(DisposeTypes type)
1239 if (type == DisposeTypes.Explicit)
1242 //Release your own managed resources here.
1243 //You should release all of your own disposable objects here.
1245 _rootLayer.Dispose();
1246 localController.Dispose();
1248 foreach(var layer in _childLayers)
1252 _childLayers.Clear();
1255 this.DisconnectNativeSignals();
1257 //Release your own unmanaged resources here.
1258 //You should not access any managed member here except static instance.
1259 //because the execution order of Finalizes is non-deterministic.
1261 if (swigCPtr.Handle != global::System.IntPtr.Zero)
1265 swigCMemOwn = false;
1266 Interop.Window.delete_Window(swigCPtr);
1268 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);