diff --git a/crates/render/src/gpu_bake.rs b/crates/render/src/gpu_bake.rs index f478f77a..0a8a357c 100644 --- a/crates/render/src/gpu_bake.rs +++ b/crates/render/src/gpu_bake.rs @@ -18,6 +18,10 @@ use texturecraft_geom::glam::Vec3; use crate::gpu_trace::{STACK, buffer, bvh_depth, bvh_rows, entry, scoped, storage}; const WORKGROUP: u32 = 64; +// The shader binds BVH nodes, triangles, input queries and results +const RAY_STORAGE_BUFFERS: u32 = 4; +// The hemisphere reduction stores one vec4 and one count per lane +const WORKGROUP_STORAGE_BYTES: u32 = WORKGROUP * (size_of::<[f32; 4]>() + size_of::()) as u32; /// Rays per dispatch: short dispatches keep slow GPUs clear of driver watchdogs. const RAYS_PER_DISPATCH: usize = 1 << 24; const NONE: u32 = u32::MAX; @@ -66,23 +70,11 @@ fn err(e: impl std::fmt::Display) -> BakeError { impl Gpu { fn new() -> Result { - let instance = wgpu::Instance::new(wgpu::InstanceDescriptor::new_without_display_handle_from_env()); - let options = wgpu::RequestAdapterOptions { power_preference: wgpu::PowerPreference::HighPerformance, ..Default::default() }; - let adapter = pollster::block_on(instance.request_adapter(&options)).map_err(|e| format!("no GPU adapter: {e}"))?; - let info = adapter.get_info(); - if info.device_type == wgpu::DeviceType::Cpu { - return Err(format!("{} is a software renderer", info.name)); - } - let limits = adapter.limits(); - if limits.max_storage_buffers_per_shader_stage < 3 - || limits.max_compute_invocations_per_workgroup < WORKGROUP - || limits.max_compute_workgroup_size_x < WORKGROUP - { - return Err(format!("{} has no usable compute shaders", info.name)); - } + let (adapter, name, limits) = bake_adapter()?; let desc = wgpu::DeviceDescriptor { label: Some("tc_bake"), required_limits: limits, ..Default::default() }; let (device, queue) = pollster::block_on(adapter.request_device(&desc)).map_err(|e| format!("no GPU device: {e}"))?; - // Errors are caught by the scopes around every call; never let wgpu's default handler panic. + + // Each GPU call has an error scope so the default handler should leave failures to those scopes device.on_uncaptured_error(Arc::new(|_| {})); let (layout, transfer, hemisphere) = scoped(&device, "GPU baking: pipelines", || { let params = wgpu::BindingType::Buffer { @@ -112,7 +104,7 @@ impl Gpu { (layout, pipe("transfer_main"), pipe("hemisphere_main")) })?; let stride = size_of::().next_multiple_of(device.limits().min_uniform_buffer_offset_alignment.max(1) as usize); - Ok(Gpu { device, queue, name: info.name, layout, transfer, hemisphere, stride }) + Ok(Gpu { device, queue, name, layout, transfer, hemisphere, stride }) } /// The largest storage buffer this device binds. @@ -122,6 +114,43 @@ impl Gpu { } } +/// Whether the adapter selected for mesh-map baking supports its compute shaders. +pub fn raytracing_available() -> bool { + static SUPPORTED: OnceLock = OnceLock::new(); + *SUPPORTED.get_or_init(|| bake_adapter().is_ok()) +} + +fn bake_adapter() -> Result<(wgpu::Adapter, String, wgpu::Limits), String> { + let instance = wgpu::Instance::new(wgpu::InstanceDescriptor::new_without_display_handle_from_env()); + let options = wgpu::RequestAdapterOptions { power_preference: wgpu::PowerPreference::HighPerformance, ..Default::default() }; + let adapter = pollster::block_on(instance.request_adapter(&options)).map_err(|e| format!("no GPU adapter: {e}"))?; + let info = adapter.get_info(); + let limits = adapter.limits(); + let flags = adapter.get_downlevel_capabilities().flags; + if let Some(reason) = unsupported_adapter(info.device_type, flags, &limits) { + return Err(format!("{} {reason}", info.name)); + } + + Ok((adapter, info.name, limits)) +} + +fn unsupported_adapter(device_type: wgpu::DeviceType, flags: wgpu::DownlevelFlags, limits: &wgpu::Limits) -> Option<&'static str> { + if device_type == wgpu::DeviceType::Cpu { + return Some("is a software renderer"); + } + + if !flags.contains(wgpu::DownlevelFlags::COMPUTE_SHADERS) + || limits.max_storage_buffers_per_shader_stage < RAY_STORAGE_BUFFERS + || limits.max_compute_invocations_per_workgroup < WORKGROUP + || limits.max_compute_workgroup_size_x < WORKGROUP + || limits.max_compute_workgroup_storage_size < WORKGROUP_STORAGE_BYTES + { + return Some("has no usable compute shaders"); + } + + None +} + /// The GPU [`Tracer`]. Its device is created on the first bake; without a hardware adapter /// every bake reports [`BakeError::Tracer`] (and runs on the CPU). #[derive(Default)] @@ -383,6 +412,22 @@ mod tests { use super::*; + #[test] + fn raytracing_requires_hardware_and_compute_support() { + let limits = wgpu::Limits::default(); + let compute = wgpu::DownlevelFlags::COMPUTE_SHADERS; + let no_compute = wgpu::Limits { max_compute_workgroup_size_x: 0, ..limits.clone() }; + let three_buffers = wgpu::Limits { max_storage_buffers_per_shader_stage: 3, ..limits.clone() }; + let no_shared_memory = wgpu::Limits { max_compute_workgroup_storage_size: 0, ..limits.clone() }; + + assert!(unsupported_adapter(wgpu::DeviceType::DiscreteGpu, compute, &limits).is_none()); + assert!(unsupported_adapter(wgpu::DeviceType::Cpu, compute, &limits).is_some()); + assert!(unsupported_adapter(wgpu::DeviceType::IntegratedGpu, wgpu::DownlevelFlags::empty(), &limits).is_some()); + assert!(unsupported_adapter(wgpu::DeviceType::IntegratedGpu, compute, &no_compute).is_some()); + assert!(unsupported_adapter(wgpu::DeviceType::IntegratedGpu, compute, &three_buffers).is_some(), "the bind group requires four storage buffers"); + assert!(unsupported_adapter(wgpu::DeviceType::IntegratedGpu, compute, &no_shared_memory).is_some()); + } + /// The GPU baker, or None (test skipped) without a hardware adapter. fn gpu() -> Option { let g = GpuBaker::new(); diff --git a/crates/ui-egui/src/bake_mode/live_preview.rs b/crates/ui-egui/src/bake_mode/live_preview.rs index 06394cb6..c76f9001 100644 --- a/crates/ui-egui/src/bake_mode/live_preview.rs +++ b/crates/ui-egui/src/bake_mode/live_preview.rs @@ -97,7 +97,11 @@ pub(crate) fn map_settings_shown(app: &TextureCraftApp) -> Option Option { - map_settings_shown(app).filter(|_| app.ui.bake_visualization.map_preview && app.bake.is_none()) + if !app.ui.prefs.live_preview_baking || !app.ui.bake_visualization.map_preview || app.bake.is_some() { + return None; + } + + map_settings_shown(app) } /// A slider dragged in Mesh Map Settings changed a setting: a running drag bake finishes and shows before the newest value bakes, so pictures keep coming while the slider moves diff --git a/crates/ui-egui/src/control.rs b/crates/ui-egui/src/control.rs index 6d14942b..8359fbe9 100644 --- a/crates/ui-egui/src/control.rs +++ b/crates/ui-egui/src/control.rs @@ -9,7 +9,7 @@ //! - `ui.menu.list`: the menu catalog with ids, shortcuts and whether each is live. //! - `ui.menu.invoke {id}`: behave like a menu click (may open a window; `ui.resetUi` asks first). //! `{id: "ui.layout.apply", name}` switches to the saved panel layout `name` (an error when there is none). -//! - `ui.reset`: reset the panels and every view setting at once, without the question the menu asks. +//! - `ui.reset`: reset the panels, view settings and interface language at once, without the question the menu asks. //! - `ui.set {...}`: merge fields into the UI state (e.g. `{"layout":"Only3D"}`). //! - `viewport.screenshot {view?: "3d"|"2d"}`: PNG of a viewport, base64. //! - `ui.screenshot`: PNG of the whole window (replies after the next frame). @@ -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, ); } @@ -255,7 +261,7 @@ pub fn handle(app: &mut TextureCraftApp, ctx: &egui::Context, method: &str, para // What Window > Reset UI does once the question is answered with Reset "ui.reset" => { - app.ui.adopt_layout(crate::UiState::default()); + app.ui.reset_ui(); ok(Value::Null) } "ui.set" => { diff --git a/crates/ui-egui/src/display_settings.rs b/crates/ui-egui/src/display_settings.rs index 945fa8c5..837e3c98 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), }); @@ -254,9 +254,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/keymap.rs b/crates/ui-egui/src/keymap.rs index 47d6548d..7d9be266 100644 --- a/crates/ui-egui/src/keymap.rs +++ b/crates/ui-egui/src/keymap.rs @@ -3,6 +3,7 @@ //! the shortcut editor window (Help ▸ Shortcuts list) and the Edit ▸ Settings ▸ Shortcuts page. use std::collections::BTreeMap; +use std::sync::OnceLock; use crate::shortcut_dispatch::Dispatcher; use craft_keymap::{Active, Chord, CommandDef, CommandRef, ConflictKind, KeyInput, Layout, Lookup, Mods, Overrides, Platform, Scope, Scopes}; @@ -41,6 +42,22 @@ pub static NOT_AVAILABLE_ACTIONS: [(&str, Binding); 2] = [ ("viewport.frame", Binding { id: "ui.toggleAnimation", group: "Viewport", label: "Toggle animation", default: Some("Space") }), ]; +/// Shortcut reference rows shown before Reimport mesh. Their example keys stay available to bind. +pub const REFERENCE_ACTIONS: [Binding; 7] = [ + Binding { id: "ui.manipulator.toggle", group: "Viewport", label: "Toggle transform handles", default: Some("Q") }, + Binding { id: "ui.manipulator.grow", group: "Viewport", label: "Enlarge transform handles", default: None }, + Binding { id: "ui.manipulator.shrink", group: "Viewport", label: "Shrink transform handles", default: Some("-") }, + Binding { id: "ui.manipulator.space", group: "Viewport", label: "Switch transform coordinate space", default: Some("T") }, + Binding { id: "ui.warpEdit", group: "Viewport", label: "Toggle warp editing", default: Some("Shift+V") }, + Binding { id: "ui.manipulator.translate", group: "Viewport", label: "Move with transform handles", default: Some("W") }, + Binding { id: "ui.manipulator.rotate", group: "Viewport", label: "Rotate with transform handles", default: Some("E") }, +]; + +fn unavailable_before(id: &str) -> impl Iterator + '_ { + let reference = if id == "file.reimportMesh" { REFERENCE_ACTIONS.as_slice() } else { &[] }; + reference.iter().chain(NOT_AVAILABLE_ACTIONS.iter().filter(move |(before, _)| *before == id).map(|(_, row)| row)) +} + /// The shortcut list's first rows, in the reference's order. The `>` and `<` of the reference are /// the shifted Period and Comma keys. const LISTED_SHORTCUTS: &[ShortcutListEntry] = &[ @@ -222,14 +239,15 @@ pub struct Bindings { stored: Keymap, map: craft_keymap::Keymap, dispatcher: Dispatcher, + conflicts: OnceLock>, } impl Default for Bindings { fn default() -> 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::default() } + + Bindings { stored, map, dispatcher: Dispatcher::default(), conflicts: OnceLock::new() } } } @@ -239,6 +257,7 @@ impl Bindings { if self.stored != *keymap || self.map.platform() != platform { self.stored = keymap.clone(); self.map = resolved(keymap, platform); + self.conflicts.take(); } } @@ -275,14 +294,22 @@ impl Bindings { matches!(self.map.lookup(&Chord::new(Mods::SHIFT, key), false, &Active::NONE), Lookup::None) } - /// Another binding on the same shortcut as `b`. - fn conflict(&self, b: &Binding) -> Option<&'static Binding> { + /// The first conflicting action for each shortcut, computed only when an editor needs it. + fn conflicts(&self) -> &BTreeMap<&'static str, &'static Binding> { + self.conflicts.get_or_init(|| bindings().iter().filter_map(|binding| self.find_conflict(binding).map(|other| (binding.id, other))).collect()) + } + + fn conflict(&self, binding: &Binding) -> Option<&'static Binding> { + self.conflicts().get(binding.id).copied() + } + + fn find_conflict(&self, b: &Binding) -> Option<&'static Binding> { let clash = self.map.conflicts_with(&CommandRef::new(b.id)).into_iter().find(|c| c.kind == ConflictKind::Clash); if let Some(clash) = clash { return bindings().iter().find(|x| x.id == clash.b.0.id); } - // The rows the reference lists and TextureCraft cannot run yet still own their keys + // Keep the existing reserved shortcuts for paused computation and animation let mine = parse(shortcut(&self.stored, b)?)?; NOT_AVAILABLE_ACTIONS.iter().map(|(_, row)| row).find(|row| row.default.and_then(parse) == Some(mine)) } @@ -369,7 +396,7 @@ pub fn shown(text: &str) -> &str { /// Whether the shortcuts in `edited` (kept in step with the working copy) have an item that /// shares its shortcut with another. pub(crate) fn has_conflict(edited: &Bindings) -> bool { - bindings().iter().any(|b| edited.conflict(b).is_some()) + !edited.conflicts().is_empty() } /// Follow `keymap` with the checker of the Settings window. @@ -399,6 +426,7 @@ pub(crate) fn actions_page(ui: &mut egui::Ui, keymap: &mut Keymap, recorder: &Bi } capture = None; } + follow(edited, keymap, &ctx); let cell = |ui: &mut egui::Ui, width: f32, add: &mut dyn FnMut(&mut egui::Ui)| { @@ -408,7 +436,6 @@ pub(crate) fn actions_page(ui: &mut egui::Ui, keymap: &mut Keymap, recorder: &Bi }); }; - // A pencil that cannot be used yet let locked_pencil = |ui: &mut egui::Ui, action: &str| { let edit = trf("Edit the shortcut of {item}", &[("item", &tr(action))]); ui.add_enabled_ui(false, |ui| icon_button(ui, ic::PENCIL_SIMPLE, &edit, false, 20.0)).inner.on_disabled_hover_text(tr(NOT_AVAILABLE)); @@ -428,9 +455,10 @@ pub(crate) fn actions_page(ui: &mut egui::Ui, keymap: &mut Keymap, recorder: &Bi ui.label(caption(tr("Actions"))); ui.add_space(4.0); for (i, b) in bindings().iter().enumerate() { - for (_, row) in NOT_AVAILABLE_ACTIONS.iter().filter(|(before, _)| *before == b.id) { + for row in unavailable_before(b.id) { locked_row(ui, row.label, row.default.unwrap_or("")); } + let waiting = capture == Some(i); ui.horizontal(|ui| { cell(ui, 300.0, &mut |ui| { @@ -485,8 +513,8 @@ pub(crate) fn actions_page(ui: &mut egui::Ui, keymap: &mut Keymap, recorder: &Bi }); } -/// 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. +/// The first key press this frame as a shortcut, including Escape routed to the window's cancel. +/// Keep the press's modifiers so only plain Escape cancels recording. fn pressed(ctx: &egui::Context, bindings: &Bindings) -> Option { let platform = craft_keymap::egui::platform(ctx); let press = ctx.input(|i| { @@ -495,7 +523,14 @@ fn pressed(ctx: &egui::Context, bindings: &Bindings) -> Option _ => None, }) }); - press.or_else(|| crate::framework::take_window_cancel(ctx).then(|| KeyboardShortcut::new(Modifiers::NONE, Key::Escape))) + + press.or_else(|| { + crate::framework::take_window_cancel(ctx).then(|| { + let modifiers = craft_ui::runtime::keys::escape_mods(ctx).unwrap_or(Mods::NONE); + + Chord::new(modifiers, craft_keymap::Key::Escape).to_egui_shortcut() + }) + }) } /// The shortcut editor window. @@ -519,6 +554,7 @@ pub fn window(app: &mut TextureCraftApp, ctx: &egui::Context) { } capture = None; } + app.bindings.sync(&app.ui.keymap, craft_keymap::egui::platform(ctx)); let mut filter: String = ctx.data(|d| d.get_temp(filter_id)).unwrap_or_default(); let mut open = true; @@ -532,7 +568,7 @@ pub fn window(app: &mut TextureCraftApp, ctx: &egui::Context) { } }); }); - let clashes = bindings().iter().filter(|b| app.bindings.conflict(b).is_some()).count(); + let clashes = app.bindings.conflicts().len(); if clashes > 0 { ui.label( RichText::new(format!("{} {}", ic::WARNING, trf("{n} items share a shortcut; the first one listed wins.", &[("n", &clashes)]))) @@ -544,7 +580,7 @@ pub fn window(app: &mut TextureCraftApp, ctx: &egui::Context) { egui::ScrollArea::vertical().max_height(420.0).auto_shrink([false, true]).show(ui, |ui| { egui::Grid::new("keymap_grid").num_columns(3).striped(true).spacing(vec2(10.0, 4.0)).show(ui, |ui| { for (i, b) in bindings().iter().enumerate() { - for (_, row) in NOT_AVAILABLE_ACTIONS.iter().filter(|(before, _)| *before == b.id) { + for row in unavailable_before(b.id) { let key = row.default.unwrap_or(""); if !needle.is_empty() && ![row.label, row.group, tr(row.label), tr(row.group), key].iter().any(|t| t.to_lowercase().contains(&needle)) { continue; @@ -558,6 +594,7 @@ pub fn window(app: &mut TextureCraftApp, ctx: &egui::Context) { ui.add_enabled(false, button).on_disabled_hover_text(tr(NOT_AVAILABLE)); ui.end_row(); } + let current = shortcut(&app.ui.keymap, b); let current_text = current.map(shown); if !needle.is_empty() diff --git a/crates/ui-egui/src/lib.rs b/crates/ui-egui/src/lib.rs index fe331a26..f5eb990d 100644 --- a/crates/ui-egui/src/lib.rs +++ b/crates/ui-egui/src/lib.rs @@ -400,11 +400,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(), } } @@ -1120,7 +1117,7 @@ const BAKE_POLL_INTERVAL: std::time::Duration = std::time::Duration::from_millis /// 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; @@ -1391,7 +1388,23 @@ pub fn data_folder(pref: &str) -> std::path::PathBuf { std::path::Path::new(&home).join("Documents").join("TextureCraft") } -/// The data folder in use: the Nightly profile when this is one, else Settings › Folders › Data folder. +/// An absolute preview cache override, or the app's default under the user's cache directory. +#[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(); + } + + let cache = if has_data_root() { + data_dir().join("cache") + } else { + craft_update::Paths::per_user(UPDATE_APP.id).map_or_else(|_| data_dir().join("cache"), |paths| paths.cache) + }; + cache.join("previews") +} + +/// The Nightly profile's data folder, or the folder chosen in Settings › Files. #[cfg(not(target_arch = "wasm32"))] pub fn data_dir() -> std::path::PathBuf { if let Some(root) = DATA_ROOT.get() { @@ -1400,7 +1413,7 @@ 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 88d73912..f1bf6713 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; @@ -59,7 +59,6 @@ pub(crate) fn show(app: &mut TextureCraftApp, ctx: &egui::Context) { #[cfg(not(target_arch = "wasm32"))] let mut pick = None; let project_open = app.session.project_open; - let gpu = app.render_state.as_ref().map(|render_state| render_state.adapter.get_info().name); // A language whose script no font draws is listed by its English name and disabled let drawable = LANGUAGES.each_ref().map(|l| crate::fonts::Script::of_language(l.code).is_none_or(|s| app.fonts.covers(s))); @@ -80,16 +79,14 @@ pub(crate) fn show(app: &mut TextureCraftApp, ctx: &egui::Context) { .show(ctx, |ui| { // Measure the footer through layout, then let the pages use only what remains ui.with_layout(egui::Layout::bottom_up(egui::Align::Min), |ui| { - // Recheck after drawing the page as well, before accepting any edits - let conflict = crate::keymap::has_conflict(&app.settings_bindings); ui.horizontal(|ui| { - if conflict { + if shortcut_conflict { let danger = Tokens::get(ui.ctx()).danger; ui.label(RichText::new(format!("{} {}", ic::WARNING, tr(SHORTCUT_ERRORS))).color(danger)); } ui.with_layout(egui::Layout::right_to_left(egui::Align::Center), |ui| { cancel = ui.add(egui::Button::new(tr("Cancel")).min_size(vec2(100.0, 0.0))).clicked(); - ok = ui.add_enabled(!conflict, egui::Button::new(tr("OK")).min_size(vec2(100.0, 0.0))).clicked(); + ok = ui.add_enabled(!shortcut_conflict, egui::Button::new(tr("OK")).min_size(vec2(100.0, 0.0))).clicked(); }); }); ui.separator(); @@ -125,7 +122,6 @@ pub(crate) fn show(app: &mut TextureCraftApp, ctx: &egui::Context) { ui, &mut draft.prefs, &drawable, - gpu.as_deref(), #[cfg(not(target_arch = "wasm32"))] resources, #[cfg(not(target_arch = "wasm32"))] @@ -152,7 +148,8 @@ pub(crate) fn show(app: &mut TextureCraftApp, ctx: &egui::Context) { }); }); - ok &= !crate::keymap::has_conflict(&app.settings_bindings); + // The Shortcuts page can introduce a conflict after the footer was drawn + let ok = ok && !crate::keymap::has_conflict(&app.settings_bindings); app.ui.windows.settings_page = draft.page; if draft.page != SettingsPage::Shortcuts || ok || cancel || !open { crate::keymap::stop_settings_capture(ctx); @@ -175,7 +172,8 @@ fn apply(app: &mut TextureCraftApp, draft: SettingsDraft) { let libraries_changed = draft.prefs.libraries != app.ui.prefs.libraries; let previous_autosave_minutes = app.ui.prefs.autosave_minutes; - app.ui.prefs = draft.prefs; + // Display Settings can change the texture resolution while this draft is open + app.ui.prefs = Prefs { viewport_texture: app.ui.prefs.viewport_texture, ..draft.prefs }; app.ui.trim_recent(); app.reschedule_autosave_if_changed(previous_autosave_minutes); @@ -274,9 +272,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. @@ -301,71 +307,97 @@ fn speed_slider(ui: &mut Ui, label: &str, value: &mut f32, width: f32) -> Respon .inner } -/// Whether the Baking options say there is no GPU to trace rays on: no adapter, or the browser. +/// Whether the platform or a missing adapter name rules out GPU baking. +/// The Settings control also checks the bake adapter's compute capabilities. 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_supports_raytracing: bool, stored: bool) -> (bool, bool) { + let supported = adapter_supports_raytracing && !cfg!(target_arch = "wasm32"); + (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, - p: &mut Prefs, + prefs: &mut Prefs, drawable: &[bool], - gpu: Option<&str>, #[cfg(not(target_arch = "wasm32"))] (available_cores, available_ram_bytes): (u32, u64), #[cfg(not(target_arch = "wasm32"))] pick: &mut Option, ) { let tk = Tokens::get(ui.ctx()); section(ui, n_("INTERFACE OPTIONS")); row(ui, tr("Language"), |ui, label| { - let selected = if p.language == SYSTEM_LANGUAGE { + let selected = if prefs.language == SYSTEM_LANGUAGE { tr("Default (System Language)") } else { - LANGUAGES.iter().find(|l| l.code == p.language).map_or(tr("Default (System Language)"), |l| l.name) + LANGUAGES.iter().find(|l| l.code == prefs.language).map_or(tr("Default (System Language)"), |l| l.name) }; egui::ComboBox::from_id_salt("settings_language") .width(CONTROL_WIDTH) .height(320.0) .selected_text(selected) .show_ui(ui, |ui| { - ui.selectable_value(&mut p.language, SYSTEM_LANGUAGE.to_owned(), tr("Default (System Language)")); + ui.selectable_value(&mut prefs.language, SYSTEM_LANGUAGE.to_owned(), tr("Default (System Language)")); for (l, ok) in LANGUAGES.iter().zip(drawable).filter(|(l, _)| crate::i18n::available(l.code)) { - let item = egui::Button::selectable(l.code == p.language, if *ok { l.name } else { l.english }); + let item = egui::Button::selectable(l.code == prefs.language, if *ok { l.name } else { l.english }); if ui.add_enabled(*ok, item).on_disabled_hover_text(tr("No font on this system can show this language")).clicked() { - p.language = l.code.to_owned(); + prefs.language = l.code.to_owned(); } } }) .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 prefs.show_keyboard_helper)); + row(ui, tr("Show world axes"), |ui, label| check(ui, label, &mut prefs.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}"); - crate::widgets::color_swatch(ui, &id, &mut p.background[index], 38.0); + crate::widgets::color_swatch(ui, &id, &mut prefs.background[index], 38.0); - // The reference shows no tooltip here; the name is only for screen readers + // Give the eyedropper an accessible name without adding a tooltip let label = trf("Pick the {overlay} Color from the Screen", &[("overlay", &name)]); - crate::screen_color_pick::eyedropper_without_tooltip(ui, ui.make_persistent_id(&id), &mut p.background[index], &label, 18.0); + crate::screen_color_pick::eyedropper_without_tooltip(ui, ui.make_persistent_id(&id), &mut prefs.background[index], &label, 18.0); 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 prefs.only_selected_material_when_painting)); + ui.small(tr("The keyboard helper and selected-material view preferences are saved for future use.")); 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, - ) + 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")); @@ -385,9 +417,11 @@ fn general( let speed_width = CONTROL_WIDTH + 12.0; ui.horizontal(|ui| { ui.add_space(12.0); - speed_slider(ui, tr("Rotation speed"), &mut p.rotation_speed, speed_width); + speed_slider(ui, tr("Rotation speed"), &mut prefs.rotation_speed, speed_width); }); - for (label, speed, inverse) in [(tr("Zoom speed"), &mut p.zoom_speed, &mut p.zoom_inverse), (tr("Wheel speed"), &mut p.wheel_speed, &mut p.wheel_inverse)] { + for (label, speed, inverse) in + [(tr("Zoom speed"), &mut prefs.zoom_speed, &mut prefs.zoom_inverse), (tr("Wheel speed"), &mut prefs.wheel_speed, &mut prefs.wheel_inverse)] + { ui.horizontal(|ui| { ui.add_space(12.0); speed_slider(ui, label, speed, speed_width); @@ -397,14 +431,25 @@ 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 prefs.save_preprocessed_scene_files); + ui.small(tr("The preprocessed scene file preference is saved for future use.")); + text_check(ui, n_("Enable live preview baking process"), &mut prefs.live_preview_baking); + + #[cfg(not(target_arch = "wasm32"))] + let gpu_bake_supported = texturecraft_render::gpu_bake::raytracing_available(); + #[cfg(target_arch = "wasm32")] + let gpu_bake_supported = false; + let (gpu_raytracing_enabled, mut gpu_raytracing_ticked) = gpu_raytracing_check(gpu_bake_supported, prefs.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() { + prefs.gpu_raytracing = gpu_raytracing_ticked; + } }); - if gpu_note_shown(gpu) { + if !gpu_raytracing_enabled { ui.horizontal(|ui| { ui.add_space(12.0); ui.label(RichText::new(tr(GPU_RAYTRACING_UNAVAILABLE)).color(tk.danger)); @@ -413,12 +458,32 @@ 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 prefs.local_cache_directory).hint_text(default).desired_width(CONTROL_WIDTH - 24.0)).labelled_by(label); + 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() { + prefs.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); not_available(ui.add(egui::Button::new("R").frame(false))); }); }); + + #[cfg(not(target_arch = "wasm32"))] + ui.small(tr("The local cache directory is saved for future use.")); + row(ui, tr("Local cache budget (in MB)"), |ui, label| { let mut budget = 4000_u32; ui.spacing_mut().item_spacing.x = 2.0; @@ -431,7 +496,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,145 +507,74 @@ fn general( not_available(ui.add(egui::Button::new("R").frame(false))); }); }); + #[cfg(not(target_arch = "wasm32"))] + row(ui, tr("Data folder"), |ui, label| { + // The launcher fixes the Nightly data folder before the app starts + if crate::has_data_root() { + ui.label(RichText::new(crate::data_dir().display().to_string()).small().color(tk.text_dim)) + .labelled_by(label) + .on_hover_text(tr("TextureCraft Nightly keeps its data in its own profile.")); + return; + } + + let default = crate::data_folder("").display().to_string(); + ui.add(egui::TextEdit::singleline(&mut prefs.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); + } + }); 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| { - 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"))] { 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(prefs.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() { + prefs.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 prefs.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); - let budget_bytes = texturecraft_engine::formats::save_ram_budget(available_ram_bytes, p.save_ram_percent); + ui.add(egui::Slider::new(&mut prefs.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, prefs.save_ram_percent); ui.label(format!("≈ {:.2} GiB", budget_bytes as f64 / (1_u64 << 30) as f64)); }); } row(ui, tr("Max project size on open"), |ui, label| { - ui.add(egui::DragValue::new(&mut p.project_open_limit_gib).range(1..=u32::MAX).suffix(" GiB")) + ui.add(egui::DragValue::new(&mut prefs.project_open_limit_gib).range(1..=u32::MAX).suffix(" GiB")) .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 prefs.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"))] { section(ui, n_("AUTOSAVE")); 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); + ui.add(egui::DragValue::new(&mut prefs.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| { - // A Nightly install keeps every folder inside its own profile (the Launcher picks it), - // so the Setting would be ignored: show where they are instead of editing it. - if crate::has_data_root() { - ui.label(RichText::new(crate::data_dir().display().to_string()).small().color(tk.text_dim)); - return; - } - 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, - if crate::has_data_root() { - tr("TextureCraft Nightly keeps its autosaves, smart materials, presets, templates and UI layouts in its own profile, beside its settings.") - } else { - 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)> { @@ -807,6 +801,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 b16d6e66..11be5a36 100644 --- a/crates/ui-egui/src/state.rs +++ b/crates/ui-egui/src/state.rs @@ -170,7 +170,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). + /// Percentage of free RAM available to a project save on desktop (0 to 100). + /// A stored zero uses the minimum budget of 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. @@ -190,6 +191,21 @@ 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. + pub live_preview_baking: bool, + /// Settings > Preview options > Local cache directory (desktop). Empty or relative uses the + /// app's default cache directory. Stored only until TextureCraft has a preview cache. + pub local_cache_directory: String, } /// The orbit speed the built-in navigation runs at. @@ -203,7 +219,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(), @@ -221,6 +237,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(), } } } @@ -721,6 +743,12 @@ impl UiState { self.rail_panel = None; } + /// Reset the workspace and return the interface to the system language. + pub(crate) fn reset_ui(&mut self) { + self.adopt_layout(Self::default()); + self.prefs.language.clear(); + } + /// Take `layout`'s panels, windows and view settings, keeping this state's dialogs, settings, files and shelf query pub fn adopt_layout(&mut self, layout: UiState) { let keep = std::mem::replace(self, layout); diff --git a/crates/ui-egui/src/viewport.rs b/crates/ui-egui/src/viewport.rs index 08e9e9eb..4c1fe3c7 100644 --- a/crates/ui-egui/src/viewport.rs +++ b/crates/ui-egui/src/viewport.rs @@ -414,9 +414,10 @@ fn set_highlight(ui: &Ui, texture_set: usize) -> SetHighlight { /// Show what the GPU side reported (each message once while its toast is up). fn gpu_report_toasts(app: &mut TextureCraftApp, reports: crate::gpu::GpuReports) { let names: Vec = reports.memory.iter().filter_map(|ts| app.session.doc.project.texture_sets.get(*ts).map(|t| t.name.clone())).collect(); + if !names.is_empty() { - // One sticky notice for every set the GPU could not hold (they are not retried, so the - // notice stays until dismissed); after a dismissal, a new one names only the new sets. + // Failed allocations are not retried, so keep a notice until the user dismisses it + // Start a new list on the first failure after dismissal let (sets, shown) = &mut app.gpu_memory; let current = shown.take().filter(|text| app.toasts.iter().any(|t| &t.text == text)); match ¤t { @@ -430,7 +431,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 => { @@ -443,7 +444,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)], ) } @@ -1157,7 +1158,10 @@ 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/src/windows.rs b/crates/ui-egui/src/windows.rs index 368eeea2..398c3871 100644 --- a/crates/ui-egui/src/windows.rs +++ b/crates/ui-egui/src/windows.rs @@ -41,7 +41,7 @@ pub(crate) fn reset_ui_keys(app: &mut TextureCraftApp, input: &mut egui::InputSt if input.consume_key(egui::Modifiers::NONE, egui::Key::Escape) { app.ui.windows.confirm_reset_ui = false; } else if nothing_focused && input.consume_key(egui::Modifiers::NONE, egui::Key::Enter) { - app.ui.adopt_layout(crate::UiState::default()); + app.ui.reset_ui(); app.ui.windows.confirm_reset_ui = false; } } @@ -54,7 +54,7 @@ fn reset_ui(app: &mut TextureCraftApp, ctx: &egui::Context) { let mut open = true; let (mut reset, mut cancel) = (false, false); dialog(ctx, "reset_ui", tr("Reset UI"), &mut open).show(ctx, |ui| { - ui.label(tr("Reset the panels, view layout, zoom and every other view setting to their defaults? Settings and shortcuts stay.")); + ui.label(tr("Reset the panels, view settings and interface language to their defaults? Other preferences and shortcuts stay.")); ui.add_space(8.0); // One row keeps the window to its contents; a bare right-to-left layout fills the screen height @@ -67,7 +67,7 @@ fn reset_ui(app: &mut TextureCraftApp, ctx: &egui::Context) { }); if reset { - app.ui.adopt_layout(crate::UiState::default()); + app.ui.reset_ui(); } if reset || cancel || !open { app.ui.windows.confirm_reset_ui = false; diff --git a/crates/ui-egui/tests/it/bake_live_preview.rs b/crates/ui-egui/tests/it/bake_live_preview.rs index 4c7d6c7c..839bbc75 100644 --- a/crates/ui-egui/tests/it/bake_live_preview.rs +++ b/crates/ui-egui/tests/it/bake_live_preview.rs @@ -105,6 +105,31 @@ fn switching_the_preview_off_hides_it() { assert!(!harness.state().session.bake_preview_active()); } +#[test] +fn disabling_live_preview_in_preferences_releases_the_picture_and_can_be_reenabled() { + let mut harness = harness(); + + for resolution in [BakeResolution::R256, BakeResolution::R128] { + let state = harness.state_mut(); + state.ui.bake_visualization.map_preview_size = resolution; + state.ui.prefs.live_preview_baking = true; + + assert!(wait_for_preview(&mut harness, |size| size == resolution.pixels()).is_some()); + let pixels = &harness.state().session.bake_preview_baked(0).unwrap().maps[&BakedMap::AmbientOcclusion]; + let picture = std::sync::Arc::downgrade(pixels); + let bytes = pixels.len() * std::mem::size_of::(); + + harness.state_mut().ui.prefs.live_preview_baking = false; + harness.run_steps(3); + + let remaining_owners = picture.strong_count(); + eprintln!("preview resolution: {resolution:?}, published bytes: {bytes}, owners after disabling: {remaining_owners}"); + assert!(!harness.state().session.bake_preview_active()); + assert_eq!(remaining_owners, 0, "disabling the preview releases its image"); + assert_ne!(harness.state().session.view, texturecraft_engine::ViewMode::MeshMap(BakedMap::AmbientOcclusion)); + } +} + #[test] fn pictures_keep_coming_while_the_slider_is_still_moving() { let mut harness = harness(); diff --git a/crates/ui-egui/tests/it/reset_ui.rs b/crates/ui-egui/tests/it/reset_ui.rs index 445993f4..66593d24 100644 --- a/crates/ui-egui/tests/it/reset_ui.rs +++ b/crates/ui-egui/tests/it/reset_ui.rs @@ -16,6 +16,7 @@ fn changed_app() -> Harness<'static, TextureCraftApp> { .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; ui.dock.close(Panel::Assets); ui.layout = ViewLayout::Only3D; @@ -63,30 +64,37 @@ fn reset_ui_asks_first_and_cancel_changes_nothing() { #[test] fn reset_ui_ok_resets_everything_as_before() { let mut h = changed_app(); + invoke(&mut h, "ui.resetUi"); h.get_by_label("Reset").click(); h.run_steps(2); + let ui = &h.state().ui; assert!(!ui.windows.confirm_reset_ui); assert!(ui.dock.is_open(Panel::Assets)); assert_eq!((ui.layout, ui.uv_zoom, ui.mesh_wireframe, ui.mode), (ViewLayout::Split, 1.0, false, Mode::Painting)); + assert_eq!(ui.prefs.language, texturecraft_ui_egui::i18n::SYSTEM_LANGUAGE); } #[test] fn reset_ui_escape_keeps_everything_and_enter_resets() { let mut h = changed_app(); + invoke(&mut h, "ui.resetUi"); h.key_press(Key::Escape); h.run_steps(2); + assert!(!h.state().ui.windows.confirm_reset_ui); assert!(view_kept(&h) && !h.state().ui.dock.is_open(Panel::Assets)); invoke(&mut h, "ui.resetUi"); h.key_press(Key::Enter); h.run_steps(2); + assert!(!h.state().ui.windows.confirm_reset_ui); assert!(h.state().ui.dock.is_open(Panel::Assets)); assert_eq!(h.state().ui.layout, ViewLayout::Split); + assert_eq!(h.state().ui.prefs.language, texturecraft_ui_egui::i18n::SYSTEM_LANGUAGE); } #[test] @@ -105,13 +113,16 @@ fn the_menu_invoke_command_asks_first_like_a_click() { fn the_ui_reset_control_command_resets_without_asking() { let mut h = changed_app(); let ctx = h.ctx.clone(); + let reply = texturecraft_ui_egui::control::handle(h.state_mut(), &ctx, "ui.reset", &serde_json::Value::Null); h.run_steps(2); + assert!(reply.get("error").is_none(), "{reply}"); let ui = &h.state().ui; assert!(!ui.windows.confirm_reset_ui, "no question for a script"); assert!(ui.dock.is_open(Panel::Assets)); assert_eq!((ui.layout, ui.uv_zoom, ui.mesh_wireframe, ui.mode), (ViewLayout::Split, 1.0, false, Mode::Painting)); + assert_eq!(ui.prefs.language, texturecraft_ui_egui::i18n::SYSTEM_LANGUAGE); } #[test] diff --git a/crates/ui-egui/tests/it/settings_window.rs b/crates/ui-egui/tests/it/settings_window.rs index df1b1d06..78e8b4e2 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}; @@ -87,47 +89,174 @@ 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(); + + // Keep the app in English while the draft displays first-run defaults + 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_ne!(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, "the default follows the system language"); assert_eq!((prefs.rotation_speed, prefs.zoom_speed, prefs.wheel_speed), (2.0, 1.0, 1.0)); } +#[test] +fn confirming_settings_keeps_a_texture_resolution_chosen_in_display_settings() { + let mut h = harness(texturecraft_engine::sample_session(128, 32).unwrap()); + let old_display = h.state().session.doc.project.display.clone(); + let ctx = h.ctx.clone(); + menus::invoke(h.state_mut(), &ctx, "ui.view.display"); + h.run_steps(4); + + let by_width = |left: &egui_kittest::Node<'_>, right: &egui_kittest::Node<'_>| left.rect().width().total_cmp(&right.rect().width()); + h.get_all_by_label("Render settings").max_by(by_width).unwrap().scroll_to_me(); + h.run_steps(3); + h.get_all_by_label("Render settings").max_by(by_width).unwrap().click(); + h.run_steps(10); + open_settings(&mut h); + + click(&mut h, "Half"); + assert_eq!(h.state().ui.prefs.viewport_texture, 1, "Display Settings applies the resolution immediately"); + click(&mut h, "OK"); + + assert_eq!(h.state().ui.prefs.viewport_texture, 1, "Settings leaves the Display Settings choice in place"); + assert_eq!(h.state().session.doc.project.display, old_display, "viewport resolution is an app preference"); +} + +#[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", "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"] { + 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").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); + let after_right = ram_percent(&h); + press_key(&mut h, Key::ArrowLeft); + press_key(&mut h, Key::ArrowLeft); + 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] +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); + let typed = stored(&h); + click(&mut h, "R, Reset to the default folder"); + let reset = stored(&h); + + assert_eq!(typed, folder); + assert!(reset.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}"); @@ -142,7 +271,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"); } @@ -154,10 +282,13 @@ 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"); + assert!(!h.state().ui.windows.settings && h.state().ui.windows.settings_draft.is_none(), "Cancel closes the window"); assert_eq!(h.state().ui.prefs, before, "Cancel drops the edits"); @@ -167,21 +298,26 @@ fn cancel_drops_the_changes_and_ok_applies_and_keeps_them() { Some(f64::from(before.autosave_minutes)), "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); + + // 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"); let mut storage = MemoryStorage::default(); @@ -437,16 +573,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(true, true), (with_gpu, with_gpu), "supported hardware keeps it on and checkable"); + assert_eq!(gpu_raytracing_check(true, false), (with_gpu, false), "supported hardware shows the stored choice"); + assert_eq!(gpu_raytracing_check(false, true), (false, false), "without support 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 baker selects its own adapter independently of the window 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 = texturecraft_render::gpu_bake::raytracing_available(); + + 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"); } #[test] diff --git a/crates/ui-egui/tests/it/shortcut_list.rs b/crates/ui-egui/tests/it/shortcut_list.rs index 88a92296..a3cf2641 100644 --- a/crates/ui-egui/tests/it/shortcut_list.rs +++ b/crates/ui-egui/tests/it/shortcut_list.rs @@ -4,7 +4,7 @@ use egui::{Event, Key, Modifiers, Role}; use egui_kittest::Harness; use egui_kittest::kittest::{NodeT, Queryable}; use serde_json::json; -use texturecraft_ui_egui::keymap::{NOT_AVAILABLE_ACTIONS, bindings}; +use texturecraft_ui_egui::keymap::{NOT_AVAILABLE_ACTIONS, REFERENCE_ACTIONS, bindings}; use texturecraft_ui_egui::{TextureCraftApp, menus}; fn harness() -> Harness<'static, TextureCraftApp> { @@ -32,8 +32,9 @@ fn no_two_default_shortcuts_are_the_same() { } } for (_, row) in &NOT_AVAILABLE_ACTIONS { - let key = row.default.unwrap(); - assert!(!seen.contains_key(key), "{} shows {key}, which another item has", row.label); + if let Some(key) = row.default { + assert_eq!(seen.insert(key, row.id), None, "{key} is reserved for {} and another item", row.label); + } } } @@ -45,7 +46,7 @@ fn the_settings_page_disables_editing_shortcuts_for_unavailable_actions() { h.run_steps(4); h.get_by_role_and_label(Role::Tab, "Shortcuts").click(); h.run_steps(4); - for (_, row) in &NOT_AVAILABLE_ACTIONS { + for row in NOT_AVAILABLE_ACTIONS.iter().map(|(_, row)| row).chain(&REFERENCE_ACTIONS) { let action = row.label; h.get_by_label(action).scroll_to_me(); h.run_steps(3); @@ -86,3 +87,74 @@ 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 recording_shift_escape_warns_that_the_key_is_reserved() { + 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); + h.get_by_label("Edit the shortcut of Save project").click(); + h.run_steps(4); + + press(&mut h, Key::Escape, Modifiers::SHIFT); + + assert!(h.query_by_label_contains("One or several errors").is_some(), "Shift+Escape is reserved for Pause Engine Computation"); + assert!(h.get_by_label("OK").accesskit_node().is_disabled()); +} + +#[test] +fn a_saved_shortcut_on_a_reference_key_does_not_block_settings() { + let mut h = harness(); + h.state_mut().ui.keymap.insert("ui.hideUi".into(), "Q".into()); + + let ctx = h.ctx.clone(); + menus::invoke(h.state_mut(), &ctx, "ui.settings"); + h.run_steps(4); + h.get_by_label("OK").click(); + h.run_steps(3); + + assert!(!h.state().ui.windows.settings, "an existing shortcut must not prevent confirming Settings"); + assert_eq!(h.state().ui.keymap.get("ui.hideUi").map(String::as_str), Some("Q")); +} + +#[test] +fn the_standalone_shortcut_editor_lists_the_reference_keys() { + let mut harness = harness(); + let context = harness.ctx.clone(); + let windows = texturecraft_ui_egui::state::Windows { shortcuts: true, ..Default::default() }; + + let reply = texturecraft_ui_egui::control::handle(harness.state_mut(), &context, "ui.set", &json!({"windows": windows})); + harness.run_steps(4); + + assert_eq!(reply["ok"], true); + assert!(harness.query_by_label("Toggle transform handles").is_some()); + assert!(harness.get_by_role_and_label(Role::Button, "Q").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...", + "Toggle transform handles", + "Enlarge transform handles", + "Shrink transform handles", + "Switch transform coordinate space", + "Toggle warp editing", + "Move with transform handles", + "Rotate with transform handles", + "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 f9626b4b..42fe417d 100644 --- a/crates/ui-egui/tests/project_limits.rs +++ b/crates/ui-egui/tests/project_limits.rs @@ -12,6 +12,7 @@ use memory_storage::MemoryStorage; fn resource_settings_follow_hardware_persist_and_apply_before_control_requests() { let legacy: Prefs = serde_json::from_str("{}").unwrap(); assert_eq!(legacy.project_open_limit_gib, 8); + let mut state = UiState::default(); state.prefs.language = "en".into(); state.prefs.project_open_limit_gib = 16; @@ -19,6 +20,7 @@ fn resource_settings_follow_hardware_persist_and_apply_before_control_requests() state.windows.settings = true; let mut storage = MemoryStorage::default(); 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() @@ -37,17 +39,20 @@ 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"); harness.get_by_role_and_label(egui::Role::SpinButton, "Max project size on open").set_value_accesskit(24.0); harness.run_steps(3); assert_eq!(formats::project_open_limit_gib(), 16, "an edit waits for OK"); + harness.get_by_label("OK").click(); harness.run_steps(3); assert_eq!(formats::project_open_limit_gib(), 24, "OK applies the edited value"); @@ -58,6 +63,7 @@ fn resource_settings_follow_hardware_persist_and_apply_before_control_requests() assert_eq!(reply["ok"], true, "{reply}"); assert_eq!(formats::project_open_limit_gib(), 32, "no frame is needed before the next command"); + harness.state_mut().save(&mut storage); let restored: UiState = serde_json::from_str(&storage.values["ui.json"]).unwrap(); assert_eq!(restored.prefs.project_open_limit_gib, 32); diff --git a/crates/ui-egui/tests/ui_snapshots.rs b/crates/ui-egui/tests/ui_snapshots.rs index d78b23db..8c779749 100644 --- a/crates/ui-egui/tests/ui_snapshots.rs +++ b/crates/ui-egui/tests/ui_snapshots.rs @@ -89,6 +89,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 441ecbbc..9053c4e3 100644 --- a/docs/control-protocol.md +++ b/docs/control-protocol.md @@ -240,7 +240,7 @@ keeps its state in a throwaway file. | `ui.menu.invoke` id `ui.saveAsTemplate` | `{id}` | File > More Save Options > Save As Template opens a save dialog in the user templates folder. The choice supplies the file path and template name to `project.template.save`. `ui.saveReduced` (Save and Reduce File Size) is listed as not implemented and not enabled | | `ui.menu.invoke` ids `ui.help.releaseNotes`, `ui.help.showLog`, `ui.help.exportLog` | `{id}` | Help > Release Notes opens the releases page in the browser; Help > Show Log opens the current desktop run's rolling `log.txt` in the system text-file handler; Help > Export Log exports the session log with each entry’s recorded UTC time, severity and source (a save dialog on desktop with a `Log_TextureCraft____.txt` name, a download on the web) | | `ui.menu.invoke` id `ui.wireframe` | `{id}` | Show mesh wireframe: shows or hides the mesh wireframe in the 3D and 2D views (the Display Settings check box). It has no menu entry and no default key; bind it in Settings > Shortcuts. The key bindings `camera.next` and `camera.previous` (Select next camera `>`, Select previous camera `<`) and `ui.mode.bake` (F8) run the same commands as before | -| `ui.reset` | | resets the panels, view layout, zoom and every other view setting at once, without the question the Reset UI menu item asks; settings and shortcuts stay | +| `ui.reset` | | resets the panels, view settings and interface language without asking for confirmation. Other preferences and shortcuts stay | | `ui.bake.start` | `{ts?: index \| [indices]}` (default: the sets ticked in Bake mode) | Opens Bake mode and bakes in the background like the Bake button: the 3D view shows the maps landing on the model as they finish (see *Live bake preview*). → the `bake.preview` state. Errors when a bake is already running | | `ui.bake.cancel` | | Stops the running bake; the set being baked keeps the maps it had, sets already finished stay applied, and the previous view mode comes back | | `ui.set` | fields of the UI state, e.g. `{"layout": "Only3D"}`; `dock` is the panel layout, a craft-ui docking `Workspace` (`{version, layout: {root, floating}, hidden}`; `root` is a tree of `Split`, `Tabs` and `Stack` nodes over the panels `Viewport`, `Assets`, `TextureSetList`, `Layers`, `TextureSetSettings`, `Properties`, `Display`, `Shader`, `History`, `Log`, `BakingLog`, `MeshMapBakers`, `BakeMaps`, `BakeSettings`, `Export` and `Renderer` (a floating window holding one right-bar panel is that panel undocked); `hidden` lists where each closed panel was, so reopening it puts it back; a layout that does not read or has no docked `Viewport` becomes the default), `prefs` the settings (`{"language": "ja", "viewport_texture": 1, "brightness": "light", "accent": "blue"}`; missing fields take their defaults; `brightness` is `dark`, `mediumDark` (default), `mediumLight` or `light`, `accent` `copper` (default), `coral`, `blue`, `violet`, `green`, `amber` or `pink`, applied on the next frame; `system_title_bar` `true` has the system draw the title bar from the next start), `keymap` the custom shortcuts (`{"file.save": "F5"}`, `""` unbinds), `log_channel` the Log panel's tab (`General` or `Assets`) | `null` | @@ -254,6 +254,7 @@ The empty-project menus keep Recent Projects openable with Clear disabled when t `ui.recent.clear` clears that list. More Save Options is disabled until a project is open. Help > Shortcuts list opens Settings on its Shortcuts page. Window > Reset UI restores the Assets, Layers, Properties, Texture Set List and Texture Set Settings panels and both toolbars. +It also restores Default (System Language). Baking Log and the bake/render settings views are disabled without a project. Import resources can open its dialog on desktop without a project; importing still requires an open project, and the dialog explains that asset-library import is not available yet. @@ -339,10 +340,16 @@ 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). `live_preview_baking` enables +the automatic Bake mode map preview when the panel's Map Preview switch is also on. +`show_keyboard_helper`, `only_selected_material_when_painting`, `save_preprocessed_scene_files` and +`local_cache_directory` are stored preferences for future use. For `local_cache_directory`, an +empty or relative path selects the app's per-user cache directory, or the profile cache for Nightly. 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 520ff678..3b58b176 100644 --- a/docs/features.md +++ b/docs/features.md @@ -254,10 +254,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. @@ -277,14 +277,16 @@ 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, with `Documents/TextureCraft` as + the default). Nightly shows its fixed profile path in the same row. - 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 (worker threads, cores kept for the UI, RAM while saving, project size on open) and the autosave - interval. Shortcuts rebinds any command in the sections Actions, Mouse shortcuts and Modifiers shortcuts (Delete clears a binding, a shared shortcut warns and keeps OK disabled, Reset all to default restores every key); the window reopens on the page it was closed on. Libraries adds or removes folders whose saved smart + interval. Reset UI restores the system language. The General page also controls the automatic + Bake mode map preview. Shortcuts rebinds any command in the sections Actions, Mouse shortcuts and Modifiers shortcuts (Delete clears a binding, a shared shortcut warns and keeps OK disabled, Reset all to default restores every key); the window reopens on the page it was closed on. Libraries adds or removes folders whose saved smart materials and masks the shelf lists. -- The **shortcut list** (Settings › Shortcuts and Help › Shortcuts list) names the actions as the reference does and starts with its default keys (Switch to baking mode Ctrl+Shift+B, Select next and previous camera `>` and `<`, Viewers layout F1 to F4); Show mesh wireframe is a bindable command. +- The **shortcut list** (Settings › Shortcuts and Help › Shortcuts list) names the actions as the reference does and starts with its default keys (Switch to baking mode F8, Select next and previous camera `>` and `<`, Viewers layout F1 to F4); Show mesh wireframe is a bindable command. - A **shortcut editor** with conflict detection, listing every menu item and every command a key can run (commands that need a path, name or similar are left out), and every shortcut shown in its tooltip. - **Help menu:** Release notes... opens the project's releases page. Export log... writes every channel to a text file with each entry's recorded UTC time, severity and source. The desktop app asks diff --git a/docs/ui-parity.md b/docs/ui-parity.md index 1e45c49d..7c074f95 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 defaults to on when the native bake adapter supports its compute shaders. Unsupported hardware and the browser show it off and disabled ([#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) and the Local cache directory are editable preferences saved for future use. R restores the default per-user cache path or the Nightly profile cache path. Enable live preview baking process (on) controls the automatic Bake mode map preview when the panel's Map Preview switch is also on. 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" F8, "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". Seven unavailable transform and warp actions follow "Export Textures...". Their example keys can still be bound to working commands. 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 Baking options when GPU baking is unavailable. The reference's TEMPORARY FILES section is called FILES and also holds the Data folder. Stable installations can edit the path. Nightly shows the fixed profile path. 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 @@ -189,7 +189,7 @@ list, not a feature-completion denominator. | F09 Generator editing | UI | Pass | Layer context menu added a generator to that mask. Selecting Position and dragging Global balance changed the mask/viewport; inspection recorded balance about 0.279 | | F10 Duplicate an effect | UI | Pass | Ctrl+D produced a separate Generator copy with the same parameters and a Duplicate effect history step | | F11 UV rectangle fill | UI | Pass | Tool 4, UV-island mode and a rectangle across two UV islands wrote 88 tiles per painted channel on a new paint layer. Undo removed that fill. Topology was visible in the tool | -| F12 Bake from the UI | UI | Pass | F8 (now Ctrl+Shift+B), 256 px, low mesh used as high mesh, Check All and Bake completed all ten map types. The UI log reported CPU execution; this is separate from the GPU command check | +| F12 Bake from the UI | UI | Pass | F8, 256 px, low mesh used as high mesh, Check All and Bake completed all ten map types. The UI log reported CPU execution; this is separate from the GPU command check | | F13 Texture-export flow | UI + accessibility text entry | Pass | Inspected Settings, Output templates and List of exports, then clicked Export. Eight 1024 px PNGs decoded successfully; all eight were byte-identical to command exports from the same saved project/options. The base-color output was inspected visually. Template creation/editing was not exercised | | F14 Save and reopen | Mixed | Pass within scope | Ctrl+S and the native Save As dialog saved four layers, two generator effects, 21 painted tiles per channel and ten 256 px baked maps. Reopening through `file.open` matched inspected layers, texture sets and mesh. This was not a complete keyboard-only open-dialog test | | F15 Smaller window | Scripted resize + UI inspection | Partial | 1280 × 800 rendered with working layout structure; the readability limits are UI-13. No full task suite at that size |