something something strip
This commit is contained in:
parent
a9224ae3fc
commit
13b6effb91
1 changed files with 43 additions and 26 deletions
|
@ -1,8 +1,8 @@
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
|
|
||||||
use derive_new::new;
|
use derive_new::new;
|
||||||
use eframe::egui::{Sense, Ui, WidgetText};
|
use eframe::egui::{ScrollArea, Sense, TextStyle, Ui, WidgetText};
|
||||||
use egui_extras::{Column, TableBuilder};
|
use egui_extras::{Column, Size, StripBuilder, TableBuilder};
|
||||||
use rfd::FileDialog;
|
use rfd::FileDialog;
|
||||||
use strum::{AsRefStr, EnumIter, IntoEnumIterator};
|
use strum::{AsRefStr, EnumIter, IntoEnumIterator};
|
||||||
|
|
||||||
|
@ -58,33 +58,50 @@ impl egui_dock::TabViewer for TabViewer {
|
||||||
ui.heading(tab.kind.as_ref());
|
ui.heading(tab.kind.as_ref());
|
||||||
match tab.kind {
|
match tab.kind {
|
||||||
TabKind::Input => {
|
TabKind::Input => {
|
||||||
TableBuilder::new(ui)
|
let button_size = TextStyle::Button.resolve(ui.style()).size;
|
||||||
.sense(Sense::click())
|
StripBuilder::new(ui)
|
||||||
.column(Column::remainder())
|
.size(Size::remainder().at_least(20.0)) // for the table
|
||||||
.body(|body| {
|
.size(Size::remainder().at_most(button_size * 4.0)) // for the add and clear buttons
|
||||||
body.rows(18.0, self.input_files.len(), |mut row| {
|
.vertical(|mut strip| {
|
||||||
let index = row.index();
|
strip.cell(|ui| {
|
||||||
row.col(|ui| {
|
ScrollArea::horizontal().show(ui, |ui| {
|
||||||
ui.label(
|
TableBuilder::new(ui)
|
||||||
&self
|
.striped(true)
|
||||||
.input_files
|
.sense(Sense::click())
|
||||||
.get(index)
|
.column(Column::remainder())
|
||||||
.map(|buf| {
|
.body(|body| {
|
||||||
buf.to_str().unwrap_or("[invalid UTF-8]").to_string()
|
body.rows(18.0, self.input_files.len(), |mut row| {
|
||||||
})
|
let index = row.index();
|
||||||
.unwrap_or("???".to_string()),
|
row.col(|ui| {
|
||||||
);
|
ui.label(
|
||||||
|
&self
|
||||||
|
.input_files
|
||||||
|
.get(index)
|
||||||
|
.map(|buf| {
|
||||||
|
buf.to_str()
|
||||||
|
.unwrap_or("[invalid UTF-8]")
|
||||||
|
.to_string()
|
||||||
|
})
|
||||||
|
.unwrap_or("???".to_string()),
|
||||||
|
);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
})
|
||||||
|
});
|
||||||
|
});
|
||||||
|
strip.cell(|ui| {
|
||||||
|
ui.vertical_centered_justified(|ui| {
|
||||||
|
if ui.button("Clear").clicked() {
|
||||||
|
self.input_files.clear();
|
||||||
|
}
|
||||||
|
if ui.button("Add").clicked() {
|
||||||
|
if let Some(mut paths) = FileDialog::new().pick_files() {
|
||||||
|
self.input_files.append(&mut paths);
|
||||||
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
if ui.button("Clear").clicked() {
|
|
||||||
self.input_files.clear();
|
|
||||||
}
|
|
||||||
if ui.button("Add").clicked() {
|
|
||||||
if let Some(mut paths) = FileDialog::new().pick_files() {
|
|
||||||
self.input_files.append(&mut paths);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// https://github.com/emilk/egui/blob/master/examples/file_dialog/src/main.rs
|
// https://github.com/emilk/egui/blob/master/examples/file_dialog/src/main.rs
|
||||||
}
|
}
|
||||||
TabKind::Decode => todo!(),
|
TabKind::Decode => todo!(),
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue