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 void SendViewAddedEventToWindow(IntPtr data)
66 NUIApplication.GetDefaultWindow()?.SendViewAdded(this);
69 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
70 private delegate void OffWindowEventCallbackType(IntPtr control);
71 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
72 private delegate bool WheelEventCallbackType(IntPtr view, IntPtr wheelEvent);
73 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
74 private delegate bool KeyCallbackType(IntPtr control, IntPtr keyEvent);
75 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
76 private delegate bool TouchDataCallbackType(IntPtr view, IntPtr touchData);
77 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
78 private delegate bool HoverEventCallbackType(IntPtr view, IntPtr hoverEvent);
79 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
80 private delegate void VisibilityChangedEventCallbackType(IntPtr data, bool visibility, VisibilityChangeType type);
81 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
82 private delegate void ResourcesLoadedCallbackType(IntPtr control);
83 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
84 private delegate void _backgroundResourceLoadedCallbackType(IntPtr view);
85 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
86 private delegate void KeyInputFocusGainedCallbackType(IntPtr control);
87 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
88 private delegate void KeyInputFocusLostCallbackType(IntPtr control);
89 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
90 private delegate void OnRelayoutEventCallbackType(IntPtr control);
91 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
92 private delegate void OnWindowEventCallbackType(IntPtr control);
93 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
94 private delegate void LayoutDirectionChangedEventCallbackType(IntPtr data, ViewLayoutDirectionType type);
97 /// Event when a child is removed.
99 /// <since_tizen> 5 </since_tizen>
100 public new event EventHandler<ChildRemovedEventArgs> ChildRemoved;
102 /// Event when a child is added.
104 /// <since_tizen> 5 </since_tizen>
105 public new event EventHandler<ChildAddedEventArgs> ChildAdded;
108 /// An event for the KeyInputFocusGained signal which can be used to subscribe or unsubscribe the event handler provided by the user.<br />
109 /// The KeyInputFocusGained signal is emitted when the control gets the key input focus.<br />
111 /// <since_tizen> 3 </since_tizen>
112 public event EventHandler FocusGained
116 if (_keyInputFocusGainedEventHandler == null)
118 _keyInputFocusGainedCallback = OnKeyInputFocusGained;
119 this.KeyInputFocusGainedSignal().Connect(_keyInputFocusGainedCallback);
122 _keyInputFocusGainedEventHandler += value;
127 _keyInputFocusGainedEventHandler -= value;
129 if (_keyInputFocusGainedEventHandler == null && KeyInputFocusGainedSignal().Empty() == false)
131 this.KeyInputFocusGainedSignal().Disconnect(_keyInputFocusGainedCallback);
137 /// An event for the KeyInputFocusLost signal which can be used to subscribe or unsubscribe the event handler provided by the user.<br />
138 /// The KeyInputFocusLost signal is emitted when the control loses the key input focus.<br />
140 /// <since_tizen> 3 </since_tizen>
141 public event EventHandler FocusLost
145 if (_keyInputFocusLostEventHandler == null)
147 _keyInputFocusLostCallback = OnKeyInputFocusLost;
148 this.KeyInputFocusLostSignal().Connect(_keyInputFocusLostCallback);
151 _keyInputFocusLostEventHandler += value;
156 _keyInputFocusLostEventHandler -= value;
158 if (_keyInputFocusLostEventHandler == null && KeyInputFocusLostSignal().Empty() == false)
160 this.KeyInputFocusLostSignal().Disconnect(_keyInputFocusLostCallback);
166 /// An event for the KeyPressed signal which can be used to subscribe or unsubscribe the event handler provided by the user.<br />
167 /// The KeyPressed signal is emitted when the key event is received.<br />
169 /// <since_tizen> 3 </since_tizen>
170 public event EventHandlerWithReturnType<object, KeyEventArgs, bool> KeyEvent
174 if (_keyEventHandler == null)
176 _keyCallback = OnKeyEvent;
177 this.KeyEventSignal().Connect(_keyCallback);
180 _keyEventHandler += value;
185 _keyEventHandler -= value;
187 if (_keyEventHandler == null && KeyEventSignal().Empty() == false)
189 this.KeyEventSignal().Disconnect(_keyCallback);
195 /// An event for the OnRelayout signal which can be used to subscribe or unsubscribe the event handler.<br />
196 /// The OnRelayout signal is emitted after the size has been set on the view during relayout.<br />
198 /// <since_tizen> 3 </since_tizen>
199 public event EventHandler Relayout
203 if (_onRelayoutEventHandler == null)
205 _onRelayoutEventCallback = OnRelayout;
206 this.OnRelayoutSignal().Connect(_onRelayoutEventCallback);
209 _onRelayoutEventHandler += value;
214 _onRelayoutEventHandler -= value;
216 if (_onRelayoutEventHandler == null && OnRelayoutSignal().Empty() == false)
218 this.OnRelayoutSignal().Disconnect(_onRelayoutEventCallback);
219 _onRelayoutEventCallback = null;
226 /// An event for the touched signal which can be used to subscribe or unsubscribe the event handler provided by the user.<br />
227 /// The touched signal is emitted when the touch input is received.<br />
228 /// This can receive touch events before child. <br />
229 /// If it returns false, the child can receive the touch event. If it returns true, the touch event is intercepted. So child cannot receive touch event.<br />
231 [EditorBrowsable(EditorBrowsableState.Never)]
232 public event EventHandlerWithReturnType<object, TouchEventArgs, bool> InterceptTouchEvent
236 if (_interceptTouchDataEventHandler == null)
238 _interceptTouchDataCallback = OnInterceptTouch;
239 this.InterceptTouchSignal().Connect(_interceptTouchDataCallback);
242 _interceptTouchDataEventHandler += value;
247 _interceptTouchDataEventHandler -= value;
249 if (_interceptTouchDataEventHandler == null && InterceptTouchSignal().Empty() == false)
251 this.InterceptTouchSignal().Disconnect(_interceptTouchDataCallback);
257 /// If child view doesn't want the parent's view to intercept the touch, you can set it to true.
259 /// parent.Add(child);
260 /// parent.InterceptTouchEvent += OnInterceptTouchEvent;
261 /// View view = child.GetParent() as View;
262 /// view.DisallowInterceptTouchEvent = true;
263 /// This prevents the parent from interceping touch.
265 [EditorBrowsable(EditorBrowsableState.Never)]
266 public bool DisallowInterceptTouchEvent { get; set; }
270 /// An event for the touched signal which can be used to subscribe or unsubscribe the event handler provided by the user.<br />
271 /// The touched signal is emitted when the touch input is received.<br />
273 /// <since_tizen> 3 </since_tizen>
274 public event EventHandlerWithReturnType<object, TouchEventArgs, bool> TouchEvent
278 if (_touchDataEventHandler == null)
280 _touchDataCallback = OnTouch;
281 this.TouchSignal().Connect(_touchDataCallback);
284 _touchDataEventHandler += value;
289 _touchDataEventHandler -= value;
291 if (_touchDataEventHandler == null && TouchSignal().Empty() == false)
293 this.TouchSignal().Disconnect(_touchDataCallback);
299 /// An event for the hovered signal which can be used to subscribe or unsubscribe the event handler provided by the user.<br />
300 /// The hovered signal is emitted when the hover input is received.<br />
302 /// <since_tizen> 3 </since_tizen>
303 public event EventHandlerWithReturnType<object, HoverEventArgs, bool> HoverEvent
307 if (_hoverEventHandler == null)
309 _hoverEventCallback = OnHoverEvent;
310 this.HoveredSignal().Connect(_hoverEventCallback);
313 _hoverEventHandler += value;
318 _hoverEventHandler -= value;
320 if (_hoverEventHandler == null && HoveredSignal().Empty() == false)
322 this.HoveredSignal().Disconnect(_hoverEventCallback);
329 /// An event for the WheelMoved signal which can be used to subscribe or unsubscribe the event handler provided by the user.<br />
330 /// The WheelMoved signal is emitted when the wheel event is received.<br />
332 /// <since_tizen> 3 </since_tizen>
333 public event EventHandlerWithReturnType<object, WheelEventArgs, bool> WheelEvent
337 if (_wheelEventHandler == null)
339 _wheelEventCallback = OnWheelEvent;
340 this.WheelEventSignal().Connect(_wheelEventCallback);
342 _wheelEventHandler += value;
344 if (WindowWheelEventHandler == null)
346 NUIApplication.GetDefaultWindow().WheelEvent += OnWindowWheelEvent;
348 WindowWheelEventHandler += value;
353 _wheelEventHandler -= value;
354 if (_wheelEventHandler == null && WheelEventSignal().Empty() == false)
356 this.WheelEventSignal().Disconnect(_wheelEventCallback);
359 WindowWheelEventHandler -= value;
360 if (WindowWheelEventHandler == null)
362 NUIApplication.GetDefaultWindow().WheelEvent -= OnWindowWheelEvent;
368 /// An event for the OnWindow signal which can be used to subscribe or unsubscribe the event handler.<br />
369 /// The OnWindow signal is emitted after the view has been connected to the window.<br />
371 /// <since_tizen> 3 </since_tizen>
372 public event EventHandler AddedToWindow
376 if (_onWindowEventHandler == null)
378 _onWindowEventCallback = OnWindow;
379 this.OnWindowSignal().Connect(_onWindowEventCallback);
382 _onWindowEventHandler += value;
387 _onWindowEventHandler -= value;
389 if (_onWindowEventHandler == null && OnWindowSignal().Empty() == false)
391 this.OnWindowSignal().Disconnect(_onWindowEventCallback);
392 _onWindowEventCallback = null;
398 /// An event for the OffWindow signal, which can be used to subscribe or unsubscribe the event handler.<br />
399 /// OffWindow signal is emitted after the view has been disconnected from the window.<br />
401 /// <since_tizen> 3 </since_tizen>
402 public event EventHandler RemovedFromWindow
406 if (_offWindowEventHandler == null)
408 _offWindowEventCallback = OffWindow;
409 this.OffWindowSignal().Connect(_offWindowEventCallback);
412 _offWindowEventHandler += value;
417 _offWindowEventHandler -= value;
419 if (_offWindowEventHandler == null && OffWindowSignal().Empty() == false)
421 this.OffWindowSignal().Disconnect(_offWindowEventCallback);
422 _offWindowEventCallback = null;
428 /// An event for visibility change which can be used to subscribe or unsubscribe the event handler.<br />
429 /// This signal is emitted when the visible property of this or a parent view is changed.<br />
431 /// <since_tizen> 3 </since_tizen>
432 public event EventHandler<VisibilityChangedEventArgs> VisibilityChanged
436 if (_visibilityChangedEventHandler == null)
438 _visibilityChangedEventCallback = OnVisibilityChanged;
439 VisibilityChangedSignal(this).Connect(_visibilityChangedEventCallback);
442 _visibilityChangedEventHandler += value;
447 _visibilityChangedEventHandler -= value;
449 if (_visibilityChangedEventHandler == null && VisibilityChangedSignal(this).Empty() == false)
451 VisibilityChangedSignal(this).Disconnect(_visibilityChangedEventCallback);
457 /// Event for layout direction change which can be used to subscribe/unsubscribe the event handler.<br />
458 /// This signal is emitted when the layout direction property of this or a parent view is changed.<br />
460 /// <since_tizen> 4 </since_tizen>
461 public event EventHandler<LayoutDirectionChangedEventArgs> LayoutDirectionChanged
465 if (_layoutDirectionChangedEventHandler == null)
467 _layoutDirectionChangedEventCallback = OnLayoutDirectionChanged;
468 LayoutDirectionChangedSignal(this).Connect(_layoutDirectionChangedEventCallback);
471 _layoutDirectionChangedEventHandler += value;
476 _layoutDirectionChangedEventHandler -= value;
478 if (_layoutDirectionChangedEventHandler == null && LayoutDirectionChangedSignal(this).Empty() == false)
480 LayoutDirectionChangedSignal(this).Disconnect(_layoutDirectionChangedEventCallback);
486 /// An event for the ResourcesLoadedSignal signal which can be used to subscribe or unsubscribe the event handler provided by the user.<br />
487 /// This signal is emitted after all resources required by a view are loaded and ready.<br />
489 /// <since_tizen> 3 </since_tizen>
490 public event EventHandler ResourcesLoaded
494 if (_resourcesLoadedEventHandler == null)
496 _ResourcesLoadedCallback = OnResourcesLoaded;
497 this.ResourcesLoadedSignal().Connect(_ResourcesLoadedCallback);
500 _resourcesLoadedEventHandler += value;
505 _resourcesLoadedEventHandler -= value;
507 if (_resourcesLoadedEventHandler == null && ResourcesLoadedSignal().Empty() == false)
509 this.ResourcesLoadedSignal().Disconnect(_ResourcesLoadedCallback);
510 _ResourcesLoadedCallback = null;
515 private EventHandler _backKeyPressed;
518 /// An event for getting notice when physical back key is pressed.<br />
519 /// This event is emitted BackKey is up.<br />
521 [EditorBrowsable(EditorBrowsableState.Never)]
522 public event EventHandler BackKeyPressed
526 _backKeyPressed += value;
527 BackKeyManager.Instance.Subscriber.Add(this);
532 BackKeyManager.Instance.Subscriber.Remove(this);
533 _backKeyPressed -= value;
538 /// Function for emitting BackKeyPressed event outside of View instance
540 [EditorBrowsable(EditorBrowsableState.Never)]
541 internal void EmitBackKeyPressed()
543 _backKeyPressed.Invoke(this, null);
547 internal event EventHandler<BackgroundResourceLoadedEventArgs> BackgroundResourceLoaded
551 if (_backgroundResourceLoadedEventHandler == null)
553 _backgroundResourceLoadedCallback = OnBackgroundResourceLoaded;
554 this.ResourcesLoadedSignal().Connect(_backgroundResourceLoadedCallback);
557 _backgroundResourceLoadedEventHandler += value;
561 _backgroundResourceLoadedEventHandler -= value;
563 if (_backgroundResourceLoadedEventHandler == null && ResourcesLoadedSignal().Empty() == false)
565 this.ResourcesLoadedSignal().Disconnect(_backgroundResourceLoadedCallback);
566 _backgroundResourceLoadedCallback = null;
571 internal TouchDataSignal InterceptTouchSignal()
573 TouchDataSignal ret = new TouchDataSignal(Interop.ActorSignal.ActorInterceptTouchSignal(SwigCPtr), false);
574 if (NDalicPINVOKE.SWIGPendingException.Pending)
575 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
579 internal TouchDataSignal TouchSignal()
581 TouchDataSignal ret = new TouchDataSignal(Interop.ActorSignal.ActorTouchSignal(SwigCPtr), false);
582 if (NDalicPINVOKE.SWIGPendingException.Pending)
583 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
587 internal HoverSignal HoveredSignal()
589 HoverSignal ret = new HoverSignal(Interop.ActorSignal.ActorHoveredSignal(SwigCPtr), false);
590 if (NDalicPINVOKE.SWIGPendingException.Pending)
591 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
595 internal WheelSignal WheelEventSignal()
597 WheelSignal ret = new WheelSignal(Interop.ActorSignal.ActorWheelEventSignal(SwigCPtr), false);
598 if (NDalicPINVOKE.SWIGPendingException.Pending)
599 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
603 internal ViewSignal OnWindowSignal()
605 ViewSignal ret = new ViewSignal(Interop.ActorSignal.ActorOnSceneSignal(SwigCPtr), false);
606 if (NDalicPINVOKE.SWIGPendingException.Pending)
607 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
611 internal ViewSignal OffWindowSignal()
613 ViewSignal ret = new ViewSignal(Interop.ActorSignal.ActorOffSceneSignal(SwigCPtr), false);
614 if (NDalicPINVOKE.SWIGPendingException.Pending)
615 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
619 internal ViewSignal OnRelayoutSignal()
621 ViewSignal ret = new ViewSignal(Interop.ActorSignal.ActorOnRelayoutSignal(SwigCPtr), false);
622 if (NDalicPINVOKE.SWIGPendingException.Pending)
623 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
627 internal ViewVisibilityChangedSignal VisibilityChangedSignal(View view)
629 ViewVisibilityChangedSignal ret = new ViewVisibilityChangedSignal(Interop.NDalic.VisibilityChangedSignal(View.getCPtr(view)), false);
630 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
634 internal ViewLayoutDirectionChangedSignal LayoutDirectionChangedSignal(View view)
636 ViewLayoutDirectionChangedSignal ret = new ViewLayoutDirectionChangedSignal(Interop.Layout.LayoutDirectionChangedSignal(View.getCPtr(view)), false);
637 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
641 internal ViewSignal ResourcesLoadedSignal()
643 ViewSignal ret = new ViewSignal(Interop.View.ResourceReadySignal(SwigCPtr), false);
644 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
648 internal ControlKeySignal KeyEventSignal()
650 ControlKeySignal ret = new ControlKeySignal(Interop.ViewSignal.KeyEventSignal(SwigCPtr), false);
651 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
655 internal KeyInputFocusSignal KeyInputFocusGainedSignal()
657 KeyInputFocusSignal ret = new KeyInputFocusSignal(Interop.ViewSignal.KeyInputFocusGainedSignal(SwigCPtr), false);
658 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
662 internal KeyInputFocusSignal KeyInputFocusLostSignal()
664 KeyInputFocusSignal ret = new KeyInputFocusSignal(Interop.ViewSignal.KeyInputFocusLostSignal(SwigCPtr), false);
665 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
669 private void OnSize2DChanged(int? width, int? height)
674 temp = new Tizen.NUI.PropertyValue((float)width);
675 Tizen.NUI.Object.SetProperty(this.SwigCPtr, View.Property.SizeWidth, temp);
680 temp = new Tizen.NUI.PropertyValue((float)height);
681 Tizen.NUI.Object.SetProperty(this.SwigCPtr, View.Property.SizeHeight, temp);
686 private void OnMinimumSizeChanged(int? width, int? height)
688 if (width != null && height != null)
690 MinimumSize = new Size2D((int)width, (int)height);
692 else if (width != null && height == null)
694 MinimumSize = new Size2D((int)width, (int)this.GetMinimumSize().Height);
696 else if (width == null && height != null)
698 MinimumSize = new Size2D((int)this.GetMinimumSize().Width, (int)height);
702 //both are null, do nothing.
706 private void OnMaximumSizeChanged(int? width, int? height)
708 if (width != null && height != null)
710 MaximumSize = new Size2D((int)width, (int)height);
712 else if (width != null && height == null)
714 MaximumSize = new Size2D((int)width, (int)this.GetMaximumSize().Height);
716 else if (width == null && height != null)
718 MaximumSize = new Size2D((int)this.GetMaximumSize().Width, (int)height);
722 //both are null, do nothing.
726 private void OnPosition2DChanged(int x, int y)
728 Position2D = new Position2D(x, y);
731 private void OnSizeChanged(float? width, float? height, float? depth)
736 temp = new Tizen.NUI.PropertyValue((float)width);
737 Tizen.NUI.Object.SetProperty(this.SwigCPtr, View.Property.SizeWidth, temp);
742 temp = new Tizen.NUI.PropertyValue((float)height);
743 Tizen.NUI.Object.SetProperty(this.SwigCPtr, View.Property.SizeHeight, temp);
748 temp = new Tizen.NUI.PropertyValue((float)depth);
749 Tizen.NUI.Object.SetProperty(this.SwigCPtr, View.Property.SizeDepth, temp);
754 private void OnPositionChanged(float x, float y, float z)
756 Position = new Position(x, y, z);
759 private void OnParentOriginChanged(float x, float y, float z)
761 ParentOrigin = new Position(x, y, z);
764 private void OnPivotPointChanged(float x, float y, float z)
766 PivotPoint = new Position(x, y, z);
769 private void OnImageShadowChanged(ShadowBase instance)
771 ImageShadow = (ImageShadow)instance;
774 private void OnBoxShadowChanged(ShadowBase instance)
776 BoxShadow = (Shadow)instance;
779 private void OnBackgroundImageBorderChanged(int left, int right, int bottom, int top)
781 BackgroundImageBorder = new Rectangle(left, right, bottom, top);
784 private void OnKeyInputFocusGained(IntPtr view)
786 if (_keyInputFocusGainedEventHandler != null)
788 _keyInputFocusGainedEventHandler(this, null);
792 private void OnKeyInputFocusLost(IntPtr view)
794 if (_keyInputFocusLostEventHandler != null)
796 _keyInputFocusLostEventHandler(this, null);
800 private bool OnKeyEvent(IntPtr view, IntPtr keyEvent)
802 if (keyEvent == global::System.IntPtr.Zero)
804 NUILog.Error("keyEvent should not be null!");
808 KeyEventArgs e = new KeyEventArgs();
812 e.Key = Tizen.NUI.Key.GetKeyFromPtr(keyEvent);
814 if (_keyEventHandler != null)
816 Delegate[] delegateList = _keyEventHandler.GetInvocationList();
818 // Oring the result of each callback.
819 foreach (EventHandlerWithReturnType<object, KeyEventArgs, bool> del in delegateList)
821 result |= del(this, e);
828 // Callback for View OnRelayout signal
829 private void OnRelayout(IntPtr data)
831 if (_onRelayoutEventHandler != null)
833 _onRelayoutEventHandler(this, null);
837 // Callback for View TouchSignal
838 private bool OnInterceptTouch(IntPtr view, IntPtr touchData)
840 if (touchData == global::System.IntPtr.Zero)
842 NUILog.Error("touchData should not be null!");
846 // DisallowInterceptTouchEvent prevents the parent from intercepting touch.
847 if (DisallowInterceptTouchEvent)
852 TouchEventArgs e = new TouchEventArgs();
854 e.Touch = Tizen.NUI.Touch.GetTouchFromPtr(touchData);
856 bool consumed = false;
858 if (_interceptTouchDataEventHandler != null)
860 consumed = _interceptTouchDataEventHandler(this, e);
866 // Callback for View TouchSignal
867 private bool OnTouch(IntPtr view, IntPtr touchData)
869 if (touchData == global::System.IntPtr.Zero)
871 NUILog.Error("touchData should not be null!");
875 TouchEventArgs e = new TouchEventArgs();
877 e.Touch = Tizen.NUI.Touch.GetTouchFromPtr(touchData);
879 bool consumed = false;
881 if (_touchDataEventHandler != null)
883 consumed = _touchDataEventHandler(this, e);
886 if (enableControlState && !consumed)
888 consumed = HandleControlStateOnTouch(e.Touch);
894 // Callback for View Hover signal
895 private bool OnHoverEvent(IntPtr view, IntPtr hoverEvent)
897 if (hoverEvent == global::System.IntPtr.Zero)
899 NUILog.Error("hoverEvent should not be null!");
903 HoverEventArgs e = new HoverEventArgs();
905 e.Hover = Tizen.NUI.Hover.GetHoverFromPtr(hoverEvent);
907 if (_hoverEventHandler != null)
909 return _hoverEventHandler(this, e);
914 // Callback for View Wheel signal
915 private bool OnWheelEvent(IntPtr view, IntPtr wheelEvent)
917 if (wheelEvent == global::System.IntPtr.Zero)
919 NUILog.Error("wheelEvent should not be null!");
923 WheelEventArgs e = new WheelEventArgs();
925 e.Wheel = Tizen.NUI.Wheel.GetWheelFromPtr(wheelEvent);
927 if (_wheelEventHandler != null)
929 return _wheelEventHandler(this, e);
934 // Callback for View OnWindow signal
935 private void OnWindow(IntPtr data)
937 if (_onWindowEventHandler != null)
939 _onWindowEventHandler(this, null);
943 // Callback for View OffWindow signal
944 private void OffWindow(IntPtr data)
946 if (_offWindowEventHandler != null)
948 _offWindowEventHandler(this, null);
952 // Callback for View visibility change signal
953 private void OnVisibilityChanged(IntPtr data, bool visibility, VisibilityChangeType type)
955 VisibilityChangedEventArgs e = new VisibilityChangedEventArgs();
958 e.View = Registry.GetManagedBaseHandleFromNativePtr(data) as View;
960 e.Visibility = visibility;
963 if (_visibilityChangedEventHandler != null)
965 _visibilityChangedEventHandler(this, e);
969 // Callback for View layout direction change signal
970 private void OnLayoutDirectionChanged(IntPtr data, ViewLayoutDirectionType type)
972 LayoutDirectionChangedEventArgs e = new LayoutDirectionChangedEventArgs();
975 e.View = Registry.GetManagedBaseHandleFromNativePtr(data) as View;
979 if (_layoutDirectionChangedEventHandler != null)
981 _layoutDirectionChangedEventHandler(this, e);
985 private void OnResourcesLoaded(IntPtr view)
987 if (_resourcesLoadedEventHandler != null)
989 _resourcesLoadedEventHandler(this, null);
993 private void OnBackgroundResourceLoaded(IntPtr view)
995 BackgroundResourceLoadedEventArgs e = new BackgroundResourceLoadedEventArgs();
996 e.Status = (ResourceLoadingStatusType)Interop.View.GetVisualResourceStatus(this.SwigCPtr, Property.BACKGROUND);
998 if (_backgroundResourceLoadedEventHandler != null)
1000 _backgroundResourceLoadedEventHandler(this, e);
1005 /// Event argument passed through the ChildAdded event.
1007 /// <since_tizen> 5 </since_tizen>
1008 public class ChildAddedEventArgs : EventArgs
1011 /// Added child view at moment.
1013 /// <since_tizen> 5 </since_tizen>
1014 public View Added { get; set; }
1018 /// Event argument passed through the ChildRemoved event.
1020 /// <since_tizen> 5 </since_tizen>
1021 public class ChildRemovedEventArgs : EventArgs
1024 /// Removed child view at moment.
1026 /// <since_tizen> 5 </since_tizen>
1027 public View Removed { get; set; }
1031 /// Event arguments that passed via the KeyEvent signal.
1033 /// <since_tizen> 3 </since_tizen>
1034 public class KeyEventArgs : EventArgs
1039 /// Key - is the key sent to the view.
1041 /// <since_tizen> 3 </since_tizen>
1056 /// Event arguments that passed via the touch signal.
1058 /// <since_tizen> 3 </since_tizen>
1059 public class TouchEventArgs : EventArgs
1061 private Touch _touch;
1064 /// Touch - contains the information of touch points.
1066 /// <since_tizen> 3 </since_tizen>
1081 /// Event arguments that passed via the hover signal.
1083 /// <since_tizen> 3 </since_tizen>
1084 public class HoverEventArgs : EventArgs
1086 private Hover _hover;
1089 /// Hover - contains touch points that represent the points that are currently being hovered or the points where a hover has stopped.
1091 /// <since_tizen> 3 </since_tizen>
1106 /// Event arguments that passed via the wheel signal.
1108 /// <since_tizen> 3 </since_tizen>
1109 public class WheelEventArgs : EventArgs
1111 private Wheel _wheel;
1114 /// WheelEvent - store a wheel rolling type: MOUSE_WHEEL or CUSTOM_WHEEL.
1116 /// <since_tizen> 3 </since_tizen>
1131 /// Event arguments of visibility changed.
1133 /// <since_tizen> 3 </since_tizen>
1134 public class VisibilityChangedEventArgs : EventArgs
1137 private bool _visibility;
1138 private VisibilityChangeType _type;
1141 /// The view, or child of view, whose visibility has changed.
1143 /// <since_tizen> 3 </since_tizen>
1157 /// Whether the view is now visible or not.
1159 /// <since_tizen> 3 </since_tizen>
1160 public bool Visibility
1168 _visibility = value;
1173 /// Whether the view's visible property has changed or a parent's.
1175 /// <since_tizen> 3 </since_tizen>
1176 public VisibilityChangeType Type
1190 /// Event arguments of layout direction changed.
1192 /// <since_tizen> 4 </since_tizen>
1193 public class LayoutDirectionChangedEventArgs : EventArgs
1196 private ViewLayoutDirectionType _type;
1199 /// The view, or child of view, whose layout direction has changed.
1201 /// <since_tizen> 4 </since_tizen>
1215 /// Whether the view's layout direction property has changed or a parent's.
1217 /// <since_tizen> 4 </since_tizen>
1218 public ViewLayoutDirectionType Type
1231 internal class BackgroundResourceLoadedEventArgs : EventArgs
1233 private ResourceLoadingStatusType status = ResourceLoadingStatusType.Invalid;
1234 public ResourceLoadingStatusType Status
1248 /// The class represents the information of the situation where the View's control state changes.
1250 [EditorBrowsable(EditorBrowsableState.Never)]
1251 public class ControlStateChangedEventArgs : EventArgs
1254 /// Create an instance with mandatory fields.
1256 /// <param name="previousState">The previous control state.</param>
1257 /// <param name="currentState">The current control state.</param>
1258 [EditorBrowsable(EditorBrowsableState.Never)]
1259 public ControlStateChangedEventArgs(ControlState previousState, ControlState currentState)
1261 PreviousState = previousState;
1262 CurrentState = currentState;
1266 /// The previous control state.
1268 [EditorBrowsable(EditorBrowsableState.Never)]
1269 public ControlState PreviousState { get; }
1272 /// The current control state.
1274 [EditorBrowsable(EditorBrowsableState.Never)]
1275 public ControlState CurrentState { get; }
1278 private EventHandlerWithReturnType<object, WheelEventArgs, bool> WindowWheelEventHandler;
1279 private void OnWindowWheelEvent(object sender, Window.WheelEventArgs e)
1283 if (e.Wheel.Type == Wheel.WheelType.CustomWheel)
1285 var arg = new WheelEventArgs()
1289 WindowWheelEventHandler?.Invoke(this, arg);