This commit is contained in:
2014-04-15 14:32:10 +04:00
parent a37f7f5c3d
commit c8d3ac1db7
6 changed files with 36 additions and 15 deletions

View File

@@ -54,7 +54,7 @@ class GroupView extends SpriteView implements IGroupView<Sprite> {
public function addView(view:IView<Dynamic>):IView<Dynamic> {
views.push(view);
viewsById.set(view.id, view);
content.addChild(view.content);
if (view.content != null) content.addChild(view.content);
view.parent = this;
invalidate();
return view;
@@ -73,7 +73,7 @@ class GroupView extends SpriteView implements IGroupView<Sprite> {
view.parent = null;
viewsById.remove(view.id);
views.remove(view);
content.removeChild(view.content);
if (view.content != null) content.removeChild(view.content);
invalidate();
return view;
}

View File

@@ -68,11 +68,11 @@ class GuiB {
}
private static function instance(type:String):Dynamic {
var clazz:Class<Dynamic> = Type.resolveClass(type);
if (clazz == null) throw new TypeError("Class \"" + type + "\" not found");
var instance:Dynamic = Type.createInstance(clazz, []);
return instance;
}
var clazz:Class<Dynamic> = Type.resolveClass(type);
if (clazz == null) throw new TypeError("Class \"" + type + "\" not found");
var instance:Dynamic = Type.createInstance(clazz, []);
return instance;
}
}
class GuiF {

View File

@@ -1,10 +1,13 @@
package haxework.gui;
import haxework.net.SwfLoader;
import flash.display.MovieClip;
//ToDo: sprite wrapper?
class MovieView extends View<MovieClip> {
public var movie(get, set):MovieClip;
public var movieUrl(default, set):String;
public function new(?movie:MovieClip) {
super(movie);
@@ -21,6 +24,7 @@ class MovieView extends View<MovieClip> {
parent.content.removeChild(content);
}
content = value;
content.visible = visible;
if (parent != null) {
parent.content.addChildAt(content, index);
}
@@ -28,11 +32,26 @@ class MovieView extends View<MovieClip> {
return content;
}
private function set_movieUrl(value:String):String {
movieUrl = value;
new SwfLoader().GET(movieUrl)
.success(function(data:MovieClip):Void {
movie = data;
});
return movieUrl;
}
override public function update():Void {
if (contentSize && movie != null) {
width = movie.loaderInfo.width;
height = movie.loaderInfo.height;
if (contentSize && content != null) {
width = content.loaderInfo.width;
height = content.loaderInfo.height;
}
super.update();
if (!contentSize && content != null) {
var s:Float = Math.min(width / content.loaderInfo.width, height / content.loaderInfo.height);
content.scaleX = content.scaleY = s;
content.x = (width - content.loaderInfo.width * s) / 2;
content.y = (height - content.loaderInfo.height * s) / 2;
}
}
}

View File

@@ -86,8 +86,10 @@ class View<C:Content> implements IView<C> {
}
public function update():Void {
content.x = x;
content.y = y;
if (content != null) {
content.x = x;
content.y = y;
}
var skin:ISkin<C, IView<C>> = currentSkin();
if (contentSize && skin != null && Std.is(skin, ISize)) {
var size:ISize = cast(skin, ISize);

View File

@@ -9,8 +9,8 @@ class ButtonColorSkin implements ISkin<Sprite, ButtonView> {
public var color(default, set_color):Int;
public var alpha(default, default):Float;
public var disable(default, default):Int;
private var colors:Map<ButtonState, Int>;
private var disable:Int;
public function new(?color:Int = 0xffffff, ?alpha:Float = 1.0) {
this.color = color;
@@ -22,7 +22,7 @@ class ButtonColorSkin implements ISkin<Sprite, ButtonView> {
colors.set(ButtonState.UP, value);
colors.set(ButtonState.DOWN, ColorUtils.diff(value, -64));
colors.set(ButtonState.OVER, ColorUtils.diff(value, 64));
disable = ColorUtils.multiply(value, 0.6);
//disable = ColorUtils.multiply(value, 0.6);
return value;
}

View File

@@ -56,7 +56,7 @@ class Callback<T> implements ICallback<T> {
public function glue(callback:ICallback<T>):ICallback<T> {
this._success = callback.callSuccess;
this._fail = callback.callFail;
callback.dispose();
//callback.dispose(); //ToDo:
return this;
}