mirror of
https://github.com/emilk/egui.git
synced 2026-08-30 13:20:05 -04:00
Update serial window example (#2756)
* Update to make it more clear what will happen * Provide an overview in readme of expectations * Update screenshot to match new code
This commit is contained in:
@@ -17,7 +17,7 @@ fn main() -> Result<(), eframe::Error> {
|
||||
eframe::run_native(
|
||||
"First Window",
|
||||
options.clone(),
|
||||
Box::new(|_cc| Box::new(MyApp::default())),
|
||||
Box::new(|_cc| Box::new(MyApp { has_next: true })),
|
||||
)?;
|
||||
|
||||
std::thread::sleep(std::time::Duration::from_secs(2));
|
||||
@@ -26,7 +26,7 @@ fn main() -> Result<(), eframe::Error> {
|
||||
eframe::run_native(
|
||||
"Second Window",
|
||||
options.clone(),
|
||||
Box::new(|_cc| Box::new(MyApp::default())),
|
||||
Box::new(|_cc| Box::new(MyApp { has_next: true })),
|
||||
)?;
|
||||
|
||||
std::thread::sleep(std::time::Duration::from_secs(2));
|
||||
@@ -35,16 +35,23 @@ fn main() -> Result<(), eframe::Error> {
|
||||
eframe::run_native(
|
||||
"Third Window",
|
||||
options,
|
||||
Box::new(|_cc| Box::new(MyApp::default())),
|
||||
Box::new(|_cc| Box::new(MyApp { has_next: false })),
|
||||
)
|
||||
}
|
||||
|
||||
#[derive(Default)]
|
||||
struct MyApp {}
|
||||
struct MyApp {
|
||||
pub(crate) has_next: bool,
|
||||
}
|
||||
|
||||
impl eframe::App for MyApp {
|
||||
fn update(&mut self, ctx: &egui::Context, frame: &mut eframe::Frame) {
|
||||
egui::CentralPanel::default().show(ctx, |ui| {
|
||||
let label_text = if self.has_next {
|
||||
"When this window is closed the next will be opened after a short delay"
|
||||
} else {
|
||||
"This is the last window. Program will end when closed"
|
||||
};
|
||||
ui.label(label_text);
|
||||
if ui.button("Close").clicked() {
|
||||
eprintln!("Pressed Close button");
|
||||
frame.close();
|
||||
|
||||
Reference in New Issue
Block a user