added GuiBuilder

This commit is contained in:
2013-08-27 10:34:25 +02:00
parent 752d0dd413
commit fdb2c0decb
8 changed files with 118 additions and 31 deletions

View File

@@ -1,40 +1,19 @@
package examples;
import haxework.gui.GuiBuilder;
import haxework.asset.JsonAsset;
import haxework.gui.Root;
import haxework.gui.core.HAlign;
import haxework.gui.core.VAlign;
import flash.Lib;
import haxework.gui.skin.ColorSkin;
import haxework.gui.View;
import haxework.gui.IView;
import flash.display.Sprite;
import haxework.gui.GroupView;
import haxework.gui.IGroupView;
@:file("examples/form.json")
class Form extends JsonAsset {}
class ViewExample {
public static function main() {
var group:IGroupView<Sprite> = new GroupView();
group.layoutVAlign = VAlign.MIDDLE;
group.layoutHAlign = HAlign.CENTER;
group.skin = new ColorSkin(0xffff00);
var view:IView<Sprite> = new View();
view.pWidth = 80;
view.pHeight = 80;
view.skin = new ColorSkin(0xff0000);
group.addView(view);
view = new View();
view.width = 100;
view.height = 100;
view.skin = new ColorSkin(0x00ff00);
group.addView(view);
view = new View();
view.width = 50;
view.height = 50;
view.skin = new ColorSkin(0x0000ff);
group.addView(view);
Lib.current.addChild(group.content);
new Root(group);
var form:Dynamic = new Form().value;
var v:IView<Sprite> = GuiBuilder.build(form);
new Root(v);
}
}

20
examples/form.json Executable file
View File

@@ -0,0 +1,20 @@
{
"type":"haxework.gui.GroupView",
"layoutHAlign":"~haxework.gui.core.HAlign:CENTER",
"layoutVAlign":"~haxework.gui.core.VAlign:MIDDLE",
"skin":{"type":"haxework.gui.skin.ColorSkin", "color":"0xff0000"},
"views":[
{
"type":"haxework.gui.View",
"pWidth":70,
"pHeight":70,
"skin":{"type":"haxework.gui.skin.ColorSkin", "color":"0x00ff00"}
},
{
"type":"haxework.gui.View",
"width":50,
"height":50,
"skin":{"type":"haxework.gui.skin.ColorSkin", "color":"0x0000ff"}
}
]
}