Merge main and retain path and rail tests

This commit is contained in:
chasse20 committed 2026-11-10 22:23:43 -05:00
commit 6a976004ee
11 files changed
+859 -59

No files matched your search

+55 -38
View File
@@ -133,9 +133,7 @@ fn split(axis: SplitAxis, size: SplitSize, first: Node<Panel>, second: Node<Pane
Node::Split { axis, size, first: Box::new(first), second: Box::new(second) }
}
/// The default: assets left of the viewport; texture set list, layers (tabbed with the texture
/// set settings) and properties down the right. Ratios match the 1600x960 window. Display,
/// shader, history and log are closed and open as floating windows.
/// The default: assets left of the viewport, then texture sets, layers (tabbed with texture set settings) and properties; ratios fit 1600x960
pub fn default_workspace() -> Workspace {
use Panel::*;
let column = split(
@@ -147,20 +145,13 @@ pub fn default_workspace() -> Workspace {
let root =
split(SplitAxis::Horizontal, SplitSize::Ratio(0.115), tabs(&[Assets]), split(SplitAxis::Horizontal, SplitSize::Ratio(0.78), tabs(&[Viewport]), column));
let mut workspace = Workspace::new(Layout { root: Some(root), floating: Vec::new() });
for panel in Panel::ALL {
if let Some(rect) = panel.float_rect() {
let location = Location {
floating: Some(rect),
anchor: None,
placement: Placement::Tab { before: None },
size: None,
stack: None,
sibling: Vec::new(),
group: None,
};
workspace.hidden.push((panel, location));
workspace.hidden.push((panel, floating_location(rect)));
}
}
for panel in [MeshMapSettings, CommonSettings, MeshMapBakers] {
workspace.hidden.push((
panel,
@@ -175,9 +166,15 @@ pub fn default_workspace() -> Workspace {
},
));
}
workspace
}
/// Where a closed panel reopens as its own floating window at `rect` (`[x, y, width, height]`)
fn floating_location(rect: [f32; 4]) -> Location<Panel> {
Location { floating: Some(rect), anchor: None, placement: Placement::Tab { before: None }, size: None, stack: None, sibling: Vec::new(), group: None }
}
/// craft-ui's checks plus the viewport's: a saved or hand-edited file cannot hide, float, group
/// or collapse it.
pub fn validate(workspace: &Workspace) -> Result<(), String> {
@@ -344,6 +341,13 @@ impl Dock {
}
}
/// Open the closed `panel` as a floating window at `rect` (`[x, y, width, height]`)
pub(crate) fn float_at(&mut self, panel: Panel, rect: [f32; 4]) {
self.workspace.hidden.retain(|(hidden_panel, _)| *hidden_panel != panel);
self.workspace.hidden.push((panel, floating_location(rect)));
self.focus(panel);
}
/// One change from the dock area's gestures. A change that is rejected leaves the layout as
/// it was.
fn apply(&mut self, action: Action<Panel>) {
@@ -415,57 +419,70 @@ pub fn show(app: &mut TextureCraftApp, ui: &mut Ui) {
if let Some(panel) = app.ui.dock.raise.take() {
area = area.raise_panel(panel);
}
let output = area.show_content(ui, &layout, &style, &mut Panels { app, tk: tokens });
let output = area.show_content(ui, &layout, &style, &mut Panels { app, tokens });
crate::rail_popup::hand_drag_to_dock(&context, area_id());
// After the dock, which records the viewport the popup reaches into, and before a changed layout returns early
crate::rail_popup::show(app, &context);
#[cfg(not(target_arch = "wasm32"))]
crate::menus::forwarded_shortcuts(app, &context, output.forwarded_events, output.forwarded_modifiers.unwrap_or_default());
if let Some(error) = &output.error {
log::warn!("docking: {error}");
}
// A layout changed by a panel takes priority over gestures from the old layout
if app.ui.dock.workspace.layout != layout {
craft_ui::docking::cancel_drag::<Panel>(&context, area_id());
return;
}
for action in output.actions {
app.ui.dock.apply(action);
}
}
/// The panels' contents, names and limits for the dock area.
/// The panels' contents, names and limits for the dock area
struct Panels<'a> {
app: &'a mut TextureCraftApp,
tk: Tokens,
tokens: Tokens,
}
/// Room between a panel's edges and its contents
const PANEL_BODY_MARGIN: Margin = Margin::symmetric(8, 4);
/// The body of every panel except the viewport, in the dock or on the rail
pub(crate) fn panel_body(app: &mut TextureCraftApp, ui: &mut Ui, panel: Panel) {
egui::Frame::new().inner_margin(PANEL_BODY_MARGIN).show(ui, |ui| match panel {
Panel::MeshMapSettings => crate::bake_mode::mesh_map_settings_panel(app, ui),
Panel::Assets => crate::shelf::body(app, ui),
Panel::CommonSettings => crate::bake_mode::common_settings_panel(app, ui),
Panel::MeshMapBakers => crate::bake_mode::mesh_map_bakers_panel(app, ui),
Panel::TextureSetList if app.ui.mode == crate::state::Mode::Baking => crate::bake_mode::texture_sets(app, ui),
Panel::TextureSetList => crate::dock::texture_set_list(app, ui),
Panel::Layers => crate::dock::layers(app, ui),
Panel::TextureSetSettings => crate::dock::texture_set_settings(app, ui),
Panel::Properties => crate::dock::properties(app, ui),
// Display and Shader Settings scroll here, as tall as their contents; History and Log scroll their own lists
Panel::Display => egui::ScrollArea::vertical().id_salt("dock-display").auto_shrink([false, true]).show(ui, |ui| crate::windows::display(app, ui)).inner,
Panel::Shader => egui::ScrollArea::vertical().id_salt("dock-shader").auto_shrink([false, true]).show(ui, |ui| crate::windows::shader(app, ui)).inner,
Panel::History => crate::windows::history(app, ui),
Panel::Log => crate::windows::log(app, ui),
Panel::Viewport => {}
});
}
impl DockContent<Panel> for Panels<'_> {
fn body(&mut self, ui: &mut Ui, panel: &Panel) {
let app = &mut *self.app;
if *panel == Panel::Viewport {
ui.painter().rect_filled(ui.max_rect(), 0.0, self.tk.viewport);
crate::rail_popup::remember_viewport(ui.ctx(), ui.max_rect());
ui.painter().rect_filled(ui.max_rect(), 0.0, self.tokens.viewport);
crate::viewport::central(app, ui);
return;
}
egui::Frame::new().inner_margin(Margin::symmetric(8, 4)).show(ui, |ui| match panel {
Panel::MeshMapSettings => crate::bake_mode::mesh_map_settings_panel(app, ui),
Panel::Assets => crate::shelf::body(app, ui),
Panel::CommonSettings => crate::bake_mode::common_settings_panel(app, ui),
Panel::MeshMapBakers => crate::bake_mode::mesh_map_bakers_panel(app, ui),
Panel::TextureSetList if app.ui.mode == crate::state::Mode::Baking => crate::bake_mode::texture_sets(app, ui),
Panel::TextureSetList => crate::dock::texture_set_list(app, ui),
Panel::Layers => crate::dock::layers(app, ui),
Panel::TextureSetSettings => crate::dock::texture_set_settings(app, ui),
Panel::Properties => crate::dock::properties(app, ui),
// The other panels scroll their own lists.
Panel::Display => {
egui::ScrollArea::vertical().id_salt("dock-display").auto_shrink([false, false]).show(ui, |ui| crate::windows::display(app, ui)).inner
}
Panel::Shader => {
egui::ScrollArea::vertical().id_salt("dock-shader").auto_shrink([false, false]).show(ui, |ui| crate::windows::shader(app, ui)).inner
}
Panel::History => crate::windows::history(app, ui),
Panel::Log => crate::windows::log(app, ui),
Panel::Viewport => {}
});
panel_body(app, ui, *panel);
}
fn logical_label(&self, panel: &Panel) -> String {
+1
View File
@@ -41,6 +41,7 @@ mod preview_request;
mod preview_worker;
pub mod profile;
pub mod properties_popup;
mod rail_popup;
pub mod render_mode;
mod resource_picker;
mod resource_picker_item;
+15 -7
View File
@@ -131,7 +131,7 @@ pub fn implemented(id: &str) -> bool {
is_ui(id) || texturecraft_engine::find(id).is_some()
}
/// Invoke a menu item (menus, shortcuts, palette, control channel `ui.menu.invoke`).
/// Invoke a menu item (menus, shortcuts, palette, control channel `ui.menu.invoke`)
pub fn invoke(app: &mut TextureCraftApp, ctx: &egui::Context, id: &str) {
if !enabled(app, id) {
return;
@@ -142,15 +142,21 @@ pub fn invoke(app: &mut TextureCraftApp, ctx: &egui::Context, id: &str) {
{
return;
}
if let Some(panel) = crate::docking::view_panel(id) {
app.ui.dock.toggle(panel);
if crate::rail_popup::is_rail_panel(panel) {
crate::rail_popup::toggle(app, panel);
} else {
app.ui.dock.toggle(panel);
}
return;
}
match id {
"ui.newProject" => app.ui.windows.new_project = true,
"ui.export" => app.ui.windows.export = true,
"ui.quit" => ctx.send_viewport_cmd(egui::ViewportCommand::Close),
"ui.projectConfig" => app.ui.dock.focus(crate::docking::Panel::Display),
"ui.projectConfig" => crate::rail_popup::open(app, crate::docking::Panel::Display),
"ui.settings" => app.ui.windows.settings = true,
"ui.mode.bake" => app.ui.mode = Mode::Baking,
"ui.mode.paint" => app.ui.mode = Mode::Painting,
@@ -316,14 +322,14 @@ pub fn shortcuts(app: &mut TextureCraftApp, ctx: &egui::Context) {
if crate::keymap::capturing(ctx) || (ctx.memory(|memory| memory.focused().is_some()) && ctx.egui_wants_keyboard_input()) {
return;
}
#[cfg(not(target_arch = "wasm32"))]
if crate::updates_ui::blocks_input(app) {
return;
}
// The dispatcher reads Copy, Cut and Paste as their chords. A pasted image is Ctrl+V here, and
// Shift+Delete and Shift+Insert (Cut and Paste on Windows) are Ctrl+X and Ctrl+V unless
// something is bound to them.
// The dispatcher reads clipboard events as shortcuts; a pasted image also means Ctrl+V
// Unless bound, Shift+Delete and Shift+Insert become Ctrl+X and Ctrl+V
ctx.input_mut(|input| {
let held = input.modifiers;
let aliases: Vec<_> = input
@@ -335,7 +341,7 @@ pub fn shortcuts(app: &mut TextureCraftApp, ctx: &egui::Context) {
input.events.extend(aliases);
});
// Escape closes an open popup first, before the Properties popup or the stroke
// Escape closes a dropdown before Properties, the rail popup, color picking or the stroke
let popup_open = egui::Popup::is_any_open(ctx);
let commands_to_invoke = ctx.input_mut(|input| {
@@ -359,6 +365,8 @@ pub fn shortcuts(app: &mut TextureCraftApp, ctx: &egui::Context) {
if !popup_open && app.properties_popup.is_some() && input.consume_key(Modifiers::NONE, Key::Escape) {
app.properties_popup = None;
} else if !popup_open && crate::rail_popup::is_visible(app) && input.consume_key(Modifiers::NONE, Key::Escape) {
app.ui.rail_panel = None;
} else if !popup_open && app.picking_id_color.is_some() && input.consume_key(Modifiers::NONE, Key::Escape) {
crate::id_color_pick::IdColorPick::end(app);
} else if app.ui.mode == Mode::Painting && !popup_open && input.consume_key(Modifiers::NONE, Key::Escape) {
+240
View File
@@ -0,0 +1,240 @@
//! The rail's panels open in a popup beside their rail icon, one at a time; dragging its title docks or floats the panel
use egui::{Id, Pos2, Rect, RichText, Sense, Ui};
use egui_phosphor::regular as ic;
use crate::TextureCraftApp;
use crate::docking::Panel;
use crate::i18n::tr;
use crate::state::Mode;
use crate::theme::Tokens;
use crate::widgets::icon_button;
/// The rail's panels, top to bottom, with their icons and Window ▸ Views ids
pub(crate) const RAIL_PANELS: [(Panel, &str, &str); 5] = [
(Panel::TextureSetSettings, ic::STACK, "ui.view.textureSetSettings"),
(Panel::Display, ic::MONITOR, "ui.view.display"),
(Panel::Shader, ic::SLIDERS_HORIZONTAL, "ui.view.shader"),
(Panel::History, ic::CLOCK_COUNTER_CLOCKWISE, "ui.view.history"),
(Panel::Log, ic::FILE_TEXT, "ui.view.log"),
];
/// The popup reaches this far into the viewport, so it covers the panels between the viewport and the rail
const VIEWPORT_OVERHANG: f32 = 48.0;
/// Narrowest the popup gets, when the viewport is not left of the rail's column
const POPUP_MIN_WIDTH: f32 = 320.0;
/// Settings panels' popups fit their contents up to this height, then scroll
const SETTINGS_MAX_HEIGHT: f32 = 640.0;
/// History and Log fill their popup, so it has one height
const LIST_HEIGHT: f32 = 400.0;
/// Gap between the popup and the rail
const RAIL_GAP: f32 = 4.0;
/// Size of the close button in the popup's title row
const TITLE_BUTTON_SIZE: f32 = 22.0;
/// The popup's area, whose rect egui remembers between frames
fn area_id() -> Id {
Id::unique("rail_popup")
}
/// Where the rail drew its strip on this frame
fn strip_id() -> Id {
Id::unique("rail_popup_strip")
}
/// Where the rail drew each panel's icon on this frame
fn icons_id() -> Id {
Id::unique("rail_popup_icons")
}
/// The panel whose popup title a drag left, and the title's rect, until the dock takes the drag over
fn pending_drag_id() -> Id {
Id::unique("rail_popup_pending_drag")
}
/// Where the dock drew the viewport on this frame
fn viewport_id() -> Id {
Id::unique("rail_popup_viewport")
}
/// Whether `panel` opens from the rail rather than in the dock
pub(crate) fn is_rail_panel(panel: Panel) -> bool {
RAIL_PANELS.iter().any(|(rail_panel, _, _)| *rail_panel == panel)
}
/// Whether the rail's open popup is visible in the current UI mode
pub(crate) fn is_visible(app: &TextureCraftApp) -> bool {
app.ui.rail_panel.is_some() && !app.ui.hide_ui && app.ui.mode != Mode::Baking
}
/// Record the rail's strip before its icons, so the popup can line up with them
pub(crate) fn begin_rail(ctx: &egui::Context, strip: Rect) {
ctx.data_mut(|data| {
data.insert_temp(strip_id(), strip);
data.insert_temp(icons_id(), Vec::<(Panel, Rect)>::new());
});
}
/// Record where the rail drew `panel`'s icon
pub(crate) fn remember_icon(ctx: &egui::Context, panel: Panel, icon: Rect) {
ctx.data_mut(|data| data.get_temp_mut_or_default::<Vec<(Panel, Rect)>>(icons_id()).push((panel, icon)));
}
/// Record where the dock drew the viewport, whose right edge the popup reaches past
pub(crate) fn remember_viewport(ctx: &egui::Context, viewport: Rect) {
ctx.data_mut(|data| data.insert_temp(viewport_id(), viewport));
}
/// A rail icon or its Window ▸ Views item: open `panel` in the popup in place of the one there, or close it
pub(crate) fn toggle(app: &mut TextureCraftApp, panel: Panel) {
// Bake mode has no rail, and a panel in the dock (which then has no rail icon) is toggled there
if app.ui.mode == Mode::Baking || app.ui.dock.is_open(panel) {
app.ui.dock.toggle(panel);
return;
}
app.ui.rail_panel = if app.ui.rail_panel == Some(panel) { None } else { Some(panel) };
}
/// Open `panel` from the rail: in its popup, or where it is in the dock (bake mode has no rail)
pub(crate) fn open(app: &mut TextureCraftApp, panel: Panel) {
if app.ui.mode == Mode::Baking || app.ui.dock.is_open(panel) {
app.ui.dock.focus(panel);
} else {
app.ui.rail_panel = Some(panel);
}
}
/// Hand a drag that left the popup's title to the dock, once the dock has drawn the panel it floated
pub(crate) fn hand_drag_to_dock(ctx: &egui::Context, dock_area: Id) {
let Some((panel, title)) = ctx.data(|data| data.get_temp::<(Panel, Rect)>(pending_drag_id())) else { return };
ctx.data_mut(|data| data.remove::<(Panel, Rect)>(pending_drag_id()));
if ctx.input(|input| input.pointer.primary_down()) {
craft_ui::docking::begin_drag(ctx, dock_area, panel, title);
}
}
/// A rail popup and its dismissing press cannot start a paint stroke or move a decal
pub(crate) fn blocks_paint_input(app: &TextureCraftApp, ctx: &egui::Context) -> bool {
let closing_id = area_id().with("closing");
let pointer_active = ctx.input(|input| input.pointer.any_down() || input.pointer.any_released());
if !pointer_active {
ctx.data_mut(|data| data.remove::<bool>(closing_id));
}
// Both views must ignore the release, which would otherwise start a single-dab stroke
let closing = ctx.data(|data| data.get_temp::<bool>(closing_id)).unwrap_or(false);
// A shortcut may open the panel during a stroke; let that existing stroke finish
!app.session.stroke_active() && (is_visible(app) || closing)
}
/// Draw the open popup beside its icon; a press outside it closes it, as for a menu (Escape does too, in `menus.rs`)
pub(crate) fn show(app: &mut TextureCraftApp, ctx: &egui::Context) {
// The dock has drawn both views, so a released dismissal must not suppress the next click
if !ctx.input(|input| input.pointer.any_down()) {
ctx.data_mut(|data| data.remove::<bool>(area_id().with("closing")));
}
let Some(panel) = app.ui.rail_panel else { return };
if app.ui.mode == Mode::Baking || app.ui.dock.is_open(panel) {
app.ui.rail_panel = None;
return;
}
let strip = ctx.data(|data| data.get_temp::<Rect>(strip_id())).unwrap_or(Rect::NOTHING);
let icons = ctx.data(|data| data.get_temp::<Vec<(Panel, Rect)>>(icons_id())).unwrap_or_default();
let Some(icon) = icons.iter().find(|(icon_panel, _)| *icon_panel == panel).map(|(_, rect)| *rect) else {
app.ui.rail_panel = None;
return;
};
let shown = ctx.memory(|memory| memory.area_rect(area_id()));
if closed_by_input(ctx, shown, strip) {
app.ui.rail_panel = None;
let held = ctx.input(|input| input.pointer.any_down());
ctx.data_mut(|data| data.insert_temp(area_id().with("closing"), held));
return;
}
let tokens = Tokens::get(ctx);
let frame = egui::Frame::popup(&ctx.global_style()).fill(tokens.panel).stroke(egui::Stroke::new(1.0, tokens.accent));
let (top_right, width) = placement(ctx, strip, icon);
let mut closed = false;
let mut dragged_from = None;
egui::Area::new(area_id()).order(egui::Order::Foreground).pivot(egui::Align2::RIGHT_TOP).fixed_pos(top_right).show(ctx, |ui| {
frame.show(ui, |ui| {
ui.set_width(width - frame.total_margin().sum().x);
let title_top = ui.cursor().top();
(closed, dragged_from) = title_row(ui, &tokens, panel);
ui.separator();
// Keep the title, frame and body on screen even when the window is shorter than the usual popup
let title_height = ui.cursor().top() - title_top;
let body_height = (ctx.content_rect().height() - frame.total_margin().sum().y - title_height).max(0.0);
body(app, ui, panel, body_height);
});
});
if closed {
app.ui.rail_panel = None;
} else if let Some(title) = dragged_from {
app.ui.rail_panel = None;
let rect = shown.unwrap_or(title);
app.ui.dock.float_at(panel, [rect.left(), rect.top(), rect.width(), rect.height()]);
ctx.data_mut(|data| data.insert_temp(pending_drag_id(), (panel, title)));
}
}
/// The popup's top right corner, beside the rail and level with its icon, and its width (egui keeps the area on screen)
fn placement(ctx: &egui::Context, strip: Rect, icon: Rect) -> (Pos2, f32) {
let right = strip.left() - RAIL_GAP;
let viewport = ctx.data(|data| data.get_temp::<Rect>(viewport_id()));
let width = viewport.map_or(POPUP_MIN_WIDTH, |viewport| right - (viewport.right() - VIEWPORT_OVERHANG)).max(POPUP_MIN_WIDTH);
(Pos2::new(right, icon.top()), width)
}
/// A press outside the popup and the rail, unless in one of the popup's own dropdowns
fn closed_by_input(ctx: &egui::Context, shown: Option<Rect>, strip: Rect) -> bool {
let pressed_at = ctx.input(|input| input.pointer.press_origin().filter(|_| input.pointer.any_pressed()));
// A press on the rail is left to its icons, which switch or close the popup themselves
let outside = pressed_at.is_some_and(|at| !strip.contains(at) && shown.is_some_and(|rect| !rect.contains(at)));
outside && !egui::Popup::is_any_open(ctx)
}
/// The panel's contents: History and Log at one height, the settings panels as tall as their contents up to a limit
fn body(app: &mut TextureCraftApp, ui: &mut Ui, panel: Panel, available_height: f32) {
// A child Ui, so the height limits start below the title row instead of moving the cursor back up to it
ui.scope(|ui| {
if matches!(panel, Panel::History | Panel::Log) {
ui.set_height(LIST_HEIGHT.min(available_height));
} else {
// The area's remembered size would otherwise cap the height
ui.set_max_height(SETTINGS_MAX_HEIGHT.min(available_height));
}
crate::docking::panel_body(app, ui, panel);
});
}
/// The panel's name, which drags like a tab, and a close button: whether it was clicked, and where a drag started
fn title_row(ui: &mut Ui, tokens: &Tokens, panel: Panel) -> (bool, Option<Rect>) {
let row = ui.horizontal(|ui| {
ui.label(RichText::new(tr(panel.name())).strong().color(tokens.text_strong));
ui.add_space((ui.available_width() - TITLE_BUTTON_SIZE).max(0.0));
icon_button(ui, ic::X, tr("Close"), false, TITLE_BUTTON_SIZE)
});
let (row, close) = (row.response.rect, row.inner);
let title = Rect::from_min_max(row.min, egui::pos2(close.rect.left(), row.bottom()));
let drag = ui.interact(title, ui.scope_id().with("rail_popup_title"), Sense::drag()).on_hover_cursor(egui::CursorIcon::Grab);
(close.clicked(), drag.drag_started().then_some(title))
}
+4
View File
@@ -257,6 +257,9 @@ pub struct UiState {
/// The docked, tabbed and floating panels around the viewport.
#[serde(default)]
pub dock: Dock,
/// The panel open against the icon rail, if any; not saved, so the app starts with the rail closed
#[serde(skip)]
pub rail_panel: Option<crate::docking::Panel>,
#[serde(default = "Dock::for_baking")]
pub(crate) inactive_mode_dock: Dock,
#[serde(default)]
@@ -353,6 +356,7 @@ impl Default for UiState {
layout: ViewLayout::Split,
split_ratio: default_split_ratio(),
dock: Dock::default(),
rail_panel: None,
inactive_mode_dock: Dock::for_baking(),
dock_is_baking: false,
bake_layout_version: BAKE_LAYOUT_VERSION,
+30 -13
View File
@@ -386,22 +386,39 @@ pub fn tool_shelf(app: &mut TextureCraftApp, ui: &mut egui::Ui) {
});
}
/// Width of the icon rail beside the dock
const RAIL_WIDTH: f32 = 38.0;
/// Size of the rail's icons
const RAIL_ICON_SIZE: f32 = 26.0;
/// Gap between the rail's icons
const RAIL_ICON_GAP: f32 = 4.0;
/// Padding inside the rail's card around its icons, as the tool shelf's
const RAIL_CARD_PADDING: egui::Margin = egui::Margin::symmetric(3, 6);
/// The icon rail: Export, then the rail panels that are not in the dock, each opening its popup
pub fn rail(app: &mut TextureCraftApp, ui: &mut egui::Ui) {
let tk = Tokens::get(ui.ctx());
egui::Panel::right("rail").resizable(false).exact_size(38.0).show_separator_line(false).frame(egui::Frame::NONE).show(ui, |ui| {
card(ui, &tk, egui::Margin { left: 0, right: GUTTER, top: GUTTER, bottom: GUTTER }, egui::Margin::symmetric(3, 6), |ui| {
ui.spacing_mut().item_spacing.y = 4.0;
if icon_button(ui, ic::EXPORT, &tip(&app.ui.keymap, tr("Export textures"), "ui.export"), app.ui.windows.export, 26.0).clicked() {
let tokens = Tokens::get(ui.ctx());
egui::Panel::right("rail").resizable(false).exact_size(RAIL_WIDTH).show_separator_line(false).frame(egui::Frame::NONE).show(ui, |ui| {
card(ui, &tokens, egui::Margin { left: 0, right: GUTTER, top: GUTTER, bottom: GUTTER }, RAIL_CARD_PADDING, |ui| {
ui.spacing_mut().item_spacing.y = RAIL_ICON_GAP;
crate::rail_popup::begin_rail(ui.ctx(), ui.max_rect());
if icon_button(ui, ic::EXPORT, &tip(&app.ui.keymap, tr("Export textures"), "ui.export"), app.ui.windows.export, RAIL_ICON_SIZE).clicked() {
app.ui.windows.export = !app.ui.windows.export;
}
for (panel, icon, id) in [
(Panel::TextureSetSettings, ic::STACK, "ui.view.textureSetSettings"),
(Panel::Display, ic::MONITOR, "ui.view.display"),
(Panel::Shader, ic::SLIDERS_HORIZONTAL, "ui.view.shader"),
(Panel::History, ic::CLOCK_COUNTER_CLOCKWISE, "ui.view.history"),
] {
if icon_button(ui, icon, &tip(&app.ui.keymap, tr(panel.name()), id), app.ui.dock.is_visible(panel), 26.0).clicked() {
app.ui.dock.toggle(panel);
// A panel in the dock, docked or floating, leaves the rail until it is closed there
for (panel, icon, id) in crate::rail_popup::RAIL_PANELS {
if app.ui.dock.is_open(panel) {
continue;
}
let response = icon_button(ui, icon, &tip(&app.ui.keymap, tr(panel.name()), id), app.ui.rail_panel == Some(panel), RAIL_ICON_SIZE);
crate::rail_popup::remember_icon(ui.ctx(), panel, response.rect);
if response.clicked() {
crate::rail_popup::toggle(app, panel);
}
}
});
+6 -1
View File
@@ -573,11 +573,15 @@ fn view_3d(app: &mut TextureCraftApp, ui: &mut Ui, rect: Rect, sync: &mut Pendin
}
}
// A dismissing click cannot paint or place a decal through the rail popup
let rail_popup = crate::rail_popup::blocks_paint_input(app, ui.ctx());
// Decal placement: a click moves the decal being placed there, unless it dismisses a waiting image drop's menu
let placing = app.placing_decal.filter(|_| app.ui.mode == crate::state::Mode::Painting);
if let Some(layer) = placing {
ui.ctx().set_cursor_icon(egui::CursorIcon::Crosshair);
if !alt
&& !rail_popup
&& !DecalDrop::blocks_input(ui.ctx())
&& response.clicked_by(PointerButton::Primary)
&& let Some(pointer) = response.interact_pointer_pos()
@@ -589,7 +593,7 @@ fn view_3d(app: &mut TextureCraftApp, ui: &mut Ui, rect: Rect, sync: &mut Pendin
}
crate::properties_popup::open_on_right_click(app, ui, &response, rect, s_held || v_held);
let popup = app.properties_popup.is_some();
let popup = app.properties_popup.is_some() || rail_popup;
// A pending ID color pick takes the next click instead of the brush
let picking_id_color = app.picking_id_color.is_some();
@@ -1679,6 +1683,7 @@ fn view_2d(app: &mut TextureCraftApp, ui: &mut Ui, rect: Rect, sync: &mut Pendin
// Painting in UV space
let painting = app.ui.mode == crate::state::Mode::Painting
&& app.properties_popup.is_none()
&& !crate::rail_popup::blocks_paint_input(app, ui.ctx())
&& !alt
&& !adjusting
&& !v_held
@@ -164,6 +164,31 @@ fn escape_cancels_the_pick_without_editing_colors() {
assert_eq!(harness.state().session.history_labels(), history);
}
#[test]
fn escape_cancels_id_picking_with_a_hidden_rail_popup() {
let (mut harness, effect) = app_with_color_selection(true);
harness.get_by_label(&pick_color_label()).click();
harness.run_steps(3);
let context = harness.ctx.clone();
texturecraft_ui_egui::menus::invoke(harness.state_mut(), &context, "ui.view.log");
harness.run_steps(3);
harness.get_by_role_and_label(egui::Role::Button, "Close");
harness.key_press(egui::Key::Tab);
harness.run_steps(3);
assert!(harness.state().ui.hide_ui);
assert!(harness.query_by_role_and_label(egui::Role::Button, "Close").is_none());
assert!(harness.state().picking_id_color.is_some());
let history = harness.state().session.history_labels();
harness.key_press(egui::Key::Escape);
harness.run_steps(3);
assert!(harness.state().picking_id_color.is_none(), "one Escape cancels ID picking despite the hidden popup");
assert_eq!(harness.state().session.view, ViewMode::Material);
assert_eq!(colors(&harness, effect), vec![FIRST, SECOND, THIRD]);
assert_eq!(harness.state().session.history_labels(), history);
}
#[test]
fn picking_from_the_popup_closes_it_before_the_viewport_click() {
use texturecraft_ui_egui::properties_popup::{self, PropertiesPopup};
+1
View File
@@ -26,6 +26,7 @@ mod path_list;
mod pen_pressure;
mod polygon_fill;
mod properties_popup;
mod rail;
mod shelf_drop;
mod shelf_hover_preview;
mod shift_lines_2d;
+444
View File
@@ -0,0 +1,444 @@
//! The rail opens its panels in a popup beside their icons, one at a time; dragging the popup's title docks or floats the panel
use egui::{Event, Modifiers, PointerButton, Pos2, Role};
use egui_kittest::Harness;
use egui_kittest::kittest::{NodeT, Queryable, by};
use texturecraft_ui_egui::TextureCraftApp;
use texturecraft_ui_egui::docking::Panel;
use texturecraft_ui_egui::state::ViewLayout;
const WINDOW_SIZE: egui::Vec2 = egui::vec2(1600.0, 960.0);
/// The rail is the last 38 points of the window; the popup's own buttons sit left of it
const RAIL_LEFT_EDGE: f32 = WINDOW_SIZE.x - 38.0;
// Small texture and bake sizes keep the sample session fast; the rail doesn't depend on them
const TEXTURE_RESOLUTION: u32 = 256;
const BAKE_RESOLUTION: u32 = 64;
/// Frames for the first layout and fonts to settle
const STARTUP_FRAMES: usize = 4;
/// Where a drag out of the popup ends: in the viewport, clear of every panel
const INTO_THE_VIEWPORT: egui::Vec2 = egui::vec2(-500.0, 100.0);
/// Moves a drag takes, so the dock sees it pass its threshold and move
const DRAG_STEPS: usize = 6;
/// Frames between a drag's events: the press must land before the moves, and each move be seen
const FRAMES_PER_DRAG_EVENT: usize = 2;
/// Frames for a click to reach the rail, the popup and the dock
const SETTLE_FRAMES: usize = 3;
// A setting only Shader Settings shows, and one only Display Settings shows
const SHADER_SETTING: &str = "Index of refraction";
const DISPLAY_SETTING: &str = "Environment opacity";
fn app() -> Harness<'static, TextureCraftApp> {
app_of_size(WINDOW_SIZE)
}
fn app_of_size(size: egui::Vec2) -> Harness<'static, TextureCraftApp> {
let session = texturecraft_engine::sample_session(TEXTURE_RESOLUTION, BAKE_RESOLUTION).unwrap();
let mut harness = Harness::builder().with_size(size).build_eframe(|cc| TextureCraftApp::new(cc, session));
// The labels below are English; a first run would speak the system's language
harness.state_mut().ui.prefs.language = "en".into();
harness.run_steps(STARTUP_FRAMES);
harness
}
/// The rail icon of the panel named `name`, if the rail shows one
fn rail_icon<'h>(harness: &'h Harness<'_, TextureCraftApp>, name: &str) -> Option<egui_kittest::Node<'h>> {
// A rail icon's label is its tooltip, which adds the shortcut when the panel has one
let is_panel = |label: &str| label == name || label.starts_with(&format!("{name} ("));
harness
.get_all_by_role(Role::Button)
.find(|button| button.rect().min.x >= RAIL_LEFT_EDGE && button.accesskit_node().label().is_some_and(|label| is_panel(&label)))
}
fn click_rail(harness: &mut Harness<'_, TextureCraftApp>, name: &str) {
rail_icon(harness, name).expect("the panel's icon on the rail").click();
harness.run_steps(SETTLE_FRAMES);
}
fn click_at(harness: &mut Harness<'_, TextureCraftApp>, position: Pos2) {
harness.hover_at(position);
harness.event(Event::PointerButton { pos: position, button: PointerButton::Primary, pressed: true, modifiers: Modifiers::NONE });
harness.run_steps(1);
harness.event(Event::PointerButton { pos: position, button: PointerButton::Primary, pressed: false, modifiers: Modifiers::NONE });
harness.run_steps(SETTLE_FRAMES);
}
/// Drag with the primary button from `from` to `to` in a few moves
fn drag(harness: &mut Harness<'_, TextureCraftApp>, from: Pos2, to: Pos2) {
harness.hover_at(from);
harness.run_steps(FRAMES_PER_DRAG_EVENT);
harness.event(Event::PointerButton { pos: from, button: PointerButton::Primary, pressed: true, modifiers: Modifiers::NONE });
harness.run_steps(FRAMES_PER_DRAG_EVENT);
for step in 1..=DRAG_STEPS {
harness.hover_at(from + (to - from) * (step as f32 / DRAG_STEPS as f32));
harness.run_steps(FRAMES_PER_DRAG_EVENT);
}
harness.event(Event::PointerButton { pos: to, button: PointerButton::Primary, pressed: false, modifiers: Modifiers::NONE });
harness.run_steps(SETTLE_FRAMES);
}
/// The popup's Close button, left of the rail (the window's own Close sits above the rail)
fn popup_close_button(harness: &Harness<'_, TextureCraftApp>) -> Option<egui::Rect> {
harness
.query_all(by().role(Role::Button))
.find(|button| button.rect().max.x < RAIL_LEFT_EDGE && button.accesskit_node().label().as_deref() == Some("Close"))
.map(|button| button.rect())
}
/// The title of the popup open on the panel named `name`: that name, level with the popup's Close button
fn open_popup_title(harness: &Harness<'_, TextureCraftApp>, name: &str) -> Option<egui::Rect> {
let close = popup_close_button(harness)?;
harness
.get_all_by_label(name)
.map(|node| node.rect())
.find(|title| title.right() < close.left() && (close.top()..=close.bottom()).contains(&title.center().y))
}
fn popup_title(harness: &Harness<'_, TextureCraftApp>, name: &str) -> egui::Rect {
open_popup_title(harness, name).expect("the popup's title")
}
fn popup_shows(harness: &Harness<'_, TextureCraftApp>, name: &str) -> bool {
open_popup_title(harness, name).is_some()
}
fn popup_closed(harness: &Harness<'_, TextureCraftApp>) -> bool {
popup_close_button(harness).is_none()
}
#[test]
fn the_rail_shows_one_panel_at_a_time() {
let mut harness = app();
click_rail(&mut harness, "Shader Settings");
assert!(popup_shows(&harness, "Shader Settings"));
assert!(harness.query_by_label(SHADER_SETTING).is_some());
click_rail(&mut harness, "Display Settings");
assert!(popup_shows(&harness, "Display Settings"));
assert!(harness.query_by_label(SHADER_SETTING).is_none(), "opening Display Settings closed Shader Settings");
assert!(harness.query_by_label(DISPLAY_SETTING).is_some());
assert!(!harness.state().ui.dock.is_open(Panel::Shader), "the rail's panels are not dock windows");
click_rail(&mut harness, "Display Settings");
assert!(popup_closed(&harness), "its own icon closes it");
}
#[test]
fn the_popup_lines_up_with_its_icon() {
let mut harness = app();
click_rail(&mut harness, "History");
let icon = rail_icon(&harness, "History").expect("the History icon").rect();
let title = popup_title(&harness, "History");
assert!(title.top() >= icon.top() && title.top() <= icon.bottom(), "the title {title:?} is not level with the icon {icon:?}");
}
#[test]
fn the_close_button_a_press_outside_and_escape_close_it() {
let mut harness = app();
click_rail(&mut harness, "Display Settings");
harness.get_by_role_and_label(Role::Button, "Close").click();
harness.run_steps(SETTLE_FRAMES);
assert!(popup_closed(&harness), "Close");
click_rail(&mut harness, "Log");
harness.get_by_label("Assets").click();
harness.run_steps(SETTLE_FRAMES);
assert!(popup_closed(&harness), "a press outside");
click_rail(&mut harness, "Log");
harness.key_press(egui::Key::Escape);
harness.run_steps(SETTLE_FRAMES);
assert!(popup_closed(&harness), "Escape");
}
#[test]
fn dragging_the_title_out_floats_the_panel_and_frees_the_rail() {
let mut harness = app();
click_rail(&mut harness, "History");
let title = popup_title(&harness, "History").center();
drag(&mut harness, title, title + INTO_THE_VIEWPORT);
assert!(popup_closed(&harness));
assert!(harness.state().ui.dock.is_visible(Panel::History), "History floats on its own");
assert!(rail_icon(&harness, "History").is_none(), "a panel in the dock has no rail icon");
click_rail(&mut harness, "Shader Settings");
assert!(popup_shows(&harness, "Shader Settings"));
assert!(harness.state().ui.dock.is_visible(Panel::History), "History stays open beside the rail's panel");
}
#[test]
fn dragging_the_title_onto_a_tab_strip_docks_the_panel_there() {
let mut harness = app();
click_rail(&mut harness, "Log");
let title = popup_title(&harness, "Log").center();
let properties_tab = harness.get_by_label("Properties - Paint").rect().center();
drag(&mut harness, title, properties_tab);
let layout = &harness.state().ui.dock.workspace().layout;
assert!(layout.contains(&Panel::Log) && !layout.floating.iter().any(|window| window.contains(&Panel::Log)), "the Log is docked");
}
#[test]
fn a_panel_closed_in_the_dock_returns_to_the_rail() {
let mut harness = app();
assert!(rail_icon(&harness, "Texture Set Settings").is_none(), "Texture Set Settings starts in the dock, beside Layers");
harness.state_mut().ui.dock.close(Panel::TextureSetSettings);
harness.run_steps(SETTLE_FRAMES);
click_rail(&mut harness, "Texture Set Settings");
assert!(popup_shows(&harness, "Texture Set Settings"));
}
#[test]
fn window_views_open_the_rail_panels_popup() {
let mut harness = app();
let ctx = harness.ctx.clone();
texturecraft_ui_egui::menus::invoke(harness.state_mut(), &ctx, "ui.view.shader");
harness.run_steps(SETTLE_FRAMES);
assert!(popup_shows(&harness, "Shader Settings"));
assert!(!harness.state().ui.dock.is_open(Panel::Shader));
// Project configuration opens Display Settings, in its popup too
texturecraft_ui_egui::menus::invoke(harness.state_mut(), &ctx, "ui.projectConfig");
harness.run_steps(SETTLE_FRAMES);
assert!(popup_shows(&harness, "Display Settings"));
}
#[test]
fn a_popup_that_would_run_past_the_bottom_moves_up() {
// Too short for Display Settings below its icon
const SHORT_WINDOW: egui::Vec2 = egui::vec2(1600.0, 600.0);
let mut harness = app_of_size(SHORT_WINDOW);
click_rail(&mut harness, "Display Settings");
let icon = rail_icon(&harness, "Display Settings").expect("the Display Settings icon").rect();
let title = popup_title(&harness, "Display Settings");
assert!(title.top() < icon.top(), "the popup at {title:?} did not move up from the icon at {icon:?}");
}
#[test]
fn display_settings_remain_reachable_in_a_short_window() {
let mut harness = app_of_size(egui::vec2(1600.0, 600.0));
click_rail(&mut harness, "Display Settings");
let last_setting = "Temporal anti-aliasing (refines the 3D view while it is still)";
harness.get_by_label(last_setting).scroll_to_me();
harness.run_steps(SETTLE_FRAMES);
let setting = harness.get_by_label(last_setting).rect();
assert!(harness.ctx.content_rect().contains_rect(setting), "the last setting must be reachable: {setting:?}");
}
#[test]
fn history_actions_remain_reachable_in_a_short_window() {
let mut harness = app_of_size(egui::vec2(1600.0, 400.0));
click_rail(&mut harness, "History");
for label in ["Undo", "Redo"] {
let button = harness
.get_all_by_role(Role::Button)
.find(|button| button.accesskit_node().label().is_some_and(|text| text.ends_with(label)))
.expect("the History action")
.rect();
assert!(harness.ctx.content_rect().contains_rect(button), "{label} must be reachable: {button:?}");
}
}
#[test]
fn opening_the_window_menu_closes_the_rail_popup() {
let mut harness = app();
click_rail(&mut harness, "Shader Settings");
harness.get_by_role_and_label(Role::Button, "Window").click();
harness.run_steps(SETTLE_FRAMES);
assert!(popup_closed(&harness));
}
#[test]
fn escape_closes_a_dropdown_before_its_rail_popup() {
let mut harness = app();
click_rail(&mut harness, "Display Settings");
let environment_row = harness.get_by_label("Environment map").rect();
harness
.get_all_by_role(Role::ComboBox)
.find(|combo| (combo.rect().center().y - environment_row.center().y).abs() < 1.0)
.expect("the environment dropdown")
.click();
harness.run_steps(SETTLE_FRAMES);
assert!(egui::Popup::is_any_open(&harness.ctx));
harness.key_press(egui::Key::Escape);
harness.run_steps(SETTLE_FRAMES);
assert!(!egui::Popup::is_any_open(&harness.ctx));
assert!(popup_shows(&harness, "Display Settings"));
harness.key_press(egui::Key::Escape);
harness.run_steps(SETTLE_FRAMES);
assert!(popup_closed(&harness));
}
#[test]
fn dismissing_a_rail_popup_does_not_paint_the_viewport() {
for layout in [ViewLayout::Only3D, ViewLayout::Only2D] {
let mut harness = app();
texturecraft_engine::execute(&mut harness.state_mut().session, "layer.add.paint", &serde_json::Value::Null).unwrap();
harness.state_mut().ui.layout = layout;
harness.run_steps(SETTLE_FRAMES);
click_rail(&mut harness, "Log");
let center = if layout == ViewLayout::Only2D { egui::pos2(700.0, 420.0) } else { harness.state().viewport_rect.center() };
let history = harness.state().session.history_labels().len();
click_at(&mut harness, center);
assert!(popup_closed(&harness));
assert_eq!(harness.state().session.history_labels().len(), history, "dismissing the popup must not paint in {layout:?}");
click_at(&mut harness, center);
assert_eq!(harness.state().session.history_labels().len(), history + 1, "the next click paints in {layout:?}");
click_rail(&mut harness, "Log");
drag(&mut harness, center, center + egui::vec2(40.0, 0.0));
assert!(popup_closed(&harness));
assert!(!harness.state().session.stroke_active());
assert_eq!(harness.state().session.history_labels().len(), history + 1, "a dismissing drag must not paint in {layout:?}");
}
}
#[test]
fn opening_a_rail_popup_during_a_stroke_still_finishes_the_stroke() {
let mut harness = app();
texturecraft_engine::execute(&mut harness.state_mut().session, "layer.add.paint", &serde_json::Value::Null).unwrap();
harness.state_mut().ui.layout = ViewLayout::Only3D;
harness.run_steps(SETTLE_FRAMES);
let center = harness.state().viewport_rect.center();
let history = harness.state().session.history_labels().len();
harness.drag_at(center);
harness.run_steps(FRAMES_PER_DRAG_EVENT);
harness.hover_at(center + egui::vec2(20.0, 0.0));
harness.run_steps(FRAMES_PER_DRAG_EVENT);
assert!(harness.state().session.stroke_active());
let context = harness.ctx.clone();
texturecraft_ui_egui::menus::invoke(harness.state_mut(), &context, "ui.view.log");
harness.run_steps(SETTLE_FRAMES);
harness.drop_at(center + egui::vec2(30.0, 0.0));
harness.run_steps(SETTLE_FRAMES);
assert!(popup_shows(&harness, "Log"));
assert!(!harness.state().session.stroke_active());
assert_eq!(harness.state().session.history_labels().len(), history + 1);
}
#[test]
fn escape_cancels_a_stroke_with_a_hidden_rail_popup() {
let mut harness = app();
texturecraft_engine::execute(&mut harness.state_mut().session, "layer.add.paint", &serde_json::Value::Null).unwrap();
harness.state_mut().ui.layout = ViewLayout::Only3D;
harness.run_steps(SETTLE_FRAMES);
click_rail(&mut harness, "Log");
harness.key_press(egui::Key::Tab);
harness.run_steps(SETTLE_FRAMES);
assert!(harness.state().ui.hide_ui);
assert!(popup_closed(&harness));
let center = harness.state().viewport_rect.center();
let history = harness.state().session.history_labels();
harness.drag_at(center);
harness.run_steps(FRAMES_PER_DRAG_EVENT);
harness.hover_at(center + egui::vec2(20.0, 0.0));
harness.run_steps(FRAMES_PER_DRAG_EVENT);
assert!(harness.state().session.stroke_active());
harness.key_press(egui::Key::Escape);
harness.run_steps(SETTLE_FRAMES);
assert!(!harness.state().session.stroke_active(), "one Escape cancels the stroke despite the hidden popup");
harness.drop_at(center + egui::vec2(30.0, 0.0));
harness.run_steps(SETTLE_FRAMES);
assert_eq!(harness.state().session.history_labels(), history, "the canceled stroke must not be committed on release");
}
#[test]
fn escape_cancels_a_path_with_a_hidden_rail_popup() {
for stored_path in [false, true] {
let mut harness = app();
texturecraft_engine::execute(&mut harness.state_mut().session, "layer.add.paint", &serde_json::Value::Null).unwrap();
let path = texturecraft_engine::execute(
&mut harness.state_mut().session,
"tool.path",
&serde_json::json!({"uvPoints": [[0.2, 0.5], [0.8, 0.5]], "commit": stored_path}),
)
.unwrap();
if stored_path {
texturecraft_engine::execute(
&mut harness.state_mut().session,
"path.edit",
&serde_json::json!({"effect": path["committed"]["effect"], "index": 0}),
)
.unwrap();
}
harness.run_steps(SETTLE_FRAMES);
click_rail(&mut harness, "Log");
harness.key_press(egui::Key::Tab);
harness.run_steps(SETTLE_FRAMES);
assert!(harness.state().ui.hide_ui);
assert!(popup_closed(&harness));
assert_eq!(harness.state().session.tool.path.points.len(), 2);
// Drafts and committed paths both have a live preview target while edited
let (effect, index) = harness.state().session.tool.path.editing.unwrap();
let history = harness.state().session.history_labels();
harness.key_press(egui::Key::Escape);
harness.run_steps(SETTLE_FRAMES);
assert!(harness.state().session.tool.path.points.is_empty(), "one Escape clears the path despite the hidden popup");
assert!(harness.state().session.tool.path.editing.is_none());
assert_eq!(harness.state().session.history_labels(), history);
assert_eq!(
harness.state().session.paths(effect).and_then(|paths| paths.get(index)).is_some(),
stored_path,
"Escape removes a draft but keeps a committed path"
);
harness.key_press(egui::Key::Tab);
harness.run_steps(SETTLE_FRAMES);
assert!(popup_shows(&harness, "Log"), "showing the UI restores its remembered popup");
}
}
+38
View File
@@ -392,3 +392,41 @@ fn path_tool_snapshots() {
harness.state_mut().session.commit_path(texturecraft_engine::geom::glam::Vec2::splat(400.0)).unwrap();
save(&mut harness, &output_dir, "path-stored-2d");
}
#[test]
#[ignore]
fn rail_window_snapshots() {
let Some(output_dir) = std::env::var_os("TC_UI_SNAPSHOTS").map(PathBuf::from) else {
eprintln!("set TC_UI_SNAPSHOTS=<dir> to write the pictures");
return;
};
std::fs::create_dir_all(&output_dir).unwrap();
let session = texturecraft_engine::sample_session(256, 64).unwrap();
let mut harness =
Harness::builder().with_size(egui::vec2(1600.0, 960.0)).with_pixels_per_point(1.0).wgpu().build_eframe(|cc| TextureCraftApp::new(cc, session));
harness.state_mut().ui.prefs.language = "en".into();
harness.state_mut().ui.dock.close(Panel::TextureSetSettings);
let context = harness.ctx.clone();
for (command, name) in [
("ui.view.textureSetSettings", "rail-texture-set-settings"),
("ui.view.display", "rail-display"),
("ui.view.shader", "rail-shader"),
("ui.view.history", "rail-history"),
("ui.view.log", "rail-log"),
] {
texturecraft_ui_egui::menus::invoke(harness.state_mut(), &context, command);
save(&mut harness, &output_dir, name);
}
harness.set_size(egui::vec2(1600.0, 600.0));
texturecraft_ui_egui::menus::invoke(harness.state_mut(), &context, "ui.view.display");
harness.run_steps(6);
harness.get_by_label("Temporal anti-aliasing (refines the 3D view while it is still)").scroll_to_me();
save(&mut harness, &output_dir, "rail-display-short");
harness.set_size(egui::vec2(1600.0, 400.0));
texturecraft_ui_egui::menus::invoke(harness.state_mut(), &context, "ui.view.history");
save(&mut harness, &output_dir, "rail-history-short");
}