2024-11-04 02:30:33 +00:00
|
|
|
pub struct Error(eframe::Error);
|
|
|
|
|
|
|
|
|
|
pub fn gui() -> anyhow::Result<()> {
|
2024-11-04 00:14:54 +00:00
|
|
|
let options = eframe::NativeOptions::default();
|
2024-11-04 02:30:33 +00:00
|
|
|
eframe::run_native(
|
|
|
|
|
"Encoded Message",
|
|
|
|
|
options,
|
|
|
|
|
Box::new(|_cc| Ok(Box::<Gui>::new(
|
2024-11-04 00:14:54 +00:00
|
|
|
Default::default()
|
2024-11-04 02:30:33 +00:00
|
|
|
)))
|
|
|
|
|
).map_err(crate::Error::from)?;
|
|
|
|
|
Ok(())
|
2024-11-03 20:57:53 +00:00
|
|
|
}
|
|
|
|
|
|
2024-11-04 03:16:40 +00:00
|
|
|
#[derive(Default)]
|
2024-11-04 00:14:54 +00:00
|
|
|
struct Gui {
|
|
|
|
|
message: Option<crate::Message>,
|
|
|
|
|
circle_length: Option<usize>,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
impl eframe::App for Gui {
|
2024-11-03 20:57:53 +00:00
|
|
|
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-03 20:57:53 +00:00
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
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())
|
|
|
|
|
}
|
2024-11-03 20:57:53 +00:00
|
|
|
}
|