From 7bfa509c88f79ec899e7e6ebdb775d3c83e420f9 Mon Sep 17 00:00:00 2001 From: charlie Date: Tue, 30 Mar 2004 13:29:13 +0000 Subject: [PATCH] Full fix for Bug 471 This patch also gives a slight speed increase due to increased efficiency at handing out slack darcs-hash:20040330132913-b408a-ee466c2fb945c5b7f159e62d58ad0c2de9e3e482.gz --- src/org/ibex/Box.java | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/src/org/ibex/Box.java b/src/org/ibex/Box.java index 180a652..514d301 100644 --- a/src/org/ibex/Box.java +++ b/src/org/ibex/Box.java @@ -295,30 +295,32 @@ public final class Box extends JSScope implements Scheduler.Task { //#repeat col/row colspan/rowspan contentwidth/contentheight x/y width/height colMaxWidth/rowMaxHeight colWidth/rowHeight \ // HSHRINK/VSHRINK maxwidth/maxheight cols/rows minwidth/minheight colWidth/rowHeight x_slack/y_slack // PHASE 1: compute column min/max sizes - int x_slack = width; - 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; -- 1.7.10.4