Skip to content

Commit

Permalink
Overviews: update in decks and library when type changes
Browse files Browse the repository at this point in the history
  • Loading branch information
ronso0 committed Sep 11, 2024
1 parent 73edc2f commit 99d13c3
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 5 deletions.
7 changes: 6 additions & 1 deletion src/waveform/overviews/overviewcache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -118,9 +118,14 @@ void OverviewCache::setOverviewType(mixxx::OverviewType type) {
}

m_type = type;

const TrackIdList trackIds = m_overviewCache.keys();
for (auto& trackId : trackIds) {
emit overviewChanged(trackId);
}
m_overviewCache.clear();

emit overviewsChanged(m_overviewCache.keys());
emit typeChanged(type);
}

void OverviewCache::setOverviewNormalized(bool normalized) {
Expand Down
6 changes: 5 additions & 1 deletion src/waveform/overviews/overviewcache.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ struct OverviewCacheItem {
class OverviewCache : public QObject, public Singleton<OverviewCache> {
Q_OBJECT
public:
mixxx::OverviewType getOverviewType();
mixxx::OverviewType getOverviewType() {
return m_type;
}
void setOverviewType(mixxx::OverviewType);

bool isOverviewNormalized();
Expand Down Expand Up @@ -73,6 +75,8 @@ class OverviewCache : public QObject, public Singleton<OverviewCache> {

void overviewsChanged(const QList<TrackId>);

void typeChanged(mixxx::OverviewType type);

protected:
OverviewCache(UserSettingsPointer pConfig,
mixxx::DbConnectionPoolPtr pDbConnectionPool,
Expand Down
22 changes: 19 additions & 3 deletions src/widget/woverview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ WOverview::WOverview(
: WWidget(parent),
m_group(group),
m_pConfig(pConfig),
m_pCache(OverviewCache::instance()),
m_type(m_pCache->getOverviewType()),
m_actualCompletion(0),
m_pixmapDone(false),
m_waveformPeak(-1.0),
Expand Down Expand Up @@ -103,6 +105,11 @@ WOverview::WOverview(
&WOverview::onTrackAnalyzerProgress);

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

connect(m_pCache,
&OverviewCache::typeChanged,
this,
&WOverview::slotTypeChanged);
}

void WOverview::setup(const QDomNode& node, const SkinContext& context) {
Expand Down Expand Up @@ -282,8 +289,17 @@ void WOverview::onConnectedControlChanged(double dParameter, double dValue) {
}
}

void WOverview::slotTypeChanged(mixxx::OverviewType type) {
kLogger.warning() << "slotTypeChanged";
if (m_type == type) {
return;
}
m_type = type;
slotWaveformSummaryUpdated();
}

void WOverview::slotWaveformSummaryUpdated() {
//qDebug() << "WOverview::slotWaveformSummaryUpdated()";
kLogger.info() << "slotWaveformSummaryUpdated";

TrackPointer pTrack(m_pCurrentTrack);
if (!pTrack) {
Expand Down Expand Up @@ -676,7 +692,7 @@ void WOverview::drawWaveformPixmap(QPainter* pPainter) {
WaveformWidgetFactory* widgetFactory = WaveformWidgetFactory::instance();
PainterScope painterScope(pPainter);
float diffGain;
bool normalize = OverviewCache::instance()->isOverviewNormalized();
bool normalize = m_pCache->isOverviewNormalized();
if (normalize && m_pixmapDone && m_waveformPeak > 1) {
diffGain = 255 - m_waveformPeak - 1;
} else {
Expand Down Expand Up @@ -1291,7 +1307,7 @@ bool WOverview::drawNextPixmapPart() {
}

RenderResult result = OverviewRenderThread::render(
pWaveform, mixxx::OverviewType::RGB, m_signalColors);
pWaveform, m_type, m_signalColors);
m_waveformSourceImage = result.image;
m_waveformPeak = result.waveformPeak;
// reset scaled image to trigger rebuild in drawWaveformPixmap()
Expand Down
6 changes: 6 additions & 0 deletions src/widget/woverview.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include "track/track_decl.h"
#include "track/trackid.h"
#include "util/parented_ptr.h"
#include "waveform/overviews/overviewtype.h"
#include "waveform/renderers/waveformmarkrange.h"
#include "waveform/renderers/waveformmarkset.h"
#include "waveform/renderers/waveformsignalcolors.h"
Expand All @@ -19,6 +20,7 @@
class PlayerManager;
class QDomNode;
class SkinContext;
class OverviewCache;

class WOverview : public WWidget, public TrackDropTarget {
Q_OBJECT
Expand All @@ -36,6 +38,7 @@ class WOverview : public WWidget, public TrackDropTarget {
void slotTrackLoaded(TrackPointer pTrack);
void slotLoadingTrack(TrackPointer pNewTrack, TrackPointer pOldTrack);
void onTrackAnalyzerProgress(TrackId trackId, AnalyzerProgress analyzerProgress);
void slotTypeChanged(mixxx::OverviewType type);

signals:
void trackDropped(const QString& filename, const QString& group) override;
Expand Down Expand Up @@ -122,6 +125,9 @@ class WOverview : public WWidget, public TrackDropTarget {

const QString m_group;
UserSettingsPointer m_pConfig;
OverviewCache* const m_pCache;

mixxx::OverviewType m_type;

int m_actualCompletion;
bool m_pixmapDone;
Expand Down

0 comments on commit 99d13c3

Please sign in to comment.