2 * Copyright(c) 2021 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
19 using System.ComponentModel;
20 using System.Runtime.InteropServices;
22 namespace Tizen.NUI.BaseComponents
25 /// View is the base class for all views.
27 /// <since_tizen> 3 </since_tizen>
28 public partial class View
30 private EventHandler offWindowEventHandler;
31 private OffWindowEventCallbackType offWindowEventCallback;
32 private EventHandlerWithReturnType<object, WheelEventArgs, bool> wheelEventHandler;
33 private WheelEventCallbackType wheelEventCallback;
34 private EventHandlerWithReturnType<object, KeyEventArgs, bool> keyEventHandler;
35 private KeyCallbackType keyCallback;
36 private EventHandlerWithReturnType<object, TouchEventArgs, bool> interceptTouchDataEventHandler;
37 private TouchDataCallbackType interceptTouchDataCallback;
38 private EventHandlerWithReturnType<object, TouchEventArgs, bool> touchDataEventHandler;
39 private TouchDataCallbackType touchDataCallback;
40 private EventHandlerWithReturnType<object, HoverEventArgs, bool> hoverEventHandler;
41 private HoverEventCallbackType hoverEventCallback;
42 private EventHandler<VisibilityChangedEventArgs> visibilityChangedEventHandler;
43 private VisibilityChangedEventCallbackType visibilityChangedEventCallback;
44 private EventHandler keyInputFocusGainedEventHandler;
45 private KeyInputFocusGainedCallbackType keyInputFocusGainedCallback;
46 private EventHandler keyInputFocusLostEventHandler;
47 private KeyInputFocusLostCallbackType keyInputFocusLostCallback;
48 private EventHandler onRelayoutEventHandler;
49 private OnRelayoutEventCallbackType onRelayoutEventCallback;
50 private EventHandler onWindowEventHandler;
51 private OnWindowEventCallbackType onWindowEventCallback;
52 private EventHandler<LayoutDirectionChangedEventArgs> layoutDirectionChangedEventHandler;
53 private LayoutDirectionChangedEventCallbackType layoutDirectionChangedEventCallback;
54 // Resource Ready Signal
55 private EventHandler resourcesLoadedEventHandler;
56 private ResourcesLoadedCallbackType ResourcesLoadedCallback;
57 private EventHandler<BackgroundResourceLoadedEventArgs> backgroundResourceLoadedEventHandler;
58 private _backgroundResourceLoadedCallbackType backgroundResourceLoadedCallback;
59 private OnWindowEventCallbackType onWindowSendEventCallback;
60 private void SendViewAddedEventToWindow(IntPtr data)
64 NUIApplication.GetDefaultWindow()?.SendViewAdded(this);
67 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
68 private delegate void OffWindowEventCallbackType(IntPtr control);
69 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
70 private delegate bool WheelEventCallbackType(IntPtr view, IntPtr wheelEvent);
71 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
72 private delegate bool KeyCallbackType(IntPtr control, IntPtr keyEvent);
73 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
74 private delegate bool TouchDataCallbackType(IntPtr view, IntPtr touchData);
75 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
76 private delegate bool HoverEventCallbackType(IntPtr view, IntPtr hoverEvent);
77 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
78 private delegate void VisibilityChangedEventCallbackType(IntPtr data, bool visibility, VisibilityChangeType type);
79 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
80 private delegate void ResourcesLoadedCallbackType(IntPtr control);
81 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
82 private delegate void _backgroundResourceLoadedCallbackType(IntPtr view);
83 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
84 private delegate void KeyInputFocusGainedCallbackType(IntPtr control);
85 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
86 private delegate void KeyInputFocusLostCallbackType(IntPtr control);
87 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
88 private delegate void OnRelayoutEventCallbackType(IntPtr control);
89 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
90 private delegate void OnWindowEventCallbackType(IntPtr control);
91 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
92 private delegate void LayoutDirectionChangedEventCallbackType(IntPtr data, ViewLayoutDirectionType type);
94 private ViewSignal offWindowSignal;
95 private WheelSignal wheelEventSignal;
96 private ControlKeySignal keyEventSignal;
97 private TouchDataSignal interceptTouchSignal;
98 private TouchDataSignal touchSignal;
99 private HoverSignal hoveredSignal;
100 private ViewVisibilityChangedSignal visibilityChangedSignal;
101 private KeyInputFocusSignal keyInputFocusGainedSignal;
102 private KeyInputFocusSignal keyInputFocusLostSignal;
103 private ViewSignal onRelayoutSignal;
104 private ViewSignal onWindowSignal;
105 private ViewLayoutDirectionChangedSignal layoutDirectionChangedSignal;
106 private ViewSignal resourcesLoadedSignal;
107 private ViewSignal backgroundResourcesLoadedSignal;
108 private ViewSignal onWindowSendSignal;
111 /// Event when a child is removed.
113 /// <since_tizen> 5 </since_tizen>
114 public new event EventHandler<ChildRemovedEventArgs> ChildRemoved;
116 /// Event when a child is added.
118 /// <since_tizen> 5 </since_tizen>
119 public new event EventHandler<ChildAddedEventArgs> ChildAdded;
122 /// An event for the KeyInputFocusGained signal which can be used to subscribe or unsubscribe the event handler provided by the user.<br />
123 /// The KeyInputFocusGained signal is emitted when the control gets the key input focus.<br />
125 /// <since_tizen> 3 </since_tizen>
126 public event EventHandler FocusGained
130 if (keyInputFocusGainedEventHandler == null)
132 keyInputFocusGainedCallback = OnKeyInputFocusGained;
133 keyInputFocusGainedSignal = this.KeyInputFocusGainedSignal();
134 keyInputFocusGainedSignal?.Connect(keyInputFocusGainedCallback);
137 keyInputFocusGainedEventHandler += value;
142 keyInputFocusGainedEventHandler -= value;
144 if (keyInputFocusGainedEventHandler == null && keyInputFocusGainedSignal?.Empty() == false)
146 keyInputFocusGainedSignal?.Disconnect(keyInputFocusGainedCallback);
147 keyInputFocusGainedSignal?.Dispose();
148 keyInputFocusGainedSignal = null;
149 keyInputFocusGainedCallback = null;
155 /// An event for the KeyInputFocusLost signal which can be used to subscribe or unsubscribe the event handler provided by the user.<br />
156 /// The KeyInputFocusLost signal is emitted when the control loses the key input focus.<br />
158 /// <since_tizen> 3 </since_tizen>
159 public event EventHandler FocusLost
163 if (keyInputFocusLostEventHandler == null)
165 keyInputFocusLostCallback = OnKeyInputFocusLost;
166 keyInputFocusLostSignal = this.KeyInputFocusLostSignal();
167 keyInputFocusLostSignal?.Connect(keyInputFocusLostCallback);
170 keyInputFocusLostEventHandler += value;
175 keyInputFocusLostEventHandler -= value;
177 if (keyInputFocusLostEventHandler == null && keyInputFocusLostSignal?.Empty() == false)
179 keyInputFocusLostSignal?.Disconnect(keyInputFocusLostCallback);
180 keyInputFocusLostSignal?.Dispose();
181 keyInputFocusLostSignal = null;
182 keyInputFocusLostCallback = null;
188 /// An event for the KeyPressed signal which can be used to subscribe or unsubscribe the event handler provided by the user.<br />
189 /// The KeyPressed signal is emitted when the key event is received.<br />
191 /// <since_tizen> 3 </since_tizen>
192 public event EventHandlerWithReturnType<object, KeyEventArgs, bool> KeyEvent
196 if (keyEventHandler == null)
198 keyCallback = OnKeyEvent;
199 keyEventSignal = this.KeyEventSignal();
200 keyEventSignal?.Connect(keyCallback);
203 keyEventHandler += value;
208 keyEventHandler -= value;
210 if (keyEventHandler == null && keyEventSignal?.Empty() == false)
212 keyEventSignal?.Disconnect(keyCallback);
213 keyEventSignal?.Dispose();
214 keyEventSignal = null;
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 onRelayoutSignal = this.OnRelayoutSignal();
233 onRelayoutSignal?.Connect(onRelayoutEventCallback);
236 onRelayoutEventHandler += value;
241 onRelayoutEventHandler -= value;
243 if (onRelayoutEventHandler == null && onRelayoutSignal?.Empty() == false)
245 onRelayoutSignal?.Disconnect(onRelayoutEventCallback);
246 onRelayoutSignal?.Dispose();
247 onRelayoutSignal = null;
248 onRelayoutEventCallback = null;
254 /// An event for the touched signal which can be used to subscribe or unsubscribe the event handler provided by the user.<br />
255 /// The touched signal is emitted when the touch input is received.<br />
256 /// This can receive touch events before child. <br />
257 /// 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 />
259 [EditorBrowsable(EditorBrowsableState.Never)]
260 public event EventHandlerWithReturnType<object, TouchEventArgs, bool> InterceptTouchEvent
264 if (interceptTouchDataEventHandler == null)
266 interceptTouchDataCallback = OnInterceptTouch;
267 interceptTouchSignal = this.InterceptTouchSignal();
268 interceptTouchSignal?.Connect(interceptTouchDataCallback);
271 interceptTouchDataEventHandler += value;
276 interceptTouchDataEventHandler -= value;
278 if (interceptTouchDataEventHandler == null && interceptTouchSignal?.Empty() == false)
280 interceptTouchSignal?.Disconnect(interceptTouchDataCallback);
281 interceptTouchSignal?.Dispose();
282 interceptTouchSignal = null;
283 interceptTouchDataCallback = null;
289 /// If child view doesn't want the parent's view to intercept the touch, you can set it to true.
291 /// parent.Add(child);
292 /// parent.InterceptTouchEvent += OnInterceptTouchEvent;
293 /// View view = child.GetParent() as View;
294 /// view.DisallowInterceptTouchEvent = true;
295 /// This prevents the parent from intercepting touch.
297 [EditorBrowsable(EditorBrowsableState.Never)]
298 public bool DisallowInterceptTouchEvent { get; set; }
302 /// An event for the touched signal which can be used to subscribe or unsubscribe the event handler provided by the user.<br />
303 /// The touched signal is emitted when the touch input is received.<br />
305 /// <since_tizen> 3 </since_tizen>
306 public event EventHandlerWithReturnType<object, TouchEventArgs, bool> TouchEvent
310 if (touchDataEventHandler == null)
312 touchDataCallback = OnTouch;
313 touchSignal = this.TouchSignal();
314 touchSignal?.Connect(touchDataCallback);
317 touchDataEventHandler += value;
322 touchDataEventHandler -= value;
324 if (touchDataEventHandler == null && touchSignal?.Empty() == false)
326 touchSignal?.Disconnect(touchDataCallback);
327 touchSignal?.Dispose();
329 touchDataCallback = null;
335 /// An event for the hovered signal which can be used to subscribe or unsubscribe the event handler provided by the user.<br />
336 /// The hovered signal is emitted when the hover input is received.<br />
338 /// <since_tizen> 3 </since_tizen>
339 public event EventHandlerWithReturnType<object, HoverEventArgs, bool> HoverEvent
343 if (hoverEventHandler == null)
345 hoverEventCallback = OnHoverEvent;
346 hoveredSignal = this.HoveredSignal();
347 hoveredSignal?.Connect(hoverEventCallback);
350 hoverEventHandler += value;
355 hoverEventHandler -= value;
357 if (hoverEventHandler == null && hoveredSignal?.Empty() == false)
359 hoveredSignal?.Disconnect(hoverEventCallback);
360 hoveredSignal?.Dispose();
361 hoveredSignal = null;
362 hoverEventCallback = null;
368 /// An event for the WheelMoved signal which can be used to subscribe or unsubscribe the event handler provided by the user.<br />
369 /// The WheelMoved signal is emitted when the wheel event is received.<br />
371 /// <since_tizen> 3 </since_tizen>
372 public event EventHandlerWithReturnType<object, WheelEventArgs, bool> WheelEvent
376 if (wheelEventHandler == null)
378 wheelEventCallback = OnWheelEvent;
379 wheelEventSignal = this.WheelEventSignal();
380 wheelEventSignal?.Connect(wheelEventCallback);
383 wheelEventHandler += value;
385 if (WindowWheelEventHandler == null)
387 NUIApplication.GetDefaultWindow().WheelEvent += OnWindowWheelEvent;
389 WindowWheelEventHandler += value;
394 wheelEventHandler -= value;
396 if (wheelEventHandler == null && wheelEventSignal?.Empty() == false)
398 wheelEventSignal?.Disconnect(wheelEventCallback);
399 wheelEventSignal?.Dispose();
400 wheelEventSignal = null;
401 wheelEventCallback = null;
404 WindowWheelEventHandler -= value;
405 if (WindowWheelEventHandler == null)
407 NUIApplication.GetDefaultWindow().WheelEvent -= OnWindowWheelEvent;
413 /// An event for the OnWindow signal which can be used to subscribe or unsubscribe the event handler.<br />
414 /// The OnWindow signal is emitted after the view has been connected to the window.<br />
416 /// <since_tizen> 3 </since_tizen>
417 public event EventHandler AddedToWindow
421 if (onWindowEventHandler == null)
423 onWindowEventCallback = OnWindow;
424 onWindowSignal = this.OnWindowSignal();
425 onWindowSignal?.Connect(onWindowEventCallback);
428 onWindowEventHandler += value;
433 onWindowEventHandler -= value;
435 if (onWindowEventHandler == null && onWindowSignal?.Empty() == false)
437 onWindowSignal?.Disconnect(onWindowEventCallback);
438 onWindowSignal?.Dispose();
439 onWindowSignal = null;
440 onWindowEventCallback = null;
446 /// An event for the OffWindow signal, which can be used to subscribe or unsubscribe the event handler.<br />
447 /// OffWindow signal is emitted after the view has been disconnected from the window.<br />
449 /// <since_tizen> 3 </since_tizen>
450 public event EventHandler RemovedFromWindow
454 if (offWindowEventHandler == null)
456 offWindowEventCallback = OffWindow;
457 offWindowSignal = this.OffWindowSignal();
458 offWindowSignal?.Connect(offWindowEventCallback);
461 offWindowEventHandler += value;
466 offWindowEventHandler -= value;
468 if (offWindowEventHandler == null && offWindowSignal?.Empty() == false)
470 offWindowSignal?.Disconnect(offWindowEventCallback);
471 offWindowSignal.Dispose();
472 offWindowSignal = null;
473 offWindowEventCallback = null;
479 /// An event for visibility change which can be used to subscribe or unsubscribe the event handler.<br />
480 /// This signal is emitted when the visible property of this or a parent view is changed.<br />
482 /// <since_tizen> 3 </since_tizen>
483 public event EventHandler<VisibilityChangedEventArgs> VisibilityChanged
487 if (visibilityChangedEventHandler == null)
489 visibilityChangedEventCallback = OnVisibilityChanged;
490 visibilityChangedSignal = this.VisibilityChangedSignal(this);
491 visibilityChangedSignal?.Connect(visibilityChangedEventCallback);
494 visibilityChangedEventHandler += value;
499 visibilityChangedEventHandler -= value;
501 if (visibilityChangedEventHandler == null && visibilityChangedSignal?.Empty() == false)
503 visibilityChangedSignal?.Disconnect(visibilityChangedEventCallback);
504 visibilityChangedSignal?.Dispose();
505 visibilityChangedSignal = null;
506 visibilityChangedEventCallback = null;
512 /// Event for layout direction change which can be used to subscribe/unsubscribe the event handler.<br />
513 /// This signal is emitted when the layout direction property of this or a parent view is changed.<br />
515 /// <since_tizen> 4 </since_tizen>
516 public event EventHandler<LayoutDirectionChangedEventArgs> LayoutDirectionChanged
520 if (layoutDirectionChangedEventHandler == null)
522 layoutDirectionChangedEventCallback = OnLayoutDirectionChanged;
523 layoutDirectionChangedSignal = this.LayoutDirectionChangedSignal(this);
524 layoutDirectionChangedSignal?.Connect(layoutDirectionChangedEventCallback);
527 layoutDirectionChangedEventHandler += value;
532 layoutDirectionChangedEventHandler -= value;
534 if (layoutDirectionChangedEventHandler == null && layoutDirectionChangedSignal?.Empty() == false)
536 layoutDirectionChangedSignal?.Disconnect(layoutDirectionChangedEventCallback);
537 layoutDirectionChangedSignal?.Dispose();
538 layoutDirectionChangedSignal = null;
539 layoutDirectionChangedEventCallback = null;
545 /// An event for the ResourcesLoadedSignal signal which can be used to subscribe or unsubscribe the event handler provided by the user.<br />
546 /// This signal is emitted after all resources required by a view are loaded and ready.<br />
548 /// <since_tizen> 3 </since_tizen>
549 public event EventHandler ResourcesLoaded
553 if (resourcesLoadedEventHandler == null)
555 ResourcesLoadedCallback = OnResourcesLoaded;
556 resourcesLoadedSignal = this.ResourcesLoadedSignal();
557 resourcesLoadedSignal?.Connect(ResourcesLoadedCallback);
560 resourcesLoadedEventHandler += value;
565 resourcesLoadedEventHandler -= value;
567 if (resourcesLoadedEventHandler == null && resourcesLoadedSignal?.Empty() == false)
569 resourcesLoadedSignal?.Disconnect(ResourcesLoadedCallback);
570 resourcesLoadedSignal?.Dispose();
571 resourcesLoadedSignal = null;
572 ResourcesLoadedCallback = null;
577 private EventHandler _backKeyPressed;
580 /// An event for getting notice when physical back key is pressed.<br />
581 /// This event is emitted BackKey is up.<br />
583 [EditorBrowsable(EditorBrowsableState.Never)]
584 public event EventHandler BackKeyPressed
588 _backKeyPressed += value;
589 BackKeyManager.Instance.Subscriber.Add(this);
594 BackKeyManager.Instance.Subscriber.Remove(this);
595 _backKeyPressed -= value;
600 /// Function for emitting BackKeyPressed event outside of View instance
602 [EditorBrowsable(EditorBrowsableState.Never)]
603 internal void EmitBackKeyPressed()
605 _backKeyPressed.Invoke(this, null);
609 internal event EventHandler<BackgroundResourceLoadedEventArgs> BackgroundResourceLoaded
613 if (backgroundResourceLoadedEventHandler == null)
615 backgroundResourceLoadedCallback = OnBackgroundResourceLoaded;
616 backgroundResourcesLoadedSignal = this.ResourcesLoadedSignal();
617 backgroundResourcesLoadedSignal?.Connect(backgroundResourceLoadedCallback);
620 backgroundResourceLoadedEventHandler += value;
624 backgroundResourceLoadedEventHandler -= value;
626 if (backgroundResourceLoadedEventHandler == null && backgroundResourcesLoadedSignal?.Empty() == false)
628 backgroundResourcesLoadedSignal?.Disconnect(backgroundResourceLoadedCallback);
629 backgroundResourcesLoadedSignal?.Dispose();
630 backgroundResourcesLoadedSignal = null;
631 backgroundResourceLoadedCallback = null;
636 internal TouchDataSignal InterceptTouchSignal()
638 TouchDataSignal ret = new TouchDataSignal(Interop.ActorSignal.ActorInterceptTouchSignal(SwigCPtr), false);
639 if (NDalicPINVOKE.SWIGPendingException.Pending)
640 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
644 internal TouchDataSignal TouchSignal()
646 TouchDataSignal ret = new TouchDataSignal(Interop.ActorSignal.ActorTouchSignal(SwigCPtr), false);
647 if (NDalicPINVOKE.SWIGPendingException.Pending)
648 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
652 internal HoverSignal HoveredSignal()
654 HoverSignal ret = new HoverSignal(Interop.ActorSignal.ActorHoveredSignal(SwigCPtr), false);
655 if (NDalicPINVOKE.SWIGPendingException.Pending)
656 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
660 internal WheelSignal WheelEventSignal()
662 WheelSignal ret = new WheelSignal(Interop.ActorSignal.ActorWheelEventSignal(SwigCPtr), false);
663 if (NDalicPINVOKE.SWIGPendingException.Pending)
664 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
668 internal ViewSignal OnWindowSignal()
670 ViewSignal ret = new ViewSignal(Interop.ActorSignal.ActorOnSceneSignal(SwigCPtr), false);
671 if (NDalicPINVOKE.SWIGPendingException.Pending)
672 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
676 internal ViewSignal OffWindowSignal()
678 ViewSignal ret = new ViewSignal(Interop.ActorSignal.ActorOffSceneSignal(SwigCPtr), false);
679 if (NDalicPINVOKE.SWIGPendingException.Pending)
680 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
684 internal ViewSignal OnRelayoutSignal()
686 ViewSignal ret = new ViewSignal(Interop.ActorSignal.ActorOnRelayoutSignal(SwigCPtr), false);
687 if (NDalicPINVOKE.SWIGPendingException.Pending)
688 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
692 internal ViewVisibilityChangedSignal VisibilityChangedSignal(View view)
694 ViewVisibilityChangedSignal ret = new ViewVisibilityChangedSignal(Interop.NDalic.VisibilityChangedSignal(View.getCPtr(view)), false);
695 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
699 internal ViewLayoutDirectionChangedSignal LayoutDirectionChangedSignal(View view)
701 ViewLayoutDirectionChangedSignal ret = new ViewLayoutDirectionChangedSignal(Interop.Layout.LayoutDirectionChangedSignal(View.getCPtr(view)), false);
702 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
706 internal ViewSignal ResourcesLoadedSignal()
708 ViewSignal ret = new ViewSignal(Interop.View.ResourceReadySignal(SwigCPtr), false);
709 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
713 internal ControlKeySignal KeyEventSignal()
715 ControlKeySignal ret = new ControlKeySignal(Interop.ViewSignal.KeyEventSignal(SwigCPtr), false);
716 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
720 internal KeyInputFocusSignal KeyInputFocusGainedSignal()
722 KeyInputFocusSignal ret = new KeyInputFocusSignal(Interop.ViewSignal.KeyInputFocusGainedSignal(SwigCPtr), false);
723 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
727 internal KeyInputFocusSignal KeyInputFocusLostSignal()
729 KeyInputFocusSignal ret = new KeyInputFocusSignal(Interop.ViewSignal.KeyInputFocusLostSignal(SwigCPtr), false);
730 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
734 private void OnSize2DChanged(int? width, int? height)
739 temp = new Tizen.NUI.PropertyValue((float)width);
740 Tizen.NUI.Object.SetProperty(this.SwigCPtr, View.Property.SizeWidth, temp);
745 temp = new Tizen.NUI.PropertyValue((float)height);
746 Tizen.NUI.Object.SetProperty(this.SwigCPtr, View.Property.SizeHeight, temp);
751 private void OnMinimumSizeChanged(int? width, int? height)
753 if (width != null && height != null)
755 MinimumSize = new Size2D((int)width, (int)height);
757 else if (width != null && height == null)
759 Vector2 minSize = this.GetMinimumSize();
760 MinimumSize = new Size2D((int)width, (int)(minSize.Height));
763 else if (width == null && height != null)
765 Vector2 minSize = this.GetMinimumSize();
766 MinimumSize = new Size2D((int)(minSize.Width), (int)height);
771 //both are null, do nothing.
775 private void OnMaximumSizeChanged(int? width, int? height)
777 if (width != null && height != null)
779 MaximumSize = new Size2D((int)width, (int)height);
781 else if (width != null && height == null)
783 Vector2 maxSize = this.GetMaximumSize();
784 MaximumSize = new Size2D((int)width, (int)(maxSize.Height));
787 else if (width == null && height != null)
789 Vector2 maxSize = this.GetMaximumSize();
790 MaximumSize = new Size2D((int)(maxSize.Width), (int)height);
795 //both are null, do nothing.
799 private void OnPosition2DChanged(int x, int y)
801 Position2D = new Position2D(x, y);
804 private void OnSizeChanged(float? width, float? height, float? depth)
809 temp = new Tizen.NUI.PropertyValue((float)width);
810 Tizen.NUI.Object.SetProperty(this.SwigCPtr, View.Property.SizeWidth, temp);
815 temp = new Tizen.NUI.PropertyValue((float)height);
816 Tizen.NUI.Object.SetProperty(this.SwigCPtr, View.Property.SizeHeight, temp);
821 temp = new Tizen.NUI.PropertyValue((float)depth);
822 Tizen.NUI.Object.SetProperty(this.SwigCPtr, View.Property.SizeDepth, temp);
827 private void OnPositionChanged(float x, float y, float z)
829 Position = new Position(x, y, z);
832 private void OnParentOriginChanged(float x, float y, float z)
834 ParentOrigin = new Position(x, y, z);
837 private void OnPivotPointChanged(float x, float y, float z)
839 PivotPoint = new Position(x, y, z);
842 private void OnImageShadowChanged(ShadowBase instance)
844 ImageShadow = (ImageShadow)instance;
847 private void OnBoxShadowChanged(ShadowBase instance)
849 BoxShadow = (Shadow)instance;
852 private void OnBackgroundImageBorderChanged(int left, int right, int bottom, int top)
854 BackgroundImageBorder = new Rectangle(left, right, bottom, top);
857 private void OnKeyInputFocusGained(IntPtr view)
859 if (keyInputFocusGainedEventHandler != null)
861 keyInputFocusGainedEventHandler(this, null);
865 private void OnKeyInputFocusLost(IntPtr view)
867 if (keyInputFocusLostEventHandler != null)
869 keyInputFocusLostEventHandler(this, null);
873 private bool OnKeyEvent(IntPtr view, IntPtr keyEvent)
875 if (keyEvent == global::System.IntPtr.Zero)
877 NUILog.Error("keyEvent should not be null!");
881 KeyEventArgs e = new KeyEventArgs();
885 e.Key = Tizen.NUI.Key.GetKeyFromPtr(keyEvent);
887 if (keyEventHandler != null)
889 Delegate[] delegateList = keyEventHandler.GetInvocationList();
891 // Oring the result of each callback.
892 foreach (EventHandlerWithReturnType<object, KeyEventArgs, bool> del in delegateList)
894 result |= del(this, e);
901 // Callback for View OnRelayout signal
902 private void OnRelayout(IntPtr data)
904 if (onRelayoutEventHandler != null)
906 onRelayoutEventHandler(this, null);
910 // Callback for View TouchSignal
911 private bool OnInterceptTouch(IntPtr view, IntPtr touchData)
913 if (touchData == global::System.IntPtr.Zero)
915 NUILog.Error("touchData should not be null!");
919 // DisallowInterceptTouchEvent prevents the parent from intercepting touch.
920 if (DisallowInterceptTouchEvent)
925 TouchEventArgs e = new TouchEventArgs();
927 e.Touch = Tizen.NUI.Touch.GetTouchFromPtr(touchData);
929 bool consumed = false;
931 if (interceptTouchDataEventHandler != null)
933 consumed = interceptTouchDataEventHandler(this, e);
939 // Callback for View TouchSignal
940 private bool OnTouch(IntPtr view, IntPtr touchData)
942 if (touchData == global::System.IntPtr.Zero)
944 NUILog.Error("touchData should not be null!");
948 TouchEventArgs e = new TouchEventArgs();
950 e.Touch = Tizen.NUI.Touch.GetTouchFromPtr(touchData);
952 bool consumed = false;
954 if (touchDataEventHandler != null)
956 consumed = touchDataEventHandler(this, e);
959 if (enableControlState && !consumed)
961 consumed = HandleControlStateOnTouch(e.Touch);
967 // Callback for View Hover signal
968 private bool OnHoverEvent(IntPtr view, IntPtr hoverEvent)
970 if (hoverEvent == global::System.IntPtr.Zero)
972 NUILog.Error("hoverEvent should not be null!");
976 HoverEventArgs e = new HoverEventArgs();
978 e.Hover = Tizen.NUI.Hover.GetHoverFromPtr(hoverEvent);
980 if (hoverEventHandler != null)
982 return hoverEventHandler(this, e);
987 // Callback for View Wheel signal
988 private bool OnWheelEvent(IntPtr view, IntPtr wheelEvent)
990 if (wheelEvent == global::System.IntPtr.Zero)
992 NUILog.Error("wheelEvent should not be null!");
996 WheelEventArgs e = new WheelEventArgs();
998 e.Wheel = Tizen.NUI.Wheel.GetWheelFromPtr(wheelEvent);
1000 if (wheelEventHandler != null)
1002 return wheelEventHandler(this, e);
1007 // Callback for View OnWindow signal
1008 private void OnWindow(IntPtr data)
1010 if (onWindowEventHandler != null)
1012 onWindowEventHandler(this, null);
1016 // Callback for View OffWindow signal
1017 private void OffWindow(IntPtr data)
1019 if (offWindowEventHandler != null)
1021 offWindowEventHandler(this, null);
1025 // Callback for View visibility change signal
1026 private void OnVisibilityChanged(IntPtr data, bool visibility, VisibilityChangeType type)
1028 VisibilityChangedEventArgs e = new VisibilityChangedEventArgs();
1031 e.View = Registry.GetManagedBaseHandleFromNativePtr(data) as View;
1033 e.Visibility = visibility;
1036 if (visibilityChangedEventHandler != null)
1038 visibilityChangedEventHandler(this, e);
1042 // Callback for View layout direction change signal
1043 private void OnLayoutDirectionChanged(IntPtr data, ViewLayoutDirectionType type)
1045 LayoutDirectionChangedEventArgs e = new LayoutDirectionChangedEventArgs();
1048 e.View = Registry.GetManagedBaseHandleFromNativePtr(data) as View;
1052 if (layoutDirectionChangedEventHandler != null)
1054 layoutDirectionChangedEventHandler(this, e);
1058 private void OnResourcesLoaded(IntPtr view)
1060 if (resourcesLoadedEventHandler != null)
1062 resourcesLoadedEventHandler(this, null);
1066 private void OnBackgroundResourceLoaded(IntPtr view)
1068 BackgroundResourceLoadedEventArgs e = new BackgroundResourceLoadedEventArgs();
1069 e.Status = (ResourceLoadingStatusType)Interop.View.GetVisualResourceStatus(this.SwigCPtr, Property.BACKGROUND);
1071 if (backgroundResourceLoadedEventHandler != null)
1073 backgroundResourceLoadedEventHandler(this, e);
1078 /// Event argument passed through the ChildAdded event.
1080 /// <since_tizen> 5 </since_tizen>
1081 public class ChildAddedEventArgs : EventArgs
1084 /// Added child view at moment.
1086 /// <since_tizen> 5 </since_tizen>
1087 public View Added { get; set; }
1091 /// Event argument passed through the ChildRemoved event.
1093 /// <since_tizen> 5 </since_tizen>
1094 public class ChildRemovedEventArgs : EventArgs
1097 /// Removed child view at moment.
1099 /// <since_tizen> 5 </since_tizen>
1100 public View Removed { get; set; }
1104 /// Event arguments that passed via the KeyEvent signal.
1106 /// <since_tizen> 3 </since_tizen>
1107 public class KeyEventArgs : EventArgs
1112 /// Key - is the key sent to the view.
1114 /// <since_tizen> 3 </since_tizen>
1129 /// Event arguments that passed via the touch signal.
1131 /// <since_tizen> 3 </since_tizen>
1132 public class TouchEventArgs : EventArgs
1134 private Touch _touch;
1137 /// Touch - contains the information of touch points.
1139 /// <since_tizen> 3 </since_tizen>
1154 /// Event arguments that passed via the hover signal.
1156 /// <since_tizen> 3 </since_tizen>
1157 public class HoverEventArgs : EventArgs
1159 private Hover _hover;
1162 /// Hover - contains touch points that represent the points that are currently being hovered or the points where a hover has stopped.
1164 /// <since_tizen> 3 </since_tizen>
1179 /// Event arguments that passed via the wheel signal.
1181 /// <since_tizen> 3 </since_tizen>
1182 public class WheelEventArgs : EventArgs
1184 private Wheel _wheel;
1187 /// WheelEvent - store a wheel rolling type: MOUSE_WHEEL or CUSTOM_WHEEL.
1189 /// <since_tizen> 3 </since_tizen>
1204 /// Event arguments of visibility changed.
1206 /// <since_tizen> 3 </since_tizen>
1207 public class VisibilityChangedEventArgs : EventArgs
1210 private bool _visibility;
1211 private VisibilityChangeType _type;
1214 /// The view, or child of view, whose visibility has changed.
1216 /// <since_tizen> 3 </since_tizen>
1230 /// Whether the view is now visible or not.
1232 /// <since_tizen> 3 </since_tizen>
1233 public bool Visibility
1241 _visibility = value;
1246 /// Whether the view's visible property has changed or a parent's.
1248 /// <since_tizen> 3 </since_tizen>
1249 public VisibilityChangeType Type
1263 /// Event arguments of layout direction changed.
1265 /// <since_tizen> 4 </since_tizen>
1266 public class LayoutDirectionChangedEventArgs : EventArgs
1269 private ViewLayoutDirectionType _type;
1272 /// The view, or child of view, whose layout direction has changed.
1274 /// <since_tizen> 4 </since_tizen>
1288 /// Whether the view's layout direction property has changed or a parent's.
1290 /// <since_tizen> 4 </since_tizen>
1291 public ViewLayoutDirectionType Type
1304 internal class BackgroundResourceLoadedEventArgs : EventArgs
1306 private ResourceLoadingStatusType status = ResourceLoadingStatusType.Invalid;
1307 public ResourceLoadingStatusType Status
1321 /// The class represents the information of the situation where the View's control state changes.
1323 [EditorBrowsable(EditorBrowsableState.Never)]
1324 public class ControlStateChangedEventArgs : EventArgs
1327 /// Create an instance with mandatory fields.
1329 /// <param name="previousState">The previous control state.</param>
1330 /// <param name="currentState">The current control state.</param>
1331 [EditorBrowsable(EditorBrowsableState.Never)]
1332 public ControlStateChangedEventArgs(ControlState previousState, ControlState currentState)
1334 PreviousState = previousState;
1335 CurrentState = currentState;
1339 /// The previous control state.
1341 [EditorBrowsable(EditorBrowsableState.Never)]
1342 public ControlState PreviousState { get; }
1345 /// The current control state.
1347 [EditorBrowsable(EditorBrowsableState.Never)]
1348 public ControlState CurrentState { get; }
1351 private EventHandlerWithReturnType<object, WheelEventArgs, bool> WindowWheelEventHandler;
1352 private void OnWindowWheelEvent(object sender, Window.WheelEventArgs e)
1356 if (e.Wheel.Type == Wheel.WheelType.CustomWheel)
1358 var arg = new WheelEventArgs()
1362 WindowWheelEventHandler?.Invoke(this, arg);
1368 /// TouchArea can reset the view's touchable area.<br/>
1369 /// If you set the TouchArea on an view, when you touch the view, the touch area is used rather than the size of the view.
1371 [EditorBrowsable(EditorBrowsableState.Never)]
1372 public Size TouchArea
1376 Size value = new Size(0, 0, 0);
1377 GetProperty(View.Property.TouchArea).Get(value);
1382 SetProperty(View.Property.TouchArea, new Tizen.NUI.PropertyValue(value));
1383 NotifyPropertyChanged();