Skip to content

Commit

Permalink
Alignment for second PShelf item is broken
Browse files Browse the repository at this point in the history
Alignment is broken for all n+1 items is broken because GC returns wrong
height from the font metrics.
  • Loading branch information
ShahzaibIbrahim committed Jan 15, 2025
1 parent 783c735 commit 5545afb
Showing 1 changed file with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,14 @@ public Point computeSize(GC gc, int wHint, int hHint, Object value)
return new Point(wHint,h);
}


/**
* {@inheritDoc}
*/
@Override
public void paint(GC gc, Object value)
{
PShelfItem item = (PShelfItem)value;
int fontHeight = gc.getFontMetrics().getHeight();

Color fore = parent.getForeground();

Expand Down Expand Up @@ -92,8 +92,8 @@ public void paint(GC gc, Object value)
}
gc.setForeground(fore);

int y2 = (getBounds().height - gc.getFontMetrics().getHeight())/2;
if ((getBounds().height - gc.getFontMetrics().getHeight()) % 2 != 0)
int y2 = (getBounds().height - fontHeight)/2;
if ((getBounds().height - fontHeight) % 2 != 0)
y2 ++;

if (isHover() && !isSelected())
Expand Down

0 comments on commit 5545afb

Please sign in to comment.