2 * Copyright(c) 2020 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.
19 using System.ComponentModel;
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
32 private WindowFocusChangedEventCallbackType _windowFocusChangedEventCallback;
33 private RootLayerTouchDataCallbackType _rootLayerTouchDataCallback;
34 private WheelEventCallbackType _wheelEventCallback;
35 private EventCallbackDelegateType1 _stageKeyCallbackDelegate;
36 private EventCallbackDelegateType0 _stageEventProcessingFinishedEventCallbackDelegate;
37 private EventHandler _stageContextLostEventHandler;
38 private EventCallbackDelegateType0 _stageContextLostEventCallbackDelegate;
39 private EventHandler _stageContextRegainedEventHandler;
40 private EventCallbackDelegateType0 _stageContextRegainedEventCallbackDelegate;
41 private EventHandler _stageSceneCreatedEventHandler;
42 private EventCallbackDelegateType0 _stageSceneCreatedEventCallbackDelegate;
43 private WindowResizeEventCallbackType _windowResizeEventCallback;
44 private WindowFocusChangedEventCallbackType _windowFocusChangedEventCallback2;
45 private TransitionEffectEventCallbackType transitionEffectEventCallback;
46 private WindowTransitionEffectSignal transitionEffectSignal;
47 private KeyboardRepeatSettingsChangedEventCallbackType keyboardRepeatSettingsChangedEventCallback;
48 private KeyboardRepeatSettingsChangedSignal keyboardRepeatSettingsChangedSignal;
50 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
51 private delegate void WindowFocusChangedEventCallbackType(IntPtr window, bool focusGained);
52 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
53 private delegate bool RootLayerTouchDataCallbackType(IntPtr view, IntPtr touchData);
54 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
55 private delegate bool WheelEventCallbackType(IntPtr view, IntPtr wheelEvent);
56 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
57 private delegate void WindowResizeEventCallbackType(IntPtr window, IntPtr windowSize);
58 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
59 private delegate void WindowFocusChangedEventCallbackType2(IntPtr window, bool focusGained);
60 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
61 private delegate void TransitionEffectEventCallbackType(IntPtr window, int state, int type);
62 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
63 private delegate void KeyboardRepeatSettingsChangedEventCallbackType();
66 /// FocusChanged event.
68 /// <since_tizen> 3 </since_tizen>
69 public event EventHandler<FocusChangedEventArgs> FocusChanged
73 if (_windowFocusChangedEventHandler == null)
75 _windowFocusChangedEventCallback = OnWindowFocusedChanged;
76 WindowFocusChangedSignal().Connect(_windowFocusChangedEventCallback);
79 _windowFocusChangedEventHandler += value;
83 _windowFocusChangedEventHandler -= value;
85 if (_windowFocusChangedEventHandler == null && WindowFocusChangedSignal().Empty() == false && _windowFocusChangedEventCallback != null)
87 WindowFocusChangedSignal().Disconnect(_windowFocusChangedEventCallback);
93 /// Emits the event when the screen is touched and when the touch ends.<br />
94 /// If there are multiple touch points then it is emitted when the first touch occurs and
95 /// when the last finger is lifted too.<br />
96 /// Even though incoming events are interrupted, the event occurs.<br />
98 /// <since_tizen> 3 </since_tizen>
99 public event EventHandler<TouchEventArgs> TouchEvent
103 if (_rootLayerTouchDataEventHandler == null)
105 _rootLayerTouchDataCallback = OnWindowTouch;
106 this.TouchDataSignal().Connect(_rootLayerTouchDataCallback);
108 _rootLayerTouchDataEventHandler += value;
112 _rootLayerTouchDataEventHandler -= value;
113 if (_rootLayerTouchDataEventHandler == null && TouchSignal().Empty() == false && _rootLayerTouchDataCallback != null)
115 this.TouchDataSignal().Disconnect(_rootLayerTouchDataCallback);
121 /// Emits the event when the wheel event is received.
123 /// <since_tizen> 3 </since_tizen>
124 public event EventHandler<WheelEventArgs> WheelEvent
128 if (_stageWheelHandler == null)
130 _wheelEventCallback = OnStageWheel;
131 WheelEventSignal().Connect(_wheelEventCallback);
133 _stageWheelHandler += value;
135 if (DetentEventHandler == null)
137 DetentEventCallback = OnDetentEvent;
138 StageWheelEventSignal().Connect(DetentEventCallback);
140 DetentEventHandler += value;
144 _stageWheelHandler -= value;
145 if (_stageWheelHandler == null && WheelEventSignal().Empty() == false)
147 WheelEventSignal().Disconnect(_wheelEventCallback);
150 DetentEventHandler -= value;
151 if (DetentEventHandler == null && StageWheelEventSignal().Empty() == false)
153 StageWheelEventSignal().Disconnect(DetentEventCallback);
159 /// Emits the event when the key event is received.
161 /// <since_tizen> 3 </since_tizen>
162 public event EventHandler<KeyEventArgs> KeyEvent
166 if (_stageKeyHandler == null)
168 _stageKeyCallbackDelegate = OnStageKey;
169 KeyEventSignal().Connect(_stageKeyCallbackDelegate);
171 _stageKeyHandler += value;
175 _stageKeyHandler -= value;
176 if (_stageKeyHandler == null && KeyEventSignal().Empty() == false)
178 KeyEventSignal().Disconnect(_stageKeyCallbackDelegate);
184 /// Emits the event when the window resized.
186 /// <since_tizen> 3 </since_tizen>
187 public event EventHandler<ResizedEventArgs> Resized
191 if (_windowResizeEventHandler == null)
193 _windowResizeEventCallback = OnResized;
194 ResizeSignal().Connect(_windowResizeEventCallback);
197 _windowResizeEventHandler += value;
201 _windowResizeEventHandler -= value;
203 if (_windowResizeEventHandler == null && ResizeSignal().Empty() == false && _windowResizeEventCallback != null)
205 ResizeSignal().Disconnect(_windowResizeEventCallback);
211 /// Please do not use! this will be deprecated. Please use 'FocusChanged' event instead.
213 /// <since_tizen> 3 </since_tizen>
214 /// Please do not use! this will be deprecated!
215 /// Instead please use FocusChanged.
216 [Obsolete("Please do not use! This will be deprecated! Please use FocusChanged instead! " +
218 "NUIApplication.GetDefaultWindow().FocusChanged = OnFocusChanged; " +
219 "private void OnFocusChanged(object source, Window.FocusChangedEventArgs args) {...}")]
220 [EditorBrowsable(EditorBrowsableState.Never)]
221 public event EventHandler<FocusChangedEventArgs> WindowFocusChanged
225 if (_windowFocusChangedEventHandler2 == null)
227 _windowFocusChangedEventCallback2 = OnWindowFocusedChanged2;
228 WindowFocusChangedSignal().Connect(_windowFocusChangedEventCallback2);
231 _windowFocusChangedEventHandler2 += value;
235 _windowFocusChangedEventHandler2 -= value;
237 if (_windowFocusChangedEventHandler2 == null && WindowFocusChangedSignal().Empty() == false && _windowFocusChangedEventCallback2 != null)
239 WindowFocusChangedSignal().Disconnect(_windowFocusChangedEventCallback2);
247 [EditorBrowsable(EditorBrowsableState.Never)]
248 public event EventHandler<TransitionEffectArgs> TransitionEffect
252 if (transitionEffectHandler == null)
254 transitionEffectEventCallback = OnTransitionEffect;
255 TransitionEffectEventSignal().Connect(transitionEffectEventCallback);
257 transitionEffectHandler += value;
261 transitionEffectHandler -= value;
262 if (transitionEffectHandler == null && TransitionEffectEventSignal().Empty() == false)
264 TransitionEffectEventSignal().Disconnect(transitionEffectEventCallback);
270 /// Keyboard Repeat Settings Changed
272 [EditorBrowsable(EditorBrowsableState.Never)]
273 public event EventHandler KeyboardRepeatSettingsChanged
277 if (keyboardRepeatSettingsChangedHandler == null)
279 keyboardRepeatSettingsChangedEventCallback = OnKeyboardRepeatSettingsChanged;
280 KeyboardRepeatSettingsChangedEventSignal().Connect(keyboardRepeatSettingsChangedEventCallback);
282 keyboardRepeatSettingsChangedHandler += value;
286 keyboardRepeatSettingsChangedHandler -= value;
287 if (keyboardRepeatSettingsChangedHandler == null && KeyboardRepeatSettingsChangedEventSignal().Empty() == false)
289 KeyboardRepeatSettingsChangedEventSignal().Disconnect(keyboardRepeatSettingsChangedEventCallback);
295 /// ViewAdded will be triggered when the view added on Window
297 /// <since_tizen> 6 </since_tizen>
298 /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
299 [EditorBrowsable(EditorBrowsableState.Never)]
300 public event EventHandler ViewAdded;
301 private event EventHandler<FocusChangedEventArgs> _windowFocusChangedEventHandler;
302 private event EventHandler<TouchEventArgs> _rootLayerTouchDataEventHandler;
303 private event EventHandler<WheelEventArgs> _stageWheelHandler;
304 private event EventHandler<KeyEventArgs> _stageKeyHandler;
305 private event EventHandler _stageEventProcessingFinishedEventHandler;
306 private event EventHandler<ResizedEventArgs> _windowResizeEventHandler;
307 private event EventHandler<FocusChangedEventArgs> _windowFocusChangedEventHandler2;
308 private event EventHandler<TransitionEffectArgs> transitionEffectHandler;
309 private event EventHandler keyboardRepeatSettingsChangedHandler;
311 internal void SendViewAdded(View view)
313 ViewAdded?.Invoke(view, EventArgs.Empty);
316 internal event EventHandler EventProcessingFinished
320 if (_stageEventProcessingFinishedEventHandler == null)
322 _stageEventProcessingFinishedEventCallbackDelegate = OnEventProcessingFinished;
323 EventProcessingFinishedSignal().Connect(_stageEventProcessingFinishedEventCallbackDelegate);
325 _stageEventProcessingFinishedEventHandler += value;
330 _stageEventProcessingFinishedEventHandler -= value;
331 if (_stageEventProcessingFinishedEventHandler == null && EventProcessingFinishedSignal().Empty() == false)
333 EventProcessingFinishedSignal().Disconnect(_stageEventProcessingFinishedEventCallbackDelegate);
338 internal event EventHandler ContextLost
342 if (_stageContextLostEventHandler == null)
344 _stageContextLostEventCallbackDelegate = OnContextLost;
345 ContextLostSignal().Connect(_stageContextLostEventCallbackDelegate);
347 _stageContextLostEventHandler += value;
351 _stageContextLostEventHandler -= value;
352 if (_stageContextLostEventHandler == null && ContextLostSignal().Empty() == false)
354 ContextLostSignal().Disconnect(_stageContextLostEventCallbackDelegate);
359 internal event EventHandler ContextRegained
363 if (_stageContextRegainedEventHandler == null)
365 _stageContextRegainedEventCallbackDelegate = OnContextRegained;
366 ContextRegainedSignal().Connect(_stageContextRegainedEventCallbackDelegate);
368 _stageContextRegainedEventHandler += value;
372 _stageContextRegainedEventHandler -= value;
373 if (_stageContextRegainedEventHandler == null && ContextRegainedSignal().Empty() == false)
375 this.ContextRegainedSignal().Disconnect(_stageContextRegainedEventCallbackDelegate);
380 internal event EventHandler SceneCreated
384 if (_stageSceneCreatedEventHandler == null)
386 _stageSceneCreatedEventCallbackDelegate = OnSceneCreated;
387 SceneCreatedSignal().Connect(_stageSceneCreatedEventCallbackDelegate);
389 _stageSceneCreatedEventHandler += value;
393 _stageSceneCreatedEventHandler -= value;
394 if (_stageSceneCreatedEventHandler == null && SceneCreatedSignal().Empty() == false)
396 SceneCreatedSignal().Disconnect(_stageSceneCreatedEventCallbackDelegate);
401 internal WindowFocusSignalType WindowFocusChangedSignal()
403 WindowFocusSignalType ret = new WindowFocusSignalType(Interop.Window.FocusChangedSignal(swigCPtr), false);
404 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
408 internal WindowFocusSignalType FocusChangedSignal()
410 WindowFocusSignalType ret = new WindowFocusSignalType(Interop.Window.FocusChangedSignal(swigCPtr), false);
411 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
415 internal KeyEventSignal KeyEventSignal()
417 KeyEventSignal ret = new KeyEventSignal(Interop.Window.KeyEventSignal(swigCPtr), false);
418 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
422 internal VoidSignal EventProcessingFinishedSignal()
424 VoidSignal ret = new VoidSignal(Interop.StageSignal.Stage_EventProcessingFinishedSignal(stageCPtr), false);
425 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
429 internal TouchSignal TouchSignal()
431 TouchSignal ret = new TouchSignal(Interop.Window.TouchSignal(swigCPtr), false);
432 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
436 internal TouchDataSignal TouchDataSignal()
438 TouchDataSignal ret = new TouchDataSignal(Interop.ActorSignal.Actor_TouchSignal(Layer.getCPtr(GetRootLayer())), false);
439 if (NDalicPINVOKE.SWIGPendingException.Pending)
440 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
444 internal VoidSignal ContextLostSignal()
446 VoidSignal ret = new VoidSignal(Interop.StageSignal.Stage_ContextLostSignal(stageCPtr), false);
447 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
451 internal VoidSignal ContextRegainedSignal()
453 VoidSignal ret = new VoidSignal(Interop.StageSignal.Stage_ContextRegainedSignal(stageCPtr), false);
454 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
458 internal VoidSignal SceneCreatedSignal()
460 VoidSignal ret = new VoidSignal(Interop.StageSignal.Stage_SceneCreatedSignal(stageCPtr), false);
461 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
465 internal ResizeSignal ResizeSignal()
467 ResizeSignal ret = new ResizeSignal(Interop.Window.Window_ResizeSignal(swigCPtr), false);
468 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
472 internal System.IntPtr GetNativeWindowHandler()
474 System.IntPtr ret = Interop.Window.GetNativeWindowHandler(HandleRef.ToIntPtr(this.swigCPtr));
475 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
480 /// Disconnect all native signals
482 /// <since_tizen> 5 </since_tizen>
483 internal void DisconnectNativeSignals()
485 if (_windowFocusChangedEventCallback != null)
487 WindowFocusChangedSignal().Disconnect(_windowFocusChangedEventCallback);
490 if (_rootLayerTouchDataCallback != null)
492 TouchDataSignal().Disconnect(_rootLayerTouchDataCallback);
495 if (_wheelEventCallback != null)
497 WheelEventSignal().Disconnect(_wheelEventCallback);
500 if (DetentEventCallback != null)
502 StageWheelEventSignal().Disconnect(DetentEventCallback);
505 if (_stageKeyCallbackDelegate != null)
507 KeyEventSignal().Disconnect(_stageKeyCallbackDelegate);
510 if (_stageEventProcessingFinishedEventCallbackDelegate != null)
512 EventProcessingFinishedSignal().Disconnect(_stageEventProcessingFinishedEventCallbackDelegate);
515 if (_stageContextLostEventCallbackDelegate != null)
517 ContextLostSignal().Disconnect(_stageContextLostEventCallbackDelegate);
520 if (_stageContextRegainedEventCallbackDelegate != null)
522 ContextRegainedSignal().Disconnect(_stageContextRegainedEventCallbackDelegate);
525 if (_stageSceneCreatedEventCallbackDelegate != null)
527 SceneCreatedSignal().Disconnect(_stageSceneCreatedEventCallbackDelegate);
530 if (_windowResizeEventCallback != null)
532 ResizeSignal().Disconnect(_windowResizeEventCallback);
535 if (_windowFocusChangedEventCallback2 != null)
537 WindowFocusChangedSignal().Disconnect(_windowFocusChangedEventCallback2);
540 if (transitionEffectSignal != null)
542 TransitionEffectEventSignal().Disconnect(transitionEffectEventCallback);
545 if (keyboardRepeatSettingsChangedSignal != null)
547 KeyboardRepeatSettingsChangedEventSignal().Disconnect(keyboardRepeatSettingsChangedEventCallback);
551 private StageWheelSignal StageWheelEventSignal()
553 StageWheelSignal ret = new StageWheelSignal(Interop.StageSignal.Stage_WheelEventSignal(stageCPtr), false);
554 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
558 private WheelSignal WheelEventSignal()
560 WheelSignal ret = new WheelSignal(Interop.ActorSignal.Actor_WheelEventSignal(Layer.getCPtr(this.GetRootLayer())), false);
561 if (NDalicPINVOKE.SWIGPendingException.Pending)
562 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
566 private WindowTransitionEffectSignal TransitionEffectEventSignal()
568 if (transitionEffectSignal == null)
570 transitionEffectSignal = new WindowTransitionEffectSignal(this);
571 if (NDalicPINVOKE.SWIGPendingException.Pending)
572 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
574 return transitionEffectSignal;
577 private KeyboardRepeatSettingsChangedSignal KeyboardRepeatSettingsChangedEventSignal()
579 if (keyboardRepeatSettingsChangedSignal == null)
581 keyboardRepeatSettingsChangedSignal = new KeyboardRepeatSettingsChangedSignal(this);
582 if (NDalicPINVOKE.SWIGPendingException.Pending)
583 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
585 return keyboardRepeatSettingsChangedSignal;
588 private void OnWindowFocusedChanged(IntPtr window, bool focusGained)
590 if (window == IntPtr.Zero)
592 NUILog.Error("OnWindowFocusedChanged() Window is null! Do nothing!");
596 FocusChangedEventArgs e = new FocusChangedEventArgs();
598 e.FocusGained = focusGained;
600 if (_windowFocusChangedEventHandler != null)
602 _windowFocusChangedEventHandler(this, e);
606 private bool OnWindowTouch(IntPtr view, IntPtr touchData)
608 if (touchData == global::System.IntPtr.Zero)
610 NUILog.Error("touchData should not be null!");
614 TouchEventArgs e = new TouchEventArgs();
616 e.Touch = Tizen.NUI.Touch.GetTouchFromPtr(touchData);
618 if (_rootLayerTouchDataEventHandler != null)
620 _rootLayerTouchDataEventHandler(this, e);
625 private bool OnStageWheel(IntPtr rootLayer, IntPtr wheelEvent)
627 if (wheelEvent == global::System.IntPtr.Zero)
629 NUILog.Error("wheelEvent should not be null!");
633 WheelEventArgs e = new WheelEventArgs();
635 e.Wheel = Tizen.NUI.Wheel.GetWheelFromPtr(wheelEvent);
637 if (_stageWheelHandler != null)
639 _stageWheelHandler(this, e);
644 // Callback for Stage KeyEventsignal
645 private void OnStageKey(IntPtr data)
647 KeyEventArgs e = new KeyEventArgs();
648 e.Key = Tizen.NUI.Key.GetKeyFromPtr(data);
651 if (_stageKeyHandler != null)
653 //here we send all data to user event handlers
654 _stageKeyHandler(this, e);
658 // Callback for Stage EventProcessingFinishedSignal
659 private void OnEventProcessingFinished()
661 if (_stageEventProcessingFinishedEventHandler != null)
663 _stageEventProcessingFinishedEventHandler(this, null);
667 // Callback for Stage ContextLostSignal
668 private void OnContextLost()
670 if (_stageContextLostEventHandler != null)
672 _stageContextLostEventHandler(this, null);
676 // Callback for Stage ContextRegainedSignal
677 private void OnContextRegained()
679 if (_stageContextRegainedEventHandler != null)
681 _stageContextRegainedEventHandler(this, null);
685 // Callback for Stage SceneCreatedSignal
686 private void OnSceneCreated()
688 if (_stageSceneCreatedEventHandler != null)
690 _stageSceneCreatedEventHandler(this, null);
694 private void OnResized(IntPtr window, IntPtr windowSize)
696 if (window == IntPtr.Zero)
698 NUILog.Error("OnResized() Window is null! Do nothing!");
702 ResizedEventArgs e = new ResizedEventArgs();
703 // var val = new Uint16Pair(windowSize, false);
704 // e.WindowSize = new Size2D(val.GetWidth(), val.GetHeight());
707 // Workaround : windowSize should be valid pointer from dali,
708 // but currenlty it is fixed and is not Uint16Pair class.
709 // will be fixed later.
710 e.WindowSize = this.WindowSize;
712 if (_windowResizeEventHandler != null)
714 _windowResizeEventHandler(this, e);
718 private void OnWindowFocusedChanged2(IntPtr window, bool focusGained)
720 if (window == IntPtr.Zero)
722 NUILog.Error("OnWindowFocusedChanged() Window is null! Do nothing!");
726 FocusChangedEventArgs e = new FocusChangedEventArgs();
728 e.FocusGained = focusGained;
730 if (_windowFocusChangedEventHandler2 != null)
732 _windowFocusChangedEventHandler2(this, e);
736 private void OnTransitionEffect(IntPtr window, int state, int type)
738 if (window == global::System.IntPtr.Zero)
743 TransitionEffectArgs e = new TransitionEffectArgs();
745 e.State = (EffectStates)state;
747 e.Type = (EffectTypes)type;
749 if (transitionEffectHandler != null)
751 transitionEffectHandler(this, e);
756 private void OnKeyboardRepeatSettingsChanged()
758 if (keyboardRepeatSettingsChangedHandler != null)
760 keyboardRepeatSettingsChangedHandler(this, null);
766 /// The focus changed event argument.
768 /// <since_tizen> 3 </since_tizen>
769 public class FocusChangedEventArgs : EventArgs
772 /// FocusGained flag.
774 /// <since_tizen> 3 </since_tizen>
775 public bool FocusGained
783 /// The touch event argument.
785 /// <since_tizen> 3 </since_tizen>
786 public class TouchEventArgs : EventArgs
788 private Touch _touch;
793 /// <since_tizen> 3 </since_tizen>
808 /// Wheel event arguments.
810 /// <since_tizen> 3 </since_tizen>
811 public class WheelEventArgs : EventArgs
813 private Wheel _wheel;
818 /// <since_tizen> 3 </since_tizen>
833 /// Key event arguments.
835 /// <since_tizen> 3 </since_tizen>
836 public class KeyEventArgs : EventArgs
843 /// <since_tizen> 3 </since_tizen>
858 /// Feeds a key event into the window.
859 /// This resized event arguments.
861 /// <since_tizen> 3 </since_tizen>
862 public class ResizedEventArgs : EventArgs
867 /// This window size.
869 /// <since_tizen> 4 </since_tizen>
870 public Size2D WindowSize
884 /// Please do not use! this will be deprecated
886 /// <since_tizen> 3 </since_tizen>
887 [Obsolete("Please do not use! This will be deprecated! Please use FocusChangedEventArgs instead! " +
889 "NUIApplication.GetDefaultWindow().FocusChanged = OnFocusChanged; " +
890 "private void OnFocusChanged(object source, Window.FocusChangedEventArgs args) {...}")]
891 [EditorBrowsable(EditorBrowsableState.Never)]
892 public class WindowFocusChangedEventArgs : EventArgs
895 /// Please do not use! this will be deprecated
897 /// <since_tizen> 3 </since_tizen>
898 public bool FocusGained
906 /// Contains and encapsulates Native Window handle.
908 /// <since_tizen> 4 </since_tizen>
909 public class SafeNativeWindowHandle : SafeHandle
912 /// Contructor, Native window handle is set to handle.
914 /// <since_tizen> 4 </since_tizen>
915 public SafeNativeWindowHandle() : base(IntPtr.Zero, false)
917 SetHandle(NUIApplication.GetDefaultWindow().GetNativeWindowHandler());
920 /// Null check if the handle is valid or not.
922 /// <since_tizen> 4 </since_tizen>
923 public override bool IsInvalid
927 return this.handle == IntPtr.Zero;
931 /// Release handle itself.
933 /// <returns>true when released successfully.</returns>
934 /// <since_tizen> 4 </since_tizen>
935 protected override bool ReleaseHandle()
942 /// TransitionEffectArgs
944 [EditorBrowsable(EditorBrowsableState.Never)]
945 public class TransitionEffectArgs : EventArgs
947 private EffectStates state;
948 private EffectTypes type;
953 [EditorBrowsable(EditorBrowsableState.Never)]
954 public EffectStates State
968 [EditorBrowsable(EditorBrowsableState.Never)]
969 public EffectTypes Type
982 private EventHandler<WheelEventArgs> DetentEventHandler;
984 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
985 private delegate void DetentEventCallbackType(IntPtr arg1);
987 private DetentEventCallbackType DetentEventCallback;
989 private void OnDetentEvent(IntPtr wheelEvent)
991 WheelEventArgs e = new WheelEventArgs();
993 if (wheelEvent != global::System.IntPtr.Zero)
995 e.Wheel = Wheel.GetWheelFromPtr(wheelEvent);
998 DetentEventHandler?.Invoke(this, e);
1002 /// VisibilityChangedArgs
1004 [EditorBrowsable(EditorBrowsableState.Never)]
1005 public class VisibilityChangedArgs : EventArgs
1007 private bool visibility;
1011 [EditorBrowsable(EditorBrowsableState.Never)]
1012 public bool Visibility
1022 private void OnVisibilityChanged(IntPtr window, bool visibility)
1024 if (window == global::System.IntPtr.Zero)
1026 NUILog.Error("[ERR] OnVisibilityChanged() window is null");
1030 VisibilityChangedArgs e = new VisibilityChangedArgs();
1031 e.Visibility = visibility;
1032 if (VisibilityChangedEventHandler != null)
1034 VisibilityChangedEventHandler.Invoke(this, e);
1038 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
1039 private delegate void VisibilityChangedEventCallbackType(IntPtr window, bool visibility);
1040 private VisibilityChangedEventCallbackType VisibilityChangedEventCallback;
1041 private event EventHandler<VisibilityChangedArgs> VisibilityChangedEventHandler;
1042 private WindowVisibilityChangedEvent VisibilityChangedEventSignal;
1047 [EditorBrowsable(EditorBrowsableState.Never)]
1048 public event EventHandler<VisibilityChangedArgs> VisibilityChanged
1052 if (VisibilityChangedEventHandler == null)
1054 VisibilityChangedEventCallback = OnVisibilityChanged;
1055 VisibilityChangedEventSignal = new WindowVisibilityChangedEvent(this);
1056 VisibilityChangedEventSignal.Connect(VisibilityChangedEventCallback);
1058 VisibilityChangedEventHandler += value;
1062 VisibilityChangedEventHandler -= value;
1063 if (VisibilityChangedEventHandler == null)
1065 if (VisibilityChangedEventSignal != null)
1067 if (VisibilityChangedEventSignal.Empty() == false)
1069 VisibilityChangedEventSignal.Disconnect(VisibilityChangedEventCallback);
1077 /// VisibiltyChangedSignalEmit
1079 [EditorBrowsable(EditorBrowsableState.Never)]
1080 public void VisibiltyChangedSignalEmit(bool visibility)
1082 if (VisibilityChangedEventSignal == null)
1084 VisibilityChangedEventSignal = new WindowVisibilityChangedEvent(this);
1086 VisibilityChangedEventSignal.Emit(this, visibility);