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 derive_new::new;
|
||||
use eframe::egui::{Sense, Ui, WidgetText};
|
||||
use egui_extras::{Column, TableBuilder};
|
||||
use eframe::egui::{ScrollArea, Sense, TextStyle, Ui, WidgetText};
|
||||
use egui_extras::{Column, Size, StripBuilder, TableBuilder};
|
||||
use rfd::FileDialog;
|
||||
use strum::{AsRefStr, EnumIter, IntoEnumIterator};
|
||||
|
||||
|
@ -58,7 +58,15 @@ impl egui_dock::TabViewer for TabViewer {
|
|||
ui.heading(tab.kind.as_ref());
|
||||
match tab.kind {
|
||||
TabKind::Input => {
|
||||
let button_size = TextStyle::Button.resolve(ui.style()).size;
|
||||
StripBuilder::new(ui)
|
||||
.size(Size::remainder().at_least(20.0)) // for the table
|
||||
.size(Size::remainder().at_most(button_size * 4.0)) // for the add and clear buttons
|
||||
.vertical(|mut strip| {
|
||||
strip.cell(|ui| {
|
||||
ScrollArea::horizontal().show(ui, |ui| {
|
||||
TableBuilder::new(ui)
|
||||
.striped(true)
|
||||
.sense(Sense::click())
|
||||
.column(Column::remainder())
|
||||
.body(|body| {
|
||||
|
@ -70,13 +78,19 @@ impl egui_dock::TabViewer for TabViewer {
|
|||
.input_files
|
||||
.get(index)
|
||||
.map(|buf| {
|
||||
buf.to_str().unwrap_or("[invalid UTF-8]").to_string()
|
||||
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();
|
||||
}
|
||||
|
@ -85,6 +99,9 @@ impl egui_dock::TabViewer for TabViewer {
|
|||
self.input_files.append(&mut paths);
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
// https://github.com/emilk/egui/blob/master/examples/file_dialog/src/main.rs
|
||||
}
|
||||
TabKind::Decode => todo!(),
|
||||
|
|
Loading…
Reference in a new issue