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);
68 private TouchDataCallbackType hitTestResultDataCallback;
70 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
71 private delegate void OffWindowEventCallbackType(IntPtr control);
72 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
73 private delegate bool WheelEventCallbackType(IntPtr view, IntPtr wheelEvent);
74 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
75 private delegate bool KeyCallbackType(IntPtr control, IntPtr keyEvent);
76 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
77 private delegate bool TouchDataCallbackType(IntPtr view, IntPtr touchData);
78 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
79 private delegate bool HoverEventCallbackType(IntPtr view, IntPtr hoverEvent);
80 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
81 private delegate void VisibilityChangedEventCallbackType(IntPtr data, bool visibility, VisibilityChangeType type);
82 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
83 private delegate void ResourcesLoadedCallbackType(IntPtr control);
84 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
85 private delegate void _backgroundResourceLoadedCallbackType(IntPtr view);
87 [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
88 private delegate void KeyInputFocusGainedCallbackType(IntPtr control);
89 [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
90 private delegate void KeyInputFocusLostCallbackType(IntPtr control);
92 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
93 private delegate void OnRelayoutEventCallbackType(IntPtr control);
94 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
95 private delegate void OnWindowEventCallbackType(IntPtr control);
96 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
97 private delegate void LayoutDirectionChangedEventCallbackType(IntPtr data, ViewLayoutDirectionType type);
100 /// Event when a child is removed.
102 /// <since_tizen> 5 </since_tizen>
103 public new event EventHandler<ChildRemovedEventArgs> ChildRemoved;
105 /// Event when a child is added.
107 /// <since_tizen> 5 </since_tizen>
108 public new event EventHandler<ChildAddedEventArgs> ChildAdded;
111 /// An event for the KeyInputFocusGained signal which can be used to subscribe or unsubscribe the event handler provided by the user.<br />
112 /// The KeyInputFocusGained signal is emitted when the control gets the key input focus.<br />
114 /// <since_tizen> 3 </since_tizen>
115 public event EventHandler FocusGained
119 if (keyInputFocusGainedEventHandler == null)
121 keyInputFocusGainedCallback = OnKeyInputFocusGained;
122 using KeyInputFocusSignal signal = new KeyInputFocusSignal(Interop.ViewSignal.KeyInputFocusGainedSignal(SwigCPtr), false);
123 signal?.Connect(keyInputFocusGainedCallback);
125 keyInputFocusGainedEventHandler += value;
130 keyInputFocusGainedEventHandler -= value;
131 if (keyInputFocusGainedEventHandler == null)
133 using KeyInputFocusSignal signal = new KeyInputFocusSignal(Interop.ViewSignal.KeyInputFocusGainedSignal(SwigCPtr), false);
135 if (keyInputFocusGainedCallback != null)
137 signal?.Disconnect(keyInputFocusGainedCallback);
138 if (signal?.Empty() == true)
140 keyInputFocusGainedCallback = null;
148 /// An event for the KeyInputFocusLost signal which can be used to subscribe or unsubscribe the event handler provided by the user.<br />
149 /// The KeyInputFocusLost signal is emitted when the control loses the key input focus.<br />
151 /// <since_tizen> 3 </since_tizen>
152 public event EventHandler FocusLost
156 if (keyInputFocusLostEventHandler == null)
158 keyInputFocusLostCallback = OnKeyInputFocusLost;
159 using KeyInputFocusSignal signal = new KeyInputFocusSignal(Interop.ViewSignal.KeyInputFocusLostSignal(SwigCPtr), false);
160 signal?.Connect(keyInputFocusLostCallback);
162 keyInputFocusLostEventHandler += value;
167 keyInputFocusLostEventHandler -= value;
168 if (keyInputFocusLostEventHandler == null)
170 using KeyInputFocusSignal signal = new KeyInputFocusSignal(Interop.ViewSignal.KeyInputFocusLostSignal(SwigCPtr), false);
172 if (keyInputFocusLostCallback != null)
174 signal?.Disconnect(keyInputFocusLostCallback);
175 if (signal?.Empty() == true)
177 keyInputFocusLostCallback = null;
185 /// An event for the KeyPressed signal which can be used to subscribe or unsubscribe the event handler provided by the user.<br />
186 /// The KeyPressed signal is emitted when the key event is received.<br />
188 /// <since_tizen> 3 </since_tizen>
189 public event EventHandlerWithReturnType<object, KeyEventArgs, bool> KeyEvent
193 if (keyEventHandler == null)
195 keyCallback = OnKeyEvent;
196 using ControlKeySignal signal = new ControlKeySignal(Interop.ViewSignal.KeyEventSignal(SwigCPtr), false);
197 signal?.Connect(keyCallback);
199 keyEventHandler += value;
204 keyEventHandler -= value;
205 if (keyEventHandler == null)
207 using ControlKeySignal signal = new ControlKeySignal(Interop.ViewSignal.KeyEventSignal(SwigCPtr), false);
208 if (signal?.Empty() == false)
210 signal?.Disconnect(keyCallback);
211 if (signal?.Empty() == true)
221 /// An event for the OnRelayout signal which can be used to subscribe or unsubscribe the event handler.<br />
222 /// The OnRelayout signal is emitted after the size has been set on the view during relayout.<br />
224 /// <since_tizen> 3 </since_tizen>
225 public event EventHandler Relayout
229 if (onRelayoutEventHandler == null)
231 onRelayoutEventCallback = OnRelayout;
232 using ViewSignal signal = new ViewSignal(Interop.ActorSignal.ActorOnRelayoutSignal(SwigCPtr), false);
233 signal?.Connect(onRelayoutEventCallback);
235 onRelayoutEventHandler += value;
240 onRelayoutEventHandler -= value;
241 if (onRelayoutEventHandler == null)
243 using ViewSignal signal = new ViewSignal(Interop.ActorSignal.ActorOnRelayoutSignal(SwigCPtr), false);
244 if (signal?.Empty() == false)
246 signal?.Disconnect(onRelayoutEventCallback);
247 if (signal?.Empty() == true)
249 onRelayoutEventCallback = null;
257 /// An event for the touched signal which can be used to subscribe or unsubscribe the event handler provided by the user.<br />
258 /// The touched signal is emitted when the touch input is received.<br />
259 /// This can receive touch events before child. <br />
260 /// 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 />
262 [EditorBrowsable(EditorBrowsableState.Never)]
263 public event EventHandlerWithReturnType<object, TouchEventArgs, bool> InterceptTouchEvent
267 if (interceptTouchDataEventHandler == null)
269 interceptTouchDataCallback = OnInterceptTouch;
270 using TouchDataSignal signal = new TouchDataSignal(Interop.ActorSignal.ActorInterceptTouchSignal(SwigCPtr), false);
271 signal?.Connect(interceptTouchDataCallback);
273 interceptTouchDataEventHandler += value;
278 interceptTouchDataEventHandler -= value;
279 if (interceptTouchDataEventHandler == null)
281 using TouchDataSignal signal = new TouchDataSignal(Interop.ActorSignal.ActorInterceptTouchSignal(SwigCPtr), false);
282 if (signal?.Empty() == false)
284 signal?.Disconnect(interceptTouchDataCallback);
285 if (signal?.Empty() == true)
287 interceptTouchDataCallback = null;
295 /// If child view doesn't want the parent's view to intercept the touch, you can set it to true.
297 /// parent.Add(child);
298 /// parent.InterceptTouchEvent += OnInterceptTouchEvent;
299 /// View view = child.GetParent() as View;
300 /// view.DisallowInterceptTouchEvent = true;
301 /// This prevents the parent from intercepting touch.
303 [EditorBrowsable(EditorBrowsableState.Never)]
304 public bool DisallowInterceptTouchEvent { get; set; }
308 /// An event for the touched signal which can be used to subscribe or unsubscribe the event handler provided by the user.<br />
309 /// The touched signal is emitted when the touch input is received.<br />
311 /// <since_tizen> 3 </since_tizen>
312 public event EventHandlerWithReturnType<object, TouchEventArgs, bool> TouchEvent
316 if (touchDataEventHandler == null)
318 touchDataCallback = OnTouch;
319 using TouchDataSignal signal = new TouchDataSignal(Interop.ActorSignal.ActorTouchSignal(SwigCPtr), false);
320 signal.Connect(touchDataCallback);
322 touchDataEventHandler += value;
327 touchDataEventHandler -= value;
328 if (touchDataEventHandler == null)
330 using TouchDataSignal signal = new TouchDataSignal(Interop.ActorSignal.ActorTouchSignal(SwigCPtr), false);
331 if (signal.Empty() == false)
333 signal.Disconnect(touchDataCallback);
334 if (signal?.Empty() == true)
336 touchDataCallback = null;
344 /// An event for the hovered signal which can be used to subscribe or unsubscribe the event handler provided by the user.<br />
345 /// The hovered signal is emitted when the hover input is received.<br />
347 /// <since_tizen> 3 </since_tizen>
348 public event EventHandlerWithReturnType<object, HoverEventArgs, bool> HoverEvent
352 if (hoverEventHandler == null)
354 hoverEventCallback = OnHoverEvent;
355 using HoverSignal signal = new HoverSignal(Interop.ActorSignal.ActorHoveredSignal(SwigCPtr), false);
356 signal?.Connect(hoverEventCallback);
358 hoverEventHandler += value;
363 hoverEventHandler -= value;
364 if (hoverEventHandler == null)
366 using HoverSignal signal = new HoverSignal(Interop.ActorSignal.ActorHoveredSignal(SwigCPtr), false);
367 if (signal?.Empty() == false)
369 signal?.Disconnect(hoverEventCallback);
370 if (signal?.Empty() == true)
372 hoverEventCallback = null;
380 /// An event for the WheelMoved signal which can be used to subscribe or unsubscribe the event handler provided by the user.<br />
381 /// The WheelMoved signal is emitted when the wheel event is received.<br />
383 /// <since_tizen> 3 </since_tizen>
384 public event EventHandlerWithReturnType<object, WheelEventArgs, bool> WheelEvent
388 if (wheelEventHandler == null)
390 wheelEventCallback = OnWheelEvent;
391 using WheelSignal signal = new WheelSignal(Interop.ActorSignal.ActorWheelEventSignal(SwigCPtr), false);
392 signal?.Connect(wheelEventCallback);
394 wheelEventHandler += value;
399 wheelEventHandler -= value;
400 if (wheelEventHandler == null)
402 using WheelSignal signal = new WheelSignal(Interop.ActorSignal.ActorWheelEventSignal(SwigCPtr), false);
403 if (signal?.Empty() == false)
405 signal?.Disconnect(wheelEventCallback);
406 if (signal?.Empty() == true)
408 wheelEventCallback = null;
416 /// An event for the OnWindow signal which can be used to subscribe or unsubscribe the event handler.<br />
417 /// The OnWindow signal is emitted after the view has been connected to the window.<br />
419 /// <since_tizen> 3 </since_tizen>
420 public event EventHandler AddedToWindow
424 if (onWindowEventHandler == null)
426 onWindowEventCallback = OnWindow;
427 using ViewSignal signal = new ViewSignal(Interop.ActorSignal.ActorOnSceneSignal(SwigCPtr), false);
428 signal?.Connect(onWindowEventCallback);
430 onWindowEventHandler += value;
435 onWindowEventHandler -= value;
436 if (onWindowEventHandler == null)
438 using ViewSignal signal = new ViewSignal(Interop.ActorSignal.ActorOnSceneSignal(SwigCPtr), false);
439 if (signal?.Empty() == false)
441 signal?.Disconnect(onWindowEventCallback);
442 if (signal?.Empty() == true)
444 onWindowEventCallback = null;
452 /// An event for the OffWindow signal, which can be used to subscribe or unsubscribe the event handler.<br />
453 /// OffWindow signal is emitted after the view has been disconnected from the window.<br />
455 /// <since_tizen> 3 </since_tizen>
456 public event EventHandler RemovedFromWindow
460 if (offWindowEventHandler == null)
462 offWindowEventCallback = OffWindow;
463 using ViewSignal signal = new ViewSignal(Interop.ActorSignal.ActorOffSceneSignal(SwigCPtr), false);
464 signal?.Connect(offWindowEventCallback);
466 offWindowEventHandler += value;
471 offWindowEventHandler -= value;
472 if (offWindowEventHandler == null)
474 using ViewSignal signal = new ViewSignal(Interop.ActorSignal.ActorOffSceneSignal(SwigCPtr), false);
475 if (signal?.Empty() == false)
477 signal?.Disconnect(offWindowEventCallback);
478 if (signal?.Empty() == true)
480 offWindowEventCallback = null;
488 /// An event for visibility change which can be used to subscribe or unsubscribe the event handler.<br />
489 /// This signal is emitted when the visible property of this or a parent view is changed.<br />
491 /// <since_tizen> 3 </since_tizen>
492 public event EventHandler<VisibilityChangedEventArgs> VisibilityChanged
496 if (visibilityChangedEventHandler == null)
498 visibilityChangedEventCallback = OnVisibilityChanged;
499 VisibilityChangedSignal(this).Connect(visibilityChangedEventCallback);
502 visibilityChangedEventHandler += value;
507 visibilityChangedEventHandler -= value;
509 if (visibilityChangedEventHandler == null && VisibilityChangedSignal(this).Empty() == false)
511 VisibilityChangedSignal(this).Disconnect(visibilityChangedEventCallback);
512 if (VisibilityChangedSignal(this).Empty() == true)
514 visibilityChangedEventCallback = null;
521 /// Event for layout direction change which can be used to subscribe/unsubscribe the event handler.<br />
522 /// This signal is emitted when the layout direction property of this or a parent view is changed.<br />
524 /// <since_tizen> 4 </since_tizen>
525 public event EventHandler<LayoutDirectionChangedEventArgs> LayoutDirectionChanged
529 if (layoutDirectionChangedEventHandler == null)
531 layoutDirectionChangedEventCallback = OnLayoutDirectionChanged;
532 LayoutDirectionChangedSignal(this).Connect(layoutDirectionChangedEventCallback);
535 layoutDirectionChangedEventHandler += value;
540 layoutDirectionChangedEventHandler -= value;
542 if (layoutDirectionChangedEventHandler == null && LayoutDirectionChangedSignal(this).Empty() == false)
544 LayoutDirectionChangedSignal(this).Disconnect(layoutDirectionChangedEventCallback);
545 if (LayoutDirectionChangedSignal(this).Empty() == true)
547 layoutDirectionChangedEventCallback = null;
554 /// An event for the ResourcesLoadedSignal signal which can be used to subscribe or unsubscribe the event handler provided by the user.<br />
555 /// This signal is emitted after all resources required by a view are loaded and ready.<br />
557 /// <since_tizen> 3 </since_tizen>
558 public event EventHandler ResourcesLoaded
562 if (resourcesLoadedEventHandler == null)
564 ResourcesLoadedCallback = OnResourcesLoaded;
565 using ViewSignal signal = new ViewSignal(Interop.View.ResourceReadySignal(SwigCPtr), false);
566 signal?.Connect(ResourcesLoadedCallback);
568 resourcesLoadedEventHandler += value;
573 resourcesLoadedEventHandler -= value;
574 if (resourcesLoadedEventHandler == null)
576 using ViewSignal signal = new ViewSignal(Interop.View.ResourceReadySignal(SwigCPtr), false);
577 if (signal?.Empty() == false)
579 signal?.Disconnect(ResourcesLoadedCallback);
580 if (signal?.Empty() == true)
582 ResourcesLoadedCallback = null;
589 private EventHandler _backKeyPressed;
592 /// An event for getting notice when physical back key is pressed.<br />
593 /// This event is emitted BackKey is up.<br />
595 [EditorBrowsable(EditorBrowsableState.Never)]
596 public event EventHandler BackKeyPressed
600 _backKeyPressed += value;
601 BackKeyManager.Instance.Subscriber.Add(this);
606 BackKeyManager.Instance.Subscriber.Remove(this);
607 _backKeyPressed -= value;
612 /// Function for emitting BackKeyPressed event outside of View instance
614 [EditorBrowsable(EditorBrowsableState.Never)]
615 internal void EmitBackKeyPressed()
617 _backKeyPressed.Invoke(this, null);
621 internal event EventHandler<BackgroundResourceLoadedEventArgs> BackgroundResourceLoaded
625 if (backgroundResourceLoadedEventHandler == null)
627 backgroundResourceLoadedCallback = OnBackgroundResourceLoaded;
628 using ViewSignal signal = new ViewSignal(Interop.View.ResourceReadySignal(SwigCPtr), false);
629 signal?.Connect(backgroundResourceLoadedCallback);
631 backgroundResourceLoadedEventHandler += value;
636 backgroundResourceLoadedEventHandler -= value;
637 if (backgroundResourceLoadedEventHandler == null)
639 using ViewSignal signal = new ViewSignal(Interop.View.ResourceReadySignal(SwigCPtr), false);
640 if (signal?.Empty() == false)
642 signal?.Disconnect(backgroundResourceLoadedCallback);
643 if (signal?.Empty() == true)
645 backgroundResourceLoadedCallback = null;
652 internal TouchDataSignal InterceptTouchSignal()
654 TouchDataSignal ret = new TouchDataSignal(Interop.ActorSignal.ActorInterceptTouchSignal(SwigCPtr), false);
655 if (NDalicPINVOKE.SWIGPendingException.Pending)
656 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
660 internal TouchDataSignal TouchSignal()
662 TouchDataSignal ret = new TouchDataSignal(Interop.ActorSignal.ActorTouchSignal(SwigCPtr), false);
663 if (NDalicPINVOKE.SWIGPendingException.Pending)
664 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
668 internal HoverSignal HoveredSignal()
670 HoverSignal ret = new HoverSignal(Interop.ActorSignal.ActorHoveredSignal(SwigCPtr), false);
671 if (NDalicPINVOKE.SWIGPendingException.Pending)
672 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
676 internal WheelSignal WheelEventSignal()
678 WheelSignal ret = new WheelSignal(Interop.ActorSignal.ActorWheelEventSignal(SwigCPtr), false);
679 if (NDalicPINVOKE.SWIGPendingException.Pending)
680 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
684 internal ViewSignal OnWindowSignal()
686 ViewSignal ret = new ViewSignal(Interop.ActorSignal.ActorOnSceneSignal(SwigCPtr), false);
687 if (NDalicPINVOKE.SWIGPendingException.Pending)
688 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
692 internal ViewSignal OffWindowSignal()
694 ViewSignal ret = new ViewSignal(Interop.ActorSignal.ActorOffSceneSignal(SwigCPtr), false);
695 if (NDalicPINVOKE.SWIGPendingException.Pending)
696 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
700 internal ViewSignal OnRelayoutSignal()
702 ViewSignal ret = new ViewSignal(Interop.ActorSignal.ActorOnRelayoutSignal(SwigCPtr), false);
703 if (NDalicPINVOKE.SWIGPendingException.Pending)
704 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
708 internal ViewVisibilityChangedSignal VisibilityChangedSignal(View view)
710 ViewVisibilityChangedSignal ret = new ViewVisibilityChangedSignal(Interop.NDalic.VisibilityChangedSignal(View.getCPtr(view)), false);
711 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
715 internal ViewLayoutDirectionChangedSignal LayoutDirectionChangedSignal(View view)
717 ViewLayoutDirectionChangedSignal ret = new ViewLayoutDirectionChangedSignal(Interop.Layout.LayoutDirectionChangedSignal(View.getCPtr(view)), false);
718 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
722 internal ViewSignal ResourcesLoadedSignal()
724 ViewSignal ret = new ViewSignal(Interop.View.ResourceReadySignal(SwigCPtr), false);
725 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
729 internal ControlKeySignal KeyEventSignal()
731 ControlKeySignal ret = new ControlKeySignal(Interop.ViewSignal.KeyEventSignal(SwigCPtr), false);
732 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
736 internal KeyInputFocusSignal KeyInputFocusGainedSignal()
738 KeyInputFocusSignal ret = new KeyInputFocusSignal(Interop.ViewSignal.KeyInputFocusGainedSignal(SwigCPtr), false);
739 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
743 internal KeyInputFocusSignal KeyInputFocusLostSignal()
745 KeyInputFocusSignal ret = new KeyInputFocusSignal(Interop.ViewSignal.KeyInputFocusLostSignal(SwigCPtr), false);
746 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
750 private void OnColorChanged(float r, float g, float b, float a)
752 Color = new Color(r, g, b, a);
755 private void OnMinimumSizeChanged(int width, int height)
757 MinimumSize = new Size2D(width, height);
760 private void OnMaximumSizeChanged(int width, int height)
762 MaximumSize = new Size2D(width, height);
765 private void OnPosition2DChanged(int x, int y)
767 SetPosition((float)x, (float)y, 0);
770 private void OnPositionChanged(float x, float y, float z)
772 SetPosition(x, y, z);
775 private void OnSize2DChanged(int width, int height)
777 SetSize((float)width, (float)height, 0);
780 private void OnSizeChanged(float width, float height, float depth)
782 SetSize(width, height, depth);
785 private void OnParentOriginChanged(float x, float y, float z)
787 ParentOrigin = new Position(x, y, z);
790 private void OnPivotPointChanged(float x, float y, float z)
792 PivotPoint = new Position(x, y, z);
795 private void OnImageShadowChanged(ShadowBase instance)
797 ImageShadow = (ImageShadow)instance;
800 private void OnBoxShadowChanged(ShadowBase instance)
802 BoxShadow = (Shadow)instance;
805 private void OnBackgroundImageBorderChanged(int left, int right, int bottom, int top)
807 BackgroundImageBorder = new Rectangle(left, right, bottom, top);
810 private void OnKeyInputFocusGained(IntPtr view)
812 if (IsNativeHandleInvalid())
816 if (keyInputFocusGainedEventHandler != null)
818 var process = global::System.Diagnostics.Process.GetCurrentProcess().Id;
819 var thread = global::System.Threading.Thread.CurrentThread.ManagedThreadId;
820 var me = this.GetType().FullName;
822 throw new ObjectDisposedException(nameof(SwigCPtr), $"Error! NUI's native dali object is already disposed. " +
823 $"OR the native dali object handle of NUI becomes null! \n" +
824 $" process:{process} thread:{thread}, isDisposed:{this.Disposed}, isDisposeQueued:{this.IsDisposeQueued}, me:{me}\n");
829 if (this.IsDisposeQueued)
831 var process = global::System.Diagnostics.Process.GetCurrentProcess().Id;
832 var thread = global::System.Threading.Thread.CurrentThread.ManagedThreadId;
833 var me = this.GetType().FullName;
835 //in this case, the View object is ready to be disposed waiting on DisposeQueue, so event callback should not be invoked!
836 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" +
837 $"process:{process} thread:{thread}, isDisposed:{this.Disposed}, isDisposeQueued:{this.IsDisposeQueued}, me:{me}\n");
843 keyInputFocusGainedEventHandler?.Invoke(this, null);
846 private void OnKeyInputFocusLost(IntPtr view)
848 if (IsNativeHandleInvalid())
852 if (keyInputFocusLostEventHandler != null)
854 var process = global::System.Diagnostics.Process.GetCurrentProcess().Id;
855 var thread = global::System.Threading.Thread.CurrentThread.ManagedThreadId;
856 var me = this.GetType().FullName;
858 throw new ObjectDisposedException(nameof(SwigCPtr), $"Error! NUI's native dali object is already disposed. " +
859 $"OR the native dali object handle of NUI becomes null! \n" +
860 $" process:{process} thread:{thread}, isDisposed:{this.Disposed}, isDisposeQueued:{this.IsDisposeQueued}, me:{me}\n");
865 if (this.IsDisposeQueued)
867 var process = global::System.Diagnostics.Process.GetCurrentProcess().Id;
868 var thread = global::System.Threading.Thread.CurrentThread.ManagedThreadId;
869 var me = this.GetType().FullName;
871 //in this case, the View object is ready to be disposed waiting on DisposeQueue, so event callback should not be invoked!
872 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" +
873 $"process:{process} thread:{thread}, isDisposed:{this.Disposed}, isDisposeQueued:{this.IsDisposeQueued}, me:{me}\n");
879 keyInputFocusLostEventHandler?.Invoke(this, null);
882 private bool OnKeyEvent(IntPtr view, IntPtr keyEvent)
884 if (keyEvent == global::System.IntPtr.Zero)
886 NUILog.Error("keyEvent should not be null!");
890 KeyEventArgs e = new KeyEventArgs();
894 e.Key = Tizen.NUI.Key.GetKeyFromPtr(keyEvent);
896 if (keyEventHandler != null)
898 Delegate[] delegateList = keyEventHandler.GetInvocationList();
900 // Oring the result of each callback.
901 foreach (EventHandlerWithReturnType<object, KeyEventArgs, bool> del in delegateList)
903 result |= del(this, e);
910 // Callback for View OnRelayout signal
911 private void OnRelayout(IntPtr data)
913 if (onRelayoutEventHandler != null)
915 onRelayoutEventHandler(this, null);
919 // Callback for View HitTestResultSignal
920 private bool OnHitTestResult(IntPtr view, IntPtr touchData)
922 TouchEventArgs e = new TouchEventArgs();
923 e.Touch = Tizen.NUI.Touch.GetTouchFromPtr(touchData);
924 return HitTest(e.Touch);
927 // Callback for View TouchSignal
928 private bool OnInterceptTouch(IntPtr view, IntPtr touchData)
930 if (touchData == global::System.IntPtr.Zero)
932 NUILog.Error("touchData should not be null!");
936 // DisallowInterceptTouchEvent prevents the parent from intercepting touch.
937 if (DisallowInterceptTouchEvent)
942 TouchEventArgs e = new TouchEventArgs();
944 e.Touch = Tizen.NUI.Touch.GetTouchFromPtr(touchData);
946 bool consumed = false;
948 if (interceptTouchDataEventHandler != null)
950 consumed = interceptTouchDataEventHandler(this, e);
956 // Callback for View TouchSignal
957 private bool OnTouch(IntPtr view, IntPtr touchData)
959 if (touchData == global::System.IntPtr.Zero)
961 NUILog.Error("touchData should not be null!");
965 if (DispatchTouchEvents == false)
967 NUILog.Debug("If DispatchTouchEvents is false, it can not dispatch.");
971 TouchEventArgs e = new TouchEventArgs();
973 e.Touch = Tizen.NUI.Touch.GetTouchFromPtr(touchData);
975 bool consumed = false;
977 if (touchDataEventHandler != null)
979 consumed = touchDataEventHandler(this, e);
982 if (enableControlState && !consumed)
984 consumed = HandleControlStateOnTouch(e.Touch);
990 // Callback for View Hover signal
991 private bool OnHoverEvent(IntPtr view, IntPtr hoverEvent)
993 if (hoverEvent == global::System.IntPtr.Zero)
995 NUILog.Error("hoverEvent should not be null!");
999 HoverEventArgs e = new HoverEventArgs();
1001 e.Hover = Tizen.NUI.Hover.GetHoverFromPtr(hoverEvent);
1003 if (hoverEventHandler != null)
1005 return hoverEventHandler(this, e);
1010 // Callback for View Wheel signal
1011 private bool OnWheelEvent(IntPtr view, IntPtr wheelEvent)
1013 if (wheelEvent == global::System.IntPtr.Zero)
1015 NUILog.Error("wheelEvent should not be null!");
1019 WheelEventArgs e = new WheelEventArgs();
1021 e.Wheel = Tizen.NUI.Wheel.GetWheelFromPtr(wheelEvent);
1023 if (wheelEventHandler != null)
1025 return wheelEventHandler(this, e);
1030 // Callback for View OnWindow signal
1031 private void OnWindow(IntPtr data)
1033 if (onWindowEventHandler != null)
1035 onWindowEventHandler(this, null);
1039 // Callback for View OffWindow signal
1040 private void OffWindow(IntPtr data)
1042 if (offWindowEventHandler != null)
1044 offWindowEventHandler(this, null);
1048 // Callback for View visibility change signal
1049 private void OnVisibilityChanged(IntPtr data, bool visibility, VisibilityChangeType type)
1051 VisibilityChangedEventArgs e = new VisibilityChangedEventArgs();
1054 e.View = Registry.GetManagedBaseHandleFromNativePtr(data) as View;
1056 e.Visibility = visibility;
1059 if (visibilityChangedEventHandler != null)
1061 visibilityChangedEventHandler(this, e);
1065 // Callback for View layout direction change signal
1066 private void OnLayoutDirectionChanged(IntPtr data, ViewLayoutDirectionType type)
1068 LayoutDirectionChangedEventArgs e = new LayoutDirectionChangedEventArgs();
1071 e.View = Registry.GetManagedBaseHandleFromNativePtr(data) as View;
1075 if (layoutDirectionChangedEventHandler != null)
1077 layoutDirectionChangedEventHandler(this, e);
1081 private void OnResourcesLoaded(IntPtr view)
1083 if(!CheckResourceReady())
1088 if (resourcesLoadedEventHandler != null)
1090 resourcesLoadedEventHandler(this, null);
1094 private void OnBackgroundResourceLoaded(IntPtr view)
1096 BackgroundResourceLoadedEventArgs e = new BackgroundResourceLoadedEventArgs();
1097 e.Status = (ResourceLoadingStatusType)Interop.View.GetVisualResourceStatus(this.SwigCPtr, Property.BACKGROUND);
1099 if (backgroundResourceLoadedEventHandler != null)
1101 backgroundResourceLoadedEventHandler(this, e);
1106 /// Event argument passed through the ChildAdded event.
1108 /// <since_tizen> 5 </since_tizen>
1109 public class ChildAddedEventArgs : EventArgs
1112 /// Added child view at moment.
1114 /// <since_tizen> 5 </since_tizen>
1115 public View Added { get; set; }
1119 /// Event argument passed through the ChildRemoved event.
1121 /// <since_tizen> 5 </since_tizen>
1122 public class ChildRemovedEventArgs : EventArgs
1125 /// Removed child view at moment.
1127 /// <since_tizen> 5 </since_tizen>
1128 public View Removed { get; set; }
1132 /// Event arguments that passed via the KeyEvent signal.
1134 /// <since_tizen> 3 </since_tizen>
1135 public class KeyEventArgs : EventArgs
1140 /// Key - is the key sent to the view.
1142 /// <since_tizen> 3 </since_tizen>
1157 /// Event arguments that passed via the touch signal.
1159 /// <since_tizen> 3 </since_tizen>
1160 public class TouchEventArgs : EventArgs
1162 private Touch _touch;
1165 /// Touch - contains the information of touch points.
1167 /// <since_tizen> 3 </since_tizen>
1182 /// Event arguments that passed via the hover signal.
1184 /// <since_tizen> 3 </since_tizen>
1185 public class HoverEventArgs : EventArgs
1187 private Hover _hover;
1190 /// Hover - contains touch points that represent the points that are currently being hovered or the points where a hover has stopped.
1192 /// <since_tizen> 3 </since_tizen>
1207 /// Event arguments that passed via the wheel signal.
1209 /// <since_tizen> 3 </since_tizen>
1210 public class WheelEventArgs : EventArgs
1212 private Wheel _wheel;
1215 /// WheelEvent - store a wheel rolling type: MOUSE_WHEEL or CUSTOM_WHEEL.
1217 /// <since_tizen> 3 </since_tizen>
1232 /// Event arguments of visibility changed.
1234 /// <since_tizen> 3 </since_tizen>
1235 public class VisibilityChangedEventArgs : EventArgs
1238 private bool _visibility;
1239 private VisibilityChangeType _type;
1242 /// The view, or child of view, whose visibility has changed.
1244 /// <since_tizen> 3 </since_tizen>
1258 /// Whether the view is now visible or not.
1260 /// <since_tizen> 3 </since_tizen>
1261 public bool Visibility
1269 _visibility = value;
1274 /// Whether the view's visible property has changed or a parent's.
1276 /// <since_tizen> 3 </since_tizen>
1277 public VisibilityChangeType Type
1291 /// Event arguments of layout direction changed.
1293 /// <since_tizen> 4 </since_tizen>
1294 public class LayoutDirectionChangedEventArgs : EventArgs
1297 private ViewLayoutDirectionType _type;
1300 /// The view, or child of view, whose layout direction has changed.
1302 /// <since_tizen> 4 </since_tizen>
1316 /// Whether the view's layout direction property has changed or a parent's.
1318 /// <since_tizen> 4 </since_tizen>
1319 public ViewLayoutDirectionType Type
1332 internal class BackgroundResourceLoadedEventArgs : EventArgs
1334 private ResourceLoadingStatusType status = ResourceLoadingStatusType.Invalid;
1335 public ResourceLoadingStatusType Status
1349 /// The class represents the information of the situation where the View's control state changes.
1351 [EditorBrowsable(EditorBrowsableState.Never)]
1352 public class ControlStateChangedEventArgs : EventArgs
1355 /// Create an instance with mandatory fields.
1357 /// <param name="previousState">The previous control state.</param>
1358 /// <param name="currentState">The current control state.</param>
1359 [EditorBrowsable(EditorBrowsableState.Never)]
1360 public ControlStateChangedEventArgs(ControlState previousState, ControlState currentState)
1362 PreviousState = previousState;
1363 CurrentState = currentState;
1367 /// The previous control state.
1369 [EditorBrowsable(EditorBrowsableState.Never)]
1370 public ControlState PreviousState { get; }
1373 /// The current control state.
1375 [EditorBrowsable(EditorBrowsableState.Never)]
1376 public ControlState CurrentState { get; }
1380 /// The expanded touch area.
1381 /// TouchArea can expand the view's touchable area.<br/>
1382 /// 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/>
1385 /// This is based on the top left x, y coordinates.<br/>
1386 /// For example) <br/>
1388 /// view.Size = new Size(100, 100);
1389 /// view.TouchAreaOffset = new Offset(-10, 20, 30, -40); // left, right, bottom, top
1391 /// Then, touch area is 130x170.<br/>
1392 /// This is view.width + TouchAreaOffset.right - TouchAreaOffset.left and view.height + TouchAreaOffset.bottom - TouchAreaOffset.top <br/>
1393 /// +---------------------+ <br/>
1399 /// | +----+----+ | <br/>
1401 /// | -10| | 20 | <br/>
1402 /// |<---+ +----->| <br/>
1405 /// | +----+----+ | <br/>
1410 /// +---------------------+ <br/>
1412 [EditorBrowsable(EditorBrowsableState.Never)]
1413 public Offset TouchAreaOffset
1417 return (Offset)GetValue(TouchAreaOffsetProperty);
1421 SetValue(TouchAreaOffsetProperty, value);
1422 NotifyPropertyChanged();
1426 private Offset InternalTouchAreaOffset
1430 Interop.ActorInternal.GetTouchAreaOffset(SwigCPtr, out int left, out int right, out int bottom, out int top);
1431 if (NDalicPINVOKE.SWIGPendingException.Pending)
1432 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1433 return new Offset(left, right, bottom, top);
1437 Interop.ActorInternal.SetTouchAreaOffset(SwigCPtr, value.Left, value.Right, value.Bottom, value.Top);
1438 if (NDalicPINVOKE.SWIGPendingException.Pending)
1439 throw NDalicPINVOKE.SWIGPendingException.Retrieve();