4 * Copyright(c) 2019 Samsung Electronics Co., Ltd.
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
20 using System.Runtime.InteropServices;
21 using Tizen.NUI.BaseComponents;
22 using System.ComponentModel;
23 using System.Collections.Generic;
28 /// The window class is used internally for drawing.<br />
29 /// The window has an orientation and indicator properties.<br />
31 /// <since_tizen> 3 </since_tizen>
32 public class Window : BaseHandle
34 private global::System.Runtime.InteropServices.HandleRef swigCPtr;
35 private global::System.Runtime.InteropServices.HandleRef stageCPtr;
36 private Layer _rootLayer;
37 private string _windowTitle;
38 private List<Layer> _childLayers = new List<Layer>();
39 private WindowFocusChangedEventCallbackType _windowFocusChangedEventCallback;
40 private RootLayerTouchDataCallbackType _rootLayerTouchDataCallback;
41 private WheelEventCallbackType _wheelEventCallback;
42 private EventCallbackDelegateType1 _stageKeyCallbackDelegate;
43 private EventCallbackDelegateType0 _stageEventProcessingFinishedEventCallbackDelegate;
44 private EventHandler _stageContextLostEventHandler;
45 private EventCallbackDelegateType0 _stageContextLostEventCallbackDelegate;
46 private EventHandler _stageContextRegainedEventHandler;
47 private EventCallbackDelegateType0 _stageContextRegainedEventCallbackDelegate;
48 private EventHandler _stageSceneCreatedEventHandler;
49 private EventCallbackDelegateType0 _stageSceneCreatedEventCallbackDelegate;
50 private WindowResizedEventCallbackType _windowResizedEventCallback;
51 private WindowFocusChangedEventCallbackType _windowFocusChangedEventCallback2;
53 private static readonly Window instance = Application.Instance?.GetWindow();
55 private LayoutController localController;
57 internal Window(global::System.IntPtr cPtr, bool cMemoryOwn) : base(Interop.Window.Window_SWIGUpcast(cPtr), cMemoryOwn)
59 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
60 if (Interop.Stage.Stage_IsInstalled())
62 stageCPtr = new global::System.Runtime.InteropServices.HandleRef(this, Interop.Stage.Stage_GetCurrent());
64 localController = new LayoutController(this);
65 NUILog.Debug("layoutController id:" + localController.GetId() );
70 /// Creates a new Window.<br />
71 /// This creates an extra window in addition to the default main window<br />
73 /// <param name="windowPosition">The position and size of the Window.</param>
74 /// <param name="isTranslucent">Whether Window is translucent.</param>
75 /// <returns>A new Window.</returns>
76 /// <since_tizen> 6 </since_tizen>
77 public Window(Rectangle windowPosition = null , bool isTranslucent = false) : this(Interop.Window.Window_New__SWIG_0(Rectangle.getCPtr(windowPosition), "", isTranslucent), true)
79 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
83 /// Creates a new Window.<br />
84 /// This creates an extra window in addition to the default main window<br />
86 /// <param name="name">The name for extra window. </param>
87 /// <param name="windowPosition">The position and size of the Window.</param>
88 /// <param name="isTranslucent">Whether Window is translucent.</param>
89 /// <returns>A new Window.</returns>
90 /// <since_tizen> 6 </since_tizen>
91 public Window(string name, Rectangle windowPosition = null, bool isTranslucent = false) : this(Interop.Window.Window_New__SWIG_0(Rectangle.getCPtr(windowPosition), name, isTranslucent), true)
93 this._windowTitle = name;
94 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
97 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
98 private delegate void WindowFocusChangedEventCallbackType(bool focusGained);
99 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
100 private delegate bool RootLayerTouchDataCallbackType(IntPtr view, IntPtr touchData);
101 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
102 private delegate bool WheelEventCallbackType(IntPtr view, IntPtr wheelEvent);
103 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
104 private delegate void WindowResizedEventCallbackType(IntPtr windowSize);
105 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
106 private delegate void WindowFocusChangedEventCallbackType2(bool focusGained);
109 /// FocusChanged event.
111 /// <since_tizen> 3 </since_tizen>
112 public event EventHandler<FocusChangedEventArgs> FocusChanged
116 if (_windowFocusChangedEventHandler == null)
118 _windowFocusChangedEventCallback = OnWindowFocusedChanged;
119 WindowFocusChangedSignal().Connect(_windowFocusChangedEventCallback);
122 _windowFocusChangedEventHandler += value;
126 _windowFocusChangedEventHandler -= value;
128 if (_windowFocusChangedEventHandler == null && WindowFocusChangedSignal().Empty() == false && _windowFocusChangedEventCallback != null)
130 WindowFocusChangedSignal().Disconnect(_windowFocusChangedEventCallback);
136 /// This event is emitted when the screen is touched and when the touch ends.<br />
137 /// If there are multiple touch points, then this will be emitted when the first touch occurs and
138 /// then when the last finger is lifted.<br />
139 /// An interrupted event will also be emitted (if it occurs).<br />
141 /// <since_tizen> 3 </since_tizen>
142 public event EventHandler<TouchEventArgs> TouchEvent
146 if (_rootLayerTouchDataEventHandler == null)
148 _rootLayerTouchDataCallback = OnWindowTouch;
149 this.TouchDataSignal().Connect(_rootLayerTouchDataCallback);
151 _rootLayerTouchDataEventHandler += value;
155 _rootLayerTouchDataEventHandler -= value;
156 if (_rootLayerTouchDataEventHandler == null && TouchSignal().Empty() == false)
158 this.TouchDataSignal().Disconnect(_rootLayerTouchDataCallback);
164 /// This event is emitted when the wheel event is received.
166 /// <since_tizen> 3 </since_tizen>
167 public event EventHandler<WheelEventArgs> WheelEvent
171 if (_stageWheelHandler == null)
173 _wheelEventCallback = OnStageWheel;
174 this.StageWheelEventSignal().Connect(_wheelEventCallback);
176 _stageWheelHandler += value;
180 _stageWheelHandler -= value;
181 if (_stageWheelHandler == null && StageWheelEventSignal().Empty() == false)
183 this.StageWheelEventSignal().Disconnect(_wheelEventCallback);
189 /// This event is emitted when the key event is received.
191 /// <since_tizen> 3 </since_tizen>
192 public event EventHandler<KeyEventArgs> KeyEvent
196 if (_stageKeyHandler == null)
198 _stageKeyCallbackDelegate = OnStageKey;
199 KeyEventSignal().Connect(_stageKeyCallbackDelegate);
201 _stageKeyHandler += value;
205 _stageKeyHandler -= value;
206 if (_stageKeyHandler == null && KeyEventSignal().Empty() == false)
208 KeyEventSignal().Disconnect(_stageKeyCallbackDelegate);
214 /// This event is emitted when the window resized.
216 /// <since_tizen> 3 </since_tizen>
217 public event EventHandler<ResizedEventArgs> Resized
221 if (_windowResizedEventHandler == null)
223 _windowResizedEventCallback = OnResized;
224 ResizedSignal().Connect(_windowResizedEventCallback);
227 _windowResizedEventHandler += value;
231 _windowResizedEventHandler -= value;
233 if (_windowResizedEventHandler == null && ResizedSignal().Empty() == false && _windowResizedEventCallback != null)
235 ResizedSignal().Disconnect(_windowResizedEventCallback);
241 /// Please do not use! this will be deprecated. Please use 'FocusChanged' event instead.
243 /// <since_tizen> 3 </since_tizen>
244 /// Please do not use! this will be deprecated!
245 /// Instead please use FocusChanged.
246 [Obsolete("Please do not use! This will be deprecated! Please use FocusChanged instead! " +
248 "Window.Instance.FocusChanged = OnFocusChanged; " +
249 "private void OnFocusChanged(object source, Window.FocusChangedEventArgs args) {...}")]
250 [EditorBrowsable(EditorBrowsableState.Never)]
251 public event EventHandler<FocusChangedEventArgs> WindowFocusChanged
255 if (_windowFocusChangedEventHandler2 == null)
257 _windowFocusChangedEventCallback2 = OnWindowFocusedChanged2;
258 WindowFocusChangedSignal().Connect(_windowFocusChangedEventCallback2);
261 _windowFocusChangedEventHandler2 += value;
265 _windowFocusChangedEventHandler2 -= value;
267 if (_windowFocusChangedEventHandler2 == null && WindowFocusChangedSignal().Empty() == false && _windowFocusChangedEventCallback2 != null)
269 WindowFocusChangedSignal().Disconnect(_windowFocusChangedEventCallback2);
275 /// ViewAdded will be triggered when the view added on Window
277 /// <since_tizen> 6 </since_tizen>
278 /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
279 [EditorBrowsable(EditorBrowsableState.Never)]
280 public event EventHandler ViewAdded;
282 internal void SendViewAdded(View view)
284 ViewAdded?.Invoke(view, EventArgs.Empty);
287 internal event EventHandler EventProcessingFinished
291 if (_stageEventProcessingFinishedEventHandler == null)
293 _stageEventProcessingFinishedEventCallbackDelegate = OnEventProcessingFinished;
294 EventProcessingFinishedSignal().Connect(_stageEventProcessingFinishedEventCallbackDelegate);
296 _stageEventProcessingFinishedEventHandler += value;
301 _stageEventProcessingFinishedEventHandler -= value;
302 if (_stageEventProcessingFinishedEventHandler == null && EventProcessingFinishedSignal().Empty() == false)
304 EventProcessingFinishedSignal().Disconnect(_stageEventProcessingFinishedEventCallbackDelegate);
309 internal event EventHandler ContextLost
313 if (_stageContextLostEventHandler == null)
315 _stageContextLostEventCallbackDelegate = OnContextLost;
316 ContextLostSignal().Connect(_stageContextLostEventCallbackDelegate);
318 _stageContextLostEventHandler += value;
322 _stageContextLostEventHandler -= value;
323 if (_stageContextLostEventHandler == null && ContextLostSignal().Empty() == false)
325 ContextLostSignal().Disconnect(_stageContextLostEventCallbackDelegate);
330 internal event EventHandler ContextRegained
334 if (_stageContextRegainedEventHandler == null)
336 _stageContextRegainedEventCallbackDelegate = OnContextRegained;
337 ContextRegainedSignal().Connect(_stageContextRegainedEventCallbackDelegate);
339 _stageContextRegainedEventHandler += value;
343 _stageContextRegainedEventHandler -= value;
344 if (_stageContextRegainedEventHandler == null && ContextRegainedSignal().Empty() == false)
346 this.ContextRegainedSignal().Disconnect(_stageContextRegainedEventCallbackDelegate);
351 internal event EventHandler SceneCreated
355 if (_stageSceneCreatedEventHandler == null)
357 _stageSceneCreatedEventCallbackDelegate = OnSceneCreated;
358 SceneCreatedSignal().Connect(_stageSceneCreatedEventCallbackDelegate);
360 _stageSceneCreatedEventHandler += value;
364 _stageSceneCreatedEventHandler -= value;
365 if (_stageSceneCreatedEventHandler == null && SceneCreatedSignal().Empty() == false)
367 SceneCreatedSignal().Disconnect(_stageSceneCreatedEventCallbackDelegate);
372 private event EventHandler<FocusChangedEventArgs> _windowFocusChangedEventHandler;
373 private event EventHandler<TouchEventArgs> _rootLayerTouchDataEventHandler;
374 private event EventHandler<WheelEventArgs> _stageWheelHandler;
375 private event EventHandler<KeyEventArgs> _stageKeyHandler;
376 private event EventHandler _stageEventProcessingFinishedEventHandler;
377 private event EventHandler<ResizedEventArgs> _windowResizedEventHandler;
378 private event EventHandler<FocusChangedEventArgs> _windowFocusChangedEventHandler2;
381 /// Enumeration for orientation of the window is the way in which a rectangular page is oriented for normal viewing.
383 /// <since_tizen> 3 </since_tizen>
384 public enum WindowOrientation
387 /// Portrait orientation. The height of the display area is greater than the width.
389 /// <since_tizen> 3 </since_tizen>
392 /// Landscape orientation. A wide view area is needed.
394 /// <since_tizen> 3 </since_tizen>
397 /// Portrait inverse orientation.
399 /// <since_tizen> 3 </since_tizen>
400 PortraitInverse = 180,
402 /// Landscape inverse orientation.
404 /// <since_tizen> 3 </since_tizen>
405 LandscapeInverse = 270
409 /// Enumeration for the key grab mode for platform-level APIs.
411 /// <since_tizen> 3 </since_tizen>
412 public enum KeyGrabMode
415 /// Grabs a key only when on the top of the grabbing-window stack mode.
419 /// Grabs a key together with the other client window(s) mode.
423 /// 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.
427 /// Grabs a key exclusively regardless of the grabbing-window's position on the window stack mode.
433 /// Enumeration for opacity of the indicator.
435 internal enum IndicatorBackgroundOpacity
443 /// Enumeration for visible mode of the indicator.
445 internal enum IndicatorVisibleMode
453 /// The stage instance property (read-only).<br />
454 /// Gets the current window.<br />
456 /// <since_tizen> 3 </since_tizen>
457 public static Window Instance
466 /// Gets or sets a window type.
468 /// <since_tizen> 3 </since_tizen>
469 public WindowType Type
473 WindowType ret = (WindowType)Interop.Window.GetType(swigCPtr);
474 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
479 Interop.Window.SetType(swigCPtr, (int)value);
480 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
485 /// Gets/Sets a window title.
487 /// <since_tizen> 4 </since_tizen>
496 _windowTitle = value;
497 SetClass(_windowTitle, "");
502 /// The rendering behavior of a Window.
504 /// <since_tizen> 5 </since_tizen>
505 public RenderingBehaviorType RenderingBehavior
509 return GetRenderingBehavior();
513 SetRenderingBehavior(value);
518 /// The window size property (read-only).
520 /// <since_tizen> 3 </since_tizen>
525 Size2D ret = GetSize();
531 /// The background color property.
533 /// <since_tizen> 3 </since_tizen>
534 public Color BackgroundColor
538 SetBackgroundColor(value);
542 Color ret = GetBackgroundColor();
548 /// The DPI property (read-only).<br />
549 /// Retrieves the DPI of the display device to which the Window is connected.<br />
551 /// <since_tizen> 3 </since_tizen>
561 /// The layer count property (read-only).<br />
562 /// Queries the number of on-Window layers.<br />
564 /// <since_tizen> 3 </since_tizen>
565 public uint LayerCount
569 return GetLayerCount();
574 /// Gets or sets a size of the window.
576 /// <since_tizen> 4 </since_tizen>
577 public Size2D WindowSize
581 return GetWindowSize();
585 SetWindowSize(value);
590 /// Gets or sets a position of the window.
592 /// <since_tizen> 4 </since_tizen>
593 public Position2D WindowPosition
597 return GetPosition();
604 internal static Vector4 DEFAULT_BACKGROUND_COLOR
608 global::System.IntPtr cPtr = Interop.Stage.Stage_DEFAULT_BACKGROUND_COLOR_get();
609 Vector4 ret = (cPtr == global::System.IntPtr.Zero) ? null : new Vector4(cPtr, false);
610 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
615 internal static Vector4 DEBUG_BACKGROUND_COLOR
619 global::System.IntPtr cPtr = Interop.Stage.Stage_DEBUG_BACKGROUND_COLOR_get();
620 Vector4 ret = (cPtr == global::System.IntPtr.Zero) ? null : new Vector4(cPtr, false);
621 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
626 internal List<Layer> LayersChildren
635 /// Get the LayoutController for this Window.
637 internal LayoutController LayoutController
641 return localController;
646 /// Feed a key-event into the window.
648 /// <param name="keyEvent">The key event to feed.</param>
649 /// <since_tizen> 4 </since_tizen>
650 [Obsolete("Please do not use! This will be deprecated! Please use FeedKey(Key keyEvent) instead!")]
651 public static void FeedKeyEvent(Key keyEvent)
653 Interop.Window.Window_FeedKeyEvent(Key.getCPtr(keyEvent));
654 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
658 /// Sets whether the window accepts a focus or not.
660 /// <param name="accept">If a focus is accepted or not. The default is true.</param>
661 /// <since_tizen> 3 </since_tizen>
662 public void SetAcceptFocus(bool accept)
664 Interop.Window.SetAcceptFocus(swigCPtr, accept);
665 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
669 /// Returns whether the window accepts a focus or not.
671 /// <returns>True if the window accepts a focus, false otherwise.</returns>
672 /// <since_tizen> 3 </since_tizen>
673 public bool IsFocusAcceptable()
675 bool ret = Interop.Window.IsFocusAcceptable(swigCPtr);
676 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
682 /// Shows the window if it is hidden.
684 /// <since_tizen> 3 </since_tizen>
687 Interop.Window.Show(swigCPtr);
688 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
692 /// Hides the window if it is showing.
694 /// <since_tizen> 3 </since_tizen>
697 Interop.Window.Hide(swigCPtr);
698 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
702 /// Retrieves whether the window is visible or not.
704 /// <returns>True if the window is visible.</returns>
705 /// <since_tizen> 3 </since_tizen>
706 public bool IsVisible()
708 bool temp = Interop.Window.IsVisible(swigCPtr);
709 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
714 /// Gets the count of supported auxiliary hints of the window.
716 /// <returns>The number of supported auxiliary hints.</returns>
717 /// <since_tizen> 3 </since_tizen>
718 public uint GetSupportedAuxiliaryHintCount()
720 uint ret = Interop.Window.GetSupportedAuxiliaryHintCount(swigCPtr);
721 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
726 /// Gets the supported auxiliary hint string of the window.
728 /// <param name="index">The index of the supported auxiliary hint lists.</param>
729 /// <returns>The auxiliary hint string of the index.</returns>
730 /// <since_tizen> 3 </since_tizen>
731 public string GetSupportedAuxiliaryHint(uint index)
733 string ret = Interop.Window.GetSupportedAuxiliaryHint(swigCPtr, index);
734 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
739 /// Creates an auxiliary hint of the window.
741 /// <param name="hint">The auxiliary hint string.</param>
742 /// <param name="value">The value string.</param>
743 /// <returns>The ID of created auxiliary hint, or 0 on failure.</returns>
744 /// <since_tizen> 3 </since_tizen>
745 public uint AddAuxiliaryHint(string hint, string value)
747 uint ret = Interop.Window.AddAuxiliaryHint(swigCPtr, hint, value);
748 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
753 /// Removes an auxiliary hint of the window.
755 /// <param name="id">The ID of the auxiliary hint.</param>
756 /// <returns>True if no error occurred, false otherwise.</returns>
757 /// <since_tizen> 3 </since_tizen>
758 public bool RemoveAuxiliaryHint(uint id)
760 bool ret = Interop.Window.RemoveAuxiliaryHint(swigCPtr, id);
761 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
766 /// Changes a value of the auxiliary hint.
768 /// <param name="id">The auxiliary hint ID.</param>
769 /// <param name="value">The value string to be set.</param>
770 /// <returns>True if no error occurred, false otherwise.</returns>
771 /// <since_tizen> 3 </since_tizen>
772 public bool SetAuxiliaryHintValue(uint id, string value)
774 bool ret = Interop.Window.SetAuxiliaryHintValue(swigCPtr, id, value);
775 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
780 /// Gets a value of the auxiliary hint.
782 /// <param name="id">The auxiliary hint ID.</param>
783 /// <returns>The string value of the auxiliary hint ID, or an empty string if none exists.</returns>
784 /// <since_tizen> 3 </since_tizen>
785 public string GetAuxiliaryHintValue(uint id)
787 string ret = Interop.Window.GetAuxiliaryHintValue(swigCPtr, id);
788 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
793 /// Gets an ID of the auxiliary hint string.
795 /// <param name="hint">The auxiliary hint string.</param>
796 /// <returns>The ID of auxiliary hint string, or 0 on failure.</returns>
797 /// <since_tizen> 3 </since_tizen>
798 public uint GetAuxiliaryHintId(string hint)
800 uint ret = Interop.Window.GetAuxiliaryHintId(swigCPtr, hint);
801 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
806 /// Sets a region to accept input events.
808 /// <param name="inputRegion">The region to accept input events.</param>
809 /// <since_tizen> 3 </since_tizen>
810 public void SetInputRegion(Rectangle inputRegion)
812 Interop.Window.SetInputRegion(swigCPtr, Rectangle.getCPtr(inputRegion));
813 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
817 /// Sets a priority level for the specified notification window.
819 /// <param name="level">The notification window level.</param>
820 /// <returns>True if no error occurred, false otherwise.</returns>
821 /// <since_tizen> 3 </since_tizen>
822 public bool SetNotificationLevel(NotificationLevel level)
824 bool ret = Interop.Window.SetNotificationLevel(swigCPtr, (int)level);
825 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
830 /// Gets a priority level for the specified notification window.
832 /// <returns>The notification window level.</returns>
833 /// <since_tizen> 3 </since_tizen>
834 public NotificationLevel GetNotificationLevel()
836 NotificationLevel ret = (NotificationLevel)Interop.Window.GetNotificationLevel(swigCPtr);
837 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
842 /// Sets a transparent window's visual state to opaque. <br />
843 /// If a visual state of a transparent window is opaque, <br />
844 /// then the window manager could handle it as an opaque window when calculating visibility.
846 /// <param name="opaque">Whether the window's visual state is opaque.</param>
847 /// <remarks>This will have no effect on an opaque window. <br />
848 /// It doesn't change transparent window to opaque window but lets the window manager know the visual state of the window.
850 /// <since_tizen> 3 </since_tizen>
851 public void SetOpaqueState(bool opaque)
853 Interop.Window.SetOpaqueState(swigCPtr, opaque);
854 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
858 /// Returns whether a transparent window's visual state is opaque or not.
860 /// <returns>True if the window's visual state is opaque, false otherwise.</returns>
861 /// <remarks> The return value has no meaning on an opaque window. </remarks>
862 /// <since_tizen> 3 </since_tizen>
863 public bool IsOpaqueState()
865 bool ret = Interop.Window.IsOpaqueState(swigCPtr);
866 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
871 /// Sets a window's screen off mode.
873 /// <param name="screenOffMode">The screen mode.</param>
874 /// <returns>True if no error occurred, false otherwise.</returns>
875 /// <since_tizen> 4 </since_tizen>
876 public bool SetScreenOffMode(ScreenOffMode screenOffMode)
878 bool ret = Interop.Window.SetScreenOffMode(swigCPtr, (int)screenOffMode);
879 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
884 /// Gets the screen mode of the window.
886 /// <returns>The screen off mode.</returns>
887 /// <since_tizen> 4 </since_tizen>
888 public ScreenOffMode GetScreenOffMode()
890 ScreenOffMode ret = (ScreenOffMode)Interop.Window.GetScreenOffMode(swigCPtr);
891 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
896 /// Sets preferred brightness of the window.
898 /// <param name="brightness">The preferred brightness (0 to 100).</param>
899 /// <returns>True if no error occurred, false otherwise.</returns>
900 /// <since_tizen> 3 </since_tizen>
901 public bool SetBrightness(int brightness)
903 bool ret = Interop.Window.SetBrightness(swigCPtr, brightness);
904 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
909 /// Gets the preferred brightness of the window.
911 /// <returns>The preferred brightness.</returns>
912 /// <since_tizen> 3 </since_tizen>
913 public int GetBrightness()
915 int ret = Interop.Window.GetBrightness(swigCPtr);
916 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
921 /// Sets the window name and the class string.
923 /// <param name="name">The name of the window.</param>
924 /// <param name="klass">The class of the window.</param>
925 /// <since_tizen> 4 </since_tizen>
926 public void SetClass(string name, string klass)
928 Interop.Window.Window_SetClass(swigCPtr, name, klass);
929 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
933 /// Raises the window to the top of the window stack.
935 /// <since_tizen> 3 </since_tizen>
938 Interop.Window.Window_Raise(swigCPtr);
939 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
943 /// Lowers the window to the bottom of the window stack.
945 /// <since_tizen> 3 </since_tizen>
948 Interop.Window.Window_Lower(swigCPtr);
949 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
953 /// Activates the window to the top of the window stack even it is iconified.
955 /// <since_tizen> 3 </since_tizen>
956 public void Activate()
958 Interop.Window.Window_Activate(swigCPtr);
959 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
963 /// Gets the default ( root ) layer.
965 /// <returns>The root layer.</returns>
966 /// <since_tizen> 3 </since_tizen>
967 public Layer GetDefaultLayer()
969 return this.GetRootLayer();
973 /// Add a child view to window.
975 /// <param name="view">the child should be added to the window.</param>
976 /// <since_tizen> 3 </since_tizen>
977 public void Add(View view)
979 Interop.Actor.Actor_Add(Layer.getCPtr(GetRootLayer()), View.getCPtr(view));
980 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
981 this.GetRootLayer().AddViewToLayerList(view); // Maintain the children list in the Layer
982 view.InternalParent = this.GetRootLayer();
986 /// Remove a child view from window.
988 /// <param name="view">the child to be removed.</param>
989 /// <since_tizen> 3 </since_tizen>
990 public void Remove(View view)
992 Interop.Actor.Actor_Remove(Layer.getCPtr(GetRootLayer()), View.getCPtr(view));
993 this.GetRootLayer().RemoveViewFromLayerList(view); // Maintain the children list in the Layer
994 view.InternalParent = null;
998 /// Retrieves the layer at a specified depth.
1000 /// <param name="depth">The layer's depth index.</param>
1001 /// <returns>The layer found at the given depth.</returns>
1002 /// <since_tizen> 3 </since_tizen>
1003 public Layer GetLayer(uint depth)
1005 if (depth < LayersChildren?.Count)
1007 Layer ret = LayersChildren?[Convert.ToInt32(depth)];
1017 /// Destroy the window immediately.
1019 [EditorBrowsable(EditorBrowsableState.Never)]
1020 public void Destroy()
1026 /// Keep rendering for at least the given amount of time.
1028 /// <param name="durationSeconds">Time to keep rendering, 0 means render at least one more frame.</param>
1029 /// <since_tizen> 3 </since_tizen>
1030 public void KeepRendering(float durationSeconds)
1032 Interop.Stage.Stage_KeepRendering(stageCPtr, durationSeconds);
1033 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1037 /// Grabs the key specified by a key for a window only when a window is the topmost window.<br />
1038 /// This function can be used for following example scenarios: <br />
1039 /// - Mobile - Using volume up or down as zoom up or down in camera apps.<br />
1041 /// <param name="DaliKey">The key code to grab.</param>
1042 /// <returns>True if the grab succeeds.</returns>
1043 /// <since_tizen> 3 </since_tizen>
1044 public bool GrabKeyTopmost(int DaliKey)
1046 bool ret = Interop.Window.GrabKeyTopmost(HandleRef.ToIntPtr(this.swigCPtr), DaliKey);
1047 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1052 /// Ungrabs the key specified by a key for the window.<br />
1053 /// 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 />
1055 /// <param name="DaliKey">The key code to ungrab.</param>
1056 /// <returns>True if the ungrab succeeds.</returns>
1057 /// <since_tizen> 3 </since_tizen>
1058 public bool UngrabKeyTopmost(int DaliKey)
1060 bool ret = Interop.Window.UngrabKeyTopmost(HandleRef.ToIntPtr(this.swigCPtr), DaliKey);
1061 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1066 /// Grabs the key specified by a key for a window in a GrabMode. <br />
1067 /// Details: This function can be used for following example scenarios: <br />
1068 /// - TV - A user might want to change the volume or channel of the background TV contents while focusing on the foregrund app. <br />
1069 /// - Mobile - When a user presses the Home key, the homescreen appears regardless of the current foreground app. <br />
1070 /// - Mobile - Using the volume up or down as zoom up or down in camera apps. <br />
1072 /// <param name="DaliKey">The key code to grab.</param>
1073 /// <param name="GrabMode">The grab mode for the key.</param>
1074 /// <returns>True if the grab succeeds.</returns>
1075 /// <since_tizen> 3 </since_tizen>
1076 public bool GrabKey(int DaliKey, KeyGrabMode GrabMode)
1078 bool ret = Interop.Window.GrabKey(HandleRef.ToIntPtr(this.swigCPtr), DaliKey, (int)GrabMode);
1079 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1084 /// Ungrabs the key specified by a key for a window.<br />
1085 /// 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 />
1087 /// <param name="DaliKey">The key code to ungrab.</param>
1088 /// <returns>True if the ungrab succeeds.</returns>
1089 /// <since_tizen> 3 </since_tizen>
1090 public bool UngrabKey(int DaliKey)
1092 bool ret = Interop.Window.UngrabKey(HandleRef.ToIntPtr(this.swigCPtr), DaliKey);
1093 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1098 /// Sets the keyboard repeat information.
1100 /// <param name="rate">The key repeat rate value in seconds.</param>
1101 /// <param name="delay">The key repeat delay value in seconds.</param>
1102 /// <returns>True if setting the keyboard repeat succeeds.</returns>
1103 /// <since_tizen> 5 </since_tizen>
1104 public bool SetKeyboardRepeatInfo(float rate, float delay)
1106 bool ret = Interop.Window.SetKeyboardRepeatInfo(rate, delay);
1107 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1112 /// Gets the keyboard repeat information.
1114 /// <param name="rate">The key repeat rate value in seconds.</param>
1115 /// <param name="delay">The key repeat delay value in seconds.</param>
1116 /// <returns>True if setting the keyboard repeat succeeds.</returns>
1117 /// <since_tizen> 5 </since_tizen>
1118 public bool GetKeyboardRepeatInfo(out float rate, out float delay)
1120 bool ret = Interop.Window.GetKeyboardRepeatInfo(out rate, out delay);
1121 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1126 /// Adds a layer to the stage.
1128 /// <param name="layer">Layer to add.</param>
1129 /// <since_tizen> 3 </since_tizen>
1130 public void AddLayer(Layer layer)
1132 Interop.Window.Add(swigCPtr, Layer.getCPtr(layer));
1133 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1135 LayersChildren?.Add(layer);
1136 layer.SetWindow(this);
1140 /// Removes a layer from the stage.
1142 /// <param name="layer">Layer to remove.</param>
1143 /// <since_tizen> 3 </since_tizen>
1144 public void RemoveLayer(Layer layer)
1146 Interop.Window.Remove(swigCPtr, Layer.getCPtr(layer));
1147 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1149 LayersChildren?.Remove(layer);
1150 layer.SetWindow(null);
1154 /// Feeds a key event into the window.
1156 /// <param name="keyEvent">The key event to feed.</param>
1157 /// <since_tizen> 5 </since_tizen>
1158 public void FeedKey(Key keyEvent)
1160 Interop.Window.Window_FeedKeyEvent(Key.getCPtr(keyEvent));
1161 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1165 /// Allows at least one more render, even when paused.
1166 /// The window should be shown, not minimised.
1168 /// <since_tizen> 4 </since_tizen>
1169 public void RenderOnce()
1171 Interop.Window.Window_RenderOnce(swigCPtr);
1172 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1175 internal static global::System.Runtime.InteropServices.HandleRef getCPtr(Window obj)
1177 return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
1180 internal static Window GetCurrent()
1182 Window ret = new Window(Interop.Stage.Stage_GetCurrent(), true);
1183 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1187 internal static bool IsInstalled()
1189 bool ret = Interop.Stage.Stage_IsInstalled();
1190 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1194 internal WindowFocusSignalType WindowFocusChangedSignal()
1196 WindowFocusSignalType ret = new WindowFocusSignalType(Interop.Window.FocusChangedSignal(swigCPtr), false);
1197 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1201 internal void ShowIndicator(Window.IndicatorVisibleMode visibleMode)
1203 Interop.WindowInternal.Window_ShowIndicator(swigCPtr, (int)visibleMode);
1204 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1207 internal void SetIndicatorBackgroundOpacity(Window.IndicatorBackgroundOpacity opacity)
1209 Interop.WindowInternal.Window_SetIndicatorBgOpacity(swigCPtr, (int)opacity);
1210 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1213 internal void RotateIndicator(Window.WindowOrientation orientation)
1215 Interop.WindowInternal.Window_RotateIndicator(swigCPtr, (int)orientation);
1216 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1220 /// Adds an orientation to the list of available orientations.
1222 /// <param name="orientation">The available orientation to add</param>
1223 /// <since_tizen> 6 </since_tizen>
1224 public void AddAvailableOrientation(Window.WindowOrientation orientation)
1226 Interop.Window.Window_AddAvailableOrientation(swigCPtr, (int)orientation);
1227 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1231 /// Removes an orientation from the list of available orientations.
1233 /// <param name="orientation">The available orientation to remove.</param>
1234 /// <since_tizen> 6 </since_tizen>
1235 public void RemoveAvailableOrientation(Window.WindowOrientation orientation)
1237 Interop.Window.Window_RemoveAvailableOrientation(swigCPtr, (int)orientation);
1238 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1242 /// Sets a preferred orientation.
1244 /// <param name="orientation">The preferred orientation.</param>
1245 /// <since_tizen> 6 </since_tizen>
1246 public void SetPreferredOrientation(Window.WindowOrientation orientation)
1248 Interop.Window.Window_SetPreferredOrientation(swigCPtr, (int)orientation);
1249 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1253 /// Gets the preferred orientation.
1255 /// <since_tizen> 6 </since_tizen>
1256 /// <returns>The preferred orientation if previously set, or none.</returns>
1257 public Window.WindowOrientation GetPreferredOrientation()
1259 Window.WindowOrientation ret = (Window.WindowOrientation)Interop.Window.Window_GetPreferredOrientation(swigCPtr);
1260 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1264 internal Any GetNativeHandle()
1266 Any ret = new Any(Interop.WindowInternal.Window_GetNativeHandle(swigCPtr), true);
1267 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1271 internal WindowFocusSignalType FocusChangedSignal()
1273 WindowFocusSignalType ret = new WindowFocusSignalType(Interop.Window.FocusChangedSignal(swigCPtr), false);
1274 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1278 internal void Add(Layer layer)
1280 Interop.Window.Add(swigCPtr, Layer.getCPtr(layer));
1281 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1283 LayersChildren?.Add(layer);
1284 layer.SetWindow(this);
1287 internal void Remove(Layer layer)
1289 Interop.Window.Remove(swigCPtr, Layer.getCPtr(layer));
1290 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1292 LayersChildren?.Remove(layer);
1293 layer.SetWindow(null);
1296 internal Vector2 GetSize()
1298 var val = new Uint16Pair(Interop.Window.GetSize(swigCPtr), false);
1299 Vector2 ret = new Vector2(val.GetWidth(), val.GetHeight());
1300 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1304 internal RenderTaskList GetRenderTaskList()
1306 RenderTaskList ret = new RenderTaskList(Interop.Stage.Stage_GetRenderTaskList(stageCPtr), true);
1307 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1312 /// Queries the number of on-window layers.
1314 /// <returns>The number of layers.</returns>
1315 /// <remarks>Note that a default layer is always provided (count >= 1).</remarks>
1316 internal uint GetLayerCount()
1318 if (LayersChildren == null || LayersChildren.Count < 0)
1321 return (uint) LayersChildren.Count;
1324 internal Layer GetRootLayer()
1326 // Window.IsInstalled() is actually true only when called from event thread and
1327 // Core has been initialized, not when Stage is ready.
1328 if (_rootLayer == null && Window.IsInstalled())
1330 _rootLayer = new Layer(Interop.Window.GetRootLayer(swigCPtr), true);
1331 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1332 LayersChildren?.Add(_rootLayer);
1333 _rootLayer.SetWindow(this);
1338 internal void SetBackgroundColor(Vector4 color)
1340 Interop.Window.SetBackgroundColor(swigCPtr, Vector4.getCPtr(color));
1341 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1344 internal Vector4 GetBackgroundColor()
1346 Vector4 ret = new Vector4(Interop.Window.GetBackgroundColor(swigCPtr), true);
1347 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1351 internal Vector2 GetDpi()
1353 Vector2 ret = new Vector2(Interop.Stage.Stage_GetDpi(stageCPtr), true);
1354 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1358 internal ObjectRegistry GetObjectRegistry()
1360 ObjectRegistry ret = new ObjectRegistry(Interop.Stage.Stage_GetObjectRegistry(stageCPtr), true);
1361 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1365 internal void SetRenderingBehavior(RenderingBehaviorType renderingBehavior)
1367 Interop.Stage.Stage_SetRenderingBehavior(stageCPtr, (int)renderingBehavior);
1368 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1371 internal RenderingBehaviorType GetRenderingBehavior()
1373 RenderingBehaviorType ret = (RenderingBehaviorType)Interop.Stage.Stage_GetRenderingBehavior(stageCPtr);
1374 if (NDalicPINVOKE.SWIGPendingException.Pending)
1375 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1379 internal KeyEventSignal KeyEventSignal()
1381 KeyEventSignal ret = new KeyEventSignal(Interop.Window.KeyEventSignal(swigCPtr), false);
1382 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1386 internal VoidSignal EventProcessingFinishedSignal()
1388 VoidSignal ret = new VoidSignal(Interop.StageSignal.Stage_EventProcessingFinishedSignal(stageCPtr), false);
1389 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1393 internal TouchSignal TouchSignal()
1395 TouchSignal ret = new TouchSignal(Interop.Window.TouchSignal(swigCPtr), false);
1396 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1400 internal TouchDataSignal TouchDataSignal()
1402 TouchDataSignal ret = new TouchDataSignal(Interop.ActorSignal.Actor_TouchSignal(Layer.getCPtr(GetRootLayer())), false);
1403 if (NDalicPINVOKE.SWIGPendingException.Pending)
1404 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1408 internal VoidSignal ContextLostSignal()
1410 VoidSignal ret = new VoidSignal(Interop.StageSignal.Stage_ContextLostSignal(stageCPtr), false);
1411 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1415 internal VoidSignal ContextRegainedSignal()
1417 VoidSignal ret = new VoidSignal(Interop.StageSignal.Stage_ContextRegainedSignal(stageCPtr), false);
1418 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1422 internal VoidSignal SceneCreatedSignal()
1424 VoidSignal ret = new VoidSignal(Interop.StageSignal.Stage_SceneCreatedSignal(stageCPtr), false);
1425 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1429 internal ResizedSignal ResizedSignal()
1431 ResizedSignal ret = new ResizedSignal(Interop.Window.Window_ResizedSignal(swigCPtr), false);
1432 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1436 internal void SetWindowSize(Size2D size)
1438 var val = new Uint16Pair((uint)size.Width, (uint)size.Height);
1439 Interop.Window.SetSize(swigCPtr, Uint16Pair.getCPtr(val));
1441 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1443 // Resetting Window size should request a relayout of the tree.
1446 internal Size2D GetWindowSize()
1448 var val = new Uint16Pair(Interop.Window.GetSize(swigCPtr), false);
1449 Size2D ret = new Size2D(val.GetWidth(), val.GetHeight());
1451 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1455 internal void SetPosition(Position2D position)
1457 var val = new Uint16Pair((uint)position.X, (uint)position.Y);
1458 Interop.Window.SetPosition(swigCPtr, Uint16Pair.getCPtr(val));
1460 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1462 // Setting Position of the window should request a relayout of the tree.
1466 internal Position2D GetPosition()
1468 var val = new Uint16Pair(Interop.Window.GetPosition(swigCPtr), true);
1469 Position2D ret = new Position2D(val.GetX(), val.GetY());
1471 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1475 internal void SetPositionSize(Rectangle positionSize)
1477 Interop.Window.Window_SetPositionSize(swigCPtr, Rectangle.getCPtr(positionSize));
1479 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1481 // Setting Position of the window should request a relayout of the tree.
1486 /// Sets whether the window is transparent or not.
1488 /// <param name="transparent">Whether the window is transparent or not.</param>
1489 /// <since_tizen> 5 </since_tizen>
1490 public void SetTransparency(bool transparent) {
1491 Interop.Window.SetTransparency(swigCPtr, transparent);
1492 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1494 // Setting transparency of the window should request a relayout of the tree in the case the window changes from fully transparent.
1499 /// Sets parent window of the window.
1500 /// After setting that, these windows do together when raise-up, lower and iconified/deiconified.
1501 /// Initially, the window is located on top of the parent. The window can go below parent by calling Lower().
1502 /// If parent's window stack is changed by calling Raise() or Lower(), child windows are located on top of the parent again.
1504 /// <param name="parent">The parent window.</param>
1505 /// <since_tizen> 6 </since_tizen>
1506 public void SetParent(Window parent) {
1507 Interop.Window.SetParent(swigCPtr, Window.getCPtr(parent));
1508 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1512 /// Unsets parent window of the window.
1513 /// After unsetting, the window is disconnected his parent window.
1515 /// <since_tizen> 6 </since_tizen>
1516 public void Unparent() {
1517 Interop.Window.Unparent(swigCPtr);
1518 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1522 /// Gets parent window of the window.
1524 /// <returns>The parent window of the window.</returns>
1525 /// <since_tizen> 6 </since_tizen>
1526 public Window GetParent() {
1527 Window ret = Registry.GetManagedBaseHandleFromNativePtr(Interop.Window.GetParent(swigCPtr)) as Window;
1528 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1533 /// Dispose for Window
1535 [EditorBrowsable(EditorBrowsableState.Never)]
1536 protected override void Dispose(DisposeTypes type)
1543 if (type == DisposeTypes.Explicit)
1546 //Release your own managed resources here.
1547 //You should release all of your own disposable objects here.
1549 _rootLayer.Dispose();
1550 localController.Dispose();
1552 foreach(var layer in _childLayers)
1556 _childLayers.Clear();
1559 this.DisconnectNativeSignals();
1561 //Release your own unmanaged resources here.
1562 //You should not access any managed member here except static instance.
1563 //because the execution order of Finalizes is non-deterministic.
1565 if (swigCPtr.Handle != global::System.IntPtr.Zero)
1569 swigCMemOwn = false;
1570 Interop.Window.delete_Window(swigCPtr);
1572 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
1578 internal System.IntPtr GetNativeWindowHandler()
1580 System.IntPtr ret = Interop.Window.GetNativeWindowHandler(HandleRef.ToIntPtr(this.swigCPtr));
1581 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1585 private void OnWindowFocusedChanged(bool focusGained)
1587 FocusChangedEventArgs e = new FocusChangedEventArgs();
1589 e.FocusGained = focusGained;
1591 if (_windowFocusChangedEventHandler != null)
1593 _windowFocusChangedEventHandler(this, e);
1597 private StageWheelSignal WheelEventSignal()
1599 StageWheelSignal ret = new StageWheelSignal(Interop.StageSignal.Stage_WheelEventSignal(stageCPtr), false);
1600 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1604 private WheelSignal StageWheelEventSignal()
1606 WheelSignal ret = new WheelSignal(Interop.ActorSignal.Actor_WheelEventSignal(Layer.getCPtr(this.GetRootLayer())), false);
1607 if (NDalicPINVOKE.SWIGPendingException.Pending)
1608 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1612 private bool OnWindowTouch(IntPtr view, IntPtr touchData)
1614 if (touchData == global::System.IntPtr.Zero)
1616 NUILog.Error("touchData should not be null!");
1620 TouchEventArgs e = new TouchEventArgs();
1622 e.Touch = Tizen.NUI.Touch.GetTouchFromPtr(touchData);
1624 if (_rootLayerTouchDataEventHandler != null)
1626 _rootLayerTouchDataEventHandler(this, e);
1631 private bool OnStageWheel(IntPtr rootLayer, IntPtr wheelEvent)
1633 if (wheelEvent == global::System.IntPtr.Zero)
1635 NUILog.Error("wheelEvent should not be null!");
1639 WheelEventArgs e = new WheelEventArgs();
1641 e.Wheel = Tizen.NUI.Wheel.GetWheelFromPtr(wheelEvent);
1643 if (_stageWheelHandler != null)
1645 _stageWheelHandler(this, e);
1650 // Callback for Stage KeyEventsignal
1651 private void OnStageKey(IntPtr data)
1653 KeyEventArgs e = new KeyEventArgs();
1654 e.Key = Tizen.NUI.Key.GetKeyFromPtr(data);
1657 if (_stageKeyHandler != null)
1659 //here we send all data to user event handlers
1660 _stageKeyHandler(this, e);
1664 // Callback for Stage EventProcessingFinishedSignal
1665 private void OnEventProcessingFinished()
1667 if (_stageEventProcessingFinishedEventHandler != null)
1669 _stageEventProcessingFinishedEventHandler(this, null);
1673 // Callback for Stage ContextLostSignal
1674 private void OnContextLost()
1676 if (_stageContextLostEventHandler != null)
1678 _stageContextLostEventHandler(this, null);
1682 // Callback for Stage ContextRegainedSignal
1683 private void OnContextRegained()
1685 if (_stageContextRegainedEventHandler != null)
1687 _stageContextRegainedEventHandler(this, null);
1691 // Callback for Stage SceneCreatedSignal
1692 private void OnSceneCreated()
1694 if (_stageSceneCreatedEventHandler != null)
1696 _stageSceneCreatedEventHandler(this, null);
1700 private void OnResized(IntPtr windowSize)
1702 ResizedEventArgs e = new ResizedEventArgs();
1703 var val = new Uint16Pair(windowSize, false);
1704 e.WindowSize = new Size2D(val.GetWidth(), val.GetHeight());
1707 if (_windowResizedEventHandler != null)
1709 _windowResizedEventHandler(this, e);
1713 private void OnWindowFocusedChanged2(bool focusGained)
1715 FocusChangedEventArgs e = new FocusChangedEventArgs();
1717 e.FocusGained = focusGained;
1719 if (_windowFocusChangedEventHandler2 != null)
1721 _windowFocusChangedEventHandler2(this, e);
1726 /// The focus changed event argument.
1728 /// <since_tizen> 3 </since_tizen>
1729 public class FocusChangedEventArgs : EventArgs
1732 /// FocusGained flag.
1734 /// <since_tizen> 3 </since_tizen>
1735 public bool FocusGained
1743 /// The touch event argument.
1745 /// <since_tizen> 3 </since_tizen>
1746 public class TouchEventArgs : EventArgs
1748 private Touch _touch;
1753 /// <since_tizen> 3 </since_tizen>
1768 /// Wheel event arguments.
1770 /// <since_tizen> 3 </since_tizen>
1771 public class WheelEventArgs : EventArgs
1773 private Wheel _wheel;
1778 /// <since_tizen> 3 </since_tizen>
1793 /// Key event arguments.
1795 /// <since_tizen> 3 </since_tizen>
1796 public class KeyEventArgs : EventArgs
1803 /// <since_tizen> 3 </since_tizen>
1818 /// Sets position and size of the window. This API guarantees that
1819 /// both moving and resizing of window will appear on the screen at once.
1821 [EditorBrowsable(EditorBrowsableState.Never)]
1822 public Rectangle WindowPositionSize
1826 Position2D position = GetPosition();
1827 Size2D size = GetSize();
1828 Rectangle ret = new Rectangle(position.X, position.Y, size.Width, size.Height);
1833 SetPositionSize(value);
1838 /// Feeds a key event into the window.
1839 /// This resized event arguments.
1841 /// <since_tizen> 3 </since_tizen>
1842 public class ResizedEventArgs : EventArgs
1847 /// This window size.
1849 /// <since_tizen> 4 </since_tizen>
1850 public Size2D WindowSize
1858 _windowSize = value;
1864 /// Please do not use! this will be deprecated
1866 /// <since_tizen> 3 </since_tizen>
1867 [Obsolete("Please do not use! This will be deprecated! Please use FocusChangedEventArgs instead! " +
1869 "Window.Instance.FocusChanged = OnFocusChanged; " +
1870 "private void OnFocusChanged(object source, Window.FocusChangedEventArgs args) {...}")]
1871 [EditorBrowsable(EditorBrowsableState.Never)]
1872 public class WindowFocusChangedEventArgs : EventArgs
1875 /// Please do not use! this will be deprecated
1877 /// <since_tizen> 3 </since_tizen>
1878 public bool FocusGained
1886 /// Contains and encapsulates Native Window handle.
1888 /// <since_tizen> 4 </since_tizen>
1889 public class SafeNativeWindowHandle : SafeHandle
1892 /// Contructor, Native window handle is set to handle.
1894 /// <since_tizen> 4 </since_tizen>
1895 public SafeNativeWindowHandle() : base(IntPtr.Zero, false)
1897 SetHandle(Tizen.NUI.Window.Instance.GetNativeWindowHandler());
1900 /// Null check if the handle is valid or not.
1902 /// <since_tizen> 4 </since_tizen>
1903 public override bool IsInvalid
1907 return this.handle == IntPtr.Zero;
1911 /// Release handle itself.
1913 /// <returns>true when released successfully.</returns>
1914 /// <since_tizen> 4 </since_tizen>
1915 protected override bool ReleaseHandle()
1922 /// Disconnect all native signals
1924 /// <since_tizen> 5 </since_tizen>
1925 internal void DisconnectNativeSignals()
1927 if( _windowFocusChangedEventCallback != null )
1929 WindowFocusChangedSignal().Disconnect(_windowFocusChangedEventCallback);
1932 if( _rootLayerTouchDataCallback != null )
1934 TouchDataSignal().Disconnect(_rootLayerTouchDataCallback);
1937 if( _wheelEventCallback != null )
1939 StageWheelEventSignal().Disconnect(_wheelEventCallback);
1942 if( _stageKeyCallbackDelegate != null )
1944 KeyEventSignal().Disconnect(_stageKeyCallbackDelegate);
1947 if( _stageEventProcessingFinishedEventCallbackDelegate != null )
1949 EventProcessingFinishedSignal().Disconnect(_stageEventProcessingFinishedEventCallbackDelegate);
1952 if( _stageContextLostEventCallbackDelegate != null )
1954 ContextLostSignal().Disconnect(_stageContextLostEventCallbackDelegate);
1957 if( _stageContextRegainedEventCallbackDelegate != null )
1959 ContextRegainedSignal().Disconnect(_stageContextRegainedEventCallbackDelegate);
1962 if( _stageSceneCreatedEventCallbackDelegate != null )
1964 SceneCreatedSignal().Disconnect(_stageSceneCreatedEventCallbackDelegate);
1967 if( _windowResizedEventCallback != null )
1969 ResizedSignal().Disconnect(_windowResizedEventCallback);
1972 if( _windowFocusChangedEventCallback2 != null )
1974 WindowFocusChangedSignal().Disconnect(_windowFocusChangedEventCallback2);
1977 if(transitionEffectSignal != null)
1979 TransitionEffectEventSignal().Disconnect(transitionEffectEventCallback);
1984 private void OnTransitionEffect(IntPtr window, int state, int type)
1986 //Tizen.Log.Fatal("NUITEST", $"OnTransitionEffect() called");
1987 if (window == global::System.IntPtr.Zero)
1989 //Tizen.Log.Error("NUI", $"OnTransitionEffect() IntPtr window is null!");
1993 TransitionEffectArgs e = new TransitionEffectArgs();
1995 e.State = (EffectStates)state;
1996 //Tizen.Log.Error("NUITEST", $"e.State={e.State}");
1998 e.Type = (EffectTypes)type;
1999 //Tizen.Log.Error("NUITEST", $"e.Type={e.Type}");
2001 if (transitionEffectHandler != null)
2003 //Tizen.Log.Fatal("NUITEST", $"Execute transitionEffectHandler(this, e)!!!");
2004 transitionEffectHandler(this, e);
2009 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
2010 private delegate void TransitionEffectEventCallbackType(IntPtr window, int state, int type);
2012 private TransitionEffectEventCallbackType transitionEffectEventCallback;
2014 private event EventHandler<TransitionEffectArgs> transitionEffectHandler;
2017 /// Enumeration for transition effect's state.
2019 [EditorBrowsable(EditorBrowsableState.Never)]
2020 public enum EffectStates
2025 [EditorBrowsable(EditorBrowsableState.Never)]
2028 /// Transition effect is started.
2030 [EditorBrowsable(EditorBrowsableState.Never)]
2033 /// Transition effect is ended.
2035 [EditorBrowsable(EditorBrowsableState.Never)]
2040 /// Enumeration for transition effect's type.
2042 [EditorBrowsable(EditorBrowsableState.Never)]
2043 public enum EffectTypes
2048 [EditorBrowsable(EditorBrowsableState.Never)]
2051 /// Window show effect.
2053 [EditorBrowsable(EditorBrowsableState.Never)]
2056 /// Window hide effect.
2058 [EditorBrowsable(EditorBrowsableState.Never)]
2063 /// TransitionEffectArgs
2065 [EditorBrowsable(EditorBrowsableState.Never)]
2066 public class TransitionEffectArgs : EventArgs
2068 private EffectStates state;
2072 [EditorBrowsable(EditorBrowsableState.Never)]
2073 public EffectStates State
2084 private EffectTypes type;
2088 [EditorBrowsable(EditorBrowsableState.Never)]
2089 public EffectTypes Type
2105 [EditorBrowsable(EditorBrowsableState.Never)]
2106 public event EventHandler<TransitionEffectArgs> TransitionEffect
2110 if (transitionEffectHandler== null)
2112 transitionEffectEventCallback = OnTransitionEffect;
2113 TransitionEffectEventSignal().Connect(transitionEffectEventCallback);
2115 transitionEffectHandler += value;
2119 transitionEffectHandler -= value;
2120 if (transitionEffectHandler == null && TransitionEffectEventSignal().Empty() == false)
2122 TransitionEffectEventSignal().Disconnect(transitionEffectEventCallback);
2127 private WindowTransitionEffectSignal transitionEffectSignal;
2128 private WindowTransitionEffectSignal TransitionEffectEventSignal()
2130 //Tizen.Log.Fatal("NUITEST", "TransitionEffectEventSignal()!");
2131 if (transitionEffectSignal == null)
2133 transitionEffectSignal = new WindowTransitionEffectSignal(this);
2134 if (NDalicPINVOKE.SWIGPendingException.Pending)
2135 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
2136 //Tizen.Log.Fatal("NUITEST", $"transitionEffectSignal is null, new here!");
2138 return transitionEffectSignal;