1
0
Fork 0
zenolith/src/treevents/MouseMove.zig
2023-11-26 14:01:22 +01:00

23 lines
687 B
Zig

//! This treevent is fired when the mouse cursor moves. It contains the new mouse cursor position
//! as well as the relative movement of the cursor.
const Position = @import("../layout/Position.zig");
const Rectangle = @import("../layout/Rectangle.zig");
const Widget = @import("../widget.zig").Widget;
pos: Position,
dx: isize,
dy: isize,
const MouseMove = @This();
pub fn dispatch(self: MouseMove, widget: *Widget) !void {
for (widget.children()) |child| {
try child.treevent(self);
}
}
pub fn isOnWidget(self: MouseMove, widget: Widget) bool {
const bb = Rectangle{ .pos = widget.data.position, .size = widget.data.size };
return bb.contains(self.pos);
}