The dock chrome and the title bar settle

Every frame ran each dock group's header, tab strip and grip and the title bar
with its menus, because PhotoCraft gave the dock no spec version and the title
slot no content version. The dock's chrome now settles under a version of what
it shows of the panels (their names in the UI language and the toolbar's grid),
and the title slot under the title, the language and whether the menus are in
the bar. A hover over the canvas runs neither.

Part of #15476, for #15493.
This commit is contained in:
aiongg committed 2026-11-20 03:10:44 +00:00
1 parent 359051359f
commit 778d88e799
5 files changed
+62 -1

No files matched your search

+2 -1
View File
@@ -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))
@@ -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<PhotocraftApp>>) -> 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");
}
}
+2
View File
@@ -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)]
@@ -175,6 +175,11 @@ impl DockPanels<String> 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<u64> {
Some(super::region_versions::dock_chrome(self.app))
}
fn content(&self, panel: &String) -> Option<u64> {
match panel.as_str() {
// The canvas shows state that changes without a command: the view, redraw progress, animation and job overlays.
@@ -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 {