| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1500,35 +1500,12 @@ File checkSketchFolder(File subfolder, String item) { | |||
| 1500 | 1500 | // ................................................................. | |
| 1501 | 1501 | ||
| 1502 | 1502 | ||
| 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 | + // } | ||
| 1532 | 1509 | ||
| 1533 | 1510 | ||
| 1534 | 1511 | /** | |
@@ -2371,8 +2348,8 @@ static public File getContentFile(String name) { | |||
| 2371 | 2348 | */ | |
| 2372 | 2349 | return new File(processingRoot, name); | |
| 2373 | 2350 | } | |
| 2374 | - | ||
| 2375 | - | ||
| 2351 | + | ||
| 2352 | + | ||
| 2376 | 2353 | // /** | |
| 2377 | 2354 | // * Get an image associated with the current color theme. | |
| 2378 | 2355 | // * @deprecated | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -76,10 +76,10 @@ public class EditorHeader extends JComponent { | |||
| 76 | 76 | static final int UNSELECTED = 0; | |
| 77 | 77 | static final int SELECTED = 1; | |
| 78 | 78 | ||
| 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; | ||
| 83 | 83 | // static final int MENU = 3; | |
| 84 | 84 | ||
| 85 | 85 | static final int PIECE_WIDTH = 4; | |
@@ -88,7 +88,7 @@ public class EditorHeader extends JComponent { | |||
| 88 | 88 | ||
| 89 | 89 | static final int ARROW_WIDTH = 14; | |
| 90 | 90 | static final int ARROW_HEIGHT = 14; | |
| 91 | - Image tabArrow; | ||
| 91 | + static Image tabArrow; | ||
| 92 | 92 | ||
| 93 | 93 | // | |
| 94 | 94 | ||
@@ -153,39 +153,41 @@ public void mouseMoved(MouseEvent e) { | |||
| 153 | 153 | } | |
| 154 | 154 | ||
| 155 | 155 | ||
| 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 | + // } | ||
| 159 | 159 | ||
| 160 | 160 | ||
| 161 | 161 | public void updateMode() { | |
| 162 | 162 | 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 | + // } | ||
| 179 | 186 | ||
| 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); | ||
| 186 | 190 | } | |
| 187 | - | ||
| 188 | - tabArrow = mode.loadImage("theme/tab-arrow" + suffix); | ||
| 189 | 191 | ||
| 190 | 192 | backgroundColor = mode.getColor("header.bgcolor"); | |
| 191 | 193 | textColor[SELECTED] = mode.getColor("header.text.selected.color"); | |
@@ -223,7 +225,7 @@ public void paintComponent(Graphics screen) { | |||
| 223 | 225 | sizeH = size.height; | |
| 224 | 226 | imageW = sizeW; | |
| 225 | 227 | imageH = sizeH; | |
| 226 | - if (Toolkit.isRetina()) { | ||
| 228 | + if (Toolkit.highResDisplay()) { | ||
| 227 | 229 | offscreen = createImage(imageW*2, imageH*2); | |
| 228 | 230 | } else { | |
| 229 | 231 | offscreen = createImage(imageW, imageH); | |
@@ -237,7 +239,7 @@ public void paintComponent(Graphics screen) { | |||
| 237 | 239 | ||
| 238 | 240 | Graphics2D g2 = (Graphics2D) g; | |
| 239 | 241 | ||
| 240 | - if (Toolkit.isRetina()) { | ||
| 242 | + if (Toolkit.highResDisplay()) { | ||
| 241 | 243 | // scale everything 2x, will be scaled down when drawn to the screen | |
| 242 | 244 | g2.scale(2, 2); | |
| 243 | 245 | } else { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -184,7 +184,7 @@ public void paintComponent(Graphics screen) { | |||
| 184 | 184 | sizeW = size.width; | |
| 185 | 185 | sizeH = size.height; | |
| 186 | 186 | setButtonBounds(); | |
| 187 | - if (Toolkit.isRetina()) { | ||
| 187 | + if (Toolkit.highResDisplay()) { | ||
| 188 | 188 | offscreen = createImage(sizeW*2, sizeH*2); | |
| 189 | 189 | } else { | |
| 190 | 190 | offscreen = createImage(sizeW, sizeH); | |
@@ -194,7 +194,7 @@ public void paintComponent(Graphics screen) { | |||
| 194 | 194 | Graphics g = offscreen.getGraphics(); | |
| 195 | 195 | ||
| 196 | 196 | Graphics2D g2 = (Graphics2D) g; | |
| 197 | - if (Toolkit.isRetina()) { | ||
| 197 | + if (Toolkit.highResDisplay()) { | ||
| 198 | 198 | g2.scale(2, 2); | |
| 199 | 199 | } else { | |
| 200 | 200 | g2.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -42,7 +42,7 @@ public abstract class EditorToolbar extends JComponent implements MouseInputList | |||
| 42 | 42 | static final int BUTTON_HEIGHT = 32; | |
| 43 | 43 | /** The amount of space between groups of buttons on the toolbar. */ | |
| 44 | 44 | 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. */ | ||
| 46 | 46 | static final int BUTTON_IMAGE_SIZE = 33; | |
| 47 | 47 | ||
| 48 | 48 | static final int INACTIVE = 0; | |
@@ -58,21 +58,8 @@ public abstract class EditorToolbar extends JComponent implements MouseInputList | |||
| 58 | 58 | ||
| 59 | 59 | Color bgcolor; | |
| 60 | 60 | ||
| 61 | - // static Image[][] buttonImages; | ||
| 62 | - // int currentRollover; | ||
| 63 | 61 | protected Button rollover; | |
| 64 | 62 | ||
| 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 | - | ||
| 76 | 63 | Font statusFont; | |
| 77 | 64 | Color statusColor; | |
| 78 | 65 | ||
@@ -82,19 +69,18 @@ public abstract class EditorToolbar extends JComponent implements MouseInputList | |||
| 82 | 69 | Color modeButtonColor; | |
| 83 | 70 | Font modeTextFont; | |
| 84 | 71 | Color modeTextColor; | |
| 85 | - String modeTitle; // = "JAVA"; //"Java"; | ||
| 86 | - // String modeTitle = "ANDROID"; //"Java"; | ||
| 72 | + String modeTitle; | ||
| 87 | 73 | int modeX1, modeY1; | |
| 88 | 74 | int modeX2, modeY2; | |
| 89 | 75 | JMenu modeMenu; | |
| 90 | 76 | ||
| 91 | 77 | protected ArrayList<Button> buttons; | |
| 92 | - | ||
| 78 | + | ||
| 93 | 79 | static final int ARROW_WIDTH = 6; | |
| 94 | 80 | static final int ARROW_HEIGHT = 6; | |
| 95 | - Image modeArrow; | ||
| 96 | - | ||
| 81 | + static Image modeArrow; | ||
| 97 | 82 | ||
| 83 | + | ||
| 98 | 84 | public EditorToolbar(Editor editor, Base base) { //, JMenu menu) { | |
| 99 | 85 | this.editor = editor; | |
| 100 | 86 | this.base = base; | |
@@ -112,6 +98,11 @@ public EditorToolbar(Editor editor, Base base) { //, JMenu menu) { | |||
| 112 | 98 | modeTextFont = mode.getFont("mode.button.font"); | |
| 113 | 99 | modeButtonColor = mode.getColor("mode.button.color"); | |
| 114 | 100 | ||
| 101 | + if (modeArrow == null) { | ||
| 102 | + String suffix = Toolkit.highResDisplay() ? "-2x.png" : ".png"; | ||
| 103 | + modeArrow = Toolkit.getLibImage("mode-arrow" + suffix); | ||
| 104 | + } | ||
| 105 | + | ||
| 115 | 106 | addMouseListener(this); | |
| 116 | 107 | addMouseMotionListener(this); | |
| 117 | 108 | } | |
@@ -122,11 +113,13 @@ public EditorToolbar(Editor editor, Base base) { //, JMenu menu) { | |||
| 122 | 113 | ||
| 123 | 114 | ||
| 124 | 115 | /** | |
| 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.) | ||
| 127 | 120 | */ | |
| 128 | 121 | public Image[][] loadImages() { | |
| 129 | - int res = Toolkit.isRetina() ? 2 : 1; | ||
| 122 | + int res = Toolkit.highResDisplay() ? 2 : 1; | ||
| 130 | 123 | ||
| 131 | 124 | String suffix = null; | |
| 132 | 125 | Image allButtons = null; | |
@@ -164,11 +157,6 @@ public Image[][] loadImages() { | |||
| 164 | 157 | } | |
| 165 | 158 | } | |
| 166 | 159 | ||
| 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 | - | ||
| 172 | 160 | return buttonImages; | |
| 173 | 161 | } | |
| 174 | 162 | ||
@@ -185,7 +173,7 @@ public void paintComponent(Graphics screen) { | |||
| 185 | 173 | Dimension size = getSize(); | |
| 186 | 174 | if ((offscreen == null) || | |
| 187 | 175 | (size.width != width) || (size.height != height)) { | |
| 188 | - if (Toolkit.isRetina()) { | ||
| 176 | + if (Toolkit.highResDisplay()) { | ||
| 189 | 177 | offscreen = createImage(size.width*2, size.height*2); | |
| 190 | 178 | } else { | |
| 191 | 179 | offscreen = createImage(size.width, size.height); | |
@@ -213,7 +201,7 @@ public void paintComponent(Graphics screen) { | |||
| 213 | 201 | Graphics g = offscreen.getGraphics(); | |
| 214 | 202 | Graphics2D g2 = (Graphics2D) g; | |
| 215 | 203 | ||
| 216 | - if (Toolkit.isRetina()) { | ||
| 204 | + if (Toolkit.highResDisplay()) { | ||
| 217 | 205 | // scale everything 2x, will be scaled down when drawn to the screen | |
| 218 | 206 | g2.scale(2, 2); | |
| 219 | 207 | } else { | |
@@ -233,7 +221,7 @@ public void paintComponent(Graphics screen) { | |||
| 233 | 221 | // g.drawImage(stateImage[i], x1[i], y1, null); | |
| 234 | 222 | // } | |
| 235 | 223 | 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); | ||
| 237 | 225 | } | |
| 238 | 226 | ||
| 239 | 227 | g.setColor(statusColor); | |
@@ -314,9 +302,8 @@ public void mouseMoved(MouseEvent e) { | |||
| 314 | 302 | int y = e.getY(); | |
| 315 | 303 | ||
| 316 | 304 | 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) { | ||
| 320 | 307 | // nothing has changed | |
| 321 | 308 | return; | |
| 322 | 309 | ||
@@ -386,7 +373,7 @@ public void mouseDragged(MouseEvent e) { } | |||
| 386 | 373 | private Button findSelection(int x, int y) { | |
| 387 | 374 | // if app loads slowly and cursor is near the buttons | |
| 388 | 375 | // 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()) { | ||
| 390 | 377 | for (Button b : buttons) { | |
| 391 | 378 | if (x > b.left && x < b.right) { | |
| 392 | 379 | return b; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -84,8 +84,7 @@ public abstract class Mode { | |||
| 84 | 84 | ||
| 85 | 85 | static final int BACKGROUND_WIDTH = 580; | |
| 86 | 86 | static final int BACKGROUND_HEIGHT = 250; | |
| 87 | - protected Image backgroundImage; | ||
| 88 | - | ||
| 87 | + protected Image backgroundImage; | ||
| 89 | 88 | ||
| 90 | 89 | // public Mode(Base base, File folder) { | |
| 91 | 90 | // this(base, folder, base.getSketchbookLibrariesFolder()); | |
@@ -171,12 +170,13 @@ public ClassLoader getClassLoader() { | |||
| 171 | 170 | */ | |
| 172 | 171 | public void setupGUI() { | |
| 173 | 172 | 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")); | ||
| 175 | 175 | ||
| 176 | 176 | // other things that have to be set explicitly for the defaults | |
| 177 | 177 | theme.setColor("run.window.bgcolor", SystemColor.control); | |
| 178 | 178 | ||
| 179 | - String suffix = Toolkit.isRetina() ? "-2x.png" : ".png"; | ||
| 179 | + String suffix = Toolkit.highResDisplay() ? "-2x.png" : ".png"; | ||
| 180 | 180 | backgroundImage = loadImage("theme/mode" + suffix); | |
| 181 | 181 | ||
| 182 | 182 | } catch (IOException e) { | |
| Back | FazBrowse Home | New Git URL |
0 commit comments