Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixing the Item height for Table and Tree when the default font is set #771

Merged
merged 1 commit into from
Jan 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ public class List extends Scrollable {

static final int CELL_GAP = 1;

/* Vertical cell padding for list item */
static final int VERTICAL_CELL_PADDING= 8;

/**
* Constructs a new instance of this class given its parent
* and a style value describing its behavior and appearance.
Expand Down Expand Up @@ -1179,7 +1182,7 @@ void setFont (NSFont font) {
super.setFont (font);
double ascent = font.ascender ();
double descent = -font.descender () + font.leading ();
((NSTableView)view).setRowHeight ((int)Math.ceil (ascent + descent) + 1);
((NSTableView)view).setRowHeight ((int)Math.ceil (ascent + descent) + VERTICAL_CELL_PADDING);
setScrollWidth();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,9 @@ public class Table extends Composite {
static final int TEXT_GAP = 2;
static final int CELL_GAP = 1;

/* Vertical cell padding for table item */
static final int VERTICAL_CELL_PADDING= 8;

/**
* Constructs a new instance of this class given its parent
* and a style value describing its behavior and appearance.
Expand Down Expand Up @@ -2822,7 +2825,7 @@ void setItemHeight (Image image, NSFont font, boolean set) {
if (font == null) font = getFont ().handle;
double ascent = font.ascender ();
double descent = -font.descender () + font.leading ();
int height = (int)Math.ceil (ascent + descent) + 1;
int height = (int)Math.ceil (ascent + descent) + VERTICAL_CELL_PADDING;
Rectangle bounds = image != null ? image.getBounds () : imageBounds;
if (bounds != null) {
imageBounds = bounds;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,9 @@ public class Tree extends Composite {
static final int TEXT_GAP = 2;
static final int CELL_GAP = 1;

/* Vertical cell padding for tree item */
static final int VERTICAL_CELL_PADDING= 8;

/**
* Constructs a new instance of this class given its parent
* and a style value describing its behavior and appearance.
Expand Down Expand Up @@ -3170,7 +3173,7 @@ void setItemHeight (Image image, NSFont font, boolean set) {
if (font == null) font = getFont ().handle;
double ascent = font.ascender ();
double descent = -font.descender () + font.leading ();
int height = (int)Math.ceil (ascent + descent) + 1;
int height = (int)Math.ceil (ascent + descent) + VERTICAL_CELL_PADDING;
Rectangle bounds = image != null ? image.getBounds () : imageBounds;
if (bounds != null) {
imageBounds = bounds;
Expand Down
Loading