This commit is contained in:
2015-07-02 11:12:52 +03:00
parent b714f60be6
commit 2113d81475
7 changed files with 17 additions and 8 deletions

View File

@@ -95,6 +95,7 @@ class Field {
}
}
@:deprecated("Use haxework.gui.ViewBuilder")
class Builder {
private var factory:Class<Dynamic>;

View File

@@ -30,6 +30,7 @@ import haxework.gui.skin.ButtonBitmapSkin;
import haxework.gui.skin.ProgressSkin;
import haxework.gui.frame.FrameSwitcher;
@:deprecated("Use haxework.gui.ViewBuilder")
class GuiBuilder {
private static var cache:Map<String, Dynamic> = new Map<String, Dynamic>();

View File

@@ -13,11 +13,13 @@ class Root {
public static var instance(default, null):Root;
public var view(default, null):IView<Sprite>;
public var autoSize(default, default):Bool;
public function new(view:IView<Sprite>) {
public function new(view:IView<Sprite>, autoSize:Bool = true) {
if (instance != null) throw new Error("Only one instance");
instance = this;
this.view = view;
this.autoSize = autoSize;
Lib.current.addChild(view.content);
var content:DisplayObject = view.content;
if (content.stage == null) {
@@ -41,8 +43,13 @@ class Root {
private function onResize(?_):Void {
var content:DisplayObject = view.content;
view.width = content.stage.stageWidth;
view.height = content.stage.stageHeight;
if (autoSize) {
view.width = content.stage.stageWidth;
view.height = content.stage.stageHeight;
} else {
view.x = (content.stage.stageWidth - view.width) / 2;
view.y = (content.stage.stageHeight - view.height) / 2;
}
L.d("Screen", content.stage.stageWidth + "x" + content.stage.stageHeight);
}
}

View File

@@ -76,7 +76,7 @@ class ViewBuilderImpl {
var template = Json.parse(loadFileAsString(a[1]));
return getValue(data, name, style, key, template);
case "link":
"(links == null) ? untyped this : links[\"" + a[1] + "\"]";
"(links == null) ? untyped this : Reflect.field(links, \"" + a[1] + "\")";
case _:
throw "Unsupported prefix \"" + a[0] + "\"";
}
@@ -121,7 +121,7 @@ class ViewBuilderImpl {
if (["type", "style"].indexOf(key) > -1) continue;
var value = getValue(data, name, style, key, Reflect.field(template, key));
if (value != null) {
data.push(Context.parse(name + "." + key + " = untyped " + value, Context.currentPos()));
data.push(Context.parse(name + "." + key + " = cast " + value, Context.currentPos()));
}
}
return name;

View File

@@ -1,6 +1,6 @@
package haxework.gui.core;
@:enum abstract HAlign(String) {
@:enum abstract HAlign(String) from String to String {
var NONE = "NONE";
var LEFT = "LEFT";
var CENTER = "CENTER";

View File

@@ -1,6 +1,6 @@
package haxework.gui.core;
@:enum abstract VAlign(String) {
@:enum abstract VAlign(String) from String to String {
var NONE = "NONE";
var TOP = "TOP";
var MIDDLE = "MIDDLE";

View File

@@ -8,7 +8,7 @@ import flash.geom.Rectangle;
import flash.display.BitmapData;
import flash.display.Graphics;
@:enum abstract FillType(String) {
@:enum abstract FillType(String) from String to String {
var NONE = "NONE";
var DEFAULT = "DEFAULT";
var COVER = "COVER";