2 * Copyright(c) 2020 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;
21 using Tizen.NUI.Components;
23 namespace Tizen.NUI.BaseComponents
26 /// View is the base class for all views.
28 /// <since_tizen> 3 </since_tizen>
29 public partial class View
31 private EventHandler _offWindowEventHandler;
32 private OffWindowEventCallbackType _offWindowEventCallback;
33 private EventHandlerWithReturnType<object, WheelEventArgs, bool> _wheelEventHandler;
34 private WheelEventCallbackType _wheelEventCallback;
35 private EventHandlerWithReturnType<object, KeyEventArgs, bool> _keyEventHandler;
36 private KeyCallbackType _keyCallback;
37 private EventHandlerWithReturnType<object, TouchEventArgs, bool> _interceptTouchDataEventHandler;
38 private TouchDataCallbackType _interceptTouchDataCallback;
39 private EventHandlerWithReturnType<object, TouchEventArgs, bool> _touchDataEventHandler;
40 private TouchDataCallbackType _touchDataCallback;
41 private EventHandlerWithReturnType<object, HoverEventArgs, bool> _hoverEventHandler;
42 private HoverEventCallbackType _hoverEventCallback;
43 private EventHandler<VisibilityChangedEventArgs> _visibilityChangedEventHandler;
44 private VisibilityChangedEventCallbackType _visibilityChangedEventCallback;
45 private EventHandler _keyInputFocusGainedEventHandler;
46 private KeyInputFocusGainedCallbackType _keyInputFocusGainedCallback;
47 private EventHandler _keyInputFocusLostEventHandler;
48 private KeyInputFocusLostCallbackType _keyInputFocusLostCallback;
49 private EventHandler _onRelayoutEventHandler;
50 private OnRelayoutEventCallbackType _onRelayoutEventCallback;
51 private EventHandler _onWindowEventHandler;
52 private OnWindowEventCallbackType _onWindowEventCallback;
53 private EventHandler<LayoutDirectionChangedEventArgs> _layoutDirectionChangedEventHandler;
54 private LayoutDirectionChangedEventCallbackType _layoutDirectionChangedEventCallback;
55 // Resource Ready Signal
56 private EventHandler _resourcesLoadedEventHandler;
57 private ResourcesLoadedCallbackType _ResourcesLoadedCallback;
58 private EventHandler<BackgroundResourceLoadedEventArgs> _backgroundResourceLoadedEventHandler;
59 private _backgroundResourceLoadedCallbackType _backgroundResourceLoadedCallback;
61 private OnWindowEventCallbackType _onWindowSendEventCallback;
63 private void SendViewAddedEventToWindow(IntPtr data)
65 NUIApplication.GetDefaultWindow()?.SendViewAdded(this);
68 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
69 private delegate void OffWindowEventCallbackType(IntPtr control);
70 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
71 private delegate bool WheelEventCallbackType(IntPtr view, IntPtr wheelEvent);
72 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
73 private delegate bool KeyCallbackType(IntPtr control, IntPtr keyEvent);
74 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
75 private delegate bool TouchDataCallbackType(IntPtr view, IntPtr touchData);
76 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
77 private delegate bool HoverEventCallbackType(IntPtr view, IntPtr hoverEvent);
78 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
79 private delegate void VisibilityChangedEventCallbackType(IntPtr data, bool visibility, VisibilityChangeType type);
80 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
81 private delegate void ResourcesLoadedCallbackType(IntPtr control);
82 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
83 private delegate void _backgroundResourceLoadedCallbackType(IntPtr view);
84 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
85 private delegate void KeyInputFocusGainedCallbackType(IntPtr control);
86 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
87 private delegate void KeyInputFocusLostCallbackType(IntPtr control);
88 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
89 private delegate void OnRelayoutEventCallbackType(IntPtr control);
90 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
91 private delegate void OnWindowEventCallbackType(IntPtr control);
92 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
93 private delegate void LayoutDirectionChangedEventCallbackType(IntPtr data, ViewLayoutDirectionType type);
96 /// Event when a child is removed.
98 /// <since_tizen> 5 </since_tizen>
99 public new event EventHandler<ChildRemovedEventArgs> ChildRemoved;
101 /// Event when a child is added.
103 /// <since_tizen> 5 </since_tizen>
104 public new event EventHandler<ChildAddedEventArgs> ChildAdded;
107 /// An event for the KeyInputFocusGained signal which can be used to subscribe or unsubscribe the event handler provided by the user.<br />
108 /// The KeyInputFocusGained signal is emitted when the control gets the key input focus.<br />
110 /// <since_tizen> 3 </since_tizen>
111 public event EventHandler FocusGained
115 if (_keyInputFocusGainedEventHandler == null)
117 _keyInputFocusGainedCallback = OnKeyInputFocusGained;
118 var signal = KeyInputFocusGainedSignal();
119 signal?.Connect(_keyInputFocusGainedCallback);
122 _keyInputFocusGainedEventHandler += value;
126 _keyInputFocusGainedEventHandler -= value;
127 if (_keyInputFocusGainedEventHandler == null)
129 var signal = KeyInputFocusGainedSignal();
130 if (signal?.Empty() == false)
132 signal?.Disconnect(_keyInputFocusGainedCallback);
133 _keyInputFocusGainedCallback = null;
141 /// An event for the KeyInputFocusLost signal which can be used to subscribe or unsubscribe the event handler provided by the user.<br />
142 /// The KeyInputFocusLost signal is emitted when the control loses the key input focus.<br />
144 /// <since_tizen> 3 </since_tizen>
145 public event EventHandler FocusLost
149 if (_keyInputFocusLostEventHandler == null)
151 _keyInputFocusLostCallback = OnKeyInputFocusLost;
152 var signal = KeyInputFocusLostSignal();
153 signal?.Connect(_keyInputFocusLostCallback);
156 _keyInputFocusLostEventHandler += value;
160 _keyInputFocusLostEventHandler -= value;
161 if (_keyInputFocusLostEventHandler == null)
163 var signal = KeyInputFocusLostSignal();
164 if (signal?.Empty() == false)
166 signal?.Disconnect(_keyInputFocusLostCallback);
167 _keyInputFocusLostCallback = null;
175 /// An event for the KeyPressed signal which can be used to subscribe or unsubscribe the event handler provided by the user.<br />
176 /// The KeyPressed signal is emitted when the key event is received.<br />
178 /// <since_tizen> 3 </since_tizen>
179 public event EventHandlerWithReturnType<object, KeyEventArgs, bool> KeyEvent
183 if (_keyEventHandler == null)
185 _keyCallback = OnKeyEvent;
186 var signal = KeyEventSignal();
187 signal?.Connect(_keyCallback);
190 _keyEventHandler += value;
194 _keyEventHandler -= value;
195 if (_keyEventHandler == null)
197 var signal = KeyEventSignal();
198 if (signal?.Empty() == false)
200 signal?.Disconnect(_keyCallback);
209 /// An event for the OnRelayout signal which can be used to subscribe or unsubscribe the event handler.<br />
210 /// The OnRelayout signal is emitted after the size has been set on the view during relayout.<br />
212 /// <since_tizen> 3 </since_tizen>
213 public event EventHandler Relayout
217 if (_onRelayoutEventHandler == null)
219 _onRelayoutEventCallback = OnRelayout;
220 var signal = OnRelayoutSignal();
221 signal?.Connect(_onRelayoutEventCallback);
224 _onRelayoutEventHandler += value;
228 _onRelayoutEventHandler -= value;
229 if (_onRelayoutEventHandler == null)
231 var signal = OnRelayoutSignal();
232 if (signal?.Empty() == false)
234 signal?.Disconnect(_onRelayoutEventCallback);
235 _onRelayoutEventCallback = null;
243 /// An event for the touched signal which can be used to subscribe or unsubscribe the event handler provided by the user.<br />
244 /// The touched signal is emitted when the touch input is received.<br />
245 /// This can receive touch events before child. <br />
246 /// 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 />
248 [EditorBrowsable(EditorBrowsableState.Never)]
249 public event EventHandlerWithReturnType<object, TouchEventArgs, bool> InterceptTouchEvent
253 if (_interceptTouchDataEventHandler == null)
255 _interceptTouchDataCallback = OnInterceptTouch;
256 var signal = InterceptTouchSignal();
257 signal?.Connect(_interceptTouchDataCallback);
260 _interceptTouchDataEventHandler += value;
264 _interceptTouchDataEventHandler -= value;
265 if (_interceptTouchDataEventHandler == null)
267 var signal = InterceptTouchSignal();
268 if (signal?.Empty() == false)
270 signal?.Disconnect(_interceptTouchDataCallback);
271 _interceptTouchDataCallback = null;
279 /// If child view doesn't want the parent's view to intercept the touch, you can set it to true.
281 /// parent.Add(child);
282 /// parent.InterceptTouchEvent += OnInterceptTouchEvent;
283 /// View view = child.GetParent() as View;
284 /// view.DisallowInterceptTouchEvent = true;
285 /// This prevents the parent from interceping touch.
287 [EditorBrowsable(EditorBrowsableState.Never)]
288 public bool DisallowInterceptTouchEvent { get; set; }
292 /// An event for the touched signal which can be used to subscribe or unsubscribe the event handler provided by the user.<br />
293 /// The touched signal is emitted when the touch input is received.<br />
295 /// <since_tizen> 3 </since_tizen>
296 public event EventHandlerWithReturnType<object, TouchEventArgs, bool> TouchEvent
300 if (_touchDataEventHandler == null)
302 _touchDataCallback = OnTouch;
303 var signal = TouchSignal();
304 signal?.Connect(_touchDataCallback);
307 _touchDataEventHandler += value;
311 _touchDataEventHandler -= value;
312 if (_touchDataEventHandler == null)
314 var signal = TouchSignal();
315 if (signal?.Empty() == false)
317 signal?.Disconnect(_touchDataCallback);
318 _touchDataCallback = null;
326 /// An event for the hovered signal which can be used to subscribe or unsubscribe the event handler provided by the user.<br />
327 /// The hovered signal is emitted when the hover input is received.<br />
329 /// <since_tizen> 3 </since_tizen>
330 public event EventHandlerWithReturnType<object, HoverEventArgs, bool> HoverEvent
334 if (_hoverEventHandler == null)
336 _hoverEventCallback = OnHoverEvent;
337 var signal = HoveredSignal();
338 signal?.Connect(_hoverEventCallback);
341 _hoverEventHandler += value;
345 _hoverEventHandler -= value;
346 if (_hoverEventHandler == null)
348 var signal = HoveredSignal();
349 if (signal?.Empty() == false)
351 signal?.Disconnect(_hoverEventCallback);
352 _hoverEventCallback = null;
360 /// An event for the WheelMoved signal which can be used to subscribe or unsubscribe the event handler provided by the user.<br />
361 /// The WheelMoved signal is emitted when the wheel event is received.<br />
363 /// <since_tizen> 3 </since_tizen>
364 public event EventHandlerWithReturnType<object, WheelEventArgs, bool> WheelEvent
368 if (_wheelEventHandler == null)
370 _wheelEventCallback = OnWheelEvent;
371 var signal = WheelEventSignal();
372 signal?.Connect(_wheelEventCallback);
375 _wheelEventHandler += value;
377 if (WindowWheelEventHandler == null)
379 NUIApplication.GetDefaultWindow().WheelEvent += OnWindowWheelEvent;
381 WindowWheelEventHandler += value;
385 _wheelEventHandler -= value;
386 if (_wheelEventHandler == null)
388 var signal = WheelEventSignal();
389 if (signal?.Empty() == false)
391 signal?.Disconnect(_wheelEventCallback);
392 _wheelEventCallback = null;
397 WindowWheelEventHandler -= value;
398 if (WindowWheelEventHandler == null)
400 NUIApplication.GetDefaultWindow().WheelEvent -= OnWindowWheelEvent;
406 /// An event for the OnWindow signal which can be used to subscribe or unsubscribe the event handler.<br />
407 /// The OnWindow signal is emitted after the view has been connected to the window.<br />
409 /// <since_tizen> 3 </since_tizen>
410 public event EventHandler AddedToWindow
414 if (_onWindowEventHandler == null)
416 _onWindowEventCallback = OnWindow;
417 var signal = OnWindowSignal();
418 signal?.Connect(_onWindowEventCallback);
421 _onWindowEventHandler += value;
425 _onWindowEventHandler -= value;
426 if (_onWindowEventHandler == null)
428 var signal = OnWindowSignal();
429 if (signal?.Empty() == false)
431 signal?.Disconnect(_onWindowEventCallback);
432 _onWindowEventCallback = null;
440 /// An event for the OffWindow signal, which can be used to subscribe or unsubscribe the event handler.<br />
441 /// OffWindow signal is emitted after the view has been disconnected from the window.<br />
443 /// <since_tizen> 3 </since_tizen>
444 public event EventHandler RemovedFromWindow
448 if (_offWindowEventHandler == null)
450 _offWindowEventCallback = OffWindow;
451 var signal = OffWindowSignal();
452 signal?.Connect(_offWindowEventCallback);
455 _offWindowEventHandler += value;
459 _offWindowEventHandler -= value;
460 if (_offWindowEventHandler == null)
462 var signal = OffWindowSignal();
463 if (signal?.Empty() == false)
465 signal?.Disconnect(_offWindowEventCallback);
466 _offWindowEventCallback = null;
474 /// An event for visibility change which can be used to subscribe or unsubscribe the event handler.<br />
475 /// This signal is emitted when the visible property of this or a parent view is changed.<br />
477 /// <since_tizen> 3 </since_tizen>
478 public event EventHandler<VisibilityChangedEventArgs> VisibilityChanged
482 if (_visibilityChangedEventHandler == null)
484 _visibilityChangedEventCallback = OnVisibilityChanged;
485 var signal = VisibilityChangedSignal(this);
486 signal?.Connect(_visibilityChangedEventCallback);
489 _visibilityChangedEventHandler += value;
493 _visibilityChangedEventHandler -= value;
494 if (_visibilityChangedEventHandler == null)
496 var signal = VisibilityChangedSignal(this);
497 if (signal?.Empty() == false)
499 signal?.Disconnect(_visibilityChangedEventCallback);
500 _visibilityChangedEventCallback = null;
508 /// Event for layout direction change which can be used to subscribe/unsubscribe the event handler.<br />
509 /// This signal is emitted when the layout direction property of this or a parent view is changed.<br />
511 /// <since_tizen> 4 </since_tizen>
512 public event EventHandler<LayoutDirectionChangedEventArgs> LayoutDirectionChanged
516 if (_layoutDirectionChangedEventHandler == null)
518 _layoutDirectionChangedEventCallback = OnLayoutDirectionChanged;
519 var signal = LayoutDirectionChangedSignal(this);
520 signal?.Connect(_layoutDirectionChangedEventCallback);
523 _layoutDirectionChangedEventHandler += value;
527 _layoutDirectionChangedEventHandler -= value;
528 if (_layoutDirectionChangedEventHandler == null)
530 var signal = LayoutDirectionChangedSignal(this);
531 if (signal?.Empty() == false)
533 signal?.Disconnect(_layoutDirectionChangedEventCallback);
534 _layoutDirectionChangedEventCallback = null;
542 /// An event for the ResourcesLoadedSignal signal which can be used to subscribe or unsubscribe the event handler provided by the user.<br />
543 /// This signal is emitted after all resources required by a view are loaded and ready.<br />
545 /// <since_tizen> 3 </since_tizen>
546 public event EventHandler ResourcesLoaded
550 if (_resourcesLoadedEventHandler == null)
552 _ResourcesLoadedCallback = OnResourcesLoaded;
553 var signal = ResourcesLoadedSignal();
554 signal?.Connect(_ResourcesLoadedCallback);
557 _resourcesLoadedEventHandler += value;
561 _resourcesLoadedEventHandler -= value;
562 if (_resourcesLoadedEventHandler == null)
564 var signal = ResourcesLoadedSignal();
565 if (signal?.Empty() == false)
567 signal?.Disconnect(_ResourcesLoadedCallback);
568 _ResourcesLoadedCallback = null;
575 private EventHandler _backKeyPressed;
578 /// An event for getting notice when physical back key is pressed.<br />
579 /// This event is emitted BackKey is up.<br />
581 [EditorBrowsable(EditorBrowsableState.Never)]
582 public event EventHandler BackKeyPressed
586 _backKeyPressed += value;
587 BackKeyManager.Instance.Subscriber.Add(this);
592 BackKeyManager.Instance.Subscriber.Remove(this);
593 _backKeyPressed -= value;
598 /// Function for emitting BackKeyPressed event outside of View instance
600 [EditorBrowsable(EditorBrowsableState.Never)]
601 internal void EmitBackKeyPressed()
603 _backKeyPressed.Invoke(this, null);
607 internal event EventHandler<BackgroundResourceLoadedEventArgs> BackgroundResourceLoaded
611 if (_backgroundResourceLoadedEventHandler == null)
613 _backgroundResourceLoadedCallback = OnBackgroundResourceLoaded;
614 var signal = ResourcesLoadedSignal();
615 signal?.Connect(_backgroundResourceLoadedCallback);
618 _backgroundResourceLoadedEventHandler += value;
622 _backgroundResourceLoadedEventHandler -= value;
623 if (_backgroundResourceLoadedEventHandler == null)
625 var signal = ResourcesLoadedSignal();
626 if (signal?.Empty() == false)
628 signal?.Disconnect(_backgroundResourceLoadedCallback);
629 _backgroundResourceLoadedCallback = null;
636 internal TouchDataSignal InterceptTouchSignal()
638 TouchDataSignal ret = new TouchDataSignal(Interop.ActorSignal.Actor_InterceptTouchSignal(swigCPtr), false);
639 if (NDalicPINVOKE.SWIGPendingException.Pending)
640 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
644 internal TouchDataSignal TouchSignal()
646 TouchDataSignal ret = new TouchDataSignal(Interop.ActorSignal.Actor_TouchSignal(swigCPtr), false);
647 if (NDalicPINVOKE.SWIGPendingException.Pending)
648 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
652 internal HoverSignal HoveredSignal()
654 HoverSignal ret = new HoverSignal(Interop.ActorSignal.Actor_HoveredSignal(swigCPtr), false);
655 if (NDalicPINVOKE.SWIGPendingException.Pending)
656 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
660 internal WheelSignal WheelEventSignal()
662 WheelSignal ret = new WheelSignal(Interop.ActorSignal.Actor_WheelEventSignal(swigCPtr), false);
663 if (NDalicPINVOKE.SWIGPendingException.Pending)
664 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
668 internal ViewSignal OnWindowSignal()
670 ViewSignal ret = new ViewSignal(Interop.ActorSignal.Actor_OnSceneSignal(swigCPtr), false);
671 if (NDalicPINVOKE.SWIGPendingException.Pending)
672 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
676 internal ViewSignal OffWindowSignal()
678 ViewSignal ret = new ViewSignal(Interop.ActorSignal.Actor_OffSceneSignal(swigCPtr), false);
679 if (NDalicPINVOKE.SWIGPendingException.Pending)
680 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
684 internal ViewSignal OnRelayoutSignal()
686 ViewSignal ret = new ViewSignal(Interop.ActorSignal.Actor_OnRelayoutSignal(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.View_KeyEventSignal(swigCPtr), false);
716 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
720 internal KeyInputFocusSignal KeyInputFocusGainedSignal()
722 KeyInputFocusSignal ret = new KeyInputFocusSignal(Interop.ViewSignal.View_KeyInputFocusGainedSignal(swigCPtr), false);
723 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
727 internal KeyInputFocusSignal KeyInputFocusLostSignal()
729 KeyInputFocusSignal ret = new KeyInputFocusSignal(Interop.ViewSignal.View_KeyInputFocusLostSignal(swigCPtr), false);
730 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
734 private void OnSize2DChanged(int? width, int? height)
738 Tizen.NUI.Object.SetProperty(this.swigCPtr, View.Property.SIZE_WIDTH, new Tizen.NUI.PropertyValue((float)width));
742 Tizen.NUI.Object.SetProperty(this.swigCPtr, View.Property.SIZE_HEIGHT, new Tizen.NUI.PropertyValue((float)height));
746 private void OnMinimumSizeChanged(int? width, int? height)
748 if (width != null && height != null)
750 MinimumSize = new Size2D((int)width, (int)height);
752 else if (width != null && height == null)
754 MinimumSize = new Size2D((int)width, (int)this.GetMinimumSize().Height);
756 else if (width == null && height != null)
758 MinimumSize = new Size2D((int)this.GetMinimumSize().Width, (int)height);
762 //both are null, do nothing.
766 private void OnMaximumSizeChanged(int? width, int? height)
768 if (width != null && height != null)
770 MaximumSize = new Size2D((int)width, (int)height);
772 else if (width != null && height == null)
774 MaximumSize = new Size2D((int)width, (int)this.GetMaximumSize().Height);
776 else if (width == null && height != null)
778 MaximumSize = new Size2D((int)this.GetMaximumSize().Width, (int)height);
782 //both are null, do nothing.
786 private void OnPosition2DChanged(int x, int y)
788 Position2D = new Position2D(x, y);
791 private void OnSizeChanged(float? width, float? height, float? depth)
795 Tizen.NUI.Object.SetProperty(this.swigCPtr, View.Property.SIZE_WIDTH, new Tizen.NUI.PropertyValue((float)width));
799 Tizen.NUI.Object.SetProperty(this.swigCPtr, View.Property.SIZE_HEIGHT, new Tizen.NUI.PropertyValue((float)height));
803 Tizen.NUI.Object.SetProperty(this.swigCPtr, View.Property.SIZE_DEPTH, new Tizen.NUI.PropertyValue((float)depth));
807 private void OnPositionChanged(float x, float y, float z)
809 Position = new Position(x, y, z);
812 private void OnParentOriginChanged(float x, float y, float z)
814 ParentOrigin = new Position(x, y, z);
817 private void OnPivotPointChanged(float x, float y, float z)
819 PivotPoint = new Position(x, y, z);
822 private void OnImageShadowChanged(ShadowBase instance)
824 ImageShadow = (ImageShadow)instance;
827 private void OnBoxShadowChanged(ShadowBase instance)
829 BoxShadow = (Shadow)instance;
832 private void OnBackgroundImageBorderChanged(int left, int right, int bottom, int top)
834 BackgroundImageBorder = new Rectangle(left, right, bottom, top);
837 private void OnKeyInputFocusGained(IntPtr view)
839 if (_keyInputFocusGainedEventHandler != null)
841 _keyInputFocusGainedEventHandler(this, null);
845 private void OnKeyInputFocusLost(IntPtr view)
847 if (_keyInputFocusLostEventHandler != null)
849 _keyInputFocusLostEventHandler(this, null);
853 private bool OnKeyEvent(IntPtr view, IntPtr keyEvent)
855 if (keyEvent == global::System.IntPtr.Zero)
857 NUILog.Error("keyEvent should not be null!");
861 KeyEventArgs e = new KeyEventArgs();
865 e.Key = Tizen.NUI.Key.GetKeyFromPtr(keyEvent);
867 if (_keyEventHandler != null)
869 Delegate[] delegateList = _keyEventHandler.GetInvocationList();
871 // Oring the result of each callback.
872 foreach (EventHandlerWithReturnType<object, KeyEventArgs, bool> del in delegateList)
874 result |= del(this, e);
881 // Callback for View OnRelayout signal
882 private void OnRelayout(IntPtr data)
884 if (_onRelayoutEventHandler != null)
886 _onRelayoutEventHandler(this, null);
890 // Callback for View TouchSignal
891 private bool OnInterceptTouch(IntPtr view, IntPtr touchData)
893 if (touchData == global::System.IntPtr.Zero)
895 NUILog.Error("touchData should not be null!");
899 // DisallowInterceptTouchEvent prevents the parent from intercepting touch.
900 if (DisallowInterceptTouchEvent)
905 TouchEventArgs e = new TouchEventArgs();
907 e.Touch = Tizen.NUI.Touch.GetTouchFromPtr(touchData);
909 bool consumed = false;
911 if (_interceptTouchDataEventHandler != null)
913 consumed = _interceptTouchDataEventHandler(this, e);
919 // Callback for View TouchSignal
920 private bool OnTouch(IntPtr view, IntPtr touchData)
922 if (touchData == global::System.IntPtr.Zero)
924 NUILog.Error("touchData should not be null!");
928 TouchEventArgs e = new TouchEventArgs();
930 e.Touch = Tizen.NUI.Touch.GetTouchFromPtr(touchData);
932 bool consumed = false;
934 if (_touchDataEventHandler != null)
936 consumed = _touchDataEventHandler(this, e);
939 if (enableControlState && !consumed)
941 consumed = HandleControlStateOnTouch(e.Touch);
947 // Callback for View Hover signal
948 private bool OnHoverEvent(IntPtr view, IntPtr hoverEvent)
950 if (hoverEvent == global::System.IntPtr.Zero)
952 NUILog.Error("hoverEvent should not be null!");
956 HoverEventArgs e = new HoverEventArgs();
958 e.Hover = Tizen.NUI.Hover.GetHoverFromPtr(hoverEvent);
960 if (_hoverEventHandler != null)
962 return _hoverEventHandler(this, e);
967 // Callback for View Wheel signal
968 private bool OnWheelEvent(IntPtr view, IntPtr wheelEvent)
970 if (wheelEvent == global::System.IntPtr.Zero)
972 NUILog.Error("wheelEvent should not be null!");
976 WheelEventArgs e = new WheelEventArgs();
978 e.Wheel = Tizen.NUI.Wheel.GetWheelFromPtr(wheelEvent);
980 if (_wheelEventHandler != null)
982 return _wheelEventHandler(this, e);
987 // Callback for View OnWindow signal
988 private void OnWindow(IntPtr data)
990 if (_onWindowEventHandler != null)
992 _onWindowEventHandler(this, null);
996 // Callback for View OffWindow signal
997 private void OffWindow(IntPtr data)
999 if (_offWindowEventHandler != null)
1001 _offWindowEventHandler(this, null);
1005 // Callback for View visibility change signal
1006 private void OnVisibilityChanged(IntPtr data, bool visibility, VisibilityChangeType type)
1008 VisibilityChangedEventArgs e = new VisibilityChangedEventArgs();
1011 e.View = Registry.GetManagedBaseHandleFromNativePtr(data) as View;
1013 e.Visibility = visibility;
1016 if (_visibilityChangedEventHandler != null)
1018 _visibilityChangedEventHandler(this, e);
1022 // Callback for View layout direction change signal
1023 private void OnLayoutDirectionChanged(IntPtr data, ViewLayoutDirectionType type)
1025 LayoutDirectionChangedEventArgs e = new LayoutDirectionChangedEventArgs();
1028 e.View = Registry.GetManagedBaseHandleFromNativePtr(data) as View;
1032 if (_layoutDirectionChangedEventHandler != null)
1034 _layoutDirectionChangedEventHandler(this, e);
1038 private void OnResourcesLoaded(IntPtr view)
1040 if (_resourcesLoadedEventHandler != null)
1042 _resourcesLoadedEventHandler(this, null);
1046 private void OnBackgroundResourceLoaded(IntPtr view)
1048 BackgroundResourceLoadedEventArgs e = new BackgroundResourceLoadedEventArgs();
1049 e.Status = (ResourceLoadingStatusType)Interop.View.View_GetVisualResourceStatus(this.swigCPtr, Property.BACKGROUND);
1051 if (_backgroundResourceLoadedEventHandler != null)
1053 _backgroundResourceLoadedEventHandler(this, e);
1058 /// Event argument passed through the ChildAdded event.
1060 /// <since_tizen> 5 </since_tizen>
1061 public class ChildAddedEventArgs : EventArgs
1064 /// Added child view at moment.
1066 /// <since_tizen> 5 </since_tizen>
1067 public View Added { get; set; }
1071 /// Event argument passed through the ChildRemoved event.
1073 /// <since_tizen> 5 </since_tizen>
1074 public class ChildRemovedEventArgs : EventArgs
1077 /// Removed child view at moment.
1079 /// <since_tizen> 5 </since_tizen>
1080 public View Removed { get; set; }
1084 /// Event arguments that passed via the KeyEvent signal.
1086 /// <since_tizen> 3 </since_tizen>
1087 public class KeyEventArgs : EventArgs
1092 /// Key - is the key sent to the view.
1094 /// <since_tizen> 3 </since_tizen>
1109 /// Event arguments that passed via the touch signal.
1111 /// <since_tizen> 3 </since_tizen>
1112 public class TouchEventArgs : EventArgs
1114 private Touch _touch;
1117 /// Touch - contains the information of touch points.
1119 /// <since_tizen> 3 </since_tizen>
1134 /// Event arguments that passed via the hover signal.
1136 /// <since_tizen> 3 </since_tizen>
1137 public class HoverEventArgs : EventArgs
1139 private Hover _hover;
1142 /// Hover - contains touch points that represent the points that are currently being hovered or the points where a hover has stopped.
1144 /// <since_tizen> 3 </since_tizen>
1159 /// Event arguments that passed via the wheel signal.
1161 /// <since_tizen> 3 </since_tizen>
1162 public class WheelEventArgs : EventArgs
1164 private Wheel _wheel;
1167 /// WheelEvent - store a wheel rolling type: MOUSE_WHEEL or CUSTOM_WHEEL.
1169 /// <since_tizen> 3 </since_tizen>
1184 /// Event arguments of visibility changed.
1186 /// <since_tizen> 3 </since_tizen>
1187 public class VisibilityChangedEventArgs : EventArgs
1190 private bool _visibility;
1191 private VisibilityChangeType _type;
1194 /// The view, or child of view, whose visibility has changed.
1196 /// <since_tizen> 3 </since_tizen>
1210 /// Whether the view is now visible or not.
1212 /// <since_tizen> 3 </since_tizen>
1213 public bool Visibility
1221 _visibility = value;
1226 /// Whether the view's visible property has changed or a parent's.
1228 /// <since_tizen> 3 </since_tizen>
1229 public VisibilityChangeType Type
1243 /// Event arguments of layout direction changed.
1245 /// <since_tizen> 4 </since_tizen>
1246 public class LayoutDirectionChangedEventArgs : EventArgs
1249 private ViewLayoutDirectionType _type;
1252 /// The view, or child of view, whose layout direction has changed.
1254 /// <since_tizen> 4 </since_tizen>
1268 /// Whether the view's layout direction property has changed or a parent's.
1270 /// <since_tizen> 4 </since_tizen>
1271 public ViewLayoutDirectionType Type
1284 internal class BackgroundResourceLoadedEventArgs : EventArgs
1286 private ResourceLoadingStatusType status = ResourceLoadingStatusType.Invalid;
1287 public ResourceLoadingStatusType Status
1301 /// The class represents the information of the situation where the View's control state changes.
1303 [EditorBrowsable(EditorBrowsableState.Never)]
1304 public class ControlStateChangedEventArgs : EventArgs
1307 /// Create an instance with mandatory fields.
1309 /// <param name="previousState">The previous control state.</param>
1310 /// <param name="currentState">The current control state.</param>
1311 [EditorBrowsable(EditorBrowsableState.Never)]
1312 public ControlStateChangedEventArgs(ControlState previousState, ControlState currentState)
1314 PreviousState = previousState;
1315 CurrentState = currentState;
1319 /// The previous control state.
1321 [EditorBrowsable(EditorBrowsableState.Never)]
1322 public ControlState PreviousState { get; }
1325 /// The current control state.
1327 [EditorBrowsable(EditorBrowsableState.Never)]
1328 public ControlState CurrentState { get; }
1331 private EventHandlerWithReturnType<object, WheelEventArgs, bool> WindowWheelEventHandler;
1332 private void OnWindowWheelEvent(object sender, Window.WheelEventArgs e)
1336 if (e.Wheel.Type == Wheel.WheelType.CustomWheel)
1338 var arg = new WheelEventArgs()
1342 WindowWheelEventHandler?.Invoke(this, arg);
1348 /// TouchArea can expand the view's touchable area.<br/>
1349 /// 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/>
1350 /// This is based on the top left x, y coordinates.<br/>
1352 /// view.Size = new Size(100, 100);<br/>
1353 /// view.TouchAreaOffset = new Offset(-10, 20, 30, -40); // left, right, bottom, top <br/>
1354 /// then touch area is 130x170.<br/>
1355 /// this is view.width + TouchAreaOffset.right - TouchAreaOffset.left and view.height + TouchAreaOffset.bottom - TouchAreaOffset.top <br/>
1356 /// +---------------------+ <br/>
1362 /// | +----+----+ | <br/>
1364 /// | -10| | 20 | <br/>
1365 /// |<---+ +----->| <br/>
1368 /// | +----+----+ | <br/>
1373 /// +---------------------+ <br/>
1375 [EditorBrowsable(EditorBrowsableState.Never)]
1376 public Offset TouchAreaOffset
1380 Interop.ActorInternal.GetTouchAreaOffset(SwigCPtr, out int left, out int right, out int bottom, out int top);
1381 if (NDalicPINVOKE.SWIGPendingException.Pending)
1382 throw NDalicPINVOKE.SWIGPendingException.Retrieve();
1383 return new Offset(left, right, bottom, top);
1387 Interop.ActorInternal.SetTouchAreaOffset(SwigCPtr, value.Left, value.Right, value.Bottom, value.Top);
1388 if (NDalicPINVOKE.SWIGPendingException.Pending)
1389 throw NDalicPINVOKE.SWIGPendingException.Retrieve();