feat(editor): step controls for orientation, crop, look and output size

Owner review 1 asked for the Camera step to frame the picture the way the
mockup does, so the step now offers Aspect, Rotation (icon buttons), Mirror
and Flip switches, Straighten, Crop size, Crop X and Crop Y, and Reset
framing. Cropping by margins is gone: the crop box is now held to the chosen
aspect.

- EditorSession gains Orient and ResetFraming. Edit and Optimise refit a
  box that was already held to the aspect whenever the aspect or the export
  box changes, and do it in the same undo step. A crop from an older project
  that was placed by offsets is left for the render to fit.
- Straighten drives the preview's grid through the new SliderActivity
  attached behaviour, which a NumberRow switches on with ShowsGrid.
- Exposure gains a Look group with Filter and Strength. A newer project's
  extra look data is kept as it is.
- Export: Width and Height now edit the preset's own box, and a new Output
  size row shows the size after the chosen proportions are applied, marked
  Capped when the encoder shrinks it. ExportPlan carries OutputSize and
  EncodedSize.
- New SwitchRow, IconActionsRow and GroupRow rows with their panel
  templates.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Alby96andClaude Opus 5.5 committed 2026-11-04 20:24:03 +01:00
1 parent aaf9c0bba7
commit 7413b72ecc
14 files changed
+1030 -100

No files matched your search

@@ -1,6 +1,7 @@
using Chronos.App.Editor;
using Chronos.Core.Advice;
using Chronos.Core.Export;
using Chronos.Core.Localization;
using Chronos.Core.Project;
using Chronos.Core.Video;
using Chronos.Core.Video.Managed;
@@ -90,4 +91,57 @@ public sealed class ExportPlannerTests
Assert.Equal("Custom", plan.PresetName);
Assert.Equal(48, plan.Setup.Encoder.Settings.Width);
}
/// <summary>An H.264 encoder that takes at most <paramref name="maxWidth"/>×<paramref name="maxHeight"/> (either way round).</summary>
private sealed class H264Provider(int maxWidth, int maxHeight) : IVideoEncoderProvider
{
public string Name => "h264";
public IReadOnlyList<EncoderCapability> Capabilities { get; } = [new(VideoCodec.H264, "Test H.264", false, maxWidth, maxHeight, false)];
public bool CanEncode(EncodeSettings settings) => settings.Codec == VideoCodec.H264;
public IVideoEncoderSession Open(EncodeSettings settings) => throw new NotSupportedException("Planning never encodes.");
}
private static ProjectSettings FourKAt(string aspect)
{
var project = new ProjectSettings();
return project with
{
Camera = project.Camera with { Aspect = project.Camera.Aspect.WithManual(aspect) },
Export = project.Export with { Preset = project.Export.Preset.WithManual("4k-h264") },
};
}
[Test]
public void TheChosenProportionsWinAndThePresetKeepsItsName()
{
var planner = new ExportPlanner(Content, [new H264Provider(4096, 2304)], EncoderHost.Client);
var plan = planner.Plan(FourKAt("9:16"))!;
Assert.Equal((2160, 3840), plan.OutputSize, "4K at 9:16");
Assert.Equal((2160, 3840), plan.EncodedSize, "the encoder takes it turned");
Assert.False(plan.IsCapped);
Assert.Equal("2160 × 3840", ExportTab.OutputSizeOf(plan));
Assert.Equal(Loc.L("Tooltips.Editor.Export.OutputSize"), ExportTab.OutputSizeToolTipOf(plan));
Assert.Equal(Loc.L("Export.Preset.4kH264"), plan.PresetName, "the preset is not made Custom");
Assert.False(plan.Export.IsCustom);
Assert.Equal((3840, 2160), (plan.Export.Width, plan.Export.Height), "Width × Height stay the preset's box");
var workload = plan.Setup.Workload();
Assert.Equal((2160, 3840), (workload.Width, workload.Height), "the estimate is of the adapted size");
var source = planner.Plan(FourKAt("source"))!;
Assert.Equal((3840, 2160), source.OutputSize, "source keeps the preset's ratio");
}
[Test]
public void AnOutputTheEncoderShrinksIsMarkedCapped()
{
var plan = new ExportPlanner(Content, [new H264Provider(1920, 1080)], EncoderHost.Client).Plan(FourKAt("9:16"))!;
Assert.Equal((2160, 3840), plan.OutputSize);
Assert.Equal((1080, 1920), plan.EncodedSize);
Assert.True(plan.IsCapped);
Assert.Equal(Loc.L("Editor.Export.Capped", "1080 × 1920"), ExportTab.OutputSizeOf(plan));
Assert.Equal(Loc.L("Tooltips.Editor.Export.OutputCapped", "1080 × 1920"), ExportTab.OutputSizeToolTipOf(plan), "the largest size it takes, turned");
}
}