From 185c2d5033f710f2afa38ff3545f44246dccb1da Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ole-Andr=C3=A9=20Rodlie?= Date: Fri, 2 Aug 2024 15:54:46 +0200 Subject: [PATCH] Timeline scrollbar UI/UX changes (wip) Untested on Windows and with HiDPI anything. --- src/app/GUI/keysview.cpp | 7 ++----- src/app/GUI/timelinewidget.cpp | 2 +- src/ui/widgets/framescrollbar.cpp | 35 ++++++++++++++++++++++++------- 3 files changed, 31 insertions(+), 13 deletions(-) diff --git a/src/app/GUI/keysview.cpp b/src/app/GUI/keysview.cpp index 388acbaf8..6e39e91bf 100644 --- a/src/app/GUI/keysview.cpp +++ b/src/app/GUI/keysview.cpp @@ -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())); } diff --git a/src/app/GUI/timelinewidget.cpp b/src/app/GUI/timelinewidget.cpp index 7ab560e92..a4c85b5e2 100644 --- a/src/app/GUI/timelinewidget.cpp +++ b/src/app/GUI/timelinewidget.cpp @@ -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)); diff --git a/src/ui/widgets/framescrollbar.cpp b/src/ui/widgets/framescrollbar.cpp index bf07766d0..cf73a1772 100644 --- a/src/ui/widgets/framescrollbar.cpp +++ b/src/ui/widgets/framescrollbar.cpp @@ -138,20 +138,31 @@ void FrameScrollBar::paintEvent(QPaintEvent *) { mMaxFrame += qFloor((width() - 40 - xT)/pixPerFrame) - mMaxFrame%iInc; // draw markers (and in/out) + bool hasInVal = false; + bool hasOutVal = false; + QPair 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); @@ -159,11 +170,21 @@ void FrameScrollBar::paintEvent(QPaintEvent *) { } } + // 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 @@ -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; }