feat(info): add info diag
cargo devel CI / cargo CI (push) Successful in 2m50s Details

This commit is contained in:
Christoph J. Scherr 2024-08-13 17:20:19 +02:00
parent 8f51a5ff44
commit 09c82cd593
2 changed files with 35 additions and 4 deletions

View File

@ -25,3 +25,4 @@ libpt = { version = "0.6.0", features = ["cli"] }
clap = { version = "4.5.15", features = ["derive"] }
image = "0.25.2"
rand = "0.8.5"
rfd = "0.14.1"

View File

@ -1,6 +1,7 @@
use clap::Parser;
use egui::IconData;
use libpt::cli::args::{VerbosityLevel, HELP_TEMPLATE};
use libpt::log::debug;
pub const TITLE: &str = "Rollator";
@ -21,6 +22,10 @@ pub struct RollatorApp {
#[serde(skip)]
#[command(flatten)]
pub(crate) verbosity: VerbosityLevel,
#[serde(skip)]
#[clap(skip)]
show_info_window: bool,
}
impl Default for RollatorApp {
@ -29,6 +34,7 @@ impl Default for RollatorApp {
label: TITLE.to_owned(),
value: 2.7,
verbosity: VerbosityLevel::INFO,
show_info_window: false,
}
}
}
@ -54,6 +60,31 @@ impl RollatorApp {
pub fn new_with_cli() -> Self {
Self::parse()
}
pub fn info_diag(&mut self, ctx: &egui::Context) {
debug!("opening info dialogue");
ctx.show_viewport_immediate(
egui::ViewportId::from_hash_of("immediate_viewport"),
egui::ViewportBuilder::default()
.with_title("Immediate Viewport")
.with_inner_size([200.0, 100.0]),
|ctx, class| {
assert!(
class == egui::ViewportClass::Immediate,
"This egui backend doesn't support multiple viewports"
);
egui::CentralPanel::default().show(ctx, |ui| {
ui.label("Hello from immediate viewport");
bottom_label(ui);
});
if ctx.input(|i| i.viewport().close_requested()) {
// Tell parent viewport that we should not show next frame:
self.show_info_window = false;
}
},
);
}
}
impl eframe::App for RollatorApp {
@ -78,10 +109,9 @@ impl eframe::App for RollatorApp {
if ui.button("Quit").clicked() {
ctx.send_viewport_cmd(egui::ViewportCommand::Close);
}
});
ui.menu_button("AAAA", |ui| {
if ui.button("Quit").clicked() {
ctx.send_viewport_cmd(egui::ViewportCommand::Close);
if ui.button("Info").clicked() || self.show_info_window {
self.show_info_window = true;
self.info_diag(ctx);
}
});
ui.add_space(16.0);