Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

turn waveform_zoom into ControlPotmeter #12387

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
23 changes: 21 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 @@ -488,6 +490,7 @@ void DlgPrefWaveform::updateWaveformAcceleration(

useAccelerationCheckBox->blockSignals(false);
}

void DlgPrefWaveform::updateWaveformOption(bool useWaveform,
WaveformWidgetBackend backend,
allshader::WaveformRendererSignalBase::Options currentOptions) {
Expand Down Expand Up @@ -559,6 +562,22 @@ void DlgPrefWaveform::slotSetWaveformOverviewType() {

void DlgPrefWaveform::slotSetDefaultZoom(int index) {
WaveformWidgetFactory::instance()->setDefaultZoom(index + 1);
QStringList groups;
for (unsigned int i = 1; i <= PlayerManager::numDecks(); i++) {
groups.append(QStringLiteral("[Channel%1]").arg(i));
}
for (unsigned int i = 1; i <= PlayerManager::numSamplers(); i++) {
groups.append(QStringLiteral("[Sampler%1]").arg(i));
}
for (unsigned int i = 1; i <= PlayerManager::numPreviewDecks(); i++) {
groups.append(QStringLiteral("[PreviewDeck%1]").arg(i));
}
for (const QString& group : std::as_const(groups)) {
ControlObject* pControl = ControlObject::getControl(
group, QStringLiteral("waveform_zoom"));
DEBUG_ASSERT(pControl);
pControl->setDefaultValue(index + 1);
}
}

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