Skip to content

Commit 9215c06

Browse files
committed
Installers windows are now correctly scaled.
1 parent 2f0b0db commit 9215c06

File tree

4 files changed

+18
-10
lines changed

4 files changed

+18
-10
lines changed

app/src/cc/arduino/contributions/libraries/ui/ContributedLibraryTableCellJPanel.java

+6-5
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
import cc.arduino.contributions.libraries.ContributedLibrary;
2727
import cc.arduino.contributions.ui.InstallerTableCell;
2828
import processing.app.Base;
29+
import processing.app.Theme;
2930

3031
public class ContributedLibraryTableCellJPanel extends JPanel {
3132

@@ -39,7 +40,7 @@ public class ContributedLibraryTableCellJPanel extends JPanel {
3940
final JLabel statusLabel;
4041

4142
public ContributedLibraryTableCellJPanel(JTable parentTable, Object value,
42-
boolean isSelected) {
43+
boolean isSelected) {
4344
super();
4445
setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
4546

@@ -217,10 +218,10 @@ private JTextPane makeNewDescription() {
217218
Document doc = description.getDocument();
218219
if (doc instanceof HTMLDocument) {
219220
HTMLDocument html = (HTMLDocument) doc;
220-
StyleSheet stylesheet = html.getStyleSheet();
221-
stylesheet.addRule("body { margin: 0; padding: 0;"
222-
+ "font-family: Verdana, Geneva, Arial, Helvetica, sans-serif;"
223-
+ "font-size: 100%;" + "font-size: 0.95em; }");
221+
StyleSheet s = html.getStyleSheet();
222+
s.addRule("body { margin: 0; padding: 0;"
223+
+ "font-family: Verdana, Geneva, Arial, Helvetica, sans-serif;"
224+
+ "font-size: " + 10 * Theme.getScale() / 100 + "; }");
224225
}
225226
description.setOpaque(false);
226227
description.setBorder(new EmptyBorder(4, 7, 7, 7));

app/src/cc/arduino/contributions/packages/ui/ContributedPlatformTableCellJPanel.java

+5-4
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@
5757
import cc.arduino.contributions.packages.ContributedPlatform;
5858
import cc.arduino.contributions.ui.InstallerTableCell;
5959
import processing.app.Base;
60+
import processing.app.Theme;
6061

6162
@SuppressWarnings("serial")
6263
public class ContributedPlatformTableCellJPanel extends JPanel {
@@ -259,10 +260,10 @@ private JTextPane makeNewDescription() {
259260
Document doc = description.getDocument();
260261
if (doc instanceof HTMLDocument) {
261262
HTMLDocument html = (HTMLDocument) doc;
262-
StyleSheet stylesheet = html.getStyleSheet();
263-
stylesheet.addRule("body { margin: 0; padding: 0;"
264-
+ "font-family: Verdana, Geneva, Arial, Helvetica, sans-serif;"
265-
+ "font-size: 100%;" + "font-size: 0.95em; }");
263+
StyleSheet s = html.getStyleSheet();
264+
s.addRule("body { margin: 0; padding: 0;"
265+
+ "font-family: Verdana, Geneva, Arial, Helvetica, sans-serif;"
266+
+ "font-size: " + 10 * Theme.getScale() / 100 + "; }");
266267
}
267268
description.setOpaque(false);
268269
description.setBorder(new EmptyBorder(4, 7, 7, 7));

app/src/cc/arduino/contributions/ui/InstallerJDialog.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
package cc.arduino.contributions.ui;
3131

3232
import static processing.app.I18n.tr;
33+
import static processing.app.Theme.scale;
3334

3435
import java.awt.BorderLayout;
3536
import java.awt.Color;
@@ -227,7 +228,7 @@ public void keyReleased(KeyEvent keyEvent) {
227228
}
228229
setProgressVisible(false, "");
229230

230-
setMinimumSize(new Dimension(800, 450));
231+
setMinimumSize(scale(new Dimension(800, 450)));
231232

232233
setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
233234

app/src/processing/app/Theme.java

+5
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525

2626
import java.awt.Color;
2727
import java.awt.Component;
28+
import java.awt.Dimension;
2829
import java.awt.Font;
2930
import java.awt.Graphics;
3031
import java.awt.Graphics2D;
@@ -127,6 +128,10 @@ static public int scale(int size) {
127128
return size * getScale() / 100;
128129
}
129130

131+
static public Dimension scale(Dimension dim) {
132+
return new Dimension(scale(dim.width), scale(dim.height));
133+
}
134+
130135
static public Color getColorCycleColor(String name, int i) {
131136
int cycleSize = getInteger(name + ".size");
132137
name = String.format("%s.%02d", name, i % cycleSize);

0 commit comments

Comments
 (0)