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:
1 parent
aaf9c0bba7
commit
7413b72ecc
14 files changed
+1030
-100
No files matched your search
@@ -1,7 +1,9 @@
|
||||
using Chronos.Core.Advice;
|
||||
using Chronos.Core.Diagnostics;
|
||||
using Chronos.Core.Export;
|
||||
using Chronos.Core.Imaging.Geometry;
|
||||
using Chronos.Core.Project;
|
||||
using Chronos.Core.Render;
|
||||
using Chronos.Core.Video;
|
||||
using Chronos.Data.Archiving.Jobs;
|
||||
using Chronos.Data.Processing;
|
||||
@@ -109,12 +111,81 @@ public sealed class EditorSession : IAsyncDisposable
|
||||
/// </summary>
|
||||
public ProjectConflictException? Conflict { get; private set; }
|
||||
|
||||
/// <summary>Applies <paramref name="change"/> as an undoable step; false when it changes nothing.</summary>
|
||||
/// <summary>
|
||||
/// Applies <paramref name="change"/> as an undoable step; false when it changes nothing. A crop box locked to the
|
||||
/// output proportions follows a change of them (<see cref="KeepCropLocked"/>) in the same step.
|
||||
/// </summary>
|
||||
/// <param name="mergeKey">Consecutive edits with the same key are one undo step (a slider drag).</param>
|
||||
public bool Edit(Func<ProjectSettings, ProjectSettings> change, string? mergeKey = null)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(change);
|
||||
return !IsReadOnly && History.Apply(change(Project), mergeKey);
|
||||
if (IsReadOnly) return false;
|
||||
var before = Project;
|
||||
return History.Apply(KeepCropLocked(before, change(before), Content.SourceWidth, Content.SourceHeight), mergeKey);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// One press of the Camera step's orientation controls (Rotate left or right, Mirror, Flip) as one undo step: the
|
||||
/// picture turns or mirrors as the user sees it, and the crop and the keyframes with it (<see cref="OrientationEdit"/>,
|
||||
/// owner review 1, R6).
|
||||
/// </summary>
|
||||
public bool Orient(OrientationOp op) => Edit(p => OrientationEdit.Apply(p, op));
|
||||
|
||||
/// <summary>
|
||||
/// "Reset framing": the crop, its offsets, the rotation, mirror, flip and straighten cleared as one undo step; the
|
||||
/// keyframes stay (<see cref="WithoutFraming"/>).
|
||||
/// </summary>
|
||||
public bool ResetFraming() => Edit(WithoutFraming);
|
||||
|
||||
/// <summary>The crop's width over its height in normalised view units for <paramref name="project"/> (<see cref="LockRatioOf"/>).</summary>
|
||||
public double CropLockRatio(ProjectSettings project) => LockRatioOf(project, Content.SourceWidth, Content.SourceHeight);
|
||||
|
||||
/// <summary>
|
||||
/// The lock ratio of the Camera step's crop (<see cref="RenderGeometry.LockRatio"/>): the output ratio the render fits
|
||||
/// the crop to, in units of the view frame of a source of the given size; a 1×1 view when the size is unknown.
|
||||
/// </summary>
|
||||
public static double LockRatioOf(ProjectSettings project, int sourceWidth, int sourceHeight)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(project);
|
||||
var (width, height) = sourceWidth > 0 && sourceHeight > 0 ? (sourceWidth, sourceHeight) : (1, 1);
|
||||
return RenderGeometry.Create(project.Camera, ExportResolver.Resolve(project.Export), width, height).LockRatio;
|
||||
}
|
||||
|
||||
/// <summary>The project without framing: no crop, no offsets, no rotation, mirror, flip or straighten; keyframes and the aspect stay.</summary>
|
||||
public static ProjectSettings WithoutFraming(ProjectSettings project)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(project);
|
||||
return project with { Camera = project.Camera with { Crop = null, OffsetX = 0, OffsetY = 0, Rotate = 0, Mirror = false, Flip = false, Straighten = 0 } };
|
||||
}
|
||||
|
||||
/// <summary>Something <see cref="ResetFraming"/> clears is set.</summary>
|
||||
public static bool HasFraming(CameraSettings camera)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(camera);
|
||||
return camera.Crop is not null || camera.OffsetX != 0 || camera.OffsetY != 0 || camera.Rotate != 0 || camera.Mirror || camera.Flip || camera.Straighten != 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// <paramref name="after"/> with its crop refitted to new output proportions (owner review 1, R5: an aspect change, a
|
||||
/// turn of a "source" aspect, an export preset of another shape): a box that was locked to the proportions before keeps
|
||||
/// its centre and area at the new ratio (<see cref="CropFrame.Refit"/>). A legacy free crop, one placed by offsets, and a
|
||||
/// box already at the new ratio stay as they are (the render fits them, <see cref="AspectRatio.FitCrop"/>).
|
||||
/// </summary>
|
||||
public static ProjectSettings KeepCropLocked(ProjectSettings before, ProjectSettings after, int sourceWidth, int sourceHeight)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(before);
|
||||
ArgumentNullException.ThrowIfNull(after);
|
||||
var camera = after.Camera;
|
||||
if (CropFrame.IsWhole(camera.Crop) || camera.OffsetX != 0 || camera.OffsetY != 0) return after;
|
||||
if (ReferenceEquals(before.Camera, camera) && ReferenceEquals(before.Export, after.Export)) return after;
|
||||
var ratio = LockRatioOf(after, sourceWidth, sourceHeight);
|
||||
var box = CropFrame.Of(camera.Crop);
|
||||
if (IsLocked(box, ratio)) return after;
|
||||
if (before.Camera.OffsetX != 0 || before.Camera.OffsetY != 0 || !IsLocked(CropFrame.Of(before.Camera.Crop), LockRatioOf(before, sourceWidth, sourceHeight)))
|
||||
return after;
|
||||
return after with { Camera = camera with { Crop = CropFrame.ToCrop(CropFrame.Refit(box, ratio)) } };
|
||||
|
||||
static bool IsLocked(RectD box, double lockRatio) => double.Abs(box.Width / box.Height / lockRatio - 1) < 1e-6;
|
||||
}
|
||||
|
||||
/// <summary>The drag or key press behind a run of merged edits ended (<see cref="ProjectHistory.EndRun"/>).</summary>
|
||||
@@ -148,7 +219,8 @@ public sealed class EditorSession : IAsyncDisposable
|
||||
|
||||
/// <summary>
|
||||
/// Applies a sequence preset (BRIEF §10.3) as one undoable step: its timing, exposure, motion, aspect and export
|
||||
/// preset; the user's frames (exclusions, hero), crop, keyframes, remap curve, exposure offset and output naming stay.
|
||||
/// preset; the user's frames (exclusions, hero), crop (refitted to the preset's aspect), orientation, keyframes, remap
|
||||
/// curve, exposure offset, look and output naming stay.
|
||||
/// </summary>
|
||||
public bool ApplyPreset(SequencePreset preset)
|
||||
{
|
||||
@@ -444,7 +516,7 @@ public sealed class EditorSession : IAsyncDisposable
|
||||
settings = result.Settings;
|
||||
changes.AddRange(result.Changes);
|
||||
}
|
||||
History.Apply(settings);
|
||||
History.Apply(KeepCropLocked(Project, settings, Content.SourceWidth, Content.SourceHeight));
|
||||
return changes;
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user