Commit 7c410663 authored by Ulf Hermann's avatar Ulf Hermann

Timeline: Introduce properties for zoom constants

minimumRangeLength and maximumZoomFactor should be accessible from QML.
Also, the timer offset is obviously not the same as minimumRangeLength,
and as the exact number doesn't matter we give it a different value to
make that clear.

Change-Id: I9cc0289809b14ed32ec06a49276e31ce7b86a301
Reviewed-by: default avatarMaurice Kalinowski <maurice.kalinowski@theqtcompany.com>
parent 19eb9e4f
......@@ -307,7 +307,7 @@ Rectangle {
zoomer: zoomControl
onRangeDoubleClicked: {
var diff = 500 - zoomer.selectionDuration;
var diff = zoomer.minimumRangeLength - zoomer.selectionDuration;
if (diff > 0)
zoomControl.setRange(zoomer.selectionStart - diff / 2,
zoomer.selectionEnd + diff / 2);
......
......@@ -48,7 +48,8 @@ Rectangle {
zoomer.traceStart;
var newEndTime = rangeMover.rangeRight * zoomer.traceDuration / width +
zoomer.traceStart;
if (isFinite(newStartTime) && isFinite(newEndTime) && newEndTime - newStartTime > 500)
if (isFinite(newStartTime) && isFinite(newEndTime) &&
newEndTime - newStartTime > zoomer.minimumRangeLength)
zoomer.setRange(newStartTime, newEndTime);
recursionGuard = false;
}
......
......@@ -120,13 +120,13 @@ void TimelineZoomControl::rebuildWindow()
qint64 oldWindowStart = m_windowStart;
qint64 oldWindowEnd = m_windowEnd;
if (traceDuration() / shownDuration < MAX_ZOOM_FACTOR) {
if (traceDuration() / shownDuration < maximumZoomFactor()) {
m_windowStart = m_traceStart;
m_windowEnd = m_traceEnd;
} else if (windowDuration() / shownDuration > MAX_ZOOM_FACTOR ||
windowDuration() / shownDuration * 2 < MAX_ZOOM_FACTOR ||
} else if (windowDuration() / shownDuration > maximumZoomFactor() ||
windowDuration() / shownDuration * 2 < maximumZoomFactor() ||
m_rangeStart < m_windowStart || m_rangeEnd > m_windowEnd) {
qint64 keep = shownDuration * MAX_ZOOM_FACTOR / 2 - shownDuration;
qint64 keep = shownDuration * maximumZoomFactor() / 2 - shownDuration;
m_windowStart = m_rangeStart - keep;
if (m_windowStart < m_traceStart) {
keep += m_traceStart - m_windowStart;
......@@ -139,7 +139,7 @@ void TimelineZoomControl::rebuildWindow()
m_windowEnd = m_traceEnd;
}
} else {
m_timer.start(500);
m_timer.start(501);
}
if (oldWindowStart != m_windowStart || oldWindowEnd != m_windowEnd) {
bool runTimer = m_timer.isActive();
......
......@@ -58,8 +58,12 @@ class TIMELINE_EXPORT TimelineZoomControl : public QObject {
Q_PROPERTY(bool windowLocked READ windowLocked WRITE setWindowLocked NOTIFY windowLockedChanged)
Q_PROPERTY(bool windowMoving READ windowMoving NOTIFY windowMovingChanged)
Q_PROPERTY(qint64 maximumZoomFactor READ maximumZoomFactor CONSTANT)
Q_PROPERTY(qint64 minimumRangeLength READ minimumRangeLength CONSTANT)
public:
static const qint64 MAX_ZOOM_FACTOR = 1 << 10;
qint64 maximumZoomFactor() const { return 1 << 10; }
qint64 minimumRangeLength() const { return 500; }
TimelineZoomControl(QObject *parent = 0);
qint64 traceStart() const { return m_traceStart; }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment