From 17c496795ecfbd89cfa9841f48a4d2e2aaa99294 Mon Sep 17 00:00:00 2001 From: AJ Isaacs Date: Sun, 15 Nov 2026 10:52:53 -0500 Subject: [PATCH] feat(shape-library): give the preview's part and dimensions more room The fitted drawing and its dimensions now keep 30 px from the preview's border instead of 10, and at least 20 px from the info lines and note chips. Linear dimensions sit 50 px off the part by default instead of 18, and leader labels 30 px instead of 20. Co-Authored-By: Claude Fable 5.2 --- .../Forms/ShapeLibraryFormTests.cs | 2 +- OpenNest/Controls/ShapePreviewControl.cs | 17 ++++++++++++----- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/OpenNest.WinForms.Tests/Forms/ShapeLibraryFormTests.cs b/OpenNest.WinForms.Tests/Forms/ShapeLibraryFormTests.cs index ca939aeb..3c693641 100644 --- a/OpenNest.WinForms.Tests/Forms/ShapeLibraryFormTests.cs +++ b/OpenNest.WinForms.Tests/Forms/ShapeLibraryFormTests.cs @@ -221,7 +221,7 @@ public class ShapeLibraryFormTests // The length sits below the drawing: it may come closer, never above its bottom edge. var after = preview.LabelBounds("Length")!.Value; Assert.True(after.Y < before.Y); - Assert.True(after.Y > before.Y - 20); + Assert.True(after.Y > before.Y - 50); }); [Fact] diff --git a/OpenNest/Controls/ShapePreviewControl.cs b/OpenNest/Controls/ShapePreviewControl.cs index abe9127f..05adaa9b 100644 --- a/OpenNest/Controls/ShapePreviewControl.cs +++ b/OpenNest/Controls/ShapePreviewControl.cs @@ -24,14 +24,19 @@ namespace OpenNest.Controls { // Screen sizes, in pixels. Gap, MinimumGap, LeaderClearance and Shoulder are sizes at the // fitted view: they grow and shrink with the zoom, so dimensions stay put on the drawing. - private const float Gap = 18f; + private const float Gap = 50f; private const float ExtensionOverrun = 5f; private const float ArrowLength = 8f; private const float ArrowHalfWidth = 3f; - private const float LeaderClearance = 20f; + private const float LeaderClearance = 30f; private const float Shoulder = 12f; private const float LabelPadding = 3f; + // Between the control's border and the note chips. private const float EdgePadding = 10f; + // Between the control's border and the fitted drawing and its dimensions. + private const float FitPadding = 30f; + // Between the info lines or note chips and the fitted drawing and its dimensions. + private const float FitClearance = 20f; private const float ChipSpacing = 6f; private const int DragThreshold = 3; // How close a dragged linear dimension may come to the drawing's bounds. @@ -220,9 +225,11 @@ namespace OpenNest.Controls return; } - var top = EdgePadding + InfoHeight(); - var bottom = EdgePadding + ChipRowsHeight(); - float left = EdgePadding, right = EdgePadding; + var info = InfoHeight(); + var chips = ChipRowsHeight(); + var top = info > 0 ? System.Math.Max(FitPadding, info + FitClearance) : FitPadding; + var bottom = chips > 0 ? System.Math.Max(FitPadding, EdgePadding + chips + FitClearance) : FitPadding; + float left = FitPadding, right = FitPadding; float reachLeft = 0, reachRight = 0, reachTop = 0, reachBottom = 0; for (var pass = 0; pass < 3; pass++)