diff --git a/haxework/gui/Builder.hx b/haxework/gui/Builder.hx index 852c2b6..379b45c 100644 --- a/haxework/gui/Builder.hx +++ b/haxework/gui/Builder.hx @@ -95,6 +95,7 @@ class Field { } } +@:deprecated("Use haxework.gui.ViewBuilder") class Builder { private var factory:Class; diff --git a/haxework/gui/GuiBuilder.hx b/haxework/gui/GuiBuilder.hx index a62f2d1..8206234 100755 --- a/haxework/gui/GuiBuilder.hx +++ b/haxework/gui/GuiBuilder.hx @@ -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 = new Map(); diff --git a/haxework/gui/Root.hx b/haxework/gui/Root.hx index ade3d96..907122e 100755 --- a/haxework/gui/Root.hx +++ b/haxework/gui/Root.hx @@ -13,11 +13,13 @@ class Root { public static var instance(default, null):Root; public var view(default, null):IView; + public var autoSize(default, default):Bool; - public function new(view:IView) { + public function new(view:IView, 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); } } diff --git a/haxework/gui/ViewBuilder.hx b/haxework/gui/ViewBuilder.hx index c144ca1..1798619 100644 --- a/haxework/gui/ViewBuilder.hx +++ b/haxework/gui/ViewBuilder.hx @@ -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; diff --git a/haxework/gui/core/HAlign.hx b/haxework/gui/core/HAlign.hx index cb86638..8bb5c15 100755 --- a/haxework/gui/core/HAlign.hx +++ b/haxework/gui/core/HAlign.hx @@ -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"; diff --git a/haxework/gui/core/VAlign.hx b/haxework/gui/core/VAlign.hx index 99d9765..32bf8f0 100755 --- a/haxework/gui/core/VAlign.hx +++ b/haxework/gui/core/VAlign.hx @@ -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"; diff --git a/haxework/gui/utils/DrawUtil.hx b/haxework/gui/utils/DrawUtil.hx index 249e717..d668afc 100755 --- a/haxework/gui/utils/DrawUtil.hx +++ b/haxework/gui/utils/DrawUtil.hx @@ -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";