Skip to content

Commit

Permalink
Timeline scrollbar UI/UX changes (wip)
Browse files Browse the repository at this point in the history
Untested on Windows and with HiDPI anything.
  • Loading branch information
rodlie committed Aug 2, 2024
1 parent 3570610 commit 185c2d5
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 13 deletions.
7 changes: 2 additions & 5 deletions src/app/GUI/keysview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -536,11 +536,8 @@ void KeysView::paintEvent(QPaintEvent *) {
bool hasOut = hasFrameOut(i+1);
bool hasMark = hasFrameMarker(i+1);
if (!hasIn && !hasOut && !hasMark) { continue; }
if (hasIn || hasOut) {
p.setPen(QPen(ThemeSupport::getThemeHighlightColor(), 2, Qt::DotLine));
} else if (hasMark) {
p.setPen(QPen(ThemeSupport::getThemeFrameMarkerColor(), 2, Qt::DotLine));
}
const QColor col = hasMark ? ThemeSupport::getThemeFrameMarkerColor() : ThemeSupport::getThemeColorGreen();
p.setPen(QPen(col, 2, Qt::DotLine));
const qreal xTT = xT + (i - mMinViewedFrame + 1)*mPixelsPerFrame;
p.drawLine(QPointF(xTT, 0), QPointF(xTT, height()));
}
Expand Down
2 changes: 1 addition & 1 deletion src/app/GUI/timelinewidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ TimelineWidget::TimelineWidget(Document &document,
mFrameScrollBar = new FrameScrollBar(1, 1, false, false, false, this);
mFrameScrollBar->setSizePolicy(QSizePolicy::Minimum,
QSizePolicy::Preferred);
mFrameScrollBar->setFixedHeight(35);
mFrameScrollBar->setFixedHeight(40);
// connect(MemoryHandler::sGetInstance(), &MemoryHandler::memoryFreed,
// frameScrollBar,
// qOverload<>(&FrameScrollBar::update));
Expand Down
35 changes: 28 additions & 7 deletions src/ui/widgets/framescrollbar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -138,32 +138,53 @@ void FrameScrollBar::paintEvent(QPaintEvent *) {
mMaxFrame += qFloor((width() - 40 - xT)/pixPerFrame) - mMaxFrame%iInc;

// draw markers (and in/out)
bool hasInVal = false;
bool hasOutVal = false;
QPair<int, int> inOut{minFrame, maxFrame};
for (int i = minFrame; i <= maxFrame; i++) {
bool hasIn = hasFrameIn(i+1);
bool hasOut = hasFrameOut(i+1);
bool hasMark = hasFrameMarker(i+1);
if (!hasIn && !hasOut && !hasMark) { continue; }
const QColor col = hasMark ? ThemeSupport::getThemeFrameMarkerColor() : ThemeSupport::getThemeHighlightColor();
p.setPen(QPen(col, 2, Qt::DotLine));
if (hasIn) {
hasInVal = true;
inOut.first = i;
}
if (hasOut) {
hasOutVal = true;
inOut.second = i;
}
const QColor col = hasMark ? ThemeSupport::getThemeFrameMarkerColor() : ThemeSupport::getThemeColorGreen();
p.setPen(QPen(col, 2, Qt::SolidLine));
const qreal xTT = xT + (i - mFrameRange.fMin + 1)*pixPerFrame;
p.drawLine(QPointF(xTT, 4), QPointF(xTT, height()));
p.drawLine(QPointF(xTT, 0), QPointF(xTT, mFm.height() + 4));

QString drawValue = hasIn ? tr("In") : hasOut ? tr("Out") : getFrameMarkerText(i+1);
if (!drawValue.isEmpty()) {
p.setPen(QPen(col, 0, Qt::SolidLine));
const auto rect = QRectF(xTT - 1, 0, mFm.horizontalAdvance(drawValue) + 2, mFm.height());
const auto rect = QRectF(xTT + 1, 0, mFm.horizontalAdvance(drawValue) + 2, mFm.height());
p.fillRect(rect, QBrush(col, Qt::SolidPattern));
p.drawRect(rect);
p.setPen(Qt::black);
p.drawText(rect, Qt::AlignCenter, drawValue);
}
}

// draw in/out range
if (hasInVal || hasOutVal) {
const QColor col = ThemeSupport::getThemeColorGreen();
p.setPen(QPen(col, 2, Qt::SolidLine));
const qreal xTT1 = xT + ((!hasInVal ? minFrame : inOut.first) - mFrameRange.fMin + 1)*pixPerFrame;
const qreal xTT2 = xT + ((!hasOutVal ? maxFrame : inOut.second) - mFrameRange.fMin + 1)*pixPerFrame;
const int h = mFm.height() + 1;
p.drawLine(QPointF(xTT1, h), QPointF(xTT2, h));
}

// draw minor
p.setPen(QPen(Qt::darkGray, 2));
for (int i = mMinFrame; i <= mMaxFrame; i += iInc) {
const qreal xTT = xT + (i - mFrameRange.fMin + 1)*pixPerFrame;
p.drawLine(QPointF(xTT, threeFourthsHeight + 4), QPointF(xTT, height()));
p.drawLine(QPointF(xTT, threeFourthsHeight + 6), QPointF(xTT, height()));
}

// draw main
Expand All @@ -172,10 +193,10 @@ void FrameScrollBar::paintEvent(QPaintEvent *) {
bool timecode = mDisplayTime && mFps > 0;
if (qAbs(pixPerFrame) > 0.11) {
while (xL < maxX) {
p.drawLine(QPointF(xL, threeFourthsHeight + 2), QPointF(xL, height()));
p.drawLine(QPointF(xL, threeFourthsHeight + 4), QPointF(xL, height()));
QString drawValue = QString::number(currentFrame);
if (timecode) { drawValue = AppSupport::getTimeCodeFromFrame(currentFrame, mFps); }
p.drawText(QRectF(xL - inc, 0, 2 * inc, height()), Qt::AlignCenter, drawValue);
p.drawText(QRectF(xL - inc, 0, 2 * inc, threeFourthsHeight + 18), Qt::AlignCenter, drawValue);
xL += inc;
currentFrame += mDrawFrameInc;
}
Expand Down

0 comments on commit 185c2d5

Please sign in to comment.