diff --git a/core/src/processing/core/PApplet.java b/core/src/processing/core/PApplet.java index cc1d66116..ca75e3695 100644 --- a/core/src/processing/core/PApplet.java +++ b/core/src/processing/core/PApplet.java @@ -9585,9 +9585,34 @@ public class PApplet implements PConstants { g = createPrimaryGraphics(); surface = g.createSurface(); if (g.displayable()) { - frame = surface.initFrame(this, backgroundColor, displayIndex, present, spanDisplays); - //surface.setTitle(getClass().getName()); - frame.setTitle(getClass().getName()); + frame = new Frame() { + @Override + public void setResizable(boolean resizable) { + deprecationWarning("setResizable"); + surface.setResizable(resizable); + } + + @Override + public void setVisible(boolean visible) { + deprecationWarning("setVisible"); + surface.setVisible(visible); + } + + @Override + public void setTitle(String title) { + deprecationWarning("setTitle"); + surface.setTitle(title); + } + + private void deprecationWarning(String method) { + PGraphics.showWarning("Use surface." + method + "() instead of " + + "frame." + method + " in Processing 3"); + } + }; + + surface.initFrame(this, backgroundColor, displayIndex, present, spanDisplays); + surface.setTitle(getClass().getName()); + //frame.setTitle(getClass().getName()); // } else { // // TODO necessary? // surface.initOffscreen(this); diff --git a/core/src/processing/core/PSurface.java b/core/src/processing/core/PSurface.java index 4a8a39204..7120d2165 100644 --- a/core/src/processing/core/PSurface.java +++ b/core/src/processing/core/PSurface.java @@ -24,7 +24,6 @@ package processing.core; import java.awt.Color; import java.awt.Component; -import java.awt.Frame; public interface PSurface { @@ -48,8 +47,9 @@ public interface PSurface { public Component initComponent(PApplet sketch); - public Frame initFrame(PApplet sketch, Color backgroundColor, - int deviceIndex, boolean fullScreen, boolean spanDisplays); + //public Frame initFrame(PApplet sketch, Color backgroundColor, + public void initFrame(PApplet sketch, Color backgroundColor, + int deviceIndex, boolean fullScreen, boolean spanDisplays); // @@ -57,14 +57,14 @@ public interface PSurface { // Silly, but prevents a lot of rewrite and extra methods for little benefit. // However, maybe prevents us from having to document the 'frame' variable? -// /** Set the window (and dock, or whatever necessary) title. */ -// public void setTitle(String title); -// -// /** Show or hide the window. */ -// public void setVisible(boolean visible); -// -// /** Set true if we want to resize things (default is not resizable) */ -// public void setResizable(boolean resizable); + /** Set the window (and dock, or whatever necessary) title. */ + public void setTitle(String title); + + /** Show or hide the window. */ + public void setVisible(boolean visible); + + /** Set true if we want to resize things (default is not resizable) */ + public void setResizable(boolean resizable); // diff --git a/core/src/processing/core/PSurfaceAWT.java b/core/src/processing/core/PSurfaceAWT.java index 797367128..3734accd7 100644 --- a/core/src/processing/core/PSurfaceAWT.java +++ b/core/src/processing/core/PSurfaceAWT.java @@ -387,7 +387,7 @@ public class PSurfaceAWT extends PSurfaceNone { @Override - public Frame initFrame(PApplet sketch, Color backgroundColor, + public void initFrame(PApplet sketch, Color backgroundColor, int deviceIndex, boolean fullScreen, boolean spanDisplays) { this.sketch = sketch; @@ -514,46 +514,49 @@ public class PSurfaceAWT extends PSurfaceNone { // http://code.google.com/p/processing/issues/detail?id=467 frame.setResizable(false); - return frame; +// return frame; } -// /** Set the window (and dock, or whatever necessary) title. */ -// public void setTitle(String title) { -// frame.setTitle(title); -// } -// -// -// /** Set true if we want to resize things (default is not resizable) */ -// public void setResizable(boolean resizable) { -// this.resizable = resizable; // really only used for canvas -// -// if (frame != null) { -// frame.setResizable(resizable); -// } -// } -// -// -// public void setVisible(boolean visible) { -// frame.setVisible(visible); -// -// // removing per https://github.com/processing/processing/pull/3162 -// // can remove the code below once 3.0a6 is tested and behaving -///* -// if (visible && PApplet.platform == PConstants.LINUX) { -// // Linux doesn't deal with insets the same way. We get fake insets -// // earlier, and then the window manager will slap its own insets -// // onto things once the frame is realized on the screen. Awzm. -// if (PApplet.platform == PConstants.LINUX) { -// Insets insets = frame.getInsets(); -// frame.setSize(Math.max(sketchWidth, MIN_WINDOW_WIDTH) + -// insets.left + insets.right, -// Math.max(sketchHeight, MIN_WINDOW_HEIGHT) + -// insets.top + insets.bottom); -// } -// } -//*/ -// } + /** Set the window (and dock, or whatever necessary) title. */ + @Override + public void setTitle(String title) { + frame.setTitle(title); + } + + + /** Set true if we want to resize things (default is not resizable) */ + @Override + public void setResizable(boolean resizable) { + //this.resizable = resizable; // really only used for canvas + + if (frame != null) { + frame.setResizable(resizable); + } + } + + + @Override + public void setVisible(boolean visible) { + frame.setVisible(visible); + + // removing per https://github.com/processing/processing/pull/3162 + // can remove the code below once 3.0a6 is tested and behaving +/* + if (visible && PApplet.platform == PConstants.LINUX) { + // Linux doesn't deal with insets the same way. We get fake insets + // earlier, and then the window manager will slap its own insets + // onto things once the frame is realized on the screen. Awzm. + if (PApplet.platform == PConstants.LINUX) { + Insets insets = frame.getInsets(); + frame.setSize(Math.max(sketchWidth, MIN_WINDOW_WIDTH) + + insets.left + insets.right, + Math.max(sketchHeight, MIN_WINDOW_HEIGHT) + + insets.top + insets.bottom); + } + } +*/ + } //public void placeFullScreen(boolean hideStop) { diff --git a/core/src/processing/core/PSurfaceFX.java b/core/src/processing/core/PSurfaceFX.java index 0073cf701..2956f3ada 100644 --- a/core/src/processing/core/PSurfaceFX.java +++ b/core/src/processing/core/PSurfaceFX.java @@ -167,48 +167,67 @@ public class PSurfaceFX implements PSurface { } - public Frame initFrame(PApplet sketch, java.awt.Color backgroundColor, + //public Frame initFrame(PApplet sketch, java.awt.Color backgroundColor, + public void initFrame(PApplet sketch, java.awt.Color backgroundColor, int deviceIndex, boolean fullScreen, boolean spanDisplays) { this.sketch = sketch; PApplicationFX.surface = this; - Frame frame = new DummyFrame(); + //Frame frame = new DummyFrame(); new Thread(new Runnable() { public void run() { Application.launch(PApplicationFX.class); } }).start(); - return frame; + //return frame; } - class DummyFrame extends Frame { - - public DummyFrame() { - super(); - } - - @Override - public void setResizable(boolean resizable) { - // TODO - } - - @Override - public void setVisible(boolean visible) { - stage.show(); - } - - @Override - public void setTitle(String title) { - if (stage != null) { - stage.setTitle(title); - } else { - System.err.println("stage was null for setTitle()"); - } - } + /** Set the window (and dock, or whatever necessary) title. */ + public void setTitle(String title) { + // TODO ignored? } + /** Show or hide the window. */ + public void setVisible(boolean visible) { + // TODO ignored? + } + + + /** Set true if we want to resize things (default is not resizable) */ + public void setResizable(boolean resizable) { + // TODO ignored? + } + + +// class DummyFrame extends Frame { +// +// public DummyFrame() { +// super(); +// } +// +// @Override +// public void setResizable(boolean resizable) { +// // TODO +// } +// +// @Override +// public void setVisible(boolean visible) { +// stage.show(); +// } +// +// @Override +// public void setTitle(String title) { +// if (stage != null) { +// stage.setTitle(title); +// } else { +// System.err.println("stage was null for setTitle()"); +// } +// } +// } + + /* public class PApplicationFX extends Application { diff --git a/core/src/processing/core/PSurfaceNone.java b/core/src/processing/core/PSurfaceNone.java index a7d830394..c0d0bc0e4 100644 --- a/core/src/processing/core/PSurfaceNone.java +++ b/core/src/processing/core/PSurfaceNone.java @@ -24,7 +24,6 @@ package processing.core; import java.awt.Color; import java.awt.Component; -import java.awt.Frame; /** @@ -55,10 +54,27 @@ public class PSurfaceNone implements PSurface { } - public Frame initFrame(PApplet sketch, Color backgroundColor, + public void initFrame(PApplet sketch, Color backgroundColor, int deviceIndex, boolean fullScreen, boolean spanDisplays) { - return null; + } + + + /** Set the window (and dock, or whatever necessary) title. */ + public void setTitle(String title) { + // TODO ignored? + } + + + /** Show or hide the window. */ + public void setVisible(boolean visible) { + // TODO ignored? + } + + + /** Set true if we want to resize things (default is not resizable) */ + public void setResizable(boolean resizable) { + // TODO ignored? } diff --git a/core/src/processing/opengl/PSurfaceLWJGL.java b/core/src/processing/opengl/PSurfaceLWJGL.java index e20972c7c..433311609 100644 --- a/core/src/processing/opengl/PSurfaceLWJGL.java +++ b/core/src/processing/opengl/PSurfaceLWJGL.java @@ -104,7 +104,7 @@ public class PSurfaceLWJGL implements PSurface { @Override - public Frame initFrame(PApplet sketch, Color backgroundColor, + public void initFrame(PApplet sketch, Color backgroundColor, int deviceIndex, boolean fullScreen, boolean spanDisplays) { this.sketch = sketch; @@ -214,8 +214,8 @@ public class PSurfaceLWJGL implements PSurface { // sketchWidth = sketch.width = sketch.sketchWidth(); // sketchHeight = sketch.height = sketch.sketchHeight(); - frame = new DummyFrame(); - return frame; +// frame = new DummyFrame(); +// return frame; } @@ -233,24 +233,24 @@ public class PSurfaceLWJGL implements PSurface { } -// @Override -// public void setTitle(String title) { -// Display.setTitle(title); -// } -// -// -// @Override -// public void setVisible(boolean visible) { -// // Apparently not possible: -// // http://forum.lwjgl.org/index.php?topic=5388.0 -// System.err.println("Cannot set visibility of window in OpenGL"); -// } -// -// -// @Override -// public void setResizable(boolean resizable) { -// Display.setResizable(resizable); -// } + @Override + public void setTitle(String title) { + Display.setTitle(title); + } + + + @Override + public void setVisible(boolean visible) { + // Apparently not possible: + // http://forum.lwjgl.org/index.php?topic=5388.0 + System.err.println("Cannot set visibility of window in OpenGL"); + } + + + @Override + public void setResizable(boolean resizable) { + Display.setResizable(resizable); + } @Override @@ -607,28 +607,28 @@ public class PSurfaceLWJGL implements PSurface { } - @SuppressWarnings("serial") - class DummyFrame extends Frame { - - public DummyFrame() { - super(); - } - - @Override - public void setResizable(boolean resizable) { - Display.setResizable(resizable); - } - - @Override - public void setVisible(boolean visible) { - System.err.println("Cannot set visibility of window in OpenGL"); - } - - @Override - public void setTitle(String title) { - Display.setTitle(title); - } - } +// @SuppressWarnings("serial") +// class DummyFrame extends Frame { +// +// public DummyFrame() { +// super(); +// } +// +// @Override +// public void setResizable(boolean resizable) { +// Display.setResizable(resizable); +// } +// +// @Override +// public void setVisible(boolean visible) { +// System.err.println("Cannot set visibility of window in OpenGL"); +// } +// +// @Override +// public void setTitle(String title) { +// Display.setTitle(title); +// } +// } diff --git a/java/libraries/jogl/src/processing/jogl/PSurfaceJOGL.java b/java/libraries/jogl/src/processing/jogl/PSurfaceJOGL.java index 35f854adc..c484c7f79 100644 --- a/java/libraries/jogl/src/processing/jogl/PSurfaceJOGL.java +++ b/java/libraries/jogl/src/processing/jogl/PSurfaceJOGL.java @@ -91,7 +91,7 @@ public class PSurfaceJOGL implements PSurface { return null; } - public Frame initFrame(PApplet sketch, Color backgroundColor, + public void initFrame(PApplet sketch, Color backgroundColor, int deviceIndex, boolean fullScreen, boolean spanDisplays) { this.sketch = sketch; @@ -321,42 +321,45 @@ public class PSurfaceJOGL implements PSurface { // error setting the window visible, should quit... } - frame = new DummyFrame(); - return frame; +// frame = new DummyFrame(); +// return frame; } - @SuppressWarnings("serial") - class DummyFrame extends Frame { - - public DummyFrame() { - super(); - } - - @Override - public void setResizable(boolean resizable) { -// super.setResizable(resizable); - } - - @Override - public void setVisible(boolean visible) { - window.setVisible(visible); - } - - @Override - public void setTitle(String title) { - window.setTitle(title); - } - } +// @SuppressWarnings("serial") +// class DummyFrame extends Frame { +// +// public DummyFrame() { +// super(); +// } +// +// @Override +// public void setResizable(boolean resizable) { +//// super.setResizable(resizable); +// } +// +// @Override +// public void setVisible(boolean visible) { +// window.setVisible(visible); +// } +// +// @Override +// public void setTitle(String title) { +// window.setTitle(title); +// } +// } + @Override public void setTitle(String title) { window.setTitle(title); } + @Override public void setVisible(boolean visible) { window.setVisible(visible); } + @Override public void setResizable(boolean resizable) { // TODO Auto-generated method stub