Skip to content

Commit 61a550a

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 b465d1a commit 61a550a

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;
@@ -2059,33 +2061,46 @@ static public Image getThemeImage(String name, Component who) {
20592061
/**
20602062
* Return an Image object from inside the Processing lib folder.
20612063
*/
2062-
static public Image getLibImage(String name, Component who) {
2064+
static public Image getLibImage(String filename, Component who) {
20632065
Toolkit tk = Toolkit.getDefaultToolkit();
20642066

2067+
SplitFile name = FileUtils.splitFilename(filename);
20652068
int scale = Theme.getInteger("gui.scalePercent");
2066-
// TODO: create high-res enlarged copies and load those if
2067-
// the scale is more than 125%
2068-
File imageLocation = new File(getContentFile("lib"), name);
2069-
Image image = tk.getImage(imageLocation.getAbsolutePath());
2069+
File libFolder = getContentFile("lib");
2070+
File imageFile1x = new File(libFolder, name.basename + "." + name.extension);
2071+
File imageFile2x = new File(libFolder, name.basename + "@2x." + name.extension);
2072+
2073+
File imageFile;
2074+
int sourceScale;
2075+
if ((scale > 125 && imageFile2x.exists()) || !imageFile1x.exists()) {
2076+
imageFile = imageFile2x;
2077+
sourceScale = 200;
2078+
} else {
2079+
imageFile = imageFile1x;
2080+
sourceScale = 100;
2081+
}
2082+
2083+
Image image = tk.getImage(imageFile.getAbsolutePath());
20702084
MediaTracker tracker = new MediaTracker(who);
20712085
tracker.addImage(image, 0);
20722086
try {
20732087
tracker.waitForAll();
20742088
} catch (InterruptedException e) {
20752089
}
2076-
if (scale != 100) {
2077-
int width = image.getWidth(null) * scale / 100;
2078-
int height = image.getHeight(null) * scale / 100;
2090+
2091+
if (scale != sourceScale) {
2092+
int width = image.getWidth(null) * scale / sourceScale;
2093+
int height = image.getHeight(null) * scale / sourceScale;
20792094
image = image.getScaledInstance(width, height, Image.SCALE_SMOOTH);
20802095
tracker.addImage(image, 1);
20812096
try {
20822097
tracker.waitForAll();
2083-
} catch (InterruptedException e) { }
2098+
} catch (InterruptedException e) {
2099+
}
20842100
}
20852101
return image;
20862102
}
20872103

2088-
20892104
// ...................................................................
20902105

20912106

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

0 commit comments

Comments
 (0)