Dashboard/Quik/Mouse.cs
H. Utku Maden 9339295378 Push all uncommitted changes.
I have had a long break from this project due to other higher priority
things going on in my life. Big changes inbound.
2023-05-13 16:17:57 +03:00

74 lines
1.9 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 QuikVec2 AbsolutePosition;
public readonly MouseButton ButtonsDown;
public MouseState(QuikVec2 position, MouseButton down)
{
AbsolutePosition = position;
ButtonsDown = down;
}
}
public class MouseButtonEventArgs : EventArgs
{
public QuikVec2 AbsolutePosition { get; }
public MouseButton Buttons { get; }
public MouseButtonEventArgs(QuikVec2 position, MouseButton buttons)
{
AbsolutePosition = position;
Buttons = buttons;
}
public QuikVec2 RelativePosition(QuikVec2 origin)
{
return AbsolutePosition - origin;
}
public QuikVec2 RelativePosition(Controls.Control control)
{
return AbsolutePosition - control.AbsoluteBounds.Min;
}
}
public class MouseMoveEventArgs : EventArgs
{
public QuikVec2 AbsolutePosition { get; }
public QuikVec2 LastPosition { get; }
public QuikVec2 Motion { get; }
public MouseMoveEventArgs(QuikVec2 position, QuikVec2 lastPosition)
{
AbsolutePosition = position;
LastPosition = lastPosition;
Motion = position - lastPosition;
}
public QuikVec2 RelativePosition(QuikVec2 origin)
{
return AbsolutePosition - origin;
}
public QuikVec2 RelativePosition(Controls.Control control)
{
return AbsolutePosition - control.AbsoluteBounds.Min;
}
}
}