Revision: 3164 http://vexi.svn.sourceforge.net/vexi/?rev=3164&view=rev Author: clrg Date: 2008-11-03 02:02:47 +0000 (Mon, 03 Nov 2008)
Log Message: ----------- Move new frame visible trap invocation to proper place (fixes bug where visible trap was receiving true but post-cascade read was false due to Surface not yet in allSurfaces as visible trap was fired in Surface constructor) + tests Modified Paths: -------------- trunk/core/org.vexi.core/src/org/vexi/core/Box.jpp trunk/core/org.vexi.core/src/org/vexi/core/Surface.java trunk/core/org.vexi.core/src/org/vexi/plat/Platform.java Added Paths: ----------- trunk/core/org.vexi.core/src_junit/test/core/box/visibleframe.t trunk/core/org.vexi.core/src_junit/test/core/box/visiblemove.t Modified: trunk/core/org.vexi.core/src/org/vexi/core/Box.jpp =================================================================== --- trunk/core/org.vexi.core/src/org/vexi/core/Box.jpp 2008-11-02 15:15:14 UTC (rev 3163) +++ trunk/core/org.vexi.core/src/org/vexi/core/Box.jpp 2008-11-03 02:02:47 UTC (rev 3164) @@ -1508,7 +1508,7 @@ } // firing visible traps - final VisibleCascade fireVisibleTraps(boolean val, VisibleCascade trapchain) { + public final VisibleCascade fireVisibleTraps(boolean val, VisibleCascade trapchain) { if (test(VISIBLE_TRAP)) { trapchain = new VisibleCascade(val, trapchain); } @@ -1520,7 +1520,7 @@ return trapchain; } - final class VisibleCascade { + public final class VisibleCascade { VisibleCascade next; Trap trap; JSExn exn; @@ -1531,7 +1531,7 @@ next = trapchain; } - void finishTraps() { + public void finishTraps() { postPutTriggerTrapsAndCatchExceptions(trap, SC_visible, exn); if (next!=null) next.finishTraps(); } Modified: trunk/core/org.vexi.core/src/org/vexi/core/Surface.java =================================================================== --- trunk/core/org.vexi.core/src/org/vexi/core/Surface.java 2008-11-02 15:15:14 UTC (rev 3163) +++ trunk/core/org.vexi.core/src/org/vexi/core/Surface.java 2008-11-03 02:02:47 UTC (rev 3164) @@ -371,20 +371,11 @@ /** Assign root box and assign surface size (root.maxdims or half the screen dims if root.maxdims are unset) */ public Surface(Box root) { + this.root = root; + // HACK - catching JSExns, exn should probably be in the throws clause. // set frame specific box properties try { - Surface old = fromBox(root); - if (old!=null) old.dispose(false); - else { - // fire pre-cascade visible traps - Box.VisibleCascade visitraps = root.fireVisibleTraps(true, null); - // finalize root assignment - this.root = root; - // fire post-cascade visible traps - if (visitraps!=null) visitraps.finishTraps(); - } - // TODO: document this in the reference JS fw = root.getAndTriggerTraps(SC_framewidth); pendingWidth = fw != null ? JSU.toInt(fw) : Platform.getScreenWidth() / 2; Modified: trunk/core/org.vexi.core/src/org/vexi/plat/Platform.java =================================================================== --- trunk/core/org.vexi.core/src/org/vexi/plat/Platform.java 2008-11-02 15:15:14 UTC (rev 3163) +++ trunk/core/org.vexi.core/src/org/vexi/plat/Platform.java 2008-11-03 02:02:47 UTC (rev 3164) @@ -133,10 +133,17 @@ public static Picture createPicture(JS r) { return platform._createPicture(r); } public static Font.Glyph createGlyph(Font f, char c) { return platform._createGlyph(f, c); } public static Surface createSurface(Box b, boolean framed) throws JSExn { + Surface old = Surface.fromBox(b); + // fire pre-cascade visible traps + Box.VisibleCascade visitraps = b.fireVisibleTraps(true, null); // get the platform implementation of surface - Surface ret = platform._createSurface(b, framed); - // add to the surfaces list + Surface ret = platform._createSurface(b, framed); + // clean up old Surface + if (old!=null) old.dispose(false); + // add to the surfaces list Surface.allSurfaces.addElement(ret); + // fire post-cascade visible traps + if (visitraps!=null) visitraps.finishTraps(); // add a fully dirty so the entire surface is drawn ret.dirty(0, 0, b.width, b.height); try { Added: trunk/core/org.vexi.core/src_junit/test/core/box/visibleframe.t =================================================================== --- trunk/core/org.vexi.core/src_junit/test/core/box/visibleframe.t (rev 0) +++ trunk/core/org.vexi.core/src_junit/test/core/box/visibleframe.t 2008-11-03 02:02:47 UTC (rev 3164) @@ -0,0 +1,14 @@ + +<vexi xmlns:ui="vexi://ui" xmlns="" xmlns:lib="_lib"> + <ui:box> + + assert(visible==false); + //vexi.ui.frame = thisbox; + //assert(visible==true); + + // auto-fail this test because it needs + // support for non-graphical testframes + assert(false); + + </ui:box> +</vexi> Added: trunk/core/org.vexi.core/src_junit/test/core/box/visiblemove.t =================================================================== --- trunk/core/org.vexi.core/src_junit/test/core/box/visiblemove.t (rev 0) +++ trunk/core/org.vexi.core/src_junit/test/core/box/visiblemove.t 2008-11-03 02:02:47 UTC (rev 3164) @@ -0,0 +1,33 @@ + +<vexi xmlns:ui="vexi://ui" xmlns="" xmlns:lib="_lib"> + <ui:box> + <ui:box display="false"> + <ui:box id="a" /> // not visible + <ui:box id="b" /> // not visible + </ui:box> + <ui:box id="c" /> // visible + + // spoof visible + thisbox.visible ++= function() { return true; } + + var a_visible = false; + var b_visible = false; + + $a.visible ++= function(v) { + a_visible = true; + cascade = v; + $a[0] = $b; + } + + $b.visible ++= function(v) { + cascade = v; + b_visible = true; + } + + // make both $a and $b visible + $c[0] = $a; + assert(a_visible==true); + assert(b_visible==true); + + </ui:box> +</vexi> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. ------------------------------------------------------------------------- This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ _______________________________________________ Vexi-svn mailing list Vexi-svn@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/vexi-svn