Shift keeps moved pixels on a line; Ctrl+A selects the canvas from the Layers panel (13.10)

This commit is contained in:
ZacharyZhang-NY committed 2026-10-01 14:35:13 -04:00
1 parent 765e071c0c
commit 51e373af4c
6 files changed
+54 -32

No files matched your search

+12 -7
View File
@@ -121,17 +121,22 @@ void SelectMenuTests::selectAllInAFieldIsTheFields()
QVERIFY(!bar.session().selection().has_value());
QTest::keyClick(editor, Qt::Key_Escape);
QTRY_VERIFY(!bar.session().renamingLayerID().has_value());
// The list holds the keys: its rows, as Swift's table.
// The list holds the keys: the canvas, never every layer.
bar.session().addBlankLayer();
NativeLayerList *list = bar.window.findChild<NativeLayerList *>();
list->setFocus();
QTRY_VERIFY(list->hasFocus());
const std::vector<ImageLayer> &layers = bar.session().document().value().layers;
bar.action("selectAll").trigger();
QCOMPARE(bar.session().selectedLayerIDs(), (QSet<QUuid>{layers[0].id, layers[1].id}));
QCOMPARE(bar.session().activeLayerID(), std::optional(layers[1].id));
QVERIFY(!bar.session().selection().has_value());
// Elsewhere it selects the canvas.
const QSet<QUuid> selected = bar.session().selectedLayerIDs();
const std::optional<QUuid> active = bar.session().activeLayerID();
QCOMPARE(selected.size(), 1);
QTest::keyClick(list, Qt::Key_A, Qt::ControlModifier);
QCOMPARE(bar.session().selection().value().path.boundingRect(), QRectF(0, 0, 50, 50));
QCOMPARE(bar.session().history.undoName(), QString("Select All"));
QCOMPARE(bar.session().selectedLayerIDs(), selected);
QCOMPARE(bar.session().activeLayerID(), active);
QVERIFY(list->hasFocus());
// Elsewhere it selects the canvas too.
bar.session().deselect();
bar.window.findChild<CanvasView *>()->setFocus();
QTRY_VERIFY(!list->hasFocus());
bar.action("selectAll").trigger();
+33
View File
@@ -11,6 +11,7 @@ private slots:
void focusLossEndsAMarqueeDraftAndAnOutlineMove();
void shiftDeleteBeginsAContentAwareFill();
void aCtrlDragMovesSelectedPixelsAndCtrlArrowsNudgeThem();
void shiftKeepsMovedPixelsOnALine();
};
void SelectionCanvasTests::marqueeDragsSelectShiftAddsAltSubtractsAndAFreshShiftSquares()
@@ -322,5 +323,37 @@ void SelectionCanvasTests::aCtrlDragMovesSelectedPixelsAndCtrlArrowsNudgeThem()
QVERIFY(session.lassoDraft().has_value() && !session.pixelMove());
}
void SelectionCanvasTests::shiftKeepsMovedPixelsOnALine()
{
Canvas shown;
EditorSession &session = shown.session;
QImage red = BrushRaster::context(400, 300, false);
red.fill(Qt::red);
session.insert(ImportedImage(red, red, "Red"));
session.applySelection(rectPath(QRectF(20, 20, 40, 40)), SelectionMode::replace, "Select");
shown.canvas->synchronizeDisplay();
const auto box = [&] { return session.displayedSelection().value().path.boundingRect(); };
shown.press(QPointF(40, 40), Qt::ControlModifier);
QVERIFY(session.pixelMove());
// Across: the drag went further that way.
shown.move(QPointF(100, 55), Qt::ControlModifier | Qt::ShiftModifier);
QCOMPARE(box(), QRectF(80, 20, 40, 40));
// Down, then a tie keeps across.
shown.move(QPointF(50, 100), Qt::ControlModifier | Qt::ShiftModifier);
QCOMPARE(box(), QRectF(20, 80, 40, 40));
shown.move(QPointF(10, 10), Qt::ControlModifier | Qt::ShiftModifier);
QCOMPARE(box(), QRectF(-10, 20, 40, 40));
// Lengths, not signs: left beats a shorter down.
shown.move(QPointF(0, 50), Qt::ControlModifier | Qt::ShiftModifier);
QCOMPARE(box(), QRectF(-20, 20, 40, 40));
// Without Shift both ways.
shown.move(QPointF(60, 55), Qt::ControlModifier);
QCOMPARE(box(), QRectF(40, 35, 40, 40));
shown.move(QPointF(70, 45), Qt::ControlModifier | Qt::ShiftModifier);
shown.release(QPointF(70, 45), Qt::ControlModifier | Qt::ShiftModifier);
QTRY_VERIFY(!session.pixelMove());
QCOMPARE(session.selection().value().path.boundingRect(), QRectF(50, 20, 40, 40));
}
QTEST_MAIN(SelectionCanvasTests)
#include "SelectionCanvasTests.moc"