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;
46 private KeyInputFocusGainedCallbackType keyInputFocusGainedCallback;
47 private EventHandler keyInputFocusLostEventHandler;
49 private KeyInputFocusLostCallbackType keyInputFocusLostCallback;
50 private EventHandler onRelayoutEventHandler;
51 private OnRelayoutEventCallbackType onRelayoutEventCallback;
52 private EventHandler onWindowEventHandler;
53 private OnWindowEventCallbackType onWindowEventCallback;
54 private EventHandler<LayoutDirectionChangedEventArgs> layoutDirectionChangedEventHandler;
55 private LayoutDirectionChangedEventCallbackType layoutDirectionChangedEventCallback;
56 // Resource Ready Signal
57 private EventHandler resourcesLoadedEventHandler;
58 private ResourcesLoadedCallbackType ResourcesLoadedCallback;
59 private EventHandler<BackgroundResourceLoadedEventArgs> backgroundResourceLoadedEventHandler;
60 private _backgroundResourceLoadedCallbackType backgroundResourceLoadedCallback;
61 private OnWindowEventCallbackType onWindowSendEventCallback;
62 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);
86 [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
87 private delegate void KeyInputFocusGainedCallbackType(IntPtr control);
88 [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
89 private delegate void KeyInputFocusLostCallbackType(IntPtr control);
91 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
92 private delegate void OnRelayoutEventCallbackType(IntPtr control);
93 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
94 private delegate void OnWindowEventCallbackType(IntPtr control);
95 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
96 private delegate void LayoutDirectionChangedEventCallbackType(IntPtr data, ViewLayoutDirectionType type);
99 /// Event when a child is removed.
101 /// <since_tizen> 5 </since_tizen>
102 public new event EventHandler<ChildRemovedEventArgs> ChildRemoved;
104 /// Event when a child is added.
106 /// <since_tizen> 5 </since_tizen>
107 public new event EventHandler<ChildAddedEventArgs> ChildAdded;
110 /// An event for the KeyInputFocusGained signal which can be used to subscribe or unsubscribe the event handler provided by the user.<br />
111 /// The KeyInputFocusGained signal is emitted when the control gets the key input focus.<br />
113 /// <since_tizen> 3 </since_tizen>
114 public event EventHandler FocusGained
118 if (keyInputFocusGainedEventHandler == null)
120 keyInputFocusGainedCallback = OnKeyInputFocusGained;
121 using KeyInputFocusSignal signal = new KeyInputFocusSignal(Interop.ViewSignal.KeyInputFocusGainedSignal(SwigCPtr), false);
122 signal?.Connect(keyInputFocusGainedCallback);
124 keyInputFocusGainedEventHandler += value;
129 keyInputFocusGainedEventHandler -= value;
130 if (keyInputFocusGainedEventHandler == null)
132 using KeyInputFocusSignal signal = new KeyInputFocusSignal(Interop.ViewSignal.KeyInputFocusGainedSignal(SwigCPtr), false);
134 if (keyInputFocusGainedCallback != null)
136 signal?.Disconnect(keyInputFocusGainedCallback);
137 if (signal?.Empty() == true)
139 keyInputFocusGainedCallback = null;
147 /// An event for the KeyInputFocusLost signal which can be used to subscribe or unsubscribe the event handler provided by the user.<br />
148 /// The KeyInputFocusLost signal is emitted when the control loses the key input focus.<br />
150 /// <since_tizen> 3 </since_tizen>
151 public event EventHandler FocusLost
155 if (keyInputFocusLostEventHandler == null)
157 keyInputFocusLostCallback = OnKeyInputFocusLost;
158 using KeyInputFocusSignal signal = new KeyInputFocusSignal(Interop.ViewSignal.KeyInputFocusLostSignal(SwigCPtr), false);
159 signal?.Connect(keyInputFocusLostCallback);
161 keyInputFocusLostEventHandler += value;
166 keyInputFocusLostEventHandler -= value;
167 if (keyInputFocusLostEventHandler == null)
169 using KeyInputFocusSignal signal = new KeyInputFocusSignal(Interop.ViewSignal.KeyInputFocusLostSignal(SwigCPtr), false);
171 if (keyInputFocusLostCallback != null)
173 signal?.Disconnect(keyInputFocusLostCallback);
174 if (signal?.Empty() == true)
176 keyInputFocusLostCallback = null;
184 /// An event for the KeyPressed signal which can be used to subscribe or unsubscribe the event handler provided by the user.<br />
185 /// The KeyPressed signal is emitted when the key event is received.<br />
187 /// <since_tizen> 3 </since_tizen>
188 public event EventHandlerWithReturnType<object, KeyEventArgs, bool> KeyEvent
192 if (keyEventHandler == null)
194 keyCallback = OnKeyEvent;
195 using ControlKeySignal signal = new ControlKeySignal(Interop.ViewSignal.KeyEventSignal(SwigCPtr), false);
196 signal?.Connect(keyCallback);
198 keyEventHandler += value;
203 keyEventHandler -= value;
204 if (keyEventHandler == null)
206 using ControlKeySignal signal = new ControlKeySignal(Interop.ViewSignal.KeyEventSignal(SwigCPtr), false);
207 if (signal?.Empty() == false)
209 signal?.Disconnect(keyCallback);
217 /// An event for the OnRelayout signal which can be used to subscribe or unsubscribe the event handler.<br />
218 /// The OnRelayout signal is emitted after the size has been set on the view during relayout.<br />
220 /// <since_tizen> 3 </since_tizen>
221 public event EventHandler Relayout
225 if (onRelayoutEventHandler == null)
227 onRelayoutEventCallback = OnRelayout;
228 using ViewSignal signal = new ViewSignal(Interop.ActorSignal.ActorOnRelayoutSignal(SwigCPtr), false);
229 signal?.Connect(onRelayoutEventCallback);
231 onRelayoutEventHandler += value;
236 onRelayoutEventHandler -= value;
237 if (onRelayoutEventHandler == null)
239 using ViewSignal signal = new ViewSignal(Interop.ActorSignal.ActorOnRelayoutSignal(SwigCPtr), false);
240 if (signal?.Empty() == false)
242 signal?.Disconnect(onRelayoutEventCallback);
243 onRelayoutEventCallback = null;
250 /// An event for the touched signal which can be used to subscribe or unsubscribe the event handler provided by the user.<br />
251 /// The touched signal is emitted when the touch input is received.<br />
252 /// This can receive touch events before child. <br />
253 /// 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 />
255 [EditorBrowsable(EditorBrowsableState.Never)]
256 public event EventHandlerWithReturnType<object, TouchEventArgs, bool> InterceptTouchEvent
260 if (interceptTouchDataEventHandler == null)
262 interceptTouchDataCallback = OnInterceptTouch;
263 using TouchDataSignal signal = new TouchDataSignal(Interop.ActorSignal.ActorInterceptTouchSignal(SwigCPtr), false);
264 signal?.Connect(interceptTouchDataCallback);
266 interceptTouchDataEventHandler += value;
271 interceptTouchDataEventHandler -= value;
272 if (interceptTouchDataEventHandler == null)
274 using TouchDataSignal signal = new TouchDataSignal(Interop.ActorSignal.ActorInterceptTouchSignal(SwigCPtr), false);
275 if (signal?.Empty() == false)
277 signal?.Disconnect(interceptTouchDataCallback);
278 interceptTouchDataCallback = null;
285 /// If child view doesn't want the parent's view to intercept the touch, you can set it to true.
287 /// parent.Add(child);
288 /// parent.InterceptTouchEvent += OnInterceptTouchEvent;
289 /// View view = child.GetParent() as View;
290 /// view.DisallowInterceptTouchEvent = true;
291 /// This prevents the parent from intercepting touch.
293 [EditorBrowsable(EditorBrowsableState.Never)]
294 public bool DisallowInterceptTouchEvent { get; set; }
298 /// An event for the touched signal which can be used to subscribe or unsubscribe the event handler provided by the user.<br />
299 /// The touched signal is emitted when the touch input is received.<br />
301 /// <since_tizen> 3 </since_tizen>
302 public event EventHandlerWithReturnType<object, TouchEventArgs, bool> TouchEvent
306 if (touchDataEventHandler == null)
308 touchDataCallback = OnTouch;
309 using TouchDataSignal signal = new TouchDataSignal(Interop.ActorSignal.ActorTouchSignal(SwigCPtr), false);
310 signal.Connect(touchDataCallback);
312 touchDataEventHandler += value;
317 touchDataEventHandler -= value;
318 if (touchDataEventHandler == null)
320 using TouchDataSignal signal = new TouchDataSignal(Interop.ActorSignal.ActorTouchSignal(SwigCPtr), false);
321 if (signal.Empty() == false)
323 signal.Disconnect(touchDataCallback);
324 touchDataCallback = null;
331 /// An event for the hovered signal which can be used to subscribe or unsubscribe the event handler provided by the user.<br />
332 /// The hovered signal is emitted when the hover input is received.<br />
334 /// <since_tizen> 3 </since_tizen>
335 public event EventHandlerWithReturnType<object, HoverEventArgs, bool> HoverEvent
339 if (hoverEventHandler == null)
341 hoverEventCallback = OnHoverEvent;
342 using HoverSignal signal = new HoverSignal(Interop.ActorSignal.ActorHoveredSignal(SwigCPtr), false);
343 signal?.Connect(hoverEventCallback);
345 hoverEventHandler += value;
350 hoverEventHandler -= value;
351 if (hoverEventHandler == null)
353 using HoverSignal signal = new HoverSignal(Interop.ActorSignal.ActorHoveredSignal(SwigCPtr), false);
354 if (signal?.Empty() == false)
356 signal?.Disconnect(hoverEventCallback);
357 hoverEventCallback = null;
364 /// An event for the WheelMoved signal which can be used to subscribe or unsubscribe the event handler provided by the user.<br />
365 /// The WheelMoved signal is emitted when the wheel event is received.<br />
367 /// <since_tizen> 3 </since_tizen>
368 public event EventHandlerWithReturnType<object, WheelEventArgs, bool> WheelEvent
372 if (wheelEventHandler == null)
374 wheelEventCallback = OnWheelEvent;
375 using WheelSignal signal = new WheelSignal(Interop.ActorSignal.ActorWheelEventSignal(SwigCPtr), false);
376 signal?.Connect(wheelEventCallback);
378 wheelEventHandler += value;
380 if (WindowWheelEventHandler == null)
382 NUIApplication.GetDefaultWindow().WheelEvent += OnWindowWheelEvent;
384 WindowWheelEventHandler += value;
389 wheelEventHandler -= value;
390 if (wheelEventHandler == null)
392 using WheelSignal signal = new WheelSignal(Interop.ActorSignal.ActorWheelEventSignal(SwigCPtr), false);
393 if (signal?.Empty() == false)
395 signal?.Disconnect(wheelEventCallback);
396 wheelEventCallback = null;
400 WindowWheelEventHandler -= value;
401 if (WindowWheelEventHandler == null)
403 NUIApplication.GetDefaultWindow().WheelEvent -= OnWindowWheelEvent;
409 /// An event for the OnWindow signal which can be used to subscribe or unsubscribe the event handler.<br />
410 /// The OnWindow signal is emitted after the view has been connected to the window.<br />
412 /// <since_tizen> 3 </since_tizen>
413 public event EventHandler AddedToWindow
417 if (onWindowEventHandler == null)
419 onWindowEventCallback = OnWindow;
420 using ViewSignal signal = new ViewSignal(Interop.ActorSignal.ActorOnSceneSignal(SwigCPtr), false);
421 signal?.Connect(onWindowEventCallback);
423 onWindowEventHandler += value;
428 onWindowEventHandler -= value;
429 if (onWindowEventHandler == null)
431 using ViewSignal signal = new ViewSignal(Interop.ActorSignal.ActorOnSceneSignal(SwigCPtr), false);
432 if (signal?.Empty() == false)
434 signal?.Disconnect(onWindowEventCallback);
435 onWindowEventCallback = null;
442 /// An event for the OffWindow signal, which can be used to subscribe or unsubscribe the event handler.<br />
443 /// OffWindow signal is emitted after the view has been disconnected from the window.<br />
445 /// <since_tizen> 3 </since_tizen>
446 public event EventHandler RemovedFromWindow
450 if (offWindowEventHandler == null)
452 offWindowEventCallback = OffWindow;
453 using ViewSignal signal = new ViewSignal(Interop.ActorSignal.ActorOffSceneSignal(SwigCPtr), false);
454 signal?.Connect(offWindowEventCallback);
456 offWindowEventHandler += value;
461 offWindowEventHandler -= value;
462 if (offWindowEventHandler == null)
464 using ViewSignal signal = new ViewSignal(Interop.ActorSignal.ActorOffSceneSignal(SwigCPtr), false);
465 if (signal?.Empty() == false)
467 signal?.Disconnect(offWindowEventCallback);
468 offWindowEventCallback = null;
475 /// An event for visibility change which can be used to subscribe or unsubscribe the event handler.<br />
476 /// This signal is emitted when the visible property of this or a parent view is changed.<br />
478 /// <since_tizen> 3 </since_tizen>
479 public event EventHandler<VisibilityChangedEventArgs> VisibilityChanged
483 if (visibilityChangedEventHandler == null)
485 visibilityChangedEventCallback = OnVisibilityChanged;
486 VisibilityChangedSignal(this).Connect(visibilityChangedEventCallback);
489 visibilityChangedEventHandler += value;
494 visibilityChangedEventHandler -= value;
496 if (visibilityChangedEventHandler == null && VisibilityChangedSignal(this).Empty() == false)
498 VisibilityChangedSignal(this).Disconnect(visibilityChangedEventCallback);
504 /// Event for layout direction change which can be used to subscribe/unsubscribe the event handler.<br />
505 /// This signal is emitted when the layout direction property of this or a parent view is changed.<br />
507 /// <since_tizen> 4 </since_tizen>
508 public event EventHandler<LayoutDirectionChangedEventArgs> LayoutDirectionChanged
512 if (layoutDirectionChangedEventHandler == null)
514 layoutDirectionChangedEventCallback = OnLayoutDirectionChanged;
515 LayoutDirectionChangedSignal(this).Connect(layoutDirectionChangedEventCallback);
518 layoutDirectionChangedEventHandler += value;
523 layoutDirectionChangedEventHandler -= value;
525 if (layoutDirectionChangedEventHandler == null && LayoutDirectionChangedSignal(this).Empty() == false)
527 LayoutDirectionChangedSignal(this).Disconnect(layoutDirectionChangedEventCallback);
533 /// An event for the ResourcesLoadedSignal signal which can be used to subscribe or unsubscribe the event handler provided by the user.<br />
534 /// This signal is emitted after all resources required by a view are loaded and ready.<br />
536 /// <since_tizen> 3 </since_tizen>
537 public event EventHandler ResourcesLoaded
541 if (resourcesLoadedEventHandler == null)
543 ResourcesLoadedCallback = OnResourcesLoaded;
544 using ViewSignal signal = new ViewSignal(Interop.View.ResourceReadySignal(SwigCPtr), false);
545 signal?.Connect(ResourcesLoadedCallback);
547 resourcesLoadedEventHandler += value;
552 resourcesLoadedEventHandler -= value;
553 if (resourcesLoadedEventHandler == null)
555 using ViewSignal signal = new ViewSignal(Interop.View.ResourceReadySignal(SwigCPtr), false);
556 if (signal?.Empty() == false)
558 signal?.Disconnect(ResourcesLoadedCallback);
559 ResourcesLoadedCallback = null;
565 private EventHandler _backKeyPressed;
568 /// An event for getting notice when physical back key is pressed.<br />
569 /// This event is emitted BackKey is up.<br />
571 [EditorBrowsable(EditorBrowsableState.Never)]
572 public event EventHandler BackKeyPressed
576 _backKeyPressed += value;
577 BackKeyManager.Instance.Subscriber.Add(this);
582 BackKeyManager.Instance.Subscriber.Remove(this);
583 _backKeyPressed -= value;
588 /// Function for emitting BackKeyPressed event outside of View instance
590 [EditorBrowsable(EditorBrowsableState.Never)]
591 internal void EmitBackKeyPressed()
593 _backKeyPressed.Invoke(this, null);
597 internal event EventHandler<BackgroundResourceLoadedEventArgs> BackgroundResourceLoaded
601 if (backgroundResourceLoadedEventHandler == null)
603 backgroundResourceLoadedCallback = OnBackgroundResourceLoaded;
604 using ViewSignal signal = new ViewSignal(Interop.View.ResourceReadySignal(SwigCPtr), false);
605 signal?.Connect(backgroundResourceLoadedCallback);
607 backgroundResourceLoadedEventHandler += value;
612 backgroundResourceLoadedEventHandler -= value;
613 if (backgroundResourceLoadedEventHandler == null)
615 using ViewSignal signal = new ViewSignal(Interop.View.ResourceReadySignal(SwigCPtr), false);
616 if (signal?.Empty() == false)
618 signal?.Disconnect(backgroundResourceLoadedCallback);
619 backgroundResourceLoadedCallback = null;
625 internal TouchDataSignal InterceptTouchSignal()
627 TouchDataSignal ret = new TouchDataSignal(Interop.ActorSignal.ActorInterceptTouchSignal(SwigCPtr), false);
628 if (NDalicPINVOKE.SWIGPendingException.Pending)
629 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
633 internal TouchDataSignal TouchSignal()
635 TouchDataSignal ret = new TouchDataSignal(Interop.ActorSignal.ActorTouchSignal(SwigCPtr), false);
636 if (NDalicPINVOKE.SWIGPendingException.Pending)
637 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
641 internal HoverSignal HoveredSignal()
643 HoverSignal ret = new HoverSignal(Interop.ActorSignal.ActorHoveredSignal(SwigCPtr), false);
644 if (NDalicPINVOKE.SWIGPendingException.Pending)
645 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
649 internal WheelSignal WheelEventSignal()
651 WheelSignal ret = new WheelSignal(Interop.ActorSignal.ActorWheelEventSignal(SwigCPtr), false);
652 if (NDalicPINVOKE.SWIGPendingException.Pending)
653 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
657 internal ViewSignal OnWindowSignal()
659 ViewSignal ret = new ViewSignal(Interop.ActorSignal.ActorOnSceneSignal(SwigCPtr), false);
660 if (NDalicPINVOKE.SWIGPendingException.Pending)
661 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
665 internal ViewSignal OffWindowSignal()
667 ViewSignal ret = new ViewSignal(Interop.ActorSignal.ActorOffSceneSignal(SwigCPtr), false);
668 if (NDalicPINVOKE.SWIGPendingException.Pending)
669 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
673 internal ViewSignal OnRelayoutSignal()
675 ViewSignal ret = new ViewSignal(Interop.ActorSignal.ActorOnRelayoutSignal(SwigCPtr), false);
676 if (NDalicPINVOKE.SWIGPendingException.Pending)
677 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
681 internal ViewVisibilityChangedSignal VisibilityChangedSignal(View view)
683 ViewVisibilityChangedSignal ret = new ViewVisibilityChangedSignal(Interop.NDalic.VisibilityChangedSignal(View.getCPtr(view)), false);
684 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
688 internal ViewLayoutDirectionChangedSignal LayoutDirectionChangedSignal(View view)
690 ViewLayoutDirectionChangedSignal ret = new ViewLayoutDirectionChangedSignal(Interop.Layout.LayoutDirectionChangedSignal(View.getCPtr(view)), false);
691 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
695 internal ViewSignal ResourcesLoadedSignal()
697 ViewSignal ret = new ViewSignal(Interop.View.ResourceReadySignal(SwigCPtr), false);
698 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
702 internal ControlKeySignal KeyEventSignal()
704 ControlKeySignal ret = new ControlKeySignal(Interop.ViewSignal.KeyEventSignal(SwigCPtr), false);
705 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
709 internal KeyInputFocusSignal KeyInputFocusGainedSignal()
711 KeyInputFocusSignal ret = new KeyInputFocusSignal(Interop.ViewSignal.KeyInputFocusGainedSignal(SwigCPtr), false);
712 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
716 internal KeyInputFocusSignal KeyInputFocusLostSignal()
718 KeyInputFocusSignal ret = new KeyInputFocusSignal(Interop.ViewSignal.KeyInputFocusLostSignal(SwigCPtr), false);
719 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
723 private void OnSize2DChanged(int? width, int? height)
728 temp = new Tizen.NUI.PropertyValue((float)width);
729 Tizen.NUI.Object.SetProperty(this.SwigCPtr, View.Property.SizeWidth, temp);
734 temp = new Tizen.NUI.PropertyValue((float)height);
735 Tizen.NUI.Object.SetProperty(this.SwigCPtr, View.Property.SizeHeight, temp);
740 private void OnMinimumSizeChanged(int? width, int? height)
742 if (width != null && height != null)
744 MinimumSize = new Size2D((int)width, (int)height);
746 else if (width != null && height == null)
748 MinimumSize = new Size2D((int)width, (int)this.GetMinimumSize().Height);
750 else if (width == null && height != null)
752 MinimumSize = new Size2D((int)this.GetMinimumSize().Width, (int)height);
756 //both are null, do nothing.
760 private void OnMaximumSizeChanged(int? width, int? height)
762 if (width != null && height != null)
764 MaximumSize = new Size2D((int)width, (int)height);
766 else if (width != null && height == null)
768 MaximumSize = new Size2D((int)width, (int)this.GetMaximumSize().Height);
770 else if (width == null && height != null)
772 MaximumSize = new Size2D((int)this.GetMaximumSize().Width, (int)height);
776 //both are null, do nothing.
780 private void OnPosition2DChanged(int x, int y)
782 Position2D = new Position2D(x, y);
785 private void OnSizeChanged(float? width, float? height, float? depth)
790 temp = new Tizen.NUI.PropertyValue((float)width);
791 Tizen.NUI.Object.SetProperty(this.SwigCPtr, View.Property.SizeWidth, temp);
796 temp = new Tizen.NUI.PropertyValue((float)height);
797 Tizen.NUI.Object.SetProperty(this.SwigCPtr, View.Property.SizeHeight, temp);
802 temp = new Tizen.NUI.PropertyValue((float)depth);
803 Tizen.NUI.Object.SetProperty(this.SwigCPtr, View.Property.SizeDepth, temp);
808 private void OnPositionChanged(float x, float y, float z)
810 Position = new Position(x, y, z);
813 private void OnParentOriginChanged(float x, float y, float z)
815 ParentOrigin = new Position(x, y, z);
818 private void OnPivotPointChanged(float x, float y, float z)
820 PivotPoint = new Position(x, y, z);
823 private void OnImageShadowChanged(ShadowBase instance)
825 ImageShadow = (ImageShadow)instance;
828 private void OnBoxShadowChanged(ShadowBase instance)
830 BoxShadow = (Shadow)instance;
833 private void OnBackgroundImageBorderChanged(int left, int right, int bottom, int top)
835 BackgroundImageBorder = new Rectangle(left, right, bottom, top);
838 private void OnKeyInputFocusGained(IntPtr view)
840 if (IsNativeHandleInvalid())
844 if (keyInputFocusGainedEventHandler != null)
846 var process = global::System.Diagnostics.Process.GetCurrentProcess().Id;
847 var thread = global::System.Threading.Thread.CurrentThread.ManagedThreadId;
848 var me = this.GetType().FullName;
850 throw new ObjectDisposedException(nameof(SwigCPtr), $"Error! NUI's native dali object is already disposed. " +
851 $"OR the native dali object handle of NUI becomes null! \n" +
852 $" process:{process} thread:{thread}, isDisposed:{this.Disposed}, isDisposeQueued:{this.IsDisposeQueued}, me:{me}\n");
857 if (this.IsDisposeQueued)
859 var process = global::System.Diagnostics.Process.GetCurrentProcess().Id;
860 var thread = global::System.Threading.Thread.CurrentThread.ManagedThreadId;
861 var me = this.GetType().FullName;
863 //in this case, the View object is ready to be disposed waiting on DisposeQueue, so event callback should not be invoked!
864 Tizen.Log.Error("NUI", "in this case, the View object is ready to be disposed waiting on DisposeQueue, so event callback should not be invoked! just return here! \n" +
865 $"process:{process} thread:{thread}, isDisposed:{this.Disposed}, isDisposeQueued:{this.IsDisposeQueued}, me:{me}\n");
871 keyInputFocusGainedEventHandler?.Invoke(this, null);
874 private void OnKeyInputFocusLost(IntPtr view)
876 if (IsNativeHandleInvalid())
880 if (keyInputFocusLostEventHandler != null)
882 var process = global::System.Diagnostics.Process.GetCurrentProcess().Id;
883 var thread = global::System.Threading.Thread.CurrentThread.ManagedThreadId;
884 var me = this.GetType().FullName;
886 throw new ObjectDisposedException(nameof(SwigCPtr), $"Error! NUI's native dali object is already disposed. " +
887 $"OR the native dali object handle of NUI becomes null! \n" +
888 $" process:{process} thread:{thread}, isDisposed:{this.Disposed}, isDisposeQueued:{this.IsDisposeQueued}, me:{me}\n");
893 if (this.IsDisposeQueued)
895 var process = global::System.Diagnostics.Process.GetCurrentProcess().Id;
896 var thread = global::System.Threading.Thread.CurrentThread.ManagedThreadId;
897 var me = this.GetType().FullName;
899 //in this case, the View object is ready to be disposed waiting on DisposeQueue, so event callback should not be invoked!
900 Tizen.Log.Error("NUI", "in this case, the View object is ready to be disposed waiting on DisposeQueue, so event callback should not be invoked! just return here! \n" +
901 $"process:{process} thread:{thread}, isDisposed:{this.Disposed}, isDisposeQueued:{this.IsDisposeQueued}, me:{me}\n");
907 keyInputFocusLostEventHandler?.Invoke(this, null);
910 private bool OnKeyEvent(IntPtr view, IntPtr keyEvent)
912 if (keyEvent == global::System.IntPtr.Zero)
914 NUILog.Error("keyEvent should not be null!");
918 KeyEventArgs e = new KeyEventArgs();
922 e.Key = Tizen.NUI.Key.GetKeyFromPtr(keyEvent);
924 if (keyEventHandler != null)
926 Delegate[] delegateList = keyEventHandler.GetInvocationList();
928 // Oring the result of each callback.
929 foreach (EventHandlerWithReturnType<object, KeyEventArgs, bool> del in delegateList)
931 result |= del(this, e);
938 // Callback for View OnRelayout signal
939 private void OnRelayout(IntPtr data)
941 if (onRelayoutEventHandler != null)
943 onRelayoutEventHandler(this, null);
947 // Callback for View TouchSignal
948 private bool OnInterceptTouch(IntPtr view, IntPtr touchData)
950 if (touchData == global::System.IntPtr.Zero)
952 NUILog.Error("touchData should not be null!");
956 // DisallowInterceptTouchEvent prevents the parent from intercepting touch.
957 if (DisallowInterceptTouchEvent)
962 TouchEventArgs e = new TouchEventArgs();
964 e.Touch = Tizen.NUI.Touch.GetTouchFromPtr(touchData);
966 bool consumed = false;
968 if (interceptTouchDataEventHandler != null)
970 consumed = interceptTouchDataEventHandler(this, e);
976 // Callback for View TouchSignal
977 private bool OnTouch(IntPtr view, IntPtr touchData)
979 if (touchData == global::System.IntPtr.Zero)
981 NUILog.Error("touchData should not be null!");
985 TouchEventArgs e = new TouchEventArgs();
987 e.Touch = Tizen.NUI.Touch.GetTouchFromPtr(touchData);
989 bool consumed = false;
991 if (touchDataEventHandler != null)
993 consumed = touchDataEventHandler(this, e);
996 if (enableControlState && !consumed)
998 consumed = HandleControlStateOnTouch(e.Touch);
1004 // Callback for View Hover signal
1005 private bool OnHoverEvent(IntPtr view, IntPtr hoverEvent)
1007 if (hoverEvent == global::System.IntPtr.Zero)
1009 NUILog.Error("hoverEvent should not be null!");
1013 HoverEventArgs e = new HoverEventArgs();
1015 e.Hover = Tizen.NUI.Hover.GetHoverFromPtr(hoverEvent);
1017 if (hoverEventHandler != null)
1019 return hoverEventHandler(this, e);
1024 // Callback for View Wheel signal
1025 private bool OnWheelEvent(IntPtr view, IntPtr wheelEvent)
1027 if (wheelEvent == global::System.IntPtr.Zero)
1029 NUILog.Error("wheelEvent should not be null!");
1033 WheelEventArgs e = new WheelEventArgs();
1035 e.Wheel = Tizen.NUI.Wheel.GetWheelFromPtr(wheelEvent);
1037 if (wheelEventHandler != null)
1039 return wheelEventHandler(this, e);
1044 // Callback for View OnWindow signal
1045 private void OnWindow(IntPtr data)
1047 if (onWindowEventHandler != null)
1049 onWindowEventHandler(this, null);
1053 // Callback for View OffWindow signal
1054 private void OffWindow(IntPtr data)
1056 if (offWindowEventHandler != null)
1058 offWindowEventHandler(this, null);
1062 // Callback for View visibility change signal
1063 private void OnVisibilityChanged(IntPtr data, bool visibility, VisibilityChangeType type)
1065 VisibilityChangedEventArgs e = new VisibilityChangedEventArgs();
1068 e.View = Registry.GetManagedBaseHandleFromNativePtr(data) as View;
1070 e.Visibility = visibility;
1073 if (visibilityChangedEventHandler != null)
1075 visibilityChangedEventHandler(this, e);
1079 // Callback for View layout direction change signal
1080 private void OnLayoutDirectionChanged(IntPtr data, ViewLayoutDirectionType type)
1082 LayoutDirectionChangedEventArgs e = new LayoutDirectionChangedEventArgs();
1085 e.View = Registry.GetManagedBaseHandleFromNativePtr(data) as View;
1089 if (layoutDirectionChangedEventHandler != null)
1091 layoutDirectionChangedEventHandler(this, e);
1095 private void OnResourcesLoaded(IntPtr view)
1097 if (resourcesLoadedEventHandler != null)
1099 resourcesLoadedEventHandler(this, null);
1103 private void OnBackgroundResourceLoaded(IntPtr view)
1105 BackgroundResourceLoadedEventArgs e = new BackgroundResourceLoadedEventArgs();
1106 e.Status = (ResourceLoadingStatusType)Interop.View.GetVisualResourceStatus(this.SwigCPtr, Property.BACKGROUND);
1108 if (backgroundResourceLoadedEventHandler != null)
1110 backgroundResourceLoadedEventHandler(this, e);
1115 /// Event argument passed through the ChildAdded event.
1117 /// <since_tizen> 5 </since_tizen>
1118 public class ChildAddedEventArgs : EventArgs
1121 /// Added child view at moment.
1123 /// <since_tizen> 5 </since_tizen>
1124 public View Added { get; set; }
1128 /// Event argument passed through the ChildRemoved event.
1130 /// <since_tizen> 5 </since_tizen>
1131 public class ChildRemovedEventArgs : EventArgs
1134 /// Removed child view at moment.
1136 /// <since_tizen> 5 </since_tizen>
1137 public View Removed { get; set; }
1141 /// Event arguments that passed via the KeyEvent signal.
1143 /// <since_tizen> 3 </since_tizen>
1144 public class KeyEventArgs : EventArgs
1149 /// Key - is the key sent to the view.
1151 /// <since_tizen> 3 </since_tizen>
1166 /// Event arguments that passed via the touch signal.
1168 /// <since_tizen> 3 </since_tizen>
1169 public class TouchEventArgs : EventArgs
1171 private Touch _touch;
1174 /// Touch - contains the information of touch points.
1176 /// <since_tizen> 3 </since_tizen>
1191 /// Event arguments that passed via the hover signal.
1193 /// <since_tizen> 3 </since_tizen>
1194 public class HoverEventArgs : EventArgs
1196 private Hover _hover;
1199 /// Hover - contains touch points that represent the points that are currently being hovered or the points where a hover has stopped.
1201 /// <since_tizen> 3 </since_tizen>
1216 /// Event arguments that passed via the wheel signal.
1218 /// <since_tizen> 3 </since_tizen>
1219 public class WheelEventArgs : EventArgs
1221 private Wheel _wheel;
1224 /// WheelEvent - store a wheel rolling type: MOUSE_WHEEL or CUSTOM_WHEEL.
1226 /// <since_tizen> 3 </since_tizen>
1241 /// Event arguments of visibility changed.
1243 /// <since_tizen> 3 </since_tizen>
1244 public class VisibilityChangedEventArgs : EventArgs
1247 private bool _visibility;
1248 private VisibilityChangeType _type;
1251 /// The view, or child of view, whose visibility has changed.
1253 /// <since_tizen> 3 </since_tizen>
1267 /// Whether the view is now visible or not.
1269 /// <since_tizen> 3 </since_tizen>
1270 public bool Visibility
1278 _visibility = value;
1283 /// Whether the view's visible property has changed or a parent's.
1285 /// <since_tizen> 3 </since_tizen>
1286 public VisibilityChangeType Type
1300 /// Event arguments of layout direction changed.
1302 /// <since_tizen> 4 </since_tizen>
1303 public class LayoutDirectionChangedEventArgs : EventArgs
1306 private ViewLayoutDirectionType _type;
1309 /// The view, or child of view, whose layout direction has changed.
1311 /// <since_tizen> 4 </since_tizen>
1325 /// Whether the view's layout direction property has changed or a parent's.
1327 /// <since_tizen> 4 </since_tizen>
1328 public ViewLayoutDirectionType Type
1341 internal class BackgroundResourceLoadedEventArgs : EventArgs
1343 private ResourceLoadingStatusType status = ResourceLoadingStatusType.Invalid;
1344 public ResourceLoadingStatusType Status
1358 /// The class represents the information of the situation where the View's control state changes.
1360 [EditorBrowsable(EditorBrowsableState.Never)]
1361 public class ControlStateChangedEventArgs : EventArgs
1364 /// Create an instance with mandatory fields.
1366 /// <param name="previousState">The previous control state.</param>
1367 /// <param name="currentState">The current control state.</param>
1368 [EditorBrowsable(EditorBrowsableState.Never)]
1369 public ControlStateChangedEventArgs(ControlState previousState, ControlState currentState)
1371 PreviousState = previousState;
1372 CurrentState = currentState;
1376 /// The previous control state.
1378 [EditorBrowsable(EditorBrowsableState.Never)]
1379 public ControlState PreviousState { get; }
1382 /// The current control state.
1384 [EditorBrowsable(EditorBrowsableState.Never)]
1385 public ControlState CurrentState { get; }
1388 private EventHandlerWithReturnType<object, WheelEventArgs, bool> WindowWheelEventHandler;
1389 private void OnWindowWheelEvent(object sender, Window.WheelEventArgs e)
1393 if (e.Wheel.Type == Wheel.WheelType.CustomWheel)
1395 var arg = new WheelEventArgs()
1399 WindowWheelEventHandler?.Invoke(this, arg);
1405 /// The expanded touch area.
1406 /// TouchArea can expand the view's touchable area.<br/>
1407 /// 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/>
1410 /// This is based on the top left x, y coordinates.<br/>
1411 /// For example) <br/>
1413 /// view.Size = new Size(100, 100);
1414 /// view.TouchAreaOffset = new Offset(-10, 20, 30, -40); // left, right, bottom, top
1416 /// Then, touch area is 130x170.<br/>
1417 /// This is view.width + TouchAreaOffset.right - TouchAreaOffset.left and view.height + TouchAreaOffset.bottom - TouchAreaOffset.top <br/>
1418 /// +---------------------+ <br/>
1424 /// | +----+----+ | <br/>
1426 /// | -10| | 20 | <br/>
1427 /// |<---+ +----->| <br/>
1430 /// | +----+----+ | <br/>
1435 /// +---------------------+ <br/>
1437 [EditorBrowsable(EditorBrowsableState.Never)]
1438 public Offset TouchAreaOffset
1442 Interop.ActorInternal.GetTouchAreaOffset(SwigCPtr, out int left, out int right, out int bottom, out int top);
1443 if (NDalicPINVOKE.SWIGPendingException.Pending)
1444 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1445 return new Offset(left, right, bottom, top);
1449 Interop.ActorInternal.SetTouchAreaOffset(SwigCPtr, value.Left, value.Right, value.Bottom, value.Top);
1450 if (NDalicPINVOKE.SWIGPendingException.Pending)
1451 throw NDalicPINVOKE.SWIGPendingException.Retrieve();