diff --git a/src/app.rs b/src/app.rs index 51e638d..e738d17 100644 --- a/src/app.rs +++ b/src/app.rs @@ -144,7 +144,7 @@ impl App |ui| { if ui.button("Quit").clicked() { - frame.close() + ctx.send_viewport_cmd(egui::ViewportCommand::Close) } }, ) @@ -168,10 +168,10 @@ impl App } impl eframe::App for App { - fn max_size_points(&self) -> egui::Vec2 - { - (f32::INFINITY, f32::INFINITY).into() - } + //fn max_size_points(&self) -> egui::Vec2 + //{ + // (f32::INFINITY, f32::INFINITY).into() + //} /// Called by the frame work to save state before shutdown. #[cfg(feature = "persistence")] fn save( @@ -199,20 +199,19 @@ impl eframe::App for App //self.read_task = Some(self.graph.read_text(insert_text, ctx)); let res = ngrams::graph::parse_corpus(ngrams::graph::Corpus::new("", [insert_text])); - *self.graph.graph.write().unwrap() = res.graph; + *self.graph.graph.write().unwrap() = res.containment; *self.graph.labels.write().unwrap() = res.labels; } }); } } - fn on_close_event(&mut self) -> bool + fn on_exit(&mut self, ctx: Option<&eframe::glow::Context>) { if let Some(handle) = self.read_task.take() { println!("abort"); handle.abort(); } - true } } use std::{future::Future, sync::{Arc, RwLock}}; diff --git a/src/graph/vis.rs b/src/graph/vis.rs index ad334cb..11f3737 100644 --- a/src/graph/vis.rs +++ b/src/graph/vis.rs @@ -1,6 +1,6 @@ -use eframe::egui::{ +use eframe::{egui::{ self, vec2, Color32, Frame, Pos2, Rect, Response, Shape, Stroke, Style, Ui, Vec2, Window -}; +}, epaint::Shadow}; #[allow(unused)] use petgraph::{ graph::{ @@ -424,13 +424,15 @@ impl NodeVis Window::new(&format!("{}({})", self.name, self.idx.index())) //Window::new(&self.name) .vscroll(true) - .default_width(80.0) + .auto_sized() + //.default_width(80.0) .frame( Frame::window(&Style::default()) + .shadow(Shadow::NONE) .fill( self.graph.labels.read().unwrap().contains(&self.key) .then_some(Color32::from_rgb(10, 50, 10)) - .unwrap_or_default() + .unwrap_or(ui.style().visuals.widgets.open.bg_fill) ) ) .show(ui.ctx(), |ui| { diff --git a/src/lib.rs b/src/lib.rs index 3f111be..1298dac 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,5 +1,6 @@ #![forbid(unsafe_code)] #![warn(clippy::all, rust_2018_idioms)] +#![allow(clippy::obfuscated_if_else)] mod app; pub use app::App; @@ -49,6 +50,6 @@ pub async fn open(graph: HypergraphRef) eframe::run_native( "Graph App", eframe::NativeOptions::default(), - Box::new(|_| Box::new(app)), + Box::new(|_| Ok(Box::new(app))), ); } diff --git a/src/main.rs b/src/main.rs index 498c455..5451448 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,5 +1,6 @@ #![forbid(unsafe_code)] #![warn(clippy::all, rust_2018_idioms)] +#![allow(clippy::obfuscated_if_else)] mod app; use app::App; @@ -33,6 +34,6 @@ async fn main() eframe::run_native( "Graph App", eframe::NativeOptions::default(), - Box::new(|_| Box::new(app)), + Box::new(|_| Ok(Box::new(app))), ); }