Bläddra i källkod

deleted h2d.comp/css

ncannasse 7 år sedan
förälder
incheckning
8672fac8a1

+ 0 - 218
h2d/comp/Box.hx

@@ -1,218 +0,0 @@
-package h2d.comp;
-
-class Box extends Component {
-
-	var input : h2d.Interactive;
-	var scrollX : Float = 0.;
-	var scrollY : Float = 0.;
-
-	public function new(?layout,?parent) {
-		super("box", parent);
-		if( layout == null ) layout = h2d.css.Defs.Layout.Inline;
-		addClass(":"+layout.getName().toLowerCase());
-	}
-
-	override function resizeRec( ctx : Context ) {
-		var extX = extLeft();
-		var extY = extTop();
-		var ctx2 = new Context(0, 0);
-		ctx2.measure = ctx.measure;
-		if( ctx.measure ) {
-			width = ctx.maxWidth;
-			height = ctx.maxHeight;
-			contentWidth = width - (extX + extRight());
-			contentHeight = height - (extY + extBottom());
-			if( style.width != null ) contentWidth = style.width;
-			if( style.height != null ) contentHeight = style.height;
-		} else {
-			ctx2.xPos = ctx.xPos;
-			ctx2.yPos = ctx.yPos;
-			if( ctx2.xPos == null ) ctx2.xPos = 0;
-			if( ctx2.yPos == null ) ctx2.yPos = 0;
-			resize(ctx2);
-		}
-		switch( style.layout ) {
-		case Inline:
-			var lineHeight = 0.;
-			var xPos = 0., yPos = 0., maxPos = 0.;
-			var prev = null;
-			for( c in components ) {
-				if( !c.visible )
-					continue;
-				if( ctx.measure ) {
-					ctx2.maxWidth = contentWidth;
-					ctx2.maxHeight = contentHeight - (yPos + lineHeight + style.verticalSpacing);
-					c.resizeRec(ctx2);
-					var next = xPos + c.width;
-					if( prev != null ) next += style.horizontalSpacing;
-					if( xPos > 0 && next > contentWidth ) {
-						yPos += lineHeight + style.verticalSpacing;
-						xPos = c.width;
-						lineHeight = c.height;
-					} else {
-						xPos = next;
-						if( c.height > lineHeight ) lineHeight = c.height;
-					}
-					if( xPos > maxPos ) maxPos = xPos;
-				} else {
-					var next = xPos + c.width;
-					if( xPos > 0 && next > contentWidth ) {
-						yPos += lineHeight + style.verticalSpacing;
-						xPos = 0;
-						lineHeight = c.height;
-					} else {
-						if( c.height > lineHeight ) lineHeight = c.height;
-					}
-					ctx2.xPos = xPos + scrollX;
-					ctx2.yPos = yPos + scrollY;
-					c.resizeRec(ctx2);
-					xPos += c.width + style.horizontalSpacing;
-				}
-				prev = c;
-			}
-			if( ctx.measure && style.dock == null ) {
-				if( maxPos < contentWidth && style.width == null ) contentWidth = maxPos;
-				if( yPos + lineHeight < contentHeight && style.height == null ) contentHeight = yPos + lineHeight;
-			}
-		case Horizontal:
-			var lineHeight = 0.;
-			var xPos = 0.;
-			var prev = null;
-			for( c in components ) {
-				if( !c.visible )
-					continue;
-				if( ctx.measure ) {
-					if( prev != null ) xPos += style.horizontalSpacing;
-					ctx2.maxWidth = contentWidth - xPos;
-					if( ctx2.maxWidth < 0 ) ctx2.maxWidth = 0;
-					ctx2.maxHeight = contentHeight;
-					c.resizeRec(ctx2);
-					xPos += c.width;
-					if( c.height > lineHeight ) lineHeight = c.height;
-				} else {
-					ctx2.xPos = xPos + scrollX;
-					ctx2.yPos = scrollY;
-					c.resizeRec(ctx2);
-					xPos += c.width + style.horizontalSpacing;
-				}
-				prev = c;
-			}
-			if( ctx.measure && style.dock == null ) {
-				if( xPos < contentWidth && style.width == null ) contentWidth = xPos;
-				if( lineHeight < contentHeight && style.height == null ) contentHeight = lineHeight;
-			}
-		case Vertical:
-			var colWidth = 0.;
-			var yPos = 0.;
-			var prev = null;
-			for( c in components ) {
-				if( !c.visible )
-					continue;
-				if( ctx.measure ) {
-					if( prev != null ) yPos += style.verticalSpacing;
-					ctx2.maxWidth = contentWidth;
-					ctx2.maxHeight = contentHeight - yPos;
-					if( ctx2.maxHeight < 0 ) ctx2.maxHeight = 0;
-					c.resizeRec(ctx2);
-					yPos += c.height;
-					if( c.width > colWidth ) colWidth = c.width;
-				} else {
-					ctx2.xPos = scrollX;
-					ctx2.yPos = yPos + scrollY;
-					c.resizeRec(ctx2);
-					yPos += c.height + style.verticalSpacing;
-				}
-				prev = c;
-			}
-			if( ctx.measure && style.dock == null ) {
-				if( colWidth < contentWidth && style.width == null ) contentWidth = colWidth;
-				if( yPos < contentHeight && style.height == null ) contentHeight = yPos;
-			}
-		case Absolute:
-			ctx2.xPos = null;
-			ctx2.yPos = null;
-			if( ctx.measure ) {
-				ctx2.maxWidth = contentWidth;
-				ctx2.maxHeight = contentHeight;
-			}
-			for( c in components )
-				c.resizeRec(ctx2);
-		case Dock:
-			ctx2.xPos = 0;
-			ctx2.yPos = 0;
-			var xPos = 0., yPos = 0., w = contentWidth, h = contentHeight;
-			if( ctx.measure ) {
-				for( c in components ) {
-					ctx2.maxWidth = w;
-					ctx2.maxHeight = h;
-					c.resizeRec(ctx2);
-					var d = c.style.dock;
-					if( d == null ) d = Full;
-					switch( d ) {
-					case Left, Right:
-						w -= c.width;
-					case Top, Bottom:
-						h -= c.height;
-					case Full:
-					}
-					if( w < 0 ) w = 0;
-					if( h < 0 ) h = 0;
-				}
-			} else {
-				for( c in components ) {
-					ctx2.maxWidth = w;
-					ctx2.maxHeight = h;
-					var d = c.style.dock;
-					if( d == null ) d = Full;
-					ctx2.xPos = xPos + scrollX;
-					ctx2.yPos = yPos + scrollY;
-					switch( d ) {
-					case Left, Top:
-					case Right:
-						ctx2.xPos += w - c.width;
-					case Bottom:
-						ctx2.yPos += h - c.height;
-					case Full:
-						ctx2.xPos += Std.int((w - c.width) * 0.5);
-						ctx2.yPos += Std.int((h - c.height) * 0.5);
-					}
-					c.resizeRec(ctx2);
-					switch( d ) {
-					case Left:
-						w -= c.width;
-						xPos += c.width;
-					case Right:
-						w -= c.width;
-					case Top:
-						h -= c.height;
-						yPos += c.height;
-					case Bottom:
-						h -= c.height;
-					case Full:
-					}
-					if( w < 0 ) w = 0;
-					if( h < 0 ) h = 0;
-				}
-			}
-		}
-		if( ctx.measure ) {
-			width = contentWidth + extX + extRight();
-			height = contentHeight + extY + extBottom();
-		} else {
-			if( style.backgroundColor != Transparent ) {
-				if( input == null ) {
-					input = new h2d.Interactive(0, 0);
-					input.cursor = Default;
-					bg.addChildAt(input, 0);
-				}
-				input.width = width - (style.marginLeft + style.marginRight);
-				input.height = height - (style.marginTop + style.marginBottom);
-			} else if( input != null ) {
-				input.remove();
-				input = null;
-			}
-		}
-	}
-
-
-}

+ 0 - 36
h2d/comp/Button.hx

@@ -1,36 +0,0 @@
-package h2d.comp;
-
-class Button extends Interactive {
-
-	var tf : h2d.Text;
-
-	public var text(default, set) : String;
-
-	public function new(text, ?parent) {
-		super("button",parent);
-		tf = new h2d.Text(null, this);
-		this.text = text;
-	}
-
-	function get_text() {
-		return tf.text;
-	}
-
-	function set_text(t) {
-		needRebuild = true;
-		return text = t;
-	}
-
-	override function resize( ctx : Context ) {
-		if( ctx.measure ) {
-			tf.font = getFont();
-			tf.textColor = style.color;
-			tf.text = text;
-			tf.smooth = true;
-			contentWidth = tf.textWidth;
-			contentHeight = tf.textHeight;
-		}
-		super.resize(ctx);
-	}
-
-}

+ 0 - 37
h2d/comp/Checkbox.hx

@@ -1,37 +0,0 @@
-package h2d.comp;
-
-class Checkbox extends Interactive {
-
-	public var checked(default, set) : Bool;
-
-	public function new(?parent) {
-		super("checkbox", parent);
-		checked = false;
-	}
-
-	function set_checked(b) {
-		toggleClass(":checked", b);
-		return checked = b;
-	}
-
-	override function resize( ctx : Context ) {
-		super.resize(ctx);
-		if( !ctx.measure ) {
-			input.width = width - (style.marginLeft + style.marginRight);
-			input.height = height - (style.marginTop + style.marginBottom);
-			if( checked ) {
-				var m = style.borderSize + style.tickSpacing;
-				bg.fillRect(style.tickColor, m, m, input.width - m * 2, input.height - m * 2);
-			}
-		}
-	}
-
-	override function onClick() {
-		checked = !checked;
-		onChange(checked);
-	}
-
-	public dynamic function onChange( checked : Bool ) {
-	}
-
-}

+ 0 - 63
h2d/comp/Color.hx

@@ -1,63 +0,0 @@
-package h2d.comp;
-
-class Color extends Component {
-
-	var input : h2d.Interactive;
-	public var value(default, set) : Int;
-
-	public function new(?parent) {
-		super("color", parent);
-		input = new h2d.Interactive(0, 0, bg);
-		var active = false;
-		input.onPush = function(_) {
-			active = true;
-		};
-		input.onOver = function(_) {
-			addClass(":hover");
-		};
-		input.onOut = function(_) {
-			active = false;
-			removeClass(":hover");
-		};
-		input.onRelease = function(_) {
-			if( active ) selectColor();
-		};
-		value = 0;
-	}
-
-	function set_value(v) {
-		needRebuild = true;
-		return value = v;
-	}
-
-	override function resize( ctx : Context ) {
-		super.resize(ctx);
-		if( !ctx.measure ) {
-			input.width = width - (style.marginLeft + style.marginRight);
-			input.height = height - (style.marginTop + style.marginBottom);
-			bg.fillRectColor(extLeft() - style.marginLeft, extTop() - style.marginTop, contentWidth, contentHeight, 0xFF000000 | value);
-		}
-	}
-
-	function selectColor() {
-		var p : Component = this;
-		while( p.parentComponent != null )
-			p = p.parentComponent;
-		var b = new Box(p);
-		b.toggleClass("modal", true);
-		var pick = new ColorPicker(b);
-		pick.color = value;
-		pick.addStyleString("dock:full");
-		pick.onChange = function(c) {
-			value = c;
-			onChange(c);
-		};
-		pick.onClose = function() {
-			b.remove();
-		};
-	}
-
-	public dynamic function onChange( color : Int ) {
-	}
-
-}

+ 0 - 687
h2d/comp/ColorPicker.hx

@@ -1,687 +0,0 @@
-package h2d.comp;
-import h2d.css.Defs;
-import h2d.css.Fill;
-
-private enum RGBA {
-	R;
-	G;
-	B;
-	A;
-}
-
-private enum ChangeState {
-	SNone;
-	SColor;
-	SPalette;
-	SChart;
-	SRed;
-	SGreen;
-	SBlue;
-	SAlpha;
-}
-
-private enum CompStyle {
-	GaugeLabel;
-	GaugeInput;
-	ColorLabel;
-	ColorInput;
-}
-
-private class Style {
-	public function new () {
-	}
-
-	public static function get(kind:CompStyle) {
-		var style = new h2d.css.Style();
-		switch(kind) {
-			case GaugeLabel: 	style.fontSize = 11;
-			case GaugeInput: 	style.width = 24;
-								style.height = 10;
-								style.fontSize = 11;
-			case ColorLabel: 	style.fontSize = 14;
-			case ColorInput: 	style.width = 50;
-								style.height = 10;
-								style.fontSize = 11;
-		}
-		return style;
-	}
-}
-
-private class Arrow extends h2d.css.Fill {
-	public function new (parent, x:Float, y:Float, ang = 0., color = 0xff000000) {
-		super(parent);
-		addPoint(-5, -4, color);
-		addPoint(-5, 4, color);
-		addPoint(0, 0, color);
-		addPoint(0, 0, color);
-		rotation = -ang;
-		this.x = x;
-		this.y = y;
-	}
-}
-
-private class Cross extends h2d.css.Fill {
-	var size:Float;
-
-	public function new (parent, size:Float, color = 0xff000000) {
-		super(parent);
-		this.size = size;
-		lineRect(FillStyle.Color(color), 0, 0, size, size, 1);
-	}
-
-	public function setColor(color:Int) {
-		clear();
-		lineRect(FillStyle.Color(color), 0, 0, size, size, 1);
-	}
-}
-
-private class Color extends h2d.Sprite {
-	var picker : ColorPicker;
-	public var width :Float;
-	public var height :Float;
-	public var color(default, set):Int = 0xFFFFFFFF;
-	public var preview(default, set):Int = 0xFFFFFFFF;
-	public var alphaValue(default, set):Float = 1.;
-
-	var canvas:h2d.css.Fill;
-	var label : h2d.comp.Label;
-	var input : h2d.comp.Input;
-
-
-	public function new (picker,ix, iy, iw, ih, parent) {
-		super(parent);
-		this.picker = picker;
-		x = ix;
-		y = iy;
-		width = iw;
-		height = ih;
-		init();
-	}
-
-	function set_color(v:Int) {
-		if(v != color) {
-			color = v;
-			drawAll();
-		}
-		return color;
-	}
-
-	function set_preview(v:Int) {
-		if(v != preview) {
-			preview = v;
-			drawAll();
-		}
-		return color;
-	}
-
-	function set_alphaValue(v:Float) {
-		alphaValue = v;
-		drawAll();
-		return color;
-	}
-
-	public function updateColor(v:Int) {
-		color = v;
-		input.value = StringTools.hex(preview, 6).substr(2);
-	}
-
-	function init() {
-		label = new h2d.comp.Label("#", this);
-		label.setStyle(Style.get(ColorLabel));
-		input = new h2d.comp.Input(this);
-		input.setStyle(Style.get(ColorInput));
-		input.value = "FFFFFF";
-		input.x = 15; input.y = 3;
-		input.onChange = function (e) {
-			input.value = input.value.toUpperCase();
-			if(input.value.length > 6) {
-				input.value = input.value.substr(0, 6);
-				return;
-			}
-			var v = Std.parseInt("0x" + input.value);
-			if (v != null) {
-				color = 255 << 24 | v;
-				picker.change = SColor;
-			}
-		};
-
-		canvas = new h2d.css.Fill(this);
-		canvas.y = 2 + height * 0.5;
-		drawAll();
-	}
-
-	public function drawAll() {
-		canvas.clear();
-		canvas.fillRectColor(0, 0, width, height * 0.5, preview);
-		canvas.fillRectColor(0, 0, width * 0.5, height * 0.5, color);
-		canvas.fillRectColor(0, height * 0.5 - 4, width, 4, 0xFF000000);
-		canvas.fillRectColor(0, height * 0.5 - 4, width * alphaValue, 4, 0xFFFFFFFF);
-		canvas.lineRect(FillStyle.Color(ColorPicker.borderColor), 0, 0, width, height * 0.5, 1);
-	}
-}
-
-private class Palette extends h2d.Sprite {
-	public var width :Float;
-	public var height :Float;
-	public var color(default, set):Int;
-
-	var picker : ColorPicker;
-	var canvas:h2d.css.Fill;
-	var interact:h2d.Interactive;
-	var cursor:h2d.Sprite;
-
-	public function new (picker, ix, iy, iw, ih, parent) {
-		super(parent);
-		this.picker = picker;
-		x = ix;
-		y = iy;
-		width = iw;
-		height = ih;
-		init();
-	}
-
-	function init() {
-		canvas = new h2d.css.Fill(this);
-		cursor = new h2d.Sprite(this);
-		var larrow = new Arrow(cursor, 0, 0, 0, 0xffcccccc);
-		var rarrow = new Arrow(cursor, width, 0, Math.PI, 0xffcccccc);
-		interact = new h2d.Interactive(width + 16, height, canvas);
-		interact.x = -8;
-		interact.onPush = function(e) {
-			setCursor(e.relY);
-			interact.startDrag(function(e) {
-				if( e.kind == EMove )
-					setCursor(e.relY);
-			});
-			picker.change = SPalette;
-		}
-		interact.onRelease = function(e) {
-			interact.stopDrag();
-			picker.change = SNone;
-		}
-		color = getColor(0);
-		drawAll();
-	}
-
-	function set_color(v:Int) {
-		color = v;
-		if(!picker.change.equals(SPalette))
-			updateCursor();
-		drawAll();
-		return color;
-	}
-
-	function updateCursor() {
-		var hsl = ColorPicker.INTtoHSL(color);
-		cursor.y = Math.round(Math.max(0, Math.min(height, (1 - hsl[0]) * height)));
-	}
-
-	public function drawAll() {
-		var s = 1;
-		var l = 0.5;
-		var seg = height / 6;
-		canvas.clear();
-		for (i in 0...6) {
-			var up = ColorPicker.HSLtoINT(1 - i / 6, s, l);
-			var down = ColorPicker.HSLtoINT(1 - (i + 1) / 6, s, l);
-			canvas.fillRectGradient(0, i * seg, width, seg, up, up, down, down);
-		}
-		canvas.lineRect(FillStyle.Color(ColorPicker.borderColor), 0, 0, width, height, 1);
-	}
-
-	public function setCursor(dy:Float) {
-		cursor.y = Math.round(Math.max(0, Math.min(height, dy)));
-		color = getColor(cursor.y);
-	}
-
-	public function getColor(py:Float) {
-		var h = 1 - (py / height);
-		var s = 1;
-		var l = 0.5;
-		return(ColorPicker.HSLtoINT(h, s, l));
-	}
-
-	public function setColorFrom(newColor:Int) {
-		var rgb = ColorPicker.INTtoRGB(newColor);
-		var hsl = ColorPicker.RGBtoHLS(rgb[0], rgb[1], rgb[2]);
-		hsl[1] = 1; hsl[2] = 0.5;
-		rgb = ColorPicker.HSLtoRGB(hsl[0], hsl[1], hsl[2]);
-		color = ColorPicker.RGBtoINT(rgb[0], rgb[1], rgb[2]);
-	}
-}
-
-private class Chart extends h2d.Sprite{
-	public var width :Int;
-	public var height :Int;
-	public var refColor(default, set):Int = 0xffffffff;
-	public var color:Int = 0xffffffff;
-
-	var picker : ColorPicker;
-	var ray :Float;
-	var canvas:h2d.css.Fill;
-	var interact:h2d.Interactive;
-	var cursor:h2d.Sprite;
-	var lastPos:h3d.Vector;
-	var cross:Cross ;
-
-	public function new (picker,ix, iy, iw, ih, ray, parent) {
-		super(parent);
-		this.picker = picker;
-		x = ix;
-		y = iy;
-		width = iw;
-		height = ih;
-		this.ray = ray;
-		init();
-	}
-
-	function init() {
-		canvas = new h2d.css.Fill(this);
-		cursor = new h2d.Sprite(this);
-		cross = new Cross(cursor, ray * 2);
-		cross.x = cross.y = -ray;
-		interact = new h2d.Interactive(width, height, canvas);
-		interact.onPush = function(e) {
-			setCursor(e.relX, e.relY);
-			interact.startDrag(function(e) {
-				if( e.kind == EMove )
-					setCursor(e.relX, e.relY);
-			});
-			picker.change = SChart;
-		}
-		interact.onRelease = function(e) {
-			interact.stopDrag();
-			picker.change = SNone;
-		}
-		drawAll();
-		setCursor(0, 0);
-	}
-
-	public function setCursor(dx:Float, dy:Float) {
-		cursor.x = Math.max(ray + 1, Math.min(width - ray - 1, dx));
-		cursor.y = Math.max(ray + 1, Math.min(height - ray - 1, dy));
-		lastPos = normalizePos(dx, dy);
-		color = getColor(lastPos.x, lastPos.y);
-		cross.setColor(ColorPicker.complementaryColor(color));
-	}
-
-	function set_refColor(v:Int) {
-		refColor = v;
-		color = getColor(lastPos.x, lastPos.y);
-		cross.setColor(ColorPicker.complementaryColor(color));
-		drawAll();
-		return refColor;
-	}
-
-	function normalizePos(dx:Float, dy:Float) {
-		var px = 1 - Math.min(width, Math.max(0, dx)) / width;
-		var py = 1 - Math.min(height, Math.max(0, dy)) / height;
-		return new h3d.Vector(px, py);
-	}
-
-	public function drawAll() {
-		canvas.clear();
-		var rgb = [(refColor >> 16) & 0xFF, (refColor >> 8) & 0xFF,  refColor & 0xFF];
-		for (i in 0...width>>1) {
-			for (j in 0...height>>1) {
-				var di = Math.max(0, Math.min(width, i * 2));
-				var dj = Math.max(0, Math.min(width, j * 2));
-				var dw = (1 - di / width);
-				var dh = (1 - dj / height);
-				var r = Math.round(rgb[0] * dh);
-				var g = Math.round(rgb[1] * dh);
-				var b = Math.round(rgb[2] * dh);
-				var max = Math.max(r, Math.max(g, b));
-				r = Math.round(r + (max - r) * dw);
-				g = Math.round(g + (max - g) * dw);
-				b = Math.round(b + (max - b) * dw);
-				var c = (255 << 24) | (r << 16) | (g << 8) | b;
-				canvas.fillRectColor(i * 2, j * 2, 2, 2, c);
-			}
-		}
-		canvas.lineRect(FillStyle.Color(ColorPicker.borderColor), 0, 0, width, height, 1);
-	}
-
-	function getColor(dw:Float, dh:Float) {
-		var rgb = [(refColor >> 16) & 0xFF, (refColor >> 8) & 0xFF,  refColor & 0xFF];
-		var r = Math.round(rgb[0] * dh);
-		var g = Math.round(rgb[1] * dh);
-		var b = Math.round(rgb[2] * dh);
-		var max = Math.max(r, Math.max(g, b));
-		r = Math.round(r + (max - r) * dw);
-		g = Math.round(g + (max - g) * dw);
-		b = Math.round(b + (max - b) * dw);
-		return ColorPicker.RGBtoINT(r, g, b);
-	}
-
-	public function setColorFrom(newColor:Int) {
-		var rgb = ColorPicker.INTtoRGB(newColor);
-		var hsl = ColorPicker.RGBtoHLS(rgb[0], rgb[1], rgb[2]);
-		hsl[1] = 1; hsl[2] = 0.5;
-		rgb = ColorPicker.HSLtoRGB(hsl[0], hsl[1], hsl[2]);
-		refColor = ColorPicker.RGBtoINT(rgb[0], rgb[1], rgb[2]);
-
-		var rgb = ColorPicker.INTtoRGB(newColor);
-		var min = Math.min(rgb[0], Math.min(rgb[1], rgb[2]));
-		var max = Math.max(rgb[0], Math.max(rgb[1], rgb[2]));
-		var dx = 1 - min / max;
-		var dy = 1 - max / 255;
-		setCursor(dx * width, dy * height);
-	}
-}
-
-private class ColorGauge extends h2d.Sprite{
-	public var width :Int;
-	public var height :Int;
-	public var color(default, set):Int = 0xffffffff;
-	public var ratio(get, null):Float;
-
-	var picker : ColorPicker;
-	var canvas:h2d.css.Fill;
-	var interact:h2d.Interactive;
-	var cursor:h2d.Sprite;
-	var bindTo:RGBA;
-	var label : h2d.comp.Label;
-	var input : h2d.comp.Input;
-	var isFinal:Bool;
-	public function new (picker,ix, iy, iw, ih, rgba, parent) {
-		super(parent);
-		this.picker = picker;
-		x = ix;
-		y = iy;
-		width = iw;
-		height = ih;
-		bindTo = rgba;
-		init();
-	}
-
-	function init() {
-		label = new h2d.comp.Label(bindTo.getName(), this);
-		label.setStyle(Style.get(GaugeLabel));
-		label.x = -45;
-		label.y = 2;
-		input = new h2d.comp.Input(this);
-		input.setStyle(Style.get(GaugeInput));
-		input.value = "255";
-		input.x = -30; input.y = 3;
-		input.onChange = function(e) {
-			setCursor(cursor.x);
-		};
-
-		canvas = new h2d.css.Fill(this);
-		cursor = new h2d.Sprite(this);
-		cursor.x = width;
-		var larrow = new Arrow(cursor, 0, 0, -Math.PI / 2, 0xffcccccc);
-		var rarrow = new Arrow(cursor, 0, height, Math.PI / 2, 0xffcccccc);
-		interact = new h2d.Interactive(width, height + 8, canvas);
-		interact.y = -4;
-		interact.onPush = function(e) {
-			setCursor(e.relX);
-			interact.startDrag(function(e) {
-				if( e.kind == EMove )
-					setCursor(e.relX);
-			});
-			setState();
-		}
-		interact.onRelease = function(e) {
-			interact.stopDrag();
-			picker.change = SNone;
-		}
-		drawAll();
-	}
-
-	function set_color(v:Int) {
-		color = v;
-		if(!bindTo.equals(RGBA.A))
-			updateCursor();
-		drawAll();
-		return color;
-	}
-
-	function setState() {
-		picker.change = switch(bindTo) {
-			case RGBA.R: SRed;
-			case RGBA.G: SGreen;
-			case RGBA.B: SBlue;
-			case RGBA.A: SAlpha;
-		}
-	}
-
-	public function get_ratio() {
-		return cursor.x / width;
-	}
-
-	public function updateCursor() {
-		var a = color >>> 24;
-		var r = (color >> 16) & 0xFF;
-		var g =	(color >> 8) & 0xFF;
-		var b = color & 0xFF;
-		cursor.x = Math.round(switch(bindTo) {
-			case RGBA.R: r * width / 255;
-			case RGBA.G: g * width / 255;
-			case RGBA.B: b * width / 255;
-			case RGBA.A: a * width / 255;
-		});
-		input.value = Std.string(Std.int(255 * ratio));
-	}
-
-	public function setCursor(dx:Float) {
-		cursor.x = Math.round(Math.max(0, Math.min(width, dx)));
-		var r = (color >> 16) & 0xFF;
-		var g =	(color >> 8) & 0xFF;
-		var b = color & 0xFF;
-		color = switch(bindTo) {
-			case RGBA.R: ColorPicker.RGBtoINT(Math.round(255 * ratio), g, b);
-			case RGBA.G: ColorPicker.RGBtoINT(r, Math.round(255 * ratio), b);
-			case RGBA.B: ColorPicker.RGBtoINT(r, g, Math.round(255 * ratio));
-			case RGBA.A: color;
-		}
-		input.value = Std.string(Math.round(255 * ratio));
-	}
-
-	public function drawAll() {
-		var r = (color >> 16) & 0xFF;
-		var g =	(color >> 8) & 0xFF;
-		var b = color & 0xFF;
-		var left:Int;
-		var right:Int;
-		switch(bindTo) {
-			case RGBA.R: left = ColorPicker.RGBtoINT(0, g, b);	right = ColorPicker.RGBtoINT(255, g, b);
-			case RGBA.G: left = ColorPicker.RGBtoINT(r, 0, b);	right = ColorPicker.RGBtoINT(r, 255, b);
-			case RGBA.B: left = ColorPicker.RGBtoINT(r, g, 0);	right = ColorPicker.RGBtoINT(r, g, 255);
-			case RGBA.A: left = 0xFF000000;						right = 0xFFFFFFFF;
-		}
-		canvas.clear();
-		canvas.fillRectGradient(0, 0, width, height, left, right, left, right);
-		canvas.lineRect(FillStyle.Color(ColorPicker.borderColor), 0, 0, width, height, 1);
-	}
-}
-
-
-
-/////////////////////////////////////////////////////////////////
-
-@:allow(h2d.comp)
-class ColorPicker extends h2d.comp.Component {
-
-	public static var borderColor = 0xFFaaaaaa;
-
-	var finalColor : Color;
-	var palette : Palette;
-	var chart : Chart;
-	var gaugeRed : ColorGauge;
-	var gaugeGreen : ColorGauge;
-	var gaugeBlue : ColorGauge;
-	var gaugeAlpha : ColorGauge;
-	var timer : haxe.Timer;
-	var change : ChangeState;
-
-	public var color(get, set) : Int;
-
-	public function new(?parent) {
-		super("colorpicker", parent);
-		init();
-	}
-
-	inline function get_color() {
-		return (finalColor.color&0xFFFFFF) | Std.int(finalColor.alphaValue*255) << 24;
-	}
-
-	function set_color(v) {
-		finalColor.color = v;
-		finalColor.alphaValue = (v >>> 24) / 255;
-		palette.setColorFrom(v);
-		chart.setColorFrom(v);
-		gaugeRed.color = chart.color;
-		gaugeGreen.color = chart.color;
-		gaugeBlue.color = chart.color;
-		gaugeAlpha.setCursor(finalColor.alphaValue * gaugeAlpha.width);
-		return v;
-	}
-
-	override function onAdd() {
-		super.onAdd();
-		if( timer == null ) {
-			timer = new haxe.Timer(10);
-			timer.run = doUpdate;
-		}
-	}
-
-	override function onRemove() {
-		super.onRemove();
-		if( timer != null ) {
-			timer.stop();
-			timer = null;
-		}
-	}
-
-	function init() {
-		finalColor = new Color(this, 15, 8, 175, 45, this);
-		palette = new Palette(this, 16, 65, 20, 140, this);
-		chart = new Chart(this,50, 65, 140, 140, 3.5, this);
-		gaugeRed = new ColorGauge(this, 50, 220, 140, 15, RGBA.R, this);
-		gaugeGreen = new ColorGauge(this, 50, 245, 140, 15, RGBA.G, this);
-		gaugeBlue = new ColorGauge(this, 50, 270, 140, 15, RGBA.B, this);
-		gaugeAlpha = new ColorGauge(this, 50, 295, 140, 15, RGBA.A, this);
-		chart.refColor = palette.color;
-		change = SNone;
-		var close = new Button("", this);
-		close.addClass(":close");
-//		close.addStyleString("layout:absolute;font-size:12px;height:10px;width:10px;");
-		close.x = 175;
-		close.y = 10;
-		close.onClick = function() {
-			onClose();
-		};
-	}
-
-	function doUpdate() {
-		finalColor.preview = chart.color;
-		if(change.equals(SNone)) {
-			if(finalColor.color != chart.color) {
-				finalColor.updateColor(chart.color);
-				onChange(color);
-			}
-			return;
-		}
-
-		switch(change) {
-			case SColor:	palette.setColorFrom(finalColor.color);
-							chart.setColorFrom(finalColor.color);
-							// require another change event since we have finalColor == chartColor
-							onChange(color);
-			case SPalette:	chart.refColor = palette.color;
-			case SRed:		chart.setColorFrom(gaugeRed.color);
-							palette.color = chart.refColor;
-			case SGreen:	chart.setColorFrom(gaugeGreen.color);
-							palette.color = chart.refColor;
-			case SBlue:		chart.setColorFrom(gaugeBlue.color);
-							palette.color = chart.refColor;
-			case SAlpha:	finalColor.alphaValue = gaugeAlpha.ratio;
-							onChange(color);
-			default:
-		}
-
-		gaugeRed.color = chart.color;
-		gaugeGreen.color = chart.color;
-		gaugeBlue.color = chart.color;
-	}
-
-	public dynamic function onClose() {
-	}
-
-	public dynamic function onChange( value : Int ) {
-	}
-
-//////////////////
-	public static function INTtoRGB(color:Int) {
-		return [(color >> 16) & 0xFF, (color >> 8) & 0xFF,  color & 0xFF];
-	}
-
-	public static function INTtoHSL(color:Int) {
-		var rgb = INTtoRGB(color);
-		return RGBtoHLS(rgb[0], rgb[1], rgb[2]);
-	}
-
-	public static function RGBtoINT(r:Int, g:Int, b:Int, a:Int = 255) {
-		return (a << 24) | (r << 16) | (g << 8) | b;
-	}
-
-	public static function RGBtoHLS(r:Float, g:Float, b:Float) {
-		r /= 255;
-		g /= 255;
-		b /= 255;
-		var max = Math.max(r, Math.max(g, b));
-		var min = Math.min(r, Math.min(g, b));
-		var med = (max + min) / 2;
-		var h = med;
-		var s = med;
-		var l = med;
-		if(max == min)
-			h = s = 0;
-		else {
-			var d = max - min;
-			s = l > 0.5 ? d / (2 - max - min) : d / (max + min);
-			if(max == r) 		h = (g - b) / d + (g < b ? 6 : 0);
-			else if(max == g) 	h = (b - r) / d + 2;
-			else if(max == b) 	h = (r - g) / d + 4;
-			h /= 6;
-		}
-		return [h, s, l];
-	}
-
-	public static function HSLtoINT(h:Float, s:Float, l:Float) {
-		var rgb = HSLtoRGB(h, s, l);
-		return RGBtoINT(rgb[0], rgb[1], rgb[2]);
-	}
-
-	public static function HSLtoRGB(h:Float, s:Float, l:Float) {
-		var r, g, b;
-		if(s == 0)
-			r = g = b = l;
-		else {
-			function hue2rgb(p:Float, q:Float, t:Float) {
-				if(t < 0) t += 1;
-				if(t > 1) t -= 1;
-				if(t < 1 / 6) return p + (q - p) * 6 * t;
-				if(t < 1 / 2) return q;
-				if(t < 2 / 3) return p + (q - p) * (2 / 3 - t) * 6;
-				return p;
-			}
-			var q = l < 0.5 ? l * (1 + s) : l + s - l * s;
-			var p = 2 * l - q;
-			r = hue2rgb(p, q, h + 1 / 3);
-			g = hue2rgb(p, q, h);
-			b = hue2rgb(p, q, h - 1 / 3);
-		}
-		return [Math.round(r * 255), Math.round(g * 255), Math.round(b * 255)];
-	}
-
-	public static function complementaryColor (color:Int) {
-		var rgb = INTtoRGB(color);
-		var r = rgb[0] ^ 0xFF;
-		var g = rgb[1] ^ 0xFF;
-		var b = rgb[2] ^ 0xFF;
-		return (255 << 24) | (r << 16) | (g << 8) | b;
-	}
-}

+ 0 - 357
h2d/comp/Component.hx

@@ -1,357 +0,0 @@
-package h2d.comp;
-import h2d.css.Defs;
-
-class Component extends Sprite {
-
-	public var id(default, set) : String;
-	var parentComponent : Component;
-	var classes : Array<String>;
-	var components : Array<Component>;
-	var iconBmp : h2d.Bitmap;
-	var bg : h2d.css.Fill;
-	// the total width and height (includes margin,borders and padding)
-	var width : Float;
-	var height : Float;
-	var contentWidth : Float = 0.;
-	var contentHeight : Float = 0.;
-	var style : h2d.css.Style;
-	var customStyle : h2d.css.Style;
-	var styleSheet : h2d.css.Engine;
-	var needRebuild(default,set) : Bool;
-
-	public function new(name,?parent) {
-		super(parent);
-		this.name = name;
-		classes = [];
-		components = [];
-		if( parentComponent == null )
-			while( parent != null ) {
-				var p = Std.instance(parent, Component);
-				if( p != null ) {
-					parentComponent = p;
-					p.components.push(this);
-					break;
-				}
-				parent = parent.parent;
-			}
-		bg = new h2d.css.Fill(this);
-		needRebuild = true;
-	}
-
-	function getComponentsRec(s : Sprite, ret : Array<Component>) {
-		var c = Std.instance(s, Component);
-		if( c == null ) {
-			for( s in s )
-				getComponentsRec(s, ret);
-		} else
-			ret.push(c);
-	}
-
-	public function getParent() {
-		if( allocated )
-			return parentComponent;
-		var c = parent;
-		while( c != null ) {
-			var cm = Std.instance(c, Component);
-			if( cm != null ) return cm;
-			c = c.parent;
-		}
-		return null;
-	}
-
-	public function getElementById(id:String) {
-		if( this.id == id )
-			return this;
-		for( c in components ) {
-			var c = c.getElementById(id);
-			if( c != null )
-				return c;
-		}
-		return null;
-	}
-
-	function set_needRebuild(v) {
-		needRebuild = v;
-		if( v && parentComponent != null && !parentComponent.needRebuild )
-			parentComponent.needRebuild = true;
-		return v;
-	}
-
-	override function onRemove() {
-		if( parentComponent != null ) {
-			parentComponent.components.remove(this);
-			parentComponent = null;
-		}
-		super.onRemove();
-	}
-
-	override function onAdd() {
-		// lookup our parent component
-		var old = parentComponent;
-		var p = parent;
-		while( p != null ) {
-			var c = Std.instance(p, Component);
-			if( c != null ) {
-				parentComponent = c;
-				if( old != c ) {
-					if( old != null ) old.components.remove(this);
-					c.components.push(this);
-				}
-				needRebuild = true;
-				super.onAdd();
-				return;
-			}
-			p = p.parent;
-		}
-		if( old != null ) old.components.remove(this);
-		parentComponent = null;
-		super.onAdd();
-	}
-
-	public function addCss(cssString) {
-		if( styleSheet == null ) evalStyle();
-		styleSheet.addRules(cssString);
-		needRebuild = true;
-	}
-
-	public function setStyle(?s) {
-		customStyle = s;
-		needRebuild = true;
-		return this;
-	}
-
-	public function getStyle( willWrite ) {
-		if( customStyle == null )
-			customStyle = new h2d.css.Style();
-		if( willWrite )
-			needRebuild = true;
-		return customStyle;
-	}
-
-	public function addStyle(s) {
-		if( customStyle == null )
-			customStyle = new h2d.css.Style();
-		customStyle.apply(s);
-		needRebuild = true;
-		return this;
-	}
-
-	public function addStyleString(s) {
-		if( customStyle == null )
-			customStyle = new h2d.css.Style();
-		new h2d.css.Parser().parse(s, customStyle);
-		needRebuild = true;
-		return this;
-	}
-
-	public function getClasses() : Iterable<String> {
-		return classes;
-	}
-
-	public function hasClass( name : String ) {
-		return Lambda.has(classes, name);
-	}
-
-	public function addClass( name : String ) {
-		if( !Lambda.has(classes, name) ) {
-			classes.push(name);
-			needRebuild = true;
-		}
-		return this;
-	}
-
-	public function toggleClass( name : String, ?flag : Null<Bool> ) {
-		if( flag != null ) {
-			if( flag )
-				addClass(name)
-			else
-				removeClass(name);
-		} else {
-			if( !classes.remove(name) )
-				classes.push(name);
-			needRebuild = true;
-		}
-		return this;
-	}
-
-	public function removeClass( name : String ) {
-		if( classes.remove(name) )
-			needRebuild = true;
-		return this;
-	}
-
-	function set_id(id) {
-		this.id = id;
-		needRebuild = true;
-		return id;
-	}
-
-	function getFont() {
-		return Context.getFont(style.fontName, Std.int(style.fontSize));
-	}
-
-	function evalStyle() {
-		if( parentComponent == null ) {
-			if( styleSheet == null )
-				styleSheet = Context.getDefaultCss();
-		} else {
-			styleSheet = parentComponent.styleSheet;
-			if( styleSheet == null ) {
-				parentComponent.evalStyle();
-				styleSheet = parentComponent.styleSheet;
-			}
-		}
-		styleSheet.applyClasses(this);
-	}
-
-	inline function extLeft() {
-		return style.paddingLeft + style.marginLeft + style.borderSize;
-	}
-
-	inline function extTop() {
-		return style.paddingTop + style.marginTop + style.borderSize;
-	}
-
-	inline function extRight() {
-		return style.paddingRight + style.marginRight + style.borderSize;
-	}
-
-	inline function extBottom() {
-		return style.paddingBottom + style.marginBottom + style.borderSize;
-	}
-
-	function resize( c : Context ) {
-		if( c.measure ) {
-			if( style.width != null ) contentWidth = style.width;
-			if( style.height != null ) contentHeight = style.height;
-			width = contentWidth + extLeft() + extRight();
-			height = contentHeight + extTop() + extBottom();
-		} else {
-			if( style.positionAbsolute ) {
-				var p = parent == null ? new h2d.col.Point() : parent.localToGlobal();
-				x = style.offsetX + extLeft() - p.x;
-				y = style.offsetY + extTop() - p.y;
-			} else {
-				if( c.xPos != null ) x = c.xPos + style.offsetX + extLeft();
-				if( c.yPos != null ) y = c.yPos + style.offsetY + extTop();
-			}
-			bg.clear();
-			bg.x = style.marginLeft - extLeft();
-			bg.y = style.marginTop - extTop();
-
-			if (style.borderRadius != null && style.borderRadius > 0) {
-				var radius = style.borderRadius;
-				var _w = contentWidth + style.paddingLeft + style.paddingRight;
-				var _h = contentHeight + style.paddingTop + style.paddingBottom;
-
-				bg.lineRoundRect(style.borderColor, 0, 0, width - (style.marginLeft + style.marginRight), height - (style.marginTop + style.marginBottom), style.borderSize, radius);
-				bg.arc(style.borderColor, style.borderSize + radius, style.borderSize + radius, style.borderSize + radius, style.borderSize, Math.PI, Math.PI + Math.PI / 2 );
-				bg.arc(style.borderColor, style.borderSize - radius + _w, style.borderSize + radius, style.borderSize + radius, style.borderSize, Math.PI + Math.PI / 2, Math.PI * 2 );
-				bg.arc(style.borderColor, style.borderSize - radius + _w, style.borderSize - radius + _h, style.borderSize + radius, style.borderSize, 0, Math.PI / 2 );
-				bg.arc(style.borderColor, style.borderSize + radius, style.borderSize - radius + _h, style.borderSize + radius, style.borderSize, Math.PI / 2, Math.PI );
-
-				bg.fillArc(style.backgroundColor, style.borderSize + radius, style.borderSize + radius, radius, Math.PI, Math.PI + Math.PI / 2 );
-				bg.fillArc(style.backgroundColor, style.borderSize - radius + _w, style.borderSize + radius, radius, Math.PI + Math.PI / 2, Math.PI * 2 );
-				bg.fillArc(style.backgroundColor, style.borderSize - radius + _w, style.borderSize - radius + _h, radius, 0, Math.PI / 2 );
-				bg.fillArc(style.backgroundColor, style.borderSize + radius, style.borderSize - radius + _h, radius, Math.PI / 2, Math.PI );
-
-				bg.fillRect(style.backgroundColor, style.borderSize + radius, style.borderSize, _w - radius * 2, radius);
-				bg.fillRect(style.backgroundColor, style.borderSize + radius, style.borderSize + _h - radius , _w - radius * 2, radius);
-				bg.fillRect(style.backgroundColor, style.borderSize, style.borderSize + radius, radius, _h - radius * 2);
-				bg.fillRect(style.backgroundColor, style.borderSize + _w - radius, style.borderSize + radius, radius, _h - radius * 2);
-
-				bg.fillRect(style.backgroundColor, style.borderSize + radius, style.borderSize + radius, _w - radius * 2, _h - radius * 2);
-			} else {
-				bg.lineRect(style.borderColor, 0, 0, width - (style.marginLeft + style.marginRight), height - (style.marginTop + style.marginBottom), style.borderSize);
-				bg.fillRect(style.backgroundColor, style.borderSize, style.borderSize, contentWidth + style.paddingLeft + style.paddingRight, contentHeight + style.paddingTop + style.paddingBottom);
-			}
-
-			if( style.icon != null ) {
-				if( iconBmp == null )
-					iconBmp = new h2d.Bitmap(null);
-				bg.addChildAt(iconBmp, 0);
-				iconBmp.x = extLeft() - style.paddingLeft + style.iconLeft;
-				iconBmp.y = extTop() - style.paddingTop + style.iconTop;
-				iconBmp.tile = Context.makeTileIcon(style.icon);
-				iconBmp.colorKey = 0xFFFF00FF;
-				iconBmp.color.setColor(style.iconColor != null ? style.iconColor : 0xFFFFFFFF);
-			} else if( iconBmp != null ) {
-				iconBmp.remove();
-				iconBmp = null;
-			}
-		}
-	}
-
-	function resizeRec( ctx : Context ) {
-		resize(ctx);
-		if( ctx.measure ) {
-			for( c in components )
-				c.resizeRec(ctx);
-		} else {
-			var oldx = ctx.xPos;
-			var oldy = ctx.yPos;
-			if( style.layout == Absolute ) {
-				ctx.xPos = null;
-				ctx.yPos = null;
-			} else {
-				ctx.xPos = 0;
-				ctx.yPos = 0;
-			}
-			for( c in components )
-				c.resizeRec(ctx);
-			ctx.xPos = oldx;
-			ctx.yPos = oldy;
-		}
-	}
-
-	override function drawRec( ctx : h2d.RenderContext ) {
-		if( style.overflowHidden ) {
-			var px = (absX + 1) / matA + 1e-10;
-			var py = (absY - 1) / matD + 1e-10;
-			ctx.engine.setRenderZone(Std.int(px + style.marginLeft - extLeft()), Std.int(py + style.marginTop - extTop()), Std.int(width - (style.marginLeft + style.marginRight)), Std.int(height - (style.marginTop + style.marginBottom)));
-		}
-		super.drawRec(ctx);
-		if( style.overflowHidden )
-			ctx.engine.setRenderZone();
-	}
-
-	function evalStyleRec() {
-		needRebuild = false;
-		evalStyle();
-		if( style.display != null )
-			visible = style.display;
-		for( c in components )
-			c.evalStyleRec();
-	}
-
-	function textAlign( tf : h2d.Text ) {
-		if( style.width == null ) {
-			tf.x = 0;
-			return;
-		}
-		switch( style.textAlign ) {
-		case Left:
-			tf.x = 0;
-		case Right:
-			tf.x = style.width - tf.textWidth;
-		case Center:
-			tf.x = Std.int((style.width - tf.textWidth) * 0.5);
-		}
-	}
-
-	public function refresh() {
-		needRebuild = true;
-	}
-
-	override function sync( ctx : RenderContext ) {
-		if( needRebuild ) {
-			evalStyleRec();
-			var ctx = new Context(ctx.engine.width, ctx.engine.height);
-			resizeRec(ctx);
-			ctx.measure = false;
-			resizeRec(ctx);
-		}
-		super.sync(ctx);
-	}
-
-}

+ 0 - 47
h2d/comp/Context.hx

@@ -1,47 +0,0 @@
-package h2d.comp;
-
-class Context {
-
-	// measure props
-	public var measure : Bool;
-	public var maxWidth : Float;
-	public var maxHeight : Float;
-	// arrange props
-	public var xPos : Null<Float>;
-	public var yPos : Null<Float>;
-
-	public function new(w, h) {
-		this.maxWidth = w;
-		this.maxHeight = h;
-		measure = true;
-	}
-
-	// ------------- STATIC API ---------------------------------------
-
-	public dynamic static function getFont( name : String, size : Int ) {
-		return hxd.res.FontBuilder.getFont(name, size);
-	}
-
-	public static function makeTileIcon( pixels : hxd.Pixels ) : h2d.Tile {
-		var t = cachedIcons.get(pixels);
-		if( t != null && !t.isDisposed() )
-			return t;
-		t = h2d.Tile.fromPixels(pixels);
-		cachedIcons.set(pixels, t);
-		return t;
-	}
-
-	static var cachedIcons = new Map<hxd.Pixels,h2d.Tile>();
-
-	public static var DEFAULT_CSS = hxd.res.Embed.getFileContent("h2d/css/default.css");
-
-	static var DEF = null;
-	public static function getDefaultCss() {
-		if( DEF != null )
-			return DEF;
-		var e = new h2d.css.Engine();
-		e.addRules(DEFAULT_CSS);
-		return e;
-	}
-
-}

+ 0 - 652
h2d/comp/GradientEditor.hx

@@ -1,652 +0,0 @@
-package h2d.comp;
-import h2d.css.Defs;
-import h2d.css.Fill;
-
-private typedef Key = { x:Float, value:Int };
-
-private enum KCursor {
-	KAlpha;
-	KColor;
-}
-
-private enum CompStyle {
-	CLabel;
-	CInput;
-	CInputSmall;
-}
-
-private class Style {
-	public function new () {
-	}
-
-	public static function get(kind:CompStyle) {
-		var style = new h2d.css.Style();
-		switch(kind) {
-			case CLabel: 		style.fontSize = 12;
-			case CInputSmall: 	style.width = 24;
-								style.height = 10;
-								style.fontSize = 11;
-			case CInput: 		style.width = 50;
-								style.height = 10;
-								style.fontSize = 11;
-		}
-		return style;
-	}
-}
-
-private class CFlag extends h2d.css.Fill {
-
-	public function new (parent, x:Float, y:Float, ang = 0., color = 0xff000000, border = 0xFFaaaaaa) {
-		super(parent);
-		var fill = this;
-		fill.rotation = -ang;
-		fill.x = x;
-		fill.y = y;
-		//bg
-
-		// bgarrow
-		fill.addPoint(-5, -4, border);
-		fill.addPoint(5, -4, border);
-		fill.addPoint(0, 0, border);
-		fill.addPoint(0, 0, border);
-
-		// bgsquare
-		var dy = -5;
-		fill.addPoint(-5, -9 + dy, border);
-		fill.addPoint(5, -9 + dy, border);
-		fill.addPoint(-5, 1 + dy, border);
-		fill.addPoint(5, 1 + dy, border);
-
-		// arrow
-		fill.addPoint(-4, -5, color);
-		fill.addPoint(4, -5, color);
-		fill.addPoint(0, 0, color);
-		fill.addPoint(0, 0, color);
-
-		// square
-		fill.addPoint(-4, -8+dy, color);
-		fill.addPoint(4, -8+dy, color);
-		fill.addPoint(-4, 0+dy, color);
-		fill.addPoint(4, 0+dy, color);
-	}
-}
-
-private class Cursor extends h2d.Sprite {
-	var gradient : GradientEditor;
-	public var value(default, set):Int;
-	public var coeff(get, null):Float;
-	public var color:Int = 0xFFFFFFFF;
-	public var bgcolor:Int = 0xFFFF00FF;
-	public var cursor:h2d.Sprite;
-	public var kind:KCursor;
-	var ang:Float;
-	var interact:h2d.Interactive;
-	var flag:CFlag;
-
-	public function new(gradient,ix, iy, kind, value, ang, parent) {
-		super(parent);
-		this.gradient = gradient;
-		x = ix;
-		y = iy;
-		this.value = value;
-		this.ang = ang;
-		this.kind = kind;
-		init();
-	}
-
-	function set_value(v) {
-		value = v;
-		if(flag != null) {
-			switch(kind) {
-				case KColor: color = value;
-				case KAlpha: color = (255 << 24) | (value << 16) | (value << 8) | value;
-			}
-			flag.remove();
-			flag = new CFlag(cursor, 0, 0, ang, color, bgcolor);
-		}
-		return value;
-	}
-
-	function get_coeff() {
-		return x / gradient.boxWidth;
-	}
-
-	function init() {
-		cursor = new h2d.Sprite(this);
-		switch(kind) {
-			case KColor: color = value;
-			case KAlpha: color = (255 << 24) | (value << 16) | (value << 8) | value;
-		}
-		flag = new CFlag(cursor, 0, 0, ang, color, bgcolor);
-		interact = new h2d.Interactive(10, 14, this);
-		interact.x = -5;
-		if(kind.equals(KAlpha))
-			interact.y = -14;
-
-		interact.onPush = function(e) drag();
-		interact.onRelease = function(e) stopDrag();
-	}
-
-	public function drag() {
-		interact.startDrag(function(e) {
-			if( e.kind == EMove ){
-				setCursor(x + (e.relX-5));
-				if(e.relY < - 6 ||  e.relY > 16 + 6)
-					gradient.dragOut = true;
-				else gradient.dragOut = false;
-			}
-			gradient.dragTarget = this ;
-		});
-
-		gradient.updateTarget = this;
-		this.parent.addChild(this);
-	}
-
-	public function stopDrag() {
-		interact.stopDrag();
-		if( !visible ) remove();
-		gradient.dragTarget = null ;
-		gradient.dragOut = false;
-	}
-
-	public function select() {
-		bgcolor = 0xFFFF00FF;
-		flag.remove();
-		flag = new CFlag(cursor, 0, 0, ang, color, bgcolor);
-
-		if(gradient.colorPicker.visible)
-			gradient.colorPicker.color = color;
-	}
-
-	public function unselect() {
-		bgcolor = 0xFFAAAAAA;
-		flag.remove();
-		flag = new CFlag(cursor, 0, 0, ang, color, bgcolor);
-	}
-
-	public function setCursor(px:Float) {
-		x = Math.max(0, Math.min(gradient.boxWidth, px));
-	}
-}
-
-
-private class AlphaSelector extends h2d.Sprite {
-	public var target(default, set):Cursor;
-	var gradient : GradientEditor;
-	var title:h2d.comp.Label;
-	var slider:h2d.comp.Slider;
-	var alphaInput:h2d.comp.Input;
-	var locLabel:h2d.comp.Label;
-	var locInput:h2d.comp.Input;
-
-	public function new (gradient,ix, iy, parent) {
-		super(parent);
-		this.gradient = gradient;
-		x = ix;
-		y = iy;
-		init();
-	}
-
-	function init() {
-		title = new h2d.comp.Label("Alpha", this);
-		title.addStyle(Style.get(CLabel));
-
-		slider = new h2d.comp.Slider(this);
-		slider.x = 55; slider.y = 4;
-		slider.onChange = function(v) { updateSlider(v); };
-		slider.value = 1;
-
-		alphaInput = new h2d.comp.Input(this);
-		alphaInput.addStyle(Style.get(CInputSmall));
-		alphaInput.x = 170;
-		alphaInput.value = "255";
-		alphaInput.onChange = function(e) {
-			var v = Std.parseFloat(alphaInput.value);
-			if (!Math.isNaN(v)) {
-				v = Math.min(255, v) / 255;
-				updateSlider(v);
-				slider.value = v;
-			}
-		};
-
-		locLabel = new h2d.comp.Label("Location             %", this);
-		locLabel.setStyle(Style.get(CLabel));
-		locLabel.x = 255;
-		locInput = new h2d.comp.Input(this);
-		locInput.setStyle(Style.get(CInput));
-		locInput.x = 320;
-		locInput.value = "100.00";
-		locInput.onChange = function(e) {
-			var v = Std.parseFloat(locInput.value);
-			if (!Math.isNaN(v)) {
-				v = Math.min(100, v);
-				target.setCursor( v * gradient.boxWidth / 100 );
-			}
-		};
-	}
-
-	public function update() {
-		if(target == null)
-			return;
-		locInput.value = Std.string(Math.floor(target.coeff * 100 * 100) / 100);
-	}
-
-	function set_target(cursor:Cursor) {
-		target = cursor;
-		var v = target.value / 255;
-		slider.value = v;
-		locInput.value = Std.string(Math.floor(target.coeff * 100 * 100) / 100);
-		updateSlider(v);
-		return target;
-	}
-
-	function updateSlider(v:Float) {
-		var alpha = Math.round(255 * v);
-		alphaInput.value = Std.string(alpha);
-		if(target == null)
-			return;
-		target.value = alpha;
-	}
-}
-
-private class ColorSelector extends h2d.Sprite {
-	public var target(default, set):Cursor;
-	var gradient : GradientEditor;
-	var title:h2d.comp.Label;
-	var locLabel:h2d.comp.Label;
-	var locInput:h2d.comp.Input;
-	var colorInput:h2d.comp.Input;
-	var canvas:h2d.css.Fill;
-	var color:Int = 0xFFFFFFFF;
-	var interact : h2d.Interactive;
-
-	public function new(gradient,ix, iy, parent) {
-		super(parent);
-		this.gradient = gradient;
-		x = ix;
-		y = iy;
-		init();
-	}
-
-	public function update() {
-		if(target == null)
-			return;
-		locInput.value = Std.string(Math.floor(target.coeff * 100 * 100) / 100);
-	}
-
-	function set_target(cursor:Cursor) {
-		target = cursor;
-		locInput.value = Std.string(Math.floor(target.coeff * 100 * 100) / 100);
-		color = target.value;
-		colorInput.value = StringTools.hex(color, 8).substr(2);
-		redraw();
-		return target;
-	}
-
-	function init() {
-		title = new h2d.comp.Label("Color                         #", this);
-		title.setStyle(Style.get(CLabel));
-
-		canvas = new Fill(this);
-		canvas.x = 45;
-		canvas.y = -8;
-		interact = new h2d.Interactive(110, 25, this);
-		interact.x = 50;
-		interact.y = -8;
-		interact.onPush = function(e) {
-			if(target == null)
-				return;
-
-			if(!gradient.colorPicker.visible) {
-				gradient.colorPicker.visible = true;
-				gradient.colorPicker.color = color;
-				gradient.colorPicker.onChange = function(v) {
-					color = target.value = v;
-					colorInput.value = StringTools.hex(v, 8).substr(2);
-					redraw();
-				}
-			}
-			else {
-				gradient.colorPicker.onChange = function(v) { };
-				gradient.colorPicker.visible = false;
-			}
-		};
-
-		colorInput = new h2d.comp.Input(this);
-		colorInput.setStyle(Style.get(CInput));
-		colorInput.x = 175;
-		colorInput.value = "FFFFFF";
-		colorInput.onChange = function (e) {
-			colorInput.value = colorInput.value.toUpperCase();
-			if(colorInput.value.length > 6) {
-				colorInput.value = colorInput.value.substr(0, 6);
-				return;
-			}
-			var v = Std.parseInt("0x" + colorInput.value);
-			if (v != null) {
-				color = target.value = 255 << 24 | v;
-				redraw();
-			}
-		};
-
-		locLabel = new h2d.comp.Label("Location             %", this);
-		locLabel.setStyle(Style.get(CLabel));
-		locLabel.x = 265;
-
-		locInput = new h2d.comp.Input(this);
-		locInput.setStyle(Style.get(CInput));
-		locInput.x = 330;
-		locInput.value = "100.00";
-		locInput.onChange = function(e) {
-			var v = Std.parseFloat(locInput.value);
-			if (!Math.isNaN(v)) {
-				v = Math.min(100, v);
-				locInput.value = Std.string(Math.floor(v * 100) / 100);
-				target.setCursor( v * gradient.boxWidth / 100 );
-			}
-		};
-
-		redraw();
-	}
-
-	function redraw() {
-		canvas.clear();
-		canvas.fillRectColor(0, 0, 110, 25, color);
-		canvas.lineRect(FillStyle.Color(gradient.borderColor), 0, 0, 110, 25, 1);
-	}
-}
-
-
-//////////////////////////////////////////////////////////
-
-class GradientEditor extends h2d.comp.Component {
-
-	public var borderColor = 0xFF888888;
-	public var dragTarget:Cursor;
-	public var dragOut:Bool;
-	public var updateTarget:Cursor;
-	public var boxWidth = 430;
-	var boxHeight = 100;
-
-	var keys:Array<Key>;
-	var colorsKeys:Array<Cursor>;
-	var alphaKeys:Array<Cursor>;
-
-	var box:h2d.Sprite;
-	var gradient:Fill;
-	var hudAlpha: AlphaSelector;
-	var hudColor: ColorSelector;
-
-	public var colorPicker:ColorPicker;
-
-	var interactUp:h2d.Interactive;
-	var interactDown:h2d.Interactive;
-
-
-	var withAlpha : Bool;
-	var holdCursor:Cursor;
-
-	public function new(?withAlpha = true, ?parent) {
-		super("gradienteditor", parent);
-		this.withAlpha = withAlpha;
-		init();
-	}
-
-	function init() {
-		colorsKeys = [];
-		alphaKeys = [];
-
-		interactUp = new h2d.Interactive(boxWidth, 16, this);
-		interactUp.x = 10;
-		interactUp.y = 30 - 16;
-		interactUp.onPush =  function(e) createAlphaKey(e.relX, 0);
-		interactDown = new h2d.Interactive(boxWidth, 16, this);
-		interactDown.x = 10;
-		interactDown.y = 30 + boxHeight;
-		interactDown.onPush =  function(e) createColorKey(e.relX, boxHeight);
-
-		box = new h2d.Sprite(this);
-		box.x = 10;
-		box.y = 30;
-		drawChecker();
-
-		hudColor = new ColorSelector(this, 20, box.y + boxHeight + 30, this);
-		hudAlpha = new AlphaSelector(this, 20, box.y + boxHeight + 30, this);
-		hudAlpha.visible = false;
-		hudAlpha.y = 0;
-
-		colorPicker = new ColorPicker(this);
-		colorPicker.y = 220;
-		colorPicker.visible = false;
-		colorPicker.onClose = function() colorPicker.visible = false;
-
-		setKeys([ { x : 0, value:0xFFFFFFFF }, { x: 1, value:0xFFFFFFFF } ],null);
-	}
-
-	public dynamic function onChange( keys : Array<Key> ) {
-	}
-
-	public function setKeys(keys:Array<Key>,?kalpha:Array<Key>) {
-		while( colorsKeys.length > 0 )
-			colorsKeys.shift().remove();
-		while( alphaKeys.length > 0 )
-			alphaKeys.shift().remove();
-		for( k in keys ) {
-			var c = new Cursor(this, k.x * boxWidth, boxHeight, KColor, k.value | 0xFF000000, Math.PI, box);
-			colorsKeys.push(c);
-		}
-		if( withAlpha ) {
-			for( a in (kalpha == null ? keys : kalpha) ) {
-				var c = new Cursor(this, a.x * boxWidth, 0, KAlpha, a.value >>> 24, 0, box);
-				alphaKeys.push(c);
-			}
-		}
-		updateKeys();
-		updateTarget = colorsKeys[0];
-	}
-
-	override function sync(ctx) {
-		if(dragTarget != null) {
-			if(dragOut) {
-				switch(dragTarget.kind) {
-					case KColor: if(colorsKeys.length > 1) {
-						colorsKeys.remove(dragTarget);
-						holdCursor = dragTarget;
-						dragTarget.visible = false;
-					}
-					case KAlpha: if(alphaKeys.length > 1) {
-						alphaKeys.remove(dragTarget);
-						holdCursor = dragTarget;
-						dragTarget.visible = false;
-					}
-				}
-			}
-			else if(holdCursor == dragTarget) {
-				holdCursor = null;
-				dragTarget.visible = true;
-				switch(dragTarget.kind) {
-					case KColor: colorsKeys.push(dragTarget);
-					case KAlpha: alphaKeys.push(dragTarget);
-				}
-			}
-
-			hudAlpha.update();
-			hudColor.update();
-		}
-		else holdCursor = null;
-
-		if(updateTarget != null) {
-			changeHud(updateTarget);
-			updateFlags(updateTarget);
-			updateTarget = null;
-		}
-
-		updateKeys();
-
-		super.sync(ctx);
-	}
-
-	function createAlphaKey(px:Float, py:Float) {
-		if( !withAlpha )
-			return;
-		var cursor = new Cursor(this, px, py, KAlpha, getAlphaAt(px / boxWidth), 0, box);
-		alphaKeys.push(cursor);
-		updateTarget = cursor;
-		cursor.drag();
-	}
-
-	function createColorKey(px:Float, py:Float) {
-		var cursor = new Cursor(this, px, py, KColor, getColorAt(px / boxWidth), Math.PI, box);
-		colorsKeys.push(cursor);
-		updateTarget = cursor;
-		cursor.drag();
-	}
-
-	function updateKeys() {
-		var keys = [];
-		for (i in 0...colorsKeys.length) {
-			var k = colorsKeys[i];
-			var alpha = getAlphaAt(k.coeff);
-			var rgb = INTtoRGB(k.value);
-			keys.push( { x:k.coeff, value:RGBtoINT(rgb[0], rgb[1], rgb[2], alpha) } );
-		}
-
-		for (i in 0...alphaKeys.length) {
-			var k = alphaKeys[i];
-			var alpha = k.value;
-			var rgb = INTtoRGB(getColorAt(k.coeff));
-			keys.push( { x:k.coeff, value:RGBtoINT(rgb[0], rgb[1], rgb[2], alpha) } );
-		}
-
-		keys.sort(function(a, b) return Reflect.compare(a.x, b.x) );
-		if(keys[0].x != 0)
-			keys.insert(0, { x:0, value:keys[0].value } );
-		if(keys[keys.length - 1].x != 1)
-			keys.push( { x:1, value:keys[keys.length - 1].value } );
-		if( Std.string(keys) != Std.string(this.keys) ) {
-			this.keys = keys;
-			drawGradient();
-			onChange(keys);
-		}
-	}
-
-	function getARGBAt(x:Float) {
-		var alpha = getAlphaAt(x);
-		var rgb = INTtoRGB(getColorAt(x));
-		return RGBtoINT(rgb[0], rgb[1], rgb[2], alpha);
-	}
-
-	function getAlphaAt(x:Float) {
-		if( !withAlpha )
-			return 255;
-		alphaKeys.sort(function(a, b) return Reflect.compare(a.coeff, b.coeff) );
-		var prev = null;
-		var next = null;
-		for (i in 0...alphaKeys.length) {
-			var k = alphaKeys[i];
-			if (k.coeff == x)
-				return k.value;
-			else if (k.coeff < x)
-				prev = k;
-			else if (k.coeff > x) {
-				if(prev == null)
-					return k.value;
-				else next = k;
-				break;
-			}
-		}
-		if(next == null)
-			return prev.value;
-		var d = (x - prev.coeff) / (next.coeff - prev.coeff);
-		return Math.round(prev.value + (next.value - prev.value) * d);
-	}
-
-	function getColorAt(x:Float) {
-		colorsKeys.sort(function(a, b) return Reflect.compare(a.coeff, b.coeff) );
-		var prev = null;
-		var next = null;
-		for (i in 0...colorsKeys.length) {
-			var k = colorsKeys[i];
-			if (k.coeff == x)
-				return k.value;
-			else if (k.coeff < x)
-				prev = k;
-			else if (k.coeff > x) {
-				if(prev == null)
-					return k.value;
-				else next = k;
-				break;
-			}
-		}
-		if(next == null)
-			return prev.value;
-
-		var d = (x - prev.coeff) / (next.coeff - prev.coeff);
-		var pRGB = INTtoRGB(prev.value);
-		var nRGB = INTtoRGB(next.value);
-		var rgb = [];
-		for (i in 0...3)
-			rgb.push(Math.round(pRGB[i] + (nRGB[i] - pRGB[i]) * d));
-		return RGBtoINT(rgb[0], rgb[1], rgb[2]);
-	}
-
-	function drawGradient() {
-		box.removeChild(gradient);
-		gradient = new Fill(box);
-		for (i in 0...keys.length - 1) {
-			var c1 = keys[i];
-			var c2 = keys[i + 1];
-			gradient.fillRectGradient(boxWidth * c1.x, 0, boxWidth * (c2.x - c1.x), boxHeight, c1.value, c2.value, c1.value, c2.value);
-		}
-		gradient.lineRect(FillStyle.Color(borderColor), 0, 0, boxWidth, boxHeight, 2);
-	}
-
-	function drawChecker() {
-		var checker = new Fill(box);
-		var nb = 90;
-		var size = Math.ceil(boxWidth / nb);
-		for (i in 0...nb) {
-			for (j in 0...nb) {
-				if(i * size >= boxWidth) break;
-				if(j * size >= boxHeight) break;
-				var color = ((i + j) % 2 == 0) ? 0xFFFFFFFF:0xFFAAAAAA;
-				checker.fillRect(FillStyle.Color(color), i * size, j * size, size, size);
-			}
-		}
-	}
-
-	function changeHud(cursor:Cursor) {
-		switch(cursor.kind) {
-			case KAlpha: 	hudAlpha.target = cursor;
-							hudAlpha.visible = true;
-							hudAlpha.y = box.y + boxHeight + 30;
-							hudColor.visible = false;
-			case KColor:	hudColor.target = cursor;
-							hudColor.visible = true;
-							hudAlpha.visible = false;
-							hudAlpha.y =  0;
-		}
-	}
-
-	function updateFlags(cursor:Cursor) {
-		for (c in alphaKeys) {
-			if (c == cursor)
-				c.select();
-			else c.unselect();
-		}
-		for (c in colorsKeys) {
-			if (c == cursor)
-				c.select();
-			else c.unselect();
-		}
-	}
-
-
-	inline public static function INTtoRGB(color:Int) {
-		return [(color >> 16) & 0xFF, (color >> 8) & 0xFF,  color & 0xFF, color >>> 24];
-	}
-
-	inline public static function RGBtoINT(r:Int, g:Int, b:Int, a:Int = 255) {
-		return (a << 24) | (r << 16) | (g << 8) | b;
-	}
-}

+ 0 - 147
h2d/comp/Input.hx

@@ -1,147 +0,0 @@
-package h2d.comp;
-import hxd.Key;
-
-@:access(h2d.comp.Input.scene)
-class Input extends Interactive {
-
-	var tf : h2d.Text;
-	var cursor : h2d.Bitmap;
-	var cursorPos(default, set) : Int;
-	public var smooth = true;
-	public var value(default, set) : String;
-
-	public function new(?parent) {
-		super("input",parent);
-		tf = new h2d.Text(null, this);
-		input.cursor = TextInput;
-		cursor = new h2d.Bitmap(null, bg);
-		cursor.visible = false;
-		var ctrlDown = false;
-		input.onFocus = function(_) {
-			ctrlDown = false;
-			addClass(":focus");
-			cursor.visible = true;
-			onFocus();
-		};
-		input.onFocusLost = function(_) {
-			removeClass(":focus");
-			cursor.visible = false;
-			onBlur();
-		};
-		input.onKeyDown = function(e:hxd.Event) {
-			if( input.hasFocus() ) {
-				// BACK
-				switch( e.keyCode ) {
-				case Key.LEFT:
-					if( cursorPos > 0 )
-						cursorPos--;
-				case Key.RIGHT:
-					if( cursorPos < value.length )
-						cursorPos++;
-				case Key.HOME:
-					cursorPos = 0;
-				case Key.END:
-					cursorPos = value.length;
-				case Key.DELETE:
-					value = value.substr(0, cursorPos) + value.substr(cursorPos + 1);
-					onChange(value);
-					return;
-				case Key.BACKSPACE:
-					if( cursorPos > 0 ) {
-						value = value.substr(0, cursorPos - 1) + value.substr(cursorPos);
-						cursorPos--;
-						onChange(value);
-					}
-					return;
-				case Key.ENTER:
-					input.blur();
-					return;
-				case Key.CTRL:
-					ctrlDown = true;
-				}
-				if( ctrlDown ) {
-					switch( e.keyCode ) {
-					case "V".code:
-						/*var clip = hxd.System.getClipboard();
-						if( clip != "" ) {
-							clip = clip.split("\t").join(" ").split("\r\n").join(" ").split("\r").join(" ").split("\n").join(" ");
-							value = value.substr(0, cursorPos) + clip + value.substr(cursorPos);
-							cursorPos += clip.length;
-							onChange(value);
-						}*/
-					default:
-					}
-					return;
-				}
-				if( e.charCode != 0 ) {
-					value = value.substr(0, cursorPos) + String.fromCharCode(e.charCode) + value.substr(cursorPos);
-					cursorPos++;
-					onChange(value);
-				}
-			}
-		};
-		input.onKeyUp = function(e:hxd.Event) {
-			if( e.keyCode == Key.CTRL ) ctrlDown = false;
-		};
-		this.value = "";
-	}
-
-	function set_cursorPos(v:Int) {
-		textAlign(tf);
-		cursor.x = tf.x + tf.calcTextWidth(value.substr(0, v)) + extLeft();
-		if( cursor.x > width - 4 ) {
-			var dx = cursor.x - (width - 4);
-			tf.x -= dx;
-			cursor.x -= dx;
-		}
-		return cursorPos = v;
-	}
-
-	public function focus() {
-		input.focus();
-		cursorPos = value.length;
-	}
-
-	function get_value() {
-		return tf.text;
-	}
-
-	function set_value(t) {
-		needRebuild = true;
-		return value = t;
-	}
-
-	override function resize( ctx : Context ) {
-		if( ctx.measure ) {
-			tf.font = getFont();
-			tf.textColor = style.color;
-			tf.text = value;
-			tf.smooth = smooth;
-			textAlign(tf);
-			contentWidth = tf.textWidth;
-			contentHeight = tf.textHeight;
-			if( cursorPos < 0 ) cursorPos = 0;
-			if( cursorPos > value.length ) cursorPos = value.length;
-			cursorPos = cursorPos;
-		}
-		super.resize(ctx);
-		if( !ctx.measure ) {
-			cursor.y = extTop() - 1;
-			cursor.tile = h2d.Tile.fromColor(style.cursorColor, 1, Std.int(height - extTop() - extBottom() + 2));
-		}
-	}
-
-	override function onClick() {
-		focus();
-	}
-
-	public dynamic function onChange( value : String ) {
-	}
-
-	public dynamic function onFocus() {
-	}
-
-	public dynamic function onBlur() {
-	}
-
-}

+ 0 - 78
h2d/comp/Interactive.hx

@@ -1,78 +0,0 @@
-package h2d.comp;
-
-class Interactive extends Component {
-
-	var input : h2d.Interactive;
-	var active : Bool;
-	var activeRight : Bool;
-
-	function new(kind,?parent) {
-		super(kind,parent);
-		input = new h2d.Interactive(0, 0, bg);
-		input.enableRightButton = true;
-		active = false;
-		activeRight = false;
-		input.onPush = function(e) {
-			switch( e.button ) {
-			case 0:
-				active = true;
-				onMouseDown();
-			case 1:
-				activeRight = true;
-			}
-		};
-		input.onOver = function(_) {
-			addClass(":hover");
-			onMouseOver();
-		};
-		input.onOut = function(_) {
-			active = false;
-			activeRight = false;
-			removeClass(":hover");
-			onMouseOut();
-		};
-		input.onRelease = function(e) {
-			switch( e.button ) {
-			case 0:
-				if( active ) {
-					active = false;
-					onClick();
-				}
-				onMouseUp();
-			case 1:
-				if( activeRight ) {
-					activeRight = false;
-					onRightClick();
-				}
-			}
-		};
-	}
-
-	override function resize( ctx : Context ) {
-		super.resize(ctx);
-		if( !ctx.measure ) {
-			input.width = width - (style.marginLeft + style.marginRight);
-			input.height = height - (style.marginTop + style.marginBottom);
-			input.visible = !hasClass(":disabled");
-		}
-	}
-
-	public dynamic function onMouseOver() {
-	}
-
-	public dynamic function onMouseOut() {
-	}
-
-	public dynamic function onMouseDown() {
-	}
-
-	public dynamic function onMouseUp() {
-	}
-
-	public dynamic function onClick() {
-	}
-
-	public dynamic function onRightClick() {
-	}
-
-}

+ 0 - 92
h2d/comp/ItemList.hx

@@ -1,92 +0,0 @@
-package h2d.comp;
-
-class ItemList extends Box {
-
-	public var selected(default,set) = -1;
-	var inputs : Array<h2d.Interactive>;
-
-	public function new(?parent) {
-		super(Vertical, parent);
-		this.name = "itemlist";
-		inputs = [];
-	}
-
-	function set_selected(v:Int) {
-		needRebuild = true;
-		return selected = v;
-	}
-
-	function onWheel( e : hxd.Event ) {
-		scrollY -= e.wheelDelta * (components.length == 0 ? 0 : (components[0].height + style.verticalSpacing));
-		if( scrollY > 0 ) scrollY = 0;
-		e.propagate = false;
-		needRebuild = true;
-	}
-
-	override function resizeRec( ctx : Context ) {
-		super.resizeRec(ctx);
-		if( !ctx.measure ) {
-			while( inputs.length < components.length )
-				inputs.push(new h2d.Interactive(0, 0, this));
-			while( inputs.length > components.length )
-				inputs.pop().remove();
-			for( i in 0...components.length ) {
-				var c = components[i];
-				var int = inputs[i];
-				var selected = selected == i;
-				var cursor = null;
-				int.x = -style.paddingLeft;
-				int.y = c.y - style.verticalSpacing * 0.5;
-				int.width = contentWidth + style.paddingLeft + style.paddingRight;
-				int.height = c.height + style.verticalSpacing;
-				var oldCursor = int.getChildAt(0);
-				if( oldCursor != null ) {
-					cursor = Std.instance(oldCursor, h2d.Bitmap);
-					if( cursor == null ) oldCursor.remove();
-				}
-				if( selected ) {
-					if( cursor != null ) cursor.remove();
-					cursor = new h2d.Bitmap(h2d.Tile.fromColor(style.selectionColor, Std.int(int.width), Std.int(int.height), (style.selectionColor>>>24)/255), int);
-					int.onOver = function(_) {
-						onItemOver(i);
-					};
-					int.onOut = function(_) {
-						onItemOver(-1);
-					}
-					int.onPush = function(_) {
-					}
-				} else {
-					int.onOver = function(_) {
-						if( cursor != null ) cursor.remove();
-						cursor = new h2d.Bitmap(h2d.Tile.fromColor(style.cursorColor, Std.int(int.width), Std.int(int.height), (style.cursorColor>>>24)/255 ), int);
-						onItemOver(i);
-					};
-					int.onOut = function(_) {
-						if( cursor != null ) cursor.remove();
-						cursor = null;
-						onItemOver(-1);
-					}
-					int.onPush = function(_) {
-						if( this.selected != i ) {
-							this.selected = i;
-							onChange(i);
-						}
-					}
-				}
-				int.onWheel = onWheel;
-				if( Lambda.indexOf(children,int) != 1 + i ) {
-					children.remove(int);
-					children.insert(1 + i, int); // insert over bg
-					int.onParentChanged();
-				}
-			}
-		}
-	}
-
-	public dynamic function onItemOver( current : Int ) {
-	}
-
-	public dynamic function onChange( selected : Int ) {
-	}
-
-}

+ 0 - 226
h2d/comp/JQuery.hx

@@ -1,226 +0,0 @@
-package h2d.comp;
-import h2d.css.Defs;
-
-private typedef Query = Array<CssClass>;
-
-@:access(h2d.comp.Component)
-@:keep
-class JQuery {
-
-	var root : Component;
-	var select : Array<Component>;
-
-	public function new( root : Component, query : Dynamic ) {
-		while( root.parentComponent != null )
-			root = root.parentComponent;
-		this.root = root;
-		select = getSet(query);
-	}
-
-	public function getComponents() {
-		return select;
-	}
-
-	public function toggleClass( cl : String, ?flag : Bool ) {
-		for( s in select ) s.toggleClass(cl,flag);
-		return this;
-	}
-
-	public function find( q : Dynamic ) {
-		if( Std.is(q, Component) )
-			return new JQuery(root, Lambda.has(select, q) ? null : q);
-		if( Std.is(q, String) ) {
-			var q = parseQuery(q);
-			var out = [];
-			for( s in select )
-				lookupRec(s, q, out);
-			return new JQuery(root, out);
-		}
-		throw "Invalid JQuery " + q;
-		return null;
-	}
-
-	public function filter( q : Dynamic ) {
-		if( Std.is(q, Component) )
-			return new JQuery(root, Lambda.has(select, q) ? null : q);
-		if( Std.is(q, String) ) {
-			var q = parseQuery(q);
-			return new JQuery(root, [for( s in select ) if( matchQuery(q, s) ) s]);
-		}
-		if( Std.is(q, JQuery) ) {
-			var q : JQuery = q;
-			return  new JQuery(root, [for( s in select ) if( Lambda.has(q.select, s) ) s]);
-		}
-		throw "Invalid JQuery " + q;
-		return null;
-	}
-
-	public function not( q : Dynamic ) {
-		if( Std.is(q, Component) )
-			return new JQuery(root, [for( s in select ) if( s != q ) s]);
-		if( Std.is(q, String) ) {
-			var q = parseQuery(q);
-			return new JQuery(root, [for( s in select ) if( !matchQuery(q, s) ) s]);
-		}
-		if( Std.is(q, JQuery) ) {
-			var q : JQuery = q;
-			return  new JQuery(root, [for( s in select ) if( !Lambda.has(q.select, s) ) s]);
-		}
-		throw "Invalid JQuery " + q;
-		return null;
-	}
-
-	public function click( f : JQuery -> Void ) {
-		for( c in select ) {
-			var int = Std.instance(c, Interactive);
-			if( int == null ) throw c + " is not interactive";
-			int.onClick = function() f(new JQuery(root,c));
-		}
-		return this;
-	}
-
-	public function show() {
-		for( s in select )
-			s.getStyle(true).display = true;
-		return this;
-	}
-
-	public function hide() {
-		for( s in select )
-			s.getStyle(true).display = false;
-		return this;
-	}
-
-	public function toggle() {
-		for( s in select ) {
-			var s = s.getStyle(true);
-			s.display = !s.display;
-		}
-		return this;
-	}
-
-	public function iterator() {
-		var it = select.iterator();
-		return {
-			hasNext : it.hasNext,
-			next : function() return new JQuery(root, it.next()),
-		};
-	}
-
-	function _get_val() : Dynamic {
-		var c = select[0];
-		if( c == null ) return null;
-		return switch( c.name ) {
-		case "slider":
-			cast(c, h2d.comp.Slider).value;
-		case "checkbox":
-			cast(c, h2d.comp.Checkbox).checked;
-		case "input":
-			cast(c, h2d.comp.Input).value;
-		case "color":
-			cast(c, h2d.comp.Color).value;
-		case "itemlist":
-			cast(c, h2d.comp.ItemList).selected;
-		case "select":
-			cast(c, h2d.comp.Select).value;
-		default:
-			null;
-		}
-	}
-
-	function _set_val( v : Dynamic ) {
-		for( c in select )
-			switch( c.name ) {
-			case "slider":
-				cast(c, h2d.comp.Slider).value = v;
-			case "checkbox":
-				cast(c, h2d.comp.Checkbox).checked = v != null && v != false;
-			case "input":
-				cast(c, h2d.comp.Input).value = Std.string(v);
-			case "color":
-				cast(c, h2d.comp.Color).value = v;
-			case "itemlist":
-				cast(c, h2d.comp.ItemList).selected = v;
-			case "select":
-				cast(c, h2d.comp.Select).setValue(v);
-			default:
-				null;
-			}
-		return this;
-	}
-
-	function _get_text() {
-		var c = select[0];
-		if( c == null ) return "";
-		return switch( c.name ) {
-		case "button":
-			cast(c, h2d.comp.Button).text;
-		case "label":
-			cast(c, h2d.comp.Label).text;
-		default:
-			"";
-		}
-	}
-
-	function _set_text(v:String) {
-		for( c in select )
-			switch( c.name ) {
-			case "button":
-				cast(c, h2d.comp.Button).text = v;
-			case "label":
-				cast(c, h2d.comp.Label).text = v;
-			default:
-			}
-		return this;
-	}
-
-	function _set_style(v:String) {
-		var s = new h2d.css.Style();
-		new h2d.css.Parser().parse(v, s);
-		for( c in select )
-			c.addStyle(s);
-		return this;
-	}
-
-	function getSet( query : Dynamic ) {
-		var set;
-		if( query == null )
-			set = [];
-		else if( Std.is(query,Component) )
-			set = [query];
-		else if( Std.is(query, Array) ) {
-			var a : Array<Dynamic> = query;
-			for( v in a ) if( !Std.is(v, Component) ) throw "Invalid JQuery "+query;
-			set = a;
-		} else if( Std.is(query, String) )
-			set = lookup(root, query);
-		else
-			throw "Invalid JQuery " + query;
-		return set;
-	}
-
-	function lookup( root : Component, query : String ) {
-		var set = [];
-		lookupRec(root, parseQuery(query), set);
-		return set;
-	}
-
-	function parseQuery(q) : Query {
-		return new h2d.css.Parser().parseClasses(q);
-	}
-
-	function matchQuery(q:Query, comp:Component) {
-		for( r in q )
-			if( h2d.css.Engine.ruleMatch(r, comp) )
-				return true;
-		return false;
-	}
-
-	function lookupRec(comp:Component, q, set : Array<Component> ) {
-		if( matchQuery(q, comp) )
-			set.push(comp);
-		for( s in comp.components )
-			lookupRec(s, q, set);
-	}
-
-}

+ 0 - 39
h2d/comp/Label.hx

@@ -1,39 +0,0 @@
-package h2d.comp;
-
-class Label extends Component {
-
-	var tf : h2d.Text;
-
-	public var text(default, set) : String;
-
-	public function new(text, ?parent) {
-		super("label",parent);
-		tf = new h2d.Text(null, this);
-		this.text = text;
-	}
-
-	function get_text() {
-		return tf.text;
-	}
-
-	function set_text(t) {
-		needRebuild = true;
-		return text = t;
-	}
-
-	override function resize( ctx : Context ) {
-		if( ctx.measure ) {
-            tf.maxWidth = ctx.maxWidth;
-			tf.font = getFont();
-			tf.textColor = style.color;
-			tf.text = text;
-			tf.smooth = true;
-			contentWidth = tf.textWidth;
-			contentHeight = tf.textHeight;
-		}
-		super.resize(ctx);
-		if( !ctx.measure )
-			textAlign(tf);
-	}
-
-}

+ 0 - 295
h2d/comp/Parser.hx

@@ -1,295 +0,0 @@
-package h2d.comp;
-
-#if hscript
-private class CustomInterp extends hscript.Interp {
-	override function fcall(o:Dynamic, f:String, args:Array<Dynamic>):Dynamic {
-		if( Std.is(o, h2d.comp.JQuery) && Reflect.field(o,f) == null ) {
-			var rf = args.length == 0 ? "_get_" + f : "_set_" + f;
-			if( Reflect.field(o, rf) == null ) throw "JQuery don't have " + f + " implemented";
-			f = rf;
-		}
-		if( Reflect.field(o, f) == null )
-			throw o + " does not have method " + f;
-		return super.fcall(o, f, args);
-	}
-}
-#end
-
-class Parser {
-
-	var comps : Map < String, haxe.xml.Fast -> Component -> Component > ;
-	#if hscript
-	var interp : hscript.Interp;
-	#end
-	var root : Component;
-
-	public function new(?api:{}) {
-		comps = new Map();
-		#if hscript
-		interp = new CustomInterp();
-		interp.variables.set("$", function(rq) return new h2d.comp.JQuery(root, rq));
-		interp.variables.set("api", api);
-		if( api != null )
-			for( f in Reflect.fields(api) )
-				interp.variables.set(f, Reflect.field(api, f));
-		#end
-	}
-
-	public function build( x : haxe.xml.Fast, ?parent : Component ) {
-		var c : Component;
-		switch( x.name.toLowerCase() ) {
-		case "body":
-			c = new Box(Absolute, parent);
-		case "style":
-			parent.addCss(x.innerData);
-			return null;
-		case "script":
-			makeScript(null, x.innerData)();
-			return null;
-		case "div", "box":
-			c = new Box(parent);
-		case "button":
-			c = new Button(x.has.value ? x.att.value : "", parent);
-		case "slider":
-			c = new Slider(parent);
-		case "label", "span":
-			c = new Label(x.x.firstChild() == null ? "" : x.innerData, parent);
-		case "h1", "h2", "h3", "h4":
-			c = new Label(x.x.firstChild() == null ? "" : x.innerData, parent);
-			c.addClass(":" + x.name.toLowerCase());
-		case "checkbox":
-			c = new Checkbox(parent);
-		case "itemlist":
-			c = new ItemList(parent);
-		case "input":
-			c = new Input(parent);
-		case "color":
-			c = new Color(parent);
-		case "colorpicker":
-			c = new ColorPicker(parent);
-		case "gradienteditor":
-			c = new GradientEditor(parent);
-		case "select":
-			c = new Select(parent);
-		case "option":
-			if( parent == null || parent.name != "select" )
-				throw "<option/> needs 'select' parent";
-			var select = Std.instance(parent, Select);
-			var label = x.innerData;
-			var value = x.has.value ? x.att.value : null;
-			select.addOption(label, value);
-			if( x.has.selected && x.att.selected != "false" )
-				select.selectedIndex = select.getOptions().length - 1;
-			return null;
-		case "value":
-			c = new Value(parent);
-		case n:
-			var make = comps.get(n);
-			if( make != null )
-				c = make(x, parent);
-			else
-				throw "Unknown node " + n;
-		}
-		if( root == null ) root = c;
-		for( n in x.x.attributes() ) {
-			var v = x.x.get(n);
-			switch( n.toLowerCase() ) {
-			case "class":
-				for( cl in v.split(" ") ) {
-					var cl = StringTools.trim(cl);
-					if( cl.length > 0 ) c.addClass(cl);
-				}
-			case "id":
-				c.id = v;
-			case "value":
-				switch( c.name ) {
-				case "slider":
-					var c : Slider = cast c;
-					c.value = Std.parseFloat(v);
-				case "input":
-					var c : Input = cast c;
-					c.value = v;
-				case "color":
-					var c : Color = cast c;
-					c.value = Std.parseInt(v);
-				case "value":
-					var c : Value = cast c;
-					c.value = Std.parseFloat(v);
-				default:
-				}
-			case "onchange":
-				switch( c.name ) {
-				case "slider":
-					var c : Slider = cast c;
-					var s = makeScript(c,v);
-					c.onChange = function(_) s();
-				case "checkbox":
-					var c : Checkbox = cast c;
-					var s = makeScript(c,v);
-					c.onChange = function(_) s();
-				case "itemlist":
-					var c : ItemList = cast c;
-					var s = makeScript(c,v);
-					c.onChange = function(_) s();
-				case "input":
-					var c : Input = cast c;
-					var s = makeScript(c,v);
-					c.onChange = function(_) s();
-				case "color":
-					var c : Color = cast c;
-					var s = makeScript(c,v);
-					c.onChange = function(_) s();
-				case "select":
-					var c : Select = cast c;
-					var s = makeScript(c,v);
-					c.onChange = function(_) s();
-				case "value":
-					var c : Value = cast c;
-					var s = makeScript(c,v);
-					c.onChange = function(_) s();
-				default:
-				}
-			case "onblur":
-				switch( c.name ) {
-				case "input":
-					var c : Input = cast c;
-					c.onBlur = makeScript(c,v);
-				default:
-				}
-			case "onfocus":
-				switch( c.name ) {
-				case "input":
-					var c : Input = cast c;
-					c.onFocus = makeScript(c,v);
-				default:
-				}
-			case "style":
-				var s = new h2d.css.Style();
-				new h2d.css.Parser().parse(v, s);
-				c.setStyle(s);
-			case "selected":
-				switch( c.name ) {
-				case "itemlist":
-					var c : ItemList = cast c;
-					c.selected = Std.parseInt(v);
-				default:
-				}
-			case "checked":
-				switch( c.name ) {
-				case "checkbox":
-					var c : Checkbox = cast c;
-					c.checked = v != "false";
-				default:
-				}
-			case "x":
-				c.x = Std.parseFloat(v);
-			case "y":
-				c.y = Std.parseFloat(v);
-			case "min":
-				switch( c.name ) {
-				case "slider":
-					var c : Slider = cast c;
-					c.minValue = Std.parseFloat(v);
-				case "value":
-					var c : Value = cast c;
-					c.minValue = Std.parseFloat(v);
-				default:
-				}
-			case "max":
-				switch( c.name ) {
-				case "slider":
-					var c : Slider = cast c;
-					c.maxValue = Std.parseFloat(v);
-				case "value":
-					var c : Value = cast c;
-					c.maxValue = Std.parseFloat(v);
-				default:
-				}
-			case "increment":
-				switch( c.name ) {
-				case "value":
-					Std.instance(c, Value).increment = Std.parseFloat(v);
-				default:
-				}
-			case "onmouseover":
-				var int = Std.instance(c, Interactive);
-				if( int != null )
-					int.onMouseOver = makeScript(c, v);
-			case "onmouseout":
-				var int = Std.instance(c, Interactive);
-				if( int != null )
-					int.onMouseOut = makeScript(c, v);
-			case "onmousedown":
-				var int = Std.instance(c, Interactive);
-				if( int != null )
-					int.onMouseDown = makeScript(c, v);
-			case "onmouseup":
-				var int = Std.instance(c, Interactive);
-				if( int != null )
-					int.onMouseUp = makeScript(c, v);
-			case "onclick":
-				var int = Std.instance(c, Interactive);
-				if( int != null )
-					int.onClick = makeScript(c, v);
-			case "onrclick":
-				var int = Std.instance(c, Interactive);
-				if( int != null )
-					int.onRightClick = makeScript(c, v);
-			case "disabled":
-				if( v != "false" )
-					c.addClass(":disabled");
-			case n:
-				throw "Unknown attrib " + n;
-			}
-		}
-		for( e in x.elements )
-			build(e, c);
-		return c;
-	}
-
-	public function register(name, make) {
-		this.comps.set(name, make);
-	}
-
-	function makeScript( c : Component, script : String ) {
-		#if hscript
-		var p = new hscript.Parser();
-		p.identChars += "$";
-		var e = null;
-		try {
-			e = p.parseString(script);
-		} catch( e : hscript.Expr.Error ) {
-			throw "Invalid Script line " + p.line + " (" + e+ ")";
-		}
-		return function() {
-			interp.variables.set("this", c);
-			try interp.execute(e) catch( e : String ) throw "Error while running script " + script + " (" + e + ")" catch( e : hscript.Expr.Error ) throw "Error while running script " + script + " (" + e + ")" ;
-		};
-		#else
-		return function() throw "Please compile with -lib hscript to get script access";
-		#end
-	}
-
-	public static function fromHtml( html : String, ?api ) : Component {
-		function lookupBody(x:Xml) {
-			if( x.nodeType == Xml.Element && x.nodeName.toLowerCase() == "body" )
-				return x;
-			if( x.nodeType == Xml.PCData )
-				return null;
-			for( e in x ) {
-				var v = lookupBody(e);
-				if( v != null ) return v;
-			}
-			return null;
-		}
-		var x = Xml.parse(html);
-		var body = lookupBody(x);
-		if( body == null ) {
-			body = Xml.createElement("body");
-			for( e in Lambda.array(x) )
-				body.addChild(e);
-		}
-		return new Parser(api).build(new haxe.xml.Fast(body),null);
-	}
-
-}

+ 0 - 144
h2d/comp/Select.hx

@@ -1,144 +0,0 @@
-package h2d.comp;
-
-class Select extends Interactive {
-
-	var tf : h2d.Text;
-	var options : Array<{ label : String, value : Null<String> }>;
-	var list : ItemList;
-	public var value(default, null) : String;
-	public var selectedIndex(default,set) : Int;
-
-	public function new(?parent) {
-		super("select", parent);
-		tf = new h2d.Text(null, this);
-		options = [];
-		selectedIndex = 0;
-	}
-
-	override function onClick() {
-		popup();
-	}
-
-	public function getOptions() {
-		return options.copy();
-	}
-
-	public function popup() {
-		if( list != null || options.length == 0 )
-			return;
-		var p : Component = this;
-		while( p.parentComponent != null )
-			p = p.parentComponent;
-		list = new ItemList();
-		list.onItemOver = function(i) onItemOver(i < 0 ? null : options[i].value);
-		p.addChild(list);
-		list.addClass("popup");
-		list.evalStyle();
-		for( o in options )
-			new Label(o.label, list);
-		updateListPos();
-		list.selected = this.selectedIndex;
-		list.onChange = function(i) {
-			this.selectedIndex = i;
-			needRebuild = true;
-			close();
-			this.onChange(value);
-		};
-		var scene = getScene();
-		scene.startDrag(function(e) {
-			if( e.kind == ERelease ) {
-				scene.stopDrag();
-				close();
-			}
-		},close);
-	}
-
-	public function close() {
-		list.remove();
-		list = null;
-		getScene().stopDrag();
-	}
-
-	public dynamic function onChange( value : String ) {
-	}
-
-	function set_selectedIndex(i) {
-		var o = options[i];
-		value = o == null ? "" : (o.value == null ? o.label : o.value);
-		if( i != selectedIndex ) needRebuild = true;
-		return selectedIndex = i;
-	}
-
-	public function setValue(v) {
-		var k = -1;
-		for( i in 0...options.length )
-			if( options[i].value == v ) {
-				k = i;
-				break;
-			}
-		if( k < 0 ) {
-			for( i in 0...options.length )
-				if( options[i].label == v ) {
-					k = i;
-					break;
-				}
-		}
-		selectedIndex = k;
-		return value;
-	}
-
-
-	function updateListPos() {
-		var scene = getScene();
-		var s = new h2d.css.Style();
-		var pos = localToGlobal();
-		s.offsetX = pos.x - extLeft();
-		s.offsetY = pos.y - extTop();
-		s.width = contentWidth + style.paddingLeft + style.paddingRight - (list.style.paddingLeft + list.style.paddingRight);
-		var yMargin = (list.style.paddingBottom + list.style.paddingTop) * 0.5;
-		var xMargin = (list.style.paddingLeft + list.style.paddingRight) * 0.5;
-		var maxY = (scene != null ? scene.height : h3d.Engine.getCurrent().height) - (list.height + yMargin);
-		var maxX = (scene != null ? scene.width : h3d.Engine.getCurrent().width) - (list.width + xMargin);
-		if( s.offsetX > maxX )
-			s.offsetX = maxX;
-		if( s.offsetX < xMargin )
-			s.offsetX = xMargin;
-		if( s.offsetY > maxY )
-			s.offsetY = maxY;
-		if( s.offsetY < yMargin )
-			s.offsetY = yMargin;
-		if( list.customStyle == null || s.offsetX != list.customStyle.offsetX || s.offsetY != list.customStyle.offsetY || s.width != list.customStyle.width )
-			list.setStyle(s);
-	}
-
-	public function clear() {
-		options = [];
-		needRebuild = true;
-		selectedIndex = 0;
-	}
-
-	public function addOption(label, ?value) {
-		options.push( { label : label, value : value } );
-		needRebuild = true;
-		if( selectedIndex == options.length - 1 )
-			selectedIndex = selectedIndex; // update value
-	}
-
-	public dynamic function onItemOver( value : String ) {
-	}
-
-	override function resize( ctx : Context ) {
-		if( ctx.measure ) {
-			tf.font = getFont();
-			tf.textColor = style.color;
-			tf.text = options[selectedIndex] == null ? "" : options[selectedIndex].label;
-			tf.smooth = true;
-			contentWidth = tf.textWidth;
-			contentHeight = tf.textHeight;
-		}
-		super.resize(ctx);
-		if( !ctx.measure && list != null )
-			updateListPos();
-	}
-
-}

+ 0 - 77
h2d/comp/Slider.hx

@@ -1,77 +0,0 @@
-package h2d.comp;
-
-class Slider extends Component {
-
-	var cursor : Button;
-	var input : h2d.Interactive;
-	public var minValue : Float = 0.;
-	public var maxValue : Float = 1.;
-	public var value(default, set) : Float;
-
-	@:access(h2d.comp.Button)
-	public function new(?parent) {
-		super("slider", parent);
-		cursor = new Button("", this);
-		cursor.input.cancelEvents = true;
-		cursor.onMouseDown = function() {
-
-		};
-		input = new h2d.Interactive(0, 0, this);
-		input.onPush = function(e) {
-			gotoValue(pixelToVal(e));
-			input.startDrag(function(e) {
-				if( e.kind == EMove )
-					gotoValue(pixelToVal(e));
-			});
-		};
-		input.onRelease = function(_) {
-			input.stopDrag();
-		}
-		value = 0.;
-	}
-
-	function pixelToVal( e : hxd.Event ) {
-		return (Std.int(e.relX - (style.borderSize + cursor.width * 0.5) ) / (input.width - (style.borderSize * 2 + cursor.width))) * (maxValue - minValue) + minValue;
-	}
-
-	function gotoValue( v : Float ) {
-		if( v < minValue ) v = minValue;
-		if( v > maxValue ) v = maxValue;
-		if( v == value )
-			return;
-		var dv = Math.abs(value - v);
-		if( style.maxIncrement != null && dv > style.maxIncrement ) {
-			if( v > value )
-				value += style.maxIncrement;
-			else
-				value -= style.maxIncrement;
-		} else if( style.increment != null )
-			value = Math.round(v / style.increment) * style.increment;
-		else
-			value = v;
-		onChange(value);
-	}
-
-	function set_value(v:Float) {
-		if( v < minValue ) v = minValue;
-		if( v > maxValue ) v = maxValue;
-		value = v;
-		needRebuild = true;
-		return v;
-	}
-
-	override function resize( ctx : Context ) {
-		super.resize(ctx);
-		if( !ctx.measure ) {
-			input.width = width - (style.marginLeft + style.marginRight) + cursor.width;
-			input.height = cursor.height - (cursor.style.marginTop + cursor.style.marginBottom);
-			input.x = cursor.style.marginLeft - style.borderSize - cursor.width * 0.5;
-			input.y = cursor.style.marginTop;
-			cursor.style.offsetX = contentWidth * (value - minValue) / (maxValue - minValue) - cursor.width * 0.5;
-		}
-	}
-
-	public dynamic function onChange( value : Float ) {
-	}
-
-}

+ 0 - 73
h2d/comp/Value.hx

@@ -1,73 +0,0 @@
-package h2d.comp;
-
-class Value extends Interactive {
-
-	var text : Input;
-	public var minValue : Float = -1e10;
-	public var maxValue : Float = 1e10;
-	public var value(default, set) : Float;
-	public var increment : Float;
-
-	public function new(?parent) {
-		super("value", parent);
-		text = new Input(this);
-		text.input.cursor = Move;
-		text.onChange = function(v) {
-			var v = Std.parseFloat(v);
-			if( !Math.isNaN(v) ) {
-				var old = text;
-				text = null;
-				value = v;
-				text = old;
-				onChange(value);
-			}
-		};
-		text.input.onPush = function(e1) {
-			text.active = true;
-			if( text.hasClass(":focus") )
-				return;
-			var startVal = value;
-			var startX = e1.relX;
-			text.input.startDrag(function(e) {
-				if( e.kind == ERelease )
-					text.input.stopDrag();
-				else {
-					var dx = Math.round(e.relX - startX);
-					var v = startVal + dx * increment;
-					if( v < minValue ) v = minValue;
-					if( v > maxValue ) v = maxValue;
-					value = v;
-					onChange(value);
-				}
-			});
-		};
-		text.onFocus = function() {
-			text.input.stopDrag();
-			text.input.cursor = TextInput;
-		};
-		text.onBlur = function() {
-			value = value;
-			text.input.cursor = Move;
-		};
-		value = 0;
-		increment = 0.1;
-	}
-
-	function set_value(v:Float) {
-		if( text != null ) text.value = ""+hxd.Math.fmt(v);
-		return value = v;
-	}
-
-	override function resize( ctx : Context ) {
-		if( ctx.measure ) {
-			text.resize(ctx);
-			contentWidth = text.width;
-			contentHeight = text.height;
-		}
-		super.resize(ctx);
-	}
-
-	public dynamic function onChange( value : Float ) {
-	}
-
-}

+ 0 - 45
h2d/css/Defs.hx

@@ -1,45 +0,0 @@
-package h2d.css;
-
-enum Unit {
-	Pix( v : Float );
-	Percent( v : Float );
-	EM( v : Float );
-}
-
-enum FillStyle {
-	Transparent;
-	Color( c : Int );
-	Gradient( a : Int, b : Int, c : Int, d : Int );
-}
-
-enum Layout {
-	Horizontal;
-	Vertical;
-	Absolute;
-	Dock;
-	Inline;
-}
-
-enum DockStyle {
-	Top;
-	Left;
-	Right;
-	Bottom;
-	Full;
-}
-
-enum TextAlign {
-	Left;
-	Right;
-	Center;
-}
-
-class CssClass {
-	public var parent : Null<CssClass>;
-	public var node : Null<String>;
-	public var className : Null<String>;
-	public var pseudoClass : Null<String>;
-	public var id : Null<String>;
-	public function new() {
-	}
-}

+ 0 - 105
h2d/css/Engine.hx

@@ -1,105 +0,0 @@
-package h2d.css;
-import h2d.css.Defs;
-
-class Rule {
-	public var id : Int;
-	public var c : CssClass;
-	public var priority : Int;
-	public var s : Style;
-	public function new() {
-	}
-}
-
-@:access(h2d.comp.Component)
-class Engine {
-
-	var rules : Array<Rule>;
-
-	public function new() {
-		rules = [];
-	}
-
-	public function applyClasses( c : h2d.comp.Component ) {
-		var s = new Style();
-		c.style = s;
-		var rules = [];
-		for( r in this.rules ) {
-			if( !ruleMatch(r.c, c) )
-				continue;
-			rules.push(r);
-		}
-		rules.sort(sortByPriority);
-		for( r in rules )
-			s.apply(r.s);
-		if( c.customStyle != null )
-			s.apply(c.customStyle);
-	}
-
-	function sortByPriority(r1:Rule, r2:Rule) {
-		var dp = r1.priority - r2.priority;
-		return dp == 0 ? r1.id - r2.id : dp;
-	}
-
-	public static function ruleMatch( c : CssClass, d : h2d.comp.Component ) {
-		if( c.pseudoClass != null ) {
-			var pc = ":" + c.pseudoClass;
-			var found = false;
-			for( cc in d.classes )
-				if( cc == pc ) {
-					found = true;
-					break;
-				}
-			if( !found )
-				return false;
-		}
-		if( c.className != null ) {
-			if( d.classes == null )
-				return false;
-			var found = false;
-			for( cc in d.classes )
-				if( cc == c.className ) {
-					found = true;
-					break;
-				}
-			if( !found )
-				return false;
-		}
-		if( c.node != null && c.node != d.name )
-			return false;
-		if( c.id != null && c.id != d.id )
-			return false;
-		if( c.parent != null ) {
-			var p = d.parentComponent;
-			while( p != null ) {
-				if( ruleMatch(c.parent, p) )
-					break;
-				p = p.parentComponent;
-			}
-			if( p == null )
-				return false;
-		}
-		return true;
-	}
-
-	public function addRules( text : String ) {
-		for( r in new Parser().parseRules(text) ) {
-			var c = r.c;
-			var imp = r.imp ? 1 : 0;
-			var nids = 0, nothers = 0, nnodes = 0;
-			while( c != null ) {
-				if( c.id != null ) nids++;
-				if( c.node != null ) nnodes++;
-				if( c.pseudoClass != null ) nothers++;
-				if( c.className != null ) nothers++;
-				c = c.parent;
-			}
-			var rule = new Rule();
-			rule.id = rules.length;
-			rule.c = r.c;
-			rule.s = r.s;
-			rule.priority = (imp << 24) | (nids << 16) | (nothers << 8) | nnodes;
-			rules.push(rule);
-		}
-	}
-
-}

+ 0 - 113
h2d/css/Fill.hx

@@ -1,113 +0,0 @@
-package h2d.css;
-import h2d.css.Defs;
-
-class Fill extends h2d.TileGroup {
-
-	public function new(?parent) {
-		super(h2d.Tile.fromColor(0xFFFFFF), parent);
-	}
-
-	public inline function fillRectColor(x, y, w, h, c) {
-		content.rectColor(x, y, w, h, c);
-	}
-
-	public inline function fillRectGradient(x, y, w, h, ctl, ctr, cbl, cbr) {
-		content.rectGradient(x, y, w, h, ctl, ctr, cbl, cbr);
-	}
-
-	public inline function addPoint(x, y, color) {
-		content.addPoint(x, y, color);
-	}
-
-	public inline function fillCircle( fill:FillStyle, x : Float, y : Float, radius : Float) {
-		switch( fill ) {
-		case Transparent:
-		case Color(c):
-		content.fillCircle(x, y, radius, c);
-		case Gradient(a,b,c,d):
-		}
-	}
-
-	public inline function fillArc( fill:FillStyle, x : Float, y : Float, ray : Float, start: Float, end: Float) {
-		switch( fill ) {
-		case Transparent:
-		case Color(c):
-			content.fillArc(x, y, ray, c, start, end);
-		case Gradient(a,b,c,d):
-		}
-	}
-
-	public function fillRect(fill:FillStyle,x,y,w,h) {
-		switch( fill ) {
-		case Transparent:
-		case Color(c):
-			fillRectColor(x,y,w,h,c);
-		case Gradient(a,b,c,d):
-			fillRectGradient(x,y,w,h,a,b,c,d);
-		}
-	}
-
-	inline function clerp(c1:Int,c2:Int,v:Float) {
-		var a = Std.int( (c1>>>24) * (1-v) + (c2>>>24) * v );
-		var r = Std.int( ((c1>>16)&0xFF) * (1-v) + ((c2>>16)&0xFF) * v );
-		var g = Std.int( ((c1>>8)&0xFF) * (1-v) + ((c2>>8)&0xFF) * v );
-		var b = Std.int( (c1&0xFF) * (1-v) + (c2&0xFF) * v );
-		return (a << 24) | (r << 16) | (g << 8) | b;
-	}
-
-	public inline function circle( fill:FillStyle, x : Float, y : Float, ray : Float, size: Float) {
-		switch( fill ) {
-		case Transparent:
-		case Color(c):
-			content.circle(x, y, ray, size, c);
-		case Gradient(a,b,c,d):
-		}
-	}
-
-	public inline function arc( fill:FillStyle, x : Float, y : Float, ray : Float, size: Float, start: Float, end: Float) {
-		switch( fill ) {
-		case Transparent:
-		case Color(c):
-			content.arc(x, y, ray, size, start, end, c);
-		case Gradient(a,b,c,d):
-		}
-	}
-
-	public function lineRoundRect(fill:FillStyle, x:Float, y:Float, w:Float, h:Float, size:Float, ellipse:Float) {
-		if( size <= 0 ) return;
-		switch( fill ) {
-		case Transparent:
-		case Color(c):
-			fillRectColor(x + ellipse, y, w - ellipse * 2, size, c);
-			fillRectColor(x + ellipse, y + h - size, w - ellipse * 2, size, c);
-			fillRectColor(x,y+size + ellipse,size,h-size*2 - ellipse * 2,c);
-			fillRectColor(x + w - size, y + size + ellipse, size, h - size * 2 - ellipse * 2, c);
-
-		case Gradient(a,b,c,d):
-		}
-	}
-
-	public function lineRect(fill:FillStyle, x:Float, y:Float, w:Float, h:Float, size:Float) {
-		if( size <= 0 ) return;
-		switch( fill ) {
-		case Transparent:
-		case Color(c):
-			fillRectColor(x,y,w,size,c);
-			fillRectColor(x,y+h-size,w,size,c);
-			fillRectColor(x,y+size,size,h-size*2,c);
-			fillRectColor(x+w-size,y+size,size,h-size*2,c);
-		case Gradient(a,b,c,d):
-			var px = size / w;
-			var py = size / h;
-			var a2 = clerp(a,c,py);
-			var b2 = clerp(b,d,py);
-			var c2 = clerp(a,c,1-py);
-			var d2 = clerp(b,d,1-py);
-			fillRectGradient(x,y,w,size,a,b,a2,b2);
-			fillRectGradient(x,y+h-size,w,size,c2,d2,c,d);
-			fillRectGradient(x,y+size,size,h-size*2,a2,clerp(a2,b2,px),c2,clerp(c2,d2,px));
-			fillRectGradient(x+w-size,y+size,size,h-size*2,clerp(a2,b2,1-px),b2,clerp(c2,d2,1-px),d2);
-		}
-	}
-
-}

+ 0 - 1030
h2d/css/Parser.hx

@@ -1,1030 +0,0 @@
-package h2d.css;
-import h2d.css.Defs;
-
-enum Token {
-	TIdent( i : String );
-	TString( s : String );
-	TInt( i : Int );
-	TFloat( f : Float );
-	TDblDot;
-	TSharp;
-	TPOpen;
-	TPClose;
-	TExclam;
-	TComma;
-	TEof;
-	TPercent;
-	TSemicolon;
-	TBrOpen;
-	TBrClose;
-	TDot;
-	TSpaces;
-	TSlash;
-	TStar;
-}
-
-enum Value {
-	VIdent( i : String );
-	VString( s : String );
-	VUnit( v : Float, unit : String );
-	VFloat( v : Float );
-	VInt( v : Int );
-	VHex( v : String );
-	VList( l : Array<Value> );
-	VGroup( l : Array<Value> );
-	VCall( f : String, vl : Array<Value> );
-	VLabel( v : String, val : Value );
-	VSlash;
-}
-
-class Parser {
-
-	var css : String;
-	var s : Style;
-	var simp : Style;
-	var pos : Int;
-
-	var spacesTokens : Bool;
-	var tokens : Array<Token>;
-
-	public function new() {
-	}
-
-
-	// ----------------- style apply ---------------------------
-
-	#if debug
-	function notImplemented( ?pos : haxe.PosInfos ) {
-		haxe.Log.trace("Not implemented", pos);
-	}
-	#else
-	inline function notImplemented() {
-	}
-	#end
-
-	function applyStyle( r : String, v : Value, s : Style ) : Bool {
-		switch( r ) {
-		case "padding":
-			switch( v ) {
-			case VGroup([a, b]):
-				var a = getVal(a), b = getVal(b);
-				if( a != null && b != null ) {
-					s.paddingTop = s.paddingBottom = a;
-					s.paddingLeft = s.paddingRight = b;
-					return true;
-				}
-			default:
-				var i = getVal(v);
-				if( i != null ) { s.padding(i); return true; }
-			}
-		case "padding-top":
-			var i = getVal(v);
-			if( i != null ) { s.paddingTop = i; return true; }
-		case "padding-left":
-			var i = getVal(v);
-			if( i != null ) { s.paddingLeft = i; return true; }
-		case "padding-right":
-			var i = getVal(v);
-			if( i != null ) { s.paddingRight = i; return true; }
-		case "padding-bottom":
-			var i = getVal(v);
-			if( i != null ) { s.paddingBottom = i; return true; }
-		case "margin":
-			switch( v ) {
-			case VGroup([a, b]):
-				var a = getVal(a), b = getVal(b);
-				if( a != null && b != null ) {
-					s.marginTop = s.marginBottom = a;
-					s.marginLeft = s.marginRight = b;
-					return true;
-				}
-			default:
-				var i = getVal(v);
-				if( i != null ) { s.margin(i); return true; }
-			}
-		case "margin-top":
-			var i = getVal(v);
-			if( i != null ) { s.marginTop = i; return true; }
-		case "margin-left":
-			var i = getVal(v);
-			if( i != null ) { s.marginLeft = i; return true; }
-		case "margin-right":
-			var i = getVal(v);
-			if( i != null ) { s.marginRight = i; return true; }
-		case "margin-bottom":
-			var i = getVal(v);
-			if( i != null ) { s.marginBottom = i; return true; }
-		case "width":
-			var i = getVal(v);
-			if( i != null ) {
-				s.width = i;
-				return true;
-			}
-			if( getIdent(v) == "auto" ) {
-				s.width = null;
-				s.autoWidth = true;
-				return true;
-			}
-		case "height":
-			var i = getVal(v);
-			if( i != null ) {
-				s.height = i;
-				return true;
-			}
-			if( getIdent(v) == "auto" ) {
-				s.height = null;
-				s.autoHeight = true;
-				return true;
-			}
-		case "background-color":
-			var f = getFill(v);
-			if( f != null ) {
-				s.backgroundColor = f;
-				return true;
-			}
-		case "background":
-			return applyComposite(["background-color"], v, s);
-		case "font-family":
-			var l = getFontName(v);
-			if( l != null ) {
-				s.fontName = l;
-				return true;
-			}
-		case "font-size":
-			var i = getUnit(v);
-			if( i != null ) {
-				switch( i ) {
-				case Pix(v):
-					s.fontSize = v;
-				default:
-					notImplemented();
-				}
-				return true;
-			}
-		case "color":
-			var c = getCol(v);
-			if( c != null ) {
-				s.color = c;
-				return true;
-			}
-		case "border-radius":
-			var i = getVal(v);
-			if( i != null ) {
-				s.borderRadius = i;
-				return true;
-			}
-		case "border":
-			if( applyComposite(["border-width", "border-style", "border-color"], v, s) )
-				return true;
-			if( getIdent(v) == "none" ) {
-				s.borderSize = 0;
-				s.borderColor = Transparent;
-				return true;
-			}
-		case "border-width":
-			var i = getVal(v);
-			if( i != null ) {
-				s.borderSize = i;
-				return true;
-			}
-		case "border-style":
-			if( getIdent(v) == "solid" )
-				return true;
-		case "border-color":
-			var c = getFill(v);
-			if( c != null ) {
-				s.borderColor = c;
-				return true;
-			}
-		case "offset":
-			return applyComposite(["offset-x", "offset-y"], v, s);
-		case "offset-x":
-			var i = getVal(v);
-			if( i != null ) {
-				s.offsetX = i;
-				return true;
-			}
-		case "offset-y":
-			var i = getVal(v);
-			if( i != null ) {
-				s.offsetY = i;
-				return true;
-			}
-		case "layout":
-			var i = mapIdent(v, [Horizontal, Vertical, Absolute, Dock, Inline]);
-			if( i != null ) {
-				s.layout = i;
-				return true;
-			}
-		case "spacing":
-			return applyComposite(["vertical-spacing", "horizontal-spacing"], v, s);
-		case "horizontal-spacing":
-			var i = getVal(v);
-			if( i != null ) {
-				s.horizontalSpacing = i;
-				return true;
-			}
-		case "vertical-spacing":
-			var i = getVal(v);
-			if( i != null ) {
-				s.verticalSpacing = i;
-				return true;
-			}
-		case "increment":
-			var i = getVal(v);
-			if( i != null ) {
-				s.increment = i;
-				return true;
-			}
-		case "max-increment":
-			var i = getVal(v);
-			if( i != null ) {
-				s.maxIncrement = i;
-				return true;
-			}
-		case "tick-color":
-			var i = getFill(v);
-			if( i != null ) {
-				s.tickColor = i;
-				return true;
-			}
-		case "tick-spacing":
-			var i = getVal(v);
-			if( i != null ) {
-				s.tickSpacing = i;
-				return true;
-			}
-		case "dock":
-			var i = mapIdent(v, [Top, Bottom, Left, Right, Full]);
-			if( i != null ) {
-				s.dock = i;
-				return true;
-			}
-		case "cursor-color":
-			var i = getColAlpha(v);
-			if( i != null ) {
-				s.cursorColor = i;
-				return true;
-			}
-		case "selection-color":
-			var i = getColAlpha(v);
-			if( i != null ) {
-				s.selectionColor = i;
-				return true;
-			}
-		case "overflow":
-			switch( getIdent(v) ) {
-			case "hidden":
-				s.overflowHidden = true;
-				return true;
-			case "visible":
-				s.overflowHidden = false;
-				return true;
-			}
-		case "icon":
-			var i = getImage(v);
-			if( i != null ) {
-				s.icon = i;
-				return true;
-			}
-		case "icon-color":
-			var c = getColAlpha(v);
-			if( c != null ) {
-				s.iconColor = c;
-				return true;
-			}
-		case "icon-left":
-			var i = getVal(v);
-			if( i != null ) {
-				s.iconLeft = i;
-				return true;
-			}
-		case "icon-top":
-			var i = getVal(v);
-			if( i != null ) {
-				s.iconTop = i;
-				return true;
-			}
-		case "position":
-			switch( getIdent(v) ) {
-			case "absolute":
-				s.positionAbsolute = true;
-				return true;
-			case "relative":
-				s.positionAbsolute = false;
-				return true;
-			default:
-			}
-		case "text-align":
-			switch( getIdent(v) ) {
-			case "left":
-				s.textAlign = Left;
-				return true;
-			case "right":
-				s.textAlign = Right;
-				return true;
-			case "center":
-				s.textAlign = Center;
-				return true;
-			default:
-			}
-		case "display":
-			switch( getIdent(v) ) {
-			case "none":
-				s.display = false;
-				return true;
-			case "block", "inline-block":
-				s.display = true;
-				return true;
-			default:
-			}
-		default:
-			throw "Not implemented '"+r+"' = "+valueStr(v);
-		}
-		return false;
-	}
-
-	function applyComposite( names : Array<String>, v : Value, s : Style ) {
-		var vl = switch( v ) {
-		case VGroup(l): l;
-		default: [v];
-		};
-		while( vl.length > 0 ) {
-			var found = false;
-			for( n in names ) {
-				var count = 1;
-				if( count > vl.length ) count = vl.length;
-				while( count > 0 ) {
-					var v = (count == 1) ? vl[0] : VGroup(vl.slice(0, count));
-					if( applyStyle(n, v, s) ) {
-						found = true;
-						names.remove(n);
-						for( i in 0...count )
-							vl.shift();
-						break;
-					}
-					count--;
-				}
-				if( found ) break;
-			}
-			if( !found )
-				return false;
-		}
-		return true;
-	}
-
-	function getGroup<T>( v : Value, f : Value -> Null<T> ) : Null<Array<T>> {
-		switch(v) {
-		case VGroup(l):
-			var a = [];
-			for( v in l ) {
-				var v = f(v);
-				if( v == null ) return null;
-				a.push(v);
-			}
-			return a;
-		default:
-			var v = f(v);
-			return (v == null) ? null : [v];
-		}
-	}
-
-	function getList<T>( v : Value, f : Value -> Null<T> ) : Null<Array<T>> {
-		switch(v) {
-		case VList(l):
-			var a = [];
-			for( v in l ) {
-				var v = f(v);
-				if( v == null ) return null;
-				a.push(v);
-			}
-			return a;
-		default:
-			var v = f(v);
-			return (v == null) ? null : [v];
-		}
-	}
-
-	function getInt( v : Value ) : Null<Int> {
-		return switch( v ) {
-		case VUnit(f, u):
-			switch( u ) {
-			case "px": Std.int(f);
-			case "pt": Std.int(f * 4 / 3);
-			default: null;
-			}
-		case VInt(v):
-			Std.int(v);
-		default:
-			null;
-		};
-	}
-
-	function getVal( v : Value ) : Null<Float> {
-		return switch( v ) {
-		case VUnit(f, u):
-			switch( u ) {
-			case "px": f;
-			case "pt": f * 4 / 3;
-			default: null;
-			}
-		case VInt(v):
-			v;
-		case VFloat(v):
-			v;
-		default:
-			null;
-		};
-	}
-
-	function getUnit( v : Value ) : Null<Unit> {
-		return switch( v ) {
-		case VUnit(f, u):
-			switch( u ) {
-			case "px": Pix(f);
-			case "pt": Pix(f * 4 / 3);
-			case "%": Percent(f / 100);
-			default: null;
-			}
-		case VInt(v):
-			Pix(v);
-		case VFloat(v):
-			Pix(v);
-		default:
-			null;
-		};
-	}
-
-	function mapIdent<T:EnumValue>( v : Value, vals : Array<T> ) : T {
-		var i = getIdent(v);
-		if( i == null ) return null;
-		for( v in vals )
-			if( v.getName().toLowerCase() == i )
-				return v;
-		return null;
-	}
-
-	function getIdent( v : Value ) : Null<String> {
-		return switch( v ) {
-		case VIdent(v): v;
-		default: null;
-		};
-	}
-
-	function getColAlpha( v : Value ) {
-		var c = getCol(v);
-		if( c != null && c >>> 24 == 0 )
-			c |= 0xFF000000;
-		return c;
-	}
-
-	function getFill( v : Value ) {
-		var c = getColAlpha(v);
-		if( c != null )
-			return Color(c);
-		switch( v ) {
-		case VCall("gradient", [a, b, c, d]):
-			var ca = getColAlpha(a);
-			var cb = getColAlpha(b);
-			var cc = getColAlpha(c);
-			var cd = getColAlpha(d);
-			if( ca != null && cb != null && cc != null && cd != null )
-				return Gradient(ca, cb, cc, cd);
-		case VIdent("transparent"):
-			return Transparent;
-		default:
-		}
-		return null;
-	}
-
-	function getCol( v : Value ) : Null<Int> {
-		return switch( v ) {
-		case VHex(v):
-			(v.length == 6) ? Std.parseInt("0x" + v) : ((v.length == 3) ? Std.parseInt("0x"+v.charAt(0)+v.charAt(0)+v.charAt(1)+v.charAt(1)+v.charAt(2)+v.charAt(2)) : null);
-		case VIdent(i):
-			switch( i ) {
-			case "black":	0x000000;
-			case "red": 	0xFF0000;
-			case "lime":	0x00FF00;
-			case "blue":	0x0000FF;
-			case "white":	0xFFFFFF;
-			case "aqua":	0x00FFFF;
-			case "fuchsia":	0xFF00FF;
-			case "yellow":	0xFFFF00;
-			case "maroon":	0x800000;
-			case "green":	0x008000;
-			case "navy":	0x000080;
-			case "olive":	0x808000;
-			case "purple": 	0x800080;
-			case "teal":	0x008080;
-			case "silver":	0xC0C0C0;
-			case "gray", "grey": 0x808080;
-			default: null;
-			}
-		case VCall("rgba", [r, g, b, a]):
-			var r = getVal(r), g = getVal(g), b = getVal(b), a = getVal(a);
-			inline function conv(k:Float) {
-				var v = Std.int(k * 255);
-				if( v < 0 ) v = 0;
-				if( v > 255 ) v = 255;
-				return v;
-			}
-			inline function check(k:Float) {
-				var v = Std.int(k);
-				if( v < 0 ) v = 0;
-				if( v > 255 ) v = 255;
-				return v;
-			}
-			if( r != null && g != null && b != null && a != null ) {
-				var a = conv(a); if( a == 0 ) a = 1; // prevent setting alpha to FF afterwards
-				(a << 24) | (check(r) << 16) | (check(g) << 8) | check(b);
-			}
-			else
-				null;
-		default:
-			null;
-		};
-	}
-
-	function getFontName( v : Value ) {
-		return switch( v ) {
-		case VString(s): s;
-		case VGroup(_):
-			var g = getGroup(v, getIdent);
-			if( g == null ) null else g.join(" ");
-		case VIdent(i): i;
-		default: null;
-		};
-	}
-
-	function getImage( v : Value ) {
-		switch( v ) {
-		case VCall("url", [VString(url)]):
-			if( StringTools.startsWith(url, "res://") )
-				return hxd.res.Loader.currentInstance.load(url.substr(6)).toImage().getPixels();
-			if( !StringTools.startsWith(url, "data:image/png;base64,") )
-				return null;
-			url = url.substr(22);
-			if( StringTools.endsWith(url, "=") ) url = url.substr(0, -1);
-			var bytes = haxe.crypto.Base64.decode(url);
-			return hxd.res.Any.fromBytes("icon",bytes).toImage().getPixels();
-		default:
-			return null;
-		}
-	}
-
-	// ---------------------- generic parsing --------------------
-
-	function unexpected( t : Token ) : Dynamic {
-		throw "Unexpected " + Std.string(t);
-		return null;
-	}
-
-	function expect( t : Token ) {
-		var tk = readToken();
-		if( tk != t ) unexpected(tk);
-	}
-
-	inline function push( t : Token ) {
-		tokens.push(t);
-	}
-
-	function isToken(t) {
-		var tk = readToken();
-		if( tk == t ) return true;
-		push(tk);
-		return false;
-	}
-
-	public function parse( css : String, s : Style ) {
-		this.css = css;
-		this.s = s;
-		pos = 0;
-		tokens = [];
-		parseStyle(TEof);
-	}
-
-	function valueStr(v) {
-		return switch( v ) {
-		case VIdent(i): i;
-		case VString(s): '"' + s + '"';
-		case VUnit(f, unit): f + unit;
-		case VFloat(f): Std.string(f);
-		case VInt(v): Std.string(v);
-		case VHex(v): "#" + v;
-		case VList(l):
-			[for( v in l ) valueStr(v)].join(", ");
-		case VGroup(l):
-			[for( v in l ) valueStr(v)].join(" ");
-		case VCall(f,args): f+"(" + [for( v in args ) valueStr(v)].join(", ") + ")";
-		case VLabel(label, v): valueStr(v) + " !" + label;
-		case VSlash: "/";
-		}
-	}
-
-	function parseStyle( eof ) {
-		while( true ) {
-			if( isToken(eof) )
-				break;
-			var r = readIdent();
-			expect(TDblDot);
-			var v = readValue();
-			var s = this.s;
-			switch( v ) {
-			case VLabel(label, val):
-				if( label == "important" ) {
-					v = val;
-					if( simp == null ) simp = new Style();
-					s = simp;
-				}
-			default:
-			}
-			if( !applyStyle(r, v, s) )
-				throw "Invalid value " + valueStr(v) + " for css " + r;
-			if( isToken(eof) )
-				break;
-			expect(TSemicolon);
-		}
-	}
-
-	public function parseRules( css : String ) {
-		this.css = css;
-		pos = 0;
-		tokens = [];
-		var rules = [];
-		while( true ) {
-			if( isToken(TEof) )
-				break;
-			var classes = readClasses();
-			expect(TBrOpen);
-			this.s = new Style();
-			this.simp = null;
-			parseStyle(TBrClose);
-			for( c in classes )
-				rules.push( { c : c, s : s, imp : false } );
-			if( this.simp != null )
-				for( c in classes )
-					rules.push( { c : c, s : simp, imp : true } );
-		}
-		return rules;
-	}
-
-	public function parseClasses( css : String ) {
-		this.css = css;
-		pos = 0;
-		tokens = [];
-		var c = readClasses();
-		expect(TEof);
-		return c;
-	}
-
-	// ----------------- class parser ---------------------------
-
-	function readClasses() {
-		var classes = [];
-		while( true ) {
-			spacesTokens = true;
-			isToken(TSpaces); // skip
-			var c = readClass(null);
-			spacesTokens = false;
-			if( c == null ) break;
-			updateClass(c);
-			classes.push(c);
-			if( !isToken(TComma) )
-				break;
-		}
-		if( classes.length == 0 )
-			unexpected(readToken());
-		return classes;
-	}
-
-	function updateClass( c : CssClass ) {
-		// map html types to comp ones
-		switch( c.node ) {
-		case "div": c.node = "box";
-		case "span": c.node = "label";
-		case "h1", "h2", "h3", "h4":
-			c.pseudoClass = c.node;
-			c.node = "label";
-		}
-		if( c.parent != null ) updateClass(c.parent);
-	}
-
-	function readClass( parent ) : CssClass {
-		var c = new CssClass();
-		c.parent = parent;
-		var def = false;
-		var last = null;
-		while( true ) {
-			var t = readToken();
-			if( last == null )
-				switch( t ) {
-				case TStar: def = true;
-				case TDot, TSharp, TDblDot: last = t;
-				case TIdent(i): c.node = i; def = true;
-				case TSpaces:
-					return def ? readClass(c) : null;
-				case TBrOpen, TComma, TEof:
-					push(t);
-					break;
-				default:
-					unexpected(t);
-				}
-			else
-				switch( t ) {
-				case TIdent(i):
-					switch( last ) {
-					case TDot: c.className = i; def = true;
-					case TSharp: c.id = i; def = true;
-					case TDblDot: c.pseudoClass = i; def = true;
-					default: throw "assert";
-					}
-					last = null;
-				default:
-					unexpected(t);
-				}
-		}
-		return def ? c : parent;
-	}
-
-	// ----------------- value parser ---------------------------
-
-	function readIdent() {
-		var t = readToken();
-		return switch( t ) {
-		case TIdent(i): i;
-		default: unexpected(t);
-		}
-	}
-
-	function readValue(?opt)  : Value {
-		var t = readToken();
-		var v = switch( t ) {
-		case TSharp:
-			VHex(readHex());
-		case TIdent(i):
-			VIdent(i);
-		case TString(s):
-			VString(s);
-		case TInt(i):
-			readValueUnit(i, i);
-		case TFloat(f):
-			readValueUnit(f, null);
-		case TSlash:
-			VSlash;
-		default:
-			if( !opt ) unexpected(t);
-			push(t);
-			null;
-		};
-		if( v != null ) v = readValueNext(v);
-		return v;
-	}
-
-	function readHex() {
-		var start = pos;
-		while( true ) {
-			var c = next();
-			if( (c >= "A".code && c <= "F".code) || (c >= "a".code && c <= "f".code) || (c >= "0".code && c <= "9".code) )
-				continue;
-			pos--;
-			break;
-		}
-		return css.substr(start, pos - start);
-	}
-
-	function readValueUnit( f : Float, ?i : Int ) {
-		var t = readToken();
-		return switch( t ) {
-		case TIdent(i):
-			VUnit(f, i);
-		case TPercent:
-			VUnit(f, "%");
-		default:
-			push(t);
-			if( i != null )
-				VInt(i);
-			else
-				VFloat(f);
-		};
-	}
-
-	function readValueNext( v : Value ) : Value {
-		var t = readToken();
-		return switch( t ) {
-		case TPOpen:
-			switch( v ) {
-			case VIdent(i):
-				switch( i ) {
-				case "url":
-					readValueNext(VCall("url",[VString(readUrl())]));
-				default:
-					var args = switch( readValue() ) {
-					case VList(l): l;
-					case x: [x];
-					}
-					expect(TPClose);
-					readValueNext(VCall(i, args));
-				}
-			default:
-				push(t);
-				v;
-			}
-		case TExclam:
-			var t = readToken();
-			switch( t ) {
-			case TIdent(i):
-				VLabel(i, v);
-			default:
-				unexpected(t);
-			}
-		case TComma:
-			loopComma(v, readValue());
-		default:
-			push(t);
-			var v2 = readValue(true);
-			if( v2 == null )
-				v;
-			else
-				loopNext(v, v2);
-		}
-	}
-
-	function loopNext(v, v2) {
-		return switch( v2 ) {
-		case VGroup(l):
-			l.unshift(v);
-			v2;
-		case VList(l):
-			l[0] = loopNext(v, l[0]);
-			v2;
-		case VLabel(lab, v2):
-			VLabel(lab, loopNext(v, v2));
-		default:
-			VGroup([v, v2]);
-		};
-	}
-
-	function loopComma(v,v2) {
-		return switch( v2 ) {
-		case VList(l):
-			l.unshift(v);
-			v2;
-		case VLabel(lab, v2):
-			VLabel(lab, loopComma(v, v2));
-		default:
-			VList([v, v2]);
-		};
-	}
-
-	// ----------------- lexer -----------------------
-
-	inline function isSpace(c) {
-		return (c == " ".code || c == "\n".code || c == "\r".code || c == "\t".code);
-	}
-
-	inline function isIdentChar(c) {
-		return (c >= "a".code && c <= "z".code) || (c >= "A".code && c <= "Z".code) || (c == "-".code) || (c == "_".code);
-	}
-
-	inline function isNum(c) {
-		return c >= "0".code && c <= "9".code;
-	}
-
-	inline function next() {
-		return StringTools.fastCodeAt(css, pos++);
-	}
-
-	function readUrl() {
-		var c0 = next();
-		while( isSpace(c0) )
-			c0 = next();
-		var quote = c0;
-		if( quote == "'".code || quote == '"'.code ) {
-			pos--;
-			switch( readToken() ) {
-			case TString(s):
-				var c0 = next();
-				while( isSpace(c0) )
-					c0 = next();
-				if( c0 != ")".code )
-					throw "Invalid char " + String.fromCharCode(c0);
-				return s;
-			default: throw "assert";
-			}
-
-		}
-		var start = pos - 1;
-		while( true ) {
-			if( StringTools.isEof(c0) )
-				break;
-			c0 = next();
-			if( c0 == ")".code ) break;
-		}
-		return StringTools.trim(css.substr(start, pos - start - 1));
-	}
-
-	#if false
-	function readToken( ?pos : haxe.PosInfos ) {
-		var t = _readToken();
-		haxe.Log.trace(t, pos);
-		return t;
-	}
-
-	function _readToken() {
-	#else
-	function readToken() {
-	#end
-		var t = tokens.pop();
-		if( t != null )
-			return t;
-		while( true ) {
-			var c = next();
-			if( StringTools.isEof(c) )
-				return TEof;
-			if( isSpace(c) ) {
-				if( spacesTokens ) {
-					while( isSpace(next()) ) {
-					}
-					pos--;
-					return TSpaces;
-				}
-
-				continue;
-			}
-			if( isNum(c) || c == '-'.code ) {
-				var i = 0, neg = false;
-				if( c == '-'.code ) { c = "0".code; neg = true; }
-				do {
-					i = i * 10 + (c - "0".code);
-					c = next();
-				} while( isNum(c) );
-				if( c == ".".code ) {
-					var f : Float = i;
-					var k = 0.1;
-					while( isNum(c = next()) ) {
-						f += (c - "0".code) * k;
-						k *= 0.1;
-					}
-					pos--;
-					return TFloat(neg? -f : f);
-				}
-				pos--;
-				return TInt(neg ? -i : i);
-			}
-			if( isIdentChar(c) ) {
-				var pos = pos - 1;
-				do c = next() while( isIdentChar(c) || isNum(c) );
-				this.pos--;
-				return TIdent(css.substr(pos,this.pos - pos));
-			}
-			switch( c ) {
-			case ":".code: return TDblDot;
-			case "#".code: return TSharp;
-			case "(".code: return TPOpen;
-			case ")".code: return TPClose;
-			case "!".code: return TExclam;
-			case "%".code: return TPercent;
-			case ";".code: return TSemicolon;
-			case ".".code: return TDot;
-			case "{".code: return TBrOpen;
-			case "}".code: return TBrClose;
-			case ",".code: return TComma;
-			case "*".code: return TStar;
-			case "/".code:
-				if( (c = next()) != '*'.code ) {
-					pos--;
-					return TSlash;
-				}
-				while( true ) {
-					while( (c = next()) != '*'.code ) {
-						if( StringTools.isEof(c) )
-							throw "Unclosed comment";
-					}
-					c = next();
-					if( c == "/".code ) break;
-					if( StringTools.isEof(c) )
-						throw "Unclosed comment";
-				}
-				return readToken();
-			case "'".code, '"'.code:
-				var pos = pos;
-				var k;
-				while( (k = next()) != c ) {
-					if( StringTools.isEof(k) )
-						throw "Unclosed string constant";
-					if( k == "\\".code ) {
-						throw "todo";
-						continue;
-					}
-				}
-				return TString(css.substr(pos, this.pos - pos - 1));
-			default:
-			}
-			pos--;
-			throw "Invalid char " + css.charAt(pos);
-		}
-		return null;
-	}
-
-}

+ 0 - 124
h2d/css/Style.hx

@@ -1,124 +0,0 @@
-package h2d.css;
-import h2d.css.Defs;
-
-class Style {
-
-	public var fontName : Null<String>;
-	public var fontSize : Null<Float>;
-	public var color : Null<Int>;
-	public var backgroundColor : Null<FillStyle>;
-	public var borderRadius : Null<Float>;
-	public var borderSize : Null<Float>;
-	public var borderColor : Null<FillStyle>;
-	public var paddingTop : Null<Float>;
-	public var paddingLeft : Null<Float>;
-	public var paddingRight : Null<Float>;
-	public var paddingBottom : Null<Float>;
-	public var width : Null<Float>;
-	public var height : Null<Float>;
-	public var autoWidth : Null<Bool>;
-	public var autoHeight : Null<Bool>;
-	public var offsetX : Null<Float>;
-	public var offsetY : Null<Float>;
-	public var layout : Null<Layout>;
-	public var horizontalSpacing : Null<Float>;
-	public var verticalSpacing : Null<Float>;
-	public var marginTop : Null<Float>;
-	public var marginLeft : Null<Float>;
-	public var marginRight : Null<Float>;
-	public var marginBottom : Null<Float>;
-	public var increment : Null<Float>;
-	public var maxIncrement : Null<Float>;
-	public var tickColor : Null<FillStyle>;
-	public var tickSpacing : Null<Float>;
-	public var dock : Null<DockStyle>;
-	public var cursorColor : Null<Int>;
-	public var selectionColor : Null<Int>;
-	public var overflowHidden : Null<Bool>;
-	public var positionAbsolute : Null<Bool>;
-	public var icon:Null<hxd.Pixels>;
-	public var iconColor : Null<Int>;
-	public var iconLeft : Null<Float>;
-	public var iconTop : Null<Float>;
-	public var textAlign : Null<TextAlign>;
-	public var display : Null<Bool>;
-
-	public function new() {
-	}
-
-	public function apply( s : Style ) {
-		if( s.fontName != null ) fontName = s.fontName;
-		if( s.fontSize != null ) fontSize = s.fontSize;
-		if( s.color != null ) color = s.color;
-		if( s.backgroundColor != null ) backgroundColor = s.backgroundColor;
-		if( s.borderRadius != null ) borderRadius = s.borderRadius;
-		if( s.borderSize != null ) borderSize = s.borderSize;
-		if( s.borderColor != null ) borderColor = s.borderColor;
-		if( s.paddingLeft != null ) paddingLeft = s.paddingLeft;
-		if( s.paddingRight != null ) paddingRight = s.paddingRight;
-		if( s.paddingTop != null ) paddingTop = s.paddingTop;
-		if( s.paddingBottom != null ) paddingBottom = s.paddingBottom;
-		if( s.offsetX != null ) offsetX = s.offsetX;
-		if( s.offsetY != null ) offsetY = s.offsetY;
-		if( s.width != null ) width = s.width;
-		if( s.height != null ) height = s.height;
-		if( s.layout != null ) layout = s.layout;
-		if( s.horizontalSpacing != null ) horizontalSpacing = s.horizontalSpacing;
-		if( s.verticalSpacing != null ) verticalSpacing = s.verticalSpacing;
-		if( s.marginLeft != null ) marginLeft = s.marginLeft;
-		if( s.marginRight != null ) marginRight = s.marginRight;
-		if( s.marginTop != null ) marginTop = s.marginTop;
-		if( s.marginBottom != null ) marginBottom = s.marginBottom;
-		if( s.increment != null ) increment = s.increment;
-		if( s.maxIncrement != null ) maxIncrement = s.maxIncrement;
-		if( s.tickColor != null ) tickColor = s.tickColor;
-		if( s.tickSpacing != null ) tickSpacing = s.tickSpacing;
-		if( s.dock != null ) dock = s.dock;
-		if( s.cursorColor != null ) cursorColor = s.cursorColor;
-		if( s.selectionColor != null ) selectionColor = s.selectionColor;
-		if( s.overflowHidden != null ) overflowHidden = s.overflowHidden;
-		if( s.icon != null ) icon = s.icon;
-		if( s.iconColor != null ) iconColor = s.iconColor;
-		if( s.iconLeft != null ) iconLeft = s.iconLeft;
-		if( s.iconTop != null ) iconTop = s.iconTop;
-		if( s.positionAbsolute != null ) positionAbsolute = s.positionAbsolute;
-		if( s.autoWidth != null ) {
-			autoWidth = s.autoWidth;
-			width = s.width;
-		}
-		if( s.autoHeight != null ) {
-			autoHeight = s.autoHeight;
-			height = s.height;
-		}
-		if( s.textAlign != null ) textAlign = s.textAlign;
-		if( s.display != null ) display = s.display;
-	}
-
-	public function padding( v : Float ) {
-		this.paddingTop = v;
-		this.paddingLeft = v;
-		this.paddingRight = v;
-		this.paddingBottom = v;
-	}
-
-	public function margin( v : Float ) {
-		this.marginTop = v;
-		this.marginLeft = v;
-		this.marginRight = v;
-		this.marginBottom = v;
-	}
-
-	public function toString() {
-		var fields = [];
-		for( f in Type.getInstanceFields(Style) ) {
-			var v : Dynamic = Reflect.field(this, f);
-			if( v == null || Reflect.isFunction(v) || f == "toString" || f == "apply" )
-				continue;
-			if( f.toLowerCase().indexOf("color") >= 0 && Std.is(v,Int) )
-				v = "#" + StringTools.hex(v, 6);
-			fields.push(f + ": " + v);
-		}
-		return "{" + fields.join(", ") + "}";
-	}
-
-}

+ 0 - 176
h2d/css/default.css

@@ -1,176 +0,0 @@
-* {
-	font-family : "Arial";
-	font-size : 12px;
-	color : white;
-	offset : 0 0;
-	border : none;
-	background-color : transparent;
-	text-align : left;
-	padding : 0;
-	margin : 0;
-}
-
-div.modal {
-	layout : dock;
-	dock : full;
-	background-color : rgba(0,0,0,0.8);
-}
-
-button, select {
-	background-color : gradient(#434343, #4B4B4B, #383838, #3A3A3A);
-	border : 1px solid gradient(#A0A0A0,#909090,#707070,#606060);
-	padding : 2px 5px;
-}
-
-button:hover {
-	background-color : gradient(#282828,#2A2A2A,#333333,#3B3B3B);
-	border : 1px solid gradient(#606060,#606060,#707070,#606060);
-	margin-top : 1px;
-	padding-bottom : 1px;
-}
-
-:disabled {
-	color : #888;
-}
-
-box {
-	layout : inline;
-	spacing : 5 5;
-}
-
-:inline {
-	layout : inline;
-}
-
-:horizontal {
-	layout : horizontal;
-}
-
-:vertical {
-	layout : vertical;
-}
-
-:absolute {
-	layout : absolute;
-}
-
-:dock {
-	layout : dock;
-}
-
-box.panel {
-	background-color : gradient(#303030,#353535,#202020,#252525);
-}
-
-slider {
-	width : 100px;
-	height : 3px;
-	margin : 7px 5px;
-	background-color : #252525;
-	border : 1px solid gradient(#434343, #4B4B4B, #383838, #3A3A3A);
-}
-
-slider button, slider button:hover {
-	margin-top : -5px;
-	padding : 0px 2px;
-}
-
-checkbox {
-	width : 9px;
-	height : 9px;
-	color : #fff;
-	margin-top : 3px;
-	tick-spacing : 2px;
-	tick-color : gradient(#C0C0C0,#B0B0B0,#888888,#707070);
-	border : 1px solid gradient(#A0A0A0,#909090,#707070,#606060);
-	background-color : gradient(#303030,#252525,#252525,#252525);
-}
-
-itemlist {
-	padding : 5px;
-	vertical-spacing : 3px;
-	cursor-color : #333;
-	selection-color : #000;
-	border : 1px solid gradient(#A0A0A0,#909090,#707070,#606060);
-	background-color : gradient(#303030,#252525,#252525,#252525);
-	overflow : hidden;
-}
-
-input {
-	width : 80px;
-	height : 14px;
-	padding : 2px 3px;
-	border : 1px solid gradient(#A0A0A0,#909090,#707070,#606060);
-	background-color : gradient(#303030,#252525,#252525,#252525);
-	overflow : hidden;
-}
-
-input:focus {
-	border : 1px solid white;
-	cursor-color : white;
-}
-
-color {
-	width : 16px;
-	height : 14px;
-	padding : 1px;
-	border : 1px solid gradient(#A0A0A0,#909090,#707070,#606060);
-}
-
-color:hover {
-	border : 1px solid gradient(#C0C0C0,#B0B0B0,#888888,#707070);
-}
-
-colorpicker {
-	width : 200px;
-	height : 320px;
-	layout : absolute;
-	border : 1px solid gradient(#A0A0A0,#909090,#707070,#606060);
-	background-color : gradient(#303030,#252525,#252525,#252525);
-}
-
-gradienteditor {
-	width : 450px;
-	height : 200px;
-	layout : absolute;
-	border : 1px solid gradient(#A0A0A0,#909090,#707070,#606060);
-	background-color : gradient(#303030,#252525,#252525,#252525);
-}
-
-:close {
-	icon : url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAIAAACQkWg2AAAAB3RJTUUH3QsICzInlD+yVAAAABd0RVh0U29mdHdhcmUAR0xEUE5HIHZlciAzLjRxhaThAAAACHRwTkdHTEQzAAAAAEqAKR8AAAAEZ0FNQQAAsY8L/GEFAAAABmJLR0QA/wD/AP+gvaeTAAAAOklEQVR4nGP4z/CfJMQw2DVAAJoiVEEMG9D0YBiBzUlwRdgsxOGH/9hVU0sDaU4izdPkBCuNY5oWGgC4sxwBPtUQzAAAAABJRU5ErkJggg=');
-	icon-color : #999;
-}
-
-button:close {
-	width : 10px;
-	height : 10px;
-	padding : 2px;
-	icon-left : -1px;
-	icon-top : -1px;
-}
-
-select {
-	padding-left : 20px;
-	icon : url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA8AAAAPCAIAAAC0tAIdAAAAB3RJTUUH3QsGCg4t5gQ/sQAAABd0RVh0U29mdHdhcmUAR0xEUE5HIHZlciAzLjRxhaThAAAACHRwTkdHTEQzAAAAAEqAKR8AAAAEZ0FNQQAAsY8L/GEFAAAABmJLR0QA/wD/AP+gvaeTAAAAQElEQVR4nGP4z/CfeMSARRQOCKtGA/hUYwXYVeMBmKr34gZ4fUlamFBfNch9JPmSBNU4NeBxN7oGgr5EaKAwTABmAPc478+46wAAAABJRU5ErkJggg=');
-	icon-left : 3px;
-	icon-top : 3px;
-	icon-color : #999;
-}
-
-select:hover {
-	icon-color : #FFF;
-}
-
-itemlist.popup {
-	position : absolute;
-}
-
-value input {
-	width : 40px;
-	text-align : center;
-}
-
-value input:focus {
-	text-align : left;
-}