feat: export panel and Render menu, playback options, videos library (owner review 1 phase 5) (#27)
CI / Build and test (push) Successful in 9m41s
CI / Windows tests and installer (push) Skipped
CI / YAML check (push) Successful in 9s
Release / Build, test and publish (push) Successful in 14m49s
CI / PostgreSQL 16 integration (push) Successful in 8m51s
CI / PostgreSQL 17 integration (push) Successful in 9m48s
CI / Docker image (push) Successful in 54s
Release / Server image (push) Successful in 1m39s

Owner review 1 R3, R8, R9. A grouped Export step and Render menu; encoding, playback (reverse, boomerang, loops, fades, hold) and still frames; one videos library on the desktop and the server with a verified trash and copies to a videos folder.

Closes #21

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: Alberto Balbo <alberto.balbo.96@gmail.com>
This commit was merged in pull request #27.
This commit is contained in:
Alby96andClaude Opus 5.5 authored and Alby96 committed 2026-11-05 09:18:40 +01:00
1 parent 188b2c2e55
commit 728ffa35cb
729 files changed
+26954 -1652

No files matched your search

+167 -4
View File
@@ -17,13 +17,14 @@ using Chronos.Core.Diagnostics;
using Chronos.Core.Imaging.Geometry;
using Chronos.Ui.Controls;
using Chronos.Ui.Theming;
using Chronos.Ui.Visuals;
namespace Chronos.App.Shell;
/// <summary>
/// <c>Chronos.exe --capture &lt;dir&gt;</c>: renders every client screen at 1440×900 in the dark and light themes to
/// <c>&lt;screen&gt;-&lt;theme&gt;.png</c> from <see cref="SampleData"/> (first run on an empty index, then a populated
/// one, then the sync table with transfers, a conflict and its confirmation, then the sequence editor on an archive
/// one, then the Videos section, then the sync table with transfers, a conflict and its confirmation, then the sequence editor on an archive
/// sequence and on a server sequence with proxies, its server job and a read-only account), plus the Library, the
/// editor's Exposure tab and the import plan in Arabic (<c>*-rtl-dark.png</c>, right to left), for visual review,
/// the pixel diff against <c>tests/visual/baselines</c> and phase reports (BRIEF §20.2), then exits. The pictures are
@@ -140,6 +141,8 @@ public static class ScreenCapture
written += await SaveAsync(window, directory, "archive-" + view, theme);
}
}
written += await CaptureVideosAsync(window, shell, sample, directory);
// The sync table with proxies kept here and transfers in every state, then filtered to the conflict, then the
// conflict's confirmation (after the other screens, so the Jobs capture keeps its own sample).
await sample.CacheProxiesAsync();
@@ -224,6 +227,42 @@ public static class ScreenCapture
return written;
}
/// <summary>
/// The Videos section (owner review 1, R9) on <see cref="SampleData.FillVideosAsync"/> in both themes: the cards of this
/// PC's, the server's and the workspace's renders (<c>videos</c>), then the list with the still selected and shown in the
/// player pane (<c>videos-list</c>); the cards again after, with nothing selected.
/// </summary>
private static async Task<int> CaptureVideosAsync(MainWindow window, ShellViewModel shell, SampleData sample, string directory)
{
var videos = shell.Videos;
await sample.FillVideosAsync(videos);
var written = 0;
foreach (var theme in Themes)
{
ThemeManager.Apply(theme);
DismissToasts(window);
videos.LayoutIndex = 0;
shell.Navigate(SectionKey.Videos);
await videos.RefreshAsync();
await Settle(window);
// The cards ask for their covers once shown; the covers decode off the UI thread.
for (var i = 0; i < 40 && videos.Rows.Any(r => r.Entry.IsLocal && r.Poster is null); i++) await Task.Delay(50);
written += await SaveAsync(window, directory, "videos", theme, waitForThumbnails: shell);
videos.LayoutIndex = 1;
if (videos.Rows.FirstOrDefault(r => r.Entry.Kind == Core.Model.RenderKind.Still) is { } still)
{
still.IsSelected = true;
videos.PlayCommand.Execute(still);
}
written += await SaveAsync(window, directory, "videos-list", theme);
videos.ClosePlayerCommand.Execute(null);
videos.ClearSelectionCommand.Execute(null);
videos.LayoutIndex = 0;
}
return written;
}
private static void SelectSyncFilter(ShellViewModel shell, SyncFilter filter) =>
shell.Server.Sync.Chips.First(c => c.Filter == filter).SelectCommand.Execute(null);
@@ -251,7 +290,8 @@ public static class ScreenCapture
/// The editor on the synthetic sunset: every step of the Edit path in both themes (<c>edit-&lt;step&gt;-&lt;theme&gt;.png</c>,
/// the Camera step with a keyframe selected, the Export step as Export.html with the crop mask and no compare), then
/// the preview overlays, the waveform, the "what changed" toast of Optimise all, the picker over the open sequence
/// (<c>edit-change</c>), the crop box, straighten and look scenes (<see cref="CaptureFramingAsync"/>), the Export step of the sequence once the server has it (Sync on) with two "Save both" copies
/// (<c>edit-change</c>), the crop box, straighten and look scenes (<see cref="CaptureFramingAsync"/>), the Export groups
/// and the Render menu (<see cref="CaptureExportAsync"/>), the Export step of the sequence once the server has it (Sync on) with two "Save both" copies
/// to restore, and the Analysis step while the analysis runs (<c>edit-busy</c>).
/// </summary>
private static async Task<int> CaptureEditorAsync(MainWindow window, ShellViewModel shell, SampleData sample, string directory)
@@ -298,6 +338,7 @@ public static class ScreenCapture
shell.Sequence.CancelPickCommand.Execute(null);
}
written += await CaptureFramingAsync(window, editor, directory);
written += await CaptureExportAsync(window, editor, directory);
// The server has the sequence (Sync can be ticked) and two copies of this PC's settings were kept by "Save both".
await sample.KeepEditorCopiesAsync(id);
@@ -307,11 +348,14 @@ public static class ScreenCapture
export.SyncToServer = true;
editor.SelectedTab = export;
editor.IsCompare = false;
// Sync and Restore are rows of the File group: the groups above it folded to their summaries.
var groups = OpenGroups(export, export.FileGroup);
foreach (var theme in Themes)
{
ThemeManager.Apply(theme);
written += await SaveEditorAsync(window, editor, directory, "edit-export-copies", theme);
}
RestoreGroups(export, groups);
export.SyncToServer = false;
editor.SelectedTab = editor.Exposure;
editor.IsCompare = true;
@@ -374,6 +418,105 @@ public static class ScreenCapture
return written;
}
/// <summary>
/// The Export step of owner review 1 (R3) in both themes: Output and File folded to their summary lines, Encoding and
/// Playback open on a boomerang played twice with fades, scrolled down to Playback's last row (<c>edit-export-playback</c>),
/// undone after with the groups as they were; then the header's Render ▾ menu dropped down over the Export step
/// (<c>edit-render-menu</c>).
/// </summary>
private static async Task<int> CaptureExportAsync(MainWindow window, EditorViewModel editor, string directory)
{
var written = 0;
var session = editor.Session;
var export = editor.Tabs.OfType<ExportTab>().Single();
var frame = editor.CurrentIndex;
foreach (var theme in Themes)
{
ThemeManager.Apply(theme);
editor.SelectedTab = export;
editor.IsCompare = false;
editor.CurrentIndex = 40;
var open = OpenGroups(export, export.EncodingGroup, export.PlaybackGroup);
var played = session.Edit(SampleData.Boomerang);
await Settle(window);
// The panel ends with Playback's last row: scrolled down to it, with as much of Encoding as fits above.
var panel = ScrollerOf<SettingGroup>(window);
panel?.ScrollToBottom();
written += await SaveEditorAsync(window, editor, directory, "edit-export-playback", theme);
panel?.ScrollToTop();
if (played) session.Undo();
RestoreGroups(export, open);
await Settle(window);
if (!await editor.WhenIdleAsync(TimeSpan.FromSeconds(30))) Log.Warning("capture", "edit-render-menu was still busy");
written += await SaveRenderMenuAsync(window, editor, directory, theme);
}
// The scenes after keep the frame they had.
editor.CurrentIndex = frame;
return written;
}
private static SettingGroup[] GroupsOf(ExportTab export) => [export.OutputGroup, export.EncodingGroup, export.PlaybackGroup, export.FileGroup];
/// <summary>Opens the Export step's groups <paramref name="open"/> and folds the others; returns which were open, for <see cref="RestoreGroups"/>.</summary>
private static bool[] OpenGroups(ExportTab export, params SettingGroup[] open)
{
var groups = GroupsOf(export);
var before = groups.Select(g => g.IsExpanded).ToArray();
foreach (var group in groups) group.IsExpanded = open.Contains(group);
return before;
}
/// <summary>The Export step's groups open or folded as <see cref="OpenGroups"/> found them (the app keeps them for the next run).</summary>
private static void RestoreGroups(ExportTab export, bool[] open)
{
var groups = GroupsOf(export);
for (var i = 0; i < groups.Length; i++) groups[i].IsExpanded = open[i];
}
/// <summary>
/// The window with the header's Render ▾ menu dropped down below its button, as the menu shows it. A context menu opens
/// in a popup of its own, on screen, which the window's picture does not hold: the menu is made from the same entries
/// (<see cref="SplitButton.CreateItem"/>), laid out apart and drawn over the window where it drops down (kept inside the
/// window, as Windows keeps it on the screen).
/// </summary>
private static async Task<int> SaveRenderMenuAsync(MainWindow window, EditorViewModel editor, string directory, AppTheme theme)
{
await Settle(window);
if (FindVisual<SplitButton>(window, b => b.Name == "RenderButton") is not { } button)
{
Log.Warning("capture", "The Render button is not shown; edit-render-menu skipped");
return 0;
}
var menu = new ContextMenu { FlowDirection = window.FlowDirection };
var template = button.TryFindResource(SplitButton.ItemTemplateKey) as DataTemplate;
foreach (var entry in editor.RenderMenuItems) menu.Items.Add(SplitButton.CreateItem(entry, template));
menu.Measure(new Size(double.PositiveInfinity, double.PositiveInfinity));
menu.Arrange(new Rect(menu.DesiredSize));
menu.UpdateLayout();
await window.Dispatcher.InvokeAsync(() => { }, DispatcherPriority.ApplicationIdle);
menu.UpdateLayout();
var root = (FrameworkElement)VisualTreeHelper.GetChild(window, 0);
// Below the button, 4 px apart (SplitButton's placement), its left edge on the button's.
var at = button.TranslatePoint(new Point(0, button.ActualHeight + 4), root);
at = new Point(Math.Round(Math.Clamp(at.X, 0, Math.Max(0, root.ActualWidth - menu.ActualWidth))), Math.Round(at.Y));
return Save(window, Path.Combine(directory, $"edit-render-menu-{theme.ToString().ToLowerInvariant()}.png"), (menu, at)) ? 1 : 0;
}
/// <summary>The first shown element of type <typeparamref name="T"/> under <paramref name="root"/> that <paramref name="match"/> takes; null when none.</summary>
private static T? FindVisual<T>(DependencyObject root, Func<T, bool> match)
where T : FrameworkElement
{
var pending = new Stack<DependencyObject>([root]);
while (pending.Count > 0)
{
var node = pending.Pop();
if (node is T { IsVisible: true } found && match(found)) return found;
for (var i = 0; i < VisualTreeHelper.GetChildrenCount(node); i++) pending.Push(VisualTreeHelper.GetChild(node, i));
}
return null;
}
/// <summary>The scroll viewer around the shown row whose data is a <typeparamref name="TRow"/>; null when none is shown.</summary>
private static ScrollViewer? ScrollerOf<TRow>(DependencyObject root)
{
@@ -455,7 +598,10 @@ public static class ScreenCapture
written += await SaveEditorAsync(window, editor, directory, "edit-remote", theme);
editor.SelectedTab = export;
editor.IsCompare = false;
// The server's encoder is the Encoding group's first row, the folder it keeps the renders in the File group's.
var groups = OpenGroups(export, export.EncodingGroup, export.FileGroup);
written += await SaveEditorAsync(window, editor, directory, "edit-remote-export", theme);
RestoreGroups(export, groups);
}
sample.RunServerRender();
@@ -522,7 +668,8 @@ public static class ScreenCapture
window.UpdateLayout();
}
private static bool Save(Window window, string path)
/// <param name="overlay">An element laid out apart (a drop-down menu) drawn over the window with its top left at the point given.</param>
private static bool Save(Window window, string path, (FrameworkElement Element, Point At)? overlay = null)
{
if (VisualTreeHelper.GetChildrenCount(window) == 0) window.ApplyTemplate();
if (VisualTreeHelper.GetChildrenCount(window) == 0)
@@ -542,8 +689,24 @@ public static class ScreenCapture
var bitmap = new RenderTargetBitmap(width, height, dpi.PixelsPerInchX, dpi.PixelsPerInchY, PixelFormats.Pbgra32);
// A right-to-left window's content already renders mirrored, as on screen.
bitmap.Render(root);
BitmapSource picture = bitmap;
if (overlay is ({ } element, var at))
{
var layer = new RenderTargetBitmap((int)Math.Ceiling(element.ActualWidth * dpi.DpiScaleX), (int)Math.Ceiling(element.ActualHeight * dpi.DpiScaleY),
dpi.PixelsPerInchX, dpi.PixelsPerInchY, PixelFormats.Pbgra32);
layer.Render(element);
var drawing = new DrawingVisual();
using (var context = drawing.RenderOpen())
{
context.DrawImage(bitmap, new Rect(0, 0, width / dpi.DpiScaleX, height / dpi.DpiScaleY));
context.DrawImage(layer, new Rect(at, new Size(layer.PixelWidth / dpi.DpiScaleX, layer.PixelHeight / dpi.DpiScaleY)));
}
var composed = new RenderTargetBitmap(width, height, dpi.PixelsPerInchX, dpi.PixelsPerInchY, PixelFormats.Pbgra32);
composed.Render(drawing);
picture = composed;
}
var encoder = new PngBitmapEncoder();
encoder.Frames.Add(BitmapFrame.Create(bitmap));
encoder.Frames.Add(BitmapFrame.Create(picture));
using var stream = File.Create(path);
encoder.Save(stream);
return true;