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> _touchDataEventHandler;
38 private TouchDataCallbackType _touchDataCallback;
39 private EventHandlerWithReturnType<object, HoverEventArgs, bool> _hoverEventHandler;
40 private HoverEventCallbackType _hoverEventCallback;
41 private EventHandler<VisibilityChangedEventArgs> _visibilityChangedEventHandler;
42 private VisibilityChangedEventCallbackType _visibilityChangedEventCallback;
43 private EventHandler _keyInputFocusGainedEventHandler;
44 private KeyInputFocusGainedCallbackType _keyInputFocusGainedCallback;
45 private EventHandler _keyInputFocusLostEventHandler;
46 private KeyInputFocusLostCallbackType _keyInputFocusLostCallback;
47 private EventHandler _onRelayoutEventHandler;
48 private OnRelayoutEventCallbackType _onRelayoutEventCallback;
49 private EventHandler _onWindowEventHandler;
50 private OnWindowEventCallbackType _onWindowEventCallback;
51 private EventHandler<LayoutDirectionChangedEventArgs> _layoutDirectionChangedEventHandler;
52 private LayoutDirectionChangedEventCallbackType _layoutDirectionChangedEventCallback;
53 // Resource Ready Signal
54 private EventHandler _resourcesLoadedEventHandler;
55 private ResourcesLoadedCallbackType _ResourcesLoadedCallback;
56 private EventHandler<BackgroundResourceLoadedEventArgs> _backgroundResourceLoadedEventHandler;
57 private _backgroundResourceLoadedCallbackType _backgroundResourceLoadedCallback;
59 private OnWindowEventCallbackType _onWindowSendEventCallback;
61 private void SendViewAddedEventToWindow(IntPtr data)
63 NUIApplication.GetDefaultWindow()?.SendViewAdded(this);
66 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
67 private delegate void OffWindowEventCallbackType(IntPtr control);
68 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
69 private delegate bool WheelEventCallbackType(IntPtr view, IntPtr wheelEvent);
70 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
71 private delegate bool KeyCallbackType(IntPtr control, IntPtr keyEvent);
72 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
73 private delegate bool TouchDataCallbackType(IntPtr view, IntPtr touchData);
74 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
75 private delegate bool HoverEventCallbackType(IntPtr view, IntPtr hoverEvent);
76 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
77 private delegate void VisibilityChangedEventCallbackType(IntPtr data, bool visibility, VisibilityChangeType type);
78 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
79 private delegate void ResourcesLoadedCallbackType(IntPtr control);
80 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
81 private delegate void _backgroundResourceLoadedCallbackType(IntPtr view);
82 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
83 private delegate void KeyInputFocusGainedCallbackType(IntPtr control);
84 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
85 private delegate void KeyInputFocusLostCallbackType(IntPtr control);
86 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
87 private delegate void OnRelayoutEventCallbackType(IntPtr control);
88 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
89 private delegate void OnWindowEventCallbackType(IntPtr control);
90 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
91 private delegate void LayoutDirectionChangedEventCallbackType(IntPtr data, ViewLayoutDirectionType type);
94 /// Event when a child is removed.
96 /// <since_tizen> 5 </since_tizen>
97 public new event EventHandler<ChildRemovedEventArgs> ChildRemoved;
99 /// Event when a child is added.
101 /// <since_tizen> 5 </since_tizen>
102 public new event EventHandler<ChildAddedEventArgs> ChildAdded;
105 /// An event for the KeyInputFocusGained signal which can be used to subscribe or unsubscribe the event handler provided by the user.<br />
106 /// The KeyInputFocusGained signal is emitted when the control gets the key input focus.<br />
108 /// <since_tizen> 3 </since_tizen>
109 public event EventHandler FocusGained
113 if (_keyInputFocusGainedEventHandler == null)
115 _keyInputFocusGainedCallback = OnKeyInputFocusGained;
116 this.KeyInputFocusGainedSignal().Connect(_keyInputFocusGainedCallback);
119 _keyInputFocusGainedEventHandler += value;
124 _keyInputFocusGainedEventHandler -= value;
126 if (_keyInputFocusGainedEventHandler == null && KeyInputFocusGainedSignal().Empty() == false)
128 this.KeyInputFocusGainedSignal().Disconnect(_keyInputFocusGainedCallback);
134 /// An event for the KeyInputFocusLost signal which can be used to subscribe or unsubscribe the event handler provided by the user.<br />
135 /// The KeyInputFocusLost signal is emitted when the control loses the key input focus.<br />
137 /// <since_tizen> 3 </since_tizen>
138 public event EventHandler FocusLost
142 if (_keyInputFocusLostEventHandler == null)
144 _keyInputFocusLostCallback = OnKeyInputFocusLost;
145 this.KeyInputFocusLostSignal().Connect(_keyInputFocusLostCallback);
148 _keyInputFocusLostEventHandler += value;
153 _keyInputFocusLostEventHandler -= value;
155 if (_keyInputFocusLostEventHandler == null && KeyInputFocusLostSignal().Empty() == false)
157 this.KeyInputFocusLostSignal().Disconnect(_keyInputFocusLostCallback);
163 /// An event for the KeyPressed signal which can be used to subscribe or unsubscribe the event handler provided by the user.<br />
164 /// The KeyPressed signal is emitted when the key event is received.<br />
166 /// <since_tizen> 3 </since_tizen>
167 public event EventHandlerWithReturnType<object, KeyEventArgs, bool> KeyEvent
171 if (_keyEventHandler == null)
173 _keyCallback = OnKeyEvent;
174 this.KeyEventSignal().Connect(_keyCallback);
177 _keyEventHandler += value;
182 _keyEventHandler -= value;
184 if (_keyEventHandler == null && KeyEventSignal().Empty() == false)
186 this.KeyEventSignal().Disconnect(_keyCallback);
192 /// An event for the OnRelayout signal which can be used to subscribe or unsubscribe the event handler.<br />
193 /// The OnRelayout signal is emitted after the size has been set on the view during relayout.<br />
195 /// <since_tizen> 3 </since_tizen>
196 public event EventHandler Relayout
200 if (_onRelayoutEventHandler == null)
202 _onRelayoutEventCallback = OnRelayout;
203 this.OnRelayoutSignal().Connect(_onRelayoutEventCallback);
206 _onRelayoutEventHandler += value;
211 _onRelayoutEventHandler -= value;
213 if (_onRelayoutEventHandler == null && OnRelayoutSignal().Empty() == false)
215 this.OnRelayoutSignal().Disconnect(_onRelayoutEventCallback);
222 /// An event for the touched signal which can be used to subscribe or unsubscribe the event handler provided by the user.<br />
223 /// The touched signal is emitted when the touch input is received.<br />
225 /// <since_tizen> 3 </since_tizen>
226 public event EventHandlerWithReturnType<object, TouchEventArgs, bool> TouchEvent
230 if (_touchDataEventHandler == null)
232 _touchDataCallback = OnTouch;
233 this.TouchSignal().Connect(_touchDataCallback);
236 _touchDataEventHandler += value;
241 _touchDataEventHandler -= value;
243 if (_touchDataEventHandler == null && TouchSignal().Empty() == false)
245 this.TouchSignal().Disconnect(_touchDataCallback);
251 /// An event for the hovered signal which can be used to subscribe or unsubscribe the event handler provided by the user.<br />
252 /// The hovered signal is emitted when the hover input is received.<br />
254 /// <since_tizen> 3 </since_tizen>
255 public event EventHandlerWithReturnType<object, HoverEventArgs, bool> HoverEvent
259 if (_hoverEventHandler == null)
261 _hoverEventCallback = OnHoverEvent;
262 this.HoveredSignal().Connect(_hoverEventCallback);
265 _hoverEventHandler += value;
270 _hoverEventHandler -= value;
272 if (_hoverEventHandler == null && HoveredSignal().Empty() == false)
274 this.HoveredSignal().Disconnect(_hoverEventCallback);
281 /// An event for the WheelMoved signal which can be used to subscribe or unsubscribe the event handler provided by the user.<br />
282 /// The WheelMoved signal is emitted when the wheel event is received.<br />
284 /// <since_tizen> 3 </since_tizen>
285 public event EventHandlerWithReturnType<object, WheelEventArgs, bool> WheelEvent
289 if (_wheelEventHandler == null)
291 _wheelEventCallback = OnWheelEvent;
292 this.WheelEventSignal().Connect(_wheelEventCallback);
294 _wheelEventHandler += value;
296 if (WindowWheelEventHandler == null)
298 NUIApplication.GetDefaultWindow().WheelEvent += OnWindowWheelEvent;
300 WindowWheelEventHandler += value;
305 _wheelEventHandler -= value;
306 if (_wheelEventHandler == null && WheelEventSignal().Empty() == false)
308 this.WheelEventSignal().Disconnect(_wheelEventCallback);
311 WindowWheelEventHandler -= value;
312 if (WindowWheelEventHandler == null)
314 NUIApplication.GetDefaultWindow().WheelEvent -= OnWindowWheelEvent;
320 /// An event for the OnWindow signal which can be used to subscribe or unsubscribe the event handler.<br />
321 /// The OnWindow signal is emitted after the view has been connected to the window.<br />
323 /// <since_tizen> 3 </since_tizen>
324 public event EventHandler AddedToWindow
328 if (_onWindowEventHandler == null)
330 _onWindowEventCallback = OnWindow;
331 this.OnWindowSignal().Connect(_onWindowEventCallback);
334 _onWindowEventHandler += value;
339 _onWindowEventHandler -= value;
341 if (_onWindowEventHandler == null && OnWindowSignal().Empty() == false)
343 this.OnWindowSignal().Disconnect(_onWindowEventCallback);
349 /// An event for the OffWindow signal, which can be used to subscribe or unsubscribe the event handler.<br />
350 /// OffWindow signal is emitted after the view has been disconnected from the window.<br />
352 /// <since_tizen> 3 </since_tizen>
353 public event EventHandler RemovedFromWindow
357 if (_offWindowEventHandler == null)
359 _offWindowEventCallback = OffWindow;
360 this.OffWindowSignal().Connect(_offWindowEventCallback);
363 _offWindowEventHandler += value;
368 _offWindowEventHandler -= value;
370 if (_offWindowEventHandler == null && OffWindowSignal().Empty() == false)
372 this.OffWindowSignal().Disconnect(_offWindowEventCallback);
378 /// An event for visibility change which can be used to subscribe or unsubscribe the event handler.<br />
379 /// This signal is emitted when the visible property of this or a parent view is changed.<br />
381 /// <since_tizen> 3 </since_tizen>
382 public event EventHandler<VisibilityChangedEventArgs> VisibilityChanged
386 if (_visibilityChangedEventHandler == null)
388 _visibilityChangedEventCallback = OnVisibilityChanged;
389 VisibilityChangedSignal(this).Connect(_visibilityChangedEventCallback);
392 _visibilityChangedEventHandler += value;
397 _visibilityChangedEventHandler -= value;
399 if (_visibilityChangedEventHandler == null && VisibilityChangedSignal(this).Empty() == false)
401 VisibilityChangedSignal(this).Disconnect(_visibilityChangedEventCallback);
407 /// Event for layout direction change which can be used to subscribe/unsubscribe the event handler.<br />
408 /// This signal is emitted when the layout direction property of this or a parent view is changed.<br />
410 /// <since_tizen> 4 </since_tizen>
411 public event EventHandler<LayoutDirectionChangedEventArgs> LayoutDirectionChanged
415 if (_layoutDirectionChangedEventHandler == null)
417 _layoutDirectionChangedEventCallback = OnLayoutDirectionChanged;
418 LayoutDirectionChangedSignal(this).Connect(_layoutDirectionChangedEventCallback);
421 _layoutDirectionChangedEventHandler += value;
426 _layoutDirectionChangedEventHandler -= value;
428 if (_layoutDirectionChangedEventHandler == null && LayoutDirectionChangedSignal(this).Empty() == false)
430 LayoutDirectionChangedSignal(this).Disconnect(_layoutDirectionChangedEventCallback);
436 /// An event for the ResourcesLoadedSignal signal which can be used to subscribe or unsubscribe the event handler provided by the user.<br />
437 /// This signal is emitted after all resources required by a view are loaded and ready.<br />
439 /// <since_tizen> 3 </since_tizen>
440 public event EventHandler ResourcesLoaded
444 if (_resourcesLoadedEventHandler == null)
446 _ResourcesLoadedCallback = OnResourcesLoaded;
447 this.ResourcesLoadedSignal().Connect(_ResourcesLoadedCallback);
450 _resourcesLoadedEventHandler += value;
455 _resourcesLoadedEventHandler -= value;
457 if (_resourcesLoadedEventHandler == null && ResourcesLoadedSignal().Empty() == false)
459 this.ResourcesLoadedSignal().Disconnect(_ResourcesLoadedCallback);
464 private EventHandler _backKeyPressed;
467 /// An event for getting notice when physical back key is pressed.<br />
468 /// This event is emitted BackKey is up.<br />
470 [EditorBrowsable(EditorBrowsableState.Never)]
471 public event EventHandler BackKeyPressed
475 _backKeyPressed += value;
476 BackKeyManager.Instance.Subscriber.Add(this);
481 BackKeyManager.Instance.Subscriber.Remove(this);
482 _backKeyPressed -= value;
487 /// Function for emitting BackKeyPressed event outside of View instance
489 [EditorBrowsable(EditorBrowsableState.Never)]
490 internal void EmitBackKeyPressed()
492 _backKeyPressed.Invoke(this,null);
496 internal event EventHandler<BackgroundResourceLoadedEventArgs> BackgroundResourceLoaded
500 if (_backgroundResourceLoadedEventHandler == null)
502 _backgroundResourceLoadedCallback = OnBackgroundResourceLoaded;
503 this.ResourcesLoadedSignal().Connect(_backgroundResourceLoadedCallback);
506 _backgroundResourceLoadedEventHandler += value;
510 _backgroundResourceLoadedEventHandler -= value;
512 if (_backgroundResourceLoadedEventHandler == null && ResourcesLoadedSignal().Empty() == false)
514 this.ResourcesLoadedSignal().Disconnect(_backgroundResourceLoadedCallback);
519 internal TouchDataSignal TouchSignal()
521 TouchDataSignal ret = new TouchDataSignal(Interop.ActorSignal.Actor_TouchSignal(swigCPtr), false);
522 if (NDalicPINVOKE.SWIGPendingException.Pending)
523 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
527 internal HoverSignal HoveredSignal()
529 HoverSignal ret = new HoverSignal(Interop.ActorSignal.Actor_HoveredSignal(swigCPtr), false);
530 if (NDalicPINVOKE.SWIGPendingException.Pending)
531 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
535 internal WheelSignal WheelEventSignal()
537 WheelSignal ret = new WheelSignal(Interop.ActorSignal.Actor_WheelEventSignal(swigCPtr), false);
538 if (NDalicPINVOKE.SWIGPendingException.Pending)
539 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
543 internal ViewSignal OnWindowSignal()
545 ViewSignal ret = new ViewSignal(Interop.ActorSignal.Actor_OnSceneSignal(swigCPtr), false);
546 if (NDalicPINVOKE.SWIGPendingException.Pending)
547 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
551 internal ViewSignal OffWindowSignal()
553 ViewSignal ret = new ViewSignal(Interop.ActorSignal.Actor_OffSceneSignal(swigCPtr), false);
554 if (NDalicPINVOKE.SWIGPendingException.Pending)
555 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
559 internal ViewSignal OnRelayoutSignal()
561 ViewSignal ret = new ViewSignal(Interop.ActorSignal.Actor_OnRelayoutSignal(swigCPtr), false);
562 if (NDalicPINVOKE.SWIGPendingException.Pending)
563 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
567 internal ViewVisibilityChangedSignal VisibilityChangedSignal(View view)
569 ViewVisibilityChangedSignal ret = new ViewVisibilityChangedSignal(Interop.NDalic.VisibilityChangedSignal(View.getCPtr(view)), false);
570 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
574 internal ViewLayoutDirectionChangedSignal LayoutDirectionChangedSignal(View view)
576 ViewLayoutDirectionChangedSignal ret = new ViewLayoutDirectionChangedSignal(Interop.Layout.LayoutDirectionChangedSignal(View.getCPtr(view)), false);
577 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
581 internal ViewSignal ResourcesLoadedSignal()
583 ViewSignal ret = new ViewSignal(Interop.View.ResourceReadySignal(swigCPtr), false);
584 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
588 internal ControlKeySignal KeyEventSignal()
590 ControlKeySignal ret = new ControlKeySignal(Interop.ViewSignal.View_KeyEventSignal(swigCPtr), false);
591 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
595 internal KeyInputFocusSignal KeyInputFocusGainedSignal()
597 KeyInputFocusSignal ret = new KeyInputFocusSignal(Interop.ViewSignal.View_KeyInputFocusGainedSignal(swigCPtr), false);
598 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
602 internal KeyInputFocusSignal KeyInputFocusLostSignal()
604 KeyInputFocusSignal ret = new KeyInputFocusSignal(Interop.ViewSignal.View_KeyInputFocusLostSignal(swigCPtr), false);
605 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
609 private void OnSize2DChanged(int? width, int? height)
613 Tizen.NUI.Object.SetProperty(this.swigCPtr, View.Property.SIZE_WIDTH, new Tizen.NUI.PropertyValue((float)width));
617 Tizen.NUI.Object.SetProperty(this.swigCPtr, View.Property.SIZE_HEIGHT, new Tizen.NUI.PropertyValue((float)height));
621 private void OnMinimumSizeChanged(int? width, int? height)
623 if (width != null && height != null)
625 MinimumSize = new Size2D((int)width, (int)height);
627 else if (width != null && height == null)
629 MinimumSize = new Size2D((int)width, (int)this.GetMinimumSize().Height);
631 else if (width == null && height != null)
633 MinimumSize = new Size2D((int)this.GetMinimumSize().Width, (int)height);
637 //both are null, do nothing.
641 private void OnMaximumSizeChanged(int? width, int? height)
643 if (width != null && height != null)
645 MaximumSize = new Size2D((int)width, (int)height);
647 else if (width != null && height == null)
649 MaximumSize = new Size2D((int)width, (int)this.GetMaximumSize().Height);
651 else if (width == null && height != null)
653 MaximumSize = new Size2D((int)this.GetMaximumSize().Width, (int)height);
657 //both are null, do nothing.
661 private void OnPosition2DChanged(int x, int y)
663 Position2D = new Position2D(x, y);
666 private void OnSizeChanged(float? width, float? height, float? depth)
670 Tizen.NUI.Object.SetProperty(this.swigCPtr, View.Property.SIZE_WIDTH, new Tizen.NUI.PropertyValue((float)width));
674 Tizen.NUI.Object.SetProperty(this.swigCPtr, View.Property.SIZE_HEIGHT, new Tizen.NUI.PropertyValue((float)height));
678 Tizen.NUI.Object.SetProperty(this.swigCPtr, View.Property.SIZE_DEPTH, new Tizen.NUI.PropertyValue((float)depth));
682 private void OnPositionChanged(float x, float y, float z)
684 Position = new Position(x, y, z);
687 private void OnParentOriginChanged(float x, float y, float z)
689 ParentOrigin = new Position(x, y, z);
692 private void OnPivotPointChanged(float x, float y, float z)
694 PivotPoint = new Position(x, y, z);
697 private void OnImageShadowChanged(ShadowBase instance)
699 ImageShadow = (ImageShadow)instance;
702 private void OnBoxShadowChanged(ShadowBase instance)
704 BoxShadow = (Shadow)instance;
707 private void OnBackgroundImageBorderChanged(int left, int right, int bottom, int top)
709 BackgroundImageBorder = new Rectangle(left, right, bottom, top);
712 private void OnKeyInputFocusGained(IntPtr view)
714 if (_keyInputFocusGainedEventHandler != null)
716 _keyInputFocusGainedEventHandler(this, null);
720 private void OnKeyInputFocusLost(IntPtr view)
722 if (_keyInputFocusLostEventHandler != null)
724 _keyInputFocusLostEventHandler(this, null);
728 private bool OnKeyEvent(IntPtr view, IntPtr keyEvent)
730 if (keyEvent == global::System.IntPtr.Zero)
732 NUILog.Error("keyEvent should not be null!");
736 KeyEventArgs e = new KeyEventArgs();
740 e.Key = Tizen.NUI.Key.GetKeyFromPtr(keyEvent);
742 if (_keyEventHandler != null)
744 Delegate[] delegateList = _keyEventHandler.GetInvocationList();
746 // Oring the result of each callback.
747 foreach (EventHandlerWithReturnType<object, KeyEventArgs, bool> del in delegateList)
749 result |= del(this, e);
756 // Callback for View OnRelayout signal
757 private void OnRelayout(IntPtr data)
759 if (_onRelayoutEventHandler != null)
761 _onRelayoutEventHandler(this, null);
765 // Callback for View TouchSignal
766 private bool OnTouch(IntPtr view, IntPtr touchData)
768 if (touchData == global::System.IntPtr.Zero)
770 NUILog.Error("touchData should not be null!");
774 TouchEventArgs e = new TouchEventArgs();
776 e.Touch = Tizen.NUI.Touch.GetTouchFromPtr(touchData);
778 bool consumed = false;
780 if (_touchDataEventHandler != null)
782 consumed = _touchDataEventHandler(this, e);
785 if (enableControlState && !consumed)
787 consumed = HandleControlStateOnTouch(e.Touch);
793 // Callback for View Hover signal
794 private bool OnHoverEvent(IntPtr view, IntPtr hoverEvent)
796 if (hoverEvent == global::System.IntPtr.Zero)
798 NUILog.Error("hoverEvent should not be null!");
802 HoverEventArgs e = new HoverEventArgs();
804 e.Hover = Tizen.NUI.Hover.GetHoverFromPtr(hoverEvent);
806 if (_hoverEventHandler != null)
808 return _hoverEventHandler(this, e);
813 // Callback for View Wheel signal
814 private bool OnWheelEvent(IntPtr view, IntPtr wheelEvent)
816 if (wheelEvent == global::System.IntPtr.Zero)
818 NUILog.Error("wheelEvent should not be null!");
822 WheelEventArgs e = new WheelEventArgs();
824 e.Wheel = Tizen.NUI.Wheel.GetWheelFromPtr(wheelEvent);
826 if (_wheelEventHandler != null)
828 return _wheelEventHandler(this, e);
833 // Callback for View OnWindow signal
834 private void OnWindow(IntPtr data)
836 if (_onWindowEventHandler != null)
838 _onWindowEventHandler(this, null);
842 // Callback for View OffWindow signal
843 private void OffWindow(IntPtr data)
845 if (_offWindowEventHandler != null)
847 _offWindowEventHandler(this, null);
851 // Callback for View visibility change signal
852 private void OnVisibilityChanged(IntPtr data, bool visibility, VisibilityChangeType type)
854 VisibilityChangedEventArgs e = new VisibilityChangedEventArgs();
857 e.View = Registry.GetManagedBaseHandleFromNativePtr(data) as View;
859 e.Visibility = visibility;
862 if (_visibilityChangedEventHandler != null)
864 _visibilityChangedEventHandler(this, e);
868 // Callback for View layout direction change signal
869 private void OnLayoutDirectionChanged(IntPtr data, ViewLayoutDirectionType type)
871 LayoutDirectionChangedEventArgs e = new LayoutDirectionChangedEventArgs();
874 e.View = Registry.GetManagedBaseHandleFromNativePtr(data) as View;
878 if (_layoutDirectionChangedEventHandler != null)
880 _layoutDirectionChangedEventHandler(this, e);
884 private void OnResourcesLoaded(IntPtr view)
886 if (_resourcesLoadedEventHandler != null)
888 _resourcesLoadedEventHandler(this, null);
892 private void OnBackgroundResourceLoaded(IntPtr view)
894 BackgroundResourceLoadedEventArgs e = new BackgroundResourceLoadedEventArgs();
895 e.Status = (ResourceLoadingStatusType)Interop.View.View_GetVisualResourceStatus(this.swigCPtr, Property.BACKGROUND);
897 if (_backgroundResourceLoadedEventHandler != null)
899 _backgroundResourceLoadedEventHandler(this, e);
904 /// Event argument passed through the ChildAdded event.
906 /// <since_tizen> 5 </since_tizen>
907 public class ChildAddedEventArgs : EventArgs
910 /// Added child view at moment.
912 /// <since_tizen> 5 </since_tizen>
913 public View Added { get; set; }
917 /// Event argument passed through the ChildRemoved event.
919 /// <since_tizen> 5 </since_tizen>
920 public class ChildRemovedEventArgs : EventArgs
923 /// Removed child view at moment.
925 /// <since_tizen> 5 </since_tizen>
926 public View Removed { get; set; }
930 /// Event arguments that passed via the KeyEvent signal.
932 /// <since_tizen> 3 </since_tizen>
933 public class KeyEventArgs : EventArgs
938 /// Key - is the key sent to the view.
940 /// <since_tizen> 3 </since_tizen>
955 /// Event arguments that passed via the touch signal.
957 /// <since_tizen> 3 </since_tizen>
958 public class TouchEventArgs : EventArgs
960 private Touch _touch;
963 /// Touch - contains the information of touch points.
965 /// <since_tizen> 3 </since_tizen>
980 /// Event arguments that passed via the hover signal.
982 /// <since_tizen> 3 </since_tizen>
983 public class HoverEventArgs : EventArgs
985 private Hover _hover;
988 /// Hover - contains touch points that represent the points that are currently being hovered or the points where a hover has stopped.
990 /// <since_tizen> 3 </since_tizen>
1005 /// Event arguments that passed via the wheel signal.
1007 /// <since_tizen> 3 </since_tizen>
1008 public class WheelEventArgs : EventArgs
1010 private Wheel _wheel;
1013 /// WheelEvent - store a wheel rolling type: MOUSE_WHEEL or CUSTOM_WHEEL.
1015 /// <since_tizen> 3 </since_tizen>
1030 /// Event arguments of visibility changed.
1032 /// <since_tizen> 3 </since_tizen>
1033 public class VisibilityChangedEventArgs : EventArgs
1036 private bool _visibility;
1037 private VisibilityChangeType _type;
1040 /// The view, or child of view, whose visibility has changed.
1042 /// <since_tizen> 3 </since_tizen>
1056 /// Whether the view is now visible or not.
1058 /// <since_tizen> 3 </since_tizen>
1059 public bool Visibility
1067 _visibility = value;
1072 /// Whether the view's visible property has changed or a parent's.
1074 /// <since_tizen> 3 </since_tizen>
1075 public VisibilityChangeType Type
1089 /// Event arguments of layout direction changed.
1091 /// <since_tizen> 4 </since_tizen>
1092 public class LayoutDirectionChangedEventArgs : EventArgs
1095 private ViewLayoutDirectionType _type;
1098 /// The view, or child of view, whose layout direction has changed.
1100 /// <since_tizen> 4 </since_tizen>
1114 /// Whether the view's layout direction property has changed or a parent's.
1116 /// <since_tizen> 4 </since_tizen>
1117 public ViewLayoutDirectionType Type
1130 internal class BackgroundResourceLoadedEventArgs : EventArgs
1132 private ResourceLoadingStatusType status = ResourceLoadingStatusType.Invalid;
1133 public ResourceLoadingStatusType Status
1147 /// The class represents the information of the situation where the View's control state changes.
1149 [EditorBrowsable(EditorBrowsableState.Never)]
1150 public class ControlStateChangedEventArgs : EventArgs
1153 /// Create an instance with mandatory fields.
1155 /// <param name="previousState">The previous control state.</param>
1156 /// <param name="currentState">The current control state.</param>
1157 [EditorBrowsable(EditorBrowsableState.Never)]
1158 public ControlStateChangedEventArgs(ControlState previousState, ControlState currentState)
1160 PreviousState = previousState;
1161 CurrentState = currentState;
1165 /// The previous control state.
1167 [EditorBrowsable(EditorBrowsableState.Never)]
1168 public ControlState PreviousState { get; }
1171 /// The current control state.
1173 [EditorBrowsable(EditorBrowsableState.Never)]
1174 public ControlState CurrentState { get; }
1177 private EventHandlerWithReturnType<object, WheelEventArgs, bool> WindowWheelEventHandler;
1178 private void OnWindowWheelEvent(object sender, Window.WheelEventArgs e)
1182 if(e.Wheel.Type == Wheel.WheelType.CustomWheel)
1184 var arg = new WheelEventArgs()
1188 WindowWheelEventHandler?.Invoke(this, arg);