// FIXME: mouse move/release still needs to propagate to boxen in which the mouse was pressed and is still held down
// FEATURE: reintroduce surface.abort
+// Broken:
+// - textures
+// - align/origin
+// - clipping (all forms)
+
import java.util.*;
import org.ibex.js.*;
import org.ibex.util.*;
+import org.ibex.plat.*;
import org.ibex.graphics.*;
/**
void place() {
if (!packed()) {
for(Box child = getChild(0); child != null; child = child.nextSibling()) {
- child.width = max(child.minwidth, child.test(HSHRINK) ? child.contentwidth : child.maxwidth);
- child.height = max(child.minheight, child.test(VSHRINK) ? child.contentheight : child.maxheight);
+ child.width = max(child.minwidth, min(child.test(HSHRINK) ? child.contentwidth : width, child.maxwidth));
+ child.height = max(child.minheight, min(child.test(VSHRINK) ? child.contentheight : height, child.maxheight));
child.place();
}
return;
xmax = save_xmax;
ymax = save_ymax;
- contentwidth = bound(minwidth, contentwidth, maxwidth);
- contentheight = bound(minheight, contentheight, maxheight);
-
- int cw = bound(minwidth, contentwidth, maxwidth), ch = bound(minheight, contentheight, maxheight);
+ int cw = contentwidth = bound(minwidth, contentwidth, maxwidth);
+ int ch = contentheight = bound(minheight, contentheight, maxheight);
//#repeat contentwidth/contentheight contentheight/contentwidth minwidth/minheight row/col col/row \
// textwidth/textheight maxwidth/maxheight bounds/boundsy x1/y1 x2/y2 z1/q1 z2/q2 z3/q3 z4/q4 \
// horizontalBounds/verticalBounds e/f multiply_px/multiply_py xmin/ymin xmax/ymax
private static final boolean OPTIMIZE = false;
/** Renders self and children within the specified region. All rendering operations are clipped to xIn,yIn,wIn,hIn */
- public void render(int cx1, int cy1, int cx2, int cy2, PixelBuffer buf, Affine a) {
+ public void render(PixelBuffer buf, Affine a) {
if (!test(VISIBLE)) return;
a = a.copy().premultiply(transform);
// FIXME: clipping
if (path == null) {
- if (((fillcolor & 0xFF000000) != 0x00000000 || parent == null)) {
+ if (((fillcolor & 0xFF000000) != 0x00000000 || parent == null) && (text==null||"".equals(text))) {
if (OPTIMIZE && a.doesNotRotate()) {
int x = (int)a.multiply_px(0, 0);
int y = (int)a.multiply_py(0, 0);
new Polygon().addrect(0, 0, contentwidth, contentheight, a).fill(buf, new Paint.SingleColorPaint(fillcolor));
}
}
- // FIXME: text
+ if (text != null) {
+ long ret = font.rasterizeGlyphs(text, buf, a, null, 0x777777, 0);
+ minwidth = maxwidth = font.textwidth(text);
+ minheight = maxheight = font.textwidth(text);
+ if (ret == 0) Platform.Scheduler.add(this);
+ }
// FIXME: texture
} else {
Polygon p = new Polygon(path, a);
p.stroke(buf, strokecolor);
}
- for(Box b = getChild(0); b != null; b = b.nextSibling()) b.render(cx1, cy1, cx2, cy2, buf, a);
+ for(Box b = getChild(0); b != null; b = b.nextSibling()) b.render(buf, a);
}
case "indexof":
Box b = (Box)args[0];
if (b.parent != this)
- return (redirect == null || redirect == this) ?
- JSU.N(-1) : redirect.call(method, args);
+ return (redirect == null || redirect == this) ? JSU.N(-1) : redirect.call(method, args);
return JSU.N(b.getIndexInParent());
case "distanceto":
if (JSU.isInt(name)) { put(JSU.toInt(name), value); return; }
//#switch(JSU.toString(name))
case "thisbox": if (value == null) removeSelf();
- case "text": { String s = value==null ? "" : JSU.toString(value); CHECKSET_STRING(text); RECONSTRAIN(); dirty(); }
+ case "text": {
+ String s = value==null ? "" : JSU.toString(value);
+ text = s;
+ minwidth = maxwidth = font.textwidth(text);
+ System.out.println("width=" + width);
+ minheight = maxheight = font.textheight(text);
+ System.out.println("height=" + height);
+ RECONSTRAIN();
+ dirty();
+ }
case "strokecolor": value = JSU.N(Color.stringToColor(JSU.toString(value))); CHECKSET_INT(strokecolor); dirty();
case "textcolor": value = JSU.N(Color.stringToColor(JSU.toString(value))); CHECKSET_INT(strokecolor); dirty();
case "shrink": CHECKSET_FLAG(HSHRINK | VSHRINK); RECONSTRAIN();