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

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:
Alby96andClaude Opus 5.5 authored and Alby96 committed 2026-11-05 01:09:09 +01:00
1 parent db389a54f2
commit 188b2c2e55
355 files changed
+10549 -1061

No files matched your search

@@ -1,3 +1,4 @@
using Chronos.Core.Imaging.Geometry;
using Chronos.Testing;
using Chronos.Ui.Visuals;
@@ -69,4 +70,75 @@ public sealed class ViewportMathTests
Assert.Approximately(Math.Round(10.4 * 1.5), t.OffsetX * 1.5, 1e-9);
Assert.Approximately(Math.Round(-3.1 * 1.5), t.OffsetY * 1.5, 1e-9);
}
[Test]
public void ACropPressTakesAHandleWithinTheGripThenTheInsideAtEveryZoom()
{
// A 400×300 image with the box [0.25, 0.2, 0.5, 0.6]: the grip is 6 view units whatever the zoom.
var crop = new RectD(0.25, 0.2, 0.5, 0.6);
foreach (var view in new[] { new ViewTransform(0.25, 40, 10), new ViewTransform(1, -30, 5), new ViewTransform(4, -500, -300) })
{
CropHandle Hit(double nx, double ny, double dx, double dy)
{
var (x, y) = view.ToView(nx * 400, ny * 300);
return ViewportMath.HitCrop(view, 400, 300, crop, x + dx, y + dy, 6);
}
var zoom = $"scale {view.Scale}";
Assert.Equal(CropHandle.TopLeft, Hit(0.25, 0.2, -5, 4), zoom);
Assert.Equal(CropHandle.BottomRight, Hit(0.75, 0.8, 6, -6), zoom);
Assert.Equal(CropHandle.Top, Hit(0.5, 0.2, 3, -2), zoom);
Assert.Equal(CropHandle.Left, Hit(0.25, 0.5, 2, 0), zoom);
Assert.Equal(CropHandle.Inside, Hit(0.25, 0.5, 0, 7), "beside a handle, inside the box: a move");
Assert.Equal(CropHandle.None, Hit(0.25, 0.5, -7, 0), "outside the box and the grip: a pan");
Assert.Equal(CropHandle.Inside, Hit(0.5, 0.5, 0, 0), zoom);
Assert.Equal(CropHandle.None, Hit(0.1, 0.1, 0, 0), zoom);
}
Assert.Equal(CropHandle.None, ViewportMath.HitCrop(new ViewTransform(0, 0, 0), 400, 300, crop, 0, 0, 6), "no view yet");
}
[Test]
public void TheNearestHandleWinsOnATinyBox()
{
// At 1/4 zoom a box of 40×30 image pixels is 10×7.5 view units: every handle is within the grip of the centre.
var view = new ViewTransform(0.25, 0, 0);
var crop = new RectD(0.45, 0.45, 0.1, 0.1);
var (x, y) = view.ToView(0.55 * 400, 0.55 * 300);
Assert.Equal(CropHandle.BottomRight, ViewportMath.HitCrop(view, 400, 300, crop, x - 1, y - 1, 6));
var (cx, cy) = view.ToView(0.5 * 400, 0.45 * 300);
Assert.Equal(CropHandle.Top, ViewportMath.HitCrop(view, 400, 300, crop, cx, cy + 0.5, 6));
}
[Test]
public void TheHandlesSitOnTheCornersAndTheEdgeMidpoints()
{
var crop = new RectD(0.1, 0.2, 0.4, 0.6);
Assert.Count(8, ViewportMath.CropHandles);
Assert.Within(0.1, 0.2, ViewportMath.HandleAt(crop, CropHandle.TopLeft).X, ViewportMath.HandleAt(crop, CropHandle.TopLeft).Y, 1e-12);
Assert.Within(0.3, 0.8, ViewportMath.HandleAt(crop, CropHandle.Bottom).X, ViewportMath.HandleAt(crop, CropHandle.Bottom).Y, 1e-12);
Assert.Within(0.5, 0.5, ViewportMath.HandleAt(crop, CropHandle.Right).X, ViewportMath.HandleAt(crop, CropHandle.Right).Y, 1e-12);
Assert.Within(0.3, 0.5, ViewportMath.HandleAt(crop, CropHandle.Inside).X, ViewportMath.HandleAt(crop, CropHandle.Inside).Y, 1e-12);
}
[Test]
public void PlusAndMinusResizeAboutTheCentreLockedAndWithinTheLimits()
{
const double ratio = 0.5;
var largest = CropFrame.Largest(ratio);
var box = CropFrame.FromRows(0.5, 0, 0, ratio);
var grown = ViewportMath.ResizeCrop(box, 0.02, ratio);
Assert.Approximately(box.Height + 0.02 * largest.Height, grown.Height, 1e-12);
Assert.Approximately(ratio, grown.Width / grown.Height, 1e-12);
Assert.Within(box.CenterX, box.CenterY, grown.CenterX, grown.CenterY, 1e-12);
var smallest = CropFrame.FromRows(CropFrame.MinimumShare, 0, 0, ratio);
Assert.Approximately(smallest.Height, ViewportMath.ResizeCrop(smallest, -0.02, ratio).Height, 1e-12, "not below the minimum");
var whole = ViewportMath.ResizeCrop(largest, 0.02, ratio);
Assert.Approximately(largest.Height, whole.Height, 1e-12, "not beyond the largest box");
// At an edge the grown box moves back inside the view.
var corner = CropFrame.FromRows(0.9, 1, 1, ratio);
var pushed = ViewportMath.ResizeCrop(corner, 0.08, ratio);
Assert.LessOrEqual(pushed.Right, 1 + 1e-12);
Assert.LessOrEqual(pushed.Bottom, 1 + 1e-12);
}
}