using System;
using System.Collections.Generic;
namespace Avalonia.Input.Raw
{
public enum RawPointerEventType
{
LeaveWindow,
LeftButtonDown,
LeftButtonUp,
RightButtonDown,
RightButtonUp,
MiddleButtonDown,
MiddleButtonUp,
XButton1Down,
XButton1Up,
XButton2Down,
XButton2Up,
Move,
Wheel,
NonClientLeftButtonDown,
TouchBegin,
TouchUpdate,
TouchEnd,
TouchCancel,
Magnify,
Rotate,
Swipe
}
///
/// A raw mouse event.
///
public class RawPointerEventArgs : RawInputEventArgs
{
private RawPointerPoint _point;
///
/// Initializes a new instance of the class.
///
/// The associated device.
/// The event timestamp.
/// The root from which the event originates.
/// The type of the event.
/// The mouse position, in client DIPs.
/// The input modifiers.
public RawPointerEventArgs(
IInputDevice device,
ulong timestamp,
IInputRoot root,
RawPointerEventType type,
Point position,
RawInputModifiers inputModifiers)
: base(device, timestamp, root)
{
Contract.Requires(device != null);
Contract.Requires(root != null);
Point = new RawPointerPoint();
Position = position;
Type = type;
InputModifiers = inputModifiers;
}
///
/// Initializes a new instance of the class.
///
/// The associated device.
/// The event timestamp.
/// The root from which the event originates.
/// The type of the event.
/// The point properties and position, in client DIPs.
/// The input modifiers.
public RawPointerEventArgs(
IInputDevice device,
ulong timestamp,
IInputRoot root,
RawPointerEventType type,
RawPointerPoint point,
RawInputModifiers inputModifiers)
: base(device, timestamp, root)
{
Contract.Requires(device != null);
Contract.Requires(root != null);
Point = point;
Type = type;
InputModifiers = inputModifiers;
}
///
/// Gets the raw pointer identifier.
///
public long RawPointerId { get; set; }
///
/// Gets the pointer properties and position, in client DIPs.
///
public RawPointerPoint Point
{
get => _point;
set => _point = value;
}
///
/// Gets the mouse position, in client DIPs.
///
public Point Position
{
get => _point.Position;
set => _point.Position = value;
}
///
/// Gets the type of the event.
///
public RawPointerEventType Type { get; set; }
///
/// Gets the input modifiers.
///
public RawInputModifiers InputModifiers { get; set; }
///
/// Points that were traversed by a pointer since the previous relevant event,
/// only valid for Move and TouchUpdate
///
public Lazy?>? IntermediatePoints { get; set; }
internal IInputElement? InputHitTestResult { get; set; }
}
public struct RawPointerPoint
{
///
/// Pointer position, in client DIPs.
///
public Point Position { get; set; }
public float Twist { get; set; }
public float Pressure { get; set; }
public float XTilt { get; set; }
public float YTilt { get; set; }
public RawPointerPoint()
{
this = default;
Pressure = 0.5f;
}
}
}