Skip to content

Commit

Permalink
draw passthrough overlay on overview ...
Browse files Browse the repository at this point in the history
on top of all overview items and put 'Passthrough' QLabel on top.
Any mouse events are still passed to the overview widget.
Skin style:
The cover color is picked from skin node <PassthroughOverlayColor>
in the Overview widget (default #bb000000), the default label style
can be adjusted in qss (#PassthroughLabel).
  • Loading branch information
ronso0 committed Apr 5, 2020
1 parent e07b176 commit ada7dfb
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 13 deletions.
3 changes: 1 addition & 2 deletions src/waveform/renderers/waveformsignalcolors.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,7 @@ bool WaveformSignalColors::setup(const QDomNode &node, const SkinContext& contex
m_passthroughOverlayColor = context.selectColor(node, "PassthroughOverlayColor");
m_passthroughOverlayColor = WSkinColor::getCorrectColor(m_passthroughOverlayColor).toRgb();
if (!m_passthroughOverlayColor.isValid()) {
// TODO(ronso0): set a default color
m_passthroughOverlayColor = Qt::transparent;
m_passthroughOverlayColor = WSkinColor::getCorrectColor(QColor(187, 0, 0, 0)).toRgb();
}

m_bgColor = context.selectColor(node, "BgColor");
Expand Down
39 changes: 28 additions & 11 deletions src/widget/woverview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
#include <QMouseEvent>
#include <QPaintEvent>
#include <QPainter>
#include <QPixmap>
#include <QUrl>
#include <QtDebug>

Expand Down Expand Up @@ -94,6 +93,17 @@ WOverview::WOverview(
this, &WOverview::onTrackAnalyzerProgress);

connect(m_pCueMenuPopup.get(), &WCueMenuPopup::aboutToHide, this, &WOverview::slotCueMenuPopupAboutToHide);

m_pPassthroughLabel = new QLabel(this);
m_pPassthroughLabel->setObjectName("PassthroughLabel");
m_pPassthroughLabel->setAlignment(Qt::AlignLeft|Qt::AlignVCenter);
m_pPassthroughLabel->setText("Passthrough");
m_pPassthroughLabel->hide();
m_pPassThroughLayout = new QVBoxLayout(this);
m_pPassThroughLayout->setContentsMargins(0,0,0,0);
m_pPassThroughLayout->setAlignment(Qt::AlignLeft|Qt::AlignVCenter);
m_pPassThroughLayout->addWidget(m_pPassthroughLabel);
setLayout(m_pPassThroughLayout);
}

void WOverview::setup(const QDomNode& node, const SkinContext& context) {
Expand Down Expand Up @@ -135,6 +145,8 @@ void WOverview::setup(const QDomNode& node, const SkinContext& context) {
m_endOfTrackColor = WSkinColor::getCorrectColor(m_endOfTrackColor);
}

m_passthroughOverlayColor = m_signalColors.getPlayedOverlayColor();

// setup hotcues and cue and loop(s)
m_marks.setup(m_group, node, context, m_signalColors);

Expand Down Expand Up @@ -243,11 +255,6 @@ void WOverview::onConnectedControlChanged(double dParameter, double dValue) {
void WOverview::slotWaveformSummaryUpdated() {
//qDebug() << "WOverview::slotWaveformSummaryUpdated()";

// Do not draw the waveform when passthrough is enabled
if (m_bPassthroughEnabled) {
return;
}

TrackPointer pTrack(m_pCurrentTrack);
if (!pTrack) {
return;
Expand Down Expand Up @@ -563,11 +570,6 @@ void WOverview::paintEvent(QPaintEvent* pEvent) {
painter.drawPixmap(rect(), m_backgroundPixmap);
}

if (m_bPassthroughEnabled) {
paintText(tr("Passthrough"), &painter);
return;
}

if (m_pCurrentTrack) {
// Refer to util/ScopePainter.h to understand the semantics of
// ScopePainter.
Expand All @@ -589,7 +591,15 @@ void WOverview::paintEvent(QPaintEvent* pEvent) {
drawMarkLabels(&painter, offset, gain);
}
}

if (m_bPassthroughEnabled) {
drawPassthroughOverlay(&painter);
m_pPassthroughLabel->show();
} else {
m_pPassthroughLabel->hide();
}
}

void WOverview::drawEndOfTrackBackground(QPainter* pPainter) {
if (m_endOfTrack) {
PainterScope painterScope(pPainter);
Expand Down Expand Up @@ -1077,6 +1087,13 @@ void WOverview::drawMarkLabels(QPainter* pPainter, const float offset, const flo
}
}

void WOverview::drawPassthroughOverlay(QPainter* pPainter) {
if (!m_waveformSourceImage.isNull() && m_passthroughOverlayColor.alpha() > 0) {
// Overlay the entire overview-waveform with a skin defined color
pPainter->fillRect(rect(), m_passthroughOverlayColor);
}
}

void WOverview::paintText(const QString& text, QPainter* pPainter) {
PainterScope painterScope(pPainter);
QColor lowColor = m_signalColors.getLowColor();
Expand Down
4 changes: 4 additions & 0 deletions src/widget/woverview.h
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ class WOverview : public WWidget, public TrackDropTarget {
void drawPickupPosition(QPainter* pPainter);
void drawTimeRuler(QPainter* pPainter);
void drawMarkLabels(QPainter* pPainter, const float offset, const float gain);
void drawPassthroughOverlay(QPainter* pPainter);
void paintText(const QString& text, QPainter* pPainter);
double samplePositionToSeconds(double sample);
inline int valueToPosition(double value) const {
Expand Down Expand Up @@ -170,6 +171,9 @@ class WOverview : public WWidget, public TrackDropTarget {
QColor m_labelTextColor;
QColor m_labelBackgroundColor;
QColor m_endOfTrackColor;
QColor m_passthroughOverlayColor;
QLabel* m_pPassthroughLabel;
QVBoxLayout* m_pPassThroughLayout;

// All WaveformMarks
WaveformMarkSet m_marks;
Expand Down

0 comments on commit ada7dfb

Please sign in to comment.