// static stuff so we don't have to keep reallocating
private static int[] numRowsInCol = new int[65535];
- private LENGTH[] colWidth = new LENGTH[65535];
- private LENGTH[] colMaxWidth = new LENGTH[65535];
- private LENGTH[] rowHeight = new LENGTH[65535];
- private LENGTH[] rowMaxHeight = new LENGTH[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; i<rowMaxHeight.length; i++) { rowMaxHeight[i] = MAX_LENGTH; colMaxWidth[i] = MAX_LENGTH; } }
final Box nextPackedSibling() { Box b = nextSibling(); return b == null || (b.test(PACKED | VISIBLE)) ? b : b.nextPackedSibling(); }
final Box firstPackedChild() { Box b = getChild(0); return b == null || (b.test(PACKED | VISIBLE)) ? b : b.nextPackedSibling(); }
new_width = bound(max(contentwidth, minwidth), new_width, test(HSHRINK) ? max(contentwidth, minwidth) : maxwidth);
new_height = bound(max(contentheight, minheight), new_height, test(VSHRINK) ? max(contentheight, minheight) : maxheight);
resize(x, y, new_width, new_height);
+ resize_children();
}
/** pack the boxes into rows and columns; also computes contentwidth */
private void resize(LENGTH x, LENGTH y, LENGTH width, LENGTH height) {
// FEATURE reimplement, but we're destroying this
- /*
if (x != this.x || y != this.y || width != this.width || height != this.height) {
- */
(parent == null ? this : parent).dirty(this.x, this.y, this.width, this.height);
boolean sizechange = (this.width != width || this.height != height) && getTrap("SizeChange") != null;
boolean poschange = (this.x != x || this.y != y) && getTrap("PosChange") != null;
this.width = width; this.height = height; this.x = x; this.y = y;
dirty();
- /*
- try { if (sizechange) putAndTriggerJSTraps("SizeChange", T); Surface.abort = true; }
+ try { if (sizechange) putAndTriggerJSTraps("SizeChange", T); /*Surface.abort = true;*/ }
catch (Exception e) { Log.log(this, e); }
- try { if (poschange) putAndTriggerJSTraps("PosChange", T); Surface.abort = true; }
+ try { if (poschange) putAndTriggerJSTraps("PosChange", T); /*Surface.abort = true;*/ }
catch (Exception e) { Log.log(this, e); }
}
- */
- if (numchildren > 0) resize_children();
}
private void resize_children() {
int slack;
- //#repeat col/row colspan/rowspan contentwidth/contentheight x/y width/height \
- // HSHRINK/VSHRINK maxwidth/maxheight cols/rows minwidth/minheight
+ //#repeat col/row colspan/rowspan contentwidth/contentheight x/y width/height colMaxWidth/rowMaxHeight \
+ // HSHRINK/VSHRINK maxwidth/maxheight cols/rows minwidth/minheight colWidth/rowHeight
// PHASE 1: compute column min/max sizes
slack = 0;
for(Box child = firstPackedChild(); child != null; child = child.nextPackedSibling())
colWidth[col] += diff;
}
}
+ //#end
- for(Box child = getChild(0); child != null; child = child.nextPackedSibling()) {
- int unbounded = 0;
+ // Phase 3: assign childrens' actual sizes
+ for(Box child = getChild(0); child != null; child = child.nextSibling()) {
+ if (!child.test(VISIBLE)) continue;
+ if (!child.test(PACKED)) {
+ child.resize(child.x, child.y,
+ child.test(HSHRINK) ? child.contentwidth : min(child.maxwidth, width - child.x),
+ child.test(VSHRINK) ? child.contentheight : min(child.maxheight, height - child.y));
+ continue;
+ }
+ 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 colWidth/rowHeight child_width/child_height
+ 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;
+ int child_width = bound(child.contentwidth, unbounded, child.test(HSHRINK) ? child.contentwidth : child.maxwidth);
+ int 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;
+ //#end
+ child.resize(child_x, child_y, child_width, child_height);
}
// cleanup
- for(int i=0; i<colWidth.length; i++) colWidth[i] = 0;
- for(int i=0; i<colMaxWidth.length; i++) colMaxWidth[i] = MAX_LENGTH;
- //#end
+ for(int i=0; i<cols; i++) { colWidth[i] = 0; colMaxWidth[i] = MAX_LENGTH; }
+ for(int i=0; i<rows; i++) { rowHeight[i] = 0; rowMaxHeight[i] = MAX_LENGTH; }
- // Phase 3: assign childrens' actual sizes
for(Box child = getChild(0); child != null; child = child.nextSibling())
- if (!test(VISIBLE)) continue;
- else if (!child.test(PACKED))
- child.resize(child.x, child.y,
- child.test(HSHRINK) ? child.contentwidth : min(child.maxwidth, width - child.x),
- child.test(VSHRINK) ? child.contentheight : min(child.maxheight, height - child.y));
- else child.resize(child.x, child.y, child.width, child.height);
+ if (test(VISIBLE))
+ child.resize_children();
}
if (!test(NOCLIP)) {
cx1 = max(cx1, parent == null ? 0 : globalx);
cy1 = max(cy1, parent == null ? 0 : globaly);
- cx2 = min(cx2, parent == null ? 0 : globalx + width);
- cy2 = min(cy2, parent == null ? 0 : globaly + height);
- if (cx2 <= cx1 || cy2 <= cy1) return;
+ cx2 = min(cx2, globalx + width);
+ cy2 = min(cy2, globaly + height);
+ //if (cx2 <= cx1 || cy2 <= cy1) return;
}
if ((fillcolor & 0xFF000000) != 0x00000000)