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

also show time / beats since last marker #13828

Open
wants to merge 5 commits into
base: 2.5
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
70 changes: 45 additions & 25 deletions src/preferences/dialog/dlgprefwaveform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,10 @@ 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"));
// Populate distanceToMark options
distanceToMarkAlignComboBox->addItem(tr("Top"));
distanceToMarkAlignComboBox->addItem(tr("Center"));
distanceToMarkAlignComboBox->addItem(tr("Bottom"));

// The GUI is not fully setup so connecting signals before calling
// slotUpdate can generate rebootMixxxView calls.
Expand Down Expand Up @@ -163,6 +163,14 @@ DlgPrefWaveform::DlgPrefWaveform(
&QSlider::valueChanged,
this,
&DlgPrefWaveform::slotSetPlayMarkerPosition);
connect(sinceMarkShowBeatsCheckBox,
&QCheckBox::toggled,
this,
&DlgPrefWaveform::slotSetSinceMarkShowBeats);
connect(sinceMarkShowTimeCheckBox,
&QCheckBox::toggled,
this,
&DlgPrefWaveform::slotSetSinceMarkShowTime);
connect(untilMarkShowBeatsCheckBox,
&QCheckBox::toggled,
this,
Expand All @@ -171,14 +179,14 @@ DlgPrefWaveform::DlgPrefWaveform(
&QCheckBox::toggled,
this,
&DlgPrefWaveform::slotSetUntilMarkShowTime);
connect(untilMarkAlignComboBox,
connect(distanceToMarkAlignComboBox,
QOverload<int>::of(&QComboBox::currentIndexChanged),
this,
&DlgPrefWaveform::slotSetUntilMarkAlign);
connect(untilMarkTextPointSizeSpinBox,
&DlgPrefWaveform::slotSetDistanceToMarkAlign);
connect(distanceToMarkTextPointSizeSpinBox,
QOverload<int>::of(&QSpinBox::valueChanged),
this,
&DlgPrefWaveform::slotSetUntilMarkTextPointSize);
&DlgPrefWaveform::slotSetDistanceToMarkTextPointSize);

setScrollSafeGuardForAllInputWidgets(this);
}
Expand All @@ -201,7 +209,7 @@ void DlgPrefWaveform::slotUpdate() {
waveformTypeComboBox->setCurrentIndex(currentIndex);
}

updateEnableUntilMark();
updateEnableDistanceToMark();

frameRateSpinBox->setValue(factory->getFrameRate());
frameRateSlider->setValue(factory->getFrameRate());
Expand All @@ -219,12 +227,14 @@ void DlgPrefWaveform::slotUpdate() {
beatGridAlphaSpinBox->setValue(factory->getBeatGridAlpha());
beatGridAlphaSlider->setValue(factory->getBeatGridAlpha());

sinceMarkShowBeatsCheckBox->setChecked(factory->getSinceMarkShowBeats());
sinceMarkShowTimeCheckBox->setChecked(factory->getSinceMarkShowTime());
untilMarkShowBeatsCheckBox->setChecked(factory->getUntilMarkShowBeats());
untilMarkShowTimeCheckBox->setChecked(factory->getUntilMarkShowTime());
untilMarkAlignComboBox->setCurrentIndex(
WaveformWidgetFactory::toUntilMarkAlignIndex(
factory->getUntilMarkAlign()));
untilMarkTextPointSizeSpinBox->setValue(factory->getUntilMarkTextPointSize());
distanceToMarkAlignComboBox->setCurrentIndex(
WaveformWidgetFactory::toDistanceToMarkAlignIndex(
factory->getDistanceToMarkAlign()));
distanceToMarkTextPointSizeSpinBox->setValue(factory->getDistanceToMarkTextPointSize());

WOverview::Type cfgOverviewType =
m_pConfig->getValue<WOverview::Type>(kOverviewTypeCfgKey, WOverview::Type::RGB);
Expand Down Expand Up @@ -309,17 +319,19 @@ void DlgPrefWaveform::slotSetWaveformType(int index) {
int handleIndex = waveformTypeComboBox->itemData(index).toInt();
WaveformWidgetFactory::instance()->setWidgetTypeFromHandle(handleIndex);

updateEnableUntilMark();
updateEnableDistanceToMark();
}

void DlgPrefWaveform::updateEnableUntilMark() {
const bool enabled = WaveformWidgetFactory::instance()->widgetTypeSupportsUntilMark();
void DlgPrefWaveform::updateEnableDistanceToMark() {
const bool enabled = WaveformWidgetFactory::instance()->widgetTypeSupportsDistanceToMark();
sinceMarkShowBeatsCheckBox->setEnabled(enabled);
sinceMarkShowTimeCheckBox->setEnabled(enabled);
untilMarkShowBeatsCheckBox->setEnabled(enabled);
untilMarkShowTimeCheckBox->setEnabled(enabled);
untilMarkAlignLabel->setEnabled(enabled);
untilMarkAlignComboBox->setEnabled(enabled);
untilMarkTextPointSizeLabel->setEnabled(enabled);
untilMarkTextPointSizeSpinBox->setEnabled(enabled);
distanceToMarkAlignLabel->setEnabled(enabled);
distanceToMarkAlignComboBox->setEnabled(enabled);
distanceToMarkTextPointSizeLabel->setEnabled(enabled);
distanceToMarkTextPointSizeSpinBox->setEnabled(enabled);
requiresGLSLLabel->setVisible(!enabled);
}

Expand Down Expand Up @@ -387,6 +399,14 @@ void DlgPrefWaveform::slotSetPlayMarkerPosition(int position) {
WaveformWidgetFactory::instance()->setPlayMarkerPosition(position / 100.0);
}

void DlgPrefWaveform::slotSetSinceMarkShowBeats(bool checked) {
WaveformWidgetFactory::instance()->setSinceMarkShowBeats(checked);
}

void DlgPrefWaveform::slotSetSinceMarkShowTime(bool checked) {
WaveformWidgetFactory::instance()->setSinceMarkShowTime(checked);
}

void DlgPrefWaveform::slotSetUntilMarkShowBeats(bool checked) {
WaveformWidgetFactory::instance()->setUntilMarkShowBeats(checked);
}
Expand All @@ -395,13 +415,13 @@ void DlgPrefWaveform::slotSetUntilMarkShowTime(bool checked) {
WaveformWidgetFactory::instance()->setUntilMarkShowTime(checked);
}

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

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

void DlgPrefWaveform::calculateCachedWaveformDiskUsage() {
Expand Down
8 changes: 5 additions & 3 deletions src/preferences/dialog/dlgprefwaveform.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,16 +39,18 @@ class DlgPrefWaveform : public DlgPreferencePage, public Ui::DlgPrefWaveformDlg
void slotClearCachedWaveforms();
void slotSetBeatGridAlpha(int alpha);
void slotSetPlayMarkerPosition(int position);
void slotSetSinceMarkShowBeats(bool checked);
void slotSetSinceMarkShowTime(bool checked);
void slotSetUntilMarkShowBeats(bool checked);
void slotSetUntilMarkShowTime(bool checked);
void slotSetUntilMarkAlign(int index);
void slotSetUntilMarkTextPointSize(int value);
void slotSetDistanceToMarkAlign(int index);
void slotSetDistanceToMarkTextPointSize(int value);

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

std::unique_ptr<ControlPushButton> m_pTypeControl;

Expand Down
152 changes: 85 additions & 67 deletions src/preferences/dialog/dlgprefwaveformdlg.ui
Original file line number Diff line number Diff line change
Expand Up @@ -459,78 +459,96 @@ Select from different types of displays for the waveform, which differ primarily
</item>

<item row="11" column="0">
<widget class="QLabel" name="untilMarkLabel">
<widget class="QLabel" name="distanceToMarkLabel">
<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>
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
</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 row="11" column="1" colspan="3">
<layout class="QGridLayout" name="gridLayout_4">
<item row="0" column="0">
<widget class="QCheckBox" name="sinceMarkShowBeatsCheckBox">
<property name="text">
<string>Beats since previous marker</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QCheckBox" name="sinceMarkShowTimeCheckBox">
<property name="text">
<string>Time since previous marker</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QCheckBox" name="untilMarkShowBeatsCheckBox">
<property name="text">
<string>Beats until next marker</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QCheckBox" name="untilMarkShowTimeCheckBox">
<property name="text">
<string>Time until next marker</string>
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="QLabel" name="distanceToMarkAlignLabel">
<property name="text">
<string>Placement</string>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
</property>
<property name="buddy">
<cstring>distanceToMarkAlignComboBox</cstring>
</property>
</widget>
</item>
<item row="1" column="2">
<widget class="QComboBox" name="distanceToMarkAlignComboBox"/>
</item>
<item row="0" column="3">
<widget class="QLabel" name="distanceToMarkTextPointSizeLabel">
<property name="text">
<string>Font size</string>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
</property>
<property name="buddy">
<cstring>distanceToMarkTextPointSizeSpinBox</cstring>
</property>
</widget>
</item>
<item row="1" column="3">
<widget class="QSpinBox" name="distanceToMarkTextPointSizeSpinBox">
<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>
</layout>
</item>
<item row="14" column="1" colspan="2">
<item row="12" column="1" colspan="2">
<widget class="QLabel" name="requiresGLSLLabel">
<property name="text">
<string>This functionality requires a waveform type marked "(GLSL)".</string>
Expand All @@ -540,7 +558,7 @@ Select from different types of displays for the waveform, which differ primarily
</property>
</widget>
</item>
<item row="15" column="0">
<item row="13" column="0">
<widget class="QLabel" name="cachedWaveforms">
<property name="text">
<string>Caching</string>
Expand All @@ -550,7 +568,7 @@ Select from different types of displays for the waveform, which differ primarily
</property>
</widget>
</item>
<item row="15" column="1" colspan="3">
<item row="13" column="1" colspan="3">
<layout class="QGridLayout" name="cachingGridLayout">
<item row="4" column="0">
<widget class="QPushButton" name="clearCachedWaveforms">
Expand Down Expand Up @@ -602,7 +620,7 @@ Select from different types of displays for the waveform, which differ primarily
</layout>
</item>

<item row="17" column="0" colspan="4">
<item row="14" column="0" colspan="4">
<widget class="QGroupBox" name="openGLStatus">
<property name="title">
<string>OpenGL status</string>
Expand Down
14 changes: 14 additions & 0 deletions src/waveform/renderers/allshader/digitsrenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,20 @@ void allshader::DigitsRenderer::updateTexture(
m_texture.setData(image);
}

float allshader::DigitsRenderer::textWidth(const QString& s) const {
const float space = static_cast<float>(m_penWidth) / 2;
float x = 0;

for (QChar c : s) {
if (x != 0) {
x -= space;
}
int index = charToIndex(c);
x += m_width[index];
}
return x;
}

float allshader::DigitsRenderer::draw(const QMatrix4x4& matrix,
float x,
float y,
Expand Down
1 change: 1 addition & 0 deletions src/waveform/renderers/allshader/digitsrenderer.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ class allshader::DigitsRenderer : public QOpenGLFunctions {
float y,
const QString& s);
float height() const;
float textWidth(const QString& s) const;

private:
mixxx::TextureShader m_shader;
Expand Down
Loading
Loading