Skip to content

Commit

Permalink
Merge branch 'master' into renormalize-lineendings
Browse files Browse the repository at this point in the history
  • Loading branch information
lcaron authored Mar 23, 2024
2 parents c88e494 + 8622402 commit 84dab01
Showing 1 changed file with 18 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ public class NebularSliderDefaultConfiguration implements NebulaSliderGraphicCon
private static final int BAR_HEIGHT = 12;
private static final int SELECTOR_HEIGHT = 32;
protected final NebulaSlider parentSlider;
private Font font;

public NebularSliderDefaultConfiguration(final NebulaSlider parentSlider) {
this.parentSlider = parentSlider;
Expand Down Expand Up @@ -68,14 +69,21 @@ public Color getArrowColor() {

@Override
public Font getTextFont() {
final FontData fontData = parentSlider.getFont().getFontData()[0];
final Font newFont = new Font(parentSlider.getDisplay(), fontData.getName(), Math.max(fontData.getHeight(), 14), SWT.BOLD);
parentSlider.addDisposeListener(e -> {
if (!newFont.isDisposed()) {
newFont.dispose();
}
});
return newFont;
if(font == null || font.isDisposed()) {
final FontData fontData = parentSlider.getFont().getFontData()[0];
Font newFont = new Font(parentSlider.getDisplay(), fontData.getName(), getFontSize(fontData), SWT.BOLD);
parentSlider.addDisposeListener(e -> {
if(!newFont.isDisposed()) {
newFont.dispose();
}
});
this.font = newFont;
}
return font;
}

protected int getFontSize(FontData fontData) {
return Math.max(fontData.getHeight(), 14);
}

@Override
Expand All @@ -99,18 +107,12 @@ public int getBarHeight() {
}

protected Color getAndDisposeColor(final int r, final int g, final int b) {
final Color color = new Color(parentSlider.getDisplay(), r, g, b);
parentSlider.addDisposeListener(e -> {
if (!color.isDisposed()) {
color.dispose();
}
});
return color;
return new Color(r, g, b);
}

@Override
public int getArrowLineWidth() {
return 3;
}

}
}

0 comments on commit 84dab01

Please sign in to comment.