PhotoCraft: An open-source, photo editor written by scratch in pure Rust
Layers panel: Clip Thumbnails to Layer Bounds (#4281) (#4312)
badaaif4fb866942c94
diff --git a/crates/engine/src/prefs.rs b/crates/engine/src/prefs.rsindex f5f31c11e..17c6a47df 100644--- a/crates/engine/src/prefs.rs+++ b/crates/engine/src/prefs.rs@@ -272,6 +272,9 @@ pub struct Interface {pub dynamic_color_sliders: bool,/// Draw menu item colours set with Edit › Menus.pub show_menu_colors: bool,+ /// Layers panel thumbnails frame the layer's own pixels instead of the whole canvas, so small+ /// objects in a large document stay visible (Photoshop's Clip Thumbnails to Layer Bounds; #4281).+ pub clip_thumbnails_to_layer_bounds: bool,pub show_tooltips: bool,/// Menus, popups and collapsing sections fade and slide, and scroll areas glide to a new/// position. Off, everything changes at once (a reduced-motion mode; #1218, #3273).@@ -309,6 +312,7 @@ impl Default for Interface {show_channels_in_color: false,dynamic_color_sliders: true,show_menu_colors: true,+ clip_thumbnails_to_layer_bounds: false,show_tooltips: true,enable_animations: true,show_bounding_box_when_dragging_layer: false,diff --git a/crates/ui-egui/src/i18n/cs.tsv b/crates/ui-egui/src/i18n/cs.tsvindex fa4be01a7..4d651a097 100644--- a/crates/ui-egui/src/i18n/cs.tsv+++ b/crates/ui-egui/src/i18n/cs.tsv@@ -1907,6 +1907,8 @@Camera Raw Defaults Výchozí nastavení Camera RawCanvas border Okraj plátnaShow canvas dots Zobrazit tečky plátna+ Clip thumbnails to layer bounds Oříznout miniatury na hranice vrstvy+ Clip Thumbnails to Layer Bounds Oříznout miniatury na hranice vrstvyCanvas color Barva plátnaCanvas custom color Vlastní barva plátnaColor picker Výběr barvydiff --git a/crates/ui-egui/src/i18n/de.tsv b/crates/ui-egui/src/i18n/de.tsvindex 2421904e2..b1d214b15 100644--- a/crates/ui-egui/src/i18n/de.tsv+++ b/crates/ui-egui/src/i18n/de.tsv@@ -1881,6 +1881,8 @@Camera Raw Defaults Camera-Raw-StandardeinstellungenCanvas border ZeichenflächenrandShow canvas dots Punkte der Zeichenfläche anzeigen+ Clip thumbnails to layer bounds Miniaturbilder auf Ebenenbegrenzung beschneiden+ Clip Thumbnails to Layer Bounds Miniaturbilder auf Ebenenbegrenzung beschneidenCanvas color ZeichenflächenfarbeCanvas custom color Benutzerdefinierte ZeichenflächenfarbeColor picker Farbwählerdiff --git a/crates/ui-egui/src/i18n/el.tsv b/crates/ui-egui/src/i18n/el.tsvindex 01009641e..6bc441d0e 100644--- a/crates/ui-egui/src/i18n/el.tsv+++ b/crates/ui-egui/src/i18n/el.tsv@@ -1655,6 +1655,8 @@Camera Raw Defaults Προεπιλογές Camera RawCanvas border Περίγραμμα καμβάShow canvas dots Εμφάνιση κουκκίδων καμβά+ Clip thumbnails to layer bounds Περικοπή μικρογραφιών στα όρια του επιπέδου+ Clip Thumbnails to Layer Bounds Περικοπή μικρογραφιών στα όρια του επιπέδουCanvas color Χρώμα καμβάCanvas custom color Προσαρμοσμένο χρώμα καμβάColor picker Επιλογέας χρώματοςdiff --git a/crates/ui-egui/src/i18n/es.tsv b/crates/ui-egui/src/i18n/es.tsvindex d37295184..aa947f228 100644--- a/crates/ui-egui/src/i18n/es.tsv+++ b/crates/ui-egui/src/i18n/es.tsv@@ -1894,6 +1894,8 @@Camera Raw Defaults Valores predeterminados de Camera RawCanvas border Borde del lienzoShow canvas dots Mostrar puntos del lienzo+ Clip thumbnails to layer bounds Recortar miniaturas a los límites de la capa+ Clip Thumbnails to Layer Bounds Recortar miniaturas a los límites de la capaCanvas color Color del lienzoCanvas custom color Color personalizado del lienzoColor picker Selector de colordiff --git a/crates/ui-egui/src/i18n/fr.tsv b/crates/ui-egui/src/i18n/fr.tsvindex 547411e9a..d597d4444 100644--- a/crates/ui-egui/src/i18n/fr.tsv+++ b/crates/ui-egui/src/i18n/fr.tsv@@ -1863,6 +1863,8 @@Camera Raw Defaults Valeurs par défaut de Camera RawCanvas border Bordure du canevasShow canvas dots Afficher les points du canevas+ Clip thumbnails to layer bounds Rogner les vignettes aux limites du calque+ Clip Thumbnails to Layer Bounds Rogner les vignettes aux limites du calqueCanvas color Couleur du canevasCanvas custom color Couleur personnalisée du canevasColor picker Sélecteur de couleursdiff --git a/crates/ui-egui/src/i18n/hu.tsv b/crates/ui-egui/src/i18n/hu.tsvindex d6d33ec2d..ded1a41a0 100644--- a/crates/ui-egui/src/i18n/hu.tsv+++ b/crates/ui-egui/src/i18n/hu.tsv@@ -3534,6 +3534,8 @@ cameraRaw Yellow Sárgashortcut billentyűparancsShortcut BillentyűparancsShow canvas dots Vászonpontok megjelenítése+ Clip thumbnails to layer bounds Bélyegképek levágása a réteg határaira+ Clip Thumbnails to Layer Bounds Bélyegképek levágása a réteg határairaShow channels in color Csatornák megjelenítése színesenShow crosshair in brush tip Szálkereszt az ecsethegybenShow extension panels Bővítménypanelek megjelenítésediff --git a/crates/ui-egui/src/i18n/id.tsv b/crates/ui-egui/src/i18n/id.tsvindex b1652dd9e..1f9e9f555 100644--- a/crates/ui-egui/src/i18n/id.tsv+++ b/crates/ui-egui/src/i18n/id.tsv@@ -1857,6 +1857,8 @@Camera Raw Defaults Default Camera RawCanvas border Border kanvasShow canvas dots Tampilkan titik kanvas+ Clip thumbnails to layer bounds Pangkas thumbnail ke batas layer+ Clip Thumbnails to Layer Bounds Pangkas Thumbnail ke Batas LayerCanvas color Warna kanvasCanvas custom color Warna kustom kanvasColor picker Pemilih warnadiff --git a/crates/ui-egui/src/i18n/it.tsv b/crates/ui-egui/src/i18n/it.tsvindex e410c2af3..85313e7c6 100644--- a/crates/ui-egui/src/i18n/it.tsv+++ b/crates/ui-egui/src/i18n/it.tsv@@ -1889,6 +1889,8 @@Camera Raw Defaults Predefiniti Camera RawCanvas border Bordo quadroShow canvas dots Mostra punti del quadro+ Clip thumbnails to layer bounds Ritaglia le miniature ai limiti del livello+ Clip Thumbnails to Layer Bounds Ritaglia le miniature ai limiti del livelloCanvas color Colore quadroCanvas custom color Colore personalizzato quadroColor picker Selettore colorediff --git a/crates/ui-egui/src/i18n/ja.tsv b/crates/ui-egui/src/i18n/ja.tsvindex 1d0865132..19ae9575e 100644--- a/crates/ui-egui/src/i18n/ja.tsv+++ b/crates/ui-egui/src/i18n/ja.tsv@@ -1891,6 +1891,8 @@Camera Raw Defaults Camera Raw の既定値Canvas border カンバスの境界Show canvas dots カンバスのドットを表示+ Clip thumbnails to layer bounds サムネールをレイヤーの境界でクリップ+ Clip Thumbnails to Layer Bounds サムネールをレイヤーの境界でクリップCanvas color カンバスの色Canvas custom color カンバスのカスタム色Color picker カラーピッカーdiff --git a/crates/ui-egui/src/i18n/ko.tsv b/crates/ui-egui/src/i18n/ko.tsvindex e199608b9..2371720eb 100644--- a/crates/ui-egui/src/i18n/ko.tsv+++ b/crates/ui-egui/src/i18n/ko.tsv@@ -1857,6 +1857,8 @@Camera Raw Defaults Camera Raw 기본값Canvas border 캔버스 테두리Show canvas dots 캔버스 점 표시+ Clip thumbnails to layer bounds 썸네일을 레이어 경계로 자르기+ Clip Thumbnails to Layer Bounds 썸네일을 레이어 경계로 자르기Canvas color 캔버스 색상Canvas custom color 캔버스 사용자 정의 색상Color picker 색상 피커diff --git a/crates/ui-egui/src/i18n/nl.tsv b/crates/ui-egui/src/i18n/nl.tsvindex 9ac977446..a6ba4b854 100644--- a/crates/ui-egui/src/i18n/nl.tsv+++ b/crates/ui-egui/src/i18n/nl.tsv@@ -1863,6 +1863,8 @@Camera Raw Defaults Standaardwaarden Camera RawCanvas border CanvasrandShow canvas dots Canvasstippen tonen+ Clip thumbnails to layer bounds Miniaturen bijsnijden tot laaggrenzen+ Clip Thumbnails to Layer Bounds Miniaturen bijsnijden tot laaggrenzenCanvas color CanvaskleurCanvas custom color Aangepaste canvaskleurColor picker Kleurkiezerdiff --git a/crates/ui-egui/src/i18n/pl.tsv b/crates/ui-egui/src/i18n/pl.tsvindex 016e564eb..ae92d2152 100644--- a/crates/ui-egui/src/i18n/pl.tsv+++ b/crates/ui-egui/src/i18n/pl.tsv@@ -1885,6 +1885,8 @@Camera Raw Defaults Domyślne ustawienia Camera RawCanvas border Obramowanie płótnaShow canvas dots Pokaż kropki płótna+ Clip thumbnails to layer bounds Przycinaj miniatury do granic warstwy+ Clip Thumbnails to Layer Bounds Przycinaj miniatury do granic warstwyCanvas color Kolor płótnaCanvas custom color Własny kolor płótnaColor picker Próbnik kolorówdiff --git a/crates/ui-egui/src/i18n/pt-br.tsv b/crates/ui-egui/src/i18n/pt-br.tsvindex 154fd3010..10176e31e 100644--- a/crates/ui-egui/src/i18n/pt-br.tsv+++ b/crates/ui-egui/src/i18n/pt-br.tsv@@ -1858,6 +1858,8 @@Camera Raw Defaults Padrões do Camera RawCanvas border Borda da tela de pinturaShow canvas dots Mostrar pontos da tela de pintura+ Clip thumbnails to layer bounds Recortar miniaturas aos limites da camada+ Clip Thumbnails to Layer Bounds Recortar miniaturas aos limites da camadaCanvas color Cor da tela de pinturaCanvas custom color Cor personalizada da tela de pinturaColor picker Seletor de coresdiff --git a/crates/ui-egui/src/i18n/ru.tsv b/crates/ui-egui/src/i18n/ru.tsvindex 6466c415c..f74b9f485 100644--- a/crates/ui-egui/src/i18n/ru.tsv+++ b/crates/ui-egui/src/i18n/ru.tsv@@ -2304,6 +2304,8 @@Camera Raw Defaults Значения Camera Raw по умолчаниюCanvas border Рамка холстаShow canvas dots Показывать точки холста+ Clip thumbnails to layer bounds Обрезать миниатюры по границам слоя+ Clip Thumbnails to Layer Bounds Обрезать миниатюры по границам слояCanvas color Цвет холстаCanvas custom color Свой цвет холстаClassic Классическаяdiff --git a/crates/ui-egui/src/i18n/sr.tsv b/crates/ui-egui/src/i18n/sr.tsvindex aa5923532..9aebfe1f5 100644--- a/crates/ui-egui/src/i18n/sr.tsv+++ b/crates/ui-egui/src/i18n/sr.tsv@@ -1842,6 +1842,8 @@Camera Raw Defaults Podrazumevana Camera Raw podešavanjaCanvas border Ivica platnaShow canvas dots Prikaži tačke na platnu+ Clip thumbnails to layer bounds Iseci sličice prema granicama sloja+ Clip Thumbnails to Layer Bounds Iseci sličice prema granicama slojaCanvas color Boja platnaCanvas custom color Prilagođena boja platnaColor picker Birač bojadiff --git a/crates/ui-egui/src/i18n/tr.tsv b/crates/ui-egui/src/i18n/tr.tsvindex 08be1125a..d6076ec35 100644--- a/crates/ui-egui/src/i18n/tr.tsv+++ b/crates/ui-egui/src/i18n/tr.tsv@@ -1839,6 +1839,8 @@Camera Raw Defaults Camera Raw VarsayılanlarıCanvas border Kanvas kenarlığıShow canvas dots Kanvas noktalarını göster+ Clip thumbnails to layer bounds Küçük resimleri katman sınırlarına kırp+ Clip Thumbnails to Layer Bounds Küçük resimleri katman sınırlarına kırpCanvas color Kanvas rengiCanvas custom color Kanvas özel rengiColor picker Renk seçicidiff --git a/crates/ui-egui/src/i18n/uk.tsv b/crates/ui-egui/src/i18n/uk.tsvindex 98e0c6ff4..7255c24f1 100644--- a/crates/ui-egui/src/i18n/uk.tsv+++ b/crates/ui-egui/src/i18n/uk.tsv@@ -2277,6 +2277,8 @@Camera Raw Defaults Типові параметри Camera RawCanvas border Межа полотнаShow canvas dots Показувати крапки полотна+ Clip thumbnails to layer bounds Обрізати мініатюри до меж шару+ Clip Thumbnails to Layer Bounds Обрізати мініатюри до меж шаруCanvas color Колір полотнаCanvas custom color Довільний колір полотнаClassic Класичнаdiff --git a/crates/ui-egui/src/i18n/vi.tsv b/crates/ui-egui/src/i18n/vi.tsvindex 3857c4431..d6a82f203 100644--- a/crates/ui-egui/src/i18n/vi.tsv+++ b/crates/ui-egui/src/i18n/vi.tsv@@ -2661,6 +2661,8 @@ shape Appearance Diện mạoBrush preview color Màu xem trước cọCache levels Mức bộ nhớ đệmShow canvas dots Hiện chấm vùng vẽ+ Clip thumbnails to layer bounds Cắt hình thu nhỏ theo biên của lớp+ Clip Thumbnails to Layer Bounds Cắt hình thu nhỏ theo biên của lớpColor picker Bộ chọn màuColor space Không gian màuColumn width Độ rộng cộtdiff --git a/crates/ui-egui/src/i18n/zh-hans.tsv b/crates/ui-egui/src/i18n/zh-hans.tsvindex ad3f2204d..d912da2c5 100644--- a/crates/ui-egui/src/i18n/zh-hans.tsv+++ b/crates/ui-egui/src/i18n/zh-hans.tsv@@ -1904,6 +1904,8 @@Camera Raw Defaults Camera Raw 默认设置Canvas border 画布边框Show canvas dots 显示画布圆点+ Clip thumbnails to layer bounds 将缩略图裁剪到图层边界+ Clip Thumbnails to Layer Bounds 将缩略图裁剪到图层边界Canvas color 画布颜色Canvas custom color 画布自定颜色Color picker 拾色器diff --git a/crates/ui-egui/src/i18n/zh-hant.tsv b/crates/ui-egui/src/i18n/zh-hant.tsvindex 9330c7426..a92587214 100644--- a/crates/ui-egui/src/i18n/zh-hant.tsv+++ b/crates/ui-egui/src/i18n/zh-hant.tsv@@ -1897,6 +1897,8 @@Camera Raw Defaults Camera Raw 預設值Canvas border 畫布邊框Show canvas dots 顯示畫布圓點+ Clip thumbnails to layer bounds 將縮圖裁切至圖層邊界+ Clip Thumbnails to Layer Bounds 將縮圖裁切至圖層邊界Canvas color 畫布顏色Canvas custom color 畫布自訂顏色Color picker 檢色器diff --git a/crates/ui-egui/src/layer_row_ui.rs b/crates/ui-egui/src/layer_row_ui.rsindex 7ac725a7c..5a6e60f79 100644--- a/crates/ui-egui/src/layer_row_ui.rs+++ b/crates/ui-egui/src/layer_row_ui.rs@@ -203,6 +203,16 @@ pub fn panel_menu(app: &mut crate::PhotocraftApp, ui: &mut egui::Ui) {}ui.close();}+ ui.separator();+ // Photoshop's Clip Thumbnails to Layer Bounds: frame each layer's pixels, not the canvas (#4281).+ let mut clip = app.session.prefs().interface.clip_thumbnails_to_layer_bounds;+ if crate::widgets::checkbox(ui, &mut clip, tl!("Clip Thumbnails to Layer Bounds")).changed() {+ if let Err(e) = app.run("prefs.set", json!({"path": "interface.clipThumbnailsToLayerBounds", "value": clip})) {+ app.ui.status = e;+ app.ui.status_error = true;+ }+ ui.close();+ }}fn rects_id() -> egui::Id {diff --git a/crates/ui-egui/src/layer_thumb_bounds_tests.rs b/crates/ui-egui/src/layer_thumb_bounds_tests.rsnew file mode 100644index 000000000..66ea820cd--- /dev/null+++ b/crates/ui-egui/src/layer_thumb_bounds_tests.rs@@ -0,0 +1,75 @@+//! #4281: Clip Thumbnails to Layer Bounds. A small object in a large document fills its Layers+//! panel thumbnail instead of being a speck in an empty canvas-sized one.++use egui::vec2;+use egui_kittest::Harness;+use photocraft_doc::LayerId;+use photocraft_geom::Rect;+use serde_json::json;++use crate::PhotocraftApp;+use crate::mask_thumbs_ui::THUMB_LAYER;++fn harness() -> (Harness<'static, PhotocraftApp>, u64) {+ let mut s = photocraft_engine::Session::new();+ s.execute("file.new", json!({"width": 2000, "height": 1000})).unwrap();+ let id = s.execute("layer.new.layer", json!({"name": "Speck"})).unwrap()["layer"].as_u64().unwrap();+ s.execute("select.rect", json!({"x": 100, "y": 200, "width": 20, "height": 10})).unwrap();+ s.execute("edit.fill", json!({"color": "#ff0000"})).unwrap();+ s.execute("select.deselect", json!({})).unwrap();+ let mut h = Harness::builder().with_size(vec2(1440.0, 1000.0)).with_max_steps(64).build_eframe(move |cc| {+ PhotocraftApp::setup_context(&cc.egui_ctx, Default::default());+ PhotocraftApp::new(s, crate::Services::default())+ });+ let ctx = h.ctx.clone();+ let (req, _rx) = crate::control::ControlRequest::new("ui.set", json!({"dockTabs": {"layers": 0}}));+ crate::control::handle(h.state_mut(), &ctx, &req);+ h.run_steps(8);+ (h, id)+}++fn frame(h: &Harness<'_, PhotocraftApp>, id: u64) -> Rect {+ *h.state().thumb_frames.get(&LayerId(id)).expect("layer thumbnail drawn")+}++fn texture_area(h: &Harness<'_, PhotocraftApp>, id: u64) -> usize {+ let (_, tex) = h.state().thumbs.get(&(LayerId(id), THUMB_LAYER)).expect("layer thumbnail drawn");+ let [w, h] = tex.size();+ w * h+}++#[test]+fn layer_thumbnails_frame_the_canvas_by_default() {+ let (h, id) = harness();+ assert!(!h.state().session.prefs().interface.clip_thumbnails_to_layer_bounds);+ assert_eq!(frame(&h, id), Rect::new(0, 0, 2000, 1000));+}++#[test]+fn clipped_layer_thumbnails_frame_the_layer_pixels() {+ let (mut h, id) = harness();+ let before = h.state().thumbs.get(&(LayerId(id), THUMB_LAYER)).map(|(r, _)| *r).unwrap();+ h.state_mut().run("prefs.set", json!({"path": "interface.clipThumbnailsToLayerBounds", "value": true})).unwrap();+ h.run_steps(4);+ assert_eq!(frame(&h, id), Rect::new(100, 200, 120, 210), "framed on the filled rect");+ let after = h.state().thumbs.get(&(LayerId(id), THUMB_LAYER)).map(|(r, _)| *r).unwrap();+ assert_ne!(before, after, "toggling the preference rebuilds the thumbnail");+ assert_eq!(texture_area(&h, id), 64 * 64, "still a 64 px square texture");++ h.state_mut().run("prefs.set", json!({"path": "interface.clipThumbnailsToLayerBounds", "value": false})).unwrap();+ h.run_steps(4);+ assert_eq!(frame(&h, id), Rect::new(0, 0, 2000, 1000), "and back to the canvas");+}++#[test]+fn empty_and_off_canvas_layers_keep_the_canvas_frame() {+ let canvas = Rect::new(0, 0, 50, 40);+ let raster = photocraft_raster::Surface::new(photocraft_color::PixelFormat::RGBA8);+ let mut empty = photocraft_doc::Layer::new("Empty", photocraft_doc::LayerContent::Raster(raster));+ assert_eq!(crate::layer_thumb_frame(&empty, canvas, true), canvas);+ empty.surface_mut().unwrap().write_pixel(-10, -10, &[1.0, 0.0, 0.0, 1.0]);+ assert_eq!(crate::layer_thumb_frame(&empty, canvas, true), canvas, "pixels only off the canvas");+ empty.surface_mut().unwrap().write_pixel(45, 5, &[1.0, 0.0, 0.0, 1.0]);+ assert_eq!(crate::layer_thumb_frame(&empty, canvas, true), Rect::new(0, 0, 46, 6), "the layer bounds, cut to the canvas");+ assert_eq!(crate::layer_thumb_frame(&empty, canvas, false), canvas);+}diff --git a/crates/ui-egui/src/lib.rs b/crates/ui-egui/src/lib.rsindex 1bc1eb56f..5e7ab5e87 100644--- a/crates/ui-egui/src/lib.rs+++ b/crates/ui-egui/src/lib.rs@@ -624,6 +624,9 @@ pub struct PhotocraftApp {pub fps: f32,last_frame_time: f64,thumbs: HashMap<(photocraft_doc::LayerId, u8), (u64, egui::TextureHandle)>,+ /// The document area each layer thumbnail in `thumbs` frames (the canvas, or the layer's+ /// bounds with Clip Thumbnails to Layer Bounds; #4281).+ thumb_frames: HashMap<photocraft_doc::LayerId, photocraft_geom::Rect>,/// History snapshot thumbnails by (document, snapshot id): a snapshot never changes, so each/// is made once (`snapshot_thumb`, #2966).snapshot_thumbs: HashMap<(DocId, u64), egui::TextureHandle>,@@ -829,6 +832,7 @@ impl PhotocraftApp {fps: 0.0,last_frame_time: 0.0,thumbs: HashMap::new(),+ thumb_frames: HashMap::new(),snapshot_thumbs: HashMap::new(),thumb_documents: Vec::new(),bounds_cache: HashMap::new(),@@ -2084,6 +2088,7 @@ impl PhotocraftApp {// Native files can restore IDs: retain the union across all open documents, rather// than deleting an ID just because one document containing it was closed.self.thumbs.retain(|key, _| live.contains(key));+ self.thumb_frames.retain(|id, _| live.contains(&(*id, mask_thumbs_ui::THUMB_LAYER)));}self.thumb_documents = documents.iter().map(|st| (st.doc.id, std::sync::Arc::downgrade(&st.doc))).collect();}@@ -2109,25 +2114,31 @@ impl PhotocraftApp {self.checker = None;}- /// Cached 64px thumbnail of a pixel-ish layer, laid out in document space.- pub fn layer_thumb(&mut self, ctx: &egui::Context, doc: &Document, layer: &photocraft_doc::Layer) -> egui::TextureId {+ /// Cached 64px thumbnail of a pixel-ish layer, letterboxed in a square, and the document+ /// area it frames: the canvas, or with Clip Thumbnails to Layer Bounds the layer's pixels.+ pub fn layer_thumb(&mut self, ctx: &egui::Context, doc: &Document, layer: &photocraft_doc::Layer) -> (egui::TextureId, photocraft_geom::Rect) {+ let clip = self.session.prefs().interface.clip_thumbnails_to_layer_bounds;// Key by content, not document revision: COW tiles change pointer only when their pixels// change, so unrelated edits (e.g. painting another layer) don't rebuild this thumbnail.- let rev = layer.surface().map_or(0, surface_fingerprint) ^ (doc.size.width as u64) << 40;+ let rev = layer.surface().map_or(0, surface_fingerprint) ^ (doc.size.width as u64) << 40 ^ u64::from(clip) << 63;let key = (layer.id, mask_thumbs_ui::THUMB_LAYER);if let Some((r, tex)) = self.thumbs.get(&key)&& *r == rev+ && let Some(frame) = self.thumb_frames.get(&layer.id){- return tex.id();+ return (tex.id(), *frame);}+ let canvas = doc.bounds();+ let frame = layer_thumb_frame(layer, canvas, clip);let mut px = [0.0f32; 8];- let img = thumb_image(doc, 64, |x, y| {+ let img = thumb_image(frame, 64, |x, y| {let Some(s) = layer.surface() else { return [0.0; 4] };let n = s.channels();s.read_pixel(x, y, &mut px[..n]);photocraft_raster::to_rgba(&s.format(), &px[..n])});- self.store_thumb(ctx, key, rev, img)+ self.thumb_frames.insert(layer.id, frame);+ (self.store_thumb(ctx, key, rev, img), frame)}/// The History panel thumbnail of snapshot `snap` of document `doc` (#2966): its composite,@@ -2162,7 +2173,7 @@ impl PhotocraftApp {return tex.id();}let mut v = [0.0f32; 1];- let img = thumb_image(doc, 64, |x, y| {+ let img = thumb_image(doc.bounds(), 64, |x, y| {mask.surface.read_pixel(x, y, &mut v);[v[0], v[0], v[0], 1.0]});@@ -2201,9 +2212,20 @@ pub fn surface_fingerprint(s: &photocraft_raster::Surface) -> u64 {h}-/// Square thumbnail of the canvas area, letterboxed, sampling `f(x, y)` in document space.-fn thumb_image(doc: &Document, side: usize, mut f: impl FnMut(i32, i32) -> [f32; 4]) -> egui::ColorImage {- let (w, h) = (doc.size.width.max(1) as f32, doc.size.height.max(1) as f32);+/// The document area a layer thumbnail frames: the canvas, or with `clip` the layer's pixels on+/// it (the canvas again when it has none there, so an empty layer still shows the page shape).+fn layer_thumb_frame(layer: &photocraft_doc::Layer, canvas: photocraft_geom::Rect, clip: bool) -> photocraft_geom::Rect {+ if !clip {+ return canvas;+ }+ let bounds = layer.surface().map_or(photocraft_geom::Rect::EMPTY, photocraft_compose::bounds::content_bounds).intersect(&canvas);+ if bounds.is_empty() { canvas } else { bounds }+}++/// Square thumbnail of the document area `frame`, letterboxed, sampling `f(x, y)` in document+/// space.+fn thumb_image(frame: photocraft_geom::Rect, side: usize, mut f: impl FnMut(i32, i32) -> [f32; 4]) -> egui::ColorImage {+ let (w, h) = (frame.width().max(1) as f32, frame.height().max(1) as f32);let scale = w.max(h) / side as f32;let (ox, oy) = ((side as f32 - w / scale) / 2.0, (side as f32 - h / scale) / 2.0);let mut px = vec![egui::Color32::TRANSPARENT; side * side];@@ -2214,7 +2236,7 @@ fn thumb_image(doc: &Document, side: usize, mut f: impl FnMut(i32, i32) -> [f32;if dx < 0.0 || dy < 0.0 || dx >= w || dy >= h {continue;}- let c = f(dx as i32, dy as i32);+ let c = f(frame.x0.saturating_add(dx as i32), frame.y0.saturating_add(dy as i32));let q = |v: f32| (v.clamp(0.0, 1.0) * 255.0 + 0.5) as u8;px[ty * side + tx] = egui::Color32::from_rgba_unmultiplied(q(c[0]), q(c[1]), q(c[2]), q(c[3]));}@@ -2589,6 +2611,8 @@ mod blur_pins_tests;#[cfg(test)]mod move_outline_tests;+#[cfg(test)]+mod layer_thumb_bounds_tests;#[cfg(test)]mod mask_thumb_refresh_tests;diff --git a/crates/ui-egui/src/panels.rs b/crates/ui-egui/src/panels.rsindex 191001c39..45a49ebfa 100644--- a/crates/ui-egui/src/panels.rs+++ b/crates/ui-egui/src/panels.rs@@ -3022,10 +3022,11 @@ fn draw_layer_thumb(app: &mut PhotocraftApp, ctx: &egui::Context, ui: &egui::Ui,_ => {// Keep row layout and outside thumbnail decorations when the image is clipped.if ui.is_rect_visible(rect) {- // The texture is a letterboxed square: draw only the part the document fills.- let (fitted, uv) = layer_thumb_fit(rect, doc.size.width, doc.size.height);+ // The texture is a letterboxed square: draw only the part its frame (the document,+ // or the layer's bounds) fills.+ let (tex, frame) = app.layer_thumb(ctx, doc, l);+ let (fitted, uv) = layer_thumb_fit(rect, frame.width(), frame.height());widgets::checker(p, fitted, 5.0);- let tex = app.layer_thumb(ctx, doc, l);p.image(tex, fitted, uv, Color32::WHITE);}}@@ -3069,7 +3070,7 @@ fn history(app: &mut PhotocraftApp, ui: &mut egui::Ui) {let ctx = ui.ctx().clone();if let Some(layer) = doc.layers.first() {widgets::checker(ui.painter(), thumb, 4.0);- let tex = app.layer_thumb(&ctx, &doc, layer);+ let (tex, _) = app.layer_thumb(&ctx, &doc, layer);ui.painter().image(tex, thumb, Rect::from_min_max(egui::Pos2::ZERO, pos2(1.0, 1.0)), Color32::WHITE);}ui.painter().rect_stroke(thumb, 0.0, Stroke::new(1.0, t.separator), StrokeKind::Outside);diff --git a/docs/scorecard.md b/docs/scorecard.mdindex a902efcb9..c64fecb5f 100644--- a/docs/scorecard.md+++ b/docs/scorecard.md@@ -9,7 +9,7 @@ Generated by `cargo xtask scorecard` from `perf/budgets.toml`, `perf/baseline.js| [Performance](#performance) | 3 | 22 | 22 | 56 scenarios: 3 within budget, 22 over budget or failing, 9 tracked only, 17 not run, 5 not measurable yet (baseline 2026-10-05) || [File compatibility](#file-compatibility) | 7 | 13 | 7 | io corpus: oracle ≥ 146/170, round trip ≥ 169/170; psd-tools corpus: oracle ≥ 241/309, round trip ≥ 308/309; photoshop oracles: oracle ≥ 149/256, round trip ≥ 258/256 || [Tools](#tools) | 32 | 11 | 0 | |-| [Workspace and UI](#workspace-and-ui) | 13 | 6 | 4 | settings that do nothing: 26 of 160 (target 0) |+| [Workspace and UI](#workspace-and-ui) | 13 | 6 | 4 | settings that do nothing: 26 of 161 (target 0) || [Type](#type) | 4 | 3 | 2 | || [Automation](#automation) | 5 | 2 | 4 | 631 of 631 menu items live (100.0%) || [Reliability](#reliability) | 5 | 2 | 0 | never-crash lints on 28 of 28 crates; panic_hunt present |@@ -176,7 +176,7 @@ Corpus floors (`crates/io/tests/corpus.rs`): the enforced minimums; the corpus t## Workspace and UI-**Settings that do nothing: 26 of 160** (target 0, #204). Counted by the prefs audit (`xtask/src/scorecard.rs`): a `Preferences` field counts as read when code outside the prefs model (`prefs.rs` except its `impl Session` blocks; tests excluded; the schema-driven dialog never names a field) accesses `section.field`, or `.section` and `.field` in the same file, or calls a section method that reads `self.field`. It is a heuristic lower bound: a generic name can look read when it isn't.+**Settings that do nothing: 26 of 161** (target 0, #204). Counted by the prefs audit (`xtask/src/scorecard.rs`): a `Preferences` field counts as read when code outside the prefs model (`prefs.rs` except its `impl Session` blocks; tests excluded; the schema-driven dialog never names a field) accesses `section.field`, or `.section` and `.field` in the same file, or calls a section method that reads `self.field`. It is a heuristic lower bound: a generic name can look read when it isn't.Unread: `general.color_picker`, `general.animated_zoom`, `general.zoom_resizes_windows`, `workspace.auto_show_hidden_panels`, `workspace.enable_floating_document_window_docking`, `file_handling.save_in_background`, `performance.cache_levels`, `performance.legacy_compositing`, `scratch_disks.disks`, `units_and_rulers.column_width`, `units_and_rulers.gutter`, `plug_ins.show_extension_panels`, `plug_ins.allow_scripts_to_connect`, `plug_ins.generator_enabled`, `type_.text_engine`, `type_.recent_fonts`, `enhanced_controls.scrubby_slider_acceleration`, `enhanced_controls.touch_gestures`, `raw_defaults.color_space`, `raw_defaults.bit_depth`, `raw_defaults.resolution`, `raw_defaults.sharpen_for`, `raw_defaults.open_as_smart_object`, `raw_defaults.apply_auto_tone`, `integrations.allow_agent_control`, `integrations.control_port`.diff --git a/docs/ui-parity.md b/docs/ui-parity.mdindex 202b9b89a..14dd5f3d9 100644--- a/docs/ui-parity.md+++ b/docs/ui-parity.md@@ -1,6 +1,6 @@# UI parity: tools, handles, modifiers and feel-> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-10-14 · **Change:** minor (Pen ⇧ 45°; last selected tool restored at launch; Layers panel filter-type dropdown with Kind, Name and Mode, #5048; Free Transform box and marching ants follow the selection, #5297; History: the trash deletes the selected snapshot, rows drag onto the trash, #5324; smart filter reordering by drag; smart object perspective row corrected to done, #426; Free Transform H/V skew fields; toolbar tool shortcuts can be reassigned; ⇧-dragged guides land on ruler ticks; layer and selection keys; tool keys; spring-loaded tool letters; type formatting keys; Pen Auto Add/Delete, #4144; smart filter rows; stale missing-tool rows corrected: Color Replacement, Red Eye and the Add/Delete Anchor Point pair are live toolbar tools, Frame landed; no percentage changed) · **Target:** Adobe Photoshop 2026+> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-10-14 · **Change:** minor (Clip Thumbnails to Layer Bounds; Pen ⇧ 45°; last selected tool restored at launch; Layers panel filter-type dropdown with Kind, Name and Mode, #5048; Free Transform box and marching ants follow the selection, #5297; History: the trash deletes the selected snapshot, rows drag onto the trash, #5324; smart filter reordering by drag; smart object perspective row corrected to done, #426; Free Transform H/V skew fields; toolbar tool shortcuts can be reassigned; ⇧-dragged guides land on ruler ticks; layer and selection keys; tool keys; spring-loaded tool letters; type formatting keys; Pen Auto Add/Delete, #4144; smart filter rows; stale missing-tool rows corrected: Color Replacement, Red Eye and the Add/Delete Anchor Point pair are live toolbar tools, Frame landed; no percentage changed) · **Target:** Adobe Photoshop 2026How PhotoCraft's direct manipulation compares with Photoshop 2026 (27.11.0): the toolbox, thehandles and modifier keys of each gesture, nudging, snapping, numeric precision, navigation,@@ -214,6 +214,7 @@ Paragraph; the rest open as in-app floating windows.| Layers panel: wheel steps blend modes, drop on New/Trash | partial | UI-217-14 || Layers panel filter-type dropdown (Kind, Name, Effect, Mode, Attribute, Color, Smart Object, Selected, Artboard) | partial | Kind, Name and Mode; the other six missing. `layer_filter_ui.rs`, `ui.set {layerFilter}` (#5048) || Smart filter rows: click selects, drag onto another smart object moves, ⌥-drag copies, drag onto Delete removes | done | `smart_ui.rs`, `layer.smartFilter.transfer` (#4271) |+| Layers panel: Clip Thumbnails to Layer Bounds (panel menu, `interface.clipThumbnailsToLayerBounds`) | done (2026-10-12) | `layer_thumb_bounds_tests.rs`; #4281. Thumbnail size and the Panel Options dialog to come || Smart filter rows: drag up or down the stack to reorder (a line marks the drop; the bottom filter is applied first) | done | `smart_ui.rs` `reorder_drop`, `layer.smartFilter.move` |## Revision history@@ -237,6 +238,7 @@ Paragraph; the rest open as in-app floating windows.| 2026-10-12 | minor | Toolbar tool shortcuts can be reassigned, removed and reset in Keyboard Shortcuts (#4086); capture, restart, group cycling, conflict and text-focus regressions || 2026-10-12 | minor | Smart filter rows can be selected, and dragged (⌥: copied) onto another smart object or onto Delete (#4271) || 2026-10-12 | minor | Free Transform options bar: H and V skew fields; a sheared box reads as skew instead of a taller H |+| 2026-10-12 | minor | Layers panel: Clip Thumbnails to Layer Bounds frames each layer's pixels instead of the canvas (#4281) || 2026-10-13 | minor | Smart filter rows can be dragged up or down their stack to reorder the filters || 2026-10-11 | minor | Pen ⇧ 45° done: ⇧-click puts the next anchor on the nearest 45° ray, ⇧-drag turns its handles in 45° steps (TOOL-214-10 done, #3751) || 2026-10-14 | minor | Last selected tool restored across launches; temporary overrides excluded, explicit Eraser choices retained, and final selection flushed on normal exit |