X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=src%2FTizen.NUI%2Fsrc%2Fpublic%2FBaseComponents%2FViewEvent.cs;h=6645c13ba541d288e07538ef483eef735d0ad5e9;hb=e775c059fe36a4630c2152d6c8a52c0a229c8613;hp=be6d4bd39ddfd0bf27d7eb112a76113d6f0a2839;hpb=c10ed3620b766c7a7893f514c5623d82e8dc205b;p=platform%2Fcore%2Fcsapi%2Ftizenfx.git diff --git a/src/Tizen.NUI/src/public/BaseComponents/ViewEvent.cs b/src/Tizen.NUI/src/public/BaseComponents/ViewEvent.cs index be6d4bd..6645c13 100755 --- a/src/Tizen.NUI/src/public/BaseComponents/ViewEvent.cs +++ b/src/Tizen.NUI/src/public/BaseComponents/ViewEvent.cs @@ -42,8 +42,10 @@ namespace Tizen.NUI.BaseComponents private EventHandler visibilityChangedEventHandler; private VisibilityChangedEventCallbackType visibilityChangedEventCallback; private EventHandler keyInputFocusGainedEventHandler; + private KeyInputFocusGainedCallbackType keyInputFocusGainedCallback; private EventHandler keyInputFocusLostEventHandler; + private KeyInputFocusLostCallbackType keyInputFocusLostCallback; private EventHandler onRelayoutEventHandler; private OnRelayoutEventCallbackType onRelayoutEventCallback; @@ -80,10 +82,12 @@ namespace Tizen.NUI.BaseComponents private delegate void ResourcesLoadedCallbackType(IntPtr control); [UnmanagedFunctionPointer(CallingConvention.StdCall)] private delegate void _backgroundResourceLoadedCallbackType(IntPtr view); - [UnmanagedFunctionPointer(CallingConvention.StdCall)] + + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] private delegate void KeyInputFocusGainedCallbackType(IntPtr control); - [UnmanagedFunctionPointer(CallingConvention.StdCall)] + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] private delegate void KeyInputFocusLostCallbackType(IntPtr control); + [UnmanagedFunctionPointer(CallingConvention.StdCall)] private delegate void OnRelayoutEventCallbackType(IntPtr control); [UnmanagedFunctionPointer(CallingConvention.StdCall)] @@ -91,22 +95,6 @@ namespace Tizen.NUI.BaseComponents [UnmanagedFunctionPointer(CallingConvention.StdCall)] private delegate void LayoutDirectionChangedEventCallbackType(IntPtr data, ViewLayoutDirectionType type); - private ViewSignal offWindowSignal; - private WheelSignal wheelEventSignal; - private ControlKeySignal keyEventSignal; - private TouchDataSignal interceptTouchSignal; - private TouchDataSignal touchSignal; - private HoverSignal hoveredSignal; - private ViewVisibilityChangedSignal visibilityChangedSignal; - private KeyInputFocusSignal keyInputFocusGainedSignal; - private KeyInputFocusSignal keyInputFocusLostSignal; - private ViewSignal onRelayoutSignal; - private ViewSignal onWindowSignal; - private ViewLayoutDirectionChangedSignal layoutDirectionChangedSignal; - private ViewSignal resourcesLoadedSignal; - private ViewSignal backgroundResourcesLoadedSignal; - private ViewSignal onWindowSendSignal; - /// /// Event when a child is removed. /// @@ -130,23 +118,27 @@ namespace Tizen.NUI.BaseComponents if (keyInputFocusGainedEventHandler == null) { keyInputFocusGainedCallback = OnKeyInputFocusGained; - keyInputFocusGainedSignal = this.KeyInputFocusGainedSignal(); - keyInputFocusGainedSignal?.Connect(keyInputFocusGainedCallback); + using KeyInputFocusSignal signal = new KeyInputFocusSignal(Interop.ViewSignal.KeyInputFocusGainedSignal(SwigCPtr), false); + signal?.Connect(keyInputFocusGainedCallback); } - keyInputFocusGainedEventHandler += value; } remove { keyInputFocusGainedEventHandler -= value; - - if (keyInputFocusGainedEventHandler == null && keyInputFocusGainedSignal?.Empty() == false) + if (keyInputFocusGainedEventHandler == null) { - keyInputFocusGainedSignal?.Disconnect(keyInputFocusGainedCallback); - keyInputFocusGainedSignal?.Dispose(); - keyInputFocusGainedSignal = null; - keyInputFocusGainedCallback = null; + using KeyInputFocusSignal signal = new KeyInputFocusSignal(Interop.ViewSignal.KeyInputFocusGainedSignal(SwigCPtr), false); + + if (keyInputFocusGainedCallback != null) + { + signal?.Disconnect(keyInputFocusGainedCallback); + if (signal?.Empty() == true) + { + keyInputFocusGainedCallback = null; + } + } } } } @@ -163,23 +155,27 @@ namespace Tizen.NUI.BaseComponents if (keyInputFocusLostEventHandler == null) { keyInputFocusLostCallback = OnKeyInputFocusLost; - keyInputFocusLostSignal = this.KeyInputFocusLostSignal(); - keyInputFocusLostSignal?.Connect(keyInputFocusLostCallback); + using KeyInputFocusSignal signal = new KeyInputFocusSignal(Interop.ViewSignal.KeyInputFocusLostSignal(SwigCPtr), false); + signal?.Connect(keyInputFocusLostCallback); } - keyInputFocusLostEventHandler += value; } remove { keyInputFocusLostEventHandler -= value; - - if (keyInputFocusLostEventHandler == null && keyInputFocusLostSignal?.Empty() == false) + if (keyInputFocusLostEventHandler == null) { - keyInputFocusLostSignal?.Disconnect(keyInputFocusLostCallback); - keyInputFocusLostSignal?.Dispose(); - keyInputFocusLostSignal = null; - keyInputFocusLostCallback = null; + using KeyInputFocusSignal signal = new KeyInputFocusSignal(Interop.ViewSignal.KeyInputFocusLostSignal(SwigCPtr), false); + + if (keyInputFocusLostCallback != null) + { + signal?.Disconnect(keyInputFocusLostCallback); + if (signal?.Empty() == true) + { + keyInputFocusLostCallback = null; + } + } } } } @@ -196,23 +192,23 @@ namespace Tizen.NUI.BaseComponents if (keyEventHandler == null) { keyCallback = OnKeyEvent; - keyEventSignal = this.KeyEventSignal(); - keyEventSignal?.Connect(keyCallback); + using ControlKeySignal signal = new ControlKeySignal(Interop.ViewSignal.KeyEventSignal(SwigCPtr), false); + signal?.Connect(keyCallback); } - keyEventHandler += value; } remove { keyEventHandler -= value; - - if (keyEventHandler == null && keyEventSignal?.Empty() == false) + if (keyEventHandler == null) { - keyEventSignal?.Disconnect(keyCallback); - keyEventSignal?.Dispose(); - keyEventSignal = null; - keyCallback = null; + using ControlKeySignal signal = new ControlKeySignal(Interop.ViewSignal.KeyEventSignal(SwigCPtr), false); + if (signal?.Empty() == false) + { + signal?.Disconnect(keyCallback); + keyCallback = null; + } } } } @@ -229,23 +225,23 @@ namespace Tizen.NUI.BaseComponents if (onRelayoutEventHandler == null) { onRelayoutEventCallback = OnRelayout; - onRelayoutSignal = this.OnRelayoutSignal(); - onRelayoutSignal?.Connect(onRelayoutEventCallback); + using ViewSignal signal = new ViewSignal(Interop.ActorSignal.ActorOnRelayoutSignal(SwigCPtr), false); + signal?.Connect(onRelayoutEventCallback); } - onRelayoutEventHandler += value; } remove { onRelayoutEventHandler -= value; - - if (onRelayoutEventHandler == null && onRelayoutSignal?.Empty() == false) + if (onRelayoutEventHandler == null) { - onRelayoutSignal?.Disconnect(onRelayoutEventCallback); - onRelayoutSignal?.Dispose(); - onRelayoutSignal = null; - onRelayoutEventCallback = null; + using ViewSignal signal = new ViewSignal(Interop.ActorSignal.ActorOnRelayoutSignal(SwigCPtr), false); + if (signal?.Empty() == false) + { + signal?.Disconnect(onRelayoutEventCallback); + onRelayoutEventCallback = null; + } } } } @@ -264,23 +260,23 @@ namespace Tizen.NUI.BaseComponents if (interceptTouchDataEventHandler == null) { interceptTouchDataCallback = OnInterceptTouch; - interceptTouchSignal = this.InterceptTouchSignal(); - interceptTouchSignal?.Connect(interceptTouchDataCallback); + using TouchDataSignal signal = new TouchDataSignal(Interop.ActorSignal.ActorInterceptTouchSignal(SwigCPtr), false); + signal?.Connect(interceptTouchDataCallback); } - interceptTouchDataEventHandler += value; } remove { interceptTouchDataEventHandler -= value; - - if (interceptTouchDataEventHandler == null && interceptTouchSignal?.Empty() == false) + if (interceptTouchDataEventHandler == null) { - interceptTouchSignal?.Disconnect(interceptTouchDataCallback); - interceptTouchSignal?.Dispose(); - interceptTouchSignal = null; - interceptTouchDataCallback = null; + using TouchDataSignal signal = new TouchDataSignal(Interop.ActorSignal.ActorInterceptTouchSignal(SwigCPtr), false); + if (signal?.Empty() == false) + { + signal?.Disconnect(interceptTouchDataCallback); + interceptTouchDataCallback = null; + } } } } @@ -292,7 +288,7 @@ namespace Tizen.NUI.BaseComponents /// parent.InterceptTouchEvent += OnInterceptTouchEvent; /// View view = child.GetParent() as View; /// view.DisallowInterceptTouchEvent = true; - /// This prevents the parent from interceping touch. + /// This prevents the parent from intercepting touch. /// [EditorBrowsable(EditorBrowsableState.Never)] public bool DisallowInterceptTouchEvent { get; set; } @@ -310,23 +306,23 @@ namespace Tizen.NUI.BaseComponents if (touchDataEventHandler == null) { touchDataCallback = OnTouch; - touchSignal = this.TouchSignal(); - touchSignal?.Connect(touchDataCallback); + using TouchDataSignal signal = new TouchDataSignal(Interop.ActorSignal.ActorTouchSignal(SwigCPtr), false); + signal.Connect(touchDataCallback); } - touchDataEventHandler += value; } remove { touchDataEventHandler -= value; - - if (touchDataEventHandler == null && touchSignal?.Empty() == false) + if (touchDataEventHandler == null) { - touchSignal?.Disconnect(touchDataCallback); - touchSignal?.Dispose(); - touchSignal = null; - touchDataCallback = null; + using TouchDataSignal signal = new TouchDataSignal(Interop.ActorSignal.ActorTouchSignal(SwigCPtr), false); + if (signal.Empty() == false) + { + signal.Disconnect(touchDataCallback); + touchDataCallback = null; + } } } } @@ -343,23 +339,23 @@ namespace Tizen.NUI.BaseComponents if (hoverEventHandler == null) { hoverEventCallback = OnHoverEvent; - hoveredSignal = this.HoveredSignal(); - hoveredSignal?.Connect(hoverEventCallback); + using HoverSignal signal = new HoverSignal(Interop.ActorSignal.ActorHoveredSignal(SwigCPtr), false); + signal?.Connect(hoverEventCallback); } - hoverEventHandler += value; } remove { hoverEventHandler -= value; - - if (hoverEventHandler == null && hoveredSignal?.Empty() == false) + if (hoverEventHandler == null) { - hoveredSignal?.Disconnect(hoverEventCallback); - hoveredSignal?.Dispose(); - hoveredSignal = null; - hoverEventCallback = null; + using HoverSignal signal = new HoverSignal(Interop.ActorSignal.ActorHoveredSignal(SwigCPtr), false); + if (signal?.Empty() == false) + { + signal?.Disconnect(hoverEventCallback); + hoverEventCallback = null; + } } } } @@ -376,10 +372,9 @@ namespace Tizen.NUI.BaseComponents if (wheelEventHandler == null) { wheelEventCallback = OnWheelEvent; - wheelEventSignal = this.WheelEventSignal(); - wheelEventSignal?.Connect(wheelEventCallback); + using WheelSignal signal = new WheelSignal(Interop.ActorSignal.ActorWheelEventSignal(SwigCPtr), false); + signal?.Connect(wheelEventCallback); } - wheelEventHandler += value; if (WindowWheelEventHandler == null) @@ -392,13 +387,14 @@ namespace Tizen.NUI.BaseComponents remove { wheelEventHandler -= value; - - if (wheelEventHandler == null && wheelEventSignal?.Empty() == false) + if (wheelEventHandler == null) { - wheelEventSignal?.Disconnect(wheelEventCallback); - wheelEventSignal?.Dispose(); - wheelEventSignal = null; - wheelEventCallback = null; + using WheelSignal signal = new WheelSignal(Interop.ActorSignal.ActorWheelEventSignal(SwigCPtr), false); + if (signal?.Empty() == false) + { + signal?.Disconnect(wheelEventCallback); + wheelEventCallback = null; + } } WindowWheelEventHandler -= value; @@ -421,23 +417,23 @@ namespace Tizen.NUI.BaseComponents if (onWindowEventHandler == null) { onWindowEventCallback = OnWindow; - onWindowSignal = this.OnWindowSignal(); - onWindowSignal?.Connect(onWindowEventCallback); + using ViewSignal signal = new ViewSignal(Interop.ActorSignal.ActorOnSceneSignal(SwigCPtr), false); + signal?.Connect(onWindowEventCallback); } - onWindowEventHandler += value; } remove { onWindowEventHandler -= value; - - if (onWindowEventHandler == null && onWindowSignal?.Empty() == false) + if (onWindowEventHandler == null) { - onWindowSignal?.Disconnect(onWindowEventCallback); - onWindowSignal?.Dispose(); - onWindowSignal = null; - onWindowEventCallback = null; + using ViewSignal signal = new ViewSignal(Interop.ActorSignal.ActorOnSceneSignal(SwigCPtr), false); + if (signal?.Empty() == false) + { + signal?.Disconnect(onWindowEventCallback); + onWindowEventCallback = null; + } } } } @@ -454,23 +450,23 @@ namespace Tizen.NUI.BaseComponents if (offWindowEventHandler == null) { offWindowEventCallback = OffWindow; - offWindowSignal = this.OffWindowSignal(); - offWindowSignal?.Connect(offWindowEventCallback); + using ViewSignal signal = new ViewSignal(Interop.ActorSignal.ActorOffSceneSignal(SwigCPtr), false); + signal?.Connect(offWindowEventCallback); } - offWindowEventHandler += value; } remove { offWindowEventHandler -= value; - - if (offWindowEventHandler == null && offWindowSignal?.Empty() == false) + if (offWindowEventHandler == null) { - offWindowSignal?.Disconnect(offWindowEventCallback); - offWindowSignal.Dispose(); - offWindowSignal = null; - offWindowEventCallback = null; + using ViewSignal signal = new ViewSignal(Interop.ActorSignal.ActorOffSceneSignal(SwigCPtr), false); + if (signal?.Empty() == false) + { + signal?.Disconnect(offWindowEventCallback); + offWindowEventCallback = null; + } } } } @@ -487,8 +483,7 @@ namespace Tizen.NUI.BaseComponents if (visibilityChangedEventHandler == null) { visibilityChangedEventCallback = OnVisibilityChanged; - visibilityChangedSignal = this.VisibilityChangedSignal(this); - visibilityChangedSignal?.Connect(visibilityChangedEventCallback); + VisibilityChangedSignal(this).Connect(visibilityChangedEventCallback); } visibilityChangedEventHandler += value; @@ -498,12 +493,9 @@ namespace Tizen.NUI.BaseComponents { visibilityChangedEventHandler -= value; - if (visibilityChangedEventHandler == null && visibilityChangedSignal?.Empty() == false) + if (visibilityChangedEventHandler == null && VisibilityChangedSignal(this).Empty() == false) { - visibilityChangedSignal?.Disconnect(visibilityChangedEventCallback); - visibilityChangedSignal?.Dispose(); - visibilityChangedSignal = null; - visibilityChangedEventCallback = null; + VisibilityChangedSignal(this).Disconnect(visibilityChangedEventCallback); } } } @@ -520,8 +512,7 @@ namespace Tizen.NUI.BaseComponents if (layoutDirectionChangedEventHandler == null) { layoutDirectionChangedEventCallback = OnLayoutDirectionChanged; - layoutDirectionChangedSignal = this.LayoutDirectionChangedSignal(this); - layoutDirectionChangedSignal?.Connect(layoutDirectionChangedEventCallback); + LayoutDirectionChangedSignal(this).Connect(layoutDirectionChangedEventCallback); } layoutDirectionChangedEventHandler += value; @@ -531,12 +522,9 @@ namespace Tizen.NUI.BaseComponents { layoutDirectionChangedEventHandler -= value; - if (layoutDirectionChangedEventHandler == null && layoutDirectionChangedSignal?.Empty() == false) + if (layoutDirectionChangedEventHandler == null && LayoutDirectionChangedSignal(this).Empty() == false) { - layoutDirectionChangedSignal?.Disconnect(layoutDirectionChangedEventCallback); - layoutDirectionChangedSignal?.Dispose(); - layoutDirectionChangedSignal = null; - layoutDirectionChangedEventCallback = null; + LayoutDirectionChangedSignal(this).Disconnect(layoutDirectionChangedEventCallback); } } } @@ -553,23 +541,23 @@ namespace Tizen.NUI.BaseComponents if (resourcesLoadedEventHandler == null) { ResourcesLoadedCallback = OnResourcesLoaded; - resourcesLoadedSignal = this.ResourcesLoadedSignal(); - resourcesLoadedSignal?.Connect(ResourcesLoadedCallback); + using ViewSignal signal = new ViewSignal(Interop.View.ResourceReadySignal(SwigCPtr), false); + signal?.Connect(ResourcesLoadedCallback); } - resourcesLoadedEventHandler += value; } remove { resourcesLoadedEventHandler -= value; - - if (resourcesLoadedEventHandler == null && resourcesLoadedSignal?.Empty() == false) + if (resourcesLoadedEventHandler == null) { - resourcesLoadedSignal?.Disconnect(ResourcesLoadedCallback); - resourcesLoadedSignal?.Dispose(); - resourcesLoadedSignal = null; - ResourcesLoadedCallback = null; + using ViewSignal signal = new ViewSignal(Interop.View.ResourceReadySignal(SwigCPtr), false); + if (signal?.Empty() == false) + { + signal?.Disconnect(ResourcesLoadedCallback); + ResourcesLoadedCallback = null; + } } } } @@ -613,22 +601,23 @@ namespace Tizen.NUI.BaseComponents if (backgroundResourceLoadedEventHandler == null) { backgroundResourceLoadedCallback = OnBackgroundResourceLoaded; - backgroundResourcesLoadedSignal = this.ResourcesLoadedSignal(); - backgroundResourcesLoadedSignal?.Connect(backgroundResourceLoadedCallback); + using ViewSignal signal = new ViewSignal(Interop.View.ResourceReadySignal(SwigCPtr), false); + signal?.Connect(backgroundResourceLoadedCallback); } - backgroundResourceLoadedEventHandler += value; } + remove { backgroundResourceLoadedEventHandler -= value; - - if (backgroundResourceLoadedEventHandler == null && backgroundResourcesLoadedSignal?.Empty() == false) + if (backgroundResourceLoadedEventHandler == null) { - backgroundResourcesLoadedSignal?.Disconnect(backgroundResourceLoadedCallback); - backgroundResourcesLoadedSignal?.Dispose(); - backgroundResourcesLoadedSignal = null; - backgroundResourceLoadedCallback = null; + using ViewSignal signal = new ViewSignal(Interop.View.ResourceReadySignal(SwigCPtr), false); + if (signal?.Empty() == false) + { + signal?.Disconnect(backgroundResourceLoadedCallback); + backgroundResourceLoadedCallback = null; + } } } } @@ -731,102 +720,39 @@ namespace Tizen.NUI.BaseComponents return ret; } - private void OnSize2DChanged(int? width, int? height) + private void OnColorChanged(float r, float g, float b, float a) { - PropertyValue temp; - if (width != null) - { - temp = new Tizen.NUI.PropertyValue((float)width); - Tizen.NUI.Object.SetProperty(this.SwigCPtr, View.Property.SizeWidth, temp); - temp.Dispose(); - } - if (height != null) - { - temp = new Tizen.NUI.PropertyValue((float)height); - Tizen.NUI.Object.SetProperty(this.SwigCPtr, View.Property.SizeHeight, temp); - temp.Dispose(); - } + Color = new Color(r, g, b, a); } - private void OnMinimumSizeChanged(int? width, int? height) + private void OnMinimumSizeChanged(int width, int height) { - if (width != null && height != null) - { - MinimumSize = new Size2D((int)width, (int)height); - } - else if (width != null && height == null) - { - Vector2 minSize = this.GetMinimumSize(); - MinimumSize = new Size2D((int)width, (int)(minSize.Height)); - minSize.Dispose(); - } - else if (width == null && height != null) - { - Vector2 minSize = this.GetMinimumSize(); - MinimumSize = new Size2D((int)(minSize.Width), (int)height); - minSize.Dispose(); - } - else - { - //both are null, do nothing. - } + MinimumSize = new Size2D(width, height); } - private void OnMaximumSizeChanged(int? width, int? height) + private void OnMaximumSizeChanged(int width, int height) { - if (width != null && height != null) - { - MaximumSize = new Size2D((int)width, (int)height); - } - else if (width != null && height == null) - { - Vector2 maxSize = this.GetMaximumSize(); - MaximumSize = new Size2D((int)width, (int)(maxSize.Height)); - maxSize.Dispose(); - } - else if (width == null && height != null) - { - Vector2 maxSize = this.GetMaximumSize(); - MaximumSize = new Size2D((int)(maxSize.Width), (int)height); - maxSize.Dispose(); - } - else - { - //both are null, do nothing. - } + MaximumSize = new Size2D(width, height); } private void OnPosition2DChanged(int x, int y) { - Position2D = new Position2D(x, y); + SetPosition((float)x, (float)y, 0); } - private void OnSizeChanged(float? width, float? height, float? depth) + private void OnPositionChanged(float x, float y, float z) { - PropertyValue temp; - if (width != null) - { - temp = new Tizen.NUI.PropertyValue((float)width); - Tizen.NUI.Object.SetProperty(this.SwigCPtr, View.Property.SizeWidth, temp); - temp.Dispose(); - } - if (height != null) - { - temp = new Tizen.NUI.PropertyValue((float)height); - Tizen.NUI.Object.SetProperty(this.SwigCPtr, View.Property.SizeHeight, temp); - temp.Dispose(); - } - if (depth != null) - { - temp = new Tizen.NUI.PropertyValue((float)depth); - Tizen.NUI.Object.SetProperty(this.SwigCPtr, View.Property.SizeDepth, temp); - temp.Dispose(); - } + SetPosition(x, y, z); } - private void OnPositionChanged(float x, float y, float z) + private void OnSize2DChanged(int width, int height) { - Position = new Position(x, y, z); + SetSize((float)width, (float)height, 0); + } + + private void OnSizeChanged(float width, float height, float depth) + { + SetSize(width, height, depth); } private void OnParentOriginChanged(float x, float y, float z) @@ -856,18 +782,74 @@ namespace Tizen.NUI.BaseComponents private void OnKeyInputFocusGained(IntPtr view) { - if (keyInputFocusGainedEventHandler != null) + if (IsNativeHandleInvalid()) { - keyInputFocusGainedEventHandler(this, null); + if (this.Disposed) + { + if (keyInputFocusGainedEventHandler != null) + { + var process = global::System.Diagnostics.Process.GetCurrentProcess().Id; + var thread = global::System.Threading.Thread.CurrentThread.ManagedThreadId; + var me = this.GetType().FullName; + + throw new ObjectDisposedException(nameof(SwigCPtr), $"Error! NUI's native dali object is already disposed. " + + $"OR the native dali object handle of NUI becomes null! \n" + + $" process:{process} thread:{thread}, isDisposed:{this.Disposed}, isDisposeQueued:{this.IsDisposeQueued}, me:{me}\n"); + } + } + else + { + if (this.IsDisposeQueued) + { + var process = global::System.Diagnostics.Process.GetCurrentProcess().Id; + var thread = global::System.Threading.Thread.CurrentThread.ManagedThreadId; + var me = this.GetType().FullName; + + //in this case, the View object is ready to be disposed waiting on DisposeQueue, so event callback should not be invoked! + Tizen.Log.Error("NUI", "in this case, the View object is ready to be disposed waiting on DisposeQueue, so event callback should not be invoked! just return here! \n" + + $"process:{process} thread:{thread}, isDisposed:{this.Disposed}, isDisposeQueued:{this.IsDisposeQueued}, me:{me}\n"); + return; + } + } } + + keyInputFocusGainedEventHandler?.Invoke(this, null); } private void OnKeyInputFocusLost(IntPtr view) { - if (keyInputFocusLostEventHandler != null) + if (IsNativeHandleInvalid()) { - keyInputFocusLostEventHandler(this, null); + if (this.Disposed) + { + if (keyInputFocusLostEventHandler != null) + { + var process = global::System.Diagnostics.Process.GetCurrentProcess().Id; + var thread = global::System.Threading.Thread.CurrentThread.ManagedThreadId; + var me = this.GetType().FullName; + + throw new ObjectDisposedException(nameof(SwigCPtr), $"Error! NUI's native dali object is already disposed. " + + $"OR the native dali object handle of NUI becomes null! \n" + + $" process:{process} thread:{thread}, isDisposed:{this.Disposed}, isDisposeQueued:{this.IsDisposeQueued}, me:{me}\n"); + } + } + else + { + if (this.IsDisposeQueued) + { + var process = global::System.Diagnostics.Process.GetCurrentProcess().Id; + var thread = global::System.Threading.Thread.CurrentThread.ManagedThreadId; + var me = this.GetType().FullName; + + //in this case, the View object is ready to be disposed waiting on DisposeQueue, so event callback should not be invoked! + Tizen.Log.Error("NUI", "in this case, the View object is ready to be disposed waiting on DisposeQueue, so event callback should not be invoked! just return here! \n" + + $"process:{process} thread:{thread}, isDisposed:{this.Disposed}, isDisposeQueued:{this.IsDisposeQueued}, me:{me}\n"); + return; + } + } } + + keyInputFocusLostEventHandler?.Invoke(this, null); } private bool OnKeyEvent(IntPtr view, IntPtr keyEvent) @@ -1365,24 +1347,68 @@ namespace Tizen.NUI.BaseComponents } /// - /// TouchArea can reset the view's touchable area.
- /// If you set the TouchArea on an view, when you touch the view, the touch area is used rather than the size of the view. + /// The expanded touch area. + /// TouchArea can expand the view's touchable area.
+ /// 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.
///
+ /// + /// This is based on the top left x, y coordinates.
+ /// For example)
+ /// + /// view.Size = new Size(100, 100); + /// view.TouchAreaOffset = new Offset(-10, 20, 30, -40); // left, right, bottom, top + /// + /// Then, touch area is 130x170.
+ /// This is view.width + TouchAreaOffset.right - TouchAreaOffset.left and view.height + TouchAreaOffset.bottom - TouchAreaOffset.top
+ /// +---------------------+
+ /// | ^ |
+ /// | | |
+ /// | | -40 |
+ /// | | |
+ /// | | |
+ /// | +----+----+ |
+ /// | | | |
+ /// | -10| | 20 |
+ /// |<---+ +----->|
+ /// | | | |
+ /// | | | |
+ /// | +----+----+ |
+ /// | | |
+ /// | | 30 |
+ /// | | |
+ /// | v |
+ /// +---------------------+
+ ///
[EditorBrowsable(EditorBrowsableState.Never)] - public Size TouchArea + public Offset TouchAreaOffset { get { - Size value = new Size(0, 0, 0); - GetProperty(View.Property.TouchArea).Get(value); - return value; + return (Offset)GetValue(TouchAreaOffsetProperty); } set { - SetProperty(View.Property.TouchArea, new Tizen.NUI.PropertyValue(value)); + SetValue(TouchAreaOffsetProperty, value); NotifyPropertyChanged(); } } + private Offset InternalTouchAreaOffset + { + get + { + Interop.ActorInternal.GetTouchAreaOffset(SwigCPtr, out int left, out int right, out int bottom, out int top); + if (NDalicPINVOKE.SWIGPendingException.Pending) + throw NDalicPINVOKE.SWIGPendingException.Retrieve(); + return new Offset(left, right, bottom, top); + } + set + { + Interop.ActorInternal.SetTouchAreaOffset(SwigCPtr, value.Left, value.Right, value.Bottom, value.Top); + if (NDalicPINVOKE.SWIGPendingException.Pending) + throw NDalicPINVOKE.SWIGPendingException.Retrieve(); + } + } + } }