mirror of
https://github.com/processing/processing4.git
synced 2026-06-16 04:26:26 +02:00
move dummy Frame into PApplet, bring back Surface methods
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
//
|
||||
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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 {
|
||||
|
||||
|
||||
@@ -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?
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -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);
|
||||
// }
|
||||
// }
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user