Browse Source

Merge pull request #8766 from AvaloniaUI/make-pointerpoint-to-be-a-struct

Make PointerPoint and PointerPointProperties to be a struct.
pull/8778/head
Dan Walmsley 4 years ago
committed by GitHub
parent
commit
e33d295a94
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 4
      samples/ControlCatalog/Pages/PointerCanvas.cs
  2. 30
      src/Avalonia.Base/Input/PointerPoint.cs

4
samples/ControlCatalog/Pages/PointerCanvas.cs

@ -174,9 +174,9 @@ Twist: {_lastProperties?.Twist}";
var lastPointer = e.GetCurrentPoint(this); var lastPointer = e.GetCurrentPoint(this);
_lastProperties = lastPointer.Properties; _lastProperties = lastPointer.Properties;
if (_lastProperties.PointerUpdateKind != PointerUpdateKind.Other) if (_lastProperties?.PointerUpdateKind != PointerUpdateKind.Other)
{ {
_lastNonOtherUpdateKind = _lastProperties.PointerUpdateKind; _lastNonOtherUpdateKind = _lastProperties?.PointerUpdateKind;
} }
if (e.RoutedEvent == PointerReleasedEvent && e.Pointer.Type == PointerType.Touch) if (e.RoutedEvent == PointerReleasedEvent && e.Pointer.Type == PointerType.Touch)

30
src/Avalonia.Base/Input/PointerPoint.cs

@ -5,7 +5,7 @@ namespace Avalonia.Input
/// <summary> /// <summary>
/// Provides basic properties for the input pointer associated with a single mouse, pen/stylus, or touch contact. /// Provides basic properties for the input pointer associated with a single mouse, pen/stylus, or touch contact.
/// </summary> /// </summary>
public sealed class PointerPoint public struct PointerPoint
{ {
public PointerPoint(IPointer pointer, Point position, PointerPointProperties properties) public PointerPoint(IPointer pointer, Point position, PointerPointProperties properties)
{ {
@ -33,47 +33,47 @@ namespace Avalonia.Input
/// <summary> /// <summary>
/// Provides extended properties for a PointerPoint object. /// Provides extended properties for a PointerPoint object.
/// </summary> /// </summary>
public sealed class PointerPointProperties public struct PointerPointProperties
{ {
/// <summary> /// <summary>
/// Gets a value that indicates whether the pointer input was triggered by the primary action mode of an input device. /// Gets a value that indicates whether the pointer input was triggered by the primary action mode of an input device.
/// </summary> /// </summary>
public bool IsLeftButtonPressed { get; } public bool IsLeftButtonPressed { get; } = false;
/// <summary> /// <summary>
/// Gets a value that indicates whether the pointer input was triggered by the tertiary action mode of an input device. /// Gets a value that indicates whether the pointer input was triggered by the tertiary action mode of an input device.
/// </summary> /// </summary>
public bool IsMiddleButtonPressed { get; } public bool IsMiddleButtonPressed { get; } = false;
/// <summary> /// <summary>
/// Gets a value that indicates whether the pointer input was triggered by the secondary action mode (if supported) of an input device. /// Gets a value that indicates whether the pointer input was triggered by the secondary action mode (if supported) of an input device.
/// </summary> /// </summary>
public bool IsRightButtonPressed { get; } public bool IsRightButtonPressed { get; } = false;
/// <summary> /// <summary>
/// Gets a value that indicates whether the pointer input was triggered by the first extended mouse button (XButton1). /// Gets a value that indicates whether the pointer input was triggered by the first extended mouse button (XButton1).
/// </summary> /// </summary>
public bool IsXButton1Pressed { get; } public bool IsXButton1Pressed { get; } = false;
/// <summary> /// <summary>
/// Gets a value that indicates whether the pointer input was triggered by the second extended mouse button (XButton2). /// Gets a value that indicates whether the pointer input was triggered by the second extended mouse button (XButton2).
/// </summary> /// </summary>
public bool IsXButton2Pressed { get; } public bool IsXButton2Pressed { get; } = false;
/// <summary> /// <summary>
/// Gets a value that indicates whether the barrel button of the pen/stylus device is pressed. /// Gets a value that indicates whether the barrel button of the pen/stylus device is pressed.
/// </summary> /// </summary>
public bool IsBarrelButtonPressed { get; } public bool IsBarrelButtonPressed { get; } = false;
/// <summary> /// <summary>
/// Gets a value that indicates whether the input is from a pen eraser. /// Gets a value that indicates whether the input is from a pen eraser.
/// </summary> /// </summary>
public bool IsEraser { get; } public bool IsEraser { get; } = false;
/// <summary> /// <summary>
/// Gets a value that indicates whether the digitizer pen is inverted. /// Gets a value that indicates whether the digitizer pen is inverted.
/// </summary> /// </summary>
public bool IsInverted { get; } public bool IsInverted { get; } = false;
/// <summary> /// <summary>
/// Gets the clockwise rotation in degrees of a pen device around its own major axis (such as when the user spins the pen in their fingers). /// Gets the clockwise rotation in degrees of a pen device around its own major axis (such as when the user spins the pen in their fingers).
@ -81,7 +81,7 @@ namespace Avalonia.Input
/// <returns> /// <returns>
/// A value between 0.0 and 359.0 in degrees of rotation. The default value is 0.0. /// A value between 0.0 and 359.0 in degrees of rotation. The default value is 0.0.
/// </returns> /// </returns>
public float Twist { get; } public float Twist { get; } = 0.0F;
/// <summary> /// <summary>
/// Gets a value that indicates the force that the pointer device (typically a pen/stylus) exerts on the surface of the digitizer. /// Gets a value that indicates the force that the pointer device (typically a pen/stylus) exerts on the surface of the digitizer.
@ -97,7 +97,7 @@ namespace Avalonia.Input
/// <returns> /// <returns>
/// The value is 0.0 when the finger or pen is perpendicular to the digitizer surface, between 0.0 and 90.0 when tilted to the right of perpendicular, and between 0.0 and -90.0 when tilted to the left of perpendicular. The default value is 0.0. /// The value is 0.0 when the finger or pen is perpendicular to the digitizer surface, between 0.0 and 90.0 when tilted to the right of perpendicular, and between 0.0 and -90.0 when tilted to the left of perpendicular. The default value is 0.0.
/// </returns> /// </returns>
public float XTilt { get; } public float XTilt { get; } = 0.0F;
/// <summary> /// <summary>
/// Gets the plane angle between the X-Z plane and the plane that contains the X axis and the axis of the input device (typically a pen/stylus). /// Gets the plane angle between the X-Z plane and the plane that contains the X axis and the axis of the input device (typically a pen/stylus).
@ -105,14 +105,14 @@ namespace Avalonia.Input
/// <returns> /// <returns>
/// The value is 0.0 when the finger or pen is perpendicular to the digitizer surface, between 0.0 and 90.0 when tilted towards the user, and between 0.0 and -90.0 when tilted away from the user. The default value is 0.0. /// The value is 0.0 when the finger or pen is perpendicular to the digitizer surface, between 0.0 and 90.0 when tilted towards the user, and between 0.0 and -90.0 when tilted away from the user. The default value is 0.0.
/// </returns> /// </returns>
public float YTilt { get; } public float YTilt { get; } = 0.0F;
/// <summary> /// <summary>
/// Gets the kind of pointer state change. /// Gets the kind of pointer state change.
/// </summary> /// </summary>
public PointerUpdateKind PointerUpdateKind { get; } public PointerUpdateKind PointerUpdateKind { get; } = PointerUpdateKind.LeftButtonPressed;
private PointerPointProperties() public PointerPointProperties()
{ {
} }

Loading…
Cancel
Save