Skip to content

Commit 93581b0

Browse files
matthijskooijmancmaglie
authored andcommitted
Set foreground color in library/board manager
Previously, only the background color was changed to white or light grey. This worked well for the default theme with a black or dark text, but not for a dark theme with white or light text. This commit fixes this by also overriding the text color to be black. Since the colors are set on the JPanel table cell, but the actual text is rendered by the description JTextPane, the `setForeground` method is overridden to forward the foreground color to the description pane. Note that this commit only touches the table cell and description inside, the dropdowns and buttons have neither background nor foreground color set (thus these use both colors from the system theme). It might be more consistent to also override these, but such native UI components are typically tricky to colorize properly, so best let the system handle that normally. An alternative solution would be only use the default colors, which would actually preserve the dark theme colors in these managers as well (rather than forcing black-on-white/grey as now). There are default colors for selected and non-selected table cells that could be used, but these are different from the current colors. Additionally, the current odd/even alternating colors are then also no longer available.
1 parent 7d62518 commit 93581b0

6 files changed

+17
-0
lines changed

Diff for: app/src/cc/arduino/contributions/libraries/ui/ContributedLibraryTableCellEditor.java

+1
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@ public Component getTableCellEditorComponent(JTable table, Object value,
125125
editorCell.versionToInstallChooser
126126
.setVisible(!mayInstalled.isPresent() && notInstalled.size() > 1);
127127

128+
editorCell.setForeground(Color.BLACK);
128129
editorCell.setBackground(new Color(218, 227, 227)); // #dae3e3
129130
return editorCell;
130131
}

Diff for: app/src/cc/arduino/contributions/libraries/ui/ContributedLibraryTableCellJPanel.java

+7
Original file line numberDiff line numberDiff line change
@@ -265,4 +265,11 @@ public void setButtonsVisible(boolean enabled) {
265265
buttonsPanel.setVisible(enabled);
266266
inactiveButtonsPanel.setVisible(!enabled);
267267
}
268+
269+
public void setForeground(Color c) {
270+
super.setForeground(c);
271+
// The description is not opaque, so copy our foreground color to it.
272+
if (description != null)
273+
description.setForeground(c);
274+
}
268275
}

Diff for: app/src/cc/arduino/contributions/libraries/ui/ContributedLibraryTableCellRenderer.java

+1
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ public Component getTableCellRendererComponent(JTable table, Object value,
4646
value, isSelected);
4747
cell.setButtonsVisible(false);
4848

49+
cell.setForeground(Color.BLACK);
4950
if (row % 2 == 0) {
5051
cell.setBackground(new Color(236, 241, 241)); // #ecf1f1
5152
} else {

Diff for: app/src/cc/arduino/contributions/packages/ui/ContributedPlatformTableCellEditor.java

+1
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,7 @@ public Component getTableCellEditorComponent(JTable table, Object _value,
130130
.setVisible(installed == null && uninstalledReleases.size() > 1);
131131

132132
cell.update(table, _value, !installedBuiltIn.isEmpty());
133+
cell.setForeground(Color.BLACK);
133134
cell.setBackground(new Color(218, 227, 227)); // #dae3e3
134135
return cell;
135136
}

Diff for: app/src/cc/arduino/contributions/packages/ui/ContributedPlatformTableCellJPanel.java

+6
Original file line numberDiff line numberDiff line change
@@ -306,4 +306,10 @@ public void setButtonsVisible(boolean enabled) {
306306
inactiveButtonsPanel.setVisible(!enabled);
307307
}
308308

309+
public void setForeground(Color c) {
310+
super.setForeground(c);
311+
// The description is not opaque, so copy our foreground color to it.
312+
if (description != null)
313+
description.setForeground(c);
314+
}
309315
}

Diff for: app/src/cc/arduino/contributions/packages/ui/ContributedPlatformTableCellRenderer.java

+1
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ public Component getTableCellRendererComponent(JTable table, Object value,
4646
cell.setButtonsVisible(false);
4747
cell.update(table, value, false);
4848

49+
cell.setForeground(Color.BLACK);
4950
if (row % 2 == 0) {
5051
cell.setBackground(new Color(236, 241, 241)); // #ecf1f1
5152
} else {

0 commit comments

Comments
 (0)