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 click or a tap opens a group at once

SeoJCalive00fdb63652b9
diff --git a/src/Filee.App/Controls/DonutMenu.cs b/src/Filee.App/Controls/DonutMenu.cs
index e2804613..d558909b 100644
--- a/src/Filee.App/Controls/DonutMenu.cs
+++ b/src/Filee.App/Controls/DonutMenu.cs
@@ -721,6 +721,12 @@ public sealed partial class DonutMenu : Control
case DonutHitKind.Segment when !IsEditMode && Items![hit.Index] is { IsEnabled: true, IsGroup: false }:
SegmentInvoked?.Invoke(this, hit.Index);
break;
+ case DonutHitKind.Segment when !IsEditMode && Items![hit.Index].Children is { Count: > 0 }:
+ Expand(hit.Index); // no waiting when clicked; a tap has no hover to rest on at all
+ break;
+ case DonutHitKind.Outside when !IsEditMode && _expanded >= 0:
+ CollapseGroup(); // clicked past the ring
+ break;
case DonutHitKind.SubSegment when !IsEditMode && Items![hit.Index].Children![hit.Sub].IsEnabled:
SubSegmentInvoked?.Invoke(this, (hit.Index, hit.Sub));
break;
diff --git a/tests/Filee.App.Tests/DonutGroupTests.cs b/tests/Filee.App.Tests/DonutGroupTests.cs
index 998eeace..49a6403b 100644
--- a/tests/Filee.App.Tests/DonutGroupTests.cs
+++ b/tests/Filee.App.Tests/DonutGroupTests.cs
@@ -3,6 +3,7 @@
using Avalonia;
using Avalonia.Controls;
+using Avalonia.Headless;
using Avalonia.Headless.XUnit;
using Avalonia.Input;
using Avalonia.Threading;
@@ -100,6 +101,26 @@ public class DonutGroupTests
window.Close();
}
+ [AvaloniaFact]
+ public void A_click_or_tap_opens_a_group_at_once_and_a_click_past_its_ring_folds_it()
+ {
+ var (donut, window) = Open();
+ var invoked = 0;
+ donut.SegmentInvoked += (_, _) => invoked++;
+ var inner = OnGroup(donut, donut.OuterRadius * 0.6);
+ window.MouseDown(inner, MouseButton.Left); // a tap: no hover before it
+ window.MouseUp(inner, MouseButton.Left);
+ Assert.True(IsOpen(donut));
+ Assert.Equal(0, invoked); // the group itself converts nothing
+
+ var past = OnGroup(donut, donut.OuterRadius + 7 + DonutMenu.SubRingSpace - 6);
+ Assert.Equal(DonutHitKind.Outside, donut.HitTest(past).Kind);
+ window.MouseDown(past, MouseButton.Left);
+ window.MouseUp(past, MouseButton.Left);
+ Assert.False(IsOpen(donut));
+ window.Close();
+ }
+
[AvaloniaFact]
public void An_open_ring_holds_across_the_gap_and_folds_when_the_pointer_goes_round_elsewhere()
{