better tree view scroll

This commit is contained in:
Penwing 2024-01-31 15:18:02 +01:00
parent 06b0d75983
commit e45ed82a29
2 changed files with 8 additions and 4 deletions

View file

@ -63,6 +63,8 @@ impl Calcifer {
ui.label("Bookshelf "); ui.label("Bookshelf ");
}); });
ui.separator(); ui.separator();
ui.label(format!("{} files displayed", self.n_file_displayed));
ui.separator();
egui::ScrollArea::vertical().show(ui, |ui| { egui::ScrollArea::vertical().show(ui, |ui| {
if let Some(file_tree) = self.file_tree.clone() { if let Some(file_tree) = self.file_tree.clone() {
let update_requested = self.list_files(ui, &file_tree, &mut n_files); let update_requested = self.list_files(ui, &file_tree, &mut n_files);
@ -75,10 +77,10 @@ impl Calcifer {
} else { } else {
ui.label("No book on the Bookshelf"); ui.label("No book on the Bookshelf");
} }
});
ui.separator(); ui.separator();
ui.label(format!("{} files displayed", n_files));
}); });
});
self.n_file_displayed = n_files.clone();
} }
pub fn draw_bottom_tray(&mut self, ctx: &egui::Context) { pub fn draw_bottom_tray(&mut self, ctx: &egui::Context) {

View file

@ -18,10 +18,10 @@ const TITLE: &str = " debug";
#[cfg(not(debug_assertions))] #[cfg(not(debug_assertions))]
const TITLE: &str = ""; const TITLE: &str = "";
const ALLOWED_FILE_EXTENSIONS: [&str; 6] = ["", "rs", "toml", "txt", "project", "sh"]; const ALLOWED_FILE_EXTENSIONS: [&str; 7] = ["", "rs", "toml", "txt", "project", "sh", "md"];
const PROJECT_EXTENSION: &str = "project"; const PROJECT_EXTENSION: &str = "project";
const TERMINAL_HEIGHT: f32 = 200.0; const TERMINAL_HEIGHT: f32 = 200.0;
const TERMINAL_RANGE: Range<f32> = 100.0..500.0; const TERMINAL_RANGE: Range<f32> = 100.0..600.0;
const RED: egui::Color32 = egui::Color32::from_rgb(235, 108, 99); const RED: egui::Color32 = egui::Color32::from_rgb(235, 108, 99);
const TIME_LABELS: [&str; 7] = [ const TIME_LABELS: [&str; 7] = [
"input", "settings", "tree", "terminal", "tabs", "content", "windows", "input", "settings", "tree", "terminal", "tabs", "content", "windows",
@ -72,6 +72,7 @@ struct Calcifer {
home: PathBuf, home: PathBuf,
tree_dir_opened: Vec<String>, tree_dir_opened: Vec<String>,
file_tree: Option<panels::FileEntry>, file_tree: Option<panels::FileEntry>,
n_file_displayed: usize,
tree_visible: bool, tree_visible: bool,
profiler_visible: bool, profiler_visible: bool,
@ -107,6 +108,7 @@ impl Default for Calcifer {
home: get_my_home().unwrap().unwrap(), home: get_my_home().unwrap().unwrap(),
tree_dir_opened: vec![], tree_dir_opened: vec![],
file_tree: None, file_tree: None,
n_file_displayed: 0,
tree_visible: false, tree_visible: false,
profiler_visible: false, profiler_visible: false,