| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -82,8 +82,8 @@ public abstract class Mode { | |||
| 82 | 82 | */ | |
| 83 | 83 | protected ClassLoader classLoader; | |
| 84 | 84 | ||
| 85 | - static final int BACKGROUND_WIDTH = 580; | ||
| 86 | - static final int BACKGROUND_HEIGHT = 250; | ||
| 85 | + static final int BACKGROUND_WIDTH = 1025; | ||
| 86 | + static final int BACKGROUND_HEIGHT = 65; | ||
| 87 | 87 | protected Image backgroundImage; | |
| 88 | 88 | ||
| 89 | 89 | // public Mode(Base base, File folder) { | |
@@ -170,9 +170,13 @@ public ClassLoader getClassLoader() { | |||
| 170 | 170 | */ | |
| 171 | 171 | public void setupGUI() { | |
| 172 | 172 | try { | |
| 173 | - //theme = new Settings(new File(folder, "theme/theme.txt")); | ||
| 173 | + // First load the default theme data for the whole PDE. | ||
| 174 | 174 | theme = new Settings(Base.getContentFile("lib/theme.txt")); | |
| 175 | 175 | ||
| 176 | + // The mode-specific theme.txt file should only contain additions, | ||
| 177 | + // and in extremely rare cases, it might override entries from the | ||
| 178 | + // main theme. Do not override for style changes unless they are | ||
| 179 | + // objectively necessary for your Mode. | ||
| 176 | 180 | File modeTheme = new File(folder, "theme/theme.txt"); | |
| 177 | 181 | if (modeTheme.exists()) { | |
| 178 | 182 | // Override the built-in settings with what the theme provides | |
@@ -182,8 +186,7 @@ public void setupGUI() { | |||
| 182 | 186 | // other things that have to be set explicitly for the defaults | |
| 183 | 187 | theme.setColor("run.window.bgcolor", SystemColor.control); | |
| 184 | 188 | ||
| 185 | - String suffix = Toolkit.highResDisplay() ? "-2x.png" : ".png"; | ||
| 186 | - backgroundImage = loadImage("theme/mode" + suffix); | ||
| 189 | + loadBackground(); | ||
| 187 | 190 | ||
| 188 | 191 | } catch (IOException e) { | |
| 189 | 192 | Base.showError("Problem loading theme.txt", | |
@@ -192,8 +195,30 @@ public void setupGUI() { | |||
| 192 | 195 | } | |
| 193 | 196 | ||
| 194 | 197 | ||
| 198 | + protected void loadBackground() { | ||
| 199 | + String suffix = Toolkit.highResDisplay() ? "-2x.png" : ".png"; | ||
| 200 | + backgroundImage = loadImage("theme/mode" + suffix); | ||
| 201 | + if (backgroundImage == null) { | ||
| 202 | + // If the image wasn't available, try the other resolution. | ||
| 203 | + // i.e. we don't (currently) have low-res versions of mode.png, | ||
| 204 | + // so this will grab the 2x version and scale it when drawn. | ||
| 205 | + suffix = !Toolkit.highResDisplay() ? "-2x.png" : ".png"; | ||
| 206 | + backgroundImage = loadImage("theme/mode" + suffix); | ||
| 207 | + } | ||
| 208 | + } | ||
| 209 | + | ||
| 210 | + | ||
| 195 | 211 | public void drawBackground(Graphics g, int offset) { | |
| 196 | 212 | if (backgroundImage != null) { | |
| 213 | + if (!Toolkit.highResDisplay()) { | ||
| 214 | + // Image might be downsampled from a 2x version. If so, we need nice | ||
| 215 | + // anti-aliasing for the very geometric images we're using. | ||
| 216 | + Graphics2D g2 = (Graphics2D) g; | ||
| 217 | + g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, | ||
| 218 | + RenderingHints.VALUE_ANTIALIAS_ON); | ||
| 219 | + g2.setRenderingHint(RenderingHints.KEY_INTERPOLATION, | ||
| 220 | + RenderingHints.VALUE_INTERPOLATION_BICUBIC); | ||
| 221 | + } | ||
| 197 | 222 | g.drawImage(backgroundImage, 0, -offset, | |
| 198 | 223 | BACKGROUND_WIDTH, BACKGROUND_HEIGHT, null); | |
| 199 | 224 | } | |
| Back | FazBrowse Home | New Git URL |
0 commit comments