Apply new waveform colors without restarting SE (#13897) - #13898
Merged
Conversation
The fancy draw style batches waveform columns by a quantized amplitude bucket and caches a pen per bucket. The bucket key carries no color, so the pen/gradient/glow caches - and the pooled _fancyBatches dictionary, which holds a pen of its own - keep painting in whatever color was current when the bucket was first seen. ResetCache() cleared the three pen caches but not the batches, so Settings -> OK rebuilt the waveform geometry and then stroked it with the stale batch pens: waveform color, selected color and fancy high color only showed up after a restart, while every other waveform color (background, cursor, shot change, paragraph left/right, text) updated at once because those build a fresh brush in their setter. Clear all of them together in ResetFancyColorCaches(), call it from ResetCache() and from the three color setters, and invalidate the visual there - the color properties are not AffectsRender, so nothing else asks for the repaint. Fixes #13897 Co-Authored-By: Claude Opus 5 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #13897 — changing the waveform color or the selected waveform color only took effect after restarting SE, while every other waveform color changed instantly.
Root cause
The fancy draw style (the default) batches waveform columns by a quantized amplitude bucket and caches a pen per bucket. The bucket key carries no color at all, so:
_fancyWaveformPenCache/_fancyWaveformGradientCache/_fancyWaveformGlowPenCachehold pens painted in whatever color was current when that bucket was first drawn, and_fancyBatches— the pooled batch dictionary, which keeps aPenof its own — does too.ResetCache()cleared the three pen caches but not_fancyBatches. SoSettings -> OKdid everything right (pushed the new colors, reset the caches, and the geometry cache key does include the colors), the geometry was rebuilt — and then stroked with the stale batch pens. Only a brand-new control, i.e. a restart, dropped them.That is exactly the split reported: waveform color, selected color (and fancy high color, which the reporter probably did not try) are the only three that go through the fancy batch/pen cache. Background, cursor, shot change, paragraph left/right and text build a fresh brush in their setter and are drawn live, so they always updated at once. The classic draw style was never affected either — it uses
_paintWaveform/_paintPenSelected, rebuilt in the setters.Fix
ResetFancyColorCaches()clears all four color-bearing caches together, and invalidates the visual (the color properties are notAffectsRender, so nothing else asked for the repaint).ResetCache()and from theWaveformColor/WaveformSelectedColor/WaveformFancyHighColorsetters, so no caller has to remember to reset anything.WaveformFancyHighColorwas a plain auto-property with no invalidation at all.Tests
tests/UI/Controls/AudioVisualizerColorTests.csrenders a fancy waveform, changes a color, re-renders, and asserts the cached draw pens no longer carry the old color — for the waveform color (with and without an explicitResetCache()), the selected color, and the fancy high color.All 4 fail on
mainand pass with the fix; the full UI suite (3246 tests) passes.