Skip to content

Commit

Permalink
More experiments with default button heights
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexisDrogoul committed Jul 17, 2021
1 parent 049ee01 commit 0ce1fb6
Showing 1 changed file with 5 additions and 4 deletions.
Expand Up @@ -72,9 +72,9 @@ public static FlatButton menu(final Composite comp, final GamaUIColor color, fin
private String text;
private RGB colorCode;
private static final int innerMarginWidth = 5;
private static int DEFAULT_HEIGHT =
WorkbenchHelper.getDisplay().getSystemFont().getFontData()[0].getHeight() + innerMarginWidth;
private int height = DEFAULT_HEIGHT;
// private static int DEFAULT_HEIGHT =
// WorkbenchHelper.getDisplay().getSystemFont().getFontData()[0].getHeight() + innerMarginWidth;
private int height = -1; // DEFAULT_HEIGHT;
private static final int imagePadding = 5;
private boolean enabled = true;
private boolean hovered = false;
Expand Down Expand Up @@ -278,7 +278,7 @@ public int computeMinHeight() {
}
if (text != null) {
final GC gc = new GC(this);
// gc.setFont(getFont());
gc.setFont(getFont());
final Point extent = gc.textExtent(text + "...");
gc.dispose();
height = Math.max(height, extent.y + innerMarginWidth);
Expand Down Expand Up @@ -403,6 +403,7 @@ public FlatButton setColor(final GamaUIColor c) {
}

public int getHeight() {
if (height == -1) { height = computeMinHeight(); }
return height;
}

Expand Down

0 comments on commit 0ce1fb6

Please sign in to comment.