Skip to content

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

C

Fix high dpi multimonitor glitch

shun-iwasawaf2e1688c9b42
diff --git a/toonz/sources/include/tools/stylepicker.h b/toonz/sources/include/tools/stylepicker.h
index 182f91ab9..03b67aea8 100644
--- a/toonz/sources/include/tools/stylepicker.h
+++ b/toonz/sources/include/tools/stylepicker.h
@@ -8,6 +8,7 @@
#include "tpalette.h"
class TStroke;
+class QWidget;
#undef DVAPI
#undef DVVAR
@@ -22,15 +23,17 @@ class TStroke;
class DVAPI StylePicker {
TImageP m_image;
TPaletteP m_palette;
+ const QWidget *m_widget;
public:
- StylePicker() {}
+ StylePicker(const QWidget *parent) : m_widget(parent) {}
// usa come palette la palette dell'immagine
- StylePicker(const TImageP &image);
+ StylePicker(const QWidget *parent, const TImageP &image);
// palette esterna (ad es. se image e' di tipo raster)
- StylePicker(const TImageP &image, const TPaletteP &palette);
+ StylePicker(const QWidget *parent, const TImageP &image,
+ const TPaletteP &palette);
// pickStyleId(point, radius)
//
diff --git a/toonz/sources/include/tools/tool.h b/toonz/sources/include/tools/tool.h
index 548b91e23..5ccf7e7b7 100644
--- a/toonz/sources/include/tools/tool.h
+++ b/toonz/sources/include/tools/tool.h
@@ -594,9 +594,10 @@ protected:
int guidedStrokePickMode = 0;
int m_guidedFrontStroke = -1;
int m_guidedBackStroke = -1;
+ QWidget *m_viewerWidget = nullptr;
public:
- Viewer() {}
+ Viewer(QWidget *widget) : m_viewerWidget(widget) {}
virtual ~Viewer() {}
const ImagePainter::VisualSettings &visualSettings() const {
@@ -706,6 +707,8 @@ public:
void getGuidedFrameIdx(int *backIdx, int *frontIdx);
void doPickGuideStroke(const TPointD &pos);
+
+ QWidget *viewerWidget() { return m_viewerWidget; }
};
#endif
diff --git a/toonz/sources/include/toonzqt/glwidget_for_highdpi.h b/toonz/sources/include/toonzqt/glwidget_for_highdpi.h
index 258e17cf4..eef8abb4d 100644
--- a/toonz/sources/include/toonzqt/glwidget_for_highdpi.h
+++ b/toonz/sources/include/toonzqt/glwidget_for_highdpi.h
@@ -19,6 +19,7 @@ public:
int width() const { return QOpenGLWidget::width() * getDevPixRatio(); }
int height() const { return QOpenGLWidget::height() * getDevPixRatio(); }
QRect rect() const { return QRect(0, 0, width(), height()); }
+ int getDevPixRatio() const { return getDevicePixelRatio(this); }
};
#endif
\ No newline at end of file
diff --git a/toonz/sources/include/toonzqt/gutil.h b/toonz/sources/include/toonzqt/gutil.h
index c98641341..19cabb1f9 100644
--- a/toonz/sources/include/toonzqt/gutil.h
+++ b/toonz/sources/include/toonzqt/gutil.h
@@ -104,7 +104,7 @@ svgToPixmap(const QString &svgFilePath, const QSize &size = QSize(),
// returns device-pixel ratio. It is 1 for normal monitors and 2 (or higher
// ratio) for high DPI monitors. Setting "Display > Set custom text size(DPI)"
// for Windows corresponds to this ratio.
-int DVAPI getDevPixRatio();
+int DVAPI getDevicePixelRatio(const QWidget *widget = nullptr);
//-----------------------------------------------------------------------------
diff --git a/toonz/sources/tnztools/edittool.cpp b/toonz/sources/tnztools/edittool.cpp
index 9eb094f61..afc6b3d16 100644
--- a/toonz/sources/tnztools/edittool.cpp
+++ b/toonz/sources/tnztools/edittool.cpp
@@ -1264,7 +1264,7 @@ void EditTool::drawMainHandle() {
TAffine parentAff = xsh->getParentPlacement(objId, frame);
TAffine aff = xsh->getPlacement(objId, frame);
TPointD center = Stage::inch * xsh->getCenter(objId, frame);
- int devPixRatio = getDevPixRatio();
+ int devPixRatio = getDevicePixelRatio(m_viewer->viewerWidget());
// the gadget appears on the center of the level. orientation and dimension
// are independent of the movement of the level
glPushMatrix();
diff --git a/toonz/sources/tnztools/edittoolgadgets.cpp b/toonz/sources/tnztools/edittoolgadgets.cpp
index 7c8127ad8..4f4d426e1 100644
--- a/toonz/sources/tnztools/edittoolgadgets.cpp
+++ b/toonz/sources/tnztools/edittoolgadgets.cpp
@@ -17,6 +17,7 @@
#include "tparamuiconcept.h"
#include "historytypes.h"
+#include "toonzqt/gutil.h"
#include <QApplication>
#include <QDesktopWidget>
@@ -26,11 +27,6 @@ using namespace EditToolGadgets;
GLdouble FxGadget::m_selectedColor[3] = {0.2, 0.8, 0.1};
namespace {
-int getDevPixRatio() {
- static int devPixRatio = QApplication::desktop()->devicePixelRatio();
- return devPixRatio;
-}
-
TPointD hadamard(const TPointD &v1, const TPointD &v2) {
return TPointD(v1.x * v2.x, v1.y * v2.y);
}
@@ -199,14 +195,14 @@ void FxGadget::setValue(const TPointParamP &param, const TPointD &pos) {
//---------------------------------------------------------------------------
void FxGadget::setPixelSize() {
- setPixelSize(sqrt(tglGetPixelSize2()) * getDevPixRatio());
+ setPixelSize(sqrt(tglGetPixelSize2()) * m_controller->getDevPixRatio());
}
//---------------------------------------------------------------------------
void FxGadget::drawTooltip(const TPointD &tooltipPos,
std::string tooltipPosText) {
- double unit = sqrt(tglGetPixelSize2()) * getDevPixRatio();
+ double unit = sqrt(tglGetPixelSize2()) * m_controller->getDevPixRatio();
glPushMatrix();
glTranslated(tooltipPos.x, tooltipPos.y, 0.0);
double sc = unit * 1.6;
@@ -494,7 +490,7 @@ void AngleFxGadget::draw(bool picking) {
else
glColor3d(0, 0, 1);
glPushName(getId());
- double pixelSize = sqrt(tglGetPixelSize2()) * getDevPixRatio();
+ double pixelSize = sqrt(tglGetPixelSize2()) * m_controller->getDevPixRatio();
double r = pixelSize * 40;
double a = pixelSize * 10, b = pixelSize * 5;
tglDrawCircle(m_pos, r);
@@ -579,7 +575,7 @@ void AngleRangeFxGadget::draw(bool picking) {
glColor3d(0, 0, 1);
};
- double pixelSize = sqrt(tglGetPixelSize2()) * getDevPixRatio();
+ double pixelSize = sqrt(tglGetPixelSize2()) * m_controller->getDevPixRatio();
double r = pixelSize * 200;
double a = pixelSize * 30;
@@ -2063,3 +2059,7 @@ int FxGadgetController::getCurrentFrame() const { return m_tool->getFrame(); }
//---------------------------------------------------------------------------
void FxGadgetController::invalidateViewer() { m_tool->invalidate(); }
+
+int FxGadgetController::getDevPixRatio() {
+ return getDevicePixelRatio(m_tool->getViewer()->viewerWidget());
+}
diff --git a/toonz/sources/tnztools/edittoolgadgets.h b/toonz/sources/tnztools/edittoolgadgets.h
index 17362f671..ceb1564c6 100644
--- a/toonz/sources/tnztools/edittoolgadgets.h
+++ b/toonz/sources/tnztools/edittoolgadgets.h
@@ -151,6 +151,8 @@ public:
bool hasGadget() { return m_gadgets.size() != 0; }
+ int getDevPixRatio();
+
public slots:
void onFxSwitched();
diff --git a/toonz/sources/tnztools/filltool.cpp b/toonz/sources/tnztools/filltool.cpp
index 1cab85b78..ee942bedc 100644
--- a/toonz/sources/tnztools/filltool.cpp
+++ b/toonz/sources/tnztools/filltool.cpp
@@ -2172,7 +2172,7 @@ int FillTool::pick(const TImageP &image, const TPointD &pos, const int frame) {
TVectorImageP vi = image;
if (!ti && !vi) return 0;
- StylePicker picker(image);
+ StylePicker picker(getViewer()->viewerWidget(), image);
double scale2 = 1.0;
if (vi) {
TAffine aff = getViewer()->getViewMatrix() * getCurrentColumnMatrix(frame);
diff --git a/toonz/sources/tnztools/fingertool.cpp b/toonz/sources/tnztools/fingertool.cpp
index 09f6ef5fc..7555adedb 100644
--- a/toonz/sources/tnztools/fingertool.cpp
+++ b/toonz/sources/tnztools/fingertool.cpp
@@ -561,7 +561,7 @@ void FingerTool::pick(const TPointD &pos) {
int subsampling = level->getImageSubsampling(getCurrentFid());
- StylePicker picker(image);
+ StylePicker picker(getViewer()->viewerWidget(), image);
int styleId =
picker.pickStyleId(TScale(1.0 / subsampling) * pos + TPointD(-0.5, -0.5),
diff --git a/toonz/sources/tnztools/rgbpickertool.cpp b/toonz/sources/tnztools/rgbpickertool.cpp
index 4b1f4f6d5..9737ea8b0 100644
--- a/toonz/sources/tnztools/rgbpickertool.cpp
+++ b/toonz/sources/tnztools/rgbpickertool.cpp
@@ -430,7 +430,7 @@ void RGBPickerTool::passivePick() {
TRectD area = TRectD(m_mousePixelPosition.x, m_mousePixelPosition.y,
m_mousePixelPosition.x, m_mousePixelPosition.y);
- StylePicker picker(image);
+ StylePicker picker(getViewer()->viewerWidget(), image);
if (LutManager::instance()->isValid()) m_viewer->bindFBO();
@@ -458,7 +458,7 @@ void RGBPickerTool::pick() {
TRectD area = TRectD(m_mousePixelPosition.x - 1, m_mousePixelPosition.y - 1,
m_mousePixelPosition.x + 1, m_mousePixelPosition.y + 1);
- StylePicker picker(image, palette);
+ StylePicker picker(getViewer()->viewerWidget(), image, palette);
if (LutManager::instance()->isValid()) m_viewer->bindFBO();
@@ -491,7 +491,7 @@ void RGBPickerTool::pickRect() {
}
m_selectingRect.empty();
if (area.getLx() <= 1 || area.getLy() <= 1) return;
- StylePicker picker(image, palette);
+ StylePicker picker(getViewer()->viewerWidget(), image, palette);
if (LutManager::instance()->isValid()) m_viewer->bindFBO();
@@ -511,7 +511,7 @@ void RGBPickerTool::pickStroke() {
TPalette *palette = ph->getPalette();
if (!palette) return;
- StylePicker picker(image, palette);
+ StylePicker picker(getViewer()->viewerWidget(), image, palette);
TStroke *stroke = new TStroke(*m_stroke);
if (LutManager::instance()->isValid()) m_viewer->bindFBO();
diff --git a/toonz/sources/tnztools/shifttracetool.cpp b/toonz/sources/tnztools/shifttracetool.cpp
index b1fcdcfdb..4738d63aa 100644
--- a/toonz/sources/tnztools/shifttracetool.cpp
+++ b/toonz/sources/tnztools/shifttracetool.cpp
@@ -245,7 +245,7 @@ void ShiftTraceTool::drawControlRect() { // TODO
inksOnly);
color = (m_ghostIndex == 0) ? backOniColor : frontOniColor;
double unit = sqrt(tglGetPixelSize2());
- unit *= getDevPixRatio();
+ unit *= getDevicePixelRatio(m_viewer->viewerWidget());
TRectD coloredBox = box.enlarge(3.0 * unit);
tglColor(color);
glBegin(GL_LINE_STRIP);
diff --git a/toonz/sources/tnztools/stylepicker.cpp b/toonz/sources/tnztools/stylepicker.cpp
index b2031497a..bee9eda15 100644
--- a/toonz/sources/tnztools/stylepicker.cpp
+++ b/toonz/sources/tnztools/stylepicker.cpp
@@ -17,13 +17,14 @@
//---------------------------------------------------------
-StylePicker::StylePicker(const TImageP &image)
- : m_image(image), m_palette(image->getPalette()) {}
+StylePicker::StylePicker(const QWidget *parent, const TImageP &image)
+ : m_widget(parent), m_image(image), m_palette(image->getPalette()) {}
//---------------------------------------------------------
-StylePicker::StylePicker(const TImageP &image, const TPaletteP &palette)
- : m_image(image), m_palette(palette) {}
+StylePicker::StylePicker(const QWidget *parent, const TImageP &image,
+ const TPaletteP &palette)
+ : m_widget(parent), m_image(image), m_palette(palette) {}
//---------------------------------------------------------
@@ -86,7 +87,7 @@ int StylePicker::pickStyleId(const TPointD &pos, double radius, double scale2,
// la thickness, cioe' la min distance dalla outline e non dalla centerLine
strokeFound = vi->getNearestStroke(pos, w, index, dist2);
if (strokeFound) {
- int devPixRatio = getDevPixRatio();
+ int devPixRatio = getDevicePixelRatio(m_widget);
dist2 *= scale2;
TStroke *stroke = vi->getStroke(index);
thick = stroke->getThickPoint(w).thick;
diff --git a/toonz/sources/tnztools/stylepickertool.cpp b/toonz/sources/tnztools/stylepickertool.cpp
index 4c94331bf..eccee88e4 100644
--- a/toonz/sources/tnztools/stylepickertool.cpp
+++ b/toonz/sources/tnztools/stylepickertool.cpp
@@ -116,7 +116,7 @@ void StylePickerTool::pick(const TPointD &pos, const TMouseEvent &e,
TAffine aff =
getViewer()->getViewMatrix() * getColumnMatrix(superPickedColumnId);
double scale2 = aff.det();
- StylePicker superPicker(pickedImage);
+ StylePicker superPicker(getViewer()->viewerWidget(), pickedImage);
int picked_subsampling =
picked_level->getImageSubsampling(pickedCell.getFrameId());
int superPicked_StyleId = superPicker.pickStyleId(
@@ -159,7 +159,7 @@ void StylePickerTool::pick(const TPointD &pos, const TMouseEvent &e,
TAffine aff = getViewer()->getViewMatrix() * getCurrentColumnMatrix();
double scale2 = aff.det();
int subsampling = level->getImageSubsampling(getCurrentFid());
- StylePicker picker(image);
+ StylePicker picker(getViewer()->viewerWidget(), image);
int styleId =
picker.pickStyleId(TScale(1.0 / subsampling) * pos + TPointD(-0.5, -0.5),
10.0, scale2, modeValue);
@@ -215,7 +215,7 @@ void StylePickerTool::mouseMove(const TPointD &pos, const TMouseEvent &e) {
TAffine aff = getViewer()->getViewMatrix() * getCurrentColumnMatrix();
double scale2 = aff.det();
int subsampling = level->getImageSubsampling(getCurrentFid());
- StylePicker picker(image);
+ StylePicker picker(getViewer()->viewerWidget(), image);
TPointD pickPos(TScale(1.0 / subsampling) * pos + TPointD(-0.5, -0.5));
int inkStyleId = picker.pickStyleId(pickPos, 10.0, scale2, 1);
int paintStyleId = picker.pickStyleId(pickPos, 10.0, scale2, 0);
diff --git a/toonz/sources/tnztools/toolutils.cpp b/toonz/sources/tnztools/toolutils.cpp
index b562ba853..674ee004f 100644
--- a/toonz/sources/tnztools/toolutils.cpp
+++ b/toonz/sources/tnztools/toolutils.cpp
@@ -1500,7 +1500,9 @@ void ToolUtils::drawBalloon(const TPointD &pos, std::string text,
const TPixel32 &color, TPoint delta,
double pixelSize, bool isPicking,
std::vector<TRectD> *otherBalloons) {
- int devPixRatio = getDevPixRatio();
+ TTool::Viewer *viewer =
+ TTool::getApplication()->getCurrentTool()->getTool()->getViewer();
+ int devPixRatio = getDevicePixelRatio(viewer->viewerWidget());
QString qText = QString::fromStdString(text);
QFont font("Arial"); // ,QFont::Bold);
font.setPixelSize(13 * devPixRatio);
@@ -1553,9 +1555,6 @@ void ToolUtils::drawBalloon(const TPointD &pos, std::string text,
int y1 = textRect.bottom() + mrg;
if (isPicking) {
- TTool::Viewer *viewer =
- TTool::getApplication()->getCurrentTool()->getTool()->getViewer();
-
if (viewer->is3DView()) {
double x0 = pos.x + textRect.left() * pixelSize,
y0 = pos.y + delta.y * pixelSize;
@@ -1645,7 +1644,9 @@ void ToolUtils::drawBalloon(const TPointD &pos, std::string text,
void ToolUtils::drawHook(const TPointD &pos, ToolUtils::HookType type,
bool highlighted, bool onionSkin) {
- int devPixRatio = getDevPixRatio();
+ TTool::Viewer *viewer =
+ TTool::getApplication()->getCurrentTool()->getTool()->getViewer();
+ int devPixRatio = getDevicePixelRatio(viewer->viewerWidget());
int r = 10, d = r + r;
QImage image(d * devPixRatio, d * devPixRatio, QImage::Format_ARGB32);
image.fill(Qt::transparent);
diff --git a/toonz/sources/toonz/colormodelviewer.cpp b/toonz/sources/toonz/colormodelviewer.cpp
index 8fa96a459..9d1ca28a4 100644
--- a/toonz/sources/toonz/colormodelviewer.cpp
+++ b/toonz/sources/toonz/colormodelviewer.cpp
@@ -271,14 +271,16 @@ void ColorModelViewer::contextMenuEvent(QContextMenuEvent *event) {
/*! If left button is pressed recall \b pick() in event pos.
*/
void ColorModelViewer::mousePressEvent(QMouseEvent *event) {
- if (event->button() == Qt::LeftButton) pick(event->pos() * getDevPixRatio());
+ if (event->button() == Qt::LeftButton)
+ pick(event->pos() * getDevicePixelRatio(this));
}
//-----------------------------------------------------------------------------
/*! If left button is moved recall \b pick() in event pos.
*/
void ColorModelViewer::mouseMoveEvent(QMouseEvent *event) {
- if (event->buttons() & Qt::LeftButton) pick(event->pos() * getDevPixRatio());
+ if (event->buttons() & Qt::LeftButton)
+ pick(event->pos() * getDevicePixelRatio(this));
}
//-----------------------------------------------------------------------------
@@ -296,7 +298,7 @@ void ColorModelViewer::pick(const QPoint &p) {
/*- 画面外ではPickできない -*/
if (!m_imageViewer->rect().contains(p)) return;
- StylePicker picker(img, currentPalette);
+ StylePicker picker(this, img, currentPalette);
QPoint viewP = m_imageViewer->mapFrom(this, p);
TPointD pos = m_imageViewer->getViewAff().inv() *
diff --git a/toonz/sources/toonz/flipbook.cpp b/toonz/sources/toonz/flipbook.cpp
index fa613d402..b14c3b271 100644
--- a/toonz/sources/toonz/flipbook.cpp
+++ b/toonz/sources/toonz/flipbook.cpp
@@ -2122,8 +2122,8 @@ void FlipBook::adaptGeometryToCurrentSize() {
if (!img) return;
TAffine toWidgetRef(m_imageViewer->getImgToWidgetAffine());
- TRectD pixGeomD(TScale(1.0 / (double)getDevPixRatio()) * toWidgetRef *
- getImageBoundsD(img));
+ TRectD pixGeomD(TScale(1.0 / (double)getDevicePixelRatio(this)) *
+ toWidgetRef * getImageBoundsD(img));
// TRectD pixGeomD(toWidgetRef * getImageBoundsD(img));
TRect pixGeom(tceil(pixGeomD.x0), tceil(pixGeomD.y0), tfloor(pixGeomD.x1) - 1,
tfloor(pixGeomD.y1) - 1);
diff --git a/toonz/sources/toonz/imageviewer.cpp b/toonz/sources/toonz/imageviewer.cpp
index b4e482faa..b11bdeb6f 100644
--- a/toonz/sources/toonz/imageviewer.cpp
+++ b/toonz/sources/toonz/imageviewer.cpp
@@ -971,7 +971,7 @@ void ImageViewer::pickColor(QMouseEvent *event, bool putValueToStyleEditor) {
return;
}
- StylePicker picker(img);
+ StylePicker picker(this, img);
TPointD pos =
getViewAff().inv() * TPointD(curPos.x() - (qreal)(width()) / 2,
@@ -1040,7 +1040,7 @@ void ImageViewer::rectPickColor(bool putValueToStyleEditor) {
return;
}
- StylePicker picker(img);
+ StylePicker picker(this, img);
if (!img->raster()) { // vector image
TPointD pressedWinPos = convert(m_pressedMousePos) + m_winPosMousePosOffset;
diff --git a/toonz/sources/toonz/main.cpp b/toonz/sources/toonz/main.cpp
index e3a03bb0e..b9258a51a 100644
--- a/toonz/sources/toonz/main.cpp
+++ b/toonz/sources/toonz/main.cpp
@@ -444,8 +444,7 @@ int main(int argc, char *argv[]) {
// splash screen
QPixmap splashPixmap = QIcon(":Resources/splash.svg").pixmap(QSize(610, 344));
- splashPixmap.setDevicePixelRatio(QApplication::desktop()->devicePixelRatio());
-// QPixmap splashPixmap(":Resources/splash.png");
+
#ifdef _WIN32
QFont font("Segoe UI", -1);
#else
diff --git a/toonz/sources/toonz/mainwindow.cpp b/toonz/sources/toonz/mainwindow.cpp
index b1fed4390..ba77da8e2 100644
--- a/toonz/sources/toonz/mainwindow.cpp
+++ b/toonz/sources/toonz/mainwindow.cpp
@@ -968,7 +968,7 @@ void MainWindow::onUpgradeTabPro() {}
void MainWindow::onAbout() {
QLabel *label = new QLabel();
QPixmap pixmap = QIcon(":Resources/splash.svg").pixmap(QSize(610, 344));
- pixmap.setDevicePixelRatio(QApplication::desktop()->devicePixelRatio());
+ pixmap.setDevicePixelRatio(getDevicePixelRatio(this));
label->setPixmap(pixmap);
DVGui::Dialog *dialog = new DVGui::Dialog(this, true);
@@ -1899,8 +1899,8 @@ void MainWindow::defineActions() {
QT_TR_NOOP("&Apply Lip Sync Data to Column"), "Alt+L",
"dialogue");
createMenuXsheetAction(MI_AutoLipSyncPopup,
- QT_TR_NOOP("&Apply Auto Lip Sync to Column"), "Ctrl+Alt+L",
- "dialogue");
+ QT_TR_NOOP("&Apply Auto Lip Sync to Column"),
+ "Ctrl+Alt+L", "dialogue");
// Menu - Cells
diff --git a/toonz/sources/toonz/ruler.cpp b/toonz/sources/toonz/ruler.cpp
index 68d15ff31..9076daed7 100644
--- a/toonz/sources/toonz/ruler.cpp
+++ b/toonz/sources/toonz/ruler.cpp
@@ -107,10 +107,10 @@ double Ruler::getPan() const {
if (m_viewer->is3DView()) // Vertical 3D
return m_viewer->getPan3D().y;
else // Vertical 2D
- return aff.a23 / getDevPixRatio();
+ return aff.a23 / m_viewer->getDevPixRatio();
else if (m_viewer->is3DView()) // Horizontal 3D
return m_viewer->getPan3D().x;
- return aff.a13 / getDevPixRatio(); // Horizontal 2D
+ return aff.a13 / m_viewer->getDevPixRatio(); // Horizontal 2D
}
//-----------------------------------------------------------------------------
@@ -137,7 +137,7 @@ void Ruler::drawVertical(QPainter &p) {
for (i = 0; i < count; i++) {
QColor color = (m_moving && count - 1 == i ? QColor(getHandleDragColor())
: QColor(getHandleColor()));
- double v = guides[i] / (double)getDevPixRatio();
+ 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));
}
@@ -192,7 +192,7 @@ void Ruler::drawHorizontal(QPainter &p) {
for (i = 0; i < count; i++) {
QColor color = (m_moving && count - 1 == i ? QColor(getHandleDragColor())
: QColor(getHandleColor()));
- double v = guides[i] / (double)getDevPixRatio();
+ 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));
}
@@ -258,7 +258,7 @@ void Ruler::mousePressEvent(QMouseEvent *e) {
int i;
int count = guides.size();
for (i = 0; i < count; i++) {
- double g = guides[i] / (double)getDevPixRatio();
+ double g = guides[i] / (double)m_viewer->getDevPixRatio();
double dist2 = (g - v) * (g - v);
if (selected < 0 || dist2 < minDist2) {
minDist2 = dist2;
@@ -268,7 +268,7 @@ void Ruler::mousePressEvent(QMouseEvent *e) {
if (e->button() == Qt::LeftButton) {
if (selected < 0 || minDist2 > 25) {
// crea una nuova guida
- guides.push_back(v * getDevPixRatio());
+ guides.push_back(v * m_viewer->getDevPixRatio());
m_viewer->update();
// aggiorna sprop!!!!
} else if (selected < count - 1)
@@ -294,7 +294,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()) * getDevPixRatio();
+ getGuides().back() = posToValue(e->pos()) * m_viewer->getDevPixRatio();
// aggiorna sprop!!!!
update();
m_viewer->update();
@@ -308,7 +308,7 @@ void Ruler::mouseMoveEvent(QMouseEvent *e) {
int count = guides.size();
for (int i = 0; i < count; i++) {
- double g = guides[i] / (double)getDevPixRatio();
+ double g = guides[i] / (double)m_viewer->getDevPixRatio();
double dist2 = (g - v) * (g - v);
if (dist2 < 25) {
setToolTip(tr(
diff --git a/toonz/sources/toonz/sceneviewer.cpp b/toonz/sources/toonz/sceneviewer.cpp
index 01758ad6f..01c7d4528 100644
--- a/toonz/sources/toonz/sceneviewer.cpp
+++ b/toonz/sources/toonz/sceneviewer.cpp
@@ -741,6 +741,7 @@ public:
SceneViewer::SceneViewer(ImageUtils::FullScreenWidget *parent)
: GLWidgetForHighDpi(parent)
+ , TTool::Viewer(this)
, m_pressure(0)
, m_lastMousePos(0, 0)
, m_mouseButton(Qt::NoButton)
diff --git a/toonz/sources/toonz/subcameramanager.cpp b/toonz/sources/toonz/subcameramanager.cpp
index 560ad0b52..d3d941bde 100644
--- a/toonz/sources/toonz/subcameramanager.cpp
+++ b/toonz/sources/toonz/subcameramanager.cpp
@@ -31,7 +31,7 @@ inline bool bitwiseContains(UCHAR flag, UCHAR state) {
inline bool bitwiseExclude(UCHAR flag, UCHAR state) {
return bitwiseContains(~state, flag);
}
-}
+} // namespace
//********************************************************************************
// Classes implementation
@@ -119,7 +119,7 @@ bool PreviewSubCameraManager::mousePressEvent(SceneViewer *viewer,
if (viewer->is3DView()) return true;
m_mousePressed = true;
- m_mousePressPos = event.mousePos() * getDevPixRatio();
+ m_mousePressPos = event.mousePos() * viewer->getDevPixRatio();
m_dragType = getSubCameraDragEnum(viewer, m_mousePressPos);
if (bitwiseExclude(m_dragType, OUTER))
@@ -133,7 +133,7 @@ bool PreviewSubCameraManager::mousePressEvent(SceneViewer *viewer,
bool PreviewSubCameraManager::mouseMoveEvent(SceneViewer *viewer,
const TMouseEvent &event) {
if (viewer->is3DView()) return true;
- QPointF curPos(event.mousePos() * getDevPixRatio());
+ QPointF curPos(event.mousePos() * viewer->getDevPixRatio());
if (event.buttons() == Qt::LeftButton) {
if (!bitwiseContains(m_dragType, INNER)) {
if (std::abs(curPos.x() - m_mousePressPos.x()) > 10 ||
@@ -334,7 +334,7 @@ TPoint PreviewSubCameraManager::getSubCameraDragDistance(
//-----------------------------------------------------------------------------
/*! Delete sub camera frame. Executed from context menu of the viewer.
-*/
+ */
void PreviewSubCameraManager::deleteSubCamera(SceneViewer *viewer) {
TCamera *camera =
TApp::instance()->getCurrentScene()->getScene()->getCurrentCamera();
diff --git a/toonz/sources/toonzqt/fxschematicnode.cpp b/toonz/sources/toonzqt/fxschematicnode.cpp
index 245a73a16..b50b35f13 100644
--- a/toonz/sources/toonzqt/fxschematicnode.cpp
+++ b/toonz/sources/toonzqt/fxschematicnode.cpp
@@ -1239,22 +1239,20 @@ void FxSchematicPort::paint(QPainter *painter,
const QStyleOptionGraphicsItem *option,
QWidget *widget) {
if (m_isPassThrough && getLinkCount() > 0) return;
-
+ int devicePixelRatio = getDevicePixelRatio(widget);
// large scaled
if (getDock()->getNode()->isNormalIconView()) {
switch (getType()) {
case eFxInputPort:
case eFxGroupedInPort: {
- QRect sourceRect =
+ QRect targetRect =
scene()->views()[0]->matrix().mapRect(boundingRect()).toRect();
static QIcon fxPortRedIcon(":Resources/fxport_red.svg");
static QIcon fxPortPassThroughRedIcon(":Resources/fxport_pt_red.svg");
QPixmap redPm = (m_isPassThrough)
- ? fxPortPassThroughRedIcon.pixmap(sourceRect.size())
- : fxPortRedIcon.pixmap(sourceRect.size());
- sourceRect = QRect(0, 0, sourceRect.width() * getDevPixRatio(),
- sourceRect.height() * getDevPixRatio());
- painter->drawPixmap(boundingRect(), redPm, sourceRect);
+ ? fxPortPassThroughRedIcon.pixmap(targetRect.size())
+ : fxPortRedIcon.pixmap(targetRect.size());
+ painter->drawPixmap(boundingRect().toRect(), redPm);
} break;
case eFxOutputPort:
@@ -1263,8 +1261,7 @@ void FxSchematicPort::paint(QPainter *painter,
scene()->views()[0]->matrix().mapRect(boundingRect()).toRect();
static QIcon fxPortBlueIcon(":Resources/fxport_blue.svg");
QPixmap bluePm = fxPortBlueIcon.pixmap(sourceRect.size());
- sourceRect = QRect(0, 0, sourceRect.width() * getDevPixRatio(),
- sourceRect.height() * getDevPixRatio());
+ sourceRect = QRect(0, 0, bluePm.width(), bluePm.height());
painter->drawPixmap(boundingRect(), bluePm, sourceRect);
FxSchematicDock *parentDock =
dynamic_cast<FxSchematicDock *>(parentItem());
@@ -1288,9 +1285,7 @@ void FxSchematicPort::paint(QPainter *painter,
scene()->views()[0]->matrix().mapRect(boundingRect()).toRect();
QPixmap linkPm =
QIcon(":Resources/schematic_link.svg").pixmap(sourceRect.size());
- sourceRect = QRect(0, 0, sourceRect.width() * getDevPixRatio(),
- sourceRect.height() * getDevPixRatio());
- painter->drawPixmap(boundingRect(), linkPm, sourceRect);
+ painter->drawPixmap(boundingRect().toRect(), linkPm);
} break;
}
}
@@ -1314,9 +1309,7 @@ void FxSchematicPort::paint(QPainter *painter,
scene()->views()[0]->matrix().mapRect(boundingRect()).toRect();
QPixmap linkPm = QIcon(":Resources/schematic_link_small.svg")
.pixmap(sourceRect.size());
- sourceRect = QRect(0, 0, sourceRect.width() * getDevPixRatio(),
- sourceRect.height() * getDevPixRatio());
- painter->drawPixmap(boundingRect(), linkPm, sourceRect);
+ painter->drawPixmap(boundingRect().toRect(), linkPm);
} break;
}
painter->drawRect(boundingRect());
@@ -3914,9 +3907,9 @@ QRectF FxSchematicPassThroughNode::boundingRect() const {
qreal width = m_width;
QRectF recF = m_nameItem->boundingRect();
if (m_showName) {
- width = recF.width();
+ width = recF.width();
if (width > m_width) xAdj = (width - m_width) / 2;
- yAdj = 30;
+ yAdj = 30;
}
return QRectF(-5 - xAdj, -5 - yAdj, std::max(m_width, width) + 10,
m_height + 10 + yAdj);
diff --git a/toonz/sources/toonzqt/gutil.cpp b/toonz/sources/toonzqt/gutil.cpp
index ef70f0840..16014b77a 100644
--- a/toonz/sources/toonzqt/gutil.cpp
+++ b/toonz/sources/toonzqt/gutil.cpp
@@ -31,9 +31,38 @@
#include <QFileInfo>
#include <QDesktopWidget>
#include <QSvgRenderer>
+#include <QScreen>
+#include <QWindow>
using namespace DVGui;
+namespace {
+inline bool hasScreensWithDifferentDevPixRatio() {
+ static bool ret = false;
+ static bool checked = false;
+ if (!checked) { // check once
+ int dpr = QApplication::desktop()->devicePixelRatio();
+ for (auto screen : QGuiApplication::screens()) {
+ if ((int)screen->devicePixelRatio() != dpr) {
+ ret = true;
+ break;
+ }
+ }
+ checked = true;
+ }
+ return ret;
+}
+
+int getHighestDevicePixelRatio() {
+ static int highestDevPixRatio = 0;
+ if (highestDevPixRatio == 0) {
+ for (auto screen : QGuiApplication::screens())
+ highestDevPixRatio =
+ std::max(highestDevPixRatio, (int)screen->devicePixelRatio());
+ }
+ return highestDevPixRatio;
+}
+} // namespace
//-----------------------------------------------------------------------------
QString fileSizeString(qint64 size, int precision) {
@@ -78,7 +107,7 @@ QPixmap rasterToQPixmap(const TRaster32P &ras, bool premultiplied,
bool setDevPixRatio) {
QPixmap pixmap = QPixmap::fromImage(rasterToQImage(ras, premultiplied));
if (setDevPixRatio) {
- pixmap.setDevicePixelRatio(getDevPixRatio());
+ pixmap.setDevicePixelRatio(getDevicePixelRatio());
}
return pixmap;
}
@@ -158,7 +187,7 @@ QPixmap scalePixmapKeepingAspectRatio(QPixmap pixmap, QSize size,
QPixmap svgToPixmap(const QString &svgFilePath, const QSize &size,
Qt::AspectRatioMode aspectRatioMode, QColor bgColor) {
- static int devPixRatio = getDevPixRatio();
+ static int devPixRatio = getHighestDevicePixelRatio();
QSvgRenderer svgRenderer(svgFilePath);
QSize pixmapSize;
QRectF renderRect;
@@ -197,7 +226,16 @@ QPixmap svgToPixmap(const QString &svgFilePath, const QSize &size,
//-----------------------------------------------------------------------------
-int getDevPixRatio() {
+int getDevicePixelRatio(const QWidget *widget) {
+ if (hasScreensWithDifferentDevPixRatio() && widget) {
+#if (QT_VERSION >= QT_VERSION_CHECK(5, 14, 0))
+ return widget->screen()->devicePixelRatio();
+#else
+ if (!widget->windowHandle()) widget->winId();
+ if (widget->windowHandle())
+ return widget->windowHandle()->devicePixelRatio();
+#endif
+ }
static int devPixRatio = QApplication::desktop()->devicePixelRatio();
return devPixRatio;
}
@@ -224,7 +262,7 @@ QString getIconThemePath(const QString &fileSVGPath) {
QPixmap compositePixmap(QPixmap pixmap, const qreal &opacity, const QSize &size,
const int leftAdj, const int topAdj, QColor bgColor) {
- static int devPixRatio = getDevPixRatio();
+ static int devPixRatio = getHighestDevicePixelRatio();
// Sets size of destination pixmap for source to be drawn onto, if size is
// empty use source pixmap size, else use custom size.
@@ -269,7 +307,7 @@ QPixmap recolorPixmap(QPixmap pixmap, QColor color) {
QIcon createQIcon(const char *iconSVGName, bool useFullOpacity,
bool isForMenuItem) {
- static int devPixRatio = getDevPixRatio();
+ static int devPixRatio = getHighestDevicePixelRatio();
QIcon themeIcon = QIcon::fromTheme(iconSVGName);
diff --git a/toonz/sources/toonzqt/schematicnode.cpp b/toonz/sources/toonzqt/schematicnode.cpp
index 415ce1317..218eba578 100644
--- a/toonz/sources/toonzqt/schematicnode.cpp
+++ b/toonz/sources/toonzqt/schematicnode.cpp
@@ -46,16 +46,16 @@ SchematicName::SchematicName(QGraphicsItem *parent, double width, double height)
popup = new QMenu();
popup->setObjectName(QLatin1String("qt_edit_menu"));
- actionCut = popup->addAction(tr("Cu&t") + ACCEL_KEY(QKeySequence::Cut),
- this, SLOT(onCut()));
+ actionCut = popup->addAction(tr("Cu&t") + ACCEL_KEY(QKeySequence::Cut), this,
+ SLOT(onCut()));
actionCut->setObjectName(QStringLiteral("edit-cut"));
actionCopy = popup->addAction(tr("&Copy") + ACCEL_KEY(QKeySequence::Copy),
- this, SLOT(onCopy()));
+ this, SLOT(onCopy()));
actionCopy->setObjectName(QStringLiteral("edit-copy"));
- actionPaste = popup->addAction(
- tr("&Paste") + ACCEL_KEY(QKeySequence::Paste), this, SLOT(onPaste()));
+ actionPaste = popup->addAction(tr("&Paste") + ACCEL_KEY(QKeySequence::Paste),
+ this, SLOT(onPaste()));
actionPaste->setObjectName(QStringLiteral("edit-paste"));
actionDelete = popup->addAction(
@@ -66,7 +66,7 @@ SchematicName::SchematicName(QGraphicsItem *parent, double width, double height)
actionSelectAll =
popup->addAction(tr("Select &All") + ACCEL_KEY(QKeySequence::SelectAll),
- this, SLOT(onSelectAll()));
+ this, SLOT(onSelectAll()));
actionSelectAll->setObjectName(QStringLiteral("select-all"));
connect(document(), SIGNAL(contentsChanged()), this,
@@ -194,8 +194,8 @@ void SchematicName::onCut() {
QString plainText = toPlainText();
if (cursor.hasSelection()) {
- int p = cursor.selectionStart();
- int n = cursor.selectionEnd() - p;
+ int p = cursor.selectionStart();
+ int n = cursor.selectionEnd() - p;
QString selection = plainText.mid(p, n);
clipboard->setText(selection);
plainText.remove(p, n);
@@ -228,7 +228,7 @@ void SchematicName::onPaste() {
QTextCursor cursor = textCursor();
QString plainText = toPlainText();
QString clipboardText = clipboard->text();
- clipboardText.remove(QRegExp("[\\n\\r]")); // remove all newlines
+ clipboardText.remove(QRegExp("[\\n\\r]")); // remove all newlines
int n, p = cursor.position();
if (cursor.hasSelection()) {
@@ -252,8 +252,8 @@ void SchematicName::onDelete() {
QString plainText = toPlainText();
if (cursor.hasSelection()) {
- int p = cursor.selectionStart();
- int n = cursor.selectionEnd() - p;
+ int p = cursor.selectionStart();
+ int n = cursor.selectionEnd() - p;
plainText.remove(p, n);
acceptName(plainText);
cursor.setPosition(p);
@@ -303,10 +303,8 @@ void SchematicThumbnailToggle::paint(QPainter *painter,
if (m_isDown)
pixmap = offIcon.pixmap(sourceRect.size());
else
- pixmap = onIcon.pixmap(sourceRect.size());
- sourceRect = QRect(0, 0, sourceRect.width() * getDevPixRatio(),
- sourceRect.height() * getDevPixRatio());
- painter->drawPixmap(rect, pixmap, sourceRect);
+ pixmap = onIcon.pixmap(sourceRect.size());
+ painter->drawPixmap(rect, pixmap);
}
//--------------------------------------------------------
@@ -424,9 +422,7 @@ void SchematicToggle::paint(QPainter *painter,
QRect sourceRect =
scene()->views()[0]->matrix().mapRect(QRect(0, 0, 18, 17));
QPixmap redPm = pix.pixmap(sourceRect.size());
- QRect newRect = QRect(0, 0, sourceRect.width() * getDevPixRatio(),
- sourceRect.height() * getDevPixRatio());
- painter->drawPixmap(rect, redPm, newRect);
+ painter->drawPixmap(rect, redPm);
} else if (!m_imageOff.isNull()) {
QPen pen(m_colorOn);
pen.setWidthF(0.5);
@@ -437,9 +433,7 @@ void SchematicToggle::paint(QPainter *painter,
QRect sourceRect =
scene()->views()[0]->matrix().mapRect(QRect(0, 0, 18, 17));
QPixmap redPm = m_imageOff.pixmap(sourceRect.size());
- QRect newRect = QRect(0, 0, sourceRect.width() * getDevPixRatio(),
- sourceRect.height() * getDevPixRatio());
- painter->drawPixmap(rect, redPm, newRect);
+ painter->drawPixmap(rect, redPm);
}
}
@@ -493,7 +487,7 @@ void SchematicToggle::contextMenuEvent(QGraphicsSceneContextMenuEvent *cme) {
//--------------------------------------------------------
/*! for Spline Aim and CP toggles
-*/
+ */
void SchematicToggle_SplineOptions::paint(
QPainter *painter, const QStyleOptionGraphicsItem *option,
QWidget *widget) {
@@ -504,9 +498,7 @@ void SchematicToggle_SplineOptions::paint(
(m_state == 2 && !m_imageOn2.isNull()) ? m_imageOn2 : m_imageOn;
QRect sourceRect = scene()->views()[0]->matrix().mapRect(rect.toRect());
QPixmap redPm = pix.pixmap(sourceRect.size());
- QRect newRect = QRect(0, 0, sourceRect.width() * getDevPixRatio(),
- sourceRect.height() * getDevPixRatio());
- painter->drawPixmap(rect, redPm, newRect);
+ painter->drawPixmap(rect.toRect(), redPm);
}
painter->setBrush(Qt::NoBrush);
painter->setPen(QColor(180, 180, 180, 255));
@@ -515,7 +507,7 @@ void SchematicToggle_SplineOptions::paint(
//--------------------------------------------------------
/*! for Spline Aim and CP toggles
-*/
+ */
void SchematicToggle_SplineOptions::mousePressEvent(
QGraphicsSceneMouseEvent *me) {
SchematicToggle::mousePressEvent(me);
@@ -561,8 +553,8 @@ void SchematicHandleSpinBox::paint(QPainter *painter,
void SchematicHandleSpinBox::mouseMoveEvent(QGraphicsSceneMouseEvent *me) {
if (m_buttonState == Qt::LeftButton) {
- bool increase = false;
- int delta = me->screenPos().y() - me->lastScreenPos().y();
+ bool increase = false;
+ int delta = me->screenPos().y() - me->lastScreenPos().y();
if (delta < 0) increase = true;
m_delta += abs(delta);
if (m_delta > 5) {
@@ -1083,13 +1075,13 @@ SchematicNode::~SchematicNode() {}
//--------------------------------------------------------
/*!Reimplements the pure virtual QGraphicsItem::boundingRect() method.
-*/
+ */
QRectF SchematicNode::boundingRect() const { return QRectF(0, 0, 1, 1); }
//--------------------------------------------------------
/*! Reimplements the pure virtual QGraphicsItem::paint() method.
-*/
+ */
void SchematicNode::paint(QPainter *painter,
const QStyleOptionGraphicsItem *option,
QWidget *widget) {
@@ -1123,7 +1115,7 @@ void SchematicNode::paint(QPainter *painter,
//--------------------------------------------------------
/*! Reimplements the QGraphicsItem::mouseMoveEvent() method.
-*/
+ */
void SchematicNode::mouseMoveEvent(QGraphicsSceneMouseEvent *me) {
QList<QGraphicsItem *> items = scene()->selectedItems();
if (items.empty()) return;
@@ -1166,7 +1158,7 @@ void SchematicNode::mouseReleaseEvent(QGraphicsSceneMouseEvent *me) {
//--------------------------------------------------------
/* Add a pair (portId, SchematicPort*port) in the mapping
-*/
+ */
SchematicPort *SchematicNode::addPort(int portId, SchematicPort *port) {
QMap<int, SchematicPort *>::iterator it;
it = m_ports.find(portId);
@@ -1206,7 +1198,7 @@ SchematicPort *SchematicNode::getPort(int portId) const {
/*! Returns a list of all node connected by links to a SchematicPort identified
* by \b portId.
-*/
+ */
QList<SchematicNode *> SchematicNode::getLinkedNodes(int portId) const {
QList<SchematicNode *> list;
SchematicPort *port = getPort(portId);
diff --git a/toonz/sources/toonzqt/schematicviewer.cpp b/toonz/sources/toonzqt/schematicviewer.cpp
index 30a19afb5..cca675525 100644
--- a/toonz/sources/toonzqt/schematicviewer.cpp
+++ b/toonz/sources/toonzqt/schematicviewer.cpp
@@ -249,14 +249,14 @@ void SchematicSceneViewer::mousePressEvent(QMouseEvent *me) {
} else if (m_cursorMode == CursorMode::Hand) {
m_mousePanPoint = m_touchDevice == QTouchDevice::TouchScreen
? mapToScene(me->pos())
- : me->pos() * getDevPixRatio();
+ : me->pos() * getDevicePixelRatio(this);
m_panning = true;
return;
}
} else if (m_buttonState == Qt::MidButton) {
m_mousePanPoint = m_touchDevice == QTouchDevice::TouchScreen
? mapToScene(me->pos())
- : me->pos() * getDevPixRatio();
+ : me->pos() * getDevicePixelRatio(this);
}
bool drawRect = true;
QList<QGraphicsItem *> pointedItems = items(me->pos());
@@ -291,12 +291,12 @@ void SchematicSceneViewer::mouseMoveEvent(QMouseEvent *me) {
m_buttonState == Qt::MidButton) {
QPointF usePos = m_touchDevice == QTouchDevice::TouchScreen
? mapToScene(me->pos())
- : me->pos() * getDevPixRatio();
+ : me->pos() * getDevicePixelRatio(this);
QPointF deltaPoint = usePos - m_mousePanPoint;
panQt(deltaPoint);
m_mousePanPoint = m_touchDevice == QTouchDevice::TouchScreen
? mapToScene(me->pos())
- : me->pos() * getDevPixRatio();
+ : me->pos() * getDevicePixelRatio(this);
} else {
if (m_cursorMode == CursorMode::Zoom && m_zooming) {
int deltaY = (m_oldWinPos.y() - me->pos().y()) * 10;
@@ -594,8 +594,9 @@ void SchematicSceneViewer::gestureEvent(QGestureEvent *e) {
}
if (changeFlags & QPinchGesture::CenterPointChanged) {
- QPointF centerDelta = (gesture->centerPoint() * getDevPixRatio()) -
- (gesture->lastCenterPoint() * getDevPixRatio());
+ QPointF centerDelta =
+ (gesture->centerPoint() * getDevicePixelRatio(this)) -
+ (gesture->lastCenterPoint() * getDevicePixelRatio(this));
if (centerDelta.manhattanLength() > 1) {
// panQt(centerDelta.toPoint());
}
@@ -630,14 +631,14 @@ void SchematicSceneViewer::touchEvent(QTouchEvent *e, int type) {
}
}
if (m_panning) {
- QPointF curPos =
- m_touchDevice == QTouchDevice::TouchScreen
- ? mapToScene(panPoint.pos().toPoint())
- : mapToScene(panPoint.pos().toPoint()) * getDevPixRatio();
- QPointF lastPos =
- m_touchDevice == QTouchDevice::TouchScreen
- ? mapToScene(panPoint.lastPos().toPoint())
- : mapToScene(panPoint.lastPos().toPoint()) * getDevPixRatio();
+ QPointF curPos = m_touchDevice == QTouchDevice::TouchScreen
+ ? mapToScene(panPoint.pos().toPoint())
+ : mapToScene(panPoint.pos().toPoint()) *
+ getDevicePixelRatio(this);
+ QPointF lastPos = m_touchDevice == QTouchDevice::TouchScreen
+ ? mapToScene(panPoint.lastPos().toPoint())
+ : mapToScene(panPoint.lastPos().toPoint()) *
+ getDevicePixelRatio(this);
QPointF centerDelta = curPos - lastPos;
panQt(centerDelta);
}
diff --git a/toonz/sources/toonzqt/stageschematicnode.cpp b/toonz/sources/toonzqt/stageschematicnode.cpp
index 65a54d490..0c41a99ce 100644
--- a/toonz/sources/toonzqt/stageschematicnode.cpp
+++ b/toonz/sources/toonzqt/stageschematicnode.cpp
@@ -763,9 +763,7 @@ void StageSchematicNodePort::paint(QPainter *painter,
else
pixmap = QIcon(":Resources/port_red.svg").pixmap(sourceRect.size());
}
- sourceRect = QRect(0, 0, sourceRect.width() * getDevPixRatio(),
- sourceRect.height() * getDevPixRatio());
- painter->drawPixmap(imgRect, pixmap, sourceRect);
+ painter->drawPixmap(imgRect, pixmap);
}
}
@@ -904,8 +902,8 @@ QRectF StageSchematicSplinePort::boundingRect() const {
void StageSchematicSplinePort::paint(QPainter *painter,
const QStyleOptionGraphicsItem *option,
QWidget *widget) {
- QRect rect(0, 0, 16, 8);
- QRect sourceRect = scene()->views()[0]->matrix().mapRect(rect);
+ QRect sourceRect =
+ scene()->views()[0]->matrix().mapRect(boundingRect().toRect());
QPixmap pixmap;
if (!m_parent->isParentPort()) {
@@ -921,9 +919,7 @@ void StageSchematicSplinePort::paint(QPainter *painter,
static QIcon splineParentIcon(":Resources/spline_parent_port.svg");
pixmap = splineParentIcon.pixmap(sourceRect.size());
}
- sourceRect = QRect(0, 0, sourceRect.width() * getDevPixRatio(),
- sourceRect.height() * getDevPixRatio());
- painter->drawPixmap(rect, pixmap, sourceRect);
+ painter->drawPixmap(boundingRect().toRect(), pixmap);
}
//--------------------------------------------------------
@@ -1560,11 +1556,11 @@ void StageSchematicNode::onHandleReleased() {
StageSchematicPegbarNode::StageSchematicPegbarNode(StageSchematicScene *scene,
TStageObject *pegbar)
: StageSchematicNode(scene, pegbar, 90, 18) {
- SchematicViewer *viewer = scene->getSchematicViewer();
- std::string name = m_stageObject->getFullName();
- std::string id = m_stageObject->getId().toString();
- m_name = QString::fromStdString(name);
- m_nameItem = new SchematicName(this, 72, 20);
+ SchematicViewer *viewer = scene->getSchematicViewer();
+ std::string name = m_stageObject->getFullName();
+ std::string id = m_stageObject->getId().toString();
+ m_name = QString::fromStdString(name);
+ m_nameItem = new SchematicName(this, 72, 20);
m_nameItem->setDefaultTextColor(viewer->getTextColor());
m_nameItem->setName(m_name);
m_nameItem->setPos(16, -1);
@@ -2008,8 +2004,8 @@ StageSchematicCameraNode::StageSchematicCameraNode(StageSchematicScene *scene,
TStageObject *pegbar)
: StageSchematicNode(scene, pegbar, 90, 18) {
SchematicViewer *viewer = scene->getSchematicViewer();
- std::string name = m_stageObject->getFullName();
- m_name = QString::fromStdString(name);
+ std::string name = m_stageObject->getFullName();
+ m_name = QString::fromStdString(name);
m_nameItem = new SchematicName(this, 54, 20);
m_nameItem->setDefaultTextColor(viewer->getTextColor());
@@ -2089,8 +2085,8 @@ StageSchematicSplineNode::StageSchematicSplineNode(StageSchematicScene *scene,
TStageObjectSpline *spline)
: SchematicNode(scene), m_spline(spline), m_isOpened(false) {
SchematicViewer *viewer = scene->getSchematicViewer();
- m_width = 90;
- m_height = 18;
+ m_width = 90;
+ m_height = 18;
assert(spline);
m_dock = new StageSchematicSplineDock(this, true, eStageSplinePort);