deinit
Parameters
- self:*GridWidget
- *GridWidget
Source
Implementation
pub fn deinit(self: *GridWidget) void {
defer if (dvui.widgetIsAllocated(self)) dvui.widgetFree(self);
defer self.* = undefined;
if (self.data().accesskit_node()) |ak_node| {
AccessKit.nodeSetRowCount(ak_node, self.max_row);
AccessKit.nodeSetColumnCount(ak_node, self.col_widths.len);
}
// resizing if row heights changed or a resize was requested via init options.
if (self.resizing) {
dvui.refresh(null, @src(), self.data().id);
}
self.resizing =
self.init_opts.resize_rows or
self.init_opts.resize_cols or
!std.math.approxEqAbs(f32, self.row_height, self.last_row_height, 0.01) or
!std.math.approxEqAbs(f32, self.header_height, self.last_header_height, 0.01);
if (self.hscroll) |*hscroll| {
self.header_group.deinit();
hscroll.deinit();
}
// Create a spacer widget to report body virtual size to scroll area
const max_row_f: f32 = @floatFromInt(self.max_row);
const this_height: f32 = if (self.init_opts.row_height_variable) self.next_row_y else (max_row_f + 1) * self.row_height;
const this_size: Size = .{ .h = this_height, .w = self.totalWidth() };
_ = dvui.spacer(@src(), .{ .min_size_content = this_size, .background = false });
if (self.bscroll) |*bscroll| {
self.body_group.deinit();
bscroll.deinit();
}
self.scroll.deinit();
dvui.dataSet(null, self.data().id, "_header_height", self.header_height);
dvui.dataSet(null, self.data().id, "_resizing", self.resizing);
dvui.dataSet(null, self.data().id, "_row_height", self.row_height);
dvui.dataSet(null, self.data().id, "_sort_col", self.sort_col_number);
dvui.dataSet(null, self.data().id, "_sort_direction", self.sort_direction);
dvui.dataSet(null, self.data().id, "_hsi", self.hsi);
if (self.bsi == &self.default_scroll_info) {
dvui.dataSet(null, self.data().id, "_default_si", self.default_scroll_info);
}
self.vbox.deinit();
}