aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJean-Baptiste Mardelle <[email protected]>2015-09-04 00:53:15 +0200
committerJean-Baptiste Mardelle <[email protected]>2015-09-04 00:53:15 +0200
commit9acfe3dacf82828c9a3647f2c1e8fd1a94b26b7b (patch)
tree5e21e7f05ceb498e9299e93ff4a12ece05971843
parenteafdda08a5c3fc9b8380c5570628359d60805cb0 (diff)
Improve timeline ruler text spacing (no more timecode overlap)
-rw-r--r--src/monitor/smallruler.cpp4
-rw-r--r--src/timeline/customruler.cpp54
2 files changed, 39 insertions, 19 deletions
diff --git a/src/monitor/smallruler.cpp b/src/monitor/smallruler.cpp
index 0f468ee..1cf1298 100644
--- a/src/monitor/smallruler.cpp
+++ b/src/monitor/smallruler.cpp
@@ -276,14 +276,14 @@ void SmallRuler::updatePixmap()
double f;
m_smallMarkSteps = m_scale * m_small;
m_mediumMarkSteps = m_scale * m_medium;
- QLineF line(0, 1, 0, 4);
+ QLineF line(0, 1, 0, m_rulerHeight / 3);
if (m_smallMarkSteps > 2) {
for (f = 0; f < width(); f += m_smallMarkSteps) {
line.translate(m_smallMarkSteps, 0);
p.drawLine(line);
}
}
- line.setLine(0, 1, 0, 7);
+ line.setLine(0, 1, 0, m_rulerHeight / 2);
if (m_mediumMarkSteps > 2 && m_mediumMarkSteps < width() / 2.5) {
for (f = 0; f < width(); f += m_mediumMarkSteps) {
line.translate(m_mediumMarkSteps, 0);
diff --git a/src/timeline/customruler.cpp b/src/timeline/customruler.cpp
index 96646aa..ba98a8a 100644
--- a/src/timeline/customruler.cpp
+++ b/src/timeline/customruler.cpp
@@ -308,6 +308,11 @@ void CustomRuler::setPixelPerMark(int rate)
m_factor = 1.0 / (double) scale * FRAME_SIZE;
m_scale = 1.0 / (double) scale;
double fend = m_scale * littleMarkDistance;
+ int textFactor = 1;
+ int timeLabelSize = QWidget::fontMetrics().boundingRect("00:00:00:000").width();
+ if (timeLabelSize > littleMarkDistance) {
+ textFactor = timeLabelSize / littleMarkDistance + 1;
+ }
if (rate > 8) {
mediumMarkDistance = (double) FRAME_SIZE * m_timecode.fps() * 60;
bigMarkDistance = (double) FRAME_SIZE * m_timecode.fps() * 300;
@@ -323,38 +328,44 @@ void CustomRuler::setPixelPerMark(int rate)
}
switch (rate) {
case 0:
- m_textSpacing = fend;
+ m_textSpacing = fend * textFactor;
break;
case 1:
- m_textSpacing = fend * 5;
+ m_textSpacing = fend * textFactor * 2.0;
break;
case 2:
+ m_textSpacing = fend * m_timecode.fps() * (textFactor / 5.0);
+ break;
case 3:
+ m_textSpacing = fend * m_timecode.fps() * (textFactor / 4.0);
+ break;
case 4:
- m_textSpacing = fend * m_timecode.fps();
+ m_textSpacing = fend * m_timecode.fps() * textFactor;
break;
case 5:
- m_textSpacing = fend * m_timecode.fps() * 5;
+ m_textSpacing = fend * m_timecode.fps() * textFactor * 2;
break;
case 6:
- m_textSpacing = fend * m_timecode.fps() * 10;
+ m_textSpacing = fend * m_timecode.fps() * textFactor * 5;
break;
case 7:
- m_textSpacing = fend * m_timecode.fps() * 30;
+ m_textSpacing = fend * m_timecode.fps() * textFactor * 10;
break;
case 8:
case 9:
- m_textSpacing = fend * m_timecode.fps() * 40;
+ m_textSpacing = fend * m_timecode.fps() * textFactor * 20;
break;
case 10:
- m_textSpacing = fend * m_timecode.fps() * 80;
+ m_textSpacing = fend * m_timecode.fps() * textFactor * 60;
break;
case 11:
+ m_textSpacing = fend * m_timecode.fps() * textFactor * 120;
+ break;
case 12:
- m_textSpacing = fend * m_timecode.fps() * 400;
+ m_textSpacing = fend * m_timecode.fps() * textFactor * 150;
break;
case 13:
- m_textSpacing = fend * m_timecode.fps() * 800;
+ m_textSpacing = fend * m_timecode.fps() * textFactor * 300;
break;
}
update();
@@ -378,7 +389,7 @@ void CustomRuler::paintEvent(QPaintEvent *e)
const int zoneStart = (int)(m_zoneStart * m_factor);
const int zoneEnd = (int)(m_zoneEnd * m_factor);
p.fillRect(zoneStart - m_offset, LABEL_SIZE + 2, zoneEnd - zoneStart, MAX_HEIGHT - LABEL_SIZE - 2, palette().color(QPalette::Highlight));
-
+
double f, fend;
const int offsetmax = ((paintRect.right() + m_offset) / FRAME_SIZE + 1) * FRAME_SIZE;
int offsetmin;
@@ -404,8 +415,11 @@ void CustomRuler::paintEvent(QPaintEvent *e)
// draw the little marks
fend = m_scale * littleMarkDistance;
if (fend > 5) {
- for (f = offsetmin - m_offset; f < offsetmax - m_offset; f += fend)
- p.drawLine((int)f, LITTLE_MARK_X, (int)f, MAX_HEIGHT);
+ QLineF l(offsetmin - m_offset, LITTLE_MARK_X, offsetmin - m_offset, MAX_HEIGHT);
+ for (f = offsetmin; f < offsetmax; f += fend) {
+ l.translate(fend, 0);
+ p.drawLine(l);
+ }
}
offsetmin = (paintRect.left() + m_offset) / mediumMarkDistance;
@@ -413,8 +427,11 @@ void CustomRuler::paintEvent(QPaintEvent *e)
// draw medium marks
fend = m_scale * mediumMarkDistance;
if (fend > 5) {
- for (f = offsetmin - m_offset - fend; f < offsetmax - m_offset + fend; f += fend)
- p.drawLine((int)f, MIDDLE_MARK_X, (int)f, MAX_HEIGHT);
+ QLineF l(offsetmin - m_offset - fend, MIDDLE_MARK_X, offsetmin - m_offset - fend, MAX_HEIGHT);
+ for (f = offsetmin - fend; f < offsetmax + fend; f += fend) {
+ l.translate(fend, 0);
+ p.drawLine(l);
+ }
}
offsetmin = (paintRect.left() + m_offset) / bigMarkDistance;
@@ -422,8 +439,11 @@ void CustomRuler::paintEvent(QPaintEvent *e)
// draw big marks
fend = m_scale * bigMarkDistance;
if (fend > 5) {
- for (f = offsetmin - m_offset; f < offsetmax - m_offset; f += fend)
- p.drawLine((int)f, BIG_MARK_X, (int)f, MAX_HEIGHT);
+ QLineF l(offsetmin - m_offset, BIG_MARK_X, offsetmin - m_offset, MAX_HEIGHT);
+ for (f = offsetmin; f < offsetmax; f += fend) {
+ l.translate(fend, 0);
+ p.drawLine(l);
+ }
}
// draw zone cursors