Windows ignores setMinimumSize(), add workaround for #5052

This commit is contained in:
Ben Fry
2017-09-03 08:36:23 -04:00
parent f1dd1554ee
commit 82c772f178
5 changed files with 51 additions and 22 deletions
+7 -6
View File
@@ -945,14 +945,15 @@ public class PSurfaceAWT extends PSurfaceNone {
// needs to resize the frame, which will resize the canvas, and so on...
@Override
public void setSize(int wide, int high) {
//In Microsoft Windows, when the surface is set to resizable (surface.setResizable(true)),
//the height set by the user can become less than or equal to zero and program crashes
//when that occurs. This is a simple fix for that
//(issue: https://github.com/processing/processing/issues/5052)
if(high <= 0) {
// When the surface is set to resizable via surface.setResizable(true),
// a crash may occur if the user sets the window to size zero.
// https://github.com/processing/processing/issues/5052
if (high <= 0) {
high = 1;
}
if (wide <= 0) {
wide = 1;
}
// if (PApplet.DEBUG) {
// //System.out.format("frame visible %b, setSize(%d, %d) %n", frame.isVisible(), wide, high);
+14 -4
View File
@@ -616,14 +616,24 @@ public class PSurfaceFX implements PSurface {
}
public void setSize(int width, int height) {
public void setSize(int wide, int high) {
// When the surface is set to resizable via surface.setResizable(true),
// a crash may occur if the user sets the window to size zero.
// https://github.com/processing/processing/issues/5052
if (high <= 0) {
high = 1;
}
if (wide <= 0) {
wide = 1;
}
//System.out.format("%s.setSize(%d, %d)%n", getClass().getSimpleName(), width, height);
Scene scene = stage.getScene();
double decorH = stage.getWidth() - scene.getWidth();
double decorV = stage.getHeight() - scene.getHeight();
stage.setWidth(width + decorH);
stage.setHeight(height + decorV);
fx.setSize(width, height);
stage.setWidth(wide + decorH);
stage.setHeight(high + decorV);
fx.setSize(wide, high);
}
+17 -7
View File
@@ -745,19 +745,29 @@ public class PSurfaceJOGL implements PSurface {
}
public void setSize(final int width, final int height) {
public void setSize(int wide, int high) {
if (pgl.presentMode()) return;
boolean changed = sketch.width != width || sketch.height != height;
// When the surface is set to resizable via surface.setResizable(true),
// a crash may occur if the user sets the window to size zero.
// https://github.com/processing/processing/issues/5052
if (high <= 0) {
high = 1;
}
if (wide <= 0) {
wide = 1;
}
sketchWidth = width;
sketchHeight = height;
boolean changed = sketch.width != wide || sketch.height != high;
sketch.setSize(width, height);
graphics.setSize(width, height);
sketchWidth = wide;
sketchHeight = high;
sketch.setSize(wide, high);
graphics.setSize(wide, high);
if (changed) {
window.setSize(width * windowScaleFactor, height * windowScaleFactor);
window.setSize(wide * windowScaleFactor, high * windowScaleFactor);
}
}
+5 -1
View File
@@ -1,6 +1,5 @@
0263 (3.3.6 or 3.4)
gohai
X shell discussion with gohai
X https://github.com/processing/processing/pull/5082
@@ -15,6 +14,11 @@ X https://github.com/processing/processing/issues/5182
X https://github.com/processing/processing/issues/5183
X https://github.com/processing/processing/issues/5194
contrib
X Add workaround for window size = 0 crash
X https://github.com/processing/processing/pull/5234
X https://github.com/processing/processing/issues/5052
_ when doing createFont, can we add it to the os fonts available?
+8 -4
View File
@@ -2,15 +2,14 @@
X update to Java 8u144
X fix issue with call to remove value instead of key in mode contrib hash
X this was only in the code used by the command line mode loader
o data folder not exporting on macOS?
o https://github.com/processing/processing/issues/5207
X confirmed working with LoadDisplayImage example
_ make setting the window icon automatic, based on files in local dirs
X https://github.com/processing/processing/issues/5123
X https://github.com/processing/processing/pull/5202
_ need to make this work behind the scenes instead
_ create icon.png or have an 'icons' folder with multiple sizes
_ movie maker a little broken
_ https://github.com/processing/processing/issues/5168
_ data folder not exporting on macOS?
_ https://github.com/processing/processing/issues/5207
contrib
X add Italian translation
@@ -21,6 +20,11 @@ X https://github.com/processing/processing/issues/5165
X typo in German translation
X https://github.com/processing/processing/pull/5195
X https://github.com/processing/processing/issues/5187
X movie maker a little broken
X https://github.com/processing/processing/issues/5168
X https://github.com/processing/processing/pull/5230
X Add more build products to linux/.gitignore
X https://github.com/processing/processing/pull/5229
jakub
X Fix comment/uncomment adding slashes at wrong indent