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.

Donut groups: a drag that only seems to leave doesn't stop a group opening

SeoJCalived5de99c49cc8
diff --git a/src/Filee.App/Controls/DonutMenu.cs b/src/Filee.App/Controls/DonutMenu.cs
index 56883da4..b13f54c4 100644
--- a/src/Filee.App/Controls/DonutMenu.cs
+++ b/src/Filee.App/Controls/DonutMenu.cs
@@ -641,6 +641,20 @@ public sealed partial class DonutMenu : Control
_ => false,
};
+ /// <summary>
+ /// A drag from outside left the window, last seen at <paramref name="lastAt"/>: clears what it lit up and folds a
+ /// group. Unless it was still on the donut or on the fan of a group that is open or about to open: Windows and macOS
+ /// report a drag leaving when it crosses a see-through pixel, or when the window's shape changes under it (as the
+ /// backdrop is drawn for a group about to open); taken as leaving, the group would never get to open.
+ /// </summary>
+ public void ExternalDragLeft(Point? lastAt)
+ {
+ if (lastAt is { } at && LeftThroughSeam(at))
+ return;
+ CollapseGroup();
+ SetExternalHighlight(-1);
+ }
+
/// <summary>Folds an open group away (the drag left the window, or files were dropped).</summary>
public void CollapseGroup()
{
diff --git a/src/Filee.App/Views/RadialWindow.axaml.cs b/src/Filee.App/Views/RadialWindow.axaml.cs
index 2ce59d51..245d0939 100644
--- a/src/Filee.App/Views/RadialWindow.axaml.cs
+++ b/src/Filee.App/Views/RadialWindow.axaml.cs
@@ -1,5 +1,6 @@
// Thin view for the live donut: forwards drag & drop and pointer events to RadialController.
+using Avalonia;
using Avalonia.Controls;
using Avalonia.Input;
using Avalonia.Platform.Storage;
@@ -39,6 +40,7 @@ public partial class RadialWindow : Window
private int _dragOverEvents;
private DonutHit _lastDragHit;
+ private Point? _lastDragAt;
private void OnDragEnter(object? sender, DragEventArgs e)
{
@@ -49,6 +51,7 @@ public partial class RadialWindow : Window
return;
}
_dragOverEvents = 0;
+ _lastDragAt = null;
FilesEntered?.Invoke(files);
OnDragOver(sender, e);
}
@@ -59,6 +62,7 @@ public partial class RadialWindow : Window
var hit = Donut.HitTest(at);
_dragOverEvents++;
_lastDragHit = hit;
+ _lastDragAt = at;
var files = e.DataTransfer.Contains(DataFormat.File);
Donut.SetExternalHit(hit, at);
@@ -70,8 +74,7 @@ public partial class RadialWindow : Window
private void OnDragLeave(object? sender, DragEventArgs e)
{
DragSummary?.Invoke(_dragOverEvents, _lastDragHit, Donut.LitAmount(_lastDragHit.Index));
- Donut.CollapseGroup();
- Donut.SetExternalHighlight(-1);
+ Donut.ExternalDragLeft(_lastDragAt);
DragLeft?.Invoke();
}
diff --git a/tests/Filee.App.Tests/DonutGroupTests.cs b/tests/Filee.App.Tests/DonutGroupTests.cs
index 778d7255..87be632f 100644
--- a/tests/Filee.App.Tests/DonutGroupTests.cs
+++ b/tests/Filee.App.Tests/DonutGroupTests.cs
@@ -194,6 +194,30 @@ public class DonutGroupTests
}
}
+ [AvaloniaFact]
+ public void A_drag_reported_leaving_over_the_donut_still_opens_the_group_it_rests_on()
+ {
+ var (donut, window) = Open();
+ var onGroup = OnGroup(donut, donut.OuterRadius * 0.6);
+ donut.SetExternalHit(donut.HitTest(onGroup), onGroup);
+
+ // As macOS does while the backdrop is drawn under the drag: "left", though still on the group's slice.
+ donut.ExternalDragLeft(onGroup);
+ Assert.Equal(Group, donut.ActiveIndex); // still lit
+ donut.SetExternalHit(donut.HitTest(onGroup), onGroup); // and back with the next drag event
+ donut.ExpandPendingGroup(); // the delay runs out
+ Assert.True(IsOpen(donut));
+
+ donut.ExternalDragLeft(OnRing(donut, 1)); // "left" from the ring: still there too
+ Assert.True(IsOpen(donut));
+
+ // Really gone: last seen away from the donut and the ring.
+ donut.ExternalDragLeft(DonutGeometry.PointAt(Center(donut), donut.OuterRadius + 30, DonutGeometry.MidAngle(0, 4)));
+ Assert.False(IsOpen(donut));
+ Assert.Equal(-1, donut.ActiveIndex);
+ window.Close();
+ }
+
[AvaloniaFact]
public void An_open_ring_holds_across_the_gap_and_folds_when_the_pointer_goes_round_elsewhere()
{