diff --git a/src/Titano.App/Sections/SequenceView.xaml b/src/Titano.App/Sections/SequenceView.xaml index c278d222..2f2ac0d4 100644 --- a/src/Titano.App/Sections/SequenceView.xaml +++ b/src/Titano.App/Sections/SequenceView.xaml @@ -124,12 +124,8 @@ CropMaskMode="{Binding CropMaskMode}" InfoText="{Binding InfoText}" ToolTip="{l:Loc Tooltips.Editor.Preview.View}" AutomationProperties.Name="{l:Loc Editor.Preview}" SizeChanged="OnPreviewSizeChanged"> - - + + Shot data shown in the bottom-right pill. public string? InfoText { get => (string?)GetValue(InfoTextProperty); set => SetValue(InfoTextProperty, value); } - /// Tool buttons shown bottom-left over the image. + /// + /// Tool buttons shown bottom-left over the image. They are logical children of the viewport, so they take its data + /// context and resources like any content, although the template presents them. + /// public object? ToolsContent { get => GetValue(ToolsContentProperty); set => SetValue(ToolsContentProperty, value); } + protected override IEnumerator LogicalChildren => + ToolsContent is { } tools ? new[] { tools }.GetEnumerator() : base.LogicalChildren; + /// Current image-to-view transform in DIPs (for hit testing overlays from outside). public ViewTransform View => _view; @@ -198,6 +206,13 @@ public class PreviewViewport : Control private double PixelScale => VisualTreeHelper.GetDpi(this).DpiScaleX; + private static void OnToolsContentChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) + { + var viewport = (PreviewViewport)d; + if (e.OldValue is not null) viewport.RemoveLogicalChild(e.OldValue); + if (e.NewValue is not null) viewport.AddLogicalChild(e.NewValue); + } + public override void OnApplyTemplate() { if (_surface is not null) _surface.SizeChanged -= OnSurfaceSizeChanged; diff --git a/tests/Titano.App.Tests/Editor/FakeRemoteSequenceApi.cs b/tests/Titano.App.Tests/Editor/FakeRemoteSequenceApi.cs index 083eb8c5..495f7cfe 100644 --- a/tests/Titano.App.Tests/Editor/FakeRemoteSequenceApi.cs +++ b/tests/Titano.App.Tests/Editor/FakeRemoteSequenceApi.cs @@ -1,3 +1,4 @@ +using System.Collections.Concurrent; using System.Net; using System.Runtime.CompilerServices; using System.Threading.Channels; @@ -39,7 +40,8 @@ internal sealed class FakeRemoteSequenceApi(Sequence sequence, IReadOnlyListPriorities set after jobs were posted (job, wire name). public List<(Guid Job, string Priority)> Priorities { get; } = []; - public Dictionary Jobs { get; } = []; + /// The server's jobs; tests change them while the source's event loop reads them. + public ConcurrentDictionary Jobs { get; } = new(); /// Thrown by the next read of a job (a failure the editor's event listener does not expect). public Exception? FailNextJobRead { get; set; } diff --git a/tests/Titano.App.Tests/Editor/RemoteSequenceSourceTests.cs b/tests/Titano.App.Tests/Editor/RemoteSequenceSourceTests.cs index d062a05d..2daeb97a 100644 --- a/tests/Titano.App.Tests/Editor/RemoteSequenceSourceTests.cs +++ b/tests/Titano.App.Tests/Editor/RemoteSequenceSourceTests.cs @@ -413,7 +413,9 @@ public sealed class RemoteSequenceSourceTests(TestContext context) api.FramesVersion = 3; api.Publish(new SequenceChangedEvent(Guid.CreateVersion7(), "frames", 7, 1)); api.Publish(new SequenceChangedEvent(remote.Sequence.Id, "frames", 3, api.SettingsVersion)); - await WaitAsync(() => source.IsOutdated); + // The flag is set before the event is raised: wait for the event, which comes last. + await WaitAsync(() => Volatile.Read(ref changes) > 0); + Assert.True(source.IsOutdated); Assert.True(source.IsReadOnly); Assert.Equal(1, Volatile.Read(ref changes)); diff --git a/tests/Titano.App.Tests/Windows/ScreenSmokeTests.cs b/tests/Titano.App.Tests/Windows/ScreenSmokeTests.cs index 24e5cb69..be72118d 100644 --- a/tests/Titano.App.Tests/Windows/ScreenSmokeTests.cs +++ b/tests/Titano.App.Tests/Windows/ScreenSmokeTests.cs @@ -334,7 +334,7 @@ public sealed class ScreenSmokeTests { var name = AutomationProperties.GetName(control); Assert.False(string.IsNullOrWhiteSpace(name), $"{screen}: an icon-only {control.GetType().Name} bound to {(control as ButtonBase)?.Command} has no name"); - Assert.True(control.ToolTip is not null, $"{screen}: '{name}' has no tooltip"); + Assert.True(control.ToolTip is not null, $"{screen}: '{name}' has no tooltip (data context: {control.DataContext?.GetType().Name ?? "none"})"); } }