emilk / egui

egui: an easy-to-use immediate mode GUI in Rust that runs on both web and native
https://www.egui.rs/
Apache License 2.0
22.34k stars 1.61k forks source link

There may be some problems with the layout of the table #3680

Open tmtbe opened 11 months ago

tmtbe commented 11 months ago

Describe the bug

let table = TableBuilder::new(ui)
            .resizable(true)
            .cell_layout(Layout::centered_and_justified(Direction::TopDown))
            .column(Column::auto())
            .column(Column::exact(20.0))
            .column(Column::initial(200.0).range(40.0..=300.0))
            .column(Column::initial(200.0).range(40.0..=300.0))
            .column(Column::remainder())
            .min_scrolled_height(0.0);
        table.header(20.0, |mut header| {
                header.col(|ui| {
                    ui.strong("");
                });
                header.col(|ui| {
                    ui.strong("");
                });
                header.col(|ui| {
                    ui.strong("KEY");
                });
                header.col(|ui| {
                    ui.strong("VALUE");
                });
                header.col(|ui| {
                    ui.strong("DESCRIPTION");
                });
            }).body(|mut body|{
            for param in data.rest.request.params.iter_mut() {
                body.row(18.0, |mut row| {
                    row.col(|ui| {
                        ui.checkbox(&mut param.enable,"");
                    });
                    row.col(|ui| {
                        if ui.button("x").clicked(){

                        }
                    });
                    row.col(|ui| {
                        ui.text_edit_singleline(&mut param.key);
                    });
                    row.col(|ui| {
                        ui.text_edit_singleline(&mut param.value);
                    });
                    row.col(|ui| {
                        ui.text_edit_singleline(&mut param.desc);
                    });
                });
            }
            body.row(18.0, |mut row| {
                row.col(|ui| {
                    ui.checkbox(&mut self.new_param.enable,"");
                });
                row.col(|ui| {
                    if ui.button("x").clicked(){

                    }
                });
                row.col(|ui| {
                    ui.text_edit_singleline(&mut self.new_param.key);
                });
                row.col(|ui| {
                    ui.text_edit_singleline(&mut self.new_param.value);
                });
                row.col(|ui| {
                    ui.text_edit_singleline(&mut self.new_param.desc);
                });

            });
        });

Table using centered_and_justified layout will cause width and window size mismatch.

Screenshots

image

Desktop (please complete the following information):

tmtbe commented 11 months ago

https://github.com/tmtbe/rust-ui.git ,You can view the code here, the specific questions are in ParamsPanel