feat(editor): visual crop, rotate/mirror/flip/straighten, colour looks (owner review 1 phase 4) (#26)
CI / Build and test (push) Successful in 8m19s
CI / Windows tests and installer (push) Skipped
CI / YAML check (push) Successful in 7s
Release / Build, test and publish (push) Successful in 12m9s
CI / PostgreSQL 16 integration (push) Successful in 7m49s
CI / PostgreSQL 17 integration (push) Successful in 7m19s
CI / Docker image (push) Successful in 46s
Release / Server image (push) Successful in 1m14s
CI / Build and test (push) Successful in 8m19s
CI / Windows tests and installer (push) Skipped
CI / YAML check (push) Successful in 7s
Release / Build, test and publish (push) Successful in 12m9s
CI / PostgreSQL 16 integration (push) Successful in 7m49s
CI / PostgreSQL 17 integration (push) Successful in 7m19s
CI / Docker image (push) Successful in 46s
Release / Server image (push) Successful in 1m14s
Owner review 1 R5 + R6. Camera rotation, mirror, flip, straighten and crop handles locked to the output; an Exposure Look group; Export output size ("proportions win"); settings format 2 with older-node gates. Also fixes project text and hashes differing between Windows and Linux.
Closes #19
Closes #20
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 #26.
This commit is contained in:
1 parent
db389a54f2
commit
188b2c2e55
355 files changed
+10549
-1061
No files matched your search
@@ -21,6 +21,102 @@ public sealed class ProjectMergeTests
|
||||
private static PendingFrame Waiting(FramePhoto photo, bool excluded = false, bool hero = false) =>
|
||||
new() { Sha256 = photo.Sha256, Size = photo.Size, CapturedAt = photo.CapturedAt, Excluded = excluded, Hero = hero };
|
||||
|
||||
[Test]
|
||||
public void ATurnOnOneSideAndALookOnTheOtherMergeIntoFormatTwo()
|
||||
{
|
||||
var basis = new ProjectSettings { Exposure = new ExposureSettings { ExposureOffsetEv = 0.2 } };
|
||||
var ours = basis with { Camera = basis.Camera with { Rotate = 90, Straighten = 1.5 } };
|
||||
var theirs = basis with { Look = new LookSettings { Filter = "sepia", Strength = 0.6 } };
|
||||
|
||||
var result = ProjectMerge.MergeWithConflicts(basis, ours, theirs);
|
||||
|
||||
Assert.False(result.HasConflicts);
|
||||
Assert.Equal((90, 1.5), (result.Merged.Camera.Rotate, result.Merged.Camera.Straighten));
|
||||
Assert.Equal("sepia", result.Merged.Look?.Filter);
|
||||
Assert.Equal(2, result.Merged.Version);
|
||||
Assert.Contains("\"version\": 2", result.Merged.ToJson());
|
||||
|
||||
// One side takes the turn away while the other keeps the look: the format the members need, not the one taken.
|
||||
var undone = ProjectMerge.MergeWithConflicts(result.Merged, result.Merged with { Camera = basis.Camera }, result.Merged with { Look = null }).Merged;
|
||||
Assert.Equal(1, ProjectContent.FormatOf(undone.ToJson()));
|
||||
Assert.Equal(basis.ToJson(), undone.ToJson());
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void BothSidesCroppingGiveOneCropConflict()
|
||||
{
|
||||
var basis = new ProjectSettings { Camera = new CameraSettings { Aspect = new Auto<string>().WithManual("9:16") } };
|
||||
var ours = basis with { Camera = basis.Camera with { Crop = [0.1, 0, 0.3, 0.9] } };
|
||||
var theirs = basis with { Camera = basis.Camera with { Crop = [0.5, 0.05, 0.2, 0.6] } };
|
||||
|
||||
var result = ProjectMerge.MergeWithConflicts(basis, ours, theirs);
|
||||
|
||||
// The box is one value: never the x of one side and the width of the other.
|
||||
Assert.SequenceEqual(["camera.crop"], result.Conflicts.Select(c => c.Path));
|
||||
Assert.SequenceEqual([0.1, 0, 0.3, 0.9], Assert.NotNull(result.Merged.Camera.Crop));
|
||||
Assert.SequenceEqual([0.5, 0.05, 0.2, 0.6], Assert.NotNull(
|
||||
ProjectMerge.MergeWithConflicts(basis, ours, theirs, new HashSet<string> { "camera.crop" }).Merged.Camera.Crop));
|
||||
|
||||
// With a mirror on their side too, the crop and the mirror are one conflict: their crop is in the mirrored frame.
|
||||
var mirrored = theirs with { Camera = theirs.Camera with { Mirror = true } };
|
||||
var coupled = ProjectMerge.MergeWithConflicts(basis, ours, mirrored);
|
||||
Assert.SequenceEqual(["camera.mirror"], coupled.Conflicts.Select(c => c.Path));
|
||||
Assert.SequenceEqual([0.1, 0, 0.3, 0.9], Assert.NotNull(coupled.Merged.Camera.Crop), "ours: our crop");
|
||||
Assert.False(coupled.Merged.Camera.Mirror, "and unmirrored");
|
||||
var taken = ProjectMerge.MergeWithConflicts(basis, ours, mirrored, new HashSet<string> { "camera.mirror" }).Merged;
|
||||
Assert.SequenceEqual([0.5, 0.05, 0.2, 0.6], Assert.NotNull(taken.Camera.Crop));
|
||||
Assert.True(taken.Camera.Mirror);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// A turn of a project without a crop changes only the orientation and the aspect (nothing else to move), so member by
|
||||
/// member a crop or keyframes the other side placed in the unturned frame would apply to the turned one: one conflict.
|
||||
/// </summary>
|
||||
[Test]
|
||||
public void ATurnOnOneSideAndAFramingOnTheOtherAreOneConflict()
|
||||
{
|
||||
var basis = new ProjectSettings { Camera = new CameraSettings { Aspect = new Auto<string>().WithManual("16:9") } };
|
||||
var turned = basis with { Camera = Chronos.Core.Imaging.Geometry.OrientationEdit.Apply(basis.Camera, Chronos.Core.Imaging.Geometry.OrientationOp.RotateRight) };
|
||||
Assert.Null(turned.Camera.Crop);
|
||||
var cropped = basis with { Camera = basis.Camera with { Crop = [0.1, 0.2, 0.6, 0.3375] } };
|
||||
|
||||
foreach (var (ours, theirs) in new[] { (turned, cropped), (cropped, turned) })
|
||||
{
|
||||
var result = ProjectMerge.MergeWithConflicts(basis, ours, theirs);
|
||||
Assert.SequenceEqual(["camera.rotate"], result.Conflicts.Select(c => c.Path));
|
||||
Assert.Equal(ours.ToJson(), result.Merged.ToJson(), "ours whole: the orientation and the framing of one side");
|
||||
var other = ProjectMerge.MergeWithConflicts(basis, ours, theirs, new HashSet<string> { "camera.rotate" }).Merged;
|
||||
Assert.Equal(theirs.ToJson(), other.ToJson());
|
||||
}
|
||||
|
||||
// Keyframes placed in the unturned frame, on the camera and on a photo that waits.
|
||||
var keyed = basis with
|
||||
{
|
||||
Camera = basis.Camera with { Keyframes = [new CameraKey(0, 0.8, 0.5, 2, 0)] },
|
||||
};
|
||||
Assert.SequenceEqual(["camera.rotate"], ProjectMerge.MergeWithConflicts(basis, turned, keyed).Conflicts.Select(c => c.Path));
|
||||
var photo = Photo(1);
|
||||
var waiting = basis with { PendingFrames = [Waiting(photo) with { Keyframes = [new CameraKey(0, 0.8, 0.5, 2, 0)] }] };
|
||||
Assert.SequenceEqual(["camera.rotate"], ProjectMerge.MergeWithConflicts(basis, waiting, turned).Conflicts.Select(c => c.Path));
|
||||
|
||||
// Anything else on the other side merges with the turn as before.
|
||||
var brighter = basis with { Exposure = basis.Exposure with { ExposureOffsetEv = 0.3 } };
|
||||
var merged = ProjectMerge.MergeWithConflicts(basis, turned, brighter);
|
||||
Assert.False(merged.HasConflicts);
|
||||
Assert.Equal((90, 0.3), (merged.Merged.Camera.Rotate, merged.Merged.Exposure.ExposureOffsetEv));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void AFormatThreeSideIsNeverMerged()
|
||||
{
|
||||
var basis = new ProjectSettings { Camera = new CameraSettings { Rotate = 90 } };
|
||||
var newer = ProjectSettings.FromJson("""{ "version": 3, "camera": { "rotate": 180 }, "look": { "filter": "film" } }""", allowNewer: true);
|
||||
var mine = basis with { Look = new LookSettings { Filter = "warm" } };
|
||||
Assert.Throws<NewerSettingsException>(() => ProjectMerge.MergeWithConflicts(basis, mine, newer));
|
||||
Assert.Throws<NewerSettingsException>(() => ProjectMerge.MergeWithConflicts(basis, newer, mine));
|
||||
Assert.Equal(3, ProjectMerge.MergeWithConflicts(basis, basis, newer).Merged.Version);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void EntriesOfOnePhotoMergeAsOneWithThePositionsOfBoth()
|
||||
{
|
||||
@@ -69,7 +165,7 @@ public sealed class ProjectMergeTests
|
||||
public void SettingsOfANewerChronosAreNeverMergedWithThisOnes()
|
||||
{
|
||||
var basis = new ProjectSettings { Exposure = new ExposureSettings { ExposureOffsetEv = 0.1 } };
|
||||
var newer = ProjectSettings.FromJson("""{ "version": 2, "exposure": { "exposureOffsetEv": 0.5 }, "grade": { "look": "film" } }""", allowNewer: true);
|
||||
var newer = ProjectSettings.FromJson("""{ "version": 3, "exposure": { "exposureOffsetEv": 0.5 }, "grade": { "look": "film" } }""", allowNewer: true);
|
||||
var mine = basis with { Stack = new StackSettings { Mode = StackSetting.Median } };
|
||||
|
||||
// Both changed: refused, whichever side the newer one is, in a replay too.
|
||||
|
||||
Reference in new issue
Block a user