file picker bad
This commit is contained in:
parent
1dc272097c
commit
a9224ae3fc
|
@ -11,6 +11,7 @@ anyhow = "1.0"
|
||||||
derive-new = "0.6.0"
|
derive-new = "0.6.0"
|
||||||
eframe = "0.27"
|
eframe = "0.27"
|
||||||
egui_dock = "0.12"
|
egui_dock = "0.12"
|
||||||
|
egui_extras = "0.27.2"
|
||||||
rfd = "0.14"
|
rfd = "0.14"
|
||||||
strum = { version = "0.26", features = ["derive"] }
|
strum = { version = "0.26", features = ["derive"] }
|
||||||
|
|
||||||
|
|
|
@ -10,6 +10,7 @@ use self::tabs::TabKind;
|
||||||
#[derive(new)]
|
#[derive(new)]
|
||||||
pub(super) struct App {
|
pub(super) struct App {
|
||||||
tree: DockState<Tab>,
|
tree: DockState<Tab>,
|
||||||
|
tab_viewer: TabViewer,
|
||||||
open_summary: bool,
|
open_summary: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -32,7 +33,7 @@ impl eframe::App for App {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
DockArea::new(&mut self.tree).show_inside(ui, &mut TabViewer::new());
|
DockArea::new(&mut self.tree).show_inside(ui, &mut self.tab_viewer);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -41,6 +42,6 @@ impl Default for App {
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
let tree = DockState::new(chefs_dish());
|
let tree = DockState::new(chefs_dish());
|
||||||
|
|
||||||
Self::new(tree, false)
|
Self::new(tree, TabViewer::default(), false)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,9 @@
|
||||||
|
use std::path::PathBuf;
|
||||||
|
|
||||||
use derive_new::new;
|
use derive_new::new;
|
||||||
use eframe::egui::{Ui, WidgetText};
|
use eframe::egui::{Sense, Ui, WidgetText};
|
||||||
|
use egui_extras::{Column, TableBuilder};
|
||||||
|
use rfd::FileDialog;
|
||||||
use strum::{AsRefStr, EnumIter, IntoEnumIterator};
|
use strum::{AsRefStr, EnumIter, IntoEnumIterator};
|
||||||
|
|
||||||
#[derive(Clone, AsRefStr, PartialEq, EnumIter)]
|
#[derive(Clone, AsRefStr, PartialEq, EnumIter)]
|
||||||
|
@ -38,8 +42,10 @@ pub(super) fn chefs_dish() -> Vec<Tab> {
|
||||||
TabKind::iter().take(5).map(|kind| Tab::new(kind)).collect()
|
TabKind::iter().take(5).map(|kind| Tab::new(kind)).collect()
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(new)]
|
#[derive(Default)]
|
||||||
pub(super) struct TabViewer {}
|
pub(super) struct TabViewer {
|
||||||
|
input_files: Vec<PathBuf>,
|
||||||
|
}
|
||||||
|
|
||||||
impl egui_dock::TabViewer for TabViewer {
|
impl egui_dock::TabViewer for TabViewer {
|
||||||
type Tab = Tab;
|
type Tab = Tab;
|
||||||
|
@ -50,17 +56,44 @@ impl egui_dock::TabViewer for TabViewer {
|
||||||
|
|
||||||
fn ui(&mut self, ui: &mut Ui, tab: &mut Self::Tab) {
|
fn ui(&mut self, ui: &mut Ui, tab: &mut Self::Tab) {
|
||||||
ui.heading(tab.kind.as_ref());
|
ui.heading(tab.kind.as_ref());
|
||||||
// match tab.kind {
|
match tab.kind {
|
||||||
// TabKind::Input => {
|
TabKind::Input => {
|
||||||
// ui.
|
TableBuilder::new(ui)
|
||||||
// },
|
.sense(Sense::click())
|
||||||
// TabKind::Decode => todo!(),
|
.column(Column::remainder())
|
||||||
// TabKind::Process => todo!(),
|
.body(|body| {
|
||||||
// TabKind::Encode => todo!(),
|
body.rows(18.0, self.input_files.len(), |mut row| {
|
||||||
// TabKind::Output => todo!(),
|
let index = row.index();
|
||||||
// TabKind::Summary => todo!(),
|
row.col(|ui| {
|
||||||
// TabKind::Help => todo!(),
|
ui.label(
|
||||||
// }
|
&self
|
||||||
|
.input_files
|
||||||
|
.get(index)
|
||||||
|
.map(|buf| {
|
||||||
|
buf.to_str().unwrap_or("[invalid UTF-8]").to_string()
|
||||||
|
})
|
||||||
|
.unwrap_or("???".to_string()),
|
||||||
|
);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
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
|
||||||
|
}
|
||||||
|
TabKind::Decode => todo!(),
|
||||||
|
TabKind::Process => todo!(),
|
||||||
|
TabKind::Encode => todo!(),
|
||||||
|
TabKind::Output => todo!(),
|
||||||
|
TabKind::Summary => todo!(),
|
||||||
|
TabKind::Help => todo!(),
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn allowed_in_windows(&self, tab: &mut Self::Tab) -> bool {
|
fn allowed_in_windows(&self, tab: &mut Self::Tab) -> bool {
|
||||||
|
|
Loading…
Reference in New Issue