mirror of
https://github.com/processing/processing4.git
synced 2026-02-03 21:59:20 +01:00
lots of changes for 0023 and the workshop
This commit is contained in:
@@ -16,7 +16,8 @@ public class PdeApplet extends Applet
|
||||
|
||||
#ifndef PLAYER
|
||||
String encoding;
|
||||
PdeEnvironment environment;
|
||||
//PdeEnvironment environment;
|
||||
PdeEditor editor;
|
||||
#endif
|
||||
|
||||
public void init() {
|
||||
@@ -37,7 +38,7 @@ public class PdeApplet extends Applet
|
||||
PdePlayer player =
|
||||
((PdePlayer) Class.forName(program).newInstance());
|
||||
add(player);
|
||||
//environment = player;
|
||||
//editor = player;
|
||||
player.init(this);
|
||||
player.start();
|
||||
} catch (Exception e) {
|
||||
@@ -82,12 +83,13 @@ public class PdeApplet extends Applet
|
||||
}
|
||||
}
|
||||
//add(hostess = new PdeEditor(this, program));
|
||||
PdeEditor editor = new PdeEditor(this, program);
|
||||
//PdeEditor editor = new PdeEditor(this, program);
|
||||
editor = new PdeEditor(this, program);
|
||||
//if (beautify) editor.doBeautify();
|
||||
|
||||
setLayout(new BorderLayout());
|
||||
add("Center", editor);
|
||||
environment = editor;
|
||||
//editor = editor;
|
||||
|
||||
//convert();
|
||||
#endif
|
||||
@@ -125,8 +127,8 @@ public class PdeApplet extends Applet
|
||||
|
||||
#ifndef PLAYER
|
||||
public void destroy() {
|
||||
if (environment != null) {
|
||||
environment.terminate();
|
||||
if (editor != null) {
|
||||
editor.terminate();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -16,6 +16,9 @@ implements ActionListener
|
||||
static Frame frame;
|
||||
WindowAdapter windowListener;
|
||||
|
||||
//static final String WINDOW_TITLE = " P r o c e 5 5 i n g ");
|
||||
static final String WINDOW_TITLE = "Proce55ing";
|
||||
|
||||
static public void main(String args[]) {
|
||||
PdeApplication app = new PdeApplication();
|
||||
//if (args.length != 0) {
|
||||
@@ -28,7 +31,7 @@ implements ActionListener
|
||||
}
|
||||
|
||||
public PdeApplication() {
|
||||
frame = new Frame(" p r o c e s s i n g ");
|
||||
frame = new Frame(WINDOW_TITLE);
|
||||
|
||||
windowListener = new WindowAdapter() {
|
||||
public void windowClosing(WindowEvent e) {
|
||||
@@ -77,7 +80,8 @@ implements ActionListener
|
||||
|
||||
// i don't like this being here, but..
|
||||
//((PdeEditor)environment).graphics.frame = frame;
|
||||
((PdeEditor)environment).frame = frame;
|
||||
//((PdeEditor)environment).frame = frame;
|
||||
editor.frame = frame;
|
||||
|
||||
frame.pack();
|
||||
frame.show(); // added back in for pde
|
||||
|
||||
@@ -11,23 +11,35 @@ import java.util.zip.*;
|
||||
// play, stop, open, save, courseware, print, beautify
|
||||
// height of button panel is 35
|
||||
|
||||
public class PdeEditor extends Panel implements PdeEnvironment {
|
||||
public class PdeEditor extends Panel /*implements PdeEnvironment*/ {
|
||||
|
||||
static final String DEFAULT_PROGRAM = "// type program here\n";
|
||||
|
||||
static final String NEW_SKETCH_ITEM = "( new sketch )";
|
||||
static final String SKETCH_PREFIX_NAME = "sketch-";
|
||||
static final String CODE_FILENAME = "sketch.pde";
|
||||
|
||||
// otherwise, if the window is resized with the message label
|
||||
// set to blank, it's preferredSize() will be fukered
|
||||
static final String EMPTY = " ";
|
||||
PdeApplet app;
|
||||
|
||||
PdeEditorButtons buttons;
|
||||
PdeEditorHeader header;
|
||||
PdeEditorStatus status;
|
||||
PdeEditorOutput output;
|
||||
|
||||
//Label status;
|
||||
TextArea textarea;
|
||||
|
||||
//PdeGraphics graphics;
|
||||
PdeRunner runner;
|
||||
|
||||
Frame frame;
|
||||
Window fullScreenWindow;
|
||||
|
||||
Label status;
|
||||
TextArea textarea;
|
||||
static final int GRID_SIZE = 33;
|
||||
static final int INSET_SIZE = 5;
|
||||
|
||||
String lastDirectory;
|
||||
String lastFile;
|
||||
@@ -37,8 +49,8 @@ public class PdeEditor extends Panel implements PdeEnvironment {
|
||||
|
||||
public PdeEditor(PdeApplet app, String program) {
|
||||
this.app = app;
|
||||
setLayout(new BorderLayout());
|
||||
|
||||
/*
|
||||
Color bgColor =
|
||||
PdeApplet.getColor("editor.bgcolor", new Color(51, 102, 153));
|
||||
Color tickColor =
|
||||
@@ -49,26 +61,49 @@ public class PdeEditor extends Panel implements PdeEnvironment {
|
||||
PdeApplet.getColor("editor.button_bgcolor", new Color(153, 153, 153));
|
||||
Color statusBgColor =
|
||||
PdeApplet.getColor("editor.status_bgcolor", new Color(204, 204, 204));
|
||||
*/
|
||||
|
||||
//int gwidth = PdeApplet.getInteger("graphics_width", 101);
|
||||
//int gheight = PdeApplet.getInteger("graphics_height", 101);
|
||||
setLayout(new BorderLayout());
|
||||
|
||||
//add("North", new PdeEditorLicensePlate());
|
||||
Panel leftPanel = new Panel();
|
||||
leftPanel.setLayout(new BorderLayout());
|
||||
|
||||
//Panel left = new Panel();
|
||||
//left.setLayout(new BorderLayout());
|
||||
Color buttonBgColor =
|
||||
PdeApplet.getColor("editor.button_bgcolor", new Color(153, 0, 0));
|
||||
buttons = new PdeEditorButtons(this);
|
||||
buttons.setBackground(buttonBgColor);
|
||||
leftPanel.add("North", buttons);
|
||||
|
||||
Label dummy = new Label();
|
||||
dummy.setBackground(buttonBgColor);
|
||||
//dummy.setBackground(new Color(0, 100, 0));
|
||||
leftPanel.add("Center", dummy);
|
||||
|
||||
add("West", leftPanel);
|
||||
|
||||
Panel rightPanel = new Panel();
|
||||
rightPanel.setLayout(new BorderLayout());
|
||||
|
||||
/*
|
||||
PdeEditorLabel sketchLabel = new PdeEditorLabel(1);
|
||||
Color sketchBgColor = new Color(51, 51, 51);
|
||||
Color sketchPrimaryTextColor = Color.white;
|
||||
Color sketchSecondaryTextColor = new Color(153, 153, 153);
|
||||
sketchLabel.setForeground(sketchPrimaryTextColor);
|
||||
sketchLabel.setBackground(sketchBgColor);
|
||||
rightPanel.add("North", sketchLabel);
|
||||
*/
|
||||
|
||||
header = new PdeEditorHeader(this, "untitled", "default");
|
||||
rightPanel.add("North", header);
|
||||
|
||||
/*
|
||||
Panel top = new Panel();
|
||||
top.setBackground(buttonBgColor);
|
||||
top.setLayout(new BorderLayout());
|
||||
|
||||
//boolean privileges = PdeApplet.hasFullPrivileges();
|
||||
//boolean courseware = PdeApplet.get("save_as") != null;
|
||||
buttons = new PdeEditorButtons(this); //, privileges, courseware,
|
||||
//(privileges & !courseware), false);
|
||||
buttons = new PdeEditorButtons(this);
|
||||
buttons.setBackground(buttonBgColor);
|
||||
//add("North", buttons);
|
||||
//top.add("North", buttons);
|
||||
top.add("West", buttons);
|
||||
|
||||
Label buttonStatus =
|
||||
@@ -77,30 +112,9 @@ public class PdeEditor extends Panel implements PdeEnvironment {
|
||||
top.add("East", buttonStatus);
|
||||
|
||||
buttons.status = buttonStatus;
|
||||
|
||||
/*
|
||||
graphics = new PdeGraphics(gwidth, gheight, bgColor);
|
||||
#ifndef OPENGL
|
||||
graphics = new PdeEditorGraphics(gwidth, gheight, tickColor,
|
||||
bgColor, bgStippleColor, this);
|
||||
#else
|
||||
if (PdeApplet.getBoolean("graphics_3D", false)) {
|
||||
graphics = new PdeEditorGraphics3D(gwidth, gheight, tickColor,
|
||||
bgColor, bgStippleColor, this);
|
||||
} else {
|
||||
graphics = new PdeEditorGraphics(gwidth, gheight, tickColor,
|
||||
bgColor, bgStippleColor, this);
|
||||
}
|
||||
#endif
|
||||
*/
|
||||
|
||||
//left.add("Center", graphics);
|
||||
|
||||
//left.setBackground(gutterBgColor);
|
||||
|
||||
//Panel right = new Panel();
|
||||
//right.setLayout(new BorderLayout());
|
||||
|
||||
/*
|
||||
Panel statusPanel = new Panel();
|
||||
statusPanel.setBackground(statusBgColor);
|
||||
statusPanel.setLayout(new FlowLayout(FlowLayout.LEFT));
|
||||
@@ -109,13 +123,42 @@ public class PdeEditor extends Panel implements PdeEnvironment {
|
||||
top.add("South", statusPanel);
|
||||
|
||||
add("North", top);
|
||||
*/
|
||||
|
||||
if (program == null) program = DEFAULT_PROGRAM;
|
||||
textarea = new TextArea(program, 20, 48,
|
||||
TextArea.SCROLLBARS_VERTICAL_ONLY );
|
||||
textarea = new TextArea(program, 20, 60,
|
||||
TextArea.SCROLLBARS_VERTICAL_ONLY);
|
||||
textarea.setFont(PdeApplet.getFont("editor"));
|
||||
//right.add("Center", textarea);
|
||||
add("Center", textarea);
|
||||
rightPanel.add("Center", textarea);
|
||||
|
||||
Panel statusPanel = new Panel();
|
||||
statusPanel.setLayout(new BorderLayout());
|
||||
|
||||
/*
|
||||
PdeEditorLabel errorLabel = new PdeEditorLabel(1);
|
||||
//errorLabel.setBackground(errorBgColor);
|
||||
errorLabel.setBackground(statusBgColor);
|
||||
errorLabel.setForeground(errorFgColor);
|
||||
errorLabel.setText("Cannot find method \"bbackground(int)\"");
|
||||
statusPanel.add("North", errorLabel);
|
||||
*/
|
||||
status = new PdeEditorStatus(this);
|
||||
statusPanel.add("North", status);
|
||||
|
||||
PdeEditorLabel stdoutLabel = new PdeEditorLabel(2);
|
||||
Color stdoutBgColor = new Color(26, 26, 26);
|
||||
Color stdoutFgColor = new Color(153, 153, 153);
|
||||
stdoutLabel.setBackground(stdoutBgColor);
|
||||
stdoutLabel.setForeground(stdoutFgColor);
|
||||
stdoutLabel.setFont(new Font("monospaced", Font.PLAIN, 11));
|
||||
//stdoutLabel.setText("Test the print");
|
||||
//stdoutLabel.setInsets(new Insets(4, 4, 4, 4));
|
||||
statusPanel.add("South", stdoutLabel);
|
||||
|
||||
rightPanel.add("South", statusPanel);
|
||||
|
||||
add("Center", rightPanel);
|
||||
|
||||
/*
|
||||
TextArea console = new TextArea("welcome to pr0[3551ng", 5, 48,
|
||||
@@ -188,6 +231,112 @@ public class PdeEditor extends Panel implements PdeEnvironment {
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
public void doOpen(Component comp, int compX, int compY) {
|
||||
// first get users/top-level entries in sketchbook
|
||||
try {
|
||||
File sketchbookDir = new File("sketchbook");
|
||||
String toplevel[] = sketchbookDir.list();
|
||||
|
||||
PopupMenu menu = new PopupMenu();
|
||||
|
||||
menu.add(NEW_SKETCH_ITEM);
|
||||
menu.addSeparator();
|
||||
|
||||
// header knows what the current user is
|
||||
for (int i = 0; i < toplevel; i++) {
|
||||
if ((toplevel[i].equals(header.user)) ||
|
||||
(toplevel[i].equals(".")) ||
|
||||
(toplevel[i].equals(".."))) continue;
|
||||
|
||||
Menu submenu = new Menu(toplevel[i]);
|
||||
File subdir = new File(sketchbookDir, toplevel[i]);
|
||||
|
||||
String path = subdir.getCanonicalPath();
|
||||
submenu.addActionListener(new OpenMenuListener(this, path));
|
||||
//submenu.addActionListener(new ActionAdapter() {
|
||||
//});
|
||||
|
||||
String entries[] = subdir.list();
|
||||
for (int j = 0; j < entries.length; j++) {
|
||||
if ((entries[j].equals(".")) ||
|
||||
(entries[j].equals(".."))) continue;
|
||||
submenu.add(entries[j]);
|
||||
}
|
||||
|
||||
menu.add(submenu);
|
||||
}
|
||||
menu.addSeparator();
|
||||
|
||||
// this might trigger even if a submenu isn't selected,
|
||||
// but hopefully not
|
||||
String mypath = path + File.separator + header.user;
|
||||
menu.addActionListener(new OpenMenuListener(this, mypath));
|
||||
|
||||
String entries[] = new File(mypath).list();
|
||||
for (int j = 0; j < entries.length; j++) {
|
||||
if ((entries[j].equals(".")) ||
|
||||
(entries[j].equals(".."))) continue;
|
||||
submenu.add(entries[j]);
|
||||
}
|
||||
|
||||
// show the feller and get psyched for a selection
|
||||
menu.show(comp, compX, compY);
|
||||
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
buttons.clear();
|
||||
}
|
||||
|
||||
|
||||
public void handleNew() {
|
||||
try {
|
||||
// does all the plumbing to create a new project
|
||||
// then calls handleOpen to load it up
|
||||
|
||||
File sketchDir = new File("sketchbook", header.user);
|
||||
int index = 0;
|
||||
File newguy = null;
|
||||
while (new File(sketchDir, SKETCH_PREFIX_NAME + pad4(index)).exists()) {
|
||||
index++;
|
||||
}
|
||||
String path = new File(sketchDir,
|
||||
SKETCH_PREFIX_NAME +
|
||||
pad4(index)).getCanonicalPath();
|
||||
// mkdir for new project name
|
||||
File newDir = new File(path);
|
||||
newDir.mkdirs();
|
||||
|
||||
// make 'data' 'applet' dirs inside that
|
||||
// actually, don't, that way can avoid too much extra mess
|
||||
|
||||
// make empty pde file
|
||||
new FileOutputStream(new File(newDir, CODE_FILENAME));
|
||||
|
||||
// now open it up
|
||||
handleOpen(path);
|
||||
|
||||
} catch (IOException e) {
|
||||
// NEED TO DO SOME ERROR REPORTING HERE ***
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
static String pad4(int what) {
|
||||
if (what < 10) return "000" + what;
|
||||
else if (what < 100) return "00" + what;
|
||||
else if (what < 1000) return "0" + what;
|
||||
else return String.valueOf(what);
|
||||
}
|
||||
|
||||
|
||||
public void handleOpen(String path) {
|
||||
System.out.println("gonna open " + path);
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
public void doOpen() {
|
||||
FileDialog fd = new FileDialog(new Frame(),
|
||||
"Open a PDE program...",
|
||||
@@ -857,8 +1006,12 @@ public class PdeEditor extends Panel implements PdeEnvironment {
|
||||
//dbcp.repaint(); // button should go back to 'play'
|
||||
//System.err.println(e.getMessage());
|
||||
//message("Problem: " + e.getMessage());
|
||||
message(e.getMessage());
|
||||
|
||||
status.error(e.getMessage());
|
||||
//message(e.getMessage());
|
||||
|
||||
buttons.clearPlay();
|
||||
|
||||
//showStatus(e.getMessage());
|
||||
}
|
||||
|
||||
@@ -874,14 +1027,41 @@ public class PdeEditor extends Panel implements PdeEnvironment {
|
||||
|
||||
|
||||
public void message(String msg) { // part of PdeEnvironment
|
||||
status.setText(msg);
|
||||
//status.setText(msg);
|
||||
//System.out.println("PdeEditor.message " + msg);
|
||||
status.notice(msg);
|
||||
}
|
||||
|
||||
|
||||
public void messageClear(String msg) {
|
||||
if (status.getText().equals(msg)) status.setText(EMPTY);
|
||||
//if (status.getText().equals(msg)) status.setText(EMPTY);
|
||||
//System.out.println("PdeEditor.messageClear " + msg);
|
||||
status.unnotice(msg);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
class OpenMenuListener implements ActionListener {
|
||||
PdeEditor editor;
|
||||
String path;
|
||||
|
||||
public OpenMenuListener(PdeEditor editor, String path) {
|
||||
this.editor = editor;
|
||||
this.path = path;
|
||||
}
|
||||
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
if (e.getActionCommand().equals(NEW_SKETCH_ITEM)) {
|
||||
editor.handleNew();
|
||||
|
||||
} else {
|
||||
editor.handleOpen(path + File.separator + e.getActionCommand());
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -7,30 +7,32 @@ import java.awt.*;
|
||||
public class PdeEditorButtons extends Panel {
|
||||
static final String EMPTY_STATUS = " ";
|
||||
|
||||
// play, stop, save, export, open
|
||||
|
||||
static final String title[] = {
|
||||
"Play", "Stop", "Close",
|
||||
"Open", "Save", "Export Applet", "Print", "Beautify",
|
||||
"Disable Full Screen", "Full Screen"
|
||||
"", "play", "stop", "save", "open", "export"
|
||||
//"", "Play", "Stop", "Save", "Open", "Export"
|
||||
//"Play", "Stop", "Close",
|
||||
//"Open", "Save", "Export Applet", "Print", "Beautify",
|
||||
//"Disable Full Screen", "Full Screen"
|
||||
};
|
||||
|
||||
static final int BUTTON_COUNT = title.length;
|
||||
static final int BUTTON_WIDTH = 24;
|
||||
static final int BUTTON_HEIGHT = 24;
|
||||
static final int BUTTON_WIDTH = PdeEditor.GRID_SIZE; //33;
|
||||
static final int BUTTON_HEIGHT = PdeEditor.GRID_SIZE; //33;
|
||||
|
||||
static final int PLAY = 0;
|
||||
static final int STOP = 1;
|
||||
static final int CLOSE = 2;
|
||||
static final int NOTHING = 0;
|
||||
static final int PLAY = 1;
|
||||
static final int STOP = 2;
|
||||
|
||||
static final int GAP_POSITION = 1;
|
||||
|
||||
static final int OPEN = 3;
|
||||
static final int SAVE = 4;
|
||||
static final int SAVE = 3;
|
||||
static final int OPEN = 4;
|
||||
static final int EXPORT = 5;
|
||||
static final int PRINT = 6;
|
||||
static final int BEAUTIFY = 7;
|
||||
|
||||
static final int DISABLE_FULL_SCREEN = 8;
|
||||
static final int FULL_SCREEN = 9;
|
||||
//static final int PRINT = 6;
|
||||
//static final int BEAUTIFY = 7;
|
||||
//static final int DISABLE_FULL_SCREEN = 8;
|
||||
//static final int FULL_SCREEN = 9;
|
||||
|
||||
static final int INACTIVE = 0;
|
||||
static final int ROLLOVER = 1;
|
||||
@@ -47,49 +49,53 @@ public class PdeEditorButtons extends Panel {
|
||||
Image rollover[];
|
||||
Image active[];
|
||||
int currentRollover;
|
||||
int currentSelection;
|
||||
|
||||
int buttonCount;
|
||||
int state[];
|
||||
Image stateImage[];
|
||||
int which[]; // mapping indices to implementation
|
||||
|
||||
int x1[], x2[];
|
||||
int y1, y2;
|
||||
//int x1[], x2[];
|
||||
//int y1, y2;
|
||||
int x1, x2;
|
||||
int y1[], y2[];
|
||||
|
||||
|
||||
public PdeEditorButtons(PdeEditor editor /*, boolean useOpenSave,
|
||||
boolean useCourseware, boolean usePrint,
|
||||
boolean useBeautify*/) {
|
||||
this.editor = editor;
|
||||
// this could be causing trouble
|
||||
buttons = PdeApplet.readImage("buttons.gif");
|
||||
|
||||
buttonCount = 0;
|
||||
which = new int[BUTTON_COUNT];
|
||||
|
||||
// always include these
|
||||
which[buttonCount++] = NOTHING;
|
||||
which[buttonCount++] = PLAY;
|
||||
which[buttonCount++] = STOP;
|
||||
//which[buttonCount++] = CLOSE; // just removed for alpha
|
||||
|
||||
// the rest are conditional
|
||||
//if (useOpenSave) {
|
||||
which[buttonCount++] = OPEN;
|
||||
which[buttonCount++] = SAVE;
|
||||
//}
|
||||
which[buttonCount++] = SAVE;
|
||||
which[buttonCount++] = OPEN;
|
||||
which[buttonCount++] = EXPORT;
|
||||
//if (useCourseware) which[buttonCount++] = SNAPSHOT;
|
||||
//if (usePrint) which[buttonCount++] = PRINT;
|
||||
//if (useBeautify) which[buttonCount++] = BEAUTIFY;
|
||||
|
||||
which[buttonCount++] = FULL_SCREEN;
|
||||
|
||||
//buttonX = new int[buttonCount];
|
||||
currentRollover = -1;
|
||||
|
||||
setLayout(null);
|
||||
status = new Label();
|
||||
status.setFont(new Font("SansSerif", Font.PLAIN, 10));
|
||||
//status.setForeground(Color.black);
|
||||
//status.setBackground(Color.yellow);
|
||||
add(status);
|
||||
status.setBounds(-5, BUTTON_COUNT*BUTTON_HEIGHT,
|
||||
BUTTON_WIDTH + 15, BUTTON_HEIGHT);
|
||||
status.setAlignment(Label.CENTER);
|
||||
}
|
||||
|
||||
|
||||
public void update() {
|
||||
//System.out.println(currentRollover);
|
||||
//System.out.println("PdeEditorButtons.update()");
|
||||
paint(this.getGraphics());
|
||||
}
|
||||
|
||||
@@ -98,6 +104,8 @@ public class PdeEditorButtons extends Panel {
|
||||
}
|
||||
|
||||
public void paint(Graphics screen) {
|
||||
//System.out.println("PdeEditorButtons.paint() " + screen);
|
||||
|
||||
if (inactive == null) {
|
||||
inactive = new Image[BUTTON_COUNT];
|
||||
rollover = new Image[BUTTON_COUNT];
|
||||
@@ -131,12 +139,27 @@ public class PdeEditorButtons extends Panel {
|
||||
width = size.width;
|
||||
height = size.height;
|
||||
|
||||
x1 = 0;
|
||||
x2 = BUTTON_WIDTH;
|
||||
|
||||
y1 = new int[buttonCount];
|
||||
y2 = new int[buttonCount];
|
||||
|
||||
int offsetY = 0;
|
||||
for (int i = 0; i < buttonCount; i++) {
|
||||
y1[i] = offsetY;
|
||||
y2[i] = offsetY + BUTTON_HEIGHT;
|
||||
offsetY = y2[i];
|
||||
}
|
||||
|
||||
/*
|
||||
// horizontal alignment
|
||||
x1 = new int[buttonCount];
|
||||
x2 = new int[buttonCount];
|
||||
|
||||
|
||||
y1 = (height - BUTTON_HEIGHT) / 2;
|
||||
y2 = y1 + BUTTON_HEIGHT;
|
||||
|
||||
|
||||
int offsetX = 8;
|
||||
//for (int i = 0; i < 2; i++) {
|
||||
for (int i = 0; i < buttonCount; i++) {
|
||||
@@ -147,6 +170,7 @@ public class PdeEditorButtons extends Panel {
|
||||
// extra space after play/stop/close
|
||||
if (i == GAP_POSITION) offsetX += 8;
|
||||
}
|
||||
*/
|
||||
|
||||
/*
|
||||
// start from righthand side and move left
|
||||
@@ -164,7 +188,8 @@ public class PdeEditorButtons extends Panel {
|
||||
g.fillRect(0, 0, width, height);
|
||||
|
||||
for (int i = 0; i < buttonCount; i++) {
|
||||
g.drawImage(stateImage[i], x1[i], y1, null);
|
||||
//g.drawImage(stateImage[i], x1[i], y1, null);
|
||||
g.drawImage(stateImage[i], x1, y1[i], null);
|
||||
}
|
||||
//g.drawImage(stateImage[i], offsetX, offsetY, null);
|
||||
/*
|
||||
@@ -192,8 +217,10 @@ public class PdeEditorButtons extends Panel {
|
||||
public boolean mouseMove(Event e, int x, int y) {
|
||||
//System.out.println(x + ", " + y);
|
||||
if (currentRollover != -1) {
|
||||
if ((x > x1[currentRollover]) && (y > y1) &&
|
||||
(x < x2[currentRollover]) && (y < y2)) {
|
||||
if ((y > y1[currentRollover]) && (x > x1) &&
|
||||
(y < y2[currentRollover]) && (x < x2)) {
|
||||
//if ((x > x1[currentRollover]) && (y > y1) &&
|
||||
// (x < x2[currentRollover]) && (y < y2)) {
|
||||
//System.out.println("same");
|
||||
return true; // no change
|
||||
|
||||
@@ -236,8 +263,10 @@ public class PdeEditorButtons extends Panel {
|
||||
|
||||
private int findSelection(int x, int y) {
|
||||
for (int i = 0; i < buttonCount; i++) {
|
||||
if ((x > x1[i]) && (y > y1) &&
|
||||
(x < x2[i]) && (y < y2)) {
|
||||
if ((x > x1) && (y > y1[i]) &&
|
||||
(x < x2) && (y < y2[i])) {
|
||||
//if ((x > x1[i]) && (y > y1) &&
|
||||
//(x < x2[i]) && (y < y2)) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
@@ -280,20 +309,30 @@ public class PdeEditorButtons extends Panel {
|
||||
int sel = findSelection(x, y);
|
||||
if (sel == -1) return false;
|
||||
currentRollover = -1;
|
||||
|
||||
currentSelection = sel;
|
||||
setState(sel, ACTIVE, true);
|
||||
switch (which[sel]) {
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
public boolean mouseUp(Event e, int x, int y) {
|
||||
//switch (which[sel]) {
|
||||
switch (currentSelection) {
|
||||
|
||||
case PLAY: editor.doPlay(); break;
|
||||
case STOP: setState(PLAY, INACTIVE, true); editor.doStop(); break;
|
||||
case CLOSE: editor.doClose(); break;
|
||||
//case CLOSE: editor.doClose(); break;
|
||||
|
||||
case OPEN: editor.doOpen(); break;
|
||||
//editor.doOpen(this, BUTTON_WIDTH, OPEN * BUTTON_HEIGHT);
|
||||
|
||||
case OPEN: editor.doOpen(); break;
|
||||
case SAVE: editor.doSaveAs(); break;
|
||||
case EXPORT: editor.doExport(); break;
|
||||
case PRINT: editor.doPrint(); break;
|
||||
case BEAUTIFY: editor.doBeautify(); break;
|
||||
//case PRINT: editor.doPrint(); break;
|
||||
//case BEAUTIFY: editor.doBeautify(); break;
|
||||
|
||||
/*
|
||||
case FULL_SCREEN:
|
||||
editor.enableFullScreen();
|
||||
which[buttonCount-1] = DISABLE_FULL_SCREEN;
|
||||
@@ -304,7 +343,10 @@ public class PdeEditorButtons extends Panel {
|
||||
which[buttonCount-1] = FULL_SCREEN;
|
||||
message(title[which[buttonCount-1]]);
|
||||
break;
|
||||
*/
|
||||
}
|
||||
|
||||
currentSelection = -1;
|
||||
//update();
|
||||
return true;
|
||||
}
|
||||
@@ -355,7 +397,7 @@ public class PdeEditorButtons extends Panel {
|
||||
|
||||
|
||||
public Dimension preferredSize() {
|
||||
return new Dimension(220, 35);
|
||||
return new Dimension(BUTTON_WIDTH, (BUTTON_COUNT + 1)*BUTTON_HEIGHT);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#ifdef EDITOR
|
||||
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.event.*;
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
public class PdeRunner implements Runnable {
|
||||
//DbnGraphics graphics;
|
||||
PdeEnvironment env;
|
||||
//PdeEnvironment env;
|
||||
PdeEditor editor;
|
||||
String program;
|
||||
|
||||
PdeEngine engine;
|
||||
@@ -17,14 +18,13 @@ public class PdeRunner implements Runnable {
|
||||
boolean forceStop;
|
||||
|
||||
|
||||
public PdeRunner(PdeEnvironment env) {
|
||||
this(env, "");
|
||||
public PdeRunner(PdeEditor editor) {
|
||||
this(editor, "");
|
||||
}
|
||||
|
||||
public PdeRunner(PdeEnvironment env, String program) {
|
||||
public PdeRunner(PdeEditor editor, String program) {
|
||||
this.program = program;
|
||||
//this.graphics = graphics;
|
||||
this.env = env;
|
||||
this.editor = editor;
|
||||
}
|
||||
|
||||
|
||||
@@ -115,7 +115,7 @@ public class PdeRunner implements Runnable {
|
||||
forceStop = false;
|
||||
*/
|
||||
|
||||
engine = new KjcEngine(program, env);
|
||||
engine = new KjcEngine(program, editor);
|
||||
engine.start();
|
||||
|
||||
/*
|
||||
@@ -143,7 +143,7 @@ public class PdeRunner implements Runnable {
|
||||
state = RUNNER_ERROR;
|
||||
forceStop = false;
|
||||
this.stop();
|
||||
env.error(e);
|
||||
editor.error(e);
|
||||
|
||||
} catch (Exception e) {
|
||||
#ifndef KVM
|
||||
@@ -156,7 +156,7 @@ public class PdeRunner implements Runnable {
|
||||
|
||||
public void finished() { // called by KjcProcessingApplet or something
|
||||
state = RUNNER_FINISHED;
|
||||
env.finished();
|
||||
editor.finished();
|
||||
}
|
||||
|
||||
|
||||
|
||||
BIN
app/buttons.gif
BIN
app/buttons.gif
Binary file not shown.
|
Before Width: | Height: | Size: 3.4 KiB After Width: | Height: | Size: 1.3 KiB |
@@ -1,3 +1,27 @@
|
||||
ABOUT REV 0023
|
||||
|
||||
- versions 21 through 23 dealt with getting the beast to work smoothly
|
||||
for the numer workshop
|
||||
|
||||
|
||||
ABOUT REV 0020
|
||||
|
||||
major release, significant, code-destroying changes
|
||||
|
||||
- largeish handful of api changes (see docs for update)
|
||||
|
||||
- naming of api for BagelImage and others changed to BImage
|
||||
|
||||
- ProcessingApplet is now BApplet
|
||||
|
||||
- doesn't work on the mac due to update problem
|
||||
|
||||
- new user interface (not all features work yet)
|
||||
|
||||
- no longer need to use 'f' with floats
|
||||
in fact, don't ever use f with floats b/c you'll get an error
|
||||
|
||||
|
||||
ABOUT REV 0019
|
||||
|
||||
noticeable changes:
|
||||
|
||||
50
todo.txt
50
todo.txt
@@ -1,3 +1,47 @@
|
||||
_ delay wasn't working for casey
|
||||
_ why is every other pixel missing from mouse events?
|
||||
_ curve and bezier behave differently for indexing points
|
||||
|
||||
_ sketch.properties contains the last program run
|
||||
_ also the window positions, etc
|
||||
_ if it doesn't exist, starts with a new project
|
||||
_ for a new project, name it untitled-0001 or as appropriate
|
||||
_ so that previous projects aren't written over
|
||||
|
||||
_ 'open' button is a switch-to button
|
||||
_ pops up list of everything in the sketchbook
|
||||
_ first item is 'new sketch', followed by delimeter
|
||||
_ next is list of subdirs other than current user, then delim
|
||||
_ the rest are the items in the current user's folder
|
||||
|
||||
|
||||
X need 'new' button on the toolbar --> NOPE, first item on 'open' menu
|
||||
_ the zero looking one might be good (instead of export)
|
||||
_ export could be three circles in a row, overlapping
|
||||
|
||||
_ need double-clickable application version for the mac
|
||||
_ if os9, this is a no-brainer.. for osx may take a little time
|
||||
|
||||
_ everything is a project.. what about short snippets of code?
|
||||
_ this version won't be able to access everything from scrapbook
|
||||
_ (that requires a more robust class loader)
|
||||
|
||||
_ verify save when
|
||||
_ closing p5 window
|
||||
_ moving to other sketch
|
||||
|
||||
** need not be implemented **
|
||||
_ write function to swap different names for Proce55ing
|
||||
_ use for window title
|
||||
_ simple app that does swapping of letters as an animation
|
||||
_ project name is changed by clicking on the name and typing
|
||||
_ user name is changed by clicking and typing
|
||||
_ after user hits 'enter', checks to see if user exists
|
||||
_ if not, pops up message asking if they want to change
|
||||
_ message goes in same spot as error/status label (turns yellow?)
|
||||
_ if user says 'no', then
|
||||
|
||||
|
||||
QUESTIONS
|
||||
_ is it necessary to have fullscreen option on toolbar anymore?
|
||||
_ what's better than POLYGON_CONVEX and POLYGON_CONCAVE?
|
||||
@@ -113,15 +157,17 @@ X int version of min and abs
|
||||
X introduce pImage, pFont, pGraphics, pConstants (pSound)
|
||||
|
||||
a _ add frame to launched window
|
||||
a _ add maximize event catcher to make fullscreen
|
||||
a X add maximize event catcher to make fullscreen
|
||||
a _ doesn't work, because of screen sizing stupidity
|
||||
a _ shift-click on play to go directly into this 'presentation mode'
|
||||
a _ lines being highlighted for errors are off
|
||||
a _ test this on other platforms as well
|
||||
a _ move everything to new bagel api names
|
||||
a X move everything to new bagel api names
|
||||
a _ draw mode needs to be better for workshops
|
||||
a _ make size() work for draw() mode
|
||||
a _ inside Engine, reach in and grab calls to 'size'
|
||||
a _ if call is not using a constant number, then punt
|
||||
a _ better yet, just make size() available throughout
|
||||
a _ importing images doesn't work
|
||||
|
||||
b _ serial.messageReceived extra long crap in demo.pde (clean up?)
|
||||
|
||||
Reference in New Issue
Block a user