Skip to content

Commit 7e26691

Browse files
Use column.wrap() instead of hand-made grid for Column View
+ Reduced width of Column View items slightly
1 parent fbde666 commit 7e26691

1 file changed

Lines changed: 9 additions & 24 deletions

File tree

src/tab.rs

Lines changed: 9 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -6701,7 +6701,7 @@ impl Tab {
67016701
} = self.config;
67026702
let grid_spacing = space_xxxs;
67036703
let icon_size = icon_sizes.column().max(24); // Prevent icons getting too small
6704-
let item_width = (160 + grid_spacing + icon_size + grid_spacing) as usize;
6704+
let item_width = (140 + grid_spacing + icon_size + grid_spacing) as usize;
67056705
let item_height = (grid_spacing + icon_size + grid_spacing) as usize;
67066706

67076707
let (width, height) = match self.size_opt.get() {
@@ -6732,10 +6732,6 @@ impl Tab {
67326732
Rectangle::new(point, size)
67336733
};
67346734

6735-
let mut grid = widget::grid()
6736-
.column_spacing(grid_spacing)
6737-
.row_spacing(grid_spacing)
6738-
.padding(grid_spacing.into());
67396735
let mut dnd_items: Vec<(usize, (usize, usize), &Item)> = Vec::new();
67406736
let mut drag_w_i = usize::MAX;
67416737
let mut drag_n_i = usize::MAX;
@@ -6758,14 +6754,12 @@ impl Tab {
67586754
let rows_m1 = height_m1 / (item_height + grid_spacing as usize);
67596755
rows_m1.max(1)
67606756
};
6761-
let cols = (items_len / rows).max(1) as usize;
6762-
let mut grid_elements = Vec::with_capacity(rows);
6763-
67646757

67656758
// TODO: Load grid content asynchronously, starting with the current view
67666759

67676760
let mut count = 0;
67686761
let mut hidden = 0;
6762+
let mut item_elements = Vec::<Element<Message>>::new();
67696763

67706764
for &(i, item) in &items {
67716765
// Ignore hidden items if not showing hidden
@@ -6779,11 +6773,6 @@ impl Tab {
67796773
let col = (count / rows) as usize;
67806774
let row = (count % rows) as usize;
67816775

6782-
// Build the grid rows when cycling through the first column
6783-
if col == 0 {
6784-
grid_elements.push(Vec::with_capacity(cols))
6785-
}
6786-
67876776
// Skip writing contents for items outside the visible viewport
67886777
item.pos_opt.set(Some((row, col)));
67896778
let item_rect = Rectangle::new(
@@ -6801,7 +6790,7 @@ impl Tab {
68016790
.height(Length::Fixed(item_height as f32))
68026791
.width(Length::Fixed(item_width as f32))
68036792
.into();
6804-
grid_elements[row].push(empty_cell);
6793+
item_elements.push(empty_cell);
68056794
count += 1;
68066795
continue;
68076796
}
@@ -6955,7 +6944,7 @@ impl Tab {
69556944
} else {
69566945
cell.into()
69576946
};
6958-
grid_elements[row].push(cell);
6947+
item_elements.push(cell);
69596948

69606949
if item.selected {
69616950
dnd_items.push((i, (row, col), item));
@@ -6974,15 +6963,11 @@ impl Tab {
69746963
return (None, self.empty_view(hidden > 0), None);
69756964
}
69766965

6977-
// Write out the visible items to the content grid
6978-
for row_elements in grid_elements {
6979-
for element in row_elements {
6980-
grid = grid.push(element);
6981-
}
6982-
grid = grid.insert_row();
6983-
}
6984-
6985-
column = column.push(grid);
6966+
column = column.push(
6967+
widget::column::with_children(item_elements)
6968+
.wrap()
6969+
.horizontal_spacing(space_xxxs)
6970+
);
69866971
}
69876972

69886973
let drag_list = (!dnd_items.is_empty()).then(|| {

0 commit comments

Comments
 (0)