Skip to content

Commit

Permalink
Merge pull request mixxxdj#12994 from m0dB/beats-until-marker
Browse files Browse the repository at this point in the history
show beats and time until next marker
  • Loading branch information
daschuer authored May 6, 2024
2 parents d824a20 + 362ace2 commit e32b1ed
Show file tree
Hide file tree
Showing 13 changed files with 843 additions and 71 deletions.
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1511,6 +1511,7 @@ if(QOPENGL)
src/shaders/unicolorshader.cpp
src/shaders/vinylqualityshader.cpp
src/util/opengltexture2d.cpp
src/waveform/renderers/allshader/digitsrenderer.cpp
src/waveform/renderers/allshader/matrixforwidgetgeometry.cpp
src/waveform/renderers/allshader/waveformrenderbackground.cpp
src/waveform/renderers/allshader/waveformrenderbeat.cpp
Expand Down
60 changes: 60 additions & 0 deletions src/preferences/dialog/dlgprefwaveform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,11 @@ DlgPrefWaveform::DlgPrefWaveform(
defaultZoomComboBox->addItem(QString::number(100 / static_cast<double>(i), 'f', 1) + " %");
}

// Populate untilMark options
untilMarkAlignComboBox->addItem(tr("Top"));
untilMarkAlignComboBox->addItem(tr("Center"));
untilMarkAlignComboBox->addItem(tr("Bottom"));

// The GUI is not fully setup so connecting signals before calling
// slotUpdate can generate rebootMixxxView calls.
// TODO(XXX): Improve this awkwardness.
Expand Down Expand Up @@ -131,6 +136,22 @@ DlgPrefWaveform::DlgPrefWaveform(
&QSlider::valueChanged,
this,
&DlgPrefWaveform::slotSetPlayMarkerPosition);
connect(untilMarkShowBeatsCheckBox,
&QCheckBox::toggled,
this,
&DlgPrefWaveform::slotSetUntilMarkShowBeats);
connect(untilMarkShowTimeCheckBox,
&QCheckBox::toggled,
this,
&DlgPrefWaveform::slotSetUntilMarkShowTime);
connect(untilMarkAlignComboBox,
QOverload<int>::of(&QComboBox::currentIndexChanged),
this,
&DlgPrefWaveform::slotSetUntilMarkAlign);
connect(untilMarkTextPointSizeSpinBox,
QOverload<int>::of(&QSpinBox::valueChanged),
this,
&DlgPrefWaveform::slotSetUntilMarkTextPointSize);

setScrollSafeGuardForAllInputWidgets(this);
}
Expand All @@ -153,6 +174,8 @@ void DlgPrefWaveform::slotUpdate() {
waveformTypeComboBox->setCurrentIndex(currentIndex);
}

updateEnableUntilMark();

frameRateSpinBox->setValue(factory->getFrameRate());
frameRateSlider->setValue(factory->getFrameRate());
endOfTrackWarningTimeSpinBox->setValue(factory->getEndOfTrackWarningTime());
Expand All @@ -169,6 +192,13 @@ void DlgPrefWaveform::slotUpdate() {
beatGridAlphaSpinBox->setValue(factory->getBeatGridAlpha());
beatGridAlphaSlider->setValue(factory->getBeatGridAlpha());

untilMarkShowBeatsCheckBox->setChecked(factory->getUntilMarkShowBeats());
untilMarkShowTimeCheckBox->setChecked(factory->getUntilMarkShowTime());
untilMarkAlignComboBox->setCurrentIndex(
WaveformWidgetFactory::toUntilMarkAlignIndex(
factory->getUntilMarkAlign()));
untilMarkTextPointSizeSpinBox->setValue(factory->getUntilMarkTextPointSize());

// By default we set RGB woverview = "2"
int overviewType = m_pConfig->getValue(
ConfigKey("[Waveform]","WaveformOverviewType"), 2);
Expand Down Expand Up @@ -252,6 +282,19 @@ void DlgPrefWaveform::slotSetWaveformType(int index) {
}
int handleIndex = waveformTypeComboBox->itemData(index).toInt();
WaveformWidgetFactory::instance()->setWidgetTypeFromHandle(handleIndex);

updateEnableUntilMark();
}

void DlgPrefWaveform::updateEnableUntilMark() {
const bool enabled = WaveformWidgetFactory::instance()->widgetTypeSupportsUntilMark();
untilMarkShowBeatsCheckBox->setEnabled(enabled);
untilMarkShowTimeCheckBox->setEnabled(enabled);
untilMarkAlignLabel->setEnabled(enabled);
untilMarkAlignComboBox->setEnabled(enabled);
untilMarkTextPointSizeLabel->setEnabled(enabled);
untilMarkTextPointSizeSpinBox->setEnabled(enabled);
requiresGLSLLabel->setVisible(!enabled);
}

void DlgPrefWaveform::slotSetWaveformOverviewType(int index) {
Expand Down Expand Up @@ -312,6 +355,23 @@ void DlgPrefWaveform::slotSetPlayMarkerPosition(int position) {
WaveformWidgetFactory::instance()->setPlayMarkerPosition(position / 100.0);
}

void DlgPrefWaveform::slotSetUntilMarkShowBeats(bool checked) {
WaveformWidgetFactory::instance()->setUntilMarkShowBeats(checked);
}

void DlgPrefWaveform::slotSetUntilMarkShowTime(bool checked) {
WaveformWidgetFactory::instance()->setUntilMarkShowTime(checked);
}

void DlgPrefWaveform::slotSetUntilMarkAlign(int index) {
WaveformWidgetFactory::instance()->setUntilMarkAlign(
WaveformWidgetFactory::toUntilMarkAlign(index));
}

void DlgPrefWaveform::slotSetUntilMarkTextPointSize(int value) {
WaveformWidgetFactory::instance()->setUntilMarkTextPointSize(value);
}

void DlgPrefWaveform::calculateCachedWaveformDiskUsage() {
AnalysisDao analysisDao(m_pConfig);
QSqlDatabase dbConnection = mixxx::DbConnectionPooled(m_pLibrary->dbConnectionPool());
Expand Down
6 changes: 5 additions & 1 deletion src/preferences/dialog/dlgprefwaveform.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,18 @@ class DlgPrefWaveform : public DlgPreferencePage, public Ui::DlgPrefWaveformDlg
void slotClearCachedWaveforms();
void slotSetBeatGridAlpha(int alpha);
void slotSetPlayMarkerPosition(int position);

void slotSetUntilMarkShowBeats(bool checked);
void slotSetUntilMarkShowTime(bool checked);
void slotSetUntilMarkAlign(int index);
void slotSetUntilMarkTextPointSize(int value);
signals:
void reloadUserInterface();

private:
void initWaveformControl();
void calculateCachedWaveformDiskUsage();
void notifyRebootNecessary();
void updateEnableUntilMark();

UserSettingsPointer m_pConfig;
std::shared_ptr<Library> m_pLibrary;
Expand Down
86 changes: 84 additions & 2 deletions src/preferences/dialog/dlgprefwaveformdlg.ui
Original file line number Diff line number Diff line change
Expand Up @@ -459,6 +459,88 @@ Select from different types of displays for the waveform, which differ primarily
</item>

<item row="11" column="0">
<widget class="QLabel" name="untilMarkLabel">
<property name="text">
<string>Play marker hints</string>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="11" column="1">
<widget class="QCheckBox" name="untilMarkShowBeatsCheckBox">
<property name="text">
<string>Beats until next marker</string>
</property>
</widget>
</item>
<item row="12" column="1">
<widget class="QCheckBox" name="untilMarkShowTimeCheckBox">
<property name="text">
<string>Time until next marker</string>
</property>
</widget>
</item>
<item row="11" column="2">
<widget class="QLabel" name="untilMarkAlignLabel">
<property name="text">
<string>Placement</string>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
</property>
<property name="buddy">
<cstring>untilMarkAlignComboBox</cstring>
</property>
</widget>
</item>
<item row="12" column="2">
<widget class="QComboBox" name="untilMarkAlignComboBox"/>
</item>
<item row="11" column="3">
<widget class="QLabel" name="untilMarkTextPointSizeLabel">
<property name="text">
<string>Font size</string>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
</property>
<property name="buddy">
<cstring>untilMarkTextPointSizeSpinBox</cstring>
</property>
</widget>
</item>
<item row="12" column="3">
<widget class="QSpinBox" name="untilMarkTextPointSizeSpinBox">
<property name="toolTip">
<string/>
</property>
<property name="suffix">
<string> pt</string>
</property>
<property name="minimum">
<number>10</number>
</property>
<property name="maximum">
<number>50</number>
</property>
<property name="value">
<number>30</number>
</property>
</widget>
</item>
<item row="14" column="1" colspan="2">
<widget class="QLabel" name="requiresGLSLLabel">
<property name="text">
<string>This functionality requires a waveform type marked "(GLSL)".</string>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="15" column="0">
<widget class="QLabel" name="cachedWaveforms">
<property name="text">
<string>Caching</string>
Expand All @@ -468,7 +550,7 @@ Select from different types of displays for the waveform, which differ primarily
</property>
</widget>
</item>
<item row="11" column="1" colspan="3">
<item row="15" column="1" colspan="3">
<layout class="QGridLayout" name="cachingGridLayout">
<item row="4" column="0">
<widget class="QPushButton" name="clearCachedWaveforms">
Expand Down Expand Up @@ -520,7 +602,7 @@ Select from different types of displays for the waveform, which differ primarily
</layout>
</item>

<item row="13" column="0" colspan="4">
<item row="17" column="0" colspan="4">
<widget class="QGroupBox" name="openGLStatus">
<property name="title">
<string>OpenGL status</string>
Expand Down
Loading

0 comments on commit e32b1ed

Please sign in to comment.