Changeset e700ea9 in subsurface


Ignore:
Timestamp:
Apr 4, 2017, 11:00:18 AM (8 weeks ago)
Author:
Dirk Hohndel <dirk@…>
Branches:
master
Children:
01d091fb
Parents:
e4086dc
git-author:
Dirk Hohndel <dirk@…> (04/03/17 12:49:14)
git-committer:
Dirk Hohndel <dirk@…> (04/04/17 11:00:18)
Message:

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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • mobile-widgets/qmlprofile.cpp

    r7ffc619 re700ea9  
    3838
    3939        // next figure out the weird magic by which we need to shift the painter so the profile is shown
    40         int dpr = lrint(devicePixelRatio());
    41         qreal magicShiftFactor = (dpr == 2 ? 0.25 : (dpr == 3 ? 0.33 : 0.0));
    42 
     40        double dpr = devicePixelRatio();
     41        double magicValues[] = { 0.0, 0.1, 0.25, 0.33, 0.375, 0.40, 0.42};
     42        qreal magicShiftFactor = 0.0;
     43        if (dpr <= 1.5) {
     44                magicShiftFactor = magicValues[0];
     45        } else if (dpr > 6.0) {
     46                magicShiftFactor = magicValues[6];
     47        } else if (IS_FP_SAME(dpr, rint(dpr))) {
     48                magicShiftFactor = magicValues[lrint(dpr)];
     49        } else {
     50                int lower = (int)dpr;
     51                magicShiftFactor = (magicValues[lower] * (lower + 1 - dpr) + magicValues[lower + 1] * (dpr - lower));
     52        }
    4353        // now set up the transformations scale the profile and
    4454        // shift the painter (taking its existing transformation into account)
Note: See TracChangeset for help on using the changeset viewer.