[NUI] Integration from dalihub (#1073)
[platform/core/csapi/tizenfx.git] / src / Tizen.NUI / src / public / WindowEvent.cs
1 /*
2  * Copyright(c) 2019 Samsung Electronics Co., Ltd.
3  *
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
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  *
16  */
17
18 using System;
19 using System.ComponentModel;
20 using System.Runtime.InteropServices;
21 using Tizen.NUI.BaseComponents;
22
23 namespace Tizen.NUI
24 {
25     /// <summary>
26     /// The window class is used internally for drawing.<br />
27     /// The window has an orientation and indicator properties.<br />
28     /// </summary>
29     /// <since_tizen> 3 </since_tizen>
30     public partial class Window
31     {
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 WindowResizedEventCallbackType _windowResizedEventCallback;
44         private WindowFocusChangedEventCallbackType _windowFocusChangedEventCallback2;
45         private TransitionEffectEventCallbackType transitionEffectEventCallback;
46         private WindowTransitionEffectSignal transitionEffectSignal;
47
48         [UnmanagedFunctionPointer(CallingConvention.StdCall)]
49         private delegate void WindowFocusChangedEventCallbackType(bool focusGained);
50         [UnmanagedFunctionPointer(CallingConvention.StdCall)]
51         private delegate bool RootLayerTouchDataCallbackType(IntPtr view, IntPtr touchData);
52         [UnmanagedFunctionPointer(CallingConvention.StdCall)]
53         private delegate bool WheelEventCallbackType(IntPtr view, IntPtr wheelEvent);
54         [UnmanagedFunctionPointer(CallingConvention.StdCall)]
55         private delegate void WindowResizedEventCallbackType(IntPtr windowSize);
56         [UnmanagedFunctionPointer(CallingConvention.StdCall)]
57         private delegate void WindowFocusChangedEventCallbackType2(bool focusGained);
58         [UnmanagedFunctionPointer(CallingConvention.StdCall)]
59         private delegate void TransitionEffectEventCallbackType(IntPtr window, int state, int type);
60
61         /// <summary>
62         /// FocusChanged event.
63         /// </summary>
64         /// <since_tizen> 3 </since_tizen>
65         public event EventHandler<FocusChangedEventArgs> FocusChanged
66         {
67             add
68             {
69                 if (_windowFocusChangedEventHandler == null)
70                 {
71                     _windowFocusChangedEventCallback = OnWindowFocusedChanged;
72                     WindowFocusChangedSignal().Connect(_windowFocusChangedEventCallback);
73                 }
74
75                 _windowFocusChangedEventHandler += value;
76             }
77             remove
78             {
79                 _windowFocusChangedEventHandler -= value;
80
81                 if (_windowFocusChangedEventHandler == null && WindowFocusChangedSignal().Empty() == false && _windowFocusChangedEventCallback != null)
82                 {
83                     WindowFocusChangedSignal().Disconnect(_windowFocusChangedEventCallback);
84                 }
85             }
86         }
87
88         /// <summary>
89         /// This event is emitted when the screen is touched and when the touch ends.<br />
90         /// If there are multiple touch points, then this will be emitted when the first touch occurs and
91         /// then when the last finger is lifted.<br />
92         /// An interrupted event will also be emitted (if it occurs).<br />
93         /// </summary>
94         /// <since_tizen> 3 </since_tizen>
95         public event EventHandler<TouchEventArgs> TouchEvent
96         {
97             add
98             {
99                 if (_rootLayerTouchDataEventHandler == null)
100                 {
101                     _rootLayerTouchDataCallback = OnWindowTouch;
102                     this.TouchDataSignal().Connect(_rootLayerTouchDataCallback);
103                 }
104                 _rootLayerTouchDataEventHandler += value;
105             }
106             remove
107             {
108                 _rootLayerTouchDataEventHandler -= value;
109                 if (_rootLayerTouchDataEventHandler == null && TouchSignal().Empty() == false)
110                 {
111                     this.TouchDataSignal().Disconnect(_rootLayerTouchDataCallback);
112                 }
113             }
114         }
115
116         /// <summary>
117         /// This event is emitted when the wheel event is received.
118         /// </summary>
119         /// <since_tizen> 3 </since_tizen>
120         public event EventHandler<WheelEventArgs> WheelEvent
121         {
122             add
123             {
124                 if (_stageWheelHandler == null)
125                 {
126                     _wheelEventCallback = OnStageWheel;
127                     this.StageWheelEventSignal().Connect(_wheelEventCallback);
128                 }
129                 _stageWheelHandler += value;
130             }
131             remove
132             {
133                 _stageWheelHandler -= value;
134                 if (_stageWheelHandler == null && StageWheelEventSignal().Empty() == false)
135                 {
136                     this.StageWheelEventSignal().Disconnect(_wheelEventCallback);
137                 }
138             }
139         }
140
141         /// <summary>
142         /// This event is emitted when the key event is received.
143         /// </summary>
144         /// <since_tizen> 3 </since_tizen>
145         public event EventHandler<KeyEventArgs> KeyEvent
146         {
147             add
148             {
149                 if (_stageKeyHandler == null)
150                 {
151                     _stageKeyCallbackDelegate = OnStageKey;
152                     KeyEventSignal().Connect(_stageKeyCallbackDelegate);
153                 }
154                 _stageKeyHandler += value;
155             }
156             remove
157             {
158                 _stageKeyHandler -= value;
159                 if (_stageKeyHandler == null && KeyEventSignal().Empty() == false)
160                 {
161                     KeyEventSignal().Disconnect(_stageKeyCallbackDelegate);
162                 }
163             }
164         }
165
166         /// <summary>
167         /// This event is emitted when the window resized.
168         /// </summary>
169         /// <since_tizen> 3 </since_tizen>
170         public event EventHandler<ResizedEventArgs> Resized
171         {
172             add
173             {
174                 if (_windowResizedEventHandler == null)
175                 {
176                     _windowResizedEventCallback = OnResized;
177                     ResizedSignal().Connect(_windowResizedEventCallback);
178                 }
179
180                 _windowResizedEventHandler += value;
181             }
182             remove
183             {
184                 _windowResizedEventHandler -= value;
185
186                 if (_windowResizedEventHandler == null && ResizedSignal().Empty() == false && _windowResizedEventCallback != null)
187                 {
188                     ResizedSignal().Disconnect(_windowResizedEventCallback);
189                 }
190             }
191         }
192
193         /// <summary>
194         /// Please do not use! this will be deprecated. Please use 'FocusChanged' event instead.
195         /// </summary>
196         /// <since_tizen> 3 </since_tizen>
197         /// Please do not use! this will be deprecated!
198         /// Instead please use FocusChanged.
199         [Obsolete("Please do not use! This will be deprecated! Please use FocusChanged instead! " +
200             "Like: " +
201             "Window.Instance.FocusChanged = OnFocusChanged; " +
202             "private void OnFocusChanged(object source, Window.FocusChangedEventArgs args) {...}")]
203         [EditorBrowsable(EditorBrowsableState.Never)]
204         public event EventHandler<FocusChangedEventArgs> WindowFocusChanged
205         {
206             add
207             {
208                 if (_windowFocusChangedEventHandler2 == null)
209                 {
210                     _windowFocusChangedEventCallback2 = OnWindowFocusedChanged2;
211                     WindowFocusChangedSignal().Connect(_windowFocusChangedEventCallback2);
212                 }
213
214                 _windowFocusChangedEventHandler2 += value;
215             }
216             remove
217             {
218                 _windowFocusChangedEventHandler2 -= value;
219
220                 if (_windowFocusChangedEventHandler2 == null && WindowFocusChangedSignal().Empty() == false && _windowFocusChangedEventCallback2 != null)
221                 {
222                     WindowFocusChangedSignal().Disconnect(_windowFocusChangedEventCallback2);
223                 }
224             }
225         }
226
227         /// <summary>
228         /// EffectStart
229         /// </summary>
230         [EditorBrowsable(EditorBrowsableState.Never)]
231         public event EventHandler<TransitionEffectArgs> TransitionEffect
232         {
233             add
234             {
235                 if (transitionEffectHandler == null)
236                 {
237                     transitionEffectEventCallback = OnTransitionEffect;
238                     TransitionEffectEventSignal().Connect(transitionEffectEventCallback);
239                 }
240                 transitionEffectHandler += value;
241             }
242             remove
243             {
244                 transitionEffectHandler -= value;
245                 if (transitionEffectHandler == null && TransitionEffectEventSignal().Empty() == false)
246                 {
247                     TransitionEffectEventSignal().Disconnect(transitionEffectEventCallback);
248                 }
249             }
250         }
251
252         /// <summary>
253         /// ViewAdded will be triggered when the view added on Window
254         /// </summary>
255         /// <since_tizen> 6 </since_tizen>
256         /// This will be public opened in tizen_5.5 after ACR done. Before ACR, need to be hidden as inhouse API.
257         [EditorBrowsable(EditorBrowsableState.Never)]
258         public event EventHandler ViewAdded;
259         private event EventHandler<FocusChangedEventArgs> _windowFocusChangedEventHandler;
260         private event EventHandler<TouchEventArgs> _rootLayerTouchDataEventHandler;
261         private event EventHandler<WheelEventArgs> _stageWheelHandler;
262         private event EventHandler<KeyEventArgs> _stageKeyHandler;
263         private event EventHandler _stageEventProcessingFinishedEventHandler;
264         private event EventHandler<ResizedEventArgs> _windowResizedEventHandler;
265         private event EventHandler<FocusChangedEventArgs> _windowFocusChangedEventHandler2;
266         private event EventHandler<TransitionEffectArgs> transitionEffectHandler;
267
268         internal void SendViewAdded(View view)
269         {
270             ViewAdded?.Invoke(view, EventArgs.Empty);
271         }
272
273         internal event EventHandler EventProcessingFinished
274         {
275             add
276             {
277                 if (_stageEventProcessingFinishedEventHandler == null)
278                 {
279                     _stageEventProcessingFinishedEventCallbackDelegate = OnEventProcessingFinished;
280                     EventProcessingFinishedSignal().Connect(_stageEventProcessingFinishedEventCallbackDelegate);
281                 }
282                 _stageEventProcessingFinishedEventHandler += value;
283
284             }
285             remove
286             {
287                 _stageEventProcessingFinishedEventHandler -= value;
288                 if (_stageEventProcessingFinishedEventHandler == null && EventProcessingFinishedSignal().Empty() == false)
289                 {
290                     EventProcessingFinishedSignal().Disconnect(_stageEventProcessingFinishedEventCallbackDelegate);
291                 }
292             }
293         }
294
295         internal event EventHandler ContextLost
296         {
297             add
298             {
299                 if (_stageContextLostEventHandler == null)
300                 {
301                     _stageContextLostEventCallbackDelegate = OnContextLost;
302                     ContextLostSignal().Connect(_stageContextLostEventCallbackDelegate);
303                 }
304                 _stageContextLostEventHandler += value;
305             }
306             remove
307             {
308                 _stageContextLostEventHandler -= value;
309                 if (_stageContextLostEventHandler == null && ContextLostSignal().Empty() == false)
310                 {
311                     ContextLostSignal().Disconnect(_stageContextLostEventCallbackDelegate);
312                 }
313             }
314         }
315
316         internal event EventHandler ContextRegained
317         {
318             add
319             {
320                 if (_stageContextRegainedEventHandler == null)
321                 {
322                     _stageContextRegainedEventCallbackDelegate = OnContextRegained;
323                     ContextRegainedSignal().Connect(_stageContextRegainedEventCallbackDelegate);
324                 }
325                 _stageContextRegainedEventHandler += value;
326             }
327             remove
328             {
329                 _stageContextRegainedEventHandler -= value;
330                 if (_stageContextRegainedEventHandler == null && ContextRegainedSignal().Empty() == false)
331                 {
332                     this.ContextRegainedSignal().Disconnect(_stageContextRegainedEventCallbackDelegate);
333                 }
334             }
335         }
336
337         internal event EventHandler SceneCreated
338         {
339             add
340             {
341                 if (_stageSceneCreatedEventHandler == null)
342                 {
343                     _stageSceneCreatedEventCallbackDelegate = OnSceneCreated;
344                     SceneCreatedSignal().Connect(_stageSceneCreatedEventCallbackDelegate);
345                 }
346                 _stageSceneCreatedEventHandler += value;
347             }
348             remove
349             {
350                 _stageSceneCreatedEventHandler -= value;
351                 if (_stageSceneCreatedEventHandler == null && SceneCreatedSignal().Empty() == false)
352                 {
353                     SceneCreatedSignal().Disconnect(_stageSceneCreatedEventCallbackDelegate);
354                 }
355             }
356         }
357
358         internal WindowFocusSignalType WindowFocusChangedSignal()
359         {
360             WindowFocusSignalType ret = new WindowFocusSignalType(Interop.Window.FocusChangedSignal(swigCPtr), false);
361             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
362             return ret;
363         }
364
365         internal WindowFocusSignalType FocusChangedSignal()
366         {
367             WindowFocusSignalType ret = new WindowFocusSignalType(Interop.Window.FocusChangedSignal(swigCPtr), false);
368             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
369             return ret;
370         }
371
372         internal KeyEventSignal KeyEventSignal()
373         {
374             KeyEventSignal ret = new KeyEventSignal(Interop.Window.KeyEventSignal(swigCPtr), false);
375             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
376             return ret;
377         }
378
379         internal VoidSignal EventProcessingFinishedSignal()
380         {
381             VoidSignal ret = new VoidSignal(Interop.StageSignal.Stage_EventProcessingFinishedSignal(stageCPtr), false);
382             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
383             return ret;
384         }
385
386         internal TouchSignal TouchSignal()
387         {
388             TouchSignal ret = new TouchSignal(Interop.Window.TouchSignal(swigCPtr), false);
389             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
390             return ret;
391         }
392
393         internal TouchDataSignal TouchDataSignal()
394         {
395             TouchDataSignal ret = new TouchDataSignal(Interop.ActorSignal.Actor_TouchSignal(Layer.getCPtr(GetRootLayer())), false);
396             if (NDalicPINVOKE.SWIGPendingException.Pending)
397                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
398             return ret;
399         }
400
401         internal VoidSignal ContextLostSignal()
402         {
403             VoidSignal ret = new VoidSignal(Interop.StageSignal.Stage_ContextLostSignal(stageCPtr), false);
404             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
405             return ret;
406         }
407
408         internal VoidSignal ContextRegainedSignal()
409         {
410             VoidSignal ret = new VoidSignal(Interop.StageSignal.Stage_ContextRegainedSignal(stageCPtr), false);
411             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
412             return ret;
413         }
414
415         internal VoidSignal SceneCreatedSignal()
416         {
417             VoidSignal ret = new VoidSignal(Interop.StageSignal.Stage_SceneCreatedSignal(stageCPtr), false);
418             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
419             return ret;
420         }
421
422         internal ResizedSignal ResizedSignal()
423         {
424             ResizedSignal ret = new ResizedSignal(Interop.Window.Window_ResizedSignal(swigCPtr), false);
425             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
426             return ret;
427         }
428
429         internal System.IntPtr GetNativeWindowHandler()
430         {
431             System.IntPtr ret = Interop.Window.GetNativeWindowHandler(HandleRef.ToIntPtr(this.swigCPtr));
432             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
433             return ret;
434         }
435
436         /// <summary>
437         /// Disconnect all native signals
438         /// </summary>
439         /// <since_tizen> 5 </since_tizen>
440         internal void DisconnectNativeSignals()
441         {
442             if (_windowFocusChangedEventCallback != null)
443             {
444                 WindowFocusChangedSignal().Disconnect(_windowFocusChangedEventCallback);
445             }
446
447             if (_rootLayerTouchDataCallback != null)
448             {
449                 TouchDataSignal().Disconnect(_rootLayerTouchDataCallback);
450             }
451
452             if (_wheelEventCallback != null)
453             {
454                 StageWheelEventSignal().Disconnect(_wheelEventCallback);
455             }
456
457             if (_stageKeyCallbackDelegate != null)
458             {
459                 KeyEventSignal().Disconnect(_stageKeyCallbackDelegate);
460             }
461
462             if (_stageEventProcessingFinishedEventCallbackDelegate != null)
463             {
464                 EventProcessingFinishedSignal().Disconnect(_stageEventProcessingFinishedEventCallbackDelegate);
465             }
466
467             if (_stageContextLostEventCallbackDelegate != null)
468             {
469                 ContextLostSignal().Disconnect(_stageContextLostEventCallbackDelegate);
470             }
471
472             if (_stageContextRegainedEventCallbackDelegate != null)
473             {
474                 ContextRegainedSignal().Disconnect(_stageContextRegainedEventCallbackDelegate);
475             }
476
477             if (_stageSceneCreatedEventCallbackDelegate != null)
478             {
479                 SceneCreatedSignal().Disconnect(_stageSceneCreatedEventCallbackDelegate);
480             }
481
482             if (_windowResizedEventCallback != null)
483             {
484                 ResizedSignal().Disconnect(_windowResizedEventCallback);
485             }
486
487             if (_windowFocusChangedEventCallback2 != null)
488             {
489                 WindowFocusChangedSignal().Disconnect(_windowFocusChangedEventCallback2);
490             }
491
492             if (transitionEffectSignal != null)
493             {
494                 TransitionEffectEventSignal().Disconnect(transitionEffectEventCallback);
495             }
496         }
497
498         private StageWheelSignal WheelEventSignal()
499         {
500             StageWheelSignal ret = new StageWheelSignal(Interop.StageSignal.Stage_WheelEventSignal(stageCPtr), false);
501             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
502             return ret;
503         }
504
505         private WheelSignal StageWheelEventSignal()
506         {
507             WheelSignal ret = new WheelSignal(Interop.ActorSignal.Actor_WheelEventSignal(Layer.getCPtr(this.GetRootLayer())), false);
508             if (NDalicPINVOKE.SWIGPendingException.Pending)
509                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
510             return ret;
511         }
512
513         private WindowTransitionEffectSignal TransitionEffectEventSignal()
514         {
515             //Tizen.Log.Fatal("NUITEST", "TransitionEffectEventSignal()!");
516             if (transitionEffectSignal == null)
517             {
518                 transitionEffectSignal = new WindowTransitionEffectSignal(this);
519                 if (NDalicPINVOKE.SWIGPendingException.Pending)
520                     throw NDalicPINVOKE.SWIGPendingException.Retrieve();
521                 //Tizen.Log.Fatal("NUITEST", $"transitionEffectSignal is null, new here!");
522             }
523             return transitionEffectSignal;
524         }
525
526         private void OnWindowFocusedChanged(bool focusGained)
527         {
528             FocusChangedEventArgs e = new FocusChangedEventArgs();
529
530             e.FocusGained = focusGained;
531
532             if (_windowFocusChangedEventHandler != null)
533             {
534                 _windowFocusChangedEventHandler(this, e);
535             }
536         }
537
538         private bool OnWindowTouch(IntPtr view, IntPtr touchData)
539         {
540             if (touchData == global::System.IntPtr.Zero)
541             {
542                 NUILog.Error("touchData should not be null!");
543                 return false;
544             }
545
546             TouchEventArgs e = new TouchEventArgs();
547
548             e.Touch = Tizen.NUI.Touch.GetTouchFromPtr(touchData);
549
550             if (_rootLayerTouchDataEventHandler != null)
551             {
552                 _rootLayerTouchDataEventHandler(this, e);
553             }
554             return false;
555         }
556
557         private bool OnStageWheel(IntPtr rootLayer, IntPtr wheelEvent)
558         {
559             if (wheelEvent == global::System.IntPtr.Zero)
560             {
561                 NUILog.Error("wheelEvent should not be null!");
562                 return true;
563             }
564
565             WheelEventArgs e = new WheelEventArgs();
566
567             e.Wheel = Tizen.NUI.Wheel.GetWheelFromPtr(wheelEvent);
568
569             if (_stageWheelHandler != null)
570             {
571                 _stageWheelHandler(this, e);
572             }
573             return true;
574         }
575
576         // Callback for Stage KeyEventsignal
577         private void OnStageKey(IntPtr data)
578         {
579             KeyEventArgs e = new KeyEventArgs();
580             e.Key = Tizen.NUI.Key.GetKeyFromPtr(data);
581
582
583             if (_stageKeyHandler != null)
584             {
585                 //here we send all data to user event handlers
586                 _stageKeyHandler(this, e);
587             }
588         }
589
590         // Callback for Stage EventProcessingFinishedSignal
591         private void OnEventProcessingFinished()
592         {
593             if (_stageEventProcessingFinishedEventHandler != null)
594             {
595                 _stageEventProcessingFinishedEventHandler(this, null);
596             }
597         }
598
599         // Callback for Stage ContextLostSignal
600         private void OnContextLost()
601         {
602             if (_stageContextLostEventHandler != null)
603             {
604                 _stageContextLostEventHandler(this, null);
605             }
606         }
607
608         // Callback for Stage ContextRegainedSignal
609         private void OnContextRegained()
610         {
611             if (_stageContextRegainedEventHandler != null)
612             {
613                 _stageContextRegainedEventHandler(this, null);
614             }
615         }
616
617         // Callback for Stage SceneCreatedSignal
618         private void OnSceneCreated()
619         {
620             if (_stageSceneCreatedEventHandler != null)
621             {
622                 _stageSceneCreatedEventHandler(this, null);
623             }
624         }
625
626         private void OnResized(IntPtr windowSize)
627         {
628             ResizedEventArgs e = new ResizedEventArgs();
629             var val = new Uint16Pair(windowSize, false);
630             e.WindowSize = new Size2D(val.GetWidth(), val.GetHeight());
631             val.Dispose();
632
633             if (_windowResizedEventHandler != null)
634             {
635                 _windowResizedEventHandler(this, e);
636             }
637         }
638
639         private void OnWindowFocusedChanged2(bool focusGained)
640         {
641             FocusChangedEventArgs e = new FocusChangedEventArgs();
642
643             e.FocusGained = focusGained;
644
645             if (_windowFocusChangedEventHandler2 != null)
646             {
647                 _windowFocusChangedEventHandler2(this, e);
648             }
649         }
650
651         private void OnTransitionEffect(IntPtr window, int state, int type)
652         {
653             //Tizen.Log.Fatal("NUITEST", $"OnTransitionEffect() called");
654             if (window == global::System.IntPtr.Zero)
655             {
656                 //Tizen.Log.Error("NUI", $"OnTransitionEffect() IntPtr window is null!");
657                 return;
658             }
659
660             TransitionEffectArgs e = new TransitionEffectArgs();
661
662             e.State = (EffectStates)state;
663             //Tizen.Log.Error("NUITEST", $"e.State={e.State}");
664
665             e.Type = (EffectTypes)type;
666             //Tizen.Log.Error("NUITEST", $"e.Type={e.Type}");
667
668             if (transitionEffectHandler != null)
669             {
670                 //Tizen.Log.Fatal("NUITEST", $"Execute transitionEffectHandler(this, e)!!!");
671                 transitionEffectHandler(this, e);
672             }
673             return;
674         }
675
676         /// <summary>
677         /// The focus changed event argument.
678         /// </summary>
679         /// <since_tizen> 3 </since_tizen>
680         public class FocusChangedEventArgs : EventArgs
681         {
682             /// <summary>
683             /// FocusGained flag.
684             /// </summary>
685             /// <since_tizen> 3 </since_tizen>
686             public bool FocusGained
687             {
688                 get;
689                 set;
690             }
691         }
692
693         /// <summary>
694         /// The touch event argument.
695         /// </summary>
696         /// <since_tizen> 3 </since_tizen>
697         public class TouchEventArgs : EventArgs
698         {
699             private Touch _touch;
700
701             /// <summary>
702             /// Touch.
703             /// </summary>
704             /// <since_tizen> 3 </since_tizen>
705             public Touch Touch
706             {
707                 get
708                 {
709                     return _touch;
710                 }
711                 set
712                 {
713                     _touch = value;
714                 }
715             }
716         }
717
718         /// <summary>
719         /// Wheel event arguments.
720         /// </summary>
721         /// <since_tizen> 3 </since_tizen>
722         public class WheelEventArgs : EventArgs
723         {
724             private Wheel _wheel;
725
726             /// <summary>
727             /// Wheel.
728             /// </summary>
729             /// <since_tizen> 3 </since_tizen>
730             public Wheel Wheel
731             {
732                 get
733                 {
734                     return _wheel;
735                 }
736                 set
737                 {
738                     _wheel = value;
739                 }
740             }
741         }
742
743         /// <summary>
744         /// Key event arguments.
745         /// </summary>
746         /// <since_tizen> 3 </since_tizen>
747         public class KeyEventArgs : EventArgs
748         {
749             private Key _key;
750
751             /// <summary>
752             /// Key.
753             /// </summary>
754             /// <since_tizen> 3 </since_tizen>
755             public Key Key
756             {
757                 get
758                 {
759                     return _key;
760                 }
761                 set
762                 {
763                     _key = value;
764                 }
765             }
766         }
767
768         /// <summary>
769         /// Feeds a key event into the window.
770         /// This resized event arguments.
771         /// </summary>
772         /// <since_tizen> 3 </since_tizen>
773         public class ResizedEventArgs : EventArgs
774         {
775             Size2D _windowSize;
776
777             /// <summary>
778             /// This window size.
779             /// </summary>
780             /// <since_tizen> 4 </since_tizen>
781             public Size2D WindowSize
782             {
783                 get
784                 {
785                     return _windowSize;
786                 }
787                 set
788                 {
789                     _windowSize = value;
790                 }
791             }
792         }
793
794         /// <summary>
795         /// Please do not use! this will be deprecated
796         /// </summary>
797         /// <since_tizen> 3 </since_tizen>
798         [Obsolete("Please do not use! This will be deprecated! Please use FocusChangedEventArgs instead! " +
799             "Like: " +
800             "Window.Instance.FocusChanged = OnFocusChanged; " +
801             "private void OnFocusChanged(object source, Window.FocusChangedEventArgs args) {...}")]
802         [EditorBrowsable(EditorBrowsableState.Never)]
803         public class WindowFocusChangedEventArgs : EventArgs
804         {
805             /// <summary>
806             /// Please do not use! this will be deprecated
807             /// </summary>
808             /// <since_tizen> 3 </since_tizen>
809             public bool FocusGained
810             {
811                 get;
812                 set;
813             }
814         }
815
816         /// <summary>
817         /// Contains and encapsulates Native Window handle.
818         /// </summary>
819         /// <since_tizen> 4 </since_tizen>
820         public class SafeNativeWindowHandle : SafeHandle
821         {
822             /// <summary>
823             /// Contructor, Native window handle is set to handle.
824             /// </summary>
825             /// <since_tizen> 4 </since_tizen>
826             public SafeNativeWindowHandle() : base(IntPtr.Zero, false)
827             {
828                 SetHandle(Tizen.NUI.Window.Instance.GetNativeWindowHandler());
829             }
830             /// <summary>
831             /// Null check if the handle is valid or not.
832             /// </summary>
833             /// <since_tizen> 4 </since_tizen>
834             public override bool IsInvalid
835             {
836                 get
837                 {
838                     return this.handle == IntPtr.Zero;
839                 }
840             }
841             /// <summary>
842             /// Release handle itself.
843             /// </summary>
844             /// <returns>true when released successfully.</returns>
845             /// <since_tizen> 4 </since_tizen>
846             protected override bool ReleaseHandle()
847             {
848                 return true;
849             }
850         }
851
852         /// <summary>
853         /// TransitionEffectArgs
854         /// </summary>
855         [EditorBrowsable(EditorBrowsableState.Never)]
856         public class TransitionEffectArgs : EventArgs
857         {
858             private EffectStates state;
859             private EffectTypes type;
860
861             /// <summary>
862             /// State
863             /// </summary>
864             [EditorBrowsable(EditorBrowsableState.Never)]
865             public EffectStates State
866             {
867                 get
868                 {
869                     return state;
870                 }
871                 set
872                 {
873                     state = value;
874                 }
875             }
876             /// <summary>
877             /// Type
878             /// </summary>
879             [EditorBrowsable(EditorBrowsableState.Never)]
880             public EffectTypes Type
881             {
882                 get
883                 {
884                     return type;
885                 }
886                 set
887                 {
888                     type = value;
889                 }
890             }
891         }
892     }
893 }