12.3b: rulers, the grid and guides on the canvas, guide drags (Compositor 1.1.7)

This commit is contained in:
雷电芽衣 committed 2026-09-26 20:55:55 -04:00
1 parent 338451fc35
commit 78bfa2445d
19 files changed
+718 -10

No files matched your search

+43
View File
@@ -0,0 +1,43 @@
#pragma once
#include "Document/EditorSession.h"
#include <QWidget>
class CanvasView;
namespace CanvasRuler {
inline constexpr int thickness = 18;
}
// The square where the two rulers meet.
class CanvasRulerCorner : public QWidget {
Q_OBJECT
public:
explicit CanvasRulerCorner(QWidget *parent = nullptr);
protected:
void paintEvent(QPaintEvent *event) override;
};
// Swift's CanvasRulerNSView: ticks in document pixels; drag out a guide.
class CanvasRulerView : public QWidget {
Q_OBJECT
public:
CanvasRulerView(EditorSession &session, CanvasGuide::Axis axis, CanvasView &canvas, QWidget *parent = nullptr);
// Numbered ticks about 70 points apart, 1-2-5 steps.
static double majorStep(double pointsPerPixel);
static QString label(double value);
protected:
void paintEvent(QPaintEvent *event) override;
void mousePressEvent(QMouseEvent *event) override;
void mouseMoveEvent(QMouseEvent *event) override;
void mouseReleaseEvent(QMouseEvent *event) override;
private:
QPointF inCanvas(QPointF point) const;
std::optional<double> documentPosition(QPointF point) const;
EditorSession &m_session;
const CanvasGuide::Axis m_axis;
CanvasView &m_canvas;
};