Commit graph

12 commits

Author SHA1 Message Date
Wayne Warren
51a98d586b egui_extras: fix row indexing 2022-04-03 20:03:11 -06:00
Wayne Warren
7706a91974 egui_extras: add heterogeneous_rows example 2022-04-03 12:11:12 -06:00
Wayne Warren
2f22f41185 egui_extras: cleanup TableBody.heterogeneous_rows a little
* use f64 when accumulating virtual height above and below visible
  region
* break the big loop iterating over heights into three loops, one for
  each non-visible region, and one for the visible region
* retain each row's stripe color using an enumeration over the given
  heights iterator
* use a VIRTUAL_EXTENSION constant to extend the "visible" region of the
  table above and below the actual visible region to provide the
  illusion of rows sliding into and out of sight
2022-04-03 12:00:27 -06:00
Wayne Warren
c2df572dd1 egui_extras: add comments to new TableBody methods 2022-04-03 11:25:38 -06:00
Wayne Warren
44bd8c1cc4 egui_extras: follow closure-based conventions for TableBody.heterogeneous_rows 2022-04-03 11:18:18 -06:00
Wayne Warren
ab4930fde7 egui_extras: make number of rows in table demo configurable 2022-04-03 10:59:10 -06:00
Wayne Warren
e81a92d32d egui_extras: enable virtual scroll for heterogenous rows
Introduce `TableBody.heterogenous_rows` and `TableRowBuilder`, the former of which takes as an argument the latter. `TableRowBuilder` provides two methods that enable virtual scrolling for rows with non-uniform heights. Those methods are:

* `TableRowBuilder.row_heights` which returns an iterator over `f32` to allow incremental virtual scroll buffer calculation.
* `TableRowBuilder.populate_row` which `TableBody.heterogenous_rows` uses to allow `TableRowBuilder` implementations to, you guessed it, populate rows that are visible.

One thought that occurs to me while writing this description is that
`TableBody.heterogenous_rows` could look more like the following:

```
    pub fn heterogenous_rows(
        mut self,
        row_heights: impl Iterator<Item = f32> + '_,
        mut row: impl FnMut(usize, TableRow<'_, '_>),
    )
```

This could potentially be easier to use, considering all the trouble I had coming up with and implementing the trait. Happy to make this change if the maintainers prefer.
2022-04-03 00:18:17 -06:00
Emil Ernerfeldt
5dff1e42c6
More table improvements (#1440)
* Clip by default
* Fix some spacing bugs
* datepicker: look nicer in light mode
* datepicker: show month names
* Table: don't allow resize of last column if it is Size::Remainder
2022-04-01 15:27:42 +02:00
Emil Ernerfeldt
c029f25c13 Table: don't allow resize of last column if it is Size::Remainder 2022-04-01 14:44:25 +02:00
Emil Ernerfeldt
51cc9c9a9a Table: fix bug with item spacing 2022-04-01 14:43:43 +02:00
Emil Ernerfeldt
21c32a18d8
Table resize (#1438)
* Let 1D strips fill up parent width/height
* Add Strip + Table + DatePicker to egui_extras changelog
* Expose some dragging- and pointer related context/memory methods
* Make tables resizable
2022-04-01 12:01:00 +02:00
René Rössler
1d32670cf3
Dynamic sized strips, tables, and date picker (#963) 2022-03-31 21:13:25 +02:00