mirror of
https://github.com/emilk/egui.git
synced 2026-08-29 04:40:03 -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:
@@ -215,10 +215,11 @@ impl winit::application::ApplicationHandler<UserEvent> for GlowApp {
|
||||
let mut redraw = || {
|
||||
let mut quit = false;
|
||||
|
||||
self.egui_glow.as_mut().unwrap().run(
|
||||
self.gl_window.as_mut().unwrap().window(),
|
||||
|egui_ctx| {
|
||||
egui::Panel::left("my_side_panel").show(egui_ctx, |ui| {
|
||||
self.egui_glow
|
||||
.as_mut()
|
||||
.unwrap()
|
||||
.run(self.gl_window.as_mut().unwrap().window(), |ui| {
|
||||
egui::Panel::left("my_side_panel").show_inside(ui, |ui| {
|
||||
ui.heading("Hello World!");
|
||||
if ui.button("Quit").clicked() {
|
||||
quit = true;
|
||||
@@ -226,8 +227,7 @@ impl winit::application::ApplicationHandler<UserEvent> for GlowApp {
|
||||
|
||||
ui.color_edit_button_rgb(self.clear_color.as_mut().try_into().unwrap());
|
||||
});
|
||||
},
|
||||
);
|
||||
});
|
||||
|
||||
if quit {
|
||||
event_loop.exit();
|
||||
|
||||
@@ -65,7 +65,7 @@ impl EguiGlow {
|
||||
}
|
||||
|
||||
/// Call [`Self::paint`] later to paint.
|
||||
pub fn run(&mut self, window: &winit::window::Window, run_ui: impl FnMut(&egui::Context)) {
|
||||
pub fn run(&mut self, window: &winit::window::Window, run_ui: impl FnMut(&mut egui::Ui)) {
|
||||
let raw_input = self.egui_winit.take_egui_input(window);
|
||||
|
||||
let egui::FullOutput {
|
||||
@@ -74,7 +74,7 @@ impl EguiGlow {
|
||||
shapes,
|
||||
pixels_per_point,
|
||||
viewport_output,
|
||||
} = self.egui_ctx.run(raw_input, run_ui);
|
||||
} = self.egui_ctx.run_ui(raw_input, run_ui);
|
||||
|
||||
if viewport_output.len() > 1 {
|
||||
log::warn!("Multiple viewports not yet supported by EguiGlow");
|
||||
|
||||
Reference in New Issue
Block a user