Skip to content

Commit 1b24531

Browse files
committed
starting switch to new design
1 parent 401ca47 commit 1b24531

File tree

9 files changed

+30
-22
lines changed

9 files changed

+30
-22
lines changed

app/src/processing/app/EditorToolbar.java

Lines changed: 26 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424

2525
import java.awt.*;
2626
import java.awt.event.*;
27+
import java.awt.image.BufferedImage;
2728
import java.util.ArrayList;
2829

2930
import javax.swing.*;
@@ -96,17 +97,6 @@ public EditorToolbar(Editor editor, Base base) { //, JMenu menu) {
9697
// this.menu = menu;
9798

9899
buttons = new ArrayList<Button>();
99-
// buttonCount = 0;
100-
// which = new int[BUTTON_COUNT];
101-
102-
// which[buttonCount++] = RUN;
103-
// which[buttonCount++] = STOP;
104-
// which[buttonCount++] = NEW;
105-
// which[buttonCount++] = OPEN;
106-
// which[buttonCount++] = SAVE;
107-
// which[buttonCount++] = EXPORT;
108-
109-
// currentRollover = -1;
110100
rollover = null;
111101

112102
mode = editor.getMode();
@@ -131,23 +121,37 @@ public EditorToolbar(Editor editor, Base base) { //, JMenu menu) {
131121
* otherwise createImage() might fail.
132122
*/
133123
public Image[][] loadImages() {
134-
// Image allButtons = Base.getThemeImage("buttons.gif", this);
135-
// Image allButtons = Base.loadImage(file);
136-
Image allButtons = mode.loadImage("theme/buttons.gif");
137-
int count = allButtons.getWidth(this) / BUTTON_WIDTH;
138-
// System.out.println("width is " + allButtons.getWidth(this));
124+
int res = Toolkit.isRetina() ? 2 : 1;
125+
126+
Image allButtons = null;
127+
// Some modes may not have a 2x version. If a mode doesn't have a 1x
128+
// version, this will cause an error... they should always have 1x.
129+
if (res == 2) {
130+
allButtons = mode.loadImage("theme/buttons-2x.png");
131+
if (allButtons == null) {
132+
res = 1; // take him down a notch
133+
}
134+
}
135+
if (res == 1) {
136+
allButtons = mode.loadImage("theme/buttons.png");
137+
if (allButtons == null) {
138+
// use the old (pre-2.0b9) file name
139+
allButtons = mode.loadImage("theme/buttons.gif");
140+
}
141+
}
142+
143+
int count = allButtons.getWidth(this) / BUTTON_WIDTH*res;
139144
Image[][] buttonImages = new Image[count][3];
140145

141146
for (int i = 0; i < count; i++) {
142147
for (int state = 0; state < 3; state++) {
143-
// Toolkit tk = Toolkit.getDefaultToolkit();
144-
// Image image = tk.createImage(BUTTON_WIDTH, BUTTON_HEIGHT);
145-
// System.out.println("image is " + image + " " + BUTTON_WIDTH + " " + BUTTON_HEIGHT);
146-
Image image = createImage(BUTTON_WIDTH, BUTTON_HEIGHT);
148+
// Image image = createImage(BUTTON_WIDTH*res, BUTTON_HEIGHT*res);
149+
Image image = new BufferedImage(BUTTON_WIDTH*res, BUTTON_HEIGHT*res, BufferedImage.TYPE_INT_ARGB);
147150
Graphics g = image.getGraphics();
148151
g.drawImage(allButtons,
149-
-(i*BUTTON_IMAGE_SIZE) - 3,
150-
(-2 + state)*BUTTON_IMAGE_SIZE, null);
152+
-(i*BUTTON_IMAGE_SIZE*res) - 3,
153+
(state-2)*BUTTON_IMAGE_SIZE*res, null);
154+
g.dispose();
151155
buttonImages[i][state] = image;
152156
}
153157
}

app/src/processing/app/Mode.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -803,6 +803,9 @@ void expandTree(JTree tree, Object object, String[] items, DefaultMutableTreeNod
803803
*/
804804
public Image loadImage(String filename) {
805805
File file = new File(folder, filename);
806+
if (!file.exists()) {
807+
return null;
808+
}
806809
return new ImageIcon(file.getAbsolutePath()).getImage();
807810
}
808811

app/src/processing/app/Toolkit.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,7 @@ static public Clipboard getSystemClipboard() {
216216

217217
static Boolean retinaProp;
218218

219+
/** Yes, retina is a marketing term. But no, nobody else has implemented hi-dpi. */
219220
static public boolean isRetina() {
220221
if (Base.isMacOS()) {
221222
// This should probably be reset each time there's a display change.

java/theme/buttons-2x.png

5.6 KB
Loading

java/theme/buttons.gif

-2.61 KB
Binary file not shown.

java/theme/buttons.png

2.47 KB
Loading

java/theme/menu-2x.png

173 Bytes
Loading

java/theme/menu.png

132 Bytes
Loading

java/theme/mode.png

234 KB
Loading

0 commit comments

Comments
 (0)