circle-cipher/src/gui.rs

47 lines
1.1 KiB
Rust
Raw Normal View History

2024-11-04 00:14:54 +00:00
pub fn gui() -> Result<(), eframe::Error> {
let options = eframe::NativeOptions::default();
eframe::run_native("Encoded Message", options, Box::new(|_cc| Ok(Box::<Gui>::new(
Default::default()
))))
}
2024-11-04 00:14:54 +00:00
struct Gui {
message: Option<crate::Message>,
circle_length: Option<usize>,
}
impl Default for Gui {
fn default() -> Self {
Self{
message: None,
circle_length: None,
}
}
}
2024-11-04 00:14:54 +00:00
impl eframe::App for Gui {
fn update(&mut self, ctx: &egui::Context, _frame: &mut eframe::Frame) {
2024-11-04 00:14:54 +00:00
egui::CentralPanel::default().show(ctx, |ui| {
//TODO: UI (on unfocus update values)
// Message Content input
// start shift input
// circle length input
// generate button (if pressed, generate plot with details)
});
}
}
2024-11-04 00:14:54 +00:00
pub struct Error(eframe::Error);
2024-11-04 00:14:54 +00:00
impl From<eframe::Error> for Error {
fn from(err: eframe::Error) -> Self {
Error(err)
}
}
impl From<Error> for anyhow::Error {
fn from(err: Error) -> Self {
anyhow::anyhow!(err.0.to_string())
}
}