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 if (touchData == global::System.IntPtr.Zero)
924 NUILog.Error("touchData should not be null!");
928 TouchEventArgs e = new TouchEventArgs();
929 e.Touch = Tizen.NUI.Touch.GetTouchFromPtr(touchData);
930 return HitTest(e.Touch);
933 // Callback for View TouchSignal
934 private bool OnInterceptTouch(IntPtr view, IntPtr touchData)
936 if (touchData == global::System.IntPtr.Zero)
938 NUILog.Error("touchData should not be null!");
942 // DisallowInterceptTouchEvent prevents the parent from intercepting touch.
943 if (DisallowInterceptTouchEvent)
948 TouchEventArgs e = new TouchEventArgs();
950 e.Touch = Tizen.NUI.Touch.GetTouchFromPtr(touchData);
952 bool consumed = false;
954 if (interceptTouchDataEventHandler != null)
956 consumed = interceptTouchDataEventHandler(this, e);
962 // Callback for View TouchSignal
963 private bool OnTouch(IntPtr view, IntPtr touchData)
965 if (touchData == global::System.IntPtr.Zero)
967 NUILog.Error("touchData should not be null!");
971 if (DispatchTouchEvents == false)
973 NUILog.Debug("If DispatchTouchEvents is false, it can not dispatch.");
977 TouchEventArgs e = new TouchEventArgs();
979 e.Touch = Tizen.NUI.Touch.GetTouchFromPtr(touchData);
981 bool consumed = false;
983 if (touchDataEventHandler != null)
985 consumed = touchDataEventHandler(this, e);
988 if (enableControlState && !consumed)
990 consumed = HandleControlStateOnTouch(e.Touch);
996 // Callback for View Hover signal
997 private bool OnHoverEvent(IntPtr view, IntPtr hoverEvent)
999 if (hoverEvent == global::System.IntPtr.Zero)
1001 NUILog.Error("hoverEvent should not be null!");
1005 HoverEventArgs e = new HoverEventArgs();
1007 e.Hover = Tizen.NUI.Hover.GetHoverFromPtr(hoverEvent);
1009 if (hoverEventHandler != null)
1011 return hoverEventHandler(this, e);
1016 // Callback for View Wheel signal
1017 private bool OnWheelEvent(IntPtr view, IntPtr wheelEvent)
1019 if (wheelEvent == global::System.IntPtr.Zero)
1021 NUILog.Error("wheelEvent should not be null!");
1025 WheelEventArgs e = new WheelEventArgs();
1027 e.Wheel = Tizen.NUI.Wheel.GetWheelFromPtr(wheelEvent);
1029 if (wheelEventHandler != null)
1031 return wheelEventHandler(this, e);
1036 // Callback for View OnWindow signal
1037 private void OnWindow(IntPtr data)
1039 if (onWindowEventHandler != null)
1041 onWindowEventHandler(this, null);
1045 // Callback for View OffWindow signal
1046 private void OffWindow(IntPtr data)
1048 if (offWindowEventHandler != null)
1050 offWindowEventHandler(this, null);
1054 // Callback for View visibility change signal
1055 private void OnVisibilityChanged(IntPtr data, bool visibility, VisibilityChangeType type)
1057 VisibilityChangedEventArgs e = new VisibilityChangedEventArgs();
1060 e.View = Registry.GetManagedBaseHandleFromNativePtr(data) as View;
1062 e.Visibility = visibility;
1065 if (visibilityChangedEventHandler != null)
1067 visibilityChangedEventHandler(this, e);
1071 // Callback for View layout direction change signal
1072 private void OnLayoutDirectionChanged(IntPtr data, ViewLayoutDirectionType type)
1074 LayoutDirectionChangedEventArgs e = new LayoutDirectionChangedEventArgs();
1077 e.View = Registry.GetManagedBaseHandleFromNativePtr(data) as View;
1081 if (layoutDirectionChangedEventHandler != null)
1083 layoutDirectionChangedEventHandler(this, e);
1087 private void OnResourcesLoaded(IntPtr view)
1089 if(!CheckResourceReady())
1094 if (resourcesLoadedEventHandler != null)
1096 resourcesLoadedEventHandler(this, null);
1100 private void OnBackgroundResourceLoaded(IntPtr view)
1102 BackgroundResourceLoadedEventArgs e = new BackgroundResourceLoadedEventArgs();
1103 e.Status = (ResourceLoadingStatusType)Interop.View.GetVisualResourceStatus(this.SwigCPtr, Property.BACKGROUND);
1105 if (backgroundResourceLoadedEventHandler != null)
1107 backgroundResourceLoadedEventHandler(this, e);
1112 /// Event argument passed through the ChildAdded event.
1114 /// <since_tizen> 5 </since_tizen>
1115 public class ChildAddedEventArgs : EventArgs
1118 /// Added child view at moment.
1120 /// <since_tizen> 5 </since_tizen>
1121 public View Added { get; set; }
1125 /// Event argument passed through the ChildRemoved event.
1127 /// <since_tizen> 5 </since_tizen>
1128 public class ChildRemovedEventArgs : EventArgs
1131 /// Removed child view at moment.
1133 /// <since_tizen> 5 </since_tizen>
1134 public View Removed { get; set; }
1138 /// Event arguments that passed via the KeyEvent signal.
1140 /// <since_tizen> 3 </since_tizen>
1141 public class KeyEventArgs : EventArgs
1146 /// Key - is the key sent to the view.
1148 /// <since_tizen> 3 </since_tizen>
1163 /// Event arguments that passed via the touch signal.
1165 /// <since_tizen> 3 </since_tizen>
1166 public class TouchEventArgs : EventArgs
1168 private Touch _touch;
1171 /// Touch - contains the information of touch points.
1173 /// <since_tizen> 3 </since_tizen>
1188 /// Event arguments that passed via the hover signal.
1190 /// <since_tizen> 3 </since_tizen>
1191 public class HoverEventArgs : EventArgs
1193 private Hover _hover;
1196 /// Hover - contains touch points that represent the points that are currently being hovered or the points where a hover has stopped.
1198 /// <since_tizen> 3 </since_tizen>
1213 /// Event arguments that passed via the wheel signal.
1215 /// <since_tizen> 3 </since_tizen>
1216 public class WheelEventArgs : EventArgs
1218 private Wheel _wheel;
1221 /// WheelEvent - store a wheel rolling type: MOUSE_WHEEL or CUSTOM_WHEEL.
1223 /// <since_tizen> 3 </since_tizen>
1238 /// Event arguments of visibility changed.
1240 /// <since_tizen> 3 </since_tizen>
1241 public class VisibilityChangedEventArgs : EventArgs
1244 private bool _visibility;
1245 private VisibilityChangeType _type;
1248 /// The view, or child of view, whose visibility has changed.
1250 /// <since_tizen> 3 </since_tizen>
1264 /// Whether the view is now visible or not.
1266 /// <since_tizen> 3 </since_tizen>
1267 public bool Visibility
1275 _visibility = value;
1280 /// Whether the view's visible property has changed or a parent's.
1282 /// <since_tizen> 3 </since_tizen>
1283 public VisibilityChangeType Type
1297 /// Event arguments of layout direction changed.
1299 /// <since_tizen> 4 </since_tizen>
1300 public class LayoutDirectionChangedEventArgs : EventArgs
1303 private ViewLayoutDirectionType _type;
1306 /// The view, or child of view, whose layout direction has changed.
1308 /// <since_tizen> 4 </since_tizen>
1322 /// Whether the view's layout direction property has changed or a parent's.
1324 /// <since_tizen> 4 </since_tizen>
1325 public ViewLayoutDirectionType Type
1338 internal class BackgroundResourceLoadedEventArgs : EventArgs
1340 private ResourceLoadingStatusType status = ResourceLoadingStatusType.Invalid;
1341 public ResourceLoadingStatusType Status
1355 /// The class represents the information of the situation where the View's control state changes.
1357 [EditorBrowsable(EditorBrowsableState.Never)]
1358 public class ControlStateChangedEventArgs : EventArgs
1361 /// Create an instance with mandatory fields.
1363 /// <param name="previousState">The previous control state.</param>
1364 /// <param name="currentState">The current control state.</param>
1365 [EditorBrowsable(EditorBrowsableState.Never)]
1366 public ControlStateChangedEventArgs(ControlState previousState, ControlState currentState)
1368 PreviousState = previousState;
1369 CurrentState = currentState;
1373 /// The previous control state.
1375 [EditorBrowsable(EditorBrowsableState.Never)]
1376 public ControlState PreviousState { get; }
1379 /// The current control state.
1381 [EditorBrowsable(EditorBrowsableState.Never)]
1382 public ControlState CurrentState { get; }
1386 /// The expanded touch area.
1387 /// TouchArea can expand the view's touchable area.<br/>
1388 /// 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/>
1391 /// This is based on the top left x, y coordinates.<br/>
1392 /// For example) <br/>
1394 /// view.Size = new Size(100, 100);
1395 /// view.TouchAreaOffset = new Offset(-10, 20, 30, -40); // left, right, bottom, top
1397 /// Then, touch area is 130x170.<br/>
1398 /// This is view.width + TouchAreaOffset.right - TouchAreaOffset.left and view.height + TouchAreaOffset.bottom - TouchAreaOffset.top <br/>
1399 /// +---------------------+ <br/>
1405 /// | +----+----+ | <br/>
1407 /// | -10| | 20 | <br/>
1408 /// |<---+ +----->| <br/>
1411 /// | +----+----+ | <br/>
1416 /// +---------------------+ <br/>
1418 [EditorBrowsable(EditorBrowsableState.Never)]
1419 public Offset TouchAreaOffset
1423 return (Offset)GetValue(TouchAreaOffsetProperty);
1427 SetValue(TouchAreaOffsetProperty, value);
1428 NotifyPropertyChanged();
1432 private Offset InternalTouchAreaOffset
1436 Interop.ActorInternal.GetTouchAreaOffset(SwigCPtr, out int left, out int right, out int bottom, out int top);
1437 if (NDalicPINVOKE.SWIGPendingException.Pending)
1438 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1439 return new Offset(left, right, bottom, top);
1443 Interop.ActorInternal.SetTouchAreaOffset(SwigCPtr, value.Left, value.Right, value.Bottom, value.Top);
1444 if (NDalicPINVOKE.SWIGPendingException.Pending)
1445 throw NDalicPINVOKE.SWIGPendingException.Retrieve();