Skip to content

armgit / Filee

Public Imported from GitHub
0

Free, open-source file converter. Convert 263 formats offline by drag & drop — images, PDF, Word, Excel, PowerPoint, HWP/HWPX, video, audio, e-books and archives. No upload, no Office needed.

Prototype: group slices that fan out presets on the donut

SeoJCalive3af7ab9551d9
diff --git a/src/Filee.App/Assets/i18n/en.json b/src/Filee.App/Assets/i18n/en.json
index 5574c844..069cb022 100644
--- a/src/Filee.App/Assets/i18n/en.json
+++ b/src/Filee.App/Assets/i18n/en.json
@@ -36,6 +36,7 @@
"donut.files_same": "{0} × {1}",
"donut.files_mixed": "{0} files",
"donut.drop_to": "Drop → {0}",
+ "donut.pick_in_group": "Move outward to choose",
"donut.click_to": "Click → {0}",
"donut.cancel": "Drop here to cancel",
"donut.close_hint": "Esc to close",
@@ -103,6 +104,13 @@
"preset.half_size": "Half size",
"preset.grayscale": "Grayscale",
"preset.remove_background": "Remove background",
+ "preset.group_rotate": "Rotate",
+ "preset.rotate_left": "Left 90°",
+ "preset.rotate_right": "Right 90°",
+ "preset.rotate_180": "180°",
+ "preset.group_flip": "Flip",
+ "preset.flip_horizontal": "Mirror",
+ "preset.flip_vertical": "Upside down",
"preset.merge_pdf": "Merge PDF",
"preset.split_pdf": "Split PDF",
"preset.long_image": "Long image",
diff --git a/src/Filee.App/Assets/i18n/ko.json b/src/Filee.App/Assets/i18n/ko.json
index e60b3710..5ef8f8f9 100644
--- a/src/Filee.App/Assets/i18n/ko.json
+++ b/src/Filee.App/Assets/i18n/ko.json
@@ -36,6 +36,7 @@
"donut.files_same": "{1} {0}개",
"donut.files_mixed": "파일 {0}개",
"donut.drop_to": "놓으면 {0}(으)로",
+ "donut.pick_in_group": "바깥으로 옮겨 고르세요",
"donut.click_to": "클릭하면 {0}(으)로",
"donut.cancel": "여기에 놓으면 취소",
"donut.close_hint": "Esc로 닫기",
@@ -103,6 +104,13 @@
"preset.half_size": "50% 축소",
"preset.grayscale": "흑백",
"preset.remove_background": "배경 제거",
+ "preset.group_rotate": "회전",
+ "preset.rotate_left": "왼쪽 90°",
+ "preset.rotate_right": "오른쪽 90°",
+ "preset.rotate_180": "180°",
+ "preset.group_flip": "뒤집기",
+ "preset.flip_horizontal": "좌우 반전",
+ "preset.flip_vertical": "상하 반전",
"preset.merge_pdf": "PDF 병합",
"preset.split_pdf": "PDF 분할",
"preset.long_image": "긴 이미지",
diff --git a/src/Filee.App/Assets/i18n/zh-CN.json b/src/Filee.App/Assets/i18n/zh-CN.json
index 6540f1b5..e0123280 100644
--- a/src/Filee.App/Assets/i18n/zh-CN.json
+++ b/src/Filee.App/Assets/i18n/zh-CN.json
@@ -36,6 +36,7 @@
"donut.files_same": "{0} 个 {1}",
"donut.files_mixed": "{0} 个文件",
"donut.drop_to": "松开 → {0}",
+ "donut.pick_in_group": "向外移动以选择",
"donut.click_to": "点击 → {0}",
"donut.cancel": "拖到这里取消",
"donut.close_hint": "按 Esc 关闭",
@@ -103,6 +104,13 @@
"preset.half_size": "缩小 50%",
"preset.grayscale": "灰度",
"preset.remove_background": "去除背景",
+ "preset.group_rotate": "旋转",
+ "preset.rotate_left": "向左 90°",
+ "preset.rotate_right": "向右 90°",
+ "preset.rotate_180": "180°",
+ "preset.group_flip": "翻转",
+ "preset.flip_horizontal": "水平翻转",
+ "preset.flip_vertical": "垂直翻转",
"preset.merge_pdf": "合并 PDF",
"preset.split_pdf": "拆分 PDF",
"preset.long_image": "长图",
diff --git a/src/Filee.App/Controls/DonutGeometry.cs b/src/Filee.App/Controls/DonutGeometry.cs
index a80a77c0..7d3ef46c 100644
--- a/src/Filee.App/Controls/DonutGeometry.cs
+++ b/src/Filee.App/Controls/DonutGeometry.cs
@@ -24,9 +24,13 @@ public enum DonutHitKind
ProgressRing,
/// <summary>The × (cancel) button on the progress ring.</summary>
ProgressCancel,
+
+ /// <summary>A slice of the small ring a group slice fans out; <see cref="DonutHit.Index"/> is the group, <see cref="DonutHit.Sub"/> the slice.</summary>
+ SubSegment,
}
-public readonly record struct DonutHit(DonutHitKind Kind, int Index = -1);
+/// <param name="Sub">With <see cref="DonutHitKind.SubSegment"/>: which of the group's presets.</param>
+public readonly record struct DonutHit(DonutHitKind Kind, int Index = -1, int Sub = -1);
/// <summary>Geometry helpers.</summary>
public static class DonutGeometry
@@ -57,6 +61,36 @@ public static class DonutGeometry
return (int)Math.Floor((angle + span / 2) / span) % count;
}
+ /// <summary>How far a group's fan reaches into each neighbouring slice, as a share of a slice.</summary>
+ public const double SubOverhang = 0.25;
+
+ /// <summary>
+ /// Width of one slice of a group's outer ring: the fan covers the group's slice and a quarter of each neighbour
+ /// (<see cref="SubOverhang"/>), split evenly, so it stays close to the slice it belongs to.
+ /// </summary>
+ public static double SubSpan(double parentSpan, int count) =>
+ count <= 0 ? 0 : parentSpan * (1 + 2 * SubOverhang) / count;
+
+ /// <summary>Centre angle of slice <paramref name="sub"/> of a fan of <paramref name="count"/>, centred on <paramref name="parentMid"/>.</summary>
+ public static double SubMidAngle(double parentMid, int sub, int count, double subSpan) =>
+ parentMid + (sub - (count - 1) / 2.0) * subSpan;
+
+ /// <summary>
+ /// Which slice of a group's fan (between <paramref name="innerRadius"/> and <paramref name="outerRadius"/>) holds
+ /// <paramref name="p"/>, or -1.
+ /// </summary>
+ public static int SubIndexAt(Point center, Point p, double innerRadius, double outerRadius, double parentMid, int count, double subSpan)
+ {
+ var distance = Math.Sqrt(Math.Pow(p.X - center.X, 2) + Math.Pow(p.Y - center.Y, 2));
+ if (count <= 0 || distance < innerRadius || distance > outerRadius)
+ return -1;
+ // Signed angle from the fan's centre, wrapped to -π..π so a fan across 12 o'clock works.
+ var delta = AngleOf(center, p) - parentMid;
+ delta = Math.IEEERemainder(delta, 2 * Math.PI);
+ var sub = (int)Math.Floor(delta / subSpan + count / 2.0);
+ return sub >= 0 && sub < count ? sub : -1;
+ }
+
/// <summary>Classifies a point. <paramref name="slack"/> extends the outer radius to include popped-out slices.</summary>
public static DonutHit HitTest(Point center, Point p, double innerRadius, double outerRadius, int count, double slack = 0)
{
diff --git a/src/Filee.App/Controls/DonutMenu.cs b/src/Filee.App/Controls/DonutMenu.cs
index f01514ba..1620eaad 100644
--- a/src/Filee.App/Controls/DonutMenu.cs
+++ b/src/Filee.App/Controls/DonutMenu.cs
@@ -31,6 +31,14 @@ public sealed class DonutItem
/// <summary>Tooltip shown for disabled slices.</summary>
public string? DisabledReason { get; init; }
+
+ /// <summary>
+ /// A group slice: converts nothing itself; hovering it fans these out in a small ring outside the donut, where they
+ /// are clicked or dropped on like ordinary slices.
+ /// </summary>
+ public IReadOnlyList<DonutItem>? Children { get; init; }
+
+ public bool IsGroup => Children is { Count: > 0 };
}
/// <summary>Donut-shaped menu control.</summary>
@@ -52,6 +60,8 @@ public sealed partial class DonutMenu : Control
AvaloniaProperty.Register<DonutMenu, bool>(nameof(IsEditMode));
public static readonly StyledProperty<bool> AllowContextEditProperty =
AvaloniaProperty.Register<DonutMenu, bool>(nameof(AllowContextEdit));
+ public static readonly StyledProperty<bool> ReserveSubRingProperty =
+ AvaloniaProperty.Register<DonutMenu, bool>(nameof(ReserveSubRing));
public static readonly StyledProperty<IBrush?> SliceBrushProperty =
AvaloniaProperty.Register<DonutMenu, IBrush?>(nameof(SliceBrush), Brushes.White);
@@ -77,6 +87,18 @@ public sealed partial class DonutMenu : Control
private const double OpenStagger = 0.028;
private const double DragStartDistance = 5;
+ /// <summary>Gap between a popped-out slice and the ring a group fans out.</summary>
+ private const double SubGap = 6;
+
+ /// <summary>Thickness of the ring a group fans out.</summary>
+ private const double SubBand = 46;
+
+ /// <summary>Extra room around the donut for the ring a group fans out (and its labels, which reach past it).</summary>
+ public const double SubRingSpace = SubGap + SubBand + 10;
+
+ /// <summary>Width and height of a donut of <paramref name="outerRadius"/>, with room for group rings when asked.</summary>
+ public static double SideFor(double outerRadius, bool subRing) => 2 * (outerRadius + PopOut + 14 + (subRing ? SubRingSpace : 0));
+
// Pencil (Material "edit") path in a 24×24 box.
private static readonly Geometry PencilIcon = Geometry.Parse(
"M3,17.25V21h3.75L17.81,9.94l-3.75-3.75L3,17.25z M20.71,7.04c0.39-0.39,0.39-1.02,0-1.41l-2.34-2.34c-0.39-0.39-1.02-0.39-1.41,0l-1.83,1.83l3.75,3.75L20.71,7.04z");
@@ -107,9 +129,16 @@ public sealed partial class DonutMenu : Control
private string? _previewLabel;
private (int Index, Point Start, PointerPressedEventArgs Args)? _press;
+ // Group slices: the one fanned out (-1 none), the one still drawn while its ring folds away, and the hovered
+ // slice of the ring.
+ private int _expanded = -1;
+ private int _shownExpanded = -1;
+ private int _subHover = -1;
+ private Spring _expand;
+
static DonutMenu()
{
- AffectsMeasure<DonutMenu>(OuterRadiusProperty);
+ AffectsMeasure<DonutMenu>(OuterRadiusProperty, ReserveSubRingProperty);
AffectsRender<DonutMenu>(HoleRatioProperty, SliceOpacityProperty, CenterTitleProperty, CenterSubtitleProperty,
IsEditModeProperty, SliceBrushProperty, SliceBorderBrushProperty, CenterBrushProperty, AccentBrushProperty,
OnAccentBrushProperty, ForegroundProperty, SecondaryForegroundProperty, SuccessBrushProperty);
@@ -135,6 +164,12 @@ public sealed partial class DonutMenu : Control
/// <summary>Live toolbar in click mode: right-click on a slice raises <see cref="SegmentContextRequested"/>.</summary>
public bool AllowContextEdit { get => GetValue(AllowContextEditProperty); set => SetValue(AllowContextEditProperty, value); }
+ /// <summary>
+ /// Leave room for a group's ring even before the slices are known (the drag window is placed before files arrive),
+ /// so the window doesn't grow, and the donut move, when they do.
+ /// </summary>
+ public bool ReserveSubRing { get => GetValue(ReserveSubRingProperty); set => SetValue(ReserveSubRingProperty, value); }
+
public IBrush? SliceBrush { get => GetValue(SliceBrushProperty); set => SetValue(SliceBrushProperty, value); }
public IBrush? SliceBorderBrush { get => GetValue(SliceBorderBrushProperty); set => SetValue(SliceBorderBrushProperty, value); }
public IBrush? CenterBrush { get => GetValue(CenterBrushProperty); set => SetValue(CenterBrushProperty, value); }
@@ -153,6 +188,12 @@ public sealed partial class DonutMenu : Control
/// <summary>A slice was clicked (live toolbar, click mode).</summary>
public event EventHandler<int>? SegmentInvoked;
+ /// <summary>A slice of a group's ring was clicked: (group, slice in the group).</summary>
+ public event EventHandler<(int Group, int Sub)>? SubSegmentInvoked;
+
+ /// <summary>The hovered slice of a group's ring, or -1. <see cref="ActiveIndexChanged"/> is raised when it changes.</summary>
+ public int ActiveSubIndex => _subHover;
+
/// <summary>Right-click or ✎ on a slice.</summary>
public event EventHandler<int>? SegmentContextRequested;
@@ -326,6 +367,14 @@ public sealed partial class DonutMenu : Control
if (IsEditMode && _hoverIndex >= 0 && _hoverIndex < Count &&
Distance(p, EditButtonCenter(_hoverIndex)) <= 13)
return new DonutHit(DonutHitKind.EditButton, _hoverIndex);
+ if (ExpandedChildren is { } children)
+ {
+ var (inner, outer) = SubRadii;
+ var sub = DonutGeometry.SubIndexAt(Center, p, inner, outer, DonutGeometry.MidAngle(_expanded, Count),
+ children.Count, DonutGeometry.SubSpan(DonutGeometry.Span(Count), children.Count));
+ if (sub >= 0)
+ return new DonutHit(DonutHitKind.SubSegment, _expanded, sub);
+ }
return DonutGeometry.HitTest(Center, p, InnerRadius, OuterRadius, Count, PopOut);
}
@@ -333,10 +382,75 @@ public sealed partial class DonutMenu : Control
protected override Size MeasureOverride(Size availableSize)
{
- var side = 2 * (OuterRadius + PopOut + 14);
+ var side = SideFor(OuterRadius, ReserveSubRing || (!IsEditMode && Items?.Any(i => i.IsGroup) == true));
return new Size(side, side);
}
+ // ───────────────────────── Groups ─────────────────────────
+
+ /// <summary>The slices of the group fanned out right now, or null.</summary>
+ private IReadOnlyList<DonutItem>? ExpandedChildren =>
+ !IsEditMode && _expanded >= 0 && _expanded < Count ? Items![_expanded].Children : null;
+
+ private (double Inner, double Outer) SubRadii => (OuterRadius + PopOut + SubGap, OuterRadius + PopOut + SubGap + SubBand);
+
+ /// <summary>
+ /// Fans a group out when its slice is reached and keeps it open while the pointer is on its ring or crossing the
+ /// gap to it; another slice or the hole folds it away.
+ /// </summary>
+ private void TrackGroups(DonutHit hit)
+ {
+ if (IsEditMode)
+ return;
+ var sub = -1;
+ switch (hit.Kind)
+ {
+ case DonutHitKind.Segment:
+ _expanded = hit.Index >= 0 && hit.Index < Count && Items![hit.Index].IsGroup ? hit.Index : -1;
+ break;
+ case DonutHitKind.SubSegment:
+ sub = hit.Sub;
+ break;
+ case DonutHitKind.Outside:
+ break;
+ default:
+ _expanded = -1;
+ break;
+ }
+ if (_expanded >= 0)
+ _shownExpanded = _expanded;
+ if (_subHover != sub)
+ {
+ _subHover = sub;
+ ActiveIndexChanged?.Invoke(this, ActiveIndex);
+ }
+ StartAnimation();
+ }
+
+ /// <summary>True when dropping or clicking at <paramref name="hit"/> converts: a slice that isn't a group, or a slice of a group's ring.</summary>
+ public bool Converts(DonutHit hit) => hit.Kind switch
+ {
+ DonutHitKind.Segment => hit.Index >= 0 && hit.Index < Count && !Items![hit.Index].IsGroup,
+ DonutHitKind.SubSegment => true,
+ _ => false,
+ };
+
+ /// <summary>Folds an open group away (the drag left the window, or files were dropped).</summary>
+ public void CollapseGroup()
+ {
+ _expanded = -1;
+ _subHover = -1;
+ StartAnimation();
+ }
+
+ /// <summary>Highlights what a drag is over from outside: a slice, a slice of a group's ring, or the hole.</summary>
+ public void SetExternalHit(DonutHit hit)
+ {
+ TrackGroups(hit);
+ SetExternalHighlight(hit.Kind is DonutHitKind.Segment or DonutHitKind.SubSegment ? hit.Index : -1,
+ hit.Kind == DonutHitKind.Center);
+ }
+
private void OnItemsChanged()
{
var n = Count;
@@ -352,6 +466,9 @@ public sealed partial class DonutMenu : Control
_previewSpan = default;
_mid = Enumerable.Range(0, n).Select(i => new Spring { Value = DonutGeometry.MidAngle(i, n) }).ToArray();
_span = Enumerable.Range(0, n).Select(_ => new Spring { Value = DonutGeometry.Span(n) }).ToArray();
+ _expanded = _shownExpanded = _subHover = -1;
+ _expand = default;
+ InvalidateMeasure();
InvalidateVisual();
}
@@ -375,9 +492,10 @@ public sealed partial class DonutMenu : Control
}
var hit = HitTest(p);
+ TrackGroups(hit);
SetHover(hit.Kind switch
{
- DonutHitKind.Segment or DonutHitKind.EditButton => hit.Index,
+ DonutHitKind.Segment or DonutHitKind.EditButton or DonutHitKind.SubSegment => hit.Index,
_ => -1,
});
ToolTip.SetTip(this, _hoverIndex >= 0 && Items![_hoverIndex] is { IsEnabled: false } item ? item.DisabledReason : null);
@@ -392,7 +510,10 @@ public sealed partial class DonutMenu : Control
return;
}
if (_press is null)
+ {
+ CollapseGroup();
SetHover(-1);
+ }
}
protected override void OnPointerPressed(PointerPressedEventArgs e)
@@ -448,9 +569,12 @@ public sealed partial class DonutMenu : Control
case DonutHitKind.EditButton:
SegmentContextRequested?.Invoke(this, hit.Index);
break;
- case DonutHitKind.Segment when !IsEditMode && Items![hit.Index].IsEnabled:
+ case DonutHitKind.Segment when !IsEditMode && Items![hit.Index] is { IsEnabled: true, IsGroup: false }:
SegmentInvoked?.Invoke(this, hit.Index);
break;
+ case DonutHitKind.SubSegment when !IsEditMode && Items![hit.Index].Children![hit.Sub].IsEnabled:
+ SubSegmentInvoked?.Invoke(this, (hit.Index, hit.Sub));
+ break;
case DonutHitKind.Center when !IsEditMode:
CenterInvoked?.Invoke(this, EventArgs.Empty);
break;
@@ -585,6 +709,9 @@ public sealed partial class DonutMenu : Control
for (var i = 0; i < _hover.Length; i++)
_hover[i] = new Spring { Value = i == ActiveIndex ? 1 : 0 };
_centerPulse = default;
+ _expand = new Spring { Value = _expanded >= 0 ? 1 : 0 };
+ if (_expanded < 0)
+ _shownExpanded = -1;
StepLayout(0, snap: true);
if (_openClock < double.MaxValue)
{
@@ -629,6 +756,9 @@ public sealed partial class DonutMenu : Control
}
Array.Fill(_open, _closing ? 0 : 1);
_centerPulse = default;
+ _expand = new Spring { Value = _expanded >= 0 ? 1 : 0 };
+ if (_expanded < 0)
+ _shownExpanded = -1;
StepLayout(dt);
if (_closing)
FinishClose();
@@ -641,6 +771,10 @@ public sealed partial class DonutMenu : Control
for (var i = 0; i < _hover.Length; i++)
active |= i == ActiveIndex ? _hover[i].Step(1, dt) : _hover[i].Step(0, dt, 320, CriticalDamping);
active |= _centerPulse.Step(0, dt, 260, 12);
+ // Critically damped: an overshoot would grow the ring past the room kept for it.
+ active |= _expand.Step(_expanded >= 0 ? 1 : 0, dt, 420, 41);
+ if (_expanded < 0 && _expand.Value <= 0.001)
+ _shownExpanded = -1;
active |= StepProgress(dt);
active |= StepLayout(dt);
@@ -758,12 +892,49 @@ public sealed partial class DonutMenu : Control
if (IsEditMode && _previewSpan.Value > 0.01)
DrawPreview(context, center, r1, r2, typeface, typefaceRegular);
+ if (!IsEditMode && _shownExpanded >= 0 && _shownExpanded < n && _expand.Value > 0.01)
+ DrawSubRing(context, center, typeface, typefaceRegular);
+
DrawCenter(context, center, r1, typeface, typefaceRegular);
if (IsEditMode && _hoverIndex >= 0 && _hoverIndex < n && _dimmedIndex < 0)
DrawEditButton(context, EditButtonCenter(_hoverIndex));
}
+ /// <summary>The ring an open group fans out, growing out of its slice.</summary>
+ private void DrawSubRing(DrawingContext context, Point center, Typeface bold, Typeface regular)
+ {
+ var group = _shownExpanded;
+ var children = Items![group].Children!;
+ var parentMid = DonutGeometry.MidAngle(group, Count);
+ var subSpan = DonutGeometry.SubSpan(DonutGeometry.Span(Count), children.Count);
+ var (inner, outer) = SubRadii;
+ var t = Math.Max(0, _expand.Value);
+ var opening = _open.Length == 0 ? 1 : Math.Clamp(_open.Average(), 0, 1);
+ // Grows outward from the group's slice: scaled about the point where it meets the donut.
+ var anchor = DonutGeometry.PointAt(center, inner, parentMid);
+ var scale = 0.8 + 0.2 * t;
+ var transform = Matrix.CreateTranslation(-anchor.X, -anchor.Y) * Matrix.CreateScale(scale, scale) *
+ Matrix.CreateTranslation(anchor.X, anchor.Y);
+
+ using (context.PushTransform(transform))
+ using (context.PushOpacity(Math.Clamp(t, 0, 1) * opening))
+ {
+ for (var k = 0; k < children.Count; k++)
+ {
+ var item = children[k];
+ var mid = DonutGeometry.SubMidAngle(parentMid, k, children.Count, subSpan);
+ var wedge = CreateWedge(center, inner, outer, mid, subSpan);
+ context.DrawGeometry(WithOpacity(SliceBrush, SliceOpacity * (item.IsEnabled ? 1 : 0.55)), BorderPen(), wedge);
+ var hot = k == _subHover && group == _expanded && item.IsEnabled;
+ if (hot)
+ context.DrawGeometry(WithOpacity(AccentBrush, 0.82), null, wedge);
+ DrawLabel(context, item, center, (inner + outer) / 2, mid, subSpan * (inner + outer) / 2 - 8,
+ SubBand - 8, bold, regular, hot);
+ }
+ }
+ }
+
private void DrawSoftShadow(DrawingContext context, Point center, double r2)
{
// A radial gradient ring fakes a soft drop shadow without blur effects (cheap on any GPU).
diff --git a/src/Filee.App/Services/RadialController.cs b/src/Filee.App/Services/RadialController.cs
index 5154c7b3..279ad386 100644
--- a/src/Filee.App/Services/RadialController.cs
+++ b/src/Filee.App/Services/RadialController.cs
@@ -131,8 +131,8 @@ public sealed class RadialController(
window.Dropped += (hit, files) =>
{
_dropped = true;
- if (hit.Kind == DonutHitKind.Segment)
- Convert(hit.Index, files.Count > 0 ? files : viewModel.Files);
+ if (hit.Kind is DonutHitKind.Segment or DonutHitKind.SubSegment)
+ Convert(hit.Index, hit.Sub, files.Count > 0 ? files : viewModel.Files);
else
Close();
};
@@ -148,8 +148,9 @@ public sealed class RadialController(
Close();
};
- donut.ActiveIndexChanged += (_, index) => viewModel.ShowHint(index, donut.IsCenterHot);
- donut.SegmentInvoked += (_, index) => Convert(index, viewModel.Files);
+ donut.ActiveIndexChanged += (_, index) => viewModel.ShowHint(index, donut.ActiveSubIndex, donut.IsCenterHot);
+ donut.SegmentInvoked += (_, index) => Convert(index, -1, viewModel.Files);
+ donut.SubSegmentInvoked += (_, hit) => Convert(hit.Group, hit.Sub, viewModel.Files);
donut.CenterInvoked += (_, _) => Close();
donut.SegmentContextRequested += async (_, index) => await EditPresetAsync(index);
donut.ProgressCancelRequested += (_, _) => _progressJob?.CancelCommand.Execute(null);
@@ -163,15 +164,15 @@ public sealed class RadialController(
return window;
}
- private void Convert(int index, IReadOnlyList<string> files)
+ /// <summary>Converts with slice <paramref name="index"/>, or with slice <paramref name="sub"/> of that group's ring.</summary>
+ private void Convert(int index, int sub, IReadOnlyList<string> files)
{
- if (index < 0 || index >= viewModel.Presets.Count || !viewModel.Items[index].IsEnabled || files.Count == 0)
+ if (viewModel.PresetAt(index, sub) is not { } preset || files.Count == 0)
{
Close();
return;
}
- var preset = viewModel.Presets[index];
log.LogInformation("Converting {Count} file(s) with preset {Preset}", files.Count, preset.Id);
var job = conversions.Start(files, preset, showInToast: false);
if (job is null || _window is null)
@@ -282,7 +283,7 @@ public sealed class RadialController(
var scaling = OperatingSystem.IsMacOS() ? 1 : screen?.Scaling ?? 1;
// Window size follows the donut size (SizeToContent); compute it up front to centre on the cursor.
- var side = 2 * (viewModel.OuterRadius + 7 + 14);
+ var side = DonutMenu.SideFor(viewModel.OuterRadius, viewModel.ReserveSubRing);
var sidePx = (int)Math.Ceiling(side * scaling);
var position = new PixelPoint(x - sidePx / 2, y - sidePx / 2);
if (screen is not null)
diff --git a/src/Filee.App/ViewModels/RadialViewModel.cs b/src/Filee.App/ViewModels/RadialViewModel.cs
index 01cb7036..d1e35bbd 100644
--- a/src/Filee.App/ViewModels/RadialViewModel.cs
+++ b/src/Filee.App/ViewModels/RadialViewModel.cs
@@ -20,6 +20,9 @@ public sealed partial class RadialViewModel(UserDataStore store, ILocalizer loc,
[ObservableProperty] private double _holeRatio = 0.42;
[ObservableProperty] private double _sliceOpacity = 0.96;
+ /// <summary>Some donut has a group slice: the window keeps room for the ring it fans out.</summary>
+ [ObservableProperty] private bool _reserveSubRing;
+
/// <summary>
/// 0 while a drag gesture waits for files, 1 otherwise. The gesture starts before anyone knows what is being
/// dragged (a file, text, or nothing: Ctrl + a rubber-band selection), so the donut only appears when files enter.
@@ -38,6 +41,24 @@ public sealed partial class RadialViewModel(UserDataStore store, ILocalizer loc,
/// <summary>Presets in slice order.</summary>
public IReadOnlyList<Preset> Presets { get; private set; } = [];
+ /// <summary>For each slice, the presets its group fans out (empty for an ordinary preset).</summary>
+ private IReadOnlyList<IReadOnlyList<Preset>> _subPresets = [];
+
+ /// <summary>
+ /// The preset that slice <paramref name="index"/> converts with, or slice <paramref name="sub"/> of its group's ring;
+ /// null when there is none or it can't convert these files.
+ /// </summary>
+ public Preset? PresetAt(int index, int sub)
+ {
+ if (index < 0 || index >= Items.Count)
+ return null;
+ if (sub < 0)
+ return Items[index] is { IsEnabled: true, IsGroup: false } ? Presets[index] : null;
+ return Items[index].Children is { } children && sub < children.Count && children[sub].IsEnabled
+ ? _subPresets[index][sub]
+ : null;
+ }
+
/// <summary>True when opened with known files (keyboard, context menu, drop zone): slices are clicked.</summary>
public bool IsClickMode { get; private set; }
@@ -49,6 +70,7 @@ public sealed partial class RadialViewModel(UserDataStore store, ILocalizer loc,
IsClickMode = false;
Files = [];
Presets = [];
+ _subPresets = [];
ApplyAppearance();
Items = [];
CenterTitle = loc["donut.center_drag"];
@@ -73,19 +95,41 @@ public sealed partial class RadialViewModel(UserDataStore store, ILocalizer loc,
.OfType<Preset>()
.ToList();
- Items = Presets.Select(p =>
+ _subPresets = Presets
+ .Select(p => (IReadOnlyList<Preset>)p.SubPresetIds.Select(store.FindPreset).OfType<Preset>().Where(c => !c.IsGroup).ToList())
+ .ToList();
+
+ DonutItem ItemOf(Preset p, bool caption = true)
{
var reason = availability.Check(p, formats);
return new DonutItem
{
Id = p.Id,
Label = loc.DisplayName(p),
- Caption = p.TargetFormat == BuiltInData.SameAsSource
- ? string.Join("/", formats.Select(f => f.DisplayName).Take(2))
- : FormatLabels.NameOf(loc, p.TargetFormat),
+ Caption = !caption ? null
+ : p.TargetFormat == BuiltInData.SameAsSource
+ ? string.Join("/", formats.Select(f => f.DisplayName).Take(2))
+ : FormatLabels.NameOf(loc, p.TargetFormat),
IsEnabled = reason is null,
DisabledReason = reason,
};
+ }
+
+ Items = Presets.Select((p, i) =>
+ {
+ if (!p.IsGroup)
+ return ItemOf(p);
+ // A group: its own name with "···", and its presets on the ring it fans out (labels only, they're small).
+ var children = _subPresets[i].Select(c => ItemOf(c, caption: false)).ToList();
+ return new DonutItem
+ {
+ Id = p.Id,
+ Label = loc.DisplayName(p),
+ Caption = "···",
+ IsEnabled = children.Any(c => c.IsEnabled),
+ DisabledReason = children.Select(c => c.DisabledReason).FirstOrDefault(r => r is not null),
+ Children = children,
+ };
}).ToList();
CenterTitle = formats.Count == 1
@@ -94,11 +138,17 @@ public sealed partial class RadialViewModel(UserDataStore store, ILocalizer loc,
CenterSubtitle = clickMode ? loc["donut.close_hint"] : null;
}
- /// <summary>Updates the centre hint for the emphasised slice.</summary>
- public void ShowHint(int index, bool centerHot)
+ /// <summary>Updates the centre hint for the emphasised slice (and slice <paramref name="sub"/> of its group's ring).</summary>
+ public void ShowHint(int index, int sub, bool centerHot)
{
if (centerHot)
CenterSubtitle = loc["donut.cancel"];
+ else if (index >= 0 && index < Items.Count && Items[index].Children is { } children)
+ CenterSubtitle = sub >= 0 && sub < children.Count
+ ? children[sub].IsEnabled
+ ? loc.Format(IsClickMode ? "donut.click_to" : "donut.drop_to", $"{Items[index].Label} · {children[sub].Label}")
+ : children[sub].DisabledReason
+ : loc["donut.pick_in_group"];
else if (index >= 0 && index < Items.Count)
CenterSubtitle = Items[index].IsEnabled
? loc.Format(IsClickMode ? "donut.click_to" : "donut.drop_to", Items[index].Label)
@@ -109,6 +159,7 @@ public sealed partial class RadialViewModel(UserDataStore store, ILocalizer loc,
private void ApplyAppearance()
{
+ ReserveSubRing = store.Profiles.Any(profile => profile.PresetIds.Any(id => store.FindPreset(id)?.IsGroup == true));
OuterRadius = Math.Clamp(store.Settings.Donut.OuterRadius, 100, 240);
HoleRatio = store.Settings.Donut.HoleRatio;
SliceOpacity = store.Settings.Donut.Opacity;
diff --git a/src/Filee.App/Views/RadialWindow.axaml b/src/Filee.App/Views/RadialWindow.axaml
index 6ddde95f..699a33d3 100644
--- a/src/Filee.App/Views/RadialWindow.axaml
+++ b/src/Filee.App/Views/RadialWindow.axaml
@@ -26,6 +26,7 @@
CenterSubtitle="{Binding CenterSubtitle}"
OuterRadius="{Binding OuterRadius}"
HoleRatio="{Binding HoleRatio}"
- SliceOpacity="{Binding SliceOpacity}" />
+ SliceOpacity="{Binding SliceOpacity}"
+ ReserveSubRing="{Binding ReserveSubRing}" />
</Panel>
</Window>
diff --git a/src/Filee.App/Views/RadialWindow.axaml.cs b/src/Filee.App/Views/RadialWindow.axaml.cs
index 869ff92b..07fc9331 100644
--- a/src/Filee.App/Views/RadialWindow.axaml.cs
+++ b/src/Filee.App/Views/RadialWindow.axaml.cs
@@ -59,16 +59,17 @@ public partial class RadialWindow : Window
_dragOverEvents++;
_lastDragHit = hit;
var files = e.DataTransfer.Contains(DataFormat.File);
- Donut.SetExternalHighlight(hit.Kind == DonutHitKind.Segment ? hit.Index : -1, hit.Kind == DonutHitKind.Center);
+ Donut.SetExternalHit(hit);
// Always COPY. Reporting MOVE would make Explorer delete the source files after the drop.
- e.DragEffects = files && hit.Kind == DonutHitKind.Segment ? DragDropEffects.Copy : DragDropEffects.None;
+ e.DragEffects = files && Donut.Converts(hit) ? DragDropEffects.Copy : DragDropEffects.None;
e.Handled = true;
}
private void OnDragLeave(object? sender, DragEventArgs e)
{
DragSummary?.Invoke(_dragOverEvents, _lastDragHit, Donut.LitAmount(_lastDragHit.Index));
+ Donut.CollapseGroup();
Donut.SetExternalHighlight(-1);
DragLeft?.Invoke();
}
@@ -77,8 +78,9 @@ public partial class RadialWindow : Window
{
var hit = Donut.HitTest(e.GetPosition(Donut));
DragSummary?.Invoke(_dragOverEvents, hit, Donut.LitAmount(hit.Index));
+ Donut.CollapseGroup();
Donut.SetExternalHighlight(-1);
- e.DragEffects = hit.Kind == DonutHitKind.Segment ? DragDropEffects.Copy : DragDropEffects.None;
+ e.DragEffects = Donut.Converts(hit) ? DragDropEffects.Copy : DragDropEffects.None;
Dropped?.Invoke(hit, LocalFiles(e));
e.Handled = true;
}
diff --git a/src/Filee.Core/Presets/BuiltInData.cs b/src/Filee.Core/Presets/BuiltInData.cs
index 65fab5c3..91fc25d9 100644
--- a/src/Filee.Core/Presets/BuiltInData.cs
+++ b/src/Filee.Core/Presets/BuiltInData.cs
@@ -43,6 +43,7 @@ public static class BuiltInData
Id = "remove-background", NameKey = "preset.remove_background", TargetFormat = "png",
Image = { RemoveBackground = true }, Output = { FileNamePattern = "{name}_transparent" },
},
+ .. ImageToolPresets(),
new()
{
Id = "tiff-300", Name = "TIFF 300dpi", TargetFormat = "tiff",
@@ -165,6 +166,36 @@ public static class BuiltInData
new() { Id = "to-eot", Name = "EOT", TargetFormat = "eot" },
];
+ /// <summary>
+ /// Rotate and flip presets, and the two groups that fan them out on the donut (added in settings schema 11). On no
+ /// default donut: users add "Rotate" / "Flip" (or single presets) in Settings → Toolbar.
+ /// </summary>
+ public static List<Preset> ImageToolPresets() =>
+ [
+ Tool("rotate-left", "preset.rotate_left", "{name}_left", i => i.Rotation = ImageRotation.Left90),
+ Tool("rotate-right", "preset.rotate_right", "{name}_right", i => i.Rotation = ImageRotation.Right90),
+ Tool("rotate-180", "preset.rotate_180", "{name}_180", i => i.Rotation = ImageRotation.Rotate180),
+ Tool("flip-horizontal", "preset.flip_horizontal", "{name}_mirrored", i => i.Flip = ImageFlip.Horizontal),
+ Tool("flip-vertical", "preset.flip_vertical", "{name}_flipped", i => i.Flip = ImageFlip.Vertical),
+ new()
+ {
+ Id = "rotate", NameKey = "preset.group_rotate", TargetFormat = SameAsSource,
+ SubPresetIds = ["rotate-left", "rotate-right", "rotate-180"],
+ },
+ new()
+ {
+ Id = "flip", NameKey = "preset.group_flip", TargetFormat = SameAsSource,
+ SubPresetIds = ["flip-horizontal", "flip-vertical"],
+ },
+ ];
+
+ private static Preset Tool(string id, string nameKey, string pattern, Action<ImageOptions> set)
+ {
+ var preset = new Preset { Id = id, NameKey = nameKey, TargetFormat = SameAsSource, Output = { FileNamePattern = pattern } };
+ set(preset.Image);
+ return preset;
+ }
+
/// <summary>Creates the default toolbar profiles.</summary>
public static List<ToolbarProfile> CreateProfiles() =>
[
diff --git a/src/Filee.Core/Presets/Preset.cs b/src/Filee.Core/Presets/Preset.cs
index 8ef81e8a..9fe50f33 100644
--- a/src/Filee.Core/Presets/Preset.cs
+++ b/src/Filee.Core/Presets/Preset.cs
@@ -41,6 +41,17 @@ public sealed class Preset
/// <summary>Where and how output files are written.</summary>
public OutputRule Output { get; set; } = new();
+ /// <summary>
+ /// Makes this preset a group: its donut slice converts nothing itself but fans out these presets (by
+ /// <see cref="Id"/>) in a small ring outside it, e.g. "Rotate" → left 90° / right 90° / 180°.
+ /// Empty for an ordinary preset.
+ /// </summary>
+ public List<string> SubPresetIds { get; set; } = [];
+
+ /// <summary>True when this preset only groups others (<see cref="SubPresetIds"/>).</summary>
+ [System.Text.Json.Serialization.JsonIgnore]
+ public bool IsGroup => SubPresetIds.Count > 0;
+
/// <summary>Creates a new random preset id.</summary>
public static string NewId() => Guid.NewGuid().ToString("N")[..12];
@@ -57,6 +68,7 @@ public sealed class Preset
Media = Media.Clone(),
Archive = Archive.Clone(),
Output = Output.Clone(),
+ SubPresetIds = [.. SubPresetIds],
};
}
@@ -73,6 +85,27 @@ public enum ResizeMode
Width,
}
+/// <summary>How an image is turned, after its EXIF orientation is applied.</summary>
+public enum ImageRotation
+{
+ None,
+ /// <summary>90° clockwise.</summary>
+ Right90,
+ /// <summary>90° counter-clockwise.</summary>
+ Left90,
+ Rotate180,
+}
+
+/// <summary>How an image is mirrored, after it is turned.</summary>
+public enum ImageFlip
+{
+ None,
+ /// <summary>Left ↔ right.</summary>
+ Horizontal,
+ /// <summary>Top ↔ bottom.</summary>
+ Vertical,
+}
+
/// <summary>TIFF compression schemes.</summary>
public enum TiffCompression
{
@@ -89,6 +122,12 @@ public sealed class ImageOptions
public ResizeMode Resize { get; set; } = ResizeMode.None;
+ /// <summary>Turns the image (after its EXIF orientation is applied).</summary>
+ public ImageRotation Rotation { get; set; }
+
+ /// <summary>Mirrors the image (after <see cref="Rotation"/>).</summary>
+ public ImageFlip Flip { get; set; }
+
/// <summary>Scale in percent when <see cref="Resize"/> is <see cref="ResizeMode.Percent"/>.</summary>
public int ResizePercent { get; set; } = 50;
diff --git a/src/Filee.Core/Settings/AppSettings.cs b/src/Filee.Core/Settings/AppSettings.cs
index 7e4f98ea..4df29b84 100644
--- a/src/Filee.Core/Settings/AppSettings.cs
+++ b/src/Filee.Core/Settings/AppSettings.cs
@@ -50,7 +50,7 @@ public sealed class DonutSettings
public sealed class AppSettings
{
/// <summary>Current schema version. Increase when the format changes and add a migration.</summary>
- public const int CurrentSchemaVersion = 10;
+ public const int CurrentSchemaVersion = 11;
public int SchemaVersion { get; set; } = CurrentSchemaVersion;
diff --git a/src/Filee.Core/Settings/UserDataStore.cs b/src/Filee.Core/Settings/UserDataStore.cs
index ae92ef14..350d7578 100644
--- a/src/Filee.Core/Settings/UserDataStore.cs
+++ b/src/Filee.Core/Settings/UserDataStore.cs
@@ -360,6 +360,16 @@ internal static class SettingsMigrations
presets.Add(BuiltInData.CreatePresets().Single(p => p.Id == "remove-background"));
changed = true;
}
+
+ // v11: rotate / flip presets and the "Rotate" / "Flip" groups that fan them out, on no donut.
+ if (from < 11)
+ {
+ foreach (var preset in BuiltInData.ImageToolPresets().Where(p => presets.All(existing => existing.Id != p.Id)))
+ {
+ presets.Add(preset);
+ changed = true;
+ }
+ }
return changed;
}
diff --git a/src/Filee.Engines/Magick/ImageEncoder.cs b/src/Filee.Engines/Magick/ImageEncoder.cs
index 574820af..bf692d80 100644
--- a/src/Filee.Engines/Magick/ImageEncoder.cs
+++ b/src/Filee.Engines/Magick/ImageEncoder.cs
@@ -165,6 +165,25 @@ internal static class ImageEncoder
{
image.AutoOrient();
+ // After AutoOrient, so a phone photo turns the way it looks, not the way its pixels are stored.
+ switch (options.Rotation)
+ {
+ case ImageRotation.Right90:
+ image.Rotate(90);
+ break;
+ case ImageRotation.Left90:
+ image.Rotate(-90);
+ break;
+ case ImageRotation.Rotate180:
+ image.Rotate(180);
+ break;
+ }
+ // ImageMagick's Flop mirrors left ↔ right, Flip top ↔ bottom.
+ if (options.Flip == ImageFlip.Horizontal)
+ image.Flop();
+ else if (options.Flip == ImageFlip.Vertical)
+ image.Flip();
+
switch (options.Resize)
{
case ResizeMode.Percent when options.ResizePercent is > 0 and not 100:
diff --git a/tests/Filee.App.Tests/DonutGeometryTests.cs b/tests/Filee.App.Tests/DonutGeometryTests.cs
index b503192b..840c61cd 100644
--- a/tests/Filee.App.Tests/DonutGeometryTests.cs
+++ b/tests/Filee.App.Tests/DonutGeometryTests.cs
@@ -36,6 +36,22 @@ public class DonutGeometryTests
Assert.Equal(3, DonutGeometry.HitTest(C, new Point(80, 200), 60, 150, 4).Index);
}
+ [Fact]
+ public void A_groups_ring_fans_out_around_its_slice()
+ {
+ var subSpan = DonutGeometry.SubSpan(DonutGeometry.Span(9), 3);
+ var parentMid = DonutGeometry.MidAngle(0, 9); // 12 o'clock: the fan straddles 0 / 2π
+ for (var k = 0; k < 3; k++)
+ {
+ var p = DonutGeometry.PointAt(C, 190, DonutGeometry.SubMidAngle(parentMid, k, 3, subSpan));
+ Assert.Equal(k, DonutGeometry.SubIndexAt(C, p, 170, 210, parentMid, 3, subSpan));
+ }
+ Assert.Equal(-1, DonutGeometry.SubIndexAt(C, DonutGeometry.PointAt(C, 190, Math.PI), 170, 210, parentMid, 3, subSpan));
+ Assert.Equal(-1, DonutGeometry.SubIndexAt(C, DonutGeometry.PointAt(C, 150, parentMid), 170, 210, parentMid, 3, subSpan));
+ // The fan covers its slice and a quarter of each neighbour.
+ Assert.Equal(DonutGeometry.Span(9) * 1.5, subSpan * 3, 6);
+ }
+
[Fact]
public void Hole_ring_and_outside_are_classified()
{
diff --git a/tests/Filee.App.Tests/RenderTests.cs b/tests/Filee.App.Tests/RenderTests.cs
index da2c5167..ad07d955 100644
--- a/tests/Filee.App.Tests/RenderTests.cs
+++ b/tests/Filee.App.Tests/RenderTests.cs
@@ -335,6 +335,53 @@ public class RenderTests
window.Close();
}
+ /// <summary>
+ /// "Rotate" and "Flip" added to the image donut: hovering "Rotate" fans out left 90° / right 90° / 180° outside it,
+ /// and the slice under the pointer there is what a drop or click converts with.
+ /// </summary>
+ [AvaloniaTheory]
+ [InlineData("ko")]
+ [InlineData("en")]
+ public void A_group_slice_fans_out_its_presets(string language)
+ {
+ TestServices.EnsureInitialized(language);
+ var images = AppHost.Get<UserDataStore>().Profiles.Single(p => p.Id == "images");
+ var before = images.PresetIds.ToList();
+ try
+ {
+ images.PresetIds.AddRange(["rotate", "flip"]);
+ var vm = AppHost.Get<RadialViewModel>();
+ vm.Load([@"C:\photos\a.jpg"], clickMode: true);
+ Assert.True(vm.ReserveSubRing);
+ var rotate = vm.Items.Count - 2;
+ Assert.Equal(3, vm.Items[rotate].Children!.Count);
+ Assert.Null(vm.PresetAt(rotate, -1)); // the group itself converts nothing
+ Assert.Equal("rotate-right", vm.PresetAt(rotate, 1)!.Id);
+
+ var window = new RadialWindow { DataContext = vm };
+ window.Show();
+ var donut = window.DonutControl;
+ donut.SetExternalHit(new DonutHit(DonutHitKind.Segment, rotate));
+ donut.SetExternalHit(new DonutHit(DonutHitKind.SubSegment, rotate, 1));
+ vm.ShowHint(rotate, donut.ActiveSubIndex, centerHot: false);
+ Pump();
+
+ var n = vm.Items.Count;
+ var mid = DonutGeometry.SubMidAngle(DonutGeometry.MidAngle(rotate, n), 1, 3, DonutGeometry.SubSpan(DonutGeometry.Span(n), 3));
+ var center = new Avalonia.Point(donut.Bounds.Width / 2, donut.Bounds.Height / 2);
+ var onRing = DonutGeometry.PointAt(center, vm.OuterRadius + 7 + DonutMenu.SubRingSpace / 2 + 3, mid);
+ Assert.Equal(new DonutHit(DonutHitKind.SubSegment, rotate, 1), donut.HitTest(onRing));
+ Assert.Contains("90°", vm.CenterSubtitle);
+ Save(window, $"donut-group-{language}.png");
+ window.Close();
+ }
+ finally
+ {
+ images.PresetIds.Clear();
+ images.PresetIds.AddRange(before);
+ }
+ }
+
/// <summary>The middle of slot <paramref name="slot"/> of a donut with <paramref name="slots"/> slices.</summary>
private static Avalonia.Point DonutPoint(DonutMenu donut, int slot, int slots)
{
diff --git a/tests/Filee.Core.Tests/SmallParsersTests.cs b/tests/Filee.Core.Tests/SmallParsersTests.cs
index 4f1dfcca..bab9a52b 100644
--- a/tests/Filee.Core.Tests/SmallParsersTests.cs
+++ b/tests/Filee.Core.Tests/SmallParsersTests.cs
@@ -49,6 +49,17 @@ public class BuiltInDataTests
Assert.All(profile.PresetIds, id => Assert.Contains(id, ids));
}
+ [Fact]
+ public void Groups_fan_out_existing_presets_that_are_not_groups_themselves()
+ {
+ var presets = BuiltInData.CreatePresets().ToDictionary(p => p.Id);
+ var groups = presets.Values.Where(p => p.IsGroup).ToList();
+ Assert.NotEmpty(groups);
+ foreach (var group in groups)
+ Assert.All(group.SubPresetIds, id => Assert.False(presets[id].IsGroup, id));
+ Assert.Equal(groups[0].SubPresetIds, groups[0].Clone().SubPresetIds);
+ }
+
[Fact]
public void Preset_ids_are_unique()
{
diff --git a/tests/Filee.Core.Tests/UserDataStoreTests.cs b/tests/Filee.Core.Tests/UserDataStoreTests.cs
index cf18bdab..ad3bf3c7 100644
--- a/tests/Filee.Core.Tests/UserDataStoreTests.cs
+++ b/tests/Filee.Core.Tests/UserDataStoreTests.cs
@@ -210,6 +210,22 @@ public class UserDataStoreTests
Assert.False(SettingsMigrations.ApplyToLibrary(9, presets, profiles)); // once only
}
+ [Fact]
+ public void Version_10_libraries_get_rotate_and_flip_presets_and_groups_on_no_donut()
+ {
+ var presets = BuiltInData.CreatePresets();
+ presets.RemoveAll(p => p.Id is "rotate-left" or "rotate-right" or "rotate-180" or "flip-horizontal" or "flip-vertical" or "rotate" or "flip");
+ var profiles = BuiltInData.CreateProfiles();
+
+ Assert.True(SettingsMigrations.ApplyToLibrary(10, presets, profiles));
+
+ Assert.Equal(["rotate-left", "rotate-right", "rotate-180"], presets.Single(p => p.Id == "rotate").SubPresetIds);
+ Assert.Equal(ImageRotation.Left90, presets.Single(p => p.Id == "rotate-left").Image.Rotation);
+ Assert.Equal(ImageFlip.Horizontal, presets.Single(p => p.Id == "flip-horizontal").Image.Flip);
+ Assert.DoesNotContain(profiles, p => p.PresetIds.Any(id => id.StartsWith("rotate") || id.StartsWith("flip")));
+ Assert.False(SettingsMigrations.ApplyToLibrary(10, presets, profiles)); // once only
+ }
+
[Fact]
public void Catalog_migration_ignores_extensions_checked_on_mixed_profiles()
{
diff --git a/tests/Filee.Engines.Tests/ImageToolTests.cs b/tests/Filee.Engines.Tests/ImageToolTests.cs
new file mode 100644
index 00000000..6d32eff3
--- /dev/null
+++ b/tests/Filee.Engines.Tests/ImageToolTests.cs
@@ -0,0 +1,39 @@
+// Rotate and flip presets: the image turns and mirrors the way the preset names say.
+
+using Filee.Core.Conversion;
+using Filee.Core.Presets;
+using ImageMagick;
+using ImageMagick.Drawing;
+
+namespace Filee.Engines.Tests;
+
+public class ImageToolTests(EngineFixture fx) : IClassFixture<EngineFixture>
+{
+ /// <summary>A 4 × 2 white image with one red pixel in the top left corner, run through a built-in preset.</summary>
+ [Theory]
+ [InlineData("rotate-right", "a_right.png", 2, 4, 1, 0)]
+ [InlineData("rotate-left", "a_left.png", 2, 4, 0, 3)]
+ [InlineData("rotate-180", "a_180.png", 4, 2, 3, 1)]
+ [InlineData("flip-horizontal", "a_mirrored.png", 4, 2, 3, 0)]
+ [InlineData("flip-vertical", "a_flipped.png", 4, 2, 0, 1)]
+ public async Task The_corner_pixel_moves_where_the_preset_says(string presetId, string name, int width, int height, int x, int y)
+ {
+ var dir = fx.NewFolder();
+ var source = Path.Combine(dir, "a.png");
+ using (var image = new MagickImage(MagickColors.White, 4, 2))
+ {
+ new Drawables().FillColor(MagickColors.Red).Point(0, 0).Draw(image);
+ image.Write(source, MagickFormat.Png);
+ }
+
+ var job = await fx.ConvertAsync([source], BuiltInData.CreatePresets().Single(p => p.Id == presetId));
+
+ Assert.Equal(JobState.Completed, job.State);
+ var output = job.Outputs.Single();
+ Assert.Equal(name, Path.GetFileName(output));
+ using var result = new MagickImage(output);
+ Assert.Equal(((uint)width, (uint)height), (result.Width, result.Height));
+ var red = result.GetPixels().GetPixel(x, y).ToColor()!;
+ Assert.True(red.R > 200 && red.G < 60, $"{presetId}: ({x},{y}) is {red}");
+ }
+}