[NUI] Delete Tizen.NUI.Components build warnings (#2674)
[platform/core/csapi/tizenfx.git] / src / Tizen.NUI / src / public / BaseComponents / ViewEvent.cs
1 /*
2  * Copyright(c) 2020 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.Components;
22
23 namespace Tizen.NUI.BaseComponents
24 {
25     /// <summary>
26     /// View is the base class for all views.
27     /// </summary>
28     /// <since_tizen> 3 </since_tizen>
29     public partial class View
30     {
31         private EventHandler _offWindowEventHandler;
32         private OffWindowEventCallbackType _offWindowEventCallback;
33         private EventHandlerWithReturnType<object, WheelEventArgs, bool> _wheelEventHandler;
34         private WheelEventCallbackType _wheelEventCallback;
35         private EventHandlerWithReturnType<object, KeyEventArgs, bool> _keyEventHandler;
36         private KeyCallbackType _keyCallback;
37         private EventHandlerWithReturnType<object, TouchEventArgs, bool> _interceptTouchDataEventHandler;
38         private TouchDataCallbackType _interceptTouchDataCallback;
39         private EventHandlerWithReturnType<object, TouchEventArgs, bool> _touchDataEventHandler;
40         private TouchDataCallbackType _touchDataCallback;
41         private EventHandlerWithReturnType<object, HoverEventArgs, bool> _hoverEventHandler;
42         private HoverEventCallbackType _hoverEventCallback;
43         private EventHandler<VisibilityChangedEventArgs> _visibilityChangedEventHandler;
44         private VisibilityChangedEventCallbackType _visibilityChangedEventCallback;
45         private EventHandler _keyInputFocusGainedEventHandler;
46         private KeyInputFocusGainedCallbackType _keyInputFocusGainedCallback;
47         private EventHandler _keyInputFocusLostEventHandler;
48         private KeyInputFocusLostCallbackType _keyInputFocusLostCallback;
49         private EventHandler _onRelayoutEventHandler;
50         private OnRelayoutEventCallbackType _onRelayoutEventCallback;
51         private EventHandler _onWindowEventHandler;
52         private OnWindowEventCallbackType _onWindowEventCallback;
53         private EventHandler<LayoutDirectionChangedEventArgs> _layoutDirectionChangedEventHandler;
54         private LayoutDirectionChangedEventCallbackType _layoutDirectionChangedEventCallback;
55         // Resource Ready Signal
56         private EventHandler _resourcesLoadedEventHandler;
57         private ResourcesLoadedCallbackType _ResourcesLoadedCallback;
58         private EventHandler<BackgroundResourceLoadedEventArgs> _backgroundResourceLoadedEventHandler;
59         private _backgroundResourceLoadedCallbackType _backgroundResourceLoadedCallback;
60
61         private void SendViewAddedEventToWindow(IntPtr data)
62         {
63             // Unused parameter
64             _ = data;
65
66             NUIApplication.GetDefaultWindow()?.SendViewAdded(this);
67         }
68
69         [UnmanagedFunctionPointer(CallingConvention.StdCall)]
70         private delegate void OffWindowEventCallbackType(IntPtr control);
71         [UnmanagedFunctionPointer(CallingConvention.StdCall)]
72         private delegate bool WheelEventCallbackType(IntPtr view, IntPtr wheelEvent);
73         [UnmanagedFunctionPointer(CallingConvention.StdCall)]
74         private delegate bool KeyCallbackType(IntPtr control, IntPtr keyEvent);
75         [UnmanagedFunctionPointer(CallingConvention.StdCall)]
76         private delegate bool TouchDataCallbackType(IntPtr view, IntPtr touchData);
77         [UnmanagedFunctionPointer(CallingConvention.StdCall)]
78         private delegate bool HoverEventCallbackType(IntPtr view, IntPtr hoverEvent);
79         [UnmanagedFunctionPointer(CallingConvention.StdCall)]
80         private delegate void VisibilityChangedEventCallbackType(IntPtr data, bool visibility, VisibilityChangeType type);
81         [UnmanagedFunctionPointer(CallingConvention.StdCall)]
82         private delegate void ResourcesLoadedCallbackType(IntPtr control);
83         [UnmanagedFunctionPointer(CallingConvention.StdCall)]
84         private delegate void _backgroundResourceLoadedCallbackType(IntPtr view);
85         [UnmanagedFunctionPointer(CallingConvention.StdCall)]
86         private delegate void KeyInputFocusGainedCallbackType(IntPtr control);
87         [UnmanagedFunctionPointer(CallingConvention.StdCall)]
88         private delegate void KeyInputFocusLostCallbackType(IntPtr control);
89         [UnmanagedFunctionPointer(CallingConvention.StdCall)]
90         private delegate void OnRelayoutEventCallbackType(IntPtr control);
91         [UnmanagedFunctionPointer(CallingConvention.StdCall)]
92         private delegate void OnWindowEventCallbackType(IntPtr control);
93         [UnmanagedFunctionPointer(CallingConvention.StdCall)]
94         private delegate void LayoutDirectionChangedEventCallbackType(IntPtr data, ViewLayoutDirectionType type);
95
96         /// <summary>
97         /// Event when a child is removed.
98         /// </summary>
99         /// <since_tizen> 5 </since_tizen>
100         public new event EventHandler<ChildRemovedEventArgs> ChildRemoved;
101         /// <summary>
102         /// Event when a child is added.
103         /// </summary>
104         /// <since_tizen> 5 </since_tizen>
105         public new event EventHandler<ChildAddedEventArgs> ChildAdded;
106
107         /// <summary>
108         /// An event for the KeyInputFocusGained signal which can be used to subscribe or unsubscribe the event handler provided by the user.<br />
109         /// The KeyInputFocusGained signal is emitted when the control gets the key input focus.<br />
110         /// </summary>
111         /// <since_tizen> 3 </since_tizen>
112         public event EventHandler FocusGained
113         {
114             add
115             {
116                 if (_keyInputFocusGainedEventHandler == null)
117                 {
118                     _keyInputFocusGainedCallback = OnKeyInputFocusGained;
119                     this.KeyInputFocusGainedSignal().Connect(_keyInputFocusGainedCallback);
120                 }
121
122                 _keyInputFocusGainedEventHandler += value;
123             }
124
125             remove
126             {
127                 _keyInputFocusGainedEventHandler -= value;
128
129                 if (_keyInputFocusGainedEventHandler == null && KeyInputFocusGainedSignal().Empty() == false)
130                 {
131                     this.KeyInputFocusGainedSignal().Disconnect(_keyInputFocusGainedCallback);
132                 }
133             }
134         }
135
136         /// <summary>
137         /// An event for the KeyInputFocusLost signal which can be used to subscribe or unsubscribe the event handler provided by the user.<br />
138         /// The KeyInputFocusLost signal is emitted when the control loses the key input focus.<br />
139         /// </summary>
140         /// <since_tizen> 3 </since_tizen>
141         public event EventHandler FocusLost
142         {
143             add
144             {
145                 if (_keyInputFocusLostEventHandler == null)
146                 {
147                     _keyInputFocusLostCallback = OnKeyInputFocusLost;
148                     this.KeyInputFocusLostSignal().Connect(_keyInputFocusLostCallback);
149                 }
150
151                 _keyInputFocusLostEventHandler += value;
152             }
153
154             remove
155             {
156                 _keyInputFocusLostEventHandler -= value;
157
158                 if (_keyInputFocusLostEventHandler == null && KeyInputFocusLostSignal().Empty() == false)
159                 {
160                     this.KeyInputFocusLostSignal().Disconnect(_keyInputFocusLostCallback);
161                 }
162             }
163         }
164
165         /// <summary>
166         /// An event for the KeyPressed signal which can be used to subscribe or unsubscribe the event handler provided by the user.<br />
167         /// The KeyPressed signal is emitted when the key event is received.<br />
168         /// </summary>
169         /// <since_tizen> 3 </since_tizen>
170         public event EventHandlerWithReturnType<object, KeyEventArgs, bool> KeyEvent
171         {
172             add
173             {
174                 if (_keyEventHandler == null)
175                 {
176                     _keyCallback = OnKeyEvent;
177                     this.KeyEventSignal().Connect(_keyCallback);
178                 }
179
180                 _keyEventHandler += value;
181             }
182
183             remove
184             {
185                 _keyEventHandler -= value;
186
187                 if (_keyEventHandler == null && KeyEventSignal().Empty() == false)
188                 {
189                     this.KeyEventSignal().Disconnect(_keyCallback);
190                 }
191             }
192         }
193
194         /// <summary>
195         /// An event for the OnRelayout signal which can be used to subscribe or unsubscribe the event handler.<br />
196         /// The OnRelayout signal is emitted after the size has been set on the view during relayout.<br />
197         /// </summary>
198         /// <since_tizen> 3 </since_tizen>
199         public event EventHandler Relayout
200         {
201             add
202             {
203                 if (_onRelayoutEventHandler == null)
204                 {
205                     _onRelayoutEventCallback = OnRelayout;
206                     this.OnRelayoutSignal().Connect(_onRelayoutEventCallback);
207                 }
208
209                 _onRelayoutEventHandler += value;
210             }
211
212             remove
213             {
214                 _onRelayoutEventHandler -= value;
215
216                 if (_onRelayoutEventHandler == null && OnRelayoutSignal().Empty() == false)
217                 {
218                     this.OnRelayoutSignal().Disconnect(_onRelayoutEventCallback);
219                     _onRelayoutEventCallback = null;
220                 }
221
222             }
223         }
224
225         /// <summary>
226         /// An event for the touched signal which can be used to subscribe or unsubscribe the event handler provided by the user.<br />
227         /// The touched signal is emitted when the touch input is received.<br />
228         /// This can receive touch events before child. <br />
229         /// If it returns false, the child can receive the touch event. If it returns true, the touch event is intercepted. So child cannot receive touch event.<br />
230         /// </summary>
231         [EditorBrowsable(EditorBrowsableState.Never)]
232         public event EventHandlerWithReturnType<object, TouchEventArgs, bool> InterceptTouchEvent
233         {
234             add
235             {
236                 if (_interceptTouchDataEventHandler == null)
237                 {
238                     _interceptTouchDataCallback = OnInterceptTouch;
239                     this.InterceptTouchSignal().Connect(_interceptTouchDataCallback);
240                 }
241
242                 _interceptTouchDataEventHandler += value;
243             }
244
245             remove
246             {
247                 _interceptTouchDataEventHandler -= value;
248
249                 if (_interceptTouchDataEventHandler == null && InterceptTouchSignal().Empty() == false)
250                 {
251                     this.InterceptTouchSignal().Disconnect(_interceptTouchDataCallback);
252                 }
253             }
254         }
255
256         /// <summary>
257         /// If child view doesn't want the parent's view to intercept the touch, you can set it to true.
258         /// for example :
259         ///    parent.Add(child);
260         ///    parent.InterceptTouchEvent += OnInterceptTouchEvent;
261         ///    View view = child.GetParent() as View;
262         ///    view.DisallowInterceptTouchEvent = true;
263         ///  This prevents the parent from interceping touch.
264         /// </summary>
265         [EditorBrowsable(EditorBrowsableState.Never)]
266         public bool DisallowInterceptTouchEvent { get; set; }
267
268
269         /// <summary>
270         /// An event for the touched signal which can be used to subscribe or unsubscribe the event handler provided by the user.<br />
271         /// The touched signal is emitted when the touch input is received.<br />
272         /// </summary>
273         /// <since_tizen> 3 </since_tizen>
274         public event EventHandlerWithReturnType<object, TouchEventArgs, bool> TouchEvent
275         {
276             add
277             {
278                 if (_touchDataEventHandler == null)
279                 {
280                     _touchDataCallback = OnTouch;
281                     this.TouchSignal().Connect(_touchDataCallback);
282                 }
283
284                 _touchDataEventHandler += value;
285             }
286
287             remove
288             {
289                 _touchDataEventHandler -= value;
290
291                 if (_touchDataEventHandler == null && TouchSignal().Empty() == false)
292                 {
293                     this.TouchSignal().Disconnect(_touchDataCallback);
294                 }
295             }
296         }
297
298         /// <summary>
299         /// An event for the hovered signal which can be used to subscribe or unsubscribe the event handler provided by the user.<br />
300         /// The hovered signal is emitted when the hover input is received.<br />
301         /// </summary>
302         /// <since_tizen> 3 </since_tizen>
303         public event EventHandlerWithReturnType<object, HoverEventArgs, bool> HoverEvent
304         {
305             add
306             {
307                 if (_hoverEventHandler == null)
308                 {
309                     _hoverEventCallback = OnHoverEvent;
310                     this.HoveredSignal().Connect(_hoverEventCallback);
311                 }
312
313                 _hoverEventHandler += value;
314             }
315
316             remove
317             {
318                 _hoverEventHandler -= value;
319
320                 if (_hoverEventHandler == null && HoveredSignal().Empty() == false)
321                 {
322                     this.HoveredSignal().Disconnect(_hoverEventCallback);
323                 }
324
325             }
326         }
327
328         /// <summary>
329         /// An event for the WheelMoved signal which can be used to subscribe or unsubscribe the event handler provided by the user.<br />
330         /// The WheelMoved signal is emitted when the wheel event is received.<br />
331         /// </summary>
332         /// <since_tizen> 3 </since_tizen>
333         public event EventHandlerWithReturnType<object, WheelEventArgs, bool> WheelEvent
334         {
335             add
336             {
337                 if (_wheelEventHandler == null)
338                 {
339                     _wheelEventCallback = OnWheelEvent;
340                     this.WheelEventSignal().Connect(_wheelEventCallback);
341                 }
342                 _wheelEventHandler += value;
343
344                 if (WindowWheelEventHandler == null)
345                 {
346                     NUIApplication.GetDefaultWindow().WheelEvent += OnWindowWheelEvent;
347                 }
348                 WindowWheelEventHandler += value;
349             }
350
351             remove
352             {
353                 _wheelEventHandler -= value;
354                 if (_wheelEventHandler == null && WheelEventSignal().Empty() == false)
355                 {
356                     this.WheelEventSignal().Disconnect(_wheelEventCallback);
357                 }
358
359                 WindowWheelEventHandler -= value;
360                 if (WindowWheelEventHandler == null)
361                 {
362                     NUIApplication.GetDefaultWindow().WheelEvent -= OnWindowWheelEvent;
363                 }
364             }
365         }
366
367         /// <summary>
368         /// An event for the OnWindow signal which can be used to subscribe or unsubscribe the event handler.<br />
369         /// The OnWindow signal is emitted after the view has been connected to the window.<br />
370         /// </summary>
371         /// <since_tizen> 3 </since_tizen>
372         public event EventHandler AddedToWindow
373         {
374             add
375             {
376                 if (_onWindowEventHandler == null)
377                 {
378                     _onWindowEventCallback = OnWindow;
379                     this.OnWindowSignal().Connect(_onWindowEventCallback);
380                 }
381
382                 _onWindowEventHandler += value;
383             }
384
385             remove
386             {
387                 _onWindowEventHandler -= value;
388
389                 if (_onWindowEventHandler == null && OnWindowSignal().Empty() == false)
390                 {
391                     this.OnWindowSignal().Disconnect(_onWindowEventCallback);
392                     _onWindowEventCallback = null;
393                 }
394             }
395         }
396
397         /// <summary>
398         /// An event for the OffWindow signal, which can be used to subscribe or unsubscribe the event handler.<br />
399         /// OffWindow signal is emitted after the view has been disconnected from the window.<br />
400         /// </summary>
401         /// <since_tizen> 3 </since_tizen>
402         public event EventHandler RemovedFromWindow
403         {
404             add
405             {
406                 if (_offWindowEventHandler == null)
407                 {
408                     _offWindowEventCallback = OffWindow;
409                     this.OffWindowSignal().Connect(_offWindowEventCallback);
410                 }
411
412                 _offWindowEventHandler += value;
413             }
414
415             remove
416             {
417                 _offWindowEventHandler -= value;
418
419                 if (_offWindowEventHandler == null && OffWindowSignal().Empty() == false)
420                 {
421                     this.OffWindowSignal().Disconnect(_offWindowEventCallback);
422                     _offWindowEventCallback = null;
423                 }
424             }
425         }
426
427         /// <summary>
428         /// An event for visibility change which can be used to subscribe or unsubscribe the event handler.<br />
429         /// This signal is emitted when the visible property of this or a parent view is changed.<br />
430         /// </summary>
431         /// <since_tizen> 3 </since_tizen>
432         public event EventHandler<VisibilityChangedEventArgs> VisibilityChanged
433         {
434             add
435             {
436                 if (_visibilityChangedEventHandler == null)
437                 {
438                     _visibilityChangedEventCallback = OnVisibilityChanged;
439                     VisibilityChangedSignal(this).Connect(_visibilityChangedEventCallback);
440                 }
441
442                 _visibilityChangedEventHandler += value;
443             }
444
445             remove
446             {
447                 _visibilityChangedEventHandler -= value;
448
449                 if (_visibilityChangedEventHandler == null && VisibilityChangedSignal(this).Empty() == false)
450                 {
451                     VisibilityChangedSignal(this).Disconnect(_visibilityChangedEventCallback);
452                 }
453             }
454         }
455
456         /// <summary>
457         /// Event for layout direction change which can be used to subscribe/unsubscribe the event handler.<br />
458         /// This signal is emitted when the layout direction property of this or a parent view is changed.<br />
459         /// </summary>
460         /// <since_tizen> 4 </since_tizen>
461         public event EventHandler<LayoutDirectionChangedEventArgs> LayoutDirectionChanged
462         {
463             add
464             {
465                 if (_layoutDirectionChangedEventHandler == null)
466                 {
467                     _layoutDirectionChangedEventCallback = OnLayoutDirectionChanged;
468                     LayoutDirectionChangedSignal(this).Connect(_layoutDirectionChangedEventCallback);
469                 }
470
471                 _layoutDirectionChangedEventHandler += value;
472             }
473
474             remove
475             {
476                 _layoutDirectionChangedEventHandler -= value;
477
478                 if (_layoutDirectionChangedEventHandler == null && LayoutDirectionChangedSignal(this).Empty() == false)
479                 {
480                     LayoutDirectionChangedSignal(this).Disconnect(_layoutDirectionChangedEventCallback);
481                 }
482             }
483         }
484
485         /// <summary>
486         /// An event for the ResourcesLoadedSignal signal which can be used to subscribe or unsubscribe the event handler provided by the user.<br />
487         /// This signal is emitted after all resources required by a view are loaded and ready.<br />
488         /// </summary>
489         /// <since_tizen> 3 </since_tizen>
490         public event EventHandler ResourcesLoaded
491         {
492             add
493             {
494                 if (_resourcesLoadedEventHandler == null)
495                 {
496                     _ResourcesLoadedCallback = OnResourcesLoaded;
497                     this.ResourcesLoadedSignal().Connect(_ResourcesLoadedCallback);
498                 }
499
500                 _resourcesLoadedEventHandler += value;
501             }
502
503             remove
504             {
505                 _resourcesLoadedEventHandler -= value;
506
507                 if (_resourcesLoadedEventHandler == null && ResourcesLoadedSignal().Empty() == false)
508                 {
509                     this.ResourcesLoadedSignal().Disconnect(_ResourcesLoadedCallback);
510                     _ResourcesLoadedCallback = null;
511                 }
512             }
513         }
514
515         private EventHandler _backKeyPressed;
516
517         /// <summary>
518         /// An event for getting notice when physical back key is pressed.<br />
519         /// This event is emitted BackKey is up.<br />
520         /// </summary>
521         [EditorBrowsable(EditorBrowsableState.Never)]
522         public event EventHandler BackKeyPressed
523         {
524             add
525             {
526                 _backKeyPressed += value;
527                 BackKeyManager.Instance.Subscriber.Add(this);
528             }
529
530             remove
531             {
532                 BackKeyManager.Instance.Subscriber.Remove(this);
533                 _backKeyPressed -= value;
534             }
535         }
536
537         /// <summary>
538         /// Function for emitting BackKeyPressed event outside of View instance
539         /// </summary>
540         [EditorBrowsable(EditorBrowsableState.Never)]
541         internal void EmitBackKeyPressed()
542         {
543             _backKeyPressed.Invoke(this, null);
544         }
545
546
547         internal event EventHandler<BackgroundResourceLoadedEventArgs> BackgroundResourceLoaded
548         {
549             add
550             {
551                 if (_backgroundResourceLoadedEventHandler == null)
552                 {
553                     _backgroundResourceLoadedCallback = OnBackgroundResourceLoaded;
554                     this.ResourcesLoadedSignal().Connect(_backgroundResourceLoadedCallback);
555                 }
556
557                 _backgroundResourceLoadedEventHandler += value;
558             }
559             remove
560             {
561                 _backgroundResourceLoadedEventHandler -= value;
562
563                 if (_backgroundResourceLoadedEventHandler == null && ResourcesLoadedSignal().Empty() == false)
564                 {
565                     this.ResourcesLoadedSignal().Disconnect(_backgroundResourceLoadedCallback);
566                     _backgroundResourceLoadedCallback = null;
567                 }
568             }
569         }
570
571         internal TouchDataSignal InterceptTouchSignal()
572         {
573             TouchDataSignal ret = new TouchDataSignal(Interop.ActorSignal.ActorInterceptTouchSignal(SwigCPtr), false);
574             if (NDalicPINVOKE.SWIGPendingException.Pending)
575                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
576             return ret;
577         }
578
579         internal TouchDataSignal TouchSignal()
580         {
581             TouchDataSignal ret = new TouchDataSignal(Interop.ActorSignal.ActorTouchSignal(SwigCPtr), false);
582             if (NDalicPINVOKE.SWIGPendingException.Pending)
583                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
584             return ret;
585         }
586
587         internal HoverSignal HoveredSignal()
588         {
589             HoverSignal ret = new HoverSignal(Interop.ActorSignal.ActorHoveredSignal(SwigCPtr), false);
590             if (NDalicPINVOKE.SWIGPendingException.Pending)
591                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
592             return ret;
593         }
594
595         internal WheelSignal WheelEventSignal()
596         {
597             WheelSignal ret = new WheelSignal(Interop.ActorSignal.ActorWheelEventSignal(SwigCPtr), false);
598             if (NDalicPINVOKE.SWIGPendingException.Pending)
599                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
600             return ret;
601         }
602
603         internal ViewSignal OnWindowSignal()
604         {
605             ViewSignal ret = new ViewSignal(Interop.ActorSignal.ActorOnSceneSignal(SwigCPtr), false);
606             if (NDalicPINVOKE.SWIGPendingException.Pending)
607                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
608             return ret;
609         }
610
611         internal ViewSignal OffWindowSignal()
612         {
613             ViewSignal ret = new ViewSignal(Interop.ActorSignal.ActorOffSceneSignal(SwigCPtr), false);
614             if (NDalicPINVOKE.SWIGPendingException.Pending)
615                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
616             return ret;
617         }
618
619         internal ViewSignal OnRelayoutSignal()
620         {
621             ViewSignal ret = new ViewSignal(Interop.ActorSignal.ActorOnRelayoutSignal(SwigCPtr), false);
622             if (NDalicPINVOKE.SWIGPendingException.Pending)
623                 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
624             return ret;
625         }
626
627         internal ViewVisibilityChangedSignal VisibilityChangedSignal(View view)
628         {
629             ViewVisibilityChangedSignal ret = new ViewVisibilityChangedSignal(Interop.NDalic.VisibilityChangedSignal(View.getCPtr(view)), false);
630             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
631             return ret;
632         }
633
634         internal ViewLayoutDirectionChangedSignal LayoutDirectionChangedSignal(View view)
635         {
636             ViewLayoutDirectionChangedSignal ret = new ViewLayoutDirectionChangedSignal(Interop.Layout.LayoutDirectionChangedSignal(View.getCPtr(view)), false);
637             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
638             return ret;
639         }
640
641         internal ViewSignal ResourcesLoadedSignal()
642         {
643             ViewSignal ret = new ViewSignal(Interop.View.ResourceReadySignal(SwigCPtr), false);
644             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
645             return ret;
646         }
647
648         internal ControlKeySignal KeyEventSignal()
649         {
650             ControlKeySignal ret = new ControlKeySignal(Interop.ViewSignal.KeyEventSignal(SwigCPtr), false);
651             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
652             return ret;
653         }
654
655         internal KeyInputFocusSignal KeyInputFocusGainedSignal()
656         {
657             KeyInputFocusSignal ret = new KeyInputFocusSignal(Interop.ViewSignal.KeyInputFocusGainedSignal(SwigCPtr), false);
658             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
659             return ret;
660         }
661
662         internal KeyInputFocusSignal KeyInputFocusLostSignal()
663         {
664             KeyInputFocusSignal ret = new KeyInputFocusSignal(Interop.ViewSignal.KeyInputFocusLostSignal(SwigCPtr), false);
665             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
666             return ret;
667         }
668
669         private void OnSize2DChanged(int? width, int? height)
670         {
671             PropertyValue temp;
672             if (width != null)
673             {
674                 temp = new Tizen.NUI.PropertyValue((float)width);
675                 Tizen.NUI.Object.SetProperty(this.SwigCPtr, View.Property.SizeWidth, temp);
676                 temp.Dispose();
677             }
678             if (height != null)
679             {
680                 temp = new Tizen.NUI.PropertyValue((float)height);
681                 Tizen.NUI.Object.SetProperty(this.SwigCPtr, View.Property.SizeHeight, temp);
682                 temp.Dispose();
683             }
684         }
685
686         private void OnMinimumSizeChanged(int? width, int? height)
687         {
688             if (width != null && height != null)
689             {
690                 MinimumSize = new Size2D((int)width, (int)height);
691             }
692             else if (width != null && height == null)
693             {
694                 MinimumSize = new Size2D((int)width, (int)this.GetMinimumSize().Height);
695             }
696             else if (width == null && height != null)
697             {
698                 MinimumSize = new Size2D((int)this.GetMinimumSize().Width, (int)height);
699             }
700             else
701             {
702                 //both are null, do nothing.
703             }
704         }
705
706         private void OnMaximumSizeChanged(int? width, int? height)
707         {
708             if (width != null && height != null)
709             {
710                 MaximumSize = new Size2D((int)width, (int)height);
711             }
712             else if (width != null && height == null)
713             {
714                 MaximumSize = new Size2D((int)width, (int)this.GetMaximumSize().Height);
715             }
716             else if (width == null && height != null)
717             {
718                 MaximumSize = new Size2D((int)this.GetMaximumSize().Width, (int)height);
719             }
720             else
721             {
722                 //both are null, do nothing.
723             }
724         }
725
726         private void OnPosition2DChanged(int x, int y)
727         {
728             Position2D = new Position2D(x, y);
729         }
730
731         private void OnSizeChanged(float? width, float? height, float? depth)
732         {
733             PropertyValue temp;
734             if (width != null)
735             {
736                 temp = new Tizen.NUI.PropertyValue((float)width);
737                 Tizen.NUI.Object.SetProperty(this.SwigCPtr, View.Property.SizeWidth, temp);
738                 temp.Dispose();
739             }
740             if (height != null)
741             {
742                 temp = new Tizen.NUI.PropertyValue((float)height);
743                 Tizen.NUI.Object.SetProperty(this.SwigCPtr, View.Property.SizeHeight, temp);
744                 temp.Dispose();
745             }
746             if (depth != null)
747             {
748                 temp = new Tizen.NUI.PropertyValue((float)depth);
749                 Tizen.NUI.Object.SetProperty(this.SwigCPtr, View.Property.SizeDepth, temp);
750                 temp.Dispose();
751             }
752         }
753
754         private void OnPositionChanged(float x, float y, float z)
755         {
756             Position = new Position(x, y, z);
757         }
758
759         private void OnParentOriginChanged(float x, float y, float z)
760         {
761             ParentOrigin = new Position(x, y, z);
762         }
763
764         private void OnPivotPointChanged(float x, float y, float z)
765         {
766             PivotPoint = new Position(x, y, z);
767         }
768
769         private void OnImageShadowChanged(ShadowBase instance)
770         {
771             ImageShadow = (ImageShadow)instance;
772         }
773
774         private void OnBoxShadowChanged(ShadowBase instance)
775         {
776             BoxShadow = (Shadow)instance;
777         }
778
779         private void OnBackgroundImageBorderChanged(int left, int right, int bottom, int top)
780         {
781             BackgroundImageBorder = new Rectangle(left, right, bottom, top);
782         }
783
784         private void OnKeyInputFocusGained(IntPtr view)
785         {
786             if (_keyInputFocusGainedEventHandler != null)
787             {
788                 _keyInputFocusGainedEventHandler(this, null);
789             }
790         }
791
792         private void OnKeyInputFocusLost(IntPtr view)
793         {
794             if (_keyInputFocusLostEventHandler != null)
795             {
796                 _keyInputFocusLostEventHandler(this, null);
797             }
798         }
799
800         private bool OnKeyEvent(IntPtr view, IntPtr keyEvent)
801         {
802             if (keyEvent == global::System.IntPtr.Zero)
803             {
804                 NUILog.Error("keyEvent should not be null!");
805                 return true;
806             }
807
808             KeyEventArgs e = new KeyEventArgs();
809
810             bool result = false;
811
812             e.Key = Tizen.NUI.Key.GetKeyFromPtr(keyEvent);
813
814             if (_keyEventHandler != null)
815             {
816                 Delegate[] delegateList = _keyEventHandler.GetInvocationList();
817
818                 // Oring the result of each callback.
819                 foreach (EventHandlerWithReturnType<object, KeyEventArgs, bool> del in delegateList)
820                 {
821                     result |= del(this, e);
822                 }
823             }
824
825             return result;
826         }
827
828         // Callback for View OnRelayout signal
829         private void OnRelayout(IntPtr data)
830         {
831             if (_onRelayoutEventHandler != null)
832             {
833                 _onRelayoutEventHandler(this, null);
834             }
835         }
836
837         // Callback for View TouchSignal
838         private bool OnInterceptTouch(IntPtr view, IntPtr touchData)
839         {
840             if (touchData == global::System.IntPtr.Zero)
841             {
842                 NUILog.Error("touchData should not be null!");
843                 return true;
844             }
845
846             // DisallowInterceptTouchEvent prevents the parent from intercepting touch.
847             if (DisallowInterceptTouchEvent)
848             {
849                 return false;
850             }
851
852             TouchEventArgs e = new TouchEventArgs();
853
854             e.Touch = Tizen.NUI.Touch.GetTouchFromPtr(touchData);
855
856             bool consumed = false;
857
858             if (_interceptTouchDataEventHandler != null)
859             {
860                 consumed = _interceptTouchDataEventHandler(this, e);
861             }
862
863             return consumed;
864         }
865
866         // Callback for View TouchSignal
867         private bool OnTouch(IntPtr view, IntPtr touchData)
868         {
869             if (touchData == global::System.IntPtr.Zero)
870             {
871                 NUILog.Error("touchData should not be null!");
872                 return true;
873             }
874
875             TouchEventArgs e = new TouchEventArgs();
876
877             e.Touch = Tizen.NUI.Touch.GetTouchFromPtr(touchData);
878
879             bool consumed = false;
880
881             if (_touchDataEventHandler != null)
882             {
883                 consumed = _touchDataEventHandler(this, e);
884             }
885
886             if (enableControlState && !consumed)
887             {
888                 consumed = HandleControlStateOnTouch(e.Touch);
889             }
890
891             return consumed;
892         }
893
894         // Callback for View Hover signal
895         private bool OnHoverEvent(IntPtr view, IntPtr hoverEvent)
896         {
897             if (hoverEvent == global::System.IntPtr.Zero)
898             {
899                 NUILog.Error("hoverEvent should not be null!");
900                 return true;
901             }
902
903             HoverEventArgs e = new HoverEventArgs();
904
905             e.Hover = Tizen.NUI.Hover.GetHoverFromPtr(hoverEvent);
906
907             if (_hoverEventHandler != null)
908             {
909                 return _hoverEventHandler(this, e);
910             }
911             return false;
912         }
913
914         // Callback for View Wheel signal
915         private bool OnWheelEvent(IntPtr view, IntPtr wheelEvent)
916         {
917             if (wheelEvent == global::System.IntPtr.Zero)
918             {
919                 NUILog.Error("wheelEvent should not be null!");
920                 return true;
921             }
922
923             WheelEventArgs e = new WheelEventArgs();
924
925             e.Wheel = Tizen.NUI.Wheel.GetWheelFromPtr(wheelEvent);
926
927             if (_wheelEventHandler != null)
928             {
929                 return _wheelEventHandler(this, e);
930             }
931             return false;
932         }
933
934         // Callback for View OnWindow signal
935         private void OnWindow(IntPtr data)
936         {
937             if (_onWindowEventHandler != null)
938             {
939                 _onWindowEventHandler(this, null);
940             }
941         }
942
943         // Callback for View OffWindow signal
944         private void OffWindow(IntPtr data)
945         {
946             if (_offWindowEventHandler != null)
947             {
948                 _offWindowEventHandler(this, null);
949             }
950         }
951
952         // Callback for View visibility change signal
953         private void OnVisibilityChanged(IntPtr data, bool visibility, VisibilityChangeType type)
954         {
955             VisibilityChangedEventArgs e = new VisibilityChangedEventArgs();
956             if (data != null)
957             {
958                 e.View = Registry.GetManagedBaseHandleFromNativePtr(data) as View;
959             }
960             e.Visibility = visibility;
961             e.Type = type;
962
963             if (_visibilityChangedEventHandler != null)
964             {
965                 _visibilityChangedEventHandler(this, e);
966             }
967         }
968
969         // Callback for View layout direction change signal
970         private void OnLayoutDirectionChanged(IntPtr data, ViewLayoutDirectionType type)
971         {
972             LayoutDirectionChangedEventArgs e = new LayoutDirectionChangedEventArgs();
973             if (data != null)
974             {
975                 e.View = Registry.GetManagedBaseHandleFromNativePtr(data) as View;
976             }
977             e.Type = type;
978
979             if (_layoutDirectionChangedEventHandler != null)
980             {
981                 _layoutDirectionChangedEventHandler(this, e);
982             }
983         }
984
985         private void OnResourcesLoaded(IntPtr view)
986         {
987             if (_resourcesLoadedEventHandler != null)
988             {
989                 _resourcesLoadedEventHandler(this, null);
990             }
991         }
992
993         private void OnBackgroundResourceLoaded(IntPtr view)
994         {
995             BackgroundResourceLoadedEventArgs e = new BackgroundResourceLoadedEventArgs();
996             e.Status = (ResourceLoadingStatusType)Interop.View.GetVisualResourceStatus(this.SwigCPtr, Property.BACKGROUND);
997
998             if (_backgroundResourceLoadedEventHandler != null)
999             {
1000                 _backgroundResourceLoadedEventHandler(this, e);
1001             }
1002         }
1003
1004         /// <summary>
1005         /// Event argument passed through the ChildAdded event.
1006         /// </summary>
1007         /// <since_tizen> 5 </since_tizen>
1008         public class ChildAddedEventArgs : EventArgs
1009         {
1010             /// <summary>
1011             /// Added child view at moment.
1012             /// </summary>
1013             /// <since_tizen> 5 </since_tizen>
1014             public View Added { get; set; }
1015         }
1016
1017         /// <summary>
1018         /// Event argument passed through the ChildRemoved event.
1019         /// </summary>
1020         /// <since_tizen> 5 </since_tizen>
1021         public class ChildRemovedEventArgs : EventArgs
1022         {
1023             /// <summary>
1024             /// Removed child view at moment.
1025             /// </summary>
1026             /// <since_tizen> 5 </since_tizen>
1027             public View Removed { get; set; }
1028         }
1029
1030         /// <summary>
1031         /// Event arguments that passed via the KeyEvent signal.
1032         /// </summary>
1033         /// <since_tizen> 3 </since_tizen>
1034         public class KeyEventArgs : EventArgs
1035         {
1036             private Key _key;
1037
1038             /// <summary>
1039             /// Key - is the key sent to the view.
1040             /// </summary>
1041             /// <since_tizen> 3 </since_tizen>
1042             public Key Key
1043             {
1044                 get
1045                 {
1046                     return _key;
1047                 }
1048                 set
1049                 {
1050                     _key = value;
1051                 }
1052             }
1053         }
1054
1055         /// <summary>
1056         /// Event arguments that passed via the touch signal.
1057         /// </summary>
1058         /// <since_tizen> 3 </since_tizen>
1059         public class TouchEventArgs : EventArgs
1060         {
1061             private Touch _touch;
1062
1063             /// <summary>
1064             /// Touch - contains the information of touch points.
1065             /// </summary>
1066             /// <since_tizen> 3 </since_tizen>
1067             public Touch Touch
1068             {
1069                 get
1070                 {
1071                     return _touch;
1072                 }
1073                 set
1074                 {
1075                     _touch = value;
1076                 }
1077             }
1078         }
1079
1080         /// <summary>
1081         /// Event arguments that passed via the hover signal.
1082         /// </summary>
1083         /// <since_tizen> 3 </since_tizen>
1084         public class HoverEventArgs : EventArgs
1085         {
1086             private Hover _hover;
1087
1088             /// <summary>
1089             /// Hover - contains touch points that represent the points that are currently being hovered or the points where a hover has stopped.
1090             /// </summary>
1091             /// <since_tizen> 3 </since_tizen>
1092             public Hover Hover
1093             {
1094                 get
1095                 {
1096                     return _hover;
1097                 }
1098                 set
1099                 {
1100                     _hover = value;
1101                 }
1102             }
1103         }
1104
1105         /// <summary>
1106         /// Event arguments that passed via the wheel signal.
1107         /// </summary>
1108         /// <since_tizen> 3 </since_tizen>
1109         public class WheelEventArgs : EventArgs
1110         {
1111             private Wheel _wheel;
1112
1113             /// <summary>
1114             /// WheelEvent - store a wheel rolling type: MOUSE_WHEEL or CUSTOM_WHEEL.
1115             /// </summary>
1116             /// <since_tizen> 3 </since_tizen>
1117             public Wheel Wheel
1118             {
1119                 get
1120                 {
1121                     return _wheel;
1122                 }
1123                 set
1124                 {
1125                     _wheel = value;
1126                 }
1127             }
1128         }
1129
1130         /// <summary>
1131         /// Event arguments of visibility changed.
1132         /// </summary>
1133         /// <since_tizen> 3 </since_tizen>
1134         public class VisibilityChangedEventArgs : EventArgs
1135         {
1136             private View _view;
1137             private bool _visibility;
1138             private VisibilityChangeType _type;
1139
1140             /// <summary>
1141             /// The view, or child of view, whose visibility has changed.
1142             /// </summary>
1143             /// <since_tizen> 3 </since_tizen>
1144             public View View
1145             {
1146                 get
1147                 {
1148                     return _view;
1149                 }
1150                 set
1151                 {
1152                     _view = value;
1153                 }
1154             }
1155
1156             /// <summary>
1157             /// Whether the view is now visible or not.
1158             /// </summary>
1159             /// <since_tizen> 3 </since_tizen>
1160             public bool Visibility
1161             {
1162                 get
1163                 {
1164                     return _visibility;
1165                 }
1166                 set
1167                 {
1168                     _visibility = value;
1169                 }
1170             }
1171
1172             /// <summary>
1173             /// Whether the view's visible property has changed or a parent's.
1174             /// </summary>
1175             /// <since_tizen> 3 </since_tizen>
1176             public VisibilityChangeType Type
1177             {
1178                 get
1179                 {
1180                     return _type;
1181                 }
1182                 set
1183                 {
1184                     _type = value;
1185                 }
1186             }
1187         }
1188
1189         /// <summary>
1190         /// Event arguments of layout direction changed.
1191         /// </summary>
1192         /// <since_tizen> 4 </since_tizen>
1193         public class LayoutDirectionChangedEventArgs : EventArgs
1194         {
1195             private View _view;
1196             private ViewLayoutDirectionType _type;
1197
1198             /// <summary>
1199             /// The view, or child of view, whose layout direction has changed.
1200             /// </summary>
1201             /// <since_tizen> 4 </since_tizen>
1202             public View View
1203             {
1204                 get
1205                 {
1206                     return _view;
1207                 }
1208                 set
1209                 {
1210                     _view = value;
1211                 }
1212             }
1213
1214             /// <summary>
1215             /// Whether the view's layout direction property has changed or a parent's.
1216             /// </summary>
1217             /// <since_tizen> 4 </since_tizen>
1218             public ViewLayoutDirectionType Type
1219             {
1220                 get
1221                 {
1222                     return _type;
1223                 }
1224                 set
1225                 {
1226                     _type = value;
1227                 }
1228             }
1229         }
1230
1231         internal class BackgroundResourceLoadedEventArgs : EventArgs
1232         {
1233             private ResourceLoadingStatusType status = ResourceLoadingStatusType.Invalid;
1234             public ResourceLoadingStatusType Status
1235             {
1236                 get
1237                 {
1238                     return status;
1239                 }
1240                 set
1241                 {
1242                     status = value;
1243                 }
1244             }
1245         }
1246
1247         /// <summary>
1248         /// The class represents the information of the situation where the View's control state changes.
1249         /// </summary>
1250         [EditorBrowsable(EditorBrowsableState.Never)]
1251         public class ControlStateChangedEventArgs : EventArgs
1252         {
1253             /// <summary>
1254             /// Create an instance with mandatory fields.
1255             /// </summary>
1256             /// <param name="previousState">The previous control state.</param>
1257             /// <param name="currentState">The current control state.</param>
1258             [EditorBrowsable(EditorBrowsableState.Never)]
1259             public ControlStateChangedEventArgs(ControlState previousState, ControlState currentState)
1260             {
1261                 PreviousState = previousState;
1262                 CurrentState = currentState;
1263             }
1264
1265             /// <summary>
1266             /// The previous control state.
1267             /// </summary>
1268             [EditorBrowsable(EditorBrowsableState.Never)]
1269             public ControlState PreviousState { get; }
1270
1271             /// <summary>
1272             /// The current control state.
1273             /// </summary>
1274             [EditorBrowsable(EditorBrowsableState.Never)]
1275             public ControlState CurrentState { get; }
1276         }
1277
1278         private EventHandlerWithReturnType<object, WheelEventArgs, bool> WindowWheelEventHandler;
1279         private void OnWindowWheelEvent(object sender, Window.WheelEventArgs e)
1280         {
1281             if (e != null)
1282             {
1283                 if (e.Wheel.Type == Wheel.WheelType.CustomWheel)
1284                 {
1285                     var arg = new WheelEventArgs()
1286                     {
1287                         Wheel = e.Wheel,
1288                     };
1289                     WindowWheelEventHandler?.Invoke(this, arg);
1290                 }
1291             }
1292         }
1293
1294     }
1295 }