Skip to content

Commit

Permalink
Properly set phrase clipping region, fixes #62
Browse files Browse the repository at this point in the history
  • Loading branch information
brunchboy committed Oct 8, 2023
1 parent 93ce5ae commit 68be52f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ This change log follows the conventions of
- The code that detects pre-nexus CDJs was confused by the CDJ-3000.
- Sometimes beat packets can come after a status packet at the very beginning of a
new beat, and this used to cause the beat number to jump up and back down.
- The clipping region was not being set correctly when painting phrase information
at the bottom of the waveform detail component, which could cause the fill dots
to extend beyond the edge of the component in certain circumstances.

### Changed

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1123,12 +1123,13 @@ private void paintPhrases(Graphics g, Rectangle clipRect, RekordboxAnlz.SongStru
FontRenderContext renderContext = g2.getFontRenderContext();
LineMetrics metrics = g2.getFont().getLineMetrics(label, renderContext);
int textHeight = (int)Math.ceil(metrics.getAscent() + metrics.getDescent());
Rectangle2D phraseRect = new Rectangle2D.Double(x1, axis + maxHeight + 2 - textHeight, x2 - x1, textHeight + 2);
g2.fill(phraseRect);

Shape oldClip = g2.getClip();
g2.setClip(phraseRect);
g2.clipRect(x1, axis + maxHeight + 2 - textHeight, x2 - x1, textHeight + 2);
Rectangle2D phraseRect = new Rectangle2D.Double(x1, axis + maxHeight + 2 - textHeight, x2 - x1, textHeight + 2);
g2.fill(phraseRect);
g2.setColor(Util.buildColor(Util.phraseTextColor(entry), PHRASE_TRANSPARENCY));

// See if the label for this phrase needs to be adjusted to stay visible as we scroll.
int labelX = x1;
if (scrolledX > labelX) { // We have scrolled past the start of the phrase.
Expand Down

0 comments on commit 68be52f

Please sign in to comment.