Optimization
This commit is contained in:
parent
d72cfe5359
commit
dc8c5aaa2b
1 changed files with 17 additions and 11 deletions
|
@ -110,7 +110,7 @@ impl<'a> TableBuilder<'a> {
|
||||||
let mut layout = StripLayout::new(ui, CellDirection::Horizontal);
|
let mut layout = StripLayout::new(ui, CellDirection::Horizontal);
|
||||||
header(TableRow {
|
header(TableRow {
|
||||||
layout: &mut layout,
|
layout: &mut layout,
|
||||||
widths: widths.clone(),
|
widths: &widths,
|
||||||
striped: false,
|
striped: false,
|
||||||
height,
|
height,
|
||||||
clicked: false,
|
clicked: false,
|
||||||
|
@ -162,13 +162,17 @@ impl<'a> Table<'a> {
|
||||||
where
|
where
|
||||||
F: for<'b> FnOnce(TableBody<'b>),
|
F: for<'b> FnOnce(TableBody<'b>),
|
||||||
{
|
{
|
||||||
let ui = self.ui;
|
let Table {
|
||||||
let widths = self.widths;
|
ui,
|
||||||
let striped = self.striped;
|
widths,
|
||||||
|
scroll,
|
||||||
|
striped,
|
||||||
|
} = self;
|
||||||
|
|
||||||
let start_y = ui.available_rect_before_wrap().top();
|
let start_y = ui.available_rect_before_wrap().top();
|
||||||
let end_y = ui.available_rect_before_wrap().bottom();
|
let end_y = ui.available_rect_before_wrap().bottom();
|
||||||
|
|
||||||
egui::ScrollArea::new([false, self.scroll]).show(ui, move |ui| {
|
egui::ScrollArea::new([false, scroll]).show(ui, move |ui| {
|
||||||
let layout = StripLayout::new(ui, CellDirection::Horizontal);
|
let layout = StripLayout::new(ui, CellDirection::Horizontal);
|
||||||
|
|
||||||
body(TableBody {
|
body(TableBody {
|
||||||
|
@ -208,7 +212,7 @@ impl<'a> TableBody<'a> {
|
||||||
let skip_height = start as f32 * height;
|
let skip_height = start as f32 * height;
|
||||||
TableRow {
|
TableRow {
|
||||||
layout: &mut self.layout,
|
layout: &mut self.layout,
|
||||||
widths: self.widths.clone(),
|
widths: &self.widths,
|
||||||
striped: false,
|
striped: false,
|
||||||
height: skip_height,
|
height: skip_height,
|
||||||
clicked: false,
|
clicked: false,
|
||||||
|
@ -225,7 +229,7 @@ impl<'a> TableBody<'a> {
|
||||||
idx,
|
idx,
|
||||||
TableRow {
|
TableRow {
|
||||||
layout: &mut self.layout,
|
layout: &mut self.layout,
|
||||||
widths: self.widths.clone(),
|
widths: &self.widths,
|
||||||
striped: self.striped && idx % 2 == 0,
|
striped: self.striped && idx % 2 == 0,
|
||||||
height,
|
height,
|
||||||
clicked: false,
|
clicked: false,
|
||||||
|
@ -238,7 +242,7 @@ impl<'a> TableBody<'a> {
|
||||||
|
|
||||||
TableRow {
|
TableRow {
|
||||||
layout: &mut self.layout,
|
layout: &mut self.layout,
|
||||||
widths: self.widths.clone(),
|
widths: &self.widths,
|
||||||
striped: false,
|
striped: false,
|
||||||
height: skip_height,
|
height: skip_height,
|
||||||
clicked: false,
|
clicked: false,
|
||||||
|
@ -251,7 +255,7 @@ impl<'a> TableBody<'a> {
|
||||||
pub fn row(&mut self, height: f32, row: impl FnOnce(TableRow<'a, '_>)) {
|
pub fn row(&mut self, height: f32, row: impl FnOnce(TableRow<'a, '_>)) {
|
||||||
row(TableRow {
|
row(TableRow {
|
||||||
layout: &mut self.layout,
|
layout: &mut self.layout,
|
||||||
widths: self.widths.clone(),
|
widths: &self.widths,
|
||||||
striped: self.striped && self.row_nr % 2 == 0,
|
striped: self.striped && self.row_nr % 2 == 0,
|
||||||
height,
|
height,
|
||||||
clicked: false,
|
clicked: false,
|
||||||
|
@ -271,7 +275,7 @@ impl<'a> Drop for TableBody<'a> {
|
||||||
/// Is created by [`TableRow`] for each created [`TableBody::row`] or each visible row in rows created by calling [`TableBody::rows`].
|
/// Is created by [`TableRow`] for each created [`TableBody::row`] or each visible row in rows created by calling [`TableBody::rows`].
|
||||||
pub struct TableRow<'a, 'b> {
|
pub struct TableRow<'a, 'b> {
|
||||||
layout: &'b mut StripLayout<'a>,
|
layout: &'b mut StripLayout<'a>,
|
||||||
widths: Vec<f32>,
|
widths: &'b [f32],
|
||||||
striped: bool,
|
striped: bool,
|
||||||
height: f32,
|
height: f32,
|
||||||
clicked: bool,
|
clicked: bool,
|
||||||
|
@ -299,7 +303,9 @@ impl<'a, 'b> TableRow<'a, 'b> {
|
||||||
"Tried using more table columns then available."
|
"Tried using more table columns then available."
|
||||||
);
|
);
|
||||||
|
|
||||||
let width = CellSize::Absolute(self.widths.remove(0));
|
let width = self.widths[0];
|
||||||
|
self.widths = &self.widths[1..];
|
||||||
|
let width = CellSize::Absolute(width);
|
||||||
let height = CellSize::Absolute(self.height);
|
let height = CellSize::Absolute(self.height);
|
||||||
|
|
||||||
let response;
|
let response;
|
||||||
|
|
Loading…
Reference in a new issue