From f2e7b75a7ab28ba8852bdfcc3b530f9d0c6c573b Mon Sep 17 00:00:00 2001 From: saker Date: Mon, 30 Sep 2024 19:40:57 -0400 Subject: [PATCH 01/12] Fix copyright --- include/MixerChannelView.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/MixerChannelView.h b/include/MixerChannelView.h index 8074d4dceaa..92b0f387deb 100644 --- a/include/MixerChannelView.h +++ b/include/MixerChannelView.h @@ -1,7 +1,7 @@ /* - * MixerChannelView.h - the mixer channel view + * MixerChannelView.h * - * Copyright (c) 2022 saker + * Copyright (c) 2024 saker * * This file is part of LMMS - https://lmms.io * From db0fb9079a2e57e4fdd3807256a779653e1a8e2e Mon Sep 17 00:00:00 2001 From: saker Date: Mon, 30 Sep 2024 19:41:22 -0400 Subject: [PATCH 02/12] Fix header guards --- include/MixerChannelView.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/include/MixerChannelView.h b/include/MixerChannelView.h index 92b0f387deb..8863a64d180 100644 --- a/include/MixerChannelView.h +++ b/include/MixerChannelView.h @@ -22,8 +22,8 @@ * */ -#ifndef MIXER_CHANNEL_VIEW_H -#define MIXER_CHANNEL_VIEW_H +#ifndef LMMS_GUI_MIXER_CHANNEL_VIEW_H +#define LMMS_GUI_MIXER_CHANNEL_VIEW_H #include #include @@ -135,4 +135,4 @@ private slots: }; } // namespace lmms::gui -#endif // MIXER_CHANNEL_VIEW_H +#endif // LMMS_GUI_MIXER_CHANNEL_VIEW_H From c1a959562039a74d8c901d3ec18ef2b5d278648f Mon Sep 17 00:00:00 2001 From: saker Date: Mon, 30 Sep 2024 20:34:33 -0400 Subject: [PATCH 03/12] Inline property getters/setters --- include/MixerChannelView.h | 23 ++++++++--------- src/gui/MixerChannelView.cpp | 50 ------------------------------------ 2 files changed, 11 insertions(+), 62 deletions(-) diff --git a/include/MixerChannelView.h b/include/MixerChannelView.h index 8863a64d180..a576417b072 100644 --- a/include/MixerChannelView.h +++ b/include/MixerChannelView.h @@ -65,25 +65,24 @@ class MixerChannelView : public QWidget void mouseDoubleClickEvent(QMouseEvent*) override; bool eventFilter(QObject* dist, QEvent* event) override; + void reset(); int channelIndex() const; void setChannelIndex(int index); - QBrush backgroundActive() const; - void setBackgroundActive(const QBrush& c); - - QColor strokeOuterActive() const; - void setStrokeOuterActive(const QColor& c); + QBrush backgroundActive() const { return m_backgroundActive; } + void setBackgroundActive(const QBrush& c) { m_backgroundActive = c; } - QColor strokeOuterInactive() const; - void setStrokeOuterInactive(const QColor& c); + QColor strokeOuterActive() const { return m_strokeOuterActive; } + void setStrokeOuterActive(const QColor& c) { m_strokeOuterActive = c; } - QColor strokeInnerActive() const; - void setStrokeInnerActive(const QColor& c); + QColor strokeOuterInactive() const { return m_strokeOuterInactive; } + void setStrokeOuterInactive(const QColor& c) { m_strokeOuterInactive = c; } - QColor strokeInnerInactive() const; - void setStrokeInnerInactive(const QColor& c); + QColor strokeInnerActive() const { return m_strokeInnerActive; } + void setStrokeInnerActive(const QColor& c) { m_strokeInnerActive = c; } - void reset(); + QColor strokeInnerInactive() const { return m_strokeInnerInactive; } + void setStrokeInnerInactive(const QColor& c) { m_strokeInnerInactive = c; } public slots: void renameChannel(); diff --git a/src/gui/MixerChannelView.cpp b/src/gui/MixerChannelView.cpp index 2228c850882..19de9f4d034 100644 --- a/src/gui/MixerChannelView.cpp +++ b/src/gui/MixerChannelView.cpp @@ -262,56 +262,6 @@ void MixerChannelView::setChannelIndex(int index) m_channelIndex = index; } -QBrush MixerChannelView::backgroundActive() const -{ - return m_backgroundActive; -} - -void MixerChannelView::setBackgroundActive(const QBrush& c) -{ - m_backgroundActive = c; -} - -QColor MixerChannelView::strokeOuterActive() const -{ - return m_strokeOuterActive; -} - -void MixerChannelView::setStrokeOuterActive(const QColor& c) -{ - m_strokeOuterActive = c; -} - -QColor MixerChannelView::strokeOuterInactive() const -{ - return m_strokeOuterInactive; -} - -void MixerChannelView::setStrokeOuterInactive(const QColor& c) -{ - m_strokeOuterInactive = c; -} - -QColor MixerChannelView::strokeInnerActive() const -{ - return m_strokeInnerActive; -} - -void MixerChannelView::setStrokeInnerActive(const QColor& c) -{ - m_strokeInnerActive = c; -} - -QColor MixerChannelView::strokeInnerInactive() const -{ - return m_strokeInnerInactive; -} - -void MixerChannelView::setStrokeInnerInactive(const QColor& c) -{ - m_strokeInnerInactive = c; -} - void MixerChannelView::reset() { m_peakIndicator->resetPeakToMinusInf(); From a526e7ca8742434adb45a4168bc5ed62e1e9207c Mon Sep 17 00:00:00 2001 From: saker Date: Mon, 30 Sep 2024 20:36:47 -0400 Subject: [PATCH 04/12] Inline more functions --- include/MixerChannelView.h | 6 +++--- src/gui/MixerChannelView.cpp | 10 ---------- 2 files changed, 3 insertions(+), 13 deletions(-) diff --git a/include/MixerChannelView.h b/include/MixerChannelView.h index a576417b072..64ce55605b1 100644 --- a/include/MixerChannelView.h +++ b/include/MixerChannelView.h @@ -38,13 +38,13 @@ #include "LcdWidget.h" #include "PixmapButton.h" #include "SendButtonIndicator.h" +#include "PeakIndicator.h" namespace lmms { class MixerChannel; } namespace lmms::gui { -class PeakIndicator; constexpr int MIXER_CHANNEL_INNER_BORDER_SIZE = 3; constexpr int MIXER_CHANNEL_OUTER_BORDER_SIZE = 1; @@ -65,8 +65,8 @@ class MixerChannelView : public QWidget void mouseDoubleClickEvent(QMouseEvent*) override; bool eventFilter(QObject* dist, QEvent* event) override; - void reset(); - int channelIndex() const; + void reset() { m_peakIndicator->resetPeakToMinusInf(); } + int channelIndex() const { return m_channelIndex; } void setChannelIndex(int index); QBrush backgroundActive() const { return m_backgroundActive; } diff --git a/src/gui/MixerChannelView.cpp b/src/gui/MixerChannelView.cpp index 19de9f4d034..30e720180bd 100644 --- a/src/gui/MixerChannelView.cpp +++ b/src/gui/MixerChannelView.cpp @@ -246,11 +246,6 @@ bool MixerChannelView::eventFilter(QObject* dist, QEvent* event) return false; } -int MixerChannelView::channelIndex() const -{ - return m_channelIndex; -} - void MixerChannelView::setChannelIndex(int index) { MixerChannel* mixerChannel = Engine::mixer()->mixerChannel(index); @@ -262,11 +257,6 @@ void MixerChannelView::setChannelIndex(int index) m_channelIndex = index; } -void MixerChannelView::reset() -{ - m_peakIndicator->resetPeakToMinusInf(); -} - void MixerChannelView::renameChannel() { m_inRename = true; From 09b169fca3a2e91f28d06546d9d548636e5a58a9 Mon Sep 17 00:00:00 2001 From: saker Date: Mon, 30 Sep 2024 20:42:12 -0400 Subject: [PATCH 05/12] Move constexpr definitions into class --- include/MixerChannelView.h | 5 +++-- src/gui/MixerChannelView.cpp | 4 ++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/include/MixerChannelView.h b/include/MixerChannelView.h index 64ce55605b1..3ab87ee12f2 100644 --- a/include/MixerChannelView.h +++ b/include/MixerChannelView.h @@ -46,8 +46,6 @@ class MixerChannel; namespace lmms::gui { -constexpr int MIXER_CHANNEL_INNER_BORDER_SIZE = 3; -constexpr int MIXER_CHANNEL_OUTER_BORDER_SIZE = 1; class MixerChannelView : public QWidget { @@ -58,6 +56,9 @@ class MixerChannelView : public QWidget Q_PROPERTY(QColor strokeInnerActive READ strokeInnerActive WRITE setStrokeInnerActive) Q_PROPERTY(QColor strokeInnerInactive READ strokeInnerInactive WRITE setStrokeInnerInactive) public: + static constexpr auto InnerBorderSize = 3; + static constexpr auto OuterBorderSize = 1; + MixerChannelView(QWidget* parent, MixerView* mixerView, int channelIndex); void paintEvent(QPaintEvent* event) override; void contextMenuEvent(QContextMenuEvent*) override; diff --git a/src/gui/MixerChannelView.cpp b/src/gui/MixerChannelView.cpp index 30e720180bd..18bba616b7d 100644 --- a/src/gui/MixerChannelView.cpp +++ b/src/gui/MixerChannelView.cpp @@ -208,11 +208,11 @@ void MixerChannelView::paintEvent(QPaintEvent* event) // inner border painter.setPen(isActive ? strokeInnerActive() : strokeInnerInactive()); - painter.drawRect(1, 1, width - MIXER_CHANNEL_INNER_BORDER_SIZE, height - MIXER_CHANNEL_INNER_BORDER_SIZE); + painter.drawRect(1, 1, width - InnerBorderSize, height - InnerBorderSize); // outer border painter.setPen(isActive ? strokeOuterActive() : strokeOuterInactive()); - painter.drawRect(0, 0, width - MIXER_CHANNEL_OUTER_BORDER_SIZE, height - MIXER_CHANNEL_OUTER_BORDER_SIZE); + painter.drawRect(0, 0, width - OuterBorderSize, height - OuterBorderSize); QWidget::paintEvent(event); } From 1dec14f338d553c498fb1c0013c40816885aea91 Mon Sep 17 00:00:00 2001 From: saker Date: Mon, 30 Sep 2024 20:54:47 -0400 Subject: [PATCH 06/12] Remove extraneous code from paintEvent The renaming code removed is handled in renameFinished already, and I don't think the base paintEvent function does anything. --- src/gui/MixerChannelView.cpp | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/src/gui/MixerChannelView.cpp b/src/gui/MixerChannelView.cpp index 18bba616b7d..8bd6e00d3ac 100644 --- a/src/gui/MixerChannelView.cpp +++ b/src/gui/MixerChannelView.cpp @@ -189,18 +189,12 @@ void MixerChannelView::contextMenuEvent(QContextMenuEvent*) void MixerChannelView::paintEvent(QPaintEvent* event) { const auto channel = mixerChannel(); - const bool muted = channel->m_muteModel.value(); - const auto name = channel->m_name; - const auto elidedName = elideName(name); const auto isActive = m_mixerView->currentMixerChannel() == this; - - if (!m_inRename && m_renameLineEdit->text() != elidedName) { m_renameLineEdit->setText(elidedName); } - const auto width = rect().width(); const auto height = rect().height(); auto painter = QPainter{this}; - if (channel->color().has_value() && !muted) + if (channel->color().has_value() && !channel->m_muteModel.value()) { painter.fillRect(rect(), channel->color()->darker(isActive ? 120 : 150)); } @@ -213,8 +207,6 @@ void MixerChannelView::paintEvent(QPaintEvent* event) // outer border painter.setPen(isActive ? strokeOuterActive() : strokeOuterInactive()); painter.drawRect(0, 0, width - OuterBorderSize, height - OuterBorderSize); - - QWidget::paintEvent(event); } void MixerChannelView::mousePressEvent(QMouseEvent*) From a1a0bceac4a1bf1e36568a0140b3ce961f14b248 Mon Sep 17 00:00:00 2001 From: saker Date: Mon, 30 Sep 2024 22:55:47 -0400 Subject: [PATCH 07/12] Fix unused variable warnings --- src/gui/MixerChannelView.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/gui/MixerChannelView.cpp b/src/gui/MixerChannelView.cpp index 8bd6e00d3ac..76b2f22bb30 100644 --- a/src/gui/MixerChannelView.cpp +++ b/src/gui/MixerChannelView.cpp @@ -186,7 +186,7 @@ void MixerChannelView::contextMenuEvent(QContextMenuEvent*) delete contextMenu; } -void MixerChannelView::paintEvent(QPaintEvent* event) +void MixerChannelView::paintEvent(QPaintEvent*) { const auto channel = mixerChannel(); const auto isActive = m_mixerView->currentMixerChannel() == this; @@ -219,7 +219,7 @@ void MixerChannelView::mouseDoubleClickEvent(QMouseEvent*) renameChannel(); } -bool MixerChannelView::eventFilter(QObject* dist, QEvent* event) +bool MixerChannelView::eventFilter(QObject*, QEvent* event) { // If we are in a rename, capture the enter/return events and handle them if (event->type() == QEvent::KeyPress) From c927d62049c4a76ccf6ab988209e4af03ed05858 Mon Sep 17 00:00:00 2001 From: saker Date: Fri, 1 Nov 2024 14:39:40 -0400 Subject: [PATCH 08/12] Move reset function back into cpp file --- include/MixerChannelView.h | 2 +- src/gui/MixerChannelView.cpp | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/include/MixerChannelView.h b/include/MixerChannelView.h index 3ab87ee12f2..1b7c4ade1f7 100644 --- a/include/MixerChannelView.h +++ b/include/MixerChannelView.h @@ -66,7 +66,7 @@ class MixerChannelView : public QWidget void mouseDoubleClickEvent(QMouseEvent*) override; bool eventFilter(QObject* dist, QEvent* event) override; - void reset() { m_peakIndicator->resetPeakToMinusInf(); } + void reset(); int channelIndex() const { return m_channelIndex; } void setChannelIndex(int index); diff --git a/src/gui/MixerChannelView.cpp b/src/gui/MixerChannelView.cpp index 76b2f22bb30..56eb8a54f38 100644 --- a/src/gui/MixerChannelView.cpp +++ b/src/gui/MixerChannelView.cpp @@ -391,4 +391,9 @@ MixerChannel* MixerChannelView::mixerChannel() const return Engine::mixer()->mixerChannel(m_channelIndex); } +void MixerChannelView::reset() +{ + m_peakIndicator->resetPeakToMinusInf(); +} + } // namespace lmms::gui From 3a6f1f3e624eb519ad7c1c009e964b0e4c179fc7 Mon Sep 17 00:00:00 2001 From: saker Date: Fri, 1 Nov 2024 14:43:33 -0400 Subject: [PATCH 09/12] Remove PeakIndicator.h include and add forward declaration --- include/MixerChannelView.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/MixerChannelView.h b/include/MixerChannelView.h index 1b7c4ade1f7..de6d59d8f86 100644 --- a/include/MixerChannelView.h +++ b/include/MixerChannelView.h @@ -38,13 +38,13 @@ #include "LcdWidget.h" #include "PixmapButton.h" #include "SendButtonIndicator.h" -#include "PeakIndicator.h" namespace lmms { class MixerChannel; } namespace lmms::gui { +class PeakIndicator; class MixerChannelView : public QWidget From 6b556fa455d130cff1f326dff580724305995524 Mon Sep 17 00:00:00 2001 From: saker Date: Fri, 1 Nov 2024 17:02:20 -0400 Subject: [PATCH 10/12] Move inner border size and outer border size into paintEvent function --- include/MixerChannelView.h | 3 --- src/gui/MixerChannelView.cpp | 7 +++++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/include/MixerChannelView.h b/include/MixerChannelView.h index de6d59d8f86..6716aee094b 100644 --- a/include/MixerChannelView.h +++ b/include/MixerChannelView.h @@ -56,9 +56,6 @@ class MixerChannelView : public QWidget Q_PROPERTY(QColor strokeInnerActive READ strokeInnerActive WRITE setStrokeInnerActive) Q_PROPERTY(QColor strokeInnerInactive READ strokeInnerInactive WRITE setStrokeInnerInactive) public: - static constexpr auto InnerBorderSize = 3; - static constexpr auto OuterBorderSize = 1; - MixerChannelView(QWidget* parent, MixerView* mixerView, int channelIndex); void paintEvent(QPaintEvent* event) override; void contextMenuEvent(QContextMenuEvent*) override; diff --git a/src/gui/MixerChannelView.cpp b/src/gui/MixerChannelView.cpp index 56eb8a54f38..2981b714874 100644 --- a/src/gui/MixerChannelView.cpp +++ b/src/gui/MixerChannelView.cpp @@ -188,6 +188,9 @@ void MixerChannelView::contextMenuEvent(QContextMenuEvent*) void MixerChannelView::paintEvent(QPaintEvent*) { + static constexpr auto innerBorderSize = 3; + static constexpr auto outerBorderSize = 1; + const auto channel = mixerChannel(); const auto isActive = m_mixerView->currentMixerChannel() == this; const auto width = rect().width(); @@ -202,11 +205,11 @@ void MixerChannelView::paintEvent(QPaintEvent*) // inner border painter.setPen(isActive ? strokeInnerActive() : strokeInnerInactive()); - painter.drawRect(1, 1, width - InnerBorderSize, height - InnerBorderSize); + painter.drawRect(1, 1, width - innerBorderSize, height - innerBorderSize); // outer border painter.setPen(isActive ? strokeOuterActive() : strokeOuterInactive()); - painter.drawRect(0, 0, width - OuterBorderSize, height - OuterBorderSize); + painter.drawRect(0, 0, width - outerBorderSize, height - outerBorderSize); } void MixerChannelView::mousePressEvent(QMouseEvent*) From 50482c64e1bdf63a72decea6b69d1aa16b7f791d Mon Sep 17 00:00:00 2001 From: saker Date: Fri, 1 Nov 2024 19:34:22 -0400 Subject: [PATCH 11/12] Set name inside textbox when moving to a new channel --- src/gui/MixerChannelView.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/gui/MixerChannelView.cpp b/src/gui/MixerChannelView.cpp index 2981b714874..8bcbd872aab 100644 --- a/src/gui/MixerChannelView.cpp +++ b/src/gui/MixerChannelView.cpp @@ -249,6 +249,7 @@ void MixerChannelView::setChannelIndex(int index) m_soloButton->setModel(&mixerChannel->m_soloModel); m_effectRackView->setModel(&mixerChannel->m_fxChain); m_channelNumberLcd->setValue(index); + m_renameLineEdit->setText(mixerChannel->m_name); m_channelIndex = index; } From ff2b17846ca9f7ab0995efd3887632a302ba8bd7 Mon Sep 17 00:00:00 2001 From: saker Date: Fri, 1 Nov 2024 19:52:10 -0400 Subject: [PATCH 12/12] Elide name --- src/gui/MixerChannelView.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/MixerChannelView.cpp b/src/gui/MixerChannelView.cpp index 8bcbd872aab..1432a42cf53 100644 --- a/src/gui/MixerChannelView.cpp +++ b/src/gui/MixerChannelView.cpp @@ -249,7 +249,7 @@ void MixerChannelView::setChannelIndex(int index) m_soloButton->setModel(&mixerChannel->m_soloModel); m_effectRackView->setModel(&mixerChannel->m_fxChain); m_channelNumberLcd->setValue(index); - m_renameLineEdit->setText(mixerChannel->m_name); + m_renameLineEdit->setText(elideName(mixerChannel->m_name)); m_channelIndex = index; }