Revision: 2468
http://vexi.svn.sourceforge.net/vexi/?rev=2468&view=rev
Author: clrg
Date: 2007-10-15 06:01:18 -0700 (Mon, 15 Oct 2007)
Log Message:
-----------
Make isVisible() acknowledge visible read traps
Modified Paths:
--------------
trunk/core/org.vexi.core/src/org/vexi/core/Box.jpp
trunk/core/org.vexi.core/src_junit/test/core/box/layout/visible.t
Modified: trunk/core/org.vexi.core/src/org/vexi/core/Box.jpp
===================================================================
--- trunk/core/org.vexi.core/src/org/vexi/core/Box.jpp 2007-10-15 12:59:31 UTC
(rev 2467)
+++ trunk/core/org.vexi.core/src/org/vexi/core/Box.jpp 2007-10-15 13:01:18 UTC
(rev 2468)
@@ -137,9 +137,11 @@
// unused - private static final int max(int a, int b, int c) { return
(a>=b && a>=c) ? a : (b>=c && b>=a) ? b : c; }
private final boolean inside(int x, int y) { return test(DISPLAY) && x >=
0 && y >= 0 && x < width && y < height; }
- private final boolean isVisible() {
+ private final boolean isVisible() throws JSExn {
Box b=this;
while(true) {
+ if (b.test(VISIBLE_READ_TRAP))
+ return JSU.toBoolean(b.getAndTriggerTraps(SC_visible));
if (!b.test(DISPLAY)) return false;
if (b.parent == null) return Surface.fromBox(b) != null;
b = b.parent;
@@ -213,7 +215,7 @@
private static final int MINMAX_TRAPS = 0x01000000;
private static final int CONTENTWIDTH_TRAP = 0x02000000;
private static final int CONTENTHEIGHT_TRAP = 0x04000000;
- // unused - private static final int FLAG = 0x08000000;
+ private static final int VISIBLE_READ_TRAP = 0x08000000;
private static final int MOVE_TRAP = 0x10000000;
private static final int ENTER_TRAP = 0x20000000;
@@ -1184,7 +1186,7 @@
case "contentwidth": return JSU.N(contentwidth);
case "contentheight": return JSU.N(contentheight);
case "display": return JSU.B(test(DISPLAY));
- case "visible": /*System.err.println("??? "+JSU.T+", "+JSU.F);*/
return isVisible() ? JSU.T : JSU.F;
+ case "visible": return (test(DISPLAY) && ((parent!=null &&
parent.isVisible()) || getSurface()!=null)) ? JSU.T : JSU.F;
case "cursor": return test(CURSOR) ? super.get(name) : null;
case "mouse":
if (getSurface() == null) return null;
@@ -1426,8 +1428,10 @@
public void addTrap(JS key, JS f) throws JSExn {
super.addTrap(key, f);
// We are only interested in write traps
- if (f.getFormalArgs().length !=1)
+ if (f.getFormalArgs().length != 1) {
+ if (JSU.toString(key).equals("visible")) set(VISIBLE_READ_TRAP);
return;
+ }
//#switch (JSU.toString(key))
case "x": set(X_TRAP);
case "y": set(Y_TRAP);
@@ -1457,7 +1461,7 @@
case "height": if (getTrap(SC_height) == null) clear(HEIGHT_TRAP);
case "contentwidth": if (getTrap(SC_contentwidth) == null)
clear(CONTENTWIDTH_TRAP);
case "contentheight": if (getTrap(SC_contentheight) == null)
clear(CONTENTHEIGHT_TRAP);
- case "visible": if (getTrap(SC_visible) == null)
clear(VISIBLE_TRAP);
+ case "visible": if (getTrap(SC_visible) == null)
clear(VISIBLE_TRAP|VISIBLE_READ_TRAP);
case "Enter": if (getTrap(SC_Enter) == null) clear(ENTER_TRAP);
case "Leave": if (getTrap(SC_Leave) == null) clear(LEAVE_TRAP);
case "_Move": if (getTrap(SC__Move) == null) clear(MOVE_TRAP);
Modified: trunk/core/org.vexi.core/src_junit/test/core/box/layout/visible.t
===================================================================
--- trunk/core/org.vexi.core/src_junit/test/core/box/layout/visible.t
2007-10-15 12:59:31 UTC (rev 2467)
+++ trunk/core/org.vexi.core/src_junit/test/core/box/layout/visible.t
2007-10-15 13:01:18 UTC (rev 2468)
@@ -2,25 +2,26 @@
var completed = false;
var b = vexi.box;
+ var c = vexi.box;
b.visible ++= function(v) {
- .util..assertEquals(false, b.visible);
+ // this will always be true due to the read trap
+ //.util..assertEquals(false, b.visible);
+ .util..assertEquals(true, c.visible);
.util..assertEquals(true, v);
cascade = v;
+ // without the visible read trap on c, this will fail
.util..assertEquals(true, b.visible);
completed = true;
}
- var c = vexi.box;
c[0] = b;
c.display = false;
c.visible ++= function() { return true; }
- vexi.log.warn("here");
c.display = true;
+ .util..assertEquals(true, b.visible);
// FEATURE - find a betterway to achieve this. Should the box
// exceptions escape to the scheduler?
assert(completed);
- vexi.log.warn("here");
-
- <ui:box/>
+ <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: Splunk Inc.
Still grepping through log files to find problems? Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
Vexi-svn mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/vexi-svn