fix(background): refresh BOTH preview layers, not just the thumbnails

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.
This commit is contained in:
2026-11-01 16:01:41 -08:00
parent d6088f8e35
commit 41b3933b08
+12 -1
View File
@@ -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();
}