Skip to content

OpenToonz - An open-source full-featured 2D animation creation software

C

fix ruler

shun_iwasawac23689f93ba4
diff --git a/toonz/sources/toonz/ruler.cpp b/toonz/sources/toonz/ruler.cpp
index ab37199f4..7c5556ada 100644
--- a/toonz/sources/toonz/ruler.cpp
+++ b/toonz/sources/toonz/ruler.cpp
@@ -102,10 +102,10 @@ double Ruler::getPan() const {
if (m_viewer->is3DView()) // Vertical 3D
return m_viewer->getPan3D().y;
else // Vertical 2D
- return aff.a23;
+ return aff.a23 / m_viewer->getDevPixRatio();
else if (m_viewer->is3DView()) // Horizontal 3D
return m_viewer->getPan3D().x;
- return aff.a13; // Horizontal 2D
+ return aff.a13 / m_viewer->getDevPixRatio(); // Horizontal 2D
}
//-----------------------------------------------------------------------------
@@ -129,7 +129,7 @@ void Ruler::drawVertical(QPainter &p) {
for (i = 0; i < count; i++) {
QColor color =
(m_moving && count - 1 == i ? QColor(0, 255, 255) : QColor(0, 0, 255));
- double v = guides[i];
+ double v = guides[i] / (double)m_viewer->getDevPixRatio();
int y = (int)(origin - zoom * v);
p.fillRect(QRect(x0, y - 1, x1 - x0, 2), QBrush(color));
}
@@ -184,7 +184,7 @@ void Ruler::drawHorizontal(QPainter &p) {
for (i = 0; i < count; i++) {
QColor color =
(m_moving && count - 1 == i ? QColor(0, 255, 255) : QColor(0, 0, 255));
- double v = guides[i];
+ double v = guides[i] / (double)m_viewer->getDevPixRatio();
int x = (int)(origin + zoom * v);
p.fillRect(QRect(x - 1, y0, 2, y1 - y0), QBrush(color));
}
@@ -247,7 +247,7 @@ void Ruler::mousePressEvent(QMouseEvent *e) {
int i;
int count = guides.size();
for (i = 0; i < count; i++) {
- double g = guides[i];
+ double g = guides[i] / (double)m_viewer->getDevPixRatio();
double dist2 = (g - v) * (g - v);
if (selected < 0 || dist2 < minDist2) {
minDist2 = dist2;
@@ -256,7 +256,7 @@ void Ruler::mousePressEvent(QMouseEvent *e) {
}
if (selected < 0 || minDist2 > 25) {
// crea una nuova guida
- guides.push_back(v);
+ guides.push_back(v * m_viewer->getDevPixRatio());
m_viewer->update();
// aggiorna sprop!!!!
} else {
@@ -275,7 +275,7 @@ void Ruler::mousePressEvent(QMouseEvent *e) {
void Ruler::mouseMoveEvent(QMouseEvent *e) {
if (m_moving) {
m_hiding = m_vertical ? (e->pos().x() < 0) : (e->pos().y() < 0);
- getGuides().back() = posToValue(e->pos());
+ getGuides().back() = posToValue(e->pos()) * m_viewer->getDevPixRatio();
// aggiorna sprop!!!!
update();
m_viewer->update();
@@ -290,7 +290,7 @@ void Ruler::mouseMoveEvent(QMouseEvent *e) {
int i;
int count = guides.size();
for (i = 0; i < count; i++) {
- double g = guides[i];
+ double g = guides[i] / (double)m_viewer->getDevPixRatio();
double dist2 = (g - v) * (g - v);
if (dist2 < minDist2)
setToolTip(tr("Click and drag to move guide"));
diff --git a/toonz/sources/toonz/viewerdraw.cpp b/toonz/sources/toonz/viewerdraw.cpp
index 4ef96bc80..f72e27274 100644
--- a/toonz/sources/toonz/viewerdraw.cpp
+++ b/toonz/sources/toonz/viewerdraw.cpp
@@ -263,9 +263,11 @@ void ViewerDraw::drawGridAndGuides(SceneViewer *viewer, double sc, Ruler *vr,
if (vr) vGuideCount = vr->getGuideCount();
if (hr) hGuideCount = hr->getGuideCount();
- int rectX1, rectx2, recty1, recty2;
- viewer->geometry().getCoords(&rectX1, &rectx2, &recty1, &recty2);
- TRect clipRect = TRect(rectX1 - 20, recty2 + 20, recty1 + 10, rectx2 - 10);
+ // int xp1, yp1, xp2, yp2;
+ // viewer->geometry().getCoords(&xp1, &yp1, &xp2, &yp2);
+ TRect clipRect = TRect(-20, -10, viewer->width() + 10, viewer->height() + 20);
+ // TRect clipRect = TRect(xp1- 20, yp2 + 20, xp2 + 10, yp1 - 10);
+ // viewer->rect().adjusted(-20, -10, 10, 20);
clipRect -=
TPoint((clipRect.x0 + clipRect.x1) / 2, (clipRect.y0 + clipRect.y1) / 2);