summaryrefslogtreecommitdiffstats
path: root/mobile-widgets
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2017-04-03 12:49:14 -0700
committerGravatar Dirk Hohndel <dirk@hohndel.org>2017-04-04 11:00:18 -0700
commite700ea9638907c63a2cc032e005da9352341bd1c (patch)
tree37ed68ad00caa14aa6d0ca14b3ae569ef83aa457 /mobile-widgets
parente4086dc74648c5f5ed7b72f1dc35e16e3bee8041 (diff)
downloadsubsurface-e700ea9638907c63a2cc032e005da9352341bd1c.tar.gz
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>
Diffstat (limited to 'mobile-widgets')
-rw-r--r--mobile-widgets/qmlprofile.cpp16
1 files changed, 13 insertions, 3 deletions
diff --git a/mobile-widgets/qmlprofile.cpp b/mobile-widgets/qmlprofile.cpp
index a823fe97e..cb665c0a0 100644
--- a/mobile-widgets/qmlprofile.cpp
+++ b/mobile-widgets/qmlprofile.cpp
@@ -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();