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

center table components in tabhud #543

Merged
merged 1 commit into from
Feb 15, 2024
Merged
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 @@ -25,11 +25,7 @@ public void addToCell(int x, int y, Component c) {

// pad extra to add a vertical line later
this.cellW = Math.max(this.cellW, c.width + PAD_S + PAD_L);

// assume all rows are equally high so overwriting doesn't matter
// if this wasn't the case, drawing would need more math
// not doing any of that if it's not needed
this.cellH = c.height + PAD_S;
this.cellH = Math.max(c.height + PAD_S, cellH);

this.width = this.cellW * this.cols;
this.height = (this.cellH * this.rows) - PAD_S / 2;
Expand All @@ -40,8 +36,9 @@ public void addToCell(int x, int y, Component c) {
public void render(DrawContext context, int xpos, int ypos) {
for (int x = 0; x < cols; x++) {
for (int y = 0; y < rows; y++) {
if (comps[x][y] != null) {
comps[x][y].render(context, xpos + (x * cellW), ypos + y * cellH);
Component comp = comps[x][y];
if (comp != null) {
comp.render(context, xpos + (x * cellW), ypos + y * cellH + (cellH / 2 - comp.height / 2));
}
}
// add a line before the col if we're not drawing the first one
Expand Down
Loading