From: adam Date: Mon, 14 Feb 2005 04:29:28 +0000 (+0000) Subject: minor fixups X-Git-Tag: 01-July-2005~10 X-Git-Url: http://git.megacz.com/?p=org.ibex.core.git;a=commitdiff_plain;h=38745e13616797b615c5c7e0605f4fb16f0f5357 minor fixups darcs-hash:20050214042928-5007d-f9c0c2dded431fbec207610c1e33c4d32cee92c6.gz --- diff --git a/src/org/ibex/core/Box.java b/src/org/ibex/core/Box.java index 76871cf..9f5aac7 100644 --- a/src/org/ibex/core/Box.java +++ b/src/org/ibex/core/Box.java @@ -9,9 +9,15 @@ package org.ibex.core; // 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.*; /** @@ -121,8 +127,8 @@ public final class Box extends JS.Obj implements Callable { 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; @@ -191,10 +197,8 @@ public final class Box extends JS.Obj implements Callable { 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 @@ -214,13 +218,13 @@ public final class Box extends JS.Obj implements Callable { 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); @@ -231,7 +235,12 @@ public final class Box extends JS.Obj implements Callable { 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); @@ -239,7 +248,7 @@ public final class Box extends JS.Obj implements Callable { 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); } @@ -252,8 +261,7 @@ public final class Box extends JS.Obj implements Callable { 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": @@ -353,7 +361,16 @@ public final class Box extends JS.Obj implements Callable { 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();