mirror of
https://github.com/emilk/egui.git
synced 2026-08-30 13:20:05 -04:00
eframe: Replace Frame::update with fn logic and fn ui (#7775)
* Part of https://github.com/emilk/egui/issues/5113 * Part of https://github.com/emilk/egui/issues/3524 ## What This deprecates `eframe::App::update` and replaces it with two new functions: ```rs pub trait App { /// Called just before `ui`, and in the future this will /// also be called for background apps when needed. fn logic(&mut self, ctx: &egui::Context, frame: &mut Frame) { } /// Show your user interface to the user. fn ui(&mut self, ui: &mut egui::Ui, frame: &mut Frame); … } ``` Similarly, `Context::run` is deprecated in favor of `Context::run_ui`. `Plugin`s are now handed a `Ui` instead of just a `Context` in `on_begin/end_frame`. ## TODO …either in this PR or a later one * [x] Deprecate `App::update` * [x] Deprecate `Context::run` * [x] Change plugins to get a `Ui` * [x] Update kittest * [x] Change viewports to get UI:s (`show_viewport_immediate` etc) - https://github.com/emilk/egui/pull/7779 ## Later PRs * [ ] Deprecate `Panel::show` * [ ] Deprecate `CentralPanel::show` * [ ] Deprecate `CentralPanel` ?
This commit is contained in:
@@ -272,14 +272,27 @@ impl EpiIntegration {
|
||||
|
||||
app.raw_input_hook(&self.egui_ctx, &mut raw_input);
|
||||
|
||||
let full_output = self.egui_ctx.run(raw_input, |egui_ctx| {
|
||||
let full_output = self.egui_ctx.run_ui(raw_input, |ui| {
|
||||
if let Some(viewport_ui_cb) = viewport_ui_cb {
|
||||
// Child viewport
|
||||
profiling::scope!("viewport_callback");
|
||||
viewport_ui_cb(egui_ctx);
|
||||
viewport_ui_cb(ui);
|
||||
} else {
|
||||
profiling::scope!("App::update");
|
||||
app.update(egui_ctx, &mut self.frame);
|
||||
{
|
||||
profiling::scope!("App::logic");
|
||||
app.logic(ui.ctx(), &mut self.frame);
|
||||
}
|
||||
|
||||
{
|
||||
profiling::scope!("App::update");
|
||||
#[expect(deprecated)]
|
||||
app.update(ui.ctx(), &mut self.frame);
|
||||
}
|
||||
|
||||
{
|
||||
profiling::scope!("App::ui");
|
||||
app.ui(ui, &mut self.frame);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -1362,7 +1362,7 @@ fn initialize_or_update_viewport(
|
||||
ids: ViewportIdPair,
|
||||
class: ViewportClass,
|
||||
mut builder: ViewportBuilder,
|
||||
viewport_ui_cb: Option<Arc<dyn Fn(&egui::Context) + Send + Sync>>,
|
||||
viewport_ui_cb: Option<Arc<dyn Fn(&mut egui::Ui) + Send + Sync>>,
|
||||
) -> &mut Viewport {
|
||||
profiling::function_scope!();
|
||||
|
||||
@@ -1494,8 +1494,8 @@ fn render_immediate_viewport(
|
||||
shapes,
|
||||
pixels_per_point,
|
||||
viewport_output,
|
||||
} = egui_ctx.run(input, |ctx| {
|
||||
viewport_ui_cb(ctx);
|
||||
} = egui_ctx.run_ui(input, |ui| {
|
||||
viewport_ui_cb(ui);
|
||||
});
|
||||
|
||||
// ---------------------------------------------------
|
||||
|
||||
@@ -1027,8 +1027,8 @@ fn render_immediate_viewport(
|
||||
shapes,
|
||||
pixels_per_point,
|
||||
viewport_output,
|
||||
} = egui_ctx.run(input, |ctx| {
|
||||
viewport_ui_cb(ctx);
|
||||
} = egui_ctx.run_ui(input, |ui| {
|
||||
viewport_ui_cb(ui);
|
||||
});
|
||||
|
||||
// ------------------------------------------
|
||||
@@ -1155,7 +1155,7 @@ fn initialize_or_update_viewport<'a>(
|
||||
ids: ViewportIdPair,
|
||||
class: ViewportClass,
|
||||
mut builder: ViewportBuilder,
|
||||
viewport_ui_cb: Option<Arc<dyn Fn(&egui::Context) + Send + Sync>>,
|
||||
viewport_ui_cb: Option<Arc<dyn Fn(&mut egui::Ui) + Send + Sync>>,
|
||||
painter: &mut egui_wgpu::winit::Painter,
|
||||
) -> &'a mut Viewport {
|
||||
use std::collections::btree_map::Entry;
|
||||
|
||||
Reference in New Issue
Block a user