Mercurial > hg > svgui
comparison view/Pane.cpp @ 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 | c2ba2796cbee |
children | 1fe7951a61e8 |
comparison
equal
deleted
inserted
replaced
576:a4ba6c96b66d | 577:dc511d5fee75 |
---|---|
915 | 915 |
916 void | 916 void |
917 Pane::drawEditingSelection(QPainter &paint) | 917 Pane::drawEditingSelection(QPainter &paint) |
918 { | 918 { |
919 int offset = m_mousePos.x() - m_clickPos.x(); | 919 int offset = m_mousePos.x() - m_clickPos.x(); |
920 int p0 = getXForFrame(m_editingSelection.getStartFrame()) + offset; | 920 |
921 long origStart = m_editingSelection.getStartFrame(); | |
922 | |
923 int p0 = getXForFrame(origStart) + offset; | |
921 int p1 = getXForFrame(m_editingSelection.getEndFrame()) + offset; | 924 int p1 = getXForFrame(m_editingSelection.getEndFrame()) + offset; |
922 | 925 |
923 if (m_editingSelectionEdge < 0) { | 926 if (m_editingSelectionEdge < 0) { |
924 p1 = getXForFrame(m_editingSelection.getEndFrame()); | 927 p1 = getXForFrame(m_editingSelection.getEndFrame()); |
925 } else if (m_editingSelectionEdge > 0) { | 928 } else if (m_editingSelectionEdge > 0) { |
926 p0 = getXForFrame(m_editingSelection.getStartFrame()); | 929 p0 = getXForFrame(m_editingSelection.getStartFrame()); |
927 } | 930 } |
928 | 931 |
932 long newStart = getFrameForX(p0); | |
933 long newEnd = getFrameForX(p1); | |
934 | |
929 paint.save(); | 935 paint.save(); |
930 paint.setPen(QPen(getForeground(), 2)); | 936 paint.setPen(QPen(getForeground(), 2)); |
937 | |
938 int fontHeight = paint.fontMetrics().height(); | |
939 int fontAscent = paint.fontMetrics().ascent(); | |
940 int sampleRate = getModelsSampleRate(); | |
941 QString startText, endText, offsetText; | |
942 startText = QString("%1").arg(newStart); | |
943 endText = QString("%1").arg(newEnd); | |
944 offsetText = QString("%1").arg(newStart - origStart); | |
945 if (newStart >= origStart) { | |
946 offsetText = tr("+%1").arg(offsetText); | |
947 } | |
948 if (sampleRate) { | |
949 startText = QString("%1 / %2") | |
950 .arg(QString::fromStdString | |
951 (RealTime::frame2RealTime(newStart, sampleRate).toText())) | |
952 .arg(startText); | |
953 endText = QString("%1 / %2") | |
954 .arg(QString::fromStdString | |
955 (RealTime::frame2RealTime(newEnd, sampleRate).toText())) | |
956 .arg(endText); | |
957 offsetText = QString("%1 / %2") | |
958 .arg(QString::fromStdString | |
959 (RealTime::frame2RealTime(newStart - origStart, sampleRate).toText())) | |
960 .arg(offsetText); | |
961 if (newStart >= origStart) { | |
962 offsetText = tr("+%1").arg(offsetText); | |
963 } | |
964 } | |
965 drawVisibleText(paint, p0 + 2, fontAscent + fontHeight + 4, startText, OutlinedText); | |
966 drawVisibleText(paint, p1 + 2, fontAscent + fontHeight + 4, endText, OutlinedText); | |
967 drawVisibleText(paint, p0 + 2, fontAscent + fontHeight*2 + 4, offsetText, OutlinedText); | |
968 drawVisibleText(paint, p1 + 2, fontAscent + fontHeight*2 + 4, offsetText, OutlinedText); | |
931 | 969 |
932 //!!! duplicating display policy with View::drawSelections | 970 //!!! duplicating display policy with View::drawSelections |
933 | 971 |
934 if (m_editingSelectionEdge < 0) { | 972 if (m_editingSelectionEdge < 0) { |
935 paint.drawLine(p0, 1, p1, 1); | 973 paint.drawLine(p0, 1, p1, 1); |