
* eframe::run_native: return errors instead of crashing * Detect and handle glutin errors * egui_demo_app: silence wgpu log spam * Add trace logs for why eframe is shutting down * Fix: only save App state once on Mac * Handle Winit failure * Log where we load app state from * Don't panic on zero-sized window * Clamp loaded window size to not be too tiny to see * Simplify code: more shared code in window_builder * Improve code readability * Fix wasm32 build * fix android * Update changelog
54 lines
1.5 KiB
Rust
54 lines
1.5 KiB
Rust
#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")] // hide console window on Windows in release
|
|
|
|
use eframe::egui;
|
|
|
|
fn main() -> Result<(), eframe::EframeError> {
|
|
if cfg!(target_os = "macos") {
|
|
eprintln!("WARNING: this example does not work on Mac! See https://github.com/emilk/egui/issues/1918");
|
|
}
|
|
|
|
let options = eframe::NativeOptions {
|
|
run_and_return: true,
|
|
initial_window_size: Some(egui::vec2(320.0, 240.0)),
|
|
..Default::default()
|
|
};
|
|
|
|
eprintln!("Starting first window…");
|
|
eframe::run_native(
|
|
"First Window",
|
|
options.clone(),
|
|
Box::new(|_cc| Box::new(MyApp::default())),
|
|
)?;
|
|
|
|
std::thread::sleep(std::time::Duration::from_secs(2));
|
|
|
|
eprintln!("Starting second window…");
|
|
eframe::run_native(
|
|
"Second Window",
|
|
options.clone(),
|
|
Box::new(|_cc| Box::new(MyApp::default())),
|
|
)?;
|
|
|
|
std::thread::sleep(std::time::Duration::from_secs(2));
|
|
|
|
eprintln!("Starting third window…");
|
|
eframe::run_native(
|
|
"Third Window",
|
|
options,
|
|
Box::new(|_cc| Box::new(MyApp::default())),
|
|
)
|
|
}
|
|
|
|
#[derive(Default)]
|
|
struct MyApp {}
|
|
|
|
impl eframe::App for MyApp {
|
|
fn update(&mut self, ctx: &egui::Context, frame: &mut eframe::Frame) {
|
|
egui::CentralPanel::default().show(ctx, |ui| {
|
|
if ui.button("Close").clicked() {
|
|
eprintln!("Pressed Close button");
|
|
frame.close();
|
|
}
|
|
});
|
|
}
|
|
}
|