From fde6cf92d6ec17d2d4159a1c92ffd5f2e3a2c92d Mon Sep 17 00:00:00 2001 From: aqw42 Date: Wed, 10 Apr 2024 00:01:52 +0200 Subject: [PATCH 01/10] Added library color selector Also unified other color controls implementation with deck track color controls --- src/library/librarycontrol.cpp | 44 ++++++++++++++++++++++------------ src/library/librarycontrol.h | 4 ++-- 2 files changed, 31 insertions(+), 17 deletions(-) diff --git a/src/library/librarycontrol.cpp b/src/library/librarycontrol.cpp index 0b69650eb51..25b7076d37b 100644 --- a/src/library/librarycontrol.cpp +++ b/src/library/librarycontrol.cpp @@ -337,14 +337,29 @@ LibraryControl::LibraryControl(Library* pLibrary) // Track Color controls m_pTrackColorPrev = std::make_unique(ConfigKey("[Library]", "track_color_prev")); m_pTrackColorNext = std::make_unique(ConfigKey("[Library]", "track_color_next")); + m_pTrackColorSelector = std::make_unique( + ConfigKey("[Library]", "track_color_selector"), false); connect(m_pTrackColorPrev.get(), &ControlPushButton::valueChanged, this, - &LibraryControl::slotTrackColorPrev); + [this](double value) { + if (value > 0) + LibraryControl::slotTrackColorSelector(-1); + }); connect(m_pTrackColorNext.get(), &ControlPushButton::valueChanged, this, - &LibraryControl::slotTrackColorNext); + [this](double value) { + if (value > 0) + LibraryControl::slotTrackColorSelector(1); + }); + connect(m_pTrackColorSelector.get(), + &ControlEncoder::valueChanged, + this, + [this](double steps) { + int iSteps = static_cast(steps); + LibraryControl::slotTrackColorSelector(iSteps); + }); // Controls to select saved searchbox queries and to clear the searchbox m_pSelectHistoryNext = std::make_unique( @@ -1109,24 +1124,23 @@ void LibraryControl::slotDecrementFontSize(double v) { } } -void LibraryControl::slotTrackColorPrev(double v) { - if (!m_pLibraryWidget || v <= 0) { +void LibraryControl::slotTrackColorSelector(int steps) { + if (!m_pLibraryWidget || steps == 0) { return; } - WTrackTableView* pTrackTableView = m_pLibraryWidget->getCurrentTrackTableView(); - if (pTrackTableView) { - pTrackTableView->assignPreviousTrackColor(); - } -} - -void LibraryControl::slotTrackColorNext(double v) { - if (!m_pLibraryWidget || v <= 0) { + LibraryView* pActiveView = m_pLibraryWidget->getCurrentTrackTableView(); + if (!pActiveView) { return; } - WTrackTableView* pTrackTableView = m_pLibraryWidget->getCurrentTrackTableView(); - if (pTrackTableView) { - pTrackTableView->assignNextTrackColor(); + while (steps != 0) { + if (steps > 0) { + pActiveView->assignNextTrackColor(); + steps--; + } else { + pActiveView->assignPreviousTrackColor(); + steps++; + } } } diff --git a/src/library/librarycontrol.h b/src/library/librarycontrol.h index 65e21013ea4..412853d0972 100644 --- a/src/library/librarycontrol.h +++ b/src/library/librarycontrol.h @@ -84,8 +84,7 @@ class LibraryControl : public QObject { void slotMoveTrack(double); void slotGoToItem(double v); - void slotTrackColorPrev(double v); - void slotTrackColorNext(double v); + void slotTrackColorSelector(int steps); // Deprecated navigation slots void slotSelectNextTrack(double v); @@ -165,6 +164,7 @@ class LibraryControl : public QObject { // Controls to change track color std::unique_ptr m_pTrackColorPrev; std::unique_ptr m_pTrackColorNext; + std::unique_ptr m_pTrackColorSelector; // Control to show/hide the track menu std::unique_ptr m_pShowTrackMenu; From 0b6e276010b4d5e450501c9856cd1ca19ecac621 Mon Sep 17 00:00:00 2001 From: aqw42 Date: Wed, 10 Apr 2024 00:04:53 +0200 Subject: [PATCH 02/10] ControlPickerMenu: Add library track color control added the last control : selector --- src/controllers/controlpickermenu.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/controllers/controlpickermenu.cpp b/src/controllers/controlpickermenu.cpp index 1c5de6e2ef5..66d8f9e93c8 100644 --- a/src/controllers/controlpickermenu.cpp +++ b/src/controllers/controlpickermenu.cpp @@ -941,6 +941,11 @@ ControlPickerMenu::ControlPickerMenu(QWidget* pParent) tr("Select the previous color in the color palette" " for the first selected track"), pLibraryMenu); + addLibraryControl("track_color_selector", + tr("Navigate Through Track Colors"), + tr("Select either next or previous color in the" + " palette for the first selected track."), + pLibraryMenu); pLibraryMenu->addSeparator(); addControl("[Recording]", From 32a8bb1d461f2576584443b09ce7efd6792418bf Mon Sep 17 00:00:00 2001 From: aqw42 Date: Wed, 10 Apr 2024 00:51:19 +0200 Subject: [PATCH 03/10] Track color controls: Fix code style issue --- src/library/librarycontrol.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/library/librarycontrol.cpp b/src/library/librarycontrol.cpp index 25b7076d37b..c4b52048615 100644 --- a/src/library/librarycontrol.cpp +++ b/src/library/librarycontrol.cpp @@ -343,15 +343,17 @@ LibraryControl::LibraryControl(Library* pLibrary) &ControlPushButton::valueChanged, this, [this](double value) { - if (value > 0) + if (value > 0) { LibraryControl::slotTrackColorSelector(-1); + } }); connect(m_pTrackColorNext.get(), &ControlPushButton::valueChanged, this, [this](double value) { - if (value > 0) + if (value > 0) { LibraryControl::slotTrackColorSelector(1); + } }); connect(m_pTrackColorSelector.get(), &ControlEncoder::valueChanged, From 9e6d17d78f6a87a1142758dbb36ac427f927658a Mon Sep 17 00:00:00 2001 From: aqw42 Date: Wed, 17 Apr 2024 16:02:12 +0200 Subject: [PATCH 04/10] Moved the color selector loop to wtracktableview --- src/library/librarycontrol.cpp | 10 ++-------- src/library/libraryview.h | 4 +--- src/widget/wtracktableview.cpp | 34 ++++++++++++---------------------- src/widget/wtracktableview.h | 3 +-- 4 files changed, 16 insertions(+), 35 deletions(-) diff --git a/src/library/librarycontrol.cpp b/src/library/librarycontrol.cpp index c4b52048615..ab6e2d0bafa 100644 --- a/src/library/librarycontrol.cpp +++ b/src/library/librarycontrol.cpp @@ -1136,13 +1136,7 @@ void LibraryControl::slotTrackColorSelector(int steps) { return; } - while (steps != 0) { - if (steps > 0) { - pActiveView->assignNextTrackColor(); - steps--; - } else { - pActiveView->assignPreviousTrackColor(); - steps++; - } + if (steps != 0) { + pActiveView->selectTrackColor(steps); } } diff --git a/src/library/libraryview.h b/src/library/libraryview.h index 2122b7da58a..1ce6f283eec 100644 --- a/src/library/libraryview.h +++ b/src/library/libraryview.h @@ -38,8 +38,6 @@ class LibraryView { } /// If applicable, requests that the LibraryView changes the track color of /// the selected track. Does nothing otherwise. - virtual void assignPreviousTrackColor() { - } - virtual void assignNextTrackColor() { + virtual void selectTrackColor(int steps) { } }; diff --git a/src/widget/wtracktableview.cpp b/src/widget/wtracktableview.cpp index 8cfda9a4c01..9f2a9028d67 100644 --- a/src/widget/wtracktableview.cpp +++ b/src/widget/wtracktableview.cpp @@ -423,28 +423,8 @@ TrackModel::SortColumnId WTrackTableView::getColumnIdFromCurrentIndex() { return trackModel->sortColumnIdFromColumnIndex(currentIndex().column()); } -void WTrackTableView::assignPreviousTrackColor() { - const QModelIndexList indices = getSelectedRows(); - if (indices.isEmpty()) { - return; - } - - TrackModel* trackModel = getTrackModel(); - if (!trackModel) { - return; - } - - QModelIndex index = indices.at(0); - TrackPointer pTrack = trackModel->getTrack(index); - if (pTrack) { - ColorPaletteSettings colorPaletteSettings(m_pConfig); - ColorPalette colorPalette = colorPaletteSettings.getTrackColorPalette(); - mixxx::RgbColor::optional_t color = pTrack->getColor(); - pTrack->setColor(colorPalette.previousColor(color)); - } -} -void WTrackTableView::assignNextTrackColor() { +void WTrackTableView::selectTrackColor(int steps) { const QModelIndexList indices = getSelectedRows(); if (indices.isEmpty()) { return; @@ -461,7 +441,17 @@ void WTrackTableView::assignNextTrackColor() { ColorPaletteSettings colorPaletteSettings(m_pConfig); ColorPalette colorPalette = colorPaletteSettings.getTrackColorPalette(); mixxx::RgbColor::optional_t color = pTrack->getColor(); - pTrack->setColor(colorPalette.nextColor(color)); + + while (steps != 0) { + if (steps > 0) { + color = colorPalette.nextColor(color); + steps--; + } else { + color = colorPalette.previousColor(color); + steps++; + } + } + pTrack->setColor(color); } } diff --git a/src/widget/wtracktableview.h b/src/widget/wtracktableview.h index 7ec93a3ae67..d8df0ef6b6d 100644 --- a/src/widget/wtracktableview.h +++ b/src/widget/wtracktableview.h @@ -39,8 +39,7 @@ class WTrackTableView : public WLibraryTableView { void resizeEvent(QResizeEvent* event) override; void activateSelectedTrack(); void loadSelectedTrackToGroup(const QString& group, bool play); - void assignNextTrackColor() override; - void assignPreviousTrackColor() override; + void selectTrackColor(int) override; TrackModel::SortColumnId getColumnIdFromCurrentIndex() override; QList getSelectedTrackIds() const; bool isTrackInCurrentView(const TrackId& trackId); From 09ddf9f439564403d9440cd25e5824985ddb3031 Mon Sep 17 00:00:00 2001 From: aqw42 Date: Wed, 17 Apr 2024 16:04:05 +0200 Subject: [PATCH 05/10] Unused argument warnign fix --- src/library/libraryview.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/library/libraryview.h b/src/library/libraryview.h index 1ce6f283eec..991fe7764ab 100644 --- a/src/library/libraryview.h +++ b/src/library/libraryview.h @@ -39,5 +39,6 @@ class LibraryView { /// If applicable, requests that the LibraryView changes the track color of /// the selected track. Does nothing otherwise. virtual void selectTrackColor(int steps) { + Q_UNUSED(steps) } }; From 9826bbe77b6b1003312d81cd1edf8ce887131471 Mon Sep 17 00:00:00 2001 From: aqw42 Date: Thu, 18 Apr 2024 01:42:52 +0200 Subject: [PATCH 06/10] Color Palette: Added getNthColor method --- src/mixer/basetrackplayer.cpp | 11 +---------- src/util/color/colorpalette.cpp | 14 ++++++++++++++ src/util/color/colorpalette.h | 1 + src/widget/wtracktableview.cpp | 23 ++++++++--------------- 4 files changed, 24 insertions(+), 25 deletions(-) diff --git a/src/mixer/basetrackplayer.cpp b/src/mixer/basetrackplayer.cpp index 1b8162c7fe9..789f093923a 100644 --- a/src/mixer/basetrackplayer.cpp +++ b/src/mixer/basetrackplayer.cpp @@ -874,16 +874,7 @@ void BaseTrackPlayerImpl::slotTrackColorSelector(int steps) { ColorPalette colorPalette = colorPaletteSettings.getTrackColorPalette(); mixxx::RgbColor::optional_t color = m_pLoadedTrack->getColor(); - while (steps != 0) { - if (steps > 0) { - color = colorPalette.nextColor(color); - steps--; - } else { - color = colorPalette.previousColor(color); - steps++; - } - } - m_pLoadedTrack->setColor(color); + m_pLoadedTrack->setColor(colorPalette.getNthColor(color, steps)); } void BaseTrackPlayerImpl::slotTrackColorChangeRequest(double v) { diff --git a/src/util/color/colorpalette.cpp b/src/util/color/colorpalette.cpp index b0bb2a53885..94376f4aaf7 100644 --- a/src/util/color/colorpalette.cpp +++ b/src/util/color/colorpalette.cpp @@ -38,6 +38,20 @@ mixxx::RgbColor::optional_t ColorPalette::previousColor(mixxx::RgbColor::optiona return at(size() - 1); } +mixxx::RgbColor::optional_t ColorPalette::getNthColor( + mixxx::RgbColor::optional_t color, int steps) const { + while (steps) { + if (steps > 0) { + color = nextColor(color); + steps--; + } else { + color = previousColor(color); + steps++; + } + } + return color; +} + mixxx::RgbColor ColorPalette::colorForHotcueIndex(unsigned int hotcueIndex) const { int colorIndex; if (m_colorIndicesByHotcue.isEmpty()) { diff --git a/src/util/color/colorpalette.h b/src/util/color/colorpalette.h index 3205a9f7008..9f30d1d4815 100644 --- a/src/util/color/colorpalette.h +++ b/src/util/color/colorpalette.h @@ -35,6 +35,7 @@ class ColorPalette final { mixxx::RgbColor::optional_t nextColor(mixxx::RgbColor::optional_t color) const; mixxx::RgbColor previousColor(mixxx::RgbColor color) const; mixxx::RgbColor::optional_t previousColor(mixxx::RgbColor::optional_t color) const; + mixxx::RgbColor::optional_t getNthColor(mixxx::RgbColor::optional_t color, int steps) const; mixxx::RgbColor colorForHotcueIndex(unsigned int index) const; QList::const_iterator begin() const { diff --git a/src/widget/wtracktableview.cpp b/src/widget/wtracktableview.cpp index 9f2a9028d67..6d6d9c53bf5 100644 --- a/src/widget/wtracktableview.cpp +++ b/src/widget/wtracktableview.cpp @@ -437,22 +437,15 @@ void WTrackTableView::selectTrackColor(int steps) { QModelIndex index = indices.at(0); TrackPointer pTrack = trackModel->getTrack(index); - if (pTrack) { - ColorPaletteSettings colorPaletteSettings(m_pConfig); - ColorPalette colorPalette = colorPaletteSettings.getTrackColorPalette(); - mixxx::RgbColor::optional_t color = pTrack->getColor(); - - while (steps != 0) { - if (steps > 0) { - color = colorPalette.nextColor(color); - steps--; - } else { - color = colorPalette.previousColor(color); - steps++; - } - } - pTrack->setColor(color); + if (!pTrack) { + return; } + + ColorPaletteSettings colorPaletteSettings(m_pConfig); + ColorPalette colorPalette = colorPaletteSettings.getTrackColorPalette(); + mixxx::RgbColor::optional_t color = pTrack->getColor(); + + pTrack->setColor(colorPalette.getNthColor(color, steps)); } void WTrackTableView::slotPurge() { From 561ab07e5c3861c5f7ac7a1976a8338a1e00a813 Mon Sep 17 00:00:00 2001 From: aqw42 Date: Thu, 6 Jun 2024 13:40:31 +0200 Subject: [PATCH 07/10] Add TODO Fix codestyle issue --- src/util/color/colorpalette.cpp | 1 + src/widget/wtracktableview.cpp | 1 - 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/src/util/color/colorpalette.cpp b/src/util/color/colorpalette.cpp index 94376f4aaf7..0a231b598d2 100644 --- a/src/util/color/colorpalette.cpp +++ b/src/util/color/colorpalette.cpp @@ -40,6 +40,7 @@ mixxx::RgbColor::optional_t ColorPalette::previousColor(mixxx::RgbColor::optiona mixxx::RgbColor::optional_t ColorPalette::getNthColor( mixxx::RgbColor::optional_t color, int steps) const { + // TODO : Use rem_euclid modulo function instead of a loop while (steps) { if (steps > 0) { color = nextColor(color); diff --git a/src/widget/wtracktableview.cpp b/src/widget/wtracktableview.cpp index 6d6d9c53bf5..06d5278b18a 100644 --- a/src/widget/wtracktableview.cpp +++ b/src/widget/wtracktableview.cpp @@ -423,7 +423,6 @@ TrackModel::SortColumnId WTrackTableView::getColumnIdFromCurrentIndex() { return trackModel->sortColumnIdFromColumnIndex(currentIndex().column()); } - void WTrackTableView::selectTrackColor(int steps) { const QModelIndexList indices = getSelectedRows(); if (indices.isEmpty()) { From a091a4f32e13eae5e87b5eb8c8770d8eb27e17a1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Th=C3=A9odore=20Noel?= Date: Sat, 28 Sep 2024 11:56:07 +0200 Subject: [PATCH 08/10] Update librarycontrol.cpp Switch to ptracktableview --- src/library/librarycontrol.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/library/librarycontrol.cpp b/src/library/librarycontrol.cpp index ab6e2d0bafa..d2a8797eaa2 100644 --- a/src/library/librarycontrol.cpp +++ b/src/library/librarycontrol.cpp @@ -1131,12 +1131,12 @@ void LibraryControl::slotTrackColorSelector(int steps) { return; } - LibraryView* pActiveView = m_pLibraryWidget->getCurrentTrackTableView(); - if (!pActiveView) { + WTrackTableView* pTrackTableView = m_pLibraryWidget->getCurrentTrackTableView(); + if (!pTrackTableView) { return; } if (steps != 0) { - pActiveView->selectTrackColor(steps); + pTrackTableView->selectTrackColor(steps); } } From be3b34c2f736083b585f3195e5d364e006969413 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Th=C3=A9odore=20Noel?= Date: Wed, 2 Oct 2024 23:47:35 +0200 Subject: [PATCH 09/10] Polishing Co-authored-by: Swiftb0y <12380386+Swiftb0y@users.noreply.github.com> --- src/library/librarycontrol.cpp | 6 ++---- src/library/libraryview.h | 3 +-- src/widget/wtracktableview.h | 2 +- 3 files changed, 4 insertions(+), 7 deletions(-) diff --git a/src/library/librarycontrol.cpp b/src/library/librarycontrol.cpp index 1c330e0ac64..53aafb0019d 100644 --- a/src/library/librarycontrol.cpp +++ b/src/library/librarycontrol.cpp @@ -344,7 +344,7 @@ LibraryControl::LibraryControl(Library* pLibrary) this, [this](double value) { if (value > 0) { - LibraryControl::slotTrackColorSelector(-1); + slotTrackColorSelector(-1); } }); connect(m_pTrackColorNext.get(), @@ -1142,7 +1142,5 @@ void LibraryControl::slotTrackColorSelector(int steps) { return; } - if (steps != 0) { - pTrackTableView->selectTrackColor(steps); - } + pTrackTableView->selectTrackColor(steps); } diff --git a/src/library/libraryview.h b/src/library/libraryview.h index 991fe7764ab..f2811a82fb4 100644 --- a/src/library/libraryview.h +++ b/src/library/libraryview.h @@ -38,7 +38,6 @@ class LibraryView { } /// If applicable, requests that the LibraryView changes the track color of /// the selected track. Does nothing otherwise. - virtual void selectTrackColor(int steps) { - Q_UNUSED(steps) + virtual void selectTrackColor(int) { } }; diff --git a/src/widget/wtracktableview.h b/src/widget/wtracktableview.h index ac0e469786d..83109aa8023 100644 --- a/src/widget/wtracktableview.h +++ b/src/widget/wtracktableview.h @@ -39,7 +39,7 @@ class WTrackTableView : public WLibraryTableView { void resizeEvent(QResizeEvent* event) override; void activateSelectedTrack(); void loadSelectedTrackToGroup(const QString& group, bool play); - void selectTrackColor(int) override; + void selectTrackColor(int steps) override; TrackModel::SortColumnId getColumnIdFromCurrentIndex() override; QList getSelectedTrackIds() const; bool isTrackInCurrentView(const TrackId& trackId); From 7a5e9abd1ee44f62fc70c758b517aa8a7d1b2f2f Mon Sep 17 00:00:00 2001 From: aqw42 Date: Sat, 5 Oct 2024 15:01:01 +0200 Subject: [PATCH 10/10] Removed virtual method selectColor in libraryview --- src/library/libraryview.h | 4 ---- src/widget/wtracktableview.h | 2 +- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/src/library/libraryview.h b/src/library/libraryview.h index f2811a82fb4..bc4914fb935 100644 --- a/src/library/libraryview.h +++ b/src/library/libraryview.h @@ -36,8 +36,4 @@ class LibraryView { virtual TrackModel::SortColumnId getColumnIdFromCurrentIndex() { return TrackModel::SortColumnId::Invalid; } - /// If applicable, requests that the LibraryView changes the track color of - /// the selected track. Does nothing otherwise. - virtual void selectTrackColor(int) { - } }; diff --git a/src/widget/wtracktableview.h b/src/widget/wtracktableview.h index 83109aa8023..efbe878c049 100644 --- a/src/widget/wtracktableview.h +++ b/src/widget/wtracktableview.h @@ -39,7 +39,7 @@ class WTrackTableView : public WLibraryTableView { void resizeEvent(QResizeEvent* event) override; void activateSelectedTrack(); void loadSelectedTrackToGroup(const QString& group, bool play); - void selectTrackColor(int steps) override; + void selectTrackColor(int steps); TrackModel::SortColumnId getColumnIdFromCurrentIndex() override; QList getSelectedTrackIds() const; bool isTrackInCurrentView(const TrackId& trackId);