ref(event): split Size into two Points (one for the size and one for the anchor / origin)
All checks were successful
Zig Project Action / Lint, Spell-check and test zig project (push) Successful in 39s
All checks were successful
Zig Project Action / Lint, Spell-check and test zig project (push) Successful in 39s
This commit is contained in:
@@ -1,11 +1,11 @@
|
||||
//! Input module for `zterm`. Contains structs to represent key events and mouse events.
|
||||
const std = @import("std");
|
||||
|
||||
const Size = @import("size.zig").Size;
|
||||
const Point = @import("point.zig").Point;
|
||||
|
||||
pub const Mouse = packed struct {
|
||||
col: u16,
|
||||
row: u16,
|
||||
x: u16,
|
||||
y: u16,
|
||||
button: Button,
|
||||
kind: Kind,
|
||||
|
||||
@@ -35,9 +35,9 @@ pub const Mouse = packed struct {
|
||||
return std.meta.eql(this, other);
|
||||
}
|
||||
|
||||
pub fn in(this: @This(), size: Size) bool {
|
||||
return this.col >= size.anchor.col and this.col <= size.cols + size.anchor.col and
|
||||
this.row >= size.anchor.row and this.row <= size.rows + size.anchor.row;
|
||||
pub fn in(this: @This(), origin: Point, size: Point) bool {
|
||||
return this.x >= origin.x and this.x <= size.x + origin.x and
|
||||
this.y >= origin.y and this.y <= size.y + origin.y;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user