Skip to content

Commit 9e3fb32

Browse files
committed
move dummy Frame into PApplet, bring back Surface methods
1 parent 7ebdae2 commit 9e3fb32

File tree

7 files changed

+216
-150
lines changed

7 files changed

+216
-150
lines changed

core/src/processing/core/PApplet.java

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9585,9 +9585,34 @@ protected PSurface initSurface(Color backgroundColor, int displayIndex,
95859585
g = createPrimaryGraphics();
95869586
surface = g.createSurface();
95879587
if (g.displayable()) {
9588-
frame = surface.initFrame(this, backgroundColor, displayIndex, present, spanDisplays);
9589-
//surface.setTitle(getClass().getName());
9590-
frame.setTitle(getClass().getName());
9588+
frame = new Frame() {
9589+
@Override
9590+
public void setResizable(boolean resizable) {
9591+
deprecationWarning("setResizable");
9592+
surface.setResizable(resizable);
9593+
}
9594+
9595+
@Override
9596+
public void setVisible(boolean visible) {
9597+
deprecationWarning("setVisible");
9598+
surface.setVisible(visible);
9599+
}
9600+
9601+
@Override
9602+
public void setTitle(String title) {
9603+
deprecationWarning("setTitle");
9604+
surface.setTitle(title);
9605+
}
9606+
9607+
private void deprecationWarning(String method) {
9608+
PGraphics.showWarning("Use surface." + method + "() instead of " +
9609+
"frame." + method + " in Processing 3");
9610+
}
9611+
};
9612+
9613+
surface.initFrame(this, backgroundColor, displayIndex, present, spanDisplays);
9614+
surface.setTitle(getClass().getName());
9615+
//frame.setTitle(getClass().getName());
95919616
// } else {
95929617
// // TODO necessary?
95939618
// surface.initOffscreen(this);

core/src/processing/core/PSurface.java

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424

2525
import java.awt.Color;
2626
import java.awt.Component;
27-
import java.awt.Frame;
2827

2928

3029
public interface PSurface {
@@ -48,23 +47,24 @@ public interface PSurface {
4847

4948
public Component initComponent(PApplet sketch);
5049

51-
public Frame initFrame(PApplet sketch, Color backgroundColor,
52-
int deviceIndex, boolean fullScreen, boolean spanDisplays);
50+
//public Frame initFrame(PApplet sketch, Color backgroundColor,
51+
public void initFrame(PApplet sketch, Color backgroundColor,
52+
int deviceIndex, boolean fullScreen, boolean spanDisplays);
5353

5454
//
5555

5656
// Just call these on an AWT Frame object stored in PApplet.
5757
// Silly, but prevents a lot of rewrite and extra methods for little benefit.
5858
// However, maybe prevents us from having to document the 'frame' variable?
5959

60-
// /** Set the window (and dock, or whatever necessary) title. */
61-
// public void setTitle(String title);
62-
//
63-
// /** Show or hide the window. */
64-
// public void setVisible(boolean visible);
65-
//
66-
// /** Set true if we want to resize things (default is not resizable) */
67-
// public void setResizable(boolean resizable);
60+
/** Set the window (and dock, or whatever necessary) title. */
61+
public void setTitle(String title);
62+
63+
/** Show or hide the window. */
64+
public void setVisible(boolean visible);
65+
66+
/** Set true if we want to resize things (default is not resizable) */
67+
public void setResizable(boolean resizable);
6868

6969
//
7070

core/src/processing/core/PSurfaceAWT.java

Lines changed: 41 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -387,7 +387,7 @@ public Component initComponent(PApplet sketch) {
387387

388388

389389
@Override
390-
public Frame initFrame(PApplet sketch, Color backgroundColor,
390+
public void initFrame(PApplet sketch, Color backgroundColor,
391391
int deviceIndex, boolean fullScreen, boolean spanDisplays) {
392392
this.sketch = sketch;
393393

@@ -514,46 +514,49 @@ public Frame initFrame(PApplet sketch, Color backgroundColor,
514514
// http://code.google.com/p/processing/issues/detail?id=467
515515
frame.setResizable(false);
516516

517-
return frame;
517+
// return frame;
518518
}
519519

520520

521-
// /** Set the window (and dock, or whatever necessary) title. */
522-
// public void setTitle(String title) {
523-
// frame.setTitle(title);
524-
// }
525-
//
526-
//
527-
// /** Set true if we want to resize things (default is not resizable) */
528-
// public void setResizable(boolean resizable) {
529-
// this.resizable = resizable; // really only used for canvas
530-
//
531-
// if (frame != null) {
532-
// frame.setResizable(resizable);
533-
// }
534-
// }
535-
//
536-
//
537-
// public void setVisible(boolean visible) {
538-
// frame.setVisible(visible);
539-
//
540-
// // removing per https://github.com/processing/processing/pull/3162
541-
// // can remove the code below once 3.0a6 is tested and behaving
542-
///*
543-
// if (visible && PApplet.platform == PConstants.LINUX) {
544-
// // Linux doesn't deal with insets the same way. We get fake insets
545-
// // earlier, and then the window manager will slap its own insets
546-
// // onto things once the frame is realized on the screen. Awzm.
547-
// if (PApplet.platform == PConstants.LINUX) {
548-
// Insets insets = frame.getInsets();
549-
// frame.setSize(Math.max(sketchWidth, MIN_WINDOW_WIDTH) +
550-
// insets.left + insets.right,
551-
// Math.max(sketchHeight, MIN_WINDOW_HEIGHT) +
552-
// insets.top + insets.bottom);
553-
// }
554-
// }
555-
//*/
556-
// }
521+
/** Set the window (and dock, or whatever necessary) title. */
522+
@Override
523+
public void setTitle(String title) {
524+
frame.setTitle(title);
525+
}
526+
527+
528+
/** Set true if we want to resize things (default is not resizable) */
529+
@Override
530+
public void setResizable(boolean resizable) {
531+
//this.resizable = resizable; // really only used for canvas
532+
533+
if (frame != null) {
534+
frame.setResizable(resizable);
535+
}
536+
}
537+
538+
539+
@Override
540+
public void setVisible(boolean visible) {
541+
frame.setVisible(visible);
542+
543+
// removing per https://github.com/processing/processing/pull/3162
544+
// can remove the code below once 3.0a6 is tested and behaving
545+
/*
546+
if (visible && PApplet.platform == PConstants.LINUX) {
547+
// Linux doesn't deal with insets the same way. We get fake insets
548+
// earlier, and then the window manager will slap its own insets
549+
// onto things once the frame is realized on the screen. Awzm.
550+
if (PApplet.platform == PConstants.LINUX) {
551+
Insets insets = frame.getInsets();
552+
frame.setSize(Math.max(sketchWidth, MIN_WINDOW_WIDTH) +
553+
insets.left + insets.right,
554+
Math.max(sketchHeight, MIN_WINDOW_HEIGHT) +
555+
insets.top + insets.bottom);
556+
}
557+
}
558+
*/
559+
}
557560

558561

559562
//public void placeFullScreen(boolean hideStop) {

core/src/processing/core/PSurfaceFX.java

Lines changed: 42 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -167,48 +167,67 @@ public void start(final Stage stage) {
167167
}
168168

169169

170-
public Frame initFrame(PApplet sketch, java.awt.Color backgroundColor,
170+
//public Frame initFrame(PApplet sketch, java.awt.Color backgroundColor,
171+
public void initFrame(PApplet sketch, java.awt.Color backgroundColor,
171172
int deviceIndex, boolean fullScreen,
172173
boolean spanDisplays) {
173174
this.sketch = sketch;
174175
PApplicationFX.surface = this;
175-
Frame frame = new DummyFrame();
176+
//Frame frame = new DummyFrame();
176177
new Thread(new Runnable() {
177178
public void run() {
178179
Application.launch(PApplicationFX.class);
179180
}
180181
}).start();
181-
return frame;
182+
//return frame;
182183
}
183184

184185

185-
class DummyFrame extends Frame {
186+
/** Set the window (and dock, or whatever necessary) title. */
187+
public void setTitle(String title) {
188+
// TODO ignored?
189+
}
186190

187-
public DummyFrame() {
188-
super();
189-
}
190191

191-
@Override
192-
public void setResizable(boolean resizable) {
193-
// TODO
194-
}
192+
/** Show or hide the window. */
193+
public void setVisible(boolean visible) {
194+
// TODO ignored?
195+
}
195196

196-
@Override
197-
public void setVisible(boolean visible) {
198-
stage.show();
199-
}
200197

201-
@Override
202-
public void setTitle(String title) {
203-
if (stage != null) {
204-
stage.setTitle(title);
205-
} else {
206-
System.err.println("stage was null for setTitle()");
207-
}
208-
}
198+
/** Set true if we want to resize things (default is not resizable) */
199+
public void setResizable(boolean resizable) {
200+
// TODO ignored?
209201
}
210202

211203

204+
// class DummyFrame extends Frame {
205+
//
206+
// public DummyFrame() {
207+
// super();
208+
// }
209+
//
210+
// @Override
211+
// public void setResizable(boolean resizable) {
212+
// // TODO
213+
// }
214+
//
215+
// @Override
216+
// public void setVisible(boolean visible) {
217+
// stage.show();
218+
// }
219+
//
220+
// @Override
221+
// public void setTitle(String title) {
222+
// if (stage != null) {
223+
// stage.setTitle(title);
224+
// } else {
225+
// System.err.println("stage was null for setTitle()");
226+
// }
227+
// }
228+
// }
229+
230+
212231
/*
213232
public class PApplicationFX extends Application {
214233

core/src/processing/core/PSurfaceNone.java

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424

2525
import java.awt.Color;
2626
import java.awt.Component;
27-
import java.awt.Frame;
2827

2928

3029
/**
@@ -55,10 +54,27 @@ public Component initComponent(PApplet sketch) {
5554
}
5655

5756

58-
public Frame initFrame(PApplet sketch, Color backgroundColor,
57+
public void initFrame(PApplet sketch, Color backgroundColor,
5958
int deviceIndex, boolean fullScreen,
6059
boolean spanDisplays) {
61-
return null;
60+
}
61+
62+
63+
/** Set the window (and dock, or whatever necessary) title. */
64+
public void setTitle(String title) {
65+
// TODO ignored?
66+
}
67+
68+
69+
/** Show or hide the window. */
70+
public void setVisible(boolean visible) {
71+
// TODO ignored?
72+
}
73+
74+
75+
/** Set true if we want to resize things (default is not resizable) */
76+
public void setResizable(boolean resizable) {
77+
// TODO ignored?
6278
}
6379

6480

0 commit comments

Comments
 (0)