2 * Copyright(c) 2021 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;
22 namespace Tizen.NUI.BaseComponents
25 /// View is the base class for all views.
27 /// <since_tizen> 3 </since_tizen>
28 public partial class View
30 private EventHandler offWindowEventHandler;
31 private OffWindowEventCallbackType offWindowEventCallback;
32 private EventHandlerWithReturnType<object, WheelEventArgs, bool> wheelEventHandler;
33 private WheelEventCallbackType wheelEventCallback;
34 private EventHandlerWithReturnType<object, KeyEventArgs, bool> keyEventHandler;
35 private KeyCallbackType keyCallback;
36 private EventHandlerWithReturnType<object, TouchEventArgs, bool> interceptTouchDataEventHandler;
37 private TouchDataCallbackType interceptTouchDataCallback;
38 private EventHandlerWithReturnType<object, TouchEventArgs, bool> touchDataEventHandler;
39 private TouchDataCallbackType touchDataCallback;
40 private EventHandlerWithReturnType<object, HoverEventArgs, bool> hoverEventHandler;
41 private HoverEventCallbackType hoverEventCallback;
42 private EventHandler<VisibilityChangedEventArgs> visibilityChangedEventHandler;
43 private VisibilityChangedEventCallbackType visibilityChangedEventCallback;
44 private EventHandler keyInputFocusGainedEventHandler;
45 private KeyInputFocusGainedCallbackType keyInputFocusGainedCallback;
46 private EventHandler keyInputFocusLostEventHandler;
47 private KeyInputFocusLostCallbackType keyInputFocusLostCallback;
48 private EventHandler onRelayoutEventHandler;
49 private OnRelayoutEventCallbackType onRelayoutEventCallback;
50 private EventHandler onWindowEventHandler;
51 private OnWindowEventCallbackType onWindowEventCallback;
52 private EventHandler<LayoutDirectionChangedEventArgs> layoutDirectionChangedEventHandler;
53 private LayoutDirectionChangedEventCallbackType layoutDirectionChangedEventCallback;
54 // Resource Ready Signal
55 private EventHandler resourcesLoadedEventHandler;
56 private ResourcesLoadedCallbackType ResourcesLoadedCallback;
57 private EventHandler<BackgroundResourceLoadedEventArgs> backgroundResourceLoadedEventHandler;
58 private _backgroundResourceLoadedCallbackType backgroundResourceLoadedCallback;
59 private OnWindowEventCallbackType onWindowSendEventCallback;
60 private void SendViewAddedEventToWindow(IntPtr data)
64 NUIApplication.GetDefaultWindow()?.SendViewAdded(this);
67 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
68 private delegate void OffWindowEventCallbackType(IntPtr control);
69 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
70 private delegate bool WheelEventCallbackType(IntPtr view, IntPtr wheelEvent);
71 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
72 private delegate bool KeyCallbackType(IntPtr control, IntPtr keyEvent);
73 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
74 private delegate bool TouchDataCallbackType(IntPtr view, IntPtr touchData);
75 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
76 private delegate bool HoverEventCallbackType(IntPtr view, IntPtr hoverEvent);
77 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
78 private delegate void VisibilityChangedEventCallbackType(IntPtr data, bool visibility, VisibilityChangeType type);
79 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
80 private delegate void ResourcesLoadedCallbackType(IntPtr control);
81 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
82 private delegate void _backgroundResourceLoadedCallbackType(IntPtr view);
83 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
84 private delegate void KeyInputFocusGainedCallbackType(IntPtr control);
85 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
86 private delegate void KeyInputFocusLostCallbackType(IntPtr control);
87 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
88 private delegate void OnRelayoutEventCallbackType(IntPtr control);
89 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
90 private delegate void OnWindowEventCallbackType(IntPtr control);
91 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
92 private delegate void LayoutDirectionChangedEventCallbackType(IntPtr data, ViewLayoutDirectionType type);
95 /// Event when a child is removed.
97 /// <since_tizen> 5 </since_tizen>
98 public new event EventHandler<ChildRemovedEventArgs> ChildRemoved;
100 /// Event when a child is added.
102 /// <since_tizen> 5 </since_tizen>
103 public new event EventHandler<ChildAddedEventArgs> ChildAdded;
106 /// An event for the KeyInputFocusGained signal which can be used to subscribe or unsubscribe the event handler provided by the user.<br />
107 /// The KeyInputFocusGained signal is emitted when the control gets the key input focus.<br />
109 /// <since_tizen> 3 </since_tizen>
110 public event EventHandler FocusGained
114 if (keyInputFocusGainedEventHandler == null)
116 keyInputFocusGainedCallback = OnKeyInputFocusGained;
117 this.KeyInputFocusGainedSignal().Connect(keyInputFocusGainedCallback);
120 keyInputFocusGainedEventHandler += value;
125 keyInputFocusGainedEventHandler -= value;
127 if (keyInputFocusGainedEventHandler == null && KeyInputFocusGainedSignal().Empty() == false)
129 this.KeyInputFocusGainedSignal().Disconnect(keyInputFocusGainedCallback);
135 /// An event for the KeyInputFocusLost signal which can be used to subscribe or unsubscribe the event handler provided by the user.<br />
136 /// The KeyInputFocusLost signal is emitted when the control loses the key input focus.<br />
138 /// <since_tizen> 3 </since_tizen>
139 public event EventHandler FocusLost
143 if (keyInputFocusLostEventHandler == null)
145 keyInputFocusLostCallback = OnKeyInputFocusLost;
146 this.KeyInputFocusLostSignal().Connect(keyInputFocusLostCallback);
149 keyInputFocusLostEventHandler += value;
154 keyInputFocusLostEventHandler -= value;
156 if (keyInputFocusLostEventHandler == null && KeyInputFocusLostSignal().Empty() == false)
158 this.KeyInputFocusLostSignal().Disconnect(keyInputFocusLostCallback);
164 /// An event for the KeyPressed signal which can be used to subscribe or unsubscribe the event handler provided by the user.<br />
165 /// The KeyPressed signal is emitted when the key event is received.<br />
167 /// <since_tizen> 3 </since_tizen>
168 public event EventHandlerWithReturnType<object, KeyEventArgs, bool> KeyEvent
172 if (keyEventHandler == null)
174 keyCallback = OnKeyEvent;
175 this.KeyEventSignal().Connect(keyCallback);
178 keyEventHandler += value;
183 keyEventHandler -= value;
185 if (keyEventHandler == null && KeyEventSignal().Empty() == false)
187 this.KeyEventSignal().Disconnect(keyCallback);
193 /// An event for the OnRelayout signal which can be used to subscribe or unsubscribe the event handler.<br />
194 /// The OnRelayout signal is emitted after the size has been set on the view during relayout.<br />
196 /// <since_tizen> 3 </since_tizen>
197 public event EventHandler Relayout
201 if (onRelayoutEventHandler == null)
203 onRelayoutEventCallback = OnRelayout;
204 this.OnRelayoutSignal().Connect(onRelayoutEventCallback);
207 onRelayoutEventHandler += value;
212 onRelayoutEventHandler -= value;
214 if (onRelayoutEventHandler == null && OnRelayoutSignal().Empty() == false)
216 this.OnRelayoutSignal().Disconnect(onRelayoutEventCallback);
217 onRelayoutEventCallback = null;
224 /// An event for the touched signal which can be used to subscribe or unsubscribe the event handler provided by the user.<br />
225 /// The touched signal is emitted when the touch input is received.<br />
226 /// This can receive touch events before child. <br />
227 /// If it returns false, the child can receive the touch event. If it returns true, the touch event is intercepted. So child cannot receive touch event.<br />
229 [EditorBrowsable(EditorBrowsableState.Never)]
230 public event EventHandlerWithReturnType<object, TouchEventArgs, bool> InterceptTouchEvent
234 if (interceptTouchDataEventHandler == null)
236 interceptTouchDataCallback = OnInterceptTouch;
237 this.InterceptTouchSignal().Connect(interceptTouchDataCallback);
240 interceptTouchDataEventHandler += value;
245 interceptTouchDataEventHandler -= value;
247 if (interceptTouchDataEventHandler == null && InterceptTouchSignal().Empty() == false)
249 this.InterceptTouchSignal().Disconnect(interceptTouchDataCallback);
255 /// If child view doesn't want the parent's view to intercept the touch, you can set it to true.
257 /// parent.Add(child);
258 /// parent.InterceptTouchEvent += OnInterceptTouchEvent;
259 /// View view = child.GetParent() as View;
260 /// view.DisallowInterceptTouchEvent = true;
261 /// This prevents the parent from intercepting touch.
263 [EditorBrowsable(EditorBrowsableState.Never)]
264 public bool DisallowInterceptTouchEvent { get; set; }
268 /// An event for the touched signal which can be used to subscribe or unsubscribe the event handler provided by the user.<br />
269 /// The touched signal is emitted when the touch input is received.<br />
271 /// <since_tizen> 3 </since_tizen>
272 public event EventHandlerWithReturnType<object, TouchEventArgs, bool> TouchEvent
276 if (touchDataEventHandler == null)
278 touchDataCallback = OnTouch;
279 this.TouchSignal().Connect(touchDataCallback);
282 touchDataEventHandler += value;
287 touchDataEventHandler -= value;
289 if (touchDataEventHandler == null && TouchSignal().Empty() == false)
291 this.TouchSignal().Disconnect(touchDataCallback);
297 /// An event for the hovered signal which can be used to subscribe or unsubscribe the event handler provided by the user.<br />
298 /// The hovered signal is emitted when the hover input is received.<br />
300 /// <since_tizen> 3 </since_tizen>
301 public event EventHandlerWithReturnType<object, HoverEventArgs, bool> HoverEvent
305 if (hoverEventHandler == null)
307 hoverEventCallback = OnHoverEvent;
308 this.HoveredSignal().Connect(hoverEventCallback);
311 hoverEventHandler += value;
316 hoverEventHandler -= value;
318 if (hoverEventHandler == null && HoveredSignal().Empty() == false)
320 this.HoveredSignal().Disconnect(hoverEventCallback);
327 /// An event for the WheelMoved signal which can be used to subscribe or unsubscribe the event handler provided by the user.<br />
328 /// The WheelMoved signal is emitted when the wheel event is received.<br />
330 /// <since_tizen> 3 </since_tizen>
331 public event EventHandlerWithReturnType<object, WheelEventArgs, bool> WheelEvent
335 if (wheelEventHandler == null)
337 wheelEventCallback = OnWheelEvent;
338 this.WheelEventSignal().Connect(wheelEventCallback);
340 wheelEventHandler += value;
342 if (WindowWheelEventHandler == null)
344 NUIApplication.GetDefaultWindow().WheelEvent += OnWindowWheelEvent;
346 WindowWheelEventHandler += value;
351 wheelEventHandler -= value;
352 if (wheelEventHandler == null && WheelEventSignal().Empty() == false)
354 this.WheelEventSignal().Disconnect(wheelEventCallback);
357 WindowWheelEventHandler -= value;
358 if (WindowWheelEventHandler == null)
360 NUIApplication.GetDefaultWindow().WheelEvent -= OnWindowWheelEvent;
366 /// An event for the OnWindow signal which can be used to subscribe or unsubscribe the event handler.<br />
367 /// The OnWindow signal is emitted after the view has been connected to the window.<br />
369 /// <since_tizen> 3 </since_tizen>
370 public event EventHandler AddedToWindow
374 if (onWindowEventHandler == null)
376 onWindowEventCallback = OnWindow;
377 this.OnWindowSignal().Connect(onWindowEventCallback);
380 onWindowEventHandler += value;
385 onWindowEventHandler -= value;
387 if (onWindowEventHandler == null && OnWindowSignal().Empty() == false)
389 this.OnWindowSignal().Disconnect(onWindowEventCallback);
390 onWindowEventCallback = null;
396 /// An event for the OffWindow signal, which can be used to subscribe or unsubscribe the event handler.<br />
397 /// OffWindow signal is emitted after the view has been disconnected from the window.<br />
399 /// <since_tizen> 3 </since_tizen>
400 public event EventHandler RemovedFromWindow
404 if (offWindowEventHandler == null)
406 offWindowEventCallback = OffWindow;
407 this.OffWindowSignal().Connect(offWindowEventCallback);
410 offWindowEventHandler += value;
415 offWindowEventHandler -= value;
417 if (offWindowEventHandler == null && OffWindowSignal().Empty() == false)
419 this.OffWindowSignal().Disconnect(offWindowEventCallback);
420 offWindowEventCallback = null;
426 /// An event for visibility change which can be used to subscribe or unsubscribe the event handler.<br />
427 /// This signal is emitted when the visible property of this or a parent view is changed.<br />
429 /// <since_tizen> 3 </since_tizen>
430 public event EventHandler<VisibilityChangedEventArgs> VisibilityChanged
434 if (visibilityChangedEventHandler == null)
436 visibilityChangedEventCallback = OnVisibilityChanged;
437 VisibilityChangedSignal(this).Connect(visibilityChangedEventCallback);
440 visibilityChangedEventHandler += value;
445 visibilityChangedEventHandler -= value;
447 if (visibilityChangedEventHandler == null && VisibilityChangedSignal(this).Empty() == false)
449 VisibilityChangedSignal(this).Disconnect(visibilityChangedEventCallback);
455 /// Event for layout direction change which can be used to subscribe/unsubscribe the event handler.<br />
456 /// This signal is emitted when the layout direction property of this or a parent view is changed.<br />
458 /// <since_tizen> 4 </since_tizen>
459 public event EventHandler<LayoutDirectionChangedEventArgs> LayoutDirectionChanged
463 if (layoutDirectionChangedEventHandler == null)
465 layoutDirectionChangedEventCallback = OnLayoutDirectionChanged;
466 LayoutDirectionChangedSignal(this).Connect(layoutDirectionChangedEventCallback);
469 layoutDirectionChangedEventHandler += value;
474 layoutDirectionChangedEventHandler -= value;
476 if (layoutDirectionChangedEventHandler == null && LayoutDirectionChangedSignal(this).Empty() == false)
478 LayoutDirectionChangedSignal(this).Disconnect(layoutDirectionChangedEventCallback);
484 /// An event for the ResourcesLoadedSignal signal which can be used to subscribe or unsubscribe the event handler provided by the user.<br />
485 /// This signal is emitted after all resources required by a view are loaded and ready.<br />
487 /// <since_tizen> 3 </since_tizen>
488 public event EventHandler ResourcesLoaded
492 if (resourcesLoadedEventHandler == null)
494 ResourcesLoadedCallback = OnResourcesLoaded;
495 this.ResourcesLoadedSignal().Connect(ResourcesLoadedCallback);
498 resourcesLoadedEventHandler += value;
503 resourcesLoadedEventHandler -= value;
505 if (resourcesLoadedEventHandler == null && ResourcesLoadedSignal().Empty() == false)
507 this.ResourcesLoadedSignal().Disconnect(ResourcesLoadedCallback);
508 ResourcesLoadedCallback = null;
513 private EventHandler _backKeyPressed;
516 /// An event for getting notice when physical back key is pressed.<br />
517 /// This event is emitted BackKey is up.<br />
519 [EditorBrowsable(EditorBrowsableState.Never)]
520 public event EventHandler BackKeyPressed
524 _backKeyPressed += value;
525 BackKeyManager.Instance.Subscriber.Add(this);
530 BackKeyManager.Instance.Subscriber.Remove(this);
531 _backKeyPressed -= value;
536 /// Function for emitting BackKeyPressed event outside of View instance
538 [EditorBrowsable(EditorBrowsableState.Never)]
539 internal void EmitBackKeyPressed()
541 _backKeyPressed.Invoke(this, null);
545 internal event EventHandler<BackgroundResourceLoadedEventArgs> BackgroundResourceLoaded
549 if (backgroundResourceLoadedEventHandler == null)
551 backgroundResourceLoadedCallback = OnBackgroundResourceLoaded;
552 this.ResourcesLoadedSignal().Connect(backgroundResourceLoadedCallback);
555 backgroundResourceLoadedEventHandler += value;
559 backgroundResourceLoadedEventHandler -= value;
561 if (backgroundResourceLoadedEventHandler == null && ResourcesLoadedSignal().Empty() == false)
563 this.ResourcesLoadedSignal().Disconnect(backgroundResourceLoadedCallback);
564 backgroundResourceLoadedCallback = null;
569 internal TouchDataSignal InterceptTouchSignal()
571 TouchDataSignal ret = new TouchDataSignal(Interop.ActorSignal.ActorInterceptTouchSignal(SwigCPtr), false);
572 if (NDalicPINVOKE.SWIGPendingException.Pending)
573 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
577 internal TouchDataSignal TouchSignal()
579 TouchDataSignal ret = new TouchDataSignal(Interop.ActorSignal.ActorTouchSignal(SwigCPtr), false);
580 if (NDalicPINVOKE.SWIGPendingException.Pending)
581 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
585 internal HoverSignal HoveredSignal()
587 HoverSignal ret = new HoverSignal(Interop.ActorSignal.ActorHoveredSignal(SwigCPtr), false);
588 if (NDalicPINVOKE.SWIGPendingException.Pending)
589 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
593 internal WheelSignal WheelEventSignal()
595 WheelSignal ret = new WheelSignal(Interop.ActorSignal.ActorWheelEventSignal(SwigCPtr), false);
596 if (NDalicPINVOKE.SWIGPendingException.Pending)
597 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
601 internal ViewSignal OnWindowSignal()
603 ViewSignal ret = new ViewSignal(Interop.ActorSignal.ActorOnSceneSignal(SwigCPtr), false);
604 if (NDalicPINVOKE.SWIGPendingException.Pending)
605 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
609 internal ViewSignal OffWindowSignal()
611 ViewSignal ret = new ViewSignal(Interop.ActorSignal.ActorOffSceneSignal(SwigCPtr), false);
612 if (NDalicPINVOKE.SWIGPendingException.Pending)
613 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
617 internal ViewSignal OnRelayoutSignal()
619 ViewSignal ret = new ViewSignal(Interop.ActorSignal.ActorOnRelayoutSignal(SwigCPtr), false);
620 if (NDalicPINVOKE.SWIGPendingException.Pending)
621 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
625 internal ViewVisibilityChangedSignal VisibilityChangedSignal(View view)
627 ViewVisibilityChangedSignal ret = new ViewVisibilityChangedSignal(Interop.NDalic.VisibilityChangedSignal(View.getCPtr(view)), false);
628 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
632 internal ViewLayoutDirectionChangedSignal LayoutDirectionChangedSignal(View view)
634 ViewLayoutDirectionChangedSignal ret = new ViewLayoutDirectionChangedSignal(Interop.Layout.LayoutDirectionChangedSignal(View.getCPtr(view)), false);
635 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
639 internal ViewSignal ResourcesLoadedSignal()
641 ViewSignal ret = new ViewSignal(Interop.View.ResourceReadySignal(SwigCPtr), false);
642 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
646 internal ControlKeySignal KeyEventSignal()
648 ControlKeySignal ret = new ControlKeySignal(Interop.ViewSignal.KeyEventSignal(SwigCPtr), false);
649 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
653 internal KeyInputFocusSignal KeyInputFocusGainedSignal()
655 KeyInputFocusSignal ret = new KeyInputFocusSignal(Interop.ViewSignal.KeyInputFocusGainedSignal(SwigCPtr), false);
656 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
660 internal KeyInputFocusSignal KeyInputFocusLostSignal()
662 KeyInputFocusSignal ret = new KeyInputFocusSignal(Interop.ViewSignal.KeyInputFocusLostSignal(SwigCPtr), false);
663 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
667 private void OnSize2DChanged(int? width, int? height)
672 temp = new Tizen.NUI.PropertyValue((float)width);
673 Tizen.NUI.Object.SetProperty(this.SwigCPtr, View.Property.SizeWidth, temp);
678 temp = new Tizen.NUI.PropertyValue((float)height);
679 Tizen.NUI.Object.SetProperty(this.SwigCPtr, View.Property.SizeHeight, temp);
684 private void OnMinimumSizeChanged(int? width, int? height)
686 if (width != null && height != null)
688 MinimumSize = new Size2D((int)width, (int)height);
690 else if (width != null && height == null)
692 MinimumSize = new Size2D((int)width, (int)this.GetMinimumSize().Height);
694 else if (width == null && height != null)
696 MinimumSize = new Size2D((int)this.GetMinimumSize().Width, (int)height);
700 //both are null, do nothing.
704 private void OnMaximumSizeChanged(int? width, int? height)
706 if (width != null && height != null)
708 MaximumSize = new Size2D((int)width, (int)height);
710 else if (width != null && height == null)
712 MaximumSize = new Size2D((int)width, (int)this.GetMaximumSize().Height);
714 else if (width == null && height != null)
716 MaximumSize = new Size2D((int)this.GetMaximumSize().Width, (int)height);
720 //both are null, do nothing.
724 private void OnPosition2DChanged(int x, int y)
726 Position2D = new Position2D(x, y);
729 private void OnSizeChanged(float? width, float? height, float? depth)
734 temp = new Tizen.NUI.PropertyValue((float)width);
735 Tizen.NUI.Object.SetProperty(this.SwigCPtr, View.Property.SizeWidth, temp);
740 temp = new Tizen.NUI.PropertyValue((float)height);
741 Tizen.NUI.Object.SetProperty(this.SwigCPtr, View.Property.SizeHeight, temp);
746 temp = new Tizen.NUI.PropertyValue((float)depth);
747 Tizen.NUI.Object.SetProperty(this.SwigCPtr, View.Property.SizeDepth, temp);
752 private void OnPositionChanged(float x, float y, float z)
754 Position = new Position(x, y, z);
757 private void OnParentOriginChanged(float x, float y, float z)
759 ParentOrigin = new Position(x, y, z);
762 private void OnPivotPointChanged(float x, float y, float z)
764 PivotPoint = new Position(x, y, z);
767 private void OnImageShadowChanged(ShadowBase instance)
769 ImageShadow = (ImageShadow)instance;
772 private void OnBoxShadowChanged(ShadowBase instance)
774 BoxShadow = (Shadow)instance;
777 private void OnBackgroundImageBorderChanged(int left, int right, int bottom, int top)
779 BackgroundImageBorder = new Rectangle(left, right, bottom, top);
782 private void OnKeyInputFocusGained(IntPtr view)
784 if (keyInputFocusGainedEventHandler != null)
786 keyInputFocusGainedEventHandler(this, null);
790 private void OnKeyInputFocusLost(IntPtr view)
792 if (keyInputFocusLostEventHandler != null)
794 keyInputFocusLostEventHandler(this, null);
798 private bool OnKeyEvent(IntPtr view, IntPtr keyEvent)
800 if (keyEvent == global::System.IntPtr.Zero)
802 NUILog.Error("keyEvent should not be null!");
806 KeyEventArgs e = new KeyEventArgs();
810 e.Key = Tizen.NUI.Key.GetKeyFromPtr(keyEvent);
812 if (keyEventHandler != null)
814 Delegate[] delegateList = keyEventHandler.GetInvocationList();
816 // Oring the result of each callback.
817 foreach (EventHandlerWithReturnType<object, KeyEventArgs, bool> del in delegateList)
819 result |= del(this, e);
826 // Callback for View OnRelayout signal
827 private void OnRelayout(IntPtr data)
829 if (onRelayoutEventHandler != null)
831 onRelayoutEventHandler(this, null);
835 // Callback for View TouchSignal
836 private bool OnInterceptTouch(IntPtr view, IntPtr touchData)
838 if (touchData == global::System.IntPtr.Zero)
840 NUILog.Error("touchData should not be null!");
844 // DisallowInterceptTouchEvent prevents the parent from intercepting touch.
845 if (DisallowInterceptTouchEvent)
850 TouchEventArgs e = new TouchEventArgs();
852 e.Touch = Tizen.NUI.Touch.GetTouchFromPtr(touchData);
854 bool consumed = false;
856 if (interceptTouchDataEventHandler != null)
858 consumed = interceptTouchDataEventHandler(this, e);
864 // Callback for View TouchSignal
865 private bool OnTouch(IntPtr view, IntPtr touchData)
867 if (touchData == global::System.IntPtr.Zero)
869 NUILog.Error("touchData should not be null!");
873 TouchEventArgs e = new TouchEventArgs();
875 e.Touch = Tizen.NUI.Touch.GetTouchFromPtr(touchData);
877 bool consumed = false;
879 if (touchDataEventHandler != null)
881 consumed = touchDataEventHandler(this, e);
884 if (enableControlState && !consumed)
886 consumed = HandleControlStateOnTouch(e.Touch);
892 // Callback for View Hover signal
893 private bool OnHoverEvent(IntPtr view, IntPtr hoverEvent)
895 if (hoverEvent == global::System.IntPtr.Zero)
897 NUILog.Error("hoverEvent should not be null!");
901 HoverEventArgs e = new HoverEventArgs();
903 e.Hover = Tizen.NUI.Hover.GetHoverFromPtr(hoverEvent);
905 if (hoverEventHandler != null)
907 return hoverEventHandler(this, e);
912 // Callback for View Wheel signal
913 private bool OnWheelEvent(IntPtr view, IntPtr wheelEvent)
915 if (wheelEvent == global::System.IntPtr.Zero)
917 NUILog.Error("wheelEvent should not be null!");
921 WheelEventArgs e = new WheelEventArgs();
923 e.Wheel = Tizen.NUI.Wheel.GetWheelFromPtr(wheelEvent);
925 if (wheelEventHandler != null)
927 return wheelEventHandler(this, e);
932 // Callback for View OnWindow signal
933 private void OnWindow(IntPtr data)
935 if (onWindowEventHandler != null)
937 onWindowEventHandler(this, null);
941 // Callback for View OffWindow signal
942 private void OffWindow(IntPtr data)
944 if (offWindowEventHandler != null)
946 offWindowEventHandler(this, null);
950 // Callback for View visibility change signal
951 private void OnVisibilityChanged(IntPtr data, bool visibility, VisibilityChangeType type)
953 VisibilityChangedEventArgs e = new VisibilityChangedEventArgs();
956 e.View = Registry.GetManagedBaseHandleFromNativePtr(data) as View;
958 e.Visibility = visibility;
961 if (visibilityChangedEventHandler != null)
963 visibilityChangedEventHandler(this, e);
967 // Callback for View layout direction change signal
968 private void OnLayoutDirectionChanged(IntPtr data, ViewLayoutDirectionType type)
970 LayoutDirectionChangedEventArgs e = new LayoutDirectionChangedEventArgs();
973 e.View = Registry.GetManagedBaseHandleFromNativePtr(data) as View;
977 if (layoutDirectionChangedEventHandler != null)
979 layoutDirectionChangedEventHandler(this, e);
983 private void OnResourcesLoaded(IntPtr view)
985 if (resourcesLoadedEventHandler != null)
987 resourcesLoadedEventHandler(this, null);
991 private void OnBackgroundResourceLoaded(IntPtr view)
993 BackgroundResourceLoadedEventArgs e = new BackgroundResourceLoadedEventArgs();
994 e.Status = (ResourceLoadingStatusType)Interop.View.GetVisualResourceStatus(this.SwigCPtr, Property.BACKGROUND);
996 if (backgroundResourceLoadedEventHandler != null)
998 backgroundResourceLoadedEventHandler(this, e);
1003 /// Event argument passed through the ChildAdded event.
1005 /// <since_tizen> 5 </since_tizen>
1006 public class ChildAddedEventArgs : EventArgs
1009 /// Added child view at moment.
1011 /// <since_tizen> 5 </since_tizen>
1012 public View Added { get; set; }
1016 /// Event argument passed through the ChildRemoved event.
1018 /// <since_tizen> 5 </since_tizen>
1019 public class ChildRemovedEventArgs : EventArgs
1022 /// Removed child view at moment.
1024 /// <since_tizen> 5 </since_tizen>
1025 public View Removed { get; set; }
1029 /// Event arguments that passed via the KeyEvent signal.
1031 /// <since_tizen> 3 </since_tizen>
1032 public class KeyEventArgs : EventArgs
1037 /// Key - is the key sent to the view.
1039 /// <since_tizen> 3 </since_tizen>
1054 /// Event arguments that passed via the touch signal.
1056 /// <since_tizen> 3 </since_tizen>
1057 public class TouchEventArgs : EventArgs
1059 private Touch _touch;
1062 /// Touch - contains the information of touch points.
1064 /// <since_tizen> 3 </since_tizen>
1079 /// Event arguments that passed via the hover signal.
1081 /// <since_tizen> 3 </since_tizen>
1082 public class HoverEventArgs : EventArgs
1084 private Hover _hover;
1087 /// Hover - contains touch points that represent the points that are currently being hovered or the points where a hover has stopped.
1089 /// <since_tizen> 3 </since_tizen>
1104 /// Event arguments that passed via the wheel signal.
1106 /// <since_tizen> 3 </since_tizen>
1107 public class WheelEventArgs : EventArgs
1109 private Wheel _wheel;
1112 /// WheelEvent - store a wheel rolling type: MOUSE_WHEEL or CUSTOM_WHEEL.
1114 /// <since_tizen> 3 </since_tizen>
1129 /// Event arguments of visibility changed.
1131 /// <since_tizen> 3 </since_tizen>
1132 public class VisibilityChangedEventArgs : EventArgs
1135 private bool _visibility;
1136 private VisibilityChangeType _type;
1139 /// The view, or child of view, whose visibility has changed.
1141 /// <since_tizen> 3 </since_tizen>
1155 /// Whether the view is now visible or not.
1157 /// <since_tizen> 3 </since_tizen>
1158 public bool Visibility
1166 _visibility = value;
1171 /// Whether the view's visible property has changed or a parent's.
1173 /// <since_tizen> 3 </since_tizen>
1174 public VisibilityChangeType Type
1188 /// Event arguments of layout direction changed.
1190 /// <since_tizen> 4 </since_tizen>
1191 public class LayoutDirectionChangedEventArgs : EventArgs
1194 private ViewLayoutDirectionType _type;
1197 /// The view, or child of view, whose layout direction has changed.
1199 /// <since_tizen> 4 </since_tizen>
1213 /// Whether the view's layout direction property has changed or a parent's.
1215 /// <since_tizen> 4 </since_tizen>
1216 public ViewLayoutDirectionType Type
1229 internal class BackgroundResourceLoadedEventArgs : EventArgs
1231 private ResourceLoadingStatusType status = ResourceLoadingStatusType.Invalid;
1232 public ResourceLoadingStatusType Status
1246 /// The class represents the information of the situation where the View's control state changes.
1248 [EditorBrowsable(EditorBrowsableState.Never)]
1249 public class ControlStateChangedEventArgs : EventArgs
1252 /// Create an instance with mandatory fields.
1254 /// <param name="previousState">The previous control state.</param>
1255 /// <param name="currentState">The current control state.</param>
1256 [EditorBrowsable(EditorBrowsableState.Never)]
1257 public ControlStateChangedEventArgs(ControlState previousState, ControlState currentState)
1259 PreviousState = previousState;
1260 CurrentState = currentState;
1264 /// The previous control state.
1266 [EditorBrowsable(EditorBrowsableState.Never)]
1267 public ControlState PreviousState { get; }
1270 /// The current control state.
1272 [EditorBrowsable(EditorBrowsableState.Never)]
1273 public ControlState CurrentState { get; }
1276 private EventHandlerWithReturnType<object, WheelEventArgs, bool> WindowWheelEventHandler;
1277 private void OnWindowWheelEvent(object sender, Window.WheelEventArgs e)
1281 if (e.Wheel.Type == Wheel.WheelType.CustomWheel)
1283 var arg = new WheelEventArgs()
1287 WindowWheelEventHandler?.Invoke(this, arg);
1293 /// The expanded touch area.
1294 /// TouchArea can expand the view's touchable area.<br/>
1295 /// If you set the TouchAreaOffset on an view, when you touch the view, the touch area is used rather than the size of the view.<br/>
1298 /// This is based on the top left x, y coordinates.<br/>
1299 /// For example) <br/>
1301 /// view.Size = new Size(100, 100);
1302 /// view.TouchAreaOffset = new Offset(-10, 20, 30, -40); // left, right, bottom, top
1304 /// Then, touch area is 130x170.<br/>
1305 /// This is view.width + TouchAreaOffset.right - TouchAreaOffset.left and view.height + TouchAreaOffset.bottom - TouchAreaOffset.top <br/>
1306 /// +---------------------+ <br/>
1312 /// | +----+----+ | <br/>
1314 /// | -10| | 20 | <br/>
1315 /// |<---+ +----->| <br/>
1318 /// | +----+----+ | <br/>
1323 /// +---------------------+ <br/>
1325 [EditorBrowsable(EditorBrowsableState.Never)]
1326 public Offset TouchAreaOffset
1330 Interop.ActorInternal.GetTouchAreaOffset(SwigCPtr, out int left, out int right, out int bottom, out int top);
1331 if (NDalicPINVOKE.SWIGPendingException.Pending)
1332 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1333 return new Offset(left, right, bottom, top);
1337 Interop.ActorInternal.SetTouchAreaOffset(SwigCPtr, value.Left, value.Right, value.Bottom, value.Top);
1338 if (NDalicPINVOKE.SWIGPendingException.Pending)
1339 throw NDalicPINVOKE.SWIGPendingException.Retrieve();