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)
713 PropertyValue temp = null;
716 temp = new PropertyValue((float)width);
717 Object.SetProperty(SwigCPtr, Property.SizeWidth, temp);
721 temp = new PropertyValue((float)height);
722 Object.SetProperty(SwigCPtr, Property.SizeHeight, temp);
727 private void OnMinimumSizeChanged(int? width, int? height)
729 if (width != null && height != null)
731 MinimumSize = new Size2D((int)width, (int)height);
733 else if (width != null && height == null)
735 MinimumSize = new Size2D((int)width, (int)this.GetMinimumSize().Height);
737 else if (width == null && height != null)
739 MinimumSize = new Size2D((int)this.GetMinimumSize().Width, (int)height);
743 //both are null, do nothing.
747 private void OnMaximumSizeChanged(int? width, int? height)
749 if (width != null && height != null)
751 MaximumSize = new Size2D((int)width, (int)height);
753 else if (width != null && height == null)
755 MaximumSize = new Size2D((int)width, (int)this.GetMaximumSize().Height);
757 else if (width == null && height != null)
759 MaximumSize = new Size2D((int)this.GetMaximumSize().Width, (int)height);
763 //both are null, do nothing.
767 private void OnPosition2DChanged(int x, int y)
769 Position2D = new Position2D(x, y);
772 private void OnSizeChanged(float? width, float? height, float? depth)
777 temp = new Tizen.NUI.PropertyValue((float)width);
778 Tizen.NUI.Object.SetProperty(this.SwigCPtr, View.Property.SizeWidth, temp);
783 temp = new Tizen.NUI.PropertyValue((float)height);
784 Tizen.NUI.Object.SetProperty(this.SwigCPtr, View.Property.SizeHeight, temp);
789 temp = new Tizen.NUI.PropertyValue((float)depth);
790 Tizen.NUI.Object.SetProperty(this.SwigCPtr, View.Property.SizeDepth, temp);
795 private void OnPositionChanged(float x, float y, float z)
797 Position = new Position(x, y, z);
800 private void OnParentOriginChanged(float x, float y, float z)
802 ParentOrigin = new Position(x, y, z);
805 private void OnPivotPointChanged(float x, float y, float z)
807 PivotPoint = new Position(x, y, z);
810 private void OnImageShadowChanged(ShadowBase instance)
812 ImageShadow = (ImageShadow)instance;
815 private void OnBoxShadowChanged(ShadowBase instance)
817 BoxShadow = (Shadow)instance;
820 private void OnBackgroundImageBorderChanged(int left, int right, int bottom, int top)
822 BackgroundImageBorder = new Rectangle(left, right, bottom, top);
825 private void OnKeyInputFocusGained(IntPtr view)
827 if (keyInputFocusGainedEventHandler != null)
829 keyInputFocusGainedEventHandler(this, null);
833 private void OnKeyInputFocusLost(IntPtr view)
835 if (keyInputFocusLostEventHandler != null)
837 keyInputFocusLostEventHandler(this, null);
841 private bool OnKeyEvent(IntPtr view, IntPtr keyEvent)
843 if (keyEvent == global::System.IntPtr.Zero)
845 NUILog.Error("keyEvent should not be null!");
849 KeyEventArgs e = new KeyEventArgs();
853 e.Key = Tizen.NUI.Key.GetKeyFromPtr(keyEvent);
855 if (keyEventHandler != null)
857 Delegate[] delegateList = keyEventHandler.GetInvocationList();
859 // Oring the result of each callback.
860 foreach (EventHandlerWithReturnType<object, KeyEventArgs, bool> del in delegateList)
862 result |= del(this, e);
869 // Callback for View OnRelayout signal
870 private void OnRelayout(IntPtr data)
872 if (onRelayoutEventHandler != null)
874 onRelayoutEventHandler(this, null);
878 // Callback for View TouchSignal
879 private bool OnInterceptTouch(IntPtr view, IntPtr touchData)
881 if (touchData == global::System.IntPtr.Zero)
883 NUILog.Error("touchData should not be null!");
887 // DisallowInterceptTouchEvent prevents the parent from intercepting touch.
888 if (DisallowInterceptTouchEvent)
893 TouchEventArgs e = new TouchEventArgs();
895 e.Touch = Tizen.NUI.Touch.GetTouchFromPtr(touchData);
897 bool consumed = false;
899 if (interceptTouchDataEventHandler != null)
901 consumed = interceptTouchDataEventHandler(this, e);
907 // Callback for View TouchSignal
908 private bool OnTouch(IntPtr view, IntPtr touchData)
910 if (touchData == global::System.IntPtr.Zero)
912 NUILog.Error("touchData should not be null!");
916 TouchEventArgs e = new TouchEventArgs();
918 e.Touch = Tizen.NUI.Touch.GetTouchFromPtr(touchData);
920 bool consumed = false;
922 if (touchDataEventHandler != null)
924 consumed = touchDataEventHandler(this, e);
927 if (enableControlState && !consumed)
929 consumed = HandleControlStateOnTouch(e.Touch);
935 // Callback for View Hover signal
936 private bool OnHoverEvent(IntPtr view, IntPtr hoverEvent)
938 if (hoverEvent == global::System.IntPtr.Zero)
940 NUILog.Error("hoverEvent should not be null!");
944 HoverEventArgs e = new HoverEventArgs();
946 e.Hover = Tizen.NUI.Hover.GetHoverFromPtr(hoverEvent);
948 if (hoverEventHandler != null)
950 return hoverEventHandler(this, e);
955 // Callback for View Wheel signal
956 private bool OnWheelEvent(IntPtr view, IntPtr wheelEvent)
958 if (wheelEvent == global::System.IntPtr.Zero)
960 NUILog.Error("wheelEvent should not be null!");
964 WheelEventArgs e = new WheelEventArgs();
966 e.Wheel = Tizen.NUI.Wheel.GetWheelFromPtr(wheelEvent);
968 if (wheelEventHandler != null)
970 return wheelEventHandler(this, e);
975 // Callback for View OnWindow signal
976 private void OnWindow(IntPtr data)
978 if (onWindowEventHandler != null)
980 onWindowEventHandler(this, null);
984 // Callback for View OffWindow signal
985 private void OffWindow(IntPtr data)
987 if (offWindowEventHandler != null)
989 offWindowEventHandler(this, null);
993 // Callback for View visibility change signal
994 private void OnVisibilityChanged(IntPtr data, bool visibility, VisibilityChangeType type)
996 VisibilityChangedEventArgs e = new VisibilityChangedEventArgs();
999 e.View = Registry.GetManagedBaseHandleFromNativePtr(data) as View;
1001 e.Visibility = visibility;
1004 if (visibilityChangedEventHandler != null)
1006 visibilityChangedEventHandler(this, e);
1010 // Callback for View layout direction change signal
1011 private void OnLayoutDirectionChanged(IntPtr data, ViewLayoutDirectionType type)
1013 LayoutDirectionChangedEventArgs e = new LayoutDirectionChangedEventArgs();
1016 e.View = Registry.GetManagedBaseHandleFromNativePtr(data) as View;
1020 if (layoutDirectionChangedEventHandler != null)
1022 layoutDirectionChangedEventHandler(this, e);
1026 private void OnResourcesLoaded(IntPtr view)
1028 if (resourcesLoadedEventHandler != null)
1030 resourcesLoadedEventHandler(this, null);
1034 private void OnBackgroundResourceLoaded(IntPtr view)
1036 BackgroundResourceLoadedEventArgs e = new BackgroundResourceLoadedEventArgs();
1037 e.Status = (ResourceLoadingStatusType)Interop.View.GetVisualResourceStatus(this.SwigCPtr, Property.BACKGROUND);
1039 if (backgroundResourceLoadedEventHandler != null)
1041 backgroundResourceLoadedEventHandler(this, e);
1046 /// Event argument passed through the ChildAdded event.
1048 /// <since_tizen> 5 </since_tizen>
1049 public class ChildAddedEventArgs : EventArgs
1052 /// Added child view at moment.
1054 /// <since_tizen> 5 </since_tizen>
1055 public View Added { get; set; }
1059 /// Event argument passed through the ChildRemoved event.
1061 /// <since_tizen> 5 </since_tizen>
1062 public class ChildRemovedEventArgs : EventArgs
1065 /// Removed child view at moment.
1067 /// <since_tizen> 5 </since_tizen>
1068 public View Removed { get; set; }
1072 /// Event arguments that passed via the KeyEvent signal.
1074 /// <since_tizen> 3 </since_tizen>
1075 public class KeyEventArgs : EventArgs
1080 /// Key - is the key sent to the view.
1082 /// <since_tizen> 3 </since_tizen>
1097 /// Event arguments that passed via the touch signal.
1099 /// <since_tizen> 3 </since_tizen>
1100 public class TouchEventArgs : EventArgs
1102 private Touch _touch;
1105 /// Touch - contains the information of touch points.
1107 /// <since_tizen> 3 </since_tizen>
1122 /// Event arguments that passed via the hover signal.
1124 /// <since_tizen> 3 </since_tizen>
1125 public class HoverEventArgs : EventArgs
1127 private Hover _hover;
1130 /// Hover - contains touch points that represent the points that are currently being hovered or the points where a hover has stopped.
1132 /// <since_tizen> 3 </since_tizen>
1147 /// Event arguments that passed via the wheel signal.
1149 /// <since_tizen> 3 </since_tizen>
1150 public class WheelEventArgs : EventArgs
1152 private Wheel _wheel;
1155 /// WheelEvent - store a wheel rolling type: MOUSE_WHEEL or CUSTOM_WHEEL.
1157 /// <since_tizen> 3 </since_tizen>
1172 /// Event arguments of visibility changed.
1174 /// <since_tizen> 3 </since_tizen>
1175 public class VisibilityChangedEventArgs : EventArgs
1178 private bool _visibility;
1179 private VisibilityChangeType _type;
1182 /// The view, or child of view, whose visibility has changed.
1184 /// <since_tizen> 3 </since_tizen>
1198 /// Whether the view is now visible or not.
1200 /// <since_tizen> 3 </since_tizen>
1201 public bool Visibility
1209 _visibility = value;
1214 /// Whether the view's visible property has changed or a parent's.
1216 /// <since_tizen> 3 </since_tizen>
1217 public VisibilityChangeType Type
1231 /// Event arguments of layout direction changed.
1233 /// <since_tizen> 4 </since_tizen>
1234 public class LayoutDirectionChangedEventArgs : EventArgs
1237 private ViewLayoutDirectionType _type;
1240 /// The view, or child of view, whose layout direction has changed.
1242 /// <since_tizen> 4 </since_tizen>
1256 /// Whether the view's layout direction property has changed or a parent's.
1258 /// <since_tizen> 4 </since_tizen>
1259 public ViewLayoutDirectionType Type
1272 internal class BackgroundResourceLoadedEventArgs : EventArgs
1274 private ResourceLoadingStatusType status = ResourceLoadingStatusType.Invalid;
1275 public ResourceLoadingStatusType Status
1289 /// The class represents the information of the situation where the View's control state changes.
1291 [EditorBrowsable(EditorBrowsableState.Never)]
1292 public class ControlStateChangedEventArgs : EventArgs
1295 /// Create an instance with mandatory fields.
1297 /// <param name="previousState">The previous control state.</param>
1298 /// <param name="currentState">The current control state.</param>
1299 [EditorBrowsable(EditorBrowsableState.Never)]
1300 public ControlStateChangedEventArgs(ControlState previousState, ControlState currentState)
1302 PreviousState = previousState;
1303 CurrentState = currentState;
1307 /// The previous control state.
1309 [EditorBrowsable(EditorBrowsableState.Never)]
1310 public ControlState PreviousState { get; }
1313 /// The current control state.
1315 [EditorBrowsable(EditorBrowsableState.Never)]
1316 public ControlState CurrentState { get; }
1319 private EventHandlerWithReturnType<object, WheelEventArgs, bool> WindowWheelEventHandler;
1320 private void OnWindowWheelEvent(object sender, Window.WheelEventArgs e)
1324 if (e.Wheel.Type == Wheel.WheelType.CustomWheel)
1326 var arg = new WheelEventArgs()
1330 WindowWheelEventHandler?.Invoke(this, arg);
1336 /// The expanded touch area.
1337 /// TouchArea can expand the view's touchable area.<br/>
1338 /// 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/>
1341 /// This is based on the top left x, y coordinates.<br/>
1342 /// For example) <br/>
1344 /// view.Size = new Size(100, 100);
1345 /// view.TouchAreaOffset = new Offset(-10, 20, 30, -40); // left, right, bottom, top
1347 /// Then, touch area is 130x170.<br/>
1348 /// This is view.width + TouchAreaOffset.right - TouchAreaOffset.left and view.height + TouchAreaOffset.bottom - TouchAreaOffset.top <br/>
1349 /// +---------------------+ <br/>
1355 /// | +----+----+ | <br/>
1357 /// | -10| | 20 | <br/>
1358 /// |<---+ +----->| <br/>
1361 /// | +----+----+ | <br/>
1366 /// +---------------------+ <br/>
1368 [EditorBrowsable(EditorBrowsableState.Never)]
1369 public Offset TouchAreaOffset
1373 return (Offset)GetValue(TouchAreaOffsetProperty);
1377 SetValue(TouchAreaOffsetProperty, value);
1378 NotifyPropertyChanged();
1382 private Offset InternalTouchAreaOffset
1386 Interop.ActorInternal.GetTouchAreaOffset(SwigCPtr, out int left, out int right, out int bottom, out int top);
1387 if (NDalicPINVOKE.SWIGPendingException.Pending)
1388 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1389 return new Offset(left, right, bottom, top);
1393 Interop.ActorInternal.SetTouchAreaOffset(SwigCPtr, value.Left, value.Right, value.Bottom, value.Top);
1394 if (NDalicPINVOKE.SWIGPendingException.Pending)
1395 throw NDalicPINVOKE.SWIGPendingException.Retrieve();