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