[PATCH] QML UI: make profile margin scale proportional to dimensions

Rick Walsh rickmwalsh at gmail.com
Fri Jan 1 23:23:39 PST 2016


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 at gmail.com>
---
Dirk,

I sent this patch as an attachment to a response to an email the other day. I'm guessing you missed it, rather than didn't like what it was doing, but I have been wrong before.

Rick

 qt-mobile/qmlprofile.cpp | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/qt-mobile/qmlprofile.cpp b/qt-mobile/qmlprofile.cpp
index ee0eea7..9c1fd32 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);
 }
-- 
2.5.0



More information about the subsurface mailing list