Fix table width size bug
This commit is contained in:
parent
73444a7116
commit
04135aaa9c
1 changed files with 18 additions and 14 deletions
|
@ -93,18 +93,22 @@ impl<'a> TableBuilder<'a> {
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn available_width(&self) -> f32 {
|
||||||
|
self.ui.available_rect_before_wrap().width()
|
||||||
|
- 2.0 * self.ui.spacing().item_spacing.x
|
||||||
|
- if self.scroll {
|
||||||
|
self.ui.spacing().scroll_bar_width
|
||||||
|
} else {
|
||||||
|
0.0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// Create a header row which always stays visible and at the top
|
/// Create a header row which always stays visible and at the top
|
||||||
pub fn header(self, height: f32, header: impl FnOnce(TableRow<'_, '_>)) -> Table<'a> {
|
pub fn header(self, height: f32, header: impl FnOnce(TableRow<'_, '_>)) -> Table<'a> {
|
||||||
let widths = self.sizing.into_lengths(
|
let available_width = self.available_width();
|
||||||
self.ui.available_rect_before_wrap().width()
|
let widths = self
|
||||||
- self.ui.spacing().item_spacing.x
|
.sizing
|
||||||
- if self.scroll {
|
.into_lengths(available_width, self.ui.spacing().item_spacing.x);
|
||||||
self.ui.spacing().scroll_bar_width
|
|
||||||
} else {
|
|
||||||
0.0
|
|
||||||
},
|
|
||||||
self.ui.spacing().item_spacing.x,
|
|
||||||
);
|
|
||||||
let ui = self.ui;
|
let ui = self.ui;
|
||||||
{
|
{
|
||||||
let mut layout = StripLayout::new(ui, CellDirection::Horizontal);
|
let mut layout = StripLayout::new(ui, CellDirection::Horizontal);
|
||||||
|
@ -131,10 +135,10 @@ impl<'a> TableBuilder<'a> {
|
||||||
where
|
where
|
||||||
F: for<'b> FnOnce(TableBody<'b>),
|
F: for<'b> FnOnce(TableBody<'b>),
|
||||||
{
|
{
|
||||||
let widths = self.sizing.into_lengths(
|
let available_width = self.available_width();
|
||||||
self.ui.available_rect_before_wrap().width(),
|
let widths = self
|
||||||
self.ui.spacing().item_spacing.x,
|
.sizing
|
||||||
);
|
.into_lengths(available_width, self.ui.spacing().item_spacing.x);
|
||||||
|
|
||||||
Table {
|
Table {
|
||||||
ui: self.ui,
|
ui: self.ui,
|
||||||
|
|
Loading…
Reference in a new issue