Skip to content

Commit

Permalink
make waveform_zoom a ControlPotmeter to simplify mapping to potmeters
Browse files Browse the repository at this point in the history
  • Loading branch information
ronso0 committed Feb 1, 2025
1 parent adda147 commit f0542c0
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 69 deletions.
8 changes: 8 additions & 0 deletions res/skins/Deere/style.qss
Original file line number Diff line number Diff line change
Expand Up @@ -1747,6 +1747,14 @@ WPushButton[value="2"]:hover,
border: 1px solid transparent;
}

/* If zoom level is set to default value (with Zoom sync enabled), the Reset button
of other deck waveforms would be lit. This is a bit distracting, disable it.
Unfortunately it doesn't turn blue if pressed but that's acceptable. */
WPushButton#WaveformZoomSetDefaultButton[value="1"] {
background-color: transparent;
border: 1px solid transparent;
}

WPushButton#PlayToggle[value="0"] {
image: url(skin:/../Deere/icon/ic_play_48px.svg) no-repeat center center;
background-color: transparent;
Expand Down
79 changes: 20 additions & 59 deletions src/mixer/basetrackplayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

#include "control/controlencoder.h"
#include "control/controlobject.h"
#include "control/controlpotmeter.h"
#include "engine/channels/enginedeck.h"
#include "engine/controls/enginecontrol.h"
#include "engine/engine.h"
Expand Down Expand Up @@ -193,32 +194,25 @@ BaseTrackPlayerImpl::BaseTrackPlayerImpl(
&BaseTrackPlayerImpl::slotLoadTrackFromSampler);

// Waveform controls
// This acts somewhat like a ControlPotmeter, but the normal _up/_down methods
// do not work properly with this CO.
m_pWaveformZoom =
std::make_unique<ControlObject>(ConfigKey(getGroup(), "waveform_zoom"));
m_pWaveformZoom->connectValueChangeRequest(this,
&BaseTrackPlayerImpl::slotWaveformZoomValueChangeRequest,
Qt::DirectConnection);
m_pWaveformZoom->set(1.0);
m_pWaveformZoomUp = std::make_unique<ControlPushButton>(
ConfigKey(getGroup(), "waveform_zoom_up"));
connect(m_pWaveformZoomUp.get(),
&ControlPushButton::valueChanged,
this,
&BaseTrackPlayerImpl::slotWaveformZoomUp);
m_pWaveformZoomDown = std::make_unique<ControlPushButton>(
ConfigKey(getGroup(), "waveform_zoom_down"));
connect(m_pWaveformZoomDown.get(),
&ControlPushButton::valueChanged,
this,
&BaseTrackPlayerImpl::slotWaveformZoomDown);
m_pWaveformZoomSetDefault = std::make_unique<ControlPushButton>(
ConfigKey(getGroup(), "waveform_zoom_set_default"));
connect(m_pWaveformZoomSetDefault.get(),
&ControlPushButton::valueChanged,
this,
&BaseTrackPlayerImpl::slotWaveformZoomSetDefault);
// Unfortunately there's no WaveformWidgetFactory instance, yet, so we can't
// use WaveformWidgetFactory::instance()->getDefaultZoom()
// Read from config ourselves instead.
double defaultZoom = m_pConfig->getValue(
ConfigKey(QStringLiteral("[Waveform]"), QStringLiteral("DefaultZoom")),
WaveformWidgetRenderer::s_waveformDefaultZoom);
m_pWaveformZoom = std::make_unique<ControlPotmeter>(
ConfigKey(getGroup(), QStringLiteral("waveform_zoom")),
WaveformWidgetRenderer::s_waveformMinZoom,
WaveformWidgetRenderer::s_waveformMaxZoom,
false, // allow out of bounds
false, // ignore no-ops
false, // track
false, // persist
defaultZoom);
const int stepCount = static_cast<int>(WaveformWidgetRenderer::s_waveformMaxZoom -
WaveformWidgetRenderer::s_waveformMinZoom);
m_pWaveformZoom->setStepCount(stepCount);
m_pWaveformZoom->setSmallStepCount(stepCount * 10);

m_pPreGain = make_parented<ControlProxy>(getGroup(), "pregain", this);

Expand Down Expand Up @@ -988,39 +982,6 @@ void BaseTrackPlayerImpl::slotVinylControlEnabled(double v) {
#endif
}

void BaseTrackPlayerImpl::slotWaveformZoomValueChangeRequest(double v) {
if (v <= WaveformWidgetRenderer::s_waveformMaxZoom
&& v >= WaveformWidgetRenderer::s_waveformMinZoom) {
m_pWaveformZoom->setAndConfirm(v);
}
}

void BaseTrackPlayerImpl::slotWaveformZoomUp(double pressed) {
if (pressed <= 0.0) {
return;
}

m_pWaveformZoom->set(m_pWaveformZoom->get() + 1.0);
}

void BaseTrackPlayerImpl::slotWaveformZoomDown(double pressed) {
if (pressed <= 0.0) {
return;
}

m_pWaveformZoom->set(m_pWaveformZoom->get() - 1.0);
}

void BaseTrackPlayerImpl::slotWaveformZoomSetDefault(double pressed) {
if (pressed <= 0.0) {
return;
}

double defaultZoom = m_pConfig->getValue(ConfigKey("[Waveform]", "DefaultZoom"),
WaveformWidgetRenderer::s_waveformDefaultZoom);
m_pWaveformZoom->set(defaultZoom);
}

void BaseTrackPlayerImpl::slotShiftCuesMillis(double milliseconds) {
if (!m_pLoadedTrack) {
return;
Expand Down
10 changes: 2 additions & 8 deletions src/mixer/basetrackplayer.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

class EngineMixer;
class ControlObject;
class ControlPotmeter;
class ControlProxy;
class ControlEncoder;
class EffectsManager;
Expand Down Expand Up @@ -144,10 +145,6 @@ class BaseTrackPlayerImpl : public BaseTrackPlayer {
/// Slot for change signals from up/down controls (relative values)
void slotTrackRatingChangeRequestRelative(int change);
void slotVinylControlEnabled(double v);
void slotWaveformZoomValueChangeRequest(double pressed);
void slotWaveformZoomUp(double pressed);
void slotWaveformZoomDown(double pressed);
void slotWaveformZoomSetDefault(double pressed);
void slotShiftCuesMillis(double milliseconds);
void slotShiftCuesMillisButton(double value, double milliseconds);
void slotUpdateReplayGainFromPregain(double pressed);
Expand Down Expand Up @@ -194,10 +191,7 @@ class BaseTrackPlayerImpl : public BaseTrackPlayer {
#endif

// Waveform display related controls
std::unique_ptr<ControlObject> m_pWaveformZoom;
std::unique_ptr<ControlPushButton> m_pWaveformZoomUp;
std::unique_ptr<ControlPushButton> m_pWaveformZoomDown;
std::unique_ptr<ControlPushButton> m_pWaveformZoomSetDefault;
std::unique_ptr<ControlPotmeter> m_pWaveformZoom;

parented_ptr<ControlProxy> m_pLoopInPoint;
parented_ptr<ControlProxy> m_pLoopOutPoint;
Expand Down
12 changes: 10 additions & 2 deletions src/preferences/dialog/dlgprefwaveform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@

#include <QMetaEnum>

#include "control/controlobject.h"
#include "control/controlpushbutton.h"
#include "library/dao/analysisdao.h"
#include "library/library.h"
#include "mixer/playermanager.h"
#include "moc_dlgprefwaveform.cpp"
#include "preferences/waveformsettings.h"
#include "util/db/dbconnectionpooled.h"
Expand Down Expand Up @@ -361,8 +363,8 @@ void DlgPrefWaveform::slotResetToDefaults() {
midVisualGain->setValue(1.0);
highVisualGain->setValue(1.0);

// Default zoom level is 3 in WaveformWidgetFactory.
defaultZoomComboBox->setCurrentIndex(3 + 1);
defaultZoomComboBox->setCurrentIndex(
static_cast<int>(WaveformWidgetRenderer::s_waveformDefaultZoom) - 1);

synchronizeZoomCheckBox->setChecked(true);

Expand Down Expand Up @@ -559,6 +561,12 @@ void DlgPrefWaveform::slotSetWaveformOverviewType() {

void DlgPrefWaveform::slotSetDefaultZoom(int index) {
WaveformWidgetFactory::instance()->setDefaultZoom(index + 1);
for (int i = 1; i <= PlayerManager::numDecks(); i++) {

Check failure on line 564 in src/preferences/dialog/dlgprefwaveform.cpp

View workflow job for this annotation

GitHub Actions / clazy

comparison of integers of different signs: 'int' and 'unsigned int' [-Werror,-Wsign-compare]

Check failure on line 564 in src/preferences/dialog/dlgprefwaveform.cpp

View workflow job for this annotation

GitHub Actions / Ubuntu 24.04

comparison of integer expressions of different signedness: ‘int’ and ‘unsigned int’ [-Werror=sign-compare]

Check failure on line 564 in src/preferences/dialog/dlgprefwaveform.cpp

View workflow job for this annotation

GitHub Actions / macOS 13 x64

comparison of integers of different signs: 'int' and 'unsigned int' [-Werror,-Wsign-compare]

Check failure on line 564 in src/preferences/dialog/dlgprefwaveform.cpp

View workflow job for this annotation

GitHub Actions / macOS 13 arm64

comparison of integers of different signs: 'int' and 'unsigned int' [-Werror,-Wsign-compare]

Check warning on line 564 in src/preferences/dialog/dlgprefwaveform.cpp

View workflow job for this annotation

GitHub Actions / coverage

comparison of integer expressions of different signedness: ‘int’ and ‘unsigned int’ [-Wsign-compare]

Check failure on line 564 in src/preferences/dialog/dlgprefwaveform.cpp

View workflow job for this annotation

GitHub Actions / Windows 2019 (MSVC)

the following warning is treated as an error

Check warning on line 564 in src/preferences/dialog/dlgprefwaveform.cpp

View workflow job for this annotation

GitHub Actions / Windows 2019 (MSVC)

'<=': signed/unsigned mismatch
ControlObject* pControl = ControlObject::getControl(
QStringLiteral("[Channel%1]").arg(i), QStringLiteral("waveform_zoom"));
DEBUG_ASSERT(pControl);
pControl->setDefaultValue(index + 1);
}
}

void DlgPrefWaveform::slotSetZoomSynchronization(bool checked) {
Expand Down

0 comments on commit f0542c0

Please sign in to comment.