I try to make a status bar on the bottom of my screen, but the window can not be made less than 100 pixels. I'm working on Processing 3.0.1.
I use the following code
void setup() {
surface.setResizable(true);
surface.setSize(300, 20);
surface.setLocation(displayWidth-300, displayHeight-50);
}
void draw() {
background(128);
}
any ideas??
Thank you all in advance
J!
If you remove the surface.setResizable(true);
statement, you can see the canvas is 300x20, but the window is not:
Processing 3.0 has a lot of changes including refactoring the windowing code, which previously relied on Java's AWT package.
Going through the current source code, you can see:
static public final int MIN_WINDOW_WIDTH = 128;
static public final int MIN_WINDOW_HEIGHT = 128;
defined in PSurface.java line 34 and used through out PSurfaceAWT.java to ensure these minimum window dimensions.
Trying to access the Surface's canvas (println(surface.getNative());
) I can it's listed as processing.awt.PSurfaceAWT$SmoothCanvas
and I can see a SmoothCanvas class with a getFrame() method which looks promising, but that doesn't seem to be accessible (even though it's a public method of a public class).
So by default, at this time, I'd say resizing the window to be smaller than 128x128 in Processing 3.x is a no go.
If Processing 3.x and smaller window is a must it might be possible to tweak the source code yourself and recompile the core library, but this may bite you later on when having multiple Processing project with multiple versions of the Processing core library. I wouldn't recommend tinkering with the core library normally.
If you can use Processing 2.x for your project, making the window size smaller than 100 pixels is achievable:
import java.awt.Dimension;
int w = 300;
int h = 20;
int appBarHeight = 23;//this is on OSX, on Windows/Linux this may be different
void setup() {
size(w, h);
frame.setResizable(true);
}
void draw() {
if (frame.getHeight() != h+appBarHeight){//wait for Processing to finish setting up it's window dimensions (including minimum window dimensions)
frame.setSize(w,h+appBarHeight);//set your dimensions
}
background(128);
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With