Commit cc77b471 authored by Ulf Hermann's avatar Ulf Hermann
Browse files

Timeline: Improve accuracy when constructing selection node



Constructing a QRectF from two points adds some float arithmetic that
can be avoided by doing the relevant math in integer before. Also,
make sure that we do the float subtraction as last step when
calculating the top of the rectangle.

Change-Id: Id33ffa0cf022ace09d5cdc3e6114b2add5f9b831
Reviewed-by: default avatarJoerg Bornemann <joerg.bornemann@theqtcompany.com>
parent d15cb20e
......@@ -95,23 +95,22 @@ TimelineRenderPass::State *TimelineSelectionRenderPass::update(
int row = model->expandedRow(selectedItem);
int rowHeight = model->expandedRowHeight(row);
height = rowHeight * model->relativeHeight(selectedItem);
top = model->expandedRowOffset(row) - height + rowHeight;
top = (model->expandedRowOffset(row) + rowHeight) - height;
} else {
int row = model->collapsedRow(selectedItem);
height = TimelineModel::defaultRowHeight() * model->relativeHeight(selectedItem);
top = TimelineModel::defaultRowHeight() * (row + 1) - height;
}
qreal left = qMax(model->startTime(selectedItem) - parentState->start(), (qint64)0);
qreal right = qMin(parentState->end() - parentState->start(),
model->endTime(selectedItem) - parentState->start());
qint64 startTime = model->startTime(selectedItem);
qint64 left = qMax(startTime - parentState->start(), (qint64)0);
qint64 width = qMin(parentState->end() - startTime, model->duration(selectedItem));
// 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
// they're independent.
QRectF position(QPointF(left * parentState->scale(), top),
QPointF(right * parentState->scale(), top + height));
QRectF position(left * parentState->scale(), top, width * parentState->scale(), height);
QColor itemColor = model->color(selectedItem);
uchar red = itemColor.red();
......
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