Skip to content

Commit 1175133

Browse files
committed
Fixed a small mess in EditorHeader
1 parent 8169010 commit 1175133

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

app/src/processing/app/EditorHeader.java

+9-8
Original file line numberDiff line numberDiff line change
@@ -66,11 +66,10 @@ public class EditorHeader extends JComponent {
6666
static final int UNSELECTED = 0;
6767
static final int SELECTED = 1;
6868

69-
static final String WHERE[] = { "left", "mid", "right", "menu" };
69+
static final String WHERE[] = { "left", "mid", "right" };
7070
static final int LEFT = 0;
7171
static final int MIDDLE = 1;
7272
static final int RIGHT = 2;
73-
static final int MENU = 3;
7473

7574
static final int PIECE_WIDTH = scale(4);
7675
static final int PIECE_HEIGHT = scale(33);
@@ -79,6 +78,7 @@ public class EditorHeader extends JComponent {
7978
static final int GRID_SIZE = scale(33);
8079

8180
static Image[][] pieces;
81+
static Image menuButtons[];
8282

8383
Image offscreen;
8484
int sizeW, sizeH;
@@ -149,15 +149,16 @@ public EditorHeader(Editor eddie) {
149149

150150
if (pieces == null) {
151151
pieces = new Image[STATUS.length][WHERE.length];
152+
menuButtons = new Image[STATUS.length];
152153
for (int i = 0; i < STATUS.length; i++) {
153154
for (int j = 0; j < WHERE.length; j++) {
154155
String path = "tab-" + STATUS[i] + "-" + WHERE[j];
155-
pieces[i][j] = Theme.getThemeImage(path, this,
156-
// TODO: Refactor this mess...
157-
j == MENU ? PIECE_HEIGHT
158-
: PIECE_WIDTH,
156+
pieces[i][j] = Theme.getThemeImage(path, this, PIECE_WIDTH,
159157
PIECE_HEIGHT);
160158
}
159+
String path = "tab-" + STATUS[i] + "-menu";
160+
menuButtons[i] = Theme.getThemeImage(path, this, PIECE_HEIGHT,
161+
PIECE_HEIGHT);
161162
}
162163
}
163164

@@ -284,10 +285,10 @@ public void paintComponent(Graphics screen) {
284285
x += PIECE_WIDTH - 1; // overlap by 1 pixel
285286
}
286287

287-
menuLeft = sizeW - (16 + pieces[0][MENU].getWidth(this));
288+
menuLeft = sizeW - (16 + menuButtons[0].getWidth(this));
288289
menuRight = sizeW - 16;
289290
// draw the dropdown menu target
290-
g.drawImage(pieces[popup.isVisible() ? SELECTED : UNSELECTED][MENU],
291+
g.drawImage(menuButtons[popup.isVisible() ? SELECTED : UNSELECTED],
291292
menuLeft, 0, null);
292293

293294
screen.drawImage(offscreen, 0, 0, null);

0 commit comments

Comments
 (0)