From 3f2e6af4fa6041310ae45cc4211abeb44286795e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ole-Andr=C3=A9=20Rodlie?= Date: Fri, 20 Oct 2023 22:59:05 +0200 Subject: [PATCH] Improved timeline handle and ticks --- src/app/GUI/animationwidgetscrollbar.cpp | 73 ++++++++++++------------ src/app/GUI/keysview.cpp | 2 +- 2 files changed, 39 insertions(+), 36 deletions(-) diff --git a/src/app/GUI/animationwidgetscrollbar.cpp b/src/app/GUI/animationwidgetscrollbar.cpp index 156a150c7..3c14bdd25 100755 --- a/src/app/GUI/animationwidgetscrollbar.cpp +++ b/src/app/GUI/animationwidgetscrollbar.cpp @@ -76,28 +76,12 @@ void FrameScrollBar::paintEvent(QPaintEvent *) { const int maxFrame = mFrameRange.fMax + f1; const qreal w1 = width() - 1.5*eSizesUI::widget + f1*pixPerFrame - x0; - QColor col = mHandleColor; - if(mPressed) { - col.setHsv(col.hue(), col.saturation(), qMin(255, col.value() + 40)); - } - QRect handleRect; - const int hLeftFrames = mFirstViewedFrame - minFrame; - - const int handleFixedWidth = 16; - const int handleWidth = qRound(mViewedFramesSpan*pixPerFrame); - const int handleLeft = mBottom ? qRound(hLeftFrames*pixPerFrame + x0) : qRound((hLeftFrames*pixPerFrame + x0)+(handleWidth/2)-(handleFixedWidth/2)); - - handleRect.setLeft(handleLeft); - handleRect.setTop(mBottom ? 2 : 5); - handleRect.setWidth(mBottom ? handleWidth : handleFixedWidth); - handleRect.setBottom(mBottom ? 6 : height()); - p.fillRect(handleRect, col); - + // draw cache if (mCurrentCanvas) { const qreal fps = mCurrentCanvas->getFps(); mFps = fps; if (!mRange) { - const int soundHeight = eSizesUI::widget/3; + const int soundHeight = eSizesUI::widget / 1.5; const int rasterHeight = eSizesUI::widget - soundHeight; const QRectF rasterRect(x0, 0, w1, rasterHeight); const auto& rasterCache = mCurrentCanvas->getSceneFramesHandler(); @@ -109,22 +93,49 @@ void FrameScrollBar::paintEvent(QPaintEvent *) { } } - p.setPen(Qt::white); + QColor col = mHandleColor; const qreal inc = mDrawFrameInc*pixPerFrame; - const int minMod = minFrame%mDrawFrameInc; qreal xL = (-minMod + (mRange ? 0. : 0.5))*pixPerFrame + x0; + qreal xxL = xL; int currentFrame = minFrame - minMod; - - /*if(!mRange) { - const int nEmpty = qCeil((70 - xL)/inc); - currentFrame += nEmpty*mDrawFrameInc; - xL += nEmpty*inc; - }*/ - const qreal threeFourthsHeight = height()*0.75; const qreal maxX = width() + eSizesUI::widget; + + // draw minor ticks + if (!mRange) { + p.setPen(mHandleColor); + while (xxL < maxX) { + p.drawLine(QPointF(xxL, threeFourthsHeight + 2), QPointF(xxL, height())); + xxL += inc/5; + } + } + + // draw handle + QRectF handleRect; + const int hLeftFrames = mFirstViewedFrame - minFrame; + const qreal handleFixedWidth = 16; + const qreal handleWidth = (mViewedFramesSpan*pixPerFrame); + const qreal handleLeft = mBottom ? (hLeftFrames*pixPerFrame + x0) : ((hLeftFrames*pixPerFrame + x0)+(handleWidth/2)-(handleFixedWidth/2)); + + handleRect.setLeft(handleLeft); + handleRect.setTop(mBottom ? 2 : 5); + handleRect.setWidth(mBottom ? handleWidth : handleFixedWidth); + handleRect.setBottom(mBottom ? 6 : height()); + if (mRange) { p.fillRect(handleRect, col); } + else { // triangle + QPainterPath path; + path.moveTo(handleRect.left() + (handleRect.width() / 2), handleRect.bottom()); + path.lineTo(handleRect.topLeft()); + path.lineTo(handleRect.topRight()); + path.lineTo(handleRect.left() + (handleRect.width() / 2), handleRect.bottom()); + p.fillPath(path, QColor(180, 0, 0)); + } + + p.setPen(Qt::white); + + // draw main ticks if (!mRange) { while(xL < maxX) { p.drawLine(QPointF(xL, threeFourthsHeight + 2), QPointF(xL, height())); @@ -139,14 +150,6 @@ void FrameScrollBar::paintEvent(QPaintEvent *) { } } - /*p.setPen(QPen(Qt::white, 1)); - if(!mRange) { - const QRectF textRect(eSizesUI::widget, 0, - 5*eSizesUI::widget, height()); - p.drawText(textRect, Qt::AlignVCenter | Qt::AlignLeft, - QString::number(mFrameRange.fMin)); - }*/ - p.end(); } diff --git a/src/app/GUI/keysview.cpp b/src/app/GUI/keysview.cpp index ee3fbecee..c26de56af 100755 --- a/src/app/GUI/keysview.cpp +++ b/src/app/GUI/keysview.cpp @@ -504,7 +504,7 @@ void KeysView::paintEvent(QPaintEvent *) { mCurrentScene->getCurrentFrame() >= minFrame) { xT = (mCurrentScene->getCurrentFrame() - mMinViewedFrame)*mPixelsPerFrame + mPixelsPerFrame*0.5; - p.setPen(QPen(Qt::darkGray, 2)); + p.setPen(QPen(QColor(180, 0, 0), 2)); p.drawLine(QPointF(xT, 0), QPointF(xT, height())); } }