diff --git a/common.go b/common.go index 0711492..698ec4f 100644 --- a/common.go +++ b/common.go @@ -11,7 +11,7 @@ import ( "time" ) -const version = "0.98.351-experimental1" +const version = "0.98.352-experimental1" const appDisplayName = "Projection Mapper - Built by Instinct" diff --git a/ddmexp_ui_win.go b/ddmexp_ui_win.go index 5bde009..efa1239 100644 --- a/ddmexp_ui_win.go +++ b/ddmexp_ui_win.go @@ -206,7 +206,7 @@ func (a *app) ddmStepPreview(delta int) { logf("Dia de Muertos: %s found no surfaces to preview on.", exp.Name) return } - a.scenePreviewShow(exp.Name, sc, n) + a.scenePreviewShowOwner("ddm", exp.Name, sc, n) ddmUI.mu.Lock() ddmUI.status = exp.Name + " previewing - nothing saved." ddmUI.mu.Unlock() diff --git a/effect_browser_catalog326_windows.go b/effect_browser_catalog326_windows.go index 4020953..d092784 100644 --- a/effect_browser_catalog326_windows.go +++ b/effect_browser_catalog326_windows.go @@ -201,9 +201,9 @@ func (a *app) effectSelect326(page int, key string) bool { roomFXQueueUI.page = i / roomFXQueuePageSize roomFXQueueUI.mu.Unlock() case ag100PageIdx: - ag100UI.mu.Lock();ag100UI.sel=i;ag100UI.mu.Unlock();a.ag100SyncLivePreview() + ag100UI.mu.Lock();ag100UI.sel=i;ag100UI.mu.Unlock() case botanicalPageIdx: - botanicalSel.Store(int32(i));a.botanicalSync() + botanicalSel.Store(int32(i)) case agPageIdx: agUI.mu.Lock() agUI.sel = i diff --git a/effect_browser_live352_windows.go b/effect_browser_live352_windows.go new file mode 100644 index 0000000..bff8f4a --- /dev/null +++ b/effect_browser_live352_windows.go @@ -0,0 +1,212 @@ +//go:build windows + +package main + +// UI selection follows a live preview only. Metadata restoration and filtering +// keep effectSelect326's silent behavior. Never toggle Preview to refresh it. +func (a *app) browseSelectLive352(page int, key string) bool { + refresh := a.browseLiveRefresh352(page) + if !a.effectSelect326(page, key) { + return false + } + if refresh != nil { + refresh() + } + return true +} + +func (a *app) browseLiveRefresh352(page int) func() { + if a == nil || a.pl == nil || a.pl.R == nil || physicsStopped.Load() || calibrationActive() { + return nil + } + pl, project, renderer := a.pl, a.pl.P, a.pl.R + pl.mu.Lock() + busy := pl.paused || pl.blackout || pl.exportOwned || pl.calibrationPaused || pl.manualPumpkin != nil || pl.door != nil || pl.pumpkin != nil || pl.pumpkinAutoDark || (pl.demoRoom != nil && !pl.demoRoom.stopped) + pl.mu.Unlock() + if busy { + return nil + } + physGen, sceneGen := renderer.physPreviewGen.Load(), renderer.scenePreviewGen.Load() + var refresh func() + switch page { + case carbonPageIdx: + if a.carbonOwnedPreview.Active(pl) { + refresh = a.startCarbonPreview + } + case chimeraPageIdx: + if a.chimeraOwnedPreview.Active(pl) { + refresh = a.chimeraPreviewCurrent + } + case antidotPageIdx: + if a.antidotOwnedPreview.Active(pl) { + refresh = a.antidotPreviewCurrent + } + case xmasPageIdx: + if a.xmasOwnedPreview.Active(pl) { + refresh = a.xmasPreviewCurrent + } + case atmosPageIdx: + if a.atmosOwnedPreview.Active(pl) { + native := a.spatialAudio.nativeAtmos + refresh = func() { + if native { + a.atmosNativePreview(false) + } else { + a.atmosPreviewCurrent() + } + } + } + case agPageIdx: + if a.agHasOwnedPreview() { + refresh = func() { + es := GetAgEffects() + agUI.mu.Lock() + i := clampi(agUI.sel, 0, len(es)-1) + agUI.mu.Unlock() + if len(es) > 0 { + a.agPreviewOn(es[i]) + } + } + } + case restylePageIdx: + if a.restyleHasOwnedPreview() { + refresh = a.restyleTest + } + case bbPageIdx: + if renderer.ScenePreviewOwner() == "bobs" { + refresh = a.bbTestPreview + } + case halloPageIdx: + if renderer.ScenePreviewOwner() == "halloween-library" { + refresh = func() { a.halloStepPreview(0) } + } + case musePageIdx: + if renderer.ScenePreviewOwner() == "muse" { + refresh = func() { a.museStepPreview(0) } + } + case themesPageIdx: + if renderer.ScenePreviewOwner() == "themes" { + refresh = a.themesPreviewCurrent + } + case ddmPageIdx: + if renderer.ScenePreviewOwner() == "ddm" { + refresh = func() { a.ddmStepPreview(0) } + } + case scenesPageIdx: + if renderer.ScenePreviewOwner() == "scenes" { + refresh = func() { a.scenesStepPreview(0) } + } + case indyPageIdx: + if renderer.ScenePreviewOwner() == "indy" { + refresh = func() { a.indyStepPreview(0) } + } + case disneyPageIdx: + if renderer.ScenePreviewOwner() == "disney" { + refresh = func() { a.disneyStepPreview(0) } + } + case camlabPageIdx: + if renderer.ScenePreviewOwner() == "camlab" { + refresh = func() { a.camlabStepPreview(0) } + } + case ttPageIdx: + ttUI.Lock() + local := ttUI.cancel != nil + gen := ttUI.gen + projected := ttUI.projOn && ttUI.projRenderer == renderer && ttUI.projGeneration == sceneGen + ttUI.Unlock() + if projected { + refresh = a.ttProjectTest + } else if local { + refresh = func() { + ttUI.Lock() + ok := ttUI.cancel != nil && ttUI.gen == gen + ttUI.Unlock() + if ok { + a.ttLocalPreview() + } + } + } + case mansionPageIdx: + if renderer.ScenePreviewOwner() == "mansion" { + refresh = func() { a.mansionStepPreview(0) } + } + + } + if refresh == nil { + old, on := renderer.PhysPreviewAssign() + items, _ := a.effectCatalog326(page) + owns := false + for _, it := range items { + if old.ID != "" && it.EffectID == old.ID { + owns = true + break + } + } + if !on || !owns { + return nil + } + switch page { + case 7, favoritesPageIdx: + refresh = func() { a.effectBrowserPreview(U.fxSel) } + case physPageIdx: + if !a.libraryOwnedPhysical() { + return nil + } + refresh = func() { + physUI.mu.Lock() + defer physUI.mu.Unlock() + a.physProjectorPreview(physKinds[clampi(physUI.sel, 0, len(physKinds)-1)], true) + } + case hxPageIdx: + refresh = func() { a.hxPreviewOn(a.hxSel()) } + case ixPageIdx: + refresh = func() { a.ixPreviewOn(a.ixSel()) } + case objiqPageIdx: + refresh = func() { a.objiqPreviewOn(a.objiqSel()) } + case ofxPageIdx: + refresh = func() { renderer.SetPhysPreview(a.ofxHooks().assign()) } + case fishTankPageIdx: + refresh = func() { renderer.SetPhysPreview(a.fishTankHooks().assign()) } + case bugsimPageIdx: + refresh = func() { renderer.SetPhysPreview(a.bugsimHooks().assign()) } + case qPageIdx: + refresh = func() { renderer.SetPhysPreview(a.qHooks().assign()) } + case roomFiltersPageIdx: + refresh = func() { renderer.SetPhysPreview(roomFilterAssignNow()) } + case antidemoPageIdx: + refresh = func() { renderer.SetPhysPreview(antidemoAssignNow()) } + case roomFXQueuePageIdx: + refresh = func() { renderer.SetPhysPreview(roomFXQueueAssignNow()) } + case antiRustPageIdx: + refresh = a.antiCuratedSync340 + case ag100PageIdx: + refresh = a.ag100SyncLivePreview + case botanicalPageIdx: + refresh = a.botanicalSync + case pixelPageIdx: + refresh = func() { a.pixelCommand(idPixelPreview) } + case deepaiPageIdx: + refresh = func() { a.deepaiPreviewOn(a.deepaiSel()) } + default: + for n, p := range antiEnginePagePtrs { + if page == *p { + i := n + refresh = func() { a.antiEngineSyncLive(i) } + break + } + } + } + } + if refresh == nil { + return nil + } + return func() { + if a.pl != pl || a.pl.P != project || a.pl.R != renderer || physicsStopped.Load() || renderer.physPreviewGen.Load() != physGen || renderer.scenePreviewGen.Load() != sceneGen { + return + } + if !a.spatialAudioStop("preview selection changed") { + return + } + refresh() + } +} diff --git a/effect_browser_live352_windows_test.go b/effect_browser_live352_windows_test.go new file mode 100644 index 0000000..f8fd65e --- /dev/null +++ b/effect_browser_live352_windows_test.go @@ -0,0 +1,82 @@ +//go:build windows + +package main + +import ( + "bytes" + "encoding/json" + "testing" +) + +func Test352ActiveRoomFilterFollowsSharedNextAndDropdown(t *testing.T) { + a, _ := qFixture(t) + oldPage := U.page + defer func() { U.page = oldPage }() + U.page = roomFiltersPageIdx + physicsStopped.Store(false) + a.pl.SetPaused(false) + a.pl.SetBlackout(false) + items, _ := a.effectCatalog326(U.page) + if len(items) < 2 { + t.Fatal("catalog") + } + a.effectSelect326(U.page, items[0].Key) + a.pl.R.SetPhysPreview(roomFilterAssignNow()) + before, _ := json.Marshal(a.pl.P) + a.browseCommand326(idBrowseNext326) + got, on := a.pl.R.PhysPreviewAssign() + want := roomFilterAssignNow() + if !on || got.Phys == nil || got.Phys.HX[0] != want.Phys.HX[0] { + t.Fatal("shared Next stale", got, want) + } + a.browsePick326(idBrowseChoice326, 0) + got, _ = a.pl.R.PhysPreviewAssign() + want = roomFilterAssignNow() + if got.Phys.HX[0] != want.Phys.HX[0] { + t.Fatal("dropdown stale") + } + after, _ := json.Marshal(a.pl.P) + if !bytes.Equal(before, after) { + t.Fatal("browsing saved project mutation") + } +} +func Test352StoppedAndForeignPreviewRemainUntouched(t *testing.T) { + a, _ := qFixture(t) + oldPage := U.page + defer func() { U.page = oldPage }() + U.page = roomFiltersPageIdx + a.pl.SetPaused(false) + a.pl.SetBlackout(false) + for _, stopped := range []bool{false, true} { + physicsStopped.Store(stopped) + a.pl.R.SetPhysPreview(Assign{Type: "fx", ID: "phys:foreign"}) + gen := a.pl.R.physPreviewGen.Load() + a.browseCommand326(idBrowseNext326) + if a.pl.R.physPreviewGen.Load() != gen { + t.Fatal("replaced foreign/stopped preview") + } + } + physicsStopped.Store(false) + a.pl.R.SetPhysPreview(Assign{}) + a.browseCommand326(idBrowseNext326) + if _, on := a.pl.R.PhysPreviewAssign(); on { + t.Fatal("started inactive preview") + } +} +func Test352StaleRefreshDoesNotReplaceNewOwner(t *testing.T) { + a, _ := qFixture(t) + physicsStopped.Store(false) + a.pl.SetPaused(false) + a.pl.SetBlackout(false) + a.pl.R.SetPhysPreview(roomFilterAssignNow()) + f := a.browseLiveRefresh352(roomFiltersPageIdx) + if f == nil { + t.Fatal("no refresh") + } + a.pl.R.SetPhysPreview(Assign{Type: "fx", ID: "phys:successor"}) + gen := a.pl.R.physPreviewGen.Load() + f() + if a.pl.R.physPreviewGen.Load() != gen { + t.Fatal("stale refresh replaced successor") + } +} diff --git a/effect_browser_ui326_windows.go b/effect_browser_ui326_windows.go index 19709b3..2b6026c 100644 --- a/effect_browser_ui326_windows.go +++ b/effect_browser_ui326_windows.go @@ -73,7 +73,7 @@ func (a *app) browsePick326(id, k int) bool { } visible := effectBrowserFiltered326(items, filter, a.st.Favs) if k >= 0 && k < len(visible) { - a.effectSelect326(U.page, visible[k].Key) + a.browseSelectLive352(U.page, visible[k].Key) } return true } @@ -98,7 +98,7 @@ func (a *app) browseCommand326(id int) bool { } visible := effectBrowserFiltered326(items, filter, a.st.Favs) if it, ok := effectBrowserStep326(visible, key, delta); ok { - a.effectSelect326(U.page, it.Key) + a.browseSelectLive352(U.page, it.Key) } default: return false diff --git a/sceneprev_ui_win.go b/sceneprev_ui_win.go index ef8da5d..d1b43b0 100644 --- a/sceneprev_ui_win.go +++ b/sceneprev_ui_win.go @@ -232,7 +232,7 @@ func (a *app) scenesStepPreview(delta int) { logf("Scenes: %s found no surfaces to preview on.", idea.Name) return } - a.scenePreviewShow(idea.Name, sc, cnt) + a.scenePreviewShowOwner("scenes", idea.Name, sc, cnt) scenesUI.mu.Lock() scenesUI.status = idea.Name + " previewing - nothing saved." scenesUI.mu.Unlock() @@ -272,7 +272,7 @@ func (a *app) indyStepPreview(delta int) { logf("Indiana Jones: %s found no surfaces to preview on.", idea.Name) return } - a.scenePreviewShow(idea.Name, sc, cnt) + a.scenePreviewShowOwner("indy", idea.Name, sc, cnt) indyUI.mu.Lock() indyUI.status = idea.Name + " previewing - nothing saved." indyUI.mu.Unlock() @@ -308,7 +308,7 @@ func (a *app) extremeStepPreview(delta int) { logf("Extreme: %s found no surfaces to preview on.", idea.Name) return } - a.scenePreviewShow(idea.Name, sc, cnt) + a.scenePreviewShowOwner("extreme", idea.Name, sc, cnt) extremeUI.mu.Lock() extremeUI.status = idea.Name + " previewing - nothing saved." extremeUI.mu.Unlock() @@ -344,7 +344,7 @@ func (a *app) disneyStepPreview(delta int) { logf("Disney: %s found no surfaces to preview on.", idea.Name) return } - a.scenePreviewShow(idea.Name, sc, cnt) + a.scenePreviewShowOwner("disney", idea.Name, sc, cnt) disneyUI.mu.Lock() disneyUI.status = idea.Name + " previewing - nothing saved." disneyUI.mu.Unlock() @@ -384,7 +384,7 @@ func (a *app) mansionStepPreview(delta int) { logf("Haunted Mansion: %s found no surfaces to preview on.", idea.Name) return } - a.scenePreviewShow(idea.Name, sc, cnt) + a.scenePreviewShowOwner("mansion", idea.Name, sc, cnt) mansionUI.mu.Lock() mansionUI.status = idea.Name + " previewing - nothing saved." mansionUI.mu.Unlock() @@ -473,7 +473,7 @@ func (a *app) camlabStepPreview(delta int) { logf("Camera Lab: %s found no surfaces to preview on.", idea.Name) return } - a.scenePreviewShow(idea.Name, sc, cnt) + a.scenePreviewShowOwner("camlab", idea.Name, sc, cnt) camlabUI.mu.Lock() camlabUI.status = idea.Name + " previewing - nothing saved." camlabUI.mu.Unlock() diff --git a/themes_20_ui_win.go b/themes_20_ui_win.go index 9bf63f9..149cba1 100644 --- a/themes_20_ui_win.go +++ b/themes_20_ui_win.go @@ -103,7 +103,7 @@ func (a *app) themesPreviewCurrent() { a.pl.mu.Unlock() if cnt > 0 && len(sc.Assign) > 0 { physicsStopped.Store(false) - a.scenePreviewShow(th.Name, sc, cnt) + a.scenePreviewShowOwner("themes", th.Name, sc, cnt) themeUI.Lock() themeUI.status = fmt.Sprintf("Temporary room preview of %q (%d surfaces) active on projector.", th.Name, cnt) themeUI.Unlock() diff --git a/whatsnew_ui_win.go b/whatsnew_ui_win.go index 3b9dacc..cefc722 100644 --- a/whatsnew_ui_win.go +++ b/whatsnew_ui_win.go @@ -47,6 +47,7 @@ type whatsNewFeature struct { } var whatsNewFeatures = []whatsNewFeature{ + {"352: Shared effect preview follows Previous and Next", "Experimental. Native Windows and projector tests NOT RUN. Dual-webcam first-pattern timeout remains unresolved.", []string{"Shared catalog Previous, Next and effect-picker selection now refresh an already-active temporary preview instead of only changing the selected label.", "Stopped, inactive and foreign previews are not started or replaced by browsing. Selection restoration stays metadata-only; no scene is saved.", "Scene-preview libraries tag their previews by tab so shared browsing can follow the correct owner."}, []string{"Start a preview, press Next and Previous, then Stop and browse again. The stopped show must remain stopped. No native execution claim from compile-only tests."}, ""}, {"351: Guided calibration handoff and usable outline canvas", "Experimental. Full Windows app and real camera/projector tests NOT RUN. Dual-webcam first-pattern timeout remains unresolved.", []string{"Guided Auto now creates and accepts its own fresh detected project before dot measurement, instead of silently adding to the old scene and stopping before calibration.", "Guided detection respects the Indoor/Outside setting from the first attempt. It no longer tries house detection first in an indoor room.", "The BIG VIEW outline photo and editing controls use separate columns, with object/type selection and Bigger/Smaller at the top.", "Click an outline in Live preview to select it; + and - resize it. Right-click keeps the existing type menu. Webcam-only preview stays pan/zoom because it is not registered to the saved outline photo.", "Dual-webcam timeout messages retain the last capture failure instead of discarding it; the hardware failure is not claimed fixed."}, []string{"Run Guided Auto once with the correct Indoor/Outside setting and send logs after it completes or stops. Do not treat the map as accurate until its measured check passes. No claim of physical alignment from software tests."}, ""}, {"350: Reviewed Antigravity floral and finite-input fixes", "Experimental. Native Windows, projector, audio and real-room tests NOT RUN.", []string{"Precomputed smooth mesh normals and 640x360 panels; up to12flowers across the first24authored contours, max3per shape, including sideways/diagonal artistic fitting. Fair allocation does not fill every object when more than12are fittable.", "Final mask uses a conservative interior guard. Projection sampling stays nearest-neighbor, not contributor bilinear filtering, to preserve exact black edges. No scan, live room tracking or camera-to-photo registration added.", "Floral state pointer avoids copying its mutex in audit snapshots. Finite UV/intensity guards added to shared GPU-frame sampling, Botanical, Chimera and Kiro. Chimera room-photo albedo interpolation improved. Seven formerly static Christmas shaders now animate; effect browser categories expanded. Unqualified AG100 parallelization and rejected343/345/Nexus lineages excluded."}, []string{"Use a project copy. Check narrow vertical/horizontal/diagonal objects, Stop/Blackout and frame profiler. Local CPU harness about10.7ms ordinary and28.0ms worst12contours per prepared panel, not rigFPS. 349 and347 retained."}, ""},