X-Git-Url: http://git.megacz.com/?p=org.ibex.core.git;a=blobdiff_plain;f=src%2Forg%2Fibex%2FBox.java;h=3892ce9f6f4945d83cbec4ae143b1ae97611485d;hp=524cb7c214827daee9dec7e38c62511ff13e6c4d;hb=678a052b8a88a204220b57071360775ffa7b8c2b;hpb=ea80b06d1e0e190d3748df9796c1acbb4a38aea9 diff --git a/src/org/ibex/Box.java b/src/org/ibex/Box.java index 524cb7c..3892ce9 100644 --- a/src/org/ibex/Box.java +++ b/src/org/ibex/Box.java @@ -214,11 +214,6 @@ public final class Box extends JSScope implements Scheduler.Task { // static stuff so we don't have to keep reallocating private static int[] numRowsInCol = new int[65535]; - private static LENGTH[] colWidth = new LENGTH[65535]; - 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; icoeff.length) coeff = new float[nc+1]; + LinearProgramming.Simplex lp_h = new LinearProgramming.Simplex(); + LinearProgramming.Problem lpr_h = new LinearProgramming.Problem(nc, nc); + LinearProgramming.Simplex lp_v = new LinearProgramming.Simplex(); + LinearProgramming.Problem lpr_v = new LinearProgramming.Problem(nc, nc); + + //#repeat col/row colspan/rowspan contentwidth/contentheight width/height colMaxWidth/rowMaxHeight colWidth/rowHeight \ + // HSHRINK/VSHRINK maxwidth/maxheight cols/rows minwidth/minheight colWidth/rowHeight x_slack/y_slack lp_h/lp_v lpr_h/lpr_v + do { + // objective function + coeff[cols*2+numkids] = coeff[cols*2+numkids+1] = (float)-10000.0; // attempt to make sum of columns equal to parent width + for(int i=cols*2; i=child.col && i=child.col && 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; - colWidth[col] += diff; + + // third priority: try to make columns similar size + for(int i=0 ; i unbounded) child_x -= (child_width - unbounded) / 2; + // colWidth/rowHeight child_width/child_height ALIGN_RIGHT/ALIGN_BOTTOM ALIGN_LEFT/ALIGN_TOP lpr_h/lpr_v + child_width = 0; + child_x = 0; + for(int i=0; i < child.col; i++) child_x += Math.round(lpr_h.solution[lpr_h.rows+i+1]); + for(int i = child.col; i < child.col + child.colspan; i++) child_width += Math.round(lpr_h.solution[lpr_h.rows+i+1]); + child_x += (child_width - min(child_width, child.test(HSHRINK) ? child.contentwidth : child.maxwidth)) / 2; + child_width = min(child_width, child.test(HSHRINK) ? child.contentwidth : child.maxwidth); //#end } child.resize(child_x, child_y, child_width, child_height); } - // cleanup - for(int i=0; i 0) + child.place_children(); } @@ -685,7 +702,6 @@ public final class Box extends JSScope implements Scheduler.Task { fillcolor = newfillcolor; } else if(value instanceof JS) { texture = Picture.load((JS)value, this); - if (texture != null) perform(); } else { throw new JSExn("fill must be null, a String, or a stream, not a " + value.getClass()); }