From de46f2b37cb354f8f7fbd9867800a591f24a6f5f Mon Sep 17 00:00:00 2001 From: Rick Walsh Date: Sat, 2 Jan 2016 18:23:39 +1100 Subject: 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 Signed-off-by: Dirk Hohndel --- qt-mobile/qmlprofile.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'qt-mobile/qmlprofile.cpp') diff --git a/qt-mobile/qmlprofile.cpp b/qt-mobile/qmlprofile.cpp index ee0eea7bb..9c1fd32a9 100644 --- a/qt-mobile/qmlprofile.cpp +++ b/qt-mobile/qmlprofile.cpp @@ -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); } -- cgit v1.2.3-70-g09d2