2 * Copyright(c) 2020 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
19 using System.ComponentModel;
20 using System.Runtime.InteropServices;
21 using Tizen.NUI.Components;
23 namespace Tizen.NUI.BaseComponents
26 /// View is the base class for all views.
28 /// <since_tizen> 3 </since_tizen>
29 public partial class View
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;
61 private OnWindowEventCallbackType _onWindowSendEventCallback;
63 private void SendViewAddedEventToWindow(IntPtr data)
65 NUIApplication.GetDefaultWindow()?.SendViewAdded(this);
68 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
69 private delegate void OffWindowEventCallbackType(IntPtr control);
70 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
71 private delegate bool WheelEventCallbackType(IntPtr view, IntPtr wheelEvent);
72 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
73 private delegate bool KeyCallbackType(IntPtr control, IntPtr keyEvent);
74 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
75 private delegate bool TouchDataCallbackType(IntPtr view, IntPtr touchData);
76 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
77 private delegate bool HoverEventCallbackType(IntPtr view, IntPtr hoverEvent);
78 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
79 private delegate void VisibilityChangedEventCallbackType(IntPtr data, bool visibility, VisibilityChangeType type);
80 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
81 private delegate void ResourcesLoadedCallbackType(IntPtr control);
82 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
83 private delegate void _backgroundResourceLoadedCallbackType(IntPtr view);
84 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
85 private delegate void KeyInputFocusGainedCallbackType(IntPtr control);
86 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
87 private delegate void KeyInputFocusLostCallbackType(IntPtr control);
88 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
89 private delegate void OnRelayoutEventCallbackType(IntPtr control);
90 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
91 private delegate void OnWindowEventCallbackType(IntPtr control);
92 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
93 private delegate void LayoutDirectionChangedEventCallbackType(IntPtr data, ViewLayoutDirectionType type);
96 /// Event when a child is removed.
98 /// <since_tizen> 5 </since_tizen>
99 public new event EventHandler<ChildRemovedEventArgs> ChildRemoved;
101 /// Event when a child is added.
103 /// <since_tizen> 5 </since_tizen>
104 public new event EventHandler<ChildAddedEventArgs> ChildAdded;
107 /// An event for the KeyInputFocusGained signal which can be used to subscribe or unsubscribe the event handler provided by the user.<br />
108 /// The KeyInputFocusGained signal is emitted when the control gets the key input focus.<br />
110 /// <since_tizen> 3 </since_tizen>
111 public event EventHandler FocusGained
115 if (_keyInputFocusGainedEventHandler == null)
117 _keyInputFocusGainedCallback = OnKeyInputFocusGained;
118 this.KeyInputFocusGainedSignal().Connect(_keyInputFocusGainedCallback);
121 _keyInputFocusGainedEventHandler += value;
126 _keyInputFocusGainedEventHandler -= value;
128 if (_keyInputFocusGainedEventHandler == null && KeyInputFocusGainedSignal().Empty() == false)
130 this.KeyInputFocusGainedSignal().Disconnect(_keyInputFocusGainedCallback);
136 /// An event for the KeyInputFocusLost signal which can be used to subscribe or unsubscribe the event handler provided by the user.<br />
137 /// The KeyInputFocusLost signal is emitted when the control loses the key input focus.<br />
139 /// <since_tizen> 3 </since_tizen>
140 public event EventHandler FocusLost
144 if (_keyInputFocusLostEventHandler == null)
146 _keyInputFocusLostCallback = OnKeyInputFocusLost;
147 this.KeyInputFocusLostSignal().Connect(_keyInputFocusLostCallback);
150 _keyInputFocusLostEventHandler += value;
155 _keyInputFocusLostEventHandler -= value;
157 if (_keyInputFocusLostEventHandler == null && KeyInputFocusLostSignal().Empty() == false)
159 this.KeyInputFocusLostSignal().Disconnect(_keyInputFocusLostCallback);
165 /// An event for the KeyPressed signal which can be used to subscribe or unsubscribe the event handler provided by the user.<br />
166 /// The KeyPressed signal is emitted when the key event is received.<br />
168 /// <since_tizen> 3 </since_tizen>
169 public event EventHandlerWithReturnType<object, KeyEventArgs, bool> KeyEvent
173 if (_keyEventHandler == null)
175 _keyCallback = OnKeyEvent;
176 this.KeyEventSignal().Connect(_keyCallback);
179 _keyEventHandler += value;
184 _keyEventHandler -= value;
186 if (_keyEventHandler == null && KeyEventSignal().Empty() == false)
188 this.KeyEventSignal().Disconnect(_keyCallback);
194 /// An event for the OnRelayout signal which can be used to subscribe or unsubscribe the event handler.<br />
195 /// The OnRelayout signal is emitted after the size has been set on the view during relayout.<br />
197 /// <since_tizen> 3 </since_tizen>
198 public event EventHandler Relayout
202 if (_onRelayoutEventHandler == null)
204 _onRelayoutEventCallback = OnRelayout;
205 this.OnRelayoutSignal().Connect(_onRelayoutEventCallback);
208 _onRelayoutEventHandler += value;
213 _onRelayoutEventHandler -= value;
215 if (_onRelayoutEventHandler == null && OnRelayoutSignal().Empty() == false)
217 this.OnRelayoutSignal().Disconnect(_onRelayoutEventCallback);
224 /// An event for the touched signal which can be used to subscribe or unsubscribe the event handler provided by the user.<br />
225 /// The touched signal is emitted when the touch input is received.<br />
226 /// This can receive touch events before child. <br />
227 /// 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 />
229 [EditorBrowsable(EditorBrowsableState.Never)]
230 public event EventHandlerWithReturnType<object, TouchEventArgs, bool> InterceptTouchEvent
234 if (_interceptTouchDataEventHandler == null)
236 _interceptTouchDataCallback = OnInterceptTouch;
237 this.InterceptTouchSignal().Connect(_interceptTouchDataCallback);
240 _interceptTouchDataEventHandler += value;
245 _interceptTouchDataEventHandler -= value;
247 if (_interceptTouchDataEventHandler == null && InterceptTouchSignal().Empty() == false)
249 this.InterceptTouchSignal().Disconnect(_interceptTouchDataCallback);
255 /// An event for the touched signal which can be used to subscribe or unsubscribe the event handler provided by the user.<br />
256 /// The touched signal is emitted when the touch input is received.<br />
258 /// <since_tizen> 3 </since_tizen>
259 public event EventHandlerWithReturnType<object, TouchEventArgs, bool> TouchEvent
263 if (_touchDataEventHandler == null)
265 _touchDataCallback = OnTouch;
266 this.TouchSignal().Connect(_touchDataCallback);
269 _touchDataEventHandler += value;
274 _touchDataEventHandler -= value;
276 if (_touchDataEventHandler == null && TouchSignal().Empty() == false)
278 this.TouchSignal().Disconnect(_touchDataCallback);
284 /// An event for the hovered signal which can be used to subscribe or unsubscribe the event handler provided by the user.<br />
285 /// The hovered signal is emitted when the hover input is received.<br />
287 /// <since_tizen> 3 </since_tizen>
288 public event EventHandlerWithReturnType<object, HoverEventArgs, bool> HoverEvent
292 if (_hoverEventHandler == null)
294 _hoverEventCallback = OnHoverEvent;
295 this.HoveredSignal().Connect(_hoverEventCallback);
298 _hoverEventHandler += value;
303 _hoverEventHandler -= value;
305 if (_hoverEventHandler == null && HoveredSignal().Empty() == false)
307 this.HoveredSignal().Disconnect(_hoverEventCallback);
314 /// An event for the WheelMoved signal which can be used to subscribe or unsubscribe the event handler provided by the user.<br />
315 /// The WheelMoved signal is emitted when the wheel event is received.<br />
317 /// <since_tizen> 3 </since_tizen>
318 public event EventHandlerWithReturnType<object, WheelEventArgs, bool> WheelEvent
322 if (_wheelEventHandler == null)
324 _wheelEventCallback = OnWheelEvent;
325 this.WheelEventSignal().Connect(_wheelEventCallback);
327 _wheelEventHandler += value;
329 if (WindowWheelEventHandler == null)
331 NUIApplication.GetDefaultWindow().WheelEvent += OnWindowWheelEvent;
333 WindowWheelEventHandler += value;
338 _wheelEventHandler -= value;
339 if (_wheelEventHandler == null && WheelEventSignal().Empty() == false)
341 this.WheelEventSignal().Disconnect(_wheelEventCallback);
344 WindowWheelEventHandler -= value;
345 if (WindowWheelEventHandler == null)
347 NUIApplication.GetDefaultWindow().WheelEvent -= OnWindowWheelEvent;
353 /// An event for the OnWindow signal which can be used to subscribe or unsubscribe the event handler.<br />
354 /// The OnWindow signal is emitted after the view has been connected to the window.<br />
356 /// <since_tizen> 3 </since_tizen>
357 public event EventHandler AddedToWindow
361 if (_onWindowEventHandler == null)
363 _onWindowEventCallback = OnWindow;
364 this.OnWindowSignal().Connect(_onWindowEventCallback);
367 _onWindowEventHandler += value;
372 _onWindowEventHandler -= value;
374 if (_onWindowEventHandler == null && OnWindowSignal().Empty() == false)
376 this.OnWindowSignal().Disconnect(_onWindowEventCallback);
382 /// An event for the OffWindow signal, which can be used to subscribe or unsubscribe the event handler.<br />
383 /// OffWindow signal is emitted after the view has been disconnected from the window.<br />
385 /// <since_tizen> 3 </since_tizen>
386 public event EventHandler RemovedFromWindow
390 if (_offWindowEventHandler == null)
392 _offWindowEventCallback = OffWindow;
393 this.OffWindowSignal().Connect(_offWindowEventCallback);
396 _offWindowEventHandler += value;
401 _offWindowEventHandler -= value;
403 if (_offWindowEventHandler == null && OffWindowSignal().Empty() == false)
405 this.OffWindowSignal().Disconnect(_offWindowEventCallback);
411 /// An event for visibility change which can be used to subscribe or unsubscribe the event handler.<br />
412 /// This signal is emitted when the visible property of this or a parent view is changed.<br />
414 /// <since_tizen> 3 </since_tizen>
415 public event EventHandler<VisibilityChangedEventArgs> VisibilityChanged
419 if (_visibilityChangedEventHandler == null)
421 _visibilityChangedEventCallback = OnVisibilityChanged;
422 VisibilityChangedSignal(this).Connect(_visibilityChangedEventCallback);
425 _visibilityChangedEventHandler += value;
430 _visibilityChangedEventHandler -= value;
432 if (_visibilityChangedEventHandler == null && VisibilityChangedSignal(this).Empty() == false)
434 VisibilityChangedSignal(this).Disconnect(_visibilityChangedEventCallback);
440 /// Event for layout direction change which can be used to subscribe/unsubscribe the event handler.<br />
441 /// This signal is emitted when the layout direction property of this or a parent view is changed.<br />
443 /// <since_tizen> 4 </since_tizen>
444 public event EventHandler<LayoutDirectionChangedEventArgs> LayoutDirectionChanged
448 if (_layoutDirectionChangedEventHandler == null)
450 _layoutDirectionChangedEventCallback = OnLayoutDirectionChanged;
451 LayoutDirectionChangedSignal(this).Connect(_layoutDirectionChangedEventCallback);
454 _layoutDirectionChangedEventHandler += value;
459 _layoutDirectionChangedEventHandler -= value;
461 if (_layoutDirectionChangedEventHandler == null && LayoutDirectionChangedSignal(this).Empty() == false)
463 LayoutDirectionChangedSignal(this).Disconnect(_layoutDirectionChangedEventCallback);
469 /// An event for the ResourcesLoadedSignal signal which can be used to subscribe or unsubscribe the event handler provided by the user.<br />
470 /// This signal is emitted after all resources required by a view are loaded and ready.<br />
472 /// <since_tizen> 3 </since_tizen>
473 public event EventHandler ResourcesLoaded
477 if (_resourcesLoadedEventHandler == null)
479 _ResourcesLoadedCallback = OnResourcesLoaded;
480 this.ResourcesLoadedSignal().Connect(_ResourcesLoadedCallback);
483 _resourcesLoadedEventHandler += value;
488 _resourcesLoadedEventHandler -= value;
490 if (_resourcesLoadedEventHandler == null && ResourcesLoadedSignal().Empty() == false)
492 this.ResourcesLoadedSignal().Disconnect(_ResourcesLoadedCallback);
497 private EventHandler _backKeyPressed;
500 /// An event for getting notice when physical back key is pressed.<br />
501 /// This event is emitted BackKey is up.<br />
503 [EditorBrowsable(EditorBrowsableState.Never)]
504 public event EventHandler BackKeyPressed
508 _backKeyPressed += value;
509 BackKeyManager.Instance.Subscriber.Add(this);
514 BackKeyManager.Instance.Subscriber.Remove(this);
515 _backKeyPressed -= value;
520 /// Function for emitting BackKeyPressed event outside of View instance
522 [EditorBrowsable(EditorBrowsableState.Never)]
523 internal void EmitBackKeyPressed()
525 _backKeyPressed.Invoke(this,null);
529 internal event EventHandler<BackgroundResourceLoadedEventArgs> BackgroundResourceLoaded
533 if (_backgroundResourceLoadedEventHandler == null)
535 _backgroundResourceLoadedCallback = OnBackgroundResourceLoaded;
536 this.ResourcesLoadedSignal().Connect(_backgroundResourceLoadedCallback);
539 _backgroundResourceLoadedEventHandler += value;
543 _backgroundResourceLoadedEventHandler -= value;
545 if (_backgroundResourceLoadedEventHandler == null && ResourcesLoadedSignal().Empty() == false)
547 this.ResourcesLoadedSignal().Disconnect(_backgroundResourceLoadedCallback);
552 internal TouchDataSignal InterceptTouchSignal()
554 TouchDataSignal ret = new TouchDataSignal(Interop.ActorSignal.Actor_InterceptTouchSignal(swigCPtr), false);
555 if (NDalicPINVOKE.SWIGPendingException.Pending)
556 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
560 internal TouchDataSignal TouchSignal()
562 TouchDataSignal ret = new TouchDataSignal(Interop.ActorSignal.Actor_TouchSignal(swigCPtr), false);
563 if (NDalicPINVOKE.SWIGPendingException.Pending)
564 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
568 internal HoverSignal HoveredSignal()
570 HoverSignal ret = new HoverSignal(Interop.ActorSignal.Actor_HoveredSignal(swigCPtr), false);
571 if (NDalicPINVOKE.SWIGPendingException.Pending)
572 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
576 internal WheelSignal WheelEventSignal()
578 WheelSignal ret = new WheelSignal(Interop.ActorSignal.Actor_WheelEventSignal(swigCPtr), false);
579 if (NDalicPINVOKE.SWIGPendingException.Pending)
580 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
584 internal ViewSignal OnWindowSignal()
586 ViewSignal ret = new ViewSignal(Interop.ActorSignal.Actor_OnSceneSignal(swigCPtr), false);
587 if (NDalicPINVOKE.SWIGPendingException.Pending)
588 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
592 internal ViewSignal OffWindowSignal()
594 ViewSignal ret = new ViewSignal(Interop.ActorSignal.Actor_OffSceneSignal(swigCPtr), false);
595 if (NDalicPINVOKE.SWIGPendingException.Pending)
596 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
600 internal ViewSignal OnRelayoutSignal()
602 ViewSignal ret = new ViewSignal(Interop.ActorSignal.Actor_OnRelayoutSignal(swigCPtr), false);
603 if (NDalicPINVOKE.SWIGPendingException.Pending)
604 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
608 internal ViewVisibilityChangedSignal VisibilityChangedSignal(View view)
610 ViewVisibilityChangedSignal ret = new ViewVisibilityChangedSignal(Interop.NDalic.VisibilityChangedSignal(View.getCPtr(view)), false);
611 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
615 internal ViewLayoutDirectionChangedSignal LayoutDirectionChangedSignal(View view)
617 ViewLayoutDirectionChangedSignal ret = new ViewLayoutDirectionChangedSignal(Interop.Layout.LayoutDirectionChangedSignal(View.getCPtr(view)), false);
618 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
622 internal ViewSignal ResourcesLoadedSignal()
624 ViewSignal ret = new ViewSignal(Interop.View.ResourceReadySignal(swigCPtr), false);
625 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
629 internal ControlKeySignal KeyEventSignal()
631 ControlKeySignal ret = new ControlKeySignal(Interop.ViewSignal.View_KeyEventSignal(swigCPtr), false);
632 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
636 internal KeyInputFocusSignal KeyInputFocusGainedSignal()
638 KeyInputFocusSignal ret = new KeyInputFocusSignal(Interop.ViewSignal.View_KeyInputFocusGainedSignal(swigCPtr), false);
639 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
643 internal KeyInputFocusSignal KeyInputFocusLostSignal()
645 KeyInputFocusSignal ret = new KeyInputFocusSignal(Interop.ViewSignal.View_KeyInputFocusLostSignal(swigCPtr), false);
646 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
650 private void OnSize2DChanged(int? width, int? height)
654 Tizen.NUI.Object.SetProperty(this.swigCPtr, View.Property.SIZE_WIDTH, new Tizen.NUI.PropertyValue((float)width));
658 Tizen.NUI.Object.SetProperty(this.swigCPtr, View.Property.SIZE_HEIGHT, new Tizen.NUI.PropertyValue((float)height));
662 private void OnMinimumSizeChanged(int? width, int? height)
664 if (width != null && height != null)
666 MinimumSize = new Size2D((int)width, (int)height);
668 else if (width != null && height == null)
670 MinimumSize = new Size2D((int)width, (int)this.GetMinimumSize().Height);
672 else if (width == null && height != null)
674 MinimumSize = new Size2D((int)this.GetMinimumSize().Width, (int)height);
678 //both are null, do nothing.
682 private void OnMaximumSizeChanged(int? width, int? height)
684 if (width != null && height != null)
686 MaximumSize = new Size2D((int)width, (int)height);
688 else if (width != null && height == null)
690 MaximumSize = new Size2D((int)width, (int)this.GetMaximumSize().Height);
692 else if (width == null && height != null)
694 MaximumSize = new Size2D((int)this.GetMaximumSize().Width, (int)height);
698 //both are null, do nothing.
702 private void OnPosition2DChanged(int x, int y)
704 Position2D = new Position2D(x, y);
707 private void OnSizeChanged(float? width, float? height, float? depth)
711 Tizen.NUI.Object.SetProperty(this.swigCPtr, View.Property.SIZE_WIDTH, new Tizen.NUI.PropertyValue((float)width));
715 Tizen.NUI.Object.SetProperty(this.swigCPtr, View.Property.SIZE_HEIGHT, new Tizen.NUI.PropertyValue((float)height));
719 Tizen.NUI.Object.SetProperty(this.swigCPtr, View.Property.SIZE_DEPTH, new Tizen.NUI.PropertyValue((float)depth));
723 private void OnPositionChanged(float x, float y, float z)
725 Position = new Position(x, y, z);
728 private void OnParentOriginChanged(float x, float y, float z)
730 ParentOrigin = new Position(x, y, z);
733 private void OnPivotPointChanged(float x, float y, float z)
735 PivotPoint = new Position(x, y, z);
738 private void OnImageShadowChanged(ShadowBase instance)
740 ImageShadow = (ImageShadow)instance;
743 private void OnBoxShadowChanged(ShadowBase instance)
745 BoxShadow = (Shadow)instance;
748 private void OnBackgroundImageBorderChanged(int left, int right, int bottom, int top)
750 BackgroundImageBorder = new Rectangle(left, right, bottom, top);
753 private void OnKeyInputFocusGained(IntPtr view)
755 if (_keyInputFocusGainedEventHandler != null)
757 _keyInputFocusGainedEventHandler(this, null);
761 private void OnKeyInputFocusLost(IntPtr view)
763 if (_keyInputFocusLostEventHandler != null)
765 _keyInputFocusLostEventHandler(this, null);
769 private bool OnKeyEvent(IntPtr view, IntPtr keyEvent)
771 if (keyEvent == global::System.IntPtr.Zero)
773 NUILog.Error("keyEvent should not be null!");
777 KeyEventArgs e = new KeyEventArgs();
781 e.Key = Tizen.NUI.Key.GetKeyFromPtr(keyEvent);
783 if (_keyEventHandler != null)
785 Delegate[] delegateList = _keyEventHandler.GetInvocationList();
787 // Oring the result of each callback.
788 foreach (EventHandlerWithReturnType<object, KeyEventArgs, bool> del in delegateList)
790 result |= del(this, e);
797 // Callback for View OnRelayout signal
798 private void OnRelayout(IntPtr data)
800 if (_onRelayoutEventHandler != null)
802 _onRelayoutEventHandler(this, null);
806 // Callback for View TouchSignal
807 private bool OnInterceptTouch(IntPtr view, IntPtr touchData)
809 if (touchData == global::System.IntPtr.Zero)
811 NUILog.Error("touchData should not be null!");
815 TouchEventArgs e = new TouchEventArgs();
817 e.Touch = Tizen.NUI.Touch.GetTouchFromPtr(touchData);
819 bool consumed = false;
821 if (_interceptTouchDataEventHandler != null)
823 consumed = _interceptTouchDataEventHandler(this, e);
826 if (enableControlState && !consumed)
828 consumed = HandleControlStateOnTouch(e.Touch);
834 // Callback for View TouchSignal
835 private bool OnTouch(IntPtr view, IntPtr touchData)
837 if (touchData == global::System.IntPtr.Zero)
839 NUILog.Error("touchData should not be null!");
843 TouchEventArgs e = new TouchEventArgs();
845 e.Touch = Tizen.NUI.Touch.GetTouchFromPtr(touchData);
847 bool consumed = false;
849 if (_touchDataEventHandler != null)
851 consumed = _touchDataEventHandler(this, e);
854 if (enableControlState && !consumed)
856 consumed = HandleControlStateOnTouch(e.Touch);
862 // Callback for View Hover signal
863 private bool OnHoverEvent(IntPtr view, IntPtr hoverEvent)
865 if (hoverEvent == global::System.IntPtr.Zero)
867 NUILog.Error("hoverEvent should not be null!");
871 HoverEventArgs e = new HoverEventArgs();
873 e.Hover = Tizen.NUI.Hover.GetHoverFromPtr(hoverEvent);
875 if (_hoverEventHandler != null)
877 return _hoverEventHandler(this, e);
882 // Callback for View Wheel signal
883 private bool OnWheelEvent(IntPtr view, IntPtr wheelEvent)
885 if (wheelEvent == global::System.IntPtr.Zero)
887 NUILog.Error("wheelEvent should not be null!");
891 WheelEventArgs e = new WheelEventArgs();
893 e.Wheel = Tizen.NUI.Wheel.GetWheelFromPtr(wheelEvent);
895 if (_wheelEventHandler != null)
897 return _wheelEventHandler(this, e);
902 // Callback for View OnWindow signal
903 private void OnWindow(IntPtr data)
905 if (_onWindowEventHandler != null)
907 _onWindowEventHandler(this, null);
911 // Callback for View OffWindow signal
912 private void OffWindow(IntPtr data)
914 if (_offWindowEventHandler != null)
916 _offWindowEventHandler(this, null);
920 // Callback for View visibility change signal
921 private void OnVisibilityChanged(IntPtr data, bool visibility, VisibilityChangeType type)
923 VisibilityChangedEventArgs e = new VisibilityChangedEventArgs();
926 e.View = Registry.GetManagedBaseHandleFromNativePtr(data) as View;
928 e.Visibility = visibility;
931 if (_visibilityChangedEventHandler != null)
933 _visibilityChangedEventHandler(this, e);
937 // Callback for View layout direction change signal
938 private void OnLayoutDirectionChanged(IntPtr data, ViewLayoutDirectionType type)
940 LayoutDirectionChangedEventArgs e = new LayoutDirectionChangedEventArgs();
943 e.View = Registry.GetManagedBaseHandleFromNativePtr(data) as View;
947 if (_layoutDirectionChangedEventHandler != null)
949 _layoutDirectionChangedEventHandler(this, e);
953 private void OnResourcesLoaded(IntPtr view)
955 if (_resourcesLoadedEventHandler != null)
957 _resourcesLoadedEventHandler(this, null);
961 private void OnBackgroundResourceLoaded(IntPtr view)
963 BackgroundResourceLoadedEventArgs e = new BackgroundResourceLoadedEventArgs();
964 e.Status = (ResourceLoadingStatusType)Interop.View.View_GetVisualResourceStatus(this.swigCPtr, Property.BACKGROUND);
966 if (_backgroundResourceLoadedEventHandler != null)
968 _backgroundResourceLoadedEventHandler(this, e);
973 /// Event argument passed through the ChildAdded event.
975 /// <since_tizen> 5 </since_tizen>
976 public class ChildAddedEventArgs : EventArgs
979 /// Added child view at moment.
981 /// <since_tizen> 5 </since_tizen>
982 public View Added { get; set; }
986 /// Event argument passed through the ChildRemoved event.
988 /// <since_tizen> 5 </since_tizen>
989 public class ChildRemovedEventArgs : EventArgs
992 /// Removed child view at moment.
994 /// <since_tizen> 5 </since_tizen>
995 public View Removed { get; set; }
999 /// Event arguments that passed via the KeyEvent signal.
1001 /// <since_tizen> 3 </since_tizen>
1002 public class KeyEventArgs : EventArgs
1007 /// Key - is the key sent to the view.
1009 /// <since_tizen> 3 </since_tizen>
1024 /// Event arguments that passed via the touch signal.
1026 /// <since_tizen> 3 </since_tizen>
1027 public class TouchEventArgs : EventArgs
1029 private Touch _touch;
1032 /// Touch - contains the information of touch points.
1034 /// <since_tizen> 3 </since_tizen>
1049 /// Event arguments that passed via the hover signal.
1051 /// <since_tizen> 3 </since_tizen>
1052 public class HoverEventArgs : EventArgs
1054 private Hover _hover;
1057 /// Hover - contains touch points that represent the points that are currently being hovered or the points where a hover has stopped.
1059 /// <since_tizen> 3 </since_tizen>
1074 /// Event arguments that passed via the wheel signal.
1076 /// <since_tizen> 3 </since_tizen>
1077 public class WheelEventArgs : EventArgs
1079 private Wheel _wheel;
1082 /// WheelEvent - store a wheel rolling type: MOUSE_WHEEL or CUSTOM_WHEEL.
1084 /// <since_tizen> 3 </since_tizen>
1099 /// Event arguments of visibility changed.
1101 /// <since_tizen> 3 </since_tizen>
1102 public class VisibilityChangedEventArgs : EventArgs
1105 private bool _visibility;
1106 private VisibilityChangeType _type;
1109 /// The view, or child of view, whose visibility has changed.
1111 /// <since_tizen> 3 </since_tizen>
1125 /// Whether the view is now visible or not.
1127 /// <since_tizen> 3 </since_tizen>
1128 public bool Visibility
1136 _visibility = value;
1141 /// Whether the view's visible property has changed or a parent's.
1143 /// <since_tizen> 3 </since_tizen>
1144 public VisibilityChangeType Type
1158 /// Event arguments of layout direction changed.
1160 /// <since_tizen> 4 </since_tizen>
1161 public class LayoutDirectionChangedEventArgs : EventArgs
1164 private ViewLayoutDirectionType _type;
1167 /// The view, or child of view, whose layout direction has changed.
1169 /// <since_tizen> 4 </since_tizen>
1183 /// Whether the view's layout direction property has changed or a parent's.
1185 /// <since_tizen> 4 </since_tizen>
1186 public ViewLayoutDirectionType Type
1199 internal class BackgroundResourceLoadedEventArgs : EventArgs
1201 private ResourceLoadingStatusType status = ResourceLoadingStatusType.Invalid;
1202 public ResourceLoadingStatusType Status
1216 /// The class represents the information of the situation where the View's control state changes.
1218 [EditorBrowsable(EditorBrowsableState.Never)]
1219 public class ControlStateChangedEventArgs : EventArgs
1222 /// Create an instance with mandatory fields.
1224 /// <param name="previousState">The previous control state.</param>
1225 /// <param name="currentState">The current control state.</param>
1226 [EditorBrowsable(EditorBrowsableState.Never)]
1227 public ControlStateChangedEventArgs(ControlState previousState, ControlState currentState)
1229 PreviousState = previousState;
1230 CurrentState = currentState;
1234 /// The previous control state.
1236 [EditorBrowsable(EditorBrowsableState.Never)]
1237 public ControlState PreviousState { get; }
1240 /// The current control state.
1242 [EditorBrowsable(EditorBrowsableState.Never)]
1243 public ControlState CurrentState { get; }
1246 private EventHandlerWithReturnType<object, WheelEventArgs, bool> WindowWheelEventHandler;
1247 private void OnWindowWheelEvent(object sender, Window.WheelEventArgs e)
1251 if(e.Wheel.Type == Wheel.WheelType.CustomWheel)
1253 var arg = new WheelEventArgs()
1257 WindowWheelEventHandler?.Invoke(this, arg);