From 94bcff177eb0645b542c46919d469f3694d2b05c Mon Sep 17 00:00:00 2001 From: Steve Biedermann Date: Tue, 8 Oct 2024 17:55:54 +0200 Subject: [PATCH] update --- src/main.rs | 29 ++++++++++++----------------- 1 file changed, 12 insertions(+), 17 deletions(-) diff --git a/src/main.rs b/src/main.rs index 17e98c4..17e9d9d 100644 --- a/src/main.rs +++ b/src/main.rs @@ -87,8 +87,7 @@ impl State { #[tokio::main] async fn main() -> Result<(), String> { let win = WindowConfig::new() - .set_always_on_top(true) - .set_vsync(true) + .set_vsync(false) .set_lazy_loop(true) .set_transparent(true) .set_high_dpi(true); @@ -105,25 +104,12 @@ async fn main() -> Result<(), String> { } fn update(app: &mut App, state: &mut State) { - if app.keyboard.is_down(KeyCode::Escape) { - let (x, y) = app.window().screen_size(); - app.window().set_position(x + 10000, y + 10000); - } - if let Ok(event) = state.tray_data.menu_channel.try_recv() { + if let Ok(event) = MenuEvent::receiver().try_recv() { if event.id == state.tray_data.quit_i.id() { state.tray_data.tray_icon.take(); app.exit(); } } - if let Ok(event) = state.tray_data.tray_channel.try_recv() { - if let TrayIconEvent::DoubleClick { - button: MouseButton::Left, - .. - } = event - { - app.window().set_position(0, 0); - } - } } fn event(_app: &mut App, _assets: &mut Assets, state: &mut State, evt: Event) { @@ -147,12 +133,13 @@ fn event(_app: &mut App, _assets: &mut Assets, state: &mut State, evt: Event) { } } -fn draw(_app: &mut App, gfx: &mut Graphics, plugins: &mut Plugins, state: &mut State) { +fn draw(app: &mut App, gfx: &mut Graphics, plugins: &mut Plugins, state: &mut State) { let mut output = plugins.egui(|ctx| { egui::SidePanel::left("side_panel").show(ctx, |ui| { ui.collapsing("Logs", |ui| { egui::ScrollArea::vertical().show(ui, |ui| { let mut to_swap = None; + let mut to_delete = None; let history_len = state.log_history.len(); for (i, log) in state.log_history.iter().enumerate() { let path_text = log.path.to_string_lossy().to_string(); @@ -164,6 +151,10 @@ fn draw(_app: &mut App, gfx: &mut Graphics, plugins: &mut Plugins, state: &mut S _ = Command::new("notepad.exe").arg(&path_text).spawn(); ui.close_menu(); } + if ui.button("Remove").clicked() { + to_delete = Some(i); + ui.close_menu(); + } }); if label.clicked() { _ = Command::new("C:\\tools\\fast-log-viewer\\fast_log_viewer.exe") @@ -181,6 +172,10 @@ fn draw(_app: &mut App, gfx: &mut Graphics, plugins: &mut Plugins, state: &mut S } state.save(); } + if let Some(i) = to_delete { + _ = state.log_history.shift_remove_index(i); + state.save(); + } }) }) });