sample fix

This commit is contained in:
2015-07-03 11:43:05 +03:00
parent cd2e80501b
commit 37846c4a18
8 changed files with 44 additions and 60 deletions

5
.gitignore vendored
View File

@@ -1,5 +1,8 @@
/.idea
*.iml
*.ipr
*.iws
out/
target/
target/
*.zip
pack.sh

View File

@@ -1,4 +0,0 @@
-main examples.ViewExample
-swf target/ViewExample.swf
-debug
-dce no

View File

@@ -1,32 +0,0 @@
package examples;
import haxework.gui.IGroupView;
import haxework.gui.ButtonView;
import haxework.gui.GuiBuilder;
import haxework.asset.JsonAsset;
import haxework.gui.Root;
import flash.display.Sprite;
@:file("examples/form.json")
class Form extends JsonAsset {}
class ViewExample implements ButtonViewListener {
public static function main() {
new ViewExample();
}
public function new() {
//var form:Dynamic = new Form().value;
var bytes = openfl.Assets.getBytes("examples/form.json");
var form:Dynamic = haxe.Json.parse(bytes.readUTFBytes(bytes.bytesAvailable));
var v:IGroupView<Sprite> = GuiBuilder.build(form, {listener:this});
new Root(v);
var button3:ButtonView = v.findViewById("panel:button3");
trace(button3.id);
}
public function onPress(view:ButtonView):Void {
trace("onPress: " + view.id);
}
}

View File

@@ -4,8 +4,10 @@
"license": "BSD",
"tags": ["flash"],
"description": "Framework.",
"version": "0.1.0",
"releasenote": "Update.",
"version": "0.2.0",
"releasenote": "ViewBuilder.",
"contributors": ["shmyga"],
"dependencies": {}
"dependencies": {
"openfl": ""
}
}

View File

@@ -1,10 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<project>
<meta title="ViewExample" package="haxework.examples" version="1.0.0" company="MegaLoMania"/>
<app path="target" file="ViewExample" main="examples.ViewExample"/>
<window width="800" height="600" if="desktop"/>
<window width="0" height="0" if="html5"/>
<source path="."/>
<haxelib name="openfl"/>
<assets path="examples" include="*"/>
</project>

View File

@@ -0,0 +1,4 @@
-cp src
-lib haxework
-main ViewExample.hx
-swf target/ViewExample.swf

View File

@@ -0,0 +1,24 @@
package;
import haxework.gui.ViewBuilder;
import haxework.gui.VGroupView;
import haxework.gui.ButtonView;
import haxework.gui.Root;
@:template("form.json")
class FormView extends VGroupView implements ViewBuilder {}
class ViewExample {
public static function main() {
new ViewExample();
}
public function new() {
new Root(new FormView({listener:this}));
}
public function onPress(view:ButtonView):Void {
trace("onPress: " + view.id);
}
}

View File

@@ -1,13 +1,11 @@
{
"type":"haxework.gui.VGroupView",
"layoutHAlign":"~haxework.gui.core.HAlign:CENTER",
"layoutVAlign":"~haxework.gui.core.VAlign:MIDDLE",
"paddings":20,
"layoutMargin":10,
"skin":{"type":"haxework.gui.skin.ColorSkin", "color":"0xff0000"},
"views":[
{
"type":"haxework.gui.View",
"type":"haxework.gui.SpriteView",
"pWidth":100,
"pHeight":100,
"leftMargin":5,
@@ -15,8 +13,8 @@
"skin":{"type":"haxework.gui.skin.ColorSkin", "color":"0x00ff00"}
},
{
"type":"haxework.gui.View",
"vAlign":"~haxework.gui.core.VAlign:BOTTOM",
"type":"haxework.gui.SpriteView",
"vAlign":"BOTTOM",
"width":50,
"height":50,
"leftMargin":5,
@@ -26,8 +24,7 @@
{
"id":"panel",
"type":"haxework.gui.HGroupView",
"layoutHAlign":"~haxework.gui.core.HAlign:RIGHT",
"layoutVAlign":"~haxework.gui.core.VAlign:MIDDLE",
"layoutHAlign":"RIGHT",
"pWidth":100,
"height":30,
"paddings":3,
@@ -41,7 +38,7 @@
"pHeight":100,
"skin":{"type":"haxework.gui.skin.ButtonColorSkin", "color":"0xcc0000"},
"text":"Text1",
"onPress":"#listener"
"onPress":"@link:listener"
},
{
"id":"button2",
@@ -51,7 +48,7 @@
"text":"Text2",
"fontFamily":"Georgia",
"fontColor":"0xffffff",
"onPress":"#listener"
"onPress":"@link:listener"
},
{
"id":"button3",
@@ -61,7 +58,7 @@
"text":"Text 3333333333 ddd",
"fontFamily":"Tahoma",
"fontColor":"0xff0000",
"onPress":"#listener"
"onPress":"@link:listener"
}
]
}