X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=src%2Forg%2Fibex%2FBox.java;h=f680f20ff5b9a3531a2e9c5be2a40b5268ae7f53;hb=5de59cbabd2184a23380fee1bdf32e52c5bb44d7;hp=f889d6e723c348c3c1c3d38e039ed56c2d10e4fa;hpb=6e7dd6604dddbd7f1f7c67c120b788193f0c0dc5;p=org.ibex.core.git diff --git a/src/org/ibex/Box.java b/src/org/ibex/Box.java index f889d6e..f680f20 100644 --- a/src/org/ibex/Box.java +++ b/src/org/ibex/Box.java @@ -245,7 +245,7 @@ public final class Box extends JSScope implements Scheduler.Task { void constrain() { //#repeat contentwidth/contentheight colspan/rowspan col/row cols/rows minwidth/minheight \ - // textwidth/textheight maxwidth/maxheight cols/rows + // textwidth/textheight maxwidth/maxheight cols/rows rowspan/colspan row/col rows/cols // FIXME: inefficient contentwidth = 0; for(int i=0; i 1) do { + /* boolean easy_width = contentwidth >= width; */ + for(Box c = firstPackedChild(); c != null; c = c.nextPackedSibling()) { + breakpoints[c.col] = true; + breakpoints[min(cols, c.col+c.colspan)] = true; + } + numregions = 0; + // FIXME: depends on cols + for(int i=0; i i && c.maxwidth < Integer.MAX_VALUE) + good = false; + if (good) { easy_width = true; break; } + } + if (easy_width) break; + */ + int nc = numregions * 2 + numkids + 1; if (coeff == null || nc+1>coeff.length) coeff = new float[nc+1]; lp_h.init(nc); - // objective function for(int i=0; i=child.col && i= child.col && regions[r+1] <= min(child.col+child.colspan,cols)) + coeff[r] = (float)(regions[r+1] - regions[r]); lp_h.add_constraint(coeff, LinearProgramming.GE, (float)child.contentwidth); + + // priority 2: honor maxwidths int child_maxwidth = child.test(HSHRINK) ? min(child.maxwidth, child.contentwidth) : child.maxwidth; if (child_maxwidth < Integer.MAX_VALUE) { - for(int i=0; i=child.col && i= child.col && regions[r+1] <= min(child.col+child.colspan,cols)) + coeff[r] = (float)(regions[r+1] - regions[r]); + coeff[numregions*2+childnum] = (float)-1.0; + lp_h.add_constraint(coeff, LinearProgramming.LE, (float)child_maxwidth); } - for(int j=0; j= child.col && regions[r+1] <= min(child.col+child.colspan,cols)) { + child_width += Math.round(lp_h.solution[lp_h.rows+r+1] * (regions[r+1] - regions[r])); + } else if (regions[r+1] <= child.col) { + child_x += Math.round(lp_h.solution[lp_h.rows+r+1] * (regions[r+1] - regions[r])); + } + } + } diff = (child_width - min(child_width, child.test(HSHRINK) ? child.contentwidth : child.maxwidth)); child_x += (child.test(ALIGN_RIGHT) ? diff : child.test(ALIGN_LEFT) ? 0 : diff / 2); child_width = min(child_width, child.test(HSHRINK) ? child.contentwidth : child.maxwidth); @@ -732,6 +789,7 @@ 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 && texture.isLoaded) perform(); } else { throw new JSExn("fill must be null, a String, or a stream, not a " + value.getClass()); }