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);
218 _onRelayoutEventCallback = null;
225 /// An event for the touched signal which can be used to subscribe or unsubscribe the event handler provided by the user.<br />
226 /// The touched signal is emitted when the touch input is received.<br />
227 /// This can receive touch events before child. <br />
228 /// If it returns false, the child can receive the touch event. If it returns true, the touch event is intercepted. So child cannot receive touch event.<br />
230 [EditorBrowsable(EditorBrowsableState.Never)]
231 public event EventHandlerWithReturnType<object, TouchEventArgs, bool> InterceptTouchEvent
235 if (_interceptTouchDataEventHandler == null)
237 _interceptTouchDataCallback = OnInterceptTouch;
238 this.InterceptTouchSignal().Connect(_interceptTouchDataCallback);
241 _interceptTouchDataEventHandler += value;
246 _interceptTouchDataEventHandler -= value;
248 if (_interceptTouchDataEventHandler == null && InterceptTouchSignal().Empty() == false)
250 this.InterceptTouchSignal().Disconnect(_interceptTouchDataCallback);
256 /// If child view doesn't want the parent's view to intercept the touch, you can set it to true.
258 /// parent.Add(child);
259 /// parent.InterceptTouchEvent += OnInterceptTouchEvent;
260 /// View view = child.GetParent() as View;
261 /// view.DisallowInterceptTouchEvent = true;
262 /// This prevents the parent from interceping touch.
264 [EditorBrowsable(EditorBrowsableState.Never)]
265 public bool DisallowInterceptTouchEvent {get; set;}
269 /// An event for the touched signal which can be used to subscribe or unsubscribe the event handler provided by the user.<br />
270 /// The touched signal is emitted when the touch input is received.<br />
272 /// <since_tizen> 3 </since_tizen>
273 public event EventHandlerWithReturnType<object, TouchEventArgs, bool> TouchEvent
277 if (_touchDataEventHandler == null)
279 _touchDataCallback = OnTouch;
280 this.TouchSignal().Connect(_touchDataCallback);
283 _touchDataEventHandler += value;
288 _touchDataEventHandler -= value;
290 if (_touchDataEventHandler == null && TouchSignal().Empty() == false)
292 this.TouchSignal().Disconnect(_touchDataCallback);
298 /// An event for the hovered signal which can be used to subscribe or unsubscribe the event handler provided by the user.<br />
299 /// The hovered signal is emitted when the hover input is received.<br />
301 /// <since_tizen> 3 </since_tizen>
302 public event EventHandlerWithReturnType<object, HoverEventArgs, bool> HoverEvent
306 if (_hoverEventHandler == null)
308 _hoverEventCallback = OnHoverEvent;
309 this.HoveredSignal().Connect(_hoverEventCallback);
312 _hoverEventHandler += value;
317 _hoverEventHandler -= value;
319 if (_hoverEventHandler == null && HoveredSignal().Empty() == false)
321 this.HoveredSignal().Disconnect(_hoverEventCallback);
328 /// An event for the WheelMoved signal which can be used to subscribe or unsubscribe the event handler provided by the user.<br />
329 /// The WheelMoved signal is emitted when the wheel event is received.<br />
331 /// <since_tizen> 3 </since_tizen>
332 public event EventHandlerWithReturnType<object, WheelEventArgs, bool> WheelEvent
336 if (_wheelEventHandler == null)
338 _wheelEventCallback = OnWheelEvent;
339 this.WheelEventSignal().Connect(_wheelEventCallback);
341 _wheelEventHandler += value;
343 if (WindowWheelEventHandler == null)
345 NUIApplication.GetDefaultWindow().WheelEvent += OnWindowWheelEvent;
347 WindowWheelEventHandler += value;
352 _wheelEventHandler -= value;
353 if (_wheelEventHandler == null && WheelEventSignal().Empty() == false)
355 this.WheelEventSignal().Disconnect(_wheelEventCallback);
358 WindowWheelEventHandler -= value;
359 if (WindowWheelEventHandler == null)
361 NUIApplication.GetDefaultWindow().WheelEvent -= OnWindowWheelEvent;
367 /// An event for the OnWindow signal which can be used to subscribe or unsubscribe the event handler.<br />
368 /// The OnWindow signal is emitted after the view has been connected to the window.<br />
370 /// <since_tizen> 3 </since_tizen>
371 public event EventHandler AddedToWindow
375 if (_onWindowEventHandler == null)
377 _onWindowEventCallback = OnWindow;
378 this.OnWindowSignal().Connect(_onWindowEventCallback);
381 _onWindowEventHandler += value;
386 _onWindowEventHandler -= value;
388 if (_onWindowEventHandler == null && OnWindowSignal().Empty() == false)
390 this.OnWindowSignal().Disconnect(_onWindowEventCallback);
391 _onWindowEventCallback = null;
397 /// An event for the OffWindow signal, which can be used to subscribe or unsubscribe the event handler.<br />
398 /// OffWindow signal is emitted after the view has been disconnected from the window.<br />
400 /// <since_tizen> 3 </since_tizen>
401 public event EventHandler RemovedFromWindow
405 if (_offWindowEventHandler == null)
407 _offWindowEventCallback = OffWindow;
408 this.OffWindowSignal().Connect(_offWindowEventCallback);
411 _offWindowEventHandler += value;
416 _offWindowEventHandler -= value;
418 if (_offWindowEventHandler == null && OffWindowSignal().Empty() == false)
420 this.OffWindowSignal().Disconnect(_offWindowEventCallback);
421 _offWindowEventCallback = null;
427 /// An event for visibility change which can be used to subscribe or unsubscribe the event handler.<br />
428 /// This signal is emitted when the visible property of this or a parent view is changed.<br />
430 /// <since_tizen> 3 </since_tizen>
431 public event EventHandler<VisibilityChangedEventArgs> VisibilityChanged
435 if (_visibilityChangedEventHandler == null)
437 _visibilityChangedEventCallback = OnVisibilityChanged;
438 VisibilityChangedSignal(this).Connect(_visibilityChangedEventCallback);
441 _visibilityChangedEventHandler += value;
446 _visibilityChangedEventHandler -= value;
448 if (_visibilityChangedEventHandler == null && VisibilityChangedSignal(this).Empty() == false)
450 VisibilityChangedSignal(this).Disconnect(_visibilityChangedEventCallback);
456 /// Event for layout direction change which can be used to subscribe/unsubscribe the event handler.<br />
457 /// This signal is emitted when the layout direction property of this or a parent view is changed.<br />
459 /// <since_tizen> 4 </since_tizen>
460 public event EventHandler<LayoutDirectionChangedEventArgs> LayoutDirectionChanged
464 if (_layoutDirectionChangedEventHandler == null)
466 _layoutDirectionChangedEventCallback = OnLayoutDirectionChanged;
467 LayoutDirectionChangedSignal(this).Connect(_layoutDirectionChangedEventCallback);
470 _layoutDirectionChangedEventHandler += value;
475 _layoutDirectionChangedEventHandler -= value;
477 if (_layoutDirectionChangedEventHandler == null && LayoutDirectionChangedSignal(this).Empty() == false)
479 LayoutDirectionChangedSignal(this).Disconnect(_layoutDirectionChangedEventCallback);
485 /// An event for the ResourcesLoadedSignal signal which can be used to subscribe or unsubscribe the event handler provided by the user.<br />
486 /// This signal is emitted after all resources required by a view are loaded and ready.<br />
488 /// <since_tizen> 3 </since_tizen>
489 public event EventHandler ResourcesLoaded
493 if (_resourcesLoadedEventHandler == null)
495 _ResourcesLoadedCallback = OnResourcesLoaded;
496 this.ResourcesLoadedSignal().Connect(_ResourcesLoadedCallback);
499 _resourcesLoadedEventHandler += value;
504 _resourcesLoadedEventHandler -= value;
506 if (_resourcesLoadedEventHandler == null && ResourcesLoadedSignal().Empty() == false)
508 this.ResourcesLoadedSignal().Disconnect(_ResourcesLoadedCallback);
509 _ResourcesLoadedCallback = null;
514 private EventHandler _backKeyPressed;
517 /// An event for getting notice when physical back key is pressed.<br />
518 /// This event is emitted BackKey is up.<br />
520 [EditorBrowsable(EditorBrowsableState.Never)]
521 public event EventHandler BackKeyPressed
525 _backKeyPressed += value;
526 BackKeyManager.Instance.Subscriber.Add(this);
531 BackKeyManager.Instance.Subscriber.Remove(this);
532 _backKeyPressed -= value;
537 /// Function for emitting BackKeyPressed event outside of View instance
539 [EditorBrowsable(EditorBrowsableState.Never)]
540 internal void EmitBackKeyPressed()
542 _backKeyPressed.Invoke(this,null);
546 internal event EventHandler<BackgroundResourceLoadedEventArgs> BackgroundResourceLoaded
550 if (_backgroundResourceLoadedEventHandler == null)
552 _backgroundResourceLoadedCallback = OnBackgroundResourceLoaded;
553 this.ResourcesLoadedSignal().Connect(_backgroundResourceLoadedCallback);
556 _backgroundResourceLoadedEventHandler += value;
560 _backgroundResourceLoadedEventHandler -= value;
562 if (_backgroundResourceLoadedEventHandler == null && ResourcesLoadedSignal().Empty() == false)
564 this.ResourcesLoadedSignal().Disconnect(_backgroundResourceLoadedCallback);
565 _backgroundResourceLoadedCallback = null;
570 internal TouchDataSignal InterceptTouchSignal()
572 TouchDataSignal ret = new TouchDataSignal(Interop.ActorSignal.Actor_InterceptTouchSignal(swigCPtr), false);
573 if (NDalicPINVOKE.SWIGPendingException.Pending)
574 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
578 internal TouchDataSignal TouchSignal()
580 TouchDataSignal ret = new TouchDataSignal(Interop.ActorSignal.Actor_TouchSignal(swigCPtr), false);
581 if (NDalicPINVOKE.SWIGPendingException.Pending)
582 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
586 internal HoverSignal HoveredSignal()
588 HoverSignal ret = new HoverSignal(Interop.ActorSignal.Actor_HoveredSignal(swigCPtr), false);
589 if (NDalicPINVOKE.SWIGPendingException.Pending)
590 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
594 internal WheelSignal WheelEventSignal()
596 WheelSignal ret = new WheelSignal(Interop.ActorSignal.Actor_WheelEventSignal(swigCPtr), false);
597 if (NDalicPINVOKE.SWIGPendingException.Pending)
598 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
602 internal ViewSignal OnWindowSignal()
604 ViewSignal ret = new ViewSignal(Interop.ActorSignal.Actor_OnSceneSignal(swigCPtr), false);
605 if (NDalicPINVOKE.SWIGPendingException.Pending)
606 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
610 internal ViewSignal OffWindowSignal()
612 ViewSignal ret = new ViewSignal(Interop.ActorSignal.Actor_OffSceneSignal(swigCPtr), false);
613 if (NDalicPINVOKE.SWIGPendingException.Pending)
614 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
618 internal ViewSignal OnRelayoutSignal()
620 ViewSignal ret = new ViewSignal(Interop.ActorSignal.Actor_OnRelayoutSignal(swigCPtr), false);
621 if (NDalicPINVOKE.SWIGPendingException.Pending)
622 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
626 internal ViewVisibilityChangedSignal VisibilityChangedSignal(View view)
628 ViewVisibilityChangedSignal ret = new ViewVisibilityChangedSignal(Interop.NDalic.VisibilityChangedSignal(View.getCPtr(view)), false);
629 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
633 internal ViewLayoutDirectionChangedSignal LayoutDirectionChangedSignal(View view)
635 ViewLayoutDirectionChangedSignal ret = new ViewLayoutDirectionChangedSignal(Interop.Layout.LayoutDirectionChangedSignal(View.getCPtr(view)), false);
636 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
640 internal ViewSignal ResourcesLoadedSignal()
642 ViewSignal ret = new ViewSignal(Interop.View.ResourceReadySignal(swigCPtr), false);
643 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
647 internal ControlKeySignal KeyEventSignal()
649 ControlKeySignal ret = new ControlKeySignal(Interop.ViewSignal.View_KeyEventSignal(swigCPtr), false);
650 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
654 internal KeyInputFocusSignal KeyInputFocusGainedSignal()
656 KeyInputFocusSignal ret = new KeyInputFocusSignal(Interop.ViewSignal.View_KeyInputFocusGainedSignal(swigCPtr), false);
657 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
661 internal KeyInputFocusSignal KeyInputFocusLostSignal()
663 KeyInputFocusSignal ret = new KeyInputFocusSignal(Interop.ViewSignal.View_KeyInputFocusLostSignal(swigCPtr), false);
664 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
668 private void OnSize2DChanged(int? width, int? height)
672 Tizen.NUI.Object.SetProperty(this.swigCPtr, View.Property.SIZE_WIDTH, new Tizen.NUI.PropertyValue((float)width));
676 Tizen.NUI.Object.SetProperty(this.swigCPtr, View.Property.SIZE_HEIGHT, new Tizen.NUI.PropertyValue((float)height));
680 private void OnMinimumSizeChanged(int? width, int? height)
682 if (width != null && height != null)
684 MinimumSize = new Size2D((int)width, (int)height);
686 else if (width != null && height == null)
688 MinimumSize = new Size2D((int)width, (int)this.GetMinimumSize().Height);
690 else if (width == null && height != null)
692 MinimumSize = new Size2D((int)this.GetMinimumSize().Width, (int)height);
696 //both are null, do nothing.
700 private void OnMaximumSizeChanged(int? width, int? height)
702 if (width != null && height != null)
704 MaximumSize = new Size2D((int)width, (int)height);
706 else if (width != null && height == null)
708 MaximumSize = new Size2D((int)width, (int)this.GetMaximumSize().Height);
710 else if (width == null && height != null)
712 MaximumSize = new Size2D((int)this.GetMaximumSize().Width, (int)height);
716 //both are null, do nothing.
720 private void OnPosition2DChanged(int x, int y)
722 Position2D = new Position2D(x, y);
725 private void OnSizeChanged(float? width, float? height, float? depth)
729 Tizen.NUI.Object.SetProperty(this.swigCPtr, View.Property.SIZE_WIDTH, new Tizen.NUI.PropertyValue((float)width));
733 Tizen.NUI.Object.SetProperty(this.swigCPtr, View.Property.SIZE_HEIGHT, new Tizen.NUI.PropertyValue((float)height));
737 Tizen.NUI.Object.SetProperty(this.swigCPtr, View.Property.SIZE_DEPTH, new Tizen.NUI.PropertyValue((float)depth));
741 private void OnPositionChanged(float x, float y, float z)
743 Position = new Position(x, y, z);
746 private void OnParentOriginChanged(float x, float y, float z)
748 ParentOrigin = new Position(x, y, z);
751 private void OnPivotPointChanged(float x, float y, float z)
753 PivotPoint = new Position(x, y, z);
756 private void OnImageShadowChanged(ShadowBase instance)
758 ImageShadow = (ImageShadow)instance;
761 private void OnBoxShadowChanged(ShadowBase instance)
763 BoxShadow = (Shadow)instance;
766 private void OnBackgroundImageBorderChanged(int left, int right, int bottom, int top)
768 BackgroundImageBorder = new Rectangle(left, right, bottom, top);
771 private void OnKeyInputFocusGained(IntPtr view)
773 if (_keyInputFocusGainedEventHandler != null)
775 _keyInputFocusGainedEventHandler(this, null);
779 private void OnKeyInputFocusLost(IntPtr view)
781 if (_keyInputFocusLostEventHandler != null)
783 _keyInputFocusLostEventHandler(this, null);
787 private bool OnKeyEvent(IntPtr view, IntPtr keyEvent)
789 if (keyEvent == global::System.IntPtr.Zero)
791 NUILog.Error("keyEvent should not be null!");
795 KeyEventArgs e = new KeyEventArgs();
799 e.Key = Tizen.NUI.Key.GetKeyFromPtr(keyEvent);
801 if (_keyEventHandler != null)
803 Delegate[] delegateList = _keyEventHandler.GetInvocationList();
805 // Oring the result of each callback.
806 foreach (EventHandlerWithReturnType<object, KeyEventArgs, bool> del in delegateList)
808 result |= del(this, e);
815 // Callback for View OnRelayout signal
816 private void OnRelayout(IntPtr data)
818 if (_onRelayoutEventHandler != null)
820 _onRelayoutEventHandler(this, null);
824 // Callback for View TouchSignal
825 private bool OnInterceptTouch(IntPtr view, IntPtr touchData)
827 if (touchData == global::System.IntPtr.Zero)
829 NUILog.Error("touchData should not be null!");
833 // DisallowInterceptTouchEvent prevents the parent from intercepting touch.
834 if (DisallowInterceptTouchEvent)
839 TouchEventArgs e = new TouchEventArgs();
841 e.Touch = Tizen.NUI.Touch.GetTouchFromPtr(touchData);
843 bool consumed = false;
845 if (_interceptTouchDataEventHandler != null)
847 consumed = _interceptTouchDataEventHandler(this, e);
853 // Callback for View TouchSignal
854 private bool OnTouch(IntPtr view, IntPtr touchData)
856 if (touchData == global::System.IntPtr.Zero)
858 NUILog.Error("touchData should not be null!");
862 TouchEventArgs e = new TouchEventArgs();
864 e.Touch = Tizen.NUI.Touch.GetTouchFromPtr(touchData);
866 bool consumed = false;
868 if (_touchDataEventHandler != null)
870 consumed = _touchDataEventHandler(this, e);
873 if (enableControlState && !consumed)
875 consumed = HandleControlStateOnTouch(e.Touch);
881 // Callback for View Hover signal
882 private bool OnHoverEvent(IntPtr view, IntPtr hoverEvent)
884 if (hoverEvent == global::System.IntPtr.Zero)
886 NUILog.Error("hoverEvent should not be null!");
890 HoverEventArgs e = new HoverEventArgs();
892 e.Hover = Tizen.NUI.Hover.GetHoverFromPtr(hoverEvent);
894 if (_hoverEventHandler != null)
896 return _hoverEventHandler(this, e);
901 // Callback for View Wheel signal
902 private bool OnWheelEvent(IntPtr view, IntPtr wheelEvent)
904 if (wheelEvent == global::System.IntPtr.Zero)
906 NUILog.Error("wheelEvent should not be null!");
910 WheelEventArgs e = new WheelEventArgs();
912 e.Wheel = Tizen.NUI.Wheel.GetWheelFromPtr(wheelEvent);
914 if (_wheelEventHandler != null)
916 return _wheelEventHandler(this, e);
921 // Callback for View OnWindow signal
922 private void OnWindow(IntPtr data)
924 if (_onWindowEventHandler != null)
926 _onWindowEventHandler(this, null);
930 // Callback for View OffWindow signal
931 private void OffWindow(IntPtr data)
933 if (_offWindowEventHandler != null)
935 _offWindowEventHandler(this, null);
939 // Callback for View visibility change signal
940 private void OnVisibilityChanged(IntPtr data, bool visibility, VisibilityChangeType type)
942 VisibilityChangedEventArgs e = new VisibilityChangedEventArgs();
945 e.View = Registry.GetManagedBaseHandleFromNativePtr(data) as View;
947 e.Visibility = visibility;
950 if (_visibilityChangedEventHandler != null)
952 _visibilityChangedEventHandler(this, e);
956 // Callback for View layout direction change signal
957 private void OnLayoutDirectionChanged(IntPtr data, ViewLayoutDirectionType type)
959 LayoutDirectionChangedEventArgs e = new LayoutDirectionChangedEventArgs();
962 e.View = Registry.GetManagedBaseHandleFromNativePtr(data) as View;
966 if (_layoutDirectionChangedEventHandler != null)
968 _layoutDirectionChangedEventHandler(this, e);
972 private void OnResourcesLoaded(IntPtr view)
974 if (_resourcesLoadedEventHandler != null)
976 _resourcesLoadedEventHandler(this, null);
980 private void OnBackgroundResourceLoaded(IntPtr view)
982 BackgroundResourceLoadedEventArgs e = new BackgroundResourceLoadedEventArgs();
983 e.Status = (ResourceLoadingStatusType)Interop.View.View_GetVisualResourceStatus(this.swigCPtr, Property.BACKGROUND);
985 if (_backgroundResourceLoadedEventHandler != null)
987 _backgroundResourceLoadedEventHandler(this, e);
992 /// Event argument passed through the ChildAdded event.
994 /// <since_tizen> 5 </since_tizen>
995 public class ChildAddedEventArgs : EventArgs
998 /// Added child view at moment.
1000 /// <since_tizen> 5 </since_tizen>
1001 public View Added { get; set; }
1005 /// Event argument passed through the ChildRemoved event.
1007 /// <since_tizen> 5 </since_tizen>
1008 public class ChildRemovedEventArgs : EventArgs
1011 /// Removed child view at moment.
1013 /// <since_tizen> 5 </since_tizen>
1014 public View Removed { get; set; }
1018 /// Event arguments that passed via the KeyEvent signal.
1020 /// <since_tizen> 3 </since_tizen>
1021 public class KeyEventArgs : EventArgs
1026 /// Key - is the key sent to the view.
1028 /// <since_tizen> 3 </since_tizen>
1043 /// Event arguments that passed via the touch signal.
1045 /// <since_tizen> 3 </since_tizen>
1046 public class TouchEventArgs : EventArgs
1048 private Touch _touch;
1051 /// Touch - contains the information of touch points.
1053 /// <since_tizen> 3 </since_tizen>
1068 /// Event arguments that passed via the hover signal.
1070 /// <since_tizen> 3 </since_tizen>
1071 public class HoverEventArgs : EventArgs
1073 private Hover _hover;
1076 /// Hover - contains touch points that represent the points that are currently being hovered or the points where a hover has stopped.
1078 /// <since_tizen> 3 </since_tizen>
1093 /// Event arguments that passed via the wheel signal.
1095 /// <since_tizen> 3 </since_tizen>
1096 public class WheelEventArgs : EventArgs
1098 private Wheel _wheel;
1101 /// WheelEvent - store a wheel rolling type: MOUSE_WHEEL or CUSTOM_WHEEL.
1103 /// <since_tizen> 3 </since_tizen>
1118 /// Event arguments of visibility changed.
1120 /// <since_tizen> 3 </since_tizen>
1121 public class VisibilityChangedEventArgs : EventArgs
1124 private bool _visibility;
1125 private VisibilityChangeType _type;
1128 /// The view, or child of view, whose visibility has changed.
1130 /// <since_tizen> 3 </since_tizen>
1144 /// Whether the view is now visible or not.
1146 /// <since_tizen> 3 </since_tizen>
1147 public bool Visibility
1155 _visibility = value;
1160 /// Whether the view's visible property has changed or a parent's.
1162 /// <since_tizen> 3 </since_tizen>
1163 public VisibilityChangeType Type
1177 /// Event arguments of layout direction changed.
1179 /// <since_tizen> 4 </since_tizen>
1180 public class LayoutDirectionChangedEventArgs : EventArgs
1183 private ViewLayoutDirectionType _type;
1186 /// The view, or child of view, whose layout direction has changed.
1188 /// <since_tizen> 4 </since_tizen>
1202 /// Whether the view's layout direction property has changed or a parent's.
1204 /// <since_tizen> 4 </since_tizen>
1205 public ViewLayoutDirectionType Type
1218 internal class BackgroundResourceLoadedEventArgs : EventArgs
1220 private ResourceLoadingStatusType status = ResourceLoadingStatusType.Invalid;
1221 public ResourceLoadingStatusType Status
1235 /// The class represents the information of the situation where the View's control state changes.
1237 [EditorBrowsable(EditorBrowsableState.Never)]
1238 public class ControlStateChangedEventArgs : EventArgs
1241 /// Create an instance with mandatory fields.
1243 /// <param name="previousState">The previous control state.</param>
1244 /// <param name="currentState">The current control state.</param>
1245 [EditorBrowsable(EditorBrowsableState.Never)]
1246 public ControlStateChangedEventArgs(ControlState previousState, ControlState currentState)
1248 PreviousState = previousState;
1249 CurrentState = currentState;
1253 /// The previous control state.
1255 [EditorBrowsable(EditorBrowsableState.Never)]
1256 public ControlState PreviousState { get; }
1259 /// The current control state.
1261 [EditorBrowsable(EditorBrowsableState.Never)]
1262 public ControlState CurrentState { get; }
1265 private EventHandlerWithReturnType<object, WheelEventArgs, bool> WindowWheelEventHandler;
1266 private void OnWindowWheelEvent(object sender, Window.WheelEventArgs e)
1270 if(e.Wheel.Type == Wheel.WheelType.CustomWheel)
1272 var arg = new WheelEventArgs()
1276 WindowWheelEventHandler?.Invoke(this, arg);