Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

egui_extras::Table doesn't behave properly when inside of a ScrollArea #3670

Closed
abey79 opened this issue Dec 1, 2023 · 1 comment · Fixed by #3690
Closed

egui_extras::Table doesn't behave properly when inside of a ScrollArea #3670

abey79 opened this issue Dec 1, 2023 · 1 comment · Fixed by #3690
Labels
bug Something is broken egui_extras rerun Desired for Rerun.io

Comments

@abey79
Copy link
Collaborator

abey79 commented Dec 1, 2023

Bug

egui_table_bug.mp4

Repro

#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")] // hide console window on Windows in release

use eframe::egui;
use eframe::egui::ScrollArea;

fn main() -> Result<(), eframe::Error> {
    env_logger::init(); // Log to stderr (if you run with `RUST_LOG=debug`).
    let options = eframe::NativeOptions {
        viewport: egui::ViewportBuilder::default().with_inner_size([320.0, 240.0]),
        ..Default::default()
    };
    eframe::run_native(
        "My egui App",
        options,
        Box::new(|cc| {
            // This gives us image support:
            egui_extras::install_image_loaders(&cc.egui_ctx);

            Box::<MyApp>::default()
        }),
    )
}

#[derive(Default)]
struct MyApp;

impl eframe::App for MyApp {
    fn update(&mut self, ctx: &egui::Context, _frame: &mut eframe::Frame) {
        egui::CentralPanel::default().show(ctx, |ui| {
            ScrollArea::both().show(ui, |ui| {
                egui_extras::TableBuilder::new(ui)
                    .auto_shrink([false, true])
                    .vscroll(false)
                    .columns(egui_extras::Column::exact(50.0), 2)
                    .header(18.0, |mut header| {
                        header.col(|ui| {
                            ui.label("Col1");
                        });
                        header.col(|ui| {
                            ui.label("col2");
                        });
                    })
                    .body(|body| {
                        body.rows(18.0, 100, |idx, mut row| {
                            row.col(|ui| {
                                ui.label(format!("R{}C1", idx));
                            });
                            row.col(|ui| {
                                ui.label(format!("R{}C2", idx));
                            });
                        });
                    });
            });
        });
    }
}
@abey79 abey79 added the bug Something is broken label Dec 1, 2023
@emilk emilk added the rerun Desired for Rerun.io label Dec 1, 2023
@emilk emilk added this to the 0.25.0 milestone Dec 1, 2023
@Imberflur
Copy link

I think I may have a similar bug. My table is inside a scroll arena (at the bottom of that area) and when using body.rows() only a single row is displayed. However, when adding the rows individually with body.row() everything seems to work well. IIUC rows is more performant because it can avoid work for rows that aren't visible. Maybe this issue is related to that logic?

emilk pushed a commit that referenced this issue Dec 8, 2023
`egui_extras::Table` now uses the clip rectangle to decide which rows to
draw when using `TableBody::rows()`.

- Closes #3682
- Closes #3670
emilk pushed a commit that referenced this issue Dec 8, 2023
`egui_extras::Table` now uses the clip rectangle to decide which rows to
draw when using `TableBody::rows()`.

- Closes #3682
- Closes #3670
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something is broken egui_extras rerun Desired for Rerun.io
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants