14.5: one View › Snap for all snapping
This commit is contained in:
14 files changed
+33
-43
No files matched your search
@@ -154,7 +154,7 @@ SnapGuides EditorSession::transformSnapTargets(const QSet<QUuid> &moving) const
|
||||
// `draft` nudged onto a nearby edge or middle, within `tolerance`.
|
||||
LayerTransform EditorSession::snappedMove(const LayerTransform &draft, const QSet<QUuid> &moving, double tolerance)
|
||||
{
|
||||
if (!m_snappingEnabled) {
|
||||
if (!snappingEnabled()) {
|
||||
snapGuides = {};
|
||||
return draft;
|
||||
}
|
||||
@@ -172,7 +172,7 @@ LayerTransform EditorSession::snappedMove(const LayerTransform &draft, const QSe
|
||||
QPointF EditorSession::snappedResizePoint(QPointF point, const TransformDrag &drag, bool proportional, const QSet<QUuid> &moving,
|
||||
double tolerance, const std::function<LayerTransform(QPointF)> &update)
|
||||
{
|
||||
if (!m_snappingEnabled || drag.mode.kind != TransformDrag::Kind::resize || drag.original.radians() != 0) {
|
||||
if (!snappingEnabled() || drag.mode.kind != TransformDrag::Kind::resize || drag.original.radians() != 0) {
|
||||
snapGuides = {};
|
||||
return point;
|
||||
}
|
||||
@@ -228,7 +228,7 @@ SnapGuides EditorSession::cropSnapTargets() const
|
||||
|
||||
QPointF EditorSession::snappedPoint(QPointF point, double tolerance)
|
||||
{
|
||||
if (!m_snappingEnabled) {
|
||||
if (!snappingEnabled()) {
|
||||
snapGuides = {};
|
||||
return point;
|
||||
}
|
||||
@@ -248,7 +248,7 @@ QPointF EditorSession::snappedPoint(QPointF point, double tolerance)
|
||||
|
||||
QSizeF EditorSession::snappedSelectionOffset(QSizeF offset, double tolerance, bool horizontal, bool vertical)
|
||||
{
|
||||
if (!m_snappingEnabled || !m_selectionMoveOrigin) {
|
||||
if (!snappingEnabled() || !m_selectionMoveOrigin) {
|
||||
snapGuides = {};
|
||||
return offset;
|
||||
}
|
||||
|
||||
@@ -368,14 +368,6 @@ void EditorSession::setShowsPixelGrid(bool shows)
|
||||
notify();
|
||||
}
|
||||
|
||||
void EditorSession::setSnappingEnabled(bool enabled)
|
||||
{
|
||||
m_snappingEnabled = enabled;
|
||||
if (!enabled)
|
||||
snapGuides = {};
|
||||
notify();
|
||||
}
|
||||
|
||||
void EditorSession::setCropRect(std::optional<QRectF> rect)
|
||||
{
|
||||
if (std::exchange(m_cropRect, rect) != rect)
|
||||
|
||||
@@ -243,9 +243,8 @@ public:
|
||||
// The View menu's grid, shown from 800%.
|
||||
bool showsPixelGrid() const { return m_showsPixelGrid; }
|
||||
void setShowsPixelGrid(bool shows);
|
||||
// View > Snap: moves and crops line up with edges.
|
||||
bool snappingEnabled() const { return m_snappingEnabled; }
|
||||
void setSnappingEnabled(bool enabled);
|
||||
// Swift's alias of View › Snap: moves, crops, drawing.
|
||||
bool snappingEnabled() const { return m_snapEnabled; }
|
||||
// The Eyedropper's ring: the sampled colour over the original.
|
||||
bool showsSampleRing() const { return m_showsSampleRing; }
|
||||
void setShowsSampleRing(bool shows);
|
||||
@@ -345,7 +344,6 @@ private:
|
||||
std::optional<QUuid> m_renamingLayerID;
|
||||
std::optional<QString> m_projectPath;
|
||||
bool m_showsPixelGrid = ToolDefaults::boolean(QStringLiteral("pixelGrid"), true);
|
||||
bool m_snappingEnabled = true;
|
||||
// The layout grid starts off; guides show; rulers hide.
|
||||
bool m_showsGrid = ToolDefaults::boolean(QStringLiteral("grid"), false);
|
||||
LayoutGrid m_layoutGrid = LayoutGrid::stored();
|
||||
|
||||
@@ -220,6 +220,8 @@ void EditorSession::setSnapEnabled(bool enabled)
|
||||
{
|
||||
m_snapEnabled = enabled;
|
||||
ToolDefaults::set(enabled, QStringLiteral("snap"));
|
||||
if (!enabled)
|
||||
snapGuides = {};
|
||||
notify();
|
||||
}
|
||||
|
||||
|
||||
@@ -135,8 +135,6 @@ CompositorMenus::CompositorMenus(ProjectWorkspace &workspace, QMenuBar &bar, QWi
|
||||
add(view, QStringLiteral("zoomOut"), QStringLiteral("Zoom Out"), QKeySequence(Qt::CTRL | Qt::Key_Minus), [zoomBy] { zoomBy(-1); });
|
||||
add(view, QStringLiteral("pixelGrid"), QStringLiteral("Pixel Grid (800% and above)"), QKeySequence(), [this] { session().setShowsPixelGrid(!session().showsPixelGrid()); })
|
||||
->setCheckable(true);
|
||||
add(view, QStringLiteral("snap"), QStringLiteral("Snap"), QKeySequence(), [this] { session().setSnappingEnabled(!session().snappingEnabled()); })
|
||||
->setCheckable(true);
|
||||
// Ctrl+H: the Move tool's box; the desktop hides apps.
|
||||
add(view, QStringLiteral("transformControls"), QStringLiteral("Show Transform Controls"), QKeySequence(Qt::CTRL | Qt::Key_H),
|
||||
[this] { session().setShowsTransformControls(!session().showsTransformControls()); })
|
||||
@@ -356,7 +354,6 @@ void CompositorMenus::synchronize()
|
||||
for (const char *name : {"fit", "actualPixels", "zoomIn", "zoomOut"})
|
||||
action(QString::fromLatin1(name))->setEnabled(drawn);
|
||||
action(QStringLiteral("pixelGrid"))->setChecked(s.showsPixelGrid());
|
||||
action(QStringLiteral("snap"))->setChecked(s.snappingEnabled());
|
||||
const bool opened = s.document().has_value();
|
||||
for (const auto &[name, value] : std::initializer_list<std::pair<const char *, bool>>{
|
||||
{"showGrid", s.showsGrid()}, {"showGuides", s.showsGuides()}, {"showRulers", s.showsRulers()}, {"snapEnabled", s.snapEnabled()},
|
||||
|
||||
Reference in new issue
Block a user