Skip to content

Commit 956a435

Browse files
author
Milkii Brewster
committed
Add control for playback marker horizontal position
Implements control for adjusting the horizontal position of the playback marker/line over waveforms. - Adds [Waveform],PlayMarkerPosition control (0.0 = left, 1.0 = right) - Creates ControlPotmeter for smooth value adjustment - Exposes control in controller picker menu for MIDI/HID mapping - Adds tooltip for the control - Preserves existing playback marker position functionality Fixes #14288
1 parent 26f9d32 commit 956a435

4 files changed

Lines changed: 31 additions & 0 deletions

File tree

src/controllers/controlpickermenu.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1563,6 +1563,11 @@ ControlPickerMenu::ControlPickerMenu(QWidget* pParent)
15631563
tr("Reset the waveform zoom level to the default value selected in "
15641564
"Preferences -> Waveforms"),
15651565
pGuiMenu);
1566+
addControl("[Waveform]",
1567+
"play_marker_position",
1568+
tr("Playback Marker Position"),
1569+
tr("Adjust the position of the playback marker on the waveforms"),
1570+
pGuiMenu);
15661571

15671572
pGuiMenu->addSeparator();
15681573

src/skin/legacy/tooltips.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,10 @@ void Tooltips::addStandardTooltips() {
7373
<< tr("Waveform Zoom")
7474
<< QString("%1").arg(resetToDefault);
7575

76+
add("[Waveform],play_marker_position")
77+
<< tr("Playback Marker Position")
78+
<< tr("Adjust the position of the playback marker on the waveforms.");
79+
7680
add("spinny")
7781
<< tr("Spinning Vinyl")
7882
<< tr("Rotates during playback and shows the position of a track.")

src/waveform/waveformwidgetfactory.cpp

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#include "waveform/waveformwidgetfactory.h"
22

3+
#include "control/controlpotmeter.h"
34
#include "waveform/renderers/waveformrendererabstract.h"
45
#include "waveform/waveform.h"
56

@@ -436,6 +437,21 @@ bool WaveformWidgetFactory::setConfig(UserSettingsPointer config) {
436437
WaveformWidgetRenderer::s_defaultPlayMarkerPosition);
437438
setPlayMarkerPosition(m_playMarkerPosition);
438439

440+
// Create control for playback marker position (0.0 = left, 1.0 = right)
441+
if (!m_pPlayMarkerPositionCO) {
442+
m_pPlayMarkerPositionCO = std::make_unique<ControlPotmeter>(
443+
ConfigKey(kWaveformGroup, QStringLiteral("play_marker_position")),
444+
0.0,
445+
1.0);
446+
connect(m_pPlayMarkerPositionCO.get(),
447+
&ControlObject::valueChanged,
448+
this,
449+
[this](double value) {
450+
setPlayMarkerPosition(value);
451+
});
452+
}
453+
m_pPlayMarkerPositionCO->set(m_playMarkerPosition);
454+
439455
int untilMarkShowBeats =
440456
m_config->getValueString(
441457
ConfigKey(kWaveformGroup, QStringLiteral("UntilMarkShowBeats")))
@@ -794,6 +810,9 @@ void WaveformWidgetFactory::setPlayMarkerPosition(double position) {
794810
m_config->setValue(ConfigKey(kWaveformGroup, QStringLiteral("PlayMarkerPosition")),
795811
m_playMarkerPosition);
796812
}
813+
if (m_pPlayMarkerPositionCO) {
814+
m_pPlayMarkerPositionCO->set(m_playMarkerPosition);
815+
}
797816

798817
for (const auto& holder : std::as_const(m_waveformWidgetHolders)) {
799818
holder.m_waveformWidget->setPlayMarkerPosition(m_playMarkerPosition);

src/waveform/waveformwidgetfactory.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
#include <QObject>
44
#include <QSurfaceFormat>
55
#include <QVector>
6+
#include <memory>
67
#include <vector>
78

89
#include "preferences/usersettings.h"
@@ -20,6 +21,7 @@ class WWaveformViewer;
2021
class WaveformWidgetAbstract;
2122
class VSyncThread;
2223
class GuiTick;
24+
class ControlPotmeter;
2325
class VisualsManager;
2426

2527
class WaveformWidgetAbstractHandle {
@@ -368,4 +370,5 @@ class WaveformWidgetFactory : public QObject,
368370
double m_actualFrameRate;
369371
int m_vSyncType;
370372
double m_playMarkerPosition;
373+
std::unique_ptr<ControlPotmeter> m_pPlayMarkerPositionCO;
371374
};

0 commit comments

Comments
 (0)