fix(desktop): show two plates in the nest progress layouts

When a layout's sheets cannot all fit the width at a third of full
height, size them so the first two fill the strip instead of keeping
full height and showing less than one plate. Open the progress window
wide (85% x 75% of the screen) so the two plates have room.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
ajandClaude Opus 5.5 committed 2026-11-27 14:46:44 -05:00
1 parent 5203646fd4
commit 0740ee1d4d
3 files changed
+38 -23

No files matched your search

@@ -74,7 +74,7 @@ public class NestReviewFormTests
}, TimeSpan.FromMinutes(1), "The STA test did not complete.");
[Fact]
public void SheetsKeepFullHeightWhenTheCaptionsAloneOverflowTheWidth() => StaTestThread.Run(() =>
public void TwoSheetsFillTheWidthWhenTheyCannotAllFit() => StaTestThread.Run(() =>
{
var stock = new NestPlateStock("sheet", new Size(48, 96), quantity: null, partSpacing: 0.25);
using var strip = new OpenNest.Controls.SheetStripControl { Size = new System.Drawing.Size(600, 300), ShowRemnant = true };
@@ -85,9 +85,13 @@ public class NestReviewFormTests
strip.SetSheets(Enumerable.Range(0, 12)
.Select(i => new ProposedPlate(i, stock, Array.Empty<Part>()))
.ToArray());
var scale = strip.PixelsPerUnit;
// One sheet fits at full height; of twelve, the first two share the width.
Assert.True(one > 0);
Assert.Equal(one, strip.PixelsPerUnit, 3);
Assert.True(scale < one);
var twoSheets = 2 * 96 * scale + 16;
Assert.InRange(twoSheets, strip.ClientSize.Width - 16 - 8, strip.ClientSize.Width - 16);
Assert.True(strip.AutoScrollMinSize.Width > strip.ClientSize.Width);
}, TimeSpan.FromMinutes(1), "The STA test did not complete.");
+28 -18
View File
@@ -120,10 +120,9 @@ namespace OpenNest.Controls
: $"{tile.Title}\n{tile.Detail}";
/// <summary>
/// Pixels per world unit, shared by every sheet. All sheets fit the width when they can;
/// otherwise they shrink to a third of full height and the strip scrolls. When the
/// captions alone are wider than the strip, shrinking cannot avoid the scroll, so the
/// sheets keep full height and the strip scrolls.
/// Pixels per world unit, shared by every sheet and at most full height. All sheets fit
/// the width when that keeps them at least a third of full height; otherwise the strip
/// scrolls with the first two sheets filling the view, so two whole plates always show.
/// </summary>
internal float PixelsPerUnit
{
@@ -136,23 +135,34 @@ namespace OpenNest.Controls
if (tallest <= 0 || height <= 0)
return 0;
var full = (float)(height / tallest);
var width = ClientSize.Width - Edge * 2 - Gap * (tiles.Count - 1);
if (tiles.Sum(t => TileWidth(t, 0)) > width)
return full;
// Largest scale whose tiles, captions included, fit the width (tile widths grow with scale).
float low = 0, high = full;
for (var i = 0; i < 24; i++)
{
var mid = (low + high) / 2;
if (tiles.Sum(t => TileWidth(t, mid)) <= width)
low = mid;
else
high = mid;
}
return System.Math.Max(low, full / 3);
var all = FitScale(tiles, full);
if (all >= full / 3)
return all;
var two = FitScale(tiles.Take(2).ToList(), full);
return two > 0 ? two : full / 3;
}
}
/// <summary>The largest scale up to <paramref name="full"/> at which <paramref name="shown"/>,
/// captions included, fit the width; 0 when their captions alone are too wide.</summary>
private float FitScale(IReadOnlyCollection<Tile> shown, float full)
{
var width = ClientSize.Width - Edge * 2 - Gap * (shown.Count - 1);
if (shown.Sum(t => TileWidth(t, 0)) > width)
return 0;
// Tile widths grow with scale, so bisect.
float low = 0, high = full;
for (var i = 0; i < 24; i++)
{
var mid = (low + high) / 2;
if (shown.Sum(t => TileWidth(t, mid)) <= width)
low = mid;
else
high = mid;
}
return low;
}
private void UpdateScrollSize()
{
var scale = PixelsPerUnit;
+4 -3
View File
@@ -204,11 +204,12 @@ namespace OpenNest.Forms
Controls.Add(header);
Controls.Add(footer);
MinimumSize = new System.Drawing.Size(640, 420);
// Tall enough that the layout cards stay readable while the search runs.
// Wide, since a card shows its first two sheets side by side across the width, and
// tall enough that the layout cards stay readable while the search runs.
var screen = Owner != null ? Screen.FromControl(Owner) : Screen.FromPoint(Cursor.Position);
Size = new System.Drawing.Size(
Size.Width - ClientSize.Width + 920,
System.Math.Max(MinimumSize.Height, (int)(screen.WorkingArea.Height * 0.8)));
System.Math.Max(MinimumSize.Width, (int)(screen.WorkingArea.Width * 0.85)),
System.Math.Max(MinimumSize.Height, (int)(screen.WorkingArea.Height * 0.75)));
ResumeLayout(true);
}