Fix DisplayProgressBar horizontal bar filling wrong side (fixes #982)#984
Merged
mathoudebine merged 1 commit intomathoudebine:mainfrom Apr 15, 2026
Conversation
The refactor in db59686 ("refactor code, inverse now a graph setting") introduced shared x1/y1/x2/y2 defaults and assigned the wrong coordinate in the horizontal non-reverse branch: x1 was set to bar_filled_width instead of x2, which caused the bar to render the empty portion in BAR_COLOR and the filled portion in BACKGROUND_COLOR. Pre-refactor code drew [0, 0, bar_filled_width, height - 1] — i.e. x2 was the variable, not x1. Restoring that behavior fixes the inversion while leaving the reverse_direction and vertical branches unchanged (those were already correct after the refactor). Fixes mathoudebine#982
There was a problem hiding this comment.
Pull request overview
Fixes a regression in DisplayProgressBar() where horizontal (width > height), non-reversed progress bars were drawing the empty portion with BAR_COLOR instead of the filled portion, restoring pre-refactor fill behavior.
Changes:
- Correct the horizontal non-reverse branch to set
x2(filled end) rather thanx1(filled start).
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| @@ -378,7 +378,7 @@ def DisplayProgressBar(self, x: int, y: int, width: int, height: int, min_value: | |||
| if reverse_direction is True: | |||
| x1 = width - bar_filled_width | |||
Owner
|
Thank you for the PR! I also needed to add a hotfix because the vertical bars were not drawing the expected state e.g. for 25% the bar was displaying 75%. Everything is now on the main branch |
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.
Summary
Fixes #982 — horizontal progress bars rendered the empty portion in
BAR_COLORinstead of the filled portion.Root cause
In commit
db59686("refactor code, inverse now a graph setting"),DisplayProgressBar()was refactored to use sharedx1/y1/x2/y2defaults (x1=0, y1=0, x2=width-1, y2=height-1) and assign one coordinate per branch. The horizontal non-reverse branch assigned the wrong one:Pre-refactor code drew
rectangle([0, 0, bar_filled_width, height - 1], fill=bar_color)— i.e.x2was the variable being assigned, notx1.Fix
One-line change: assign
x2 = bar_filled_widthinstead ofx1. The vertical branches and thereverse_direction=Truehorizontal branch were already correct after the refactor and are unchanged.Testing
Verified on a UsbMonitor 3.5" (Revision A) with the DragonBall theme — horizontal CPU/DISK/GPU bars now fill from the left as expected, matching pre-refactor behavior.