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.
|
||||
|
||||
@@ -327,7 +327,7 @@ public abstract class ProjectRecoveryTests(TestContext context) : DatabaseTest(c
|
||||
var folder = fx.Paths.Sequence(sequence.Folder);
|
||||
|
||||
// A newer Chronos on another PC sharing the archive pushes version 2 in its settings format, and mirrors it.
|
||||
var settings = """{ "version": 2, "exposure": { "exposureOffsetEv": 0.5 }, "futureThing": true }""";
|
||||
var settings = """{ "version": 3, "exposure": { "exposureOffsetEv": 0.5 }, "futureThing": true }""";
|
||||
var now = DateTimeOffset.UtcNow;
|
||||
var future = new ProjectVersion
|
||||
{
|
||||
@@ -339,7 +339,7 @@ public abstract class ProjectRecoveryTests(TestContext context) : DatabaseTest(c
|
||||
ClientName = "newer",
|
||||
SettingsJson = settings,
|
||||
ContentHash = ProjectContent.Hash(settings),
|
||||
SettingsFormat = 2,
|
||||
SettingsFormat = 3,
|
||||
FramesVersion = head.FramesVersion,
|
||||
CreatedAt = now,
|
||||
StoredAt = now,
|
||||
|
||||
@@ -91,6 +91,21 @@ public abstract class ProjectServiceTests(TestContext context) : DatabaseTest(co
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// <paramref name="version"/> as a build on the other OS wrote it before every build wrote LF: its text with the other
|
||||
/// line ends (CRLF for LF, LF for CRLF), hashed as such. Flipped, not made CRLF, so a test means the same on every OS.
|
||||
/// </summary>
|
||||
internal static ProjectVersion Foreign(ProjectVersion version)
|
||||
{
|
||||
var text = Foreign(version.SettingsJson);
|
||||
return version with { SettingsJson = text, ContentHash = ProjectContent.Hash(text) };
|
||||
}
|
||||
|
||||
/// <summary><paramref name="text"/> with the other line ends: LF where it has CRLF, CRLF where it has LF.</summary>
|
||||
internal static string Foreign(string text) => text.Contains("\r\n", StringComparison.Ordinal)
|
||||
? text.Replace("\r\n", "\n", StringComparison.Ordinal)
|
||||
: text.Replace("\n", "\r\n", StringComparison.Ordinal);
|
||||
|
||||
[Test]
|
||||
public async Task MainIsMadeFromTheSequenceSettingsWithItsPositionsParkedByPhoto()
|
||||
{
|
||||
@@ -195,6 +210,33 @@ public abstract class ProjectServiceTests(TestContext context) : DatabaseTest(co
|
||||
Assert.Equal(2, (await projects.HeadAsync(main.Id, fx.Ct)).Number);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task PushesFromAnotherOsAreNoOutsideChange()
|
||||
{
|
||||
var fx = await FixtureAsync();
|
||||
// Hashed photos: only line ends tell the texts apart (no photo named anew to compare by).
|
||||
var (sequence, frames) = await UploadedAsync(fx, 4);
|
||||
Assert.True(frames.All(f => f.Sha256 is { Length: 64 }));
|
||||
var projects = fx.Service.Projects;
|
||||
var main = await projects.MainAsync(sequence.Id, fx.Ct);
|
||||
var first = await projects.HeadAsync(main.Id, fx.Ct);
|
||||
|
||||
// A Windows desktop of a build before pushes to this home: CRLF versions on a home writing LF (and the reverse on Linux).
|
||||
var second = Foreign(Draft(first, new ProjectSettings { ExcludedFrames = [1], HeroFrame = 2 }, frames));
|
||||
Assert.Equal(PushOutcome.Stored, (await projects.PushAsync(main.Id, second, fx.Ct)).Outcome);
|
||||
var third = Foreign(Draft(second, new ProjectSettings { ExcludedFrames = [1, 3], Exposure = new ExposureSettings { ExposureOffsetEv = 0.4 } }, frames));
|
||||
Assert.Equal(PushOutcome.Stored, (await projects.PushAsync(main.Id, third, fx.Ct)).Outcome);
|
||||
Assert.Equal(PushOutcome.AlreadyStored, (await projects.PushAsync(main.Id, third, fx.Ct)).Outcome);
|
||||
|
||||
// The editor's old path writes the same settings again: the mirror of the third version, no outside change.
|
||||
await WriteSettingsAsync(fx, sequence.Id, ProjectSettings.FromJson(ProjectContent.Place(third.SettingsJson, Photos(frames))));
|
||||
var head = await projects.HeadAsync(main.Id, fx.Ct);
|
||||
Assert.Equal((third.Id, 3), (head.Id, head.Number));
|
||||
Assert.Equal(third.ContentHash, head.ContentHash);
|
||||
Assert.SequenceEqual([ProjectVersionKind.Commit, ProjectVersionKind.Commit, ProjectVersionKind.Imported],
|
||||
(await projects.HistoryAsync(main.Id, cancellationToken: fx.Ct)).Select(v => v.Kind));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task SettingsAnotherPathWritesBecomeAnExternalVersionOfMain()
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user