| 75 | } |
| 76 | |
| 77 | void FilterControl::paint(juce::Graphics& g) |
| 78 | { |
| 79 | if (isVisible()) |
| 80 | processor.setHistoryArray(5); // 5 means global |
| 81 | |
| 82 | bool isFilterEnabled = *processor.treeState.getRawParameterValue(FILTER_BYPASS_ID); |
| 83 | if (isFilterEnabled) |
| 84 | { |
| 85 | draggableLowButton.setState(true); |
| 86 | draggablePeakButton.setState(true); |
| 87 | draggableHighButton.setState(true); |
| 88 | |
| 89 | g.setColour(juce::Colours::hotpink.withBrightness(0.8f)); |
| 90 | g.strokePath(responseCurve, juce::PathStrokeType(2.0f)); |
| 91 | |
| 92 | g.setColour(juce::Colours::hotpink.withBrightness(0.8f).withAlpha(0.2f)); |
| 93 | g.fillPath(responseCurve); |
| 94 | |
| 95 | // Only draw LFO curve if animation is active |
| 96 | if (isAnimationActive) |
| 97 | { |
| 98 | g.setColour(juce::Colours::red.withAlpha(0.5f)); |
| 99 | g.strokePath(lfoResponseCurve, juce::PathStrokeType(1.0f)); |
| 100 | } |
| 101 | } |
| 102 | else |
| 103 | { |
| 104 | draggableLowButton.setState(false); |
| 105 | draggablePeakButton.setState(false); |
| 106 | draggableHighButton.setState(false); |
| 107 | |
| 108 | g.setColour(juce::Colours::dimgrey.withAlpha(0.8f)); |
| 109 | g.strokePath(responseCurve, juce::PathStrokeType(2.0f)); |
| 110 | |
| 111 | g.setColour(juce::Colours::dimgrey.withAlpha(0.8f).withAlpha(0.2f)); |
| 112 | g.fillPath(responseCurve); |
| 113 | } |
| 114 | |
| 115 | float size = getWidth() / 1000.0f * 15; |
| 116 | |
| 117 | // ======================== DRAG LOGIC & VALUE DISPLAY ======================== |
| 118 | bool isDragging = false; |
| 119 | double currentFreq = 0; |
| 120 | double currentGain = 0; |
| 121 | |
| 122 | auto mousePos = getMouseXYRelative(); |
| 123 | |
| 124 | // Clamp mouse position to stay within the component bounds for calculations |
| 125 | mousePos.x = juce::jlimit(0, getWidth(), mousePos.x); |
| 126 | mousePos.y = juce::jlimit(0, getHeight(), mousePos.y); |
| 127 | |
| 128 | float buttonX = mousePos.x - size / 2.0f; |
| 129 | float buttonY = mousePos.y - size / 2.0f; |
| 130 | |
| 131 | // A helper lambda to set parameter values directly in the processor state |
| 132 | auto setParameterValue = [&](const juce::String& paramID, float value) |
| 133 | { |
| 134 | if (auto* param = processor.treeState.getParameter(paramID)) |
nothing calls this directly
no test coverage detected