diff --git a/haxework/format/Formatter.hx b/haxework/format/Formatter.hx index 63caa56..2fbf2af 100755 --- a/haxework/format/Formatter.hx +++ b/haxework/format/Formatter.hx @@ -14,6 +14,7 @@ class Formatter implements IFormatter { case "nn": doubleDigit(date.getMinutes()); case "hh": doubleDigit(date.getHours()); case "dd": doubleDigit(date.getDate()); + case "d": Std.string(date.getDate()); case "mm": doubleDigit(date.getMonth() + 1); case "yyyy": date.getFullYear() + ""; case "month": locale.getArray("month")[date.getMonth()]; diff --git a/haxework/gui/GuiBuilder.hx b/haxework/gui/GuiBuilder.hx index a155aae..b841238 100755 --- a/haxework/gui/GuiBuilder.hx +++ b/haxework/gui/GuiBuilder.hx @@ -27,11 +27,16 @@ class GuiBuilder { private function new() {} public static function build(data:Dynamic, ?links:Dynamic):Dynamic { - var type:String = data.type; - Reflect.deleteField(data, "type"); - var object:Dynamic = instance(type); - fill(object, data, links); - return object; + if (Reflect.hasField(data, "type")) { + var type:String = data.type; + Reflect.deleteField(data, "type"); + var object:Dynamic = instance(type); + fill(object, data, links); + return object; + } else { + fill(data, data, links); + return data; + } } private static function fill(object:Dynamic, data:Dynamic, ?links:Dynamic):Void { diff --git a/haxework/gui/IView.hx b/haxework/gui/IView.hx index 773cdd3..6c42be2 100755 --- a/haxework/gui/IView.hx +++ b/haxework/gui/IView.hx @@ -8,6 +8,7 @@ import haxework.gui.core.SizeType; typedef Content = { var x:Float; var y:Float; + var visible:Bool; } interface IView { @@ -45,6 +46,8 @@ interface IView { public var parent(default, null):Null>; public var inLayout(default, set):Bool; + public var visible(default, set):Bool; + public function update():Void; public function invalidate():Void; } \ No newline at end of file diff --git a/haxework/gui/ImageView.hx b/haxework/gui/ImageView.hx new file mode 100755 index 0000000..e93d9fd --- /dev/null +++ b/haxework/gui/ImageView.hx @@ -0,0 +1,23 @@ +package haxework.gui; + +import haxework.gui.skin.BitmapSkin; +import haxework.gui.skin.ButtonBitmapSkin; +import flash.display.BitmapData; + +class ImageView extends SpriteView { + + private var image(default, set):BitmapData; + + public function new() { + super(); + } + + public function set_image(value:BitmapData):BitmapData { + if (image != value) { + image = value; + skin = untyped new BitmapSkin(image); + invalidate(); + } + return image; + } +} \ No newline at end of file diff --git a/haxework/gui/MovieView.hx b/haxework/gui/MovieView.hx index 3c83087..c90c558 100755 --- a/haxework/gui/MovieView.hx +++ b/haxework/gui/MovieView.hx @@ -6,7 +6,7 @@ class MovieView extends View { public var movie(get, set):MovieClip; - public function new(movie:MovieClip) { + public function new(?movie:MovieClip) { super(movie); } @@ -16,11 +16,15 @@ class MovieView extends View { private function set_movie(value:MovieClip):MovieClip { content = value; - if (contentSize) { - width = value.loaderInfo.width; - height = value.loaderInfo.height; - } invalidate(); return content; } + + override public function update():Void { + if (contentSize && movie != null) { + width = movie.loaderInfo.width; + height = movie.loaderInfo.height; + } + super.update(); + } } \ No newline at end of file diff --git a/haxework/gui/View.hx b/haxework/gui/View.hx index 4a11326..faa9854 100755 --- a/haxework/gui/View.hx +++ b/haxework/gui/View.hx @@ -51,6 +51,8 @@ class View implements IView { public var parent(default, null):Null>; public var inLayout(default, set):Bool; + public var visible(default, set):Bool; + public function new(content:C) { id = Type.getClassName(Type.getClass(this)) + counter++; this.content = content; @@ -62,6 +64,7 @@ class View implements IView { vAlign = VAlign.NONE; hAlign = HAlign.NONE; inLayout = true; + visible = true; } private function currentSkin():ISkin> { @@ -250,6 +253,14 @@ class View implements IView { } return inLayout; } + + private function set_visible(value:Bool):Bool { + if (visible != value) { + visible = value; + if (content != null) content.visible = visible; + } + return visible; + } } diff --git a/haxework/gui/skin/BitmapSkin.hx b/haxework/gui/skin/BitmapSkin.hx new file mode 100755 index 0000000..ee05f50 --- /dev/null +++ b/haxework/gui/skin/BitmapSkin.hx @@ -0,0 +1,40 @@ +package haxework.gui.skin; + +import flash.display.BitmapData; +import haxework.gui.utils.ColorUtils; +import haxework.gui.ButtonView.ButtonState; +import flash.display.Graphics; +import flash.display.Sprite; + +class BitmapSkin implements ISkin implements ISize { + + public var width(default, null):Float; + public var height(default, null):Float; + + public var image(null, set):BitmapData; + + public function new(?image:BitmapData = null) { + if (image != null) { + this.image = image; + } + } + + private function set_image(value:BitmapData):BitmapData { + if (image != value) { + image = value; + width = image.width; + height = image.height; + } + return image; + } + + public function draw(view:SpriteView):Void { + if (image == null) return; + var graphics:Graphics = view.content.graphics; + graphics.clear(); + graphics.beginBitmapFill(image, null, false, true); + graphics.drawRect(0, 0, view.width, view.height); + graphics.endFill(); + } + +} \ No newline at end of file