Skip to content

Commit f1fc862

Browse files
committed
Added hi-res toolbar images
Hi-resolution images are saved with the "@2x.png" suffix, the image loader will select the best image available based on the user selected scaling. Missing hi-res images can be added later together with lo-res images.
1 parent 5637130 commit f1fc862

14 files changed

+25
-10
lines changed

app/src/processing/app/Base.java

Lines changed: 25 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,14 @@
3636
import cc.arduino.view.Event;
3737
import cc.arduino.view.JMenuUtils;
3838
import cc.arduino.view.SplashScreenHelper;
39+
3940
import org.apache.commons.compress.utils.IOUtils;
4041
import org.apache.commons.lang3.StringUtils;
4142
import processing.app.debug.TargetBoard;
4243
import processing.app.debug.TargetPackage;
4344
import processing.app.debug.TargetPlatform;
4445
import processing.app.helpers.*;
46+
import processing.app.helpers.FileUtils.SplitFile;
4547
import processing.app.helpers.filefilters.OnlyDirs;
4648
import processing.app.helpers.filefilters.OnlyFilesWithExtension;
4749
import processing.app.javax.swing.filechooser.FileNameExtensionFilter;
@@ -2047,33 +2049,46 @@ static public Image getThemeImage(String name, Component who) {
20472049
/**
20482050
* Return an Image object from inside the Processing lib folder.
20492051
*/
2050-
static public Image getLibImage(String name, Component who) {
2052+
static public Image getLibImage(String filename, Component who) {
20512053
Toolkit tk = Toolkit.getDefaultToolkit();
20522054

2055+
SplitFile name = FileUtils.splitFilename(filename);
20532056
int scale = Theme.getInteger("gui.scalePercent");
2054-
// TODO: create high-res enlarged copies and load those if
2055-
// the scale is more than 125%
2056-
File imageLocation = new File(getContentFile("lib"), name);
2057-
Image image = tk.getImage(imageLocation.getAbsolutePath());
2057+
File libFolder = getContentFile("lib");
2058+
File imageFile1x = new File(libFolder, name.basename + "." + name.extension);
2059+
File imageFile2x = new File(libFolder, name.basename + "@2x." + name.extension);
2060+
2061+
File imageFile;
2062+
int sourceScale;
2063+
if ((scale > 125 && imageFile2x.exists()) || !imageFile1x.exists()) {
2064+
imageFile = imageFile2x;
2065+
sourceScale = 200;
2066+
} else {
2067+
imageFile = imageFile1x;
2068+
sourceScale = 100;
2069+
}
2070+
2071+
Image image = tk.getImage(imageFile.getAbsolutePath());
20582072
MediaTracker tracker = new MediaTracker(who);
20592073
tracker.addImage(image, 0);
20602074
try {
20612075
tracker.waitForAll();
20622076
} catch (InterruptedException e) {
20632077
}
2064-
if (scale != 100) {
2065-
int width = image.getWidth(null) * scale / 100;
2066-
int height = image.getHeight(null) * scale / 100;
2078+
2079+
if (scale != sourceScale) {
2080+
int width = image.getWidth(null) * scale / sourceScale;
2081+
int height = image.getHeight(null) * scale / sourceScale;
20672082
image = image.getScaledInstance(width, height, Image.SCALE_SMOOTH);
20682083
tracker.addImage(image, 1);
20692084
try {
20702085
tracker.waitForAll();
2071-
} catch (InterruptedException e) { }
2086+
} catch (InterruptedException e) {
2087+
}
20722088
}
20732089
return image;
20742090
}
20752091

2076-
20772092
// ...................................................................
20782093

20792094

build/shared/lib/theme/buttons@2x.png

9.38 KB
Loading

build/shared/lib/theme/close@2x.png

375 Bytes
Loading

build/shared/lib/theme/lock@2x.png

1.65 KB
Loading
382 Bytes
Loading

build/shared/lib/theme/resize@2x.png

233 Bytes
Loading
211 Bytes
Loading
325 Bytes
Loading
169 Bytes
Loading
223 Bytes
Loading
208 Bytes
Loading
328 Bytes
Loading
167 Bytes
Loading
222 Bytes
Loading

0 commit comments

Comments
 (0)