Align rows without an info icon, indent the baked map list, and test template selection

Rows without an info icon keep an invisible one so their controls line
up with the others. The baked map list follows the section indent. New
tests pick a saved template, check that the OpenColorIO settings are
disabled with the hint, and render Project configuration in both color
management modes (ignored GPU snapshot test).
This commit is contained in:
vangel76 committed 2026-11-18 00:17:48 +01:00
1 parent 76e8f110ab
commit 2416736820
4 files changed
+63 -9

No files matched your search

+8 -5
View File
@@ -251,11 +251,14 @@ fn baked_maps(new_project: &mut NewProject, ui: &mut Ui) -> bool {
});
ui.add_space(4.0);
egui::Frame::new().fill(tokens.field).corner_radius(2.0).inner_margin(4.0).show(ui, |ui| {
egui::ScrollArea::vertical().id_salt("np_baked_map_list").max_height(FILE_LIST_HEIGHT).auto_shrink([false, false]).show(ui, |ui| {
for path in &new_project.baked_maps {
ui.add(egui::Label::new(file_name(path)).truncate()).on_hover_text(path.as_str());
}
ui.horizontal(|ui| {
ui.add_space(ROW_INDENT);
egui::Frame::new().fill(tokens.field).corner_radius(2.0).inner_margin(4.0).show(ui, |ui| {
egui::ScrollArea::vertical().id_salt("np_baked_map_list").max_height(FILE_LIST_HEIGHT).auto_shrink([false, false]).show(ui, |ui| {
for path in &new_project.baked_maps {
ui.add(egui::Label::new(file_name(path)).truncate()).on_hover_text(path.as_str());
}
});
});
});
ui.add_space(4.0);
+4 -4
View File
@@ -21,9 +21,6 @@ pub(crate) const FORM_HEIGHT: f32 = 760.0;
/// Indent of the rows below a section title.
pub(crate) const ROW_INDENT: f32 = 16.0;
/// Room kept for the info icon at the end of a row without one.
const INFO_SLOT: f32 = 16.0;
/// How a project manages colour. Only Legacy is implemented; OpenColorIO can be chosen to see its
/// settings, but they stay disabled and a project is always created and kept as Legacy.
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
@@ -79,7 +76,10 @@ pub(crate) fn check_row<R>(ui: &mut Ui, info: Option<&str>, control: impl FnOnce
fn info_slot(ui: &mut Ui, info: Option<&str>) {
match info {
Some(text) => info_icon(ui, text),
None => ui.add_space(INFO_SLOT),
// An invisible icon keeps the controls of rows without one in the same column
None => {
ui.add_visible(false, egui::Label::new(egui_phosphor::regular::INFO));
}
}
}
@@ -173,6 +173,12 @@ fn opencolorio_shows_its_settings_disabled_and_creates_legacy() {
assert!(h.query_by_label(label).is_some(), "{label} is shown");
}
assert!(h.query_by_label("ACEScg").is_some(), "the OpenColorIO working color space");
let ocio_config = h.get_by_value("ACES 2.0");
assert!(ocio_config.accesskit_node().is_disabled(), "the OpenColorIO settings are disabled");
let center = ocio_config.rect().center();
h.hover_at(center);
h.run_steps(30);
assert!(h.query_by_label(NOT_AVAILABLE).is_some(), "with the not-available hint");
let params = create_command(&texturecraft_ui_egui::state::NewProject { file: Some("a.obj".into()), ..h.state().ui.new_project.clone() }).unwrap();
assert!(params.get("colorManagement").is_none(), "nothing about color management reaches the command");
}
@@ -259,3 +265,22 @@ fn create_stays_on_screen_in_a_short_window() {
assert!(create.bottom() <= 600.0 && create.top() >= 0.0, "Create is visible without scrolling: {create:?}");
assert!(cancel.bottom() <= 600.0, "{cancel:?}");
}
#[test]
fn picking_a_template_sets_its_resolution_and_normal_map_format() {
let mut h = harness();
h.state_mut().session.templates.dir = None;
h.state_mut().run("textureSet.settings", serde_json::json!({"normalFormat": "directX"})).unwrap();
h.state_mut().run("project.template.save", serde_json::json!({"name": "Small DirectX"})).unwrap();
h.run_steps(2);
h.get_by_value(DEFAULT_TEMPLATE).click();
h.run_steps(3);
h.get_by_label("Small DirectX").click();
h.run_steps(3);
assert!(h.query_by_value("Small DirectX").is_some());
assert!(h.query_by_value("128 x 128").is_some(), "the template's resolution (the open project's 128 px)");
assert!(h.query_by_value("DirectX").is_some(), "the template's normal map format");
assert_eq!(h.state().ui.new_project.resolution, 128);
}
+26
View File
@@ -793,3 +793,29 @@ fn a_format_the_project_already_has_is_not_set_again() {
assert_eq!(project_normal_format(&h), NormalFormat::DirectX);
assert_eq!(h.state().session.history_labels().len(), steps, "no extra undo step");
}
#[test]
#[ignore = "offscreen GPU snapshots; set TC_UI_SNAPSHOTS to an output directory"]
fn project_config_snapshots() {
let output_dir = std::path::PathBuf::from(std::env::var_os("TC_UI_SNAPSHOTS").expect("set TC_UI_SNAPSHOTS"));
std::fs::create_dir_all(&output_dir).unwrap();
let dir = temp_dir("snapshots");
let file = dir.join("quad.obj");
std::fs::write(&file, QUAD).unwrap();
let mut session = Session::from_mesh_bytes("quad.obj", QUAD.as_bytes(), 128, "quad").unwrap();
session.doc.project.mesh_path = file.display().to_string();
let mut h = Harness::builder().with_size(egui::vec2(1600.0, 960.0)).with_pixels_per_point(1.0).wgpu().build_eframe(|cc| TextureCraftApp::new(cc, session));
h.run_steps(6);
open_window(&mut h);
h.run_steps(6);
h.render().unwrap().save(output_dir.join("project-config-legacy.png")).unwrap();
h.get_by_value("Legacy").scroll_to_me();
h.run_steps(3);
h.get_by_value("Legacy").click();
h.run_steps(3);
h.get_by_label("OpenColorIO").click();
h.run_steps(3);
h.get_by_label("Export color spaces").scroll_to_me();
h.run_steps(6);
h.render().unwrap().save(output_dir.join("project-config-ocio.png")).unwrap();
}