From 2ff95d58f05568ad379ae46b58135b56ed83e5ff Mon Sep 17 00:00:00 2001 From: Marc Sabatella Date: Sat, 21 Nov 2015 09:01:14 -0700 Subject: [PATCH 1/3] fix gui scaling regressions for high DPI displays --- mscore/exampleview.cpp | 9 ++++----- mscore/globals.h | 5 +++-- mscore/musescore.cpp | 11 +++++++++-- 3 files changed, 16 insertions(+), 9 deletions(-) diff --git a/mscore/exampleview.cpp b/mscore/exampleview.cpp index 8727b1be973e1..4d6e51cff6bc5 100644 --- a/mscore/exampleview.cpp +++ b/mscore/exampleview.cpp @@ -31,8 +31,8 @@ ExampleView::ExampleView(QWidget* parent) _score = 0; setAcceptDrops(true); setFocusPolicy(Qt::StrongFocus); - double mag = 1.0; - qreal _spatium = SPATIUM20; + double mag = guiScaling * (DPI_DISPLAY / DPI); // default is same as scoreview + qreal _spatium = SPATIUM20 * mag; _matrix = QTransform(mag, 0.0, 0.0, mag, _spatium, -_spatium * 6); imatrix = _matrix.inverted(); } @@ -336,9 +336,8 @@ void ExampleView::mousePressEvent(QMouseEvent* event) QSize ExampleView::sizeHint() const { - return QSize( - 1000 * guiScaling * (DPI / 90), - 80 * guiScaling * (DPI / 90)); + qreal mag = guiScaling * (DPI_DISPLAY / DPI); // same as example itself + return QSize(1000 * mag, 80 * mag); } diff --git a/mscore/globals.h b/mscore/globals.h index 954b0ca9b7f8d..8d6bdb87e55a7 100644 --- a/mscore/globals.h +++ b/mscore/globals.h @@ -95,8 +95,9 @@ struct MidiRemote { extern const char* stateName(ScoreState); -static constexpr qreal DPMM_DISPLAY = 4; // 100 DPI -static constexpr qreal PALETTE_SPATIUM = 1.9 * DPMM_DISPLAY; +static constexpr qreal DPI_DISPLAY = 96.0; // 96 DPI nominal resolution +static constexpr qreal DPMM_DISPLAY = DPI_DISPLAY / 25.4; +static constexpr qreal PALETTE_SPATIUM = 1.764 * DPMM_DISPLAY; extern QPaintDevice* pdev; diff --git a/mscore/musescore.cpp b/mscore/musescore.cpp index 134f97210f9e5..a20ec46a62fa5 100644 --- a/mscore/musescore.cpp +++ b/mscore/musescore.cpp @@ -130,7 +130,7 @@ bool externalIcons = false; bool pluginMode = false; static bool startWithNewScore = false; double converterDpi = 0; -double guiScaling = 1.0; +double guiScaling = 0.0; int trimMargin = -1; bool noWebView = false; bool exportScoreParts = false; @@ -348,7 +348,14 @@ MuseScore::MuseScore() { QScreen* screen = QGuiApplication::primaryScreen(); _physicalDotsPerInch = screen->physicalDotsPerInch(); // physical resolution - _physicalDotsPerInch *= guiScaling; + if (guiScaling == 0.0) { + // set scale for icons, palette elements, window sizes, etc + // the default values are hard coded in pixel sizes and assume ~96 DPI + if (qAbs(_physicalDotsPerInch - DPI_DISPLAY) > 6.0) + guiScaling = _physicalDotsPerInch / DPI_DISPLAY; + else + guiScaling = 1.0; + } _sstate = STATE_INIT; setWindowTitle(QString(MUSESCORE_NAME_VERSION)); From c20ecb590fb14510d8775e870731478aa0a2b011 Mon Sep 17 00:00:00 2001 From: Marc Sabatella Date: Tue, 24 Nov 2015 12:51:10 -0700 Subject: [PATCH 2/3] cheap partial fix for scaling on Windows <= 7 --- mscore/musescore.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/mscore/musescore.cpp b/mscore/musescore.cpp index a20ec46a62fa5..0471e22d2d24a 100644 --- a/mscore/musescore.cpp +++ b/mscore/musescore.cpp @@ -347,7 +347,14 @@ MuseScore::MuseScore() : QMainWindow() { QScreen* screen = QGuiApplication::primaryScreen(); +#if defined(Q_OS_WIN) + if (QSysInfo::WindowsVersion <= QSysInfo::WV_WINDOWS7) + _physicalDotsPerInch = screen->logicalDotsPerInch() * screen->devicePixelRatio(); + else + _physicalDotsPerInch = screen->physicalDotsPerInch(); // physical resolution +#else _physicalDotsPerInch = screen->physicalDotsPerInch(); // physical resolution +#endif if (guiScaling == 0.0) { // set scale for icons, palette elements, window sizes, etc // the default values are hard coded in pixel sizes and assume ~96 DPI From 3957c59521a2f832689b1d34a4ed0279101f8983 Mon Sep 17 00:00:00 2001 From: Marc Sabatella Date: Wed, 2 Dec 2015 23:26:52 -0700 Subject: [PATCH 3/3] fix example view dimensions --- mscore/exampleview.cpp | 11 +++++++---- mscore/note_groups.ui | 6 +++--- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/mscore/exampleview.cpp b/mscore/exampleview.cpp index 4d6e51cff6bc5..5d5a44d1f4d03 100644 --- a/mscore/exampleview.cpp +++ b/mscore/exampleview.cpp @@ -31,9 +31,10 @@ ExampleView::ExampleView(QWidget* parent) _score = 0; setAcceptDrops(true); setFocusPolicy(Qt::StrongFocus); - double mag = guiScaling * (DPI_DISPLAY / DPI); // default is same as scoreview + double mag = 0.9 * guiScaling * (DPI_DISPLAY / DPI); // 90% of nominal qreal _spatium = SPATIUM20 * mag; - _matrix = QTransform(mag, 0.0, 0.0, mag, _spatium, -_spatium * 6); + // example would normally be 10sp from top of page; this leaves 3sp margin above + _matrix = QTransform(mag, 0.0, 0.0, mag, _spatium, -_spatium * 7.0); imatrix = _matrix.inverted(); } @@ -336,8 +337,10 @@ void ExampleView::mousePressEvent(QMouseEvent* event) QSize ExampleView::sizeHint() const { - qreal mag = guiScaling * (DPI_DISPLAY / DPI); // same as example itself - return QSize(1000 * mag, 80 * mag); + qreal mag = 0.9 * guiScaling * (DPI_DISPLAY / DPI); + qreal _spatium = SPATIUM20 * mag; + // staff is 4sp tall with 3sp margin above; this leaves 3sp margin below + return QSize(1000 * mag, _spatium * 10.0); } diff --git a/mscore/note_groups.ui b/mscore/note_groups.ui index e00e385c79ea9..52fab55b747e0 100644 --- a/mscore/note_groups.ui +++ b/mscore/note_groups.ui @@ -47,7 +47,7 @@ - + 0 0 @@ -152,7 +152,7 @@ - + 0 0 @@ -238,7 +238,7 @@ - + 0 0