* MessageQueue-time (the size/position/state at the time that the
* now-executing message was enqueued). This distinction is important.
*/
+// FIXME: put the scar box back in
public abstract class Surface extends PixelBuffer {
public int getWidth() { return root == null ? 0 : root.width; }
/** When set to true, render() should abort as soon as possible and restart the rendering process */
static volatile boolean abort = false;
- /** the scar image drawn on the bottom right hand corner */
- static Box scarBox = null;
-
public static boolean alt = false; ///< true iff the alt button is pressed down, in real time
public static boolean control = false; ///< true iff the control button is pressed down, in real time
public static boolean shift = false; ///< true iff the shift button is pressed down, in real time
protected final void SizeChange(final int width, final int height) {
Message.Q.add(new Message() { public void perform() {
if (width == root.width && height == root.height) return;
- root.width = width;
- root.height = height;
root.needs_reflow = true;
+ root.reflow(width, height);
}});
abort = true;
}
/** wrapper for setSize() which makes sure to dirty the place where the scar used to be */
void setSize() {
- scarBox.dirty();
- root.width = Math.max(root.width, scarBox.minwidth);
- root.height = Math.max(root.height, scarBox.minheight);
+ root.width = Math.max(root.width, 10);
+ root.height = Math.max(root.height, 10);
setSize(root.width, root.height);
- scarBox.x = 0;
- scarBox.y = root.height - scarBox.minheight;
}
/** Indicates that the Surface is no longer needed */
}
public Surface(Box root) {
+
this.root = root;
- scarBox = new Box();
- try {
- scarBox.put("image", ((Res)Main.builtin.get("org/xwt/builtin/scar.png")).getInputStream());
- } catch (Exception e) {
- Log.log(this, e);
- }
- scarBox.surface = this;
if (root.surface != null && root.surface.root == root) root.surface.dispose(false);
else root.remove();
root.surface = this;
Refresh();
}
- public void paintRegion(int x, int y, int w, int h) {
- root.render(0, 0, x, y, w, h, this);
- scarBox.render(0, 0, x, y, w, h, this);
- }
-
/** runs the prerender() and render() pipelines in the root Box to regenerate the backbuffer, then blits it to the screen */
public synchronized void render() {
if (y+h > root.height) h = root.height - y;
if (w <= 0 || h <= 0) continue;
- paintRegion(x, y, w, h);
+ root.render(0, 0, x, y, w, h, this);
if (abort) {
public static abstract class DoubleBufferedSurface extends Surface {
- public DoubleBufferedSurface(Box root) {
- super(root);
-
- // this is a bit dangerous since we're passing ourselves to another method before subclasses' ctors have run...
- backbuffer = Platform.createPixelBuffer(Platform.getScreenWidth(), Platform.getScreenHeight(), this);
- }
-
- /** The automatic double buffer for the root box */
- PixelBuffer backbuffer = null;
-
- /** Dirty regions on the screen which need to be rebuilt using Surface.blit() */
+ public DoubleBufferedSurface(Box root) { super(root); }
+ PixelBuffer backbuffer = Platform.createPixelBuffer(Platform.getScreenWidth(), Platform.getScreenHeight(), this);
DirtyList screenDirtyRegions = new DirtyList();
public void drawPicture(Picture source, int dx1, int dy1, int dx2, int dy2, int sx1, int sy1, int sx2, int sy2) {
+ screenDirtyRegions.dirty(dx1, dy1, dx2 - dx1, dy2 - dy1);
backbuffer.drawPicture(source, dx1, dy1, dx2, dy2, sx1, sy1, sx2, sy2); }
public void fillRect(int x1, int y1, int x2, int y2, int color) {
+ screenDirtyRegions.dirty(x1, y1, x2 - x1, y2 - y1);
backbuffer.fillRect(x1, y1, x2, y2, color); }
-
- public void paintRegion(int x, int y, int w, int h) {
- super.paintRegion(x, y, w, h);
- screenDirtyRegions.dirty(x, y, w, h);
- }
public void render() {
super.render();