mirror of
https://github.com/emilk/egui.git
synced 2026-06-27 15:13:12 -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.
34 lines
1.2 KiB
Rust
34 lines
1.2 KiB
Rust
#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")] // hide console window on Windows in release
|
|
#![expect(rustdoc::missing_crate_level_docs)] // it's an example
|
|
|
|
use eframe::egui;
|
|
|
|
fn main() -> eframe::Result {
|
|
env_logger::init(); // Log to stderr (if you run with `RUST_LOG=debug`).
|
|
|
|
let options = eframe::NativeOptions {
|
|
viewport: egui::ViewportBuilder::default().with_inner_size([320.0, 240.0]),
|
|
..Default::default()
|
|
};
|
|
|
|
// Our application state:
|
|
let mut name = "Arthur".to_owned();
|
|
let mut age = 42;
|
|
|
|
eframe::run_ui_native("My egui App", options, move |ui, _frame| {
|
|
egui::CentralPanel::default().show(ui, |ui| {
|
|
ui.heading("My egui Application");
|
|
ui.horizontal(|ui| {
|
|
let name_label = ui.label("Your name: ");
|
|
ui.text_edit_singleline(&mut name)
|
|
.labelled_by(name_label.id);
|
|
});
|
|
ui.add(egui::Slider::new(&mut age, 0..=120).text("age"));
|
|
if ui.button("Increment").clicked() {
|
|
age += 1;
|
|
}
|
|
ui.label(format!("Hello '{name}', age {age}"));
|
|
});
|
|
})
|
|
}
|