fix(app): editor review fixes for saving, undo, preview, commands and layout
- Undo/redo snapshots take outside changes (advice, merged edits) on Replace; a drag, click or key press ends a merged run; Reset to Auto is its own step. - A failed save stays pending and is retried with backoff; closing or switching asks before discarding it; the local source throws unless the index took it. - Opening a sequence survives any failure; the window title follows the editor; the job bar hides when idle in the editor. - Render, Add to queue and Batch re-read their state; disabled commands say why; Analyse is disabled while queued and announces its cost and Ctrl+Shift+A. - Preview: 1:1 and wheel zoom render the source's own pixels, the view keeps its place across resolutions, crop mask result mode, unreadable frames say so, labelled tools, keyboard focus on open, tools hidden on Export lose their effect. - Preparation re-solves from measured series (no re-decode per slider step) with a half-precision frame cache. - Exposure flicker and waveform charts, Time plan chart, Camera crop margins, sortable frame table, wrapped findings, responsive preset cards, render-done follow-up, Jobs history filtered on the sequence. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012iLMBNwBE2GnphAsu4cjaC
This commit is contained in:
32 files changed
+1612
-369
No files matched your search
@@ -8,18 +8,34 @@ using Titano.Core.Localization;
|
||||
using Titano.Core.Mathematics;
|
||||
using Titano.Core.Project;
|
||||
using Titano.Ui.Mvvm;
|
||||
using Titano.Ui.Visuals;
|
||||
|
||||
namespace Titano.App.Editor;
|
||||
|
||||
/// <summary>Margins of the free crop, in the order of <c>CameraTab.Margins</c> (opposites differ in the lowest bit).</summary>
|
||||
public enum CropSide
|
||||
{
|
||||
Left,
|
||||
Right,
|
||||
Top,
|
||||
Bottom,
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Camera (BRIEF §12.3): output aspect and crop placement, and virtual-camera keyframes edited as a zoom curve over the
|
||||
/// sequence (X = frame, Y = zoom) with the selected keyframe's framing below.
|
||||
/// Camera (BRIEF §12.3): the free crop of the frame (margins), the output aspect and its placement inside the crop, and
|
||||
/// virtual-camera keyframes edited as a zoom curve over the sequence (X = frame, Y = zoom) with the selected keyframe's
|
||||
/// framing below.
|
||||
/// </summary>
|
||||
public sealed class CameraTab : EditorTab
|
||||
{
|
||||
/// <summary>Zoom at the top of the curve editor.</summary>
|
||||
public const double MaxZoom = 4;
|
||||
|
||||
/// <summary>Largest crop margin; opposite margins together leave at least <see cref="MinCropSize"/> of the frame.</summary>
|
||||
public const double MaxCropMargin = 0.45;
|
||||
|
||||
public const double MinCropSize = 0.1;
|
||||
|
||||
private int _selectedKey = -1;
|
||||
|
||||
public CameraTab(EditorViewModel editor)
|
||||
@@ -28,6 +44,10 @@ public sealed class CameraTab : EditorTab
|
||||
var s = editor.Session;
|
||||
Rows =
|
||||
[
|
||||
CropRow(s, CropSide.Left, "Editor.Camera.CropLeft"),
|
||||
CropRow(s, CropSide.Right, "Editor.Camera.CropRight"),
|
||||
CropRow(s, CropSide.Top, "Editor.Camera.CropTop"),
|
||||
CropRow(s, CropSide.Bottom, "Editor.Camera.CropBottom"),
|
||||
new AutoChoiceRow<string>(s, EditorSettings.Aspect, "Editor.Camera.Aspect", "Tooltips.Editor.Camera.Aspect",
|
||||
[
|
||||
new Choice("source", "Editor.Aspect.Source"), new Choice("16:9", "Editor.Aspect.Ratio", "16:9"), new Choice("21:9", "Editor.Aspect.Ratio", "21:9"),
|
||||
@@ -35,9 +55,9 @@ public sealed class CameraTab : EditorTab
|
||||
new Choice("9:16", "Editor.Aspect.Ratio", "9:16"), new Choice("4:5", "Editor.Aspect.Ratio", "4:5"),
|
||||
]),
|
||||
new NumberRow(s, "Editor.Camera.OffsetX", "Tooltips.Editor.Camera.OffsetX", -1, 1, 0.05, p => p.Camera.OffsetX,
|
||||
(p, v) => p with { Camera = p.Camera with { OffsetX = v } }, Placement),
|
||||
(p, v) => p with { Camera = p.Camera with { OffsetX = v } }, EditorText.Placement),
|
||||
new NumberRow(s, "Editor.Camera.OffsetY", "Tooltips.Editor.Camera.OffsetY", -1, 1, 0.05, p => p.Camera.OffsetY,
|
||||
(p, v) => p with { Camera = p.Camera with { OffsetY = v } }, Placement),
|
||||
(p, v) => p with { Camera = p.Camera with { OffsetY = v } }, EditorText.Placement),
|
||||
];
|
||||
AddKeyCommand = new RelayCommand(AddKey, () => !Editor.IsBusy && Keys.All(k => k.Frame != Editor.CurrentIndex));
|
||||
RemoveKeyCommand = new RelayCommand(RemoveKey, () => !Editor.IsBusy && SelectedKey >= 0);
|
||||
@@ -96,6 +116,12 @@ public sealed class CameraTab : EditorTab
|
||||
|
||||
public ICommand RemoveKeyCommand { get; }
|
||||
|
||||
/// <summary>What Add keyframe does, or why it cannot run now.</summary>
|
||||
public string AddKeyToolTip => Loc.L(Editor.IsBusy ? "Tooltips.Editor.Busy"
|
||||
: Keys.Any(k => k.Frame == Editor.CurrentIndex) ? "Tooltips.Editor.Camera.KeyExists" : "Tooltips.Editor.Camera.AddKey");
|
||||
|
||||
public string RemoveKeyToolTip => Loc.L(Editor.IsBusy ? "Tooltips.Editor.Busy" : HasSelectedKey ? "Tooltips.Editor.Camera.RemoveKey" : "Tooltips.Editor.Camera.NoKey");
|
||||
|
||||
/// <summary>Run by the curve editor after each finished edit.</summary>
|
||||
public ICommand CommitCurveCommand { get; }
|
||||
|
||||
@@ -130,9 +156,38 @@ public sealed class CameraTab : EditorTab
|
||||
Editor.Session.Edit(p => p with { Camera = p.Camera with { Keyframes = [.. keys.DistinctBy(k => k.Frame)] } });
|
||||
}
|
||||
|
||||
public void OnCurrentFrameChanged() => OnPropertyChanged(nameof(Playhead));
|
||||
public override void OnCurrentFrameChanged()
|
||||
{
|
||||
OnPropertyChanged(nameof(Playhead));
|
||||
OnPropertyChanged(nameof(AddKeyToolTip));
|
||||
}
|
||||
|
||||
private static string Placement(double value) => value == 0 ? Loc.L("Editor.Value.Centred") : value.ToString("+0.00;−0.00", Loc.Culture);
|
||||
public override void OnBusyChanged()
|
||||
{
|
||||
base.OnBusyChanged();
|
||||
OnPropertyChanged(nameof(AddKeyToolTip));
|
||||
OnPropertyChanged(nameof(RemoveKeyToolTip));
|
||||
}
|
||||
|
||||
/// <summary>A margin of the free crop (<see cref="CameraSettings.Crop"/>, normalised x, y, width, height); all zero = the whole frame.</summary>
|
||||
private static NumberRow CropRow(EditorSession session, CropSide side, string headerKey) => new(session, headerKey, "Tooltips.Editor.Camera.Crop", 0,
|
||||
MaxCropMargin, 0.01, p => Margins(p.Camera.Crop)[(int)side], (p, v) => p with { Camera = p.Camera with { Crop = WithMargin(p.Camera.Crop, side, v) } },
|
||||
v => Formatting.Percent(v));
|
||||
|
||||
/// <summary>Left, right, top and bottom margins of a crop rectangle.</summary>
|
||||
private static double[] Margins(double[]? crop) => crop is [var x, var y, var w, var h] && new[] { x, y, w, h }.All(double.IsFinite)
|
||||
? [double.Clamp(x, 0, 1), double.Clamp(1 - x - w, 0, 1), double.Clamp(y, 0, 1), double.Clamp(1 - y - h, 0, 1)]
|
||||
: [0, 0, 0, 0];
|
||||
|
||||
private static double[]? WithMargin(double[]? crop, CropSide side, double value)
|
||||
{
|
||||
var margins = Margins(crop);
|
||||
var opposite = (int)side ^ 1;
|
||||
margins[(int)side] = double.Clamp(value, 0, double.Min(MaxCropMargin, 1 - MinCropSize - margins[opposite]));
|
||||
if (margins.All(m => m == 0)) return null;
|
||||
var (left, right, top, bottom) = (margins[0], margins[1], margins[2], margins[3]);
|
||||
return [left, top, 1 - left - right, 1 - top - bottom];
|
||||
}
|
||||
|
||||
private Point ToPoint(CameraKey key) => new(Editor.FrameCount > 1 ? (double)key.Frame / (Editor.FrameCount - 1) : 0, (key.Zoom - 1) / (MaxZoom - 1));
|
||||
|
||||
@@ -166,6 +221,7 @@ public sealed class CameraTab : EditorTab
|
||||
private void OnSelectedKeyChanged()
|
||||
{
|
||||
OnPropertyChanged(nameof(HasSelectedKey));
|
||||
OnPropertyChanged(nameof(RemoveKeyToolTip));
|
||||
OnPropertyChanged(nameof(SelectedCenterX));
|
||||
OnPropertyChanged(nameof(SelectedCenterY));
|
||||
OnPropertyChanged(nameof(SelectedZoom));
|
||||
@@ -175,13 +231,16 @@ public sealed class CameraTab : EditorTab
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Time (BRIEF §12.3): timing mode, playback rate, fit-to duration and the time-remap curve (output time → source
|
||||
/// position, Fritsch–Carlson as the render evaluates it), with the plan in numbers.
|
||||
/// Time (BRIEF §12.3): timing mode, playback rate, fit-to duration, the plan chart (video frames each photo gets, cuts
|
||||
/// marked, the plan in numbers) and the time-remap curve (output time → source position, Fritsch–Carlson as the render
|
||||
/// evaluates it).
|
||||
/// </summary>
|
||||
public sealed class TimeTab : EditorTab
|
||||
{
|
||||
private Func<double, double>? _evaluator;
|
||||
private string? _planText;
|
||||
private IReadOnlyList<ChartSeries> _planSeries = [];
|
||||
private IReadOnlyList<TimelineMarker> _planMarkers = [];
|
||||
|
||||
public TimeTab(EditorViewModel editor)
|
||||
: base(editor, "Time", AdvisorSection.Timing)
|
||||
@@ -216,6 +275,16 @@ public sealed class TimeTab : EditorTab
|
||||
/// <summary>"3,600 frames → 2 min 30 s · 24 fps".</summary>
|
||||
public string? PlanText { get => _planText; private set => Set(ref _planText, value); }
|
||||
|
||||
/// <summary>Video frames each photo is shown for (0 = skipped by a speed-up, gap = excluded), over the sequence.</summary>
|
||||
public IReadOnlyList<ChartSeries> PlanSeries { get => _planSeries; private set => Set(ref _planSeries, value); }
|
||||
|
||||
/// <summary>Cuts of the plan (deliberate pauses, gaps, long exclusion runs).</summary>
|
||||
public IReadOnlyList<TimelineMarker> PlanMarkers { get => _planMarkers; private set => Set(ref _planMarkers, value); }
|
||||
|
||||
public IReadOnlyList<ChartLegendItem> PlanLegend { get; } = [new(Loc.L("Editor.Chart.Shown"), "Brush.Accent")];
|
||||
|
||||
public Func<double, string> PlanFormatter { get; } = v => v.ToString("0.#", Loc.Culture);
|
||||
|
||||
public double Playhead => Editor.FrameCount > 1 ? (double)Editor.CurrentIndex / (Editor.FrameCount - 1) : double.NaN;
|
||||
|
||||
public Func<double, string> XFormatter { get; } = x => Loc.L("Editor.Time.Output", (x * 100).ToString("0", Loc.Culture));
|
||||
@@ -240,11 +309,23 @@ public sealed class TimeTab : EditorTab
|
||||
if (Editor.Plan is not { } plan)
|
||||
{
|
||||
PlanText = null;
|
||||
PlanSeries = [];
|
||||
PlanMarkers = [];
|
||||
return;
|
||||
}
|
||||
var render = plan.Setup.Plan;
|
||||
PlanText = Loc.Plural("Editor.Time.Plan", render.Frames.Count, Formatting.Duration(TimeSpan.FromSeconds(render.DurationSeconds)),
|
||||
EditorText.FrameRate(render.FrameRate));
|
||||
var shown = new double[Editor.FrameCount];
|
||||
Array.Fill(shown, double.NaN);
|
||||
foreach (var index in render.IncludedFrames) shown[index] = 0;
|
||||
foreach (var frame in render.Frames)
|
||||
{
|
||||
var index = int.Clamp((int)double.Round(frame.SourcePosition), 0, shown.Length - 1);
|
||||
shown[index] = (double.IsNaN(shown[index]) ? 0 : shown[index]) + frame.Slots;
|
||||
}
|
||||
PlanSeries = [new ChartSeries(Loc.L("Editor.Chart.Shown"), shown, "Brush.Accent")];
|
||||
PlanMarkers = [.. render.IncludedFrames.Where(render.IsCutBefore).Select(i => new TimelineMarker(i, MarkerKind.Warning, Loc.L("Editor.Marker.Cut")))];
|
||||
}
|
||||
|
||||
/// <summary>The curve editor finished an edit: the points become the remap curve, and the timing mode follows it.</summary>
|
||||
@@ -261,7 +342,7 @@ public sealed class TimeTab : EditorTab
|
||||
});
|
||||
}
|
||||
|
||||
public void OnCurrentFrameChanged() => OnPropertyChanged(nameof(Playhead));
|
||||
public override void OnCurrentFrameChanged() => OnPropertyChanged(nameof(Playhead));
|
||||
|
||||
private static Func<double, double>? Spline(IReadOnlyList<Point> points)
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user