X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=src%2Forg%2Fibex%2FSurface.java;h=d2130e39781455f5d6b12e7e1df2f88e3ce26972;hb=707b1064f56e88db0cf555a99cb4aa224484f51a;hp=383e7a86b6387d1b7d17a5f0b9b127f476898df3;hpb=3591b88b94a6bb378af3d4abe6eb5233ce583104;p=org.ibex.core.git diff --git a/src/org/ibex/Surface.java b/src/org/ibex/Surface.java index 383e7a8..d2130e3 100644 --- a/src/org/ibex/Surface.java +++ b/src/org/ibex/Surface.java @@ -88,7 +88,6 @@ public abstract class Surface extends PixelBuffer implements Scheduler.Task { if (button == 1) new Message("_Press1", T, root); else if (button == 2) new Message("_Press2", T, root); else if (button == 3) { - final Box who = root; Scheduler.add(new Scheduler.Task() { public void perform() throws JSExn { Platform.clipboardReadEnabled = true; try { @@ -127,16 +126,17 @@ public abstract class Surface extends PixelBuffer implements Scheduler.Task { } /** we enqueue ourselves in the Scheduler when we have a Move message to deal with */ - public void perform() { - if (mousex == newmousex && mousey == newmousey) return; - int oldmousex = mousex; mousex = newmousex; - int oldmousey = mousey; mousey = newmousey; - String oldcursor = cursor; cursor = "default"; - // Root gets motion events outside itself (if trapped) - if (!root.inside(oldmousex, oldmousey) && !root.inside(mousex, mousey) && (button1 || button2 || button3)) - root.putAndTriggerTrapsAndCatchExceptions("_Move", T); - if (!cursor.equals(oldcursor)) syncCursor(); - } + private Scheduler.Task mover = new Scheduler.Task() { + public void perform() { + if (mousex == newmousex && mousey == newmousey) return; + int oldmousex = mousex; mousex = newmousex; + int oldmousey = mousey; mousey = newmousey; + String oldcursor = cursor; cursor = "default"; + // FIXME: Root (ONLY) gets motion events outside itself (if trapped) + if (oldmousex != mousex || oldmousey != mousey) + root.putAndTriggerTrapsAndCatchExceptions("_Move", T); + if (!cursor.equals(oldcursor)) syncCursor(); + } }; /** * Notify Ibex that the mouse has moved. If the mouse leaves the @@ -147,9 +147,14 @@ public abstract class Surface extends PixelBuffer implements Scheduler.Task { protected final void Move(final int newmousex, final int newmousey) { this.newmousex = newmousex; this.newmousey = newmousey; - Scheduler.add(this); + Scheduler.add(mover); } + protected final void HScroll(int pixels) { new Message("_HScroll", new Integer(pixels), root); } + protected final void VScroll(int pixels) { new Message("_VScroll", new Integer(pixels), root); } + protected final void HScroll(float lines) { new Message("_HScroll", new Float(lines), root); } + protected final void VScroll(float lines) { new Message("_VScroll", new Float(lines), root); } + /** subclasses should invoke this method when the user resizes the window */ protected final void SizeChange(final int width, final int height) { if (pendingWidth == width && pendingHeight == height) return; @@ -177,7 +182,10 @@ public abstract class Surface extends PixelBuffer implements Scheduler.Task { protected final void Minimized(boolean b) { minimized = b; new Message("Minimized", b ? T : F, root); } protected final void Maximized(boolean b) { maximized = b; new Message("Maximized", b ? T : F, root); } protected final void Focused(boolean b) { new Message("Focused", b ? T : F, root); } - public void Refresh() { Scheduler.add(new Scheduler.Task() { public void perform() { } }); } + + private boolean scheduled = false; + public void Refresh() { if (!scheduled) Scheduler.add(this); scheduled = true; } + public void perform() { scheduled = false; Scheduler.renderAll(); } public final void setMaximized(boolean b) { if (b != maximized) _setMaximized(maximized = b); } public final void setMinimized(boolean b) { if (b != minimized) _setMinimized(minimized = b); } @@ -224,11 +232,11 @@ public abstract class Surface extends PixelBuffer implements Scheduler.Task { /** runs the prerender() and render() pipelines in the root Box to regenerate the backbuffer, then blits it to the screen */ public synchronized void render() { - + scheduled = false; // make sure the root is properly sized do { abort = false; - root.repack(); + root.pack(); if (syncRootBoxToSurface) { root.setMaxWidth(JS.N(pendingWidth)); root.setMaxHeight(JS.N(pendingHeight)); @@ -240,12 +248,12 @@ public abstract class Surface extends PixelBuffer implements Scheduler.Task { dirty(0, root.maxheight - Main.scarImage.height, Main.scarImage.width, Main.scarImage.height); } root.resize(root.x, root.y, root.maxwidth, root.maxheight); - root.resize_children(); + root.place(); setSize(root.width, root.height); - String oldcursor = cursor; + /*String oldcursor = cursor; cursor = "default"; root.putAndTriggerTrapsAndCatchExceptions("_Move", JS.T); - if (!cursor.equals(oldcursor)) syncCursor(); + if (!cursor.equals(oldcursor)) syncCursor();*/ } while(abort); int[][] dirt = dirtyRegions.flush(); @@ -301,6 +309,10 @@ public abstract class Surface extends PixelBuffer implements Scheduler.Task { else if (value.toLowerCase().equals("control")) control = false; else if (value.toLowerCase().equals("shift")) shift = false; this.value = value; + } else if (name.equals("_HScroll") || name.equals("_VScroll")) { + // FIXME: technically points != pixels + if (value instanceof Integer) + value = new Float(((Integer)value).intValue() * root.fontSize()); } try { boxContainingMouse.putAndTriggerTrapsAndCatchExceptions(name, value);