Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions app/src/processing/app/ui/EditorButton.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import javax.swing.*;

import processing.app.Mode;
import processing.app.ui.Toolkit;


abstract public class EditorButton extends JComponent
Expand All @@ -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;

Expand All @@ -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;

Expand Down Expand Up @@ -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;
Expand All @@ -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);
}
Expand All @@ -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);
}

Expand Down Expand Up @@ -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
Expand Down
12 changes: 12 additions & 0 deletions app/src/processing/app/ui/EditorToolbar.java
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
Binary file added build/shared/lib/toolbar/compiling-background-1x.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added build/shared/lib/toolbar/compiling-background-2x.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added build/shared/lib/toolbar/loader.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
24 changes: 19 additions & 5 deletions java/src/processing/mode/java/JavaEditor.java
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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) {
Expand All @@ -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);
Expand Down Expand Up @@ -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
Expand Down
10 changes: 10 additions & 0 deletions java/src/processing/mode/java/JavaMode.java
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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;
Expand All @@ -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"),
Expand Down