Skip to content

Commit

Permalink
Overview column: update when type is changed in preferences
Browse files Browse the repository at this point in the history
  • Loading branch information
ronso0 committed Sep 9, 2024
1 parent aae4336 commit 2fe92b6
Show file tree
Hide file tree
Showing 6 changed files with 109 additions and 11 deletions.
4 changes: 4 additions & 0 deletions res/skins/LateNight/library.xml
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,10 @@
<Library>
<ShowButtonText>false</ShowButtonText>
<TrackTableBackgroundColorOpacity>0.175</TrackTableBackgroundColorOpacity>
<!-- Colors for the render modes of the Overview column -->
<!-- For the decks' overview we only set the signal color,
other colors are the defaults. -->
<SignalColor><Variable name="SignalColor_12"/></SignalColor>
</Library>

</Children>
Expand Down
3 changes: 3 additions & 0 deletions src/library/tabledelegates/overviewdelegate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@ void OverviewDelegate::slotTypeControlChanged(double v) {
}

m_type = type;
// Instantly update visible overviews so we get a live preview
// when changing the type in the preferences.
m_pTableView->update();
}

/// Maybe request repaint via dataChanged() by BaseTrackTableModel
Expand Down
13 changes: 13 additions & 0 deletions src/skin/legacy/legacyskinparser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
#include "util/timer.h"
#include "util/valuetransformer.h"
#include "util/xml.h"
#include "waveform/overviews/waveformoverviewrenderer.h"
#include "waveform/renderers/waveformsignalcolors.h"
#include "waveform/vsyncthread.h"
#include "waveform/waveformwidgetfactory.h"
#include "widget/controlwidgetconnection.h"
Expand Down Expand Up @@ -1580,6 +1582,17 @@ QWidget* LegacySkinParser::parseLibrary(const QDomElement& node) {
BaseTrackTableModel::kApplyPlayedTrackColorDefault);
BaseTrackTableModel::setApplyPlayedTrackColor(applyPlayedTrackColor);

// Get colors for the different render modes of the Overview column
WaveformSignalColors* pSignalColors = new WaveformSignalColors();
pSignalColors->setup(node, *m_pContext);
WaveformOverviewRenderer::setRgbLowColor(pSignalColors->getRgbLowColor());
WaveformOverviewRenderer::setRgbMidColor(pSignalColors->getRgbMidColor());
WaveformOverviewRenderer::setRgbHighColor(pSignalColors->getRgbHighColor());
WaveformOverviewRenderer::setFilteredLowColor(pSignalColors->getLowColor());
WaveformOverviewRenderer::setFilteredMidColor(pSignalColors->getMidColor());
WaveformOverviewRenderer::setFilteredHighColor(pSignalColors->getHighColor());
WaveformOverviewRenderer::setSignalColor(pSignalColors->getSignalColor());

// Connect Library search signals to the WLibrary
connect(m_pLibrary,
&Library::search,
Expand Down
60 changes: 57 additions & 3 deletions src/waveform/overviews/waveformoverviewrenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,44 @@
#include "util/colorcomponents.h"
#include "util/math.h"

QColor WaveformOverviewRenderer::s_rgbLowColor = defaultLowColor;
QColor WaveformOverviewRenderer::s_rgbMidColor = defaultMidColor;
QColor WaveformOverviewRenderer::s_rgbHighColor = defaultHighColor;

QColor WaveformOverviewRenderer::s_filteredLowColor = defaultLowColor;
QColor WaveformOverviewRenderer::s_filteredMidColor = defaultMidColor;
QColor WaveformOverviewRenderer::s_filteredHighColor = defaultHighColor;

QColor WaveformOverviewRenderer::s_signalColor = defaultSignalColor;

void WaveformOverviewRenderer::setRgbLowColor(QColor color) {
s_rgbLowColor = color;
}

void WaveformOverviewRenderer::setRgbMidColor(QColor color) {
s_rgbMidColor = color;
}

void WaveformOverviewRenderer::setRgbHighColor(QColor color) {
s_rgbHighColor = color;
}

void WaveformOverviewRenderer::setFilteredLowColor(QColor color) {
s_filteredLowColor = color;
}

void WaveformOverviewRenderer::setFilteredMidColor(QColor color) {
s_filteredMidColor = color;
}

void WaveformOverviewRenderer::setFilteredHighColor(QColor color) {
s_filteredHighColor = color;
}

void WaveformOverviewRenderer::setSignalColor(QColor color) {
s_signalColor = color;
}

QImage WaveformOverviewRenderer::render(ConstWaveformPointer pWaveform,
WOverview::Type type) {
const int dataSize = pWaveform->getDataSize();
Expand All @@ -19,11 +57,27 @@ QImage WaveformOverviewRenderer::render(ConstWaveformPointer pWaveform,
painter.translate(0.0, static_cast<double>(image.height()) / 2.0);

if (type == WOverview::Type::HSV) {
drawWaveformPartHSV(&painter, pWaveform, nullptr, dataSize);
drawWaveformPartHSV(&painter,
pWaveform,
nullptr,
dataSize,
s_signalColor);
} else if (type == WOverview::Type::Filtered) {
drawWaveformPartLMH(&painter, pWaveform, nullptr, dataSize);
drawWaveformPartLMH(&painter,
pWaveform,
nullptr,
dataSize,
s_filteredLowColor,
s_filteredMidColor,
s_filteredHighColor);
} else {
drawWaveformPartRGB(&painter, pWaveform, nullptr, dataSize);
drawWaveformPartRGB(&painter,
pWaveform,
nullptr,
dataSize,
s_rgbLowColor,
s_rgbMidColor,
s_rgbHighColor);
}

return image;
Expand Down
38 changes: 31 additions & 7 deletions src/waveform/overviews/waveformoverviewrenderer.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,21 +16,45 @@ class WaveformOverviewRenderer : public Singleton<WaveformOverviewRenderer> {
ConstWaveformPointer pWaveform,
int* start,
int end,
QColor lowColor = Qt::red,
QColor midColor = Qt::green,
QColor highColor = Qt::blue);
QColor rgbLowColor,
QColor rgbMidColor,
QColor rgbHighColor);
void drawWaveformPartLMH(
QPainter* pPainter,
ConstWaveformPointer pWaveform,
int* start,
int end,
QColor lowColor = Qt::red,
QColor midColor = Qt::green,
QColor highColor = Qt::blue);
QColor lowColor,
QColor midColor,
QColor highColor);
void drawWaveformPartHSV(
QPainter* pPainter,
ConstWaveformPointer pWaveform,
int* start,
int end,
QColor lowColor = Qt::lightGray);
QColor lowColor);

static void setRgbLowColor(QColor rgbLow);
static void setRgbMidColor(QColor color);
static void setRgbHighColor(QColor color);
static void setFilteredLowColor(QColor color);
static void setFilteredMidColor(QColor color);
static void setFilteredHighColor(QColor color);
static void setSignalColor(QColor color);

static constexpr QColor defaultLowColor = QColor(255, 0, 0);
static constexpr QColor defaultMidColor = QColor(0, 255, 0);
static constexpr QColor defaultHighColor = QColor(0, 0, 255);

static constexpr QColor defaultSignalColor = QColor(200, 200, 200);

static QColor s_rgbLowColor;
static QColor s_rgbMidColor;
static QColor s_rgbHighColor;

static QColor s_filteredLowColor;
static QColor s_filteredMidColor;
static QColor s_filteredHighColor;

static QColor s_signalColor;
};
2 changes: 1 addition & 1 deletion src/widget/woverview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1374,7 +1374,7 @@ bool WOverview::drawNextPixmapPart() {
pWaveform,
&m_actualCompletion,
nextCompletion,
m_signalColors.getLowColor());
m_signalColors.getSignalColor());
} else { // Type::RGB:
ScopedTimer t(QStringLiteral("WOverview::drawNextPixmapPartRGB"));
WaveformOverviewRenderer::instance()->drawWaveformPartRGB(
Expand Down

0 comments on commit 2fe92b6

Please sign in to comment.