Skip to content

Commit

Permalink
Update keysview
Browse files Browse the repository at this point in the history
  • Loading branch information
rodlie committed Jun 24, 2024
1 parent 8056c30 commit 240b2cc
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 17 deletions.
46 changes: 29 additions & 17 deletions src/app/GUI/keysview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,28 @@ void KeysView::selectKeysInSelectionRect() {
}
}

bool KeysView::hasFrameIn(const int frame)
{
if (!mCurrentScene) { return false; }
const auto frameIn = mCurrentScene->getFrameIn();
if ((frameIn.first && frame == (frameIn.second - 1))) { return true; }
return false;
}

bool KeysView::hasFrameOut(const int frame)
{
if (!mCurrentScene) { return false; }
const auto frameOut = mCurrentScene->getFrameOut();
if ((frameOut.first && frame == (frameOut.second - 1))) { return true; }
return false;
}

bool KeysView::hasFrameMarker(const int frame)
{
if (!mCurrentScene) { return false; }
return mCurrentScene->hasMarker(frame);
}

void KeysView::resizeEvent(QResizeEvent *e) {
if(mHighlighter) mHighlighter->resize(e->size());
updatePixelsPerFrame();
Expand Down Expand Up @@ -497,24 +519,14 @@ void KeysView::paintEvent(QPaintEvent *) {
maxFrame += qFloor((width() - 40 - xT)/mPixelsPerFrame) - maxFrame%iInc;
for(int i = minFrame; i <= maxFrame; i += iInc) {
const qreal xTT = xT + (i - mMinViewedFrame + 1)*mPixelsPerFrame;
p.setPen(QPen(ThemeSupport::getThemeTimelineColor(), 2));
p.drawLine(QPointF(xTT, 0), QPointF(xTT, height()));

if (mCurrentScene) {
const auto frameIn = mCurrentScene->getFrameIn();
const auto frameOut = mCurrentScene->getFrameOut();
if ((frameOut.first && i == (frameOut.second-1)) || (frameIn.first && i == (frameIn.second-1))) {
p.setPen(QPen(ThemeSupport::getThemeHighlightColor(), 2, Qt::DotLine));
p.drawLine(QPointF(xTT, 0), QPointF(xTT, height()));
}
const auto markers = mCurrentScene->getMarkers();
for (const auto &mark: markers) {
if ((mark.second-1) == i) {
p.setPen(QPen(Qt::white, 2, Qt::DotLine));
p.drawLine(QPointF(xTT, 0), QPointF(xTT, height()));
}
}
if (hasFrameIn(i) || hasFrameOut(i)) {
p.setPen(QPen(ThemeSupport::getThemeHighlightColor(), 2, Qt::DotLine));
} else if (hasFrameMarker(i)) {
p.setPen(QPen(Qt::white, 2, Qt::DotLine));
} else {
p.setPen(QPen(ThemeSupport::getThemeTimelineColor(), 2));
}
p.drawLine(QPointF(xTT, 0), QPointF(xTT, height()));
}

if (mCurrentScene) {
Expand Down
4 changes: 4 additions & 0 deletions src/app/GUI/keysview.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,10 @@ class KeysView : public QWidget, public KeyFocusTarget {
void clearKeySelection();
void selectKeysInSelectionRect();

bool hasFrameIn(const int frame);
bool hasFrameOut(const int frame);
bool hasFrameMarker(const int frame);

// graph

void graphPaint(QPainter *p);
Expand Down

0 comments on commit 240b2cc

Please sign in to comment.