Skip to content

Commit e2fec88

Browse files
committed
Added some missing Theme.scale(..)
Now toolbar and header are correctly rendered
1 parent 967153f commit e2fec88

File tree

3 files changed

+18
-11
lines changed

3 files changed

+18
-11
lines changed

app/src/processing/app/EditorHeader.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535

3636
import javax.swing.*;
3737

38+
import static processing.app.Theme.scale;
3839

3940
/**
4041
* Sketch tabs at the top of the editor window.
@@ -71,10 +72,10 @@ public class EditorHeader extends JComponent {
7172
static final int RIGHT = 2;
7273
static final int MENU = 3;
7374

74-
static final int PIECE_WIDTH = 4;
75+
static final int PIECE_WIDTH = scale(4);
7576

7677
// value for the size bars, buttons, etc
77-
static final int GRID_SIZE = Theme.scale(33);
78+
static final int GRID_SIZE = scale(33);
7879

7980
static Image[][] pieces;
8081

@@ -238,7 +239,7 @@ public void paintComponent(Graphics screen) {
238239
tabRight = new int[codeCount];
239240
}
240241

241-
int x = 6; // offset from left edge of the component
242+
int x = scale(6); // offset from left edge of the component
242243
for (int i = 0; i < sketch.getCodeCount(); i++) {
243244
SketchCode code = sketch.getCode(i);
244245

@@ -249,6 +250,7 @@ public void paintComponent(Graphics screen) {
249250
String text = " " + codeName + (code.isModified() ? " \u00A7" : " ");
250251

251252
Graphics2D g2 = (Graphics2D) g;
253+
252254
int textWidth = (int)
253255
font.getStringBounds(text, g2.getFontRenderContext()).getWidth();
254256

app/src/processing/app/EditorLineStatus.java

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,17 @@
3030
import processing.app.helpers.PreferencesMap;
3131
import static processing.app.I18n.tr;
3232

33+
import static processing.app.Theme.scale;
3334

3435
/**
3536
* Li'l status bar fella that shows the line number.
3637
*/
3738
public class EditorLineStatus extends JComponent {
39+
3840
int start = -1, stop;
3941

4042
Image resize;
43+
private static final int RESIZE_IMAGE_SIZE = scale(20);
4144

4245
Color foreground;
4346
Color background;
@@ -50,12 +53,11 @@ public class EditorLineStatus extends JComponent {
5053
String name = "";
5154
String serialport = "";
5255

53-
5456
public EditorLineStatus() {
5557
background = Theme.getColor("linestatus.bgcolor");
5658
font = Theme.getFont("linestatus.font");
5759
foreground = Theme.getColor("linestatus.color");
58-
high = Theme.scale(Theme.getInteger("linestatus.height"));
60+
high = scale(Theme.getInteger("linestatus.height"));
5961

6062
if (OSUtils.isMacOS()) {
6163
resize = Theme.getThemeImage("resize.png", this);
@@ -103,17 +105,18 @@ public void paintComponent(Graphics g) {
103105
g.setFont(font);
104106
g.setColor(foreground);
105107
int baseline = (high + g.getFontMetrics().getAscent()) / 2;
106-
g.drawString(text, 6, baseline);
108+
g.drawString(text, scale(6), baseline);
107109

108110
g.setColor(messageForeground);
109111
String tmp = I18n.format(tr("{0} on {1}"), name, serialport);
110112

111113
Rectangle2D bounds = g.getFontMetrics().getStringBounds(tmp, null);
112114

113-
g.drawString(tmp, size.width - (int) bounds.getWidth() -20 , baseline);
115+
g.drawString(tmp, size.width - (int) bounds.getWidth() - RESIZE_IMAGE_SIZE,
116+
baseline);
114117

115118
if (OSUtils.isMacOS()) {
116-
g.drawImage(resize, size.width - 20, 0, this);
119+
g.drawImage(resize, size.width - RESIZE_IMAGE_SIZE, 0, this);
117120
}
118121
}
119122

app/src/processing/app/EditorToolbar.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -146,9 +146,11 @@ private void loadButtons() {
146146
for (int state = 0; state < 3; state++) {
147147
Image image = createImage(BUTTON_WIDTH, BUTTON_HEIGHT);
148148
Graphics g = image.getGraphics();
149-
g.drawImage(allButtons,
150-
-(i * BUTTON_IMAGE_SIZE) - 3,
151-
(-2 + state) * BUTTON_IMAGE_SIZE, null);
149+
g.setColor(bgcolor);
150+
g.fillRect(0, 0, BUTTON_WIDTH, BUTTON_HEIGHT);
151+
int offset = (BUTTON_IMAGE_SIZE - BUTTON_WIDTH) / 2;
152+
g.drawImage(allButtons, -(i * BUTTON_IMAGE_SIZE) - offset,
153+
(-2 + state) * BUTTON_IMAGE_SIZE, null);
152154
buttonImages[i][state] = image;
153155
}
154156
}

0 commit comments

Comments
 (0)