DVUI

pointToBodyRelative

Converts a physical point (e.g. a mouse position) into a logical point relative to the top-left of the grid's body. Return the logical point if it is located within the grid body, otherwise return null.

Parameters

#
self:*GridWidget
*GridWidget
point:Point.Physical
Point.Physical

Source

Implementation

#
pub fn pointToBodyRelative(self: *GridWidget, point: Point.Physical) ?Point {
    const scroll_wd = self.scroll.data();
    var result = scroll_wd.rectScale().pointFromPhysical(point);
    if (scroll_wd.rect.contains(result) and result.y >= self.header_height) {
        result.y -= self.header_height;
        return result;
    }
    return null;
}