diff --git a/app/src/processing/app/ui/EditorButton.java b/app/src/processing/app/ui/EditorButton.java index 8a115c5715..52c338e6e8 100644 --- a/app/src/processing/app/ui/EditorButton.java +++ b/app/src/processing/app/ui/EditorButton.java @@ -26,6 +26,7 @@ import javax.swing.*; import processing.app.Mode; +import processing.app.ui.Toolkit; abstract public class EditorButton extends JComponent @@ -42,6 +43,7 @@ abstract public class EditorButton extends JComponent protected boolean pressed; protected boolean selected; protected boolean rollover; + protected boolean compiling; // protected JLabel rolloverLabel; protected boolean shift; @@ -50,6 +52,8 @@ abstract public class EditorButton extends JComponent protected Image selectedImage; protected Image rolloverImage; protected Image pressedImage; + protected Image compileImageBg; + protected ImageIcon compileImage; protected Image gradient; @@ -82,6 +86,9 @@ public EditorButton(EditorToolbar parent, String name, selectedImage = mode.loadImageX(name + "-selected"); pressedImage = mode.loadImageX(name + "-pressed"); rolloverImage = mode.loadImageX(name + "-rollover"); + // Compile ImageIcon gif and it's background + compileImage = Toolkit.getLibIcon("toolbar/loader.gif"); + compileImageBg = mode.loadImageX("/lib/toolbar/compiling-background"); if (disabledImage == null) { disabledImage = enabledImage; @@ -95,6 +102,9 @@ public EditorButton(EditorToolbar parent, String name, if (rolloverImage == null) { rolloverImage = enabledImage; // could be pressed image } + if (compileImage == null) { + compileImage = new ImageIcon(enabledImage); + } addMouseListener(this); addMouseMotionListener(this); } @@ -111,10 +121,16 @@ public void paintComponent(Graphics g) { image = pressedImage; } else if (rollover) { image = rolloverImage; + } else if (compiling) { + image = compileImage.getImage(); } if (gradient != null) { g.drawImage(gradient, 0, 0, DIM, DIM, this); } + if (compiling) { + // Sets white background to the compile gif icon + g.drawImage(compileImageBg, 0, 0, DIM, DIM, this); + } g.drawImage(image, 0, 0, DIM, DIM, this); } @@ -201,6 +217,11 @@ public void setSelected(boolean selected) { this.selected = selected; } + public void setCompile(boolean compiling) { + // Sets the button image to spinner.gif + this.compiling = compiling; + } + /* @Override diff --git a/app/src/processing/app/ui/EditorToolbar.java b/app/src/processing/app/ui/EditorToolbar.java index 0af6c8a4c1..ddb06a33a0 100644 --- a/app/src/processing/app/ui/EditorToolbar.java +++ b/app/src/processing/app/ui/EditorToolbar.java @@ -208,6 +208,18 @@ public void deactivateRun() { } + public void activateCompile() { + runButton.setCompile(true); + repaint(); + } + + + public void deactivateCompile() { + runButton.setCompile(false); + repaint(); + } + + public void activateStop() { stopButton.setSelected(true); repaint(); diff --git a/build/shared/lib/toolbar/compiling-background-1x.png b/build/shared/lib/toolbar/compiling-background-1x.png new file mode 100644 index 0000000000..44356ea76d Binary files /dev/null and b/build/shared/lib/toolbar/compiling-background-1x.png differ diff --git a/build/shared/lib/toolbar/compiling-background-2x.png b/build/shared/lib/toolbar/compiling-background-2x.png new file mode 100644 index 0000000000..65a89974bf Binary files /dev/null and b/build/shared/lib/toolbar/compiling-background-2x.png differ diff --git a/build/shared/lib/toolbar/loader.gif b/build/shared/lib/toolbar/loader.gif new file mode 100644 index 0000000000..e8c23759c8 Binary files /dev/null and b/build/shared/lib/toolbar/loader.gif differ diff --git a/java/src/processing/mode/java/JavaEditor.java b/java/src/processing/mode/java/JavaEditor.java index 178730eb4b..afaaeee6eb 100644 --- a/java/src/processing/mode/java/JavaEditor.java +++ b/java/src/processing/mode/java/JavaEditor.java @@ -1096,7 +1096,7 @@ public void handleRun() { public void run() { prepareRun(); try { - toolbar.activateRun(); + toolbar.activateCompile(); //runtime = jmode.handleRun(sketch, JavaEditor.this); runtime = jmode.handleLaunch(sketch, JavaEditor.this, false); } catch (Exception e) { @@ -1113,7 +1113,7 @@ public void handlePresent() { public void run() { prepareRun(); try { - toolbar.activateRun(); + toolbar.activateCompile(); //runtime = jmode.handlePresent(sketch, JavaEditor.this); runtime = jmode.handleLaunch(sketch, JavaEditor.this, true); } catch (Exception e) { @@ -1130,7 +1130,7 @@ public void run() { prepareRun(); try { // toolbar.activate(JavaToolbar.RUN); - toolbar.activateRun(); + toolbar.activateCompile(); runtime = jmode.handleTweak(sketch, JavaEditor.this); } catch (Exception e) { statusError(e); @@ -2068,13 +2068,27 @@ public VariableInspector variableInspector() { return inspector; } - - protected void activateRun() { + public void activateRun() { debugItem.setEnabled(false); // toolbar.activate(JavaToolbar.RUN); toolbar.activateRun(); } + protected void activateCompile() { + debugItem.setEnabled(false); + toolbar.activateCompile(); + } + + /** + * Deactivate the Compile gif icon on Run button. This is called by + * handleLaunch() and handleTweak() to notify that the sketch has stopped + * compiling and is ready to run, usually in response to an error (or maybe + * the sketch completing and exiting?) Tools should not call this function. + */ + public void deactivateCompile() { + debugItem.setEnabled(true); + toolbar.deactivateCompile(); + } /** * Deactivate the Run button. This is called by Runner to notify that the diff --git a/java/src/processing/mode/java/JavaMode.java b/java/src/processing/mode/java/JavaMode.java index ed9d4e3e38..1bcff506bf 100644 --- a/java/src/processing/mode/java/JavaMode.java +++ b/java/src/processing/mode/java/JavaMode.java @@ -149,6 +149,7 @@ public Runner handlePresent(Sketch sketch, public Runner handleLaunch(Sketch sketch, RunnerListener listener, final boolean present) throws SketchException { JavaBuild build = new JavaBuild(sketch); + final JavaEditor editor = (JavaEditor) listener; // String appletClassName = build.build(false); String appletClassName = build.build(true); if (appletClassName != null) { @@ -163,6 +164,10 @@ public void run() { } } }).start(); + // Compilation passed, so deactivate the compile icon + // and enable run icon + editor.deactivateCompile(); + editor.activateRun(); return runtime; } return null; @@ -176,6 +181,11 @@ public Runner handleTweak(Sketch sketch, final JavaEditor editor = (JavaEditor) listener; // editor.errorCheckerService.quickErrorCheck(); // done in prepareRun() + // Compilation passed, so deactivate the compile icon + // and enable run icon + editor.deactivateCompile(); + editor.activateRun(); + if (isSketchModified(sketch)) { editor.deactivateRun(); Messages.showMessage(Language.text("menu.file.save"),