Skip to content

Commit dfb8409

Browse files
committed
deal with NaN in stage.getWidth/Height() during FX2D window placement
1 parent d993351 commit dfb8409

File tree

3 files changed

+22
-20
lines changed

3 files changed

+22
-20
lines changed

app/src/processing/app/ui/EditorState.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,7 @@ void defaultLocation(List<Editor> editors) {
163163

164164
defaultWidth = Math.min(defaultWidth, deviceBounds.width);
165165
defaultHeight = Math.min(defaultHeight, deviceBounds.height);
166+
//System.out.println("default w/h = " + defaultWidth + "/" + defaultHeight);
166167

167168
if (editors.size() == 0) {
168169
// If no current active editor, use default placement.

core/src/processing/javafx/PSurfaceFX.java

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,7 @@ public void start(final Stage stage) {
313313
// https://github.com/processing/processing/issues/3823
314314
if ((PApplet.platform == PConstants.MACOSX ||
315315
PApplet.platform == PConstants.LINUX) &&
316-
PApplet.javaVersionName.equals("1.8.0_60")) {
316+
PApplet.javaVersionName.compareTo("1.8.0_60") >= 0) {
317317
System.err.println("smooth() disabled for JavaFX with this Java version due to Oracle bug");
318318
System.err.println("https://github.com/processing/processing/issues/3795");
319319
smooth = 0;
@@ -446,9 +446,11 @@ public void placeWindow(int[] location, int[] editorLocation) {
446446
}
447447

448448
//Dimension window = setFrameSize();
449-
450449
// int contentW = Math.max(sketchWidth, MIN_WINDOW_WIDTH);
451450
// int contentH = Math.max(sketchHeight, MIN_WINDOW_HEIGHT);
451+
// System.out.println("stage size is " + stage.getWidth() + " " + stage.getHeight());
452+
int wide = sketch.width; // stage.getWidth() is NaN here
453+
int high = sketch.height; // stage.getHeight()
452454

453455
if (location != null) {
454456
// a specific location was received from the Runner
@@ -460,28 +462,26 @@ public void placeWindow(int[] location, int[] editorLocation) {
460462
int locationX = editorLocation[0] - 20;
461463
int locationY = editorLocation[1];
462464

463-
if (locationX - stage.getWidth() > 10) {
465+
if (locationX - wide > 10) {
464466
// if it fits to the left of the window
465-
stage.setX(locationX - stage.getWidth());
467+
stage.setX(locationX - wide);
466468
stage.setY(locationY);
467469

468470
} else { // doesn't fit
469-
/*
470-
// if it fits inside the editor window,
471-
// offset slightly from upper lefthand corner
472-
// so that it's plunked inside the text area
473-
locationX = editorLocation[0] + 66;
474-
locationY = editorLocation[1] + 66;
475-
476-
if ((locationX + stage.getWidth() > sketch.displayWidth - 33) ||
477-
(locationY + stage.getHeight() > sketch.displayHeight - 33)) {
478-
// otherwise center on screen
479-
*/
480-
locationX = (int) ((sketch.displayWidth - stage.getWidth()) / 2);
481-
locationY = (int) ((sketch.displayHeight - stage.getHeight()) / 2);
482-
/*
483-
}
484-
*/
471+
// // if it fits inside the editor window,
472+
// // offset slightly from upper lefthand corner
473+
// // so that it's plunked inside the text area
474+
// locationX = editorLocation[0] + 66;
475+
// locationY = editorLocation[1] + 66;
476+
//
477+
// if ((locationX + stage.getWidth() > sketch.displayWidth - 33) ||
478+
// (locationY + stage.getHeight() > sketch.displayHeight - 33)) {
479+
// // otherwise center on screen
480+
// locationX = (int) ((sketch.displayWidth - wide) / 2);
481+
// locationY = (int) ((sketch.displayHeight - high) / 2);
482+
// }
483+
locationX = (sketch.displayWidth - wide) / 2;
484+
locationY = (sketch.displayHeight - high) / 2;
485485
stage.setX(locationX);
486486
stage.setY(locationY);
487487
}

core/todo.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ X Editor menu is outside the visible screen with 800x480 display
77
X https://github.com/processing/processing/issues/3913
88
X https://github.com/processing/processing/pull/3999
99
X https://github.com/processing/processing/pull/3992
10+
X add a patch for FX2D menubar not hiding, root cause not sorted out
1011

1112
jakub
1213
X Fix depth sorter ordering when two triangles in a plane share vertices

0 commit comments

Comments
 (0)