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);
95 /// Event when a child is removed.
97 /// <since_tizen> 5 </since_tizen>
98 public new event EventHandler<ChildRemovedEventArgs> ChildRemoved;
100 /// Event when a child is added.
102 /// <since_tizen> 5 </since_tizen>
103 public new event EventHandler<ChildAddedEventArgs> ChildAdded;
106 /// An event for the KeyInputFocusGained signal which can be used to subscribe or unsubscribe the event handler provided by the user.<br />
107 /// The KeyInputFocusGained signal is emitted when the control gets the key input focus.<br />
109 /// <since_tizen> 3 </since_tizen>
110 public event EventHandler FocusGained
114 if (keyInputFocusGainedEventHandler == null)
116 keyInputFocusGainedCallback = OnKeyInputFocusGained;
117 using KeyInputFocusSignal signal = new KeyInputFocusSignal(Interop.ViewSignal.KeyInputFocusGainedSignal(SwigCPtr), false);
118 signal?.Connect(keyInputFocusGainedCallback);
120 keyInputFocusGainedEventHandler += value;
125 keyInputFocusGainedEventHandler -= value;
126 if (keyInputFocusGainedEventHandler == null)
128 using KeyInputFocusSignal signal = new KeyInputFocusSignal(Interop.ViewSignal.KeyInputFocusGainedSignal(SwigCPtr), false);
129 if (signal?.Empty() == false)
131 signal?.Disconnect(keyInputFocusGainedCallback);
132 keyInputFocusGainedCallback = null;
139 /// An event for the KeyInputFocusLost signal which can be used to subscribe or unsubscribe the event handler provided by the user.<br />
140 /// The KeyInputFocusLost signal is emitted when the control loses the key input focus.<br />
142 /// <since_tizen> 3 </since_tizen>
143 public event EventHandler FocusLost
147 if (keyInputFocusLostEventHandler == null)
149 keyInputFocusLostCallback = OnKeyInputFocusLost;
150 using KeyInputFocusSignal signal = new KeyInputFocusSignal(Interop.ViewSignal.KeyInputFocusLostSignal(SwigCPtr), false);
151 signal?.Connect(keyInputFocusLostCallback);
153 keyInputFocusLostEventHandler += value;
158 keyInputFocusLostEventHandler -= value;
159 if (keyInputFocusLostEventHandler == null)
161 using KeyInputFocusSignal signal = new KeyInputFocusSignal(Interop.ViewSignal.KeyInputFocusLostSignal(SwigCPtr), false);
162 if (signal?.Empty() == false)
164 signal?.Disconnect(keyInputFocusLostCallback);
165 keyInputFocusLostCallback = null;
172 /// An event for the KeyPressed signal which can be used to subscribe or unsubscribe the event handler provided by the user.<br />
173 /// The KeyPressed signal is emitted when the key event is received.<br />
175 /// <since_tizen> 3 </since_tizen>
176 public event EventHandlerWithReturnType<object, KeyEventArgs, bool> KeyEvent
180 if (keyEventHandler == null)
182 keyCallback = OnKeyEvent;
183 using ControlKeySignal signal = new ControlKeySignal(Interop.ViewSignal.KeyEventSignal(SwigCPtr), false);
184 signal?.Connect(keyCallback);
186 keyEventHandler += value;
191 keyEventHandler -= value;
192 if (keyEventHandler == null)
194 using ControlKeySignal signal = new ControlKeySignal(Interop.ViewSignal.KeyEventSignal(SwigCPtr), false);
195 if (signal?.Empty() == false)
197 signal?.Disconnect(keyCallback);
205 /// An event for the OnRelayout signal which can be used to subscribe or unsubscribe the event handler.<br />
206 /// The OnRelayout signal is emitted after the size has been set on the view during relayout.<br />
208 /// <since_tizen> 3 </since_tizen>
209 public event EventHandler Relayout
213 if (onRelayoutEventHandler == null)
215 onRelayoutEventCallback = OnRelayout;
216 using ViewSignal signal = new ViewSignal(Interop.ActorSignal.ActorOnRelayoutSignal(SwigCPtr), false);
217 signal?.Connect(onRelayoutEventCallback);
219 onRelayoutEventHandler += value;
224 onRelayoutEventHandler -= value;
225 if (onRelayoutEventHandler == null)
227 using ViewSignal signal = new ViewSignal(Interop.ActorSignal.ActorOnRelayoutSignal(SwigCPtr), false);
228 if (signal?.Empty() == false)
230 signal?.Disconnect(onRelayoutEventCallback);
231 onRelayoutEventCallback = null;
238 /// An event for the touched signal which can be used to subscribe or unsubscribe the event handler provided by the user.<br />
239 /// The touched signal is emitted when the touch input is received.<br />
240 /// This can receive touch events before child. <br />
241 /// 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 />
243 [EditorBrowsable(EditorBrowsableState.Never)]
244 public event EventHandlerWithReturnType<object, TouchEventArgs, bool> InterceptTouchEvent
248 if (interceptTouchDataEventHandler == null)
250 interceptTouchDataCallback = OnInterceptTouch;
251 using TouchDataSignal signal = new TouchDataSignal(Interop.ActorSignal.ActorInterceptTouchSignal(SwigCPtr), false);
252 signal?.Connect(interceptTouchDataCallback);
254 interceptTouchDataEventHandler += value;
259 interceptTouchDataEventHandler -= value;
260 if (interceptTouchDataEventHandler == null)
262 using TouchDataSignal signal = new TouchDataSignal(Interop.ActorSignal.ActorInterceptTouchSignal(SwigCPtr), false);
263 if (signal?.Empty() == false)
265 signal?.Disconnect(interceptTouchDataCallback);
266 interceptTouchDataCallback = null;
273 /// If child view doesn't want the parent's view to intercept the touch, you can set it to true.
275 /// parent.Add(child);
276 /// parent.InterceptTouchEvent += OnInterceptTouchEvent;
277 /// View view = child.GetParent() as View;
278 /// view.DisallowInterceptTouchEvent = true;
279 /// This prevents the parent from intercepting touch.
281 [EditorBrowsable(EditorBrowsableState.Never)]
282 public bool DisallowInterceptTouchEvent { get; set; }
286 /// An event for the touched signal which can be used to subscribe or unsubscribe the event handler provided by the user.<br />
287 /// The touched signal is emitted when the touch input is received.<br />
289 /// <since_tizen> 3 </since_tizen>
290 public event EventHandlerWithReturnType<object, TouchEventArgs, bool> TouchEvent
294 if (touchDataEventHandler == null)
296 touchDataCallback = OnTouch;
297 using TouchDataSignal signal = new TouchDataSignal(Interop.ActorSignal.ActorTouchSignal(SwigCPtr), false);
298 signal.Connect(touchDataCallback);
300 touchDataEventHandler += value;
305 touchDataEventHandler -= value;
306 if (touchDataEventHandler == null)
308 using TouchDataSignal signal = new TouchDataSignal(Interop.ActorSignal.ActorTouchSignal(SwigCPtr), false);
309 if (signal.Empty() == false)
311 signal.Disconnect(touchDataCallback);
312 touchDataCallback = null;
319 /// An event for the hovered signal which can be used to subscribe or unsubscribe the event handler provided by the user.<br />
320 /// The hovered signal is emitted when the hover input is received.<br />
322 /// <since_tizen> 3 </since_tizen>
323 public event EventHandlerWithReturnType<object, HoverEventArgs, bool> HoverEvent
327 if (hoverEventHandler == null)
329 hoverEventCallback = OnHoverEvent;
330 using HoverSignal signal = new HoverSignal(Interop.ActorSignal.ActorHoveredSignal(SwigCPtr), false);
331 signal?.Connect(hoverEventCallback);
333 hoverEventHandler += value;
338 hoverEventHandler -= value;
339 if (hoverEventHandler == null)
341 using HoverSignal signal = new HoverSignal(Interop.ActorSignal.ActorHoveredSignal(SwigCPtr), false);
342 if (signal?.Empty() == false)
344 signal?.Disconnect(hoverEventCallback);
345 hoverEventCallback = null;
352 /// An event for the WheelMoved signal which can be used to subscribe or unsubscribe the event handler provided by the user.<br />
353 /// The WheelMoved signal is emitted when the wheel event is received.<br />
355 /// <since_tizen> 3 </since_tizen>
356 public event EventHandlerWithReturnType<object, WheelEventArgs, bool> WheelEvent
360 if (wheelEventHandler == null)
362 wheelEventCallback = OnWheelEvent;
363 using WheelSignal signal = new WheelSignal(Interop.ActorSignal.ActorWheelEventSignal(SwigCPtr), false);
364 signal?.Connect(wheelEventCallback);
366 wheelEventHandler += value;
368 if (WindowWheelEventHandler == null)
370 NUIApplication.GetDefaultWindow().WheelEvent += OnWindowWheelEvent;
372 WindowWheelEventHandler += value;
377 wheelEventHandler -= value;
378 if (wheelEventHandler == null)
380 using WheelSignal signal = new WheelSignal(Interop.ActorSignal.ActorWheelEventSignal(SwigCPtr), false);
381 if (signal?.Empty() == false)
383 signal?.Disconnect(wheelEventCallback);
384 wheelEventCallback = null;
388 WindowWheelEventHandler -= value;
389 if (WindowWheelEventHandler == null)
391 NUIApplication.GetDefaultWindow().WheelEvent -= OnWindowWheelEvent;
397 /// An event for the OnWindow signal which can be used to subscribe or unsubscribe the event handler.<br />
398 /// The OnWindow signal is emitted after the view has been connected to the window.<br />
400 /// <since_tizen> 3 </since_tizen>
401 public event EventHandler AddedToWindow
405 if (onWindowEventHandler == null)
407 onWindowEventCallback = OnWindow;
408 using ViewSignal signal = new ViewSignal(Interop.ActorSignal.ActorOnSceneSignal(SwigCPtr), false);
409 signal?.Connect(onWindowEventCallback);
411 onWindowEventHandler += value;
416 onWindowEventHandler -= value;
417 if (onWindowEventHandler == null)
419 using ViewSignal signal = new ViewSignal(Interop.ActorSignal.ActorOnSceneSignal(SwigCPtr), false);
420 if (signal?.Empty() == false)
422 signal?.Disconnect(onWindowEventCallback);
423 onWindowEventCallback = null;
430 /// An event for the OffWindow signal, which can be used to subscribe or unsubscribe the event handler.<br />
431 /// OffWindow signal is emitted after the view has been disconnected from the window.<br />
433 /// <since_tizen> 3 </since_tizen>
434 public event EventHandler RemovedFromWindow
438 if (offWindowEventHandler == null)
440 offWindowEventCallback = OffWindow;
441 using ViewSignal signal = new ViewSignal(Interop.ActorSignal.ActorOffSceneSignal(SwigCPtr), false);
442 signal?.Connect(offWindowEventCallback);
444 offWindowEventHandler += value;
449 offWindowEventHandler -= value;
450 if (offWindowEventHandler == null)
452 using ViewSignal signal = new ViewSignal(Interop.ActorSignal.ActorOffSceneSignal(SwigCPtr), false);
453 if (signal?.Empty() == false)
455 signal?.Disconnect(offWindowEventCallback);
456 offWindowEventCallback = null;
463 /// An event for visibility change which can be used to subscribe or unsubscribe the event handler.<br />
464 /// This signal is emitted when the visible property of this or a parent view is changed.<br />
466 /// <since_tizen> 3 </since_tizen>
467 public event EventHandler<VisibilityChangedEventArgs> VisibilityChanged
471 if (visibilityChangedEventHandler == null)
473 visibilityChangedEventCallback = OnVisibilityChanged;
474 VisibilityChangedSignal(this).Connect(visibilityChangedEventCallback);
477 visibilityChangedEventHandler += value;
482 visibilityChangedEventHandler -= value;
484 if (visibilityChangedEventHandler == null && VisibilityChangedSignal(this).Empty() == false)
486 VisibilityChangedSignal(this).Disconnect(visibilityChangedEventCallback);
492 /// Event for layout direction change which can be used to subscribe/unsubscribe the event handler.<br />
493 /// This signal is emitted when the layout direction property of this or a parent view is changed.<br />
495 /// <since_tizen> 4 </since_tizen>
496 public event EventHandler<LayoutDirectionChangedEventArgs> LayoutDirectionChanged
500 if (layoutDirectionChangedEventHandler == null)
502 layoutDirectionChangedEventCallback = OnLayoutDirectionChanged;
503 LayoutDirectionChangedSignal(this).Connect(layoutDirectionChangedEventCallback);
506 layoutDirectionChangedEventHandler += value;
511 layoutDirectionChangedEventHandler -= value;
513 if (layoutDirectionChangedEventHandler == null && LayoutDirectionChangedSignal(this).Empty() == false)
515 LayoutDirectionChangedSignal(this).Disconnect(layoutDirectionChangedEventCallback);
521 /// An event for the ResourcesLoadedSignal signal which can be used to subscribe or unsubscribe the event handler provided by the user.<br />
522 /// This signal is emitted after all resources required by a view are loaded and ready.<br />
524 /// <since_tizen> 3 </since_tizen>
525 public event EventHandler ResourcesLoaded
529 if (resourcesLoadedEventHandler == null)
531 ResourcesLoadedCallback = OnResourcesLoaded;
532 using ViewSignal signal = new ViewSignal(Interop.View.ResourceReadySignal(SwigCPtr), false);
533 signal?.Connect(ResourcesLoadedCallback);
535 resourcesLoadedEventHandler += value;
540 resourcesLoadedEventHandler -= value;
541 if (resourcesLoadedEventHandler == null)
543 using ViewSignal signal = new ViewSignal(Interop.View.ResourceReadySignal(SwigCPtr), false);
544 if (signal?.Empty() == false)
546 signal?.Disconnect(ResourcesLoadedCallback);
547 ResourcesLoadedCallback = null;
553 private EventHandler _backKeyPressed;
556 /// An event for getting notice when physical back key is pressed.<br />
557 /// This event is emitted BackKey is up.<br />
559 [EditorBrowsable(EditorBrowsableState.Never)]
560 public event EventHandler BackKeyPressed
564 _backKeyPressed += value;
565 BackKeyManager.Instance.Subscriber.Add(this);
570 BackKeyManager.Instance.Subscriber.Remove(this);
571 _backKeyPressed -= value;
576 /// Function for emitting BackKeyPressed event outside of View instance
578 [EditorBrowsable(EditorBrowsableState.Never)]
579 internal void EmitBackKeyPressed()
581 _backKeyPressed.Invoke(this, null);
585 internal event EventHandler<BackgroundResourceLoadedEventArgs> BackgroundResourceLoaded
589 if (backgroundResourceLoadedEventHandler == null)
591 backgroundResourceLoadedCallback = OnBackgroundResourceLoaded;
592 using ViewSignal signal = new ViewSignal(Interop.View.ResourceReadySignal(SwigCPtr), false);
593 signal?.Connect(backgroundResourceLoadedCallback);
595 backgroundResourceLoadedEventHandler += value;
600 backgroundResourceLoadedEventHandler -= value;
601 if (backgroundResourceLoadedEventHandler == null)
603 using ViewSignal signal = new ViewSignal(Interop.View.ResourceReadySignal(SwigCPtr), false);
604 if (signal?.Empty() == false)
606 signal?.Disconnect(backgroundResourceLoadedCallback);
607 backgroundResourceLoadedCallback = null;
613 internal TouchDataSignal InterceptTouchSignal()
615 TouchDataSignal ret = new TouchDataSignal(Interop.ActorSignal.ActorInterceptTouchSignal(SwigCPtr), false);
616 if (NDalicPINVOKE.SWIGPendingException.Pending)
617 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
621 internal TouchDataSignal TouchSignal()
623 TouchDataSignal ret = new TouchDataSignal(Interop.ActorSignal.ActorTouchSignal(SwigCPtr), false);
624 if (NDalicPINVOKE.SWIGPendingException.Pending)
625 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
629 internal HoverSignal HoveredSignal()
631 HoverSignal ret = new HoverSignal(Interop.ActorSignal.ActorHoveredSignal(SwigCPtr), false);
632 if (NDalicPINVOKE.SWIGPendingException.Pending)
633 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
637 internal WheelSignal WheelEventSignal()
639 WheelSignal ret = new WheelSignal(Interop.ActorSignal.ActorWheelEventSignal(SwigCPtr), false);
640 if (NDalicPINVOKE.SWIGPendingException.Pending)
641 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
645 internal ViewSignal OnWindowSignal()
647 ViewSignal ret = new ViewSignal(Interop.ActorSignal.ActorOnSceneSignal(SwigCPtr), false);
648 if (NDalicPINVOKE.SWIGPendingException.Pending)
649 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
653 internal ViewSignal OffWindowSignal()
655 ViewSignal ret = new ViewSignal(Interop.ActorSignal.ActorOffSceneSignal(SwigCPtr), false);
656 if (NDalicPINVOKE.SWIGPendingException.Pending)
657 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
661 internal ViewSignal OnRelayoutSignal()
663 ViewSignal ret = new ViewSignal(Interop.ActorSignal.ActorOnRelayoutSignal(SwigCPtr), false);
664 if (NDalicPINVOKE.SWIGPendingException.Pending)
665 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
669 internal ViewVisibilityChangedSignal VisibilityChangedSignal(View view)
671 ViewVisibilityChangedSignal ret = new ViewVisibilityChangedSignal(Interop.NDalic.VisibilityChangedSignal(View.getCPtr(view)), false);
672 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
676 internal ViewLayoutDirectionChangedSignal LayoutDirectionChangedSignal(View view)
678 ViewLayoutDirectionChangedSignal ret = new ViewLayoutDirectionChangedSignal(Interop.Layout.LayoutDirectionChangedSignal(View.getCPtr(view)), false);
679 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
683 internal ViewSignal ResourcesLoadedSignal()
685 ViewSignal ret = new ViewSignal(Interop.View.ResourceReadySignal(SwigCPtr), false);
686 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
690 internal ControlKeySignal KeyEventSignal()
692 ControlKeySignal ret = new ControlKeySignal(Interop.ViewSignal.KeyEventSignal(SwigCPtr), false);
693 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
697 internal KeyInputFocusSignal KeyInputFocusGainedSignal()
699 KeyInputFocusSignal ret = new KeyInputFocusSignal(Interop.ViewSignal.KeyInputFocusGainedSignal(SwigCPtr), false);
700 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
704 internal KeyInputFocusSignal KeyInputFocusLostSignal()
706 KeyInputFocusSignal ret = new KeyInputFocusSignal(Interop.ViewSignal.KeyInputFocusLostSignal(SwigCPtr), false);
707 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
711 private void OnSize2DChanged(int? width, int? height)
716 temp = new Tizen.NUI.PropertyValue((float)width);
717 Tizen.NUI.Object.SetProperty(this.SwigCPtr, View.Property.SizeWidth, temp);
722 temp = new Tizen.NUI.PropertyValue((float)height);
723 Tizen.NUI.Object.SetProperty(this.SwigCPtr, View.Property.SizeHeight, temp);
728 private void OnMinimumSizeChanged(int? width, int? height)
730 if (width != null && height != null)
732 MinimumSize = new Size2D((int)width, (int)height);
734 else if (width != null && height == null)
736 MinimumSize = new Size2D((int)width, (int)this.GetMinimumSize().Height);
738 else if (width == null && height != null)
740 MinimumSize = new Size2D((int)this.GetMinimumSize().Width, (int)height);
744 //both are null, do nothing.
748 private void OnMaximumSizeChanged(int? width, int? height)
750 if (width != null && height != null)
752 MaximumSize = new Size2D((int)width, (int)height);
754 else if (width != null && height == null)
756 MaximumSize = new Size2D((int)width, (int)this.GetMaximumSize().Height);
758 else if (width == null && height != null)
760 MaximumSize = new Size2D((int)this.GetMaximumSize().Width, (int)height);
764 //both are null, do nothing.
768 private void OnPosition2DChanged(int x, int y)
770 Position2D = new Position2D(x, y);
773 private void OnSizeChanged(float? width, float? height, float? depth)
778 temp = new Tizen.NUI.PropertyValue((float)width);
779 Tizen.NUI.Object.SetProperty(this.SwigCPtr, View.Property.SizeWidth, temp);
784 temp = new Tizen.NUI.PropertyValue((float)height);
785 Tizen.NUI.Object.SetProperty(this.SwigCPtr, View.Property.SizeHeight, temp);
790 temp = new Tizen.NUI.PropertyValue((float)depth);
791 Tizen.NUI.Object.SetProperty(this.SwigCPtr, View.Property.SizeDepth, temp);
796 private void OnPositionChanged(float x, float y, float z)
798 Position = new Position(x, y, z);
801 private void OnParentOriginChanged(float x, float y, float z)
803 ParentOrigin = new Position(x, y, z);
806 private void OnPivotPointChanged(float x, float y, float z)
808 PivotPoint = new Position(x, y, z);
811 private void OnImageShadowChanged(ShadowBase instance)
813 ImageShadow = (ImageShadow)instance;
816 private void OnBoxShadowChanged(ShadowBase instance)
818 BoxShadow = (Shadow)instance;
821 private void OnBackgroundImageBorderChanged(int left, int right, int bottom, int top)
823 BackgroundImageBorder = new Rectangle(left, right, bottom, top);
826 private void OnKeyInputFocusGained(IntPtr view)
828 if (keyInputFocusGainedEventHandler != null)
830 keyInputFocusGainedEventHandler(this, null);
834 private void OnKeyInputFocusLost(IntPtr view)
836 if (keyInputFocusLostEventHandler != null)
838 keyInputFocusLostEventHandler(this, null);
842 private bool OnKeyEvent(IntPtr view, IntPtr keyEvent)
844 if (keyEvent == global::System.IntPtr.Zero)
846 NUILog.Error("keyEvent should not be null!");
850 KeyEventArgs e = new KeyEventArgs();
854 e.Key = Tizen.NUI.Key.GetKeyFromPtr(keyEvent);
856 if (keyEventHandler != null)
858 Delegate[] delegateList = keyEventHandler.GetInvocationList();
860 // Oring the result of each callback.
861 foreach (EventHandlerWithReturnType<object, KeyEventArgs, bool> del in delegateList)
863 result |= del(this, e);
870 // Callback for View OnRelayout signal
871 private void OnRelayout(IntPtr data)
873 if (onRelayoutEventHandler != null)
875 onRelayoutEventHandler(this, null);
879 // Callback for View TouchSignal
880 private bool OnInterceptTouch(IntPtr view, IntPtr touchData)
882 if (touchData == global::System.IntPtr.Zero)
884 NUILog.Error("touchData should not be null!");
888 // DisallowInterceptTouchEvent prevents the parent from intercepting touch.
889 if (DisallowInterceptTouchEvent)
894 TouchEventArgs e = new TouchEventArgs();
896 e.Touch = Tizen.NUI.Touch.GetTouchFromPtr(touchData);
898 bool consumed = false;
900 if (interceptTouchDataEventHandler != null)
902 consumed = interceptTouchDataEventHandler(this, e);
908 // Callback for View TouchSignal
909 private bool OnTouch(IntPtr view, IntPtr touchData)
911 if (touchData == global::System.IntPtr.Zero)
913 NUILog.Error("touchData should not be null!");
917 TouchEventArgs e = new TouchEventArgs();
919 e.Touch = Tizen.NUI.Touch.GetTouchFromPtr(touchData);
921 bool consumed = false;
923 if (touchDataEventHandler != null)
925 consumed = touchDataEventHandler(this, e);
928 if (enableControlState && !consumed)
930 consumed = HandleControlStateOnTouch(e.Touch);
936 // Callback for View Hover signal
937 private bool OnHoverEvent(IntPtr view, IntPtr hoverEvent)
939 if (hoverEvent == global::System.IntPtr.Zero)
941 NUILog.Error("hoverEvent should not be null!");
945 HoverEventArgs e = new HoverEventArgs();
947 e.Hover = Tizen.NUI.Hover.GetHoverFromPtr(hoverEvent);
949 if (hoverEventHandler != null)
951 return hoverEventHandler(this, e);
956 // Callback for View Wheel signal
957 private bool OnWheelEvent(IntPtr view, IntPtr wheelEvent)
959 if (wheelEvent == global::System.IntPtr.Zero)
961 NUILog.Error("wheelEvent should not be null!");
965 WheelEventArgs e = new WheelEventArgs();
967 e.Wheel = Tizen.NUI.Wheel.GetWheelFromPtr(wheelEvent);
969 if (wheelEventHandler != null)
971 return wheelEventHandler(this, e);
976 // Callback for View OnWindow signal
977 private void OnWindow(IntPtr data)
979 if (onWindowEventHandler != null)
981 onWindowEventHandler(this, null);
985 // Callback for View OffWindow signal
986 private void OffWindow(IntPtr data)
988 if (offWindowEventHandler != null)
990 offWindowEventHandler(this, null);
994 // Callback for View visibility change signal
995 private void OnVisibilityChanged(IntPtr data, bool visibility, VisibilityChangeType type)
997 VisibilityChangedEventArgs e = new VisibilityChangedEventArgs();
1000 e.View = Registry.GetManagedBaseHandleFromNativePtr(data) as View;
1002 e.Visibility = visibility;
1005 if (visibilityChangedEventHandler != null)
1007 visibilityChangedEventHandler(this, e);
1011 // Callback for View layout direction change signal
1012 private void OnLayoutDirectionChanged(IntPtr data, ViewLayoutDirectionType type)
1014 LayoutDirectionChangedEventArgs e = new LayoutDirectionChangedEventArgs();
1017 e.View = Registry.GetManagedBaseHandleFromNativePtr(data) as View;
1021 if (layoutDirectionChangedEventHandler != null)
1023 layoutDirectionChangedEventHandler(this, e);
1027 private void OnResourcesLoaded(IntPtr view)
1029 if (resourcesLoadedEventHandler != null)
1031 resourcesLoadedEventHandler(this, null);
1035 private void OnBackgroundResourceLoaded(IntPtr view)
1037 BackgroundResourceLoadedEventArgs e = new BackgroundResourceLoadedEventArgs();
1038 e.Status = (ResourceLoadingStatusType)Interop.View.GetVisualResourceStatus(this.SwigCPtr, Property.BACKGROUND);
1040 if (backgroundResourceLoadedEventHandler != null)
1042 backgroundResourceLoadedEventHandler(this, e);
1047 /// Event argument passed through the ChildAdded event.
1049 /// <since_tizen> 5 </since_tizen>
1050 public class ChildAddedEventArgs : EventArgs
1053 /// Added child view at moment.
1055 /// <since_tizen> 5 </since_tizen>
1056 public View Added { get; set; }
1060 /// Event argument passed through the ChildRemoved event.
1062 /// <since_tizen> 5 </since_tizen>
1063 public class ChildRemovedEventArgs : EventArgs
1066 /// Removed child view at moment.
1068 /// <since_tizen> 5 </since_tizen>
1069 public View Removed { get; set; }
1073 /// Event arguments that passed via the KeyEvent signal.
1075 /// <since_tizen> 3 </since_tizen>
1076 public class KeyEventArgs : EventArgs
1081 /// Key - is the key sent to the view.
1083 /// <since_tizen> 3 </since_tizen>
1098 /// Event arguments that passed via the touch signal.
1100 /// <since_tizen> 3 </since_tizen>
1101 public class TouchEventArgs : EventArgs
1103 private Touch _touch;
1106 /// Touch - contains the information of touch points.
1108 /// <since_tizen> 3 </since_tizen>
1123 /// Event arguments that passed via the hover signal.
1125 /// <since_tizen> 3 </since_tizen>
1126 public class HoverEventArgs : EventArgs
1128 private Hover _hover;
1131 /// Hover - contains touch points that represent the points that are currently being hovered or the points where a hover has stopped.
1133 /// <since_tizen> 3 </since_tizen>
1148 /// Event arguments that passed via the wheel signal.
1150 /// <since_tizen> 3 </since_tizen>
1151 public class WheelEventArgs : EventArgs
1153 private Wheel _wheel;
1156 /// WheelEvent - store a wheel rolling type: MOUSE_WHEEL or CUSTOM_WHEEL.
1158 /// <since_tizen> 3 </since_tizen>
1173 /// Event arguments of visibility changed.
1175 /// <since_tizen> 3 </since_tizen>
1176 public class VisibilityChangedEventArgs : EventArgs
1179 private bool _visibility;
1180 private VisibilityChangeType _type;
1183 /// The view, or child of view, whose visibility has changed.
1185 /// <since_tizen> 3 </since_tizen>
1199 /// Whether the view is now visible or not.
1201 /// <since_tizen> 3 </since_tizen>
1202 public bool Visibility
1210 _visibility = value;
1215 /// Whether the view's visible property has changed or a parent's.
1217 /// <since_tizen> 3 </since_tizen>
1218 public VisibilityChangeType Type
1232 /// Event arguments of layout direction changed.
1234 /// <since_tizen> 4 </since_tizen>
1235 public class LayoutDirectionChangedEventArgs : EventArgs
1238 private ViewLayoutDirectionType _type;
1241 /// The view, or child of view, whose layout direction has changed.
1243 /// <since_tizen> 4 </since_tizen>
1257 /// Whether the view's layout direction property has changed or a parent's.
1259 /// <since_tizen> 4 </since_tizen>
1260 public ViewLayoutDirectionType Type
1273 internal class BackgroundResourceLoadedEventArgs : EventArgs
1275 private ResourceLoadingStatusType status = ResourceLoadingStatusType.Invalid;
1276 public ResourceLoadingStatusType Status
1290 /// The class represents the information of the situation where the View's control state changes.
1292 [EditorBrowsable(EditorBrowsableState.Never)]
1293 public class ControlStateChangedEventArgs : EventArgs
1296 /// Create an instance with mandatory fields.
1298 /// <param name="previousState">The previous control state.</param>
1299 /// <param name="currentState">The current control state.</param>
1300 [EditorBrowsable(EditorBrowsableState.Never)]
1301 public ControlStateChangedEventArgs(ControlState previousState, ControlState currentState)
1303 PreviousState = previousState;
1304 CurrentState = currentState;
1308 /// The previous control state.
1310 [EditorBrowsable(EditorBrowsableState.Never)]
1311 public ControlState PreviousState { get; }
1314 /// The current control state.
1316 [EditorBrowsable(EditorBrowsableState.Never)]
1317 public ControlState CurrentState { get; }
1320 private EventHandlerWithReturnType<object, WheelEventArgs, bool> WindowWheelEventHandler;
1321 private void OnWindowWheelEvent(object sender, Window.WheelEventArgs e)
1325 if (e.Wheel.Type == Wheel.WheelType.CustomWheel)
1327 var arg = new WheelEventArgs()
1331 WindowWheelEventHandler?.Invoke(this, arg);
1337 /// The expanded touch area.
1338 /// TouchArea can expand the view's touchable area.<br/>
1339 /// 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/>
1342 /// This is based on the top left x, y coordinates.<br/>
1343 /// For example) <br/>
1345 /// view.Size = new Size(100, 100);
1346 /// view.TouchAreaOffset = new Offset(-10, 20, 30, -40); // left, right, bottom, top
1348 /// Then, touch area is 130x170.<br/>
1349 /// This is view.width + TouchAreaOffset.right - TouchAreaOffset.left and view.height + TouchAreaOffset.bottom - TouchAreaOffset.top <br/>
1350 /// +---------------------+ <br/>
1356 /// | +----+----+ | <br/>
1358 /// | -10| | 20 | <br/>
1359 /// |<---+ +----->| <br/>
1362 /// | +----+----+ | <br/>
1367 /// +---------------------+ <br/>
1369 [EditorBrowsable(EditorBrowsableState.Never)]
1370 public Offset TouchAreaOffset
1374 return (Offset)GetValue(TouchAreaOffsetProperty);
1378 SetValue(TouchAreaOffsetProperty, value);
1379 NotifyPropertyChanged();
1383 private Offset InternalTouchAreaOffset
1387 Interop.ActorInternal.GetTouchAreaOffset(SwigCPtr, out int left, out int right, out int bottom, out int top);
1388 if (NDalicPINVOKE.SWIGPendingException.Pending)
1389 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1390 return new Offset(left, right, bottom, top);
1394 Interop.ActorInternal.SetTouchAreaOffset(SwigCPtr, value.Left, value.Right, value.Bottom, value.Top);
1395 if (NDalicPINVOKE.SWIGPendingException.Pending)
1396 throw NDalicPINVOKE.SWIGPendingException.Retrieve();