mirror of
https://github.com/arduino/Arduino.git
synced 2025-01-20 09:52:13 +01:00
Remove unneeded color-setting code in the boards and library manager
Previously, for the boards manager: - InstallerJDialog would set the "selection background" color on the table, using the "status.notice.bgcolor" the color (default blueish green). This color is not used directly, but made available for cell renderers to use.a1448876a1/app/src/cc/arduino/contributions/ui/InstallerJDialog.java (L183)
- For each cell, either a ContributedPlatformTableCellEditor or ContributedPlatformTableCellRenderer is used, depending on whether the cell is being edited (i.e. when selected). - Both of these create a ContributedPlatformTableCellJPanel, and call its `update` method, which creates the components for the cell. - The `update` method als sets the background color of the description to white, which does not actually have any effect because the description is not opaque.a1448876a1/app/src/cc/arduino/contributions/packages/ui/ContributedPlatformTableCellJPanel.java (L271)
a1448876a1/app/src/cc/arduino/contributions/packages/ui/ContributedPlatformTableCellJPanel.java (L309)
https://docs.oracle.com/javase/7/docs/api/javax/swing/JComponent.html#setBackground(java.awt.Color) - The `update` method also sets its colors of itself (JPanel) to the FG and BG color, or the selected FG and BG color of the table depending on the selected status of the cell. These seem to default to black on white for non-selected and white on blue-ish for selected cells. However, InstallJDialog has replaced the selected BG with a blueish green, as shown above. Of these, only the BG colors actually seem to take effect. The fg color of the description component is actually used (default black).a1448876a1/app/src/cc/arduino/contributions/packages/ui/ContributedPlatformTableCellJPanel.java (L282-L288)
- After calling `update`, ContributedPlatformTableCellEditor overrides the JPanel background color with a fixed grey color. Similarly, ContributedPlatformTableCellRenderer sets an alternating white and (slightly lighter) grey background color. Together, this means that the background color set by ContributedPlatformTableCellJPanel is never actually used.a1448876a1/app/src/cc/arduino/contributions/packages/ui/ContributedPlatformTableCellEditor.java (L132-L133)
a1448876a1/app/src/cc/arduino/contributions/packages/ui/ContributedPlatformTableCellRenderer.java (L47-L53)
For the library manager, pretty much the same happens. Effectively, the only colors that were actually used were the background colors set by ContributedPlatformTableCellEditor and ContributedPlatformTableCellRenderer. This is problematic because: - There is a lot of other confusing and unused code - The foreground color is never set. This is fine when it is black or another dark color, but when the system is configured with a dark theme, the default foreground color will be white, which is problematic on a white background. This commit remove the unneeded code, setting the foreground color is left for later. It also removes the (now unused) `isSelected` from `ContributedPlatformTableCellJPanel::update`. For the library manager, the corresponding argument is still used to decide the "author" color.
This commit is contained in:
parent
b4bcb304a3
commit
778f681c2f
@ -199,7 +199,6 @@ public class ContributedLibraryTableCellJPanel extends JPanel {
|
|||||||
description.setText(desc);
|
description.setText(desc);
|
||||||
// copy description to accessibility context for screen readers to use
|
// copy description to accessibility context for screen readers to use
|
||||||
description.getAccessibleContext().setAccessibleDescription(desc);
|
description.getAccessibleContext().setAccessibleDescription(desc);
|
||||||
description.setBackground(Color.WHITE);
|
|
||||||
|
|
||||||
// for modelToView to work, the text area has to be sized. It doesn't
|
// for modelToView to work, the text area has to be sized. It doesn't
|
||||||
// matter if it's visible or not.
|
// matter if it's visible or not.
|
||||||
@ -209,14 +208,6 @@ public class ContributedLibraryTableCellJPanel extends JPanel {
|
|||||||
InstallerTableCell
|
InstallerTableCell
|
||||||
.setJTextPaneDimensionToFitContainedText(description,
|
.setJTextPaneDimensionToFitContainedText(description,
|
||||||
parentTable.getBounds().width);
|
parentTable.getBounds().width);
|
||||||
|
|
||||||
if (isSelected) {
|
|
||||||
setBackground(parentTable.getSelectionBackground());
|
|
||||||
setForeground(parentTable.getSelectionForeground());
|
|
||||||
} else {
|
|
||||||
setBackground(parentTable.getBackground());
|
|
||||||
setForeground(parentTable.getForeground());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// same function as in ContributedPlatformTableCellJPanel - is there a utils file this can move to?
|
// same function as in ContributedPlatformTableCellJPanel - is there a utils file this can move to?
|
||||||
|
@ -129,7 +129,7 @@ public class ContributedPlatformTableCellEditor extends InstallerTableCell {
|
|||||||
cell.versionToInstallChooser
|
cell.versionToInstallChooser
|
||||||
.setVisible(installed == null && uninstalledReleases.size() > 1);
|
.setVisible(installed == null && uninstalledReleases.size() > 1);
|
||||||
|
|
||||||
cell.update(table, _value, true, !installedBuiltIn.isEmpty());
|
cell.update(table, _value, !installedBuiltIn.isEmpty());
|
||||||
cell.setBackground(new Color(218, 227, 227)); // #dae3e3
|
cell.setBackground(new Color(218, 227, 227)); // #dae3e3
|
||||||
return cell;
|
return cell;
|
||||||
}
|
}
|
||||||
|
@ -175,8 +175,7 @@ public class ContributedPlatformTableCellJPanel extends JPanel {
|
|||||||
return retString;
|
return retString;
|
||||||
}
|
}
|
||||||
|
|
||||||
void update(JTable parentTable, Object value, boolean isSelected,
|
void update(JTable parentTable, Object value, boolean hasBuiltInRelease) {
|
||||||
boolean hasBuiltInRelease) {
|
|
||||||
ContributedPlatformReleases releases = (ContributedPlatformReleases) value;
|
ContributedPlatformReleases releases = (ContributedPlatformReleases) value;
|
||||||
|
|
||||||
JTextPane description = makeNewDescription();
|
JTextPane description = makeNewDescription();
|
||||||
@ -262,7 +261,6 @@ public class ContributedPlatformTableCellJPanel extends JPanel {
|
|||||||
description.setText(desc);
|
description.setText(desc);
|
||||||
// copy description to accessibility context for screen readers to use
|
// copy description to accessibility context for screen readers to use
|
||||||
description.getAccessibleContext().setAccessibleDescription(desc);
|
description.getAccessibleContext().setAccessibleDescription(desc);
|
||||||
description.setBackground(Color.WHITE);
|
|
||||||
|
|
||||||
// for modelToView to work, the text area has to be sized. It doesn't
|
// for modelToView to work, the text area has to be sized. It doesn't
|
||||||
// matter if it's visible or not.
|
// matter if it's visible or not.
|
||||||
@ -272,14 +270,6 @@ public class ContributedPlatformTableCellJPanel extends JPanel {
|
|||||||
int width = parentTable.getBounds().width;
|
int width = parentTable.getBounds().width;
|
||||||
InstallerTableCell.setJTextPaneDimensionToFitContainedText(description,
|
InstallerTableCell.setJTextPaneDimensionToFitContainedText(description,
|
||||||
width);
|
width);
|
||||||
|
|
||||||
if (isSelected) {
|
|
||||||
setBackground(parentTable.getSelectionBackground());
|
|
||||||
setForeground(parentTable.getSelectionForeground());
|
|
||||||
} else {
|
|
||||||
setBackground(parentTable.getBackground());
|
|
||||||
setForeground(parentTable.getForeground());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private JTextPane makeNewDescription() {
|
private JTextPane makeNewDescription() {
|
||||||
|
@ -44,7 +44,7 @@ public class ContributedPlatformTableCellRenderer implements TableCellRenderer {
|
|||||||
int column) {
|
int column) {
|
||||||
ContributedPlatformTableCellJPanel cell = new ContributedPlatformTableCellJPanel();
|
ContributedPlatformTableCellJPanel cell = new ContributedPlatformTableCellJPanel();
|
||||||
cell.setButtonsVisible(false);
|
cell.setButtonsVisible(false);
|
||||||
cell.update(table, value, isSelected, false);
|
cell.update(table, value, false);
|
||||||
|
|
||||||
if (row % 2 == 0) {
|
if (row % 2 == 0) {
|
||||||
cell.setBackground(new Color(236, 241, 241)); // #ecf1f1
|
cell.setBackground(new Color(236, 241, 241)); // #ecf1f1
|
||||||
|
@ -180,7 +180,6 @@ public abstract class InstallerJDialog<T> extends JDialog {
|
|||||||
contribTable.setDragEnabled(false);
|
contribTable.setDragEnabled(false);
|
||||||
contribTable.setIntercellSpacing(new Dimension(0, 1));
|
contribTable.setIntercellSpacing(new Dimension(0, 1));
|
||||||
contribTable.setShowVerticalLines(false);
|
contribTable.setShowVerticalLines(false);
|
||||||
contribTable.setSelectionBackground(Theme.getColor("status.notice.bgcolor"));
|
|
||||||
contribTable.addKeyListener(new AbstractKeyListener() {
|
contribTable.addKeyListener(new AbstractKeyListener() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
Loading…
x
Reference in New Issue
Block a user