diff --git a/ci-scripts/linux/travis-build.sh b/ci-scripts/linux/travis-build.sh index d183a91..94f2166 100644 --- a/ci-scripts/linux/travis-build.sh +++ b/ci-scripts/linux/travis-build.sh @@ -3,7 +3,7 @@ pushd thirdparty/tiff-4.0.3 CFLAGS="-fPIC" CXXFLAGS="-fPIC" ./configure --disable-jbig && make popd cd toonz && mkdir build && cd build -source /opt/qt55/bin/qt55-env.sh +source /opt/qt56/bin/qt56-env.sh cmake ../sources \ -DWITH_SYSTEM_SUPERLU:BOOL=OFF # according to https://docs.travis-ci.com/user/ci-environment/#Virtualization-environments diff --git a/ci-scripts/linux/travis-install.sh b/ci-scripts/linux/travis-install.sh index b25bf7f..91035d1 100644 --- a/ci-scripts/linux/travis-install.sh +++ b/ci-scripts/linux/travis-install.sh @@ -1,6 +1,6 @@ -sudo add-apt-repository --yes ppa:beineri/opt-qt551-trusty +sudo add-apt-repository --yes ppa:beineri/opt-qt562-trusty sudo apt-get update -sudo apt-get install -y liblzo2-dev liblz4-dev libfreetype6-dev libpng-dev libsdl2-dev libglew-dev freeglut3-dev qt55script libsuperlu3-dev libpng-dev qt55svg qt55tools qt55multimedia wget libusb-1.0-0-dev libboost-all-dev liblzma-dev +sudo apt-get install -y liblzo2-dev liblz4-dev libfreetype6-dev libpng-dev libsdl2-dev libglew-dev freeglut3-dev qt56script libsuperlu3-dev libpng-dev qt56svg qt56tools qt56multimedia wget libusb-1.0-0-dev libboost-all-dev liblzma-dev # someone forgot to include liblz4.pc with the package, use the version from xenial, as it only depends on libc wget http://mirrors.kernel.org/ubuntu/pool/main/l/lz4/liblz4-1_0.0~r131-2ubuntu2_amd64.deb -O liblz4.deb wget http://mirrors.kernel.org/ubuntu/pool/main/l/lz4/liblz4-dev_0.0~r131-2ubuntu2_amd64.deb -O liblz4-dev.deb diff --git a/doc/how_to_build_linux.md b/doc/how_to_build_linux.md index a1a479d..8adb582 100644 --- a/doc/how_to_build_linux.md +++ b/doc/how_to_build_linux.md @@ -6,7 +6,7 @@ Building OpenToonz from source requires the following dependencies: - Git - GCC or Clang - CMake (3.4.1 or newer). -- Qt5 (5.5 or newer) +- Qt5 (5.6 or newer) - Boost (1.55 or newer) - SDL2 - LibPNG diff --git a/toonz/sources/include/toonzqt/glwidget_for_highdpi.h b/toonz/sources/include/toonzqt/glwidget_for_highdpi.h new file mode 100644 index 0000000..2bae136 --- /dev/null +++ b/toonz/sources/include/toonzqt/glwidget_for_highdpi.h @@ -0,0 +1,32 @@ +#pragma once + +#ifndef GLWIDGET_FOR_HIGHDPI_H +#define GLWIDGET_FOR_HIGHDPI_H + +#include +#include +#include + +// use obsolete QGLWidget instead of QOpenGLWidget for now... +// TODO: replace with the "modern" OpenGL source and transfer to QOpenGLWidget +class GLWidgetForHighDpi : public QGLWidget { +public: + GLWidgetForHighDpi(QWidget *parent = Q_NULLPTR, + const QGLWidget *shareWidget = Q_NULLPTR, + Qt::WindowFlags f = Qt::WindowFlags()) + : QGLWidget(parent, shareWidget, f) {} + + // 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 getDevPixRatio() const { + static int devPixRatio = QApplication::desktop()->devicePixelRatio(); + return devPixRatio; + } + // modify sizes for high DPI monitors + int width() const { return QGLWidget::width() * getDevPixRatio(); } + int height() const { return QGLWidget::height() * getDevPixRatio(); } + QRect rect() const { return QRect(0, 0, width(), height()); } +}; + +#endif \ No newline at end of file diff --git a/toonz/sources/include/toonzqt/styleeditor.h b/toonz/sources/include/toonzqt/styleeditor.h index 251e7d7..8608ac7 100644 --- a/toonz/sources/include/toonzqt/styleeditor.h +++ b/toonz/sources/include/toonzqt/styleeditor.h @@ -21,6 +21,7 @@ #include "toonzqt/doublefield.h" #include "toonzqt/colorfield.h" #include "toonzqt/tabbar.h" +#include "toonzqt/glwidget_for_highdpi.h" // Toonz includes //#include "../toonz/tapp.h" //iwsw commented out temporarily @@ -32,7 +33,6 @@ #include #include #include -#include #include #include @@ -135,7 +135,7 @@ public: enum CurrentWheel { none, leftWheel, rightTriangle }; -class DVAPI HexagonalColorWheel final : public QOpenGLWidget { +class DVAPI HexagonalColorWheel final : public GLWidgetForHighDpi { Q_OBJECT // backgoround color (R160, G160, B160) diff --git a/toonz/sources/toonz/imageviewer.cpp b/toonz/sources/toonz/imageviewer.cpp index 84ae895..4abfd87 100644 --- a/toonz/sources/toonz/imageviewer.cpp +++ b/toonz/sources/toonz/imageviewer.cpp @@ -200,7 +200,7 @@ public: ImageViewer::ImageViewer(QWidget *parent, FlipBook *flipbook, bool showHistogram) - : QOpenGLWidget(parent) + : GLWidgetForHighDpi(parent) , m_pressedMousePos(0, 0) , m_mouseButton(Qt::NoButton) , m_draggingZoomSelection(false) @@ -322,7 +322,8 @@ void ImageViewer::contextMenuEvent(QContextMenuEvent *event) { bool addedSep = false; - if (m_isHistogramEnable && visibleRegion().contains(event->pos())) { + if (m_isHistogramEnable && + visibleRegion().contains(event->pos() * getDevPixRatio())) { menu->addSeparator(); addedSep = true; action = menu->addAction(tr("Show Histogram")); @@ -729,18 +730,20 @@ void ImageViewer::updateCursor(const TPoint &curPos) { /*! If middle button is pressed pan the image. Update current mouse position. */ void ImageViewer::mouseMoveEvent(QMouseEvent *event) { - TPoint curPos = TPoint(event->pos().x(), event->pos().y()); + QPoint curQPos = event->pos() * getDevPixRatio(); + + TPoint curPos = TPoint(curQPos.x(), curQPos.y()); if (m_visualSettings.m_defineLoadbox && m_flipbook) { if (m_mouseButton == Qt::LeftButton) updateLoadbox(curPos); else if (m_mouseButton == Qt::MidButton) - panQt(event->pos() - m_pos); + panQt(curQPos - m_pos); else updateCursor(curPos); update(); event->ignore(); - m_pos = event->pos(); + m_pos = curQPos; return; } @@ -762,11 +765,11 @@ void ImageViewer::mouseMoveEvent(QMouseEvent *event) { } if (m_compareSettings.m_dragCompareX || m_compareSettings.m_dragCompareY) - dragCompare(event->pos() - m_pos); + dragCompare(curQPos - m_pos); else if (m_mouseButton == Qt::MidButton) - panQt(event->pos() - m_pos); + panQt(curQPos - m_pos); - m_pos = event->pos(); + m_pos = curQPos; // pick the color if the histogram popup is opened if (m_isHistogramEnable && m_histogramPopup->isVisible() && !m_isColorModel) { @@ -830,8 +833,10 @@ void ImageViewer::pickColor(QMouseEvent *event, bool putValueToStyleEditor) { if (!m_isHistogramEnable) return; if (!m_histogramPopup->isVisible()) return; + QPoint curPos = event->pos() * getDevPixRatio(); + // avoid to pick outside of the flip - if ((!m_image) || !rect().contains(event->pos())) { + if ((!m_image) || !rect().contains(curPos)) { // throw transparent color m_histogramPopup->updateInfo(TPixel32::Transparent, TPointD(-1, -1)); return; @@ -839,7 +844,7 @@ void ImageViewer::pickColor(QMouseEvent *event, bool putValueToStyleEditor) { StylePicker picker(m_image); - TPoint mousePos = TPoint(event->pos().x(), height() - 1 - event->pos().y()); + TPoint mousePos = TPoint(curPos.x(), height() - 1 - curPos.y()); TRectD area = TRectD(mousePos.x, mousePos.y, mousePos.x, mousePos.y); // iwsw commented out temporarily @@ -854,7 +859,7 @@ void ImageViewer::pickColor(QMouseEvent *event, bool putValueToStyleEditor) { // Preferences::instance()->isDoColorCorrectionByUsing3DLutEnabled()) // get3DLutUtil()->releaseFBO(); - QPoint viewP = mapFrom(this, event->pos()); + QPoint viewP = mapFrom(this, curPos); TPointD pos = getViewAff().inv() * TPointD(viewP.x() - width() / 2, -viewP.y() + height() / 2); TPointD imagePos = TPointD(0.5 * m_image->getBBox().getLx() + pos.x, @@ -952,7 +957,7 @@ void ImageViewer::mouseDoubleClickEvent(QMouseEvent *event) { //------------------------------------------------------------------------------ void ImageViewer::mousePressEvent(QMouseEvent *event) { - m_pos = event->pos(); + m_pos = event->pos() * getDevPixRatio(); m_pressedMousePos = TPoint(m_pos.x(), m_pos.y()); m_mouseButton = event->button(); m_draggingZoomSelection = false; @@ -1036,8 +1041,8 @@ void ImageViewer::mouseReleaseEvent(QMouseEvent *event) { void ImageViewer::wheelEvent(QWheelEvent *event) { if (event->orientation() == Qt::Horizontal) return; int delta = event->delta() > 0 ? 120 : -120; - QPoint center(event->pos().x() - width() / 2, - -event->pos().y() + height() / 2); + QPoint center(event->pos().x() * getDevPixRatio() - width() / 2, + -event->pos().y() * getDevPixRatio() + height() / 2); zoomQt(center, exp(0.001 * delta)); } @@ -1146,7 +1151,8 @@ void ImageViewer::adaptView(const QRect &geomRect) { void ImageViewer::doSwapBuffers() { glFlush(); } void ImageViewer::changeSwapBehavior(bool enable) { - setUpdateBehavior(enable ? PartialUpdate : NoPartialUpdate); + // do nothing for now as setUpdateBehavior is not available with QGLWidget + // setUpdateBehavior(enable ? PartialUpdate : NoPartialUpdate); } //----------------------------------------------------------------------------- diff --git a/toonz/sources/toonz/imageviewer.h b/toonz/sources/toonz/imageviewer.h index 0d8655c..d8c905b 100644 --- a/toonz/sources/toonz/imageviewer.h +++ b/toonz/sources/toonz/imageviewer.h @@ -7,8 +7,7 @@ //#include "toonzqt/ghibli_3dlut_util.h" #include "toonz/imagepainter.h" - -#include +#include "toonzqt/glwidget_for_highdpi.h" //----------------------------------------------------------------------------- @@ -22,7 +21,7 @@ class HistogramPopup; // ImageViewer //-------------------- -class ImageViewer final : public QOpenGLWidget { +class ImageViewer final : public GLWidgetForHighDpi { Q_OBJECT enum DragType { eNone, diff --git a/toonz/sources/toonz/main.cpp b/toonz/sources/toonz/main.cpp index 4b3967a..bfa8206 100644 --- a/toonz/sources/toonz/main.cpp +++ b/toonz/sources/toonz/main.cpp @@ -263,6 +263,12 @@ int main(int argc, char *argv[]) { } } +// Enables high-DPI scaling. This attribute must be set before QApplication is +// constructed. Available from Qt 5.6. +#if QT_VERSION >= 0x050600 + QApplication::setAttribute(Qt::AA_EnableHighDpiScaling); +#endif + QApplication a(argc, argv); #ifdef MACOSX @@ -340,6 +346,9 @@ int main(int argc, char *argv[]) { a.setAttribute(Qt::AA_DontCreateNativeWidgetSiblings); #endif + // Enable to render smooth icons on high dpi monitors + a.setAttribute(Qt::AA_UseHighDpiPixmaps); + // Set the app's locale for numeric stuff to standard C. This is important for // atof() and similar // calls that are locale-dependant. @@ -360,10 +369,12 @@ int main(int argc, char *argv[]) { // splash screen QPixmap splashPixmap(":Resources/splash.png"); #ifdef _WIN32 - a.setFont(QFont("Arial", 10)); + QFont font("Arial", -1); #else - a.setFont(QFont("Helvetica", 10)); + QFont font("Helvetica", -1); #endif + font.setPixelSize(13); + a.setFont(font); QString offsetStr("\n\n\n\n\n\n\n\n"); diff --git a/toonz/sources/toonz/sceneviewer.cpp b/toonz/sources/toonz/sceneviewer.cpp index 1b521a2..714d804 100644 --- a/toonz/sources/toonz/sceneviewer.cpp +++ b/toonz/sources/toonz/sceneviewer.cpp @@ -466,7 +466,7 @@ public: //----------------------------------------------------------------------------- SceneViewer::SceneViewer(ImageUtils::FullScreenWidget *parent) - : QGLWidget(parent, touchProxy()) + : GLWidgetForHighDpi(parent, touchProxy()) , m_pressure(0) , m_lastMousePos(0, 0) , m_mouseButton(Qt::NoButton) @@ -765,6 +765,7 @@ TPointD SceneViewer::winToWorld(const QPoint &pos) const { } else return TAffine() * TPointD(0, 0); } + return getViewMatrix().inv() * pp; } @@ -2556,10 +2557,12 @@ void SceneViewer::invalidateToolStatus() { */ TRectD SceneViewer::getGeometry() const { + int devPixRatio = getDevPixRatio(); TTool *tool = TApp::instance()->getCurrentTool()->getTool(); - TPointD topLeft = tool->getMatrix().inv() * winToWorld(geometry().topLeft()); - TPointD bottomRight = - tool->getMatrix().inv() * winToWorld(geometry().bottomRight()); + TPointD topLeft = + tool->getMatrix().inv() * winToWorld(geometry().topLeft() * devPixRatio); + TPointD bottomRight = tool->getMatrix().inv() * + winToWorld(geometry().bottomRight() * devPixRatio); TObjectHandle *objHandle = TApp::instance()->getCurrentObject(); if (tool->getToolType() & TTool::LevelTool && !objHandle->isSpline()) { diff --git a/toonz/sources/toonz/sceneviewer.h b/toonz/sources/toonz/sceneviewer.h index 10276dc..9d063ca 100644 --- a/toonz/sources/toonz/sceneviewer.h +++ b/toonz/sources/toonz/sceneviewer.h @@ -13,6 +13,7 @@ // TnzQt includes #include "toonzqt/menubarcommand.h" #include "toonzqt/flipconsole.h" +#include "toonzqt/glwidget_for_highdpi.h" // iwsw commented out temporarily //#include "toonzqt/ghibli_3dlut_util.h" @@ -23,9 +24,6 @@ #include "pane.h" #include "previewer.h" -// Qt includes -#include - //===================================================================== // Forward declarations @@ -57,7 +55,7 @@ public: // SceneViewer //----------------------------------------------------------------------------- -class SceneViewer final : public QGLWidget, +class SceneViewer final : public GLWidgetForHighDpi, public TTool::Viewer, public Previewer::Listener { Q_OBJECT diff --git a/toonz/sources/toonz/sceneviewerevents.cpp b/toonz/sources/toonz/sceneviewerevents.cpp index 9d7f76e..53439ce 100644 --- a/toonz/sources/toonz/sceneviewerevents.cpp +++ b/toonz/sources/toonz/sceneviewerevents.cpp @@ -75,9 +75,9 @@ int modifiers = 0; void initToonzEvent(TMouseEvent &toonzEvent, QMouseEvent *event, int widgetHeight, double pressure, bool isTablet, - bool isClick) { - toonzEvent.m_pos = - TPoint(event->pos().x(), widgetHeight - 1 - event->pos().y()); + bool isClick, int devPixRatio) { + toonzEvent.m_pos = TPoint(event->pos().x() * devPixRatio, + widgetHeight - 1 - event->pos().y() * devPixRatio); toonzEvent.m_pressure = isTablet ? int(255 * pressure) : 255; toonzEvent.setModifiers(event->modifiers() & Qt::ShiftModifier, @@ -274,7 +274,7 @@ void SceneViewer::enterEvent(QEvent *) { void SceneViewer::mouseMoveEvent(QMouseEvent *event) { if (m_freezedStatus != NO_FREEZED) return; - QPoint curPos = event->pos(); + QPoint curPos = event->pos() * getDevPixRatio(); bool cursorSet = false; m_lastMousePos = curPos; @@ -359,7 +359,7 @@ void SceneViewer::mouseMoveEvent(QMouseEvent *event) { tool->setViewer(this); TMouseEvent toonzEvent; initToonzEvent(toonzEvent, event, height(), m_pressure, m_tabletEvent, - false); + false, getDevPixRatio()); TPointD worldPos = winToWorld(curPos); TPointD pos = tool->getMatrix().inv() * worldPos; @@ -417,7 +417,7 @@ void SceneViewer::mousePressEvent(QMouseEvent *event) { if (m_mouseButton != Qt::NoButton) return; - m_pos = event->pos(); + m_pos = event->pos() * getDevPixRatio(); m_mouseButton = event->button(); // when using tablet, avoid unexpected drawing behavior occurs when @@ -476,7 +476,8 @@ void SceneViewer::mousePressEvent(QMouseEvent *event) { if (m_pressure > 0 && !m_tabletEvent) m_tabletEvent = true; if (TApp::instance()->isPenCloseToTablet()) m_tabletEvent = true; - initToonzEvent(toonzEvent, event, height(), m_pressure, m_tabletEvent, true); + initToonzEvent(toonzEvent, event, height(), m_pressure, m_tabletEvent, true, + getDevPixRatio()); // if(!m_tabletEvent) qDebug() << "-----------------MOUSE PRESS 'PURO'. // POSSIBILE EMBOLO"; TPointD pos = tool->getMatrix().inv() * winToWorld(m_pos); @@ -542,8 +543,9 @@ void SceneViewer::mouseReleaseEvent(QMouseEvent *event) { { TMouseEvent toonzEvent; initToonzEvent(toonzEvent, event, height(), m_pressure, m_tabletEvent, - false); - TPointD pos = tool->getMatrix().inv() * winToWorld(event->pos()); + false, getDevPixRatio()); + TPointD pos = + tool->getMatrix().inv() * winToWorld(event->pos() * getDevPixRatio()); TObjectHandle *objHandle = TApp::instance()->getCurrentObject(); if (tool->getToolType() & TTool::LevelTool && !objHandle->isSpline()) { @@ -620,8 +622,9 @@ void SceneViewer::wheelEvent(QWheelEvent *event) { } else if (delta > 0) { CommandManager::instance()->execute("MI_PrevDrawing"); } - } else - zoomQt(event->pos(), exp(0.001 * delta)); + } else { + zoomQt(event->pos() * getDevPixRatio(), exp(0.001 * delta)); + } } event->accept(); } @@ -1000,8 +1003,10 @@ void SceneViewer::mouseDoubleClickEvent(QMouseEvent *event) { TTool *tool = TApp::instance()->getCurrentTool()->getTool(); if (!tool || !tool->isEnabled()) return; TMouseEvent toonzEvent; - initToonzEvent(toonzEvent, event, height(), m_pressure, m_tabletEvent, true); - TPointD pos = tool->getMatrix().inv() * winToWorld(event->pos()); + initToonzEvent(toonzEvent, event, height(), m_pressure, m_tabletEvent, true, + getDevPixRatio()); + TPointD pos = + tool->getMatrix().inv() * winToWorld(event->pos() * getDevPixRatio()); TObjectHandle *objHandle = TApp::instance()->getCurrentObject(); if (tool->getToolType() & TTool::LevelTool && !objHandle->isSpline()) { pos.x /= m_dpiScale.x; @@ -1036,7 +1041,9 @@ void SceneViewer::contextMenuEvent(QContextMenuEvent *e) { if (m_freezedStatus != NO_FREEZED) return; if (m_isLocator) return; - TPoint winPos(e->pos().x(), height() - e->pos().y()); + int devPixRatio = getDevPixRatio(); + TPoint winPos(e->pos().x() * devPixRatio, + height() - e->pos().y() * devPixRatio); std::vector columnIndices; // enable to select all the columns regardless of the click position for (int i = 0; @@ -1047,8 +1054,8 @@ void SceneViewer::contextMenuEvent(QContextMenuEvent *e) { SceneViewerContextMenu *menu = new SceneViewerContextMenu(this); TTool *tool = TApp::instance()->getCurrentTool()->getTool(); - TPointD pos = - ((tool) ? tool->getMatrix().inv() : TAffine()) * winToWorld(e->pos()); + TPointD pos = ((tool) ? tool->getMatrix().inv() : TAffine()) * + winToWorld(e->pos() * devPixRatio); menu->addEnterGroupCommands(pos); menu->addLevelCommands(columnIndices); diff --git a/toonz/sources/toonz/subcameramanager.cpp b/toonz/sources/toonz/subcameramanager.cpp index c6a7b34..0b53d45 100644 --- a/toonz/sources/toonz/subcameramanager.cpp +++ b/toonz/sources/toonz/subcameramanager.cpp @@ -119,7 +119,7 @@ bool PreviewSubCameraManager::mousePressEvent(SceneViewer *viewer, if (viewer->is3DView()) return true; m_mousePressed = true; - m_mousePressPos = event->pos(); + m_mousePressPos = event->pos() * viewer->getDevPixRatio(); m_dragType = getSubCameraDragEnum(viewer, m_mousePressPos); if (bitwiseExclude(m_dragType, OUTER)) @@ -133,8 +133,7 @@ bool PreviewSubCameraManager::mousePressEvent(SceneViewer *viewer, bool PreviewSubCameraManager::mouseMoveEvent(SceneViewer *viewer, QMouseEvent *event) { if (viewer->is3DView()) return true; - - QPoint curPos(event->pos()); + QPoint curPos(event->pos() * viewer->getDevPixRatio()); if (event->buttons() == Qt::LeftButton) { if (!bitwiseContains(m_dragType, INNER)) { if (abs(curPos.x() - m_mousePressPos.x()) > 10 || diff --git a/toonz/sources/toonz/tapp.cpp b/toonz/sources/toonz/tapp.cpp index 014f8b0..5988f2c 100644 --- a/toonz/sources/toonz/tapp.cpp +++ b/toonz/sources/toonz/tapp.cpp @@ -57,6 +57,8 @@ #include #include #include +#include +#include //=================================================================== diff --git a/toonz/sources/toonz/xshcellviewer.cpp b/toonz/sources/toonz/xshcellviewer.cpp index 68e644a..eaaf089 100644 --- a/toonz/sources/toonz/xshcellviewer.cpp +++ b/toonz/sources/toonz/xshcellviewer.cpp @@ -512,10 +512,11 @@ void RenameCellField::showInRowCol(int row, int col, bool multiColumnSelected) { m_col = col; #ifdef _WIN32 - static QFont font("Arial", XSHEET_FONT_SIZE, QFont::Normal); + static QFont font("Arial", -1, QFont::Normal); #else - static QFont font("Helvetica", XSHEET_FONT_SIZE, QFont::Normal); + static QFont font("Helvetica", -1, QFont::Normal); #endif + font.setPixelSize(XSHEET_FONT_PX_SIZE); setFont(font); setAlignment(Qt::AlignRight | Qt::AlignBottom); @@ -1269,10 +1270,11 @@ void CellArea::drawLevelCell(QPainter &p, int row, int col, bool isReference) { : m_viewer->getTextColor()); #ifdef _WIN32 - static QFont font("Arial", XSHEET_FONT_SIZE, QFont::Normal); + static QFont font("Arial", -1, QFont::Normal); #else - static QFont font("Helvetica", XSHEET_FONT_SIZE, QFont::Normal); + static QFont font("Helvetica", -1, QFont::Normal); #endif + font.setPixelSize(XSHEET_FONT_PX_SIZE); p.setFont(font); // do not draw frame number under RenameCellField @@ -1376,16 +1378,21 @@ void CellArea::drawSoundTextCell(QPainter &p, int row, int col) { QString text = cell.getSoundTextLevel()->getFrameText(fid.getNumber() - 1); p.setPen(Qt::black); QRect nameRect = rect.adjusted(8, -H_ADJUST, -10, H_ADJUST); - // il nome va scritto se e' diverso dalla cella precedente oppure se - // siamo su una marker line - static QFont font("Helvetica", XSHEET_FONT_SIZE, QFont::Normal); +// il nome va scritto se e' diverso dalla cella precedente oppure se +// siamo su una marker line +#ifdef _WIN32 + static QFont font("Arial", -1, QFont::Normal); +#else + static QFont font("Helvetica", -1, QFont::Normal); +#endif + font.setPixelSize(XSHEET_FONT_PX_SIZE); p.setFont(font); #if QT_VERSION >= 0x050500 QFontMetrics metric(font); QString elidaName = elideText(text, metric, nameRect.width(), "~"); #else - QString elidaName = elideText(text, font, nameRect.width(), "~"); + QString elidaName = elideText(text, font, nameRect.width(), "~"); #endif if (!sameLevel || prevCell.m_frameId != fid) @@ -1487,11 +1494,12 @@ void CellArea::drawPaletteCell(QPainter &p, int row, int col, : m_viewer->getTextColor()); // il nome va scritto se e' diverso dalla cella precedente oppure se // siamo su una marker line -#ifndef _WIN32 - static QFont font("Arial", XSHEET_FONT_SIZE, QFont::Normal); +#ifdef _WIN32 + static QFont font("Arial", -1, QFont::Normal); #else - static QFont font("Helvetica", XSHEET_FONT_SIZE, QFont::Normal); + static QFont font("Helvetica", -1, QFont::Normal); #endif + font.setPixelSize(XSHEET_FONT_PX_SIZE); p.setFont(font); QFontMetrics fm(font); diff --git a/toonz/sources/toonz/xshcolumnviewer.cpp b/toonz/sources/toonz/xshcolumnviewer.cpp index 09c4ab4..97d8066 100644 --- a/toonz/sources/toonz/xshcolumnviewer.cpp +++ b/toonz/sources/toonz/xshcolumnviewer.cpp @@ -312,7 +312,7 @@ void ChangeObjectParent::refresh() { QString text; QList pegbarList; QList columnList; - int maxTextLength = 0; + QString theLongestTxt; int i; for (i = 0; i < objectCount; i++) { TStageObjectId id = tree->getStageObject(i)->getId(); @@ -334,12 +334,20 @@ void ChangeObjectParent::refresh() { newText = QString("Col ") + indexStr; columnList.append(newText); } - if (newText.length() > maxTextLength) maxTextLength = newText.length(); + if (newText.length() > theLongestTxt.length()) theLongestTxt = newText; } for (i = 0; i < columnList.size(); i++) addItem(columnList.at(i)); for (i = 0; i < pegbarList.size(); i++) addItem(pegbarList.at(i)); - m_width = maxTextLength * XSHEET_FONT_SIZE + 2; +#ifdef _WIN32 + static QFont font("Arial", -1, QFont::Bold); +#else + static QFont font("Helvetica", -1, QFont::Normal); +#endif + // set font size in pixel + font.setPixelSize(XSHEET_FONT_PX_SIZE); + + m_width = QFontMetrics(font).width(theLongestTxt) + 2; selectCurrent(text); } @@ -451,7 +459,12 @@ RenameColumnField::RenameColumnField(QWidget *parent, XsheetViewer *viewer) void RenameColumnField::show(QPoint pos, int col) { move(pos); - static QFont font("Helvetica", XSHEET_FONT_SIZE, QFont::Normal); +#ifdef _WIN32 + static QFont font("Arial", -1, QFont::Normal); +#else + static QFont font("Helvetica", -1, QFont::Normal); +#endif + font.setPixelSize(XSHEET_FONT_PX_SIZE); setFont(font); m_col = col; @@ -578,10 +591,11 @@ void ColumnArea::drawLevelColumnHead(QPainter &p, int col) { // Preparing painter #ifdef _WIN32 - QFont font("Arial", XSHEET_FONT_SIZE, QFont::Normal); + static QFont font("Arial", -1, QFont::Normal); #else - QFont font("Helvetica", XSHEET_FONT_SIZE, QFont::Normal); + static QFont font("Helvetica", -1, QFont::Normal); #endif + font.setPixelSize(XSHEET_FONT_PX_SIZE); p.setFont(font); p.setRenderHint(QPainter::SmoothPixmapTransform, true); @@ -789,8 +803,12 @@ void ColumnArea::drawSoundColumnHead(QPainter &p, int col) { TColumnSelection *selection = m_viewer->getColumnSelection(); p.setRenderHint(QPainter::SmoothPixmapTransform, true); - QFont font("Helvetica"); - font.setPointSize(XSHEET_FONT_SIZE); +#ifdef _WIN32 + static QFont font("Arial", -1, QFont::Normal); +#else + static QFont font("Helvetica", -1, QFont::Normal); +#endif + font.setPixelSize(XSHEET_FONT_PX_SIZE); p.setFont(font); int x = m_viewer->columnToX(col); @@ -940,10 +958,12 @@ void ColumnArea::drawPaletteColumnHead(QPainter &p, int col) { TColumnSelection *selection = m_viewer->getColumnSelection(); #ifdef _WIN32 - QFont font("Arial", XSHEET_FONT_SIZE, QFont::Normal); + static QFont font("Arial", -1, QFont::Normal); #else - QFont font("Helvetica", XSHEET_FONT_SIZE, QFont::Normal); + static QFont font("Helvetica", -1, QFont::Normal); #endif + font.setPixelSize(XSHEET_FONT_PX_SIZE); + p.setFont(font); p.setRenderHint(QPainter::SmoothPixmapTransform, true); @@ -1074,8 +1094,12 @@ void ColumnArea::drawSoundTextColumnHead(QPainter &p, int col) { TColumnSelection *selection = m_viewer->getColumnSelection(); p.setRenderHint(QPainter::SmoothPixmapTransform, true); - QFont font("Helvetica"); - font.setPointSize(XSHEET_FONT_SIZE); +#ifdef _WIN32 + static QFont font("Arial", -1, QFont::Normal); +#else + static QFont font("Helvetica", -1, QFont::Normal); +#endif + font.setPixelSize(XSHEET_FONT_PX_SIZE); p.setFont(font); int x = m_viewer->columnToX(col); diff --git a/toonz/sources/toonz/xsheetviewer.h b/toonz/sources/toonz/xsheetviewer.h index 64a17de..5596ca4 100644 --- a/toonz/sources/toonz/xsheetviewer.h +++ b/toonz/sources/toonz/xsheetviewer.h @@ -13,13 +13,8 @@ #include "cellkeyframeselection.h" #include "toonzqt/spreadsheetviewer.h" -#ifdef _WIN32 -#define XSHEET_FONT_SIZE 9 +#define XSHEET_FONT_PX_SIZE 12 #define H_ADJUST 2 -#else -#define XSHEET_FONT_SIZE 11 -#define H_ADJUST 0 -#endif // forward declaration class TXsheet; diff --git a/toonz/sources/toonz/xshrowviewer.cpp b/toonz/sources/toonz/xshrowviewer.cpp index 820bec5..53e8913 100644 --- a/toonz/sources/toonz/xshrowviewer.cpp +++ b/toonz/sources/toonz/xshrowviewer.cpp @@ -89,10 +89,13 @@ void RowArea::drawRows(QPainter &p, int r0, int r1) { } #ifdef _WIN32 - static QFont font("Arial", XSHEET_FONT_SIZE, QFont::Bold); + static QFont font("Arial", -1, QFont::Bold); #else - static QFont font("Helvetica", XSHEET_FONT_SIZE, QFont::Normal); + static QFont font("Helvetica", -1, QFont::Normal); #endif + // set font size in pixel + font.setPixelSize(XSHEET_FONT_PX_SIZE); + p.setFont(font); // marker interval diff --git a/toonz/sources/toonzqt/CMakeLists.txt b/toonz/sources/toonzqt/CMakeLists.txt index 0463e33..5ac9c48 100644 --- a/toonz/sources/toonzqt/CMakeLists.txt +++ b/toonz/sources/toonzqt/CMakeLists.txt @@ -86,6 +86,7 @@ set(MOC_HEADERS ../include/toonzqt/flipconsoleowner.h ../include/toonzqt/combohistogram.h ../include/toonzqt/fxiconmanager.h + ../include/toonzqt/glwidget_for_highdpi.h pluginhost.h ) diff --git a/toonz/sources/toonzqt/functionsheet.cpp b/toonz/sources/toonzqt/functionsheet.cpp index 5294fcb..9d86d2d 100644 --- a/toonz/sources/toonzqt/functionsheet.cpp +++ b/toonz/sources/toonzqt/functionsheet.cpp @@ -641,10 +641,11 @@ void FunctionSheetCellViewer::drawCells(QPainter &painter, int r0, int c0, } #ifdef _WIN32 - static QFont font("Arial", 9, QFont::Normal); + static QFont font("Arial", -1, QFont::Bold); #else - static QFont font("Helvetica", 9, QFont::Normal); + static QFont font("Helvetica", -1, QFont::Bold); #endif + font.setPixelSize(12); painter.setFont(font); painter.drawText(cellRect.adjusted(10, 0, 0, 0), Qt::AlignVCenter | Qt::AlignLeft, text); diff --git a/toonz/sources/toonzqt/spreadsheetviewer.cpp b/toonz/sources/toonzqt/spreadsheetviewer.cpp index 8c375e9..3858bf2 100644 --- a/toonz/sources/toonzqt/spreadsheetviewer.cpp +++ b/toonz/sources/toonzqt/spreadsheetviewer.cpp @@ -237,10 +237,11 @@ DragTool *RowPanel::createDragTool(QMouseEvent *) { void RowPanel::drawRows(QPainter &p, int r0, int r1) { #ifdef _WIN32 - static QFont font("Arial", 9, QFont::Bold); + static QFont font("Arial", -1, QFont::Bold); #else - static QFont font("Helvetica", 9, QFont::Bold); + static QFont font("Helvetica", -1, QFont::Bold); #endif + font.setPixelSize(12); p.setFont(font); QRect visibleRect = visibleRegion().boundingRect(); diff --git a/toonz/sources/toonzqt/styleeditor.cpp b/toonz/sources/toonzqt/styleeditor.cpp index 6520885..2c08501 100644 --- a/toonz/sources/toonzqt/styleeditor.cpp +++ b/toonz/sources/toonzqt/styleeditor.cpp @@ -548,7 +548,7 @@ QPixmap makeSquareShading(const ColorModel &color, ColorChannel channel, //***************************************************************************** HexagonalColorWheel::HexagonalColorWheel(QWidget *parent) - : QOpenGLWidget(parent) + : GLWidgetForHighDpi(parent) , m_bgColor(128, 128, 128) // defaul value in case this value does not set // in the style sheet { @@ -597,20 +597,20 @@ void HexagonalColorWheel::initializeGL() { //----------------------------------------------------------------------------- -void HexagonalColorWheel::resizeGL(int width, int height) { - float d = (width - 5.0f) / 2.5f; - bool isHorizontallyLong = ((d * 1.732f) < height) ? false : true; +void HexagonalColorWheel::resizeGL(int w, int h) { + float d = (w - 5.0f) / 2.5f; + bool isHorizontallyLong = ((d * 1.732f) < h) ? false : true; if (isHorizontallyLong) { - m_triEdgeLen = (float)height / 1.732f; - m_triHeight = (float)height / 2.0f; - m_wheelPosition.setX(((float)width - (m_triEdgeLen * 2.5f + 5.0f)) / 2.0f); + m_triEdgeLen = (float)h / 1.732f; + m_triHeight = (float)h / 2.0f; + m_wheelPosition.setX(((float)w - (m_triEdgeLen * 2.5f + 5.0f)) / 2.0f); m_wheelPosition.setY(0.0f); } else { m_triEdgeLen = d; m_triHeight = m_triEdgeLen * 0.866f; m_wheelPosition.setX(0.0f); - m_wheelPosition.setY(((float)height - (m_triHeight * 2.0f)) / 2.0f); + m_wheelPosition.setY(((float)h - (m_triHeight * 2.0f)) / 2.0f); } // set all vertices positions @@ -637,16 +637,16 @@ void HexagonalColorWheel::resizeGL(int width, int height) { m_leftp[2].setY(0.0f); // GL settings - glViewport(0, 0, width, height); + glViewport(0, 0, w, h); glMatrixMode(GL_PROJECTION); glLoadIdentity(); - glOrtho(0.0, (GLdouble)width, (GLdouble)height, 0.0, 1.0, -1.0); + glOrtho(0.0, (GLdouble)w, (GLdouble)h, 0.0, 1.0, -1.0); // iwsw commented out temporarily /* if(Preferences::instance()->isDoColorCorrectionByUsing3DLutEnabled() && m_ghibli3DLutUtil) - m_ghibli3DLutUtil->onResize(width,height); + m_ghibli3DLutUtil->onResize(w,h); */ } @@ -777,15 +777,16 @@ void HexagonalColorWheel::mousePressEvent(QMouseEvent *event) { // check whether the mouse cursor is in the wheel or in the triangle (or // nothing). + QPoint curPos = event->pos() * getDevPixRatio(); QPolygonF wheelPolygon; // in the case of the wheel wheelPolygon << m_wp[1] << m_wp[2] << m_wp[3] << m_wp[4] << m_wp[5] << m_wp[6]; wheelPolygon.translate(m_wheelPosition); - if (wheelPolygon.toPolygon().containsPoint(event->pos(), Qt::OddEvenFill)) { + if (wheelPolygon.toPolygon().containsPoint(curPos, Qt::OddEvenFill)) { m_currentWheel = leftWheel; - clickLeftWheel(event->pos()); + clickLeftWheel(curPos); return; } @@ -793,9 +794,9 @@ void HexagonalColorWheel::mousePressEvent(QMouseEvent *event) { // in the case of the triangle wheelPolygon << m_leftp[0] << m_leftp[1] << m_leftp[2]; wheelPolygon.translate(m_wheelPosition); - if (wheelPolygon.toPolygon().containsPoint(event->pos(), Qt::OddEvenFill)) { + if (wheelPolygon.toPolygon().containsPoint(curPos, Qt::OddEvenFill)) { m_currentWheel = rightTriangle; - clickRightTriangle(event->pos()); + clickRightTriangle(curPos); return; } @@ -811,10 +812,10 @@ void HexagonalColorWheel::mouseMoveEvent(QMouseEvent *event) { case none: break; case leftWheel: - clickLeftWheel(event->pos()); + clickLeftWheel(event->pos() * getDevPixRatio()); break; case rightTriangle: - clickRightTriangle(event->pos()); + clickRightTriangle(event->pos() * getDevPixRatio()); break; } }