mirror of
https://github.com/processing/processing4.git
synced 2026-02-14 10:55:38 +01:00
window placement, and exact placement now working for external
This commit is contained in:
@@ -472,7 +472,7 @@ public class PdeBase extends Frame
|
||||
menu.add(new MenuItem("Stop", new MenuShortcut('T')));
|
||||
menu.addSeparator();
|
||||
|
||||
menu.add(new MenuItem("Add data file..."));
|
||||
menu.add(new MenuItem("Add file..."));
|
||||
menu.add(new MenuItem("Create font..."));
|
||||
|
||||
if ((platform == WINDOWS) || (platform == MACOSX)) {
|
||||
@@ -1101,8 +1101,8 @@ public class PdeBase extends Frame
|
||||
} else if (command.equals("Beautify")) {
|
||||
editor.doBeautify();
|
||||
|
||||
} else if (command.equals("Add data file...")) {
|
||||
editor.addDataFile();
|
||||
} else if (command.equals("Add file...")) {
|
||||
editor.addFile();
|
||||
|
||||
} else if (command.equals("Create font...")) {
|
||||
new PdeFontBuilder(new File(editor.sketchDir, "data"));
|
||||
|
||||
@@ -848,7 +848,13 @@ public class PdeEditor extends JPanel {
|
||||
|
||||
} else {
|
||||
try {
|
||||
appletLocation = runtime.window.getLocation();
|
||||
// the window will also be null the process was running
|
||||
// externally. so don't even try setting if window is null
|
||||
// since PdeRuntime will set the appletLocation when an
|
||||
// external process is in use.
|
||||
if (runtime.window != null) {
|
||||
appletLocation = runtime.window.getLocation();
|
||||
}
|
||||
} catch (NullPointerException e) { }
|
||||
}
|
||||
//System.out.println("doclose2");
|
||||
@@ -1813,7 +1819,7 @@ public class PdeEditor extends JPanel {
|
||||
}
|
||||
|
||||
|
||||
public void addDataFile() {
|
||||
public void addFile() {
|
||||
// get a dialog, select a file to add to the sketch
|
||||
String prompt = "Select an image or other data file to copy to your sketch";
|
||||
FileDialog fd = new FileDialog(new Frame(), prompt, FileDialog.LOAD);
|
||||
@@ -1830,10 +1836,24 @@ public class PdeEditor extends JPanel {
|
||||
// if people don't want it to copy, they can do it by hand
|
||||
File sourceFile = new File(directory, filename);
|
||||
|
||||
File dataFolder = new File(sketchDir, "data");
|
||||
if (!dataFolder.exists()) dataFolder.mkdirs();
|
||||
File destFile = null;
|
||||
|
||||
File destFile = new File(dataFolder, filename);
|
||||
// if the file appears to be code related, drop it
|
||||
// into the code folder, instead of the data folder
|
||||
if (filename.toLowerCase().endsWith(".class") ||
|
||||
filename.toLowerCase().endsWith(".jar") ||
|
||||
filename.toLowerCase().endsWith(".dll") ||
|
||||
filename.toLowerCase().endsWith(".jnilib") ||
|
||||
filename.toLowerCase().endsWith(".so")) {
|
||||
File codeFolder = new File(sketchDir, "code");
|
||||
if (!codeFolder.exists()) codeFolder.mkdirs();
|
||||
destFile = new File(codeFolder, filename);
|
||||
|
||||
} else {
|
||||
File dataFolder = new File(sketchDir, "data");
|
||||
if (!dataFolder.exists()) dataFolder.mkdirs();
|
||||
destFile = new File(dataFolder, filename);
|
||||
}
|
||||
//System.out.println("copying from " + sourceFile);
|
||||
//System.out.println("copying to " + destFile);
|
||||
copyFile(sourceFile, destFile);
|
||||
|
||||
@@ -57,6 +57,7 @@ class PdeMessageSiphon implements Runnable {
|
||||
}
|
||||
} catch (Exception e) {
|
||||
System.err.println("PdeMessageSiphon err " + e);
|
||||
e.printStackTrace();
|
||||
//thread.stop(); // implicit (and no longer supported)
|
||||
}
|
||||
//System.err.println("siphon thread exiting");
|
||||
|
||||
@@ -68,25 +68,24 @@ public class PdeRuntime implements PdeMessageConsumer {
|
||||
|
||||
this.leechErr = leechErr;
|
||||
|
||||
//Frame frame = PdeBase.frame;
|
||||
Point parentLoc = editor.base.getLocation(); //frame.getLocation();
|
||||
Insets parentInsets = editor.base.getInsets(); //frame.getInsets();
|
||||
Point parentLoc = editor.base.getLocation();
|
||||
Insets parentInsets = editor.base.getInsets();
|
||||
|
||||
int x1 = parentLoc.x - 20;
|
||||
int y1 = parentLoc.y;
|
||||
|
||||
try {
|
||||
//if (PdeBase.getBoolean("play.external", false)) {
|
||||
//System.out.println(externalPaths);
|
||||
|
||||
if (externalRuntime) {
|
||||
//System.out.println("going external");
|
||||
String command[] = new String[] {
|
||||
"java",
|
||||
"-cp",
|
||||
externalPaths,
|
||||
"BApplet",
|
||||
"--external=" + x1 + "," + y1,
|
||||
BApplet.EXTERNAL_FLAG + ((windowLocation != null) ?
|
||||
("e" +
|
||||
windowLocation.x + "," +
|
||||
windowLocation.y) :
|
||||
(x1 + "," + y1)),
|
||||
className
|
||||
};
|
||||
|
||||
@@ -382,6 +381,16 @@ public class PdeRuntime implements PdeMessageConsumer {
|
||||
return;
|
||||
}
|
||||
|
||||
if (s.indexOf(BApplet.EXTERNAL_MOVE) == 0) {
|
||||
String nums = s.substring(s.indexOf(' ') + 1);
|
||||
int space = nums.indexOf(' ');
|
||||
int left = Integer.parseInt(nums.substring(0, space));
|
||||
int top = Integer.parseInt(nums.substring(space + 1));
|
||||
editor.appletLocation = new Point(left, top);
|
||||
//System.out.println("wanna move to " + left + " " + top);
|
||||
return;
|
||||
}
|
||||
|
||||
//System.err.println("message " + s.length() + ":" + s);
|
||||
if (s.length() > 2) System.err.println(s);
|
||||
|
||||
|
||||
12
todo.txt
12
todo.txt
@@ -6,21 +6,21 @@ X beginShape/endShape.. 3D scenes with boxes..
|
||||
X newPixels is in BGraphics.endFrame,
|
||||
X screen.drawImage is in BApplet.paint
|
||||
X need to move both to BApplet.paint()
|
||||
|
||||
_ external applet stuff
|
||||
X external applet stuff
|
||||
X set initial position of external applets via BApplet
|
||||
X closing window doesn't disable the stop button
|
||||
X hitting 'stop' should freeze applet, not close window
|
||||
o what was the random NullPointerException
|
||||
|
||||
_ 'add files' for .class, .jar should drop the stuff in
|
||||
_ send messages for window location
|
||||
_ external classes using loadStream, etc have trouble
|
||||
X send messages for window location
|
||||
X remove 'wanna move' msg, and actually record the position
|
||||
X 'add files' for .class, .jar should drop the stuff into 'code'
|
||||
o external classes using loadStream, etc have trouble
|
||||
|
||||
_ history could be gzipped and appended to history.dat
|
||||
_ along with another file that is actually a table of offsets
|
||||
_ no need to make the thing a gzip stream
|
||||
_ checkbox on menu for 'record history' ?
|
||||
_ history converter option?
|
||||
|
||||
_ jikes errors are missing newline/linefeed ?
|
||||
|
||||
|
||||
Reference in New Issue
Block a user