[NUI] Implement shadow in View (#1223)
[platform/core/csapi/tizenfx.git] / src / Tizen.NUI / src / public / BaseComponents / ViewEvent.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.Runtime.InteropServices;
20
21 namespace Tizen.NUI.BaseComponents
22 {
23     /// <summary>
24     /// View is the base class for all views.
25     /// </summary>
26     /// <since_tizen> 3 </since_tizen>
27     public partial class View
28     {
29         private EventHandler _offWindowEventHandler;
30         private OffWindowEventCallbackType _offWindowEventCallback;
31         private EventHandlerWithReturnType<object, WheelEventArgs, bool> _wheelEventHandler;
32         private WheelEventCallbackType _wheelEventCallback;
33         private EventHandlerWithReturnType<object, KeyEventArgs, bool> _keyEventHandler;
34         private KeyCallbackType _keyCallback;
35         private EventHandlerWithReturnType<object, TouchEventArgs, bool> _touchDataEventHandler;
36         private TouchDataCallbackType _touchDataCallback;
37         private EventHandlerWithReturnType<object, HoverEventArgs, bool> _hoverEventHandler;
38         private HoverEventCallbackType _hoverEventCallback;
39         private EventHandler<VisibilityChangedEventArgs> _visibilityChangedEventHandler;
40         private VisibilityChangedEventCallbackType _visibilityChangedEventCallback;
41         private EventHandler _keyInputFocusGainedEventHandler;
42         private KeyInputFocusGainedCallbackType _keyInputFocusGainedCallback;
43         private EventHandler _keyInputFocusLostEventHandler;
44         private KeyInputFocusLostCallbackType _keyInputFocusLostCallback;
45         private EventHandler _onRelayoutEventHandler;
46         private OnRelayoutEventCallbackType _onRelayoutEventCallback;
47         private EventHandler _onWindowEventHandler;
48         private OnWindowEventCallbackType _onWindowEventCallback;
49         private EventHandler<LayoutDirectionChangedEventArgs> _layoutDirectionChangedEventHandler;
50         private LayoutDirectionChangedEventCallbackType _layoutDirectionChangedEventCallback;
51         // Resource Ready Signal
52         private EventHandler _resourcesLoadedEventHandler;
53         private ResourcesLoadedCallbackType _ResourcesLoadedCallback;
54         private EventHandler<BackgroundResourceLoadedEventArgs> _backgroundResourceLoadedEventHandler;
55         private _backgroundResourceLoadedCallbackType _backgroundResourceLoadedCallback;
56
57         private OnWindowEventCallbackType _onWindowSendEventCallback;
58
59         private void SendViewAddedEventToWindow(IntPtr data)
60         {
61             Window.Instance?.SendViewAdded(this);
62         }
63
64         [UnmanagedFunctionPointer(CallingConvention.StdCall)]
65         private delegate void OffWindowEventCallbackType(IntPtr control);
66         [UnmanagedFunctionPointer(CallingConvention.StdCall)]
67         private delegate bool WheelEventCallbackType(IntPtr view, IntPtr wheelEvent);
68         [UnmanagedFunctionPointer(CallingConvention.StdCall)]
69         private delegate bool KeyCallbackType(IntPtr control, IntPtr keyEvent);
70         [UnmanagedFunctionPointer(CallingConvention.StdCall)]
71         private delegate bool TouchDataCallbackType(IntPtr view, IntPtr touchData);
72         [UnmanagedFunctionPointer(CallingConvention.StdCall)]
73         private delegate bool HoverEventCallbackType(IntPtr view, IntPtr hoverEvent);
74         [UnmanagedFunctionPointer(CallingConvention.StdCall)]
75         private delegate void VisibilityChangedEventCallbackType(IntPtr data, bool visibility, VisibilityChangeType type);
76         [UnmanagedFunctionPointer(CallingConvention.StdCall)]
77         private delegate void ResourcesLoadedCallbackType(IntPtr control);
78         [UnmanagedFunctionPointer(CallingConvention.StdCall)]
79         private delegate void _backgroundResourceLoadedCallbackType(IntPtr view);
80         [UnmanagedFunctionPointer(CallingConvention.StdCall)]
81         private delegate void KeyInputFocusGainedCallbackType(IntPtr control);
82         [UnmanagedFunctionPointer(CallingConvention.StdCall)]
83         private delegate void KeyInputFocusLostCallbackType(IntPtr control);
84         [UnmanagedFunctionPointer(CallingConvention.StdCall)]
85         private delegate void OnRelayoutEventCallbackType(IntPtr control);
86         [UnmanagedFunctionPointer(CallingConvention.StdCall)]
87         private delegate void OnWindowEventCallbackType(IntPtr control);
88         [UnmanagedFunctionPointer(CallingConvention.StdCall)]
89         private delegate void LayoutDirectionChangedEventCallbackType(IntPtr data, ViewLayoutDirectionType type);
90
91         /// <summary>
92         /// Event when a child is removed.
93         /// </summary>
94         /// <since_tizen> 5 </since_tizen>
95         public new event EventHandler<ChildRemovedEventArgs> ChildRemoved;
96         /// <summary>
97         /// Event when a child is added.
98         /// </summary>
99         /// <since_tizen> 5 </since_tizen>
100         public new event EventHandler<ChildAddedEventArgs> ChildAdded;
101
102         /// <summary>
103         /// An event for the KeyInputFocusGained signal which can be used to subscribe or unsubscribe the event handler provided by the user.<br />
104         /// The KeyInputFocusGained signal is emitted when the control gets the key input focus.<br />
105         /// </summary>
106         /// <since_tizen> 3 </since_tizen>
107         public event EventHandler FocusGained
108         {
109             add
110             {
111                 if (_keyInputFocusGainedEventHandler == null)
112                 {
113                     _keyInputFocusGainedCallback = OnKeyInputFocusGained;
114                     this.KeyInputFocusGainedSignal().Connect(_keyInputFocusGainedCallback);
115                 }
116
117                 _keyInputFocusGainedEventHandler += value;
118             }
119
120             remove
121             {
122                 _keyInputFocusGainedEventHandler -= value;
123
124                 if (_keyInputFocusGainedEventHandler == null && KeyInputFocusGainedSignal().Empty() == false)
125                 {
126                     this.KeyInputFocusGainedSignal().Disconnect(_keyInputFocusGainedCallback);
127                 }
128             }
129         }
130
131         /// <summary>
132         /// An event for the KeyInputFocusLost signal which can be used to subscribe or unsubscribe the event handler provided by the user.<br />
133         /// The KeyInputFocusLost signal is emitted when the control loses the key input focus.<br />
134         /// </summary>
135         /// <since_tizen> 3 </since_tizen>
136         public event EventHandler FocusLost
137         {
138             add
139             {
140                 if (_keyInputFocusLostEventHandler == null)
141                 {
142                     _keyInputFocusLostCallback = OnKeyInputFocusLost;
143                     this.KeyInputFocusLostSignal().Connect(_keyInputFocusLostCallback);
144                 }
145
146                 _keyInputFocusLostEventHandler += value;
147             }
148
149             remove
150             {
151                 _keyInputFocusLostEventHandler -= value;
152
153                 if (_keyInputFocusLostEventHandler == null && KeyInputFocusLostSignal().Empty() == false)
154                 {
155                     this.KeyInputFocusLostSignal().Disconnect(_keyInputFocusLostCallback);
156                 }
157             }
158         }
159
160         /// <summary>
161         /// An event for the KeyPressed signal which can be used to subscribe or unsubscribe the event handler provided by the user.<br />
162         /// The KeyPressed signal is emitted when the key event is received.<br />
163         /// </summary>
164         /// <since_tizen> 3 </since_tizen>
165         public event EventHandlerWithReturnType<object, KeyEventArgs, bool> KeyEvent
166         {
167             add
168             {
169                 if (_keyEventHandler == null)
170                 {
171                     _keyCallback = OnKeyEvent;
172                     this.KeyEventSignal().Connect(_keyCallback);
173                 }
174
175                 _keyEventHandler += value;
176             }
177
178             remove
179             {
180                 _keyEventHandler -= value;
181
182                 if (_keyEventHandler == null && KeyEventSignal().Empty() == false)
183                 {
184                     this.KeyEventSignal().Disconnect(_keyCallback);
185                 }
186             }
187         }
188
189         /// <summary>
190         /// An event for the OnRelayout signal which can be used to subscribe or unsubscribe the event handler.<br />
191         /// The OnRelayout signal is emitted after the size has been set on the view during relayout.<br />
192         /// </summary>
193         /// <since_tizen> 3 </since_tizen>
194         public event EventHandler Relayout
195         {
196             add
197             {
198                 if (_onRelayoutEventHandler == null)
199                 {
200                     _onRelayoutEventCallback = OnRelayout;
201                     this.OnRelayoutSignal().Connect(_onRelayoutEventCallback);
202                 }
203
204                 _onRelayoutEventHandler += value;
205             }
206
207             remove
208             {
209                 _onRelayoutEventHandler -= value;
210
211                 if (_onRelayoutEventHandler == null && OnRelayoutSignal().Empty() == false)
212                 {
213                     this.OnRelayoutSignal().Disconnect(_onRelayoutEventCallback);
214                 }
215
216             }
217         }
218
219         /// <summary>
220         /// An event for the touched signal which can be used to subscribe or unsubscribe the event handler provided by the user.<br />
221         /// The touched signal is emitted when the touch input is received.<br />
222         /// </summary>
223         /// <since_tizen> 3 </since_tizen>
224         public event EventHandlerWithReturnType<object, TouchEventArgs, bool> TouchEvent
225         {
226             add
227             {
228                 if (_touchDataEventHandler == null)
229                 {
230                     _touchDataCallback = OnTouch;
231                     this.TouchSignal().Connect(_touchDataCallback);
232                 }
233
234                 _touchDataEventHandler += value;
235             }
236
237             remove
238             {
239                 _touchDataEventHandler -= value;
240
241                 if (_touchDataEventHandler == null && TouchSignal().Empty() == false)
242                 {
243                     this.TouchSignal().Disconnect(_touchDataCallback);
244                 }
245
246             }
247         }
248
249         /// <summary>
250         /// An event for the hovered signal which can be used to subscribe or unsubscribe the event handler provided by the user.<br />
251         /// The hovered signal is emitted when the hover input is received.<br />
252         /// </summary>
253         /// <since_tizen> 3 </since_tizen>
254         public event EventHandlerWithReturnType<object, HoverEventArgs, bool> HoverEvent
255         {
256             add
257             {
258                 if (_hoverEventHandler == null)
259                 {
260                     _hoverEventCallback = OnHoverEvent;
261                     this.HoveredSignal().Connect(_hoverEventCallback);
262                 }
263
264                 _hoverEventHandler += value;
265             }
266
267             remove
268             {
269                 _hoverEventHandler -= value;
270
271                 if (_hoverEventHandler == null && HoveredSignal().Empty() == false)
272                 {
273                     this.HoveredSignal().Disconnect(_hoverEventCallback);
274                 }
275
276             }
277         }
278
279         /// <summary>
280         /// An event for the WheelMoved signal which can be used to subscribe or unsubscribe the event handler provided by the user.<br />
281         /// The WheelMoved signal is emitted when the wheel event is received.<br />
282         /// </summary>
283         /// <since_tizen> 3 </since_tizen>
284         public event EventHandlerWithReturnType<object, WheelEventArgs, bool> WheelEvent
285         {
286             add
287             {
288                 if (_wheelEventHandler == null)
289                 {
290                     _wheelEventCallback = OnWheelEvent;
291                     this.WheelEventSignal().Connect(_wheelEventCallback);
292                 }
293
294                 _wheelEventHandler += value;
295             }
296
297             remove
298             {
299                 _wheelEventHandler -= value;
300
301                 if (_wheelEventHandler == null && WheelEventSignal().Empty() == false)
302                 {
303                     this.WheelEventSignal().Disconnect(_wheelEventCallback);
304                 }
305
306             }
307         }
308
309         /// <summary>
310         /// An event for the OnWindow signal which can be used to subscribe or unsubscribe the event handler.<br />
311         /// The OnWindow signal is emitted after the view has been connected to the window.<br />
312         /// </summary>
313         /// <since_tizen> 3 </since_tizen>
314         public event EventHandler AddedToWindow
315         {
316             add
317             {
318                 if (_onWindowEventHandler == null)
319                 {
320                     _onWindowEventCallback = OnWindow;
321                     this.OnWindowSignal().Connect(_onWindowEventCallback);
322                 }
323
324                 _onWindowEventHandler += value;
325             }
326
327             remove
328             {
329                 _onWindowEventHandler -= value;
330
331                 if (_onWindowEventHandler == null && OnWindowSignal().Empty() == false)
332                 {
333                     this.OnWindowSignal().Disconnect(_onWindowEventCallback);
334                 }
335             }
336         }
337
338         /// <summary>
339         /// An event for the OffWindow signal, which can be used to subscribe or unsubscribe the event handler.<br />
340         /// OffWindow signal is emitted after the view has been disconnected from the window.<br />
341         /// </summary>
342         /// <since_tizen> 3 </since_tizen>
343         public event EventHandler RemovedFromWindow
344         {
345             add
346             {
347                 if (_offWindowEventHandler == null)
348                 {
349                     _offWindowEventCallback = OffWindow;
350                     this.OffWindowSignal().Connect(_offWindowEventCallback);
351                 }
352
353                 _offWindowEventHandler += value;
354             }
355
356             remove
357             {
358                 _offWindowEventHandler -= value;
359
360                 if (_offWindowEventHandler == null && OffWindowSignal().Empty() == false)
361                 {
362                     this.OffWindowSignal().Disconnect(_offWindowEventCallback);
363                 }
364             }
365         }
366
367         /// <summary>
368         /// An event for visibility change which can be used to subscribe or unsubscribe the event handler.<br />
369         /// This signal is emitted when the visible property of this or a parent view is changed.<br />
370         /// </summary>
371         /// <since_tizen> 3 </since_tizen>
372         public event EventHandler<VisibilityChangedEventArgs> VisibilityChanged
373         {
374             add
375             {
376                 if (_visibilityChangedEventHandler == null)
377                 {
378                     _visibilityChangedEventCallback = OnVisibilityChanged;
379                     VisibilityChangedSignal(this).Connect(_visibilityChangedEventCallback);
380                 }
381
382                 _visibilityChangedEventHandler += value;
383             }
384
385             remove
386             {
387                 _visibilityChangedEventHandler -= value;
388
389                 if (_visibilityChangedEventHandler == null && VisibilityChangedSignal(this).Empty() == false)
390                 {
391                     VisibilityChangedSignal(this).Disconnect(_visibilityChangedEventCallback);
392                 }
393             }
394         }
395
396         /// <summary>
397         /// Event for layout direction change which can be used to subscribe/unsubscribe the event handler.<br />
398         /// This signal is emitted when the layout direction property of this or a parent view is changed.<br />
399         /// </summary>
400         /// <since_tizen> 4 </since_tizen>
401         public event EventHandler<LayoutDirectionChangedEventArgs> LayoutDirectionChanged
402         {
403             add
404             {
405                 if (_layoutDirectionChangedEventHandler == null)
406                 {
407                     _layoutDirectionChangedEventCallback = OnLayoutDirectionChanged;
408                     LayoutDirectionChangedSignal(this).Connect(_layoutDirectionChangedEventCallback);
409                 }
410
411                 _layoutDirectionChangedEventHandler += value;
412             }
413
414             remove
415             {
416                 _layoutDirectionChangedEventHandler -= value;
417
418                 if (_layoutDirectionChangedEventHandler == null && LayoutDirectionChangedSignal(this).Empty() == false)
419                 {
420                     LayoutDirectionChangedSignal(this).Disconnect(_layoutDirectionChangedEventCallback);
421                 }
422             }
423         }
424
425         /// <summary>
426         /// An event for the ResourcesLoadedSignal signal which can be used to subscribe or unsubscribe the event handler provided by the user.<br />
427         /// This signal is emitted after all resources required by a view are loaded and ready.<br />
428         /// </summary>
429         /// <since_tizen> 3 </since_tizen>
430         public event EventHandler ResourcesLoaded
431         {
432             add
433             {
434                 if (_resourcesLoadedEventHandler == null)
435                 {
436                     _ResourcesLoadedCallback = OnResourcesLoaded;
437                     this.ResourcesLoadedSignal().Connect(_ResourcesLoadedCallback);
438                 }
439
440                 _resourcesLoadedEventHandler += value;
441             }
442
443             remove
444             {
445                 _resourcesLoadedEventHandler -= value;
446
447                 if (_resourcesLoadedEventHandler == null && ResourcesLoadedSignal().Empty() == false)
448                 {
449                     this.ResourcesLoadedSignal().Disconnect(_ResourcesLoadedCallback);
450                 }
451             }
452         }
453
454         internal event EventHandler<BackgroundResourceLoadedEventArgs> BackgroundResourceLoaded
455         {
456             add
457             {
458                 if (_backgroundResourceLoadedEventHandler == null)
459                 {
460                     _backgroundResourceLoadedCallback = OnBackgroundResourceLoaded;
461                     this.ResourcesLoadedSignal().Connect(_backgroundResourceLoadedCallback);
462                 }
463
464                 _backgroundResourceLoadedEventHandler += value;
465             }
466             remove
467             {
468                 _backgroundResourceLoadedEventHandler -= value;
469
470                 if (_backgroundResourceLoadedEventHandler == null && ResourcesLoadedSignal().Empty() == false)
471                 {
472                     this.ResourcesLoadedSignal().Disconnect(_backgroundResourceLoadedCallback);
473                 }
474             }
475         }
476
477         internal TouchDataSignal TouchSignal()
478         {
479             TouchDataSignal ret = new TouchDataSignal(Interop.ActorSignal.Actor_TouchSignal(swigCPtr), false);
480             if (NDalicPINVOKE.SWIGPendingException.Pending)
481                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
482             return ret;
483         }
484
485         internal HoverSignal HoveredSignal()
486         {
487             HoverSignal ret = new HoverSignal(Interop.ActorSignal.Actor_HoveredSignal(swigCPtr), false);
488             if (NDalicPINVOKE.SWIGPendingException.Pending)
489                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
490             return ret;
491         }
492
493         internal WheelSignal WheelEventSignal()
494         {
495             WheelSignal ret = new WheelSignal(Interop.ActorSignal.Actor_WheelEventSignal(swigCPtr), false);
496             if (NDalicPINVOKE.SWIGPendingException.Pending)
497                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
498             return ret;
499         }
500
501         internal ViewSignal OnWindowSignal()
502         {
503             ViewSignal ret = new ViewSignal(Interop.ActorSignal.Actor_OnStageSignal(swigCPtr), false);
504             if (NDalicPINVOKE.SWIGPendingException.Pending)
505                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
506             return ret;
507         }
508
509         internal ViewSignal OffWindowSignal()
510         {
511             ViewSignal ret = new ViewSignal(Interop.ActorSignal.Actor_OffStageSignal(swigCPtr), false);
512             if (NDalicPINVOKE.SWIGPendingException.Pending)
513                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
514             return ret;
515         }
516
517         internal ViewSignal OnRelayoutSignal()
518         {
519             ViewSignal ret = new ViewSignal(Interop.ActorSignal.Actor_OnRelayoutSignal(swigCPtr), false);
520             if (NDalicPINVOKE.SWIGPendingException.Pending)
521                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
522             return ret;
523         }
524
525         internal ViewVisibilityChangedSignal VisibilityChangedSignal(View view)
526         {
527             ViewVisibilityChangedSignal ret = new ViewVisibilityChangedSignal(Interop.NDalic.VisibilityChangedSignal(View.getCPtr(view)), false);
528             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
529             return ret;
530         }
531
532         internal ViewLayoutDirectionChangedSignal LayoutDirectionChangedSignal(View view)
533         {
534             ViewLayoutDirectionChangedSignal ret = new ViewLayoutDirectionChangedSignal(Interop.Layout.LayoutDirectionChangedSignal(View.getCPtr(view)), false);
535             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
536             return ret;
537         }
538
539         internal ViewSignal ResourcesLoadedSignal()
540         {
541             ViewSignal ret = new ViewSignal(Interop.View.ResourceReadySignal(swigCPtr), false);
542             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
543             return ret;
544         }
545
546         internal ControlKeySignal KeyEventSignal()
547         {
548             ControlKeySignal ret = new ControlKeySignal(Interop.ViewSignal.View_KeyEventSignal(swigCPtr), false);
549             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
550             return ret;
551         }
552
553         internal KeyInputFocusSignal KeyInputFocusGainedSignal()
554         {
555             KeyInputFocusSignal ret = new KeyInputFocusSignal(Interop.ViewSignal.View_KeyInputFocusGainedSignal(swigCPtr), false);
556             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
557             return ret;
558         }
559
560         internal KeyInputFocusSignal KeyInputFocusLostSignal()
561         {
562             KeyInputFocusSignal ret = new KeyInputFocusSignal(Interop.ViewSignal.View_KeyInputFocusLostSignal(swigCPtr), false);
563             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
564             return ret;
565         }
566
567         private void OnSize2DChanged(int width, int height)
568         {
569             Size2D = new Size2D(width, height);
570         }
571
572         private void OnMinimumSizeChanged(int width, int height)
573         {
574             MinimumSize = new Size2D(width, height);
575         }
576
577         private void OnMaximumSizeChanged(int width, int height)
578         {
579             MaximumSize = new Size2D(width, height);
580         }
581
582         private void OnPosition2DChanged(int x, int y)
583         {
584             Position2D = new Position2D(x, y);
585         }
586
587         private void OnSizeChanged(float width, float height, float depth)
588         {
589             Size = new Size(width, height, depth);
590         }
591
592         private void OnPositionChanged(float x, float y, float z)
593         {
594             Position = new Position(x, y, z);
595         }
596
597         private void OnParentOriginChanged(float x, float y, float z)
598         {
599             ParentOrigin = new Position(x, y, z);
600         }
601
602         private void OnPivotPointChanged(float x, float y, float z)
603         {
604             PivotPoint = new Position(x, y, z);
605         }
606
607         private void OnImageShadowChanged(TransformablePropertyMap instance)
608         {
609             ImageShadow = (ImageShadow)instance;
610         }
611
612         private void OnBoxShadowChanged(TransformablePropertyMap instance)
613         {
614             BoxShadow = (Shadow)instance;
615         }
616
617         private void OnKeyInputFocusGained(IntPtr view)
618         {
619             if (_keyInputFocusGainedEventHandler != null)
620             {
621                 _keyInputFocusGainedEventHandler(this, null);
622             }
623         }
624
625         private void OnKeyInputFocusLost(IntPtr view)
626         {
627             if (_keyInputFocusLostEventHandler != null)
628             {
629                 _keyInputFocusLostEventHandler(this, null);
630             }
631         }
632
633         private bool OnKeyEvent(IntPtr view, IntPtr keyEvent)
634         {
635             if (keyEvent == global::System.IntPtr.Zero)
636             {
637                 NUILog.Error("keyEvent should not be null!");
638                 return true;
639             }
640
641             KeyEventArgs e = new KeyEventArgs();
642
643             bool result = false;
644
645             e.Key = Tizen.NUI.Key.GetKeyFromPtr(keyEvent);
646
647             if (_keyEventHandler != null)
648             {
649                 Delegate[] delegateList = _keyEventHandler.GetInvocationList();
650
651                 // Oring the result of each callback.
652                 foreach (EventHandlerWithReturnType<object, KeyEventArgs, bool> del in delegateList)
653                 {
654                     result |= del(this, e);
655                 }
656             }
657
658             return result;
659         }
660
661         // Callback for View OnRelayout signal
662         private void OnRelayout(IntPtr data)
663         {
664             if (_onRelayoutEventHandler != null)
665             {
666                 _onRelayoutEventHandler(this, null);
667             }
668         }
669
670         // Callback for View TouchSignal
671         private bool OnTouch(IntPtr view, IntPtr touchData)
672         {
673             if (touchData == global::System.IntPtr.Zero)
674             {
675                 NUILog.Error("touchData should not be null!");
676                 return true;
677             }
678
679             TouchEventArgs e = new TouchEventArgs();
680
681             e.Touch = Tizen.NUI.Touch.GetTouchFromPtr(touchData);
682
683             if (_touchDataEventHandler != null)
684             {
685                 return _touchDataEventHandler(this, e);
686             }
687             return false;
688         }
689
690         // Callback for View Hover signal
691         private bool OnHoverEvent(IntPtr view, IntPtr hoverEvent)
692         {
693             if (hoverEvent == global::System.IntPtr.Zero)
694             {
695                 NUILog.Error("hoverEvent should not be null!");
696                 return true;
697             }
698
699             HoverEventArgs e = new HoverEventArgs();
700
701             e.Hover = Tizen.NUI.Hover.GetHoverFromPtr(hoverEvent);
702
703             if (_hoverEventHandler != null)
704             {
705                 return _hoverEventHandler(this, e);
706             }
707             return false;
708         }
709
710         // Callback for View Wheel signal
711         private bool OnWheelEvent(IntPtr view, IntPtr wheelEvent)
712         {
713             if (wheelEvent == global::System.IntPtr.Zero)
714             {
715                 NUILog.Error("wheelEvent should not be null!");
716                 return true;
717             }
718
719             WheelEventArgs e = new WheelEventArgs();
720
721             e.Wheel = Tizen.NUI.Wheel.GetWheelFromPtr(wheelEvent);
722
723             if (_wheelEventHandler != null)
724             {
725                 return _wheelEventHandler(this, e);
726             }
727             return false;
728         }
729
730         // Callback for View OnWindow signal
731         private void OnWindow(IntPtr data)
732         {
733             if (_onWindowEventHandler != null)
734             {
735                 _onWindowEventHandler(this, null);
736             }
737         }
738
739         // Callback for View OffWindow signal
740         private void OffWindow(IntPtr data)
741         {
742             if (_offWindowEventHandler != null)
743             {
744                 _offWindowEventHandler(this, null);
745             }
746         }
747
748         // Callback for View visibility change signal
749         private void OnVisibilityChanged(IntPtr data, bool visibility, VisibilityChangeType type)
750         {
751             VisibilityChangedEventArgs e = new VisibilityChangedEventArgs();
752             if (data != null)
753             {
754                 e.View = Registry.GetManagedBaseHandleFromNativePtr(data) as View;
755             }
756             e.Visibility = visibility;
757             e.Type = type;
758
759             if (_visibilityChangedEventHandler != null)
760             {
761                 _visibilityChangedEventHandler(this, e);
762             }
763         }
764
765         // Callback for View layout direction change signal
766         private void OnLayoutDirectionChanged(IntPtr data, ViewLayoutDirectionType type)
767         {
768             LayoutDirectionChangedEventArgs e = new LayoutDirectionChangedEventArgs();
769             if (data != null)
770             {
771                 e.View = Registry.GetManagedBaseHandleFromNativePtr(data) as View;
772             }
773             e.Type = type;
774
775             if (_layoutDirectionChangedEventHandler != null)
776             {
777                 _layoutDirectionChangedEventHandler(this, e);
778             }
779         }
780
781         private void OnResourcesLoaded(IntPtr view)
782         {
783             if (_resourcesLoadedEventHandler != null)
784             {
785                 _resourcesLoadedEventHandler(this, null);
786             }
787         }
788
789         private void OnBackgroundResourceLoaded(IntPtr view)
790         {
791             BackgroundResourceLoadedEventArgs e = new BackgroundResourceLoadedEventArgs();
792             e.Status = (ResourceLoadingStatusType)Interop.View.View_GetVisualResourceStatus(this.swigCPtr, Property.BACKGROUND);
793
794             if (_backgroundResourceLoadedEventHandler != null)
795             {
796                 _backgroundResourceLoadedEventHandler(this, e);
797             }
798         }
799
800         /// <summary>
801         /// Event argument passed through the ChildAdded event.
802         /// </summary>
803         /// <since_tizen> 5 </since_tizen>
804         public class ChildAddedEventArgs : EventArgs
805         {
806             /// <summary>
807             /// Added child view at moment.
808             /// </summary>
809             /// <since_tizen> 5 </since_tizen>
810             public View Added { get; set; }
811         }
812
813         /// <summary>
814         /// Event argument passed through the ChildRemoved event.
815         /// </summary>
816         /// <since_tizen> 5 </since_tizen>
817         public class ChildRemovedEventArgs : EventArgs
818         {
819             /// <summary>
820             /// Removed child view at moment.
821             /// </summary>
822             /// <since_tizen> 5 </since_tizen>
823             public View Removed { get; set; }
824         }
825
826         /// <summary>
827         /// Event arguments that passed via the KeyEvent signal.
828         /// </summary>
829         /// <since_tizen> 3 </since_tizen>
830         public class KeyEventArgs : EventArgs
831         {
832             private Key _key;
833
834             /// <summary>
835             /// Key - is the key sent to the view.
836             /// </summary>
837             /// <since_tizen> 3 </since_tizen>
838             public Key Key
839             {
840                 get
841                 {
842                     return _key;
843                 }
844                 set
845                 {
846                     _key = value;
847                 }
848             }
849         }
850
851         /// <summary>
852         /// Event arguments that passed via the touch signal.
853         /// </summary>
854         /// <since_tizen> 3 </since_tizen>
855         public class TouchEventArgs : EventArgs
856         {
857             private Touch _touch;
858
859             /// <summary>
860             /// Touch - contains the information of touch points.
861             /// </summary>
862             /// <since_tizen> 3 </since_tizen>
863             public Touch Touch
864             {
865                 get
866                 {
867                     return _touch;
868                 }
869                 set
870                 {
871                     _touch = value;
872                 }
873             }
874         }
875
876         /// <summary>
877         /// Event arguments that passed via the hover signal.
878         /// </summary>
879         /// <since_tizen> 3 </since_tizen>
880         public class HoverEventArgs : EventArgs
881         {
882             private Hover _hover;
883
884             /// <summary>
885             /// Hover - contains touch points that represent the points that are currently being hovered or the points where a hover has stopped.
886             /// </summary>
887             /// <since_tizen> 3 </since_tizen>
888             public Hover Hover
889             {
890                 get
891                 {
892                     return _hover;
893                 }
894                 set
895                 {
896                     _hover = value;
897                 }
898             }
899         }
900
901         /// <summary>
902         /// Event arguments that passed via the wheel signal.
903         /// </summary>
904         /// <since_tizen> 3 </since_tizen>
905         public class WheelEventArgs : EventArgs
906         {
907             private Wheel _wheel;
908
909             /// <summary>
910             /// WheelEvent - store a wheel rolling type: MOUSE_WHEEL or CUSTOM_WHEEL.
911             /// </summary>
912             /// <since_tizen> 3 </since_tizen>
913             public Wheel Wheel
914             {
915                 get
916                 {
917                     return _wheel;
918                 }
919                 set
920                 {
921                     _wheel = value;
922                 }
923             }
924         }
925
926         /// <summary>
927         /// Event arguments of visibility changed.
928         /// </summary>
929         /// <since_tizen> 3 </since_tizen>
930         public class VisibilityChangedEventArgs : EventArgs
931         {
932             private View _view;
933             private bool _visibility;
934             private VisibilityChangeType _type;
935
936             /// <summary>
937             /// The view, or child of view, whose visibility has changed.
938             /// </summary>
939             /// <since_tizen> 3 </since_tizen>
940             public View View
941             {
942                 get
943                 {
944                     return _view;
945                 }
946                 set
947                 {
948                     _view = value;
949                 }
950             }
951
952             /// <summary>
953             /// Whether the view is now visible or not.
954             /// </summary>
955             /// <since_tizen> 3 </since_tizen>
956             public bool Visibility
957             {
958                 get
959                 {
960                     return _visibility;
961                 }
962                 set
963                 {
964                     _visibility = value;
965                 }
966             }
967
968             /// <summary>
969             /// Whether the view's visible property has changed or a parent's.
970             /// </summary>
971             /// <since_tizen> 3 </since_tizen>
972             public VisibilityChangeType Type
973             {
974                 get
975                 {
976                     return _type;
977                 }
978                 set
979                 {
980                     _type = value;
981                 }
982             }
983         }
984
985         /// <summary>
986         /// Event arguments of layout direction changed.
987         /// </summary>
988         /// <since_tizen> 4 </since_tizen>
989         public class LayoutDirectionChangedEventArgs : EventArgs
990         {
991             private View _view;
992             private ViewLayoutDirectionType _type;
993
994             /// <summary>
995             /// The view, or child of view, whose layout direction has changed.
996             /// </summary>
997             /// <since_tizen> 4 </since_tizen>
998             public View View
999             {
1000                 get
1001                 {
1002                     return _view;
1003                 }
1004                 set
1005                 {
1006                     _view = value;
1007                 }
1008             }
1009
1010             /// <summary>
1011             /// Whether the view's layout direction property has changed or a parent's.
1012             /// </summary>
1013             /// <since_tizen> 4 </since_tizen>
1014             public ViewLayoutDirectionType Type
1015             {
1016                 get
1017                 {
1018                     return _type;
1019                 }
1020                 set
1021                 {
1022                     _type = value;
1023                 }
1024             }
1025         }
1026
1027         internal class BackgroundResourceLoadedEventArgs : EventArgs
1028         {
1029             private ResourceLoadingStatusType status = ResourceLoadingStatusType.Invalid;
1030             public ResourceLoadingStatusType Status
1031             {
1032                 get
1033                 {
1034                     return status;
1035                 }
1036                 set
1037                 {
1038                     status = value;
1039                 }
1040             }
1041         }
1042     }
1043 }