From 90321a7e53235b7808b93b2adf003db9c5ffebdc Mon Sep 17 00:00:00 2001 From: Claude Date: Sat, 3 Oct 2026 11:10:10 +0000 Subject: [PATCH] fix(editor): round the colour temperature to tens without a negative digit count double.Round(x, -1) throws, so opening any analysed sequence with a white balance range failed in the Exposure tab's constructor and the editor never appeared. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_012iLMBNwBE2GnphAsu4cjaC --- src/Titano.App/Editor/ExposureTab.cs | 5 ++++- tests/Titano.App.Tests/Editor/EditorTextTests.cs | 8 ++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/Titano.App/Editor/ExposureTab.cs b/src/Titano.App/Editor/ExposureTab.cs index 0a47b21e..a715a743 100644 --- a/src/Titano.App/Editor/ExposureTab.cs +++ b/src/Titano.App/Editor/ExposureTab.cs @@ -115,10 +115,13 @@ public sealed class ExposureTab : EditorTab { if (Editor.Session.Content.Deep is not { } deep) return (null, Loc.L("Tooltips.Editor.NotApplicable.NeedsAnalysis")); if (deep.WhiteBalance is { KelvinLow: { } low, KelvinHigh: { } high }) - return (Loc.L("Editor.Value.Kelvin", double.Round(low, -1).ToString("N0", Loc.Culture), double.Round(high, -1).ToString("N0", Loc.Culture)), null); + return (Loc.L("Editor.Value.Kelvin", RoundToTens(low).ToString("N0", Loc.Culture), RoundToTens(high).ToString("N0", Loc.Culture)), null); return (null, Loc.L("Tooltips.Editor.NotApplicable.Kelvin")); } + /// Kelvin shown to the nearest ten (Math.Round takes no negative digit count). + internal static double RoundToTens(double kelvin) => double.Round(kelvin / 10) * 10; + private void BuildChart() { var content = Editor.Session.Content; diff --git a/tests/Titano.App.Tests/Editor/EditorTextTests.cs b/tests/Titano.App.Tests/Editor/EditorTextTests.cs index a9bbcbfa..837bf0d1 100644 --- a/tests/Titano.App.Tests/Editor/EditorTextTests.cs +++ b/tests/Titano.App.Tests/Editor/EditorTextTests.cs @@ -11,6 +11,14 @@ public sealed class EditorTextTests { static EditorTextTests() => _ = EditorFixture.Sunset; + [Test] + public void ColourTemperatureShowsToTheNearestTen() + { + Assert.Equal(5560.0, ExposureTab.RoundToTens(5557.2)); + Assert.Equal(3200.0, ExposureTab.RoundToTens(3203.9)); + Assert.Equal(12_000.0, ExposureTab.RoundToTens(11_998)); + } + [Test] public void OptimiseReportsValuesAsTheControlsShowThem() {