perf(ui): the dock keys its columns by the panels' versions

The dock shows each column as a memoized view keyed by the versions of the
panels it shows (craft-libs DockPanels::content): every panel returns its
region version, the toolbar a version of its rail (the slots and tool in
the preferences, the remembered group tools, the Edit Toolbar drawer and
the footer). The canvas has no version yet, so the docked tree it sits in
runs every pass while the columns beside it replay.

The chrome settle trials count the dock's inner views (tab rows, column
bars, panel bodies, the toolbar footer) as run or replayed only where their
column runs; at rest they replay inside the column's view, so the trials
assert that nothing ran and the column views replayed.

Needs the craft-libs pin moved to a commit with the dock's column views.
This commit is contained in:
aiongg committed 2026-11-27 01:00:11 +00:00
1 parent 1975f8f1f7
commit 9de8092976
3 files changed
+40 -13

No files matched your search

+22 -13
View File
@@ -58,8 +58,8 @@ fn tab_strip_runs(h: &H) -> Vec<(&'static str, u32)> {
last_pass_runs(&h.ctx).into_iter().filter(|(ty, _)| ty.contains("TabStrip<'_, craft_ui_panels::docking::PanelKey>")).collect()
}
/// A hover over the canvas replays the dock's tab rows and column bars and the menu bar (memoized views) and runs no
/// panel tab strip.
/// A hover over the canvas replays the dock's tab rows and column bars (in the columns' views, which replay whole) and
/// the menu bar (memoized views) and runs no panel tab strip.
#[test]
fn a_hover_over_the_canvas_replays_the_dock_chrome_and_the_menu_bar() {
let mut h = harness();
@@ -70,9 +70,12 @@ fn a_hover_over_the_canvas_replays_the_dock_chrome_and_the_menu_bar() {
h.run_steps(1);
// The menu bar sits in the title bar's own view: while that replays, the menu bar replays with it.
let title_replayed = views(&h, "TitleSlot<", MemoRun::Replayed) == 1;
let columns = (views_ran(&h, "area::ColumnView<"), views(&h, "area::ColumnView<", MemoRun::Replayed));
assert!(columns.0 == 0 && columns.1 >= 1, "hover step {step}: the dock's columns replay: {columns:?}");
let views = chrome_views(&h);
for kind in ["TabRow", "dock_column::bar::BarProps", "menu::bar::BarProps"] {
let shown = views.iter().any(|(name, _)| name.contains(kind)) || (kind == "menu::bar::BarProps" && title_replayed);
let replayed_with = if kind == "menu::bar::BarProps" { title_replayed } else { columns.1 >= 1 };
let shown = views.iter().any(|(name, _)| name.contains(kind)) || replayed_with;
assert!(shown, "hover step {step}: the chrome shows a {kind} view: {views:?}");
}
let ran: Vec<_> = views.iter().filter(|(_, run)| *run != MemoRun::Replayed).collect();
@@ -81,8 +84,9 @@ fn a_hover_over_the_canvas_replays_the_dock_chrome_and_the_menu_bar() {
}
}
/// A hover over the canvas replays the title bar, the options bar, the status bar (its own view) and every panel body: the
/// panels read the modifiers, not the pointer frame (storytold/craft-libs#2812), so a pointer move runs none of them.
/// A hover over the canvas replays the title bar, the options bar, the status bar (its own view) and every panel body
/// (in the columns' views, which replay whole): the panels read the modifiers, not the pointer frame
/// (storytold/craft-libs#2812), so a pointer move runs none of them.
#[test]
fn a_hover_over_the_canvas_replays_the_bars_and_the_panel_bodies() {
let mut h = harness();
@@ -93,13 +97,17 @@ fn a_hover_over_the_canvas_replays_the_bars_and_the_panel_bodies() {
for slot in ["TitleSlot<", "OptionsSlot<", "status_bar::StatusProps<"] {
assert_eq!((views_ran(&h, slot), views(&h, slot, MemoRun::Replayed)), (0, 1), "hover step {step}: the {slot} view replays");
}
let bodies = (views_ran(&h, "region_versions::PanelBody<"), views(&h, "region_versions::PanelBody<", MemoRun::Replayed));
assert!(bodies.0 == 0 && bodies.1 >= 2, "hover step {step}: every panel body replays: {bodies:?}");
let columns = (views_ran(&h, "area::ColumnView<"), views(&h, "area::ColumnView<", MemoRun::Replayed));
assert!(
views_ran(&h, "region_versions::PanelBody<") == 0 && columns == (0, columns.1) && columns.1 >= 2,
"hover step {step}: every panel body replays with its column: {columns:?}"
);
}
}
/// A hover over the canvas replays the toolbar's footer (the colour chips, Quick Mask and Screen Mode): the rail replays
/// its tool buttons but calls its footer every pass, so before it was a view of its own it ran on every frame (#15493).
/// A hover over the canvas replays the toolbar's footer (the colour chips, Quick Mask and Screen Mode) with the toolbar's
/// column: the rail replays its tool buttons but calls its footer every pass, so before it was a view of its own it ran
/// on every frame (#15493).
#[test]
fn a_hover_over_the_canvas_replays_the_toolbar_footer() {
let mut h = harness();
@@ -107,8 +115,8 @@ fn a_hover_over_the_canvas_replays_the_toolbar_footer() {
for step in 1..=3 {
h.event(Event::PointerMoved(at + vec2(step as f32, 0.0)));
h.run_steps(1);
let footer = (views_ran(&h, "toolbar::FooterProps<"), views(&h, "toolbar::FooterProps<", MemoRun::Replayed));
assert_eq!(footer, (0, 1), "hover step {step}: the toolbar footer replays");
let columns = (views_ran(&h, "area::ColumnView<"), views(&h, "area::ColumnView<", MemoRun::Replayed));
assert!(views_ran(&h, "toolbar::FooterProps<") == 0 && columns.0 == 0 && columns.1 >= 1, "hover step {step}: the toolbar footer replays: {columns:?}");
}
}
@@ -120,8 +128,9 @@ fn a_zoom_runs_only_the_panels_that_show_the_view() {
let ctx = h.ctx.clone();
crate::menus::invoke(h.state_mut(), &ctx, "view.zoomIn", json!({})).unwrap();
h.run_steps(1);
let bodies = (views_ran(&h, "region_versions::PanelBody<"), views(&h, "region_versions::PanelBody<", MemoRun::Replayed));
assert!(bodies.0 <= 1 && bodies.1 >= 2, "only the Navigator's body may run, the others replay: {bodies:?}");
let columns = views(&h, "area::ColumnView<", MemoRun::Replayed);
let bodies = views_ran(&h, "region_versions::PanelBody<");
assert!(bodies <= 1 && columns >= 1, "only the Navigator's body may run, the other columns replay: {bodies} ran, {columns} columns replayed");
}
/// The footer runs again when a colour it shows changes without a command (the Color panel's sliders, a Color Picker
@@ -231,6 +231,17 @@ impl DockPanels<String> for Panels<'_> {
}
}
/// The version of what the dock shows for a panel, which keys its column: the canvas shows state that changes
/// without a command (the view, redraw progress, animation and job overlays) and has none, so the docked tree it
/// sits in runs every pass while the columns beside it replay.
fn content(&self, panel: &String) -> Option<u64> {
match panel.as_str() {
CANVAS => None,
TOOLBAR => Some(super::region_versions::toolbar(self.app)),
id => Some(super::region_versions::panel(self.app, id)),
}
}
/// The canvas group is the document area: it draws its own tabs and documents in the group's rect. The toolbar's
/// group is its rail, which takes the group's full rect and measures its height at a width.
fn group_view(&mut self, panels: &[String], _: usize, ui: &mut egui::Ui, at: GroupAt, _: &mut BodyCx<'_>) -> Option<f32> {
@@ -91,6 +91,13 @@ pub(crate) fn toolbar_footer(app: &PhotocraftApp) -> u64 {
version(app, (colours(app), quick_mask, app.ui.view.screen_mode))
}
/// The version of the toolbar's group view, which the dock keys the toolbar's column by: the rail's slots (in the
/// preferences, which [`version`] holds with the tool), the tools its groups remember, whether the Edit Toolbar drawer
/// is open, and what the footer shows ([`toolbar_footer`]).
pub(crate) fn toolbar(app: &PhotocraftApp) -> u64 {
version(app, (toolbar_footer(app), &app.ui.group_tools, app.ui.toolbar_drawer))
}
/// 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, whether the menus are in the bar (not in the macOS menu bar) and whether the bar takes the
/// menu keys (F10, Alt, Alt+letter), which a dialog or the shortcut recorder holds back: a dialog closed with Escape