Mercurial > hg > svgui
changeset 577:dc511d5fee75
* Display distance the selection has been dragged by, when moving it with the edit tool
author | Chris Cannam |
---|---|
date | Fri, 04 Feb 2011 14:30:51 +0000 |
parents | a4ba6c96b66d |
children | e2211947cbfd |
files | view/Pane.cpp |
diffstat | 1 files changed, 40 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/view/Pane.cpp Mon Oct 25 21:52:38 2010 +0200 +++ b/view/Pane.cpp Fri Feb 04 14:30:51 2011 +0000 @@ -917,17 +917,55 @@ Pane::drawEditingSelection(QPainter &paint) { int offset = m_mousePos.x() - m_clickPos.x(); - int p0 = getXForFrame(m_editingSelection.getStartFrame()) + offset; + + long origStart = m_editingSelection.getStartFrame(); + + int p0 = getXForFrame(origStart) + offset; int p1 = getXForFrame(m_editingSelection.getEndFrame()) + offset; - + if (m_editingSelectionEdge < 0) { p1 = getXForFrame(m_editingSelection.getEndFrame()); } else if (m_editingSelectionEdge > 0) { p0 = getXForFrame(m_editingSelection.getStartFrame()); } + long newStart = getFrameForX(p0); + long newEnd = getFrameForX(p1); + paint.save(); paint.setPen(QPen(getForeground(), 2)); + + int fontHeight = paint.fontMetrics().height(); + int fontAscent = paint.fontMetrics().ascent(); + int sampleRate = getModelsSampleRate(); + QString startText, endText, offsetText; + startText = QString("%1").arg(newStart); + endText = QString("%1").arg(newEnd); + offsetText = QString("%1").arg(newStart - origStart); + if (newStart >= origStart) { + offsetText = tr("+%1").arg(offsetText); + } + if (sampleRate) { + startText = QString("%1 / %2") + .arg(QString::fromStdString + (RealTime::frame2RealTime(newStart, sampleRate).toText())) + .arg(startText); + endText = QString("%1 / %2") + .arg(QString::fromStdString + (RealTime::frame2RealTime(newEnd, sampleRate).toText())) + .arg(endText); + offsetText = QString("%1 / %2") + .arg(QString::fromStdString + (RealTime::frame2RealTime(newStart - origStart, sampleRate).toText())) + .arg(offsetText); + if (newStart >= origStart) { + offsetText = tr("+%1").arg(offsetText); + } + } + drawVisibleText(paint, p0 + 2, fontAscent + fontHeight + 4, startText, OutlinedText); + drawVisibleText(paint, p1 + 2, fontAscent + fontHeight + 4, endText, OutlinedText); + drawVisibleText(paint, p0 + 2, fontAscent + fontHeight*2 + 4, offsetText, OutlinedText); + drawVisibleText(paint, p1 + 2, fontAscent + fontHeight*2 + 4, offsetText, OutlinedText); //!!! duplicating display policy with View::drawSelections