private int layoutCount = 0;
private ControlState propagatableControlStates = ControlState.All;
- // List of dispatch Event
- private PanGestureDetector panGestureDetector = null;
- private LongPressGestureDetector longGestureDetector = null;
- private PinchGestureDetector pinchGestureDetector = null;
- private TapGestureDetector tapGestureDetector = null;
- private RotationGestureDetector rotationGestureDetector = null;
- private int configGestureCount = 0;
- private bool dispatchTouchEvents = true;
- private bool dispatchGestureEvents = true;
- private bool dispatchParentGestureEvents = true;
private string internalName = string.Empty;
private Position internalCurrentParentOrigin = null;
private Position internalCurrentAnchorPoint = null;
private Vector3 internalTargetSize = null;
private Size2D internalCurrentSize = null;
- private Vector3 internalNaturalSize = null;
private Position internalCurrentPosition = null;
private Vector3 internalCurrentWorldPosition = null;
private Vector3 internalCurrentScale = null;
private Vector4 internalCurrentWorldColor = null;
private Vector2 internalCurrentScreenPosition = null;
+ private static int aliveCount = 0;
+
static View()
{
RegisterPropertyGroup(PositionProperty, positionPropertyGroup);
RegisterAccessibilityDelegate();
}
+ static internal new void Preload()
+ {
+ Container.Preload();
+
+ // Do nothing. Just call for load static values.
+ var temporalPositionPropertyGroup = positionPropertyGroup;
+ var temporalSizePropertyGroup = sizePropertyGroup;
+ var temporalScalePropertyGroup = scalePropertyGroup;
+ }
+
+ /// <summary>
+ /// Accessibility mode for controlling View's Accessible implementation.
+ /// It is only relevant when deriving custom controls from View directly,
+ /// as classes derived from CustomView (or any of its subclasses) get the
+ /// Custom mode by default.
+ /// </summary>
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public enum ViewAccessibilityMode
+ {
+ /// <summary>
+ /// Default accessibility implementation. Overriding View.Accessibility...()
+ /// virtual methods will have no effect.
+ /// </summary>
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ Default,
+ /// <summary>
+ /// Custom accessibility implementation. Overriding View.Accessibility...()
+ /// will be necessary to provide accessibility support for the View.
+ /// </summary>
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ Custom,
+ }
+
+ private static IntPtr NewWithAccessibilityMode(ViewAccessibilityMode accessibilityMode)
+ {
+ switch (accessibilityMode)
+ {
+ case ViewAccessibilityMode.Custom:
+ {
+ return Interop.View.NewCustom();
+ }
+ case ViewAccessibilityMode.Default:
+ default:
+ {
+ return Interop.View.New();
+ }
+ }
+ }
+
/// <summary>
/// Creates a new instance of a view.
/// </summary>
/// <since_tizen> 3 </since_tizen>
- public View() : this(Interop.View.New(), true)
+ public View() : this(ViewAccessibilityMode.Default)
+ {
+ }
+
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public View(ViewAccessibilityMode accessibilityMode) : this(NewWithAccessibilityMode(accessibilityMode), true)
{
if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
}
SetVisible(shown);
}
- internal View(View uiControl, bool shown = true) : this(Interop.View.NewView(View.getCPtr(uiControl)), true)
+ internal View(global::System.IntPtr cPtr, bool cMemoryOwn, ViewStyle viewStyle, bool shown = true) : this(cPtr, cMemoryOwn, shown)
{
- if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
- if (!shown)
- {
- SetVisible(false);
- }
-
- backgroundExtraData = uiControl.backgroundExtraData == null ? null : new BackgroundExtraData(uiControl.backgroundExtraData);
+ InitializeStyle(viewStyle);
}
- internal View(global::System.IntPtr cPtr, bool cMemoryOwn, ViewStyle viewStyle, bool shown = true) : this(cPtr, cMemoryOwn, shown)
+ internal View(global::System.IntPtr cPtr, bool cMemoryOwn, bool shown = true) : this(cPtr, cMemoryOwn, shown, cMemoryOwn)
{
- InitializeStyle(viewStyle);
}
- internal View(global::System.IntPtr cPtr, bool cMemoryOwn, bool shown = true) : base(cPtr, cMemoryOwn)
+ internal View(global::System.IntPtr cPtr, bool cMemoryOwn, bool shown, bool cRegister) : base(cPtr, cMemoryOwn, cRegister)
{
if (HasBody())
{
PositionUsesPivotPoint = false;
+ GrabTouchAfterLeave = defaultGrabTouchAfterLeave;
+ AllowOnlyOwnTouch = defaultAllowOnlyOwnTouch;
}
- onWindowSendEventCallback = SendViewAddedEventToWindow;
- using ViewSignal signal = new ViewSignal(Interop.ActorSignal.ActorOnSceneSignal(SwigCPtr), false);
- signal?.Connect(onWindowSendEventCallback);
-
- hitTestResultDataCallback = OnHitTestResult;
- using TouchDataSignal touchDataSignal = new TouchDataSignal(Interop.ActorSignal.ActorHitTestResultSignal(SwigCPtr), false);
- touchDataSignal?.Connect(hitTestResultDataCallback);
-
if (!shown)
{
SetVisible(false);
}
- GrabTouchAfterLeave = defaultGrabTouchAfterLeave;
- AllowOnlyOwnTouch = defaultAllowOnlyOwnTouch;
+ aliveCount++;
}
internal View(ViewImpl implementation, bool shown = true) : this(Interop.View.NewViewInternal(ViewImpl.getCPtr(implementation)), true)
{
using (var propertyValue = GetProperty(Property.TOOLTIP))
{
- if (propertyValue != null && propertyValue.Get(out string retrivedValue))
+ using var propertyMap = new PropertyMap();
+ if (propertyValue != null && propertyValue.Get(propertyMap))
{
- return retrivedValue;
+ using var retrivedContentValue = propertyMap?.Find(NDalic.TooltipContent);
+ if (retrivedContentValue != null)
+ {
+ using var contextPropertyMap = new PropertyMap();
+ if (retrivedContentValue.Get(contextPropertyMap))
+ {
+ using var retrivedTextValue = contextPropertyMap?.Find(NDalic.TextVisualText);
+ if (retrivedTextValue != null && retrivedTextValue.Get(out string retrivedValue))
+ {
+ return retrivedValue;
+ }
+ }
+ }
}
- NUILog.Error($"[ERROR] Fail to get TooltipText! Return error MSG (error to get TooltipText)!");
- return "error to get TooltipText";
+ return "";
}
}
set
{
Vector3 temp = GetNaturalSize();
if (NDalicPINVOKE.SWIGPendingException.Pending) throw new InvalidOperationException("FATAL: get Exception", NDalicPINVOKE.SWIGPendingException.Retrieve());
-
- Size2D sz = new Size2D((int)temp.Width, (int)temp.Height);
- temp.Dispose();
+ Size2D sz = null;
+ if (temp != null)
+ {
+ sz = new Size2D((int)temp.Width, (int)temp.Height);
+ temp.Dispose();
+ }
return sz;
}
}
set
{
Object.InternalSetPropertyBool(SwigCPtr, View.Property.CaptureAllTouchAfterStart, value);
+
+ // Use custom HitTest callback only if GrabTouchAfterLeave is true.
+ if (value)
+ {
+ RegisterHitTestCallback();
+ }
+ else
+ {
+ UnregisterHitTestCallback();
+ }
+
NotifyPropertyChanged();
}
}
}
/// <summary>
- /// Gets or sets the status of whether the view should emit key event signals.
- /// If a View's DispatchKeyEvents is set to false, then itself and parents will not receive key event signals.
- /// </summary>
- [EditorBrowsable(EditorBrowsableState.Never)]
- public bool DispatchKeyEvents
- {
- get
- {
- return (bool)GetValue(DispatchKeyEventsProperty);
- }
- set
- {
- SetValue(DispatchKeyEventsProperty, value);
- NotifyPropertyChanged();
- }
- }
-
- /// <summary>
- /// Gets or sets the status of whether touch events can be dispatched.
- /// If a View's DispatchTouchEvents is set to false, then it's can not will receive touch and parents will not receive a touch event signal either.
- /// This works without adding a TouchEvent callback in the View.
- /// <note>
- /// If the <see cref="Tizen.NUI.BaseComponents.View.Sensitive"/> is a property that determines whether or not to be hittable, then this property prevents the propagation of the hit touch event.
- /// </note>
- /// </summary>
- [EditorBrowsable(EditorBrowsableState.Never)]
- public bool DispatchTouchEvents
- {
- get
- {
- return dispatchTouchEvents;
- }
- set
- {
- if (dispatchTouchEvents != value)
- {
- dispatchTouchEvents = value;
- if (dispatchTouchEvents == false)
- {
- TouchEvent += OnDispatchTouchEvent;
- }
- else
- {
- TouchEvent -= OnDispatchTouchEvent;
- }
- }
- }
- }
-
- private bool OnDispatchTouchEvent(object source, View.TouchEventArgs e)
- {
- return true;
- }
-
- /// <summary>
- /// Gets or sets the status of whether the view should emit Gesture event signals.
- /// If a View's DispatchGestureEvents is set to false, then itself and parents will not receive all gesture event signals.
- /// The itself and parents does not receive tap, pinch, pan, rotation, or longpress gestures.
- /// </summary>
- [EditorBrowsable(EditorBrowsableState.Never)]
- public bool DispatchGestureEvents
- {
- get
- {
- return dispatchGestureEvents;
- }
- set
- {
- if (dispatchGestureEvents != value)
- {
- dispatchGestureEvents = value;
- ConfigGestureDetector(dispatchGestureEvents);
- }
- }
- }
-
- /// <summary>
- /// Gets or sets the status of whether the view should emit Gesture event signals.
- /// If a View's DispatchParentGestureEvents is set to false, then parents will not receive all gesture event signals.
- /// The parents does not receive tap, pinch, pan, rotation, or longpress gestures.
- /// </summary>
- [EditorBrowsable(EditorBrowsableState.Never)]
- public bool DispatchParentGestureEvents
- {
- get
- {
- return dispatchParentGestureEvents;
- }
- set
- {
- if (dispatchParentGestureEvents != value)
- {
- dispatchParentGestureEvents = value;
- ConfigGestureDetector(dispatchParentGestureEvents);
- }
- }
- }
-
- private void ConfigGestureDetector(bool dispatch)
- {
- if (panGestureDetector == null) panGestureDetector = new PanGestureDetector();
- if (longGestureDetector == null) longGestureDetector = new LongPressGestureDetector();
- if (pinchGestureDetector == null) pinchGestureDetector = new PinchGestureDetector();
- if (tapGestureDetector == null) tapGestureDetector = new TapGestureDetector();
- if (rotationGestureDetector == null) rotationGestureDetector = new RotationGestureDetector();
-
- if (dispatch == true)
- {
- configGestureCount = configGestureCount > 0 ? configGestureCount-- : 0;
- if (configGestureCount == 0)
- {
- panGestureDetector.Detach(this);
- longGestureDetector.Detach(this);
- pinchGestureDetector.Detach(this);
- tapGestureDetector.Detach(this);
- rotationGestureDetector.Detach(this);
-
- panGestureDetector.Detected -= OnGestureDetected;
- longGestureDetector.Detected -= OnGestureDetected;
- pinchGestureDetector.Detected -= OnGestureDetected;
- tapGestureDetector.Detected -= OnGestureDetected;
- rotationGestureDetector.Detected -= OnGestureDetected;
-
- panGestureDetector = null;
- longGestureDetector = null;
- pinchGestureDetector = null;
- tapGestureDetector = null;
- rotationGestureDetector = null;
- }
- }
- else
- {
- if (configGestureCount == 0)
- {
- panGestureDetector.Attach(this);
- longGestureDetector.Attach(this);
- pinchGestureDetector.Attach(this);
- tapGestureDetector.Attach(this);
- rotationGestureDetector.Attach(this);
-
- panGestureDetector.Detected += OnGestureDetected;
- longGestureDetector.Detected += OnGestureDetected;
- pinchGestureDetector.Detected += OnGestureDetected;
- tapGestureDetector.Detected += OnGestureDetected;
- rotationGestureDetector.Detected += OnGestureDetected;
- }
- configGestureCount++;
- }
- }
-
- private void OnGestureDetected(object source, EventArgs e)
- {
- // Does notting. This is to consume the gesture.
- }
-
- /// <summary>
/// Called when the view is hit through TouchEvent or GestureEvent.
/// If it returns true, it means that it was hit, and the touch/gesture event is called from the view.
/// If it returns false, it means that it will not be hit, and the hit-test continues to the next view.
[EditorBrowsable(EditorBrowsableState.Never)]
public Vector3 CurrentScale => GetCurrentScale();
+ /// <summary>
+ /// Gets the number of currently alived View object.
+ /// </summary>
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public static int AliveCount => aliveCount;
+
}
}