diff --git a/app/src/processing/app/EditorState.java b/app/src/processing/app/EditorState.java index 9f2660f39..52395df6d 100644 --- a/app/src/processing/app/EditorState.java +++ b/app/src/processing/app/EditorState.java @@ -18,7 +18,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ + */ package processing.app; @@ -26,160 +26,184 @@ import java.awt.GraphicsConfiguration; import java.awt.GraphicsDevice; import java.awt.GraphicsEnvironment; import java.awt.Rectangle; -import java.io.BufferedReader; -import java.io.IOException; -import java.io.PrintWriter; +import java.io.*; import java.util.List; +//import processing.core.PApplet; -import processing.core.PApplet; - public class EditorState { - // path to the main .pde file for the sketch +// scenarios: +// 1) new untitled sketch (needs device, needs bounds) +// 2) restoring sketch from recent menu +// - device cannot be found +// - device is found but it's a different size +// - device is found and size is correct +// 3) re-opening sketch in a new mode + + +public class EditorState { + // path to the main .pde file for the sketch // String path; - // placement of the window + // placement of the window // int windowX, windowY, windowW, windowH; - Rectangle editorBounds; - int dividerLocation; - // width/height of the screen on which this window was placed + Rectangle editorBounds; + int dividerLocation; + // width/height of the screen on which this window was placed // int displayW, displayH; - String deviceName; - Rectangle deviceBounds; +// String deviceName; // not really useful b/c it's more about bounds anyway + Rectangle deviceBounds; - - EditorState(List editors) { - defaultConfig(); - defaultLocation(editors); - } - - - EditorState(BufferedReader reader) throws IOException { - String line = reader.readLine(); - String[] pieces = PApplet.split(line, '\t'); + + /** + * Create a fresh editor state object from the default screen device and + * set its placement relative to the last opened window. + * @param editors List of active editor objects + */ + EditorState(List editors) { + defaultConfig(); + defaultLocation(editors); + } + + +// EditorState(BufferedReader reader) throws IOException { +// String line = reader.readLine(); + EditorState(String[] pieces) throws IOException { +// String line = reader.readLine(); +// String[] pieces = PApplet.split(line, '\t'); +// String[] pieces = PApplet.split(line, ','); // path = pieces[0]; - + + editorBounds = new Rectangle(Integer.parseInt(pieces[0]), + Integer.parseInt(pieces[1]), + Integer.parseInt(pieces[2]), + Integer.parseInt(pieces[3])); + + dividerLocation = Integer.parseInt(pieces[4]); + + deviceBounds = new Rectangle(Integer.parseInt(pieces[5]), + Integer.parseInt(pieces[6]), + Integer.parseInt(pieces[7]), + Integer.parseInt(pieces[8])); + // windowX = Integer.parseInt(pieces[1]); // windowY = Integer.parseInt(pieces[2]); // windowW = Integer.parseInt(pieces[3]); // windowH = Integer.parseInt(pieces[4]); - + // displayW = Integer.parseInt(pieces[5]); // displayH = Integer.parseInt(pieces[6]); - } + } - // scenarios: - // 1) new untitled sketch (needs device, needs bounds) - // 2) restoring sketch from recent menu - // - device cannot be found - // - device is found but it's a different size - // - device is found and size is correct - // 3) re-opening sketch in a new mode - - GraphicsConfiguration checkConfig() { - GraphicsEnvironment graphicsEnvironment = - GraphicsEnvironment.getLocalGraphicsEnvironment(); - GraphicsDevice[] screenDevices = graphicsEnvironment.getScreenDevices(); - for (GraphicsDevice device : screenDevices) { - GraphicsConfiguration[] configurations = device.getConfigurations(); - for (GraphicsConfiguration config : configurations) { - if (config.getDevice().getIDstring().equals(deviceName)) { - if (deviceBounds != null && config.getBounds().equals(deviceBounds)) { - return config; - } else { - - } - } - } - } - // otherwise go to the default config - return defaultConfig(); - } - - - GraphicsConfiguration defaultConfig() { - GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); - GraphicsDevice device = ge.getDefaultScreenDevice(); - GraphicsConfiguration config = device.getDefaultConfiguration(); - deviceName = device.getIDstring(); - deviceBounds = config.getBounds(); - return config; - } - - - void defaultLocation(List editors) { - int defaultWidth = Preferences.getInteger("editor.window.width.default"); - int defaultHeight = Preferences.getInteger("editor.window.height.default"); - - if (editors.size() == 0) { - // If no current active editor, use default placement. - // Center the window on ths screen, taking into account that the - // upper-left corner of the device may have a non (0, 0) origin. - int editorX = - deviceBounds.x + (deviceBounds.width - defaultWidth) / 2; - int editorY = - deviceBounds.y + (deviceBounds.height - defaultHeight) / 2; - editorBounds = - new Rectangle(editorX, editorY, defaultWidth, defaultHeight); - dividerLocation = 0; - - } else { - // With a currently active editor, open the new window using the same - // dimensions and divider location, but offset slightly. - synchronized (editors) { - final int OVER = 50; - Editor lastOpened = editors.get(editors.size() - 1); - editorBounds = lastOpened.getBounds(); - editorBounds.x += OVER; - editorBounds.y += OVER; - dividerLocation = lastOpened.getDividerLocation(); - - if (!deviceBounds.contains(editorBounds)) { - // Warp the next window to a randomish location on screen. - editorBounds.x = deviceBounds.x + (int) (Math.random() * (deviceBounds.width - defaultWidth)); - editorBounds.y = deviceBounds.y + (int) (Math.random() * (deviceBounds.height - defaultHeight)); - } + + GraphicsConfiguration checkConfig() { + GraphicsEnvironment graphicsEnvironment = + GraphicsEnvironment.getLocalGraphicsEnvironment(); + GraphicsDevice[] screenDevices = graphicsEnvironment.getScreenDevices(); + for (GraphicsDevice device : screenDevices) { + GraphicsConfiguration[] configurations = device.getConfigurations(); + for (GraphicsConfiguration config : configurations) { +// if (config.getDevice().getIDstring().equals(deviceName)) { + if (deviceBounds != null && config.getBounds().equals(deviceBounds)) { + return config; +// } else { +// } } } } + // otherwise go to the default config + return defaultConfig(); + } - void update(Editor editor) { + GraphicsConfiguration defaultConfig() { + GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); + GraphicsDevice device = ge.getDefaultScreenDevice(); + GraphicsConfiguration config = device.getDefaultConfiguration(); +// deviceName = device.getIDstring(); + deviceBounds = config.getBounds(); + return config; + } + + + /** + * Figure out the next location by sizing up the last editor in the list. + * If no editors are opened, it'll just open on the main screen. + * @param editors List of editors currently opened + */ + void defaultLocation(List editors) { + int defaultWidth = Preferences.getInteger("editor.window.width.default"); + int defaultHeight = Preferences.getInteger("editor.window.height.default"); + + if (editors.size() == 0) { + // If no current active editor, use default placement. + // Center the window on ths screen, taking into account that the + // upper-left corner of the device may have a non (0, 0) origin. + int editorX = + deviceBounds.x + (deviceBounds.width - defaultWidth) / 2; + int editorY = + deviceBounds.y + (deviceBounds.height - defaultHeight) / 2; + editorBounds = + new Rectangle(editorX, editorY, defaultWidth, defaultHeight); + dividerLocation = 0; + + } else { + // With a currently active editor, open the new window using the same + // dimensions and divider location, but offset slightly. + synchronized (editors) { + final int OVER = 50; + Editor lastOpened = editors.get(editors.size() - 1); + editorBounds = lastOpened.getBounds(); + editorBounds.x += OVER; + editorBounds.y += OVER; + dividerLocation = lastOpened.getDividerLocation(); + + if (!deviceBounds.contains(editorBounds)) { + // Warp the next window to a randomish location on screen. + editorBounds.x = deviceBounds.x + (int) (Math.random() * (deviceBounds.width - defaultWidth)); + editorBounds.y = deviceBounds.y + (int) (Math.random() * (deviceBounds.height - defaultHeight)); + } + } + } + } + + + void update(Editor editor) { // path = editor.getSketch().getMainFilePath(); - editorBounds = editor.getBounds(); - dividerLocation = editor.getDividerLocation(); - GraphicsConfiguration config = editor.getGraphicsConfiguration(); - GraphicsDevice device = config.getDevice(); - deviceBounds = config.getBounds(); - deviceName = device.getIDstring(); - } + editorBounds = editor.getBounds(); + dividerLocation = editor.getDividerLocation(); + GraphicsConfiguration config = editor.getGraphicsConfiguration(); +// GraphicsDevice device = config.getDevice(); + deviceBounds = config.getBounds(); +// deviceName = device.getIDstring(); + } - void apply(Editor editor) { - editor.setBounds(editorBounds); - if (dividerLocation != 0) { - editor.setDividerLocation(dividerLocation); - } + void apply(Editor editor) { + editor.setBounds(editorBounds); + if (dividerLocation != 0) { + editor.setDividerLocation(dividerLocation); } - - - void write(PrintWriter writer) { + } + + + void write(PrintWriter writer) { // writer.print(path); - writer.print('\t'); - writeRect(writer, editorBounds); - writer.print('\t'); - writer.print(deviceName); - writer.print('\t'); - writeRect(writer, deviceBounds); - } + writer.print('\t'); + writeRect(writer, editorBounds); +// writer.print('\t'); +// writer.print(deviceName); + writer.print('\t'); + writeRect(writer, deviceBounds); + } - void writeRect(PrintWriter writer, Rectangle rect) { - writer.print(rect.x); - writer.print('\t'); - writer.print(rect.y); - writer.print('\t'); - writer.print(rect.width); - writer.print('\t'); - writer.print(rect.height); - } - } \ No newline at end of file + void writeRect(PrintWriter writer, Rectangle rect) { + writer.print(rect.x); + writer.print('\t'); + writer.print(rect.y); + writer.print('\t'); + writer.print(rect.width); + writer.print('\t'); + writer.print(rect.height); + } +} \ No newline at end of file diff --git a/app/src/processing/app/Preferences.java b/app/src/processing/app/Preferences.java index 02c0493b9..eb881464a 100644 --- a/app/src/processing/app/Preferences.java +++ b/app/src/processing/app/Preferences.java @@ -362,6 +362,7 @@ public class Preferences { displayLabel.setToolTipText(tip); displayBox.add(displayLabel); displaySelectionBox = new JComboBox(); + updateDisplayList(); // needs to happen here for getPreferredSize() displayBox.add(displaySelectionBox); pain.add(displayBox); d = displayBox.getPreferredSize(); diff --git a/app/src/processing/app/Recent.java b/app/src/processing/app/Recent.java index e0df2ee59..ae1ab4be1 100644 --- a/app/src/processing/app/Recent.java +++ b/app/src/processing/app/Recent.java @@ -21,11 +21,6 @@ package processing.app; -import java.awt.Dimension; -import java.awt.GraphicsConfiguration; -import java.awt.GraphicsDevice; -import java.awt.Rectangle; -import java.awt.Toolkit; import java.io.*; import processing.core.PApplet; diff --git a/app/src/processing/mode/java/runner/Runner.java b/app/src/processing/mode/java/runner/Runner.java index bc0e9abcd..51bc208c8 100644 --- a/app/src/processing/mode/java/runner/Runner.java +++ b/app/src/processing/mode/java/runner/Runner.java @@ -31,7 +31,6 @@ import processing.mode.java.JavaBuild; import java.awt.GraphicsDevice; import java.awt.GraphicsEnvironment; import java.awt.Point; -import java.awt.Rectangle; import java.io.*; import java.util.*; diff --git a/core/todo.txt b/core/todo.txt index 391dbbb02..853574748 100644 --- a/core/todo.txt +++ b/core/todo.txt @@ -56,6 +56,8 @@ _ decide on naming for the next release _ wiki.processing.org/w/Window_Size_and_Full_Screen _ static mode sketches seem to break ESC... noLoop() problem? +_ need to find another way to get ESC on static mode +_ b/c static mode sketches *do* finish because they have no draw() _ PUtil -> move match(), lots of other non-gui functions into own class _ and merge it in statically via the methods code diff --git a/todo.txt b/todo.txt index 0f6efd500..756537e5b 100644 --- a/todo.txt +++ b/todo.txt @@ -3,6 +3,9 @@ X fix up some of the error messages inside Compiler X when internal tools crash, don't add them to the menu X (prevents the PDE from locking up on startup) +_ add redirects from dev.processing.org again, plus dns entry +_ old bugs db links no longer working + displays X ability to select monitor via preferences panel X this applies to any applet that's run externally currently (verify) @@ -21,10 +24,8 @@ X get rid of restore sketch feature _ remove pref for restoring sketches _ implement recent sketches menu _ casey: recent sketches is a yes, window menu could go either way -window menu: -http://code.google.com/p/processing/issues/detail?id=545 -recent sketches: -http://code.google.com/p/processing/issues/detail?id=188 +window menu: http://code.google.com/p/processing/issues/detail?id=545 +recent sketches: http://code.google.com/p/processing/issues/detail?id=188 _ multiple sketch windows.. having a windows menu? _ examples button on toolbar? open / recent / sketchbook? _ add "recent files" list to open menu? @@ -42,6 +43,10 @@ _ http://dev.processing.org/bugs/show_bug.cgi?id=72 _ http://code.google.com/p/processing/issues/detail?id=27 Base.restoreSketches() has commented out code that checked for out of bounds windows with the preferences last.window.x and last.window.y. These prefs don't exist anymore, but it would be quick to implement it again using last.sketch.location instead. It would probably result in less code, because it would mean we could get rid of the windowPositionValid stuff. +2.0 +_ decide whether to do same as Android preproc on parsing size/renderer/etc + + _ find in reference for copy() (on image) tries to open PVector.copy() _ might need disambiguation pages? _ if a reference page is missing, throws a bunch of exceptions @@ -1021,6 +1026,7 @@ _ http://code.google.com/p/processing/issues/detail?id=157 _ don't allow people to override methods like paint() _ make them final? just improve the error messages? _ http://dev.processing.org/bugs/show_bug.cgi?id=1219 +_ http://processing.org/bugs/bugzilla/1219.html _ Processing chokes if a sketch defines a class with same name as the sketch _ http://dev.processing.org/bugs/show_bug.cgi?id=1199 _ http://dev.processing.org/bugs/show_bug.cgi?id=1294