- for(Box child = getChild(0); child != null; child = child.nextPackedSibling()) {
- int unbounded = 0;
- for(int i = child.col; i < child.col + child.colspan; i++) unbounded += colWidth[i];
- child.width = bound(child.contentwidth, unbounded, child.test(HSHRINK) ? child.contentwidth : child.maxwidth);
- child.x = test(ALIGN_RIGHT) ? slack : test(ALIGN_LEFT) ? slack / 2 : 0;
- for(int i=0; i < child.col; i++) child.x += colWidth[i];
- if (child.width < unbounded) child.x += (child.width - unbounded) / 2;
+ // 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 = max(child.minwidth, child_width);
+ child_height = max(child.minheight, child_height);
+ } else {
+ int unbounded;
+ //#repeat col/row colspan/rowspan contentwidth/contentheight width/height colMaxWidth/rowMaxHeight \
+ // child_x/child_y x/y HSHRINK/VSHRINK maxwidth/maxheight cols/rows minwidth/minheight x_slack/y_slack \
+ // colWidth/rowHeight child_width/child_height ALIGN_RIGHT/ALIGN_BOTTOM ALIGN_LEFT/ALIGN_TOP
+ unbounded = 0;
+ for(int i = child.col; i < child.col + child.colspan; i++) unbounded += colWidth[i];
+ child_width = bound(child.contentwidth, unbounded, child.test(HSHRINK) ? child.contentwidth : child.maxwidth);
+ child_x = test(ALIGN_RIGHT) ? x_slack : test(ALIGN_LEFT) ? 0 : x_slack / 2;
+ for(int i=0; i < child.col; i++) child_x += colWidth[i];
+ if (child_width > unbounded) child_x -= (child_width - unbounded) / 2;
+ //#end
+ }
+ child.resize(child_x, child_y, child_width, child_height);