DVUI

colWidth

Returns the width of the requested column

Parameters

#
self:*GridWidget
*GridWidget
col_num:usize
usize

Source

Implementation

#
pub fn colWidth(self: *GridWidget, col_num: usize) f32 {
    if (col_num >= self.col_widths.len) {
        dvui.log.debug("GridWidget {x} col_num {d} is greater than number of columns {d} using default col_width\n", .{ self.data().id, col_num, self.col_widths.len });
        return default_col_width;
    }
    // If grid is keeping track of the column widths return the start of frame col width
    // as next frame's value may have already been set by colWidthSet() for a previous row.
    // During column resizing, this is used to ensure that all cells get a width of 0,
    // so they can expand to their preferred size, until the next frame.
    if (self.starting_col_widths) |starting_col_widths| {
        return starting_col_widths[col_num];
    } else {
        return self.col_widths[col_num];
    }
}