From 99ba1bf7475a566110048063e9a2c60c416dca8d Mon Sep 17 00:00:00 2001 From: Oleg <18466855+EvaTheSalmon@users.noreply.github.com> Date: Mon, 9 Nov 2026 18:12:33 +0300 Subject: [PATCH] refactor(ui): put every inset on the spacing scale The UI's AXAML carried 45 margins, paddings and spacings off the 4/8/12/16/24/32 scale (20, 14, 10, 6 and a few 2, 3 and 5 px), and the dialog buttons carried their own 12,2 padding. Each value now sits on the scale at the level it belongs to: 16 px window margins, 12 px label gaps, 8 px row gaps, 4 px inside a control. Text buttons take Semi's own 12,0 padding at 32 px. A git grep gate in ui-theme.md prints any off-scale inset left, and per-window tests read the realised insets back. Co-Authored-By: Claude Opus 5.5 --- AGENTS.md | 2 + .../UI/Chart/AxisScalePanelLayoutTests.cs | 23 + .../UI/Chart/ChartMarkerViewTests.cs | 25 + .../UI/Chart/TimeWindowPanelViewTests.cs | 14 + .../UI/Export/CsvExportWindowTests.cs | 63 +- .../UI/Legend/TrendLegendTopRowViewTests.cs | 2 + .../UI/Legend/TrendLegendViewTests.cs | 39 + .../UI/MainWindow/AboutInfoTests.cs | 16 + .../UI/MainWindow/AppStatusBarViewTests.cs | 28 + .../UI/Messages/MessagePanelViewTests.cs | 40 + .../UI/Navigation/NavigationBarViewTests.cs | 21 + .../UI/PenEditor/PenEditorLayoutViewTests.cs | 16 + .../UI/Settings/SettingsViewTests.cs | 60 ++ .../UI/Startup/StartupFailureWindowTests.cs | 26 + SemiPlot/SemiPlot.Tests.Unit/UI/ViewProbe.cs | 9 + .../SemiPlot.UI/Chart/AxisScalePanel.axaml | 8 +- .../SemiPlot.UI/Chart/TimeWindowPanel.axaml | 4 +- .../SemiPlot.UI/Chart/TrendChartView.axaml | 8 +- .../SemiPlot.UI/Export/CsvExportWindow.axaml | 23 +- .../SemiPlot.UI/Legend/TrendLegendView.axaml | 12 +- .../SemiPlot.UI/MainWindow/AboutDialog.axaml | 3 +- .../SemiPlot.UI/MainWindow/AppStatusBar.axaml | 5 +- .../Messages/MessagePanelView.axaml | 7 +- .../Navigation/NavigationBarView.axaml | 2 +- .../PenEditor/PenEditorWindow.axaml | 1 - .../SemiPlot.UI/Settings/SettingsDialog.axaml | 17 +- .../Startup/StartupFailureWindow.axaml | 12 +- docs/architecture/charting.md | 18 +- docs/architecture/ui-theme.md | 201 +++-- docs/plans/backlog.md | 6 + .../completed/20261103-ui-spacing-scale.md | 825 ++++++++++++++++++ 31 files changed, 1396 insertions(+), 140 deletions(-) create mode 100644 docs/plans/completed/20261103-ui-spacing-scale.md diff --git a/AGENTS.md b/AGENTS.md index 229c166..edf019e 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -324,6 +324,8 @@ No abbreviations in names. - Every colour this tree's AXAML paints resolves to a key in `SemiPlot.UI/Styles/Palette.axaml`; a literal in AXAML is a defect. Semi's own surfaces outside that key set keep Semi's variant-aware stock brushes (`docs/architecture/ui-theme.md`). +- Every `Margin`, `Padding` and `*Spacing` value in AXAML is on the 4/8/12/16/24/32 scale; a text button + takes Semi's padding (`docs/architecture/ui-theme.md#an-off-scale-inset-in-axaml-is-a-defect`). - A form never resizes on validation: fixed width, an `invalid` border class, one reserved message line (`docs/architecture/ui-theme.md#a-form-never-resizes-on-validation`). - The left-button gesture is one state, never overlapping branches: a `Chart/LeftButtonTool` diff --git a/SemiPlot/SemiPlot.Tests.Unit/UI/Chart/AxisScalePanelLayoutTests.cs b/SemiPlot/SemiPlot.Tests.Unit/UI/Chart/AxisScalePanelLayoutTests.cs index 2e99117..12b2244 100644 --- a/SemiPlot/SemiPlot.Tests.Unit/UI/Chart/AxisScalePanelLayoutTests.cs +++ b/SemiPlot/SemiPlot.Tests.Unit/UI/Chart/AxisScalePanelLayoutTests.cs @@ -121,6 +121,29 @@ public void TheLogarithmicBox_StartsAtTheFieldEdge_UnderTheScaleTypeLabel(string box.Content.Should().Be(Resources.PenFormLogarithmic); } + [AvaloniaFact] + public void TheForm_TakesItsGapsFromTheSpacingScale() + { + using var viewModel = CreateLoadedViewModel(); + using var shown = ShowChart(viewModel); + var (_, panel) = OpenPanel(viewModel, shown); + var bounds = panel.FindControl("AxisScaleBounds")!; + var row = panel.FindControl("AxisScaleType")!; + var header = (Control)panel.FindControl("AxisScalePenName")!.Parent!; + var maximum = panel.FindControl("AxisScaleMaximum")!; + var maximumLabel = bounds.Children.OfType().First(); + + (ViewProbe.LeftOf(maximum, bounds) - ViewProbe.RightOf(maximumLabel, bounds)) + .Should().Be(12, "label to field"); + (ViewProbe.LeftOf(panel.FindControl("AxisScaleLogarithmic")!, row) + - ViewProbe.RightOf(panel.FindControl("AxisScaleTypeLabel")!, row)) + .Should().Be(12, "label to field"); + (ViewProbe.TopOf(panel.FindControl("AxisScaleMinimum")!, panel) - ViewProbe.BottomOf(maximum, panel)) + .Should().Be(8, "the row spacing"); + (ViewProbe.TopOf(row, panel) - ViewProbe.BottomOf(bounds, panel)).Should().Be(8, "the row spacing"); + (ViewProbe.TopOf(bounds, panel) - ViewProbe.BottomOf(header, panel)).Should().Be(8, "the row spacing"); + } + [AvaloniaFact] public void AClickOnTheScaleTypeLabelOrBesideTheBox_LeavesTheFlagAndGivesThePanelTheKeyboard() { diff --git a/SemiPlot/SemiPlot.Tests.Unit/UI/Chart/ChartMarkerViewTests.cs b/SemiPlot/SemiPlot.Tests.Unit/UI/Chart/ChartMarkerViewTests.cs index 57ede3f..30e5e51 100644 --- a/SemiPlot/SemiPlot.Tests.Unit/UI/Chart/ChartMarkerViewTests.cs +++ b/SemiPlot/SemiPlot.Tests.Unit/UI/Chart/ChartMarkerViewTests.cs @@ -679,6 +679,31 @@ public void RenameOnAMarker_WithANewLabelAndOk_RelabelsIt() LabelEditor.IsOpen.Should().BeFalse(); } + [AvaloniaFact] + public void TheLabelEditorButtons_TakeTheThemesPaddingAndHeight() + { + var marker = new StoredMarker(1, MomentAt(0.25), "Etch start"); + _channel.Push(marker); + OpenLabelEditorToRename(marker); + + foreach (var name in new[] { "MarkerLabelOk", "MarkerLabelCancel" }) + { + ViewProbe.ShouldTakeTheThemesButtonInsets(LabelEditorButton(name), name); + } + } + + [AvaloniaFact] + public void TheLabelEditor_StandsItsButtonsEightPixelsUnderTheBox() + { + var marker = new StoredMarker(1, MomentAt(0.25), "Etch start"); + _channel.Push(marker); + OpenLabelEditorToRename(marker); + var editor = (Control)LabelEditor.Content!; + + (ViewProbe.TopOf(LabelEditorButton("MarkerLabelOk"), editor) - ViewProbe.BottomOf(LabelBox, editor)) + .Should().Be(8, "the row spacing"); + } + [AvaloniaFact] public void RenameOnAMarker_ThenCancel_KeepsTheOldLabel() { diff --git a/SemiPlot/SemiPlot.Tests.Unit/UI/Chart/TimeWindowPanelViewTests.cs b/SemiPlot/SemiPlot.Tests.Unit/UI/Chart/TimeWindowPanelViewTests.cs index 8823bf6..3fcbf3d 100644 --- a/SemiPlot/SemiPlot.Tests.Unit/UI/Chart/TimeWindowPanelViewTests.cs +++ b/SemiPlot/SemiPlot.Tests.Unit/UI/Chart/TimeWindowPanelViewTests.cs @@ -329,6 +329,20 @@ public void TheMessageLine_KeepsThePanelsSize_EmptyAndWithTheLongestRule(string skippedSizes.Should().Be(emptySizes); } + [AvaloniaFact] + public void TheGrid_TakesItsGapsFromTheSpacingScale() + { + using var stand = PanelStand.Create(); + stand.Open(); + var startTime = stand.Panel.FindControl("TimeWindowStartTime")!; + var endTime = stand.Panel.FindControl("TimeWindowEndTime")!; + + (ViewProbe.LeftOf(stand.Picker("TimeWindowStartDate"), stand.Panel) - ViewProbe.RightOf(startTime, stand.Panel)) + .Should().Be(12, "field to field in one row"); + (ViewProbe.TopOf(endTime, stand.Panel) - ViewProbe.BottomOf(startTime, stand.Panel)) + .Should().Be(8, "the row spacing"); + } + private static CalendarDayButton DayButton(CalendarDatePicker picker, DateTime day) { var popup = ViewProbe.Descendant(picker, "PART_Popup"); diff --git a/SemiPlot/SemiPlot.Tests.Unit/UI/Export/CsvExportWindowTests.cs b/SemiPlot/SemiPlot.Tests.Unit/UI/Export/CsvExportWindowTests.cs index 074817f..23f1330 100644 --- a/SemiPlot/SemiPlot.Tests.Unit/UI/Export/CsvExportWindowTests.cs +++ b/SemiPlot/SemiPlot.Tests.Unit/UI/Export/CsvExportWindowTests.cs @@ -87,6 +87,24 @@ public void TheWindow_KeepsItsSizeAndItsButtonsWhenAFieldTurnsInvalid() } } + [AvaloniaFact] + public void TheButtons_TakeTheThemesPaddingAndHeight() + { + using var viewModel = Build(); + var window = Realise(new CsvExportWindow { DataContext = viewModel }); + try + { + foreach (var name in new[] { "ExportSaveAs", "ExportCancel", "ExportClose" }) + { + ShouldTakeTheThemesButtonInsets(Named