fix(preview): draw video layers, unlink Play from Loop, geometry last
Three reports from the creator, plus two bugs the real clip exposed. 1. A video layer was INVISIBLE in the preview. The pane's per-layer Image is Collapsed by default and switched on by a whitelist of DataTriggers; MediaSource matched none, so the clip decoded into a bitmap that nothing displayed. Same defect the alert box hit on 2026-09-26 and the scoreboard after it — now recorded at the top of docs/ai/ui-surface.md with a test that asserts the bound Image is Visible (`MediaPreviewDisplayTests`). 2. Play is no longer tied to Loop: the button is always enabled (creator ruling — Loop must not toggle Play). Loop still restarts a finished clip, which is the behaviour that was broken. 3. Geometry is now the LAST section of the properties list for every draggable element, with opacity at the top; the web source's duplicate geometry block is gone (it now uses the shared one, which had been sitting above the media panel). 4. The physical mouse-drag test is deleted. It injected real cursor movement, hijacked whatever machine ran it, and failed whenever the desktop was busy. The arithmetic it covered now lives in `Helpers/DragReorderMath.cs` — pure, and covered by `DragReorderMathTests` (threshold, up/down moves, no-op and out-of-range). The two persistence tests were already synthetic. 5. Real-clip check (creator's `test_greenscreen_moving_subject.mp4`, 1920×1080): the detector REJECTED it — a fully saturated green sits at value 1.0 and the detector's 0.98 brightness ceiling threw it away. White highlights are excluded by the saturation floor, which is the property that actually separates them, so the ceiling is gone. With it fixed, the clip is detected as green (high confidence), and keyed through our own pipe 97.8% of pixels go transparent. Measured: keying with the canonical #00B140 keys 0.0% of this clip — which is why the key colour comes from the measured screen. Tests: 567 passed, 0 failed, clean build 0 warnings. The gate's scope check flags `Assets/Videos/test_greenscreen_moving_subject.mp4` — the creator's working copy, deliberately not committed; the fixture lives under ytLive.Tests/Fixtures.
This commit is contained in:
@@ -54,122 +54,6 @@ public sealed class LayerReorderPersistenceTests
|
||||
_app.Run(RunCrossTypeReload);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Same use case as above but driven with REAL injected mouse input
|
||||
/// (SetCursorPos + mouse_event against the desktop) so the actual
|
||||
/// List_PreviewMouseLeftButtonDown/Move/Up handlers — the seam no synthetic
|
||||
/// event can exercise, since e.GetPosition reads the physical cursor — must
|
||||
/// run. Requires an interactive desktop session: if the window is covered or
|
||||
/// the session is locked, the pointer no-ops and the drag never lands.
|
||||
/// </summary>
|
||||
[Fact]
|
||||
public void RealMouseDrag_OnTheLayerList_PersistsTheReorder()
|
||||
{
|
||||
_app.Run(RunRealDrag);
|
||||
}
|
||||
|
||||
private void RunRealDrag()
|
||||
{
|
||||
var tempDb = Path.Combine(Path.GetTempPath(), $"ytLlive-realdrag-{Guid.NewGuid():N}.db");
|
||||
MainViewModel.LayoutPathOverride = tempDb;
|
||||
var window = default(MainWindow);
|
||||
try
|
||||
{
|
||||
using (var schema = new LayoutStore(tempDb)) { }
|
||||
SqliteConnection.ClearAllPools();
|
||||
SeedThreeLayers(tempDb);
|
||||
|
||||
window = new MainWindow();
|
||||
var vm = (MainViewModel)window.DataContext;
|
||||
vm.StagedScene = vm.Scenes.Single(s => SceneCatalog.Is(s.Name, SceneCatalog.Live));
|
||||
Assert.True(vm.StagedScene!.Elements.OfType<Source>().Count() >= 4,
|
||||
"3 seeded layers + the healed Background + Brand logo must load");
|
||||
|
||||
window.Show();
|
||||
window.Activate();
|
||||
window.Topmost = true;
|
||||
window.UpdateLayout();
|
||||
|
||||
var panel = (UserControl)window.FindName("LeftPanel")!;
|
||||
var list = (FocusPreservingListBox)panel.FindName("SourceList")!;
|
||||
list.UpdateLayout();
|
||||
|
||||
// Brand logo is a permanent layer between Background and user layers.
|
||||
// Physically drag ImgC above ImgA; the background and logo keep their
|
||||
// relative positions while EndListDrag persists the user-layer reorder.
|
||||
var sources = vm.StagedScene.Elements.OfType<Source>().ToArray();
|
||||
var from = RowScreenPoint(list, sources.First(s => s.Name == "ImgC"));
|
||||
var to = RowScreenPoint(list, sources.First(s => s.Name == "ImgA"));
|
||||
|
||||
SetCursorPos((int)from.X, (int)from.Y);
|
||||
LetInputSettle(80);
|
||||
mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, UIntPtr.Zero);
|
||||
LetInputSettle(120);
|
||||
SetCursorPos((int)to.X, (int)to.Y);
|
||||
LetInputSettle(250);
|
||||
mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, UIntPtr.Zero);
|
||||
LetInputSettle(400);
|
||||
|
||||
var expected = vm.StagedScene.Elements.OfType<Source>().Select(s => s.Name).ToArray();
|
||||
Assert.Equal("Background", expected[0]);
|
||||
Assert.Equal("Brand logo", expected[1]);
|
||||
Assert.Equal("ImgC", expected[2]);
|
||||
Assert.True(Array.IndexOf(expected, "ImgC") < Array.IndexOf(expected, "ImgA"));
|
||||
|
||||
Assert.True(PumpUntil(() => SourceNamesInDb(tempDb).SequenceEqual(expected),
|
||||
TimeSpan.FromSeconds(10)),
|
||||
"a real mouse drag-and-drop must be persisted by the background save");
|
||||
Assert.Equal(expected, SourceNamesInDb(tempDb));
|
||||
|
||||
// The same drop must persist the PREVIEW LAYOUT too — each layer's
|
||||
// geometry (X/Y/W/H) rides in the same Source rows as the SortOrder.
|
||||
var dragged = vm.StagedScene.Elements.OfType<Source>().Single(s => s.Name == "ImgC");
|
||||
Assert.Equal((dragged.X, dragged.Y, dragged.Width, dragged.Height),
|
||||
GeometryInDb(tempDb, "ImgC"));
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (window != null) window.Close();
|
||||
MainViewModel.LayoutPathOverride = null;
|
||||
SqliteConnection.ClearAllPools();
|
||||
try { File.Delete(tempDb); } catch { /* best-effort cleanup */ }
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Screen (device-pixel) point one-third into an item's list row — over
|
||||
/// the name TextBlock, away from the per-row buttons/rename TextBox.</summary>
|
||||
private static Point RowScreenPoint(FocusPreservingListBox list, Models.SceneElement item)
|
||||
{
|
||||
var container = (ListBoxItem)list.ItemContainerGenerator.ContainerFromItem(item)!;
|
||||
var inList = container.TransformToVisual(list)
|
||||
.Transform(new Point(Math.Min(30, container.ActualWidth - 12), container.ActualHeight / 2));
|
||||
return list.PointToScreen(inList);
|
||||
}
|
||||
|
||||
/// <summary>Pumps the app dispatcher while sleeping in small steps, so real
|
||||
/// input messages posted to the thread queue are processed mid-gesture.</summary>
|
||||
private static void LetInputSettle(int milliseconds)
|
||||
{
|
||||
var frame = new DispatcherFrame();
|
||||
var timer = new DispatcherTimer { Interval = TimeSpan.FromMilliseconds(milliseconds) };
|
||||
timer.Tick += (_, _) =>
|
||||
{
|
||||
timer.Stop();
|
||||
frame.Continue = false;
|
||||
};
|
||||
timer.Start();
|
||||
Dispatcher.PushFrame(frame);
|
||||
}
|
||||
|
||||
private const uint MOUSEEVENTF_LEFTDOWN = 0x0002;
|
||||
private const uint MOUSEEVENTF_LEFTUP = 0x0004;
|
||||
|
||||
[DllImport("user32.dll")]
|
||||
private static extern bool SetCursorPos(int x, int y);
|
||||
|
||||
[DllImport("user32.dll")]
|
||||
private static extern void mouse_event(uint dwFlags, uint dx, uint dy, uint dwData, UIntPtr dwExtraInfo);
|
||||
|
||||
private void Run()
|
||||
{
|
||||
var tempDb = Path.Combine(Path.GetTempPath(), $"ytLlive-reorder-{Guid.NewGuid():N}.db");
|
||||
|
||||
Reference in New Issue
Block a user