Dashboard/Quik/Mouse.cs

74 lines
1.8 KiB
C#

using System;
namespace Quik
{
public enum MouseButton
{
Primary = 1 << 0,
Secondary = 1 << 1,
Tertiary = 1 << 2,
Auxilliary1 = 1 << 3,
Auxilliary2 = 1 << 4,
Auxilliary3 = 1 << 5,
Auxilliary4 = 1 << 6,
Auxilliary5 = 1 << 8,
}
public struct MouseState
{
public readonly QVec2 AbsolutePosition;
public readonly MouseButton ButtonsDown;
public MouseState(QVec2 position, MouseButton down)
{
AbsolutePosition = position;
ButtonsDown = down;
}
}
public class MouseButtonEventArgs : EventArgs
{
public QVec2 AbsolutePosition { get; }
public MouseButton Buttons { get; }
public MouseButtonEventArgs(QVec2 position, MouseButton buttons)
{
AbsolutePosition = position;
Buttons = buttons;
}
public QVec2 RelativePosition(QVec2 origin)
{
return AbsolutePosition - origin;
}
public QVec2 RelativePosition(Controls.Control control)
{
return AbsolutePosition - control.AbsoluteBounds.Min;
}
}
public class MouseMoveEventArgs : EventArgs
{
public QVec2 AbsolutePosition { get; }
public QVec2 LastPosition { get; }
public QVec2 Motion { get; }
public MouseMoveEventArgs(QVec2 position, QVec2 lastPosition)
{
AbsolutePosition = position;
LastPosition = lastPosition;
Motion = position - lastPosition;
}
public QVec2 RelativePosition(QVec2 origin)
{
return AbsolutePosition - origin;
}
public QVec2 RelativePosition(Controls.Control control)
{
return AbsolutePosition - control.AbsoluteBounds.Min;
}
}
}