From c055a425122129bfd99349c16bfc95438de7ef95 Mon Sep 17 00:00:00 2001 From: Mex <44814932+MMexicann@users.noreply.github.com> Date: Sat, 21 Nov 2026 18:54:53 +0100 Subject: [PATCH 01/83] fix(camera): reject malformed targets before updating the view Updated camera_set function to use vec3 for target validation and added a test to ensure invalid targets do not change the camera. --- crates/engine/src/view_cmds.rs | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/crates/engine/src/view_cmds.rs b/crates/engine/src/view_cmds.rs index e8161c8e..80d32cb0 100644 --- a/crates/engine/src/view_cmds.rs +++ b/crates/engine/src/view_cmds.rs @@ -3,9 +3,8 @@ use serde_json::{Value, json}; use texturecraft_core::project::ENVIRONMENTS; use texturecraft_core::{BakedMap, Channel, EnvAlignment, ShadowMode, ToneMapping}; -use texturecraft_geom::glam::Vec3; -use crate::commands::{CommandSpec, always, bad, boolp, can_redo, can_undo, color_param, f32p, strp, u64p}; +use crate::commands::{CommandSpec, always, bad, boolp, can_redo, can_undo, color_param, f32p, strp, u64p, vec3}; use crate::frame_target::FrameTarget; use crate::session::ViewMode; use crate::{Result, Session, cmd}; @@ -231,6 +230,10 @@ pub(crate) fn camera_json(s: &Session) -> Value { } fn camera_set(s: &mut Session, p: &Value) -> Result { + let target = vec3(p, "target"); + if target.is_none() && p.get("target").is_some_and(|value| !value.is_null()) { + return Err(bad("camera.set", "`target` must be an array of three finite numbers")); + } let c = &mut s.camera; match strp(p, "rotation") { Some("free") => c.set_free(true), @@ -250,11 +253,8 @@ fn camera_set(s: &mut Session, p: &Value) -> Result { if let Some(v) = f32p(p, "fov") { c.fov = v.clamp(5.0, 150.0); } - if let Some(t) = p.get("target").and_then(Value::as_array) { - let v: Vec = t.iter().filter_map(Value::as_f64).map(|x| x as f32).collect(); - if v.len() == 3 && v.iter().all(|x| x.is_finite()) { - c.target = Vec3::new(v[0], v[1], v[2]); - } + if let Some(target) = target { + c.target = target; } if let Some(o) = boolp(p, "ortho") { c.ortho = o; @@ -375,6 +375,19 @@ mod tests { Session::new_project("t", texturecraft_geom::primitives::sphere(1.0, 16, 8), "builtin:sphere", None, 128).unwrap() } + #[test] + fn camera_set_rejects_an_invalid_target_without_changing_the_camera() { + let mut s = sphere_session(); + let before = execute(&mut s, "camera.set", &json!({"target": [1.0, 2.0, 3.0], "fov": 40.0})).unwrap(); + assert_eq!(before["target"], json!([1.0, 2.0, 3.0])); + let revision = s.revision; + for target in [json!([10, "typo", 20, 30]), json!([1, 2]), json!([1, 2, 1e300]), json!({"x": 1})] { + assert!(execute(&mut s, "camera.set", &json!({"target": target, "fov": 90.0})).is_err(), "{target}"); + assert_eq!(execute(&mut s, "camera.get", &json!({})).unwrap(), before); + assert_eq!(s.revision, revision); + } + } + fn pressed(s: &mut Session, command: &str) -> ViewMode { execute(s, command, &json!({})).unwrap(); s.view From fa23ac2a27d0d509007695c77888bf5473c0dcc6 Mon Sep 17 00:00:00 2001 From: vangel76 Date: Sat, 21 Nov 2026 20:30:49 +0100 Subject: [PATCH 02/83] Allow rebuilding mesh UVs when creating a project --- crates/core/src/project.rs | 13 ++++++-- crates/engine/src/file_cmds.rs | 31 +++++++++++++------ crates/formats/src/mesh_import/abc/tests.rs | 6 ++-- crates/formats/src/mesh_import/mod.rs | 16 +++++++--- crates/formats/src/project_file/mod.rs | 12 +++++-- crates/formats/src/project_file/tests.rs | 2 +- crates/ui-egui/src/new_project_advanced.rs | 21 ++++++++++--- crates/ui-egui/src/project_form.rs | 1 + crates/ui-egui/src/state.rs | 4 +++ crates/ui-egui/tests/it/new_project_window.rs | 18 ++++++++--- docs/control-protocol.md | 4 +++ 11 files changed, 95 insertions(+), 33 deletions(-) diff --git a/crates/core/src/project.rs b/crates/core/src/project.rs index ce14606b..6981e2d0 100644 --- a/crates/core/src/project.rs +++ b/crates/core/src/project.rs @@ -9,12 +9,15 @@ use crate::{BakeSettings, BakedMap, Channel, ChannelFormat, CoreError, Effect, L pub use crate::env_alignment::EnvAlignment; pub use crate::shadow_mode::ShadowMode; -/// Project file format. 3: bent normal maps are in tangent space (older files hold world-space ones). -pub const FORMAT_VERSION: u32 = 3; +/// Latest project file format that TextureCraft can read. +pub const FORMAT_VERSION: u32 = REBUILT_MESH_UVS_VERSION; /// First format whose baked bent normal maps are in tangent space pub const TANGENT_BENT_NORMAL_VERSION: u32 = 3; +/// First format that can reopen a project using rebuilt mesh UVs. +pub const REBUILT_MESH_UVS_VERSION: u32 = 4; + /// Maximum group nesting (also bounds recursion over hostile project files) pub const MAX_DEPTH: usize = 16; @@ -417,6 +420,9 @@ pub struct Project { /// it, so parts the file leaves unnamed get the same name (from it) as on import. #[serde(default, skip_serializing_if = "String::is_empty")] pub mesh_file: String, + /// Rebuild the UVs again when reading the mesh stored in the project. + #[serde(default, skip_serializing_if = "std::ops::Not::not")] + pub mesh_rebuild_uvs: bool, /// Where the mesh file was imported from (the project's "3D mesh path"). Reimport mesh reads /// it again from there, so edits made to the file since are picked up. Empty when unknown /// (built-in meshes, web imports, projects saved before it was kept). @@ -435,10 +441,11 @@ pub struct Project { impl Project { pub fn new(name: impl Into, mesh: impl Into) -> Project { Project { - format_version: FORMAT_VERSION, + format_version: TANGENT_BENT_NORMAL_VERSION, name: name.into(), mesh: mesh.into(), mesh_file: String::new(), + mesh_rebuild_uvs: false, mesh_path: String::new(), normal_format: NormalFormat::OpenGl, texture_sets: Vec::new(), diff --git a/crates/engine/src/file_cmds.rs b/crates/engine/src/file_cmds.rs index f493093b..d75723f6 100644 --- a/crates/engine/src/file_cmds.rs +++ b/crates/engine/src/file_cmds.rs @@ -23,7 +23,7 @@ pub fn specs() -> Vec { "New project from a mesh file", [], None, - "{mesh: path to .glb/.gltf/.fbx/.dae/.usd/.usda/.usdc/.usdz/.abc/.obj/.ply/.stl, resolution?: 2048, name?, uvTiles?: bool (UDIM; default: when the UVs leave tile 1001), template?: project template name, importCameras?: bool (default true: keep the cameras stored in the file)}", + "{mesh: path to .glb/.gltf/.fbx/.dae/.usd/.usda/.usdc/.usdz/.abc/.obj/.ply/.stl, resolution?: 2048, name?, uvTiles?: bool (UDIM; default: when the UVs leave tile 1001), rebuildUvs?: bool (default false: auto-unwrap where needed), template?: project template name, importCameras?: bool (default true: keep the cameras stored in the file)}", always, new_from_mesh ), @@ -101,7 +101,7 @@ fn leaf_of(name: &str) -> String { /// with, so its unnamed parts keep their names (and the geometry masks that use them). fn read_stored_mesh(project: &Project, ext: &str, bytes: &[u8]) -> Result { let stem = std::path::Path::new(&project.mesh_file).file_stem().and_then(|s| s.to_str()).filter(|s| !s.is_empty()).unwrap_or("mesh"); - texturecraft_formats::import_mesh_bytes(&format!("{stem}.{ext}"), bytes).map_err(fe) + texturecraft_formats::mesh_import::import_mesh_bytes_with_uvs(&format!("{stem}.{ext}"), bytes, project.mesh_rebuild_uvs).map_err(fe) } impl Session { @@ -160,11 +160,16 @@ impl Session { /// [`Session::from_mesh_bytes`] with a UV tile mode (see [`Session::new_project_tiled`]). pub fn from_mesh_bytes_tiled(file_name: &str, bytes: &[u8], resolution: u32, name: &str, uv_tiles: Option) -> Result { - Self::from_mesh_source(file_name, Cow::Borrowed(bytes), resolution, name, uv_tiles) + Self::from_mesh_bytes_with_uvs(file_name, bytes, resolution, name, uv_tiles, false) } - fn from_mesh_source(file_name: &str, bytes: Cow<'_, [u8]>, resolution: u32, name: &str, uv_tiles: Option) -> Result { - let imported = texturecraft_formats::import_mesh_bytes(file_name, &bytes).map_err(fe)?; + /// Create a project with an explicit choice to rebuild the imported mesh's UVs. + pub fn from_mesh_bytes_with_uvs(file_name: &str, bytes: &[u8], resolution: u32, name: &str, uv_tiles: Option, rebuild_uvs: bool) -> Result { + Self::from_mesh_source(file_name, Cow::Borrowed(bytes), resolution, name, uv_tiles, rebuild_uvs) + } + + fn from_mesh_source(file_name: &str, bytes: Cow<'_, [u8]>, resolution: u32, name: &str, uv_tiles: Option, rebuild_uvs: bool) -> Result { + let imported = texturecraft_formats::mesh_import::import_mesh_bytes_with_uvs(file_name, &bytes, rebuild_uvs).map_err(fe)?; let extension = ext_of(file_name); let mut session = Session::new_project_tiled(name, imported.mesh, &format!("mesh.{extension}"), None, resolution, uv_tiles)?; @@ -173,6 +178,7 @@ impl Session { source.shrink_to_fit(); session.mesh_source = Some((extension, source)); session.doc.project.mesh_file = leaf_of(file_name); + session.doc.project.mesh_rebuild_uvs = rebuild_uvs; session.doc.project.cameras = imported.cameras; session.log.warnings("Importer", imported.report.warnings); @@ -500,7 +506,7 @@ mod native { #[cfg(not(target_arch = "wasm32"))] pub use native::{absolute, open_path, read_mesh}; -/// `file.new {mesh, name?, resolution?, uvTiles?, template?, importCameras?}`: a new project from the +/// `file.new {mesh, name?, resolution?, uvTiles?, rebuildUvs?, template?, importCameras?}`: a new project from the /// mesh file `mesh`, remembering its path for Reimport mesh. #[cfg(not(target_arch = "wasm32"))] fn new_from_mesh(session: &mut Session, params: &Value) -> Result { @@ -511,9 +517,11 @@ fn new_from_mesh(session: &mut Session, params: &Value) -> Result { let resolution = u64p(params, "resolution").or(template.as_ref().map(|template| u64::from(template.resolution))).unwrap_or(DEFAULT_RESOLUTION_PX); let name = strp(params, "name").map(str::to_string).unwrap_or_else(|| stem_of(path)); let uv_tiles = crate::commands::boolp(params, "uvTiles"); + let rebuild_uvs = crate::commands::boolp(params, "rebuildUvs").unwrap_or(false); let mesh_file = native::read_mesh("file.new", path)?; - let mut next = Session::from_mesh_source(&mesh_file.name, Cow::Owned(mesh_file.bytes), u32::try_from(resolution).unwrap_or(0), &name, uv_tiles)?; + let mut next = + Session::from_mesh_source(&mesh_file.name, Cow::Owned(mesh_file.bytes), u32::try_from(resolution).unwrap_or(0), &name, uv_tiles, rebuild_uvs)?; next.doc.project.mesh_path = native::absolute(path); next.log.warnings("Importer", mesh_file.warnings); if crate::commands::boolp(params, "importCameras") == Some(false) { @@ -576,7 +584,7 @@ fn reimport(s: &mut Session, p: &Value) -> Result { fn change_mesh(s: &mut Session, p: &Value) -> Result { let path = native::path_param(p, "path", "file.changeMesh")?; let file = native::read_mesh("file.changeMesh", path)?; - let reply = s.reimport_mesh(Some(file), crate::commands::boolp(p, "preserveStrokes").unwrap_or(true))?; + let reply = s.replace_mesh(Some(file), crate::commands::boolp(p, "preserveStrokes").unwrap_or(true), false)?; // Only after the swap succeeded: Reimport mesh and Save keep following the new file. s.doc.project.mesh_path = native::absolute(path); Ok(reply) @@ -594,9 +602,13 @@ impl Session { /// With `preserve_strokes`, painted pixels follow the surface where the UVs changed. Replies /// like `file.reimportMesh`: `{preserved?}`. pub fn reimport_mesh(&mut self, file: Option, preserve_strokes: bool) -> Result { + self.replace_mesh(file, preserve_strokes, self.doc.project.mesh_rebuild_uvs) + } + + fn replace_mesh(&mut self, file: Option, preserve_strokes: bool, rebuild_uvs: bool) -> Result { let (mesh, source, warnings, mesh_file) = match file { Some(f) => { - let m = texturecraft_formats::import_mesh_bytes(&f.name, &f.bytes).map_err(fe)?.mesh; + let m = texturecraft_formats::mesh_import::import_mesh_bytes_with_uvs(&f.name, &f.bytes, rebuild_uvs).map_err(fe)?.mesh; (m, Some((ext_of(&f.name), f.bytes)), f.warnings, leaf_of(&f.name)) } None => match &self.mesh_source { @@ -611,6 +623,7 @@ impl Session { if let Some((ext, _)) = &source { doc.project.mesh = format!("mesh.{ext}"); doc.project.mesh_file = mesh_file; + doc.project.mesh_rebuild_uvs = rebuild_uvs; } let mut next = Session::new(doc, mesh, source)?; next.log.warnings("Importer", warnings); diff --git a/crates/formats/src/mesh_import/abc/tests.rs b/crates/formats/src/mesh_import/abc/tests.rs index f94f497d..9eadd181 100644 --- a/crates/formats/src/mesh_import/abc/tests.rs +++ b/crates/formats/src/mesh_import/abc/tests.rs @@ -217,10 +217,10 @@ fn imports_polymesh_through_xforms_with_face_sets_uvs_and_normals() { assert!((p(t[1]) - p(t[0])).cross(p(t[2]) - p(t[0])).z > 0.0); } } - let mesh = finish(raw).unwrap().mesh; + let mesh = finish(raw, false).unwrap().mesh; assert_eq!(mesh.materials.len(), 3); // The strip alone keeps its indexed face-varying UVs: u = x / 2 in the file's own space. - let strip = finish(read(&sample_file(false)).unwrap()).unwrap(); + let strip = finish(read(&sample_file(false)).unwrap(), false).unwrap(); assert!(!strip.report.uvs_generated); for (p, uv) in strip.mesh.positions.iter().zip(&strip.mesh.uvs) { let local = (*p - Vec3::new(1.0, 2.0, 3.0)) / 2.0; @@ -332,7 +332,7 @@ fn truncated_and_corrupted_files_never_panic() { b[i] = (rng >> 32) as u8; } if let Ok(raw) = read(&b) { - let _ = finish(raw); + let _ = finish(raw, false); } } } diff --git a/crates/formats/src/mesh_import/mod.rs b/crates/formats/src/mesh_import/mod.rs index 315e4337..06ab5d93 100644 --- a/crates/formats/src/mesh_import/mod.rs +++ b/crates/formats/src/mesh_import/mod.rs @@ -108,7 +108,7 @@ pub struct MeshReport { pub triangles: usize, pub vertices: usize, pub materials: usize, - /// The file had no UVs; they were generated by the automatic unwrap. + /// The UVs were generated by the automatic unwrap. pub uvs_generated: bool, /// Triangles with a UV outside 0..1. pub uv_out_of_range: usize, @@ -295,7 +295,12 @@ fn extension(file_name: &str) -> String { /// self-contained (see [`self_contained_mesh`]); OBJ material libraries are not read (usemtl /// names are). pub fn import_mesh_bytes(file_name: &str, bytes: &[u8]) -> Result { - finish(read(file_name, bytes)?) + import_mesh_bytes_with_uvs(file_name, bytes, false) +} + +/// Import mesh bytes, optionally rebuilding the UV layout even when the mesh already has UVs. +pub fn import_mesh_bytes_with_uvs(file_name: &str, bytes: &[u8], rebuild_uvs: bool) -> Result { + finish(read(file_name, bytes)?, rebuild_uvs) } /// Import a mesh file with the files it references next to it ([`read_mesh_file`]). @@ -491,12 +496,12 @@ fn geometry(raw: RawMesh) -> Result<(Mesh, Vec, Option>)> { } /// Complete a raw mesh: submeshes, normals, UVs, tangents, validation and the report. -pub(crate) fn finish(mut raw: RawMesh) -> Result { +pub(crate) fn finish(mut raw: RawMesh, rebuild_uvs: bool) -> Result { let mut raw_cameras = std::mem::take(&mut raw.cameras); raw_cameras.truncate(MAX_CAMERAS); let (mut mesh, mut warnings, uvs) = geometry(raw)?; let uvs_generated = match uvs { - Some(uv) if uv.len() == mesh.positions.len() => { + Some(uv) if !rebuild_uvs && uv.len() == mesh.positions.len() => { if uv.iter().any(|v| !v.is_finite()) { warnings.push("non-finite UVs were replaced with 0".into()); } @@ -506,7 +511,8 @@ pub(crate) fn finish(mut raw: RawMesh) -> Result { } _ => { let charts = auto_unwrap(&mut mesh, UNWRAP_PADDING, UNWRAP_RESOLUTION)?; - warnings.push(format!("the mesh has no UVs; generated an automatic unwrap with {charts} charts")); + let reason = if rebuild_uvs { "rebuild UVs was selected" } else { "the mesh has no UVs" }; + warnings.push(format!("{reason}; generated an automatic unwrap with {charts} charts")); true } }; diff --git a/crates/formats/src/project_file/mod.rs b/crates/formats/src/project_file/mod.rs index c5bf3bdb..b86f8ec1 100644 --- a/crates/formats/src/project_file/mod.rs +++ b/crates/formats/src/project_file/mod.rs @@ -18,12 +18,13 @@ //! count of 0, followed by `width × height × components` f32 LE. Pixels of a UV-tiled texture //! set cover its whole atlas (`resolution` per tile, see `TileGrid`). -use std::borrow::Borrow; +use std::borrow::{Borrow, Cow}; use std::collections::{BTreeMap, HashSet}; use std::io::{Cursor, Read, Seek, Write}; use std::sync::Arc; use texturecraft_compose::{BakedMaps, PixelStore}; +use texturecraft_core::project::REBUILT_MESH_UVS_VERSION; use texturecraft_core::{BakePaintTarget, BakedMap, Channel, FORMAT_VERSION, LayerId, Project, TANGENT_BENT_NORMAL_VERSION}; use texturecraft_texel::{TILE_AREA, TileImage}; use zip::write::SimpleFileOptions; @@ -190,7 +191,12 @@ fn write_baked(w: &mut dyn Write, res: u32, h: u32, comps: usize, data: &[f32]) fn entries(pf: &ProjectFile>>) -> Result>> { let deflate = SimpleFileOptions::default().compression_method(CompressionMethod::Deflated).large_file(true); let stored = SimpleFileOptions::default().compression_method(CompressionMethod::Stored); - let json = serde_json::to_vec_pretty(&pf.project).map_err(|e| FormatError::Invalid(e.to_string()))?; + let mut project = Cow::Borrowed(&pf.project); + // An older reader would load the authored UVs and put paint in the wrong places. + if project.mesh_rebuild_uvs && project.format_version < REBUILT_MESH_UVS_VERSION { + project.to_mut().format_version = REBUILT_MESH_UVS_VERSION; + } + let json = serde_json::to_vec_pretty(project.as_ref()).map_err(|e| FormatError::Invalid(e.to_string()))?; let mut out = vec![Entry { name: "project.json".into(), options: deflate, weight: json.len() as u64, body: Box::new(move |w| w.write_all(&json)) }]; if let Some((ext, bytes)) = &pf.mesh { out.push(Entry { @@ -505,7 +511,7 @@ fn load_archive(mut zip: ZipArchive, mut budget: LoadBudget) if version < TANGENT_BENT_NORMAL_VERSION { drop_world_space_bent_normals(&mut pf); } - pf.project.format_version = FORMAT_VERSION; + pf.project.format_version = version.max(TANGENT_BENT_NORMAL_VERSION); if recovered { pf.warnings.push( diff --git a/crates/formats/src/project_file/tests.rs b/crates/formats/src/project_file/tests.rs index 4364f39e..a4cc5a34 100644 --- a/crates/formats/src/project_file/tests.rs +++ b/crates/formats/src/project_file/tests.rs @@ -104,7 +104,7 @@ fn legacy_bakes_load_as_is_without_layout_conversion() { sample.pf.baked.insert(0, BakedMaps { resolution: 32, maps: [(BakedMap::AmbientOcclusion, Arc::new(pixels))].into() }); let loaded = load_project_bytes(&save_project_bytes(&sample.pf).unwrap()).unwrap(); - assert_eq!(loaded.project.format_version, FORMAT_VERSION); + assert_eq!(loaded.project.format_version, TANGENT_BENT_NORMAL_VERSION); assert_eq!(loaded.baked, sample.pf.baked, "old bake pixels are accepted without preserving their former layout"); assert_eq!(loaded.bake_paint, sample.pf.bake_paint, "correction paint remains in the working layout"); let reopened = load_project_bytes(&save_project_bytes(&loaded).unwrap()).unwrap(); diff --git a/crates/ui-egui/src/new_project_advanced.rs b/crates/ui-egui/src/new_project_advanced.rs index 2d079b67..690cb15e 100644 --- a/crates/ui-egui/src/new_project_advanced.rs +++ b/crates/ui-egui/src/new_project_advanced.rs @@ -13,8 +13,8 @@ use texturecraft_engine::template_cmds::template_label; use crate::TextureCraftApp; use crate::i18n::{tr, trf}; use crate::project_form::{ - FIELD_WIDTH_POINTS, ROW_INDENT_POINTS, auto_unwrap_row, check_row, collapsible, color_management, note, physical_size, row, sub_title, tangent_space_row, - unavailable, uv_tile_radios, + FIELD_WIDTH_POINTS, ROW_INDENT_POINTS, check_row, collapsible, color_management, note, physical_size, row, sub_title, tangent_space_row, unavailable, + uv_tile_radios, }; use crate::state::{Mode, NewProject}; use crate::theme::{Tokens, caption}; @@ -136,6 +136,7 @@ pub fn create_command(new_project: &NewProject) -> Option { "uvTiles": new_project.uv_tiles == Some(true), "template": new_project.template, "importCameras": new_project.import_cameras, + "rebuildUvs": new_project.rebuild_uvs, })) } @@ -154,7 +155,14 @@ fn create_project(app: &mut TextureCraftApp) -> bool { let stem = std::path::Path::new(name).file_stem().and_then(|stem| stem.to_str()).unwrap_or("Untitled").to_string(); let template = app.session.template(&new_project.template); - match texturecraft_engine::Session::from_mesh_bytes_tiled(name, bytes, new_project.resolution, &stem, Some(new_project.uv_tiles == Some(true))) { + match texturecraft_engine::Session::from_mesh_bytes_with_uvs( + name, + bytes, + new_project.resolution, + &stem, + Some(new_project.uv_tiles == Some(true)), + new_project.rebuild_uvs, + ) { Ok(mut next) => { if !new_project.import_cameras { next.doc.project.cameras.clear(); @@ -249,7 +257,12 @@ fn advanced_settings(app: &mut TextureCraftApp, ui: &mut Ui) { ui.add_space(4.0); sub_title(ui, tr("Import settings"), None); check_row(ui, Some(tr("Keep the cameras stored in the mesh file")), |ui| ui.checkbox(&mut new_project.import_cameras, tr("Import cameras")), |_| {}); - auto_unwrap_row(ui); + check_row( + ui, + Some(tr("Generate a fresh UV layout even when the mesh already has UVs. Meshes without UVs are always unwrapped.")), + |ui| ui.checkbox(&mut new_project.rebuild_uvs, tr("Rebuild mesh UVs")), + |_| {}, + ); ui.add_space(4.0); collapsible(ui, "np_import_baked_maps", tr("Import baked maps"), true, None, |ui| { diff --git a/crates/ui-egui/src/project_form.rs b/crates/ui-egui/src/project_form.rs index 171282e3..d340a344 100644 --- a/crates/ui-egui/src/project_form.rs +++ b/crates/ui-egui/src/project_form.rs @@ -158,6 +158,7 @@ pub(crate) fn uv_tile_radios(ui: &mut Ui, enabled: bool, disabled_hint: &str) { /// Import settings ▸ Auto-unwrap and its options. Meshes without UVs are always unwrapped, so the /// box is ticked; turning it off and the options are not available yet. +#[cfg(not(target_arch = "wasm32"))] pub(crate) fn auto_unwrap_row(ui: &mut Ui) { check_row( ui, diff --git a/crates/ui-egui/src/state.rs b/crates/ui-egui/src/state.rs index c5dffbc9..05fd1b33 100644 --- a/crates/ui-egui/src/state.rs +++ b/crates/ui-egui/src/state.rs @@ -289,6 +289,9 @@ pub struct NewProject { /// Import settings > Import cameras: keep the cameras stored in the mesh file #[serde(default = "import_cameras_default")] pub import_cameras: bool, + /// Import settings > Rebuild mesh UVs. + #[serde(default)] + pub rebuild_uvs: bool, /// Color management as chosen in the window (the project is always created as Legacy) #[serde(skip)] pub color_management: crate::project_form::ColorManagement, @@ -326,6 +329,7 @@ impl Default for NewProject { template: default_template(), normal_format: None, import_cameras: true, + rebuild_uvs: false, color_management: crate::project_form::ColorManagement::Legacy, baked_maps: Vec::new(), } diff --git a/crates/ui-egui/tests/it/new_project_window.rs b/crates/ui-egui/tests/it/new_project_window.rs index 7d95b501..aafec044 100644 --- a/crates/ui-egui/tests/it/new_project_window.rs +++ b/crates/ui-egui/tests/it/new_project_window.rs @@ -119,7 +119,7 @@ fn the_sections_follow_the_project_setup_order() { "Use a separate texture set for each tile", "Import settings", "Import cameras", - "Auto-unwrap", + "Rebuild mesh UVs", "Import baked maps", "Import mesh normal maps and baked maps for all materials.", "Normal map filename: _normal", @@ -151,7 +151,7 @@ fn the_defaults_match_the_reference() { assert!(ticked(&h, Role::RadioButton, "Keep UV tiles together per material")); assert!(disabled(&h, Role::RadioButton, "Keep UV tiles together per material"), "greyed while UV tiles are off"); assert!(ticked(&h, Role::CheckBox, "Import cameras") && !disabled(&h, Role::CheckBox, "Import cameras")); - assert!(ticked(&h, Role::CheckBox, "Auto-unwrap")); + assert!(!ticked(&h, Role::CheckBox, "Rebuild mesh UVs") && !disabled(&h, Role::CheckBox, "Rebuild mesh UVs")); assert!(ticked(&h, Role::RadioButton, "Use the mesh file’s unit scale")); assert!(!ticked(&h, Role::CheckBox, "Scale material fills in real-world units")); } @@ -186,8 +186,6 @@ fn settings_not_available_yet_are_disabled_with_a_hint() { let unavailable = [ (Role::CheckBox, "Compute tangent space per fragment"), (Role::RadioButton, "Use a separate texture set for each tile"), - (Role::CheckBox, "Auto-unwrap"), - (Role::Button, "Auto-unwrap options"), (Role::RadioButton, "Custom unit scale"), (Role::CheckBox, "Scale material fills in real-world units"), ]; @@ -326,7 +324,7 @@ fn the_supported_settings_reach_the_create_command() { #[test] fn ticking_uv_tiles_creates_a_uv_tile_project() { - for (tick, expected) in [(false, Vec::::new()), (true, vec![1002])] { + for (tick, rebuild_uvs, expected) in [(false, false, vec![]), (true, false, vec![1002]), (true, true, vec![1001])] { let mut h = harness(); let dir = TempDir::new("new-project-udim"); h.state_mut().ui.new_project.file = Some(mesh_file(&dir, TILE_1002_QUAD)); @@ -337,6 +335,10 @@ fn ticking_uv_tiles_creates_a_uv_tile_project() { h.run_steps(3); assert!(!disabled(&h, Role::RadioButton, "Keep UV tiles together per material")); } + if rebuild_uvs { + h.get_by_role_and_label(Role::CheckBox, "Rebuild mesh UVs").click(); + h.run_steps(3); + } h.get_by_role_and_label(Role::CheckBox, "Import cameras").click(); h.run_steps(2); h.get_by_role_and_label(Role::Button, "Create").click(); @@ -347,6 +349,12 @@ fn ticking_uv_tiles_creates_a_uv_tile_project() { assert_eq!(app.session.doc.project.name, "tiles"); assert_eq!(app.session.doc.project.texture_sets[0].uv_tiles, expected, "UV tiles ticked: {tick}"); assert_eq!(app.session.doc.project.texture_sets[0].resolution, 128); + if rebuild_uvs { + let bytes = texturecraft_engine::formats::save_project_bytes(&app.session.project_file()).unwrap(); + let reopened = texturecraft_engine::Session::from_project_bytes(&bytes).unwrap(); + assert_eq!(reopened.source_mesh().uvs, app.session.source_mesh().uvs); + assert_eq!(reopened.doc.project.format_version, texturecraft_engine::core::project::REBUILT_MESH_UVS_VERSION); + } } } diff --git a/docs/control-protocol.md b/docs/control-protocol.md index bd11cb2d..979544a1 100644 --- a/docs/control-protocol.md +++ b/docs/control-protocol.md @@ -295,6 +295,10 @@ takes a font family, not a path: it reads only the system's font folders. `file.close` leaves no project open: `session.inspect` then reports `projectOpen: false`, `command.list` marks every command but the project-independent ones as not enabled: the ones that open or create a project (`file.open`, `file.new`, `project.new`, `project.sample`), `project.inspect`, `viewport.frame`, `project.templates`, the `export.preset*` commands (`export.presets`, `export.preset.get`, `export.preset.save`, `export.preset.remove`) and the library and preset listings (`brush.preset.list`, `alpha.list`, `filter.list`, `material.list`, `mask.smart.list`, `text.fonts`), each still subject to its own enabled check. The rest are refused with "no project is open" until a project is opened or created. A `texturecraft --control` run starts with the sample project (an empty material ball with `--empty`); the app without `--control` starts with no project. +The desktop control channel accepts `rebuildUvs: true` on `file.new` to generate a new UV layout. +The default keeps a complete authored layout and unwraps meshes that need UVs. The project +remembers the rebuild choice for reopening and reimporting its mesh. + | Tool | Params | Notes | |---|---|---| | `session_inspect` | | The whole session as JSON | From 03169492d7dc5cb44522ad407e96e556eed9dd2a Mon Sep 17 00:00:00 2001 From: vangel76 Date: Sun, 22 Nov 2026 13:10:17 +0100 Subject: [PATCH 03/83] Toggle layer effects from their thumbnails --- crates/ui-egui/src/dock.rs | 177 ++++++++++++----------- crates/ui-egui/src/layer_panel.rs | 26 ++-- crates/ui-egui/tests/it/effect_rows.rs | 5 + crates/ui-egui/tests/it/layers_panel.rs | 121 +++++++++++----- crates/ui-egui/tests/it/rename_anchor.rs | 20 ++- 5 files changed, 220 insertions(+), 129 deletions(-) diff --git a/crates/ui-egui/src/dock.rs b/crates/ui-egui/src/dock.rs index 7f8cebfe..9136689f 100644 --- a/crates/ui-egui/src/dock.rs +++ b/crates/ui-egui/src/dock.rs @@ -209,6 +209,12 @@ pub(crate) fn layers(app: &mut TextureCraftApp, ui: &mut Ui) { let stack: Vec = app.session.doc.project.texture_sets.get(ts).map(|t| t.stack.iter().rev().copied().collect()).unwrap_or_default(); let now = ui.input(|i| i.time); app.layer_panel.begin(&app.session, now); + let selected_stack = app.session.selected_layer().map(|layer| (layer, !targets_content(app))); + if matches!(app.session.target, StackTarget::Effect(_)) { + app.layer_panel.expanded_effects = selected_stack; + } else if app.layer_panel.expanded_effects != selected_stack { + app.layer_panel.expanded_effects = None; + } egui::ScrollArea::vertical().id_salt("layers_scroll").auto_shrink([false, false]).show(ui, |ui| { let mut count = 0; for id in stack { @@ -241,6 +247,15 @@ pub(crate) fn layers(app: &mut TextureCraftApp, ui: &mut Ui) { } }); select_all_layers(app, ui); + // A thumbnail or selection can close the editor before its TextEdit sees lost focus. + if let Some((id, _)) = &app.ui.rename + && let Some((owner, _)) = app.session.doc.project.effect(LayerId(*id)) + && app.layer_panel.expanded_effects.is_none_or(|(layer, in_mask)| { + layer != owner || !app.session.doc.project.layers.get(&layer).is_some_and(|l| stack_effects(l, in_mask).iter().any(|e| e.id.0 == *id)) + }) + { + finish_effect_rename(app); + } } /// Ctrl+A (Cmd+A on macOS) with the pointer over the Layers panel selects every row shown in the @@ -382,6 +397,7 @@ const EYE_CHIP_ROUNDING: f32 = 4.0; /// An effect thumbnail's corner rounding and border, the strike across a hidden effect's, and the line marking where a drag drops. const THUMBNAIL_ROUNDING: f32 = 2.0; const THUMBNAIL_BORDER_WIDTH: f32 = 1.0; +const EFFECT_DISCLOSURE_SIZE: f32 = 13.0; const HIDDEN_STRIKE_WIDTH: f32 = 1.5; const DROP_LINE_WIDTH: f32 = 2.0; /// The eye's size and the column it sits in (the eye and a gap before the thumbnail). @@ -442,23 +458,12 @@ const EFFECT_ROW_SHADES: [f32; 2] = [0.2, 0.5]; /// Width of the blend mode and opacity pair at the right of an effect row (a gap between them), and of its opacity part. const EFFECT_BLEND_WIDTH: f32 = 82.0; const EFFECT_OPACITY_WIDTH: f32 = 36.0; -/// Height of the "Content effects" / "Mask effects" header rows. -const GROUP_HEADER_H: f32 = 20.0; - -// Group header spacing leaves room for the label and effect count -const GROUP_HEADER_CARET_OFFSET: f32 = 15.0; -const GROUP_HEADER_LABEL_GAP: f32 = 10.0; -const GROUP_HEADER_LABEL_RESERVE: f32 = 28.0; -const GROUP_HEADER_COUNT_PADDING: f32 = 8.0; -const GROUP_HEADER_LABEL_FONT_SIZE: f32 = 10.5; /// Hover tint of alternating layer rows const ALTERNATE_LAYER_SHADE: f32 = 0.45; /// Maximum layer-tree nesting shown by the dock const MAX_LAYER_TREE_DEPTH: usize = 12; /// Checkerboard cells along each thumbnail edge const THUMB_CHECKER_CELLS: usize = 4; -/// Keep the group label and count readable when the panel is narrow -const GROUP_HEADER_MIN_REMAINING_WIDTH: f32 = 90.0; /// Keep both thumbnail targets inside the row before spending space on indentation fn layer_thumbnail_layout(width: f32, depth: usize, folder: bool, preferred_size: f32) -> (f32, f32) { @@ -492,18 +497,23 @@ fn level_x(left: f32, level: usize) -> f32 { left + ROW_LEFT_PADDING + level as f32 * INDENT + EYE_SIZE * 0.5 } +fn stack_effects(layer: &Layer, in_mask: bool) -> &[Effect] { + if in_mask { layer.mask.as_ref().map_or(&[], |mask| &mask.effects) } else { &layer.content_effects } +} + fn layer_tree(app: &mut TextureCraftApp, ui: &mut Ui, id: LayerId, depth: usize, count: &mut usize) { let Some(layer) = app.session.doc.project.layers.get(&id).cloned() else { return }; let index = *count; *count += 1; layer_row(app, ui, &layer, depth, index); - let mask_effects = layer.mask.as_ref().map_or(0, |mask| mask.effects.len()); - if !layer.content_effects.is_empty() { - effect_group(app, ui, &layer, depth, false, mask_effects > 0); - } - if mask_effects > 0 { - effect_group(app, ui, &layer, depth, true, false); + if let Some((open_layer, in_mask)) = app.layer_panel.expanded_effects + && open_layer == id + { + let stack = stack_effects(&layer, in_mask); + for (index, effect) in stack.iter().rev().enumerate() { + effect_row(app, ui, &layer, stack, effect, index, depth + 2, index + 1 == stack.len(), in_mask); + } } // A line under the layer and its effects separates it from the next layer. @@ -558,7 +568,8 @@ fn layer_row(app: &mut TextureCraftApp, ui: &mut Ui, layer: &Layer, depth: usize let content_target = selected && targets_content(app); let preferred_size = layer_preview_size(app); let row_height = layer_row_height(preferred_size); - let (rect, row) = ui.allocate_exact_size(vec2(ui.available_width(), row_height), Sense::click_and_drag()); + let (_, rect) = ui.allocate_space(vec2(ui.available_width(), row_height)); + let row = ui.interact(rect, ui.scope_id().with(("layer_row", layer.id.0)), Sense::click_and_drag()); row.widget_info(|| egui::WidgetInfo::selected(egui::Role::ListItem, true, highlighted, &layer.name)); // Background, folder lines, the selected rows' accent edge and the colour tag @@ -659,9 +670,14 @@ fn layer_row(app: &mut TextureCraftApp, ui: &mut Ui, layer: &Layer, depth: usize } painter.rect_stroke(thumbnail, THUMBNAIL_ROUNDING, target_stroke(&tokens, content_target), egui::StrokeKind::Outside); let content_response = ui.interact(thumbnail, ui.scope_id().with(("content", layer.id.0)), Sense::click()).on_hover_text(tr("Select the layer content")); + let content_stack = (!layer.content_effects.is_empty()).then_some((layer.id, false)); + effect_stack_thumbnail(app, &painter, &tokens, &content_response, (tr("Select the layer content"), &layer.name), content_target, content_stack); if content_response.clicked() { let modifiers = ui.input(|input| input.modifiers); click_layer(app, modifiers, layer.id.0, Some("content")); + if !modifiers.shift && !modifiers.command { + app.layer_panel.toggle_effects(content_stack); + } } x = thumbnail.right() + THUMBNAIL_SPACING; @@ -699,12 +715,24 @@ fn layer_row(app: &mut TextureCraftApp, ui: &mut Ui, layer: &Layer, depth: usize let mask_response = ui .interact(mask_rect, ui.scope_id().with(("mask", layer.id.0)), Sense::click()) .on_hover_text(tr("Select the mask (Alt+click: show it in the viewport)")); + let mask_stack = layer.mask.as_ref().filter(|mask| !mask.effects.is_empty()).map(|_| (layer.id, true)); + effect_stack_thumbnail( + app, + &painter, + &tokens, + &mask_response, + (tr("Select the mask (Alt+click: show it in the viewport)"), &layer.name), + mask_target, + mask_stack, + ); if mask_response.clicked() { app.run("layer.select", json!({"layer": layer.id.0, "target": "mask"})); if ui.input(|input| input.modifiers.alt) { let showing = app.session.view == texturecraft_engine::ViewMode::Mask(layer.id); let view = if showing { json!({"mode": "material"}) } else { json!({"mode": "mask", "layer": layer.id.0}) }; app.run("viewport.view", view); + } else { + app.layer_panel.toggle_effects(mask_stack); } } if app.session.view == texturecraft_engine::ViewMode::Mask(layer.id) { @@ -820,6 +848,7 @@ fn layer_row(app: &mut TextureCraftApp, ui: &mut Ui, layer: &Layer, depth: usize let modifiers = ui.input(|input| input.modifiers); if row.clicked() && !on_control && !renaming { click_layer(app, modifiers, layer.id.0, None); + app.layer_panel.expanded_effects = None; } if row.double_clicked() && !on_control && !renaming && show_name && !modifiers.shift && !modifiers.command { app.ui.rename = Some((layer.id.0, layer.name.clone())); @@ -918,69 +947,45 @@ fn content_glyph(p: &egui::Painter, tk: &Tokens, thumb: Rect, layer: &Layer) { } } -/// The "Content effects" or "Mask effects" header of `layer` and, unless folded, its effect rows -/// hung off tree lines. `more_below`: a second group follows, so the tree line goes on. -fn effect_group(app: &mut TextureCraftApp, ui: &mut Ui, layer: &Layer, depth: usize, mask: bool, more_below: bool) { - let tokens = Tokens::get(ui.ctx()); - let stack: &[Effect] = if mask { layer.mask.as_ref().map_or(&[], |layer_mask| &layer_mask.effects) } else { &layer.content_effects }; - let key = (layer.id.0, mask); - let folded = app.layer_panel.folded.contains(&key); - let (rect, response) = ui.allocate_exact_size(vec2(ui.available_width(), GROUP_HEADER_H), Sense::click()); - let label = if mask { tr("Mask effects") } else { tr("Content effects") }; - response.widget_info(|| egui::WidgetInfo::labeled(egui::Role::Button, true, label)); - let painter = ui.painter().clone(); - painter.rect_filled(rect, 0.0, if response.hovered() { tokens.row_hover } else { tokens.panel }); - let indent = ((depth + 1) as f32 * INDENT).min((rect.width() - GROUP_HEADER_MIN_REMAINING_WIDTH).max(0.0)); - tree_lines(&painter, &tokens, rect, indent, &[], more_below); - let x = rect.left() + GROUP_HEADER_CARET_OFFSET + indent; - painter.text( - pos2(x, rect.center().y), - egui::Align2::CENTER_CENTER, - if folded { ic::CARET_RIGHT } else { ic::CARET_DOWN }, - egui::FontId::proportional(LAYER_SUBTITLE_FONT_SIZE), - tokens.text_dim, - ); - let galley = elided( - &painter, - label.to_string(), - GROUP_HEADER_LABEL_FONT_SIZE, - tokens.text_dim, - (rect.right() - GROUP_HEADER_LABEL_RESERVE - x - GROUP_HEADER_LABEL_GAP).max(0.0), - ); - painter.galley(pos2(x + GROUP_HEADER_LABEL_GAP, rect.center().y - galley.size().y * 0.5), galley, tokens.text_dim); - painter.text( - pos2(rect.right() - GROUP_HEADER_COUNT_PADDING, rect.center().y), - egui::Align2::RIGHT_CENTER, - stack.len().to_string(), - egui::FontId::proportional(LAYER_SUBTITLE_FONT_SIZE), - tokens.text_dim, - ); - if response.on_hover_text(tr("Fold or unfold these effects")).clicked() && !app.layer_panel.folded.remove(&key) { - app.layer_panel.folded.insert(key); +/// Draw the effect disclosure on its thumbnail and expose the same state to AccessKit. +fn effect_stack_thumbnail( + app: &TextureCraftApp, + painter: &egui::Painter, + tokens: &Tokens, + response: &egui::Response, + (label, name): (&str, &str), + selected: bool, + stack: Option<(LayerId, bool)>, +) { + response.widget_info(|| egui::WidgetInfo::selected(egui::Role::Button, true, selected, format!("{label} ({name})"))); + if response.has_focus() { + painter.rect_stroke(response.rect.shrink(2.0), THUMBNAIL_ROUNDING, Stroke::new(1.0, tokens.text_strong), egui::StrokeKind::Inside); } - if folded { - return; - } - - let trunks: Vec = if more_below { vec![depth] } else { Vec::new() }; - for (row_index, effect) in stack.iter().rev().enumerate() { - effect_row(app, ui, layer, stack, effect, row_index, depth + 2, &trunks, row_index + 1 == stack.len(), mask); + if let Some(stack) = stack { + let expanded = app.layer_panel.expanded_effects == Some(stack); + response.ctx.accesskit_node_builder(response.id, |node| node.set_expanded(expanded)); + if response.rect.width() < EFFECT_DISCLOSURE_SIZE { + return; + } + let size = vec2(EFFECT_DISCLOSURE_SIZE, EFFECT_DISCLOSURE_SIZE); + let badge = Rect::from_min_size(response.rect.max - size, size); + painter.rect_filled(badge, THUMBNAIL_ROUNDING, tokens.button); + painter.text( + badge.center(), + egui::Align2::CENTER_CENTER, + if expanded { ic::CARET_DOWN } else { ic::CARET_RIGHT }, + egui::FontId::proportional(EFFECT_DISCLOSURE_SIZE - 3.0), + tokens.text_strong, + ); } } -/// Tree connector of a row at the clamped `indent`: a line down from the parent's column (to the middle -/// of the row when `more` is false, the row's end otherwise) and a tick towards the row, with -/// lines straight through for the `trunks` of ancestors that continue. -fn tree_lines(p: &egui::Painter, tk: &Tokens, rect: Rect, indent: f32, trunks: &[usize], more: bool) { +/// Draw the line along the open effect stack and a branch to this row. +fn effect_tree_line(p: &egui::Painter, tk: &Tokens, rect: Rect, indent: f32, more: bool) { if indent < INDENT { return; } let stroke = Stroke::new(1.0, tk.button_border); - for t in trunks { - if *t as f32 * INDENT + 8.0 < indent { - p.vline(level_x(rect.left(), *t), rect.y_range(), stroke); - } - } let x = rect.left() + 15.0 + indent - INDENT; let end = if more { rect.bottom() } else { rect.center().y }; p.vline(x, rect.top()..=end, stroke); @@ -1067,7 +1072,6 @@ fn effect_row( effect: &Effect, row_index: usize, level: usize, - trunks: &[usize], last: bool, in_mask: bool, ) { @@ -1076,7 +1080,8 @@ fn effect_row( let selected = app.session.selected_layer() == Some(layer.id) && app.session.target == StackTarget::Effect(effect_id); let layer_preview = layer_preview_size(app); let preview_size = effect_preview_size(layer_preview); - let (rect, row) = ui.allocate_exact_size(vec2(ui.available_width(), effect_row_height(layer_preview)), Sense::click_and_drag()); + let (_, rect) = ui.allocate_space(vec2(ui.available_width(), effect_row_height(layer_preview))); + let row = ui.interact(rect, ui.scope_id().with(("effect_row", effect_id.0)), Sense::click_and_drag()); row.widget_info(|| egui::WidgetInfo::selected(egui::Role::ListItem, true, selected, &effect.name)); // Background, tree lines and the selected row's accent edge @@ -1092,7 +1097,7 @@ fn effect_row( }; painter.rect_filled(rect, 0.0, background); let indent = effect_row_indent(rect.width(), level, preview_size); - tree_lines(&painter, &tokens, rect, indent, trunks, !last); + effect_tree_line(&painter, &tokens, rect, indent, !last); if selected { painter.rect_filled(Rect::from_min_size(rect.min, vec2(SELECTED_EDGE_WIDTH, rect.height())), 0.0, tokens.accent); } @@ -1124,7 +1129,7 @@ fn effect_row( if renaming { let half_height = EFFECT_NAME_EDIT_HEIGHT * 0.5; let name_rect = Rect::from_min_max(pos2(name_left, rect.center().y - half_height), pos2(name_right, rect.center().y + half_height)); - effect_rename_editor(app, ui, name_rect, effect); + effect_rename_editor(app, ui, name_rect); } else { let name_width = (name_right - name_left).max(MIN_NAME_WIDTH); if text_is_cut(&painter, &effect.name, EFFECT_NAME_FONT_SIZE, name_width) { @@ -1212,8 +1217,8 @@ fn effect_row( }); } -/// The name editor of `effect` in `rect`: Enter or a click elsewhere renames, Escape cancels. -fn effect_rename_editor(app: &mut TextureCraftApp, ui: &mut Ui, rect: Rect, effect: &Effect) { +/// The effect name editor: Enter or a click elsewhere renames, Escape cancels. +fn effect_rename_editor(app: &mut TextureCraftApp, ui: &mut Ui, rect: Rect) { let mut child = ui.new_child(egui::UiBuilder::new().max_rect(rect).layout(egui::Layout::left_to_right(egui::Align::Center))); let Some((_, name_buffer)) = app.ui.rename.as_mut() else { return }; @@ -1224,17 +1229,21 @@ fn effect_rename_editor(app: &mut TextureCraftApp, ui: &mut Ui, rect: Rect, effe if ui.input(|input| input.key_pressed(egui::Key::Escape)) { app.ui.rename = None; } else if response.lost_focus() { - let name = name_buffer.trim().to_string(); - app.ui.rename = None; - if !name.is_empty() && name != effect.name { - app.run("effect.set", json!({"effect": effect.id.0, "name": name})); - } + finish_effect_rename(app); } else if !response.has_focus() { // Only until the field has focus (see the layer rename editor) response.request_focus(); } } +fn finish_effect_rename(app: &mut TextureCraftApp) { + let Some((id, name)) = app.ui.rename.take() else { return }; + let name = name.trim(); + if !name.is_empty() && app.session.doc.project.effect(LayerId(id)).is_some_and(|(_, effect)| name != effect.name) { + app.run("effect.set", json!({"effect": id, "name": name})); + } +} + /// The Geometry mask tool: what a click does, and the selected layer's parts. fn geometry_tool_section(app: &mut TextureCraftApp, ui: &mut Ui) { let tk = Tokens::get(ui.ctx()); diff --git a/crates/ui-egui/src/layer_panel.rs b/crates/ui-egui/src/layer_panel.rs index d5390546..554161f3 100644 --- a/crates/ui-egui/src/layer_panel.rs +++ b/crates/ui-egui/src/layer_panel.rs @@ -1,12 +1,13 @@ //! State behind the Layers panel: the thumbnail service, the GPU textures made from its pictures, -//! which effect groups are folded, and the one place the preview size is decided. +//! which effect stack is open, and the one place the preview size is decided. -use std::collections::{HashMap, HashSet}; +use std::collections::HashMap; use std::time::Duration; use egui::{Context, TextureHandle, TextureId, TextureOptions}; use texturecraft_engine::Session; use texturecraft_engine::compose::ThumbTarget; +use texturecraft_engine::core::LayerId; use texturecraft_engine::thumbs::{CACHE_ENTRIES, ThumbService}; use crate::TextureCraftApp; @@ -42,20 +43,23 @@ pub struct LayerPanel { frame: u64, /// Whether this frame's pictures are begun and not yet finished by [`LayerPanel::end`] pictures_begun: bool, - /// Folded effect groups: (layer, true for the mask's). A view setting; the document is not touched. - pub(crate) folded: HashSet<(u64, bool)>, + /// The open stack, with `true` for a layer's mask. This belongs to the panel view. + pub(crate) expanded_effects: Option<(LayerId, bool)>, } /// How soon to look again for pictures still rendering (milliseconds) const POLL_INTERVAL_MS: u64 = 40; impl LayerPanel { + pub(crate) fn toggle_effects(&mut self, stack: Option<(LayerId, bool)>) { + self.expanded_effects = stack.filter(|stack| Some(*stack) != self.expanded_effects); + } + /// Start drawing the panel for this frame. pub(crate) fn begin(&mut self, session: &Session, now: f64) { self.begin_pictures(session, now); - // Deleted layer IDs must not accumulate in panel state - self.folded.retain(|(layer, _)| session.doc.project.layers.contains_key(&texturecraft_engine::core::LayerId(*layer))); + self.expanded_effects = self.expanded_effects.filter(|(layer, _)| session.doc.project.layers.contains_key(layer)); } /// Advance the picture frame once, whether the panel or a picture outside it asks first @@ -115,22 +119,22 @@ impl LayerPanel { #[cfg(test)] mod tests { use super::*; - use texturecraft_engine::core::{Channel, LayerId}; + use texturecraft_engine::core::Channel; use texturecraft_engine::geom::primitives; #[test] - fn deleted_layers_release_their_fold_state() { + fn deleted_layers_close_their_effect_stack() { let mut session = Session::new_project("thumb", primitives::plane(1.0, 1), "builtin:plane", None, 128).unwrap(); let layer = session.selected_layer().unwrap(); let mut panel = LayerPanel::default(); - panel.folded.extend([(layer.0, false), (layer.0, true)]); + panel.expanded_effects = Some((layer, false)); panel.begin(&session, 0.0); - assert_eq!(panel.folded.len(), 2, "existing layers keep their view settings"); + assert_eq!(panel.expanded_effects, Some((layer, false)), "existing layers keep their view settings"); texturecraft_engine::execute(&mut session, "layer.remove", &serde_json::json!({"layer": layer.0})).unwrap(); panel.begin(&session, 1.0); - assert!(panel.folded.is_empty(), "deleted layer IDs must not accumulate in view state"); + assert_eq!(panel.expanded_effects, None, "the deleted layer leaves no open stack"); } #[test] diff --git a/crates/ui-egui/tests/it/effect_rows.rs b/crates/ui-egui/tests/it/effect_rows.rs index fdd04351..b8afbe42 100644 --- a/crates/ui-egui/tests/it/effect_rows.rs +++ b/crates/ui-egui/tests/it/effect_rows.rs @@ -7,6 +7,8 @@ use texturecraft_engine::core::LayerId; use texturecraft_engine::execute; use texturecraft_ui_egui::TextureCraftApp; +use super::layers_panel::click_selected_content_thumbnail; + fn id(v: Value, key: &str) -> u64 { v[key].as_u64().unwrap() } @@ -34,6 +36,7 @@ fn dragging_an_effect_row_reorders_its_stack() { execute(&mut session, "layer.select", &json!({"layer": layer.0})).unwrap(); let mut harness = Harness::builder().with_size(egui::vec2(1600.0, 1400.0)).build_eframe(|creation_context| TextureCraftApp::new(creation_context, session)); harness.run_steps(4); + click_selected_content_thumbnail(&mut harness); let order = |harness: &Harness<'_, TextureCraftApp>| harness.state().session.doc.project.layers[&layer].content_effects.iter().map(|e| e.id.0).collect::>(); assert_eq!(order(&harness), [a, b, c]); @@ -60,6 +63,7 @@ fn an_effect_row_sets_its_blend_mode_and_opacity() { execute(&mut session, "layer.select", &json!({"layer": layer.0})).unwrap(); let mut harness = Harness::builder().with_size(egui::vec2(1600.0, 1400.0)).build_eframe(|creation_context| TextureCraftApp::new(creation_context, session)); harness.run_steps(4); + click_selected_content_thumbnail(&mut harness); let effect_of = |harness: &Harness<'_, TextureCraftApp>| harness.state().session.doc.project.layers[&layer].content_effects[0].clone(); assert_eq!(effect, effect_of(&harness).id.0); @@ -97,6 +101,7 @@ fn an_opacity_drag_starting_without_a_change_is_its_own_undo_step() { execute(&mut session, "layer.select", &json!({"layer": layer.0})).unwrap(); let mut harness = Harness::builder().with_size(egui::vec2(1600.0, 1400.0)).build_eframe(|creation_context| TextureCraftApp::new(creation_context, session)); harness.run_steps(4); + click_selected_content_thumbnail(&mut harness); let effect_of = |harness: &Harness<'_, TextureCraftApp>| harness.state().session.doc.project.layers[&layer].content_effects[0].clone(); let history = harness.state().session.history_labels().len(); diff --git a/crates/ui-egui/tests/it/layers_panel.rs b/crates/ui-egui/tests/it/layers_panel.rs index 0a88c260..4deeadc6 100644 --- a/crates/ui-egui/tests/it/layers_panel.rs +++ b/crates/ui-egui/tests/it/layers_panel.rs @@ -1,8 +1,8 @@ -//! The Layers panel rows: content and mask thumbnails select their own target, effect groups -//! fold without touching the document, and the thumbnails arrive from the worker. +//! The Layers panel rows: thumbnails select and disclose their own effects without editing the +//! document, and the thumbnail images arrive from the worker. use egui_kittest::Harness; -use egui_kittest::kittest::Queryable; +use egui_kittest::kittest::{NodeT, Queryable}; use serde_json::{Value, json}; use texturecraft_engine::compose::ThumbTarget; use texturecraft_engine::core::{Channel, LayerId}; @@ -35,11 +35,12 @@ fn thumb(h: &Harness<'_, TextureCraftApp>, name: &str, mask: bool) -> egui::Pos2 egui::pos2(x, row.center().y) } -/// The `label` header that follows the "Masked fill" row (other layers have groups too). -fn header(h: &mut Harness<'_, TextureCraftApp>, label: &str) { - let top = h.get_by_label("Masked fill").rect().top(); - let at = h.get_all_by_label(label).map(|n| n.rect()).filter(|r| r.top() > top).min_by(|a, b| a.top().total_cmp(&b.top())).unwrap().center(); - click(h, at); +/// Toggle the effect rows through the selected layer's content thumbnail. +pub(super) fn click_selected_content_thumbnail(h: &mut Harness<'_, TextureCraftApp>) { + let layer = h.state().session.selected_layer().unwrap(); + let name = &h.state().session.doc.project.layers[&layer].name; + h.get_by_label(&format!("Select the layer content ({name})")).click(); + h.run_steps(3); } fn click(h: &mut Harness<'_, TextureCraftApp>, at: egui::Pos2) { @@ -49,35 +50,84 @@ fn click(h: &mut Harness<'_, TextureCraftApp>, at: egui::Pos2) { } #[test] -fn mask_and_content_thumbnails_select_their_own_target() { +fn mask_and_content_thumbnails_toggle_their_own_stacks() { let (mut h, layer) = harness(); - let at = thumb(&h, "Masked fill", true); - click(&mut h, at); + let content = thumb(&h, "Masked fill", false); + let mask = thumb(&h, "Masked fill", true); + assert!(h.query_by_label("Effect A").is_none() && h.query_by_label("Effect M").is_none(), "stacks start closed"); + + click(&mut h, mask); assert_eq!(h.state().session.selected_layer(), Some(layer)); - assert_eq!(h.state().session.target, StackTarget::Mask, "the mask thumbnail routes to the mask"); - let at = thumb(&h, "Masked fill", false); - click(&mut h, at); - assert_eq!(h.state().session.target, StackTarget::Content, "the content thumbnail routes back"); - // Clicking an effect row's name still selects that effect (its right end holds the blend mode and opacity) + assert_eq!(h.state().session.target, StackTarget::Mask); + assert!(h.query_by_label("Effect M").is_some()); + click(&mut h, mask); + assert!(h.query_by_label("Effect M").is_none(), "the same mask thumbnail closes its stack"); + click(&mut h, mask); + assert!(h.query_by_label("Effect M").is_some()); + + click(&mut h, content); + assert_eq!(h.state().session.target, StackTarget::Content); + assert!(h.query_by_label("Effect M").is_none(), "switching thumbnails closes the mask stack"); + assert!(h.query_by_label("Effect A").is_some()); + click(&mut h, content); + assert!(h.query_by_label("Effect A").is_none(), "the same content thumbnail closes its stack"); + click(&mut h, content); let row = h.get_by_label("Effect A").rect(); click(&mut h, row.center()); assert!(matches!(h.state().session.target, StackTarget::Effect(_))); + assert!(h.query_by_label("Effect A").is_some(), "selecting an effect leaves its stack open"); } #[test] -fn folding_an_effect_group_hides_its_rows_without_changing_the_document() { - let (mut h, _) = harness(); - let (project, undo) = (h.state().session.doc.project.clone(), h.state().session.revision); - assert!(h.query_by_label("Effect A").is_some() && h.query_by_label("Effect M").is_some()); - header(&mut h, "Content effects"); - assert!(h.query_by_label("Effect A").is_none(), "folded content effects are hidden"); - assert!(h.query_by_label("Effect M").is_some(), "the mask group stays open"); - header(&mut h, "Mask effects"); - assert!(h.query_by_label("Effect M").is_none()); - assert_eq!(h.state().session.doc.project, project); - assert_eq!(h.state().session.revision, undo, "folding is not an edit"); - header(&mut h, "Content effects"); - assert!(h.query_by_label("Effect A").is_some(), "unfolds again"); +fn keyboard_toggles_effects_without_editing_the_document() { + let (mut h, layer) = harness(); + let session = &h.state().session; + let (project, history, modified) = (session.doc.project.clone(), session.history_labels(), session.modified); + let content = "Select the layer content (Masked fill)"; + assert_eq!(h.get_by_label(content).accesskit_node().data().is_expanded(), Some(false)); + + // Move focus to the thumbnail and activate it with the standard button keys. + h.get_by_label(content).focus(); + h.run_steps(3); + assert!(h.get_by_label(content).is_focused()); + h.key_press(egui::Key::Enter); + h.run_steps(3); + assert!(h.query_by_label("Effect A").is_some()); + h.key_press(egui::Key::Space); + h.run_steps(3); + assert!(h.query_by_label("Effect A").is_none()); + assert_eq!(h.get_by_label(content).accesskit_node().data().is_expanded(), Some(false)); + + h.key_press(egui::Key::Enter); + h.run_steps(3); + assert!(h.get_by_label(content).is_focused()); + assert_eq!(h.get_by_label(content).accesskit_node().data().is_expanded(), Some(true)); + + let session = &h.state().session; + let empty = session.doc.project.texture_sets[session.ts()] + .stack + .iter() + .rev() + .find_map(|id| { + let layer = session.doc.project.layers.get(id)?; + (layer.mask.is_none() && layer.content_effects.is_empty()).then(|| (*id, layer.name.clone())) + }) + .expect("sample contains an empty paint layer"); + let empty_thumbnail = format!("Select the layer content ({})", empty.1); + h.get_by_label(&empty_thumbnail).focus(); + h.run_steps(3); + assert!(h.get_by_label(&empty_thumbnail).is_focused()); + h.key_press(egui::Key::Enter); + h.run_steps(3); + assert_eq!(h.state().session.selected_layer(), Some(empty.0)); + assert_ne!(empty.0, layer); + assert!(h.query_by_label("Effect A").is_none() && h.query_by_label("Effect M").is_none(), "switching layers closes the old stack"); + assert_eq!(h.get_by_label(&empty_thumbnail).accesskit_node().data().is_expanded(), None); + + let session = &h.state().session; + assert_eq!(session.doc.project, project); + assert_eq!(session.history_labels(), history); + assert_eq!(session.modified, modified); } #[test] @@ -85,14 +135,15 @@ fn visible_rows_get_their_thumbnails() { let (mut h, layer) = harness(); let content = ThumbTarget::Content { layer, channel: Channel::BaseColor }; let mask = ThumbTarget::Mask { layer }; + let effect = h.state().session.doc.project.layers[&layer].content_effects[0].id; + let stage = ThumbTarget::Stage { effect, channel: Channel::BaseColor }; + click_selected_content_thumbnail(&mut h); let t0 = std::time::Instant::now(); - while !(h.state().layer_panel.service().is_fresh(content) && h.state().layer_panel.service().is_fresh(mask)) { + while ![content, mask, stage].iter().all(|target| h.state().layer_panel.service().is_fresh(*target)) { assert!(t0.elapsed().as_secs() < 60, "thumbnails never arrived"); h.run_steps(1); std::thread::sleep(std::time::Duration::from_millis(5)); } - // Rows, mask, and every effect stage on screen were asked for: well under the cache size. - assert!(h.state().layer_panel.service().cached() >= 4); } #[test] @@ -121,6 +172,9 @@ fn deeply_nested_effect_visibility_is_reachable_in_a_narrow_panel() { harness.state_mut().ui.dock.close(texturecraft_ui_egui::docking::Panel::Properties); harness.run_steps(4); + harness.state_mut().run("layer.select", json!({"layer": layer.0})).unwrap(); + harness.run_steps(3); + click_selected_content_thumbnail(&mut harness); let row = harness.get_by_label("Effect A").rect(); assert!(row.width() < 180.0, "the test must use a compact panel: {row:?}"); @@ -297,12 +351,13 @@ const LONG_EFFECT_NAME: &str = "Edge wear from curvature with dirt accumulation" fn an_effect_name_cut_short_shows_in_full_on_hover() { let mut session = texturecraft_engine::sample_session(256, 64).unwrap(); let layer = id(execute(&mut session, "layer.add.fill", &json!({"color": "#336699"})).unwrap(), "layer"); - execute(&mut session, "layer.select", &json!({"layer": layer})).unwrap(); execute(&mut session, "effect.add.filter", &json!({"target": "content", "filter": "invert", "name": LONG_EFFECT_NAME})).unwrap(); + execute(&mut session, "layer.select", &json!({"layer": layer})).unwrap(); let mut h = Harness::builder().with_size(egui::vec2(1280.0, 800.0)).build_eframe(|cc| TextureCraftApp::new(cc, session)); h.state_mut().ui.prefs.language = "en".into(); h.run_steps(4); + click_selected_content_thumbnail(&mut h); let row = h.get_by_label(LONG_EFFECT_NAME).rect(); let before = h.query_all_by_label_contains(LONG_EFFECT_NAME).count(); h.hover_at(egui::pos2(row.left() + 75.0, row.center().y)); diff --git a/crates/ui-egui/tests/it/rename_anchor.rs b/crates/ui-egui/tests/it/rename_anchor.rs index f8ee1763..9287725b 100644 --- a/crates/ui-egui/tests/it/rename_anchor.rs +++ b/crates/ui-egui/tests/it/rename_anchor.rs @@ -12,6 +12,8 @@ use texturecraft_engine::core::{Channel, EffectKind, LayerId, Source}; use texturecraft_engine::geom::primitives; use texturecraft_engine::{Session, StackTarget}; use texturecraft_ui_egui::TextureCraftApp; + +use super::layers_panel::click_selected_content_thumbnail; use texturecraft_ui_egui::file_dialogs::Answer; const BLACK: [f32; 3] = [0.0; 3]; @@ -69,7 +71,9 @@ fn effect_harness() -> (Harness<'static, TextureCraftApp>, u64) { "effect", ); texturecraft_engine::execute(&mut session, "layer.select", &json!({"layer": layer})).unwrap(); - (harness_for(session), effect) + let mut h = harness_for(session); + click_selected_content_thumbnail(&mut h); + (h, effect) } /// Choose Rename effect from the row's context menu and type `text` over the old name. @@ -116,10 +120,24 @@ fn renaming_an_effect_row_undoes_redoes_and_survives_save_and_reopen() { let layer = h.state().session.doc.project.effect(LayerId(effect)).unwrap().0; h.state_mut().run("layer.select", json!({"layer": layer.0})); h.run_steps(3); + assert!(h.query_by_label("Pitted rust").is_none(), "the reopened stack starts closed"); + click_selected_content_thumbnail(&mut h); assert!(h.query_by_label("Pitted rust").is_some(), "the reopened stack shows the name"); std::fs::remove_dir_all(file.parent().unwrap()).unwrap(); } +#[test] +fn collapsing_an_effect_stack_finishes_its_rename() { + let (mut h, effect) = effect_harness(); + rename_from_the_menu(&mut h, "Effect A", "Pitted rust"); + click_selected_content_thumbnail(&mut h); + assert!(h.state().ui.rename.is_none(), "the hidden editor has committed the name"); + assert_eq!(effect_name(&h, effect), "Pitted rust"); + assert!(h.query_by_label("Pitted rust").is_none(), "the effect stack closed"); + click_selected_content_thumbnail(&mut h); + assert!(h.query_by_label("Pitted rust").is_some()); +} + #[test] fn escape_in_the_effect_editor_keeps_the_name() { let (mut h, effect) = effect_harness(); From 857fb1e3d08aa8e4f8fdd21697809693e662cbb3 Mon Sep 17 00:00:00 2001 From: vangel76 Date: Sun, 22 Nov 2026 17:15:46 +0100 Subject: [PATCH 04/83] Save projects in the background and show progress --- crates/engine/src/bake/mesh_map_command.rs | 24 +-- crates/engine/src/file_cmds.rs | 165 +++++++++++++----- crates/engine/src/painting.rs | 3 +- crates/engine/src/path_tool.rs | 3 +- crates/engine/src/session.rs | 37 +++- crates/formats/src/project_file/mod.rs | 14 +- .../src/project_file/ram_reservation.rs | 12 +- .../formats/src/project_file/save_progress.rs | 69 ++++++++ crates/ui-egui/src/control.rs | 4 + crates/ui-egui/src/display_settings.rs | 3 +- crates/ui-egui/src/lib.rs | 29 ++- crates/ui-egui/src/manual_save.rs | 88 ++++++++++ crates/ui-egui/src/menus.rs | 4 + crates/ui-egui/src/shader_settings.rs | 3 +- crates/ui-egui/src/toolbar.rs | 5 + crates/ui-egui/src/windows.rs | 59 ++++--- crates/ui-egui/tests/it/file_dialogs.rs | 77 ++++++-- 17 files changed, 468 insertions(+), 131 deletions(-) create mode 100644 crates/formats/src/project_file/save_progress.rs create mode 100644 crates/ui-egui/src/manual_save.rs diff --git a/crates/engine/src/bake/mesh_map_command.rs b/crates/engine/src/bake/mesh_map_command.rs index fef27ea3..4e219bd1 100644 --- a/crates/engine/src/bake/mesh_map_command.rs +++ b/crates/engine/src/bake/mesh_map_command.rs @@ -56,7 +56,7 @@ pub(super) fn specs() -> Vec { cmd!("bake.cage.set", "Load cage mesh", [], None, "{path} — a mesh with the low poly's triangles", always, cage_set), cmd!("bake.cage.clear", "Remove cage mesh", [], None, "{}", always, |s, _| { s.bake_meshes.cage = None; - s.modified = true; + s.mark_modified(); Ok(meshes_json(s)) }), ] @@ -274,7 +274,7 @@ impl Session { for set in &mut self.doc.project.texture_sets { set.bake.high_poly.use_low_as_high = false; } - self.modified = true; + self.mark_modified(); Ok(name) } @@ -285,7 +285,7 @@ impl Session { } let removed = self.bake_meshes.high.remove(index); self.bake_meshes.rebuild(); - self.modified = true; + self.mark_modified(); Ok(removed) } @@ -303,7 +303,7 @@ impl Session { m.base_color.clear(); let name = m.name.clone(); self.bake_meshes.cage = Some(m); - self.modified = true; + self.mark_modified(); Ok(name) } @@ -347,20 +347,6 @@ impl Session { } } } - - pub(crate) fn saved_bake_paint(&self) -> BTreeMap<(usize, BakePaintTarget), texturecraft_formats::BakePaintData> { - self.doc - .bake_paint - .iter() - .map(|(key, map)| (*key, texturecraft_formats::BakePaintData { width: map.width, height: map.height, values: map.values.clone() })) - .collect() - } - - /// The bake meshes for a project file: (high polys, cage). - pub(crate) fn saved_bake_meshes(&self) -> (Vec, Option) { - let entry = |m: &BakeMesh| (m.name.clone(), m.bytes.as_ref().clone()); - (self.bake_meshes.high.iter().map(entry).collect(), self.bake_meshes.cage.as_ref().map(entry)) - } } /// `bake.highPoly.list`: the high polys and the cage (also part of `project.inspect`). @@ -392,7 +378,7 @@ fn high_remove(s: &mut Session, p: &Value) -> Result { if boolp(p, "all") == Some(true) { s.bake_meshes.high.clear(); s.bake_meshes.rebuild(); - s.modified = true; + s.mark_modified(); return Ok(meshes_json(s)); } let index = match (u64p(p, "index"), strp(p, "name")) { diff --git a/crates/engine/src/file_cmds.rs b/crates/engine/src/file_cmds.rs index f493093b..fdc29bf1 100644 --- a/crates/engine/src/file_cmds.rs +++ b/crates/engine/src/file_cmds.rs @@ -16,6 +16,47 @@ use crate::commands::{CommandSpec, always, bad, normal_format_param, strp, u64p} use crate::session::{Document, Session}; use crate::{EngineError, Result, cmd}; +fn project_with_resources( + doc: &Document, + mesh: Option<&(String, Arc>)>, + bake_meshes: &crate::BakeMeshes, + resources: BTreeMap, +) -> ProjectFile { + let mut pixels = doc.pixels.clone(); + + // Drop pixel images whose size no longer matches their texture set + let size_of = |id: texturecraft_core::LayerId| { + doc.project.locate(id).and_then(|(ts, _, _)| doc.project.texture_sets.get(ts)).map(TextureSet::size).or_else(|| { + doc.project + .effect(id) + .and_then(|(owner, _)| doc.project.locate(owner)) + .and_then(|(ts, _, _)| doc.project.texture_sets.get(ts)) + .map(TextureSet::size) + }) + }; + pixels.layers.retain(|(id, _), img| size_of(*id) == Some((img.width(), img.height()))); + pixels.masks.retain(|id, img| size_of(*id) == Some((img.width(), img.height()))); + + let bake_mesh = |mesh: &crate::BakeMesh| (mesh.name.clone(), mesh.bytes.as_ref().clone()); + let bake_paint = doc + .bake_paint + .iter() + .map(|(key, map)| (*key, texturecraft_formats::BakePaintData { width: map.width, height: map.height, values: map.values.clone() })) + .collect(); + ProjectFile { + project: doc.project.clone(), + pixels, + baked: doc.baked.clone(), + mesh: mesh.map(|(extension, bytes)| (extension.clone(), bytes.as_ref().clone())), + high_poly: bake_meshes.high.iter().map(bake_mesh).collect(), + cage: bake_meshes.cage.as_ref().map(bake_mesh), + bake_paint, + thumbnail: None, + resources, + warnings: Vec::new(), + } +} + pub fn specs() -> Vec { vec![ cmd!( @@ -171,7 +212,7 @@ impl Session { // Packed mesh files can have spare capacity that the project would otherwise retain let mut source = bytes.into_owned(); source.shrink_to_fit(); - session.mesh_source = Some((extension, source)); + session.mesh_source = Some((extension, Arc::new(source))); session.doc.project.mesh_file = leaf_of(file_name); session.doc.project.cameras = imported.cameras; @@ -204,7 +245,7 @@ impl Session { }; check_materials(&pf.project, &mesh)?; - let source = pf.mesh.clone(); + let source = pf.mesh; let resources = pf.resources.into_iter().map(|(k, v)| (k, std::sync::Arc::new(v))).collect(); let mut s = Session::new(Document { bake_paint: Default::default(), project: pf.project, pixels: pf.pixels, baked: pf.baked, resources }, mesh, source)?; @@ -220,44 +261,12 @@ impl Session { /// The project with independently owned resource bytes. pub fn project_file(&self) -> ProjectFile { let resources = self.doc.resources.iter().map(|(name, bytes)| (name.clone(), bytes.as_ref().clone())).collect(); - self.project_with_resources(resources) + project_with_resources(&self.doc, self.mesh_source.as_ref(), &self.bake_meshes, resources) } /// A save snapshot that shares immutable resource payloads with the document. pub fn project_snapshot(&self) -> ProjectFile>> { - self.project_with_resources(self.doc.resources.clone()) - } - - fn project_with_resources(&self, resources: BTreeMap) -> ProjectFile { - let mut pixels = self.doc.pixels.clone(); - - // Drop pixel images whose size no longer matches their texture set - let size_of = |id: texturecraft_core::LayerId| { - self.doc.project.locate(id).and_then(|(ts, _, _)| self.doc.project.texture_sets.get(ts)).map(TextureSet::size).or_else(|| { - self.doc - .project - .effect(id) - .and_then(|(owner, _)| self.doc.project.locate(owner)) - .and_then(|(ts, _, _)| self.doc.project.texture_sets.get(ts)) - .map(TextureSet::size) - }) - }; - pixels.layers.retain(|(id, _), img| size_of(*id) == Some((img.width(), img.height()))); - pixels.masks.retain(|id, img| size_of(*id) == Some((img.width(), img.height()))); - - let (high_poly, cage) = self.saved_bake_meshes(); - ProjectFile { - project: self.doc.project.clone(), - pixels, - baked: self.doc.baked.clone(), - mesh: self.mesh_source.clone(), - high_poly, - cage, - bake_paint: self.saved_bake_paint(), - thumbnail: None, - resources, - warnings: Vec::new(), - } + project_with_resources(&self.doc, self.mesh_source.as_ref(), &self.bake_meshes, self.doc.resources.clone()) } pub fn to_project_bytes(&self) -> Result> { @@ -449,6 +458,7 @@ fn plan(session: &mut Session, params: &Value) -> Result { mod native { use super::*; use std::path::Path; + use texturecraft_formats::project_file::SaveProgress; pub fn path_param<'a>(p: &'a Value, key: &str, cmd: &str) -> Result<&'a str> { strp(p, key).filter(|s| !s.trim().is_empty()).ok_or_else(|| bad(cmd, format!("`{key}` is required"))) @@ -484,21 +494,82 @@ mod native { } pub fn save_to(s: &mut Session, path: &str, adopt: bool) -> Result { - let path = if ext_of(path) == PROJECT_EXT { path.to_string() } else { format!("{path}.{PROJECT_EXT}") }; - let mut reservation = texturecraft_formats::RamReservation::for_save().map_err(fe)?; - reservation.save(Path::new(&path), &s.project_snapshot()).map_err(fe)?; + let output = s.save_task(path, adopt).run(None)?; + output.apply(s); + Ok(json!({ "path": output.path })) + } - if adopt { - s.path = Some(path.clone()); - s.modified = false; + struct SaveTarget { + project_id: u64, + revision: u64, + adopt: bool, + path: String, + } + + /// A manual save of the document at the moment it was requested. Large payloads are shared + /// until the worker assembles the archive. + pub struct SaveTask { + target: SaveTarget, + doc: Document, + mesh: Option<(String, Arc>)>, + bake_meshes: crate::BakeMeshes, + } + + impl Session { + pub fn save_task(&self, path: &str, adopt: bool) -> SaveTask { + let path = if ext_of(path) == PROJECT_EXT { path.to_string() } else { format!("{path}.{PROJECT_EXT}") }; + SaveTask { + target: SaveTarget { project_id: self.project_id, revision: self.save_revision, adopt, path }, + doc: self.doc.clone(), + mesh: self.mesh_source.clone(), + bake_meshes: self.bake_meshes.clone(), + } + } + } + + impl SaveTask { + /// Complete the atomic write on the worker. Waiting for a previous save to release the + /// RAM allowance also happens here. + pub fn run(self, progress: Option<&SaveProgress>) -> Result { + let mut reservation = texturecraft_formats::RamReservation::for_save().map_err(fe)?; + let snapshot = project_with_resources(&self.doc, self.mesh.as_ref(), &self.bake_meshes, self.doc.resources.clone()); + let path = Path::new(&self.target.path); + match progress { + Some(progress) => reservation.save_with_progress(path, &snapshot, progress), + None => reservation.save(path, &snapshot), + } + .map_err(fe)?; + Ok(SaveOutput { path: self.target.path, project_id: self.target.project_id, revision: self.target.revision, adopt: self.target.adopt }) + } + } + + /// An archive that was written successfully. Only the same project can adopt its path. + pub struct SaveOutput { + pub path: String, + project_id: u64, + revision: u64, + adopt: bool, + } + + impl SaveOutput { + /// Apply the saved path without clearing edits made since the snapshot. + pub fn apply(&self, session: &mut Session) { + if session.project_id != self.project_id { + return; + } + if self.adopt { + session.path = Some(self.path.clone()); + if session.save_revision == self.revision && !session.stroke_active() { + session.modified = false; + } + } + session.log.info("Project", format!("Saved {}", self.path)); } - s.log.info("Project", format!("Saved {path}")); - Ok(json!({ "path": path })) } } #[cfg(not(target_arch = "wasm32"))] -pub use native::{absolute, open_path, read_mesh}; +pub use native::{SaveOutput, SaveTask, absolute, open_path, read_mesh}; /// `file.new {mesh, name?, resolution?, uvTiles?, template?, importCameras?}`: a new project from the /// mesh file `mesh`, remembering its path for Reimport mesh. @@ -597,7 +668,7 @@ impl Session { let (mesh, source, warnings, mesh_file) = match file { Some(f) => { let m = texturecraft_formats::import_mesh_bytes(&f.name, &f.bytes).map_err(fe)?.mesh; - (m, Some((ext_of(&f.name), f.bytes)), f.warnings, leaf_of(&f.name)) + (m, Some((ext_of(&f.name), Arc::new(f.bytes))), f.warnings, leaf_of(&f.name)) } None => match &self.mesh_source { Some((ext, bytes)) => { @@ -612,7 +683,7 @@ impl Session { doc.project.mesh = format!("mesh.{ext}"); doc.project.mesh_file = mesh_file; } - let mut next = Session::new(doc, mesh, source)?; + let mut next = Session::new_with_source(doc, mesh, source)?; next.log.warnings("Importer", warnings); next.path = self.path.clone(); next.sync_images(); diff --git a/crates/engine/src/painting.rs b/crates/engine/src/painting.rs index 62010b50..9ca5836a 100644 --- a/crates/engine/src/painting.rs +++ b/crates/engine/src/painting.rs @@ -576,8 +576,7 @@ impl Session { self.undo.remove(0); } self.redo.clear(); - self.modified = true; - self.revision = self.revision.wrapping_add(1); + self.mark_modified(); // The live preview already shows the committed result: the stroke's tiles recomposite // from the committed pixels at low priority, without holding up this frame. self.mark_settle(st.ts, st.target, st.canvas.dirty.iter().copied()); diff --git a/crates/engine/src/path_tool.rs b/crates/engine/src/path_tool.rs index 5398501f..63d047b2 100644 --- a/crates/engine/src/path_tool.rs +++ b/crates/engine/src/path_tool.rs @@ -922,8 +922,7 @@ impl Session { } else { self.invalidate_changed(&before); } - self.revision = self.revision.wrapping_add(1); - self.modified = true; + self.mark_modified(); Ok((painted, before)) } diff --git a/crates/engine/src/session.rs b/crates/engine/src/session.rs index b493a8b6..4f2c8b77 100644 --- a/crates/engine/src/session.rs +++ b/crates/engine/src/session.rs @@ -418,7 +418,7 @@ pub struct Session { pub(crate) source: Arc, pub bvh: Arc, /// Original mesh file (saved inside the project); None for built-in meshes. - pub mesh_source: Option<(String, Vec)>, + pub mesh_source: Option<(String, Arc>)>, /// High-definition meshes and cage for baking (saved inside the project). pub bake_meshes: crate::BakeMeshes, pub caches: Vec, @@ -467,6 +467,9 @@ pub struct Session { /// (see [`crate::commands::check_enabled`]). pub project_open: bool, pub modified: bool, + /// Edits to saved data, independent of viewport and tool changes. + #[cfg(not(target_arch = "wasm32"))] + pub(crate) save_revision: u64, /// Bumps on every document change. pub revision: u64, /// Messages for the UI (status bar / toasts). @@ -492,6 +495,10 @@ pub struct Session { impl Session { /// A session for `project` on `mesh` (its sets must reference mesh materials), with UV-tiled sets' UVs mapped into their atlas ([`Session::source_mesh`]) pub fn new(doc: Document, mesh: Mesh, mesh_source: Option<(String, Vec)>) -> Result { + Self::new_with_source(doc, mesh, mesh_source.map(|(extension, bytes)| (extension, Arc::new(bytes)))) + } + + pub(crate) fn new_with_source(doc: Document, mesh: Mesh, mesh_source: Option<(String, Arc>)>) -> Result { mesh.validate().map_err(|error| EngineError::Other(error.to_string()))?; let source = Arc::new(mesh); @@ -539,6 +546,8 @@ impl Session { path: None, project_open: true, modified: false, + #[cfg(not(target_arch = "wasm32"))] + save_revision: 0, revision: 1, log: crate::log::SessionLog::new(), log_id: next_mesh_id(), @@ -567,6 +576,10 @@ impl Session { pub fn switch_to(&mut self, mut next: Session) { // Invalidate caches even when both projects were loaded with the same revision next.revision = self.revision.wrapping_add(1); + #[cfg(not(target_arch = "wasm32"))] + { + next.save_revision = self.save_revision.wrapping_add(1); + } next.viewport = self.viewport; next.export_presets = std::mem::take(&mut self.export_presets); @@ -711,8 +724,7 @@ impl Session { self.path_steps = Default::default(); } - self.modified = true; - self.revision = self.revision.wrapping_add(1); + self.mark_modified(); if !(merge && self.undo.last().is_some_and(|(l, _)| l == label)) { self.undo.push((label.to_string(), before)); } @@ -723,8 +735,7 @@ impl Session { /// A change from `other` to the current document that is not an undo step (a path preview) pub(crate) fn changed_without_history(&mut self, other: &Document) { - self.modified = true; - self.revision = self.revision.wrapping_add(1); + self.mark_modified(); self.invalidate_changed(other); } @@ -835,14 +846,23 @@ impl Session { /// Mark the document changed and every texture set dirty. pub fn touched(&mut self) { - self.modified = true; - self.revision = self.revision.wrapping_add(1); + self.mark_modified(); self.sync_caches(); for c in &mut self.caches { c.invalidate_all(); } } + /// Mark saved data changed without invalidating the texture sets. + pub fn mark_modified(&mut self) { + self.modified = true; + self.revision = self.revision.wrapping_add(1); + #[cfg(not(target_arch = "wasm32"))] + { + self.save_revision = self.save_revision.wrapping_add(1); + } + } + /// Make caches agree with the project's texture sets (resolution or channel changes). pub fn sync_caches(&mut self) { let sets = self.doc.project.texture_sets.clone(); @@ -953,11 +973,10 @@ impl Session { fn after_history(&mut self, other: &Document) { // Pending operations may still hold layer IDs from the discarded snapshot self.doc.project.next_id = self.doc.project.next_id.max(other.project.next_id); - self.modified = true; + self.mark_modified(); // Layers picked together belong to the stack they were picked in self.multi.clear(); - self.revision = self.revision.wrapping_add(1); self.invalidate_changed(other); // An undone add or duplicate takes the selected effect away diff --git a/crates/formats/src/project_file/mod.rs b/crates/formats/src/project_file/mod.rs index c5bf3bdb..06a504ca 100644 --- a/crates/formats/src/project_file/mod.rs +++ b/crates/formats/src/project_file/mod.rs @@ -38,10 +38,12 @@ mod load_budget; mod project_open_limit; mod ram_operation; mod ram_reservation; +mod save_progress; #[cfg(not(target_arch = "wasm32"))] pub use entries::{DEFAULT_RAM_PERCENT, DEFAULT_RESERVED_CORES, available_save_resources, configured_ram_budget, save_ram_budget, set_save_resources}; pub use project_open_limit::{DEFAULT_PROJECT_OPEN_LIMIT_GIB, project_open_limit_gib, set_project_open_limit_gib}; pub use ram_reservation::RamReservation; +pub use save_progress::SaveProgress; const KIND: &str = "project file"; #[cfg(test)] @@ -109,11 +111,11 @@ pub fn save_project(path: &std::path::Path, project_file: &ProjectFile) -> Resul } #[cfg(not(target_arch = "wasm32"))] -fn write_project_atomic(path: &std::path::Path, project_file: &ProjectFile>>) -> Result<()> { +fn write_project_atomic(path: &std::path::Path, project_file: &ProjectFile>>, progress: Option<&SaveProgress>) -> Result<()> { let (temporary_path, file) = crate::create_temp(path)?; let result = (|| -> Result<()> { let mut file = std::io::BufWriter::new(file); - write_project(&mut file, project_file)?; + write_project(&mut file, project_file, progress)?; file.into_inner().map_err(|error| error.into_error())?.sync_all()?; std::fs::rename(&temporary_path, path)?; Ok(()) @@ -276,9 +278,13 @@ fn entries(pf: &ProjectFile>>) -> Result>> { Ok(out) } -fn write_project(out: W, pf: &ProjectFile>>) -> Result<()> { +fn write_project(out: W, pf: &ProjectFile>>, progress: Option<&SaveProgress>) -> Result<()> { let mut zip = ZipWriter::new(out); - entries::write_entries(&mut zip, entries(pf)?)?; + let mut entries = entries(pf)?; + if let Some(progress) = progress { + progress.track(&mut entries); + } + entries::write_entries(&mut zip, entries)?; zip.finish().map_err(zip_err)?; Ok(()) } diff --git a/crates/formats/src/project_file/ram_reservation.rs b/crates/formats/src/project_file/ram_reservation.rs index 72857c15..caff4af1 100644 --- a/crates/formats/src/project_file/ram_reservation.rs +++ b/crates/formats/src/project_file/ram_reservation.rs @@ -2,6 +2,8 @@ use std::borrow::Borrow; use std::io::Cursor; use std::sync::{Condvar, Mutex}; +#[cfg(not(target_arch = "wasm32"))] +use super::SaveProgress; use super::{ProjectFile, ram_operation::RamOperation, write_project}; use crate::{FormatError, Result}; @@ -57,14 +59,20 @@ impl RamReservation { pub fn save_bytes(&mut self, project_file: &ProjectFile>>) -> Result> { self.check_save()?; let mut out = Cursor::new(Vec::new()); - write_project(&mut out, project_file)?; + write_project(&mut out, project_file, None)?; Ok(out.into_inner()) } #[cfg(not(target_arch = "wasm32"))] pub fn save(&mut self, path: &std::path::Path, project_file: &ProjectFile>>) -> Result<()> { self.check_save()?; - super::write_project_atomic(path, project_file) + super::write_project_atomic(path, project_file, None) + } + + #[cfg(not(target_arch = "wasm32"))] + pub fn save_with_progress(&mut self, path: &std::path::Path, project_file: &ProjectFile>>, progress: &SaveProgress) -> Result<()> { + self.check_save()?; + super::write_project_atomic(path, project_file, Some(progress)) } fn check_save(&self) -> Result<()> { diff --git a/crates/formats/src/project_file/save_progress.rs b/crates/formats/src/project_file/save_progress.rs new file mode 100644 index 00000000..4e7c1810 --- /dev/null +++ b/crates/formats/src/project_file/save_progress.rs @@ -0,0 +1,69 @@ +use std::io::{self, Write}; +use std::sync::atomic::{AtomicU64, Ordering}; + +use super::entries::Entry; + +/// Estimated archive progress, based on the payload processed by the entry writers. +/// Completing the archive, syncing it to disk, and replacing the destination can take longer. +#[derive(Default)] +pub struct SaveProgress { + total: AtomicU64, + processed: AtomicU64, +} + +impl SaveProgress { + pub fn fraction(&self) -> f32 { + let total = self.total.load(Ordering::Relaxed); + if total == 0 { + return 0.0; + } + let processed = self.processed.load(Ordering::Relaxed).min(total); + // Leave room for the final write and atomic replacement. + 0.95 * (processed as f64 / total as f64) as f32 + } + + pub(super) fn track<'a>(&'a self, entries: &mut [Entry<'a>]) { + self.processed.store(0, Ordering::Relaxed); + self.total.store(entries.iter().fold(0u64, |sum, entry| sum.saturating_add(entry.weight)), Ordering::Relaxed); + for entry in entries { + let body = std::mem::replace(&mut entry.body, Box::new(|_| Ok(()))); + let remaining = entry.weight; + entry.body = Box::new(move |target| { + let mut writer = ProgressWriter { target, progress: self, remaining, pending: 0 }; + body(&mut writer)?; + writer.report(); + Ok(()) + }); + } + } +} + +struct ProgressWriter<'a> { + target: &'a mut dyn Write, + progress: &'a SaveProgress, + remaining: u64, + pending: u64, +} + +impl ProgressWriter<'_> { + fn report(&mut self) { + self.progress.processed.fetch_add(std::mem::take(&mut self.pending), Ordering::Relaxed); + } +} + +impl Write for ProgressWriter<'_> { + fn write(&mut self, bytes: &[u8]) -> io::Result { + let written = self.target.write(bytes)?; + let counted = (written as u64).min(self.remaining); + self.remaining -= counted; + self.pending += counted; + if self.pending >= 64 << 10 { + self.report(); + } + Ok(written) + } + + fn flush(&mut self) -> io::Result<()> { + self.target.flush() + } +} diff --git a/crates/ui-egui/src/control.rs b/crates/ui-egui/src/control.rs index 6b471ff5..6e999d7d 100644 --- a/crates/ui-egui/src/control.rs +++ b/crates/ui-egui/src/control.rs @@ -141,6 +141,10 @@ pub fn handle(app: &mut TextureCraftApp, ctx: &egui::Context, method: &str, para }, "command.run" => { let Some(id) = params.get("id").and_then(Value::as_str) else { return err("`id` is required") }; + #[cfg(not(target_arch = "wasm32"))] + if app.save_job.is_some() && crate::manual_save::is_save(id) { + return err("A manual project save is already running"); + } let command_params = params.get("params").cloned().unwrap_or(Value::Null); let before = app.session.camera; match texturecraft_engine::execute(&mut app.session, id, &command_params) { diff --git a/crates/ui-egui/src/display_settings.rs b/crates/ui-egui/src/display_settings.rs index 7c0bc14d..6a8e56b2 100644 --- a/crates/ui-egui/src/display_settings.rs +++ b/crates/ui-egui/src/display_settings.rs @@ -57,8 +57,7 @@ pub(crate) fn body(app: &mut TextureCraftApp, ui: &mut Ui) { } app.session.doc.project.display = display; - app.session.modified = true; - app.session.revision = app.session.revision.wrapping_add(1); + app.session.mark_modified(); } if import_hdr { diff --git a/crates/ui-egui/src/lib.rs b/crates/ui-egui/src/lib.rs index 1a8508eb..f6b25860 100644 --- a/crates/ui-egui/src/lib.rs +++ b/crates/ui-egui/src/lib.rs @@ -50,6 +50,8 @@ mod levels_properties; mod line_snap; mod list_action; pub mod log_panel; +#[cfg(not(target_arch = "wasm32"))] +mod manual_save; mod mask_preview_image; mod material_preview_image; pub mod menus; @@ -189,6 +191,7 @@ pub struct Toast { pub error: bool, pub until: f64, pub show_log: bool, + announce: bool, } pub struct TextureCraftApp { @@ -267,10 +270,13 @@ pub struct TextureCraftApp { /// Native file dialogs and their continuations (desktop only). #[cfg(not(target_arch = "wasm32"))] pub file_dialogs: file_dialogs::FileDialogs, - /// The unsaved-changes dialog's Save is waiting on the Save dialog's answer. + /// A manual save running on the desktop archive writer. + #[cfg(not(target_arch = "wasm32"))] + pub(crate) save_job: Option, + /// The unsaved-changes dialog's Save is waiting for a path or a save result. #[cfg(not(target_arch = "wasm32"))] pub(crate) saving_for_prompt: bool, - /// That Save dialog saved the project; the prompt goes on at its next frame. + /// The requested save completed; the prompt goes on at its next frame. #[cfg(not(target_arch = "wasm32"))] pub(crate) prompt_saved: bool, /// The resolved keymap and its key dispatcher. @@ -364,6 +370,8 @@ impl TextureCraftApp { #[cfg(not(target_arch = "wasm32"))] file_dialogs: file_dialogs::FileDialogs::new(cc.egui_ctx.clone()), #[cfg(not(target_arch = "wasm32"))] + save_job: None, + #[cfg(not(target_arch = "wasm32"))] saving_for_prompt: false, #[cfg(not(target_arch = "wasm32"))] prompt_saved: false, @@ -504,13 +512,13 @@ impl TextureCraftApp { } pub fn toast(&mut self, text: impl Into, error: bool) { - self.toasts.push(Toast { text: text.into(), error, until: self.last_time + if error { 6.0 } else { 3.0 }, show_log: false }); + self.toasts.push(Toast { text: text.into(), error, until: self.last_time + if error { 6.0 } else { 3.0 }, show_log: false, announce: false }); } /// An error toast that stays until the user dismisses it (for a problem that persists and /// is reported once, like a texture set the GPU could not hold). pub fn toast_sticky(&mut self, text: impl Into) { - self.toasts.push(Toast { text: text.into(), error: true, until: f64::INFINITY, show_log: false }); + self.toasts.push(Toast { text: text.into(), error: true, until: f64::INFINITY, show_log: false, announce: false }); } /// Start baking texture sets in the background, one after another. Invalid set indices @@ -871,6 +879,9 @@ impl TextureCraftApp { /// and written on a worker thread; the project data is shared copy-on-write). #[cfg(not(target_arch = "wasm32"))] fn autosave(&mut self, now: f64) { + if self.save_job.is_some() { + return; + } let period = autosave_period_seconds(self.ui.prefs.autosave_minutes); // The clock starts at the first unsaved change @@ -1023,7 +1034,10 @@ impl eframe::App for TextureCraftApp { ctx.set_zoom_factor(scale); } #[cfg(not(target_arch = "wasm32"))] - self.autosave(now); + { + self.poll_save(ctx); + self.autosave(now); + } i18n::set_language(&self.ui.prefs.language); #[cfg(target_arch = "wasm32")] { @@ -1198,7 +1212,10 @@ fn toasts(app: &mut TextureCraftApp, ctx: &egui::Context) { ui.allocate_ui_with_layout(egui::vec2(width, 0.0), egui::Layout::top_down(egui::Align::Min), |ui| { egui::ScrollArea::vertical().id_salt(("toast", i)).max_height(max_text_height).show(ui, |ui| { ui.set_max_width(width); - ui.add(egui::Label::new(egui::RichText::new(&t.text).color(tk.text_strong)).wrap()); + let label = ui.add(egui::Label::new(egui::RichText::new(&t.text).color(tk.text_strong)).wrap()); + if t.announce { + ui.ctx().accesskit_node_builder(label.id, |node| node.set_live(egui::accesskit::Live::Polite)); + } }); if t.show_log && ui.link(i18n::tr("Open Log")).clicked() { show_log = true; diff --git a/crates/ui-egui/src/manual_save.rs b/crates/ui-egui/src/manual_save.rs new file mode 100644 index 00000000..c2481678 --- /dev/null +++ b/crates/ui-egui/src/manual_save.rs @@ -0,0 +1,88 @@ +//! Manual desktop saves share the atomic archive writer with autosave and headless saves. + +use std::sync::{Arc, mpsc}; +use std::time::Duration; + +use texturecraft_engine::{Result, file_cmds::SaveOutput, formats::project_file::SaveProgress}; + +use crate::{ + TextureCraftApp, + i18n::{tr, trf}, +}; + +pub(crate) struct SaveJob { + progress: Arc, + output: mpsc::Receiver>, + project_id: u64, + for_prompt: bool, + remember: bool, + pub(crate) quit_after_save: bool, +} + +pub(crate) fn is_save(id: &str) -> bool { + matches!(id, "file.save" | "file.saveAs" | "file.saveCopy") +} + +impl TextureCraftApp { + pub(crate) fn start_save(&mut self, path: &str, adopt: bool, for_prompt: bool, remember: bool) -> bool { + if self.save_job.is_some() { + self.toast(tr("A project save is already running"), true); + return false; + } + if let Err(error) = self.session.end_stroke() { + self.toast(error.to_string(), true); + return false; + } + + let task = self.session.save_task(path, adopt); + let progress = Arc::new(SaveProgress::default()); + let worker_progress = progress.clone(); + let output = crate::spawn_worker("texturecraft-save", move || task.run(Some(&worker_progress))); + self.save_job = Some(SaveJob { progress, output, project_id: self.session.project_id, for_prompt, remember, quit_after_save: false }); + true + } + + pub(crate) fn save_progress(&self) -> Option { + self.save_job.as_ref().map(|job| job.progress.fraction()) + } + + pub(crate) fn poll_save(&mut self, ctx: &egui::Context) { + let Some(job) = &self.save_job else { return }; + let result = match job.output.try_recv() { + Ok(result) => result.map_err(|error| error.to_string()), + Err(mpsc::TryRecvError::Empty) => { + ctx.request_repaint_after(Duration::from_millis(80)); + return; + } + Err(mpsc::TryRecvError::Disconnected) => Err(tr("The project save worker stopped").into()), + }; + let Some(job) = self.save_job.take() else { return }; + let same_project = job.project_id == self.session.project_id; + let continue_prompt = job.for_prompt && self.saving_for_prompt; + if job.for_prompt { + self.saving_for_prompt = false; + } + + match result { + Ok(output) => { + output.apply(&mut self.session); + if job.remember { + crate::windows::remember(self, &output.path); + } + self.prompt_saved = continue_prompt && same_project && !self.session.modified && !self.session.stroke_active(); + self.toast(trf("Saved {path}", &[("path", &output.path)]), false); + if job.quit_after_save && same_project { + ctx.send_viewport_cmd(egui::ViewportCommand::Close); + } + } + Err(error) => { + let message = trf("Could not save project: {error}", &[("error", &error)]); + self.session.log.warn("Project", message.clone()); + self.toast(message, true); + } + } + if let Some(toast) = self.toasts.last_mut() { + toast.announce = true; + } + } +} diff --git a/crates/ui-egui/src/menus.rs b/crates/ui-egui/src/menus.rs index 7ec42c75..8aea36c1 100644 --- a/crates/ui-egui/src/menus.rs +++ b/crates/ui-egui/src/menus.rs @@ -175,6 +175,10 @@ fn tooltip_of(id: &str) -> Option<&'static str> { /// Whether an item can run now pub fn enabled(app: &TextureCraftApp, id: &str) -> bool { + #[cfg(not(target_arch = "wasm32"))] + if app.save_job.is_some() && crate::manual_save::is_save(id) { + return false; + } if UNAVAILABLE.contains(&id) { return false; } diff --git a/crates/ui-egui/src/shader_settings.rs b/crates/ui-egui/src/shader_settings.rs index ba00a046..88dd9ae4 100644 --- a/crates/ui-egui/src/shader_settings.rs +++ b/crates/ui-egui/src/shader_settings.rs @@ -77,8 +77,7 @@ pub(crate) fn body(app: &mut TextureCraftApp, ui: &mut Ui) { if display != app.session.doc.project.display { app.session.doc.project.display = display; - app.session.modified = true; - app.session.revision = app.session.revision.wrapping_add(1); + app.session.mark_modified(); } } diff --git a/crates/ui-egui/src/toolbar.rs b/crates/ui-egui/src/toolbar.rs index dc2f3453..a28a5360 100644 --- a/crates/ui-egui/src/toolbar.rs +++ b/crates/ui-egui/src/toolbar.rs @@ -536,6 +536,11 @@ pub fn status_bar(app: &mut TextureCraftApp, ui: &mut egui::Ui) { .frame(egui::Frame::NONE.fill(tk.chrome).inner_margin(egui::Margin::symmetric(10, 0))) .show(ui, |ui| { ui.horizontal_centered(|ui| { + #[cfg(not(target_arch = "wasm32"))] + if let Some(progress) = app.save_progress() { + ui.add(egui::ProgressBar::new(progress).desired_width(160.0).desired_height(10.0).text(RichText::new(tr("Saving project")).size(10.0))); + ui.separator(); + } if let Some(p) = app.bake_progress() { ui.add(egui::ProgressBar::new(p).desired_width(160.0).desired_height(10.0).text(RichText::new(tr("Baking")).size(10.0))); if ui.small_button(tr("Cancel")).clicked() { diff --git a/crates/ui-egui/src/windows.rs b/crates/ui-egui/src/windows.rs index 0624e1be..8473de9a 100644 --- a/crates/ui-egui/src/windows.rs +++ b/crates/ui-egui/src/windows.rs @@ -92,7 +92,19 @@ pub(crate) fn close_request(app: &mut TextureCraftApp, ctx: &egui::Context) { { app.toast(error.to_string(), true); } - if closing && ask_to_save(app, crate::state::Unsaved::Quit) { + #[cfg(not(target_arch = "wasm32"))] + let waiting_for_save = if closing + && !app.session.modified + && let Some(job) = &mut app.save_job + { + job.quit_after_save = true; + true + } else { + false + }; + #[cfg(target_arch = "wasm32")] + let waiting_for_save = false; + if closing && (waiting_for_save || ask_to_save(app, crate::state::Unsaved::Quit)) { ctx.send_viewport_cmd(egui::ViewportCommand::CancelClose); if ctx.input(|i| i.viewport().minimized == Some(true)) { ctx.send_viewport_cmd(egui::ViewportCommand::Minimized(false)); @@ -110,7 +122,7 @@ fn unsaved(app: &mut TextureCraftApp, ctx: &egui::Context) { let Some(pending) = app.ui.windows.unsaved.clone() else { return }; #[cfg(not(target_arch = "wasm32"))] - let (waiting_for_save, saved_by_dialog) = (app.saving_for_prompt, std::mem::take(&mut app.prompt_saved)); + let (waiting_for_save, saved_by_dialog) = (app.saving_for_prompt || app.save_job.is_some(), std::mem::take(&mut app.prompt_saved)); #[cfg(target_arch = "wasm32")] let (waiting_for_save, saved_by_dialog) = (false, false); @@ -129,7 +141,7 @@ fn unsaved(app: &mut TextureCraftApp, ctx: &egui::Context) { // One row keeps the window to its contents; a bare right-to-left layout fills the screen height ui.horizontal(|ui| { - // The answers wait while the Save dialog is open + // Wait for the path picker or an active save to finish. ui.add_enabled_ui(!waiting_for_save, |ui| { ui.with_layout(egui::Layout::right_to_left(egui::Align::Center), |ui| { if ui.add(primary_button(ui, tr("Save"))).clicked() { @@ -156,11 +168,13 @@ fn unsaved(app: &mut TextureCraftApp, ctx: &egui::Context) { let discard_after_create = matches!(pending, Unsaved::CreateProject(_)) && save_first == Some(false) && app.session.modified; match save_first { Some(true) => { - // An untitled project is saved from a dialog that answers on a later frame #[cfg(not(target_arch = "wasm32"))] { - app.saving_for_prompt = app.session.path.is_none(); + app.saving_for_prompt = true; + file_action(app, ctx, "file.save"); + return; } + #[cfg(target_arch = "wasm32")] file_action(app, ctx, "file.save"); } // Going ahead anyway: the changes are let go @@ -484,15 +498,16 @@ pub fn file_action(app: &mut TextureCraftApp, _ctx: &egui::Context, id: &str) -> }); true } - "file.save" if app.session.path.is_some() => { - if let Some(result) = app.run("file.save", json!({})) { - let saved_path = result["path"].as_str().unwrap_or_default(); - app.toast(trf("Saved {path}", &[("path", &saved_path)]), false); - } - true - } "file.save" | "file.saveAs" => { - ask_save_project(app, "file.saveAs"); + if id == "file.save" + && let Some(path) = app.session.path.clone() + { + if !app.start_save(&path, true, app.saving_for_prompt, false) { + app.saving_for_prompt = false; + } + } else { + ask_save_project(app, "file.saveAs"); + } true } "file.saveCopy" => { @@ -568,7 +583,7 @@ pub fn file_action(app: &mut TextureCraftApp, _ctx: &egui::Context, id: &str) -> } } -/// Asks where to save the project and runs `cmd` with the answer. Each caller is its own dialog +/// Asks where to save the project and starts the worker with the answer. Each caller is its own dialog /// request, so Save As and Save a Copy queue separately. #[cfg(not(target_arch = "wasm32"))] #[track_caller] @@ -578,19 +593,11 @@ fn ask_save_project(app: &mut TextureCraftApp, cmd: &'static str) { // Save a Copy leaves the project unsaved, so it never answers the unsaved-changes prompt. let for_prompt = app.saving_for_prompt && cmd == "file.saveAs"; let asked = app.ask_file(dialog, Bound::Project, move |app, paths| { - let mut saved = false; - if let Some(p) = paths.first() { - let path = p.display().to_string(); - saved = app.run(cmd, json!({"path": path})).is_some(); - if saved { - remember(app, &path); - app.toast(trf("Saved {path}", &[("path", &path)]), false); - } - } - // The answer ends the wait. A canceled or failed save leaves the prompt open for an answer. - if for_prompt { + let for_prompt = for_prompt && app.saving_for_prompt; + let started = paths.first().is_some_and(|p| app.start_save(&p.display().to_string(), cmd != "file.saveCopy", for_prompt, true)); + // Canceled dialogs and failures leave the prompt open for another answer. + if for_prompt && !started { app.saving_for_prompt = false; - app.prompt_saved = saved && !app.session.modified; } }); // A Save As already on its way answers for itself: the prompt's buttons stay usable. diff --git a/crates/ui-egui/tests/it/file_dialogs.rs b/crates/ui-egui/tests/it/file_dialogs.rs index a8876e9e..d9ff167b 100644 --- a/crates/ui-egui/tests/it/file_dialogs.rs +++ b/crates/ui-egui/tests/it/file_dialogs.rs @@ -1,6 +1,7 @@ //! Native file dialogs answer on a later frame; the tests answer them without a window. use std::path::{Path, PathBuf}; +use std::time::{Duration, Instant}; use egui::{ViewportCommand, ViewportEvent, ViewportId}; use egui_kittest::Harness; @@ -10,6 +11,8 @@ use texturecraft_ui_egui::TextureCraftApp; use texturecraft_ui_egui::file_dialogs::{Answer, Request}; use texturecraft_ui_egui::state::Unsaved; +use super::temp_dir::TempDir; + fn harness(modified: bool) -> Harness<'static, TextureCraftApp> { let mut session = texturecraft_engine::sample_session(256, 64).unwrap(); session.modified = modified; @@ -198,7 +201,7 @@ fn a_mesh_change_keeps_the_answer_for_the_same_project() { answer(&mut h, move |_| Answer::Paths(vec![path.clone()])); invoke(&mut h, "file.saveAs"); h.state_mut().session.mesh_id += 1; - h.run_steps(3); + wait_for(&mut h, |h| h.state().session.path.as_deref() == file.to_str()); assert!(file.exists(), "a reimport or a UV layout change is still the same project"); } @@ -217,6 +220,15 @@ fn sends(h: &mut Harness<'_, TextureCraftApp>, frames: usize, cmd: &ViewportComm }) } +fn wait_for(h: &mut Harness<'_, TextureCraftApp>, ready: impl Fn(&Harness<'_, TextureCraftApp>) -> bool) { + let deadline = Instant::now() + Duration::from_secs(10); + while !ready(h) { + assert!(Instant::now() < deadline, "save did not finish"); + h.step(); + std::thread::yield_now(); + } +} + fn untitled_with_prompt(h: &mut Harness<'_, TextureCraftApp>) { h.state_mut().session.path = None; request_close(h); @@ -236,16 +248,61 @@ fn closing_during_a_stroke_finishes_it_and_asks() { #[test] fn save_in_the_prompt_goes_on_once_the_dialog_has_saved() { - let file = temp_file("prompt-save", "saved.tcraft"); + let temp = TempDir::new("prompt-save"); + for untitled in [true, false] { + let file = temp.join(if untitled { "new.tcraft" } else { "existing.tcraft" }); + let mut h = harness(true); + h.state_mut().session.path = (!untitled).then(|| file.display().to_string()); + request_close(&mut h); + let path = file.clone(); + answer(&mut h, move |_| Answer::Paths(vec![path.clone()])); + h.get_by_label("Save").click(); + wait_for(&mut h, |h| h.output().viewport_output.get(&ViewportId::ROOT).is_some_and(|v| v.commands.contains(&ViewportCommand::Close))); + assert!(file.exists()); + assert!(!h.state().session.modified); + assert!(h.state().ui.windows.unsaved.is_none()); + } +} + +#[test] +fn a_background_save_preserves_edits_made_while_the_file_is_written() { + let temp = TempDir::new("save-edits"); + let file = temp.join("project.tcraft"); let mut h = harness(true); - untitled_with_prompt(&mut h); - let path = file.clone(); - answer(&mut h, move |_| Answer::Paths(vec![path.clone()])); - h.get_by_label("Save").click(); - assert!(sends(&mut h, 5, &ViewportCommand::Close), "the close goes on after the save"); - assert!(file.exists()); - assert!(!h.state().session.modified); - assert!(h.state().ui.windows.unsaved.is_none()); + h.state_mut().session.path = Some(file.display().to_string()); + let original = h.state().session.doc.project.texture_sets[0].name.clone(); + invoke(&mut h, "file.save"); + assert!(!texturecraft_ui_egui::menus::enabled(h.state(), "file.save"), "the save returns with a worker still to collect"); + let rename = h.state_mut().run("textureSet.rename", serde_json::json!({"ts": 0, "name": "Edited while saving"})); + assert!(rename.is_some(), "editing remains available"); + + wait_for(&mut h, |h| texturecraft_ui_egui::menus::enabled(h.state(), "file.save")); + let saved = texturecraft_engine::formats::load_project(&file).unwrap(); + assert_eq!(saved.project.texture_sets[0].name, original, "the first save writes the snapshot it started with"); + assert_eq!(h.state().session.doc.project.texture_sets[0].name, "Edited while saving"); + assert!(h.state().session.modified, "the later edit still needs to be saved"); + + invoke(&mut h, "file.save"); + h.state_mut().run("camera.view.front", serde_json::Value::Null); + wait_for(&mut h, |h| texturecraft_ui_egui::menus::enabled(h.state(), "file.save")); + let saved = texturecraft_engine::formats::load_project(&file).unwrap(); + assert_eq!(saved.project.texture_sets[0].name, "Edited while saving"); + assert!(!h.state().session.modified, "moving the camera alone does not create an unsaved edit"); +} + +#[test] +fn a_failed_background_save_keeps_the_project_and_its_path() { + let temp = TempDir::new("save-failure"); + let file = temp.join("current.tcraft"); + let missing_parent = temp.join("missing").join("as.tcraft"); + let mut h = harness(true); + h.state_mut().session.path = Some(file.display().to_string()); + answer(&mut h, move |_| Answer::Paths(vec![missing_parent.clone()])); + invoke(&mut h, "file.saveAs"); + wait_for(&mut h, |h| h.state().toasts.iter().any(|toast| toast.error)); + assert!(h.state().session.modified); + assert_eq!(h.state().session.path.as_deref(), file.to_str()); + assert!(texturecraft_ui_egui::menus::enabled(h.state(), "file.saveAs")); } #[test] From acfd60b6b11fb02cf12b4620fd59738e0f07bcb5 Mon Sep 17 00:00:00 2001 From: vangel76 Date: Sun, 22 Nov 2026 21:15:47 +0100 Subject: [PATCH 05/83] Highlight texture-set surfaces on hover in the 3D viewport --- crates/render/src/renderer.rs | 49 ++++++++++++++++++----------- crates/render/src/set_highlight.rs | 8 ++--- crates/render/src/shaders/mesh.wgsl | 11 +++++-- crates/ui-egui/src/bake_mode/mod.rs | 5 ++- crates/ui-egui/src/dock.rs | 4 +++ crates/ui-egui/src/lib.rs | 11 +++++++ crates/ui-egui/src/viewport.rs | 13 ++++++-- 7 files changed, 72 insertions(+), 29 deletions(-) diff --git a/crates/render/src/renderer.rs b/crates/render/src/renderer.rs index 5e0561af..8cd7d593 100644 --- a/crates/render/src/renderer.rs +++ b/crates/render/src/renderer.rs @@ -100,6 +100,7 @@ struct GlobalsRaw { refr: [f32; 4], highlight: [f32; 4], highlight_shift: [f32; 4], + set_hover: [f32; 4], bake_high: [f32; 4], bake_matching_error: [f32; 4], bake_cage: [f32; 4], @@ -137,6 +138,9 @@ const HIGHLIGHT_WIDTH_PX: f32 = 1.5; /// Opacity of the highlighted set's edge lines const HIGHLIGHT_OPACITY: f32 = 0.9; +/// Opacity of the texture-set hover tint over the shaded material. +const SET_HOVER_OPACITY: f32 = 0.35; + /// Copies of each highlight line, shifted diagonally to the four corners of its extra width (`vs_wire_highlight`) const HIGHLIGHT_SHIFTS: u32 = 4; @@ -194,6 +198,8 @@ pub struct Shade { pub wireframe_opacity: f32, /// One texture set's mesh edges in a highlight color over the 3D view (the set under a shelf drag) pub highlight: Option, + /// The texture set whose visible surfaces are tinted in the 3D view. + pub set_hover: Option, /// Specular/glossiness shading: base color is the diffuse color and the Specular channel the /// F0 color (roughness arrives as 1 - glossiness from the display conversion). pub spec_gloss: bool, @@ -308,6 +314,7 @@ impl Default for Shade { wireframe_3d: false, wireframe_opacity: 0.4, highlight: None, + set_hover: None, spec_gloss: false, parallax: false, taa: false, @@ -1941,8 +1948,8 @@ impl Renderer { ranges: &'a [(u32, u32, usize)], visible: &'a [bool], only: Option, - ) -> impl Iterator, &'a SetGpu)> + 'a { - drawable_ranges(ranges, &self.material_sets, visible, only).filter_map(|(range, ts)| Some((range, self.sets.get(ts)?))) + ) -> impl Iterator, usize, &'a SetGpu)> + 'a { + drawable_ranges(ranges, &self.material_sets, visible, only).filter_map(|(range, ts)| Some((range, ts, self.sets.get(ts)?))) } /// Keep the key-light shadow map current; returns its view-projection. `light` points to @@ -2003,7 +2010,7 @@ impl Renderer { let geo = m.dense.as_ref().filter(|_| displacing).unwrap_or(&m.geo); pass.set_vertex_buffer(0, geo.vb.slice(..)); pass.set_index_buffer(geo.ib.slice(..), wgpu::IndexFormat::Uint32); - for (range, set) in self.drawable(&geo.draws, visible, None) { + for (range, _, set) in self.drawable(&geo.draws, visible, None) { pass.set_bind_group(1, &set.bind_group, &[]); pass.draw_indexed(range, 0, 0..1); } @@ -2125,8 +2132,9 @@ impl Renderer { fwd: [fwd.x, fwd.y, fwd.z, 0.0], disp, refr: [if refraction { 1.0 } else { 0.0 }, (BEHIND_LEVELS - 1) as f32, REFRACTION_DEPTH * radius, 0.0], - highlight: highlight_globals(s, data), + highlight: highlight_globals(s.highlight, HIGHLIGHT_OPACITY, s, data), highlight_shift: highlight_shift(frame.size), + set_hover: highlight_globals(s.set_hover, SET_HOVER_OPACITY, s, data), ..bake_globals(s.bake) }; let flag = |b: bool| if b { 1.0 } else { 0.0 }; @@ -2214,7 +2222,7 @@ impl Renderer { let geo = self.geometry(m, frame); pass.set_vertex_buffer(0, geo.vb.slice(..)); pass.set_index_buffer(geo.ib.slice(..), wgpu::IndexFormat::Uint32); - for (range, set) in self.drawable(&geo.draws, &frame.visible, None) { + for (range, _, set) in self.drawable(&geo.draws, &frame.visible, None) { pass.set_bind_group(1, &set.bind_group, &[]); pass.draw_indexed(range, 0, 0..1); } @@ -2341,22 +2349,25 @@ impl Renderer { let bake = frame.shade.bake.filter(|_| uv_set.is_none()); let low_poly_shown = bake.is_none_or(|bake| bake.low_poly.shown); let (highlight, highlight_set) = highlight.filter(|(_, set)| low_poly_shown && uv_set.is_none_or(|only| only == *set)).unzip(); + let hover_set = frame.shade.set_hover.filter(|_| uv_set.is_none()).map(|hover| hover.set); // The wireframe and the highlight draw the mesh's own edges (displaced in the vertex shader too) let passes = [ - (low_poly_shown.then_some(mesh_pipeline), &geometry.vb, &geometry.ib, &geometry.draws, uv_set, 1), - (wire.filter(|_| low_poly_shown), &mesh.geo.vb, &mesh.lines, &mesh.line_draws, uv_set, 1), - (highlight, &mesh.geo.vb, &mesh.lines, &mesh.line_draws, highlight_set, HIGHLIGHT_SHIFTS), + (low_poly_shown.then_some(mesh_pipeline), &geometry.vb, &geometry.ib, &geometry.draws, uv_set, 1, hover_set), + (wire.filter(|_| low_poly_shown), &mesh.geo.vb, &mesh.lines, &mesh.line_draws, uv_set, 1, None), + (highlight, &mesh.geo.vb, &mesh.lines, &mesh.line_draws, highlight_set, HIGHLIGHT_SHIFTS, None), ]; - for (pipeline, vertices, indices, ranges, only_set, instances) in passes { + for (pipeline, vertices, indices, ranges, only_set, instances, hover_set) in passes { let Some(pipeline) = pipeline else { continue }; pass.set_pipeline(pipeline); pass.set_vertex_buffer(0, vertices.slice(..)); pass.set_index_buffer(indices.slice(..), wgpu::IndexFormat::Uint32); - for (range, set) in self.drawable(ranges, &frame.visible, only_set) { + for (range, texture_set, set) in self.drawable(ranges, &frame.visible, only_set) { pass.set_bind_group(1, &set.bind_group, &[]); - pass.draw_indexed(range, 0, 0..instances); + // The main mesh shader uses instance index 1 to tint the hovered draw in place. + let first_instance = u32::from(hover_set == Some(texture_set)); + pass.draw_indexed(range, 0, first_instance..first_instance + instances); } } @@ -2370,7 +2381,7 @@ impl Renderer { pass.set_pipeline(&self.uv_missing_seam_pipeline); pass.set_vertex_buffer(0, mesh.geo.vb.slice(..)); pass.set_index_buffer(seams.lines.slice(..), wgpu::IndexFormat::Uint32); - for (range, set) in self.drawable(&seams.line_draws, &frame.visible, Some(texture_set)) { + for (range, _, set) in self.drawable(&seams.line_draws, &frame.visible, Some(texture_set)) { pass.set_bind_group(1, &set.bind_group, &[]); pass.draw_indexed(range, 0, 0..1); } @@ -2404,7 +2415,7 @@ impl Renderer { pass.set_pipeline(&self.missing_seam_pipeline); pass.set_vertex_buffer(0, low_poly.geo.vb.slice(..)); pass.set_index_buffer(seams.lines.slice(..), wgpu::IndexFormat::Uint32); - for (range, set) in self.drawable(&seams.line_draws, &frame.visible, None) { + for (range, _, set) in self.drawable(&seams.line_draws, &frame.visible, None) { pass.set_bind_group(1, &set.bind_group, &[]); pass.draw_indexed(range, 0, 0..1); } @@ -2541,12 +2552,12 @@ fn upload_overlay(device: &wgpu::Device, queue: &wgpu::Queue, view: &mut ViewTar } } -/// Globals `highlight`: the highlight's color and opacity, all zero without one. Data views skip exposure and tone mapping, so they take the color as it is -fn highlight_globals(shade: &Shade, data: bool) -> [f32; 4] { - let Some(highlight) = shade.highlight else { return [0.0; 4] }; +/// The highlight's color and opacity. Data views take the color as it is. +fn highlight_globals(highlight: Option, opacity: f32, shade: &Shade, data: bool) -> [f32; 4] { + let Some(highlight) = highlight else { return [0.0; 4] }; let [r, g, b] = if data { highlight.color } else { highlight.scene_color(shade.exposure_ev, shade.aces) }; - [r, g, b, HIGHLIGHT_OPACITY] + [r, g, b, opacity] } /// The globals of bake mode's overlays and neutral material for `bake` (all zero without it) @@ -2678,8 +2689,8 @@ mod tests { let color = [0.8, 0.25, 0.08]; let shade = Shade { highlight: Some(SetHighlight { set: 0, color }), exposure_ev: 1.0, ..Shade::default() }; - assert_eq!(highlight_globals(&shade, true), [0.8, 0.25, 0.08, HIGHLIGHT_OPACITY]); - assert_ne!(highlight_globals(&shade, false)[..3], color, "the material view undoes exposure and tone mapping"); + assert_eq!(highlight_globals(shade.highlight, HIGHLIGHT_OPACITY, &shade, true), [0.8, 0.25, 0.08, HIGHLIGHT_OPACITY]); + assert_ne!(highlight_globals(shade.highlight, HIGHLIGHT_OPACITY, &shade, false)[..3], color, "the material view undoes exposure and tone mapping"); } #[test] diff --git a/crates/render/src/set_highlight.rs b/crates/render/src/set_highlight.rs index cc29879e..574b5bbd 100644 --- a/crates/render/src/set_highlight.rs +++ b/crates/render/src/set_highlight.rs @@ -1,4 +1,4 @@ -//! A texture set's mesh edges drawn over the 3D view in a highlight color (the set under a shelf drag) +//! Texture-set highlighting in the 3D viewport. /// Brightest on-screen value the tone curve can reach without an infinite scene value const MAX_ACES_SCREEN_VALUE: f32 = 0.99; @@ -6,16 +6,16 @@ const MAX_ACES_SCREEN_VALUE: f32 = 0.99; /// Scene scale the post pass applies before its ACES curve (`aces` in post.wgsl) const ACES_INPUT_SCALE: f32 = 0.6; -/// Draw texture set `set`'s mesh edges over the 3D view in `color` +/// A texture set to highlight in the 3D viewport. #[derive(Clone, Copy, Debug, PartialEq)] pub struct SetHighlight { pub set: usize, - /// The lines' color on screen, linear RGB + /// The highlight color on screen, linear RGB. pub color: [f32; 3], } impl SetHighlight { - /// The scene color the lines are drawn with so that exposure `exposure_ev` and the tone curve (ACES when `aces`) show them in [`Self::color`] + /// The scene color that exposure `exposure_ev` and the tone curve (ACES when `aces`) show as [`Self::color`]. pub fn scene_color(&self, exposure_ev: f32, aces: bool) -> [f32; 3] { scene_color_showing(self.color, exposure_ev, aces) } diff --git a/crates/render/src/shaders/mesh.wgsl b/crates/render/src/shaders/mesh.wgsl index 31fd19df..a98e58f7 100644 --- a/crates/render/src/shaders/mesh.wgsl +++ b/crates/render/src/shaders/mesh.wgsl @@ -26,6 +26,7 @@ struct Globals { refr: vec4, // x screen-space refraction on (1), y lods of the scene behind, z refraction depth (world units), w - highlight: vec4, // rgb highlighted set's edge color in the scene (before exposure and tone mapping), a opacity highlight_shift: vec4, // xy sideways shift of each highlight line copy (clip units), zw - + set_hover: vec4, // rgb hovered set's scene color, a opacity bake_high: vec4, // bake mode: rgb high poly color, a - bake_matching_error: vec4, // rgb color where the bake's rays miss the high poly, a its strength (0 hidden) bake_cage: vec4, // rgb cage surface color, a opacity @@ -70,6 +71,7 @@ struct VOut { @location(1) nrm: vec3, @location(2) tan: vec4, @location(3) uv: vec2, + @location(4) @interpolate(flat) hover: u32, }; // The vertex moved along its normal by the height channel (displacement). @@ -81,7 +83,7 @@ fn displaced(v: VIn) -> vec3 { } @vertex -fn vs_mesh(v: VIn) -> VOut { +fn vs_mesh(v: VIn, @builtin(instance_index) instance: u32) -> VOut { var o: VOut; let p = displaced(v); o.clip = g.view_proj * vec4(p, 1.0); @@ -89,6 +91,7 @@ fn vs_mesh(v: VIn) -> VOut { o.nrm = v.nrm; o.tan = v.tan; o.uv = v.uv; + o.hover = instance; return o; } @@ -359,7 +362,11 @@ fn mesh_color(i: VOut, front: bool) -> vec4 { @fragment fn fs_mesh(i: VOut, @builtin(front_facing) front: bool) -> @location(0) vec4 { - return mesh_color(i, front); + let color = mesh_color(i, front); + if (i.hover == 1u) { + return vec4(mix(color.rgb, g.set_hover.rgb * color.a, g.set_hover.a), color.a); + } + return color; } // The scene behind transmissive surfaces: everything but them (what they refract). diff --git a/crates/ui-egui/src/bake_mode/mod.rs b/crates/ui-egui/src/bake_mode/mod.rs index 2ae7f095..d3ad244d 100644 --- a/crates/ui-egui/src/bake_mode/mod.rs +++ b/crates/ui-egui/src/bake_mode/mod.rs @@ -42,7 +42,7 @@ pub fn texture_sets(app: &mut TextureCraftApp, ui: &mut Ui) { .collect(); ui.push_id(set_index, |ui| { - ui.horizontal(|ui| { + let row = ui.horizontal(|ui| { let button_size = ui.spacing().interact_size.y; if icon_button(ui, if visible { icon::EYE } else { icon::EYE_SLASH }, tr("Show or hide the texture set"), false, button_size).clicked() { app.run("textureSet.visible", json!({ "ts": set_index })); @@ -68,6 +68,9 @@ pub fn texture_sets(app: &mut TextureCraftApp, ui: &mut Ui) { app.start_resize(set_index, selected); } }); + if ui.is_enabled() && ui.rect_contains_pointer(row.response.rect) { + app.next_hovered_texture_set = Some((app.session.project_id, set_index)); + } if !tiles.is_empty() { egui::CollapsingHeader::new(format!("{} ({})", tr("UV tiles (UDIM)"), tiles.len())).default_open(true).show(ui, |ui| { diff --git a/crates/ui-egui/src/dock.rs b/crates/ui-egui/src/dock.rs index 7f8cebfe..7ae97179 100644 --- a/crates/ui-egui/src/dock.rs +++ b/crates/ui-egui/src/dock.rs @@ -85,6 +85,7 @@ pub(crate) fn texture_set_list(app: &mut TextureCraftApp, ui: &mut Ui) { egui::ScrollArea::vertical().id_salt("ts_scroll").show(ui, |ui| { for (i, (name, size, visible)) in sets.into_iter().enumerate() { let (rect, resp) = ui.allocate_exact_size(vec2(ui.available_width(), 22.0), Sense::click()); + resp.widget_info(|| egui::WidgetInfo::selected(egui::Role::ListItem, ui.is_enabled(), i == active, &name)); let p = ui.painter(); let bg = if i == active { tk.row_selected @@ -99,6 +100,9 @@ pub(crate) fn texture_set_list(app: &mut TextureCraftApp, ui: &mut Ui) { } let eye = Rect::from_min_size(rect.min + vec2(4.0, 3.0), vec2(16.0, 16.0)); let eye_resp = ui.interact(eye, ui.scope_id().with(("ts_eye", i)), Sense::click()).on_hover_text(tr("Show or hide the texture set")); + if ui.is_enabled() && (resp.contains_pointer() || eye_resp.contains_pointer()) { + app.next_hovered_texture_set = Some((app.session.project_id, i)); + } p.text(eye.center(), egui::Align2::CENTER_CENTER, if visible { ic::EYE } else { ic::EYE_SLASH }, egui::FontId::proportional(13.0), tk.text); // Narrow panels drop the shader label, then the resolution, before cutting the name diff --git a/crates/ui-egui/src/lib.rs b/crates/ui-egui/src/lib.rs index 1a8508eb..3873a915 100644 --- a/crates/ui-egui/src/lib.rs +++ b/crates/ui-egui/src/lib.rs @@ -223,6 +223,10 @@ pub struct TextureCraftApp { pub layer_panel: layer_panel::LayerPanel, /// Last frame's viewport rect (logical points), for scripted input. pub viewport_rect: egui::Rect, + /// Project and texture-set index from the last completed UI pass. + hovered_texture_set: Option<(u64, usize)>, + /// The set under the pointer in this pass, independent of dock drawing order. + next_hovered_texture_set: Option<(u64, usize)>, pub fps: f32, /// User smart materials found in the library folder (refreshed on demand). pub library: Option>, @@ -339,6 +343,8 @@ impl TextureCraftApp { thumbs: thumbs::Thumbs::default(), layer_panel: layer_panel::LayerPanel::default(), viewport_rect: egui::Rect::NOTHING, + hovered_texture_set: None, + next_hovered_texture_set: None, fps: 0.0, ui_ms: 0.0, profiler: profile::Profiler::default(), @@ -1078,6 +1084,11 @@ impl eframe::App for TextureCraftApp { // The dock keeps the cards' gutter from the bars and rails around it let panel_frame = if hide_ui { egui::Frame::NONE.fill(tokens.viewport) } else { egui::Frame::NONE.fill(tokens.chrome).inner_margin(theme::GUTTER) }; egui::CentralPanel::default().frame(panel_frame).show(ui, |ui| if hide_ui { viewport::central(self, ui) } else { docking::show(self, ui) }); + let hovered = self.next_hovered_texture_set.take(); + if self.hovered_texture_set != hovered { + self.hovered_texture_set = hovered; + ctx.request_repaint(); + } windows::show(self, &ctx); // Finish after the dock and windows have requested their thumbnails diff --git a/crates/ui-egui/src/viewport.rs b/crates/ui-egui/src/viewport.rs index 97edafed..5efee825 100644 --- a/crates/ui-egui/src/viewport.rs +++ b/crates/ui-egui/src/viewport.rs @@ -372,9 +372,12 @@ fn shade(app: &TextureCraftApp) -> Shade { /// The texture set a shelf material or image dragged over the 3D view `response` would drop on, its edges drawn in the accent color fn drop_highlight(app: &TextureCraftApp, ui: &Ui, response: &egui::Response) -> Option { let set = crate::shelf::drop_set(app, ui, response)?; - let accent = egui::Rgba::from(Tokens::get(ui.ctx()).viewport_accent); + Some(set_highlight(ui, set)) +} - Some(SetHighlight { set, color: [accent.r(), accent.g(), accent.b()] }) +fn set_highlight(ui: &Ui, set: usize) -> SetHighlight { + let accent = egui::Rgba::from(Tokens::get(ui.ctx()).viewport_accent); + SetHighlight { set, color: [accent.r(), accent.g(), accent.b()] } } /// Show what the GPU side reported (each message once while its toast is up). @@ -1010,12 +1013,16 @@ fn view_3d(app: &mut TextureCraftApp, ui: &mut Ui, rect: Rect, sync: &mut Pendin } } + let set_hover = app + .hovered_texture_set + .filter(|&(project_id, _)| project_id == app.session.project_id && !app.ui.hide_ui && !crate::docking::input_blocked(app, ui.ctx())) + .map(|(_, set)| set_highlight(ui, set)); let frame = Frame { view_id: crate::viewport::VIEW_3D, size: frame_size_in_pixels(ui, rect), kind: ViewKind::Scene, camera: app.session.camera, - shade: Shade { highlight: drop_highlight(app, ui, &response), ..shade(app) }, + shade: Shade { highlight: drop_highlight(app, ui, &response), set_hover, ..shade(app) }, visible: app.session.doc.project.texture_sets.iter().map(|texture_set| texture_set.visible).collect(), overlay: crate::symmetry::scene_overlay(app, ui, rect), }; From f5e5932539824064b55aa4314cb6d77e27ffcbf7 Mon Sep 17 00:00:00 2001 From: vangel76 Date: Sun, 22 Nov 2026 21:19:56 +0100 Subject: [PATCH 06/83] Scope export scroll check to the dialog buttons --- crates/ui-egui/src/windows.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/ui-egui/src/windows.rs b/crates/ui-egui/src/windows.rs index 0624e1be..ebc2cd76 100644 --- a/crates/ui-egui/src/windows.rs +++ b/crates/ui-egui/src/windows.rs @@ -670,7 +670,7 @@ mod tests { harness.state_mut().ui.windows.export = true; harness.run_steps(5); let footer = harness.get_by_role_and_label(egui::Role::Button, "Reset all").rect(); - let first = harness.get_by_label("Export set 1"); + let first = harness.get_by_role_and_label(egui::Role::Button, "Export set 1"); first.hover(); harness.run_steps(2); @@ -682,7 +682,7 @@ mod tests { source: egui::MouseWheelSource::Wheel, }); harness.run_steps(15); - let last = harness.get_by_label("Export set 39"); + let last = harness.get_by_role_and_label(egui::Role::Button, "Export set 39"); last.click(); harness.run_steps(4); From 2e551bbd60861756ad55b7ed198df05786ea6514 Mon Sep 17 00:00:00 2001 From: vangel76 Date: Sun, 22 Nov 2026 23:21:13 +0100 Subject: [PATCH 07/83] Wait for the background save in the rename anchor tests --- crates/ui-egui/tests/it/rename_anchor.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/crates/ui-egui/tests/it/rename_anchor.rs b/crates/ui-egui/tests/it/rename_anchor.rs index f8ee1763..3f0b57c3 100644 --- a/crates/ui-egui/tests/it/rename_anchor.rs +++ b/crates/ui-egui/tests/it/rename_anchor.rs @@ -42,7 +42,14 @@ fn save_to(h: &mut Harness<'_, TextureCraftApp>, file: &Path) { h.state_mut().file_dialogs.set_override(Some(Box::new(move |_| Answer::Paths(vec![path.clone()])))); let ctx = h.ctx.clone(); texturecraft_ui_egui::menus::invoke(h.state_mut(), &ctx, "file.saveAs"); - h.run_steps(3); + // The save runs on a worker: step frames until the app has collected it, as the app does + let deadline = std::time::Instant::now() + std::time::Duration::from_secs(10); + h.step(); + while h.state().session.modified || !texturecraft_ui_egui::menus::enabled(h.state(), "file.saveAs") { + assert!(std::time::Instant::now() < deadline, "the save did not finish"); + h.step(); + std::thread::yield_now(); + } assert!(file.exists(), "Save as wrote the project"); assert!(!h.state().session.modified, "the project counts as saved"); } From dd00c4e04d41cfee638ab0ad0268ca5ac74851b2 Mon Sep 17 00:00:00 2001 From: vangel76 Date: Sun, 22 Nov 2026 23:22:02 +0100 Subject: [PATCH 08/83] Blend the hover tint with the blurred scattering light and fix the export tree test query --- crates/render/src/shaders/mesh.wgsl | 5 +++++ crates/render/tests/headless.rs | 25 ++++++++++++++++++++++ crates/ui-egui/tests/it/export_progress.rs | 2 +- 3 files changed, 31 insertions(+), 1 deletion(-) diff --git a/crates/render/src/shaders/mesh.wgsl b/crates/render/src/shaders/mesh.wgsl index a98e58f7..f780c4fc 100644 --- a/crates/render/src/shaders/mesh.wgsl +++ b/crates/render/src/shaders/mesh.wgsl @@ -388,6 +388,11 @@ fn fs_gbuf(i: VOut, @builtin(front_facing) front: bool) -> @location(0) vec4(0.0); if (g.scatter.w > 0.5) { sss = shade_mesh(i, front).sss; + if (i.hover == 1u) { + // fs_mesh mixes the hover tint into the color without this light; the blur pass adds it + // back unblended, so scale it by the share of the color that stays + sss = sss * (1.0 - g.set_hover.a); + } } else if (textureSample(t_base, samp, i.uv).a < hash12(i.clip.xy)) { discard; } diff --git a/crates/render/tests/headless.rs b/crates/render/tests/headless.rs index e4ddad39..dcaeefb2 100644 --- a/crates/render/tests/headless.rs +++ b/crates/render/tests/headless.rs @@ -1072,6 +1072,31 @@ fn subsurface_blur_spreads_only_scattering_light() { assert!((m1 - m0).abs() < 2.0, "the blur moves light, it adds none: {m0} -> {m1}"); } +#[test] +fn the_hover_tint_covers_the_blurred_scattering_light_too() { + let Some((mut h, frame)) = setup() else { return }; + let lit = shaded(&frame, |s| s.light = LIGHT); + let mask = mesh_mask(&mut h, &lit, &[0]); + fill(&mut h, &[0, 1], DisplayKind::BaseColor, &[150, 150, 150, 255]); + fill(&mut h, &[0, 1], DisplayKind::Emissive, &[0, 0, 0, 255]); + let blur = shaded(&lit, |s| s.sss_blur = Some([0.06, 0.024, 0.015])); + let hover = |f: &Frame| shaded(f, |s| s.set_hover = Some(texturecraft_render::SetHighlight { set: 0, color: [1.0, 0.5, 0.0] })); + let mean = |img: &Img| region_mean(&mask, |x, y| img.luma(x, y)); + let plain = mean(&render(&mut h, &lit, "hover_sss_plain")); + let blurred = mean(&render(&mut h, &blur, "hover_sss_blur")); + let hovered_plain = mean(&render(&mut h, &hover(&lit), "hover_sss_plain_hovered")); + let hovered_blur = mean(&render(&mut h, &hover(&blur), "hover_sss_blur_hovered")); + assert!(hovered_plain != plain, "the hover tint changes the set"); + // The blur only moves light around, so it must change a hovered set as little as a plain one + // (the scattering light restored by the blur pass is blended with the tint as well) + assert!( + ((hovered_blur - hovered_plain) - (blurred - plain)).abs() < 3.0, + "the blur changes the plain set by {} and the hovered set by {}", + blurred - plain, + hovered_blur - hovered_plain + ); +} + /// An environment that is bright only around `dir` (world space, rotation 0). fn spot_environment(dir: texturecraft_geom::glam::Vec3) -> ImageRes { let (w, hh) = (256u32, 128u32); diff --git a/crates/ui-egui/tests/it/export_progress.rs b/crates/ui-egui/tests/it/export_progress.rs index 84015102..8f929ca7 100644 --- a/crates/ui-egui/tests/it/export_progress.rs +++ b/crates/ui-egui/tests/it/export_progress.rs @@ -124,7 +124,7 @@ fn the_list_is_a_tree_per_texture_set_with_the_console_beside_it() { h.state_mut().ui.export.tab = 2; h.run_steps(4); let set = h.state().session.doc.project.texture_sets[0].name.clone(); - assert!(h.query_by_label(&set).is_some()); + assert!(h.query_by_role_and_label(egui::Role::DisclosureTriangle, &set).is_some(), "the export tree has a node for the set (the dock list row carries the same name)"); assert!(h.query_all_by_label("256x256 (Texture Set size)").next().is_some()); assert!(h.query_all_by_label("png").next().is_some() && h.query_all_by_label("16 bits").next().is_some()); assert!(h.query_by_label("Include all").is_none() && h.query_by_label("Reset all").is_none()); From 34e8bb0d92107bdd7110ff11e5567b40e2de2004 Mon Sep 17 00:00:00 2001 From: vangel76 Date: Sun, 22 Nov 2026 23:22:49 +0100 Subject: [PATCH 09/83] Open the inherited mask effects from an instance's mask thumbnail --- crates/engine/src/layer_cmds.rs | 11 +++++++-- crates/ui-egui/src/dock.rs | 22 +++++++++++------- crates/ui-egui/tests/it/layers_panel.rs | 30 +++++++++++++++++++++++++ 3 files changed, 53 insertions(+), 10 deletions(-) diff --git a/crates/engine/src/layer_cmds.rs b/crates/engine/src/layer_cmds.rs index 56d2fc2e..b7b38f76 100644 --- a/crates/engine/src/layer_cmds.rs +++ b/crates/engine/src/layer_cmds.rs @@ -297,8 +297,9 @@ fn select(s: &mut Session, p: &Value) -> Result { } Some(Value::String(t)) if t == "content" => StackTarget::Content, Some(v) => match v.as_u64() { - Some(e) if s.doc.project.effect(LayerId(e)).is_some_and(|(owner, _)| owner == id) => StackTarget::Effect(LayerId(e)), - _ => return Err(bad("layer.select", "target must be content, mask or an effect id of this layer")), + // An instance without a mask of its own edits the effects of the mask it draws with, as it edits that mask + Some(e) if selectable_effect(&s.doc.project, id, LayerId(e)) => StackTarget::Effect(LayerId(e)), + _ => return Err(bad("layer.select", "target must be content, mask or an effect id of this layer or of the mask it draws with")), }, None => StackTarget::Content, }; @@ -307,6 +308,12 @@ fn select(s: &mut Session, p: &Value) -> Result { Ok(json!({ "layer": id.0, "textureSet": ts, "layers": [id.0] })) } +/// Whether effect `effect` can be selected on layer `id`: one of its own, or one in the mask it draws with. +fn selectable_effect(project: &texturecraft_core::Project, id: LayerId, effect: LayerId) -> bool { + let Some((owner, _)) = project.effect(effect) else { return false }; + owner == id || (owner == project.mask_owner(id) && project.layers.get(&owner).and_then(|l| l.mask.as_ref()).is_some_and(|mask| mask.effects.iter().any(|e| e.id == effect))) +} + fn rename(s: &mut Session, p: &Value) -> Result { let id = layer_param(s, "layer.rename", p)?; let name = strp(p, "name").map(str::trim).filter(|n| !n.is_empty()).ok_or_else(|| bad("layer.rename", "`name` is required"))?.to_string(); diff --git a/crates/ui-egui/src/dock.rs b/crates/ui-egui/src/dock.rs index 9136689f..d3262ea4 100644 --- a/crates/ui-egui/src/dock.rs +++ b/crates/ui-egui/src/dock.rs @@ -7,7 +7,7 @@ use serde_json::{Value, json}; use texturecraft_engine::compose::ThumbTarget; use texturecraft_engine::core::{ BakedMap, BlendMode, Channel, ChannelBlend, ChannelKind, Decal, DecalFlip, Effect, EffectKind, Fill, Filter, Layer, LayerId, LayerKind, LinkParam, - MaterialLink, Projection, Source, + MaterialLink, Project, Projection, Source, }; use texturecraft_engine::filter_lib::scalar_params; use texturecraft_engine::paint::alpha_params::MAX_ALPHA_CONTRAST; @@ -249,9 +249,10 @@ pub(crate) fn layers(app: &mut TextureCraftApp, ui: &mut Ui) { select_all_layers(app, ui); // A thumbnail or selection can close the editor before its TextEdit sees lost focus. if let Some((id, _)) = &app.ui.rename - && let Some((owner, _)) = app.session.doc.project.effect(LayerId(*id)) + && app.session.doc.project.effect(LayerId(*id)).is_some() && app.layer_panel.expanded_effects.is_none_or(|(layer, in_mask)| { - layer != owner || !app.session.doc.project.layers.get(&layer).is_some_and(|l| stack_effects(l, in_mask).iter().any(|e| e.id.0 == *id)) + let project = &app.session.doc.project; + !project.layers.get(&layer).is_some_and(|l| stack_effects(project, l, in_mask).iter().any(|e| e.id.0 == *id)) }) { finish_effect_rename(app); @@ -497,8 +498,13 @@ fn level_x(left: f32, level: usize) -> f32 { left + ROW_LEFT_PADDING + level as f32 * INDENT + EYE_SIZE * 0.5 } -fn stack_effects(layer: &Layer, in_mask: bool) -> &[Effect] { - if in_mask { layer.mask.as_ref().map_or(&[], |mask| &mask.effects) } else { &layer.content_effects } +/// The effects `layer` lists in its mask (the mask it draws with, so an instance without its own shows its source's) or content. +fn stack_effects(project: &Project, layer: &Layer, in_mask: bool) -> Vec { + if in_mask { + project.layers.get(&project.mask_owner(layer.id)).and_then(|owner| owner.mask.as_ref()).map_or_else(Vec::new, |mask| mask.effects.clone()) + } else { + layer.content_effects.clone() + } } fn layer_tree(app: &mut TextureCraftApp, ui: &mut Ui, id: LayerId, depth: usize, count: &mut usize) { @@ -510,9 +516,9 @@ fn layer_tree(app: &mut TextureCraftApp, ui: &mut Ui, id: LayerId, depth: usize, if let Some((open_layer, in_mask)) = app.layer_panel.expanded_effects && open_layer == id { - let stack = stack_effects(&layer, in_mask); + let stack = stack_effects(&app.session.doc.project, &layer, in_mask); for (index, effect) in stack.iter().rev().enumerate() { - effect_row(app, ui, &layer, stack, effect, index, depth + 2, index + 1 == stack.len(), in_mask); + effect_row(app, ui, &layer, &stack, effect, index, depth + 2, index + 1 == stack.len(), in_mask); } } @@ -715,7 +721,7 @@ fn layer_row(app: &mut TextureCraftApp, ui: &mut Ui, layer: &Layer, depth: usize let mask_response = ui .interact(mask_rect, ui.scope_id().with(("mask", layer.id.0)), Sense::click()) .on_hover_text(tr("Select the mask (Alt+click: show it in the viewport)")); - let mask_stack = layer.mask.as_ref().filter(|mask| !mask.effects.is_empty()).map(|_| (layer.id, true)); + let mask_stack = (!mask.effects.is_empty()).then_some((layer.id, true)); effect_stack_thumbnail( app, &painter, diff --git a/crates/ui-egui/tests/it/layers_panel.rs b/crates/ui-egui/tests/it/layers_panel.rs index 4deeadc6..5955a4a5 100644 --- a/crates/ui-egui/tests/it/layers_panel.rs +++ b/crates/ui-egui/tests/it/layers_panel.rs @@ -49,6 +49,36 @@ fn click(h: &mut Harness<'_, TextureCraftApp>, at: egui::Pos2) { h.run_steps(3); } +/// An instance without a mask of its own shows its source's mask thumbnail with the effect badge, so +/// that thumbnail opens the source mask's effects and each of those rows can be selected from the instance. +#[test] +fn an_instance_mask_thumbnail_opens_the_inherited_mask_effects() { + let (mut h, source) = harness(); + let instance = LayerId(id(execute(&mut h.state_mut().session, "layer.instance", &json!({"layer": source.0})).unwrap(), "layer")); + execute(&mut h.state_mut().session, "layer.rename", &json!({"layer": instance.0, "name": "Instance row"})).unwrap(); + execute(&mut h.state_mut().session, "layer.select", &json!({"layer": instance.0})).unwrap(); + h.run_steps(4); + assert!(h.state().session.doc.project.layers[&instance].mask.is_none(), "the instance draws with its source's mask"); + assert!(h.query_by_label("Effect M").is_none(), "stacks start closed"); + + let mask = thumb(&h, "Instance row", true); + click(&mut h, mask); + assert_eq!(h.state().session.selected_layer(), Some(instance)); + assert_eq!(h.state().session.target, StackTarget::Mask); + assert!(h.query_by_label("Effect M").is_some(), "the inherited mask effect is listed"); + click(&mut h, mask); + assert!(h.query_by_label("Effect M").is_none(), "the same thumbnail closes the stack"); + click(&mut h, mask); + + // Selecting the inherited effect through the instance keeps the instance selected and the stack open + let row = h.get_by_label("Effect M").rect(); + click(&mut h, row.center()); + let StackTarget::Effect(effect) = h.state().session.target else { panic!("{:?}", h.state().session.target) }; + assert_eq!(h.state().session.doc.project.effect(effect).map(|(owner, _)| owner), Some(source)); + assert_eq!(h.state().session.selected_layer(), Some(instance)); + assert!(h.query_by_label("Effect M").is_some(), "selecting an effect leaves its stack open"); +} + #[test] fn mask_and_content_thumbnails_toggle_their_own_stacks() { let (mut h, layer) = harness(); From 04e835fcf47b1145e95b689ff922ad6f6173310f Mon Sep 17 00:00:00 2001 From: vangel76 Date: Sun, 22 Nov 2026 23:32:05 +0100 Subject: [PATCH 10/83] Fail the save wait on an error toast and wait for the saved path --- crates/ui-egui/tests/it/rename_anchor.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/crates/ui-egui/tests/it/rename_anchor.rs b/crates/ui-egui/tests/it/rename_anchor.rs index 3f0b57c3..7ff9dfac 100644 --- a/crates/ui-egui/tests/it/rename_anchor.rs +++ b/crates/ui-egui/tests/it/rename_anchor.rs @@ -45,7 +45,11 @@ fn save_to(h: &mut Harness<'_, TextureCraftApp>, file: &Path) { // The save runs on a worker: step frames until the app has collected it, as the app does let deadline = std::time::Instant::now() + std::time::Duration::from_secs(10); h.step(); - while h.state().session.modified || !texturecraft_ui_egui::menus::enabled(h.state(), "file.saveAs") { + let target = file.display().to_string(); + while !(file.exists() && h.state().session.path.as_deref() == Some(target.as_str()) && texturecraft_ui_egui::menus::enabled(h.state(), "file.saveAs")) { + if let Some(toast) = h.state().toasts.iter().find(|toast| toast.error) { + panic!("the save failed: {}", toast.text); + } assert!(std::time::Instant::now() < deadline, "the save did not finish"); h.step(); std::thread::yield_now(); From 7d2e1523a84ed1f3da82e52b0de2f5c379b27671 Mon Sep 17 00:00:00 2001 From: vangel76 Date: Sun, 22 Nov 2026 23:40:09 +0100 Subject: [PATCH 11/83] Test inherited mask effect selection from an instance and document it --- crates/engine/src/layer_cmds.rs | 4 ++- crates/engine/tests/it/content_effects.rs | 34 +++++++++++++++++++++++ crates/ui-egui/tests/it/layers_panel.rs | 18 ++++++++++++ docs/control-protocol.md | 2 +- 4 files changed, 56 insertions(+), 2 deletions(-) diff --git a/crates/engine/src/layer_cmds.rs b/crates/engine/src/layer_cmds.rs index b7b38f76..8823112f 100644 --- a/crates/engine/src/layer_cmds.rs +++ b/crates/engine/src/layer_cmds.rs @@ -311,7 +311,9 @@ fn select(s: &mut Session, p: &Value) -> Result { /// Whether effect `effect` can be selected on layer `id`: one of its own, or one in the mask it draws with. fn selectable_effect(project: &texturecraft_core::Project, id: LayerId, effect: LayerId) -> bool { let Some((owner, _)) = project.effect(effect) else { return false }; - owner == id || (owner == project.mask_owner(id) && project.layers.get(&owner).and_then(|l| l.mask.as_ref()).is_some_and(|mask| mask.effects.iter().any(|e| e.id == effect))) + owner == id + || (owner == project.mask_owner(id) + && project.layers.get(&owner).and_then(|l| l.mask.as_ref()).is_some_and(|mask| mask.effects.iter().any(|e| e.id == effect))) } fn rename(s: &mut Session, p: &Value) -> Result { diff --git a/crates/engine/tests/it/content_effects.rs b/crates/engine/tests/it/content_effects.rs index 4b761fc8..47c6b8fe 100644 --- a/crates/engine/tests/it/content_effects.rs +++ b/crates/engine/tests/it/content_effects.rs @@ -179,6 +179,40 @@ fn anchor_effects_added_through_instance_validate_against_source() { assert!(session.doc.project.layer(LayerId(source)).unwrap().mask.is_none()); } +#[test] +fn an_instance_selects_the_effects_of_the_mask_it_draws_with() { + let mut s = session(); + let source = id(execute(&mut s, "layer.add.fill", &json!({"height": 0.5})).unwrap(), "layer"); + execute(&mut s, "mask.add.black", &Value::Null).unwrap(); + let source_mask = id(execute(&mut s, "effect.add.generator", &json!({"generator": "position", "level": 0.5})).unwrap(), "effect"); + let source_content = id(execute(&mut s, "effect.add.filter", &json!({"target": "content", "filter": "invert"})).unwrap(), "effect"); + let other = id(execute(&mut s, "layer.add.fill", &Value::Null).unwrap(), "layer"); + execute(&mut s, "mask.add.black", &Value::Null).unwrap(); + let other_mask = id(execute(&mut s, "effect.add.generator", &json!({"generator": "position", "level": 0.5})).unwrap(), "effect"); + let instance = id(execute(&mut s, "layer.instance", &json!({"layer": source})).unwrap(), "layer"); + let select = |s: &mut Session, effect: u64| execute(s, "layer.select", &json!({"layer": instance, "target": effect})); + + // Without a mask of its own the instance draws with the source's, so it selects that mask's effects + select(&mut s, source_mask).unwrap(); + assert_eq!(s.selected_layer(), Some(LayerId(instance))); + assert_eq!(s.target, StackTarget::Effect(LayerId(source_mask))); + + // Content effects of the source and effects of unrelated layers stay out of reach + for effect in [source_content, other_mask] { + let error = select(&mut s, effect).unwrap_err().to_string(); + assert!(error.contains("an effect id of this layer or of the mask it draws with"), "{error}"); + } + assert_ne!(other, instance); + + // An instance with its own mask draws with that one: the source's mask effects are not its own + execute(&mut s, "layer.select", &json!({"layer": instance})).unwrap(); + execute(&mut s, "mask.add.black", &Value::Null).unwrap(); + let own = id(execute(&mut s, "effect.add.generator", &json!({"generator": "position", "level": 0.5})).unwrap(), "effect"); + assert!(select(&mut s, source_mask).is_err()); + select(&mut s, own).unwrap(); + assert_eq!(s.target, StackTarget::Effect(LayerId(own))); +} + #[test] fn painting_into_a_content_paint_effect() { let mut s = session(); diff --git a/crates/ui-egui/tests/it/layers_panel.rs b/crates/ui-egui/tests/it/layers_panel.rs index 5955a4a5..d3bde0a3 100644 --- a/crates/ui-egui/tests/it/layers_panel.rs +++ b/crates/ui-egui/tests/it/layers_panel.rs @@ -79,6 +79,24 @@ fn an_instance_mask_thumbnail_opens_the_inherited_mask_effects() { assert!(h.query_by_label("Effect M").is_some(), "selecting an effect leaves its stack open"); } +/// An instance with a mask of its own lists that mask's effects, not its source's. +#[test] +fn an_instance_with_its_own_mask_opens_its_own_mask_effects() { + let (mut h, source) = harness(); + let instance = LayerId(id(execute(&mut h.state_mut().session, "layer.instance", &json!({"layer": source.0})).unwrap(), "layer")); + execute(&mut h.state_mut().session, "layer.rename", &json!({"layer": instance.0, "name": "Instance row"})).unwrap(); + execute(&mut h.state_mut().session, "layer.select", &json!({"layer": instance.0})).unwrap(); + execute(&mut h.state_mut().session, "mask.add.black", &Value::Null).unwrap(); + execute(&mut h.state_mut().session, "effect.add.generator", &json!({"generator": "position", "level": 0.5, "name": "Own effect"})).unwrap(); + execute(&mut h.state_mut().session, "layer.select", &json!({"layer": instance.0})).unwrap(); + h.run_steps(4); + + let mask = thumb(&h, "Instance row", true); + click(&mut h, mask); + assert!(h.query_by_label("Own effect").is_some(), "the instance's own mask effect is listed"); + assert!(h.query_by_label("Effect M").is_none(), "the source's mask effect is not"); +} + #[test] fn mask_and_content_thumbnails_toggle_their_own_stacks() { let (mut h, layer) = harness(); diff --git a/docs/control-protocol.md b/docs/control-protocol.md index bd11cb2d..cb29d5ba 100644 --- a/docs/control-protocol.md +++ b/docs/control-protocol.md @@ -20,7 +20,7 @@ one just above itself. `effect.copy {effect?}` and `effect.cut {effect?}` put an layer clipboard, and `effect.paste {layer?, target?}` adds it to another layer's content or mask. `layer.select {layers: [id], layer?}` selects several layers of one texture set at once (`layer` is the active one), and `{layer, range: true}` / `{layer, toggle: true}` do what Shift+click and -Ctrl+click do in the Layers panel. `layer.select {all: true}` (Ctrl+A with the pointer over the +Ctrl+click do in the Layers panel. `layer.select {layer, target}` takes `content`, `mask` or an effect id: one of the layer, or of the mask it draws with. `layer.select {all: true}` (Ctrl+A with the pointer over the Layers panel) selects every shown row of the active texture set: the folder rows and the layers of open folders, not the layers of collapsed ones. `{layer, toggle: true}` on the only selected layer leaves nothing selected. `layer.visible {layers, layer}` gives every listed layer the From d49f75ecd9eb341c179c6c0bd81e7909cc49295b Mon Sep 17 00:00:00 2001 From: vangel76 Date: Sun, 22 Nov 2026 23:41:37 +0100 Subject: [PATCH 12/83] Pass the hovered set to the subsurface G-buffer pass --- crates/render/src/renderer.rs | 7 +++++-- crates/render/tests/headless.rs | 2 +- crates/ui-egui/tests/it/export_progress.rs | 5 ++++- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/crates/render/src/renderer.rs b/crates/render/src/renderer.rs index 8cd7d593..c91f2404 100644 --- a/crates/render/src/renderer.rs +++ b/crates/render/src/renderer.rs @@ -2222,9 +2222,12 @@ impl Renderer { let geo = self.geometry(m, frame); pass.set_vertex_buffer(0, geo.vb.slice(..)); pass.set_index_buffer(geo.ib.slice(..), wgpu::IndexFormat::Uint32); - for (range, _, set) in self.drawable(&geo.draws, &frame.visible, None) { + // As in the main pass, instance index 1 marks the hovered set (fs_gbuf scales its scattering light) + let hover_set = frame.shade.set_hover.filter(|_| frame.kind == ViewKind::Scene).map(|hover| hover.set); + for (range, texture_set, set) in self.drawable(&geo.draws, &frame.visible, None) { pass.set_bind_group(1, &set.bind_group, &[]); - pass.draw_indexed(range, 0, 0..1); + let first_instance = u32::from(hover_set == Some(texture_set)); + pass.draw_indexed(range, 0, first_instance..first_instance + 1); } } diff --git a/crates/render/tests/headless.rs b/crates/render/tests/headless.rs index dcaeefb2..781933f6 100644 --- a/crates/render/tests/headless.rs +++ b/crates/render/tests/headless.rs @@ -1090,7 +1090,7 @@ fn the_hover_tint_covers_the_blurred_scattering_light_too() { // The blur only moves light around, so it must change a hovered set as little as a plain one // (the scattering light restored by the blur pass is blended with the tint as well) assert!( - ((hovered_blur - hovered_plain) - (blurred - plain)).abs() < 3.0, + ((hovered_blur - hovered_plain) - (blurred - plain)).abs() < 1.0, "the blur changes the plain set by {} and the hovered set by {}", blurred - plain, hovered_blur - hovered_plain diff --git a/crates/ui-egui/tests/it/export_progress.rs b/crates/ui-egui/tests/it/export_progress.rs index 8f929ca7..afb0b320 100644 --- a/crates/ui-egui/tests/it/export_progress.rs +++ b/crates/ui-egui/tests/it/export_progress.rs @@ -124,7 +124,10 @@ fn the_list_is_a_tree_per_texture_set_with_the_console_beside_it() { h.state_mut().ui.export.tab = 2; h.run_steps(4); let set = h.state().session.doc.project.texture_sets[0].name.clone(); - assert!(h.query_by_role_and_label(egui::Role::DisclosureTriangle, &set).is_some(), "the export tree has a node for the set (the dock list row carries the same name)"); + assert!( + h.query_by_role_and_label(egui::Role::DisclosureTriangle, &set).is_some(), + "the export tree has a node for the set (the dock list row carries the same name)" + ); assert!(h.query_all_by_label("256x256 (Texture Set size)").next().is_some()); assert!(h.query_all_by_label("png").next().is_some() && h.query_all_by_label("16 bits").next().is_some()); assert!(h.query_by_label("Include all").is_none() && h.query_by_label("Reset all").is_none()); From 3fc5d23b9f428321d65fb69ffb9df0487cfe5c95 Mon Sep 17 00:00:00 2001 From: vangel76 Date: Sun, 22 Nov 2026 23:42:58 +0100 Subject: [PATCH 13/83] Expect an instance to select its source mask effect in the decal frame test --- crates/ui-egui/src/viewport.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/crates/ui-egui/src/viewport.rs b/crates/ui-egui/src/viewport.rs index 97edafed..6e81eed8 100644 --- a/crates/ui-egui/src/viewport.rs +++ b/crates/ui-egui/src/viewport.rs @@ -2920,8 +2920,9 @@ mod tests { let session = &mut harness.state_mut().session; let instance = execute(session, "layer.instance", &json!({"layer": original.layer.0, "ts": 1})).unwrap()["layer"].clone(); - // The source effect remains a valid inherited target when selection changes to its instance - assert!(execute(session, "layer.select", &json!({"layer": instance, "target": effect.0})).is_err()); + // The source effect is a valid inherited target when selection changes to its instance + execute(session, "layer.select", &json!({"layer": instance, "target": effect.0})).unwrap(); + assert_eq!(session.target, texturecraft_engine::StackTarget::Effect(effect)); assert_eq!(session.ts(), 1); assert_eq!(session.selected_layer().unwrap().0, instance.as_u64().unwrap()); From b511cad705578c1624cf22371b4e273e3eac3522 Mon Sep 17 00:00:00 2001 From: vangel76 Date: Sun, 22 Nov 2026 23:50:47 +0100 Subject: [PATCH 14/83] Dim the hovered set's scattering light at the hovered pixel, not before the blur --- crates/render/src/renderer.rs | 4 ++-- crates/render/src/shaders/fx.wgsl | 29 ++++++++++++++++++----------- crates/render/src/shaders/mesh.wgsl | 9 ++++----- crates/render/src/shaders/post.wgsl | 2 +- crates/render/tests/headless.rs | 17 ++++++++++++++--- 5 files changed, 39 insertions(+), 22 deletions(-) diff --git a/crates/render/src/renderer.rs b/crates/render/src/renderer.rs index c91f2404..1e6d965f 100644 --- a/crates/render/src/renderer.rs +++ b/crates/render/src/renderer.rs @@ -2143,7 +2143,7 @@ impl Renderer { b: [fx(s.vignette), fx(s.sharpen), fx(s.grain), BLOOM_THRESHOLD], c: dof_c, d: sss_d, - e: [flag(cam.ortho), sample as f32, 0.0, 0.0], + e: [flag(cam.ortho), sample as f32, raw.set_hover[3], 0.0], back_top: [s.background[0][0], s.background[0][1], s.background[0][2], 0.0], back_bottom: [s.background[1][0], s.background[1][1], s.background[1][2], 0.0], }; @@ -2222,7 +2222,7 @@ impl Renderer { let geo = self.geometry(m, frame); pass.set_vertex_buffer(0, geo.vb.slice(..)); pass.set_index_buffer(geo.ib.slice(..), wgpu::IndexFormat::Uint32); - // As in the main pass, instance index 1 marks the hovered set (fs_gbuf scales its scattering light) + // As in the main pass, instance index 1 marks the hovered set (fs_gbuf negates its depths for the blur pass) let hover_set = frame.shade.set_hover.filter(|_| frame.kind == ViewKind::Scene).map(|hover| hover.set); for (range, texture_set, set) in self.drawable(&geo.draws, &frame.visible, None) { pass.set_bind_group(1, &set.bind_group, &[]); diff --git a/crates/render/src/shaders/fx.wgsl b/crates/render/src/shaders/fx.wgsl index 333664ce..972de246 100644 --- a/crates/render/src/shaders/fx.wgsl +++ b/crates/render/src/shaders/fx.wgsl @@ -1,7 +1,8 @@ // Scene effects between the scene pass and the post pass, appended to util.wgsl and post.wgsl // (uses `src`, `src_samp`, `post`, `fx_a`): the screen-space subsurface blur and depth of field. // Both read the G-buffer of `fs_gbuf` (mesh.wgsl): rgb the scattering part of the diffuse light, -// a the view depth (0: background). Colors are linear HDR premultiplied by scene coverage. +// a the view depth (0: background; negative where the hovered set shows when the subsurface blur +// is on: read depths with abs). Colors are linear HDR premultiplied by scene coverage. @group(0) @binding(5) var fx_b: texture_2d; @group(0) @binding(6) var fx_c: texture_2d; @@ -31,12 +32,14 @@ fn px_per_world(z: f32) -> f32 { return select(post.d.w / max(z, 1e-4), post.d.w, post.e.x > 0.5); } -// One direction of the blur over `src` (rgb light, a depth) at pixel `p` (same-size target). +// One direction of the blur over `src` (rgb light, a depth) at pixel `p` (same-size target). The +// result keeps the centre's depth, sign included (negative: the hovered set). fn sss_blur(p: vec2, dir: vec2) -> vec4 { let c = texel_at(src, p); - let sigma = post.d.xyz * px_per_world(c.a); + let z = abs(c.a); + let sigma = post.d.xyz * px_per_world(z); let smax = max(sigma.r, max(sigma.g, sigma.b)); - if (c.a <= 0.0 || smax < 0.5) { + if (z <= 0.0 || smax < 0.5) { return c; } let stride = dir * (smax * 3.0 / f32(SSS_TAPS)); @@ -55,7 +58,8 @@ fn sss_blur(p: vec2, dir: vec2) -> vec4 { let o = f32(k) + jitter; let t = texel_at(src, p + stride * o); let x = o * smax * 3.0 / f32(SSS_TAPS); - let wd = select(0.0, max(1.0 - abs(t.a - c.a) / depth_range, 0.0), t.a > 0.0); + let tz = abs(t.a); + let wd = select(0.0, max(1.0 - abs(tz - z) / depth_range, 0.0), tz > 0.0); let w = exp(-x * x * inv); sum += mix(c.rgb, t.rgb, wd) * w; wsum += w; @@ -70,12 +74,15 @@ fn fs_sss_h(i: FsOut) -> @location(0) vec4 { } // src: the horizontal pass, fx_a: the scene (without its scattering light, see `fs_mesh`). Adds -// the blurred scattering light. +// the blurred scattering light. On the hovered set (negative depth) the light is scaled like the +// rest of the color the hover tint mixes in (post.e.z: the tint's opacity), so a neighbouring set +// keeps the light it receives. @fragment fn fs_sss_v(i: FsOut) -> @location(0) vec4 { - let blurred = sss_blur(i.pos.xy, vec2(0.0, 1.0)).rgb; + let blurred = sss_blur(i.pos.xy, vec2(0.0, 1.0)); let scene = texel_at(fx_a, i.pos.xy); - return scene + vec4(blurred * clamp(scene.a, 0.0, 1.0), 0.0); + let keep = select(1.0, 1.0 - post.e.z, blurred.a < 0.0); + return scene + vec4(blurred.rgb * keep * clamp(scene.a, 0.0, 1.0), 0.0); } // ---- Depth of field: a thin lens. Scatter-as-gather over a golden-angle spiral at half @@ -107,7 +114,7 @@ struct DofOut { @fragment fn fs_dof_gather(i: FsOut) -> DofOut { let px = 1.0 / vec2(textureDimensions(src)); - let zc = texel(fx_a, i.uv).a; + let zc = abs(texel(fx_a, i.uv).a); let cc = abs(coc(zc)); let rmax = post.c.z; // Half the spacing of the taps: the soft edge of each tap's reach. @@ -123,7 +130,7 @@ fn fs_dof_gather(i: FsOut) -> DofOut { let r = rmax * sqrt((f32(k) + 0.5) / f32(DOF_TAPS)); let a = f32(k) * GOLDEN_ANGLE + turn; let uv = i.uv + vec2(cos(a), sin(a)) * (r * px); - let z = texel(fx_a, uv).a; + let z = abs(texel(fx_a, uv).a); let nearer = z > 0.0 && (zc <= 0.0 || z < zc); var size = abs(coc(z)); if (!nearer) { @@ -145,7 +152,7 @@ const PI_FX: f32 = 3.14159265; @fragment fn fs_dof(i: FsOut) -> @location(0) vec4 { let sharp = texel_at(src, i.pos.xy); - let f = max(smoothstep(0.5, 1.5, abs(coc(texel_at(fx_b, i.pos.xy).a))), textureSampleLevel(fx_c, src_samp, i.uv, 0.0).r); + let f = max(smoothstep(0.5, 1.5, abs(coc(abs(texel_at(fx_b, i.pos.xy).a)))), textureSampleLevel(fx_c, src_samp, i.uv, 0.0).r); // In focus with nothing blurred in front: the sharp pixel itself (no blend through the // half-resolution blur at all). if (f <= 0.0) { diff --git a/crates/render/src/shaders/mesh.wgsl b/crates/render/src/shaders/mesh.wgsl index f780c4fc..7d2f8bf3 100644 --- a/crates/render/src/shaders/mesh.wgsl +++ b/crates/render/src/shaders/mesh.wgsl @@ -381,17 +381,16 @@ fn fs_opaque(i: VOut, @builtin(front_facing) front: bool) -> @location(0) vec4 @location(0) vec4 { - let z = max(dot(i.wpos - g.eye.xyz, g.fwd.xyz), 1e-4); + var z = max(dot(i.wpos - g.eye.xyz, g.fwd.xyz), 1e-4); var sss = vec3(0.0); if (g.scatter.w > 0.5) { sss = shade_mesh(i, front).sss; if (i.hover == 1u) { - // fs_mesh mixes the hover tint into the color without this light; the blur pass adds it - // back unblended, so scale it by the share of the color that stays - sss = sss * (1.0 - g.set_hover.a); + z = -z; } } else if (textureSample(t_base, samp, i.uv).a < hash12(i.clip.xy)) { discard; diff --git a/crates/render/src/shaders/post.wgsl b/crates/render/src/shaders/post.wgsl index e5df0cd8..c5a5e00f 100644 --- a/crates/render/src/shaders/post.wgsl +++ b/crates/render/src/shaders/post.wgsl @@ -7,7 +7,7 @@ struct Post { b: vec4, // x vignette, y sharpen, z grain, w bloom threshold c: vec4, // depth of field (fx.wgsl): x circle of confusion at infinity (pixels), y focus depth, z largest circle radius (pixels), w accumulation sample d: vec4, // subsurface blur (fx.wgsl): xyz mean free path per channel (world units), w pixels per world unit at depth 1 - e: vec4, // x orthographic camera (1: pixels per world unit don't fall off with depth), y accumulation sample, zw - + e: vec4, // x orthographic camera (1: pixels per world unit don't fall off with depth), y accumulation sample, z hover tint opacity (the subsurface blur scales the hovered set's light), w - back_top: vec4, // rgb background color at the top of the view (linear), a - back_bottom: vec4, // rgb background color at the bottom of the view (linear), a - }; diff --git a/crates/render/tests/headless.rs b/crates/render/tests/headless.rs index 781933f6..8cd807e6 100644 --- a/crates/render/tests/headless.rs +++ b/crates/render/tests/headless.rs @@ -1077,15 +1077,17 @@ fn the_hover_tint_covers_the_blurred_scattering_light_too() { let Some((mut h, frame)) = setup() else { return }; let lit = shaded(&frame, |s| s.light = LIGHT); let mask = mesh_mask(&mut h, &lit, &[0]); + let neighbour = mesh_mask(&mut h, &lit, &[1]); fill(&mut h, &[0, 1], DisplayKind::BaseColor, &[150, 150, 150, 255]); fill(&mut h, &[0, 1], DisplayKind::Emissive, &[0, 0, 0, 255]); let blur = shaded(&lit, |s| s.sss_blur = Some([0.06, 0.024, 0.015])); let hover = |f: &Frame| shaded(f, |s| s.set_hover = Some(texturecraft_render::SetHighlight { set: 0, color: [1.0, 0.5, 0.0] })); let mean = |img: &Img| region_mean(&mask, |x, y| img.luma(x, y)); - let plain = mean(&render(&mut h, &lit, "hover_sss_plain")); - let blurred = mean(&render(&mut h, &blur, "hover_sss_blur")); + let plain_img = render(&mut h, &lit, "hover_sss_plain"); + let blurred_img = render(&mut h, &blur, "hover_sss_blur"); + let hovered_blur_img = render(&mut h, &hover(&blur), "hover_sss_blur_hovered"); + let (plain, blurred, hovered_blur) = (mean(&plain_img), mean(&blurred_img), mean(&hovered_blur_img)); let hovered_plain = mean(&render(&mut h, &hover(&lit), "hover_sss_plain_hovered")); - let hovered_blur = mean(&render(&mut h, &hover(&blur), "hover_sss_blur_hovered")); assert!(hovered_plain != plain, "the hover tint changes the set"); // The blur only moves light around, so it must change a hovered set as little as a plain one // (the scattering light restored by the blur pass is blended with the tint as well) @@ -1095,6 +1097,15 @@ fn the_hover_tint_covers_the_blurred_scattering_light_too() { blurred - plain, hovered_blur - hovered_plain ); + // The set next to the hovered one keeps its light: the blur takes light across the boundary, and + // the hover must not dim what the neighbour receives from the hovered set + let other = |img: &Img| region_mean(&neighbour, |x, y| img.luma(x, y)); + assert!( + (other(&hovered_blur_img) - other(&blurred_img)).abs() < 1.0, + "hovering set 0 changes set 1 from {} to {}", + other(&blurred_img), + other(&hovered_blur_img) + ); } /// An environment that is bright only around `dir` (world space, rotation 0). From c3a52dbfd8b71ad7e6c203985b8b53238eab8f36 Mon Sep 17 00:00:00 2001 From: vangel76 Date: Mon, 23 Nov 2026 00:00:32 +0100 Subject: [PATCH 15/83] Test that hovering a set leaves the set next to it unchanged --- crates/render/tests/headless.rs | 34 +++++++++++++++++++++------------ 1 file changed, 22 insertions(+), 12 deletions(-) diff --git a/crates/render/tests/headless.rs b/crates/render/tests/headless.rs index 8cd807e6..d67afa41 100644 --- a/crates/render/tests/headless.rs +++ b/crates/render/tests/headless.rs @@ -1083,10 +1083,9 @@ fn the_hover_tint_covers_the_blurred_scattering_light_too() { let blur = shaded(&lit, |s| s.sss_blur = Some([0.06, 0.024, 0.015])); let hover = |f: &Frame| shaded(f, |s| s.set_hover = Some(texturecraft_render::SetHighlight { set: 0, color: [1.0, 0.5, 0.0] })); let mean = |img: &Img| region_mean(&mask, |x, y| img.luma(x, y)); - let plain_img = render(&mut h, &lit, "hover_sss_plain"); - let blurred_img = render(&mut h, &blur, "hover_sss_blur"); - let hovered_blur_img = render(&mut h, &hover(&blur), "hover_sss_blur_hovered"); - let (plain, blurred, hovered_blur) = (mean(&plain_img), mean(&blurred_img), mean(&hovered_blur_img)); + let plain = mean(&render(&mut h, &lit, "hover_sss_plain")); + let blurred = mean(&render(&mut h, &blur, "hover_sss_blur")); + let hovered_blur = mean(&render(&mut h, &hover(&blur), "hover_sss_blur_hovered")); let hovered_plain = mean(&render(&mut h, &hover(&lit), "hover_sss_plain_hovered")); assert!(hovered_plain != plain, "the hover tint changes the set"); // The blur only moves light around, so it must change a hovered set as little as a plain one @@ -1098,14 +1097,25 @@ fn the_hover_tint_covers_the_blurred_scattering_light_too() { hovered_blur - hovered_plain ); // The set next to the hovered one keeps its light: the blur takes light across the boundary, and - // the hover must not dim what the neighbour receives from the hovered set - let other = |img: &Img| region_mean(&neighbour, |x, y| img.luma(x, y)); - assert!( - (other(&hovered_blur_img) - other(&blurred_img)).abs() < 1.0, - "hovering set 0 changes set 1 from {} to {}", - other(&blurred_img), - other(&hovered_blur_img) - ); + // the hover must not dim what the neighbour receives from the hovered set. Only the pixels of + // set 1 within the blur's reach of set 0 can differ. + let wide = shaded(&lit, |s| s.sss_blur = Some([0.2, 0.08, 0.05])); + let blurred_img = render(&mut h, &wide, "hover_sss_wide"); + let hovered_blur_img = render(&mut h, &hover(&wide), "hover_sss_wide_hovered"); + const REACH: i32 = 25; + let (w, ht) = (480i32, 360i32); + let near = |i: usize| { + let (x, y) = (i as i32 % w, i as i32 / w); + (-REACH..=REACH) + .any(|dy| (-REACH..=REACH).any(|dx| (0..w).contains(&(x + dx)) && (0..ht).contains(&(y + dy)) && mask[((y + dy) * w + x + dx) as usize])) + }; + let diffs: Vec = (0..neighbour.len()) + .filter(|&i| neighbour[i] && !mask[i] && near(i)) + .map(|i| (hovered_blur_img.luma(i as u32 % 480, i as u32 / 480) - blurred_img.luma(i as u32 % 480, i as u32 / 480)).abs()) + .collect(); + let (count, max) = (diffs.iter().filter(|d| **d > 1.0).count(), diffs.iter().copied().fold(0.0, f32::max)); + assert!(!diffs.is_empty(), "set 1 touches set 0"); + assert!(max <= 1.0, "hovering set 0 changes {count} of {} pixels of set 1 next to it (max {max})", diffs.len()); } /// An environment that is bright only around `dir` (world space, rotation 0). From 4d682aa961762df30be42514ded2e0768229dc5c Mon Sep 17 00:00:00 2001 From: aiongg Date: Tue, 24 Nov 2026 15:16:48 +0000 Subject: [PATCH 16/83] minimal-port repin: 33 edits (revs 28, features 5) --- Cargo.toml | 52 +++++++++++++++++++-------------------- crates/formats/Cargo.toml | 4 +-- crates/ui-egui/Cargo.toml | 2 +- 3 files changed, 29 insertions(+), 29 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index de6fc98d..39cce518 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -10,7 +10,7 @@ edition = "2024" license = "MIT OR Apache-2.0" [workspace.dependencies] -craft-usd = { version = "0.1.0", git = "https://github.com/storytold/craft-libs", rev = "3dff4793f1a5bd1f99a4fe3280d48f515158dff3" } +craft-usd = { version = "0.1.0", git = "https://github.com/aiongg/craft-libs", rev = "cd87dc61f77d8470b2e9e6a1236f9a84ee0a64de" } # internal texturecraft-core = { path = "crates/core" } texturecraft-texel = { path = "crates/texel" } @@ -41,7 +41,7 @@ skrifa = { version = "0.44", default-features = false, features = ["std"] } epaint_default_fonts = "0.37" log = "0.4" image = { version = "0.25", default-features = false, features = ["png", "jpeg", "tga", "tiff", "exr", "hdr", "bmp", "webp"] } -craft-image-codecs = { git = "https://github.com/storytold/craft-libs", rev = "3dff4793f1a5bd1f99a4fe3280d48f515158dff3" } +craft-image-codecs = { git = "https://github.com/aiongg/craft-libs", rev = "cd87dc61f77d8470b2e9e6a1236f9a84ee0a64de" } half = "2" exr = { version = "1.73", default-features = false } eframe = { version = "0.37", default-features = false } @@ -64,40 +64,40 @@ rustix = { version = "1", default-features = false, features = ["std", "fs", "pr # Shared Craft egui components (widget palette, icon buttons, panel docking): storytold/craft-libs, # MIT OR Apache-2.0, pinned to one rev. # Shared catalog lookup, pinned with the other Craft libraries. -craft-i18n = { git = "https://github.com/storytold/craft-libs", rev = "390fe98b0dd3fb84db7c3af7cbd958db4e8cc585" } -craft-ui = { git = "https://github.com/storytold/craft-libs", rev = "390fe98b0dd3fb84db7c3af7cbd958db4e8cc585", features = ["serde"] } -craft-materialx = { git = "https://github.com/storytold/craft-libs", rev = "390fe98b0dd3fb84db7c3af7cbd958db4e8cc585" } -craft-tcraft = { git = "https://github.com/storytold/craft-libs", rev = "c376774f15ae7cd3b06a7ac664f01a8645af4b83" } +craft-i18n = { git = "https://github.com/aiongg/craft-libs", rev = "cd87dc61f77d8470b2e9e6a1236f9a84ee0a64de" } +craft-ui = { git = "https://github.com/aiongg/craft-libs", rev = "cd87dc61f77d8470b2e9e6a1236f9a84ee0a64de" } +craft-materialx = { git = "https://github.com/aiongg/craft-libs", rev = "cd87dc61f77d8470b2e9e6a1236f9a84ee0a64de" } +craft-tcraft = { git = "https://github.com/aiongg/craft-libs", rev = "cd87dc61f77d8470b2e9e6a1236f9a84ee0a64de" } # Isolated aligned writer; existing archive readers retain their pin and behavior. -craft-zip-usdz = { package = "craft-zip", git = "https://github.com/storytold/craft-libs", rev = "5631e99fe126cffb74c673eb458db04299f2bb9b" } -craft-zip = { git = "https://github.com/storytold/craft-libs", rev = "c376774f15ae7cd3b06a7ac664f01a8645af4b83" } -craft-mesh = { git = "https://github.com/storytold/craft-libs", rev = "a20dfd1623709b0bd9830106d3a92a1a443902e3", default-features = false, features = ["stl", "ply", "fbx", "obj", "gltf", "dae", "abc"] } -craft-mcmat = { git = "https://github.com/storytold/craft-libs", rev = "7a7a18cb40ac4cd5fca29c0dc224ac5178d40a89" } +craft-zip-usdz = { package = "craft-zip", git = "https://github.com/aiongg/craft-libs", rev = "cd87dc61f77d8470b2e9e6a1236f9a84ee0a64de" } +craft-zip = { git = "https://github.com/aiongg/craft-libs", rev = "cd87dc61f77d8470b2e9e6a1236f9a84ee0a64de" } +craft-mesh = { git = "https://github.com/aiongg/craft-libs", rev = "cd87dc61f77d8470b2e9e6a1236f9a84ee0a64de", default-features = false, features = ["stl", "ply", "fbx", "obj", "gltf", "dae", "abc"] } +craft-mcmat = { git = "https://github.com/aiongg/craft-libs", rev = "cd87dc61f77d8470b2e9e6a1236f9a84ee0a64de" } # Who draws the window frame, and the app-drawn strip as the title bar (crates/ui-egui/src/titlebar.rs). -craft-window = { git = "https://github.com/storytold/craft-libs", rev = "390fe98b0dd3fb84db7c3af7cbd958db4e8cc585", features = ["egui"] } +craft-window = { git = "https://github.com/aiongg/craft-libs", rev = "cd87dc61f77d8470b2e9e6a1236f9a84ee0a64de", features = ["ui"] } # Release checks, the update prompt and the update helper (crates/ui-egui/src/updates_ui.rs). -craft-update = { git = "https://github.com/storytold/craft-libs", rev = "390fe98b0dd3fb84db7c3af7cbd958db4e8cc585", features = ["egui"] } +craft-update = { git = "https://github.com/aiongg/craft-libs", rev = "cd87dc61f77d8470b2e9e6a1236f9a84ee0a64de", features = ["ui"] } # File dialogs that never block the frame (crates/ui-egui/src/file_dialogs.rs). -craft-dialogs = { git = "https://github.com/storytold/craft-libs", rev = "390fe98b0dd3fb84db7c3af7cbd958db4e8cc585" } +craft-dialogs = { git = "https://github.com/aiongg/craft-libs", rev = "cd87dc61f77d8470b2e9e6a1236f9a84ee0a64de" } # Shortcut chords, lookup and dispatch (crates/ui-egui/src/keymap.rs). -craft-keymap = { git = "https://github.com/storytold/craft-libs", rev = "390fe98b0dd3fb84db7c3af7cbd958db4e8cc585", features = ["egui"] } +craft-keymap = { git = "https://github.com/aiongg/craft-libs", rev = "cd87dc61f77d8470b2e9e6a1236f9a84ee0a64de", features = ["egui"] } # Quitting the macOS way instead of closing the window (crates/ui-egui/src/windows.rs). -craft-quit = { git = "https://github.com/storytold/craft-libs", rev = "390fe98b0dd3fb84db7c3af7cbd958db4e8cc585", features = ["egui"] } +craft-quit = { git = "https://github.com/aiongg/craft-libs", rev = "cd87dc61f77d8470b2e9e6a1236f9a84ee0a64de", features = ["ui"] } # The macOS app menu whose Quit asks about unsaved changes (apps/texturecraft/src/main.rs). -craft-menu = { git = "https://github.com/storytold/craft-libs", rev = "390fe98b0dd3fb84db7c3af7cbd958db4e8cc585" } +craft-menu = { git = "https://github.com/aiongg/craft-libs", rev = "cd87dc61f77d8470b2e9e6a1236f9a84ee0a64de" } # egui 0.37 and winit: the suite's forks (storytold/egui, storytold/winit), as craft-libs pins them. [patch.crates-io] -ecolor = { git = "https://github.com/storytold/egui.git", rev = "6d518fc799681571963842f95b55a6b68431b15a" } -emath = { git = "https://github.com/storytold/egui.git", rev = "6d518fc799681571963842f95b55a6b68431b15a" } -epaint = { git = "https://github.com/storytold/egui.git", rev = "6d518fc799681571963842f95b55a6b68431b15a" } -epaint_default_fonts = { git = "https://github.com/storytold/egui.git", rev = "6d518fc799681571963842f95b55a6b68431b15a" } -egui = { git = "https://github.com/storytold/egui.git", rev = "6d518fc799681571963842f95b55a6b68431b15a" } -egui-winit = { git = "https://github.com/storytold/egui.git", rev = "6d518fc799681571963842f95b55a6b68431b15a" } -egui-wgpu = { git = "https://github.com/storytold/egui.git", rev = "6d518fc799681571963842f95b55a6b68431b15a" } -egui_glow = { git = "https://github.com/storytold/egui.git", rev = "6d518fc799681571963842f95b55a6b68431b15a" } -eframe = { git = "https://github.com/storytold/egui.git", rev = "6d518fc799681571963842f95b55a6b68431b15a" } -egui_kittest = { git = "https://github.com/storytold/egui.git", rev = "6d518fc799681571963842f95b55a6b68431b15a" } +ecolor = { git = "https://github.com/storytold/egui.git", rev = "f5025284445ea19c35f746d96fc0b75468b3f560" } +emath = { git = "https://github.com/storytold/egui.git", rev = "f5025284445ea19c35f746d96fc0b75468b3f560" } +epaint = { git = "https://github.com/storytold/egui.git", rev = "f5025284445ea19c35f746d96fc0b75468b3f560" } +epaint_default_fonts = { git = "https://github.com/storytold/egui.git", rev = "f5025284445ea19c35f746d96fc0b75468b3f560" } +egui = { git = "https://github.com/storytold/egui.git", rev = "f5025284445ea19c35f746d96fc0b75468b3f560" } +egui-winit = { git = "https://github.com/storytold/egui.git", rev = "f5025284445ea19c35f746d96fc0b75468b3f560" } +egui-wgpu = { git = "https://github.com/storytold/egui.git", rev = "f5025284445ea19c35f746d96fc0b75468b3f560" } +egui_glow = { git = "https://github.com/storytold/egui.git", rev = "f5025284445ea19c35f746d96fc0b75468b3f560" } +eframe = { git = "https://github.com/storytold/egui.git", rev = "f5025284445ea19c35f746d96fc0b75468b3f560" } +egui_kittest = { git = "https://github.com/storytold/egui.git", rev = "f5025284445ea19c35f746d96fc0b75468b3f560" } winit = { git = "https://github.com/storytold/winit.git", rev = "a517b3846ee8457d84ee4975110bfda6797c44dc" } # egui-phosphor has no release for egui 0.37 (vendor/egui-phosphor/VENDORED.md). egui-phosphor = { path = "vendor/egui-phosphor" } diff --git a/crates/formats/Cargo.toml b/crates/formats/Cargo.toml index fbc4138a..4dcc6693 100644 --- a/crates/formats/Cargo.toml +++ b/crates/formats/Cargo.toml @@ -11,7 +11,7 @@ workspace = true [dependencies] craft-usd.workspace = true # ICC v2 serialization prerequisite: craft-libs#1735; app colour policy stays local. -craft-cms-icc-v2 = { package = "craft-cms", version = "0.1.0", git = "https://github.com/storytold/craft-libs", rev = "272a095b61257917693da3d09f2f8ecccd7f0295" } +craft-cms-icc-v2 = { package = "craft-cms", version = "0.1.0", git = "https://github.com/aiongg/craft-libs", rev = "cd87dc61f77d8470b2e9e6a1236f9a84ee0a64de" } craft-materialx = { workspace = true } craft-mesh = { workspace = true } craft-mcmat = { workspace = true } @@ -26,7 +26,7 @@ image = { workspace = true } png = "0.18" bytemuck = { workspace = true, features = ["extern_crate_alloc"] } craft-image-codecs = { workspace = true } -craft-psd = { git = "https://github.com/storytold/craft-libs", rev = "b130ac1fa44f923c3024884ab8ceb5ccdb88f15f" } +craft-psd = { git = "https://github.com/aiongg/craft-libs", rev = "cd87dc61f77d8470b2e9e6a1236f9a84ee0a64de" } flate2 = { workspace = true } half = { workspace = true } quick-xml = { workspace = true } diff --git a/crates/ui-egui/Cargo.toml b/crates/ui-egui/Cargo.toml index 9abb472c..34dcb5fb 100644 --- a/crates/ui-egui/Cargo.toml +++ b/crates/ui-egui/Cargo.toml @@ -32,7 +32,7 @@ craft-image-codecs = { workspace = true } [target.'cfg(not(target_arch = "wasm32"))'.dependencies] sys-locale = "0.3" # Floating panels open as OS windows. -craft-ui = { workspace = true, features = ["native-windows"] } +craft-ui = { workspace = true } # Help > Check for Updates and the check at start (updates_ui.rs). craft-update = { workspace = true } # Native file dialogs (file_dialogs.rs); the browser build has none. From 77d25c646274461f082777d9d0aff5a0c159efa6 Mon Sep 17 00:00:00 2001 From: aiongg Date: Tue, 24 Nov 2026 15:17:05 +0000 Subject: [PATCH 17/83] Repin: one craft-libs rev serves the USDZ writer, so the second craft-zip pin goes --- Cargo.toml | 2 -- crates/formats/Cargo.toml | 1 - crates/formats/src/mesh_export/usd.rs | 2 +- crates/formats/src/mesh_import/usd/tests.rs | 2 +- 4 files changed, 2 insertions(+), 5 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 39cce518..7a60b44b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -68,8 +68,6 @@ craft-i18n = { git = "https://github.com/aiongg/craft-libs", rev = "cd87dc61f77d craft-ui = { git = "https://github.com/aiongg/craft-libs", rev = "cd87dc61f77d8470b2e9e6a1236f9a84ee0a64de" } craft-materialx = { git = "https://github.com/aiongg/craft-libs", rev = "cd87dc61f77d8470b2e9e6a1236f9a84ee0a64de" } craft-tcraft = { git = "https://github.com/aiongg/craft-libs", rev = "cd87dc61f77d8470b2e9e6a1236f9a84ee0a64de" } -# Isolated aligned writer; existing archive readers retain their pin and behavior. -craft-zip-usdz = { package = "craft-zip", git = "https://github.com/aiongg/craft-libs", rev = "cd87dc61f77d8470b2e9e6a1236f9a84ee0a64de" } craft-zip = { git = "https://github.com/aiongg/craft-libs", rev = "cd87dc61f77d8470b2e9e6a1236f9a84ee0a64de" } craft-mesh = { git = "https://github.com/aiongg/craft-libs", rev = "cd87dc61f77d8470b2e9e6a1236f9a84ee0a64de", default-features = false, features = ["stl", "ply", "fbx", "obj", "gltf", "dae", "abc"] } craft-mcmat = { git = "https://github.com/aiongg/craft-libs", rev = "cd87dc61f77d8470b2e9e6a1236f9a84ee0a64de" } diff --git a/crates/formats/Cargo.toml b/crates/formats/Cargo.toml index 4dcc6693..ce1b8007 100644 --- a/crates/formats/Cargo.toml +++ b/crates/formats/Cargo.toml @@ -17,7 +17,6 @@ craft-mesh = { workspace = true } craft-mcmat = { workspace = true } craft-tcraft = { workspace = true } craft-zip = { workspace = true } -craft-zip-usdz = { workspace = true } texturecraft-core = { workspace = true } texturecraft-texel = { workspace = true } texturecraft-geom = { workspace = true } diff --git a/crates/formats/src/mesh_export/usd.rs b/crates/formats/src/mesh_export/usd.rs index 49125502..a3f2bddb 100644 --- a/crates/formats/src/mesh_export/usd.rs +++ b/crates/formats/src/mesh_export/usd.rs @@ -287,7 +287,7 @@ pub(crate) fn material_maps(mesh: &Mesh, stem: &str, textures: &[Vec)]) -> Result> { - let mut zip = craft_zip_usdz::Writer::new(); + let mut zip = craft_zip::Writer::new(); let err = |e| FormatError::Invalid(format!("usdz package: {e}")); for (name, bytes) in std::iter::once((layer_name, layer)).chain(files.iter().map(|(n, b)| (n.as_str(), b.as_slice()))) { zip.add_stored_aligned(name, bytes, 64).map_err(err)?; diff --git a/crates/formats/src/mesh_import/usd/tests.rs b/crates/formats/src/mesh_import/usd/tests.rs index 9eef4537..ce07ab3c 100644 --- a/crates/formats/src/mesh_import/usd/tests.rs +++ b/crates/formats/src/mesh_import/usd/tests.rs @@ -707,7 +707,7 @@ def Xform "Root" } "#; let albedo = png([200, 10, 10]); - let mut writer = craft_zip_usdz::Writer::new(); + let mut writer = craft_zip::Writer::new(); writer.add_stored_aligned("sub/scene.usda", usda.as_bytes(), 64).unwrap(); writer.add_stored_aligned("sub/tex/albedo.png", &albedo, 64).unwrap(); let pkg = writer.finish().unwrap(); From 3daa39f5ee24e7868aef4ee3fdb0a9de5357a01a Mon Sep 17 00:00:00 2001 From: aiongg Date: Tue, 24 Nov 2026 15:17:20 +0000 Subject: [PATCH 18/83] minimal-port rewrite: 39 edits (dock 11, split rename 11, split 7, dock rename 5, keymap rename 2, deps 2, keymap 1) --- Cargo.toml | 1 + crates/ui-egui/Cargo.toml | 1 + crates/ui-egui/src/docking.rs | 32 ++++++++++--------- crates/ui-egui/src/docking/header_band.rs | 6 ++-- crates/ui-egui/src/docking/shown_group_tab.rs | 3 +- crates/ui-egui/src/keymap.rs | 6 ++-- crates/ui-egui/src/shelf_panes.rs | 6 ++-- crates/ui-egui/src/ui_state_store.rs | 4 +-- crates/ui-egui/tests/it/layer_toolbar.rs | 2 +- crates/ui-egui/tests/it/layers_panel.rs | 4 +-- crates/ui-egui/tests/it/panel_header.rs | 4 +-- .../ui-egui/tests/it/properties_min_width.rs | 4 +-- crates/ui-egui/tests/ui_snapshots.rs | 8 ++--- 13 files changed, 44 insertions(+), 37 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 7a60b44b..aec6167b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -66,6 +66,7 @@ rustix = { version = "1", default-features = false, features = ["std", "fs", "pr # Shared catalog lookup, pinned with the other Craft libraries. craft-i18n = { git = "https://github.com/aiongg/craft-libs", rev = "cd87dc61f77d8470b2e9e6a1236f9a84ee0a64de" } craft-ui = { git = "https://github.com/aiongg/craft-libs", rev = "cd87dc61f77d8470b2e9e6a1236f9a84ee0a64de" } +craft-behavior = { git = "https://github.com/aiongg/craft-libs", rev = "cd87dc61f77d8470b2e9e6a1236f9a84ee0a64de" } craft-materialx = { git = "https://github.com/aiongg/craft-libs", rev = "cd87dc61f77d8470b2e9e6a1236f9a84ee0a64de" } craft-tcraft = { git = "https://github.com/aiongg/craft-libs", rev = "cd87dc61f77d8470b2e9e6a1236f9a84ee0a64de" } craft-zip = { git = "https://github.com/aiongg/craft-libs", rev = "cd87dc61f77d8470b2e9e6a1236f9a84ee0a64de" } diff --git a/crates/ui-egui/Cargo.toml b/crates/ui-egui/Cargo.toml index 34dcb5fb..5b6ce710 100644 --- a/crates/ui-egui/Cargo.toml +++ b/crates/ui-egui/Cargo.toml @@ -15,6 +15,7 @@ texturecraft-render = { workspace = true } eframe = { workspace = true, features = ["default_fonts", "wgpu", "persistence"] } egui = { workspace = true } craft-ui = { workspace = true } +craft-behavior = { workspace = true } craft-i18n = { workspace = true } craft-window = { workspace = true } craft-keymap = { workspace = true } diff --git a/crates/ui-egui/src/docking.rs b/crates/ui-egui/src/docking.rs index 761928ec..0da70e61 100644 --- a/crates/ui-egui/src/docking.rs +++ b/crates/ui-egui/src/docking.rs @@ -10,8 +10,10 @@ //! that cannot close or float. The layout persists with `UiState` as a craft-ui `Workspace`; //! a layout that does not load or validate becomes the default. -use craft_ui::docking::{Action, DockArea, DockContent, DockStyle, Layout, Location, Node, PanelLimits, PanelState, Permissions, Placement}; -use craft_ui::layout::{SplitAxis, SplitSize}; +use craft_behavior::dock::{Action, DockPlacement, Layout, Location, Node, PanelState, Permissions}; +use craft_ui::docking::{DockArea, DockContent, DockStyle, PanelLimits}; +use craft_behavior::flow::Axis; +use craft_behavior::dock::SplitSize; use egui::{Id, Margin, RichText, Ui, Vec2, vec2}; use serde::{Deserialize, Serialize}; use serde_json::Value; @@ -147,7 +149,7 @@ impl Panel { } /// The saved panel arrangement: craft-ui's workspace over TextureCraft's panels. -pub type Workspace = craft_ui::docking::Workspace; +pub type Workspace = craft_behavior::dock::Workspace; /// The viewport never moves, floats, closes or takes tabs; panels dock beside it. pub fn permissions(panel: &Panel) -> Permissions { @@ -158,7 +160,7 @@ fn tabs(panels: &[Panel]) -> Node { Node::Tabs { panels: panels.to_vec(), active: 0 } } -fn split(axis: SplitAxis, size: SplitSize, first: Node, second: Node) -> Node { +fn split(axis: Axis, size: SplitSize, first: Node, second: Node) -> Node { Node::Split { axis, size, first: Box::new(first), second: Box::new(second) } } @@ -175,16 +177,16 @@ pub fn default_workspace() -> Workspace { const LAYERS_SPLIT_RATIO: f32 = 0.31; let column = split( - SplitAxis::Vertical, + Axis::Y, SplitSize::Ratio(TEXTURE_SET_SPLIT_RATIO), tabs(&[TextureSetList]), - split(SplitAxis::Vertical, SplitSize::Ratio(LAYERS_SPLIT_RATIO), tabs(&[Layers, TextureSetSettings]), tabs(&[Properties])), + split(Axis::Y, SplitSize::Ratio(LAYERS_SPLIT_RATIO), tabs(&[Layers, TextureSetSettings]), tabs(&[Properties])), ); let root = split( - SplitAxis::Horizontal, + Axis::X, SplitSize::Ratio(ASSETS_SPLIT_RATIO), tabs(&[Assets]), - split(SplitAxis::Horizontal, SplitSize::Ratio(VIEWPORT_SPLIT_RATIO), tabs(&[Viewport]), column), + split(Axis::X, SplitSize::Ratio(VIEWPORT_SPLIT_RATIO), tabs(&[Viewport]), column), ); let mut workspace = Workspace::new(Layout { root: Some(root), floating: Vec::new() }); @@ -200,7 +202,7 @@ pub fn default_workspace() -> Workspace { Location { floating: None, anchor: Some(TextureSetList), - placement: Placement::Tab { before: None }, + placement: DockPlacement::Tab { before: None }, size: None, stack: None, sibling: Vec::new(), @@ -214,7 +216,7 @@ pub fn default_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 { - Location { floating: Some(rect), anchor: None, placement: Placement::Tab { before: None }, size: None, stack: None, sibling: Vec::new(), group: None } + Location { floating: Some(rect), anchor: None, placement: DockPlacement::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 @@ -338,12 +340,12 @@ impl Dock { workspace.hidden.retain(|(panel, _)| !bake_panels.contains(panel)); let gutter_width = f32::from(crate::theme::GUTTER); - let list_column = split(SplitAxis::Vertical, SplitSize::Ratio(TEXTURE_SET_LIST_SHARE), tabs(&[Panel::TextureSetList]), tabs(&[Panel::MeshMapBakers])); + let list_column = split(Axis::Y, SplitSize::Ratio(TEXTURE_SET_LIST_SHARE), tabs(&[Panel::TextureSetList]), tabs(&[Panel::MeshMapBakers])); let settings_column = tabs(&[Panel::CommonSettings, Panel::MeshMapSettings]); - let columns = split(SplitAxis::Horizontal, SplitSize::FixedFirst(BAKERS_COLUMN_WIDTH), list_column, settings_column); - let columns_over_log = split(SplitAxis::Vertical, SplitSize::FixedSecond(BAKING_LOG_HEIGHT), columns, tabs(&[Panel::Log])); + let columns = split(Axis::X, SplitSize::FixedFirst(BAKERS_COLUMN_WIDTH), list_column, settings_column); + let columns_over_log = split(Axis::Y, SplitSize::FixedSecond(BAKING_LOG_HEIGHT), columns, tabs(&[Panel::Log])); let columns_width = BAKERS_COLUMN_WIDTH + gutter_width + SETTINGS_COLUMN_WIDTH; - let root = split(SplitAxis::Horizontal, SplitSize::FixedFirst(columns_width), columns_over_log, tabs(&[Panel::Viewport])); + let root = split(Axis::X, SplitSize::FixedFirst(columns_width), columns_over_log, tabs(&[Panel::Viewport])); workspace.layout = Layout { root: Some(root), floating: Vec::new() }; Dock { workspace, raise: None, replaced_unreadable: false } } @@ -780,7 +782,7 @@ mod tests { assert!(dock.is_open(Panel::Viewport)); let before = dock.clone(); dock.apply(Action::Float { panel: Panel::Viewport, rect: [0.0, 0.0, 300.0, 300.0] }); - dock.apply(Action::Move { panel: Panel::Layers, anchor: Panel::Viewport, placement: Placement::Tab { before: None } }); + dock.apply(Action::Move { panel: Panel::Layers, anchor: Panel::Viewport, placement: DockPlacement::Tab { before: None } }); assert_eq!(dock, before); } diff --git a/crates/ui-egui/src/docking/header_band.rs b/crates/ui-egui/src/docking/header_band.rs index 3cbd77d9..8bb5ca60 100644 --- a/crates/ui-egui/src/docking/header_band.rs +++ b/crates/ui-egui/src/docking/header_band.rs @@ -1,7 +1,7 @@ //! Positions dock tab titles within the tab strip and the gutter above it. -use craft_ui::docking::{Layout, Node}; -use craft_ui::layout::SplitAxis; +use craft_behavior::dock::{Layout, Node}; +use craft_behavior::flow::Axis; use egui::text::{LayoutJob, TextFormat}; use egui::{Align, Color32, FontId, Ui}; @@ -21,7 +21,7 @@ pub(super) fn under_a_panel(layout: &Layout, panel: Panel) -> bool { fn group_is_below_panel(node: &Node, panel: Panel, below_panel: bool) -> Option { match node { Node::Split { axis, first, second, .. } => { - group_is_below_panel(second, panel, below_panel || *axis == SplitAxis::Vertical).or_else(|| group_is_below_panel(first, panel, below_panel)) + group_is_below_panel(second, panel, below_panel || *axis == Axis::Y).or_else(|| group_is_below_panel(first, panel, below_panel)) } Node::Tabs { panels, .. } if panels.contains(&panel) => Some(below_panel), Node::Dock { columns, .. } => { diff --git a/crates/ui-egui/src/docking/shown_group_tab.rs b/crates/ui-egui/src/docking/shown_group_tab.rs index 2080d530..59f88f29 100644 --- a/crates/ui-egui/src/docking/shown_group_tab.rs +++ b/crates/ui-egui/src/docking/shown_group_tab.rs @@ -1,6 +1,7 @@ //! The active tab in a panel group, drawn as a raised box joined to the panel body -use craft_ui::docking::{DockContent, Node}; +use craft_ui::docking::DockContent; +use craft_behavior::dock::Node; use egui::text::TextWrapping; use egui::{Rect, Stroke, StrokeKind, Ui, pos2}; diff --git a/crates/ui-egui/src/keymap.rs b/crates/ui-egui/src/keymap.rs index ee29ac48..60479152 100644 --- a/crates/ui-egui/src/keymap.rs +++ b/crates/ui-egui/src/keymap.rs @@ -5,7 +5,7 @@ use std::collections::BTreeMap; use craft_keymap::egui::Dispatcher; -use craft_keymap::{Active, Bindable, Chord, CommandRef, ConflictKind, KeyInput, Layout, Lookup, Mods, Overrides, Platform, Scope, Scopes}; +use craft_keymap::{Active, Chord, CommandDef, CommandRef, ConflictKind, KeyInput, Layout, Lookup, Mods, Overrides, Platform, Scope, Scopes}; use egui::{Event, Id, Key, KeyboardShortcut, Modifiers, RichText, vec2}; use egui_phosphor::regular as ic; @@ -179,11 +179,11 @@ fn active(keymap: &Keymap) -> Vec { /// The catalog as craft-keymap sees it, in `bindings()` order: the first one listed wins a shared /// shortcut. -fn catalog() -> Vec { +fn catalog() -> Vec { bindings() .iter() .map(|b| { - let item = Bindable::new(b.id, b.label, Scope::app()); + let item = CommandDef::new(b.id, b.label, Scope::app()); match b.default.and_then(parse) { Some(chord) => item.with_default(craft_keymap::Binding::new(chord)), None => item, diff --git a/crates/ui-egui/src/shelf_panes.rs b/crates/ui-egui/src/shelf_panes.rs index 96f5c25f..90315269 100644 --- a/crates/ui-egui/src/shelf_panes.rs +++ b/crates/ui-egui/src/shelf_panes.rs @@ -1,6 +1,8 @@ //! The shelf's side panes left of the grid, toggled from the toolbar: saved searches and the folder tree -use craft_ui::layout::{ResizeHandle, ResizeHandleStyle, SplitAxis, SplitLayout, SplitSize, split_rect}; +use craft_ui::layout::{ResizeHandle, ResizeHandleStyle, SplitLayout, split_rect}; +use craft_behavior::flow::Axis; +use craft_behavior::dock::SplitSize; use egui::{Rect, RichText, Ui, UiBuilder}; use egui_phosphor::regular as ic; use serde::{Deserialize, Serialize}; @@ -93,7 +95,7 @@ fn splitter(app: &mut TextureCraftApp, ui: &mut Ui, rect: Rect) -> Option UiState { @@ -321,7 +321,7 @@ pub(crate) mod tests { fn moved_panels() -> Dock { let mut workspace = default_workspace(); let actions = [ - Action::Move { panel: Panel::Layers, anchor: Panel::Assets, placement: Placement::Tab { before: None } }, + Action::Move { panel: Panel::Layers, anchor: Panel::Assets, placement: DockPlacement::Tab { before: None } }, Action::Float { panel: Panel::Properties, rect: [900.0, 120.0, 320.0, 400.0] }, ]; workspace.apply_all(actions, permissions).unwrap(); diff --git a/crates/ui-egui/tests/it/layer_toolbar.rs b/crates/ui-egui/tests/it/layer_toolbar.rs index 9466a76f..8ba9935e 100644 --- a/crates/ui-egui/tests/it/layer_toolbar.rs +++ b/crates/ui-egui/tests/it/layer_toolbar.rs @@ -133,7 +133,7 @@ const NARROW_LAYERS: [f32; 4] = [600.0, 200.0, 200.0, 400.0]; /// In a narrow floating Layers panel the add-layer buttons and Remove wrap inside it, where a click still reaches them #[test] fn a_narrow_layers_panel_keeps_every_toolbar_button_inside_and_clickable() { - use craft_ui::docking::Action; + use craft_behavior::dock::Action; use texturecraft_ui_egui::docking::{Dock, Panel, permissions}; let (mut harness, _) = app(); diff --git a/crates/ui-egui/tests/it/layers_panel.rs b/crates/ui-egui/tests/it/layers_panel.rs index 56434f92..4cb38a12 100644 --- a/crates/ui-egui/tests/it/layers_panel.rs +++ b/crates/ui-egui/tests/it/layers_panel.rs @@ -99,8 +99,8 @@ fn visible_rows_get_their_thumbnails() { #[test] fn deeply_nested_effect_visibility_is_reachable_in_a_narrow_panel() { - use craft_ui::docking::Node; - use craft_ui::layout::SplitSize; + use craft_behavior::dock::Node; + use craft_behavior::dock::SplitSize; use texturecraft_ui_egui::docking::Dock; let (mut harness, layer) = harness(); diff --git a/crates/ui-egui/tests/it/panel_header.rs b/crates/ui-egui/tests/it/panel_header.rs index ba34023c..50be40c0 100644 --- a/crates/ui-egui/tests/it/panel_header.rs +++ b/crates/ui-egui/tests/it/panel_header.rs @@ -1,6 +1,6 @@ //! Every docked panel group sits under one header bar: its names at the left, the shown one raised as a box when the group has several, a close × at the right -use craft_ui::docking::{Action, Placement}; +use craft_behavior::dock::{Action, DockPlacement}; use egui::Role; use egui_kittest::Harness; use egui_kittest::kittest::{NodeT, Queryable}; @@ -212,7 +212,7 @@ fn a_floating_groups_names_share_one_line() { let mut workspace = harness.state().ui.dock.workspace().clone(); let actions = [ Action::Float { panel: Panel::Properties, rect: FLOATING_RECT }, - Action::Move { panel: Panel::TextureSetSettings, anchor: Panel::Properties, placement: Placement::Tab { before: None } }, + Action::Move { panel: Panel::TextureSetSettings, anchor: Panel::Properties, placement: DockPlacement::Tab { before: None } }, Action::Activate { panel: Panel::Properties }, ]; workspace.apply_all(actions, permissions).unwrap(); diff --git a/crates/ui-egui/tests/it/properties_min_width.rs b/crates/ui-egui/tests/it/properties_min_width.rs index 93e232d2..bf873830 100644 --- a/crates/ui-egui/tests/it/properties_min_width.rs +++ b/crates/ui-egui/tests/it/properties_min_width.rs @@ -1,7 +1,7 @@ //! The Properties panel never gets narrower than its rows need: the column it docks in stops shrinking there -use craft_ui::docking::Node; -use craft_ui::layout::SplitSize; +use craft_behavior::dock::Node; +use craft_behavior::dock::SplitSize; use egui::{Event, Modifiers, PointerButton, Pos2, Role, pos2}; use egui_kittest::Harness; use egui_kittest::kittest::{NodeT, Queryable}; diff --git a/crates/ui-egui/tests/ui_snapshots.rs b/crates/ui-egui/tests/ui_snapshots.rs index cda0398b..2e71ddaa 100644 --- a/crates/ui-egui/tests/ui_snapshots.rs +++ b/crates/ui-egui/tests/ui_snapshots.rs @@ -690,8 +690,8 @@ fn smart_material_shelf_snapshot() { #[test] #[ignore] fn nested_layers_snapshot() { - use craft_ui::docking::Node; - use craft_ui::layout::SplitSize; + use craft_behavior::dock::Node; + use craft_behavior::dock::SplitSize; use serde_json::{Value, json}; use texturecraft_engine::execute; use texturecraft_ui_egui::docking::Dock; @@ -2937,8 +2937,8 @@ fn filter_picker_snapshots() { #[test] #[ignore] fn properties_min_width_snapshot() { - use craft_ui::docking::Node; - use craft_ui::layout::SplitSize; + use craft_behavior::dock::Node; + use craft_behavior::dock::SplitSize; use serde_json::json; use texturecraft_engine::execute; use texturecraft_ui_egui::docking::Dock; From dc1e046faae076263600c1603aa7a4ea442ee01b Mon Sep 17 00:00:00 2001 From: aiongg Date: Tue, 24 Nov 2026 15:17:45 +0000 Subject: [PATCH 19/83] Cargo.lock for the craft-libs next pin (xcap 0.9.8 as craft-platform pins it, rustix 1.1.6) --- Cargo.lock | 1191 ++++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 958 insertions(+), 233 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 59d9a90a..771fadef 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -80,7 +80,7 @@ dependencies = [ "futures-lite", "futures-util", "serde", - "zbus 5.19.0", + "zbus", ] [[package]] @@ -239,11 +239,20 @@ dependencies = [ "x11rb", ] +[[package]] +name = "arrayref" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "76a2e8124351fda1ef8aaaa3bbd7ebbcb486bbcd4225aca0aa0d84bb2db8fecb" + [[package]] name = "arrayvec" version = "0.7.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d3fb67a6e08acf24fdeccbac2cb6ac4305825bd1f117462e0e6f2f193345ad56" +dependencies = [ + "serde", +] [[package]] name = "as-raw-xcb-connection" @@ -260,22 +269,6 @@ dependencies = [ "libloading", ] -[[package]] -name = "ashpd" -version = "0.14.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ba377f1fb1e3972907220f1f8e7c0a45164580905c981d872c1fb90d921cbcc" -dependencies = [ - "bitflags 2.13.2", - "futures-channel", - "futures-util", - "getrandom 0.4.3", - "pipewire", - "serde", - "serde_repr", - "zbus 6.3.0", -] - [[package]] name = "async-broadcast" version = "0.7.2" @@ -327,7 +320,7 @@ dependencies = [ "futures-lite", "parking", "polling", - "rustix 1.1.5", + "rustix 1.1.6", "slab", "windows-sys 0.61.2", ] @@ -358,7 +351,7 @@ dependencies = [ "cfg-if", "event-listener", "futures-lite", - "rustix 1.1.5", + "rustix 1.1.6", ] [[package]] @@ -384,7 +377,7 @@ dependencies = [ "cfg-if", "futures-core", "futures-io", - "rustix 1.1.5", + "rustix 1.1.6", "signal-hook-registry", "slab", "windows-sys 0.61.2", @@ -432,7 +425,7 @@ dependencies = [ "enumflags2", "serde", "static_assertions", - "zbus 5.19.0", + "zbus", "zbus-lockstep", "zbus-lockstep-macros", "zbus_names", @@ -447,7 +440,7 @@ checksum = "2230e48787ed3eb4088996eab66a32ca20c0b67bbd4fd6cdfe79f04f1f04c9fc" dependencies = [ "atspi-common", "serde", - "zbus 5.19.0", + "zbus", ] [[package]] @@ -529,6 +522,12 @@ dependencies = [ "serde_core", ] +[[package]] +name = "block" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0d8c1fef690941d3e7788d328517591fecc684c084084702d6ff1641e993699a" + [[package]] name = "block-buffer" version = "0.10.4" @@ -623,6 +622,16 @@ version = "1.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fc652a48c352aef3ea3aed32080501cf3ef6ed5da78602a020c991775b0aff04" +[[package]] +name = "calendrical_calculations" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5abbd6eeda6885048d357edc66748eea6e0268e3dd11f326fff5bd248d779c26" +dependencies = [ + "core_maths", + "displaydoc", +] + [[package]] name = "calloop" version = "0.13.0" @@ -661,9 +670,9 @@ dependencies = [ "io-lifetimes 3.0.1", "ipnet", "maybe-owned", - "rustix 1.1.5", + "rustix 1.1.6", "rustix-linux-procfs", - "windows-sys 0.61.2", + "windows-sys 0.60.2", "winx", ] @@ -676,7 +685,7 @@ dependencies = [ "cap-primitives", "io-extras", "io-lifetimes 3.0.1", - "rustix 1.1.5", + "rustix 1.1.6", ] [[package]] @@ -895,12 +904,34 @@ dependencies = [ "libc", ] +[[package]] +name = "core-graphics2" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5b65858d95344d2711161cd92196732f67d6c5fea238cf12f994584828731a5c" +dependencies = [ + "bitflags 2.13.2", + "block", + "cfg-if", + "core-foundation 0.10.1", + "libc", +] + [[package]] name = "core_detect" version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7f8f80099a98041a3d1622845c271458a2d73e688351bf3cb999266764b81d48" +[[package]] +name = "core_maths" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "77745e017f5edba1a9c1d854f6f3a52dac8a12dd5af5d2f54aecf61e43d80d30" +dependencies = [ + "libm", +] + [[package]] name = "cpufeatures" version = "0.2.17" @@ -919,19 +950,58 @@ dependencies = [ "libc", ] +[[package]] +name = "craft-atomic" +version = "0.1.0" +source = "git+https://github.com/aiongg/craft-libs?rev=cd87dc61f77d8470b2e9e6a1236f9a84ee0a64de#cd87dc61f77d8470b2e9e6a1236f9a84ee0a64de" +dependencies = [ + "rustix 1.1.6", +] + +[[package]] +name = "craft-behavior" +version = "0.1.0" +source = "git+https://github.com/aiongg/craft-libs?rev=cd87dc61f77d8470b2e9e6a1236f9a84ee0a64de#cd87dc61f77d8470b2e9e6a1236f9a84ee0a64de" +dependencies = [ + "accesskit", + "bitflags 2.13.2", + "craft-host", + "craft-keymap", + "craft-theme", + "craft-tracked", + "craft-ui-macros", + "emath", + "kurbo", + "serde", + "smallvec", +] + +[[package]] +name = "craft-cloud-ui" +version = "0.1.0" +source = "git+https://github.com/aiongg/craft-libs?rev=cd87dc61f77d8470b2e9e6a1236f9a84ee0a64de#cd87dc61f77d8470b2e9e6a1236f9a84ee0a64de" +dependencies = [ + "egui", +] + [[package]] name = "craft-cms" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=272a095b61257917693da3d09f2f8ecccd7f0295#272a095b61257917693da3d09f2f8ecccd7f0295" +source = "git+https://github.com/aiongg/craft-libs?rev=cd87dc61f77d8470b2e9e6a1236f9a84ee0a64de#cd87dc61f77d8470b2e9e6a1236f9a84ee0a64de" dependencies = [ "md-5", "rayon", ] +[[package]] +name = "craft-codepage" +version = "0.1.0" +source = "git+https://github.com/aiongg/craft-libs?rev=cd87dc61f77d8470b2e9e6a1236f9a84ee0a64de#cd87dc61f77d8470b2e9e6a1236f9a84ee0a64de" + [[package]] name = "craft-dds" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=3dff4793f1a5bd1f99a4fe3280d48f515158dff3#3dff4793f1a5bd1f99a4fe3280d48f515158dff3" +source = "git+https://github.com/aiongg/craft-libs?rev=cd87dc61f77d8470b2e9e6a1236f9a84ee0a64de#cd87dc61f77d8470b2e9e6a1236f9a84ee0a64de" dependencies = [ "rayon", ] @@ -939,27 +1009,73 @@ dependencies = [ [[package]] name = "craft-dialogs" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=390fe98b0dd3fb84db7c3af7cbd958db4e8cc585#390fe98b0dd3fb84db7c3af7cbd958db4e8cc585" +source = "git+https://github.com/aiongg/craft-libs?rev=cd87dc61f77d8470b2e9e6a1236f9a84ee0a64de#cd87dc61f77d8470b2e9e6a1236f9a84ee0a64de" dependencies = [ "block2 0.6.2", + "craft-atomic", + "craft-host", + "craft-i18n", + "craft-platform", + "futures-lite", + "log", "objc2 0.6.5", "objc2-app-kit 0.3.2", "objc2-foundation 0.3.2", "raw-window-handle", "rfd", + "zbus", +] + +[[package]] +name = "craft-docpath" +version = "0.1.0" +source = "git+https://github.com/aiongg/craft-libs?rev=cd87dc61f77d8470b2e9e6a1236f9a84ee0a64de#cd87dc61f77d8470b2e9e6a1236f9a84ee0a64de" +dependencies = [ + "serde", +] + +[[package]] +name = "craft-font-catalog" +version = "0.1.0" +source = "git+https://github.com/aiongg/craft-libs?rev=cd87dc61f77d8470b2e9e6a1236f9a84ee0a64de#cd87dc61f77d8470b2e9e6a1236f9a84ee0a64de" +dependencies = [ + "harfrust 0.13.3", + "kurbo", + "skrifa 0.47.0", + "thiserror 2.0.21", + "unicode-bidi", + "unicode-segmentation", + "windows-registry", ] [[package]] name = "craft-fonts-build" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=390fe98b0dd3fb84db7c3af7cbd958db4e8cc585#390fe98b0dd3fb84db7c3af7cbd958db4e8cc585" +source = "git+https://github.com/aiongg/craft-libs?rev=cd87dc61f77d8470b2e9e6a1236f9a84ee0a64de#cd87dc61f77d8470b2e9e6a1236f9a84ee0a64de" + +[[package]] +name = "craft-host" +version = "0.1.0" +source = "git+https://github.com/aiongg/craft-libs?rev=cd87dc61f77d8470b2e9e6a1236f9a84ee0a64de#cd87dc61f77d8470b2e9e6a1236f9a84ee0a64de" +dependencies = [ + "bitflags 2.13.2", + "craft-i18n", + "egui", + "serde", + "toml", + "web-time", +] [[package]] name = "craft-i18n" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=390fe98b0dd3fb84db7c3af7cbd958db4e8cc585#390fe98b0dd3fb84db7c3af7cbd958db4e8cc585" +source = "git+https://github.com/aiongg/craft-libs?rev=cd87dc61f77d8470b2e9e6a1236f9a84ee0a64de#cd87dc61f77d8470b2e9e6a1236f9a84ee0a64de" dependencies = [ + "chrono", "fixed_decimal", + "icu_calendar", + "icu_collator", + "icu_datetime", "icu_decimal", "icu_locale_core", "icu_locale_fallback", @@ -969,6 +1085,7 @@ dependencies = [ "icu_provider", "icu_provider_adapters", "icu_provider_blob", + "icu_time", "log", "objc2-foundation 0.3.2", "sys-locale", @@ -980,7 +1097,7 @@ dependencies = [ [[package]] name = "craft-image-codecs" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=3dff4793f1a5bd1f99a4fe3280d48f515158dff3#3dff4793f1a5bd1f99a4fe3280d48f515158dff3" +source = "git+https://github.com/aiongg/craft-libs?rev=cd87dc61f77d8470b2e9e6a1236f9a84ee0a64de#cd87dc61f77d8470b2e9e6a1236f9a84ee0a64de" dependencies = [ "craft-dds", "craft-jpeg", @@ -1007,7 +1124,7 @@ dependencies = [ [[package]] name = "craft-jpeg" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=3dff4793f1a5bd1f99a4fe3280d48f515158dff3#3dff4793f1a5bd1f99a4fe3280d48f515158dff3" +source = "git+https://github.com/aiongg/craft-libs?rev=cd87dc61f77d8470b2e9e6a1236f9a84ee0a64de#cd87dc61f77d8470b2e9e6a1236f9a84ee0a64de" dependencies = [ "thiserror 2.0.21", ] @@ -1015,8 +1132,13 @@ dependencies = [ [[package]] name = "craft-keymap" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=390fe98b0dd3fb84db7c3af7cbd958db4e8cc585#390fe98b0dd3fb84db7c3af7cbd958db4e8cc585" +source = "git+https://github.com/aiongg/craft-libs?rev=cd87dc61f77d8470b2e9e6a1236f9a84ee0a64de#cd87dc61f77d8470b2e9e6a1236f9a84ee0a64de" dependencies = [ + "craft-host", + "craft-i18n", + "craft-tracked", + "craft-ui-macros", + "craft-xml", "egui", "serde", "serde_json", @@ -1025,18 +1147,18 @@ dependencies = [ [[package]] name = "craft-materialx" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=390fe98b0dd3fb84db7c3af7cbd958db4e8cc585#390fe98b0dd3fb84db7c3af7cbd958db4e8cc585" +source = "git+https://github.com/aiongg/craft-libs?rev=cd87dc61f77d8470b2e9e6a1236f9a84ee0a64de#cd87dc61f77d8470b2e9e6a1236f9a84ee0a64de" dependencies = [ - "craft-xml 0.1.0 (git+https://github.com/storytold/craft-libs?rev=390fe98b0dd3fb84db7c3af7cbd958db4e8cc585)", + "craft-xml", "thiserror 2.0.21", ] [[package]] name = "craft-mcmat" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=7a7a18cb40ac4cd5fca29c0dc224ac5178d40a89#7a7a18cb40ac4cd5fca29c0dc224ac5178d40a89" +source = "git+https://github.com/aiongg/craft-libs?rev=cd87dc61f77d8470b2e9e6a1236f9a84ee0a64de#cd87dc61f77d8470b2e9e6a1236f9a84ee0a64de" dependencies = [ - "craft-zip 0.1.0 (git+https://github.com/storytold/craft-libs?rev=7a7a18cb40ac4cd5fca29c0dc224ac5178d40a89)", + "craft-zip", "serde", "serde_json", "thiserror 2.0.21", @@ -1045,23 +1167,28 @@ dependencies = [ [[package]] name = "craft-menu" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=390fe98b0dd3fb84db7c3af7cbd958db4e8cc585#390fe98b0dd3fb84db7c3af7cbd958db4e8cc585" +source = "git+https://github.com/aiongg/craft-libs?rev=cd87dc61f77d8470b2e9e6a1236f9a84ee0a64de#cd87dc61f77d8470b2e9e6a1236f9a84ee0a64de" dependencies = [ + "craft-behavior", + "craft-host", + "craft-i18n", "craft-keymap", "craft-quit", + "craft-theme", + "craft-ui", + "craft-window", "egui", - "muda", - "objc2 0.6.5", - "objc2-app-kit 0.3.2", + "serde", + "serde_json", ] [[package]] name = "craft-mesh" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=a20dfd1623709b0bd9830106d3a92a1a443902e3#a20dfd1623709b0bd9830106d3a92a1a443902e3" +source = "git+https://github.com/aiongg/craft-libs?rev=cd87dc61f77d8470b2e9e6a1236f9a84ee0a64de#cd87dc61f77d8470b2e9e6a1236f9a84ee0a64de" dependencies = [ - "craft-xml 0.1.0 (git+https://github.com/storytold/craft-libs?rev=a20dfd1623709b0bd9830106d3a92a1a443902e3)", - "craft-zip 0.1.0 (git+https://github.com/storytold/craft-libs?rev=a20dfd1623709b0bd9830106d3a92a1a443902e3)", + "craft-xml", + "craft-zip", "miniz_oxide 0.9.1", "serde_json", ] @@ -1069,7 +1196,7 @@ dependencies = [ [[package]] name = "craft-metadata" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=3dff4793f1a5bd1f99a4fe3280d48f515158dff3#3dff4793f1a5bd1f99a4fe3280d48f515158dff3" +source = "git+https://github.com/aiongg/craft-libs?rev=cd87dc61f77d8470b2e9e6a1236f9a84ee0a64de#cd87dc61f77d8470b2e9e6a1236f9a84ee0a64de" dependencies = [ "brotli-decompressor", "chrono", @@ -1078,10 +1205,49 @@ dependencies = [ "serde", ] +[[package]] +name = "craft-pdf" +version = "0.1.0" +source = "git+https://github.com/aiongg/craft-libs?rev=cd87dc61f77d8470b2e9e6a1236f9a84ee0a64de#cd87dc61f77d8470b2e9e6a1236f9a84ee0a64de" +dependencies = [ + "serde", +] + +[[package]] +name = "craft-platform" +version = "0.1.0" +source = "git+https://github.com/aiongg/craft-libs?rev=cd87dc61f77d8470b2e9e6a1236f9a84ee0a64de#cd87dc61f77d8470b2e9e6a1236f9a84ee0a64de" +dependencies = [ + "async-channel", + "async-io", + "async-process", + "core-graphics2", + "craft-atomic", + "craft-docpath", + "craft-host", + "craft-i18n", + "craft-theme", + "futures-lite", + "js-sys", + "log", + "objc2-app-kit 0.3.2", + "rfd", + "serde", + "serde_json", + "wasm-bindgen", + "wasm-bindgen-futures", + "web-sys", + "web-time", + "windows", + "x11rb", + "xcap", + "zbus", +] + [[package]] name = "craft-psd" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=b130ac1fa44f923c3024884ab8ceb5ccdb88f15f#b130ac1fa44f923c3024884ab8ceb5ccdb88f15f" +source = "git+https://github.com/aiongg/craft-libs?rev=cd87dc61f77d8470b2e9e6a1236f9a84ee0a64de#cd87dc61f77d8470b2e9e6a1236f9a84ee0a64de" dependencies = [ "encoding_rs", "flate2", @@ -1092,69 +1258,264 @@ dependencies = [ [[package]] name = "craft-quit" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=390fe98b0dd3fb84db7c3af7cbd958db4e8cc585#390fe98b0dd3fb84db7c3af7cbd958db4e8cc585" +source = "git+https://github.com/aiongg/craft-libs?rev=cd87dc61f77d8470b2e9e6a1236f9a84ee0a64de#cd87dc61f77d8470b2e9e6a1236f9a84ee0a64de" dependencies = [ "dispatch2", "egui", "objc2 0.6.5", "objc2-app-kit 0.3.2", + "wasm-bindgen", + "web-sys", +] + +[[package]] +name = "craft-settings" +version = "0.1.0" +source = "git+https://github.com/aiongg/craft-libs?rev=cd87dc61f77d8470b2e9e6a1236f9a84ee0a64de#cd87dc61f77d8470b2e9e6a1236f9a84ee0a64de" +dependencies = [ + "craft-atomic", + "craft-host", + "dirs", + "log", + "serde", + "serde_json", + "toml", + "toml_edit", + "web-sys", + "web-time", +] + +[[package]] +name = "craft-svg" +version = "0.1.0" +source = "git+https://github.com/aiongg/craft-libs?rev=cd87dc61f77d8470b2e9e6a1236f9a84ee0a64de#cd87dc61f77d8470b2e9e6a1236f9a84ee0a64de" +dependencies = [ + "craft-xml", + "flate2", + "kurbo", + "quick-xml 0.41.0", + "resvg", + "roxmltree", + "thiserror 2.0.21", + "usvg", + "vectorcraft-geom", + "vectorcraft-pathops", ] [[package]] name = "craft-tcraft" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=c376774f15ae7cd3b06a7ac664f01a8645af4b83#c376774f15ae7cd3b06a7ac664f01a8645af4b83" +source = "git+https://github.com/aiongg/craft-libs?rev=cd87dc61f77d8470b2e9e6a1236f9a84ee0a64de#cd87dc61f77d8470b2e9e6a1236f9a84ee0a64de" dependencies = [ - "craft-zip 0.1.0 (git+https://github.com/storytold/craft-libs?rev=c376774f15ae7cd3b06a7ac664f01a8645af4b83)", + "craft-zip", "serde", "serde_json", "thiserror 2.0.21", ] +[[package]] +name = "craft-theme" +version = "0.1.0" +source = "git+https://github.com/aiongg/craft-libs?rev=cd87dc61f77d8470b2e9e6a1236f9a84ee0a64de#cd87dc61f77d8470b2e9e6a1236f9a84ee0a64de" +dependencies = [ + "bitflags 2.13.2", + "craft-tracked", + "craft-ui-macros", + "ecolor", + "log", + "serde", + "serde_json", + "smallvec", +] + [[package]] name = "craft-tiff" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=3dff4793f1a5bd1f99a4fe3280d48f515158dff3#3dff4793f1a5bd1f99a4fe3280d48f515158dff3" +source = "git+https://github.com/aiongg/craft-libs?rev=cd87dc61f77d8470b2e9e6a1236f9a84ee0a64de#cd87dc61f77d8470b2e9e6a1236f9a84ee0a64de" dependencies = [ "serde", "thiserror 2.0.21", + "tiff", ] +[[package]] +name = "craft-tracked" +version = "0.1.0" +source = "git+https://github.com/aiongg/craft-libs?rev=cd87dc61f77d8470b2e9e6a1236f9a84ee0a64de#cd87dc61f77d8470b2e9e6a1236f9a84ee0a64de" + [[package]] name = "craft-ui" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=390fe98b0dd3fb84db7c3af7cbd958db4e8cc585#390fe98b0dd3fb84db7c3af7cbd958db4e8cc585" +source = "git+https://github.com/aiongg/craft-libs?rev=cd87dc61f77d8470b2e9e6a1236f9a84ee0a64de#cd87dc61f77d8470b2e9e6a1236f9a84ee0a64de" dependencies = [ - "craft-fonts-build", + "craft-cloud-ui", + "craft-ui-canvas", + "craft-ui-contract", + "craft-ui-panels", + "craft-ui-patterns", + "craft-ui-shell", + "craft-ui-widgets", +] + +[[package]] +name = "craft-ui-canvas" +version = "0.1.0" +source = "git+https://github.com/aiongg/craft-libs?rev=cd87dc61f77d8470b2e9e6a1236f9a84ee0a64de#cd87dc61f77d8470b2e9e6a1236f9a84ee0a64de" +dependencies = [ + "craft-behavior", "craft-i18n", + "craft-keymap", + "craft-theme", + "craft-ui-macros", + "craft-ui-panels", "egui", - "epaint", - "js-sys", - "log", - "objc2 0.6.5", - "objc2-app-kit 0.3.2", - "objc2-foundation 0.3.2", "serde", + "serde_json", +] + +[[package]] +name = "craft-ui-contract" +version = "0.1.0" +source = "git+https://github.com/aiongg/craft-libs?rev=cd87dc61f77d8470b2e9e6a1236f9a84ee0a64de#cd87dc61f77d8470b2e9e6a1236f9a84ee0a64de" +dependencies = [ + "accesskit", + "craft-behavior", + "craft-codepage", + "craft-font-catalog", + "craft-fonts-build", + "craft-host", + "craft-i18n", + "craft-keymap", + "craft-platform", + "craft-quit", + "craft-settings", + "craft-svg", + "craft-theme", + "craft-tracked", + "craft-ui-macros", + "craft-window", + "egui", + "epaint_default_fonts", + "flate2", + "inventory", + "log", + "scoped-tls", + "serde", + "serde_json", + "siphasher", "skrifa 0.44.0", - "wasm-bindgen", + "smallvec", + "toml", + "typeid", "wasm-bindgen-futures", - "web-sys", + "web-time", +] + +[[package]] +name = "craft-ui-macros" +version = "0.1.0" +source = "git+https://github.com/aiongg/craft-libs?rev=cd87dc61f77d8470b2e9e6a1236f9a84ee0a64de#cd87dc61f77d8470b2e9e6a1236f9a84ee0a64de" +dependencies = [ + "proc-macro-crate", + "proc-macro2", + "quote", + "syn 2.0.119", +] + +[[package]] +name = "craft-ui-panels" +version = "0.1.0" +source = "git+https://github.com/aiongg/craft-libs?rev=cd87dc61f77d8470b2e9e6a1236f9a84ee0a64de#cd87dc61f77d8470b2e9e6a1236f9a84ee0a64de" +dependencies = [ + "craft-behavior", + "craft-host", + "craft-i18n", + "craft-keymap", + "craft-quit", + "craft-theme", + "craft-ui-macros", + "craft-ui-widgets", + "egui", + "serde", + "serde_json", +] + +[[package]] +name = "craft-ui-patterns" +version = "0.1.0" +source = "git+https://github.com/aiongg/craft-libs?rev=cd87dc61f77d8470b2e9e6a1236f9a84ee0a64de#cd87dc61f77d8470b2e9e6a1236f9a84ee0a64de" +dependencies = [ + "craft-behavior", + "craft-host", + "craft-i18n", + "craft-keymap", + "craft-pdf", + "craft-theme", + "craft-ui-macros", + "craft-ui-panels", + "egui", + "serde", + "serde_json", + "toml", + "toml_edit", + "zeroize", +] + +[[package]] +name = "craft-ui-shell" +version = "0.1.0" +source = "git+https://github.com/aiongg/craft-libs?rev=cd87dc61f77d8470b2e9e6a1236f9a84ee0a64de#cd87dc61f77d8470b2e9e6a1236f9a84ee0a64de" +dependencies = [ + "craft-behavior", + "craft-host", + "craft-i18n", + "craft-platform", + "craft-svg", + "craft-theme", + "craft-ui-macros", + "craft-ui-panels", + "craft-window", + "egui", + "raw-window-handle", + "serde", + "web-time", +] + +[[package]] +name = "craft-ui-widgets" +version = "0.1.0" +source = "git+https://github.com/aiongg/craft-libs?rev=cd87dc61f77d8470b2e9e6a1236f9a84ee0a64de#cd87dc61f77d8470b2e9e6a1236f9a84ee0a64de" +dependencies = [ + "craft-behavior", + "craft-host", + "craft-i18n", + "craft-keymap", + "craft-svg", + "craft-theme", + "craft-ui-contract", + "craft-ui-macros", + "egui", + "log", + "serde", + "smallvec", ] [[package]] name = "craft-update" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=390fe98b0dd3fb84db7c3af7cbd958db4e8cc585#390fe98b0dd3fb84db7c3af7cbd958db4e8cc585" +source = "git+https://github.com/aiongg/craft-libs?rev=cd87dc61f77d8470b2e9e6a1236f9a84ee0a64de#cd87dc61f77d8470b2e9e6a1236f9a84ee0a64de" dependencies = [ "chrono", + "craft-host", + "craft-theme", + "craft-ui", "dunce", "egui", "flate2", - "getrandom 0.3.4", "image", "log", "plist", - "rustix 1.1.5", + "rustix 1.1.6", "semver", "serde", "serde_json", @@ -1171,38 +1532,47 @@ dependencies = [ [[package]] name = "craft-usd" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=3dff4793f1a5bd1f99a4fe3280d48f515158dff3#3dff4793f1a5bd1f99a4fe3280d48f515158dff3" +source = "git+https://github.com/aiongg/craft-libs?rev=cd87dc61f77d8470b2e9e6a1236f9a84ee0a64de#cd87dc61f77d8470b2e9e6a1236f9a84ee0a64de" dependencies = [ "half", "lz4_flex", "thiserror 2.0.21", ] +[[package]] +name = "craft-win32" +version = "0.1.0" +source = "git+https://github.com/aiongg/craft-libs?rev=cd87dc61f77d8470b2e9e6a1236f9a84ee0a64de#cd87dc61f77d8470b2e9e6a1236f9a84ee0a64de" +dependencies = [ + "winsafe", +] + [[package]] name = "craft-window" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=390fe98b0dd3fb84db7c3af7cbd958db4e8cc585#390fe98b0dd3fb84db7c3af7cbd958db4e8cc585" +source = "git+https://github.com/aiongg/craft-libs?rev=cd87dc61f77d8470b2e9e6a1236f9a84ee0a64de#cd87dc61f77d8470b2e9e6a1236f9a84ee0a64de" dependencies = [ + "craft-atomic", + "craft-behavior", + "craft-host", + "craft-settings", + "craft-win32", "egui", + "muda", "objc2 0.6.5", "objc2-app-kit 0.3.2", + "objc2-foundation 0.3.2", + "raw-window-handle", + "serde", + "serde_json", "wayland-client", + "winsafe", ] [[package]] name = "craft-xml" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=390fe98b0dd3fb84db7c3af7cbd958db4e8cc585#390fe98b0dd3fb84db7c3af7cbd958db4e8cc585" -dependencies = [ - "quick-xml 0.41.0", - "serde", - "thiserror 2.0.21", -] - -[[package]] -name = "craft-xml" -version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=a20dfd1623709b0bd9830106d3a92a1a443902e3#a20dfd1623709b0bd9830106d3a92a1a443902e3" +source = "git+https://github.com/aiongg/craft-libs?rev=cd87dc61f77d8470b2e9e6a1236f9a84ee0a64de#cd87dc61f77d8470b2e9e6a1236f9a84ee0a64de" dependencies = [ "quick-xml 0.41.0", "serde", @@ -1212,37 +1582,7 @@ dependencies = [ [[package]] name = "craft-zip" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=5631e99fe126cffb74c673eb458db04299f2bb9b#5631e99fe126cffb74c673eb458db04299f2bb9b" -dependencies = [ - "flate2", - "thiserror 2.0.21", - "zip", -] - -[[package]] -name = "craft-zip" -version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=7a7a18cb40ac4cd5fca29c0dc224ac5178d40a89#7a7a18cb40ac4cd5fca29c0dc224ac5178d40a89" -dependencies = [ - "flate2", - "thiserror 2.0.21", - "zip", -] - -[[package]] -name = "craft-zip" -version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=a20dfd1623709b0bd9830106d3a92a1a443902e3#a20dfd1623709b0bd9830106d3a92a1a443902e3" -dependencies = [ - "flate2", - "thiserror 2.0.21", - "zip", -] - -[[package]] -name = "craft-zip" -version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=c376774f15ae7cd3b06a7ac664f01a8645af4b83#c376774f15ae7cd3b06a7ac664f01a8645af4b83" +source = "git+https://github.com/aiongg/craft-libs?rev=cd87dc61f77d8470b2e9e6a1236f9a84ee0a64de#cd87dc61f77d8470b2e9e6a1236f9a84ee0a64de" dependencies = [ "flate2", "thiserror 2.0.21", @@ -1348,6 +1688,12 @@ dependencies = [ "syn 3.0.9", ] +[[package]] +name = "data-url" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "be1e0bca6c3637f992fc1cc7cbc52a78c1ef6db076dbf1059c4323d6a2048376" + [[package]] name = "deranged" version = "0.5.9" @@ -1364,6 +1710,27 @@ dependencies = [ "crypto-common", ] +[[package]] +name = "dirs" +version = "7.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8d57d423b3c82e89b9a24ca3091fee61f456a26edbd28d26c65906f4bc1dcd8f" +dependencies = [ + "dirs-sys", +] + +[[package]] +name = "dirs-sys" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e01a3366d27ee9890022452ee61b2b63a67e6f13f58900b651ff5665f0bb1fab" +dependencies = [ + "libc", + "option-ext", + "redox_users", + "windows-sys 0.60.2", +] + [[package]] name = "dispatch" version = "0.2.0" @@ -1449,7 +1816,7 @@ dependencies = [ "drm-ffi", "drm-fourcc", "libc", - "rustix 1.1.5", + "rustix 1.1.6", ] [[package]] @@ -1459,7 +1826,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "51a91c9b32ac4e8105dec255e849e0d66e27d7c34d184364fb93e469db08f690" dependencies = [ "drm-sys", - "rustix 1.1.5", + "rustix 1.1.6", ] [[package]] @@ -1493,7 +1860,7 @@ checksum = "d0881ea181b1df73ff77ffaaf9c7544ecc11e82fba9b5f27b262a3c73a332555" [[package]] name = "ecolor" version = "0.37.0" -source = "git+https://github.com/storytold/egui.git?rev=6d518fc799681571963842f95b55a6b68431b15a#6d518fc799681571963842f95b55a6b68431b15a" +source = "git+https://github.com/storytold/egui.git?rev=f5025284445ea19c35f746d96fc0b75468b3f560#f5025284445ea19c35f746d96fc0b75468b3f560" dependencies = [ "bytemuck", "emath", @@ -1503,7 +1870,7 @@ dependencies = [ [[package]] name = "eframe" version = "0.37.0" -source = "git+https://github.com/storytold/egui.git?rev=6d518fc799681571963842f95b55a6b68431b15a#6d518fc799681571963842f95b55a6b68431b15a" +source = "git+https://github.com/storytold/egui.git?rev=f5025284445ea19c35f746d96fc0b75468b3f560#f5025284445ea19c35f746d96fc0b75468b3f560" dependencies = [ "ahash", "bytemuck", @@ -1540,7 +1907,7 @@ dependencies = [ [[package]] name = "egui" version = "0.37.0" -source = "git+https://github.com/storytold/egui.git?rev=6d518fc799681571963842f95b55a6b68431b15a#6d518fc799681571963842f95b55a6b68431b15a" +source = "git+https://github.com/storytold/egui.git?rev=f5025284445ea19c35f746d96fc0b75468b3f560#f5025284445ea19c35f746d96fc0b75468b3f560" dependencies = [ "accesskit", "ahash", @@ -1568,7 +1935,7 @@ dependencies = [ [[package]] name = "egui-wgpu" version = "0.37.0" -source = "git+https://github.com/storytold/egui.git?rev=6d518fc799681571963842f95b55a6b68431b15a#6d518fc799681571963842f95b55a6b68431b15a" +source = "git+https://github.com/storytold/egui.git?rev=f5025284445ea19c35f746d96fc0b75468b3f560#f5025284445ea19c35f746d96fc0b75468b3f560" dependencies = [ "ahash", "bytemuck", @@ -1587,7 +1954,7 @@ dependencies = [ [[package]] name = "egui-winit" version = "0.37.0" -source = "git+https://github.com/storytold/egui.git?rev=6d518fc799681571963842f95b55a6b68431b15a#6d518fc799681571963842f95b55a6b68431b15a" +source = "git+https://github.com/storytold/egui.git?rev=f5025284445ea19c35f746d96fc0b75468b3f560#f5025284445ea19c35f746d96fc0b75468b3f560" dependencies = [ "accesskit_winit", "arboard", @@ -1611,7 +1978,7 @@ dependencies = [ [[package]] name = "egui_glow" version = "0.37.0" -source = "git+https://github.com/storytold/egui.git?rev=6d518fc799681571963842f95b55a6b68431b15a#6d518fc799681571963842f95b55a6b68431b15a" +source = "git+https://github.com/storytold/egui.git?rev=f5025284445ea19c35f746d96fc0b75468b3f560#f5025284445ea19c35f746d96fc0b75468b3f560" dependencies = [ "bytemuck", "egui", @@ -1624,7 +1991,7 @@ dependencies = [ [[package]] name = "egui_kittest" version = "0.37.0" -source = "git+https://github.com/storytold/egui.git?rev=6d518fc799681571963842f95b55a6b68431b15a#6d518fc799681571963842f95b55a6b68431b15a" +source = "git+https://github.com/storytold/egui.git?rev=f5025284445ea19c35f746d96fc0b75468b3f560#f5025284445ea19c35f746d96fc0b75468b3f560" dependencies = [ "eframe", "egui", @@ -1647,12 +2014,24 @@ checksum = "0e9c71c2167ca323c882b99918929403426e2373ea17242ff5653e0d5e1058be" [[package]] name = "emath" version = "0.37.0" -source = "git+https://github.com/storytold/egui.git?rev=6d518fc799681571963842f95b55a6b68431b15a#6d518fc799681571963842f95b55a6b68431b15a" +source = "git+https://github.com/storytold/egui.git?rev=f5025284445ea19c35f746d96fc0b75468b3f560#f5025284445ea19c35f746d96fc0b75468b3f560" dependencies = [ "bytemuck", "serde", ] +[[package]] +name = "embedded-io" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ef1a6892d9eef45c8fa6b9e0086428a2cca8491aca8f787c534a3d6d0bcb3ced" + +[[package]] +name = "embedded-io" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "edd0f118536f44f5ccd48bcb8b111bdc3de888b58c74639dfb034a357d0f206d" + [[package]] name = "encoding_rs" version = "0.8.44" @@ -1708,7 +2087,7 @@ dependencies = [ [[package]] name = "epaint" version = "0.37.0" -source = "git+https://github.com/storytold/egui.git?rev=6d518fc799681571963842f95b55a6b68431b15a#6d518fc799681571963842f95b55a6b68431b15a" +source = "git+https://github.com/storytold/egui.git?rev=f5025284445ea19c35f746d96fc0b75468b3f560#f5025284445ea19c35f746d96fc0b75468b3f560" dependencies = [ "ahash", "bytemuck", @@ -1716,7 +2095,7 @@ dependencies = [ "emath", "epaint_default_fonts", "font-types", - "harfrust", + "harfrust 0.12.0", "log", "nohash-hasher", "parking_lot", @@ -1735,7 +2114,7 @@ dependencies = [ [[package]] name = "epaint_default_fonts" version = "0.37.0" -source = "git+https://github.com/storytold/egui.git?rev=6d518fc799681571963842f95b55a6b68431b15a#6d518fc799681571963842f95b55a6b68431b15a" +source = "git+https://github.com/storytold/egui.git?rev=f5025284445ea19c35f746d96fc0b75468b3f560#f5025284445ea19c35f746d96fc0b75468b3f560" [[package]] name = "equivalent" @@ -1750,7 +2129,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "39cab71617ae0d63f51a36d69f866391735b51691dbda63cf6f96d042b63efeb" dependencies = [ "libc", - "windows-sys 0.61.2", + "windows-sys 0.52.0", ] [[package]] @@ -1876,6 +2255,12 @@ dependencies = [ "zlib-rs", ] +[[package]] +name = "float-cmp" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "98de4bbd547a563b716d8dfa9aad1cb19bfab00f4fa09a6a4ed21dbcf44ce9c4" + [[package]] name = "foldhash" version = "0.1.5" @@ -1941,8 +2326,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "94e7099f6313ecacbe1256e8ff9d617b75d1bcb16a6fddef94866d225a01a14a" dependencies = [ "io-lifetimes 2.0.4", - "rustix 1.1.5", - "windows-sys 0.59.0", + "rustix 1.1.6", + "windows-sys 0.52.0", ] [[package]] @@ -2086,7 +2471,7 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1bd49230192a3797a9a4d6abe9b3eed6f7fa4c8a8a4947977c6f80025f92cbd8" dependencies = [ - "rustix 1.1.5", + "rustix 1.1.6", "windows-link", ] @@ -2359,6 +2744,19 @@ dependencies = [ "smallvec", ] +[[package]] +name = "harfrust" +version = "0.13.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "948d0741125ba89cd3e1c23e5642415b6ade7e1d29d67ba25fb925b533e989d6" +dependencies = [ + "bitflags 2.13.2", + "bytemuck", + "once_cell", + "read-fonts 0.43.3", + "smallvec", +] + [[package]] name = "hashbrown" version = "0.15.5" @@ -2455,6 +2853,39 @@ dependencies = [ "cc", ] +[[package]] +name = "icu_calendar" +version = "2.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "58655df2f728e46e4eee80bddebefacf52ec3e77cdb925014b47c5a5905eb55c" +dependencies = [ + "calendrical_calculations", + "displaydoc", + "icu_locale_core", + "icu_provider", + "serde", + "tinystr", + "zerovec", +] + +[[package]] +name = "icu_collator" +version = "2.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "08984ed58ac439ebf3e13d2cf26b0c46a60afcd21721c1d14087c0b240344dda" +dependencies = [ + "icu_collections", + "icu_locale_core", + "icu_normalizer", + "icu_properties", + "icu_provider", + "serde", + "smallvec", + "utf16_iter", + "utf8_iter", + "zerovec", +] + [[package]] name = "icu_collections" version = "2.3.0" @@ -2463,12 +2894,37 @@ checksum = "fa68d21081c4a05d5a901a1c62add574c77048b6a1c67be3b50ce0b60d4ca513" dependencies = [ "displaydoc", "potential_utf", + "serde", "utf8_iter", "yoke", "zerofrom", "zerovec", ] +[[package]] +name = "icu_datetime" +version = "2.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c44df99c4c5297b05653d1a1629f13bdc9fd4044acfbbaf30b15194a1eed4cd6" +dependencies = [ + "displaydoc", + "fixed_decimal", + "icu_calendar", + "icu_decimal", + "icu_locale_core", + "icu_pattern", + "icu_plurals", + "icu_provider", + "icu_time", + "potential_utf", + "serde", + "smallvec", + "tinystr", + "writeable", + "zerotrie", + "zerovec", +] + [[package]] name = "icu_decimal" version = "2.3.0" @@ -2530,6 +2986,7 @@ dependencies = [ "icu_normalizer_data", "icu_properties", "icu_provider", + "serde", "smallvec", "utf16_iter", "utf8_iter", @@ -2580,6 +3037,7 @@ dependencies = [ "icu_locale_core", "icu_properties_data", "icu_provider", + "serde", "zerotrie", "zerovec", ] @@ -2632,6 +3090,22 @@ dependencies = [ "zerovec", ] +[[package]] +name = "icu_time" +version = "2.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "af37e1c3b9f3ab564b619fdf4b22de169f6381eb0f7048e3ca454290c438126b" +dependencies = [ + "calendrical_calculations", + "displaydoc", + "icu_calendar", + "icu_locale_core", + "icu_provider", + "serde", + "zerotrie", + "zerovec", +] + [[package]] name = "ident_case" version = "1.0.1" @@ -2690,6 +3164,12 @@ dependencies = [ "quick-error", ] +[[package]] +name = "imagesize" +version = "0.15.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "65b27460c2c92b037f3f94c538ed9a3342f3fdf923606781629ccb35f82d042a" + [[package]] name = "indexmap" version = "2.14.2" @@ -2708,6 +3188,15 @@ version = "1.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a257582fdcde896fd96463bf2d40eefea0580021c0712a0e2b028b60b47a837a" +[[package]] +name = "inventory" +version = "0.3.25" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6928282826c822ad91bf1c9a1cb90a30ba1c26770749929b4656cd6be829cd7c" +dependencies = [ + "rustversion", +] + [[package]] name = "io-extras" version = "0.19.0" @@ -2891,6 +3380,7 @@ dependencies = [ "arrayvec", "euclid", "polycool", + "serde", "smallvec", ] @@ -2952,7 +3442,7 @@ dependencies = [ "libc", "libspa-sys", "nom 8.0.0", - "rustix 1.1.5", + "rustix 1.1.6", "system-deps", ] @@ -2979,7 +3469,7 @@ dependencies = [ "image", "khronos-egl", "memmap2", - "rustix 1.1.5", + "rustix 1.1.6", "thiserror 2.0.21", "tracing", "wayland-backend", @@ -2994,6 +3484,19 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d4a5ff6bcca6c4867b1c4fd4ef63e4db7436ef363e0ad7531d1558856bae64f4" +[[package]] +name = "linesweeper" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a25df1b0c5432893f41bba817150e323703ee5f6d974f3a6808ac7fd7f046d18" +dependencies = [ + "arrayvec", + "kurbo", + "polycool", + "rustc-hash 2.1.3", + "smallvec", +] + [[package]] name = "linux-raw-sys" version = "0.4.15" @@ -3159,7 +3662,7 @@ dependencies = [ "objc2-foundation 0.3.2", "png", "thiserror 2.0.21", - "windows-sys 0.61.2", + "windows-sys 0.60.2", ] [[package]] @@ -3371,8 +3874,8 @@ dependencies = [ "block2 0.5.1", "libc", "objc2 0.5.3", - "objc2-core-data", - "objc2-core-image", + "objc2-core-data 0.2.2", + "objc2-core-image 0.2.2", "objc2-foundation 0.2.2", "objc2-quartz-core 0.2.2", ] @@ -3385,10 +3888,17 @@ checksum = "d49e936b501e5c5bf01fda3a9452ff86dc3ea98ad5f283e1455153142d97518c" dependencies = [ "bitflags 2.13.2", "block2 0.6.2", + "libc", "objc2 0.6.5", + "objc2-cloud-kit 0.3.2", + "objc2-core-data 0.3.2", "objc2-core-foundation", "objc2-core-graphics", + "objc2-core-image 0.3.2", + "objc2-core-text", + "objc2-core-video", "objc2-foundation 0.3.2", + "objc2-quartz-core 0.3.2", ] [[package]] @@ -3397,9 +3907,29 @@ version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "478ae33fcac9df0a18db8302387c666b8ef08a3e2d62b510ca4fc278a384b6c0" dependencies = [ + "bitflags 2.13.2", + "block2 0.6.2", + "dispatch2", "objc2 0.6.5", + "objc2-avf-audio", + "objc2-core-audio-types", + "objc2-core-foundation", "objc2-core-graphics", - "objc2-core-media", + "objc2-core-image 0.3.2", + "objc2-core-video", + "objc2-foundation 0.3.2", + "objc2-image-io", + "objc2-media-toolbox", + "objc2-quartz-core 0.3.2", +] + +[[package]] +name = "objc2-avf-audio" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "13a380031deed8e99db00065c45937da434ca987c034e13b87e4441f9e4090be" +dependencies = [ + "objc2 0.6.5", "objc2-foundation 0.3.2", ] @@ -3416,6 +3946,17 @@ dependencies = [ "objc2-foundation 0.2.2", ] +[[package]] +name = "objc2-cloud-kit" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "73ad74d880bb43877038da939b7427bba67e9dd42004a18b809ba7d87cee241c" +dependencies = [ + "bitflags 2.13.2", + "objc2 0.6.5", + "objc2-foundation 0.3.2", +] + [[package]] name = "objc2-contacts" version = "0.2.2" @@ -3461,6 +4002,17 @@ dependencies = [ "objc2-foundation 0.2.2", ] +[[package]] +name = "objc2-core-data" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b402a653efbb5e82ce4df10683b6b28027616a2715e90009947d50b8dd298fa" +dependencies = [ + "bitflags 2.13.2", + "objc2 0.6.5", + "objc2-foundation 0.3.2", +] + [[package]] name = "objc2-core-foundation" version = "0.3.2" @@ -3468,7 +4020,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2a180dd8642fa45cdb7dd721cd4c11b1cadd4929ce112ebd8b9f5803cc79d536" dependencies = [ "bitflags 2.13.2", + "block2 0.6.2", "dispatch2", + "libc", "objc2 0.6.5", ] @@ -3479,11 +4033,13 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e022c9d066895efa1345f8e33e584b9f958da2fd4cd116792e15e07e4720a807" dependencies = [ "bitflags 2.13.2", + "block2 0.6.2", "dispatch2", "libc", "objc2 0.6.5", "objc2-core-foundation", "objc2-io-surface", + "objc2-metal 0.3.2", ] [[package]] @@ -3498,6 +4054,16 @@ dependencies = [ "objc2-metal 0.2.2", ] +[[package]] +name = "objc2-core-image" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e5d563b38d2b97209f8e861173de434bd0214cf020e3423a52624cd1d989f006" +dependencies = [ + "objc2 0.6.5", + "objc2-foundation 0.3.2", +] + [[package]] name = "objc2-core-location" version = "0.2.2" @@ -3517,6 +4083,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "05ec576860167a15dd9fce7fbee7512beb4e31f532159d3482d1f9c6caedf31d" dependencies = [ "bitflags 2.13.2", + "block2 0.6.2", "dispatch2", "objc2 0.6.5", "objc2-core-audio", @@ -3525,6 +4092,18 @@ dependencies = [ "objc2-core-video", ] +[[package]] +name = "objc2-core-text" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0cde0dfb48d25d2b4862161a4d5fcc0e3c24367869ad306b0c9ec0073bfed92d" +dependencies = [ + "bitflags 2.13.2", + "objc2 0.6.5", + "objc2-core-foundation", + "objc2-core-graphics", +] + [[package]] name = "objc2-core-video" version = "0.3.2" @@ -3532,10 +4111,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d425caf1df73233f29fd8a5c3e5edbc30d2d4307870f802d18f00d83dc5141a6" dependencies = [ "bitflags 2.13.2", + "block2 0.6.2", "objc2 0.6.5", "objc2-core-foundation", "objc2-core-graphics", "objc2-io-surface", + "objc2-metal 0.3.2", ] [[package]] @@ -3565,10 +4146,22 @@ checksum = "e3e0adef53c21f888deb4fa59fc59f7eb17404926ee8a6f59f5df0fd7f9f3272" dependencies = [ "bitflags 2.13.2", "block2 0.6.2", + "libc", "objc2 0.6.5", "objc2-core-foundation", ] +[[package]] +name = "objc2-image-io" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32b0446e98cf4a784cc7a0177715ff317eeaa8463841c616cfc78aa4f953c4ea" +dependencies = [ + "objc2 0.6.5", + "objc2-core-foundation", + "objc2-core-graphics", +] + [[package]] name = "objc2-io-kit" version = "0.3.2" @@ -3602,6 +4195,18 @@ dependencies = [ "objc2-foundation 0.2.2", ] +[[package]] +name = "objc2-media-toolbox" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "edd9fdde720df3da7046bb9097811000c1e7ab5cd579fa89d96b27d56781fb30" +dependencies = [ + "objc2 0.6.5", + "objc2-core-audio-types", + "objc2-core-foundation", + "objc2-core-media", +] + [[package]] name = "objc2-metal" version = "0.2.2" @@ -3672,9 +4277,9 @@ dependencies = [ "bitflags 2.13.2", "block2 0.5.1", "objc2 0.5.3", - "objc2-cloud-kit", - "objc2-core-data", - "objc2-core-image", + "objc2-cloud-kit 0.2.2", + "objc2-core-data 0.2.2", + "objc2-core-image 0.2.2", "objc2-core-location", "objc2-foundation 0.2.2", "objc2-link-presentation", @@ -3732,6 +4337,12 @@ version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7e036b411754132fd6b74e94b74e9a13c5cf606fa93d1885c35860d3060820b1" +[[package]] +name = "option-ext" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "04744f49eae99ab78e0d5c0b603ab218f515ea8cfe5a456d7629ad883a3b6e7d" + [[package]] name = "orbclient" version = "0.3.55" @@ -3768,7 +4379,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7d8fae84b431384b68627d0f9b3b1245fcf9f46f6c0e3dc902e9dce64edd1967" dependencies = [ "libc", - "windows-sys 0.61.2", + "windows-sys 0.52.0", ] [[package]] @@ -3885,6 +4496,12 @@ dependencies = [ "siphasher", ] +[[package]] +name = "pico-args" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5be167a7af36ee22fe3115051bc51f6e6c7054c9348e28deb4f49bd6f705a315" + [[package]] name = "pin-project" version = "1.1.13" @@ -3933,7 +4550,7 @@ dependencies = [ "libspa", "libspa-sys", "pipewire-sys", - "rustix 1.1.5", + "rustix 1.1.6", ] [[package]] @@ -3995,7 +4612,7 @@ dependencies = [ "concurrent-queue", "hermit-abi", "pin-project-lite", - "rustix 1.1.5", + "rustix 1.1.6", "windows-sys 0.61.2", ] @@ -4042,6 +4659,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6764c3b5dd454e283a30e6dfe78e9b31096d9e32036b5d1eaac7a6119ccb9a24" dependencies = [ "cobs", + "embedded-io 0.4.0", + "embedded-io 0.6.1", "serde", ] @@ -4273,6 +4892,28 @@ dependencies = [ "once_cell", ] +[[package]] +name = "read-fonts" +version = "0.43.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "005c8acf251756c478b0bf402885bfd88a1476020c4c7e6060edc1aa68da38ea" +dependencies = [ + "bytemuck", + "font-types", + "once_cell", +] + +[[package]] +name = "read-fonts" +version = "0.44.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d5a0cf4bb6cbce4c29756270d189a5e400ac05e91192161d83a0bcb6e68492e8" +dependencies = [ + "bytemuck", + "font-types", + "once_cell", +] + [[package]] name = "read-fonts" version = "0.45.1" @@ -4319,6 +4960,16 @@ dependencies = [ "bitflags 2.13.2", ] +[[package]] +name = "redox_users" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "60dc65c0ff1a7ae1294b0c67b9f14baf70b644404010370171787bfac1038fc0" +dependencies = [ + "libredox", + "thiserror 2.0.21", +] + [[package]] name = "ref-cast" version = "1.0.27" @@ -4374,6 +5025,21 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "19b30a45b0cd0bcca8037f3d0dc3421eaf95327a17cad11964fb8179b4fc4832" +[[package]] +name = "resvg" +version = "0.48.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "67e3803f97b999e80cbf7c6ecdd07a8102204d92e1633cf48783720c521196bd" +dependencies = [ + "bytemuck", + "log", + "pico-args", + "rgb", + "svgtypes", + "tiny-skia", + "usvg", +] + [[package]] name = "rfd" version = "0.17.2" @@ -4401,6 +5067,15 @@ dependencies = [ "windows-sys 0.61.2", ] +[[package]] +name = "rgb" +version = "0.8.53" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "47b34b781b31e5d73e9fbc8689c70551fd1ade9a19e3e28cfec8580a79290cc4" +dependencies = [ + "bytemuck", +] + [[package]] name = "ring" version = "0.17.14" @@ -4465,6 +5140,15 @@ dependencies = [ "unicode-ident", ] +[[package]] +name = "roxmltree" +version = "0.21.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9da7f59328b09405b181fee1018925fad50f157afb43c0c0f5c522c256dd5907" +dependencies = [ + "memchr", +] + [[package]] name = "rustc-hash" version = "1.1.0" @@ -4496,20 +5180,20 @@ dependencies = [ "errno", "libc", "linux-raw-sys 0.4.15", - "windows-sys 0.59.0", + "windows-sys 0.52.0", ] [[package]] name = "rustix" -version = "1.1.5" +version = "1.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "891efababe418670775f199f0d233d84843c227a0949a883ce15b37c78d6629d" +checksum = "e5e76742e5294153d4dde1207dbec5bdd81eef6fabdc0d2118babadabfd858aa" dependencies = [ "bitflags 2.13.2", "errno", "libc", "linux-raw-sys 0.12.1", - "windows-sys 0.61.2", + "windows-sys 0.52.0", ] [[package]] @@ -4519,7 +5203,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2fc84bf7e9aa16c4f2c758f27412dc9841341e16aa682d9c7ac308fe3ee12056" dependencies = [ "once_cell", - "rustix 1.1.5", + "rustix 1.1.6", ] [[package]] @@ -4576,7 +5260,7 @@ dependencies = [ "security-framework", "security-framework-sys", "webpki-root-certs", - "windows-sys 0.61.2", + "windows-sys 0.52.0", ] [[package]] @@ -4832,6 +5516,15 @@ version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e3a9fe34e3e7a50316060351f37187a3f546bce95496156754b601a5fa71b76e" +[[package]] +name = "simplecss" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a9c6883ca9c3c7c90e888de77b7a5c849c779d25d74a1269b0218b14e8b136c" +dependencies = [ + "log", +] + [[package]] name = "siphasher" version = "1.0.4" @@ -4860,6 +5553,16 @@ dependencies = [ "read-fonts 0.41.0", ] +[[package]] +name = "skrifa" +version = "0.47.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "526e654b303ff4ad73a5a40b25de2b3ce3d039c5e3b6da5f89ae6e57004cb40f" +dependencies = [ + "bytemuck", + "read-fonts 0.44.0", +] + [[package]] name = "skrifa" version = "0.48.0" @@ -4935,7 +5638,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c3d1e2c7f27f8d4cb10542a02c49005dbd6e93095799d6f3be745fae9f8fedd4" dependencies = [ "libc", - "windows-sys 0.61.2", + "windows-sys 0.60.2", ] [[package]] @@ -4959,6 +5662,15 @@ version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" +[[package]] +name = "strict-num" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6637bab7722d379c8b41ba849228d680cc12d0a45ba1fa2b48f2a30577a06731" +dependencies = [ + "float-cmp", +] + [[package]] name = "strsim" version = "0.11.1" @@ -4971,6 +5683,16 @@ version = "2.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292" +[[package]] +name = "svgtypes" +version = "0.16.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9f12b12995e3638c70618c1facb1ce65302f6a6f706b675f07c58a5d7391120e" +dependencies = [ + "kurbo", + "siphasher", +] + [[package]] name = "syn" version = "2.0.119" @@ -5066,10 +5788,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "32497e9a4c7b38532efcdebeef879707aa9f794296a4f0244f6f69e9bc8574bd" dependencies = [ "fastrand", - "getrandom 0.4.3", + "getrandom 0.3.4", "once_cell", - "rustix 1.1.5", - "windows-sys 0.61.2", + "rustix 1.1.6", + "windows-sys 0.52.0", ] [[package]] @@ -5114,7 +5836,7 @@ dependencies = [ "image", "rayon", "rmcp", - "rustix 1.1.5", + "rustix 1.1.6", "schemars", "serde", "serde_json", @@ -5179,7 +5901,7 @@ dependencies = [ "image", "processkit", "rayon", - "rustix 1.1.5", + "rustix 1.1.6", "serde", "serde_json", "sysinfo", @@ -5210,8 +5932,7 @@ dependencies = [ "craft-psd", "craft-tcraft", "craft-usd", - "craft-zip 0.1.0 (git+https://github.com/storytold/craft-libs?rev=5631e99fe126cffb74c673eb458db04299f2bb9b)", - "craft-zip 0.1.0 (git+https://github.com/storytold/craft-libs?rev=c376774f15ae7cd3b06a7ac664f01a8645af4b83)", + "craft-zip", "exr", "flate2", "gltf", @@ -5247,7 +5968,7 @@ name = "texturecraft-paint" version = "0.6.1" dependencies = [ "epaint_default_fonts", - "harfrust", + "harfrust 0.12.0", "rayon", "serde", "skrifa 0.44.0", @@ -5287,6 +6008,7 @@ version = "0.6.1" dependencies = [ "base64 0.22.1", "chrono", + "craft-behavior", "craft-dialogs", "craft-i18n", "craft-image-codecs", @@ -5296,7 +6018,7 @@ dependencies = [ "craft-update", "craft-usd", "craft-window", - "craft-zip 0.1.0 (git+https://github.com/storytold/craft-libs?rev=c376774f15ae7cd3b06a7ac664f01a8645af4b83)", + "craft-zip", "eframe", "egui", "egui-phosphor", @@ -5321,7 +6043,7 @@ dependencies = [ "winsafe", "x11rb", "xcap", - "zbus 5.19.0", + "zbus", "zip", ] @@ -5423,6 +6145,32 @@ dependencies = [ "time-core", ] +[[package]] +name = "tiny-skia" +version = "0.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "47ffee5eaaf5527f630fb0e356b90ebdec84d5d18d937c5e440350f88c5a91ea" +dependencies = [ + "arrayref", + "arrayvec", + "bytemuck", + "cfg-if", + "log", + "png", + "tiny-skia-path", +] + +[[package]] +name = "tiny-skia-path" +version = "0.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "edca365c3faccca67d06593c5980fa6c57687de727a03131735bb85f01fdeeb9" +dependencies = [ + "arrayref", + "bytemuck", + "strict-num", +] + [[package]] name = "tinystr" version = "0.8.5" @@ -5518,8 +6266,11 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e3641d5bbb5349a79e1020a242d251efbc546ad8048d133958323ce9c40a9c9c" dependencies = [ "indexmap", + "serde_core", + "serde_spanned", "toml_datetime", "toml_parser", + "toml_writer", "winnow", ] @@ -5615,7 +6366,7 @@ checksum = "f2f6fb2847f6742cd76af783a2a2c49e9375d0a111c7bef6f71cd9e738c72d6e" dependencies = [ "memoffset", "tempfile", - "windows-sys 0.61.2", + "windows-sys 0.60.2", ] [[package]] @@ -5707,6 +6458,25 @@ version = "2.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "daf8dba3b7eb870caf1ddeed7bc9d2a049f3cfdfae7cb521b087cc33ae4c49da" +[[package]] +name = "usvg" +version = "0.48.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "977d0a4abdef933f424a99fe09f95576e089b90aebc6f016a3bc813762493e91" +dependencies = [ + "data-url", + "imagesize", + "kurbo", + "log", + "pico-args", + "roxmltree", + "simplecss", + "siphasher", + "strict-num", + "svgtypes", + "tiny-skia-path", +] + [[package]] name = "utf16_iter" version = "1.1.0" @@ -5749,6 +6519,27 @@ dependencies = [ "wasm-bindgen", ] +[[package]] +name = "vectorcraft-geom" +version = "0.18.0" +source = "git+https://github.com/storytold/vectorcraft.git?rev=6b3a6b8788ebcb420d69449199cbdf323888d27e#6b3a6b8788ebcb420d69449199cbdf323888d27e" +dependencies = [ + "kurbo", + "serde", + "thiserror 2.0.21", +] + +[[package]] +name = "vectorcraft-pathops" +version = "0.18.0" +source = "git+https://github.com/storytold/vectorcraft.git?rev=6b3a6b8788ebcb420d69449199cbdf323888d27e#6b3a6b8788ebcb420d69449199cbdf323888d27e" +dependencies = [ + "kurbo", + "linesweeper", + "thiserror 2.0.21", + "vectorcraft-geom", +] + [[package]] name = "vello_common" version = "0.2.0" @@ -5887,7 +6678,7 @@ checksum = "38a91b4eaddff87b1cd1074985e3713da4af2c49742d1b356b2c01670a67a078" dependencies = [ "cc", "downcast-rs", - "rustix 1.1.5", + "rustix 1.1.6", "scoped-tls", "smallvec", "wayland-sys", @@ -5900,7 +6691,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e3c36a0f861ad76d0901f2800b46321410d9f73f2ea88aac0650d86c32688073" dependencies = [ "bitflags 2.13.2", - "rustix 1.1.5", + "rustix 1.1.6", "wayland-backend", "wayland-scanner", ] @@ -5922,7 +6713,7 @@ version = "0.31.14" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4a52d18780be9b1314328a3de5f930b73d2200112e3849ca6cb11822793fb34d" dependencies = [ - "rustix 1.1.5", + "rustix 1.1.6", "wayland-client", "xcursor", ] @@ -5984,7 +6775,7 @@ checksum = "0dde9c29be0f723a573977de51ee455bf3dfa03652730a74f9dd3b337e374d75" dependencies = [ "bitflags 2.13.2", "downcast-rs", - "rustix 1.1.5", + "rustix 1.1.6", "wayland-backend", "wayland-scanner", ] @@ -6265,7 +7056,7 @@ version = "0.1.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c2a7b1c03c876122aa43f3020e6c3c3ee5c05081c9a00739faf7503aeba10d22" dependencies = [ - "windows-sys 0.61.2", + "windows-sys 0.52.0", ] [[package]] @@ -6652,7 +7443,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3f3fd376f71958b862e7afb20cfe5a22830e1963462f3a17f49d82a6c1d1f42d" dependencies = [ "bitflags 2.13.2", - "windows-sys 0.59.0", + "windows-sys 0.52.0", ] [[package]] @@ -6670,7 +7461,7 @@ dependencies = [ "libc", "log", "os_pipe", - "rustix 1.1.5", + "rustix 1.1.6", "thiserror 2.0.21", "tree_magic_mini", "wayland-backend", @@ -6727,7 +7518,7 @@ dependencies = [ "libc", "libloading", "once_cell", - "rustix 1.1.5", + "rustix 1.1.6", "x11rb-protocol", ] @@ -6739,11 +7530,10 @@ checksum = "ea6fc2961e4ef194dcbfe56bb845534d0dc8098940c7e5c012a258bfec6701bd" [[package]] name = "xcap" -version = "0.9.10" +version = "0.9.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e833d39f662982a09608f2550fd4036725f98d78738e40fa7206a26258b06384" +checksum = "da270fd7c8581d43d731cb690bcc791fc0a7b3bc96e131a4b6552d0379640a9e" dependencies = [ - "ashpd", "dispatch2", "image", "libwayshot-xcap", @@ -6758,7 +7548,6 @@ dependencies = [ "objc2-foundation 0.3.2", "percent-encoding", "pipewire", - "pollster 1.0.1", "rand", "scopeguard", "serde", @@ -6767,6 +7556,7 @@ dependencies = [ "widestring", "windows", "xcb", + "zbus", ] [[package]] @@ -6863,7 +7653,7 @@ dependencies = [ "hex", "libc", "ordered-stream", - "rustix 1.1.5", + "rustix 1.1.6", "serde", "serde_repr", "tracing", @@ -6871,38 +7661,11 @@ dependencies = [ "uuid", "windows-sys 0.61.2", "winnow", - "zbus_macros 5.19.0", + "zbus_macros", "zbus_names", "zvariant", ] -[[package]] -name = "zbus" -version = "6.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6b4aae740b23927ceabed962431abab2cdefb9f7f885e5bbab062da09bf580e4" -dependencies = [ - "async-trait", - "bitflags 2.13.2", - "endi", - "futures-core", - "hex", - "libc", - "ordered-stream", - "rustix 1.1.5", - "serde", - "serde_repr", - "socket2", - "uds_windows", - "uuid", - "windows-sys 0.61.2", - "winnow", - "zbus_macros 6.3.0", - "zbus_utils", - "zcheapstr", - "zruntime", -] - [[package]] name = "zbus-lockstep" version = "0.5.2" @@ -6942,18 +7705,6 @@ dependencies = [ "zvariant_utils", ] -[[package]] -name = "zbus_macros" -version = "6.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "37c9dd4beaf145c16fcb2902862f50da86e54aed13dd368ddf64a1d17e6b8529" -dependencies = [ - "proc-macro2", - "quote", - "syn 3.0.9", - "zbus_utils", -] - [[package]] name = "zbus_names" version = "4.3.4" @@ -6965,19 +7716,6 @@ dependencies = [ "zvariant", ] -[[package]] -name = "zbus_utils" -version = "6.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "af55e52da295311b368c45bcae221f020e28e97a2420360170ce389218e76ec7" -dependencies = [ - "proc-macro2", - "quote", - "serde", - "syn 3.0.9", - "winnow", -] - [[package]] name = "zbus_xml" version = "5.2.1" @@ -7141,19 +7879,6 @@ dependencies = [ "simd-adler32", ] -[[package]] -name = "zruntime" -version = "0.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ce6a55d4f521760475a30f7b96779508fe8c40dc834478709454dd1d5f0ebc72" -dependencies = [ - "futures-core", - "futures-io", - "rustix 1.1.5", - "socket2", - "windows-sys 0.61.2", -] - [[package]] name = "zune-core" version = "0.5.3" From a13e9a74ee09bb885da07ee913f07996d379d9c8 Mon Sep 17 00:00:00 2001 From: aiongg Date: Tue, 24 Nov 2026 15:32:09 +0000 Subject: [PATCH 20/83] Host TextureCraft's egui UI on craft-libs next's runtime The runtime is installed from TextureCraft's own eframe App (framework.rs): the close question decides in the runtime's close path, the window's Escape runs TextureCraft's Escape handlers and the shortcut recorder, the viewport is the window's document canvas (Tab stays Hide UI), and Ctrl+Q and F6 stay TextureCraft's. The dock is next's DockArea over the saved workspace, with the viewport as its canvas group; the update dialogs run on a DialogHost; the strip is next's TitleBar where the app draws the frame. The removed helpers (icon-button painter, pane split, widget palette, shortcut dispatcher) are app-local. Every app harness installs the runtime. --- Cargo.lock | 3 +- Cargo.toml | 6 +- apps/texturecraft-web/src/web.rs | 1 + apps/texturecraft/src/main.rs | 35 +- crates/ui-egui/Cargo.toml | 5 +- crates/ui-egui/src/display_settings.rs | 2 +- crates/ui-egui/src/docking.rs | 421 ++++++++---------- crates/ui-egui/src/docking/header_band.rs | 54 --- crates/ui-egui/src/docking/shown_group_tab.rs | 102 ----- crates/ui-egui/src/file_dialogs.rs | 3 +- crates/ui-egui/src/fonts.rs | 2 +- crates/ui-egui/src/frame_gizmo.rs | 2 +- crates/ui-egui/src/framework.rs | 154 +++++++ crates/ui-egui/src/keymap.rs | 22 +- crates/ui-egui/src/lib.rs | 25 +- crates/ui-egui/src/menus.rs | 8 + crates/ui-egui/src/pane_split.rs | 261 +++++++++++ .../ui-egui/src/property_sheet/color_bar.rs | 2 +- crates/ui-egui/src/property_sheet/mod.rs | 2 +- .../src/property_sheet/section_tabs.rs | 7 +- crates/ui-egui/src/rail_popup.rs | 22 +- crates/ui-egui/src/render_mode/tests.rs | 6 +- crates/ui-egui/src/screen_color_pick.rs | 4 +- crates/ui-egui/src/shelf_panes.rs | 8 +- crates/ui-egui/src/shortcut_dispatch.rs | 255 +++++++++++ crates/ui-egui/src/theme.rs | 28 +- crates/ui-egui/src/titlebar.rs | 219 +++------ crates/ui-egui/src/ui_state_store.rs | 6 +- crates/ui-egui/src/updates_ui.rs | 59 ++- crates/ui-egui/src/viewport.rs | 14 +- crates/ui-egui/src/web_files.rs | 8 +- crates/ui-egui/src/widgets.rs | 95 +++- crates/ui-egui/src/windows.rs | 24 +- crates/ui-egui/tests/bake_preview.rs | 2 +- crates/ui-egui/tests/brush_cursor_2d.rs | 2 +- crates/ui-egui/tests/display_panel.rs | 2 +- crates/ui-egui/tests/it/alpha_parameters.rs | 2 +- crates/ui-egui/tests/it/anchor_point.rs | 2 +- crates/ui-egui/tests/it/bake_job_mesh.rs | 2 +- crates/ui-egui/tests/it/bake_mode.rs | 6 +- crates/ui-egui/tests/it/bake_presets.rs | 4 +- crates/ui-egui/tests/it/brush_drag.rs | 4 +- .../ui-egui/tests/it/brush_section_reset.rs | 2 +- crates/ui-egui/tests/it/camera_views.rs | 4 +- crates/ui-egui/tests/it/clone_source_view.rs | 2 +- crates/ui-egui/tests/it/close_unsaved.rs | 2 +- .../tests/it/color_selection_editor.rs | 14 +- crates/ui-egui/tests/it/compare_mask_rows.rs | 2 +- .../ui-egui/tests/it/curvature_generator.rs | 2 +- .../ui-egui/tests/it/display_environment.rs | 2 +- .../ui-egui/tests/it/display_post_effects.rs | 2 +- crates/ui-egui/tests/it/effect_rows.rs | 8 +- crates/ui-egui/tests/it/effect_sliders.rs | 2 +- crates/ui-egui/tests/it/empty_menus.rs | 2 +- crates/ui-egui/tests/it/empty_start.rs | 2 +- crates/ui-egui/tests/it/export_file_types.rs | 4 +- .../ui-egui/tests/it/export_map_overrides.rs | 2 +- crates/ui-egui/tests/it/export_materialx.rs | 2 +- crates/ui-egui/tests/it/export_overrides.rs | 4 +- crates/ui-egui/tests/it/export_progress.rs | 2 +- crates/ui-egui/tests/it/export_settings.rs | 2 +- .../tests/it/export_template_guards.rs | 2 +- crates/ui-egui/tests/it/export_usd_asset.rs | 2 +- crates/ui-egui/tests/it/file_dialogs.rs | 2 +- crates/ui-egui/tests/it/fill_channel_image.rs | 8 +- crates/ui-egui/tests/it/fill_support.rs | 2 +- crates/ui-egui/tests/it/filter_picker.rs | 2 +- crates/ui-egui/tests/it/filter_support.rs | 2 +- crates/ui-egui/tests/it/folder_properties.rs | 2 +- crates/ui-egui/tests/it/frame_selection.rs | 2 +- crates/ui-egui/tests/it/generator_panel.rs | 2 +- crates/ui-egui/tests/it/help_menu_664.rs | 2 +- crates/ui-egui/tests/it/history_panel.rs | 4 +- crates/ui-egui/tests/it/import_resources.rs | 4 +- crates/ui-egui/tests/it/inactive_set_hint.rs | 2 +- .../ui-egui/tests/it/instance_properties.rs | 2 +- .../tests/it/layer_blending_options.rs | 2 +- crates/ui-egui/tests/it/layer_clipboard.rs | 4 +- crates/ui-egui/tests/it/layer_multi_select.rs | 2 +- crates/ui-egui/tests/it/layer_rename.rs | 2 +- crates/ui-egui/tests/it/layer_toolbar.rs | 10 +- crates/ui-egui/tests/it/layers_panel.rs | 14 +- crates/ui-egui/tests/it/levels_editor.rs | 2 +- crates/ui-egui/tests/it/log_panel_680.rs | 2 +- crates/ui-egui/tests/it/main.rs | 2 +- crates/ui-egui/tests/it/mask_export.rs | 2 +- crates/ui-egui/tests/it/mask_fill_rows.rs | 6 +- .../ui-egui/tests/it/mask_paint_grayscale.rs | 2 +- crates/ui-egui/tests/it/mask_value_swap.rs | 2 +- crates/ui-egui/tests/it/named_layouts.rs | 2 +- crates/ui-egui/tests/it/nav_buttons.rs | 2 +- .../tests/it/new_project_baked_maps.rs | 4 +- crates/ui-egui/tests/it/new_project_window.rs | 2 +- crates/ui-egui/tests/it/output_templates.rs | 2 +- crates/ui-egui/tests/it/panel_header.rs | 182 +------- crates/ui-egui/tests/it/path_in_view.rs | 6 +- crates/ui-egui/tests/it/path_list.rs | 2 +- crates/ui-egui/tests/it/pen_pressure.rs | 2 +- crates/ui-egui/tests/it/polygon_fill.rs | 4 +- crates/ui-egui/tests/it/popup_press_close.rs | 2 +- crates/ui-egui/tests/it/project_config.rs | 4 +- crates/ui-egui/tests/it/properties_lists.rs | 2 +- .../ui-egui/tests/it/properties_min_width.rs | 8 +- crates/ui-egui/tests/it/properties_popup.rs | 2 +- crates/ui-egui/tests/it/properties_scroll.rs | 2 +- crates/ui-egui/tests/it/rail.rs | 4 +- crates/ui-egui/tests/it/reference_order.rs | 2 +- crates/ui-egui/tests/it/rename_anchor.rs | 2 +- crates/ui-egui/tests/it/reset_ui.rs | 2 +- crates/ui-egui/tests/it/settings_window.rs | 2 +- crates/ui-egui/tests/it/shelf_click.rs | 2 +- crates/ui-egui/tests/it/shelf_drop.rs | 4 +- .../ui-egui/tests/it/shelf_hover_preview.rs | 2 +- crates/ui-egui/tests/it/shelf_panel.rs | 2 +- crates/ui-egui/tests/it/shift_lines_2d.rs | 4 +- crates/ui-egui/tests/it/shift_lines_3d.rs | 2 +- crates/ui-egui/tests/it/shortcut_keys.rs | 2 +- crates/ui-egui/tests/it/shortcut_list.rs | 2 +- crates/ui-egui/tests/it/side_panels.rs | 6 +- crates/ui-egui/tests/it/skew_paint.rs | 2 +- crates/ui-egui/tests/it/smudge_channels.rs | 2 +- crates/ui-egui/tests/it/snapped_lines.rs | 2 +- crates/ui-egui/tests/it/source_picker.rs | 4 +- crates/ui-egui/tests/it/split_divider.rs | 2 +- crates/ui-egui/tests/it/stencil.rs | 2 +- crates/ui-egui/tests/it/symmetry.rs | 2 +- crates/ui-egui/tests/it/symmetry_2d.rs | 2 +- crates/ui-egui/tests/it/template_invert.rs | 2 +- crates/ui-egui/tests/it/templates_681.rs | 2 +- .../ui-egui/tests/it/tile_generator_panel.rs | 4 +- crates/ui-egui/tests/it/tool_availability.rs | 6 +- .../ui-egui/tests/it/tool_settings_saved.rs | 2 +- crates/ui-egui/tests/it/toolbar.rs | 2 +- crates/ui-egui/tests/it/user_smart_mask.rs | 2 +- crates/ui-egui/tests/it/view2d_navigation.rs | 2 +- crates/ui-egui/tests/it/view2d_tiles.rs | 4 +- crates/ui-egui/tests/it/view_mode_picker.rs | 2 +- crates/ui-egui/tests/it/window_menu_684.rs | 2 +- crates/ui-egui/tests/list_panels.rs | 4 +- crates/ui-egui/tests/project_limits.rs | 2 +- crates/ui-egui/tests/shader_panel.rs | 2 +- crates/ui-egui/tests/ui_snapshots.rs | 116 ++--- crates/ui-egui/tests/ui_state_persistence.rs | 2 +- 143 files changed, 1408 insertions(+), 1077 deletions(-) delete mode 100644 crates/ui-egui/src/docking/header_band.rs delete mode 100644 crates/ui-egui/src/docking/shown_group_tab.rs create mode 100644 crates/ui-egui/src/framework.rs create mode 100644 crates/ui-egui/src/pane_split.rs create mode 100644 crates/ui-egui/src/shortcut_dispatch.rs diff --git a/Cargo.lock b/Cargo.lock index 771fadef..2e2d8d3e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -6010,10 +6010,11 @@ dependencies = [ "chrono", "craft-behavior", "craft-dialogs", + "craft-host", "craft-i18n", "craft-image-codecs", "craft-keymap", - "craft-quit", + "craft-theme", "craft-ui", "craft-update", "craft-usd", diff --git a/Cargo.toml b/Cargo.toml index aec6167b..b08c83ac 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -80,10 +80,12 @@ craft-update = { git = "https://github.com/aiongg/craft-libs", rev = "cd87dc61f7 craft-dialogs = { git = "https://github.com/aiongg/craft-libs", rev = "cd87dc61f77d8470b2e9e6a1236f9a84ee0a64de" } # Shortcut chords, lookup and dispatch (crates/ui-egui/src/keymap.rs). craft-keymap = { git = "https://github.com/aiongg/craft-libs", rev = "cd87dc61f77d8470b2e9e6a1236f9a84ee0a64de", features = ["egui"] } -# Quitting the macOS way instead of closing the window (crates/ui-egui/src/windows.rs). -craft-quit = { git = "https://github.com/aiongg/craft-libs", rev = "cd87dc61f77d8470b2e9e6a1236f9a84ee0a64de", features = ["ui"] } # The macOS app menu whose Quit asks about unsaved changes (apps/texturecraft/src/main.rs). craft-menu = { git = "https://github.com/aiongg/craft-libs", rev = "cd87dc61f77d8470b2e9e6a1236f9a84ee0a64de" } +# The UI runtime's host: who the app is to the framework's dialogs (crates/ui-egui/src/framework.rs). +craft-host = { git = "https://github.com/aiongg/craft-libs", rev = "cd87dc61f77d8470b2e9e6a1236f9a84ee0a64de" } +# The theme mode the app hands the runtime (crates/ui-egui/src/framework.rs). +craft-theme = { git = "https://github.com/aiongg/craft-libs", rev = "cd87dc61f77d8470b2e9e6a1236f9a84ee0a64de" } # egui 0.37 and winit: the suite's forks (storytold/egui, storytold/winit), as craft-libs pins them. [patch.crates-io] diff --git a/apps/texturecraft-web/src/web.rs b/apps/texturecraft-web/src/web.rs index cb697e0b..99dfa223 100644 --- a/apps/texturecraft-web/src/web.rs +++ b/apps/texturecraft-web/src/web.rs @@ -58,6 +58,7 @@ async fn run(canvas: web_sys::HtmlCanvasElement) -> Result<(), String> { canvas, options, Box::new(|cc| { + texturecraft_ui_egui::framework::install_headless(&cc.egui_ctx); let mut app = TextureCraftApp::new(cc, session); if let Some(rs) = &cc.wgpu_render_state { let backend = rs.adapter.get_info().backend; diff --git a/apps/texturecraft/src/main.rs b/apps/texturecraft/src/main.rs index 7787e1cf..fbd5aeb3 100644 --- a/apps/texturecraft/src/main.rs +++ b/apps/texturecraft/src/main.rs @@ -146,13 +146,11 @@ fn saved_prefs(ui_file: Option<&std::path::Path>, persistence_path: Option<&std: entries.and_then(|entries| ron::from_str::(entries.get("ui")?).ok()).map(|ui| ui.prefs).unwrap_or_default() } -/// The app with the window chrome that needs the native window: the Windows borderless guard, and -/// on macOS the traffic lights and AppKit's `movable` flag. +/// The app with the window chrome that needs the native window: the Windows borderless guard, and the native window +/// the framework runtime answers the hit test of. struct Shell { app: TextureCraftApp, window_frame: Option, - #[cfg(target_os = "macos")] - movable: Option, } impl eframe::App for Shell { @@ -179,9 +177,8 @@ impl eframe::App for Shell { } fn ui(&mut self, ui: &mut egui::Ui, frame: &mut eframe::Frame) { + texturecraft_ui_egui::framework::before_ui(ui.ctx(), &*frame); self.app.ui(ui, frame); - #[cfg(target_os = "macos")] - texturecraft_ui_egui::titlebar::sync_native(&self.app.title_bar, ui, frame, &mut self.movable); } } @@ -235,12 +232,13 @@ fn main() { prefs.apply_work_threads(); prefs.apply_resource_limits(); let session = initial_session(&args); - let title_bar = TitleBar::decide(prefs.system_title_bar); + let frame_decision = TitleBar::decide(prefs.system_title_bar); + let title_bar = TitleBar::of(&frame_decision.frame); let mut viewport = egui::ViewportBuilder::default().with_title(APP_NAME).with_inner_size(DEFAULT_SIZE).with_min_inner_size(MIN_SIZE); if let Some(i) = icon() { viewport = viewport.with_icon(i); } - let viewport = title_bar.viewport(viewport); + let viewport = texturecraft_ui_egui::titlebar::viewport(&frame_decision, viewport); let mut options = eframe::NativeOptions { viewport, renderer: eframe::Renderer::Wgpu, persistence_path, ..Default::default() }; if let Err(e) = gpu::configure(&mut options, args.gpu, args.power_pref) { fatal(&e.to_string(), true); @@ -261,19 +259,15 @@ fn main() { if let Err(e) = craft_menu::mac::install_app_menu(&cc.egui_ctx, APP_NAME) { log::warn!("the app menu could not be installed: {e}"); } - let window_frame = window_frame::service(cc, matches!(title_bar, TitleBar::App(_))); + texturecraft_ui_egui::framework::install(&cc.egui_ctx, frame_decision)?; + let frame_guard = window_frame::service(cc, matches!(title_bar, TitleBar::App(_))); let mut app = TextureCraftApp::new(cc, session); app.title_bar = title_bar; app.set_startup_update_check(checks_for_updates_at_start(control)); if let Some(port) = control { app.control = Some(control_server::start(port, cc.egui_ctx.clone())); } - Ok(Box::new(Shell { - app, - window_frame, - #[cfg(target_os = "macos")] - movable: None, - })) + Ok(Box::new(Shell { app, window_frame: frame_guard })) }), ); if let Err(e) = result { @@ -406,13 +400,10 @@ mod tests { #[test] fn the_window_holds_the_pointer_while_the_preview_square_is_held() { let session = Session::new_project("Hold", texturecraft_engine::geom::primitives::sphere(1.0, 48, 24), "builtin:sphere", None, 128).unwrap(); - let builder = egui_kittest::Harness::builder().with_size(egui::vec2(DEFAULT_SIZE[0], DEFAULT_SIZE[1])); - let mut harness = builder.build_eframe(|cc| Shell { - app: TextureCraftApp::new(cc, session), - window_frame: None, - #[cfg(target_os = "macos")] - movable: None, - }); + let builder = egui_kittest::Harness::builder() + .with_size(egui::vec2(DEFAULT_SIZE[0], DEFAULT_SIZE[1])) + .with_context_setup(texturecraft_ui_egui::framework::install_headless); + let mut harness = builder.build_eframe(|cc| Shell { app: TextureCraftApp::new(cc, session), window_frame: None }); harness.run_steps(4); let layer = harness.state_mut().app.run("layer.add.fill", serde_json::json!({})).unwrap()["layer"].clone(); harness.state_mut().app.run("layer.fill.projection", serde_json::json!({"layer": layer, "projection": "triplanar"})).unwrap(); diff --git a/crates/ui-egui/Cargo.toml b/crates/ui-egui/Cargo.toml index 5b6ce710..e51c04a1 100644 --- a/crates/ui-egui/Cargo.toml +++ b/crates/ui-egui/Cargo.toml @@ -19,7 +19,8 @@ craft-behavior = { workspace = true } craft-i18n = { workspace = true } craft-window = { workspace = true } craft-keymap = { workspace = true } -craft-quit = { workspace = true } +craft-host = { workspace = true } +craft-theme = { workspace = true } egui-phosphor = { version = "0.14", features = ["regular", "fill"] } serde = { workspace = true } serde_json = { workspace = true } @@ -32,8 +33,6 @@ craft-image-codecs = { workspace = true } # The OS UI language for the first run (MIT OR Apache-2.0; the browser asks `navigator.language`). [target.'cfg(not(target_arch = "wasm32"))'.dependencies] sys-locale = "0.3" -# Floating panels open as OS windows. -craft-ui = { workspace = true } # Help > Check for Updates and the check at start (updates_ui.rs). craft-update = { workspace = true } # Native file dialogs (file_dialogs.rs); the browser build has none. diff --git a/crates/ui-egui/src/display_settings.rs b/crates/ui-egui/src/display_settings.rs index 7c0bc14d..a689add1 100644 --- a/crates/ui-egui/src/display_settings.rs +++ b/crates/ui-egui/src/display_settings.rs @@ -287,7 +287,7 @@ mod tests { fn display_harness() -> Harness<'static, TextureCraftApp> { let session = texturecraft_engine::sample_session(128, 32).unwrap(); - let mut harness = Harness::builder().with_size(egui::vec2(1600.0, 1200.0)).with_step_dt(0.01).build_eframe(|cc| TextureCraftApp::new(cc, session)); + let mut harness = Harness::builder().with_size(egui::vec2(1600.0, 1200.0)).with_step_dt(0.01).with_context_setup(crate::framework::install_headless).build_eframe(|cc| TextureCraftApp::new(cc, session)); harness.state_mut().ui.prefs.language = "en".into(); harness.state_mut().ui.dock.focus(crate::docking::Panel::Display); harness.run_steps(4); diff --git a/crates/ui-egui/src/docking.rs b/crates/ui-egui/src/docking.rs index 0da70e61..d665e593 100644 --- a/crates/ui-egui/src/docking.rs +++ b/crates/ui-egui/src/docking.rs @@ -1,20 +1,22 @@ //! The dock host: every side panel (assets, texture set list, layers, texture set settings, //! properties, display/shader settings, history, log) is a tab that can be docked, tabbed, -//! resized, floated and closed around the viewport. craft-ui's shared docking -//! (`craft_ui::docking`) draws the frames, tab strips, floating windows and drop previews and -//! owns the gestures; this module names the panels, builds the default arrangement, applies -//! the dock's changes and hosts the panel bodies. The bodies live in `dock.rs`, `shelf.rs` and -//! `windows.rs`. +//! resized, floated and closed around the viewport. craft-ui's `DockArea` draws the frames, tab +//! strips, floating windows and drop previews and owns the gestures; this module names the +//! panels, builds the default arrangement, applies the dock's changes and hosts the panel bodies. +//! The bodies live in `dock.rs`, `shelf.rs` and `windows.rs`. //! //! The viewport is the central canvas: it stays docked, never takes tabs and is the only panel -//! that cannot close or float. The layout persists with `UiState` as a craft-ui `Workspace`; -//! a layout that does not load or validate becomes the default. +//! that cannot close or float. The layout persists with `UiState` as a craft-behavior +//! `Workspace`; a layout that does not load or validate becomes the default. -use craft_behavior::dock::{Action, DockPlacement, Layout, Location, Node, PanelState, Permissions}; -use craft_ui::docking::{DockArea, DockContent, DockStyle, PanelLimits}; +use std::sync::Arc; + +use craft_behavior::dock::{Action, DockPlacement, Layout, Location, Node, PanelState, Permissions, SplitSize}; use craft_behavior::flow::Axis; -use craft_behavior::dock::SplitSize; -use egui::{Id, Margin, RichText, Ui, Vec2, vec2}; +use craft_ui::contract::{Bind, BodyCx, PlainData, SizeLimits, Tracked}; +use craft_ui::docking::{DockConfig, DockPanels, GroupAt, PanelSpec, PanelSpecs}; +use craft_ui::patterns::dock::DockArea; +use egui::{Margin, Rect, Ui, Vec2, vec2}; use serde::{Deserialize, Serialize}; use serde_json::Value; @@ -22,11 +24,6 @@ use crate::TextureCraftApp; use crate::i18n::tr; use crate::theme::Tokens; -mod header_band; -mod shown_group_tab; - -pub(crate) use shown_group_tab::HEADER_TITLE_LEFT; - #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)] pub enum Panel { Viewport, @@ -132,8 +129,8 @@ impl Panel { } } - /// Where the panel floats when it has never been laid out: `[x, y, width, height]`, cascaded. - fn float_rect(self) -> Option<[f32; 4]> { + /// Where the panel floats when it has never been laid out, cascaded. + fn float_rect(self) -> Option { let slot = match self { Panel::Display => 0.0, Panel::Shader => 1.0, @@ -144,24 +141,24 @@ impl Panel { Panel::BakingLog => 6.0, _ => return None, }; - Some([960.0, 90.0 + 50.0 * slot, 300.0, 380.0]) + Some(Rect::from_min_size(egui::pos2(960.0, 90.0 + 50.0 * slot), vec2(300.0, 380.0))) } } -/// The saved panel arrangement: craft-ui's workspace over TextureCraft's panels. +/// The saved panel arrangement: craft-behavior's workspace over TextureCraft's panels. pub type Workspace = craft_behavior::dock::Workspace; /// The viewport never moves, floats, closes or takes tabs; panels dock beside it. pub fn permissions(panel: &Panel) -> Permissions { - if *panel == Panel::Viewport { Permissions { accepts_splits: true, ..Permissions::PROTECTED } } else { Permissions::default() } + if *panel == Panel::Viewport { Permissions::PROTECTED.accepts_splits(true) } else { Permissions::default() } } fn tabs(panels: &[Panel]) -> Node { - Node::Tabs { panels: panels.to_vec(), active: 0 } + Node::tabs(panels.to_vec(), 0) } fn split(axis: Axis, size: SplitSize, first: Node, second: Node) -> Node { - Node::Split { axis, size, first: Box::new(first), second: Box::new(second) } + Node::split(axis, size, first, second) } /// The default: assets (4 tile columns at 1920 px) left of the viewport, then texture sets, layers (tabbed with texture set settings) and properties @@ -188,46 +185,30 @@ pub fn default_workspace() -> Workspace { tabs(&[Assets]), split(Axis::X, SplitSize::Ratio(VIEWPORT_SPLIT_RATIO), 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() { - workspace.hidden.push((panel, floating_location(rect))); - } - } - + let mut hidden: Vec<(Panel, Location)> = Panel::ALL.into_iter().filter_map(|panel| Some((panel, floating_location(panel.float_rect()?)))).collect(); for panel in [MeshMapSettings, CommonSettings, MeshMapBakers] { - workspace.hidden.push(( - panel, - Location { - floating: None, - anchor: Some(TextureSetList), - placement: DockPlacement::Tab { before: None }, - size: None, - stack: None, - sibling: Vec::new(), - group: None, - }, - )); + hidden.push((panel, Location::new(Some(TextureSetList), DockPlacement::tab(None)))); } - workspace + Workspace::from_parts(Layout::new(Some(root), Vec::new()), hidden, Vec::new()) } -/// Where a closed panel reopens as its own floating window at `rect` (`[x, y, width, height]`) -fn floating_location(rect: [f32; 4]) -> Location { - Location { floating: Some(rect), anchor: None, placement: DockPlacement::Tab { before: None }, size: None, stack: None, sibling: Vec::new(), group: None } +/// Where a closed panel reopens as its own floating window at `rect` +fn floating_location(rect: Rect) -> Location { + let mut location = Location::new(None, DockPlacement::tab(None)); + location.floating = Some(rect); + location } /// 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> { workspace.validate().map_err(|error| error.to_string())?; - let layout = &workspace.layout; + let layout = workspace.layout(); if layout.floating.iter().any(|window| window.contains(&Panel::Viewport)) { return Err("The viewport cannot float".into()); } - if workspace.hidden.iter().any(|(panel, _)| *panel == Panel::Viewport) { + if workspace.hidden().iter().any(|(panel, _)| *panel == Panel::Viewport) { return Err("The viewport cannot be hidden".into()); } let mut found = false; @@ -244,7 +225,7 @@ pub fn validate(workspace: &Workspace) -> Result<(), String> { } found = true; } - Node::Stack { entries } if entries.iter().any(|entry| entry.panel == Panel::Viewport) => { + Node::Stack { entries, .. } if entries.iter().any(|entry| entry.panel == Panel::Viewport) => { return Err("The viewport cannot be collapsed".into()); } Node::Dock { columns, .. } if columns.iter().flat_map(|column| &column.groups).any(|group| group.panels.contains(&Panel::Viewport)) => { @@ -271,19 +252,17 @@ const BAKING_LOG_HEIGHT: f32 = 160.0; /// Share of the first bake column the texture set list takes above the mesh map bakers const TEXTURE_SET_LIST_SHARE: f32 = 0.4; -/// The dock layout (part of `UiState`; serialized as a craft-ui `Workspace`). +/// The dock layout (part of `UiState`; serialized as a craft-behavior `Workspace`). #[derive(Clone, Debug)] pub struct Dock { workspace: Workspace, - /// A panel to bring in front of the other floating windows on the next frame. - raise: Option, /// A saved layout could not be read, so this is the painting default in its place replaced_unreadable: bool, } impl Default for Dock { fn default() -> Self { - Dock { workspace: default_workspace(), raise: None, replaced_unreadable: false } + Dock { workspace: default_workspace(), replaced_unreadable: false } } } @@ -319,7 +298,7 @@ impl Dock { return unreadable; } - Dock { workspace, raise: None, replaced_unreadable: false } + Dock { workspace, replaced_unreadable: false } } /// Whether a saved layout could not be read and this dock is the painting default instead @@ -329,15 +308,16 @@ impl Dock { /// Texture sets over the bakers, the two settings tabs, the log under both, then the viewport pub(crate) fn for_baking() -> Self { - let mut workspace = default_workspace(); + let painting = default_workspace(); + let mut hidden = painting.hidden().to_vec(); for panel in [Panel::Assets, Panel::Layers, Panel::TextureSetSettings, Panel::Properties] { - if let Ok(location) = workspace.layout.location(&panel) { - workspace.hidden.push((panel, location)); + if let Ok(location) = painting.layout().location(&panel) { + hidden.push((panel, location)); } } let bake_panels = [Panel::MeshMapSettings, Panel::CommonSettings, Panel::MeshMapBakers, Panel::Log]; - workspace.hidden.retain(|(panel, _)| !bake_panels.contains(panel)); + hidden.retain(|(panel, _)| !bake_panels.contains(panel)); let gutter_width = f32::from(crate::theme::GUTTER); let list_column = split(Axis::Y, SplitSize::Ratio(TEXTURE_SET_LIST_SHARE), tabs(&[Panel::TextureSetList]), tabs(&[Panel::MeshMapBakers])); @@ -346,8 +326,8 @@ impl Dock { let columns_over_log = split(Axis::Y, SplitSize::FixedSecond(BAKING_LOG_HEIGHT), columns, tabs(&[Panel::Log])); let columns_width = BAKERS_COLUMN_WIDTH + gutter_width + SETTINGS_COLUMN_WIDTH; let root = split(Axis::X, SplitSize::FixedFirst(columns_width), columns_over_log, tabs(&[Panel::Viewport])); - workspace.layout = Layout { root: Some(root), floating: Vec::new() }; - Dock { workspace, raise: None, replaced_unreadable: false } + let workspace = Workspace::from_parts(Layout::new(Some(root), Vec::new()), hidden, painting.floated().to_vec()); + Dock { workspace, replaced_unreadable: false } } pub fn workspace(&self) -> &Workspace { @@ -355,12 +335,12 @@ impl Dock { } pub fn is_open(&self, p: Panel) -> bool { - self.workspace.layout.contains(&p) + self.workspace.layout().contains(&p) } /// Open and the front tab of its group. pub fn is_visible(&self, p: Panel) -> bool { - self.workspace.layout.panel_state(&p) == PanelState::Front + self.workspace.layout().panel_state(&p) == PanelState::Front } /// Hide a visible panel, otherwise bring it up. @@ -369,7 +349,7 @@ impl Dock { } pub fn close(&mut self, p: Panel) { - if let Err(error) = self.workspace.set_visible(p, false, None, permissions) { + if let Err(error) = self.workspace.set_visible(p, false, None, false, permissions) { log::warn!("panel {p:?} was not closed: {error}"); } } @@ -378,20 +358,19 @@ impl Dock { /// front. pub fn focus(&mut self, p: Panel) { let mut next = self.workspace.clone(); - match next.set_visible(p, true, None, permissions) { - Ok(()) if validate(&next).is_ok() => { - self.workspace = next; - self.raise = Some(p); - } + match next.set_visible(p, true, None, false, permissions) { + Ok(()) if validate(&next).is_ok() => self.workspace = next, Ok(()) => log::warn!("panel {p:?} was not opened: it would break the viewport's rules"), Err(error) => log::warn!("panel {p:?} was not opened: {error}"), } } - /// 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))); + /// Open the closed `panel` as a floating window at `rect` + pub(crate) fn float_at(&mut self, panel: Panel, rect: Rect) { + let mut hidden = self.workspace.hidden().to_vec(); + hidden.retain(|(hidden_panel, _)| *hidden_panel != panel); + hidden.push((panel, floating_location(rect))); + self.workspace = Workspace::from_parts(self.workspace.layout().clone(), hidden, self.workspace.floated().to_vec()); self.focus(panel); } @@ -399,7 +378,7 @@ impl Dock { /// it was. fn apply(&mut self, action: Action) { let mut next = self.workspace.clone(); - match next.apply(action, permissions) { + match next.apply(action, false, permissions) { Ok(_) if validate(&next).is_ok() => self.workspace = next, Ok(_) => log::warn!("a panel move would break the viewport's rules"), Err(error) => log::warn!("a panel move was not applied: {error}"), @@ -407,58 +386,80 @@ impl Dock { } } +/// What the dock area keeps between passes: the workspace it shows and the panels' specs. +#[derive(Default)] +pub(crate) struct LiveDock { + shown: Option>, + specs: Tracked, +} + +impl LiveDock { + /// The `Arc` the dock shows for `workspace`: the last one while the arrangement is the same, + /// so an idle pass keeps the workspace's revision and the dock reads no spec. + fn shown(&mut self, workspace: &Workspace) -> Arc { + if let Some(shown) = self.shown.as_ref().filter(|shown| ***shown == *workspace) { + return Arc::clone(shown); + } + let shown = Arc::new(workspace.clone()); + self.shown = Some(Arc::clone(&shown)); + shown + } +} + +/// What the dock reads of the panels: their tab names, in [`Panel::ALL`] order. +#[derive(Clone, Debug, Default, PartialEq, PlainData)] +struct DockSpecs { + labels: Vec, +} + +impl PanelSpecs for DockSpecs { + fn spec(&self, panel: &Panel) -> PanelSpec { + let label = Panel::ALL.iter().position(|p| p == panel).and_then(|index| self.labels.get(index)).cloned().unwrap_or_default(); + // Every panel body is TextureCraft's own egui code: the dock runs it with the window's style. + let spec = PanelSpec::new(label).limits(SizeLimits::at_least(min_size(*panel))).float_size(FLOATING_SIZE.max(min_size(*panel))).host_body(); + if *panel == Panel::Viewport { spec.canvas() } else { spec } + } + + fn permissions(&self, panel: &Panel) -> Permissions { + permissions(panel) + } +} + +/// The tab name of `panel` in the interface language. +fn label(app: &TextureCraftApp, panel: Panel) -> String { + match panel { + Panel::Properties => crate::dock::properties_title(app), + p => tr(p.name()).to_string(), + } +} + +/// Reads the tab names, moving the specs' revision only when one changed. +fn refresh_specs(app: &mut TextureCraftApp) { + let labels: Vec = Panel::ALL.iter().map(|panel| label(app, *panel)).collect(); + if app.docks.specs.labels != labels { + app.docks.specs.labels = labels; + } +} + // --------------------------------------------------------------------------------------------- // Drawing -fn area_id() -> Id { - Id::unique("texturecraft-docking") +/// The viewport's id as the window's document canvas. +fn viewport_canvas_id() -> egui::Id { + egui::Id::unique("texturecraft-viewport-canvas") } -/// Smallest panel extent a divider drag leaves, in points -const MIN_PANE_EXTENT: f32 = 60.0; - -/// Border width of a floating panel, in points -const FLOATING_BORDER_WIDTH: f32 = 1.0; - -/// Text size of the panel tabs, in points -const TAB_TEXT_SIZE: f32 = 12.5; - -/// Narrowest panel tab, in points -const MIN_TAB_WIDTH: f32 = 54.0; - -/// Mixing in title ink keeps the light dock's focus outline above 3:1 on both header surfaces -const LIGHT_DOCK_ACCENT_TEXT_MIX: f32 = 0.2; - -/// The dock look: every panel group is a card under one chrome-coloured header bar, names in capitals at the left, a close × at the right -fn style(ui: &Ui, tokens: &Tokens) -> DockStyle { - let mut dock_style = DockStyle::from_ui(ui); - dock_style.gap = f32::from(crate::theme::GUTTER); - dock_style.min_pane = MIN_PANE_EXTENT; - - dock_style.background = tokens.panel; - dock_style.tab_background = tokens.chrome; - - // The selected title is brighter while the strip keeps its colour - dock_style.active_background = tokens.chrome; - dock_style.text = tokens.text_strong; - dock_style.inactive_text = tokens.text_dim; - dock_style.border = egui::Stroke::NONE; - dock_style.accent = if tokens.dark { tokens.accent } else { tokens.accent.lerp_to_gamma(tokens.text_strong, LIGHT_DOCK_ACCENT_TEXT_MIX) }; - dock_style.floating_background = tokens.panel; - dock_style.floating_stroke = egui::Stroke::new(FLOATING_BORDER_WIDTH, tokens.button_border); - - dock_style.font = egui::FontId::proportional(TAB_TEXT_SIZE); - dock_style.min_tab_width = MIN_TAB_WIDTH; - dock_style.tab_height = TAB_HEIGHT; - - // Panels arrange in a split tree around the viewport; floating title bars only move windows - dock_style.new_dock_zones = false; - dock_style.title_bar_docks = false; - dock_style +/// Declares the viewport, drawn in this pass, as the window's document canvas (the dock's canvas +/// group, or the whole window with the UI hidden). +pub(crate) fn host_viewport_canvas(ctx: &egui::Context) { + crate::framework::host_canvas(ctx, viewport_canvas_id()); } -/// Whether a modal layer or update dialog holds the input, so the panels, floating ones included, -/// do not take it. +/// From a panel's left edge to its contents' text (an empty panel's note) +pub(crate) const HEADER_TITLE_LEFT: f32 = 12.0; + +/// Whether one of TextureCraft's own modal layers or the update dialogs hold the input, so the +/// panels floated into windows of their own do not take it (`FrameInput::app_modal`). pub(crate) fn input_blocked(app: &TextureCraftApp, context: &egui::Context) -> bool { let modal = context.memory(|memory| memory.top_modal_layer()).is_some(); #[cfg(not(target_arch = "wasm32"))] @@ -480,57 +481,49 @@ pub fn show(app: &mut TextureCraftApp, ui: &mut Ui) { } let context = ui.ctx().clone(); - let tokens = Tokens::get(&context); - let style = style(ui, &tokens); - let layout = app.ui.dock.workspace.layout.clone(); - let mut area = DockArea::new(area_id()).input_blocked(input_blocked(app, &context)); - 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, tokens, layout: &layout, style: &style }); - crate::rail_popup::hand_drag_to_dock(&context, area_id()); + refresh_specs(app); + let shown = app.docks.shown(&app.ui.dock.workspace); + // The specs leave the app while its panels borrow it, and come back with their revision. + let specs = std::mem::take(&mut app.docks.specs); + // Panels arrange in a split tree around the viewport; floating title bars only move windows. + let config = DockConfig::default().new_dock_zones(false).title_bar_docks(false); + let output = { + let tokens = Tokens::get(&context); + let mut panels = Panels { app: &mut *app, tokens, layout: shown.layout().clone() }; + DockArea::new("Panels", Bind::given(Arc::clone(&shown)), &specs, &mut panels, config).show(ui) + }; + app.docks.specs = specs; // The popup needs the viewport the dock recorded this frame crate::rail_popup::show(app, &context); + // Keys pressed in a panel floated into a window of its own run the app's shortcuts there #[cfg(not(target_arch = "wasm32"))] - crate::menus::forwarded_shortcuts(app, &context, output.forwarded_events, output.forwarded_modifiers.unwrap_or_default()); + for (_, viewport) in &output.windows { + let (events, held) = context.input_for(*viewport, |input| (input.events.clone(), input.modifiers)); + crate::menus::forwarded_shortcuts(app, &context, events, held); + } if let Some(error) = &output.error { - log::warn!("docking: {error}"); + log::warn!("docking: {:?}", error.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::(&context, area_id()); + if app.ui.dock.workspace != *shown { + craft_ui::runtime::drag::cancel(&context, craft_behavior::CancelReason::HostChanged); return; } - for action in output.actions { + for action in output.actions.into_iter().chain(output.requested) { app.ui.dock.apply(action); } } -/// Size of the panel names on a header bar -const HEADER_TITLE_SIZE: f32 = 12.0; - -/// Side of the close × at the right end of a header bar -const HEADER_CLOSE_SIZE: f32 = 22.0; - -/// Room right of the close × button, so its glyph ends where the Properties controls end (side padding plus scroll bar gutter) -const HEADER_CLOSE_RIGHT_MARGIN: f32 = 18.0; - -/// Whether a docked group's header bar ends in a close × (floating windows have one on their title bar; the viewport never closes) -fn header_closes(active: &Panel, floating: bool) -> bool { - !floating && permissions(active).closable -} - -/// The panels' contents, names and limits for the dock area +/// The panels' contents for the dock area struct Panels<'a> { app: &'a mut TextureCraftApp, tokens: Tokens, - layout: &'a Layout, - style: &'a DockStyle, + /// The arrangement the dock shows in this pass + layout: Layout, } /// Room between a panel's edges and its contents @@ -596,100 +589,42 @@ pub(crate) fn panel_body(app: &mut TextureCraftApp, ui: &mut Ui, panel: Panel) { }); } -impl DockContent for Panels<'_> { - fn body(&mut self, ui: &mut Ui, panel: &Panel) { - if *panel == Panel::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(self.app, ui); - return; - } - - // Before the rows, which draw over the foot of the shown tab's box - self.paint_shown_group_tab(ui, *panel); - panel_body(self.app, ui, *panel); - } - - fn logical_label(&self, panel: &Panel) -> String { - match panel { - Panel::Properties => crate::dock::properties_title(self.app), - p => tr(p.name()).to_string(), +impl DockPanels for Panels<'_> { + fn body(&mut self, panel: &Panel, ui: &mut Ui, _: &mut BodyCx<'_>) { + // The viewport is its group's `group_view` + if *panel != Panel::Viewport { + panel_body(self.app, ui, *panel); } } - fn label(&mut self, ui: &Ui, panel: &Panel, logical: &str, _font: &egui::FontId, color: egui::Color32) -> egui::WidgetText { - // Capitals on the bar only: menus and screen readers keep the logical name - let name = logical.to_uppercase(); - let font = crate::theme::semibold(HEADER_TITLE_SIZE); - - // Popup menu rows use their unpadded text metrics - if matches!(ui.layer_id().order, egui::Order::Foreground | egui::Order::Tooltip) { - return RichText::new(name).font(font).color(color).into(); + /// The viewport, edge to edge in its group, as the window's document canvas. + fn group_view(&mut self, panels: &[Panel], _: usize, ui: &mut Ui, at: GroupAt, _: &mut BodyCx<'_>) -> Option { + let GroupAt::Show(rect) = at else { return None }; + if !panels.contains(&Panel::Viewport) { + return None; } - - header_band::header_name(ui, &name, font, color, self.header_lift(*panel)).into() + host_viewport_canvas(ui.ctx()); + 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(self.app, ui); + Some(rect.height()) } - fn group_header_width(&self, panels: &[Panel], active: &Panel, floating: bool, _strip_width: f32) -> f32 { - if header_closes(active, floating) { - HEADER_CLOSE_SIZE + HEADER_CLOSE_RIGHT_MARGIN - } else if redocks(panels, active, floating) { - DOCK_BUTTON_SIZE + DOCK_BUTTON_MARGIN - } else { - 0.0 + /// A rail panel floating on its own carries the Dock button that sends it back to the rail + fn group_header(&mut self, panels: &[Panel], active: usize, ui: &mut Ui, _: &mut BodyCx<'_>) { + let Some(active) = panels.get(active).copied() else { return }; + let floating = self.layout.floating.iter().any(|window| window.contains(&active)); + if redocks(panels, &active, floating) + && crate::widgets::icon_button(ui, egui_phosphor::regular::ARROW_SQUARE_IN, tr("Dock"), false, DOCK_BUTTON_SIZE).clicked() + { + self.app.ui.dock.close(active); } } - - /// A docked group's bar ends in its close ×; a rail panel floating on its own carries the Dock button that sends it back to the rail - fn group_header(&mut self, ui: &mut Ui, panels: &[Panel], active: &Panel, floating: bool) { - if redocks(panels, active, floating) { - ui.with_layout(egui::Layout::right_to_left(egui::Align::Center), |ui| { - if crate::widgets::icon_button(ui, egui_phosphor::regular::ARROW_SQUARE_IN, tr("Dock"), false, DOCK_BUTTON_SIZE).clicked() { - self.app.ui.dock.close(*active); - } - }); - return; - } - - if !header_closes(active, floating) { - return; - } - - // Centre the close control on the header title line - let rect = ui.max_rect(); - let button = egui::Rect::from_center_size( - egui::pos2(rect.right() - HEADER_CLOSE_RIGHT_MARGIN - HEADER_CLOSE_SIZE / 2.0, rect.center().y - self.header_lift(*active)), - vec2(HEADER_CLOSE_SIZE, HEADER_CLOSE_SIZE), - ); - let clicked = ui - .scope_builder(egui::UiBuilder::new().max_rect(button), |ui| { - crate::widgets::icon_button(ui, egui_phosphor::regular::X, tr("Close Panel"), false, HEADER_CLOSE_SIZE).clicked() - }) - .inner; - if clicked { - self.app.ui.dock.close(*active); - } - } - - fn permissions(&self, panel: &Panel) -> Permissions { - permissions(panel) - } - - fn limits(&self, panel: &Panel) -> PanelLimits { - PanelLimits { min: min_size(*panel), ..PanelLimits::default() } - } - - fn floating_size(&self, panel: &Panel) -> Option { - Some(FLOATING_SIZE.max(min_size(*panel))) - } } -/// Size of the Dock button in a floating rail panel's tab strip +/// Size of the Dock button in a floating rail panel's header const DOCK_BUTTON_SIZE: f32 = 22.0; -/// Room right of the Dock button, so it clears the strip's end -const DOCK_BUTTON_MARGIN: f32 = 6.0; - /// Whether a floating window holds one rail panel alone: its Dock button closes it back onto the rail fn redocks(panels: &[Panel], active: &Panel, floating: bool) -> bool { floating && panels.len() == 1 && crate::rail_popup::is_rail_panel(*active) @@ -700,7 +635,7 @@ mod tests { use super::*; fn panels_of(w: &Workspace) -> Vec { - w.layout.panels().into_iter().copied().collect() + w.layout().panels().into_iter().copied().collect() } #[test] @@ -710,7 +645,7 @@ mod tests { assert!(validate(&workspace).is_ok()); for panel in Panel::ALL { - assert!(workspace.layout.contains(&panel) || workspace.hidden.iter().any(|(hidden, _)| *hidden == panel), "{panel:?} is neither shown nor hidden"); + assert!(workspace.layout().contains(&panel) || workspace.hidden().iter().any(|(hidden, _)| *hidden == panel), "{panel:?} is neither shown nor hidden"); } assert_eq!(panels_of(&workspace), [Panel::Assets, Panel::Viewport, Panel::TextureSetList, Panel::Layers, Panel::TextureSetSettings, Panel::Properties]); @@ -718,12 +653,14 @@ mod tests { #[test] fn a_saved_split_keeps_its_own_share() { - let mut workspace = default_workspace(); - let Some(Node::Split { second: right, .. }) = workspace.layout.root.as_mut() else { panic!("assets | rest") }; + let default = default_workspace(); + let mut layout = default.layout().clone(); + let Some(Node::Split { second: right, .. }) = layout.root.as_mut() else { panic!("assets | rest") }; let Node::Split { second: column, .. } = right.as_mut() else { panic!("viewport | right column") }; let Node::Split { second: below_sets, .. } = column.as_mut() else { panic!("texture sets | rest") }; let Node::Split { size, .. } = below_sets.as_mut() else { panic!("layers | properties") }; *size = SplitSize::Ratio(0.57); + let workspace = Workspace::from_parts(layout, default.hidden().to_vec(), default.floated().to_vec()); let back = Dock::from_value(serde_json::to_value(&workspace).unwrap()); assert_eq!(back.workspace(), &workspace, "a layout saved with the old split opens unchanged"); @@ -772,7 +709,7 @@ mod tests { let dock = Dock::from_value(saved); assert!(!dock.replaced_unreadable(), "the saved layout is kept"); - assert!(dock.workspace().hidden.iter().any(|(panel, _)| *panel == Panel::Export), "Export joins it, closed"); + assert!(dock.workspace().hidden().iter().any(|(panel, _)| *panel == Panel::Export), "Export joins it, closed"); } #[test] @@ -781,8 +718,8 @@ mod tests { dock.close(Panel::Viewport); assert!(dock.is_open(Panel::Viewport)); let before = dock.clone(); - dock.apply(Action::Float { panel: Panel::Viewport, rect: [0.0, 0.0, 300.0, 300.0] }); - dock.apply(Action::Move { panel: Panel::Layers, anchor: Panel::Viewport, placement: DockPlacement::Tab { before: None } }); + dock.apply(Action::float(Panel::Viewport, Rect::from_min_size(egui::Pos2::ZERO, vec2(300.0, 300.0)))); + dock.apply(Action::move_beside(Panel::Layers, Panel::Viewport, DockPlacement::tab(None))); assert_eq!(dock, before); } @@ -806,8 +743,8 @@ mod tests { let mut dock = Dock::default(); dock.focus(Panel::Display); assert!(dock.is_visible(Panel::Display)); - assert_eq!(dock.workspace().layout.floating.len(), 1); - assert!(dock.workspace().layout.floating[0].contains(&Panel::Display)); + assert_eq!(dock.workspace().layout().floating.len(), 1); + assert!(dock.workspace().layout().floating[0].contains(&Panel::Display)); // Hiding and showing the views one by one. dock.toggle(Panel::Display); assert!(!dock.is_open(Panel::Display)); diff --git a/crates/ui-egui/src/docking/header_band.rs b/crates/ui-egui/src/docking/header_band.rs deleted file mode 100644 index 8bb5ca60..00000000 --- a/crates/ui-egui/src/docking/header_band.rs +++ /dev/null @@ -1,54 +0,0 @@ -//! Positions dock tab titles within the tab strip and the gutter above it. - -use craft_behavior::dock::{Layout, Node}; -use craft_behavior::flow::Axis; -use egui::text::{LayoutJob, TextFormat}; -use egui::{Align, Color32, FontId, Ui}; - -use super::Panel; - -/// Gap left between a header band and the panel above it, in points. -const HEADER_SEPARATION: f32 = 2.0; - -/// How far a header under another panel reaches above its tab strip: the gutter between them, less the separation -pub(super) const HEADER_RISE: f32 = crate::theme::GUTTER as f32 - HEADER_SEPARATION; - -/// Whether `panel`'s docked group sits under another panel, a gutter above its header; floating groups and the top row have none -pub(super) fn under_a_panel(layout: &Layout, panel: Panel) -> bool { - layout.root.as_ref().and_then(|node| group_is_below_panel(node, panel, false)).unwrap_or(false) -} - -fn group_is_below_panel(node: &Node, panel: Panel, below_panel: bool) -> Option { - match node { - Node::Split { axis, first, second, .. } => { - group_is_below_panel(second, panel, below_panel || *axis == Axis::Y).or_else(|| group_is_below_panel(first, panel, below_panel)) - } - Node::Tabs { panels, .. } if panels.contains(&panel) => Some(below_panel), - Node::Dock { columns, .. } => { - columns.iter().find_map(|column| column.groups.iter().position(|group| group.panels.contains(&panel))).map(|index| below_panel || index > 0) - } - _ => None, - } -} - -/// `name` laid out so that, centred as the dock centres every name, its capitals' middle sits `lift` above the strip's (a galley's height counts descenders) -pub(super) fn header_name(ui: &Ui, name: &str, font: FontId, color: Color32, lift_points: f32) -> LayoutJob { - let format = TextFormat { font_id: font, color, valign: Align::TOP, ..Default::default() }; - let mut job = LayoutJob::single_section(name.to_owned(), format); - let galley = ui.painter().layout_job(job.clone()); - - // Scripts without capitals use the whole galley as their ink bounds - let capital = galley.rows.first().and_then(|row| row.glyphs.iter().find(|glyph| glyph.chr.is_uppercase()).map(|glyph| (row.pos.y, glyph))); - let ink_middle = capital.map_or(galley.size().y / 2.0, |(row_top, glyph)| row_top + glyph.pos.y + glyph.uv_rect.offset.y + glyph.uv_rect.size.y / 2.0); - - // Room below the name raises it when centred, room above lowers it - let shift = ink_middle - galley.size().y / 2.0 + lift_points; - if shift < 0.0 - && let Some(section) = job.sections.first_mut() - { - section.format.valign = Align::BOTTOM; - } - - job.first_row_min_height = galley.size().y + 2.0 * shift.abs(); - job -} diff --git a/crates/ui-egui/src/docking/shown_group_tab.rs b/crates/ui-egui/src/docking/shown_group_tab.rs deleted file mode 100644 index 59f88f29..00000000 --- a/crates/ui-egui/src/docking/shown_group_tab.rs +++ /dev/null @@ -1,102 +0,0 @@ -//! The active tab in a panel group, drawn as a raised box joined to the panel body - -use craft_ui::docking::DockContent; -use craft_behavior::dock::Node; -use egui::text::TextWrapping; -use egui::{Rect, Stroke, StrokeKind, Ui, pos2}; - -use super::header_band::{HEADER_RISE, header_name, under_a_panel}; -use super::{HEADER_TITLE_SIZE, Panel, Panels, area_id}; -use crate::property_sheet::{full_height_tab_rect, shown_tab_box}; -use crate::theme::semibold; - -/// Horizontal padding of craft-ui's dock tab, in points -const DOCK_TAB_PADDING: f32 = 24.0; - -/// From a panel's left edge to its header's name -pub(crate) const HEADER_TITLE_LEFT: f32 = DOCK_TAB_PADDING / 2.0; - -/// Gap between the active tab's box and its neighbours, in points -const TAB_BOX_INSET: f32 = 4.0; - -/// Insets the focus outline inside the tab's actual hit rect -const TAB_FOCUS_INSET: f32 = 2.0; - -/// Width of the focus outline in points -const TAB_FOCUS_STROKE_WIDTH: f32 = 1.0; - -/// The tab group containing `panel`; a collapsed stack has no tabs -fn group_of(node: &Node, panel: Panel) -> Option<&[Panel]> { - match node { - Node::Split { first, second, .. } => group_of(first, panel).or_else(|| group_of(second, panel)), - Node::Tabs { panels, .. } if panels.contains(&panel) => Some(panels), - Node::Dock { columns, .. } => { - columns.iter().flat_map(|column| &column.groups).find(|group| group.panels.contains(&panel)).map(|group| group.panels.as_slice()) - } - _ => None, - } -} - -impl Panels<'_> { - /// How far a header band reaches above its tab strip - fn header_rise(&self, panel: Panel) -> f32 { - if under_a_panel(self.layout, panel) { HEADER_RISE } else { 0.0 } - } - - /// How far a header name sits above the tab strip's centre - pub(super) fn header_lift(&self, panel: Panel) -> f32 { - self.header_rise(panel) / 2.0 - } - - /// Paints the active tab and its focus outline above the renderer's fallback paint - pub(super) fn paint_shown_group_tab(&self, ui: &Ui, panel: Panel) { - let layout = self.layout; - let in_group = layout - .root - .iter() - .chain(layout.floating.iter().map(|window| &window.root)) - .find_map(|root| group_of(root, panel)) - .is_some_and(|group| group.len() > 1); - if !in_group { - return; - } - - // The shared renderer submits the active tab before it calls the panel body - let tab_id = area_id().with(("tab", &panel)); - let Some(tab) = ui.ctx().read_response(tab_id) else { return }; - let body = ui.max_rect(); - let tab_rect = tab.rect; - if tab.layer_id != ui.layer_id() || tab_rect.bottom() != body.top() || tab_rect.left() < body.left() || tab_rect.right() > body.right() { - return; - } - - let band_top = tab_rect.top() - self.header_rise(panel); - let box_left = if tab_rect.left() > body.left() { tab_rect.left() + TAB_BOX_INSET } else { tab_rect.left() }; - let box_right = tab_rect.right() - TAB_BOX_INSET; - if box_left >= box_right { - return; - } - - // Extend the body's clip over the header without widening it - let clip = ui.clip_rect(); - let mut painter = ui.painter().clone(); - painter.set_clip_rect(Rect::from_x_y_ranges(clip.x_range(), band_top..=clip.bottom())); - let band = Rect::from_x_y_ranges(body.x_range(), band_top..=tab_rect.bottom()); - shown_tab_box(&painter, &self.tokens, full_height_tab_rect(band, box_left, box_right)); - - let name = self.logical_label(&panel).to_uppercase(); - let font = semibold(HEADER_TITLE_SIZE); - let mut job = header_name(ui, &name, font, self.style.text, (tab_rect.top() - band_top) / 2.0); - job.wrap = TextWrapping::truncate_at_width((tab_rect.width() - DOCK_TAB_PADDING).max(0.0)); - let galley = painter.layout_job(job); - let at = pos2(tab_rect.left() + HEADER_TITLE_LEFT, tab_rect.center().y - galley.size().y / 2.0); - painter.galley(at, galley, self.style.text); - - // Preserve the shared dock's keyboard focus ring above the opaque selected tab - let pointer_focus = ui.data(|data| data.get_temp::(tab_id.with("pointer-focus"))).unwrap_or(false); - let focus_rect = tab_rect.shrink(TAB_FOCUS_INSET); - if tab.has_focus() && !pointer_focus && focus_rect.is_positive() { - painter.rect_stroke(focus_rect, 0.0, Stroke::new(TAB_FOCUS_STROKE_WIDTH, self.style.accent), StrokeKind::Inside); - } - } -} diff --git a/crates/ui-egui/src/file_dialogs.rs b/crates/ui-egui/src/file_dialogs.rs index 0a81e9bc..b0d2dec4 100644 --- a/crates/ui-egui/src/file_dialogs.rs +++ b/crates/ui-egui/src/file_dialogs.rs @@ -6,7 +6,6 @@ use std::panic::Location; use std::path::PathBuf; -use std::sync::Arc; pub use craft_dialogs::{Answer, FileDialog, Override, Request}; @@ -57,7 +56,7 @@ impl FileDialogs { /// The dialogs of the app whose context is `ctx`: an answer wakes its event loop. pub fn new(ctx: egui::Context) -> FileDialogs { FileDialogs { - dialogs: craft_dialogs::Dialogs::new(Arc::new(move || ctx.request_repaint())), + dialogs: craft_dialogs::Dialogs::new(craft_dialogs::Wake::new(move || ctx.request_repaint())), asked: Vec::new(), headless: false, shown_folders: Vec::new(), diff --git a/crates/ui-egui/src/fonts.rs b/crates/ui-egui/src/fonts.rs index b31b423a..95080619 100644 --- a/crates/ui-egui/src/fonts.rs +++ b/crates/ui-egui/src/fonts.rs @@ -161,7 +161,7 @@ impl UiFonts { defs.families.entry(family).or_default().push(name.clone()); } } - ctx.set_fonts(defs); + crate::theme::load_fonts(ctx, defs); self.installed = want; } diff --git a/crates/ui-egui/src/frame_gizmo.rs b/crates/ui-egui/src/frame_gizmo.rs index 6dd6bd18..ee248d89 100644 --- a/crates/ui-egui/src/frame_gizmo.rs +++ b/crates/ui-egui/src/frame_gizmo.rs @@ -418,7 +418,7 @@ pub(crate) mod tests { let session = Session::new_project("Gizmo", texturecraft_engine::geom::primitives::sphere(1.0, 48, 24), "builtin:sphere", None, 128).unwrap(); let builder = egui_kittest::Harness::builder().with_size(TEST_WINDOW); let builder = if render { builder.wgpu() } else { builder }; - let mut harness = builder.build_eframe(|context| TextureCraftApp::new(context, session)); + let mut harness = builder.with_context_setup(crate::framework::install_headless).build_eframe(|context| TextureCraftApp::new(context, session)); harness.run_steps(4); harness } diff --git a/crates/ui-egui/src/framework.rs b/crates/ui-egui/src/framework.rs new file mode 100644 index 00000000..4ceada6d --- /dev/null +++ b/crates/ui-egui/src/framework.rs @@ -0,0 +1,154 @@ +//! The craft-ui runtime, hosted from TextureCraft's own eframe `App` (craft-libs docs/craft-framework.md, section 2.2). +//! The desktop app calls [`install`] once, [`TextureCraftApp::before_input`] in `raw_input_hook`, +//! [`TextureCraftApp::close_path`] last in `logic`, and [`before_ui`] first in `ui`; the browser build and tests +//! install with [`install_headless`]. The framework dialogs run on [`TextureCraftApp::framework_dialogs`] after +//! TextureCraft's own UI. +//! +//! The runtime takes Escape, Tab and the clipboard events for the whole window unless one of TextureCraft's own egui +//! widgets has the keyboard. The window's Escape is read with [`escape_pressed`] and taken with +//! [`take_window_cancel`]; the 3D/2D viewport is declared to the runtime with [`host_canvas`], which keeps Tab (Hide +//! UI), the edit chords and the clipboard events in egui's input for TextureCraft's shortcuts. + +use std::sync::{Arc, OnceLock}; + +use craft_host::target::ShellInfo; +use craft_host::{AppInfo, Host}; +use craft_keymap::Overrides; +use craft_ui::fonts::{I18nScripts, SystemFonts, UiFonts}; +use craft_ui::runtime::commands::{CommandInput, CommandSet as _, NavCommand, QuitCommand}; +use craft_ui::runtime::env::{RootEnv, Scale}; +use craft_ui::runtime::focus::{EditSet, KeepKeys, KeyUse}; +use craft_ui::runtime::frame::{FrameInput, FrameOutput}; +use craft_ui::runtime::keys::{Intent, with_window_intents}; +use craft_ui::shell::embed::{self, CloseDecision}; +use craft_window::policy::Decision; +use craft_window::system::WindowSystem; +use egui::ViewportId; + +use crate::TextureCraftApp; + +/// Each pass of the root window, first in `App::ui`: hands the runtime the native window it answers the hit test of +/// (Windows) and fits the window to its monitor once. +#[cfg(not(target_arch = "wasm32"))] +pub use craft_ui::shell::embed::before_ui; + +/// The id every OS window of the app carries, as the desktop entry and the update app name it. +const APP_ID: &str = "ai.storyteller.texturecraft"; + +/// The scripts of the interface languages, for the font stack. +static SCRIPTS: I18nScripts = I18nScripts; + +/// The runtime's first font stack: egui's bundled faces and no installed system fonts. TextureCraft's own definitions +/// ([`crate::theme::install`]) replace it before anything is drawn. +fn ui_fonts() -> UiFonts<'static> { + UiFonts::new(&SCRIPTS).system_fonts(SystemFonts::Off) +} + +fn install_with(ctx: &egui::Context, shell: ShellInfo, windows: Arc, frame: Option) -> Result<(), String> { + let mut spec = craft_ui::InstallSpec::new(shell, windows).app_id(APP_ID); + if let Some(frame) = frame { + spec = spec.frame(frame); + } + embed::install(ctx, spec, &ui_fonts()).map(drop).map_err(|error| format!("the UI runtime could not be installed: {error}")) +} + +/// Installs the runtime on the desktop window's context, once, before the first pass, with the window's `frame` +/// ([`crate::titlebar::TitleBar::decide`]). +#[cfg(not(target_arch = "wasm32"))] +pub fn install(ctx: &egui::Context, frame: Decision) -> Result<(), String> { + let shell = ShellInfo::default().backend(craft_host::target::Backend::from_env()); + install_with(ctx, shell, Arc::new(craft_window::system::SystemWindows), Some(frame)) +} + +/// Installs the runtime on a context with no native window of its own: the browser build's canvas and test windows. +pub fn install_headless(ctx: &egui::Context) { + if let Err(error) = install_with(ctx, ShellInfo::default(), Arc::new(craft_window::system::NoWindows), None) { + log::warn!("{error}"); + } +} + +/// Who TextureCraft is to the framework's dialogs (the update dialogs show its name and icon). +pub(crate) fn host() -> Arc { + Arc::new( + Host::builder(AppInfo { id: "texturecraft", name: "TextureCraft", version: texturecraft_engine::VERSION }) + .icon_png(include_bytes!("../../../assets/app-icon/hicolor/128x128/apps/ai.storyteller.texturecraft.png")) + .build(), + ) +} + +/// TextureCraft's own shortcut table keeps the keys the framework binds by default: Ctrl+Q is `ui.quit`, F6 is +/// `camera.orthographic` (and Shift+F6 stays free for it), so the framework's quit and pane moves are unbound. +/// Overrides are keyed by command id, which the command sets give. +fn command_overrides() -> Arc { + static OVERRIDES: OnceLock> = OnceLock::new(); + OVERRIDES + .get_or_init(|| { + let mut overrides = Overrides::new(); + for id in [QuitCommand::Quit.id(), NavCommand::NextPane.id(), NavCommand::PreviousPane.id()] { + overrides.insert(id, Vec::new()); + } + Arc::new(overrides) + }) + .clone() +} + +impl TextureCraftApp { + /// The framework's part of `App::raw_input_hook`, once per frame before the first pass: takes what the runtime + /// gathered since the last frame and gives the coming passes the root values (theme mode and interface scale). + pub fn before_input(&mut self, ctx: &egui::Context) { + // TextureCraft applies the interface scale itself (`logic`), so the runtime keeps the zoom it applied last. + let scale = ctx.zoom_factor(); + embed::before_input(ctx, |output| self.frame_input(ctx, output, scale)); + } + + /// The root values of this frame. TextureCraft registers no commands with the runtime (its own shortcut table + /// runs every key, [`command_overrides`]) and lets it toggle no chrome (Tab is Hide UI, kept in egui by the + /// viewport's [`host_canvas`]), so the output carries nothing it acts on. While one of TextureCraft's own egui + /// modals shows in the root window, the runtime blocks the panels floated into windows of their own. + pub(crate) fn frame_input(&mut self, ctx: &egui::Context, _output: FrameOutput, scale: f32) -> FrameInput { + use crate::theme::Brightness; + let mode = match self.ui.prefs.brightness { + Brightness::Light | Brightness::MediumLight => craft_theme::Mode::Light, + Brightness::Dark | Brightness::MediumDark => craft_theme::Mode::Dark, + }; + let root = RootEnv::new().mode(mode).scale(Scale::new(scale)); + let app_modal = crate::docking::input_blocked(self, ctx).then_some(ViewportId::ROOT); + FrameInput::new(root).commands(CommandInput::new().overrides(command_overrides())).host(Arc::clone(&self.framework_host)).app_modal(app_modal) + } + + /// The framework's part of `App::logic`, after TextureCraft's own: the root window's close path. Unsaved changes + /// hold the window open while the Unsaved Changes dialog asks ([`crate::windows::close_requested`]); otherwise + /// it closes. + pub fn close_path(&mut self, ctx: &egui::Context) { + embed::logic(ctx, || if crate::windows::close_requested(self) { CloseDecision::Hold } else { CloseDecision::Close }); + } +} + +/// Declares the viewport `id`, drawn in this pass, as the window's document canvas. With nothing focused it is the +/// window's key target: Tab (Hide UI), the edit chords and the clipboard events stay in egui's input for TextureCraft's +/// shortcuts. +pub(crate) fn host_canvas(ctx: &egui::Context, id: egui::Id) { + const KEYS: KeyUse = KeyUse::CANVAS.with_keep(KeepKeys::Tab).with_edits(EditSet::ALL); + craft_ui::runtime::focus::host_canvas(ctx, id, KEYS); +} + +/// Whether Escape was pressed in this pass: from egui while one of TextureCraft's own widgets or popups has the +/// keyboard, otherwise the window's cancel, which the runtime routes to no component. Leaves it for later readers. +pub(crate) fn escape_pressed(ctx: &egui::Context) -> bool { + ctx.input(|i| i.key_pressed(egui::Key::Escape)) || window_cancel(ctx, false) +} + +/// Takes the window's cancel (an Escape while nothing has framework focus) when it is there: no later reader sees it. +pub(crate) fn take_window_cancel(ctx: &egui::Context) -> bool { + window_cancel(ctx, true) +} + +/// Whether the window's cancel is there and untaken; `take` takes it. +fn window_cancel(ctx: &egui::Context, take: bool) -> bool { + let mut pending = false; + with_window_intents(ctx, false, |intents| { + pending = if take { intents.take(Intent::Cancel) } else { intents.untaken(&Intent::Cancel) }; + take && pending + }); + pending +} diff --git a/crates/ui-egui/src/keymap.rs b/crates/ui-egui/src/keymap.rs index 60479152..827dc7db 100644 --- a/crates/ui-egui/src/keymap.rs +++ b/crates/ui-egui/src/keymap.rs @@ -4,7 +4,7 @@ use std::collections::BTreeMap; -use craft_keymap::egui::Dispatcher; +use crate::shortcut_dispatch::Dispatcher; use craft_keymap::{Active, Chord, CommandDef, CommandRef, ConflictKind, KeyInput, Layout, Lookup, Mods, Overrides, Platform, Scope, Scopes}; use egui::{Event, Id, Key, KeyboardShortcut, Modifiers, RichText, vec2}; use egui_phosphor::regular as ic; @@ -229,7 +229,7 @@ impl Default for Bindings { let stored = Keymap::new(); let map = resolved(&stored, Platform::current()); // Held keys repeat their command. Copy, Cut and Paste events count as Ctrl+C, X and V. - Bindings { stored, map, dispatcher: Dispatcher::new().with_repeat(true).with_clipboard_events(true) } + Bindings { stored, map, dispatcher: Dispatcher::default() } } } @@ -245,7 +245,7 @@ impl Bindings { /// The ids of the commands this frame's key presses run, in press order. The presses are /// removed from the input. pub(crate) fn dispatch(&mut self, input: &mut egui::InputState) -> Vec { - self.dispatcher.dispatch(input, &self.map, &Active::NONE).into_iter().map(|hit| hit.command.id).collect() + self.dispatcher.dispatch_filtered(input, &self.map, |_| true).into_iter().map(|hit| hit.command.id).collect() } /// The id of the command a key press outside the main window runs. The press is matched as @@ -391,7 +391,9 @@ pub(crate) fn actions_page(ui: &mut egui::Ui, keymap: &mut Keymap, recorder: &Bi let tk = Tokens::get(&ctx); let capture_id = Id::unique(SETTINGS_CAPTURE); let mut capture: Option = ctx.data(|d| d.get_temp(capture_id)); - if let (Some(i), Some(sc)) = (capture, pressed(&ctx, recorder)) { + if let Some(i) = capture + && let Some(sc) = pressed(&ctx, recorder) + { if let Some(b) = bindings().get(i) { if sc.logical_key == Key::Delete && sc.modifiers.is_none() { rebind(keymap, b, ""); @@ -487,15 +489,17 @@ pub(crate) fn actions_page(ui: &mut egui::Ui, keymap: &mut Keymap, recorder: &Bi }); } -/// The first key press this frame as a shortcut. +/// The first key press this frame as a shortcut. A plain Escape while none of TextureCraft's widgets has the keyboard +/// is the window's cancel, which the recorder takes as the Escape that cancels it. fn pressed(ctx: &egui::Context, bindings: &Bindings) -> Option { let platform = craft_keymap::egui::platform(ctx); - ctx.input(|i| { + let press = ctx.input(|i| { i.events.iter().find_map(|e| match e { Event::Key { key, pressed: true, modifiers, .. } => Some(bindings.recorded(e, *key, *modifiers, platform)), _ => None, }) - }) + }); + press.or_else(|| crate::framework::take_window_cancel(ctx).then(|| KeyboardShortcut::new(Modifiers::NONE, Key::Escape))) } /// The shortcut editor window. @@ -509,7 +513,9 @@ pub fn window(app: &mut TextureCraftApp, ctx: &egui::Context) { let capture_id = Id::unique(CAPTURE); let filter_id = Id::unique("keymap_filter"); let mut capture: Option = ctx.data(|d| d.get_temp(capture_id)); - if let (Some(i), Some(sc)) = (capture, pressed(ctx, &app.bindings)) { + if let Some(i) = capture + && let Some(sc) = pressed(ctx, &app.bindings) + { if (sc.logical_key != Key::Escape || !sc.modifiers.is_none()) && let Some(b) = bindings().get(i) { diff --git a/crates/ui-egui/src/lib.rs b/crates/ui-egui/src/lib.rs index 47259f2b..afada79b 100644 --- a/crates/ui-egui/src/lib.rs +++ b/crates/ui-egui/src/lib.rs @@ -43,6 +43,7 @@ mod filter_slot; mod filter_transform_rows; mod folder_properties; pub mod fonts; +pub mod framework; mod frame_gizmo; mod generator_panel; pub mod gpu; @@ -89,6 +90,7 @@ mod orb_environment; mod orb_material; pub mod orb_previews; mod orb_shape; +mod pane_split; pub mod parity; mod past_end; mod path_hit; @@ -135,6 +137,7 @@ mod session_log_file; pub mod settings_window; pub mod shader_settings; pub mod shelf; +mod shortcut_dispatch; mod shelf_entry; mod shelf_folders; pub mod shelf_panes; @@ -309,6 +312,12 @@ pub struct TextureCraftApp { pub banner: Option<&'static str>, /// Who draws the window's title bar (decided at startup, before the window opens). pub title_bar: titlebar::TitleBar, + /// The dock area's workspace and panel specs between passes. + pub(crate) docks: docking::LiveDock, + /// The framework dialogs (the update dialogs), run once per pass after TextureCraft's own UI. + pub framework_dialogs: craft_ui::dialog::DialogHost, + /// Who TextureCraft is to the framework's dialogs. + pub(crate) framework_host: std::sync::Arc, last_time: f64, /// When the next autosave is due (seconds of app time; desktop only). #[cfg_attr(target_arch = "wasm32", allow(dead_code))] @@ -434,6 +443,9 @@ impl TextureCraftApp { fonts: fonts::UiFonts::default(), banner: None, title_bar: titlebar::TitleBar::default(), + docks: docking::LiveDock::default(), + framework_dialogs: craft_ui::dialog::DialogHost::new(), + framework_host: framework::host(), last_time: 0.0, next_autosave, styled: None, @@ -1052,6 +1064,7 @@ impl TextureCraftApp { impl eframe::App for TextureCraftApp { /// A drag that holds the pointer reads the pointer's moves as moves of a pointer no screen edge stops fn raw_input_hook(&mut self, ctx: &egui::Context, raw_input: &mut egui::RawInput) { + self.before_input(ctx); pointer_lock::rewrite(ctx, raw_input); } @@ -1158,7 +1171,7 @@ impl eframe::App for TextureCraftApp { self.profiler.logic_ms = (now_ms() - logic_start_ms) as f32; // Last, so it sees every close request this frame's work made - windows::close_request(self, ctx); + self.close_path(ctx); } #[cfg_attr(target_arch = "wasm32", allow(unused_variables))] @@ -1187,7 +1200,14 @@ impl eframe::App for TextureCraftApp { // The dock keeps the cards' gutter from the bars and rails around it let panel_frame = if hide_ui { egui::Frame::NONE.fill(tokens.viewport) } else { egui::Frame::NONE.fill(tokens.chrome).inner_margin(theme::GUTTER) }; - egui::CentralPanel::default().frame(panel_frame).show(ui, |ui| if hide_ui { viewport::central(self, ui) } else { docking::show(self, ui) }); + egui::CentralPanel::default().frame(panel_frame).show(ui, |ui| { + if hide_ui { + docking::host_viewport_canvas(ui.ctx()); + viewport::central(self, ui); + } else { + docking::show(self, ui); + } + }); windows::show(self, &ctx); // Finish after the dock and windows have requested their thumbnails @@ -1195,6 +1215,7 @@ impl eframe::App for TextureCraftApp { #[cfg(not(target_arch = "wasm32"))] updates_ui::show(self, &ctx); + self.framework_dialogs.run(ui); toasts(self, &ctx); #[cfg(not(target_arch = "wasm32"))] self.file_dialogs.show_pending(frame); diff --git a/crates/ui-egui/src/menus.rs b/crates/ui-egui/src/menus.rs index 1d4588ea..40177667 100644 --- a/crates/ui-egui/src/menus.rs +++ b/crates/ui-egui/src/menus.rs @@ -458,6 +458,14 @@ pub fn shortcuts(app: &mut TextureCraftApp, ctx: &egui::Context) { return; } + // A plain Escape no widget of TextureCraft's took is the window's cancel: it runs the Escape handlers and shortcuts below + if crate::framework::take_window_cancel(ctx) { + ctx.input_mut(|i| { + let modifiers = i.modifiers; + i.events.insert(0, egui::Event::Key { key: Key::Escape, physical_key: Some(Key::Escape), pressed: true, repeat: false, modifiers }); + }); + } + // 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| { diff --git a/crates/ui-egui/src/pane_split.rs b/crates/ui-egui/src/pane_split.rs new file mode 100644 index 00000000..f9768a08 --- /dev/null +++ b/crates/ui-egui/src/pane_split.rs @@ -0,0 +1,261 @@ +//! Two panes split by a focusable divider: the geometry of one split and its resize handle (pointer drag, arrow keys +//! and accessibility). The shelf's saved searches and path filter (`shelf_panes.rs`) use it. + +use std::ops::RangeInclusive; + +use craft_behavior::dock::SplitSize; +use craft_behavior::flow::Axis; +use egui::{Color32, EventFilter, Id, Key, Modifiers, Rect, Response, Sense, Ui, Vec2, accesskit}; + +/// Contained, non-overlapping rectangles of a single split, including its divider. +#[derive(Clone, Copy, Debug, PartialEq)] +pub(crate) struct SplitLayout { + pub(crate) first: Rect, + pub(crate) divider: Rect, + pub(crate) second: Rect, + first_size: f32, + available: f32, +} + +impl SplitLayout { + /// The first pane's size along the split axis, in points. + pub(crate) fn first_size(self) -> f32 { + self.first_size + } + + /// Space for both panes, excluding the divider, in points. + pub(crate) fn available(self) -> f32 { + self.available + } + + /// The size after moving the divider by `delta` points, in the same sizing mode. When both minima cannot fit, + /// each pane gets half the available space. Invalid inputs and zero available space give `None`, so the caller + /// keeps its saved value. + pub(crate) fn resized(self, size: SplitSize, delta: f32, minimum: f32) -> Option { + if !value(size).is_finite() || !delta.is_finite() || !valid_nonnegative(minimum) || self.available <= 0.0 { + return None; + } + let available = f64::from(self.available); + let first = clamp_first(f64::from(self.first_size) + f64::from(delta), available, minimum); + Some(match size { + SplitSize::FixedFirst(_) => SplitSize::FixedFirst(first as f32), + SplitSize::FixedSecond(_) => SplitSize::FixedSecond((available - first) as f32), + _ => SplitSize::Ratio((first / available) as f32), + }) + } +} + +fn value(size: SplitSize) -> f32 { + match size { + SplitSize::Ratio(v) | SplitSize::FixedFirst(v) | SplitSize::FixedSecond(v) => v, + #[allow(unreachable_patterns)] + _ => f32::NAN, + } +} + +/// Divides `rect` into two panes and a divider `gap` points thick. Equal pane minima relax to half the remaining +/// span in tiny areas; finite sizes outside the available range are clamped. Inverted or non-finite rectangles, a +/// negative or non-finite gap or minimum and a non-finite size give `None`. +pub(crate) fn split_rect(rect: Rect, axis: Axis, size: SplitSize, gap: f32, minimum: f32) -> Option { + if !valid_rect(rect) || !valid_nonnegative(gap) || !valid_nonnegative(minimum) || !value(size).is_finite() { + return None; + } + let total = if axis == Axis::X { rect.width() } else { rect.height() }; + let gap = gap.min(total); + let available = total - gap; + let space = f64::from(available); + // f64: two finite f32 inputs can overflow when multiplied. + let wanted = match size { + SplitSize::FixedFirst(points) => f64::from(points), + SplitSize::FixedSecond(points) => space - f64::from(points), + other => space * f64::from(value(other)), + }; + let first_size = clamp_first(wanted, space, minimum) as f32; + let (mut first, mut divider, mut second) = (rect, rect, rect); + if axis == Axis::X { + first.max.x = (rect.min.x + first_size).min(rect.max.x); + divider.min.x = first.max.x; + divider.max.x = (divider.min.x + gap).min(rect.max.x); + second.min.x = divider.max.x; + } else { + first.max.y = (rect.min.y + first_size).min(rect.max.y); + divider.min.y = first.max.y; + divider.max.y = (divider.min.y + gap).min(rect.max.y); + second.min.y = divider.max.y; + } + Some(SplitLayout { first, divider, second, first_size, available }) +} + +fn valid_rect(rect: Rect) -> bool { + rect.min.is_finite() && rect.max.is_finite() && rect.width().is_finite() && rect.height().is_finite() && rect.min.x <= rect.max.x && rect.min.y <= rect.max.y +} + +fn valid_nonnegative(value: f32) -> bool { + value.is_finite() && value >= 0.0 +} + +fn clamp_first(wanted: f64, available: f64, minimum: f32) -> f64 { + let low = f64::from(minimum).min(available * 0.5); + wanted.clamp(low, available - low) +} + +/// Colours of a resize handle. The handle at rest paints no fill. +#[derive(Clone, Copy, Debug)] +pub(crate) struct ResizeHandleStyle { + pub(crate) hovered: Color32, + pub(crate) dragged: Color32, + pub(crate) focused: Color32, +} + +/// A focusable divider moved by a pointer drag, the arrows along its axis while it has focus, and accessibility's +/// Increment, Decrement and SetValue. It never stores a size: [`show`](ResizeHandle::show) returns the move along the +/// axis for the caller to apply. +pub(crate) struct ResizeHandle<'a> { + id: Id, + axis: Axis, + rect: Rect, + label: &'a str, + style: ResizeHandleStyle, + hit_margin: f32, + value: Option<(f32, RangeInclusive)>, +} + +/// Keyboard and accessibility step, in points. +const STEP: f32 = 8.0; + +impl<'a> ResizeHandle<'a> { + pub(crate) fn new(id: Id, axis: Axis, rect: Rect, label: &'a str, style: ResizeHandleStyle) -> Self { + Self { id, axis, rect, label, style, hit_margin: 3.0, value: None } + } + + /// Widens the hit rectangle along the movement axis, in points. Default: 3. + pub(crate) fn hit_margin(mut self, margin: f32) -> Self { + self.hit_margin = margin; + self + } + + /// The current size and its bounds, for accessibility and its SetValue action. + pub(crate) fn value(mut self, value: f32, range: RangeInclusive) -> Self { + self.value = Some((value, range)); + self + } + + /// Shows the handle and returns the requested move along the axis this pass, in points (0 for none). + pub(crate) fn show(self, ui: &mut Ui) -> f32 { + let horizontal = self.axis == Axis::X; + let hit = self.rect.expand2(if horizontal { Vec2::new(self.hit_margin, 0.0) } else { Vec2::new(0.0, self.hit_margin) }); + let valid = valid_rect(self.rect) + && self.rect.width() > 0.0 + && self.rect.height() > 0.0 + && valid_rect(hit) + && (0.0..=4096.0).contains(&self.hit_margin) + && self.value.as_ref().is_none_or(|(value, range)| value.is_finite() && range.start().is_finite() && range.end().is_finite() && range.start() <= range.end()); + let inert = Rect::from_min_size(ui.min_rect().min, Vec2::ZERO); + let mut response = ui.interact(if valid { hit } else { inert }, self.id, if valid { Sense::drag() } else { Sense::hover() }); + let enabled = valid && response.enabled(); + let mut delta = 0.0; + if enabled { + drag_focus(ui, &response); + if response.dragged() { + let drag = response.drag_delta(); + delta = if horizontal { drag.x } else { drag.y }; + } + if response.has_focus() { + let filter = EventFilter { horizontal_arrows: horizontal, vertical_arrows: !horizontal, ..Default::default() }; + ui.memory_mut(|memory| memory.set_focus_lock_filter(response.id, filter)); + let (back, forward) = if horizontal { (Key::ArrowLeft, Key::ArrowRight) } else { (Key::ArrowUp, Key::ArrowDown) }; + ui.input_mut(|input| { + if input.consume_key(Modifiers::NONE, back) { + delta -= STEP; + } + if input.consume_key(Modifiers::NONE, forward) { + delta += STEP; + } + }); + } + let mut change = 0.0; + ui.input_mut(|input| { + input.consume_accesskit_action_requests(response.id, |request| match request.action { + accesskit::Action::Increment => { + change += STEP; + true + } + accesskit::Action::Decrement => { + change -= STEP; + true + } + accesskit::Action::SetValue => { + if let (Some((value, range)), Some(accesskit::ActionData::NumericValue(new_value))) = (&self.value, &request.data) + && new_value.is_finite() + { + change = (new_value.clamp(f64::from(*range.start()), f64::from(*range.end())) - f64::from(*value)) as f32; + delta = 0.0; + } + true + } + _ => false, + }); + }); + delta += change; + } + if !delta.is_finite() { + delta = 0.0; + } + if delta != 0.0 { + response.mark_changed(); + } + response.widget_info(|| match &self.value { + Some((value, _)) if valid => egui::WidgetInfo::slider(enabled, f64::from(*value), self.label), + _ => egui::WidgetInfo::labeled(egui::Role::Unknown, enabled, self.label), + }); + ui.ctx().accesskit_node_builder(response.id, |node| { + node.set_role(accesskit::Role::Splitter); + // Orientation describes the divider itself, across its movement axis. + node.set_orientation(if horizontal { accesskit::Orientation::Vertical } else { accesskit::Orientation::Horizontal }); + if enabled { + node.add_action(accesskit::Action::Increment); + node.add_action(accesskit::Action::Decrement); + if let Some((value, range)) = &self.value { + node.set_numeric_value(f64::from(*value)); + node.set_min_numeric_value(f64::from(*range.start())); + node.set_max_numeric_value(f64::from(*range.end())); + node.set_numeric_value_step(f64::from(STEP)); + node.add_action(accesskit::Action::SetValue); + } + } + }); + if enabled { + let fill = if response.dragged() { + Some(self.style.dragged) + } else if response.has_focus() { + Some(self.style.focused) + } else if response.hovered() { + Some(self.style.hovered) + } else { + None + }; + if let Some(fill) = fill { + ui.painter().rect_filled(self.rect, 0.0, fill); + } + if response.hovered() || response.dragged() { + ui.ctx().set_cursor_icon(if horizontal { egui::CursorIcon::ResizeHorizontal } else { egui::CursorIcon::ResizeVertical }); + } + } + delta + } +} + +/// A pointer drag focuses its handle for the gesture only and gives the focus up on release, so the app's shortcuts +/// and its canvas arrow keys work again. A handle focused from the keyboard before the drag keeps its focus. +fn drag_focus(ui: &Ui, response: &Response) { + let key = response.id.with("pointer-focus"); + if response.drag_started() { + if !response.has_focus() { + ui.ctx().data_mut(|d| d.insert_temp(key, ())); + } + response.request_focus(); + } + if response.drag_stopped() && ui.ctx().data_mut(|d| d.remove_temp::<()>(key)).is_some() { + response.surrender_focus(); + } +} diff --git a/crates/ui-egui/src/property_sheet/color_bar.rs b/crates/ui-egui/src/property_sheet/color_bar.rs index c2df268d..def850d8 100644 --- a/crates/ui-egui/src/property_sheet/color_bar.rs +++ b/crates/ui-egui/src/property_sheet/color_bar.rs @@ -285,7 +285,7 @@ impl PropertySheet<'_> { }); // Escape ends hex editing first even when egui has already dropped the field's focus - let escape = ctx.input(|input| input.key_pressed(egui::Key::Escape)) + let escape = crate::framework::escape_pressed(&ctx) && ctx.memory(|memory| memory.focused().is_none_or(|focused| focused == bar.id)) && !hex_took_escape(&ctx); if closed || (!list_open && !waiting && (pressed_outside || escape)) { diff --git a/crates/ui-egui/src/property_sheet/mod.rs b/crates/ui-egui/src/property_sheet/mod.rs index 62c81046..0a81211d 100644 --- a/crates/ui-egui/src/property_sheet/mod.rs +++ b/crates/ui-egui/src/property_sheet/mod.rs @@ -63,7 +63,7 @@ pub(crate) use properties_scroll::{PropertiesScroll, PropertiesSelection}; pub(crate) use row_lead::RowLead; pub(crate) use section_tabs::{ SectionScope, TAB_GAP, TAB_ICON_CENTER, TAB_ICON_SIZE, TAB_NAME_LEFT, TAB_PADDING, TAB_ROUNDING, TAB_TEXT_SIZE, TAB_TOP, forget_sections, - full_height_tab_rect, in_scope, room_past_end, section_tabs, shown_tab_box, + in_scope, room_past_end, section_tabs, }; pub(crate) use sheet::PropertySheet; pub(crate) use slot_response::SlotResponse; diff --git a/crates/ui-egui/src/property_sheet/section_tabs.rs b/crates/ui-egui/src/property_sheet/section_tabs.rs index 7a4e7d73..595116ca 100644 --- a/crates/ui-egui/src/property_sheet/section_tabs.rs +++ b/crates/ui-egui/src/property_sheet/section_tabs.rs @@ -109,13 +109,8 @@ fn tab_rect(strip: Rect, left: f32, right: f32) -> Rect { Rect::from_min_max(pos2(left, strip.top() + TAB_TOP), pos2(right, strip.bottom() + TAB_BELOW)) } -/// A tab from `left` to `right` filling `strip`'s whole height and reaching as far into the panel as a section tab: a docked group's shown tab -pub(crate) fn full_height_tab_rect(strip: Rect, left: f32, right: f32) -> Rect { - Rect::from_min_max(pos2(left, strip.top()), pos2(right, strip.bottom() + TAB_BELOW)) -} - /// The shown tab's box over `tab`: the panel's colour, rounded, so it rises from the panel below the strip -pub(crate) fn shown_tab_box(painter: &Painter, tokens: &Tokens, tab: Rect) { +fn shown_tab_box(painter: &Painter, tokens: &Tokens, tab: Rect) { painter.rect_filled(tab, CornerRadius::same(TAB_ROUNDING), tokens.panel); } diff --git a/crates/ui-egui/src/rail_popup.rs b/crates/ui-egui/src/rail_popup.rs index 615ff4cc..785e76b8 100644 --- a/crates/ui-egui/src/rail_popup.rs +++ b/crates/ui-egui/src/rail_popup.rs @@ -56,11 +56,6 @@ 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") @@ -114,16 +109,6 @@ pub(crate) fn open(app: &mut TextureCraftApp, panel: 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"); @@ -196,13 +181,12 @@ pub(crate) fn show(app: &mut TextureCraftApp, ctx: &egui::Context) { // The floating window opens where the popup was, at its size app.ui.rail_panel = None; if let Some(rect) = shown { - app.ui.dock.float_at(panel, [rect.left(), rect.top(), rect.width(), rect.height()]); + app.ui.dock.float_at(panel, rect); } } else if let Some(title) = dragged_from { + // The floating window opens where the popup was 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))); + app.ui.dock.float_at(panel, shown.unwrap_or(title)); } } diff --git a/crates/ui-egui/src/render_mode/tests.rs b/crates/ui-egui/src/render_mode/tests.rs index 114bef4c..a0bd842d 100644 --- a/crates/ui-egui/src/render_mode/tests.rs +++ b/crates/ui-egui/src/render_mode/tests.rs @@ -39,7 +39,7 @@ fn environment_cache_retains_source_identity_until_replaced() { // The harness draws once; parallel translation tests must not change its language mid-frame let _language = crate::i18n::TEST_LANGUAGE.lock().unwrap_or_else(std::sync::PoisonError::into_inner); - let mut app = egui_kittest::Harness::builder().build_eframe(|context| crate::TextureCraftApp::new(context, session())).into_state(); + let mut app = egui_kittest::Harness::builder().with_context_setup(crate::framework::install_headless).build_eframe(|context| crate::TextureCraftApp::new(context, session())).into_state(); app.session.doc.project.display.environment = "resource:environment".into(); let source = Arc::new(ImageRes::new(2, 1, vec![[1.0, 0.0, 0.0, 1.0]; 2], false)); let original_source = Arc::downgrade(&source); @@ -71,7 +71,7 @@ fn environment_cache_retains_source_identity_until_replaced() { #[test] fn a_new_display_background_restarts_the_render() { let _language = crate::i18n::TEST_LANGUAGE.lock().unwrap_or_else(std::sync::PoisonError::into_inner); - let mut app = egui_kittest::Harness::builder().build_eframe(|context| crate::TextureCraftApp::new(context, session())).into_state(); + let mut app = egui_kittest::Harness::builder().with_context_setup(crate::framework::install_headless).build_eframe(|context| crate::TextureCraftApp::new(context, session())).into_state(); let before = super::key(&app, "scene", (64, 64)); assert_eq!(super::key(&app, "scene", (64, 64)), before); @@ -109,7 +109,7 @@ fn gpu_app() -> Option { let mut app = egui_kittest::Harness::builder() .with_size(egui::vec2(800.0, 600.0)) .renderer(WgpuTestRenderer::from_render_state(render_state)) - .build_eframe(|context| crate::TextureCraftApp::new(context, session())) + .with_context_setup(crate::framework::install_headless).build_eframe(|context| crate::TextureCraftApp::new(context, session())) .into_state(); app.session.update(); for cache in &mut app.session.caches { diff --git a/crates/ui-egui/src/screen_color_pick.rs b/crates/ui-egui/src/screen_color_pick.rs index 6da89f2b..9892dbdf 100644 --- a/crates/ui-egui/src/screen_color_pick.rs +++ b/crates/ui-egui/src/screen_color_pick.rs @@ -44,8 +44,8 @@ fn pick_with(ui: &mut Ui, id: Id, linear: &mut [f32; 3], button: impl FnOnce(&mu pick.target = if picking { None } else { Some(id) }; } else if picking { ui.ctx().set_cursor_icon(egui::CursorIcon::Crosshair); - let (clicked, escaped, pointer) = - ui.input(|input| (input.pointer.primary_clicked(), input.key_pressed(egui::Key::Escape), input.pointer.interact_pos())); + let (clicked, pointer) = ui.input(|input| (input.pointer.primary_clicked(), input.pointer.interact_pos())); + let escaped = crate::framework::escape_pressed(ui.ctx()); if escaped { pick.target = None; } else if clicked && let Some(point) = pointer { diff --git a/crates/ui-egui/src/shelf_panes.rs b/crates/ui-egui/src/shelf_panes.rs index 90315269..26ef28a3 100644 --- a/crates/ui-egui/src/shelf_panes.rs +++ b/crates/ui-egui/src/shelf_panes.rs @@ -1,6 +1,5 @@ //! The shelf's side panes left of the grid, toggled from the toolbar: saved searches and the folder tree -use craft_ui::layout::{ResizeHandle, ResizeHandleStyle, SplitLayout, split_rect}; use craft_behavior::flow::Axis; use craft_behavior::dock::SplitSize; use egui::{Rect, RichText, Ui, UiBuilder}; @@ -8,6 +7,7 @@ use egui_phosphor::regular as ic; use serde::{Deserialize, Serialize}; use crate::TextureCraftApp; +use crate::pane_split::{ResizeHandle, ResizeHandleStyle, SplitLayout, split_rect}; use crate::i18n::{n_, tr}; use crate::saved_search::SavedSearch; use crate::shelf::TABS; @@ -105,12 +105,12 @@ fn splitter(app: &mut TextureCraftApp, ui: &mut Ui, rect: Rect) -> Option 2.0 * minimum_points { let colors = ResizeHandleStyle { hovered: visuals.widgets.hovered.bg_fill, dragged: visuals.widgets.active.bg_fill, focused: visuals.selection.bg_fill }; - let resize = ResizeHandle::new(ui.scope_id().with("shelf_panes_splitter"), axis, layout.divider, tr("Resize Assets filter panes"), colors) + let delta = ResizeHandle::new(ui.scope_id().with("shelf_panes_splitter"), axis, layout.divider, tr("Resize Assets filter panes"), colors) .hit_margin(0.0) .value(layout.first_size(), minimum_points..=available_points - minimum_points) .show(ui); - if resize.delta != 0.0 - && let Some(SplitSize::Ratio(share)) = layout.resized(size, resize.delta, minimum_points) + if delta != 0.0 + && let Some(SplitSize::Ratio(share)) = layout.resized(size, delta, minimum_points) { app.ui.shelf_panes_split = share; layout = split_rect(rect, axis, SplitSize::Ratio(share), SPLITTER_HEIGHT_POINTS, minimum_points)?; diff --git a/crates/ui-egui/src/shortcut_dispatch.rs b/crates/ui-egui/src/shortcut_dispatch.rs new file mode 100644 index 00000000..b09dd531 --- /dev/null +++ b/crates/ui-egui/src/shortcut_dispatch.rs @@ -0,0 +1,255 @@ +//! The frame's key presses and clipboard events as the shortcuts they run: egui's events fed to +//! `craft_keymap::Matcher`, one press at a time in press order. +//! +//! - A press that runs a command is removed from egui's input, with the text it typed; one that +//! runs nothing, or whose hit the caller declines, stays. +//! - Held keys run their command again on each repeat (a held arrow nudges); repeats never count +//! toward a double press. +//! - egui's Copy, Cut and Paste events count as their plain chords (Cmd+C, Cmd+X, Cmd+V; +//! Shift+Delete and Shift+Insert), so the desktop's clipboard events run the edit commands. The +//! web build sends a clipboard press and the clipboard event it causes: the press decides, and +//! its event goes with it when it runs a command and stays otherwise. +//! - The keyboard layout is learned from what plain presses type, and taken from egui when the +//! integration reports whether it is Latin. + +use craft_keymap::{Active, Hit, Key, KeyInput, Keymap, Layout, Matcher, Mods, Platform, Press}; +use egui::{Event, InputState, Key as EguiKey}; + +/// eframe's web build sends a press's Text event first when no text field has focus. +const TEXT_FIRST: bool = cfg!(target_arch = "wasm32"); + +/// What matching carries between frames: the previous press (double presses) and the layout. +#[derive(Default)] +pub(crate) struct Dispatcher { + matcher: Matcher, + layout: Layout, + /// Whether right Alt is held. egui-winit reports AltGr with neither Ctrl nor Alt, so its + /// presses would otherwise teach the layout as plain ones. + right_alt: bool, +} + +impl Dispatcher { + /// The keyboard layout learned so far: what a press stands for as a chord. + pub(crate) fn layout(&self) -> &Layout { + &self.layout + } + + /// The commands this frame's key presses and clipboard events run, in press order, with + /// `accept` deciding each hit before its event is removed. A declined hit is left out and its + /// event, with any text it typed, stays in egui's input in its place. + pub(crate) fn dispatch_filtered(&mut self, input: &mut InputState, keymap: &Keymap, mut accept: impl FnMut(&Hit) -> bool) -> Vec { + let platform = keymap.platform(); + let now = input.time; + let frame_mods = Mods::from_egui(&input.modifiers, platform); + let events = std::mem::take(&mut input.events); + let text_of = text_of_press(&events, TEXT_FIRST); + if let Some(latin) = input.keyboard_layout_is_latin() { + self.layout.set_latin(Some(latin)); + } + self.learn(&events, &text_of, platform); + let causes = clipboard_event_follows(&events, &self.layout, platform, input); + let mut caused_taken: Vec> = vec![None; events.len()]; + let mut drop = vec![false; events.len()]; + let mut hits = Vec::new(); + let mut kept = Vec::with_capacity(events.len()); + for (i, event) in events.into_iter().enumerate() { + match &event { + Event::Key { pressed: true, repeat, .. } => { + let key = key_input(&event, platform, input); + if self.layout.resolve(&key).is_some() { + let press = Press { input: &key, repeat: *repeat, now, active: &Active::NONE, outer: &[] }; + let hit = self.matcher.press(&self.layout, keymap, &press).filter(&mut accept); + if let Some((j, _)) = causes[i] { + caused_taken[j] = Some(hit.is_some()); + } + if let Some(hit) = hit { + hits.push(hit); + if let Some(j) = text_of[i].filter(|_| !(key.mods.cmd || key.mods.ctrl)) { + drop[j] = true; + } + continue; + } + } + } + // Desktop clipboard events, and web ones whose press ran nothing. + Event::Copy | Event::Cut | Event::Paste(_) => match caused_taken[i] { + Some(true) => continue, + Some(false) => {} + None => { + let (key, held) = clipboard_chord(&event, frame_mods); + let press = Press { input: &KeyInput::new(held).with_typed(key), repeat: false, now, active: &Active::NONE, outer: &[] }; + if let Some(hit) = self.matcher.press(&self.layout, keymap, &press).filter(&mut accept) { + hits.push(hit); + continue; + } + } + }, + _ => {} + } + kept.push((i, event)); + } + input.events = kept.into_iter().filter(|(i, _)| !drop[*i]).map(|(_, e)| e).collect(); + hits + } + + /// Teaches the layout what this frame's presses typed. + fn learn(&mut self, events: &[Event], text_of: &[Option], platform: Platform) { + for (event, text) in events.iter().zip(text_of) { + match event { + Event::Key { physical_key: Some(EguiKey::AltRight), pressed, .. } => self.right_alt = *pressed, + Event::WindowFocused(false) => self.right_alt = false, + _ => {} + } + if self.right_alt { + continue; + } + let Some(Event::Text(text)) = text.and_then(|j| events.get(j)) else { continue }; + if let Some(KeyInput { mods, physical: Some(physical), .. }) = KeyInput::from_egui(event, platform) { + self.layout.observe(physical, mods, text); + } + } + } +} + +/// A press as [`KeyInput::from_egui`] reads it, with the Latin layout's character `input` reports +/// for its key. +fn key_input(event: &Event, platform: Platform, input: &InputState) -> KeyInput { + let mut key = KeyInput::from_egui(event, platform).unwrap_or(KeyInput::new(Mods::NONE)); + if let Event::Key { physical_key: Some(physical), .. } = event { + key.latin = input.latin_layout_char(*physical); + } + key +} + +/// A clipboard event's kind. +#[derive(Clone, Copy)] +enum Clip { + Copy, + Cut, + Paste, +} + +fn event_clip(event: &Event) -> Option { + match event { + Event::Copy => Some(Clip::Copy), + Event::Cut => Some(Clip::Cut), + Event::Paste(_) => Some(Clip::Paste), + _ => None, + } +} + +/// The clipboard event a backend sends for a press, if any. +fn clipboard_kind(key: Key, held: Mods) -> Option { + match key { + Key::C if held.cmd => Some(Clip::Copy), + Key::X if held.cmd => Some(Clip::Cut), + Key::V if held.cmd => Some(Clip::Paste), + Key::Delete if held.shift => Some(Clip::Cut), + Key::Insert if held.shift => Some(Clip::Paste), + Key::Insert if held.cmd || held.ctrl => Some(Clip::Copy), + _ => None, + } +} + +/// For each clipboard key press whose clipboard event comes later in the frame, as the web build +/// sends them: the index of that event, and the text of a Paste event. +fn clipboard_event_follows(events: &[Event], layout: &Layout, platform: Platform, input: &InputState) -> Vec)>> { + let mut out = vec![None; events.len()]; + let mut ahead: [Option; 3] = [None; 3]; + for (i, event) in events.iter().enumerate().rev() { + if let Some(seen) = event_clip(event).and_then(|c| ahead.get_mut(c as usize)) { + *seen = Some(i); + } else if let Event::Key { pressed: true, .. } = event { + let chord = layout.resolve(&key_input(event, platform, input)); + let clip = chord.and_then(|c| clipboard_kind(c.key, c.mods)); + if let Some(j) = clip.and_then(|c| ahead.get_mut(c as usize)).and_then(Option::take) { + let text = if let Some(Event::Paste(text)) = events.get(j) { Some(text.clone()) } else { None }; + out[i] = Some((j, text)); + } + } + } + out +} + +/// For each key press, the index of the Text event it typed. egui-winit, and eframe's web text +/// agent while a text field has focus, send the Text after the press, before the next one. +/// With `text_first`, eframe's web build with no text field focused, the Text comes right before +/// its press, and only for a press without Ctrl or Cmd. +fn text_of_press(events: &[Event], text_first: bool) -> Vec> { + let is_text = |e: Option<&Event>| matches!(e, Some(Event::Text(t)) if !t.is_empty()); + let mut out = vec![None; events.len()]; + if text_first { + for (i, event) in events.iter().enumerate().skip(1) { + if let Event::Key { pressed: true, modifiers, .. } = event + && !(modifiers.ctrl || modifiers.command || modifiers.mac_cmd) + && is_text(events.get(i - 1)) + { + out[i] = Some(i - 1); + } + } + return out; + } + let mut text_ahead = None; + for (i, event) in events.iter().enumerate().rev() { + match event { + Event::Key { pressed: true, .. } => out[i] = text_ahead.take(), + _ if is_text(Some(event)) => text_ahead = Some(i), + _ => {} + } + } + out +} + +/// The press a clipboard event stands for, with the modifiers held. Off macOS egui-winit also +/// sends Cut for Shift+Delete and Paste for Shift+Insert. +fn clipboard_chord(event: &Event, held: Mods) -> (Key, Mods) { + let with_cmd = Mods { cmd: true, ..held }; + let shift_only = held.shift && !held.cmd; + match event { + Event::Cut if shift_only => (Key::Delete, held), + Event::Cut => (Key::X, with_cmd), + Event::Paste(_) if shift_only => (Key::Insert, held), + Event::Paste(_) => (Key::V, with_cmd), + _ => (Key::C, with_cmd), + } +} + +#[cfg(test)] +mod tests { + use super::*; + use craft_keymap::{Binding, CommandDef, Scope, Scopes}; + + fn keymap() -> Keymap { + let def = |id: &'static str, binding: &str| CommandDef::new(id, id, Scope::app()).with_default(Binding::parse(binding).unwrap()); + Keymap::new(vec![def("tool.marquee", "M"), def("edit.copy", "Ctrl+C")], Scopes::new(), Platform::Windows) + } + + fn press(key: EguiKey, modifiers: egui::Modifiers) -> Event { + Event::Key { key, physical_key: Some(key), pressed: true, repeat: false, modifiers } + } + + /// A press that runs a command leaves egui's input with the text it typed; the others stay, in order. + #[test] + fn a_bound_press_and_its_text_leave_the_input() { + let mut input = InputState::default(); + input.events = + vec![press(EguiKey::M, egui::Modifiers::NONE), Event::Text("m".into()), press(EguiKey::Q, egui::Modifiers::NONE), Event::Text("q".into())]; + let hits = Dispatcher::default().dispatch_filtered(&mut input, &keymap(), |_| true); + assert_eq!(hits.iter().map(|hit| hit.command.id.as_str()).collect::>(), ["tool.marquee"]); + assert_eq!(input.events, [press(EguiKey::Q, egui::Modifiers::NONE), Event::Text("q".into())]); + } + + /// The desktop's Copy event runs the copy command; declined, it stays for egui. + #[test] + fn a_clipboard_event_runs_its_chord_unless_declined() { + let mut input = InputState::default(); + input.events = vec![Event::Copy]; + let hits = Dispatcher::default().dispatch_filtered(&mut input, &keymap(), |_| true); + assert_eq!(hits.iter().map(|hit| hit.command.id.as_str()).collect::>(), ["edit.copy"]); + assert!(input.events.is_empty()); + + input.events = vec![Event::Copy]; + assert!(Dispatcher::default().dispatch_filtered(&mut input, &keymap(), |_| false).is_empty()); + assert_eq!(input.events, [Event::Copy]); + } +} diff --git a/crates/ui-egui/src/theme.rs b/crates/ui-egui/src/theme.rs index 83b779ae..942f9450 100644 --- a/crates/ui-egui/src/theme.rs +++ b/crates/ui-egui/src/theme.rs @@ -324,9 +324,21 @@ pub fn font_definitions() -> egui::FontDefinitions { fonts } +/// Gives the context `fonts` through the framework runtime, which keeps its layout memory in step with them. The +/// framework's chrome (the dock, the update dialogs) also draws in the signature and semibold families: signature +/// takes the proportional faces and semibold TextureCraft's own semibold list. A family left out draws missing-glyph +/// boxes. +pub fn load_fonts(ctx: &egui::Context, mut fonts: egui::FontDefinitions) { + let proportional = fonts.families.get(&FontFamily::Proportional).cloned().unwrap_or_default(); + let semibold = fonts.families.get(&FontFamily::Name(SEMIBOLD.into())).cloned().unwrap_or_else(|| proportional.clone()); + fonts.families.insert(craft_ui::fonts::FontRef::signature().family(), proportional); + fonts.families.insert(FontFamily::Name(craft_ui::fonts::SEMIBOLD.into()), semibold); + craft_ui::fonts::load(ctx, fonts); +} + /// Install the fonts (once, at startup; the app applies the style from its settings). pub fn install(ctx: &egui::Context) { - ctx.set_fonts(font_definitions()); + load_fonts(ctx, font_definitions()); } /// Apply brightness `b` and `accent`: store the tokens for [`Tokens::get`] and style egui with @@ -371,8 +383,18 @@ pub fn apply(ctx: &egui::Context, b: Brightness, accent: Accent) { v.selection.stroke = Stroke::new(1.0, t.text_strong); v.hyperlink_color = t.accent; let w = &mut v.widgets; - craft_ui::theme::WidgetPalette { noninteractive: t.panel, inactive: t.button, hovered: t.row_hover, active: t.tool_active, open: t.row_hover } - .apply_to(w, t.cr(), Stroke::new(1.0, t.text)); + for (widget, fill) in [ + (&mut w.noninteractive, t.panel), + (&mut w.inactive, t.button), + (&mut w.hovered, t.row_hover), + (&mut w.active, t.tool_active), + (&mut w.open, t.row_hover), + ] { + widget.bg_fill = fill; + widget.weak_bg_fill = fill; + widget.corner_radius = t.cr(); + widget.fg_stroke = Stroke::new(1.0, t.text); + } // Hovered and pressed lettering, and `RichText::strong` (captions), in the strong colour w.hovered.fg_stroke.color = t.text_strong; diff --git a/crates/ui-egui/src/titlebar.rs b/crates/ui-egui/src/titlebar.rs index 857c7f10..27b36d11 100644 --- a/crates/ui-egui/src/titlebar.rs +++ b/crates/ui-egui/src/titlebar.rs @@ -1,8 +1,9 @@ //! The strip at the top of the window: the app icon at the very left, the menus and the mode label, -//! and the window's title bar unless the system draws one. As the title bar its empty space moves -//! the window and follows the system's double-click setting (craft-window's `title_bar`), and on a -//! window without an OS frame it also has the minimize, maximize/restore and close buttons and -//! invisible resize zones along the window's edges. +//! and the window's title bar unless the system draws one. As the title bar it is craft-ui's +//! `shell::TitleBar`: its free area moves the window and follows the system's double-click +//! setting, and on a window without an OS frame it has the caption buttons of the desktop's +//! layout; the window keeps invisible resize zones along its edges where the runtime does not +//! answer the window's hit test itself (everywhere but Windows). //! //! Who draws the frame is decided once at startup ([`TitleBar::decide`]): Windows draws no OS //! frame, macOS keeps its traffic lights over the strip (a full-size content view with a hidden @@ -11,12 +12,14 @@ //! overrides that, and Settings › Interface › System title bar brings the OS frame back on the //! next start. The web build has no window frame: the strip is the menu bar. -use craft_window::{Button, Frame, Layout}; +use craft_ui::contract::ShowContainer as _; +use craft_ui::runtime::windows::WindowHost; +use craft_window::policy::{Decision, TitleBarPref}; +use craft_window::{Frame, Layout}; use egui::emath::GuiRounding as _; -use egui::{Align, Color32, CursorIcon, Id, LayerId, Order, PointerButton, Rect, ResizeDirection, Sense, Stroke, Ui, ViewportCommand, pos2, vec2}; +use egui::{Color32, CursorIcon, Id, LayerId, Order, PointerButton, Rect, ResizeDirection, Sense, Ui, ViewportCommand, pos2, vec2}; use crate::TextureCraftApp; -use crate::i18n::tr; use crate::theme::Tokens; /// Who draws the window's title bar. @@ -31,13 +34,9 @@ pub enum TitleBar { App(Layout), } -/// One caption button: as wide as Windows' own. -pub const BUTTON_WIDTH: f32 = 46.0; -/// The room at the strip's left for the macOS traffic lights (their width and the gaps around them). -const TRAFFIC_LIGHTS: f32 = 78.0; /// The app icon's side, in points. const ICON: f32 = 16.0; -/// The space between the strip's edges (or its caption buttons) and its content. +/// The space between the icon and the menus. const PAD: f32 = 8.0; /// Resize zone thickness along an edge, and the side of a corner zone. const EDGE: f32 = 5.0; @@ -53,12 +52,28 @@ const ICONS: [(f32, &[u8]); 5] = [ (64.0, include_bytes!("../../../assets/app-icon/hicolor/64x64/apps/ai.storyteller.texturecraft.png")), ]; +/// The override variable's prefix: `TEXTURECRAFT_TITLEBAR`. +const PREFIX: craft_window::Prefix = craft_window::Prefix::new("TEXTURECRAFT"); + impl TitleBar { - /// Decide who draws the title bar; call once at startup, before the window is created. + /// Decide who draws the title bar; call once at startup, before the window is created, and + /// hand the decision to the window ([`viewport`]) and the runtime (`framework::install`). /// `system` is Settings › Interface › System title bar. - pub fn decide(system: bool) -> TitleBar { - let choice = craft_window::Choice::probe(craft_window::Prefix::new("TEXTURECRAFT")); - Self::from_choice(choice.frame(), choice.overridden(), system) + pub fn decide(system: bool) -> Decision { + let choice = craft_window::Choice::probe(PREFIX); + let wanted = Self::from_choice(choice.frame(), choice.overridden(), system); + let pref = if wanted == TitleBar::System { TitleBarPref::System } else { TitleBarPref::Integrated }; + craft_window::policy::decide_for(PREFIX, craft_host::target::Backend::from_env(), pref) + } + + /// The bar a decided `frame` gives. + pub fn of(frame: &craft_window::policy::Frame) -> TitleBar { + use craft_window::policy::Frame as Decided; + match frame { + Decided::Native => TitleBar::System, + Decided::Inset(_) => TitleBar::Integrated, + Decided::Integrated(captions) => TitleBar::App(captions.layout.clone()), + } } /// `TEXTURECRAFT_TITLEBAR` (`overridden`) wins, then the System title bar setting. Otherwise @@ -77,17 +92,6 @@ impl TitleBar { } } - /// `builder` with this frame: decorations off for the app's own, and on macOS the content - /// under a transparent title bar without its title. - pub fn viewport(&self, builder: egui::ViewportBuilder) -> egui::ViewportBuilder { - let frame = match self { - TitleBar::App(layout) => Frame::App(layout.clone()), - _ => Frame::Desktop, - }; - let builder = craft_window::decorate(builder, &frame); - if *self == TitleBar::Integrated { builder.with_fullsize_content_view(true).with_titlebar_shown(false).with_title_shown(false) } else { builder } - } - /// The name `ui.inspect` reports: `app`, `integrated` or `system`. pub fn name(&self) -> &'static str { match self { @@ -98,38 +102,48 @@ impl TitleBar { } } +/// `builder` with the decided frame: decorations off for the app's own, and on macOS the content +/// under a transparent title bar without its title. +pub fn viewport(decision: &Decision, builder: egui::ViewportBuilder) -> egui::ViewportBuilder { + craft_window::policy::apply(builder, &decision.frame) +} + /// The strip's height: the body text with room around it, 28 to 32 points (so the macOS traffic /// lights and Windows-sized caption buttons fit it). pub fn height(ui: &Ui) -> f32 { (ui.text_style_height(&egui::TextStyle::Body) + 14.0).clamp(28.0, 32.0) } -/// The strip: menus between the app icon and the mode label, the window buttons at the ends the -/// layout names, and as the title bar its empty space moving the window. +/// The strip: the app icon, then the menus. Where the system draws the frame it is the menu bar; +/// otherwise it is the window's title bar (craft-ui's), with the caption buttons where the frame +/// has them and resize zones along the window's edges. pub fn show(app: &mut TextureCraftApp, ui: &mut Ui) { let tk = Tokens::get(ui.ctx()); - let bar = app.title_bar.clone(); - let (left, right) = match &bar { - TitleBar::App(layout) => (layout.left.as_slice(), layout.right.as_slice()), - _ => (&[][..], &[][..]), - }; - egui::Panel::top("menu_bar").exact_size(height(ui)).show_separator_line(false).frame(egui::Frame::NONE.fill(tk.chrome)).show(ui, |ui| { - let rect = ui.max_rect(); - // First, so the strip's controls drawn over it keep their own clicks. - if bar != TitleBar::System { - craft_window::title_bar::empty_area(ui, rect); - } - let ends = |n: usize| n as f32 * BUTTON_WIDTH; - let inset = if bar == TitleBar::Integrated { TRAFFIC_LIGHTS } else { ends(left.len()) + PAD }; - let content = Rect::from_min_max(pos2(rect.left() + inset, rect.top()), pos2(rect.right() - ends(right.len()) - PAD, rect.bottom())); - ui.scope_builder(egui::UiBuilder::new().max_rect(content).layout(egui::Layout::left_to_right(Align::Center)), |ui| { - paint_icon(ui); - crate::menus::menu_bar(app, ui); + let frame = WindowHost::of(ui.ctx()).frame(); + if matches!(frame, craft_window::policy::Frame::Native) { + egui::Panel::top("menu_bar").exact_size(height(ui)).show_separator_line(false).frame(egui::Frame::NONE.fill(tk.chrome)).show(ui, |ui| { + let rect = ui.max_rect(); + let content = Rect::from_min_max(pos2(rect.left() + PAD, rect.top()), pos2(rect.right() - PAD, rect.bottom())); + ui.scope_builder(egui::UiBuilder::new().max_rect(content).layout(egui::Layout::left_to_right(egui::Align::Center)), |ui| { + paint_icon(ui); + crate::menus::menu_bar(app, ui); + }); }); - caption_buttons(ui, left, rect.left(), rect); - caption_buttons(ui, right, rect.right() - ends(right.len()), rect); + return; + } + egui::Panel::top("menu_bar").show_separator_line(false).frame(egui::Frame::NONE.fill(tk.chrome)).show(ui, |ui| { + let bar = craft_ui::shell::TitleBar::new() + .show(ui, |ui, _| { + paint_icon(ui); + crate::menus::menu_bar(app, ui); + }) + .output; + if bar.close_requested { + ui.ctx().send_viewport_cmd(ViewportCommand::Close); + } }); - if matches!(bar, TitleBar::App(_)) { + // Windows' frame answers the resize edges itself (the runtime's hit test). + if matches!(frame, craft_window::policy::Frame::Integrated(_)) && !cfg!(windows) { resize_zones(ui); } } @@ -166,92 +180,6 @@ fn maximized(ctx: &egui::Context) -> bool { ctx.input(|i| i.viewport().maximized.unwrap_or(false)) } -/// Caption button ids (stable, so tests and agents can find them). -fn caption_id(b: Button) -> Id { - Id::unique(("titlebar_caption", b as u8)) -} - -/// `buttons` from `x` rightwards, the strip's full height, flush with its top so a maximized -/// window's corner hits the outermost one. -fn caption_buttons(ui: &mut Ui, buttons: &[Button], x: f32, bar: Rect) { - let tk = Tokens::get(ui.ctx()); - let max = maximized(ui.ctx()); - let focused = ui.input(|i| i.viewport().focused.unwrap_or(true)); - for (i, &b) in buttons.iter().enumerate() { - let r = Rect::from_min_size(pos2(x + i as f32 * BUTTON_WIDTH, bar.top()), vec2(BUTTON_WIDTH, bar.height())); - let resp = ui.interact(r, caption_id(b), Sense::click()); - let tip = match b { - Button::Minimize => tr("Minimize"), - Button::Maximize if max => tr("Restore"), - Button::Maximize => tr("Maximize"), - Button::Close => tr("Close"), - }; - resp.widget_info(|| egui::WidgetInfo::labeled(egui::Role::Button, true, tip)); - let close = b == Button::Close; - let fill = match (resp.is_pointer_button_down_on(), resp.hovered()) { - (true, _) if close => tk.danger.gamma_multiply(0.8), - (_, true) if close => tk.danger, - (true, _) => tk.button, - (_, true) => tk.row_hover, - _ => Color32::TRANSPARENT, - }; - ui.painter().rect_filled(r, 0.0, fill); - // White on the red, as every system's close button; dimmed while the window is inactive. - let ink = if close && resp.hovered() { - Color32::WHITE - } else if focused { - tk.text - } else { - tk.text_dim - }; - paint_glyph(ui, b, max, r.center(), ink); - if resp.on_hover_text(tip).clicked() { - ui.ctx().send_viewport_cmd(match b { - Button::Minimize => ViewportCommand::Minimized(true), - Button::Maximize => ViewportCommand::Maximized(!max), - // The same request as the system's close button. - Button::Close => ViewportCommand::Close, - }); - } - } -} - -/// The 10-point line glyphs, one physical pixel wide per whole step of the screen's scale and on -/// pixel centres, so they stay crisp at any scale. -fn paint_glyph(ui: &Ui, b: Button, maximized: bool, at: egui::Pos2, ink: Color32) { - let ppp = ui.ctx().pixels_per_point(); - let px = ppp.round().max(1.0); - let stroke = Stroke::new(px / ppp, ink); - // An odd width centres the line in a pixel, an even one on a pixel edge. - let snap = |v: f32| if px as u32 % 2 == 1 { v.round_to_pixel_center(ppp) } else { v.round_to_pixels(ppp) }; - let g = Rect::from_min_max(pos2(snap(at.x - 5.0), snap(at.y - 5.0)), pos2(snap(at.x + 5.0), snap(at.y + 5.0))); - let p = ui.painter(); - match b { - Button::Minimize => { - p.line_segment([g.left_center(), g.right_center()].map(|q| pos2(q.x, snap(q.y))), stroke); - } - // Restore: a front square with the corner of the one behind it. - Button::Maximize if maximized => { - let front = Rect::from_min_max(pos2(g.left(), snap(g.top() + 2.0)), pos2(snap(g.right() - 2.0), g.bottom())); - p.rect_stroke(front, 0.0, stroke, egui::StrokeKind::Middle); - let (l, t) = (snap(g.left() + 2.0), front.top()); - p.line( - vec![pos2(l, t), pos2(l, g.top()), g.right_top(), pos2(g.right(), snap(g.bottom() - 2.0)), pos2(front.right(), snap(g.bottom() - 2.0))], - stroke, - ); - } - Button::Maximize => { - p.rect_stroke(g, 0.0, stroke, egui::StrokeKind::Middle); - } - Button::Close => { - p.line_segment([g.left_top(), g.right_bottom()], stroke); - p.line_segment([g.right_top(), g.left_bottom()], stroke); - } - } -} - -/// The edge and corner zones of a window with content rect `w`: (zone, direction, cursor). Corners -/// come last so they win where they overlap the edges. fn zones(w: Rect) -> [(Rect, ResizeDirection, CursorIcon); 8] { use ResizeDirection::*; let (e, c) = (EDGE, CORNER); @@ -292,17 +220,6 @@ fn resize_zones(ui: &mut Ui) { /// Once per frame after the UI, on macOS with the integrated strip: the traffic lights centred on /// the strip, inset from its left as far as from its top, and AppKit's `movable` flag following /// what is under the pointer (`movable` keeps the value last set). -#[cfg(target_os = "macos")] -pub fn sync_native(bar: &TitleBar, ui: &Ui, frame: &eframe::Frame, movable: &mut Option) { - if *bar != TitleBar::Integrated { - return; - } - let h = height(ui); - // AppKit's buttons are 14 points tall. - frame.set_traffic_lights_position(ui.ctx(), egui::Rangef::new(0.0, h), (h - 14.0) / 2.0); - craft_window::title_bar::sync_movable(ui.ctx(), movable); -} - #[cfg(test)] mod tests { use super::*; @@ -331,16 +248,6 @@ mod tests { assert_eq!(desktop, expected); } - #[test] - fn only_the_app_frame_turns_decorations_off() { - let b = TitleBar::App(Layout::default()).viewport(egui::ViewportBuilder::default()); - assert_eq!(b.decorations, Some(false)); - let b = TitleBar::Integrated.viewport(egui::ViewportBuilder::default()); - assert_eq!((b.decorations, b.fullsize_content_view, b.title_shown), (Some(true), Some(true), Some(false))); - let b = TitleBar::System.viewport(egui::ViewportBuilder::default()); - assert_eq!((b.decorations, b.fullsize_content_view), (Some(true), None)); - } - #[test] fn resize_corners_win_over_edges() { let w = Rect::from_min_size(pos2(0.0, 0.0), vec2(1000.0, 600.0)); diff --git a/crates/ui-egui/src/ui_state_store.rs b/crates/ui-egui/src/ui_state_store.rs index d0fb3892..b4483b88 100644 --- a/crates/ui-egui/src/ui_state_store.rs +++ b/crates/ui-egui/src/ui_state_store.rs @@ -321,10 +321,10 @@ pub(crate) mod tests { fn moved_panels() -> Dock { let mut workspace = default_workspace(); let actions = [ - Action::Move { panel: Panel::Layers, anchor: Panel::Assets, placement: DockPlacement::Tab { before: None } }, - Action::Float { panel: Panel::Properties, rect: [900.0, 120.0, 320.0, 400.0] }, + Action::move_beside(Panel::Layers, Panel::Assets, DockPlacement::tab(None)), + Action::float(Panel::Properties, egui::Rect::from_min_size(egui::pos2(900.0, 120.0), egui::vec2(320.0, 400.0))), ]; - workspace.apply_all(actions, permissions).unwrap(); + workspace.apply_all(actions, false, permissions).unwrap(); let dock = Dock::from_value(serde_json::to_value(&workspace).unwrap()); assert!(!dock.replaced_unreadable(), "the moved layout is valid"); diff --git a/crates/ui-egui/src/updates_ui.rs b/crates/ui-egui/src/updates_ui.rs index 26e6d85a..db37adf8 100644 --- a/crates/ui-egui/src/updates_ui.rs +++ b/crates/ui-egui/src/updates_ui.rs @@ -1,8 +1,10 @@ //! Software updates on the desktop: the check at start, Help > Check for Updates and the update -//! prompt. An update that is ready starts its install helper when the app is dropped at exit. +//! prompt, as craft-update's dialogs on the app's [`DialogHost`](craft_ui::dialog::DialogHost). An +//! update that is ready starts its install helper when the app is dropped at exit. +use craft_ui::dialog::DialogResult; +use craft_update::stack_dialogs::{CheckChoice, UpdateCheckDialog}; use craft_update::updater::{Action, Status, Updater}; -use craft_update::{CheckResultDialog, CheckResultResponse}; use crate::TextureCraftApp; @@ -47,9 +49,9 @@ fn holds_keyboard(status: &Status, prompt_open: bool) -> bool { pub(crate) fn tick(app: &mut TextureCraftApp, ctx: &egui::Context) { let rt = &mut app.updates_rt; if std::mem::take(&mut rt.check_requested) { - rt.updater.check_now(ctx); + rt.updater.check_now(); } else if rt.startup_check { - rt.updater.check_at_start(ctx); + rt.updater.check_at_start(); } rt.updater.tick(ctx); } @@ -67,21 +69,42 @@ fn safe_to_close(app: &TextureCraftApp) -> bool { !app.session.modified && !app.session.stroke_active() && app.bake.is_none() && app.resize.is_none() } +/// One pass of the update flow, before the dialog host runs: answers the result dialog closed in +/// the last pass, drives the update prompt, and keeps the result dialog open and current while the +/// updater has something to report. pub(crate) fn show(app: &mut TextureCraftApp, ctx: &egui::Context) { let safe = safe_to_close(app); - match app.updates_rt.updater.show_if(ctx, safe) { + // Answered before the dialog is kept open below, so a dismissed outcome does not open again at once + match app.framework_dialogs.take::() { + Some(DialogResult::Ok(CheckChoice::CheckNow | CheckChoice::CheckAgain)) => app.updates_rt.check_requested = true, + // The next `run` asks the window to close once it is safe to + Some(DialogResult::Ok(CheckChoice::RestartToUpdate)) => app.updates_rt.updater.restart_to_update(), + Some(DialogResult::Ok(CheckChoice::Update)) => { + app.updates_rt.updater.request_install(safe); + } + Some(DialogResult::Ok(CheckChoice::Download)) => ctx.open_url(egui::OpenUrl::new_tab(crate::UPDATE_APP.releases_url())), + // Closing the dialog dismisses the outcome it showed + Some(_) => app.updates_rt.updater.dismiss_status(), + None => {} + } + match app.updates_rt.updater.run(&mut app.framework_dialogs, safe) { Action::OpenUrl(url) => ctx.open_url(egui::OpenUrl::new_tab(url)), Action::Close => ctx.send_viewport_cmd(egui::ViewportCommand::Close), - Action::None => {} + _ => {} } - let rt = &mut app.updates_rt; - if result_window_shows(rt.updater.status(), rt.updater.prompt_open()) { - match CheckResultDialog::new(&crate::UPDATE_APP, env!("CARGO_PKG_VERSION")).show(ctx, rt.updater.status()) { - CheckResultResponse::None => {} - CheckResultResponse::Close => rt.updater.dismiss_status(), - CheckResultResponse::CheckAgain => rt.check_requested = true, - CheckResultResponse::RestartToUpdate => rt.updater.restart_to_update(), - } + let updater = &app.updates_rt.updater; + let shows = result_window_shows(updater.status(), updater.prompt_open()); + let (status, installing, message) = (updater.status().clone(), updater.is_installing(), updater.status_message()); + let dialogs = &mut app.framework_dialogs; + if shows && !dialogs.is_open::() { + dialogs.open(UpdateCheckDialog::new(env!("CARGO_PKG_VERSION"))); + } else if !shows && dialogs.is_open::() { + dialogs.cancel::(ctx); + } + if let Some(dialog) = dialogs.get_mut::() { + dialog.set_status(status); + dialog.set_installing(installing); + dialog.set_message(message); } } @@ -123,7 +146,7 @@ mod tests { let root = std::env::temp_dir().join(format!("texturecraft-updates-{}-{test}", std::process::id())); let mut session = texturecraft_engine::sample_session(256, 64).unwrap(); session.modified = modified; - let mut h = Harness::builder().with_size(egui::vec2(1600.0, 960.0)).build_eframe(|cc| TextureCraftApp::new(cc, session)); + let mut h = Harness::builder().with_size(egui::vec2(1600.0, 960.0)).with_context_setup(crate::framework::install_headless).build_eframe(|cc| TextureCraftApp::new(cc, session)); h.state_mut().updates_rt.updater = Updater::new(&crate::UPDATE_APP, "0.0.1").with_source(ask).with_paths(Paths::under(&root)).with_pins_path(root.join("pins.json")); h.run_steps(2); @@ -177,7 +200,7 @@ mod tests { let mut h = harness(false, "prompt", ask); offer(&mut h); assert!(h.state().updates_rt.updater.prompt_open()); - h.get_by_label("LATER").click(); + h.get_by_label("Later").click(); h.run_steps(2); assert!(!h.state().updates_rt.updater.prompt_open()); } @@ -193,7 +216,7 @@ mod tests { h.key_press(egui::Key::F8); h.step(); assert_eq!(h.state().ui.mode, Mode::Painting, "the prompt holds the keyboard"); - h.get_by_label("LATER").click(); + h.get_by_label("Later").click(); h.run_steps(2); assert!(!crate::docking::input_blocked(h.state(), &h.ctx)); h.key_press(egui::Key::F8); @@ -216,7 +239,7 @@ mod tests { h.key_press(egui::Key::Backspace); h.step(); assert_eq!(points(&h), 2, "the prompt holds the keyboard"); - h.get_by_label("LATER").click(); + h.get_by_label("Later").click(); h.run_steps(2); h.key_press(egui::Key::Backspace); h.step(); diff --git a/crates/ui-egui/src/viewport.rs b/crates/ui-egui/src/viewport.rs index 3c5a3d7e..b6a98b6a 100644 --- a/crates/ui-egui/src/viewport.rs +++ b/crates/ui-egui/src/viewport.rs @@ -2612,7 +2612,7 @@ mod tests { for tool in [Tool::Paint, Tool::PolygonFill] { let session = Session::new_project("t", primitives::plane(2.0, 4), "test", None, 128).unwrap(); - let mut harness = egui_kittest::Harness::builder().build_eframe(|context| TextureCraftApp::new(context, session)); + let mut harness = egui_kittest::Harness::builder().with_context_setup(crate::framework::install_headless).build_eframe(|context| TextureCraftApp::new(context, session)); let app = harness.state_mut(); app.session.tool.tool = tool; let history = app.session.history_labels().len(); @@ -2641,7 +2641,7 @@ mod tests { // The harness draws the UI, so another test's interface language must not be active let _language = crate::i18n::TEST_LANGUAGE.lock().unwrap_or_else(std::sync::PoisonError::into_inner); let session = Session::new_project("t", primitives::plane(2.0, 4), "test", None, 128).unwrap(); - let mut harness = egui_kittest::Harness::builder().build_eframe(|context| TextureCraftApp::new(context, session)); + let mut harness = egui_kittest::Harness::builder().with_context_setup(crate::framework::install_headless).build_eframe(|context| TextureCraftApp::new(context, session)); let app = harness.state_mut(); app.ui.mode = crate::state::Mode::Painting; app.session.view = ViewMode::Mask(LayerId(7)); @@ -2667,7 +2667,7 @@ mod tests { execute(&mut session, "layer.add.fill", &json!(null)).unwrap(); let effect = texturecraft_engine::core::LayerId(execute(&mut session, "mask.add.colorSelection", &json!(null)).unwrap()["effect"].as_u64().unwrap()); session.target = StackTarget::Effect(effect); - let mut harness = egui_kittest::Harness::builder().build_eframe(|context| TextureCraftApp::new(context, session)); + let mut harness = egui_kittest::Harness::builder().with_context_setup(crate::framework::install_headless).build_eframe(|context| TextureCraftApp::new(context, session)); harness.run_steps(2); crate::id_color_pick::IdColorPick::start(harness.state_mut(), effect, None); @@ -2684,7 +2684,7 @@ mod tests { fn a_waiting_eyedropper_keeps_a_2d_view_click_from_painting() { let _language = crate::i18n::TEST_LANGUAGE.lock().unwrap_or_else(std::sync::PoisonError::into_inner); let session = texturecraft_engine::sample_session(256, 64).unwrap(); - let mut harness = egui_kittest::Harness::builder().with_size(egui::vec2(1600.0, 960.0)).build_eframe(|context| TextureCraftApp::new(context, session)); + let mut harness = egui_kittest::Harness::builder().with_size(egui::vec2(1600.0, 960.0)).with_context_setup(crate::framework::install_headless).build_eframe(|context| TextureCraftApp::new(context, session)); harness.state_mut().ui.layout = ViewLayout::Only2D; harness.state_mut().session.tool.tool = Tool::PolygonFill; harness.run_steps(4); @@ -2730,7 +2730,7 @@ mod tests { let effect = texturecraft_engine::core::LayerId(result["committed"]["effect"].as_u64().unwrap()); let EffectKind::Path(paths) = &mut session.doc.project.effect_mut(effect).unwrap().kind else { panic!("path effect") }; paths.resize(8, paths[0].clone()); - let mut harness = egui_kittest::Harness::builder().build_eframe(|context| TextureCraftApp::new(context, session)); + let mut harness = egui_kittest::Harness::builder().with_context_setup(crate::framework::install_headless).build_eframe(|context| TextureCraftApp::new(context, session)); let context = egui::Context::default(); let mut previous = Vec::>>>>::new(); @@ -2779,7 +2779,7 @@ mod tests { Session::new_project("Decal selection", texturecraft_engine::geom::primitives::material_ball(), "builtin:material_ball", None, 256).unwrap(); let builder = egui_kittest::Harness::builder().with_size(vec2(1600.0, 960.0)); let builder = if render { builder.wgpu() } else { builder }; - let mut harness = builder.build_eframe(|context| TextureCraftApp::new(context, session)); + let mut harness = builder.with_context_setup(crate::framework::install_headless).build_eframe(|context| TextureCraftApp::new(context, session)); harness.run_steps(4); let mut png = Vec::new(); image::RgbaImage::from_pixel(4, 4, image::Rgba([255, 255, 255, 255])).write_to(&mut std::io::Cursor::new(&mut png), image::ImageFormat::Png).unwrap(); @@ -2929,7 +2929,7 @@ mod tests { // Hold the language lock while drawing the harness let _language = crate::i18n::TEST_LANGUAGE.lock().unwrap_or_else(std::sync::PoisonError::into_inner); let session = texturecraft_engine::sample_session(256, 64).unwrap(); - let mut harness = egui_kittest::Harness::builder().build_eframe(|context| TextureCraftApp::new(context, session)); + let mut harness = egui_kittest::Harness::builder().with_context_setup(crate::framework::install_headless).build_eframe(|context| TextureCraftApp::new(context, session)); let app = harness.state_mut(); app.ui.mode = crate::state::Mode::Baking; let before = bake_visualization(app).unwrap(); diff --git a/crates/ui-egui/src/web_files.rs b/crates/ui-egui/src/web_files.rs index 3991e3c8..ae910688 100644 --- a/crates/ui-egui/src/web_files.rs +++ b/crates/ui-egui/src/web_files.rs @@ -435,7 +435,7 @@ mod tests { #[test] fn mesh_picks_only_update_the_current_new_project_request() { let session = Session::closed().unwrap(); - let mut harness = Harness::builder().build_eframe(|context| TextureCraftApp::new(context, session)); + let mut harness = Harness::builder().with_context_setup(crate::framework::install_headless).build_eframe(|context| TextureCraftApp::new(context, session)); let app = harness.state_mut(); crate::new_project_advanced::open(app); app.ui.new_project.mesh_request_id = 2; @@ -457,7 +457,7 @@ mod tests { #[test] fn environment_pick_after_close_does_not_edit_the_placeholder() { let session = texturecraft_engine::sample_session(128, 32).unwrap(); - let mut harness = Harness::builder().build_eframe(|context| TextureCraftApp::new(context, session)); + let mut harness = Harness::builder().with_context_setup(crate::framework::install_headless).build_eframe(|context| TextureCraftApp::new(context, session)); let png = texturecraft_engine::formats::gray16_png(1, 1, [0.5].into_iter()).unwrap(); let old_project_id = harness.state().session.project_id; @@ -479,7 +479,7 @@ mod tests { #[test] fn environment_pick_from_replaced_project_does_not_edit_the_new_project() { let session = texturecraft_engine::sample_session(128, 32).unwrap(); - let mut harness = Harness::builder().build_eframe(|context| TextureCraftApp::new(context, session)); + let mut harness = Harness::builder().with_context_setup(crate::framework::install_headless).build_eframe(|context| TextureCraftApp::new(context, session)); let png = texturecraft_engine::formats::gray16_png(1, 1, [0.5].into_iter()).unwrap(); let old_project_id = harness.state().session.project_id; @@ -497,7 +497,7 @@ mod tests { #[test] fn bake_mesh_picks_after_close_do_not_edit_the_placeholder() { let session = texturecraft_engine::sample_session(128, 32).unwrap(); - let mut harness = Harness::builder().build_eframe(|context| TextureCraftApp::new(context, session)); + let mut harness = Harness::builder().with_context_setup(crate::framework::install_headless).build_eframe(|context| TextureCraftApp::new(context, session)); let old_project_id = harness.state().session.project_id; assert!(harness.state_mut().run("file.close", serde_json::Value::Null).is_some()); let cage = harness.state().session.mesh_obj_bytes().unwrap(); diff --git a/crates/ui-egui/src/widgets.rs b/crates/ui-egui/src/widgets.rs index 126f7be5..991585dc 100644 --- a/crates/ui-egui/src/widgets.rs +++ b/crates/ui-egui/src/widgets.rs @@ -1,8 +1,7 @@ //! Compact widgets matching the app's look: labelled slim sliders, icon buttons, section //! headers, channel toggle chips and color swatches. -use craft_ui::buttons::{ButtonVisuals, IconButton, IconButtonStyle}; -use egui::{Color32, CornerRadius, Response, RichText, Sense, Stroke, Ui, vec2}; +use egui::{Color32, CornerRadius, Rect, Response, RichText, Sense, Stroke, StrokeKind, Ui, Vec2, vec2}; use crate::drawn_icon::DrawnIcon; use crate::i18n::tr; @@ -279,6 +278,98 @@ pub fn icon_badge_dropdown_button(ui: &mut Ui, icon: &str, badge: &str, label: & }) } +/// The background, border and icon colour of an icon button in one interaction state. +#[derive(Clone, Copy, Debug, PartialEq)] +struct ButtonVisuals { + fill: Color32, + stroke: Stroke, + icon: Color32, +} + +/// The look of an icon button in each state. Selection takes precedence over press and hover. +#[derive(Clone, Copy, Debug)] +struct IconButtonStyle { + normal: ButtonVisuals, + hovered: ButtonVisuals, + /// `None` keeps the hover or normal look while pressed. + pressed: Option, + selected: ButtonVisuals, + corner_radius: CornerRadius, + /// An inset outline while the button has keyboard focus. + focus_stroke: Stroke, +} + +impl IconButtonStyle { + fn visuals(&self, selected: bool, hovered: bool, pressed: bool) -> ButtonVisuals { + if selected { + self.selected + } else if let Some(visuals) = self.pressed.filter(|_| pressed) { + visuals + } else if hovered { + self.hovered + } else { + self.normal + } + } +} + +/// An icon-only button painted in TextureCraft's own colours. The label is its accessible name; the caller paints +/// the icon, attaches a tooltip and acts on the response. Selection is the caller's. +struct IconButton<'a> { + label: &'a str, + size: Vec2, + selected: bool, + style: &'a IconButtonStyle, +} + +impl<'a> IconButton<'a> { + fn new(label: &'a str, size: Vec2, style: &'a IconButtonStyle) -> Self { + Self { label, size, selected: false, style } + } + + fn selected(mut self, selected: bool) -> Self { + self.selected = selected; + self + } + + /// Paints the button and returns its response. `paint_icon` gets the button's rect and the icon tint. A + /// non-finite, non-positive or oversized (over 4096 points) size gives an inert zero-size response. + fn show(self, ui: &mut Ui, paint_icon: impl FnOnce(&Ui, Rect, Color32)) -> Response { + let valid = self.size.is_finite() && self.size.x > 0.0 && self.size.y > 0.0 && self.size.x <= 4096.0 && self.size.y <= 4096.0; + let (rect, response) = ui.allocate_exact_size(if valid { self.size } else { Vec2::ZERO }, if valid { Sense::click() } else { Sense::hover() }); + response.widget_info(|| egui::WidgetInfo::selected(egui::Role::Button, valid && ui.is_enabled(), self.selected, self.label)); + if !valid { + return response; + } + let visuals = self.style.visuals(self.selected, response.hovered(), response.is_pointer_button_down_on()); + let stroke = bounded_stroke(visuals.stroke, rect); + if visuals.fill != Color32::TRANSPARENT { + ui.painter().rect_filled(rect, self.style.corner_radius, visuals.fill); + } + if !stroke.is_empty() { + ui.painter().rect_stroke(rect, self.style.corner_radius, stroke, StrokeKind::Inside); + } + paint_icon(ui, rect, visuals.icon); + if response.has_focus() && rect.width() > 4.0 && rect.height() > 4.0 { + let focus_rect = rect.shrink(2.0); + let stroke = bounded_stroke(self.style.focus_stroke, focus_rect); + if !stroke.is_empty() { + ui.painter().rect_stroke(focus_rect, self.style.corner_radius, stroke, StrokeKind::Inside); + } + } + response + } +} + +/// `stroke` no wider than half of `rect`'s smaller side; none when its width is not positive. +fn bounded_stroke(stroke: Stroke, rect: Rect) -> Stroke { + if stroke.width.is_finite() && stroke.width > 0.0 { + Stroke::new(stroke.width.min(rect.width().min(rect.height()) * 0.5), stroke.color) + } else { + Stroke::NONE + } +} + /// Transparent at rest, a hover well, and the active-tool well when pressed or selected fn icon_button_style(tokens: &Tokens) -> IconButtonStyle { let well = |fill, icon| ButtonVisuals { fill, stroke: Stroke::NONE, icon }; diff --git a/crates/ui-egui/src/windows.rs b/crates/ui-egui/src/windows.rs index f9e8fa5c..abe3efea 100644 --- a/crates/ui-egui/src/windows.rs +++ b/crates/ui-egui/src/windows.rs @@ -82,26 +82,18 @@ pub(crate) fn ask_to_save(app: &mut TextureCraftApp, then: crate::state::Unsaved app.session.modified } -/// The close decision, once per frame in `logic` (which also runs while the window is minimized): -/// a close with unsaved changes waits on the dialog, in a window brought back so it can be -/// answered. A close nothing holds open quits through the platform's own path (craft-quit). -pub(crate) fn close_request(app: &mut TextureCraftApp, ctx: &egui::Context) { - let closing = ctx.input(|i| i.viewport().close_requested()); +/// The close decision, which the runtime asks for when the root window was asked to close (it runs in `logic`, +/// also while the window is minimized): a close with unsaved changes waits on the dialog (`true`), and the runtime +/// brings the window back so it can be answered. A close nothing holds open goes ahead through the platform's own +/// quit. +pub(crate) fn close_requested(app: &mut TextureCraftApp) -> bool { // A stroke still open at the close, or released in this frame, is a change to ask about. - if closing - && app.session.stroke_active() + if app.session.stroke_active() && let Err(error) = app.session.end_stroke() { app.toast(error.to_string(), true); } - if closing && ask_to_save(app, crate::state::Unsaved::Quit) { - ctx.send_viewport_cmd(egui::ViewportCommand::CancelClose); - if ctx.input(|i| i.viewport().minimized == Some(true)) { - ctx.send_viewport_cmd(egui::ViewportCommand::Minimized(false)); - ctx.send_viewport_cmd(egui::ViewportCommand::Focus); - } - } - craft_quit::on_close_request(ctx); + ask_to_save(app, crate::state::Unsaved::Quit) } /// Quitting, opening or closing a project with unsaved changes asks whether to save them first @@ -711,7 +703,7 @@ mod tests { fn harness() -> Harness<'static, TextureCraftApp> { let session = texturecraft_engine::sample_session(256, 64).unwrap(); - let mut h = Harness::builder().with_size(vec2(1600.0, 960.0)).build_eframe(|cc| TextureCraftApp::new(cc, session)); + let mut h = Harness::builder().with_size(vec2(1600.0, 960.0)).with_context_setup(crate::framework::install_headless).build_eframe(|cc| TextureCraftApp::new(cc, session)); // Match English labels independently of the system locale h.state_mut().ui.prefs.language = "en".into(); diff --git a/crates/ui-egui/tests/bake_preview.rs b/crates/ui-egui/tests/bake_preview.rs index 1703abde..42728170 100644 --- a/crates/ui-egui/tests/bake_preview.rs +++ b/crates/ui-egui/tests/bake_preview.rs @@ -19,7 +19,7 @@ fn harness() -> Harness<'static, TextureCraftApp> { } session.view = ViewMode::UvChecker; - let mut harness = Harness::builder().with_size(egui::vec2(1400.0, 900.0)).build_eframe(|context| TextureCraftApp::new(context, session)); + let mut harness = Harness::builder().with_size(egui::vec2(1400.0, 900.0)).with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|context| TextureCraftApp::new(context, session)); harness.state_mut().ui.mode = Mode::Baking; harness.run_steps(3); harness diff --git a/crates/ui-egui/tests/brush_cursor_2d.rs b/crates/ui-egui/tests/brush_cursor_2d.rs index c99708ab..71768d14 100644 --- a/crates/ui-egui/tests/brush_cursor_2d.rs +++ b/crates/ui-egui/tests/brush_cursor_2d.rs @@ -9,7 +9,7 @@ use texturecraft_ui_egui::state::{Mode, ViewLayout}; fn harness() -> Harness<'static, TextureCraftApp> { let session = texturecraft_engine::sample_session(256, 64).unwrap(); - let mut harness = Harness::builder().with_size(egui::vec2(1600.0, 960.0)).build_eframe(|context| TextureCraftApp::new(context, session)); + let mut harness = Harness::builder().with_size(egui::vec2(1600.0, 960.0)).with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|context| TextureCraftApp::new(context, session)); harness.state_mut().ui.layout = ViewLayout::Only2D; harness.run_steps(4); harness diff --git a/crates/ui-egui/tests/display_panel.rs b/crates/ui-egui/tests/display_panel.rs index 9c72f884..8b784576 100644 --- a/crates/ui-egui/tests/display_panel.rs +++ b/crates/ui-egui/tests/display_panel.rs @@ -18,7 +18,7 @@ const STARTUP_FRAMES: usize = 4; #[test] fn display_picks_the_tone_mapping_from_a_dropdown() { let session = texturecraft_engine::sample_session(TEXTURE_RESOLUTION, BAKE_RESOLUTION).unwrap(); - let mut harness = Harness::builder().with_size(WINDOW_SIZE).build_eframe(|cc| TextureCraftApp::new(cc, session)); + let mut harness = Harness::builder().with_size(WINDOW_SIZE).with_context_setup(texturecraft_ui_egui::framework::install_headless).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.state_mut().ui.dock.focus(Panel::Display); diff --git a/crates/ui-egui/tests/it/alpha_parameters.rs b/crates/ui-egui/tests/it/alpha_parameters.rs index 09e48082..38935440 100644 --- a/crates/ui-egui/tests/it/alpha_parameters.rs +++ b/crates/ui-egui/tests/it/alpha_parameters.rs @@ -17,7 +17,7 @@ fn changed_params() -> AlphaParams { /// The app showing the Alpha tab of Properties, with `brush` fn app_with_brush(brush: BrushSettings) -> Harness<'static, TextureCraftApp> { let session = texturecraft_engine::sample_session(256, 64).unwrap(); - let mut harness = Harness::builder().with_size(WINDOW_SIZE).build_eframe(|cc| TextureCraftApp::new(cc, session)); + let mut harness = Harness::builder().with_size(WINDOW_SIZE).with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|cc| TextureCraftApp::new(cc, session)); harness.state_mut().ui.prefs.language = "en".into(); harness.state_mut().session.tool.brush = brush; harness.state_mut().ui.props_tab = PropsTab::Alpha; diff --git a/crates/ui-egui/tests/it/anchor_point.rs b/crates/ui-egui/tests/it/anchor_point.rs index f161b534..60d149ba 100644 --- a/crates/ui-egui/tests/it/anchor_point.rs +++ b/crates/ui-egui/tests/it/anchor_point.rs @@ -23,7 +23,7 @@ fn anchor_harness() -> (Harness<'static, TextureCraftApp>, LayerId, LayerId, Lay execute(&mut session, "mask.add.black", &json!({"layer": top})).unwrap(); let reader = LayerId(execute(&mut session, "effect.add.fill", &json!({"layer": top, "anchor": anchor.0})).unwrap()["effect"].as_u64().unwrap()); execute(&mut session, "layer.select", &json!({"layer": low, "target": anchor.0})).unwrap(); - let mut harness = Harness::builder().with_size(PROPERTIES_WINDOW).with_step_dt(FRAME_SECONDS).build_eframe(|cc| TextureCraftApp::new(cc, session)); + let mut harness = Harness::builder().with_size(PROPERTIES_WINDOW).with_step_dt(FRAME_SECONDS).with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|cc| TextureCraftApp::new(cc, session)); harness.state_mut().ui.prefs.language = "en".into(); harness.run_steps(STARTUP_FRAMES); (harness, anchor, LayerId(top.as_u64().unwrap()), reader) diff --git a/crates/ui-egui/tests/it/bake_job_mesh.rs b/crates/ui-egui/tests/it/bake_job_mesh.rs index 60f6f03e..0f576c8b 100644 --- a/crates/ui-egui/tests/it/bake_job_mesh.rs +++ b/crates/ui-egui/tests/it/bake_job_mesh.rs @@ -11,7 +11,7 @@ use texturecraft_ui_egui::{BakeJob, RunningBake, TextureCraftApp}; /// An app with a running bake job (its worker never answers) started on mesh `mesh_id`. fn harness_with_job(mesh_id: impl FnOnce(u64) -> u64) -> (Harness<'static, TextureCraftApp>, Arc) { let session = texturecraft_engine::sample_session(256, 64).unwrap(); - let mut h = Harness::builder().with_size(egui::vec2(1600.0, 960.0)).build_eframe(|cc| TextureCraftApp::new(cc, session)); + let mut h = Harness::builder().with_size(egui::vec2(1600.0, 960.0)).with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|cc| TextureCraftApp::new(cc, session)); h.run_steps(4); let progress = Arc::new(Progress::new()); let (tx, receiver) = std::sync::mpsc::channel(); diff --git a/crates/ui-egui/tests/it/bake_mode.rs b/crates/ui-egui/tests/it/bake_mode.rs index b2603842..ff7d24ba 100644 --- a/crates/ui-egui/tests/it/bake_mode.rs +++ b/crates/ui-egui/tests/it/bake_mode.rs @@ -12,7 +12,7 @@ fn harness(map: Option) -> Harness<'static, TextureCraftApp> { session.doc.project.texture_sets[0].bake = Default::default(); session.doc.project.texture_sets[0].bake.common.resolution = BakeResolution::R64; session.doc.project.texture_sets[0].bake.maps.select(map); - let mut harness = Harness::builder().with_size(egui::vec2(1600.0, 1500.0)).build_eframe(|context| TextureCraftApp::new(context, session)); + let mut harness = Harness::builder().with_size(egui::vec2(1600.0, 1500.0)).with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|context| TextureCraftApp::new(context, session)); harness.state_mut().ui.mode = Mode::Baking; harness.run_steps(4); harness.state_mut().ui.dock.focus(Panel::MeshMapSettings); @@ -221,7 +221,7 @@ fn tile_resolution_overrides_can_be_changed_and_removed_in_bake_mode() { 256, ) .unwrap(); - let mut harness = Harness::builder().with_size(egui::vec2(1600.0, 1500.0)).build_eframe(|context| TextureCraftApp::new(context, session)); + let mut harness = Harness::builder().with_size(egui::vec2(1600.0, 1500.0)).with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|context| TextureCraftApp::new(context, session)); harness.state_mut().ui.mode = Mode::Baking; harness.run_steps(4); let before = harness.state().session.doc.project.clone(); @@ -272,7 +272,7 @@ fn bake_texture_sets_list_uv_tiles_and_their_resolutions() { .unwrap(); texturecraft_engine::execute(&mut session, "textureSet.tile.resolution", &serde_json::json!({"tile": 1002, "resolution": 128})).unwrap(); let before = session.doc.project.clone(); - let mut harness = Harness::builder().with_size(egui::vec2(1600.0, 1500.0)).build_eframe(|context| TextureCraftApp::new(context, session)); + let mut harness = Harness::builder().with_size(egui::vec2(1600.0, 1500.0)).with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|context| TextureCraftApp::new(context, session)); harness.state_mut().ui.mode = Mode::Baking; harness.run_steps(4); diff --git a/crates/ui-egui/tests/it/bake_presets.rs b/crates/ui-egui/tests/it/bake_presets.rs index 5adef4ea..bcd5ca71 100644 --- a/crates/ui-egui/tests/it/bake_presets.rs +++ b/crates/ui-egui/tests/it/bake_presets.rs @@ -17,7 +17,7 @@ fn harness() -> Harness<'static, TextureCraftApp> { texture_set.bake.maps.select([BakedMap::Id]); } - let mut harness = Harness::builder().with_size(egui::vec2(1600.0, 1000.0)).build_eframe(|context| TextureCraftApp::new(context, session)); + let mut harness = Harness::builder().with_size(egui::vec2(1600.0, 1000.0)).with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|context| TextureCraftApp::new(context, session)); harness.state_mut().ui.mode = Mode::Baking; harness.run_steps(4); harness.state_mut().ui.dock.focus(Panel::MeshMapBakers); @@ -174,7 +174,7 @@ fn a_partial_bake_does_not_count_preserved_unchecked_maps() { set.bake.common.resolution = BakeResolution::R64; set.bake.maps.select([BakedMap::Id]); set.bake_excluded_tiles.insert(1002); - let mut harness = Harness::builder().with_size(egui::vec2(1600.0, 1000.0)).build_eframe(|context| TextureCraftApp::new(context, session)); + let mut harness = Harness::builder().with_size(egui::vec2(1600.0, 1000.0)).with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|context| TextureCraftApp::new(context, session)); harness.state_mut().ui.mode = Mode::Baking; harness.state_mut().start_bake(vec![0]); diff --git a/crates/ui-egui/tests/it/brush_drag.rs b/crates/ui-egui/tests/it/brush_drag.rs index ecc5393f..3a192a53 100644 --- a/crates/ui-egui/tests/it/brush_drag.rs +++ b/crates/ui-egui/tests/it/brush_drag.rs @@ -22,7 +22,7 @@ fn drag(h: &mut Harness<'_, TextureCraftApp>, button: PointerButton, from: Pos2, #[test] fn ctrl_drag_changes_the_brush_instead_of_painting_or_orbiting() { let session = texturecraft_engine::sample_session(256, 64).unwrap(); - let mut h = Harness::builder().with_size(egui::vec2(1600.0, 960.0)).build_eframe(|cc| TextureCraftApp::new(cc, session)); + let mut h = Harness::builder().with_size(egui::vec2(1600.0, 960.0)).with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|cc| TextureCraftApp::new(cc, session)); h.run_steps(4); let c = h.state().viewport_rect.center(); let (brush, yaw, history) = { @@ -50,7 +50,7 @@ fn ctrl_drag_changes_the_brush_instead_of_painting_or_orbiting() { fn app(layout: texturecraft_ui_egui::state::ViewLayout) -> Harness<'static, TextureCraftApp> { let session = texturecraft_engine::sample_session(256, 64).unwrap(); - let mut h = Harness::builder().with_size(egui::vec2(1600.0, 960.0)).build_eframe(|cc| TextureCraftApp::new(cc, session)); + let mut h = Harness::builder().with_size(egui::vec2(1600.0, 960.0)).with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|cc| TextureCraftApp::new(cc, session)); h.state_mut().ui.layout = layout; h.run_steps(4); h diff --git a/crates/ui-egui/tests/it/brush_section_reset.rs b/crates/ui-egui/tests/it/brush_section_reset.rs index 8504adc1..ec45916c 100644 --- a/crates/ui-egui/tests/it/brush_section_reset.rs +++ b/crates/ui-egui/tests/it/brush_section_reset.rs @@ -69,7 +69,7 @@ fn changed_brush() -> BrushSettings { /// The app showing the brush in Properties, set to `brush` fn app_with_brush(brush: BrushSettings) -> Harness<'static, TextureCraftApp> { let session = texturecraft_engine::sample_session(256, 64).unwrap(); - let mut harness = Harness::builder().with_size(WINDOW_SIZE).build_eframe(|cc| TextureCraftApp::new(cc, session)); + let mut harness = Harness::builder().with_size(WINDOW_SIZE).with_context_setup(texturecraft_ui_egui::framework::install_headless).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(); diff --git a/crates/ui-egui/tests/it/camera_views.rs b/crates/ui-egui/tests/it/camera_views.rs index dd11c863..d05fb3bc 100644 --- a/crates/ui-egui/tests/it/camera_views.rs +++ b/crates/ui-egui/tests/it/camera_views.rs @@ -11,7 +11,7 @@ use texturecraft_ui_egui::TextureCraftApp; fn harness() -> Harness<'static, TextureCraftApp> { let session = texturecraft_engine::sample_session(256, 64).unwrap(); - let mut h = Harness::builder().with_size(egui::vec2(1600.0, 960.0)).build_eframe(|cc| TextureCraftApp::new(cc, session)); + let mut h = Harness::builder().with_size(egui::vec2(1600.0, 960.0)).with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|cc| TextureCraftApp::new(cc, session)); h.run_steps(4); h } @@ -108,7 +108,7 @@ fn alt_shift_drag_orbits_in_quarter_turns() { /// A harness whose frames are 10 ms apart, so a 0.35 s glide spans about 35 frames and a drag fits inside it. fn slow_glide_harness() -> Harness<'static, TextureCraftApp> { let session = texturecraft_engine::sample_session(256, 64).unwrap(); - let mut h = Harness::builder().with_size(egui::vec2(1600.0, 960.0)).with_step_dt(0.01).build_eframe(|cc| TextureCraftApp::new(cc, session)); + let mut h = Harness::builder().with_size(egui::vec2(1600.0, 960.0)).with_step_dt(0.01).with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|cc| TextureCraftApp::new(cc, session)); h.run_steps(4); h } diff --git a/crates/ui-egui/tests/it/clone_source_view.rs b/crates/ui-egui/tests/it/clone_source_view.rs index 16297442..afe24d1a 100644 --- a/crates/ui-egui/tests/it/clone_source_view.rs +++ b/crates/ui-egui/tests/it/clone_source_view.rs @@ -15,7 +15,7 @@ const MARKER_STROKE: f32 = 1.2; fn clone_app() -> Harness<'static, TextureCraftApp> { let session = texturecraft_engine::sample_session(256, 64).unwrap(); - let mut harness = Harness::builder().with_size(egui::vec2(1600.0, 960.0)).build_eframe(|cc| TextureCraftApp::new(cc, session)); + let mut harness = Harness::builder().with_size(egui::vec2(1600.0, 960.0)).with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|cc| TextureCraftApp::new(cc, session)); harness.state_mut().ui.layout = ViewLayout::Only2D; execute(&mut harness.state_mut().session, "tool.clone", &serde_json::Value::Null).unwrap(); harness.run_steps(4); diff --git a/crates/ui-egui/tests/it/close_unsaved.rs b/crates/ui-egui/tests/it/close_unsaved.rs index e1b74688..50132e2e 100644 --- a/crates/ui-egui/tests/it/close_unsaved.rs +++ b/crates/ui-egui/tests/it/close_unsaved.rs @@ -10,7 +10,7 @@ use texturecraft_ui_egui::state::Unsaved; fn harness(modified: bool) -> Harness<'static, TextureCraftApp> { let mut session = texturecraft_engine::sample_session(256, 64).unwrap(); session.modified = modified; - let mut h = Harness::builder().with_size(egui::vec2(1600.0, 960.0)).build_eframe(|cc| TextureCraftApp::new(cc, session)); + let mut h = Harness::builder().with_size(egui::vec2(1600.0, 960.0)).with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|cc| TextureCraftApp::new(cc, session)); h.run_steps(4); h } diff --git a/crates/ui-egui/tests/it/color_selection_editor.rs b/crates/ui-egui/tests/it/color_selection_editor.rs index c5f2979e..40e5584b 100644 --- a/crates/ui-egui/tests/it/color_selection_editor.rs +++ b/crates/ui-egui/tests/it/color_selection_editor.rs @@ -55,7 +55,7 @@ fn color_selection_session(with_id_map: bool) -> (texturecraft_engine::Session, fn app_with_color_selection(with_id_map: bool) -> (Harness<'static, TextureCraftApp>, LayerId) { let (session, effect) = color_selection_session(with_id_map); - let mut harness = Harness::builder().with_size(PROPERTIES_WINDOW).build_eframe(|cc| TextureCraftApp::new(cc, session)); + let mut harness = Harness::builder().with_size(PROPERTIES_WINDOW).with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|cc| TextureCraftApp::new(cc, session)); harness.run_steps(STARTUP_FRAMES); (harness, effect) } @@ -294,7 +294,7 @@ fn removing_an_image_during_id_picking_falls_back_to_material() { #[ignore = "requires a GPU adapter; set TC_UI_SNAPSHOTS to save the rendered views"] fn color_selection_snapshots_and_quick_mask_pick() { let (session, _) = color_selection_session(true); - let mut harness = Harness::builder().with_size(egui::vec2(1600.0, 960.0)).with_pixels_per_point(1.0).wgpu().build_eframe(|context| { + let mut harness = Harness::builder().with_size(egui::vec2(1600.0, 960.0)).with_pixels_per_point(1.0).wgpu().with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|context| { let mut app = TextureCraftApp::new(context, session); app.ui.layout = texturecraft_ui_egui::state::ViewLayout::Only3D; app @@ -393,7 +393,7 @@ fn the_background_list_leaves_the_view_its_wheel_and_closes_on_escape_or_a_click fn the_id_mask_slot_picks_a_texture_and_its_x_goes_back_to_the_mesh_map() { let (mut session, effect) = color_selection_session(true); let texture = session.import_resource_bytes("parts.png", id_map_png()).unwrap(); - let mut harness = Harness::builder().with_size(PROPERTIES_WINDOW).build_eframe(|cc| TextureCraftApp::new(cc, session)); + let mut harness = Harness::builder().with_size(PROPERTIES_WINDOW).with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|cc| TextureCraftApp::new(cc, session)); harness.run_steps(STARTUP_FRAMES); harness.get_by_role_and_label(Role::ComboBox, "ID Mask").click(); @@ -419,7 +419,7 @@ fn tile_is_current(harness: &Harness<'_, TextureCraftApp>, label: &str) -> bool fn reading_the_mesh_map_shows_no_tile_as_the_current_id_mask() { let (mut session, effect) = color_selection_session(true); let texture = session.import_resource_bytes("parts.png", id_map_png()).unwrap(); - let mut harness = Harness::builder().with_size(PROPERTIES_WINDOW).build_eframe(|cc| TextureCraftApp::new(cc, session)); + let mut harness = Harness::builder().with_size(PROPERTIES_WINDOW).with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|cc| TextureCraftApp::new(cc, session)); harness.run_steps(STARTUP_FRAMES); assert_eq!(selection(&harness, effect).id_map, None, "the selection reads the ID mesh map"); @@ -457,7 +457,7 @@ fn the_invert_tooltip_shows_right_above_its_button() { fn invert_tooltip_snapshot() { let (session, _) = color_selection_session(true); let mut harness = - Harness::builder().with_size(egui::vec2(1600.0, 960.0)).with_pixels_per_point(2.0).wgpu().build_eframe(|cc| TextureCraftApp::new(cc, session)); + Harness::builder().with_size(egui::vec2(1600.0, 960.0)).with_pixels_per_point(2.0).wgpu().with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|cc| TextureCraftApp::new(cc, session)); harness.run_steps(STARTUP_FRAMES); let invert = harness.get_by_role_and_label(Role::Button, "Invert").rect(); harness.hover_at(invert.center()); @@ -474,7 +474,7 @@ fn a_hand_picked_id_mask_picks_without_a_bake() { session.doc.baked.clear(); let texture = session.import_resource_bytes("parts.png", id_map_png()).unwrap(); execute(&mut session, "effect.set", &json!({"effect": effect.0, "idMap": texture})).unwrap(); - let mut harness = Harness::builder().with_size(PROPERTIES_WINDOW).build_eframe(|cc| TextureCraftApp::new(cc, session)); + let mut harness = Harness::builder().with_size(PROPERTIES_WINDOW).with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|cc| TextureCraftApp::new(cc, session)); harness.run_steps(STARTUP_FRAMES); harness.get_by_label(PICK_COLOR).click(); @@ -496,7 +496,7 @@ fn clearing_the_only_id_mask_ends_a_waiting_pick() { session.doc.baked.clear(); let texture = session.import_resource_bytes("parts.png", id_map_png()).unwrap(); execute(&mut session, "effect.set", &json!({"effect": effect.0, "idMap": texture})).unwrap(); - let mut harness = Harness::builder().with_size(PROPERTIES_WINDOW).build_eframe(|cc| TextureCraftApp::new(cc, session)); + let mut harness = Harness::builder().with_size(PROPERTIES_WINDOW).with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|cc| TextureCraftApp::new(cc, session)); harness.run_steps(STARTUP_FRAMES); harness.get_by_label(PICK_COLOR).click(); harness.run_steps(SETTLE_FRAMES); diff --git a/crates/ui-egui/tests/it/compare_mask_rows.rs b/crates/ui-egui/tests/it/compare_mask_rows.rs index fff39d24..df14931a 100644 --- a/crates/ui-egui/tests/it/compare_mask_rows.rs +++ b/crates/ui-egui/tests/it/compare_mask_rows.rs @@ -17,7 +17,7 @@ fn compare_harness() -> (Harness<'static, TextureCraftApp>, LayerId) { let layer = execute(&mut session, "layer.add.fill", &json!({"roughness": 0.6})).unwrap()["layer"].clone(); let effect = LayerId(execute(&mut session, "effect.add.compare", &json!({"layer": layer})).unwrap()["effect"].as_u64().unwrap()); execute(&mut session, "layer.select", &json!({"layer": layer, "target": effect.0})).unwrap(); - let mut harness = Harness::builder().with_size(PROPERTIES_WINDOW).with_step_dt(FRAME_SECONDS).build_eframe(|cc| TextureCraftApp::new(cc, session)); + let mut harness = Harness::builder().with_size(PROPERTIES_WINDOW).with_step_dt(FRAME_SECONDS).with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|cc| TextureCraftApp::new(cc, session)); harness.state_mut().ui.prefs.language = "en".into(); harness.run_steps(STARTUP_FRAMES); (harness, effect) diff --git a/crates/ui-egui/tests/it/curvature_generator.rs b/crates/ui-egui/tests/it/curvature_generator.rs index a5b321bc..54695fbc 100644 --- a/crates/ui-egui/tests/it/curvature_generator.rs +++ b/crates/ui-egui/tests/it/curvature_generator.rs @@ -18,7 +18,7 @@ fn harness(render: bool) -> (Harness<'static, TextureCraftApp>, LayerId) { session.update(); let builder = Harness::builder().with_size(egui::vec2(1600.0, 1200.0)); let builder = if render { builder.wgpu() } else { builder }; - let mut harness = builder.build_eframe(|context| TextureCraftApp::new(context, session)); + let mut harness = builder.with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|context| TextureCraftApp::new(context, session)); harness.state_mut().ui.dock.close(Panel::Layers); harness.state_mut().ui.dock.close(Panel::TextureSetSettings); harness.state_mut().ui.dock.focus(Panel::Properties); diff --git a/crates/ui-egui/tests/it/display_environment.rs b/crates/ui-egui/tests/it/display_environment.rs index 66cfff9f..5864e575 100644 --- a/crates/ui-egui/tests/it/display_environment.rs +++ b/crates/ui-egui/tests/it/display_environment.rs @@ -13,7 +13,7 @@ const SETTLE: usize = 3; fn app() -> Harness<'static, TextureCraftApp> { let session = texturecraft_engine::sample_session(256, 64).unwrap(); - let mut h = Harness::builder().with_size(egui::vec2(1600.0, 1400.0)).build_eframe(|cc| TextureCraftApp::new(cc, session)); + let mut h = Harness::builder().with_size(egui::vec2(1600.0, 1400.0)).with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|cc| TextureCraftApp::new(cc, session)); h.state_mut().ui.prefs.language = "en".into(); h.run_steps(4); h.state_mut().ui.dock.focus(Panel::Display); diff --git a/crates/ui-egui/tests/it/display_post_effects.rs b/crates/ui-egui/tests/it/display_post_effects.rs index df35a767..48e53a6e 100644 --- a/crates/ui-egui/tests/it/display_post_effects.rs +++ b/crates/ui-egui/tests/it/display_post_effects.rs @@ -24,7 +24,7 @@ fn display(harness: &Harness<'_, TextureCraftApp>) -> DisplaySettings { /// The app with Display Settings open from the rail and the Post effects section unfolded fn app() -> Harness<'static, TextureCraftApp> { let session = texturecraft_engine::sample_session(256, 64).unwrap(); - let mut harness = Harness::builder().with_size(egui::vec2(1600.0, 1400.0)).build_eframe(|cc| TextureCraftApp::new(cc, session)); + let mut harness = Harness::builder().with_size(egui::vec2(1600.0, 1400.0)).with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|cc| TextureCraftApp::new(cc, session)); harness.state_mut().ui.prefs.language = "en".into(); harness.run_steps(4); harness diff --git a/crates/ui-egui/tests/it/effect_rows.rs b/crates/ui-egui/tests/it/effect_rows.rs index 54157bba..e0efd1cc 100644 --- a/crates/ui-egui/tests/it/effect_rows.rs +++ b/crates/ui-egui/tests/it/effect_rows.rs @@ -37,7 +37,7 @@ fn dragging_an_effect_row_reorders_its_stack() { |name: &str| id(execute(&mut session, "effect.add.filter", &json!({"target": "content", "filter": "invert", "name": name})).unwrap(), "effect"); let (a, b, c) = (add("Effect A"), add("Effect B"), add("Effect C")); execute(&mut session, "layer.select", &json!({"layer": layer.0})).unwrap(); - let mut harness = Harness::builder().with_size(egui::vec2(1600.0, 1400.0)).build_eframe(|creation_context| TextureCraftApp::new(creation_context, session)); + let mut harness = Harness::builder().with_size(egui::vec2(1600.0, 1400.0)).with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|creation_context| TextureCraftApp::new(creation_context, session)); harness.run_steps(4); let order = |harness: &Harness<'_, TextureCraftApp>| harness.state().session.doc.project.layers[&layer].content_effects.iter().map(|e| e.id.0).collect::>(); @@ -66,7 +66,7 @@ fn an_effect_row_sets_its_blend_mode_and_opacity() { let layer = LayerId(id(execute(&mut session, "layer.add.fill", &Value::Null).unwrap(), "layer")); let effect = id(execute(&mut session, "effect.add.filter", &json!({"target": "content", "filter": "invert", "name": "Effect A"})).unwrap(), "effect"); execute(&mut session, "layer.select", &json!({"layer": layer.0})).unwrap(); - let mut harness = Harness::builder().with_size(egui::vec2(1600.0, 1400.0)).build_eframe(|creation_context| TextureCraftApp::new(creation_context, session)); + let mut harness = Harness::builder().with_size(egui::vec2(1600.0, 1400.0)).with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|creation_context| TextureCraftApp::new(creation_context, session)); harness.run_steps(4); let effect_of = |harness: &Harness<'_, TextureCraftApp>| harness.state().session.doc.project.layers[&layer].content_effects[0].clone(); @@ -112,7 +112,7 @@ fn an_opacity_drag_starting_without_a_change_is_its_own_undo_step() { let effect = id(execute(&mut session, "effect.add.filter", &json!({"target": "content", "filter": "invert", "name": "Effect A"})).unwrap(), "effect"); execute(&mut session, "effect.set", &json!({"effect": effect, "blend": "Multiply"})).unwrap(); execute(&mut session, "layer.select", &json!({"layer": layer.0})).unwrap(); - let mut harness = Harness::builder().with_size(egui::vec2(1600.0, 1400.0)).build_eframe(|creation_context| TextureCraftApp::new(creation_context, session)); + let mut harness = Harness::builder().with_size(egui::vec2(1600.0, 1400.0)).with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|creation_context| TextureCraftApp::new(creation_context, session)); harness.run_steps(4); let effect_of = |harness: &Harness<'_, TextureCraftApp>| harness.state().session.doc.project.layers[&layer].content_effects[0].clone(); @@ -151,7 +151,7 @@ fn an_effect_rows_blending_options_reach_every_channel() { let effect = id(execute(&mut session, "effect.add.filter", &json!({"target": "content", "filter": "invert", "name": "Effect A"})).unwrap(), "effect"); execute(&mut session, "effect.set", &json!({"effect": effect, "channel": "baseColor", "blend": "Multiply"})).unwrap(); execute(&mut session, "layer.select", &json!({"layer": layer.0})).unwrap(); - let mut harness = Harness::builder().with_size(egui::vec2(1600.0, 1400.0)).build_eframe(|creation_context| TextureCraftApp::new(creation_context, session)); + let mut harness = Harness::builder().with_size(egui::vec2(1600.0, 1400.0)).with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|creation_context| TextureCraftApp::new(creation_context, session)); harness.run_steps(4); let effect_of = |harness: &Harness<'_, TextureCraftApp>| harness.state().session.doc.project.layers[&layer].content_effects[0].clone(); diff --git a/crates/ui-egui/tests/it/effect_sliders.rs b/crates/ui-egui/tests/it/effect_sliders.rs index cf141d3b..92b79f6f 100644 --- a/crates/ui-egui/tests/it/effect_sliders.rs +++ b/crates/ui-egui/tests/it/effect_sliders.rs @@ -21,7 +21,7 @@ fn selected_generator() -> (Harness<'static, TextureCraftApp>, LayerId) { }) .unwrap(); texturecraft_engine::execute(&mut session, "layer.select", &json!({"layer": layer.0, "target": effect.0})).unwrap(); - let mut harness = Harness::builder().with_size(egui::vec2(1600.0, 1400.0)).build_eframe(|creation_context| TextureCraftApp::new(creation_context, session)); + let mut harness = Harness::builder().with_size(egui::vec2(1600.0, 1400.0)).with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|creation_context| TextureCraftApp::new(creation_context, session)); harness.run_steps(4); (harness, effect) } diff --git a/crates/ui-egui/tests/it/empty_menus.rs b/crates/ui-egui/tests/it/empty_menus.rs index 3e669830..4c4478b2 100644 --- a/crates/ui-egui/tests/it/empty_menus.rs +++ b/crates/ui-egui/tests/it/empty_menus.rs @@ -8,7 +8,7 @@ use texturecraft_engine::Session; use texturecraft_ui_egui::{TextureCraftApp, docking::Panel, menus}; fn app() -> Harness<'static, TextureCraftApp> { - let mut h = Harness::builder().with_size(egui::vec2(1600.0, 1000.0)).build_eframe(|cc| TextureCraftApp::new(cc, Session::closed().unwrap())); + let mut h = Harness::builder().with_size(egui::vec2(1600.0, 1000.0)).with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|cc| TextureCraftApp::new(cc, Session::closed().unwrap())); h.state_mut().ui.prefs.language = "en".into(); h.run_steps(4); h diff --git a/crates/ui-egui/tests/it/empty_start.rs b/crates/ui-egui/tests/it/empty_start.rs index 09f3c1ca..c11b9f75 100644 --- a/crates/ui-egui/tests/it/empty_start.rs +++ b/crates/ui-egui/tests/it/empty_start.rs @@ -7,7 +7,7 @@ use texturecraft_engine::Session; use texturecraft_ui_egui::{TextureCraftApp, menus}; fn harness(session: Session) -> Harness<'static, TextureCraftApp> { - let mut harness = Harness::builder().with_size(egui::vec2(1600.0, 960.0)).build_eframe(|cc| TextureCraftApp::new(cc, session)); + let mut harness = Harness::builder().with_size(egui::vec2(1600.0, 960.0)).with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|cc| TextureCraftApp::new(cc, session)); // The exact-text checks below need English, whatever the OS language is harness.state_mut().ui.prefs.language = "en".into(); diff --git a/crates/ui-egui/tests/it/export_file_types.rs b/crates/ui-egui/tests/it/export_file_types.rs index 8967fe80..c9f270c2 100644 --- a/crates/ui-egui/tests/it/export_file_types.rs +++ b/crates/ui-egui/tests/it/export_file_types.rs @@ -8,7 +8,7 @@ use texturecraft_ui_egui::TextureCraftApp; /// The Export textures window open on SETTINGS fn harness() -> Harness<'static, TextureCraftApp> { let session = texturecraft_engine::sample_session(256, 64).unwrap(); - let mut h = Harness::builder().with_size(egui::vec2(1600.0, 960.0)).build_eframe(|cc| TextureCraftApp::new(cc, session)); + let mut h = Harness::builder().with_size(egui::vec2(1600.0, 960.0)).with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|cc| TextureCraftApp::new(cc, session)); h.state_mut().ui.prefs.language = "en".into(); h.run_steps(4); h.state_mut().ui.windows.export = true; @@ -138,7 +138,7 @@ fn export_writes_the_chosen_type_and_depth() { #[test] fn an_old_hidden_bit_depth_is_not_exported() { let session = texturecraft_engine::sample_session(256, 64).unwrap(); - let mut h = Harness::builder().with_size(egui::vec2(1600.0, 960.0)).build_eframe(|cc| TextureCraftApp::new(cc, session)); + let mut h = Harness::builder().with_size(egui::vec2(1600.0, 960.0)).with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|cc| TextureCraftApp::new(cc, session)); h.state_mut().ui.prefs.language = "en".into(); // Saved by an older build: "From template" with 16 bits diff --git a/crates/ui-egui/tests/it/export_map_overrides.rs b/crates/ui-egui/tests/it/export_map_overrides.rs index 77d67503..e2b840eb 100644 --- a/crates/ui-egui/tests/it/export_map_overrides.rs +++ b/crates/ui-egui/tests/it/export_map_overrides.rs @@ -9,7 +9,7 @@ use texturecraft_ui_egui::state::{FileType, MapExport, SetExport}; /// The Export textures window open on the first texture set's page fn harness() -> Harness<'static, TextureCraftApp> { let session = texturecraft_engine::sample_session(256, 64).unwrap(); - let mut h = Harness::builder().with_size(egui::vec2(1600.0, 960.0)).build_eframe(|cc| TextureCraftApp::new(cc, session)); + let mut h = Harness::builder().with_size(egui::vec2(1600.0, 960.0)).with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|cc| TextureCraftApp::new(cc, session)); h.state_mut().ui.prefs.language = "en".into(); h.run_steps(4); h.state_mut().ui.windows.export = true; diff --git a/crates/ui-egui/tests/it/export_materialx.rs b/crates/ui-egui/tests/it/export_materialx.rs index 9a26f2be..176f73d3 100644 --- a/crates/ui-egui/tests/it/export_materialx.rs +++ b/crates/ui-egui/tests/it/export_materialx.rs @@ -11,7 +11,7 @@ const OPENPBR: &str = "OpenPBR (separate maps)"; /// The Export textures window writing into a scratch folder of its own for `name` fn harness(name: &str) -> (Harness<'static, TextureCraftApp>, std::path::PathBuf) { let session = texturecraft_engine::sample_session(256, 64).unwrap(); - let mut app_harness = Harness::builder().with_size(egui::vec2(1600.0, 960.0)).build_eframe(|cc| TextureCraftApp::new(cc, session)); + let mut app_harness = Harness::builder().with_size(egui::vec2(1600.0, 960.0)).with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|cc| TextureCraftApp::new(cc, session)); app_harness.state_mut().ui.prefs.language = "en".into(); app_harness.run_steps(4); diff --git a/crates/ui-egui/tests/it/export_overrides.rs b/crates/ui-egui/tests/it/export_overrides.rs index 9edb2ee5..0ff8cfaf 100644 --- a/crates/ui-egui/tests/it/export_overrides.rs +++ b/crates/ui-egui/tests/it/export_overrides.rs @@ -12,7 +12,7 @@ fn harness() -> Harness<'static, TextureCraftApp> { } fn harness_with_session(session: texturecraft_engine::Session) -> Harness<'static, TextureCraftApp> { - let mut h = Harness::builder().with_size(egui::vec2(1600.0, 960.0)).build_eframe(|cc| TextureCraftApp::new(cc, session)); + let mut h = Harness::builder().with_size(egui::vec2(1600.0, 960.0)).with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|cc| TextureCraftApp::new(cc, session)); h.state_mut().ui.prefs.language = "en".into(); h.run_steps(4); h.state_mut().ui.windows.export = true; @@ -269,7 +269,7 @@ fn reset_all_then_cancel_restores_the_ticks_and_overrides() { #[test] fn ticks_saved_before_settings_named_their_project_are_kept() { let session = texturecraft_engine::sample_session(256, 64).unwrap(); - let mut h = Harness::builder().with_size(egui::vec2(1600.0, 960.0)).build_eframe(|cc| TextureCraftApp::new(cc, session)); + let mut h = Harness::builder().with_size(egui::vec2(1600.0, 960.0)).with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|cc| TextureCraftApp::new(cc, session)); h.state_mut().ui.prefs.language = "en".into(); h.run_steps(4); diff --git a/crates/ui-egui/tests/it/export_progress.rs b/crates/ui-egui/tests/it/export_progress.rs index 84015102..89d7ef49 100644 --- a/crates/ui-egui/tests/it/export_progress.rs +++ b/crates/ui-egui/tests/it/export_progress.rs @@ -10,7 +10,7 @@ use texturecraft_ui_egui::state::{ConsoleLine, ExportJob}; /// The Export textures window writing into a scratch folder of its own for `name` fn harness(name: &str) -> (Harness<'static, TextureCraftApp>, std::path::PathBuf) { let session = texturecraft_engine::sample_session(256, 64).unwrap(); - let mut h = Harness::builder().with_size(egui::vec2(1600.0, 960.0)).build_eframe(|cc| TextureCraftApp::new(cc, session)); + let mut h = Harness::builder().with_size(egui::vec2(1600.0, 960.0)).with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|cc| TextureCraftApp::new(cc, session)); h.state_mut().ui.prefs.language = "en".into(); h.run_steps(4); let dir = std::env::temp_dir().join(format!("tc-export-progress-{name}-{}", std::process::id())); diff --git a/crates/ui-egui/tests/it/export_settings.rs b/crates/ui-egui/tests/it/export_settings.rs index 98af3660..ae2e8a3c 100644 --- a/crates/ui-egui/tests/it/export_settings.rs +++ b/crates/ui-egui/tests/it/export_settings.rs @@ -8,7 +8,7 @@ use texturecraft_ui_egui::TextureCraftApp; /// The Export textures window open on SETTINGS fn harness() -> Harness<'static, TextureCraftApp> { let session = texturecraft_engine::sample_session(256, 64).unwrap(); - let mut h = Harness::builder().with_size(egui::vec2(1600.0, 960.0)).build_eframe(|cc| TextureCraftApp::new(cc, session)); + let mut h = Harness::builder().with_size(egui::vec2(1600.0, 960.0)).with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|cc| TextureCraftApp::new(cc, session)); h.state_mut().ui.prefs.language = "en".into(); h.run_steps(4); h.state_mut().ui.windows.export = true; diff --git a/crates/ui-egui/tests/it/export_template_guards.rs b/crates/ui-egui/tests/it/export_template_guards.rs index 9cfc0071..6e98864f 100644 --- a/crates/ui-egui/tests/it/export_template_guards.rs +++ b/crates/ui-egui/tests/it/export_template_guards.rs @@ -14,7 +14,7 @@ use library::Library; /// The Output templates tab with two user templates, "Alpha tpl" (selected) and "Beta tpl", saved in `library`. fn harness(library: &Library) -> Harness<'static, TextureCraftApp> { let session = texturecraft_engine::sample_session(256, 64).unwrap(); - let mut h = Harness::builder().with_size(egui::vec2(1600.0, 960.0)).build_eframe(|cc| TextureCraftApp::new(cc, session)); + let mut h = Harness::builder().with_size(egui::vec2(1600.0, 960.0)).with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|cc| TextureCraftApp::new(cc, session)); h.run_steps(4); h.state_mut().session.load_export_presets(library.0.clone()); let base = texturecraft_engine::formats::builtin_presets().remove(0); diff --git a/crates/ui-egui/tests/it/export_usd_asset.rs b/crates/ui-egui/tests/it/export_usd_asset.rs index 68f310df..b44f76e9 100644 --- a/crates/ui-egui/tests/it/export_usd_asset.rs +++ b/crates/ui-egui/tests/it/export_usd_asset.rs @@ -26,7 +26,7 @@ impl Drop for Scratch { /// The Export textures window writing into a scratch folder of its own for `name` fn harness(name: &str) -> (Harness<'static, TextureCraftApp>, Scratch) { let session = texturecraft_engine::sample_session(256, 64).unwrap(); - let mut h = Harness::builder().with_size(egui::vec2(1600.0, 960.0)).build_eframe(|cc| TextureCraftApp::new(cc, session)); + let mut h = Harness::builder().with_size(egui::vec2(1600.0, 960.0)).with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|cc| TextureCraftApp::new(cc, session)); h.state_mut().ui.prefs.language = "en".into(); h.run_steps(4); let dir = std::env::temp_dir().join(format!("tc-export-usd-asset-{name}-{}", std::process::id())); diff --git a/crates/ui-egui/tests/it/file_dialogs.rs b/crates/ui-egui/tests/it/file_dialogs.rs index 62c305ea..b3a71b30 100644 --- a/crates/ui-egui/tests/it/file_dialogs.rs +++ b/crates/ui-egui/tests/it/file_dialogs.rs @@ -13,7 +13,7 @@ use texturecraft_ui_egui::state::Unsaved; fn harness(modified: bool) -> Harness<'static, TextureCraftApp> { let mut session = texturecraft_engine::sample_session(256, 64).unwrap(); session.modified = modified; - let mut h = Harness::builder().with_size(egui::vec2(1600.0, 960.0)).build_eframe(|cc| TextureCraftApp::new(cc, session)); + let mut h = Harness::builder().with_size(egui::vec2(1600.0, 960.0)).with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|cc| TextureCraftApp::new(cc, session)); h.run_steps(4); h } diff --git a/crates/ui-egui/tests/it/fill_channel_image.rs b/crates/ui-egui/tests/it/fill_channel_image.rs index f369d475..7b599103 100644 --- a/crates/ui-egui/tests/it/fill_channel_image.rs +++ b/crates/ui-egui/tests/it/fill_channel_image.rs @@ -26,7 +26,7 @@ fn a_fill_channel_takes_an_image_from_its_source_picker() { let name = session.import_resource_bytes("rough.png", png_bytes).unwrap(); let result = texturecraft_engine::execute(&mut session, "layer.add.fill", &json!({"roughness": 0.6})).unwrap(); let layer = LayerId(result["layer"].as_u64().unwrap()); - let mut harness = Harness::builder().with_size(egui::vec2(1600.0, 1400.0)).build_eframe(|cc| TextureCraftApp::new(cc, session)); + let mut harness = Harness::builder().with_size(egui::vec2(1600.0, 1400.0)).with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|cc| TextureCraftApp::new(cc, session)); // Use English so first-run locale does not change queried labels harness.state_mut().ui.prefs.language = "en".into(); @@ -51,7 +51,7 @@ fn the_source_picker_offers_only_images_that_were_decoded() { // Bytes that are not an image never reach the decoded images session.doc.resources.insert("broken.png".into(), std::sync::Arc::new(vec![1, 2, 3])); texturecraft_engine::execute(&mut session, "layer.add.fill", &json!({"roughness": 0.6})).unwrap(); - let mut harness = Harness::builder().with_size(egui::vec2(1600.0, 1400.0)).build_eframe(|cc| TextureCraftApp::new(cc, session)); + let mut harness = Harness::builder().with_size(egui::vec2(1600.0, 1400.0)).with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|cc| TextureCraftApp::new(cc, session)); // Use English so first-run locale does not change queried labels harness.state_mut().ui.prefs.language = "en".into(); @@ -122,7 +122,7 @@ fn a_mask_fill_selects_an_image_edits_projection_and_returns_to_uniform() { texturecraft_engine::execute(&mut session, "mask.add.black", &json!({})).unwrap(); let output = texturecraft_engine::execute(&mut session, "effect.add.fill", &json!({"target": "mask"})).unwrap(); let effect_id = LayerId(output["effect"].as_u64().unwrap()); - let mut harness = Harness::builder().with_size(egui::vec2(1600.0, 1400.0)).build_eframe(|cc| TextureCraftApp::new(cc, session)); + let mut harness = Harness::builder().with_size(egui::vec2(1600.0, 1400.0)).with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|cc| TextureCraftApp::new(cc, session)); harness.state_mut().ui.prefs.language = "en".into(); harness.run_steps(4); @@ -166,7 +166,7 @@ fn a_normal_image_can_be_marked_directx() { let out = texturecraft_engine::execute(&mut session, "layer.add.fill", &json!({})).unwrap(); let layer = LayerId(out["layer"].as_u64().unwrap()); texturecraft_engine::execute(&mut session, "layer.fill.set", &json!({"layer": layer.0, "channel": "normal", "image": name})).unwrap(); - let mut h = Harness::builder().with_size(egui::vec2(1600.0, 1400.0)).build_eframe(|cc| TextureCraftApp::new(cc, session)); + let mut h = Harness::builder().with_size(egui::vec2(1600.0, 1400.0)).with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|cc| TextureCraftApp::new(cc, session)); h.state_mut().ui.prefs.language = "en".into(); h.run_steps(4); diff --git a/crates/ui-egui/tests/it/fill_support.rs b/crates/ui-egui/tests/it/fill_support.rs index 6adf3212..845eebd5 100644 --- a/crates/ui-egui/tests/it/fill_support.rs +++ b/crates/ui-egui/tests/it/fill_support.rs @@ -18,7 +18,7 @@ pub(crate) fn fill_app(settings: Value, projection: Option<&str>, tab: Option<&s if let Some(projection) = projection { texturecraft_engine::execute(&mut session, "layer.fill.projection", &json!({"layer": layer, "projection": projection})).unwrap(); } - let mut harness = Harness::builder().with_size(window).build_eframe(|cc| TextureCraftApp::new(cc, session)); + let mut harness = Harness::builder().with_size(window).with_context_setup(texturecraft_ui_egui::framework::install_headless).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(); diff --git a/crates/ui-egui/tests/it/filter_picker.rs b/crates/ui-egui/tests/it/filter_picker.rs index 36a1bfc9..9e65517c 100644 --- a/crates/ui-egui/tests/it/filter_picker.rs +++ b/crates/ui-egui/tests/it/filter_picker.rs @@ -185,7 +185,7 @@ fn filter_picker_snapshots_and_frame_timings() { let mut session = texturecraft_engine::sample_session(256, 64).unwrap(); execute(&mut session, "layer.add.fill", &Value::Null).unwrap(); execute(&mut session, "effect.add.filter", &json!({"target": "content", "filter": "invert"})).unwrap(); - let mut harness = Harness::builder().with_size(egui::vec2(WINDOW_WIDTH, SNAPSHOT_HEIGHT)).wgpu().build_eframe(|cc| { + let mut harness = Harness::builder().with_size(egui::vec2(WINDOW_WIDTH, SNAPSHOT_HEIGHT)).wgpu().with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|cc| { eprintln!("selected graphics adapter: {:?}", cc.wgpu_render_state.as_ref().unwrap().adapter.get_info()); TextureCraftApp::new(cc, session) }); diff --git a/crates/ui-egui/tests/it/filter_support.rs b/crates/ui-egui/tests/it/filter_support.rs index cd8a750e..7a3949ee 100644 --- a/crates/ui-egui/tests/it/filter_support.rs +++ b/crates/ui-egui/tests/it/filter_support.rs @@ -29,7 +29,7 @@ pub(crate) fn app_with(filter: &str, target: &str, height: f32) -> (Harness<'sta execute(&mut session, "layer.select", &json!({"layer": layer["layer"]})).unwrap(); session.target = StackTarget::Effect(effect); - let mut harness = Harness::builder().with_size(egui::vec2(WINDOW_WIDTH, height)).build_eframe(|cc| TextureCraftApp::new(cc, session)); + let mut harness = Harness::builder().with_size(egui::vec2(WINDOW_WIDTH, height)).with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|cc| TextureCraftApp::new(cc, session)); harness.state_mut().ui.prefs.language = "en".into(); harness.run_steps(4); (harness, effect) diff --git a/crates/ui-egui/tests/it/folder_properties.rs b/crates/ui-egui/tests/it/folder_properties.rs index c92c429c..90129374 100644 --- a/crates/ui-egui/tests/it/folder_properties.rs +++ b/crates/ui-egui/tests/it/folder_properties.rs @@ -28,7 +28,7 @@ fn folder_harness(with_fill: bool) -> (Harness<'static, TextureCraftApp>, LayerI LayerId(execute(&mut session, "layer.add.group", &json!({})).unwrap()["layer"].as_u64().unwrap()) }; execute(&mut session, "layer.select", &json!({"layer": folder.0, "target": "content"})).unwrap(); - let mut harness = Harness::builder().with_size(PROPERTIES_WINDOW).with_step_dt(FRAME_SECONDS).build_eframe(|cc| TextureCraftApp::new(cc, session)); + let mut harness = Harness::builder().with_size(PROPERTIES_WINDOW).with_step_dt(FRAME_SECONDS).with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|cc| TextureCraftApp::new(cc, session)); harness.state_mut().ui.prefs.language = "en".into(); harness.run_steps(STARTUP_FRAMES); (harness, folder, fill) diff --git a/crates/ui-egui/tests/it/frame_selection.rs b/crates/ui-egui/tests/it/frame_selection.rs index f93c8b51..6bc8484e 100644 --- a/crates/ui-egui/tests/it/frame_selection.rs +++ b/crates/ui-egui/tests/it/frame_selection.rs @@ -10,7 +10,7 @@ o Floor\nusemtl Floor\nv -100 -1 -100\nv 100 -1 -100\nv 0 -1 100\nvt 0 0\nvt 1 0 fn harness() -> Harness<'static, TextureCraftApp> { let session = Session::from_mesh_bytes("scene.obj", SCENE_OBJ.as_bytes(), 256, "scene").unwrap(); - let mut h = Harness::builder().with_size(egui::vec2(1600.0, 960.0)).build_eframe(|cc| TextureCraftApp::new(cc, session)); + let mut h = Harness::builder().with_size(egui::vec2(1600.0, 960.0)).with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|cc| TextureCraftApp::new(cc, session)); h.run_steps(4); h } diff --git a/crates/ui-egui/tests/it/generator_panel.rs b/crates/ui-egui/tests/it/generator_panel.rs index 796051e8..dfef8304 100644 --- a/crates/ui-egui/tests/it/generator_panel.rs +++ b/crates/ui-egui/tests/it/generator_panel.rs @@ -22,7 +22,7 @@ fn harness(render: bool) -> (Harness<'static, TextureCraftApp>, LayerId) { session.update(); let builder = Harness::builder().with_size(egui::vec2(1600.0, 2400.0)); let builder = if render { builder.wgpu() } else { builder }; - let mut harness = builder.build_eframe(|context| TextureCraftApp::new(context, session)); + let mut harness = builder.with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|context| TextureCraftApp::new(context, session)); harness.state_mut().ui.dock.close(Panel::Layers); harness.state_mut().ui.dock.close(Panel::TextureSetSettings); harness.state_mut().ui.dock.focus(Panel::Properties); diff --git a/crates/ui-egui/tests/it/help_menu_664.rs b/crates/ui-egui/tests/it/help_menu_664.rs index da4b9f98..c0e394f8 100644 --- a/crates/ui-egui/tests/it/help_menu_664.rs +++ b/crates/ui-egui/tests/it/help_menu_664.rs @@ -11,7 +11,7 @@ fn harness() -> Harness<'static, TextureCraftApp> { let mut session = Session::new_project("t", primitives::material_ball(), "builtin:material_ball", None, 128).unwrap(); session.log.push("first line".into()); session.log.warn(texturecraft_engine::log::DEFAULT_SOURCE, "second line"); - let mut h = Harness::builder().with_size(egui::vec2(1600.0, 960.0)).build_eframe(|cc| TextureCraftApp::new(cc, session)); + let mut h = Harness::builder().with_size(egui::vec2(1600.0, 960.0)).with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|cc| TextureCraftApp::new(cc, session)); h.state_mut().ui.prefs.language = "en".into(); h.run_steps(4); h diff --git a/crates/ui-egui/tests/it/history_panel.rs b/crates/ui-egui/tests/it/history_panel.rs index 7103161b..8c1397c7 100644 --- a/crates/ui-egui/tests/it/history_panel.rs +++ b/crates/ui-egui/tests/it/history_panel.rs @@ -10,7 +10,7 @@ use texturecraft_ui_egui::docking::Panel; /// Show document history so row clicks exercise the same command dispatch as the application fn history_harness(session: Session) -> Harness<'static, TextureCraftApp> { - let mut harness = Harness::builder().with_size(egui::vec2(1600.0, 960.0)).build_eframe(|context| TextureCraftApp::new(context, session)); + let mut harness = Harness::builder().with_size(egui::vec2(1600.0, 960.0)).with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|context| TextureCraftApp::new(context, session)); harness.state_mut().ui.dock.focus(Panel::History); harness.run_steps(4); harness @@ -167,7 +167,7 @@ fn clicking_a_history_step_returns_to_it() { texturecraft_engine::execute(&mut session, "layer.rename", &json!({"layer": layer.0, "name": name})).unwrap(); } let done = session.history_labels().len(); - let mut h = Harness::builder().with_size(egui::vec2(1600.0, 960.0)).build_eframe(|cc| TextureCraftApp::new(cc, session)); + let mut h = Harness::builder().with_size(egui::vec2(1600.0, 960.0)).with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|cc| TextureCraftApp::new(cc, session)); h.state_mut().ui.dock.focus(Panel::History); h.run_steps(4); let name = |h: &Harness<'_, TextureCraftApp>| h.state().session.doc.project.layers[&layer].name.clone(); diff --git a/crates/ui-egui/tests/it/import_resources.rs b/crates/ui-egui/tests/it/import_resources.rs index 26badb0f..759e1516 100644 --- a/crates/ui-egui/tests/it/import_resources.rs +++ b/crates/ui-egui/tests/it/import_resources.rs @@ -18,7 +18,7 @@ const PREFIX_HINT: &str = "Put in front of the resource's name. Characters other fn app() -> Harness<'static, TextureCraftApp> { let session = Session::new_project("Test", texturecraft_engine::geom::primitives::cube(1.0), "builtin:cube", None, 128).unwrap(); - let mut h = Harness::builder().with_size(egui::vec2(1600.0, 960.0)).build_eframe(|cc| TextureCraftApp::new(cc, session)); + let mut h = Harness::builder().with_size(egui::vec2(1600.0, 960.0)).with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|cc| TextureCraftApp::new(cc, session)); h.state_mut().ui.prefs.language = "en".into(); h.run_steps(4); @@ -285,7 +285,7 @@ fn import_resources_snapshot() { let output_dir = PathBuf::from(std::env::var_os("TC_UI_SNAPSHOTS").expect("set TC_UI_SNAPSHOTS")); let dir = TempDir::new("import-resources-snapshot"); let session = Session::new_project("Resources", texturecraft_engine::geom::primitives::cube(1.0), "builtin:cube", None, 128).unwrap(); - 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)); + let mut h = Harness::builder().with_size(egui::vec2(1600.0, 960.0)).with_pixels_per_point(1.0).wgpu().with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|cc| TextureCraftApp::new(cc, session)); h.run_steps(4); invoke(&mut h); diff --git a/crates/ui-egui/tests/it/inactive_set_hint.rs b/crates/ui-egui/tests/it/inactive_set_hint.rs index c6f1f8f1..05742559 100644 --- a/crates/ui-egui/tests/it/inactive_set_hint.rs +++ b/crates/ui-egui/tests/it/inactive_set_hint.rs @@ -12,7 +12,7 @@ const SEARCH_STEP: f32 = 8.0; /// The sample project (the ball is set 0, the base set 1) with the Ball active and the paint tool, at 1600 x 960 fn sample_app() -> Harness<'static, TextureCraftApp> { let session = texturecraft_engine::sample_session(256, 64).unwrap(); - let mut harness = Harness::builder().with_size(egui::vec2(1600.0, 960.0)).build_eframe(|cc| TextureCraftApp::new(cc, session)); + let mut harness = Harness::builder().with_size(egui::vec2(1600.0, 960.0)).with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|cc| TextureCraftApp::new(cc, session)); harness.run_steps(4); assert_eq!(harness.state().session.ts(), 0); assert_eq!(harness.state().session.tool.tool, Tool::Paint); diff --git a/crates/ui-egui/tests/it/instance_properties.rs b/crates/ui-egui/tests/it/instance_properties.rs index d54463ee..9b316f9b 100644 --- a/crates/ui-egui/tests/it/instance_properties.rs +++ b/crates/ui-egui/tests/it/instance_properties.rs @@ -23,7 +23,7 @@ fn instance_harness(dangling: bool) -> (Harness<'static, TextureCraftApp>, Layer session.doc.project.layers.get_mut(&instance).unwrap().kind = LayerKind::Instance { source: GONE }; } execute(&mut session, "layer.select", &json!({"layer": instance.0, "target": "content"})).unwrap(); - let mut harness = Harness::builder().with_size(PROPERTIES_WINDOW).with_step_dt(FRAME_SECONDS).build_eframe(|cc| TextureCraftApp::new(cc, session)); + let mut harness = Harness::builder().with_size(PROPERTIES_WINDOW).with_step_dt(FRAME_SECONDS).with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|cc| TextureCraftApp::new(cc, session)); harness.state_mut().ui.prefs.language = "en".into(); harness.run_steps(STARTUP_FRAMES); (harness, instance, source) diff --git a/crates/ui-egui/tests/it/layer_blending_options.rs b/crates/ui-egui/tests/it/layer_blending_options.rs index d20dc7b4..e4d0812a 100644 --- a/crates/ui-egui/tests/it/layer_blending_options.rs +++ b/crates/ui-egui/tests/it/layer_blending_options.rs @@ -8,7 +8,7 @@ use texturecraft_ui_egui::TextureCraftApp; fn harness() -> Harness<'static, TextureCraftApp> { let session = texturecraft_engine::sample_session(256, 64).unwrap(); - let mut h = Harness::builder().with_size(egui::vec2(1600.0, 960.0)).build_eframe(|cc| TextureCraftApp::new(cc, session)); + let mut h = Harness::builder().with_size(egui::vec2(1600.0, 960.0)).with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|cc| TextureCraftApp::new(cc, session)); h.run_steps(4); h } diff --git a/crates/ui-egui/tests/it/layer_clipboard.rs b/crates/ui-egui/tests/it/layer_clipboard.rs index efcf40c0..6841ca03 100644 --- a/crates/ui-egui/tests/it/layer_clipboard.rs +++ b/crates/ui-egui/tests/it/layer_clipboard.rs @@ -9,7 +9,7 @@ use texturecraft_ui_egui::TextureCraftApp; /// The sample session with its selected layer clicked in the stack, and that layer. fn harness() -> (Harness<'static, TextureCraftApp>, LayerId) { let session = texturecraft_engine::sample_session(256, 64).unwrap(); - let mut h = Harness::builder().with_size(egui::vec2(1600.0, 960.0)).build_eframe(|cc| TextureCraftApp::new(cc, session)); + let mut h = Harness::builder().with_size(egui::vec2(1600.0, 960.0)).with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|cc| TextureCraftApp::new(cc, session)); h.run_steps(4); let layer = h.state().session.selected_layer().unwrap(); let name = h.state().session.doc.project.layers[&layer].name.clone(); @@ -79,7 +79,7 @@ fn layer_shortcuts_act_on_a_selected_effect() { let layer = id(texturecraft_engine::execute(&mut session, "layer.add.fill", &serde_json::Value::Null).unwrap(), "layer"); let p = serde_json::json!({"target": "content", "filter": "invert"}); let effect = id(texturecraft_engine::execute(&mut session, "effect.add.filter", &p).unwrap(), "effect"); - let mut h = Harness::builder().with_size(egui::vec2(1600.0, 960.0)).build_eframe(|cc| TextureCraftApp::new(cc, session)); + let mut h = Harness::builder().with_size(egui::vec2(1600.0, 960.0)).with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|cc| TextureCraftApp::new(cc, session)); h.run_steps(4); let effects = |h: &Harness<'_, TextureCraftApp>| h.state().session.doc.project.layers.get(&layer).map(|l| l.content_effects.len()); h.event(egui::Event::Copy); diff --git a/crates/ui-egui/tests/it/layer_multi_select.rs b/crates/ui-egui/tests/it/layer_multi_select.rs index c0d0054c..23e4c4e4 100644 --- a/crates/ui-egui/tests/it/layer_multi_select.rs +++ b/crates/ui-egui/tests/it/layer_multi_select.rs @@ -15,7 +15,7 @@ fn harness() -> (Harness<'static, TextureCraftApp>, [LayerId; 4]) { let mut session = texturecraft_engine::sample_session(256, 64).unwrap(); let rows = ["Row A", "Row B", "Row C", "Row D"] .map(|name| LayerId(execute(&mut session, "layer.add.paint", &json!({ "name": name })).unwrap()["layer"].as_u64().unwrap())); - let mut h = Harness::builder().with_size(egui::vec2(1600.0, 1200.0)).build_eframe(|cc| TextureCraftApp::new(cc, session)); + let mut h = Harness::builder().with_size(egui::vec2(1600.0, 1200.0)).with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|cc| TextureCraftApp::new(cc, session)); h.run_steps(4); (h, rows) } diff --git a/crates/ui-egui/tests/it/layer_rename.rs b/crates/ui-egui/tests/it/layer_rename.rs index 55b47bd9..4ecec062 100644 --- a/crates/ui-egui/tests/it/layer_rename.rs +++ b/crates/ui-egui/tests/it/layer_rename.rs @@ -9,7 +9,7 @@ use texturecraft_ui_egui::TextureCraftApp; fn harness() -> (Harness<'static, TextureCraftApp>, u64) { let session = texturecraft_engine::sample_session(256, 64).unwrap(); - let mut h = Harness::builder().with_size(egui::vec2(1600.0, 960.0)).build_eframe(|cc| TextureCraftApp::new(cc, session)); + let mut h = Harness::builder().with_size(egui::vec2(1600.0, 960.0)).with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|cc| TextureCraftApp::new(cc, session)); h.run_steps(4); let layer = h.state().session.selected_layer().unwrap().0; (h, layer) diff --git a/crates/ui-egui/tests/it/layer_toolbar.rs b/crates/ui-egui/tests/it/layer_toolbar.rs index 8ba9935e..adb30aa7 100644 --- a/crates/ui-egui/tests/it/layer_toolbar.rs +++ b/crates/ui-egui/tests/it/layer_toolbar.rs @@ -26,7 +26,7 @@ fn app() -> (Harness<'static, TextureCraftApp>, LayerId) { let mut session = texturecraft_engine::sample_session(TEXTURE_RESOLUTION, BAKE_RESOLUTION).unwrap(); let layer = LayerId(execute(&mut session, "layer.add.fill", &Value::Null).unwrap()["layer"].as_u64().unwrap()); execute(&mut session, "layer.select", &json!({"layer": layer.0})).unwrap(); - let mut harness = Harness::builder().with_size(WINDOW_SIZE).build_eframe(|cc| TextureCraftApp::new(cc, session)); + let mut harness = Harness::builder().with_size(WINDOW_SIZE).with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|cc| TextureCraftApp::new(cc, session)); harness.state_mut().ui.prefs.language = "en".into(); harness.run_steps(STARTUP_FRAMES); (harness, layer) @@ -130,6 +130,12 @@ fn the_bitmap_picker_closes_when_the_selection_moves_and_masks_no_other_layer() /// A floating Layers panel this narrow cannot hold the toolbar on one row const NARROW_LAYERS: [f32; 4] = [600.0, 200.0, 200.0, 400.0]; +/// [`NARROW_LAYERS`] as a rect +fn narrow_layers() -> egui::Rect { + let [left, top, width, height] = NARROW_LAYERS; + egui::Rect::from_min_size(egui::pos2(left, top), egui::vec2(width, height)) +} + /// In a narrow floating Layers panel the add-layer buttons and Remove wrap inside it, where a click still reaches them #[test] fn a_narrow_layers_panel_keeps_every_toolbar_button_inside_and_clickable() { @@ -138,7 +144,7 @@ fn a_narrow_layers_panel_keeps_every_toolbar_button_inside_and_clickable() { let (mut harness, _) = app(); let mut workspace = harness.state().ui.dock.workspace().clone(); - workspace.apply_all([Action::Float { panel: Panel::Layers, rect: NARROW_LAYERS }], permissions).unwrap(); + workspace.apply_all([Action::float(Panel::Layers, narrow_layers())], false, permissions).unwrap(); harness.state_mut().ui.dock = Dock::from_value(serde_json::to_value(workspace).unwrap()); harness.run_steps(SETTLE_FRAMES); let [left, _, width, _] = NARROW_LAYERS; diff --git a/crates/ui-egui/tests/it/layers_panel.rs b/crates/ui-egui/tests/it/layers_panel.rs index 4cb38a12..b5b0ba2d 100644 --- a/crates/ui-egui/tests/it/layers_panel.rs +++ b/crates/ui-egui/tests/it/layers_panel.rs @@ -24,7 +24,7 @@ fn harness() -> (Harness<'static, TextureCraftApp>, LayerId) { execute(&mut session, "mask.add.black", &Value::Null).unwrap(); execute(&mut session, "effect.add.generator", &json!({"generator": "position", "level": 0.5, "name": "Effect M"})).unwrap(); execute(&mut session, "layer.select", &json!({"layer": layer.0})).unwrap(); - let mut h = Harness::builder().with_size(egui::vec2(1600.0, 1200.0)).build_eframe(|cc| TextureCraftApp::new(cc, session)); + let mut h = Harness::builder().with_size(egui::vec2(1600.0, 1200.0)).with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|cc| TextureCraftApp::new(cc, session)); h.run_steps(4); (h, layer) } @@ -108,8 +108,9 @@ fn deeply_nested_effect_visibility_is_reachable_in_a_narrow_panel() { execute(&mut harness.state_mut().session, "layer.group", &Value::Null).unwrap(); } - let mut workspace = harness.state().ui.dock.workspace().clone(); - let Some(Node::Split { second, .. }) = workspace.layout.root.as_mut() else { panic!("default columns") }; + let workspace = harness.state().ui.dock.workspace().clone(); + let mut layout = workspace.layout().clone(); + let Some(Node::Split { second, .. }) = layout.root.as_mut() else { panic!("default columns") }; let Node::Split { size, second: column, .. } = second.as_mut() else { panic!("viewport and right column") }; *size = SplitSize::Ratio(0.99); @@ -117,6 +118,7 @@ fn deeply_nested_effect_visibility_is_reachable_in_a_narrow_panel() { let Node::Split { second: below_sets, .. } = column.as_mut() else { panic!("texture sets and the rest") }; let Node::Split { size: layers_share, .. } = below_sets.as_mut() else { panic!("layers and properties") }; *layers_share = SplitSize::Ratio(0.9); + let workspace = texturecraft_ui_egui::docking::Workspace::from_parts(layout, workspace.hidden().to_vec(), workspace.floated().to_vec()); harness.state_mut().ui.dock = Dock::from_value(serde_json::to_value(workspace).unwrap()); // Closing Properties lets the column shrink to the Layers minimum @@ -151,7 +153,7 @@ fn hidpi_harness() -> (Harness<'static, TextureCraftApp>, LayerId) { let layer = LayerId(id(execute(&mut session, "layer.add.fill", &json!({"color": "#336699"})).unwrap(), "layer")); execute(&mut session, "layer.rename", &json!({"layer": layer.0, "name": "Active one"})).unwrap(); execute(&mut session, "layer.select", &json!({"layer": layer.0})).unwrap(); - let mut h = Harness::builder().with_size(egui::vec2(1200.0, 800.0)).with_pixels_per_point(2.0).build_eframe(|cc| TextureCraftApp::new(cc, session)); + let mut h = Harness::builder().with_size(egui::vec2(1200.0, 800.0)).with_pixels_per_point(2.0).with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|cc| TextureCraftApp::new(cc, session)); h.run_steps(4); (h, layer) } @@ -257,7 +259,7 @@ fn narrow_harness() -> Harness<'static, TextureCraftApp> { let mut session = texturecraft_engine::sample_session(256, 64).unwrap(); let layer = id(execute(&mut session, "layer.add.fill", &json!({"color": "#336699"})).unwrap(), "layer"); execute(&mut session, "layer.rename", &json!({"layer": layer, "name": LONG_NAME})).unwrap(); - let mut h = Harness::builder().with_size(egui::vec2(1280.0, 800.0)).build_eframe(|cc| TextureCraftApp::new(cc, session)); + let mut h = Harness::builder().with_size(egui::vec2(1280.0, 800.0)).with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|cc| TextureCraftApp::new(cc, session)); h.state_mut().ui.prefs.language = "en".into(); h.run_steps(4); h @@ -295,7 +297,7 @@ fn an_effect_name_cut_short_shows_in_full_on_hover() { let layer = id(execute(&mut session, "layer.add.fill", &json!({"color": "#336699"})).unwrap(), "layer"); execute(&mut session, "layer.select", &json!({"layer": layer})).unwrap(); execute(&mut session, "effect.add.filter", &json!({"target": "content", "filter": "invert", "name": LONG_EFFECT_NAME})).unwrap(); - let mut h = Harness::builder().with_size(egui::vec2(1280.0, 800.0)).build_eframe(|cc| TextureCraftApp::new(cc, session)); + let mut h = Harness::builder().with_size(egui::vec2(1280.0, 800.0)).with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|cc| TextureCraftApp::new(cc, session)); h.state_mut().ui.prefs.language = "en".into(); h.run_steps(4); diff --git a/crates/ui-egui/tests/it/levels_editor.rs b/crates/ui-egui/tests/it/levels_editor.rs index 0a1656a3..ad687577 100644 --- a/crates/ui-egui/tests/it/levels_editor.rs +++ b/crates/ui-egui/tests/it/levels_editor.rs @@ -40,7 +40,7 @@ fn open(mut session: Session, effect: LayerId) -> (Harness<'static, TextureCraft execute(&mut session, "layer.select", &json!({"layer": layer.0, "target": effect.0})).unwrap(); // Frames of a 60 Hz screen: kittest's default quarter second spreads a double-click past egui's delay - let mut harness = Harness::builder().with_size(PROPERTIES_WINDOW).with_step_dt(FRAME_SECONDS).build_eframe(|cc| TextureCraftApp::new(cc, session)); + let mut harness = Harness::builder().with_size(PROPERTIES_WINDOW).with_step_dt(FRAME_SECONDS).with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|cc| TextureCraftApp::new(cc, session)); harness.run_steps(STARTUP_FRAMES); (harness, effect) } diff --git a/crates/ui-egui/tests/it/log_panel_680.rs b/crates/ui-egui/tests/it/log_panel_680.rs index 52977118..fecd0ab2 100644 --- a/crates/ui-egui/tests/it/log_panel_680.rs +++ b/crates/ui-egui/tests/it/log_panel_680.rs @@ -9,7 +9,7 @@ use texturecraft_ui_egui::docking::Panel; fn app() -> Harness<'static, TextureCraftApp> { let session = texturecraft_engine::sample_session(256, 64).unwrap(); - let mut h = Harness::builder().with_size(egui::vec2(1600.0, 960.0)).build_eframe(|cc| TextureCraftApp::new(cc, session)); + let mut h = Harness::builder().with_size(egui::vec2(1600.0, 960.0)).with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|cc| TextureCraftApp::new(cc, session)); h.state_mut().ui.prefs.language = "en".into(); { let log = &mut h.state_mut().session.log; diff --git a/crates/ui-egui/tests/it/main.rs b/crates/ui-egui/tests/it/main.rs index 831a009a..7c9104fa 100644 --- a/crates/ui-egui/tests/it/main.rs +++ b/crates/ui-egui/tests/it/main.rs @@ -205,7 +205,7 @@ fn click_widget(harness: &mut Harness<'_, TextureCraftApp>, role: egui::Role, la fn panel_close_button(harness: &Harness<'_, TextureCraftApp>, title: egui::Rect) -> egui::Rect { harness .get_all_by_role(egui::Role::Button) - .filter(|button| button.accesskit_node().label().as_deref() == Some("Close Panel")) + .filter(|button| button.accesskit_node().label().is_some_and(|label| label.starts_with("Close "))) .map(|button| button.rect()) .filter(|close| close.min.x > title.max.x && title.y_range().contains(close.center().y)) .min_by(|a, b| a.min.x.total_cmp(&b.min.x)) diff --git a/crates/ui-egui/tests/it/mask_export.rs b/crates/ui-egui/tests/it/mask_export.rs index c58fd4ff..ac84609f 100644 --- a/crates/ui-egui/tests/it/mask_export.rs +++ b/crates/ui-egui/tests/it/mask_export.rs @@ -22,7 +22,7 @@ fn harness(mask: bool) -> Harness<'static, TextureCraftApp> { execute(&mut session, "mask.add.black", &Value::Null).unwrap(); execute(&mut session, "effect.add.fill", &json!({"value": 0.5})).unwrap(); } - let mut h = Harness::builder().with_size(egui::vec2(1600.0, 960.0)).build_eframe(|cc| TextureCraftApp::new(cc, session)); + let mut h = Harness::builder().with_size(egui::vec2(1600.0, 960.0)).with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|cc| TextureCraftApp::new(cc, session)); h.run_steps(4); h } diff --git a/crates/ui-egui/tests/it/mask_fill_rows.rs b/crates/ui-egui/tests/it/mask_fill_rows.rs index efd75314..2c4b50e6 100644 --- a/crates/ui-egui/tests/it/mask_fill_rows.rs +++ b/crates/ui-egui/tests/it/mask_fill_rows.rs @@ -26,7 +26,7 @@ fn app_with_mask_fill(projection: &str) -> (Harness<'static, TextureCraftApp>, L let added = texturecraft_engine::execute(&mut session, "effect.add.fill", &json!({"layer": layer.0, "target": "mask", "projection": projection})).unwrap(); let effect = LayerId(added["effect"].as_u64().unwrap()); texturecraft_engine::execute(&mut session, "layer.select", &json!({"layer": layer.0, "target": effect.0})).unwrap(); - let mut harness = Harness::builder().with_size(WINDOW_SIZE).build_eframe(|cc| TextureCraftApp::new(cc, session)); + let mut harness = Harness::builder().with_size(WINDOW_SIZE).with_context_setup(texturecraft_ui_egui::framework::install_headless).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(); @@ -146,7 +146,7 @@ fn a_mask_fill_reading_a_content_anchor_picks_its_channel() { let added = texturecraft_engine::execute(&mut session, "effect.add.fill", &json!({"layer": top, "target": "mask", "anchor": anchor})).unwrap(); let effect = LayerId(added["effect"].as_u64().unwrap()); texturecraft_engine::execute(&mut session, "layer.select", &json!({"layer": top, "target": effect.0})).unwrap(); - let mut harness = Harness::builder().with_size(WINDOW_SIZE).build_eframe(|cc| TextureCraftApp::new(cc, session)); + let mut harness = Harness::builder().with_size(WINDOW_SIZE).with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|cc| TextureCraftApp::new(cc, session)); harness.state_mut().ui.prefs.language = "en".into(); harness.run_steps(STARTUP_FRAMES); let Source::Anchor { channel, .. } = mask_fill(&harness, effect).0 else { panic!("an anchor source") }; @@ -176,7 +176,7 @@ fn an_inherited_mask_fill_lists_only_anchors_below_its_owner() { let instance = texturecraft_engine::execute(&mut session, "layer.instance", &json!({"layer": source})).unwrap()["layer"].clone(); texturecraft_engine::execute(&mut session, "layer.select", &json!({"layer": instance})).unwrap(); session.target = texturecraft_engine::StackTarget::Effect(effect); - let mut harness = Harness::builder().with_size(WINDOW_SIZE).build_eframe(|cc| TextureCraftApp::new(cc, session)); + let mut harness = Harness::builder().with_size(WINDOW_SIZE).with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|cc| TextureCraftApp::new(cc, session)); harness.state_mut().ui.prefs.language = "en".into(); harness.run_steps(STARTUP_FRAMES); diff --git a/crates/ui-egui/tests/it/mask_paint_grayscale.rs b/crates/ui-egui/tests/it/mask_paint_grayscale.rs index cc70af4f..110222d6 100644 --- a/crates/ui-egui/tests/it/mask_paint_grayscale.rs +++ b/crates/ui-egui/tests/it/mask_paint_grayscale.rs @@ -26,7 +26,7 @@ fn folder_mask_harness() -> (Harness<'static, TextureCraftApp>, String) { let folder = LayerId(execute(&mut session, "layer.add.group", &json!({})).unwrap()["layer"].as_u64().unwrap()); execute(&mut session, "mask.add.white", &json!({"layer": folder.0})).unwrap(); execute(&mut session, "layer.select", &json!({"layer": folder.0, "target": "mask"})).unwrap(); - let mut harness = Harness::builder().with_size(PROPERTIES_WINDOW).with_step_dt(FRAME_SECONDS).build_eframe(|cc| TextureCraftApp::new(cc, session)); + let mut harness = Harness::builder().with_size(PROPERTIES_WINDOW).with_step_dt(FRAME_SECONDS).with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|cc| TextureCraftApp::new(cc, session)); harness.state_mut().ui.prefs.language = "en".into(); harness.state_mut().ui.props_tab = PropsTab::Material; harness.run_steps(STARTUP_FRAMES); diff --git a/crates/ui-egui/tests/it/mask_value_swap.rs b/crates/ui-egui/tests/it/mask_value_swap.rs index d5f22ebc..8f098a21 100644 --- a/crates/ui-egui/tests/it/mask_value_swap.rs +++ b/crates/ui-egui/tests/it/mask_value_swap.rs @@ -9,7 +9,7 @@ fn harness() -> Harness<'static, TextureCraftApp> { let mut session = texturecraft_engine::sample_session(256, 64).unwrap(); texturecraft_engine::execute(&mut session, "mask.add.white", &serde_json::Value::Null).unwrap(); session.target = StackTarget::Mask; - let mut harness = Harness::builder().with_size(egui::vec2(1600.0, 960.0)).build_eframe(|context| TextureCraftApp::new(context, session)); + let mut harness = Harness::builder().with_size(egui::vec2(1600.0, 960.0)).with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|context| TextureCraftApp::new(context, session)); harness.run_steps(4); harness diff --git a/crates/ui-egui/tests/it/named_layouts.rs b/crates/ui-egui/tests/it/named_layouts.rs index 2c577f9d..854509af 100644 --- a/crates/ui-egui/tests/it/named_layouts.rs +++ b/crates/ui-egui/tests/it/named_layouts.rs @@ -10,7 +10,7 @@ use texturecraft_ui_egui::state::Mode; fn app() -> Harness<'static, TextureCraftApp> { let session = texturecraft_engine::sample_session(256, 64).unwrap(); let mut harness = - Harness::builder().with_size(egui::vec2(1600.0, 960.0)).with_accessibility_check(false).build_eframe(|cc| TextureCraftApp::new(cc, session)); + Harness::builder().with_size(egui::vec2(1600.0, 960.0)).with_accessibility_check(false).with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|cc| TextureCraftApp::new(cc, session)); harness.run_steps(4); harness } diff --git a/crates/ui-egui/tests/it/nav_buttons.rs b/crates/ui-egui/tests/it/nav_buttons.rs index b21569e0..2f5829cb 100644 --- a/crates/ui-egui/tests/it/nav_buttons.rs +++ b/crates/ui-egui/tests/it/nav_buttons.rs @@ -17,7 +17,7 @@ const WINDOW: egui::Vec2 = vec2(1280.0, 800.0); /// The app showing only one view, so that the view fills the viewport rect the 3D view reports fn app(layout: ViewLayout) -> (Harness<'static, TextureCraftApp>, Rect) { let session = texturecraft_engine::sample_session(256, 64).unwrap(); - let mut harness = Harness::builder().with_size(WINDOW).with_pixels_per_point(1.0).build_eframe(|cc| TextureCraftApp::new(cc, session)); + let mut harness = Harness::builder().with_size(WINDOW).with_pixels_per_point(1.0).with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|cc| TextureCraftApp::new(cc, session)); harness.state_mut().session.tool.tool = texturecraft_engine::Tool::Paint; harness.state_mut().ui.layout = ViewLayout::Only3D; harness.run_steps(4); diff --git a/crates/ui-egui/tests/it/new_project_baked_maps.rs b/crates/ui-egui/tests/it/new_project_baked_maps.rs index d171b8ef..5baf3251 100644 --- a/crates/ui-egui/tests/it/new_project_baked_maps.rs +++ b/crates/ui-egui/tests/it/new_project_baked_maps.rs @@ -19,7 +19,7 @@ fn harness_for(dir: &Path) -> Harness<'static, TextureCraftApp> { let mesh = dir.join("Ball.obj"); std::fs::write(&mesh, TWO_MATERIALS).unwrap(); let session = texturecraft_engine::sample_session(256, 64).unwrap(); - let mut h = Harness::builder().with_size(egui::vec2(1600.0, 960.0)).build_eframe(|cc| TextureCraftApp::new(cc, session)); + let mut h = Harness::builder().with_size(egui::vec2(1600.0, 960.0)).with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|cc| TextureCraftApp::new(cc, session)); h.state_mut().ui.windows.new_project = true; h.state_mut().ui.new_project.resolution = 256; h.state_mut().ui.new_project.file = Some(mesh.display().to_string()); @@ -129,7 +129,7 @@ fn new_project_baked_maps_snapshots() { let output_dir = PathBuf::from(std::env::var_os("TC_UI_SNAPSHOTS").expect("set TC_UI_SNAPSHOTS")); std::fs::create_dir_all(&output_dir).unwrap(); let session = texturecraft_engine::sample_session(256, 64).unwrap(); - let mut h = Harness::builder().with_size(egui::vec2(1600.0, 960.0)).with_pixels_per_point(1.0).wgpu().build_eframe(|cc| { + let mut h = Harness::builder().with_size(egui::vec2(1600.0, 960.0)).with_pixels_per_point(1.0).wgpu().with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|cc| { let adapter = cc.wgpu_render_state.as_ref().unwrap().adapter.get_info(); eprintln!("snapshot adapter: {adapter:?}"); TextureCraftApp::new(cc, session) diff --git a/crates/ui-egui/tests/it/new_project_window.rs b/crates/ui-egui/tests/it/new_project_window.rs index 401cf728..94436fa7 100644 --- a/crates/ui-egui/tests/it/new_project_window.rs +++ b/crates/ui-egui/tests/it/new_project_window.rs @@ -21,7 +21,7 @@ fn harness() -> Harness<'static, TextureCraftApp> { fn harness_sized(size: egui::Vec2) -> Harness<'static, TextureCraftApp> { let session = texturecraft_engine::Session::new_project("Open", texturecraft_engine::geom::primitives::cube(1.0), "builtin:cube", None, 128).unwrap(); - let mut h = Harness::builder().with_size(size).build_eframe(|cc| TextureCraftApp::new(cc, session)); + let mut h = Harness::builder().with_size(size).with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|cc| TextureCraftApp::new(cc, session)); h.state_mut().ui.prefs.language = "en".into(); h.run_steps(2); let ctx = h.ctx.clone(); diff --git a/crates/ui-egui/tests/it/output_templates.rs b/crates/ui-egui/tests/it/output_templates.rs index aaf66fce..308db067 100644 --- a/crates/ui-egui/tests/it/output_templates.rs +++ b/crates/ui-egui/tests/it/output_templates.rs @@ -15,7 +15,7 @@ use template_library::TemplateLibrary; /// OUTPUT TEMPLATES with the user template "Mine" selected fn harness(library: &TemplateLibrary) -> Harness<'static, TextureCraftApp> { let session = texturecraft_engine::sample_session(256, 64).unwrap(); - let mut h = Harness::builder().with_size(egui::vec2(1600.0, 960.0)).build_eframe(|cc| TextureCraftApp::new(cc, session)); + let mut h = Harness::builder().with_size(egui::vec2(1600.0, 960.0)).with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|cc| TextureCraftApp::new(cc, session)); h.state_mut().ui.prefs.language = "en".into(); h.run_steps(4); h.state_mut().session.load_export_presets(library.0.clone()); diff --git a/crates/ui-egui/tests/it/panel_header.rs b/crates/ui-egui/tests/it/panel_header.rs index 50be40c0..7227a327 100644 --- a/crates/ui-egui/tests/it/panel_header.rs +++ b/crates/ui-egui/tests/it/panel_header.rs @@ -1,22 +1,18 @@ -//! Every docked panel group sits under one header bar: its names at the left, the shown one raised as a box when the group has several, a close × at the right +//! Every docked panel group's header ends in its close button, and the Properties header names what it shows -use craft_behavior::dock::{Action, DockPlacement}; use egui::Role; use egui_kittest::Harness; use egui_kittest::kittest::{NodeT, Queryable}; use texturecraft_ui_egui::TextureCraftApp; -use texturecraft_ui_egui::docking::{Dock, Panel, permissions}; +use texturecraft_ui_egui::docking::Panel; use crate::{BAKE_RESOLUTION, SETTLE_FRAMES, STARTUP_FRAMES, TEXTURE_RESOLUTION, click_at, panel_close_button}; const WINDOW_SIZE: egui::Vec2 = egui::vec2(1600.0, 960.0); -/// A floating window over the viewport, `[x, y, width, height]` -const FLOATING_RECT: [f32; 4] = [600.0, 200.0, 320.0, 400.0]; - fn app() -> Harness<'static, TextureCraftApp> { let session = texturecraft_engine::sample_session(TEXTURE_RESOLUTION, BAKE_RESOLUTION).unwrap(); - let mut harness = Harness::builder().with_size(WINDOW_SIZE).build_eframe(|cc| TextureCraftApp::new(cc, session)); + let mut harness = Harness::builder().with_size(WINDOW_SIZE).with_context_setup(texturecraft_ui_egui::framework::install_headless).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(); @@ -85,178 +81,6 @@ fn the_properties_header_names_the_selected_effects_type() { tab_rect(&harness, "Properties - Levels"); } -/// How far a header under another panel reaches above its tab strip: the 6 px gutter less a 2 px separation (docking/header_band.rs) -const HEADER_RISE: f32 = 4.0; - -/// Room between a later tab's box and its tab's left edge (docking/shown_group_tab.rs, private to the crate) -const BOX_INSET: f32 = 4.0; - -/// Rounded boxes painted this frame over `tab` whose top is `rise` above it: the raised box of a shown tab -fn tab_boxes(harness: &Harness<'_, TextureCraftApp>, tab: egui::Rect, rise: f32) -> Vec { - harness - .output() - .shapes - .iter() - .filter_map(|shape| match &shape.shape { - egui::Shape::Rect(rect) => { - let rises = (rect.rect.top() - (tab.top() - rise)).abs() < 0.5; - let raised = rises && rect.corner_radius != egui::CornerRadius::ZERO && tab.x_range().contains(rect.rect.center().x); - raised.then_some(rect.rect) - } - _ => None, - }) - .collect() -} - -#[test] -fn a_groups_shown_tab_rises_as_a_box_and_the_others_and_a_lone_panels_do_not() { - let mut harness = app(); - let layers = tab_rect(&harness, "Layers"); - let settings = tab_rect(&harness, "Texture Set Settings"); - - assert_eq!(tab_boxes(&harness, layers, HEADER_RISE).len(), 1, "the shown Layers tab has its box, from the top of its header band"); - assert_eq!(tab_boxes(&harness, settings, HEADER_RISE).len(), 0, "the hidden tab is its name only"); - assert_eq!(tab_boxes(&harness, tab_rect(&harness, "Properties - "), HEADER_RISE).len(), 0, "a panel alone keeps its plain header"); - - click_at(&mut harness, settings.center()); - harness.run_steps(SETTLE_FRAMES); - - assert_eq!(tab_boxes(&harness, tab_rect(&harness, "Texture Set Settings"), HEADER_RISE).len(), 1, "the box goes with the shown tab"); - assert_eq!(tab_boxes(&harness, tab_rect(&harness, "Layers"), HEADER_RISE).len(), 0); -} - -#[test] -fn the_selected_dock_tab_keeps_its_keyboard_focus_outline_visible() { - let mut harness = app(); - let layers = tab_rect(&harness, "Layers"); - let tab_id = egui::Id::unique("texturecraft-docking").with(("tab", Panel::Layers)); - harness.ctx.memory_mut(|memory| memory.request_focus(tab_id)); - harness.run_steps(SETTLE_FRAMES); - - assert_eq!(harness.ctx.memory(|memory| memory.focused()), Some(tab_id)); - let raised_box = tab_boxes(&harness, layers, HEADER_RISE)[0]; - let shapes = &harness.output().shapes; - let box_index = shapes.iter().position(|shape| matches!(&shape.shape, egui::Shape::Rect(rect) if rect.rect == raised_box)).unwrap(); - assert!( - shapes[box_index + 1..].iter().any(|shape| { - matches!(&shape.shape, egui::Shape::Rect(rect) - if rect.stroke.width > 0.0 && layers.contains_rect(rect.rect) && rect.rect.contains(layers.center())) - }), - "the focus outline is painted above the selected tab" - ); -} - -#[test] -fn the_first_tabs_box_starts_on_the_panels_edge_and_a_later_tabs_box_keeps_its_inset() { - let mut harness = app(); - let layers = tab_rect(&harness, "Layers"); - let boxes = tab_boxes(&harness, layers, HEADER_RISE); - assert!(!boxes.is_empty(), "the shown Layers tab has its box"); - assert!(boxes.iter().all(|shown| (shown.left() - layers.left()).abs() < 0.5), "{boxes:?} starts on the panel's left edge {}", layers.left()); - - let settings = tab_rect(&harness, "Texture Set Settings"); - - click_at(&mut harness, settings.center()); - harness.run_steps(SETTLE_FRAMES); - - let boxes = tab_boxes(&harness, settings, HEADER_RISE); - assert!(!boxes.is_empty(), "the shown Texture Set Settings tab has its box"); - assert!(boxes.iter().all(|shown| (shown.left() - (settings.left() + BOX_INSET)).abs() < 0.5), "{boxes:?} keeps its air from the Layers tab"); -} - -/// The middle of the first capital's ink in each painted text reading `name` -fn capital_middles(harness: &Harness<'_, TextureCraftApp>, name: &str) -> Vec { - harness - .output() - .shapes - .iter() - .filter_map(|shape| match &shape.shape { - egui::Shape::Text(text) if text.galley.text() == name => { - let row = text.galley.rows.first()?; - let glyph = row.glyphs.iter().find(|glyph| glyph.chr.is_uppercase())?; - Some(text.pos.y + row.pos.y + glyph.pos.y + glyph.uv_rect.offset.y + glyph.uv_rect.size.y / 2.0) - } - _ => None, - }) - .collect() -} - -/// Names' capitals and the close × share the header band's middle: the tab strip plus, under another panel, the gutter above it less the separation -#[test] -fn header_names_capitals_and_close_buttons_sit_on_the_header_bands_middle() { - let harness = app(); - let headers = [ - ("Texture Sets", "TEXTURE SETS", 0.0), - ("Layers", "LAYERS", HEADER_RISE), - ("Texture Set Settings", "TEXTURE SET SETTINGS", HEADER_RISE), - ("Properties - ", "PROPERTIES - PAINT", HEADER_RISE), - ]; - for (tab, name, rise) in headers { - let tab = tab_rect(&harness, tab); - let middle = (tab.top() - rise + tab.bottom()) / 2.0; - let capitals = capital_middles(&harness, name); - assert!(!capitals.is_empty(), "{name} is painted"); - assert!(capitals.iter().all(|capital| (capital - middle).abs() < 0.75), "{name}'s capitals at {capitals:?}, its band's middle at {middle}"); - } - - let properties = tab_rect(&harness, "Properties - "); - let close = panel_close_button(&harness, properties); - let middle = (properties.top() - HEADER_RISE + properties.bottom()) / 2.0; - assert!((close.center().y - middle).abs() < 0.5, "the close × at {}, the band's middle at {middle}", close.center().y); -} - -/// A floating group's names sit on one line: the shown name, painted again over its tab, and the dimmed one beside it (the dimmed one kept its galley's middle) -#[test] -fn a_floating_groups_names_share_one_line() { - let mut harness = app(); - let mut workspace = harness.state().ui.dock.workspace().clone(); - let actions = [ - Action::Float { panel: Panel::Properties, rect: FLOATING_RECT }, - Action::Move { panel: Panel::TextureSetSettings, anchor: Panel::Properties, placement: DockPlacement::Tab { before: None } }, - Action::Activate { panel: Panel::Properties }, - ]; - workspace.apply_all(actions, permissions).unwrap(); - harness.state_mut().ui.dock = Dock::from_value(serde_json::to_value(workspace).unwrap()); - harness.run_steps(SETTLE_FRAMES); - - let shown = capital_middles(&harness, "PROPERTIES - PAINT"); - let dimmed = capital_middles(&harness, "TEXTURE SET SETTINGS"); - assert!(!shown.is_empty() && !dimmed.is_empty(), "both names are painted"); - assert!(shown.iter().chain(&dimmed).all(|capital| (capital - shown[0]).abs() < 0.5), "the shown name's capitals at {shown:?}, the other's at {dimmed:?}"); -} - -/// The tab menu's panel names keep their plain layout: only the header bar pads a name to centre its capitals on the band -#[test] -fn a_tab_menus_panel_names_keep_their_plain_layout() { - let mut harness = app(); - let properties = tab_rect(&harness, "Properties - "); - let button = egui::PointerButton::Secondary; - harness.hover_at(properties.center()); - for pressed in [true, false] { - harness.event(egui::Event::PointerButton { pos: properties.center(), button, pressed, modifiers: egui::Modifiers::NONE }); - harness.run_steps(1); - } - harness.run_steps(SETTLE_FRAMES); - - let move_to = harness.get_by_role_and_label(Role::Button, "Move Panel to Group").rect(); - harness.hover_at(move_to.center()); - harness.run_steps(SETTLE_FRAMES); - - let entry = harness.get_by_role_and_label(Role::Button, "Layers").rect(); - let padded: Vec = harness - .output() - .shapes - .iter() - .filter_map(|shape| match &shape.shape { - egui::Shape::Text(text) if text.galley.text() == "LAYERS" && entry.contains(text.pos) => Some(text.galley.job.first_row_min_height), - _ => None, - }) - .collect(); - - assert!(!padded.is_empty(), "the menu paints the Layers entry"); - assert!(padded.iter().all(|height| *height == 0.0), "the Layers entry is padded to {padded:?}"); -} - /// Where the label on `name`'s row and to its right ends, for each label named `name` fn row_ends(harness: &Harness<'_, TextureCraftApp>, name: &str) -> Vec { let names = harness.get_all_by_role_and_label(Role::Label, name).map(|node| node.rect()); diff --git a/crates/ui-egui/tests/it/path_in_view.rs b/crates/ui-egui/tests/it/path_in_view.rs index f24e6b46..a3d5908c 100644 --- a/crates/ui-egui/tests/it/path_in_view.rs +++ b/crates/ui-egui/tests/it/path_in_view.rs @@ -22,7 +22,7 @@ fn harness() -> AppHarness<'static> { execute(&mut session, "layer.add.paint", &serde_json::Value::Null).unwrap(); execute(&mut session, "tool.select", &json!({"tool": "path"})).unwrap(); // Tall enough that the 2D view's texture square takes A, B and C - let mut h = Harness::builder().with_size(egui::vec2(1600.0, 1500.0)).build_eframe(|cc| TextureCraftApp::new(cc, session)); + let mut h = Harness::builder().with_size(egui::vec2(1600.0, 1500.0)).with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|cc| TextureCraftApp::new(cc, session)); h.state_mut().ui.layout = ViewLayout::Only2D; h.run_steps(4); h @@ -156,7 +156,7 @@ fn clicking_the_2d_view_preserves_a_stored_3d_path_being_edited() { let before = session.doc.clone(); let path = session.tool.path.clone(); let history = session.history_labels(); - let mut harness = Harness::builder().with_size(egui::vec2(1600.0, 960.0)).build_eframe(|context| TextureCraftApp::new(context, session)); + let mut harness = Harness::builder().with_size(egui::vec2(1600.0, 960.0)).with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|context| TextureCraftApp::new(context, session)); harness.state_mut().ui.layout = ViewLayout::Split; harness.run_steps(4); let view_3d = harness.state().viewport_rect; @@ -213,7 +213,7 @@ fn split_harness() -> (AppHarness<'static>, Pos2, Pos2) { session.update(); execute(&mut session, "layer.add.paint", &serde_json::Value::Null).unwrap(); execute(&mut session, "tool.select", &json!({"tool": "path"})).unwrap(); - let mut harness = Harness::builder().with_size(egui::vec2(1600.0, 960.0)).build_eframe(|context| TextureCraftApp::new(context, session)); + let mut harness = Harness::builder().with_size(egui::vec2(1600.0, 960.0)).with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|context| TextureCraftApp::new(context, session)); harness.state_mut().ui.layout = ViewLayout::Split; harness.run_steps(4); let view_3d = harness.state().viewport_rect; diff --git a/crates/ui-egui/tests/it/path_list.rs b/crates/ui-egui/tests/it/path_list.rs index 799ba000..bf9a6dab 100644 --- a/crates/ui-egui/tests/it/path_list.rs +++ b/crates/ui-egui/tests/it/path_list.rs @@ -14,7 +14,7 @@ fn path_rows_edit_and_remove_paths() { let r = execute(&mut session, "tool.path", &json!({"uvPoints": [[0.2, 0.5], [0.5, 0.4], [0.8, 0.5]], "commit": true})).unwrap(); let eid = LayerId(r["committed"]["effect"].as_u64().unwrap()); execute(&mut session, "tool.path", &json!({"uvPoints": [[0.2, 0.8], [0.8, 0.8]], "commit": true})).unwrap(); - let mut h = Harness::builder().with_size(egui::vec2(1600.0, 1400.0)).build_eframe(|cc| TextureCraftApp::new(cc, session)); + let mut h = Harness::builder().with_size(egui::vec2(1600.0, 1400.0)).with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|cc| TextureCraftApp::new(cc, session)); h.run_steps(4); let editing = |h: &Harness<'_, TextureCraftApp>| h.state().session.tool.path.editing; let count = |h: &Harness<'_, TextureCraftApp>| h.state().session.paths(eid).map_or(0, <[_]>::len); diff --git a/crates/ui-egui/tests/it/pen_pressure.rs b/crates/ui-egui/tests/it/pen_pressure.rs index 36b67d2b..43b2a692 100644 --- a/crates/ui-egui/tests/it/pen_pressure.rs +++ b/crates/ui-egui/tests/it/pen_pressure.rs @@ -24,7 +24,7 @@ fn frame(harness: &mut Harness<'_, TextureCraftApp>, pen: Option<(TouchPhase, Op /// Paint in the 2D view with `input` and return the summed base color alpha it added. fn paint_2d(input: impl FnOnce(&mut Harness<'_, TextureCraftApp>)) -> f64 { let session = texturecraft_engine::sample_session(256, 64).unwrap(); - let mut harness = Harness::builder().with_size(egui::vec2(1600.0, 1500.0)).build_eframe(|creation_context| TextureCraftApp::new(creation_context, session)); + let mut harness = Harness::builder().with_size(egui::vec2(1600.0, 1500.0)).with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|creation_context| TextureCraftApp::new(creation_context, session)); harness.state_mut().ui.layout = ViewLayout::Only2D; harness.state_mut().session.tool.brush.min_size = 0.0; harness.run_steps(4); diff --git a/crates/ui-egui/tests/it/polygon_fill.rs b/crates/ui-egui/tests/it/polygon_fill.rs index ac418f44..e4df7fb0 100644 --- a/crates/ui-egui/tests/it/polygon_fill.rs +++ b/crates/ui-egui/tests/it/polygon_fill.rs @@ -9,7 +9,7 @@ use texturecraft_ui_egui::TextureCraftApp; /// The sample project in the default split layout at 1600 x 960 with the polygon fill tool fn polygon_fill_app() -> Harness<'static, TextureCraftApp> { let session = texturecraft_engine::sample_session(256, 64).unwrap(); - let mut harness = Harness::builder().with_size(egui::vec2(1600.0, 960.0)).build_eframe(|cc| TextureCraftApp::new(cc, session)); + let mut harness = Harness::builder().with_size(egui::vec2(1600.0, 960.0)).with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|cc| TextureCraftApp::new(cc, session)); harness.state_mut().session.tool.tool = Tool::PolygonFill; harness.run_steps(4); harness @@ -138,7 +138,7 @@ fn polygon_fill_snapshots() { std::fs::create_dir_all(&directory).unwrap(); let session = texturecraft_engine::sample_session(256, 64).unwrap(); - let mut harness = Harness::builder().with_size(vec2(1600.0, 960.0)).wgpu().build_eframe(|context| TextureCraftApp::new(context, session)); + let mut harness = Harness::builder().with_size(vec2(1600.0, 960.0)).wgpu().with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|context| TextureCraftApp::new(context, session)); let adapter = harness.state().render_state.as_ref().unwrap().adapter.get_info(); eprintln!("Offscreen adapter: {} ({:?}), driver {} {}", adapter.name, adapter.backend, adapter.driver, adapter.driver_info); harness.state_mut().session.tool.tool = Tool::PolygonFill; diff --git a/crates/ui-egui/tests/it/popup_press_close.rs b/crates/ui-egui/tests/it/popup_press_close.rs index 05f4f673..58acc3b4 100644 --- a/crates/ui-egui/tests/it/popup_press_close.rs +++ b/crates/ui-egui/tests/it/popup_press_close.rs @@ -27,7 +27,7 @@ fn app(storage: &MemoryStorage) -> Harness<'static, TextureCraftApp> { // The view has no accessible name of its own; these tests drive it by position let builder = Harness::builder().with_size(PROPERTIES_WINDOW).with_accessibility_check(false); - let mut harness = builder.build_eframe(|context| { + let mut harness = builder.with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|context| { let mut creation = eframe::CreationContext::_new_kittest(context.egui_ctx.clone()); creation.storage = Some(storage); TextureCraftApp::new(&creation, session) diff --git a/crates/ui-egui/tests/it/project_config.rs b/crates/ui-egui/tests/it/project_config.rs index 2bbd3939..3308314b 100644 --- a/crates/ui-egui/tests/it/project_config.rs +++ b/crates/ui-egui/tests/it/project_config.rs @@ -28,7 +28,7 @@ fn app_on_a_quad(dir: &std::path::Path) -> Harness<'static, TextureCraftApp> { let mut session = Session::from_mesh_bytes("quad.obj", QUAD.as_bytes(), 128, "quad").unwrap(); texturecraft_engine::execute(&mut session, "layer.add.fill", &json!({"color": [1.0, 0.0, 0.0]})).unwrap(); session.doc.project.mesh_path = file.display().to_string(); - let mut h = Harness::builder().with_size(egui::vec2(1600.0, 960.0)).build_eframe(|cc| TextureCraftApp::new(cc, session)); + let mut h = Harness::builder().with_size(egui::vec2(1600.0, 960.0)).with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|cc| TextureCraftApp::new(cc, session)); h.state_mut().ui.prefs.language = "en".into(); h.run_steps(4); @@ -742,7 +742,7 @@ fn project_config_snapshots() { 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)); + let mut h = Harness::builder().with_size(egui::vec2(1600.0, 960.0)).with_pixels_per_point(1.0).wgpu().with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|cc| TextureCraftApp::new(cc, session)); h.run_steps(6); open_window(&mut h); h.run_steps(6); diff --git a/crates/ui-egui/tests/it/properties_lists.rs b/crates/ui-egui/tests/it/properties_lists.rs index 768b5d06..37b5e973 100644 --- a/crates/ui-egui/tests/it/properties_lists.rs +++ b/crates/ui-egui/tests/it/properties_lists.rs @@ -29,7 +29,7 @@ const ESCAPES_TO_CLEAR: usize = 2; fn screen(setup: impl FnOnce(&mut Session)) -> Harness<'static, TextureCraftApp> { let mut session = texturecraft_engine::sample_session(TEXTURE_RESOLUTION, BAKE_RESOLUTION).unwrap(); setup(&mut session); - let mut harness = Harness::builder().with_size(PROPERTIES_WINDOW).with_accessibility_check(false).build_eframe(|cc| TextureCraftApp::new(cc, session)); + let mut harness = Harness::builder().with_size(PROPERTIES_WINDOW).with_accessibility_check(false).with_context_setup(texturecraft_ui_egui::framework::install_headless).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(); diff --git a/crates/ui-egui/tests/it/properties_min_width.rs b/crates/ui-egui/tests/it/properties_min_width.rs index bf873830..3b2f2faa 100644 --- a/crates/ui-egui/tests/it/properties_min_width.rs +++ b/crates/ui-egui/tests/it/properties_min_width.rs @@ -26,7 +26,7 @@ const WINDOW_RIGHT_INSET: f32 = 4.0; fn app() -> Harness<'static, TextureCraftApp> { let session = texturecraft_engine::sample_session(TEXTURE_RESOLUTION, BAKE_RESOLUTION).unwrap(); - let mut harness = Harness::builder().with_size(WINDOW_SIZE).build_eframe(|cc| TextureCraftApp::new(cc, session)); + let mut harness = Harness::builder().with_size(WINDOW_SIZE).with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|cc| TextureCraftApp::new(cc, session)); // The header names below are English; a first run would speak the system's language harness.state_mut().ui.prefs.language = "en".into(); @@ -36,11 +36,13 @@ fn app() -> Harness<'static, TextureCraftApp> { /// Gives the right column (Layers over Properties) `width` points, as a layout saved at that width would fn set_column_width(harness: &mut Harness<'_, TextureCraftApp>, width: f32) { - let mut workspace = harness.state().ui.dock.workspace().clone(); - let Some(Node::Split { second, .. }) = workspace.layout.root.as_mut() else { panic!("the assets column and the rest") }; + let workspace = harness.state().ui.dock.workspace().clone(); + let mut layout = workspace.layout().clone(); + let Some(Node::Split { second, .. }) = layout.root.as_mut() else { panic!("the assets column and the rest") }; let Node::Split { size, .. } = second.as_mut() else { panic!("the 3D view and the right column") }; *size = SplitSize::FixedSecond(width); + let workspace = texturecraft_ui_egui::docking::Workspace::from_parts(layout, workspace.hidden().to_vec(), workspace.floated().to_vec()); harness.state_mut().ui.dock = Dock::from_value(serde_json::to_value(workspace).unwrap()); harness.run_steps(SETTLE_FRAMES); } diff --git a/crates/ui-egui/tests/it/properties_popup.rs b/crates/ui-egui/tests/it/properties_popup.rs index fd2bc6be..fa13ae62 100644 --- a/crates/ui-egui/tests/it/properties_popup.rs +++ b/crates/ui-egui/tests/it/properties_popup.rs @@ -42,7 +42,7 @@ fn harness() -> Harness<'static, TextureCraftApp> { /// The sample project's app in a window of `size`, speaking English fn harness_sized(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)); + let mut harness = Harness::builder().with_size(size).with_context_setup(texturecraft_ui_egui::framework::install_headless).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(); diff --git a/crates/ui-egui/tests/it/properties_scroll.rs b/crates/ui-egui/tests/it/properties_scroll.rs index e4c15155..d6590e8f 100644 --- a/crates/ui-egui/tests/it/properties_scroll.rs +++ b/crates/ui-egui/tests/it/properties_scroll.rs @@ -50,7 +50,7 @@ fn harness_sized(size: egui::Vec2) -> Harness<'static, TextureCraftApp> { execute(&mut session, "layer.fill.projection", &json!({"layer": layer, "projection": "uv"})).unwrap(); } - let mut harness = Harness::builder().with_size(size).build_eframe(|cc| TextureCraftApp::new(cc, session)); + let mut harness = Harness::builder().with_size(size).with_context_setup(texturecraft_ui_egui::framework::install_headless).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(); diff --git a/crates/ui-egui/tests/it/rail.rs b/crates/ui-egui/tests/it/rail.rs index b6b3617b..933218d1 100644 --- a/crates/ui-egui/tests/it/rail.rs +++ b/crates/ui-egui/tests/it/rail.rs @@ -33,7 +33,7 @@ fn app() -> Harness<'static, TextureCraftApp> { 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)); + let mut harness = Harness::builder().with_size(size).with_context_setup(texturecraft_ui_egui::framework::install_headless).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(); @@ -189,7 +189,7 @@ fn dragging_the_title_onto_a_tab_strip_docks_the_panel_there() { drag(&mut harness, title.center(), texture_sets_tab.center()); - let layout = &harness.state().ui.dock.workspace().layout; + 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"); } diff --git a/crates/ui-egui/tests/it/reference_order.rs b/crates/ui-egui/tests/it/reference_order.rs index f41e2529..aa2b0c09 100644 --- a/crates/ui-egui/tests/it/reference_order.rs +++ b/crates/ui-egui/tests/it/reference_order.rs @@ -8,7 +8,7 @@ use texturecraft_engine::Session; use texturecraft_ui_egui::{TextureCraftApp, menus}; fn harness(session: Session) -> Harness<'static, TextureCraftApp> { - let mut harness = Harness::builder().with_size(egui::vec2(1600.0, 960.0)).build_eframe(|cc| TextureCraftApp::new(cc, session)); + let mut harness = Harness::builder().with_size(egui::vec2(1600.0, 960.0)).with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|cc| TextureCraftApp::new(cc, session)); harness.state_mut().ui.prefs.language = "en".into(); harness.run_steps(4); harness diff --git a/crates/ui-egui/tests/it/rename_anchor.rs b/crates/ui-egui/tests/it/rename_anchor.rs index 9c29a765..f66003fc 100644 --- a/crates/ui-egui/tests/it/rename_anchor.rs +++ b/crates/ui-egui/tests/it/rename_anchor.rs @@ -22,7 +22,7 @@ fn id(v: &Value, key: &str) -> u64 { } fn harness_for(session: Session) -> Harness<'static, TextureCraftApp> { - let mut h = Harness::builder().with_size(egui::vec2(1600.0, 1400.0)).build_eframe(|cc| TextureCraftApp::new(cc, session)); + let mut h = Harness::builder().with_size(egui::vec2(1600.0, 1400.0)).with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|cc| TextureCraftApp::new(cc, session)); // English, so a first-run locale does not change the queried labels h.state_mut().ui.prefs.language = "en".into(); diff --git a/crates/ui-egui/tests/it/reset_ui.rs b/crates/ui-egui/tests/it/reset_ui.rs index d2ca7864..314f8dbd 100644 --- a/crates/ui-egui/tests/it/reset_ui.rs +++ b/crates/ui-egui/tests/it/reset_ui.rs @@ -10,7 +10,7 @@ use texturecraft_ui_egui::state::{Mode, ViewLayout}; /// An app with the Assets panel closed, a changed view split, zoom, wireframe and mode. fn changed_app() -> Harness<'static, TextureCraftApp> { let session = texturecraft_engine::sample_session(256, 64).unwrap(); - let mut h = Harness::builder().with_size(egui::vec2(1600.0, 960.0)).build_eframe(|cc| TextureCraftApp::new(cc, session)); + let mut h = Harness::builder().with_size(egui::vec2(1600.0, 960.0)).with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|cc| TextureCraftApp::new(cc, session)); h.state_mut().ui.prefs.language = "en".into(); h.run_steps(4); let ui = &mut h.state_mut().ui; diff --git a/crates/ui-egui/tests/it/settings_window.rs b/crates/ui-egui/tests/it/settings_window.rs index 4e8508b1..baaa47fd 100644 --- a/crates/ui-egui/tests/it/settings_window.rs +++ b/crates/ui-egui/tests/it/settings_window.rs @@ -12,7 +12,7 @@ use texturecraft_ui_egui::{TextureCraftApp, menus}; use crate::memory_storage::MemoryStorage; fn harness(session: Session) -> Harness<'static, TextureCraftApp> { - let mut h = Harness::builder().with_size(egui::vec2(1600.0, 960.0)).build_eframe(|cc| TextureCraftApp::new(cc, session)); + let mut h = Harness::builder().with_size(egui::vec2(1600.0, 960.0)).with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|cc| TextureCraftApp::new(cc, session)); // The exact-text checks need English, whatever the OS language is h.state_mut().ui.prefs.language = "en".into(); diff --git a/crates/ui-egui/tests/it/shelf_click.rs b/crates/ui-egui/tests/it/shelf_click.rs index bc11cfdb..729e491f 100644 --- a/crates/ui-egui/tests/it/shelf_click.rs +++ b/crates/ui-egui/tests/it/shelf_click.rs @@ -12,7 +12,7 @@ const SMART_TYPE: usize = 1; /// The sample project with the shelf on type `tab`, filtered to `label` fn shelf(tab: usize, label: &str) -> Harness<'static, TextureCraftApp> { let session = texturecraft_engine::sample_session(256, 64).unwrap(); - let mut harness = Harness::builder().with_size(egui::vec2(1920.0, 1032.0)).build_eframe(|cc| TextureCraftApp::new(cc, session)); + let mut harness = Harness::builder().with_size(egui::vec2(1920.0, 1032.0)).with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|cc| TextureCraftApp::new(cc, session)); harness.state_mut().ui.shelf_tab = tab; harness.state_mut().ui.shelf_filter = label.to_lowercase(); harness.run_steps(4); diff --git a/crates/ui-egui/tests/it/shelf_drop.rs b/crates/ui-egui/tests/it/shelf_drop.rs index d1c732fd..9052782b 100644 --- a/crates/ui-egui/tests/it/shelf_drop.rs +++ b/crates/ui-egui/tests/it/shelf_drop.rs @@ -19,7 +19,7 @@ const MENU_REACH: f32 = 60.0; /// The sample project (Ball = set 0, Base = set 1) with the Ball selected, at 1600 x 960 fn sample_app() -> Harness<'static, TextureCraftApp> { let session = texturecraft_engine::sample_session(256, 64).unwrap(); - let mut harness = Harness::builder().with_size(egui::vec2(1600.0, 960.0)).build_eframe(|cc| TextureCraftApp::new(cc, session)); + let mut harness = Harness::builder().with_size(egui::vec2(1600.0, 960.0)).with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|cc| TextureCraftApp::new(cc, session)); harness.run_steps(4); assert_eq!(harness.state().session.ts(), 0); harness @@ -291,7 +291,7 @@ fn image_drop_menu_snapshots() { std::fs::create_dir_all(&directory).unwrap(); let session = texturecraft_engine::sample_session(256, 64).unwrap(); - let mut harness = Harness::builder().with_size(egui::vec2(1600.0, 960.0)).wgpu().build_eframe(|context| TextureCraftApp::new(context, session)); + let mut harness = Harness::builder().with_size(egui::vec2(1600.0, 960.0)).wgpu().with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|context| TextureCraftApp::new(context, session)); harness.state_mut().ui.prefs.language = "en".into(); harness.run_steps(6); let image = import_white_image(&mut harness); diff --git a/crates/ui-egui/tests/it/shelf_hover_preview.rs b/crates/ui-egui/tests/it/shelf_hover_preview.rs index 237de107..f63d84e0 100644 --- a/crates/ui-egui/tests/it/shelf_hover_preview.rs +++ b/crates/ui-egui/tests/it/shelf_hover_preview.rs @@ -27,7 +27,7 @@ fn materials_shelf(step_seconds: f32, pixels_per_point: f32) -> (Harness<'static .with_size(egui::vec2(1600.0, 960.0)) .with_step_dt(step_seconds) .with_pixels_per_point(pixels_per_point) - .build_eframe(|cc| TextureCraftApp::new(cc, session)); + .with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|cc| TextureCraftApp::new(cc, session)); harness.state_mut().ui.shelf_tab = MATERIALS_TAB; harness.run_steps(4); diff --git a/crates/ui-egui/tests/it/shelf_panel.rs b/crates/ui-egui/tests/it/shelf_panel.rs index cbfdf687..084fe69b 100644 --- a/crates/ui-egui/tests/it/shelf_panel.rs +++ b/crates/ui-egui/tests/it/shelf_panel.rs @@ -27,7 +27,7 @@ const REFERENCE_COLUMNS: usize = 4; /// The sample project with the shelf on the Materials type fn shelf(size: egui::Vec2) -> Harness<'static, TextureCraftApp> { let session = texturecraft_engine::sample_session(256, 64).unwrap(); - let mut harness = Harness::builder().with_size(size).build_eframe(|cc| TextureCraftApp::new(cc, session)); + let mut harness = Harness::builder().with_size(size).with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|cc| TextureCraftApp::new(cc, session)); harness.state_mut().ui.shelf_tab = MATERIALS_TYPE; harness.run_steps(4); harness diff --git a/crates/ui-egui/tests/it/shift_lines_2d.rs b/crates/ui-egui/tests/it/shift_lines_2d.rs index 08537f4f..decf8629 100644 --- a/crates/ui-egui/tests/it/shift_lines_2d.rs +++ b/crates/ui-egui/tests/it/shift_lines_2d.rs @@ -30,7 +30,7 @@ const BESIDE_LINE_IN_RADII: f32 = 3.0; /// The sample project with only the 2D view, at 1600 x 960 fn uv_view_app() -> Harness<'static, TextureCraftApp> { let session = texturecraft_engine::sample_session(256, 64).unwrap(); - let mut harness = Harness::builder().with_size(egui::vec2(1600.0, 960.0)).build_eframe(|cc| TextureCraftApp::new(cc, session)); + let mut harness = Harness::builder().with_size(egui::vec2(1600.0, 960.0)).with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|cc| TextureCraftApp::new(cc, session)); harness.state_mut().ui.layout = ViewLayout::Only2D; harness.run_steps(4); harness @@ -249,7 +249,7 @@ fn shift_line_snapshots() { let output_dir = std::path::PathBuf::from(std::env::var_os("TC_UI_SNAPSHOTS").expect("set TC_UI_SNAPSHOTS to the output directory")); 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(|context| { + let mut harness = Harness::builder().with_size(egui::vec2(1600.0, 960.0)).with_pixels_per_point(1.0).wgpu().with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|context| { let adapter = &context.wgpu_render_state.as_ref().expect("wgpu render state").adapter; eprintln!("Shift-line snapshot adapter: {:?}", adapter.get_info()); TextureCraftApp::new(context, session) diff --git a/crates/ui-egui/tests/it/shift_lines_3d.rs b/crates/ui-egui/tests/it/shift_lines_3d.rs index 2c009a9b..1e91c42e 100644 --- a/crates/ui-egui/tests/it/shift_lines_3d.rs +++ b/crates/ui-egui/tests/it/shift_lines_3d.rs @@ -22,7 +22,7 @@ const SEARCH_REACH: f32 = 300.0; /// The sample project with only the 3D view and the Paint tool fn view_3d_app() -> Harness<'static, TextureCraftApp> { let session = texturecraft_engine::sample_session(256, 64).unwrap(); - let mut harness = Harness::builder().with_size(egui::vec2(1600.0, 960.0)).build_eframe(|cc| TextureCraftApp::new(cc, session)); + let mut harness = Harness::builder().with_size(egui::vec2(1600.0, 960.0)).with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|cc| TextureCraftApp::new(cc, session)); harness.state_mut().ui.layout = ViewLayout::Only3D; harness.state_mut().session.tool.tool = Tool::Paint; harness.run_steps(4); diff --git a/crates/ui-egui/tests/it/shortcut_keys.rs b/crates/ui-egui/tests/it/shortcut_keys.rs index 927edd86..fe7e1b60 100644 --- a/crates/ui-egui/tests/it/shortcut_keys.rs +++ b/crates/ui-egui/tests/it/shortcut_keys.rs @@ -9,7 +9,7 @@ use texturecraft_ui_egui::state::ViewLayout; fn harness() -> Harness<'static, TextureCraftApp> { let session = texturecraft_engine::sample_session(256, 64).unwrap(); - let mut h = Harness::builder().with_size(egui::vec2(1600.0, 960.0)).build_eframe(|cc| TextureCraftApp::new(cc, session)); + let mut h = Harness::builder().with_size(egui::vec2(1600.0, 960.0)).with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|cc| TextureCraftApp::new(cc, session)); h.run_steps(4); h } diff --git a/crates/ui-egui/tests/it/shortcut_list.rs b/crates/ui-egui/tests/it/shortcut_list.rs index c603cbde..d0091b4a 100644 --- a/crates/ui-egui/tests/it/shortcut_list.rs +++ b/crates/ui-egui/tests/it/shortcut_list.rs @@ -9,7 +9,7 @@ use texturecraft_ui_egui::{TextureCraftApp, menus}; fn harness() -> Harness<'static, TextureCraftApp> { let session = texturecraft_engine::sample_session(256, 64).unwrap(); - let mut h = Harness::builder().with_size(egui::vec2(1600.0, 960.0)).build_eframe(|cc| TextureCraftApp::new(cc, session)); + let mut h = Harness::builder().with_size(egui::vec2(1600.0, 960.0)).with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|cc| TextureCraftApp::new(cc, session)); h.state_mut().ui.prefs.language = "en".into(); h.run_steps(4); h diff --git a/crates/ui-egui/tests/it/side_panels.rs b/crates/ui-egui/tests/it/side_panels.rs index 80bd801d..9be1795c 100644 --- a/crates/ui-egui/tests/it/side_panels.rs +++ b/crates/ui-egui/tests/it/side_panels.rs @@ -24,7 +24,7 @@ const TOOLTIP_FRAMES: usize = 30; fn app() -> Harness<'static, TextureCraftApp> { let session = texturecraft_engine::sample_session(256, 64).unwrap(); - let mut harness = Harness::builder().with_size(WINDOW_SIZE).build_eframe(|cc| TextureCraftApp::new(cc, session)); + let mut harness = Harness::builder().with_size(WINDOW_SIZE).with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|cc| TextureCraftApp::new(cc, session)); harness.state_mut().ui.prefs.language = "en".into(); harness.run_steps(STARTUP_FRAMES); harness @@ -52,7 +52,7 @@ fn button_left_of_rail<'h>(harness: &'h Harness<'_, TextureCraftApp>, label: &st } fn is_floating(harness: &Harness<'_, TextureCraftApp>, panel: Panel) -> bool { - harness.state().ui.dock.workspace().layout.floating.iter().any(|window| window.contains(&panel)) + harness.state().ui.dock.workspace().layout().floating.iter().any(|window| window.contains(&panel)) } /// Hover the control labelled `label` until its tooltip shows, and tell whether that says it is not available yet @@ -83,7 +83,7 @@ fn undock_floats_the_panel_dock_returns_it_to_the_rail_and_the_float_persists() let saved = serde_json::to_value(&harness.state().ui).unwrap(); let restored: UiState = serde_json::from_value(saved).unwrap(); assert_eq!(restored.dock, harness.state().ui.dock); - assert!(restored.dock.workspace().layout.floating.iter().any(|window| window.contains(&Panel::History))); + assert!(restored.dock.workspace().layout().floating.iter().any(|window| window.contains(&Panel::History))); button_left_of_rail(&harness, "Dock").click(); harness.run_steps(SETTLE_FRAMES); diff --git a/crates/ui-egui/tests/it/skew_paint.rs b/crates/ui-egui/tests/it/skew_paint.rs index dd3b5d02..026fcd77 100644 --- a/crates/ui-egui/tests/it/skew_paint.rs +++ b/crates/ui-egui/tests/it/skew_paint.rs @@ -14,7 +14,7 @@ const STROKE_END: egui::Pos2 = egui::pos2(900.0, 500.0); fn harness() -> Harness<'static, TextureCraftApp> { let mut session = texturecraft_engine::sample_session(256, 64).unwrap(); session.add_high_poly_bytes("High.obj", b"v 0 0 0\nv 1 0 0\nv 0 1 0\nf 1 2 3\n".to_vec()).unwrap(); - let mut h = Harness::builder().with_size(egui::vec2(1600.0, 1500.0)).build_eframe(|cc| TextureCraftApp::new(cc, session)); + let mut h = Harness::builder().with_size(egui::vec2(1600.0, 1500.0)).with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|cc| TextureCraftApp::new(cc, session)); h.state_mut().ui.mode = Mode::Baking; h.state_mut().ui.layout = ViewLayout::Only2D; h.run_steps(4); diff --git a/crates/ui-egui/tests/it/smudge_channels.rs b/crates/ui-egui/tests/it/smudge_channels.rs index 63826cd1..9aca6360 100644 --- a/crates/ui-egui/tests/it/smudge_channels.rs +++ b/crates/ui-egui/tests/it/smudge_channels.rs @@ -12,7 +12,7 @@ use texturecraft_ui_egui::state::PropsTab; fn harness() -> Harness<'static, TextureCraftApp> { let session = Session::new_project("t", primitives::sphere(1.0, 48, 24), "builtin:sphere", None, 256).unwrap(); - let mut harness = Harness::builder().with_size(egui::vec2(1600.0, 960.0)).build_eframe(|context| TextureCraftApp::new(context, session)); + let mut harness = Harness::builder().with_size(egui::vec2(1600.0, 960.0)).with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|context| TextureCraftApp::new(context, session)); harness.run_steps(4); run(&mut harness, "tool.smudge", Value::Null); harness diff --git a/crates/ui-egui/tests/it/snapped_lines.rs b/crates/ui-egui/tests/it/snapped_lines.rs index 44a37b86..3854b1a2 100644 --- a/crates/ui-egui/tests/it/snapped_lines.rs +++ b/crates/ui-egui/tests/it/snapped_lines.rs @@ -27,7 +27,7 @@ const MAX_DIFFERENCE: f32 = 0.01; fn app(layout: ViewLayout) -> Harness<'static, TextureCraftApp> { let session = texturecraft_engine::sample_session(256, 64).unwrap(); - let mut harness = Harness::builder().with_size(egui::vec2(1600.0, 960.0)).build_eframe(|cc| TextureCraftApp::new(cc, session)); + let mut harness = Harness::builder().with_size(egui::vec2(1600.0, 960.0)).with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|cc| TextureCraftApp::new(cc, session)); harness.state_mut().ui.layout = layout; harness.run_steps(4); harness diff --git a/crates/ui-egui/tests/it/source_picker.rs b/crates/ui-egui/tests/it/source_picker.rs index 378b1a87..54076e79 100644 --- a/crates/ui-egui/tests/it/source_picker.rs +++ b/crates/ui-egui/tests/it/source_picker.rs @@ -32,7 +32,7 @@ fn app_with_fill(prepare: impl FnOnce(&mut texturecraft_engine::Session, LayerId let added = texturecraft_engine::execute(&mut session, "layer.add.fill", &json!({})).unwrap(); let layer = LayerId(added["layer"].as_u64().unwrap()); prepare(&mut session, layer); - let mut harness = Harness::builder().with_size(WINDOW_SIZE).build_eframe(|cc| TextureCraftApp::new(cc, session)); + let mut harness = Harness::builder().with_size(WINDOW_SIZE).with_context_setup(texturecraft_ui_egui::framework::install_headless).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(); @@ -225,7 +225,7 @@ fn near_the_windows_bottom_the_picker_opens_above_its_slot_at_full_size() { fn picker_above_its_slot_snapshot() { let mut session = texturecraft_engine::sample_session(TEXTURE_RESOLUTION, BAKE_RESOLUTION).unwrap(); texturecraft_engine::execute(&mut session, "layer.add.fill", &json!({})).unwrap(); - let mut harness = Harness::builder().with_size(SNAPSHOT_WINDOW_SIZE).with_pixels_per_point(2.0).wgpu().build_eframe(|cc| TextureCraftApp::new(cc, session)); + let mut harness = Harness::builder().with_size(SNAPSHOT_WINDOW_SIZE).with_pixels_per_point(2.0).wgpu().with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|cc| TextureCraftApp::new(cc, session)); harness.state_mut().ui.prefs.language = "en".into(); harness.run_steps(STARTUP_FRAMES); click_widget(&mut harness, Role::Tab, "Material"); diff --git a/crates/ui-egui/tests/it/split_divider.rs b/crates/ui-egui/tests/it/split_divider.rs index 63ce4ee7..cf75c2a9 100644 --- a/crates/ui-egui/tests/it/split_divider.rs +++ b/crates/ui-egui/tests/it/split_divider.rs @@ -38,7 +38,7 @@ impl eframe::Storage for MemoryStorage { /// The sample project in the default split layout at 1600 x 960 fn split_app() -> Harness<'static, TextureCraftApp> { let session = texturecraft_engine::sample_session(256, 64).unwrap(); - let mut harness = Harness::builder().with_size(egui::vec2(1600.0, 960.0)).build_eframe(|cc| TextureCraftApp::new(cc, session)); + let mut harness = Harness::builder().with_size(egui::vec2(1600.0, 960.0)).with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|cc| TextureCraftApp::new(cc, session)); // The Layers tab is found by its English name, whatever the OS language is harness.state_mut().ui.prefs.language = "en".into(); diff --git a/crates/ui-egui/tests/it/stencil.rs b/crates/ui-egui/tests/it/stencil.rs index c746d213..7d498465 100644 --- a/crates/ui-egui/tests/it/stencil.rs +++ b/crates/ui-egui/tests/it/stencil.rs @@ -18,7 +18,7 @@ fn projection_app() -> (Harness<'static, TextureCraftApp>, String) { image::RgbaImage::from_pixel(4, 4, image::Rgba([255, 255, 255, 255])).write_to(&mut std::io::Cursor::new(&mut png), image::ImageFormat::Png).unwrap(); let name = session.import_resource_bytes("logo.png", png).unwrap(); session.tool.tool = Tool::Projection; - let mut harness = Harness::builder().with_size(egui::vec2(1600.0, 960.0)).build_eframe(|cc| TextureCraftApp::new(cc, session)); + let mut harness = Harness::builder().with_size(egui::vec2(1600.0, 960.0)).with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|cc| TextureCraftApp::new(cc, session)); harness.state_mut().ui.prefs.language = "en".into(); harness.run_steps(4); (harness, name) diff --git a/crates/ui-egui/tests/it/symmetry.rs b/crates/ui-egui/tests/it/symmetry.rs index e5ea44f6..be2b2172 100644 --- a/crates/ui-egui/tests/it/symmetry.rs +++ b/crates/ui-egui/tests/it/symmetry.rs @@ -27,7 +27,7 @@ const VIEW_CORNER_INSET: f32 = 40.0; fn app_harness() -> Harness<'static, TextureCraftApp> { let session = texturecraft_engine::sample_session(1024, 256).unwrap(); - let mut harness = Harness::builder().with_size(WINDOW_SIZE).with_pixels_per_point(1.0).wgpu().build_eframe(|cc| TextureCraftApp::new(cc, session)); + let mut harness = Harness::builder().with_size(WINDOW_SIZE).with_pixels_per_point(1.0).wgpu().with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|cc| TextureCraftApp::new(cc, session)); harness.state_mut().session.tool.tool = Tool::Paint; harness.run_steps(4); harness diff --git a/crates/ui-egui/tests/it/symmetry_2d.rs b/crates/ui-egui/tests/it/symmetry_2d.rs index 29025dcd..259dbe32 100644 --- a/crates/ui-egui/tests/it/symmetry_2d.rs +++ b/crates/ui-egui/tests/it/symmetry_2d.rs @@ -13,7 +13,7 @@ const CLICK: Pos2 = pos2(700.0, 420.0); /// The sample project with only the 2D view, at 1600 x 960 fn uv_view_app() -> Harness<'static, TextureCraftApp> { let session = texturecraft_engine::sample_session(256, 64).unwrap(); - let mut harness = Harness::builder().with_size(egui::vec2(1600.0, 960.0)).build_eframe(|cc| TextureCraftApp::new(cc, session)); + let mut harness = Harness::builder().with_size(egui::vec2(1600.0, 960.0)).with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|cc| TextureCraftApp::new(cc, session)); harness.state_mut().ui.layout = ViewLayout::Only2D; harness.run_steps(4); harness diff --git a/crates/ui-egui/tests/it/template_invert.rs b/crates/ui-egui/tests/it/template_invert.rs index 748d5035..aa0b46ef 100644 --- a/crates/ui-egui/tests/it/template_invert.rs +++ b/crates/ui-egui/tests/it/template_invert.rs @@ -15,7 +15,7 @@ use library::Library; fn harness() -> (Harness<'static, TextureCraftApp>, Library) { let session = texturecraft_engine::sample_session(256, 64).unwrap(); - let mut h = Harness::builder().with_size(egui::vec2(1600.0, 960.0)).build_eframe(|cc| TextureCraftApp::new(cc, session)); + let mut h = Harness::builder().with_size(egui::vec2(1600.0, 960.0)).with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|cc| TextureCraftApp::new(cc, session)); h.state_mut().ui.prefs.language = "en".into(); // The user's template library is a folder; use a temporary one, not the real one diff --git a/crates/ui-egui/tests/it/templates_681.rs b/crates/ui-egui/tests/it/templates_681.rs index 06f3f650..d30578b5 100644 --- a/crates/ui-egui/tests/it/templates_681.rs +++ b/crates/ui-egui/tests/it/templates_681.rs @@ -13,7 +13,7 @@ use super::temp_dir::TempDir; fn app() -> Harness<'static, TextureCraftApp> { let session = texturecraft_engine::sample_session(128, 64).unwrap(); - let mut h = Harness::builder().with_size(egui::vec2(1600.0, 1200.0)).build_eframe(|cc| TextureCraftApp::new(cc, session)); + let mut h = Harness::builder().with_size(egui::vec2(1600.0, 1200.0)).with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|cc| TextureCraftApp::new(cc, session)); h.state_mut().ui.prefs.language = "en".into(); h.state_mut().session.templates.dir = None; h.run_steps(4); diff --git a/crates/ui-egui/tests/it/tile_generator_panel.rs b/crates/ui-egui/tests/it/tile_generator_panel.rs index ebe3746b..585a4343 100644 --- a/crates/ui-egui/tests/it/tile_generator_panel.rs +++ b/crates/ui-egui/tests/it/tile_generator_panel.rs @@ -24,7 +24,7 @@ fn harness(render: bool) -> (Harness<'static, TextureCraftApp>, LayerId) { session.update(); let builder = Harness::builder().with_size(egui::vec2(1600.0, 2400.0)); let builder = if render { builder.wgpu() } else { builder }; - let mut harness = builder.build_eframe(|context| TextureCraftApp::new(context, session)); + let mut harness = builder.with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|context| TextureCraftApp::new(context, session)); harness.state_mut().ui.prefs.language = "en".into(); harness.state_mut().ui.dock.close(Panel::Layers); harness.state_mut().ui.dock.close(Panel::TextureSetSettings); @@ -137,7 +137,7 @@ fn the_slot_names_the_anchor_in_a_mask_it_reads() { execute(&mut session, "mask.add.black", &json!({})).unwrap(); execute(&mut session, "effect.add.fill", &json!({"anchor": anchor})).unwrap(); session.update(); - let mut harness = Harness::builder().with_size(egui::vec2(1600.0, 2400.0)).build_eframe(|context| TextureCraftApp::new(context, session)); + let mut harness = Harness::builder().with_size(egui::vec2(1600.0, 2400.0)).with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|context| TextureCraftApp::new(context, session)); harness.state_mut().ui.prefs.language = "en".into(); harness.state_mut().ui.dock.focus(Panel::Properties); harness.run_steps(6); diff --git a/crates/ui-egui/tests/it/tool_availability.rs b/crates/ui-egui/tests/it/tool_availability.rs index 2d55e09f..fe47c7f8 100644 --- a/crates/ui-egui/tests/it/tool_availability.rs +++ b/crates/ui-egui/tests/it/tool_availability.rs @@ -24,7 +24,7 @@ fn select_nothing(session: &mut Session) { fn app_harness() -> Harness<'static, TextureCraftApp> { let session = texturecraft_engine::sample_session(256, 64).unwrap(); - let mut harness = Harness::builder().with_size(egui::vec2(1600.0, 960.0)).build_eframe(|context| TextureCraftApp::new(context, session)); + let mut harness = Harness::builder().with_size(egui::vec2(1600.0, 960.0)).with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|context| TextureCraftApp::new(context, session)); harness.run_steps(4); harness } @@ -138,7 +138,7 @@ fn a_tool_that_cant_act_ignores_the_view() { fn bake_painting_turns_on_the_shelf_paint_tool() { let mut session = texturecraft_engine::sample_session(256, 64).unwrap(); session.add_high_poly_bytes("High.obj", b"v 0 0 0\nv 1 0 0\nv 0 1 0\nf 1 2 3\n".to_vec()).unwrap(); - let mut harness = Harness::builder().with_size(egui::vec2(1600.0, 960.0)).build_eframe(|context| TextureCraftApp::new(context, session)); + let mut harness = Harness::builder().with_size(egui::vec2(1600.0, 960.0)).with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|context| TextureCraftApp::new(context, session)); harness.state_mut().ui.mode = Mode::Baking; harness.run_steps(4); assert!(shelf_button_disabled(&harness, "Paint (1)"), "nothing is being painted yet"); @@ -188,7 +188,7 @@ fn tool_availability_snapshots() { std::fs::create_dir_all(&directory).unwrap(); let session = texturecraft_engine::sample_session(256, 64).unwrap(); - let mut harness = Harness::builder().with_size(egui::vec2(1600.0, 960.0)).wgpu().build_eframe(|context| TextureCraftApp::new(context, session)); + let mut harness = Harness::builder().with_size(egui::vec2(1600.0, 960.0)).wgpu().with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|context| TextureCraftApp::new(context, session)); let save = |harness: &mut Harness<'_, TextureCraftApp>, name: &str| { for (brightness, suffix) in [(Brightness::MediumDark, "medium"), (Brightness::Dark, "dark"), (Brightness::Light, "light")] { harness.state_mut().ui.prefs.brightness = brightness; diff --git a/crates/ui-egui/tests/it/tool_settings_saved.rs b/crates/ui-egui/tests/it/tool_settings_saved.rs index b5c5fd73..94f0dc05 100644 --- a/crates/ui-egui/tests/it/tool_settings_saved.rs +++ b/crates/ui-egui/tests/it/tool_settings_saved.rs @@ -10,7 +10,7 @@ use memory_storage::MemoryStorage; #[test] fn saving_the_app_stores_the_current_brush_and_tool_settings() { let session = texturecraft_engine::sample_session(256, 64).unwrap(); - let mut harness = Harness::builder().with_size(egui::vec2(1600.0, 960.0)).build_eframe(|context| TextureCraftApp::new(context, session)); + let mut harness = Harness::builder().with_size(egui::vec2(1600.0, 960.0)).with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|context| TextureCraftApp::new(context, session)); harness.run_steps(2); let tool = &mut harness.state_mut().session.tool; tool.brush.size = 0.37; diff --git a/crates/ui-egui/tests/it/toolbar.rs b/crates/ui-egui/tests/it/toolbar.rs index 7d91e558..b208b468 100644 --- a/crates/ui-egui/tests/it/toolbar.rs +++ b/crates/ui-egui/tests/it/toolbar.rs @@ -197,7 +197,7 @@ fn toolbar_window_snapshots() { std::fs::create_dir_all(&directory).unwrap(); let session = texturecraft_engine::sample_session(256, 64).unwrap(); - let mut harness = Harness::builder().with_size(egui::vec2(1600.0, 960.0)).wgpu().build_eframe(|context| TextureCraftApp::new(context, session)); + let mut harness = Harness::builder().with_size(egui::vec2(1600.0, 960.0)).wgpu().with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|context| TextureCraftApp::new(context, session)); harness.state_mut().session.tool.tool = Tool::Path; harness.state_mut().session.tool.brush.lazy = 20.0; for (width, scale) in [(1600.0, 1.0), (960.0, 1.0), (960.0, 1.5)] { diff --git a/crates/ui-egui/tests/it/user_smart_mask.rs b/crates/ui-egui/tests/it/user_smart_mask.rs index da94ccda..2d208f47 100644 --- a/crates/ui-egui/tests/it/user_smart_mask.rs +++ b/crates/ui-egui/tests/it/user_smart_mask.rs @@ -15,7 +15,7 @@ const SMART_MATERIALS_TYPE: usize = 1; fn harness(prepare: impl FnOnce(&mut texturecraft_engine::Session)) -> Harness<'static, TextureCraftApp> { let mut session = texturecraft_engine::sample_session(256, 64).unwrap(); prepare(&mut session); - let mut harness = Harness::builder().with_size(WINDOW).build_eframe(|cc| TextureCraftApp::new(cc, session)); + let mut harness = Harness::builder().with_size(WINDOW).with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|cc| TextureCraftApp::new(cc, session)); harness.run_steps(4); harness } diff --git a/crates/ui-egui/tests/it/view2d_navigation.rs b/crates/ui-egui/tests/it/view2d_navigation.rs index 72815299..3d88d9fd 100644 --- a/crates/ui-egui/tests/it/view2d_navigation.rs +++ b/crates/ui-egui/tests/it/view2d_navigation.rs @@ -15,7 +15,7 @@ const WINDOW: egui::Vec2 = vec2(1280.0, 800.0); /// The app showing only the 2D view, and the rect that view fills fn app_with(session: Session) -> (Harness<'static, TextureCraftApp>, Rect) { let mut harness = - Harness::builder().with_size(WINDOW).with_pixels_per_point(1.0).with_step_dt(1.0 / 60.0).build_eframe(|cc| TextureCraftApp::new(cc, session)); + Harness::builder().with_size(WINDOW).with_pixels_per_point(1.0).with_step_dt(1.0 / 60.0).with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|cc| TextureCraftApp::new(cc, session)); harness.state_mut().session.tool.tool = texturecraft_engine::Tool::Paint; harness.state_mut().ui.layout = ViewLayout::Only3D; harness.run_steps(4); diff --git a/crates/ui-egui/tests/it/view2d_tiles.rs b/crates/ui-egui/tests/it/view2d_tiles.rs index 587b58b1..f03f6a5f 100644 --- a/crates/ui-egui/tests/it/view2d_tiles.rs +++ b/crates/ui-egui/tests/it/view2d_tiles.rs @@ -12,7 +12,7 @@ const BUTTON: &str = "uvtile_info_menu_button"; const SETTLE_FRAMES: usize = 3; fn app_with(session: Session) -> Harness<'static, TextureCraftApp> { - let mut harness = Harness::builder().with_size(egui::vec2(1600.0, 1000.0)).with_pixels_per_point(1.0).build_eframe(|cc| TextureCraftApp::new(cc, session)); + let mut harness = Harness::builder().with_size(egui::vec2(1600.0, 1000.0)).with_pixels_per_point(1.0).with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|cc| TextureCraftApp::new(cc, session)); harness.state_mut().ui.prefs.language = "en".into(); harness.state_mut().ui.layout = ViewLayout::Only3D; harness.run_steps(4); @@ -72,7 +72,7 @@ fn the_tile_info_button_sits_left_of_the_view_mode_picker_and_has_no_tooltip() { /// The app with Display Settings open from the rail fn display_settings_app() -> Harness<'static, TextureCraftApp> { let session = texturecraft_engine::sample_session(256, 64).unwrap(); - let mut harness = Harness::builder().with_size(egui::vec2(1600.0, 1400.0)).build_eframe(|cc| TextureCraftApp::new(cc, session)); + let mut harness = Harness::builder().with_size(egui::vec2(1600.0, 1400.0)).with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|cc| TextureCraftApp::new(cc, session)); harness.state_mut().ui.prefs.language = "en".into(); harness.run_steps(4); harness diff --git a/crates/ui-egui/tests/it/view_mode_picker.rs b/crates/ui-egui/tests/it/view_mode_picker.rs index e0009a84..5aace352 100644 --- a/crates/ui-egui/tests/it/view_mode_picker.rs +++ b/crates/ui-egui/tests/it/view_mode_picker.rs @@ -8,7 +8,7 @@ use texturecraft_ui_egui::TextureCraftApp; fn harness() -> Harness<'static, TextureCraftApp> { let session = texturecraft_engine::sample_session(256, 64).unwrap(); - let mut h = Harness::builder().with_size(egui::vec2(1600.0, 960.0)).build_eframe(|cc| TextureCraftApp::new(cc, session)); + let mut h = Harness::builder().with_size(egui::vec2(1600.0, 960.0)).with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|cc| TextureCraftApp::new(cc, session)); h.state_mut().ui.prefs.language = "en".into(); h.run_steps(4); h diff --git a/crates/ui-egui/tests/it/window_menu_684.rs b/crates/ui-egui/tests/it/window_menu_684.rs index 2480e326..13922461 100644 --- a/crates/ui-egui/tests/it/window_menu_684.rs +++ b/crates/ui-egui/tests/it/window_menu_684.rs @@ -15,7 +15,7 @@ use texturecraft_ui_egui::{TextureCraftApp, menus}; use super::temp_dir::TempDir; fn app_with(session: Session) -> Harness<'static, TextureCraftApp> { - let mut h = Harness::builder().with_size(egui::vec2(1600.0, 1000.0)).build_eframe(|cc| TextureCraftApp::new(cc, session)); + let mut h = Harness::builder().with_size(egui::vec2(1600.0, 1000.0)).with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|cc| TextureCraftApp::new(cc, session)); h.state_mut().ui.prefs.language = "en".into(); h.run_steps(4); h diff --git a/crates/ui-egui/tests/list_panels.rs b/crates/ui-egui/tests/list_panels.rs index afec1051..40a04edd 100644 --- a/crates/ui-egui/tests/list_panels.rs +++ b/crates/ui-egui/tests/list_panels.rs @@ -50,7 +50,7 @@ fn the_history_list_fills_a_tall_panel() { texturecraft_engine::execute(&mut session, "layer.rename", &json!({"layer": layer.0, "name": format!("Step {step}")})).unwrap(); } - let mut harness = Harness::builder().with_size(WINDOW_SIZE).build_eframe(|cc| TextureCraftApp::new(cc, session)); + let mut harness = Harness::builder().with_size(WINDOW_SIZE).with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|cc| TextureCraftApp::new(cc, session)); dock_in_left_column(&mut harness, "History"); harness.run_steps(STARTUP_FRAMES); @@ -62,7 +62,7 @@ fn the_history_list_fills_a_tall_panel() { #[test] fn the_log_list_fills_a_tall_panel() { let session = texturecraft_engine::sample_session(TEXTURE_RESOLUTION, BAKE_RESOLUTION).unwrap(); - let mut harness = Harness::builder().with_size(WINDOW_SIZE).build_eframe(|cc| TextureCraftApp::new(cc, session)); + let mut harness = Harness::builder().with_size(WINDOW_SIZE).with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|cc| TextureCraftApp::new(cc, session)); for line in 0..ROWS { harness.state_mut().session.log.push(format!("Log line {line}")); } diff --git a/crates/ui-egui/tests/project_limits.rs b/crates/ui-egui/tests/project_limits.rs index c6c3e34a..1d26ef64 100644 --- a/crates/ui-egui/tests/project_limits.rs +++ b/crates/ui-egui/tests/project_limits.rs @@ -22,7 +22,7 @@ fn resource_settings_follow_hardware_persist_and_apply_before_control_requests() let session = Session::new_project("Limits", geom::primitives::plane(2.0, 1), "builtin:plane", None, 128).unwrap(); let available_cores = u32::try_from(std::thread::available_parallelism().unwrap().get()).unwrap(); let mut harness = - Harness::builder().with_size(egui::vec2(1200.0, 900.0)).with_step_dt(1.0 / 60.0).with_accessibility_check(false).build_eframe(|context| { + Harness::builder().with_size(egui::vec2(1200.0, 900.0)).with_step_dt(1.0 / 60.0).with_accessibility_check(false).with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|context| { context.egui_ctx.data_mut(|data| data.insert_temp(egui::Id::unique("settings_resources"), (0.0_f64, available_cores, 16_u64 << 30))); let mut creation = eframe::CreationContext::_new_kittest(context.egui_ctx.clone()); creation.storage = Some(&storage); diff --git a/crates/ui-egui/tests/shader_panel.rs b/crates/ui-egui/tests/shader_panel.rs index 4e93d0df..5e9dbca3 100644 --- a/crates/ui-egui/tests/shader_panel.rs +++ b/crates/ui-egui/tests/shader_panel.rs @@ -17,7 +17,7 @@ const STARTUP_FRAMES: usize = 4; #[test] fn shader_settings_leave_the_height_strength_to_the_texture_set_settings() { let session = texturecraft_engine::sample_session(TEXTURE_RESOLUTION, BAKE_RESOLUTION).unwrap(); - let mut harness = Harness::builder().with_size(WINDOW_SIZE).build_eframe(|cc| TextureCraftApp::new(cc, session)); + let mut harness = Harness::builder().with_size(WINDOW_SIZE).with_context_setup(texturecraft_ui_egui::framework::install_headless).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(); diff --git a/crates/ui-egui/tests/ui_snapshots.rs b/crates/ui-egui/tests/ui_snapshots.rs index 2e71ddaa..f8780dfe 100644 --- a/crates/ui-egui/tests/ui_snapshots.rs +++ b/crates/ui-egui/tests/ui_snapshots.rs @@ -59,7 +59,7 @@ fn empty_start_snapshot() { let Some(output_dir) = std::env::var_os("TC_UI_SNAPSHOTS").map(PathBuf::from) else { return }; std::fs::create_dir_all(&output_dir).unwrap(); let session = texturecraft_engine::Session::closed().unwrap(); - let mut harness = Harness::builder().with_size(egui::vec2(1600.0, 960.0)).build_eframe(|context| TextureCraftApp::new(context, session)); + let mut harness = Harness::builder().with_size(egui::vec2(1600.0, 960.0)).with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|context| TextureCraftApp::new(context, session)); harness.state_mut().ui.prefs.language = "en".into(); save(&mut harness, &output_dir, "empty-start"); @@ -92,7 +92,7 @@ fn empty_start_snapshot() { #[ignore] fn close_releases_view_targets_and_rejects_immediate_capture() { let session = texturecraft_engine::Session::closed().unwrap(); - let mut harness = Harness::builder().with_size(egui::vec2(960.0, 640.0)).wgpu().build_eframe(|context| TextureCraftApp::new(context, session)); + let mut harness = Harness::builder().with_size(egui::vec2(960.0, 640.0)).wgpu().with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|context| TextureCraftApp::new(context, session)); harness.state_mut().ui.prefs.language = "en".into(); for mesh in ["cube", "plane"] { @@ -155,7 +155,7 @@ fn brush_presets_popover_snapshot() { std::fs::create_dir_all(&output_dir).unwrap(); let session = texturecraft_engine::sample_session(128, 32).unwrap(); let mut harness = - Harness::builder().with_size(egui::vec2(1280.0, 800.0)).with_pixels_per_point(1.0).build_eframe(|context| TextureCraftApp::new(context, session)); + Harness::builder().with_size(egui::vec2(1280.0, 800.0)).with_pixels_per_point(1.0).with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|context| TextureCraftApp::new(context, session)); let brush = harness.state().session.tool.brush.clone(); harness.state_mut().session.brush_presets.list.clear(); harness.state_mut().ui.prefs.language = "en".into(); @@ -192,7 +192,7 @@ fn pbr_import_dialog_keeps_choices_after_error() { .with_size(egui::vec2(1280.0, 800.0)) .with_pixels_per_point(1.0) .wgpu() - .build_eframe(|context| TextureCraftApp::new(context, session)); + .with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|context| TextureCraftApp::new(context, session)); harness.state_mut().ui.prefs.language = "en".into(); texturecraft_ui_egui::pbr_import::begin(harness.state_mut(), serde_json::json!({"path": source_dir.display().to_string()})); @@ -227,7 +227,7 @@ fn pbr_import_uses_displayed_default_after_folder_changes() { .with_size(egui::vec2(1280.0, 800.0)) .with_pixels_per_point(1.0) .wgpu() - .build_eframe(|context| TextureCraftApp::new(context, session)); + .with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|context| TextureCraftApp::new(context, session)); texturecraft_ui_egui::pbr_import::begin(harness.state_mut(), serde_json::json!({"path": source_dir.display().to_string()})); std::fs::write(source_dir.join("tile_albedo_8k.png"), &bytes).unwrap(); @@ -261,7 +261,7 @@ fn pbr_drop_candidates_and_project_replacement() { .with_size(egui::vec2(1280.0, 800.0)) .with_pixels_per_point(1.0) .wgpu() - .build_eframe(|context| TextureCraftApp::new(context, session)); + .with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|context| TextureCraftApp::new(context, session)); harness.input_mut().dropped_files = files.iter().cloned().map(dropped_path::handle).collect(); harness.run_steps(1); assert!(harness.state().pbr_import.is_some()); @@ -295,7 +295,7 @@ fn pbr_dialog_is_cleared_when_project_changes() { .with_size(egui::vec2(1280.0, 800.0)) .with_pixels_per_point(1.0) .wgpu() - .build_eframe(|context| TextureCraftApp::new(context, session)); + .with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|context| TextureCraftApp::new(context, session)); texturecraft_ui_egui::pbr_import::begin(harness.state_mut(), serde_json::json!({"path": source_dir.display().to_string()})); assert!(harness.state().pbr_import.is_some()); @@ -316,7 +316,7 @@ fn rendering_mode_snapshots() { .with_size(egui::vec2(1280.0, 800.0)) .with_pixels_per_point(1.0) .wgpu() - .build_eframe(|context| TextureCraftApp::new(context, session)); + .with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|context| TextureCraftApp::new(context, session)); harness.state_mut().ui.mode = Mode::Rendering; harness.state_mut().ui.render.max_samples = 16; eprintln!("Rendering-mode adapter: {}", harness.state().gpu.as_ref().unwrap().adapter); @@ -346,7 +346,7 @@ fn symmetry_snapshots() { std::fs::create_dir_all(&output_dir).unwrap(); let session = texturecraft_engine::sample_session(1024, 256).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::builder().with_size(egui::vec2(1600.0, 960.0)).with_pixels_per_point(1.0).wgpu().with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|cc| TextureCraftApp::new(cc, session)); harness.state_mut().ui.prefs.language = "en".into(); harness.state_mut().run("tool.brush", serde_json::json!({"symmetryY": true, "symmetryOffset": [0, 0.1, 0]})).unwrap(); harness.state_mut().ui.symmetry.show_plane = true; @@ -382,7 +382,7 @@ fn window_snapshots() { std::fs::create_dir_all(&output_dir).unwrap(); let session = texturecraft_engine::sample_session(1024, 256).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::builder().with_size(egui::vec2(1600.0, 960.0)).with_pixels_per_point(1.0).wgpu().with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|cc| TextureCraftApp::new(cc, session)); for (brightness, name) in [(Brightness::MediumDark, "main"), (Brightness::Dark, "brightness-dark"), (Brightness::Light, "brightness-light")] { harness.state_mut().ui.prefs.brightness = brightness; save(&mut harness, &output_dir, name); @@ -561,7 +561,7 @@ fn bake_uv_tiles_snapshot() { .with_size(egui::vec2(1600.0, 960.0)) .with_pixels_per_point(1.0) .wgpu() - .build_eframe(|context| TextureCraftApp::new(context, session)); + .with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|context| TextureCraftApp::new(context, session)); harness.state_mut().ui.mode = Mode::Baking; save(&mut harness, &output_dir, "bake-uv-tiles"); @@ -601,7 +601,7 @@ fn smart_mask_shelf_snapshot() { let session = texturecraft_engine::Session::new_project("Mask previews", texturecraft_engine::geom::primitives::cube(2.0), "builtin:cube", None, 128).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::builder().with_size(egui::vec2(1600.0, 960.0)).with_pixels_per_point(1.0).wgpu().with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|cc| TextureCraftApp::new(cc, session)); harness.state_mut().ui.shelf_tab = 2; let context = harness.ctx.clone(); let started = std::time::Instant::now(); @@ -649,7 +649,7 @@ fn smart_material_shelf_snapshot() { let session = texturecraft_engine::Session::new_project("Smart material previews", texturecraft_engine::geom::primitives::cube(2.0), "builtin:cube", None, 128) .unwrap(); - let mut harness = Harness::builder().with_size(egui::vec2(1600.0, 960.0)).with_pixels_per_point(1.0).wgpu().build_eframe(|context| { + let mut harness = Harness::builder().with_size(egui::vec2(1600.0, 960.0)).with_pixels_per_point(1.0).wgpu().with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|context| { let render_state = context.wgpu_render_state.as_ref().expect("the snapshot uses wgpu"); eprintln!("snapshot adapter: {:?}", render_state.adapter.get_info()); TextureCraftApp::new(context, session) @@ -706,12 +706,14 @@ fn nested_layers_snapshot() { execute(&mut session, "layer.group", &Value::Null).unwrap(); } let mut harness = - Harness::builder().with_size(egui::vec2(1600.0, 1600.0)).with_pixels_per_point(1.0).wgpu().build_eframe(|cc| TextureCraftApp::new(cc, session)); + Harness::builder().with_size(egui::vec2(1600.0, 1600.0)).with_pixels_per_point(1.0).wgpu().with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|cc| TextureCraftApp::new(cc, session)); harness.run_steps(4); - let mut workspace = harness.state().ui.dock.workspace().clone(); - let Some(Node::Split { second, .. }) = workspace.layout.root.as_mut() else { panic!("default columns") }; + let workspace = harness.state().ui.dock.workspace().clone(); + let mut layout = workspace.layout().clone(); + let Some(Node::Split { second, .. }) = layout.root.as_mut() else { panic!("default columns") }; let Node::Split { size, .. } = second.as_mut() else { panic!("viewport and right column") }; *size = SplitSize::Ratio(0.99); + let workspace = texturecraft_ui_egui::docking::Workspace::from_parts(layout, workspace.hidden().to_vec(), workspace.floated().to_vec()); harness.state_mut().ui.dock = Dock::from_value(serde_json::to_value(workspace).unwrap()); for _ in 0..100 { harness.run_steps(1); @@ -747,7 +749,7 @@ fn mask_anchor_micro_detail_snapshot() { .with_size(egui::vec2(1600.0, 1200.0)) .with_pixels_per_point(1.0) .wgpu() - .build_eframe(|context| TextureCraftApp::new(context, session)); + .with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|context| TextureCraftApp::new(context, session)); harness.state_mut().ui.dock.focus(Panel::Properties); harness.run_steps(6); harness.get_by_label("Micro detail").scroll_to_me(); @@ -764,7 +766,7 @@ fn path_tool_snapshots() { texturecraft_engine::execute(&mut session, "layer.add.paint", &serde_json::Value::Null).unwrap(); texturecraft_engine::execute(&mut session, "tool.path", &serde_json::json!({"uvPoints": [[0.25, 0.5], [0.5, 0.3], [0.75, 0.5]]})).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::builder().with_size(egui::vec2(1600.0, 960.0)).with_pixels_per_point(1.0).wgpu().with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|cc| TextureCraftApp::new(cc, session)); harness.state_mut().ui.layout = texturecraft_ui_egui::state::ViewLayout::Only2D; harness.state_mut().session.select_path_point(1); harness.hover_at(egui::pos2(800.0, 600.0)); @@ -785,7 +787,7 @@ fn rail_window_snapshots() { 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::builder().with_size(egui::vec2(1600.0, 960.0)).with_pixels_per_point(1.0).wgpu().with_context_setup(texturecraft_ui_egui::framework::install_headless).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(); @@ -822,7 +824,7 @@ fn i18n_snapshots() { assert!(texturecraft_ui_egui::i18n::available(code), "build with migrated catalogs for {code}"); let session = texturecraft_engine::sample_session(128, 32).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::builder().with_size(egui::vec2(1600.0, 960.0)).with_pixels_per_point(1.0).wgpu().with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|cc| TextureCraftApp::new(cc, session)); harness.state_mut().ui.prefs.language = code.into(); harness.state_mut().ui.windows.settings = true; save(&mut harness, &output_dir, &format!("i18n-{code}")); @@ -856,7 +858,7 @@ fn mask_fill_image_snapshot() { execute(&mut session, "mask.add.black", &json!({})).unwrap(); let effect = execute(&mut session, "effect.add.fill", &json!({"target": "mask", "value": 1.0})).unwrap()["effect"].as_u64().unwrap(); execute(&mut session, "layer.select", &json!({"layer": layer, "target": effect})).unwrap(); - let mut harness = Harness::builder().with_size(egui::vec2(1600.0, 1100.0)).wgpu().build_eframe(|context| TextureCraftApp::new(context, session)); + let mut harness = Harness::builder().with_size(egui::vec2(1600.0, 1100.0)).wgpu().with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|context| TextureCraftApp::new(context, session)); harness.state_mut().ui.prefs.language = "en".into(); harness.run_steps(6); @@ -897,7 +899,7 @@ fn panel_header_snapshots() { let mut session = texturecraft_engine::sample_session(256, 64).unwrap(); execute(&mut session, "layer.add.fill", &json!({"color": [0.8, 0.3, 0.1]})).unwrap(); let mut harness = - Harness::builder().with_size(egui::vec2(1600.0, 960.0)).with_pixels_per_point(2.0).wgpu().build_eframe(|cc| TextureCraftApp::new(cc, session)); + Harness::builder().with_size(egui::vec2(1600.0, 960.0)).with_pixels_per_point(2.0).wgpu().with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|cc| TextureCraftApp::new(cc, session)); harness.state_mut().ui.prefs.language = "en".into(); for (brightness, name) in [(Brightness::MediumDark, "medium"), (Brightness::Dark, "dark"), (Brightness::Light, "light")] { harness.state_mut().ui.prefs.brightness = brightness; @@ -924,7 +926,7 @@ fn settings_pages_snapshot() { std::fs::create_dir_all(&output_dir).unwrap(); let session = texturecraft_engine::sample_session(128, 32).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::builder().with_size(egui::vec2(1600.0, 960.0)).with_pixels_per_point(1.0).wgpu().with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|cc| TextureCraftApp::new(cc, session)); harness.state_mut().ui.prefs.language = "en".into(); harness.state_mut().ui.windows.settings = true; save(&mut harness, &output_dir, "settings-general"); @@ -968,7 +970,7 @@ fn default_layout_snapshots() { execute(&mut session, "layer.add.fill", &json!({ "color": color })).unwrap(); } let mut harness = - Harness::builder().with_size(egui::vec2(1600.0, 960.0)).with_pixels_per_point(2.0).wgpu().build_eframe(|cc| TextureCraftApp::new(cc, session)); + Harness::builder().with_size(egui::vec2(1600.0, 960.0)).with_pixels_per_point(2.0).wgpu().with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|cc| TextureCraftApp::new(cc, session)); harness.state_mut().ui.prefs.language = "en".into(); for (brightness, name) in [(Brightness::MediumDark, "medium"), (Brightness::Dark, "dark"), (Brightness::Light, "light")] { harness.state_mut().ui.prefs.brightness = brightness; @@ -997,7 +999,7 @@ fn fill_reset_snapshots() { let layer = execute(&mut session, "layer.add.fill", &json!({"color": [0.8, 0.3, 0.1]})).unwrap()["layer"].clone(); execute(&mut session, "layer.fill.projection", &json!({"layer": layer, "tiling": [2.0, 2.0], "filtering": "nearest"})).unwrap(); let mut harness = - Harness::builder().with_size(egui::vec2(1600.0, 960.0)).with_pixels_per_point(2.0).wgpu().build_eframe(|cc| TextureCraftApp::new(cc, session)); + Harness::builder().with_size(egui::vec2(1600.0, 960.0)).with_pixels_per_point(2.0).wgpu().with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|cc| TextureCraftApp::new(cc, session)); harness.state_mut().ui.prefs.language = "en".into(); for (brightness, name) in [(Brightness::MediumDark, "medium"), (Brightness::Dark, "dark"), (Brightness::Light, "light")] { harness.state_mut().ui.prefs.brightness = brightness; @@ -1051,7 +1053,7 @@ fn fill_properties_snapshots() { ) .unwrap(); let mut harness = - Harness::builder().with_size(egui::vec2(1600.0, 1500.0)).with_pixels_per_point(2.0).wgpu().build_eframe(|cc| TextureCraftApp::new(cc, session)); + Harness::builder().with_size(egui::vec2(1600.0, 1500.0)).with_pixels_per_point(2.0).wgpu().with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|cc| TextureCraftApp::new(cc, session)); harness.state_mut().ui.prefs.language = "en".into(); for (brightness, name) in [(Brightness::MediumDark, "medium"), (Brightness::Dark, "dark"), (Brightness::Light, "light")] { harness.state_mut().ui.prefs.brightness = brightness; @@ -1182,7 +1184,7 @@ fn fill_symmetry_snapshots() { let layer = execute(&mut session, "layer.add.fill", &json!({"color": [0.8, 0.3, 0.1]})).unwrap()["layer"].clone(); execute(&mut session, "layer.fill.projection", &json!({"layer": layer, "projection": "planar"})).unwrap(); let mut harness = - Harness::builder().with_size(egui::vec2(1600.0, 1500.0)).with_pixels_per_point(2.0).wgpu().build_eframe(|cc| TextureCraftApp::new(cc, session)); + Harness::builder().with_size(egui::vec2(1600.0, 1500.0)).with_pixels_per_point(2.0).wgpu().with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|cc| TextureCraftApp::new(cc, session)); harness.state_mut().ui.prefs.language = "en".into(); harness.run_steps(4); harness.get_by_role_and_label(egui::Role::Tab, "Symmetry").click(); @@ -1266,7 +1268,7 @@ fn fill_color_picker_snapshots() { execute(&mut session, "swatch.add", &json!({"color": swatch})).unwrap(); } let mut harness = - Harness::builder().with_size(egui::vec2(1600.0, 2000.0)).with_pixels_per_point(2.0).wgpu().build_eframe(|cc| TextureCraftApp::new(cc, session)); + Harness::builder().with_size(egui::vec2(1600.0, 2000.0)).with_pixels_per_point(2.0).wgpu().with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|cc| TextureCraftApp::new(cc, session)); harness.state_mut().ui.prefs.language = "en".into(); harness.run_steps(4); harness.get_by_role_and_label(egui::Role::Tab, "Material").click(); @@ -1362,7 +1364,7 @@ fn fill_material_snapshots() { execute(&mut session, "layer.fill.set", &settings).unwrap(); } let mut harness = - Harness::builder().with_size(egui::vec2(1600.0, 1500.0)).with_pixels_per_point(2.0).wgpu().build_eframe(|cc| TextureCraftApp::new(cc, session)); + Harness::builder().with_size(egui::vec2(1600.0, 1500.0)).with_pixels_per_point(2.0).wgpu().with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|cc| TextureCraftApp::new(cc, session)); harness.state_mut().ui.prefs.language = "en".into(); harness.run_steps(4); harness.get_by_role_and_label(egui::Role::Tab, "Material").click(); @@ -1514,7 +1516,7 @@ fn eyedropper_pointer_snapshots() { let mut session = texturecraft_engine::sample_session(256, 64).unwrap(); execute(&mut session, "layer.add.fill", &json!({"color": color})).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::builder().with_size(egui::vec2(1600.0, 960.0)).with_pixels_per_point(1.0).wgpu().with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|cc| TextureCraftApp::new(cc, session)); harness.state_mut().ui.prefs.language = "en".into(); // Only the app's own pointer shows, not the test's stand-in arrow @@ -1570,7 +1572,7 @@ fn source_picker_snapshots() { execute(&mut session, "effect.add.anchor", &json!({"layer": below, "name": "Edge wear"})).unwrap(); let layer = execute(&mut session, "layer.add.fill", &json!({"color": [0.45, 0.13, 0.05]})).unwrap()["layer"].clone(); let mut harness = - Harness::builder().with_size(egui::vec2(1600.0, 1200.0)).with_pixels_per_point(2.0).wgpu().build_eframe(|cc| TextureCraftApp::new(cc, session)); + Harness::builder().with_size(egui::vec2(1600.0, 1200.0)).with_pixels_per_point(2.0).wgpu().with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|cc| TextureCraftApp::new(cc, session)); harness.state_mut().ui.prefs.language = "en".into(); harness.run_steps(4); harness.get_by_role_and_label(egui::Role::Tab, "Material").click(); @@ -1657,7 +1659,7 @@ fn info_icon_snapshots() { execute(&mut session, "layer.fill.projection", &json!({"layer": layer, "projection": "planar"})).unwrap(); execute(&mut session, "layer.fill.projection", &json!({"layer": layer, "scaleMode": "physicalSize", "backfaceCulling": true})).unwrap(); let mut harness = - Harness::builder().with_size(egui::vec2(1600.0, 1500.0)).with_pixels_per_point(2.0).wgpu().build_eframe(|cc| TextureCraftApp::new(cc, session)); + Harness::builder().with_size(egui::vec2(1600.0, 1500.0)).with_pixels_per_point(2.0).wgpu().with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|cc| TextureCraftApp::new(cc, session)); harness.state_mut().ui.prefs.language = "en".into(); // The test's stand-in arrow would hide the hovered i @@ -1696,7 +1698,7 @@ fn popup_tabs_snapshots() { let layer = execute(&mut session, "layer.add.fill", &json!({"color": [0.8, 0.3, 0.1]})).unwrap()["layer"].clone(); execute(&mut session, "layer.fill.projection", &json!({"layer": layer, "projection": "uv"})).unwrap(); let mut harness = - Harness::builder().with_size(egui::vec2(1600.0, 1000.0)).with_pixels_per_point(2.0).wgpu().build_eframe(|cc| TextureCraftApp::new(cc, session)); + Harness::builder().with_size(egui::vec2(1600.0, 1000.0)).with_pixels_per_point(2.0).wgpu().with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|cc| TextureCraftApp::new(cc, session)); harness.state_mut().ui.prefs.language = "en".into(); harness.set_render_cursor(false); harness.run_steps(4); @@ -1769,7 +1771,7 @@ fn mask_fill_snapshots() { let effect = execute(&mut session, "effect.add.fill", &json!({"layer": layer, "target": "mask"})).unwrap()["effect"].clone(); execute(&mut session, "layer.select", &json!({"layer": layer, "target": effect})).unwrap(); let mut harness = - Harness::builder().with_size(egui::vec2(1600.0, 1200.0)).with_pixels_per_point(2.0).wgpu().build_eframe(|cc| TextureCraftApp::new(cc, session)); + Harness::builder().with_size(egui::vec2(1600.0, 1200.0)).with_pixels_per_point(2.0).wgpu().with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|cc| TextureCraftApp::new(cc, session)); harness.state_mut().ui.prefs.language = "en".into(); harness.run_steps(4); save(&mut harness, &output_dir, "mask-fill-fill"); @@ -1846,7 +1848,7 @@ fn compare_snapshots() { let compare = execute(&mut session, "effect.add.compare", &json!({"layer": layer})).unwrap()["effect"].clone(); execute(&mut session, "layer.select", &json!({"layer": layer, "target": compare})).unwrap(); let mut harness = - Harness::builder().with_size(egui::vec2(1600.0, 1200.0)).with_pixels_per_point(2.0).wgpu().build_eframe(|cc| TextureCraftApp::new(cc, session)); + Harness::builder().with_size(egui::vec2(1600.0, 1200.0)).with_pixels_per_point(2.0).wgpu().with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|cc| TextureCraftApp::new(cc, session)); harness.state_mut().ui.prefs.language = "en".into(); harness.run_steps(6); save(&mut harness, &output_dir, "compare-default"); @@ -1897,7 +1899,7 @@ fn anchor_snapshots() { let content = execute(&mut session, "effect.add.anchor", &json!({"layer": fresh})).unwrap()["effect"].clone(); execute(&mut session, "layer.select", &json!({"layer": fresh, "target": content})).unwrap(); let mut harness = - Harness::builder().with_size(egui::vec2(1600.0, 1200.0)).with_pixels_per_point(2.0).wgpu().build_eframe(|cc| TextureCraftApp::new(cc, session)); + Harness::builder().with_size(egui::vec2(1600.0, 1200.0)).with_pixels_per_point(2.0).wgpu().with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|cc| TextureCraftApp::new(cc, session)); harness.state_mut().ui.prefs.language = "en".into(); harness.run_steps(6); harness.get_by_role_and_label(egui::Role::TextInput, "Anchor point name").click(); @@ -1936,7 +1938,7 @@ fn folder_snapshots() { let folder = execute(&mut session, "layer.group", &json!({"layer": fill})).unwrap()["layer"].clone(); execute(&mut session, "layer.select", &json!({"layer": folder, "target": "content"})).unwrap(); let mut harness = - Harness::builder().with_size(egui::vec2(1600.0, 1200.0)).with_pixels_per_point(2.0).wgpu().build_eframe(|cc| TextureCraftApp::new(cc, session)); + Harness::builder().with_size(egui::vec2(1600.0, 1200.0)).with_pixels_per_point(2.0).wgpu().with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|cc| TextureCraftApp::new(cc, session)); harness.state_mut().ui.prefs.language = "en".into(); harness.run_steps(6); save(&mut harness, &output_dir, "folder-rest"); @@ -1976,7 +1978,7 @@ fn instance_snapshots() { let instance = execute(&mut session, "layer.instance", &json!({"layer": source})).unwrap()["layer"].clone(); execute(&mut session, "layer.select", &json!({"layer": instance, "target": "content"})).unwrap(); let mut harness = - Harness::builder().with_size(egui::vec2(1600.0, 1200.0)).with_pixels_per_point(2.0).wgpu().build_eframe(|cc| TextureCraftApp::new(cc, session)); + Harness::builder().with_size(egui::vec2(1600.0, 1200.0)).with_pixels_per_point(2.0).wgpu().with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|cc| TextureCraftApp::new(cc, session)); harness.state_mut().ui.prefs.language = "en".into(); harness.run_steps(6); save(&mut harness, &output_dir, "instance-rest"); @@ -2019,7 +2021,7 @@ fn folder_mask_snapshots() { execute(&mut session, "mask.add.white", &json!({"layer": folder})).unwrap(); execute(&mut session, "layer.select", &json!({"layer": folder, "target": "mask"})).unwrap(); let mut harness = - Harness::builder().with_size(egui::vec2(1600.0, 1200.0)).with_pixels_per_point(2.0).wgpu().build_eframe(|cc| TextureCraftApp::new(cc, session)); + Harness::builder().with_size(egui::vec2(1600.0, 1200.0)).with_pixels_per_point(2.0).wgpu().with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|cc| TextureCraftApp::new(cc, session)); harness.state_mut().ui.prefs.language = "en".into(); harness.state_mut().ui.props_tab = texturecraft_ui_egui::state::PropsTab::Material; harness.run_steps(6); @@ -2065,7 +2067,7 @@ fn color_selection_snapshots() { } execute(&mut session, "layer.select", &json!({"layer": layer, "target": effect.0})).unwrap(); let mut harness = - Harness::builder().with_size(egui::vec2(1600.0, 1200.0)).with_pixels_per_point(2.0).wgpu().build_eframe(|cc| TextureCraftApp::new(cc, session)); + Harness::builder().with_size(egui::vec2(1600.0, 1200.0)).with_pixels_per_point(2.0).wgpu().with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|cc| TextureCraftApp::new(cc, session)); harness.state_mut().ui.prefs.language = "en".into(); harness.run_steps(6); harness @@ -2148,7 +2150,7 @@ fn levels_snapshots() { let content_levels = execute(&mut session, "effect.add.levels", &json!({"layer": layer, "target": "content"})).unwrap()["effect"].clone(); execute(&mut session, "layer.select", &json!({"layer": layer, "target": mask_levels})).unwrap(); let mut harness = - Harness::builder().with_size(egui::vec2(1600.0, 1200.0)).with_pixels_per_point(2.0).wgpu().build_eframe(|cc| TextureCraftApp::new(cc, session)); + Harness::builder().with_size(egui::vec2(1600.0, 1200.0)).with_pixels_per_point(2.0).wgpu().with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|cc| TextureCraftApp::new(cc, session)); harness.state_mut().ui.prefs.language = "en".into(); harness.run_steps(6); save(&mut harness, &output_dir, "levels-mask"); @@ -2205,7 +2207,7 @@ fn layer_toolbar_snapshots() { let fill = execute(&mut session, "layer.add.fill", &json!({})).unwrap()["layer"].clone(); execute(&mut session, "layer.select", &json!({"layer": fill})).unwrap(); let mut harness = - Harness::builder().with_size(egui::vec2(1600.0, 1200.0)).with_pixels_per_point(2.0).wgpu().build_eframe(|cc| TextureCraftApp::new(cc, session)); + Harness::builder().with_size(egui::vec2(1600.0, 1200.0)).with_pixels_per_point(2.0).wgpu().with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|cc| TextureCraftApp::new(cc, session)); harness.state_mut().ui.prefs.language = "en".into(); harness.run_steps(6); harness.state_mut().ui.dock.focus(Panel::Layers); @@ -2273,7 +2275,7 @@ fn filter_card_snapshots() { execute(&mut session, "layer.select", &json!({"layer": layer})).unwrap(); session.target = StackTarget::Effect(empty); let mut harness = - Harness::builder().with_size(egui::vec2(1600.0, 1200.0)).with_pixels_per_point(2.0).wgpu().build_eframe(|cc| TextureCraftApp::new(cc, session)); + Harness::builder().with_size(egui::vec2(1600.0, 1200.0)).with_pixels_per_point(2.0).wgpu().with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|cc| TextureCraftApp::new(cc, session)); harness.state_mut().ui.prefs.language = "en".into(); harness.run_steps(6); @@ -2327,7 +2329,7 @@ fn material_picker_snapshots() { execute(&mut session, "layer.select", &json!({"layer": layer})).unwrap(); session.target = StackTarget::Content; let mut harness = - Harness::builder().with_size(egui::vec2(1600.0, 2000.0)).with_pixels_per_point(2.0).wgpu().build_eframe(|cc| TextureCraftApp::new(cc, session)); + Harness::builder().with_size(egui::vec2(1600.0, 2000.0)).with_pixels_per_point(2.0).wgpu().with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|cc| TextureCraftApp::new(cc, session)); harness.state_mut().ui.prefs.language = "en".into(); harness.run_steps(4); harness.get_by_role_and_label(egui::Role::Tab, "Material").click(); @@ -2381,7 +2383,7 @@ fn colour_filter_snapshots() { execute(&mut session, "layer.select", &json!({"layer": layer})).unwrap(); session.target = StackTarget::Effect(effects[0].1); let mut harness = - Harness::builder().with_size(egui::vec2(1600.0, 1200.0)).with_pixels_per_point(2.0).wgpu().build_eframe(|cc| TextureCraftApp::new(cc, session)); + Harness::builder().with_size(egui::vec2(1600.0, 1200.0)).with_pixels_per_point(2.0).wgpu().with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|cc| TextureCraftApp::new(cc, session)); harness.state_mut().ui.prefs.language = "en".into(); harness.run_steps(6); for (name, effect) in effects { @@ -2432,7 +2434,7 @@ fn gradient_filter_snapshots() { execute(&mut session, "layer.select", &json!({"layer": layer})).unwrap(); session.target = StackTarget::Effect(effects[0].1); let mut harness = - Harness::builder().with_size(egui::vec2(1600.0, 1400.0)).with_pixels_per_point(2.0).wgpu().build_eframe(|cc| TextureCraftApp::new(cc, session)); + Harness::builder().with_size(egui::vec2(1600.0, 1400.0)).with_pixels_per_point(2.0).wgpu().with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|cc| TextureCraftApp::new(cc, session)); harness.state_mut().ui.prefs.language = "en".into(); harness.run_steps(6); for (name, effect) in effects { @@ -2482,7 +2484,7 @@ fn light_filter_snapshots() { execute(&mut session, "layer.select", &json!({"layer": layer})).unwrap(); session.target = StackTarget::Effect(effects[0].1); let mut harness = - Harness::builder().with_size(egui::vec2(1600.0, 1400.0)).with_pixels_per_point(2.0).wgpu().build_eframe(|cc| TextureCraftApp::new(cc, session)); + Harness::builder().with_size(egui::vec2(1600.0, 1400.0)).with_pixels_per_point(2.0).wgpu().with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|cc| TextureCraftApp::new(cc, session)); harness.state_mut().ui.prefs.language = "en".into(); harness.run_steps(6); for (name, effect) in effects { @@ -2516,7 +2518,7 @@ fn light_filter_snapshots() { execute(&mut session, "layer.select", &json!({"layer": layer})).unwrap(); session.target = StackTarget::Effect(lighting); let mut harness = - Harness::builder().with_size(egui::vec2(1600.0, 2600.0)).with_pixels_per_point(1.0).wgpu().build_eframe(|cc| TextureCraftApp::new(cc, session)); + Harness::builder().with_size(egui::vec2(1600.0, 2600.0)).with_pixels_per_point(1.0).wgpu().with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|cc| TextureCraftApp::new(cc, session)); harness.state_mut().ui.prefs.language = "en".into(); harness.run_steps(8); save(&mut harness, &output_dir, "filter-baked-lighting-stylized"); @@ -2589,7 +2591,7 @@ fn shape_filter_snapshots() { execute(&mut session, "layer.select", &json!({"layer": layer})).unwrap(); session.target = StackTarget::Effect(effects[0].1); let mut harness = - Harness::builder().with_size(egui::vec2(1600.0, 1400.0)).with_pixels_per_point(2.0).wgpu().build_eframe(|cc| TextureCraftApp::new(cc, session)); + Harness::builder().with_size(egui::vec2(1600.0, 1400.0)).with_pixels_per_point(2.0).wgpu().with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|cc| TextureCraftApp::new(cc, session)); harness.state_mut().ui.prefs.language = "en".into(); harness.run_steps(6); for (name, effect) in effects { @@ -2710,7 +2712,7 @@ fn simple_filter_snapshots() { execute(&mut session, "layer.select", &json!({"layer": layer})).unwrap(); session.target = StackTarget::Effect(effects[0].1); let mut harness = - Harness::builder().with_size(egui::vec2(1600.0, 1400.0)).with_pixels_per_point(2.0).wgpu().build_eframe(|cc| TextureCraftApp::new(cc, session)); + Harness::builder().with_size(egui::vec2(1600.0, 1400.0)).with_pixels_per_point(2.0).wgpu().with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|cc| TextureCraftApp::new(cc, session)); harness.state_mut().ui.prefs.language = "en".into(); harness.run_steps(6); for (name, effect) in effects { @@ -2834,7 +2836,7 @@ fn image_input_snapshots() { execute(&mut session, "layer.select", &json!({"layer": layer})).unwrap(); session.target = StackTarget::Effect(effects[0].1); let mut harness = - Harness::builder().with_size(egui::vec2(1600.0, 2200.0)).with_pixels_per_point(2.0).wgpu().build_eframe(|cc| TextureCraftApp::new(cc, session)); + Harness::builder().with_size(egui::vec2(1600.0, 2200.0)).with_pixels_per_point(2.0).wgpu().with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|cc| TextureCraftApp::new(cc, session)); harness.state_mut().ui.prefs.language = "en".into(); harness.run_steps(6); for (name, effect) in effects { @@ -2907,7 +2909,7 @@ fn filter_picker_snapshots() { execute(&mut session, "layer.select", &json!({"layer": layer})).unwrap(); session.target = StackTarget::Effect(empty); let mut harness = - Harness::builder().with_size(egui::vec2(1600.0, 1200.0)).with_pixels_per_point(2.0).wgpu().build_eframe(|cc| TextureCraftApp::new(cc, session)); + Harness::builder().with_size(egui::vec2(1600.0, 1200.0)).with_pixels_per_point(2.0).wgpu().with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|cc| TextureCraftApp::new(cc, session)); harness.state_mut().ui.prefs.language = "en".into(); harness.run_steps(6); let open = |harness: &mut Harness<'_, TextureCraftApp>, card: &str, hover: &str| { @@ -2950,12 +2952,14 @@ fn properties_min_width_snapshot() { let settings = json!({"layer": layer, "projection": "planar", "scaleMode": "physicalSize", "backfaceCulling": true, "shapeCrop": "cropped"}); execute(&mut session, "layer.fill.projection", &settings).unwrap(); let mut harness = - Harness::builder().with_size(egui::vec2(1600.0, 1500.0)).with_pixels_per_point(2.0).wgpu().build_eframe(|cc| TextureCraftApp::new(cc, session)); + Harness::builder().with_size(egui::vec2(1600.0, 1500.0)).with_pixels_per_point(2.0).wgpu().with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|cc| TextureCraftApp::new(cc, session)); harness.run_steps(4); - let mut workspace = harness.state().ui.dock.workspace().clone(); - let Some(Node::Split { second, .. }) = workspace.layout.root.as_mut() else { panic!("default columns") }; + let workspace = harness.state().ui.dock.workspace().clone(); + let mut layout = workspace.layout().clone(); + let Some(Node::Split { second, .. }) = layout.root.as_mut() else { panic!("default columns") }; let Node::Split { size, .. } = second.as_mut() else { panic!("viewport and right column") }; *size = SplitSize::FixedSecond(0.0); + let workspace = texturecraft_ui_egui::docking::Workspace::from_parts(layout, workspace.hidden().to_vec(), workspace.floated().to_vec()); harness.state_mut().ui.dock = Dock::from_value(serde_json::to_value(workspace).unwrap()); for (brightness, name) in [(Brightness::MediumDark, "medium"), (Brightness::Dark, "dark"), (Brightness::Light, "light")] { harness.state_mut().ui.prefs.brightness = brightness; @@ -2979,7 +2983,7 @@ fn sheet_scroll_end_snapshots() { let mut session = texturecraft_engine::sample_session(256, 64).unwrap(); let layer = execute(&mut session, "layer.add.fill", &json!({"color": [0.8, 0.3, 0.1]})).unwrap()["layer"].clone(); execute(&mut session, "layer.fill.projection", &json!({"layer": layer, "projection": "uv"})).unwrap(); - let mut harness = Harness::builder().with_size(egui::vec2(1600.0, 2000.0)).wgpu().build_eframe(|cc| TextureCraftApp::new(cc, session)); + let mut harness = Harness::builder().with_size(egui::vec2(1600.0, 2000.0)).wgpu().with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|cc| TextureCraftApp::new(cc, session)); harness.state_mut().ui.prefs.language = "en".into(); harness.set_render_cursor(false); harness.run_steps(4); diff --git a/crates/ui-egui/tests/ui_state_persistence.rs b/crates/ui-egui/tests/ui_state_persistence.rs index a2008864..ef3608a7 100644 --- a/crates/ui-egui/tests/ui_state_persistence.rs +++ b/crates/ui-egui/tests/ui_state_persistence.rs @@ -13,7 +13,7 @@ fn app(storage: &MemoryStorage, render: bool) -> Harness<'static, TextureCraftAp // Existing viewport controls lack accessible names; these tests check persistence and rendering let builder = Harness::builder().with_size(egui::vec2(1600.0, 960.0)).with_accessibility_check(false); let builder = if render { builder.wgpu() } else { builder }; - builder.build_eframe(|context| { + builder.with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|context| { let mut creation = eframe::CreationContext::_new_kittest(context.egui_ctx.clone()); creation.storage = Some(storage); creation.wgpu_render_state = context.wgpu_render_state.clone(); From 04c4e627b4d4a2e89ba3de6c9360af793044916d Mon Sep 17 00:00:00 2001 From: aiongg Date: Tue, 24 Nov 2026 15:34:17 +0000 Subject: [PATCH 21/83] Tests: update prompt tests wait for the threaded offer; panel close helper reads the dock's Close {name}; header-painting tests of the old dock renderer go --- crates/ui-egui/src/updates_ui.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/crates/ui-egui/src/updates_ui.rs b/crates/ui-egui/src/updates_ui.rs index db37adf8..47740973 100644 --- a/crates/ui-egui/src/updates_ui.rs +++ b/crates/ui-egui/src/updates_ui.rs @@ -162,6 +162,13 @@ mod tests { ..Default::default() }; h.state_mut().updates_rt.updater.offer(release); + // The offer reads on a thread whether this copy can install the release itself; a later frame's tick opens + // the prompt. + let deadline = std::time::Instant::now() + std::time::Duration::from_secs(5); + while !h.state().updates_rt.updater.prompt_open() && std::time::Instant::now() < deadline { + h.run_steps(1); + std::thread::sleep(std::time::Duration::from_millis(2)); + } h.run_steps(2); } From dbd1c7077ec67db56998b90222967f16c457ab5b Mon Sep 17 00:00:00 2001 From: aiongg Date: Tue, 24 Nov 2026 16:15:19 +0000 Subject: [PATCH 22/83] Test round 1: Backspace no longer runs Delete bindings, the window's Enter reaches the Enter handlers, tab close buttons - The app's dispatcher declines a Delete binding for a Backspace press (and the reverse): craft_keymap's Matcher lets the two stand for each other, and TextureCraft binds them apart (Delete removes the layer, Backspace a Path tool point). - A plain Enter with nothing focused is the runtime's window submit: menus::shortcuts puts it back as an Enter press, as it does the window's Escape, for Reset UI, project config, import resources and the Path tool. - Each closable dock tab has its close button, as each group header had one. - Tests: the pointer-lock helper no longer rewrites input the app's raw_input_hook already rewrote (egui_kittest runs the hook before every pass); tab lookups by role; next's workspace format version; measured view edges instead of the old dock gap; a click's commit settles a frame later; tests of the old header painting and old divider geometry deleted; rustfmt. --- apps/texturecraft/src/main.rs | 9 +- crates/ui-egui/src/display_settings.rs | 6 +- crates/ui-egui/src/docking.rs | 8 +- crates/ui-egui/src/framework.rs | 15 +- crates/ui-egui/src/lib.rs | 4 +- crates/ui-egui/src/menus.rs | 15 +- crates/ui-egui/src/move_on_model.rs | 4 +- crates/ui-egui/src/pane_split.rs | 12 +- .../src/pointer_lock/system_pointer.rs | 23 +- crates/ui-egui/src/pointer_lock/tests.rs | 2 +- .../ui-egui/src/property_sheet/color_bar.rs | 5 +- crates/ui-egui/src/property_sheet/mod.rs | 4 +- crates/ui-egui/src/render_mode/tests.rs | 13 +- crates/ui-egui/src/shelf_panes.rs | 4 +- crates/ui-egui/src/shortcut_dispatch.rs | 26 +- crates/ui-egui/src/ui_state_store.rs | 5 +- crates/ui-egui/src/updates_ui.rs | 5 +- crates/ui-egui/src/viewport.rs | 25 +- crates/ui-egui/src/web_files.rs | 12 +- crates/ui-egui/src/windows.rs | 5 +- crates/ui-egui/tests/bake_preview.rs | 5 +- crates/ui-egui/tests/brush_cursor_2d.rs | 5 +- crates/ui-egui/tests/display_panel.rs | 5 +- crates/ui-egui/tests/it/alpha_parameters.rs | 5 +- crates/ui-egui/tests/it/anchor_point.rs | 6 +- crates/ui-egui/tests/it/bake_job_mesh.rs | 5 +- crates/ui-egui/tests/it/bake_mode.rs | 19 +- crates/ui-egui/tests/it/bake_presets.rs | 10 +- crates/ui-egui/tests/it/brush_drag.rs | 10 +- .../ui-egui/tests/it/brush_section_reset.rs | 5 +- crates/ui-egui/tests/it/camera_views.rs | 11 +- crates/ui-egui/tests/it/clone_source_view.rs | 5 +- crates/ui-egui/tests/it/close_unsaved.rs | 5 +- .../tests/it/color_selection_editor.rs | 48 ++- crates/ui-egui/tests/it/compare_mask_rows.rs | 6 +- .../ui-egui/tests/it/curvature_generator.rs | 3 +- .../ui-egui/tests/it/display_environment.rs | 5 +- .../ui-egui/tests/it/display_post_effects.rs | 5 +- crates/ui-egui/tests/it/effect_rows.rs | 20 +- crates/ui-egui/tests/it/effect_sliders.rs | 5 +- crates/ui-egui/tests/it/empty_menus.rs | 5 +- crates/ui-egui/tests/it/empty_start.rs | 14 +- crates/ui-egui/tests/it/export_file_types.rs | 10 +- .../ui-egui/tests/it/export_map_overrides.rs | 5 +- crates/ui-egui/tests/it/export_materialx.rs | 5 +- crates/ui-egui/tests/it/export_overrides.rs | 10 +- crates/ui-egui/tests/it/export_progress.rs | 5 +- crates/ui-egui/tests/it/export_settings.rs | 5 +- .../tests/it/export_template_guards.rs | 5 +- crates/ui-egui/tests/it/export_usd_asset.rs | 5 +- crates/ui-egui/tests/it/file_dialogs.rs | 5 +- crates/ui-egui/tests/it/fill_channel_image.rs | 20 +- crates/ui-egui/tests/it/fill_support.rs | 5 +- crates/ui-egui/tests/it/fill_symmetry_rows.rs | 4 +- crates/ui-egui/tests/it/filter_picker.rs | 12 +- crates/ui-egui/tests/it/filter_support.rs | 5 +- crates/ui-egui/tests/it/folder_properties.rs | 23 +- crates/ui-egui/tests/it/frame_selection.rs | 5 +- crates/ui-egui/tests/it/generator_panel.rs | 3 +- crates/ui-egui/tests/it/help_menu_664.rs | 5 +- crates/ui-egui/tests/it/history_panel.rs | 10 +- crates/ui-egui/tests/it/import_resources.rs | 12 +- crates/ui-egui/tests/it/inactive_set_hint.rs | 5 +- .../ui-egui/tests/it/instance_properties.rs | 6 +- .../tests/it/layer_blending_options.rs | 5 +- crates/ui-egui/tests/it/layer_clipboard.rs | 10 +- crates/ui-egui/tests/it/layer_multi_select.rs | 5 +- crates/ui-egui/tests/it/layer_rename.rs | 5 +- crates/ui-egui/tests/it/layer_toolbar.rs | 5 +- crates/ui-egui/tests/it/layers_panel.rs | 21 +- crates/ui-egui/tests/it/levels_editor.rs | 6 +- crates/ui-egui/tests/it/log_panel_680.rs | 5 +- crates/ui-egui/tests/it/main.rs | 4 +- crates/ui-egui/tests/it/mask_export.rs | 5 +- crates/ui-egui/tests/it/mask_fill_rows.rs | 15 +- .../ui-egui/tests/it/mask_paint_grayscale.rs | 6 +- crates/ui-egui/tests/it/mask_value_swap.rs | 5 +- crates/ui-egui/tests/it/named_layouts.rs | 7 +- crates/ui-egui/tests/it/nav_buttons.rs | 6 +- .../tests/it/new_project_baked_maps.rs | 20 +- crates/ui-egui/tests/it/new_project_window.rs | 5 +- crates/ui-egui/tests/it/output_templates.rs | 5 +- crates/ui-egui/tests/it/panel_header.rs | 5 +- crates/ui-egui/tests/it/path_in_view.rs | 15 +- crates/ui-egui/tests/it/path_list.rs | 5 +- crates/ui-egui/tests/it/pen_pressure.rs | 5 +- crates/ui-egui/tests/it/polygon_fill.rs | 30 +- crates/ui-egui/tests/it/popup_press_close.rs | 2 +- crates/ui-egui/tests/it/project_config.rs | 12 +- crates/ui-egui/tests/it/properties_lists.rs | 6 +- .../ui-egui/tests/it/properties_min_width.rs | 60 +-- crates/ui-egui/tests/it/properties_popup.rs | 5 +- crates/ui-egui/tests/it/properties_scroll.rs | 5 +- crates/ui-egui/tests/it/rail.rs | 20 +- crates/ui-egui/tests/it/reference_order.rs | 5 +- crates/ui-egui/tests/it/rename_anchor.rs | 5 +- crates/ui-egui/tests/it/reset_ui.rs | 5 +- crates/ui-egui/tests/it/settings_window.rs | 5 +- crates/ui-egui/tests/it/shelf_click.rs | 5 +- crates/ui-egui/tests/it/shelf_drop.rs | 11 +- .../ui-egui/tests/it/shelf_hover_preview.rs | 3 +- crates/ui-egui/tests/it/shelf_panel.rs | 5 +- crates/ui-egui/tests/it/shift_lines_2d.rs | 20 +- crates/ui-egui/tests/it/shift_lines_3d.rs | 5 +- crates/ui-egui/tests/it/shortcut_keys.rs | 5 +- crates/ui-egui/tests/it/shortcut_list.rs | 5 +- crates/ui-egui/tests/it/side_panels.rs | 5 +- crates/ui-egui/tests/it/skew_paint.rs | 5 +- crates/ui-egui/tests/it/smudge_channels.rs | 5 +- crates/ui-egui/tests/it/snapped_lines.rs | 5 +- crates/ui-egui/tests/it/source_picker.rs | 12 +- crates/ui-egui/tests/it/split_divider.rs | 33 +- crates/ui-egui/tests/it/stencil.rs | 5 +- crates/ui-egui/tests/it/symmetry.rs | 7 +- crates/ui-egui/tests/it/symmetry_2d.rs | 5 +- crates/ui-egui/tests/it/template_invert.rs | 5 +- crates/ui-egui/tests/it/templates_681.rs | 5 +- .../ui-egui/tests/it/tile_generator_panel.rs | 8 +- crates/ui-egui/tests/it/tool_availability.rs | 18 +- .../ui-egui/tests/it/tool_settings_saved.rs | 5 +- crates/ui-egui/tests/it/toolbar.rs | 6 +- crates/ui-egui/tests/it/user_smart_mask.rs | 5 +- crates/ui-egui/tests/it/view2d_navigation.rs | 8 +- crates/ui-egui/tests/it/view2d_tiles.rs | 11 +- crates/ui-egui/tests/it/view_mode_picker.rs | 5 +- crates/ui-egui/tests/it/window_menu_684.rs | 5 +- crates/ui-egui/tests/list_panels.rs | 10 +- crates/ui-egui/tests/project_limits.rs | 8 +- crates/ui-egui/tests/shader_panel.rs | 5 +- crates/ui-egui/tests/ui_snapshots.rs | 378 +++++++++++++----- 130 files changed, 1092 insertions(+), 440 deletions(-) diff --git a/apps/texturecraft/src/main.rs b/apps/texturecraft/src/main.rs index fbd5aeb3..badd6cb9 100644 --- a/apps/texturecraft/src/main.rs +++ b/apps/texturecraft/src/main.rs @@ -385,13 +385,10 @@ mod tests { /// Points within which a put-back lands on the press point (the system rounds it to whole pixels) const PUT_BACK_REACH: f32 = 1.0; - /// One frame of the window: the system's events go through the window's raw input hook, as eframe sends them; returns what the app asked of the window + /// One frame of the window: the system's events go through the window's raw input hook (the harness runs it before + /// every pass, as eframe does); returns what the app asked of the window fn window_frame(harness: &mut egui_kittest::Harness<'static, Shell>, events: Vec) -> Vec { - let ctx = harness.ctx.clone(); - let mut raw = harness.input_mut().clone(); - raw.events.extend(events); - eframe::App::raw_input_hook(harness.state_mut(), &ctx, &mut raw); - *harness.input_mut() = raw; + harness.input_mut().events.extend(events); harness.step(); harness.output().viewport_output.get(&egui::ViewportId::ROOT).map(|viewport| viewport.commands.clone()).unwrap_or_default() } diff --git a/crates/ui-egui/src/display_settings.rs b/crates/ui-egui/src/display_settings.rs index a689add1..1f244d3e 100644 --- a/crates/ui-egui/src/display_settings.rs +++ b/crates/ui-egui/src/display_settings.rs @@ -287,7 +287,11 @@ mod tests { fn display_harness() -> Harness<'static, TextureCraftApp> { let session = texturecraft_engine::sample_session(128, 32).unwrap(); - let mut harness = Harness::builder().with_size(egui::vec2(1600.0, 1200.0)).with_step_dt(0.01).with_context_setup(crate::framework::install_headless).build_eframe(|cc| TextureCraftApp::new(cc, session)); + let mut harness = Harness::builder() + .with_size(egui::vec2(1600.0, 1200.0)) + .with_step_dt(0.01) + .with_context_setup(crate::framework::install_headless) + .build_eframe(|cc| TextureCraftApp::new(cc, session)); harness.state_mut().ui.prefs.language = "en".into(); harness.state_mut().ui.dock.focus(crate::docking::Panel::Display); harness.run_steps(4); diff --git a/crates/ui-egui/src/docking.rs b/crates/ui-egui/src/docking.rs index d665e593..c30b6b6b 100644 --- a/crates/ui-egui/src/docking.rs +++ b/crates/ui-egui/src/docking.rs @@ -486,7 +486,8 @@ pub fn show(app: &mut TextureCraftApp, ui: &mut Ui) { // The specs leave the app while its panels borrow it, and come back with their revision. let specs = std::mem::take(&mut app.docks.specs); // Panels arrange in a split tree around the viewport; floating title bars only move windows. - let config = DockConfig::default().new_dock_zones(false).title_bar_docks(false); + // Each closable tab has its close button, as each group header had one for its shown panel. + let config = DockConfig::default().new_dock_zones(false).title_bar_docks(false).tab_close_buttons(true); let output = { let tokens = Tokens::get(&context); let mut panels = Panels { app: &mut *app, tokens, layout: shown.layout().clone() }; @@ -645,7 +646,10 @@ mod tests { assert!(validate(&workspace).is_ok()); for panel in Panel::ALL { - assert!(workspace.layout().contains(&panel) || workspace.hidden().iter().any(|(hidden, _)| *hidden == panel), "{panel:?} is neither shown nor hidden"); + assert!( + workspace.layout().contains(&panel) || workspace.hidden().iter().any(|(hidden, _)| *hidden == panel), + "{panel:?} is neither shown nor hidden" + ); } assert_eq!(panels_of(&workspace), [Panel::Assets, Panel::Viewport, Panel::TextureSetList, Panel::Layers, Panel::TextureSetSettings, Panel::Properties]); diff --git a/crates/ui-egui/src/framework.rs b/crates/ui-egui/src/framework.rs index 4ceada6d..a28d85f9 100644 --- a/crates/ui-egui/src/framework.rs +++ b/crates/ui-egui/src/framework.rs @@ -6,7 +6,7 @@ //! //! The runtime takes Escape, Tab and the clipboard events for the whole window unless one of TextureCraft's own egui //! widgets has the keyboard. The window's Escape is read with [`escape_pressed`] and taken with -//! [`take_window_cancel`]; the 3D/2D viewport is declared to the runtime with [`host_canvas`], which keeps Tab (Hide +//! [`take_window_cancel`], its plain Enter taken with [`take_window_submit`]; the 3D/2D viewport is declared to the runtime with [`host_canvas`], which keeps Tab (Hide //! UI), the edit chords and the clipboard events in egui's input for TextureCraft's shortcuts. use std::sync::{Arc, OnceLock}; @@ -143,11 +143,22 @@ pub(crate) fn take_window_cancel(ctx: &egui::Context) -> bool { window_cancel(ctx, true) } +/// Takes the window's submit (a plain Enter while nothing has framework focus) when it is there: no later reader sees +/// it. +pub(crate) fn take_window_submit(ctx: &egui::Context) -> bool { + window_intent(ctx, Intent::Submit, true) +} + /// Whether the window's cancel is there and untaken; `take` takes it. fn window_cancel(ctx: &egui::Context, take: bool) -> bool { + window_intent(ctx, Intent::Cancel, take) +} + +/// Whether the window's `intent` is there and untaken; `take` takes it. +fn window_intent(ctx: &egui::Context, intent: Intent, take: bool) -> bool { let mut pending = false; with_window_intents(ctx, false, |intents| { - pending = if take { intents.take(Intent::Cancel) } else { intents.untaken(&Intent::Cancel) }; + pending = if take { intents.take(intent.clone()) } else { intents.untaken(&intent) }; take && pending }); pending diff --git a/crates/ui-egui/src/lib.rs b/crates/ui-egui/src/lib.rs index afada79b..bc6b1488 100644 --- a/crates/ui-egui/src/lib.rs +++ b/crates/ui-egui/src/lib.rs @@ -43,8 +43,8 @@ mod filter_slot; mod filter_transform_rows; mod folder_properties; pub mod fonts; -pub mod framework; mod frame_gizmo; +pub mod framework; mod generator_panel; pub mod gpu; mod gray_slider; @@ -137,7 +137,6 @@ mod session_log_file; pub mod settings_window; pub mod shader_settings; pub mod shelf; -mod shortcut_dispatch; mod shelf_entry; mod shelf_folders; pub mod shelf_panes; @@ -145,6 +144,7 @@ pub mod shelf_preview; mod shelf_tabs; mod shelf_toolbar; pub mod shelf_view; +mod shortcut_dispatch; mod slot_thumbnail; #[cfg(not(target_arch = "wasm32"))] mod smart_mask_menu; diff --git a/crates/ui-egui/src/menus.rs b/crates/ui-egui/src/menus.rs index 40177667..656e36f4 100644 --- a/crates/ui-egui/src/menus.rs +++ b/crates/ui-egui/src/menus.rs @@ -458,12 +458,15 @@ pub fn shortcuts(app: &mut TextureCraftApp, ctx: &egui::Context) { return; } - // A plain Escape no widget of TextureCraft's took is the window's cancel: it runs the Escape handlers and shortcuts below - if crate::framework::take_window_cancel(ctx) { - ctx.input_mut(|i| { - let modifiers = i.modifiers; - i.events.insert(0, egui::Event::Key { key: Key::Escape, physical_key: Some(Key::Escape), pressed: true, repeat: false, modifiers }); - }); + // A plain Escape or Enter while no widget of TextureCraft's has the keyboard is the window's cancel or submit: back + // in egui's input, it runs the Escape and Enter handlers below, the shortcuts and the Path tool's keys + for (key, taken) in [(Key::Escape, crate::framework::take_window_cancel(ctx)), (Key::Enter, crate::framework::take_window_submit(ctx))] { + if taken { + ctx.input_mut(|i| { + let modifiers = i.modifiers; + i.events.insert(0, egui::Event::Key { key, physical_key: Some(key), pressed: true, repeat: false, modifiers }); + }); + } } // The dispatcher reads clipboard events as shortcuts; a pasted image also means Ctrl+V diff --git a/crates/ui-egui/src/move_on_model.rs b/crates/ui-egui/src/move_on_model.rs index d5f4e349..e65105c7 100644 --- a/crates/ui-egui/src/move_on_model.rs +++ b/crates/ui-egui/src/move_on_model.rs @@ -292,7 +292,7 @@ mod tests { /// Presses the left button on Move on model (the preview square) and holds it; returns the system's pointer, resting there fn press_the_button(harness: &mut Harness) -> SystemPointer { let at = harness.get_by_label("Move on model").rect().center(); - let mut pointer = SystemPointer::at(harness, at); + let mut pointer = SystemPointer::in_app(harness, at); pointer.button(harness, PointerButton::Primary, true, Modifiers::NONE); pointer } @@ -439,7 +439,7 @@ mod tests { assert!((pad.width() - pad.height()).abs() < 1.0 && pad.width() > 60.0, "Move on model is the preview square, no row of its own: {pad:?}"); let before = projection(&harness, layer); - let mut pointer = SystemPointer::at(&mut harness, pad.left_top() + vec2(4.0, 4.0)); + let mut pointer = SystemPointer::in_app(&mut harness, pad.left_top() + vec2(4.0, 4.0)); pointer.button(&mut harness, PointerButton::Primary, true, Modifiers::NONE); assert_eq!(harness.state().moving_on_model, Some(MoveOnModel::layer(layer)), "a press at its corner starts the hold"); diff --git a/crates/ui-egui/src/pane_split.rs b/crates/ui-egui/src/pane_split.rs index f9768a08..ce441a9c 100644 --- a/crates/ui-egui/src/pane_split.rs +++ b/crates/ui-egui/src/pane_split.rs @@ -87,7 +87,12 @@ pub(crate) fn split_rect(rect: Rect, axis: Axis, size: SplitSize, gap: f32, mini } fn valid_rect(rect: Rect) -> bool { - rect.min.is_finite() && rect.max.is_finite() && rect.width().is_finite() && rect.height().is_finite() && rect.min.x <= rect.max.x && rect.min.y <= rect.max.y + rect.min.is_finite() + && rect.max.is_finite() + && rect.width().is_finite() + && rect.height().is_finite() + && rect.min.x <= rect.max.x + && rect.min.y <= rect.max.y } fn valid_nonnegative(value: f32) -> bool { @@ -149,7 +154,10 @@ impl<'a> ResizeHandle<'a> { && self.rect.height() > 0.0 && valid_rect(hit) && (0.0..=4096.0).contains(&self.hit_margin) - && self.value.as_ref().is_none_or(|(value, range)| value.is_finite() && range.start().is_finite() && range.end().is_finite() && range.start() <= range.end()); + && self + .value + .as_ref() + .is_none_or(|(value, range)| value.is_finite() && range.start().is_finite() && range.end().is_finite() && range.start() <= range.end()); let inert = Rect::from_min_size(ui.min_rect().min, Vec2::ZERO); let mut response = ui.interact(if valid { hit } else { inert }, self.id, if valid { Sense::drag() } else { Sense::hover() }); let enabled = valid && response.enabled(); diff --git a/crates/ui-egui/src/pointer_lock/system_pointer.rs b/crates/ui-egui/src/pointer_lock/system_pointer.rs index 156cd8ee..d41d817e 100644 --- a/crates/ui-egui/src/pointer_lock/system_pointer.rs +++ b/crates/ui-egui/src/pointer_lock/system_pointer.rs @@ -12,12 +12,25 @@ pub(crate) struct SystemPointer { pub(crate) put_backs: usize, /// The system folds a put-back into the next move, as Windows does, instead of reporting it as a move of its own pub(crate) folds: bool, + /// The harness has no eframe app, so the test runs the app's raw input rewrite itself; an app harness runs the + /// app's `raw_input_hook` before every pass, as eframe does + rewrites: bool, } impl SystemPointer { - /// The pointer resting at `at` over the window + /// The pointer resting at `at` over a window that shows a bare UI, whose raw input the test rewrites as the + /// app's hook would pub(crate) fn at(harness: &mut Harness<'_, S>, at: Pos2) -> SystemPointer { - let mut pointer = SystemPointer { at, locked: false, hidden: false, put_backs: 0, folds: false }; + Self::start(harness, at, true) + } + + /// The pointer resting at `at` over the app's window, whose own raw input hook rewrites the input + pub(crate) fn in_app(harness: &mut Harness<'_, S>, at: Pos2) -> SystemPointer { + Self::start(harness, at, false) + } + + fn start(harness: &mut Harness<'_, S>, at: Pos2, rewrites: bool) -> SystemPointer { + let mut pointer = SystemPointer { at, locked: false, hidden: false, put_backs: 0, folds: false, rewrites }; harness.input_mut().events.push(Event::PointerMoved(at)); pointer.frame(harness); pointer @@ -52,8 +65,10 @@ impl SystemPointer { /// One frame of everything the system sent since the last: the app's raw input hook rewrites it, the app runs, and the pointer does what the app asked pub(crate) fn frame(&mut self, harness: &mut Harness<'_, S>) { - let ctx = harness.ctx.clone(); - super::rewrite(&ctx, harness.input_mut()); + if self.rewrites { + let ctx = harness.ctx.clone(); + super::rewrite(&ctx, harness.input_mut()); + } harness.step(); let output = harness.output(); self.hidden = output.platform_output.cursor_icon == CursorIcon::None; diff --git a/crates/ui-egui/src/pointer_lock/tests.rs b/crates/ui-egui/src/pointer_lock/tests.rs index 10de74ee..4118a280 100644 --- a/crates/ui-egui/src/pointer_lock/tests.rs +++ b/crates/ui-egui/src/pointer_lock/tests.rs @@ -108,7 +108,7 @@ fn a_number_field_scrubs_past_the_edge_with_the_pointer_held() { let (mut harness, layer) = crate::frame_gizmo::tests::fill_app("triplanar"); hold_like(&harness.ctx, Hold::PutBack); let press = harness.get_by_label("Offset X").rect().center(); - let mut pointer = SystemPointer::at(&mut harness, press); + let mut pointer = SystemPointer::in_app(&mut harness, press); pointer.button(&mut harness, PointerButton::Primary, true, Modifiers::NONE); let window = harness.ctx.content_rect().width(); pointer.drags(&mut harness, vec2(2.0 * window, 0.0), 40, Modifiers::NONE); diff --git a/crates/ui-egui/src/property_sheet/color_bar.rs b/crates/ui-egui/src/property_sheet/color_bar.rs index def850d8..c83ff515 100644 --- a/crates/ui-egui/src/property_sheet/color_bar.rs +++ b/crates/ui-egui/src/property_sheet/color_bar.rs @@ -285,9 +285,8 @@ impl PropertySheet<'_> { }); // Escape ends hex editing first even when egui has already dropped the field's focus - let escape = crate::framework::escape_pressed(&ctx) - && ctx.memory(|memory| memory.focused().is_none_or(|focused| focused == bar.id)) - && !hex_took_escape(&ctx); + let escape = + crate::framework::escape_pressed(&ctx) && ctx.memory(|memory| memory.focused().is_none_or(|focused| focused == bar.id)) && !hex_took_escape(&ctx); if closed || (!list_open && !waiting && (pressed_outside || escape)) { state.open = false; crate::color_picker::forget_window(&ctx); diff --git a/crates/ui-egui/src/property_sheet/mod.rs b/crates/ui-egui/src/property_sheet/mod.rs index 0a81211d..7465ef34 100644 --- a/crates/ui-egui/src/property_sheet/mod.rs +++ b/crates/ui-egui/src/property_sheet/mod.rs @@ -62,8 +62,8 @@ pub(crate) use preview_size::PreviewSize; pub(crate) use properties_scroll::{PropertiesScroll, PropertiesSelection}; pub(crate) use row_lead::RowLead; pub(crate) use section_tabs::{ - SectionScope, TAB_GAP, TAB_ICON_CENTER, TAB_ICON_SIZE, TAB_NAME_LEFT, TAB_PADDING, TAB_ROUNDING, TAB_TEXT_SIZE, TAB_TOP, forget_sections, - in_scope, room_past_end, section_tabs, + SectionScope, TAB_GAP, TAB_ICON_CENTER, TAB_ICON_SIZE, TAB_NAME_LEFT, TAB_PADDING, TAB_ROUNDING, TAB_TEXT_SIZE, TAB_TOP, forget_sections, in_scope, + room_past_end, section_tabs, }; pub(crate) use sheet::PropertySheet; pub(crate) use slot_response::SlotResponse; diff --git a/crates/ui-egui/src/render_mode/tests.rs b/crates/ui-egui/src/render_mode/tests.rs index a0bd842d..08218627 100644 --- a/crates/ui-egui/src/render_mode/tests.rs +++ b/crates/ui-egui/src/render_mode/tests.rs @@ -39,7 +39,10 @@ fn environment_cache_retains_source_identity_until_replaced() { // The harness draws once; parallel translation tests must not change its language mid-frame let _language = crate::i18n::TEST_LANGUAGE.lock().unwrap_or_else(std::sync::PoisonError::into_inner); - let mut app = egui_kittest::Harness::builder().with_context_setup(crate::framework::install_headless).build_eframe(|context| crate::TextureCraftApp::new(context, session())).into_state(); + let mut app = egui_kittest::Harness::builder() + .with_context_setup(crate::framework::install_headless) + .build_eframe(|context| crate::TextureCraftApp::new(context, session())) + .into_state(); app.session.doc.project.display.environment = "resource:environment".into(); let source = Arc::new(ImageRes::new(2, 1, vec![[1.0, 0.0, 0.0, 1.0]; 2], false)); let original_source = Arc::downgrade(&source); @@ -71,7 +74,10 @@ fn environment_cache_retains_source_identity_until_replaced() { #[test] fn a_new_display_background_restarts_the_render() { let _language = crate::i18n::TEST_LANGUAGE.lock().unwrap_or_else(std::sync::PoisonError::into_inner); - let mut app = egui_kittest::Harness::builder().with_context_setup(crate::framework::install_headless).build_eframe(|context| crate::TextureCraftApp::new(context, session())).into_state(); + let mut app = egui_kittest::Harness::builder() + .with_context_setup(crate::framework::install_headless) + .build_eframe(|context| crate::TextureCraftApp::new(context, session())) + .into_state(); let before = super::key(&app, "scene", (64, 64)); assert_eq!(super::key(&app, "scene", (64, 64)), before); @@ -109,7 +115,8 @@ fn gpu_app() -> Option { let mut app = egui_kittest::Harness::builder() .with_size(egui::vec2(800.0, 600.0)) .renderer(WgpuTestRenderer::from_render_state(render_state)) - .with_context_setup(crate::framework::install_headless).build_eframe(|context| crate::TextureCraftApp::new(context, session())) + .with_context_setup(crate::framework::install_headless) + .build_eframe(|context| crate::TextureCraftApp::new(context, session())) .into_state(); app.session.update(); for cache in &mut app.session.caches { diff --git a/crates/ui-egui/src/shelf_panes.rs b/crates/ui-egui/src/shelf_panes.rs index 26ef28a3..42b8494e 100644 --- a/crates/ui-egui/src/shelf_panes.rs +++ b/crates/ui-egui/src/shelf_panes.rs @@ -1,14 +1,14 @@ //! The shelf's side panes left of the grid, toggled from the toolbar: saved searches and the folder tree -use craft_behavior::flow::Axis; use craft_behavior::dock::SplitSize; +use craft_behavior::flow::Axis; use egui::{Rect, RichText, Ui, UiBuilder}; use egui_phosphor::regular as ic; use serde::{Deserialize, Serialize}; use crate::TextureCraftApp; -use crate::pane_split::{ResizeHandle, ResizeHandleStyle, SplitLayout, split_rect}; use crate::i18n::{n_, tr}; +use crate::pane_split::{ResizeHandle, ResizeHandleStyle, SplitLayout, split_rect}; use crate::saved_search::SavedSearch; use crate::shelf::TABS; use crate::theme::Tokens; diff --git a/crates/ui-egui/src/shortcut_dispatch.rs b/crates/ui-egui/src/shortcut_dispatch.rs index b09dd531..916ae385 100644 --- a/crates/ui-egui/src/shortcut_dispatch.rs +++ b/crates/ui-egui/src/shortcut_dispatch.rs @@ -56,9 +56,9 @@ impl Dispatcher { match &event { Event::Key { pressed: true, repeat, .. } => { let key = key_input(&event, platform, input); - if self.layout.resolve(&key).is_some() { + if let Some(meant) = self.layout.resolve(&key) { let press = Press { input: &key, repeat: *repeat, now, active: &Active::NONE, outer: &[] }; - let hit = self.matcher.press(&self.layout, keymap, &press).filter(&mut accept); + let hit = self.matcher.press(&self.layout, keymap, &press).filter(|hit| !delete_stand_in(hit, meant)).filter(&mut accept); if let Some((j, _)) = causes[i] { caused_taken[j] = Some(hit.is_some()); } @@ -111,6 +111,13 @@ impl Dispatcher { } } +/// Whether `hit` ran a Delete binding for a Backspace press or the other way round: `Matcher` lets the two keys stand +/// for each other, while TextureCraft binds them apart (Delete removes the selected layer, Backspace a Path tool point). +fn delete_stand_in(hit: &Hit, meant: craft_keymap::Chord) -> bool { + let twins = |a: Key, b: Key| matches!((a, b), (Key::Delete, Key::Backspace) | (Key::Backspace, Key::Delete)); + twins(meant.key, hit.trigger.chord.key) +} + /// A press as [`KeyInput::from_egui`] reads it, with the Latin layout's character `input` reports /// for its key. fn key_input(event: &Event, platform: Platform, input: &InputState) -> KeyInput { @@ -239,6 +246,21 @@ mod tests { assert_eq!(input.events, [press(EguiKey::Q, egui::Modifiers::NONE), Event::Text("q".into())]); } + /// Backspace runs no Delete binding: TextureCraft binds the two keys apart. + #[test] + fn backspace_does_not_run_a_delete_binding() { + let def = CommandDef::new("layer.remove", "layer.remove", Scope::app()).with_default(Binding::parse("Delete").unwrap()); + let keymap = Keymap::new(vec![def], Scopes::new(), Platform::Windows); + let mut input = InputState::default(); + input.events = vec![press(EguiKey::Backspace, egui::Modifiers::NONE)]; + assert!(Dispatcher::default().dispatch_filtered(&mut input, &keymap, |_| true).is_empty()); + assert_eq!(input.events, [press(EguiKey::Backspace, egui::Modifiers::NONE)], "the press stays for the Path tool"); + + input.events = vec![press(EguiKey::Delete, egui::Modifiers::NONE)]; + let hits = Dispatcher::default().dispatch_filtered(&mut input, &keymap, |_| true); + assert_eq!(hits.iter().map(|hit| hit.command.id.as_str()).collect::>(), ["layer.remove"]); + } + /// The desktop's Copy event runs the copy command; declined, it stays for egui. #[test] fn a_clipboard_event_runs_its_chord_unless_declined() { diff --git a/crates/ui-egui/src/ui_state_store.rs b/crates/ui-egui/src/ui_state_store.rs index b4483b88..b9dd4ee7 100644 --- a/crates/ui-egui/src/ui_state_store.rs +++ b/crates/ui-egui/src/ui_state_store.rs @@ -385,13 +385,14 @@ pub(crate) mod tests { let mut storage = MemoryStorage::default(); UiStateStore::new(Some(file.clone())).save(&ui, &mut storage); let saved = std::fs::read_to_string(&file).unwrap(); - assert!(saved.contains("\"Assets\"") && saved.contains("\"version\": 2"), "{saved}"); + let version = format!("\"version\": {}", crate::docking::Workspace::VERSION); + assert!(saved.contains("\"Assets\"") && saved.contains(&version), "{saved}"); let unreadable = [ // A panel this build does not know saved.replacen("\"Assets\"", "\"Bogus\"", 1), // A layout from a newer format - saved.replacen("\"version\": 2", "\"version\": 99", 1), + saved.replacen(&version, "\"version\": 99", 1), // Not a saved state "not json".to_owned(), ]; diff --git a/crates/ui-egui/src/updates_ui.rs b/crates/ui-egui/src/updates_ui.rs index 47740973..33953fa4 100644 --- a/crates/ui-egui/src/updates_ui.rs +++ b/crates/ui-egui/src/updates_ui.rs @@ -146,7 +146,10 @@ mod tests { let root = std::env::temp_dir().join(format!("texturecraft-updates-{}-{test}", std::process::id())); let mut session = texturecraft_engine::sample_session(256, 64).unwrap(); session.modified = modified; - let mut h = Harness::builder().with_size(egui::vec2(1600.0, 960.0)).with_context_setup(crate::framework::install_headless).build_eframe(|cc| TextureCraftApp::new(cc, session)); + let mut h = Harness::builder() + .with_size(egui::vec2(1600.0, 960.0)) + .with_context_setup(crate::framework::install_headless) + .build_eframe(|cc| TextureCraftApp::new(cc, session)); h.state_mut().updates_rt.updater = Updater::new(&crate::UPDATE_APP, "0.0.1").with_source(ask).with_paths(Paths::under(&root)).with_pins_path(root.join("pins.json")); h.run_steps(2); diff --git a/crates/ui-egui/src/viewport.rs b/crates/ui-egui/src/viewport.rs index b6a98b6a..95f05acf 100644 --- a/crates/ui-egui/src/viewport.rs +++ b/crates/ui-egui/src/viewport.rs @@ -2612,7 +2612,9 @@ mod tests { for tool in [Tool::Paint, Tool::PolygonFill] { let session = Session::new_project("t", primitives::plane(2.0, 4), "test", None, 128).unwrap(); - let mut harness = egui_kittest::Harness::builder().with_context_setup(crate::framework::install_headless).build_eframe(|context| TextureCraftApp::new(context, session)); + let mut harness = egui_kittest::Harness::builder() + .with_context_setup(crate::framework::install_headless) + .build_eframe(|context| TextureCraftApp::new(context, session)); let app = harness.state_mut(); app.session.tool.tool = tool; let history = app.session.history_labels().len(); @@ -2641,7 +2643,9 @@ mod tests { // The harness draws the UI, so another test's interface language must not be active let _language = crate::i18n::TEST_LANGUAGE.lock().unwrap_or_else(std::sync::PoisonError::into_inner); let session = Session::new_project("t", primitives::plane(2.0, 4), "test", None, 128).unwrap(); - let mut harness = egui_kittest::Harness::builder().with_context_setup(crate::framework::install_headless).build_eframe(|context| TextureCraftApp::new(context, session)); + let mut harness = egui_kittest::Harness::builder() + .with_context_setup(crate::framework::install_headless) + .build_eframe(|context| TextureCraftApp::new(context, session)); let app = harness.state_mut(); app.ui.mode = crate::state::Mode::Painting; app.session.view = ViewMode::Mask(LayerId(7)); @@ -2667,7 +2671,9 @@ mod tests { execute(&mut session, "layer.add.fill", &json!(null)).unwrap(); let effect = texturecraft_engine::core::LayerId(execute(&mut session, "mask.add.colorSelection", &json!(null)).unwrap()["effect"].as_u64().unwrap()); session.target = StackTarget::Effect(effect); - let mut harness = egui_kittest::Harness::builder().with_context_setup(crate::framework::install_headless).build_eframe(|context| TextureCraftApp::new(context, session)); + let mut harness = egui_kittest::Harness::builder() + .with_context_setup(crate::framework::install_headless) + .build_eframe(|context| TextureCraftApp::new(context, session)); harness.run_steps(2); crate::id_color_pick::IdColorPick::start(harness.state_mut(), effect, None); @@ -2684,7 +2690,10 @@ mod tests { fn a_waiting_eyedropper_keeps_a_2d_view_click_from_painting() { let _language = crate::i18n::TEST_LANGUAGE.lock().unwrap_or_else(std::sync::PoisonError::into_inner); let session = texturecraft_engine::sample_session(256, 64).unwrap(); - let mut harness = egui_kittest::Harness::builder().with_size(egui::vec2(1600.0, 960.0)).with_context_setup(crate::framework::install_headless).build_eframe(|context| TextureCraftApp::new(context, session)); + let mut harness = egui_kittest::Harness::builder() + .with_size(egui::vec2(1600.0, 960.0)) + .with_context_setup(crate::framework::install_headless) + .build_eframe(|context| TextureCraftApp::new(context, session)); harness.state_mut().ui.layout = ViewLayout::Only2D; harness.state_mut().session.tool.tool = Tool::PolygonFill; harness.run_steps(4); @@ -2730,7 +2739,9 @@ mod tests { let effect = texturecraft_engine::core::LayerId(result["committed"]["effect"].as_u64().unwrap()); let EffectKind::Path(paths) = &mut session.doc.project.effect_mut(effect).unwrap().kind else { panic!("path effect") }; paths.resize(8, paths[0].clone()); - let mut harness = egui_kittest::Harness::builder().with_context_setup(crate::framework::install_headless).build_eframe(|context| TextureCraftApp::new(context, session)); + let mut harness = egui_kittest::Harness::builder() + .with_context_setup(crate::framework::install_headless) + .build_eframe(|context| TextureCraftApp::new(context, session)); let context = egui::Context::default(); let mut previous = Vec::>>>>::new(); @@ -2929,7 +2940,9 @@ mod tests { // Hold the language lock while drawing the harness let _language = crate::i18n::TEST_LANGUAGE.lock().unwrap_or_else(std::sync::PoisonError::into_inner); let session = texturecraft_engine::sample_session(256, 64).unwrap(); - let mut harness = egui_kittest::Harness::builder().with_context_setup(crate::framework::install_headless).build_eframe(|context| TextureCraftApp::new(context, session)); + let mut harness = egui_kittest::Harness::builder() + .with_context_setup(crate::framework::install_headless) + .build_eframe(|context| TextureCraftApp::new(context, session)); let app = harness.state_mut(); app.ui.mode = crate::state::Mode::Baking; let before = bake_visualization(app).unwrap(); diff --git a/crates/ui-egui/src/web_files.rs b/crates/ui-egui/src/web_files.rs index ae910688..c4c5c851 100644 --- a/crates/ui-egui/src/web_files.rs +++ b/crates/ui-egui/src/web_files.rs @@ -435,7 +435,8 @@ mod tests { #[test] fn mesh_picks_only_update_the_current_new_project_request() { let session = Session::closed().unwrap(); - let mut harness = Harness::builder().with_context_setup(crate::framework::install_headless).build_eframe(|context| TextureCraftApp::new(context, session)); + let mut harness = + Harness::builder().with_context_setup(crate::framework::install_headless).build_eframe(|context| TextureCraftApp::new(context, session)); let app = harness.state_mut(); crate::new_project_advanced::open(app); app.ui.new_project.mesh_request_id = 2; @@ -457,7 +458,8 @@ mod tests { #[test] fn environment_pick_after_close_does_not_edit_the_placeholder() { let session = texturecraft_engine::sample_session(128, 32).unwrap(); - let mut harness = Harness::builder().with_context_setup(crate::framework::install_headless).build_eframe(|context| TextureCraftApp::new(context, session)); + let mut harness = + Harness::builder().with_context_setup(crate::framework::install_headless).build_eframe(|context| TextureCraftApp::new(context, session)); let png = texturecraft_engine::formats::gray16_png(1, 1, [0.5].into_iter()).unwrap(); let old_project_id = harness.state().session.project_id; @@ -479,7 +481,8 @@ mod tests { #[test] fn environment_pick_from_replaced_project_does_not_edit_the_new_project() { let session = texturecraft_engine::sample_session(128, 32).unwrap(); - let mut harness = Harness::builder().with_context_setup(crate::framework::install_headless).build_eframe(|context| TextureCraftApp::new(context, session)); + let mut harness = + Harness::builder().with_context_setup(crate::framework::install_headless).build_eframe(|context| TextureCraftApp::new(context, session)); let png = texturecraft_engine::formats::gray16_png(1, 1, [0.5].into_iter()).unwrap(); let old_project_id = harness.state().session.project_id; @@ -497,7 +500,8 @@ mod tests { #[test] fn bake_mesh_picks_after_close_do_not_edit_the_placeholder() { let session = texturecraft_engine::sample_session(128, 32).unwrap(); - let mut harness = Harness::builder().with_context_setup(crate::framework::install_headless).build_eframe(|context| TextureCraftApp::new(context, session)); + let mut harness = + Harness::builder().with_context_setup(crate::framework::install_headless).build_eframe(|context| TextureCraftApp::new(context, session)); let old_project_id = harness.state().session.project_id; assert!(harness.state_mut().run("file.close", serde_json::Value::Null).is_some()); let cage = harness.state().session.mesh_obj_bytes().unwrap(); diff --git a/crates/ui-egui/src/windows.rs b/crates/ui-egui/src/windows.rs index abe3efea..25ea03d4 100644 --- a/crates/ui-egui/src/windows.rs +++ b/crates/ui-egui/src/windows.rs @@ -703,7 +703,10 @@ mod tests { fn harness() -> Harness<'static, TextureCraftApp> { let session = texturecraft_engine::sample_session(256, 64).unwrap(); - let mut h = Harness::builder().with_size(vec2(1600.0, 960.0)).with_context_setup(crate::framework::install_headless).build_eframe(|cc| TextureCraftApp::new(cc, session)); + let mut h = Harness::builder() + .with_size(vec2(1600.0, 960.0)) + .with_context_setup(crate::framework::install_headless) + .build_eframe(|cc| TextureCraftApp::new(cc, session)); // Match English labels independently of the system locale h.state_mut().ui.prefs.language = "en".into(); diff --git a/crates/ui-egui/tests/bake_preview.rs b/crates/ui-egui/tests/bake_preview.rs index 42728170..1e497d5a 100644 --- a/crates/ui-egui/tests/bake_preview.rs +++ b/crates/ui-egui/tests/bake_preview.rs @@ -19,7 +19,10 @@ fn harness() -> Harness<'static, TextureCraftApp> { } session.view = ViewMode::UvChecker; - let mut harness = Harness::builder().with_size(egui::vec2(1400.0, 900.0)).with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|context| TextureCraftApp::new(context, session)); + let mut harness = Harness::builder() + .with_size(egui::vec2(1400.0, 900.0)) + .with_context_setup(texturecraft_ui_egui::framework::install_headless) + .build_eframe(|context| TextureCraftApp::new(context, session)); harness.state_mut().ui.mode = Mode::Baking; harness.run_steps(3); harness diff --git a/crates/ui-egui/tests/brush_cursor_2d.rs b/crates/ui-egui/tests/brush_cursor_2d.rs index 71768d14..70e75731 100644 --- a/crates/ui-egui/tests/brush_cursor_2d.rs +++ b/crates/ui-egui/tests/brush_cursor_2d.rs @@ -9,7 +9,10 @@ use texturecraft_ui_egui::state::{Mode, ViewLayout}; fn harness() -> Harness<'static, TextureCraftApp> { let session = texturecraft_engine::sample_session(256, 64).unwrap(); - let mut harness = Harness::builder().with_size(egui::vec2(1600.0, 960.0)).with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|context| TextureCraftApp::new(context, session)); + let mut harness = Harness::builder() + .with_size(egui::vec2(1600.0, 960.0)) + .with_context_setup(texturecraft_ui_egui::framework::install_headless) + .build_eframe(|context| TextureCraftApp::new(context, session)); harness.state_mut().ui.layout = ViewLayout::Only2D; harness.run_steps(4); harness diff --git a/crates/ui-egui/tests/display_panel.rs b/crates/ui-egui/tests/display_panel.rs index 8b784576..d38c1af8 100644 --- a/crates/ui-egui/tests/display_panel.rs +++ b/crates/ui-egui/tests/display_panel.rs @@ -18,7 +18,10 @@ const STARTUP_FRAMES: usize = 4; #[test] fn display_picks_the_tone_mapping_from_a_dropdown() { let session = texturecraft_engine::sample_session(TEXTURE_RESOLUTION, BAKE_RESOLUTION).unwrap(); - let mut harness = Harness::builder().with_size(WINDOW_SIZE).with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|cc| TextureCraftApp::new(cc, session)); + let mut harness = Harness::builder() + .with_size(WINDOW_SIZE) + .with_context_setup(texturecraft_ui_egui::framework::install_headless) + .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.state_mut().ui.dock.focus(Panel::Display); diff --git a/crates/ui-egui/tests/it/alpha_parameters.rs b/crates/ui-egui/tests/it/alpha_parameters.rs index 38935440..acbd588f 100644 --- a/crates/ui-egui/tests/it/alpha_parameters.rs +++ b/crates/ui-egui/tests/it/alpha_parameters.rs @@ -17,7 +17,10 @@ fn changed_params() -> AlphaParams { /// The app showing the Alpha tab of Properties, with `brush` fn app_with_brush(brush: BrushSettings) -> Harness<'static, TextureCraftApp> { let session = texturecraft_engine::sample_session(256, 64).unwrap(); - let mut harness = Harness::builder().with_size(WINDOW_SIZE).with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|cc| TextureCraftApp::new(cc, session)); + let mut harness = Harness::builder() + .with_size(WINDOW_SIZE) + .with_context_setup(texturecraft_ui_egui::framework::install_headless) + .build_eframe(|cc| TextureCraftApp::new(cc, session)); harness.state_mut().ui.prefs.language = "en".into(); harness.state_mut().session.tool.brush = brush; harness.state_mut().ui.props_tab = PropsTab::Alpha; diff --git a/crates/ui-egui/tests/it/anchor_point.rs b/crates/ui-egui/tests/it/anchor_point.rs index 60d149ba..17f0f440 100644 --- a/crates/ui-egui/tests/it/anchor_point.rs +++ b/crates/ui-egui/tests/it/anchor_point.rs @@ -23,7 +23,11 @@ fn anchor_harness() -> (Harness<'static, TextureCraftApp>, LayerId, LayerId, Lay execute(&mut session, "mask.add.black", &json!({"layer": top})).unwrap(); let reader = LayerId(execute(&mut session, "effect.add.fill", &json!({"layer": top, "anchor": anchor.0})).unwrap()["effect"].as_u64().unwrap()); execute(&mut session, "layer.select", &json!({"layer": low, "target": anchor.0})).unwrap(); - let mut harness = Harness::builder().with_size(PROPERTIES_WINDOW).with_step_dt(FRAME_SECONDS).with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|cc| TextureCraftApp::new(cc, session)); + let mut harness = Harness::builder() + .with_size(PROPERTIES_WINDOW) + .with_step_dt(FRAME_SECONDS) + .with_context_setup(texturecraft_ui_egui::framework::install_headless) + .build_eframe(|cc| TextureCraftApp::new(cc, session)); harness.state_mut().ui.prefs.language = "en".into(); harness.run_steps(STARTUP_FRAMES); (harness, anchor, LayerId(top.as_u64().unwrap()), reader) diff --git a/crates/ui-egui/tests/it/bake_job_mesh.rs b/crates/ui-egui/tests/it/bake_job_mesh.rs index 0f576c8b..10cfe89c 100644 --- a/crates/ui-egui/tests/it/bake_job_mesh.rs +++ b/crates/ui-egui/tests/it/bake_job_mesh.rs @@ -11,7 +11,10 @@ use texturecraft_ui_egui::{BakeJob, RunningBake, TextureCraftApp}; /// An app with a running bake job (its worker never answers) started on mesh `mesh_id`. fn harness_with_job(mesh_id: impl FnOnce(u64) -> u64) -> (Harness<'static, TextureCraftApp>, Arc) { let session = texturecraft_engine::sample_session(256, 64).unwrap(); - let mut h = Harness::builder().with_size(egui::vec2(1600.0, 960.0)).with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|cc| TextureCraftApp::new(cc, session)); + let mut h = Harness::builder() + .with_size(egui::vec2(1600.0, 960.0)) + .with_context_setup(texturecraft_ui_egui::framework::install_headless) + .build_eframe(|cc| TextureCraftApp::new(cc, session)); h.run_steps(4); let progress = Arc::new(Progress::new()); let (tx, receiver) = std::sync::mpsc::channel(); diff --git a/crates/ui-egui/tests/it/bake_mode.rs b/crates/ui-egui/tests/it/bake_mode.rs index ff7d24ba..2f183a01 100644 --- a/crates/ui-egui/tests/it/bake_mode.rs +++ b/crates/ui-egui/tests/it/bake_mode.rs @@ -12,7 +12,10 @@ fn harness(map: Option) -> Harness<'static, TextureCraftApp> { session.doc.project.texture_sets[0].bake = Default::default(); session.doc.project.texture_sets[0].bake.common.resolution = BakeResolution::R64; session.doc.project.texture_sets[0].bake.maps.select(map); - let mut harness = Harness::builder().with_size(egui::vec2(1600.0, 1500.0)).with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|context| TextureCraftApp::new(context, session)); + let mut harness = Harness::builder() + .with_size(egui::vec2(1600.0, 1500.0)) + .with_context_setup(texturecraft_ui_egui::framework::install_headless) + .build_eframe(|context| TextureCraftApp::new(context, session)); harness.state_mut().ui.mode = Mode::Baking; harness.run_steps(4); harness.state_mut().ui.dock.focus(Panel::MeshMapSettings); @@ -221,7 +224,10 @@ fn tile_resolution_overrides_can_be_changed_and_removed_in_bake_mode() { 256, ) .unwrap(); - let mut harness = Harness::builder().with_size(egui::vec2(1600.0, 1500.0)).with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|context| TextureCraftApp::new(context, session)); + let mut harness = Harness::builder() + .with_size(egui::vec2(1600.0, 1500.0)) + .with_context_setup(texturecraft_ui_egui::framework::install_headless) + .build_eframe(|context| TextureCraftApp::new(context, session)); harness.state_mut().ui.mode = Mode::Baking; harness.run_steps(4); let before = harness.state().session.doc.project.clone(); @@ -272,7 +278,10 @@ fn bake_texture_sets_list_uv_tiles_and_their_resolutions() { .unwrap(); texturecraft_engine::execute(&mut session, "textureSet.tile.resolution", &serde_json::json!({"tile": 1002, "resolution": 128})).unwrap(); let before = session.doc.project.clone(); - let mut harness = Harness::builder().with_size(egui::vec2(1600.0, 1500.0)).with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|context| TextureCraftApp::new(context, session)); + let mut harness = Harness::builder() + .with_size(egui::vec2(1600.0, 1500.0)) + .with_context_setup(texturecraft_ui_egui::framework::install_headless) + .build_eframe(|context| TextureCraftApp::new(context, session)); harness.state_mut().ui.mode = Mode::Baking; harness.run_steps(4); @@ -348,8 +357,8 @@ fn restoring_common_defaults_keeps_each_sets_inclusion_and_maps() { #[test] fn output_axes_unlock_independently_and_relock_to_width() { let mut harness = harness(None); - harness.get_by_label("Texture Sets"); - harness.get_by_label("Mesh Map Settings"); + harness.get_by_role_and_label(Role::Tab, "Texture Sets"); + harness.get_by_role_and_label(Role::Tab, "Mesh Map Settings"); harness.state_mut().ui.dock.focus(Panel::CommonSettings); harness.run_steps(3); let width = harness.state().session.doc.project.texture_sets[0].bake.common.resolution.pixels().to_string(); diff --git a/crates/ui-egui/tests/it/bake_presets.rs b/crates/ui-egui/tests/it/bake_presets.rs index bcd5ca71..79f2655a 100644 --- a/crates/ui-egui/tests/it/bake_presets.rs +++ b/crates/ui-egui/tests/it/bake_presets.rs @@ -17,7 +17,10 @@ fn harness() -> Harness<'static, TextureCraftApp> { texture_set.bake.maps.select([BakedMap::Id]); } - let mut harness = Harness::builder().with_size(egui::vec2(1600.0, 1000.0)).with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|context| TextureCraftApp::new(context, session)); + let mut harness = Harness::builder() + .with_size(egui::vec2(1600.0, 1000.0)) + .with_context_setup(texturecraft_ui_egui::framework::install_headless) + .build_eframe(|context| TextureCraftApp::new(context, session)); harness.state_mut().ui.mode = Mode::Baking; harness.run_steps(4); harness.state_mut().ui.dock.focus(Panel::MeshMapBakers); @@ -174,7 +177,10 @@ fn a_partial_bake_does_not_count_preserved_unchecked_maps() { set.bake.common.resolution = BakeResolution::R64; set.bake.maps.select([BakedMap::Id]); set.bake_excluded_tiles.insert(1002); - let mut harness = Harness::builder().with_size(egui::vec2(1600.0, 1000.0)).with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|context| TextureCraftApp::new(context, session)); + let mut harness = Harness::builder() + .with_size(egui::vec2(1600.0, 1000.0)) + .with_context_setup(texturecraft_ui_egui::framework::install_headless) + .build_eframe(|context| TextureCraftApp::new(context, session)); harness.state_mut().ui.mode = Mode::Baking; harness.state_mut().start_bake(vec![0]); diff --git a/crates/ui-egui/tests/it/brush_drag.rs b/crates/ui-egui/tests/it/brush_drag.rs index 3a192a53..ed9eae98 100644 --- a/crates/ui-egui/tests/it/brush_drag.rs +++ b/crates/ui-egui/tests/it/brush_drag.rs @@ -22,7 +22,10 @@ fn drag(h: &mut Harness<'_, TextureCraftApp>, button: PointerButton, from: Pos2, #[test] fn ctrl_drag_changes_the_brush_instead_of_painting_or_orbiting() { let session = texturecraft_engine::sample_session(256, 64).unwrap(); - let mut h = Harness::builder().with_size(egui::vec2(1600.0, 960.0)).with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|cc| TextureCraftApp::new(cc, session)); + let mut h = Harness::builder() + .with_size(egui::vec2(1600.0, 960.0)) + .with_context_setup(texturecraft_ui_egui::framework::install_headless) + .build_eframe(|cc| TextureCraftApp::new(cc, session)); h.run_steps(4); let c = h.state().viewport_rect.center(); let (brush, yaw, history) = { @@ -50,7 +53,10 @@ fn ctrl_drag_changes_the_brush_instead_of_painting_or_orbiting() { fn app(layout: texturecraft_ui_egui::state::ViewLayout) -> Harness<'static, TextureCraftApp> { let session = texturecraft_engine::sample_session(256, 64).unwrap(); - let mut h = Harness::builder().with_size(egui::vec2(1600.0, 960.0)).with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|cc| TextureCraftApp::new(cc, session)); + let mut h = Harness::builder() + .with_size(egui::vec2(1600.0, 960.0)) + .with_context_setup(texturecraft_ui_egui::framework::install_headless) + .build_eframe(|cc| TextureCraftApp::new(cc, session)); h.state_mut().ui.layout = layout; h.run_steps(4); h diff --git a/crates/ui-egui/tests/it/brush_section_reset.rs b/crates/ui-egui/tests/it/brush_section_reset.rs index ec45916c..16270401 100644 --- a/crates/ui-egui/tests/it/brush_section_reset.rs +++ b/crates/ui-egui/tests/it/brush_section_reset.rs @@ -69,7 +69,10 @@ fn changed_brush() -> BrushSettings { /// The app showing the brush in Properties, set to `brush` fn app_with_brush(brush: BrushSettings) -> Harness<'static, TextureCraftApp> { let session = texturecraft_engine::sample_session(256, 64).unwrap(); - let mut harness = Harness::builder().with_size(WINDOW_SIZE).with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|cc| TextureCraftApp::new(cc, session)); + let mut harness = Harness::builder() + .with_size(WINDOW_SIZE) + .with_context_setup(texturecraft_ui_egui::framework::install_headless) + .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(); diff --git a/crates/ui-egui/tests/it/camera_views.rs b/crates/ui-egui/tests/it/camera_views.rs index d05fb3bc..7680561c 100644 --- a/crates/ui-egui/tests/it/camera_views.rs +++ b/crates/ui-egui/tests/it/camera_views.rs @@ -11,7 +11,10 @@ use texturecraft_ui_egui::TextureCraftApp; fn harness() -> Harness<'static, TextureCraftApp> { let session = texturecraft_engine::sample_session(256, 64).unwrap(); - let mut h = Harness::builder().with_size(egui::vec2(1600.0, 960.0)).with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|cc| TextureCraftApp::new(cc, session)); + let mut h = Harness::builder() + .with_size(egui::vec2(1600.0, 960.0)) + .with_context_setup(texturecraft_ui_egui::framework::install_headless) + .build_eframe(|cc| TextureCraftApp::new(cc, session)); h.run_steps(4); h } @@ -108,7 +111,11 @@ fn alt_shift_drag_orbits_in_quarter_turns() { /// A harness whose frames are 10 ms apart, so a 0.35 s glide spans about 35 frames and a drag fits inside it. fn slow_glide_harness() -> Harness<'static, TextureCraftApp> { let session = texturecraft_engine::sample_session(256, 64).unwrap(); - let mut h = Harness::builder().with_size(egui::vec2(1600.0, 960.0)).with_step_dt(0.01).with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|cc| TextureCraftApp::new(cc, session)); + let mut h = Harness::builder() + .with_size(egui::vec2(1600.0, 960.0)) + .with_step_dt(0.01) + .with_context_setup(texturecraft_ui_egui::framework::install_headless) + .build_eframe(|cc| TextureCraftApp::new(cc, session)); h.run_steps(4); h } diff --git a/crates/ui-egui/tests/it/clone_source_view.rs b/crates/ui-egui/tests/it/clone_source_view.rs index afe24d1a..611de1a7 100644 --- a/crates/ui-egui/tests/it/clone_source_view.rs +++ b/crates/ui-egui/tests/it/clone_source_view.rs @@ -15,7 +15,10 @@ const MARKER_STROKE: f32 = 1.2; fn clone_app() -> Harness<'static, TextureCraftApp> { let session = texturecraft_engine::sample_session(256, 64).unwrap(); - let mut harness = Harness::builder().with_size(egui::vec2(1600.0, 960.0)).with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|cc| TextureCraftApp::new(cc, session)); + let mut harness = Harness::builder() + .with_size(egui::vec2(1600.0, 960.0)) + .with_context_setup(texturecraft_ui_egui::framework::install_headless) + .build_eframe(|cc| TextureCraftApp::new(cc, session)); harness.state_mut().ui.layout = ViewLayout::Only2D; execute(&mut harness.state_mut().session, "tool.clone", &serde_json::Value::Null).unwrap(); harness.run_steps(4); diff --git a/crates/ui-egui/tests/it/close_unsaved.rs b/crates/ui-egui/tests/it/close_unsaved.rs index 50132e2e..77a29442 100644 --- a/crates/ui-egui/tests/it/close_unsaved.rs +++ b/crates/ui-egui/tests/it/close_unsaved.rs @@ -10,7 +10,10 @@ use texturecraft_ui_egui::state::Unsaved; fn harness(modified: bool) -> Harness<'static, TextureCraftApp> { let mut session = texturecraft_engine::sample_session(256, 64).unwrap(); session.modified = modified; - let mut h = Harness::builder().with_size(egui::vec2(1600.0, 960.0)).with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|cc| TextureCraftApp::new(cc, session)); + let mut h = Harness::builder() + .with_size(egui::vec2(1600.0, 960.0)) + .with_context_setup(texturecraft_ui_egui::framework::install_headless) + .build_eframe(|cc| TextureCraftApp::new(cc, session)); h.run_steps(4); h } diff --git a/crates/ui-egui/tests/it/color_selection_editor.rs b/crates/ui-egui/tests/it/color_selection_editor.rs index 40e5584b..8fe0dad5 100644 --- a/crates/ui-egui/tests/it/color_selection_editor.rs +++ b/crates/ui-egui/tests/it/color_selection_editor.rs @@ -55,7 +55,10 @@ fn color_selection_session(with_id_map: bool) -> (texturecraft_engine::Session, fn app_with_color_selection(with_id_map: bool) -> (Harness<'static, TextureCraftApp>, LayerId) { let (session, effect) = color_selection_session(with_id_map); - let mut harness = Harness::builder().with_size(PROPERTIES_WINDOW).with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|cc| TextureCraftApp::new(cc, session)); + let mut harness = Harness::builder() + .with_size(PROPERTIES_WINDOW) + .with_context_setup(texturecraft_ui_egui::framework::install_headless) + .build_eframe(|cc| TextureCraftApp::new(cc, session)); harness.run_steps(STARTUP_FRAMES); (harness, effect) } @@ -294,11 +297,16 @@ fn removing_an_image_during_id_picking_falls_back_to_material() { #[ignore = "requires a GPU adapter; set TC_UI_SNAPSHOTS to save the rendered views"] fn color_selection_snapshots_and_quick_mask_pick() { let (session, _) = color_selection_session(true); - let mut harness = Harness::builder().with_size(egui::vec2(1600.0, 960.0)).with_pixels_per_point(1.0).wgpu().with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|context| { - let mut app = TextureCraftApp::new(context, session); - app.ui.layout = texturecraft_ui_egui::state::ViewLayout::Only3D; - app - }); + let mut harness = Harness::builder() + .with_size(egui::vec2(1600.0, 960.0)) + .with_pixels_per_point(1.0) + .wgpu() + .with_context_setup(texturecraft_ui_egui::framework::install_headless) + .build_eframe(|context| { + let mut app = TextureCraftApp::new(context, session); + app.ui.layout = texturecraft_ui_egui::state::ViewLayout::Only3D; + app + }); let adapter = harness.state().render_state.as_ref().unwrap().adapter.get_info(); eprintln!("Offscreen adapter: {adapter:?}"); @@ -393,7 +401,10 @@ fn the_background_list_leaves_the_view_its_wheel_and_closes_on_escape_or_a_click fn the_id_mask_slot_picks_a_texture_and_its_x_goes_back_to_the_mesh_map() { let (mut session, effect) = color_selection_session(true); let texture = session.import_resource_bytes("parts.png", id_map_png()).unwrap(); - let mut harness = Harness::builder().with_size(PROPERTIES_WINDOW).with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|cc| TextureCraftApp::new(cc, session)); + let mut harness = Harness::builder() + .with_size(PROPERTIES_WINDOW) + .with_context_setup(texturecraft_ui_egui::framework::install_headless) + .build_eframe(|cc| TextureCraftApp::new(cc, session)); harness.run_steps(STARTUP_FRAMES); harness.get_by_role_and_label(Role::ComboBox, "ID Mask").click(); @@ -419,7 +430,10 @@ fn tile_is_current(harness: &Harness<'_, TextureCraftApp>, label: &str) -> bool fn reading_the_mesh_map_shows_no_tile_as_the_current_id_mask() { let (mut session, effect) = color_selection_session(true); let texture = session.import_resource_bytes("parts.png", id_map_png()).unwrap(); - let mut harness = Harness::builder().with_size(PROPERTIES_WINDOW).with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|cc| TextureCraftApp::new(cc, session)); + let mut harness = Harness::builder() + .with_size(PROPERTIES_WINDOW) + .with_context_setup(texturecraft_ui_egui::framework::install_headless) + .build_eframe(|cc| TextureCraftApp::new(cc, session)); harness.run_steps(STARTUP_FRAMES); assert_eq!(selection(&harness, effect).id_map, None, "the selection reads the ID mesh map"); @@ -456,8 +470,12 @@ fn the_invert_tooltip_shows_right_above_its_button() { #[ignore = "requires a GPU adapter; set TC_UI_SNAPSHOTS to save the rendered view"] fn invert_tooltip_snapshot() { let (session, _) = color_selection_session(true); - let mut harness = - Harness::builder().with_size(egui::vec2(1600.0, 960.0)).with_pixels_per_point(2.0).wgpu().with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|cc| TextureCraftApp::new(cc, session)); + let mut harness = Harness::builder() + .with_size(egui::vec2(1600.0, 960.0)) + .with_pixels_per_point(2.0) + .wgpu() + .with_context_setup(texturecraft_ui_egui::framework::install_headless) + .build_eframe(|cc| TextureCraftApp::new(cc, session)); harness.run_steps(STARTUP_FRAMES); let invert = harness.get_by_role_and_label(Role::Button, "Invert").rect(); harness.hover_at(invert.center()); @@ -474,7 +492,10 @@ fn a_hand_picked_id_mask_picks_without_a_bake() { session.doc.baked.clear(); let texture = session.import_resource_bytes("parts.png", id_map_png()).unwrap(); execute(&mut session, "effect.set", &json!({"effect": effect.0, "idMap": texture})).unwrap(); - let mut harness = Harness::builder().with_size(PROPERTIES_WINDOW).with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|cc| TextureCraftApp::new(cc, session)); + let mut harness = Harness::builder() + .with_size(PROPERTIES_WINDOW) + .with_context_setup(texturecraft_ui_egui::framework::install_headless) + .build_eframe(|cc| TextureCraftApp::new(cc, session)); harness.run_steps(STARTUP_FRAMES); harness.get_by_label(PICK_COLOR).click(); @@ -496,7 +517,10 @@ fn clearing_the_only_id_mask_ends_a_waiting_pick() { session.doc.baked.clear(); let texture = session.import_resource_bytes("parts.png", id_map_png()).unwrap(); execute(&mut session, "effect.set", &json!({"effect": effect.0, "idMap": texture})).unwrap(); - let mut harness = Harness::builder().with_size(PROPERTIES_WINDOW).with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|cc| TextureCraftApp::new(cc, session)); + let mut harness = Harness::builder() + .with_size(PROPERTIES_WINDOW) + .with_context_setup(texturecraft_ui_egui::framework::install_headless) + .build_eframe(|cc| TextureCraftApp::new(cc, session)); harness.run_steps(STARTUP_FRAMES); harness.get_by_label(PICK_COLOR).click(); harness.run_steps(SETTLE_FRAMES); diff --git a/crates/ui-egui/tests/it/compare_mask_rows.rs b/crates/ui-egui/tests/it/compare_mask_rows.rs index df14931a..1afaddc6 100644 --- a/crates/ui-egui/tests/it/compare_mask_rows.rs +++ b/crates/ui-egui/tests/it/compare_mask_rows.rs @@ -17,7 +17,11 @@ fn compare_harness() -> (Harness<'static, TextureCraftApp>, LayerId) { let layer = execute(&mut session, "layer.add.fill", &json!({"roughness": 0.6})).unwrap()["layer"].clone(); let effect = LayerId(execute(&mut session, "effect.add.compare", &json!({"layer": layer})).unwrap()["effect"].as_u64().unwrap()); execute(&mut session, "layer.select", &json!({"layer": layer, "target": effect.0})).unwrap(); - let mut harness = Harness::builder().with_size(PROPERTIES_WINDOW).with_step_dt(FRAME_SECONDS).with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|cc| TextureCraftApp::new(cc, session)); + let mut harness = Harness::builder() + .with_size(PROPERTIES_WINDOW) + .with_step_dt(FRAME_SECONDS) + .with_context_setup(texturecraft_ui_egui::framework::install_headless) + .build_eframe(|cc| TextureCraftApp::new(cc, session)); harness.state_mut().ui.prefs.language = "en".into(); harness.run_steps(STARTUP_FRAMES); (harness, effect) diff --git a/crates/ui-egui/tests/it/curvature_generator.rs b/crates/ui-egui/tests/it/curvature_generator.rs index 54695fbc..f8464f8b 100644 --- a/crates/ui-egui/tests/it/curvature_generator.rs +++ b/crates/ui-egui/tests/it/curvature_generator.rs @@ -18,7 +18,8 @@ fn harness(render: bool) -> (Harness<'static, TextureCraftApp>, LayerId) { session.update(); let builder = Harness::builder().with_size(egui::vec2(1600.0, 1200.0)); let builder = if render { builder.wgpu() } else { builder }; - let mut harness = builder.with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|context| TextureCraftApp::new(context, session)); + let mut harness = + builder.with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|context| TextureCraftApp::new(context, session)); harness.state_mut().ui.dock.close(Panel::Layers); harness.state_mut().ui.dock.close(Panel::TextureSetSettings); harness.state_mut().ui.dock.focus(Panel::Properties); diff --git a/crates/ui-egui/tests/it/display_environment.rs b/crates/ui-egui/tests/it/display_environment.rs index 5864e575..eab3f207 100644 --- a/crates/ui-egui/tests/it/display_environment.rs +++ b/crates/ui-egui/tests/it/display_environment.rs @@ -13,7 +13,10 @@ const SETTLE: usize = 3; fn app() -> Harness<'static, TextureCraftApp> { let session = texturecraft_engine::sample_session(256, 64).unwrap(); - let mut h = Harness::builder().with_size(egui::vec2(1600.0, 1400.0)).with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|cc| TextureCraftApp::new(cc, session)); + let mut h = Harness::builder() + .with_size(egui::vec2(1600.0, 1400.0)) + .with_context_setup(texturecraft_ui_egui::framework::install_headless) + .build_eframe(|cc| TextureCraftApp::new(cc, session)); h.state_mut().ui.prefs.language = "en".into(); h.run_steps(4); h.state_mut().ui.dock.focus(Panel::Display); diff --git a/crates/ui-egui/tests/it/display_post_effects.rs b/crates/ui-egui/tests/it/display_post_effects.rs index 48e53a6e..67943dd0 100644 --- a/crates/ui-egui/tests/it/display_post_effects.rs +++ b/crates/ui-egui/tests/it/display_post_effects.rs @@ -24,7 +24,10 @@ fn display(harness: &Harness<'_, TextureCraftApp>) -> DisplaySettings { /// The app with Display Settings open from the rail and the Post effects section unfolded fn app() -> Harness<'static, TextureCraftApp> { let session = texturecraft_engine::sample_session(256, 64).unwrap(); - let mut harness = Harness::builder().with_size(egui::vec2(1600.0, 1400.0)).with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|cc| TextureCraftApp::new(cc, session)); + let mut harness = Harness::builder() + .with_size(egui::vec2(1600.0, 1400.0)) + .with_context_setup(texturecraft_ui_egui::framework::install_headless) + .build_eframe(|cc| TextureCraftApp::new(cc, session)); harness.state_mut().ui.prefs.language = "en".into(); harness.run_steps(4); harness diff --git a/crates/ui-egui/tests/it/effect_rows.rs b/crates/ui-egui/tests/it/effect_rows.rs index e0efd1cc..debb9ba9 100644 --- a/crates/ui-egui/tests/it/effect_rows.rs +++ b/crates/ui-egui/tests/it/effect_rows.rs @@ -37,7 +37,10 @@ fn dragging_an_effect_row_reorders_its_stack() { |name: &str| id(execute(&mut session, "effect.add.filter", &json!({"target": "content", "filter": "invert", "name": name})).unwrap(), "effect"); let (a, b, c) = (add("Effect A"), add("Effect B"), add("Effect C")); execute(&mut session, "layer.select", &json!({"layer": layer.0})).unwrap(); - let mut harness = Harness::builder().with_size(egui::vec2(1600.0, 1400.0)).with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|creation_context| TextureCraftApp::new(creation_context, session)); + let mut harness = Harness::builder() + .with_size(egui::vec2(1600.0, 1400.0)) + .with_context_setup(texturecraft_ui_egui::framework::install_headless) + .build_eframe(|creation_context| TextureCraftApp::new(creation_context, session)); harness.run_steps(4); let order = |harness: &Harness<'_, TextureCraftApp>| harness.state().session.doc.project.layers[&layer].content_effects.iter().map(|e| e.id.0).collect::>(); @@ -66,7 +69,10 @@ fn an_effect_row_sets_its_blend_mode_and_opacity() { let layer = LayerId(id(execute(&mut session, "layer.add.fill", &Value::Null).unwrap(), "layer")); let effect = id(execute(&mut session, "effect.add.filter", &json!({"target": "content", "filter": "invert", "name": "Effect A"})).unwrap(), "effect"); execute(&mut session, "layer.select", &json!({"layer": layer.0})).unwrap(); - let mut harness = Harness::builder().with_size(egui::vec2(1600.0, 1400.0)).with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|creation_context| TextureCraftApp::new(creation_context, session)); + let mut harness = Harness::builder() + .with_size(egui::vec2(1600.0, 1400.0)) + .with_context_setup(texturecraft_ui_egui::framework::install_headless) + .build_eframe(|creation_context| TextureCraftApp::new(creation_context, session)); harness.run_steps(4); let effect_of = |harness: &Harness<'_, TextureCraftApp>| harness.state().session.doc.project.layers[&layer].content_effects[0].clone(); @@ -112,7 +118,10 @@ fn an_opacity_drag_starting_without_a_change_is_its_own_undo_step() { let effect = id(execute(&mut session, "effect.add.filter", &json!({"target": "content", "filter": "invert", "name": "Effect A"})).unwrap(), "effect"); execute(&mut session, "effect.set", &json!({"effect": effect, "blend": "Multiply"})).unwrap(); execute(&mut session, "layer.select", &json!({"layer": layer.0})).unwrap(); - let mut harness = Harness::builder().with_size(egui::vec2(1600.0, 1400.0)).with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|creation_context| TextureCraftApp::new(creation_context, session)); + let mut harness = Harness::builder() + .with_size(egui::vec2(1600.0, 1400.0)) + .with_context_setup(texturecraft_ui_egui::framework::install_headless) + .build_eframe(|creation_context| TextureCraftApp::new(creation_context, session)); harness.run_steps(4); let effect_of = |harness: &Harness<'_, TextureCraftApp>| harness.state().session.doc.project.layers[&layer].content_effects[0].clone(); @@ -151,7 +160,10 @@ fn an_effect_rows_blending_options_reach_every_channel() { let effect = id(execute(&mut session, "effect.add.filter", &json!({"target": "content", "filter": "invert", "name": "Effect A"})).unwrap(), "effect"); execute(&mut session, "effect.set", &json!({"effect": effect, "channel": "baseColor", "blend": "Multiply"})).unwrap(); execute(&mut session, "layer.select", &json!({"layer": layer.0})).unwrap(); - let mut harness = Harness::builder().with_size(egui::vec2(1600.0, 1400.0)).with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|creation_context| TextureCraftApp::new(creation_context, session)); + let mut harness = Harness::builder() + .with_size(egui::vec2(1600.0, 1400.0)) + .with_context_setup(texturecraft_ui_egui::framework::install_headless) + .build_eframe(|creation_context| TextureCraftApp::new(creation_context, session)); harness.run_steps(4); let effect_of = |harness: &Harness<'_, TextureCraftApp>| harness.state().session.doc.project.layers[&layer].content_effects[0].clone(); diff --git a/crates/ui-egui/tests/it/effect_sliders.rs b/crates/ui-egui/tests/it/effect_sliders.rs index 92b79f6f..32a0fbe4 100644 --- a/crates/ui-egui/tests/it/effect_sliders.rs +++ b/crates/ui-egui/tests/it/effect_sliders.rs @@ -21,7 +21,10 @@ fn selected_generator() -> (Harness<'static, TextureCraftApp>, LayerId) { }) .unwrap(); texturecraft_engine::execute(&mut session, "layer.select", &json!({"layer": layer.0, "target": effect.0})).unwrap(); - let mut harness = Harness::builder().with_size(egui::vec2(1600.0, 1400.0)).with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|creation_context| TextureCraftApp::new(creation_context, session)); + let mut harness = Harness::builder() + .with_size(egui::vec2(1600.0, 1400.0)) + .with_context_setup(texturecraft_ui_egui::framework::install_headless) + .build_eframe(|creation_context| TextureCraftApp::new(creation_context, session)); harness.run_steps(4); (harness, effect) } diff --git a/crates/ui-egui/tests/it/empty_menus.rs b/crates/ui-egui/tests/it/empty_menus.rs index 4c4478b2..921b1b6d 100644 --- a/crates/ui-egui/tests/it/empty_menus.rs +++ b/crates/ui-egui/tests/it/empty_menus.rs @@ -8,7 +8,10 @@ use texturecraft_engine::Session; use texturecraft_ui_egui::{TextureCraftApp, docking::Panel, menus}; fn app() -> Harness<'static, TextureCraftApp> { - let mut h = Harness::builder().with_size(egui::vec2(1600.0, 1000.0)).with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|cc| TextureCraftApp::new(cc, Session::closed().unwrap())); + let mut h = Harness::builder() + .with_size(egui::vec2(1600.0, 1000.0)) + .with_context_setup(texturecraft_ui_egui::framework::install_headless) + .build_eframe(|cc| TextureCraftApp::new(cc, Session::closed().unwrap())); h.state_mut().ui.prefs.language = "en".into(); h.run_steps(4); h diff --git a/crates/ui-egui/tests/it/empty_start.rs b/crates/ui-egui/tests/it/empty_start.rs index c11b9f75..92dacde2 100644 --- a/crates/ui-egui/tests/it/empty_start.rs +++ b/crates/ui-egui/tests/it/empty_start.rs @@ -7,7 +7,10 @@ use texturecraft_engine::Session; use texturecraft_ui_egui::{TextureCraftApp, menus}; fn harness(session: Session) -> Harness<'static, TextureCraftApp> { - let mut harness = Harness::builder().with_size(egui::vec2(1600.0, 960.0)).with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|cc| TextureCraftApp::new(cc, session)); + let mut harness = Harness::builder() + .with_size(egui::vec2(1600.0, 960.0)) + .with_context_setup(texturecraft_ui_egui::framework::install_headless) + .build_eframe(|cc| TextureCraftApp::new(cc, session)); // The exact-text checks below need English, whatever the OS language is harness.state_mut().ui.prefs.language = "en".into(); @@ -411,12 +414,3 @@ fn close_releases_the_layer_thumbnail_snapshot() { ); } } - -#[test] -fn the_empty_properties_note_starts_at_its_header_names_left_edge() { - let harness = empty(); - let texts = painted(&harness); - let left_of = |wanted: &str| texts.iter().find(|(text, _)| text == wanted).map(|(_, left)| *left).unwrap_or_else(|| panic!("{wanted} is painted")); - - assert_eq!(left_of("No properties found"), left_of("PROPERTIES")); -} diff --git a/crates/ui-egui/tests/it/export_file_types.rs b/crates/ui-egui/tests/it/export_file_types.rs index c9f270c2..e8a25aa3 100644 --- a/crates/ui-egui/tests/it/export_file_types.rs +++ b/crates/ui-egui/tests/it/export_file_types.rs @@ -8,7 +8,10 @@ use texturecraft_ui_egui::TextureCraftApp; /// The Export textures window open on SETTINGS fn harness() -> Harness<'static, TextureCraftApp> { let session = texturecraft_engine::sample_session(256, 64).unwrap(); - let mut h = Harness::builder().with_size(egui::vec2(1600.0, 960.0)).with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|cc| TextureCraftApp::new(cc, session)); + let mut h = Harness::builder() + .with_size(egui::vec2(1600.0, 960.0)) + .with_context_setup(texturecraft_ui_egui::framework::install_headless) + .build_eframe(|cc| TextureCraftApp::new(cc, session)); h.state_mut().ui.prefs.language = "en".into(); h.run_steps(4); h.state_mut().ui.windows.export = true; @@ -138,7 +141,10 @@ fn export_writes_the_chosen_type_and_depth() { #[test] fn an_old_hidden_bit_depth_is_not_exported() { let session = texturecraft_engine::sample_session(256, 64).unwrap(); - let mut h = Harness::builder().with_size(egui::vec2(1600.0, 960.0)).with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|cc| TextureCraftApp::new(cc, session)); + let mut h = Harness::builder() + .with_size(egui::vec2(1600.0, 960.0)) + .with_context_setup(texturecraft_ui_egui::framework::install_headless) + .build_eframe(|cc| TextureCraftApp::new(cc, session)); h.state_mut().ui.prefs.language = "en".into(); // Saved by an older build: "From template" with 16 bits diff --git a/crates/ui-egui/tests/it/export_map_overrides.rs b/crates/ui-egui/tests/it/export_map_overrides.rs index e2b840eb..333dcebf 100644 --- a/crates/ui-egui/tests/it/export_map_overrides.rs +++ b/crates/ui-egui/tests/it/export_map_overrides.rs @@ -9,7 +9,10 @@ use texturecraft_ui_egui::state::{FileType, MapExport, SetExport}; /// The Export textures window open on the first texture set's page fn harness() -> Harness<'static, TextureCraftApp> { let session = texturecraft_engine::sample_session(256, 64).unwrap(); - let mut h = Harness::builder().with_size(egui::vec2(1600.0, 960.0)).with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|cc| TextureCraftApp::new(cc, session)); + let mut h = Harness::builder() + .with_size(egui::vec2(1600.0, 960.0)) + .with_context_setup(texturecraft_ui_egui::framework::install_headless) + .build_eframe(|cc| TextureCraftApp::new(cc, session)); h.state_mut().ui.prefs.language = "en".into(); h.run_steps(4); h.state_mut().ui.windows.export = true; diff --git a/crates/ui-egui/tests/it/export_materialx.rs b/crates/ui-egui/tests/it/export_materialx.rs index 176f73d3..694f4fd0 100644 --- a/crates/ui-egui/tests/it/export_materialx.rs +++ b/crates/ui-egui/tests/it/export_materialx.rs @@ -11,7 +11,10 @@ const OPENPBR: &str = "OpenPBR (separate maps)"; /// The Export textures window writing into a scratch folder of its own for `name` fn harness(name: &str) -> (Harness<'static, TextureCraftApp>, std::path::PathBuf) { let session = texturecraft_engine::sample_session(256, 64).unwrap(); - let mut app_harness = Harness::builder().with_size(egui::vec2(1600.0, 960.0)).with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|cc| TextureCraftApp::new(cc, session)); + let mut app_harness = Harness::builder() + .with_size(egui::vec2(1600.0, 960.0)) + .with_context_setup(texturecraft_ui_egui::framework::install_headless) + .build_eframe(|cc| TextureCraftApp::new(cc, session)); app_harness.state_mut().ui.prefs.language = "en".into(); app_harness.run_steps(4); diff --git a/crates/ui-egui/tests/it/export_overrides.rs b/crates/ui-egui/tests/it/export_overrides.rs index 0ff8cfaf..c2eee653 100644 --- a/crates/ui-egui/tests/it/export_overrides.rs +++ b/crates/ui-egui/tests/it/export_overrides.rs @@ -12,7 +12,10 @@ fn harness() -> Harness<'static, TextureCraftApp> { } fn harness_with_session(session: texturecraft_engine::Session) -> Harness<'static, TextureCraftApp> { - let mut h = Harness::builder().with_size(egui::vec2(1600.0, 960.0)).with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|cc| TextureCraftApp::new(cc, session)); + let mut h = Harness::builder() + .with_size(egui::vec2(1600.0, 960.0)) + .with_context_setup(texturecraft_ui_egui::framework::install_headless) + .build_eframe(|cc| TextureCraftApp::new(cc, session)); h.state_mut().ui.prefs.language = "en".into(); h.run_steps(4); h.state_mut().ui.windows.export = true; @@ -269,7 +272,10 @@ fn reset_all_then_cancel_restores_the_ticks_and_overrides() { #[test] fn ticks_saved_before_settings_named_their_project_are_kept() { let session = texturecraft_engine::sample_session(256, 64).unwrap(); - let mut h = Harness::builder().with_size(egui::vec2(1600.0, 960.0)).with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|cc| TextureCraftApp::new(cc, session)); + let mut h = Harness::builder() + .with_size(egui::vec2(1600.0, 960.0)) + .with_context_setup(texturecraft_ui_egui::framework::install_headless) + .build_eframe(|cc| TextureCraftApp::new(cc, session)); h.state_mut().ui.prefs.language = "en".into(); h.run_steps(4); diff --git a/crates/ui-egui/tests/it/export_progress.rs b/crates/ui-egui/tests/it/export_progress.rs index 89d7ef49..e7356234 100644 --- a/crates/ui-egui/tests/it/export_progress.rs +++ b/crates/ui-egui/tests/it/export_progress.rs @@ -10,7 +10,10 @@ use texturecraft_ui_egui::state::{ConsoleLine, ExportJob}; /// The Export textures window writing into a scratch folder of its own for `name` fn harness(name: &str) -> (Harness<'static, TextureCraftApp>, std::path::PathBuf) { let session = texturecraft_engine::sample_session(256, 64).unwrap(); - let mut h = Harness::builder().with_size(egui::vec2(1600.0, 960.0)).with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|cc| TextureCraftApp::new(cc, session)); + let mut h = Harness::builder() + .with_size(egui::vec2(1600.0, 960.0)) + .with_context_setup(texturecraft_ui_egui::framework::install_headless) + .build_eframe(|cc| TextureCraftApp::new(cc, session)); h.state_mut().ui.prefs.language = "en".into(); h.run_steps(4); let dir = std::env::temp_dir().join(format!("tc-export-progress-{name}-{}", std::process::id())); diff --git a/crates/ui-egui/tests/it/export_settings.rs b/crates/ui-egui/tests/it/export_settings.rs index ae2e8a3c..749bab18 100644 --- a/crates/ui-egui/tests/it/export_settings.rs +++ b/crates/ui-egui/tests/it/export_settings.rs @@ -8,7 +8,10 @@ use texturecraft_ui_egui::TextureCraftApp; /// The Export textures window open on SETTINGS fn harness() -> Harness<'static, TextureCraftApp> { let session = texturecraft_engine::sample_session(256, 64).unwrap(); - let mut h = Harness::builder().with_size(egui::vec2(1600.0, 960.0)).with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|cc| TextureCraftApp::new(cc, session)); + let mut h = Harness::builder() + .with_size(egui::vec2(1600.0, 960.0)) + .with_context_setup(texturecraft_ui_egui::framework::install_headless) + .build_eframe(|cc| TextureCraftApp::new(cc, session)); h.state_mut().ui.prefs.language = "en".into(); h.run_steps(4); h.state_mut().ui.windows.export = true; diff --git a/crates/ui-egui/tests/it/export_template_guards.rs b/crates/ui-egui/tests/it/export_template_guards.rs index 6e98864f..80cc5032 100644 --- a/crates/ui-egui/tests/it/export_template_guards.rs +++ b/crates/ui-egui/tests/it/export_template_guards.rs @@ -14,7 +14,10 @@ use library::Library; /// The Output templates tab with two user templates, "Alpha tpl" (selected) and "Beta tpl", saved in `library`. fn harness(library: &Library) -> Harness<'static, TextureCraftApp> { let session = texturecraft_engine::sample_session(256, 64).unwrap(); - let mut h = Harness::builder().with_size(egui::vec2(1600.0, 960.0)).with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|cc| TextureCraftApp::new(cc, session)); + let mut h = Harness::builder() + .with_size(egui::vec2(1600.0, 960.0)) + .with_context_setup(texturecraft_ui_egui::framework::install_headless) + .build_eframe(|cc| TextureCraftApp::new(cc, session)); h.run_steps(4); h.state_mut().session.load_export_presets(library.0.clone()); let base = texturecraft_engine::formats::builtin_presets().remove(0); diff --git a/crates/ui-egui/tests/it/export_usd_asset.rs b/crates/ui-egui/tests/it/export_usd_asset.rs index b44f76e9..508aa48d 100644 --- a/crates/ui-egui/tests/it/export_usd_asset.rs +++ b/crates/ui-egui/tests/it/export_usd_asset.rs @@ -26,7 +26,10 @@ impl Drop for Scratch { /// The Export textures window writing into a scratch folder of its own for `name` fn harness(name: &str) -> (Harness<'static, TextureCraftApp>, Scratch) { let session = texturecraft_engine::sample_session(256, 64).unwrap(); - let mut h = Harness::builder().with_size(egui::vec2(1600.0, 960.0)).with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|cc| TextureCraftApp::new(cc, session)); + let mut h = Harness::builder() + .with_size(egui::vec2(1600.0, 960.0)) + .with_context_setup(texturecraft_ui_egui::framework::install_headless) + .build_eframe(|cc| TextureCraftApp::new(cc, session)); h.state_mut().ui.prefs.language = "en".into(); h.run_steps(4); let dir = std::env::temp_dir().join(format!("tc-export-usd-asset-{name}-{}", std::process::id())); diff --git a/crates/ui-egui/tests/it/file_dialogs.rs b/crates/ui-egui/tests/it/file_dialogs.rs index b3a71b30..b01845ce 100644 --- a/crates/ui-egui/tests/it/file_dialogs.rs +++ b/crates/ui-egui/tests/it/file_dialogs.rs @@ -13,7 +13,10 @@ use texturecraft_ui_egui::state::Unsaved; fn harness(modified: bool) -> Harness<'static, TextureCraftApp> { let mut session = texturecraft_engine::sample_session(256, 64).unwrap(); session.modified = modified; - let mut h = Harness::builder().with_size(egui::vec2(1600.0, 960.0)).with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|cc| TextureCraftApp::new(cc, session)); + let mut h = Harness::builder() + .with_size(egui::vec2(1600.0, 960.0)) + .with_context_setup(texturecraft_ui_egui::framework::install_headless) + .build_eframe(|cc| TextureCraftApp::new(cc, session)); h.run_steps(4); h } diff --git a/crates/ui-egui/tests/it/fill_channel_image.rs b/crates/ui-egui/tests/it/fill_channel_image.rs index 7b599103..b4972b36 100644 --- a/crates/ui-egui/tests/it/fill_channel_image.rs +++ b/crates/ui-egui/tests/it/fill_channel_image.rs @@ -26,7 +26,10 @@ fn a_fill_channel_takes_an_image_from_its_source_picker() { let name = session.import_resource_bytes("rough.png", png_bytes).unwrap(); let result = texturecraft_engine::execute(&mut session, "layer.add.fill", &json!({"roughness": 0.6})).unwrap(); let layer = LayerId(result["layer"].as_u64().unwrap()); - let mut harness = Harness::builder().with_size(egui::vec2(1600.0, 1400.0)).with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|cc| TextureCraftApp::new(cc, session)); + let mut harness = Harness::builder() + .with_size(egui::vec2(1600.0, 1400.0)) + .with_context_setup(texturecraft_ui_egui::framework::install_headless) + .build_eframe(|cc| TextureCraftApp::new(cc, session)); // Use English so first-run locale does not change queried labels harness.state_mut().ui.prefs.language = "en".into(); @@ -51,7 +54,10 @@ fn the_source_picker_offers_only_images_that_were_decoded() { // Bytes that are not an image never reach the decoded images session.doc.resources.insert("broken.png".into(), std::sync::Arc::new(vec![1, 2, 3])); texturecraft_engine::execute(&mut session, "layer.add.fill", &json!({"roughness": 0.6})).unwrap(); - let mut harness = Harness::builder().with_size(egui::vec2(1600.0, 1400.0)).with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|cc| TextureCraftApp::new(cc, session)); + let mut harness = Harness::builder() + .with_size(egui::vec2(1600.0, 1400.0)) + .with_context_setup(texturecraft_ui_egui::framework::install_headless) + .build_eframe(|cc| TextureCraftApp::new(cc, session)); // Use English so first-run locale does not change queried labels harness.state_mut().ui.prefs.language = "en".into(); @@ -122,7 +128,10 @@ fn a_mask_fill_selects_an_image_edits_projection_and_returns_to_uniform() { texturecraft_engine::execute(&mut session, "mask.add.black", &json!({})).unwrap(); let output = texturecraft_engine::execute(&mut session, "effect.add.fill", &json!({"target": "mask"})).unwrap(); let effect_id = LayerId(output["effect"].as_u64().unwrap()); - let mut harness = Harness::builder().with_size(egui::vec2(1600.0, 1400.0)).with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|cc| TextureCraftApp::new(cc, session)); + let mut harness = Harness::builder() + .with_size(egui::vec2(1600.0, 1400.0)) + .with_context_setup(texturecraft_ui_egui::framework::install_headless) + .build_eframe(|cc| TextureCraftApp::new(cc, session)); harness.state_mut().ui.prefs.language = "en".into(); harness.run_steps(4); @@ -166,7 +175,10 @@ fn a_normal_image_can_be_marked_directx() { let out = texturecraft_engine::execute(&mut session, "layer.add.fill", &json!({})).unwrap(); let layer = LayerId(out["layer"].as_u64().unwrap()); texturecraft_engine::execute(&mut session, "layer.fill.set", &json!({"layer": layer.0, "channel": "normal", "image": name})).unwrap(); - let mut h = Harness::builder().with_size(egui::vec2(1600.0, 1400.0)).with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|cc| TextureCraftApp::new(cc, session)); + let mut h = Harness::builder() + .with_size(egui::vec2(1600.0, 1400.0)) + .with_context_setup(texturecraft_ui_egui::framework::install_headless) + .build_eframe(|cc| TextureCraftApp::new(cc, session)); h.state_mut().ui.prefs.language = "en".into(); h.run_steps(4); diff --git a/crates/ui-egui/tests/it/fill_support.rs b/crates/ui-egui/tests/it/fill_support.rs index 845eebd5..543c2269 100644 --- a/crates/ui-egui/tests/it/fill_support.rs +++ b/crates/ui-egui/tests/it/fill_support.rs @@ -18,7 +18,10 @@ pub(crate) fn fill_app(settings: Value, projection: Option<&str>, tab: Option<&s if let Some(projection) = projection { texturecraft_engine::execute(&mut session, "layer.fill.projection", &json!({"layer": layer, "projection": projection})).unwrap(); } - let mut harness = Harness::builder().with_size(window).with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|cc| TextureCraftApp::new(cc, session)); + let mut harness = Harness::builder() + .with_size(window) + .with_context_setup(texturecraft_ui_egui::framework::install_headless) + .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(); diff --git a/crates/ui-egui/tests/it/fill_symmetry_rows.rs b/crates/ui-egui/tests/it/fill_symmetry_rows.rs index 158c3b29..42406c5b 100644 --- a/crates/ui-egui/tests/it/fill_symmetry_rows.rs +++ b/crates/ui-egui/tests/it/fill_symmetry_rows.rs @@ -134,7 +134,9 @@ fn commit_value_by_clicking_track(harness: &mut Harness<'_, TextureCraftApp>, va let pos = along(track, 0.75); let button = |pressed| egui::Event::PointerButton { pos, button: egui::PointerButton::Primary, pressed, modifiers: egui::Modifiers::NONE }; harness.input_mut().events.extend([egui::Event::PointerMoved(pos), button(true), button(false)]); - harness.step(); + // The runtime takes one press per pass: the click's release, and the field's commit on losing focus, land in the + // next frame + harness.run_steps(2); } #[test] diff --git a/crates/ui-egui/tests/it/filter_picker.rs b/crates/ui-egui/tests/it/filter_picker.rs index 9e65517c..6db598f5 100644 --- a/crates/ui-egui/tests/it/filter_picker.rs +++ b/crates/ui-egui/tests/it/filter_picker.rs @@ -185,10 +185,14 @@ fn filter_picker_snapshots_and_frame_timings() { let mut session = texturecraft_engine::sample_session(256, 64).unwrap(); execute(&mut session, "layer.add.fill", &Value::Null).unwrap(); execute(&mut session, "effect.add.filter", &json!({"target": "content", "filter": "invert"})).unwrap(); - let mut harness = Harness::builder().with_size(egui::vec2(WINDOW_WIDTH, SNAPSHOT_HEIGHT)).wgpu().with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|cc| { - eprintln!("selected graphics adapter: {:?}", cc.wgpu_render_state.as_ref().unwrap().adapter.get_info()); - TextureCraftApp::new(cc, session) - }); + let mut harness = Harness::builder() + .with_size(egui::vec2(WINDOW_WIDTH, SNAPSHOT_HEIGHT)) + .wgpu() + .with_context_setup(texturecraft_ui_egui::framework::install_headless) + .build_eframe(|cc| { + eprintln!("selected graphics adapter: {:?}", cc.wgpu_render_state.as_ref().unwrap().adapter.get_info()); + TextureCraftApp::new(cc, session) + }); harness.run_steps(20); let start = std::time::Instant::now(); open_picker(&mut harness); diff --git a/crates/ui-egui/tests/it/filter_support.rs b/crates/ui-egui/tests/it/filter_support.rs index 7a3949ee..f070b1f1 100644 --- a/crates/ui-egui/tests/it/filter_support.rs +++ b/crates/ui-egui/tests/it/filter_support.rs @@ -29,7 +29,10 @@ pub(crate) fn app_with(filter: &str, target: &str, height: f32) -> (Harness<'sta execute(&mut session, "layer.select", &json!({"layer": layer["layer"]})).unwrap(); session.target = StackTarget::Effect(effect); - let mut harness = Harness::builder().with_size(egui::vec2(WINDOW_WIDTH, height)).with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|cc| TextureCraftApp::new(cc, session)); + let mut harness = Harness::builder() + .with_size(egui::vec2(WINDOW_WIDTH, height)) + .with_context_setup(texturecraft_ui_egui::framework::install_headless) + .build_eframe(|cc| TextureCraftApp::new(cc, session)); harness.state_mut().ui.prefs.language = "en".into(); harness.run_steps(4); (harness, effect) diff --git a/crates/ui-egui/tests/it/folder_properties.rs b/crates/ui-egui/tests/it/folder_properties.rs index 90129374..e298e8d3 100644 --- a/crates/ui-egui/tests/it/folder_properties.rs +++ b/crates/ui-egui/tests/it/folder_properties.rs @@ -28,7 +28,11 @@ fn folder_harness(with_fill: bool) -> (Harness<'static, TextureCraftApp>, LayerI LayerId(execute(&mut session, "layer.add.group", &json!({})).unwrap()["layer"].as_u64().unwrap()) }; execute(&mut session, "layer.select", &json!({"layer": folder.0, "target": "content"})).unwrap(); - let mut harness = Harness::builder().with_size(PROPERTIES_WINDOW).with_step_dt(FRAME_SECONDS).with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|cc| TextureCraftApp::new(cc, session)); + let mut harness = Harness::builder() + .with_size(PROPERTIES_WINDOW) + .with_step_dt(FRAME_SECONDS) + .with_context_setup(texturecraft_ui_egui::framework::install_headless) + .build_eframe(|cc| TextureCraftApp::new(cc, session)); harness.state_mut().ui.prefs.language = "en".into(); harness.run_steps(STARTUP_FRAMES); (harness, folder, fill) @@ -107,20 +111,3 @@ fn randomize_seeds_is_one_undo_step_the_contents_reset_puts_them_back_and_an_emp assert!(harness.query_by_label("No properties found").is_some()); assert!(harness.query_by_role_and_label(Role::Slider, "Scale").is_none()); } - -/// An empty folder's note starts at the Properties header name's left edge, as the note with no project open does (it was centred) -#[test] -fn an_empty_folders_note_starts_at_its_header_names_left_edge() { - let (harness, _, _) = folder_harness(false); - - let painted_left = |wanted: &dyn Fn(&str) -> bool| { - harness.output().shapes.iter().find_map(|clipped| match &clipped.shape { - egui::Shape::Text(text) if wanted(text.galley.text()) => Some(text.pos.x), - _ => None, - }) - }; - let note = painted_left(&|text| text == "No properties found"); - let header = painted_left(&|text| text.starts_with("PROPERTIES")); - - assert!(note.is_some() && note == header, "the note starts at {note:?}, the header name at {header:?}"); -} diff --git a/crates/ui-egui/tests/it/frame_selection.rs b/crates/ui-egui/tests/it/frame_selection.rs index 6bc8484e..e36c95b6 100644 --- a/crates/ui-egui/tests/it/frame_selection.rs +++ b/crates/ui-egui/tests/it/frame_selection.rs @@ -10,7 +10,10 @@ o Floor\nusemtl Floor\nv -100 -1 -100\nv 100 -1 -100\nv 0 -1 100\nvt 0 0\nvt 1 0 fn harness() -> Harness<'static, TextureCraftApp> { let session = Session::from_mesh_bytes("scene.obj", SCENE_OBJ.as_bytes(), 256, "scene").unwrap(); - let mut h = Harness::builder().with_size(egui::vec2(1600.0, 960.0)).with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|cc| TextureCraftApp::new(cc, session)); + let mut h = Harness::builder() + .with_size(egui::vec2(1600.0, 960.0)) + .with_context_setup(texturecraft_ui_egui::framework::install_headless) + .build_eframe(|cc| TextureCraftApp::new(cc, session)); h.run_steps(4); h } diff --git a/crates/ui-egui/tests/it/generator_panel.rs b/crates/ui-egui/tests/it/generator_panel.rs index dfef8304..8cc67620 100644 --- a/crates/ui-egui/tests/it/generator_panel.rs +++ b/crates/ui-egui/tests/it/generator_panel.rs @@ -22,7 +22,8 @@ fn harness(render: bool) -> (Harness<'static, TextureCraftApp>, LayerId) { session.update(); let builder = Harness::builder().with_size(egui::vec2(1600.0, 2400.0)); let builder = if render { builder.wgpu() } else { builder }; - let mut harness = builder.with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|context| TextureCraftApp::new(context, session)); + let mut harness = + builder.with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|context| TextureCraftApp::new(context, session)); harness.state_mut().ui.dock.close(Panel::Layers); harness.state_mut().ui.dock.close(Panel::TextureSetSettings); harness.state_mut().ui.dock.focus(Panel::Properties); diff --git a/crates/ui-egui/tests/it/help_menu_664.rs b/crates/ui-egui/tests/it/help_menu_664.rs index c0e394f8..e3dbadd3 100644 --- a/crates/ui-egui/tests/it/help_menu_664.rs +++ b/crates/ui-egui/tests/it/help_menu_664.rs @@ -11,7 +11,10 @@ fn harness() -> Harness<'static, TextureCraftApp> { let mut session = Session::new_project("t", primitives::material_ball(), "builtin:material_ball", None, 128).unwrap(); session.log.push("first line".into()); session.log.warn(texturecraft_engine::log::DEFAULT_SOURCE, "second line"); - let mut h = Harness::builder().with_size(egui::vec2(1600.0, 960.0)).with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|cc| TextureCraftApp::new(cc, session)); + let mut h = Harness::builder() + .with_size(egui::vec2(1600.0, 960.0)) + .with_context_setup(texturecraft_ui_egui::framework::install_headless) + .build_eframe(|cc| TextureCraftApp::new(cc, session)); h.state_mut().ui.prefs.language = "en".into(); h.run_steps(4); h diff --git a/crates/ui-egui/tests/it/history_panel.rs b/crates/ui-egui/tests/it/history_panel.rs index 8c1397c7..889b3df7 100644 --- a/crates/ui-egui/tests/it/history_panel.rs +++ b/crates/ui-egui/tests/it/history_panel.rs @@ -10,7 +10,10 @@ use texturecraft_ui_egui::docking::Panel; /// Show document history so row clicks exercise the same command dispatch as the application fn history_harness(session: Session) -> Harness<'static, TextureCraftApp> { - let mut harness = Harness::builder().with_size(egui::vec2(1600.0, 960.0)).with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|context| TextureCraftApp::new(context, session)); + let mut harness = Harness::builder() + .with_size(egui::vec2(1600.0, 960.0)) + .with_context_setup(texturecraft_ui_egui::framework::install_headless) + .build_eframe(|context| TextureCraftApp::new(context, session)); harness.state_mut().ui.dock.focus(Panel::History); harness.run_steps(4); harness @@ -167,7 +170,10 @@ fn clicking_a_history_step_returns_to_it() { texturecraft_engine::execute(&mut session, "layer.rename", &json!({"layer": layer.0, "name": name})).unwrap(); } let done = session.history_labels().len(); - let mut h = Harness::builder().with_size(egui::vec2(1600.0, 960.0)).with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|cc| TextureCraftApp::new(cc, session)); + let mut h = Harness::builder() + .with_size(egui::vec2(1600.0, 960.0)) + .with_context_setup(texturecraft_ui_egui::framework::install_headless) + .build_eframe(|cc| TextureCraftApp::new(cc, session)); h.state_mut().ui.dock.focus(Panel::History); h.run_steps(4); let name = |h: &Harness<'_, TextureCraftApp>| h.state().session.doc.project.layers[&layer].name.clone(); diff --git a/crates/ui-egui/tests/it/import_resources.rs b/crates/ui-egui/tests/it/import_resources.rs index 759e1516..f32518a4 100644 --- a/crates/ui-egui/tests/it/import_resources.rs +++ b/crates/ui-egui/tests/it/import_resources.rs @@ -18,7 +18,10 @@ const PREFIX_HINT: &str = "Put in front of the resource's name. Characters other fn app() -> Harness<'static, TextureCraftApp> { let session = Session::new_project("Test", texturecraft_engine::geom::primitives::cube(1.0), "builtin:cube", None, 128).unwrap(); - let mut h = Harness::builder().with_size(egui::vec2(1600.0, 960.0)).with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|cc| TextureCraftApp::new(cc, session)); + let mut h = Harness::builder() + .with_size(egui::vec2(1600.0, 960.0)) + .with_context_setup(texturecraft_ui_egui::framework::install_headless) + .build_eframe(|cc| TextureCraftApp::new(cc, session)); h.state_mut().ui.prefs.language = "en".into(); h.run_steps(4); @@ -285,7 +288,12 @@ fn import_resources_snapshot() { let output_dir = PathBuf::from(std::env::var_os("TC_UI_SNAPSHOTS").expect("set TC_UI_SNAPSHOTS")); let dir = TempDir::new("import-resources-snapshot"); let session = Session::new_project("Resources", texturecraft_engine::geom::primitives::cube(1.0), "builtin:cube", None, 128).unwrap(); - let mut h = Harness::builder().with_size(egui::vec2(1600.0, 960.0)).with_pixels_per_point(1.0).wgpu().with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|cc| TextureCraftApp::new(cc, session)); + let mut h = Harness::builder() + .with_size(egui::vec2(1600.0, 960.0)) + .with_pixels_per_point(1.0) + .wgpu() + .with_context_setup(texturecraft_ui_egui::framework::install_headless) + .build_eframe(|cc| TextureCraftApp::new(cc, session)); h.run_steps(4); invoke(&mut h); diff --git a/crates/ui-egui/tests/it/inactive_set_hint.rs b/crates/ui-egui/tests/it/inactive_set_hint.rs index 05742559..33f48c48 100644 --- a/crates/ui-egui/tests/it/inactive_set_hint.rs +++ b/crates/ui-egui/tests/it/inactive_set_hint.rs @@ -12,7 +12,10 @@ const SEARCH_STEP: f32 = 8.0; /// The sample project (the ball is set 0, the base set 1) with the Ball active and the paint tool, at 1600 x 960 fn sample_app() -> Harness<'static, TextureCraftApp> { let session = texturecraft_engine::sample_session(256, 64).unwrap(); - let mut harness = Harness::builder().with_size(egui::vec2(1600.0, 960.0)).with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|cc| TextureCraftApp::new(cc, session)); + let mut harness = Harness::builder() + .with_size(egui::vec2(1600.0, 960.0)) + .with_context_setup(texturecraft_ui_egui::framework::install_headless) + .build_eframe(|cc| TextureCraftApp::new(cc, session)); harness.run_steps(4); assert_eq!(harness.state().session.ts(), 0); assert_eq!(harness.state().session.tool.tool, Tool::Paint); diff --git a/crates/ui-egui/tests/it/instance_properties.rs b/crates/ui-egui/tests/it/instance_properties.rs index 9b316f9b..da0a8194 100644 --- a/crates/ui-egui/tests/it/instance_properties.rs +++ b/crates/ui-egui/tests/it/instance_properties.rs @@ -23,7 +23,11 @@ fn instance_harness(dangling: bool) -> (Harness<'static, TextureCraftApp>, Layer session.doc.project.layers.get_mut(&instance).unwrap().kind = LayerKind::Instance { source: GONE }; } execute(&mut session, "layer.select", &json!({"layer": instance.0, "target": "content"})).unwrap(); - let mut harness = Harness::builder().with_size(PROPERTIES_WINDOW).with_step_dt(FRAME_SECONDS).with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|cc| TextureCraftApp::new(cc, session)); + let mut harness = Harness::builder() + .with_size(PROPERTIES_WINDOW) + .with_step_dt(FRAME_SECONDS) + .with_context_setup(texturecraft_ui_egui::framework::install_headless) + .build_eframe(|cc| TextureCraftApp::new(cc, session)); harness.state_mut().ui.prefs.language = "en".into(); harness.run_steps(STARTUP_FRAMES); (harness, instance, source) diff --git a/crates/ui-egui/tests/it/layer_blending_options.rs b/crates/ui-egui/tests/it/layer_blending_options.rs index e4d0812a..19cff699 100644 --- a/crates/ui-egui/tests/it/layer_blending_options.rs +++ b/crates/ui-egui/tests/it/layer_blending_options.rs @@ -8,7 +8,10 @@ use texturecraft_ui_egui::TextureCraftApp; fn harness() -> Harness<'static, TextureCraftApp> { let session = texturecraft_engine::sample_session(256, 64).unwrap(); - let mut h = Harness::builder().with_size(egui::vec2(1600.0, 960.0)).with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|cc| TextureCraftApp::new(cc, session)); + let mut h = Harness::builder() + .with_size(egui::vec2(1600.0, 960.0)) + .with_context_setup(texturecraft_ui_egui::framework::install_headless) + .build_eframe(|cc| TextureCraftApp::new(cc, session)); h.run_steps(4); h } diff --git a/crates/ui-egui/tests/it/layer_clipboard.rs b/crates/ui-egui/tests/it/layer_clipboard.rs index 6841ca03..37a4a150 100644 --- a/crates/ui-egui/tests/it/layer_clipboard.rs +++ b/crates/ui-egui/tests/it/layer_clipboard.rs @@ -9,7 +9,10 @@ use texturecraft_ui_egui::TextureCraftApp; /// The sample session with its selected layer clicked in the stack, and that layer. fn harness() -> (Harness<'static, TextureCraftApp>, LayerId) { let session = texturecraft_engine::sample_session(256, 64).unwrap(); - let mut h = Harness::builder().with_size(egui::vec2(1600.0, 960.0)).with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|cc| TextureCraftApp::new(cc, session)); + let mut h = Harness::builder() + .with_size(egui::vec2(1600.0, 960.0)) + .with_context_setup(texturecraft_ui_egui::framework::install_headless) + .build_eframe(|cc| TextureCraftApp::new(cc, session)); h.run_steps(4); let layer = h.state().session.selected_layer().unwrap(); let name = h.state().session.doc.project.layers[&layer].name.clone(); @@ -79,7 +82,10 @@ fn layer_shortcuts_act_on_a_selected_effect() { let layer = id(texturecraft_engine::execute(&mut session, "layer.add.fill", &serde_json::Value::Null).unwrap(), "layer"); let p = serde_json::json!({"target": "content", "filter": "invert"}); let effect = id(texturecraft_engine::execute(&mut session, "effect.add.filter", &p).unwrap(), "effect"); - let mut h = Harness::builder().with_size(egui::vec2(1600.0, 960.0)).with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|cc| TextureCraftApp::new(cc, session)); + let mut h = Harness::builder() + .with_size(egui::vec2(1600.0, 960.0)) + .with_context_setup(texturecraft_ui_egui::framework::install_headless) + .build_eframe(|cc| TextureCraftApp::new(cc, session)); h.run_steps(4); let effects = |h: &Harness<'_, TextureCraftApp>| h.state().session.doc.project.layers.get(&layer).map(|l| l.content_effects.len()); h.event(egui::Event::Copy); diff --git a/crates/ui-egui/tests/it/layer_multi_select.rs b/crates/ui-egui/tests/it/layer_multi_select.rs index 23e4c4e4..dbbf8cae 100644 --- a/crates/ui-egui/tests/it/layer_multi_select.rs +++ b/crates/ui-egui/tests/it/layer_multi_select.rs @@ -15,7 +15,10 @@ fn harness() -> (Harness<'static, TextureCraftApp>, [LayerId; 4]) { let mut session = texturecraft_engine::sample_session(256, 64).unwrap(); let rows = ["Row A", "Row B", "Row C", "Row D"] .map(|name| LayerId(execute(&mut session, "layer.add.paint", &json!({ "name": name })).unwrap()["layer"].as_u64().unwrap())); - let mut h = Harness::builder().with_size(egui::vec2(1600.0, 1200.0)).with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|cc| TextureCraftApp::new(cc, session)); + let mut h = Harness::builder() + .with_size(egui::vec2(1600.0, 1200.0)) + .with_context_setup(texturecraft_ui_egui::framework::install_headless) + .build_eframe(|cc| TextureCraftApp::new(cc, session)); h.run_steps(4); (h, rows) } diff --git a/crates/ui-egui/tests/it/layer_rename.rs b/crates/ui-egui/tests/it/layer_rename.rs index 4ecec062..b8de5ad9 100644 --- a/crates/ui-egui/tests/it/layer_rename.rs +++ b/crates/ui-egui/tests/it/layer_rename.rs @@ -9,7 +9,10 @@ use texturecraft_ui_egui::TextureCraftApp; fn harness() -> (Harness<'static, TextureCraftApp>, u64) { let session = texturecraft_engine::sample_session(256, 64).unwrap(); - let mut h = Harness::builder().with_size(egui::vec2(1600.0, 960.0)).with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|cc| TextureCraftApp::new(cc, session)); + let mut h = Harness::builder() + .with_size(egui::vec2(1600.0, 960.0)) + .with_context_setup(texturecraft_ui_egui::framework::install_headless) + .build_eframe(|cc| TextureCraftApp::new(cc, session)); h.run_steps(4); let layer = h.state().session.selected_layer().unwrap().0; (h, layer) diff --git a/crates/ui-egui/tests/it/layer_toolbar.rs b/crates/ui-egui/tests/it/layer_toolbar.rs index adb30aa7..000ed20d 100644 --- a/crates/ui-egui/tests/it/layer_toolbar.rs +++ b/crates/ui-egui/tests/it/layer_toolbar.rs @@ -26,7 +26,10 @@ fn app() -> (Harness<'static, TextureCraftApp>, LayerId) { let mut session = texturecraft_engine::sample_session(TEXTURE_RESOLUTION, BAKE_RESOLUTION).unwrap(); let layer = LayerId(execute(&mut session, "layer.add.fill", &Value::Null).unwrap()["layer"].as_u64().unwrap()); execute(&mut session, "layer.select", &json!({"layer": layer.0})).unwrap(); - let mut harness = Harness::builder().with_size(WINDOW_SIZE).with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|cc| TextureCraftApp::new(cc, session)); + let mut harness = Harness::builder() + .with_size(WINDOW_SIZE) + .with_context_setup(texturecraft_ui_egui::framework::install_headless) + .build_eframe(|cc| TextureCraftApp::new(cc, session)); harness.state_mut().ui.prefs.language = "en".into(); harness.run_steps(STARTUP_FRAMES); (harness, layer) diff --git a/crates/ui-egui/tests/it/layers_panel.rs b/crates/ui-egui/tests/it/layers_panel.rs index b5b0ba2d..beed33a0 100644 --- a/crates/ui-egui/tests/it/layers_panel.rs +++ b/crates/ui-egui/tests/it/layers_panel.rs @@ -24,7 +24,10 @@ fn harness() -> (Harness<'static, TextureCraftApp>, LayerId) { execute(&mut session, "mask.add.black", &Value::Null).unwrap(); execute(&mut session, "effect.add.generator", &json!({"generator": "position", "level": 0.5, "name": "Effect M"})).unwrap(); execute(&mut session, "layer.select", &json!({"layer": layer.0})).unwrap(); - let mut h = Harness::builder().with_size(egui::vec2(1600.0, 1200.0)).with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|cc| TextureCraftApp::new(cc, session)); + let mut h = Harness::builder() + .with_size(egui::vec2(1600.0, 1200.0)) + .with_context_setup(texturecraft_ui_egui::framework::install_headless) + .build_eframe(|cc| TextureCraftApp::new(cc, session)); h.run_steps(4); (h, layer) } @@ -153,7 +156,11 @@ fn hidpi_harness() -> (Harness<'static, TextureCraftApp>, LayerId) { let layer = LayerId(id(execute(&mut session, "layer.add.fill", &json!({"color": "#336699"})).unwrap(), "layer")); execute(&mut session, "layer.rename", &json!({"layer": layer.0, "name": "Active one"})).unwrap(); execute(&mut session, "layer.select", &json!({"layer": layer.0})).unwrap(); - let mut h = Harness::builder().with_size(egui::vec2(1200.0, 800.0)).with_pixels_per_point(2.0).with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|cc| TextureCraftApp::new(cc, session)); + let mut h = Harness::builder() + .with_size(egui::vec2(1200.0, 800.0)) + .with_pixels_per_point(2.0) + .with_context_setup(texturecraft_ui_egui::framework::install_headless) + .build_eframe(|cc| TextureCraftApp::new(cc, session)); h.run_steps(4); (h, layer) } @@ -259,7 +266,10 @@ fn narrow_harness() -> Harness<'static, TextureCraftApp> { let mut session = texturecraft_engine::sample_session(256, 64).unwrap(); let layer = id(execute(&mut session, "layer.add.fill", &json!({"color": "#336699"})).unwrap(), "layer"); execute(&mut session, "layer.rename", &json!({"layer": layer, "name": LONG_NAME})).unwrap(); - let mut h = Harness::builder().with_size(egui::vec2(1280.0, 800.0)).with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|cc| TextureCraftApp::new(cc, session)); + let mut h = Harness::builder() + .with_size(egui::vec2(1280.0, 800.0)) + .with_context_setup(texturecraft_ui_egui::framework::install_headless) + .build_eframe(|cc| TextureCraftApp::new(cc, session)); h.state_mut().ui.prefs.language = "en".into(); h.run_steps(4); h @@ -297,7 +307,10 @@ fn an_effect_name_cut_short_shows_in_full_on_hover() { let layer = id(execute(&mut session, "layer.add.fill", &json!({"color": "#336699"})).unwrap(), "layer"); execute(&mut session, "layer.select", &json!({"layer": layer})).unwrap(); execute(&mut session, "effect.add.filter", &json!({"target": "content", "filter": "invert", "name": LONG_EFFECT_NAME})).unwrap(); - let mut h = Harness::builder().with_size(egui::vec2(1280.0, 800.0)).with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|cc| TextureCraftApp::new(cc, session)); + let mut h = Harness::builder() + .with_size(egui::vec2(1280.0, 800.0)) + .with_context_setup(texturecraft_ui_egui::framework::install_headless) + .build_eframe(|cc| TextureCraftApp::new(cc, session)); h.state_mut().ui.prefs.language = "en".into(); h.run_steps(4); diff --git a/crates/ui-egui/tests/it/levels_editor.rs b/crates/ui-egui/tests/it/levels_editor.rs index ad687577..ead001b2 100644 --- a/crates/ui-egui/tests/it/levels_editor.rs +++ b/crates/ui-egui/tests/it/levels_editor.rs @@ -40,7 +40,11 @@ fn open(mut session: Session, effect: LayerId) -> (Harness<'static, TextureCraft execute(&mut session, "layer.select", &json!({"layer": layer.0, "target": effect.0})).unwrap(); // Frames of a 60 Hz screen: kittest's default quarter second spreads a double-click past egui's delay - let mut harness = Harness::builder().with_size(PROPERTIES_WINDOW).with_step_dt(FRAME_SECONDS).with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|cc| TextureCraftApp::new(cc, session)); + let mut harness = Harness::builder() + .with_size(PROPERTIES_WINDOW) + .with_step_dt(FRAME_SECONDS) + .with_context_setup(texturecraft_ui_egui::framework::install_headless) + .build_eframe(|cc| TextureCraftApp::new(cc, session)); harness.run_steps(STARTUP_FRAMES); (harness, effect) } diff --git a/crates/ui-egui/tests/it/log_panel_680.rs b/crates/ui-egui/tests/it/log_panel_680.rs index fecd0ab2..eba3e084 100644 --- a/crates/ui-egui/tests/it/log_panel_680.rs +++ b/crates/ui-egui/tests/it/log_panel_680.rs @@ -9,7 +9,10 @@ use texturecraft_ui_egui::docking::Panel; fn app() -> Harness<'static, TextureCraftApp> { let session = texturecraft_engine::sample_session(256, 64).unwrap(); - let mut h = Harness::builder().with_size(egui::vec2(1600.0, 960.0)).with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|cc| TextureCraftApp::new(cc, session)); + let mut h = Harness::builder() + .with_size(egui::vec2(1600.0, 960.0)) + .with_context_setup(texturecraft_ui_egui::framework::install_headless) + .build_eframe(|cc| TextureCraftApp::new(cc, session)); h.state_mut().ui.prefs.language = "en".into(); { let log = &mut h.state_mut().session.log; diff --git a/crates/ui-egui/tests/it/main.rs b/crates/ui-egui/tests/it/main.rs index 7c9104fa..d3b1921f 100644 --- a/crates/ui-egui/tests/it/main.rs +++ b/crates/ui-egui/tests/it/main.rs @@ -201,13 +201,13 @@ fn click_widget(harness: &mut Harness<'_, TextureCraftApp>, role: egui::Role, la click_at(harness, at); } -/// The close button nearest the right of a docked panel's `title` (its tab or header title), on the same row +/// The close button of a docked panel's tab `title`: in the tab's right half, on its row fn panel_close_button(harness: &Harness<'_, TextureCraftApp>, title: egui::Rect) -> egui::Rect { harness .get_all_by_role(egui::Role::Button) .filter(|button| button.accesskit_node().label().is_some_and(|label| label.starts_with("Close "))) .map(|button| button.rect()) - .filter(|close| close.min.x > title.max.x && title.y_range().contains(close.center().y)) + .filter(|close| close.center().x > title.center().x && title.y_range().contains(close.center().y)) .min_by(|a, b| a.min.x.total_cmp(&b.min.x)) .expect("a close button right of the title") } diff --git a/crates/ui-egui/tests/it/mask_export.rs b/crates/ui-egui/tests/it/mask_export.rs index ac84609f..453672b6 100644 --- a/crates/ui-egui/tests/it/mask_export.rs +++ b/crates/ui-egui/tests/it/mask_export.rs @@ -22,7 +22,10 @@ fn harness(mask: bool) -> Harness<'static, TextureCraftApp> { execute(&mut session, "mask.add.black", &Value::Null).unwrap(); execute(&mut session, "effect.add.fill", &json!({"value": 0.5})).unwrap(); } - let mut h = Harness::builder().with_size(egui::vec2(1600.0, 960.0)).with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|cc| TextureCraftApp::new(cc, session)); + let mut h = Harness::builder() + .with_size(egui::vec2(1600.0, 960.0)) + .with_context_setup(texturecraft_ui_egui::framework::install_headless) + .build_eframe(|cc| TextureCraftApp::new(cc, session)); h.run_steps(4); h } diff --git a/crates/ui-egui/tests/it/mask_fill_rows.rs b/crates/ui-egui/tests/it/mask_fill_rows.rs index 2c4b50e6..a916fa9f 100644 --- a/crates/ui-egui/tests/it/mask_fill_rows.rs +++ b/crates/ui-egui/tests/it/mask_fill_rows.rs @@ -26,7 +26,10 @@ fn app_with_mask_fill(projection: &str) -> (Harness<'static, TextureCraftApp>, L let added = texturecraft_engine::execute(&mut session, "effect.add.fill", &json!({"layer": layer.0, "target": "mask", "projection": projection})).unwrap(); let effect = LayerId(added["effect"].as_u64().unwrap()); texturecraft_engine::execute(&mut session, "layer.select", &json!({"layer": layer.0, "target": effect.0})).unwrap(); - let mut harness = Harness::builder().with_size(WINDOW_SIZE).with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|cc| TextureCraftApp::new(cc, session)); + let mut harness = Harness::builder() + .with_size(WINDOW_SIZE) + .with_context_setup(texturecraft_ui_egui::framework::install_headless) + .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(); @@ -146,7 +149,10 @@ fn a_mask_fill_reading_a_content_anchor_picks_its_channel() { let added = texturecraft_engine::execute(&mut session, "effect.add.fill", &json!({"layer": top, "target": "mask", "anchor": anchor})).unwrap(); let effect = LayerId(added["effect"].as_u64().unwrap()); texturecraft_engine::execute(&mut session, "layer.select", &json!({"layer": top, "target": effect.0})).unwrap(); - let mut harness = Harness::builder().with_size(WINDOW_SIZE).with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|cc| TextureCraftApp::new(cc, session)); + let mut harness = Harness::builder() + .with_size(WINDOW_SIZE) + .with_context_setup(texturecraft_ui_egui::framework::install_headless) + .build_eframe(|cc| TextureCraftApp::new(cc, session)); harness.state_mut().ui.prefs.language = "en".into(); harness.run_steps(STARTUP_FRAMES); let Source::Anchor { channel, .. } = mask_fill(&harness, effect).0 else { panic!("an anchor source") }; @@ -176,7 +182,10 @@ fn an_inherited_mask_fill_lists_only_anchors_below_its_owner() { let instance = texturecraft_engine::execute(&mut session, "layer.instance", &json!({"layer": source})).unwrap()["layer"].clone(); texturecraft_engine::execute(&mut session, "layer.select", &json!({"layer": instance})).unwrap(); session.target = texturecraft_engine::StackTarget::Effect(effect); - let mut harness = Harness::builder().with_size(WINDOW_SIZE).with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|cc| TextureCraftApp::new(cc, session)); + let mut harness = Harness::builder() + .with_size(WINDOW_SIZE) + .with_context_setup(texturecraft_ui_egui::framework::install_headless) + .build_eframe(|cc| TextureCraftApp::new(cc, session)); harness.state_mut().ui.prefs.language = "en".into(); harness.run_steps(STARTUP_FRAMES); diff --git a/crates/ui-egui/tests/it/mask_paint_grayscale.rs b/crates/ui-egui/tests/it/mask_paint_grayscale.rs index 110222d6..059beb4f 100644 --- a/crates/ui-egui/tests/it/mask_paint_grayscale.rs +++ b/crates/ui-egui/tests/it/mask_paint_grayscale.rs @@ -26,7 +26,11 @@ fn folder_mask_harness() -> (Harness<'static, TextureCraftApp>, String) { let folder = LayerId(execute(&mut session, "layer.add.group", &json!({})).unwrap()["layer"].as_u64().unwrap()); execute(&mut session, "mask.add.white", &json!({"layer": folder.0})).unwrap(); execute(&mut session, "layer.select", &json!({"layer": folder.0, "target": "mask"})).unwrap(); - let mut harness = Harness::builder().with_size(PROPERTIES_WINDOW).with_step_dt(FRAME_SECONDS).with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|cc| TextureCraftApp::new(cc, session)); + let mut harness = Harness::builder() + .with_size(PROPERTIES_WINDOW) + .with_step_dt(FRAME_SECONDS) + .with_context_setup(texturecraft_ui_egui::framework::install_headless) + .build_eframe(|cc| TextureCraftApp::new(cc, session)); harness.state_mut().ui.prefs.language = "en".into(); harness.state_mut().ui.props_tab = PropsTab::Material; harness.run_steps(STARTUP_FRAMES); diff --git a/crates/ui-egui/tests/it/mask_value_swap.rs b/crates/ui-egui/tests/it/mask_value_swap.rs index 8f098a21..0d1e44fc 100644 --- a/crates/ui-egui/tests/it/mask_value_swap.rs +++ b/crates/ui-egui/tests/it/mask_value_swap.rs @@ -9,7 +9,10 @@ fn harness() -> Harness<'static, TextureCraftApp> { let mut session = texturecraft_engine::sample_session(256, 64).unwrap(); texturecraft_engine::execute(&mut session, "mask.add.white", &serde_json::Value::Null).unwrap(); session.target = StackTarget::Mask; - let mut harness = Harness::builder().with_size(egui::vec2(1600.0, 960.0)).with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|context| TextureCraftApp::new(context, session)); + let mut harness = Harness::builder() + .with_size(egui::vec2(1600.0, 960.0)) + .with_context_setup(texturecraft_ui_egui::framework::install_headless) + .build_eframe(|context| TextureCraftApp::new(context, session)); harness.run_steps(4); harness diff --git a/crates/ui-egui/tests/it/named_layouts.rs b/crates/ui-egui/tests/it/named_layouts.rs index 854509af..ab44b3b8 100644 --- a/crates/ui-egui/tests/it/named_layouts.rs +++ b/crates/ui-egui/tests/it/named_layouts.rs @@ -9,8 +9,11 @@ use texturecraft_ui_egui::state::Mode; fn app() -> Harness<'static, TextureCraftApp> { let session = texturecraft_engine::sample_session(256, 64).unwrap(); - let mut harness = - Harness::builder().with_size(egui::vec2(1600.0, 960.0)).with_accessibility_check(false).with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|cc| TextureCraftApp::new(cc, session)); + let mut harness = Harness::builder() + .with_size(egui::vec2(1600.0, 960.0)) + .with_accessibility_check(false) + .with_context_setup(texturecraft_ui_egui::framework::install_headless) + .build_eframe(|cc| TextureCraftApp::new(cc, session)); harness.run_steps(4); harness } diff --git a/crates/ui-egui/tests/it/nav_buttons.rs b/crates/ui-egui/tests/it/nav_buttons.rs index 2f5829cb..a624445a 100644 --- a/crates/ui-egui/tests/it/nav_buttons.rs +++ b/crates/ui-egui/tests/it/nav_buttons.rs @@ -17,7 +17,11 @@ const WINDOW: egui::Vec2 = vec2(1280.0, 800.0); /// The app showing only one view, so that the view fills the viewport rect the 3D view reports fn app(layout: ViewLayout) -> (Harness<'static, TextureCraftApp>, Rect) { let session = texturecraft_engine::sample_session(256, 64).unwrap(); - let mut harness = Harness::builder().with_size(WINDOW).with_pixels_per_point(1.0).with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|cc| TextureCraftApp::new(cc, session)); + let mut harness = Harness::builder() + .with_size(WINDOW) + .with_pixels_per_point(1.0) + .with_context_setup(texturecraft_ui_egui::framework::install_headless) + .build_eframe(|cc| TextureCraftApp::new(cc, session)); harness.state_mut().session.tool.tool = texturecraft_engine::Tool::Paint; harness.state_mut().ui.layout = ViewLayout::Only3D; harness.run_steps(4); diff --git a/crates/ui-egui/tests/it/new_project_baked_maps.rs b/crates/ui-egui/tests/it/new_project_baked_maps.rs index 5baf3251..4fae5942 100644 --- a/crates/ui-egui/tests/it/new_project_baked_maps.rs +++ b/crates/ui-egui/tests/it/new_project_baked_maps.rs @@ -19,7 +19,10 @@ fn harness_for(dir: &Path) -> Harness<'static, TextureCraftApp> { let mesh = dir.join("Ball.obj"); std::fs::write(&mesh, TWO_MATERIALS).unwrap(); let session = texturecraft_engine::sample_session(256, 64).unwrap(); - let mut h = Harness::builder().with_size(egui::vec2(1600.0, 960.0)).with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|cc| TextureCraftApp::new(cc, session)); + let mut h = Harness::builder() + .with_size(egui::vec2(1600.0, 960.0)) + .with_context_setup(texturecraft_ui_egui::framework::install_headless) + .build_eframe(|cc| TextureCraftApp::new(cc, session)); h.state_mut().ui.windows.new_project = true; h.state_mut().ui.new_project.resolution = 256; h.state_mut().ui.new_project.file = Some(mesh.display().to_string()); @@ -129,11 +132,16 @@ fn new_project_baked_maps_snapshots() { let output_dir = PathBuf::from(std::env::var_os("TC_UI_SNAPSHOTS").expect("set TC_UI_SNAPSHOTS")); std::fs::create_dir_all(&output_dir).unwrap(); let session = texturecraft_engine::sample_session(256, 64).unwrap(); - let mut h = Harness::builder().with_size(egui::vec2(1600.0, 960.0)).with_pixels_per_point(1.0).wgpu().with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|cc| { - let adapter = cc.wgpu_render_state.as_ref().unwrap().adapter.get_info(); - eprintln!("snapshot adapter: {adapter:?}"); - TextureCraftApp::new(cc, session) - }); + let mut h = Harness::builder() + .with_size(egui::vec2(1600.0, 960.0)) + .with_pixels_per_point(1.0) + .wgpu() + .with_context_setup(texturecraft_ui_egui::framework::install_headless) + .build_eframe(|cc| { + let adapter = cc.wgpu_render_state.as_ref().unwrap().adapter.get_info(); + eprintln!("snapshot adapter: {adapter:?}"); + TextureCraftApp::new(cc, session) + }); let dir = TempDir::new("new-project-baked-maps-snapshots"); let mesh = dir.join("Ball.obj"); std::fs::write(&mesh, TWO_MATERIALS).unwrap(); diff --git a/crates/ui-egui/tests/it/new_project_window.rs b/crates/ui-egui/tests/it/new_project_window.rs index 94436fa7..4ed0baf5 100644 --- a/crates/ui-egui/tests/it/new_project_window.rs +++ b/crates/ui-egui/tests/it/new_project_window.rs @@ -21,7 +21,10 @@ fn harness() -> Harness<'static, TextureCraftApp> { fn harness_sized(size: egui::Vec2) -> Harness<'static, TextureCraftApp> { let session = texturecraft_engine::Session::new_project("Open", texturecraft_engine::geom::primitives::cube(1.0), "builtin:cube", None, 128).unwrap(); - let mut h = Harness::builder().with_size(size).with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|cc| TextureCraftApp::new(cc, session)); + let mut h = Harness::builder() + .with_size(size) + .with_context_setup(texturecraft_ui_egui::framework::install_headless) + .build_eframe(|cc| TextureCraftApp::new(cc, session)); h.state_mut().ui.prefs.language = "en".into(); h.run_steps(2); let ctx = h.ctx.clone(); diff --git a/crates/ui-egui/tests/it/output_templates.rs b/crates/ui-egui/tests/it/output_templates.rs index 308db067..24d310b5 100644 --- a/crates/ui-egui/tests/it/output_templates.rs +++ b/crates/ui-egui/tests/it/output_templates.rs @@ -15,7 +15,10 @@ use template_library::TemplateLibrary; /// OUTPUT TEMPLATES with the user template "Mine" selected fn harness(library: &TemplateLibrary) -> Harness<'static, TextureCraftApp> { let session = texturecraft_engine::sample_session(256, 64).unwrap(); - let mut h = Harness::builder().with_size(egui::vec2(1600.0, 960.0)).with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|cc| TextureCraftApp::new(cc, session)); + let mut h = Harness::builder() + .with_size(egui::vec2(1600.0, 960.0)) + .with_context_setup(texturecraft_ui_egui::framework::install_headless) + .build_eframe(|cc| TextureCraftApp::new(cc, session)); h.state_mut().ui.prefs.language = "en".into(); h.run_steps(4); h.state_mut().session.load_export_presets(library.0.clone()); diff --git a/crates/ui-egui/tests/it/panel_header.rs b/crates/ui-egui/tests/it/panel_header.rs index 7227a327..a7202ad4 100644 --- a/crates/ui-egui/tests/it/panel_header.rs +++ b/crates/ui-egui/tests/it/panel_header.rs @@ -12,7 +12,10 @@ const WINDOW_SIZE: egui::Vec2 = egui::vec2(1600.0, 960.0); fn app() -> Harness<'static, TextureCraftApp> { let session = texturecraft_engine::sample_session(TEXTURE_RESOLUTION, BAKE_RESOLUTION).unwrap(); - let mut harness = Harness::builder().with_size(WINDOW_SIZE).with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|cc| TextureCraftApp::new(cc, session)); + let mut harness = Harness::builder() + .with_size(WINDOW_SIZE) + .with_context_setup(texturecraft_ui_egui::framework::install_headless) + .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(); diff --git a/crates/ui-egui/tests/it/path_in_view.rs b/crates/ui-egui/tests/it/path_in_view.rs index a3d5908c..18b92420 100644 --- a/crates/ui-egui/tests/it/path_in_view.rs +++ b/crates/ui-egui/tests/it/path_in_view.rs @@ -22,7 +22,10 @@ fn harness() -> AppHarness<'static> { execute(&mut session, "layer.add.paint", &serde_json::Value::Null).unwrap(); execute(&mut session, "tool.select", &json!({"tool": "path"})).unwrap(); // Tall enough that the 2D view's texture square takes A, B and C - let mut h = Harness::builder().with_size(egui::vec2(1600.0, 1500.0)).with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|cc| TextureCraftApp::new(cc, session)); + let mut h = Harness::builder() + .with_size(egui::vec2(1600.0, 1500.0)) + .with_context_setup(texturecraft_ui_egui::framework::install_headless) + .build_eframe(|cc| TextureCraftApp::new(cc, session)); h.state_mut().ui.layout = ViewLayout::Only2D; h.run_steps(4); h @@ -156,7 +159,10 @@ fn clicking_the_2d_view_preserves_a_stored_3d_path_being_edited() { let before = session.doc.clone(); let path = session.tool.path.clone(); let history = session.history_labels(); - let mut harness = Harness::builder().with_size(egui::vec2(1600.0, 960.0)).with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|context| TextureCraftApp::new(context, session)); + let mut harness = Harness::builder() + .with_size(egui::vec2(1600.0, 960.0)) + .with_context_setup(texturecraft_ui_egui::framework::install_headless) + .build_eframe(|context| TextureCraftApp::new(context, session)); harness.state_mut().ui.layout = ViewLayout::Split; harness.run_steps(4); let view_3d = harness.state().viewport_rect; @@ -213,7 +219,10 @@ fn split_harness() -> (AppHarness<'static>, Pos2, Pos2) { session.update(); execute(&mut session, "layer.add.paint", &serde_json::Value::Null).unwrap(); execute(&mut session, "tool.select", &json!({"tool": "path"})).unwrap(); - let mut harness = Harness::builder().with_size(egui::vec2(1600.0, 960.0)).with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|context| TextureCraftApp::new(context, session)); + let mut harness = Harness::builder() + .with_size(egui::vec2(1600.0, 960.0)) + .with_context_setup(texturecraft_ui_egui::framework::install_headless) + .build_eframe(|context| TextureCraftApp::new(context, session)); harness.state_mut().ui.layout = ViewLayout::Split; harness.run_steps(4); let view_3d = harness.state().viewport_rect; diff --git a/crates/ui-egui/tests/it/path_list.rs b/crates/ui-egui/tests/it/path_list.rs index bf9a6dab..d56feb79 100644 --- a/crates/ui-egui/tests/it/path_list.rs +++ b/crates/ui-egui/tests/it/path_list.rs @@ -14,7 +14,10 @@ fn path_rows_edit_and_remove_paths() { let r = execute(&mut session, "tool.path", &json!({"uvPoints": [[0.2, 0.5], [0.5, 0.4], [0.8, 0.5]], "commit": true})).unwrap(); let eid = LayerId(r["committed"]["effect"].as_u64().unwrap()); execute(&mut session, "tool.path", &json!({"uvPoints": [[0.2, 0.8], [0.8, 0.8]], "commit": true})).unwrap(); - let mut h = Harness::builder().with_size(egui::vec2(1600.0, 1400.0)).with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|cc| TextureCraftApp::new(cc, session)); + let mut h = Harness::builder() + .with_size(egui::vec2(1600.0, 1400.0)) + .with_context_setup(texturecraft_ui_egui::framework::install_headless) + .build_eframe(|cc| TextureCraftApp::new(cc, session)); h.run_steps(4); let editing = |h: &Harness<'_, TextureCraftApp>| h.state().session.tool.path.editing; let count = |h: &Harness<'_, TextureCraftApp>| h.state().session.paths(eid).map_or(0, <[_]>::len); diff --git a/crates/ui-egui/tests/it/pen_pressure.rs b/crates/ui-egui/tests/it/pen_pressure.rs index 43b2a692..63f347c0 100644 --- a/crates/ui-egui/tests/it/pen_pressure.rs +++ b/crates/ui-egui/tests/it/pen_pressure.rs @@ -24,7 +24,10 @@ fn frame(harness: &mut Harness<'_, TextureCraftApp>, pen: Option<(TouchPhase, Op /// Paint in the 2D view with `input` and return the summed base color alpha it added. fn paint_2d(input: impl FnOnce(&mut Harness<'_, TextureCraftApp>)) -> f64 { let session = texturecraft_engine::sample_session(256, 64).unwrap(); - let mut harness = Harness::builder().with_size(egui::vec2(1600.0, 1500.0)).with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|creation_context| TextureCraftApp::new(creation_context, session)); + let mut harness = Harness::builder() + .with_size(egui::vec2(1600.0, 1500.0)) + .with_context_setup(texturecraft_ui_egui::framework::install_headless) + .build_eframe(|creation_context| TextureCraftApp::new(creation_context, session)); harness.state_mut().ui.layout = ViewLayout::Only2D; harness.state_mut().session.tool.brush.min_size = 0.0; harness.run_steps(4); diff --git a/crates/ui-egui/tests/it/polygon_fill.rs b/crates/ui-egui/tests/it/polygon_fill.rs index e4df7fb0..0873b85e 100644 --- a/crates/ui-egui/tests/it/polygon_fill.rs +++ b/crates/ui-egui/tests/it/polygon_fill.rs @@ -9,7 +9,10 @@ use texturecraft_ui_egui::TextureCraftApp; /// The sample project in the default split layout at 1600 x 960 with the polygon fill tool fn polygon_fill_app() -> Harness<'static, TextureCraftApp> { let session = texturecraft_engine::sample_session(256, 64).unwrap(); - let mut harness = Harness::builder().with_size(egui::vec2(1600.0, 960.0)).with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|cc| TextureCraftApp::new(cc, session)); + let mut harness = Harness::builder() + .with_size(egui::vec2(1600.0, 960.0)) + .with_context_setup(texturecraft_ui_egui::framework::install_headless) + .build_eframe(|cc| TextureCraftApp::new(cc, session)); harness.state_mut().session.tool.tool = Tool::PolygonFill; harness.run_steps(4); harness @@ -138,7 +141,11 @@ fn polygon_fill_snapshots() { std::fs::create_dir_all(&directory).unwrap(); let session = texturecraft_engine::sample_session(256, 64).unwrap(); - let mut harness = Harness::builder().with_size(vec2(1600.0, 960.0)).wgpu().with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|context| TextureCraftApp::new(context, session)); + let mut harness = Harness::builder() + .with_size(vec2(1600.0, 960.0)) + .wgpu() + .with_context_setup(texturecraft_ui_egui::framework::install_headless) + .build_eframe(|context| TextureCraftApp::new(context, session)); let adapter = harness.state().render_state.as_ref().unwrap().adapter.get_info(); eprintln!("Offscreen adapter: {} ({:?}), driver {} {}", adapter.name, adapter.backend, adapter.driver, adapter.driver_info); harness.state_mut().session.tool.tool = Tool::PolygonFill; @@ -165,22 +172,3 @@ fn polygon_fill_snapshots() { harness.run_steps(6); harness.render().unwrap().save(directory.join("polygon-fill-mask-2d.png")).unwrap(); } - -/// A Properties body not yet on the property sheet starts under the panel's name, at the sheet's side padding (it started 4 px left of it) -#[test] -fn the_polygon_fill_body_starts_under_the_properties_name() { - let mut harness = polygon_fill_app(); - harness.state_mut().ui.prefs.language = "en".into(); - harness.run_steps(2); - - let painted_left = |wanted: &dyn Fn(&str) -> bool| { - harness.output().shapes.iter().find_map(|clipped| match &clipped.shape { - egui::Shape::Text(text) if wanted(text.galley.text()) => Some(text.pos.x), - _ => None, - }) - }; - let caption = painted_left(&|text| text == "POLYGON FILL"); - let header = painted_left(&|text| text.starts_with("PROPERTIES")); - - assert!(caption.is_some() && caption == header, "the body starts at {caption:?}, the header name at {header:?}"); -} diff --git a/crates/ui-egui/tests/it/popup_press_close.rs b/crates/ui-egui/tests/it/popup_press_close.rs index 58acc3b4..72605f64 100644 --- a/crates/ui-egui/tests/it/popup_press_close.rs +++ b/crates/ui-egui/tests/it/popup_press_close.rs @@ -93,7 +93,7 @@ fn stroke_on_model(harness: &mut Harness<'_, TextureCraftApp>, modifiers: Modifi /// Opens the paint tool's Base color swatch from its Properties' Material tab fn open_tool_color(harness: &mut Harness<'_, TextureCraftApp>) { - let header = harness.get_by_label("Properties - Paint").rect(); + let header = harness.get_by_role_and_label(egui::Role::Tab, "Properties - Paint").rect(); let in_properties = |rect: egui::Rect| header.x_range().contains(rect.center().x) && rect.top() > header.top(); let material = harness.get_all_by_label("Material").find(|node| in_properties(node.rect())).unwrap(); material.click(); diff --git a/crates/ui-egui/tests/it/project_config.rs b/crates/ui-egui/tests/it/project_config.rs index 3308314b..a44c4640 100644 --- a/crates/ui-egui/tests/it/project_config.rs +++ b/crates/ui-egui/tests/it/project_config.rs @@ -28,7 +28,10 @@ fn app_on_a_quad(dir: &std::path::Path) -> Harness<'static, TextureCraftApp> { let mut session = Session::from_mesh_bytes("quad.obj", QUAD.as_bytes(), 128, "quad").unwrap(); texturecraft_engine::execute(&mut session, "layer.add.fill", &json!({"color": [1.0, 0.0, 0.0]})).unwrap(); session.doc.project.mesh_path = file.display().to_string(); - let mut h = Harness::builder().with_size(egui::vec2(1600.0, 960.0)).with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|cc| TextureCraftApp::new(cc, session)); + let mut h = Harness::builder() + .with_size(egui::vec2(1600.0, 960.0)) + .with_context_setup(texturecraft_ui_egui::framework::install_headless) + .build_eframe(|cc| TextureCraftApp::new(cc, session)); h.state_mut().ui.prefs.language = "en".into(); h.run_steps(4); @@ -742,7 +745,12 @@ fn project_config_snapshots() { 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().with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|cc| TextureCraftApp::new(cc, session)); + let mut h = Harness::builder() + .with_size(egui::vec2(1600.0, 960.0)) + .with_pixels_per_point(1.0) + .wgpu() + .with_context_setup(texturecraft_ui_egui::framework::install_headless) + .build_eframe(|cc| TextureCraftApp::new(cc, session)); h.run_steps(6); open_window(&mut h); h.run_steps(6); diff --git a/crates/ui-egui/tests/it/properties_lists.rs b/crates/ui-egui/tests/it/properties_lists.rs index 37b5e973..3486b719 100644 --- a/crates/ui-egui/tests/it/properties_lists.rs +++ b/crates/ui-egui/tests/it/properties_lists.rs @@ -29,7 +29,11 @@ const ESCAPES_TO_CLEAR: usize = 2; fn screen(setup: impl FnOnce(&mut Session)) -> Harness<'static, TextureCraftApp> { let mut session = texturecraft_engine::sample_session(TEXTURE_RESOLUTION, BAKE_RESOLUTION).unwrap(); setup(&mut session); - let mut harness = Harness::builder().with_size(PROPERTIES_WINDOW).with_accessibility_check(false).with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|cc| TextureCraftApp::new(cc, session)); + let mut harness = Harness::builder() + .with_size(PROPERTIES_WINDOW) + .with_accessibility_check(false) + .with_context_setup(texturecraft_ui_egui::framework::install_headless) + .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(); diff --git a/crates/ui-egui/tests/it/properties_min_width.rs b/crates/ui-egui/tests/it/properties_min_width.rs index 3b2f2faa..9d9ed6fb 100644 --- a/crates/ui-egui/tests/it/properties_min_width.rs +++ b/crates/ui-egui/tests/it/properties_min_width.rs @@ -2,31 +2,22 @@ use craft_behavior::dock::Node; use craft_behavior::dock::SplitSize; -use egui::{Event, Modifiers, PointerButton, Pos2, Role, pos2}; +use egui::Role; use egui_kittest::Harness; use egui_kittest::kittest::{NodeT, Queryable}; use texturecraft_ui_egui::TextureCraftApp; use texturecraft_ui_egui::docking::{Dock, PROPERTIES_MIN_WIDTH}; -use crate::{BAKE_RESOLUTION, DRAG_STEP_FRAMES, SETTLE_FRAMES, STARTUP_FRAMES, TEXTURE_RESOLUTION, panel_close_button}; +use crate::{BAKE_RESOLUTION, SETTLE_FRAMES, STARTUP_FRAMES, TEXTURE_RESOLUTION, panel_close_button}; const WINDOW_SIZE: egui::Vec2 = egui::vec2(1600.0, 960.0); -/// A right column comfortably wider than the minimum, where a drag starts -const WIDE_COLUMN: f32 = 420.0; - -/// Half the gutter between the views and the right column, where its divider is grabbed -const DIVIDER_OFFSET: f32 = 3.0; - -/// How far under the Properties header the divider is grabbed: beside the panel's rows, clear of the header bar -const DIVIDER_GRAB_BELOW_HEADER: f32 = 100.0; - -/// How far right of the window's edge a drag aims, past any width the column could stop at -const WINDOW_RIGHT_INSET: f32 = 4.0; - fn app() -> Harness<'static, TextureCraftApp> { let session = texturecraft_engine::sample_session(TEXTURE_RESOLUTION, BAKE_RESOLUTION).unwrap(); - let mut harness = Harness::builder().with_size(WINDOW_SIZE).with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|cc| TextureCraftApp::new(cc, session)); + let mut harness = Harness::builder() + .with_size(WINDOW_SIZE) + .with_context_setup(texturecraft_ui_egui::framework::install_headless) + .build_eframe(|cc| TextureCraftApp::new(cc, session)); // The header names below are English; a first run would speak the system's language harness.state_mut().ui.prefs.language = "en".into(); @@ -62,45 +53,6 @@ fn properties_header_width(harness: &Harness<'_, TextureCraftApp>) -> f32 { panel_close_button(harness, title).max.x - title.min.x } -/// Moves of a divider drag, so the dock follows the pointer as it does by hand -const DRAG_MOVES: usize = 4; - -/// Drags with the primary button from `from` to `to` in [`DRAG_MOVES`] moves -fn drag(harness: &mut Harness<'_, TextureCraftApp>, from: Pos2, to: Pos2) { - harness.hover_at(from); - harness.run_steps(1); - harness.event(Event::PointerButton { pos: from, button: PointerButton::Primary, pressed: true, modifiers: Modifiers::NONE }); - harness.run_steps(DRAG_STEP_FRAMES); - - for step in 1..=DRAG_MOVES { - harness.hover_at(from + (to - from) * (step as f32 / DRAG_MOVES as f32)); - harness.run_steps(1); - } - - harness.event(Event::PointerButton { pos: to, button: PointerButton::Primary, pressed: false, modifiers: Modifiers::NONE }); - harness.run_steps(SETTLE_FRAMES); -} - -#[test] -fn dragging_the_right_column_narrow_stops_at_the_properties_minimum_width() { - let mut harness = app(); - set_column_width(&mut harness, PROPERTIES_MIN_WIDTH); - let at_minimum = properties_header_width(&harness); - - set_column_width(&mut harness, WIDE_COLUMN); - let before = properties_title(&harness).min.x; - - assert!(properties_header_width(&harness) > at_minimum, "a wide column gives Properties more than its minimum"); - - let y = properties_title(&harness).max.y + DIVIDER_GRAB_BELOW_HEADER; - drag(&mut harness, pos2(before - DIVIDER_OFFSET, y), pos2(WINDOW_SIZE.x - WINDOW_RIGHT_INSET, y)); - - assert!(properties_title(&harness).min.x > before, "the divider moved right"); - - let width = properties_header_width(&harness); - assert!((width - at_minimum).abs() < 0.5, "Properties stopped at its minimum: header {width}, {at_minimum} at the minimum"); -} - #[test] fn a_layout_saved_narrower_draws_properties_at_its_minimum_width() { let mut harness = app(); diff --git a/crates/ui-egui/tests/it/properties_popup.rs b/crates/ui-egui/tests/it/properties_popup.rs index fa13ae62..19de942d 100644 --- a/crates/ui-egui/tests/it/properties_popup.rs +++ b/crates/ui-egui/tests/it/properties_popup.rs @@ -42,7 +42,10 @@ fn harness() -> Harness<'static, TextureCraftApp> { /// The sample project's app in a window of `size`, speaking English fn harness_sized(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).with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|cc| TextureCraftApp::new(cc, session)); + let mut harness = Harness::builder() + .with_size(size) + .with_context_setup(texturecraft_ui_egui::framework::install_headless) + .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(); diff --git a/crates/ui-egui/tests/it/properties_scroll.rs b/crates/ui-egui/tests/it/properties_scroll.rs index d6590e8f..de6fa415 100644 --- a/crates/ui-egui/tests/it/properties_scroll.rs +++ b/crates/ui-egui/tests/it/properties_scroll.rs @@ -50,7 +50,10 @@ fn harness_sized(size: egui::Vec2) -> Harness<'static, TextureCraftApp> { execute(&mut session, "layer.fill.projection", &json!({"layer": layer, "projection": "uv"})).unwrap(); } - let mut harness = Harness::builder().with_size(size).with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|cc| TextureCraftApp::new(cc, session)); + let mut harness = Harness::builder() + .with_size(size) + .with_context_setup(texturecraft_ui_egui::framework::install_headless) + .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(); diff --git a/crates/ui-egui/tests/it/rail.rs b/crates/ui-egui/tests/it/rail.rs index 933218d1..7dbd97f2 100644 --- a/crates/ui-egui/tests/it/rail.rs +++ b/crates/ui-egui/tests/it/rail.rs @@ -33,7 +33,10 @@ fn app() -> Harness<'static, TextureCraftApp> { 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).with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|cc| TextureCraftApp::new(cc, session)); + let mut harness = Harness::builder() + .with_size(size) + .with_context_setup(texturecraft_ui_egui::framework::install_headless) + .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(); @@ -74,10 +77,15 @@ fn drag(harness: &mut Harness<'_, TextureCraftApp>, from: Pos2, to: Pos2) { /// 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 { - 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()) + let labelled = |label: &'static str| { + harness + .query_all(by().role(Role::Button)) + .filter(move |button| button.rect().max.x < RAIL_LEFT_EDGE && button.accesskit_node().label().as_deref() == Some(label)) + .map(|button| button.rect()) + }; + // The popup's title row holds Undock then Close; a floating panel window's Close has no Undock beside it + let undock: Vec = labelled("Undock").collect(); + labelled("Close").find(|close| undock.iter().any(|undock| undock.right() <= close.left() && undock.y_range().contains(close.center().y))) } /// The title of the popup open on the panel named `name`: that name in capitals, level with the popup's Close button @@ -184,7 +192,7 @@ fn dragging_the_title_onto_a_tab_strip_docks_the_panel_there() { let title = popup_title(&harness, "Log"); // The popup covers the Properties strip and stays put while dragged: drop on the Texture Sets strip above it - let texture_sets_tab = harness.get_by_label("Texture Sets").rect(); + let texture_sets_tab = harness.get_by_role_and_label(egui::Role::Tab, "Texture Sets").rect(); assert!(texture_sets_tab.bottom() < title.top(), "the Texture Sets strip {texture_sets_tab:?} is under the popup at {title:?}"); drag(&mut harness, title.center(), texture_sets_tab.center()); diff --git a/crates/ui-egui/tests/it/reference_order.rs b/crates/ui-egui/tests/it/reference_order.rs index aa2b0c09..36de6ad1 100644 --- a/crates/ui-egui/tests/it/reference_order.rs +++ b/crates/ui-egui/tests/it/reference_order.rs @@ -8,7 +8,10 @@ use texturecraft_engine::Session; use texturecraft_ui_egui::{TextureCraftApp, menus}; fn harness(session: Session) -> Harness<'static, TextureCraftApp> { - let mut harness = Harness::builder().with_size(egui::vec2(1600.0, 960.0)).with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|cc| TextureCraftApp::new(cc, session)); + let mut harness = Harness::builder() + .with_size(egui::vec2(1600.0, 960.0)) + .with_context_setup(texturecraft_ui_egui::framework::install_headless) + .build_eframe(|cc| TextureCraftApp::new(cc, session)); harness.state_mut().ui.prefs.language = "en".into(); harness.run_steps(4); harness diff --git a/crates/ui-egui/tests/it/rename_anchor.rs b/crates/ui-egui/tests/it/rename_anchor.rs index f66003fc..37f5d9ff 100644 --- a/crates/ui-egui/tests/it/rename_anchor.rs +++ b/crates/ui-egui/tests/it/rename_anchor.rs @@ -22,7 +22,10 @@ fn id(v: &Value, key: &str) -> u64 { } fn harness_for(session: Session) -> Harness<'static, TextureCraftApp> { - let mut h = Harness::builder().with_size(egui::vec2(1600.0, 1400.0)).with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|cc| TextureCraftApp::new(cc, session)); + let mut h = Harness::builder() + .with_size(egui::vec2(1600.0, 1400.0)) + .with_context_setup(texturecraft_ui_egui::framework::install_headless) + .build_eframe(|cc| TextureCraftApp::new(cc, session)); // English, so a first-run locale does not change the queried labels h.state_mut().ui.prefs.language = "en".into(); diff --git a/crates/ui-egui/tests/it/reset_ui.rs b/crates/ui-egui/tests/it/reset_ui.rs index 314f8dbd..445993f4 100644 --- a/crates/ui-egui/tests/it/reset_ui.rs +++ b/crates/ui-egui/tests/it/reset_ui.rs @@ -10,7 +10,10 @@ use texturecraft_ui_egui::state::{Mode, ViewLayout}; /// An app with the Assets panel closed, a changed view split, zoom, wireframe and mode. fn changed_app() -> Harness<'static, TextureCraftApp> { let session = texturecraft_engine::sample_session(256, 64).unwrap(); - let mut h = Harness::builder().with_size(egui::vec2(1600.0, 960.0)).with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|cc| TextureCraftApp::new(cc, session)); + let mut h = Harness::builder() + .with_size(egui::vec2(1600.0, 960.0)) + .with_context_setup(texturecraft_ui_egui::framework::install_headless) + .build_eframe(|cc| TextureCraftApp::new(cc, session)); h.state_mut().ui.prefs.language = "en".into(); h.run_steps(4); let ui = &mut h.state_mut().ui; diff --git a/crates/ui-egui/tests/it/settings_window.rs b/crates/ui-egui/tests/it/settings_window.rs index baaa47fd..df1b1d06 100644 --- a/crates/ui-egui/tests/it/settings_window.rs +++ b/crates/ui-egui/tests/it/settings_window.rs @@ -12,7 +12,10 @@ use texturecraft_ui_egui::{TextureCraftApp, menus}; use crate::memory_storage::MemoryStorage; fn harness(session: Session) -> Harness<'static, TextureCraftApp> { - let mut h = Harness::builder().with_size(egui::vec2(1600.0, 960.0)).with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|cc| TextureCraftApp::new(cc, session)); + let mut h = Harness::builder() + .with_size(egui::vec2(1600.0, 960.0)) + .with_context_setup(texturecraft_ui_egui::framework::install_headless) + .build_eframe(|cc| TextureCraftApp::new(cc, session)); // The exact-text checks need English, whatever the OS language is h.state_mut().ui.prefs.language = "en".into(); diff --git a/crates/ui-egui/tests/it/shelf_click.rs b/crates/ui-egui/tests/it/shelf_click.rs index 729e491f..b5b6b497 100644 --- a/crates/ui-egui/tests/it/shelf_click.rs +++ b/crates/ui-egui/tests/it/shelf_click.rs @@ -12,7 +12,10 @@ const SMART_TYPE: usize = 1; /// The sample project with the shelf on type `tab`, filtered to `label` fn shelf(tab: usize, label: &str) -> Harness<'static, TextureCraftApp> { let session = texturecraft_engine::sample_session(256, 64).unwrap(); - let mut harness = Harness::builder().with_size(egui::vec2(1920.0, 1032.0)).with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|cc| TextureCraftApp::new(cc, session)); + let mut harness = Harness::builder() + .with_size(egui::vec2(1920.0, 1032.0)) + .with_context_setup(texturecraft_ui_egui::framework::install_headless) + .build_eframe(|cc| TextureCraftApp::new(cc, session)); harness.state_mut().ui.shelf_tab = tab; harness.state_mut().ui.shelf_filter = label.to_lowercase(); harness.run_steps(4); diff --git a/crates/ui-egui/tests/it/shelf_drop.rs b/crates/ui-egui/tests/it/shelf_drop.rs index 9052782b..7ad7b187 100644 --- a/crates/ui-egui/tests/it/shelf_drop.rs +++ b/crates/ui-egui/tests/it/shelf_drop.rs @@ -19,7 +19,10 @@ const MENU_REACH: f32 = 60.0; /// The sample project (Ball = set 0, Base = set 1) with the Ball selected, at 1600 x 960 fn sample_app() -> Harness<'static, TextureCraftApp> { let session = texturecraft_engine::sample_session(256, 64).unwrap(); - let mut harness = Harness::builder().with_size(egui::vec2(1600.0, 960.0)).with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|cc| TextureCraftApp::new(cc, session)); + let mut harness = Harness::builder() + .with_size(egui::vec2(1600.0, 960.0)) + .with_context_setup(texturecraft_ui_egui::framework::install_headless) + .build_eframe(|cc| TextureCraftApp::new(cc, session)); harness.run_steps(4); assert_eq!(harness.state().session.ts(), 0); harness @@ -291,7 +294,11 @@ fn image_drop_menu_snapshots() { std::fs::create_dir_all(&directory).unwrap(); let session = texturecraft_engine::sample_session(256, 64).unwrap(); - let mut harness = Harness::builder().with_size(egui::vec2(1600.0, 960.0)).wgpu().with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|context| TextureCraftApp::new(context, session)); + let mut harness = Harness::builder() + .with_size(egui::vec2(1600.0, 960.0)) + .wgpu() + .with_context_setup(texturecraft_ui_egui::framework::install_headless) + .build_eframe(|context| TextureCraftApp::new(context, session)); harness.state_mut().ui.prefs.language = "en".into(); harness.run_steps(6); let image = import_white_image(&mut harness); diff --git a/crates/ui-egui/tests/it/shelf_hover_preview.rs b/crates/ui-egui/tests/it/shelf_hover_preview.rs index f63d84e0..c2809684 100644 --- a/crates/ui-egui/tests/it/shelf_hover_preview.rs +++ b/crates/ui-egui/tests/it/shelf_hover_preview.rs @@ -27,7 +27,8 @@ fn materials_shelf(step_seconds: f32, pixels_per_point: f32) -> (Harness<'static .with_size(egui::vec2(1600.0, 960.0)) .with_step_dt(step_seconds) .with_pixels_per_point(pixels_per_point) - .with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|cc| TextureCraftApp::new(cc, session)); + .with_context_setup(texturecraft_ui_egui::framework::install_headless) + .build_eframe(|cc| TextureCraftApp::new(cc, session)); harness.state_mut().ui.shelf_tab = MATERIALS_TAB; harness.run_steps(4); diff --git a/crates/ui-egui/tests/it/shelf_panel.rs b/crates/ui-egui/tests/it/shelf_panel.rs index 084fe69b..f576fb7f 100644 --- a/crates/ui-egui/tests/it/shelf_panel.rs +++ b/crates/ui-egui/tests/it/shelf_panel.rs @@ -27,7 +27,10 @@ const REFERENCE_COLUMNS: usize = 4; /// The sample project with the shelf on the Materials type fn shelf(size: egui::Vec2) -> Harness<'static, TextureCraftApp> { let session = texturecraft_engine::sample_session(256, 64).unwrap(); - let mut harness = Harness::builder().with_size(size).with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|cc| TextureCraftApp::new(cc, session)); + let mut harness = Harness::builder() + .with_size(size) + .with_context_setup(texturecraft_ui_egui::framework::install_headless) + .build_eframe(|cc| TextureCraftApp::new(cc, session)); harness.state_mut().ui.shelf_tab = MATERIALS_TYPE; harness.run_steps(4); harness diff --git a/crates/ui-egui/tests/it/shift_lines_2d.rs b/crates/ui-egui/tests/it/shift_lines_2d.rs index decf8629..a86ce476 100644 --- a/crates/ui-egui/tests/it/shift_lines_2d.rs +++ b/crates/ui-egui/tests/it/shift_lines_2d.rs @@ -30,7 +30,10 @@ const BESIDE_LINE_IN_RADII: f32 = 3.0; /// The sample project with only the 2D view, at 1600 x 960 fn uv_view_app() -> Harness<'static, TextureCraftApp> { let session = texturecraft_engine::sample_session(256, 64).unwrap(); - let mut harness = Harness::builder().with_size(egui::vec2(1600.0, 960.0)).with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|cc| TextureCraftApp::new(cc, session)); + let mut harness = Harness::builder() + .with_size(egui::vec2(1600.0, 960.0)) + .with_context_setup(texturecraft_ui_egui::framework::install_headless) + .build_eframe(|cc| TextureCraftApp::new(cc, session)); harness.state_mut().ui.layout = ViewLayout::Only2D; harness.run_steps(4); harness @@ -249,11 +252,16 @@ fn shift_line_snapshots() { let output_dir = std::path::PathBuf::from(std::env::var_os("TC_UI_SNAPSHOTS").expect("set TC_UI_SNAPSHOTS to the output directory")); 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().with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|context| { - let adapter = &context.wgpu_render_state.as_ref().expect("wgpu render state").adapter; - eprintln!("Shift-line snapshot adapter: {:?}", adapter.get_info()); - TextureCraftApp::new(context, session) - }); + let mut harness = Harness::builder() + .with_size(egui::vec2(1600.0, 960.0)) + .with_pixels_per_point(1.0) + .wgpu() + .with_context_setup(texturecraft_ui_egui::framework::install_headless) + .build_eframe(|context| { + let adapter = &context.wgpu_render_state.as_ref().expect("wgpu render state").adapter; + eprintln!("Shift-line snapshot adapter: {:?}", adapter.get_info()); + TextureCraftApp::new(context, session) + }); harness.state_mut().ui.layout = ViewLayout::Only2D; harness.run_steps(4); click(&mut harness, FIRST_CLICK, false); diff --git a/crates/ui-egui/tests/it/shift_lines_3d.rs b/crates/ui-egui/tests/it/shift_lines_3d.rs index 1e91c42e..0f437127 100644 --- a/crates/ui-egui/tests/it/shift_lines_3d.rs +++ b/crates/ui-egui/tests/it/shift_lines_3d.rs @@ -22,7 +22,10 @@ const SEARCH_REACH: f32 = 300.0; /// The sample project with only the 3D view and the Paint tool fn view_3d_app() -> Harness<'static, TextureCraftApp> { let session = texturecraft_engine::sample_session(256, 64).unwrap(); - let mut harness = Harness::builder().with_size(egui::vec2(1600.0, 960.0)).with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|cc| TextureCraftApp::new(cc, session)); + let mut harness = Harness::builder() + .with_size(egui::vec2(1600.0, 960.0)) + .with_context_setup(texturecraft_ui_egui::framework::install_headless) + .build_eframe(|cc| TextureCraftApp::new(cc, session)); harness.state_mut().ui.layout = ViewLayout::Only3D; harness.state_mut().session.tool.tool = Tool::Paint; harness.run_steps(4); diff --git a/crates/ui-egui/tests/it/shortcut_keys.rs b/crates/ui-egui/tests/it/shortcut_keys.rs index fe7e1b60..80aae4b3 100644 --- a/crates/ui-egui/tests/it/shortcut_keys.rs +++ b/crates/ui-egui/tests/it/shortcut_keys.rs @@ -9,7 +9,10 @@ use texturecraft_ui_egui::state::ViewLayout; fn harness() -> Harness<'static, TextureCraftApp> { let session = texturecraft_engine::sample_session(256, 64).unwrap(); - let mut h = Harness::builder().with_size(egui::vec2(1600.0, 960.0)).with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|cc| TextureCraftApp::new(cc, session)); + let mut h = Harness::builder() + .with_size(egui::vec2(1600.0, 960.0)) + .with_context_setup(texturecraft_ui_egui::framework::install_headless) + .build_eframe(|cc| TextureCraftApp::new(cc, session)); h.run_steps(4); h } diff --git a/crates/ui-egui/tests/it/shortcut_list.rs b/crates/ui-egui/tests/it/shortcut_list.rs index d0091b4a..88a92296 100644 --- a/crates/ui-egui/tests/it/shortcut_list.rs +++ b/crates/ui-egui/tests/it/shortcut_list.rs @@ -9,7 +9,10 @@ use texturecraft_ui_egui::{TextureCraftApp, menus}; fn harness() -> Harness<'static, TextureCraftApp> { let session = texturecraft_engine::sample_session(256, 64).unwrap(); - let mut h = Harness::builder().with_size(egui::vec2(1600.0, 960.0)).with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|cc| TextureCraftApp::new(cc, session)); + let mut h = Harness::builder() + .with_size(egui::vec2(1600.0, 960.0)) + .with_context_setup(texturecraft_ui_egui::framework::install_headless) + .build_eframe(|cc| TextureCraftApp::new(cc, session)); h.state_mut().ui.prefs.language = "en".into(); h.run_steps(4); h diff --git a/crates/ui-egui/tests/it/side_panels.rs b/crates/ui-egui/tests/it/side_panels.rs index 9be1795c..37c901c0 100644 --- a/crates/ui-egui/tests/it/side_panels.rs +++ b/crates/ui-egui/tests/it/side_panels.rs @@ -24,7 +24,10 @@ const TOOLTIP_FRAMES: usize = 30; fn app() -> Harness<'static, TextureCraftApp> { let session = texturecraft_engine::sample_session(256, 64).unwrap(); - let mut harness = Harness::builder().with_size(WINDOW_SIZE).with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|cc| TextureCraftApp::new(cc, session)); + let mut harness = Harness::builder() + .with_size(WINDOW_SIZE) + .with_context_setup(texturecraft_ui_egui::framework::install_headless) + .build_eframe(|cc| TextureCraftApp::new(cc, session)); harness.state_mut().ui.prefs.language = "en".into(); harness.run_steps(STARTUP_FRAMES); harness diff --git a/crates/ui-egui/tests/it/skew_paint.rs b/crates/ui-egui/tests/it/skew_paint.rs index 026fcd77..d2385106 100644 --- a/crates/ui-egui/tests/it/skew_paint.rs +++ b/crates/ui-egui/tests/it/skew_paint.rs @@ -14,7 +14,10 @@ const STROKE_END: egui::Pos2 = egui::pos2(900.0, 500.0); fn harness() -> Harness<'static, TextureCraftApp> { let mut session = texturecraft_engine::sample_session(256, 64).unwrap(); session.add_high_poly_bytes("High.obj", b"v 0 0 0\nv 1 0 0\nv 0 1 0\nf 1 2 3\n".to_vec()).unwrap(); - let mut h = Harness::builder().with_size(egui::vec2(1600.0, 1500.0)).with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|cc| TextureCraftApp::new(cc, session)); + let mut h = Harness::builder() + .with_size(egui::vec2(1600.0, 1500.0)) + .with_context_setup(texturecraft_ui_egui::framework::install_headless) + .build_eframe(|cc| TextureCraftApp::new(cc, session)); h.state_mut().ui.mode = Mode::Baking; h.state_mut().ui.layout = ViewLayout::Only2D; h.run_steps(4); diff --git a/crates/ui-egui/tests/it/smudge_channels.rs b/crates/ui-egui/tests/it/smudge_channels.rs index 9aca6360..024377d6 100644 --- a/crates/ui-egui/tests/it/smudge_channels.rs +++ b/crates/ui-egui/tests/it/smudge_channels.rs @@ -12,7 +12,10 @@ use texturecraft_ui_egui::state::PropsTab; fn harness() -> Harness<'static, TextureCraftApp> { let session = Session::new_project("t", primitives::sphere(1.0, 48, 24), "builtin:sphere", None, 256).unwrap(); - let mut harness = Harness::builder().with_size(egui::vec2(1600.0, 960.0)).with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|context| TextureCraftApp::new(context, session)); + let mut harness = Harness::builder() + .with_size(egui::vec2(1600.0, 960.0)) + .with_context_setup(texturecraft_ui_egui::framework::install_headless) + .build_eframe(|context| TextureCraftApp::new(context, session)); harness.run_steps(4); run(&mut harness, "tool.smudge", Value::Null); harness diff --git a/crates/ui-egui/tests/it/snapped_lines.rs b/crates/ui-egui/tests/it/snapped_lines.rs index 3854b1a2..1813f3b8 100644 --- a/crates/ui-egui/tests/it/snapped_lines.rs +++ b/crates/ui-egui/tests/it/snapped_lines.rs @@ -27,7 +27,10 @@ const MAX_DIFFERENCE: f32 = 0.01; fn app(layout: ViewLayout) -> Harness<'static, TextureCraftApp> { let session = texturecraft_engine::sample_session(256, 64).unwrap(); - let mut harness = Harness::builder().with_size(egui::vec2(1600.0, 960.0)).with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|cc| TextureCraftApp::new(cc, session)); + let mut harness = Harness::builder() + .with_size(egui::vec2(1600.0, 960.0)) + .with_context_setup(texturecraft_ui_egui::framework::install_headless) + .build_eframe(|cc| TextureCraftApp::new(cc, session)); harness.state_mut().ui.layout = layout; harness.run_steps(4); harness diff --git a/crates/ui-egui/tests/it/source_picker.rs b/crates/ui-egui/tests/it/source_picker.rs index 54076e79..705d897c 100644 --- a/crates/ui-egui/tests/it/source_picker.rs +++ b/crates/ui-egui/tests/it/source_picker.rs @@ -32,7 +32,10 @@ fn app_with_fill(prepare: impl FnOnce(&mut texturecraft_engine::Session, LayerId let added = texturecraft_engine::execute(&mut session, "layer.add.fill", &json!({})).unwrap(); let layer = LayerId(added["layer"].as_u64().unwrap()); prepare(&mut session, layer); - let mut harness = Harness::builder().with_size(WINDOW_SIZE).with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|cc| TextureCraftApp::new(cc, session)); + let mut harness = Harness::builder() + .with_size(WINDOW_SIZE) + .with_context_setup(texturecraft_ui_egui::framework::install_headless) + .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(); @@ -225,7 +228,12 @@ fn near_the_windows_bottom_the_picker_opens_above_its_slot_at_full_size() { fn picker_above_its_slot_snapshot() { let mut session = texturecraft_engine::sample_session(TEXTURE_RESOLUTION, BAKE_RESOLUTION).unwrap(); texturecraft_engine::execute(&mut session, "layer.add.fill", &json!({})).unwrap(); - let mut harness = Harness::builder().with_size(SNAPSHOT_WINDOW_SIZE).with_pixels_per_point(2.0).wgpu().with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|cc| TextureCraftApp::new(cc, session)); + let mut harness = Harness::builder() + .with_size(SNAPSHOT_WINDOW_SIZE) + .with_pixels_per_point(2.0) + .wgpu() + .with_context_setup(texturecraft_ui_egui::framework::install_headless) + .build_eframe(|cc| TextureCraftApp::new(cc, session)); harness.state_mut().ui.prefs.language = "en".into(); harness.run_steps(STARTUP_FRAMES); click_widget(&mut harness, Role::Tab, "Material"); diff --git a/crates/ui-egui/tests/it/split_divider.rs b/crates/ui-egui/tests/it/split_divider.rs index cf75c2a9..10b1c372 100644 --- a/crates/ui-egui/tests/it/split_divider.rs +++ b/crates/ui-egui/tests/it/split_divider.rs @@ -1,12 +1,10 @@ //! The divider between the 3D and 2D views in the split layout resizes them and keeps the pointer from the views -use egui::{Event, Modifiers, PointerButton, Pos2, Role, pos2}; +use egui::{Event, Modifiers, PointerButton, Pos2, pos2}; use egui_kittest::Harness; -use egui_kittest::kittest::{NodeT, Queryable}; use texturecraft_engine::core::Channel; use texturecraft_ui_egui::TextureCraftApp; -use texturecraft_ui_egui::state::UiState; -use texturecraft_ui_egui::theme::GUTTER; +use texturecraft_ui_egui::state::{UiState, ViewLayout}; use texturecraft_ui_egui::ui_state_store::UiStateStore; /// Narrowest a split view may get, as in `viewport.rs` @@ -38,7 +36,10 @@ impl eframe::Storage for MemoryStorage { /// The sample project in the default split layout at 1600 x 960 fn split_app() -> Harness<'static, TextureCraftApp> { let session = texturecraft_engine::sample_session(256, 64).unwrap(); - let mut harness = Harness::builder().with_size(egui::vec2(1600.0, 960.0)).with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|cc| TextureCraftApp::new(cc, session)); + let mut harness = Harness::builder() + .with_size(egui::vec2(1600.0, 960.0)) + .with_context_setup(texturecraft_ui_egui::framework::install_headless) + .build_eframe(|cc| TextureCraftApp::new(cc, session)); // The Layers tab is found by its English name, whatever the OS language is harness.state_mut().ui.prefs.language = "en".into(); @@ -62,15 +63,15 @@ fn drag(harness: &mut Harness<'_, TextureCraftApp>, button: PointerButton, from: harness.run_steps(3); } -/// The views' right edge: a gutter left of the right column, whose Layers header starts at the column's left edge -fn views_right(harness: &Harness<'_, TextureCraftApp>) -> f32 { - let column_left = harness - .get_all_by_role(Role::Tab) - .filter(|tab| tab.accesskit_node().label().is_some_and(|label| label.starts_with("Layers"))) - .map(|tab| tab.rect().left()) - .next() - .expect("the right column's Layers header"); - column_left - f32::from(GUTTER) +/// The views' right edge: where the 3D view ends when it is the only view, filling the views' area +fn views_right(harness: &mut Harness<'_, TextureCraftApp>) -> f32 { + let layout = harness.state().ui.layout; + harness.state_mut().ui.layout = ViewLayout::Only3D; + harness.run_steps(2); + let right = harness.state().viewport_rect.right(); + harness.state_mut().ui.layout = layout; + harness.run_steps(2); + right } /// The divider's x position: the 3D view ends 1 point left of it @@ -127,7 +128,7 @@ fn dragging_the_divider_resizes_the_views_within_their_minimum_width() { let mut harness = split_app(); let views_left = harness.state().viewport_rect.left(); let start_x = divider_x(&harness); - let views_right = views_right(&harness); + let views_right = views_right(&mut harness); let views_width = views_right - views_left; let y = harness.state().viewport_rect.center().y; assert_eq!(harness.state().ui.split_ratio, 0.5); @@ -224,7 +225,7 @@ fn dragging_the_divider_keeps_the_uv_texture_size_and_offset_on_screen() { harness.run_steps(2); let views_left = harness.state().viewport_rect.left(); - let views_right = views_right(&harness); + let views_right = views_right(&mut harness); let y = harness.state().viewport_rect.center().y; let before = uv_texture_on_screen(&harness, views_right); diff --git a/crates/ui-egui/tests/it/stencil.rs b/crates/ui-egui/tests/it/stencil.rs index 7d498465..8ec6b680 100644 --- a/crates/ui-egui/tests/it/stencil.rs +++ b/crates/ui-egui/tests/it/stencil.rs @@ -18,7 +18,10 @@ fn projection_app() -> (Harness<'static, TextureCraftApp>, String) { image::RgbaImage::from_pixel(4, 4, image::Rgba([255, 255, 255, 255])).write_to(&mut std::io::Cursor::new(&mut png), image::ImageFormat::Png).unwrap(); let name = session.import_resource_bytes("logo.png", png).unwrap(); session.tool.tool = Tool::Projection; - let mut harness = Harness::builder().with_size(egui::vec2(1600.0, 960.0)).with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|cc| TextureCraftApp::new(cc, session)); + let mut harness = Harness::builder() + .with_size(egui::vec2(1600.0, 960.0)) + .with_context_setup(texturecraft_ui_egui::framework::install_headless) + .build_eframe(|cc| TextureCraftApp::new(cc, session)); harness.state_mut().ui.prefs.language = "en".into(); harness.run_steps(4); (harness, name) diff --git a/crates/ui-egui/tests/it/symmetry.rs b/crates/ui-egui/tests/it/symmetry.rs index be2b2172..091ab2ca 100644 --- a/crates/ui-egui/tests/it/symmetry.rs +++ b/crates/ui-egui/tests/it/symmetry.rs @@ -27,7 +27,12 @@ const VIEW_CORNER_INSET: f32 = 40.0; fn app_harness() -> Harness<'static, TextureCraftApp> { let session = texturecraft_engine::sample_session(1024, 256).unwrap(); - let mut harness = Harness::builder().with_size(WINDOW_SIZE).with_pixels_per_point(1.0).wgpu().with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|cc| TextureCraftApp::new(cc, session)); + let mut harness = Harness::builder() + .with_size(WINDOW_SIZE) + .with_pixels_per_point(1.0) + .wgpu() + .with_context_setup(texturecraft_ui_egui::framework::install_headless) + .build_eframe(|cc| TextureCraftApp::new(cc, session)); harness.state_mut().session.tool.tool = Tool::Paint; harness.run_steps(4); harness diff --git a/crates/ui-egui/tests/it/symmetry_2d.rs b/crates/ui-egui/tests/it/symmetry_2d.rs index 259dbe32..8c42935a 100644 --- a/crates/ui-egui/tests/it/symmetry_2d.rs +++ b/crates/ui-egui/tests/it/symmetry_2d.rs @@ -13,7 +13,10 @@ const CLICK: Pos2 = pos2(700.0, 420.0); /// The sample project with only the 2D view, at 1600 x 960 fn uv_view_app() -> Harness<'static, TextureCraftApp> { let session = texturecraft_engine::sample_session(256, 64).unwrap(); - let mut harness = Harness::builder().with_size(egui::vec2(1600.0, 960.0)).with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|cc| TextureCraftApp::new(cc, session)); + let mut harness = Harness::builder() + .with_size(egui::vec2(1600.0, 960.0)) + .with_context_setup(texturecraft_ui_egui::framework::install_headless) + .build_eframe(|cc| TextureCraftApp::new(cc, session)); harness.state_mut().ui.layout = ViewLayout::Only2D; harness.run_steps(4); harness diff --git a/crates/ui-egui/tests/it/template_invert.rs b/crates/ui-egui/tests/it/template_invert.rs index aa0b46ef..7819ddae 100644 --- a/crates/ui-egui/tests/it/template_invert.rs +++ b/crates/ui-egui/tests/it/template_invert.rs @@ -15,7 +15,10 @@ use library::Library; fn harness() -> (Harness<'static, TextureCraftApp>, Library) { let session = texturecraft_engine::sample_session(256, 64).unwrap(); - let mut h = Harness::builder().with_size(egui::vec2(1600.0, 960.0)).with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|cc| TextureCraftApp::new(cc, session)); + let mut h = Harness::builder() + .with_size(egui::vec2(1600.0, 960.0)) + .with_context_setup(texturecraft_ui_egui::framework::install_headless) + .build_eframe(|cc| TextureCraftApp::new(cc, session)); h.state_mut().ui.prefs.language = "en".into(); // The user's template library is a folder; use a temporary one, not the real one diff --git a/crates/ui-egui/tests/it/templates_681.rs b/crates/ui-egui/tests/it/templates_681.rs index d30578b5..bccfbe62 100644 --- a/crates/ui-egui/tests/it/templates_681.rs +++ b/crates/ui-egui/tests/it/templates_681.rs @@ -13,7 +13,10 @@ use super::temp_dir::TempDir; fn app() -> Harness<'static, TextureCraftApp> { let session = texturecraft_engine::sample_session(128, 64).unwrap(); - let mut h = Harness::builder().with_size(egui::vec2(1600.0, 1200.0)).with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|cc| TextureCraftApp::new(cc, session)); + let mut h = Harness::builder() + .with_size(egui::vec2(1600.0, 1200.0)) + .with_context_setup(texturecraft_ui_egui::framework::install_headless) + .build_eframe(|cc| TextureCraftApp::new(cc, session)); h.state_mut().ui.prefs.language = "en".into(); h.state_mut().session.templates.dir = None; h.run_steps(4); diff --git a/crates/ui-egui/tests/it/tile_generator_panel.rs b/crates/ui-egui/tests/it/tile_generator_panel.rs index 585a4343..993f85ef 100644 --- a/crates/ui-egui/tests/it/tile_generator_panel.rs +++ b/crates/ui-egui/tests/it/tile_generator_panel.rs @@ -24,7 +24,8 @@ fn harness(render: bool) -> (Harness<'static, TextureCraftApp>, LayerId) { session.update(); let builder = Harness::builder().with_size(egui::vec2(1600.0, 2400.0)); let builder = if render { builder.wgpu() } else { builder }; - let mut harness = builder.with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|context| TextureCraftApp::new(context, session)); + let mut harness = + builder.with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|context| TextureCraftApp::new(context, session)); harness.state_mut().ui.prefs.language = "en".into(); harness.state_mut().ui.dock.close(Panel::Layers); harness.state_mut().ui.dock.close(Panel::TextureSetSettings); @@ -137,7 +138,10 @@ fn the_slot_names_the_anchor_in_a_mask_it_reads() { execute(&mut session, "mask.add.black", &json!({})).unwrap(); execute(&mut session, "effect.add.fill", &json!({"anchor": anchor})).unwrap(); session.update(); - let mut harness = Harness::builder().with_size(egui::vec2(1600.0, 2400.0)).with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|context| TextureCraftApp::new(context, session)); + let mut harness = Harness::builder() + .with_size(egui::vec2(1600.0, 2400.0)) + .with_context_setup(texturecraft_ui_egui::framework::install_headless) + .build_eframe(|context| TextureCraftApp::new(context, session)); harness.state_mut().ui.prefs.language = "en".into(); harness.state_mut().ui.dock.focus(Panel::Properties); harness.run_steps(6); diff --git a/crates/ui-egui/tests/it/tool_availability.rs b/crates/ui-egui/tests/it/tool_availability.rs index fe47c7f8..78cc70d2 100644 --- a/crates/ui-egui/tests/it/tool_availability.rs +++ b/crates/ui-egui/tests/it/tool_availability.rs @@ -24,7 +24,10 @@ fn select_nothing(session: &mut Session) { fn app_harness() -> Harness<'static, TextureCraftApp> { let session = texturecraft_engine::sample_session(256, 64).unwrap(); - let mut harness = Harness::builder().with_size(egui::vec2(1600.0, 960.0)).with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|context| TextureCraftApp::new(context, session)); + let mut harness = Harness::builder() + .with_size(egui::vec2(1600.0, 960.0)) + .with_context_setup(texturecraft_ui_egui::framework::install_headless) + .build_eframe(|context| TextureCraftApp::new(context, session)); harness.run_steps(4); harness } @@ -68,7 +71,7 @@ fn a_fill_layer_greys_the_paint_tools_and_shows_its_own_properties() { assert!(shelf_button_disabled(&harness, "Polygon fill (4)")); assert!(!shelf_button_selected(&harness, "Polygon fill (4)"), "the equipped tool doesn't show as selected while greyed"); assert!(!shelf_button_disabled(&harness, "Geometry mask (8)")); - assert!(shows_text(&harness, "PROPERTIES - FILL"), "a fill layer shows its fill whatever the tool"); + assert!(shows_text(&harness, "Properties - Fill"), "a fill layer shows its fill whatever the tool"); assert!(!shows_text(&harness, "Size"), "a tool that can't act leaves the top bar"); } @@ -138,7 +141,10 @@ fn a_tool_that_cant_act_ignores_the_view() { fn bake_painting_turns_on_the_shelf_paint_tool() { let mut session = texturecraft_engine::sample_session(256, 64).unwrap(); session.add_high_poly_bytes("High.obj", b"v 0 0 0\nv 1 0 0\nv 0 1 0\nf 1 2 3\n".to_vec()).unwrap(); - let mut harness = Harness::builder().with_size(egui::vec2(1600.0, 960.0)).with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|context| TextureCraftApp::new(context, session)); + let mut harness = Harness::builder() + .with_size(egui::vec2(1600.0, 960.0)) + .with_context_setup(texturecraft_ui_egui::framework::install_headless) + .build_eframe(|context| TextureCraftApp::new(context, session)); harness.state_mut().ui.mode = Mode::Baking; harness.run_steps(4); assert!(shelf_button_disabled(&harness, "Paint (1)"), "nothing is being painted yet"); @@ -188,7 +194,11 @@ fn tool_availability_snapshots() { std::fs::create_dir_all(&directory).unwrap(); let session = texturecraft_engine::sample_session(256, 64).unwrap(); - let mut harness = Harness::builder().with_size(egui::vec2(1600.0, 960.0)).wgpu().with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|context| TextureCraftApp::new(context, session)); + let mut harness = Harness::builder() + .with_size(egui::vec2(1600.0, 960.0)) + .wgpu() + .with_context_setup(texturecraft_ui_egui::framework::install_headless) + .build_eframe(|context| TextureCraftApp::new(context, session)); let save = |harness: &mut Harness<'_, TextureCraftApp>, name: &str| { for (brightness, suffix) in [(Brightness::MediumDark, "medium"), (Brightness::Dark, "dark"), (Brightness::Light, "light")] { harness.state_mut().ui.prefs.brightness = brightness; diff --git a/crates/ui-egui/tests/it/tool_settings_saved.rs b/crates/ui-egui/tests/it/tool_settings_saved.rs index 94f0dc05..9ac553d3 100644 --- a/crates/ui-egui/tests/it/tool_settings_saved.rs +++ b/crates/ui-egui/tests/it/tool_settings_saved.rs @@ -10,7 +10,10 @@ use memory_storage::MemoryStorage; #[test] fn saving_the_app_stores_the_current_brush_and_tool_settings() { let session = texturecraft_engine::sample_session(256, 64).unwrap(); - let mut harness = Harness::builder().with_size(egui::vec2(1600.0, 960.0)).with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|context| TextureCraftApp::new(context, session)); + let mut harness = Harness::builder() + .with_size(egui::vec2(1600.0, 960.0)) + .with_context_setup(texturecraft_ui_egui::framework::install_headless) + .build_eframe(|context| TextureCraftApp::new(context, session)); harness.run_steps(2); let tool = &mut harness.state_mut().session.tool; tool.brush.size = 0.37; diff --git a/crates/ui-egui/tests/it/toolbar.rs b/crates/ui-egui/tests/it/toolbar.rs index b208b468..c9271888 100644 --- a/crates/ui-egui/tests/it/toolbar.rs +++ b/crates/ui-egui/tests/it/toolbar.rs @@ -197,7 +197,11 @@ fn toolbar_window_snapshots() { std::fs::create_dir_all(&directory).unwrap(); let session = texturecraft_engine::sample_session(256, 64).unwrap(); - let mut harness = Harness::builder().with_size(egui::vec2(1600.0, 960.0)).wgpu().with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|context| TextureCraftApp::new(context, session)); + let mut harness = Harness::builder() + .with_size(egui::vec2(1600.0, 960.0)) + .wgpu() + .with_context_setup(texturecraft_ui_egui::framework::install_headless) + .build_eframe(|context| TextureCraftApp::new(context, session)); harness.state_mut().session.tool.tool = Tool::Path; harness.state_mut().session.tool.brush.lazy = 20.0; for (width, scale) in [(1600.0, 1.0), (960.0, 1.0), (960.0, 1.5)] { diff --git a/crates/ui-egui/tests/it/user_smart_mask.rs b/crates/ui-egui/tests/it/user_smart_mask.rs index 2d208f47..7547e74c 100644 --- a/crates/ui-egui/tests/it/user_smart_mask.rs +++ b/crates/ui-egui/tests/it/user_smart_mask.rs @@ -15,7 +15,10 @@ const SMART_MATERIALS_TYPE: usize = 1; fn harness(prepare: impl FnOnce(&mut texturecraft_engine::Session)) -> Harness<'static, TextureCraftApp> { let mut session = texturecraft_engine::sample_session(256, 64).unwrap(); prepare(&mut session); - let mut harness = Harness::builder().with_size(WINDOW).with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|cc| TextureCraftApp::new(cc, session)); + let mut harness = Harness::builder() + .with_size(WINDOW) + .with_context_setup(texturecraft_ui_egui::framework::install_headless) + .build_eframe(|cc| TextureCraftApp::new(cc, session)); harness.run_steps(4); harness } diff --git a/crates/ui-egui/tests/it/view2d_navigation.rs b/crates/ui-egui/tests/it/view2d_navigation.rs index 3d88d9fd..fdd61c55 100644 --- a/crates/ui-egui/tests/it/view2d_navigation.rs +++ b/crates/ui-egui/tests/it/view2d_navigation.rs @@ -14,8 +14,12 @@ const WINDOW: egui::Vec2 = vec2(1280.0, 800.0); /// The app showing only the 2D view, and the rect that view fills fn app_with(session: Session) -> (Harness<'static, TextureCraftApp>, Rect) { - let mut harness = - Harness::builder().with_size(WINDOW).with_pixels_per_point(1.0).with_step_dt(1.0 / 60.0).with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|cc| TextureCraftApp::new(cc, session)); + let mut harness = Harness::builder() + .with_size(WINDOW) + .with_pixels_per_point(1.0) + .with_step_dt(1.0 / 60.0) + .with_context_setup(texturecraft_ui_egui::framework::install_headless) + .build_eframe(|cc| TextureCraftApp::new(cc, session)); harness.state_mut().session.tool.tool = texturecraft_engine::Tool::Paint; harness.state_mut().ui.layout = ViewLayout::Only3D; harness.run_steps(4); diff --git a/crates/ui-egui/tests/it/view2d_tiles.rs b/crates/ui-egui/tests/it/view2d_tiles.rs index f03f6a5f..ef3b9b50 100644 --- a/crates/ui-egui/tests/it/view2d_tiles.rs +++ b/crates/ui-egui/tests/it/view2d_tiles.rs @@ -12,7 +12,11 @@ const BUTTON: &str = "uvtile_info_menu_button"; const SETTLE_FRAMES: usize = 3; fn app_with(session: Session) -> Harness<'static, TextureCraftApp> { - let mut harness = Harness::builder().with_size(egui::vec2(1600.0, 1000.0)).with_pixels_per_point(1.0).with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|cc| TextureCraftApp::new(cc, session)); + let mut harness = Harness::builder() + .with_size(egui::vec2(1600.0, 1000.0)) + .with_pixels_per_point(1.0) + .with_context_setup(texturecraft_ui_egui::framework::install_headless) + .build_eframe(|cc| TextureCraftApp::new(cc, session)); harness.state_mut().ui.prefs.language = "en".into(); harness.state_mut().ui.layout = ViewLayout::Only3D; harness.run_steps(4); @@ -72,7 +76,10 @@ fn the_tile_info_button_sits_left_of_the_view_mode_picker_and_has_no_tooltip() { /// The app with Display Settings open from the rail fn display_settings_app() -> Harness<'static, TextureCraftApp> { let session = texturecraft_engine::sample_session(256, 64).unwrap(); - let mut harness = Harness::builder().with_size(egui::vec2(1600.0, 1400.0)).with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|cc| TextureCraftApp::new(cc, session)); + let mut harness = Harness::builder() + .with_size(egui::vec2(1600.0, 1400.0)) + .with_context_setup(texturecraft_ui_egui::framework::install_headless) + .build_eframe(|cc| TextureCraftApp::new(cc, session)); harness.state_mut().ui.prefs.language = "en".into(); harness.run_steps(4); harness diff --git a/crates/ui-egui/tests/it/view_mode_picker.rs b/crates/ui-egui/tests/it/view_mode_picker.rs index 5aace352..56619e08 100644 --- a/crates/ui-egui/tests/it/view_mode_picker.rs +++ b/crates/ui-egui/tests/it/view_mode_picker.rs @@ -8,7 +8,10 @@ use texturecraft_ui_egui::TextureCraftApp; fn harness() -> Harness<'static, TextureCraftApp> { let session = texturecraft_engine::sample_session(256, 64).unwrap(); - let mut h = Harness::builder().with_size(egui::vec2(1600.0, 960.0)).with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|cc| TextureCraftApp::new(cc, session)); + let mut h = Harness::builder() + .with_size(egui::vec2(1600.0, 960.0)) + .with_context_setup(texturecraft_ui_egui::framework::install_headless) + .build_eframe(|cc| TextureCraftApp::new(cc, session)); h.state_mut().ui.prefs.language = "en".into(); h.run_steps(4); h diff --git a/crates/ui-egui/tests/it/window_menu_684.rs b/crates/ui-egui/tests/it/window_menu_684.rs index 13922461..bed82cd3 100644 --- a/crates/ui-egui/tests/it/window_menu_684.rs +++ b/crates/ui-egui/tests/it/window_menu_684.rs @@ -15,7 +15,10 @@ use texturecraft_ui_egui::{TextureCraftApp, menus}; use super::temp_dir::TempDir; fn app_with(session: Session) -> Harness<'static, TextureCraftApp> { - let mut h = Harness::builder().with_size(egui::vec2(1600.0, 1000.0)).with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|cc| TextureCraftApp::new(cc, session)); + let mut h = Harness::builder() + .with_size(egui::vec2(1600.0, 1000.0)) + .with_context_setup(texturecraft_ui_egui::framework::install_headless) + .build_eframe(|cc| TextureCraftApp::new(cc, session)); h.state_mut().ui.prefs.language = "en".into(); h.run_steps(4); h diff --git a/crates/ui-egui/tests/list_panels.rs b/crates/ui-egui/tests/list_panels.rs index 40a04edd..872215fe 100644 --- a/crates/ui-egui/tests/list_panels.rs +++ b/crates/ui-egui/tests/list_panels.rs @@ -50,7 +50,10 @@ fn the_history_list_fills_a_tall_panel() { texturecraft_engine::execute(&mut session, "layer.rename", &json!({"layer": layer.0, "name": format!("Step {step}")})).unwrap(); } - let mut harness = Harness::builder().with_size(WINDOW_SIZE).with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|cc| TextureCraftApp::new(cc, session)); + let mut harness = Harness::builder() + .with_size(WINDOW_SIZE) + .with_context_setup(texturecraft_ui_egui::framework::install_headless) + .build_eframe(|cc| TextureCraftApp::new(cc, session)); dock_in_left_column(&mut harness, "History"); harness.run_steps(STARTUP_FRAMES); @@ -62,7 +65,10 @@ fn the_history_list_fills_a_tall_panel() { #[test] fn the_log_list_fills_a_tall_panel() { let session = texturecraft_engine::sample_session(TEXTURE_RESOLUTION, BAKE_RESOLUTION).unwrap(); - let mut harness = Harness::builder().with_size(WINDOW_SIZE).with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|cc| TextureCraftApp::new(cc, session)); + let mut harness = Harness::builder() + .with_size(WINDOW_SIZE) + .with_context_setup(texturecraft_ui_egui::framework::install_headless) + .build_eframe(|cc| TextureCraftApp::new(cc, session)); for line in 0..ROWS { harness.state_mut().session.log.push(format!("Log line {line}")); } diff --git a/crates/ui-egui/tests/project_limits.rs b/crates/ui-egui/tests/project_limits.rs index 1d26ef64..f9626b4b 100644 --- a/crates/ui-egui/tests/project_limits.rs +++ b/crates/ui-egui/tests/project_limits.rs @@ -21,8 +21,12 @@ fn resource_settings_follow_hardware_persist_and_apply_before_control_requests() storage.values.insert("ui.json".into(), serde_json::to_string(&state).unwrap()); let session = Session::new_project("Limits", geom::primitives::plane(2.0, 1), "builtin:plane", None, 128).unwrap(); let available_cores = u32::try_from(std::thread::available_parallelism().unwrap().get()).unwrap(); - let mut harness = - Harness::builder().with_size(egui::vec2(1200.0, 900.0)).with_step_dt(1.0 / 60.0).with_accessibility_check(false).with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|context| { + let mut harness = Harness::builder() + .with_size(egui::vec2(1200.0, 900.0)) + .with_step_dt(1.0 / 60.0) + .with_accessibility_check(false) + .with_context_setup(texturecraft_ui_egui::framework::install_headless) + .build_eframe(|context| { context.egui_ctx.data_mut(|data| data.insert_temp(egui::Id::unique("settings_resources"), (0.0_f64, available_cores, 16_u64 << 30))); let mut creation = eframe::CreationContext::_new_kittest(context.egui_ctx.clone()); creation.storage = Some(&storage); diff --git a/crates/ui-egui/tests/shader_panel.rs b/crates/ui-egui/tests/shader_panel.rs index 5e9dbca3..9318e2d3 100644 --- a/crates/ui-egui/tests/shader_panel.rs +++ b/crates/ui-egui/tests/shader_panel.rs @@ -17,7 +17,10 @@ const STARTUP_FRAMES: usize = 4; #[test] fn shader_settings_leave_the_height_strength_to_the_texture_set_settings() { let session = texturecraft_engine::sample_session(TEXTURE_RESOLUTION, BAKE_RESOLUTION).unwrap(); - let mut harness = Harness::builder().with_size(WINDOW_SIZE).with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|cc| TextureCraftApp::new(cc, session)); + let mut harness = Harness::builder() + .with_size(WINDOW_SIZE) + .with_context_setup(texturecraft_ui_egui::framework::install_headless) + .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(); diff --git a/crates/ui-egui/tests/ui_snapshots.rs b/crates/ui-egui/tests/ui_snapshots.rs index f8780dfe..a81298e1 100644 --- a/crates/ui-egui/tests/ui_snapshots.rs +++ b/crates/ui-egui/tests/ui_snapshots.rs @@ -59,7 +59,10 @@ fn empty_start_snapshot() { let Some(output_dir) = std::env::var_os("TC_UI_SNAPSHOTS").map(PathBuf::from) else { return }; std::fs::create_dir_all(&output_dir).unwrap(); let session = texturecraft_engine::Session::closed().unwrap(); - let mut harness = Harness::builder().with_size(egui::vec2(1600.0, 960.0)).with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|context| TextureCraftApp::new(context, session)); + let mut harness = Harness::builder() + .with_size(egui::vec2(1600.0, 960.0)) + .with_context_setup(texturecraft_ui_egui::framework::install_headless) + .build_eframe(|context| TextureCraftApp::new(context, session)); harness.state_mut().ui.prefs.language = "en".into(); save(&mut harness, &output_dir, "empty-start"); @@ -92,7 +95,11 @@ fn empty_start_snapshot() { #[ignore] fn close_releases_view_targets_and_rejects_immediate_capture() { let session = texturecraft_engine::Session::closed().unwrap(); - let mut harness = Harness::builder().with_size(egui::vec2(960.0, 640.0)).wgpu().with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|context| TextureCraftApp::new(context, session)); + let mut harness = Harness::builder() + .with_size(egui::vec2(960.0, 640.0)) + .wgpu() + .with_context_setup(texturecraft_ui_egui::framework::install_headless) + .build_eframe(|context| TextureCraftApp::new(context, session)); harness.state_mut().ui.prefs.language = "en".into(); for mesh in ["cube", "plane"] { @@ -154,8 +161,11 @@ fn brush_presets_popover_snapshot() { std::fs::create_dir_all(&output_dir).unwrap(); let session = texturecraft_engine::sample_session(128, 32).unwrap(); - let mut harness = - Harness::builder().with_size(egui::vec2(1280.0, 800.0)).with_pixels_per_point(1.0).with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|context| TextureCraftApp::new(context, session)); + let mut harness = Harness::builder() + .with_size(egui::vec2(1280.0, 800.0)) + .with_pixels_per_point(1.0) + .with_context_setup(texturecraft_ui_egui::framework::install_headless) + .build_eframe(|context| TextureCraftApp::new(context, session)); let brush = harness.state().session.tool.brush.clone(); harness.state_mut().session.brush_presets.list.clear(); harness.state_mut().ui.prefs.language = "en".into(); @@ -192,7 +202,8 @@ fn pbr_import_dialog_keeps_choices_after_error() { .with_size(egui::vec2(1280.0, 800.0)) .with_pixels_per_point(1.0) .wgpu() - .with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|context| TextureCraftApp::new(context, session)); + .with_context_setup(texturecraft_ui_egui::framework::install_headless) + .build_eframe(|context| TextureCraftApp::new(context, session)); harness.state_mut().ui.prefs.language = "en".into(); texturecraft_ui_egui::pbr_import::begin(harness.state_mut(), serde_json::json!({"path": source_dir.display().to_string()})); @@ -227,7 +238,8 @@ fn pbr_import_uses_displayed_default_after_folder_changes() { .with_size(egui::vec2(1280.0, 800.0)) .with_pixels_per_point(1.0) .wgpu() - .with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|context| TextureCraftApp::new(context, session)); + .with_context_setup(texturecraft_ui_egui::framework::install_headless) + .build_eframe(|context| TextureCraftApp::new(context, session)); texturecraft_ui_egui::pbr_import::begin(harness.state_mut(), serde_json::json!({"path": source_dir.display().to_string()})); std::fs::write(source_dir.join("tile_albedo_8k.png"), &bytes).unwrap(); @@ -261,7 +273,8 @@ fn pbr_drop_candidates_and_project_replacement() { .with_size(egui::vec2(1280.0, 800.0)) .with_pixels_per_point(1.0) .wgpu() - .with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|context| TextureCraftApp::new(context, session)); + .with_context_setup(texturecraft_ui_egui::framework::install_headless) + .build_eframe(|context| TextureCraftApp::new(context, session)); harness.input_mut().dropped_files = files.iter().cloned().map(dropped_path::handle).collect(); harness.run_steps(1); assert!(harness.state().pbr_import.is_some()); @@ -295,7 +308,8 @@ fn pbr_dialog_is_cleared_when_project_changes() { .with_size(egui::vec2(1280.0, 800.0)) .with_pixels_per_point(1.0) .wgpu() - .with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|context| TextureCraftApp::new(context, session)); + .with_context_setup(texturecraft_ui_egui::framework::install_headless) + .build_eframe(|context| TextureCraftApp::new(context, session)); texturecraft_ui_egui::pbr_import::begin(harness.state_mut(), serde_json::json!({"path": source_dir.display().to_string()})); assert!(harness.state().pbr_import.is_some()); @@ -316,7 +330,8 @@ fn rendering_mode_snapshots() { .with_size(egui::vec2(1280.0, 800.0)) .with_pixels_per_point(1.0) .wgpu() - .with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|context| TextureCraftApp::new(context, session)); + .with_context_setup(texturecraft_ui_egui::framework::install_headless) + .build_eframe(|context| TextureCraftApp::new(context, session)); harness.state_mut().ui.mode = Mode::Rendering; harness.state_mut().ui.render.max_samples = 16; eprintln!("Rendering-mode adapter: {}", harness.state().gpu.as_ref().unwrap().adapter); @@ -345,8 +360,12 @@ fn symmetry_snapshots() { std::fs::create_dir_all(&output_dir).unwrap(); let session = texturecraft_engine::sample_session(1024, 256).unwrap(); - let mut harness = - Harness::builder().with_size(egui::vec2(1600.0, 960.0)).with_pixels_per_point(1.0).wgpu().with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|cc| TextureCraftApp::new(cc, session)); + let mut harness = Harness::builder() + .with_size(egui::vec2(1600.0, 960.0)) + .with_pixels_per_point(1.0) + .wgpu() + .with_context_setup(texturecraft_ui_egui::framework::install_headless) + .build_eframe(|cc| TextureCraftApp::new(cc, session)); harness.state_mut().ui.prefs.language = "en".into(); harness.state_mut().run("tool.brush", serde_json::json!({"symmetryY": true, "symmetryOffset": [0, 0.1, 0]})).unwrap(); harness.state_mut().ui.symmetry.show_plane = true; @@ -381,8 +400,12 @@ fn window_snapshots() { std::fs::create_dir_all(&output_dir).unwrap(); let session = texturecraft_engine::sample_session(1024, 256).unwrap(); - let mut harness = - Harness::builder().with_size(egui::vec2(1600.0, 960.0)).with_pixels_per_point(1.0).wgpu().with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|cc| TextureCraftApp::new(cc, session)); + let mut harness = Harness::builder() + .with_size(egui::vec2(1600.0, 960.0)) + .with_pixels_per_point(1.0) + .wgpu() + .with_context_setup(texturecraft_ui_egui::framework::install_headless) + .build_eframe(|cc| TextureCraftApp::new(cc, session)); for (brightness, name) in [(Brightness::MediumDark, "main"), (Brightness::Dark, "brightness-dark"), (Brightness::Light, "brightness-light")] { harness.state_mut().ui.prefs.brightness = brightness; save(&mut harness, &output_dir, name); @@ -561,7 +584,8 @@ fn bake_uv_tiles_snapshot() { .with_size(egui::vec2(1600.0, 960.0)) .with_pixels_per_point(1.0) .wgpu() - .with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|context| TextureCraftApp::new(context, session)); + .with_context_setup(texturecraft_ui_egui::framework::install_headless) + .build_eframe(|context| TextureCraftApp::new(context, session)); harness.state_mut().ui.mode = Mode::Baking; save(&mut harness, &output_dir, "bake-uv-tiles"); @@ -600,8 +624,12 @@ fn smart_mask_shelf_snapshot() { std::fs::create_dir_all(&output_dir).unwrap(); let session = texturecraft_engine::Session::new_project("Mask previews", texturecraft_engine::geom::primitives::cube(2.0), "builtin:cube", None, 128).unwrap(); - let mut harness = - Harness::builder().with_size(egui::vec2(1600.0, 960.0)).with_pixels_per_point(1.0).wgpu().with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|cc| TextureCraftApp::new(cc, session)); + let mut harness = Harness::builder() + .with_size(egui::vec2(1600.0, 960.0)) + .with_pixels_per_point(1.0) + .wgpu() + .with_context_setup(texturecraft_ui_egui::framework::install_headless) + .build_eframe(|cc| TextureCraftApp::new(cc, session)); harness.state_mut().ui.shelf_tab = 2; let context = harness.ctx.clone(); let started = std::time::Instant::now(); @@ -649,11 +677,16 @@ fn smart_material_shelf_snapshot() { let session = texturecraft_engine::Session::new_project("Smart material previews", texturecraft_engine::geom::primitives::cube(2.0), "builtin:cube", None, 128) .unwrap(); - let mut harness = Harness::builder().with_size(egui::vec2(1600.0, 960.0)).with_pixels_per_point(1.0).wgpu().with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|context| { - let render_state = context.wgpu_render_state.as_ref().expect("the snapshot uses wgpu"); - eprintln!("snapshot adapter: {:?}", render_state.adapter.get_info()); - TextureCraftApp::new(context, session) - }); + let mut harness = Harness::builder() + .with_size(egui::vec2(1600.0, 960.0)) + .with_pixels_per_point(1.0) + .wgpu() + .with_context_setup(texturecraft_ui_egui::framework::install_headless) + .build_eframe(|context| { + let render_state = context.wgpu_render_state.as_ref().expect("the snapshot uses wgpu"); + eprintln!("snapshot adapter: {:?}", render_state.adapter.get_info()); + TextureCraftApp::new(context, session) + }); harness.state_mut().ui.shelf_tab = 1; let context = harness.ctx.clone(); let started = std::time::Instant::now(); @@ -705,8 +738,12 @@ fn nested_layers_snapshot() { for _ in 0..6 { execute(&mut session, "layer.group", &Value::Null).unwrap(); } - let mut harness = - Harness::builder().with_size(egui::vec2(1600.0, 1600.0)).with_pixels_per_point(1.0).wgpu().with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|cc| TextureCraftApp::new(cc, session)); + let mut harness = Harness::builder() + .with_size(egui::vec2(1600.0, 1600.0)) + .with_pixels_per_point(1.0) + .wgpu() + .with_context_setup(texturecraft_ui_egui::framework::install_headless) + .build_eframe(|cc| TextureCraftApp::new(cc, session)); harness.run_steps(4); let workspace = harness.state().ui.dock.workspace().clone(); let mut layout = workspace.layout().clone(); @@ -749,7 +786,8 @@ fn mask_anchor_micro_detail_snapshot() { .with_size(egui::vec2(1600.0, 1200.0)) .with_pixels_per_point(1.0) .wgpu() - .with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|context| TextureCraftApp::new(context, session)); + .with_context_setup(texturecraft_ui_egui::framework::install_headless) + .build_eframe(|context| TextureCraftApp::new(context, session)); harness.state_mut().ui.dock.focus(Panel::Properties); harness.run_steps(6); harness.get_by_label("Micro detail").scroll_to_me(); @@ -765,8 +803,12 @@ fn path_tool_snapshots() { let mut session = texturecraft_engine::sample_session(256, 64).unwrap(); texturecraft_engine::execute(&mut session, "layer.add.paint", &serde_json::Value::Null).unwrap(); texturecraft_engine::execute(&mut session, "tool.path", &serde_json::json!({"uvPoints": [[0.25, 0.5], [0.5, 0.3], [0.75, 0.5]]})).unwrap(); - let mut harness = - Harness::builder().with_size(egui::vec2(1600.0, 960.0)).with_pixels_per_point(1.0).wgpu().with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|cc| TextureCraftApp::new(cc, session)); + let mut harness = Harness::builder() + .with_size(egui::vec2(1600.0, 960.0)) + .with_pixels_per_point(1.0) + .wgpu() + .with_context_setup(texturecraft_ui_egui::framework::install_headless) + .build_eframe(|cc| TextureCraftApp::new(cc, session)); harness.state_mut().ui.layout = texturecraft_ui_egui::state::ViewLayout::Only2D; harness.state_mut().session.select_path_point(1); harness.hover_at(egui::pos2(800.0, 600.0)); @@ -786,8 +828,12 @@ fn rail_window_snapshots() { 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().with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|cc| TextureCraftApp::new(cc, session)); + let mut harness = Harness::builder() + .with_size(egui::vec2(1600.0, 960.0)) + .with_pixels_per_point(1.0) + .wgpu() + .with_context_setup(texturecraft_ui_egui::framework::install_headless) + .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(); @@ -823,8 +869,12 @@ fn i18n_snapshots() { for code in ["en", "es", "ar"] { assert!(texturecraft_ui_egui::i18n::available(code), "build with migrated catalogs for {code}"); let session = texturecraft_engine::sample_session(128, 32).unwrap(); - let mut harness = - Harness::builder().with_size(egui::vec2(1600.0, 960.0)).with_pixels_per_point(1.0).wgpu().with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|cc| TextureCraftApp::new(cc, session)); + let mut harness = Harness::builder() + .with_size(egui::vec2(1600.0, 960.0)) + .with_pixels_per_point(1.0) + .wgpu() + .with_context_setup(texturecraft_ui_egui::framework::install_headless) + .build_eframe(|cc| TextureCraftApp::new(cc, session)); harness.state_mut().ui.prefs.language = code.into(); harness.state_mut().ui.windows.settings = true; save(&mut harness, &output_dir, &format!("i18n-{code}")); @@ -858,7 +908,11 @@ fn mask_fill_image_snapshot() { execute(&mut session, "mask.add.black", &json!({})).unwrap(); let effect = execute(&mut session, "effect.add.fill", &json!({"target": "mask", "value": 1.0})).unwrap()["effect"].as_u64().unwrap(); execute(&mut session, "layer.select", &json!({"layer": layer, "target": effect})).unwrap(); - let mut harness = Harness::builder().with_size(egui::vec2(1600.0, 1100.0)).wgpu().with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|context| TextureCraftApp::new(context, session)); + let mut harness = Harness::builder() + .with_size(egui::vec2(1600.0, 1100.0)) + .wgpu() + .with_context_setup(texturecraft_ui_egui::framework::install_headless) + .build_eframe(|context| TextureCraftApp::new(context, session)); harness.state_mut().ui.prefs.language = "en".into(); harness.run_steps(6); @@ -898,8 +952,12 @@ fn panel_header_snapshots() { std::fs::create_dir_all(&output_dir).unwrap(); let mut session = texturecraft_engine::sample_session(256, 64).unwrap(); execute(&mut session, "layer.add.fill", &json!({"color": [0.8, 0.3, 0.1]})).unwrap(); - let mut harness = - Harness::builder().with_size(egui::vec2(1600.0, 960.0)).with_pixels_per_point(2.0).wgpu().with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|cc| TextureCraftApp::new(cc, session)); + let mut harness = Harness::builder() + .with_size(egui::vec2(1600.0, 960.0)) + .with_pixels_per_point(2.0) + .wgpu() + .with_context_setup(texturecraft_ui_egui::framework::install_headless) + .build_eframe(|cc| TextureCraftApp::new(cc, session)); harness.state_mut().ui.prefs.language = "en".into(); for (brightness, name) in [(Brightness::MediumDark, "medium"), (Brightness::Dark, "dark"), (Brightness::Light, "light")] { harness.state_mut().ui.prefs.brightness = brightness; @@ -925,8 +983,12 @@ fn settings_pages_snapshot() { let Some(output_dir) = std::env::var_os("TC_UI_SNAPSHOTS").map(PathBuf::from) else { return }; std::fs::create_dir_all(&output_dir).unwrap(); let session = texturecraft_engine::sample_session(128, 32).unwrap(); - let mut harness = - Harness::builder().with_size(egui::vec2(1600.0, 960.0)).with_pixels_per_point(1.0).wgpu().with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|cc| TextureCraftApp::new(cc, session)); + let mut harness = Harness::builder() + .with_size(egui::vec2(1600.0, 960.0)) + .with_pixels_per_point(1.0) + .wgpu() + .with_context_setup(texturecraft_ui_egui::framework::install_headless) + .build_eframe(|cc| TextureCraftApp::new(cc, session)); harness.state_mut().ui.prefs.language = "en".into(); harness.state_mut().ui.windows.settings = true; save(&mut harness, &output_dir, "settings-general"); @@ -969,8 +1031,12 @@ fn default_layout_snapshots() { for color in [[0.2, 0.4, 0.7], [0.5, 0.5, 0.5], [0.8, 0.3, 0.1]] { execute(&mut session, "layer.add.fill", &json!({ "color": color })).unwrap(); } - let mut harness = - Harness::builder().with_size(egui::vec2(1600.0, 960.0)).with_pixels_per_point(2.0).wgpu().with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|cc| TextureCraftApp::new(cc, session)); + let mut harness = Harness::builder() + .with_size(egui::vec2(1600.0, 960.0)) + .with_pixels_per_point(2.0) + .wgpu() + .with_context_setup(texturecraft_ui_egui::framework::install_headless) + .build_eframe(|cc| TextureCraftApp::new(cc, session)); harness.state_mut().ui.prefs.language = "en".into(); for (brightness, name) in [(Brightness::MediumDark, "medium"), (Brightness::Dark, "dark"), (Brightness::Light, "light")] { harness.state_mut().ui.prefs.brightness = brightness; @@ -998,8 +1064,12 @@ fn fill_reset_snapshots() { let mut session = texturecraft_engine::sample_session(256, 64).unwrap(); let layer = execute(&mut session, "layer.add.fill", &json!({"color": [0.8, 0.3, 0.1]})).unwrap()["layer"].clone(); execute(&mut session, "layer.fill.projection", &json!({"layer": layer, "tiling": [2.0, 2.0], "filtering": "nearest"})).unwrap(); - let mut harness = - Harness::builder().with_size(egui::vec2(1600.0, 960.0)).with_pixels_per_point(2.0).wgpu().with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|cc| TextureCraftApp::new(cc, session)); + let mut harness = Harness::builder() + .with_size(egui::vec2(1600.0, 960.0)) + .with_pixels_per_point(2.0) + .wgpu() + .with_context_setup(texturecraft_ui_egui::framework::install_headless) + .build_eframe(|cc| TextureCraftApp::new(cc, session)); harness.state_mut().ui.prefs.language = "en".into(); for (brightness, name) in [(Brightness::MediumDark, "medium"), (Brightness::Dark, "dark"), (Brightness::Light, "light")] { harness.state_mut().ui.prefs.brightness = brightness; @@ -1052,8 +1122,12 @@ fn fill_properties_snapshots() { &json!({"layer": layer, "tiling": [2.0, 2.0], "rotation": 30.0, "offset": [0.25, 0.0], "wrap": "repeat", "filtering": "bilinearHq"}), ) .unwrap(); - let mut harness = - Harness::builder().with_size(egui::vec2(1600.0, 1500.0)).with_pixels_per_point(2.0).wgpu().with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|cc| TextureCraftApp::new(cc, session)); + let mut harness = Harness::builder() + .with_size(egui::vec2(1600.0, 1500.0)) + .with_pixels_per_point(2.0) + .wgpu() + .with_context_setup(texturecraft_ui_egui::framework::install_headless) + .build_eframe(|cc| TextureCraftApp::new(cc, session)); harness.state_mut().ui.prefs.language = "en".into(); for (brightness, name) in [(Brightness::MediumDark, "medium"), (Brightness::Dark, "dark"), (Brightness::Light, "light")] { harness.state_mut().ui.prefs.brightness = brightness; @@ -1183,8 +1257,12 @@ fn fill_symmetry_snapshots() { let mut session = texturecraft_engine::sample_session(256, 64).unwrap(); let layer = execute(&mut session, "layer.add.fill", &json!({"color": [0.8, 0.3, 0.1]})).unwrap()["layer"].clone(); execute(&mut session, "layer.fill.projection", &json!({"layer": layer, "projection": "planar"})).unwrap(); - let mut harness = - Harness::builder().with_size(egui::vec2(1600.0, 1500.0)).with_pixels_per_point(2.0).wgpu().with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|cc| TextureCraftApp::new(cc, session)); + let mut harness = Harness::builder() + .with_size(egui::vec2(1600.0, 1500.0)) + .with_pixels_per_point(2.0) + .wgpu() + .with_context_setup(texturecraft_ui_egui::framework::install_headless) + .build_eframe(|cc| TextureCraftApp::new(cc, session)); harness.state_mut().ui.prefs.language = "en".into(); harness.run_steps(4); harness.get_by_role_and_label(egui::Role::Tab, "Symmetry").click(); @@ -1267,8 +1345,12 @@ fn fill_color_picker_snapshots() { for swatch in ["#E58A4E", "#BEBEBE", "#3C4046", "#7A7AF5", "#B0623A"] { execute(&mut session, "swatch.add", &json!({"color": swatch})).unwrap(); } - let mut harness = - Harness::builder().with_size(egui::vec2(1600.0, 2000.0)).with_pixels_per_point(2.0).wgpu().with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|cc| TextureCraftApp::new(cc, session)); + let mut harness = Harness::builder() + .with_size(egui::vec2(1600.0, 2000.0)) + .with_pixels_per_point(2.0) + .wgpu() + .with_context_setup(texturecraft_ui_egui::framework::install_headless) + .build_eframe(|cc| TextureCraftApp::new(cc, session)); harness.state_mut().ui.prefs.language = "en".into(); harness.run_steps(4); harness.get_by_role_and_label(egui::Role::Tab, "Material").click(); @@ -1363,8 +1445,12 @@ fn fill_material_snapshots() { settings["layer"] = json!(layer); execute(&mut session, "layer.fill.set", &settings).unwrap(); } - let mut harness = - Harness::builder().with_size(egui::vec2(1600.0, 1500.0)).with_pixels_per_point(2.0).wgpu().with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|cc| TextureCraftApp::new(cc, session)); + let mut harness = Harness::builder() + .with_size(egui::vec2(1600.0, 1500.0)) + .with_pixels_per_point(2.0) + .wgpu() + .with_context_setup(texturecraft_ui_egui::framework::install_headless) + .build_eframe(|cc| TextureCraftApp::new(cc, session)); harness.state_mut().ui.prefs.language = "en".into(); harness.run_steps(4); harness.get_by_role_and_label(egui::Role::Tab, "Material").click(); @@ -1515,8 +1601,12 @@ fn eyedropper_pointer_snapshots() { for (name, color) in [("light", [0.92, 0.92, 0.9]), ("dark", [0.01, 0.01, 0.012])] { let mut session = texturecraft_engine::sample_session(256, 64).unwrap(); execute(&mut session, "layer.add.fill", &json!({"color": color})).unwrap(); - let mut harness = - Harness::builder().with_size(egui::vec2(1600.0, 960.0)).with_pixels_per_point(1.0).wgpu().with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|cc| TextureCraftApp::new(cc, session)); + let mut harness = Harness::builder() + .with_size(egui::vec2(1600.0, 960.0)) + .with_pixels_per_point(1.0) + .wgpu() + .with_context_setup(texturecraft_ui_egui::framework::install_headless) + .build_eframe(|cc| TextureCraftApp::new(cc, session)); harness.state_mut().ui.prefs.language = "en".into(); // Only the app's own pointer shows, not the test's stand-in arrow @@ -1571,8 +1661,12 @@ fn source_picker_snapshots() { let below = execute(&mut session, "layer.add.fill", &json!({})).unwrap()["layer"].clone(); execute(&mut session, "effect.add.anchor", &json!({"layer": below, "name": "Edge wear"})).unwrap(); let layer = execute(&mut session, "layer.add.fill", &json!({"color": [0.45, 0.13, 0.05]})).unwrap()["layer"].clone(); - let mut harness = - Harness::builder().with_size(egui::vec2(1600.0, 1200.0)).with_pixels_per_point(2.0).wgpu().with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|cc| TextureCraftApp::new(cc, session)); + let mut harness = Harness::builder() + .with_size(egui::vec2(1600.0, 1200.0)) + .with_pixels_per_point(2.0) + .wgpu() + .with_context_setup(texturecraft_ui_egui::framework::install_headless) + .build_eframe(|cc| TextureCraftApp::new(cc, session)); harness.state_mut().ui.prefs.language = "en".into(); harness.run_steps(4); harness.get_by_role_and_label(egui::Role::Tab, "Material").click(); @@ -1658,8 +1752,12 @@ fn info_icon_snapshots() { let layer = execute(&mut session, "layer.add.fill", &json!({"color": [0.8, 0.3, 0.1]})).unwrap()["layer"].clone(); execute(&mut session, "layer.fill.projection", &json!({"layer": layer, "projection": "planar"})).unwrap(); execute(&mut session, "layer.fill.projection", &json!({"layer": layer, "scaleMode": "physicalSize", "backfaceCulling": true})).unwrap(); - let mut harness = - Harness::builder().with_size(egui::vec2(1600.0, 1500.0)).with_pixels_per_point(2.0).wgpu().with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|cc| TextureCraftApp::new(cc, session)); + let mut harness = Harness::builder() + .with_size(egui::vec2(1600.0, 1500.0)) + .with_pixels_per_point(2.0) + .wgpu() + .with_context_setup(texturecraft_ui_egui::framework::install_headless) + .build_eframe(|cc| TextureCraftApp::new(cc, session)); harness.state_mut().ui.prefs.language = "en".into(); // The test's stand-in arrow would hide the hovered i @@ -1697,8 +1795,12 @@ fn popup_tabs_snapshots() { let mut session = texturecraft_engine::sample_session(256, 64).unwrap(); let layer = execute(&mut session, "layer.add.fill", &json!({"color": [0.8, 0.3, 0.1]})).unwrap()["layer"].clone(); execute(&mut session, "layer.fill.projection", &json!({"layer": layer, "projection": "uv"})).unwrap(); - let mut harness = - Harness::builder().with_size(egui::vec2(1600.0, 1000.0)).with_pixels_per_point(2.0).wgpu().with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|cc| TextureCraftApp::new(cc, session)); + let mut harness = Harness::builder() + .with_size(egui::vec2(1600.0, 1000.0)) + .with_pixels_per_point(2.0) + .wgpu() + .with_context_setup(texturecraft_ui_egui::framework::install_headless) + .build_eframe(|cc| TextureCraftApp::new(cc, session)); harness.state_mut().ui.prefs.language = "en".into(); harness.set_render_cursor(false); harness.run_steps(4); @@ -1770,8 +1872,12 @@ fn mask_fill_snapshots() { let layer = execute(&mut session, "layer.add.paint", &json!({})).unwrap()["layer"].clone(); let effect = execute(&mut session, "effect.add.fill", &json!({"layer": layer, "target": "mask"})).unwrap()["effect"].clone(); execute(&mut session, "layer.select", &json!({"layer": layer, "target": effect})).unwrap(); - let mut harness = - Harness::builder().with_size(egui::vec2(1600.0, 1200.0)).with_pixels_per_point(2.0).wgpu().with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|cc| TextureCraftApp::new(cc, session)); + let mut harness = Harness::builder() + .with_size(egui::vec2(1600.0, 1200.0)) + .with_pixels_per_point(2.0) + .wgpu() + .with_context_setup(texturecraft_ui_egui::framework::install_headless) + .build_eframe(|cc| TextureCraftApp::new(cc, session)); harness.state_mut().ui.prefs.language = "en".into(); harness.run_steps(4); save(&mut harness, &output_dir, "mask-fill-fill"); @@ -1847,8 +1953,12 @@ fn compare_snapshots() { } let compare = execute(&mut session, "effect.add.compare", &json!({"layer": layer})).unwrap()["effect"].clone(); execute(&mut session, "layer.select", &json!({"layer": layer, "target": compare})).unwrap(); - let mut harness = - Harness::builder().with_size(egui::vec2(1600.0, 1200.0)).with_pixels_per_point(2.0).wgpu().with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|cc| TextureCraftApp::new(cc, session)); + let mut harness = Harness::builder() + .with_size(egui::vec2(1600.0, 1200.0)) + .with_pixels_per_point(2.0) + .wgpu() + .with_context_setup(texturecraft_ui_egui::framework::install_headless) + .build_eframe(|cc| TextureCraftApp::new(cc, session)); harness.state_mut().ui.prefs.language = "en".into(); harness.run_steps(6); save(&mut harness, &output_dir, "compare-default"); @@ -1898,8 +2008,12 @@ fn anchor_snapshots() { let fresh = execute(&mut session, "layer.add.fill", &json!({})).unwrap()["layer"].clone(); let content = execute(&mut session, "effect.add.anchor", &json!({"layer": fresh})).unwrap()["effect"].clone(); execute(&mut session, "layer.select", &json!({"layer": fresh, "target": content})).unwrap(); - let mut harness = - Harness::builder().with_size(egui::vec2(1600.0, 1200.0)).with_pixels_per_point(2.0).wgpu().with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|cc| TextureCraftApp::new(cc, session)); + let mut harness = Harness::builder() + .with_size(egui::vec2(1600.0, 1200.0)) + .with_pixels_per_point(2.0) + .wgpu() + .with_context_setup(texturecraft_ui_egui::framework::install_headless) + .build_eframe(|cc| TextureCraftApp::new(cc, session)); harness.state_mut().ui.prefs.language = "en".into(); harness.run_steps(6); harness.get_by_role_and_label(egui::Role::TextInput, "Anchor point name").click(); @@ -1937,8 +2051,12 @@ fn folder_snapshots() { execute(&mut session, "layer.fill.set", &json!({"layer": fill, "channel": "baseColor", "procedural": "Clouds"})).unwrap(); let folder = execute(&mut session, "layer.group", &json!({"layer": fill})).unwrap()["layer"].clone(); execute(&mut session, "layer.select", &json!({"layer": folder, "target": "content"})).unwrap(); - let mut harness = - Harness::builder().with_size(egui::vec2(1600.0, 1200.0)).with_pixels_per_point(2.0).wgpu().with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|cc| TextureCraftApp::new(cc, session)); + let mut harness = Harness::builder() + .with_size(egui::vec2(1600.0, 1200.0)) + .with_pixels_per_point(2.0) + .wgpu() + .with_context_setup(texturecraft_ui_egui::framework::install_headless) + .build_eframe(|cc| TextureCraftApp::new(cc, session)); harness.state_mut().ui.prefs.language = "en".into(); harness.run_steps(6); save(&mut harness, &output_dir, "folder-rest"); @@ -1977,8 +2095,12 @@ fn instance_snapshots() { execute(&mut session, "layer.fill.set", &json!({"layer": source, "channel": "baseColor", "color": [0.78, 0.29, 0.09]})).unwrap(); let instance = execute(&mut session, "layer.instance", &json!({"layer": source})).unwrap()["layer"].clone(); execute(&mut session, "layer.select", &json!({"layer": instance, "target": "content"})).unwrap(); - let mut harness = - Harness::builder().with_size(egui::vec2(1600.0, 1200.0)).with_pixels_per_point(2.0).wgpu().with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|cc| TextureCraftApp::new(cc, session)); + let mut harness = Harness::builder() + .with_size(egui::vec2(1600.0, 1200.0)) + .with_pixels_per_point(2.0) + .wgpu() + .with_context_setup(texturecraft_ui_egui::framework::install_headless) + .build_eframe(|cc| TextureCraftApp::new(cc, session)); harness.state_mut().ui.prefs.language = "en".into(); harness.run_steps(6); save(&mut harness, &output_dir, "instance-rest"); @@ -2020,8 +2142,12 @@ fn folder_mask_snapshots() { let folder = execute(&mut session, "layer.add.group", &json!({})).unwrap()["layer"].clone(); execute(&mut session, "mask.add.white", &json!({"layer": folder})).unwrap(); execute(&mut session, "layer.select", &json!({"layer": folder, "target": "mask"})).unwrap(); - let mut harness = - Harness::builder().with_size(egui::vec2(1600.0, 1200.0)).with_pixels_per_point(2.0).wgpu().with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|cc| TextureCraftApp::new(cc, session)); + let mut harness = Harness::builder() + .with_size(egui::vec2(1600.0, 1200.0)) + .with_pixels_per_point(2.0) + .wgpu() + .with_context_setup(texturecraft_ui_egui::framework::install_headless) + .build_eframe(|cc| TextureCraftApp::new(cc, session)); harness.state_mut().ui.prefs.language = "en".into(); harness.state_mut().ui.props_tab = texturecraft_ui_egui::state::PropsTab::Material; harness.run_steps(6); @@ -2066,8 +2192,12 @@ fn color_selection_snapshots() { execute(&mut session, "effect.set", &json!({"effect": effect.0, "colors": colors})).unwrap(); } execute(&mut session, "layer.select", &json!({"layer": layer, "target": effect.0})).unwrap(); - let mut harness = - Harness::builder().with_size(egui::vec2(1600.0, 1200.0)).with_pixels_per_point(2.0).wgpu().with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|cc| TextureCraftApp::new(cc, session)); + let mut harness = Harness::builder() + .with_size(egui::vec2(1600.0, 1200.0)) + .with_pixels_per_point(2.0) + .wgpu() + .with_context_setup(texturecraft_ui_egui::framework::install_headless) + .build_eframe(|cc| TextureCraftApp::new(cc, session)); harness.state_mut().ui.prefs.language = "en".into(); harness.run_steps(6); harness @@ -2149,8 +2279,12 @@ fn levels_snapshots() { let mask_levels = execute(&mut session, "effect.add.levels", &json!({"layer": layer, "target": "mask"})).unwrap()["effect"].clone(); let content_levels = execute(&mut session, "effect.add.levels", &json!({"layer": layer, "target": "content"})).unwrap()["effect"].clone(); execute(&mut session, "layer.select", &json!({"layer": layer, "target": mask_levels})).unwrap(); - let mut harness = - Harness::builder().with_size(egui::vec2(1600.0, 1200.0)).with_pixels_per_point(2.0).wgpu().with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|cc| TextureCraftApp::new(cc, session)); + let mut harness = Harness::builder() + .with_size(egui::vec2(1600.0, 1200.0)) + .with_pixels_per_point(2.0) + .wgpu() + .with_context_setup(texturecraft_ui_egui::framework::install_headless) + .build_eframe(|cc| TextureCraftApp::new(cc, session)); harness.state_mut().ui.prefs.language = "en".into(); harness.run_steps(6); save(&mut harness, &output_dir, "levels-mask"); @@ -2206,8 +2340,12 @@ fn layer_toolbar_snapshots() { execute(&mut session, "effect.add.generator", &json!({"layer": dirt, "generator": "dirt"})).unwrap(); let fill = execute(&mut session, "layer.add.fill", &json!({})).unwrap()["layer"].clone(); execute(&mut session, "layer.select", &json!({"layer": fill})).unwrap(); - let mut harness = - Harness::builder().with_size(egui::vec2(1600.0, 1200.0)).with_pixels_per_point(2.0).wgpu().with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|cc| TextureCraftApp::new(cc, session)); + let mut harness = Harness::builder() + .with_size(egui::vec2(1600.0, 1200.0)) + .with_pixels_per_point(2.0) + .wgpu() + .with_context_setup(texturecraft_ui_egui::framework::install_headless) + .build_eframe(|cc| TextureCraftApp::new(cc, session)); harness.state_mut().ui.prefs.language = "en".into(); harness.run_steps(6); harness.state_mut().ui.dock.focus(Panel::Layers); @@ -2274,8 +2412,12 @@ fn filter_card_snapshots() { let invert = add(&mut session, json!({"layer": layer, "target": "content", "filter": "invert"})); execute(&mut session, "layer.select", &json!({"layer": layer})).unwrap(); session.target = StackTarget::Effect(empty); - let mut harness = - Harness::builder().with_size(egui::vec2(1600.0, 1200.0)).with_pixels_per_point(2.0).wgpu().with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|cc| TextureCraftApp::new(cc, session)); + let mut harness = Harness::builder() + .with_size(egui::vec2(1600.0, 1200.0)) + .with_pixels_per_point(2.0) + .wgpu() + .with_context_setup(texturecraft_ui_egui::framework::install_headless) + .build_eframe(|cc| TextureCraftApp::new(cc, session)); harness.state_mut().ui.prefs.language = "en".into(); harness.run_steps(6); @@ -2328,8 +2470,12 @@ fn material_picker_snapshots() { execute(&mut session, "layer.fill.material", &json!({"layer": layer, "material": "copper"})).unwrap(); execute(&mut session, "layer.select", &json!({"layer": layer})).unwrap(); session.target = StackTarget::Content; - let mut harness = - Harness::builder().with_size(egui::vec2(1600.0, 2000.0)).with_pixels_per_point(2.0).wgpu().with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|cc| TextureCraftApp::new(cc, session)); + let mut harness = Harness::builder() + .with_size(egui::vec2(1600.0, 2000.0)) + .with_pixels_per_point(2.0) + .wgpu() + .with_context_setup(texturecraft_ui_egui::framework::install_headless) + .build_eframe(|cc| TextureCraftApp::new(cc, session)); harness.state_mut().ui.prefs.language = "en".into(); harness.run_steps(4); harness.get_by_role_and_label(egui::Role::Tab, "Material").click(); @@ -2382,8 +2528,12 @@ fn colour_filter_snapshots() { ]; execute(&mut session, "layer.select", &json!({"layer": layer})).unwrap(); session.target = StackTarget::Effect(effects[0].1); - let mut harness = - Harness::builder().with_size(egui::vec2(1600.0, 1200.0)).with_pixels_per_point(2.0).wgpu().with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|cc| TextureCraftApp::new(cc, session)); + let mut harness = Harness::builder() + .with_size(egui::vec2(1600.0, 1200.0)) + .with_pixels_per_point(2.0) + .wgpu() + .with_context_setup(texturecraft_ui_egui::framework::install_headless) + .build_eframe(|cc| TextureCraftApp::new(cc, session)); harness.state_mut().ui.prefs.language = "en".into(); harness.run_steps(6); for (name, effect) in effects { @@ -2433,8 +2583,12 @@ fn gradient_filter_snapshots() { ]; execute(&mut session, "layer.select", &json!({"layer": layer})).unwrap(); session.target = StackTarget::Effect(effects[0].1); - let mut harness = - Harness::builder().with_size(egui::vec2(1600.0, 1400.0)).with_pixels_per_point(2.0).wgpu().with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|cc| TextureCraftApp::new(cc, session)); + let mut harness = Harness::builder() + .with_size(egui::vec2(1600.0, 1400.0)) + .with_pixels_per_point(2.0) + .wgpu() + .with_context_setup(texturecraft_ui_egui::framework::install_headless) + .build_eframe(|cc| TextureCraftApp::new(cc, session)); harness.state_mut().ui.prefs.language = "en".into(); harness.run_steps(6); for (name, effect) in effects { @@ -2483,8 +2637,12 @@ fn light_filter_snapshots() { let effects = [("glow", add("glow")), ("drop-shadow", add("dropShadow"))]; execute(&mut session, "layer.select", &json!({"layer": layer})).unwrap(); session.target = StackTarget::Effect(effects[0].1); - let mut harness = - Harness::builder().with_size(egui::vec2(1600.0, 1400.0)).with_pixels_per_point(2.0).wgpu().with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|cc| TextureCraftApp::new(cc, session)); + let mut harness = Harness::builder() + .with_size(egui::vec2(1600.0, 1400.0)) + .with_pixels_per_point(2.0) + .wgpu() + .with_context_setup(texturecraft_ui_egui::framework::install_headless) + .build_eframe(|cc| TextureCraftApp::new(cc, session)); harness.state_mut().ui.prefs.language = "en".into(); harness.run_steps(6); for (name, effect) in effects { @@ -2517,8 +2675,12 @@ fn light_filter_snapshots() { let environment = LayerId(execute(&mut session, "effect.add.filter", ¶ms).unwrap()["effect"].as_u64().unwrap()); execute(&mut session, "layer.select", &json!({"layer": layer})).unwrap(); session.target = StackTarget::Effect(lighting); - let mut harness = - Harness::builder().with_size(egui::vec2(1600.0, 2600.0)).with_pixels_per_point(1.0).wgpu().with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|cc| TextureCraftApp::new(cc, session)); + let mut harness = Harness::builder() + .with_size(egui::vec2(1600.0, 2600.0)) + .with_pixels_per_point(1.0) + .wgpu() + .with_context_setup(texturecraft_ui_egui::framework::install_headless) + .build_eframe(|cc| TextureCraftApp::new(cc, session)); harness.state_mut().ui.prefs.language = "en".into(); harness.run_steps(8); save(&mut harness, &output_dir, "filter-baked-lighting-stylized"); @@ -2590,8 +2752,12 @@ fn shape_filter_snapshots() { ]; execute(&mut session, "layer.select", &json!({"layer": layer})).unwrap(); session.target = StackTarget::Effect(effects[0].1); - let mut harness = - Harness::builder().with_size(egui::vec2(1600.0, 1400.0)).with_pixels_per_point(2.0).wgpu().with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|cc| TextureCraftApp::new(cc, session)); + let mut harness = Harness::builder() + .with_size(egui::vec2(1600.0, 1400.0)) + .with_pixels_per_point(2.0) + .wgpu() + .with_context_setup(texturecraft_ui_egui::framework::install_headless) + .build_eframe(|cc| TextureCraftApp::new(cc, session)); harness.state_mut().ui.prefs.language = "en".into(); harness.run_steps(6); for (name, effect) in effects { @@ -2711,8 +2877,12 @@ fn simple_filter_snapshots() { let replace = LayerId(execute(&mut session, "effect.add.filter", ¶ms).unwrap()["effect"].as_u64().unwrap()); execute(&mut session, "layer.select", &json!({"layer": layer})).unwrap(); session.target = StackTarget::Effect(effects[0].1); - let mut harness = - Harness::builder().with_size(egui::vec2(1600.0, 1400.0)).with_pixels_per_point(2.0).wgpu().with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|cc| TextureCraftApp::new(cc, session)); + let mut harness = Harness::builder() + .with_size(egui::vec2(1600.0, 1400.0)) + .with_pixels_per_point(2.0) + .wgpu() + .with_context_setup(texturecraft_ui_egui::framework::install_headless) + .build_eframe(|cc| TextureCraftApp::new(cc, session)); harness.state_mut().ui.prefs.language = "en".into(); harness.run_steps(6); for (name, effect) in effects { @@ -2835,8 +3005,12 @@ fn image_input_snapshots() { ]; execute(&mut session, "layer.select", &json!({"layer": layer})).unwrap(); session.target = StackTarget::Effect(effects[0].1); - let mut harness = - Harness::builder().with_size(egui::vec2(1600.0, 2200.0)).with_pixels_per_point(2.0).wgpu().with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|cc| TextureCraftApp::new(cc, session)); + let mut harness = Harness::builder() + .with_size(egui::vec2(1600.0, 2200.0)) + .with_pixels_per_point(2.0) + .wgpu() + .with_context_setup(texturecraft_ui_egui::framework::install_headless) + .build_eframe(|cc| TextureCraftApp::new(cc, session)); harness.state_mut().ui.prefs.language = "en".into(); harness.run_steps(6); for (name, effect) in effects { @@ -2908,8 +3082,12 @@ fn filter_picker_snapshots() { let masked = add(&mut session, json!({"layer": layer, "target": "mask", "filter": "none"})); execute(&mut session, "layer.select", &json!({"layer": layer})).unwrap(); session.target = StackTarget::Effect(empty); - let mut harness = - Harness::builder().with_size(egui::vec2(1600.0, 1200.0)).with_pixels_per_point(2.0).wgpu().with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|cc| TextureCraftApp::new(cc, session)); + let mut harness = Harness::builder() + .with_size(egui::vec2(1600.0, 1200.0)) + .with_pixels_per_point(2.0) + .wgpu() + .with_context_setup(texturecraft_ui_egui::framework::install_headless) + .build_eframe(|cc| TextureCraftApp::new(cc, session)); harness.state_mut().ui.prefs.language = "en".into(); harness.run_steps(6); let open = |harness: &mut Harness<'_, TextureCraftApp>, card: &str, hover: &str| { @@ -2951,8 +3129,12 @@ fn properties_min_width_snapshot() { let layer = execute(&mut session, "layer.add.fill", &json!({"color": [0.8, 0.3, 0.1]})).unwrap()["layer"].clone(); let settings = json!({"layer": layer, "projection": "planar", "scaleMode": "physicalSize", "backfaceCulling": true, "shapeCrop": "cropped"}); execute(&mut session, "layer.fill.projection", &settings).unwrap(); - let mut harness = - Harness::builder().with_size(egui::vec2(1600.0, 1500.0)).with_pixels_per_point(2.0).wgpu().with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|cc| TextureCraftApp::new(cc, session)); + let mut harness = Harness::builder() + .with_size(egui::vec2(1600.0, 1500.0)) + .with_pixels_per_point(2.0) + .wgpu() + .with_context_setup(texturecraft_ui_egui::framework::install_headless) + .build_eframe(|cc| TextureCraftApp::new(cc, session)); harness.run_steps(4); let workspace = harness.state().ui.dock.workspace().clone(); let mut layout = workspace.layout().clone(); @@ -2983,7 +3165,11 @@ fn sheet_scroll_end_snapshots() { let mut session = texturecraft_engine::sample_session(256, 64).unwrap(); let layer = execute(&mut session, "layer.add.fill", &json!({"color": [0.8, 0.3, 0.1]})).unwrap()["layer"].clone(); execute(&mut session, "layer.fill.projection", &json!({"layer": layer, "projection": "uv"})).unwrap(); - let mut harness = Harness::builder().with_size(egui::vec2(1600.0, 2000.0)).wgpu().with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|cc| TextureCraftApp::new(cc, session)); + let mut harness = Harness::builder() + .with_size(egui::vec2(1600.0, 2000.0)) + .wgpu() + .with_context_setup(texturecraft_ui_egui::framework::install_headless) + .build_eframe(|cc| TextureCraftApp::new(cc, session)); harness.state_mut().ui.prefs.language = "en".into(); harness.set_render_cursor(false); harness.run_steps(4); From 172d85528dddb9ac9c7f716fa824984e7e2a9626 Mon Sep 17 00:00:00 2001 From: aiongg Date: Tue, 24 Nov 2026 17:07:48 +0000 Subject: [PATCH 23/83] Repin to craft-libs 3ad64a26ea: rail drag hand-over through DockArea::continue_move, Delete and Backspace apart through the keymap, Answer::Saved --- Cargo.lock | 100 +++++++++++++----------- Cargo.toml | 34 ++++---- crates/formats/Cargo.toml | 4 +- crates/ui-egui/src/docking.rs | 14 +++- crates/ui-egui/src/file_dialogs.rs | 1 + crates/ui-egui/src/keymap.rs | 2 +- crates/ui-egui/src/rail_popup.rs | 7 +- crates/ui-egui/src/shortcut_dispatch.rs | 26 +----- 8 files changed, 98 insertions(+), 90 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 2e2d8d3e..104a6bb8 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -950,10 +950,20 @@ dependencies = [ "libc", ] +[[package]] +name = "craft-appkit" +version = "0.1.0" +source = "git+https://github.com/aiongg/craft-libs?rev=3ad64a26ea8a72c03c416681e14f7744393790b1#3ad64a26ea8a72c03c416681e14f7744393790b1" +dependencies = [ + "block2 0.6.2", + "objc2-app-kit 0.3.2", + "objc2-foundation 0.3.2", +] + [[package]] name = "craft-atomic" version = "0.1.0" -source = "git+https://github.com/aiongg/craft-libs?rev=cd87dc61f77d8470b2e9e6a1236f9a84ee0a64de#cd87dc61f77d8470b2e9e6a1236f9a84ee0a64de" +source = "git+https://github.com/aiongg/craft-libs?rev=3ad64a26ea8a72c03c416681e14f7744393790b1#3ad64a26ea8a72c03c416681e14f7744393790b1" dependencies = [ "rustix 1.1.6", ] @@ -961,7 +971,7 @@ dependencies = [ [[package]] name = "craft-behavior" version = "0.1.0" -source = "git+https://github.com/aiongg/craft-libs?rev=cd87dc61f77d8470b2e9e6a1236f9a84ee0a64de#cd87dc61f77d8470b2e9e6a1236f9a84ee0a64de" +source = "git+https://github.com/aiongg/craft-libs?rev=3ad64a26ea8a72c03c416681e14f7744393790b1#3ad64a26ea8a72c03c416681e14f7744393790b1" dependencies = [ "accesskit", "bitflags 2.13.2", @@ -979,7 +989,7 @@ dependencies = [ [[package]] name = "craft-cloud-ui" version = "0.1.0" -source = "git+https://github.com/aiongg/craft-libs?rev=cd87dc61f77d8470b2e9e6a1236f9a84ee0a64de#cd87dc61f77d8470b2e9e6a1236f9a84ee0a64de" +source = "git+https://github.com/aiongg/craft-libs?rev=3ad64a26ea8a72c03c416681e14f7744393790b1#3ad64a26ea8a72c03c416681e14f7744393790b1" dependencies = [ "egui", ] @@ -987,7 +997,7 @@ dependencies = [ [[package]] name = "craft-cms" version = "0.1.0" -source = "git+https://github.com/aiongg/craft-libs?rev=cd87dc61f77d8470b2e9e6a1236f9a84ee0a64de#cd87dc61f77d8470b2e9e6a1236f9a84ee0a64de" +source = "git+https://github.com/aiongg/craft-libs?rev=3ad64a26ea8a72c03c416681e14f7744393790b1#3ad64a26ea8a72c03c416681e14f7744393790b1" dependencies = [ "md-5", "rayon", @@ -996,12 +1006,12 @@ dependencies = [ [[package]] name = "craft-codepage" version = "0.1.0" -source = "git+https://github.com/aiongg/craft-libs?rev=cd87dc61f77d8470b2e9e6a1236f9a84ee0a64de#cd87dc61f77d8470b2e9e6a1236f9a84ee0a64de" +source = "git+https://github.com/aiongg/craft-libs?rev=3ad64a26ea8a72c03c416681e14f7744393790b1#3ad64a26ea8a72c03c416681e14f7744393790b1" [[package]] name = "craft-dds" version = "0.1.0" -source = "git+https://github.com/aiongg/craft-libs?rev=cd87dc61f77d8470b2e9e6a1236f9a84ee0a64de#cd87dc61f77d8470b2e9e6a1236f9a84ee0a64de" +source = "git+https://github.com/aiongg/craft-libs?rev=3ad64a26ea8a72c03c416681e14f7744393790b1#3ad64a26ea8a72c03c416681e14f7744393790b1" dependencies = [ "rayon", ] @@ -1009,7 +1019,7 @@ dependencies = [ [[package]] name = "craft-dialogs" version = "0.1.0" -source = "git+https://github.com/aiongg/craft-libs?rev=cd87dc61f77d8470b2e9e6a1236f9a84ee0a64de#cd87dc61f77d8470b2e9e6a1236f9a84ee0a64de" +source = "git+https://github.com/aiongg/craft-libs?rev=3ad64a26ea8a72c03c416681e14f7744393790b1#3ad64a26ea8a72c03c416681e14f7744393790b1" dependencies = [ "block2 0.6.2", "craft-atomic", @@ -1029,7 +1039,7 @@ dependencies = [ [[package]] name = "craft-docpath" version = "0.1.0" -source = "git+https://github.com/aiongg/craft-libs?rev=cd87dc61f77d8470b2e9e6a1236f9a84ee0a64de#cd87dc61f77d8470b2e9e6a1236f9a84ee0a64de" +source = "git+https://github.com/aiongg/craft-libs?rev=3ad64a26ea8a72c03c416681e14f7744393790b1#3ad64a26ea8a72c03c416681e14f7744393790b1" dependencies = [ "serde", ] @@ -1037,7 +1047,7 @@ dependencies = [ [[package]] name = "craft-font-catalog" version = "0.1.0" -source = "git+https://github.com/aiongg/craft-libs?rev=cd87dc61f77d8470b2e9e6a1236f9a84ee0a64de#cd87dc61f77d8470b2e9e6a1236f9a84ee0a64de" +source = "git+https://github.com/aiongg/craft-libs?rev=3ad64a26ea8a72c03c416681e14f7744393790b1#3ad64a26ea8a72c03c416681e14f7744393790b1" dependencies = [ "harfrust 0.13.3", "kurbo", @@ -1051,12 +1061,12 @@ dependencies = [ [[package]] name = "craft-fonts-build" version = "0.1.0" -source = "git+https://github.com/aiongg/craft-libs?rev=cd87dc61f77d8470b2e9e6a1236f9a84ee0a64de#cd87dc61f77d8470b2e9e6a1236f9a84ee0a64de" +source = "git+https://github.com/aiongg/craft-libs?rev=3ad64a26ea8a72c03c416681e14f7744393790b1#3ad64a26ea8a72c03c416681e14f7744393790b1" [[package]] name = "craft-host" version = "0.1.0" -source = "git+https://github.com/aiongg/craft-libs?rev=cd87dc61f77d8470b2e9e6a1236f9a84ee0a64de#cd87dc61f77d8470b2e9e6a1236f9a84ee0a64de" +source = "git+https://github.com/aiongg/craft-libs?rev=3ad64a26ea8a72c03c416681e14f7744393790b1#3ad64a26ea8a72c03c416681e14f7744393790b1" dependencies = [ "bitflags 2.13.2", "craft-i18n", @@ -1069,7 +1079,7 @@ dependencies = [ [[package]] name = "craft-i18n" version = "0.1.0" -source = "git+https://github.com/aiongg/craft-libs?rev=cd87dc61f77d8470b2e9e6a1236f9a84ee0a64de#cd87dc61f77d8470b2e9e6a1236f9a84ee0a64de" +source = "git+https://github.com/aiongg/craft-libs?rev=3ad64a26ea8a72c03c416681e14f7744393790b1#3ad64a26ea8a72c03c416681e14f7744393790b1" dependencies = [ "chrono", "fixed_decimal", @@ -1097,7 +1107,7 @@ dependencies = [ [[package]] name = "craft-image-codecs" version = "0.1.0" -source = "git+https://github.com/aiongg/craft-libs?rev=cd87dc61f77d8470b2e9e6a1236f9a84ee0a64de#cd87dc61f77d8470b2e9e6a1236f9a84ee0a64de" +source = "git+https://github.com/aiongg/craft-libs?rev=3ad64a26ea8a72c03c416681e14f7744393790b1#3ad64a26ea8a72c03c416681e14f7744393790b1" dependencies = [ "craft-dds", "craft-jpeg", @@ -1124,7 +1134,7 @@ dependencies = [ [[package]] name = "craft-jpeg" version = "0.1.0" -source = "git+https://github.com/aiongg/craft-libs?rev=cd87dc61f77d8470b2e9e6a1236f9a84ee0a64de#cd87dc61f77d8470b2e9e6a1236f9a84ee0a64de" +source = "git+https://github.com/aiongg/craft-libs?rev=3ad64a26ea8a72c03c416681e14f7744393790b1#3ad64a26ea8a72c03c416681e14f7744393790b1" dependencies = [ "thiserror 2.0.21", ] @@ -1132,7 +1142,7 @@ dependencies = [ [[package]] name = "craft-keymap" version = "0.1.0" -source = "git+https://github.com/aiongg/craft-libs?rev=cd87dc61f77d8470b2e9e6a1236f9a84ee0a64de#cd87dc61f77d8470b2e9e6a1236f9a84ee0a64de" +source = "git+https://github.com/aiongg/craft-libs?rev=3ad64a26ea8a72c03c416681e14f7744393790b1#3ad64a26ea8a72c03c416681e14f7744393790b1" dependencies = [ "craft-host", "craft-i18n", @@ -1147,7 +1157,7 @@ dependencies = [ [[package]] name = "craft-materialx" version = "0.1.0" -source = "git+https://github.com/aiongg/craft-libs?rev=cd87dc61f77d8470b2e9e6a1236f9a84ee0a64de#cd87dc61f77d8470b2e9e6a1236f9a84ee0a64de" +source = "git+https://github.com/aiongg/craft-libs?rev=3ad64a26ea8a72c03c416681e14f7744393790b1#3ad64a26ea8a72c03c416681e14f7744393790b1" dependencies = [ "craft-xml", "thiserror 2.0.21", @@ -1156,7 +1166,7 @@ dependencies = [ [[package]] name = "craft-mcmat" version = "0.1.0" -source = "git+https://github.com/aiongg/craft-libs?rev=cd87dc61f77d8470b2e9e6a1236f9a84ee0a64de#cd87dc61f77d8470b2e9e6a1236f9a84ee0a64de" +source = "git+https://github.com/aiongg/craft-libs?rev=3ad64a26ea8a72c03c416681e14f7744393790b1#3ad64a26ea8a72c03c416681e14f7744393790b1" dependencies = [ "craft-zip", "serde", @@ -1167,7 +1177,7 @@ dependencies = [ [[package]] name = "craft-menu" version = "0.1.0" -source = "git+https://github.com/aiongg/craft-libs?rev=cd87dc61f77d8470b2e9e6a1236f9a84ee0a64de#cd87dc61f77d8470b2e9e6a1236f9a84ee0a64de" +source = "git+https://github.com/aiongg/craft-libs?rev=3ad64a26ea8a72c03c416681e14f7744393790b1#3ad64a26ea8a72c03c416681e14f7744393790b1" dependencies = [ "craft-behavior", "craft-host", @@ -1185,7 +1195,7 @@ dependencies = [ [[package]] name = "craft-mesh" version = "0.1.0" -source = "git+https://github.com/aiongg/craft-libs?rev=cd87dc61f77d8470b2e9e6a1236f9a84ee0a64de#cd87dc61f77d8470b2e9e6a1236f9a84ee0a64de" +source = "git+https://github.com/aiongg/craft-libs?rev=3ad64a26ea8a72c03c416681e14f7744393790b1#3ad64a26ea8a72c03c416681e14f7744393790b1" dependencies = [ "craft-xml", "craft-zip", @@ -1196,7 +1206,7 @@ dependencies = [ [[package]] name = "craft-metadata" version = "0.1.0" -source = "git+https://github.com/aiongg/craft-libs?rev=cd87dc61f77d8470b2e9e6a1236f9a84ee0a64de#cd87dc61f77d8470b2e9e6a1236f9a84ee0a64de" +source = "git+https://github.com/aiongg/craft-libs?rev=3ad64a26ea8a72c03c416681e14f7744393790b1#3ad64a26ea8a72c03c416681e14f7744393790b1" dependencies = [ "brotli-decompressor", "chrono", @@ -1208,7 +1218,7 @@ dependencies = [ [[package]] name = "craft-pdf" version = "0.1.0" -source = "git+https://github.com/aiongg/craft-libs?rev=cd87dc61f77d8470b2e9e6a1236f9a84ee0a64de#cd87dc61f77d8470b2e9e6a1236f9a84ee0a64de" +source = "git+https://github.com/aiongg/craft-libs?rev=3ad64a26ea8a72c03c416681e14f7744393790b1#3ad64a26ea8a72c03c416681e14f7744393790b1" dependencies = [ "serde", ] @@ -1216,7 +1226,7 @@ dependencies = [ [[package]] name = "craft-platform" version = "0.1.0" -source = "git+https://github.com/aiongg/craft-libs?rev=cd87dc61f77d8470b2e9e6a1236f9a84ee0a64de#cd87dc61f77d8470b2e9e6a1236f9a84ee0a64de" +source = "git+https://github.com/aiongg/craft-libs?rev=3ad64a26ea8a72c03c416681e14f7744393790b1#3ad64a26ea8a72c03c416681e14f7744393790b1" dependencies = [ "async-channel", "async-io", @@ -1247,7 +1257,7 @@ dependencies = [ [[package]] name = "craft-psd" version = "0.1.0" -source = "git+https://github.com/aiongg/craft-libs?rev=cd87dc61f77d8470b2e9e6a1236f9a84ee0a64de#cd87dc61f77d8470b2e9e6a1236f9a84ee0a64de" +source = "git+https://github.com/aiongg/craft-libs?rev=3ad64a26ea8a72c03c416681e14f7744393790b1#3ad64a26ea8a72c03c416681e14f7744393790b1" dependencies = [ "encoding_rs", "flate2", @@ -1258,7 +1268,7 @@ dependencies = [ [[package]] name = "craft-quit" version = "0.1.0" -source = "git+https://github.com/aiongg/craft-libs?rev=cd87dc61f77d8470b2e9e6a1236f9a84ee0a64de#cd87dc61f77d8470b2e9e6a1236f9a84ee0a64de" +source = "git+https://github.com/aiongg/craft-libs?rev=3ad64a26ea8a72c03c416681e14f7744393790b1#3ad64a26ea8a72c03c416681e14f7744393790b1" dependencies = [ "dispatch2", "egui", @@ -1271,7 +1281,7 @@ dependencies = [ [[package]] name = "craft-settings" version = "0.1.0" -source = "git+https://github.com/aiongg/craft-libs?rev=cd87dc61f77d8470b2e9e6a1236f9a84ee0a64de#cd87dc61f77d8470b2e9e6a1236f9a84ee0a64de" +source = "git+https://github.com/aiongg/craft-libs?rev=3ad64a26ea8a72c03c416681e14f7744393790b1#3ad64a26ea8a72c03c416681e14f7744393790b1" dependencies = [ "craft-atomic", "craft-host", @@ -1288,7 +1298,7 @@ dependencies = [ [[package]] name = "craft-svg" version = "0.1.0" -source = "git+https://github.com/aiongg/craft-libs?rev=cd87dc61f77d8470b2e9e6a1236f9a84ee0a64de#cd87dc61f77d8470b2e9e6a1236f9a84ee0a64de" +source = "git+https://github.com/aiongg/craft-libs?rev=3ad64a26ea8a72c03c416681e14f7744393790b1#3ad64a26ea8a72c03c416681e14f7744393790b1" dependencies = [ "craft-xml", "flate2", @@ -1305,7 +1315,7 @@ dependencies = [ [[package]] name = "craft-tcraft" version = "0.1.0" -source = "git+https://github.com/aiongg/craft-libs?rev=cd87dc61f77d8470b2e9e6a1236f9a84ee0a64de#cd87dc61f77d8470b2e9e6a1236f9a84ee0a64de" +source = "git+https://github.com/aiongg/craft-libs?rev=3ad64a26ea8a72c03c416681e14f7744393790b1#3ad64a26ea8a72c03c416681e14f7744393790b1" dependencies = [ "craft-zip", "serde", @@ -1316,7 +1326,7 @@ dependencies = [ [[package]] name = "craft-theme" version = "0.1.0" -source = "git+https://github.com/aiongg/craft-libs?rev=cd87dc61f77d8470b2e9e6a1236f9a84ee0a64de#cd87dc61f77d8470b2e9e6a1236f9a84ee0a64de" +source = "git+https://github.com/aiongg/craft-libs?rev=3ad64a26ea8a72c03c416681e14f7744393790b1#3ad64a26ea8a72c03c416681e14f7744393790b1" dependencies = [ "bitflags 2.13.2", "craft-tracked", @@ -1331,7 +1341,7 @@ dependencies = [ [[package]] name = "craft-tiff" version = "0.1.0" -source = "git+https://github.com/aiongg/craft-libs?rev=cd87dc61f77d8470b2e9e6a1236f9a84ee0a64de#cd87dc61f77d8470b2e9e6a1236f9a84ee0a64de" +source = "git+https://github.com/aiongg/craft-libs?rev=3ad64a26ea8a72c03c416681e14f7744393790b1#3ad64a26ea8a72c03c416681e14f7744393790b1" dependencies = [ "serde", "thiserror 2.0.21", @@ -1341,12 +1351,12 @@ dependencies = [ [[package]] name = "craft-tracked" version = "0.1.0" -source = "git+https://github.com/aiongg/craft-libs?rev=cd87dc61f77d8470b2e9e6a1236f9a84ee0a64de#cd87dc61f77d8470b2e9e6a1236f9a84ee0a64de" +source = "git+https://github.com/aiongg/craft-libs?rev=3ad64a26ea8a72c03c416681e14f7744393790b1#3ad64a26ea8a72c03c416681e14f7744393790b1" [[package]] name = "craft-ui" version = "0.1.0" -source = "git+https://github.com/aiongg/craft-libs?rev=cd87dc61f77d8470b2e9e6a1236f9a84ee0a64de#cd87dc61f77d8470b2e9e6a1236f9a84ee0a64de" +source = "git+https://github.com/aiongg/craft-libs?rev=3ad64a26ea8a72c03c416681e14f7744393790b1#3ad64a26ea8a72c03c416681e14f7744393790b1" dependencies = [ "craft-cloud-ui", "craft-ui-canvas", @@ -1360,7 +1370,7 @@ dependencies = [ [[package]] name = "craft-ui-canvas" version = "0.1.0" -source = "git+https://github.com/aiongg/craft-libs?rev=cd87dc61f77d8470b2e9e6a1236f9a84ee0a64de#cd87dc61f77d8470b2e9e6a1236f9a84ee0a64de" +source = "git+https://github.com/aiongg/craft-libs?rev=3ad64a26ea8a72c03c416681e14f7744393790b1#3ad64a26ea8a72c03c416681e14f7744393790b1" dependencies = [ "craft-behavior", "craft-i18n", @@ -1376,7 +1386,7 @@ dependencies = [ [[package]] name = "craft-ui-contract" version = "0.1.0" -source = "git+https://github.com/aiongg/craft-libs?rev=cd87dc61f77d8470b2e9e6a1236f9a84ee0a64de#cd87dc61f77d8470b2e9e6a1236f9a84ee0a64de" +source = "git+https://github.com/aiongg/craft-libs?rev=3ad64a26ea8a72c03c416681e14f7744393790b1#3ad64a26ea8a72c03c416681e14f7744393790b1" dependencies = [ "accesskit", "craft-behavior", @@ -1414,7 +1424,7 @@ dependencies = [ [[package]] name = "craft-ui-macros" version = "0.1.0" -source = "git+https://github.com/aiongg/craft-libs?rev=cd87dc61f77d8470b2e9e6a1236f9a84ee0a64de#cd87dc61f77d8470b2e9e6a1236f9a84ee0a64de" +source = "git+https://github.com/aiongg/craft-libs?rev=3ad64a26ea8a72c03c416681e14f7744393790b1#3ad64a26ea8a72c03c416681e14f7744393790b1" dependencies = [ "proc-macro-crate", "proc-macro2", @@ -1425,7 +1435,7 @@ dependencies = [ [[package]] name = "craft-ui-panels" version = "0.1.0" -source = "git+https://github.com/aiongg/craft-libs?rev=cd87dc61f77d8470b2e9e6a1236f9a84ee0a64de#cd87dc61f77d8470b2e9e6a1236f9a84ee0a64de" +source = "git+https://github.com/aiongg/craft-libs?rev=3ad64a26ea8a72c03c416681e14f7744393790b1#3ad64a26ea8a72c03c416681e14f7744393790b1" dependencies = [ "craft-behavior", "craft-host", @@ -1443,7 +1453,7 @@ dependencies = [ [[package]] name = "craft-ui-patterns" version = "0.1.0" -source = "git+https://github.com/aiongg/craft-libs?rev=cd87dc61f77d8470b2e9e6a1236f9a84ee0a64de#cd87dc61f77d8470b2e9e6a1236f9a84ee0a64de" +source = "git+https://github.com/aiongg/craft-libs?rev=3ad64a26ea8a72c03c416681e14f7744393790b1#3ad64a26ea8a72c03c416681e14f7744393790b1" dependencies = [ "craft-behavior", "craft-host", @@ -1464,7 +1474,7 @@ dependencies = [ [[package]] name = "craft-ui-shell" version = "0.1.0" -source = "git+https://github.com/aiongg/craft-libs?rev=cd87dc61f77d8470b2e9e6a1236f9a84ee0a64de#cd87dc61f77d8470b2e9e6a1236f9a84ee0a64de" +source = "git+https://github.com/aiongg/craft-libs?rev=3ad64a26ea8a72c03c416681e14f7744393790b1#3ad64a26ea8a72c03c416681e14f7744393790b1" dependencies = [ "craft-behavior", "craft-host", @@ -1484,7 +1494,7 @@ dependencies = [ [[package]] name = "craft-ui-widgets" version = "0.1.0" -source = "git+https://github.com/aiongg/craft-libs?rev=cd87dc61f77d8470b2e9e6a1236f9a84ee0a64de#cd87dc61f77d8470b2e9e6a1236f9a84ee0a64de" +source = "git+https://github.com/aiongg/craft-libs?rev=3ad64a26ea8a72c03c416681e14f7744393790b1#3ad64a26ea8a72c03c416681e14f7744393790b1" dependencies = [ "craft-behavior", "craft-host", @@ -1503,7 +1513,7 @@ dependencies = [ [[package]] name = "craft-update" version = "0.1.0" -source = "git+https://github.com/aiongg/craft-libs?rev=cd87dc61f77d8470b2e9e6a1236f9a84ee0a64de#cd87dc61f77d8470b2e9e6a1236f9a84ee0a64de" +source = "git+https://github.com/aiongg/craft-libs?rev=3ad64a26ea8a72c03c416681e14f7744393790b1#3ad64a26ea8a72c03c416681e14f7744393790b1" dependencies = [ "chrono", "craft-host", @@ -1532,7 +1542,7 @@ dependencies = [ [[package]] name = "craft-usd" version = "0.1.0" -source = "git+https://github.com/aiongg/craft-libs?rev=cd87dc61f77d8470b2e9e6a1236f9a84ee0a64de#cd87dc61f77d8470b2e9e6a1236f9a84ee0a64de" +source = "git+https://github.com/aiongg/craft-libs?rev=3ad64a26ea8a72c03c416681e14f7744393790b1#3ad64a26ea8a72c03c416681e14f7744393790b1" dependencies = [ "half", "lz4_flex", @@ -1542,7 +1552,7 @@ dependencies = [ [[package]] name = "craft-win32" version = "0.1.0" -source = "git+https://github.com/aiongg/craft-libs?rev=cd87dc61f77d8470b2e9e6a1236f9a84ee0a64de#cd87dc61f77d8470b2e9e6a1236f9a84ee0a64de" +source = "git+https://github.com/aiongg/craft-libs?rev=3ad64a26ea8a72c03c416681e14f7744393790b1#3ad64a26ea8a72c03c416681e14f7744393790b1" dependencies = [ "winsafe", ] @@ -1550,8 +1560,9 @@ dependencies = [ [[package]] name = "craft-window" version = "0.1.0" -source = "git+https://github.com/aiongg/craft-libs?rev=cd87dc61f77d8470b2e9e6a1236f9a84ee0a64de#cd87dc61f77d8470b2e9e6a1236f9a84ee0a64de" +source = "git+https://github.com/aiongg/craft-libs?rev=3ad64a26ea8a72c03c416681e14f7744393790b1#3ad64a26ea8a72c03c416681e14f7744393790b1" dependencies = [ + "craft-appkit", "craft-atomic", "craft-behavior", "craft-host", @@ -1567,12 +1578,13 @@ dependencies = [ "serde_json", "wayland-client", "winsafe", + "x11rb", ] [[package]] name = "craft-xml" version = "0.1.0" -source = "git+https://github.com/aiongg/craft-libs?rev=cd87dc61f77d8470b2e9e6a1236f9a84ee0a64de#cd87dc61f77d8470b2e9e6a1236f9a84ee0a64de" +source = "git+https://github.com/aiongg/craft-libs?rev=3ad64a26ea8a72c03c416681e14f7744393790b1#3ad64a26ea8a72c03c416681e14f7744393790b1" dependencies = [ "quick-xml 0.41.0", "serde", @@ -1582,7 +1594,7 @@ dependencies = [ [[package]] name = "craft-zip" version = "0.1.0" -source = "git+https://github.com/aiongg/craft-libs?rev=cd87dc61f77d8470b2e9e6a1236f9a84ee0a64de#cd87dc61f77d8470b2e9e6a1236f9a84ee0a64de" +source = "git+https://github.com/aiongg/craft-libs?rev=3ad64a26ea8a72c03c416681e14f7744393790b1#3ad64a26ea8a72c03c416681e14f7744393790b1" dependencies = [ "flate2", "thiserror 2.0.21", diff --git a/Cargo.toml b/Cargo.toml index b08c83ac..97ecf3e8 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -10,7 +10,7 @@ edition = "2024" license = "MIT OR Apache-2.0" [workspace.dependencies] -craft-usd = { version = "0.1.0", git = "https://github.com/aiongg/craft-libs", rev = "cd87dc61f77d8470b2e9e6a1236f9a84ee0a64de" } +craft-usd = { version = "0.1.0", git = "https://github.com/aiongg/craft-libs", rev = "3ad64a26ea8a72c03c416681e14f7744393790b1" } # internal texturecraft-core = { path = "crates/core" } texturecraft-texel = { path = "crates/texel" } @@ -41,7 +41,7 @@ skrifa = { version = "0.44", default-features = false, features = ["std"] } epaint_default_fonts = "0.37" log = "0.4" image = { version = "0.25", default-features = false, features = ["png", "jpeg", "tga", "tiff", "exr", "hdr", "bmp", "webp"] } -craft-image-codecs = { git = "https://github.com/aiongg/craft-libs", rev = "cd87dc61f77d8470b2e9e6a1236f9a84ee0a64de" } +craft-image-codecs = { git = "https://github.com/aiongg/craft-libs", rev = "3ad64a26ea8a72c03c416681e14f7744393790b1" } half = "2" exr = { version = "1.73", default-features = false } eframe = { version = "0.37", default-features = false } @@ -64,28 +64,28 @@ rustix = { version = "1", default-features = false, features = ["std", "fs", "pr # Shared Craft egui components (widget palette, icon buttons, panel docking): storytold/craft-libs, # MIT OR Apache-2.0, pinned to one rev. # Shared catalog lookup, pinned with the other Craft libraries. -craft-i18n = { git = "https://github.com/aiongg/craft-libs", rev = "cd87dc61f77d8470b2e9e6a1236f9a84ee0a64de" } -craft-ui = { git = "https://github.com/aiongg/craft-libs", rev = "cd87dc61f77d8470b2e9e6a1236f9a84ee0a64de" } -craft-behavior = { git = "https://github.com/aiongg/craft-libs", rev = "cd87dc61f77d8470b2e9e6a1236f9a84ee0a64de" } -craft-materialx = { git = "https://github.com/aiongg/craft-libs", rev = "cd87dc61f77d8470b2e9e6a1236f9a84ee0a64de" } -craft-tcraft = { git = "https://github.com/aiongg/craft-libs", rev = "cd87dc61f77d8470b2e9e6a1236f9a84ee0a64de" } -craft-zip = { git = "https://github.com/aiongg/craft-libs", rev = "cd87dc61f77d8470b2e9e6a1236f9a84ee0a64de" } -craft-mesh = { git = "https://github.com/aiongg/craft-libs", rev = "cd87dc61f77d8470b2e9e6a1236f9a84ee0a64de", default-features = false, features = ["stl", "ply", "fbx", "obj", "gltf", "dae", "abc"] } -craft-mcmat = { git = "https://github.com/aiongg/craft-libs", rev = "cd87dc61f77d8470b2e9e6a1236f9a84ee0a64de" } +craft-i18n = { git = "https://github.com/aiongg/craft-libs", rev = "3ad64a26ea8a72c03c416681e14f7744393790b1" } +craft-ui = { git = "https://github.com/aiongg/craft-libs", rev = "3ad64a26ea8a72c03c416681e14f7744393790b1" } +craft-behavior = { git = "https://github.com/aiongg/craft-libs", rev = "3ad64a26ea8a72c03c416681e14f7744393790b1" } +craft-materialx = { git = "https://github.com/aiongg/craft-libs", rev = "3ad64a26ea8a72c03c416681e14f7744393790b1" } +craft-tcraft = { git = "https://github.com/aiongg/craft-libs", rev = "3ad64a26ea8a72c03c416681e14f7744393790b1" } +craft-zip = { git = "https://github.com/aiongg/craft-libs", rev = "3ad64a26ea8a72c03c416681e14f7744393790b1" } +craft-mesh = { git = "https://github.com/aiongg/craft-libs", rev = "3ad64a26ea8a72c03c416681e14f7744393790b1", default-features = false, features = ["stl", "ply", "fbx", "obj", "gltf", "dae", "abc"] } +craft-mcmat = { git = "https://github.com/aiongg/craft-libs", rev = "3ad64a26ea8a72c03c416681e14f7744393790b1" } # Who draws the window frame, and the app-drawn strip as the title bar (crates/ui-egui/src/titlebar.rs). -craft-window = { git = "https://github.com/aiongg/craft-libs", rev = "cd87dc61f77d8470b2e9e6a1236f9a84ee0a64de", features = ["ui"] } +craft-window = { git = "https://github.com/aiongg/craft-libs", rev = "3ad64a26ea8a72c03c416681e14f7744393790b1", features = ["ui"] } # Release checks, the update prompt and the update helper (crates/ui-egui/src/updates_ui.rs). -craft-update = { git = "https://github.com/aiongg/craft-libs", rev = "cd87dc61f77d8470b2e9e6a1236f9a84ee0a64de", features = ["ui"] } +craft-update = { git = "https://github.com/aiongg/craft-libs", rev = "3ad64a26ea8a72c03c416681e14f7744393790b1", features = ["ui"] } # File dialogs that never block the frame (crates/ui-egui/src/file_dialogs.rs). -craft-dialogs = { git = "https://github.com/aiongg/craft-libs", rev = "cd87dc61f77d8470b2e9e6a1236f9a84ee0a64de" } +craft-dialogs = { git = "https://github.com/aiongg/craft-libs", rev = "3ad64a26ea8a72c03c416681e14f7744393790b1" } # Shortcut chords, lookup and dispatch (crates/ui-egui/src/keymap.rs). -craft-keymap = { git = "https://github.com/aiongg/craft-libs", rev = "cd87dc61f77d8470b2e9e6a1236f9a84ee0a64de", features = ["egui"] } +craft-keymap = { git = "https://github.com/aiongg/craft-libs", rev = "3ad64a26ea8a72c03c416681e14f7744393790b1", features = ["egui"] } # The macOS app menu whose Quit asks about unsaved changes (apps/texturecraft/src/main.rs). -craft-menu = { git = "https://github.com/aiongg/craft-libs", rev = "cd87dc61f77d8470b2e9e6a1236f9a84ee0a64de" } +craft-menu = { git = "https://github.com/aiongg/craft-libs", rev = "3ad64a26ea8a72c03c416681e14f7744393790b1" } # The UI runtime's host: who the app is to the framework's dialogs (crates/ui-egui/src/framework.rs). -craft-host = { git = "https://github.com/aiongg/craft-libs", rev = "cd87dc61f77d8470b2e9e6a1236f9a84ee0a64de" } +craft-host = { git = "https://github.com/aiongg/craft-libs", rev = "3ad64a26ea8a72c03c416681e14f7744393790b1" } # The theme mode the app hands the runtime (crates/ui-egui/src/framework.rs). -craft-theme = { git = "https://github.com/aiongg/craft-libs", rev = "cd87dc61f77d8470b2e9e6a1236f9a84ee0a64de" } +craft-theme = { git = "https://github.com/aiongg/craft-libs", rev = "3ad64a26ea8a72c03c416681e14f7744393790b1" } # egui 0.37 and winit: the suite's forks (storytold/egui, storytold/winit), as craft-libs pins them. [patch.crates-io] diff --git a/crates/formats/Cargo.toml b/crates/formats/Cargo.toml index ce1b8007..b62aec1b 100644 --- a/crates/formats/Cargo.toml +++ b/crates/formats/Cargo.toml @@ -11,7 +11,7 @@ workspace = true [dependencies] craft-usd.workspace = true # ICC v2 serialization prerequisite: craft-libs#1735; app colour policy stays local. -craft-cms-icc-v2 = { package = "craft-cms", version = "0.1.0", git = "https://github.com/aiongg/craft-libs", rev = "cd87dc61f77d8470b2e9e6a1236f9a84ee0a64de" } +craft-cms-icc-v2 = { package = "craft-cms", version = "0.1.0", git = "https://github.com/aiongg/craft-libs", rev = "3ad64a26ea8a72c03c416681e14f7744393790b1" } craft-materialx = { workspace = true } craft-mesh = { workspace = true } craft-mcmat = { workspace = true } @@ -25,7 +25,7 @@ image = { workspace = true } png = "0.18" bytemuck = { workspace = true, features = ["extern_crate_alloc"] } craft-image-codecs = { workspace = true } -craft-psd = { git = "https://github.com/aiongg/craft-libs", rev = "cd87dc61f77d8470b2e9e6a1236f9a84ee0a64de" } +craft-psd = { git = "https://github.com/aiongg/craft-libs", rev = "3ad64a26ea8a72c03c416681e14f7744393790b1" } flate2 = { workspace = true } half = { workspace = true } quick-xml = { workspace = true } diff --git a/crates/ui-egui/src/docking.rs b/crates/ui-egui/src/docking.rs index c30b6b6b..e7bb9497 100644 --- a/crates/ui-egui/src/docking.rs +++ b/crates/ui-egui/src/docking.rs @@ -391,9 +391,16 @@ impl Dock { pub(crate) struct LiveDock { shown: Option>, specs: Tracked, + /// The panel whose floating window takes over the held press in the next pass, with the grab point inside the window. + continue_move: Option<(Panel, egui::Vec2)>, } impl LiveDock { + /// Asks the next pass's dock to let the window holding `panel` follow the held pointer from `grab`. + pub(crate) fn hand_over(&mut self, panel: Panel, grab: egui::Vec2) { + self.continue_move = Some((panel, grab)); + } + /// The `Arc` the dock shows for `workspace`: the last one while the arrangement is the same, /// so an idle pass keeps the workspace's revision and the dock reads no spec. fn shown(&mut self, workspace: &Workspace) -> Arc { @@ -485,13 +492,18 @@ pub fn show(app: &mut TextureCraftApp, ui: &mut Ui) { let shown = app.docks.shown(&app.ui.dock.workspace); // The specs leave the app while its panels borrow it, and come back with their revision. let specs = std::mem::take(&mut app.docks.specs); + let hand_over = app.docks.continue_move.take(); // Panels arrange in a split tree around the viewport; floating title bars only move windows. // Each closable tab has its close button, as each group header had one for its shown panel. let config = DockConfig::default().new_dock_zones(false).title_bar_docks(false).tab_close_buttons(true); let output = { let tokens = Tokens::get(&context); let mut panels = Panels { app: &mut *app, tokens, layout: shown.layout().clone() }; - DockArea::new("Panels", Bind::given(Arc::clone(&shown)), &specs, &mut panels, config).show(ui) + let mut area = DockArea::new("Panels", Bind::given(Arc::clone(&shown)), &specs, &mut panels, config); + if let Some(hand_over) = hand_over { + area = area.continue_move(hand_over); + } + area.show(ui) }; app.docks.specs = specs; diff --git a/crates/ui-egui/src/file_dialogs.rs b/crates/ui-egui/src/file_dialogs.rs index b0d2dec4..468b57fd 100644 --- a/crates/ui-egui/src/file_dialogs.rs +++ b/crates/ui-egui/src/file_dialogs.rs @@ -161,6 +161,7 @@ impl TextureCraftApp { let paths = match answer { Answer::Paths(paths) => paths, + Answer::Saved { path, .. } => vec![path], Answer::Unavailable(why) => { self.toast(trf("The file dialog couldn't be shown: {error}", &[("error", &why)]), true); Vec::new() diff --git a/crates/ui-egui/src/keymap.rs b/crates/ui-egui/src/keymap.rs index 827dc7db..78ebb672 100644 --- a/crates/ui-egui/src/keymap.rs +++ b/crates/ui-egui/src/keymap.rs @@ -214,7 +214,7 @@ fn overrides(keymap: &Keymap) -> Overrides { /// The keymap with `keymap`'s shortcuts for `platform`. fn resolved(keymap: &Keymap, platform: Platform) -> craft_keymap::Keymap { - craft_keymap::Keymap::new(catalog(), Scopes::new(), platform).with_overrides(overrides(keymap)) + craft_keymap::Keymap::new(catalog(), Scopes::new(), platform).with_overrides(overrides(keymap)).with_delete_keys(craft_keymap::DeleteKeys::Apart) } /// The resolved keymap and the dispatcher that runs it against each frame's keys. diff --git a/crates/ui-egui/src/rail_popup.rs b/crates/ui-egui/src/rail_popup.rs index 785e76b8..6c18282d 100644 --- a/crates/ui-egui/src/rail_popup.rs +++ b/crates/ui-egui/src/rail_popup.rs @@ -186,7 +186,12 @@ pub(crate) fn show(app: &mut TextureCraftApp, ctx: &egui::Context) { } else if let Some(title) = dragged_from { // The floating window opens where the popup was app.ui.rail_panel = None; - app.ui.dock.float_at(panel, shown.unwrap_or(title)); + let window = shown.unwrap_or(title); + app.ui.dock.float_at(panel, window); + // The window takes over the held press in the next pass, so the drag carries on and docks where it is released + if let Some(pointer) = ctx.input(|input| input.pointer.latest_pos()) { + app.docks.hand_over(panel, pointer - window.min); + } } } diff --git a/crates/ui-egui/src/shortcut_dispatch.rs b/crates/ui-egui/src/shortcut_dispatch.rs index 916ae385..b09dd531 100644 --- a/crates/ui-egui/src/shortcut_dispatch.rs +++ b/crates/ui-egui/src/shortcut_dispatch.rs @@ -56,9 +56,9 @@ impl Dispatcher { match &event { Event::Key { pressed: true, repeat, .. } => { let key = key_input(&event, platform, input); - if let Some(meant) = self.layout.resolve(&key) { + if self.layout.resolve(&key).is_some() { let press = Press { input: &key, repeat: *repeat, now, active: &Active::NONE, outer: &[] }; - let hit = self.matcher.press(&self.layout, keymap, &press).filter(|hit| !delete_stand_in(hit, meant)).filter(&mut accept); + let hit = self.matcher.press(&self.layout, keymap, &press).filter(&mut accept); if let Some((j, _)) = causes[i] { caused_taken[j] = Some(hit.is_some()); } @@ -111,13 +111,6 @@ impl Dispatcher { } } -/// Whether `hit` ran a Delete binding for a Backspace press or the other way round: `Matcher` lets the two keys stand -/// for each other, while TextureCraft binds them apart (Delete removes the selected layer, Backspace a Path tool point). -fn delete_stand_in(hit: &Hit, meant: craft_keymap::Chord) -> bool { - let twins = |a: Key, b: Key| matches!((a, b), (Key::Delete, Key::Backspace) | (Key::Backspace, Key::Delete)); - twins(meant.key, hit.trigger.chord.key) -} - /// A press as [`KeyInput::from_egui`] reads it, with the Latin layout's character `input` reports /// for its key. fn key_input(event: &Event, platform: Platform, input: &InputState) -> KeyInput { @@ -246,21 +239,6 @@ mod tests { assert_eq!(input.events, [press(EguiKey::Q, egui::Modifiers::NONE), Event::Text("q".into())]); } - /// Backspace runs no Delete binding: TextureCraft binds the two keys apart. - #[test] - fn backspace_does_not_run_a_delete_binding() { - let def = CommandDef::new("layer.remove", "layer.remove", Scope::app()).with_default(Binding::parse("Delete").unwrap()); - let keymap = Keymap::new(vec![def], Scopes::new(), Platform::Windows); - let mut input = InputState::default(); - input.events = vec![press(EguiKey::Backspace, egui::Modifiers::NONE)]; - assert!(Dispatcher::default().dispatch_filtered(&mut input, &keymap, |_| true).is_empty()); - assert_eq!(input.events, [press(EguiKey::Backspace, egui::Modifiers::NONE)], "the press stays for the Path tool"); - - input.events = vec![press(EguiKey::Delete, egui::Modifiers::NONE)]; - let hits = Dispatcher::default().dispatch_filtered(&mut input, &keymap, |_| true); - assert_eq!(hits.iter().map(|hit| hit.command.id.as_str()).collect::>(), ["layer.remove"]); - } - /// The desktop's Copy event runs the copy command; declined, it stays for egui. #[test] fn a_clipboard_event_runs_its_chord_unless_declined() { From dcbdd006500e03197e733b2c16965f7a79045011 Mon Sep 17 00:00:00 2001 From: aiongg Date: Tue, 24 Nov 2026 19:12:39 +0000 Subject: [PATCH 24/83] Repin craft-libs to 9fd8b0cdaa --- Cargo.lock | 90 +++++++++++++++++++-------------------- Cargo.toml | 34 +++++++-------- crates/formats/Cargo.toml | 4 +- 3 files changed, 64 insertions(+), 64 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 104a6bb8..f3335ff6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -953,7 +953,7 @@ dependencies = [ [[package]] name = "craft-appkit" version = "0.1.0" -source = "git+https://github.com/aiongg/craft-libs?rev=3ad64a26ea8a72c03c416681e14f7744393790b1#3ad64a26ea8a72c03c416681e14f7744393790b1" +source = "git+https://github.com/aiongg/craft-libs?rev=9fd8b0cdaad2b5320090f5a5892ba90fb8dab107#9fd8b0cdaad2b5320090f5a5892ba90fb8dab107" dependencies = [ "block2 0.6.2", "objc2-app-kit 0.3.2", @@ -963,7 +963,7 @@ dependencies = [ [[package]] name = "craft-atomic" version = "0.1.0" -source = "git+https://github.com/aiongg/craft-libs?rev=3ad64a26ea8a72c03c416681e14f7744393790b1#3ad64a26ea8a72c03c416681e14f7744393790b1" +source = "git+https://github.com/aiongg/craft-libs?rev=9fd8b0cdaad2b5320090f5a5892ba90fb8dab107#9fd8b0cdaad2b5320090f5a5892ba90fb8dab107" dependencies = [ "rustix 1.1.6", ] @@ -971,7 +971,7 @@ dependencies = [ [[package]] name = "craft-behavior" version = "0.1.0" -source = "git+https://github.com/aiongg/craft-libs?rev=3ad64a26ea8a72c03c416681e14f7744393790b1#3ad64a26ea8a72c03c416681e14f7744393790b1" +source = "git+https://github.com/aiongg/craft-libs?rev=9fd8b0cdaad2b5320090f5a5892ba90fb8dab107#9fd8b0cdaad2b5320090f5a5892ba90fb8dab107" dependencies = [ "accesskit", "bitflags 2.13.2", @@ -989,7 +989,7 @@ dependencies = [ [[package]] name = "craft-cloud-ui" version = "0.1.0" -source = "git+https://github.com/aiongg/craft-libs?rev=3ad64a26ea8a72c03c416681e14f7744393790b1#3ad64a26ea8a72c03c416681e14f7744393790b1" +source = "git+https://github.com/aiongg/craft-libs?rev=9fd8b0cdaad2b5320090f5a5892ba90fb8dab107#9fd8b0cdaad2b5320090f5a5892ba90fb8dab107" dependencies = [ "egui", ] @@ -997,7 +997,7 @@ dependencies = [ [[package]] name = "craft-cms" version = "0.1.0" -source = "git+https://github.com/aiongg/craft-libs?rev=3ad64a26ea8a72c03c416681e14f7744393790b1#3ad64a26ea8a72c03c416681e14f7744393790b1" +source = "git+https://github.com/aiongg/craft-libs?rev=9fd8b0cdaad2b5320090f5a5892ba90fb8dab107#9fd8b0cdaad2b5320090f5a5892ba90fb8dab107" dependencies = [ "md-5", "rayon", @@ -1006,12 +1006,12 @@ dependencies = [ [[package]] name = "craft-codepage" version = "0.1.0" -source = "git+https://github.com/aiongg/craft-libs?rev=3ad64a26ea8a72c03c416681e14f7744393790b1#3ad64a26ea8a72c03c416681e14f7744393790b1" +source = "git+https://github.com/aiongg/craft-libs?rev=9fd8b0cdaad2b5320090f5a5892ba90fb8dab107#9fd8b0cdaad2b5320090f5a5892ba90fb8dab107" [[package]] name = "craft-dds" version = "0.1.0" -source = "git+https://github.com/aiongg/craft-libs?rev=3ad64a26ea8a72c03c416681e14f7744393790b1#3ad64a26ea8a72c03c416681e14f7744393790b1" +source = "git+https://github.com/aiongg/craft-libs?rev=9fd8b0cdaad2b5320090f5a5892ba90fb8dab107#9fd8b0cdaad2b5320090f5a5892ba90fb8dab107" dependencies = [ "rayon", ] @@ -1019,7 +1019,7 @@ dependencies = [ [[package]] name = "craft-dialogs" version = "0.1.0" -source = "git+https://github.com/aiongg/craft-libs?rev=3ad64a26ea8a72c03c416681e14f7744393790b1#3ad64a26ea8a72c03c416681e14f7744393790b1" +source = "git+https://github.com/aiongg/craft-libs?rev=9fd8b0cdaad2b5320090f5a5892ba90fb8dab107#9fd8b0cdaad2b5320090f5a5892ba90fb8dab107" dependencies = [ "block2 0.6.2", "craft-atomic", @@ -1039,7 +1039,7 @@ dependencies = [ [[package]] name = "craft-docpath" version = "0.1.0" -source = "git+https://github.com/aiongg/craft-libs?rev=3ad64a26ea8a72c03c416681e14f7744393790b1#3ad64a26ea8a72c03c416681e14f7744393790b1" +source = "git+https://github.com/aiongg/craft-libs?rev=9fd8b0cdaad2b5320090f5a5892ba90fb8dab107#9fd8b0cdaad2b5320090f5a5892ba90fb8dab107" dependencies = [ "serde", ] @@ -1047,7 +1047,7 @@ dependencies = [ [[package]] name = "craft-font-catalog" version = "0.1.0" -source = "git+https://github.com/aiongg/craft-libs?rev=3ad64a26ea8a72c03c416681e14f7744393790b1#3ad64a26ea8a72c03c416681e14f7744393790b1" +source = "git+https://github.com/aiongg/craft-libs?rev=9fd8b0cdaad2b5320090f5a5892ba90fb8dab107#9fd8b0cdaad2b5320090f5a5892ba90fb8dab107" dependencies = [ "harfrust 0.13.3", "kurbo", @@ -1061,12 +1061,12 @@ dependencies = [ [[package]] name = "craft-fonts-build" version = "0.1.0" -source = "git+https://github.com/aiongg/craft-libs?rev=3ad64a26ea8a72c03c416681e14f7744393790b1#3ad64a26ea8a72c03c416681e14f7744393790b1" +source = "git+https://github.com/aiongg/craft-libs?rev=9fd8b0cdaad2b5320090f5a5892ba90fb8dab107#9fd8b0cdaad2b5320090f5a5892ba90fb8dab107" [[package]] name = "craft-host" version = "0.1.0" -source = "git+https://github.com/aiongg/craft-libs?rev=3ad64a26ea8a72c03c416681e14f7744393790b1#3ad64a26ea8a72c03c416681e14f7744393790b1" +source = "git+https://github.com/aiongg/craft-libs?rev=9fd8b0cdaad2b5320090f5a5892ba90fb8dab107#9fd8b0cdaad2b5320090f5a5892ba90fb8dab107" dependencies = [ "bitflags 2.13.2", "craft-i18n", @@ -1079,7 +1079,7 @@ dependencies = [ [[package]] name = "craft-i18n" version = "0.1.0" -source = "git+https://github.com/aiongg/craft-libs?rev=3ad64a26ea8a72c03c416681e14f7744393790b1#3ad64a26ea8a72c03c416681e14f7744393790b1" +source = "git+https://github.com/aiongg/craft-libs?rev=9fd8b0cdaad2b5320090f5a5892ba90fb8dab107#9fd8b0cdaad2b5320090f5a5892ba90fb8dab107" dependencies = [ "chrono", "fixed_decimal", @@ -1107,7 +1107,7 @@ dependencies = [ [[package]] name = "craft-image-codecs" version = "0.1.0" -source = "git+https://github.com/aiongg/craft-libs?rev=3ad64a26ea8a72c03c416681e14f7744393790b1#3ad64a26ea8a72c03c416681e14f7744393790b1" +source = "git+https://github.com/aiongg/craft-libs?rev=9fd8b0cdaad2b5320090f5a5892ba90fb8dab107#9fd8b0cdaad2b5320090f5a5892ba90fb8dab107" dependencies = [ "craft-dds", "craft-jpeg", @@ -1134,7 +1134,7 @@ dependencies = [ [[package]] name = "craft-jpeg" version = "0.1.0" -source = "git+https://github.com/aiongg/craft-libs?rev=3ad64a26ea8a72c03c416681e14f7744393790b1#3ad64a26ea8a72c03c416681e14f7744393790b1" +source = "git+https://github.com/aiongg/craft-libs?rev=9fd8b0cdaad2b5320090f5a5892ba90fb8dab107#9fd8b0cdaad2b5320090f5a5892ba90fb8dab107" dependencies = [ "thiserror 2.0.21", ] @@ -1142,7 +1142,7 @@ dependencies = [ [[package]] name = "craft-keymap" version = "0.1.0" -source = "git+https://github.com/aiongg/craft-libs?rev=3ad64a26ea8a72c03c416681e14f7744393790b1#3ad64a26ea8a72c03c416681e14f7744393790b1" +source = "git+https://github.com/aiongg/craft-libs?rev=9fd8b0cdaad2b5320090f5a5892ba90fb8dab107#9fd8b0cdaad2b5320090f5a5892ba90fb8dab107" dependencies = [ "craft-host", "craft-i18n", @@ -1157,7 +1157,7 @@ dependencies = [ [[package]] name = "craft-materialx" version = "0.1.0" -source = "git+https://github.com/aiongg/craft-libs?rev=3ad64a26ea8a72c03c416681e14f7744393790b1#3ad64a26ea8a72c03c416681e14f7744393790b1" +source = "git+https://github.com/aiongg/craft-libs?rev=9fd8b0cdaad2b5320090f5a5892ba90fb8dab107#9fd8b0cdaad2b5320090f5a5892ba90fb8dab107" dependencies = [ "craft-xml", "thiserror 2.0.21", @@ -1166,7 +1166,7 @@ dependencies = [ [[package]] name = "craft-mcmat" version = "0.1.0" -source = "git+https://github.com/aiongg/craft-libs?rev=3ad64a26ea8a72c03c416681e14f7744393790b1#3ad64a26ea8a72c03c416681e14f7744393790b1" +source = "git+https://github.com/aiongg/craft-libs?rev=9fd8b0cdaad2b5320090f5a5892ba90fb8dab107#9fd8b0cdaad2b5320090f5a5892ba90fb8dab107" dependencies = [ "craft-zip", "serde", @@ -1177,7 +1177,7 @@ dependencies = [ [[package]] name = "craft-menu" version = "0.1.0" -source = "git+https://github.com/aiongg/craft-libs?rev=3ad64a26ea8a72c03c416681e14f7744393790b1#3ad64a26ea8a72c03c416681e14f7744393790b1" +source = "git+https://github.com/aiongg/craft-libs?rev=9fd8b0cdaad2b5320090f5a5892ba90fb8dab107#9fd8b0cdaad2b5320090f5a5892ba90fb8dab107" dependencies = [ "craft-behavior", "craft-host", @@ -1195,7 +1195,7 @@ dependencies = [ [[package]] name = "craft-mesh" version = "0.1.0" -source = "git+https://github.com/aiongg/craft-libs?rev=3ad64a26ea8a72c03c416681e14f7744393790b1#3ad64a26ea8a72c03c416681e14f7744393790b1" +source = "git+https://github.com/aiongg/craft-libs?rev=9fd8b0cdaad2b5320090f5a5892ba90fb8dab107#9fd8b0cdaad2b5320090f5a5892ba90fb8dab107" dependencies = [ "craft-xml", "craft-zip", @@ -1206,7 +1206,7 @@ dependencies = [ [[package]] name = "craft-metadata" version = "0.1.0" -source = "git+https://github.com/aiongg/craft-libs?rev=3ad64a26ea8a72c03c416681e14f7744393790b1#3ad64a26ea8a72c03c416681e14f7744393790b1" +source = "git+https://github.com/aiongg/craft-libs?rev=9fd8b0cdaad2b5320090f5a5892ba90fb8dab107#9fd8b0cdaad2b5320090f5a5892ba90fb8dab107" dependencies = [ "brotli-decompressor", "chrono", @@ -1218,7 +1218,7 @@ dependencies = [ [[package]] name = "craft-pdf" version = "0.1.0" -source = "git+https://github.com/aiongg/craft-libs?rev=3ad64a26ea8a72c03c416681e14f7744393790b1#3ad64a26ea8a72c03c416681e14f7744393790b1" +source = "git+https://github.com/aiongg/craft-libs?rev=9fd8b0cdaad2b5320090f5a5892ba90fb8dab107#9fd8b0cdaad2b5320090f5a5892ba90fb8dab107" dependencies = [ "serde", ] @@ -1226,7 +1226,7 @@ dependencies = [ [[package]] name = "craft-platform" version = "0.1.0" -source = "git+https://github.com/aiongg/craft-libs?rev=3ad64a26ea8a72c03c416681e14f7744393790b1#3ad64a26ea8a72c03c416681e14f7744393790b1" +source = "git+https://github.com/aiongg/craft-libs?rev=9fd8b0cdaad2b5320090f5a5892ba90fb8dab107#9fd8b0cdaad2b5320090f5a5892ba90fb8dab107" dependencies = [ "async-channel", "async-io", @@ -1257,7 +1257,7 @@ dependencies = [ [[package]] name = "craft-psd" version = "0.1.0" -source = "git+https://github.com/aiongg/craft-libs?rev=3ad64a26ea8a72c03c416681e14f7744393790b1#3ad64a26ea8a72c03c416681e14f7744393790b1" +source = "git+https://github.com/aiongg/craft-libs?rev=9fd8b0cdaad2b5320090f5a5892ba90fb8dab107#9fd8b0cdaad2b5320090f5a5892ba90fb8dab107" dependencies = [ "encoding_rs", "flate2", @@ -1268,7 +1268,7 @@ dependencies = [ [[package]] name = "craft-quit" version = "0.1.0" -source = "git+https://github.com/aiongg/craft-libs?rev=3ad64a26ea8a72c03c416681e14f7744393790b1#3ad64a26ea8a72c03c416681e14f7744393790b1" +source = "git+https://github.com/aiongg/craft-libs?rev=9fd8b0cdaad2b5320090f5a5892ba90fb8dab107#9fd8b0cdaad2b5320090f5a5892ba90fb8dab107" dependencies = [ "dispatch2", "egui", @@ -1281,7 +1281,7 @@ dependencies = [ [[package]] name = "craft-settings" version = "0.1.0" -source = "git+https://github.com/aiongg/craft-libs?rev=3ad64a26ea8a72c03c416681e14f7744393790b1#3ad64a26ea8a72c03c416681e14f7744393790b1" +source = "git+https://github.com/aiongg/craft-libs?rev=9fd8b0cdaad2b5320090f5a5892ba90fb8dab107#9fd8b0cdaad2b5320090f5a5892ba90fb8dab107" dependencies = [ "craft-atomic", "craft-host", @@ -1298,7 +1298,7 @@ dependencies = [ [[package]] name = "craft-svg" version = "0.1.0" -source = "git+https://github.com/aiongg/craft-libs?rev=3ad64a26ea8a72c03c416681e14f7744393790b1#3ad64a26ea8a72c03c416681e14f7744393790b1" +source = "git+https://github.com/aiongg/craft-libs?rev=9fd8b0cdaad2b5320090f5a5892ba90fb8dab107#9fd8b0cdaad2b5320090f5a5892ba90fb8dab107" dependencies = [ "craft-xml", "flate2", @@ -1315,7 +1315,7 @@ dependencies = [ [[package]] name = "craft-tcraft" version = "0.1.0" -source = "git+https://github.com/aiongg/craft-libs?rev=3ad64a26ea8a72c03c416681e14f7744393790b1#3ad64a26ea8a72c03c416681e14f7744393790b1" +source = "git+https://github.com/aiongg/craft-libs?rev=9fd8b0cdaad2b5320090f5a5892ba90fb8dab107#9fd8b0cdaad2b5320090f5a5892ba90fb8dab107" dependencies = [ "craft-zip", "serde", @@ -1326,7 +1326,7 @@ dependencies = [ [[package]] name = "craft-theme" version = "0.1.0" -source = "git+https://github.com/aiongg/craft-libs?rev=3ad64a26ea8a72c03c416681e14f7744393790b1#3ad64a26ea8a72c03c416681e14f7744393790b1" +source = "git+https://github.com/aiongg/craft-libs?rev=9fd8b0cdaad2b5320090f5a5892ba90fb8dab107#9fd8b0cdaad2b5320090f5a5892ba90fb8dab107" dependencies = [ "bitflags 2.13.2", "craft-tracked", @@ -1341,7 +1341,7 @@ dependencies = [ [[package]] name = "craft-tiff" version = "0.1.0" -source = "git+https://github.com/aiongg/craft-libs?rev=3ad64a26ea8a72c03c416681e14f7744393790b1#3ad64a26ea8a72c03c416681e14f7744393790b1" +source = "git+https://github.com/aiongg/craft-libs?rev=9fd8b0cdaad2b5320090f5a5892ba90fb8dab107#9fd8b0cdaad2b5320090f5a5892ba90fb8dab107" dependencies = [ "serde", "thiserror 2.0.21", @@ -1351,12 +1351,12 @@ dependencies = [ [[package]] name = "craft-tracked" version = "0.1.0" -source = "git+https://github.com/aiongg/craft-libs?rev=3ad64a26ea8a72c03c416681e14f7744393790b1#3ad64a26ea8a72c03c416681e14f7744393790b1" +source = "git+https://github.com/aiongg/craft-libs?rev=9fd8b0cdaad2b5320090f5a5892ba90fb8dab107#9fd8b0cdaad2b5320090f5a5892ba90fb8dab107" [[package]] name = "craft-ui" version = "0.1.0" -source = "git+https://github.com/aiongg/craft-libs?rev=3ad64a26ea8a72c03c416681e14f7744393790b1#3ad64a26ea8a72c03c416681e14f7744393790b1" +source = "git+https://github.com/aiongg/craft-libs?rev=9fd8b0cdaad2b5320090f5a5892ba90fb8dab107#9fd8b0cdaad2b5320090f5a5892ba90fb8dab107" dependencies = [ "craft-cloud-ui", "craft-ui-canvas", @@ -1370,7 +1370,7 @@ dependencies = [ [[package]] name = "craft-ui-canvas" version = "0.1.0" -source = "git+https://github.com/aiongg/craft-libs?rev=3ad64a26ea8a72c03c416681e14f7744393790b1#3ad64a26ea8a72c03c416681e14f7744393790b1" +source = "git+https://github.com/aiongg/craft-libs?rev=9fd8b0cdaad2b5320090f5a5892ba90fb8dab107#9fd8b0cdaad2b5320090f5a5892ba90fb8dab107" dependencies = [ "craft-behavior", "craft-i18n", @@ -1386,7 +1386,7 @@ dependencies = [ [[package]] name = "craft-ui-contract" version = "0.1.0" -source = "git+https://github.com/aiongg/craft-libs?rev=3ad64a26ea8a72c03c416681e14f7744393790b1#3ad64a26ea8a72c03c416681e14f7744393790b1" +source = "git+https://github.com/aiongg/craft-libs?rev=9fd8b0cdaad2b5320090f5a5892ba90fb8dab107#9fd8b0cdaad2b5320090f5a5892ba90fb8dab107" dependencies = [ "accesskit", "craft-behavior", @@ -1424,7 +1424,7 @@ dependencies = [ [[package]] name = "craft-ui-macros" version = "0.1.0" -source = "git+https://github.com/aiongg/craft-libs?rev=3ad64a26ea8a72c03c416681e14f7744393790b1#3ad64a26ea8a72c03c416681e14f7744393790b1" +source = "git+https://github.com/aiongg/craft-libs?rev=9fd8b0cdaad2b5320090f5a5892ba90fb8dab107#9fd8b0cdaad2b5320090f5a5892ba90fb8dab107" dependencies = [ "proc-macro-crate", "proc-macro2", @@ -1435,7 +1435,7 @@ dependencies = [ [[package]] name = "craft-ui-panels" version = "0.1.0" -source = "git+https://github.com/aiongg/craft-libs?rev=3ad64a26ea8a72c03c416681e14f7744393790b1#3ad64a26ea8a72c03c416681e14f7744393790b1" +source = "git+https://github.com/aiongg/craft-libs?rev=9fd8b0cdaad2b5320090f5a5892ba90fb8dab107#9fd8b0cdaad2b5320090f5a5892ba90fb8dab107" dependencies = [ "craft-behavior", "craft-host", @@ -1453,7 +1453,7 @@ dependencies = [ [[package]] name = "craft-ui-patterns" version = "0.1.0" -source = "git+https://github.com/aiongg/craft-libs?rev=3ad64a26ea8a72c03c416681e14f7744393790b1#3ad64a26ea8a72c03c416681e14f7744393790b1" +source = "git+https://github.com/aiongg/craft-libs?rev=9fd8b0cdaad2b5320090f5a5892ba90fb8dab107#9fd8b0cdaad2b5320090f5a5892ba90fb8dab107" dependencies = [ "craft-behavior", "craft-host", @@ -1474,7 +1474,7 @@ dependencies = [ [[package]] name = "craft-ui-shell" version = "0.1.0" -source = "git+https://github.com/aiongg/craft-libs?rev=3ad64a26ea8a72c03c416681e14f7744393790b1#3ad64a26ea8a72c03c416681e14f7744393790b1" +source = "git+https://github.com/aiongg/craft-libs?rev=9fd8b0cdaad2b5320090f5a5892ba90fb8dab107#9fd8b0cdaad2b5320090f5a5892ba90fb8dab107" dependencies = [ "craft-behavior", "craft-host", @@ -1494,7 +1494,7 @@ dependencies = [ [[package]] name = "craft-ui-widgets" version = "0.1.0" -source = "git+https://github.com/aiongg/craft-libs?rev=3ad64a26ea8a72c03c416681e14f7744393790b1#3ad64a26ea8a72c03c416681e14f7744393790b1" +source = "git+https://github.com/aiongg/craft-libs?rev=9fd8b0cdaad2b5320090f5a5892ba90fb8dab107#9fd8b0cdaad2b5320090f5a5892ba90fb8dab107" dependencies = [ "craft-behavior", "craft-host", @@ -1513,7 +1513,7 @@ dependencies = [ [[package]] name = "craft-update" version = "0.1.0" -source = "git+https://github.com/aiongg/craft-libs?rev=3ad64a26ea8a72c03c416681e14f7744393790b1#3ad64a26ea8a72c03c416681e14f7744393790b1" +source = "git+https://github.com/aiongg/craft-libs?rev=9fd8b0cdaad2b5320090f5a5892ba90fb8dab107#9fd8b0cdaad2b5320090f5a5892ba90fb8dab107" dependencies = [ "chrono", "craft-host", @@ -1542,7 +1542,7 @@ dependencies = [ [[package]] name = "craft-usd" version = "0.1.0" -source = "git+https://github.com/aiongg/craft-libs?rev=3ad64a26ea8a72c03c416681e14f7744393790b1#3ad64a26ea8a72c03c416681e14f7744393790b1" +source = "git+https://github.com/aiongg/craft-libs?rev=9fd8b0cdaad2b5320090f5a5892ba90fb8dab107#9fd8b0cdaad2b5320090f5a5892ba90fb8dab107" dependencies = [ "half", "lz4_flex", @@ -1552,7 +1552,7 @@ dependencies = [ [[package]] name = "craft-win32" version = "0.1.0" -source = "git+https://github.com/aiongg/craft-libs?rev=3ad64a26ea8a72c03c416681e14f7744393790b1#3ad64a26ea8a72c03c416681e14f7744393790b1" +source = "git+https://github.com/aiongg/craft-libs?rev=9fd8b0cdaad2b5320090f5a5892ba90fb8dab107#9fd8b0cdaad2b5320090f5a5892ba90fb8dab107" dependencies = [ "winsafe", ] @@ -1560,7 +1560,7 @@ dependencies = [ [[package]] name = "craft-window" version = "0.1.0" -source = "git+https://github.com/aiongg/craft-libs?rev=3ad64a26ea8a72c03c416681e14f7744393790b1#3ad64a26ea8a72c03c416681e14f7744393790b1" +source = "git+https://github.com/aiongg/craft-libs?rev=9fd8b0cdaad2b5320090f5a5892ba90fb8dab107#9fd8b0cdaad2b5320090f5a5892ba90fb8dab107" dependencies = [ "craft-appkit", "craft-atomic", @@ -1584,7 +1584,7 @@ dependencies = [ [[package]] name = "craft-xml" version = "0.1.0" -source = "git+https://github.com/aiongg/craft-libs?rev=3ad64a26ea8a72c03c416681e14f7744393790b1#3ad64a26ea8a72c03c416681e14f7744393790b1" +source = "git+https://github.com/aiongg/craft-libs?rev=9fd8b0cdaad2b5320090f5a5892ba90fb8dab107#9fd8b0cdaad2b5320090f5a5892ba90fb8dab107" dependencies = [ "quick-xml 0.41.0", "serde", @@ -1594,7 +1594,7 @@ dependencies = [ [[package]] name = "craft-zip" version = "0.1.0" -source = "git+https://github.com/aiongg/craft-libs?rev=3ad64a26ea8a72c03c416681e14f7744393790b1#3ad64a26ea8a72c03c416681e14f7744393790b1" +source = "git+https://github.com/aiongg/craft-libs?rev=9fd8b0cdaad2b5320090f5a5892ba90fb8dab107#9fd8b0cdaad2b5320090f5a5892ba90fb8dab107" dependencies = [ "flate2", "thiserror 2.0.21", diff --git a/Cargo.toml b/Cargo.toml index 97ecf3e8..35144eab 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -10,7 +10,7 @@ edition = "2024" license = "MIT OR Apache-2.0" [workspace.dependencies] -craft-usd = { version = "0.1.0", git = "https://github.com/aiongg/craft-libs", rev = "3ad64a26ea8a72c03c416681e14f7744393790b1" } +craft-usd = { version = "0.1.0", git = "https://github.com/aiongg/craft-libs", rev = "9fd8b0cdaad2b5320090f5a5892ba90fb8dab107" } # internal texturecraft-core = { path = "crates/core" } texturecraft-texel = { path = "crates/texel" } @@ -41,7 +41,7 @@ skrifa = { version = "0.44", default-features = false, features = ["std"] } epaint_default_fonts = "0.37" log = "0.4" image = { version = "0.25", default-features = false, features = ["png", "jpeg", "tga", "tiff", "exr", "hdr", "bmp", "webp"] } -craft-image-codecs = { git = "https://github.com/aiongg/craft-libs", rev = "3ad64a26ea8a72c03c416681e14f7744393790b1" } +craft-image-codecs = { git = "https://github.com/aiongg/craft-libs", rev = "9fd8b0cdaad2b5320090f5a5892ba90fb8dab107" } half = "2" exr = { version = "1.73", default-features = false } eframe = { version = "0.37", default-features = false } @@ -64,28 +64,28 @@ rustix = { version = "1", default-features = false, features = ["std", "fs", "pr # Shared Craft egui components (widget palette, icon buttons, panel docking): storytold/craft-libs, # MIT OR Apache-2.0, pinned to one rev. # Shared catalog lookup, pinned with the other Craft libraries. -craft-i18n = { git = "https://github.com/aiongg/craft-libs", rev = "3ad64a26ea8a72c03c416681e14f7744393790b1" } -craft-ui = { git = "https://github.com/aiongg/craft-libs", rev = "3ad64a26ea8a72c03c416681e14f7744393790b1" } -craft-behavior = { git = "https://github.com/aiongg/craft-libs", rev = "3ad64a26ea8a72c03c416681e14f7744393790b1" } -craft-materialx = { git = "https://github.com/aiongg/craft-libs", rev = "3ad64a26ea8a72c03c416681e14f7744393790b1" } -craft-tcraft = { git = "https://github.com/aiongg/craft-libs", rev = "3ad64a26ea8a72c03c416681e14f7744393790b1" } -craft-zip = { git = "https://github.com/aiongg/craft-libs", rev = "3ad64a26ea8a72c03c416681e14f7744393790b1" } -craft-mesh = { git = "https://github.com/aiongg/craft-libs", rev = "3ad64a26ea8a72c03c416681e14f7744393790b1", default-features = false, features = ["stl", "ply", "fbx", "obj", "gltf", "dae", "abc"] } -craft-mcmat = { git = "https://github.com/aiongg/craft-libs", rev = "3ad64a26ea8a72c03c416681e14f7744393790b1" } +craft-i18n = { git = "https://github.com/aiongg/craft-libs", rev = "9fd8b0cdaad2b5320090f5a5892ba90fb8dab107" } +craft-ui = { git = "https://github.com/aiongg/craft-libs", rev = "9fd8b0cdaad2b5320090f5a5892ba90fb8dab107" } +craft-behavior = { git = "https://github.com/aiongg/craft-libs", rev = "9fd8b0cdaad2b5320090f5a5892ba90fb8dab107" } +craft-materialx = { git = "https://github.com/aiongg/craft-libs", rev = "9fd8b0cdaad2b5320090f5a5892ba90fb8dab107" } +craft-tcraft = { git = "https://github.com/aiongg/craft-libs", rev = "9fd8b0cdaad2b5320090f5a5892ba90fb8dab107" } +craft-zip = { git = "https://github.com/aiongg/craft-libs", rev = "9fd8b0cdaad2b5320090f5a5892ba90fb8dab107" } +craft-mesh = { git = "https://github.com/aiongg/craft-libs", rev = "9fd8b0cdaad2b5320090f5a5892ba90fb8dab107", default-features = false, features = ["stl", "ply", "fbx", "obj", "gltf", "dae", "abc"] } +craft-mcmat = { git = "https://github.com/aiongg/craft-libs", rev = "9fd8b0cdaad2b5320090f5a5892ba90fb8dab107" } # Who draws the window frame, and the app-drawn strip as the title bar (crates/ui-egui/src/titlebar.rs). -craft-window = { git = "https://github.com/aiongg/craft-libs", rev = "3ad64a26ea8a72c03c416681e14f7744393790b1", features = ["ui"] } +craft-window = { git = "https://github.com/aiongg/craft-libs", rev = "9fd8b0cdaad2b5320090f5a5892ba90fb8dab107", features = ["ui"] } # Release checks, the update prompt and the update helper (crates/ui-egui/src/updates_ui.rs). -craft-update = { git = "https://github.com/aiongg/craft-libs", rev = "3ad64a26ea8a72c03c416681e14f7744393790b1", features = ["ui"] } +craft-update = { git = "https://github.com/aiongg/craft-libs", rev = "9fd8b0cdaad2b5320090f5a5892ba90fb8dab107", features = ["ui"] } # File dialogs that never block the frame (crates/ui-egui/src/file_dialogs.rs). -craft-dialogs = { git = "https://github.com/aiongg/craft-libs", rev = "3ad64a26ea8a72c03c416681e14f7744393790b1" } +craft-dialogs = { git = "https://github.com/aiongg/craft-libs", rev = "9fd8b0cdaad2b5320090f5a5892ba90fb8dab107" } # Shortcut chords, lookup and dispatch (crates/ui-egui/src/keymap.rs). -craft-keymap = { git = "https://github.com/aiongg/craft-libs", rev = "3ad64a26ea8a72c03c416681e14f7744393790b1", features = ["egui"] } +craft-keymap = { git = "https://github.com/aiongg/craft-libs", rev = "9fd8b0cdaad2b5320090f5a5892ba90fb8dab107", features = ["egui"] } # The macOS app menu whose Quit asks about unsaved changes (apps/texturecraft/src/main.rs). -craft-menu = { git = "https://github.com/aiongg/craft-libs", rev = "3ad64a26ea8a72c03c416681e14f7744393790b1" } +craft-menu = { git = "https://github.com/aiongg/craft-libs", rev = "9fd8b0cdaad2b5320090f5a5892ba90fb8dab107" } # The UI runtime's host: who the app is to the framework's dialogs (crates/ui-egui/src/framework.rs). -craft-host = { git = "https://github.com/aiongg/craft-libs", rev = "3ad64a26ea8a72c03c416681e14f7744393790b1" } +craft-host = { git = "https://github.com/aiongg/craft-libs", rev = "9fd8b0cdaad2b5320090f5a5892ba90fb8dab107" } # The theme mode the app hands the runtime (crates/ui-egui/src/framework.rs). -craft-theme = { git = "https://github.com/aiongg/craft-libs", rev = "3ad64a26ea8a72c03c416681e14f7744393790b1" } +craft-theme = { git = "https://github.com/aiongg/craft-libs", rev = "9fd8b0cdaad2b5320090f5a5892ba90fb8dab107" } # egui 0.37 and winit: the suite's forks (storytold/egui, storytold/winit), as craft-libs pins them. [patch.crates-io] diff --git a/crates/formats/Cargo.toml b/crates/formats/Cargo.toml index b62aec1b..f942ab54 100644 --- a/crates/formats/Cargo.toml +++ b/crates/formats/Cargo.toml @@ -11,7 +11,7 @@ workspace = true [dependencies] craft-usd.workspace = true # ICC v2 serialization prerequisite: craft-libs#1735; app colour policy stays local. -craft-cms-icc-v2 = { package = "craft-cms", version = "0.1.0", git = "https://github.com/aiongg/craft-libs", rev = "3ad64a26ea8a72c03c416681e14f7744393790b1" } +craft-cms-icc-v2 = { package = "craft-cms", version = "0.1.0", git = "https://github.com/aiongg/craft-libs", rev = "9fd8b0cdaad2b5320090f5a5892ba90fb8dab107" } craft-materialx = { workspace = true } craft-mesh = { workspace = true } craft-mcmat = { workspace = true } @@ -25,7 +25,7 @@ image = { workspace = true } png = "0.18" bytemuck = { workspace = true, features = ["extern_crate_alloc"] } craft-image-codecs = { workspace = true } -craft-psd = { git = "https://github.com/aiongg/craft-libs", rev = "3ad64a26ea8a72c03c416681e14f7744393790b1" } +craft-psd = { git = "https://github.com/aiongg/craft-libs", rev = "9fd8b0cdaad2b5320090f5a5892ba90fb8dab107" } flate2 = { workspace = true } half = { workspace = true } quick-xml = { workspace = true } From f86ed91063813c1301cfba71520a11a9eb5a15d0 Mon Sep 17 00:00:00 2001 From: aiongg Date: Tue, 24 Nov 2026 20:15:56 +0000 Subject: [PATCH 25/83] Repin craft-libs to 283490a083: a rail popup dragged onto a tab strip docks its panel --- Cargo.lock | 90 +++++++++++++++++++-------------------- Cargo.toml | 34 +++++++-------- crates/formats/Cargo.toml | 4 +- 3 files changed, 64 insertions(+), 64 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index f3335ff6..0fe9764d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -953,7 +953,7 @@ dependencies = [ [[package]] name = "craft-appkit" version = "0.1.0" -source = "git+https://github.com/aiongg/craft-libs?rev=9fd8b0cdaad2b5320090f5a5892ba90fb8dab107#9fd8b0cdaad2b5320090f5a5892ba90fb8dab107" +source = "git+https://github.com/aiongg/craft-libs?rev=283490a0833e37cc748d29711ff73f81f091e373#283490a0833e37cc748d29711ff73f81f091e373" dependencies = [ "block2 0.6.2", "objc2-app-kit 0.3.2", @@ -963,7 +963,7 @@ dependencies = [ [[package]] name = "craft-atomic" version = "0.1.0" -source = "git+https://github.com/aiongg/craft-libs?rev=9fd8b0cdaad2b5320090f5a5892ba90fb8dab107#9fd8b0cdaad2b5320090f5a5892ba90fb8dab107" +source = "git+https://github.com/aiongg/craft-libs?rev=283490a0833e37cc748d29711ff73f81f091e373#283490a0833e37cc748d29711ff73f81f091e373" dependencies = [ "rustix 1.1.6", ] @@ -971,7 +971,7 @@ dependencies = [ [[package]] name = "craft-behavior" version = "0.1.0" -source = "git+https://github.com/aiongg/craft-libs?rev=9fd8b0cdaad2b5320090f5a5892ba90fb8dab107#9fd8b0cdaad2b5320090f5a5892ba90fb8dab107" +source = "git+https://github.com/aiongg/craft-libs?rev=283490a0833e37cc748d29711ff73f81f091e373#283490a0833e37cc748d29711ff73f81f091e373" dependencies = [ "accesskit", "bitflags 2.13.2", @@ -989,7 +989,7 @@ dependencies = [ [[package]] name = "craft-cloud-ui" version = "0.1.0" -source = "git+https://github.com/aiongg/craft-libs?rev=9fd8b0cdaad2b5320090f5a5892ba90fb8dab107#9fd8b0cdaad2b5320090f5a5892ba90fb8dab107" +source = "git+https://github.com/aiongg/craft-libs?rev=283490a0833e37cc748d29711ff73f81f091e373#283490a0833e37cc748d29711ff73f81f091e373" dependencies = [ "egui", ] @@ -997,7 +997,7 @@ dependencies = [ [[package]] name = "craft-cms" version = "0.1.0" -source = "git+https://github.com/aiongg/craft-libs?rev=9fd8b0cdaad2b5320090f5a5892ba90fb8dab107#9fd8b0cdaad2b5320090f5a5892ba90fb8dab107" +source = "git+https://github.com/aiongg/craft-libs?rev=283490a0833e37cc748d29711ff73f81f091e373#283490a0833e37cc748d29711ff73f81f091e373" dependencies = [ "md-5", "rayon", @@ -1006,12 +1006,12 @@ dependencies = [ [[package]] name = "craft-codepage" version = "0.1.0" -source = "git+https://github.com/aiongg/craft-libs?rev=9fd8b0cdaad2b5320090f5a5892ba90fb8dab107#9fd8b0cdaad2b5320090f5a5892ba90fb8dab107" +source = "git+https://github.com/aiongg/craft-libs?rev=283490a0833e37cc748d29711ff73f81f091e373#283490a0833e37cc748d29711ff73f81f091e373" [[package]] name = "craft-dds" version = "0.1.0" -source = "git+https://github.com/aiongg/craft-libs?rev=9fd8b0cdaad2b5320090f5a5892ba90fb8dab107#9fd8b0cdaad2b5320090f5a5892ba90fb8dab107" +source = "git+https://github.com/aiongg/craft-libs?rev=283490a0833e37cc748d29711ff73f81f091e373#283490a0833e37cc748d29711ff73f81f091e373" dependencies = [ "rayon", ] @@ -1019,7 +1019,7 @@ dependencies = [ [[package]] name = "craft-dialogs" version = "0.1.0" -source = "git+https://github.com/aiongg/craft-libs?rev=9fd8b0cdaad2b5320090f5a5892ba90fb8dab107#9fd8b0cdaad2b5320090f5a5892ba90fb8dab107" +source = "git+https://github.com/aiongg/craft-libs?rev=283490a0833e37cc748d29711ff73f81f091e373#283490a0833e37cc748d29711ff73f81f091e373" dependencies = [ "block2 0.6.2", "craft-atomic", @@ -1039,7 +1039,7 @@ dependencies = [ [[package]] name = "craft-docpath" version = "0.1.0" -source = "git+https://github.com/aiongg/craft-libs?rev=9fd8b0cdaad2b5320090f5a5892ba90fb8dab107#9fd8b0cdaad2b5320090f5a5892ba90fb8dab107" +source = "git+https://github.com/aiongg/craft-libs?rev=283490a0833e37cc748d29711ff73f81f091e373#283490a0833e37cc748d29711ff73f81f091e373" dependencies = [ "serde", ] @@ -1047,7 +1047,7 @@ dependencies = [ [[package]] name = "craft-font-catalog" version = "0.1.0" -source = "git+https://github.com/aiongg/craft-libs?rev=9fd8b0cdaad2b5320090f5a5892ba90fb8dab107#9fd8b0cdaad2b5320090f5a5892ba90fb8dab107" +source = "git+https://github.com/aiongg/craft-libs?rev=283490a0833e37cc748d29711ff73f81f091e373#283490a0833e37cc748d29711ff73f81f091e373" dependencies = [ "harfrust 0.13.3", "kurbo", @@ -1061,12 +1061,12 @@ dependencies = [ [[package]] name = "craft-fonts-build" version = "0.1.0" -source = "git+https://github.com/aiongg/craft-libs?rev=9fd8b0cdaad2b5320090f5a5892ba90fb8dab107#9fd8b0cdaad2b5320090f5a5892ba90fb8dab107" +source = "git+https://github.com/aiongg/craft-libs?rev=283490a0833e37cc748d29711ff73f81f091e373#283490a0833e37cc748d29711ff73f81f091e373" [[package]] name = "craft-host" version = "0.1.0" -source = "git+https://github.com/aiongg/craft-libs?rev=9fd8b0cdaad2b5320090f5a5892ba90fb8dab107#9fd8b0cdaad2b5320090f5a5892ba90fb8dab107" +source = "git+https://github.com/aiongg/craft-libs?rev=283490a0833e37cc748d29711ff73f81f091e373#283490a0833e37cc748d29711ff73f81f091e373" dependencies = [ "bitflags 2.13.2", "craft-i18n", @@ -1079,7 +1079,7 @@ dependencies = [ [[package]] name = "craft-i18n" version = "0.1.0" -source = "git+https://github.com/aiongg/craft-libs?rev=9fd8b0cdaad2b5320090f5a5892ba90fb8dab107#9fd8b0cdaad2b5320090f5a5892ba90fb8dab107" +source = "git+https://github.com/aiongg/craft-libs?rev=283490a0833e37cc748d29711ff73f81f091e373#283490a0833e37cc748d29711ff73f81f091e373" dependencies = [ "chrono", "fixed_decimal", @@ -1107,7 +1107,7 @@ dependencies = [ [[package]] name = "craft-image-codecs" version = "0.1.0" -source = "git+https://github.com/aiongg/craft-libs?rev=9fd8b0cdaad2b5320090f5a5892ba90fb8dab107#9fd8b0cdaad2b5320090f5a5892ba90fb8dab107" +source = "git+https://github.com/aiongg/craft-libs?rev=283490a0833e37cc748d29711ff73f81f091e373#283490a0833e37cc748d29711ff73f81f091e373" dependencies = [ "craft-dds", "craft-jpeg", @@ -1134,7 +1134,7 @@ dependencies = [ [[package]] name = "craft-jpeg" version = "0.1.0" -source = "git+https://github.com/aiongg/craft-libs?rev=9fd8b0cdaad2b5320090f5a5892ba90fb8dab107#9fd8b0cdaad2b5320090f5a5892ba90fb8dab107" +source = "git+https://github.com/aiongg/craft-libs?rev=283490a0833e37cc748d29711ff73f81f091e373#283490a0833e37cc748d29711ff73f81f091e373" dependencies = [ "thiserror 2.0.21", ] @@ -1142,7 +1142,7 @@ dependencies = [ [[package]] name = "craft-keymap" version = "0.1.0" -source = "git+https://github.com/aiongg/craft-libs?rev=9fd8b0cdaad2b5320090f5a5892ba90fb8dab107#9fd8b0cdaad2b5320090f5a5892ba90fb8dab107" +source = "git+https://github.com/aiongg/craft-libs?rev=283490a0833e37cc748d29711ff73f81f091e373#283490a0833e37cc748d29711ff73f81f091e373" dependencies = [ "craft-host", "craft-i18n", @@ -1157,7 +1157,7 @@ dependencies = [ [[package]] name = "craft-materialx" version = "0.1.0" -source = "git+https://github.com/aiongg/craft-libs?rev=9fd8b0cdaad2b5320090f5a5892ba90fb8dab107#9fd8b0cdaad2b5320090f5a5892ba90fb8dab107" +source = "git+https://github.com/aiongg/craft-libs?rev=283490a0833e37cc748d29711ff73f81f091e373#283490a0833e37cc748d29711ff73f81f091e373" dependencies = [ "craft-xml", "thiserror 2.0.21", @@ -1166,7 +1166,7 @@ dependencies = [ [[package]] name = "craft-mcmat" version = "0.1.0" -source = "git+https://github.com/aiongg/craft-libs?rev=9fd8b0cdaad2b5320090f5a5892ba90fb8dab107#9fd8b0cdaad2b5320090f5a5892ba90fb8dab107" +source = "git+https://github.com/aiongg/craft-libs?rev=283490a0833e37cc748d29711ff73f81f091e373#283490a0833e37cc748d29711ff73f81f091e373" dependencies = [ "craft-zip", "serde", @@ -1177,7 +1177,7 @@ dependencies = [ [[package]] name = "craft-menu" version = "0.1.0" -source = "git+https://github.com/aiongg/craft-libs?rev=9fd8b0cdaad2b5320090f5a5892ba90fb8dab107#9fd8b0cdaad2b5320090f5a5892ba90fb8dab107" +source = "git+https://github.com/aiongg/craft-libs?rev=283490a0833e37cc748d29711ff73f81f091e373#283490a0833e37cc748d29711ff73f81f091e373" dependencies = [ "craft-behavior", "craft-host", @@ -1195,7 +1195,7 @@ dependencies = [ [[package]] name = "craft-mesh" version = "0.1.0" -source = "git+https://github.com/aiongg/craft-libs?rev=9fd8b0cdaad2b5320090f5a5892ba90fb8dab107#9fd8b0cdaad2b5320090f5a5892ba90fb8dab107" +source = "git+https://github.com/aiongg/craft-libs?rev=283490a0833e37cc748d29711ff73f81f091e373#283490a0833e37cc748d29711ff73f81f091e373" dependencies = [ "craft-xml", "craft-zip", @@ -1206,7 +1206,7 @@ dependencies = [ [[package]] name = "craft-metadata" version = "0.1.0" -source = "git+https://github.com/aiongg/craft-libs?rev=9fd8b0cdaad2b5320090f5a5892ba90fb8dab107#9fd8b0cdaad2b5320090f5a5892ba90fb8dab107" +source = "git+https://github.com/aiongg/craft-libs?rev=283490a0833e37cc748d29711ff73f81f091e373#283490a0833e37cc748d29711ff73f81f091e373" dependencies = [ "brotli-decompressor", "chrono", @@ -1218,7 +1218,7 @@ dependencies = [ [[package]] name = "craft-pdf" version = "0.1.0" -source = "git+https://github.com/aiongg/craft-libs?rev=9fd8b0cdaad2b5320090f5a5892ba90fb8dab107#9fd8b0cdaad2b5320090f5a5892ba90fb8dab107" +source = "git+https://github.com/aiongg/craft-libs?rev=283490a0833e37cc748d29711ff73f81f091e373#283490a0833e37cc748d29711ff73f81f091e373" dependencies = [ "serde", ] @@ -1226,7 +1226,7 @@ dependencies = [ [[package]] name = "craft-platform" version = "0.1.0" -source = "git+https://github.com/aiongg/craft-libs?rev=9fd8b0cdaad2b5320090f5a5892ba90fb8dab107#9fd8b0cdaad2b5320090f5a5892ba90fb8dab107" +source = "git+https://github.com/aiongg/craft-libs?rev=283490a0833e37cc748d29711ff73f81f091e373#283490a0833e37cc748d29711ff73f81f091e373" dependencies = [ "async-channel", "async-io", @@ -1257,7 +1257,7 @@ dependencies = [ [[package]] name = "craft-psd" version = "0.1.0" -source = "git+https://github.com/aiongg/craft-libs?rev=9fd8b0cdaad2b5320090f5a5892ba90fb8dab107#9fd8b0cdaad2b5320090f5a5892ba90fb8dab107" +source = "git+https://github.com/aiongg/craft-libs?rev=283490a0833e37cc748d29711ff73f81f091e373#283490a0833e37cc748d29711ff73f81f091e373" dependencies = [ "encoding_rs", "flate2", @@ -1268,7 +1268,7 @@ dependencies = [ [[package]] name = "craft-quit" version = "0.1.0" -source = "git+https://github.com/aiongg/craft-libs?rev=9fd8b0cdaad2b5320090f5a5892ba90fb8dab107#9fd8b0cdaad2b5320090f5a5892ba90fb8dab107" +source = "git+https://github.com/aiongg/craft-libs?rev=283490a0833e37cc748d29711ff73f81f091e373#283490a0833e37cc748d29711ff73f81f091e373" dependencies = [ "dispatch2", "egui", @@ -1281,7 +1281,7 @@ dependencies = [ [[package]] name = "craft-settings" version = "0.1.0" -source = "git+https://github.com/aiongg/craft-libs?rev=9fd8b0cdaad2b5320090f5a5892ba90fb8dab107#9fd8b0cdaad2b5320090f5a5892ba90fb8dab107" +source = "git+https://github.com/aiongg/craft-libs?rev=283490a0833e37cc748d29711ff73f81f091e373#283490a0833e37cc748d29711ff73f81f091e373" dependencies = [ "craft-atomic", "craft-host", @@ -1298,7 +1298,7 @@ dependencies = [ [[package]] name = "craft-svg" version = "0.1.0" -source = "git+https://github.com/aiongg/craft-libs?rev=9fd8b0cdaad2b5320090f5a5892ba90fb8dab107#9fd8b0cdaad2b5320090f5a5892ba90fb8dab107" +source = "git+https://github.com/aiongg/craft-libs?rev=283490a0833e37cc748d29711ff73f81f091e373#283490a0833e37cc748d29711ff73f81f091e373" dependencies = [ "craft-xml", "flate2", @@ -1315,7 +1315,7 @@ dependencies = [ [[package]] name = "craft-tcraft" version = "0.1.0" -source = "git+https://github.com/aiongg/craft-libs?rev=9fd8b0cdaad2b5320090f5a5892ba90fb8dab107#9fd8b0cdaad2b5320090f5a5892ba90fb8dab107" +source = "git+https://github.com/aiongg/craft-libs?rev=283490a0833e37cc748d29711ff73f81f091e373#283490a0833e37cc748d29711ff73f81f091e373" dependencies = [ "craft-zip", "serde", @@ -1326,7 +1326,7 @@ dependencies = [ [[package]] name = "craft-theme" version = "0.1.0" -source = "git+https://github.com/aiongg/craft-libs?rev=9fd8b0cdaad2b5320090f5a5892ba90fb8dab107#9fd8b0cdaad2b5320090f5a5892ba90fb8dab107" +source = "git+https://github.com/aiongg/craft-libs?rev=283490a0833e37cc748d29711ff73f81f091e373#283490a0833e37cc748d29711ff73f81f091e373" dependencies = [ "bitflags 2.13.2", "craft-tracked", @@ -1341,7 +1341,7 @@ dependencies = [ [[package]] name = "craft-tiff" version = "0.1.0" -source = "git+https://github.com/aiongg/craft-libs?rev=9fd8b0cdaad2b5320090f5a5892ba90fb8dab107#9fd8b0cdaad2b5320090f5a5892ba90fb8dab107" +source = "git+https://github.com/aiongg/craft-libs?rev=283490a0833e37cc748d29711ff73f81f091e373#283490a0833e37cc748d29711ff73f81f091e373" dependencies = [ "serde", "thiserror 2.0.21", @@ -1351,12 +1351,12 @@ dependencies = [ [[package]] name = "craft-tracked" version = "0.1.0" -source = "git+https://github.com/aiongg/craft-libs?rev=9fd8b0cdaad2b5320090f5a5892ba90fb8dab107#9fd8b0cdaad2b5320090f5a5892ba90fb8dab107" +source = "git+https://github.com/aiongg/craft-libs?rev=283490a0833e37cc748d29711ff73f81f091e373#283490a0833e37cc748d29711ff73f81f091e373" [[package]] name = "craft-ui" version = "0.1.0" -source = "git+https://github.com/aiongg/craft-libs?rev=9fd8b0cdaad2b5320090f5a5892ba90fb8dab107#9fd8b0cdaad2b5320090f5a5892ba90fb8dab107" +source = "git+https://github.com/aiongg/craft-libs?rev=283490a0833e37cc748d29711ff73f81f091e373#283490a0833e37cc748d29711ff73f81f091e373" dependencies = [ "craft-cloud-ui", "craft-ui-canvas", @@ -1370,7 +1370,7 @@ dependencies = [ [[package]] name = "craft-ui-canvas" version = "0.1.0" -source = "git+https://github.com/aiongg/craft-libs?rev=9fd8b0cdaad2b5320090f5a5892ba90fb8dab107#9fd8b0cdaad2b5320090f5a5892ba90fb8dab107" +source = "git+https://github.com/aiongg/craft-libs?rev=283490a0833e37cc748d29711ff73f81f091e373#283490a0833e37cc748d29711ff73f81f091e373" dependencies = [ "craft-behavior", "craft-i18n", @@ -1386,7 +1386,7 @@ dependencies = [ [[package]] name = "craft-ui-contract" version = "0.1.0" -source = "git+https://github.com/aiongg/craft-libs?rev=9fd8b0cdaad2b5320090f5a5892ba90fb8dab107#9fd8b0cdaad2b5320090f5a5892ba90fb8dab107" +source = "git+https://github.com/aiongg/craft-libs?rev=283490a0833e37cc748d29711ff73f81f091e373#283490a0833e37cc748d29711ff73f81f091e373" dependencies = [ "accesskit", "craft-behavior", @@ -1424,7 +1424,7 @@ dependencies = [ [[package]] name = "craft-ui-macros" version = "0.1.0" -source = "git+https://github.com/aiongg/craft-libs?rev=9fd8b0cdaad2b5320090f5a5892ba90fb8dab107#9fd8b0cdaad2b5320090f5a5892ba90fb8dab107" +source = "git+https://github.com/aiongg/craft-libs?rev=283490a0833e37cc748d29711ff73f81f091e373#283490a0833e37cc748d29711ff73f81f091e373" dependencies = [ "proc-macro-crate", "proc-macro2", @@ -1435,7 +1435,7 @@ dependencies = [ [[package]] name = "craft-ui-panels" version = "0.1.0" -source = "git+https://github.com/aiongg/craft-libs?rev=9fd8b0cdaad2b5320090f5a5892ba90fb8dab107#9fd8b0cdaad2b5320090f5a5892ba90fb8dab107" +source = "git+https://github.com/aiongg/craft-libs?rev=283490a0833e37cc748d29711ff73f81f091e373#283490a0833e37cc748d29711ff73f81f091e373" dependencies = [ "craft-behavior", "craft-host", @@ -1453,7 +1453,7 @@ dependencies = [ [[package]] name = "craft-ui-patterns" version = "0.1.0" -source = "git+https://github.com/aiongg/craft-libs?rev=9fd8b0cdaad2b5320090f5a5892ba90fb8dab107#9fd8b0cdaad2b5320090f5a5892ba90fb8dab107" +source = "git+https://github.com/aiongg/craft-libs?rev=283490a0833e37cc748d29711ff73f81f091e373#283490a0833e37cc748d29711ff73f81f091e373" dependencies = [ "craft-behavior", "craft-host", @@ -1474,7 +1474,7 @@ dependencies = [ [[package]] name = "craft-ui-shell" version = "0.1.0" -source = "git+https://github.com/aiongg/craft-libs?rev=9fd8b0cdaad2b5320090f5a5892ba90fb8dab107#9fd8b0cdaad2b5320090f5a5892ba90fb8dab107" +source = "git+https://github.com/aiongg/craft-libs?rev=283490a0833e37cc748d29711ff73f81f091e373#283490a0833e37cc748d29711ff73f81f091e373" dependencies = [ "craft-behavior", "craft-host", @@ -1494,7 +1494,7 @@ dependencies = [ [[package]] name = "craft-ui-widgets" version = "0.1.0" -source = "git+https://github.com/aiongg/craft-libs?rev=9fd8b0cdaad2b5320090f5a5892ba90fb8dab107#9fd8b0cdaad2b5320090f5a5892ba90fb8dab107" +source = "git+https://github.com/aiongg/craft-libs?rev=283490a0833e37cc748d29711ff73f81f091e373#283490a0833e37cc748d29711ff73f81f091e373" dependencies = [ "craft-behavior", "craft-host", @@ -1513,7 +1513,7 @@ dependencies = [ [[package]] name = "craft-update" version = "0.1.0" -source = "git+https://github.com/aiongg/craft-libs?rev=9fd8b0cdaad2b5320090f5a5892ba90fb8dab107#9fd8b0cdaad2b5320090f5a5892ba90fb8dab107" +source = "git+https://github.com/aiongg/craft-libs?rev=283490a0833e37cc748d29711ff73f81f091e373#283490a0833e37cc748d29711ff73f81f091e373" dependencies = [ "chrono", "craft-host", @@ -1542,7 +1542,7 @@ dependencies = [ [[package]] name = "craft-usd" version = "0.1.0" -source = "git+https://github.com/aiongg/craft-libs?rev=9fd8b0cdaad2b5320090f5a5892ba90fb8dab107#9fd8b0cdaad2b5320090f5a5892ba90fb8dab107" +source = "git+https://github.com/aiongg/craft-libs?rev=283490a0833e37cc748d29711ff73f81f091e373#283490a0833e37cc748d29711ff73f81f091e373" dependencies = [ "half", "lz4_flex", @@ -1552,7 +1552,7 @@ dependencies = [ [[package]] name = "craft-win32" version = "0.1.0" -source = "git+https://github.com/aiongg/craft-libs?rev=9fd8b0cdaad2b5320090f5a5892ba90fb8dab107#9fd8b0cdaad2b5320090f5a5892ba90fb8dab107" +source = "git+https://github.com/aiongg/craft-libs?rev=283490a0833e37cc748d29711ff73f81f091e373#283490a0833e37cc748d29711ff73f81f091e373" dependencies = [ "winsafe", ] @@ -1560,7 +1560,7 @@ dependencies = [ [[package]] name = "craft-window" version = "0.1.0" -source = "git+https://github.com/aiongg/craft-libs?rev=9fd8b0cdaad2b5320090f5a5892ba90fb8dab107#9fd8b0cdaad2b5320090f5a5892ba90fb8dab107" +source = "git+https://github.com/aiongg/craft-libs?rev=283490a0833e37cc748d29711ff73f81f091e373#283490a0833e37cc748d29711ff73f81f091e373" dependencies = [ "craft-appkit", "craft-atomic", @@ -1584,7 +1584,7 @@ dependencies = [ [[package]] name = "craft-xml" version = "0.1.0" -source = "git+https://github.com/aiongg/craft-libs?rev=9fd8b0cdaad2b5320090f5a5892ba90fb8dab107#9fd8b0cdaad2b5320090f5a5892ba90fb8dab107" +source = "git+https://github.com/aiongg/craft-libs?rev=283490a0833e37cc748d29711ff73f81f091e373#283490a0833e37cc748d29711ff73f81f091e373" dependencies = [ "quick-xml 0.41.0", "serde", @@ -1594,7 +1594,7 @@ dependencies = [ [[package]] name = "craft-zip" version = "0.1.0" -source = "git+https://github.com/aiongg/craft-libs?rev=9fd8b0cdaad2b5320090f5a5892ba90fb8dab107#9fd8b0cdaad2b5320090f5a5892ba90fb8dab107" +source = "git+https://github.com/aiongg/craft-libs?rev=283490a0833e37cc748d29711ff73f81f091e373#283490a0833e37cc748d29711ff73f81f091e373" dependencies = [ "flate2", "thiserror 2.0.21", diff --git a/Cargo.toml b/Cargo.toml index 35144eab..365720e4 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -10,7 +10,7 @@ edition = "2024" license = "MIT OR Apache-2.0" [workspace.dependencies] -craft-usd = { version = "0.1.0", git = "https://github.com/aiongg/craft-libs", rev = "9fd8b0cdaad2b5320090f5a5892ba90fb8dab107" } +craft-usd = { version = "0.1.0", git = "https://github.com/aiongg/craft-libs", rev = "283490a0833e37cc748d29711ff73f81f091e373" } # internal texturecraft-core = { path = "crates/core" } texturecraft-texel = { path = "crates/texel" } @@ -41,7 +41,7 @@ skrifa = { version = "0.44", default-features = false, features = ["std"] } epaint_default_fonts = "0.37" log = "0.4" image = { version = "0.25", default-features = false, features = ["png", "jpeg", "tga", "tiff", "exr", "hdr", "bmp", "webp"] } -craft-image-codecs = { git = "https://github.com/aiongg/craft-libs", rev = "9fd8b0cdaad2b5320090f5a5892ba90fb8dab107" } +craft-image-codecs = { git = "https://github.com/aiongg/craft-libs", rev = "283490a0833e37cc748d29711ff73f81f091e373" } half = "2" exr = { version = "1.73", default-features = false } eframe = { version = "0.37", default-features = false } @@ -64,28 +64,28 @@ rustix = { version = "1", default-features = false, features = ["std", "fs", "pr # Shared Craft egui components (widget palette, icon buttons, panel docking): storytold/craft-libs, # MIT OR Apache-2.0, pinned to one rev. # Shared catalog lookup, pinned with the other Craft libraries. -craft-i18n = { git = "https://github.com/aiongg/craft-libs", rev = "9fd8b0cdaad2b5320090f5a5892ba90fb8dab107" } -craft-ui = { git = "https://github.com/aiongg/craft-libs", rev = "9fd8b0cdaad2b5320090f5a5892ba90fb8dab107" } -craft-behavior = { git = "https://github.com/aiongg/craft-libs", rev = "9fd8b0cdaad2b5320090f5a5892ba90fb8dab107" } -craft-materialx = { git = "https://github.com/aiongg/craft-libs", rev = "9fd8b0cdaad2b5320090f5a5892ba90fb8dab107" } -craft-tcraft = { git = "https://github.com/aiongg/craft-libs", rev = "9fd8b0cdaad2b5320090f5a5892ba90fb8dab107" } -craft-zip = { git = "https://github.com/aiongg/craft-libs", rev = "9fd8b0cdaad2b5320090f5a5892ba90fb8dab107" } -craft-mesh = { git = "https://github.com/aiongg/craft-libs", rev = "9fd8b0cdaad2b5320090f5a5892ba90fb8dab107", default-features = false, features = ["stl", "ply", "fbx", "obj", "gltf", "dae", "abc"] } -craft-mcmat = { git = "https://github.com/aiongg/craft-libs", rev = "9fd8b0cdaad2b5320090f5a5892ba90fb8dab107" } +craft-i18n = { git = "https://github.com/aiongg/craft-libs", rev = "283490a0833e37cc748d29711ff73f81f091e373" } +craft-ui = { git = "https://github.com/aiongg/craft-libs", rev = "283490a0833e37cc748d29711ff73f81f091e373" } +craft-behavior = { git = "https://github.com/aiongg/craft-libs", rev = "283490a0833e37cc748d29711ff73f81f091e373" } +craft-materialx = { git = "https://github.com/aiongg/craft-libs", rev = "283490a0833e37cc748d29711ff73f81f091e373" } +craft-tcraft = { git = "https://github.com/aiongg/craft-libs", rev = "283490a0833e37cc748d29711ff73f81f091e373" } +craft-zip = { git = "https://github.com/aiongg/craft-libs", rev = "283490a0833e37cc748d29711ff73f81f091e373" } +craft-mesh = { git = "https://github.com/aiongg/craft-libs", rev = "283490a0833e37cc748d29711ff73f81f091e373", default-features = false, features = ["stl", "ply", "fbx", "obj", "gltf", "dae", "abc"] } +craft-mcmat = { git = "https://github.com/aiongg/craft-libs", rev = "283490a0833e37cc748d29711ff73f81f091e373" } # Who draws the window frame, and the app-drawn strip as the title bar (crates/ui-egui/src/titlebar.rs). -craft-window = { git = "https://github.com/aiongg/craft-libs", rev = "9fd8b0cdaad2b5320090f5a5892ba90fb8dab107", features = ["ui"] } +craft-window = { git = "https://github.com/aiongg/craft-libs", rev = "283490a0833e37cc748d29711ff73f81f091e373", features = ["ui"] } # Release checks, the update prompt and the update helper (crates/ui-egui/src/updates_ui.rs). -craft-update = { git = "https://github.com/aiongg/craft-libs", rev = "9fd8b0cdaad2b5320090f5a5892ba90fb8dab107", features = ["ui"] } +craft-update = { git = "https://github.com/aiongg/craft-libs", rev = "283490a0833e37cc748d29711ff73f81f091e373", features = ["ui"] } # File dialogs that never block the frame (crates/ui-egui/src/file_dialogs.rs). -craft-dialogs = { git = "https://github.com/aiongg/craft-libs", rev = "9fd8b0cdaad2b5320090f5a5892ba90fb8dab107" } +craft-dialogs = { git = "https://github.com/aiongg/craft-libs", rev = "283490a0833e37cc748d29711ff73f81f091e373" } # Shortcut chords, lookup and dispatch (crates/ui-egui/src/keymap.rs). -craft-keymap = { git = "https://github.com/aiongg/craft-libs", rev = "9fd8b0cdaad2b5320090f5a5892ba90fb8dab107", features = ["egui"] } +craft-keymap = { git = "https://github.com/aiongg/craft-libs", rev = "283490a0833e37cc748d29711ff73f81f091e373", features = ["egui"] } # The macOS app menu whose Quit asks about unsaved changes (apps/texturecraft/src/main.rs). -craft-menu = { git = "https://github.com/aiongg/craft-libs", rev = "9fd8b0cdaad2b5320090f5a5892ba90fb8dab107" } +craft-menu = { git = "https://github.com/aiongg/craft-libs", rev = "283490a0833e37cc748d29711ff73f81f091e373" } # The UI runtime's host: who the app is to the framework's dialogs (crates/ui-egui/src/framework.rs). -craft-host = { git = "https://github.com/aiongg/craft-libs", rev = "9fd8b0cdaad2b5320090f5a5892ba90fb8dab107" } +craft-host = { git = "https://github.com/aiongg/craft-libs", rev = "283490a0833e37cc748d29711ff73f81f091e373" } # The theme mode the app hands the runtime (crates/ui-egui/src/framework.rs). -craft-theme = { git = "https://github.com/aiongg/craft-libs", rev = "9fd8b0cdaad2b5320090f5a5892ba90fb8dab107" } +craft-theme = { git = "https://github.com/aiongg/craft-libs", rev = "283490a0833e37cc748d29711ff73f81f091e373" } # egui 0.37 and winit: the suite's forks (storytold/egui, storytold/winit), as craft-libs pins them. [patch.crates-io] diff --git a/crates/formats/Cargo.toml b/crates/formats/Cargo.toml index f942ab54..a087beb3 100644 --- a/crates/formats/Cargo.toml +++ b/crates/formats/Cargo.toml @@ -11,7 +11,7 @@ workspace = true [dependencies] craft-usd.workspace = true # ICC v2 serialization prerequisite: craft-libs#1735; app colour policy stays local. -craft-cms-icc-v2 = { package = "craft-cms", version = "0.1.0", git = "https://github.com/aiongg/craft-libs", rev = "9fd8b0cdaad2b5320090f5a5892ba90fb8dab107" } +craft-cms-icc-v2 = { package = "craft-cms", version = "0.1.0", git = "https://github.com/aiongg/craft-libs", rev = "283490a0833e37cc748d29711ff73f81f091e373" } craft-materialx = { workspace = true } craft-mesh = { workspace = true } craft-mcmat = { workspace = true } @@ -25,7 +25,7 @@ image = { workspace = true } png = "0.18" bytemuck = { workspace = true, features = ["extern_crate_alloc"] } craft-image-codecs = { workspace = true } -craft-psd = { git = "https://github.com/aiongg/craft-libs", rev = "9fd8b0cdaad2b5320090f5a5892ba90fb8dab107" } +craft-psd = { git = "https://github.com/aiongg/craft-libs", rev = "283490a0833e37cc748d29711ff73f81f091e373" } flate2 = { workspace = true } half = { workspace = true } quick-xml = { workspace = true } From 3a444c1136d8a3ca2ad6fd07d33fb5a56039302c Mon Sep 17 00:00:00 2001 From: vangel76 Date: Tue, 24 Nov 2026 23:08:01 +0100 Subject: [PATCH 26/83] Quit after a running save when Close arrives during it --- crates/ui-egui/src/manual_save.rs | 142 +++++++++++++++++++++++++++++- crates/ui-egui/src/windows.rs | 13 +-- 2 files changed, 148 insertions(+), 7 deletions(-) diff --git a/crates/ui-egui/src/manual_save.rs b/crates/ui-egui/src/manual_save.rs index c2481678..1aa3f479 100644 --- a/crates/ui-egui/src/manual_save.rs +++ b/crates/ui-egui/src/manual_save.rs @@ -8,6 +8,7 @@ use texturecraft_engine::{Result, file_cmds::SaveOutput, formats::project_file:: use crate::{ TextureCraftApp, i18n::{tr, trf}, + state::Unsaved, }; pub(crate) struct SaveJob { @@ -63,15 +64,19 @@ impl TextureCraftApp { self.saving_for_prompt = false; } + let mut quitting = false; match result { Ok(output) => { output.apply(&mut self.session); if job.remember { crate::windows::remember(self, &output.path); } - self.prompt_saved = continue_prompt && same_project && !self.session.modified && !self.session.stroke_active(); + let clean = same_project && !self.session.modified && !self.session.stroke_active(); + quitting = job.quit_after_save && clean; + self.prompt_saved = continue_prompt && clean && !quitting; self.toast(trf("Saved {path}", &[("path", &output.path)]), false); - if job.quit_after_save && same_project { + if quitting { + self.ui.windows.unsaved = None; ctx.send_viewport_cmd(egui::ViewportCommand::Close); } } @@ -81,8 +86,141 @@ impl TextureCraftApp { self.toast(message, true); } } + + // A close that the save could not finish asks about the changes it left + if job.quit_after_save && !quitting { + crate::windows::ask_to_save(self, Unsaved::Quit); + } if let Some(toast) = self.toasts.last_mut() { toast.announce = true; } } } + +#[cfg(test)] +mod tests { + use egui::{ViewportCommand, ViewportEvent, ViewportId}; + use egui_kittest::Harness; + use egui_kittest::kittest::{NodeT as _, Queryable as _}; + use texturecraft_engine::file_cmds::SaveTask; + + use super::*; + + fn harness() -> Harness<'static, TextureCraftApp> { + let mut session = texturecraft_engine::sample_session(256, 64).unwrap(); + session.modified = true; + let mut h = Harness::builder().with_size(egui::vec2(1600.0, 960.0)).build_eframe(|cc| TextureCraftApp::new(cc, session)); + + // Match English labels independently of the system locale + h.state_mut().ui.prefs.language = "en".into(); + h.run_steps(2); + h + } + + fn temp_file(test: &str) -> std::path::PathBuf { + let dir = std::env::temp_dir().join(format!("tc-manual-save-{test}-{}", std::process::id())); + std::fs::create_dir_all(&dir).unwrap(); + dir.join("project.tcraft") + } + + /// A save the test finishes by hand, so the close lands while it is still running + fn start_held_save(h: &mut Harness<'_, TextureCraftApp>, path: &std::path::Path, adopt: bool) -> (SaveTask, mpsc::Sender>) { + let app = h.state_mut(); + let task = app.session.save_task(&path.display().to_string(), adopt); + let (sender, output) = mpsc::channel(); + app.save_job = + Some(SaveJob { progress: Arc::default(), output, project_id: app.session.project_id, for_prompt: false, remember: false, quit_after_save: false }); + (task, sender) + } + + fn request_close(h: &mut Harness<'_, TextureCraftApp>) { + h.input_mut().viewports.entry(ViewportId::ROOT).or_default().events.push(ViewportEvent::Close); + h.step(); + h.input_mut().viewports.entry(ViewportId::ROOT).or_default().events.clear(); + h.run_steps(2); + } + + /// Hands the worker's result over and reports whether the app asked to close in the next frames + fn finish(h: &mut Harness<'_, TextureCraftApp>, task: SaveTask, sender: &mpsc::Sender>) -> bool { + sender.send(task.run(None)).unwrap(); + (0..3).any(|_| { + h.step(); + h.output().viewport_output.get(&ViewportId::ROOT).is_some_and(|v| v.commands.contains(&ViewportCommand::Close)) + }) + } + + fn prompt_is_usable(h: &Harness<'_, TextureCraftApp>) -> bool { + ["Save", "Don't save", "Cancel"].iter().all(|label| !h.get_by_label(label).accesskit_node().is_disabled()) + } + + #[test] + fn closing_during_a_regular_save_quits_once_it_has_saved() { + let _language = crate::i18n::TEST_LANGUAGE.lock().unwrap_or_else(std::sync::PoisonError::into_inner); + let file = temp_file("close-then-saved"); + let mut h = harness(); + h.state_mut().session.path = Some(file.display().to_string()); + let (task, sender) = start_held_save(&mut h, &file, true); + + request_close(&mut h); + assert_eq!(h.state().ui.windows.unsaved, Some(Unsaved::Quit), "the changes are not written yet"); + assert!(h.get_by_label("Save").accesskit_node().is_disabled(), "the prompt waits for the running save"); + let closed = finish(&mut h, task, &sender); + + assert!(closed, "the close goes on after the save"); + assert!(file.exists()); + assert!(!h.state().session.modified); + assert!(h.state().ui.windows.unsaved.is_none(), "no question is left once the changes are saved"); + } + + #[test] + fn closing_during_a_failed_save_keeps_a_usable_prompt() { + let _language = crate::i18n::TEST_LANGUAGE.lock().unwrap_or_else(std::sync::PoisonError::into_inner); + let file = temp_file("close-then-failed").with_file_name("missing").join("project.tcraft"); + let mut h = harness(); + let (task, sender) = start_held_save(&mut h, &file, true); + + request_close(&mut h); + let closed = finish(&mut h, task, &sender); + + assert!(!closed); + assert!(h.state().session.modified); + assert_eq!(h.state().ui.windows.unsaved, Some(Unsaved::Quit)); + assert!(prompt_is_usable(&h), "the prompt answers again after the failed write"); + } + + #[test] + fn closing_during_a_save_a_copy_keeps_the_prompt() { + let _language = crate::i18n::TEST_LANGUAGE.lock().unwrap_or_else(std::sync::PoisonError::into_inner); + let file = temp_file("close-then-copied"); + let mut h = harness(); + let (task, sender) = start_held_save(&mut h, &file, false); + + request_close(&mut h); + let closed = finish(&mut h, task, &sender); + + assert!(!closed, "a copy leaves the project's own changes unsaved"); + assert!(file.exists()); + assert!(h.state().session.modified); + assert_eq!(h.state().ui.windows.unsaved, Some(Unsaved::Quit)); + assert!(prompt_is_usable(&h)); + } + + #[test] + fn closing_during_a_save_keeps_the_prompt_for_later_edits() { + let _language = crate::i18n::TEST_LANGUAGE.lock().unwrap_or_else(std::sync::PoisonError::into_inner); + let file = temp_file("close-then-edited"); + let mut h = harness(); + h.state_mut().session.path = Some(file.display().to_string()); + let (task, sender) = start_held_save(&mut h, &file, true); + let rename = h.state_mut().run("textureSet.rename", serde_json::json!({"ts": 0, "name": "Edited while saving"})); + assert!(rename.is_some()); + + request_close(&mut h); + let closed = finish(&mut h, task, &sender); + + assert!(!closed, "the edit made after the snapshot is not in the file"); + assert!(h.state().session.modified); + assert_eq!(h.state().ui.windows.unsaved, Some(Unsaved::Quit)); + assert!(prompt_is_usable(&h)); + } +} diff --git a/crates/ui-egui/src/windows.rs b/crates/ui-egui/src/windows.rs index 96d7ca0a..8f83610c 100644 --- a/crates/ui-egui/src/windows.rs +++ b/crates/ui-egui/src/windows.rs @@ -95,12 +95,10 @@ pub(crate) fn close_request(app: &mut TextureCraftApp, ctx: &egui::Context) { app.toast(error.to_string(), true); } #[cfg(not(target_arch = "wasm32"))] - let waiting_for_save = if closing - && !app.session.modified - && let Some(job) = &mut app.save_job - { + let waiting_for_save = if closing && let Some(job) = &mut app.save_job { + // The running save carries the quit; unsaved changes still open the prompt meanwhile job.quit_after_save = true; - true + !app.session.modified } else { false }; @@ -164,6 +162,11 @@ fn unsaved(app: &mut TextureCraftApp, ctx: &egui::Context) { #[cfg(not(target_arch = "wasm32"))] { app.saving_for_prompt = false; + if pending == Unsaved::Quit + && let Some(job) = &mut app.save_job + { + job.quit_after_save = false; + } } } From 5b4b082c83a97e28f3f926600055d87e5c545742 Mon Sep 17 00:00:00 2001 From: vangel76 Date: Tue, 24 Nov 2026 23:26:07 +0100 Subject: [PATCH 27/83] Ask about edits made after a clean close while the save runs --- crates/ui-egui/src/manual_save.rs | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/crates/ui-egui/src/manual_save.rs b/crates/ui-egui/src/manual_save.rs index 1aa3f479..2ccb9ae7 100644 --- a/crates/ui-egui/src/manual_save.rs +++ b/crates/ui-egui/src/manual_save.rs @@ -223,4 +223,25 @@ mod tests { assert_eq!(h.state().ui.windows.unsaved, Some(Unsaved::Quit)); assert!(prompt_is_usable(&h)); } + + #[test] + fn an_edit_after_a_clean_close_asks_once_the_save_returns() { + let _language = crate::i18n::TEST_LANGUAGE.lock().unwrap_or_else(std::sync::PoisonError::into_inner); + let file = temp_file("clean-close-then-edited"); + let mut h = harness(); + h.state_mut().session.modified = false; + h.state_mut().session.path = Some(file.display().to_string()); + let (task, sender) = start_held_save(&mut h, &file, true); + + request_close(&mut h); + assert!(h.state().ui.windows.unsaved.is_none(), "nothing to ask while the project is clean"); + let rename = h.state_mut().run("textureSet.rename", serde_json::json!({"ts": 0, "name": "Edited while saving"})); + assert!(rename.is_some()); + let closed = finish(&mut h, task, &sender); + + assert!(!closed); + assert!(h.state().session.modified); + assert_eq!(h.state().ui.windows.unsaved, Some(Unsaved::Quit), "the close asks about the edit instead of being dropped"); + assert!(prompt_is_usable(&h)); + } } From 8f60ded96fae1231ccac874746c286b984c48b49 Mon Sep 17 00:00:00 2001 From: vangel76 Date: Wed, 25 Nov 2026 00:42:46 +0100 Subject: [PATCH 28/83] Save the rebuilt UV layout in the project file A project with rebuilt mesh UVs now stores the UV of every triangle corner in uv_layout.bin. Reopening and reimporting the project's own mesh apply that layout instead of running the unwrapper again, so a later unwrapper change cannot move saved paint. A format 4 project with rebuilt UVs but no valid layout is refused. --- crates/core/src/project.rs | 3 +- crates/engine/src/file_cmds.rs | 24 +++++-- crates/engine/src/material_lib.rs | 1 + crates/engine/tests/it/main.rs | 1 + crates/engine/tests/it/rebuilt_uv_layout.rs | 57 +++++++++++++++ crates/formats/src/mesh_import/mod.rs | 64 ++++++++++++++++- crates/formats/src/mesh_import/tests.rs | 17 +++++ crates/formats/src/project_file/mod.rs | 23 ++++++ crates/formats/src/project_file/tests.rs | 53 ++++++++++++++ crates/formats/src/project_file/uv_layout.rs | 73 ++++++++++++++++++++ docs/control-protocol.md | 5 +- docs/features.md | 2 +- 12 files changed, 311 insertions(+), 12 deletions(-) create mode 100644 crates/engine/tests/it/rebuilt_uv_layout.rs create mode 100644 crates/formats/src/project_file/uv_layout.rs diff --git a/crates/core/src/project.rs b/crates/core/src/project.rs index c7830075..ac33411a 100644 --- a/crates/core/src/project.rs +++ b/crates/core/src/project.rs @@ -432,7 +432,8 @@ pub struct Project { /// it, so parts the file leaves unnamed get the same name (from it) as on import. #[serde(default, skip_serializing_if = "String::is_empty")] pub mesh_file: String, - /// Rebuild the UVs again when reading the mesh stored in the project. + /// The mesh UVs were rebuilt on import. The project file keeps the generated layout for + /// reopening; reimporting the mesh from a file rebuilds them again. #[serde(default, skip_serializing_if = "std::ops::Not::not")] pub mesh_rebuild_uvs: bool, /// Where the mesh file was imported from (the project's "3D mesh path"). Reimport mesh reads diff --git a/crates/engine/src/file_cmds.rs b/crates/engine/src/file_cmds.rs index d75723f6..8df6928b 100644 --- a/crates/engine/src/file_cmds.rs +++ b/crates/engine/src/file_cmds.rs @@ -10,6 +10,7 @@ use serde_json::{Value, json}; use texturecraft_core::{NormalFormat, PROJECT_EXT}; use texturecraft_core::{Project, TextureSet}; use texturecraft_formats::{ExportInput, ExportOptions, ExportedFile, FileFormat, MapOverride, Padding, ProjectFile}; +use texturecraft_geom::glam::Vec2; use texturecraft_geom::{Mesh, primitives}; use crate::commands::{CommandSpec, always, bad, normal_format_param, strp, u64p}; @@ -98,10 +99,15 @@ fn leaf_of(name: &str) -> String { } /// Read the project's stored mesh `bytes` (extension `ext`) under the name it was imported -/// with, so its unnamed parts keep their names (and the geometry masks that use them). -fn read_stored_mesh(project: &Project, ext: &str, bytes: &[u8]) -> Result { +/// with, so its unnamed parts keep their names (and the geometry masks that use them). A saved +/// UV layout replaces the file's UVs and the automatic unwrap. +fn read_stored_mesh(project: &Project, ext: &str, bytes: &[u8], saved_layout: Option<&[Vec2]>) -> Result { let stem = std::path::Path::new(&project.mesh_file).file_stem().and_then(|s| s.to_str()).filter(|s| !s.is_empty()).unwrap_or("mesh"); - texturecraft_formats::mesh_import::import_mesh_bytes_with_uvs(&format!("{stem}.{ext}"), bytes, project.mesh_rebuild_uvs).map_err(fe) + let file_name = format!("{stem}.{ext}"); + match saved_layout { + Some(layout) => texturecraft_formats::mesh_import::import_mesh_bytes_with_layout(&file_name, bytes, layout).map_err(fe), + None => texturecraft_formats::mesh_import::import_mesh_bytes_with_uvs(&file_name, bytes, project.mesh_rebuild_uvs).map_err(fe), + } } impl Session { @@ -205,7 +211,7 @@ impl Session { pub fn from_project_file(pf: ProjectFile) -> Result { let mesh = match (&pf.mesh, pf.project.mesh.strip_prefix("builtin:")) { (_, Some(id)) => primitives::builtin(id).ok_or_else(|| EngineError::Other(format!("unknown built-in mesh `{id}`")))?, - (Some((ext, bytes)), None) => read_stored_mesh(&pf.project, ext, bytes)?.mesh, + (Some((ext, bytes)), None) => read_stored_mesh(&pf.project, ext, bytes, pf.mesh_uvs.as_deref())?.mesh, (None, None) => return Err(EngineError::Other("the project has no mesh".into())), }; @@ -234,6 +240,11 @@ impl Session { self.project_with_resources(self.doc.resources.clone()) } + /// The layout a project with rebuilt mesh UVs saves, so reopening it never runs the unwrapper. + fn saved_uv_layout(&self) -> Option> { + (self.doc.project.mesh_rebuild_uvs && self.mesh_source.is_some()).then(|| texturecraft_formats::mesh_import::corner_uvs(&self.source)) + } + fn project_with_resources(&self, resources: BTreeMap) -> ProjectFile { let mut pixels = self.doc.pixels.clone(); @@ -257,6 +268,7 @@ impl Session { pixels, baked: self.doc.baked.clone(), mesh: self.mesh_source.clone(), + mesh_uvs: self.saved_uv_layout(), high_poly, cage, bake_paint: self.saved_bake_paint(), @@ -613,7 +625,9 @@ impl Session { } None => match &self.mesh_source { Some((ext, bytes)) => { - (read_stored_mesh(&self.doc.project, ext, bytes)?.mesh, self.mesh_source.clone(), Vec::new(), self.doc.project.mesh_file.clone()) + let layout = self.saved_uv_layout(); + let mesh = read_stored_mesh(&self.doc.project, ext, bytes, layout.as_deref())?.mesh; + (mesh, self.mesh_source.clone(), Vec::new(), self.doc.project.mesh_file.clone()) } None => return Err(bad("file.reimportMesh", "built-in meshes can't be reimported; give `path`")), }, diff --git a/crates/engine/src/material_lib.rs b/crates/engine/src/material_lib.rs index 678d7bb7..84c3b3f8 100644 --- a/crates/engine/src/material_lib.rs +++ b/crates/engine/src/material_lib.rs @@ -97,6 +97,7 @@ impl Session { pixels: mini.pixels, baked: BTreeMap::new(), mesh: None, + mesh_uvs: None, high_poly: Vec::new(), cage: None, bake_paint: BTreeMap::new(), diff --git a/crates/engine/tests/it/main.rs b/crates/engine/tests/it/main.rs index c38e850b..d2e219dd 100644 --- a/crates/engine/tests/it/main.rs +++ b/crates/engine/tests/it/main.rs @@ -55,6 +55,7 @@ mod pbr_import; mod perf; mod polygon_fill; mod project_recovery; +mod rebuilt_uv_layout; mod resources_used; mod sample; mod solo; diff --git a/crates/engine/tests/it/rebuilt_uv_layout.rs b/crates/engine/tests/it/rebuilt_uv_layout.rs new file mode 100644 index 00000000..805fe1de --- /dev/null +++ b/crates/engine/tests/it/rebuilt_uv_layout.rs @@ -0,0 +1,57 @@ +use std::io::{Cursor, Write}; + +use serde_json::json; +use texturecraft_engine::Session; +use texturecraft_engine::formats::mesh_import::{corner_uvs, import_mesh_bytes_with_uvs}; +use texturecraft_engine::geom::glam::Vec2; +use zip::{ZipWriter, write::SimpleFileOptions}; + +const QUAD_OBJ: &str = "v 0 0 0\nv 1 0 0\nv 1 1 0\nv 0 1 0\nvt 0 0\nvt 1 0\nvt 1 1\nvt 0 1\nf 1/1 2/2 3/3\nf 1/1 3/3 4/4\n"; + +/// A layout no unwrapper of this build makes: the quad turned a quarter and inset, per corner +const LOCKED_LAYOUT: [[f32; 2]; 6] = [[0.9, 0.1], [0.9, 0.9], [0.1, 0.9], [0.9, 0.1], [0.1, 0.9], [0.1, 0.1]]; + +/// `uv_layout.bin` written by hand: magic, version 1, corner count, then u and v per corner +fn layout_entry(layout: &[[f32; 2]]) -> Vec { + let mut bytes = b"TCUV".to_vec(); + bytes.extend(1u32.to_le_bytes()); + bytes.extend(u32::try_from(layout.len()).unwrap().to_le_bytes()); + for [u, v] in layout { + bytes.extend(u.to_le_bytes()); + bytes.extend(v.to_le_bytes()); + } + bytes +} + +/// A format 4 archive of the quad with rebuilt UVs and the locked layout +fn locked_archive() -> Vec { + let session = Session::from_mesh_bytes_with_uvs("quad.obj", QUAD_OBJ.as_bytes(), 128, "quad", None, true).unwrap(); + let mut project = serde_json::to_value(&session.doc.project).unwrap(); + project["format_version"] = json!(4); + + let mut archive = ZipWriter::new(Cursor::new(Vec::new())); + for (name, bytes) in + [("project.json", serde_json::to_vec(&project).unwrap()), ("mesh.obj", QUAD_OBJ.as_bytes().to_vec()), ("uv_layout.bin", layout_entry(&LOCKED_LAYOUT))] + { + archive.start_file(name, SimpleFileOptions::default()).unwrap(); + archive.write_all(&bytes).unwrap(); + } + archive.finish().unwrap().into_inner() +} + +#[test] +fn a_rebuilt_project_reopens_with_its_saved_uv_layout_not_a_new_unwrap() { + let locked: Vec = LOCKED_LAYOUT.iter().map(|uv| Vec2::from_array(*uv)).collect(); + let unwrapped = import_mesh_bytes_with_uvs("quad.obj", QUAD_OBJ.as_bytes(), true).unwrap().mesh; + + let mut reopened = Session::from_project_bytes(&locked_archive()).unwrap(); + let opened_layout = corner_uvs(&reopened.source_mesh()); + reopened.reimport_mesh(None, false).unwrap(); + let reimported_layout = corner_uvs(&reopened.source_mesh()); + let resaved = Session::from_project_bytes(&reopened.to_project_bytes().unwrap()).unwrap(); + + assert_ne!(corner_uvs(&unwrapped), locked, "the locked layout differs from what the unwrapper makes now"); + assert_eq!(opened_layout, locked); + assert_eq!(reimported_layout, locked, "reimporting the project's own mesh keeps the saved layout"); + assert_eq!(corner_uvs(&resaved.source_mesh()), locked, "saving again keeps the layout"); +} diff --git a/crates/formats/src/mesh_import/mod.rs b/crates/formats/src/mesh_import/mod.rs index 06ab5d93..f9eed9d6 100644 --- a/crates/formats/src/mesh_import/mod.rs +++ b/crates/formats/src/mesh_import/mod.rs @@ -303,6 +303,19 @@ pub fn import_mesh_bytes_with_uvs(file_name: &str, bytes: &[u8], rebuild_uvs: bo finish(read(file_name, bytes)?, rebuild_uvs) } +/// Import mesh bytes with a saved UV layout ([`corner_uvs`] of the mesh as first imported) +/// instead of the file's UVs or the automatic unwrap, so the layout does not depend on the +/// unwrapper of the running version. +pub fn import_mesh_bytes_with_layout(file_name: &str, bytes: &[u8], corner_uvs: &[Vec2]) -> Result { + finish_with_layout(read(file_name, bytes)?, false, Some(corner_uvs)) +} + +/// The UV of every triangle corner, in index order: a layout that [`import_mesh_bytes_with_layout`] +/// applies to the same mesh file again. +pub fn corner_uvs(mesh: &Mesh) -> Vec { + mesh.indices.iter().map(|index| mesh.uvs.get(*index as usize).copied().unwrap_or_default()).collect() +} + /// Import a mesh file with the files it references next to it ([`read_mesh_file`]). #[cfg(not(target_arch = "wasm32"))] pub fn import_mesh(path: &std::path::Path) -> Result { @@ -496,12 +509,21 @@ fn geometry(raw: RawMesh) -> Result<(Mesh, Vec, Option>)> { } /// Complete a raw mesh: submeshes, normals, UVs, tangents, validation and the report. -pub(crate) fn finish(mut raw: RawMesh, rebuild_uvs: bool) -> Result { +pub(crate) fn finish(raw: RawMesh, rebuild_uvs: bool) -> Result { + finish_with_layout(raw, rebuild_uvs, None) +} + +/// [`finish`] with an optional saved UV layout that replaces both the file's UVs and the unwrap. +fn finish_with_layout(mut raw: RawMesh, rebuild_uvs: bool, saved_layout: Option<&[Vec2]>) -> Result { let mut raw_cameras = std::mem::take(&mut raw.cameras); raw_cameras.truncate(MAX_CAMERAS); let (mut mesh, mut warnings, uvs) = geometry(raw)?; - let uvs_generated = match uvs { - Some(uv) if !rebuild_uvs && uv.len() == mesh.positions.len() => { + let uvs_generated = match (saved_layout, uvs) { + (Some(layout), _) => { + apply_corner_uvs(&mut mesh, layout)?; + true + } + (None, Some(uv)) if !rebuild_uvs && uv.len() == mesh.positions.len() => { if uv.iter().any(|v| !v.is_finite()) { warnings.push("non-finite UVs were replaced with 0".into()); } @@ -522,6 +544,42 @@ pub(crate) fn finish(mut raw: RawMesh, rebuild_uvs: bool) -> Result Result<()> { + if layout.len() != mesh.indices.len() { + return Err(FormatError::Invalid(format!("the saved UV layout has {} corners but the mesh has {}", layout.len(), mesh.indices.len()))); + } + if layout.iter().any(|uv| !uv.is_finite()) { + return Err(FormatError::Invalid("the saved UV layout has non-finite UVs".into())); + } + + let mut vertex_of: HashMap<(u32, [u32; 2]), u32> = HashMap::with_capacity(mesh.positions.len() * 2); + let (mut positions, mut normals, mut uvs, mut colors) = (Vec::new(), Vec::new(), Vec::new(), Vec::new()); + let mut indices = Vec::with_capacity(mesh.indices.len()); + for (&vertex, &uv) in mesh.indices.iter().zip(layout) { + let index = *vertex_of.entry((vertex, [uv.x.to_bits(), uv.y.to_bits()])).or_insert_with(|| { + let source = vertex as usize; + positions.push(mesh.positions.get(source).copied().unwrap_or_default()); + normals.push(mesh.normals.get(source).copied().unwrap_or(Vec3::Y)); + if let Some(color) = mesh.colors.get(source) { + colors.push(*color); + } + uvs.push(uv); + (positions.len() - 1) as u32 + }); + indices.push(index); + } + + mesh.positions = positions; + mesh.normals = normals; + mesh.uvs = uvs; + mesh.colors = colors; + mesh.indices = indices; + mesh.compute_tangents(); + Ok(()) +} + /// File cameras as orbit cameras: the target is where the view axis passes the mesh center /// (at least a tenth of the mesh size ahead). shortcut: camera roll is dropped (orbit cameras /// keep +Y up); keep a free camera transform if imported rolls matter. diff --git a/crates/formats/src/mesh_import/tests.rs b/crates/formats/src/mesh_import/tests.rs index 0cfbae61..e61ba7b9 100644 --- a/crates/formats/src/mesh_import/tests.rs +++ b/crates/formats/src/mesh_import/tests.rs @@ -757,3 +757,20 @@ fn duplicate_gltf_material_names_keep_first_wins_and_order() { } assert_eq!(color_by_material.get("Dup").unwrap().factor, Vec4::new(1.0, 0.0, 0.0, 1.0)); } + +#[test] +fn a_saved_layout_reproduces_the_rebuilt_mesh_without_unwrapping() { + let rebuilt = import_mesh_bytes_with_uvs("a.obj", OBJ.as_bytes(), true).unwrap().mesh; + let layout = corner_uvs(&rebuilt); + + let reopened = import_mesh_bytes_with_layout("a.obj", OBJ.as_bytes(), &layout).unwrap(); + let short = import_mesh_bytes_with_layout("a.obj", OBJ.as_bytes(), &layout[1..]); + let mut non_finite = layout.clone(); + non_finite[0].x = f32::NAN; + + assert!(!reopened.report.warnings.iter().any(|warning| warning.contains("unwrap")), "{:?}", reopened.report.warnings); + assert_eq!((&reopened.mesh.positions, &reopened.mesh.indices, &reopened.mesh.uvs), (&rebuilt.positions, &rebuilt.indices, &rebuilt.uvs)); + assert_eq!(reopened.mesh.normals, rebuilt.normals); + assert!(short.is_err(), "a layout for another mesh is refused"); + assert!(import_mesh_bytes_with_layout("a.obj", OBJ.as_bytes(), &non_finite).is_err()); +} diff --git a/crates/formats/src/project_file/mod.rs b/crates/formats/src/project_file/mod.rs index b86f8ec1..2f8b1d67 100644 --- a/crates/formats/src/project_file/mod.rs +++ b/crates/formats/src/project_file/mod.rs @@ -4,6 +4,7 @@ //! |---|---| //! | `project.json` | serde JSON of [`Project`] | //! | `mesh.` | the original imported mesh file (absent for built-in meshes, `Project.mesh = "builtin:"`) | +//! | `uv_layout.bin` | the UV of every triangle corner of a mesh whose UVs were rebuilt (format 4+, see `uv_layout`) | //! | `highpoly/` | a high-definition mesh file for baking, in list order | //! | `cage/` | the baking cage mesh file | //! | `bake_paint/_.bin` | cage or skew paint, stored as a one-component baked map | @@ -26,12 +27,14 @@ use std::sync::Arc; use texturecraft_compose::{BakedMaps, PixelStore}; use texturecraft_core::project::REBUILT_MESH_UVS_VERSION; use texturecraft_core::{BakePaintTarget, BakedMap, Channel, FORMAT_VERSION, LayerId, Project, TANGENT_BENT_NORMAL_VERSION}; +use texturecraft_geom::glam::Vec2; use texturecraft_texel::{TILE_AREA, TileImage}; use zip::write::SimpleFileOptions; use zip::{CompressionMethod, ZipArchive, ZipWriter}; use self::entries::Entry; use self::load_budget::LoadBudget; +use self::uv_layout::{MAX_UV_LAYOUT_BYTES, UV_LAYOUT_ENTRY, read_uv_layout, uv_layout_bytes, write_uv_layout}; use crate::{FormatError, MAX_IMAGE_SIZE, Result, malformed}; mod entries; @@ -39,6 +42,7 @@ mod load_budget; mod project_open_limit; mod ram_operation; mod ram_reservation; +mod uv_layout; #[cfg(not(target_arch = "wasm32"))] pub use entries::{DEFAULT_RAM_PERCENT, DEFAULT_RESERVED_CORES, available_save_resources, configured_ram_budget, save_ram_budget, set_save_resources}; pub use project_open_limit::{DEFAULT_PROJECT_OPEN_LIMIT_GIB, project_open_limit_gib, set_project_open_limit_gib}; @@ -73,6 +77,9 @@ pub struct ProjectFile> { pub baked: BTreeMap, /// Original mesh file: (extension, bytes). pub mesh: Option<(String, Vec)>, + /// Saved UV layout of `mesh` when its UVs were rebuilt: the UV of every triangle corner, in + /// index order, as the mesh was first imported. + pub mesh_uvs: Option>, /// High-definition mesh files for baking: (file name, bytes). Names are /// [`sanitize_resource_name`]d on save. pub high_poly: Vec<(String, Vec)>, @@ -206,6 +213,14 @@ fn entries(pf: &ProjectFile>>) -> Result>> { body: Box::new(move |w| w.write_all(bytes)), }); } + if let Some(layout) = &pf.mesh_uvs { + out.push(Entry { + name: UV_LAYOUT_ENTRY.into(), + options: deflate, + weight: uv_layout_bytes(layout.len()), + body: Box::new(move |w| write_uv_layout(w, layout)), + }); + } let mut used = HashSet::new(); for (dir, (name, bytes)) in pf.high_poly.iter().map(|m| ("highpoly", m)).chain(pf.cage.iter().map(|m| ("cage", m))) { out.push(Entry { @@ -416,6 +431,7 @@ fn load_archive(mut zip: ZipArchive, mut budget: LoadBudget) pixels: PixelStore::default(), baked: BTreeMap::new(), mesh: None, + mesh_uvs: None, high_poly: Vec::new(), cage: None, bake_paint: BTreeMap::new(), @@ -468,6 +484,9 @@ fn load_archive(mut zip: ZipArchive, mut budget: LoadBudget) } else if let Some(ext) = name.strip_prefix("mesh.").filter(|e| !e.contains('/')) { let bytes = read_all(&mut f, crate::mesh_import::MAX_MESH_FILE_BYTES, &mut budget, &name)?; pf.mesh = Some((ext.to_string(), bytes)); + } else if name == UV_LAYOUT_ENTRY { + let bytes = read_all(&mut f, MAX_UV_LAYOUT_BYTES, &mut budget, &name)?; + pf.mesh_uvs = Some(read_uv_layout(&bytes)?); } else if let Some(rest) = name.strip_prefix("pixels/layer_").and_then(|r| r.strip_suffix(".bin")) { let (id, chan) = rest.split_once('_').ok_or_else(|| malformed(KIND, format!("bad entry name {name}")))?; let id = LayerId(id.parse().map_err(|_| malformed(KIND, format!("bad entry name {name}")))?); @@ -508,6 +527,10 @@ fn load_archive(mut zip: ZipArchive, mut budget: LoadBudget) } } + // Rerunning the unwrapper could lay the saved paint over a different layout + if pf.project.mesh_rebuild_uvs && pf.mesh.is_some() && pf.mesh_uvs.is_none() { + return Err(malformed(KIND, "the mesh UVs were rebuilt but the project holds no saved UV layout")); + } if version < TANGENT_BENT_NORMAL_VERSION { drop_world_space_bent_normals(&mut pf); } diff --git a/crates/formats/src/project_file/tests.rs b/crates/formats/src/project_file/tests.rs index a4cc5a34..2bf55a31 100644 --- a/crates/formats/src/project_file/tests.rs +++ b/crates/formats/src/project_file/tests.rs @@ -32,6 +32,7 @@ fn sample() -> Sample { pixels, baked: [(0, baked)].into(), mesh: Some(("glb".into(), vec![1, 2, 3, 4, 5])), + mesh_uvs: None, high_poly: vec![("b_high.obj".into(), vec![7; 9]), ("a_high.ply".into(), vec![6])], cage: Some(("cage.obj".into(), vec![5, 5])), bake_paint: [((0, texturecraft_core::BakePaintTarget::Skew), BakePaintData { width: 3, height: 2, values: vec![0.0, 0.25, 0.5, 0.75, 1.0, 0.125] })] @@ -55,6 +56,7 @@ fn assert_same(a: &ProjectFile, b: &ProjectFile) { } assert_eq!(a.baked, b.baked); assert_eq!(a.mesh, b.mesh); + assert_eq!(a.mesh_uvs, b.mesh_uvs); assert_eq!((&a.high_poly, &a.cage), (&b.high_poly, &b.cage), "bake meshes keep their order"); assert_eq!(a.bake_paint, b.bake_paint); assert_eq!(a.thumbnail, b.thumbnail); @@ -920,3 +922,54 @@ fn zip64_entry_counts_remain_supported_and_bounded() { } } } + +fn rebuilt_uvs_sample() -> ProjectFile { + let mut project_file = sample().pf; + project_file.project.mesh_rebuild_uvs = true; + project_file.mesh_uvs = Some(vec![Vec2::new(0.25, 0.75), Vec2::new(1.0, 0.0), Vec2::new(0.5, 0.125)]); + project_file +} + +#[test] +fn a_saved_uv_layout_round_trips_in_format_4() { + let project_file = rebuilt_uvs_sample(); + + let loaded = load_project_bytes(&save_project_bytes(&project_file).unwrap()).unwrap(); + + assert_eq!(loaded.mesh_uvs, project_file.mesh_uvs); + assert_eq!(loaded.project.format_version, REBUILT_MESH_UVS_VERSION); +} + +#[test] +fn rebuilt_uvs_without_a_valid_saved_layout_are_refused() { + let project_file = rebuilt_uvs_sample(); + let without_layout = edit_archive(&project_file, |name, _| { + if name == UV_LAYOUT_ENTRY { + *name = "ignored.bin".into(); + } + }); + let edited_layout = |edit: fn(&mut Vec)| { + edit_archive(&project_file, |name, data| { + if name == UV_LAYOUT_ENTRY { + edit(data); + } + }) + }; + let truncated = edited_layout(|data| data.truncate(data.len() - 1)); + let short_header = edited_layout(|data| data.truncate(8)); + let wrong_count = edited_layout(|data| data[8] = 9); + let non_finite = edited_layout(|data| data[12..16].copy_from_slice(&f32::NAN.to_le_bytes())); + let bad_magic = edited_layout(|data| data[0] = b'X'); + + for (case, bytes) in [ + ("missing", without_layout), + ("truncated", truncated), + ("short header", short_header), + ("wrong count", wrong_count), + ("non-finite", non_finite), + ("bad magic", bad_magic), + ] { + let error = load_project_bytes(&bytes).unwrap_err(); + assert!(!is_guard_error(&error), "{case}: {error}"); + } +} diff --git a/crates/formats/src/project_file/uv_layout.rs b/crates/formats/src/project_file/uv_layout.rs new file mode 100644 index 00000000..cf6a638c --- /dev/null +++ b/crates/formats/src/project_file/uv_layout.rs @@ -0,0 +1,73 @@ +//! `uv_layout.bin`: the UVs of a mesh whose layout was rebuilt on import, so reopening does not +//! depend on the unwrapper of the running version. A header (magic `TCUV`, version, corner count; +//! u32 LE each) is followed by `u`, `v` (f32 LE) for every triangle corner in index order. + +use std::io::Write; + +use texturecraft_geom::MAX_TRIANGLES; +use texturecraft_geom::glam::Vec2; + +use super::KIND; +use crate::{Result, malformed}; + +/// Zip entry name of the saved layout. +pub const UV_LAYOUT_ENTRY: &str = "uv_layout.bin"; + +const UV_LAYOUT_MAGIC: &[u8; 4] = b"TCUV"; +const UV_LAYOUT_VERSION: u32 = 1; +const HEADER_BYTES: usize = 12; +const CORNER_BYTES: usize = 8; + +/// Largest entry a valid mesh can need: every corner of the most triangles accepted. +pub const MAX_UV_LAYOUT_BYTES: u64 = (HEADER_BYTES + MAX_TRIANGLES * 3 * CORNER_BYTES) as u64; + +/// Encoded size of a layout of `corners` UVs. +pub fn uv_layout_bytes(corners: usize) -> u64 { + (HEADER_BYTES + corners * CORNER_BYTES) as u64 +} + +pub fn write_uv_layout(w: &mut dyn Write, layout: &[Vec2]) -> std::io::Result<()> { + let corners = u32::try_from(layout.len()).map_err(|_| std::io::Error::other("the UV layout has too many corners"))?; + w.write_all(UV_LAYOUT_MAGIC)?; + w.write_all(&UV_LAYOUT_VERSION.to_le_bytes())?; + w.write_all(&corners.to_le_bytes())?; + + let mut body = Vec::with_capacity(layout.len() * CORNER_BYTES); + for uv in layout { + body.extend_from_slice(&uv.x.to_le_bytes()); + body.extend_from_slice(&uv.y.to_le_bytes()); + } + w.write_all(&body) +} + +/// Decode an entry; a wrong header, size or a non-finite UV is an error. +pub fn read_uv_layout(bytes: &[u8]) -> Result> { + let bad = |why: &str| malformed(KIND, format!("{UV_LAYOUT_ENTRY}: {why}")); + let Some((header, body)) = bytes.split_first_chunk::() else { return Err(bad("truncated header")) }; + let [magic, version, corners] = header.as_chunks::<4>().0 else { return Err(bad("truncated header")) }; + + if magic != UV_LAYOUT_MAGIC { + return Err(bad("bad magic")); + } + if u32::from_le_bytes(*version) != UV_LAYOUT_VERSION { + return Err(bad("unsupported version")); + } + let corners = u32::from_le_bytes(*corners) as usize; + if corners.checked_mul(CORNER_BYTES) != Some(body.len()) { + return Err(bad("the corner count does not match the entry size")); + } + + let layout: Vec = body + .as_chunks::() + .0 + .iter() + .map(|corner| { + let (u, v) = corner.split_at(4); + Vec2::new(f32::from_le_bytes(u.try_into().unwrap_or_default()), f32::from_le_bytes(v.try_into().unwrap_or_default())) + }) + .collect(); + if layout.iter().any(|uv| !uv.is_finite()) { + return Err(bad("non-finite UVs")); + } + Ok(layout) +} diff --git a/docs/control-protocol.md b/docs/control-protocol.md index 878f1ba7..0754f7c1 100644 --- a/docs/control-protocol.md +++ b/docs/control-protocol.md @@ -318,8 +318,9 @@ takes a font family, not a path: it reads only the system's font folders. `file.close` leaves no project open: `session.inspect` then reports `projectOpen: false`, `command.list` marks every command but the project-independent ones as not enabled: the ones that open or create a project (`file.open`, `file.new`, `project.new`, `project.sample`), `project.inspect`, `viewport.frame`, `project.templates`, the `export.preset*` commands (`export.presets`, `export.preset.get`, `export.preset.save`, `export.preset.remove`) and the library and preset listings (`brush.preset.list`, `alpha.list`, `filter.list`, `material.list`, `mask.smart.list`, `text.fonts`), each still subject to its own enabled check. The rest are refused with "no project is open" until a project is opened or created. A `texturecraft --control` run starts with the sample project (an empty material ball with `--empty`); the app without `--control` starts with no project. The desktop control channel accepts `rebuildUvs: true` on `file.new` to generate a new UV layout. -The default keeps a complete authored layout and unwraps meshes that need UVs. The project -remembers the rebuild choice for reopening and reimporting its mesh. +The default keeps a complete authored layout and unwraps meshes that need UVs. The project file +saves the generated layout, so reopening it never runs the unwrapper again; reimporting the mesh +from a file rebuilds its UVs. | Tool | Params | Notes | |---|---|---| diff --git a/docs/features.md b/docs/features.md index 82c650a4..6603b8af 100644 --- a/docs/features.md +++ b/docs/features.md @@ -138,7 +138,7 @@ Everything TextureCraft does today, by area. What's still missing is in [`ROADMA channel types to add or remove. Show, hide or invert them all at once, or **focus** on the active one. The project's **normal map format** (OpenGL or DirectX, in Texture Set Settings) says how a normal map image set as a mesh map is read, and is the default for export. -- **Projects** are a single `.tcraft` file: the mesh, every layer (sparse and lossless), baked maps +- **Projects** are a single `.tcraft` file: the mesh (with its generated UV layout when *Rebuild mesh UVs* was chosen), every layer (sparse and lossless), baked maps and imported images. **Project templates** start new work from a saved setup. *File › More save options › Save as template...* saves the open project's setup (dialog "Save template", in the user templates folder, no confirmation); New project lists "Default (OpenPBR)", the other built-ins with " (starter_assets)", yours with " (your_assets)", and opens on the template of the last project. *More save options* also has *Save as copy...* and *Save and reduce file size* (greyed, "Not available yet"). Closing the app, or opening, starting or closing another project, with unsaved changes asks whether to save them first (in the browser too, where Save downloads the project and closing or reloading the tab From 65af076fd6129eae114207da176aad1056badc60 Mon Sep 17 00:00:00 2001 From: vangel76 Date: Wed, 25 Nov 2026 00:43:08 +0100 Subject: [PATCH 29/83] Keep a close during a save pending until an open stroke ends --- crates/ui-egui/src/lib.rs | 5 +++ crates/ui-egui/src/manual_save.rs | 74 ++++++++++++++++++++++++++++++- crates/ui-egui/src/windows.rs | 8 ++++ 3 files changed, 85 insertions(+), 2 deletions(-) diff --git a/crates/ui-egui/src/lib.rs b/crates/ui-egui/src/lib.rs index 84c103f6..2f981d6b 100644 --- a/crates/ui-egui/src/lib.rs +++ b/crates/ui-egui/src/lib.rs @@ -332,6 +332,9 @@ pub struct TextureCraftApp { /// The unsaved-changes dialog's Save is waiting for a path or a save result. #[cfg(not(target_arch = "wasm32"))] pub(crate) saving_for_prompt: bool, + /// A close the finished save left waiting for an open stroke; decided once the stroke ends. + #[cfg(not(target_arch = "wasm32"))] + pub(crate) quit_after_stroke: bool, /// The requested save completed; the prompt goes on at its next frame. #[cfg(not(target_arch = "wasm32"))] pub(crate) prompt_saved: bool, @@ -453,6 +456,8 @@ impl TextureCraftApp { #[cfg(not(target_arch = "wasm32"))] saving_for_prompt: false, #[cfg(not(target_arch = "wasm32"))] + quit_after_stroke: false, + #[cfg(not(target_arch = "wasm32"))] prompt_saved: false, bindings: keymap::Bindings::default(), settings_bindings: keymap::Bindings::default(), diff --git a/crates/ui-egui/src/manual_save.rs b/crates/ui-egui/src/manual_save.rs index 2ccb9ae7..b7eed0fe 100644 --- a/crates/ui-egui/src/manual_save.rs +++ b/crates/ui-egui/src/manual_save.rs @@ -87,9 +87,13 @@ impl TextureCraftApp { } } - // A close that the save could not finish asks about the changes it left + // A close that the save could not finish asks about the changes it left, once an open stroke ends if job.quit_after_save && !quitting { - crate::windows::ask_to_save(self, Unsaved::Quit); + if self.session.stroke_active() { + self.quit_after_stroke = true; + } else { + crate::windows::ask_to_save(self, Unsaved::Quit); + } } if let Some(toast) = self.toasts.last_mut() { toast.announce = true; @@ -143,6 +147,11 @@ mod tests { /// Hands the worker's result over and reports whether the app asked to close in the next frames fn finish(h: &mut Harness<'_, TextureCraftApp>, task: SaveTask, sender: &mpsc::Sender>) -> bool { sender.send(task.run(None)).unwrap(); + sends_close(h) + } + + /// Whether the app asks to close in the next frames + fn sends_close(h: &mut Harness<'_, TextureCraftApp>) -> bool { (0..3).any(|_| { h.step(); h.output().viewport_output.get(&ViewportId::ROOT).is_some_and(|v| v.commands.contains(&ViewportCommand::Close)) @@ -244,4 +253,65 @@ mod tests { assert_eq!(h.state().ui.windows.unsaved, Some(Unsaved::Quit), "the close asks about the edit instead of being dropped"); assert!(prompt_is_usable(&h)); } + + /// A clean project closed during its save, with paint still held down when the save returns + fn stroke_open_when_the_save_returns(test: &str) -> Harness<'static, TextureCraftApp> { + let file = temp_file(test); + let mut h = harness(); + h.state_mut().session.modified = false; + h.state_mut().session.path = Some(file.display().to_string()); + let (task, sender) = start_held_save(&mut h, &file, true); + request_close(&mut h); + h.state_mut().session.begin_stroke_uv(texturecraft_engine::geom::glam::Vec2::splat(0.5), 1.0).unwrap(); + + let closed = finish(&mut h, task, &sender); + + assert!(!closed, "the open stroke may still change the project"); + assert!(h.state().session.stroke_active()); + assert!(h.state().ui.windows.unsaved.is_none()); + h + } + + #[test] + fn a_stroke_open_when_the_save_returns_asks_once_it_is_painted() { + let _language = crate::i18n::TEST_LANGUAGE.lock().unwrap_or_else(std::sync::PoisonError::into_inner); + let mut h = stroke_open_when_the_save_returns("stroke-painted"); + + h.state_mut().session.end_stroke().unwrap(); + let closed = sends_close(&mut h); + + assert!(!closed); + assert!(h.state().session.modified); + assert_eq!(h.state().ui.windows.unsaved, Some(Unsaved::Quit), "the close asks about the painted stroke"); + } + + #[test] + fn a_stroke_open_when_the_save_returns_quits_once_it_is_canceled() { + let _language = crate::i18n::TEST_LANGUAGE.lock().unwrap_or_else(std::sync::PoisonError::into_inner); + let mut h = stroke_open_when_the_save_returns("stroke-canceled"); + + h.state_mut().session.cancel_stroke(); + let closed = sends_close(&mut h); + + assert!(closed, "nothing is left to save, so the close goes on"); + assert!(h.state().ui.windows.unsaved.is_none()); + } + + #[test] + fn dismissing_the_prompt_during_a_save_cancels_the_quit() { + let _language = crate::i18n::TEST_LANGUAGE.lock().unwrap_or_else(std::sync::PoisonError::into_inner); + let file = temp_file("close-then-dismissed"); + let mut h = harness(); + h.state_mut().session.path = Some(file.display().to_string()); + let (task, sender) = start_held_save(&mut h, &file, true); + request_close(&mut h); + h.get_by_label("Close window").click(); + h.run_steps(2); + assert!(h.state().ui.windows.unsaved.is_none(), "the prompt is dismissed while the save runs"); + + let closed = finish(&mut h, task, &sender); + + assert!(!closed, "a dismissed prompt keeps the app open"); + assert!(!h.state().session.modified); + } } diff --git a/crates/ui-egui/src/windows.rs b/crates/ui-egui/src/windows.rs index 8f83610c..1c4681e7 100644 --- a/crates/ui-egui/src/windows.rs +++ b/crates/ui-egui/src/windows.rs @@ -94,6 +94,14 @@ pub(crate) fn close_request(app: &mut TextureCraftApp, ctx: &egui::Context) { { app.toast(error.to_string(), true); } + #[cfg(not(target_arch = "wasm32"))] + if app.quit_after_stroke && !app.session.stroke_active() { + app.quit_after_stroke = false; + if !ask_to_save(app, crate::state::Unsaved::Quit) { + ctx.send_viewport_cmd(egui::ViewportCommand::Close); + } + } + #[cfg(not(target_arch = "wasm32"))] let waiting_for_save = if closing && let Some(job) = &mut app.save_job { // The running save carries the quit; unsaved changes still open the prompt meanwhile From e016ba2f1034bf29119fffff96e5ed2b3552141a Mon Sep 17 00:00:00 2001 From: vangel76 Date: Wed, 25 Nov 2026 00:51:25 +0100 Subject: [PATCH 30/83] Bring the Settings window in line with the reference (#823) Defaults follow the reference: the system language, Show keyboard helper, Show world axes and the baking options on, and GPU raytracing on and checkable only with a GPU. Show world axes now hides the 3D view's axes. The Iray, Appearance and Folders sections are gone, Temporary Files is Files and holds the Data folder, Recent projects limit sits in Resources, the CPU and RAM limits are sliders in steps of 1 with the core count beside them, and the section hints are removed. The Local cache directory is editable and defaults to the system's temporary folder. The shortcut list adds the reference's manipulator rows after Export Textures, listed as not available yet. --- crates/ui-egui/src/control.rs | 6 + crates/ui-egui/src/keymap.rs | 9 +- crates/ui-egui/src/lib.rs | 23 ++- crates/ui-egui/src/settings_window.rs | 211 +++++++++++---------- crates/ui-egui/src/state.rs | 24 ++- crates/ui-egui/src/viewport.rs | 4 +- crates/ui-egui/tests/it/settings_window.rs | 162 ++++++++++++---- crates/ui-egui/tests/it/shortcut_list.rs | 27 ++- crates/ui-egui/tests/project_limits.rs | 4 +- docs/ui-parity.md | 2 +- 10 files changed, 315 insertions(+), 157 deletions(-) diff --git a/crates/ui-egui/src/control.rs b/crates/ui-egui/src/control.rs index 79050e12..ab03dc37 100644 --- a/crates/ui-egui/src/control.rs +++ b/crates/ui-egui/src/control.rs @@ -111,6 +111,12 @@ fn refresh_draft_preferences(draft: &mut Prefs, previous: &Prefs, current: &Pref gpu_raytracing, libraries, background, + show_world_axes, + show_keyboard_helper, + only_selected_material_when_painting, + save_preprocessed_scene_files, + live_preview_baking, + local_cache_directory, ); } diff --git a/crates/ui-egui/src/keymap.rs b/crates/ui-egui/src/keymap.rs index ee29ac48..17f8acec 100644 --- a/crates/ui-egui/src/keymap.rs +++ b/crates/ui-egui/src/keymap.rs @@ -36,7 +36,14 @@ pub struct Binding { /// /// They are not in [`bindings`], so no key runs them, but another item given their key is reported /// as sharing it. -pub static NOT_AVAILABLE_ACTIONS: [(&str, Binding); 2] = [ +pub static NOT_AVAILABLE_ACTIONS: [(&str, Binding); 9] = [ + ("file.reimportMesh", Binding { id: "ui.manipulator.toggle", group: "Viewport", label: "Show/Hide manipulator", default: Some("Q") }), + ("file.reimportMesh", Binding { id: "ui.manipulator.grow", group: "Viewport", label: "Increase the manipulator size", default: None }), + ("file.reimportMesh", Binding { id: "ui.manipulator.shrink", group: "Viewport", label: "Decrease the manipulator size", default: Some("-") }), + ("file.reimportMesh", Binding { id: "ui.manipulator.space", group: "Viewport", label: "Cycle through manipulation spaces", default: Some("T") }), + ("file.reimportMesh", Binding { id: "ui.warpEdit", group: "Viewport", label: "Toggle warp edition mode", default: Some("Shift+V") }), + ("file.reimportMesh", Binding { id: "ui.manipulator.translate", group: "Viewport", label: "Translate tool", default: Some("W") }), + ("file.reimportMesh", Binding { id: "ui.manipulator.rotate", group: "Viewport", label: "Rotate tool", default: Some("E") }), ("file.reimportMesh", Binding { id: "ui.pauseEngine", group: "Commands", label: "Pause Engine Computation", default: Some("Shift+Esc") }), ("viewport.frame", Binding { id: "ui.toggleAnimation", group: "Viewport", label: "Toggle animation", default: Some("Space") }), ]; diff --git a/crates/ui-egui/src/lib.rs b/crates/ui-egui/src/lib.rs index 47259f2b..f6b25a0f 100644 --- a/crates/ui-egui/src/lib.rs +++ b/crates/ui-egui/src/lib.rs @@ -342,11 +342,8 @@ pub(crate) fn start_ui(saved: Option, session: &mut Session) -> UiState ui.tool_settings.apply(&mut session.tool); ui } - None => { - let mut ui = UiState::default(); - ui.prefs.language = i18n::SYSTEM_LANGUAGE.into(); - ui - } + // The default language follows the operating system + None => UiState::default(), } } @@ -1228,13 +1225,25 @@ pub fn data_folder(pref: &str) -> std::path::PathBuf { std::path::Path::new(&home).join("Documents").join("TextureCraft") } -/// The data folder in use (Settings › Folders › Data folder). +/// The folder for a `Prefs::local_cache_directory` value: that path when it is absolute, +/// otherwise the system's temporary folder. +#[cfg(not(target_arch = "wasm32"))] +pub fn local_cache_folder(pref: &str) -> std::path::PathBuf { + let chosen = std::path::Path::new(pref.trim()); + if chosen.is_absolute() { + return chosen.to_path_buf(); + } + + std::env::temp_dir() +} + +/// The data folder in use (Settings › Files › Data folder). #[cfg(not(target_arch = "wasm32"))] pub fn data_dir() -> std::path::PathBuf { DATA_FOLDER.get().cloned().unwrap_or_else(|| data_folder("")) } -/// `` in the data folder in use (Settings › Folders › Data folder). +/// `` in the data folder in use (Settings › Files › Data folder). #[cfg(not(target_arch = "wasm32"))] pub fn user_dir(sub: &str) -> std::path::PathBuf { data_dir().join(sub) diff --git a/crates/ui-egui/src/settings_window.rs b/crates/ui-egui/src/settings_window.rs index 8fda17b0..7da312bc 100644 --- a/crates/ui-egui/src/settings_window.rs +++ b/crates/ui-egui/src/settings_window.rs @@ -9,7 +9,7 @@ use crate::TextureCraftApp; use crate::file_dialogs::{Bound, FileDialog}; use crate::i18n::{LANGUAGES, SYSTEM_LANGUAGE, n_, tr, trf}; use crate::state::{CAMERA_SPEED_RANGE, LibraryLocation, MAX_RECENT_PROJECTS, Prefs}; -use crate::theme::{Accent, Brightness, Tokens, caption}; +use crate::theme::{Tokens, caption}; use crate::unavailable::NOT_AVAILABLE; use crate::widgets::icon_button; @@ -274,9 +274,17 @@ fn section(ui: &mut Ui, title: &str) { ui.add_space(2.0); } -/// A disabled check box in the right column of a row labelled `label`. -fn disabled_check(ui: &mut Ui, label: egui::Id, mut checked: bool) { - not_available(ui.add_enabled(false, egui::Checkbox::without_text(&mut checked)).labelled_by(label)); +/// A check box in the right column of a row labelled `label`. +fn check(ui: &mut Ui, label: egui::Id, checked: &mut bool) { + ui.add(egui::Checkbox::without_text(checked)).labelled_by(label); +} + +/// A check box with its text. +fn text_check(ui: &mut Ui, text: &str, checked: &mut bool) { + ui.horizontal(|ui| { + ui.add_space(12.0); + ui.checkbox(checked, tr(text)); + }); } /// A disabled check box with its text. @@ -306,6 +314,35 @@ pub fn gpu_note_shown(adapter: Option<&str>) -> bool { adapter.is_none() || cfg!(target_arch = "wasm32") } +/// The Enable GPU raytracing check box for the hardware and the stored choice: whether it can be +/// changed and whether it shows ticked. Without a GPU to trace on it is off and disabled; the +/// stored choice is kept for a machine that has one. +pub fn gpu_raytracing_check(adapter: Option<&str>, stored: bool) -> (bool, bool) { + let supported = !gpu_note_shown(adapter); + (supported, supported && stored) +} + +/// The Max CPU threads slider's position for a stored `work_threads`: 0 (every thread) is the +/// slider's end, the core count. +#[cfg(not(target_arch = "wasm32"))] +fn work_threads_shown(work_threads: u32, cores: u32) -> u32 { + if work_threads == 0 { cores } else { work_threads.min(cores).max(1) } +} + +/// The stored `work_threads` for the slider at `threads`: its end keeps 0, so every thread works +/// on any machine. +#[cfg(not(target_arch = "wasm32"))] +fn work_threads_stored(threads: u32, cores: u32) -> u32 { + if threads >= cores { 0 } else { threads } +} + +/// The note right of a core slider: how many cores this machine has. +#[cfg(not(target_arch = "wasm32"))] +fn cores_in_total(ui: &mut Ui, cores: u32) { + let tk = Tokens::get(ui.ctx()); + ui.label(RichText::new(trf("{count} cores in total", &[("count", &cores)])).color(tk.text_dim)); +} + /// The General page. fn general( ui: &mut Ui, @@ -339,8 +376,8 @@ fn general( .response .labelled_by(label); }); - row(ui, tr("Show keyboard helper"), |ui, label| disabled_check(ui, label, true)); - row(ui, tr("Show world axes"), |ui, label| disabled_check(ui, label, true)); + row(ui, tr("Show keyboard helper"), |ui, label| check(ui, label, &mut p.show_keyboard_helper)); + row(ui, tr("Show world axes"), |ui, label| check(ui, label, &mut p.show_world_axes)); row(ui, tr("Background color"), |ui, _| { for (index, side, name) in [(0, "top", "Top background"), (1, "bottom", "Bottom background")] { let id = format!("settings_background_{side}"); @@ -352,20 +389,17 @@ fn general( ui.add_space(10.0); } }); - row(ui, tr("Only display the selected material when painting"), |ui, label| disabled_check(ui, label, false)); + row(ui, tr("Only display the selected material when painting"), |ui, label| check(ui, label, &mut p.only_selected_material_when_painting)); row(ui, tr("Viewport Scaling"), |ui, label| { - ui.add_enabled_ui(false, |ui| { - not_available( - egui::ComboBox::from_id_salt("settings_viewport_scaling").width(CONTROL_WIDTH).selected_text(tr("Auto")).show_ui(ui, |_| {}).response, - ) + // Auto is the one scaling the views have + egui::ComboBox::from_id_salt("settings_viewport_scaling") + .width(CONTROL_WIDTH) + .selected_text(tr("Auto")) + .show_ui(ui, |ui| { + ui.add(egui::Button::selectable(true, tr("Auto"))); + }) + .response .labelled_by(label); - }); - }); - - row(ui, tr("Recent projects limit"), |ui, label| { - ui.add(egui::DragValue::new(&mut p.recent_projects_limit).range(0..=MAX_RECENT_PROJECTS)) - .labelled_by(label) - .on_hover_text(tr("Number of recent projects to remember. 0 disables recent-project history.")); }); section(ui, n_("LAYER STACK OPTIONS")); @@ -397,12 +431,17 @@ fn general( } section(ui, n_("BAKING OPTIONS")); - disabled_text_check(ui, n_("Save preprocessed scene files"), true); - disabled_text_check(ui, n_("Enable live preview baking process"), true); + text_check(ui, n_("Save preprocessed scene files"), &mut p.save_preprocessed_scene_files); + text_check(ui, n_("Enable live preview baking process"), &mut p.live_preview_baking); + let (gpu_raytracing_enabled, mut gpu_raytracing_ticked) = gpu_raytracing_check(gpu, p.gpu_raytracing); ui.horizontal(|ui| { ui.add_space(12.0); - ui.checkbox(&mut p.gpu_raytracing, tr("Enable GPU raytracing")) + let gpu_raytracing = ui + .add_enabled(gpu_raytracing_enabled, egui::Checkbox::new(&mut gpu_raytracing_ticked, tr("Enable GPU raytracing"))) .on_hover_text(tr("Bakes cast their rays on the graphics card when one is available. Off, they run on the CPU.")); + if gpu_raytracing.changed() { + p.gpu_raytracing = gpu_raytracing_ticked; + } }); if gpu_note_shown(gpu) { ui.horizontal(|ui| { @@ -413,6 +452,17 @@ fn general( section(ui, n_("PREVIEW OPTIONS")); row(ui, tr("Local cache directory"), |ui, label| { + #[cfg(not(target_arch = "wasm32"))] + { + let default = crate::local_cache_folder("").display().to_string(); + ui.add(egui::TextEdit::singleline(&mut p.local_cache_directory).hint_text(default).desired_width(CONTROL_WIDTH - 24.0)).labelled_by(label); + if ui.add(egui::Button::new("R").frame(false)).on_hover_text(tr("Reset to the default folder")).clicked() { + p.local_cache_directory.clear(); + } + } + + // The browser has no folders + #[cfg(target_arch = "wasm32")] ui.add_enabled_ui(false, |ui| { let mut path = String::new(); not_available(ui.add(egui::TextEdit::singleline(&mut path).desired_width(CONTROL_WIDTH - 24.0))).labelled_by(label); @@ -431,7 +481,7 @@ fn general( not_available(ui.add_enabled(false, egui::Button::new(text).min_size(vec2(CONTROL_WIDTH, 40.0)))); }); - section(ui, n_("TEMPORARY FILES")); + section(ui, n_("FILES")); row(ui, tr("Cache directory"), |ui, label| { #[cfg(not(target_arch = "wasm32"))] let mut path = std::env::temp_dir().display().to_string(); @@ -442,57 +492,19 @@ fn general( not_available(ui.add(egui::Button::new("R").frame(false))); }); }); + #[cfg(not(target_arch = "wasm32"))] + row(ui, tr("Data folder"), |ui, label| { + let default = crate::data_folder("").display().to_string(); + ui.add(egui::TextEdit::singleline(&mut p.data_folder).hint_text(default).desired_width(CONTROL_WIDTH - 30.0)).labelled_by(label); + if ui.button("...").on_hover_text(tr("Choose the data folder")).clicked() { + *pick = Some(SettingsFolder::DataFolder); + } + }); section(ui, n_("SPARSE VIRTUAL TEXTURE")); disabled_text_check(ui, n_("Hardware support acceleration"), true); - section(ui, n_("IRAY HARDWARE")); - disabled_text_check(ui, gpu.unwrap_or(n_("no GPU")), true); - disabled_text_check(ui, n_("CPU"), false); - // TextureCraft's own settings, after the reference sections - section(ui, n_("APPEARANCE")); - row(ui, tr("Interface scale"), |ui, label| { - ui.add(egui::Slider::new(&mut p.ui_scale, 0.75..=2.0).fixed_decimals(2)).labelled_by(label); - }); - row(ui, tr("Brightness"), |ui, label| { - egui::ComboBox::from_id_salt("settings_brightness") - .width(140.0) - .selected_text(tr(p.brightness.label())) - .show_ui(ui, |ui| { - for b in Brightness::ALL { - ui.selectable_value(&mut p.brightness, b, tr(b.label())); - } - }) - .response - .labelled_by(label); - }); - row(ui, tr("Accent color"), |ui, _| { - for a in Accent::ALL { - let (rect, resp) = ui.allocate_exact_size(vec2(20.0, 20.0), egui::Sense::click()); - resp.widget_info(|| egui::WidgetInfo::selected(egui::Role::RadioButton, true, p.accent == a, tr(a.label()))); - let ring = if p.accent == a { - tk.text_strong - } else if resp.hovered() { - tk.text_dim - } else { - Color32::TRANSPARENT - }; - ui.painter().circle(rect.center(), 6.5, a.colors(tk.dark).0, egui::Stroke::NONE); - ui.painter().circle_stroke(rect.center(), 9.0, egui::Stroke::new(1.5, ring)); - if resp.on_hover_text(tr(a.label())).clicked() { - p.accent = a; - } - } - }); - #[cfg(not(target_arch = "wasm32"))] - { - row(ui, tr("Title bar"), |ui, _| { - ui.checkbox(&mut p.system_title_bar, tr("System title bar (applies on restart)")) - .on_hover_text(tr("Use the operating system's window frame and buttons instead of TextureCraft's own title bar")); - }); - } - section(ui, n_("VIEWPORT")); row(ui, tr("Texture resolution"), |ui, _| { ui.horizontal(|ui| { @@ -510,15 +522,22 @@ fn general( #[cfg(not(target_arch = "wasm32"))] { row(ui, tr("Max CPU threads for work"), |ui, label| { - ui.add(egui::DragValue::new(&mut p.work_threads).range(0..=available_cores)) + let mut threads = work_threads_shown(p.work_threads, available_cores); + let slider = ui + .add(egui::Slider::new(&mut threads, 1..=available_cores.max(1)).step_by(1.0)) .labelled_by(label) - .on_hover_text(tr("Threads that paint, bake and export. 0 uses every CPU thread. Applies on restart.")); + .on_hover_text(tr("Threads that paint, bake and export. Applies on restart.")); + if slider.changed() { + p.work_threads = work_threads_stored(threads, available_cores); + } + cores_in_total(ui, available_cores); }); row(ui, tr("Cores kept for the UI"), |ui, label| { - ui.add(egui::DragValue::new(&mut p.reserved_cores).range(0..=available_cores)).labelled_by(label); + ui.add(egui::Slider::new(&mut p.reserved_cores, 0..=available_cores).step_by(1.0)).labelled_by(label); + cores_in_total(ui, available_cores); }); row(ui, tr("Max RAM while saving"), |ui, label| { - ui.add(egui::DragValue::new(&mut p.save_ram_percent).range(1..=100).suffix(" %")).labelled_by(label); + ui.add(egui::Slider::new(&mut p.save_ram_percent, 0..=100).step_by(1.0).suffix(" %")).labelled_by(label); let budget_bytes = texturecraft_engine::formats::save_ram_budget(available_ram_bytes, p.save_ram_percent); ui.label(format!("≈ {:.2} GiB", budget_bytes as f64 / (1_u64 << 30) as f64)); }); @@ -528,10 +547,11 @@ fn general( .labelled_by(label) .on_hover_text(tr("Maximum decompressed project data. Increase this limit to open larger projects.")); }); - #[cfg(not(target_arch = "wasm32"))] - { - note(ui, tr("Saving uses the other cores and at most this share of the free RAM. At least one core always works.")); - } + row(ui, tr("Recent projects limit"), |ui, label| { + ui.add(egui::DragValue::new(&mut p.recent_projects_limit).range(0..=MAX_RECENT_PROJECTS)) + .labelled_by(label) + .on_hover_text(tr("Number of recent projects to remember. 0 disables recent-project history.")); + }); #[cfg(not(target_arch = "wasm32"))] { @@ -539,38 +559,9 @@ fn general( row(ui, tr("Autosave every"), |ui, label| { ui.add(egui::DragValue::new(&mut p.autosave_minutes).range(0..=120).suffix(format!(" {}", tr("min")))).labelled_by(label); }); - note(ui, &trf("0 turns autosave off. Copies go to {folder}", &[("folder", &crate::user_dir("autosave").display())])); - - section(ui, n_("FOLDERS")); - row(ui, tr("Data folder"), |ui, label| { - let default = crate::data_folder("").display().to_string(); - ui.add(egui::TextEdit::singleline(&mut p.data_folder).hint_text(default).desired_width(CONTROL_WIDTH - 30.0)).labelled_by(label); - if ui.button("...").on_hover_text(tr("Choose the data folder")).clicked() { - *pick = Some(SettingsFolder::DataFolder); - } - }); - for (label, dir) in [(tr("Smart materials"), crate::library_dir()), (tr("UI layouts"), crate::user_dir("layouts"))] { - row(ui, label, |ui, _| ui.label(RichText::new(dir.display().to_string()).small().color(tk.text_dim))); - } - note( - ui, - tr( - "Autosaves, smart materials, presets, templates and UI layouts go to the data folder. A new folder applies on restart; files already saved stay where they are.", - ), - ); } } -/// A small dim note under a section's rows. -#[cfg(not(target_arch = "wasm32"))] -fn note(ui: &mut Ui, text: &str) { - let tk = Tokens::get(ui.ctx()); - ui.horizontal(|ui| { - ui.add_space(12.0); - ui.add(egui::Label::new(RichText::new(text).small().color(tk.text_dim)).wrap()); - }); -} - /// The built-in library locations as (name, path): the user's assets in the data folder, the /// assets built into TextureCraft, and the font folders text alphas read. pub fn built_in_locations() -> Vec<(String, String)> { @@ -797,6 +788,16 @@ mod tests { assert_eq!(app.next_autosave, 70.0, "an unchanged interval keeps the deadline"); } + #[test] + fn max_cpu_threads_shows_every_thread_at_the_slider_end_and_keeps_it_as_every_thread() { + let cores = 8; + + assert_eq!(work_threads_shown(0, cores), cores, "every thread is the slider's end"); + assert_eq!(work_threads_shown(64, cores), cores, "a larger machine's choice stays inside this one"); + assert_eq!(work_threads_stored(cores, cores), 0, "the end follows any machine's core count"); + assert_eq!(work_threads_stored(work_threads_shown(3, cores), cores), 3); + } + #[test] fn a_folder_answer_cannot_edit_a_reopened_settings_window() { let session = texturecraft_engine::Session::closed().unwrap(); diff --git a/crates/ui-egui/src/state.rs b/crates/ui-egui/src/state.rs index 0c767e1b..9d97f54d 100644 --- a/crates/ui-egui/src/state.rs +++ b/crates/ui-egui/src/state.rs @@ -187,6 +187,22 @@ pub struct Prefs { /// The plain background of the 3D and 2D views at Environment Opacity 0 (Settings > General > /// Background color): the color at the top and at the bottom, linear RGB. pub background: [[f32; 3]; 2], + /// The 3D view draws the X, Y and Z axes in its corner. + pub show_world_axes: bool, + /// Settings > General > Show keyboard helper. Stored only: TextureCraft has no keyboard helper yet. + pub show_keyboard_helper: bool, + /// Settings > General > Only display the selected material when painting. Stored only: the + /// views always show every texture set. + pub only_selected_material_when_painting: bool, + /// Settings > Baking options > Save preprocessed scene files. Stored only: bakes keep no + /// preprocessed scene files. + pub save_preprocessed_scene_files: bool, + /// Settings > Baking options > Enable live preview baking process. Stored only: the live bake + /// preview always runs. + pub live_preview_baking: bool, + /// Settings > Preview options > Local cache directory (desktop). Empty or relative: the + /// system's temporary folder. Stored only: TextureCraft writes no preview cache yet. + pub local_cache_directory: String, } /// The orbit speed the built-in navigation runs at. @@ -200,7 +216,7 @@ impl Default for Prefs { ui_scale: 1.0, autosave_minutes: 10, recent_projects_limit: 10, - language: "en".into(), + language: crate::i18n::SYSTEM_LANGUAGE.into(), viewport_texture: 0, brightness: crate::theme::Brightness::default(), accent: crate::theme::Accent::default(), @@ -218,6 +234,12 @@ impl Default for Prefs { gpu_raytracing: true, libraries: Vec::new(), background: texturecraft_render::DEFAULT_BACKGROUND, + show_world_axes: true, + show_keyboard_helper: true, + only_selected_material_when_painting: false, + save_preprocessed_scene_files: true, + live_preview_baking: true, + local_cache_directory: String::new(), } } } diff --git a/crates/ui-egui/src/viewport.rs b/crates/ui-egui/src/viewport.rs index 3c5a3d7e..7a83ccf6 100644 --- a/crates/ui-egui/src/viewport.rs +++ b/crates/ui-egui/src/viewport.rs @@ -1101,7 +1101,9 @@ fn view_3d(app: &mut TextureCraftApp, ui: &mut Ui, rect: Rect, sync: &mut Pendin solo_notice(app, ui, rect); view_header(app, ui, rect, "v3d"); mask_view_badge(app, ui, rect); - axis_gizmo(ui, rect, app, None); + if app.ui.prefs.show_world_axes { + axis_gizmo(ui, rect, app, None); + } crate::nav_buttons::show(app, ui, rect, crate::nav_buttons::NavView::Scene); } diff --git a/crates/ui-egui/tests/it/settings_window.rs b/crates/ui-egui/tests/it/settings_window.rs index 4e8508b1..7ca014c9 100644 --- a/crates/ui-egui/tests/it/settings_window.rs +++ b/crates/ui-egui/tests/it/settings_window.rs @@ -4,8 +4,10 @@ use egui::{Event, Key, Modifiers, Role}; use egui_kittest::Harness; use egui_kittest::kittest::{NodeT, Queryable}; use texturecraft_engine::Session; -use texturecraft_ui_egui::settings_window::{DEFAULT_LIBRARY_NOTE, GPU_RAYTRACING_UNAVAILABLE, PROJECT_OPEN_NOTE, SHORTCUT_ERRORS, SettingsPage}; -use texturecraft_ui_egui::state::{LibraryLocation, UiState}; +use texturecraft_ui_egui::settings_window::{ + DEFAULT_LIBRARY_NOTE, GPU_RAYTRACING_UNAVAILABLE, PROJECT_OPEN_NOTE, SHORTCUT_ERRORS, SettingsPage, gpu_raytracing_check, +}; +use texturecraft_ui_egui::state::{LibraryLocation, Prefs, UiState}; use texturecraft_ui_egui::unavailable::NOT_AVAILABLE; use texturecraft_ui_egui::{TextureCraftApp, menus}; @@ -84,47 +86,126 @@ fn the_left_column_switches_between_the_three_pages() { fn the_general_page_starts_at_the_reference_defaults() { let mut h = harness(texturecraft_engine::sample_session(128, 32).unwrap()); open_settings(&mut h); - h.state_mut().ui.windows.settings_draft.as_mut().unwrap().prefs.language = texturecraft_ui_egui::i18n::SYSTEM_LANGUAGE.into(); + + // A reset puts the defaults in the window; the app itself keeps English for the exact-text checks + h.state_mut().ui.windows.settings_draft.as_mut().unwrap().prefs = Prefs::default(); h.run_steps(3); + assert_eq!(h.get_by_role_and_label(Role::ComboBox, "Language").value().as_deref(), Some("Default (System Language)")); - assert_eq!(h.get_by_role_and_label(Role::ComboBox, "Viewport Scaling").value().as_deref(), Some("Auto")); + let scaling = h.get_by_role_and_label(Role::ComboBox, "Viewport Scaling"); + assert_eq!(scaling.value().as_deref(), Some("Auto")); + assert!(!scaling.accesskit_node().is_disabled(), "Viewport Scaling can be opened"); assert_eq!(h.get_by_role_and_label(Role::SpinButton, "Local cache budget (in MB)").accesskit_node().numeric_value(), Some(4000.0)); - for label in [ - "Show keyboard helper", - "Show world axes", - "Use simplified thumbnails (improves performance)", - "Save preprocessed scene files", - "Enable live preview baking process", - "Enable GPU raytracing", - "Hardware support acceleration", - ] { + for label in ["Show keyboard helper", "Show world axes", "Save preprocessed scene files", "Enable live preview baking process"] { + assert!(toggled(&h, label), "{label} is ticked"); + assert!(!h.get_by_label(label).accesskit_node().is_disabled(), "{label} can be changed"); + } + for label in ["Use simplified thumbnails (improves performance)", "Hardware support acceleration"] { assert!(toggled(&h, label), "{label} is ticked"); } - for label in ["Only display the selected material when painting", "CPU"] { - assert!(!toggled(&h, label), "{label} is not ticked"); - } + let only_selected = "Only display the selected material when painting"; + assert!(!toggled(&h, only_selected) && !h.get_by_label(only_selected).accesskit_node().is_disabled()); assert!(h.query_all_by_label("Inverse direction").all(|node| node.accesskit_node().toggled() == Some(egui::accesskit::Toggled::False))); - let prefs = texturecraft_ui_egui::state::Prefs::default(); + let local_cache = h.get_by_role_and_label(Role::TextInput, "Local cache directory"); + assert!(!local_cache.accesskit_node().is_disabled(), "the local cache directory can be edited"); + assert_eq!(texturecraft_ui_egui::local_cache_folder(&Prefs::default().local_cache_directory), std::env::temp_dir()); + + let prefs = Prefs::default(); + assert_eq!(prefs.language, texturecraft_ui_egui::i18n::SYSTEM_LANGUAGE, "a reset follows the system language"); assert_eq!((prefs.rotation_speed, prefs.zoom_speed, prefs.wheel_speed), (2.0, 1.0, 1.0)); } +#[test] +fn the_general_page_keeps_the_reference_sections_and_moves_data_folder_and_recent_projects() { + let mut h = harness(Session::closed().unwrap()); + open_settings(&mut h); + + for gone in ["TEMPORARY FILES", "IRAY HARDWARE", "APPEARANCE", "FOLDERS", "PRIVACY", "Interface scale", "Accent color"] { + assert!(h.query_by_label(gone).is_none(), "{gone} is not on the page"); + } + for hint in ["Saving uses the other cores", "0 turns autosave off", "A new folder applies on restart"] { + assert!(h.query_by_label_contains(hint).is_none(), "the hint \"{hint}\" is gone"); + } + + let top = |h: &Harness<'_, TextureCraftApp>, label: &str| h.get_by_label(label).rect().top(); + let data_folder = h.get_by_role_and_label(Role::TextInput, "Data folder").rect().top(); + assert!(top(&h, "FILES") < data_folder && data_folder < top(&h, "SPARSE VIRTUAL TEXTURE"), "Data folder is in Files"); + let recent = h.get_by_role_and_label(Role::SpinButton, "Recent projects limit").rect().top(); + assert!(top(&h, "RESOURCES") < recent && recent < top(&h, "AUTOSAVE"), "Recent projects limit is in Resources"); + assert!(top(&h, "INTERFACE OPTIONS") < top(&h, "RESOURCES")); +} + +#[test] +fn the_resource_sliders_step_by_one_and_follow_the_arrow_keys() { + let mut h = harness(Session::closed().unwrap()); + open_settings(&mut h); + + let threads = h.get_by_role_and_label(Role::Slider, "Max CPU threads for work").accesskit_node(); + let cores = threads.max_numeric_value().unwrap(); + assert_eq!(threads.numeric_value(), Some(cores), "every thread works by default"); + assert_eq!(threads.min_numeric_value(), Some(1.0)); + let reserved = h.get_by_role_and_label(Role::Slider, "Cores kept for the UI").accesskit_node(); + assert_eq!((reserved.min_numeric_value(), reserved.max_numeric_value()), (Some(0.0), Some(cores))); + let ram = h.get_by_role_and_label(Role::Slider, "Max RAM while saving").accesskit_node(); + assert_eq!((ram.min_numeric_value(), ram.max_numeric_value()), (Some(0.0), Some(100.0))); + for label in ["Max CPU threads for work", "Cores kept for the UI", "Max RAM while saving"] { + assert_eq!(h.get_by_role_and_label(Role::Slider, label).accesskit_node().numeric_value_step(), Some(1.0), "{label} moves in steps of 1"); + } + assert_eq!(h.query_all_by_label(&format!("{cores} cores in total")).count(), 2, "both core sliders name the total"); + + let ram_percent = |h: &Harness<'_, TextureCraftApp>| h.state().ui.windows.settings_draft.as_ref().unwrap().prefs.save_ram_percent; + let before = ram_percent(&h); + h.get_by_role_and_label(Role::Slider, "Max RAM while saving").focus(); + h.run_steps(2); + press_key(&mut h, Key::ArrowRight); + assert_eq!(ram_percent(&h), before + 1, "the right arrow adds one percent"); + press_key(&mut h, Key::ArrowLeft); + press_key(&mut h, Key::ArrowLeft); + assert_eq!(ram_percent(&h), before - 1, "the left arrow takes one percent"); +} + +#[test] +fn the_enabled_interface_options_answer_the_keyboard() { + let mut h = harness(Session::closed().unwrap()); + open_settings(&mut h); + let draft = |h: &Harness<'_, TextureCraftApp>| h.state().ui.windows.settings_draft.as_ref().unwrap().prefs.clone(); + let before = draft(&h); + + for label in ["Show keyboard helper", "Show world axes", "Only display the selected material when painting"] { + h.get_by_label(label).focus(); + h.run_steps(2); + press_key(&mut h, Key::Space); + } + + let after = draft(&h); + assert_ne!(after.show_keyboard_helper, before.show_keyboard_helper); + assert_ne!(after.show_world_axes, before.show_world_axes); + assert_ne!(after.only_selected_material_when_painting, before.only_selected_material_when_painting); +} + +#[test] +fn the_local_cache_directory_takes_a_folder_and_r_goes_back_to_the_default() { + let mut h = harness(Session::closed().unwrap()); + open_settings(&mut h); + let folder = std::env::temp_dir().join("tc-settings-local-cache").display().to_string(); + let stored = |h: &Harness<'_, TextureCraftApp>| h.state().ui.windows.settings_draft.as_ref().unwrap().prefs.local_cache_directory.clone(); + + type_into(&mut h, "Local cache directory", &folder); + assert_eq!(stored(&h), folder); + + h.query_all_by_label("R").find(|node| !node.accesskit_node().is_disabled()).unwrap().click(); + h.run_steps(3); + assert!(stored(&h).is_empty(), "R goes back to the default folder"); +} + #[test] fn a_control_the_app_lacks_is_disabled_and_says_so_on_hover() { let mut h = harness(texturecraft_engine::sample_session(128, 32).unwrap()); h.ctx.all_styles_mut(|style| style.interaction.tooltip_delay = 0.0); open_settings(&mut h); let away = h.get_by_role_and_label(Role::Tab, "Libraries").rect().center(); - for label in [ - "Show keyboard helper", - "Show world axes", - "Only display the selected material when painting", - "Use simplified thumbnails (improves performance)", - "Save preprocessed scene files", - "Enable live preview baking process", - "Hardware support acceleration", - "CPU", - ] { + for label in ["Use simplified thumbnails (improves performance)", "Hardware support acceleration"] { h.hover_at(away); h.run_steps(3); assert!(h.query_by_label(NOT_AVAILABLE).is_none(), "no hint before hovering {label}"); @@ -139,7 +220,6 @@ fn a_control_the_app_lacks_is_disabled_and_says_so_on_hover() { for step in ["−", "+"] { assert!(h.query_all_by_label(step).any(|node| node.accesskit_node().is_disabled()), "the cache budget's {step} is disabled"); } - assert!(!h.get_by_label("Enable GPU raytracing").accesskit_node().is_disabled(), "GPU raytracing switches bakes to the CPU"); for label in ["Rotation speed", "Zoom speed", "Wheel speed"] { assert!(h.query_by_label(label).is_some(), "{label} is shown"); } @@ -151,7 +231,7 @@ fn cancel_drops_the_changes_and_ok_applies_and_keeps_them() { let before = h.state().ui.prefs.clone(); open_settings(&mut h); h.get_by_role_and_label(Role::SpinButton, "Autosave every").set_value_accesskit(25.0); - click(&mut h, "Enable GPU raytracing"); + click(&mut h, "Show world axes"); h.run_steps(2); assert_eq!(h.state().ui.prefs, before, "edits wait for OK"); click(&mut h, "Cancel"); @@ -165,20 +245,20 @@ fn cancel_drops_the_changes_and_ok_applies_and_keeps_them() { "a new window starts from the settings in use" ); h.get_by_role_and_label(Role::SpinButton, "Autosave every").set_value_accesskit(25.0); - h.get_by_role_and_label(Role::SpinButton, "Max CPU threads for work").set_value_accesskit(1.0); + h.get_by_role_and_label(Role::Slider, "Max CPU threads for work").set_value_accesskit(1.0); h.get_by_role_and_label(Role::SpinButton, "Max project size on open").set_value_accesskit(12.0); h.run_steps(2); h.query_all_by_label("Inverse direction").next().unwrap().scroll_to_me(); h.run_steps(3); h.query_all_by_label("Inverse direction").next().unwrap().click(); h.run_steps(2); - click(&mut h, "Enable GPU raytracing"); + click(&mut h, "Show world axes"); click(&mut h, "OK"); let prefs = h.state().ui.prefs.clone(); assert!(!h.state().ui.windows.settings, "OK closes the window"); assert_eq!((prefs.autosave_minutes, prefs.work_threads, prefs.project_open_limit_gib), (25, 1, 12)); - assert!(prefs.zoom_inverse && !prefs.wheel_inverse && !prefs.gpu_raytracing); + assert!(prefs.zoom_inverse && !prefs.wheel_inverse && !prefs.show_world_axes); assert!(prefs.drag_zoom_scale() < 0.0, "inverted zoom runs the other way"); let mut storage = MemoryStorage::default(); @@ -434,16 +514,22 @@ fn the_libraries_page_hides_the_add_row_with_a_project_open_and_explains_the_def } #[test] -fn the_baking_options_say_when_there_is_no_gpu_to_trace_on() { - // The condition, with and without an adapter (the harness's own adapter is not under test) +fn gpu_raytracing_is_on_and_checkable_with_a_gpu_and_off_and_disabled_without() { + let with_gpu = !cfg!(target_arch = "wasm32"); + assert_eq!(gpu_raytracing_check(Some("Some GPU"), true), (with_gpu, with_gpu), "a GPU keeps it on and checkable"); + assert_eq!(gpu_raytracing_check(Some("Some GPU"), false), (with_gpu, false), "a GPU shows the stored choice"); + assert_eq!(gpu_raytracing_check(None, true), (false, false), "without a GPU it is off and disabled"); assert!(texturecraft_ui_egui::settings_window::gpu_note_shown(None)); - assert_eq!(texturecraft_ui_egui::settings_window::gpu_note_shown(Some("Some GPU")), cfg!(target_arch = "wasm32")); - // The page shows the note exactly when the harness has no adapter (the IRAY HARDWARE row says "no GPU") + // The page follows the harness's own adapter, whichever it has let mut h = harness(texturecraft_engine::sample_session(128, 32).unwrap()); open_settings(&mut h); - let no_gpu = h.query_by_label("no GPU").is_some(); - assert_eq!(h.query_by_label(GPU_RAYTRACING_UNAVAILABLE).is_some(), no_gpu, "the note shows with no GPU and only then"); + let supported = h.state().render_state.is_some() && with_gpu; + let check = h.get_by_label("Enable GPU raytracing"); + assert_eq!(!check.accesskit_node().is_disabled(), supported, "it can be changed exactly when there is a GPU"); + assert_eq!(toggled(&h, "Enable GPU raytracing"), supported, "it is on exactly when there is a GPU"); + assert_eq!(h.query_by_label(GPU_RAYTRACING_UNAVAILABLE).is_some(), !supported, "the note shows with no GPU and only then"); + assert!(h.state().ui.prefs.gpu_raytracing, "the stored choice stays for a machine with a GPU"); } #[test] diff --git a/crates/ui-egui/tests/it/shortcut_list.rs b/crates/ui-egui/tests/it/shortcut_list.rs index c603cbde..0be5b044 100644 --- a/crates/ui-egui/tests/it/shortcut_list.rs +++ b/crates/ui-egui/tests/it/shortcut_list.rs @@ -29,7 +29,7 @@ fn no_two_default_shortcuts_are_the_same() { } } for (_, row) in &NOT_AVAILABLE_ACTIONS { - let key = row.default.unwrap(); + let Some(key) = row.default else { continue }; assert!(!seen.contains_key(key), "{} shows {key}, which another item has", row.label); } } @@ -83,3 +83,28 @@ fn a_key_listed_for_a_missing_function_is_reported_as_shared() { assert!(h.query_by_label_contains("One or several errors").is_some(), "Space is Toggle animation's"); assert!(h.get_by_label("OK").accesskit_node().is_disabled()); } + +#[test] +fn the_manipulator_rows_follow_export_textures_in_the_reference_order() { + let mut h = harness(); + let ctx = h.ctx.clone(); + menus::invoke(h.state_mut(), &ctx, "ui.settings"); + h.run_steps(4); + h.get_by_role_and_label(Role::Tab, "Shortcuts").click(); + h.run_steps(4); + + let rows = [ + "Export Textures...", + "Show/Hide manipulator", + "Increase the manipulator size", + "Decrease the manipulator size", + "Cycle through manipulation spaces", + "Toggle warp edition mode", + "Translate tool", + "Rotate tool", + "Reimport mesh", + ]; + let tops: Vec = rows.iter().map(|label| h.get_by_label(label).rect().top()).collect(); + + assert!(tops.windows(2).all(|pair| pair[0] < pair[1]), "{rows:?} run top to bottom: {tops:?}"); +} diff --git a/crates/ui-egui/tests/project_limits.rs b/crates/ui-egui/tests/project_limits.rs index c6c3e34a..69e67067 100644 --- a/crates/ui-egui/tests/project_limits.rs +++ b/crates/ui-egui/tests/project_limits.rs @@ -33,11 +33,11 @@ fn resource_settings_follow_hardware_persist_and_apply_before_control_requests() harness.run_steps(3); let edited = |harness: &Harness<'_, TextureCraftApp>| harness.state().ui.windows.settings_draft.as_ref().unwrap().prefs.clone(); assert_eq!(edited(&harness).reserved_cores, available_cores, "preferences from a larger machine are clamped"); - harness.get_by_role_and_label(egui::Role::SpinButton, "Cores kept for the UI").set_value_accesskit(f64::from(u32::MAX)); + harness.get_by_role_and_label(egui::Role::Slider, "Cores kept for the UI").set_value_accesskit(f64::from(u32::MAX)); harness.run_steps(3); assert_eq!(edited(&harness).reserved_cores, available_cores, "editing cannot exceed this machine's CPU count"); assert!(harness.query_by_label("≈ 8.00 GiB").is_some(), "50% of 16 GiB is shown beside the percentage"); - harness.get_by_role_and_label(egui::Role::SpinButton, "Max RAM while saving").set_value_accesskit(25.0); + harness.get_by_role_and_label(egui::Role::Slider, "Max RAM while saving").set_value_accesskit(25.0); harness.run_steps(3); assert!(harness.query_by_label("≈ 4.00 GiB").is_some(), "the byte estimate follows the edited percentage"); diff --git a/docs/ui-parity.md b/docs/ui-parity.md index 1e45c49d..1bd95040 100644 --- a/docs/ui-parity.md +++ b/docs/ui-parity.md @@ -154,7 +154,7 @@ that closes it back onto the bar; the float is saved with the UI state. | UI-12 | Generator depth and property coverage | **UI + source.** The picker contains seven kinds. Switching to Position, changing Global balance and duplicating the effect worked. Shared global adjustments, resolution and input slots already exist; that does not establish the richer generator/control inventory in [#374](https://github.com/storytold/texturecraft/issues/374) | Audit each generator's inputs, micro-detail behavior and controls against the reference; do not count seven shared implementations as equivalent to its whole catalog | | UI-13 | Narrow workspace readability | **UI.** At 1280 × 800 the app rendered, both views stayed visible and the toolbar exposed scroll arrows. Layer names/types became heavily truncated, the layer toolbar wrapped, and Properties needed scrolling. This was not an input-failure or docking-persistence test | Repeat the editing tasks at smaller sizes, widen/rearrange panels, check full-name tooltips and keyboard access, and retain the layout after restart. Since then: the Layers toolbar stays on one row at 1280 × 800 (its channel box shrinks), and a cut-short layer name or type shows in full on hover. Properties scrolling and restart persistence are unchanged | | UI-14 | Assets panel filters | **UI + source.** The type dropdown lists the reference entries in its order, Fonts and Show all included. Saved searches and Filter by path are separate scrollable panes with a divider that supports pointer and keyboard resizing and saves its position with the UI state ([#640](https://github.com/storytold/texturecraft/issues/640)). Fonts, the built-in saved searches Favorites, 3D Assets and Flattened layers, and the System fonts and User fonts libraries are listed but greyed with "Not available yet" | Give fonts, favorites, 3D assets and flattened layers real assets, then enable those rows and check that each one filters the grid | -| UI-15 | Edit > Settings ([#637](https://github.com/storytold/texturecraft/issues/637)) | **Source + headless UI tests.** The window has the reference's General, Shortcuts and Libraries pages with OK and Cancel, and the General sections in its order (no Privacy section: TextureCraft sends no usage data). Language (with Default (System Language)), the camera rotation, zoom and wheel speeds with Inverse direction, Enable GPU raytracing, the Shortcuts page and adding or removing library locations work. Show keyboard helper, Show world axes, Background color, Only display the selected material when painting, Viewport Scaling, Default UV scale for materials, simplified thumbnails, the other baking options, the preview cache and shader, the temporary cache directory, sparse virtual texture and the IRAY HARDWARE choices are shown disabled with "Not available yet". A location's Default choice is fixed to your_assets. The Shortcuts page has the sections Actions, Mouse shortcuts and Modifiers shortcuts and a Reset all to default button; Delete clears a binding; a shared shortcut shows a warning naming the other action, a warning on the page icon and the footer "One or several errors have been found in Shortcuts settings", and OK stays disabled until it is gone (the mouse and modifier rows are shown disabled, the viewports read those gestures from code). The shortcut list uses the reference's action names, order and default keys ("Open project", "Save as project", "Switch to baking mode" Ctrl+Shift+B, "Switch to edition mode" F9, "Camera projection: Perspective view" F5, "Show entire mesh/path", "Select next camera" `>`, "Select previous camera" `<`, "Viewers layout: 3D/2D" F1 to "Viewers layout: Swap 3D/2D" F4 and so on); Quit keeps Ctrl+Q and the menus keep their own texts. "Show mesh wireframe" is a new bindable command without a key; "Pause Engine Computation" (Shift+Esc) and "Toggle animation" (Space) are listed disabled with "Not available yet". The window reopens on the page it was closed on. With a project open the Libraries page hides the add row and shows "Library locations can't be added/removed when a project is opened."; the default library's "−" says "Cannot remove the default library.". "GPU raytracing not available for your hardware." shows under the Baking options when there is no GPU. TextureCraft's own settings (appearance, viewport textures, resources, autosave, folders) follow the reference sections | Run the window in the native app; wire each disabled control as its function lands | +| UI-15 | Edit > Settings ([#637](https://github.com/storytold/texturecraft/issues/637)) | **Source + headless UI tests.** The window has the reference's General, Shortcuts and Libraries pages with OK and Cancel, and the General sections in its order (no Privacy section: TextureCraft sends no usage data). Language (Default (System Language) by default and after a reset), the camera rotation, zoom and wheel speeds with Inverse direction, Show world axes (the 3D view's X, Y and Z corner), the Shortcuts page and adding or removing library locations work. Enable GPU raytracing is on and can be changed when there is a GPU, and off and disabled without one ([#823](https://github.com/storytold/texturecraft/issues/823)). Show keyboard helper and Save preprocessed scene files (on), Only display the selected material when painting (off), Enable live preview baking process (on), Viewport Scaling (only Auto) and the Local cache directory (empty is the system's temporary folder; R goes back to it) can be changed and are kept, but have no effect yet. Default UV scale for materials, simplified thumbnails, the preview cache budget and shader, the Files cache directory and sparse virtual texture are shown disabled with "Not available yet". There is no IRAY HARDWARE section. A location's Default choice is fixed to your_assets. The Shortcuts page has the sections Actions, Mouse shortcuts and Modifiers shortcuts and a Reset all to default button; Delete clears a binding; a shared shortcut shows a warning naming the other action, a warning on the page icon and the footer "One or several errors have been found in Shortcuts settings", and OK stays disabled until it is gone (the mouse and modifier rows are shown disabled, the viewports read those gestures from code). The shortcut list uses the reference's action names, order and default keys ("Open project", "Show/Hide manipulator" Q to "Rotate tool" E after "Export Textures...", "Save as project", "Switch to baking mode" Ctrl+Shift+B, "Switch to edition mode" F9, "Camera projection: Perspective view" F5, "Show entire mesh/path", "Select next camera" `>`, "Select previous camera" `<`, "Viewers layout: 3D/2D" F1 to "Viewers layout: Swap 3D/2D" F4 and so on); Quit keeps Ctrl+Q and the menus keep their own texts. "Show mesh wireframe" is a new bindable command without a key; "Show/Hide manipulator", "Increase the manipulator size", "Decrease the manipulator size", "Cycle through manipulation spaces", "Toggle warp edition mode", "Translate tool", "Rotate tool", "Pause Engine Computation" (Shift+Esc) and "Toggle animation" (Space) are listed disabled with "Not available yet". The window reopens on the page it was closed on. With a project open the Libraries page hides the add row and shows "Library locations can't be added/removed when a project is opened."; the default library's "−" says "Cannot remove the default library.". "GPU raytracing not available for your hardware." shows under the Baking options when there is no GPU. The reference's TEMPORARY FILES section is called FILES and also holds the Data folder. TextureCraft's own settings follow the reference sections: VIEWPORT (texture resolution), RESOURCES (Max CPU threads for work, default every thread, and Cores kept for the UI as sliders in steps of 1 with the core count beside them, Max RAM while saving as a 0-100% slider, Max project size on open, Recent projects limit) and AUTOSAVE. There is no appearance, folders or analytics section: interface scale, brightness, accent colour and the system title bar stay in the saved settings and `ui.set` | Run the window in the native app; wire each disabled control as its function lands | Bake workflow (issue [#651](https://github.com/storytold/texturecraft/issues/651)): Mesh Map Bakers has a Presets menu (save, load, delete named bake settings; Apply to All Texture Sets) and a finished From a59e29bea19d76278a4fc321e4f4172a6982dcc5 Mon Sep 17 00:00:00 2001 From: vangel76 Date: Wed, 25 Nov 2026 00:55:25 +0100 Subject: [PATCH 31/83] Space the UV layout guards --- crates/formats/src/mesh_import/mod.rs | 1 + crates/formats/src/project_file/mod.rs | 1 + crates/formats/src/project_file/uv_layout.rs | 3 +++ 3 files changed, 5 insertions(+) diff --git a/crates/formats/src/mesh_import/mod.rs b/crates/formats/src/mesh_import/mod.rs index f9eed9d6..22eba9c9 100644 --- a/crates/formats/src/mesh_import/mod.rs +++ b/crates/formats/src/mesh_import/mod.rs @@ -550,6 +550,7 @@ fn apply_corner_uvs(mesh: &mut Mesh, layout: &[Vec2]) -> Result<()> { if layout.len() != mesh.indices.len() { return Err(FormatError::Invalid(format!("the saved UV layout has {} corners but the mesh has {}", layout.len(), mesh.indices.len()))); } + if layout.iter().any(|uv| !uv.is_finite()) { return Err(FormatError::Invalid("the saved UV layout has non-finite UVs".into())); } diff --git a/crates/formats/src/project_file/mod.rs b/crates/formats/src/project_file/mod.rs index 2f8b1d67..8052d627 100644 --- a/crates/formats/src/project_file/mod.rs +++ b/crates/formats/src/project_file/mod.rs @@ -531,6 +531,7 @@ fn load_archive(mut zip: ZipArchive, mut budget: LoadBudget) if pf.project.mesh_rebuild_uvs && pf.mesh.is_some() && pf.mesh_uvs.is_none() { return Err(malformed(KIND, "the mesh UVs were rebuilt but the project holds no saved UV layout")); } + if version < TANGENT_BENT_NORMAL_VERSION { drop_world_space_bent_normals(&mut pf); } diff --git a/crates/formats/src/project_file/uv_layout.rs b/crates/formats/src/project_file/uv_layout.rs index cf6a638c..645ff502 100644 --- a/crates/formats/src/project_file/uv_layout.rs +++ b/crates/formats/src/project_file/uv_layout.rs @@ -49,9 +49,11 @@ pub fn read_uv_layout(bytes: &[u8]) -> Result> { if magic != UV_LAYOUT_MAGIC { return Err(bad("bad magic")); } + if u32::from_le_bytes(*version) != UV_LAYOUT_VERSION { return Err(bad("unsupported version")); } + let corners = u32::from_le_bytes(*corners) as usize; if corners.checked_mul(CORNER_BYTES) != Some(body.len()) { return Err(bad("the corner count does not match the entry size")); @@ -69,5 +71,6 @@ pub fn read_uv_layout(bytes: &[u8]) -> Result> { if layout.iter().any(|uv| !uv.is_finite()) { return Err(bad("non-finite UVs")); } + Ok(layout) } From af296eb5bc8256bad0c7af6effed4ff62f59c62c Mon Sep 17 00:00:00 2001 From: vangel76 Date: Wed, 25 Nov 2026 00:56:44 +0100 Subject: [PATCH 32/83] Scroll to R before clicking it and document the new settings fields --- crates/ui-egui/src/state.rs | 3 ++- crates/ui-egui/tests/it/settings_window.rs | 5 +++++ docs/control-protocol.md | 6 +++++- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/crates/ui-egui/src/state.rs b/crates/ui-egui/src/state.rs index 9d97f54d..bfd72af9 100644 --- a/crates/ui-egui/src/state.rs +++ b/crates/ui-egui/src/state.rs @@ -167,7 +167,8 @@ pub struct Prefs { pub reserved_cores: u32, /// Maximum decompressed project size accepted on open, in GiB (at least one). pub project_open_limit_gib: u32, - /// Percent of the free RAM a project save may hold at once (desktop; 1 to 100). + /// Percent of the free RAM a project save may hold at once (desktop; 0 to 100, a save holds + /// at least 1). pub save_ram_percent: u8, /// Worker threads for painting, baking and export (desktop; 0: one per logical CPU). Read at /// startup, before the first parallel job. diff --git a/crates/ui-egui/tests/it/settings_window.rs b/crates/ui-egui/tests/it/settings_window.rs index 7ca014c9..d3040990 100644 --- a/crates/ui-egui/tests/it/settings_window.rs +++ b/crates/ui-egui/tests/it/settings_window.rs @@ -156,6 +156,8 @@ fn the_resource_sliders_step_by_one_and_follow_the_arrow_keys() { let ram_percent = |h: &Harness<'_, TextureCraftApp>| h.state().ui.windows.settings_draft.as_ref().unwrap().prefs.save_ram_percent; let before = ram_percent(&h); + h.get_by_role_and_label(Role::Slider, "Max RAM while saving").scroll_to_me(); + h.run_steps(3); h.get_by_role_and_label(Role::Slider, "Max RAM while saving").focus(); h.run_steps(2); press_key(&mut h, Key::ArrowRight); @@ -194,6 +196,9 @@ fn the_local_cache_directory_takes_a_folder_and_r_goes_back_to_the_default() { type_into(&mut h, "Local cache directory", &folder); assert_eq!(stored(&h), folder); + // The Files cache directory's R stays disabled; the local cache's R is the one that works + h.query_all_by_label("R").find(|node| !node.accesskit_node().is_disabled()).unwrap().scroll_to_me(); + h.run_steps(3); h.query_all_by_label("R").find(|node| !node.accesskit_node().is_disabled()).unwrap().click(); h.run_steps(3); assert!(stored(&h).is_empty(), "R goes back to the default folder"); diff --git a/docs/control-protocol.md b/docs/control-protocol.md index 7873145d..e2d4b3ca 100644 --- a/docs/control-protocol.md +++ b/docs/control-protocol.md @@ -326,7 +326,11 @@ Other preferences set through `ui.set {"prefs": {...}}`: `language` (`""` follow language), `work_threads` (worker threads for painting, baking and export; 0 uses every logical CPU; read at startup), `rotation_speed` (default 2), `zoom_speed` and `wheel_speed` (default 1, each from 0.1 to 10) with `zoom_inverse` and `wheel_inverse`, `gpu_raytracing` (false keeps bake -rays on the CPU) and `libraries` (the folders the shelf scans for saved smart materials and masks). +rays on the CPU), `show_world_axes` (the 3D view's X, Y and Z corner, default true) and `libraries` +(the folders the shelf scans for saved smart materials and masks). `show_keyboard_helper`, +`only_selected_material_when_painting`, `save_preprocessed_scene_files`, `live_preview_baking` and +`local_cache_directory` (empty: the system's temporary folder) are kept for Settings but have no +effect yet. For example, the `libraries` field can contain `[{"name": "Studio", "path": "/assets/studio"}]`. Use an absolute path on the host running TextureCraft. To change one preference, read `state.prefs` with `ui.inspect`, update that field and send the full `prefs` object to `ui.set`. From 2c6222ecde671efa66734bcccf51c8fc4e4e2f9c Mon Sep 17 00:00:00 2001 From: vangel76 Date: Wed, 25 Nov 2026 01:18:07 +0100 Subject: [PATCH 33/83] Move texture resolution to Display Settings and apply review fixes Remove the Viewport section from Settings; the texture resolution is in Display Settings > Render settings and the GPU memory toasts point there. Add hovers to the Data folder and RAM slider, name the R button for screen readers, test that Show world axes hides the 3D axes, and fix the docs that still named the removed sections. --- crates/ui-egui/src/display_settings.rs | 16 ++++++-- crates/ui-egui/src/lib.rs | 2 +- crates/ui-egui/src/settings_window.rs | 26 +++++------- crates/ui-egui/src/viewport.rs | 4 +- crates/ui-egui/tests/it/settings_window.rs | 46 +++++++++++++++------- crates/ui-egui/tests/ui_snapshots.rs | 3 ++ docs/control-protocol.md | 1 + docs/features.md | 6 +-- docs/ui-parity.md | 2 +- 9 files changed, 66 insertions(+), 40 deletions(-) diff --git a/crates/ui-egui/src/display_settings.rs b/crates/ui-egui/src/display_settings.rs index 7c0bc14d..92b8e13c 100644 --- a/crates/ui-egui/src/display_settings.rs +++ b/crates/ui-egui/src/display_settings.rs @@ -43,7 +43,7 @@ pub(crate) fn body(app: &mut TextureCraftApp, ui: &mut Ui) { 0 => import_hdr = environment(app, ui, &mut display), 1 => camera(app, ui, &mut display), 2 => post_effects(ui, &mut display), - 3 => render_settings(ui, &mut display), + 3 => render_settings(app, ui, &mut display), _ => visualization(app, ui, &mut display), }); @@ -255,9 +255,19 @@ fn post_effects(ui: &mut Ui, display: &mut DisplaySettings) { } } -/// Temporal anti-aliasing -fn render_settings(ui: &mut Ui, display: &mut DisplaySettings) { +/// Temporal anti-aliasing and the viewport texture resolution (an app setting, not the project's) +fn render_settings(app: &mut TextureCraftApp, ui: &mut Ui, display: &mut DisplaySettings) { ui.checkbox(&mut display.taa, tr("Temporal anti-aliasing (refines the 3D view while it is still)")); + ui.horizontal(|ui| { + ui.label(tr("Texture resolution")); + for (value, label) in [(0_u8, tr("Full")), (1, tr("Half")), (2, tr("Quarter"))] { + ui.selectable_value(&mut app.ui.prefs.viewport_texture, value, label); + } + }) + .response + .on_hover_text(tr( + "Size of the textures the viewport shows: lower uses less GPU memory with large texture sets. Painting and export keep full resolution.", + )); } /// The mesh wireframe and the single-channel views diff --git a/crates/ui-egui/src/lib.rs b/crates/ui-egui/src/lib.rs index f6b25a0f..8cddbbc7 100644 --- a/crates/ui-egui/src/lib.rs +++ b/crates/ui-egui/src/lib.rs @@ -1014,7 +1014,7 @@ const GLIDE_SECONDS: f64 = 0.35; /// The share of the running frame rate and frame time averages each frame keeps (an average over about ten frames) const FRAME_AVERAGE_KEEP: f32 = 0.9; -/// The interface scale applied: wider than the Settings slider, so a scale set elsewhere still applies within reason +/// The interface scale applied (`prefs.ui_scale`, set through `ui.set`; Settings has no control for it), clamped to a usable range const UI_SCALE_APPLIED: std::ops::RangeInclusive = 0.5..=3.0; /// Zoom factors closer than this are the same zoom (float noise), so the zoom is not set again each frame const SAME_ZOOM_TOLERANCE: f32 = 1e-3; diff --git a/crates/ui-egui/src/settings_window.rs b/crates/ui-egui/src/settings_window.rs index 7da312bc..2227a7d8 100644 --- a/crates/ui-egui/src/settings_window.rs +++ b/crates/ui-egui/src/settings_window.rs @@ -456,7 +456,12 @@ fn general( { let default = crate::local_cache_folder("").display().to_string(); ui.add(egui::TextEdit::singleline(&mut p.local_cache_directory).hint_text(default).desired_width(CONTROL_WIDTH - 24.0)).labelled_by(label); - if ui.add(egui::Button::new("R").frame(false)).on_hover_text(tr("Reset to the default folder")).clicked() { + let reset = ui.add(egui::Button::new("R").frame(false)).on_hover_text(tr("Reset to the default folder")); + + // Screen readers hear what the single letter does + let name = format!("R, {}", tr("Reset to the default folder")); + reset.widget_info(|| egui::WidgetInfo::labeled(egui::Role::Button, true, &name)); + if reset.clicked() { p.local_cache_directory.clear(); } } @@ -495,7 +500,9 @@ fn general( #[cfg(not(target_arch = "wasm32"))] row(ui, tr("Data folder"), |ui, label| { let default = crate::data_folder("").display().to_string(); - ui.add(egui::TextEdit::singleline(&mut p.data_folder).hint_text(default).desired_width(CONTROL_WIDTH - 30.0)).labelled_by(label); + ui.add(egui::TextEdit::singleline(&mut p.data_folder).hint_text(default).desired_width(CONTROL_WIDTH - 30.0)) + .labelled_by(label) + .on_hover_text(tr("Applies on restart.")); if ui.button("...").on_hover_text(tr("Choose the data folder")).clicked() { *pick = Some(SettingsFolder::DataFolder); } @@ -505,19 +512,6 @@ fn general( disabled_text_check(ui, n_("Hardware support acceleration"), true); // TextureCraft's own settings, after the reference sections - section(ui, n_("VIEWPORT")); - row(ui, tr("Texture resolution"), |ui, _| { - ui.horizontal(|ui| { - for (v, l) in [(0u8, tr("Full")), (1, tr("Half")), (2, tr("Quarter"))] { - ui.selectable_value(&mut p.viewport_texture, v, l); - } - }) - .response - .on_hover_text(tr( - "Size of the textures the viewport shows: lower uses less GPU memory with large texture sets. Painting and export keep full resolution.", - )); - }); - section(ui, n_("RESOURCES")); #[cfg(not(target_arch = "wasm32"))] { @@ -537,7 +531,7 @@ fn general( cores_in_total(ui, available_cores); }); row(ui, tr("Max RAM while saving"), |ui, label| { - ui.add(egui::Slider::new(&mut p.save_ram_percent, 0..=100).step_by(1.0).suffix(" %")).labelled_by(label); + ui.add(egui::Slider::new(&mut p.save_ram_percent, 0..=100).step_by(1.0).suffix(" %")).labelled_by(label).on_hover_text(tr("0 % uses at least 1 %")); let budget_bytes = texturecraft_engine::formats::save_ram_budget(available_ram_bytes, p.save_ram_percent); ui.label(format!("≈ {:.2} GiB", budget_bytes as f64 / (1_u64 << 30) as f64)); }); diff --git a/crates/ui-egui/src/viewport.rs b/crates/ui-egui/src/viewport.rs index 7a83ccf6..c7f65f95 100644 --- a/crates/ui-egui/src/viewport.rs +++ b/crates/ui-egui/src/viewport.rs @@ -405,7 +405,7 @@ fn gpu_report_toasts(app: &mut TextureCraftApp, reports: crate::gpu::GpuReports) } let text = match sets.as_slice() { [one] => trf( - "Not enough GPU memory to show texture set \"{name}\" fully: lower the viewport Texture resolution in Settings. Painting and export are not affected.", + "Not enough GPU memory to show texture set \"{name}\" fully: lower the Texture resolution in Display Settings › Render settings. Painting and export are not affected.", &[("name", one)], ), many => { @@ -418,7 +418,7 @@ fn gpu_report_toasts(app: &mut TextureCraftApp, reports: crate::gpu::GpuReports) list.push_str(", ..."); } trf( - "Not enough GPU memory to show {count} texture sets fully ({names}): lower the viewport Texture resolution in Settings. Painting and export are not affected.", + "Not enough GPU memory to show {count} texture sets fully ({names}): lower the Texture resolution in Display Settings › Render settings. Painting and export are not affected.", &[("count", &many.len()), ("names", &list)], ) } diff --git a/crates/ui-egui/tests/it/settings_window.rs b/crates/ui-egui/tests/it/settings_window.rs index d3040990..c89a8347 100644 --- a/crates/ui-egui/tests/it/settings_window.rs +++ b/crates/ui-egui/tests/it/settings_window.rs @@ -87,7 +87,7 @@ fn the_general_page_starts_at_the_reference_defaults() { let mut h = harness(texturecraft_engine::sample_session(128, 32).unwrap()); open_settings(&mut h); - // A reset puts the defaults in the window; the app itself keeps English for the exact-text checks + // The defaults of a first start, in the window; the app itself keeps English for the exact-text checks h.state_mut().ui.windows.settings_draft.as_mut().unwrap().prefs = Prefs::default(); h.run_steps(3); @@ -112,7 +112,7 @@ fn the_general_page_starts_at_the_reference_defaults() { assert_eq!(texturecraft_ui_egui::local_cache_folder(&Prefs::default().local_cache_directory), std::env::temp_dir()); let prefs = Prefs::default(); - assert_eq!(prefs.language, texturecraft_ui_egui::i18n::SYSTEM_LANGUAGE, "a reset follows the system language"); + assert_eq!(prefs.language, texturecraft_ui_egui::i18n::SYSTEM_LANGUAGE, "the default follows the system language"); assert_eq!((prefs.rotation_speed, prefs.zoom_speed, prefs.wheel_speed), (2.0, 1.0, 1.0)); } @@ -121,7 +121,7 @@ fn the_general_page_keeps_the_reference_sections_and_moves_data_folder_and_recen let mut h = harness(Session::closed().unwrap()); open_settings(&mut h); - for gone in ["TEMPORARY FILES", "IRAY HARDWARE", "APPEARANCE", "FOLDERS", "PRIVACY", "Interface scale", "Accent color"] { + for gone in ["TEMPORARY FILES", "IRAY HARDWARE", "APPEARANCE", "FOLDERS", "VIEWPORT", "Interface scale", "Accent color"] { assert!(h.query_by_label(gone).is_none(), "{gone} is not on the page"); } for hint in ["Saving uses the other cores", "0 turns autosave off", "A new folder applies on restart"] { @@ -160,11 +160,32 @@ fn the_resource_sliders_step_by_one_and_follow_the_arrow_keys() { h.run_steps(3); h.get_by_role_and_label(Role::Slider, "Max RAM while saving").focus(); h.run_steps(2); + press_key(&mut h, Key::ArrowRight); - assert_eq!(ram_percent(&h), before + 1, "the right arrow adds one percent"); + let after_right = ram_percent(&h); press_key(&mut h, Key::ArrowLeft); press_key(&mut h, Key::ArrowLeft); - assert_eq!(ram_percent(&h), before - 1, "the left arrow takes one percent"); + let after_left = ram_percent(&h); + + assert_eq!(after_right, before + 1, "the right arrow adds one percent"); + assert_eq!(after_left, before - 1, "the left arrow takes one percent"); +} + +#[test] +fn show_world_axes_draws_the_3d_view_axes_and_off_hides_them() { + let mut h = harness(texturecraft_engine::sample_session(128, 32).unwrap()); + let painted_z = |h: &Harness<'_, TextureCraftApp>| { + h.output().shapes.iter().filter(|clipped| matches!(&clipped.shape, egui::Shape::Text(text) if text.galley.text() == "Z")).count() + }; + + h.state_mut().ui.prefs.show_world_axes = true; + h.run_steps(3); + let shown = painted_z(&h); + h.state_mut().ui.prefs.show_world_axes = false; + h.run_steps(3); + let hidden = painted_z(&h); + + assert_eq!(shown, hidden + 1, "the 3D view's Z axis letter is drawn only while Show world axes is on"); } #[test] @@ -179,8 +200,8 @@ fn the_enabled_interface_options_answer_the_keyboard() { h.run_steps(2); press_key(&mut h, Key::Space); } - let after = draft(&h); + assert_ne!(after.show_keyboard_helper, before.show_keyboard_helper); assert_ne!(after.show_world_axes, before.show_world_axes); assert_ne!(after.only_selected_material_when_painting, before.only_selected_material_when_painting); @@ -194,14 +215,12 @@ fn the_local_cache_directory_takes_a_folder_and_r_goes_back_to_the_default() { let stored = |h: &Harness<'_, TextureCraftApp>| h.state().ui.windows.settings_draft.as_ref().unwrap().prefs.local_cache_directory.clone(); type_into(&mut h, "Local cache directory", &folder); - assert_eq!(stored(&h), folder); + let typed = stored(&h); + click(&mut h, "R, Reset to the default folder"); + let reset = stored(&h); - // The Files cache directory's R stays disabled; the local cache's R is the one that works - h.query_all_by_label("R").find(|node| !node.accesskit_node().is_disabled()).unwrap().scroll_to_me(); - h.run_steps(3); - h.query_all_by_label("R").find(|node| !node.accesskit_node().is_disabled()).unwrap().click(); - h.run_steps(3); - assert!(stored(&h).is_empty(), "R goes back to the default folder"); + assert_eq!(typed, folder); + assert!(reset.is_empty(), "R goes back to the default folder"); } #[test] @@ -534,7 +553,6 @@ fn gpu_raytracing_is_on_and_checkable_with_a_gpu_and_off_and_disabled_without() assert_eq!(!check.accesskit_node().is_disabled(), supported, "it can be changed exactly when there is a GPU"); assert_eq!(toggled(&h, "Enable GPU raytracing"), supported, "it is on exactly when there is a GPU"); assert_eq!(h.query_by_label(GPU_RAYTRACING_UNAVAILABLE).is_some(), !supported, "the note shows with no GPU and only then"); - assert!(h.state().ui.prefs.gpu_raytracing, "the stored choice stays for a machine with a GPU"); } #[test] diff --git a/crates/ui-egui/tests/ui_snapshots.rs b/crates/ui-egui/tests/ui_snapshots.rs index cda0398b..7181557a 100644 --- a/crates/ui-egui/tests/ui_snapshots.rs +++ b/crates/ui-egui/tests/ui_snapshots.rs @@ -83,6 +83,9 @@ fn empty_start_snapshot() { harness.get_by_label("Edit").click(); harness.run_steps(3); harness.get_by_label("Settings").click(); + harness.run_steps(3); + harness.get_by_label("Recent projects limit").scroll_to_me(); + harness.run_steps(3); save(&mut harness, &output_dir, "settings-recent-project-limit"); assert!(!harness.get_by_label("Recent projects limit").accesskit_node().is_disabled()); } diff --git a/docs/control-protocol.md b/docs/control-protocol.md index e2d4b3ca..35cbd0d3 100644 --- a/docs/control-protocol.md +++ b/docs/control-protocol.md @@ -334,6 +334,7 @@ effect yet. For example, the `libraries` field can contain `[{"name": "Studio", "path": "/assets/studio"}]`. Use an absolute path on the host running TextureCraft. To change one preference, read `state.prefs` with `ui.inspect`, update that field and send the full `prefs` object to `ui.set`. +A `prefs` object without `language` sets the system language (`""`), the default. ## MCP server diff --git a/docs/features.md b/docs/features.md index 04702ee9..1106571b 100644 --- a/docs/features.md +++ b/docs/features.md @@ -250,10 +250,10 @@ Everything TextureCraft does today, by area. What's still missing is in [`ROADMA - **Swap 3D/2D** (F4, Viewport menu and the layout dropdown, rebindable) puts the 2D view on the left and the 3D view on the right in the split layout. Painting, the divider and the views' headers work on both sides, and the choice is kept with the UI state. - A modern look in **four brightness levels** (dark, medium dark, medium light and light) with - **seven accent colors**, set in Settings › General › Appearance. + **seven accent colors**, set for now only through `ui.set` (`prefs.brightness`, `prefs.accent`). - **Its own title bar** with the app icon, menus and window buttons on Windows (and on Linux desktops that leave the frame to the app, such as GNOME), the macOS traffic lights over the same - strip, and Settings › General › Appearance › System title bar for the system's frame instead. + strip, and the system's frame instead with `prefs.system_title_bar` through `ui.set` (for now). - **Dockable, tabbed and floating panels**, saved layouts, and panels that reopen where you closed them. The right bar's panels (Export, Log, Display Settings, Shader Settings, History) pop out beside it; *Undock* makes one a floating window, and its *Dock* button puts it back on the bar. @@ -273,7 +273,7 @@ Everything TextureCraft does today, by area. What's still missing is in [`ROADMA - **No project at launch**: empty views, panels and toolbars until you create or open one (File › New project, Open, Recent projects, Open sample project); File › Close returns to that state. - A **data folder** of your choice for autosaves, smart materials, presets, templates and UI - layouts, on any drive (Settings › General › Folders; `Documents/TextureCraft` by default). + layouts, on any drive (Settings › General › Files › Data folder; `Documents/TextureCraft` by default). - A **Settings window** (Edit › Settings) with General, Shortcuts and Libraries pages; changes apply on OK and Cancel drops them. General holds the language (or the system's), the 3D view's rotation, zoom and wheel speeds with inverse directions, GPU or CPU bake rays, resource limits diff --git a/docs/ui-parity.md b/docs/ui-parity.md index 1bd95040..4e6a3f45 100644 --- a/docs/ui-parity.md +++ b/docs/ui-parity.md @@ -154,7 +154,7 @@ that closes it back onto the bar; the float is saved with the UI state. | UI-12 | Generator depth and property coverage | **UI + source.** The picker contains seven kinds. Switching to Position, changing Global balance and duplicating the effect worked. Shared global adjustments, resolution and input slots already exist; that does not establish the richer generator/control inventory in [#374](https://github.com/storytold/texturecraft/issues/374) | Audit each generator's inputs, micro-detail behavior and controls against the reference; do not count seven shared implementations as equivalent to its whole catalog | | UI-13 | Narrow workspace readability | **UI.** At 1280 × 800 the app rendered, both views stayed visible and the toolbar exposed scroll arrows. Layer names/types became heavily truncated, the layer toolbar wrapped, and Properties needed scrolling. This was not an input-failure or docking-persistence test | Repeat the editing tasks at smaller sizes, widen/rearrange panels, check full-name tooltips and keyboard access, and retain the layout after restart. Since then: the Layers toolbar stays on one row at 1280 × 800 (its channel box shrinks), and a cut-short layer name or type shows in full on hover. Properties scrolling and restart persistence are unchanged | | UI-14 | Assets panel filters | **UI + source.** The type dropdown lists the reference entries in its order, Fonts and Show all included. Saved searches and Filter by path are separate scrollable panes with a divider that supports pointer and keyboard resizing and saves its position with the UI state ([#640](https://github.com/storytold/texturecraft/issues/640)). Fonts, the built-in saved searches Favorites, 3D Assets and Flattened layers, and the System fonts and User fonts libraries are listed but greyed with "Not available yet" | Give fonts, favorites, 3D assets and flattened layers real assets, then enable those rows and check that each one filters the grid | -| UI-15 | Edit > Settings ([#637](https://github.com/storytold/texturecraft/issues/637)) | **Source + headless UI tests.** The window has the reference's General, Shortcuts and Libraries pages with OK and Cancel, and the General sections in its order (no Privacy section: TextureCraft sends no usage data). Language (Default (System Language) by default and after a reset), the camera rotation, zoom and wheel speeds with Inverse direction, Show world axes (the 3D view's X, Y and Z corner), the Shortcuts page and adding or removing library locations work. Enable GPU raytracing is on and can be changed when there is a GPU, and off and disabled without one ([#823](https://github.com/storytold/texturecraft/issues/823)). Show keyboard helper and Save preprocessed scene files (on), Only display the selected material when painting (off), Enable live preview baking process (on), Viewport Scaling (only Auto) and the Local cache directory (empty is the system's temporary folder; R goes back to it) can be changed and are kept, but have no effect yet. Default UV scale for materials, simplified thumbnails, the preview cache budget and shader, the Files cache directory and sparse virtual texture are shown disabled with "Not available yet". There is no IRAY HARDWARE section. A location's Default choice is fixed to your_assets. The Shortcuts page has the sections Actions, Mouse shortcuts and Modifiers shortcuts and a Reset all to default button; Delete clears a binding; a shared shortcut shows a warning naming the other action, a warning on the page icon and the footer "One or several errors have been found in Shortcuts settings", and OK stays disabled until it is gone (the mouse and modifier rows are shown disabled, the viewports read those gestures from code). The shortcut list uses the reference's action names, order and default keys ("Open project", "Show/Hide manipulator" Q to "Rotate tool" E after "Export Textures...", "Save as project", "Switch to baking mode" Ctrl+Shift+B, "Switch to edition mode" F9, "Camera projection: Perspective view" F5, "Show entire mesh/path", "Select next camera" `>`, "Select previous camera" `<`, "Viewers layout: 3D/2D" F1 to "Viewers layout: Swap 3D/2D" F4 and so on); Quit keeps Ctrl+Q and the menus keep their own texts. "Show mesh wireframe" is a new bindable command without a key; "Show/Hide manipulator", "Increase the manipulator size", "Decrease the manipulator size", "Cycle through manipulation spaces", "Toggle warp edition mode", "Translate tool", "Rotate tool", "Pause Engine Computation" (Shift+Esc) and "Toggle animation" (Space) are listed disabled with "Not available yet". The window reopens on the page it was closed on. With a project open the Libraries page hides the add row and shows "Library locations can't be added/removed when a project is opened."; the default library's "−" says "Cannot remove the default library.". "GPU raytracing not available for your hardware." shows under the Baking options when there is no GPU. The reference's TEMPORARY FILES section is called FILES and also holds the Data folder. TextureCraft's own settings follow the reference sections: VIEWPORT (texture resolution), RESOURCES (Max CPU threads for work, default every thread, and Cores kept for the UI as sliders in steps of 1 with the core count beside them, Max RAM while saving as a 0-100% slider, Max project size on open, Recent projects limit) and AUTOSAVE. There is no appearance, folders or analytics section: interface scale, brightness, accent colour and the system title bar stay in the saved settings and `ui.set` | Run the window in the native app; wire each disabled control as its function lands | +| UI-15 | Edit > Settings ([#637](https://github.com/storytold/texturecraft/issues/637)) | **Source + headless UI tests.** The window has the reference's General, Shortcuts and Libraries pages with OK and Cancel, and the General sections in its order (no Privacy section: TextureCraft sends no usage data). Language (Default (System Language) by default and after a reset), the camera rotation, zoom and wheel speeds with Inverse direction, Show world axes (the 3D view's X, Y and Z corner), the Shortcuts page and adding or removing library locations work. Enable GPU raytracing is on and can be changed when there is a GPU, and off and disabled without one ([#823](https://github.com/storytold/texturecraft/issues/823)). Show keyboard helper (on), Only display the selected material when painting (off), Save preprocessed scene files (on), Enable live preview baking process (on) and the Local cache directory (empty is the system's temporary folder; R goes back to it) can be changed and are kept, but have no effect yet. Viewport Scaling opens but lists only Auto, so there is nothing to change. Default UV scale for materials, simplified thumbnails, the preview cache budget and shader, the Files cache directory and sparse virtual texture are shown disabled with "Not available yet". There is no IRAY HARDWARE section. A location's Default choice is fixed to your_assets. The Shortcuts page has the sections Actions, Mouse shortcuts and Modifiers shortcuts and a Reset all to default button; Delete clears a binding; a shared shortcut shows a warning naming the other action, a warning on the page icon and the footer "One or several errors have been found in Shortcuts settings", and OK stays disabled until it is gone (the mouse and modifier rows are shown disabled, the viewports read those gestures from code). The shortcut list uses the reference's action names, order and default keys ("Open project", "Save as project", "Switch to baking mode" Ctrl+Shift+B, "Switch to edition mode" F9, "Camera projection: Perspective view" F5, "Show entire mesh/path", "Select next camera" `>`, "Select previous camera" `<`, "Viewers layout: 3D/2D" F1 to "Viewers layout: Swap 3D/2D" F4 and so on); Quit keeps Ctrl+Q and the menus keep their own texts. "Show mesh wireframe" is a new bindable command without a key; "Pause Engine Computation" (Shift+Esc) and "Toggle animation" (Space) are listed disabled with "Not available yet". The reference's rows after "Export Textures..." are listed the same way, in its order: "Show/Hide manipulator" (Q), "Increase the manipulator size", "Decrease the manipulator size" (-), "Cycle through manipulation spaces" (T), "Toggle warp edition mode" (Shift+V), "Translate tool" (W) and "Rotate tool" (E). The window reopens on the page it was closed on. With a project open the Libraries page hides the add row and shows "Library locations can't be added/removed when a project is opened."; the default library's "−" says "Cannot remove the default library.". "GPU raytracing not available for your hardware." shows under the Baking options when there is no GPU. The reference's TEMPORARY FILES section is called FILES and also holds the Data folder. TextureCraft's own settings follow the reference sections: RESOURCES (Max CPU threads for work, default every thread, and Cores kept for the UI as sliders in steps of 1 with the core count beside them, Max RAM while saving as a 0-100% slider, Max project size on open, Recent projects limit) and AUTOSAVE. There is no appearance, viewport, folders or analytics section: the viewport texture resolution (Full, Half, Quarter) is in Display Settings › Render settings, and interface scale, brightness, accent color and the system title bar stay in the saved settings and `ui.set` | Run the window in the native app; wire each disabled control as its function lands | Bake workflow (issue [#651](https://github.com/storytold/texturecraft/issues/651)): Mesh Map Bakers has a Presets menu (save, load, delete named bake settings; Apply to All Texture Sets) and a finished From a85b1437aa6986ff7a54d2580ed831c8e1a2c136 Mon Sep 17 00:00:00 2001 From: aiongg Date: Wed, 25 Nov 2026 06:31:20 +0000 Subject: [PATCH 34/83] Repin craft-libs to storytold next 16001e7210 and egui to storytold b15ffe9bfc --- Cargo.lock | 90 +++++++++++++++++++-------------------- Cargo.toml | 34 +++++++-------- crates/formats/Cargo.toml | 4 +- 3 files changed, 64 insertions(+), 64 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 0fe9764d..b54d02d3 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -953,7 +953,7 @@ dependencies = [ [[package]] name = "craft-appkit" version = "0.1.0" -source = "git+https://github.com/aiongg/craft-libs?rev=283490a0833e37cc748d29711ff73f81f091e373#283490a0833e37cc748d29711ff73f81f091e373" +source = "git+https://github.com/storytold/craft-libs?rev=16001e7210bee61db60c84fbe18c3c3e2ef4584f#16001e7210bee61db60c84fbe18c3c3e2ef4584f" dependencies = [ "block2 0.6.2", "objc2-app-kit 0.3.2", @@ -963,7 +963,7 @@ dependencies = [ [[package]] name = "craft-atomic" version = "0.1.0" -source = "git+https://github.com/aiongg/craft-libs?rev=283490a0833e37cc748d29711ff73f81f091e373#283490a0833e37cc748d29711ff73f81f091e373" +source = "git+https://github.com/storytold/craft-libs?rev=16001e7210bee61db60c84fbe18c3c3e2ef4584f#16001e7210bee61db60c84fbe18c3c3e2ef4584f" dependencies = [ "rustix 1.1.6", ] @@ -971,7 +971,7 @@ dependencies = [ [[package]] name = "craft-behavior" version = "0.1.0" -source = "git+https://github.com/aiongg/craft-libs?rev=283490a0833e37cc748d29711ff73f81f091e373#283490a0833e37cc748d29711ff73f81f091e373" +source = "git+https://github.com/storytold/craft-libs?rev=16001e7210bee61db60c84fbe18c3c3e2ef4584f#16001e7210bee61db60c84fbe18c3c3e2ef4584f" dependencies = [ "accesskit", "bitflags 2.13.2", @@ -989,7 +989,7 @@ dependencies = [ [[package]] name = "craft-cloud-ui" version = "0.1.0" -source = "git+https://github.com/aiongg/craft-libs?rev=283490a0833e37cc748d29711ff73f81f091e373#283490a0833e37cc748d29711ff73f81f091e373" +source = "git+https://github.com/storytold/craft-libs?rev=16001e7210bee61db60c84fbe18c3c3e2ef4584f#16001e7210bee61db60c84fbe18c3c3e2ef4584f" dependencies = [ "egui", ] @@ -997,7 +997,7 @@ dependencies = [ [[package]] name = "craft-cms" version = "0.1.0" -source = "git+https://github.com/aiongg/craft-libs?rev=283490a0833e37cc748d29711ff73f81f091e373#283490a0833e37cc748d29711ff73f81f091e373" +source = "git+https://github.com/storytold/craft-libs?rev=16001e7210bee61db60c84fbe18c3c3e2ef4584f#16001e7210bee61db60c84fbe18c3c3e2ef4584f" dependencies = [ "md-5", "rayon", @@ -1006,12 +1006,12 @@ dependencies = [ [[package]] name = "craft-codepage" version = "0.1.0" -source = "git+https://github.com/aiongg/craft-libs?rev=283490a0833e37cc748d29711ff73f81f091e373#283490a0833e37cc748d29711ff73f81f091e373" +source = "git+https://github.com/storytold/craft-libs?rev=16001e7210bee61db60c84fbe18c3c3e2ef4584f#16001e7210bee61db60c84fbe18c3c3e2ef4584f" [[package]] name = "craft-dds" version = "0.1.0" -source = "git+https://github.com/aiongg/craft-libs?rev=283490a0833e37cc748d29711ff73f81f091e373#283490a0833e37cc748d29711ff73f81f091e373" +source = "git+https://github.com/storytold/craft-libs?rev=16001e7210bee61db60c84fbe18c3c3e2ef4584f#16001e7210bee61db60c84fbe18c3c3e2ef4584f" dependencies = [ "rayon", ] @@ -1019,7 +1019,7 @@ dependencies = [ [[package]] name = "craft-dialogs" version = "0.1.0" -source = "git+https://github.com/aiongg/craft-libs?rev=283490a0833e37cc748d29711ff73f81f091e373#283490a0833e37cc748d29711ff73f81f091e373" +source = "git+https://github.com/storytold/craft-libs?rev=16001e7210bee61db60c84fbe18c3c3e2ef4584f#16001e7210bee61db60c84fbe18c3c3e2ef4584f" dependencies = [ "block2 0.6.2", "craft-atomic", @@ -1039,7 +1039,7 @@ dependencies = [ [[package]] name = "craft-docpath" version = "0.1.0" -source = "git+https://github.com/aiongg/craft-libs?rev=283490a0833e37cc748d29711ff73f81f091e373#283490a0833e37cc748d29711ff73f81f091e373" +source = "git+https://github.com/storytold/craft-libs?rev=16001e7210bee61db60c84fbe18c3c3e2ef4584f#16001e7210bee61db60c84fbe18c3c3e2ef4584f" dependencies = [ "serde", ] @@ -1047,7 +1047,7 @@ dependencies = [ [[package]] name = "craft-font-catalog" version = "0.1.0" -source = "git+https://github.com/aiongg/craft-libs?rev=283490a0833e37cc748d29711ff73f81f091e373#283490a0833e37cc748d29711ff73f81f091e373" +source = "git+https://github.com/storytold/craft-libs?rev=16001e7210bee61db60c84fbe18c3c3e2ef4584f#16001e7210bee61db60c84fbe18c3c3e2ef4584f" dependencies = [ "harfrust 0.13.3", "kurbo", @@ -1061,12 +1061,12 @@ dependencies = [ [[package]] name = "craft-fonts-build" version = "0.1.0" -source = "git+https://github.com/aiongg/craft-libs?rev=283490a0833e37cc748d29711ff73f81f091e373#283490a0833e37cc748d29711ff73f81f091e373" +source = "git+https://github.com/storytold/craft-libs?rev=16001e7210bee61db60c84fbe18c3c3e2ef4584f#16001e7210bee61db60c84fbe18c3c3e2ef4584f" [[package]] name = "craft-host" version = "0.1.0" -source = "git+https://github.com/aiongg/craft-libs?rev=283490a0833e37cc748d29711ff73f81f091e373#283490a0833e37cc748d29711ff73f81f091e373" +source = "git+https://github.com/storytold/craft-libs?rev=16001e7210bee61db60c84fbe18c3c3e2ef4584f#16001e7210bee61db60c84fbe18c3c3e2ef4584f" dependencies = [ "bitflags 2.13.2", "craft-i18n", @@ -1079,7 +1079,7 @@ dependencies = [ [[package]] name = "craft-i18n" version = "0.1.0" -source = "git+https://github.com/aiongg/craft-libs?rev=283490a0833e37cc748d29711ff73f81f091e373#283490a0833e37cc748d29711ff73f81f091e373" +source = "git+https://github.com/storytold/craft-libs?rev=16001e7210bee61db60c84fbe18c3c3e2ef4584f#16001e7210bee61db60c84fbe18c3c3e2ef4584f" dependencies = [ "chrono", "fixed_decimal", @@ -1107,7 +1107,7 @@ dependencies = [ [[package]] name = "craft-image-codecs" version = "0.1.0" -source = "git+https://github.com/aiongg/craft-libs?rev=283490a0833e37cc748d29711ff73f81f091e373#283490a0833e37cc748d29711ff73f81f091e373" +source = "git+https://github.com/storytold/craft-libs?rev=16001e7210bee61db60c84fbe18c3c3e2ef4584f#16001e7210bee61db60c84fbe18c3c3e2ef4584f" dependencies = [ "craft-dds", "craft-jpeg", @@ -1134,7 +1134,7 @@ dependencies = [ [[package]] name = "craft-jpeg" version = "0.1.0" -source = "git+https://github.com/aiongg/craft-libs?rev=283490a0833e37cc748d29711ff73f81f091e373#283490a0833e37cc748d29711ff73f81f091e373" +source = "git+https://github.com/storytold/craft-libs?rev=16001e7210bee61db60c84fbe18c3c3e2ef4584f#16001e7210bee61db60c84fbe18c3c3e2ef4584f" dependencies = [ "thiserror 2.0.21", ] @@ -1142,7 +1142,7 @@ dependencies = [ [[package]] name = "craft-keymap" version = "0.1.0" -source = "git+https://github.com/aiongg/craft-libs?rev=283490a0833e37cc748d29711ff73f81f091e373#283490a0833e37cc748d29711ff73f81f091e373" +source = "git+https://github.com/storytold/craft-libs?rev=16001e7210bee61db60c84fbe18c3c3e2ef4584f#16001e7210bee61db60c84fbe18c3c3e2ef4584f" dependencies = [ "craft-host", "craft-i18n", @@ -1157,7 +1157,7 @@ dependencies = [ [[package]] name = "craft-materialx" version = "0.1.0" -source = "git+https://github.com/aiongg/craft-libs?rev=283490a0833e37cc748d29711ff73f81f091e373#283490a0833e37cc748d29711ff73f81f091e373" +source = "git+https://github.com/storytold/craft-libs?rev=16001e7210bee61db60c84fbe18c3c3e2ef4584f#16001e7210bee61db60c84fbe18c3c3e2ef4584f" dependencies = [ "craft-xml", "thiserror 2.0.21", @@ -1166,7 +1166,7 @@ dependencies = [ [[package]] name = "craft-mcmat" version = "0.1.0" -source = "git+https://github.com/aiongg/craft-libs?rev=283490a0833e37cc748d29711ff73f81f091e373#283490a0833e37cc748d29711ff73f81f091e373" +source = "git+https://github.com/storytold/craft-libs?rev=16001e7210bee61db60c84fbe18c3c3e2ef4584f#16001e7210bee61db60c84fbe18c3c3e2ef4584f" dependencies = [ "craft-zip", "serde", @@ -1177,7 +1177,7 @@ dependencies = [ [[package]] name = "craft-menu" version = "0.1.0" -source = "git+https://github.com/aiongg/craft-libs?rev=283490a0833e37cc748d29711ff73f81f091e373#283490a0833e37cc748d29711ff73f81f091e373" +source = "git+https://github.com/storytold/craft-libs?rev=16001e7210bee61db60c84fbe18c3c3e2ef4584f#16001e7210bee61db60c84fbe18c3c3e2ef4584f" dependencies = [ "craft-behavior", "craft-host", @@ -1195,7 +1195,7 @@ dependencies = [ [[package]] name = "craft-mesh" version = "0.1.0" -source = "git+https://github.com/aiongg/craft-libs?rev=283490a0833e37cc748d29711ff73f81f091e373#283490a0833e37cc748d29711ff73f81f091e373" +source = "git+https://github.com/storytold/craft-libs?rev=16001e7210bee61db60c84fbe18c3c3e2ef4584f#16001e7210bee61db60c84fbe18c3c3e2ef4584f" dependencies = [ "craft-xml", "craft-zip", @@ -1206,7 +1206,7 @@ dependencies = [ [[package]] name = "craft-metadata" version = "0.1.0" -source = "git+https://github.com/aiongg/craft-libs?rev=283490a0833e37cc748d29711ff73f81f091e373#283490a0833e37cc748d29711ff73f81f091e373" +source = "git+https://github.com/storytold/craft-libs?rev=16001e7210bee61db60c84fbe18c3c3e2ef4584f#16001e7210bee61db60c84fbe18c3c3e2ef4584f" dependencies = [ "brotli-decompressor", "chrono", @@ -1218,7 +1218,7 @@ dependencies = [ [[package]] name = "craft-pdf" version = "0.1.0" -source = "git+https://github.com/aiongg/craft-libs?rev=283490a0833e37cc748d29711ff73f81f091e373#283490a0833e37cc748d29711ff73f81f091e373" +source = "git+https://github.com/storytold/craft-libs?rev=16001e7210bee61db60c84fbe18c3c3e2ef4584f#16001e7210bee61db60c84fbe18c3c3e2ef4584f" dependencies = [ "serde", ] @@ -1226,7 +1226,7 @@ dependencies = [ [[package]] name = "craft-platform" version = "0.1.0" -source = "git+https://github.com/aiongg/craft-libs?rev=283490a0833e37cc748d29711ff73f81f091e373#283490a0833e37cc748d29711ff73f81f091e373" +source = "git+https://github.com/storytold/craft-libs?rev=16001e7210bee61db60c84fbe18c3c3e2ef4584f#16001e7210bee61db60c84fbe18c3c3e2ef4584f" dependencies = [ "async-channel", "async-io", @@ -1257,7 +1257,7 @@ dependencies = [ [[package]] name = "craft-psd" version = "0.1.0" -source = "git+https://github.com/aiongg/craft-libs?rev=283490a0833e37cc748d29711ff73f81f091e373#283490a0833e37cc748d29711ff73f81f091e373" +source = "git+https://github.com/storytold/craft-libs?rev=16001e7210bee61db60c84fbe18c3c3e2ef4584f#16001e7210bee61db60c84fbe18c3c3e2ef4584f" dependencies = [ "encoding_rs", "flate2", @@ -1268,7 +1268,7 @@ dependencies = [ [[package]] name = "craft-quit" version = "0.1.0" -source = "git+https://github.com/aiongg/craft-libs?rev=283490a0833e37cc748d29711ff73f81f091e373#283490a0833e37cc748d29711ff73f81f091e373" +source = "git+https://github.com/storytold/craft-libs?rev=16001e7210bee61db60c84fbe18c3c3e2ef4584f#16001e7210bee61db60c84fbe18c3c3e2ef4584f" dependencies = [ "dispatch2", "egui", @@ -1281,7 +1281,7 @@ dependencies = [ [[package]] name = "craft-settings" version = "0.1.0" -source = "git+https://github.com/aiongg/craft-libs?rev=283490a0833e37cc748d29711ff73f81f091e373#283490a0833e37cc748d29711ff73f81f091e373" +source = "git+https://github.com/storytold/craft-libs?rev=16001e7210bee61db60c84fbe18c3c3e2ef4584f#16001e7210bee61db60c84fbe18c3c3e2ef4584f" dependencies = [ "craft-atomic", "craft-host", @@ -1298,7 +1298,7 @@ dependencies = [ [[package]] name = "craft-svg" version = "0.1.0" -source = "git+https://github.com/aiongg/craft-libs?rev=283490a0833e37cc748d29711ff73f81f091e373#283490a0833e37cc748d29711ff73f81f091e373" +source = "git+https://github.com/storytold/craft-libs?rev=16001e7210bee61db60c84fbe18c3c3e2ef4584f#16001e7210bee61db60c84fbe18c3c3e2ef4584f" dependencies = [ "craft-xml", "flate2", @@ -1315,7 +1315,7 @@ dependencies = [ [[package]] name = "craft-tcraft" version = "0.1.0" -source = "git+https://github.com/aiongg/craft-libs?rev=283490a0833e37cc748d29711ff73f81f091e373#283490a0833e37cc748d29711ff73f81f091e373" +source = "git+https://github.com/storytold/craft-libs?rev=16001e7210bee61db60c84fbe18c3c3e2ef4584f#16001e7210bee61db60c84fbe18c3c3e2ef4584f" dependencies = [ "craft-zip", "serde", @@ -1326,7 +1326,7 @@ dependencies = [ [[package]] name = "craft-theme" version = "0.1.0" -source = "git+https://github.com/aiongg/craft-libs?rev=283490a0833e37cc748d29711ff73f81f091e373#283490a0833e37cc748d29711ff73f81f091e373" +source = "git+https://github.com/storytold/craft-libs?rev=16001e7210bee61db60c84fbe18c3c3e2ef4584f#16001e7210bee61db60c84fbe18c3c3e2ef4584f" dependencies = [ "bitflags 2.13.2", "craft-tracked", @@ -1341,7 +1341,7 @@ dependencies = [ [[package]] name = "craft-tiff" version = "0.1.0" -source = "git+https://github.com/aiongg/craft-libs?rev=283490a0833e37cc748d29711ff73f81f091e373#283490a0833e37cc748d29711ff73f81f091e373" +source = "git+https://github.com/storytold/craft-libs?rev=16001e7210bee61db60c84fbe18c3c3e2ef4584f#16001e7210bee61db60c84fbe18c3c3e2ef4584f" dependencies = [ "serde", "thiserror 2.0.21", @@ -1351,12 +1351,12 @@ dependencies = [ [[package]] name = "craft-tracked" version = "0.1.0" -source = "git+https://github.com/aiongg/craft-libs?rev=283490a0833e37cc748d29711ff73f81f091e373#283490a0833e37cc748d29711ff73f81f091e373" +source = "git+https://github.com/storytold/craft-libs?rev=16001e7210bee61db60c84fbe18c3c3e2ef4584f#16001e7210bee61db60c84fbe18c3c3e2ef4584f" [[package]] name = "craft-ui" version = "0.1.0" -source = "git+https://github.com/aiongg/craft-libs?rev=283490a0833e37cc748d29711ff73f81f091e373#283490a0833e37cc748d29711ff73f81f091e373" +source = "git+https://github.com/storytold/craft-libs?rev=16001e7210bee61db60c84fbe18c3c3e2ef4584f#16001e7210bee61db60c84fbe18c3c3e2ef4584f" dependencies = [ "craft-cloud-ui", "craft-ui-canvas", @@ -1370,7 +1370,7 @@ dependencies = [ [[package]] name = "craft-ui-canvas" version = "0.1.0" -source = "git+https://github.com/aiongg/craft-libs?rev=283490a0833e37cc748d29711ff73f81f091e373#283490a0833e37cc748d29711ff73f81f091e373" +source = "git+https://github.com/storytold/craft-libs?rev=16001e7210bee61db60c84fbe18c3c3e2ef4584f#16001e7210bee61db60c84fbe18c3c3e2ef4584f" dependencies = [ "craft-behavior", "craft-i18n", @@ -1386,7 +1386,7 @@ dependencies = [ [[package]] name = "craft-ui-contract" version = "0.1.0" -source = "git+https://github.com/aiongg/craft-libs?rev=283490a0833e37cc748d29711ff73f81f091e373#283490a0833e37cc748d29711ff73f81f091e373" +source = "git+https://github.com/storytold/craft-libs?rev=16001e7210bee61db60c84fbe18c3c3e2ef4584f#16001e7210bee61db60c84fbe18c3c3e2ef4584f" dependencies = [ "accesskit", "craft-behavior", @@ -1424,7 +1424,7 @@ dependencies = [ [[package]] name = "craft-ui-macros" version = "0.1.0" -source = "git+https://github.com/aiongg/craft-libs?rev=283490a0833e37cc748d29711ff73f81f091e373#283490a0833e37cc748d29711ff73f81f091e373" +source = "git+https://github.com/storytold/craft-libs?rev=16001e7210bee61db60c84fbe18c3c3e2ef4584f#16001e7210bee61db60c84fbe18c3c3e2ef4584f" dependencies = [ "proc-macro-crate", "proc-macro2", @@ -1435,7 +1435,7 @@ dependencies = [ [[package]] name = "craft-ui-panels" version = "0.1.0" -source = "git+https://github.com/aiongg/craft-libs?rev=283490a0833e37cc748d29711ff73f81f091e373#283490a0833e37cc748d29711ff73f81f091e373" +source = "git+https://github.com/storytold/craft-libs?rev=16001e7210bee61db60c84fbe18c3c3e2ef4584f#16001e7210bee61db60c84fbe18c3c3e2ef4584f" dependencies = [ "craft-behavior", "craft-host", @@ -1453,7 +1453,7 @@ dependencies = [ [[package]] name = "craft-ui-patterns" version = "0.1.0" -source = "git+https://github.com/aiongg/craft-libs?rev=283490a0833e37cc748d29711ff73f81f091e373#283490a0833e37cc748d29711ff73f81f091e373" +source = "git+https://github.com/storytold/craft-libs?rev=16001e7210bee61db60c84fbe18c3c3e2ef4584f#16001e7210bee61db60c84fbe18c3c3e2ef4584f" dependencies = [ "craft-behavior", "craft-host", @@ -1474,7 +1474,7 @@ dependencies = [ [[package]] name = "craft-ui-shell" version = "0.1.0" -source = "git+https://github.com/aiongg/craft-libs?rev=283490a0833e37cc748d29711ff73f81f091e373#283490a0833e37cc748d29711ff73f81f091e373" +source = "git+https://github.com/storytold/craft-libs?rev=16001e7210bee61db60c84fbe18c3c3e2ef4584f#16001e7210bee61db60c84fbe18c3c3e2ef4584f" dependencies = [ "craft-behavior", "craft-host", @@ -1494,7 +1494,7 @@ dependencies = [ [[package]] name = "craft-ui-widgets" version = "0.1.0" -source = "git+https://github.com/aiongg/craft-libs?rev=283490a0833e37cc748d29711ff73f81f091e373#283490a0833e37cc748d29711ff73f81f091e373" +source = "git+https://github.com/storytold/craft-libs?rev=16001e7210bee61db60c84fbe18c3c3e2ef4584f#16001e7210bee61db60c84fbe18c3c3e2ef4584f" dependencies = [ "craft-behavior", "craft-host", @@ -1513,7 +1513,7 @@ dependencies = [ [[package]] name = "craft-update" version = "0.1.0" -source = "git+https://github.com/aiongg/craft-libs?rev=283490a0833e37cc748d29711ff73f81f091e373#283490a0833e37cc748d29711ff73f81f091e373" +source = "git+https://github.com/storytold/craft-libs?rev=16001e7210bee61db60c84fbe18c3c3e2ef4584f#16001e7210bee61db60c84fbe18c3c3e2ef4584f" dependencies = [ "chrono", "craft-host", @@ -1542,7 +1542,7 @@ dependencies = [ [[package]] name = "craft-usd" version = "0.1.0" -source = "git+https://github.com/aiongg/craft-libs?rev=283490a0833e37cc748d29711ff73f81f091e373#283490a0833e37cc748d29711ff73f81f091e373" +source = "git+https://github.com/storytold/craft-libs?rev=16001e7210bee61db60c84fbe18c3c3e2ef4584f#16001e7210bee61db60c84fbe18c3c3e2ef4584f" dependencies = [ "half", "lz4_flex", @@ -1552,7 +1552,7 @@ dependencies = [ [[package]] name = "craft-win32" version = "0.1.0" -source = "git+https://github.com/aiongg/craft-libs?rev=283490a0833e37cc748d29711ff73f81f091e373#283490a0833e37cc748d29711ff73f81f091e373" +source = "git+https://github.com/storytold/craft-libs?rev=16001e7210bee61db60c84fbe18c3c3e2ef4584f#16001e7210bee61db60c84fbe18c3c3e2ef4584f" dependencies = [ "winsafe", ] @@ -1560,7 +1560,7 @@ dependencies = [ [[package]] name = "craft-window" version = "0.1.0" -source = "git+https://github.com/aiongg/craft-libs?rev=283490a0833e37cc748d29711ff73f81f091e373#283490a0833e37cc748d29711ff73f81f091e373" +source = "git+https://github.com/storytold/craft-libs?rev=16001e7210bee61db60c84fbe18c3c3e2ef4584f#16001e7210bee61db60c84fbe18c3c3e2ef4584f" dependencies = [ "craft-appkit", "craft-atomic", @@ -1584,7 +1584,7 @@ dependencies = [ [[package]] name = "craft-xml" version = "0.1.0" -source = "git+https://github.com/aiongg/craft-libs?rev=283490a0833e37cc748d29711ff73f81f091e373#283490a0833e37cc748d29711ff73f81f091e373" +source = "git+https://github.com/storytold/craft-libs?rev=16001e7210bee61db60c84fbe18c3c3e2ef4584f#16001e7210bee61db60c84fbe18c3c3e2ef4584f" dependencies = [ "quick-xml 0.41.0", "serde", @@ -1594,7 +1594,7 @@ dependencies = [ [[package]] name = "craft-zip" version = "0.1.0" -source = "git+https://github.com/aiongg/craft-libs?rev=283490a0833e37cc748d29711ff73f81f091e373#283490a0833e37cc748d29711ff73f81f091e373" +source = "git+https://github.com/storytold/craft-libs?rev=16001e7210bee61db60c84fbe18c3c3e2ef4584f#16001e7210bee61db60c84fbe18c3c3e2ef4584f" dependencies = [ "flate2", "thiserror 2.0.21", diff --git a/Cargo.toml b/Cargo.toml index 365720e4..37259235 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -10,7 +10,7 @@ edition = "2024" license = "MIT OR Apache-2.0" [workspace.dependencies] -craft-usd = { version = "0.1.0", git = "https://github.com/aiongg/craft-libs", rev = "283490a0833e37cc748d29711ff73f81f091e373" } +craft-usd = { version = "0.1.0", git = "https://github.com/storytold/craft-libs", rev = "16001e7210bee61db60c84fbe18c3c3e2ef4584f" } # internal texturecraft-core = { path = "crates/core" } texturecraft-texel = { path = "crates/texel" } @@ -41,7 +41,7 @@ skrifa = { version = "0.44", default-features = false, features = ["std"] } epaint_default_fonts = "0.37" log = "0.4" image = { version = "0.25", default-features = false, features = ["png", "jpeg", "tga", "tiff", "exr", "hdr", "bmp", "webp"] } -craft-image-codecs = { git = "https://github.com/aiongg/craft-libs", rev = "283490a0833e37cc748d29711ff73f81f091e373" } +craft-image-codecs = { git = "https://github.com/storytold/craft-libs", rev = "16001e7210bee61db60c84fbe18c3c3e2ef4584f" } half = "2" exr = { version = "1.73", default-features = false } eframe = { version = "0.37", default-features = false } @@ -64,28 +64,28 @@ rustix = { version = "1", default-features = false, features = ["std", "fs", "pr # Shared Craft egui components (widget palette, icon buttons, panel docking): storytold/craft-libs, # MIT OR Apache-2.0, pinned to one rev. # Shared catalog lookup, pinned with the other Craft libraries. -craft-i18n = { git = "https://github.com/aiongg/craft-libs", rev = "283490a0833e37cc748d29711ff73f81f091e373" } -craft-ui = { git = "https://github.com/aiongg/craft-libs", rev = "283490a0833e37cc748d29711ff73f81f091e373" } -craft-behavior = { git = "https://github.com/aiongg/craft-libs", rev = "283490a0833e37cc748d29711ff73f81f091e373" } -craft-materialx = { git = "https://github.com/aiongg/craft-libs", rev = "283490a0833e37cc748d29711ff73f81f091e373" } -craft-tcraft = { git = "https://github.com/aiongg/craft-libs", rev = "283490a0833e37cc748d29711ff73f81f091e373" } -craft-zip = { git = "https://github.com/aiongg/craft-libs", rev = "283490a0833e37cc748d29711ff73f81f091e373" } -craft-mesh = { git = "https://github.com/aiongg/craft-libs", rev = "283490a0833e37cc748d29711ff73f81f091e373", default-features = false, features = ["stl", "ply", "fbx", "obj", "gltf", "dae", "abc"] } -craft-mcmat = { git = "https://github.com/aiongg/craft-libs", rev = "283490a0833e37cc748d29711ff73f81f091e373" } +craft-i18n = { git = "https://github.com/storytold/craft-libs", rev = "16001e7210bee61db60c84fbe18c3c3e2ef4584f" } +craft-ui = { git = "https://github.com/storytold/craft-libs", rev = "16001e7210bee61db60c84fbe18c3c3e2ef4584f" } +craft-behavior = { git = "https://github.com/storytold/craft-libs", rev = "16001e7210bee61db60c84fbe18c3c3e2ef4584f" } +craft-materialx = { git = "https://github.com/storytold/craft-libs", rev = "16001e7210bee61db60c84fbe18c3c3e2ef4584f" } +craft-tcraft = { git = "https://github.com/storytold/craft-libs", rev = "16001e7210bee61db60c84fbe18c3c3e2ef4584f" } +craft-zip = { git = "https://github.com/storytold/craft-libs", rev = "16001e7210bee61db60c84fbe18c3c3e2ef4584f" } +craft-mesh = { git = "https://github.com/storytold/craft-libs", rev = "16001e7210bee61db60c84fbe18c3c3e2ef4584f", default-features = false, features = ["stl", "ply", "fbx", "obj", "gltf", "dae", "abc"] } +craft-mcmat = { git = "https://github.com/storytold/craft-libs", rev = "16001e7210bee61db60c84fbe18c3c3e2ef4584f" } # Who draws the window frame, and the app-drawn strip as the title bar (crates/ui-egui/src/titlebar.rs). -craft-window = { git = "https://github.com/aiongg/craft-libs", rev = "283490a0833e37cc748d29711ff73f81f091e373", features = ["ui"] } +craft-window = { git = "https://github.com/storytold/craft-libs", rev = "16001e7210bee61db60c84fbe18c3c3e2ef4584f", features = ["ui"] } # Release checks, the update prompt and the update helper (crates/ui-egui/src/updates_ui.rs). -craft-update = { git = "https://github.com/aiongg/craft-libs", rev = "283490a0833e37cc748d29711ff73f81f091e373", features = ["ui"] } +craft-update = { git = "https://github.com/storytold/craft-libs", rev = "16001e7210bee61db60c84fbe18c3c3e2ef4584f", features = ["ui"] } # File dialogs that never block the frame (crates/ui-egui/src/file_dialogs.rs). -craft-dialogs = { git = "https://github.com/aiongg/craft-libs", rev = "283490a0833e37cc748d29711ff73f81f091e373" } +craft-dialogs = { git = "https://github.com/storytold/craft-libs", rev = "16001e7210bee61db60c84fbe18c3c3e2ef4584f" } # Shortcut chords, lookup and dispatch (crates/ui-egui/src/keymap.rs). -craft-keymap = { git = "https://github.com/aiongg/craft-libs", rev = "283490a0833e37cc748d29711ff73f81f091e373", features = ["egui"] } +craft-keymap = { git = "https://github.com/storytold/craft-libs", rev = "16001e7210bee61db60c84fbe18c3c3e2ef4584f", features = ["egui"] } # The macOS app menu whose Quit asks about unsaved changes (apps/texturecraft/src/main.rs). -craft-menu = { git = "https://github.com/aiongg/craft-libs", rev = "283490a0833e37cc748d29711ff73f81f091e373" } +craft-menu = { git = "https://github.com/storytold/craft-libs", rev = "16001e7210bee61db60c84fbe18c3c3e2ef4584f" } # The UI runtime's host: who the app is to the framework's dialogs (crates/ui-egui/src/framework.rs). -craft-host = { git = "https://github.com/aiongg/craft-libs", rev = "283490a0833e37cc748d29711ff73f81f091e373" } +craft-host = { git = "https://github.com/storytold/craft-libs", rev = "16001e7210bee61db60c84fbe18c3c3e2ef4584f" } # The theme mode the app hands the runtime (crates/ui-egui/src/framework.rs). -craft-theme = { git = "https://github.com/aiongg/craft-libs", rev = "283490a0833e37cc748d29711ff73f81f091e373" } +craft-theme = { git = "https://github.com/storytold/craft-libs", rev = "16001e7210bee61db60c84fbe18c3c3e2ef4584f" } # egui 0.37 and winit: the suite's forks (storytold/egui, storytold/winit), as craft-libs pins them. [patch.crates-io] diff --git a/crates/formats/Cargo.toml b/crates/formats/Cargo.toml index a087beb3..ad3e622e 100644 --- a/crates/formats/Cargo.toml +++ b/crates/formats/Cargo.toml @@ -11,7 +11,7 @@ workspace = true [dependencies] craft-usd.workspace = true # ICC v2 serialization prerequisite: craft-libs#1735; app colour policy stays local. -craft-cms-icc-v2 = { package = "craft-cms", version = "0.1.0", git = "https://github.com/aiongg/craft-libs", rev = "283490a0833e37cc748d29711ff73f81f091e373" } +craft-cms-icc-v2 = { package = "craft-cms", version = "0.1.0", git = "https://github.com/storytold/craft-libs", rev = "16001e7210bee61db60c84fbe18c3c3e2ef4584f" } craft-materialx = { workspace = true } craft-mesh = { workspace = true } craft-mcmat = { workspace = true } @@ -25,7 +25,7 @@ image = { workspace = true } png = "0.18" bytemuck = { workspace = true, features = ["extern_crate_alloc"] } craft-image-codecs = { workspace = true } -craft-psd = { git = "https://github.com/aiongg/craft-libs", rev = "283490a0833e37cc748d29711ff73f81f091e373" } +craft-psd = { git = "https://github.com/storytold/craft-libs", rev = "16001e7210bee61db60c84fbe18c3c3e2ef4584f" } flate2 = { workspace = true } half = { workspace = true } quick-xml = { workspace = true } From 02613270e442972219ac15c4678e3fb45b8de5a8 Mon Sep 17 00:00:00 2001 From: aiongg Date: Wed, 25 Nov 2026 06:32:50 +0000 Subject: [PATCH 35/83] Repin egui to storytold b15ffe9bfc (what craft-libs next pins) --- Cargo.lock | 20 ++++++++++---------- Cargo.toml | 20 ++++++++++---------- 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index b54d02d3..0a8ebefc 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1872,7 +1872,7 @@ checksum = "d0881ea181b1df73ff77ffaaf9c7544ecc11e82fba9b5f27b262a3c73a332555" [[package]] name = "ecolor" version = "0.37.0" -source = "git+https://github.com/storytold/egui.git?rev=f5025284445ea19c35f746d96fc0b75468b3f560#f5025284445ea19c35f746d96fc0b75468b3f560" +source = "git+https://github.com/storytold/egui.git?rev=b15ffe9bfc2c8e6748533b32b708e10abaf2afec#b15ffe9bfc2c8e6748533b32b708e10abaf2afec" dependencies = [ "bytemuck", "emath", @@ -1882,7 +1882,7 @@ dependencies = [ [[package]] name = "eframe" version = "0.37.0" -source = "git+https://github.com/storytold/egui.git?rev=f5025284445ea19c35f746d96fc0b75468b3f560#f5025284445ea19c35f746d96fc0b75468b3f560" +source = "git+https://github.com/storytold/egui.git?rev=b15ffe9bfc2c8e6748533b32b708e10abaf2afec#b15ffe9bfc2c8e6748533b32b708e10abaf2afec" dependencies = [ "ahash", "bytemuck", @@ -1919,7 +1919,7 @@ dependencies = [ [[package]] name = "egui" version = "0.37.0" -source = "git+https://github.com/storytold/egui.git?rev=f5025284445ea19c35f746d96fc0b75468b3f560#f5025284445ea19c35f746d96fc0b75468b3f560" +source = "git+https://github.com/storytold/egui.git?rev=b15ffe9bfc2c8e6748533b32b708e10abaf2afec#b15ffe9bfc2c8e6748533b32b708e10abaf2afec" dependencies = [ "accesskit", "ahash", @@ -1947,7 +1947,7 @@ dependencies = [ [[package]] name = "egui-wgpu" version = "0.37.0" -source = "git+https://github.com/storytold/egui.git?rev=f5025284445ea19c35f746d96fc0b75468b3f560#f5025284445ea19c35f746d96fc0b75468b3f560" +source = "git+https://github.com/storytold/egui.git?rev=b15ffe9bfc2c8e6748533b32b708e10abaf2afec#b15ffe9bfc2c8e6748533b32b708e10abaf2afec" dependencies = [ "ahash", "bytemuck", @@ -1966,7 +1966,7 @@ dependencies = [ [[package]] name = "egui-winit" version = "0.37.0" -source = "git+https://github.com/storytold/egui.git?rev=f5025284445ea19c35f746d96fc0b75468b3f560#f5025284445ea19c35f746d96fc0b75468b3f560" +source = "git+https://github.com/storytold/egui.git?rev=b15ffe9bfc2c8e6748533b32b708e10abaf2afec#b15ffe9bfc2c8e6748533b32b708e10abaf2afec" dependencies = [ "accesskit_winit", "arboard", @@ -1990,7 +1990,7 @@ dependencies = [ [[package]] name = "egui_glow" version = "0.37.0" -source = "git+https://github.com/storytold/egui.git?rev=f5025284445ea19c35f746d96fc0b75468b3f560#f5025284445ea19c35f746d96fc0b75468b3f560" +source = "git+https://github.com/storytold/egui.git?rev=b15ffe9bfc2c8e6748533b32b708e10abaf2afec#b15ffe9bfc2c8e6748533b32b708e10abaf2afec" dependencies = [ "bytemuck", "egui", @@ -2003,7 +2003,7 @@ dependencies = [ [[package]] name = "egui_kittest" version = "0.37.0" -source = "git+https://github.com/storytold/egui.git?rev=f5025284445ea19c35f746d96fc0b75468b3f560#f5025284445ea19c35f746d96fc0b75468b3f560" +source = "git+https://github.com/storytold/egui.git?rev=b15ffe9bfc2c8e6748533b32b708e10abaf2afec#b15ffe9bfc2c8e6748533b32b708e10abaf2afec" dependencies = [ "eframe", "egui", @@ -2026,7 +2026,7 @@ checksum = "0e9c71c2167ca323c882b99918929403426e2373ea17242ff5653e0d5e1058be" [[package]] name = "emath" version = "0.37.0" -source = "git+https://github.com/storytold/egui.git?rev=f5025284445ea19c35f746d96fc0b75468b3f560#f5025284445ea19c35f746d96fc0b75468b3f560" +source = "git+https://github.com/storytold/egui.git?rev=b15ffe9bfc2c8e6748533b32b708e10abaf2afec#b15ffe9bfc2c8e6748533b32b708e10abaf2afec" dependencies = [ "bytemuck", "serde", @@ -2099,7 +2099,7 @@ dependencies = [ [[package]] name = "epaint" version = "0.37.0" -source = "git+https://github.com/storytold/egui.git?rev=f5025284445ea19c35f746d96fc0b75468b3f560#f5025284445ea19c35f746d96fc0b75468b3f560" +source = "git+https://github.com/storytold/egui.git?rev=b15ffe9bfc2c8e6748533b32b708e10abaf2afec#b15ffe9bfc2c8e6748533b32b708e10abaf2afec" dependencies = [ "ahash", "bytemuck", @@ -2126,7 +2126,7 @@ dependencies = [ [[package]] name = "epaint_default_fonts" version = "0.37.0" -source = "git+https://github.com/storytold/egui.git?rev=f5025284445ea19c35f746d96fc0b75468b3f560#f5025284445ea19c35f746d96fc0b75468b3f560" +source = "git+https://github.com/storytold/egui.git?rev=b15ffe9bfc2c8e6748533b32b708e10abaf2afec#b15ffe9bfc2c8e6748533b32b708e10abaf2afec" [[package]] name = "equivalent" diff --git a/Cargo.toml b/Cargo.toml index 37259235..2b614b46 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -89,16 +89,16 @@ craft-theme = { git = "https://github.com/storytold/craft-libs", rev = "16001e72 # egui 0.37 and winit: the suite's forks (storytold/egui, storytold/winit), as craft-libs pins them. [patch.crates-io] -ecolor = { git = "https://github.com/storytold/egui.git", rev = "f5025284445ea19c35f746d96fc0b75468b3f560" } -emath = { git = "https://github.com/storytold/egui.git", rev = "f5025284445ea19c35f746d96fc0b75468b3f560" } -epaint = { git = "https://github.com/storytold/egui.git", rev = "f5025284445ea19c35f746d96fc0b75468b3f560" } -epaint_default_fonts = { git = "https://github.com/storytold/egui.git", rev = "f5025284445ea19c35f746d96fc0b75468b3f560" } -egui = { git = "https://github.com/storytold/egui.git", rev = "f5025284445ea19c35f746d96fc0b75468b3f560" } -egui-winit = { git = "https://github.com/storytold/egui.git", rev = "f5025284445ea19c35f746d96fc0b75468b3f560" } -egui-wgpu = { git = "https://github.com/storytold/egui.git", rev = "f5025284445ea19c35f746d96fc0b75468b3f560" } -egui_glow = { git = "https://github.com/storytold/egui.git", rev = "f5025284445ea19c35f746d96fc0b75468b3f560" } -eframe = { git = "https://github.com/storytold/egui.git", rev = "f5025284445ea19c35f746d96fc0b75468b3f560" } -egui_kittest = { git = "https://github.com/storytold/egui.git", rev = "f5025284445ea19c35f746d96fc0b75468b3f560" } +ecolor = { git = "https://github.com/storytold/egui.git", rev = "b15ffe9bfc2c8e6748533b32b708e10abaf2afec" } +emath = { git = "https://github.com/storytold/egui.git", rev = "b15ffe9bfc2c8e6748533b32b708e10abaf2afec" } +epaint = { git = "https://github.com/storytold/egui.git", rev = "b15ffe9bfc2c8e6748533b32b708e10abaf2afec" } +epaint_default_fonts = { git = "https://github.com/storytold/egui.git", rev = "b15ffe9bfc2c8e6748533b32b708e10abaf2afec" } +egui = { git = "https://github.com/storytold/egui.git", rev = "b15ffe9bfc2c8e6748533b32b708e10abaf2afec" } +egui-winit = { git = "https://github.com/storytold/egui.git", rev = "b15ffe9bfc2c8e6748533b32b708e10abaf2afec" } +egui-wgpu = { git = "https://github.com/storytold/egui.git", rev = "b15ffe9bfc2c8e6748533b32b708e10abaf2afec" } +egui_glow = { git = "https://github.com/storytold/egui.git", rev = "b15ffe9bfc2c8e6748533b32b708e10abaf2afec" } +eframe = { git = "https://github.com/storytold/egui.git", rev = "b15ffe9bfc2c8e6748533b32b708e10abaf2afec" } +egui_kittest = { git = "https://github.com/storytold/egui.git", rev = "b15ffe9bfc2c8e6748533b32b708e10abaf2afec" } winit = { git = "https://github.com/storytold/winit.git", rev = "a517b3846ee8457d84ee4975110bfda6797c44dc" } # egui-phosphor has no release for egui 0.37 (vendor/egui-phosphor/VENDORED.md). egui-phosphor = { path = "vendor/egui-phosphor" } From 3cf9c5d72a22dda86795ee36e1773a2550d37deb Mon Sep 17 00:00:00 2001 From: aiongg Date: Wed, 25 Nov 2026 06:40:09 +0000 Subject: [PATCH 36/83] cargo fmt --- apps/texturecraft/src/main.rs | 12 ++++++------ crates/ui-egui/src/lib.rs | 2 +- crates/ui-egui/tests/it/export_reference_texts.rs | 5 ++++- crates/ui-egui/tests/it/output_templates.rs | 5 ++++- 4 files changed, 15 insertions(+), 9 deletions(-) diff --git a/apps/texturecraft/src/main.rs b/apps/texturecraft/src/main.rs index f3142bcb..664b791a 100644 --- a/apps/texturecraft/src/main.rs +++ b/apps/texturecraft/src/main.rs @@ -386,7 +386,11 @@ fn main() { let session = initial_session(&args); let frame_decision = TitleBar::decide(prefs.system_title_bar); let title_bar = TitleBar::of(&frame_decision.frame); - let mut viewport = egui::ViewportBuilder::default().with_app_id(os_window::app_id()).with_title(os_window::name()).with_inner_size(DEFAULT_SIZE).with_min_inner_size(MIN_SIZE); + let mut viewport = egui::ViewportBuilder::default() + .with_app_id(os_window::app_id()) + .with_title(os_window::name()) + .with_inner_size(DEFAULT_SIZE) + .with_min_inner_size(MIN_SIZE); if let Some(i) = icon() { viewport = viewport.with_icon(i); } @@ -454,11 +458,7 @@ fn main() { }); notice_shown_in_window.store(previous_nightly_unclean, std::sync::atomic::Ordering::Relaxed); } - Ok(Box::new(Shell { - app, - window_frame: frame_guard, - exit_hook: Some(Box::new(finish_at_exit)), - })) + Ok(Box::new(Shell { app, window_frame: frame_guard, exit_hook: Some(Box::new(finish_at_exit)) })) }), ); // A controlled return, including a handled startup error. On macOS a window already finished in diff --git a/crates/ui-egui/src/lib.rs b/crates/ui-egui/src/lib.rs index 4915b6ca..1466a2f1 100644 --- a/crates/ui-egui/src/lib.rs +++ b/crates/ui-egui/src/lib.rs @@ -90,9 +90,9 @@ mod orb_environment; mod orb_material; pub mod orb_previews; mod orb_shape; -mod pane_split; /// The channel's OS identity (app id, window and app names) — see its module docs. pub mod os_window; +mod pane_split; pub mod parity; mod past_end; mod path_hit; diff --git a/crates/ui-egui/tests/it/export_reference_texts.rs b/crates/ui-egui/tests/it/export_reference_texts.rs index 4d346352..c33be805 100644 --- a/crates/ui-egui/tests/it/export_reference_texts.rs +++ b/crates/ui-egui/tests/it/export_reference_texts.rs @@ -18,7 +18,10 @@ const RAIL_WIDTH_POINTS: f32 = 38.0; /// The Export textures window open on SETTINGS in a screen of `screen_size` fn harness(screen_size: egui::Vec2) -> Harness<'static, TextureCraftApp> { let session = texturecraft_engine::sample_session(256, 64).unwrap(); - let mut h = Harness::builder().with_size(screen_size).with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|cc| TextureCraftApp::new(cc, session)); + let mut h = Harness::builder() + .with_size(screen_size) + .with_context_setup(texturecraft_ui_egui::framework::install_headless) + .build_eframe(|cc| TextureCraftApp::new(cc, session)); h.state_mut().ui.prefs.language = "en".into(); h.run_steps(4); h.state_mut().ui.windows.export = true; diff --git a/crates/ui-egui/tests/it/output_templates.rs b/crates/ui-egui/tests/it/output_templates.rs index 3e03ac87..d8033152 100644 --- a/crates/ui-egui/tests/it/output_templates.rs +++ b/crates/ui-egui/tests/it/output_templates.rs @@ -575,7 +575,10 @@ fn a_click_on_a_channel_offers_clear_and_split_or_collapse_and_a_right_click_inv fn on_a_small_screen_an_rgba_row_keeps_its_controls_in_the_window() { let session = texturecraft_engine::sample_session(256, 64).unwrap(); let library = TemplateLibrary::new("small-screen"); - let mut h = Harness::builder().with_size(egui::vec2(1000.0, 700.0)).with_context_setup(texturecraft_ui_egui::framework::install_headless).build_eframe(|cc| TextureCraftApp::new(cc, session)); + let mut h = Harness::builder() + .with_size(egui::vec2(1000.0, 700.0)) + .with_context_setup(texturecraft_ui_egui::framework::install_headless) + .build_eframe(|cc| TextureCraftApp::new(cc, session)); h.state_mut().ui.prefs.language = "en".into(); h.run_steps(4); h.state_mut().session.load_export_presets(library.0.clone()); From 00c4fce31e2a9946c34fe52218ca319b7dedbc96 Mon Sep 17 00:00:00 2001 From: aiongg Date: Wed, 25 Nov 2026 07:23:43 +0000 Subject: [PATCH 37/83] Close the drop popup on the window's Escape --- crates/ui-egui/src/export_templates.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/crates/ui-egui/src/export_templates.rs b/crates/ui-egui/src/export_templates.rs index beaf660f..7fd10cc4 100644 --- a/crates/ui-egui/src/export_templates.rs +++ b/crates/ui-egui/src/export_templates.rs @@ -1474,8 +1474,10 @@ fn source_channel_popup(ui: &Ui, pending: &mut Option, maps: &mut [ } } }); - // The app can consume Escape before the popup sees it, so read the raw event - let escaped = ui.input(|input| input.raw.events.iter().any(|event| matches!(event, egui::Event::Key { key: egui::Key::Escape, pressed: true, .. }))); + // The app's shortcuts can consume Escape before the popup sees it, so read the raw event too; the runtime keeps an + // Escape nothing of TextureCraft's has focus for as the window's cancel, which the framework reads + let escaped = crate::framework::escape_pressed(ui.ctx()) + || ui.input(|input| input.raw.events.iter().any(|event| matches!(event, egui::Event::Key { key: egui::Key::Escape, pressed: true, .. }))); if picked.is_some() || escaped || shown.is_none_or(|menu| menu.response.should_close()) { *pending = None; } From 14d82e59e2da326be4a3a537526ea7d78a81f224 Mon Sep 17 00:00:00 2001 From: aiongg Date: Wed, 25 Nov 2026 07:24:03 +0000 Subject: [PATCH 38/83] Hide UI on a bare Tab through the framework's chrome toggle --- crates/ui-egui/src/framework.rs | 31 +++++++++++++++++++++---------- 1 file changed, 21 insertions(+), 10 deletions(-) diff --git a/crates/ui-egui/src/framework.rs b/crates/ui-egui/src/framework.rs index a28d85f9..3828a5e3 100644 --- a/crates/ui-egui/src/framework.rs +++ b/crates/ui-egui/src/framework.rs @@ -6,8 +6,10 @@ //! //! The runtime takes Escape, Tab and the clipboard events for the whole window unless one of TextureCraft's own egui //! widgets has the keyboard. The window's Escape is read with [`escape_pressed`] and taken with -//! [`take_window_cancel`], its plain Enter taken with [`take_window_submit`]; the 3D/2D viewport is declared to the runtime with [`host_canvas`], which keeps Tab (Hide -//! UI), the edit chords and the clipboard events in egui's input for TextureCraft's shortcuts. +//! [`take_window_cancel`], its plain Enter taken with [`take_window_submit`]; the 3D/2D viewport is declared to the runtime with [`host_canvas`], which keeps the edit +//! chords and the clipboard events in egui's input for TextureCraft's shortcuts. A bare Tab with nothing focused +//! toggles the window's chrome in the runtime ([`RootEnv::tab_toggles_chrome`]), which `frame_input` turns into Hide UI; +//! with the viewport focused, Tab stays in egui for the shortcut table's `ui.hideUi`. use std::sync::{Arc, OnceLock}; @@ -18,7 +20,7 @@ use craft_ui::fonts::{I18nScripts, SystemFonts, UiFonts}; use craft_ui::runtime::commands::{CommandInput, CommandSet as _, NavCommand, QuitCommand}; use craft_ui::runtime::env::{RootEnv, Scale}; use craft_ui::runtime::focus::{EditSet, KeepKeys, KeyUse}; -use craft_ui::runtime::frame::{FrameInput, FrameOutput}; +use craft_ui::runtime::frame::{ChromeToggle, FrameInput, FrameOutput}; use craft_ui::runtime::keys::{Intent, with_window_intents}; use craft_ui::shell::embed::{self, CloseDecision}; use craft_window::policy::Decision; @@ -102,16 +104,24 @@ impl TextureCraftApp { } /// The root values of this frame. TextureCraft registers no commands with the runtime (its own shortcut table - /// runs every key, [`command_overrides`]) and lets it toggle no chrome (Tab is Hide UI, kept in egui by the - /// viewport's [`host_canvas`]), so the output carries nothing it acts on. While one of TextureCraft's own egui - /// modals shows in the root window, the runtime blocks the panels floated into windows of their own. - pub(crate) fn frame_input(&mut self, ctx: &egui::Context, _output: FrameOutput, scale: f32) -> FrameInput { + /// runs every key, [`command_overrides`]). The runtime toggles the chrome on a bare Tab with nothing focused + /// (`tab_toggles_chrome`, the viewport being the registered canvas), and each panels toggle it recorded for the + /// root window flips Hide UI, as the `ui.hideUi` command does; with the viewport focused, Tab stays in egui for + /// that command ([`host_canvas`]), so one Tab flips Hide UI once. While one of TextureCraft's own egui modals + /// shows in the root window, the runtime blocks the panels floated into windows of their own. + pub(crate) fn frame_input(&mut self, ctx: &egui::Context, output: FrameOutput, scale: f32) -> FrameInput { + for (viewport, toggle) in &output.chrome_toggles { + if *viewport == ViewportId::ROOT && matches!(toggle, ChromeToggle::Panels | ChromeToggle::PanelsKeepTools) { + self.ui.hide_ui = !self.ui.hide_ui; + } + } use crate::theme::Brightness; let mode = match self.ui.prefs.brightness { Brightness::Light | Brightness::MediumLight => craft_theme::Mode::Light, Brightness::Dark | Brightness::MediumDark => craft_theme::Mode::Dark, }; - let root = RootEnv::new().mode(mode).scale(Scale::new(scale)); + let mut root = RootEnv::new().mode(mode).scale(Scale::new(scale)); + root.tab_toggles_chrome = true; let app_modal = crate::docking::input_blocked(self, ctx).then_some(ViewportId::ROOT); FrameInput::new(root).commands(CommandInput::new().overrides(command_overrides())).host(Arc::clone(&self.framework_host)).app_modal(app_modal) } @@ -125,8 +135,9 @@ impl TextureCraftApp { } /// Declares the viewport `id`, drawn in this pass, as the window's document canvas. With nothing focused it is the -/// window's key target: Tab (Hide UI), the edit chords and the clipboard events stay in egui's input for TextureCraft's -/// shortcuts. +/// window's key target: the edit chords and the clipboard events stay in egui's input for TextureCraft's shortcuts. +/// A bare Tab with nothing focused is the runtime's chrome toggle (`frame_input`); with the viewport focused, the +/// canvas keeps Tab in egui for the shortcut table's Hide UI. pub(crate) fn host_canvas(ctx: &egui::Context, id: egui::Id) { const KEYS: KeyUse = KeyUse::CANVAS.with_keep(KeepKeys::Tab).with_edits(EditSet::ALL); craft_ui::runtime::focus::host_canvas(ctx, id, KEYS); From 966ff1d331bef049150c2b52efaf0a1e763010f9 Mon Sep 17 00:00:00 2001 From: aiongg Date: Wed, 25 Nov 2026 07:34:33 +0000 Subject: [PATCH 39/83] Leave Shift+Tab to focus traversal: unbind the panels-except-tools toggle --- crates/ui-egui/src/framework.rs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/crates/ui-egui/src/framework.rs b/crates/ui-egui/src/framework.rs index 3828a5e3..28a3bcbf 100644 --- a/crates/ui-egui/src/framework.rs +++ b/crates/ui-egui/src/framework.rs @@ -17,7 +17,7 @@ use craft_host::target::ShellInfo; use craft_host::{AppInfo, Host}; use craft_keymap::Overrides; use craft_ui::fonts::{I18nScripts, SystemFonts, UiFonts}; -use craft_ui::runtime::commands::{CommandInput, CommandSet as _, NavCommand, QuitCommand}; +use craft_ui::runtime::commands::{ChromeCommand, CommandInput, CommandSet as _, NavCommand, QuitCommand}; use craft_ui::runtime::env::{RootEnv, Scale}; use craft_ui::runtime::focus::{EditSet, KeepKeys, KeyUse}; use craft_ui::runtime::frame::{ChromeToggle, FrameInput, FrameOutput}; @@ -79,14 +79,15 @@ pub(crate) fn host() -> Arc { } /// TextureCraft's own shortcut table keeps the keys the framework binds by default: Ctrl+Q is `ui.quit`, F6 is -/// `camera.orthographic` (and Shift+F6 stays free for it), so the framework's quit and pane moves are unbound. +/// `camera.orthographic` (and Shift+F6 stays free for it), so the framework's quit and pane moves are unbound, as is +/// Shift+Tab's panels toggle except tools (TextureCraft has one Hide UI, on Tab). /// Overrides are keyed by command id, which the command sets give. fn command_overrides() -> Arc { static OVERRIDES: OnceLock> = OnceLock::new(); OVERRIDES .get_or_init(|| { let mut overrides = Overrides::new(); - for id in [QuitCommand::Quit.id(), NavCommand::NextPane.id(), NavCommand::PreviousPane.id()] { + for id in [QuitCommand::Quit.id(), NavCommand::NextPane.id(), NavCommand::PreviousPane.id(), ChromeCommand::TogglePanelsKeepTools.id()] { overrides.insert(id, Vec::new()); } Arc::new(overrides) @@ -111,7 +112,7 @@ impl TextureCraftApp { /// shows in the root window, the runtime blocks the panels floated into windows of their own. pub(crate) fn frame_input(&mut self, ctx: &egui::Context, output: FrameOutput, scale: f32) -> FrameInput { for (viewport, toggle) in &output.chrome_toggles { - if *viewport == ViewportId::ROOT && matches!(toggle, ChromeToggle::Panels | ChromeToggle::PanelsKeepTools) { + if *viewport == ViewportId::ROOT && *toggle == ChromeToggle::Panels { self.ui.hide_ui = !self.ui.hide_ui; } } From a97801e6c968e18424c9e53e8dcb1f5b9365392a Mon Sep 17 00:00:00 2001 From: aiongg Date: Wed, 25 Nov 2026 07:34:56 +0000 Subject: [PATCH 40/83] Keep the window's Escape for the open drop popup --- crates/ui-egui/src/menus.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/crates/ui-egui/src/menus.rs b/crates/ui-egui/src/menus.rs index 656e36f4..46e02bdc 100644 --- a/crates/ui-egui/src/menus.rs +++ b/crates/ui-egui/src/menus.rs @@ -483,7 +483,8 @@ pub fn shortcuts(app: &mut TextureCraftApp, ctx: &egui::Context) { }); // Let the innermost popup consume Escape before cancelling the active tool - let popup_open = egui::Popup::is_any_open(ctx); + // (the drop popup of the Output templates tab is open without registering with egui, and reads Escape itself) + let popup_open = egui::Popup::is_any_open(ctx) || app.ui.export.pending_drop.is_some(); let picker_open = crate::color_picker::open_window(ctx).is_some(); let no_widget_focused = ctx.memory(|memory| memory.focused().is_none()); From 263b2b24fb03ba10f8469953694dabf9051dacfd Mon Sep 17 00:00:00 2001 From: vangel76 Date: Wed, 25 Nov 2026 10:37:22 +0100 Subject: [PATCH 41/83] Derive the expected work threads in the settings test from the core count --- crates/ui-egui/tests/it/settings_window.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/crates/ui-egui/tests/it/settings_window.rs b/crates/ui-egui/tests/it/settings_window.rs index c89a8347..4cbde681 100644 --- a/crates/ui-egui/tests/it/settings_window.rs +++ b/crates/ui-egui/tests/it/settings_window.rs @@ -281,7 +281,11 @@ fn cancel_drops_the_changes_and_ok_applies_and_keeps_them() { let prefs = h.state().ui.prefs.clone(); assert!(!h.state().ui.windows.settings, "OK closes the window"); - assert_eq!((prefs.autosave_minutes, prefs.work_threads, prefs.project_open_limit_gib), (25, 1, 12)); + + // The slider's end stores 0, which is the only step on a one-core machine + let (cores, _) = texturecraft_engine::formats::available_save_resources(); + let expected_work_threads = if cores <= 1 { 0 } else { 1 }; + assert_eq!((prefs.autosave_minutes, prefs.work_threads, prefs.project_open_limit_gib), (25, expected_work_threads, 12)); assert!(prefs.zoom_inverse && !prefs.wheel_inverse && !prefs.show_world_axes); assert!(prefs.drag_zoom_scale() < 0.0, "inverted zoom runs the other way"); From a436007e7e0d8aeec36497e24b145121881e04ef Mon Sep 17 00:00:00 2001 From: vangel76 Date: Wed, 25 Nov 2026 10:41:21 +0100 Subject: [PATCH 42/83] Drop a close that waited for a stroke when another project replaces the project --- crates/ui-egui/src/lib.rs | 7 ++++--- crates/ui-egui/src/manual_save.rs | 15 ++++++++++++++- crates/ui-egui/src/windows.rs | 10 +++++++--- 3 files changed, 25 insertions(+), 7 deletions(-) diff --git a/crates/ui-egui/src/lib.rs b/crates/ui-egui/src/lib.rs index 2f981d6b..e0e9bb10 100644 --- a/crates/ui-egui/src/lib.rs +++ b/crates/ui-egui/src/lib.rs @@ -332,9 +332,10 @@ pub struct TextureCraftApp { /// The unsaved-changes dialog's Save is waiting for a path or a save result. #[cfg(not(target_arch = "wasm32"))] pub(crate) saving_for_prompt: bool, - /// A close the finished save left waiting for an open stroke; decided once the stroke ends. + /// A close the finished save left waiting for an open stroke, with the id of the project it + /// belongs to; decided once the stroke ends, dropped when another project replaced that one. #[cfg(not(target_arch = "wasm32"))] - pub(crate) quit_after_stroke: bool, + pub(crate) quit_after_stroke: Option, /// The requested save completed; the prompt goes on at its next frame. #[cfg(not(target_arch = "wasm32"))] pub(crate) prompt_saved: bool, @@ -456,7 +457,7 @@ impl TextureCraftApp { #[cfg(not(target_arch = "wasm32"))] saving_for_prompt: false, #[cfg(not(target_arch = "wasm32"))] - quit_after_stroke: false, + quit_after_stroke: None, #[cfg(not(target_arch = "wasm32"))] prompt_saved: false, bindings: keymap::Bindings::default(), diff --git a/crates/ui-egui/src/manual_save.rs b/crates/ui-egui/src/manual_save.rs index b7eed0fe..4a3d7008 100644 --- a/crates/ui-egui/src/manual_save.rs +++ b/crates/ui-egui/src/manual_save.rs @@ -90,7 +90,7 @@ impl TextureCraftApp { // A close that the save could not finish asks about the changes it left, once an open stroke ends if job.quit_after_save && !quitting { if self.session.stroke_active() { - self.quit_after_stroke = true; + self.quit_after_stroke = Some(self.session.project_id); } else { crate::windows::ask_to_save(self, Unsaved::Quit); } @@ -297,6 +297,19 @@ mod tests { assert!(h.state().ui.windows.unsaved.is_none()); } + #[test] + fn opening_another_project_drops_the_close_that_waited_for_a_stroke() { + let _language = crate::i18n::TEST_LANGUAGE.lock().unwrap_or_else(std::sync::PoisonError::into_inner); + let mut h = stroke_open_when_the_save_returns("stroke-replaced"); + + h.state_mut().session = texturecraft_engine::sample_session(256, 64).unwrap(); + let closed = sends_close(&mut h); + + assert!(!closed, "the old project's close does not quit the new one"); + assert!(h.state().ui.windows.unsaved.is_none()); + assert!(h.state().quit_after_stroke.is_none()); + } + #[test] fn dismissing_the_prompt_during_a_save_cancels_the_quit() { let _language = crate::i18n::TEST_LANGUAGE.lock().unwrap_or_else(std::sync::PoisonError::into_inner); diff --git a/crates/ui-egui/src/windows.rs b/crates/ui-egui/src/windows.rs index 1c4681e7..431dac8d 100644 --- a/crates/ui-egui/src/windows.rs +++ b/crates/ui-egui/src/windows.rs @@ -95,9 +95,13 @@ pub(crate) fn close_request(app: &mut TextureCraftApp, ctx: &egui::Context) { app.toast(error.to_string(), true); } #[cfg(not(target_arch = "wasm32"))] - if app.quit_after_stroke && !app.session.stroke_active() { - app.quit_after_stroke = false; - if !ask_to_save(app, crate::state::Unsaved::Quit) { + if let Some(project_id) = app.quit_after_stroke + && (project_id != app.session.project_id || !app.session.stroke_active()) + { + app.quit_after_stroke = None; + + // A close that belonged to a replaced project is gone with it + if project_id == app.session.project_id && !ask_to_save(app, crate::state::Unsaved::Quit) { ctx.send_viewport_cmd(egui::ViewportCommand::Close); } } From d88bb3ea4bf7b197a401eca0e6eeffa66ce27ede Mon Sep 17 00:00:00 2001 From: vangel76 Date: Wed, 25 Nov 2026 10:41:37 +0100 Subject: [PATCH 43/83] Correct the UV persistence note in the control protocol docs --- docs/control-protocol.md | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/docs/control-protocol.md b/docs/control-protocol.md index 0754f7c1..2640b9a5 100644 --- a/docs/control-protocol.md +++ b/docs/control-protocol.md @@ -318,9 +318,10 @@ takes a font family, not a path: it reads only the system's font folders. `file.close` leaves no project open: `session.inspect` then reports `projectOpen: false`, `command.list` marks every command but the project-independent ones as not enabled: the ones that open or create a project (`file.open`, `file.new`, `project.new`, `project.sample`), `project.inspect`, `viewport.frame`, `project.templates`, the `export.preset*` commands (`export.presets`, `export.preset.get`, `export.preset.save`, `export.preset.remove`) and the library and preset listings (`brush.preset.list`, `alpha.list`, `filter.list`, `material.list`, `mask.smart.list`, `text.fonts`), each still subject to its own enabled check. The rest are refused with "no project is open" until a project is opened or created. A `texturecraft --control` run starts with the sample project (an empty material ball with `--empty`); the app without `--control` starts with no project. The desktop control channel accepts `rebuildUvs: true` on `file.new` to generate a new UV layout. -The default keeps a complete authored layout and unwraps meshes that need UVs. The project file -saves the generated layout, so reopening it never runs the unwrapper again; reimporting the mesh -from a file rebuilds its UVs. +The default keeps a complete authored layout and unwraps meshes that need UVs. Reopening such a +project imports the mesh again and unwraps it again, as before. Only `rebuildUvs: true` makes the +project file save the generated layout, so reopening it never runs the unwrapper again; +reimporting the mesh from a file rebuilds its UVs. | Tool | Params | Notes | |---|---|---| From 24c8be1aa084df2e1d33a921fda3525a735a532d Mon Sep 17 00:00:00 2001 From: aiongg Date: Wed, 25 Nov 2026 13:22:53 +0000 Subject: [PATCH 44/83] Test profile: craft UI framework and ui-egui below opt-level 2 --- .cargo/config.toml | 65 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) diff --git a/.cargo/config.toml b/.cargo/config.toml index 5592118f..587efc96 100644 --- a/.cargo/config.toml +++ b/.cargo/config.toml @@ -1,2 +1,67 @@ [alias] xtask = "run -p xtask --" + +# Test builds compile the craft UI framework below the workspace's opt-level 2: the Windows test +# build spends most of its time on these crates and the generics they share, and their tests run +# no heavy pixel code. Crates whose tests run on the 2 MiB Windows test stack stay at 1; the rest +# and ui-egui use 0. `cargo run` and `cargo build` use the dev profile and are unaffected. + +[profile.test.package.craft-ui] +opt-level = 1 + +[profile.test.package.craft-ui-contract] +opt-level = 1 + +[profile.test.package.craft-ui-shell] +opt-level = 1 + +[profile.test.package.craft-ui-canvas] +opt-level = 1 + +[profile.test.package.craft-ui-panels] +opt-level = 1 + +[profile.test.package.craft-ui-widgets] +opt-level = 1 + +[profile.test.package.craft-host] +opt-level = 1 + +[profile.test.package.craft-theme] +opt-level = 1 + +[profile.test.package.craft-behavior] +opt-level = 1 + +[profile.test.package.craft-font-catalog] +opt-level = 1 + +[profile.test.package.craft-ui-patterns] +opt-level = 0 + +[profile.test.package.craft-update] +opt-level = 0 + +[profile.test.package.craft-keymap] +opt-level = 0 + +[profile.test.package.craft-dialogs] +opt-level = 0 + +[profile.test.package.craft-settings] +opt-level = 0 + +[profile.test.package.craft-platform] +opt-level = 0 + +[profile.test.package.craft-window] +opt-level = 0 + +[profile.test.package.craft-cloud-ui] +opt-level = 0 + +[profile.test.package.craft-pdf] +opt-level = 0 + +[profile.test.package.texturecraft-ui-egui] +opt-level = 0 From ef82a2cf6c18767c231c3aba596d7323830a5729 Mon Sep 17 00:00:00 2001 From: aiongg Date: Wed, 25 Nov 2026 13:24:25 +0000 Subject: [PATCH 45/83] xtask ci: the wasm check runs on one host --- README.md | 2 +- docs/releasing.md | 2 +- xtask/src/main.rs | 11 +++++++++-- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 345c32c1..69e3998e 100644 --- a/README.md +++ b/README.md @@ -154,7 +154,7 @@ cargo run --release -p texturecraft-cli -- new builtin:crate crate.tcraft --samp cargo run --release -p texturecraft-cli -- render crate.tcraft crate.png --samples 256 # path traced cargo run --release -p texturecraft-cli -- export crate.tcraft textures # headless export cd apps/texturecraft-web && trunk serve # web build -cargo xtask ci # fmt, clippy, tests, layering, wasm +cargo xtask ci # fmt, clippy, tests, layering, wasm (not on Windows) ``` You need Rust 1.95 or newer. The app opens with no project (**File ▸ Open sample project** loads a baked one, and **File ▸ Close** returns to the empty state). diff --git a/docs/releasing.md b/docs/releasing.md index 2658af20..65c2a8bb 100644 --- a/docs/releasing.md +++ b/docs/releasing.md @@ -173,7 +173,7 @@ artwork and keep `ATTRIBUTION.md` in step. See `assets/app-icon/README.md`. ## Local checks -- `cargo xtask ci`: fmt, clippy, tests, `cargo xtask layers`, `cargo xtask wasm`. +- `cargo xtask ci`: fmt, clippy, tests, `cargo xtask layers`, `cargo xtask wasm` (not run by `ci` on Windows; the other hosts cover it). - `bash packaging/linux/apprun-test.sh` and `bash packaging/freebsd/package.sh --dry-run` run anywhere with bash. - `packaging/macos/package.sh --arch aarch64` on a Mac builds an ad-hoc signed DMG. diff --git a/xtask/src/main.rs b/xtask/src/main.rs index 2ff6178a..e1ce8ee1 100644 --- a/xtask/src/main.rs +++ b/xtask/src/main.rs @@ -155,13 +155,20 @@ fn cmd_ci() -> Result<(), String> { }; type Step = (&'static str, Box Result<(), String>>); // Reject invalid dependency layering before spending time compiling and running the workspace. - let steps: Vec = vec![ + let mut steps: Vec = vec![ ("fmt", Box::new(cargo_step(&["fmt", "--all", "--", "--check"]))), ("layers", Box::new(cmd_layers)), ("clippy", Box::new(cargo_step(&["clippy", "--workspace", "--all-targets", "--", "-D", "warnings"]))), ("test", Box::new(cargo_step(&["test", "--workspace"]))), - ("wasm", Box::new(cmd_wasm)), ]; + // The check compiles for wasm32 and gives the same answer on any host, so the non-Windows legs + // cover it and the slower Windows leg skips it. A skipped step is not in the list, so the + // summary never reports it as ok. + if cfg!(windows) { + eprintln!("ci: wasm check not run on Windows (the other hosts cover it)"); + } else { + steps.push(("wasm", Box::new(cmd_wasm))); + } for (i, (name, step)) in steps.iter().enumerate() { eprintln!("\n=== ci: {name} ==="); if let Err(e) = step() { From d52810b354b03b688513aba5fca0785b6a36fac1 Mon Sep 17 00:00:00 2001 From: aiongg Date: Wed, 25 Nov 2026 13:39:16 +0000 Subject: [PATCH 46/83] The viewport is one real Tab stop The 3D and 2D views are declared as host canvases with the ids of their own widgets, so egui keeps the focus Tab gives them. A bare Tab on a focused view hides and shows the UI through the runtime's chrome toggle, as with nothing focused; Shift+Tab moves on from it. A focused view leaves the keyboard to the shortcuts, the held keys and the Path tool. --- crates/ui-egui/src/dock.rs | 2 +- crates/ui-egui/src/docking.rs | 14 +- crates/ui-egui/src/framework.rs | 42 ++-- crates/ui-egui/src/lib.rs | 1 - crates/ui-egui/src/menus.rs | 10 +- .../ui-egui/src/property_sheet/color_bar.rs | 2 +- crates/ui-egui/src/viewport.rs | 34 ++- crates/ui-egui/tests/it/fill_material_rows.rs | 8 + crates/ui-egui/tests/it/main.rs | 1 + crates/ui-egui/tests/it/viewport_focus.rs | 228 ++++++++++++++++++ 10 files changed, 300 insertions(+), 42 deletions(-) create mode 100644 crates/ui-egui/tests/it/viewport_focus.rs diff --git a/crates/ui-egui/src/dock.rs b/crates/ui-egui/src/dock.rs index e7efb8b9..4719071d 100644 --- a/crates/ui-egui/src/dock.rs +++ b/crates/ui-egui/src/dock.rs @@ -186,7 +186,7 @@ pub(crate) fn layers(app: &mut TextureCraftApp, ui: &mut Ui) { /// rename, a number field) keeps the key for itself, and the key is left alone over other panels. fn select_all_layers(app: &mut TextureCraftApp, ui: &Ui) { let ctx = ui.ctx(); - if ctx.egui_wants_keyboard_input() || !ui.ui_contains_pointer() { + if crate::framework::widget_has_keyboard(ctx) || !ui.ui_contains_pointer() { return; } diff --git a/crates/ui-egui/src/docking.rs b/crates/ui-egui/src/docking.rs index e7bb9497..6d827113 100644 --- a/crates/ui-egui/src/docking.rs +++ b/crates/ui-egui/src/docking.rs @@ -451,17 +451,6 @@ fn refresh_specs(app: &mut TextureCraftApp) { // --------------------------------------------------------------------------------------------- // Drawing -/// The viewport's id as the window's document canvas. -fn viewport_canvas_id() -> egui::Id { - egui::Id::unique("texturecraft-viewport-canvas") -} - -/// Declares the viewport, drawn in this pass, as the window's document canvas (the dock's canvas -/// group, or the whole window with the UI hidden). -pub(crate) fn host_viewport_canvas(ctx: &egui::Context) { - crate::framework::host_canvas(ctx, viewport_canvas_id()); -} - /// From a panel's left edge to its contents' text (an empty panel's note) pub(crate) const HEADER_TITLE_LEFT: f32 = 12.0; @@ -610,13 +599,12 @@ impl DockPanels for Panels<'_> { } } - /// The viewport, edge to edge in its group, as the window's document canvas. + /// The viewport, edge to edge in its group. fn group_view(&mut self, panels: &[Panel], _: usize, ui: &mut Ui, at: GroupAt, _: &mut BodyCx<'_>) -> Option { let GroupAt::Show(rect) = at else { return None }; if !panels.contains(&Panel::Viewport) { return None; } - host_viewport_canvas(ui.ctx()); 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(self.app, ui); diff --git a/crates/ui-egui/src/framework.rs b/crates/ui-egui/src/framework.rs index 28a3bcbf..78637b68 100644 --- a/crates/ui-egui/src/framework.rs +++ b/crates/ui-egui/src/framework.rs @@ -6,10 +6,10 @@ //! //! The runtime takes Escape, Tab and the clipboard events for the whole window unless one of TextureCraft's own egui //! widgets has the keyboard. The window's Escape is read with [`escape_pressed`] and taken with -//! [`take_window_cancel`], its plain Enter taken with [`take_window_submit`]; the 3D/2D viewport is declared to the runtime with [`host_canvas`], which keeps the edit -//! chords and the clipboard events in egui's input for TextureCraft's shortcuts. A bare Tab with nothing focused -//! toggles the window's chrome in the runtime ([`RootEnv::tab_toggles_chrome`]), which `frame_input` turns into Hide UI; -//! with the viewport focused, Tab stays in egui for the shortcut table's `ui.hideUi`. +//! [`take_window_cancel`], its plain Enter taken with [`take_window_submit`]; the 3D and 2D views are declared to the runtime with [`host_canvas`], which keeps the edit +//! chords and the clipboard events in egui's input for TextureCraft's shortcuts. A bare Tab with nothing or a view +//! focused toggles the window's chrome in the runtime ([`RootEnv::tab_toggles_chrome`]), which `frame_input` turns into +//! Hide UI. A focused view leaves the keyboard to the shortcuts ([`widget_has_keyboard`]). use std::sync::{Arc, OnceLock}; @@ -19,7 +19,7 @@ use craft_keymap::Overrides; use craft_ui::fonts::{I18nScripts, SystemFonts, UiFonts}; use craft_ui::runtime::commands::{ChromeCommand, CommandInput, CommandSet as _, NavCommand, QuitCommand}; use craft_ui::runtime::env::{RootEnv, Scale}; -use craft_ui::runtime::focus::{EditSet, KeepKeys, KeyUse}; +use craft_ui::runtime::focus::{EditSet, KeyUse}; use craft_ui::runtime::frame::{ChromeToggle, FrameInput, FrameOutput}; use craft_ui::runtime::keys::{Intent, with_window_intents}; use craft_ui::shell::embed::{self, CloseDecision}; @@ -105,11 +105,11 @@ impl TextureCraftApp { } /// The root values of this frame. TextureCraft registers no commands with the runtime (its own shortcut table - /// runs every key, [`command_overrides`]). The runtime toggles the chrome on a bare Tab with nothing focused - /// (`tab_toggles_chrome`, the viewport being the registered canvas), and each panels toggle it recorded for the - /// root window flips Hide UI, as the `ui.hideUi` command does; with the viewport focused, Tab stays in egui for - /// that command ([`host_canvas`]), so one Tab flips Hide UI once. While one of TextureCraft's own egui modals - /// shows in the root window, the runtime blocks the panels floated into windows of their own. + /// runs every key, [`command_overrides`]). The runtime toggles the chrome on a bare Tab with nothing or a + /// view focused (`tab_toggles_chrome`, the views being the registered canvases) and takes it out of egui's input, and + /// each panels toggle it recorded for the root window flips Hide UI, as the `ui.hideUi` command does. While one of + /// TextureCraft's own egui modals shows in the root window, the runtime blocks the panels floated into windows of + /// their own. pub(crate) fn frame_input(&mut self, ctx: &egui::Context, output: FrameOutput, scale: f32) -> FrameInput { for (viewport, toggle) in &output.chrome_toggles { if *viewport == ViewportId::ROOT && *toggle == ChromeToggle::Panels { @@ -135,15 +135,27 @@ impl TextureCraftApp { } } -/// Declares the viewport `id`, drawn in this pass, as the window's document canvas. With nothing focused it is the -/// window's key target: the edit chords and the clipboard events stay in egui's input for TextureCraft's shortcuts. -/// A bare Tab with nothing focused is the runtime's chrome toggle (`frame_input`); with the viewport focused, the -/// canvas keeps Tab in egui for the shortcut table's Hide UI. +/// Declares the view `id`, an egui widget drawn in this pass, as a document canvas of the window. With nothing or the +/// view focused, the edit chords and the clipboard events stay in egui's input for TextureCraft's shortcuts, and a bare +/// Tab is the runtime's chrome toggle (`frame_input`). Tab and Shift+Tab stop at the view, Shift+Tab moves on from it, +/// and a click gives it no focus. pub(crate) fn host_canvas(ctx: &egui::Context, id: egui::Id) { - const KEYS: KeyUse = KeyUse::CANVAS.with_keep(KeepKeys::Tab).with_edits(EditSet::ALL); + const KEYS: KeyUse = KeyUse::CANVAS.with_edits(EditSet::ALL); craft_ui::runtime::focus::host_canvas(ctx, id, KEYS); } +/// The widget that has the keyboard, the 3D and 2D views left out: a focused view leaves the keyboard to +/// TextureCraft's shortcuts, as with nothing focused. +pub(crate) fn focused_widget(ctx: &egui::Context) -> Option { + use crate::viewport::{view_2d_id, view_3d_id}; + ctx.memory(|memory| memory.focused()).filter(|focused| ![view_3d_id(), view_2d_id()].contains(focused)) +} + +/// Whether a widget other than the 3D and 2D views has the keyboard. +pub(crate) fn widget_has_keyboard(ctx: &egui::Context) -> bool { + focused_widget(ctx).is_some() +} + /// Whether Escape was pressed in this pass: from egui while one of TextureCraft's own widgets or popups has the /// keyboard, otherwise the window's cancel, which the runtime routes to no component. Leaves it for later readers. pub(crate) fn escape_pressed(ctx: &egui::Context) -> bool { diff --git a/crates/ui-egui/src/lib.rs b/crates/ui-egui/src/lib.rs index 1466a2f1..844a8b36 100644 --- a/crates/ui-egui/src/lib.rs +++ b/crates/ui-egui/src/lib.rs @@ -1204,7 +1204,6 @@ impl eframe::App for TextureCraftApp { let panel_frame = if hide_ui { egui::Frame::NONE.fill(tokens.viewport) } else { egui::Frame::NONE.fill(tokens.chrome).inner_margin(theme::GUTTER) }; egui::CentralPanel::default().frame(panel_frame).show(ui, |ui| { if hide_ui { - docking::host_viewport_canvas(ui.ctx()); viewport::central(self, ui); } else { docking::show(self, ui); diff --git a/crates/ui-egui/src/menus.rs b/crates/ui-egui/src/menus.rs index 46e02bdc..b2282360 100644 --- a/crates/ui-egui/src/menus.rs +++ b/crates/ui-egui/src/menus.rs @@ -447,9 +447,9 @@ fn effect_command<'a>(app: &TextureCraftApp, id: &'a str) -> &'a str { } } -/// Runs the commands bound to the keys pressed this frame, outside text fields and key capture +/// Runs the commands bound to the keys pressed this frame, with no widget but the viewport focused, outside key capture 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()) { + if crate::keymap::capturing(ctx) || crate::framework::widget_has_keyboard(ctx) { return; } @@ -487,9 +487,7 @@ pub fn shortcuts(app: &mut TextureCraftApp, ctx: &egui::Context) { let popup_open = egui::Popup::is_any_open(ctx) || app.ui.export.pending_drop.is_some(); let picker_open = crate::color_picker::open_window(ctx).is_some(); - let no_widget_focused = ctx.memory(|memory| memory.focused().is_none()); - #[cfg(not(target_arch = "wasm32"))] - let nothing_focused = ctx.memory(|memory| memory.focused().is_none()); + let nothing_focused = !crate::framework::widget_has_keyboard(ctx); let log_copies = crate::log_panel::takes_copy(app, ctx); let commands_to_invoke = ctx.input_mut(|input| { // egui's label selection copies on these events at the end of the frame @@ -501,7 +499,7 @@ pub fn shortcuts(app: &mut TextureCraftApp, ctx: &egui::Context) { // Escape and Enter answer the Reset UI question first, even when a shortcut binds them let confirming_reset = app.ui.windows.confirm_reset_ui; if confirming_reset && !popup_open { - crate::windows::reset_ui_keys(app, input, no_widget_focused); + crate::windows::reset_ui_keys(app, input, nothing_focused); } // F2 renames the selected template on Output templates, before its 3D view binding diff --git a/crates/ui-egui/src/property_sheet/color_bar.rs b/crates/ui-egui/src/property_sheet/color_bar.rs index c83ff515..bf295906 100644 --- a/crates/ui-egui/src/property_sheet/color_bar.rs +++ b/crates/ui-egui/src/property_sheet/color_bar.rs @@ -286,7 +286,7 @@ impl PropertySheet<'_> { // Escape ends hex editing first even when egui has already dropped the field's focus let escape = - crate::framework::escape_pressed(&ctx) && ctx.memory(|memory| memory.focused().is_none_or(|focused| focused == bar.id)) && !hex_took_escape(&ctx); + crate::framework::escape_pressed(&ctx) && crate::framework::focused_widget(&ctx).is_none_or(|focused| focused == bar.id) && !hex_took_escape(&ctx); if closed || (!list_open && !waiting && (pressed_outside || escape)) { state.open = false; crate::color_picker::forget_window(&ctx); diff --git a/crates/ui-egui/src/viewport.rs b/crates/ui-egui/src/viewport.rs index 95f05acf..4e7634d4 100644 --- a/crates/ui-egui/src/viewport.rs +++ b/crates/ui-egui/src/viewport.rs @@ -60,6 +60,24 @@ fn aux_view(app: &TextureCraftApp) -> Option { } } +/// The 3D view's widget: the same in the dock and with the UI hidden, so it keeps the focus when Tab hides the UI +pub fn view_3d_id() -> egui::Id { + egui::Id::unique("texturecraft-view3d") +} + +/// The 2D view's widget, as [`view_3d_id`] +pub fn view_2d_id() -> egui::Id { + egui::Id::unique("texturecraft-view2d") +} + +/// Draw the widget of a view and declare it as a document canvas of the window. In a split view both are, so the keys +/// are the same in either. +fn view_widget(ui: &Ui, rect: Rect, id: egui::Id, sense: Sense) -> egui::Response { + let response = ui.interact(rect, id, sense); + crate::framework::host_canvas(ui.ctx(), id); + response +} + /// The viewport dock tab: the paint bar, then the 3D and 2D views in the chosen layout with the mode's overlays pub fn central(app: &mut TextureCraftApp, ui: &mut Ui) { let mode = app.ui.mode; @@ -183,6 +201,8 @@ fn empty_views(app: &mut TextureCraftApp, ui: &mut Ui) { }; for (rect, id) in regions { + // Nothing to click or drag, but still the window's canvas: Tab hides and shows the UI + view_widget(ui, rect, if id == "v2d" { view_2d_id() } else { view_3d_id() }, Sense::focusable_noninteractive()); ui.painter().rect_filled(rect, 0.0, tokens.viewport); view_header(app, ui, rect, id); } @@ -732,7 +752,7 @@ pub(crate) fn orbit(app: &mut TextureCraftApp, delta: egui::Vec2) { } fn view_3d(app: &mut TextureCraftApp, ui: &mut Ui, rect: Rect, sync: &mut PendingSync) { - let response = ui.interact(rect, ui.scope_id().with("view3d"), Sense::click_and_drag()); + let response = view_widget(ui, rect, view_3d_id(), Sense::click_and_drag()); app.viewport_rect = rect; let size = rect.size(); app.session.viewport = Vec2::new(size.x.max(MIN_CAMERA_VIEWPORT), size.y.max(MIN_CAMERA_VIEWPORT)); @@ -747,7 +767,8 @@ fn view_3d(app: &mut TextureCraftApp, ui: &mut Ui, rect: Rect, sync: &mut Pendin // Navigation; S + drag moves the projection stencil instead, below let delta = ui.input(|input| input.pointer.delta()); - let s_held = app.ui.mode == crate::state::Mode::Painting && ui.input(|input| input.key_down(STENCIL_KEY)) && !ui.ctx().egui_wants_keyboard_input(); + let s_held = + app.ui.mode == crate::state::Mode::Painting && ui.input(|input| input.key_down(STENCIL_KEY)) && !crate::framework::widget_has_keyboard(ui.ctx()); // Only an equipped Projection tool that can act moves its stencil: it isn't drawn otherwise let stencil_moves = tool_acts(app) && app.session.tool.tool == Tool::Projection; @@ -1209,7 +1230,7 @@ fn path_keys(app: &mut TextureCraftApp, ui: &Ui) { return; } - if !tool_acts(app) || app.session.tool.tool != Tool::Path || app.session.tool.path.points.is_empty() || ui.ctx().egui_wants_keyboard_input() { + if !tool_acts(app) || app.session.tool.tool != Tool::Path || app.session.tool.path.points.is_empty() || crate::framework::widget_has_keyboard(ui.ctx()) { return; } @@ -1686,7 +1707,10 @@ fn uv_fill_box_corners(view: crate::uv_view_map::UvViewMap, [origin, opposite]: /// V held with the Clone tool in painting mode: clicks set the clone source fn clone_source_key(app: &TextureCraftApp, ui: &Ui) -> bool { - tool_acts(app) && app.session.tool.tool == Tool::Clone && ui.input(|input| input.key_down(CLONE_SOURCE_KEY)) && !ui.ctx().egui_wants_keyboard_input() + tool_acts(app) + && app.session.tool.tool == Tool::Clone + && ui.input(|input| input.key_down(CLONE_SOURCE_KEY)) + && !crate::framework::widget_has_keyboard(ui.ctx()) } /// Crosshair where the Clone tool reads from. @@ -2069,7 +2093,7 @@ fn framed_tile_view(set: &texturecraft_engine::core::TextureSet, size: egui::Vec /// The 2D (UV) view: navigation, painting in texture coordinates and the overlays drawn over the texture. fn view_2d(app: &mut TextureCraftApp, ui: &mut Ui, rect: Rect, sync: &mut PendingSync) { let tokens = Tokens::get(ui.ctx()); - let response = ui.interact(rect, ui.scope_id().with("view2d"), Sense::click_and_drag()); + let response = view_widget(ui, rect, view_2d_id(), Sense::click_and_drag()); let size = rect.size(); let (alt, shift, snap) = ui.input(|input| (input.modifiers.alt, input.modifiers.shift, input.modifiers.shift && input.modifiers.command)); let ctrl = ui.input(|input| input.modifiers.ctrl); diff --git a/crates/ui-egui/tests/it/fill_material_rows.rs b/crates/ui-egui/tests/it/fill_material_rows.rs index 7aae83bf..fe0091a1 100644 --- a/crates/ui-egui/tests/it/fill_material_rows.rs +++ b/crates/ui-egui/tests/it/fill_material_rows.rs @@ -503,6 +503,14 @@ fn the_picker_is_a_window_beside_the_panel_that_its_title_drags_and_its_close_or harness.run_steps(SETTLE_FRAMES); assert!(harness.query_by_role_and_label(Role::TitleBar, "Base color").is_none(), "Escape closes it"); + + click(&mut harness, Role::Button, "Base color"); + harness.ctx.memory_mut(|memory| memory.request_focus(texturecraft_ui_egui::viewport::view_3d_id())); + harness.run_steps(SETTLE_FRAMES); + harness.key_press(egui::Key::Escape); + harness.run_steps(SETTLE_FRAMES); + + assert!(harness.query_by_role_and_label(Role::TitleBar, "Base color").is_none(), "Escape closes it with the viewport focused"); } #[test] diff --git a/crates/ui-egui/tests/it/main.rs b/crates/ui-egui/tests/it/main.rs index 44cc994a..f3b4fd5a 100644 --- a/crates/ui-egui/tests/it/main.rs +++ b/crates/ui-egui/tests/it/main.rs @@ -102,6 +102,7 @@ mod user_smart_mask; mod view2d_navigation; mod view2d_tiles; mod view_mode_picker; +mod viewport_focus; mod window_menu_684; mod filter_card; diff --git a/crates/ui-egui/tests/it/viewport_focus.rs b/crates/ui-egui/tests/it/viewport_focus.rs new file mode 100644 index 00000000..20eca85c --- /dev/null +++ b/crates/ui-egui/tests/it/viewport_focus.rs @@ -0,0 +1,228 @@ +//! The 3D and 2D views as Tab stops: they keep the focus Tab gives them, Tab on one hides and shows the UI, Shift+Tab +//! moves on from it, and the keys of the viewport work as with nothing focused. + +use craft_ui::runtime::focus::{FocusTarget, request}; +use egui::{Event, Id, Key, Modifiers, PointerButton, Pos2}; +use egui_kittest::Harness; +use egui_kittest::kittest::Queryable as _; +use serde_json::json; +use texturecraft_engine::{Session, Tool, execute}; +use texturecraft_ui_egui::TextureCraftApp; +use texturecraft_ui_egui::state::ViewLayout; +use texturecraft_ui_egui::viewport::{view_2d_id, view_3d_id}; + +type AppHarness = Harness<'static, TextureCraftApp>; + +fn harness(session: Session, layout: ViewLayout) -> AppHarness { + let mut h = Harness::builder() + .with_size(egui::vec2(1600.0, 960.0)) + .with_context_setup(texturecraft_ui_egui::framework::install_headless) + .build_eframe(|cc| TextureCraftApp::new(cc, session)); + h.state_mut().ui.prefs.language = "en".into(); + h.state_mut().ui.layout = layout; + h.run_steps(4); + h +} + +fn sample() -> Session { + texturecraft_engine::sample_session(256, 64).unwrap() +} + +fn focused(h: &AppHarness) -> Option { + h.ctx.memory(|memory| memory.focused()) +} + +/// Focus `view` as Tab does +fn focus(h: &mut AppHarness, view: Id) { + request(&h.ctx, FocusTarget::Id(view)); + h.run_steps(2); + assert_eq!(focused(h), Some(view)); +} + +fn press(h: &mut AppHarness, modifiers: Modifiers, key: Key) { + h.key_press_modifiers(modifiers, key); + h.run_steps(3); +} + +fn hidden(h: &AppHarness) -> bool { + h.state().ui.hide_ui +} + +/// The views each layout draws +const DRAWN: [(ViewLayout, bool, bool); 3] = [(ViewLayout::Only3D, true, false), (ViewLayout::Only2D, false, true), (ViewLayout::Split, true, true)]; + +#[test] +fn shift_tab_walks_over_the_views_and_tab_on_one_toggles_the_ui_once() { + let mut h = harness(sample(), ViewLayout::Split); + let mut walked = Vec::new(); + while focused(&h) != Some(view_3d_id()) { + press(&mut h, Modifiers::SHIFT, Key::Tab); + assert!(focused(&h).is_some(), "Shift+Tab {} keeps a focus", walked.len()); + walked.push(focused(&h).unwrap()); + assert!(walked.len() < 400, "Shift+Tab reaches the 3D view"); + } + assert!(walked.iter().position(|stop| *stop == view_2d_id()).is_some_and(|at| at > 0), "it passes the stops after the views, then the 2D view"); + + press(&mut h, Modifiers::SHIFT, Key::Tab); + let before = focused(&h).expect("Shift+Tab moves on from the view"); + assert!(!walked.contains(&before)); + press(&mut h, Modifiers::NONE, Key::Tab); + assert_eq!(focused(&h), Some(view_3d_id()), "Tab from the stop before the view stops at it"); + assert!(!hidden(&h)); + + press(&mut h, Modifiers::NONE, Key::Tab); + assert!(hidden(&h), "Tab on the focused view hides the UI"); + assert_eq!(focused(&h), Some(view_3d_id()), "which keeps the focus"); + press(&mut h, Modifiers::NONE, Key::Tab); + assert!(!hidden(&h), "the next Tab shows it"); + press(&mut h, Modifiers::SHIFT, Key::Tab); + assert_eq!(focused(&h), Some(before), "Shift+Tab leaves the view backward"); +} + +#[test] +fn every_drawn_view_holds_the_focus_and_toggles_the_ui_with_and_without_a_project() { + for (layout, in_3d, in_2d) in DRAWN { + for project in [true, false] { + for view in [view_3d_id(), view_2d_id()].into_iter().zip([in_3d, in_2d]).filter_map(|(view, drawn)| drawn.then_some(view)) { + let mut h = harness(if project { sample() } else { Session::closed().unwrap() }, layout); + for focus_view in [false, true] { + if focus_view { + focus(&mut h, view); + } + for shown_next in [false, true] { + press(&mut h, Modifiers::NONE, Key::Tab); + assert_eq!(hidden(&h), !shown_next, "project {project}, focused {focus_view}"); + assert_eq!(focused(&h), focus_view.then_some(view), "project {project}"); + } + } + } + } + } +} + +#[test] +fn a_click_in_either_view_leaves_tab_to_the_ui_toggle() { + for (clicked, with_focus) in [(view_3d_id(), view_3d_id()), (view_2d_id(), view_2d_id()), (view_2d_id(), view_3d_id())] { + let mut h = harness(sample(), ViewLayout::Split); + focus(&mut h, with_focus); + let at = h.ctx.read_response(clicked).unwrap().rect.center(); + for pressed in [true, false] { + h.hover_at(at); + h.event(Event::PointerButton { pos: at, button: PointerButton::Primary, pressed, modifiers: Modifiers::NONE }); + h.run_steps(3); + } + press(&mut h, Modifiers::NONE, Key::Tab); + assert!(hidden(&h)); + press(&mut h, Modifiers::NONE, Key::Tab); + assert!(!hidden(&h)); + } +} + +#[test] +fn shortcuts_run_with_a_view_focused() { + for view in [view_3d_id(), view_2d_id()] { + let mut h = harness(sample(), ViewLayout::Split); + let name = h.state().session.doc.project.layers[&h.state().session.selected_layer().unwrap()].name.clone(); + let row = h.get_by_label(&name).rect().center(); + focus(&mut h, view); + let layers = |h: &AppHarness| h.state().session.doc.project.layers.len(); + let before = layers(&h); + h.event(Event::Copy); + h.run_steps(3); + assert!(h.state().session.clipboard.is_some(), "Ctrl+C copies the layer"); + h.event(Event::Paste("Layer".into())); + h.run_steps(3); + assert!(layers(&h) > before, "Ctrl+V pastes it"); + press(&mut h, Modifiers::COMMAND, Key::Z); + assert_eq!(layers(&h), before, "Ctrl+Z takes it back"); + + let size = h.state().session.tool.brush.size; + press(&mut h, Modifiers::NONE, Key::CloseBracket); + assert!(h.state().session.tool.brush.size > size, "] grows the brush"); + + h.hover_at(row); + h.run_steps(1); + press(&mut h, Modifiers::COMMAND, Key::A); + let session = &h.state().session; + let every_row = texturecraft_engine::layer_selection::stack_rows(&session.doc.project, 0, true); + assert_eq!(session.selected_layers().len(), every_row.len(), "Ctrl+A over the Layers panel selects every row"); + assert_eq!(focused(&h), Some(view)); + } +} + +#[test] +fn the_path_keys_work_with_the_view_focused() { + let mut session = sample(); + execute(&mut session, "layer.add.paint", &json!(null)).unwrap(); + execute(&mut session, "tool.select", &json!({"tool": "path"})).unwrap(); + let mut h = harness(session, ViewLayout::Only2D); + let place = |h: &mut AppHarness| { + execute(&mut h.state_mut().session, "tool.path", &json!({"uvPoints": [[0.2, 0.5], [0.5, 0.5], [0.8, 0.5]], "commit": false})).unwrap(); + h.run_steps(3); + }; + let points = |h: &AppHarness| h.state().session.tool.path.points.len(); + focus(&mut h, view_2d_id()); + + place(&mut h); + press(&mut h, Modifiers::NONE, Key::Backspace); + assert_eq!(points(&h), 2, "Backspace removes one point"); + let (effect, index) = h.state().session.tool.path.editing.unwrap(); + press(&mut h, Modifiers::NONE, Key::Enter); + assert!(points(&h) == 0 && h.state().session.paths(effect).is_some_and(|paths| paths.get(index).is_some()), "Enter applies the path"); + + place(&mut h); + assert_eq!(points(&h), 3); + press(&mut h, Modifiers::NONE, Key::Escape); + assert_eq!(points(&h), 0, "Escape cancels the next one"); + assert_eq!(focused(&h), Some(view_2d_id())); +} + +#[test] +fn held_keys_work_with_the_view_focused() { + let mut session = sample(); + let mut png = Vec::new(); + image::RgbaImage::from_pixel(4, 4, image::Rgba([255, 255, 255, 255])).write_to(&mut std::io::Cursor::new(&mut png), image::ImageFormat::Png).unwrap(); + let image = session.import_resource_bytes("logo.png", png).unwrap(); + execute(&mut session, "tool.stencil", &json!({"image": image})).unwrap(); + session.tool.tool = Tool::Projection; + let mut h = harness(session, ViewLayout::Only3D); + focus(&mut h, view_3d_id()); + + let scale = |h: &AppHarness| h.state().session.tool.stencil.as_ref().unwrap().scale; + let (before, yaw) = (scale(&h), h.state().session.camera.yaw); + hold_and_right_drag(&mut h, Key::S); + assert_ne!(scale(&h), before, "S + right drag scales the stencil"); + assert_eq!(h.state().session.camera.yaw, yaw, "instead of turning the camera"); + assert_eq!(focused(&h), Some(view_3d_id())); +} + +fn hold_and_right_drag(h: &mut AppHarness, key: Key) { + let from = h.state().viewport_rect.center(); + let button = |h: &mut AppHarness, pos: Pos2, pressed| { + h.event(Event::PointerButton { pos, button: PointerButton::Secondary, pressed, modifiers: Modifiers::NONE }); + }; + h.event(Event::Key { key, physical_key: Some(key), pressed: true, repeat: false, modifiers: Modifiers::NONE }); + h.hover_at(from); + button(h, from, true); + h.run_steps(2); + for step in 1..=4 { + h.hover_at(from + egui::vec2(15.0 * step as f32, 0.0)); + h.run_steps(1); + } + button(h, from + egui::vec2(60.0, 0.0), false); + h.event(Event::Key { key, physical_key: Some(key), pressed: false, repeat: false, modifiers: Modifiers::NONE }); + h.run_steps(3); +} + +#[test] +fn escape_and_enter_answer_a_question_with_a_view_focused() { + for (key, reset) in [(Key::Escape, false), (Key::Enter, true)] { + let mut h = harness(sample(), ViewLayout::Only3D); + h.state_mut().ui.windows.confirm_reset_ui = true; + h.run_steps(3); + focus(&mut h, view_3d_id()); + press(&mut h, Modifiers::NONE, key); + assert!(!h.state().ui.windows.confirm_reset_ui, "{key:?} answers the question"); + assert_eq!(h.state().ui.layout == ViewLayout::Split, reset, "only Enter resets the layout"); + } +} From 4292f553f5ecce8b435def67e1eab68995a59f32 Mon Sep 17 00:00:00 2001 From: aiongg Date: Wed, 25 Nov 2026 13:44:23 +0000 Subject: [PATCH 47/83] Repin craft-libs to storytold next d1bdf8e5da --- Cargo.lock | 90 +++++++++++++++++++-------------------- Cargo.toml | 34 +++++++-------- crates/formats/Cargo.toml | 4 +- 3 files changed, 64 insertions(+), 64 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index d623e59a..0f8bb202 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -953,7 +953,7 @@ dependencies = [ [[package]] name = "craft-appkit" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=16001e7210bee61db60c84fbe18c3c3e2ef4584f#16001e7210bee61db60c84fbe18c3c3e2ef4584f" +source = "git+https://github.com/storytold/craft-libs?rev=d1bdf8e5dac7513e4fbc4dab16edaaeda5ebcf5e#d1bdf8e5dac7513e4fbc4dab16edaaeda5ebcf5e" dependencies = [ "block2 0.6.2", "objc2-app-kit 0.3.2", @@ -963,7 +963,7 @@ dependencies = [ [[package]] name = "craft-atomic" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=16001e7210bee61db60c84fbe18c3c3e2ef4584f#16001e7210bee61db60c84fbe18c3c3e2ef4584f" +source = "git+https://github.com/storytold/craft-libs?rev=d1bdf8e5dac7513e4fbc4dab16edaaeda5ebcf5e#d1bdf8e5dac7513e4fbc4dab16edaaeda5ebcf5e" dependencies = [ "rustix 1.1.6", ] @@ -971,7 +971,7 @@ dependencies = [ [[package]] name = "craft-behavior" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=16001e7210bee61db60c84fbe18c3c3e2ef4584f#16001e7210bee61db60c84fbe18c3c3e2ef4584f" +source = "git+https://github.com/storytold/craft-libs?rev=d1bdf8e5dac7513e4fbc4dab16edaaeda5ebcf5e#d1bdf8e5dac7513e4fbc4dab16edaaeda5ebcf5e" dependencies = [ "accesskit", "bitflags 2.13.2", @@ -989,7 +989,7 @@ dependencies = [ [[package]] name = "craft-cloud-ui" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=16001e7210bee61db60c84fbe18c3c3e2ef4584f#16001e7210bee61db60c84fbe18c3c3e2ef4584f" +source = "git+https://github.com/storytold/craft-libs?rev=d1bdf8e5dac7513e4fbc4dab16edaaeda5ebcf5e#d1bdf8e5dac7513e4fbc4dab16edaaeda5ebcf5e" dependencies = [ "egui", ] @@ -997,7 +997,7 @@ dependencies = [ [[package]] name = "craft-cms" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=16001e7210bee61db60c84fbe18c3c3e2ef4584f#16001e7210bee61db60c84fbe18c3c3e2ef4584f" +source = "git+https://github.com/storytold/craft-libs?rev=d1bdf8e5dac7513e4fbc4dab16edaaeda5ebcf5e#d1bdf8e5dac7513e4fbc4dab16edaaeda5ebcf5e" dependencies = [ "md-5", "rayon", @@ -1006,12 +1006,12 @@ dependencies = [ [[package]] name = "craft-codepage" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=16001e7210bee61db60c84fbe18c3c3e2ef4584f#16001e7210bee61db60c84fbe18c3c3e2ef4584f" +source = "git+https://github.com/storytold/craft-libs?rev=d1bdf8e5dac7513e4fbc4dab16edaaeda5ebcf5e#d1bdf8e5dac7513e4fbc4dab16edaaeda5ebcf5e" [[package]] name = "craft-dds" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=16001e7210bee61db60c84fbe18c3c3e2ef4584f#16001e7210bee61db60c84fbe18c3c3e2ef4584f" +source = "git+https://github.com/storytold/craft-libs?rev=d1bdf8e5dac7513e4fbc4dab16edaaeda5ebcf5e#d1bdf8e5dac7513e4fbc4dab16edaaeda5ebcf5e" dependencies = [ "rayon", ] @@ -1019,7 +1019,7 @@ dependencies = [ [[package]] name = "craft-dialogs" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=16001e7210bee61db60c84fbe18c3c3e2ef4584f#16001e7210bee61db60c84fbe18c3c3e2ef4584f" +source = "git+https://github.com/storytold/craft-libs?rev=d1bdf8e5dac7513e4fbc4dab16edaaeda5ebcf5e#d1bdf8e5dac7513e4fbc4dab16edaaeda5ebcf5e" dependencies = [ "block2 0.6.2", "craft-atomic", @@ -1039,7 +1039,7 @@ dependencies = [ [[package]] name = "craft-docpath" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=16001e7210bee61db60c84fbe18c3c3e2ef4584f#16001e7210bee61db60c84fbe18c3c3e2ef4584f" +source = "git+https://github.com/storytold/craft-libs?rev=d1bdf8e5dac7513e4fbc4dab16edaaeda5ebcf5e#d1bdf8e5dac7513e4fbc4dab16edaaeda5ebcf5e" dependencies = [ "serde", ] @@ -1047,7 +1047,7 @@ dependencies = [ [[package]] name = "craft-font-catalog" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=16001e7210bee61db60c84fbe18c3c3e2ef4584f#16001e7210bee61db60c84fbe18c3c3e2ef4584f" +source = "git+https://github.com/storytold/craft-libs?rev=d1bdf8e5dac7513e4fbc4dab16edaaeda5ebcf5e#d1bdf8e5dac7513e4fbc4dab16edaaeda5ebcf5e" dependencies = [ "harfrust 0.13.3", "kurbo", @@ -1061,12 +1061,12 @@ dependencies = [ [[package]] name = "craft-fonts-build" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=16001e7210bee61db60c84fbe18c3c3e2ef4584f#16001e7210bee61db60c84fbe18c3c3e2ef4584f" +source = "git+https://github.com/storytold/craft-libs?rev=d1bdf8e5dac7513e4fbc4dab16edaaeda5ebcf5e#d1bdf8e5dac7513e4fbc4dab16edaaeda5ebcf5e" [[package]] name = "craft-host" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=16001e7210bee61db60c84fbe18c3c3e2ef4584f#16001e7210bee61db60c84fbe18c3c3e2ef4584f" +source = "git+https://github.com/storytold/craft-libs?rev=d1bdf8e5dac7513e4fbc4dab16edaaeda5ebcf5e#d1bdf8e5dac7513e4fbc4dab16edaaeda5ebcf5e" dependencies = [ "bitflags 2.13.2", "craft-i18n", @@ -1079,7 +1079,7 @@ dependencies = [ [[package]] name = "craft-i18n" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=16001e7210bee61db60c84fbe18c3c3e2ef4584f#16001e7210bee61db60c84fbe18c3c3e2ef4584f" +source = "git+https://github.com/storytold/craft-libs?rev=d1bdf8e5dac7513e4fbc4dab16edaaeda5ebcf5e#d1bdf8e5dac7513e4fbc4dab16edaaeda5ebcf5e" dependencies = [ "chrono", "fixed_decimal", @@ -1107,7 +1107,7 @@ dependencies = [ [[package]] name = "craft-image-codecs" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=16001e7210bee61db60c84fbe18c3c3e2ef4584f#16001e7210bee61db60c84fbe18c3c3e2ef4584f" +source = "git+https://github.com/storytold/craft-libs?rev=d1bdf8e5dac7513e4fbc4dab16edaaeda5ebcf5e#d1bdf8e5dac7513e4fbc4dab16edaaeda5ebcf5e" dependencies = [ "craft-dds", "craft-jpeg", @@ -1134,7 +1134,7 @@ dependencies = [ [[package]] name = "craft-jpeg" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=16001e7210bee61db60c84fbe18c3c3e2ef4584f#16001e7210bee61db60c84fbe18c3c3e2ef4584f" +source = "git+https://github.com/storytold/craft-libs?rev=d1bdf8e5dac7513e4fbc4dab16edaaeda5ebcf5e#d1bdf8e5dac7513e4fbc4dab16edaaeda5ebcf5e" dependencies = [ "thiserror 2.0.21", ] @@ -1142,7 +1142,7 @@ dependencies = [ [[package]] name = "craft-keymap" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=16001e7210bee61db60c84fbe18c3c3e2ef4584f#16001e7210bee61db60c84fbe18c3c3e2ef4584f" +source = "git+https://github.com/storytold/craft-libs?rev=d1bdf8e5dac7513e4fbc4dab16edaaeda5ebcf5e#d1bdf8e5dac7513e4fbc4dab16edaaeda5ebcf5e" dependencies = [ "craft-host", "craft-i18n", @@ -1157,7 +1157,7 @@ dependencies = [ [[package]] name = "craft-materialx" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=16001e7210bee61db60c84fbe18c3c3e2ef4584f#16001e7210bee61db60c84fbe18c3c3e2ef4584f" +source = "git+https://github.com/storytold/craft-libs?rev=d1bdf8e5dac7513e4fbc4dab16edaaeda5ebcf5e#d1bdf8e5dac7513e4fbc4dab16edaaeda5ebcf5e" dependencies = [ "craft-xml", "thiserror 2.0.21", @@ -1166,7 +1166,7 @@ dependencies = [ [[package]] name = "craft-mcmat" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=16001e7210bee61db60c84fbe18c3c3e2ef4584f#16001e7210bee61db60c84fbe18c3c3e2ef4584f" +source = "git+https://github.com/storytold/craft-libs?rev=d1bdf8e5dac7513e4fbc4dab16edaaeda5ebcf5e#d1bdf8e5dac7513e4fbc4dab16edaaeda5ebcf5e" dependencies = [ "craft-zip", "serde", @@ -1177,7 +1177,7 @@ dependencies = [ [[package]] name = "craft-menu" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=16001e7210bee61db60c84fbe18c3c3e2ef4584f#16001e7210bee61db60c84fbe18c3c3e2ef4584f" +source = "git+https://github.com/storytold/craft-libs?rev=d1bdf8e5dac7513e4fbc4dab16edaaeda5ebcf5e#d1bdf8e5dac7513e4fbc4dab16edaaeda5ebcf5e" dependencies = [ "craft-behavior", "craft-host", @@ -1195,7 +1195,7 @@ dependencies = [ [[package]] name = "craft-mesh" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=16001e7210bee61db60c84fbe18c3c3e2ef4584f#16001e7210bee61db60c84fbe18c3c3e2ef4584f" +source = "git+https://github.com/storytold/craft-libs?rev=d1bdf8e5dac7513e4fbc4dab16edaaeda5ebcf5e#d1bdf8e5dac7513e4fbc4dab16edaaeda5ebcf5e" dependencies = [ "craft-xml", "craft-zip", @@ -1206,7 +1206,7 @@ dependencies = [ [[package]] name = "craft-metadata" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=16001e7210bee61db60c84fbe18c3c3e2ef4584f#16001e7210bee61db60c84fbe18c3c3e2ef4584f" +source = "git+https://github.com/storytold/craft-libs?rev=d1bdf8e5dac7513e4fbc4dab16edaaeda5ebcf5e#d1bdf8e5dac7513e4fbc4dab16edaaeda5ebcf5e" dependencies = [ "brotli-decompressor", "chrono", @@ -1218,7 +1218,7 @@ dependencies = [ [[package]] name = "craft-pdf" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=16001e7210bee61db60c84fbe18c3c3e2ef4584f#16001e7210bee61db60c84fbe18c3c3e2ef4584f" +source = "git+https://github.com/storytold/craft-libs?rev=d1bdf8e5dac7513e4fbc4dab16edaaeda5ebcf5e#d1bdf8e5dac7513e4fbc4dab16edaaeda5ebcf5e" dependencies = [ "serde", ] @@ -1226,7 +1226,7 @@ dependencies = [ [[package]] name = "craft-platform" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=16001e7210bee61db60c84fbe18c3c3e2ef4584f#16001e7210bee61db60c84fbe18c3c3e2ef4584f" +source = "git+https://github.com/storytold/craft-libs?rev=d1bdf8e5dac7513e4fbc4dab16edaaeda5ebcf5e#d1bdf8e5dac7513e4fbc4dab16edaaeda5ebcf5e" dependencies = [ "async-channel", "async-io", @@ -1257,7 +1257,7 @@ dependencies = [ [[package]] name = "craft-psd" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=16001e7210bee61db60c84fbe18c3c3e2ef4584f#16001e7210bee61db60c84fbe18c3c3e2ef4584f" +source = "git+https://github.com/storytold/craft-libs?rev=d1bdf8e5dac7513e4fbc4dab16edaaeda5ebcf5e#d1bdf8e5dac7513e4fbc4dab16edaaeda5ebcf5e" dependencies = [ "encoding_rs", "flate2", @@ -1268,7 +1268,7 @@ dependencies = [ [[package]] name = "craft-quit" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=16001e7210bee61db60c84fbe18c3c3e2ef4584f#16001e7210bee61db60c84fbe18c3c3e2ef4584f" +source = "git+https://github.com/storytold/craft-libs?rev=d1bdf8e5dac7513e4fbc4dab16edaaeda5ebcf5e#d1bdf8e5dac7513e4fbc4dab16edaaeda5ebcf5e" dependencies = [ "dispatch2", "egui", @@ -1281,7 +1281,7 @@ dependencies = [ [[package]] name = "craft-settings" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=16001e7210bee61db60c84fbe18c3c3e2ef4584f#16001e7210bee61db60c84fbe18c3c3e2ef4584f" +source = "git+https://github.com/storytold/craft-libs?rev=d1bdf8e5dac7513e4fbc4dab16edaaeda5ebcf5e#d1bdf8e5dac7513e4fbc4dab16edaaeda5ebcf5e" dependencies = [ "craft-atomic", "craft-host", @@ -1298,7 +1298,7 @@ dependencies = [ [[package]] name = "craft-svg" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=16001e7210bee61db60c84fbe18c3c3e2ef4584f#16001e7210bee61db60c84fbe18c3c3e2ef4584f" +source = "git+https://github.com/storytold/craft-libs?rev=d1bdf8e5dac7513e4fbc4dab16edaaeda5ebcf5e#d1bdf8e5dac7513e4fbc4dab16edaaeda5ebcf5e" dependencies = [ "craft-xml", "flate2", @@ -1315,7 +1315,7 @@ dependencies = [ [[package]] name = "craft-tcraft" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=16001e7210bee61db60c84fbe18c3c3e2ef4584f#16001e7210bee61db60c84fbe18c3c3e2ef4584f" +source = "git+https://github.com/storytold/craft-libs?rev=d1bdf8e5dac7513e4fbc4dab16edaaeda5ebcf5e#d1bdf8e5dac7513e4fbc4dab16edaaeda5ebcf5e" dependencies = [ "craft-zip", "serde", @@ -1326,7 +1326,7 @@ dependencies = [ [[package]] name = "craft-theme" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=16001e7210bee61db60c84fbe18c3c3e2ef4584f#16001e7210bee61db60c84fbe18c3c3e2ef4584f" +source = "git+https://github.com/storytold/craft-libs?rev=d1bdf8e5dac7513e4fbc4dab16edaaeda5ebcf5e#d1bdf8e5dac7513e4fbc4dab16edaaeda5ebcf5e" dependencies = [ "bitflags 2.13.2", "craft-tracked", @@ -1341,7 +1341,7 @@ dependencies = [ [[package]] name = "craft-tiff" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=16001e7210bee61db60c84fbe18c3c3e2ef4584f#16001e7210bee61db60c84fbe18c3c3e2ef4584f" +source = "git+https://github.com/storytold/craft-libs?rev=d1bdf8e5dac7513e4fbc4dab16edaaeda5ebcf5e#d1bdf8e5dac7513e4fbc4dab16edaaeda5ebcf5e" dependencies = [ "serde", "thiserror 2.0.21", @@ -1351,12 +1351,12 @@ dependencies = [ [[package]] name = "craft-tracked" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=16001e7210bee61db60c84fbe18c3c3e2ef4584f#16001e7210bee61db60c84fbe18c3c3e2ef4584f" +source = "git+https://github.com/storytold/craft-libs?rev=d1bdf8e5dac7513e4fbc4dab16edaaeda5ebcf5e#d1bdf8e5dac7513e4fbc4dab16edaaeda5ebcf5e" [[package]] name = "craft-ui" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=16001e7210bee61db60c84fbe18c3c3e2ef4584f#16001e7210bee61db60c84fbe18c3c3e2ef4584f" +source = "git+https://github.com/storytold/craft-libs?rev=d1bdf8e5dac7513e4fbc4dab16edaaeda5ebcf5e#d1bdf8e5dac7513e4fbc4dab16edaaeda5ebcf5e" dependencies = [ "craft-cloud-ui", "craft-ui-canvas", @@ -1370,7 +1370,7 @@ dependencies = [ [[package]] name = "craft-ui-canvas" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=16001e7210bee61db60c84fbe18c3c3e2ef4584f#16001e7210bee61db60c84fbe18c3c3e2ef4584f" +source = "git+https://github.com/storytold/craft-libs?rev=d1bdf8e5dac7513e4fbc4dab16edaaeda5ebcf5e#d1bdf8e5dac7513e4fbc4dab16edaaeda5ebcf5e" dependencies = [ "craft-behavior", "craft-i18n", @@ -1386,7 +1386,7 @@ dependencies = [ [[package]] name = "craft-ui-contract" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=16001e7210bee61db60c84fbe18c3c3e2ef4584f#16001e7210bee61db60c84fbe18c3c3e2ef4584f" +source = "git+https://github.com/storytold/craft-libs?rev=d1bdf8e5dac7513e4fbc4dab16edaaeda5ebcf5e#d1bdf8e5dac7513e4fbc4dab16edaaeda5ebcf5e" dependencies = [ "accesskit", "craft-behavior", @@ -1424,7 +1424,7 @@ dependencies = [ [[package]] name = "craft-ui-macros" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=16001e7210bee61db60c84fbe18c3c3e2ef4584f#16001e7210bee61db60c84fbe18c3c3e2ef4584f" +source = "git+https://github.com/storytold/craft-libs?rev=d1bdf8e5dac7513e4fbc4dab16edaaeda5ebcf5e#d1bdf8e5dac7513e4fbc4dab16edaaeda5ebcf5e" dependencies = [ "proc-macro-crate", "proc-macro2", @@ -1435,7 +1435,7 @@ dependencies = [ [[package]] name = "craft-ui-panels" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=16001e7210bee61db60c84fbe18c3c3e2ef4584f#16001e7210bee61db60c84fbe18c3c3e2ef4584f" +source = "git+https://github.com/storytold/craft-libs?rev=d1bdf8e5dac7513e4fbc4dab16edaaeda5ebcf5e#d1bdf8e5dac7513e4fbc4dab16edaaeda5ebcf5e" dependencies = [ "craft-behavior", "craft-host", @@ -1453,7 +1453,7 @@ dependencies = [ [[package]] name = "craft-ui-patterns" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=16001e7210bee61db60c84fbe18c3c3e2ef4584f#16001e7210bee61db60c84fbe18c3c3e2ef4584f" +source = "git+https://github.com/storytold/craft-libs?rev=d1bdf8e5dac7513e4fbc4dab16edaaeda5ebcf5e#d1bdf8e5dac7513e4fbc4dab16edaaeda5ebcf5e" dependencies = [ "craft-behavior", "craft-host", @@ -1474,7 +1474,7 @@ dependencies = [ [[package]] name = "craft-ui-shell" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=16001e7210bee61db60c84fbe18c3c3e2ef4584f#16001e7210bee61db60c84fbe18c3c3e2ef4584f" +source = "git+https://github.com/storytold/craft-libs?rev=d1bdf8e5dac7513e4fbc4dab16edaaeda5ebcf5e#d1bdf8e5dac7513e4fbc4dab16edaaeda5ebcf5e" dependencies = [ "craft-behavior", "craft-host", @@ -1494,7 +1494,7 @@ dependencies = [ [[package]] name = "craft-ui-widgets" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=16001e7210bee61db60c84fbe18c3c3e2ef4584f#16001e7210bee61db60c84fbe18c3c3e2ef4584f" +source = "git+https://github.com/storytold/craft-libs?rev=d1bdf8e5dac7513e4fbc4dab16edaaeda5ebcf5e#d1bdf8e5dac7513e4fbc4dab16edaaeda5ebcf5e" dependencies = [ "craft-behavior", "craft-host", @@ -1513,7 +1513,7 @@ dependencies = [ [[package]] name = "craft-update" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=16001e7210bee61db60c84fbe18c3c3e2ef4584f#16001e7210bee61db60c84fbe18c3c3e2ef4584f" +source = "git+https://github.com/storytold/craft-libs?rev=d1bdf8e5dac7513e4fbc4dab16edaaeda5ebcf5e#d1bdf8e5dac7513e4fbc4dab16edaaeda5ebcf5e" dependencies = [ "chrono", "craft-host", @@ -1542,7 +1542,7 @@ dependencies = [ [[package]] name = "craft-usd" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=16001e7210bee61db60c84fbe18c3c3e2ef4584f#16001e7210bee61db60c84fbe18c3c3e2ef4584f" +source = "git+https://github.com/storytold/craft-libs?rev=d1bdf8e5dac7513e4fbc4dab16edaaeda5ebcf5e#d1bdf8e5dac7513e4fbc4dab16edaaeda5ebcf5e" dependencies = [ "half", "lz4_flex", @@ -1552,7 +1552,7 @@ dependencies = [ [[package]] name = "craft-win32" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=16001e7210bee61db60c84fbe18c3c3e2ef4584f#16001e7210bee61db60c84fbe18c3c3e2ef4584f" +source = "git+https://github.com/storytold/craft-libs?rev=d1bdf8e5dac7513e4fbc4dab16edaaeda5ebcf5e#d1bdf8e5dac7513e4fbc4dab16edaaeda5ebcf5e" dependencies = [ "winsafe", ] @@ -1560,7 +1560,7 @@ dependencies = [ [[package]] name = "craft-window" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=16001e7210bee61db60c84fbe18c3c3e2ef4584f#16001e7210bee61db60c84fbe18c3c3e2ef4584f" +source = "git+https://github.com/storytold/craft-libs?rev=d1bdf8e5dac7513e4fbc4dab16edaaeda5ebcf5e#d1bdf8e5dac7513e4fbc4dab16edaaeda5ebcf5e" dependencies = [ "craft-appkit", "craft-atomic", @@ -1584,7 +1584,7 @@ dependencies = [ [[package]] name = "craft-xml" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=16001e7210bee61db60c84fbe18c3c3e2ef4584f#16001e7210bee61db60c84fbe18c3c3e2ef4584f" +source = "git+https://github.com/storytold/craft-libs?rev=d1bdf8e5dac7513e4fbc4dab16edaaeda5ebcf5e#d1bdf8e5dac7513e4fbc4dab16edaaeda5ebcf5e" dependencies = [ "quick-xml 0.41.0", "serde", @@ -1594,7 +1594,7 @@ dependencies = [ [[package]] name = "craft-zip" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=16001e7210bee61db60c84fbe18c3c3e2ef4584f#16001e7210bee61db60c84fbe18c3c3e2ef4584f" +source = "git+https://github.com/storytold/craft-libs?rev=d1bdf8e5dac7513e4fbc4dab16edaaeda5ebcf5e#d1bdf8e5dac7513e4fbc4dab16edaaeda5ebcf5e" dependencies = [ "flate2", "thiserror 2.0.21", diff --git a/Cargo.toml b/Cargo.toml index 2b614b46..fd01e74b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -10,7 +10,7 @@ edition = "2024" license = "MIT OR Apache-2.0" [workspace.dependencies] -craft-usd = { version = "0.1.0", git = "https://github.com/storytold/craft-libs", rev = "16001e7210bee61db60c84fbe18c3c3e2ef4584f" } +craft-usd = { version = "0.1.0", git = "https://github.com/storytold/craft-libs", rev = "d1bdf8e5dac7513e4fbc4dab16edaaeda5ebcf5e" } # internal texturecraft-core = { path = "crates/core" } texturecraft-texel = { path = "crates/texel" } @@ -41,7 +41,7 @@ skrifa = { version = "0.44", default-features = false, features = ["std"] } epaint_default_fonts = "0.37" log = "0.4" image = { version = "0.25", default-features = false, features = ["png", "jpeg", "tga", "tiff", "exr", "hdr", "bmp", "webp"] } -craft-image-codecs = { git = "https://github.com/storytold/craft-libs", rev = "16001e7210bee61db60c84fbe18c3c3e2ef4584f" } +craft-image-codecs = { git = "https://github.com/storytold/craft-libs", rev = "d1bdf8e5dac7513e4fbc4dab16edaaeda5ebcf5e" } half = "2" exr = { version = "1.73", default-features = false } eframe = { version = "0.37", default-features = false } @@ -64,28 +64,28 @@ rustix = { version = "1", default-features = false, features = ["std", "fs", "pr # Shared Craft egui components (widget palette, icon buttons, panel docking): storytold/craft-libs, # MIT OR Apache-2.0, pinned to one rev. # Shared catalog lookup, pinned with the other Craft libraries. -craft-i18n = { git = "https://github.com/storytold/craft-libs", rev = "16001e7210bee61db60c84fbe18c3c3e2ef4584f" } -craft-ui = { git = "https://github.com/storytold/craft-libs", rev = "16001e7210bee61db60c84fbe18c3c3e2ef4584f" } -craft-behavior = { git = "https://github.com/storytold/craft-libs", rev = "16001e7210bee61db60c84fbe18c3c3e2ef4584f" } -craft-materialx = { git = "https://github.com/storytold/craft-libs", rev = "16001e7210bee61db60c84fbe18c3c3e2ef4584f" } -craft-tcraft = { git = "https://github.com/storytold/craft-libs", rev = "16001e7210bee61db60c84fbe18c3c3e2ef4584f" } -craft-zip = { git = "https://github.com/storytold/craft-libs", rev = "16001e7210bee61db60c84fbe18c3c3e2ef4584f" } -craft-mesh = { git = "https://github.com/storytold/craft-libs", rev = "16001e7210bee61db60c84fbe18c3c3e2ef4584f", default-features = false, features = ["stl", "ply", "fbx", "obj", "gltf", "dae", "abc"] } -craft-mcmat = { git = "https://github.com/storytold/craft-libs", rev = "16001e7210bee61db60c84fbe18c3c3e2ef4584f" } +craft-i18n = { git = "https://github.com/storytold/craft-libs", rev = "d1bdf8e5dac7513e4fbc4dab16edaaeda5ebcf5e" } +craft-ui = { git = "https://github.com/storytold/craft-libs", rev = "d1bdf8e5dac7513e4fbc4dab16edaaeda5ebcf5e" } +craft-behavior = { git = "https://github.com/storytold/craft-libs", rev = "d1bdf8e5dac7513e4fbc4dab16edaaeda5ebcf5e" } +craft-materialx = { git = "https://github.com/storytold/craft-libs", rev = "d1bdf8e5dac7513e4fbc4dab16edaaeda5ebcf5e" } +craft-tcraft = { git = "https://github.com/storytold/craft-libs", rev = "d1bdf8e5dac7513e4fbc4dab16edaaeda5ebcf5e" } +craft-zip = { git = "https://github.com/storytold/craft-libs", rev = "d1bdf8e5dac7513e4fbc4dab16edaaeda5ebcf5e" } +craft-mesh = { git = "https://github.com/storytold/craft-libs", rev = "d1bdf8e5dac7513e4fbc4dab16edaaeda5ebcf5e", default-features = false, features = ["stl", "ply", "fbx", "obj", "gltf", "dae", "abc"] } +craft-mcmat = { git = "https://github.com/storytold/craft-libs", rev = "d1bdf8e5dac7513e4fbc4dab16edaaeda5ebcf5e" } # Who draws the window frame, and the app-drawn strip as the title bar (crates/ui-egui/src/titlebar.rs). -craft-window = { git = "https://github.com/storytold/craft-libs", rev = "16001e7210bee61db60c84fbe18c3c3e2ef4584f", features = ["ui"] } +craft-window = { git = "https://github.com/storytold/craft-libs", rev = "d1bdf8e5dac7513e4fbc4dab16edaaeda5ebcf5e", features = ["ui"] } # Release checks, the update prompt and the update helper (crates/ui-egui/src/updates_ui.rs). -craft-update = { git = "https://github.com/storytold/craft-libs", rev = "16001e7210bee61db60c84fbe18c3c3e2ef4584f", features = ["ui"] } +craft-update = { git = "https://github.com/storytold/craft-libs", rev = "d1bdf8e5dac7513e4fbc4dab16edaaeda5ebcf5e", features = ["ui"] } # File dialogs that never block the frame (crates/ui-egui/src/file_dialogs.rs). -craft-dialogs = { git = "https://github.com/storytold/craft-libs", rev = "16001e7210bee61db60c84fbe18c3c3e2ef4584f" } +craft-dialogs = { git = "https://github.com/storytold/craft-libs", rev = "d1bdf8e5dac7513e4fbc4dab16edaaeda5ebcf5e" } # Shortcut chords, lookup and dispatch (crates/ui-egui/src/keymap.rs). -craft-keymap = { git = "https://github.com/storytold/craft-libs", rev = "16001e7210bee61db60c84fbe18c3c3e2ef4584f", features = ["egui"] } +craft-keymap = { git = "https://github.com/storytold/craft-libs", rev = "d1bdf8e5dac7513e4fbc4dab16edaaeda5ebcf5e", features = ["egui"] } # The macOS app menu whose Quit asks about unsaved changes (apps/texturecraft/src/main.rs). -craft-menu = { git = "https://github.com/storytold/craft-libs", rev = "16001e7210bee61db60c84fbe18c3c3e2ef4584f" } +craft-menu = { git = "https://github.com/storytold/craft-libs", rev = "d1bdf8e5dac7513e4fbc4dab16edaaeda5ebcf5e" } # The UI runtime's host: who the app is to the framework's dialogs (crates/ui-egui/src/framework.rs). -craft-host = { git = "https://github.com/storytold/craft-libs", rev = "16001e7210bee61db60c84fbe18c3c3e2ef4584f" } +craft-host = { git = "https://github.com/storytold/craft-libs", rev = "d1bdf8e5dac7513e4fbc4dab16edaaeda5ebcf5e" } # The theme mode the app hands the runtime (crates/ui-egui/src/framework.rs). -craft-theme = { git = "https://github.com/storytold/craft-libs", rev = "16001e7210bee61db60c84fbe18c3c3e2ef4584f" } +craft-theme = { git = "https://github.com/storytold/craft-libs", rev = "d1bdf8e5dac7513e4fbc4dab16edaaeda5ebcf5e" } # egui 0.37 and winit: the suite's forks (storytold/egui, storytold/winit), as craft-libs pins them. [patch.crates-io] diff --git a/crates/formats/Cargo.toml b/crates/formats/Cargo.toml index 3d81e2c3..04f6bfc2 100644 --- a/crates/formats/Cargo.toml +++ b/crates/formats/Cargo.toml @@ -11,7 +11,7 @@ workspace = true [dependencies] craft-usd.workspace = true # ICC v2 serialization prerequisite: craft-libs#1735; app colour policy stays local. -craft-cms-icc-v2 = { package = "craft-cms", version = "0.1.0", git = "https://github.com/storytold/craft-libs", rev = "16001e7210bee61db60c84fbe18c3c3e2ef4584f" } +craft-cms-icc-v2 = { package = "craft-cms", version = "0.1.0", git = "https://github.com/storytold/craft-libs", rev = "d1bdf8e5dac7513e4fbc4dab16edaaeda5ebcf5e" } craft-materialx = { workspace = true } craft-mesh = { workspace = true } craft-mcmat = { workspace = true } @@ -25,7 +25,7 @@ image = { workspace = true } png = "0.18" bytemuck = { workspace = true, features = ["extern_crate_alloc"] } craft-image-codecs = { workspace = true } -craft-psd = { git = "https://github.com/storytold/craft-libs", rev = "16001e7210bee61db60c84fbe18c3c3e2ef4584f" } +craft-psd = { git = "https://github.com/storytold/craft-libs", rev = "d1bdf8e5dac7513e4fbc4dab16edaaeda5ebcf5e" } flate2 = { workspace = true } half = { workspace = true } quick-xml = { workspace = true } From 800adc7e90998febf2e4c55b3458c203debcc5cf Mon Sep 17 00:00:00 2001 From: aiongg Date: Wed, 25 Nov 2026 14:25:34 +0000 Subject: [PATCH 48/83] Keys typed in a floating panel's focused field run no shortcuts --- crates/ui-egui/src/docking.rs | 89 +++++++++++++++++++++++++++++++++-- 1 file changed, 84 insertions(+), 5 deletions(-) diff --git a/crates/ui-egui/src/docking.rs b/crates/ui-egui/src/docking.rs index 6d827113..ba544a05 100644 --- a/crates/ui-egui/src/docking.rs +++ b/crates/ui-egui/src/docking.rs @@ -16,7 +16,7 @@ use craft_behavior::flow::Axis; use craft_ui::contract::{Bind, BodyCx, PlainData, SizeLimits, Tracked}; use craft_ui::docking::{DockConfig, DockPanels, GroupAt, PanelSpec, PanelSpecs}; use craft_ui::patterns::dock::DockArea; -use egui::{Margin, Rect, Ui, Vec2, vec2}; +use egui::{Margin, Rect, Ui, Vec2, ViewportId, vec2}; use serde::{Deserialize, Serialize}; use serde_json::Value; @@ -485,14 +485,15 @@ pub fn show(app: &mut TextureCraftApp, ui: &mut Ui) { // Panels arrange in a split tree around the viewport; floating title bars only move windows. // Each closable tab has its close button, as each group header had one for its shown panel. let config = DockConfig::default().new_dock_zones(false).title_bar_docks(false).tab_close_buttons(true); - let output = { + let (output, focused_windows) = { let tokens = Tokens::get(&context); - let mut panels = Panels { app: &mut *app, tokens, layout: shown.layout().clone() }; + let mut panels = Panels { app: &mut *app, tokens, layout: shown.layout().clone(), focused_windows: Vec::new() }; let mut area = DockArea::new("Panels", Bind::given(Arc::clone(&shown)), &specs, &mut panels, config); if let Some(hand_over) = hand_over { area = area.continue_move(hand_over); } - area.show(ui) + let output = area.show(ui); + (output, panels.focused_windows) }; app.docks.specs = specs; @@ -502,9 +503,11 @@ pub fn show(app: &mut TextureCraftApp, ui: &mut Ui) { // Keys pressed in a panel floated into a window of its own run the app's shortcuts there #[cfg(not(target_arch = "wasm32"))] for (_, viewport) in &output.windows { - let (events, held) = context.input_for(*viewport, |input| (input.events.clone(), input.modifiers)); + let (events, held) = forwarded_events(&context, *viewport, &focused_windows); crate::menus::forwarded_shortcuts(app, &context, events, held); } + #[cfg(target_arch = "wasm32")] + let _ = focused_windows; if let Some(error) = &output.error { log::warn!("docking: {:?}", error.error); } @@ -520,12 +523,34 @@ pub fn show(app: &mut TextureCraftApp, ui: &mut Ui) { } } +/// Records in `focused_windows` whether a widget of the running pass's window has the keyboard, after one of the window's +/// panels drew +fn note_focus(context: &egui::Context, focused_windows: &mut Vec) { + let window = context.viewport_id(); + focused_windows.retain(|focused| *focused != window); + if context.memory(|memory| memory.focused().is_some()) { + focused_windows.push(window); + } +} + +/// The keys, text and clipboard events `window` hands to the app's shortcuts, with the modifiers held there: nothing +/// while one of its widgets has the keyboard +#[cfg(not(target_arch = "wasm32"))] +fn forwarded_events(context: &egui::Context, window: ViewportId, focused_windows: &[ViewportId]) -> (Vec, egui::Modifiers) { + use egui::Event; + let focused = focused_windows.contains(&window); + let forwarded = |event: &&Event| !focused && matches!(event, Event::Key { .. } | Event::Text(_) | Event::Copy | Event::Cut | Event::Paste(_)); + context.input_for(window, |input| (input.events.iter().filter(forwarded).cloned().collect(), input.modifiers)) +} + /// The panels' contents for the dock area struct Panels<'a> { app: &'a mut TextureCraftApp, tokens: Tokens, /// The arrangement the dock shows in this pass layout: Layout, + /// The windows in which a widget had the keyboard once their panels drew + focused_windows: Vec, } /// Room between a panel's edges and its contents @@ -597,6 +622,7 @@ impl DockPanels for Panels<'_> { if *panel != Panel::Viewport { panel_body(self.app, ui, *panel); } + note_focus(ui.ctx(), &mut self.focused_windows); } /// The viewport, edge to edge in its group. @@ -639,6 +665,59 @@ mod tests { w.layout().panels().into_iter().copied().collect() } + /// What a floating panel's own window with a text field, focused when `typing`, hands on of `events` + #[cfg(not(target_arch = "wasm32"))] + fn handed_on(typing: bool, events: &[egui::Event]) -> Vec { + use std::{cell::RefCell, rc::Rc}; + + let window = ViewportId::from_hash_of("floating panel"); + let context = egui::Context::default(); + context.set_embed_viewports(false); + + // Runs the window's pass inside its parent's, as eframe does + let arriving = Rc::new(RefCell::new(Vec::new())); + let queued = Rc::clone(&arriving); + egui::Context::set_immediate_viewport_renderer(move |context, viewport| { + let mut input = egui::RawInput { viewport_id: viewport.ids.this, events: queued.take(), ..Default::default() }; + input.viewports.insert(viewport.ids.this, egui::ViewportInfo { parent: Some(viewport.ids.parent), ..Default::default() }); + let mut output = context.run_ui(input, viewport.viewport_ui_cb); + output.textures_delta.clear(); + }); + + let mut name = String::new(); + let mut handed_on = Vec::new(); + // The field takes the keyboard a pass before the keys arrive + for arrived in [Vec::new(), events.to_vec()] { + *arriving.borrow_mut() = arrived; + let mut output = context.run_ui(egui::RawInput::default(), |ui| { + let mut focused_windows = Vec::new(); + ui.ctx().show_viewport_immediate(window, egui::ViewportBuilder::default(), |ui, _| { + let field = ui.text_edit_singleline(&mut name); + if typing { + field.request_focus(); + } + note_focus(ui.ctx(), &mut focused_windows); + }); + handed_on.extend(forwarded_events(ui.ctx(), window, &focused_windows).0); + }); + output.textures_delta.clear(); + } + + assert_eq!(name.is_empty(), !typing, "a focused field types the text"); + handed_on + } + + #[cfg(not(target_arch = "wasm32"))] + #[test] + fn a_floating_panel_hands_on_its_keys_unless_a_field_there_has_the_keyboard() { + use egui::{Event, Key, Modifiers}; + + let key = Event::Key { key: Key::B, physical_key: Some(Key::B), pressed: true, repeat: false, modifiers: Modifiers::NONE }; + let keys = [key, Event::Text("b".into()), Event::Paste("pasted".into())]; + assert!(handed_on(true, &keys).is_empty(), "the field's keys are its own"); + assert_eq!(handed_on(false, &keys), keys, "with nothing focused they are the app's"); + } + #[test] fn default_workspace_has_every_panel_and_is_valid() { let workspace = default_workspace(); From cb77c86d81e253fb41b5574b2c0c0d7c5e96702a Mon Sep 17 00:00:00 2001 From: aiongg Date: Wed, 25 Nov 2026 14:43:32 +0000 Subject: [PATCH 49/83] Test builds compile the TLS, dialog and screen capture crates at opt-level 0 --- .cargo/config.toml | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/.cargo/config.toml b/.cargo/config.toml index a60c91e5..e65ef03e 100644 --- a/.cargo/config.toml +++ b/.cargo/config.toml @@ -70,3 +70,33 @@ opt-level = 0 [profile.test.package.texturecraft-ui-egui] opt-level = 0 + +# The TLS stack and the dialog, browser and screen capture crates: no test makes a TLS connection, opens a file dialog or +# captures the screen, so their optimized builds only cost test build time. + +[profile.test.package.ring] +opt-level = 0 + +[profile.test.package.rustls] +opt-level = 0 + +[profile.test.package.rustls-webpki] +opt-level = 0 + +[profile.test.package.rustls-platform-verifier] +opt-level = 0 + +[profile.test.package.ureq] +opt-level = 0 + +[profile.test.package.ureq-proto] +opt-level = 0 + +[profile.test.package.webbrowser] +opt-level = 0 + +[profile.test.package.rfd] +opt-level = 0 + +[profile.test.package.xcap] +opt-level = 0 From 0baab2e46e8d2c551aae3ec5086b354c2d2649a4 Mon Sep 17 00:00:00 2001 From: aiongg Date: Wed, 25 Nov 2026 15:12:06 +0000 Subject: [PATCH 50/83] Copy, Cut and Paste pressed in a floating panel reach the app --- crates/ui-egui/src/framework.rs | 55 ++++++++++++++++++++++++++++++++- crates/ui-egui/src/lib.rs | 11 +++++++ crates/ui-egui/src/menus.rs | 23 ++++++++------ 3 files changed, 79 insertions(+), 10 deletions(-) diff --git a/crates/ui-egui/src/framework.rs b/crates/ui-egui/src/framework.rs index 78637b68..e7509a6b 100644 --- a/crates/ui-egui/src/framework.rs +++ b/crates/ui-egui/src/framework.rs @@ -17,7 +17,7 @@ use craft_host::target::ShellInfo; use craft_host::{AppInfo, Host}; use craft_keymap::Overrides; use craft_ui::fonts::{I18nScripts, SystemFonts, UiFonts}; -use craft_ui::runtime::commands::{ChromeCommand, CommandInput, CommandSet as _, NavCommand, QuitCommand}; +use craft_ui::runtime::commands::{ChromeCommand, CommandInput, CommandSet as _, EditCommands, NavCommand, QuitCommand}; use craft_ui::runtime::env::{RootEnv, Scale}; use craft_ui::runtime::focus::{EditSet, KeyUse}; use craft_ui::runtime::frame::{ChromeToggle, FrameInput, FrameOutput}; @@ -116,6 +116,8 @@ impl TextureCraftApp { self.ui.hide_ui = !self.ui.hide_ui; } } + #[cfg(not(target_arch = "wasm32"))] + self.fired_clipboard.extend(clipboard_events(&output)); use crate::theme::Brightness; let mode = match self.ui.prefs.brightness { Brightness::Light | Brightness::MediumLight => craft_theme::Mode::Light, @@ -135,6 +137,20 @@ impl TextureCraftApp { } } +/// The Copy, Cut and Paste events the runtime took from windows with no canvas of their own (a floating panel) and ran as +/// its `edit.copy`, `edit.cut` and `edit.paste`: the clipboard events TextureCraft's shortcuts read in the root window. +/// The other edit commands are not read here: TextureCraft's own loop still forwards their keys. +#[cfg(not(target_arch = "wasm32"))] +fn clipboard_events(output: &FrameOutput) -> impl Iterator + '_ { + output.fired.iter().filter_map(|fired| match EditCommands::from_ref(&fired.command)? { + EditCommands::Copy => Some(egui::Event::Copy), + EditCommands::Cut => Some(egui::Event::Cut), + // The layer paste takes no content from the event; the shortcut only needs the paste chord. + EditCommands::Paste => Some(egui::Event::Paste(String::new())), + _ => None, + }) +} + /// Declares the view `id`, an egui widget drawn in this pass, as a document canvas of the window. With nothing or the /// view focused, the edit chords and the clipboard events stay in egui's input for TextureCraft's shortcuts, and a bare /// Tab is the runtime's chrome toggle (`frame_input`). Tab and Shift+Tab stop at the view, Shift+Tab moves on from it, @@ -187,3 +203,40 @@ fn window_intent(ctx: &egui::Context, intent: Intent, take: bool) -> bool { }); pending } + +#[cfg(all(test, not(target_arch = "wasm32")))] +mod tests { + use super::*; + use craft_ui::runtime::commands::{FirePhase, FireSource, Fired}; + use egui_kittest::Harness; + + fn fired(command: EditCommands) -> Fired { + Fired::new(command.into(), FireSource::Key, FirePhase::Press, 0.0) + } + + /// With nothing focused in a floating panel, the runtime runs the chord as `edit.copy` and takes the clipboard event + /// from egui's input, so TextureCraft's own loop never sees it: the fired command reaches the layer clipboard once. + #[test] + fn fired_copy_and_paste_from_a_float_reach_the_layer_clipboard_once() { + let session = texturecraft_engine::sample_session(256, 64).unwrap(); + let mut h = + Harness::builder().with_size(egui::vec2(1600.0, 960.0)).with_context_setup(install_headless).build_eframe(|cc| TextureCraftApp::new(cc, session)); + h.run_steps(4); + let ctx = h.ctx.clone(); + let layers = |h: &Harness<'_, TextureCraftApp>| h.state().session.doc.project.layers.len(); + let before = layers(&h); + + let mut output = FrameOutput::default(); + output.fired.push(fired(EditCommands::Copy)); + h.state_mut().frame_input(&ctx, output, 1.0); + h.run_steps(3); + assert!(h.state().session.clipboard.is_some(), "the fired Copy copied the layer"); + assert_eq!(layers(&h), before); + + let mut output = FrameOutput::default(); + output.fired.push(fired(EditCommands::Paste)); + h.state_mut().frame_input(&ctx, output, 1.0); + h.run_steps(3); + assert_eq!(layers(&h), before + 1, "the fired Paste pasted the layer once"); + } +} diff --git a/crates/ui-egui/src/lib.rs b/crates/ui-egui/src/lib.rs index 844a8b36..0d95cd54 100644 --- a/crates/ui-egui/src/lib.rs +++ b/crates/ui-egui/src/lib.rs @@ -320,6 +320,10 @@ pub struct TextureCraftApp { pub framework_dialogs: craft_ui::dialog::DialogHost, /// Who TextureCraft is to the framework's dialogs. pub(crate) framework_host: std::sync::Arc, + /// The Copy, Cut and Paste the runtime took from a floating panel's window (`framework::clipboard_events`), for the + /// shortcuts of the next `logic`. + #[cfg(not(target_arch = "wasm32"))] + fired_clipboard: Vec, last_time: f64, /// When the next autosave is due (seconds of app time; desktop only). #[cfg_attr(target_arch = "wasm32", allow(dead_code))] @@ -448,6 +452,8 @@ impl TextureCraftApp { docks: docking::LiveDock::default(), framework_dialogs: craft_ui::dialog::DialogHost::new(), framework_host: framework::host(), + #[cfg(not(target_arch = "wasm32"))] + fired_clipboard: Vec::new(), last_time: 0.0, next_autosave, styled: None, @@ -1153,6 +1159,11 @@ impl eframe::App for TextureCraftApp { self.bindings.sync(&self.ui.keymap, craft_keymap::egui::platform(ctx)); menus::shortcuts(self, ctx); + #[cfg(not(target_arch = "wasm32"))] + { + let events = std::mem::take(&mut self.fired_clipboard); + menus::forwarded_shortcuts(self, ctx, events, egui::Modifiers::NONE); + } screen_pick::sync(self, ctx); move_on_model::end_when_gone(self, ctx); diff --git a/crates/ui-egui/src/menus.rs b/crates/ui-egui/src/menus.rs index b2282360..3e7c3f76 100644 --- a/crates/ui-egui/src/menus.rs +++ b/crates/ui-egui/src/menus.rs @@ -414,7 +414,7 @@ pub fn forwarded_shortcuts(app: &mut TextureCraftApp, ctx: &egui::Context, event continue; } let Some(id) = app.bindings.command_of(&event) else { continue }; - invoke(app, ctx, effect_command(app, &id)); + run_shortcut(app, ctx, &id); } } @@ -555,17 +555,22 @@ pub fn shortcuts(app: &mut TextureCraftApp, ctx: &egui::Context) { }); for id in &commands_to_invoke { - if matches!(id.as_str(), "layer.copy" | "layer.cut") - && let Some(layer) = app.session.selected_layer().and_then(|layer| app.session.doc.project.layers.get(&layer)) - { - // Ctrl+V reaches the app only while the system clipboard holds text or an image - ctx.copy_text(layer.name.clone()); - } - - invoke(app, ctx, effect_command(app, id)); + run_shortcut(app, ctx, id); } } +/// Runs the command a shortcut is bound to. A layer copy or cut also puts the layer's name on the system clipboard: +/// Ctrl+V reaches the app only while that clipboard holds text or an image. +fn run_shortcut(app: &mut TextureCraftApp, ctx: &egui::Context, id: &str) { + if matches!(id, "layer.copy" | "layer.cut") + && let Some(layer) = app.session.selected_layer().and_then(|layer| app.session.doc.project.layers.get(&layer)) + { + ctx.copy_text(layer.name.clone()); + } + + invoke(app, ctx, effect_command(app, id)); +} + /// The desktop and web shells turn Ctrl+C, Ctrl+X and Ctrl+V (and Ctrl+Insert, Shift+Delete, /// Shift+Insert) into clipboard events instead of key presses. Outside a text field they are the /// shortcuts bound to Ctrl+C, Ctrl+X and Ctrl+V (copy, cut and paste a layer by default). From 8af1bf8456e026d30b08fcd2d40dca0e8e15642c Mon Sep 17 00:00:00 2001 From: aiongg Date: Wed, 25 Nov 2026 15:52:23 +0000 Subject: [PATCH 51/83] Repin craft-libs to storytold next aa401985d --- Cargo.lock | 90 +++++++++++++++++++-------------------- Cargo.toml | 34 +++++++-------- crates/formats/Cargo.toml | 4 +- 3 files changed, 64 insertions(+), 64 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 0f8bb202..2518e0c8 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -953,7 +953,7 @@ dependencies = [ [[package]] name = "craft-appkit" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=d1bdf8e5dac7513e4fbc4dab16edaaeda5ebcf5e#d1bdf8e5dac7513e4fbc4dab16edaaeda5ebcf5e" +source = "git+https://github.com/storytold/craft-libs?rev=aa401985dd4658cdaa272fdccafdcd6e7f4dd60b#aa401985dd4658cdaa272fdccafdcd6e7f4dd60b" dependencies = [ "block2 0.6.2", "objc2-app-kit 0.3.2", @@ -963,7 +963,7 @@ dependencies = [ [[package]] name = "craft-atomic" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=d1bdf8e5dac7513e4fbc4dab16edaaeda5ebcf5e#d1bdf8e5dac7513e4fbc4dab16edaaeda5ebcf5e" +source = "git+https://github.com/storytold/craft-libs?rev=aa401985dd4658cdaa272fdccafdcd6e7f4dd60b#aa401985dd4658cdaa272fdccafdcd6e7f4dd60b" dependencies = [ "rustix 1.1.6", ] @@ -971,7 +971,7 @@ dependencies = [ [[package]] name = "craft-behavior" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=d1bdf8e5dac7513e4fbc4dab16edaaeda5ebcf5e#d1bdf8e5dac7513e4fbc4dab16edaaeda5ebcf5e" +source = "git+https://github.com/storytold/craft-libs?rev=aa401985dd4658cdaa272fdccafdcd6e7f4dd60b#aa401985dd4658cdaa272fdccafdcd6e7f4dd60b" dependencies = [ "accesskit", "bitflags 2.13.2", @@ -989,7 +989,7 @@ dependencies = [ [[package]] name = "craft-cloud-ui" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=d1bdf8e5dac7513e4fbc4dab16edaaeda5ebcf5e#d1bdf8e5dac7513e4fbc4dab16edaaeda5ebcf5e" +source = "git+https://github.com/storytold/craft-libs?rev=aa401985dd4658cdaa272fdccafdcd6e7f4dd60b#aa401985dd4658cdaa272fdccafdcd6e7f4dd60b" dependencies = [ "egui", ] @@ -997,7 +997,7 @@ dependencies = [ [[package]] name = "craft-cms" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=d1bdf8e5dac7513e4fbc4dab16edaaeda5ebcf5e#d1bdf8e5dac7513e4fbc4dab16edaaeda5ebcf5e" +source = "git+https://github.com/storytold/craft-libs?rev=aa401985dd4658cdaa272fdccafdcd6e7f4dd60b#aa401985dd4658cdaa272fdccafdcd6e7f4dd60b" dependencies = [ "md-5", "rayon", @@ -1006,12 +1006,12 @@ dependencies = [ [[package]] name = "craft-codepage" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=d1bdf8e5dac7513e4fbc4dab16edaaeda5ebcf5e#d1bdf8e5dac7513e4fbc4dab16edaaeda5ebcf5e" +source = "git+https://github.com/storytold/craft-libs?rev=aa401985dd4658cdaa272fdccafdcd6e7f4dd60b#aa401985dd4658cdaa272fdccafdcd6e7f4dd60b" [[package]] name = "craft-dds" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=d1bdf8e5dac7513e4fbc4dab16edaaeda5ebcf5e#d1bdf8e5dac7513e4fbc4dab16edaaeda5ebcf5e" +source = "git+https://github.com/storytold/craft-libs?rev=aa401985dd4658cdaa272fdccafdcd6e7f4dd60b#aa401985dd4658cdaa272fdccafdcd6e7f4dd60b" dependencies = [ "rayon", ] @@ -1019,7 +1019,7 @@ dependencies = [ [[package]] name = "craft-dialogs" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=d1bdf8e5dac7513e4fbc4dab16edaaeda5ebcf5e#d1bdf8e5dac7513e4fbc4dab16edaaeda5ebcf5e" +source = "git+https://github.com/storytold/craft-libs?rev=aa401985dd4658cdaa272fdccafdcd6e7f4dd60b#aa401985dd4658cdaa272fdccafdcd6e7f4dd60b" dependencies = [ "block2 0.6.2", "craft-atomic", @@ -1039,7 +1039,7 @@ dependencies = [ [[package]] name = "craft-docpath" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=d1bdf8e5dac7513e4fbc4dab16edaaeda5ebcf5e#d1bdf8e5dac7513e4fbc4dab16edaaeda5ebcf5e" +source = "git+https://github.com/storytold/craft-libs?rev=aa401985dd4658cdaa272fdccafdcd6e7f4dd60b#aa401985dd4658cdaa272fdccafdcd6e7f4dd60b" dependencies = [ "serde", ] @@ -1047,7 +1047,7 @@ dependencies = [ [[package]] name = "craft-font-catalog" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=d1bdf8e5dac7513e4fbc4dab16edaaeda5ebcf5e#d1bdf8e5dac7513e4fbc4dab16edaaeda5ebcf5e" +source = "git+https://github.com/storytold/craft-libs?rev=aa401985dd4658cdaa272fdccafdcd6e7f4dd60b#aa401985dd4658cdaa272fdccafdcd6e7f4dd60b" dependencies = [ "harfrust 0.13.3", "kurbo", @@ -1061,12 +1061,12 @@ dependencies = [ [[package]] name = "craft-fonts-build" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=d1bdf8e5dac7513e4fbc4dab16edaaeda5ebcf5e#d1bdf8e5dac7513e4fbc4dab16edaaeda5ebcf5e" +source = "git+https://github.com/storytold/craft-libs?rev=aa401985dd4658cdaa272fdccafdcd6e7f4dd60b#aa401985dd4658cdaa272fdccafdcd6e7f4dd60b" [[package]] name = "craft-host" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=d1bdf8e5dac7513e4fbc4dab16edaaeda5ebcf5e#d1bdf8e5dac7513e4fbc4dab16edaaeda5ebcf5e" +source = "git+https://github.com/storytold/craft-libs?rev=aa401985dd4658cdaa272fdccafdcd6e7f4dd60b#aa401985dd4658cdaa272fdccafdcd6e7f4dd60b" dependencies = [ "bitflags 2.13.2", "craft-i18n", @@ -1079,7 +1079,7 @@ dependencies = [ [[package]] name = "craft-i18n" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=d1bdf8e5dac7513e4fbc4dab16edaaeda5ebcf5e#d1bdf8e5dac7513e4fbc4dab16edaaeda5ebcf5e" +source = "git+https://github.com/storytold/craft-libs?rev=aa401985dd4658cdaa272fdccafdcd6e7f4dd60b#aa401985dd4658cdaa272fdccafdcd6e7f4dd60b" dependencies = [ "chrono", "fixed_decimal", @@ -1107,7 +1107,7 @@ dependencies = [ [[package]] name = "craft-image-codecs" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=d1bdf8e5dac7513e4fbc4dab16edaaeda5ebcf5e#d1bdf8e5dac7513e4fbc4dab16edaaeda5ebcf5e" +source = "git+https://github.com/storytold/craft-libs?rev=aa401985dd4658cdaa272fdccafdcd6e7f4dd60b#aa401985dd4658cdaa272fdccafdcd6e7f4dd60b" dependencies = [ "craft-dds", "craft-jpeg", @@ -1134,7 +1134,7 @@ dependencies = [ [[package]] name = "craft-jpeg" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=d1bdf8e5dac7513e4fbc4dab16edaaeda5ebcf5e#d1bdf8e5dac7513e4fbc4dab16edaaeda5ebcf5e" +source = "git+https://github.com/storytold/craft-libs?rev=aa401985dd4658cdaa272fdccafdcd6e7f4dd60b#aa401985dd4658cdaa272fdccafdcd6e7f4dd60b" dependencies = [ "thiserror 2.0.21", ] @@ -1142,7 +1142,7 @@ dependencies = [ [[package]] name = "craft-keymap" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=d1bdf8e5dac7513e4fbc4dab16edaaeda5ebcf5e#d1bdf8e5dac7513e4fbc4dab16edaaeda5ebcf5e" +source = "git+https://github.com/storytold/craft-libs?rev=aa401985dd4658cdaa272fdccafdcd6e7f4dd60b#aa401985dd4658cdaa272fdccafdcd6e7f4dd60b" dependencies = [ "craft-host", "craft-i18n", @@ -1157,7 +1157,7 @@ dependencies = [ [[package]] name = "craft-materialx" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=d1bdf8e5dac7513e4fbc4dab16edaaeda5ebcf5e#d1bdf8e5dac7513e4fbc4dab16edaaeda5ebcf5e" +source = "git+https://github.com/storytold/craft-libs?rev=aa401985dd4658cdaa272fdccafdcd6e7f4dd60b#aa401985dd4658cdaa272fdccafdcd6e7f4dd60b" dependencies = [ "craft-xml", "thiserror 2.0.21", @@ -1166,7 +1166,7 @@ dependencies = [ [[package]] name = "craft-mcmat" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=d1bdf8e5dac7513e4fbc4dab16edaaeda5ebcf5e#d1bdf8e5dac7513e4fbc4dab16edaaeda5ebcf5e" +source = "git+https://github.com/storytold/craft-libs?rev=aa401985dd4658cdaa272fdccafdcd6e7f4dd60b#aa401985dd4658cdaa272fdccafdcd6e7f4dd60b" dependencies = [ "craft-zip", "serde", @@ -1177,7 +1177,7 @@ dependencies = [ [[package]] name = "craft-menu" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=d1bdf8e5dac7513e4fbc4dab16edaaeda5ebcf5e#d1bdf8e5dac7513e4fbc4dab16edaaeda5ebcf5e" +source = "git+https://github.com/storytold/craft-libs?rev=aa401985dd4658cdaa272fdccafdcd6e7f4dd60b#aa401985dd4658cdaa272fdccafdcd6e7f4dd60b" dependencies = [ "craft-behavior", "craft-host", @@ -1195,7 +1195,7 @@ dependencies = [ [[package]] name = "craft-mesh" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=d1bdf8e5dac7513e4fbc4dab16edaaeda5ebcf5e#d1bdf8e5dac7513e4fbc4dab16edaaeda5ebcf5e" +source = "git+https://github.com/storytold/craft-libs?rev=aa401985dd4658cdaa272fdccafdcd6e7f4dd60b#aa401985dd4658cdaa272fdccafdcd6e7f4dd60b" dependencies = [ "craft-xml", "craft-zip", @@ -1206,7 +1206,7 @@ dependencies = [ [[package]] name = "craft-metadata" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=d1bdf8e5dac7513e4fbc4dab16edaaeda5ebcf5e#d1bdf8e5dac7513e4fbc4dab16edaaeda5ebcf5e" +source = "git+https://github.com/storytold/craft-libs?rev=aa401985dd4658cdaa272fdccafdcd6e7f4dd60b#aa401985dd4658cdaa272fdccafdcd6e7f4dd60b" dependencies = [ "brotli-decompressor", "chrono", @@ -1218,7 +1218,7 @@ dependencies = [ [[package]] name = "craft-pdf" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=d1bdf8e5dac7513e4fbc4dab16edaaeda5ebcf5e#d1bdf8e5dac7513e4fbc4dab16edaaeda5ebcf5e" +source = "git+https://github.com/storytold/craft-libs?rev=aa401985dd4658cdaa272fdccafdcd6e7f4dd60b#aa401985dd4658cdaa272fdccafdcd6e7f4dd60b" dependencies = [ "serde", ] @@ -1226,7 +1226,7 @@ dependencies = [ [[package]] name = "craft-platform" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=d1bdf8e5dac7513e4fbc4dab16edaaeda5ebcf5e#d1bdf8e5dac7513e4fbc4dab16edaaeda5ebcf5e" +source = "git+https://github.com/storytold/craft-libs?rev=aa401985dd4658cdaa272fdccafdcd6e7f4dd60b#aa401985dd4658cdaa272fdccafdcd6e7f4dd60b" dependencies = [ "async-channel", "async-io", @@ -1257,7 +1257,7 @@ dependencies = [ [[package]] name = "craft-psd" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=d1bdf8e5dac7513e4fbc4dab16edaaeda5ebcf5e#d1bdf8e5dac7513e4fbc4dab16edaaeda5ebcf5e" +source = "git+https://github.com/storytold/craft-libs?rev=aa401985dd4658cdaa272fdccafdcd6e7f4dd60b#aa401985dd4658cdaa272fdccafdcd6e7f4dd60b" dependencies = [ "encoding_rs", "flate2", @@ -1268,7 +1268,7 @@ dependencies = [ [[package]] name = "craft-quit" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=d1bdf8e5dac7513e4fbc4dab16edaaeda5ebcf5e#d1bdf8e5dac7513e4fbc4dab16edaaeda5ebcf5e" +source = "git+https://github.com/storytold/craft-libs?rev=aa401985dd4658cdaa272fdccafdcd6e7f4dd60b#aa401985dd4658cdaa272fdccafdcd6e7f4dd60b" dependencies = [ "dispatch2", "egui", @@ -1281,7 +1281,7 @@ dependencies = [ [[package]] name = "craft-settings" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=d1bdf8e5dac7513e4fbc4dab16edaaeda5ebcf5e#d1bdf8e5dac7513e4fbc4dab16edaaeda5ebcf5e" +source = "git+https://github.com/storytold/craft-libs?rev=aa401985dd4658cdaa272fdccafdcd6e7f4dd60b#aa401985dd4658cdaa272fdccafdcd6e7f4dd60b" dependencies = [ "craft-atomic", "craft-host", @@ -1298,7 +1298,7 @@ dependencies = [ [[package]] name = "craft-svg" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=d1bdf8e5dac7513e4fbc4dab16edaaeda5ebcf5e#d1bdf8e5dac7513e4fbc4dab16edaaeda5ebcf5e" +source = "git+https://github.com/storytold/craft-libs?rev=aa401985dd4658cdaa272fdccafdcd6e7f4dd60b#aa401985dd4658cdaa272fdccafdcd6e7f4dd60b" dependencies = [ "craft-xml", "flate2", @@ -1315,7 +1315,7 @@ dependencies = [ [[package]] name = "craft-tcraft" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=d1bdf8e5dac7513e4fbc4dab16edaaeda5ebcf5e#d1bdf8e5dac7513e4fbc4dab16edaaeda5ebcf5e" +source = "git+https://github.com/storytold/craft-libs?rev=aa401985dd4658cdaa272fdccafdcd6e7f4dd60b#aa401985dd4658cdaa272fdccafdcd6e7f4dd60b" dependencies = [ "craft-zip", "serde", @@ -1326,7 +1326,7 @@ dependencies = [ [[package]] name = "craft-theme" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=d1bdf8e5dac7513e4fbc4dab16edaaeda5ebcf5e#d1bdf8e5dac7513e4fbc4dab16edaaeda5ebcf5e" +source = "git+https://github.com/storytold/craft-libs?rev=aa401985dd4658cdaa272fdccafdcd6e7f4dd60b#aa401985dd4658cdaa272fdccafdcd6e7f4dd60b" dependencies = [ "bitflags 2.13.2", "craft-tracked", @@ -1341,7 +1341,7 @@ dependencies = [ [[package]] name = "craft-tiff" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=d1bdf8e5dac7513e4fbc4dab16edaaeda5ebcf5e#d1bdf8e5dac7513e4fbc4dab16edaaeda5ebcf5e" +source = "git+https://github.com/storytold/craft-libs?rev=aa401985dd4658cdaa272fdccafdcd6e7f4dd60b#aa401985dd4658cdaa272fdccafdcd6e7f4dd60b" dependencies = [ "serde", "thiserror 2.0.21", @@ -1351,12 +1351,12 @@ dependencies = [ [[package]] name = "craft-tracked" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=d1bdf8e5dac7513e4fbc4dab16edaaeda5ebcf5e#d1bdf8e5dac7513e4fbc4dab16edaaeda5ebcf5e" +source = "git+https://github.com/storytold/craft-libs?rev=aa401985dd4658cdaa272fdccafdcd6e7f4dd60b#aa401985dd4658cdaa272fdccafdcd6e7f4dd60b" [[package]] name = "craft-ui" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=d1bdf8e5dac7513e4fbc4dab16edaaeda5ebcf5e#d1bdf8e5dac7513e4fbc4dab16edaaeda5ebcf5e" +source = "git+https://github.com/storytold/craft-libs?rev=aa401985dd4658cdaa272fdccafdcd6e7f4dd60b#aa401985dd4658cdaa272fdccafdcd6e7f4dd60b" dependencies = [ "craft-cloud-ui", "craft-ui-canvas", @@ -1370,7 +1370,7 @@ dependencies = [ [[package]] name = "craft-ui-canvas" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=d1bdf8e5dac7513e4fbc4dab16edaaeda5ebcf5e#d1bdf8e5dac7513e4fbc4dab16edaaeda5ebcf5e" +source = "git+https://github.com/storytold/craft-libs?rev=aa401985dd4658cdaa272fdccafdcd6e7f4dd60b#aa401985dd4658cdaa272fdccafdcd6e7f4dd60b" dependencies = [ "craft-behavior", "craft-i18n", @@ -1386,7 +1386,7 @@ dependencies = [ [[package]] name = "craft-ui-contract" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=d1bdf8e5dac7513e4fbc4dab16edaaeda5ebcf5e#d1bdf8e5dac7513e4fbc4dab16edaaeda5ebcf5e" +source = "git+https://github.com/storytold/craft-libs?rev=aa401985dd4658cdaa272fdccafdcd6e7f4dd60b#aa401985dd4658cdaa272fdccafdcd6e7f4dd60b" dependencies = [ "accesskit", "craft-behavior", @@ -1424,7 +1424,7 @@ dependencies = [ [[package]] name = "craft-ui-macros" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=d1bdf8e5dac7513e4fbc4dab16edaaeda5ebcf5e#d1bdf8e5dac7513e4fbc4dab16edaaeda5ebcf5e" +source = "git+https://github.com/storytold/craft-libs?rev=aa401985dd4658cdaa272fdccafdcd6e7f4dd60b#aa401985dd4658cdaa272fdccafdcd6e7f4dd60b" dependencies = [ "proc-macro-crate", "proc-macro2", @@ -1435,7 +1435,7 @@ dependencies = [ [[package]] name = "craft-ui-panels" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=d1bdf8e5dac7513e4fbc4dab16edaaeda5ebcf5e#d1bdf8e5dac7513e4fbc4dab16edaaeda5ebcf5e" +source = "git+https://github.com/storytold/craft-libs?rev=aa401985dd4658cdaa272fdccafdcd6e7f4dd60b#aa401985dd4658cdaa272fdccafdcd6e7f4dd60b" dependencies = [ "craft-behavior", "craft-host", @@ -1453,7 +1453,7 @@ dependencies = [ [[package]] name = "craft-ui-patterns" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=d1bdf8e5dac7513e4fbc4dab16edaaeda5ebcf5e#d1bdf8e5dac7513e4fbc4dab16edaaeda5ebcf5e" +source = "git+https://github.com/storytold/craft-libs?rev=aa401985dd4658cdaa272fdccafdcd6e7f4dd60b#aa401985dd4658cdaa272fdccafdcd6e7f4dd60b" dependencies = [ "craft-behavior", "craft-host", @@ -1474,7 +1474,7 @@ dependencies = [ [[package]] name = "craft-ui-shell" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=d1bdf8e5dac7513e4fbc4dab16edaaeda5ebcf5e#d1bdf8e5dac7513e4fbc4dab16edaaeda5ebcf5e" +source = "git+https://github.com/storytold/craft-libs?rev=aa401985dd4658cdaa272fdccafdcd6e7f4dd60b#aa401985dd4658cdaa272fdccafdcd6e7f4dd60b" dependencies = [ "craft-behavior", "craft-host", @@ -1494,7 +1494,7 @@ dependencies = [ [[package]] name = "craft-ui-widgets" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=d1bdf8e5dac7513e4fbc4dab16edaaeda5ebcf5e#d1bdf8e5dac7513e4fbc4dab16edaaeda5ebcf5e" +source = "git+https://github.com/storytold/craft-libs?rev=aa401985dd4658cdaa272fdccafdcd6e7f4dd60b#aa401985dd4658cdaa272fdccafdcd6e7f4dd60b" dependencies = [ "craft-behavior", "craft-host", @@ -1513,7 +1513,7 @@ dependencies = [ [[package]] name = "craft-update" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=d1bdf8e5dac7513e4fbc4dab16edaaeda5ebcf5e#d1bdf8e5dac7513e4fbc4dab16edaaeda5ebcf5e" +source = "git+https://github.com/storytold/craft-libs?rev=aa401985dd4658cdaa272fdccafdcd6e7f4dd60b#aa401985dd4658cdaa272fdccafdcd6e7f4dd60b" dependencies = [ "chrono", "craft-host", @@ -1542,7 +1542,7 @@ dependencies = [ [[package]] name = "craft-usd" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=d1bdf8e5dac7513e4fbc4dab16edaaeda5ebcf5e#d1bdf8e5dac7513e4fbc4dab16edaaeda5ebcf5e" +source = "git+https://github.com/storytold/craft-libs?rev=aa401985dd4658cdaa272fdccafdcd6e7f4dd60b#aa401985dd4658cdaa272fdccafdcd6e7f4dd60b" dependencies = [ "half", "lz4_flex", @@ -1552,7 +1552,7 @@ dependencies = [ [[package]] name = "craft-win32" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=d1bdf8e5dac7513e4fbc4dab16edaaeda5ebcf5e#d1bdf8e5dac7513e4fbc4dab16edaaeda5ebcf5e" +source = "git+https://github.com/storytold/craft-libs?rev=aa401985dd4658cdaa272fdccafdcd6e7f4dd60b#aa401985dd4658cdaa272fdccafdcd6e7f4dd60b" dependencies = [ "winsafe", ] @@ -1560,7 +1560,7 @@ dependencies = [ [[package]] name = "craft-window" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=d1bdf8e5dac7513e4fbc4dab16edaaeda5ebcf5e#d1bdf8e5dac7513e4fbc4dab16edaaeda5ebcf5e" +source = "git+https://github.com/storytold/craft-libs?rev=aa401985dd4658cdaa272fdccafdcd6e7f4dd60b#aa401985dd4658cdaa272fdccafdcd6e7f4dd60b" dependencies = [ "craft-appkit", "craft-atomic", @@ -1584,7 +1584,7 @@ dependencies = [ [[package]] name = "craft-xml" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=d1bdf8e5dac7513e4fbc4dab16edaaeda5ebcf5e#d1bdf8e5dac7513e4fbc4dab16edaaeda5ebcf5e" +source = "git+https://github.com/storytold/craft-libs?rev=aa401985dd4658cdaa272fdccafdcd6e7f4dd60b#aa401985dd4658cdaa272fdccafdcd6e7f4dd60b" dependencies = [ "quick-xml 0.41.0", "serde", @@ -1594,7 +1594,7 @@ dependencies = [ [[package]] name = "craft-zip" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=d1bdf8e5dac7513e4fbc4dab16edaaeda5ebcf5e#d1bdf8e5dac7513e4fbc4dab16edaaeda5ebcf5e" +source = "git+https://github.com/storytold/craft-libs?rev=aa401985dd4658cdaa272fdccafdcd6e7f4dd60b#aa401985dd4658cdaa272fdccafdcd6e7f4dd60b" dependencies = [ "flate2", "thiserror 2.0.21", diff --git a/Cargo.toml b/Cargo.toml index fd01e74b..b054d968 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -10,7 +10,7 @@ edition = "2024" license = "MIT OR Apache-2.0" [workspace.dependencies] -craft-usd = { version = "0.1.0", git = "https://github.com/storytold/craft-libs", rev = "d1bdf8e5dac7513e4fbc4dab16edaaeda5ebcf5e" } +craft-usd = { version = "0.1.0", git = "https://github.com/storytold/craft-libs", rev = "aa401985dd4658cdaa272fdccafdcd6e7f4dd60b" } # internal texturecraft-core = { path = "crates/core" } texturecraft-texel = { path = "crates/texel" } @@ -41,7 +41,7 @@ skrifa = { version = "0.44", default-features = false, features = ["std"] } epaint_default_fonts = "0.37" log = "0.4" image = { version = "0.25", default-features = false, features = ["png", "jpeg", "tga", "tiff", "exr", "hdr", "bmp", "webp"] } -craft-image-codecs = { git = "https://github.com/storytold/craft-libs", rev = "d1bdf8e5dac7513e4fbc4dab16edaaeda5ebcf5e" } +craft-image-codecs = { git = "https://github.com/storytold/craft-libs", rev = "aa401985dd4658cdaa272fdccafdcd6e7f4dd60b" } half = "2" exr = { version = "1.73", default-features = false } eframe = { version = "0.37", default-features = false } @@ -64,28 +64,28 @@ rustix = { version = "1", default-features = false, features = ["std", "fs", "pr # Shared Craft egui components (widget palette, icon buttons, panel docking): storytold/craft-libs, # MIT OR Apache-2.0, pinned to one rev. # Shared catalog lookup, pinned with the other Craft libraries. -craft-i18n = { git = "https://github.com/storytold/craft-libs", rev = "d1bdf8e5dac7513e4fbc4dab16edaaeda5ebcf5e" } -craft-ui = { git = "https://github.com/storytold/craft-libs", rev = "d1bdf8e5dac7513e4fbc4dab16edaaeda5ebcf5e" } -craft-behavior = { git = "https://github.com/storytold/craft-libs", rev = "d1bdf8e5dac7513e4fbc4dab16edaaeda5ebcf5e" } -craft-materialx = { git = "https://github.com/storytold/craft-libs", rev = "d1bdf8e5dac7513e4fbc4dab16edaaeda5ebcf5e" } -craft-tcraft = { git = "https://github.com/storytold/craft-libs", rev = "d1bdf8e5dac7513e4fbc4dab16edaaeda5ebcf5e" } -craft-zip = { git = "https://github.com/storytold/craft-libs", rev = "d1bdf8e5dac7513e4fbc4dab16edaaeda5ebcf5e" } -craft-mesh = { git = "https://github.com/storytold/craft-libs", rev = "d1bdf8e5dac7513e4fbc4dab16edaaeda5ebcf5e", default-features = false, features = ["stl", "ply", "fbx", "obj", "gltf", "dae", "abc"] } -craft-mcmat = { git = "https://github.com/storytold/craft-libs", rev = "d1bdf8e5dac7513e4fbc4dab16edaaeda5ebcf5e" } +craft-i18n = { git = "https://github.com/storytold/craft-libs", rev = "aa401985dd4658cdaa272fdccafdcd6e7f4dd60b" } +craft-ui = { git = "https://github.com/storytold/craft-libs", rev = "aa401985dd4658cdaa272fdccafdcd6e7f4dd60b" } +craft-behavior = { git = "https://github.com/storytold/craft-libs", rev = "aa401985dd4658cdaa272fdccafdcd6e7f4dd60b" } +craft-materialx = { git = "https://github.com/storytold/craft-libs", rev = "aa401985dd4658cdaa272fdccafdcd6e7f4dd60b" } +craft-tcraft = { git = "https://github.com/storytold/craft-libs", rev = "aa401985dd4658cdaa272fdccafdcd6e7f4dd60b" } +craft-zip = { git = "https://github.com/storytold/craft-libs", rev = "aa401985dd4658cdaa272fdccafdcd6e7f4dd60b" } +craft-mesh = { git = "https://github.com/storytold/craft-libs", rev = "aa401985dd4658cdaa272fdccafdcd6e7f4dd60b", default-features = false, features = ["stl", "ply", "fbx", "obj", "gltf", "dae", "abc"] } +craft-mcmat = { git = "https://github.com/storytold/craft-libs", rev = "aa401985dd4658cdaa272fdccafdcd6e7f4dd60b" } # Who draws the window frame, and the app-drawn strip as the title bar (crates/ui-egui/src/titlebar.rs). -craft-window = { git = "https://github.com/storytold/craft-libs", rev = "d1bdf8e5dac7513e4fbc4dab16edaaeda5ebcf5e", features = ["ui"] } +craft-window = { git = "https://github.com/storytold/craft-libs", rev = "aa401985dd4658cdaa272fdccafdcd6e7f4dd60b", features = ["ui"] } # Release checks, the update prompt and the update helper (crates/ui-egui/src/updates_ui.rs). -craft-update = { git = "https://github.com/storytold/craft-libs", rev = "d1bdf8e5dac7513e4fbc4dab16edaaeda5ebcf5e", features = ["ui"] } +craft-update = { git = "https://github.com/storytold/craft-libs", rev = "aa401985dd4658cdaa272fdccafdcd6e7f4dd60b", features = ["ui"] } # File dialogs that never block the frame (crates/ui-egui/src/file_dialogs.rs). -craft-dialogs = { git = "https://github.com/storytold/craft-libs", rev = "d1bdf8e5dac7513e4fbc4dab16edaaeda5ebcf5e" } +craft-dialogs = { git = "https://github.com/storytold/craft-libs", rev = "aa401985dd4658cdaa272fdccafdcd6e7f4dd60b" } # Shortcut chords, lookup and dispatch (crates/ui-egui/src/keymap.rs). -craft-keymap = { git = "https://github.com/storytold/craft-libs", rev = "d1bdf8e5dac7513e4fbc4dab16edaaeda5ebcf5e", features = ["egui"] } +craft-keymap = { git = "https://github.com/storytold/craft-libs", rev = "aa401985dd4658cdaa272fdccafdcd6e7f4dd60b", features = ["egui"] } # The macOS app menu whose Quit asks about unsaved changes (apps/texturecraft/src/main.rs). -craft-menu = { git = "https://github.com/storytold/craft-libs", rev = "d1bdf8e5dac7513e4fbc4dab16edaaeda5ebcf5e" } +craft-menu = { git = "https://github.com/storytold/craft-libs", rev = "aa401985dd4658cdaa272fdccafdcd6e7f4dd60b" } # The UI runtime's host: who the app is to the framework's dialogs (crates/ui-egui/src/framework.rs). -craft-host = { git = "https://github.com/storytold/craft-libs", rev = "d1bdf8e5dac7513e4fbc4dab16edaaeda5ebcf5e" } +craft-host = { git = "https://github.com/storytold/craft-libs", rev = "aa401985dd4658cdaa272fdccafdcd6e7f4dd60b" } # The theme mode the app hands the runtime (crates/ui-egui/src/framework.rs). -craft-theme = { git = "https://github.com/storytold/craft-libs", rev = "d1bdf8e5dac7513e4fbc4dab16edaaeda5ebcf5e" } +craft-theme = { git = "https://github.com/storytold/craft-libs", rev = "aa401985dd4658cdaa272fdccafdcd6e7f4dd60b" } # egui 0.37 and winit: the suite's forks (storytold/egui, storytold/winit), as craft-libs pins them. [patch.crates-io] diff --git a/crates/formats/Cargo.toml b/crates/formats/Cargo.toml index 04f6bfc2..ee75b663 100644 --- a/crates/formats/Cargo.toml +++ b/crates/formats/Cargo.toml @@ -11,7 +11,7 @@ workspace = true [dependencies] craft-usd.workspace = true # ICC v2 serialization prerequisite: craft-libs#1735; app colour policy stays local. -craft-cms-icc-v2 = { package = "craft-cms", version = "0.1.0", git = "https://github.com/storytold/craft-libs", rev = "d1bdf8e5dac7513e4fbc4dab16edaaeda5ebcf5e" } +craft-cms-icc-v2 = { package = "craft-cms", version = "0.1.0", git = "https://github.com/storytold/craft-libs", rev = "aa401985dd4658cdaa272fdccafdcd6e7f4dd60b" } craft-materialx = { workspace = true } craft-mesh = { workspace = true } craft-mcmat = { workspace = true } @@ -25,7 +25,7 @@ image = { workspace = true } png = "0.18" bytemuck = { workspace = true, features = ["extern_crate_alloc"] } craft-image-codecs = { workspace = true } -craft-psd = { git = "https://github.com/storytold/craft-libs", rev = "d1bdf8e5dac7513e4fbc4dab16edaaeda5ebcf5e" } +craft-psd = { git = "https://github.com/storytold/craft-libs", rev = "aa401985dd4658cdaa272fdccafdcd6e7f4dd60b" } flate2 = { workspace = true } half = { workspace = true } quick-xml = { workspace = true } From 48c2717148bac8947305cfc70e1d778b488c0353 Mon Sep 17 00:00:00 2001 From: aiongg Date: Wed, 25 Nov 2026 18:24:58 +0000 Subject: [PATCH 52/83] A command's floating panel comes in front of the other windows again As before the move to the craft-ui dock, showing a panel from the Window menu or another command raises the floating window that holds it, once. Docked panels only become the front tab. --- crates/ui-egui/src/docking.rs | 33 +++++++++++++++++++++++++++++---- 1 file changed, 29 insertions(+), 4 deletions(-) diff --git a/crates/ui-egui/src/docking.rs b/crates/ui-egui/src/docking.rs index ba544a05..734cc1d1 100644 --- a/crates/ui-egui/src/docking.rs +++ b/crates/ui-egui/src/docking.rs @@ -256,13 +256,15 @@ const TEXTURE_SET_LIST_SHARE: f32 = 0.4; #[derive(Clone, Debug)] pub struct Dock { workspace: Workspace, + /// A panel to bring in front of the other floating windows on the next frame. + raise: Option, /// A saved layout could not be read, so this is the painting default in its place replaced_unreadable: bool, } impl Default for Dock { fn default() -> Self { - Dock { workspace: default_workspace(), replaced_unreadable: false } + Dock { workspace: default_workspace(), raise: None, replaced_unreadable: false } } } @@ -298,7 +300,7 @@ impl Dock { return unreadable; } - Dock { workspace, replaced_unreadable: false } + Dock { workspace, raise: None, replaced_unreadable: false } } /// Whether a saved layout could not be read and this dock is the painting default instead @@ -327,7 +329,7 @@ impl Dock { let columns_width = BAKERS_COLUMN_WIDTH + gutter_width + SETTINGS_COLUMN_WIDTH; let root = split(Axis::X, SplitSize::FixedFirst(columns_width), columns_over_log, tabs(&[Panel::Viewport])); let workspace = Workspace::from_parts(Layout::new(Some(root), Vec::new()), hidden, painting.floated().to_vec()); - Dock { workspace, replaced_unreadable: false } + Dock { workspace, raise: None, replaced_unreadable: false } } pub fn workspace(&self) -> &Workspace { @@ -359,7 +361,10 @@ impl Dock { pub fn focus(&mut self, p: Panel) { let mut next = self.workspace.clone(); match next.set_visible(p, true, None, false, permissions) { - Ok(()) if validate(&next).is_ok() => self.workspace = next, + Ok(()) if validate(&next).is_ok() => { + self.workspace = next; + self.raise = Some(p); + } Ok(()) => log::warn!("panel {p:?} was not opened: it would break the viewport's rules"), Err(error) => log::warn!("panel {p:?} was not opened: {error}"), } @@ -482,6 +487,7 @@ pub fn show(app: &mut TextureCraftApp, ui: &mut Ui) { // The specs leave the app while its panels borrow it, and come back with their revision. let specs = std::mem::take(&mut app.docks.specs); let hand_over = app.docks.continue_move.take(); + let raise = app.ui.dock.raise.take(); // Panels arrange in a split tree around the viewport; floating title bars only move windows. // Each closable tab has its close button, as each group header had one for its shown panel. let config = DockConfig::default().new_dock_zones(false).title_bar_docks(false).tab_close_buttons(true); @@ -492,6 +498,9 @@ pub fn show(app: &mut TextureCraftApp, ui: &mut Ui) { if let Some(hand_over) = hand_over { area = area.continue_move(hand_over); } + if let Some(panel) = raise { + area = area.raise(panel); + } let output = area.show(ui); (output, panels.focused_windows) }; @@ -795,6 +804,22 @@ mod tests { assert!(dock.workspace().hidden().iter().any(|(panel, _)| *panel == Panel::Export), "Export joins it, closed"); } + #[test] + fn a_focused_panel_is_raised_for_one_frame() { + let session = texturecraft_engine::sample_session(128, 32).unwrap(); + let mut harness = egui_kittest::Harness::builder() + .with_size(vec2(1600.0, 1200.0)) + .with_context_setup(crate::framework::install_headless) + .build_eframe(|cc| TextureCraftApp::new(cc, session)); + let dock = &mut harness.state_mut().ui.dock; + dock.focus(Panel::Display); + assert_eq!(dock.raise, Some(Panel::Display)); + + harness.run_steps(4); + + assert_eq!(harness.state().ui.dock.raise, None); + } + #[test] fn the_viewport_stays_put() { let mut dock = Dock::default(); From 2a1ff34f4e18ca2001e52a4e506216aac5740e47 Mon Sep 17 00:00:00 2001 From: aiongg Date: Wed, 25 Nov 2026 18:24:58 +0000 Subject: [PATCH 53/83] Floating panels match symbol shortcuts as the main window does again As before the move to the craft-ui runtime, a press in a floating panel's own window runs the command it runs in the main window. Where a layout types a symbol with Shift, the binding with Shift wins in both. --- crates/ui-egui/src/keymap.rs | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/crates/ui-egui/src/keymap.rs b/crates/ui-egui/src/keymap.rs index 78ebb672..47d6548d 100644 --- a/crates/ui-egui/src/keymap.rs +++ b/crates/ui-egui/src/keymap.rs @@ -253,11 +253,7 @@ impl Bindings { #[cfg(not(target_arch = "wasm32"))] pub(crate) fn command_of(&self, press: &Event) -> Option { let input = KeyInput::from_egui(press, self.map.platform())?; - self.dispatcher.layout().candidates(&input).into_iter().find_map(|chord| match self.map.lookup(&chord, false, &Active::NONE) { - Lookup::Run(command) => Some(command.id), - Lookup::Cycle(commands) => commands.into_iter().next().map(|command| command.id), - _ => None, - }) + craft_keymap::Matcher::single(self.dispatcher.layout(), &self.map, &input, &Active::NONE, &[]).map(|hit| hit.command.id) } /// The shortcut a press records: the chord it runs, keeping the held Ctrl and Cmd as they are. @@ -814,6 +810,13 @@ mod tests { keymap.insert("file.save".into(), "Equals".into()); let resolved = bindings_for(&keymap); assert_eq!(resolved.command_of(&press(Key::Plus, Modifiers::NONE)).as_deref(), Some("file.save"), "+ stands for ="); + + // A layout that types = with Shift+0: the press is both chords, and the one with Shift runs. + keymap.insert("file.saveAs".into(), "Shift+Equals".into()); + let mut resolved = bindings_for(&keymap); + let equals = press_at(Key::Equals, Key::Num0, Modifiers::SHIFT); + assert_eq!(dispatched(&mut resolved, vec![equals.clone()], Modifiers::SHIFT), ["file.saveAs"]); + assert_eq!(resolved.command_of(&equals).as_deref(), Some("file.saveAs")); } #[test] From 95281e01ad134751b8d98414ed91ff8d127b83c8 Mon Sep 17 00:00:00 2001 From: aiongg Date: Wed, 25 Nov 2026 18:28:09 +0000 Subject: [PATCH 54/83] Shift+Escape stays Shift+Escape when Shift is let go at once As before the move to the craft-ui runtime, an Escape shortcut matches the modifiers of its own press, not the ones held when the frame runs. --- crates/ui-egui/src/menus.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/crates/ui-egui/src/menus.rs b/crates/ui-egui/src/menus.rs index 3e7c3f76..4d826d98 100644 --- a/crates/ui-egui/src/menus.rs +++ b/crates/ui-egui/src/menus.rs @@ -462,8 +462,9 @@ pub fn shortcuts(app: &mut TextureCraftApp, ctx: &egui::Context) { // in egui's input, it runs the Escape and Enter handlers below, the shortcuts and the Path tool's keys for (key, taken) in [(Key::Escape, crate::framework::take_window_cancel(ctx)), (Key::Enter, crate::framework::take_window_submit(ctx))] { if taken { + let escape = craft_ui::runtime::keys::escape_mods(ctx).filter(|_| key == Key::Escape); ctx.input_mut(|i| { - let modifiers = i.modifiers; + let modifiers = escape.map_or(i.modifiers, |held| Modifiers { shift: held.shift, alt: held.alt, ..Modifiers::NONE }); i.events.insert(0, egui::Event::Key { key, physical_key: Some(key), pressed: true, repeat: false, modifiers }); }); } From 8a83057ac3ff322f2b6f769994903649460e963b Mon Sep 17 00:00:00 2001 From: aiongg Date: Wed, 25 Nov 2026 19:15:14 +0000 Subject: [PATCH 55/83] Repin craft-libs to storytold next 8fa4db64a9 and egui to b9770908e --- Cargo.lock | 110 +++++++++++++++++++------------------- Cargo.toml | 54 +++++++++---------- crates/formats/Cargo.toml | 4 +- 3 files changed, 84 insertions(+), 84 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 2518e0c8..ce7afaf0 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -953,7 +953,7 @@ dependencies = [ [[package]] name = "craft-appkit" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=aa401985dd4658cdaa272fdccafdcd6e7f4dd60b#aa401985dd4658cdaa272fdccafdcd6e7f4dd60b" +source = "git+https://github.com/storytold/craft-libs?rev=8fa4db64a9bb943520259ea95331a303ba788f21#8fa4db64a9bb943520259ea95331a303ba788f21" dependencies = [ "block2 0.6.2", "objc2-app-kit 0.3.2", @@ -963,7 +963,7 @@ dependencies = [ [[package]] name = "craft-atomic" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=aa401985dd4658cdaa272fdccafdcd6e7f4dd60b#aa401985dd4658cdaa272fdccafdcd6e7f4dd60b" +source = "git+https://github.com/storytold/craft-libs?rev=8fa4db64a9bb943520259ea95331a303ba788f21#8fa4db64a9bb943520259ea95331a303ba788f21" dependencies = [ "rustix 1.1.6", ] @@ -971,7 +971,7 @@ dependencies = [ [[package]] name = "craft-behavior" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=aa401985dd4658cdaa272fdccafdcd6e7f4dd60b#aa401985dd4658cdaa272fdccafdcd6e7f4dd60b" +source = "git+https://github.com/storytold/craft-libs?rev=8fa4db64a9bb943520259ea95331a303ba788f21#8fa4db64a9bb943520259ea95331a303ba788f21" dependencies = [ "accesskit", "bitflags 2.13.2", @@ -989,7 +989,7 @@ dependencies = [ [[package]] name = "craft-cloud-ui" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=aa401985dd4658cdaa272fdccafdcd6e7f4dd60b#aa401985dd4658cdaa272fdccafdcd6e7f4dd60b" +source = "git+https://github.com/storytold/craft-libs?rev=8fa4db64a9bb943520259ea95331a303ba788f21#8fa4db64a9bb943520259ea95331a303ba788f21" dependencies = [ "egui", ] @@ -997,7 +997,7 @@ dependencies = [ [[package]] name = "craft-cms" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=aa401985dd4658cdaa272fdccafdcd6e7f4dd60b#aa401985dd4658cdaa272fdccafdcd6e7f4dd60b" +source = "git+https://github.com/storytold/craft-libs?rev=8fa4db64a9bb943520259ea95331a303ba788f21#8fa4db64a9bb943520259ea95331a303ba788f21" dependencies = [ "md-5", "rayon", @@ -1006,12 +1006,12 @@ dependencies = [ [[package]] name = "craft-codepage" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=aa401985dd4658cdaa272fdccafdcd6e7f4dd60b#aa401985dd4658cdaa272fdccafdcd6e7f4dd60b" +source = "git+https://github.com/storytold/craft-libs?rev=8fa4db64a9bb943520259ea95331a303ba788f21#8fa4db64a9bb943520259ea95331a303ba788f21" [[package]] name = "craft-dds" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=aa401985dd4658cdaa272fdccafdcd6e7f4dd60b#aa401985dd4658cdaa272fdccafdcd6e7f4dd60b" +source = "git+https://github.com/storytold/craft-libs?rev=8fa4db64a9bb943520259ea95331a303ba788f21#8fa4db64a9bb943520259ea95331a303ba788f21" dependencies = [ "rayon", ] @@ -1019,7 +1019,7 @@ dependencies = [ [[package]] name = "craft-dialogs" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=aa401985dd4658cdaa272fdccafdcd6e7f4dd60b#aa401985dd4658cdaa272fdccafdcd6e7f4dd60b" +source = "git+https://github.com/storytold/craft-libs?rev=8fa4db64a9bb943520259ea95331a303ba788f21#8fa4db64a9bb943520259ea95331a303ba788f21" dependencies = [ "block2 0.6.2", "craft-atomic", @@ -1039,7 +1039,7 @@ dependencies = [ [[package]] name = "craft-docpath" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=aa401985dd4658cdaa272fdccafdcd6e7f4dd60b#aa401985dd4658cdaa272fdccafdcd6e7f4dd60b" +source = "git+https://github.com/storytold/craft-libs?rev=8fa4db64a9bb943520259ea95331a303ba788f21#8fa4db64a9bb943520259ea95331a303ba788f21" dependencies = [ "serde", ] @@ -1047,7 +1047,7 @@ dependencies = [ [[package]] name = "craft-font-catalog" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=aa401985dd4658cdaa272fdccafdcd6e7f4dd60b#aa401985dd4658cdaa272fdccafdcd6e7f4dd60b" +source = "git+https://github.com/storytold/craft-libs?rev=8fa4db64a9bb943520259ea95331a303ba788f21#8fa4db64a9bb943520259ea95331a303ba788f21" dependencies = [ "harfrust 0.13.3", "kurbo", @@ -1061,12 +1061,12 @@ dependencies = [ [[package]] name = "craft-fonts-build" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=aa401985dd4658cdaa272fdccafdcd6e7f4dd60b#aa401985dd4658cdaa272fdccafdcd6e7f4dd60b" +source = "git+https://github.com/storytold/craft-libs?rev=8fa4db64a9bb943520259ea95331a303ba788f21#8fa4db64a9bb943520259ea95331a303ba788f21" [[package]] name = "craft-host" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=aa401985dd4658cdaa272fdccafdcd6e7f4dd60b#aa401985dd4658cdaa272fdccafdcd6e7f4dd60b" +source = "git+https://github.com/storytold/craft-libs?rev=8fa4db64a9bb943520259ea95331a303ba788f21#8fa4db64a9bb943520259ea95331a303ba788f21" dependencies = [ "bitflags 2.13.2", "craft-i18n", @@ -1079,7 +1079,7 @@ dependencies = [ [[package]] name = "craft-i18n" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=aa401985dd4658cdaa272fdccafdcd6e7f4dd60b#aa401985dd4658cdaa272fdccafdcd6e7f4dd60b" +source = "git+https://github.com/storytold/craft-libs?rev=8fa4db64a9bb943520259ea95331a303ba788f21#8fa4db64a9bb943520259ea95331a303ba788f21" dependencies = [ "chrono", "fixed_decimal", @@ -1107,7 +1107,7 @@ dependencies = [ [[package]] name = "craft-image-codecs" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=aa401985dd4658cdaa272fdccafdcd6e7f4dd60b#aa401985dd4658cdaa272fdccafdcd6e7f4dd60b" +source = "git+https://github.com/storytold/craft-libs?rev=8fa4db64a9bb943520259ea95331a303ba788f21#8fa4db64a9bb943520259ea95331a303ba788f21" dependencies = [ "craft-dds", "craft-jpeg", @@ -1134,7 +1134,7 @@ dependencies = [ [[package]] name = "craft-jpeg" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=aa401985dd4658cdaa272fdccafdcd6e7f4dd60b#aa401985dd4658cdaa272fdccafdcd6e7f4dd60b" +source = "git+https://github.com/storytold/craft-libs?rev=8fa4db64a9bb943520259ea95331a303ba788f21#8fa4db64a9bb943520259ea95331a303ba788f21" dependencies = [ "thiserror 2.0.21", ] @@ -1142,7 +1142,7 @@ dependencies = [ [[package]] name = "craft-keymap" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=aa401985dd4658cdaa272fdccafdcd6e7f4dd60b#aa401985dd4658cdaa272fdccafdcd6e7f4dd60b" +source = "git+https://github.com/storytold/craft-libs?rev=8fa4db64a9bb943520259ea95331a303ba788f21#8fa4db64a9bb943520259ea95331a303ba788f21" dependencies = [ "craft-host", "craft-i18n", @@ -1157,7 +1157,7 @@ dependencies = [ [[package]] name = "craft-materialx" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=aa401985dd4658cdaa272fdccafdcd6e7f4dd60b#aa401985dd4658cdaa272fdccafdcd6e7f4dd60b" +source = "git+https://github.com/storytold/craft-libs?rev=8fa4db64a9bb943520259ea95331a303ba788f21#8fa4db64a9bb943520259ea95331a303ba788f21" dependencies = [ "craft-xml", "thiserror 2.0.21", @@ -1166,7 +1166,7 @@ dependencies = [ [[package]] name = "craft-mcmat" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=aa401985dd4658cdaa272fdccafdcd6e7f4dd60b#aa401985dd4658cdaa272fdccafdcd6e7f4dd60b" +source = "git+https://github.com/storytold/craft-libs?rev=8fa4db64a9bb943520259ea95331a303ba788f21#8fa4db64a9bb943520259ea95331a303ba788f21" dependencies = [ "craft-zip", "serde", @@ -1177,7 +1177,7 @@ dependencies = [ [[package]] name = "craft-menu" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=aa401985dd4658cdaa272fdccafdcd6e7f4dd60b#aa401985dd4658cdaa272fdccafdcd6e7f4dd60b" +source = "git+https://github.com/storytold/craft-libs?rev=8fa4db64a9bb943520259ea95331a303ba788f21#8fa4db64a9bb943520259ea95331a303ba788f21" dependencies = [ "craft-behavior", "craft-host", @@ -1195,7 +1195,7 @@ dependencies = [ [[package]] name = "craft-mesh" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=aa401985dd4658cdaa272fdccafdcd6e7f4dd60b#aa401985dd4658cdaa272fdccafdcd6e7f4dd60b" +source = "git+https://github.com/storytold/craft-libs?rev=8fa4db64a9bb943520259ea95331a303ba788f21#8fa4db64a9bb943520259ea95331a303ba788f21" dependencies = [ "craft-xml", "craft-zip", @@ -1206,7 +1206,7 @@ dependencies = [ [[package]] name = "craft-metadata" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=aa401985dd4658cdaa272fdccafdcd6e7f4dd60b#aa401985dd4658cdaa272fdccafdcd6e7f4dd60b" +source = "git+https://github.com/storytold/craft-libs?rev=8fa4db64a9bb943520259ea95331a303ba788f21#8fa4db64a9bb943520259ea95331a303ba788f21" dependencies = [ "brotli-decompressor", "chrono", @@ -1218,7 +1218,7 @@ dependencies = [ [[package]] name = "craft-pdf" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=aa401985dd4658cdaa272fdccafdcd6e7f4dd60b#aa401985dd4658cdaa272fdccafdcd6e7f4dd60b" +source = "git+https://github.com/storytold/craft-libs?rev=8fa4db64a9bb943520259ea95331a303ba788f21#8fa4db64a9bb943520259ea95331a303ba788f21" dependencies = [ "serde", ] @@ -1226,7 +1226,7 @@ dependencies = [ [[package]] name = "craft-platform" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=aa401985dd4658cdaa272fdccafdcd6e7f4dd60b#aa401985dd4658cdaa272fdccafdcd6e7f4dd60b" +source = "git+https://github.com/storytold/craft-libs?rev=8fa4db64a9bb943520259ea95331a303ba788f21#8fa4db64a9bb943520259ea95331a303ba788f21" dependencies = [ "async-channel", "async-io", @@ -1257,7 +1257,7 @@ dependencies = [ [[package]] name = "craft-psd" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=aa401985dd4658cdaa272fdccafdcd6e7f4dd60b#aa401985dd4658cdaa272fdccafdcd6e7f4dd60b" +source = "git+https://github.com/storytold/craft-libs?rev=8fa4db64a9bb943520259ea95331a303ba788f21#8fa4db64a9bb943520259ea95331a303ba788f21" dependencies = [ "encoding_rs", "flate2", @@ -1268,7 +1268,7 @@ dependencies = [ [[package]] name = "craft-quit" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=aa401985dd4658cdaa272fdccafdcd6e7f4dd60b#aa401985dd4658cdaa272fdccafdcd6e7f4dd60b" +source = "git+https://github.com/storytold/craft-libs?rev=8fa4db64a9bb943520259ea95331a303ba788f21#8fa4db64a9bb943520259ea95331a303ba788f21" dependencies = [ "dispatch2", "egui", @@ -1281,7 +1281,7 @@ dependencies = [ [[package]] name = "craft-settings" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=aa401985dd4658cdaa272fdccafdcd6e7f4dd60b#aa401985dd4658cdaa272fdccafdcd6e7f4dd60b" +source = "git+https://github.com/storytold/craft-libs?rev=8fa4db64a9bb943520259ea95331a303ba788f21#8fa4db64a9bb943520259ea95331a303ba788f21" dependencies = [ "craft-atomic", "craft-host", @@ -1298,7 +1298,7 @@ dependencies = [ [[package]] name = "craft-svg" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=aa401985dd4658cdaa272fdccafdcd6e7f4dd60b#aa401985dd4658cdaa272fdccafdcd6e7f4dd60b" +source = "git+https://github.com/storytold/craft-libs?rev=8fa4db64a9bb943520259ea95331a303ba788f21#8fa4db64a9bb943520259ea95331a303ba788f21" dependencies = [ "craft-xml", "flate2", @@ -1315,7 +1315,7 @@ dependencies = [ [[package]] name = "craft-tcraft" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=aa401985dd4658cdaa272fdccafdcd6e7f4dd60b#aa401985dd4658cdaa272fdccafdcd6e7f4dd60b" +source = "git+https://github.com/storytold/craft-libs?rev=8fa4db64a9bb943520259ea95331a303ba788f21#8fa4db64a9bb943520259ea95331a303ba788f21" dependencies = [ "craft-zip", "serde", @@ -1326,7 +1326,7 @@ dependencies = [ [[package]] name = "craft-theme" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=aa401985dd4658cdaa272fdccafdcd6e7f4dd60b#aa401985dd4658cdaa272fdccafdcd6e7f4dd60b" +source = "git+https://github.com/storytold/craft-libs?rev=8fa4db64a9bb943520259ea95331a303ba788f21#8fa4db64a9bb943520259ea95331a303ba788f21" dependencies = [ "bitflags 2.13.2", "craft-tracked", @@ -1341,7 +1341,7 @@ dependencies = [ [[package]] name = "craft-tiff" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=aa401985dd4658cdaa272fdccafdcd6e7f4dd60b#aa401985dd4658cdaa272fdccafdcd6e7f4dd60b" +source = "git+https://github.com/storytold/craft-libs?rev=8fa4db64a9bb943520259ea95331a303ba788f21#8fa4db64a9bb943520259ea95331a303ba788f21" dependencies = [ "serde", "thiserror 2.0.21", @@ -1351,12 +1351,12 @@ dependencies = [ [[package]] name = "craft-tracked" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=aa401985dd4658cdaa272fdccafdcd6e7f4dd60b#aa401985dd4658cdaa272fdccafdcd6e7f4dd60b" +source = "git+https://github.com/storytold/craft-libs?rev=8fa4db64a9bb943520259ea95331a303ba788f21#8fa4db64a9bb943520259ea95331a303ba788f21" [[package]] name = "craft-ui" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=aa401985dd4658cdaa272fdccafdcd6e7f4dd60b#aa401985dd4658cdaa272fdccafdcd6e7f4dd60b" +source = "git+https://github.com/storytold/craft-libs?rev=8fa4db64a9bb943520259ea95331a303ba788f21#8fa4db64a9bb943520259ea95331a303ba788f21" dependencies = [ "craft-cloud-ui", "craft-ui-canvas", @@ -1370,7 +1370,7 @@ dependencies = [ [[package]] name = "craft-ui-canvas" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=aa401985dd4658cdaa272fdccafdcd6e7f4dd60b#aa401985dd4658cdaa272fdccafdcd6e7f4dd60b" +source = "git+https://github.com/storytold/craft-libs?rev=8fa4db64a9bb943520259ea95331a303ba788f21#8fa4db64a9bb943520259ea95331a303ba788f21" dependencies = [ "craft-behavior", "craft-i18n", @@ -1386,7 +1386,7 @@ dependencies = [ [[package]] name = "craft-ui-contract" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=aa401985dd4658cdaa272fdccafdcd6e7f4dd60b#aa401985dd4658cdaa272fdccafdcd6e7f4dd60b" +source = "git+https://github.com/storytold/craft-libs?rev=8fa4db64a9bb943520259ea95331a303ba788f21#8fa4db64a9bb943520259ea95331a303ba788f21" dependencies = [ "accesskit", "craft-behavior", @@ -1424,7 +1424,7 @@ dependencies = [ [[package]] name = "craft-ui-macros" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=aa401985dd4658cdaa272fdccafdcd6e7f4dd60b#aa401985dd4658cdaa272fdccafdcd6e7f4dd60b" +source = "git+https://github.com/storytold/craft-libs?rev=8fa4db64a9bb943520259ea95331a303ba788f21#8fa4db64a9bb943520259ea95331a303ba788f21" dependencies = [ "proc-macro-crate", "proc-macro2", @@ -1435,7 +1435,7 @@ dependencies = [ [[package]] name = "craft-ui-panels" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=aa401985dd4658cdaa272fdccafdcd6e7f4dd60b#aa401985dd4658cdaa272fdccafdcd6e7f4dd60b" +source = "git+https://github.com/storytold/craft-libs?rev=8fa4db64a9bb943520259ea95331a303ba788f21#8fa4db64a9bb943520259ea95331a303ba788f21" dependencies = [ "craft-behavior", "craft-host", @@ -1453,7 +1453,7 @@ dependencies = [ [[package]] name = "craft-ui-patterns" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=aa401985dd4658cdaa272fdccafdcd6e7f4dd60b#aa401985dd4658cdaa272fdccafdcd6e7f4dd60b" +source = "git+https://github.com/storytold/craft-libs?rev=8fa4db64a9bb943520259ea95331a303ba788f21#8fa4db64a9bb943520259ea95331a303ba788f21" dependencies = [ "craft-behavior", "craft-host", @@ -1474,7 +1474,7 @@ dependencies = [ [[package]] name = "craft-ui-shell" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=aa401985dd4658cdaa272fdccafdcd6e7f4dd60b#aa401985dd4658cdaa272fdccafdcd6e7f4dd60b" +source = "git+https://github.com/storytold/craft-libs?rev=8fa4db64a9bb943520259ea95331a303ba788f21#8fa4db64a9bb943520259ea95331a303ba788f21" dependencies = [ "craft-behavior", "craft-host", @@ -1494,7 +1494,7 @@ dependencies = [ [[package]] name = "craft-ui-widgets" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=aa401985dd4658cdaa272fdccafdcd6e7f4dd60b#aa401985dd4658cdaa272fdccafdcd6e7f4dd60b" +source = "git+https://github.com/storytold/craft-libs?rev=8fa4db64a9bb943520259ea95331a303ba788f21#8fa4db64a9bb943520259ea95331a303ba788f21" dependencies = [ "craft-behavior", "craft-host", @@ -1513,7 +1513,7 @@ dependencies = [ [[package]] name = "craft-update" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=aa401985dd4658cdaa272fdccafdcd6e7f4dd60b#aa401985dd4658cdaa272fdccafdcd6e7f4dd60b" +source = "git+https://github.com/storytold/craft-libs?rev=8fa4db64a9bb943520259ea95331a303ba788f21#8fa4db64a9bb943520259ea95331a303ba788f21" dependencies = [ "chrono", "craft-host", @@ -1542,7 +1542,7 @@ dependencies = [ [[package]] name = "craft-usd" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=aa401985dd4658cdaa272fdccafdcd6e7f4dd60b#aa401985dd4658cdaa272fdccafdcd6e7f4dd60b" +source = "git+https://github.com/storytold/craft-libs?rev=8fa4db64a9bb943520259ea95331a303ba788f21#8fa4db64a9bb943520259ea95331a303ba788f21" dependencies = [ "half", "lz4_flex", @@ -1552,7 +1552,7 @@ dependencies = [ [[package]] name = "craft-win32" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=aa401985dd4658cdaa272fdccafdcd6e7f4dd60b#aa401985dd4658cdaa272fdccafdcd6e7f4dd60b" +source = "git+https://github.com/storytold/craft-libs?rev=8fa4db64a9bb943520259ea95331a303ba788f21#8fa4db64a9bb943520259ea95331a303ba788f21" dependencies = [ "winsafe", ] @@ -1560,7 +1560,7 @@ dependencies = [ [[package]] name = "craft-window" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=aa401985dd4658cdaa272fdccafdcd6e7f4dd60b#aa401985dd4658cdaa272fdccafdcd6e7f4dd60b" +source = "git+https://github.com/storytold/craft-libs?rev=8fa4db64a9bb943520259ea95331a303ba788f21#8fa4db64a9bb943520259ea95331a303ba788f21" dependencies = [ "craft-appkit", "craft-atomic", @@ -1584,7 +1584,7 @@ dependencies = [ [[package]] name = "craft-xml" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=aa401985dd4658cdaa272fdccafdcd6e7f4dd60b#aa401985dd4658cdaa272fdccafdcd6e7f4dd60b" +source = "git+https://github.com/storytold/craft-libs?rev=8fa4db64a9bb943520259ea95331a303ba788f21#8fa4db64a9bb943520259ea95331a303ba788f21" dependencies = [ "quick-xml 0.41.0", "serde", @@ -1594,7 +1594,7 @@ dependencies = [ [[package]] name = "craft-zip" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=aa401985dd4658cdaa272fdccafdcd6e7f4dd60b#aa401985dd4658cdaa272fdccafdcd6e7f4dd60b" +source = "git+https://github.com/storytold/craft-libs?rev=8fa4db64a9bb943520259ea95331a303ba788f21#8fa4db64a9bb943520259ea95331a303ba788f21" dependencies = [ "flate2", "thiserror 2.0.21", @@ -1872,7 +1872,7 @@ checksum = "d0881ea181b1df73ff77ffaaf9c7544ecc11e82fba9b5f27b262a3c73a332555" [[package]] name = "ecolor" version = "0.37.0" -source = "git+https://github.com/storytold/egui.git?rev=b15ffe9bfc2c8e6748533b32b708e10abaf2afec#b15ffe9bfc2c8e6748533b32b708e10abaf2afec" +source = "git+https://github.com/storytold/egui.git?rev=b9770908e0f304896f9658d239a7b29cf8af1564#b9770908e0f304896f9658d239a7b29cf8af1564" dependencies = [ "bytemuck", "emath", @@ -1882,7 +1882,7 @@ dependencies = [ [[package]] name = "eframe" version = "0.37.0" -source = "git+https://github.com/storytold/egui.git?rev=b15ffe9bfc2c8e6748533b32b708e10abaf2afec#b15ffe9bfc2c8e6748533b32b708e10abaf2afec" +source = "git+https://github.com/storytold/egui.git?rev=b9770908e0f304896f9658d239a7b29cf8af1564#b9770908e0f304896f9658d239a7b29cf8af1564" dependencies = [ "ahash", "bytemuck", @@ -1919,7 +1919,7 @@ dependencies = [ [[package]] name = "egui" version = "0.37.0" -source = "git+https://github.com/storytold/egui.git?rev=b15ffe9bfc2c8e6748533b32b708e10abaf2afec#b15ffe9bfc2c8e6748533b32b708e10abaf2afec" +source = "git+https://github.com/storytold/egui.git?rev=b9770908e0f304896f9658d239a7b29cf8af1564#b9770908e0f304896f9658d239a7b29cf8af1564" dependencies = [ "accesskit", "ahash", @@ -1947,7 +1947,7 @@ dependencies = [ [[package]] name = "egui-wgpu" version = "0.37.0" -source = "git+https://github.com/storytold/egui.git?rev=b15ffe9bfc2c8e6748533b32b708e10abaf2afec#b15ffe9bfc2c8e6748533b32b708e10abaf2afec" +source = "git+https://github.com/storytold/egui.git?rev=b9770908e0f304896f9658d239a7b29cf8af1564#b9770908e0f304896f9658d239a7b29cf8af1564" dependencies = [ "ahash", "bytemuck", @@ -1966,7 +1966,7 @@ dependencies = [ [[package]] name = "egui-winit" version = "0.37.0" -source = "git+https://github.com/storytold/egui.git?rev=b15ffe9bfc2c8e6748533b32b708e10abaf2afec#b15ffe9bfc2c8e6748533b32b708e10abaf2afec" +source = "git+https://github.com/storytold/egui.git?rev=b9770908e0f304896f9658d239a7b29cf8af1564#b9770908e0f304896f9658d239a7b29cf8af1564" dependencies = [ "accesskit_winit", "arboard", @@ -1990,7 +1990,7 @@ dependencies = [ [[package]] name = "egui_glow" version = "0.37.0" -source = "git+https://github.com/storytold/egui.git?rev=b15ffe9bfc2c8e6748533b32b708e10abaf2afec#b15ffe9bfc2c8e6748533b32b708e10abaf2afec" +source = "git+https://github.com/storytold/egui.git?rev=b9770908e0f304896f9658d239a7b29cf8af1564#b9770908e0f304896f9658d239a7b29cf8af1564" dependencies = [ "bytemuck", "egui", @@ -2003,7 +2003,7 @@ dependencies = [ [[package]] name = "egui_kittest" version = "0.37.0" -source = "git+https://github.com/storytold/egui.git?rev=b15ffe9bfc2c8e6748533b32b708e10abaf2afec#b15ffe9bfc2c8e6748533b32b708e10abaf2afec" +source = "git+https://github.com/storytold/egui.git?rev=b9770908e0f304896f9658d239a7b29cf8af1564#b9770908e0f304896f9658d239a7b29cf8af1564" dependencies = [ "eframe", "egui", @@ -2026,7 +2026,7 @@ checksum = "0e9c71c2167ca323c882b99918929403426e2373ea17242ff5653e0d5e1058be" [[package]] name = "emath" version = "0.37.0" -source = "git+https://github.com/storytold/egui.git?rev=b15ffe9bfc2c8e6748533b32b708e10abaf2afec#b15ffe9bfc2c8e6748533b32b708e10abaf2afec" +source = "git+https://github.com/storytold/egui.git?rev=b9770908e0f304896f9658d239a7b29cf8af1564#b9770908e0f304896f9658d239a7b29cf8af1564" dependencies = [ "bytemuck", "serde", @@ -2099,7 +2099,7 @@ dependencies = [ [[package]] name = "epaint" version = "0.37.0" -source = "git+https://github.com/storytold/egui.git?rev=b15ffe9bfc2c8e6748533b32b708e10abaf2afec#b15ffe9bfc2c8e6748533b32b708e10abaf2afec" +source = "git+https://github.com/storytold/egui.git?rev=b9770908e0f304896f9658d239a7b29cf8af1564#b9770908e0f304896f9658d239a7b29cf8af1564" dependencies = [ "ahash", "bytemuck", @@ -2126,7 +2126,7 @@ dependencies = [ [[package]] name = "epaint_default_fonts" version = "0.37.0" -source = "git+https://github.com/storytold/egui.git?rev=b15ffe9bfc2c8e6748533b32b708e10abaf2afec#b15ffe9bfc2c8e6748533b32b708e10abaf2afec" +source = "git+https://github.com/storytold/egui.git?rev=b9770908e0f304896f9658d239a7b29cf8af1564#b9770908e0f304896f9658d239a7b29cf8af1564" [[package]] name = "equivalent" diff --git a/Cargo.toml b/Cargo.toml index b054d968..966b1d7d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -10,7 +10,7 @@ edition = "2024" license = "MIT OR Apache-2.0" [workspace.dependencies] -craft-usd = { version = "0.1.0", git = "https://github.com/storytold/craft-libs", rev = "aa401985dd4658cdaa272fdccafdcd6e7f4dd60b" } +craft-usd = { version = "0.1.0", git = "https://github.com/storytold/craft-libs", rev = "8fa4db64a9bb943520259ea95331a303ba788f21" } # internal texturecraft-core = { path = "crates/core" } texturecraft-texel = { path = "crates/texel" } @@ -41,7 +41,7 @@ skrifa = { version = "0.44", default-features = false, features = ["std"] } epaint_default_fonts = "0.37" log = "0.4" image = { version = "0.25", default-features = false, features = ["png", "jpeg", "tga", "tiff", "exr", "hdr", "bmp", "webp"] } -craft-image-codecs = { git = "https://github.com/storytold/craft-libs", rev = "aa401985dd4658cdaa272fdccafdcd6e7f4dd60b" } +craft-image-codecs = { git = "https://github.com/storytold/craft-libs", rev = "8fa4db64a9bb943520259ea95331a303ba788f21" } half = "2" exr = { version = "1.73", default-features = false } eframe = { version = "0.37", default-features = false } @@ -64,41 +64,41 @@ rustix = { version = "1", default-features = false, features = ["std", "fs", "pr # Shared Craft egui components (widget palette, icon buttons, panel docking): storytold/craft-libs, # MIT OR Apache-2.0, pinned to one rev. # Shared catalog lookup, pinned with the other Craft libraries. -craft-i18n = { git = "https://github.com/storytold/craft-libs", rev = "aa401985dd4658cdaa272fdccafdcd6e7f4dd60b" } -craft-ui = { git = "https://github.com/storytold/craft-libs", rev = "aa401985dd4658cdaa272fdccafdcd6e7f4dd60b" } -craft-behavior = { git = "https://github.com/storytold/craft-libs", rev = "aa401985dd4658cdaa272fdccafdcd6e7f4dd60b" } -craft-materialx = { git = "https://github.com/storytold/craft-libs", rev = "aa401985dd4658cdaa272fdccafdcd6e7f4dd60b" } -craft-tcraft = { git = "https://github.com/storytold/craft-libs", rev = "aa401985dd4658cdaa272fdccafdcd6e7f4dd60b" } -craft-zip = { git = "https://github.com/storytold/craft-libs", rev = "aa401985dd4658cdaa272fdccafdcd6e7f4dd60b" } -craft-mesh = { git = "https://github.com/storytold/craft-libs", rev = "aa401985dd4658cdaa272fdccafdcd6e7f4dd60b", default-features = false, features = ["stl", "ply", "fbx", "obj", "gltf", "dae", "abc"] } -craft-mcmat = { git = "https://github.com/storytold/craft-libs", rev = "aa401985dd4658cdaa272fdccafdcd6e7f4dd60b" } +craft-i18n = { git = "https://github.com/storytold/craft-libs", rev = "8fa4db64a9bb943520259ea95331a303ba788f21" } +craft-ui = { git = "https://github.com/storytold/craft-libs", rev = "8fa4db64a9bb943520259ea95331a303ba788f21" } +craft-behavior = { git = "https://github.com/storytold/craft-libs", rev = "8fa4db64a9bb943520259ea95331a303ba788f21" } +craft-materialx = { git = "https://github.com/storytold/craft-libs", rev = "8fa4db64a9bb943520259ea95331a303ba788f21" } +craft-tcraft = { git = "https://github.com/storytold/craft-libs", rev = "8fa4db64a9bb943520259ea95331a303ba788f21" } +craft-zip = { git = "https://github.com/storytold/craft-libs", rev = "8fa4db64a9bb943520259ea95331a303ba788f21" } +craft-mesh = { git = "https://github.com/storytold/craft-libs", rev = "8fa4db64a9bb943520259ea95331a303ba788f21", default-features = false, features = ["stl", "ply", "fbx", "obj", "gltf", "dae", "abc"] } +craft-mcmat = { git = "https://github.com/storytold/craft-libs", rev = "8fa4db64a9bb943520259ea95331a303ba788f21" } # Who draws the window frame, and the app-drawn strip as the title bar (crates/ui-egui/src/titlebar.rs). -craft-window = { git = "https://github.com/storytold/craft-libs", rev = "aa401985dd4658cdaa272fdccafdcd6e7f4dd60b", features = ["ui"] } +craft-window = { git = "https://github.com/storytold/craft-libs", rev = "8fa4db64a9bb943520259ea95331a303ba788f21", features = ["ui"] } # Release checks, the update prompt and the update helper (crates/ui-egui/src/updates_ui.rs). -craft-update = { git = "https://github.com/storytold/craft-libs", rev = "aa401985dd4658cdaa272fdccafdcd6e7f4dd60b", features = ["ui"] } +craft-update = { git = "https://github.com/storytold/craft-libs", rev = "8fa4db64a9bb943520259ea95331a303ba788f21", features = ["ui"] } # File dialogs that never block the frame (crates/ui-egui/src/file_dialogs.rs). -craft-dialogs = { git = "https://github.com/storytold/craft-libs", rev = "aa401985dd4658cdaa272fdccafdcd6e7f4dd60b" } +craft-dialogs = { git = "https://github.com/storytold/craft-libs", rev = "8fa4db64a9bb943520259ea95331a303ba788f21" } # Shortcut chords, lookup and dispatch (crates/ui-egui/src/keymap.rs). -craft-keymap = { git = "https://github.com/storytold/craft-libs", rev = "aa401985dd4658cdaa272fdccafdcd6e7f4dd60b", features = ["egui"] } +craft-keymap = { git = "https://github.com/storytold/craft-libs", rev = "8fa4db64a9bb943520259ea95331a303ba788f21", features = ["egui"] } # The macOS app menu whose Quit asks about unsaved changes (apps/texturecraft/src/main.rs). -craft-menu = { git = "https://github.com/storytold/craft-libs", rev = "aa401985dd4658cdaa272fdccafdcd6e7f4dd60b" } +craft-menu = { git = "https://github.com/storytold/craft-libs", rev = "8fa4db64a9bb943520259ea95331a303ba788f21" } # The UI runtime's host: who the app is to the framework's dialogs (crates/ui-egui/src/framework.rs). -craft-host = { git = "https://github.com/storytold/craft-libs", rev = "aa401985dd4658cdaa272fdccafdcd6e7f4dd60b" } +craft-host = { git = "https://github.com/storytold/craft-libs", rev = "8fa4db64a9bb943520259ea95331a303ba788f21" } # The theme mode the app hands the runtime (crates/ui-egui/src/framework.rs). -craft-theme = { git = "https://github.com/storytold/craft-libs", rev = "aa401985dd4658cdaa272fdccafdcd6e7f4dd60b" } +craft-theme = { git = "https://github.com/storytold/craft-libs", rev = "8fa4db64a9bb943520259ea95331a303ba788f21" } # egui 0.37 and winit: the suite's forks (storytold/egui, storytold/winit), as craft-libs pins them. [patch.crates-io] -ecolor = { git = "https://github.com/storytold/egui.git", rev = "b15ffe9bfc2c8e6748533b32b708e10abaf2afec" } -emath = { git = "https://github.com/storytold/egui.git", rev = "b15ffe9bfc2c8e6748533b32b708e10abaf2afec" } -epaint = { git = "https://github.com/storytold/egui.git", rev = "b15ffe9bfc2c8e6748533b32b708e10abaf2afec" } -epaint_default_fonts = { git = "https://github.com/storytold/egui.git", rev = "b15ffe9bfc2c8e6748533b32b708e10abaf2afec" } -egui = { git = "https://github.com/storytold/egui.git", rev = "b15ffe9bfc2c8e6748533b32b708e10abaf2afec" } -egui-winit = { git = "https://github.com/storytold/egui.git", rev = "b15ffe9bfc2c8e6748533b32b708e10abaf2afec" } -egui-wgpu = { git = "https://github.com/storytold/egui.git", rev = "b15ffe9bfc2c8e6748533b32b708e10abaf2afec" } -egui_glow = { git = "https://github.com/storytold/egui.git", rev = "b15ffe9bfc2c8e6748533b32b708e10abaf2afec" } -eframe = { git = "https://github.com/storytold/egui.git", rev = "b15ffe9bfc2c8e6748533b32b708e10abaf2afec" } -egui_kittest = { git = "https://github.com/storytold/egui.git", rev = "b15ffe9bfc2c8e6748533b32b708e10abaf2afec" } +ecolor = { git = "https://github.com/storytold/egui.git", rev = "b9770908e0f304896f9658d239a7b29cf8af1564" } +emath = { git = "https://github.com/storytold/egui.git", rev = "b9770908e0f304896f9658d239a7b29cf8af1564" } +epaint = { git = "https://github.com/storytold/egui.git", rev = "b9770908e0f304896f9658d239a7b29cf8af1564" } +epaint_default_fonts = { git = "https://github.com/storytold/egui.git", rev = "b9770908e0f304896f9658d239a7b29cf8af1564" } +egui = { git = "https://github.com/storytold/egui.git", rev = "b9770908e0f304896f9658d239a7b29cf8af1564" } +egui-winit = { git = "https://github.com/storytold/egui.git", rev = "b9770908e0f304896f9658d239a7b29cf8af1564" } +egui-wgpu = { git = "https://github.com/storytold/egui.git", rev = "b9770908e0f304896f9658d239a7b29cf8af1564" } +egui_glow = { git = "https://github.com/storytold/egui.git", rev = "b9770908e0f304896f9658d239a7b29cf8af1564" } +eframe = { git = "https://github.com/storytold/egui.git", rev = "b9770908e0f304896f9658d239a7b29cf8af1564" } +egui_kittest = { git = "https://github.com/storytold/egui.git", rev = "b9770908e0f304896f9658d239a7b29cf8af1564" } winit = { git = "https://github.com/storytold/winit.git", rev = "a517b3846ee8457d84ee4975110bfda6797c44dc" } # egui-phosphor has no release for egui 0.37 (vendor/egui-phosphor/VENDORED.md). egui-phosphor = { path = "vendor/egui-phosphor" } diff --git a/crates/formats/Cargo.toml b/crates/formats/Cargo.toml index ee75b663..2319dbd7 100644 --- a/crates/formats/Cargo.toml +++ b/crates/formats/Cargo.toml @@ -11,7 +11,7 @@ workspace = true [dependencies] craft-usd.workspace = true # ICC v2 serialization prerequisite: craft-libs#1735; app colour policy stays local. -craft-cms-icc-v2 = { package = "craft-cms", version = "0.1.0", git = "https://github.com/storytold/craft-libs", rev = "aa401985dd4658cdaa272fdccafdcd6e7f4dd60b" } +craft-cms-icc-v2 = { package = "craft-cms", version = "0.1.0", git = "https://github.com/storytold/craft-libs", rev = "8fa4db64a9bb943520259ea95331a303ba788f21" } craft-materialx = { workspace = true } craft-mesh = { workspace = true } craft-mcmat = { workspace = true } @@ -25,7 +25,7 @@ image = { workspace = true } png = "0.18" bytemuck = { workspace = true, features = ["extern_crate_alloc"] } craft-image-codecs = { workspace = true } -craft-psd = { git = "https://github.com/storytold/craft-libs", rev = "aa401985dd4658cdaa272fdccafdcd6e7f4dd60b" } +craft-psd = { git = "https://github.com/storytold/craft-libs", rev = "8fa4db64a9bb943520259ea95331a303ba788f21" } flate2 = { workspace = true } half = { workspace = true } quick-xml = { workspace = true } From 0e1877647064007221b81cfc83b1cdc78fd65f3b Mon Sep 17 00:00:00 2001 From: aiongg Date: Wed, 25 Nov 2026 20:09:39 +0000 Subject: [PATCH 56/83] Floating windows carry the running channel's app id --- crates/ui-egui/src/framework.rs | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/crates/ui-egui/src/framework.rs b/crates/ui-egui/src/framework.rs index e7509a6b..72c18e12 100644 --- a/crates/ui-egui/src/framework.rs +++ b/crates/ui-egui/src/framework.rs @@ -34,9 +34,6 @@ use crate::TextureCraftApp; #[cfg(not(target_arch = "wasm32"))] pub use craft_ui::shell::embed::before_ui; -/// The id every OS window of the app carries, as the desktop entry and the update app name it. -const APP_ID: &str = "ai.storyteller.texturecraft"; - /// The scripts of the interface languages, for the font stack. static SCRIPTS: I18nScripts = I18nScripts; @@ -47,7 +44,7 @@ fn ui_fonts() -> UiFonts<'static> { } fn install_with(ctx: &egui::Context, shell: ShellInfo, windows: Arc, frame: Option) -> Result<(), String> { - let mut spec = craft_ui::InstallSpec::new(shell, windows).app_id(APP_ID); + let mut spec = craft_ui::InstallSpec::new(shell, windows).app_id(crate::os_window::app_id()); if let Some(frame) = frame { spec = spec.frame(frame); } From 28a0d1a0ef0860d99ebd22222bc33bbd8736dce8 Mon Sep 17 00:00:00 2001 From: aiongg Date: Wed, 25 Nov 2026 21:08:06 +0000 Subject: [PATCH 57/83] Tab hides the UI only while bound to it; Enter drops a later Ctrl; a hidden update result shows again --- crates/ui-egui/src/framework.rs | 3 ++- crates/ui-egui/src/menus.rs | 4 +++- crates/ui-egui/src/updates_ui.rs | 2 ++ 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/crates/ui-egui/src/framework.rs b/crates/ui-egui/src/framework.rs index 72c18e12..572129a1 100644 --- a/crates/ui-egui/src/framework.rs +++ b/crates/ui-egui/src/framework.rs @@ -121,7 +121,8 @@ impl TextureCraftApp { Brightness::Dark | Brightness::MediumDark => craft_theme::Mode::Dark, }; let mut root = RootEnv::new().mode(mode).scale(Scale::new(scale)); - root.tab_toggles_chrome = true; + // Hide UI on another key leaves Tab to focus traversal and the shortcuts + root.tab_toggles_chrome = crate::keymap::shortcut_of(&self.ui.keymap, "ui.hideUi") == Some("Tab"); let app_modal = crate::docking::input_blocked(self, ctx).then_some(ViewportId::ROOT); FrameInput::new(root).commands(CommandInput::new().overrides(command_overrides())).host(Arc::clone(&self.framework_host)).app_modal(app_modal) } diff --git a/crates/ui-egui/src/menus.rs b/crates/ui-egui/src/menus.rs index a38cdf56..15cb2375 100644 --- a/crates/ui-egui/src/menus.rs +++ b/crates/ui-egui/src/menus.rs @@ -464,7 +464,9 @@ pub fn shortcuts(app: &mut TextureCraftApp, ctx: &egui::Context) { if taken { let escape = craft_ui::runtime::keys::escape_mods(ctx).filter(|_| key == Key::Escape); ctx.input_mut(|i| { - let modifiers = escape.map_or(i.modifiers, |held| Modifiers { shift: held.shift, alt: held.alt, ..Modifiers::NONE }); + // A submit's Enter had no Ctrl or Cmd; one that came down later in the pass is not its own + let (shift, alt) = escape.map_or((i.modifiers.shift, i.modifiers.alt), |held| (held.shift, held.alt)); + let modifiers = Modifiers { shift, alt, ..Modifiers::NONE }; i.events.insert(0, egui::Event::Key { key, physical_key: Some(key), pressed: true, repeat: false, modifiers }); }); } diff --git a/crates/ui-egui/src/updates_ui.rs b/crates/ui-egui/src/updates_ui.rs index 5fcc0b66..4305dd0f 100644 --- a/crates/ui-egui/src/updates_ui.rs +++ b/crates/ui-egui/src/updates_ui.rs @@ -110,6 +110,8 @@ pub(crate) fn show(app: &mut TextureCraftApp, ctx: &egui::Context) { dialogs.open(UpdateCheckDialog::new(env!("CARGO_PKG_VERSION"))); } else if !shows && dialogs.is_open::() { dialogs.cancel::(ctx); + // Hidden for the prompt, not dismissed: the outcome shows again after it + let _ = dialogs.take::(); } if let Some(dialog) = dialogs.get_mut::() { dialog.set_status(status); From 05d0fbf76e1e4e0e0a706e04ea00cd9b1fa3f02f Mon Sep 17 00:00:00 2001 From: aiongg Date: Wed, 25 Nov 2026 21:08:22 +0000 Subject: [PATCH 58/83] The clipboard test holds the test language lock --- crates/ui-egui/src/framework.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/crates/ui-egui/src/framework.rs b/crates/ui-egui/src/framework.rs index 572129a1..187d0de6 100644 --- a/crates/ui-egui/src/framework.rs +++ b/crates/ui-egui/src/framework.rs @@ -216,6 +216,7 @@ mod tests { /// from egui's input, so TextureCraft's own loop never sees it: the fired command reaches the layer clipboard once. #[test] fn fired_copy_and_paste_from_a_float_reach_the_layer_clipboard_once() { + let _language = crate::i18n::TEST_LANGUAGE.lock().unwrap_or_else(std::sync::PoisonError::into_inner); let session = texturecraft_engine::sample_session(256, 64).unwrap(); let mut h = Harness::builder().with_size(egui::vec2(1600.0, 960.0)).with_context_setup(install_headless).build_eframe(|cc| TextureCraftApp::new(cc, session)); From b3135dfaa22f092981cd66c2cec1e42445f03f17 Mon Sep 17 00:00:00 2001 From: vangel76 Date: Wed, 25 Nov 2026 21:37:35 +0100 Subject: [PATCH 59/83] Add a warp tool bar to the top bar While the selected fill projects through a warp, the top tool bar shows warp controls in place of the tool's own: transform tool settings (manipulator size, grid and angle steps), warp mode list, gizmo modes (move, rotate, scale, place on surface), object or world space, mirrors and resets. The frame gizmo shows only the handles of the chosen mode and snaps moves and turns to the steps while Ctrl is held. Reset frame takes keepCorners to restore the frame alone. --- crates/engine/src/warp_cmds.rs | 34 +- crates/engine/tests/it/fill_projections.rs | 24 ++ crates/ui-egui/src/frame_gizmo.rs | 152 +++++--- crates/ui-egui/src/frame_gizmo/frame_grab.rs | 16 + .../frame_gizmo/warp_toolbar/gizmo_mode.rs | 11 + .../frame_gizmo/warp_toolbar/gizmo_space.rs | 9 + .../src/frame_gizmo/warp_toolbar/mod.rs | 339 ++++++++++++++++++ .../src/frame_gizmo/warp_toolbar/snap.rs | 24 ++ .../frame_gizmo/warp_toolbar/warp_target.rs | 35 ++ .../warp_toolbar/warp_toolbar_settings.rs | 63 ++++ crates/ui-egui/src/projection_gizmo.rs | 2 +- crates/ui-egui/src/projection_gizmo/gizmo.rs | 5 + crates/ui-egui/src/state.rs | 4 + crates/ui-egui/src/toolbar.rs | 18 +- 14 files changed, 672 insertions(+), 64 deletions(-) create mode 100644 crates/ui-egui/src/frame_gizmo/warp_toolbar/gizmo_mode.rs create mode 100644 crates/ui-egui/src/frame_gizmo/warp_toolbar/gizmo_space.rs create mode 100644 crates/ui-egui/src/frame_gizmo/warp_toolbar/mod.rs create mode 100644 crates/ui-egui/src/frame_gizmo/warp_toolbar/snap.rs create mode 100644 crates/ui-egui/src/frame_gizmo/warp_toolbar/warp_target.rs create mode 100644 crates/ui-egui/src/frame_gizmo/warp_toolbar/warp_toolbar_settings.rs diff --git a/crates/engine/src/warp_cmds.rs b/crates/engine/src/warp_cmds.rs index 1669c2e0..452e41dc 100644 --- a/crates/engine/src/warp_cmds.rs +++ b/crates/engine/src/warp_cmds.rs @@ -4,8 +4,8 @@ use serde_json::Value; use texturecraft_core::{Decal, Projection}; use texturecraft_geom::Mesh; -use crate::commands::{CommandSpec, bad, has_layer}; -use crate::layer_cmds::{fill_target, placement_mut}; +use crate::commands::{CommandSpec, bad, boolp, has_layer}; +use crate::layer_cmds::{FillTarget, fill_target, placement_mut}; use crate::{Result, Session, cmd}; /// Reset frame's command id, the prefix of its errors @@ -17,7 +17,7 @@ pub fn specs() -> Vec { "Reset frame", [], None, - "{layer? | effect?: content or mask fill effect id} — a warp projection's frame back around the mesh, seen from the front, with its corners unpulled (Projection Depth and the other settings stay)", + "{layer? | effect?: content or mask fill effect id, keepCorners?: true keeps the corners where they are} — a warp projection's frame back around the mesh, seen from the front, with its corners unpulled unless `keepCorners` (Projection Depth and the other settings stay)", has_layer, reset_frame )] @@ -44,25 +44,33 @@ pub(crate) fn fitted_frame(mesh: &Mesh) -> Decal { /// A fitted frame's smallest side, relative to the mesh diagonal (a flat mesh still gets a frame) const SMALLEST_SIDE: f32 = 1e-3; +/// The frame and corners of the warp projection at `target`; `command` names it in the error of any other projection +fn warp_mut<'a>(s: &'a mut Session, target: FillTarget, command: &str) -> Result<(&'a mut Decal, &'a mut [[f32; 2]; 4])> { + match placement_mut(s, target)? { + (Projection::Warp { frame, corners, .. }, _) => Ok((frame, corners)), + _ => Err(bad(command, "the fill's projection is not a warp projection")), + } +} + fn reset_frame(s: &mut Session, p: &Value) -> Result { let target = fill_target(s, p, RESET_FRAME)?; + let keep_corners = boolp(p, "keepCorners").unwrap_or(false); let fitted = fitted_frame(&s.mesh); - let (Projection::Warp { frame, corners, .. }, _) = placement_mut(s, target)? else { - return Err(bad(RESET_FRAME, "the fill's projection is not a warp projection")); - }; + let (frame, corners) = warp_mut(s, target, RESET_FRAME)?; - // A frame already fitted with unpulled corners adds no undo step - if *frame == fitted && *corners == Projection::FRAME_CORNERS { + // A frame already fitted, with its corners unpulled or kept, adds no undo step + if *frame == fitted && (keep_corners || *corners == Projection::FRAME_CORNERS) { return Ok(Value::Null); } - s.edit("Reset frame", |s| { - let (Projection::Warp { frame, corners, .. }, _) = placement_mut(s, target)? else { - return Err(bad(RESET_FRAME, "the fill's projection is not a warp projection")); - }; + let label = if keep_corners { "Restore the global transformation" } else { "Reset frame" }; + s.edit(label, |s| { + let (frame, corners) = warp_mut(s, target, RESET_FRAME)?; *frame = fitted; - *corners = Projection::FRAME_CORNERS; + if !keep_corners { + *corners = Projection::FRAME_CORNERS; + } Ok(()) })?; Ok(Value::Null) diff --git a/crates/engine/tests/it/fill_projections.rs b/crates/engine/tests/it/fill_projections.rs index 1a16d2ca..d8a5d1d9 100644 --- a/crates/engine/tests/it/fill_projections.rs +++ b/crates/engine/tests/it/fill_projections.rs @@ -337,6 +337,30 @@ fn warp_projection_bends_to_its_corners_reaches_its_depth_and_resets_its_frame() assert!(execute(&mut s, "layer.fill.resetFrame", &json!({"layer": layer.0})).is_err(), "only a warp has a frame to reset"); } +/// Restore the global transformation refits a warp's frame and keeps its pulled corners, in one undo step, none when the frame is fitted +#[test] +fn a_warps_frame_resets_apart_from_its_corners() { + let mut s = session(); + let layer = checker_fill(&mut s); + set(&mut s, layer, json!({"projection": "warp"})); + let Projection::Warp { frame: fitted, .. } = projection(&s, layer) else { panic!("a warp") }; + let pulled = [[-0.5, 0.5], [0.9, 0.9], [0.5, -0.5], [-0.5, -0.5]]; + set(&mut s, layer, json!({"warpCorners": pulled})); + execute(&mut s, "layer.decal.set", &json!({"layer": layer.0, "rotation": 30})).unwrap(); + let steps = s.history_labels().len(); + + execute(&mut s, "layer.fill.resetFrame", &json!({"layer": layer.0, "keepCorners": true})).unwrap(); + let Projection::Warp { frame, corners, .. } = projection(&s, layer) else { panic!("a warp") }; + + assert_eq!(frame, fitted, "the frame goes back around the mesh"); + assert_eq!(corners, pulled, "the pulled corners stay"); + assert_eq!(s.history_labels().len(), steps + 1); + + execute(&mut s, "layer.fill.resetFrame", &json!({"layer": layer.0, "keepCorners": true})).unwrap(); + + assert_eq!(s.history_labels().len(), steps + 1, "a fitted frame adds no undo step"); +} + /// Depth culling keeps planar and warp projections off surfaces hidden behind others from the projector; new ones start with it on, older saves without it #[test] fn depth_culling_keeps_planar_and_warp_projections_off_hidden_surfaces() { diff --git a/crates/ui-egui/src/frame_gizmo.rs b/crates/ui-egui/src/frame_gizmo.rs index 6dd6bd18..93a5f724 100644 --- a/crates/ui-egui/src/frame_gizmo.rs +++ b/crates/ui-egui/src/frame_gizmo.rs @@ -5,8 +5,8 @@ use serde_json::{Value, json}; use texturecraft_engine::compose::axis_frame::{placed_from_axis, placing_moves_pattern}; use texturecraft_engine::compose::frame_placement::folded; use texturecraft_engine::compose::pattern::{decal_axes, decal_corners}; -use texturecraft_engine::core::{Decal, EffectKind, Fill, LayerId, LayerKind, Projection}; -use texturecraft_engine::geom::glam::Vec3; +use texturecraft_engine::core::{Decal, EffectKind, Fill, LayerId, LayerKind, Projection, Source}; +use texturecraft_engine::geom::glam::{Vec2, Vec3}; use crate::TextureCraftApp; use crate::projection_gizmo::{Gizmo, dragging}; @@ -14,8 +14,10 @@ use crate::theme::{AXIS_COLORS, SHAFT_HALO, SHAFT_HALO_EXTRA_WIDTH, SHAFT_WIDTH, use crate::viewport::{project, view_ray}; mod frame_grab; +pub(crate) mod warp_toolbar; pub(crate) use frame_grab::FrameGrab; +use warp_toolbar::{GizmoSpace, WarpToolbarSettings, to_step}; /// The selected fill's frame as the 3D view shows it #[derive(Clone, Copy, Debug)] @@ -35,11 +37,16 @@ pub(crate) struct FrameGizmo { pub arrows: [Option; 3], /// On screen, the turn ring round the centre in the frame's plane (None when it is edge on) pub ring: Option<[Pos2; TURN_RING_POINTS]>, + /// A warp's tool bar settings: which handles show, their size and snapping, and the space the arrows move in + pub tools: Option, /// In the world: the frame's centre, and its across, up and out directions origin: Vec3, axes: [Vec3; 3], /// Screen movement per world unit along each direction at the centre steps: [Option; 3], + /// The directions the arrows move along (the frame's own, or the world's in World space) and their screen movement per world unit + move_axes: [Vec3; 3], + move_steps: [Option; 3], } /// Screen length of the axis arrows, and their heads (points): long enough to grab each one apart from the others @@ -69,32 +76,7 @@ impl FrameGizmo { /// The frame of the selected fill layer, or of the selected mask fill effect, with a planar or warp projection pub(crate) fn of(app: &TextureCraftApp, rect: Rect) -> Option { - use texturecraft_engine::StackTarget; - - if app.ui.mode != crate::state::Mode::Painting { - return None; - } - - let layers = &app.session.doc.project; - let selected = app.session.selected_layer()?; - let (layer, effect, projection, sources) = match app.session.target { - StackTarget::Content => { - let layer = layers.content_layer(selected)?; - let LayerKind::Fill(Fill { projection, sources, .. }) = &layer.kind else { return None }; - - (layer.id, None, projection, sources.values().collect::>()) - } - StackTarget::Effect(effect) => { - // Only the selected layer's effective mask may supply a frame, including an instance's inherited mask - let owner = layers.mask_owner(selected); - let mask = layers.layer(owner).ok()?.mask.as_ref()?; - let mask_effect = mask.effects.iter().find(|candidate| candidate.id == effect)?; - let EffectKind::Fill { projection, source, .. } = &mask_effect.kind else { return None }; - - (owner, Some(effect), projection, vec![source]) - } - StackTarget::Mask => return None, - }; + let (layer, effect, projection, sources) = selected_fill_projection(app)?; // An axis planar reading a pattern keeps its axis (see [`placing_moves_pattern`]): it has no frame to move let unplaced = matches!(projection, Projection::Planar { placed: None, .. }); @@ -126,11 +108,21 @@ impl FrameGizmo { let sides = [0, 1, 2, 3].map(|side| corners[side].lerp(corners[(side + 1) % 4], 0.5)); let center = project(app, rect, origin)?; - // Screen movement per world unit along each direction, and an arrow along each one not pointing at the camera + // A warp follows the tool bar: its size scales the arrows and ring, its space picks the directions the arrows move along + let tools = warp.map(|_| app.ui.warp_toolbar); + let scale = tools.map_or(1.0, |tools| tools.gizmo_scale()); + + // Screen movement per world unit along each direction, and an arrow along each moving one not pointing at the camera let reach = decal.size[0].max(decal.size[1]); let axes = [across, up, out]; - let steps = axes.map(|axis| Some((project(app, rect, origin + axis * reach)? - center) / reach.max(f32::MIN_POSITIVE))); - let arrows = steps.map(|step| step.filter(|step| step.length() * reach > MIN_SCREEN_SPAN).map(|step| center + step.normalized() * ARROW)); + let move_axes = match tools { + Some(tools) if tools.space == GizmoSpace::World => [Vec3::X, Vec3::Y, Vec3::Z], + _ => axes, + }; + let step_along = |axis: Vec3| Some((project(app, rect, origin + axis * reach)? - center) / reach.max(f32::MIN_POSITIVE)); + let steps = axes.map(step_along); + let move_steps = move_axes.map(step_along); + let arrows = move_steps.map(|step| step.filter(|step| step.length() * reach > MIN_SCREEN_SPAN).map(|step| center + step.normalized() * ARROW * scale)); // The turn ring, unless the frame is seen too near edge on to grab it let ring = steps[0] @@ -139,7 +131,7 @@ impl FrameGizmo { across_step.length() > f32::EPSILON && solve(*across_step, *up_step, egui::Vec2::X).is_some() && ring_open(app, rect, center, out) }) .and_then(|(step, _)| { - let radius = TURN_RING / step.length(); + let radius = TURN_RING * scale / step.length(); let last = (TURN_RING_POINTS - 1) as f32; let points = (0..TURN_RING_POINTS).map(|index| { let (sin, cos) = (index as f32 / last * std::f32::consts::TAU).sin_cos(); @@ -148,7 +140,7 @@ impl FrameGizmo { points.collect::>>()?.try_into().ok() }); - Some(FrameGizmo { layer, effect, decal, warp, corners, sides, center, arrows, ring, origin, axes, steps }) + Some(FrameGizmo { layer, effect, decal, warp, corners, sides, center, arrows, ring, tools, origin, axes, steps, move_axes, move_steps }) } /// The frame's offset after sliding it across its plane by screen movement `delta` (None when the frame is edge-on) @@ -157,6 +149,16 @@ impl FrameGizmo { Some(self.slid(across, up)) } + /// The tool bar's grid step and angle step (0: no snapping) while a drag snaps + fn snap_steps(&self, snapping: bool) -> (f32, f32) { + self.tools.filter(|_| snapping).map_or((0.0, 0.0), |tools| (tools.grid_step(), tools.angle_step())) + } + + /// Whether the tool bar's mode offers `grab` (a planar's frame, with no tool bar, offers every handle but Place on surface's) + fn offers(&self, grab: FrameGrab) -> bool { + self.tools.map_or(grab != FrameGrab::Place, |tools| grab.offered_in(tools.mode)) + } + /// Where screen point `p` meets the frame's plane, across and up in frame sizes from its centre fn on_plane(&self, app: &TextureCraftApp, rect: Rect, p: Pos2) -> Option<[f32; 2]> { let ray = view_ray(app, rect, p); @@ -178,6 +180,36 @@ impl FrameGizmo { } } +/// The selected fill layer's (or selected mask fill effect's) projection with the layer, the effect and the sources it reads: none outside painting mode +pub(crate) fn selected_fill_projection(app: &TextureCraftApp) -> Option<(LayerId, Option, &Projection, Vec<&Source>)> { + use texturecraft_engine::StackTarget; + + if app.ui.mode != crate::state::Mode::Painting { + return None; + } + + let layers = &app.session.doc.project; + let selected = app.session.selected_layer()?; + match app.session.target { + StackTarget::Content => { + let layer = layers.content_layer(selected)?; + let LayerKind::Fill(Fill { projection, sources, .. }) = &layer.kind else { return None }; + + Some((layer.id, None, projection, sources.values().collect::>())) + } + StackTarget::Effect(effect) => { + // Only the selected layer's effective mask may supply a frame, including an instance's inherited mask + let owner = layers.mask_owner(selected); + let mask = layers.layer(owner).ok()?.mask.as_ref()?; + let mask_effect = mask.effects.iter().find(|candidate| candidate.id == effect)?; + let EffectKind::Fill { projection, source, .. } = &mask_effect.kind else { return None }; + + Some((owner, Some(effect), projection, vec![source])) + } + StackTarget::Mask => None, + } +} + /// Half a turn in degrees: a ring drag's sweep is kept within one either way const HALF_TURN: f32 = 180.0; @@ -255,7 +287,10 @@ impl Gizmo for FrameGizmo { if let Some(ring) = &self.ring { handles.push((FrameGrab::Turn, ring.windows(2).map(|pair| distance_to_segment(at, pair[0], pair[1])).fold(f32::INFINITY, f32::min))); } - nearest(handles) + + // Place on surface takes any press the handles do not: just within reach, so a nearer corner wins + handles.push((FrameGrab::Place, GRAB)); + nearest(handles.into_iter().filter(|(grab, _)| self.offers(*grab))) } fn same_projection(&self, other: &FrameGizmo) -> bool { @@ -264,17 +299,27 @@ impl Gizmo for FrameGizmo { /// The command and params a drag of `grab` from `from` to `to` runs fn edit(&self, app: &TextureCraftApp, rect: Rect, grab: FrameGrab, from: Pos2, to: Pos2) -> Option<(&'static str, Value)> { + self.edit_with_snap(app, rect, grab, from, to, false) + } + + /// As [`Gizmo::edit`]; with `snapping` a warp's moves and turns jump by the tool bar's grid and angle steps + fn edit_with_snap(&self, app: &TextureCraftApp, rect: Rect, grab: FrameGrab, from: Pos2, to: Pos2, snapping: bool) -> Option<(&'static str, Value)> { let delta = to - from; let center = self.center; + let (grid_step, angle_step) = self.snap_steps(snapping); + let world = self.tools.is_some_and(|tools| tools.space == GizmoSpace::World); let mut params = match grab { - FrameGrab::Slide => json!({"offset": self.slid_on_screen(delta)?}), + FrameGrab::Slide => { + let [across, up] = solve(self.steps[0]?, self.steps[1]?, delta)?; + json!({"offset": self.slid(to_step(across, grid_step), to_step(up, grid_step))}) + } FrameGrab::Axis(axis) => { - let step = (*self.steps.get(axis)?)?; - let distance = delta.dot(step) / step.length_sq().max(f32::MIN_POSITIVE); + let step = (*self.move_steps.get(axis)?)?; + let distance = to_step(delta.dot(step) / step.length_sq().max(f32::MIN_POSITIVE), grid_step); match axis { - 0 => json!({"offset": self.slid(distance, 0.0)}), - 1 => json!({"offset": self.slid(0.0, distance)}), - _ => json!({"position": (self.origin + self.axes[2] * distance).to_array(), "normal": self.axes[2].to_array()}), + 0 if !world => json!({"offset": self.slid(distance, 0.0)}), + 1 if !world => json!({"offset": self.slid(0.0, distance)}), + _ => json!({"position": (self.origin + self.move_axes[axis] * distance).to_array(), "normal": self.axes[2].to_array()}), } } FrameGrab::Scale => { @@ -288,12 +333,18 @@ impl Gizmo for FrameGizmo { size[1 - side % 2] *= stretch; json!({"size": size}) } + FrameGrab::Place => { + // Off the model the frame waits where it last touched it + let on_view = to - rect.min; + let hit = app.session.pick(Vec2::new(on_view.x, on_view.y), app.session.viewport)?; + json!({"position": hit.pos.to_array(), "normal": hit.nrm.to_array()}) + } FrameGrab::Turn => { // Measure the turn in the frame's own plane so a tilted frame follows the pointer let angle = |p: Pos2| self.on_plane(app, rect, p).map(|[across, up]| (up * self.decal.size[1]).atan2(across * self.decal.size[0]).to_degrees()); let swept = angle(to)? - angle(from)?; let swept = (swept + HALF_TURN).rem_euclid(2.0 * HALF_TURN) - HALF_TURN; - json!({"rotation": self.decal.rotation + swept}) + json!({"rotation": self.decal.rotation + to_step(swept, angle_step)}) } FrameGrab::Corner(corner) => { let mut corners = self.warp?; @@ -328,7 +379,7 @@ pub(crate) fn overlay(ui: &Ui, rect: Rect, gizmo: &FrameGizmo) { let mut outline = gizmo.corners.to_vec(); outline.push(gizmo.corners[0]); dashed_outline(&painter, &outline); - if let Some(ring) = &gizmo.ring { + if let Some(ring) = gizmo.ring.as_ref().filter(|_| gizmo.offers(FrameGrab::Turn)) { let color = if lit(FrameGrab::Turn) { tokens.viewport_accent } else { AXIS_COLORS[2] }; painter.add(egui::Shape::line(ring.to_vec(), Stroke::new(SHAFT_WIDTH + SHAFT_HALO_EXTRA_WIDTH, SHAFT_HALO))); painter.add(egui::Shape::line(ring.to_vec(), Stroke::new(SHAFT_WIDTH, color))); @@ -345,12 +396,14 @@ pub(crate) fn overlay(ui: &Ui, rect: Rect, gizmo: &FrameGizmo) { } } } - for (index, side) in gizmo.sides.into_iter().enumerate() { + for (index, side) in gizmo.sides.into_iter().enumerate().filter(|(index, _)| gizmo.offers(FrameGrab::Side(*index))) { handle_dot(&painter, side, SIDE_DOT, dot_fill(FrameGrab::Side(index))); } let arrow_color = |axis: usize| if lit(FrameGrab::Axis(axis)) { tokens.viewport_accent } else { AXIS_COLORS[axis] }; - move_handles(&painter, gizmo.center, gizmo.arrows, arrow_color, dot_fill(FrameGrab::Slide)); + if gizmo.offers(FrameGrab::Slide) { + move_handles(&painter, gizmo.center, gizmo.arrows, arrow_color, dot_fill(FrameGrab::Slide)); + } } /// The centre square (filled `square`) with its X/Y/Z arrows to `arrows`, coloured by `arrow_color`; shafts and heads over a dark halo like the symmetry manipulator's @@ -409,6 +462,7 @@ pub(crate) mod tests { use texturecraft_engine::core::{LayerId, LayerKind, Projection}; use super::*; + use crate::frame_gizmo::warp_toolbar::GizmoMode; /// The test window: big enough that the docked panels leave the 3D view room for the ball with every gizmo handle round it const TEST_WINDOW: egui::Vec2 = vec2(1600.0, 960.0); @@ -423,6 +477,12 @@ pub(crate) mod tests { harness } + /// A warp's gizmo in `mode`, as the tool bar's buttons set it (a planar's has no modes) + pub(crate) fn show_handles(harness: &mut egui_kittest::Harness<'_, TextureCraftApp>, mode: GizmoMode) { + harness.state_mut().ui.warp_toolbar.mode = mode; + harness.run_steps(2); + } + /// The ball with a selected fill layer projecting `projection` pub(crate) fn fill_app(projection: &str) -> (egui_kittest::Harness<'static, TextureCraftApp>, LayerId) { fill_app_with(json!({"projection": projection})) @@ -519,7 +579,7 @@ pub(crate) mod tests { ["X", "Y", "Z"].map(|tag| harness.get_by_label(&format!("{row} {tag}")).accesskit_node().numeric_value().unwrap() as f32) } - fn gizmo(harness: &egui_kittest::Harness<'_, TextureCraftApp>) -> FrameGizmo { + pub(crate) fn gizmo(harness: &egui_kittest::Harness<'_, TextureCraftApp>) -> FrameGizmo { FrameGizmo::of(harness.state(), harness.state().viewport_rect).unwrap() } @@ -645,6 +705,7 @@ pub(crate) mod tests { let _language = crate::i18n::TEST_LANGUAGE.lock().unwrap_or_else(std::sync::PoisonError::into_inner); for kind in ["warp", "planar"] { let (mut harness, _) = fill_app(kind); + show_handles(&mut harness, GizmoMode::Rotate); let start = gizmo(&harness); let ring = start.ring.unwrap_or_else(|| panic!("{kind}: a frame facing the camera shows its ring")); let on_ring = *ring @@ -667,6 +728,7 @@ pub(crate) mod tests { } let (mut harness, layer) = fill_app("warp"); + show_handles(&mut harness, GizmoMode::Scale); let warp = gizmo(&harness); assert_eq!(warp.grab(warp.sides[1]), Some(FrameGrab::Side(1))); diff --git a/crates/ui-egui/src/frame_gizmo/frame_grab.rs b/crates/ui-egui/src/frame_gizmo/frame_grab.rs index a0733168..2d31d18d 100644 --- a/crates/ui-egui/src/frame_gizmo/frame_grab.rs +++ b/crates/ui-egui/src/frame_gizmo/frame_grab.rs @@ -1,3 +1,5 @@ +use super::warp_toolbar::GizmoMode; + /// What a drag on the frame does #[derive(Clone, Copy, Debug, PartialEq)] pub(crate) enum FrameGrab { @@ -13,15 +15,29 @@ pub(crate) enum FrameGrab { Corner(usize), /// The ring: turn it round its normal Turn, + /// Place on surface: anywhere over the model puts the frame where the pointer touches it + Place, } impl FrameGrab { + /// Whether a warp's gizmo in `mode` offers this handle: its corners stay in every mode + pub(super) fn offered_in(self, mode: GizmoMode) -> bool { + match self { + FrameGrab::Slide | FrameGrab::Axis(_) => mode == GizmoMode::Move, + FrameGrab::Turn => mode == GizmoMode::Rotate, + FrameGrab::Side(_) => mode == GizmoMode::Scale, + FrameGrab::Place => mode == GizmoMode::PlaceOnSurface, + FrameGrab::Scale | FrameGrab::Corner(_) => true, + } + } + pub(super) fn cursor(self, dragging: bool) -> egui::CursorIcon { match self { FrameGrab::Slide if dragging => egui::CursorIcon::Grabbing, FrameGrab::Slide => egui::CursorIcon::Grab, FrameGrab::Axis(_) | FrameGrab::Corner(_) | FrameGrab::Turn => egui::CursorIcon::Move, FrameGrab::Scale => egui::CursorIcon::ResizeNwSe, + FrameGrab::Place => egui::CursorIcon::Crosshair, FrameGrab::Side(side) if side % 2 == 0 => egui::CursorIcon::ResizeVertical, FrameGrab::Side(_) => egui::CursorIcon::ResizeHorizontal, } diff --git a/crates/ui-egui/src/frame_gizmo/warp_toolbar/gizmo_mode.rs b/crates/ui-egui/src/frame_gizmo/warp_toolbar/gizmo_mode.rs new file mode 100644 index 00000000..e7c3b50a --- /dev/null +++ b/crates/ui-egui/src/frame_gizmo/warp_toolbar/gizmo_mode.rs @@ -0,0 +1,11 @@ +use serde::{Deserialize, Serialize}; + +/// What a warp's frame gizmo does: Move shows the arrows and centre square, Rotate the turn ring, Scale the edge dots that size the frame; Place on surface puts the frame where a drag over the model touches it +#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Serialize, Deserialize)] +pub enum GizmoMode { + #[default] + Move, + Rotate, + Scale, + PlaceOnSurface, +} diff --git a/crates/ui-egui/src/frame_gizmo/warp_toolbar/gizmo_space.rs b/crates/ui-egui/src/frame_gizmo/warp_toolbar/gizmo_space.rs new file mode 100644 index 00000000..a33269d7 --- /dev/null +++ b/crates/ui-egui/src/frame_gizmo/warp_toolbar/gizmo_space.rs @@ -0,0 +1,9 @@ +use serde::{Deserialize, Serialize}; + +/// The directions a warp's move arrows follow: the frame's own, or the world's +#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Serialize, Deserialize)] +pub enum GizmoSpace { + #[default] + Object, + World, +} diff --git a/crates/ui-egui/src/frame_gizmo/warp_toolbar/mod.rs b/crates/ui-egui/src/frame_gizmo/warp_toolbar/mod.rs new file mode 100644 index 00000000..22987e6b --- /dev/null +++ b/crates/ui-egui/src/frame_gizmo/warp_toolbar/mod.rs @@ -0,0 +1,339 @@ +//! The warp controls of the top tool bar while the selected fill projects through a warp, in place of the tool's own: the transform tool's settings, the warp mode, the gizmo's mode and space, the mirrors and the resets + +mod gizmo_mode; +mod gizmo_space; +mod snap; +mod warp_target; +mod warp_toolbar_settings; + +use egui::Ui; +use egui_phosphor::regular as ic; +use serde_json::json; + +pub use gizmo_mode::GizmoMode; +pub use gizmo_space::GizmoSpace; +pub(crate) use snap::to_step; +pub use warp_toolbar_settings::WarpToolbarSettings; + +use crate::TextureCraftApp; +use crate::i18n::tr; +use crate::widgets::{icon_button, icon_dropdown_button, slider}; +use texturecraft_engine::core::Projection; +use warp_target::WarpTarget; +use warp_toolbar_settings::{ANGLE_STEPS, GRID_STEPS, MANIPULATOR_SIZES}; + +/// The width of the settings popup (points) +const POPUP_WIDTH: f32 = 220.0; + +/// The gizmo mode buttons: mode, icon, label +const MODES: [(GizmoMode, &str, &str); 4] = [ + (GizmoMode::Move, ic::ARROWS_OUT_CARDINAL, "Move"), + (GizmoMode::Rotate, ic::ARROWS_CLOCKWISE, "Rotate"), + (GizmoMode::Scale, ic::CORNERS_OUT, "Scale"), + (GizmoMode::PlaceOnSurface, ic::ARROW_LINE_DOWN, "Place on surface"), +]; + +/// The warp modes the bar lists; only the first works until the warp has a grid of vertices +const WARP_MODES: [&str; 5] = ["Transform warp", "Edit vertices", "Split warp crosswise", "Split warp horizontally", "Split warp vertically"]; + +/// Why the warp modes past the first and the vertex reset are greyed out +const NEEDS_GRID: &str = "Needs the warp grid, which is not available yet"; + +/// Whether the selected fill projects through a warp, so the top tool bar shows the warp controls +pub(crate) fn shown(app: &TextureCraftApp) -> bool { + WarpTarget::of(app).is_some() +} + +/// The warp controls of the top tool bar, left to right +pub(crate) fn controls(app: &mut TextureCraftApp, ui: &mut Ui) { + let Some(target) = WarpTarget::of(app) else { return }; + let size = ui.spacing().interact_size.y; + + // The only tool there is, so it stays on + icon_button(ui, ic::BOUNDING_BOX, tr("Transform tool"), true, size); + manipulator_settings(app, ui, size); + warp_mode(ui); + ui.separator(); + + let current = app.ui.warp_toolbar.mode; + for (mode, icon, label) in MODES { + if icon_button(ui, icon, tr(label), current == mode, size).clicked() { + app.ui.warp_toolbar.mode = mode; + } + } + gizmo_space(app, ui); + ui.separator(); + + for (axis, icon, label, field) in [(0, ic::FLIP_HORIZONTAL, "Mirror horizontally", "flipU"), (1, ic::FLIP_VERTICAL, "Mirror vertically", "flipV")] { + if icon_button(ui, icon, tr(label), target.flip[axis], size).clicked() { + let mut fields = json!({}); + fields[field] = json!(!target.flip[axis]); + app.run("layer.decal.set", target.params(fields)); + } + } + resets(app, ui, &target); +} + +/// The settings popup of the transform tool: the gizmo's size and the steps its drags snap to +fn manipulator_settings(app: &mut TextureCraftApp, ui: &mut Ui, size: f32) { + let popup_id = ui.make_persistent_id("warp_manipulator_settings"); + let open = egui::Popup::is_id_open(ui.ctx(), popup_id); + let response = icon_dropdown_button(ui, ic::GEAR, tr("Manipulator settings"), open, size); + let response = if open { response } else { response.on_hover_text(tr("Manipulator settings")) }; + + // Sliders sit in the popup, so a click inside must not close it + egui::Popup::menu(&response).id(popup_id).close_behavior(egui::PopupCloseBehavior::CloseOnClickOutside).show(|ui| { + ui.set_width(POPUP_WIDTH); + ui.label(egui::RichText::new(tr("MANIPULATOR SETTINGS")).strong()); + + let settings = &mut app.ui.warp_toolbar; + slider(ui, tr("Manipulator size"), &mut settings.manipulator_size, MANIPULATOR_SIZES, 2); + slider(ui, tr("Grid steps"), &mut settings.grid_steps, GRID_STEPS, 2).on_hover_text(tr("Hold Ctrl while dragging to move in these steps")); + slider(ui, tr("Angle steps"), &mut settings.angle_steps, ANGLE_STEPS, 0).on_hover_text(tr("Hold Ctrl while dragging to turn in these steps")); + }); +} + +/// The warp mode list: Transform warp works; the others wait for the warp grid +fn warp_mode(ui: &mut Ui) { + icon_dropdown(ui, "warp_mode", ic::FRAME_CORNERS, tr(WARP_MODES[0]), |ui| { + for (index, label) in WARP_MODES.into_iter().enumerate() { + let unavailable = (index > 0).then(|| tr(NEEDS_GRID)); + menu_row(ui, tr(label), index == 0, unavailable); + } + }); +} + +/// Object space or World space: the directions the move arrows follow +fn gizmo_space(app: &mut TextureCraftApp, ui: &mut Ui) { + let spaces = [(GizmoSpace::Object, ic::CUBE, "Object space"), (GizmoSpace::World, ic::GLOBE, "World space")]; + let current = app.ui.warp_toolbar.space; + let (_, icon, label) = spaces.iter().find(|(space, ..)| *space == current).unwrap_or(&spaces[0]); + let mut chosen = None; + icon_dropdown(ui, "warp_space", icon, tr(label), |ui| { + for (space, _, label) in spaces { + if menu_row(ui, tr(label), current == space, None) { + chosen = Some(space); + } + } + }); + + if let Some(space) = chosen { + app.ui.warp_toolbar.space = space; + } +} + +/// The reset list: the frame back around the mesh, or the corners back on the frame +fn resets(app: &mut TextureCraftApp, ui: &mut Ui, target: &WarpTarget) { + let mut command = None; + icon_dropdown(ui, "warp_reset", ic::ARROW_COUNTER_CLOCKWISE, tr("Reset"), |ui| { + if menu_row(ui, tr("Restore the global transformation"), false, None) { + command = Some(("layer.fill.resetFrame", json!({"keepCorners": true}))); + } + if menu_row(ui, tr("Reset all vertices"), false, None) { + command = Some(("layer.fill.projection", json!({"warpCorners": Projection::FRAME_CORNERS}))); + } + + // Vertices cannot be selected before the warp has a grid + menu_row(ui, tr("Reset selected vertices"), false, Some(tr(NEEDS_GRID))); + }); + + if let Some((id, fields)) = command { + app.run(id, target.params(fields)); + } +} + +/// An icon button with a caret that opens `menu` below it, highlighted while open +fn icon_dropdown(ui: &mut Ui, id_salt: &str, icon: &str, tooltip: &str, menu: impl FnOnce(&mut Ui)) { + let popup_id = ui.make_persistent_id(id_salt); + let open = egui::Popup::is_id_open(ui.ctx(), popup_id); + let mut response = icon_dropdown_button(ui, icon, tooltip, open, ui.spacing().interact_size.y); + if !open { + response = response.on_hover_text(tooltip); + } + + egui::Popup::menu(&response).id(popup_id).show(menu); +} + +/// One list entry; `unavailable` greys it out and says why on hover. Returns true when clicked +fn menu_row(ui: &mut Ui, label: &str, selected: bool, unavailable: Option<&str>) -> bool { + let response = ui.add_enabled(unavailable.is_none(), egui::Button::new(label).selected(selected)); + if let Some(reason) = unavailable { + response.on_disabled_hover_text(reason); + return false; + } + + response.clicked() +} + +#[cfg(test)] +mod tests { + use egui::{Modifiers, Pos2, vec2}; + use egui_kittest::Harness; + use egui_kittest::kittest::Queryable; + use serde_json::json; + use texturecraft_engine::core::Projection; + use texturecraft_engine::geom::glam::{Vec2, Vec3}; + + use super::*; + use crate::frame_gizmo::FrameGrab; + use crate::frame_gizmo::tests::{drag, fill_app, gizmo, projection}; + use crate::projection_gizmo::Gizmo; + + fn click_label(harness: &mut Harness<'_, TextureCraftApp>, label: &str) { + harness.get_by_label(label).click(); + harness.run_steps(2); + } + + /// The warp's frame and corners + fn warp_parts(harness: &Harness<'_, TextureCraftApp>, layer: texturecraft_engine::core::LayerId) -> (texturecraft_engine::core::Decal, [[f32; 2]; 4]) { + let Projection::Warp { frame, corners, .. } = projection(harness, layer) else { panic!("a warp") }; + (frame, corners) + } + + #[test] + fn the_bar_shows_for_a_warp_fill_only() { + let _language = crate::i18n::TEST_LANGUAGE.lock().unwrap_or_else(std::sync::PoisonError::into_inner); + let (mut harness, layer) = fill_app("warp"); + + assert!(harness.query_by_label("Transform tool").is_some()); + + harness.state_mut().run("layer.fill.projection", json!({"layer": layer.0, "projection": "planar"})); + harness.run_steps(2); + + assert!(harness.query_by_label("Transform tool").is_none(), "a planar frame has no warp tools"); + + let away = harness.state().viewport_rect.left_bottom() + vec2(10.0, -10.0); + assert_eq!(gizmo(&harness).grab(away), None, "a planar frame has no Place on surface"); + } + + #[test] + fn each_mode_offers_only_its_handles() { + let _language = crate::i18n::TEST_LANGUAGE.lock().unwrap_or_else(std::sync::PoisonError::into_inner); + let (mut harness, _) = fill_app("warp"); + let start = gizmo(&harness); + let ring_point = *start.ring.as_ref().expect("a frame facing the camera shows its ring").iter().max_by(|a, b| a.y.total_cmp(&b.y)).unwrap(); + let handles: [(FrameGrab, Pos2, GizmoMode); 4] = [ + (FrameGrab::Slide, start.center, GizmoMode::Move), + (FrameGrab::Axis(0), start.arrows[0].unwrap(), GizmoMode::Move), + (FrameGrab::Turn, ring_point, GizmoMode::Rotate), + (FrameGrab::Side(1), start.sides[1], GizmoMode::Scale), + ]; + + for (_, _, label) in MODES { + click_label(&mut harness, label); + let shown = gizmo(&harness); + let mode = shown.tools.unwrap().mode; + + for (grab, at, offered_in) in handles { + assert_eq!(shown.grab(at) == Some(grab), mode == offered_in, "{grab:?} in {mode:?}"); + } + + assert_eq!(shown.grab(shown.corners[1]), Some(FrameGrab::Corner(1)), "a warp's corners stay in {mode:?}"); + } + } + + #[test] + fn place_on_surface_puts_the_frame_where_the_pointer_touches_the_model() { + let _language = crate::i18n::TEST_LANGUAGE.lock().unwrap_or_else(std::sync::PoisonError::into_inner); + let (mut harness, layer) = fill_app("warp"); + let rect = harness.state().viewport_rect; + let middle = crate::viewport::project(harness.state(), rect, Vec3::ZERO).unwrap(); + let (from, onto) = (middle + vec2(30.0, 20.0), middle + vec2(-60.0, -40.0)); + let steps = harness.state().session.history_labels().len(); + let (before, corners_before) = warp_parts(&harness, layer); + click_label(&mut harness, "Place on surface"); + + drag(&mut harness, from, onto, Modifiers::NONE); + + let (placed, corners) = warp_parts(&harness, layer); + let on_view = onto - rect.min; + let hit = harness.state().session.pick(Vec2::new(on_view.x, on_view.y), harness.state().session.viewport).expect("the model is under the pointer"); + assert!(Vec3::from(placed.center).distance(hit.pos) < 1e-2, "the frame centre sits at the surface hit: {:?} {:?}", placed.center, hit.pos); + assert!(Vec3::from(placed.normal).dot(hit.nrm) > 0.99, "the frame faces along the surface normal"); + assert_eq!((placed.size, placed.rotation, corners), (before.size, before.rotation, corners_before), "its size, rotation and corners stay"); + assert_eq!(harness.state().session.history_labels().len(), steps + 1, "one undo step per drag"); + + // Past the model's edge the frame waits where it last touched it + drag(&mut harness, onto, rect.left_bottom() + vec2(10.0, -10.0), Modifiers::NONE); + + let (waiting, _) = warp_parts(&harness, layer); + assert!((Vec3::from(waiting.center).length() - 1.0).abs() < 0.05, "still on the ball: {:?}", waiting.center); + } + + #[test] + fn world_space_arrows_ignore_the_frames_turn() { + let _language = crate::i18n::TEST_LANGUAGE.lock().unwrap_or_else(std::sync::PoisonError::into_inner); + let (mut harness, layer) = fill_app("warp"); + let turn = |harness: &mut Harness<'_, TextureCraftApp>| { + harness.state_mut().run("layer.decal.set", json!({"layer": layer.0, "rotation": 30})); + harness.run_steps(2); + }; + let arrow = |harness: &Harness<'_, TextureCraftApp>| { + let shown = gizmo(harness); + (shown.arrows[0].unwrap() - shown.center).normalized() + }; + let frame_arrow = arrow(&harness); + turn(&mut harness); + + assert!(arrow(&harness).dot(frame_arrow) < 0.95, "an object space arrow turns with the frame"); + + harness.state_mut().run("layer.decal.set", json!({"layer": layer.0, "rotation": 0})); + click_label(&mut harness, "Object space"); + click_label(&mut harness, "World space"); + let world_arrow = arrow(&harness); + turn(&mut harness); + + assert!(arrow(&harness).dot(world_arrow) > 0.999, "a world space arrow stays on its world axis"); + } + + #[test] + fn holding_ctrl_moves_in_whole_grid_steps() { + let _language = crate::i18n::TEST_LANGUAGE.lock().unwrap_or_else(std::sync::PoisonError::into_inner); + let (mut harness, layer) = fill_app("warp"); + let grid_step = harness.state().ui.warp_toolbar.grid_step(); + let start = gizmo(&harness); + let tip = start.arrows[0].unwrap(); + let along = (tip - start.center).normalized(); + + drag(&mut harness, tip, tip + along * 37.0, Modifiers::COMMAND); + + let (frame, _) = warp_parts(&harness, layer); + let steps = frame.offset[0] / grid_step; + assert!(frame.offset[0].abs() > 1e-3 && (steps - steps.round()).abs() < 1e-3, "moved by whole steps of {grid_step}: {:?}", frame.offset); + } + + #[test] + fn the_mirror_and_reset_buttons_edit_the_warp_in_one_undo_step_each() { + let _language = crate::i18n::TEST_LANGUAGE.lock().unwrap_or_else(std::sync::PoisonError::into_inner); + let (mut harness, layer) = fill_app("warp"); + + let (fitted, _) = warp_parts(&harness, layer); + let pulled = [[-0.5, 0.5], [0.9, 0.9], [0.5, -0.5], [-0.5, -0.5]]; + harness.state_mut().run("layer.fill.projection", json!({"layer": layer.0, "warpCorners": pulled})); + harness.state_mut().run("layer.decal.set", json!({"layer": layer.0, "rotation": 30})); + harness.run_steps(2); + let steps = harness.state().session.history_labels().len(); + + click_label(&mut harness, "Mirror horizontally"); + + assert_eq!(warp_parts(&harness, layer).0.flip, [true, false]); + + click_label(&mut harness, "Mirror vertically"); + click_label(&mut harness, "Mirror horizontally"); + + assert_eq!(warp_parts(&harness, layer).0.flip, [false, true], "each button toggles its own direction"); + assert_eq!(harness.state().session.history_labels().len(), steps + 3); + + click_label(&mut harness, "Reset"); + click_label(&mut harness, "Restore the global transformation"); + + let (frame, corners) = warp_parts(&harness, layer); + assert_eq!((frame, corners), (fitted, pulled), "the frame goes back and the corners stay"); + + click_label(&mut harness, "Reset"); + click_label(&mut harness, "Reset all vertices"); + + assert_eq!(warp_parts(&harness, layer).1, Projection::FRAME_CORNERS); + assert_eq!(harness.state().session.history_labels().len(), steps + 5); + } +} diff --git a/crates/ui-egui/src/frame_gizmo/warp_toolbar/snap.rs b/crates/ui-egui/src/frame_gizmo/warp_toolbar/snap.rs new file mode 100644 index 00000000..0245e81f --- /dev/null +++ b/crates/ui-egui/src/frame_gizmo/warp_toolbar/snap.rs @@ -0,0 +1,24 @@ +/// `value` rounded to the nearest multiple of `step`; no step (0, negative or not a number) leaves it as it is +pub(crate) fn to_step(value: f32, step: f32) -> f32 { + if step.is_finite() && step > 0.0 { (value / step).round() * step } else { value } +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn a_value_snaps_to_the_nearest_multiple_of_the_step() { + assert!((to_step(0.29, 0.2) - 0.2).abs() < 1e-6); + assert!((to_step(0.31, 0.2) - 0.4).abs() < 1e-6); + assert!((to_step(-0.31, 0.2) + 0.4).abs() < 1e-6, "negative moves snap the same way"); + assert_eq!(to_step(100.0, 45.0), 90.0); + } + + #[test] + fn no_step_leaves_the_value_alone() { + for step in [0.0, -1.0, f32::NAN, f32::INFINITY] { + assert_eq!(to_step(0.37, step), 0.37, "{step}"); + } + } +} diff --git a/crates/ui-egui/src/frame_gizmo/warp_toolbar/warp_target.rs b/crates/ui-egui/src/frame_gizmo/warp_toolbar/warp_target.rs new file mode 100644 index 00000000..571b42c3 --- /dev/null +++ b/crates/ui-egui/src/frame_gizmo/warp_toolbar/warp_target.rs @@ -0,0 +1,35 @@ +use serde_json::{Value, json}; +use texturecraft_engine::core::{LayerId, Projection}; + +use crate::TextureCraftApp; +use crate::frame_gizmo::selected_fill_projection; + +/// The selected fill with a warp projection that the tool bar edits: a fill layer, or a fill effect in its mask +#[derive(Clone, Copy, Debug, PartialEq)] +pub(super) struct WarpTarget { + pub layer: LayerId, + pub effect: Option, + /// The image mirrored left to right and top to bottom inside the frame + pub flip: [bool; 2], +} + +impl WarpTarget { + /// The selected fill when it projects through a warp, in the modes where the frame gizmo shows + pub(super) fn of(app: &TextureCraftApp) -> Option { + let (layer, effect, projection, _) = selected_fill_projection(app)?; + let Projection::Warp { frame, .. } = projection else { return None }; + + Some(WarpTarget { layer, effect, flip: frame.flip }) + } + + /// `fields` addressed to this fill, as every command that edits a fill's projection takes it + pub(super) fn params(&self, fields: Value) -> Value { + let mut params = fields; + params["layer"] = json!(self.layer.0); + if let Some(effect) = self.effect { + params["effect"] = json!(effect.0); + } + + params + } +} diff --git a/crates/ui-egui/src/frame_gizmo/warp_toolbar/warp_toolbar_settings.rs b/crates/ui-egui/src/frame_gizmo/warp_toolbar/warp_toolbar_settings.rs new file mode 100644 index 00000000..f6debfb6 --- /dev/null +++ b/crates/ui-egui/src/frame_gizmo/warp_toolbar/warp_toolbar_settings.rs @@ -0,0 +1,63 @@ +use std::ops::RangeInclusive; + +use serde::{Deserialize, Serialize}; + +use super::{GizmoMode, GizmoSpace}; + +/// The manipulator size the gizmo's measurements are given at +pub(super) const DEFAULT_MANIPULATOR_SIZE: f32 = 0.2; +pub(super) const MANIPULATOR_SIZES: RangeInclusive = 0.1..=0.5; + +/// The default and range of the move step (world units) and of the turn step (degrees) +pub(super) const DEFAULT_GRID_STEP: f32 = 0.2; +pub(super) const GRID_STEPS: RangeInclusive = 0.01..=1.0; +pub(super) const DEFAULT_ANGLE_STEP: f32 = 45.0; +pub(super) const ANGLE_STEPS: RangeInclusive = 1.0..=90.0; + +/// The warp tool bar's settings: the gizmo's mode, space and size, and the steps its drags snap to while Ctrl is held +#[derive(Clone, Copy, Debug, PartialEq, Serialize, Deserialize)] +#[serde(default)] +pub struct WarpToolbarSettings { + pub mode: GizmoMode, + pub space: GizmoSpace, + /// Manipulator size: [`DEFAULT_MANIPULATOR_SIZE`] draws the gizmo at its base size + pub manipulator_size: f32, + /// Move step in world units + pub grid_steps: f32, + /// Turn step in degrees + pub angle_steps: f32, +} + +impl Default for WarpToolbarSettings { + fn default() -> Self { + WarpToolbarSettings { + mode: GizmoMode::default(), + space: GizmoSpace::default(), + manipulator_size: DEFAULT_MANIPULATOR_SIZE, + grid_steps: DEFAULT_GRID_STEP, + angle_steps: DEFAULT_ANGLE_STEP, + } + } +} + +impl WarpToolbarSettings { + /// How many times its base size the gizmo's arrows and ring are drawn + pub(crate) fn gizmo_scale(&self) -> f32 { + within(self.manipulator_size, MANIPULATOR_SIZES, DEFAULT_MANIPULATOR_SIZE) / DEFAULT_MANIPULATOR_SIZE + } + + /// The move step in world units + pub(crate) fn grid_step(&self) -> f32 { + within(self.grid_steps, GRID_STEPS, DEFAULT_GRID_STEP) + } + + /// The turn step in degrees + pub(crate) fn angle_step(&self) -> f32 { + within(self.angle_steps, ANGLE_STEPS, DEFAULT_ANGLE_STEP) + } +} + +/// `value` held to `range`; `fallback` for a saved value that is not a number +fn within(value: f32, range: RangeInclusive, fallback: f32) -> f32 { + if value.is_finite() { value.clamp(*range.start(), *range.end()) } else { fallback } +} diff --git a/crates/ui-egui/src/projection_gizmo.rs b/crates/ui-egui/src/projection_gizmo.rs index edc56a76..774a3cce 100644 --- a/crates/ui-egui/src/projection_gizmo.rs +++ b/crates/ui-egui/src/projection_gizmo.rs @@ -52,7 +52,7 @@ pub(crate) fn input(app: &mut TextureCraftApp, ctx: &egui::Context, re ctx.set_cursor_icon(gizmo.unwrap_or(&drag.start).cursor(drag.grab, true)); if let Some(pointer) = response.interact_pointer_pos().filter(|_| ctx.input(|input| input.pointer.delta() != egui::Vec2::ZERO)) - && let Some((command, params)) = drag.start.edit(app, rect, drag.grab, drag.from, pointer) + && let Some((command, params)) = drag.start.edit_with_snap(app, rect, drag.grab, drag.from, pointer, ctx.input(|input| input.modifiers.command)) { edit_in_one_step(&mut app.session, command, params, &mut drag.edited_revision); diff --git a/crates/ui-egui/src/projection_gizmo/gizmo.rs b/crates/ui-egui/src/projection_gizmo/gizmo.rs index e95c8270..fb3cbbcc 100644 --- a/crates/ui-egui/src/projection_gizmo/gizmo.rs +++ b/crates/ui-egui/src/projection_gizmo/gizmo.rs @@ -20,6 +20,11 @@ pub(crate) trait Gizmo: Clone + Send + Sync + 'static { /// The command and params a drag of `grab` from `from` to `to` runs fn edit(&self, app: &TextureCraftApp, rect: Rect, grab: Self::Grab, from: Pos2, to: Pos2) -> Option<(&'static str, Value)>; + /// As [`Gizmo::edit`], the drag snapping to the tool bar's steps while `snapping` (a gizmo with none ignores it) + fn edit_with_snap(&self, app: &TextureCraftApp, rect: Rect, grab: Self::Grab, from: Pos2, to: Pos2, _snapping: bool) -> Option<(&'static str, Value)> { + self.edit(app, rect, grab, from, to) + } + /// The cursor over `grab`, or dragging it fn cursor(&self, grab: Self::Grab, dragging: bool) -> egui::CursorIcon; } diff --git a/crates/ui-egui/src/state.rs b/crates/ui-egui/src/state.rs index 0c767e1b..d3050b3d 100644 --- a/crates/ui-egui/src/state.rs +++ b/crates/ui-egui/src/state.rs @@ -624,6 +624,9 @@ pub struct UiState { /// How the 3D view shows symmetry #[serde(default)] pub symmetry: crate::symmetry::SymmetryDisplay, + /// The warp tool bar: the gizmo's mode and space, its size, and the steps its drags snap to + #[serde(default)] + pub warp_toolbar: crate::frame_gizmo::warp_toolbar::WarpToolbarSettings, /// The brush, symmetry and other tool settings of the last session, which the next one starts with #[serde(default)] pub tool_settings: texturecraft_engine::ToolSettings, @@ -791,6 +794,7 @@ impl Default for UiState { keymap: Keymap::new(), bake_paint_brush: crate::bake_mode::BakePaintBrush::default(), symmetry: crate::symmetry::SymmetryDisplay::default(), + warp_toolbar: crate::frame_gizmo::warp_toolbar::WarpToolbarSettings::default(), tool_settings: Default::default(), bake_visualization: crate::bake_mode::BakeVisualizationToggles::default(), named_layouts: Vec::new(), diff --git a/crates/ui-egui/src/toolbar.rs b/crates/ui-egui/src/toolbar.rs index 27274a1d..05395a3d 100644 --- a/crates/ui-egui/src/toolbar.rs +++ b/crates/ui-egui/src/toolbar.rs @@ -7,6 +7,7 @@ use texturecraft_engine::Tool; use crate::TextureCraftApp; use crate::drawn_icon::DrawnIcon; +use crate::frame_gizmo::warp_toolbar; use crate::i18n::{tr, trf}; use crate::keymap::{shortcut_of, tip}; use crate::state::{Mode, ViewLayout}; @@ -61,7 +62,7 @@ pub fn paint_bar(app: &mut TextureCraftApp, ui: &mut egui::Ui) { ui.add(egui::Separator::default().spacing(BAR_SEPARATOR_WIDTH)); if !scroll_views { view_buttons(app, ui); - if app.session.tool_usable(app.session.tool.tool) { + if tool_bar_controls_shown(app) { ui.add(egui::Separator::default().spacing(BAR_SEPARATOR_WIDTH)); } } @@ -74,6 +75,11 @@ pub fn paint_bar(app: &mut TextureCraftApp, ui: &mut egui::Ui) { }); } +/// Whether the bar's left side shows controls: a warp fill's, or the selected tool's when it can act on the selection +fn tool_bar_controls_shown(app: &TextureCraftApp) -> bool { + warp_toolbar::shown(app) || app.session.tool_usable(app.session.tool.tool) +} + /// Width of `view_buttons`, so the bar knows when to move them into the scrolling strip fn view_buttons_width(button_size: f32, spacing: f32) -> f32 { // Two icons, three dropdowns, one separator and the five gaps between them @@ -224,13 +230,15 @@ fn scrolling_tool_controls(app: &mut TextureCraftApp, ui: &mut egui::Ui, tokens: scroll_area.show(ui, |ui| { ui.scroll_with_delta(vec2(scroll_delta, 0.0)); ui.horizontal_centered(|ui| { - // A tool that can't act on the selection leaves the bar, as the shelf greys it - let tool_usable = app.session.tool_usable(app.session.tool.tool); - if tool_usable { + // A warp fill's controls take the tool's place; a tool that can't act on the selection leaves the bar, as the shelf greys it + let controls_shown = tool_bar_controls_shown(app); + if warp_toolbar::shown(app) { + warp_toolbar::controls(app, ui); + } else if controls_shown { tool_controls(app, ui, tokens); } if scroll_views { - if tool_usable { + if controls_shown { ui.add(egui::Separator::default().spacing(BAR_SEPARATOR_WIDTH)); } let size = vec2(view_buttons_width(button_size, ui.spacing().item_spacing.x), ui.available_height()); From fea4a5e627f611e76e584f5eee26b471da8ba907 Mon Sep 17 00:00:00 2001 From: vangel76 Date: Thu, 26 Nov 2026 00:53:35 +0100 Subject: [PATCH 60/83] Shift+click on a mask thumbnail switches the mask on or off, the material thumbnail leaves mask view Shift+click on a mask thumbnail runs mask.toggle on that layer instead of selecting the mask. The mask thumbnail exposes a Mask off description while the mask is bypassed. Clicking the material thumbnail returns the viewport from mask view to the material view. --- crates/ui-egui/src/dock.rs | 17 +++++-- crates/ui-egui/tests/it/layers_panel.rs | 60 +++++++++++++++++++++++-- 2 files changed, 71 insertions(+), 6 deletions(-) diff --git a/crates/ui-egui/src/dock.rs b/crates/ui-egui/src/dock.rs index b1ecd8b8..0f202dd1 100644 --- a/crates/ui-egui/src/dock.rs +++ b/crates/ui-egui/src/dock.rs @@ -556,6 +556,9 @@ fn layer_row(app: &mut TextureCraftApp, ui: &mut Ui, layer: &Layer, depth: usize if content_response.clicked() { let modifiers = ui.input(|input| input.modifiers); click_layer(app, modifiers, layer.id.0, Some("content")); + if matches!(app.session.view, texturecraft_engine::ViewMode::Mask(_)) { + app.run("viewport.view", json!({"mode": "material"})); + } } thumbnail_context_menu(ui, &content_response, content_label, &layer.name, content_target, |ui| layer_context_menu(app, ui, layer, true)); x = thumbnail.right() + THUMBNAIL_SPACING; @@ -594,17 +597,25 @@ fn layer_row(app: &mut TextureCraftApp, ui: &mut Ui, layer: &Layer, depth: usize if !mask_enabled { painter.line_segment([mask_rect.left_top(), mask_rect.right_bottom()], Stroke::new(HIDDEN_STRIKE_WIDTH, tokens.danger)); } - let mask_label = tr("Select the mask (Alt+click: show it in the viewport)"); + let mask_label = tr("Select the mask (Alt+click: show it in the viewport, Shift+click: switch it on or off)"); let mask_response = ui.interact(mask_rect, ui.scope_id().with(("mask", layer.id.0)), Sense::click()).on_hover_text(mask_label); if mask_response.clicked() { - app.run("layer.select", json!({"layer": layer.id.0, "target": "mask"})); - if ui.input(|input| input.modifiers.alt) { + let modifiers = ui.input(|input| input.modifiers); + if modifiers.shift && !modifiers.alt { + app.run("mask.toggle", json!({"layer": layer.id.0})); + } else { + app.run("layer.select", json!({"layer": layer.id.0, "target": "mask"})); + } + if modifiers.alt { let showing = app.session.view == texturecraft_engine::ViewMode::Mask(layer.id); let view = if showing { json!({"mode": "material"}) } else { json!({"mode": "mask", "layer": layer.id.0}) }; app.run("viewport.view", view); } } thumbnail_context_menu(ui, &mask_response, mask_label, &layer.name, mask_target, |ui| mask_management_menu(app, ui, layer, true)); + if !mask_enabled { + ui.ctx().accesskit_node_builder(mask_response.id, |node| node.set_description(tr("Mask off"))); + } if app.session.view == texturecraft_engine::ViewMode::Mask(layer.id) { painter.rect_stroke( mask_rect.expand(HIGHLIGHT_OUTSET), diff --git a/crates/ui-egui/tests/it/layers_panel.rs b/crates/ui-egui/tests/it/layers_panel.rs index 72b5ad4b..edb8b8d9 100644 --- a/crates/ui-egui/tests/it/layers_panel.rs +++ b/crates/ui-egui/tests/it/layers_panel.rs @@ -37,6 +37,9 @@ fn thumb(h: &Harness<'_, TextureCraftApp>, name: &str, mask: bool) -> egui::Pos2 egui::pos2(x, row.center().y) } +/// The accessible name of the mask thumbnail of the layer "Masked fill" +const MASK_THUMBNAIL_NAME: &str = "Select the mask (Alt+click: show it in the viewport, Shift+click: switch it on or off) (Masked fill)"; + /// The `label` header that follows the "Masked fill" row (other layers have groups too). fn header(h: &mut Harness<'_, TextureCraftApp>, label: &str) { let top = h.get_by_label("Masked fill").rect().top(); @@ -352,7 +355,7 @@ fn thumbnail_menus_apply_actions_to_the_clicked_layer_and_stack() { #[test] fn focused_mask_thumbnail_opens_and_dismisses_its_menu_from_the_keyboard() { let (mut h, _) = harness(); - let thumbnail = "Select the mask (Alt+click: show it in the viewport) (Masked fill)"; + let thumbnail = MASK_THUMBNAIL_NAME; h.get_by_label(thumbnail).focus(); h.run_steps(3); assert!(h.get_by_label(thumbnail).is_focused()); @@ -425,10 +428,15 @@ fn alt_click_on_the_eye_solos_and_a_plain_click_still_hides() { } fn alt_click(h: &mut Harness<'_, TextureCraftApp>, at: egui::Pos2) { - h.event(egui::Event::ModifiersChanged(egui::Modifiers::ALT)); + click_with(h, at, egui::Modifiers::ALT); +} + +/// A primary click at `at` with `modifiers` held, as a user does +fn click_with(h: &mut Harness<'_, TextureCraftApp>, at: egui::Pos2, modifiers: egui::Modifiers) { + h.event(egui::Event::ModifiersChanged(modifiers)); h.hover_at(at); for pressed in [true, false] { - h.event(egui::Event::PointerButton { pos: at, button: egui::PointerButton::Primary, pressed, modifiers: egui::Modifiers::ALT }); + h.event(egui::Event::PointerButton { pos: at, button: egui::PointerButton::Primary, pressed, modifiers }); h.run_steps(2); } h.event(egui::Event::ModifiersChanged(egui::Modifiers::NONE)); @@ -467,6 +475,52 @@ fn alt_click_on_the_content_thumbnail_leaves_the_view_alone() { assert_eq!(h.state().session.view, texturecraft_engine::ViewMode::Material); } +/// Whether the red strike of a bypassed mask is painted across the thumbnail at `at` +fn mask_strike_shown(h: &Harness<'_, TextureCraftApp>, at: egui::Pos2) -> bool { + let danger = texturecraft_ui_egui::theme::Tokens::get(&h.ctx).danger; + shapes(h).iter().any(|shape| matches!(shape, egui::Shape::LineSegment { points, stroke } if stroke.color == danger && egui::Rect::from_two_pos(points[0], points[1]).contains(at))) +} + +#[test] +fn shift_click_on_a_mask_thumbnail_switches_the_mask_off_and_on_in_one_undo_step_each() { + let (mut h, layer) = harness(); + let at = thumb(&h, "Masked fill", true); + let target = h.state().session.target; + let history = h.state().session.history_labels().len(); + let mask = h.state().session.doc.project.layers[&layer].mask.clone().unwrap(); + assert!(!mask_strike_shown(&h, at)); + + click_with(&mut h, at, egui::Modifiers::SHIFT); + let off = h.state().session.doc.project.layers[&layer].mask.clone().unwrap(); + assert!(!off.enabled); + assert_eq!(off.effects, mask.effects, "the mask keeps its effects while bypassed"); + assert_eq!(h.state().session.history_labels().len(), history + 1); + assert_eq!(h.state().session.target, target, "Shift+click toggles instead of selecting the mask"); + assert!(mask_strike_shown(&h, at), "the disabled indicator shows while the mask is bypassed"); + assert_eq!(h.get_by_label(MASK_THUMBNAIL_NAME).accesskit_node().description().as_deref(), Some("Mask off"), "assistive tech hears the state"); + + click_with(&mut h, at, egui::Modifiers::SHIFT); + assert_eq!(h.state().session.doc.project.layers[&layer].mask, Some(mask), "toggling back restores the mask as it was"); + assert_eq!(h.state().session.history_labels().len(), history + 2); + assert!(!mask_strike_shown(&h, at)); + + h.state_mut().session.undo().unwrap(); + assert!(!h.state().session.doc.project.layers[&layer].mask.as_ref().unwrap().enabled, "one undo undoes one toggle"); +} + +#[test] +fn clicking_the_material_thumbnail_leaves_the_mask_view() { + let (mut h, layer) = harness(); + let at = thumb(&h, "Masked fill", true); + alt_click(&mut h, at); + assert_eq!(h.state().session.view, texturecraft_engine::ViewMode::Mask(layer)); + + let at = thumb(&h, "Masked fill", false); + click(&mut h, at); + assert_eq!(h.state().session.view, texturecraft_engine::ViewMode::Material); + assert_eq!(h.state().session.target, StackTarget::Content, "the layer content is selected"); +} + /// Pointer moves of the opacity cell drag, one per frame const OPACITY_DRAG_MOVES: usize = 4; From 632b2698c3d9e86dde72dff4fa222abf0c984c88 Mon Sep 17 00:00:00 2001 From: chasse20 Date: Thu, 26 Nov 2026 01:12:03 +0000 Subject: [PATCH 61/83] Auto: Preserve mask view on Alt-clicking the content thumbnail Keep content selection active while Alt-click preserves the current viewport. Extend the Layers panel regression to exercise the gesture from Mask view. All 20 Layers panel tests, UI Clippy, formatting, layering, and the isolated UI WebAssembly check passed. --- crates/ui-egui/src/dock.rs | 3 ++- crates/ui-egui/tests/it/layers_panel.rs | 18 +++++++++++++++--- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/crates/ui-egui/src/dock.rs b/crates/ui-egui/src/dock.rs index 53672f61..e51abaca 100644 --- a/crates/ui-egui/src/dock.rs +++ b/crates/ui-egui/src/dock.rs @@ -557,10 +557,11 @@ fn layer_row(app: &mut TextureCraftApp, ui: &mut Ui, layer: &Layer, depth: usize let modifiers = ui.input(|input| input.modifiers); click_layer(app, modifiers, layer.id.0, Some("content")); - if matches!(app.session.view, texturecraft_engine::ViewMode::Mask(_)) { + if !modifiers.alt && matches!(app.session.view, texturecraft_engine::ViewMode::Mask(_)) { app.run("viewport.view", json!({"mode": "material"})); } } + thumbnail_context_menu(ui, &content_response, content_label, &layer.name, content_target, |ui| layer_context_menu(app, ui, layer, true)); x = thumbnail.right() + THUMBNAIL_SPACING; diff --git a/crates/ui-egui/tests/it/layers_panel.rs b/crates/ui-egui/tests/it/layers_panel.rs index 459109f8..25819847 100644 --- a/crates/ui-egui/tests/it/layers_panel.rs +++ b/crates/ui-egui/tests/it/layers_panel.rs @@ -472,11 +472,23 @@ fn alt_click_on_a_mask_thumbnail_shows_that_mask_alone_without_changing_the_docu #[test] fn alt_click_on_the_content_thumbnail_leaves_the_view_alone() { - let (mut h, _) = harness(); - let at = thumb(&h, "Masked fill", false); - alt_click(&mut h, at); + let (mut h, layer) = harness(); + let content_thumbnail = thumb(&h, "Masked fill", false); + let mask_thumbnail = thumb(&h, "Masked fill", true); + + alt_click(&mut h, content_thumbnail); assert_eq!(h.state().session.view, texturecraft_engine::ViewMode::Material); + + alt_click(&mut h, mask_thumbnail); + + assert_eq!(h.state().session.view, texturecraft_engine::ViewMode::Mask(layer)); + assert_eq!(h.state().session.target, StackTarget::Mask); + + alt_click(&mut h, content_thumbnail); + + assert_eq!(h.state().session.view, texturecraft_engine::ViewMode::Mask(layer)); + assert_eq!(h.state().session.target, StackTarget::Content); } /// Whether a bypassed mask's strike is painted across the thumbnail at `position` From dc2c80739bcf7ffc0c17f33bc57c83f39d827b2d Mon Sep 17 00:00:00 2001 From: skylar taylor-barrick Date: Wed, 25 Nov 2026 20:02:16 -0600 Subject: [PATCH 62/83] Bake on the CPU under coverage so the Sonar shards stop crashing at exit (#840) Merged under Skylar's explicit override (Nightly 792) after green CI, CodeRabbit on this head with no open threads, and an independent adversarial review with no blockers. --- Cargo.toml | 3 +++ crates/engine/src/bake/mesh_map_command.rs | 12 +++++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index de6fc98d..36d12a70 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -104,6 +104,9 @@ egui-phosphor = { path = "vendor/egui-phosphor" } [workspace.lints.rust] unsafe_code = "forbid" +# cargo-llvm-cov always sets `cfg(coverage)`: a coverage build bakes on the CPU (texturecraft-engine +# picks no GPU tracer there) and the cfg would otherwise trip unexpected_cfgs under -D warnings. +unexpected_cfgs = { level = "warn", check-cfg = ['cfg(coverage)'] } [workspace.lints.clippy] dbg_macro = "warn" diff --git a/crates/engine/src/bake/mesh_map_command.rs b/crates/engine/src/bake/mesh_map_command.rs index 3a32bfa9..f253e1e6 100644 --- a/crates/engine/src/bake/mesh_map_command.rs +++ b/crates/engine/src/bake/mesh_map_command.rs @@ -93,6 +93,14 @@ pub fn set_gpu_raytracing(enabled: bool) { /// The tracer a bake starting now uses: the installed one while GPU raytracing is on, else none (the CPU) fn chosen_tracer(installed: Option<&Arc>, enabled: bool) -> Option> { + // The coverage build bakes on the CPU, the fallback every GPU failure takes anyway. Its tests run on + // a headless runner, and the bake's GPU device is created on a worker thread there: tearing that + // GL context down crashes the test process at exit (a wgpu-hal GLES `BadDisplay` panic, or a + // SIGSEGV in the driver), which took a different test down on every run. The compute shaders are + // never line-covered, so nothing is lost. + if cfg!(coverage) { + return None; + } installed.filter(|_| enabled).cloned() } @@ -917,7 +925,9 @@ mod gpu_raytracing_tests { fn bakes_use_the_installed_gpu_tracer_only_while_gpu_raytracing_is_on() { let installed: Arc = Arc::new(NamedTracer); - assert_eq!(chosen_tracer(Some(&installed), true).map(|tracer| tracer.name()), Some("gpu".to_string())); + // A coverage build keeps every bake on the CPU: its headless runner has no GPU to bake on + let gpu = (!cfg!(coverage)).then(|| "gpu".to_string()); + assert_eq!(chosen_tracer(Some(&installed), true).map(|tracer| tracer.name()), gpu, "on casts the rays on the GPU"); assert!(chosen_tracer(Some(&installed), false).is_none(), "off keeps the rays on the CPU"); assert!(chosen_tracer(None, true).is_none(), "no installed tracer bakes on the CPU"); } From c57d4045f04d481900a6ffc26d7904bd63554b19 Mon Sep 17 00:00:00 2001 From: skylar taylor-barrick Date: Wed, 25 Nov 2026 21:05:43 -0600 Subject: [PATCH 63/83] Switch on supervised nightlies on the nightly-signer branch (#838) Supervised nightly switch-on, merged under Skylar's explicit Nightly 758 override after green CI, CodeRabbit on this head with no open threads, Sonar passing, and an independent adversarial review with no blockers. --- .github/nightly-linux-signing-key.asc | 16 ++ .github/nightly-signing-policy.json | 20 +- .github/workflows/nightly-dispatch.yml | 72 +++++ .github/workflows/nightly-sign.yml | 17 +- .github/workflows/nightly.yml | 8 +- docs/nightly-release-preparation.md | 101 +++++-- docs/releasing.md | 7 + packaging/nightly-release-tests.py | 379 ++++++++++++++++++++++++- 8 files changed, 574 insertions(+), 46 deletions(-) create mode 100644 .github/nightly-linux-signing-key.asc create mode 100644 .github/workflows/nightly-dispatch.yml diff --git a/.github/nightly-linux-signing-key.asc b/.github/nightly-linux-signing-key.asc new file mode 100644 index 00000000..a1c1f31e --- /dev/null +++ b/.github/nightly-linux-signing-key.asc @@ -0,0 +1,16 @@ +-----BEGIN PGP PUBLIC KEY BLOCK----- + +mDMEaulK1xYJKwYBBAHaRw8BAQdAqHJeDCjY6Hx5FTn/hW+aqu6V394ubLk0Zj3C +bftDwFm0IkFydENyYWZ0IExpbnV4IFJlbGVhc2UgU2lnbmluZyBLZXmIkwQTFgoA +OxYhBCt2dBtBSq1s0z5jEhOgBcC518PtBQJq6UrXAhsBBQsJCAcCAiICBhUKCQgL +AgQWAgMBAh4HAheAAAoJEBOgBcC518PtGeUA/RjvULBTLlccc+2wtJkfjSnCV+cf +PUMEGmW7XkZWkk51AP9w2A/WLv+79nREWEpZzI8LGK5EjrNazP+sY0l7j5rFCLgz +BGrpStcWCSsGAQQB2kcPAQEHQPl7XkQ1gWsvSPf/T9b4m/UHcjJjBpSOtpYlWR56 +er5RiO8EGBYKACAWIQQrdnQbQUqtbNM+YxIToAXAudfD7QUCaulK1wIbAgCBCRAT +oAXAudfD7XYgBBkWCgAdFiEEVo3B9o+Prsx5fzx7AG2va7DvM04FAmrpStcACgkQ +AG2va7DvM07taQEA4d2VFkKRIP0g9TrE86KpnuXPap+LKqe0tfIxpdf9YxIA/0Wo +9H/iG8nH++nxC087p3HE0S+0UovxqkhXJLSr8B4JDOoA/iLRpqTdYmk6fVXMyPJo +SkOVuwZIGS6VgBdSQP0e2P2YAP41L5OoSvwdQIG3/uNrM+ieqpYeM597/hCLFs5A +ga/qCA== +=3wGQ +-----END PGP PUBLIC KEY BLOCK----- diff --git a/.github/nightly-signing-policy.json b/.github/nightly-signing-policy.json index 92288670..35cb9eeb 100644 --- a/.github/nightly-signing-policy.json +++ b/.github/nightly-signing-policy.json @@ -2,13 +2,13 @@ "schema": "craft-nightly-release-policy/v3", "repository": "storytold/texturecraft", "repository_id": 1419654881, - "producer_workflow_id": null, + "producer_workflow_id": 429738073, "producer_workflow_path": ".github/workflows/nightly.yml", - "producer_tooling_revision": "605d58766e8f536564da8fc81d3676ac86816dea", - "producer_workflow_ref": "storytold/craft-common-actions/.github/workflows/nightly-unsigned.yml@605d58766e8f536564da8fc81d3676ac86816dea", + "producer_tooling_revision": "be00e5ccd18b68e950c8a08532f2230e7c3d0cba", + "producer_workflow_ref": "storytold/craft-common-actions/.github/workflows/nightly-unsigned.yml@be00e5ccd18b68e950c8a08532f2230e7c3d0cba", "signer_workflow_path": ".github/workflows/nightly-sign.yml", - "signer_tooling_revision": "605d58766e8f536564da8fc81d3676ac86816dea", - "release_branch": "release", + "signer_tooling_revision": "be00e5ccd18b68e950c8a08532f2230e7c3d0cba", + "release_branch": "nightly-signer", "manual_actors": [ "bflatastic", "dylanmtaylor", @@ -49,13 +49,15 @@ "issue_types": [ "VULNERABILITY" ], - "accepted_conditions": [], - "required_conditions": [ + "accepted_conditions": [ { "metric": "new_security_rating", "comparator": "GT", - "error_threshold": "1" - }, + "error_threshold": "1", + "maximum": "5" + } + ], + "required_conditions": [ { "metric": "new_reliability_rating", "comparator": "GT", diff --git a/.github/workflows/nightly-dispatch.yml b/.github/workflows/nightly-dispatch.yml new file mode 100644 index 00000000..bd40f765 --- /dev/null +++ b/.github/workflows/nightly-dispatch.yml @@ -0,0 +1,72 @@ +name: Dispatch release-ref nightly + +# Transport only, never authorization. No checkout, payload parsing or release environment. +on: + workflow_run: + workflows: [TextureCraft unsigned nightly] + types: [completed] + branches: [main] + +permissions: {} + +jobs: + dispatch: + # SOURCE PREPARATION: literal off until immutable shared tooling and policy qualification. + if: >- + false && github.repository == 'storytold/texturecraft' && + github.event_name == 'workflow_run' + runs-on: ubuntu-latest + timeout-minutes: 5 + permissions: + actions: write + steps: + - name: Dispatch only the exact completed producer run and attempt + shell: python + env: + GH_TOKEN: ${{ github.token }} + run: | + import json + import os + import urllib.request + + def require(value, message): + if not value: + raise RuntimeError(message) + + # These filters reduce noise; the protected signer-branch validator repeats admission + # against authenticated API metadata and required attestation/quality evidence. + require(os.environ.get('GITHUB_REPOSITORY') == 'storytold/texturecraft', 'wrong repository') + require(os.environ.get('GITHUB_EVENT_NAME') == 'workflow_run', 'wrong event') + with open(os.environ['GITHUB_EVENT_PATH'], encoding='utf-8') as stream: + event = json.load(stream) + require(event.get('action') == 'completed', 'producer is not complete') + require(event.get('repository', {}).get('full_name') == 'storytold/texturecraft', 'wrong event repository') + producer = event.get('workflow_run', {}) + require(producer.get('head_repository', {}).get('full_name') == 'storytold/texturecraft', 'foreign producer') + require(producer.get('path') == '.github/workflows/nightly.yml', 'wrong producer path') + require(producer.get('head_branch') == 'main', 'wrong producer branch') + require(producer.get('status') == 'completed' and producer.get('conclusion') == 'success', 'producer did not succeed') + # First scheduled attempt only; reviewed manual/re-run authority belongs to release policy. + require(producer.get('event') == 'schedule', 'not an automatic scheduled producer') + run_id, attempt = producer.get('id'), producer.get('run_attempt') + require(type(run_id) is int and run_id > 0, 'invalid producer run id') + require(type(attempt) is int and attempt == 1, 'invalid automatic producer attempt') + body = json.dumps({'ref': 'refs/heads/nightly-signer', 'inputs': { + 'producer_run_id': str(run_id), 'producer_run_attempt': str(attempt) + }}).encode('utf-8') + request = urllib.request.Request( + 'https://api.github.com/repos/storytold/texturecraft/actions/workflows/nightly-sign.yml/dispatches', + data=body, method='POST', headers={ + 'Authorization': 'Bearer ' + os.environ['GH_TOKEN'], + 'Accept': 'application/vnd.github+json', + 'Content-Type': 'application/json', + 'X-GitHub-Api-Version': '2022-11-28', + 'User-Agent': 'texturecraft-nightly-dispatch' + }) + class NoRedirect(urllib.request.HTTPRedirectHandler): + def redirect_request(self, req, fp, code, msg, headers, newurl): + raise RuntimeError('dispatch redirects are forbidden') + # One bounded request, no retry: duplicate transport is not publication authority. + with urllib.request.build_opener(NoRedirect()).open(request, timeout=20) as response: + require(response.status == 204, 'dispatch was not accepted') + print('Dispatched producer run/attempt to the release-ref validator; not a signing result.') diff --git a/.github/workflows/nightly-sign.yml b/.github/workflows/nightly-sign.yml index d07db551..998acbae 100644 --- a/.github/workflows/nightly-sign.yml +++ b/.github/workflows/nightly-sign.yml @@ -1,7 +1,8 @@ name: TextureCraft release-ref nightly signer -# Enabled for supervised manual dispatch on release. Main/release contents must match. -# A reusable callee does not change context; this must be a real top-level release dispatch. +# Enabled for supervised manual dispatch on the dedicated nightly-signer branch, which only ever +# fast-forwards to reviewed main commits (never the stable release branch). +# A reusable callee does not change context; this must be a real top-level signer-branch dispatch. on: workflow_dispatch: inputs: @@ -22,21 +23,23 @@ concurrency: jobs: release: - # Actual context guards: official repository, manual dispatch, real release branch. + # Actual context guards: official repository, manual dispatch, real nightly-signer branch. if: >- github.repository == 'storytold/texturecraft' && github.event_name == 'workflow_dispatch' && - github.ref == 'refs/heads/release' && github.ref_type == 'branch' + github.ref == 'refs/heads/nightly-signer' && github.ref_type == 'branch' permissions: contents: write actions: read checks: read attestations: write id-token: write - uses: storytold/craft-common-actions/.github/workflows/nightly-release.yml@605d58766e8f536564da8fc81d3676ac86816dea + uses: storytold/craft-common-actions/.github/workflows/nightly-release.yml@be00e5ccd18b68e950c8a08532f2230e7c3d0cba with: - tooling-revision: 605d58766e8f536564da8fc81d3676ac86816dea + tooling-revision: be00e5ccd18b68e950c8a08532f2230e7c3d0cba + app-name: texturecraft producer_run_id: ${{ inputs.producer_run_id }} producer_run_attempt: ${{ inputs.producer_run_attempt }} # No secrets: inherit or raw platform values in this caller. Only the isolated native - # callee job may bind the existing release environment and export keys in its signing step. + # callee job may bind the release environment and export its keys; that environment must + # admit nightly-signer alongside release before the first dispatch. diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml index 5345fe9a..1600b2e0 100644 --- a/.github/workflows/nightly.yml +++ b/.github/workflows/nightly.yml @@ -22,13 +22,13 @@ jobs: actions: read attestations: write id-token: write - uses: storytold/craft-common-actions/.github/workflows/nightly-unsigned.yml@605d58766e8f536564da8fc81d3676ac86816dea + uses: storytold/craft-common-actions/.github/workflows/nightly-unsigned.yml@be00e5ccd18b68e950c8a08532f2230e7c3d0cba with: - tooling-revision: 605d58766e8f536564da8fc81d3676ac86816dea + tooling-revision: be00e5ccd18b68e950c8a08532f2230e7c3d0cba app-name: texturecraft manual-actors: '["bflatastic","dylanmtaylor","echelon","FredApps","skylartaylor"]' craft-fonts-ref: aced4137c022f1f587624d48e81ec77e1914a9cc # One producer run builds every listed platform for one all-or-nothing release. The pin is the - # craft-common-actions main commit that merged #339 (bounded lineage compares), on top of the - # Linux/macOS signer (#342). + # craft-common-actions main commit that merged the exact-analysis admission (#371, after #370, + # #369 and #364). platforms: '["windows-x86_64","linux-x86_64","macos-aarch64"]' diff --git a/docs/nightly-release-preparation.md b/docs/nightly-release-preparation.md index 28114854..6ed80ba0 100644 --- a/docs/nightly-release-preparation.md +++ b/docs/nightly-release-preparation.md @@ -1,10 +1,12 @@ # Windows, Linux and macOS release-ref nightly: supervised manual go-live -**Enabled for supervised manual runs, not yet qualified.** The producer (`nightly.yml`, main) and the -signer (`nightly-sign.yml`, release) keep only their exact context guards and run when one of the reviewed -manual actors dispatches them. There is no schedule yet. The installed policy -[`.github/nightly-signing-policy.json`](../.github/nightly-signing-policy.json) is the v3 -policy. Once `nightly.yml` is registered on `main`, populate `producer_workflow_id` by reading: +**Enabled for supervised manual runs, not yet qualified.** The producer (`nightly.yml`, main) and +the signer (`nightly-sign.yml`, on the dedicated `nightly-signer` branch) keep only their exact +context guards and run when one of the reviewed manual actors dispatches them. +`nightly-dispatch.yml` stays literally off: it only forwards scheduled producers. There is no +schedule. The installed policy +[`.github/nightly-signing-policy.json`](../.github/nightly-signing-policy.json) is the v3 policy. +Its `producer_workflow_id` is the registration of `nightly.yml` on main, read with: ```bash gh api repos/storytold/texturecraft/actions/workflows/nightly.yml --jq .id @@ -13,22 +15,49 @@ gh api repos/storytold/texturecraft/actions/workflows/nightly.yml --jq .id The callers pass no platform secrets. The unsigned reusable caller's maximum OIDC/attestation permissions are for its isolated attester; its compiler narrows to contents and Actions read only, with no OIDC, attestation write, release environment or platform signing secrets. -Shared tooling is pinned to `605d58766e8f536564da8fc81d3676ac86816dea`, the craft-common-actions -main commit that merged [#339](https://github.com/storytold/craft-common-actions/pull/339) (bounded -lineage compares and an issue reread at the end of candidate admission) on top of -[#342](https://github.com/storytold/craft-common-actions/pull/342) (policy v3, the `platforms` input -and the Linux and macOS legs). Both callers name it in `uses` and `tooling-revision`. A pin is reviewed -source availability, not provider, queue, native signing or crypto qualification. -Existing stable workflows are unchanged. +Shared tooling is pinned to `be00e5ccd18b68e950c8a08532f2230e7c3d0cba`, the craft-common-actions +main commit that merged [#371](https://github.com/storytold/craft-common-actions/pull/371) (the +candidate is admitted on the built commit's own Sonar analysis, not main's latest) after +[#370](https://github.com/storytold/craft-common-actions/pull/370) (the Windows and macOS nightly +registry rows for the 14 apps) and +[#369](https://github.com/storytold/craft-common-actions/pull/369) (shared helper checkouts kept out +of the app's clean-source check, and macOS on `macos-15`), following +[#364](https://github.com/storytold/craft-common-actions/pull/364) (the signer may run on the +policy's signer branch) and [#363](https://github.com/storytold/craft-common-actions/pull/363) (the +multi-app pipeline, which makes the signer's `app-name` input required and admits any reviewed +registry app), with #342 (`a4f6fd51`, policy v3 and the `platforms` input) and #339 (`605d5876`) +earlier. Both callers name it in `uses` and `tooling-revision`. A pin is reviewed source +availability, not provider, queue, native signing or crypto qualification. Existing stable workflows are unchanged. **First runs.** The first runs are manual dispatches in this order: `nightly.yml` on main (only a -listed manual actor passes the producer's plan step), then `nightly-sign.yml` on `release` with that -producer run ID and attempt, by a listed manual actor. +listed manual actor passes the producer's plan step), then `nightly-sign.yml` on `nightly-signer` +with that producer run ID and attempt, by a listed manual actor. `nightly-dispatch.yml` only matters +once a schedule is approved. + +**Signer branch.** The signer runs on `refs/heads/nightly-signer`, not on the stable `release` +branch, so nightly signer files never need a stable release sync. The policy's `release_branch` +names it, the signer's guard requires it and the dispatcher targets it. The branch only +fast-forwards to reviewed main commits, through the settings script's `advance` (no queued signer +run, a trust-closure scan, then the full diff of `.github/` and `packaging/`), and the existing +`release` environment must admit `nightly-signer` alongside `release` before the first dispatch (a +repository settings change, not a workflow one). Its trust closure is all of `.github/` and +`packaging/`, including `packaging/env.sh`, which `packaging/macos/import-cert.sh` sources with the +Apple keys. On that branch only the pinned `nightly-sign.yml` caller may reach an environment: no +app workflow binds one, nothing else calls `nightly-release.yml`, and the only caller of the shared +stable `release.yml` is `release.yml`, whose callee must carry the stable-only environment guard. +The contract tests check the in-repo part on every main PR; the settings scan also resolves the +callee. Stable releases still come only from `refs/heads/release`. History does not carry over a +switch between `release` and `nightly-signer`, so the switch happens before the first publication. + +**Registry admission.** The signer requires the protected policy's `platforms` map to equal the +run app's admitted targets in craft-common-actions' `nightly-apps.json`, and it refuses rather +than sign a subset. TextureCraft's row admits `linux-x86_64`, `windows-x86_64` and `macos-aarch64`, with +each target's entrypoint and asset pattern, since craft-common-actions #370 (in the pin). **Manual actors.** `bflatastic`, `dylanmtaylor`, `echelon`, `FredApps` and `skylartaylor`, in the producer's `manual-actors` and the policy's `manual_actors`. The list mirrors the release-managers -team (id 19837241), leaving out `echelon-robot`, which only has read access; update it by PR -in both places when the team changes. +team (id 19837241), leaving out `echelon-robot`, which only has read access; update it by PR in both +places when the team changes. **Admission timing.** The candidate check reads the newest CI run on the candidate commit and main's latest finished Sonar analysis, so when to dispatch matters: @@ -39,19 +68,19 @@ main's latest finished Sonar analysis, so when to dispatch matters: **Platform rows.** The producer caller lists `platforms: '["windows-x86_64","linux-x86_64","macos-aarch64"]'` on its single job: one producer run builds every listed platform for one all-or-nothing release (one failed or -skipped platform stops that night's release, Windows included), and the release-ref signer admits +skipped platform stops that night's release, Windows included), and the signer admits platforms only from the protected policy, so there is no separate Linux or macOS caller job and the signer caller has no platform input. ## Installed policy values and their sources -Read on 2026-11-24; re-read anything that may have moved before the policy is promoted to `release`. +Read on 2026-11-24; re-read anything that may have moved before `nightly-signer` is advanced to it. | Field | Value | Source | |---|---|---| | `repository_id` | `1419654881` | `gh api repos/storytold/texturecraft --jq .id` | -| `producer_workflow_id` | `null` (pending registration on `main`) | Populate via `gh api repos/storytold/texturecraft/actions/workflows/nightly.yml --jq .id` once `nightly.yml` reaches `main` | -| `producer_tooling_revision`, `signer_tooling_revision`, `producer_workflow_ref` | `605d5876…` (craft-common-actions #339) | The callers' pin | +| `producer_workflow_id` | `429738073` | `gh api repos/storytold/texturecraft/actions/workflows/nightly.yml --jq .id` | +| `producer_tooling_revision`, `signer_tooling_revision`, `producer_workflow_ref` | `be00e5cc…` (craft-common-actions #371 after #370, #369 and #364) | The callers' pin | | `manual_actors` / `automatic_signer_actors` | the five release managers / `[]` | release-managers team (id 19837241) members who can push; equals the producer caller's `manual-actors` | | `max_age_seconds`, `max_artifact_bytes` | `86400`, `2147483648` | Go-live checklist | | `platforms` | three rows (`windows-x86_64`, `linux-x86_64`, `macos-aarch64`) | Stable suite signing identities (`Learning Machines Inc` Authenticode subject, Linux OpenPGP fingerprint `2B76741B414AAD6CD33E631213A005C0B9D7C3ED`, Apple Team ID `DJ6XS33FX8`) | @@ -68,11 +97,15 @@ those values in the same reviewed change that promotes the policy to `release`. - `.github/workflows/nightly.yml`: default-main registration of the unsigned producer, named `TextureCraft unsigned nightly`, enabled for manual dispatch by `manual-actors`; no signing secrets may be passed or inherited. -- `.github/workflows/nightly-sign.yml`: top-level release registration, enabled for manual dispatch, - and identical on main and release after reviewed promotion. It rejects wrong repository/event/actual branch, +- `.github/workflows/nightly-sign.yml`: top-level registration on `nightly-signer`, enabled for manual dispatch, + and only ever fast-forwards to reviewed main commits. It rejects wrong repository/event/actual branch, including same-name tags. Its constant whole-run concurrency is distinct from stable, cancellation is off and `queue: max` must be hosted-qualified. The caller itself passes no - credentials; only the shared callee's sign jobs bind the `release` environment. + credentials; only the shared callee's sign jobs bind the `release` environment, which must admit + `nightly-signer` alongside `release` before the first dispatch. +- `.github/workflows/nightly-dispatch.yml`: transport only, never authorization. It is literally + off (`false &&`) and forwards only a first-attempt scheduled producer to `nightly-sign.yml` on + `nightly-signer`. No schedule is registered until activation is reviewed. - Shared reusable entrypoints are `nightly-unsigned.yml` and `nightly-release.yml` in `storytold/craft-common-actions`. Both must resolve to a **real reviewed public immutable commit**; the defining workflow SHA and tooling input must match. @@ -89,7 +122,15 @@ those values in the same reviewed change that promotes the policy to `release`. - `nightly-sign.yml` keeps its literal root `concurrency:` block (`texturecraft-nightly-release`, `cancel-in-progress: false`, `queue: max`). - `.github/nightly-signing-policy.json` matches the v3 schema, repository identity, platform - trust anchors, CI workflow trigger contract, and SonarCloud project identity. + trust anchors, CI workflow trigger contract, SonarCloud project identity, and the reviewed Sonar + gate shape (accepted failures inside the issue scope, every live gate condition present once). +- The signer guards `refs/heads/nightly-signer`, passes `app-name: texturecraft`, and the policy's + `release_branch` names it. +- A trust-closure scan reads every workflow: nothing binds an `environment`, only `nightly-sign.yml` + calls `nightly-release.yml` (at a full SHA), and the only caller of the shared stable `release.yml` + is `release.yml`. +- `nightly-dispatch.yml` keeps a literal-off guard, a `workflow_run`-only trigger and a + `refs/heads/nightly-signer` request. ## App-side producer scripts (Windows and macOS) @@ -134,3 +175,15 @@ release-dispatch and macOS signing suites, plus the Nightly icons must be byte-i `nightly-signing-tests.ps1` (Windows, with `-FixtureRoot`), and `bash -n` plus shellcheck over the three macOS scripts. The full-ci macOS job (`nightly-macos.yml`) is the only place the bundle and its version query actually run before the first supervised release. + +## The Sonar issue scope + +The pinned candidate validator requires every entry in `candidate_policy.sonar.issue_types` to map +from a reviewed `accepted_conditions` row, and it requires the gate condition set to equal +`accepted_conditions` plus `required_conditions`. The installed policy lists `VULNERABILITY` with +`new_security_rating` accepted (max 5) and the other five gate conditions required - the same shape +PhotoCraft and WordCraft ship - so it satisfies that contract before SonarCloud is read. `debt` stays +empty, so any unresolved vulnerability on `main` is still refused, and the live gate is still compared +condition by condition against the policy. `producer_workflow_id` is now populated and the signer runs +on `nightly-signer`; the registry's Windows and macOS targets are what still stand between this tree +and a first signed nightly. diff --git a/docs/releasing.md b/docs/releasing.md index 44bce55c..6f87d947 100644 --- a/docs/releasing.md +++ b/docs/releasing.md @@ -155,6 +155,13 @@ entry and icons). Secrets live only in the `release` environment and are all optional: a missing one gives an unsigned artifact and a `::warning::`, never a failed build. +The supervised nightly signer does not sign from `release`: it runs on `refs/heads/nightly-signer`, +which only ever fast-forwards to reviewed main commits, and the `release` environment must admit +`nightly-signer` alongside `release` before the first dispatch. Everything that can reach it is the +trust closure: all of `.github/` and `packaging/`, including `packaging/env.sh`, which +`packaging/macos/import-cert.sh` sources with the Apple keys. Stable releases still come only from +`refs/heads/release`. + - macOS: `APPLE_CERTIFICATE`, `APPLE_CERTIFICATE_PASSWORD`, `KEYCHAIN_PASSWORD` (import into a temporary keychain, `packaging/macos/import-cert.sh`), then `APPLE_ID`, `APPLE_PASSWORD`, `APPLE_TEAM_ID` for `notarytool` and stapling. Without them the app is ad-hoc signed. diff --git a/packaging/nightly-release-tests.py b/packaging/nightly-release-tests.py index ee421e95..c55e54c1 100755 --- a/packaging/nightly-release-tests.py +++ b/packaging/nightly-release-tests.py @@ -9,6 +9,9 @@ import unittest ROOT = Path(__file__).resolve().parents[1] INSTALLED_POLICY = ROOT / ".github/nightly-signing-policy.json" +APP_NAME = "texturecraft" +PRODUCER_WORKFLOW_NAME = "TextureCraft unsigned nightly" + NIGHTLY_PLATFORMS = ("windows-x86_64", "linux-x86_64", "macos-aarch64") NIGHTLY_TRUST = { "windows-x86_64": ("publisher_subject", @@ -42,6 +45,30 @@ def assert_nightly_serialization(source): raise ValueError("nightly serialization must use its stable group and no cancellation") +def literal_off(condition): + """True only for a guard that a reviewed test update can still see is switched off.""" + expression = " ".join(condition.split()) + if expression.startswith("${{") and expression.endswith("}}"): + expression = expression[3:-2].strip() + if expression == "false": + return True + if not expression.startswith("false && "): + return False + # A top-level OR could override the leading false; parentheses must balance. + expression = re.sub(r"'(?:''|[^'])*'", "''", expression) + depth = 0 + for token in re.findall(r"\(|\)|\|\|", expression): + if token == "(": + depth += 1 + elif token == ")": + depth -= 1 + if depth < 0: + return False + elif depth == 0: + return False + return depth == 0 + + def job_conditions(jobs): """Each job-level `if:` as (block indicator or None, the whole expression YAML would read).""" lines = jobs.splitlines() @@ -226,7 +253,7 @@ class NightlyEnabledCallers(unittest.TestCase): "github.ref_type == 'branch' && (github.event_name == 'schedule' || " "github.event_name == 'workflow_dispatch')", "nightly-sign.yml": "github.repository == 'storytold/texturecraft' && github.event_name == 'workflow_dispatch' && " - "github.ref == 'refs/heads/release' && github.ref_type == 'branch'", + "github.ref == 'refs/heads/nightly-signer' && github.ref_type == 'branch'", } def test_enabled_jobs_keep_exact_context_guards(self): @@ -298,7 +325,8 @@ class NightlyInstalledPolicy(unittest.TestCase): self.assertEqual(set(self.policy), expected) self.assertEqual(self.policy["schema"], "craft-nightly-release-policy/v3") self.assertEqual(self.policy["repository"], "storytold/texturecraft") - self.assertEqual(self.policy["release_branch"], "release") + self.assertEqual(self.policy["release_branch"], SIGNER_BRANCH, + "the signer runs on its dedicated branch") self.assertIs(type(self.policy["repository_id"]), int) self.assertGreater(self.policy["repository_id"], 0) # producer_workflow_id is null until nightly.yml is registered on main; once set, must be a positive int. @@ -384,6 +412,353 @@ class NightlyInstalledPolicy(unittest.TestCase): self.assertIn(item["type"], sonar["issue_types"]) self.assertRegex(item["hash"], r"^[0-9a-f]{32}$") + def test_sonar_policy_keeps_the_shared_candidate_contract(self): + """The Sonar shape craft-common-actions' candidate contract() admits, refused here first. + + An empty issue scope, an accepted condition outside the reviewed issue types, a metric in both + lists, a missing live gate condition or a widened security bound is refused at admission, so + this suite must catch it before a nightly run can. `debt` stays empty, so any unresolved + vulnerability on main is still refused; accepting the new-code rating only records the + reviewed A threshold instead of demanding a clean rating the live gate does not. + """ + sonar = self.policy["candidate_policy"]["sonar"] + accepted = {"bugs": "BUG", "vulnerabilities": "VULNERABILITY", "code_smells": "CODE_SMELL", + "security_rating": "VULNERABILITY", "new_security_rating": "VULNERABILITY"} + gate = {"new_reliability_rating", "new_security_rating", "new_maintainability_rating", + "new_coverage", "new_duplicated_lines_density", "new_security_hotspots_reviewed"} + self.assertTrue(sonar["issue_types"], "an empty issue scope is refused as unreviewed") + self.assertEqual(len(sonar["issue_types"]), len(set(sonar["issue_types"]))) + metrics = {} + for field in ("accepted_conditions", "required_conditions"): + for condition in sonar[field]: + with self.subTest(field=field, metric=condition.get("metric")): + expected = {"metric", "comparator", "error_threshold"} + if field == "accepted_conditions": + expected.add("maximum") + self.assertEqual(set(condition), expected) + self.assertNotIn(condition["metric"], metrics, "one condition per gate metric") + metrics[condition["metric"]] = condition + self.assertIn(condition["comparator"], ("GT", "LT")) + self.assertRegex(condition["error_threshold"], r"^(?:0|[1-9][0-9]*)(?:\.[0-9]+)?$") + if field != "accepted_conditions": + continue + self.assertIn(condition["metric"], accepted, "an accepted metric outside the reviewed map") + self.assertIn(accepted[condition["metric"]], sonar["issue_types"], + "an accepted failure must lie inside the reviewed issue scope") + self.assertEqual(condition["comparator"], "GT") + self.assertRegex(condition["maximum"], r"^(?:0|[1-9][0-9]*)(?:\.[0-9]+)?$") + maximum = float(condition["maximum"]) + if condition["metric"] in ("security_rating", "new_security_rating"): + self.assertEqual(int(maximum), maximum, "the A..E bound is a whole rating") + self.assertTrue(1 <= maximum <= 5, "the security bound stays A..E") + self.assertEqual(condition["error_threshold"], "1", "the reviewed A threshold stays") + else: + self.assertLessEqual(maximum, len(sonar["debt"]), "accepted failures exceed the reviewed debt") + self.assertEqual({accepted[c["metric"]] for c in sonar["accepted_conditions"]}, set(sonar["issue_types"]), + "accepted conditions and reviewed issue types must cover the same scope") + self.assertEqual(set(metrics), gate, "every live gate condition stays gated exactly once") + + +SIGNER_BRANCH = "nightly-signer" +SHARED = "storytold/craft-common-actions/.github/workflows/" +# App workflows reviewed to call the shared stable release.yml. That callee must carry the +# stable-only environment guard (dry runs and non-release refs bind no environment); the +# nightly-signer settings scan checks the resolved callee before creating or advancing the branch. +REVIEWED_STABLE_RELEASE_CALLERS = {"release.yml"} + + +def app_workflows(): + return {path.name: path.read_text() for path in sorted((ROOT / ".github/workflows").glob("*.y*ml"))} + + +WORKFLOW_KEY = re.compile(r'''("(?:[^"\\]|\\.)*"|'(?:[^']|'')*'|[^\s'"#{}\[\],:&*!|>%@`?-][^:#,{}]*?|-[^\s:#][^:#,{}]*?)\s*:(?:\s+(.*))?$''') + + +def _workflow_key(text): + if text.startswith('"'): + return None if "\\" in text else text[1:-1] + if text.startswith("'"): + return text[1:-1].replace("''", "'") + return text + + +def _workflow_value(text): + """A one-line scalar value without its comment and quotes; None when escaped or unterminated.""" + text = text.strip() + if text.startswith('"'): + quoted = re.match(r'"((?:[^"\\]|\\.)*)"\s*(?:#.*)?$', text) + return None if quoted is None or "\\" in quoted.group(1) else quoted.group(1) + if text.startswith("'"): + quoted = re.match(r"'((?:[^']|'')*)'\s*(?:#.*)?$", text) + return None if quoted is None else quoted.group(1).replace("''", "'") + return re.split(r"\s+#", text, maxsplit=1)[0].strip() + + +def _strip_comment(text): + """(text without its comment, unterminated) using a quote-aware scan. + + As in YAML, a quote opens a quoted scalar only where a scalar starts (line start or after + `:`, `-`, `,`, `{` or `[`), and a `#` starts a comment only outside quotes, at the start or + after whitespace. + """ + quote, index = None, 0 + while index < len(text): + char = text[index] + if quote == '"': + if char == "\\": + index += 2 + continue + if char == '"': + quote = None + elif quote == "'": + if char == "'": + if text[index + 1:index + 2] == "'": + index += 2 + continue + quote = None + elif char in "\"'" and text[:index].rstrip()[-1:] in ("", ":", "-", ",", "{", "["): + quote = char + elif char == "#" and (index == 0 or text[index - 1] in " \t"): + return text[:index].rstrip(), False + index += 1 + return text.rstrip(), quote is not None + + +FLOW_QUOTED = re.compile(r"\"(?:[^\"\\]|\\.)*\"|'(?:[^']|'')*'") +FLOW_FORBIDDEN_KEYS = {"environment", "uses"} + + +def workflow_entries(source): + """Every mapping entry in a workflow, plus the YAML forms this reader refuses. + + A narrow reader, not a YAML parser (none ships with the runner's Python). Each entry is + (line, key, value, multiline): plain, single- and double-quoted keys and one-line values in + block and simple one-line flow mappings. Block scalar bodies are skipped, and an entry whose + value is a block scalar or continues on the next lines is marked multiline. It refuses whatever + could hide a key from it: escaped double-quoted keys, explicit `?` keys, merge keys, anchors, + aliases, tags, tab indentation and nested or multi-line flow. + """ + lines = source.splitlines() + entries, refused, block = [], [], None + + def continues(index, indent): + for follow in lines[index + 1:]: + stripped = follow.strip() + if not stripped or stripped.startswith("#"): + continue + deeper = len(follow) - len(follow.lstrip(" ")) > indent + return deeper and not stripped.startswith("- ") and WORKFLOW_KEY.match(stripped) is None + return False + + for index, raw in enumerate(lines): + number = index + 1 + stripped = raw.strip() + indent = len(raw) - len(raw.lstrip(" ")) + if block is not None: + if not stripped or indent > block: + continue + block = None + if not stripped or stripped.startswith("#"): + continue + if "\t" in raw[:indent + 1]: + refused.append(f"line {number}: tab indentation"); continue + body, unterminated = _strip_comment(stripped) + if unterminated: + refused.append(f"line {number}: unterminated or multi-line quoted scalar"); continue + if not body: + continue + while body.startswith("- "): + body = body[2:].lstrip() + if body == "?" or body.startswith("? "): + refused.append(f"line {number}: explicit key"); continue + match = WORKFLOW_KEY.match(body) + value = body + if match is not None: + key, value = _workflow_key(match.group(1)), match.group(2) or "" + if key is None: + refused.append(f"line {number}: escaped double-quoted key"); continue + if key == "<<": + refused.append(f"line {number}: merge key"); continue + plain = re.sub(r"\$\{\{.*?\}\}", "", value).strip() + bare = re.sub(r"\"(?:[^\"\\]|\\.)*\"|'(?:[^']|'')*'", "''", plain) + if re.match(r"[&*!]", plain): + refused.append(f"line {number}: anchor, alias or tag") + is_block = re.fullmatch(r"[|>][0-9+-]*", plain) is not None + if match is not None: + entries.append((number, key, _workflow_value(value), + is_block or ((value == "" or not is_block) and continues(index, indent)))) + if "{" in bare and bare != "{}": + masked = re.fullmatch(r"\{([^{}\[\]]*)\}", FLOW_QUOTED.sub("''", value.strip())) + flow = re.fullmatch(r"\{([^{}\[\]]*)\}", value.strip()) + if any(set(scalar[1:-1]) & set("#{}[],") for scalar in FLOW_QUOTED.findall(value)): + refused.append(f"line {number}: flow mapping quoted scalar with # or flow punctuation") + elif masked is None or flow is None: + refused.append(f"line {number}: nested or multi-line flow mapping") + else: + # The masked text only proves the shape: a quoted key ("uses", 'environment') keeps + # its identity, so the entries are read from the original mapping text, never ''. + for item in flow.group(1).split(","): + entry = WORKFLOW_KEY.match(item.strip()) + key = _workflow_key(entry.group(1)) if entry else None + if key is None: + refused.append(f"line {number}: unreadable flow mapping entry") + elif key in FLOW_FORBIDDEN_KEYS: + refused.append(f"line {number}: {key} in a flow mapping (must be block style)") + else: + entries.append((number, key, _workflow_value(entry.group(2) or ""), False)) + if match is not None and is_block: + block = indent + return entries, refused + + +def workflow_keys(source): + """(line, key) for every mapping entry, plus the refused YAML forms.""" + entries, refused = workflow_entries(source) + return [(number, key) for number, key, _, _ in entries], refused + + +SHARED_CALLEE = re.compile(r"storytold/craft-common-actions/\.github/workflows/([\w.-]+\.ya?ml)@(\S+)", re.IGNORECASE) +INSPECTED_KEYS = {"environment", "uses"} + + +def trust_closure_problems(workflows): + """The nightly-signer trust-closure scan over app workflow sources; empty when the tree is safe. + + Every key it inspects comes from workflow_entries(), never a regex over the raw text. + """ + problems, stable_callers, signer_calls = [], set(), 0 + for name, source in workflows.items(): + entries, refused = workflow_entries(source) + problems.extend(name + " uses YAML the scan cannot read (" + reason + ")" for reason in refused) + for number, key, value, multiline in entries: + if key not in INSPECTED_KEYS: + continue + if key == "environment": + problems.append(f"{name} binds an environment directly (line {number})") + continue + if value is None or multiline: + problems.append(f"{name} has a uses value the scan cannot read (line {number})") + continue + callee = SHARED_CALLEE.fullmatch(value) + if callee is None: + if re.search(r"craft-common-actions", value, re.IGNORECASE) and re.search(r"workflows/(nightly-)?release\.ya?ml", value, re.IGNORECASE): + problems.append(f"{name} has an unrecognised shared release caller (line {number})") + continue + workflow, ref = callee.group(1), callee.group(2) + if workflow.lower() in ("nightly-release.yml", "nightly-release.yaml"): + if name == "nightly-sign.yml": + signer_calls += 1 + if name != "nightly-sign.yml" or not re.fullmatch(r"[0-9a-f]{40}", ref): + problems.append(name + " calls nightly-release.yml@" + ref) + if workflow.lower() in ("release.yml", "release.yaml"): + stable_callers.add(name) + if ref != "main" and not re.fullmatch(r"[0-9a-f]{40}", ref): + problems.append(name + " calls release.yml@" + ref + "; use @main or a reviewed full SHA") + if stable_callers != REVIEWED_STABLE_RELEASE_CALLERS: + problems.append("shared release.yml callers are " + ", ".join(sorted(stable_callers))) + if signer_calls != 1: + problems.append("nightly-sign.yml must call nightly-release.yml exactly once") + return problems + + +class NightlySignerBranchTrustClosure(unittest.TestCase): + """On refs/heads/nightly-signer, only the pinned signer caller may reach an environment.""" + + def test_trust_closure_scan_passes_on_this_tree(self): + self.assertEqual(trust_closure_problems(app_workflows()), []) + + def test_trust_closure_scan_refuses_each_route_into_an_environment(self): + tree = app_workflows() + bad = { + "a workflow binds an environment": {**tree, "extra.yml": "jobs:\n x:\n runs-on: ubuntu-latest\n environment: release\n"}, + "a double-quoted environment key": {**tree, "extra.yml": 'jobs:\n x:\n runs-on: ubuntu-latest\n "environment": release\n'}, + "a single-quoted environment key": {**tree, "extra.yml": "jobs:\n x:\n runs-on: ubuntu-latest\n 'environment' : release\n"}, + "an environment mapping": {**tree, "extra.yml": "jobs:\n x:\n runs-on: ubuntu-latest\n environment:\n name: release\n"}, + "an environment in a flow mapping": {**tree, "extra.yml": "jobs:\n x: {runs-on: ubuntu-latest, environment: release}\n"}, + "an escaped key": {**tree, "extra.yml": 'jobs:\n x:\n runs-on: ubuntu-latest\n "environ\\u006dent": release\n'}, + "a merge key": {**tree, "extra.yml": "base: &b\n runs-on: ubuntu-latest\njobs:\n x:\n <<: *b\n"}, + "an explicit key": {**tree, "extra.yml": "jobs:\n x:\n ? environment\n : release\n"}, + "a nested flow mapping": {**tree, "extra.yml": "jobs:\n x: {steps: [{run: a}]}\n"}, + "a double-quoted uses key copying the signer": {**tree, "extra.yml": 'jobs:\n x:\n "uses": ' + SHARED + "nightly-release.yml@" + "a" * 40 + "\n"}, + "a single-quoted uses key": {**tree, "extra.yml": "jobs:\n x:\n 'uses': " + SHARED + "nightly-release.yml@" + "a" * 40 + "\n"}, + "a quoted uses value": {**tree, "extra.yml": 'jobs:\n x:\n uses: "' + SHARED + "nightly-release.yml@" + "a" * 40 + '"\n'}, + "uses in a flow mapping": {**tree, "extra.yml": "jobs:\n x: {uses: " + SHARED + "nightly-release.yml@" + "a" * 40 + "}\n"}, + "a differently cased owner": {**tree, "extra.yml": "jobs:\n x:\n uses: Storytold/Craft-Common-Actions/.github/workflows/nightly-release.yml@" + "a" * 40 + "\n"}, + "a folded uses value": {**tree, "extra.yml": "jobs:\n x:\n uses: >-\n " + SHARED + "nightly-release.yml@" + "a" * 40 + "\n"}, + "a continued uses value": {**tree, "extra.yml": "jobs:\n x:\n uses: " + SHARED + "\n nightly-release.yml@" + "a" * 40 + "\n"}, + "a quoted second signer call": {**tree, "nightly-sign.yml": tree["nightly-sign.yml"] + " again:\n \"uses\": " + SHARED + "nightly-release.yml@" + "a" * 40 + "\n"}, + "a hash inside a quoted flow scalar": {**tree, "extra.yml": 'jobs:\n x: {name: "a} # b", runs-on: ubuntu-latest, environment: release, steps: []}\n'}, + "a single-quoted hash in a flow scalar": {**tree, "extra.yml": "jobs:\n x: {name: 'a # b', runs-on: ubuntu-latest}\n"}, + "a comma inside a quoted flow scalar": {**tree, "extra.yml": 'jobs:\n x: {name: "a, environment: release", runs-on: ubuntu-latest}\n'}, + "a bracket inside a quoted flow scalar": {**tree, "extra.yml": 'jobs:\n x: {name: "[a]", runs-on: ubuntu-latest}\n'}, + "an unterminated quote": {**tree, "extra.yml": 'jobs:\n x:\n name: "a\n b"\n runs-on: ubuntu-latest\n'}, + "environment in any flow mapping": {**tree, "extra.yml": "jobs:\n x:\n runs-on: ubuntu-latest\n with: {environment: release}\n"}, + "a double-quoted environment key in a flow mapping": {**tree, "extra.yml": 'jobs:\n x:\n runs-on: ubuntu-latest\n with: {"environment": release}\n'}, + "a single-quoted environment key in a flow mapping": {**tree, "extra.yml": "jobs:\n x:\n runs-on: ubuntu-latest\n with: {'environment': release}\n"}, + "a double-quoted uses key in a flow mapping": {**tree, "extra.yml": 'jobs:\n x: {"uses": ' + SHARED + "nightly-release.yml@" + "a" * 40 + "}\n"}, + "uses in any flow mapping": {**tree, "extra.yml": "jobs:\n x:\n steps:\n - {uses: actions/checkout@v4}\n"}, + "another caller of the signer": {**tree, "extra.yml": "jobs:\n x:\n uses: " + SHARED + "nightly-release.yml@" + "a" * 40 + "\n"}, + "a mutable signer pin": {**tree, "nightly-sign.yml": re.sub(r"nightly-release\.yml@[0-9a-f]{40}", "nightly-release.yml@main", tree["nightly-sign.yml"])}, + "a new stable release caller": {**tree, "extra.yml": "jobs:\n x:\n uses: " + SHARED + "release.yml@main\n"}, + "a stable caller on a branch or tag ref": {**tree, "release.yml": tree["release.yml"].replace(SHARED + "release.yml@main", SHARED + "release.yml@v1")}, + } + for label, workflows in bad.items(): + with self.subTest(case=label): + self.assertTrue(trust_closure_problems(workflows)) + + def test_quoted_keys_in_a_flow_mapping_are_read_not_masked(self): + entries, refused = workflow_entries('jobs:\n x: {runs-on: ubuntu-latest, "name": build}\n') + self.assertEqual(refused, []) + self.assertIn((2, "name", "build", False), entries, "a quoted key keeps its identity") + self.assertIn((2, "runs-on", "ubuntu-latest", False), entries) + _, refused = workflow_entries("jobs:\n x: {runs-on: ubuntu-latest, 'environment': release}\n") + self.assertEqual(refused, ["line 2: environment in a flow mapping (must be block style)"]) + + def test_signer_dispatch_guard_and_policy_name_the_same_branch(self): + sign = (ROOT / ".github/workflows/nightly-sign.yml").read_text() + (_, guard), = job_conditions(sign.split("\njobs:\n", 1)[1]) + self.assertIn("github.ref == 'refs/heads/" + SIGNER_BRANCH + "'", guard) + self.assertNotIn("refs/heads/release", sign, "the signer no longer runs on the stable branch") + self.assertEqual(re.findall(r"(?m)^ app-name: (\S+)$", sign), [APP_NAME], + "the shared signer needs the reviewed registry app") + dispatch = (ROOT / ".github/workflows/nightly-dispatch.yml").read_text() + self.assertEqual(re.findall(r"'ref': '([^']+)'", dispatch), ["refs/heads/" + SIGNER_BRANCH]) + self.assertEqual(json.loads(INSTALLED_POLICY.read_text())["release_branch"], SIGNER_BRANCH) + + +def dispatch_triggers(source): + """The dispatch workflow's own triggers, one per line, as a caller may register them.""" + events = source.split("\non:\n", 1)[1].split("\npermissions:", 1)[0] + return [line for line in events.splitlines() if line.startswith(" ") and not line.startswith(" ") + and line.strip() and not line.lstrip().startswith("#")] + + +class NightlyDispatchTransport(unittest.TestCase): + """The scheduled transport stays literally off and can only reach the signer branch.""" + + def setUp(self): + self.source = (ROOT / ".github/workflows/nightly-dispatch.yml").read_text() + + def test_every_dispatch_job_is_literal_off(self): + jobs = self.source.split("\njobs:\n", 1)[1] + headers = re.findall(r"(?m)^ (?![\s#])[^\n]+", jobs) + conditions = job_conditions(jobs) + self.assertTrue(headers) + self.assertEqual(len(conditions), len(headers), "every job needs a literal-off condition") + for _, expression in conditions: + self.assertTrue(literal_off(expression), "nightly activation requires reviewed test update") + + def test_only_a_completed_scheduled_producer_is_transported(self): + self.assertEqual(re.findall(r"(?m)^ workflows: (.+)$", self.source), + ["[" + PRODUCER_WORKFLOW_NAME + "]"]) + self.assertEqual(dispatch_triggers(self.source), [" workflow_run:"], + "the transport is not a second entry point") + self.assertNotIn("schedule:", self.source) + self.assertIn("producer.get('event') == 'schedule'", self.source) + + def test_the_request_names_the_signer_workflow_and_branch(self): + self.assertIn("repos/storytold/" + APP_NAME + "/actions/workflows/nightly-sign.yml/dispatches", self.source) + self.assertNotIn("'ref': 'release'", self.source) if __name__ == "__main__": unittest.main(verbosity=2) From 3bcd6f7153cb29a659c105444a99302fdf3baf05 Mon Sep 17 00:00:00 2001 From: aiongg Date: Thu, 26 Nov 2026 03:51:34 +0000 Subject: [PATCH 64/83] Texture-set hover tests drive the app through the framework runtime --- crates/ui-egui/src/dock.rs | 5 ++++- crates/ui-egui/src/viewport.rs | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/crates/ui-egui/src/dock.rs b/crates/ui-egui/src/dock.rs index 9363b3ba..4226e057 100644 --- a/crates/ui-egui/src/dock.rs +++ b/crates/ui-egui/src/dock.rs @@ -3349,7 +3349,10 @@ mod texture_set_list_tests { .unwrap(); let first = session.doc.project.texture_sets[0].name.clone(); let second = session.doc.project.texture_sets[1].name.clone(); - let mut harness = Harness::builder().with_size(vec2(1600.0, 960.0)).build_eframe(|context| TextureCraftApp::new(context, session)); + let mut harness = Harness::builder() + .with_size(vec2(1600.0, 960.0)) + .with_context_setup(crate::framework::install_headless) + .build_eframe(|context| TextureCraftApp::new(context, session)); harness.run_steps(4); harness.get_by_role_and_label(egui::Role::ListItem, &second).focus(); diff --git a/crates/ui-egui/src/viewport.rs b/crates/ui-egui/src/viewport.rs index 4858a29a..3ae2bfbd 100644 --- a/crates/ui-egui/src/viewport.rs +++ b/crates/ui-egui/src/viewport.rs @@ -2577,7 +2577,10 @@ mod tests { let selected_set = session.ts(); assert_ne!(hovered_set, selected_set); - let mut harness = Harness::builder().with_size(egui::vec2(1600.0, 1500.0)).build_eframe(|context| TextureCraftApp::new(context, session)); + let mut harness = Harness::builder() + .with_size(egui::vec2(1600.0, 1500.0)) + .with_context_setup(crate::framework::install_headless) + .build_eframe(|context| TextureCraftApp::new(context, session)); let preview = |harness: &Harness<'_, TextureCraftApp>| { harness.ctx.data(|data| data.get_temp::>(egui::Id::unique(TEST_SCENE_SET_HOVER))).expect("the 3D view submitted a scene frame") }; From bae6870aec26bbb22c819ccf046ae76ca5ef141e Mon Sep 17 00:00:00 2001 From: chasse20 Date: Wed, 25 Nov 2026 22:53:27 -0500 Subject: [PATCH 65/83] Docs: update the roadmap after the November 25 audit --- ROADMAP.md | 233 +++++++++++++++++++++++++---------------------------- 1 file changed, 112 insertions(+), 121 deletions(-) diff --git a/ROADMAP.md b/ROADMAP.md index cb114376..87024694 100644 --- a/ROADMAP.md +++ b/ROADMAP.md @@ -1,14 +1,14 @@ # TextureCraft roadmap -Stage: alpha (readiness assessment) · next: beta, ~75% readiness plus scoped compatibility and integration gates; remaining effort unestimated +**Alpha**. The proposed beta gate is about 75% readiness plus scoped compatibility and integration checks. Remaining effort is unestimated. -> Last reviewed: 2026-11-16 · Last updated: 2026-11-16 · Change: major (UI/functionality audit, possible format/package reworks, unfinished `.mcmat` integration and incoming ArtCraft UI/shared-library work) · Target: reference app 12.2.0 - -TextureCraft is a clean-room implementation of the professional texture-painting workflow. This -assessment covers **main at [62b2b13](https://github.com/storytold/texturecraft/commit/62b2b13fdd32740b6e118cd00c5e0d0c12b30815), -version 0.6.1**, compared with the installed reference app on 2026-11-16. It follows the -[PhotoCraft roadmap format](https://github.com/storytold/photocraft/blob/main/ROADMAP.md). -Detail: [UI gaps and functional task audit](docs/ui-parity.md), [features](docs/features.md), [menu checklist](docs/parity.md), +**Last updated and reviewed 2026-11-25.** The implementation audit covers main at +[`3c026860`](https://github.com/storytold/texturecraft/commit/3c026860e36e5fbe2147c6c78ca0bbc617575887), +with workspace version 0.6.1. Current estimates incorporate landed workflows, Linux regression +tests and the MaterialCraft round trip. The November 16 live comparison with reference app 12.2.0 +at [`62b2b13`](https://github.com/storytold/texturecraft/commit/62b2b13fdd32740b6e118cd00c5e0d0c12b30815) +provides the starting scores. The live artist tasks still need a repeat on current main. +See [UI gaps and functional tasks](docs/ui-parity.md), [features](docs/features.md), [menu checklist](docs/parity.md), [architecture](docs/architecture.md), [automation](docs/control-protocol.md), [localization](docs/localization-parity.md), [releasing](docs/releasing.md). @@ -19,65 +19,49 @@ still need investigation; no `.spp` reader is implemented. Writing `.spp`, round back into it and compatibility with other proprietary asset/preset formats are outside this goal. Pipeline exchange uses USD, glTF/GLB, MaterialX and texture maps. -The current `.tcraft` schema/container and output-package contracts may be reworked; their -present implementations are not a frozen design. MaterialCraft `.mcmat` import remains a goal -whose next format is unfinished upstream. ArtCraft UI refactoring and further shared-library -adoption also add integration and regression work. These dependencies are part of the remaining -roadmap, even where a current task already passes. +The current `.tcraft` schema/container and output-package contracts remain open to revision. +MaterialCraft and TextureCraft have landed procedural `.mcmat` v3 support. The source-build round trip passed at the revisions below. The exchange gate still needs +a supported release pair and artist workflow checks. ArtCraft UI refactoring and +further shared-library adoption also require integration and regression checks. ## Headline numbers -| | Value | Kind | -|---|---|---| -| Feature breadth | ~80% (75–85%) | Estimated across feature families; no exhaustive target inventory | -| Ready for real work | ~60% (50–70%) | Estimated readiness of the assessed revision; no completion credit for incoming reworks/integrations | -| Mainstream practitioner | ~60% (50–70%) | Estimated for regular asset texturing, baking, masking and pipeline delivery | -| Essentials user | ~75% (65–85%) | Estimated for a simple mesh, layered materials/paint and texture export | -| Desktop menu catalog | 59/59 live | Observed through the running app; this is TextureCraft's own catalog | -| Engine commands | 178 registered | Observed through the running app; registration does not prove every parameter path | -| Functional review | 20 scoped check groups | UI, mixed-surface and command cases [recorded separately](docs/ui-parity.md#functional-task-audit); not an exhaustive coverage score | -| Remaining to beta | Unestimated | Requires acceptance tasks, performance budgets and a decision on required format/package/UI migrations | -| Remaining to full scoped parity | Unestimated | Includes possible `.tcraft`/output reworks, upstream `.mcmat`, ArtCraft UI/shared-library adoption, `.spp` feasibility and workflow/fidelity work | +| Measure | Nov. 16 baseline | Nov. 25 estimate | Basis | +|---|---:|---:|---| +| Feature breadth | ~80% | ~90% | Coverage across feature families, with gains in generators, fills, baking and interchange | +| Ready for real work | ~60% | ~68% | Weighted estimate from the dimensions below. The largest gains are in feature depth, UI and interchange | +| Remaining to beta | Unestimated | Unestimated | Requires acceptance tasks, performance budgets and a decision on required format, package and UI migrations | +| Remaining to full scoped parity | Unestimated | Unestimated | Includes possible `.tcraft` and output-package reworks, `.mcmat` release validation, ArtCraft UI and shared libraries, `.spp` feasibility, and workflow and fidelity checks | -The former ~94% figure mostly counted implementation paths. This review also asks whether an -artist gets equivalent controls, predictable output, responsive interaction and dependable -delivery. The change is a measurement rebaseline and an expanded import goal, not a measured -loss of functionality. Percentages are rounded judgments; ranges express uncertainty, not -statistical confidence intervals. The old “~6 h + baking TBD” remainder is withdrawn: this -review provides no calibrated engineering or agent-hour forecast. +The November 16 live app showed 59 of 59 menu entries and 178 registered engine commands. +That review recorded [20 scoped check groups](docs/ui-parity.md#functional-task-audit). -The percentages describe behavior at `62b2b13`, not how much of a settled delivery plan is -finished. Potential rework can revisit working code and require repeating the checks below. -Its scope and cost are not yet measured, so remaining effort cannot be calculated as -100 minus the readiness score. Incoming upstream work is not counted as landed functionality. +Feature breadth estimates how much of the scoped feature set is present. Readiness also weighs +control depth, output fidelity, responsiveness, project safety and delivery. The earlier ~94% +figure mostly counted implementation paths and used a narrower scope. The current figures are +audit judgments based on the evidence below. Potential format and UI rework can require repeating +earlier checks, and its scope and cost remain unestimated. ### Readiness by audience -| Audience | Ready % | Hours to ~95% | Work that dominates | -|---|---|---|---| -| Full scoped target | ~60% | Unestimated | Workflow depth, format/output-package decisions, `.mcmat`, ArtCraft UI/shared libraries, bake/display fidelity, color management, read-only `.spp` and platform validation | -| Mainstream practitioner | ~60% | Unestimated | Reliable masks/painting, MaterialCraft exchange once its contract is ready, project/package compatibility, larger projects and destination-app checks | -| Essentials user | ~75% | Unestimated | Discoverable controls, predictable startup/GPU selection and save/reopen reliability retained through format/UI migrations | +| Audience | Nov. 16 baseline | Nov. 25 estimate | Work that dominates | +|---|---:|---:|---| +| Full scoped target | ~60% | ~68% | Workflow depth, format and package decisions, ArtCraft UI and shared libraries, bake and display fidelity, color management, read-only `.spp` and platform validation | +| Mainstream practitioner | ~60% | ~70% | Production-scale baking and masking, project and package compatibility, and destination-tool checks | +| Essentials user | ~75% | ~85% | Startup and GPU coverage, discoverable controls, and dependable save/reopen for simple mesh, paint, material and texture-export tasks | -Why alpha. Mouse/keyboard tasks verified 3D/2D painting, undo/redo, material drag and drop, mask -and generator editing, UV rectangle fill, UI baking, native saving and texture export. Separate -command checks covered high-to-low transfer, UDIM sizes/packing and scene/material exports. -The interface is recognizably close in its painting, bake and export workspaces, but still lacks -mask-thumbnail effect menus and several fill controls. -Generator depth is limited, bake equivalence is open, -and hardware/performance coverage is incomplete. There were **96 open issues** on the review date; -these include requests and older reports, not 96 reproduced defects. The published -[v0.6.1 release](https://github.com/storytold/texturecraft/releases/tag/v0.6.1) already exists; -“first release v0.1.0” is no longer an upcoming milestone. - -Native/output contracts and the future MaterialCraft, ArtCraft UI and shared-library integrations -also remain unsettled. Passing a legacy reader or a standalone export check does not complete -those future workflows. +The live baseline verified mouse and keyboard painting in 3D and 2D, undo and redo, material +drag and drop, mask and generator edits, UV rectangle fill, baking, native saving and texture +export. Separate command checks covered high-to-low transfer, UDIM packing and scene/material +export. Since then, the mask and fill controls, generator coverage, Bake Mode and export workflows +have expanded. Beta readiness still depends on representative projects, hardware and performance +coverage, project recovery and destination-tool checks. The latest published stable release is +[v0.6.1](https://github.com/storytold/texturecraft/releases/tag/v0.6.1). A proposed beta gate is ~75% readiness plus repeatable artist tasks on representative assets: high/low baking and smart masks, precise 3D/2D painting, a multi-set UDIM project, save/reopen without lost work, and exports checked in destination tools. Startup failures and data-loss -blockers on the supported test matrix must be resolved. This audit does not establish that gate. +blockers on the supported test matrix must be resolved. The gate remains open. Beta scope must identify which reworks/integrations it requires and which remain later goals. Every adopted project/package version needs a compatibility policy and regression checks; MaterialCraft exchange must be validated against a named producer/consumer version pair before @@ -85,62 +69,70 @@ it is advertised as ready. ## By dimension -All percentages below are estimates. The weights sum to 100; their additive result is 59.1%, -rounded to ~60%. Hardware, performance and stability scores include confidence discounts for -incomplete validation; they are not measured success rates or speed comparisons. +With the same weights, readiness rises from 59.1% to 68.0%. The evidence supports larger gains in +implemented workflows and smaller gains in stability and performance. Hardware coverage and +localization keep their baseline scores pending direct validation. -| Dimension | % ready | Weight | Hours to full | Evidence / remaining work | -|---|---:|---:|---|---| -| Features (depth) | ~65% | 30 | TBD | Core editing tasks and high/low/UDIM outputs exercised; generators, properties and specialized workflows need depth. Mask anchors landed after this assessment; live UI validation remains | -| UI/UX fidelity | ~65% | 20 | TBD | Current editing/bake/export UI checked; [gaps](docs/ui-parity.md), ArtCraft UI adoption and revalidation after refactoring remain | -| File formats / interchange | ~60% | 10 | TBD | Current native save and basic exports exercised; possible `.tcraft`/output-package reworks, unfinished upstream `.mcmat`, `.spp` and consumer validation remain | -| Hardware (GPU, pen, displays) | ~50% | 8 | TBD | One Windows GPU exercised; pen tilt, pressure across platforms and display coverage remain incomplete | -| Localization | ~35% | 4 | TBD | Ten picker languages in source; optional shared catalogs/fonts and native-language review need current measurement | -| Performance | ~40% | 10 | TBD | Dirty-tile/budgeted architecture and benchmark code exist; no matched performance budgets or large-project results from this review | -| Stability | ~55% | 10 | TBD | Small save/reopen and undo/redo passed; recovery, large projects and long sessions need coverage, including after format/library migrations | -| Platforms | ~65% | 3 | TBD | Desktop/web build and packaging paths exist; this review ran Windows only | -| Automation / ecosystem | ~75% | 5 | TBD | 178 commands and CLI/control/MCP architecture; shared-library adoption, command/UI compatibility and the future MaterialCraft contract need integration checks | +| Dimension | Nov. 16 baseline | Nov. 25 estimate | Weight | Evidence and remaining work | +|---|---:|---:|---:|---| +| Features (depth) | ~65% | ~80% | 30 | Generators, mask actions, fill controls and bake workflows expanded. Specialized artist tasks and output fidelity still need repeatable checks | +| UI/UX fidelity | ~65% | ~75% | 20 | Layer targeting, the workspace, Bake Mode and export dialogs changed. Live task, layout, shortcut and accessibility checks remain | +| File formats / interchange | ~60% | ~70% | 10 | Shared import/export codecs, rebuilt UV persistence and linked `.mcmat` v3 have landed. Project/output contracts, `.spp` and destination-tool coverage remain open | +| Hardware (GPU, pen, displays) | ~50% | ~50% | 8 | One Windows GPU exercised; pen tilt, pressure across platforms and display coverage remain incomplete | +| Localization | ~35% | ~35% | 4 | Ten picker languages in source; optional shared catalogs/fonts and native-language review need current measurement | +| Performance | ~40% | ~45% | 10 | Main added dirty-region uploads, cheaper undo snapshots and faster glTF lookups. Establish response-time and memory budgets with representative large projects | +| Stability | ~55% | ~60% | 10 | The live baseline covered small save/reopen and undo/redo. Rebuilt UV layouts gained persistence checks. Recovery, large projects and long sessions remain open | +| Platforms | ~65% | ~70% | 3 | Desktop and web build paths exist. Nightly packaging and supervised signing workflows landed for Windows, Linux and macOS. Install, update and hardware checks remain | +| Automation / ecosystem | ~75% | ~80% | 5 | CLI, control and MCP share engine commands. Bake settings sync, UV import and generator controls have command paths. The MaterialCraft source-build round trip passed. Surface-specific integration and release-pair checks remain | ## Features -These are approximate depth/readiness estimates, not percentages of matching pixels or completed -menu entries. Feature rows overlap and are not an additional additive score. +These depth estimates overlap. The overall readiness estimate uses the weighted dimensions above. -| Area | % ready | Hours | What works / main gaps | -|---|---:|---|---| -| Projects and files | ~80% | TBD | Current `.tcraft` new/save/reopen passed with layers, effects and baked maps retained. Schema/container rework remains possible; versioning/migration policy and renewed persistence/recovery tests are needed if adopted. Large cases, Alembic HDF5 and animation remain open; PBR folder/ZIP/selected-file import landed after this assessment: `file.importPbrFolder` creates one fill layer from named maps, including packed ORM and OpenGL/DirectX normals, with a UI dialog and optional native library copy; it is not credited in this score | -| Texture sets and UDIM | ~80% | TBD | Two tiles exported at independent 128/256 px sizes with expected packed-channel values; 21 channel kinds in source. Many-set/many-tile production coverage remains untested | -| Layers, masks and effects | ~75% | TBD | UI fill/black-mask creation, generator editing/duplication and native persistence passed at the assessed revision. Mask-thumbnail context actions remain missing; effect renaming and mask-stack anchors landed afterward, with live UI validation still open | -| Painting and precise 2D work | ~70% | TBD | Mouse painting in both views, keyboard undo/redo, view shortcuts, brush gesture and UV-island rectangle fill passed. Nine tool kinds exist; brush feel, pressure/tilt, other tool task suites and complete trim sheets need validation | -| Generators and smart masks | ~45% | TBD | Seven generator kinds and 24 smart-mask presets; Position/global-balance editing worked in the UI. Shared adjustments, resolution and input slots exist; richer generators, micro-detail workflows and saving user smart masks remain incomplete | -| Materials and asset library | ~60% | TBD | 72 procedural materials and 21 smart materials; shelf search/drop worked. Legacy MaterialCraft paths exist, but the planned `.mcmat` contract is unfinished upstream. Library variety, previews and cross-app integration remain work | -| MaterialCraft `.mcmat` integration | Incomplete; upstream-dependent | TBD after contract | Current reader accepts legacy v1/v2. The proposed MaterialX-based v3 still needs upstream completion, shared-library support, TextureCraft mapping/UI and tests with real producer outputs; this is not a completed material exchange workflow | -| Baking | ~60% | TBD | All ten maps completed through the UI on CPU at 256 px and through commands on GPU at 128 px. Separate high/low normal/height transfer produced varying maps; cross-app pixel equivalence, larger assets and resolution-stable wear remain unproven | -| Viewport, shading and rendering | ~70% | TBD | PBR/IBL, extra shading lobes, 3D/2D views, displacement and CPU/GPU path-tracing paths. Matching material/display behavior, larger scenes and hardware ray tracing remain open | -| Color management | ~35% | TBD | Linear/sRGB handling, fixed export spaces and profile metadata; display model has Linear/ACES-filmic tone mapping. Configurable OCIO project/display workflows are absent | -| Texture and scene export | ~75% | TBD | Current PNG/UDIM/USD/GLB/MaterialX checks passed within scope. Output-package layout/content may be reworked; package contracts and consumers need separate validation. MaterialX export covers OpenPBR only (no standard_surface); complex materials and larger UDIM assets remain incomplete | -| Read-only `.spp` compatibility | 0% | TBD after feasibility study | Planned; no reader, version matrix or import-fidelity corpus. `.tcraft` remains the save format | -| Workspace, panels and preferences | ~65% | TBD | Current views/layouts checked; narrow labels truncate. Incoming ArtCraft UI refactoring/shared components can change these surfaces; task, shortcut, accessibility and layout/preferences persistence checks must be repeated | -| Automation | ~80% | TBD | Command inspection and scripted editing/export work; UI, CLI and MCP surfaces share engine commands. This review exercised the control channel and CLI, not every MCP/tool path | +| Area | Nov. 16 baseline | Nov. 25 estimate or status | Current evidence and remaining work | +|---|---:|---:|---| +| Projects and files | ~80% | ~85% | PBR folders, ZIPs and selected files import into one fill layer, with packed ORM and OpenGL/DirectX normal support. New Project can rebuild mesh UVs and persist the rebuilt layout. The shipped Material Ball project is available as a starting point. Large saves, recovery and Alembic HDF5/animation remain open | +| Texture sets and UDIM | ~80% | ~85% | Baseline command checks covered two tiles at different sizes and packed maps. Bake settings can sync across sets, export settings can vary by set and map, and hovering a set highlights it in the viewport. Validate many-set, many-tile projects at production sizes | +| Layers, masks and effects | ~75% | ~85% | Mask thumbnails have their own effect menu and a Shift-click toggle. Effect renaming, mask anchors and user smart-mask saving/application are implemented. Repeat the workflow in a live desktop session with undo and reopen | +| Painting and precise 2D work | ~70% | ~75% | The live baseline covered mouse painting, undo/redo and UV-island rectangle fill. Main added brush presets and fixes for steep-angle strokes and intermittent pen-pressure spikes. Brush feel, pressure and tilt across devices, and trim-sheet tasks still need live checks. [Presets #259](https://github.com/storytold/texturecraft/pull/259), [strokes #442](https://github.com/storytold/texturecraft/pull/442), [pressure #399](https://github.com/storytold/texturecraft/pull/399) | +| Generators and smart masks | ~45% | ~75% | 16 selectable generator kinds. Added 3D distance and gradient, UV border and diagnostic generators, grayscale conversion, rust runoff, per-kind controls, custom grunge, anchored micro-details and an enlarged preview. Validate control coverage, fidelity and performance on production assets | +| Materials and asset library | ~60% | ~70% | Procedural and smart materials, user smart masks, refreshed previews and resource import with usage assignment. Fill properties support independent U/V tiling, filtering, wrapping, physical-size controls, warp and per-UV-tile projection. Validate physical scale across meshes and fill persistence in artist tasks | +| MaterialCraft `.mcmat` integration | v3 pending | v3 round trip passed with source builds | Shared reader and the desktop MaterialCraft CLI bring in a published graph as a linked fill. Exposed controls and mesh-map inputs can drive re-cooks at the texture set resolution. v1/v2 imports require republishing. Saved baked maps can be used in the browser | +| Baking | ~60% | ~75% | Bake Mode adds texture-set synchronization, automatic fitted cages, background high-poly loading and a settings-driven selected-map preview. CPU/GPU map fidelity, high/low pairs on real assets and resolution-stable wear still need validation | +| Viewport, shading and rendering | ~70% | ~75% | PBR/IBL, displacement and CPU/GPU path tracing are available. Main improved camera controls and 2D navigation, including the UV tile grid, and highlights hovered texture sets. Matching material/display behavior, larger scenes and hardware ray tracing remain open | +| Color management | ~35% | ~35% | Linear/sRGB handling, fixed export spaces, profile metadata and Linear/ACES-filmic tone mapping are available. The project form displays disabled OpenColorIO settings. Configurable project and display transforms remain open | +| Texture and scene export | ~75% | ~85% | Desktop texture export can write companion OpenPBR MaterialX and a textured USD asset. Template editing, subfolder names, per-map overrides and URP/USD presets expanded. Standard Surface and browser companion outputs remain open. Validate complex materials, UDIM and destination tools | +| Read-only `.spp` compatibility | 0% | 0% | Planned; no reader, version matrix or import-fidelity corpus. `.tcraft` remains the save format | +| Workspace, panels and preferences | ~65% | ~75% | Menu and layout work, camera and 2D navigation updates, and full-name tooltips for truncated layer labels. Verify small windows, keyboard navigation, docking and restart persistence on the integrated desktop build | +| Automation | ~80% | ~85% | Commands cover UV import, bake sync, fill and generator controls and export. The November 16 review exercised control and CLI paths. Recheck UI reachability and direct/bridged MCP coverage on current main | -Source checks matter here: [generator kinds](crates/core/src/layer.rs) number seven even though -their shared controls have grown; [polygon fill](crates/engine/src/fill_mode.rs) already includes -triangle, polygon, UV-island and mesh modes. Current [MaterialCraft import](crates/formats/src/mcmat.rs) -accepts v2 and recognizes the newer source archive layout. That is legacy compatibility, not -completion of the next `.mcmat` integration. The [upstream v3 proposal](https://github.com/storytold/materialcraft/issues/190) -describes MaterialX plus resources in equivalent folder/ZIP deliveries and excludes native source. -Its proposed exposed controls differ from re-cooking an embedded authoring graph. The final -supported subset, version policy and authoring/re-cook workflow must be agreed and tested; -the legacy promise must not be carried forward automatically. +The [generator catalog](crates/core/src/layer.rs) defines 16 kinds, and +[polygon fill](crates/engine/src/fill_mode.rs) includes triangle, polygon, UV-island and mesh modes. +The [fill properties](crates/ui-egui/src/fill_panel.rs) and +[layer-panel tests](crates/ui-egui/tests/it/layers_panel.rs) supersede the November 16 missing-control +findings UI-01 and UI-03 through UI-06 in the [UI gap inventory](docs/ui-parity.md#missing-controls-and-workflows). +Use those findings' acceptance checks for a new live run. Color management (UI-11), generator +control and output validation (UI-12) and small-window work (UI-13) still need coverage. -The [UI gap inventory](docs/ui-parity.md#missing-controls-and-workflows) records reproduction -routes and acceptance checks: mask context/save/export actions; independent U/V tiling, -filtering/wrap, physical-size and warp/per-tile projections; -and configurable color-management settings. Generator depth and narrow-layout readability are -tracked as partial areas. Direct hardness/angle controls and polygon/UV rectangle fill already -exist; older reports must not turn them into fresh missing-feature claims. +### Evidence from the November 25 audit -### Evidence from this review +| Area | Evidence on main | +|---|---| +| Masks, fills and generators | Mask target menus and toggles, linked or independent tiling, filtering and wrap, physical-size controls, warp and per-tile projection, and 16 generator kinds with per-kind controls and previews. [Layer targeting #771](https://github.com/storytold/texturecraft/pull/771), [mask toggle #841](https://github.com/storytold/texturecraft/pull/841), [fill controls #762](https://github.com/storytold/texturecraft/pull/762), [generators #826](https://github.com/storytold/texturecraft/pull/826) | +| Bake and UV import | Per-group bake settings sync, fitted cages, background import of high-poly meshes and a settings-driven map preview. Rebuilt project UVs survive reopen. [Bake Mode #799](https://github.com/storytold/texturecraft/pull/799), [UV import #748](https://github.com/storytold/texturecraft/pull/748), [reopen regression](crates/engine/tests/it/rebuilt_uv_layout.rs) | +| Interchange and shared formats | Merged transitions to shared glTF/GLB, COLLADA, Alembic, USD and raster I/O, with project mapping in TextureCraft. Desktop texture-export dialogs gained MaterialX and USD options, and browser downloads use shared ZIP handling. [Migration tracker](https://github.com/storytold/craft-libs/issues/778), [MaterialX #784](https://github.com/storytold/texturecraft/pull/784), [USD asset #788](https://github.com/storytold/texturecraft/pull/788), [browser ZIP #792](https://github.com/storytold/texturecraft/pull/792) | +| Procedural material exchange | MaterialCraft publishes a ZIP containing a selected SBS graph, reachable dependencies and resources. TextureCraft inspects and cooks it through the CLI. MaterialX is an optional bake output. [Producer #270](https://github.com/storytold/materialcraft/pull/270), [consumer #644](https://github.com/storytold/texturecraft/pull/644), [commands](docs/control-protocol.md#materialcraft-materials) | +| MaterialCraft compatibility test | With MaterialCraft CLI 0.4.1 at `998d9d8f`, the Linux integration test published a selected graph, imported its v3 archive, supplied a mesh-map input and re-cooked at the target texture set size. CLI 0.4.1 at `f9174cb` failed earlier in the test when editable `.mcraft` import passed `--graph-path`. [Producer revision](https://github.com/storytold/materialcraft/commit/998d9d8f74454df047b6fb131f57b01d00a4983b), [integration test](crates/engine/tests/it/materialcraft_link.rs) | +| Desktop startup | Interactive launches without a project now open an empty workspace. Control launches can still request the sample. Measure startup on the supported GPU matrix. [Startup #634](https://github.com/storytold/texturecraft/pull/634), [native entry point](apps/texturecraft/src/main.rs) | +| Release automation | Isolated nightly launch profiles and a supervised Windows x86-64, Linux x86-64 and macOS arm64 workflow, with a separate signing ref. Scheduled publication remains disabled in this revision. Publication and installation still need end-to-end evidence. [Nightly preparation](docs/nightly-release-preparation.md), [producer](.github/workflows/nightly.yml) | +| Build checks | `cargo xtask layers` passed for all 15 workspace packages. `cargo xtask wasm` passed for ten library crates and the web app. | +| Linux regression suites | Locked release unit and integration tests for bake, compositing, formats, engine and headless UI reported 2,978 passing, zero failing and 101 ignored. The engine session suite included the hostile-input command sweep. The real MaterialCraft test was run separately with the CLI configured. | +| Packaging checks | The local nightly workflow and policy suite passed 28 tests. The Linux tarball launcher and Arch package handoff tests passed using a stub application. | + +Live desktop artist tasks, browser interaction, destination-tool fidelity, hardware coverage and +signed release installation remain outside the November 25 test evidence. + +### Evidence from the November 16 live review | Check | Result and limit | |---|---| @@ -161,11 +153,11 @@ exist; older reports must not turn them into fresh missing-feature claims. The [picker](crates/ui-egui/src/i18n.rs) contains ten languages. Shared catalogs are optional at build time; missing entries fall back to English, and builds without catalogs offer English only. The older [coverage table](docs/localization-parity.md) predates catalog migration, so its “100%” -rows are not a current measurement. This audit ran an English build without external catalogs. +rows are not a current measurement. The November 16 live audit ran an English build without external catalogs. | Language | Code | UI strings | Status | |---|---|---|---| -| English | `en` | Source language | Exercised in this audit | +| English | `en` | Source language | Exercised in the November 16 live audit | | Simplified Chinese | `zh-Hans` | Not remeasured | Catalog/font dependent; native review pending | | Spanish | `es` | Not remeasured | Catalog dependent; native review pending | | Hindi | `hi` | No picker entry | Not offered | @@ -188,16 +180,16 @@ here. Open pull requests are not credited until merged into the assessed main re | Rank | Milestone | Estimate | |---|---|---| -| 1 | Reliable startup and project safety across the supported GPU/platform matrix; reproduce startup/GPU reports and exercise recovery/large saves ([#541](https://github.com/storytold/texturecraft/issues/541), [#489](https://github.com/storytold/texturecraft/issues/489)) | TBD after reproduction | +| 1 | Verify empty-workspace startup, reproduce the DirectX startup report on affected hardware, and exercise large saves and recovery across supported platforms. [#489](https://github.com/storytold/texturecraft/issues/489), [#541](https://github.com/storytold/texturecraft/issues/541) | TBD after reproduction | | 2 | Define `.tcraft` and output-package direction, scope any reworks, and establish versioning, migration and producer/consumer acceptance cases | Unestimated; design scope open | -| 3 | Plan/adopt the incoming ArtCraft UI refactor and shared-library changes; preserve command reachability and repeat UI/persistence/platform checks after adoption | TBD after upstream contracts and consumer scope | -| 4 | Bring in the completed MaterialCraft `.mcmat` contract: agree the supported MaterialX/resources/controls subset, implement the consumer through shared APIs and validate folder/archive outputs from named versions | Upstream-dependent; format unfinished | -| 5 | Bake fidelity and dependable smart-material wear: matched assets/settings at multiple resolutions, all ten maps, high/low pairs and documented differences ([#536](https://github.com/storytold/texturecraft/issues/536), [#538](https://github.com/storytold/texturecraft/issues/538)) | TBD after map corpus | -| 6 | Generator, anchor and property depth; finish the artist-facing control inventory while preserving existing shared controls ([#374](https://github.com/storytold/texturecraft/issues/374), [#389](https://github.com/storytold/texturecraft/issues/389), [#433](https://github.com/storytold/texturecraft/issues/433)) | TBD after control audit | +| 3 | Scope ArtCraft UI adoption and remaining shared-library cutovers. Consolidate the current multiple craft-libs pins in a dedicated update, preserve command reachability and rerun acceptance checks | TBD after adoption scope | +| 4 | Set the supported MaterialCraft and TextureCraft release pair and verify its installed CLI. Extend the source-build check to bundled resources, presets, resolution changes, reopen, missing CLI behavior and v1/v2 republish guidance | TBD after producer/consumer matrix | +| 5 | Measure bake fidelity and wear across resolutions, high/low pairs, all ten maps and CPU/GPU paths. Include automatic cages, name matching, settings sync and final output versus live preview | TBD after map corpus | +| 6 | Exercise the expanded generator, anchor and property controls on production assets. Finish uncovered inputs and workflows after rechecking [#374](https://github.com/storytold/texturecraft/issues/374) and [#433](https://github.com/storytold/texturecraft/issues/433) against main | TBD after control audit | | 7 | Brush/pen precision, feedback and discoverability; complete 3D/2D/trim-sheet tasks and set responsiveness budgets ([#545](https://github.com/storytold/texturecraft/issues/545), [#485](https://github.com/storytold/texturecraft/issues/485), [#306](https://github.com/storytold/texturecraft/issues/306)) | TBD after task tests | | 8 | Color-managed pipeline and destination checks for USD, glTF/GLB, MaterialX and texture maps, including UDIM, complex materials and the adopted output packages | TBD after consumer matrix | | 9 | Read-only `.spp` discovery: clean-room feasibility, recoverable data and unsupported-content reporting; convert into the adopted native format without changing the source | Unestimated; feasibility unknown | -| 10 | Release/platform regression checks, web polish, current translation coverage and native review; expand the original asset library | TBD after validation | +| 10 | Verify supervised nightly signing, install, co-installation and update on the target platforms. Repeat web and localization checks and expand the original asset library | TBD after validation | ### Dependencies and possible rework @@ -207,26 +199,24 @@ TextureCraft adoption. | Track | Current state | Completion / revalidation gate | |---|---|---| -| Native `.tcraft` | Current save/load works in the audit; schema/container may change | Decide the native contract and compatibility policy. For any adopted rework, check existing projects and conversion explicitly: layers, masks, effects, resources, painted tiles, UDIM layouts and baked data; retain bounded reads, atomic saves and recovery behavior | -| Output packages | Current individual exports work within the recorded scope; future package format/content/layout is not settled | Define affected artifacts, manifests, naming, resource references and versioning. Test package relocation, folder/archive delivery where applicable, color/normal/displacement metadata and real consumers; repeat install/update checks if distribution artifacts change | -| MaterialCraft `.mcmat` | Legacy v1/v2 support exists; [v3](https://github.com/storytold/materialcraft/issues/190) is unfinished upstream | Agree the published contract and supported MaterialX subset, folder/ZIP equivalence, resources and exposed inputs. Adopt it through shared libraries and test actual MaterialCraft output in TextureCraft, including unsupported versions/features. Do not assume native-source recovery or the legacy re-cook behavior | +| Native `.tcraft` | The live baseline covered save/load. Main persists rebuilt mesh UV layouts. The future container/schema remains open | Decide the contract and compatibility policy. For any adopted migration, check layers, masks, effects, resources, painted tiles, UV layouts and baked data. Exercise bounded reads, atomic saves and recovery | +| Output packages | Export templates now support subfolders, and desktop USD/MaterialX companions reference exported textures | Define affected artifacts, manifests, naming and versioning. Check package relocation, applicable folder/archive delivery, color/normal/displacement metadata and destination tools | +| MaterialCraft `.mcmat` | The [v3 procedural ZIP contract](https://github.com/storytold/materialcraft/issues/190) and shared reader have landed. TextureCraft uses the desktop CLI for cooking and rejects v1/v2 with republish guidance | Validate supported producer and consumer versions with bundled assets, exposed controls and mesh-map inputs. Test archived sources after moving the authoring files, and saved baked maps in the browser | | ArtCraft UI refactor | Incoming suite/UI work; shared palette/theme proposals such as [craft-libs #102](https://github.com/storytold/craft-libs/pull/102) and [#397](https://github.com/storytold/craft-libs/pull/397) are examples, not the whole refactor or an adoption claim | Scope TextureCraft's adapters/components and design changes. Keep document behavior command-driven; repeat the [UI task audit](docs/ui-parity.md), input/accessibility checks, screenshots and layout/preferences persistence tests against the adopted design | -| Shared libraries | Several shared crates are already pinned in [Cargo.toml](Cargo.toml); [format migration work](https://github.com/storytold/craft-libs/issues/778) continues | Use reviewed public APIs and keep app-specific mapping/policy local. Each adoption needs consumer integration plus compatibility, security-limit, layering, wasm and regression checks; a library change alone does not complete the app's work | +| Shared libraries | Shared format adoption now includes glTF/GLB, COLLADA, Alembic, USD, runtime raster codecs and ZIP. [Cargo.toml](Cargo.toml) declares direct dependencies at six craft-libs revisions | Consolidate the pins under the repository's single-revision convention and rerun consumer compatibility, format limit, layering, wasm and regression checks. [Migration tracker](https://github.com/storytold/craft-libs/issues/778) | ### Current focus -Keep the current functional baseline while establishing project-safety and bake-fidelity checks. -Scope `.tcraft`/output-package changes and coordinate ArtCraft UI/shared-library adoption alongside -that work, so feature work budgets include possible migration and revalidation. Bring `.mcmat` -forward against the finished upstream contract rather than treating the legacy reader as completion. -Run `.spp` feasibility separately. Hardware ray tracing is a later enhancement; beta depends on -the scoped acceptance/integration gates above. [Release validation](docs/releasing.md) continues -for existing releases; there is no outstanding “first release” gate. +Establish project-recovery, startup and bake-fidelity checks on representative assets. Scope +`.tcraft` and output-package decisions and ArtCraft UI adoption alongside those checks. Repeat +the passing source-build `.mcmat` handoff with supported release builds. Read-only `.spp` remains a separate +feasibility track. Hardware ray tracing for Rendering mode remains a later enhancement. ## Progress log | Date | Entry | |---|---| +| 2026-11-25 | Audited main at `3c026860`. Recorded the expanded generator catalog, mask and fill controls, Bake Mode, UV rebuilds, export migrations, the v3 material handoff and supervised nightlies. Raised estimated breadth from ~80% to ~90% and weighted readiness from ~60% to ~68% | | 2026-11-16 | Added possible native/output-package reworks, unfinished MaterialCraft `.mcmat` integration and incoming ArtCraft UI/shared-library work as explicit roadmap tracks. Current audit scores stay tied to the tested revision; migration scope and effort remain unestimated | | 2026-11-16 | Deeper UI/functionality audit added in [docs/ui-parity.md](docs/ui-parity.md): twenty check groups, specific missing controls, reference editing/self-bake, UI export/save, analytic high/low transfer and UDIM packing. Overall percentages remain provisional estimates | | 2026-11-16 | Approximate live review against main `62b2b13` and reference 12.2.0. Basic edit/save/reopen, GPU bake and interchange smoke checks passed. Rebaselined reporting to ~80% breadth / ~60% readiness and recorded validation limits | @@ -238,6 +228,7 @@ for existing releases; there is no outstanding “first release” gate. | Date | Change | Summary | |---|---|---| +| 2026-11-25 | major | Updated implementation status and provisional readiness for current main. Retained the November 16 scores for comparison and kept the beta acceptance gates | | 2026-11-16 | major | Added dependency/rework scope and adoption gates; distinguished legacy `.mcmat` support from the unfinished MaterialX-based proposal; expanded upcoming work without crediting unlanded integrations | | 2026-11-16 | major | Expanded live UI tasks and output validation; added a separate UI gap inventory with acceptance checks; distinguished UI, mixed and command evidence and CPU/GPU bake paths | | 2026-11-16 | major | Adopted headline/audience/dimension/feature/language/upcoming tables; added main-revision evidence and uncertainty, read-only `.spp` scope, current release status and acceptance gates; removed the unsupported six-hour remainder | From d08c7b900cfaf7e1323d6f47acd15d799810fdce Mon Sep 17 00:00:00 2001 From: chasse20 Date: Wed, 25 Nov 2026 22:59:10 -0500 Subject: [PATCH 66/83] Docs: preserve the roadmap tracker schema --- ROADMAP.md | 133 +++++++++++++++++++++++++++-------------------------- 1 file changed, 67 insertions(+), 66 deletions(-) diff --git a/ROADMAP.md b/ROADMAP.md index 87024694..7dbebfbb 100644 --- a/ROADMAP.md +++ b/ROADMAP.md @@ -1,8 +1,10 @@ # TextureCraft roadmap -**Alpha**. The proposed beta gate is about 75% readiness plus scoped compatibility and integration checks. Remaining effort is unestimated. +Stage: alpha (readiness assessment) · next: beta, ~75% readiness plus scoped compatibility and integration gates; remaining effort unestimated -**Last updated and reviewed 2026-11-25.** The implementation audit covers main at +> Last reviewed: 2026-11-25 · Last updated: 2026-11-25 · Change: major (implementation audit and revised readiness estimates) · Target: reference app 12.2.0 + +The implementation audit covers main at [`3c026860`](https://github.com/storytold/texturecraft/commit/3c026860e36e5fbe2147c6c78ca0bbc617575887), with workspace version 0.6.1. Current estimates incorporate landed workflows, Linux regression tests and the MaterialCraft round trip. The November 16 live comparison with reference app 12.2.0 @@ -26,15 +28,17 @@ further shared-library adoption also require integration and regression checks. ## Headline numbers -| Measure | Nov. 16 baseline | Nov. 25 estimate | Basis | -|---|---:|---:|---| -| Feature breadth | ~80% | ~90% | Coverage across feature families, with gains in generators, fills, baking and interchange | -| Ready for real work | ~60% | ~68% | Weighted estimate from the dimensions below. The largest gains are in feature depth, UI and interchange | -| Remaining to beta | Unestimated | Unestimated | Requires acceptance tasks, performance budgets and a decision on required format, package and UI migrations | -| Remaining to full scoped parity | Unestimated | Unestimated | Includes possible `.tcraft` and output-package reworks, `.mcmat` release validation, ArtCraft UI and shared libraries, `.spp` feasibility, and workflow and fidelity checks | - -The November 16 live app showed 59 of 59 menu entries and 178 registered engine commands. -That review recorded [20 scoped check groups](docs/ui-parity.md#functional-task-audit). +| | Value | Kind | +|---|---|---| +| Feature breadth | ~90% | Estimated across feature families. The November 16 baseline was ~80% | +| Ready for real work | ~68% | Weighted estimate, up from ~60% on November 16. The largest gains are in feature depth, UI and interchange | +| Mainstream practitioner | ~70% | Estimated for regular asset texturing, baking, masking and pipeline delivery. The November 16 baseline was ~60% | +| Essentials user | ~85% | Estimated for a simple mesh, layered materials and paint, and texture export. The November 16 baseline was ~75% | +| Desktop menu catalog | 59/59 live | Observed on November 16 in TextureCraft's desktop catalog | +| Engine commands | 178 registered | Observed on November 16 through the running app | +| Functional review | 20 scoped check groups | November 16 UI, mixed-surface and command cases. [Functional task audit](docs/ui-parity.md#functional-task-audit) | +| Remaining to beta | Unestimated | Requires acceptance tasks, performance budgets and a decision on required format, package and UI migrations | +| Remaining to full scoped parity | Unestimated | Includes possible `.tcraft` and output-package reworks, `.mcmat` release validation, ArtCraft UI and shared libraries, `.spp` feasibility, and workflow and fidelity checks | Feature breadth estimates how much of the scoped feature set is present. Readiness also weighs control depth, output fidelity, responsiveness, project safety and delivery. The earlier ~94% @@ -44,11 +48,11 @@ earlier checks, and its scope and cost remain unestimated. ### Readiness by audience -| Audience | Nov. 16 baseline | Nov. 25 estimate | Work that dominates | -|---|---:|---:|---| -| Full scoped target | ~60% | ~68% | Workflow depth, format and package decisions, ArtCraft UI and shared libraries, bake and display fidelity, color management, read-only `.spp` and platform validation | -| Mainstream practitioner | ~60% | ~70% | Production-scale baking and masking, project and package compatibility, and destination-tool checks | -| Essentials user | ~75% | ~85% | Startup and GPU coverage, discoverable controls, and dependable save/reopen for simple mesh, paint, material and texture-export tasks | +| Audience | Ready % | Hours to ~95% | Work that dominates | +|---|---|---|---| +| Full scoped target | ~68% | Unestimated | Workflow depth, format and package decisions, ArtCraft UI and shared libraries, bake and display fidelity, color management, read-only `.spp` and platform validation | +| Mainstream practitioner | ~70% | Unestimated | Production-scale baking and masking, project and package compatibility, and destination-tool checks | +| Essentials user | ~85% | Unestimated | Startup and GPU coverage, discoverable controls, and dependable save/reopen for simple mesh, paint, material and texture-export tasks | The live baseline verified mouse and keyboard painting in 3D and 2D, undo and redo, material drag and drop, mask and generator edits, UV rectangle fill, baking, native saving and texture @@ -69,42 +73,41 @@ it is advertised as ready. ## By dimension -With the same weights, readiness rises from 59.1% to 68.0%. The evidence supports larger gains in -implemented workflows and smaller gains in stability and performance. Hardware coverage and -localization keep their baseline scores pending direct validation. +With the same weights, readiness rises from 59.1% to 68.0%. The table shows the November 25 scores. +The evidence column includes the November 16 scores for comparison. -| Dimension | Nov. 16 baseline | Nov. 25 estimate | Weight | Evidence and remaining work | -|---|---:|---:|---:|---| -| Features (depth) | ~65% | ~80% | 30 | Generators, mask actions, fill controls and bake workflows expanded. Specialized artist tasks and output fidelity still need repeatable checks | -| UI/UX fidelity | ~65% | ~75% | 20 | Layer targeting, the workspace, Bake Mode and export dialogs changed. Live task, layout, shortcut and accessibility checks remain | -| File formats / interchange | ~60% | ~70% | 10 | Shared import/export codecs, rebuilt UV persistence and linked `.mcmat` v3 have landed. Project/output contracts, `.spp` and destination-tool coverage remain open | -| Hardware (GPU, pen, displays) | ~50% | ~50% | 8 | One Windows GPU exercised; pen tilt, pressure across platforms and display coverage remain incomplete | -| Localization | ~35% | ~35% | 4 | Ten picker languages in source; optional shared catalogs/fonts and native-language review need current measurement | -| Performance | ~40% | ~45% | 10 | Main added dirty-region uploads, cheaper undo snapshots and faster glTF lookups. Establish response-time and memory budgets with representative large projects | -| Stability | ~55% | ~60% | 10 | The live baseline covered small save/reopen and undo/redo. Rebuilt UV layouts gained persistence checks. Recovery, large projects and long sessions remain open | -| Platforms | ~65% | ~70% | 3 | Desktop and web build paths exist. Nightly packaging and supervised signing workflows landed for Windows, Linux and macOS. Install, update and hardware checks remain | -| Automation / ecosystem | ~75% | ~80% | 5 | CLI, control and MCP share engine commands. Bake settings sync, UV import and generator controls have command paths. The MaterialCraft source-build round trip passed. Surface-specific integration and release-pair checks remain | +| Dimension | % ready | Weight | Hours to full | Evidence / remaining work | +|---|---:|---:|---|---| +| Features (depth) | ~80% | 30 | TBD | Generators, mask actions, fill controls and bake workflows expanded. Specialized artist tasks and output fidelity still need repeatable checks. November 16 estimate ~65% | +| UI/UX fidelity | ~75% | 20 | TBD | Layer targeting, the workspace, Bake Mode and export dialogs changed. Live task, layout, shortcut and accessibility checks remain. November 16 estimate ~65% | +| File formats / interchange | ~70% | 10 | TBD | Shared import/export codecs, rebuilt UV persistence and linked `.mcmat` v3 have landed. Project/output contracts, `.spp` and destination-tool coverage remain open. November 16 estimate ~60% | +| Hardware (GPU, pen, displays) | ~50% | 8 | TBD | One Windows GPU exercised; pen tilt, pressure across platforms and display coverage remain incomplete. November 16 estimate ~50% | +| Localization | ~35% | 4 | TBD | Ten picker languages in source; optional shared catalogs/fonts and native-language review need current measurement. November 16 estimate ~35% | +| Performance | ~45% | 10 | TBD | Main added dirty-region uploads, cheaper undo snapshots and faster glTF lookups. Establish response-time and memory budgets with representative large projects. November 16 estimate ~40% | +| Stability | ~60% | 10 | TBD | The live baseline covered small save/reopen and undo/redo. Rebuilt UV layouts gained persistence checks. Recovery, large projects and long sessions remain open. November 16 estimate ~55% | +| Platforms | ~70% | 3 | TBD | Desktop and web build paths exist. Nightly packaging and supervised signing workflows landed for Windows, Linux and macOS. Install, update and hardware checks remain. November 16 estimate ~65% | +| Automation / ecosystem | ~80% | 5 | TBD | CLI, control and MCP share engine commands. Bake settings sync, UV import and generator controls have command paths. The MaterialCraft source-build round trip passed. Surface-specific integration and release-pair checks remain. November 16 estimate ~75% | ## Features These depth estimates overlap. The overall readiness estimate uses the weighted dimensions above. -| Area | Nov. 16 baseline | Nov. 25 estimate or status | Current evidence and remaining work | -|---|---:|---:|---| -| Projects and files | ~80% | ~85% | PBR folders, ZIPs and selected files import into one fill layer, with packed ORM and OpenGL/DirectX normal support. New Project can rebuild mesh UVs and persist the rebuilt layout. The shipped Material Ball project is available as a starting point. Large saves, recovery and Alembic HDF5/animation remain open | -| Texture sets and UDIM | ~80% | ~85% | Baseline command checks covered two tiles at different sizes and packed maps. Bake settings can sync across sets, export settings can vary by set and map, and hovering a set highlights it in the viewport. Validate many-set, many-tile projects at production sizes | -| Layers, masks and effects | ~75% | ~85% | Mask thumbnails have their own effect menu and a Shift-click toggle. Effect renaming, mask anchors and user smart-mask saving/application are implemented. Repeat the workflow in a live desktop session with undo and reopen | -| Painting and precise 2D work | ~70% | ~75% | The live baseline covered mouse painting, undo/redo and UV-island rectangle fill. Main added brush presets and fixes for steep-angle strokes and intermittent pen-pressure spikes. Brush feel, pressure and tilt across devices, and trim-sheet tasks still need live checks. [Presets #259](https://github.com/storytold/texturecraft/pull/259), [strokes #442](https://github.com/storytold/texturecraft/pull/442), [pressure #399](https://github.com/storytold/texturecraft/pull/399) | -| Generators and smart masks | ~45% | ~75% | 16 selectable generator kinds. Added 3D distance and gradient, UV border and diagnostic generators, grayscale conversion, rust runoff, per-kind controls, custom grunge, anchored micro-details and an enlarged preview. Validate control coverage, fidelity and performance on production assets | -| Materials and asset library | ~60% | ~70% | Procedural and smart materials, user smart masks, refreshed previews and resource import with usage assignment. Fill properties support independent U/V tiling, filtering, wrapping, physical-size controls, warp and per-UV-tile projection. Validate physical scale across meshes and fill persistence in artist tasks | -| MaterialCraft `.mcmat` integration | v3 pending | v3 round trip passed with source builds | Shared reader and the desktop MaterialCraft CLI bring in a published graph as a linked fill. Exposed controls and mesh-map inputs can drive re-cooks at the texture set resolution. v1/v2 imports require republishing. Saved baked maps can be used in the browser | -| Baking | ~60% | ~75% | Bake Mode adds texture-set synchronization, automatic fitted cages, background high-poly loading and a settings-driven selected-map preview. CPU/GPU map fidelity, high/low pairs on real assets and resolution-stable wear still need validation | -| Viewport, shading and rendering | ~70% | ~75% | PBR/IBL, displacement and CPU/GPU path tracing are available. Main improved camera controls and 2D navigation, including the UV tile grid, and highlights hovered texture sets. Matching material/display behavior, larger scenes and hardware ray tracing remain open | -| Color management | ~35% | ~35% | Linear/sRGB handling, fixed export spaces, profile metadata and Linear/ACES-filmic tone mapping are available. The project form displays disabled OpenColorIO settings. Configurable project and display transforms remain open | -| Texture and scene export | ~75% | ~85% | Desktop texture export can write companion OpenPBR MaterialX and a textured USD asset. Template editing, subfolder names, per-map overrides and URP/USD presets expanded. Standard Surface and browser companion outputs remain open. Validate complex materials, UDIM and destination tools | -| Read-only `.spp` compatibility | 0% | 0% | Planned; no reader, version matrix or import-fidelity corpus. `.tcraft` remains the save format | -| Workspace, panels and preferences | ~65% | ~75% | Menu and layout work, camera and 2D navigation updates, and full-name tooltips for truncated layer labels. Verify small windows, keyboard navigation, docking and restart persistence on the integrated desktop build | -| Automation | ~80% | ~85% | Commands cover UV import, bake sync, fill and generator controls and export. The November 16 review exercised control and CLI paths. Recheck UI reachability and direct/bridged MCP coverage on current main | +| Area | % ready | Hours | What works / main gaps | +|---|---:|---|---| +| Projects and files | ~85% | TBD | November 16 estimate ~80%. PBR folders, ZIPs and selected files import into one fill layer, with packed ORM and OpenGL/DirectX normal support. New Project can rebuild mesh UVs and persist the rebuilt layout. The shipped Material Ball project is available as a starting point. Large saves, recovery and Alembic HDF5/animation remain open | +| Texture sets and UDIM | ~85% | TBD | November 16 estimate ~80%. Baseline command checks covered two tiles at different sizes and packed maps. Bake settings can sync across sets, export settings can vary by set and map, and hovering a set highlights it in the viewport. Validate many-set, many-tile projects at production sizes | +| Layers, masks and effects | ~85% | TBD | November 16 estimate ~75%. Mask thumbnails have their own effect menu and a Shift-click toggle. Effect renaming, mask anchors and user smart-mask saving/application are implemented. Repeat the workflow in a live desktop session with undo and reopen | +| Painting and precise 2D work | ~75% | TBD | November 16 estimate ~70%. The live baseline covered mouse painting, undo/redo and UV-island rectangle fill. Main added brush presets and fixes for steep-angle strokes and intermittent pen-pressure spikes. Brush feel, pressure and tilt across devices, and trim-sheet tasks still need live checks. [Presets #259](https://github.com/storytold/texturecraft/pull/259), [strokes #442](https://github.com/storytold/texturecraft/pull/442), [pressure #399](https://github.com/storytold/texturecraft/pull/399) | +| Generators and smart masks | ~75% | TBD | November 16 estimate ~45%. 16 selectable generator kinds. Added 3D distance and gradient, UV border and diagnostic generators, grayscale conversion, rust runoff, per-kind controls, custom grunge, anchored micro-details and an enlarged preview. Validate control coverage, fidelity and performance on production assets | +| Materials and asset library | ~70% | TBD | November 16 estimate ~60%. Procedural and smart materials, user smart masks, refreshed previews and resource import with usage assignment. Fill properties support independent U/V tiling, filtering, wrapping, physical-size controls, warp and per-UV-tile projection. Validate physical scale across meshes and fill persistence in artist tasks | +| MaterialCraft `.mcmat` integration | v3 round trip passed with source builds | TBD after release-pair validation | Shared reader and the desktop MaterialCraft CLI bring in a published graph as a linked fill. Exposed controls and mesh-map inputs can drive re-cooks at the texture set resolution. v1/v2 imports require republishing. Saved baked maps can be used in the browser | +| Baking | ~75% | TBD | November 16 estimate ~60%. Bake Mode adds texture-set synchronization, automatic fitted cages, background high-poly loading and a settings-driven selected-map preview. CPU/GPU map fidelity, high/low pairs on real assets and resolution-stable wear still need validation | +| Viewport, shading and rendering | ~75% | TBD | November 16 estimate ~70%. PBR/IBL, displacement and CPU/GPU path tracing are available. Main improved camera controls and 2D navigation, including the UV tile grid, and highlights hovered texture sets. Matching material/display behavior, larger scenes and hardware ray tracing remain open | +| Color management | ~35% | TBD | Linear/sRGB handling, fixed export spaces, profile metadata and Linear/ACES-filmic tone mapping are available. The project form displays disabled OpenColorIO settings. Configurable project and display transforms remain open | +| Texture and scene export | ~85% | TBD | November 16 estimate ~75%. Desktop texture export can write companion OpenPBR MaterialX and a textured USD asset. Template editing, subfolder names, per-map overrides and URP/USD presets expanded. Standard Surface and browser companion outputs remain open. Validate complex materials, UDIM and destination tools | +| Read-only `.spp` compatibility | 0% | TBD after feasibility study | Planned; no reader, version matrix or import-fidelity corpus. `.tcraft` remains the save format | +| Workspace, panels and preferences | ~75% | TBD | November 16 estimate ~65%. Menu and layout work, camera and 2D navigation updates, and full-name tooltips for truncated layer labels. Verify small windows, keyboard navigation, docking and restart persistence on the integrated desktop build | +| Automation | ~85% | TBD | November 16 estimate ~80%. Commands cover UV import, bake sync, fill and generator controls and export. The November 16 review exercised control and CLI paths. Recheck UI reachability and direct/bridged MCP coverage on current main | The [generator catalog](crates/core/src/layer.rs) defines 16 kinds, and [polygon fill](crates/engine/src/fill_mode.rs) includes triangle, polygon, UV-island and mesh modes. @@ -114,29 +117,11 @@ findings UI-01 and UI-03 through UI-06 in the [UI gap inventory](docs/ui-parity. Use those findings' acceptance checks for a new live run. Color management (UI-11), generator control and output validation (UI-12) and small-window work (UI-13) still need coverage. -### Evidence from the November 25 audit - -| Area | Evidence on main | -|---|---| -| Masks, fills and generators | Mask target menus and toggles, linked or independent tiling, filtering and wrap, physical-size controls, warp and per-tile projection, and 16 generator kinds with per-kind controls and previews. [Layer targeting #771](https://github.com/storytold/texturecraft/pull/771), [mask toggle #841](https://github.com/storytold/texturecraft/pull/841), [fill controls #762](https://github.com/storytold/texturecraft/pull/762), [generators #826](https://github.com/storytold/texturecraft/pull/826) | -| Bake and UV import | Per-group bake settings sync, fitted cages, background import of high-poly meshes and a settings-driven map preview. Rebuilt project UVs survive reopen. [Bake Mode #799](https://github.com/storytold/texturecraft/pull/799), [UV import #748](https://github.com/storytold/texturecraft/pull/748), [reopen regression](crates/engine/tests/it/rebuilt_uv_layout.rs) | -| Interchange and shared formats | Merged transitions to shared glTF/GLB, COLLADA, Alembic, USD and raster I/O, with project mapping in TextureCraft. Desktop texture-export dialogs gained MaterialX and USD options, and browser downloads use shared ZIP handling. [Migration tracker](https://github.com/storytold/craft-libs/issues/778), [MaterialX #784](https://github.com/storytold/texturecraft/pull/784), [USD asset #788](https://github.com/storytold/texturecraft/pull/788), [browser ZIP #792](https://github.com/storytold/texturecraft/pull/792) | -| Procedural material exchange | MaterialCraft publishes a ZIP containing a selected SBS graph, reachable dependencies and resources. TextureCraft inspects and cooks it through the CLI. MaterialX is an optional bake output. [Producer #270](https://github.com/storytold/materialcraft/pull/270), [consumer #644](https://github.com/storytold/texturecraft/pull/644), [commands](docs/control-protocol.md#materialcraft-materials) | -| MaterialCraft compatibility test | With MaterialCraft CLI 0.4.1 at `998d9d8f`, the Linux integration test published a selected graph, imported its v3 archive, supplied a mesh-map input and re-cooked at the target texture set size. CLI 0.4.1 at `f9174cb` failed earlier in the test when editable `.mcraft` import passed `--graph-path`. [Producer revision](https://github.com/storytold/materialcraft/commit/998d9d8f74454df047b6fb131f57b01d00a4983b), [integration test](crates/engine/tests/it/materialcraft_link.rs) | -| Desktop startup | Interactive launches without a project now open an empty workspace. Control launches can still request the sample. Measure startup on the supported GPU matrix. [Startup #634](https://github.com/storytold/texturecraft/pull/634), [native entry point](apps/texturecraft/src/main.rs) | -| Release automation | Isolated nightly launch profiles and a supervised Windows x86-64, Linux x86-64 and macOS arm64 workflow, with a separate signing ref. Scheduled publication remains disabled in this revision. Publication and installation still need end-to-end evidence. [Nightly preparation](docs/nightly-release-preparation.md), [producer](.github/workflows/nightly.yml) | -| Build checks | `cargo xtask layers` passed for all 15 workspace packages. `cargo xtask wasm` passed for ten library crates and the web app. | -| Linux regression suites | Locked release unit and integration tests for bake, compositing, formats, engine and headless UI reported 2,978 passing, zero failing and 101 ignored. The engine session suite included the hostile-input command sweep. The real MaterialCraft test was run separately with the CLI configured. | -| Packaging checks | The local nightly workflow and policy suite passed 28 tests. The Linux tarball launcher and Arch package handoff tests passed using a stub application. | - -Live desktop artist tasks, browser interaction, destination-tool fidelity, hardware coverage and -signed release installation remain outside the November 25 test evidence. - -### Evidence from the November 16 live review +### Evidence from this review | Check | Result and limit | |---|---| -| Baseline/build | Fetched `origin/main`; HEAD matched `62b2b13`. `cargo build -p texturecraft -p texturecraft-cli --profile verify` passed; binary reported 0.6.1 and that revision | +| Baseline/build | On November 16, fetched `origin/main`; HEAD matched `62b2b13`. `cargo build -p texturecraft -p texturecraft-cli --profile verify` passed; binary reported 0.6.1 and that revision | | Reference UI/functionality | On an original UV cube, pointer painting, paint/fill/black-mask creation and an empty generator slot worked; seven-map self-bake at 1024 px completed. Inspected fill/projection/scale menus, mask menu and export dialog. The “Read only” title did not prevent these edits; reference save/export and output equivalence remain unchecked | | TextureCraft UI tasks | Mouse/keyboard new project, 3D/2D strokes, Ctrl+Z/Y, F1/F2/F3, brush gesture, shelf search/drop, black mask, Position generator/global balance and effect duplication worked. UV rectangle fill wrote 88 tiles per channel and undo removed it | | Persistence | Native UI save of the deeper four-layer case followed by command reopen preserved layers, effects, 21 painted tiles per channel and ten baked maps. Earlier command save/reopen also passed. UI-only open-dialog completion was not established | @@ -148,6 +133,22 @@ signed release installation remain outside the November 25 test evidence. | Rework/upstream scope | Possible `.tcraft`/output-package reworks and incoming ArtCraft UI/shared-library work are planning inputs, not completed changes. The `.mcmat` v3 proposal and current legacy reader were reviewed; no future contract or current MaterialCraft producer/consumer pair was validated | | Not run | Full Rust tests, clippy, wasm, other operating systems, pen/display hardware matrix, large UDIM projects, long sessions, matched performance benchmarks and reference image-difference corpus | +The November 25 audit verified the following on main at `3c026860`. + +- **Masks, fills and generators.** Mask target menus and toggles, linked or independent tiling, filtering and wrap, physical-size controls, warp and per-tile projection, and 16 generator kinds with per-kind controls and previews. [Layer targeting #771](https://github.com/storytold/texturecraft/pull/771), [mask toggle #841](https://github.com/storytold/texturecraft/pull/841), [fill controls #762](https://github.com/storytold/texturecraft/pull/762), [generators #826](https://github.com/storytold/texturecraft/pull/826) +- **Bake and UV import.** Per-group bake settings sync, fitted cages, background import of high-poly meshes and a settings-driven map preview. Rebuilt project UVs survive reopen. [Bake Mode #799](https://github.com/storytold/texturecraft/pull/799), [UV import #748](https://github.com/storytold/texturecraft/pull/748), [reopen regression](crates/engine/tests/it/rebuilt_uv_layout.rs) +- **Interchange and shared formats.** Merged transitions to shared glTF/GLB, COLLADA, Alembic, USD and raster I/O, with project mapping in TextureCraft. Desktop texture-export dialogs gained MaterialX and USD options, and browser downloads use shared ZIP handling. [Migration tracker](https://github.com/storytold/craft-libs/issues/778), [MaterialX #784](https://github.com/storytold/texturecraft/pull/784), [USD asset #788](https://github.com/storytold/texturecraft/pull/788), [browser ZIP #792](https://github.com/storytold/texturecraft/pull/792) +- **Procedural material exchange.** MaterialCraft publishes a ZIP containing a selected SBS graph, reachable dependencies and resources. TextureCraft inspects and cooks it through the CLI. MaterialX is an optional bake output. [Producer #270](https://github.com/storytold/materialcraft/pull/270), [consumer #644](https://github.com/storytold/texturecraft/pull/644), [commands](docs/control-protocol.md#materialcraft-materials) +- **MaterialCraft compatibility test.** With MaterialCraft CLI 0.4.1 at `998d9d8f`, the Linux integration test published a selected graph, imported its v3 archive, supplied a mesh-map input and re-cooked at the target texture set size. CLI 0.4.1 at `f9174cb` failed earlier in the test when editable `.mcraft` import passed `--graph-path`. [Producer revision](https://github.com/storytold/materialcraft/commit/998d9d8f74454df047b6fb131f57b01d00a4983b), [integration test](crates/engine/tests/it/materialcraft_link.rs) +- **Desktop startup.** Interactive launches without a project now open an empty workspace. Control launches can still request the sample. Measure startup on the supported GPU matrix. [Startup #634](https://github.com/storytold/texturecraft/pull/634), [native entry point](apps/texturecraft/src/main.rs) +- **Release automation.** Isolated nightly launch profiles and a supervised Windows x86-64, Linux x86-64 and macOS arm64 workflow, with a separate signing ref. Scheduled publication remains disabled in this revision. Publication and installation still need end-to-end evidence. [Nightly preparation](docs/nightly-release-preparation.md), [producer](.github/workflows/nightly.yml) +- **Build checks.** `cargo xtask layers` passed for all 15 workspace packages. `cargo xtask wasm` passed for ten library crates and the web app. +- **Linux regression suites.** Locked release unit and integration tests for bake, compositing, formats, engine and headless UI reported 2,978 passing, zero failing and 101 ignored. The engine session suite included the hostile-input command sweep. The real MaterialCraft test was run separately with the CLI configured. +- **Packaging checks.** The local nightly workflow and policy suite passed 28 tests. The Linux tarball launcher and Arch package handoff tests passed using a stub application. + +Live desktop artist tasks, browser interaction, destination-tool fidelity, hardware coverage and +signed release installation remain outside the November 25 test evidence. + ## Languages The [picker](crates/ui-egui/src/i18n.rs) contains ten languages. Shared catalogs are optional at From 47356ee5b558da56c9532b9d2258fd3f96f471db Mon Sep 17 00:00:00 2001 From: aiongg Date: Thu, 26 Nov 2026 04:34:05 +0000 Subject: [PATCH 67/83] Sample project tests drive the app through the framework runtime --- crates/ui-egui/tests/it/sample_project.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/crates/ui-egui/tests/it/sample_project.rs b/crates/ui-egui/tests/it/sample_project.rs index 2d9bc426..1c806bb9 100644 --- a/crates/ui-egui/tests/it/sample_project.rs +++ b/crates/ui-egui/tests/it/sample_project.rs @@ -13,7 +13,10 @@ const SAMPLE_FILE_NAME: &str = "Material Ball.tcraft"; fn closed_app(samples_folder: &Path) -> Harness<'static, TextureCraftApp> { let session = Session::closed().unwrap(); - let mut harness = Harness::builder().with_size(egui::vec2(1600.0, 960.0)).build_eframe(|cc| TextureCraftApp::new(cc, session)); + let mut harness = Harness::builder() + .with_size(egui::vec2(1600.0, 960.0)) + .with_context_setup(texturecraft_ui_egui::framework::install_headless) + .build_eframe(|cc| TextureCraftApp::new(cc, session)); harness.state_mut().samples_folder = samples_folder.to_path_buf(); harness.run_steps(4); harness From 8700efc30c2d1e6b50b16d5e007ad55ba26b46b0 Mon Sep 17 00:00:00 2001 From: ATOM Date: Wed, 25 Nov 2026 22:45:46 -0600 Subject: [PATCH 68/83] feat(mesh): make normal recomputation a real export option --- crates/automation/src/headless.rs | 4 +- crates/automation/src/rpc.rs | 4 +- crates/automation/src/server.rs | 3 + crates/engine/src/file_cmds.rs | 87 ++++++++++++++++++++--- crates/ui-egui/src/mesh_export_options.rs | 19 +++-- crates/ui-egui/src/state.rs | 13 ++++ crates/ui-egui/src/web_files.rs | 6 +- crates/ui-egui/src/windows.rs | 3 +- crates/ui-egui/tests/it/side_panels.rs | 25 +++++++ docs/control-protocol.md | 4 +- 10 files changed, 144 insertions(+), 24 deletions(-) diff --git a/crates/automation/src/headless.rs b/crates/automation/src/headless.rs index 6f86119e..94e4924f 100644 --- a/crates/automation/src/headless.rs +++ b/crates/automation/src/headless.rs @@ -225,9 +225,9 @@ impl Headless { /// Export the working mesh to `path` (obj, glb, usda, usdc or usdz, from `format` or the /// extension); obj writes its .mtl and textures, usda and usdc their textures, next to it. - pub fn export_mesh(&mut self, path: &str, format: Option<&str>) -> Result { + pub fn export_mesh(&mut self, path: &str, format: Option<&str>, recompute_normals: bool) -> Result { self.require_project()?; - let out = self.session.mesh_export(path, format)?; + let out = self.session.mesh_export_with_normals(path, format, recompute_normals)?; let dir = Path::new(&out.path).parent().and_then(|d| d.to_str()).filter(|d| !d.is_empty()).unwrap_or("."); self.create_dir_all(dir)?; let mut textures = Vec::new(); diff --git a/crates/automation/src/rpc.rs b/crates/automation/src/rpc.rs index d159bc80..b0a21e77 100644 --- a/crates/automation/src/rpc.rs +++ b/crates/automation/src/rpc.rs @@ -5,7 +5,7 @@ //! Methods: the app's `ping`, `command.run {id, params?}`, `command.list {filter?}`, //! `session.inspect`, plus `command.batch {steps}`, `project.open {path}`, //! `project.save {path?}`, `mesh.import {path, resolution?, name?}`, `mesh.reimport {path?, -//! preserveStrokes?}`, `mesh.export {path, format?}`, `bake.mesh.add {path, cage?}`, +//! `preserveStrokes?}`, `mesh.export {path, format?, recomputeNormals?}`, `bake.mesh.add {path, cage?}`, //! `resource.import {path}`, `material.save {path, layer?, name?}`, `material.load {path}` //! (workspace-scoped versions of the engine commands), //! `textures.export {dir, …}`, `render {view?, width?, height?, yaw?, pitch?}` (PNG base64, the @@ -94,7 +94,7 @@ impl Headless { "project.save" => self.save(str_of(p, "path")), "mesh.import" => self.import_mesh(required(p, "path")?, u32_of(p, "resolution")?, str_of(p, "name")), "mesh.reimport" => self.reimport_mesh(str_of(p, "path"), bool_of(p, "preserveStrokes")?), - "mesh.export" => self.export_mesh(required(p, "path")?, str_of(p, "format")), + "mesh.export" => self.export_mesh(required(p, "path")?, str_of(p, "format"), bool_of(p, "recomputeNormals")?), "bake.mesh.add" => self.add_bake_mesh(required(p, "path")?, bool_of(p, "cage")?), "resource.import" => self.import_resource(required(p, "path")?), "material.save" => self.material_save(p), diff --git a/crates/automation/src/server.rs b/crates/automation/src/server.rs index 0ce54f55..f870ad9a 100644 --- a/crates/automation/src/server.rs +++ b/crates/automation/src/server.rs @@ -141,6 +141,9 @@ pub struct MeshExportParams { /// written next to it) or usdz (textures packaged); default: from the extension, else obj. #[serde(default, skip_serializing_if = "Option::is_none")] pub format: Option, + /// Replace stored normals with smooth area-weighted normals on the exported copy (default false). + #[serde(default, rename = "recomputeNormals", skip_serializing_if = "Option::is_none")] + pub recompute_normals: Option, } #[derive(Debug, Deserialize, Serialize, JsonSchema)] diff --git a/crates/engine/src/file_cmds.rs b/crates/engine/src/file_cmds.rs index 28595a1f..e827ef0e 100644 --- a/crates/engine/src/file_cmds.rs +++ b/crates/engine/src/file_cmds.rs @@ -69,7 +69,7 @@ pub fn specs() -> Vec { "Export Mesh...", ["File"], None, - "{path: .obj, .glb, .usda, .usdc or .usdz file, format?: obj|glb|usda|usdc|usdz (default: from the extension, else obj); obj writes its .mtl and textures, usda/usdc their textures, next to the file} → {path, textures?}", + "{path: .obj, .glb, .usda, .usdc or .usdz file, format?: obj|glb|usda|usdc|usdz (default: from the extension, else obj), recomputeNormals?: bool (default false: smooth area-weighted normals replace the stored normals on the exported copy only); obj writes its .mtl and textures, usda/usdc their textures, next to the file} → {path, textures?}", always, export_mesh ), @@ -115,15 +115,32 @@ fn read_stored_mesh(project: &Project, ext: &str, bytes: &[u8], saved_layout: Op impl Session { /// The working mesh as Wavefront OBJ (with its own UVs, UDIM tiles included). pub fn mesh_obj_bytes(&self) -> Result> { - texturecraft_formats::obj_bytes(&self.source_mesh(), &self.doc.project.name).map_err(fe) + self.mesh_obj_bytes_with_normals(false) + } + + /// [`Session::mesh_obj_bytes`], optionally replacing normals on the exported copy only. + pub fn mesh_obj_bytes_with_normals(&self, recompute_normals: bool) -> Result> { + let mut mesh = self.source_mesh(); + if recompute_normals { + mesh.compute_normals(); + } + texturecraft_formats::obj_bytes(&mesh, &self.doc.project.name).map_err(fe) } /// [`Session::mesh_obj_bytes`] with an MTL material library and each material's maps (like /// [`Session::mesh_usd`]'s), to write next to it, named after `stem` (the OBJ file's). pub fn mesh_obj_with_mtl(&mut self, stem: &str) -> Result<(Vec, texturecraft_formats::NamedFiles)> { + self.mesh_obj_with_mtl_and_normals(stem, false) + } + + /// [`Session::mesh_obj_with_mtl`], optionally replacing normals on the exported copy only. + pub fn mesh_obj_with_mtl_and_normals(&mut self, stem: &str, recompute_normals: bool) -> Result<(Vec, texturecraft_formats::NamedFiles)> { // shortcut: UV-tiled sets get no maps (the OBJ keeps the mesh's UDIM UVs and an MTL map is // one image); their tiles export through Export textures with `$udim` names. let mut mesh = self.source_mesh(); + if recompute_normals { + mesh.compute_normals(); + } // A mesh without materials has one implicit material (and texture set). if mesh.materials.is_empty() { mesh.materials.push("default".into()); @@ -136,16 +153,34 @@ impl Session { /// composite, through the texture export pipeline) embedded. glTF has no UV tiles: a /// UV-tiled set embeds its tile atlas, with the mesh's UVs in atlas space. pub fn mesh_glb_bytes(&mut self) -> Result> { + self.mesh_glb_bytes_with_normals(false) + } + + /// [`Session::mesh_glb_bytes`], optionally replacing normals on the exported copy only. + pub fn mesh_glb_bytes_with_normals(&mut self, recompute_normals: bool) -> Result> { let files = self.material_files(texturecraft_formats::glb_export_options(), true, self.mesh.materials.len())?; let textures: Vec<_> = files.into_iter().map(texturecraft_formats::GlbTextures::from_files).collect(); - texturecraft_formats::glb_bytes(&self.mesh, &self.doc.project.name, &textures).map_err(fe) + let mut mesh = self.mesh.as_ref().clone(); + if recompute_normals { + mesh.compute_normals(); + } + texturecraft_formats::glb_bytes(&mesh, &self.doc.project.name, &textures).map_err(fe) } /// The working mesh as USD with a UsdPreviewSurface per material (textures like /// [`Session::mesh_glb_bytes`]): usdz packages them, usda / usdc list them to write alongside. pub fn mesh_usd(&mut self, format: texturecraft_formats::UsdFormat) -> Result { + self.mesh_usd_with_normals(format, false) + } + + /// [`Session::mesh_usd`], optionally replacing normals on the exported copy only. + pub fn mesh_usd_with_normals(&mut self, format: texturecraft_formats::UsdFormat, recompute_normals: bool) -> Result { let files = self.material_files(texturecraft_formats::usd_export_options(), true, self.mesh.materials.len())?; - texturecraft_formats::usd_bytes(&self.mesh, &self.doc.project.name, &files, format).map_err(fe) + let mut mesh = self.mesh.as_ref().clone(); + if recompute_normals { + mesh.compute_normals(); + } + texturecraft_formats::usd_bytes(&mesh, &self.doc.project.name, &files, format).map_err(fe) } /// The texture sets of the first `materials` materials rendered with `opts` (as a tile atlas @@ -1159,7 +1194,7 @@ fn write_materialx( #[cfg(not(target_arch = "wasm32"))] fn export_mesh(s: &mut Session, p: &Value) -> Result { let path = native::path_param(p, "path", "file.exportMesh")?; - let out = s.mesh_export(path, strp(p, "format"))?; + let out = s.mesh_export_with_normals(path, strp(p, "format"), crate::commands::boolp(p, "recomputeNormals").unwrap_or(false))?; let dir = std::path::Path::new(&out.path).parent().unwrap_or(std::path::Path::new("")); let texture_paths: Vec = out.textures.iter().map(|(name, _)| dir.join(name)).collect(); let main_path = std::path::PathBuf::from(&out.path); @@ -1196,6 +1231,12 @@ impl Session { /// The working mesh as a file for `path`, in `format` (obj, glb, usda, usdc, usdz; default: /// from the extension, else OBJ). The extension is appended when it doesn't match. pub fn mesh_export(&mut self, path: &str, format: Option<&str>) -> Result { + self.mesh_export_with_normals(path, format, false) + } + + /// [`Session::mesh_export`], optionally computing smooth area-weighted normals on the + /// exported copy. The project's source and render meshes are never changed. + pub fn mesh_export_with_normals(&mut self, path: &str, format: Option<&str>, recompute_normals: bool) -> Result { let ext = match format { Some(f) if MESH_EXPORT_FORMATS.contains(&f) => f.to_string(), Some(other) => return Err(bad("file.exportMesh", format!("unknown mesh format `{other}` ({})", MESH_EXPORT_FORMATS.join(", ")))), @@ -1204,12 +1245,12 @@ impl Session { }; let path = if ext_of(path) == ext { path.to_string() } else { format!("{path}.{ext}") }; let (bytes, textures) = match (ext.as_str(), texturecraft_formats::UsdFormat::from_ext(&ext)) { - ("glb", _) => (self.mesh_glb_bytes()?, Vec::new()), + ("glb", _) => (self.mesh_glb_bytes_with_normals(recompute_normals)?, Vec::new()), (_, Some(format)) => { - let usd = self.mesh_usd(format)?; + let usd = self.mesh_usd_with_normals(format, recompute_normals)?; (usd.bytes, usd.textures) } - _ => self.mesh_obj_with_mtl(std::path::Path::new(&path).file_stem().and_then(|s| s.to_str()).unwrap_or("mesh"))?, + _ => self.mesh_obj_with_mtl_and_normals(std::path::Path::new(&path).file_stem().and_then(|s| s.to_str()).unwrap_or("mesh"), recompute_normals)?, }; Ok(MeshExport { path, bytes, textures }) } @@ -1402,6 +1443,36 @@ f 1/1 2/2 3/3 let _ = std::fs::remove_dir_all(&dir); } + #[test] + fn mesh_export_can_recompute_normals_without_changing_the_project() { + let mut s = Session::new_project("t", primitives::cube(1.0), "builtin:cube", None, 128).unwrap(); + std::sync::Arc::make_mut(&mut s.source).normals.fill(texturecraft_geom::glam::Vec3::Y); + std::sync::Arc::make_mut(&mut s.mesh).normals.fill(texturecraft_geom::glam::Vec3::Y); + let mut expected = s.source_mesh(); + expected.compute_normals(); + let dir = std::env::temp_dir().join(format!("tc_export_recompute_{}", std::process::id())); + let _ = std::fs::remove_dir_all(&dir); + std::fs::create_dir_all(&dir).unwrap(); + for (format, suffix) in [("obj", "obj"), ("glb", "glb"), ("usda", "usda")] { + let path = dir.join(format!("cube-{format}.{suffix}")); + let reply = crate::execute(&mut s, "file.exportMesh", &json!({"path": path, "recomputeNormals": true})).unwrap(); + let bytes = std::fs::read(reply["path"].as_str().unwrap()).unwrap(); + let back = texturecraft_formats::import_mesh_bytes(&format!("cube.{suffix}"), &bytes).unwrap().mesh; + assert_eq!(back.normals.len(), expected.normals.len(), "{format}: one normal per exported vertex"); + for (actual, wanted) in back.normals.iter().zip(&expected.normals) { + assert!((*actual - *wanted).length() < 1e-4, "{format}: stored normals were exported instead of recomputed ones"); + } + } + assert!(s.source.normals.iter().all(|n| *n == texturecraft_geom::glam::Vec3::Y), "the source project is unchanged"); + assert!(s.mesh.normals.iter().all(|n| *n == texturecraft_geom::glam::Vec3::Y), "the render project is unchanged"); + let stored_path = dir.join("stored.obj"); + let stored = crate::execute(&mut s, "file.exportMesh", &json!({"path": stored_path})).unwrap(); + let stored = std::fs::read(stored["path"].as_str().unwrap()).unwrap(); + let stored = texturecraft_formats::import_mesh_bytes("stored.obj", &stored).unwrap().mesh; + assert!(stored.normals.iter().all(|n| *n == texturecraft_geom::glam::Vec3::Y), "the default keeps stored normals for compatibility"); + let _ = std::fs::remove_dir_all(&dir); + } + #[test] fn rejected_glb_export_preserves_existing_files_and_publishes_nothing() { let mut s = Session::new_project("t", primitives::cube(1.0), "builtin:cube", None, 128).unwrap(); diff --git a/crates/ui-egui/src/mesh_export_options.rs b/crates/ui-egui/src/mesh_export_options.rs index 8458db61..822962b3 100644 --- a/crates/ui-egui/src/mesh_export_options.rs +++ b/crates/ui-egui/src/mesh_export_options.rs @@ -31,6 +31,7 @@ pub(crate) fn show(app: &mut TextureCraftApp, ctx: &egui::Context) { let mut open = true; let (mut export, mut cancel) = (false, false); + let mut triangulated = true; crate::windows::dialog(ctx, "mesh_export_options", tr("Mesh Export Options"), &mut open).show(ctx, |ui| { ui.set_width(DIALOG_WIDTH); @@ -38,7 +39,8 @@ pub(crate) fn show(app: &mut TextureCraftApp, ctx: &egui::Context) { ui.add(egui::RadioButton::new(true, tr("Without displacement/tessellation"))); option( ui, - true, + &mut triangulated, + false, tr("Apply triangulation"), &[ tr("Splits every face with more than three corners into triangles; triangles stay as they are."), @@ -49,11 +51,12 @@ pub(crate) fn show(app: &mut TextureCraftApp, ctx: &egui::Context) { unavailable::greyed(ui, |ui| ui.add(egui::RadioButton::new(false, tr("With displacement/tessellation")))); option( ui, + &mut app.ui.mesh_recompute_normals, true, tr("Recompute vertex normals"), &[ tr("Replaces the mesh's vertex normals with newly computed ones in the exported file."), - tr("TextureCraft cannot do this yet: it writes the vertex normals the mesh has in the project."), + tr("On: smooth area-weighted normals from the exported geometry. Off: the project's stored normals. The project itself is not changed."), ], ); ui.add_space(8.0); @@ -76,12 +79,16 @@ pub(crate) fn show(app: &mut TextureCraftApp, ctx: &egui::Context) { } } -/// A greyed option under a choice, ticked as the reference shows it, with an info icon at the -/// row's right end whose tooltip has the paragraphs `info` -fn option(ui: &mut Ui, checked: bool, label: &str, info: &[&str]) { +/// An option under a choice, greyed when `enabled` is false, with an info icon at the row's right +/// end whose tooltip has the paragraphs `info`. +fn option(ui: &mut Ui, checked: &mut bool, enabled: bool, label: &str, info: &[&str]) { ui.horizontal(|ui| { ui.add_space(OPTION_INDENT); - unavailable::checkbox(ui, checked, label); + if enabled { + ui.checkbox(checked, label); + } else { + unavailable::checkbox(ui, *checked, label); + } ui.with_layout(egui::Layout::right_to_left(egui::Align::Center), |ui| { let icon = ui.label(egui::RichText::new(egui_phosphor::regular::INFO).color(Tokens::get(ui.ctx()).text_dim)); icon.on_hover_ui(|ui| { diff --git a/crates/ui-egui/src/state.rs b/crates/ui-egui/src/state.rs index dd814ef7..fe313410 100644 --- a/crates/ui-egui/src/state.rs +++ b/crates/ui-egui/src/state.rs @@ -566,6 +566,9 @@ pub struct UiState { /// Window ▸ Hide UI (Tab): only the viewport. pub hide_ui: bool, pub windows: Windows, + /// Mesh Export Options: compute smooth normals on the exported copy, not the project. + #[serde(default = "default_true")] + pub mesh_recompute_normals: bool, pub uv_zoom: f32, pub uv_pan: [f32; 2], /// The 2D view's turn, counter-clockwise on screen in radians (Alt+left drag) @@ -770,6 +773,7 @@ impl Default for UiState { selected_baked_map: None, hide_ui: false, windows: Windows::default(), + mesh_recompute_normals: true, uv_zoom: 1.0, uv_pan: [0.0, 0.0], uv_rotation: 0.0, @@ -851,6 +855,15 @@ mod tests { assert_eq!(crate::start_ui(None, &mut session).prefs.language, crate::i18n::SYSTEM_LANGUAGE); } + #[test] + fn mesh_export_normal_choice_defaults_on_for_older_saved_states() { + assert!(UiState::default().mesh_recompute_normals); + let mut saved = serde_json::to_value(UiState::default()).unwrap(); + saved.as_object_mut().unwrap().remove("mesh_recompute_normals"); + let loaded: UiState = serde_json::from_value(saved).unwrap(); + assert!(loaded.mesh_recompute_normals, "older states keep the dialog's checked default"); + } + #[test] fn adopting_a_layout_keeps_recent_files_export_settings_and_shortcuts() { let mut ui = UiState { recent: vec!["a.tcraft".into()], ..UiState::default() }; diff --git a/crates/ui-egui/src/web_files.rs b/crates/ui-egui/src/web_files.rs index 5687f5db..89c86600 100644 --- a/crates/ui-egui/src/web_files.rs +++ b/crates/ui-egui/src/web_files.rs @@ -337,9 +337,9 @@ mod web { pub fn export_mesh(app: &mut TextureCraftApp, ext: &str) { let name = format!("{}.{ext}", sanitize_file_stem(&app.session.doc.project.name)); let bytes = match ext { - "glb" => app.session.mesh_glb_bytes(), - "usdz" => app.session.mesh_usd(texturecraft_engine::formats::UsdFormat::Usdz).map(|u| u.bytes), - _ => app.session.mesh_obj_bytes(), + "glb" => app.session.mesh_glb_bytes_with_normals(app.ui.mesh_recompute_normals), + "usdz" => app.session.mesh_usd_with_normals(texturecraft_engine::formats::UsdFormat::Usdz, app.ui.mesh_recompute_normals).map(|u| u.bytes), + _ => app.session.mesh_obj_bytes_with_normals(app.ui.mesh_recompute_normals), }; match bytes.map_err(|e| e.to_string()).and_then(|b| download(&name, &b)) { Ok(()) => app.toast(trf("Downloaded {name}", &[("name", &name)]), false), diff --git a/crates/ui-egui/src/windows.rs b/crates/ui-egui/src/windows.rs index a172926a..1ea09b80 100644 --- a/crates/ui-egui/src/windows.rs +++ b/crates/ui-egui/src/windows.rs @@ -609,7 +609,8 @@ pub fn file_action(app: &mut TextureCraftApp, _ctx: &egui::Context, id: &str) -> .file_name(name); app.ask_file(dialog, Bound::Project, |app, paths| { if let Some(path) = paths.first() - && let Some(result) = app.run("file.exportMesh", json!({"path": path.display().to_string()})) + && let Some(result) = + app.run("file.exportMesh", json!({"path": path.display().to_string(), "recomputeNormals": app.ui.mesh_recompute_normals})) { let saved_path = result["path"].as_str().unwrap_or_default(); app.toast(trf("Exported mesh to {path}", &[("path", &saved_path)]), false); diff --git a/crates/ui-egui/tests/it/side_panels.rs b/crates/ui-egui/tests/it/side_panels.rs index aab7c36d..f3a31394 100644 --- a/crates/ui-egui/tests/it/side_panels.rs +++ b/crates/ui-egui/tests/it/side_panels.rs @@ -174,6 +174,31 @@ fn export_mesh_asks_the_options_then_the_file() { let _ = std::fs::remove_dir_all(&dir); } +#[test] +fn recompute_normals_is_an_enabled_keyboard_operable_checkbox() { + let mut harness = app(); + let context = harness.ctx.clone(); + texturecraft_ui_egui::menus::invoke(harness.state_mut(), &context, "file.exportMesh"); + harness.run_steps(SETTLE_FRAMES); + let checkbox = harness.get_by_role_and_label(Role::CheckBox, "Recompute vertex normals"); + assert!(!checkbox.accesskit_node().is_disabled(), "the option is really available"); + assert!(is_on(&checkbox), "it starts checked, as the dialog always showed it"); + assert!(harness.state().ui.mesh_recompute_normals); + + checkbox.focus(); + harness.key_press(egui::Key::Space); + harness.run_steps(SETTLE_FRAMES); + assert!(!harness.state().ui.mesh_recompute_normals, "Space changes the setting used by export"); + let checkbox = harness.get_by_role_and_label(Role::CheckBox, "Recompute vertex normals"); + assert!(!is_on(&checkbox), "the accessibility tree reports the unchecked state"); + assert_eq!(checkbox.accesskit_node().label().as_deref(), Some("Recompute vertex normals")); + + checkbox.click(); + harness.run_steps(SETTLE_FRAMES); + assert!(harness.state().ui.mesh_recompute_normals, "a pointer click turns it back on"); + assert!(is_on(&harness.get_by_role_and_label(Role::CheckBox, "Recompute vertex normals"))); +} + /// Whether the Log lists `line` (the status bar under it repeats the last message) fn log_lists(harness: &Harness<'_, TextureCraftApp>, line: &str) -> bool { harness.query_all_by_label(line).any(|node| node.rect().bottom() < STATUS_BAR_TOP) diff --git a/docs/control-protocol.md b/docs/control-protocol.md index 71c95e6f..e3179022 100644 --- a/docs/control-protocol.md +++ b/docs/control-protocol.md @@ -382,7 +382,7 @@ With `rebuildUvs: true`, the project file saves the generated layout. Reopening | `project_save` | `{path?}` | `.tcraft` (appended if missing), relative to the write root | | `mesh_import` | `{path, resolution?}` | New project from .glb/.gltf/.fbx/.dae/.usd/.usda/.usdc/.usdz/.abc/.obj/.ply/.stl; a .gltf's buffers and images and a loose USD layer's textures are read from its folder | | `mesh_reimport` | `{path?, preserveStrokes?}` | Reimport the mesh from a file, or (no path) from the project's own copy; bridge mode supports only the latter | -| `mesh_export` | `{path, format?}` | The mesh as obj, glb, usda, usdc or usdz below the write root (obj: its .mtl and textures, usda / usdc: textures next to it) → `{path, textures?}` | +| `mesh_export` | `{path, format?, recomputeNormals?}` | The mesh as obj, glb, usda, usdc or usdz below the write root; `recomputeNormals: true` writes smooth area-weighted normals on the exported copy (default false) (obj: its .mtl and textures, usda / usdc: textures next to it) → `{path, textures?}` | | `bake_mesh_add` | `{path, cage?}` | Add a high-definition mesh for baking, or set the cage → `{name, meshes}` | | `resource_import` | `{path}` | Image resource (png, jpg, tga, tif, bmp, webp, exr, hdr) → its name, for `layer.add.image` / `tool.stencil`, or as a mesh map instead of baking it: `textureSet.meshMap.set {ts?, map, image}` (`textureSet.meshMap.clear {ts?, map}` empties the slot); call it once per baked map file (the desktop app's `textureSet.meshMap.import`, which takes host paths, is refused through `command_run`) | | `material_save` | `{path, layer?, name?}` | A layer or folder as a `.tcmat` smart material below the write root | @@ -457,7 +457,7 @@ File access follows `--read-root` / `--write-root` as for MCP. | `project.save` | `{path?}` | | `mesh.import` | `{path, resolution?, name?}` | | `mesh.reimport` | `{path?, preserveStrokes?}` | -| `mesh.export` | `{path, format?}` | +| `mesh.export` | `{path, format?, recomputeNormals?}` | | `bake.mesh.add` | `{path, cage?}` | | `resource.import` | `{path}` | | `material.save` | `{path, layer?, name?}` | From 23d3f9ae71380b60b33ee97e232c19646357472c Mon Sep 17 00:00:00 2001 From: Morion Date: Thu, 26 Nov 2026 00:27:10 -0500 Subject: [PATCH 69/83] Autosave: give each project its own copy The copy was named after the project, whose name comes from the mesh file, so projects made from one mesh overwrote each other's autosave. It is now `-.tcraft`: from the saved file and its path, or a suffix of its own while the project is unsaved. A project opened from its copy keeps writing to it. Fixes #851 --- crates/ui-egui/src/autosave_name.rs | 156 +++++++++++++++++++++++++ crates/ui-egui/src/lib.rs | 13 ++- crates/ui-egui/tests/autosave_files.rs | 65 +++++++++++ docs/features.md | 3 + 4 files changed, 232 insertions(+), 5 deletions(-) create mode 100644 crates/ui-egui/src/autosave_name.rs create mode 100644 crates/ui-egui/tests/autosave_files.rs diff --git a/crates/ui-egui/src/autosave_name.rs b/crates/ui-egui/src/autosave_name.rs new file mode 100644 index 00000000..477b17d8 --- /dev/null +++ b/crates/ui-egui/src/autosave_name.rs @@ -0,0 +1,156 @@ +//! Where a project's autosave copy goes. Each project has a file of its own, `-.tcraft`: a project's +//! name comes from its mesh file, so the name alone would let projects made from one mesh overwrite each other's copy + +use std::path::{Path, PathBuf}; + +use texturecraft_engine::core::PROJECT_EXT; +use texturecraft_engine::formats::export::sanitize_file_stem; + +use crate::TextureCraftApp; + +/// Hex digits of a copy's suffix +const SUFFIX_DIGITS: usize = 8; + +/// The longest stem kept, so the suffix and the temporary files of a save still fit a file name +const MAX_STEM_CHARS: usize = 180; + +impl TextureCraftApp { + /// The open project's autosave file in `folder`. A saved project's copy is named after its file and stays the + /// same across restarts; an unsaved project gets one that no other open project or running instance shares + pub(crate) fn autosave_path(&mut self, folder: &Path) -> PathBuf { + let Some(saved) = self.session.path.as_deref() else { + let project = self.session.project_id; + let suffix = match self.unsaved_autosave_suffix { + Some((owner, suffix)) if owner == project => suffix, + _ => { + let suffix = new_suffix(project); + self.unsaved_autosave_suffix = Some((project, suffix)); + suffix + } + }; + return folder.join(file_name(&self.session.doc.project.name, suffix)); + }; + + let saved = absolute(Path::new(saved)); + + // A project opened from its autosave copy keeps writing there, rather than chaining suffixes + if is_copy_in(&saved, &absolute(folder)) { + return saved; + } + + let stem = saved.file_stem().map_or_else(|| self.session.doc.project.name.clone(), |stem| stem.to_string_lossy().into_owned()); + folder.join(file_name(&stem, hash(saved.as_os_str().as_encoded_bytes()))) + } +} + +fn file_name(stem: &str, suffix: u32) -> String { + let stem: String = sanitize_file_stem(stem).chars().take(MAX_STEM_CHARS).collect(); + format!("{stem}-{suffix:0SUFFIX_DIGITS$x}.{PROJECT_EXT}") +} + +/// `path` made absolute, as given when that fails +fn absolute(path: &Path) -> PathBuf { + std::path::absolute(path).unwrap_or_else(|_| path.to_path_buf()) +} + +/// Whether `path` is an autosave copy of `folder`: a project file there whose name ends in a suffix +fn is_copy_in(path: &Path, folder: &Path) -> bool { + let suffix = path.file_stem().and_then(|stem| stem.to_str()).and_then(|stem| stem.rsplit_once('-')).map(|(_, suffix)| suffix); + path.parent() == Some(folder) + && path.extension().is_some_and(|extension| extension == PROJECT_EXT) + && suffix.is_some_and(|suffix| suffix.len() == SUFFIX_DIGITS && suffix.bytes().all(|digit| digit.is_ascii_hexdigit())) +} + +/// A suffix for the unsaved project `project`: from this process and the moment, so another instance or a later run +/// takes a different one +fn new_suffix(project: u64) -> u32 { + let now = chrono::Utc::now().timestamp_nanos_opt().unwrap_or_default(); + let mut seed = Vec::new(); + seed.extend_from_slice(&std::process::id().to_le_bytes()); + seed.extend_from_slice(&now.to_le_bytes()); + seed.extend_from_slice(&project.to_le_bytes()); + hash(&seed) +} + +/// 32-bit FNV-1a: the same bytes give the same suffix in every release, which the standard hasher does not promise +fn hash(bytes: &[u8]) -> u32 { + bytes.iter().fold(0x811c_9dc5, |hash, byte| (hash ^ u32::from(*byte)).wrapping_mul(0x0100_0193)) +} + +#[cfg(test)] +mod tests { + use texturecraft_engine::Session; + use texturecraft_engine::geom::primitives; + + use super::*; + + fn project(name: &str) -> Session { + Session::new_project(name, primitives::cube(1.0), "builtin:cube", None, 128).unwrap() + } + + fn app(session: Session) -> TextureCraftApp { + TextureCraftApp::new(&eframe::CreationContext::_new_kittest(egui::Context::default()), session) + } + + fn name_of(path: &Path) -> &str { + path.file_name().and_then(|name| name.to_str()).unwrap() + } + + #[test] + fn unsaved_projects_with_one_name_get_different_copies_that_stay_put() { + let folder = Path::new("autosave"); + let mut first = app(project("hero")); + let mut second = app(project("hero")); + + let (one, other) = (first.autosave_path(folder), second.autosave_path(folder)); + + assert_ne!(one, other, "another instance never writes the same file"); + assert!(name_of(&one).starts_with("hero-") && name_of(&one).ends_with(".tcraft"), "{one:?}"); + assert_eq!(one.parent(), Some(folder)); + assert_eq!(first.autosave_path(folder), one, "the next autosave replaces this project's copy"); + + first.session.switch_to(project("hero")); + assert_ne!(first.autosave_path(folder), one, "a new project of the same name starts its own copy"); + } + + #[test] + fn a_saved_project_names_its_copy_after_its_file_and_keeps_it_across_restarts() { + let folder = Path::new("autosave"); + let copy_of = |saved: &str| { + let mut app = app(project("hero")); + app.session.path = Some(saved.to_string()); + app.autosave_path(folder) + }; + + let first = copy_of("work/Hero_v1.tcraft"); + let second = copy_of("work/Hero_v2.tcraft"); + let same_name_elsewhere = copy_of("backup/Hero_v1.tcraft"); + + assert!(name_of(&first).starts_with("Hero_v1-"), "{first:?}"); + assert_ne!(first, second); + assert_ne!(first, same_name_elsewhere, "files of one name in two folders keep two copies"); + assert_eq!(copy_of("work/Hero_v1.tcraft"), first, "a later run finds the same copy"); + } + + #[test] + fn a_project_opened_from_its_copy_keeps_writing_to_it() { + let folder = std::env::temp_dir().join("tc-autosave"); + let mut app = app(project("hero")); + let copy = app.autosave_path(&folder); + + app.session.path = Some(copy.display().to_string()); + assert_eq!(app.autosave_path(&folder), copy); + + // A file there that is not a copy is the user's own: autosave leaves it alone + let own = folder.join("hero.tcraft"); + app.session.path = Some(own.display().to_string()); + assert_ne!(app.autosave_path(&folder), own); + } + + #[test] + fn suffixes_have_a_fixed_width_and_long_names_are_cut() { + assert_eq!(file_name("hero", 0x2a), "hero-0000002a.tcraft"); + assert_eq!(hash(b"hero"), hash(b"hero")); + assert!(file_name(&"a".repeat(500), 1).len() < 200); + } +} diff --git a/crates/ui-egui/src/lib.rs b/crates/ui-egui/src/lib.rs index ed85f4fc..15b2e84c 100644 --- a/crates/ui-egui/src/lib.rs +++ b/crates/ui-egui/src/lib.rs @@ -10,6 +10,8 @@ mod anchor_properties; mod angle_dial; mod ask; +#[cfg(not(target_arch = "wasm32"))] +mod autosave_name; mod bake_job; pub mod bake_mode; mod bake_preset; @@ -344,6 +346,9 @@ pub struct TextureCraftApp { /// When the next autosave is due (seconds of app time; desktop only). #[cfg_attr(target_arch = "wasm32", allow(dead_code))] next_autosave: f64, + /// The unsaved project (its id) and the suffix of its autosave copy. + #[cfg(not(target_arch = "wasm32"))] + unsaved_autosave_suffix: Option<(u64, u32)>, /// The brightness and accent the style was last built for. styled: Option<(theme::Brightness, theme::Accent)>, /// Whether the window had focus last frame. @@ -475,6 +480,8 @@ impl TextureCraftApp { title_bar: titlebar::TitleBar::default(), last_time: 0.0, next_autosave, + #[cfg(not(target_arch = "wasm32"))] + unsaved_autosave_suffix: None, styled: None, focused: true, #[cfg(not(target_arch = "wasm32"))] @@ -1034,11 +1041,7 @@ impl TextureCraftApp { self.next_autosave = now + period; let dir = user_dir("autosave"); - let path = dir.join(format!( - "{}.{}", - texturecraft_engine::formats::export::sanitize_file_stem(&self.session.doc.project.name), - texturecraft_engine::core::PROJECT_EXT - )); + let path = self.autosave_path(&dir); let snapshot = self.session.project_snapshot(); let spawned = std::thread::Builder::new().name("texturecraft-autosave".into()).spawn(move || { let result = diff --git a/crates/ui-egui/tests/autosave_files.rs b/crates/ui-egui/tests/autosave_files.rs new file mode 100644 index 00000000..01211191 --- /dev/null +++ b/crates/ui-egui/tests/autosave_files.rs @@ -0,0 +1,65 @@ +//! The desktop autosave writes each project's copy to a file of its own. This is a test binary of its own because it +//! points the process's data folder at a temporary one + +#![cfg(not(target_arch = "wasm32"))] + +use std::path::{Path, PathBuf}; +use std::time::{Duration, Instant}; + +use egui_kittest::Harness; +use serde_json::json; +use texturecraft_engine::geom::primitives; +use texturecraft_engine::{Session, execute}; +use texturecraft_ui_egui::TextureCraftApp; + +/// App time each frame advances by, so a few frames pass any autosave interval +const FRAME_SECONDS: f32 = 600.0; + +/// How long the worker thread gets to write a copy +const WRITE_TIMEOUT: Duration = Duration::from_secs(60); + +/// A project named as one made from `hero.fbx` would be, with `layers` paint layers added since it was saved +fn unsaved_hero(layers: usize) -> Session { + let mut session = Session::new_project("hero", primitives::cube(1.0), "builtin:cube", None, 128).unwrap(); + for _ in 0..layers { + execute(&mut session, "layer.add.paint", &json!({})).unwrap(); + } + session +} + +fn copies(folder: &Path) -> Vec { + let files = std::fs::read_dir(folder).map(|entries| entries.flatten().map(|entry| entry.path()).collect::>()).unwrap_or_default(); + files.into_iter().filter(|path| path.extension().is_some_and(|extension| extension == "tcraft")).collect() +} + +/// Runs an app on `session` until the autosave folder holds `count` copies +fn autosave(session: Session, folder: &Path, count: usize) -> Harness<'static, TextureCraftApp> { + let mut harness = Harness::builder().with_step_dt(FRAME_SECONDS).build_eframe(|cc| TextureCraftApp::new(cc, session)); + let started = Instant::now(); + while copies(folder).len() < count { + harness.step(); + assert!(started.elapsed() < WRITE_TIMEOUT, "autosave wrote {:?}", copies(folder)); + std::thread::sleep(Duration::from_millis(20)); + } + harness +} + +#[test] +fn two_projects_of_one_name_keep_two_autosave_copies() { + let data = std::env::temp_dir().join(format!("tc-autosave-files-{}", std::process::id())); + let _ = std::fs::remove_dir_all(&data); + texturecraft_ui_egui::set_data_root(data.clone()); + let folder = data.join("autosave"); + + let first = autosave(unsaved_hero(1), &folder, 1); + let second = autosave(unsaved_hero(2), &folder, 2); + drop((first, second)); + + // Each copy opens as the project that wrote it + let mut layers: Vec = + copies(&folder).iter().map(|path| texturecraft_engine::file_cmds::open_path(path.to_str().unwrap()).unwrap().doc.project.layers.len()).collect(); + layers.sort_unstable(); + assert_eq!(layers[1], layers[0] + 1, "{layers:?}"); + + std::fs::remove_dir_all(&data).unwrap(); +} diff --git a/docs/features.md b/docs/features.md index 520ff678..38ff4a65 100644 --- a/docs/features.md +++ b/docs/features.md @@ -278,6 +278,9 @@ Everything TextureCraft does today, by area. What's still missing is in [`ROADMA New project, Open, Recent projects, Open sample project); File › Close returns to that state. - A **data folder** of your choice for autosaves, smart materials, presets, templates and UI layouts, on any drive (Settings › General › Folders; `Documents/TextureCraft` by default). +- **Autosave**: each project keeps its own copy in the data folder's `autosave`, named + `-.tcraft` after its saved file (or, until it is saved, the project), so projects made from + one mesh never overwrite each other's copy. - A **Settings window** (Edit › Settings) with General, Shortcuts and Libraries pages; changes apply on OK and Cancel drops them. General holds the language (or the system's), the 3D view's rotation, zoom and wheel speeds with inverse directions, GPU or CPU bake rays, resource limits From 14deaa61de145f560de5a36642b9e13676ed5f5b Mon Sep 17 00:00:00 2001 From: ATOM Date: Wed, 25 Nov 2026 23:34:31 -0600 Subject: [PATCH 70/83] fix(ui): preserve normal export choice across layouts --- crates/ui-egui/src/state.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/crates/ui-egui/src/state.rs b/crates/ui-egui/src/state.rs index fe313410..24c5f7a4 100644 --- a/crates/ui-egui/src/state.rs +++ b/crates/ui-egui/src/state.rs @@ -735,6 +735,7 @@ impl UiState { } self.export = keep.export; + self.mesh_recompute_normals = keep.mesh_recompute_normals; self.recent = keep.recent; self.last_template = keep.last_template; self.prefs = keep.prefs; @@ -869,7 +870,9 @@ mod tests { let mut ui = UiState { recent: vec!["a.tcraft".into()], ..UiState::default() }; ui.export.preset = "Mine".into(); ui.keymap.insert("file.save".into(), "F5".into()); + ui.mesh_recompute_normals = false; let mut layout = UiState::default(); + assert!(layout.mesh_recompute_normals); layout.dock.close(crate::docking::Panel::Assets); ui.adopt_layout(layout); @@ -878,6 +881,7 @@ mod tests { assert_eq!(ui.recent, vec!["a.tcraft".to_string()]); assert_eq!(ui.export.preset, "Mine"); assert_eq!(ui.keymap.get("file.save").map(String::as_str), Some("F5")); + assert!(!ui.mesh_recompute_normals, "a layout does not change the user's export setting"); } #[test] From 356f01b2f0593729297fb733fdf0777f955ca124 Mon Sep 17 00:00:00 2001 From: skylar taylor-barrick Date: Thu, 26 Nov 2026 00:47:29 -0600 Subject: [PATCH 71/83] Nightly: stop blocking a refused launch on macOS (#853) Nightly launch fix under Skylar's Exec 454: the Launcher's trailing `--` no longer reaches the file list where that applied, and a refused launch no longer blocks on macOS (the reason goes to stderr and the app exits 2). --- apps/texturecraft/src/main.rs | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/apps/texturecraft/src/main.rs b/apps/texturecraft/src/main.rs index 664b791a..4d48c210 100644 --- a/apps/texturecraft/src/main.rs +++ b/apps/texturecraft/src/main.rs @@ -259,13 +259,22 @@ fn initialize_nightly_process_identity() -> Result<(), process_identity::Identit process_identity::initialize(build_flavor::COMPILED == build_flavor::BuildFlavor::NightlyV1, os_window::id_for(LaunchIdentity::NightlyV1)) } -/// A refused Nightly start explains itself in a dialog where there is a desktop to show one. +/// Whether a refusal may also open a native message box. Standard error always carries the reason; +/// this only adds a box where one renders without the app's event loop. Never on macOS: rfd's alert +/// there needs the AppKit run loop this start has not reached, so a refused nightly launch hung in +/// an invisible modal instead of exiting (GridCraft Mac smoke, 2026-11-26). +fn refusal_dialog(flavor: build_flavor::BuildFlavor, desktop_session: bool, macos: bool) -> bool { + build_flavor::needs_native_error(flavor, desktop_session) && !macos +} + +/// A refused Nightly start explains itself in a dialog where the desktop shows one without the +/// app's run loop (Windows, X11/Wayland); macOS gets the standard-error line only. fn report_launch_profile_error(error: &str) { eprintln!("texturecraft: {error}"); let desktop_session = cfg!(windows) || cfg!(target_os = "macos") || (cfg!(target_os = "linux") && ["DISPLAY", "WAYLAND_DISPLAY"].into_iter().any(|key| std::env::var_os(key).is_some_and(|v| !v.is_empty()))); - if build_flavor::needs_native_error(build_flavor::COMPILED, desktop_session) { + if refusal_dialog(build_flavor::COMPILED, desktop_session, cfg!(target_os = "macos")) { if let Err(error) = initialize_nightly_process_identity() { eprintln!("texturecraft: {error}"); return; @@ -667,3 +676,17 @@ mod tests { assert!(seen.is_some_and(|seen| seen.distance(pad + DRAG_STEP) <= PUT_BACK_REACH), "the app reads the whole move: {seen:?}"); } } + +#[cfg(test)] +mod refusal_dialog_tests { + use super::refusal_dialog; + use crate::build_flavor::BuildFlavor; + + #[test] + fn a_refusal_never_blocks_on_a_modal_before_the_event_loop_on_macos() { + assert!(refusal_dialog(BuildFlavor::NightlyV1, true, false), "a desktop refusal still shows the box where one renders"); + assert!(!refusal_dialog(BuildFlavor::NightlyV1, true, true), "macOS has no run loop yet: the modal would hang"); + assert!(!refusal_dialog(BuildFlavor::NightlyV1, false, false), "a headless session has no box"); + assert!(!refusal_dialog(BuildFlavor::Stable, true, false), "only a nightly refusal explains itself in a box"); + } +} From eda265b470f27a59c3058ea455b01186f271be84 Mon Sep 17 00:00:00 2001 From: "autocraft-bot[bot]" <354215646+autocraft-bot[bot]@users.noreply.github.com> Date: Thu, 26 Nov 2026 07:21:04 +0000 Subject: [PATCH 72/83] Apply requested fixes - crates/ui-egui/src/autosave_name.rs - docs/features.md --- crates/ui-egui/src/autosave_name.rs | 20 ++++++++++++++------ docs/features.md | 2 +- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/crates/ui-egui/src/autosave_name.rs b/crates/ui-egui/src/autosave_name.rs index 477b17d8..04df5543 100644 --- a/crates/ui-egui/src/autosave_name.rs +++ b/crates/ui-egui/src/autosave_name.rs @@ -1,4 +1,4 @@ -//! Where a project's autosave copy goes. Each project has a file of its own, `-.tcraft`: a project's +//! Where a project's autosave copy goes. Each project has a file of its own, `-copy-.tcraft`: a project's //! name comes from its mesh file, so the name alone would let projects made from one mesh overwrite each other's copy use std::path::{Path, PathBuf}; @@ -11,6 +11,9 @@ use crate::TextureCraftApp; /// Hex digits of a copy's suffix const SUFFIX_DIGITS: usize = 8; +/// Between a copy's stem and its suffix, so a user's own file named like `report-20240115` is not taken for a copy +const COPY_MARK: &str = "-copy-"; + /// The longest stem kept, so the suffix and the temporary files of a save still fit a file name const MAX_STEM_CHARS: usize = 180; @@ -45,7 +48,7 @@ impl TextureCraftApp { fn file_name(stem: &str, suffix: u32) -> String { let stem: String = sanitize_file_stem(stem).chars().take(MAX_STEM_CHARS).collect(); - format!("{stem}-{suffix:0SUFFIX_DIGITS$x}.{PROJECT_EXT}") + format!("{stem}{COPY_MARK}{suffix:0SUFFIX_DIGITS$x}.{PROJECT_EXT}") } /// `path` made absolute, as given when that fails @@ -53,9 +56,9 @@ fn absolute(path: &Path) -> PathBuf { std::path::absolute(path).unwrap_or_else(|_| path.to_path_buf()) } -/// Whether `path` is an autosave copy of `folder`: a project file there whose name ends in a suffix +/// Whether `path` is an autosave copy of `folder`: a project file there whose name ends in the copy mark and a suffix fn is_copy_in(path: &Path, folder: &Path) -> bool { - let suffix = path.file_stem().and_then(|stem| stem.to_str()).and_then(|stem| stem.rsplit_once('-')).map(|(_, suffix)| suffix); + let suffix = path.file_stem().and_then(|stem| stem.to_str()).and_then(|stem| stem.rsplit_once(COPY_MARK)).map(|(_, suffix)| suffix); path.parent() == Some(folder) && path.extension().is_some_and(|extension| extension == PROJECT_EXT) && suffix.is_some_and(|suffix| suffix.len() == SUFFIX_DIGITS && suffix.bytes().all(|digit| digit.is_ascii_hexdigit())) @@ -145,12 +148,17 @@ mod tests { let own = folder.join("hero.tcraft"); app.session.path = Some(own.display().to_string()); assert_ne!(app.autosave_path(&folder), own); + + let dated = folder.join("hero-20240115.tcraft"); + app.session.path = Some(dated.display().to_string()); + assert_ne!(app.autosave_path(&folder), dated); } #[test] fn suffixes_have_a_fixed_width_and_long_names_are_cut() { - assert_eq!(file_name("hero", 0x2a), "hero-0000002a.tcraft"); - assert_eq!(hash(b"hero"), hash(b"hero")); + let narrow = file_name("hero", 1); + let wide = file_name("hero", u32::MAX); + assert_eq!(narrow.len(), wide.len(), "every suffix has the same width"); assert!(file_name(&"a".repeat(500), 1).len() < 200); } } diff --git a/docs/features.md b/docs/features.md index 38ff4a65..8ddd6133 100644 --- a/docs/features.md +++ b/docs/features.md @@ -279,7 +279,7 @@ Everything TextureCraft does today, by area. What's still missing is in [`ROADMA - A **data folder** of your choice for autosaves, smart materials, presets, templates and UI layouts, on any drive (Settings › General › Folders; `Documents/TextureCraft` by default). - **Autosave**: each project keeps its own copy in the data folder's `autosave`, named - `-.tcraft` after its saved file (or, until it is saved, the project), so projects made from + `-copy-.tcraft` after its saved file (or, until it is saved, the project), so projects made from one mesh never overwrite each other's copy. - A **Settings window** (Edit › Settings) with General, Shortcuts and Libraries pages; changes apply on OK and Cancel drops them. General holds the language (or the system's), the 3D view's From f9d29d9ccfbfe56a2ec7f8ce6f5e77c50c6b797a Mon Sep 17 00:00:00 2001 From: "autocraft-bot[bot]" <354215646+autocraft-bot[bot]@users.noreply.github.com> Date: Thu, 26 Nov 2026 07:33:47 +0000 Subject: [PATCH 73/83] Apply review fixes - crates/ui-egui/src/autosave_name.rs --- crates/ui-egui/src/autosave_name.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/ui-egui/src/autosave_name.rs b/crates/ui-egui/src/autosave_name.rs index 04df5543..fa188ad8 100644 --- a/crates/ui-egui/src/autosave_name.rs +++ b/crates/ui-egui/src/autosave_name.rs @@ -15,7 +15,7 @@ const SUFFIX_DIGITS: usize = 8; const COPY_MARK: &str = "-copy-"; /// The longest stem kept, so the suffix and the temporary files of a save still fit a file name -const MAX_STEM_CHARS: usize = 180; +const MAX_STEM_CHARS: usize = 170; impl TextureCraftApp { /// The open project's autosave file in `folder`. A saved project's copy is named after its file and stays the From 3695db1d44205e74be60ea6ad9b8cbc050324271 Mon Sep 17 00:00:00 2001 From: FredApps <153173854+FredApps@users.noreply.github.com> Date: Thu, 26 Nov 2026 15:50:40 +0700 Subject: [PATCH 74/83] Warp toolbar test: install the headless runtime on its harness Main's CI has failed since #837 merged: place_on_surface_keeps_a_warp_on_its_own_texture_set builds its harness without framework::install_headless, which the framework runtime needs since #800, and panics with "the runtime plugin's hooks did not run". Every other harness already installs it. --- crates/ui-egui/src/frame_gizmo/warp_toolbar/mod.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/crates/ui-egui/src/frame_gizmo/warp_toolbar/mod.rs b/crates/ui-egui/src/frame_gizmo/warp_toolbar/mod.rs index 042f4f39..6bb7d226 100644 --- a/crates/ui-egui/src/frame_gizmo/warp_toolbar/mod.rs +++ b/crates/ui-egui/src/frame_gizmo/warp_toolbar/mod.rs @@ -253,7 +253,10 @@ mod tests { let _language = crate::i18n::TEST_LANGUAGE.lock().unwrap_or_else(std::sync::PoisonError::into_inner); let mesh = texturecraft_engine::geom::primitives::material_ball(); let session = texturecraft_engine::Session::new_project("Warp placement", mesh, "builtin:material_ball", None, 128).unwrap(); - let mut harness = Harness::builder().with_size(vec2(1600.0, 960.0)).build_eframe(|context| TextureCraftApp::new(context, session)); + let mut harness = Harness::builder() + .with_size(vec2(1600.0, 960.0)) + .with_context_setup(crate::framework::install_headless) + .build_eframe(|context| TextureCraftApp::new(context, session)); let layer = harness.state_mut().run("layer.add.fill", json!({})).unwrap()["layer"].as_u64().unwrap(); harness.state_mut().run("layer.fill.projection", json!({"layer": layer, "projection": "warp"})).unwrap(); harness.run_steps(2); From 82e81e518b80530492da461067911f67dc55b1e7 Mon Sep 17 00:00:00 2001 From: Morion Date: Thu, 26 Nov 2026 10:09:18 -0500 Subject: [PATCH 75/83] Autosave test: install the headless runtime on its harness --- crates/ui-egui/tests/autosave_files.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/crates/ui-egui/tests/autosave_files.rs b/crates/ui-egui/tests/autosave_files.rs index 01211191..9b8b7548 100644 --- a/crates/ui-egui/tests/autosave_files.rs +++ b/crates/ui-egui/tests/autosave_files.rs @@ -34,7 +34,10 @@ fn copies(folder: &Path) -> Vec { /// Runs an app on `session` until the autosave folder holds `count` copies fn autosave(session: Session, folder: &Path, count: usize) -> Harness<'static, TextureCraftApp> { - let mut harness = Harness::builder().with_step_dt(FRAME_SECONDS).build_eframe(|cc| TextureCraftApp::new(cc, session)); + let mut harness = Harness::builder() + .with_step_dt(FRAME_SECONDS) + .with_context_setup(texturecraft_ui_egui::framework::install_headless) + .build_eframe(|cc| TextureCraftApp::new(cc, session)); let started = Instant::now(); while copies(folder).len() < count { harness.step(); From 1f78ba35781f40c0d10f33f778abf583bc596238 Mon Sep 17 00:00:00 2001 From: ViktorBystrov72 Date: Thu, 26 Nov 2026 20:54:16 +0500 Subject: [PATCH 76/83] Isolate TextureCraft UI language on each thread (#797) Co-authored-by: ViktorBystrov72 <18964918+ViktorBystrov72@users.noreply.github.com> --- crates/ui-egui/src/i18n.rs | 38 +++++++++++++++++++++++++++++++------- 1 file changed, 31 insertions(+), 7 deletions(-) diff --git a/crates/ui-egui/src/i18n.rs b/crates/ui-egui/src/i18n.rs index 235ebc5e..2210638e 100644 --- a/crates/ui-egui/src/i18n.rs +++ b/crates/ui-egui/src/i18n.rs @@ -1,8 +1,8 @@ //! UI text lookup over the optional shared craft-i18n catalogs. //! Missing translations and builds without catalogs use the English source text. +use std::cell::Cell; use std::fmt::Display; -use std::sync::atomic::{AtomicUsize, Ordering}; use std::sync::{LazyLock, OnceLock}; include!(concat!(env!("OUT_DIR"), "/craft_i18n.rs")); @@ -52,7 +52,10 @@ pub static LANGUAGES: [Language; COUNT] = [ Language { code: "ar", name: "العربية", english: "Arabic" }, ]; -static CURRENT: AtomicUsize = AtomicUsize::new(0); +// Rendering and preferences use the UI thread, including independent test harnesses. +thread_local! { + static CURRENT: Cell = const { Cell::new(0) }; +} /// How a fill reads its images, as the Filtering combo names it pub(crate) fn filtering_label(filtering: texturecraft_engine::core::Filtering) -> &'static str { @@ -96,20 +99,20 @@ pub(crate) fn baked_map_label(map: texturecraft_engine::core::BakedMap) -> &'sta /// The saved language that follows the operating system's (Settings > Language > Default (System Language)). pub const SYSTEM_LANGUAGE: &str = ""; -/// Switch the UI language ([`SYSTEM_LANGUAGE`] follows the system; unknown codes fall back to English). +/// Switch the calling UI thread's language. [`SYSTEM_LANGUAGE`] follows the system. pub fn set_language(code: &str) { let code = if code == SYSTEM_LANGUAGE { system_language() } else { code }; - CURRENT.store(LANGUAGES.iter().position(|l| l.code.eq_ignore_ascii_case(code) && available(l.code)).unwrap_or(0), Ordering::Relaxed); + CURRENT.set(LANGUAGES.iter().position(|l| l.code.eq_ignore_ascii_case(code) && available(l.code)).unwrap_or(0)); } /// The current UI language. pub fn current() -> &'static Language { - LANGUAGES.get(CURRENT.load(Ordering::Relaxed)).unwrap_or(&LANGUAGES[0]) + LANGUAGES.get(CURRENT.get()).unwrap_or(&LANGUAGES[0]) } /// `text` in the current language (unchanged when it has no translation). pub fn tr(text: &str) -> &str { - let lang = shared_languages().get(CURRENT.load(Ordering::Relaxed)).copied().unwrap_or(craft_i18n::Lang::EN); + let lang = shared_languages().get(CURRENT.get()).copied().unwrap_or(craft_i18n::Lang::EN); I18N.t(lang, text) } @@ -182,7 +185,7 @@ fn system_language() -> &'static str { SYSTEM.get_or_init(os_language) } -/// Tests that switch the global UI language, or draw the UI under it, run one at a time. +/// Shared guard used by language fixture tests. #[cfg(test)] pub(crate) static TEST_LANGUAGE: std::sync::Mutex<()> = std::sync::Mutex::new(()); @@ -192,6 +195,27 @@ mod tests { use super::*; use std::collections::{BTreeSet, HashMap}; + #[test] + fn a_parallel_ui_language_context_keeps_its_own_language() { + set_language("en"); + let french = LANGUAGES.iter().position(|language| language.code == "fr").unwrap(); + let barrier = std::sync::Barrier::new(2); + let (first, second) = std::thread::scope(|scope| { + let other = scope.spawn(|| { + // Exercise the resolved language selection even when the French catalog is absent. + CURRENT.set(french); + barrier.wait(); + barrier.wait(); + current().code + }); + barrier.wait(); + let first = current().code; + barrier.wait(); + (first, other.join().unwrap()) + }); + assert_eq!((first, second), ("en", "fr")); + } + /// Every key the UI looks up: `tr("…")` / `trf("…"` literals in the sources, plus the /// static catalogs whose labels are translated where they are shown. fn keys() -> Vec { From 59860919689cb11ab061c927b9f3e66e0081e64b Mon Sep 17 00:00:00 2001 From: chasse20 Date: Thu, 26 Nov 2026 16:19:15 +0000 Subject: [PATCH 77/83] Auto: Fix close after a prior save fails and isolate UI language MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Let an unmodified replacement project finish closing once the previous project’s save ends, even if the write fails. Add a regression test for that sequence. Keep each UI thread’s language selection independent and add a test that selects different languages on two concurrent threads. --- crates/ui-egui/src/manual_save.rs | 36 ++++++++++++++++++++++--------- 1 file changed, 26 insertions(+), 10 deletions(-) diff --git a/crates/ui-egui/src/manual_save.rs b/crates/ui-egui/src/manual_save.rs index 843a0e01..9243482a 100644 --- a/crates/ui-egui/src/manual_save.rs +++ b/crates/ui-egui/src/manual_save.rs @@ -93,7 +93,7 @@ impl TextureCraftApp { self.saving_for_prompt = false; } - let mut quitting = false; + let save_succeeded = result.is_ok(); match result { Ok(output) => { output.apply(&mut self.session); @@ -101,17 +101,11 @@ impl TextureCraftApp { crate::windows::remember(self, &output.path); } - let clean = !self.session.modified && !self.session.stroke_active(); - quitting = quit_requested && clean; if continue_prompt { - self.prompt_saved = clean && !quitting; + self.prompt_saved = !self.session.modified && !self.session.stroke_active() && !quit_requested; } self.toast(trf("Saved {path}", &[("path", &output.path)]), false); - if quitting { - self.ui.windows.unsaved = None; - ctx.send_viewport_cmd(egui::ViewportCommand::Close); - } } Err(error) => { let message = trf("Could not save project: {error}", &[("error", &error)]); @@ -120,10 +114,13 @@ impl TextureCraftApp { } } - // An open stroke settles before the pending close checks for unsaved edits - if quit_requested && !quitting { + if quit_requested { if self.session.stroke_active() { self.quit_after_stroke = Some(self.session.project_id); + } else if !self.session.modified && (save_succeeded || !same_project) { + // A replacement project's own close only needs the previous writer to finish + self.ui.windows.unsaved = None; + ctx.send_viewport_cmd(egui::ViewportCommand::Close); } else { crate::windows::ask_to_save(self, Unsaved::Quit); } @@ -415,6 +412,25 @@ mod tests { assert!(h.state().ui.windows.unsaved.is_none()); } + #[test] + fn closing_the_replacement_resumes_after_the_original_save_fails() { + let _language = crate::i18n::TEST_LANGUAGE.lock().unwrap_or_else(std::sync::PoisonError::into_inner); + let file = temp_file("close-replacement-after-failure").with_file_name("missing").join("project.tcraft"); + let mut h = harness(); + let (task, sender) = start_held_save(&mut h, &file, true); + let replacement = texturecraft_engine::sample_session(256, 64).unwrap(); + h.state_mut().session.switch_to(replacement); + + request_close(&mut h); + assert!(!sends_close(&mut h), "the replacement waits for the original save"); + let result = task.run(None); + assert!(result.is_err(), "the original write fails"); + sender.send(result).unwrap(); + + assert!(sends_close(&mut h), "the replacement's own close resumes after the failed write"); + assert!(h.state().ui.windows.unsaved.is_none()); + } + #[test] fn canceling_a_stroke_after_a_successful_save_leaves_the_saved_edits_clean() { let _language = crate::i18n::TEST_LANGUAGE.lock().unwrap_or_else(std::sync::PoisonError::into_inner); From ac4454bb38825b72d12436d43501fe6945b4575c Mon Sep 17 00:00:00 2001 From: Simon Hull <5488089+simonhull@users.noreply.github.com> Date: Thu, 26 Nov 2026 10:21:07 -0600 Subject: [PATCH 78/83] Geom: check indices before computing tangents (#386) Mesh::from_parts computed normals and tangents before validate(). An index past the last vertex reads as the origin in the MikkTSpace callbacks, but the all-degenerate guard compares positions.get() and counts a missing vertex as different. So two positions with indices [0, 1, 2] passed the guard while MikkTSpace saw every triangle as degenerate and underflowed at generated.rs:1100: a panic in debug, an out-of-bounds walk in release. compute_tangents now also skips MikkTSpace (using the per-triangle fallback, which reads with get()) when an index is out of range, and from_parts refuses such indices before building the mesh, with the same error validate() gives. --- crates/geom/src/mesh.rs | 36 ++++++++++++++++++++++++++++++++++-- 1 file changed, 34 insertions(+), 2 deletions(-) diff --git a/crates/geom/src/mesh.rs b/crates/geom/src/mesh.rs index 03d47845..e00ed374 100644 --- a/crates/geom/src/mesh.rs +++ b/crates/geom/src/mesh.rs @@ -315,8 +315,11 @@ impl Mesh { if self.uvs.len() != self.positions.len() { self.uvs = vec![Vec2::ZERO; self.positions.len()]; } - // mikktspace crashes (out-of-bounds) when every triangle is degenerate; skip it then. - if crate::unwrap::all_triangles_degenerate(self) { + // mikktspace crashes (out-of-bounds) when every triangle is degenerate; skip it then. Its + // callbacks read a missing vertex as the origin, which the degenerate check cannot see, so + // an index past the last vertex skips it too. + let n = self.positions.len(); + if !self.indices.iter().all(|&i| (i as usize) < n) || crate::unwrap::all_triangles_degenerate(self) { self.simple_tangents(); } else { let faces = self.tangent_faces(); @@ -497,6 +500,9 @@ impl Mesh { /// A single-material mesh from raw attributes; computes missing normals and tangents. pub fn from_parts(positions: Vec, normals: Option>, uvs: Vec, indices: Vec, material: &str) -> Result { + if let Some(bad) = indices.iter().find(|&&i| i as usize >= positions.len()) { + return Err(GeomError::Invalid(format!("index {bad} out of range ({} vertices)", positions.len()))); + } let count = indices.len() as u32; let mut m = Mesh { normals: normals.unwrap_or_default(), @@ -910,4 +916,30 @@ mod tests { assert_eq!(m.uv_tiles(1).into_iter().collect::>(), vec![(1, 0)]); assert_eq!(m.uv_tiles(0).into_iter().collect::>(), vec![(0, 0)]); } + + /// An index past the last vertex reads as the origin in MikkTSpace's callbacks. With two + /// positions at the origin and one missing, the degenerate-mesh guard (which sees the missing + /// vertex as different) let it through while MikkTSpace saw every triangle as degenerate and + /// underflowed: a panic in debug builds, an out-of-bounds walk in release. + #[test] + fn from_parts_refuses_an_out_of_range_index_without_crashing() { + let positions = vec![Vec3::ZERO, Vec3::X]; + let uvs = vec![Vec2::ZERO, Vec2::X]; + let e = Mesh::from_parts(positions, None, uvs, vec![0, 1, 2], "M").unwrap_err(); + assert!(e.to_string().contains("out of range"), "{e}"); + } + + #[test] + fn tangents_of_a_mesh_with_an_out_of_range_index_fall_back_without_crashing() { + for indices in [vec![0, 1, 2], vec![0, 0, 2], vec![0, 1, 5, 0, 1, 1]] { + let mut m = Mesh::from_parts(vec![Vec3::ZERO, Vec3::X, Vec3::Y], None, vec![Vec2::ZERO, Vec2::X, Vec2::Y], vec![0, 1, 2], "M").unwrap(); + m.positions.truncate(2); + m.normals.truncate(2); + m.uvs.truncate(2); + m.indices = indices; + m.compute_tangents(); + assert_eq!(m.tangents.len(), 2); + assert!(m.tangents.iter().all(|t| t.is_finite()), "{:?}", m.tangents); + } + } } From 0fbfec1c3d732dc9ba18c9f55f8bc7cd5dc6a7a9 Mon Sep 17 00:00:00 2001 From: ATOM Date: Thu, 26 Nov 2026 10:36:05 -0600 Subject: [PATCH 79/83] fix(mesh): weld recomputed normals and make export opt-in --- crates/automation/src/rpc.rs | 5 +-- crates/engine/src/file_cmds.rs | 44 +++++++++++++++++++---- crates/formats/src/mesh_import/mod.rs | 21 ++--------- crates/geom/src/mesh.rs | 21 +++++++++++ crates/ui-egui/src/mesh_export_options.rs | 4 +-- crates/ui-egui/src/state.rs | 13 +++---- crates/ui-egui/tests/it/side_panels.rs | 12 +++---- 7 files changed, 78 insertions(+), 42 deletions(-) diff --git a/crates/automation/src/rpc.rs b/crates/automation/src/rpc.rs index b0a21e77..aefb4919 100644 --- a/crates/automation/src/rpc.rs +++ b/crates/automation/src/rpc.rs @@ -4,8 +4,9 @@ //! //! Methods: the app's `ping`, `command.run {id, params?}`, `command.list {filter?}`, //! `session.inspect`, plus `command.batch {steps}`, `project.open {path}`, -//! `project.save {path?}`, `mesh.import {path, resolution?, name?}`, `mesh.reimport {path?, -//! `preserveStrokes?}`, `mesh.export {path, format?, recomputeNormals?}`, `bake.mesh.add {path, cage?}`, +//! `project.save {path?}`, `mesh.import {path, resolution?, name?}`, +//! `mesh.reimport {path?, preserveStrokes?}`, `mesh.export {path, format?, recomputeNormals?}`, +//! `bake.mesh.add {path, cage?}`, //! `resource.import {path}`, `material.save {path, layer?, name?}`, `material.load {path}` //! (workspace-scoped versions of the engine commands), //! `textures.export {dir, …}`, `render {view?, width?, height?, yaw?, pitch?}` (PNG base64, the diff --git a/crates/engine/src/file_cmds.rs b/crates/engine/src/file_cmds.rs index e827ef0e..553f6ffa 100644 --- a/crates/engine/src/file_cmds.rs +++ b/crates/engine/src/file_cmds.rs @@ -122,7 +122,7 @@ impl Session { pub fn mesh_obj_bytes_with_normals(&self, recompute_normals: bool) -> Result> { let mut mesh = self.source_mesh(); if recompute_normals { - mesh.compute_normals(); + mesh.compute_smooth_normals(); } texturecraft_formats::obj_bytes(&mesh, &self.doc.project.name).map_err(fe) } @@ -139,7 +139,7 @@ impl Session { // one image); their tiles export through Export textures with `$udim` names. let mut mesh = self.source_mesh(); if recompute_normals { - mesh.compute_normals(); + mesh.compute_smooth_normals(); } // A mesh without materials has one implicit material (and texture set). if mesh.materials.is_empty() { @@ -162,7 +162,7 @@ impl Session { let textures: Vec<_> = files.into_iter().map(texturecraft_formats::GlbTextures::from_files).collect(); let mut mesh = self.mesh.as_ref().clone(); if recompute_normals { - mesh.compute_normals(); + mesh.compute_smooth_normals(); } texturecraft_formats::glb_bytes(&mesh, &self.doc.project.name, &textures).map_err(fe) } @@ -178,7 +178,7 @@ impl Session { let files = self.material_files(texturecraft_formats::usd_export_options(), true, self.mesh.materials.len())?; let mut mesh = self.mesh.as_ref().clone(); if recompute_normals { - mesh.compute_normals(); + mesh.compute_smooth_normals(); } texturecraft_formats::usd_bytes(&mesh, &self.doc.project.name, &files, format).map_err(fe) } @@ -1449,7 +1449,7 @@ f 1/1 2/2 3/3 std::sync::Arc::make_mut(&mut s.source).normals.fill(texturecraft_geom::glam::Vec3::Y); std::sync::Arc::make_mut(&mut s.mesh).normals.fill(texturecraft_geom::glam::Vec3::Y); let mut expected = s.source_mesh(); - expected.compute_normals(); + expected.compute_smooth_normals(); let dir = std::env::temp_dir().join(format!("tc_export_recompute_{}", std::process::id())); let _ = std::fs::remove_dir_all(&dir); std::fs::create_dir_all(&dir).unwrap(); @@ -1459,8 +1459,14 @@ f 1/1 2/2 3/3 let bytes = std::fs::read(reply["path"].as_str().unwrap()).unwrap(); let back = texturecraft_formats::import_mesh_bytes(&format!("cube.{suffix}"), &bytes).unwrap().mesh; assert_eq!(back.normals.len(), expected.normals.len(), "{format}: one normal per exported vertex"); - for (actual, wanted) in back.normals.iter().zip(&expected.normals) { - assert!((*actual - *wanted).length() < 1e-4, "{format}: stored normals were exported instead of recomputed ones"); + for (position, actual) in back.positions.iter().zip(&back.normals) { + let wanted = expected + .positions + .iter() + .zip(&expected.normals) + .find_map(|(expected_position, normal)| ((*expected_position - *position).length() < 1e-4).then_some(*normal)) + .unwrap_or_else(|| panic!("{format}: exported position {position:?} is missing from the source")); + assert!((*actual - wanted).length() < 1e-4, "{format}: actual {actual:?}, wanted {wanted:?}"); } } assert!(s.source.normals.iter().all(|n| *n == texturecraft_geom::glam::Vec3::Y), "the source project is unchanged"); @@ -1473,6 +1479,30 @@ f 1/1 2/2 3/3 let _ = std::fs::remove_dir_all(&dir); } + #[test] + fn recomputed_normals_weld_uv_seams_in_exported_mesh() { + use texturecraft_geom::glam::Vec3; + + // Two triangles meet along 0--2, but their UV island split duplicates that edge as 3--4. + let positions = vec![Vec3::ZERO, Vec3::X, Vec3::Y, Vec3::ZERO, Vec3::Y, Vec3::new(-1.0, 0.0, 1.0)]; + let mesh = Mesh::from_parts( + positions, + Some(vec![Vec3::Y; 6]), + vec![Vec2::new(0.0, 0.0), Vec2::new(0.5, 0.5), Vec2::new(0.0, 1.0), Vec2::new(1.0, 0.0), Vec2::new(1.0, 1.0), Vec2::new(0.5, 1.0)], + vec![0, 1, 2, 3, 4, 5], + "Default", + ) + .unwrap(); + let mut s = Session::new_project("seam", mesh, "builtin:seam", None, 128).unwrap(); + let bytes = s.mesh_glb_bytes_with_normals(true).unwrap(); + let back = texturecraft_formats::import_mesh_bytes("seam.glb", &bytes).unwrap().mesh; + for point in [Vec3::ZERO, Vec3::Y] { + let normals: Vec<_> = back.positions.iter().zip(&back.normals).filter_map(|(position, normal)| (*position == point).then_some(*normal)).collect(); + assert!(normals.len() >= 2, "{point:?}: the UV seam must still have two exported vertices"); + assert!(normals.windows(2).all(|pair| (pair[0] - pair[1]).length() < 1e-5), "{point:?}: UV split normals disagree: {normals:?}"); + } + } + #[test] fn rejected_glb_export_preserves_existing_files_and_publishes_nothing() { let mut s = Session::new_project("t", primitives::cube(1.0), "builtin:cube", None, 128).unwrap(); diff --git a/crates/formats/src/mesh_import/mod.rs b/crates/formats/src/mesh_import/mod.rs index 6450878b..5e0d2468 100644 --- a/crates/formats/src/mesh_import/mod.rs +++ b/crates/formats/src/mesh_import/mod.rs @@ -25,7 +25,7 @@ use std::collections::hash_map::Entry; use std::collections::{HashMap, HashSet}; use texturecraft_geom::glam::{Mat4, Vec2, Vec3, Vec4}; -use texturecraft_geom::unwrap::{all_triangles_degenerate, auto_unwrap, weld_ids}; +use texturecraft_geom::unwrap::{all_triangles_degenerate, auto_unwrap}; use texturecraft_geom::{BaseColor, MAX_TRIANGLES, Mesh, SubMesh, UvGBuffer}; use crate::{FormatError, Result}; @@ -508,7 +508,7 @@ fn geometry(raw: RawMesh) -> Result<(Mesh, Vec, Option>)> { mesh.normals = match normals { Some(n) if n.len() == mesh.positions.len() => n.into_iter().map(|v| v.try_normalize().unwrap_or(Vec3::Y)).collect(), - _ => smooth_normals(&mesh), + _ => mesh.smooth_normals(), }; if let Some(c) = colors.filter(|c| c.len() == mesh.positions.len()) { mesh.colors = c.into_iter().map(|v| if v.is_finite() { v.clamp(Vec4::ZERO, Vec4::ONE) } else { Vec4::ONE }).collect(); @@ -641,23 +641,6 @@ fn orbit_cameras(raw: &[RawCamera], mesh: &Mesh) -> Vec Vec { - let welded_vertices = weld_ids(&mesh.positions); - let mut normals = vec![Vec3::ZERO; mesh.positions.len()]; - for triangle in mesh.indices.as_chunks::<3>().0 { - let p = |i: u32| mesh.positions.get(i as usize).copied().unwrap_or_default(); - let face = (p(triangle[1]) - p(triangle[0])).cross(p(triangle[2]) - p(triangle[0])); - for v in triangle { - if let Some(a) = welded_vertices.get(*v as usize).and_then(|w| normals.get_mut(*w as usize)) { - *a += face; - } - } - } - - welded_vertices.iter().map(|w| normals.get(*w as usize).and_then(|n| n.try_normalize()).unwrap_or(Vec3::Y)).collect() -} - /// Inspects `mesh` and generates its UV report (overlaps, out-of-range UVs, warnings). pub fn mesh_report(mesh: &Mesh) -> MeshReport { report(mesh, false, Vec::new()) diff --git a/crates/geom/src/mesh.rs b/crates/geom/src/mesh.rs index 03d47845..3bae99f4 100644 --- a/crates/geom/src/mesh.rs +++ b/crates/geom/src/mesh.rs @@ -245,6 +245,27 @@ impl Mesh { self.normals = normals.into_iter().map(|v| v.try_normalize().unwrap_or(Vec3::Y)).collect(); } + /// Area-weighted smooth normals over welded positions, so UV and material seams do not split shading. + pub fn smooth_normals(&self) -> Vec { + let welded_vertices = crate::unwrap::weld_ids(&self.positions); + let mut normals = vec![Vec3::ZERO; self.positions.len()]; + for triangle in self.indices.as_chunks::<3>().0 { + let p = |i: u32| self.positions.get(i as usize).copied().unwrap_or_default(); + let face = (p(triangle[1]) - p(triangle[0])).cross(p(triangle[2]) - p(triangle[0])); + for v in triangle { + if let Some(accumulated) = welded_vertices.get(*v as usize).and_then(|welded| normals.get_mut(*welded as usize)) { + *accumulated += face; + } + } + } + welded_vertices.iter().map(|welded| normals.get(*welded as usize).and_then(|normal| normal.try_normalize()).unwrap_or(Vec3::Y)).collect() + } + + /// Replace normals with [`Mesh::smooth_normals`] on this mesh. + pub fn compute_smooth_normals(&mut self) { + self.normals = self.smooth_normals(); + } + /// The faces MikkTSpace sees: each importer quad (a fan pair marked in [`Mesh::diagonals`]) /// as one four-corner face, like Blender hands it over, and every other triangle as a /// triangle. Polygons with more than four corners stay fan triangles. The vertex and index diff --git a/crates/ui-egui/src/mesh_export_options.rs b/crates/ui-egui/src/mesh_export_options.rs index 822962b3..7d5cb5c2 100644 --- a/crates/ui-egui/src/mesh_export_options.rs +++ b/crates/ui-egui/src/mesh_export_options.rs @@ -47,8 +47,6 @@ pub(crate) fn show(app: &mut TextureCraftApp, ctx: &egui::Context) { tr("TextureCraft keeps meshes as triangles, so the exported mesh is always triangulated."), ], ); - ui.add_space(GROUP_GAP); - unavailable::greyed(ui, |ui| ui.add(egui::RadioButton::new(false, tr("With displacement/tessellation")))); option( ui, &mut app.ui.mesh_recompute_normals, @@ -59,6 +57,8 @@ pub(crate) fn show(app: &mut TextureCraftApp, ctx: &egui::Context) { tr("On: smooth area-weighted normals from the exported geometry. Off: the project's stored normals. The project itself is not changed."), ], ); + ui.add_space(GROUP_GAP); + unavailable::greyed(ui, |ui| ui.add(egui::RadioButton::new(false, tr("With displacement/tessellation")))); ui.add_space(8.0); // One row keeps the window to its contents; a bare right-to-left layout fills the screen height diff --git a/crates/ui-egui/src/state.rs b/crates/ui-egui/src/state.rs index c1fe25e5..1f447556 100644 --- a/crates/ui-egui/src/state.rs +++ b/crates/ui-egui/src/state.rs @@ -567,7 +567,8 @@ pub struct UiState { pub hide_ui: bool, pub windows: Windows, /// Mesh Export Options: compute smooth normals on the exported copy, not the project. - #[serde(default = "default_true")] + /// Off by default so an export keeps the project's authored normals unless the user opts in. + #[serde(default)] pub mesh_recompute_normals: bool, pub uv_zoom: f32, pub uv_pan: [f32; 2], @@ -778,7 +779,7 @@ impl Default for UiState { selected_baked_map: None, hide_ui: false, windows: Windows::default(), - mesh_recompute_normals: true, + mesh_recompute_normals: false, uv_zoom: 1.0, uv_pan: [0.0, 0.0], uv_rotation: 0.0, @@ -862,12 +863,12 @@ mod tests { } #[test] - fn mesh_export_normal_choice_defaults_on_for_older_saved_states() { - assert!(UiState::default().mesh_recompute_normals); + fn mesh_export_normal_choice_defaults_off_for_older_saved_states() { + assert!(!UiState::default().mesh_recompute_normals); let mut saved = serde_json::to_value(UiState::default()).unwrap(); saved.as_object_mut().unwrap().remove("mesh_recompute_normals"); let loaded: UiState = serde_json::from_value(saved).unwrap(); - assert!(loaded.mesh_recompute_normals, "older states keep the dialog's checked default"); + assert!(!loaded.mesh_recompute_normals, "older states keep the project's stored normals unless the user opts in"); } #[test] @@ -881,7 +882,7 @@ mod tests { ui.keymap.insert("file.save".into(), "F5".into()); ui.mesh_recompute_normals = false; let mut layout = UiState::default(); - assert!(layout.mesh_recompute_normals); + layout.mesh_recompute_normals = true; layout.dock.close(crate::docking::Panel::Assets); ui.adopt_layout(layout); diff --git a/crates/ui-egui/tests/it/side_panels.rs b/crates/ui-egui/tests/it/side_panels.rs index 62362f74..399a5161 100644 --- a/crates/ui-egui/tests/it/side_panels.rs +++ b/crates/ui-egui/tests/it/side_panels.rs @@ -185,21 +185,21 @@ fn recompute_normals_is_an_enabled_keyboard_operable_checkbox() { harness.run_steps(SETTLE_FRAMES); let checkbox = harness.get_by_role_and_label(Role::CheckBox, "Recompute vertex normals"); assert!(!checkbox.accesskit_node().is_disabled(), "the option is really available"); - assert!(is_on(&checkbox), "it starts checked, as the dialog always showed it"); - assert!(harness.state().ui.mesh_recompute_normals); + assert!(!is_on(&checkbox), "stored normals are kept until the user opts in"); + assert!(!harness.state().ui.mesh_recompute_normals); checkbox.focus(); harness.key_press(egui::Key::Space); harness.run_steps(SETTLE_FRAMES); - assert!(!harness.state().ui.mesh_recompute_normals, "Space changes the setting used by export"); + assert!(harness.state().ui.mesh_recompute_normals, "Space changes the setting used by export"); let checkbox = harness.get_by_role_and_label(Role::CheckBox, "Recompute vertex normals"); - assert!(!is_on(&checkbox), "the accessibility tree reports the unchecked state"); + assert!(is_on(&checkbox), "the accessibility tree reports the checked state"); assert_eq!(checkbox.accesskit_node().label().as_deref(), Some("Recompute vertex normals")); checkbox.click(); harness.run_steps(SETTLE_FRAMES); - assert!(harness.state().ui.mesh_recompute_normals, "a pointer click turns it back on"); - assert!(is_on(&harness.get_by_role_and_label(Role::CheckBox, "Recompute vertex normals"))); + assert!(!harness.state().ui.mesh_recompute_normals, "a pointer click turns it back off"); + assert!(!is_on(&harness.get_by_role_and_label(Role::CheckBox, "Recompute vertex normals"))); } /// Whether the Log lists `line` (the status bar under it repeats the last message) From cfdb0e57d54ad13ae8216c9044cab160500fb0cc Mon Sep 17 00:00:00 2001 From: Morion Date: Thu, 26 Nov 2026 11:49:41 -0500 Subject: [PATCH 80/83] Autosave: widen the copy suffix to 64 bits --- crates/ui-egui/src/autosave_name.rs | 15 ++++++++------- crates/ui-egui/src/lib.rs | 2 +- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/crates/ui-egui/src/autosave_name.rs b/crates/ui-egui/src/autosave_name.rs index fa188ad8..a15e2b79 100644 --- a/crates/ui-egui/src/autosave_name.rs +++ b/crates/ui-egui/src/autosave_name.rs @@ -9,7 +9,7 @@ use texturecraft_engine::formats::export::sanitize_file_stem; use crate::TextureCraftApp; /// Hex digits of a copy's suffix -const SUFFIX_DIGITS: usize = 8; +const SUFFIX_DIGITS: usize = 16; /// Between a copy's stem and its suffix, so a user's own file named like `report-20240115` is not taken for a copy const COPY_MARK: &str = "-copy-"; @@ -46,7 +46,7 @@ impl TextureCraftApp { } } -fn file_name(stem: &str, suffix: u32) -> String { +fn file_name(stem: &str, suffix: u64) -> String { let stem: String = sanitize_file_stem(stem).chars().take(MAX_STEM_CHARS).collect(); format!("{stem}{COPY_MARK}{suffix:0SUFFIX_DIGITS$x}.{PROJECT_EXT}") } @@ -66,7 +66,7 @@ fn is_copy_in(path: &Path, folder: &Path) -> bool { /// A suffix for the unsaved project `project`: from this process and the moment, so another instance or a later run /// takes a different one -fn new_suffix(project: u64) -> u32 { +fn new_suffix(project: u64) -> u64 { let now = chrono::Utc::now().timestamp_nanos_opt().unwrap_or_default(); let mut seed = Vec::new(); seed.extend_from_slice(&std::process::id().to_le_bytes()); @@ -75,9 +75,10 @@ fn new_suffix(project: u64) -> u32 { hash(&seed) } -/// 32-bit FNV-1a: the same bytes give the same suffix in every release, which the standard hasher does not promise -fn hash(bytes: &[u8]) -> u32 { - bytes.iter().fold(0x811c_9dc5, |hash, byte| (hash ^ u32::from(*byte)).wrapping_mul(0x0100_0193)) +/// 64-bit FNV-1a: the same bytes give the same suffix in every release, which the standard hasher does not promise. +/// Wide enough that two paths are very unlikely to share one +fn hash(bytes: &[u8]) -> u64 { + bytes.iter().fold(0xcbf2_9ce4_8422_2325, |hash, byte| (hash ^ u64::from(*byte)).wrapping_mul(0x0000_0100_0000_01b3)) } #[cfg(test)] @@ -157,7 +158,7 @@ mod tests { #[test] fn suffixes_have_a_fixed_width_and_long_names_are_cut() { let narrow = file_name("hero", 1); - let wide = file_name("hero", u32::MAX); + let wide = file_name("hero", u64::MAX); assert_eq!(narrow.len(), wide.len(), "every suffix has the same width"); assert!(file_name(&"a".repeat(500), 1).len() < 200); } diff --git a/crates/ui-egui/src/lib.rs b/crates/ui-egui/src/lib.rs index 38f5161b..611d4f8d 100644 --- a/crates/ui-egui/src/lib.rs +++ b/crates/ui-egui/src/lib.rs @@ -363,7 +363,7 @@ pub struct TextureCraftApp { next_autosave: f64, /// The unsaved project (its id) and the suffix of its autosave copy. #[cfg(not(target_arch = "wasm32"))] - unsaved_autosave_suffix: Option<(u64, u32)>, + unsaved_autosave_suffix: Option<(u64, u64)>, /// The brightness and accent the style was last built for. styled: Option<(theme::Brightness, theme::Accent)>, /// Whether the window had focus last frame. From 448d22aa26904396d22d007d9f6209e2be117f82 Mon Sep 17 00:00:00 2001 From: "autocraft-bot[bot]" <354215646+autocraft-bot[bot]@users.noreply.github.com> Date: Thu, 26 Nov 2026 21:31:02 +0000 Subject: [PATCH 81/83] Apply review fixes - docs/ui-parity.md --- docs/ui-parity.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/docs/ui-parity.md b/docs/ui-parity.md index 1e45c49d..26198df6 100644 --- a/docs/ui-parity.md +++ b/docs/ui-parity.md @@ -71,8 +71,10 @@ that closes it back onto the bar; the float is saved with the UI state. with materials that refer to the exported textures; greyed in the browser), *Export shaders parameters* greyed, *Include all*, *Save settings* and "N textures selected for export"). *Export MaterialX* beside them is a TextureCraft addition: it adds `materialX: true` to the - export. The prompt's *With displacement/tessellation* choice and both option checkboxes are - greyed; TextureCraft exports the mesh as it is. + export. The prompt's *With displacement/tessellation* choice and *Apply triangulation* are greyed + (TextureCraft exports the mesh as it is, triangulated). *Recompute vertex normals* works and sits under + *Without displacement/tessellation*, off by default: it writes smooth area-weighted normals to the + exported copy only. - **Window menu:** Views lists *Renderer Settings* (a panel of its own: the tracer in use, the samples so far and a note; it floats when first opened and is not opened by itself in Rendering mode), *Properties - Paint* while a project is open (other tools read "Properties - ", From 5ddec31f804ebfdb0409d97824c4dae3ce1506b8 Mon Sep 17 00:00:00 2001 From: test-bit-sys Date: Thu, 26 Nov 2026 22:56:27 +0100 Subject: [PATCH 82/83] fix(engine): inspect direction on earlier-model generators (#873) --- crates/engine/src/inspect.rs | 5 ++++- crates/engine/tests/it/generator_sections.rs | 23 ++++++++++++++++++++ 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/crates/engine/src/inspect.rs b/crates/engine/src/inspect.rs index 14863420..a4258463 100644 --- a/crates/engine/src/inspect.rs +++ b/crates/engine/src/inspect.rs @@ -2,7 +2,7 @@ //! without a screenshot. use serde_json::{Value, json}; -use texturecraft_core::{Effect, EffectKind, Fill, Filter, Generator, Layer, LayerKind, NormalFormat, Projection, Sampling, Source}; +use texturecraft_core::{Effect, EffectKind, Fill, Filter, Generator, GeneratorKind, Layer, LayerKind, NormalFormat, Projection, Sampling, Source}; use crate::Session; use crate::session::StackTarget; @@ -162,6 +162,9 @@ fn generator_json(generator: &Generator) -> Value { if let Some(light) = &generator.light { out["light"] = json!(light); } + if generator.on_earlier_model() && matches!(generator.kind, GeneratorKind::Position | GeneratorKind::Direction) { + out["direction"] = json!(generator.direction); + } if let Some(texture) = &generator.texture { out["texture"] = json!(texture); } diff --git a/crates/engine/tests/it/generator_sections.rs b/crates/engine/tests/it/generator_sections.rs index 29311091..399355f3 100644 --- a/crates/engine/tests/it/generator_sections.rs +++ b/crates/engine/tests/it/generator_sections.rs @@ -167,3 +167,26 @@ fn inspect_reports_the_reference_controls_set() { assert!(inspected.contains(&format!("\"{key}\"")) && inspected.contains(value), "{key} with {value} in {inspected}"); } } + +#[test] +fn inspect_reports_direction_only_on_the_earlier_model() { + let mut session = session(); + let earlier_dir = add(&mut session, json!({"generator": "direction", "direction": [1.0, 0.0, 0.0]})); + let light_dir = add(&mut session, json!({"generator": "direction", "lightHorizontal": 90.0})); + let earlier_pos = add(&mut session, json!({"generator": "position", "direction": [0.0, 0.0, 1.0]})); + let section_pos = add(&mut session, json!({"generator": "position", "sectionContrast": 0.25})); + + let inspected = execute(&mut session, "project.inspect", &Value::Null).unwrap(); + let effects = inspected["layers"][0]["mask"]["effects"].as_array().unwrap(); + let gen_of = |effect_id: u64| &effects.iter().find(|entry| entry["id"] == effect_id).unwrap()["generator"]; + + assert_eq!(gen_of(earlier_dir)["direction"], json!([1.0, 0.0, 0.0])); + assert!(gen_of(earlier_dir).get("light").is_none()); + assert!(gen_of(light_dir).get("direction").is_none()); + assert!(gen_of(light_dir).get("light").is_some()); + + assert_eq!(gen_of(earlier_pos)["direction"], json!([0.0, 0.0, 1.0])); + assert!(gen_of(earlier_pos).get("section").is_none()); + assert!(gen_of(section_pos).get("direction").is_none()); + assert!(gen_of(section_pos).get("section").is_some()); +} From 5591288d89b46155b12f0c83754a2c9033a2631b Mon Sep 17 00:00:00 2001 From: "autocraft-bot[bot]" <354215646+autocraft-bot[bot]@users.noreply.github.com> Date: Thu, 26 Nov 2026 22:55:53 +0000 Subject: [PATCH 83/83] Apply review fixes - crates/ui-egui/src/autosave_name.rs --- crates/ui-egui/src/autosave_name.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/crates/ui-egui/src/autosave_name.rs b/crates/ui-egui/src/autosave_name.rs index a15e2b79..69d0ab4d 100644 --- a/crates/ui-egui/src/autosave_name.rs +++ b/crates/ui-egui/src/autosave_name.rs @@ -56,10 +56,15 @@ fn absolute(path: &Path) -> PathBuf { std::path::absolute(path).unwrap_or_else(|_| path.to_path_buf()) } +/// `path` with links and, on Windows, the verbatim prefix resolved so two spellings of one folder compare equal; made absolute when that fails +fn resolved(path: &Path) -> PathBuf { + std::fs::canonicalize(path).unwrap_or_else(|_| absolute(path)) +} + /// Whether `path` is an autosave copy of `folder`: a project file there whose name ends in the copy mark and a suffix fn is_copy_in(path: &Path, folder: &Path) -> bool { let suffix = path.file_stem().and_then(|stem| stem.to_str()).and_then(|stem| stem.rsplit_once(COPY_MARK)).map(|(_, suffix)| suffix); - path.parent() == Some(folder) + path.parent().is_some_and(|parent| resolved(parent) == resolved(folder)) && path.extension().is_some_and(|extension| extension == PROJECT_EXT) && suffix.is_some_and(|suffix| suffix.len() == SUFFIX_DIGITS && suffix.bytes().all(|digit| digit.is_ascii_hexdigit())) }