Skip to content

Commit

Permalink
Timeline scrollbar: UI minor
Browse files Browse the repository at this point in the history
  • Loading branch information
rodlie committed Aug 2, 2024
1 parent 945df56 commit b12f310
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 13 deletions.
5 changes: 5 additions & 0 deletions src/core/themesupport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,11 @@ const QColor ThemeSupport::getThemeColorGreen(int alpha)
return getQColor(73, 209, 132, alpha);
}

const QColor ThemeSupport::getThemeColorGreenDark(int alpha)
{
return getQColor(27, 49, 39, alpha);
}

const QColor ThemeSupport::getThemeColorOrange(int alpha)
{
return getQColor(255, 123, 0, alpha);
Expand Down
1 change: 1 addition & 0 deletions src/core/themesupport.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ class CORE_EXPORT ThemeSupport
static const QColor getThemeColorYellow(int alpha = 255);
static const QColor getThemeColorPink(int alpha = 255);
static const QColor getThemeColorGreen(int alpha = 255);
static const QColor getThemeColorGreenDark(int alpha = 255);
static const QColor getThemeColorOrange(int alpha = 255);
static const QPalette getDarkPalette(int alpha = 255);
static const QPalette getDarkerPalette(int alpha = 255);
Expand Down
27 changes: 14 additions & 13 deletions src/ui/widgets/framescrollbar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,18 @@ void FrameScrollBar::paintEvent(QPaintEvent *) {
mMinFrame = mMinFrame - mMinFrame%iInc - 1;
mMaxFrame += qFloor((width() - 40 - xT)/pixPerFrame) - mMaxFrame%iInc;

// draw in/out range
if (frameIn.first && frameOut.first) {
p.setPen(Qt::NoPen);
const qreal xTT1 = xT + (frameIn.second - mFrameRange.fMin) * pixPerFrame;
const qreal xTT2 = xT + (frameOut.second - mFrameRange.fMin) * pixPerFrame;
const int h = mFm.height();
const auto rect = QRectF(xTT1, h, xTT2 - xTT1, height() - h);
p.fillRect(rect, QBrush(ThemeSupport::getThemeColorGreenDark(),
Qt::SolidPattern));
p.drawRect(rect);
}

// draw markers (and in/out)
for (int i = minFrame; i <= maxFrame; i++) {
bool hasIn = frameIn.first ? hasFrameIn(i) : false;
Expand All @@ -152,8 +164,9 @@ void FrameScrollBar::paintEvent(QPaintEvent *) {
p.setPen(QPen(col, 2, Qt::SolidLine));
const qreal xTT = xT + (i - mFrameRange.fMin + 1)*pixPerFrame;
p.drawLine(QPointF(xTT, 0), QPointF(xTT, mFm.height() + 4));

const QString drawValue = hasIn ? tr("In") : hasOut ? tr("Out") : getFrameMarkerText(i);
p.setPen(QPen(col, 0, Qt::SolidLine));
p.setPen(Qt::NoPen);
const auto rect = QRectF(xTT + 1, 0,
mFm.horizontalAdvance(drawValue) + 2,
mFm.height());
Expand All @@ -163,18 +176,6 @@ void FrameScrollBar::paintEvent(QPaintEvent *) {
p.drawText(rect, Qt::AlignCenter, drawValue);
}

// draw in/out range
if (frameIn.first && frameOut.first) {
p.setPen(Qt::NoPen);
const qreal xTT1 = xT + (frameIn.second - mFrameRange.fMin) * pixPerFrame;
const qreal xTT2 = xT + (frameOut.second - mFrameRange.fMin) * pixPerFrame;
const int h = mFm.height() + 1;
const auto rect = QRectF(xTT1, h, xTT2 - xTT1, height() - h);
p.fillRect(rect, QBrush(ThemeSupport::getThemeColorGreen(40),
Qt::SolidPattern));
p.drawRect(rect);
}

// draw minor
p.setPen(QPen(Qt::darkGray, 2));
for (int i = mMinFrame; i <= mMaxFrame; i += iInc) {
Expand Down

0 comments on commit b12f310

Please sign in to comment.