Skip to content

Commit

Permalink
Fix markers drawing
Browse files Browse the repository at this point in the history
  • Loading branch information
rodlie committed Jul 3, 2024
1 parent 66a0974 commit 3fb859a
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 14 deletions.
20 changes: 15 additions & 5 deletions src/app/GUI/keysview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,8 @@ void KeysView::mousePressEvent(QMouseEvent *e) {
if(!movable) {
} else if(movable->isDurationRect()) {
QMenu menu;
menu.addAction("Settings...");
menu.addAction(tr("Edit duration"));
// TODO: add split action
const auto selectedAction = menu.exec(e->globalPos());
if(selectedAction) {
const auto durRect = static_cast<DurationRectangle*>(movable);
Expand Down Expand Up @@ -517,15 +518,24 @@ void KeysView::paintEvent(QPaintEvent *) {
minFrame += qCeil((-xT)/mPixelsPerFrame);
minFrame = minFrame - minFrame%iInc - 1;
maxFrame += qFloor((width() - 40 - xT)/mPixelsPerFrame) - maxFrame%iInc;

for(int i = minFrame; i <= maxFrame; i += iInc) {
const qreal xTT = xT + (i - mMinViewedFrame + 1)*mPixelsPerFrame;
if (hasFrameIn(i+1) || hasFrameOut(i+1)) {
p.drawLine(QPointF(xTT, 0), QPointF(xTT, height()));
}

// draw markers (and in/out)
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; }
if (hasIn || hasOut) {
p.setPen(QPen(ThemeSupport::getThemeHighlightColor(), 2, Qt::DotLine));
} else if (hasFrameMarker(i+1)) {
} else if (hasMark) {
p.setPen(QPen(ThemeSupport::getThemeFrameMarkerColor(), 2, Qt::DotLine));
} else {
p.setPen(QPen(ThemeSupport::getThemeTimelineColor(), 2));
}
const qreal xTT = xT + (i - mMinViewedFrame + 1)*mPixelsPerFrame;
p.drawLine(QPointF(xTT, 0), QPointF(xTT, height()));
}

Expand Down
25 changes: 16 additions & 9 deletions src/ui/widgets/framescrollbar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,6 @@ void FrameScrollBar::paintEvent(QPaintEvent *) {

// draw the stuff ...
if (!mRange) {
// draw minor
p.setPen(QPen(Qt::darkGray, 2));
p.translate(eSizesUI::widget/2, 0);
qreal xT = pixPerFrame*0.5;
int iInc = 1;
Expand All @@ -137,16 +135,25 @@ void FrameScrollBar::paintEvent(QPaintEvent *) {
mMinFrame += qCeil((-xT)/pixPerFrame);
mMinFrame = mMinFrame - mMinFrame%iInc - 1;
mMaxFrame += qFloor((width() - 40 - xT)/pixPerFrame) - mMaxFrame%iInc;

// draw markers (and in/out)
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; }
p.setPen(QPen(hasMark ? ThemeSupport::getThemeFrameMarkerColor() : ThemeSupport::getThemeHighlightColor(), 2, Qt::DotLine));
const qreal xTT = xT + (i - mFrameRange.fMin + 1)*pixPerFrame;
p.drawLine(QPointF(xTT, 4), QPointF(xTT, height()));
}

// 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;
bool hasMarker = hasFrameMarker(i+1);
if (hasFrameIn(i+1) || hasFrameOut(i+1) || hasMarker) {
p.setPen(QPen(hasMarker ? ThemeSupport::getThemeFrameMarkerColor() : ThemeSupport::getThemeHighlightColor(), 2, Qt::DotLine));
p.drawLine(QPointF(xTT, 4), QPointF(xTT, height()));
p.setPen(QPen(Qt::darkGray, 2));
}
p.drawLine(QPointF(xTT, threeFourthsHeight + 4), QPointF(xTT, height()));
}

// draw main
p.setPen(QPen(Qt::white, 2));
p.translate(-(eSizesUI::widget/2), 0);
Expand Down Expand Up @@ -278,7 +285,7 @@ void FrameScrollBar::mousePressEvent(QMouseEvent *event)
const auto clearFrameOutAct = new QAction(tr("Clear Frame In/Out"), this);
const auto setMarkerAct = new QAction(tr(hasMarker ? "Remove Marker" : "Add Marker"), this);
const auto clearMarkersAct = new QAction(tr("Clear Markers"), this);
const auto splitDurationAct = new QAction(tr("Split"), this);
const auto splitDurationAct = new QAction(tr("Split Clip"), this);

menu.addSeparator();
menu.addAction(setFrameInAct);
Expand Down

0 comments on commit 3fb859a

Please sign in to comment.