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.
C# audio-converteravaloniabatch-conversionconvertercsharpdocument-converterdocx-to-pdfdotnetdrag-and-dropfile-conversionfile-converterheic-converterhwphwpximage-converterlinuxmacospdf-convertervideo-converterwindows
Donut: highlights and layout stay steady when frames come late
KnifeLemon29dec8d73e76
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 2a0fd154..8425f664 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -6,6 +6,15 @@ version it publishes under "What's Changed" in the GitHub release notes, above tAdd a `## <version>` section before tagging a release. Write what someone using Filee notices: what's new, where tofind it, what it does and doesn't do.+## 1.7.2++### Fixes++- When the computer was busy (a screen recorder running, a slow graphics card), slices of the donut could stay lit+ after the pointer left them, pile up in the accent colour and fly apart as the donut closed. A late frame moved the+ highlight further than it should, and every following frame made it worse. The animations now stay steady however+ late the frames come. Turning on "Reduce animations" was the workaround until now.+## 1.7.1### Fixesdiff --git a/Directory.Build.props b/Directory.Build.propsindex 16521d64..e1eb5c1c 100644--- a/Directory.Build.props+++ b/Directory.Build.props@@ -14,7 +14,7 @@parameters of a member is fine (CS1573). --><NoWarn>$(NoWarn);CS1591;CS1573</NoWarn>- <Version>1.7.1</Version>+ <Version>1.7.2</Version><Product>Filee</Product><Authors>Filee contributors</Authors><Copyright>Copyright (c) Filee contributors</Copyright>diff --git a/src/Filee.App/Controls/DonutMenu.cs b/src/Filee.App/Controls/DonutMenu.csindex adef5b5a..f01514ba 100644--- a/src/Filee.App/Controls/DonutMenu.cs+++ b/src/Filee.App/Controls/DonutMenu.cs@@ -478,11 +478,22 @@ public sealed partial class DonutMenu : Controlpublic double Value;public double Velocity;+ /// <summary>+ /// Longest time one integration step covers. With these stiffnesses a single step of a late frame (50 ms)+ /// overshoots more each frame instead of settling: slices stayed lit and flew apart on a busy machine.+ /// </summary>+ private const double MaxStep = 1 / 120.0;+public bool Step(double target, double dt, double stiffness = 320, double damping = 20){- var force = stiffness * (target - Value) - damping * Velocity;- Velocity += force * dt;- Value += Velocity * dt;+ var steps = Math.Max(1, (int)Math.Ceiling(dt / MaxStep));+ var h = dt / steps;+ for (var i = 0; i < steps; i++)+ {+ var force = stiffness * (target - Value) - damping * Velocity;+ Velocity += force * h;+ Value += Velocity * h;+ }var settled = Math.Abs(target - Value) < 0.001 && Math.Abs(Velocity) < 0.01;if (settled){diff --git a/tests/Filee.App.Tests/DonutHighlightTests.cs b/tests/Filee.App.Tests/DonutHighlightTests.csindex 3f87cc13..dfadefc0 100644--- a/tests/Filee.App.Tests/DonutHighlightTests.cs+++ b/tests/Filee.App.Tests/DonutHighlightTests.cs@@ -91,6 +91,34 @@ public class DonutHighlightTestsAssert.Equal(0, donut.LitAmount(1), 3);}+ [AvaloniaFact]+ public void Highlights_settle_when_frames_come_late()+ {+ TestServices.EnsureInitialized("ko");+ Filee.App.Services.Motion.Configure(false, () => false);+ var donut = new DonutMenu+ {+ Items = new[] { "PNG", "JPG", "WEBP", "PDF" }.Select(l => new DonutItem { Id = l, Label = l }).ToList(),+ };+ // Every frame as late as the loop allows (a busy GPU, a screen recorder): the pointer crosses the slices.+ const double late = 0.05;+ for (var slice = 0; slice < 4; slice++)+ {+ donut.SetExternalHighlight(slice);+ for (var i = 0; i < 6; i++)+ donut.Advance(late);+ }+ for (var i = 0; i < 60; i++)+ {+ donut.Advance(late);+ for (var slice = 0; slice < 3; slice++)+ Assert.InRange(donut.LitAmount(slice), 0, 1);+ }++ Assert.All(Enumerable.Range(0, 3), slice => Assert.Equal(0, donut.LitAmount(slice), 3));+ Assert.Equal(1, donut.LitAmount(3), 3);+ }+[AvaloniaFact] // switching the setting restyles the open windows, which belong to the UI threadpublic void Following_the_system_reads_it_again_when_a_window_opens(){