Timeline: Properly account for out-of-bounds events

If an event has to be clipped its length gets shorter ...

Change-Id: Ic59abebff3e856214bbb12eca324816b4e9e740d
Reviewed-by: Joerg Bornemann <joerg.bornemann@theqtcompany.com>
This commit is contained in:
Ulf Hermann
2015-11-10 11:37:39 +01:00
parent ba02ec3b03
commit 00f84cc698

View File

@@ -102,9 +102,12 @@ TimelineRenderPass::State *TimelineSelectionRenderPass::update(
top = TimelineModel::defaultRowHeight() * (row + 1) - height;
}
qint64 startTime = model->startTime(selectedItem);
qint64 left = qMax(startTime - parentState->start(), (qint64)0);
qint64 width = qMin(parentState->end() - startTime, model->duration(selectedItem));
qint64 startTime = qBound(parentState->start(), model->startTime(selectedItem),
parentState->end());
qint64 endTime = qBound(parentState->start(), model->endTime(selectedItem),
parentState->end());
qint64 left = startTime - parentState->start();
qint64 width = endTime - startTime;
// Construct from upper left and lower right for better precision. When constructing from
// left and width the error on the left border is inherited by the right border. Like this