diff --git a/Source/Components/Label.cpp b/Source/Components/Label.cpp index 898407c..ff0484a 100644 --- a/Source/Components/Label.cpp +++ b/Source/Components/Label.cpp @@ -33,7 +33,12 @@ bool Label::keyPressed (const juce::KeyPress& key) { showEditor(); - juce::String keyChar{key.getTextCharacter()}; + const double valueAsDouble = value.getValue(); + + juce::String keyChar; + if (valueAsDouble < 0.0 && key.getTextCharacter() != '-') + keyChar << "-"; + keyChar << key.getTextCharacter(); getCurrentTextEditor()->setText (keyChar, false); @@ -46,12 +51,13 @@ bool Label::keyPressed (const juce::KeyPress& key) void Label::editorShown (juce::TextEditor* labelEditor) { - auto& textEditor = dynamic_cast (*labelEditor); - - textEditor.clearCharacters(); + const double valueAsDouble = value.getValue(); + const juce::String str(valueAsDouble, 2); - const juce::String str = textEditor.getText(); - textEditor.setHighlightedRegion ({str.contains ("-")? 1 : 0, str.length()}); + auto& editor = dynamic_cast (*labelEditor); + editor.clearCharacters(); + editor.setText(str); + editor.setHighlightedRegion ({str.contains ("-")? 1 : 0, str.length()}); } diff --git a/Source/Helpers/ParameterHelpers.h b/Source/Helpers/ParameterHelpers.h index e29cc3f..ed2c6c2 100755 --- a/Source/Helpers/ParameterHelpers.h +++ b/Source/Helpers/ParameterHelpers.h @@ -86,7 +86,13 @@ inline std::unique_ptr makePrmDb defaultValue, attributes .withLabel(label) - .withStringFromValueFunction([] (const float value, int) { return juce::String (value, 2) + " dB"; }) + .withStringFromValueFunction([] (float value, int) + { + // Not a fan of "-0.00 dB" + if (std::abs(value) < 0.005f) + value = 0.0f; + return juce::String (value, 2) + " dB"; + }) .withValueFromStringFunction([] (const juce::String& text) { return text.getFloatValue(); }) ); } diff --git a/cmake/pluginval.cmake b/cmake/pluginval.cmake index a361aca..e0bbc75 100644 --- a/cmake/pluginval.cmake +++ b/cmake/pluginval.cmake @@ -39,7 +39,7 @@ function(add_pluginval target) COMMAND ${PLUGINVAL_WRAPPER} "${PLUGINVAL_EXE}" --validate "$>" --strictness-level 5 - --timeout-ms 60000 + --timeout-ms 120000 DEPENDS "${PLUGINVAL_EXE}" ${target}_VST3 COMMENT "Running pluginval on ${target} VST3" )