From 41b3933b08f5c975e7d4b4c7709a52d3aa606f59 Mon Sep 17 00:00:00 2001 From: gramps Date: Sun, 1 Nov 2026 16:01:41 -0800 Subject: [PATCH] fix(background): refresh BOTH preview layers, not just the thumbnails MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The preview draws two background images — BackgroundImage and, above it, ActiveBackgroundImage (the static art) — while the mini-pane reads the scene snapshot. The default-restore path only called UpdateBackgroundImage, so the thumbnails updated and the preview did not. It now calls UpdateActiveBackground as well. Also adds the generic cure behind the Background bug: OnSelectedElementPropertyChanged invalidates the scene bake for ANY property change. A static layer's pixels are cached by element identity, so a property edit without invalidation repaints nothing and the control looks dead — the failure was never specific to UseDefaultBackground, only first noticed there. Background + thumbnail tests pass (21); Release 0 warnings. --- ViewModels/MainViewModel.cs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/ViewModels/MainViewModel.cs b/ViewModels/MainViewModel.cs index 5817f58..76fbefc 100644 --- a/ViewModels/MainViewModel.cs +++ b/ViewModels/MainViewModel.cs @@ -105,6 +105,13 @@ public partial class MainViewModel : ViewModelBase private void OnSelectedElementPropertyChanged(object? sender, System.ComponentModel.PropertyChangedEventArgs e) { + // ⛔ Safety net for EVERY property control: a static layer's appearance is baked into the + // scene cache keyed on element identity, so changing a property without invalidating the + // bake repaints nothing — the control looks dead. The Background toggle was the first case + // found (2026-11-01); the cause is generic, so the cure is here rather than one handler per + // property. Cheap: the bake is recomputed on demand, once. + if (StagedScene != null) _sceneGraph.InvalidateBake(StagedScene); + if (e.PropertyName == nameof(SceneElement.UseDefaultBackground)) { // ⛔ Turning the default back ON has to RE-STAMP the shipped art. Browse… writes the @@ -122,8 +129,12 @@ public partial class MainViewModel : ViewModelBase } } - if (StagedScene != null) _sceneGraph.InvalidateBake(StagedScene); + // Both surfaces: UpdateBackgroundImage drives the preview's lower layer, + // UpdateActiveBackground drives ActiveBackgroundImage (the art the preview draws above + // it). Refreshing only the first is why the thumbnails changed while the preview did + // not (creator report, 2026-11-01). UpdateBackgroundImage(); + UpdateActiveBackground(); RefreshSnapshotsAsync(); ScheduleSave(); }