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 /// If child view doesn't want the parent's view to intercept the touch, you can set it to true.
257 /// parent.Add(child);
258 /// parent.InterceptTouchEvent += OnInterceptTouchEvent;
259 /// View view = child.GetParent() as View;
260 /// view.DisallowInterceptTouchEvent = true;
261 /// This prevents the parent from interceping touch.
263 [EditorBrowsable(EditorBrowsableState.Never)]
264 public bool DisallowInterceptTouchEvent {get; set;}
268 /// An event for the touched signal which can be used to subscribe or unsubscribe the event handler provided by the user.<br />
269 /// The touched signal is emitted when the touch input is received.<br />
271 /// <since_tizen> 3 </since_tizen>
272 public event EventHandlerWithReturnType<object, TouchEventArgs, bool> TouchEvent
276 if (_touchDataEventHandler == null)
278 _touchDataCallback = OnTouch;
279 this.TouchSignal().Connect(_touchDataCallback);
282 _touchDataEventHandler += value;
287 _touchDataEventHandler -= value;
289 if (_touchDataEventHandler == null && TouchSignal().Empty() == false)
291 this.TouchSignal().Disconnect(_touchDataCallback);
297 /// An event for the hovered signal which can be used to subscribe or unsubscribe the event handler provided by the user.<br />
298 /// The hovered signal is emitted when the hover input is received.<br />
300 /// <since_tizen> 3 </since_tizen>
301 public event EventHandlerWithReturnType<object, HoverEventArgs, bool> HoverEvent
305 if (_hoverEventHandler == null)
307 _hoverEventCallback = OnHoverEvent;
308 this.HoveredSignal().Connect(_hoverEventCallback);
311 _hoverEventHandler += value;
316 _hoverEventHandler -= value;
318 if (_hoverEventHandler == null && HoveredSignal().Empty() == false)
320 this.HoveredSignal().Disconnect(_hoverEventCallback);
327 /// An event for the WheelMoved signal which can be used to subscribe or unsubscribe the event handler provided by the user.<br />
328 /// The WheelMoved signal is emitted when the wheel event is received.<br />
330 /// <since_tizen> 3 </since_tizen>
331 public event EventHandlerWithReturnType<object, WheelEventArgs, bool> WheelEvent
335 if (_wheelEventHandler == null)
337 _wheelEventCallback = OnWheelEvent;
338 this.WheelEventSignal().Connect(_wheelEventCallback);
340 _wheelEventHandler += value;
342 if (WindowWheelEventHandler == null)
344 NUIApplication.GetDefaultWindow().WheelEvent += OnWindowWheelEvent;
346 WindowWheelEventHandler += value;
351 _wheelEventHandler -= value;
352 if (_wheelEventHandler == null && WheelEventSignal().Empty() == false)
354 this.WheelEventSignal().Disconnect(_wheelEventCallback);
357 WindowWheelEventHandler -= value;
358 if (WindowWheelEventHandler == null)
360 NUIApplication.GetDefaultWindow().WheelEvent -= OnWindowWheelEvent;
366 /// An event for the OnWindow signal which can be used to subscribe or unsubscribe the event handler.<br />
367 /// The OnWindow signal is emitted after the view has been connected to the window.<br />
369 /// <since_tizen> 3 </since_tizen>
370 public event EventHandler AddedToWindow
374 if (_onWindowEventHandler == null)
376 _onWindowEventCallback = OnWindow;
377 this.OnWindowSignal().Connect(_onWindowEventCallback);
380 _onWindowEventHandler += value;
385 _onWindowEventHandler -= value;
387 if (_onWindowEventHandler == null && OnWindowSignal().Empty() == false)
389 this.OnWindowSignal().Disconnect(_onWindowEventCallback);
395 /// An event for the OffWindow signal, which can be used to subscribe or unsubscribe the event handler.<br />
396 /// OffWindow signal is emitted after the view has been disconnected from the window.<br />
398 /// <since_tizen> 3 </since_tizen>
399 public event EventHandler RemovedFromWindow
403 if (_offWindowEventHandler == null)
405 _offWindowEventCallback = OffWindow;
406 this.OffWindowSignal().Connect(_offWindowEventCallback);
409 _offWindowEventHandler += value;
414 _offWindowEventHandler -= value;
416 if (_offWindowEventHandler == null && OffWindowSignal().Empty() == false)
418 this.OffWindowSignal().Disconnect(_offWindowEventCallback);
424 /// An event for visibility change which can be used to subscribe or unsubscribe the event handler.<br />
425 /// This signal is emitted when the visible property of this or a parent view is changed.<br />
427 /// <since_tizen> 3 </since_tizen>
428 public event EventHandler<VisibilityChangedEventArgs> VisibilityChanged
432 if (_visibilityChangedEventHandler == null)
434 _visibilityChangedEventCallback = OnVisibilityChanged;
435 VisibilityChangedSignal(this).Connect(_visibilityChangedEventCallback);
438 _visibilityChangedEventHandler += value;
443 _visibilityChangedEventHandler -= value;
445 if (_visibilityChangedEventHandler == null && VisibilityChangedSignal(this).Empty() == false)
447 VisibilityChangedSignal(this).Disconnect(_visibilityChangedEventCallback);
453 /// Event for layout direction change which can be used to subscribe/unsubscribe the event handler.<br />
454 /// This signal is emitted when the layout direction property of this or a parent view is changed.<br />
456 /// <since_tizen> 4 </since_tizen>
457 public event EventHandler<LayoutDirectionChangedEventArgs> LayoutDirectionChanged
461 if (_layoutDirectionChangedEventHandler == null)
463 _layoutDirectionChangedEventCallback = OnLayoutDirectionChanged;
464 LayoutDirectionChangedSignal(this).Connect(_layoutDirectionChangedEventCallback);
467 _layoutDirectionChangedEventHandler += value;
472 _layoutDirectionChangedEventHandler -= value;
474 if (_layoutDirectionChangedEventHandler == null && LayoutDirectionChangedSignal(this).Empty() == false)
476 LayoutDirectionChangedSignal(this).Disconnect(_layoutDirectionChangedEventCallback);
482 /// An event for the ResourcesLoadedSignal signal which can be used to subscribe or unsubscribe the event handler provided by the user.<br />
483 /// This signal is emitted after all resources required by a view are loaded and ready.<br />
485 /// <since_tizen> 3 </since_tizen>
486 public event EventHandler ResourcesLoaded
490 if (_resourcesLoadedEventHandler == null)
492 _ResourcesLoadedCallback = OnResourcesLoaded;
493 this.ResourcesLoadedSignal().Connect(_ResourcesLoadedCallback);
496 _resourcesLoadedEventHandler += value;
501 _resourcesLoadedEventHandler -= value;
503 if (_resourcesLoadedEventHandler == null && ResourcesLoadedSignal().Empty() == false)
505 this.ResourcesLoadedSignal().Disconnect(_ResourcesLoadedCallback);
510 private EventHandler _backKeyPressed;
513 /// An event for getting notice when physical back key is pressed.<br />
514 /// This event is emitted BackKey is up.<br />
516 [EditorBrowsable(EditorBrowsableState.Never)]
517 public event EventHandler BackKeyPressed
521 _backKeyPressed += value;
522 BackKeyManager.Instance.Subscriber.Add(this);
527 BackKeyManager.Instance.Subscriber.Remove(this);
528 _backKeyPressed -= value;
533 /// Function for emitting BackKeyPressed event outside of View instance
535 [EditorBrowsable(EditorBrowsableState.Never)]
536 internal void EmitBackKeyPressed()
538 _backKeyPressed.Invoke(this,null);
542 internal event EventHandler<BackgroundResourceLoadedEventArgs> BackgroundResourceLoaded
546 if (_backgroundResourceLoadedEventHandler == null)
548 _backgroundResourceLoadedCallback = OnBackgroundResourceLoaded;
549 this.ResourcesLoadedSignal().Connect(_backgroundResourceLoadedCallback);
552 _backgroundResourceLoadedEventHandler += value;
556 _backgroundResourceLoadedEventHandler -= value;
558 if (_backgroundResourceLoadedEventHandler == null && ResourcesLoadedSignal().Empty() == false)
560 this.ResourcesLoadedSignal().Disconnect(_backgroundResourceLoadedCallback);
565 internal TouchDataSignal InterceptTouchSignal()
567 TouchDataSignal ret = new TouchDataSignal(Interop.ActorSignal.Actor_InterceptTouchSignal(swigCPtr), false);
568 if (NDalicPINVOKE.SWIGPendingException.Pending)
569 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
573 internal TouchDataSignal TouchSignal()
575 TouchDataSignal ret = new TouchDataSignal(Interop.ActorSignal.Actor_TouchSignal(swigCPtr), false);
576 if (NDalicPINVOKE.SWIGPendingException.Pending)
577 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
581 internal HoverSignal HoveredSignal()
583 HoverSignal ret = new HoverSignal(Interop.ActorSignal.Actor_HoveredSignal(swigCPtr), false);
584 if (NDalicPINVOKE.SWIGPendingException.Pending)
585 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
589 internal WheelSignal WheelEventSignal()
591 WheelSignal ret = new WheelSignal(Interop.ActorSignal.Actor_WheelEventSignal(swigCPtr), false);
592 if (NDalicPINVOKE.SWIGPendingException.Pending)
593 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
597 internal ViewSignal OnWindowSignal()
599 ViewSignal ret = new ViewSignal(Interop.ActorSignal.Actor_OnSceneSignal(swigCPtr), false);
600 if (NDalicPINVOKE.SWIGPendingException.Pending)
601 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
605 internal ViewSignal OffWindowSignal()
607 ViewSignal ret = new ViewSignal(Interop.ActorSignal.Actor_OffSceneSignal(swigCPtr), false);
608 if (NDalicPINVOKE.SWIGPendingException.Pending)
609 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
613 internal ViewSignal OnRelayoutSignal()
615 ViewSignal ret = new ViewSignal(Interop.ActorSignal.Actor_OnRelayoutSignal(swigCPtr), false);
616 if (NDalicPINVOKE.SWIGPendingException.Pending)
617 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
621 internal ViewVisibilityChangedSignal VisibilityChangedSignal(View view)
623 ViewVisibilityChangedSignal ret = new ViewVisibilityChangedSignal(Interop.NDalic.VisibilityChangedSignal(View.getCPtr(view)), false);
624 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
628 internal ViewLayoutDirectionChangedSignal LayoutDirectionChangedSignal(View view)
630 ViewLayoutDirectionChangedSignal ret = new ViewLayoutDirectionChangedSignal(Interop.Layout.LayoutDirectionChangedSignal(View.getCPtr(view)), false);
631 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
635 internal ViewSignal ResourcesLoadedSignal()
637 ViewSignal ret = new ViewSignal(Interop.View.ResourceReadySignal(swigCPtr), false);
638 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
642 internal ControlKeySignal KeyEventSignal()
644 ControlKeySignal ret = new ControlKeySignal(Interop.ViewSignal.View_KeyEventSignal(swigCPtr), false);
645 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
649 internal KeyInputFocusSignal KeyInputFocusGainedSignal()
651 KeyInputFocusSignal ret = new KeyInputFocusSignal(Interop.ViewSignal.View_KeyInputFocusGainedSignal(swigCPtr), false);
652 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
656 internal KeyInputFocusSignal KeyInputFocusLostSignal()
658 KeyInputFocusSignal ret = new KeyInputFocusSignal(Interop.ViewSignal.View_KeyInputFocusLostSignal(swigCPtr), false);
659 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
663 private void OnSize2DChanged(int? width, int? height)
667 Tizen.NUI.Object.SetProperty(this.swigCPtr, View.Property.SIZE_WIDTH, new Tizen.NUI.PropertyValue((float)width));
671 Tizen.NUI.Object.SetProperty(this.swigCPtr, View.Property.SIZE_HEIGHT, new Tizen.NUI.PropertyValue((float)height));
675 private void OnMinimumSizeChanged(int? width, int? height)
677 if (width != null && height != null)
679 MinimumSize = new Size2D((int)width, (int)height);
681 else if (width != null && height == null)
683 MinimumSize = new Size2D((int)width, (int)this.GetMinimumSize().Height);
685 else if (width == null && height != null)
687 MinimumSize = new Size2D((int)this.GetMinimumSize().Width, (int)height);
691 //both are null, do nothing.
695 private void OnMaximumSizeChanged(int? width, int? height)
697 if (width != null && height != null)
699 MaximumSize = new Size2D((int)width, (int)height);
701 else if (width != null && height == null)
703 MaximumSize = new Size2D((int)width, (int)this.GetMaximumSize().Height);
705 else if (width == null && height != null)
707 MaximumSize = new Size2D((int)this.GetMaximumSize().Width, (int)height);
711 //both are null, do nothing.
715 private void OnPosition2DChanged(int x, int y)
717 Position2D = new Position2D(x, y);
720 private void OnSizeChanged(float? width, float? height, float? depth)
724 Tizen.NUI.Object.SetProperty(this.swigCPtr, View.Property.SIZE_WIDTH, new Tizen.NUI.PropertyValue((float)width));
728 Tizen.NUI.Object.SetProperty(this.swigCPtr, View.Property.SIZE_HEIGHT, new Tizen.NUI.PropertyValue((float)height));
732 Tizen.NUI.Object.SetProperty(this.swigCPtr, View.Property.SIZE_DEPTH, new Tizen.NUI.PropertyValue((float)depth));
736 private void OnPositionChanged(float x, float y, float z)
738 Position = new Position(x, y, z);
741 private void OnParentOriginChanged(float x, float y, float z)
743 ParentOrigin = new Position(x, y, z);
746 private void OnPivotPointChanged(float x, float y, float z)
748 PivotPoint = new Position(x, y, z);
751 private void OnImageShadowChanged(ShadowBase instance)
753 ImageShadow = (ImageShadow)instance;
756 private void OnBoxShadowChanged(ShadowBase instance)
758 BoxShadow = (Shadow)instance;
761 private void OnBackgroundImageBorderChanged(int left, int right, int bottom, int top)
763 BackgroundImageBorder = new Rectangle(left, right, bottom, top);
766 private void OnKeyInputFocusGained(IntPtr view)
768 if (_keyInputFocusGainedEventHandler != null)
770 _keyInputFocusGainedEventHandler(this, null);
774 private void OnKeyInputFocusLost(IntPtr view)
776 if (_keyInputFocusLostEventHandler != null)
778 _keyInputFocusLostEventHandler(this, null);
782 private bool OnKeyEvent(IntPtr view, IntPtr keyEvent)
784 if (keyEvent == global::System.IntPtr.Zero)
786 NUILog.Error("keyEvent should not be null!");
790 KeyEventArgs e = new KeyEventArgs();
794 e.Key = Tizen.NUI.Key.GetKeyFromPtr(keyEvent);
796 if (_keyEventHandler != null)
798 Delegate[] delegateList = _keyEventHandler.GetInvocationList();
800 // Oring the result of each callback.
801 foreach (EventHandlerWithReturnType<object, KeyEventArgs, bool> del in delegateList)
803 result |= del(this, e);
810 // Callback for View OnRelayout signal
811 private void OnRelayout(IntPtr data)
813 if (_onRelayoutEventHandler != null)
815 _onRelayoutEventHandler(this, null);
819 // Callback for View TouchSignal
820 private bool OnInterceptTouch(IntPtr view, IntPtr touchData)
822 if (touchData == global::System.IntPtr.Zero)
824 NUILog.Error("touchData should not be null!");
828 // DisallowInterceptTouchEvent prevents the parent from intercepting touch.
829 if (DisallowInterceptTouchEvent)
834 TouchEventArgs e = new TouchEventArgs();
836 e.Touch = Tizen.NUI.Touch.GetTouchFromPtr(touchData);
838 bool consumed = false;
840 if (_interceptTouchDataEventHandler != null)
842 consumed = _interceptTouchDataEventHandler(this, e);
848 // Callback for View TouchSignal
849 private bool OnTouch(IntPtr view, IntPtr touchData)
851 if (touchData == global::System.IntPtr.Zero)
853 NUILog.Error("touchData should not be null!");
857 TouchEventArgs e = new TouchEventArgs();
859 e.Touch = Tizen.NUI.Touch.GetTouchFromPtr(touchData);
861 bool consumed = false;
863 if (_touchDataEventHandler != null)
865 consumed = _touchDataEventHandler(this, e);
868 if (enableControlState && !consumed)
870 consumed = HandleControlStateOnTouch(e.Touch);
876 // Callback for View Hover signal
877 private bool OnHoverEvent(IntPtr view, IntPtr hoverEvent)
879 if (hoverEvent == global::System.IntPtr.Zero)
881 NUILog.Error("hoverEvent should not be null!");
885 HoverEventArgs e = new HoverEventArgs();
887 e.Hover = Tizen.NUI.Hover.GetHoverFromPtr(hoverEvent);
889 if (_hoverEventHandler != null)
891 return _hoverEventHandler(this, e);
896 // Callback for View Wheel signal
897 private bool OnWheelEvent(IntPtr view, IntPtr wheelEvent)
899 if (wheelEvent == global::System.IntPtr.Zero)
901 NUILog.Error("wheelEvent should not be null!");
905 WheelEventArgs e = new WheelEventArgs();
907 e.Wheel = Tizen.NUI.Wheel.GetWheelFromPtr(wheelEvent);
909 if (_wheelEventHandler != null)
911 return _wheelEventHandler(this, e);
916 // Callback for View OnWindow signal
917 private void OnWindow(IntPtr data)
919 if (_onWindowEventHandler != null)
921 _onWindowEventHandler(this, null);
925 // Callback for View OffWindow signal
926 private void OffWindow(IntPtr data)
928 if (_offWindowEventHandler != null)
930 _offWindowEventHandler(this, null);
934 // Callback for View visibility change signal
935 private void OnVisibilityChanged(IntPtr data, bool visibility, VisibilityChangeType type)
937 VisibilityChangedEventArgs e = new VisibilityChangedEventArgs();
940 e.View = Registry.GetManagedBaseHandleFromNativePtr(data) as View;
942 e.Visibility = visibility;
945 if (_visibilityChangedEventHandler != null)
947 _visibilityChangedEventHandler(this, e);
951 // Callback for View layout direction change signal
952 private void OnLayoutDirectionChanged(IntPtr data, ViewLayoutDirectionType type)
954 LayoutDirectionChangedEventArgs e = new LayoutDirectionChangedEventArgs();
957 e.View = Registry.GetManagedBaseHandleFromNativePtr(data) as View;
961 if (_layoutDirectionChangedEventHandler != null)
963 _layoutDirectionChangedEventHandler(this, e);
967 private void OnResourcesLoaded(IntPtr view)
969 if (_resourcesLoadedEventHandler != null)
971 _resourcesLoadedEventHandler(this, null);
975 private void OnBackgroundResourceLoaded(IntPtr view)
977 BackgroundResourceLoadedEventArgs e = new BackgroundResourceLoadedEventArgs();
978 e.Status = (ResourceLoadingStatusType)Interop.View.View_GetVisualResourceStatus(this.swigCPtr, Property.BACKGROUND);
980 if (_backgroundResourceLoadedEventHandler != null)
982 _backgroundResourceLoadedEventHandler(this, e);
987 /// Event argument passed through the ChildAdded event.
989 /// <since_tizen> 5 </since_tizen>
990 public class ChildAddedEventArgs : EventArgs
993 /// Added child view at moment.
995 /// <since_tizen> 5 </since_tizen>
996 public View Added { get; set; }
1000 /// Event argument passed through the ChildRemoved event.
1002 /// <since_tizen> 5 </since_tizen>
1003 public class ChildRemovedEventArgs : EventArgs
1006 /// Removed child view at moment.
1008 /// <since_tizen> 5 </since_tizen>
1009 public View Removed { get; set; }
1013 /// Event arguments that passed via the KeyEvent signal.
1015 /// <since_tizen> 3 </since_tizen>
1016 public class KeyEventArgs : EventArgs
1021 /// Key - is the key sent to the view.
1023 /// <since_tizen> 3 </since_tizen>
1038 /// Event arguments that passed via the touch signal.
1040 /// <since_tizen> 3 </since_tizen>
1041 public class TouchEventArgs : EventArgs
1043 private Touch _touch;
1046 /// Touch - contains the information of touch points.
1048 /// <since_tizen> 3 </since_tizen>
1063 /// Event arguments that passed via the hover signal.
1065 /// <since_tizen> 3 </since_tizen>
1066 public class HoverEventArgs : EventArgs
1068 private Hover _hover;
1071 /// Hover - contains touch points that represent the points that are currently being hovered or the points where a hover has stopped.
1073 /// <since_tizen> 3 </since_tizen>
1088 /// Event arguments that passed via the wheel signal.
1090 /// <since_tizen> 3 </since_tizen>
1091 public class WheelEventArgs : EventArgs
1093 private Wheel _wheel;
1096 /// WheelEvent - store a wheel rolling type: MOUSE_WHEEL or CUSTOM_WHEEL.
1098 /// <since_tizen> 3 </since_tizen>
1113 /// Event arguments of visibility changed.
1115 /// <since_tizen> 3 </since_tizen>
1116 public class VisibilityChangedEventArgs : EventArgs
1119 private bool _visibility;
1120 private VisibilityChangeType _type;
1123 /// The view, or child of view, whose visibility has changed.
1125 /// <since_tizen> 3 </since_tizen>
1139 /// Whether the view is now visible or not.
1141 /// <since_tizen> 3 </since_tizen>
1142 public bool Visibility
1150 _visibility = value;
1155 /// Whether the view's visible property has changed or a parent's.
1157 /// <since_tizen> 3 </since_tizen>
1158 public VisibilityChangeType Type
1172 /// Event arguments of layout direction changed.
1174 /// <since_tizen> 4 </since_tizen>
1175 public class LayoutDirectionChangedEventArgs : EventArgs
1178 private ViewLayoutDirectionType _type;
1181 /// The view, or child of view, whose layout direction has changed.
1183 /// <since_tizen> 4 </since_tizen>
1197 /// Whether the view's layout direction property has changed or a parent's.
1199 /// <since_tizen> 4 </since_tizen>
1200 public ViewLayoutDirectionType Type
1213 internal class BackgroundResourceLoadedEventArgs : EventArgs
1215 private ResourceLoadingStatusType status = ResourceLoadingStatusType.Invalid;
1216 public ResourceLoadingStatusType Status
1230 /// The class represents the information of the situation where the View's control state changes.
1232 [EditorBrowsable(EditorBrowsableState.Never)]
1233 public class ControlStateChangedEventArgs : EventArgs
1236 /// Create an instance with mandatory fields.
1238 /// <param name="previousState">The previous control state.</param>
1239 /// <param name="currentState">The current control state.</param>
1240 [EditorBrowsable(EditorBrowsableState.Never)]
1241 public ControlStateChangedEventArgs(ControlState previousState, ControlState currentState)
1243 PreviousState = previousState;
1244 CurrentState = currentState;
1248 /// The previous control state.
1250 [EditorBrowsable(EditorBrowsableState.Never)]
1251 public ControlState PreviousState { get; }
1254 /// The current control state.
1256 [EditorBrowsable(EditorBrowsableState.Never)]
1257 public ControlState CurrentState { get; }
1260 private EventHandlerWithReturnType<object, WheelEventArgs, bool> WindowWheelEventHandler;
1261 private void OnWindowWheelEvent(object sender, Window.WheelEventArgs e)
1265 if(e.Wheel.Type == Wheel.WheelType.CustomWheel)
1267 var arg = new WheelEventArgs()
1271 WindowWheelEventHandler?.Invoke(this, arg);