Skip to content

Commit cbc381b

Browse files
committed
holy hell, let's burn this place down
1 parent d5fb25e commit cbc381b

File tree

26 files changed

+91
-129
lines changed

26 files changed

+91
-129
lines changed

app/src/processing/app/Base.java

Lines changed: 8 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1500,35 +1500,12 @@ File checkSketchFolder(File subfolder, String item) {
15001500
// .................................................................
15011501

15021502

1503-
/**
1504-
* Show the About box.
1505-
*/
1506-
public void handleAbout() {
1507-
final Image image = Toolkit.getLibImage("about.jpg", activeEditor);
1508-
final Window window = new Window(activeEditor) {
1509-
public void paint(Graphics g) {
1510-
g.drawImage(image, 0, 0, null);
1511-
1512-
Graphics2D g2 = (Graphics2D) g;
1513-
g2.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING,
1514-
RenderingHints.VALUE_TEXT_ANTIALIAS_OFF);
1515-
1516-
g.setFont(new Font("SansSerif", Font.PLAIN, 11));
1517-
g.setColor(Color.white);
1518-
g.drawString(Base.VERSION_NAME, 50, 30);
1519-
}
1520-
};
1521-
window.addMouseListener(new MouseAdapter() {
1522-
public void mousePressed(MouseEvent e) {
1523-
window.dispose();
1524-
}
1525-
});
1526-
int w = image.getWidth(activeEditor);
1527-
int h = image.getHeight(activeEditor);
1528-
Dimension screen = Toolkit.getScreenSize();
1529-
window.setBounds((screen.width-w)/2, (screen.height-h)/2, w, h);
1530-
window.setVisible(true);
1531-
}
1503+
// /**
1504+
// * Show the About box.
1505+
// */
1506+
// static public void handleAbout() {
1507+
// new About(activeEditor);
1508+
// }
15321509

15331510

15341511
/**
@@ -2371,8 +2348,8 @@ static public File getContentFile(String name) {
23712348
*/
23722349
return new File(processingRoot, name);
23732350
}
2374-
2375-
2351+
2352+
23762353
// /**
23772354
// * Get an image associated with the current color theme.
23782355
// * @deprecated

app/src/processing/app/EditorHeader.java

Lines changed: 36 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -76,10 +76,10 @@ public class EditorHeader extends JComponent {
7676
static final int UNSELECTED = 0;
7777
static final int SELECTED = 1;
7878

79-
static final String WHERE[] = { "left", "mid", "right" }; //, "menu" };
80-
static final int LEFT = 0;
81-
static final int MIDDLE = 1;
82-
static final int RIGHT = 2;
79+
// static final String WHERE[] = { "left", "mid", "right" }; //, "menu" };
80+
// static final int LEFT = 0;
81+
// static final int MIDDLE = 1;
82+
// static final int RIGHT = 2;
8383
// static final int MENU = 3;
8484

8585
static final int PIECE_WIDTH = 4;
@@ -88,7 +88,7 @@ public class EditorHeader extends JComponent {
8888

8989
static final int ARROW_WIDTH = 14;
9090
static final int ARROW_HEIGHT = 14;
91-
Image tabArrow;
91+
static Image tabArrow;
9292

9393
//
9494

@@ -153,39 +153,41 @@ public void mouseMoved(MouseEvent e) {
153153
}
154154

155155

156-
protected String tabFile(int status, int where) {
157-
return "theme/tab-" + STATUS[status] + "-" + WHERE[where];
158-
}
156+
// protected String tabFile(int status, int where) {
157+
// return "theme/tab-" + STATUS[status] + "-" + WHERE[where];
158+
// }
159159

160160

161161
public void updateMode() {
162162
Mode mode = editor.getMode();
163-
int res = Toolkit.isRetina() ? 2 : 1;
164-
165-
String suffix = "-2x.png"; // wishful thinking
166-
// Some modes may not have a 2x version. If a mode doesn't have a 1x
167-
// version, this will cause an error... they should always have 1x.
168-
if (res == 2) {
169-
if (!mode.getContentFile(tabFile(0, 0) + suffix).exists()) {
170-
res = 1;
171-
}
172-
}
173-
if (res == 1) {
174-
suffix = ".png";
175-
if (!mode.getContentFile(tabFile(0, 0) + suffix).exists()) {
176-
suffix = ".gif";
177-
}
178-
}
163+
// int res = Toolkit.isRetina() ? 2 : 1;
164+
// String suffix = "-2x.png"; // wishful thinking
165+
// // Some modes may not have a 2x version. If a mode doesn't have a 1x
166+
// // version, this will cause an error... they should always have 1x.
167+
// if (res == 2) {
168+
// if (!mode.getContentFile(tabFile(0, 0) + suffix).exists()) {
169+
// res = 1;
170+
// }
171+
// }
172+
// if (res == 1) {
173+
// suffix = ".png";
174+
// if (!mode.getContentFile(tabFile(0, 0) + suffix).exists()) {
175+
// suffix = ".gif";
176+
// }
177+
// }
178+
//
179+
// pieces = new Image[STATUS.length][WHERE.length];
180+
// for (int status = 0; status < STATUS.length; status++) {
181+
// for (int where = 0; where < WHERE.length; where++) {
182+
// //String filename = "theme/tab-" + STATUS[i] + "-" + WHERE[j] + ".gif";
183+
// pieces[status][where] = mode.loadImage(tabFile(status, where) + suffix);
184+
// }
185+
// }
179186

180-
pieces = new Image[STATUS.length][WHERE.length];
181-
for (int status = 0; status < STATUS.length; status++) {
182-
for (int where = 0; where < WHERE.length; where++) {
183-
//String filename = "theme/tab-" + STATUS[i] + "-" + WHERE[j] + ".gif";
184-
pieces[status][where] = mode.loadImage(tabFile(status, where) + suffix);
185-
}
187+
if (tabArrow == null) {
188+
String suffix = Toolkit.highResDisplay() ? "-2x.png" : ".png";
189+
tabArrow = Toolkit.getLibImage("tab-arrow" + suffix);
186190
}
187-
188-
tabArrow = mode.loadImage("theme/tab-arrow" + suffix);
189191

190192
backgroundColor = mode.getColor("header.bgcolor");
191193
textColor[SELECTED] = mode.getColor("header.text.selected.color");
@@ -223,7 +225,7 @@ public void paintComponent(Graphics screen) {
223225
sizeH = size.height;
224226
imageW = sizeW;
225227
imageH = sizeH;
226-
if (Toolkit.isRetina()) {
228+
if (Toolkit.highResDisplay()) {
227229
offscreen = createImage(imageW*2, imageH*2);
228230
} else {
229231
offscreen = createImage(imageW, imageH);
@@ -237,7 +239,7 @@ public void paintComponent(Graphics screen) {
237239

238240
Graphics2D g2 = (Graphics2D) g;
239241

240-
if (Toolkit.isRetina()) {
242+
if (Toolkit.highResDisplay()) {
241243
// scale everything 2x, will be scaled down when drawn to the screen
242244
g2.scale(2, 2);
243245
} else {

app/src/processing/app/EditorStatus.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ public void paintComponent(Graphics screen) {
184184
sizeW = size.width;
185185
sizeH = size.height;
186186
setButtonBounds();
187-
if (Toolkit.isRetina()) {
187+
if (Toolkit.highResDisplay()) {
188188
offscreen = createImage(sizeW*2, sizeH*2);
189189
} else {
190190
offscreen = createImage(sizeW, sizeH);
@@ -194,7 +194,7 @@ public void paintComponent(Graphics screen) {
194194
Graphics g = offscreen.getGraphics();
195195

196196
Graphics2D g2 = (Graphics2D) g;
197-
if (Toolkit.isRetina()) {
197+
if (Toolkit.highResDisplay()) {
198198
g2.scale(2, 2);
199199
} else {
200200
g2.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING,

app/src/processing/app/EditorToolbar.java

Lines changed: 21 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public abstract class EditorToolbar extends JComponent implements MouseInputList
4242
static final int BUTTON_HEIGHT = 32;
4343
/** The amount of space between groups of buttons on the toolbar. */
4444
static final int BUTTON_GAP = 5;
45-
/** Size of the button image being chopped up. */
45+
/** Size (both width and height) of the buttons in the source image. */
4646
static final int BUTTON_IMAGE_SIZE = 33;
4747

4848
static final int INACTIVE = 0;
@@ -58,21 +58,8 @@ public abstract class EditorToolbar extends JComponent implements MouseInputList
5858

5959
Color bgcolor;
6060

61-
// static Image[][] buttonImages;
62-
// int currentRollover;
6361
protected Button rollover;
6462

65-
// int buttonCount;
66-
/** Current state for this button */
67-
// int[] state; // = new int[BUTTON_COUNT];
68-
/** Current image for this button's state */
69-
// Image[] stateImage;
70-
// int which[]; // mapping indices to implementation
71-
72-
// int x1[], x2[];
73-
static final int TOP = 2;
74-
static final int BOTTOM = BUTTON_HEIGHT;
75-
7663
Font statusFont;
7764
Color statusColor;
7865

@@ -82,19 +69,18 @@ public abstract class EditorToolbar extends JComponent implements MouseInputList
8269
Color modeButtonColor;
8370
Font modeTextFont;
8471
Color modeTextColor;
85-
String modeTitle; // = "JAVA"; //"Java";
86-
// String modeTitle = "ANDROID"; //"Java";
72+
String modeTitle;
8773
int modeX1, modeY1;
8874
int modeX2, modeY2;
8975
JMenu modeMenu;
9076

9177
protected ArrayList<Button> buttons;
92-
78+
9379
static final int ARROW_WIDTH = 6;
9480
static final int ARROW_HEIGHT = 6;
95-
Image modeArrow;
96-
81+
static Image modeArrow;
9782

83+
9884
public EditorToolbar(Editor editor, Base base) { //, JMenu menu) {
9985
this.editor = editor;
10086
this.base = base;
@@ -112,6 +98,11 @@ public EditorToolbar(Editor editor, Base base) { //, JMenu menu) {
11298
modeTextFont = mode.getFont("mode.button.font");
11399
modeButtonColor = mode.getColor("mode.button.color");
114100

101+
if (modeArrow == null) {
102+
String suffix = Toolkit.highResDisplay() ? "-2x.png" : ".png";
103+
modeArrow = Toolkit.getLibImage("mode-arrow" + suffix);
104+
}
105+
115106
addMouseListener(this);
116107
addMouseMotionListener(this);
117108
}
@@ -122,11 +113,13 @@ public EditorToolbar(Editor editor, Base base) { //, JMenu menu) {
122113

123114

124115
/**
125-
* Only call this from paintComponent, or when the comp is displayable,
126-
* otherwise createImage() might fail.
116+
* Load button images and slice them up. Only call this from paintComponent,
117+
* or when the comp is displayable, otherwise createImage() might fail.
118+
* (Using BufferedImage instead of createImage() nowadays, so that may
119+
* no longer be relevant.)
127120
*/
128121
public Image[][] loadImages() {
129-
int res = Toolkit.isRetina() ? 2 : 1;
122+
int res = Toolkit.highResDisplay() ? 2 : 1;
130123

131124
String suffix = null;
132125
Image allButtons = null;
@@ -164,11 +157,6 @@ public Image[][] loadImages() {
164157
}
165158
}
166159

167-
// Load the dropdown arrow, based on all the work done above
168-
modeArrow = mode.loadImage("theme/mode-arrow" + suffix);
169-
// And the background image
170-
// backgroundImage = mode.loadImage("theme/mode" + suffix);
171-
172160
return buttonImages;
173161
}
174162

@@ -185,7 +173,7 @@ public void paintComponent(Graphics screen) {
185173
Dimension size = getSize();
186174
if ((offscreen == null) ||
187175
(size.width != width) || (size.height != height)) {
188-
if (Toolkit.isRetina()) {
176+
if (Toolkit.highResDisplay()) {
189177
offscreen = createImage(size.width*2, size.height*2);
190178
} else {
191179
offscreen = createImage(size.width, size.height);
@@ -213,7 +201,7 @@ public void paintComponent(Graphics screen) {
213201
Graphics g = offscreen.getGraphics();
214202
Graphics2D g2 = (Graphics2D) g;
215203

216-
if (Toolkit.isRetina()) {
204+
if (Toolkit.highResDisplay()) {
217205
// scale everything 2x, will be scaled down when drawn to the screen
218206
g2.scale(2, 2);
219207
} else {
@@ -233,7 +221,7 @@ public void paintComponent(Graphics screen) {
233221
// g.drawImage(stateImage[i], x1[i], y1, null);
234222
// }
235223
for (Button b : buttons) {
236-
g.drawImage(b.stateImage, b.left, TOP, BUTTON_WIDTH, BUTTON_HEIGHT, null);
224+
g.drawImage(b.stateImage, b.left, 0, BUTTON_WIDTH, BUTTON_HEIGHT, null);
237225
}
238226

239227
g.setColor(statusColor);
@@ -314,9 +302,8 @@ public void mouseMoved(MouseEvent e) {
314302
int y = e.getY();
315303

316304
if (rollover != null) {
317-
// if ((x > x1[currentRollover]) && (y > y1) &&
318-
// (x < x2[currentRollover]) && (y < y2)) {
319-
if (y > TOP && y < BOTTOM && x > rollover.left && x < rollover.right) {
305+
//if (y > TOP && y < BOTTOM && x > rollover.left && x < rollover.right) {
306+
if (y > 0 && y < getHeight() && x > rollover.left && x < rollover.right) {
320307
// nothing has changed
321308
return;
322309

@@ -386,7 +373,7 @@ public void mouseDragged(MouseEvent e) { }
386373
private Button findSelection(int x, int y) {
387374
// if app loads slowly and cursor is near the buttons
388375
// when it comes up, the app may not have time to load
389-
if (offscreen != null && y > TOP && y < BOTTOM) {
376+
if (offscreen != null && y > 0 && y < getHeight()) {
390377
for (Button b : buttons) {
391378
if (x > b.left && x < b.right) {
392379
return b;

app/src/processing/app/Mode.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,7 @@ public abstract class Mode {
8484

8585
static final int BACKGROUND_WIDTH = 580;
8686
static final int BACKGROUND_HEIGHT = 250;
87-
protected Image backgroundImage;
88-
87+
protected Image backgroundImage;
8988

9089
// public Mode(Base base, File folder) {
9190
// this(base, folder, base.getSketchbookLibrariesFolder());
@@ -171,12 +170,13 @@ public ClassLoader getClassLoader() {
171170
*/
172171
public void setupGUI() {
173172
try {
174-
theme = new Settings(new File(folder, "theme/theme.txt"));
173+
//theme = new Settings(new File(folder, "theme/theme.txt"));
174+
theme = new Settings(Base.getContentFile("theme.txt"));
175175

176176
// other things that have to be set explicitly for the defaults
177177
theme.setColor("run.window.bgcolor", SystemColor.control);
178178

179-
String suffix = Toolkit.isRetina() ? "-2x.png" : ".png";
179+
String suffix = Toolkit.highResDisplay() ? "-2x.png" : ".png";
180180
backgroundImage = loadImage("theme/mode" + suffix);
181181

182182
} catch (IOException e) {

0 commit comments

Comments
 (0)