Merge branch 'port-d'
# Conflicts: # AGENTS.md
This commit is contained in:
commit
8204e6a28b
14 files changed
+231
-101
No files matched your search
@@ -1,48 +1,11 @@
|
||||
#include "CanvasFixtures.h"
|
||||
#include "MovePressFixtures.h"
|
||||
|
||||
// Swift's resize snapping on the canvas: handles, Ctrl, Shift.
|
||||
namespace {
|
||||
// The document fills the canvas: view points are pixels.
|
||||
struct Canvas : Shown {
|
||||
QUuid red;
|
||||
Canvas() : Shown(QSize(400, 300), QSize(400, 300))
|
||||
{
|
||||
settle();
|
||||
session.zoom(1);
|
||||
session.insert(filled(100, 100, qRgba(255, 0, 0, 255), "Red"));
|
||||
red = session.activeLayerID().value();
|
||||
session.selectTool(NavigationTool::move);
|
||||
canvas->synchronizeDisplay();
|
||||
if (session.viewport.viewPoint(QPointF(0, 0), documentSize()) != QPointF(0, 0))
|
||||
throw std::runtime_error("the document does not fill the canvas");
|
||||
}
|
||||
QPointF origin() const { return layerWith(session, red).transform.origin; }
|
||||
void press(QPointF at, Qt::KeyboardModifiers modifiers = Qt::NoModifier) { QTest::mousePress(canvas, Qt::LeftButton, modifiers, at.toPoint()); }
|
||||
void move(QPointF to, Qt::KeyboardModifiers modifiers = Qt::NoModifier)
|
||||
{
|
||||
QMouseEvent event(QEvent::MouseMove, to, to, canvas->mapToGlobal(to.toPoint()), Qt::NoButton, Qt::LeftButton, modifiers);
|
||||
QApplication::sendEvent(canvas, &event);
|
||||
}
|
||||
void release(QPointF at, Qt::KeyboardModifiers modifiers = Qt::NoModifier) { QTest::mouseRelease(canvas, Qt::LeftButton, modifiers, at.toPoint()); }
|
||||
void drag(QPointF from, QPointF to, Qt::KeyboardModifiers modifiers = Qt::NoModifier)
|
||||
{
|
||||
press(from, modifiers);
|
||||
move((from + to) / 2, modifiers);
|
||||
move(to, modifiers);
|
||||
release(to, modifiers);
|
||||
}
|
||||
void click(QPointF at, Qt::KeyboardModifiers modifiers = Qt::NoModifier)
|
||||
{
|
||||
press(at, modifiers);
|
||||
release(at, modifiers);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
class ResizeSnapCanvasTests : public QObject {
|
||||
Q_OBJECT
|
||||
private slots:
|
||||
void resizedEdgesSnapUnlessCtrl();
|
||||
void altResizesFromTheCentreAndSnaps();
|
||||
};
|
||||
|
||||
void ResizeSnapCanvasTests::resizedEdgesSnapUnlessCtrl()
|
||||
@@ -81,5 +44,21 @@ void ResizeSnapCanvasTests::resizedEdgesSnapUnlessCtrl()
|
||||
shown.release(QPointF(397, 349));
|
||||
}
|
||||
|
||||
// Swift's "resizing from the center with Option snaps too".
|
||||
void ResizeSnapCanvasTests::altResizesFromTheCentreAndSnaps()
|
||||
{
|
||||
Canvas shown;
|
||||
EditorSession &session = shown.session;
|
||||
session.setLocksTransformRatio(false);
|
||||
// Right edge to 396, left to 4: 396 snaps.
|
||||
shown.press(QPointF(250, 150), Qt::AltModifier);
|
||||
shown.move(QPointF(396, 150), Qt::AltModifier);
|
||||
QCOMPARE(session.transformEdit().value().draft, (LayerTransform{.origin = {0, 100}, .size = {400, 100}}));
|
||||
QCOMPARE(session.snapGuides, (SnapGuides{{400}, {}}));
|
||||
shown.release(QPointF(396, 150), Qt::AltModifier);
|
||||
QCOMPARE(layerWith(session, shown.red).transform, (LayerTransform{.origin = {0, 100}, .size = {400, 100}}));
|
||||
QCOMPARE(int(session.document().value().layers.size()), 1);
|
||||
}
|
||||
|
||||
QTEST_MAIN(ResizeSnapCanvasTests)
|
||||
#include "ResizeSnapCanvasTests.moc"
|
||||
Reference in new issue
Block a user