mirror of
https://github.com/emilk/egui.git
synced 2026-06-27 07:03:14 -04:00
The three methods for showing a `Panel` are now: * `panel.show`: always show the panel. * `panel.show_collapsible`: show or hide the panel, with a slide animation in between. * `Panel::show_switched`: animate between two different panels: a thin/collapsed one and a thick/expanded one.
53 lines
1.4 KiB
Rust
53 lines
1.4 KiB
Rust
#![doc = include_str!("../README.md")]
|
|
|
|
use eframe::{CreationContext, egui};
|
|
|
|
#[cfg(target_os = "android")]
|
|
#[unsafe(no_mangle)]
|
|
fn android_main(app: winit::platform::android::activity::AndroidApp) {
|
|
// Log to android output
|
|
android_logger::init_once(
|
|
android_logger::Config::default().with_max_level(log::LevelFilter::Info),
|
|
);
|
|
|
|
let options = eframe::NativeOptions {
|
|
android_app: Some(app),
|
|
..Default::default()
|
|
};
|
|
eframe::run_native(
|
|
"My egui App",
|
|
options,
|
|
Box::new(|cc| Ok(Box::new(MyApp::new(cc)))),
|
|
)
|
|
.unwrap()
|
|
}
|
|
|
|
pub struct MyApp {
|
|
demo: egui_demo_lib::DemoWindows,
|
|
}
|
|
|
|
impl MyApp {
|
|
pub fn new(cc: &CreationContext) -> Self {
|
|
egui_extras::install_image_loaders(&cc.egui_ctx);
|
|
Self {
|
|
demo: egui_demo_lib::DemoWindows::default(),
|
|
}
|
|
}
|
|
}
|
|
|
|
impl eframe::App for MyApp {
|
|
fn ui(&mut self, ui: &mut egui::Ui, _frame: &mut eframe::Frame) {
|
|
// Reserve some space at the top so the demo ui isn't hidden behind the android status bar
|
|
// TODO(lucasmerlin): This is a pretty big hack, should be fixed once safe_area implemented
|
|
// for android:
|
|
// https://github.com/rust-windowing/winit/issues/3910
|
|
egui::Panel::top("status_bar_space").show(ui, |ui| {
|
|
ui.set_height(32.0);
|
|
});
|
|
|
|
egui::CentralPanel::default().show(ui, |ui| {
|
|
self.demo.ui(ui);
|
|
});
|
|
}
|
|
}
|