/*
- * Copyright(c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright(c) 2021 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
using System;
using System.ComponentModel;
using System.Runtime.InteropServices;
-using Tizen.NUI.Components;
namespace Tizen.NUI.BaseComponents
{
/// <since_tizen> 3 </since_tizen>
public partial class View
{
- private EventHandler _offWindowEventHandler;
- private OffWindowEventCallbackType _offWindowEventCallback;
- private EventHandlerWithReturnType<object, WheelEventArgs, bool> _wheelEventHandler;
- private WheelEventCallbackType _wheelEventCallback;
- private EventHandlerWithReturnType<object, KeyEventArgs, bool> _keyEventHandler;
- private KeyCallbackType _keyCallback;
- private EventHandlerWithReturnType<object, TouchEventArgs, bool> _interceptTouchDataEventHandler;
- private TouchDataCallbackType _interceptTouchDataCallback;
- private EventHandlerWithReturnType<object, TouchEventArgs, bool> _touchDataEventHandler;
- private TouchDataCallbackType _touchDataCallback;
- private EventHandlerWithReturnType<object, HoverEventArgs, bool> _hoverEventHandler;
- private HoverEventCallbackType _hoverEventCallback;
- private EventHandler<VisibilityChangedEventArgs> _visibilityChangedEventHandler;
- private VisibilityChangedEventCallbackType _visibilityChangedEventCallback;
- private EventHandler _keyInputFocusGainedEventHandler;
- private KeyInputFocusGainedCallbackType _keyInputFocusGainedCallback;
- private EventHandler _keyInputFocusLostEventHandler;
- private KeyInputFocusLostCallbackType _keyInputFocusLostCallback;
- private EventHandler _onRelayoutEventHandler;
- private OnRelayoutEventCallbackType _onRelayoutEventCallback;
- private EventHandler _onWindowEventHandler;
- private OnWindowEventCallbackType _onWindowEventCallback;
- private EventHandler<LayoutDirectionChangedEventArgs> _layoutDirectionChangedEventHandler;
- private LayoutDirectionChangedEventCallbackType _layoutDirectionChangedEventCallback;
+ private EventHandler offWindowEventHandler;
+ private OffWindowEventCallbackType offWindowEventCallback;
+ private EventHandlerWithReturnType<object, WheelEventArgs, bool> wheelEventHandler;
+ private WheelEventCallbackType wheelEventCallback;
+ private EventHandlerWithReturnType<object, KeyEventArgs, bool> keyEventHandler;
+ private KeyCallbackType keyCallback;
+ private EventHandlerWithReturnType<object, TouchEventArgs, bool> interceptTouchDataEventHandler;
+ private TouchDataCallbackType interceptTouchDataCallback;
+ private EventHandlerWithReturnType<object, TouchEventArgs, bool> touchDataEventHandler;
+ private TouchDataCallbackType touchDataCallback;
+ private EventHandlerWithReturnType<object, HoverEventArgs, bool> hoverEventHandler;
+ private HoverEventCallbackType hoverEventCallback;
+ private EventHandler<VisibilityChangedEventArgs> visibilityChangedEventHandler;
+ private VisibilityChangedEventCallbackType visibilityChangedEventCallback;
+ private EventHandler keyInputFocusGainedEventHandler;
+
+ private KeyInputFocusGainedCallbackType keyInputFocusGainedCallback;
+ private EventHandler keyInputFocusLostEventHandler;
+
+ private KeyInputFocusLostCallbackType keyInputFocusLostCallback;
+ private EventHandler onRelayoutEventHandler;
+ private OnRelayoutEventCallbackType onRelayoutEventCallback;
+ private EventHandler onWindowEventHandler;
+ private OnWindowEventCallbackType onWindowEventCallback;
+ private EventHandler<LayoutDirectionChangedEventArgs> layoutDirectionChangedEventHandler;
+ private LayoutDirectionChangedEventCallbackType layoutDirectionChangedEventCallback;
// Resource Ready Signal
- private EventHandler _resourcesLoadedEventHandler;
- private ResourcesLoadedCallbackType _ResourcesLoadedCallback;
- private EventHandler<BackgroundResourceLoadedEventArgs> _backgroundResourceLoadedEventHandler;
- private _backgroundResourceLoadedCallbackType _backgroundResourceLoadedCallback;
-
+ private EventHandler resourcesLoadedEventHandler;
+ private ResourcesLoadedCallbackType ResourcesLoadedCallback;
+ private EventHandler<BackgroundResourceLoadedEventArgs> backgroundResourceLoadedEventHandler;
+ private _backgroundResourceLoadedCallbackType backgroundResourceLoadedCallback;
+ private OnWindowEventCallbackType onWindowSendEventCallback;
private void SendViewAddedEventToWindow(IntPtr data)
{
// Unused parameter
_ = data;
-
NUIApplication.GetDefaultWindow()?.SendViewAdded(this);
}
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)]
{
add
{
- if (_keyInputFocusGainedEventHandler == null)
+ if (keyInputFocusGainedEventHandler == null)
{
- _keyInputFocusGainedCallback = OnKeyInputFocusGained;
- this.KeyInputFocusGainedSignal().Connect(_keyInputFocusGainedCallback);
+ keyInputFocusGainedCallback = OnKeyInputFocusGained;
+ using KeyInputFocusSignal signal = new KeyInputFocusSignal(Interop.ViewSignal.KeyInputFocusGainedSignal(SwigCPtr), false);
+ signal?.Connect(keyInputFocusGainedCallback);
}
-
- _keyInputFocusGainedEventHandler += value;
+ keyInputFocusGainedEventHandler += value;
}
remove
{
- _keyInputFocusGainedEventHandler -= value;
-
- if (_keyInputFocusGainedEventHandler == null && KeyInputFocusGainedSignal().Empty() == false)
+ keyInputFocusGainedEventHandler -= value;
+ if (keyInputFocusGainedEventHandler == null)
{
- this.KeyInputFocusGainedSignal().Disconnect(_keyInputFocusGainedCallback);
+ using KeyInputFocusSignal signal = new KeyInputFocusSignal(Interop.ViewSignal.KeyInputFocusGainedSignal(SwigCPtr), false);
+
+ if (keyInputFocusGainedCallback != null)
+ {
+ signal?.Disconnect(keyInputFocusGainedCallback);
+ if (signal?.Empty() == true)
+ {
+ keyInputFocusGainedCallback = null;
+ }
+ }
}
}
}
{
add
{
- if (_keyInputFocusLostEventHandler == null)
+ if (keyInputFocusLostEventHandler == null)
{
- _keyInputFocusLostCallback = OnKeyInputFocusLost;
- this.KeyInputFocusLostSignal().Connect(_keyInputFocusLostCallback);
+ keyInputFocusLostCallback = OnKeyInputFocusLost;
+ using KeyInputFocusSignal signal = new KeyInputFocusSignal(Interop.ViewSignal.KeyInputFocusLostSignal(SwigCPtr), false);
+ signal?.Connect(keyInputFocusLostCallback);
}
-
- _keyInputFocusLostEventHandler += value;
+ keyInputFocusLostEventHandler += value;
}
remove
{
- _keyInputFocusLostEventHandler -= value;
-
- if (_keyInputFocusLostEventHandler == null && KeyInputFocusLostSignal().Empty() == false)
+ keyInputFocusLostEventHandler -= value;
+ if (keyInputFocusLostEventHandler == null)
{
- this.KeyInputFocusLostSignal().Disconnect(_keyInputFocusLostCallback);
+ using KeyInputFocusSignal signal = new KeyInputFocusSignal(Interop.ViewSignal.KeyInputFocusLostSignal(SwigCPtr), false);
+
+ if (keyInputFocusLostCallback != null)
+ {
+ signal?.Disconnect(keyInputFocusLostCallback);
+ if (signal?.Empty() == true)
+ {
+ keyInputFocusLostCallback = null;
+ }
+ }
}
}
}
{
add
{
- if (_keyEventHandler == null)
+ if (keyEventHandler == null)
{
- _keyCallback = OnKeyEvent;
- this.KeyEventSignal().Connect(_keyCallback);
+ keyCallback = OnKeyEvent;
+ using ControlKeySignal signal = new ControlKeySignal(Interop.ViewSignal.KeyEventSignal(SwigCPtr), false);
+ signal?.Connect(keyCallback);
}
-
- _keyEventHandler += value;
+ keyEventHandler += value;
}
remove
{
- _keyEventHandler -= value;
-
- if (_keyEventHandler == null && KeyEventSignal().Empty() == false)
+ keyEventHandler -= value;
+ if (keyEventHandler == null)
{
- this.KeyEventSignal().Disconnect(_keyCallback);
+ using ControlKeySignal signal = new ControlKeySignal(Interop.ViewSignal.KeyEventSignal(SwigCPtr), false);
+ if (signal?.Empty() == false)
+ {
+ signal?.Disconnect(keyCallback);
+ keyCallback = null;
+ }
}
}
}
{
add
{
- if (_onRelayoutEventHandler == null)
+ if (onRelayoutEventHandler == null)
{
- _onRelayoutEventCallback = OnRelayout;
- this.OnRelayoutSignal().Connect(_onRelayoutEventCallback);
+ onRelayoutEventCallback = OnRelayout;
+ using ViewSignal signal = new ViewSignal(Interop.ActorSignal.ActorOnRelayoutSignal(SwigCPtr), false);
+ signal?.Connect(onRelayoutEventCallback);
}
-
- _onRelayoutEventHandler += value;
+ onRelayoutEventHandler += value;
}
remove
{
- _onRelayoutEventHandler -= value;
-
- if (_onRelayoutEventHandler == null && OnRelayoutSignal().Empty() == false)
+ onRelayoutEventHandler -= value;
+ if (onRelayoutEventHandler == null)
{
- this.OnRelayoutSignal().Disconnect(_onRelayoutEventCallback);
- _onRelayoutEventCallback = null;
+ using ViewSignal signal = new ViewSignal(Interop.ActorSignal.ActorOnRelayoutSignal(SwigCPtr), false);
+ if (signal?.Empty() == false)
+ {
+ signal?.Disconnect(onRelayoutEventCallback);
+ onRelayoutEventCallback = null;
+ }
}
-
}
}
{
add
{
- if (_interceptTouchDataEventHandler == null)
+ if (interceptTouchDataEventHandler == null)
{
- _interceptTouchDataCallback = OnInterceptTouch;
- this.InterceptTouchSignal().Connect(_interceptTouchDataCallback);
+ interceptTouchDataCallback = OnInterceptTouch;
+ using TouchDataSignal signal = new TouchDataSignal(Interop.ActorSignal.ActorInterceptTouchSignal(SwigCPtr), false);
+ signal?.Connect(interceptTouchDataCallback);
}
-
- _interceptTouchDataEventHandler += value;
+ interceptTouchDataEventHandler += value;
}
remove
{
- _interceptTouchDataEventHandler -= value;
-
- if (_interceptTouchDataEventHandler == null && InterceptTouchSignal().Empty() == false)
+ interceptTouchDataEventHandler -= value;
+ if (interceptTouchDataEventHandler == null)
{
- this.InterceptTouchSignal().Disconnect(_interceptTouchDataCallback);
+ using TouchDataSignal signal = new TouchDataSignal(Interop.ActorSignal.ActorInterceptTouchSignal(SwigCPtr), false);
+ if (signal?.Empty() == false)
+ {
+ signal?.Disconnect(interceptTouchDataCallback);
+ interceptTouchDataCallback = null;
+ }
}
}
}
/// 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.
/// </summary>
[EditorBrowsable(EditorBrowsableState.Never)]
public bool DisallowInterceptTouchEvent { get; set; }
{
add
{
- if (_touchDataEventHandler == null)
+ if (touchDataEventHandler == null)
{
- _touchDataCallback = OnTouch;
- this.TouchSignal().Connect(_touchDataCallback);
+ touchDataCallback = OnTouch;
+ using TouchDataSignal signal = new TouchDataSignal(Interop.ActorSignal.ActorTouchSignal(SwigCPtr), false);
+ signal.Connect(touchDataCallback);
}
-
- _touchDataEventHandler += value;
+ touchDataEventHandler += value;
}
remove
{
- _touchDataEventHandler -= value;
-
- if (_touchDataEventHandler == null && TouchSignal().Empty() == false)
+ touchDataEventHandler -= value;
+ if (touchDataEventHandler == null)
{
- this.TouchSignal().Disconnect(_touchDataCallback);
+ using TouchDataSignal signal = new TouchDataSignal(Interop.ActorSignal.ActorTouchSignal(SwigCPtr), false);
+ if (signal.Empty() == false)
+ {
+ signal.Disconnect(touchDataCallback);
+ touchDataCallback = null;
+ }
}
}
}
{
add
{
- if (_hoverEventHandler == null)
+ if (hoverEventHandler == null)
{
- _hoverEventCallback = OnHoverEvent;
- this.HoveredSignal().Connect(_hoverEventCallback);
+ hoverEventCallback = OnHoverEvent;
+ using HoverSignal signal = new HoverSignal(Interop.ActorSignal.ActorHoveredSignal(SwigCPtr), false);
+ signal?.Connect(hoverEventCallback);
}
-
- _hoverEventHandler += value;
+ hoverEventHandler += value;
}
remove
{
- _hoverEventHandler -= value;
-
- if (_hoverEventHandler == null && HoveredSignal().Empty() == false)
+ hoverEventHandler -= value;
+ if (hoverEventHandler == null)
{
- this.HoveredSignal().Disconnect(_hoverEventCallback);
+ using HoverSignal signal = new HoverSignal(Interop.ActorSignal.ActorHoveredSignal(SwigCPtr), false);
+ if (signal?.Empty() == false)
+ {
+ signal?.Disconnect(hoverEventCallback);
+ hoverEventCallback = null;
+ }
}
-
}
}
{
add
{
- if (_wheelEventHandler == null)
+ if (wheelEventHandler == null)
{
- _wheelEventCallback = OnWheelEvent;
- this.WheelEventSignal().Connect(_wheelEventCallback);
+ wheelEventCallback = OnWheelEvent;
+ using WheelSignal signal = new WheelSignal(Interop.ActorSignal.ActorWheelEventSignal(SwigCPtr), false);
+ signal?.Connect(wheelEventCallback);
}
- _wheelEventHandler += value;
+ wheelEventHandler += value;
if (WindowWheelEventHandler == null)
{
remove
{
- _wheelEventHandler -= value;
- if (_wheelEventHandler == null && WheelEventSignal().Empty() == false)
+ wheelEventHandler -= value;
+ if (wheelEventHandler == null)
{
- this.WheelEventSignal().Disconnect(_wheelEventCallback);
+ using WheelSignal signal = new WheelSignal(Interop.ActorSignal.ActorWheelEventSignal(SwigCPtr), false);
+ if (signal?.Empty() == false)
+ {
+ signal?.Disconnect(wheelEventCallback);
+ wheelEventCallback = null;
+ }
}
WindowWheelEventHandler -= value;
{
add
{
- if (_onWindowEventHandler == null)
+ if (onWindowEventHandler == null)
{
- _onWindowEventCallback = OnWindow;
- this.OnWindowSignal().Connect(_onWindowEventCallback);
+ onWindowEventCallback = OnWindow;
+ using ViewSignal signal = new ViewSignal(Interop.ActorSignal.ActorOnSceneSignal(SwigCPtr), false);
+ signal?.Connect(onWindowEventCallback);
}
-
- _onWindowEventHandler += value;
+ onWindowEventHandler += value;
}
remove
{
- _onWindowEventHandler -= value;
-
- if (_onWindowEventHandler == null && OnWindowSignal().Empty() == false)
+ onWindowEventHandler -= value;
+ if (onWindowEventHandler == null)
{
- this.OnWindowSignal().Disconnect(_onWindowEventCallback);
- _onWindowEventCallback = null;
+ using ViewSignal signal = new ViewSignal(Interop.ActorSignal.ActorOnSceneSignal(SwigCPtr), false);
+ if (signal?.Empty() == false)
+ {
+ signal?.Disconnect(onWindowEventCallback);
+ onWindowEventCallback = null;
+ }
}
}
}
{
add
{
- if (_offWindowEventHandler == null)
+ if (offWindowEventHandler == null)
{
- _offWindowEventCallback = OffWindow;
- this.OffWindowSignal().Connect(_offWindowEventCallback);
+ offWindowEventCallback = OffWindow;
+ using ViewSignal signal = new ViewSignal(Interop.ActorSignal.ActorOffSceneSignal(SwigCPtr), false);
+ signal?.Connect(offWindowEventCallback);
}
-
- _offWindowEventHandler += value;
+ offWindowEventHandler += value;
}
remove
{
- _offWindowEventHandler -= value;
-
- if (_offWindowEventHandler == null && OffWindowSignal().Empty() == false)
+ offWindowEventHandler -= value;
+ if (offWindowEventHandler == null)
{
- this.OffWindowSignal().Disconnect(_offWindowEventCallback);
- _offWindowEventCallback = null;
+ using ViewSignal signal = new ViewSignal(Interop.ActorSignal.ActorOffSceneSignal(SwigCPtr), false);
+ if (signal?.Empty() == false)
+ {
+ signal?.Disconnect(offWindowEventCallback);
+ offWindowEventCallback = null;
+ }
}
}
}
{
add
{
- if (_visibilityChangedEventHandler == null)
+ if (visibilityChangedEventHandler == null)
{
- _visibilityChangedEventCallback = OnVisibilityChanged;
- VisibilityChangedSignal(this).Connect(_visibilityChangedEventCallback);
+ visibilityChangedEventCallback = OnVisibilityChanged;
+ VisibilityChangedSignal(this).Connect(visibilityChangedEventCallback);
}
- _visibilityChangedEventHandler += value;
+ visibilityChangedEventHandler += value;
}
remove
{
- _visibilityChangedEventHandler -= value;
+ visibilityChangedEventHandler -= value;
- if (_visibilityChangedEventHandler == null && VisibilityChangedSignal(this).Empty() == false)
+ if (visibilityChangedEventHandler == null && VisibilityChangedSignal(this).Empty() == false)
{
- VisibilityChangedSignal(this).Disconnect(_visibilityChangedEventCallback);
+ VisibilityChangedSignal(this).Disconnect(visibilityChangedEventCallback);
}
}
}
{
add
{
- if (_layoutDirectionChangedEventHandler == null)
+ if (layoutDirectionChangedEventHandler == null)
{
- _layoutDirectionChangedEventCallback = OnLayoutDirectionChanged;
- LayoutDirectionChangedSignal(this).Connect(_layoutDirectionChangedEventCallback);
+ layoutDirectionChangedEventCallback = OnLayoutDirectionChanged;
+ LayoutDirectionChangedSignal(this).Connect(layoutDirectionChangedEventCallback);
}
- _layoutDirectionChangedEventHandler += value;
+ layoutDirectionChangedEventHandler += value;
}
remove
{
- _layoutDirectionChangedEventHandler -= value;
+ layoutDirectionChangedEventHandler -= value;
- if (_layoutDirectionChangedEventHandler == null && LayoutDirectionChangedSignal(this).Empty() == false)
+ if (layoutDirectionChangedEventHandler == null && LayoutDirectionChangedSignal(this).Empty() == false)
{
- LayoutDirectionChangedSignal(this).Disconnect(_layoutDirectionChangedEventCallback);
+ LayoutDirectionChangedSignal(this).Disconnect(layoutDirectionChangedEventCallback);
}
}
}
{
add
{
- if (_resourcesLoadedEventHandler == null)
+ if (resourcesLoadedEventHandler == null)
{
- _ResourcesLoadedCallback = OnResourcesLoaded;
- this.ResourcesLoadedSignal().Connect(_ResourcesLoadedCallback);
+ ResourcesLoadedCallback = OnResourcesLoaded;
+ using ViewSignal signal = new ViewSignal(Interop.View.ResourceReadySignal(SwigCPtr), false);
+ signal?.Connect(ResourcesLoadedCallback);
}
-
- _resourcesLoadedEventHandler += value;
+ resourcesLoadedEventHandler += value;
}
remove
{
- _resourcesLoadedEventHandler -= value;
-
- if (_resourcesLoadedEventHandler == null && ResourcesLoadedSignal().Empty() == false)
+ resourcesLoadedEventHandler -= value;
+ if (resourcesLoadedEventHandler == null)
{
- this.ResourcesLoadedSignal().Disconnect(_ResourcesLoadedCallback);
- _ResourcesLoadedCallback = null;
+ using ViewSignal signal = new ViewSignal(Interop.View.ResourceReadySignal(SwigCPtr), false);
+ if (signal?.Empty() == false)
+ {
+ signal?.Disconnect(ResourcesLoadedCallback);
+ ResourcesLoadedCallback = null;
+ }
}
}
}
{
add
{
- if (_backgroundResourceLoadedEventHandler == null)
+ if (backgroundResourceLoadedEventHandler == null)
{
- _backgroundResourceLoadedCallback = OnBackgroundResourceLoaded;
- this.ResourcesLoadedSignal().Connect(_backgroundResourceLoadedCallback);
+ backgroundResourceLoadedCallback = OnBackgroundResourceLoaded;
+ using ViewSignal signal = new ViewSignal(Interop.View.ResourceReadySignal(SwigCPtr), false);
+ signal?.Connect(backgroundResourceLoadedCallback);
}
-
- _backgroundResourceLoadedEventHandler += value;
+ backgroundResourceLoadedEventHandler += value;
}
+
remove
{
- _backgroundResourceLoadedEventHandler -= value;
-
- if (_backgroundResourceLoadedEventHandler == null && ResourcesLoadedSignal().Empty() == false)
+ backgroundResourceLoadedEventHandler -= value;
+ if (backgroundResourceLoadedEventHandler == null)
{
- this.ResourcesLoadedSignal().Disconnect(_backgroundResourceLoadedCallback);
- _backgroundResourceLoadedCallback = null;
+ using ViewSignal signal = new ViewSignal(Interop.View.ResourceReadySignal(SwigCPtr), false);
+ if (signal?.Empty() == false)
+ {
+ signal?.Disconnect(backgroundResourceLoadedCallback);
+ backgroundResourceLoadedCallback = null;
+ }
}
}
}
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)
- {
- 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)
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)
e.Key = Tizen.NUI.Key.GetKeyFromPtr(keyEvent);
- if (_keyEventHandler != null)
+ if (keyEventHandler != null)
{
- Delegate[] delegateList = _keyEventHandler.GetInvocationList();
+ Delegate[] delegateList = keyEventHandler.GetInvocationList();
// Oring the result of each callback.
foreach (EventHandlerWithReturnType<object, KeyEventArgs, bool> del in delegateList)
// Callback for View OnRelayout signal
private void OnRelayout(IntPtr data)
{
- if (_onRelayoutEventHandler != null)
+ if (onRelayoutEventHandler != null)
{
- _onRelayoutEventHandler(this, null);
+ onRelayoutEventHandler(this, null);
}
}
bool consumed = false;
- if (_interceptTouchDataEventHandler != null)
+ if (interceptTouchDataEventHandler != null)
{
- consumed = _interceptTouchDataEventHandler(this, e);
+ consumed = interceptTouchDataEventHandler(this, e);
}
return consumed;
bool consumed = false;
- if (_touchDataEventHandler != null)
+ if (touchDataEventHandler != null)
{
- consumed = _touchDataEventHandler(this, e);
+ consumed = touchDataEventHandler(this, e);
}
if (enableControlState && !consumed)
e.Hover = Tizen.NUI.Hover.GetHoverFromPtr(hoverEvent);
- if (_hoverEventHandler != null)
+ if (hoverEventHandler != null)
{
- return _hoverEventHandler(this, e);
+ return hoverEventHandler(this, e);
}
return false;
}
e.Wheel = Tizen.NUI.Wheel.GetWheelFromPtr(wheelEvent);
- if (_wheelEventHandler != null)
+ if (wheelEventHandler != null)
{
- return _wheelEventHandler(this, e);
+ return wheelEventHandler(this, e);
}
return false;
}
// Callback for View OnWindow signal
private void OnWindow(IntPtr data)
{
- if (_onWindowEventHandler != null)
+ if (onWindowEventHandler != null)
{
- _onWindowEventHandler(this, null);
+ onWindowEventHandler(this, null);
}
}
// Callback for View OffWindow signal
private void OffWindow(IntPtr data)
{
- if (_offWindowEventHandler != null)
+ if (offWindowEventHandler != null)
{
- _offWindowEventHandler(this, null);
+ offWindowEventHandler(this, null);
}
}
e.Visibility = visibility;
e.Type = type;
- if (_visibilityChangedEventHandler != null)
+ if (visibilityChangedEventHandler != null)
{
- _visibilityChangedEventHandler(this, e);
+ visibilityChangedEventHandler(this, e);
}
}
}
e.Type = type;
- if (_layoutDirectionChangedEventHandler != null)
+ if (layoutDirectionChangedEventHandler != null)
{
- _layoutDirectionChangedEventHandler(this, e);
+ layoutDirectionChangedEventHandler(this, e);
}
}
private void OnResourcesLoaded(IntPtr view)
{
- if (_resourcesLoadedEventHandler != null)
+ if (resourcesLoadedEventHandler != null)
{
- _resourcesLoadedEventHandler(this, null);
+ resourcesLoadedEventHandler(this, null);
}
}
BackgroundResourceLoadedEventArgs e = new BackgroundResourceLoadedEventArgs();
e.Status = (ResourceLoadingStatusType)Interop.View.GetVisualResourceStatus(this.SwigCPtr, Property.BACKGROUND);
- if (_backgroundResourceLoadedEventHandler != null)
+ if (backgroundResourceLoadedEventHandler != null)
{
- _backgroundResourceLoadedEventHandler(this, e);
+ backgroundResourceLoadedEventHandler(this, e);
}
}
}
}
+ /// <summary>
+ /// The expanded touch area.
+ /// TouchArea can expand the view's touchable area.<br/>
+ /// 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/>
+ /// </summary>
+ /// <remarks>
+ /// This is based on the top left x, y coordinates.<br/>
+ /// For example) <br/>
+ /// <code>
+ /// view.Size = new Size(100, 100);
+ /// view.TouchAreaOffset = new Offset(-10, 20, 30, -40); // left, right, bottom, top
+ /// </code>
+ /// Then, touch area is 130x170.<br/>
+ /// This is view.width + TouchAreaOffset.right - TouchAreaOffset.left and view.height + TouchAreaOffset.bottom - TouchAreaOffset.top <br/>
+ /// +---------------------+ <br/>
+ /// | ^ | <br/>
+ /// | | | <br/>
+ /// | | -40 | <br/>
+ /// | | | <br/>
+ /// | | | <br/>
+ /// | +----+----+ | <br/>
+ /// | | | | <br/>
+ /// | -10| | 20 | <br/>
+ /// |<---+ +----->| <br/>
+ /// | | | | <br/>
+ /// | | | | <br/>
+ /// | +----+----+ | <br/>
+ /// | | | <br/>
+ /// | | 30 | <br/>
+ /// | | | <br/>
+ /// | v | <br/>
+ /// +---------------------+ <br/>
+ /// </remarks>
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public Offset TouchAreaOffset
+ {
+ get
+ {
+ return (Offset)GetValue(TouchAreaOffsetProperty);
+ }
+ set
+ {
+ 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();
+ }
+ }
+
}
}