Skip to content

Commit

Permalink
update egui
Browse files Browse the repository at this point in the history
  • Loading branch information
mankinskin committed Oct 4, 2024
1 parent b9f9796 commit 5ac8344
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 14 deletions.
15 changes: 7 additions & 8 deletions src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ impl App
|ui| {
if ui.button("Quit").clicked()
{
frame.close()
ctx.send_viewport_cmd(egui::ViewportCommand::Close)
}
},
)
Expand All @@ -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(
Expand Down Expand Up @@ -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}};
Expand Down
10 changes: 6 additions & 4 deletions src/graph/vis.rs
Original file line number Diff line number Diff line change
@@ -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::{
Expand Down Expand Up @@ -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| {
Expand Down
3 changes: 2 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#![forbid(unsafe_code)]
#![warn(clippy::all, rust_2018_idioms)]
#![allow(clippy::obfuscated_if_else)]

mod app;
pub use app::App;
Expand Down Expand Up @@ -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))),
);
}
3 changes: 2 additions & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#![forbid(unsafe_code)]
#![warn(clippy::all, rust_2018_idioms)]
#![allow(clippy::obfuscated_if_else)]

mod app;
use app::App;
Expand Down Expand Up @@ -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))),
);
}

0 comments on commit 5ac8344

Please sign in to comment.