Skip to content

Commit

Permalink
auto focus new explorers
Browse files Browse the repository at this point in the history
  • Loading branch information
Vulae committed Aug 4, 2024
1 parent 44b3602 commit e4eb86a
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/app/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,15 @@ use super::explorers::{image::ImageExplorer, source_engine::{vpk::VpkExplorer, v
pub struct AppContext {
pub explorers: Vec<SharedExplorer>,
open_explorer: Uuid,
auto_focus_new_explorers: bool,
}

impl AppContext {
fn new() -> AppContext {
AppContext {
explorers: Vec::new(),
open_explorer: Uuid::nil(),
auto_focus_new_explorers: true,
}
}
}
Expand Down Expand Up @@ -55,6 +57,9 @@ impl SharedAppContext {
}

pub fn new_explorer(&mut self, explorer: impl Explorer + 'static) {
if self.app_context.borrow().auto_focus_new_explorers {
self.app_context.borrow_mut().open_explorer = explorer.uuid();
}
self.app_context.borrow_mut().explorers.push(SharedExplorer(Rc::new(RefCell::new(explorer))));
}

Expand Down Expand Up @@ -108,6 +113,8 @@ impl SharedAppContext {

impl eframe::App for SharedAppContext {
fn update(&mut self, ctx: &egui::Context, _frame: &mut eframe::Frame) {
self.app_context.borrow_mut().auto_focus_new_explorers = !ctx.input(|i| i.modifiers.shift);

let files = ctx.input(|i| i.raw.dropped_files.clone());
if !files.is_empty() {
for file in files {
Expand Down

0 comments on commit e4eb86a

Please sign in to comment.