From 74382c9f3d06e3224a6d01fec3628325a5a8d6c6 Mon Sep 17 00:00:00 2001 From: Antoine C Date: Sun, 17 Nov 2024 19:37:44 +0000 Subject: [PATCH] Replace atomic CO with stem selection to change the load behaviour --- src/library/librarycontrol.cpp | 54 ++++++++++++++++++++-------------- src/library/librarycontrol.h | 10 ++++++- 2 files changed, 41 insertions(+), 23 deletions(-) diff --git a/src/library/librarycontrol.cpp b/src/library/librarycontrol.cpp index b54bc75a8257..0158c79f4ca1 100644 --- a/src/library/librarycontrol.cpp +++ b/src/library/librarycontrol.cpp @@ -39,21 +39,13 @@ LoadToGroupController::LoadToGroupController(LibraryControl* pParent, const QStr &LoadToGroupController::slotLoadToGroupAndPlay); #ifdef __STEM__ - m_loadSelectedTrackStems = - std::make_unique(ConfigKey(group, "load_selected_track_stems")); - connect(m_loadSelectedTrackStems.get(), - &ControlObject::valueChanged, - this, - [this](double value) { - if (value >= 0 && value <= 2 << mixxx::kMaxSupportedStems) { - emit loadToGroup(m_group, - mixxx::StemChannelSelection::fromInt( - static_cast(value)), - false); - } - }); + for (int stemIdx = 0; stemIdx < mixxx::kMaxSupportedStems; stemIdx++) { + m_loadSelectedLibraryStems[stemIdx] = + std::make_unique(ConfigKey( + QStringLiteral("[LibraryStem%1]").arg(stemIdx + 1), + "selected")); + } #endif - connect(this, &LoadToGroupController::loadToGroup, pParent, @@ -62,25 +54,35 @@ LoadToGroupController::LoadToGroupController(LibraryControl* pParent, const QStr LoadToGroupController::~LoadToGroupController() = default; +#ifdef __STEM__ +mixxx::StemChannelSelection LoadToGroupController::getLibraryStemSelection() const { + auto stemSelection = mixxx::StemChannelSelection(); + for (int stemIdx = 0; stemIdx < mixxx::kMaxSupportedStems; stemIdx++) { + if (!m_loadSelectedLibraryStems[stemIdx]->toBool()) { + continue; + } + stemSelection |= mixxx::StemChannel(1 << stemIdx); + } + return stemSelection; +} +#endif + void LoadToGroupController::slotLoadToGroup(double v) { if (v > 0) { - emit loadToGroup(m_group, #ifdef __STEM__ - mixxx::StemChannelSelection(), + emit loadToGroup(m_group, getLibraryStemSelection(), false); +#else + emit loadToGroup(m_group, false); #endif - false); } } void LoadToGroupController::slotLoadToGroupAndPlay(double v) { if (v > 0) { #ifdef __STEM__ - emit loadToGroup(m_group, - mixxx::StemChannelSelection(), - true); + emit loadToGroup(m_group, getLibraryStemSelection(), true); #else - emit loadToGroup(m_group, - true); + emit loadToGroup(m_group, true); #endif } } @@ -98,6 +100,14 @@ LibraryControl::LibraryControl(Library* pLibrary) m_numPreviewDecks(kAppGroup, QStringLiteral("num_preview_decks"), this) { qRegisterMetaType("FocusWidget"); +#ifdef __STEM__ + for (int stemIdx = 0; stemIdx < mixxx::kMaxSupportedStems; stemIdx++) { + m_loadSelectedStems[stemIdx] = std::make_unique( + ConfigKey(QStringLiteral("[LibraryStem%1]").arg(stemIdx + 1), + "selected")); + } +#endif + slotNumDecksChanged(m_numDecks.get()); slotNumSamplersChanged(m_numSamplers.get()); slotNumPreviewDecksChanged(m_numPreviewDecks.get()); diff --git a/src/library/librarycontrol.h b/src/library/librarycontrol.h index 584d2df1a7a7..514b6908bcef 100644 --- a/src/library/librarycontrol.h +++ b/src/library/librarycontrol.h @@ -4,6 +4,7 @@ #include #include "control/controlproxy.h" +#include "control/pollingcontrolproxy.h" #include "library/library_decl.h" #ifdef __STEM__ #include "engine/engine.h" @@ -45,7 +46,9 @@ class LoadToGroupController : public QObject { std::unique_ptr m_pLoadAndPlayControl; #ifdef __STEM__ - std::unique_ptr m_loadSelectedTrackStems; + mixxx::StemChannelSelection getLibraryStemSelection() const; + + std::unique_ptr m_loadSelectedLibraryStems[mixxx::kMaxSupportedStems]; #endif }; @@ -221,4 +224,9 @@ class LibraryControl : public QObject { ControlProxy m_numSamplers; ControlProxy m_numPreviewDecks; std::map> m_loadToGroupControllers; + +#ifdef __STEM__ + // Stem selection + std::unique_ptr m_loadSelectedStems[mixxx::kMaxSupportedStems]; +#endif };