| 35 | } |
| 36 | |
| 37 | void SpectrumBackground::paint(juce::Graphics& g) |
| 38 | { |
| 39 | // 1. Get the real physical scale factor for this paint cycle |
| 40 | const float currentDisplayScale = g.getInternalContext().getPhysicalPixelScaleFactor(); |
| 41 | |
| 42 | // 2. Check if the scale has changed (or if it's the first time painting) |
| 43 | if (currentDisplayScale != lastDisplayScale) |
| 44 | { |
| 45 | // If it changed, update our stored value and regenerate the background image |
| 46 | lastDisplayScale = currentDisplayScale; |
| 47 | createBackgroundImage(); |
| 48 | |
| 49 | // Return immediately. The regeneration will trigger a new paint call. |
| 50 | return; |
| 51 | } |
| 52 | // 3. If scale is unchanged, just draw the pre-rendered cache. |
| 53 | g.drawImage(cachedBackground, getLocalBounds().toFloat()); |
| 54 | } |
| 55 | |
| 56 | void SpectrumBackground::resized() |
| 57 | { |
nothing calls this directly
no outgoing calls
no test coverage detected