diff --git a/crates/ui-egui/src/app/frame.rs b/crates/ui-egui/src/app/frame.rs index e5e86d919cc..5be839b1ab8 100644 --- a/crates/ui-egui/src/app/frame.rs +++ b/crates/ui-egui/src/app/frame.rs @@ -224,7 +224,7 @@ impl PhotocraftApp { let panels_on = &self.ui.panels; let (menu_bar, options_bar, status_bar) = (panels_on.menu_bar, panels_on.options_bar, panels_on.status_bar); let window_title = panels::title_bar::window_title(self); - let versions = (panels::region_versions::options_bar(self), panels::region_versions::status_bar(self)); + let versions = (panels::region_versions::options_bar(self), panels::region_versions::status_bar(self), panels::region_versions::title_bar(self)); // The shell binds a copy of the mode, since `show` takes the app too; the copy goes back // to the view after the pass. let mut mode = self.ui.view.screen_mode; @@ -233,6 +233,7 @@ impl PhotocraftApp { .window_title(window_title) .screen_mode(Bind::bound(&mut mode)) .title_bar_if(menu_bar, |ui, _cx, app| panels::title_bar(app, ui)) + .content(slots::TITLE, versions.2) .options_bar(options_bar && !home, |ui, _cx, app| panels::options_bar(app, ui)) .content(slots::OPTIONS, versions.0) .status(status_bar && !home, |ui, _cx, app| panels::status_bar(app, ui)) diff --git a/crates/ui-egui/src/chrome_settle_trials.rs b/crates/ui-egui/src/chrome_settle_trials.rs new file mode 100644 index 00000000000..50ac07d5a3f --- /dev/null +++ b/crates/ui-egui/src/chrome_settle_trials.rs @@ -0,0 +1,36 @@ +//! The window's chrome settles (#15493): a frame whose only input is the pointer moving over the canvas runs no dock +//! group header, panel tab strip or grip and no title bar; each repaints its last run. Before, every frame ran them. + +use craft::ui::runtime::measure::last_pass_runs; +use egui::{Event, vec2}; +use egui_kittest::Harness; +use serde_json::json; + +use crate::PhotocraftApp; + +/// The chrome components the last pass ran, by type name. +fn chrome_runs(h: &Harness<'static, Box>) -> Vec<(&'static str, u32)> { + const CHROME: [&str; 4] = + ["docking::group::DockGroup<", "docking::group::GroupGrip<", "TabStrip<'_, craft_ui_panels::docking::PanelKey>", "title_bar::bar::TitleBar<"]; + last_pass_runs(&h.ctx).into_iter().filter(|(ty, _)| CHROME.iter().any(|name| ty.contains(name))).collect() +} + +#[test] +fn a_hover_over_the_canvas_runs_no_dock_chrome_and_no_title_bar() { + let mut h = Harness::builder().with_size(vec2(1440.0, 900.0)).with_max_steps(64).with_step_dt(1.0 / 60.0).build_eframe(|cc| { + PhotocraftApp::setup_context(&cc.egui_ctx, Default::default()); + let mut session = photocraft_engine::Session::new(); + session.execute("file.new", json!({"width": 400, "height": 300})).unwrap(); + PhotocraftApp::with_context(cc.egui_ctx.clone(), session, crate::Services::default()) + }); + h.run_steps(8); + let at = h.state().last_canvas_rect.center(); + h.event(Event::PointerMoved(at)); + h.run_steps(4); + assert!(!last_pass_runs(&h.ctx).is_empty(), "the frame runs components"); + for step in 1..=3 { + h.event(Event::PointerMoved(at + vec2(step as f32, 0.0))); + h.run_steps(1); + assert_eq!(chrome_runs(&h), [], "hover step {step}: the dock chrome and the title bar repaint their last run"); + } +} diff --git a/crates/ui-egui/src/lib.rs b/crates/ui-egui/src/lib.rs index 46044fbbc8e..2095c79d1a7 100644 --- a/crates/ui-egui/src/lib.rs +++ b/crates/ui-egui/src/lib.rs @@ -937,6 +937,8 @@ mod move_outline_tests; #[cfg(test)] mod move_bar_distribute_gear_tests; +#[cfg(test)] +mod chrome_settle_trials; #[cfg(test)] mod doc_revision_trials; #[cfg(test)] diff --git a/crates/ui-egui/src/panels/panel_docking.rs b/crates/ui-egui/src/panels/panel_docking.rs index 24e2cb331c8..cb90982355e 100644 --- a/crates/ui-egui/src/panels/panel_docking.rs +++ b/crates/ui-egui/src/panels/panel_docking.rs @@ -175,6 +175,11 @@ impl DockPanels for Panels<'_> { body(self.app, ui, panel); } + /// Each group's header and tab strip and each column's bar settle as the panel bodies do. + fn spec_version(&self) -> Option { + Some(super::region_versions::dock_chrome(self.app)) + } + fn content(&self, panel: &String) -> Option { match panel.as_str() { // The canvas shows state that changes without a command: the view, redraw progress, animation and job overlays. diff --git a/crates/ui-egui/src/panels/region_versions.rs b/crates/ui-egui/src/panels/region_versions.rs index 25d3c3daf0a..6c1a473f30e 100644 --- a/crates/ui-egui/src/panels/region_versions.rs +++ b/crates/ui-egui/src/panels/region_versions.rs @@ -15,6 +15,23 @@ pub(crate) fn options_bar(app: &PhotocraftApp) -> u64 { version(app, (view(app), app.ui.transform.is_some())) } +/// The version of the title bar: the title it shows (the active document's name and its unsaved mark), the language +/// its menu titles are in and whether the menus are in the bar (not in the macOS menu bar). An open menu is an overlay +/// and runs as it is shown. +pub(crate) fn title_bar(app: &PhotocraftApp) -> u64 { + version(app, (super::title_bar::title_text(app), crate::i18n::current().code(), app.services.native_menu.is_none())) +} + +/// The version of what the dock's chrome (each group's header and tab strip, each column's bar) shows of the panels +/// (`DockPanels::spec_version`): their names in the UI language and the toolbar's grid, whose cells are the visible +/// toolbar slots. Every other part of a panel's spec, its permissions and whether its menu has rows are fixed per +/// registered panel. The chrome shows no document data, so this version holds nothing of [`version`]. +pub(crate) fn dock_chrome(app: &PhotocraftApp) -> u64 { + let mut hasher = std::collections::hash_map::DefaultHasher::new(); + (crate::i18n::current().code(), super::toolbar::cells(app)).hash(&mut hasher); + hasher.finish() +} + /// The version of the status bar: the zoom readout of the active view, the status message and the item it shows, the /// render-path note, and the progress of the background redraw and of the job in view. pub(crate) fn status_bar(app: &PhotocraftApp) -> u64 {