mirror of
https://github.com/processing/processing4.git
synced 2026-06-16 04:26:26 +02:00
working on sketch i/o
This commit is contained in:
+101
-86
@@ -60,12 +60,12 @@ public class PdeEditor extends JFrame
|
||||
" " +
|
||||
" ";
|
||||
|
||||
static final int NEW = 1;
|
||||
static final int OPEN = 2;
|
||||
static final int QUIT = 3;
|
||||
static final int HANDLE_NEW = 1;
|
||||
static final int HANDLE_OPEN = 2;
|
||||
static final int HANDLE_QUIT = 3;
|
||||
int checking;
|
||||
String openingPath;
|
||||
String openingName;
|
||||
String handleOpenPath;
|
||||
//String openingName;
|
||||
|
||||
PdeEditorButtons buttons;
|
||||
PdeEditorHeader header;
|
||||
@@ -368,7 +368,8 @@ public class PdeEditor extends JFrame
|
||||
|
||||
//if (sketchName != null) {
|
||||
if ((sketchPath != null) && (new File(sketchPath)).exists()) {
|
||||
skOpen(new PdeSketch(sketchFile));
|
||||
handleOpen(sketchPath);
|
||||
//skOpen(new PdeSketch(sketchFile));
|
||||
//if (new File(sketchDir + File.separator + sketchName + ".pde").exists()) {
|
||||
//skOpen(sketchDir, sketchName);
|
||||
|
||||
@@ -376,7 +377,8 @@ public class PdeEditor extends JFrame
|
||||
//skNew2(true);
|
||||
//}
|
||||
} else {
|
||||
skNew2(true);
|
||||
//skNew2(true);
|
||||
handleNew2(true);
|
||||
}
|
||||
|
||||
|
||||
@@ -1020,7 +1022,8 @@ public class PdeEditor extends JFrame
|
||||
|
||||
sketch.cleanup();
|
||||
|
||||
// toxi_030903: focus the PDE again after quitting presentation mode
|
||||
// [toxi 030903]
|
||||
// focus the PDE again after quitting presentation mode
|
||||
toFront();
|
||||
}
|
||||
|
||||
@@ -1033,83 +1036,65 @@ public class PdeEditor extends JFrame
|
||||
}
|
||||
|
||||
|
||||
// check to see if there have been changes
|
||||
// if so, prompt user whether or not to save first
|
||||
// if the user cancels, return false to abort parent operation
|
||||
/**
|
||||
* Check to see if there have been changes. If so, prompt user
|
||||
* whether or not to save first. If the user cancels, just ignore.
|
||||
* Otherwise, one of the other methods will handle calling
|
||||
* checkModified2() which will get on with business.
|
||||
*/
|
||||
protected void checkModified(int checking) {
|
||||
checkModified(checking, null, null);
|
||||
}
|
||||
|
||||
protected void checkModified(int checking, String path, String name) {
|
||||
//checkModified(checking, null, null);
|
||||
//}
|
||||
//protected void checkModified(int checking, String path, String name) {
|
||||
this.checking = checking;
|
||||
openingPath = path;
|
||||
openingName = name;
|
||||
//openingPath = path;
|
||||
//openingName = name;
|
||||
|
||||
if (sketch.isModified()) {
|
||||
String prompt = "Save changes to " + sketch.name + "? ";
|
||||
|
||||
if (checking != HANDLE_QUIT) {
|
||||
// if the user is not quitting, then use the nicer
|
||||
// dialog that's actually inside the p5 window.
|
||||
status.prompt(prompt);
|
||||
|
||||
} else {
|
||||
// if the user selected quit, then this has to be done with
|
||||
// a JOptionPane instead of internally in the editor.
|
||||
// TODO this is actually just a bug to be fixed.
|
||||
|
||||
// macosx java kills the app even though cancel might get hit
|
||||
// so the cancel button is (temporarily) left off
|
||||
// this may be treated differently in macosx java 1.4,
|
||||
// but 1.4 isn't currently stable enough to use.
|
||||
|
||||
// turns out windows has the same problem (sometimes)
|
||||
// disable cancel for now until a fix can be found.
|
||||
|
||||
Object[] options = { "Yes", "No" };
|
||||
int result = JOptionPane.showOptionDialog(this,
|
||||
prompt,
|
||||
"Quit",
|
||||
JOptionPane.YES_NO_OPTION,
|
||||
JOptionPane.QUESTION_MESSAGE,
|
||||
null,
|
||||
options,
|
||||
options[0]);
|
||||
/*
|
||||
} else {
|
||||
Object[] options = { "Yes", "No", "Cancel" };
|
||||
result = JOptionPane.showOptionDialog(this,
|
||||
prompt,
|
||||
"Quit",
|
||||
JOptionPane.YES_NO_CANCEL_OPTION,
|
||||
JOptionPane.QUESTION_MESSAGE,
|
||||
null,
|
||||
options,
|
||||
options[2]);
|
||||
*/
|
||||
|
||||
if (result == JOptionPane.YES_OPTION) {
|
||||
//System.out.println("yes");
|
||||
//System.out.println("saving");
|
||||
//doSave();
|
||||
sketch.save();
|
||||
//System.out.println("done saving");
|
||||
checkModified2();
|
||||
|
||||
} else if (result == JOptionPane.NO_OPTION) {
|
||||
//System.out.println("no");
|
||||
checkModified2(); // though this may just quit
|
||||
|
||||
} else if (result == JOptionPane.CANCEL_OPTION) {
|
||||
//System.out.println("cancel");
|
||||
// does nothing
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
if (!sketch.isModified()) {
|
||||
checkModified2();
|
||||
}
|
||||
//System.out.println("exiting checkmodified");
|
||||
|
||||
String prompt = "Save changes to " + sketch.name + "? ";
|
||||
|
||||
if (checking != HANDLE_QUIT) {
|
||||
// if the user is not quitting, then use the nicer
|
||||
// dialog that's actually inside the p5 window.
|
||||
status.prompt(prompt);
|
||||
|
||||
} else {
|
||||
// if the user selected quit, then this has to be done with
|
||||
// a JOptionPane instead of internally in the editor.
|
||||
// TODO this is actually just a bug to be fixed.
|
||||
|
||||
// macosx java kills the app even though cancel might get hit
|
||||
// so the cancel button is (temporarily) left off
|
||||
// this may be treated differently in macosx java 1.4,
|
||||
// but 1.4 isn't currently stable enough to use.
|
||||
|
||||
// turns out windows has the same problem (sometimes)
|
||||
// disable cancel for now until a fix can be found.
|
||||
|
||||
Object[] options = { "Yes", "No" };
|
||||
int result = JOptionPane.showOptionDialog(this,
|
||||
prompt,
|
||||
"Quit",
|
||||
JOptionPane.YES_NO_OPTION,
|
||||
JOptionPane.QUESTION_MESSAGE,
|
||||
null,
|
||||
options,
|
||||
options[0]);
|
||||
|
||||
if (result == JOptionPane.YES_OPTION) {
|
||||
sketch.save();
|
||||
checkModified2();
|
||||
|
||||
} else if (result == JOptionPane.NO_OPTION) {
|
||||
checkModified2(); // though this may just quit
|
||||
|
||||
} else if (result == JOptionPane.CANCEL_OPTION) {
|
||||
// ignored
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1118,9 +1103,10 @@ public class PdeEditor extends JFrame
|
||||
*/
|
||||
public void checkModified2() {
|
||||
switch (checking) {
|
||||
case NEW: handleNew2(false); break;
|
||||
case OPEN: skOpen2(openingPath, openingName); break;
|
||||
case QUIT: handleQuit2(); break;
|
||||
case HANDLE_NEW: handleNew2(false); break;
|
||||
//case HANDLE_OPEN: skOpen2(openingPath, openingName); break;
|
||||
case HANDLE_OPEN: handleOpen2(openingPath); break;
|
||||
case HANDLE_QUIT: handleQuit2(); break;
|
||||
}
|
||||
checking = 0;
|
||||
}
|
||||
@@ -1132,7 +1118,7 @@ public class PdeEditor extends JFrame
|
||||
*/
|
||||
public void handleNew() {
|
||||
doStop();
|
||||
checkModified(NEW);
|
||||
checkModified(HANDLE_NEW);
|
||||
}
|
||||
|
||||
|
||||
@@ -1157,16 +1143,39 @@ public class PdeEditor extends JFrame
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Need to determine what to open, happens when the 'open' button
|
||||
* is hit or open is selected from the menu.
|
||||
*/
|
||||
public void handleOpen() {
|
||||
String path = sketchbook.handleOpen();
|
||||
if (path != null) handleOpen(path);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get ready to open something good.
|
||||
*/
|
||||
public void handleOpen(String path) {
|
||||
doStop();
|
||||
handleOpenPath = path;
|
||||
checkModified(HANDLE_OPEN);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
public void skOpen(String path, String name) {
|
||||
doStop();
|
||||
checkModified(SK_OPEN, path, name);
|
||||
}
|
||||
|
||||
|
||||
protected void skOpen2(String path, String name) {
|
||||
File osketchFile = new File(path, name + ".pde");
|
||||
File osketchDir = new File(path);
|
||||
handleOpen2(name, osketchFile, osketchDir);
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
@@ -1193,8 +1202,14 @@ public class PdeEditor extends JFrame
|
||||
*/
|
||||
|
||||
|
||||
protected void handleOpen2() {
|
||||
sketch = new PdeSketch(handleOpenPath);
|
||||
// i guess this just sets everything up properly?
|
||||
}
|
||||
|
||||
|
||||
protected void handleOpen2(String isketchName,
|
||||
File isketchFile, File isketchDir) {
|
||||
File isketchFile, File isketchDir) {
|
||||
if (!isketchFile.exists()) {
|
||||
status.error("no file named " + isketchName);
|
||||
return;
|
||||
@@ -1428,7 +1443,7 @@ public class PdeEditor extends JFrame
|
||||
doClose();
|
||||
|
||||
//if (!checkModified()) return;
|
||||
checkModified(QUIT);
|
||||
checkModified(HANDLE_QUIT);
|
||||
//System.out.println("exiting doquit");
|
||||
}
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
/*
|
||||
PdeSketchbook - handles sketchbook mechanics for the sketch menu
|
||||
Part of the Processing project - http://Proce55ing.net
|
||||
Part of the Processing project - http://processing.org
|
||||
|
||||
Except where noted, code is written by Ben Fry
|
||||
Copyright (c) 2001-03 Massachusetts Institute of Technology
|
||||
@@ -26,6 +26,7 @@ import java.awt.*;
|
||||
import java.awt.event.*;
|
||||
import java.io.*;
|
||||
import java.net.*;
|
||||
import java.text.*;
|
||||
import java.util.*;
|
||||
import java.util.zip.*;
|
||||
|
||||
@@ -34,6 +35,10 @@ import javax.swing.event.*;
|
||||
import javax.swing.text.*;
|
||||
import javax.swing.undo.*;
|
||||
|
||||
#ifdef MACOS
|
||||
import com.apple.mrj.*;
|
||||
#endif
|
||||
|
||||
|
||||
public class PdeSketchbook {
|
||||
PdeEditor editor;
|
||||
@@ -42,6 +47,9 @@ public class PdeSketchbook {
|
||||
//File sketchbookFolder;
|
||||
//String sketchbookPath; // canonical path
|
||||
|
||||
// last file/directory used for file opening
|
||||
String handleOpenDirectory;
|
||||
|
||||
File examplesFolder;
|
||||
String examplesPath; // canonical path (for comparison)
|
||||
|
||||
@@ -90,7 +98,7 @@ public class PdeSketchbook {
|
||||
* Handle creating a sketch folder, return its base .pde file
|
||||
* or null if the operation was cancelled.
|
||||
*/
|
||||
public String handleNew() throws IOException {
|
||||
public String handleNew(boolean startup) throws IOException {
|
||||
File newbieDir = null;
|
||||
String newbieName = null;
|
||||
|
||||
@@ -165,6 +173,40 @@ public class PdeSketchbook {
|
||||
}
|
||||
|
||||
|
||||
public String handleOpen() {
|
||||
FileDialog fd = new FileDialog(new Frame(),
|
||||
"Open a Processing sketch...",
|
||||
FileDialog.LOAD);
|
||||
if (handleOpenDirectory == null) {
|
||||
handleOpenDirectory = PdePreferences.get("sketchbook.path");
|
||||
}
|
||||
fd.setDirectory(handleOpenDirectory);
|
||||
|
||||
// only show .pde files as eligible bachelors
|
||||
fd.setFilenameFilter(new FilenameFilter() {
|
||||
public boolean accept(File dir, String name) {
|
||||
return name.endsWith(".pde");
|
||||
}
|
||||
});
|
||||
|
||||
// gimme some money
|
||||
fd.show();
|
||||
|
||||
// what in the hell yu want, boy?
|
||||
String directory = fd.getDirectory();
|
||||
String filename = fd.getFile();
|
||||
|
||||
// user cancelled selection
|
||||
if (filename == null) return null;
|
||||
|
||||
// this may come in handy sometime
|
||||
handleOpenDirectory = directory;
|
||||
|
||||
File selection = new File(directory, filename);
|
||||
return selection.getAbsolutePath();
|
||||
}
|
||||
|
||||
|
||||
// listener for sketchbk items uses getParent() to figure out
|
||||
// the directories above it
|
||||
|
||||
@@ -261,6 +303,9 @@ public class PdeSketchbook {
|
||||
* Clear out projects that are empty.
|
||||
*/
|
||||
public void clean() {
|
||||
System.err.println("TODO sketchbook.clean() is disabled");
|
||||
if (true) return; // fool the compiler
|
||||
|
||||
if (!PdePreferences.getBoolean("sketchbook.auto_clean")) return;
|
||||
|
||||
//String userPath = base.sketchbookPath + File.separator + userName;
|
||||
|
||||
+63
-6
@@ -42,6 +42,13 @@ X if this causes trouble, change the preference for lib/pde.properties
|
||||
X compiler.substitute_unicode = false
|
||||
X option to set what browser is in use
|
||||
_ http://processing.org/discourse/yabb/YaBB.cgi?board=Proce55ing_Software;action=display;num=1074106123;start=0
|
||||
X implement concave/convex polygons
|
||||
X code from carlos that was patched into old graphics
|
||||
|
||||
toxi
|
||||
X sphereDetail() function + reference
|
||||
X optimized the flat_rect() function for solid colours (20% faster)
|
||||
X noise() is (partially) broken in v67
|
||||
|
||||
goodbye macos9
|
||||
X posted to message board about it going away
|
||||
@@ -73,6 +80,49 @@ o http://processing.org/discourse/yabb/YaBB.cgi?board=Proce55ing_Software;acti
|
||||
o try ariel's Thread.yield() suggestion
|
||||
o set default framerate of 24? 30? 2x that?
|
||||
|
||||
|
||||
_ notify toxi when i know how soon before i'm going to release 68
|
||||
|
||||
_ put SecurityException things around file i/o for applets
|
||||
_ rather than checking online(), since applets might be signed
|
||||
_ shut off the automatic gunzipping
|
||||
|
||||
_ shift-backspace doesn't work in the editor
|
||||
_ http://processing.org/discourse/yabb/YaBB.cgi?board=Proce55ing_software_bugs;action=display;num=1074192817;start=0
|
||||
|
||||
_ key codes not properly coming through for UP/DOWN/etc
|
||||
_ http://processing.org/discourse/yabb/YaBB.cgi?board=Proce55ing_software_bugs;action=display;num=1075138932;start=0
|
||||
|
||||
eclipse when running in debug mode:
|
||||
ps -w -w -axo command | grep java
|
||||
/System/Library/Frameworks/JavaVM.framework/Versions/1.4.1/Home/bin/java -Djava.security.policy=java.policy.applet -classpath /Users/fry/Desktop/eclipse/workspace/javatest -Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp transport=dt_socket,suspend=y,address=localhost:10506 sun.applet.AppletViewer
|
||||
|
||||
whoa.. BGraphics.screenX() et al had the camera stuff shut off
|
||||
and that's what shipped in 67. shite.
|
||||
need to get things fixed up properly so camera is properly set
|
||||
ISOMETRIC was completely broken.. need to implement properly
|
||||
also, the default camera is perspective
|
||||
|
||||
_ split() function splits strings
|
||||
_ ints() converts an array of strings/doubles/floats to an int array
|
||||
_ split() should also use StringTokenizer
|
||||
_ to do countTokens() and then stuff into an array
|
||||
_ shave() or chomp() or trim() method to remove whitespace on either side
|
||||
_ including unicode nbsp
|
||||
_ check ordering of split() in java vs perl for regexp
|
||||
_ make a note in the docs about using split
|
||||
_ StrList.subset(3); subsets starting at 3
|
||||
_ other matlab style commands
|
||||
_ die() command to exit an application or just stall out an applet
|
||||
_ die(String error) and die(String error, Exception e)
|
||||
_ knows not to die when run as an application in p5 env because
|
||||
_ the leecherror will be non-null (otherwise external, so die is ok)
|
||||
|
||||
_ commands for askSerialPort() and askVideoInput?
|
||||
_ like the askFile() command, prompt for the port to use
|
||||
_ or just store it for later use
|
||||
_ fileBrowser / serialPortBrowser / cameraBrowser or videoBrowser ?
|
||||
|
||||
_ once compiling again, change PdeException
|
||||
_ rename the class for a minute to find all references
|
||||
_ then add references to the *file index* in question
|
||||
@@ -104,17 +154,13 @@ _ sync files into lib/build rather than copying everything new
|
||||
_ check file existence and modification dates to know which to copy
|
||||
_ and which files to delete if some have been removed
|
||||
_ this also means that the file copying has to set mod dates (JDK13)
|
||||
_ http://processing.org/discourse/yabb/YaBB.cgi?board=Proce55ing_software_bugs;action=display;num=1074789934
|
||||
|
||||
when creating a new file, suggest untitled.pde
|
||||
they can put a .java or .pde extension on the file
|
||||
if no extension is found, add the .pde extension
|
||||
if the file has a .pde extension, then it will be run through the preproc.
|
||||
|
||||
code coming from toxi
|
||||
_ sphereDetail() function + reference
|
||||
_ optimized the flat_rect() function for solid colours (20% faster)
|
||||
_ noise() is (partially) broken in v67
|
||||
|
||||
_ option for having multiple files open
|
||||
X need ui for tabs from casey
|
||||
X tabbed interface for multiple files
|
||||
@@ -123,6 +169,8 @@ _ "new text java/pde file" menu item
|
||||
|
||||
|
||||
SKETCHBOOK
|
||||
_ sort sketch names in the open menu
|
||||
_ http://processing.org/discourse/yabb/YaBB.cgi?board=Proce55ing_software_bugs;action=display;num=1074981609
|
||||
_ sketch.properties should go into user.home
|
||||
_ otherwise moving sketch folder will kill it
|
||||
_ last-used sketch not being saved
|
||||
@@ -146,6 +194,7 @@ _ when 'skNew' is cancelled in 'open' mode, nullpointerex at the top
|
||||
|
||||
EXAMPLES
|
||||
_ check if file is read-only, and if so, ask where to put sketch
|
||||
_ http://processing.org/discourse/yabb/YaBB.cgi?board=Proce55ing_Software;action=display;num=1075149564;start=0
|
||||
_ how to handle examples: read only, somewhere inside lib
|
||||
_ move examples to folder that goes w/ p5 app
|
||||
_ set examples somehow read-only
|
||||
@@ -174,7 +223,6 @@ _ switch to PImage, PApplet, etc
|
||||
_ update() mode needs to be hacked in
|
||||
_ separating of BGraphics and BApplet
|
||||
_ change copyrights on the files again (to match ?)
|
||||
_ concave/convex polygons
|
||||
_ proper lineweight
|
||||
_ camera clipping
|
||||
_ put screenshots into their sketch folder
|
||||
@@ -295,6 +343,9 @@ _ http://processing.org/discourse/yabb/YaBB.cgi?board=Proce55ing_software_bugs
|
||||
|
||||
|
||||
CONSOLE
|
||||
_ error messages run off the edge and go invisible
|
||||
_ actually this is just for the editor status box
|
||||
_ http://processing.org/discourse/yabb/YaBB.cgi?board=Proce55ing_software_bugs;action=display;num=1074894329
|
||||
_ set max frame rate at 60 fps? avoid the full-on spew to the console
|
||||
_ console runs really really slow with a lot of println() calls
|
||||
_ http://processing.org/discourse/yabb/YaBB.cgi?board=Proce55ing_software_bugs;action=display;num=1064182823
|
||||
@@ -705,6 +756,10 @@ PDE / Details
|
||||
1 _ and on second find run, should instead select all the find string
|
||||
1 _ so that typing will replace it directly
|
||||
|
||||
1 _ rename/saveas doesn't properly have its focus set
|
||||
1 _ the whole thing is selected, but not directly editable
|
||||
1 _ http://processing.org/discourse/yabb/YaBB.cgi?board=Proce55ing_Software;action=display;num=1075149929
|
||||
|
||||
|
||||
PDE / Font Builder
|
||||
|
||||
@@ -773,6 +828,8 @@ DISTRIBUTION / Windows
|
||||
|
||||
DISTRIBUTION / Linux
|
||||
b _ splash screen
|
||||
1 _ ctrl-t is not stopping a sketch
|
||||
1 _ http://processing.org/discourse/yabb/YaBB.cgi?board=Proce55ing_software_bugs;action=display;num=1074810469
|
||||
|
||||
|
||||
DISTRIBUTION / Mac OS X
|
||||
|
||||
Reference in New Issue
Block a user