[macro] added @:view macro, refactored @:template macro

This commit is contained in:
2018-03-06 15:44:07 +03:00
parent 4a65cef02a
commit a53510d1d4
11 changed files with 243 additions and 198 deletions

View File

@@ -1,4 +1,9 @@
-cp src
-lib haxework
-cp ../../src/main
-lib yaml
-lib promhx
-main ViewExample.hx
-swf target/ViewExample.swf
--macro haxework.parser.Parser.auto()
-swf target/ViewExample.swf
#-as3 target

View File

@@ -1,29 +1,39 @@
package;
import haxework.gui.ViewBuilder;
import haxework.gui.View;
import haxework.gui.VGroupView;
import haxework.gui.ButtonView;
import haxework.gui.Root;
@:template("form.json")
class FormView extends VGroupView implements ViewBuilder {}
@:template2("form.json")
class FormView extends VGroupView {
@:view public var panel(default, null):View;
@:view public var button1(default, null):View;
@:view public var button2(default, null):View;
@:view public var button3(default, null):View;
private function init() {
trace('Init');
}
}
class ViewExample {
public static function main() {
new ViewExample();
}
public static function main() {
new ViewExample();
}
public function new() {
var form = new FormView({listener:this});
Root.bind(form);
trace(form.panel);
trace(form.button1);
trace(form.button2);
trace(form.button3);
}
public function new() {
var form:FormView = new FormView();
Root.bind(form);
trace(form.panel);
trace(form.button1);
trace(form.button2);
trace(form.button3);
}
public function onPress(view:ButtonView):Void {
trace("onPress: " + view.id);
}
public function onPress(view:ButtonView):Void {
trace("onPress: " + view.id);
}
}

View File

@@ -37,8 +37,7 @@
"width":100,
"pHeight":100,
"skin":{"@type":"haxework.gui.skin.ButtonColorSkin", "color":"0xcc0000"},
"text":"Text1",
"onPress":"@link:listener"
"text":"Text1"
},
{
"id":"button2",
@@ -47,8 +46,7 @@
"skin":{"@type":"haxework.gui.skin.ButtonColorSkin", "color":"0x00cc00"},
"text":"Text2",
"fontFamily":"Georgia",
"fontColor":"0xffffff",
"onPress":"@link:listener"
"fontColor":"0xffffff"
},
{
"id":"button3",
@@ -57,8 +55,7 @@
"skin":{"@type":"haxework.gui.skin.ButtonColorSkin", "color":"0x00cccc"},
"text":"Text 3333333333 ddd",
"fontFamily":"Tahoma",
"fontColor":"0xff0000",
"onPress":"@link:listener"
"fontColor":"0xff0000"
}
]
}