Skip to content
Permalink
Browse files

Merge pull request #2296 from MarcSabatella/gui-scaling

fix gui scaling regressions for high DPI displays
  • Loading branch information...
wschweer committed Jan 4, 2016
2 parents 313f17d + 3957c59 commit e842ec03e4f88faf0e72e9fd67ede2c4fd1d34c1
Showing with 30 additions and 13 deletions.
  1. +8 −6 mscore/exampleview.cpp
  2. +3 −2 mscore/globals.h
  3. +16 −2 mscore/musescore.cpp
  4. +3 −3 mscore/note_groups.ui
@@ -31,9 +31,10 @@ ExampleView::ExampleView(QWidget* parent)
_score = 0;
setAcceptDrops(true);
setFocusPolicy(Qt::StrongFocus);
double mag = 1.0;
qreal _spatium = SPATIUM20;
_matrix = QTransform(mag, 0.0, 0.0, mag, _spatium, -_spatium * 6);
double mag = 0.9 * guiScaling * (DPI_DISPLAY / DPI); // 90% of nominal
qreal _spatium = SPATIUM20 * mag;
// 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,9 +337,10 @@ void ExampleView::mousePressEvent(QMouseEvent* event)

QSize ExampleView::sizeHint() const
{
return QSize(
1000 * guiScaling * (DPI / 90),
80 * guiScaling * (DPI / 90));
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);
}


@@ -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;

@@ -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;
@@ -347,8 +347,22 @@ 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
_physicalDotsPerInch *= guiScaling;
#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
if (qAbs(_physicalDotsPerInch - DPI_DISPLAY) > 6.0)
guiScaling = _physicalDotsPerInch / DPI_DISPLAY;
else
guiScaling = 1.0;
}

_sstate = STATE_INIT;
setWindowTitle(QString(MUSESCORE_NAME_VERSION));
@@ -47,7 +47,7 @@
<item row="1" column="2">
<widget class="Ms::ExampleView" name="view16">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<sizepolicy hsizetype="Expanding" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
@@ -152,7 +152,7 @@
<item row="2" column="2">
<widget class="Ms::ExampleView" name="view32">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<sizepolicy hsizetype="Expanding" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
@@ -238,7 +238,7 @@
<item row="0" column="2">
<widget class="Ms::ExampleView" name="view8">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<sizepolicy hsizetype="Expanding" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>

0 comments on commit e842ec0

Please sign in to comment.
You can’t perform that action at this time.