/*
- * Copyright(c) 2019 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> _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 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;
+ onRelayoutEventHandler -= value;
+ if (onRelayoutEventHandler == null)
+ {
+ using ViewSignal signal = new ViewSignal(Interop.ActorSignal.ActorOnRelayoutSignal(SwigCPtr), false);
+ if (signal?.Empty() == false)
+ {
+ signal?.Disconnect(onRelayoutEventCallback);
+ onRelayoutEventCallback = null;
+ }
+ }
+ }
+ }
- if (_onRelayoutEventHandler == null && OnRelayoutSignal().Empty() == false)
+ /// <summary>
+ /// An event for the touched signal which can be used to subscribe or unsubscribe the event handler provided by the user.<br />
+ /// The touched signal is emitted when the touch input is received.<br />
+ /// This can receive touch events before child. <br />
+ /// If it returns false, the child can receive the touch event. If it returns true, the touch event is intercepted. So child cannot receive touch event.<br />
+ /// </summary>
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public event EventHandlerWithReturnType<object, TouchEventArgs, bool> InterceptTouchEvent
+ {
+ add
+ {
+ if (interceptTouchDataEventHandler == null)
{
- this.OnRelayoutSignal().Disconnect(_onRelayoutEventCallback);
+ interceptTouchDataCallback = OnInterceptTouch;
+ using TouchDataSignal signal = new TouchDataSignal(Interop.ActorSignal.ActorInterceptTouchSignal(SwigCPtr), false);
+ signal?.Connect(interceptTouchDataCallback);
}
+ interceptTouchDataEventHandler += value;
+ }
+ remove
+ {
+ interceptTouchDataEventHandler -= value;
+ if (interceptTouchDataEventHandler == null)
+ {
+ using TouchDataSignal signal = new TouchDataSignal(Interop.ActorSignal.ActorInterceptTouchSignal(SwigCPtr), false);
+ if (signal?.Empty() == false)
+ {
+ signal?.Disconnect(interceptTouchDataCallback);
+ interceptTouchDataCallback = null;
+ }
+ }
}
}
/// <summary>
+ /// If child view doesn't want the parent's view to intercept the touch, you can set it to true.
+ /// for example :
+ /// parent.Add(child);
+ /// parent.InterceptTouchEvent += OnInterceptTouchEvent;
+ /// View view = child.GetParent() as View;
+ /// view.DisallowInterceptTouchEvent = true;
+ /// This prevents the parent from intercepting touch.
+ /// </summary>
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public bool DisallowInterceptTouchEvent { get; set; }
+
+
+ /// <summary>
/// An event for the touched signal which can be used to subscribe or unsubscribe the event handler provided by the user.<br />
/// The touched signal is emitted when the touch input is received.<br />
/// </summary>
{
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);
+ 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);
+ 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);
+ using ViewSignal signal = new ViewSignal(Interop.View.ResourceReadySignal(SwigCPtr), false);
+ if (signal?.Empty() == false)
+ {
+ signal?.Disconnect(ResourcesLoadedCallback);
+ ResourcesLoadedCallback = null;
+ }
}
}
}
+ private EventHandler _backKeyPressed;
+
+ /// <summary>
+ /// An event for getting notice when physical back key is pressed.<br />
+ /// This event is emitted BackKey is up.<br />
+ /// </summary>
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public event EventHandler BackKeyPressed
+ {
+ add
+ {
+ _backKeyPressed += value;
+ BackKeyManager.Instance.Subscriber.Add(this);
+ }
+
+ remove
+ {
+ BackKeyManager.Instance.Subscriber.Remove(this);
+ _backKeyPressed -= value;
+ }
+ }
+
+ /// <summary>
+ /// Function for emitting BackKeyPressed event outside of View instance
+ /// </summary>
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ internal void EmitBackKeyPressed()
+ {
+ _backKeyPressed.Invoke(this, null);
+ }
+
+
internal event EventHandler<BackgroundResourceLoadedEventArgs> BackgroundResourceLoaded
{
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);
+ using ViewSignal signal = new ViewSignal(Interop.View.ResourceReadySignal(SwigCPtr), false);
+ if (signal?.Empty() == false)
+ {
+ signal?.Disconnect(backgroundResourceLoadedCallback);
+ backgroundResourceLoadedCallback = null;
+ }
}
}
}
+ internal TouchDataSignal InterceptTouchSignal()
+ {
+ TouchDataSignal ret = new TouchDataSignal(Interop.ActorSignal.ActorInterceptTouchSignal(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);
+ TouchDataSignal ret = new TouchDataSignal(Interop.ActorSignal.ActorTouchSignal(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);
+ HoverSignal ret = new HoverSignal(Interop.ActorSignal.ActorHoveredSignal(SwigCPtr), false);
if (NDalicPINVOKE.SWIGPendingException.Pending)
throw NDalicPINVOKE.SWIGPendingException.Retrieve();
return ret;
internal WheelSignal WheelEventSignal()
{
- WheelSignal ret = new WheelSignal(Interop.ActorSignal.Actor_WheelEventSignal(swigCPtr), false);
+ WheelSignal ret = new WheelSignal(Interop.ActorSignal.ActorWheelEventSignal(SwigCPtr), false);
if (NDalicPINVOKE.SWIGPendingException.Pending)
throw NDalicPINVOKE.SWIGPendingException.Retrieve();
return ret;
internal ViewSignal OnWindowSignal()
{
- ViewSignal ret = new ViewSignal(Interop.ActorSignal.Actor_OnStageSignal(swigCPtr), false);
+ ViewSignal ret = new ViewSignal(Interop.ActorSignal.ActorOnSceneSignal(SwigCPtr), false);
if (NDalicPINVOKE.SWIGPendingException.Pending)
throw NDalicPINVOKE.SWIGPendingException.Retrieve();
return ret;
internal ViewSignal OffWindowSignal()
{
- ViewSignal ret = new ViewSignal(Interop.ActorSignal.Actor_OffStageSignal(swigCPtr), false);
+ ViewSignal ret = new ViewSignal(Interop.ActorSignal.ActorOffSceneSignal(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);
+ ViewSignal ret = new ViewSignal(Interop.ActorSignal.ActorOnRelayoutSignal(SwigCPtr), false);
if (NDalicPINVOKE.SWIGPendingException.Pending)
throw NDalicPINVOKE.SWIGPendingException.Retrieve();
return ret;
internal ViewSignal ResourcesLoadedSignal()
{
- ViewSignal ret = new ViewSignal(Interop.View.ResourceReadySignal(swigCPtr), false);
+ 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);
+ ControlKeySignal ret = new ControlKeySignal(Interop.ViewSignal.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);
+ KeyInputFocusSignal ret = new KeyInputFocusSignal(Interop.ViewSignal.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);
+ KeyInputFocusSignal ret = new KeyInputFocusSignal(Interop.ViewSignal.KeyInputFocusLostSignal(SwigCPtr), false);
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
return ret;
}
- private void OnSize2DChanged(int width, int height)
+ private void OnColorChanged(float r, float g, float b, float a)
{
- Size2D = new Size2D(width, height);
+ Color = new Color(r, g, b, a);
}
private void OnMinimumSizeChanged(int width, int 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)
{
- Size = new Size(width, height, depth);
+ SetPosition(x, y, z);
}
- private void OnPositionChanged(float x, float y, float z)
+ private void OnSize2DChanged(int width, int height)
+ {
+ SetSize((float)width, (float)height, 0);
+ }
+
+ 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);
+ onRelayoutEventHandler(this, null);
}
}
// Callback for View TouchSignal
+ private bool OnInterceptTouch(IntPtr view, IntPtr touchData)
+ {
+ if (touchData == global::System.IntPtr.Zero)
+ {
+ NUILog.Error("touchData should not be null!");
+ return true;
+ }
+
+ // DisallowInterceptTouchEvent prevents the parent from intercepting touch.
+ if (DisallowInterceptTouchEvent)
+ {
+ return false;
+ }
+
+ TouchEventArgs e = new TouchEventArgs();
+
+ e.Touch = Tizen.NUI.Touch.GetTouchFromPtr(touchData);
+
+ bool consumed = false;
+
+ if (interceptTouchDataEventHandler != null)
+ {
+ consumed = interceptTouchDataEventHandler(this, e);
+ }
+
+ return consumed;
+ }
+
+ // Callback for View TouchSignal
private bool OnTouch(IntPtr view, IntPtr touchData)
{
if (touchData == global::System.IntPtr.Zero)
e.Touch = Tizen.NUI.Touch.GetTouchFromPtr(touchData);
- if (_touchDataEventHandler != null)
+ bool consumed = false;
+
+ if (touchDataEventHandler != null)
{
- return _touchDataEventHandler(this, e);
+ consumed = touchDataEventHandler(this, e);
}
- return false;
+
+ if (enableControlState && !consumed)
+ {
+ consumed = HandleControlStateOnTouch(e.Touch);
+ }
+
+ return consumed;
}
// Callback for View Hover signal
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);
}
}
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);
}
}
}
/// <summary>
+ /// The class represents the information of the situation where the View's control state changes.
/// </summary>
[EditorBrowsable(EditorBrowsableState.Never)]
- public class ControlStateChagedInfo
+ public class ControlStateChangedEventArgs : EventArgs
{
/// <summary>
- /// The previous control state.
+ /// Create an instance with mandatory fields.
/// </summary>
- public ControlStateChagedInfo(ControlStates previousState, ControlStates currentState, Touch touch)
+ /// <param name="previousState">The previous control state.</param>
+ /// <param name="currentState">The current control state.</param>
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public ControlStateChangedEventArgs(ControlState previousState, ControlState currentState)
{
PreviousState = previousState;
CurrentState = currentState;
- Touch = touch;
}
/// <summary>
/// The previous control state.
/// </summary>
- public ControlStates PreviousState { get; }
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public ControlState PreviousState { get; }
/// <summary>
/// The current control state.
/// </summary>
- public ControlStates CurrentState { get; }
-
- /// <summary>
- /// The touch information in case the state has changed by touching.
- /// </summary>
- /// <remarks>
- /// The value is null if it is not the case.
- /// </remarks>
- public Touch Touch { get; }
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public ControlState CurrentState { get; }
}
private EventHandlerWithReturnType<object, WheelEventArgs, bool> WindowWheelEventHandler;
private void OnWindowWheelEvent(object sender, Window.WheelEventArgs e)
{
- if(e != null)
+ if (e != null)
{
- if(e.Wheel.Type == Wheel.WheelType.CustomWheel)
+ if (e.Wheel.Type == Wheel.WheelType.CustomWheel)
{
var arg = new WheelEventArgs()
{
}
}
+ /// <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();
+ }
+ }
+
}
}