diff --git a/src/preferences/dialog/dlgprefwaveform.cpp b/src/preferences/dialog/dlgprefwaveform.cpp index de65ffc9cfd..9f26e28987d 100644 --- a/src/preferences/dialog/dlgprefwaveform.cpp +++ b/src/preferences/dialog/dlgprefwaveform.cpp @@ -73,6 +73,9 @@ DlgPrefWaveform::DlgPrefWaveform( untilMarkAlignComboBox->addItem(tr("Center")); untilMarkAlignComboBox->addItem(tr("Bottom")); + untilMarkTextHeightLimitComboBox->addItem(tr("1/3rd of waveform viewer")); + untilMarkTextHeightLimitComboBox->addItem(tr("Full waveform viewer height")); + // The GUI is not fully setup so connecting signals before calling // slotUpdate can generate rebootMixxxView calls. // TODO(XXX): Improve this awkwardness. @@ -179,6 +182,10 @@ DlgPrefWaveform::DlgPrefWaveform( QOverload::of(&QSpinBox::valueChanged), this, &DlgPrefWaveform::slotSetUntilMarkTextPointSize); + connect(untilMarkTextHeightLimitComboBox, + QOverload::of(&QComboBox::currentIndexChanged), + this, + &DlgPrefWaveform::slotSetUntilMarkTextHeightLimit); setScrollSafeGuardForAllInputWidgets(this); } @@ -225,6 +232,9 @@ void DlgPrefWaveform::slotUpdate() { WaveformWidgetFactory::toUntilMarkAlignIndex( factory->getUntilMarkAlign())); untilMarkTextPointSizeSpinBox->setValue(factory->getUntilMarkTextPointSize()); + untilMarkTextHeightLimitComboBox->setCurrentIndex( + WaveformWidgetFactory::toUntilMarkTextHeightLimitIndex( + factory->getUntilMarkTextHeightLimit())); WOverview::Type cfgOverviewType = m_pConfig->getValue(kOverviewTypeCfgKey, WOverview::Type::RGB); @@ -320,6 +330,7 @@ void DlgPrefWaveform::updateEnableUntilMark() { untilMarkAlignComboBox->setEnabled(enabled); untilMarkTextPointSizeLabel->setEnabled(enabled); untilMarkTextPointSizeSpinBox->setEnabled(enabled); + untilMarkTextHeightLimitComboBox->setEnabled(enabled); requiresGLSLLabel->setVisible(!enabled); } @@ -404,6 +415,11 @@ void DlgPrefWaveform::slotSetUntilMarkTextPointSize(int value) { WaveformWidgetFactory::instance()->setUntilMarkTextPointSize(value); } +void DlgPrefWaveform::slotSetUntilMarkTextHeightLimit(int index) { + WaveformWidgetFactory::instance()->setUntilMarkTextHeightLimit( + WaveformWidgetFactory::toUntilMarkTextHeightLimit(index)); +} + void DlgPrefWaveform::calculateCachedWaveformDiskUsage() { AnalysisDao analysisDao(m_pConfig); QSqlDatabase dbConnection = mixxx::DbConnectionPooled(m_pLibrary->dbConnectionPool()); diff --git a/src/preferences/dialog/dlgprefwaveform.h b/src/preferences/dialog/dlgprefwaveform.h index 931b8b4639e..7d0c23e47e3 100644 --- a/src/preferences/dialog/dlgprefwaveform.h +++ b/src/preferences/dialog/dlgprefwaveform.h @@ -43,6 +43,7 @@ class DlgPrefWaveform : public DlgPreferencePage, public Ui::DlgPrefWaveformDlg void slotSetUntilMarkShowTime(bool checked); void slotSetUntilMarkAlign(int index); void slotSetUntilMarkTextPointSize(int value); + void slotSetUntilMarkTextHeightLimit(int index); private: void initWaveformControl(); diff --git a/src/preferences/dialog/dlgprefwaveformdlg.ui b/src/preferences/dialog/dlgprefwaveformdlg.ui index 6c42b4bf020..2a98c17e307 100644 --- a/src/preferences/dialog/dlgprefwaveformdlg.ui +++ b/src/preferences/dialog/dlgprefwaveformdlg.ui @@ -468,67 +468,87 @@ Select from different types of displays for the waveform, which differ primarily - - - - Beats until next marker - - - - - - - Time until next marker - - - - - - - Placement - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - - - untilMarkAlignComboBox - - - - - - - - - - Font size - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - - - untilMarkTextPointSizeSpinBox - - - - - - - - - - pt - - - 10 - - - 50 - - - 30 - - + + + + + + Beats until next marker + + + + + + + Placement + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + + + untilMarkAlignComboBox + + + + + + + Preferred font size + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + + + untilMarkTextPointSizeSpinBox + + + + + + + Text height limit + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + + + untilMarkTextHeightLimitComboBox + + + + + + + Time until next marker + + + + + + + + + + + + + pt + + + 10 + + + 100 + + + 30 + + + + + + + diff --git a/src/waveform/renderers/allshader/waveformrendermark.cpp b/src/waveform/renderers/allshader/waveformrendermark.cpp index a6468920071..a60d668ab97 100644 --- a/src/waveform/renderers/allshader/waveformrendermark.cpp +++ b/src/waveform/renderers/allshader/waveformrendermark.cpp @@ -85,8 +85,14 @@ void allshader::WaveformRenderMark::initializeGL() { updatePlayPosMarkTexture(); const auto untilMarkTextPointSize = WaveformWidgetFactory::instance()->getUntilMarkTextPointSize(); + const auto untilMarkTextHeightLimit = + WaveformWidgetFactory::instance() + ->getUntilMarkTextHeightLimit(); // proportion of waveform + // height + const auto untilMarkMaxHeightForText = getMaxHeightForText(untilMarkTextHeightLimit); + m_digitsRenderer.updateTexture(untilMarkTextPointSize, - getMaxHeightForText(), + untilMarkMaxHeightForText, m_waveformRenderer->getDevicePixelRatio()); } @@ -319,8 +325,14 @@ void allshader::WaveformRenderMark::drawUntilMark(const QMatrix4x4& matrix, floa const auto untilMarkTextPointSize = WaveformWidgetFactory::instance()->getUntilMarkTextPointSize(); + const auto untilMarkTextHeightLimit = + WaveformWidgetFactory::instance() + ->getUntilMarkTextHeightLimit(); // proportion of waveform + // height + const auto untilMarkMaxHeightForText = getMaxHeightForText(untilMarkTextHeightLimit); + m_digitsRenderer.updateTexture(untilMarkTextPointSize, - getMaxHeightForText(), + untilMarkMaxHeightForText, m_waveformRenderer->getDevicePixelRatio()); if (m_timeUntilMark == 0.0) { @@ -333,7 +345,8 @@ void allshader::WaveformRenderMark::drawUntilMark(const QMatrix4x4& matrix, floa ? m_waveformRenderer->getBreadth() - ch : m_waveformRenderer->getBreadth() / 2.f; - bool multiLine = untilMarkShowBeats && untilMarkShowTime && ch * 2.f < getMaxHeightForText(); + bool multiLine = untilMarkShowBeats && untilMarkShowTime && + ch * 2.f < untilMarkMaxHeightForText; if (multiLine) { if (untilMarkAlign != Qt::AlignTop) { @@ -513,6 +526,6 @@ void allshader::WaveformRenderMark::updateUntilMark( (endPosition - playPosition)); } -float allshader::WaveformRenderMark::getMaxHeightForText() const { - return m_waveformRenderer->getBreadth() / 3; +float allshader::WaveformRenderMark::getMaxHeightForText(float proportion) const { + return std::roundf(m_waveformRenderer->getBreadth() * proportion); } diff --git a/src/waveform/renderers/allshader/waveformrendermark.h b/src/waveform/renderers/allshader/waveformrendermark.h index 317f132e26d..0937cfbbfa1 100644 --- a/src/waveform/renderers/allshader/waveformrendermark.h +++ b/src/waveform/renderers/allshader/waveformrendermark.h @@ -54,7 +54,7 @@ class allshader::WaveformRenderMark : public ::WaveformRenderMarkBase, void drawTexture(const QMatrix4x4& matrix, float x, float y, QOpenGLTexture* texture); void updateUntilMark(double playPosition, double markerPosition); void drawUntilMark(const QMatrix4x4& matrix, float x); - float getMaxHeightForText() const; + float getMaxHeightForText(float proportion) const; mixxx::RGBAShader m_rgbaShader; mixxx::TextureShader m_textureShader; diff --git a/src/waveform/waveformwidgetfactory.cpp b/src/waveform/waveformwidgetfactory.cpp index bb63c331dff..003c264587f 100644 --- a/src/waveform/waveformwidgetfactory.cpp +++ b/src/waveform/waveformwidgetfactory.cpp @@ -139,6 +139,7 @@ WaveformWidgetFactory::WaveformWidgetFactory() m_untilMarkShowTime(false), m_untilMarkAlign(Qt::AlignVCenter), m_untilMarkTextPointSize(24), + m_untilMarkTextHeightLimit(toUntilMarkTextHeightLimit(0)), m_openGlAvailable(false), m_openGlesAvailable(false), m_openGLShaderAvailable(false), @@ -458,6 +459,9 @@ bool WaveformWidgetFactory::setConfig(UserSettingsPointer config) { setUntilMarkTextPointSize( m_config->getValue(ConfigKey("[Waveform]", "UntilMarkTextPointSize"), m_untilMarkTextPointSize)); + setUntilMarkTextHeightLimit(toUntilMarkTextHeightLimit( + m_config->getValue(ConfigKey("[Waveform]", "UntilMarkTextHeightLimit"), + toUntilMarkTextHeightLimitIndex(m_untilMarkTextHeightLimit)))); return true; } @@ -1410,6 +1414,14 @@ void WaveformWidgetFactory::setUntilMarkTextPointSize(int value) { } } +void WaveformWidgetFactory::setUntilMarkTextHeightLimit(float value) { + m_untilMarkTextHeightLimit = value; + if (m_config) { + m_config->setValue(ConfigKey("[Waveform]", "UntilMarkTextHeightLimit"), + toUntilMarkTextHeightLimitIndex(m_untilMarkTextHeightLimit)); + } +} + // static Qt::Alignment WaveformWidgetFactory::toUntilMarkAlign(int index) { switch (index) { @@ -1438,3 +1450,25 @@ int WaveformWidgetFactory::toUntilMarkAlignIndex(Qt::Alignment align) { assert(false); return 1; } +// static +float WaveformWidgetFactory::toUntilMarkTextHeightLimit(int index) { + switch (index) { + case 0: + return 0.333f; + case 1: + return 1.f; + } + assert(false); + return 0.33f; +} +// static +int WaveformWidgetFactory::toUntilMarkTextHeightLimitIndex(float value) { + if (value == 0.333f) { + return 0; + } + if (value == 1.f) { + return 1; + } + assert(false); + return 0; +} diff --git a/src/waveform/waveformwidgetfactory.h b/src/waveform/waveformwidgetfactory.h index f57cd305be6..349669ad1be 100644 --- a/src/waveform/waveformwidgetfactory.h +++ b/src/waveform/waveformwidgetfactory.h @@ -102,6 +102,7 @@ class WaveformWidgetFactory : public QObject, public Singleton