Make LabeledProgressBar work on Mono #4255
Merged
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.
Problem
The new
LabeledProgressBar
s from #4249 don't display correctly on Mono; the underlying progress bar graphic is never rendered, and changing the text doesn't erase previous iterations of it, so they end up all piled up on top of one another over a plain background. It's unreadable and unusable.Cause
The strategy of adding a
Label
toProgressBar.Controls
was appealing because it allowed us to let text rendering be handled by code that's already an expert in it, but turning aLabel
transparent seems to rely too heavily on quirks of the specific Win32 graphics subsystems. Mono just does things a bit differently.Changes
TransparentLabel.cs
is deletedLabeledProgressBar
usesTextRenderer.DrawText
to draw its ownText
property inOnPaint
rather than delegating this duty to a containedLabel
. This is a bit simpler and makes it work on Mono.LabeledProgressBar
to further reduce any remaining flickering