mirror of
https://github.com/subsurface/subsurface.git
synced 2025-01-19 22:35:27 +00:00
QML UI: more hacks for the magicShiftFactor hack
Since the device pixel ratio can be a fraction we should interpolate the values. I still don't really understand why this is necessary, so this is a hack on top of a hack - but for most values I tried this does seem to give us a reasonably well placed (and well scaled) profile. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
e4086dc746
commit
e700ea9638
1 changed files with 13 additions and 3 deletions
|
@ -37,9 +37,19 @@ void QMLProfile::paint(QPainter *painter)
|
|||
qreal sy = painterRect.height() / sceneSize / dprComp;
|
||||
|
||||
// next figure out the weird magic by which we need to shift the painter so the profile is shown
|
||||
int dpr = lrint(devicePixelRatio());
|
||||
qreal magicShiftFactor = (dpr == 2 ? 0.25 : (dpr == 3 ? 0.33 : 0.0));
|
||||
|
||||
double dpr = devicePixelRatio();
|
||||
double magicValues[] = { 0.0, 0.1, 0.25, 0.33, 0.375, 0.40, 0.42};
|
||||
qreal magicShiftFactor = 0.0;
|
||||
if (dpr <= 1.5) {
|
||||
magicShiftFactor = magicValues[0];
|
||||
} else if (dpr > 6.0) {
|
||||
magicShiftFactor = magicValues[6];
|
||||
} else if (IS_FP_SAME(dpr, rint(dpr))) {
|
||||
magicShiftFactor = magicValues[lrint(dpr)];
|
||||
} else {
|
||||
int lower = (int)dpr;
|
||||
magicShiftFactor = (magicValues[lower] * (lower + 1 - dpr) + magicValues[lower + 1] * (dpr - lower));
|
||||
}
|
||||
// now set up the transformations scale the profile and
|
||||
// shift the painter (taking its existing transformation into account)
|
||||
QTransform profileTransform = QTransform();
|
||||
|
|
Loading…
Add table
Reference in a new issue