X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=src%2Forg%2Fibex%2FBox.java;h=514d301a0fcbbe083566c2e5d983da51eefe152d;hb=7bfa509c88f79ec899e7e6ebdb775d3c83e420f9;hp=90fd4997893a1e5318a021e929abbd31d44a64f2;hpb=e2dab289d7adfebb01adf5ce782e7fa1b122cded;p=org.ibex.core.git diff --git a/src/org/ibex/Box.java b/src/org/ibex/Box.java index 90fd499..514d301 100644 --- a/src/org/ibex/Box.java +++ b/src/org/ibex/Box.java @@ -152,6 +152,8 @@ public final class Box extends JSScope implements Scheduler.Task { private short col = 0; public LENGTH x = 0; public LENGTH y = 0; + public LENGTH ax = 0; // FEATURE: roll these into x/y; requires lots of changes + public LENGTH ay = 0; // FEATURE: roll these into x/y; requires lots of changes; perhaps y()? public LENGTH width = 0; public LENGTH height = 0; private LENGTH contentwidth = 0; // == max(minwidth, textwidth, sum(child.contentwidth)) @@ -175,9 +177,10 @@ public final class Box extends JSScope implements Scheduler.Task { // as external events have occured, check the state of box if (texture != null) { if (texture.isLoaded) { minwidth = min(texture.width, maxwidth); minheight = min(texture.height, maxheight); } - else { JS res = texture.stream; texture = null; throw new JSExn("image not found: "+res); } + else { JS res = texture.stream; texture = null; throw new JSExn("image not found: "+res.unclone()); } + } else { + Log.warn(Box.class, "perform() called with null texture"); } - MARK_REPACK; MARK_REFLOW; MARK_RESIZE; @@ -215,7 +218,7 @@ public final class Box extends JSScope implements Scheduler.Task { private static LENGTH[] colMaxWidth = new LENGTH[65535]; private static LENGTH[] rowHeight = new LENGTH[65535]; private static LENGTH[] rowMaxHeight = new LENGTH[65535]; - static { for(int i=0; i 0 && cols > 0 && startslack != x_slack;) { - int increment = max(1, x_slack / cols); - startslack = x_slack; - for(short col=0; col < cols; col++) { - // FIXME: double check this - int diff = min(min(colMaxWidth[col], colWidth[col] + increment) - colWidth[col], x_slack); - x_slack -= diff; + int x_slack = width; + for(int i=0; i 0 && eligible > 0;) { + int increment = max(1, x_slack / eligible); + eligible = 0; + for(short col=0, count=0; col < cols; col++) { + if (colMaxWidth[col] <= colWidth[col]) continue; + if (slacklevel + increment < colWidth[col]) { eligible++; continue; } + int diff = min(increment, min(colMaxWidth[col] - colWidth[col], slacklevel + increment - colWidth[col])); + eligible++; colWidth[col] += diff; + x_slack -= diff; } - } + slacklevel += increment; + } //#end - // Phase 3: assign childrens' actual sizes + // PHASE 3: assign childrens' actual sizes for(Box child = getChild(0); child != null; child = child.nextSibling()) { if (!child.test(VISIBLE)) continue; int child_width, child_height, child_x, child_y; if (!child.test(PACKED)) { - child_x = child.x; - child_y = child.y; - child_width = child.test(HSHRINK) ? child.contentwidth : min(child.maxwidth, width - child_x); - child_height = child.test(VSHRINK) ? child.contentheight : min(child.maxheight, height - child_y); + child_width = child.test(HSHRINK) ? child.contentwidth : min(child.maxwidth, width - Math.abs(child.ax)); + child_height = child.test(VSHRINK) ? child.contentheight : min(child.maxheight, height - Math.abs(child.ay)); child_width = max(child.minwidth, child_width); child_height = max(child.minheight, child_height); + int gap_x = width - child_width; + int gap_y = height - child_height; + child_x = child.ax + (child.test(ALIGN_RIGHT) ? gap_x : !child.test(ALIGN_LEFT) ? gap_x / 2 : 0); + child_y = child.ay + (child.test(ALIGN_BOTTOM) ? gap_y : !child.test(ALIGN_TOP) ? gap_y / 2 : 0); } else { int unbounded; //#repeat col/row colspan/rowspan contentwidth/contentheight width/height colMaxWidth/rowMaxHeight \ @@ -343,8 +350,8 @@ public final class Box extends JSScope implements Scheduler.Task { } // cleanup - for(int i=0; i