mirror of
https://github.com/ajisaacs/OpenNest.git
synced 2026-12-01 16:51:34 -05:00
fix(ui): return the placing preview to the cursor after a settled click
Shift/Ctrl+click settles the preview onto the plate, then copies it. The preview stayed on the settled copy until the mouse moved, so clicking again without moving settled from inside that copy and stacked the next part on it. The preview now goes back to where it was clicked, keeping any arrow nudge. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
e78fc45149
commit
5b67d78ac7
2 files changed
+38
-1
No files matched your search
@@ -114,6 +114,32 @@ public class ActionCloneTests
|
||||
Assert.Equal(0, copy.Bottom, 6);
|
||||
}, TimeSpan.FromMinutes(1), "The STA test did not complete.");
|
||||
|
||||
[Theory]
|
||||
[InlineData(Keys.Shift)]
|
||||
[InlineData(Keys.Control)]
|
||||
public void RepeatedModifiedClicksWithoutMovingStackNoCopies(Keys modifiers) => StaTestThread.Run(() =>
|
||||
{
|
||||
var plate = new Plate(48, 96) { PartSpacing = 0 };
|
||||
using var view = new PlateView { Plate = plate, Size = new System.Drawing.Size(600, 600) };
|
||||
view.ZoomToFit();
|
||||
view.SetAction(typeof(ActionClone), Square("new"));
|
||||
var action = Assert.IsType<ActionClone>(view.Actions.CurrentAction);
|
||||
action.PlacementOrder = OpenNest.Engine.Fill.SettleOrder.VerticalFirst;
|
||||
var preview = Assert.Single(view.SelectedParts);
|
||||
preview.BasePart.Location = new Vector(1, 20);
|
||||
|
||||
action.Apply(modifiers);
|
||||
Assert.Equal(new Vector(1, 20), preview.BasePart.BoundingBox.Location);
|
||||
action.Apply(modifiers);
|
||||
action.Apply(modifiers);
|
||||
|
||||
Assert.Equal(3, plate.Parts.Count);
|
||||
var bottoms = plate.Parts.Select(p => p.BoundingBox.Bottom).OrderBy(y => y).ToList();
|
||||
Assert.Equal(0, bottoms[0], 6);
|
||||
Assert.InRange(bottoms[1], 4, 4.01);
|
||||
Assert.InRange(bottoms[2], 8, 8.02);
|
||||
}, TimeSpan.FromMinutes(1), "The STA test did not complete.");
|
||||
|
||||
[Fact]
|
||||
public void ADialogsFakeMouseMoveLeavesNudgedPreviewsInPlace() => StaTestThread.Run(() =>
|
||||
{
|
||||
|
||||
@@ -209,7 +209,9 @@ namespace OpenNest.Actions
|
||||
change.MarkChanged();
|
||||
var shift = (modifiers & Keys.Shift) == Keys.Shift;
|
||||
var boxesOnly = !shift && (modifiers & Keys.Control) == Keys.Control;
|
||||
if (shift || boxesOnly)
|
||||
var settles = shift || boxesOnly;
|
||||
var home = parts.GetBoundingBox().Location;
|
||||
if (settles)
|
||||
{
|
||||
var movingParts = parts.Select(p => p.BasePart).ToList();
|
||||
|
||||
@@ -251,6 +253,15 @@ namespace OpenNest.Actions
|
||||
foreach (var (members, kerf) in commonLines)
|
||||
plateView.Plate.JoinCommonLine(members.Select(i => placed[i]), kerf);
|
||||
|
||||
// Put the previews back where they were clicked: left on the settled copy, the
|
||||
// next click without moving the mouse would settle from inside it and stack on it.
|
||||
if (settles)
|
||||
{
|
||||
var back = home - parts.GetBoundingBox().Location;
|
||||
parts.ForEach(p => p.Offset(back));
|
||||
plateView.Invalidate();
|
||||
}
|
||||
|
||||
if (plateView.Plate.CutOffs.Count > 0)
|
||||
plateView.Plate.RegenerateCutOffs(plateView.CutOffSettings);
|
||||
change.Complete();
|
||||
|
||||
Reference in new issue
Block a user