mirror of
https://github.com/emilk/egui.git
synced 2026-06-28 07:23:13 -04:00
Context::current_rendering_viewport was replaced by Context::get_viewport_id Added Context::get_parent_viewport_id Changed Context::run to need parent_viewport_id Changed Context::beagin to need parent_viewport_id Added ImplContext::frame_stack Some work on making posibile to render multiples frames at the same time A lot of more things in glutin backend is not Arc<RwLock<T>>
37 lines
1.2 KiB
Rust
37 lines
1.2 KiB
Rust
#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")] // hide console window on Windows in release
|
|
|
|
use eframe::egui::{self};
|
|
|
|
fn main() -> Result<(), eframe::Error> {
|
|
env_logger::init(); // Log to stderr (if you run with `RUST_LOG=debug`).
|
|
|
|
let options = eframe::NativeOptions {
|
|
initial_window_size: Some(egui::vec2(320.0, 240.0)),
|
|
..Default::default()
|
|
};
|
|
|
|
// Our application state:
|
|
let mut name = "Arthur".to_owned();
|
|
let mut age = 42;
|
|
|
|
eframe::run_simple_native("My egui App", options, move |ctx, _frame| {
|
|
egui::CentralPanel::default().show(ctx, |ui| {
|
|
ui.label(format!(
|
|
"Current rendering window: {}",
|
|
ctx.get_viewport_id()
|
|
));
|
|
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("Click each year").clicked() {
|
|
age += 1;
|
|
}
|
|
ui.label(format!("Hello '{name}', age {age}"));
|
|
});
|
|
})
|
|
}
|