Skip to content

Commit

Permalink
add table::body return scroll
Browse files Browse the repository at this point in the history
  • Loading branch information
frederik-uni authored Jul 15, 2024
1 parent 0d89e31 commit a63ccda
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions crates/egui_extras/src/table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
//! Takes all available height, so if you want something below the table, put it in a strip.
use egui::{
scroll_area::ScrollBarVisibility, Align, NumExt as _, Rangef, Rect, Response, ScrollArea, Ui,
Vec2, Vec2b,
scroll_area::{ScrollAreaOutput, ScrollBarVisibility},
Align, NumExt as _, Rangef, Rect, Response, ScrollArea, Ui, Vec2, Vec2b,
};

use crate::{
Expand Down Expand Up @@ -474,7 +474,7 @@ impl<'a> TableBuilder<'a> {
}

/// Create table body without a header row
pub fn body<F>(self, add_body_contents: F)
pub fn body<F>(self, add_body_contents: F) -> ScrollAreaOutput<()>
where
F: for<'b> FnOnce(TableBody<'b>),
{
Expand Down Expand Up @@ -515,7 +515,7 @@ impl<'a> TableBuilder<'a> {
scroll_options,
sense,
}
.body(add_body_contents);
.body(add_body_contents)
}
}

Expand Down Expand Up @@ -641,7 +641,7 @@ impl<'a> Table<'a> {
}

/// Create table body after adding a header row
pub fn body<F>(self, add_body_contents: F)
pub fn body<F>(self, add_body_contents: F) -> ScrollAreaOutput<()>
where
F: for<'b> FnOnce(TableBody<'b>),
{
Expand Down Expand Up @@ -692,7 +692,7 @@ impl<'a> Table<'a> {
let widths_ref = &state.column_widths;
let max_used_widths_ref = &mut max_used_widths;

scroll_area.show(ui, move |ui| {
let scroll_area_out = scroll_area.show(ui, move |ui| {
let mut scroll_to_y_range = None;

let clip_rect = ui.clip_rect();
Expand Down Expand Up @@ -843,6 +843,7 @@ impl<'a> Table<'a> {
state.max_used_widths = max_used_widths;

state.store(ui, state_id);
scroll_area_out
}
}

Expand Down

0 comments on commit a63ccda

Please sign in to comment.