mirror of
https://github.com/emilk/egui.git
synced 2026-09-02 14:50:03 -04:00
egui_extras::Table improvements (#2369)
* Use simple `ui.interact` for the resize line * Introduce TableReizeState * Simplify some code * Add striped options to table demo * Auto-size table columns by double-clicking the resize line * Table: add option to auto-size the columns * Table: don't let column width gets too small, unless clipping is on * egui_extras: always use serde Otherwise using `get_persisted` etc is impossible, and working around that tedious. * Avoid clipping last column in a resizable table * Some better naming * Table: Use new `Column` for setting column sizes and properties Also make `clip` a per-column property * All Table:s store state for auto-sizing purposes * Customize each column wether or not it is resizable * fix some auto-sizing bugs * Fix shrinkage of adaptive column content * Rename `scroll` to `vscroll` for clarity * Add Table::scroll_to_row * scroll_to_row takes alignment * Fix bug in table sizing * Strip: turn clipping OFF by default, because it is dangerous and sucks * Add TableBody::mac_rect helper * Table: add options to control the scroll area height. * Docstring fixes * Cleanup
This commit is contained in:
@@ -56,11 +56,11 @@ impl<'a> StripBuilder<'a> {
|
||||
ui,
|
||||
sizing: Default::default(),
|
||||
cell_layout,
|
||||
clip: true,
|
||||
clip: false,
|
||||
}
|
||||
}
|
||||
|
||||
/// Should we clip the contents of each cell? Default: `true`.
|
||||
/// Should we clip the contents of each cell? Default: `false`.
|
||||
pub fn clip(mut self, clip: bool) -> Self {
|
||||
self.clip = clip;
|
||||
self
|
||||
@@ -98,15 +98,11 @@ impl<'a> StripBuilder<'a> {
|
||||
self.ui.available_rect_before_wrap().width(),
|
||||
self.ui.spacing().item_spacing.x,
|
||||
);
|
||||
let mut layout = StripLayout::new(
|
||||
self.ui,
|
||||
CellDirection::Horizontal,
|
||||
self.clip,
|
||||
self.cell_layout,
|
||||
);
|
||||
let mut layout = StripLayout::new(self.ui, CellDirection::Horizontal, self.cell_layout);
|
||||
strip(Strip {
|
||||
layout: &mut layout,
|
||||
direction: CellDirection::Horizontal,
|
||||
clip: self.clip,
|
||||
sizes: widths,
|
||||
size_index: 0,
|
||||
});
|
||||
@@ -125,15 +121,11 @@ impl<'a> StripBuilder<'a> {
|
||||
self.ui.available_rect_before_wrap().height(),
|
||||
self.ui.spacing().item_spacing.y,
|
||||
);
|
||||
let mut layout = StripLayout::new(
|
||||
self.ui,
|
||||
CellDirection::Vertical,
|
||||
self.clip,
|
||||
self.cell_layout,
|
||||
);
|
||||
let mut layout = StripLayout::new(self.ui, CellDirection::Vertical, self.cell_layout);
|
||||
strip(Strip {
|
||||
layout: &mut layout,
|
||||
direction: CellDirection::Vertical,
|
||||
clip: self.clip,
|
||||
sizes: heights,
|
||||
size_index: 0,
|
||||
});
|
||||
@@ -146,6 +138,7 @@ impl<'a> StripBuilder<'a> {
|
||||
pub struct Strip<'a, 'b> {
|
||||
layout: &'b mut StripLayout<'a>,
|
||||
direction: CellDirection,
|
||||
clip: bool,
|
||||
sizes: Vec<f32>,
|
||||
size_index: usize,
|
||||
}
|
||||
@@ -172,7 +165,9 @@ impl<'a, 'b> Strip<'a, 'b> {
|
||||
/// Add cell contents.
|
||||
pub fn cell(&mut self, add_contents: impl FnOnce(&mut Ui)) {
|
||||
let (width, height) = self.next_cell_size();
|
||||
self.layout.add(width, height, add_contents);
|
||||
let striped = false;
|
||||
self.layout
|
||||
.add(self.clip, striped, width, height, add_contents);
|
||||
}
|
||||
|
||||
/// Add an empty cell.
|
||||
@@ -183,7 +178,7 @@ impl<'a, 'b> Strip<'a, 'b> {
|
||||
|
||||
/// Add a strip as cell.
|
||||
pub fn strip(&mut self, strip_builder: impl FnOnce(StripBuilder<'_>)) {
|
||||
let clip = self.layout.clip;
|
||||
let clip = self.clip;
|
||||
self.cell(|ui| {
|
||||
strip_builder(StripBuilder::new(ui).clip(clip));
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user