1
0
mirror of https://github.com/emilk/egui.git synced 2026-09-01 22:30:03 -04:00

eframe app creation refactor (#1363)

* Change how eframe apps are created
* eframe: re-export epi::* so users don't need to care about what epi is
This commit is contained in:
Emil Ernerfeldt
2022-03-16 15:39:48 +01:00
committed by GitHub
parent c768d1d48e
commit c8f6cae362
26 changed files with 387 additions and 444 deletions

View File

@@ -4,7 +4,15 @@
#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")] // hide console window on Windows in release
use eframe::{egui, epi};
use eframe::egui;
fn main() {
let options = eframe::NativeOptions {
initial_window_size: Some(egui::vec2(1000.0, 700.0)),
..Default::default()
};
eframe::run_native("svg example", options, |_cc| Box::new(MyApp::default()));
}
struct MyApp {
svg_image: egui_extras::RetainedImage,
@@ -22,12 +30,8 @@ impl Default for MyApp {
}
}
impl epi::App for MyApp {
fn name(&self) -> &str {
"svg example"
}
fn update(&mut self, ctx: &egui::Context, _frame: &epi::Frame) {
impl eframe::App for MyApp {
fn update(&mut self, ctx: &egui::Context, _frame: &eframe::Frame) {
egui::CentralPanel::default().show(ctx, |ui| {
ui.heading("SVG example");
ui.label("The SVG is rasterized and displayed as a texture.");
@@ -39,11 +43,3 @@ impl epi::App for MyApp {
});
}
}
fn main() {
let options = eframe::NativeOptions {
initial_window_size: Some(egui::vec2(1000.0, 700.0)),
..Default::default()
};
eframe::run_native(Box::new(MyApp::default()), options);
}