diff --git a/crates/ui-egui/src/canvas/marks/tests.rs b/crates/ui-egui/src/canvas/marks/tests.rs index 1c57946982..2bb6ecda50 100644 --- a/crates/ui-egui/src/canvas/marks/tests.rs +++ b/crates/ui-egui/src/canvas/marks/tests.rs @@ -40,20 +40,31 @@ fn settled(app: &mut VectorcraftApp, view: &CanvasView, ids: &[NodeId]) -> Vec egui::Context { /// One frame of the whole app on `ctx` as the hosts run it (kb.C26): the app has the window's context, as the hosts /// hand it when they create the app, gives the input of the frame -/// (`embed::before_input`), the window draws with `raw`, and the app takes what the runtime gathered in it, running the -/// commands it fired, as the host's next frame begins. The frame's texture uploads are handled. +/// (`embed::before_input`, once, as the hosts call it), the window draws with `raw`, and the app takes what the runtime +/// gathered in it, running the commands it fired, as the host's next frame begins ([`run_fired`]). The frame's texture +/// uploads are handled. pub(crate) fn app_frame(app: &mut crate::VectorcraftApp, ctx: &egui::Context, raw: egui::RawInput) -> egui::FullOutput { part_frame(app, ctx, raw, |app, ui| { app.tick(ui.ctx()); @@ -56,11 +57,18 @@ pub(crate) fn part_frame( app.raw_input(ctx, &mut raw); embed::before_input(ctx, |out| app.frame_input(out)); let mut out = ctx.run_ui(raw, |ui| draw(app, ui)); - embed::before_input(ctx, |out| app.frame_input(out)); + run_fired(app, ctx); out.textures_delta.clear(); out } +/// The app takes what the runtime gathered on `ctx` since the last frame began and runs the commands it fired, as the +/// host's next `embed::before_input` does, without giving the runtime its input: the next frame gives it. A second +/// input in one frame makes every command state the next frame publishes look changed, and the frame asks for a rerun. +pub(crate) fn run_fired(app: &mut crate::VectorcraftApp, ctx: &egui::Context) { + let _ = app.frame_input(take_output(ctx)); +} + /// Held by a test that changes the custom dictionary, which the whole process shares, or that needs it to hold still: /// every change moves the dictionary's generation, and a Check Spelling walk that sees it move checks its scope again /// from the start. diff --git a/crates/ui-egui/src/tests/lifecycle.rs b/crates/ui-egui/src/tests/lifecycle.rs index 0887622ffc..41ace0ff2d 100644 --- a/crates/ui-egui/src/tests/lifecycle.rs +++ b/crates/ui-egui/src/tests/lifecycle.rs @@ -64,7 +64,7 @@ fn run_frame( } }); // The commands the frame fired run as the host's next frame begins (`testing::app_frame`). - craft::ui::shell::embed::before_input(ctx, |output| app.frame_input(output)); + crate::testing::run_fired(app, ctx); out.textures_delta.clear(); (passes, out.platform_output.ime) } diff --git a/crates/ui-egui/src/tests/nativemenu.rs b/crates/ui-egui/src/tests/nativemenu.rs index 27dd215565..8a13fbda07 100644 --- a/crates/ui-egui/src/tests/nativemenu.rs +++ b/crates/ui-egui/src/tests/nativemenu.rs @@ -125,10 +125,7 @@ impl Mac { screen_rect: Some(Rect::from_min_size(Pos2::ZERO, vec2(1600.0, 850.0))), ..Default::default() }; - let app = &mut self.app; - craft::ui::shell::embed::before_input(&self.ctx, |out| app.frame_input(out)); - - crate::testing::app_frame(app, &self.ctx, raw) + crate::testing::app_frame(&mut self.app, &self.ctx, raw) } /// AppKit chose an item by its key equivalent `sc`. A paste the menu asks the host for diff --git a/crates/ui-egui/src/tests/plugins.rs b/crates/ui-egui/src/tests/plugins.rs index 24ec586447..7b51659271 100644 --- a/crates/ui-egui/src/tests/plugins.rs +++ b/crates/ui-egui/src/tests/plugins.rs @@ -48,14 +48,11 @@ pub(super) fn window(app: VectorcraftApp) -> Window { /// commands the pass fired run as the next frame begins. pub(super) fn app_step(h: &mut Window) { let ctx = h.ctx.clone(); - let input = |h: &mut Window| { - let app = h.state_mut(); - app.adopt_context(&ctx); - craft::ui::shell::embed::before_input(&ctx, |out| app.frame_input(out)); - }; - input(h); + let app = h.state_mut(); + app.adopt_context(&ctx); + craft::ui::shell::embed::before_input(&ctx, |out| app.frame_input(out)); h.step(); - input(h); + crate::testing::run_fired(h.state_mut(), &ctx); } /// Draws a frame of `h` at `time` seconds. diff --git a/crates/ui-egui/src/tests/sysclip.rs b/crates/ui-egui/src/tests/sysclip.rs index 878683cb4b..baa21396ed 100644 --- a/crates/ui-egui/src/tests/sysclip.rs +++ b/crates/ui-egui/src/tests/sysclip.rs @@ -315,11 +315,7 @@ pub(super) fn frame(app: &mut VectorcraftApp, events: Vec) -> egui: static CTX: egui::Context = crate::testing::ui_context(); } let ctx = CTX.with(Clone::clone); - craft::ui::shell::embed::before_input(&ctx, |output| app.frame_input(output)); - let mut out = crate::testing::app_frame(app, &ctx, egui::RawInput { events, ..Default::default() }); - craft::ui::shell::embed::before_input(&ctx, |output| app.frame_input(output)); - out.textures_delta.clear(); - out + crate::testing::app_frame(app, &ctx, egui::RawInput { events, ..Default::default() }) } /// The paste egui sends for a clipboard with a picture and no text. diff --git a/crates/ui-egui/tests/control_bar_corners.rs b/crates/ui-egui/tests/control_bar_corners.rs index 35c3b75deb..f11ca7b51e 100644 --- a/crates/ui-egui/tests/control_bar_corners.rs +++ b/crates/ui-egui/tests/control_bar_corners.rs @@ -4,6 +4,7 @@ use std::sync::{Mutex, MutexGuard}; +use craft::ui::runtime::frame::take_output; use craft::ui::shell::embed; use egui::{Event, Rect, vec2}; use serde_json::json; @@ -99,7 +100,7 @@ impl Frames { }, |ui| chrome::control_bar(app, ui), ); - embed::before_input(&self.ctx, |out| app.frame_input(out)); + let _ = app.frame_input(take_output(&self.ctx)); let nodes = output.platform_output.accesskit_update.take().map(|update| update.nodes.into_iter().map(|(_, node)| node).collect()).unwrap_or_default(); output.textures_delta.clear(); diff --git a/crates/ui-egui/tests/pattern_only_nudge.rs b/crates/ui-egui/tests/pattern_only_nudge.rs index cb7c58a7e2..9a17b2b498 100644 --- a/crates/ui-egui/tests/pattern_only_nudge.rs +++ b/crates/ui-egui/tests/pattern_only_nudge.rs @@ -74,7 +74,7 @@ impl Scene { // As the hosts run a frame: the app gives its input, and the commands the pass fired run as the next frame begins. craft::ui::shell::embed::before_input(&self.ctx, |out| self.app.frame_input(out)); let mut out = self.ctx.run_ui(raw, |ui| self.app.ui(ui)); - craft::ui::shell::embed::before_input(&self.ctx, |out| self.app.frame_input(out)); + let _ = self.app.frame_input(craft::ui::runtime::frame::take_output(&self.ctx)); out.textures_delta.clear(); } diff --git a/crates/ui-egui/tests/selection_tools_toggle.rs b/crates/ui-egui/tests/selection_tools_toggle.rs index fa8e35a3d7..5e7522ea77 100644 --- a/crates/ui-egui/tests/selection_tools_toggle.rs +++ b/crates/ui-egui/tests/selection_tools_toggle.rs @@ -4,6 +4,7 @@ use std::sync::{Mutex, MutexGuard}; +use craft::ui::runtime::frame::take_output; use craft::ui::shell::embed; use egui::{Event, Key, Modifiers}; use serde_json::json; @@ -65,6 +66,7 @@ impl Keyboard { fn frame(&mut self, app: &mut VectorcraftApp, events: Vec) { self.time += 0.05; + app.adopt_context(&self.ctx); embed::before_input(&self.ctx, |out| app.frame_input(out)); let mut out = self.ctx.run_ui( egui::RawInput { @@ -79,8 +81,8 @@ impl Keyboard { app.ui(ui); }, ); - // The commands the pass fired run as the host's next frame begins. - embed::before_input(&self.ctx, |out| app.frame_input(out)); + // The commands the pass fired run as the host's next frame begins; the next frame gives the input. + let _ = app.frame_input(take_output(&self.ctx)); out.textures_delta.clear(); }