QML UI: make profile margin scale proportional to dimensions

The QMLProfile height is specified as ~2/3 (actually 0.66) width in
DiveDetailsView.qml. In order to produce an even margin around the profile,
the scaling factor reduction for height needs to be 3/2 times that for width.

MarginFactor is specified as 0.013 to approximate the margin calculated by
commits ef653b4 and 7e2898d for my Galaxy S6.
MarginFactor	= margin  / width
		= 18 / 1365
		= 0.132

Signed-off-by: Rick Walsh <rickmwalsh@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
Rick Walsh 2016-01-02 18:23:39 +11:00 committed by Dirk Hohndel
parent e856f816f2
commit de46f2b37c

View file

@ -40,6 +40,7 @@ void QMLProfile::setDiveId(const QString &diveId)
static bool firstRun = true;
static QTransform profileTransform;
m_diveId = diveId;
double marginFactor = 0.013; // margin as proportion of profile display width
struct dive *d = get_dive_by_uniq_id(m_diveId.toInt());
if (m_diveId.toInt() < 1)
return;
@ -68,5 +69,7 @@ void QMLProfile::setDiveId(const QString &diveId)
m_profileWidget->plotDive(d);
// scale the profile to create a margin
m_profileWidget->scale(0.95, 0.95);
// the profile height is ~2/3 the width, so to create an even margin,
// the scale reduction for height should be 3/2 the reduction for width
m_profileWidget->scale(1 - 2 * marginFactor, 1 - 3 * marginFactor);
}