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)
68 NUIApplication.GetDefaultWindow()?.SendViewAdded(this);
71 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
72 private delegate void OffWindowEventCallbackType(IntPtr control);
73 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
74 private delegate bool WheelEventCallbackType(IntPtr view, IntPtr wheelEvent);
75 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
76 private delegate bool KeyCallbackType(IntPtr control, IntPtr keyEvent);
77 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
78 private delegate bool TouchDataCallbackType(IntPtr view, IntPtr touchData);
79 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
80 private delegate bool HoverEventCallbackType(IntPtr view, IntPtr hoverEvent);
81 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
82 private delegate void VisibilityChangedEventCallbackType(IntPtr data, bool visibility, VisibilityChangeType type);
83 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
84 private delegate void ResourcesLoadedCallbackType(IntPtr control);
85 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
86 private delegate void _backgroundResourceLoadedCallbackType(IntPtr view);
87 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
88 private delegate void KeyInputFocusGainedCallbackType(IntPtr control);
89 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
90 private delegate void KeyInputFocusLostCallbackType(IntPtr control);
91 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
92 private delegate void OnRelayoutEventCallbackType(IntPtr control);
93 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
94 private delegate void OnWindowEventCallbackType(IntPtr control);
95 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
96 private delegate void LayoutDirectionChangedEventCallbackType(IntPtr data, ViewLayoutDirectionType type);
99 /// Event when a child is removed.
101 /// <since_tizen> 5 </since_tizen>
102 public new event EventHandler<ChildRemovedEventArgs> ChildRemoved;
104 /// Event when a child is added.
106 /// <since_tizen> 5 </since_tizen>
107 public new event EventHandler<ChildAddedEventArgs> ChildAdded;
110 /// An event for the KeyInputFocusGained signal which can be used to subscribe or unsubscribe the event handler provided by the user.<br />
111 /// The KeyInputFocusGained signal is emitted when the control gets the key input focus.<br />
113 /// <since_tizen> 3 </since_tizen>
114 public event EventHandler FocusGained
118 if (_keyInputFocusGainedEventHandler == null)
120 _keyInputFocusGainedCallback = OnKeyInputFocusGained;
121 this.KeyInputFocusGainedSignal().Connect(_keyInputFocusGainedCallback);
124 _keyInputFocusGainedEventHandler += value;
129 _keyInputFocusGainedEventHandler -= value;
131 if (_keyInputFocusGainedEventHandler == null && KeyInputFocusGainedSignal().Empty() == false)
133 this.KeyInputFocusGainedSignal().Disconnect(_keyInputFocusGainedCallback);
139 /// An event for the KeyInputFocusLost signal which can be used to subscribe or unsubscribe the event handler provided by the user.<br />
140 /// The KeyInputFocusLost signal is emitted when the control loses the key input focus.<br />
142 /// <since_tizen> 3 </since_tizen>
143 public event EventHandler FocusLost
147 if (_keyInputFocusLostEventHandler == null)
149 _keyInputFocusLostCallback = OnKeyInputFocusLost;
150 this.KeyInputFocusLostSignal().Connect(_keyInputFocusLostCallback);
153 _keyInputFocusLostEventHandler += value;
158 _keyInputFocusLostEventHandler -= value;
160 if (_keyInputFocusLostEventHandler == null && KeyInputFocusLostSignal().Empty() == false)
162 this.KeyInputFocusLostSignal().Disconnect(_keyInputFocusLostCallback);
168 /// An event for the KeyPressed signal which can be used to subscribe or unsubscribe the event handler provided by the user.<br />
169 /// The KeyPressed signal is emitted when the key event is received.<br />
171 /// <since_tizen> 3 </since_tizen>
172 public event EventHandlerWithReturnType<object, KeyEventArgs, bool> KeyEvent
176 if (_keyEventHandler == null)
178 _keyCallback = OnKeyEvent;
179 this.KeyEventSignal().Connect(_keyCallback);
182 _keyEventHandler += value;
187 _keyEventHandler -= value;
189 if (_keyEventHandler == null && KeyEventSignal().Empty() == false)
191 this.KeyEventSignal().Disconnect(_keyCallback);
197 /// An event for the OnRelayout signal which can be used to subscribe or unsubscribe the event handler.<br />
198 /// The OnRelayout signal is emitted after the size has been set on the view during relayout.<br />
200 /// <since_tizen> 3 </since_tizen>
201 public event EventHandler Relayout
205 if (_onRelayoutEventHandler == null)
207 _onRelayoutEventCallback = OnRelayout;
208 this.OnRelayoutSignal().Connect(_onRelayoutEventCallback);
211 _onRelayoutEventHandler += value;
216 _onRelayoutEventHandler -= value;
218 if (_onRelayoutEventHandler == null && OnRelayoutSignal().Empty() == false)
220 this.OnRelayoutSignal().Disconnect(_onRelayoutEventCallback);
221 _onRelayoutEventCallback = null;
228 /// An event for the touched signal which can be used to subscribe or unsubscribe the event handler provided by the user.<br />
229 /// The touched signal is emitted when the touch input is received.<br />
230 /// This can receive touch events before child. <br />
231 /// 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 />
233 [EditorBrowsable(EditorBrowsableState.Never)]
234 public event EventHandlerWithReturnType<object, TouchEventArgs, bool> InterceptTouchEvent
238 if (_interceptTouchDataEventHandler == null)
240 _interceptTouchDataCallback = OnInterceptTouch;
241 this.InterceptTouchSignal().Connect(_interceptTouchDataCallback);
244 _interceptTouchDataEventHandler += value;
249 _interceptTouchDataEventHandler -= value;
251 if (_interceptTouchDataEventHandler == null && InterceptTouchSignal().Empty() == false)
253 this.InterceptTouchSignal().Disconnect(_interceptTouchDataCallback);
259 /// If child view doesn't want the parent's view to intercept the touch, you can set it to true.
261 /// parent.Add(child);
262 /// parent.InterceptTouchEvent += OnInterceptTouchEvent;
263 /// View view = child.GetParent() as View;
264 /// view.DisallowInterceptTouchEvent = true;
265 /// This prevents the parent from interceping touch.
267 [EditorBrowsable(EditorBrowsableState.Never)]
268 public bool DisallowInterceptTouchEvent { get; set; }
272 /// An event for the touched signal which can be used to subscribe or unsubscribe the event handler provided by the user.<br />
273 /// The touched signal is emitted when the touch input is received.<br />
275 /// <since_tizen> 3 </since_tizen>
276 public event EventHandlerWithReturnType<object, TouchEventArgs, bool> TouchEvent
280 if (_touchDataEventHandler == null)
282 _touchDataCallback = OnTouch;
283 this.TouchSignal().Connect(_touchDataCallback);
286 _touchDataEventHandler += value;
291 _touchDataEventHandler -= value;
293 if (_touchDataEventHandler == null && TouchSignal().Empty() == false)
295 this.TouchSignal().Disconnect(_touchDataCallback);
301 /// An event for the hovered signal which can be used to subscribe or unsubscribe the event handler provided by the user.<br />
302 /// The hovered signal is emitted when the hover input is received.<br />
304 /// <since_tizen> 3 </since_tizen>
305 public event EventHandlerWithReturnType<object, HoverEventArgs, bool> HoverEvent
309 if (_hoverEventHandler == null)
311 _hoverEventCallback = OnHoverEvent;
312 this.HoveredSignal().Connect(_hoverEventCallback);
315 _hoverEventHandler += value;
320 _hoverEventHandler -= value;
322 if (_hoverEventHandler == null && HoveredSignal().Empty() == false)
324 this.HoveredSignal().Disconnect(_hoverEventCallback);
331 /// An event for the WheelMoved signal which can be used to subscribe or unsubscribe the event handler provided by the user.<br />
332 /// The WheelMoved signal is emitted when the wheel event is received.<br />
334 /// <since_tizen> 3 </since_tizen>
335 public event EventHandlerWithReturnType<object, WheelEventArgs, bool> WheelEvent
339 if (_wheelEventHandler == null)
341 _wheelEventCallback = OnWheelEvent;
342 this.WheelEventSignal().Connect(_wheelEventCallback);
344 _wheelEventHandler += value;
346 if (WindowWheelEventHandler == null)
348 NUIApplication.GetDefaultWindow().WheelEvent += OnWindowWheelEvent;
350 WindowWheelEventHandler += value;
355 _wheelEventHandler -= value;
356 if (_wheelEventHandler == null && WheelEventSignal().Empty() == false)
358 this.WheelEventSignal().Disconnect(_wheelEventCallback);
361 WindowWheelEventHandler -= value;
362 if (WindowWheelEventHandler == null)
364 NUIApplication.GetDefaultWindow().WheelEvent -= OnWindowWheelEvent;
370 /// An event for the OnWindow signal which can be used to subscribe or unsubscribe the event handler.<br />
371 /// The OnWindow signal is emitted after the view has been connected to the window.<br />
373 /// <since_tizen> 3 </since_tizen>
374 public event EventHandler AddedToWindow
378 if (_onWindowEventHandler == null)
380 _onWindowEventCallback = OnWindow;
381 this.OnWindowSignal().Connect(_onWindowEventCallback);
384 _onWindowEventHandler += value;
389 _onWindowEventHandler -= value;
391 if (_onWindowEventHandler == null && OnWindowSignal().Empty() == false)
393 this.OnWindowSignal().Disconnect(_onWindowEventCallback);
394 _onWindowEventCallback = null;
400 /// An event for the OffWindow signal, which can be used to subscribe or unsubscribe the event handler.<br />
401 /// OffWindow signal is emitted after the view has been disconnected from the window.<br />
403 /// <since_tizen> 3 </since_tizen>
404 public event EventHandler RemovedFromWindow
408 if (_offWindowEventHandler == null)
410 _offWindowEventCallback = OffWindow;
411 this.OffWindowSignal().Connect(_offWindowEventCallback);
414 _offWindowEventHandler += value;
419 _offWindowEventHandler -= value;
421 if (_offWindowEventHandler == null && OffWindowSignal().Empty() == false)
423 this.OffWindowSignal().Disconnect(_offWindowEventCallback);
424 _offWindowEventCallback = null;
430 /// An event for visibility change which can be used to subscribe or unsubscribe the event handler.<br />
431 /// This signal is emitted when the visible property of this or a parent view is changed.<br />
433 /// <since_tizen> 3 </since_tizen>
434 public event EventHandler<VisibilityChangedEventArgs> VisibilityChanged
438 if (_visibilityChangedEventHandler == null)
440 _visibilityChangedEventCallback = OnVisibilityChanged;
441 VisibilityChangedSignal(this).Connect(_visibilityChangedEventCallback);
444 _visibilityChangedEventHandler += value;
449 _visibilityChangedEventHandler -= value;
451 if (_visibilityChangedEventHandler == null && VisibilityChangedSignal(this).Empty() == false)
453 VisibilityChangedSignal(this).Disconnect(_visibilityChangedEventCallback);
459 /// Event for layout direction change which can be used to subscribe/unsubscribe the event handler.<br />
460 /// This signal is emitted when the layout direction property of this or a parent view is changed.<br />
462 /// <since_tizen> 4 </since_tizen>
463 public event EventHandler<LayoutDirectionChangedEventArgs> LayoutDirectionChanged
467 if (_layoutDirectionChangedEventHandler == null)
469 _layoutDirectionChangedEventCallback = OnLayoutDirectionChanged;
470 LayoutDirectionChangedSignal(this).Connect(_layoutDirectionChangedEventCallback);
473 _layoutDirectionChangedEventHandler += value;
478 _layoutDirectionChangedEventHandler -= value;
480 if (_layoutDirectionChangedEventHandler == null && LayoutDirectionChangedSignal(this).Empty() == false)
482 LayoutDirectionChangedSignal(this).Disconnect(_layoutDirectionChangedEventCallback);
488 /// An event for the ResourcesLoadedSignal signal which can be used to subscribe or unsubscribe the event handler provided by the user.<br />
489 /// This signal is emitted after all resources required by a view are loaded and ready.<br />
491 /// <since_tizen> 3 </since_tizen>
492 public event EventHandler ResourcesLoaded
496 if (_resourcesLoadedEventHandler == null)
498 _ResourcesLoadedCallback = OnResourcesLoaded;
499 this.ResourcesLoadedSignal().Connect(_ResourcesLoadedCallback);
502 _resourcesLoadedEventHandler += value;
507 _resourcesLoadedEventHandler -= value;
509 if (_resourcesLoadedEventHandler == null && ResourcesLoadedSignal().Empty() == false)
511 this.ResourcesLoadedSignal().Disconnect(_ResourcesLoadedCallback);
512 _ResourcesLoadedCallback = null;
517 private EventHandler _backKeyPressed;
520 /// An event for getting notice when physical back key is pressed.<br />
521 /// This event is emitted BackKey is up.<br />
523 [EditorBrowsable(EditorBrowsableState.Never)]
524 public event EventHandler BackKeyPressed
528 _backKeyPressed += value;
529 BackKeyManager.Instance.Subscriber.Add(this);
534 BackKeyManager.Instance.Subscriber.Remove(this);
535 _backKeyPressed -= value;
540 /// Function for emitting BackKeyPressed event outside of View instance
542 [EditorBrowsable(EditorBrowsableState.Never)]
543 internal void EmitBackKeyPressed()
545 _backKeyPressed.Invoke(this, null);
549 internal event EventHandler<BackgroundResourceLoadedEventArgs> BackgroundResourceLoaded
553 if (_backgroundResourceLoadedEventHandler == null)
555 _backgroundResourceLoadedCallback = OnBackgroundResourceLoaded;
556 this.ResourcesLoadedSignal().Connect(_backgroundResourceLoadedCallback);
559 _backgroundResourceLoadedEventHandler += value;
563 _backgroundResourceLoadedEventHandler -= value;
565 if (_backgroundResourceLoadedEventHandler == null && ResourcesLoadedSignal().Empty() == false)
567 this.ResourcesLoadedSignal().Disconnect(_backgroundResourceLoadedCallback);
568 _backgroundResourceLoadedCallback = null;
573 internal TouchDataSignal InterceptTouchSignal()
575 TouchDataSignal ret = new TouchDataSignal(Interop.ActorSignal.ActorInterceptTouchSignal(SwigCPtr), false);
576 if (NDalicPINVOKE.SWIGPendingException.Pending)
577 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
581 internal TouchDataSignal TouchSignal()
583 TouchDataSignal ret = new TouchDataSignal(Interop.ActorSignal.ActorTouchSignal(SwigCPtr), false);
584 if (NDalicPINVOKE.SWIGPendingException.Pending)
585 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
589 internal HoverSignal HoveredSignal()
591 HoverSignal ret = new HoverSignal(Interop.ActorSignal.ActorHoveredSignal(SwigCPtr), false);
592 if (NDalicPINVOKE.SWIGPendingException.Pending)
593 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
597 internal WheelSignal WheelEventSignal()
599 WheelSignal ret = new WheelSignal(Interop.ActorSignal.ActorWheelEventSignal(SwigCPtr), false);
600 if (NDalicPINVOKE.SWIGPendingException.Pending)
601 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
605 internal ViewSignal OnWindowSignal()
607 ViewSignal ret = new ViewSignal(Interop.ActorSignal.ActorOnSceneSignal(SwigCPtr), false);
608 if (NDalicPINVOKE.SWIGPendingException.Pending)
609 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
613 internal ViewSignal OffWindowSignal()
615 ViewSignal ret = new ViewSignal(Interop.ActorSignal.ActorOffSceneSignal(SwigCPtr), false);
616 if (NDalicPINVOKE.SWIGPendingException.Pending)
617 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
621 internal ViewSignal OnRelayoutSignal()
623 ViewSignal ret = new ViewSignal(Interop.ActorSignal.ActorOnRelayoutSignal(SwigCPtr), false);
624 if (NDalicPINVOKE.SWIGPendingException.Pending)
625 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
629 internal ViewVisibilityChangedSignal VisibilityChangedSignal(View view)
631 ViewVisibilityChangedSignal ret = new ViewVisibilityChangedSignal(Interop.NDalic.VisibilityChangedSignal(View.getCPtr(view)), false);
632 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
636 internal ViewLayoutDirectionChangedSignal LayoutDirectionChangedSignal(View view)
638 ViewLayoutDirectionChangedSignal ret = new ViewLayoutDirectionChangedSignal(Interop.Layout.LayoutDirectionChangedSignal(View.getCPtr(view)), false);
639 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
643 internal ViewSignal ResourcesLoadedSignal()
645 ViewSignal ret = new ViewSignal(Interop.View.ResourceReadySignal(SwigCPtr), false);
646 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
650 internal ControlKeySignal KeyEventSignal()
652 ControlKeySignal ret = new ControlKeySignal(Interop.ViewSignal.KeyEventSignal(SwigCPtr), false);
653 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
657 internal KeyInputFocusSignal KeyInputFocusGainedSignal()
659 KeyInputFocusSignal ret = new KeyInputFocusSignal(Interop.ViewSignal.KeyInputFocusGainedSignal(SwigCPtr), false);
660 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
664 internal KeyInputFocusSignal KeyInputFocusLostSignal()
666 KeyInputFocusSignal ret = new KeyInputFocusSignal(Interop.ViewSignal.KeyInputFocusLostSignal(SwigCPtr), false);
667 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
671 private void OnSize2DChanged(int? width, int? height)
675 Tizen.NUI.Object.SetProperty(this.SwigCPtr, View.Property.SizeWidth, new Tizen.NUI.PropertyValue((float)width));
679 Tizen.NUI.Object.SetProperty(this.SwigCPtr, View.Property.SizeHeight, new Tizen.NUI.PropertyValue((float)height));
683 private void OnMinimumSizeChanged(int? width, int? height)
685 if (width != null && height != null)
687 MinimumSize = new Size2D((int)width, (int)height);
689 else if (width != null && height == null)
691 MinimumSize = new Size2D((int)width, (int)this.GetMinimumSize().Height);
693 else if (width == null && height != null)
695 MinimumSize = new Size2D((int)this.GetMinimumSize().Width, (int)height);
699 //both are null, do nothing.
703 private void OnMaximumSizeChanged(int? width, int? height)
705 if (width != null && height != null)
707 MaximumSize = new Size2D((int)width, (int)height);
709 else if (width != null && height == null)
711 MaximumSize = new Size2D((int)width, (int)this.GetMaximumSize().Height);
713 else if (width == null && height != null)
715 MaximumSize = new Size2D((int)this.GetMaximumSize().Width, (int)height);
719 //both are null, do nothing.
723 private void OnPosition2DChanged(int x, int y)
725 Position2D = new Position2D(x, y);
728 private void OnSizeChanged(float? width, float? height, float? depth)
732 Tizen.NUI.Object.SetProperty(this.SwigCPtr, View.Property.SizeWidth, new Tizen.NUI.PropertyValue((float)width));
736 Tizen.NUI.Object.SetProperty(this.SwigCPtr, View.Property.SizeHeight, new Tizen.NUI.PropertyValue((float)height));
740 Tizen.NUI.Object.SetProperty(this.SwigCPtr, View.Property.SizeDepth, new Tizen.NUI.PropertyValue((float)depth));
744 private void OnPositionChanged(float x, float y, float z)
746 Position = new Position(x, y, z);
749 private void OnParentOriginChanged(float x, float y, float z)
751 ParentOrigin = new Position(x, y, z);
754 private void OnPivotPointChanged(float x, float y, float z)
756 PivotPoint = new Position(x, y, z);
759 private void OnImageShadowChanged(ShadowBase instance)
761 ImageShadow = (ImageShadow)instance;
764 private void OnBoxShadowChanged(ShadowBase instance)
766 BoxShadow = (Shadow)instance;
769 private void OnBackgroundImageBorderChanged(int left, int right, int bottom, int top)
771 BackgroundImageBorder = new Rectangle(left, right, bottom, top);
774 private void OnKeyInputFocusGained(IntPtr view)
776 if (_keyInputFocusGainedEventHandler != null)
778 _keyInputFocusGainedEventHandler(this, null);
782 private void OnKeyInputFocusLost(IntPtr view)
784 if (_keyInputFocusLostEventHandler != null)
786 _keyInputFocusLostEventHandler(this, null);
790 private bool OnKeyEvent(IntPtr view, IntPtr keyEvent)
792 if (keyEvent == global::System.IntPtr.Zero)
794 NUILog.Error("keyEvent should not be null!");
798 KeyEventArgs e = new KeyEventArgs();
802 e.Key = Tizen.NUI.Key.GetKeyFromPtr(keyEvent);
804 if (_keyEventHandler != null)
806 Delegate[] delegateList = _keyEventHandler.GetInvocationList();
808 // Oring the result of each callback.
809 foreach (EventHandlerWithReturnType<object, KeyEventArgs, bool> del in delegateList)
811 result |= del(this, e);
818 // Callback for View OnRelayout signal
819 private void OnRelayout(IntPtr data)
821 if (_onRelayoutEventHandler != null)
823 _onRelayoutEventHandler(this, null);
827 // Callback for View TouchSignal
828 private bool OnInterceptTouch(IntPtr view, IntPtr touchData)
830 if (touchData == global::System.IntPtr.Zero)
832 NUILog.Error("touchData should not be null!");
836 // DisallowInterceptTouchEvent prevents the parent from intercepting touch.
837 if (DisallowInterceptTouchEvent)
842 TouchEventArgs e = new TouchEventArgs();
844 e.Touch = Tizen.NUI.Touch.GetTouchFromPtr(touchData);
846 bool consumed = false;
848 if (_interceptTouchDataEventHandler != null)
850 consumed = _interceptTouchDataEventHandler(this, e);
856 // Callback for View TouchSignal
857 private bool OnTouch(IntPtr view, IntPtr touchData)
859 if (touchData == global::System.IntPtr.Zero)
861 NUILog.Error("touchData should not be null!");
865 TouchEventArgs e = new TouchEventArgs();
867 e.Touch = Tizen.NUI.Touch.GetTouchFromPtr(touchData);
869 bool consumed = false;
871 if (_touchDataEventHandler != null)
873 consumed = _touchDataEventHandler(this, e);
876 if (enableControlState && !consumed)
878 consumed = HandleControlStateOnTouch(e.Touch);
884 // Callback for View Hover signal
885 private bool OnHoverEvent(IntPtr view, IntPtr hoverEvent)
887 if (hoverEvent == global::System.IntPtr.Zero)
889 NUILog.Error("hoverEvent should not be null!");
893 HoverEventArgs e = new HoverEventArgs();
895 e.Hover = Tizen.NUI.Hover.GetHoverFromPtr(hoverEvent);
897 if (_hoverEventHandler != null)
899 return _hoverEventHandler(this, e);
904 // Callback for View Wheel signal
905 private bool OnWheelEvent(IntPtr view, IntPtr wheelEvent)
907 if (wheelEvent == global::System.IntPtr.Zero)
909 NUILog.Error("wheelEvent should not be null!");
913 WheelEventArgs e = new WheelEventArgs();
915 e.Wheel = Tizen.NUI.Wheel.GetWheelFromPtr(wheelEvent);
917 if (_wheelEventHandler != null)
919 return _wheelEventHandler(this, e);
924 // Callback for View OnWindow signal
925 private void OnWindow(IntPtr data)
927 if (_onWindowEventHandler != null)
929 _onWindowEventHandler(this, null);
933 // Callback for View OffWindow signal
934 private void OffWindow(IntPtr data)
936 if (_offWindowEventHandler != null)
938 _offWindowEventHandler(this, null);
942 // Callback for View visibility change signal
943 private void OnVisibilityChanged(IntPtr data, bool visibility, VisibilityChangeType type)
945 VisibilityChangedEventArgs e = new VisibilityChangedEventArgs();
948 e.View = Registry.GetManagedBaseHandleFromNativePtr(data) as View;
950 e.Visibility = visibility;
953 if (_visibilityChangedEventHandler != null)
955 _visibilityChangedEventHandler(this, e);
959 // Callback for View layout direction change signal
960 private void OnLayoutDirectionChanged(IntPtr data, ViewLayoutDirectionType type)
962 LayoutDirectionChangedEventArgs e = new LayoutDirectionChangedEventArgs();
965 e.View = Registry.GetManagedBaseHandleFromNativePtr(data) as View;
969 if (_layoutDirectionChangedEventHandler != null)
971 _layoutDirectionChangedEventHandler(this, e);
975 private void OnResourcesLoaded(IntPtr view)
977 if (_resourcesLoadedEventHandler != null)
979 _resourcesLoadedEventHandler(this, null);
983 private void OnBackgroundResourceLoaded(IntPtr view)
985 BackgroundResourceLoadedEventArgs e = new BackgroundResourceLoadedEventArgs();
986 e.Status = (ResourceLoadingStatusType)Interop.View.GetVisualResourceStatus(this.SwigCPtr, Property.BACKGROUND);
988 if (_backgroundResourceLoadedEventHandler != null)
990 _backgroundResourceLoadedEventHandler(this, e);
995 /// Event argument passed through the ChildAdded event.
997 /// <since_tizen> 5 </since_tizen>
998 public class ChildAddedEventArgs : EventArgs
1001 /// Added child view at moment.
1003 /// <since_tizen> 5 </since_tizen>
1004 public View Added { get; set; }
1008 /// Event argument passed through the ChildRemoved event.
1010 /// <since_tizen> 5 </since_tizen>
1011 public class ChildRemovedEventArgs : EventArgs
1014 /// Removed child view at moment.
1016 /// <since_tizen> 5 </since_tizen>
1017 public View Removed { get; set; }
1021 /// Event arguments that passed via the KeyEvent signal.
1023 /// <since_tizen> 3 </since_tizen>
1024 public class KeyEventArgs : EventArgs
1029 /// Key - is the key sent to the view.
1031 /// <since_tizen> 3 </since_tizen>
1046 /// Event arguments that passed via the touch signal.
1048 /// <since_tizen> 3 </since_tizen>
1049 public class TouchEventArgs : EventArgs
1051 private Touch _touch;
1054 /// Touch - contains the information of touch points.
1056 /// <since_tizen> 3 </since_tizen>
1071 /// Event arguments that passed via the hover signal.
1073 /// <since_tizen> 3 </since_tizen>
1074 public class HoverEventArgs : EventArgs
1076 private Hover _hover;
1079 /// Hover - contains touch points that represent the points that are currently being hovered or the points where a hover has stopped.
1081 /// <since_tizen> 3 </since_tizen>
1096 /// Event arguments that passed via the wheel signal.
1098 /// <since_tizen> 3 </since_tizen>
1099 public class WheelEventArgs : EventArgs
1101 private Wheel _wheel;
1104 /// WheelEvent - store a wheel rolling type: MOUSE_WHEEL or CUSTOM_WHEEL.
1106 /// <since_tizen> 3 </since_tizen>
1121 /// Event arguments of visibility changed.
1123 /// <since_tizen> 3 </since_tizen>
1124 public class VisibilityChangedEventArgs : EventArgs
1127 private bool _visibility;
1128 private VisibilityChangeType _type;
1131 /// The view, or child of view, whose visibility has changed.
1133 /// <since_tizen> 3 </since_tizen>
1147 /// Whether the view is now visible or not.
1149 /// <since_tizen> 3 </since_tizen>
1150 public bool Visibility
1158 _visibility = value;
1163 /// Whether the view's visible property has changed or a parent's.
1165 /// <since_tizen> 3 </since_tizen>
1166 public VisibilityChangeType Type
1180 /// Event arguments of layout direction changed.
1182 /// <since_tizen> 4 </since_tizen>
1183 public class LayoutDirectionChangedEventArgs : EventArgs
1186 private ViewLayoutDirectionType _type;
1189 /// The view, or child of view, whose layout direction has changed.
1191 /// <since_tizen> 4 </since_tizen>
1205 /// Whether the view's layout direction property has changed or a parent's.
1207 /// <since_tizen> 4 </since_tizen>
1208 public ViewLayoutDirectionType Type
1221 internal class BackgroundResourceLoadedEventArgs : EventArgs
1223 private ResourceLoadingStatusType status = ResourceLoadingStatusType.Invalid;
1224 public ResourceLoadingStatusType Status
1238 /// The class represents the information of the situation where the View's control state changes.
1240 [EditorBrowsable(EditorBrowsableState.Never)]
1241 public class ControlStateChangedEventArgs : EventArgs
1244 /// Create an instance with mandatory fields.
1246 /// <param name="previousState">The previous control state.</param>
1247 /// <param name="currentState">The current control state.</param>
1248 [EditorBrowsable(EditorBrowsableState.Never)]
1249 public ControlStateChangedEventArgs(ControlState previousState, ControlState currentState)
1251 PreviousState = previousState;
1252 CurrentState = currentState;
1256 /// The previous control state.
1258 [EditorBrowsable(EditorBrowsableState.Never)]
1259 public ControlState PreviousState { get; }
1262 /// The current control state.
1264 [EditorBrowsable(EditorBrowsableState.Never)]
1265 public ControlState CurrentState { get; }
1268 private EventHandlerWithReturnType<object, WheelEventArgs, bool> WindowWheelEventHandler;
1269 private void OnWindowWheelEvent(object sender, Window.WheelEventArgs e)
1273 if (e.Wheel.Type == Wheel.WheelType.CustomWheel)
1275 var arg = new WheelEventArgs()
1279 WindowWheelEventHandler?.Invoke(this, arg);