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;
49 private WindowFocusSignalType windowFocusChangedSignal;
50 private WindowFocusSignalType windowFocusChangedSignal2;
51 private TouchDataSignal touchDataSignal;
52 private TouchSignal touchSignal;
53 private WheelSignal wheelSignal;
54 private StageWheelSignal stageWheelSignal;
55 private KeyEventSignal keyEventSignal;
56 private VoidSignal sceneCreatedSignal;
57 private ResizeSignal resizeSignal;
58 private VoidSignal eventProcessingFinishedSignal;
59 private VoidSignal contextLostSignal;
60 private VoidSignal contextRegainedSignal;
62 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
63 private delegate void WindowFocusChangedEventCallbackType(IntPtr window, bool focusGained);
64 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
65 private delegate bool RootLayerTouchDataCallbackType(IntPtr view, IntPtr touchData);
66 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
67 private delegate bool WheelEventCallbackType(IntPtr view, IntPtr wheelEvent);
68 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
69 private delegate void WindowResizeEventCallbackType(IntPtr window, IntPtr windowSize);
70 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
71 private delegate void WindowFocusChangedEventCallbackType2(IntPtr window, bool focusGained);
72 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
73 private delegate void TransitionEffectEventCallbackType(IntPtr window, int state, int type);
74 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
75 private delegate void KeyboardRepeatSettingsChangedEventCallbackType();
78 /// FocusChanged event.
80 /// <since_tizen> 3 </since_tizen>
81 public event EventHandler<FocusChangedEventArgs> FocusChanged
85 if (_windowFocusChangedEventHandler == null)
87 _windowFocusChangedEventCallback = OnWindowFocusedChanged;
88 windowFocusChangedSignal = WindowFocusChangedSignal();
89 windowFocusChangedSignal?.Connect(_windowFocusChangedEventCallback);
92 _windowFocusChangedEventHandler += value;
96 _windowFocusChangedEventHandler -= value;
98 if (_windowFocusChangedEventHandler == null && windowFocusChangedSignal?.Empty() == false && _windowFocusChangedEventCallback != null)
100 windowFocusChangedSignal?.Disconnect(_windowFocusChangedEventCallback);
106 /// Emits the event when the screen is touched and when the touch ends.<br />
107 /// If there are multiple touch points then it is emitted when the first touch occurs and
108 /// when the last finger is lifted too.<br />
109 /// Even though incoming events are interrupted, the event occurs.<br />
111 /// <since_tizen> 3 </since_tizen>
112 public event EventHandler<TouchEventArgs> TouchEvent
116 if (_rootLayerTouchDataEventHandler == null)
118 _rootLayerTouchDataCallback = OnWindowTouch;
119 touchDataSignal = this.TouchDataSignal();
120 touchDataSignal?.Connect(_rootLayerTouchDataCallback);
122 _rootLayerTouchDataEventHandler += value;
126 _rootLayerTouchDataEventHandler -= value;
127 touchSignal = TouchSignal();
128 if (_rootLayerTouchDataEventHandler == null && touchSignal?.Empty() == false && _rootLayerTouchDataCallback != null)
130 touchDataSignal?.Disconnect(_rootLayerTouchDataCallback);
136 /// Emits the event when the wheel event is received.
138 /// <since_tizen> 3 </since_tizen>
139 public event EventHandler<WheelEventArgs> WheelEvent
143 if (_stageWheelHandler == null)
145 _wheelEventCallback = OnStageWheel;
146 wheelSignal = WheelEventSignal();
147 wheelSignal?.Connect(_wheelEventCallback);
149 _stageWheelHandler += value;
151 if (DetentEventHandler == null)
153 DetentEventCallback = OnDetentEvent;
154 stageWheelSignal = StageWheelEventSignal();
155 stageWheelSignal?.Connect(DetentEventCallback);
157 DetentEventHandler += value;
161 _stageWheelHandler -= value;
162 if (_stageWheelHandler == null && wheelSignal?.Empty() == false)
164 wheelSignal?.Disconnect(_wheelEventCallback);
167 DetentEventHandler -= value;
168 if (DetentEventHandler == null && stageWheelSignal?.Empty() == false)
170 stageWheelSignal?.Disconnect(DetentEventCallback);
176 /// Emits the event when the key event is received.
178 /// <since_tizen> 3 </since_tizen>
179 public event EventHandler<KeyEventArgs> KeyEvent
183 if (_stageKeyHandler == null)
185 _stageKeyCallbackDelegate = OnStageKey;
186 keyEventSignal = KeyEventSignal();
187 keyEventSignal?.Connect(_stageKeyCallbackDelegate);
189 _stageKeyHandler += value;
193 _stageKeyHandler -= value;
194 if (_stageKeyHandler == null && keyEventSignal?.Empty() == false)
196 keyEventSignal?.Disconnect(_stageKeyCallbackDelegate);
202 /// Emits the event when the window resized.
204 /// <since_tizen> 3 </since_tizen>
205 public event EventHandler<ResizedEventArgs> Resized
209 if (_windowResizeEventHandler == null)
211 _windowResizeEventCallback = OnResized;
212 resizeSignal = ResizeSignal();
213 resizeSignal?.Connect(_windowResizeEventCallback);
216 _windowResizeEventHandler += value;
220 _windowResizeEventHandler -= value;
222 if (_windowResizeEventHandler == null && resizeSignal?.Empty() == false && _windowResizeEventCallback != null)
224 resizeSignal?.Disconnect(_windowResizeEventCallback);
230 /// Please do not use! this will be deprecated. Please use 'FocusChanged' event instead.
232 /// <since_tizen> 3 </since_tizen>
233 /// Please do not use! this will be deprecated!
234 /// Instead please use FocusChanged.
235 [Obsolete("Please do not use! This will be deprecated! Please use FocusChanged instead! " +
237 "NUIApplication.GetDefaultWindow().FocusChanged = OnFocusChanged; " +
238 "private void OnFocusChanged(object source, Window.FocusChangedEventArgs args) {...}")]
239 [EditorBrowsable(EditorBrowsableState.Never)]
240 public event EventHandler<FocusChangedEventArgs> WindowFocusChanged
244 if (_windowFocusChangedEventHandler2 == null)
246 _windowFocusChangedEventCallback2 = OnWindowFocusedChanged2;
247 windowFocusChangedSignal2 = WindowFocusChangedSignal();
248 windowFocusChangedSignal2?.Connect(_windowFocusChangedEventCallback2);
251 _windowFocusChangedEventHandler2 += value;
255 _windowFocusChangedEventHandler2 -= value;
257 if (_windowFocusChangedEventHandler2 == null && windowFocusChangedSignal2?.Empty() == false && _windowFocusChangedEventCallback2 != null)
259 windowFocusChangedSignal2?.Disconnect(_windowFocusChangedEventCallback2);
267 [EditorBrowsable(EditorBrowsableState.Never)]
268 public event EventHandler<TransitionEffectEventArgs> TransitionEffect
272 if (transitionEffectHandler == null)
274 transitionEffectEventCallback = OnTransitionEffect;
275 TransitionEffectEventSignal().Connect(transitionEffectEventCallback);
277 transitionEffectHandler += value;
281 transitionEffectHandler -= value;
282 if (transitionEffectHandler == null && TransitionEffectEventSignal().Empty() == false)
284 TransitionEffectEventSignal().Disconnect(transitionEffectEventCallback);
290 /// Keyboard Repeat Settings Changed
292 [EditorBrowsable(EditorBrowsableState.Never)]
293 public event EventHandler KeyboardRepeatSettingsChanged
297 if (keyboardRepeatSettingsChangedHandler == null)
299 keyboardRepeatSettingsChangedEventCallback = OnKeyboardRepeatSettingsChanged;
300 KeyboardRepeatSettingsChangedEventSignal().Connect(keyboardRepeatSettingsChangedEventCallback);
302 keyboardRepeatSettingsChangedHandler += value;
306 keyboardRepeatSettingsChangedHandler -= value;
307 if (keyboardRepeatSettingsChangedHandler == null && KeyboardRepeatSettingsChangedEventSignal().Empty() == false)
309 KeyboardRepeatSettingsChangedEventSignal().Disconnect(keyboardRepeatSettingsChangedEventCallback);
315 /// ViewAdded will be triggered when the view added on Window
317 /// <since_tizen> 6 </since_tizen>
318 /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
319 [EditorBrowsable(EditorBrowsableState.Never)]
320 public event EventHandler ViewAdded;
321 private event EventHandler<FocusChangedEventArgs> _windowFocusChangedEventHandler;
322 private event EventHandler<TouchEventArgs> _rootLayerTouchDataEventHandler;
323 private event EventHandler<WheelEventArgs> _stageWheelHandler;
324 private event EventHandler<KeyEventArgs> _stageKeyHandler;
325 private event EventHandler _stageEventProcessingFinishedEventHandler;
326 private event EventHandler<ResizedEventArgs> _windowResizeEventHandler;
327 private event EventHandler<FocusChangedEventArgs> _windowFocusChangedEventHandler2;
328 private event EventHandler<TransitionEffectEventArgs> transitionEffectHandler;
329 private event EventHandler keyboardRepeatSettingsChangedHandler;
331 internal void SendViewAdded(View view)
333 ViewAdded?.Invoke(view, EventArgs.Empty);
336 internal event EventHandler EventProcessingFinished
340 if (_stageEventProcessingFinishedEventHandler == null)
342 _stageEventProcessingFinishedEventCallbackDelegate = OnEventProcessingFinished;
343 eventProcessingFinishedSignal = EventProcessingFinishedSignal();
344 eventProcessingFinishedSignal?.Connect(_stageEventProcessingFinishedEventCallbackDelegate);
346 _stageEventProcessingFinishedEventHandler += value;
351 _stageEventProcessingFinishedEventHandler -= value;
352 if (_stageEventProcessingFinishedEventHandler == null && eventProcessingFinishedSignal?.Empty() == false)
354 eventProcessingFinishedSignal?.Disconnect(_stageEventProcessingFinishedEventCallbackDelegate);
359 internal event EventHandler ContextLost
363 if (_stageContextLostEventHandler == null)
365 _stageContextLostEventCallbackDelegate = OnContextLost;
366 contextLostSignal = ContextLostSignal();
367 contextLostSignal?.Connect(_stageContextLostEventCallbackDelegate);
369 _stageContextLostEventHandler += value;
373 _stageContextLostEventHandler -= value;
374 if (_stageContextLostEventHandler == null && contextLostSignal?.Empty() == false)
376 contextLostSignal?.Disconnect(_stageContextLostEventCallbackDelegate);
381 internal event EventHandler ContextRegained
385 if (_stageContextRegainedEventHandler == null)
387 _stageContextRegainedEventCallbackDelegate = OnContextRegained;
388 contextRegainedSignal = ContextRegainedSignal();
389 contextRegainedSignal?.Connect(_stageContextRegainedEventCallbackDelegate);
391 _stageContextRegainedEventHandler += value;
395 _stageContextRegainedEventHandler -= value;
396 if (_stageContextRegainedEventHandler == null && contextRegainedSignal?.Empty() == false)
398 contextRegainedSignal?.Disconnect(_stageContextRegainedEventCallbackDelegate);
403 internal event EventHandler SceneCreated
407 if (_stageSceneCreatedEventHandler == null)
409 _stageSceneCreatedEventCallbackDelegate = OnSceneCreated;
410 sceneCreatedSignal = SceneCreatedSignal();
411 sceneCreatedSignal?.Connect(_stageSceneCreatedEventCallbackDelegate);
413 _stageSceneCreatedEventHandler += value;
417 _stageSceneCreatedEventHandler -= value;
418 if (_stageSceneCreatedEventHandler == null && sceneCreatedSignal?.Empty() == false)
420 sceneCreatedSignal?.Disconnect(_stageSceneCreatedEventCallbackDelegate);
425 internal WindowFocusSignalType WindowFocusChangedSignal()
427 WindowFocusSignalType ret = new WindowFocusSignalType(Interop.Window.FocusChangedSignal(SwigCPtr), false);
428 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
432 internal WindowFocusSignalType FocusChangedSignal()
434 WindowFocusSignalType ret = new WindowFocusSignalType(Interop.Window.FocusChangedSignal(SwigCPtr), false);
435 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
439 internal KeyEventSignal KeyEventSignal()
441 KeyEventSignal ret = new KeyEventSignal(Interop.Window.KeyEventSignal(SwigCPtr), false);
442 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
446 internal VoidSignal EventProcessingFinishedSignal()
448 VoidSignal ret = new VoidSignal(Interop.StageSignal.EventProcessingFinishedSignal(stageCPtr), false);
449 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
453 internal TouchSignal TouchSignal()
455 TouchSignal ret = new TouchSignal(Interop.Window.TouchSignal(SwigCPtr), false);
456 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
460 internal TouchDataSignal TouchDataSignal()
462 TouchDataSignal ret = new TouchDataSignal(Interop.ActorSignal.ActorTouchSignal(Layer.getCPtr(GetRootLayer())), false);
463 if (NDalicPINVOKE.SWIGPendingException.Pending)
464 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
468 internal VoidSignal ContextLostSignal()
470 VoidSignal ret = new VoidSignal(Interop.StageSignal.ContextLostSignal(stageCPtr), false);
471 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
475 internal VoidSignal ContextRegainedSignal()
477 VoidSignal ret = new VoidSignal(Interop.StageSignal.ContextRegainedSignal(stageCPtr), false);
478 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
482 internal VoidSignal SceneCreatedSignal()
484 VoidSignal ret = new VoidSignal(Interop.StageSignal.SceneCreatedSignal(stageCPtr), false);
485 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
489 internal ResizeSignal ResizeSignal()
491 ResizeSignal ret = new ResizeSignal(Interop.Window.ResizeSignal(SwigCPtr), false);
492 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
496 internal System.IntPtr GetNativeWindowHandler()
498 System.IntPtr ret = Interop.Window.GetNativeWindowHandler(HandleRef.ToIntPtr(this.SwigCPtr));
499 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
504 /// Disconnect all native signals
506 /// <since_tizen> 5 </since_tizen>
507 internal void DisconnectNativeSignals()
509 if (_windowFocusChangedEventCallback != null)
511 windowFocusChangedSignal?.Disconnect(_windowFocusChangedEventCallback);
514 if (_rootLayerTouchDataCallback != null)
516 touchDataSignal?.Disconnect(_rootLayerTouchDataCallback);
519 if (_wheelEventCallback != null)
521 wheelSignal?.Disconnect(_wheelEventCallback);
524 if (DetentEventCallback != null)
526 stageWheelSignal?.Disconnect(DetentEventCallback);
529 if (_stageKeyCallbackDelegate != null)
531 keyEventSignal?.Disconnect(_stageKeyCallbackDelegate);
534 if (_stageEventProcessingFinishedEventCallbackDelegate != null)
536 eventProcessingFinishedSignal?.Disconnect(_stageEventProcessingFinishedEventCallbackDelegate);
539 if (_stageContextLostEventCallbackDelegate != null)
541 contextLostSignal?.Disconnect(_stageContextLostEventCallbackDelegate);
544 if (_stageContextRegainedEventCallbackDelegate != null)
546 contextRegainedSignal?.Disconnect(_stageContextRegainedEventCallbackDelegate);
549 if (_stageSceneCreatedEventCallbackDelegate != null)
551 sceneCreatedSignal?.Disconnect(_stageSceneCreatedEventCallbackDelegate);
554 if (_windowResizeEventCallback != null)
556 resizeSignal?.Disconnect(_windowResizeEventCallback);
559 if (_windowFocusChangedEventCallback2 != null)
561 windowFocusChangedSignal2?.Disconnect(_windowFocusChangedEventCallback2);
564 if (transitionEffectSignal != null)
566 TransitionEffectEventSignal().Disconnect(transitionEffectEventCallback);
569 if (keyboardRepeatSettingsChangedSignal != null)
571 KeyboardRepeatSettingsChangedEventSignal().Disconnect(keyboardRepeatSettingsChangedEventCallback);
575 private StageWheelSignal StageWheelEventSignal()
577 StageWheelSignal ret = new StageWheelSignal(Interop.StageSignal.WheelEventSignal(stageCPtr), false);
578 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
582 private WheelSignal WheelEventSignal()
584 WheelSignal ret = new WheelSignal(Interop.ActorSignal.ActorWheelEventSignal(Layer.getCPtr(this.GetRootLayer())), false);
585 if (NDalicPINVOKE.SWIGPendingException.Pending)
586 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
590 private WindowTransitionEffectSignal TransitionEffectEventSignal()
592 if (transitionEffectSignal == null)
594 transitionEffectSignal = new WindowTransitionEffectSignal(this);
595 if (NDalicPINVOKE.SWIGPendingException.Pending)
596 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
598 return transitionEffectSignal;
601 private KeyboardRepeatSettingsChangedSignal KeyboardRepeatSettingsChangedEventSignal()
603 if (keyboardRepeatSettingsChangedSignal == null)
605 keyboardRepeatSettingsChangedSignal = new KeyboardRepeatSettingsChangedSignal(this);
606 if (NDalicPINVOKE.SWIGPendingException.Pending)
607 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
609 return keyboardRepeatSettingsChangedSignal;
612 private void OnWindowFocusedChanged(IntPtr window, bool focusGained)
614 if (window == IntPtr.Zero)
616 NUILog.Error("OnWindowFocusedChanged() Window is null! Do nothing!");
620 FocusChangedEventArgs e = new FocusChangedEventArgs();
622 e.FocusGained = focusGained;
624 if (_windowFocusChangedEventHandler != null)
626 _windowFocusChangedEventHandler(this, e);
630 private bool OnWindowTouch(IntPtr view, IntPtr touchData)
632 if (touchData == global::System.IntPtr.Zero)
634 NUILog.Error("touchData should not be null!");
638 TouchEventArgs e = new TouchEventArgs();
640 e.Touch = Tizen.NUI.Touch.GetTouchFromPtr(touchData);
642 if (_rootLayerTouchDataEventHandler != null)
644 _rootLayerTouchDataEventHandler(this, e);
649 private bool OnStageWheel(IntPtr rootLayer, IntPtr wheelEvent)
651 if (wheelEvent == global::System.IntPtr.Zero)
653 NUILog.Error("wheelEvent should not be null!");
657 WheelEventArgs e = new WheelEventArgs();
659 e.Wheel = Tizen.NUI.Wheel.GetWheelFromPtr(wheelEvent);
661 if (_stageWheelHandler != null)
663 _stageWheelHandler(this, e);
668 // Callback for Stage KeyEventsignal
669 private void OnStageKey(IntPtr data)
671 KeyEventArgs e = new KeyEventArgs();
672 e.Key = Tizen.NUI.Key.GetKeyFromPtr(data);
675 if (_stageKeyHandler != null)
677 //here we send all data to user event handlers
678 _stageKeyHandler(this, e);
682 // Callback for Stage EventProcessingFinishedSignal
683 private void OnEventProcessingFinished()
685 if (_stageEventProcessingFinishedEventHandler != null)
687 _stageEventProcessingFinishedEventHandler(this, null);
691 // Callback for Stage ContextLostSignal
692 private void OnContextLost()
694 if (_stageContextLostEventHandler != null)
696 _stageContextLostEventHandler(this, null);
700 // Callback for Stage ContextRegainedSignal
701 private void OnContextRegained()
703 if (_stageContextRegainedEventHandler != null)
705 _stageContextRegainedEventHandler(this, null);
709 // Callback for Stage SceneCreatedSignal
710 private void OnSceneCreated()
712 if (_stageSceneCreatedEventHandler != null)
714 _stageSceneCreatedEventHandler(this, null);
718 private void OnResized(IntPtr window, IntPtr windowSize)
720 if (window == IntPtr.Zero)
722 NUILog.Error("OnResized() Window is null! Do nothing!");
726 ResizedEventArgs e = new ResizedEventArgs();
727 // var val = new Uint16Pair(windowSize, false);
728 // e.WindowSize = new Size2D(val.GetWidth(), val.GetHeight());
731 // Workaround : windowSize should be valid pointer from dali,
732 // but currenlty it is fixed and is not Uint16Pair class.
733 // will be fixed later.
734 e.WindowSize = this.WindowSize;
736 if (_windowResizeEventHandler != null)
738 _windowResizeEventHandler(this, e);
742 private void OnWindowFocusedChanged2(IntPtr window, bool focusGained)
744 if (window == IntPtr.Zero)
746 NUILog.Error("OnWindowFocusedChanged() Window is null! Do nothing!");
750 FocusChangedEventArgs e = new FocusChangedEventArgs();
752 e.FocusGained = focusGained;
754 if (_windowFocusChangedEventHandler2 != null)
756 _windowFocusChangedEventHandler2(this, e);
760 private void OnTransitionEffect(IntPtr window, int state, int type)
762 if (window == global::System.IntPtr.Zero)
767 TransitionEffectEventArgs e = new TransitionEffectEventArgs();
769 e.State = (EffectState)state;
771 e.Type = (EffectType)type;
773 if (transitionEffectHandler != null)
775 transitionEffectHandler(this, e);
780 private void OnKeyboardRepeatSettingsChanged()
782 if (keyboardRepeatSettingsChangedHandler != null)
784 keyboardRepeatSettingsChangedHandler(this, null);
790 /// The focus changed event argument.
792 /// <since_tizen> 3 </since_tizen>
793 public class FocusChangedEventArgs : EventArgs
796 /// FocusGained flag.
798 /// <since_tizen> 3 </since_tizen>
799 public bool FocusGained
807 /// The touch event argument.
809 /// <since_tizen> 3 </since_tizen>
810 public class TouchEventArgs : EventArgs
812 private Touch _touch;
817 /// <since_tizen> 3 </since_tizen>
832 /// Wheel event arguments.
834 /// <since_tizen> 3 </since_tizen>
835 public class WheelEventArgs : EventArgs
837 private Wheel _wheel;
842 /// <since_tizen> 3 </since_tizen>
857 /// Key event arguments.
859 /// <since_tizen> 3 </since_tizen>
860 public class KeyEventArgs : EventArgs
867 /// <since_tizen> 3 </since_tizen>
882 /// Feeds a key event into the window.
883 /// This resized event arguments.
885 /// <since_tizen> 3 </since_tizen>
886 public class ResizedEventArgs : EventArgs
891 /// This window size.
893 /// <since_tizen> 4 </since_tizen>
894 public Size2D WindowSize
908 /// Please do not use! this will be deprecated
910 /// <since_tizen> 3 </since_tizen>
911 [Obsolete("Please do not use! This will be deprecated! Please use FocusChangedEventArgs instead! " +
913 "NUIApplication.GetDefaultWindow().FocusChanged = OnFocusChanged; " +
914 "private void OnFocusChanged(object source, Window.FocusChangedEventArgs args) {...}")]
915 [EditorBrowsable(EditorBrowsableState.Never)]
916 [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1034:NestedTypesShouldNotBeVisible")]
917 public class WindowFocusChangedEventArgs : EventArgs
920 /// Please do not use! this will be deprecated
922 /// <since_tizen> 3 </since_tizen>
923 public bool FocusGained
931 /// Contains and encapsulates Native Window handle.
933 /// <since_tizen> 4 </since_tizen>
934 public class SafeNativeWindowHandle : SafeHandle
937 /// Contructor, Native window handle is set to handle.
939 /// <since_tizen> 4 </since_tizen>
940 public SafeNativeWindowHandle() : base(IntPtr.Zero, false)
942 SetHandle(NUIApplication.GetDefaultWindow().GetNativeWindowHandler());
945 /// Null check if the handle is valid or not.
947 /// <since_tizen> 4 </since_tizen>
948 public override bool IsInvalid
952 return this.handle == IntPtr.Zero;
956 /// Release handle itself.
958 /// <returns>true when released successfully.</returns>
959 /// <since_tizen> 4 </since_tizen>
960 protected override bool ReleaseHandle()
967 /// TransitionEffectArgs
969 [EditorBrowsable(EditorBrowsableState.Never)]
970 public class TransitionEffectEventArgs : EventArgs
972 private EffectState state;
973 private EffectType type;
978 [EditorBrowsable(EditorBrowsableState.Never)]
979 public EffectState State
993 [EditorBrowsable(EditorBrowsableState.Never)]
994 public EffectType Type
1007 private EventHandler<WheelEventArgs> DetentEventHandler;
1009 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
1010 private delegate void DetentEventCallbackType(IntPtr arg1);
1012 private DetentEventCallbackType DetentEventCallback;
1014 private void OnDetentEvent(IntPtr wheelEvent)
1016 WheelEventArgs e = new WheelEventArgs();
1018 if (wheelEvent != global::System.IntPtr.Zero)
1020 e.Wheel = Wheel.GetWheelFromPtr(wheelEvent);
1023 DetentEventHandler?.Invoke(this, e);
1027 /// VisibilityChangedArgs
1029 [EditorBrowsable(EditorBrowsableState.Never)]
1030 public class VisibilityChangedEventArgs : EventArgs
1032 private bool visibility;
1036 [EditorBrowsable(EditorBrowsableState.Never)]
1037 public bool Visibility
1047 private void OnVisibilityChanged(IntPtr window, bool visibility)
1049 if (window == global::System.IntPtr.Zero)
1051 NUILog.Error("[ERR] OnVisibilityChanged() window is null");
1055 VisibilityChangedEventArgs e = new VisibilityChangedEventArgs();
1056 e.Visibility = visibility;
1057 if (VisibilityChangedEventHandler != null)
1059 VisibilityChangedEventHandler.Invoke(this, e);
1063 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
1064 private delegate void VisibilityChangedEventCallbackType(IntPtr window, bool visibility);
1065 private VisibilityChangedEventCallbackType VisibilityChangedEventCallback;
1066 private event EventHandler<VisibilityChangedEventArgs> VisibilityChangedEventHandler;
1067 private WindowVisibilityChangedEvent VisibilityChangedEventSignal;
1072 [EditorBrowsable(EditorBrowsableState.Never)]
1073 public event EventHandler<VisibilityChangedEventArgs> VisibilityChanged
1077 if (VisibilityChangedEventHandler == null)
1079 VisibilityChangedEventCallback = OnVisibilityChanged;
1080 VisibilityChangedEventSignal = new WindowVisibilityChangedEvent(this);
1081 VisibilityChangedEventSignal.Connect(VisibilityChangedEventCallback);
1083 VisibilityChangedEventHandler += value;
1087 VisibilityChangedEventHandler -= value;
1088 if (VisibilityChangedEventHandler == null)
1090 if (VisibilityChangedEventSignal != null)
1092 if (VisibilityChangedEventSignal.Empty() == false)
1094 VisibilityChangedEventSignal.Disconnect(VisibilityChangedEventCallback);
1102 /// VisibiltyChangedSignalEmit
1104 [EditorBrowsable(EditorBrowsableState.Never)]
1105 public void VisibiltyChangedSignalEmit(bool visibility)
1107 if (VisibilityChangedEventSignal == null)
1109 VisibilityChangedEventSignal = new WindowVisibilityChangedEvent(this);
1111 VisibilityChangedEventSignal.Emit(this, visibility);