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

epi: merge App::load into App::setup, and provide Frame argument

This gives users more control over the order of load/setup.

It also allows users to load textures in setup.
This commit is contained in:
Emil Ernerfeldt
2021-06-07 20:53:33 +02:00
parent 31769d400f
commit 44b573f6a6
7 changed files with 105 additions and 53 deletions

View File

@@ -35,16 +35,16 @@ All notable changes to the `egui_glium` integration will be noted in this file.
## 0.7.0 - 2021-01-04
### Changed
### Changed 🔧
* `http` `persistence` and `time` are now optional (and opt-in) features.
## 0.6.0 - 2020-12-26
### Added
### Added
* `egui_glium` will auto-save your app state every 30 seconds.
* `egui_glium` can now set windows as fixed size (e.g. the user can't resize the window). See `egui::App::is_resizable()`.
### Changed
### Changed 🔧
* `egui_glium` will now save you app state to [a better directory](https://docs.rs/directories-next/2.0.0/directories_next/struct.ProjectDirs.html#method.data_dir).
* `egui_glium::run`: the parameter `app` now has signature `Box<dyn App>` (you need to add `Box::new(app)` to your code).
* Window title is now passed via the `trait` function `egui::App::name()`.
@@ -55,7 +55,7 @@ All notable changes to the `egui_glium` integration will be noted in this file.
## 0.5.0 - 2020-12-13
### Changed
### Changed 🔧
* FileStorage::from_path now takes `Into<Path>` instead of `String`

View File

@@ -167,9 +167,8 @@ fn load_icon(icon_data: epi::IconData) -> Option<glutin::window::Icon> {
pub fn run(mut app: Box<dyn epi::App>, nativve_options: epi::NativeOptions) -> ! {
let mut storage = create_storage(app.name());
if let Some(storage) = &mut storage {
app.load(storage.as_ref());
}
#[cfg(feature = "http")]
let http = std::sync::Arc::new(crate::http::GliumHttp {});
let window_settings = deserialize_window_settings(&storage);
let event_loop = glutin::event_loop::EventLoop::with_user_event();
@@ -183,7 +182,20 @@ pub fn run(mut app: Box<dyn epi::App>, nativve_options: epi::NativeOptions) -> !
let mut egui = EguiGlium::new(&display);
*egui.ctx().memory() = deserialize_memory(&storage).unwrap_or_default();
app.setup(&egui.ctx());
{
let (ctx, painter) = egui.ctx_and_painter_mut();
let mut app_output = epi::backend::AppOutput::default();
let mut frame = epi::backend::FrameBuilder {
info: integration_info(&display, None),
tex_allocator: painter,
#[cfg(feature = "http")]
http: http.clone(),
output: &mut app_output,
repaint_signal: repaint_signal.clone(),
}
.build();
app.setup(&ctx, &mut frame, storage.as_deref());
}
let mut previous_frame_time = None;
@@ -192,9 +204,6 @@ pub fn run(mut app: Box<dyn epi::App>, nativve_options: epi::NativeOptions) -> !
#[cfg(feature = "persistence")]
let mut last_auto_save = Instant::now();
#[cfg(feature = "http")]
let http = std::sync::Arc::new(crate::http::GliumHttp {});
if app.warm_up_enabled() {
let saved_memory = egui.ctx().memory().clone();
egui.ctx().memory().set_everything_is_visible(true);