ProgressBar: fixed visual artifacts in indeterminate mode, on HiDPI screens at 125%, 150% and 175% scaling, when the progress moves around

This commit is contained in:
Karl Tauber
2020-01-23 10:33:01 +01:00
parent 5a29753912
commit 0910bd23c4
2 changed files with 21 additions and 0 deletions

View File

@@ -1,6 +1,12 @@
FlatLaf Change Log
==================
## Unreleased
- ProgressBar: Fixed visual artifacts in indeterminate mode, on HiDPI screens at
125%, 150% and 175% scaling, when the progress moves around.
## 0.26
- Menus:

View File

@@ -193,4 +193,19 @@ public class FlatProgressBarUI
paintString( g, x, y, width, height, amountFull, insets );
}
}
@Override
protected void setAnimationIndex( int newValue ) {
super.setAnimationIndex( newValue );
// On HiDPI screens at 125%, 150% and 175% scaling, it occurs that antialiased painting
// may paint one pixel outside of the clipping area. This results in visual artifacts
// in indeterminate mode when the progress moves around.
// Unfortunately it is not safe to invoke getBox() from here (may throw NPE),
// which makes it impractical to get progress box and repaint increased box.
// Only solution is to repaint whole progress bar.
double systemScaleFactor = UIScale.getSystemScaleFactor( progressBar.getGraphicsConfiguration() );
if( (int) systemScaleFactor != systemScaleFactor )
progressBar.repaint();
}
}