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 OnColorChanged(float r, float g, float b, float a)
725 Color = new Color(r, g, b, a);
728 private void OnMinimumSizeChanged(int width, int height)
730 MinimumSize = new Size2D(width, height);
733 private void OnMaximumSizeChanged(int width, int height)
735 MaximumSize = new Size2D(width, height);
738 private void OnPosition2DChanged(int x, int y)
740 SetPosition((float)x, (float)y, 0);
743 private void OnPositionChanged(float x, float y, float z)
745 SetPosition(x, y, z);
748 private void OnSize2DChanged(int width, int height)
750 SetSize((float)width, (float)height, 0);
753 private void OnSizeChanged(float width, float height, float depth)
755 SetSize(width, height, depth);
758 private void OnParentOriginChanged(float x, float y, float z)
760 ParentOrigin = new Position(x, y, z);
763 private void OnPivotPointChanged(float x, float y, float z)
765 PivotPoint = new Position(x, y, z);
768 private void OnImageShadowChanged(ShadowBase instance)
770 ImageShadow = (ImageShadow)instance;
773 private void OnBoxShadowChanged(ShadowBase instance)
775 BoxShadow = (Shadow)instance;
778 private void OnBackgroundImageBorderChanged(int left, int right, int bottom, int top)
780 BackgroundImageBorder = new Rectangle(left, right, bottom, top);
783 private void OnKeyInputFocusGained(IntPtr view)
785 if (IsNativeHandleInvalid())
789 if (keyInputFocusGainedEventHandler != null)
791 var process = global::System.Diagnostics.Process.GetCurrentProcess().Id;
792 var thread = global::System.Threading.Thread.CurrentThread.ManagedThreadId;
793 var me = this.GetType().FullName;
795 throw new ObjectDisposedException(nameof(SwigCPtr), $"Error! NUI's native dali object is already disposed. " +
796 $"OR the native dali object handle of NUI becomes null! \n" +
797 $" process:{process} thread:{thread}, isDisposed:{this.Disposed}, isDisposeQueued:{this.IsDisposeQueued}, me:{me}\n");
802 if (this.IsDisposeQueued)
804 var process = global::System.Diagnostics.Process.GetCurrentProcess().Id;
805 var thread = global::System.Threading.Thread.CurrentThread.ManagedThreadId;
806 var me = this.GetType().FullName;
808 //in this case, the View object is ready to be disposed waiting on DisposeQueue, so event callback should not be invoked!
809 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" +
810 $"process:{process} thread:{thread}, isDisposed:{this.Disposed}, isDisposeQueued:{this.IsDisposeQueued}, me:{me}\n");
816 keyInputFocusGainedEventHandler?.Invoke(this, null);
819 private void OnKeyInputFocusLost(IntPtr view)
821 if (IsNativeHandleInvalid())
825 if (keyInputFocusLostEventHandler != null)
827 var process = global::System.Diagnostics.Process.GetCurrentProcess().Id;
828 var thread = global::System.Threading.Thread.CurrentThread.ManagedThreadId;
829 var me = this.GetType().FullName;
831 throw new ObjectDisposedException(nameof(SwigCPtr), $"Error! NUI's native dali object is already disposed. " +
832 $"OR the native dali object handle of NUI becomes null! \n" +
833 $" process:{process} thread:{thread}, isDisposed:{this.Disposed}, isDisposeQueued:{this.IsDisposeQueued}, me:{me}\n");
838 if (this.IsDisposeQueued)
840 var process = global::System.Diagnostics.Process.GetCurrentProcess().Id;
841 var thread = global::System.Threading.Thread.CurrentThread.ManagedThreadId;
842 var me = this.GetType().FullName;
844 //in this case, the View object is ready to be disposed waiting on DisposeQueue, so event callback should not be invoked!
845 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" +
846 $"process:{process} thread:{thread}, isDisposed:{this.Disposed}, isDisposeQueued:{this.IsDisposeQueued}, me:{me}\n");
852 keyInputFocusLostEventHandler?.Invoke(this, null);
855 private bool OnKeyEvent(IntPtr view, IntPtr keyEvent)
857 if (keyEvent == global::System.IntPtr.Zero)
859 NUILog.Error("keyEvent should not be null!");
863 KeyEventArgs e = new KeyEventArgs();
867 e.Key = Tizen.NUI.Key.GetKeyFromPtr(keyEvent);
869 if (keyEventHandler != null)
871 Delegate[] delegateList = keyEventHandler.GetInvocationList();
873 // Oring the result of each callback.
874 foreach (EventHandlerWithReturnType<object, KeyEventArgs, bool> del in delegateList)
876 result |= del(this, e);
883 // Callback for View OnRelayout signal
884 private void OnRelayout(IntPtr data)
886 if (onRelayoutEventHandler != null)
888 onRelayoutEventHandler(this, null);
892 // Callback for View TouchSignal
893 private bool OnInterceptTouch(IntPtr view, IntPtr touchData)
895 if (touchData == global::System.IntPtr.Zero)
897 NUILog.Error("touchData should not be null!");
901 // DisallowInterceptTouchEvent prevents the parent from intercepting touch.
902 if (DisallowInterceptTouchEvent)
907 TouchEventArgs e = new TouchEventArgs();
909 e.Touch = Tizen.NUI.Touch.GetTouchFromPtr(touchData);
911 bool consumed = false;
913 if (interceptTouchDataEventHandler != null)
915 consumed = interceptTouchDataEventHandler(this, e);
921 // Callback for View TouchSignal
922 private bool OnTouch(IntPtr view, IntPtr touchData)
924 if (touchData == global::System.IntPtr.Zero)
926 NUILog.Error("touchData should not be null!");
930 TouchEventArgs e = new TouchEventArgs();
932 e.Touch = Tizen.NUI.Touch.GetTouchFromPtr(touchData);
934 bool consumed = false;
936 if (touchDataEventHandler != null)
938 consumed = touchDataEventHandler(this, e);
941 if (enableControlState && !consumed)
943 consumed = HandleControlStateOnTouch(e.Touch);
949 // Callback for View Hover signal
950 private bool OnHoverEvent(IntPtr view, IntPtr hoverEvent)
952 if (hoverEvent == global::System.IntPtr.Zero)
954 NUILog.Error("hoverEvent should not be null!");
958 HoverEventArgs e = new HoverEventArgs();
960 e.Hover = Tizen.NUI.Hover.GetHoverFromPtr(hoverEvent);
962 if (hoverEventHandler != null)
964 return hoverEventHandler(this, e);
969 // Callback for View Wheel signal
970 private bool OnWheelEvent(IntPtr view, IntPtr wheelEvent)
972 if (wheelEvent == global::System.IntPtr.Zero)
974 NUILog.Error("wheelEvent should not be null!");
978 WheelEventArgs e = new WheelEventArgs();
980 e.Wheel = Tizen.NUI.Wheel.GetWheelFromPtr(wheelEvent);
982 if (wheelEventHandler != null)
984 return wheelEventHandler(this, e);
989 // Callback for View OnWindow signal
990 private void OnWindow(IntPtr data)
992 if (onWindowEventHandler != null)
994 onWindowEventHandler(this, null);
998 // Callback for View OffWindow signal
999 private void OffWindow(IntPtr data)
1001 if (offWindowEventHandler != null)
1003 offWindowEventHandler(this, null);
1007 // Callback for View visibility change signal
1008 private void OnVisibilityChanged(IntPtr data, bool visibility, VisibilityChangeType type)
1010 VisibilityChangedEventArgs e = new VisibilityChangedEventArgs();
1013 e.View = Registry.GetManagedBaseHandleFromNativePtr(data) as View;
1015 e.Visibility = visibility;
1018 if (visibilityChangedEventHandler != null)
1020 visibilityChangedEventHandler(this, e);
1024 // Callback for View layout direction change signal
1025 private void OnLayoutDirectionChanged(IntPtr data, ViewLayoutDirectionType type)
1027 LayoutDirectionChangedEventArgs e = new LayoutDirectionChangedEventArgs();
1030 e.View = Registry.GetManagedBaseHandleFromNativePtr(data) as View;
1034 if (layoutDirectionChangedEventHandler != null)
1036 layoutDirectionChangedEventHandler(this, e);
1040 private void OnResourcesLoaded(IntPtr view)
1042 if (resourcesLoadedEventHandler != null)
1044 resourcesLoadedEventHandler(this, null);
1048 private void OnBackgroundResourceLoaded(IntPtr view)
1050 BackgroundResourceLoadedEventArgs e = new BackgroundResourceLoadedEventArgs();
1051 e.Status = (ResourceLoadingStatusType)Interop.View.GetVisualResourceStatus(this.SwigCPtr, Property.BACKGROUND);
1053 if (backgroundResourceLoadedEventHandler != null)
1055 backgroundResourceLoadedEventHandler(this, e);
1060 /// Event argument passed through the ChildAdded event.
1062 /// <since_tizen> 5 </since_tizen>
1063 public class ChildAddedEventArgs : EventArgs
1066 /// Added child view at moment.
1068 /// <since_tizen> 5 </since_tizen>
1069 public View Added { get; set; }
1073 /// Event argument passed through the ChildRemoved event.
1075 /// <since_tizen> 5 </since_tizen>
1076 public class ChildRemovedEventArgs : EventArgs
1079 /// Removed child view at moment.
1081 /// <since_tizen> 5 </since_tizen>
1082 public View Removed { get; set; }
1086 /// Event arguments that passed via the KeyEvent signal.
1088 /// <since_tizen> 3 </since_tizen>
1089 public class KeyEventArgs : EventArgs
1094 /// Key - is the key sent to the view.
1096 /// <since_tizen> 3 </since_tizen>
1111 /// Event arguments that passed via the touch signal.
1113 /// <since_tizen> 3 </since_tizen>
1114 public class TouchEventArgs : EventArgs
1116 private Touch _touch;
1119 /// Touch - contains the information of touch points.
1121 /// <since_tizen> 3 </since_tizen>
1136 /// Event arguments that passed via the hover signal.
1138 /// <since_tizen> 3 </since_tizen>
1139 public class HoverEventArgs : EventArgs
1141 private Hover _hover;
1144 /// Hover - contains touch points that represent the points that are currently being hovered or the points where a hover has stopped.
1146 /// <since_tizen> 3 </since_tizen>
1161 /// Event arguments that passed via the wheel signal.
1163 /// <since_tizen> 3 </since_tizen>
1164 public class WheelEventArgs : EventArgs
1166 private Wheel _wheel;
1169 /// WheelEvent - store a wheel rolling type: MOUSE_WHEEL or CUSTOM_WHEEL.
1171 /// <since_tizen> 3 </since_tizen>
1186 /// Event arguments of visibility changed.
1188 /// <since_tizen> 3 </since_tizen>
1189 public class VisibilityChangedEventArgs : EventArgs
1192 private bool _visibility;
1193 private VisibilityChangeType _type;
1196 /// The view, or child of view, whose visibility has changed.
1198 /// <since_tizen> 3 </since_tizen>
1212 /// Whether the view is now visible or not.
1214 /// <since_tizen> 3 </since_tizen>
1215 public bool Visibility
1223 _visibility = value;
1228 /// Whether the view's visible property has changed or a parent's.
1230 /// <since_tizen> 3 </since_tizen>
1231 public VisibilityChangeType Type
1245 /// Event arguments of layout direction changed.
1247 /// <since_tizen> 4 </since_tizen>
1248 public class LayoutDirectionChangedEventArgs : EventArgs
1251 private ViewLayoutDirectionType _type;
1254 /// The view, or child of view, whose layout direction has changed.
1256 /// <since_tizen> 4 </since_tizen>
1270 /// Whether the view's layout direction property has changed or a parent's.
1272 /// <since_tizen> 4 </since_tizen>
1273 public ViewLayoutDirectionType Type
1286 internal class BackgroundResourceLoadedEventArgs : EventArgs
1288 private ResourceLoadingStatusType status = ResourceLoadingStatusType.Invalid;
1289 public ResourceLoadingStatusType Status
1303 /// The class represents the information of the situation where the View's control state changes.
1305 [EditorBrowsable(EditorBrowsableState.Never)]
1306 public class ControlStateChangedEventArgs : EventArgs
1309 /// Create an instance with mandatory fields.
1311 /// <param name="previousState">The previous control state.</param>
1312 /// <param name="currentState">The current control state.</param>
1313 [EditorBrowsable(EditorBrowsableState.Never)]
1314 public ControlStateChangedEventArgs(ControlState previousState, ControlState currentState)
1316 PreviousState = previousState;
1317 CurrentState = currentState;
1321 /// The previous control state.
1323 [EditorBrowsable(EditorBrowsableState.Never)]
1324 public ControlState PreviousState { get; }
1327 /// The current control state.
1329 [EditorBrowsable(EditorBrowsableState.Never)]
1330 public ControlState CurrentState { get; }
1333 private EventHandlerWithReturnType<object, WheelEventArgs, bool> WindowWheelEventHandler;
1334 private void OnWindowWheelEvent(object sender, Window.WheelEventArgs e)
1338 if (e.Wheel.Type == Wheel.WheelType.CustomWheel)
1340 var arg = new WheelEventArgs()
1344 WindowWheelEventHandler?.Invoke(this, arg);
1350 /// The expanded touch area.
1351 /// TouchArea can expand the view's touchable area.<br/>
1352 /// 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/>
1355 /// This is based on the top left x, y coordinates.<br/>
1356 /// For example) <br/>
1358 /// view.Size = new Size(100, 100);
1359 /// view.TouchAreaOffset = new Offset(-10, 20, 30, -40); // left, right, bottom, top
1361 /// Then, touch area is 130x170.<br/>
1362 /// This is view.width + TouchAreaOffset.right - TouchAreaOffset.left and view.height + TouchAreaOffset.bottom - TouchAreaOffset.top <br/>
1363 /// +---------------------+ <br/>
1369 /// | +----+----+ | <br/>
1371 /// | -10| | 20 | <br/>
1372 /// |<---+ +----->| <br/>
1375 /// | +----+----+ | <br/>
1380 /// +---------------------+ <br/>
1382 [EditorBrowsable(EditorBrowsableState.Never)]
1383 public Offset TouchAreaOffset
1387 return (Offset)GetValue(TouchAreaOffsetProperty);
1391 SetValue(TouchAreaOffsetProperty, value);
1392 NotifyPropertyChanged();
1396 private Offset InternalTouchAreaOffset
1400 Interop.ActorInternal.GetTouchAreaOffset(SwigCPtr, out int left, out int right, out int bottom, out int top);
1401 if (NDalicPINVOKE.SWIGPendingException.Pending)
1402 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1403 return new Offset(left, right, bottom, top);
1407 Interop.ActorInternal.SetTouchAreaOffset(SwigCPtr, value.Left, value.Right, value.Bottom, value.Top);
1408 if (NDalicPINVOKE.SWIGPendingException.Pending)
1409 throw NDalicPINVOKE.SWIGPendingException.Retrieve();