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=a9f221359c98fe876e6815cf1cac115fe744e75e;hpb=210c19dcac5bd0535e588d34044b06de401cc0d6;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 a9f2213..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)] @@ -126,10 +130,14 @@ namespace Tizen.NUI.BaseComponents if (keyInputFocusGainedEventHandler == null) { using KeyInputFocusSignal signal = new KeyInputFocusSignal(Interop.ViewSignal.KeyInputFocusGainedSignal(SwigCPtr), false); - if (signal?.Empty() == false) + + if (keyInputFocusGainedCallback != null) { signal?.Disconnect(keyInputFocusGainedCallback); - keyInputFocusGainedCallback = null; + if (signal?.Empty() == true) + { + keyInputFocusGainedCallback = null; + } } } } @@ -159,10 +167,14 @@ namespace Tizen.NUI.BaseComponents if (keyInputFocusLostEventHandler == null) { using KeyInputFocusSignal signal = new KeyInputFocusSignal(Interop.ViewSignal.KeyInputFocusLostSignal(SwigCPtr), false); - if (signal?.Empty() == false) + + if (keyInputFocusLostCallback != null) { signal?.Disconnect(keyInputFocusLostCallback); - keyInputFocusLostCallback = null; + if (signal?.Empty() == true) + { + keyInputFocusLostCallback = null; + } } } } @@ -594,7 +606,7 @@ namespace Tizen.NUI.BaseComponents } backgroundResourceLoadedEventHandler += value; } - + remove { backgroundResourceLoadedEventHandler -= value; @@ -708,93 +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 = null; - if (width != null) - { - temp = new PropertyValue((float)width); - Object.SetProperty(SwigCPtr, Property.SizeWidth, temp); - } - if (height != null) - { - temp = new PropertyValue((float)height); - Object.SetProperty(SwigCPtr, 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) - { - MinimumSize = new Size2D((int)width, (int)this.GetMinimumSize().Height); - } - else if (width == null && height != null) - { - MinimumSize = new Size2D((int)this.GetMinimumSize().Width, (int)height); - } - 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) - { - MaximumSize = new Size2D((int)width, (int)this.GetMaximumSize().Height); - } - else if (width == null && height != null) - { - MaximumSize = new Size2D((int)this.GetMaximumSize().Width, (int)height); - } - 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) @@ -824,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)