/*
- * 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 OnWindowEventCallbackType _onWindowSendEventCallback;
-
- private void SendViewAddedEventToWindow(IntPtr data)
- {
- NUIApplication.GetDefaultWindow()?.SendViewAdded(this);
- }
+ private EventHandler resourcesLoadedEventHandler;
+ private ResourcesLoadedCallbackType resourcesLoadedCallback;
+ private EventHandler<BackgroundResourceLoadedEventArgs> backgroundResourceLoadedEventHandler;
+ private _backgroundResourceLoadedCallbackType backgroundResourceLoadedCallback;
+ private TouchDataCallbackType hitTestResultDataCallback;
[UnmanagedFunctionPointer(CallingConvention.StdCall)]
private delegate void OffWindowEventCallbackType(IntPtr control);
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;
+ Interop.ViewSignal.KeyInputFocusGainedConnect(SwigCPtr, keyInputFocusGainedCallback.ToHandleRef(this));
+ NDalicPINVOKE.ThrowExceptionIfExists();
}
-
- _keyInputFocusGainedEventHandler += value;
+ keyInputFocusGainedEventHandler += value;
}
remove
{
- _keyInputFocusGainedEventHandler -= value;
-
- if (_keyInputFocusGainedEventHandler == null && KeyInputFocusGainedSignal().Empty() == false)
+ keyInputFocusGainedEventHandler -= value;
+ if (keyInputFocusGainedEventHandler == null && keyInputFocusGainedCallback != null)
{
- this.KeyInputFocusGainedSignal().Disconnect(_keyInputFocusGainedCallback);
+ Interop.ViewSignal.KeyInputFocusGainedDisconnect(SwigCPtr, keyInputFocusGainedCallback.ToHandleRef(this));
+ NDalicPINVOKE.ThrowExceptionIfExists();
+ keyInputFocusGainedCallback = null;
}
}
}
{
add
{
- if (_keyInputFocusLostEventHandler == null)
+ if (keyInputFocusLostEventHandler == null)
{
- _keyInputFocusLostCallback = OnKeyInputFocusLost;
- this.KeyInputFocusLostSignal().Connect(_keyInputFocusLostCallback);
+ keyInputFocusLostCallback = OnKeyInputFocusLost;
+ Interop.ViewSignal.KeyInputFocusLostConnect(SwigCPtr, keyInputFocusLostCallback.ToHandleRef(this));
+ NDalicPINVOKE.ThrowExceptionIfExists();
}
-
- _keyInputFocusLostEventHandler += value;
+ keyInputFocusLostEventHandler += value;
}
remove
{
- _keyInputFocusLostEventHandler -= value;
-
- if (_keyInputFocusLostEventHandler == null && KeyInputFocusLostSignal().Empty() == false)
+ keyInputFocusLostEventHandler -= value;
+ if (keyInputFocusLostEventHandler == null && keyInputFocusLostCallback != null)
{
- this.KeyInputFocusLostSignal().Disconnect(_keyInputFocusLostCallback);
+ Interop.ViewSignal.KeyInputFocusLostDisconnect(SwigCPtr, keyInputFocusLostCallback.ToHandleRef(this));
+ NDalicPINVOKE.ThrowExceptionIfExists();
+ keyInputFocusLostCallback = null;
}
}
}
{
add
{
- if (_keyEventHandler == null)
+ if (keyEventHandler == null)
{
- _keyCallback = OnKeyEvent;
- this.KeyEventSignal().Connect(_keyCallback);
+ keyCallback = OnKeyEvent;
+ Interop.ViewSignal.KeyEventConnect(SwigCPtr, keyCallback.ToHandleRef(this));
+ NDalicPINVOKE.ThrowExceptionIfExists();
}
-
- _keyEventHandler += value;
+ keyEventHandler += value;
}
remove
{
- _keyEventHandler -= value;
-
- if (_keyEventHandler == null && KeyEventSignal().Empty() == false)
+ keyEventHandler -= value;
+ if (keyEventHandler == null && keyCallback != null)
{
- this.KeyEventSignal().Disconnect(_keyCallback);
+ Interop.ViewSignal.KeyEventDisconnect(SwigCPtr, keyCallback.ToHandleRef(this));
+ NDalicPINVOKE.ThrowExceptionIfExists();
+ keyCallback = null;
}
}
}
{
add
{
- if (_onRelayoutEventHandler == null)
+ if (onRelayoutEventHandler == null)
{
- _onRelayoutEventCallback = OnRelayout;
- this.OnRelayoutSignal().Connect(_onRelayoutEventCallback);
+ onRelayoutEventCallback = OnRelayout;
+ Interop.ActorSignal.OnRelayoutConnect(SwigCPtr, onRelayoutEventCallback.ToHandleRef(this));
+ NDalicPINVOKE.ThrowExceptionIfExists();
}
-
- _onRelayoutEventHandler += value;
+ onRelayoutEventHandler += value;
}
remove
{
- _onRelayoutEventHandler -= value;
-
- if (_onRelayoutEventHandler == null && OnRelayoutSignal().Empty() == false)
+ onRelayoutEventHandler -= value;
+ if (onRelayoutEventHandler == null && onRelayoutEventCallback != null)
{
- this.OnRelayoutSignal().Disconnect(_onRelayoutEventCallback);
+ Interop.ActorSignal.OnRelayoutDisconnect(SwigCPtr, onRelayoutEventCallback.ToHandleRef(this));
+ NDalicPINVOKE.ThrowExceptionIfExists();
+ onRelayoutEventCallback = null;
}
-
}
}
{
add
{
- if (_interceptTouchDataEventHandler == null)
+ if (interceptTouchDataEventHandler == null)
{
- _interceptTouchDataCallback = OnInterceptTouch;
- this.InterceptTouchSignal().Connect(_interceptTouchDataCallback);
+ interceptTouchDataCallback = OnInterceptTouch;
+ Interop.ActorSignal.InterceptTouchConnect(SwigCPtr, interceptTouchDataCallback.ToHandleRef(this));
+ NDalicPINVOKE.ThrowExceptionIfExists();
}
-
- _interceptTouchDataEventHandler += value;
+ interceptTouchDataEventHandler += value;
}
remove
{
- _interceptTouchDataEventHandler -= value;
-
- if (_interceptTouchDataEventHandler == null && InterceptTouchSignal().Empty() == false)
+ interceptTouchDataEventHandler -= value;
+ if (interceptTouchDataEventHandler == null && interceptTouchDataCallback != null)
{
- this.InterceptTouchSignal().Disconnect(_interceptTouchDataCallback);
+ Interop.ActorSignal.InterceptTouchDisconnect(SwigCPtr, interceptTouchDataCallback.ToHandleRef(this));
+ NDalicPINVOKE.ThrowExceptionIfExists();
+ 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;}
+ public bool DisallowInterceptTouchEvent { get; set; }
/// <summary>
{
add
{
- if (_touchDataEventHandler == null)
+ if (touchDataEventHandler == null)
{
- _touchDataCallback = OnTouch;
- this.TouchSignal().Connect(_touchDataCallback);
+ touchDataCallback = OnTouch;
+ Interop.ActorSignal.TouchConnect(SwigCPtr, touchDataCallback.ToHandleRef(this));
+ NDalicPINVOKE.ThrowExceptionIfExists();
}
-
- _touchDataEventHandler += value;
+ touchDataEventHandler += value;
}
remove
{
- _touchDataEventHandler -= value;
-
- if (_touchDataEventHandler == null && TouchSignal().Empty() == false)
+ touchDataEventHandler -= value;
+ if (touchDataEventHandler == null && touchDataCallback != null)
{
- this.TouchSignal().Disconnect(_touchDataCallback);
+ Interop.ActorSignal.TouchDisconnect(SwigCPtr, touchDataCallback.ToHandleRef(this));
+ NDalicPINVOKE.ThrowExceptionIfExists();
+ touchDataCallback = null;
}
}
}
{
add
{
- if (_hoverEventHandler == null)
+ if (hoverEventHandler == null)
{
- _hoverEventCallback = OnHoverEvent;
- this.HoveredSignal().Connect(_hoverEventCallback);
+ hoverEventCallback = OnHoverEvent;
+ Interop.ActorSignal.HoveredConnect(SwigCPtr, hoverEventCallback.ToHandleRef(this));
+ NDalicPINVOKE.ThrowExceptionIfExists();
}
-
- _hoverEventHandler += value;
+ hoverEventHandler += value;
}
remove
{
- _hoverEventHandler -= value;
-
- if (_hoverEventHandler == null && HoveredSignal().Empty() == false)
+ hoverEventHandler -= value;
+ if (hoverEventHandler == null && hoverEventCallback != null)
{
- this.HoveredSignal().Disconnect(_hoverEventCallback);
+ Interop.ActorSignal.HoveredDisconnect(SwigCPtr, hoverEventCallback.ToHandleRef(this));
+ NDalicPINVOKE.ThrowExceptionIfExists();
+ hoverEventCallback = null;
}
-
}
}
{
add
{
- if (_wheelEventHandler == null)
- {
- _wheelEventCallback = OnWheelEvent;
- this.WheelEventSignal().Connect(_wheelEventCallback);
- }
- _wheelEventHandler += value;
-
- if (WindowWheelEventHandler == null)
+ if (wheelEventHandler == null)
{
- NUIApplication.GetDefaultWindow().WheelEvent += OnWindowWheelEvent;
+ wheelEventCallback = OnWheelEvent;
+ Interop.ActorSignal.WheelEventConnect(SwigCPtr, wheelEventCallback.ToHandleRef(this));
+ NDalicPINVOKE.ThrowExceptionIfExists();
}
- WindowWheelEventHandler += value;
+ wheelEventHandler += value;
}
remove
{
- _wheelEventHandler -= value;
- if (_wheelEventHandler == null && WheelEventSignal().Empty() == false)
- {
- this.WheelEventSignal().Disconnect(_wheelEventCallback);
- }
-
- WindowWheelEventHandler -= value;
- if (WindowWheelEventHandler == null)
+ wheelEventHandler -= value;
+ if (wheelEventHandler == null && wheelEventCallback != null)
{
- NUIApplication.GetDefaultWindow().WheelEvent -= OnWindowWheelEvent;
+ Interop.ActorSignal.WheelEventDisconnect(SwigCPtr, wheelEventCallback.ToHandleRef(this));
+ NDalicPINVOKE.ThrowExceptionIfExists();
+ wheelEventCallback = null;
}
}
}
{
add
{
- if (_onWindowEventHandler == null)
+ if (onWindowEventHandler == null)
{
- _onWindowEventCallback = OnWindow;
- this.OnWindowSignal().Connect(_onWindowEventCallback);
+ onWindowEventCallback = OnWindow;
+ Interop.ActorSignal.OnSceneConnect(SwigCPtr, onWindowEventCallback.ToHandleRef(this));
+ NDalicPINVOKE.ThrowExceptionIfExists();
}
-
- _onWindowEventHandler += value;
+ onWindowEventHandler += value;
}
remove
{
- _onWindowEventHandler -= value;
-
- if (_onWindowEventHandler == null && OnWindowSignal().Empty() == false)
+ onWindowEventHandler -= value;
+ if (onWindowEventHandler == null && onWindowEventCallback != null)
{
- this.OnWindowSignal().Disconnect(_onWindowEventCallback);
+ Interop.ActorSignal.OnSceneDisconnect(SwigCPtr, onWindowEventCallback.ToHandleRef(this));
+ NDalicPINVOKE.ThrowExceptionIfExists();
+ onWindowEventCallback = null;
}
}
}
{
add
{
- if (_offWindowEventHandler == null)
+ if (offWindowEventHandler == null)
{
- _offWindowEventCallback = OffWindow;
- this.OffWindowSignal().Connect(_offWindowEventCallback);
+ offWindowEventCallback = OffWindow;
+ Interop.ActorSignal.OffSceneConnect(SwigCPtr, offWindowEventCallback.ToHandleRef(this));
+ NDalicPINVOKE.ThrowExceptionIfExists();
}
-
- _offWindowEventHandler += value;
+ offWindowEventHandler += value;
}
remove
{
- _offWindowEventHandler -= value;
-
- if (_offWindowEventHandler == null && OffWindowSignal().Empty() == false)
+ offWindowEventHandler -= value;
+ if (offWindowEventHandler == null && offWindowEventCallback != null)
{
- this.OffWindowSignal().Disconnect(_offWindowEventCallback);
+ Interop.ActorSignal.OffSceneDisconnect(SwigCPtr, offWindowEventCallback.ToHandleRef(this));
+ NDalicPINVOKE.ThrowExceptionIfExists();
+ offWindowEventCallback = null;
}
}
}
{
add
{
- if (_visibilityChangedEventHandler == null)
+ if (visibilityChangedEventHandler == null)
{
- _visibilityChangedEventCallback = OnVisibilityChanged;
- VisibilityChangedSignal(this).Connect(_visibilityChangedEventCallback);
+ visibilityChangedEventCallback = OnVisibilityChanged;
+ Interop.ActorSignal.VisibilityChangedConnect(SwigCPtr, visibilityChangedEventCallback.ToHandleRef(this));
+ NDalicPINVOKE.ThrowExceptionIfExists();
}
-
- _visibilityChangedEventHandler += value;
+ visibilityChangedEventHandler += value;
}
remove
{
- _visibilityChangedEventHandler -= value;
-
- if (_visibilityChangedEventHandler == null && VisibilityChangedSignal(this).Empty() == false)
+ visibilityChangedEventHandler -= value;
+ if (visibilityChangedEventHandler == null && visibilityChangedEventCallback != null)
{
- VisibilityChangedSignal(this).Disconnect(_visibilityChangedEventCallback);
+ Interop.ActorSignal.VisibilityChangedDisconnect(SwigCPtr, visibilityChangedEventCallback.ToHandleRef(this));
+ NDalicPINVOKE.ThrowExceptionIfExists();
+ visibilityChangedEventCallback = null;
}
}
}
{
add
{
- if (_layoutDirectionChangedEventHandler == null)
+ if (layoutDirectionChangedEventHandler == null)
{
- _layoutDirectionChangedEventCallback = OnLayoutDirectionChanged;
- LayoutDirectionChangedSignal(this).Connect(_layoutDirectionChangedEventCallback);
+ layoutDirectionChangedEventCallback = OnLayoutDirectionChanged;
+ Interop.ActorSignal.LayoutDirectionChangedConnect(SwigCPtr, layoutDirectionChangedEventCallback.ToHandleRef(this));
+ NDalicPINVOKE.ThrowExceptionIfExists();
}
- _layoutDirectionChangedEventHandler += value;
+ layoutDirectionChangedEventHandler += value;
}
remove
{
- _layoutDirectionChangedEventHandler -= value;
+ layoutDirectionChangedEventHandler -= value;
- if (_layoutDirectionChangedEventHandler == null && LayoutDirectionChangedSignal(this).Empty() == false)
+ if (layoutDirectionChangedEventHandler == null && layoutDirectionChangedEventCallback != null)
{
- LayoutDirectionChangedSignal(this).Disconnect(_layoutDirectionChangedEventCallback);
+ Interop.ActorSignal.LayoutDirectionChangedDisconnect(SwigCPtr, layoutDirectionChangedEventCallback.ToHandleRef(this));
+ NDalicPINVOKE.ThrowExceptionIfExists();
+ layoutDirectionChangedEventCallback = null;
}
}
}
{
add
{
- if (_resourcesLoadedEventHandler == null)
+ if (resourcesLoadedEventHandler == null)
{
- _ResourcesLoadedCallback = OnResourcesLoaded;
- this.ResourcesLoadedSignal().Connect(_ResourcesLoadedCallback);
+ resourcesLoadedCallback = OnResourcesLoaded;
+ Interop.ViewSignal.ResourceReadyConnect(SwigCPtr, resourcesLoadedCallback.ToHandleRef(this));
+ NDalicPINVOKE.ThrowExceptionIfExists();
}
-
- _resourcesLoadedEventHandler += value;
+ resourcesLoadedEventHandler += value;
}
remove
{
- _resourcesLoadedEventHandler -= value;
-
- if (_resourcesLoadedEventHandler == null && ResourcesLoadedSignal().Empty() == false)
+ resourcesLoadedEventHandler -= value;
+ if (resourcesLoadedEventHandler == null && resourcesLoadedCallback != null)
{
- this.ResourcesLoadedSignal().Disconnect(_ResourcesLoadedCallback);
+ Interop.ViewSignal.ResourceReadyDisconnect(SwigCPtr, resourcesLoadedCallback.ToHandleRef(this));
+ NDalicPINVOKE.ThrowExceptionIfExists();
+ resourcesLoadedCallback = null;
}
}
}
[EditorBrowsable(EditorBrowsableState.Never)]
internal void EmitBackKeyPressed()
{
- _backKeyPressed.Invoke(this,null);
+ _backKeyPressed.Invoke(this, null);
}
{
add
{
- if (_backgroundResourceLoadedEventHandler == null)
+ if (backgroundResourceLoadedEventHandler == null)
{
- _backgroundResourceLoadedCallback = OnBackgroundResourceLoaded;
- this.ResourcesLoadedSignal().Connect(_backgroundResourceLoadedCallback);
+ backgroundResourceLoadedCallback = OnBackgroundResourceLoaded;
+ Interop.ViewSignal.ResourceReadyConnect(SwigCPtr, backgroundResourceLoadedCallback.ToHandleRef(this));
+ NDalicPINVOKE.ThrowExceptionIfExists();
}
-
- _backgroundResourceLoadedEventHandler += value;
+ backgroundResourceLoadedEventHandler += value;
}
+
remove
{
- _backgroundResourceLoadedEventHandler -= value;
-
- if (_backgroundResourceLoadedEventHandler == null && ResourcesLoadedSignal().Empty() == false)
+ backgroundResourceLoadedEventHandler -= value;
+ if (backgroundResourceLoadedEventHandler == null && backgroundResourceLoadedCallback != null)
{
- this.ResourcesLoadedSignal().Disconnect(_backgroundResourceLoadedCallback);
+ Interop.ViewSignal.ResourceReadyDisconnect(SwigCPtr, backgroundResourceLoadedCallback.ToHandleRef(this));
+ NDalicPINVOKE.ThrowExceptionIfExists();
+ backgroundResourceLoadedCallback = null;
}
}
}
- internal TouchDataSignal InterceptTouchSignal()
- {
- TouchDataSignal ret = new TouchDataSignal(Interop.ActorSignal.Actor_InterceptTouchSignal(swigCPtr), false);
- if (NDalicPINVOKE.SWIGPendingException.Pending)
- throw NDalicPINVOKE.SWIGPendingException.Retrieve();
- return ret;
- }
-
- internal TouchDataSignal TouchSignal()
- {
- TouchDataSignal ret = new TouchDataSignal(Interop.ActorSignal.Actor_TouchSignal(swigCPtr), false);
- if (NDalicPINVOKE.SWIGPendingException.Pending)
- throw NDalicPINVOKE.SWIGPendingException.Retrieve();
- return ret;
- }
-
- internal HoverSignal HoveredSignal()
- {
- HoverSignal ret = new HoverSignal(Interop.ActorSignal.Actor_HoveredSignal(swigCPtr), false);
- if (NDalicPINVOKE.SWIGPendingException.Pending)
- throw NDalicPINVOKE.SWIGPendingException.Retrieve();
- return ret;
- }
-
- internal WheelSignal WheelEventSignal()
+ private void OnColorChanged(float r, float g, float b, float a)
{
- WheelSignal ret = new WheelSignal(Interop.ActorSignal.Actor_WheelEventSignal(swigCPtr), false);
- if (NDalicPINVOKE.SWIGPendingException.Pending)
- throw NDalicPINVOKE.SWIGPendingException.Retrieve();
- return ret;
+ Color = new Color(r, g, b, a);
}
- internal ViewSignal OnWindowSignal()
+ private void OnMinimumSizeChanged(int width, int height)
{
- ViewSignal ret = new ViewSignal(Interop.ActorSignal.Actor_OnSceneSignal(swigCPtr), false);
- if (NDalicPINVOKE.SWIGPendingException.Pending)
- throw NDalicPINVOKE.SWIGPendingException.Retrieve();
- return ret;
- }
-
- internal ViewSignal OffWindowSignal()
- {
- ViewSignal ret = new ViewSignal(Interop.ActorSignal.Actor_OffSceneSignal(swigCPtr), false);
- if (NDalicPINVOKE.SWIGPendingException.Pending)
- throw NDalicPINVOKE.SWIGPendingException.Retrieve();
- return ret;
- }
-
- internal ViewSignal OnRelayoutSignal()
- {
- ViewSignal ret = new ViewSignal(Interop.ActorSignal.Actor_OnRelayoutSignal(swigCPtr), false);
- if (NDalicPINVOKE.SWIGPendingException.Pending)
- throw NDalicPINVOKE.SWIGPendingException.Retrieve();
- return ret;
- }
-
- internal ViewVisibilityChangedSignal VisibilityChangedSignal(View view)
- {
- ViewVisibilityChangedSignal ret = new ViewVisibilityChangedSignal(Interop.NDalic.VisibilityChangedSignal(View.getCPtr(view)), false);
- if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
- return ret;
- }
-
- internal ViewLayoutDirectionChangedSignal LayoutDirectionChangedSignal(View view)
- {
- ViewLayoutDirectionChangedSignal ret = new ViewLayoutDirectionChangedSignal(Interop.Layout.LayoutDirectionChangedSignal(View.getCPtr(view)), false);
- if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
- return ret;
- }
-
- internal ViewSignal ResourcesLoadedSignal()
- {
- ViewSignal ret = new ViewSignal(Interop.View.ResourceReadySignal(swigCPtr), false);
- if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
- return ret;
- }
-
- internal ControlKeySignal KeyEventSignal()
- {
- ControlKeySignal ret = new ControlKeySignal(Interop.ViewSignal.View_KeyEventSignal(swigCPtr), false);
- if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
- return ret;
- }
-
- internal KeyInputFocusSignal KeyInputFocusGainedSignal()
- {
- KeyInputFocusSignal ret = new KeyInputFocusSignal(Interop.ViewSignal.View_KeyInputFocusGainedSignal(swigCPtr), false);
- if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
- return ret;
- }
-
- internal KeyInputFocusSignal KeyInputFocusLostSignal()
- {
- KeyInputFocusSignal ret = new KeyInputFocusSignal(Interop.ViewSignal.View_KeyInputFocusLostSignal(swigCPtr), false);
- if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
- return ret;
- }
-
- private void OnSize2DChanged(int? width, int? height)
- {
- if (width != null)
- {
- Tizen.NUI.Object.SetProperty(this.swigCPtr, View.Property.SIZE_WIDTH, new Tizen.NUI.PropertyValue((float)width));
- }
- if (height != null)
- {
- Tizen.NUI.Object.SetProperty(this.swigCPtr, View.Property.SIZE_HEIGHT, new Tizen.NUI.PropertyValue((float)height));
- }
+ MinimumSize = new Size2D(width, height);
}
- private void OnMinimumSizeChanged(int? width, int? height)
+ private void OnMaximumSizeChanged(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.
- }
+ MaximumSize = new Size2D(width, height);
}
- private void OnMaximumSizeChanged(int? width, int? height)
+ private void OnPosition2DChanged(int x, int y)
{
- 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.
- }
+ SetPosition((float)x, (float)y, 0);
}
- private void OnPosition2DChanged(int x, int y)
+ private void OnPositionChanged(float x, float y, float z)
{
- Position2D = new Position2D(x, y);
+ SetPosition(x, y, z);
}
- private void OnSizeChanged(float? width, float? height, float? depth)
+ private void OnSize2DChanged(int width, int height)
{
- if (width != null)
- {
- Tizen.NUI.Object.SetProperty(this.swigCPtr, View.Property.SIZE_WIDTH, new Tizen.NUI.PropertyValue((float)width));
- }
- if (height != null)
- {
- Tizen.NUI.Object.SetProperty(this.swigCPtr, View.Property.SIZE_HEIGHT, new Tizen.NUI.PropertyValue((float)height));
- }
- if (depth != null)
- {
- Tizen.NUI.Object.SetProperty(this.swigCPtr, View.Property.SIZE_DEPTH, new Tizen.NUI.PropertyValue((float)depth));
- }
+ SetSize((float)width, (float)height, 0);
}
- private void OnPositionChanged(float x, float y, float z)
+ private void OnSizeChanged(float width, float height, float depth)
{
- Position = new Position(x, y, z);
+ 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);
+ }
+ }
+
+ // Callback for View HitTestResultSignal
+ private bool OnHitTestResult(IntPtr view, IntPtr touchData)
+ {
+ if (touchData == global::System.IntPtr.Zero)
{
- _onRelayoutEventHandler(this, null);
+ NUILog.Error("touchData should not be null!");
+ return true;
}
+
+ TouchEventArgs e = new TouchEventArgs();
+ e.Touch = Tizen.NUI.Touch.GetTouchFromPtr(touchData);
+ return HitTest(e.Touch);
}
// Callback for View TouchSignal
bool consumed = false;
- if (_interceptTouchDataEventHandler != null)
+ if (interceptTouchDataEventHandler != null)
{
- consumed = _interceptTouchDataEventHandler(this, e);
+ consumed = interceptTouchDataEventHandler(this, e);
}
return consumed;
return true;
}
+ if (DispatchTouchEvents == false)
+ {
+ NUILog.Debug("If DispatchTouchEvents is false, it can not dispatch.");
+ return true;
+ }
+
TouchEventArgs e = new TouchEventArgs();
e.Touch = Tizen.NUI.Touch.GetTouchFromPtr(touchData);
bool consumed = false;
- if (_touchDataEventHandler != null)
+ if (touchDataEventHandler != null)
{
- consumed = _touchDataEventHandler(this, e);
+ consumed = touchDataEventHandler(this, e);
}
if (enableControlState && !consumed)
consumed = HandleControlStateOnTouch(e.Touch);
}
+ if (DispatchParentTouchEvents == false)
+ {
+ NUILog.Debug("If DispatchParentTouchEvents is false, it can not dispatch to parent.");
+ return true;
+ }
+
return 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(!CheckResourceReady())
{
- _resourcesLoadedEventHandler(this, null);
+ return;
+ }
+
+ if (resourcesLoadedEventHandler != null)
+ {
+ resourcesLoadedEventHandler(this, null);
}
}
private void OnBackgroundResourceLoaded(IntPtr view)
{
BackgroundResourceLoadedEventArgs e = new BackgroundResourceLoadedEventArgs();
- e.Status = (ResourceLoadingStatusType)Interop.View.View_GetVisualResourceStatus(this.swigCPtr, Property.BACKGROUND);
+ e.Status = (ResourceLoadingStatusType)Interop.View.GetVisualResourceStatus(this.SwigCPtr, Property.BACKGROUND);
- if (_backgroundResourceLoadedEventHandler != null)
+ if (backgroundResourceLoadedEventHandler != null)
{
- _backgroundResourceLoadedEventHandler(this, e);
+ backgroundResourceLoadedEventHandler(this, e);
}
}
public ControlState CurrentState { get; }
}
- private EventHandlerWithReturnType<object, WheelEventArgs, bool> WindowWheelEventHandler;
- private void OnWindowWheelEvent(object sender, Window.WheelEventArgs 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
{
- if(e != null)
+ get
{
- if(e.Wheel.Type == Wheel.WheelType.CustomWheel)
- {
- var arg = new WheelEventArgs()
- {
- Wheel = e.Wheel,
- };
- WindowWheelEventHandler?.Invoke(this, arg);
- }
+ return (Offset)GetValue(TouchAreaOffsetProperty);
+ }
+ set
+ {
+ SetValue(TouchAreaOffsetProperty, value);
+ NotifyPropertyChanged();
}
}
- /// <summary>
- /// TouchArea can reset the view's touchable area.<br/>
- /// 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.
- /// </summary>
- [EditorBrowsable(EditorBrowsableState.Never)]
- public Size2D TouchArea
+ private Offset InternalTouchAreaOffset
{
get
{
- Size2D temp = new Size2D(0, 0);
- GetProperty(View.Property.TouchArea).Get(temp);
- return new Size2D(temp.Width, temp.Height);
+ 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
{
- SetProperty(View.Property.TouchArea, new Tizen.NUI.PropertyValue(value));
- NotifyPropertyChanged();
+ Interop.ActorInternal.SetTouchAreaOffset(SwigCPtr, value.Left, value.Right, value.Bottom, value.Top);
+ if (NDalicPINVOKE.SWIGPendingException.Pending)
+ throw NDalicPINVOKE.SWIGPendingException.Retrieve();
}
}