From f53b065d59d3257c58d6540785a80d6b33bb9b5b Mon Sep 17 00:00:00 2001 From: shmyga Date: Fri, 10 Jul 2015 19:52:21 +0300 Subject: [PATCH] view type removed --- haxework/animate/CircleMaskAnimate.hx | 11 +++---- haxework/animate/FadeAnimate.hx | 4 +-- haxework/animate/UnFadeAnimate.hx | 4 +-- haxework/gui/AnimateView.hx | 2 +- haxework/gui/ButtonView.hx | 6 ++-- haxework/gui/GroupView.hx | 38 ++++++++++++++----------- haxework/gui/IGroupView.hx | 20 +++++++------ haxework/gui/ITextView.hx | 5 ++-- haxework/gui/IView.hx | 25 ++++------------ haxework/gui/InputView.hx | 2 +- haxework/gui/MovieView.hx | 12 ++++---- haxework/gui/Root.hx | 4 +-- haxework/gui/SpriteView.hx | 8 +++++- haxework/gui/TextView.hx | 4 +-- haxework/gui/ToggleButtonView.hx | 6 ++-- haxework/gui/View.hx | 27 ++++++++++-------- haxework/gui/ViewBuilder.hx | 2 +- haxework/gui/frame/FrameSwitcher.hx | 19 +++++++------ haxework/gui/frame/IFrameSwitcher.hx | 6 ++-- haxework/gui/layout/DefaultLayout.hx | 14 ++++----- haxework/gui/layout/HorizontalLayout.hx | 2 +- haxework/gui/layout/ILayout.hx | 2 +- haxework/gui/layout/VerticalLayout.hx | 2 +- haxework/gui/list/HListView.hx | 15 +++++----- haxework/gui/list/HScrollSkin.hx | 4 +-- haxework/gui/list/ListView.hx | 22 +++++++------- haxework/gui/list/ScrollView.hx | 2 +- haxework/gui/list/VListView.hx | 15 +++++----- haxework/gui/list/VScrollSkin.hx | 4 +-- haxework/gui/popup/PopupManager.hx | 6 ++-- haxework/gui/popup/PopupView.hx | 2 +- haxework/gui/skin/BitmapSkin.hx | 4 +-- haxework/gui/skin/ButtonBitmapSkin.hx | 4 +-- haxework/gui/skin/ButtonColorSkin.hx | 4 +-- haxework/gui/skin/ColorSkin.hx | 6 ++-- haxework/gui/skin/FakeSkin.hx | 4 +-- haxework/gui/skin/ISkin.hx | 2 +- haxework/gui/skin/ProgressSkin.hx | 4 +-- 38 files changed, 163 insertions(+), 160 deletions(-) mode change 100644 => 100755 haxework/animate/CircleMaskAnimate.hx mode change 100644 => 100755 haxework/animate/FadeAnimate.hx mode change 100644 => 100755 haxework/animate/UnFadeAnimate.hx mode change 100644 => 100755 haxework/gui/ViewBuilder.hx mode change 100644 => 100755 haxework/gui/popup/PopupManager.hx diff --git a/haxework/animate/CircleMaskAnimate.hx b/haxework/animate/CircleMaskAnimate.hx old mode 100644 new mode 100755 index 8e54b2a..4ff5733 --- a/haxework/animate/CircleMaskAnimate.hx +++ b/haxework/animate/CircleMaskAnimate.hx @@ -1,5 +1,6 @@ package haxework.animate; +import flash.display.DisplayObjectContainer; import haxework.animate.IAnimate; import flash.display.Sprite; import haxework.gui.IView; @@ -7,12 +8,12 @@ import haxework.animate.Animate; class CircleMaskAnimate extends Animate { - private var view:IView; + private var view:IView; private var mask:Sprite; private var cyrcle:Sprite; private var size:Float; - public function new(view:IView, ?duration:Int = 1000) { + public function new(view:IView, ?duration:Int = 1000) { super(duration); this.view = view; this.mask = new Sprite(); @@ -29,9 +30,9 @@ class CircleMaskAnimate extends Animate { redraw(size, size); - view.parent.content.addChild(mask); + view.parent.container.addChild(mask); view.content.mask = mask; - view.parent.content.addChild(cyrcle); + view.parent.container.addChild(cyrcle); super.start(callback, custom); } @@ -56,7 +57,7 @@ class CircleMaskAnimate extends Animate { if (progress >= 1 && view.content.parent != null) { if (view.content.parent.contains(mask)) view.content.parent.removeChild(mask); view.content.mask = null; - if (view.content.parent.contains(cyrcle)) view.parent.content.removeChild(cyrcle); + if (view.content.parent.contains(cyrcle)) view.parent.container.removeChild(cyrcle); } } } diff --git a/haxework/animate/FadeAnimate.hx b/haxework/animate/FadeAnimate.hx old mode 100644 new mode 100755 index 41930a8..b737cfb --- a/haxework/animate/FadeAnimate.hx +++ b/haxework/animate/FadeAnimate.hx @@ -7,9 +7,9 @@ import haxework.animate.Animate; class FadeAnimate extends Animate { - private var view:IView; + private var view:IView; - public function new(view:IView, ?duration = 500) { + public function new(view:IView, ?duration = 500) { super(duration); this.view = view; } diff --git a/haxework/animate/UnFadeAnimate.hx b/haxework/animate/UnFadeAnimate.hx old mode 100644 new mode 100755 index 9d79081..e334177 --- a/haxework/animate/UnFadeAnimate.hx +++ b/haxework/animate/UnFadeAnimate.hx @@ -6,9 +6,9 @@ import haxework.animate.Animate; class UnFadeAnimate extends Animate { - private var view:IView; + private var view:IView; - public function new(view:IView, ?duration = 500) { + public function new(view:IView, ?duration = 500) { super(duration); this.view = view; } diff --git a/haxework/gui/AnimateView.hx b/haxework/gui/AnimateView.hx index a524d16..9971c54 100755 --- a/haxework/gui/AnimateView.hx +++ b/haxework/gui/AnimateView.hx @@ -18,7 +18,7 @@ class AnimateView extends SpriteView { frames = []; frame = 0; interval = 200; - content.addChild(bitmap); + contentAsSprite.addChild(bitmap); changeFrame(); } diff --git a/haxework/gui/ButtonView.hx b/haxework/gui/ButtonView.hx index 074a80a..7901b5c 100755 --- a/haxework/gui/ButtonView.hx +++ b/haxework/gui/ButtonView.hx @@ -26,8 +26,8 @@ class ButtonView extends LabelView { downed = false; state = ButtonState.UP; dispatcher = new Dispatcher>(); - content.buttonMode = true; - content.mouseChildren = false; + contentAsSprite.buttonMode = true; + contentAsSprite.mouseChildren = false; #if js content.addEventListener(MouseEvent.MOUSE_UP, onMouseClick); #else @@ -81,7 +81,7 @@ class ButtonView extends LabelView { private function set_disabled(value:Bool):Bool { if (disabled != value) { disabled = value; - content.buttonMode = !disabled; + contentAsSprite.buttonMode = !disabled; invalidate(); } return disabled; diff --git a/haxework/gui/GroupView.hx b/haxework/gui/GroupView.hx index 6c1635d..cede1be 100755 --- a/haxework/gui/GroupView.hx +++ b/haxework/gui/GroupView.hx @@ -1,14 +1,16 @@ package haxework.gui; +import flash.display.DisplayObjectContainer; import haxework.gui.core.VAlign; import haxework.gui.core.HAlign; import haxework.gui.layout.DefaultLayout; import haxework.gui.layout.ILayout; import flash.display.Sprite; -class GroupView extends SpriteView implements IGroupView { +class GroupView extends SpriteView implements IGroupView { + public var container(get, null):DisplayObjectContainer; - public var views(default, set):Array>; + public var views(default, set):Array; public var layout(default, default):ILayout; public var layoutVAlign(default, set):VAlign; @@ -21,7 +23,7 @@ class GroupView extends SpriteView implements IGroupView { public var bottomPadding(default, set):Float; public var paddings(null, set):Float; - private var viewsById:Map>; + private var viewsById:Map; public function new(?layout:ILayout) { super(); @@ -31,7 +33,11 @@ class GroupView extends SpriteView implements IGroupView { layoutHAlign = HAlign.CENTER; layoutVAlign = VAlign.MIDDLE; views = []; - viewsById = new Map>(); + viewsById = new Map(); + } + + inline private function get_container():DisplayObjectContainer { + return contentAsSprite; } override public function update():Void { @@ -39,51 +45,51 @@ class GroupView extends SpriteView implements IGroupView { for (view in views) { view.update(); if (view.index > -1) { - content.setChildIndex(view.content, view.index); + contentAsSprite.setChildIndex(view.content, view.index); } } super.update(); } - public function set_views(value:Array>):Array> { + public function set_views(value:Array):Array { if (views == null) views = []; for (view in value) addView(view); return views; } - public function addView(view:IView):IView { + public function addView(view:IView):IView { views.push(view); viewsById.set(view.id, view); - if (view.content != null) content.addChild(view.content); + if (view.content != null) contentAsSprite.addChild(view.content); view.parent = this; invalidate(); return view; } - public function insertView(view:IView, index:Int):IView { + public function insertView(view:IView, index:Int):IView { if (index < 0) index = views.length + index; views.insert(index, view); viewsById.set(view.id, view); - if (view.content != null) content.addChild(view.content); + if (view.content != null) contentAsSprite.addChild(view.content); view.parent = this; invalidate(); return view; } - public function addViewFirst(view:IView):IView { + public function addViewFirst(view:IView):IView { views.unshift(view); viewsById.set(view.id, view); - content.addChild(view.content); + contentAsSprite.addChild(view.content); view.parent = this; invalidate(); return view; } - public function removeView(view:IView):IView { + public function removeView(view:IView):IView { view.parent = null; viewsById.remove(view.id); views.remove(view); - if (view.content != null) content.removeChild(view.content); + if (view.content != null) contentAsSprite.removeChild(view.content); invalidate(); return view; } @@ -94,7 +100,7 @@ class GroupView extends SpriteView implements IGroupView { } } - public function removeViewById(id:String):IView { + public function removeViewById(id:String):IView { if (viewsById.exists(id)) { return removeView(viewsById.get(id)); } else { @@ -102,7 +108,7 @@ class GroupView extends SpriteView implements IGroupView { } } - public function findViewById>(id:String, ?clazz:Class):Null { + public function findViewById(id:String, ?clazz:Class):Null { var idd:Array = id.split(":"); if (idd.length > 1) { var id0 = idd.shift(); diff --git a/haxework/gui/IGroupView.hx b/haxework/gui/IGroupView.hx index eec97cf..ca3297d 100755 --- a/haxework/gui/IGroupView.hx +++ b/haxework/gui/IGroupView.hx @@ -1,24 +1,26 @@ package haxework.gui; -import haxework.gui.IView.Content; +import flash.display.DisplayObject; +import flash.display.DisplayObjectContainer; import haxework.gui.core.HAlign; import haxework.gui.core.VAlign; import haxework.gui.layout.ILayout; -interface IGroupView extends IView extends HasPaddings { +interface IGroupView extends IView extends HasPaddings { + public var container(get, null):DisplayObjectContainer; - public var views(default, null):Array>; + public var views(default, null):Array; public var layout(default, default):ILayout; public var layoutVAlign(default, set):VAlign; public var layoutHAlign(default, set):HAlign; public var layoutMargin(default, set):Float; - public function addView(view:IView):IView; - public function addViewFirst(view:IView):IView; - public function insertView(view:IView, index:Int):IView; - public function removeView(view:IView):IView; + public function addView(view:IView):IView; + public function addViewFirst(view:IView):IView; + public function insertView(view:IView, index:Int):IView; + public function removeView(view:IView):IView; public function removeAllViews():Void; - public function removeViewById(id:String):IView; - public function findViewById>(id:String, ?clazz:Class):Null; + public function removeViewById(id:String):IView; + public function findViewById(id:String, ?clazz:Class):Null; } \ No newline at end of file diff --git a/haxework/gui/ITextView.hx b/haxework/gui/ITextView.hx index c5542a5..13804ed 100755 --- a/haxework/gui/ITextView.hx +++ b/haxework/gui/ITextView.hx @@ -1,10 +1,11 @@ package haxework.gui; +import flash.text.TextField; import haxework.gui.IView.Content; import flash.text.TextFormatAlign; -interface ITextView extends IView extends HasPaddings { - public var textField(default, null):T; +interface ITextView extends IView extends HasPaddings { + public var textField(default, null):TextField; public var text(get, set):String; public var align(default, set):TextFormatAlign; //ToDo: font properties to object diff --git a/haxework/gui/IView.hx b/haxework/gui/IView.hx index e9749aa..849a6d4 100755 --- a/haxework/gui/IView.hx +++ b/haxework/gui/IView.hx @@ -1,27 +1,12 @@ package haxework.gui; +import flash.display.DisplayObject; import haxework.gui.core.VAlign; import haxework.gui.core.HAlign; import haxework.gui.skin.ISkin; import haxework.gui.core.SizeType; -typedef Content = { - #if flash - var x(default,default):Float; - var y(default,default):Float; - var visible(default,default):Bool; - var alpha(default,default):Float; - @:optional var mouseEnabled(default,default):Bool; - #else - var x(get,set):Float; - var y(get,set):Float; - var visible(get,set):Bool; - var alpha(get,set):Float; - @:optional var mouseEnabled(default,default):Bool; - #end -} - -interface IView { +interface IView { public var id(default, default):String; public var x(default, set):Float; @@ -52,10 +37,10 @@ interface IView { public var bottomMargin(default, set):Float; public var margins(null, set):Float; - public var content(default, null):C; - public var skin(default, set):ISkin>; + public var content(default, null):DisplayObject; + public var skin(default, set):ISkin; - public var parent(default, null):Null>; + public var parent(default, null):Null; public var inLayout(default, set):Bool; public var visible(default, set):Bool; diff --git a/haxework/gui/InputView.hx b/haxework/gui/InputView.hx index bd1c62c..17e269a 100755 --- a/haxework/gui/InputView.hx +++ b/haxework/gui/InputView.hx @@ -28,7 +28,7 @@ class InputView extends TextView implements IDisposable { textField.addEventListener(KeyboardEvent.KEY_DOWN, onKeyDown); hintTextField = buildHintTextField(); - content.addChild(hintTextField); + contentAsSprite.addChild(hintTextField); } override private function buildTextField():TextField { diff --git a/haxework/gui/MovieView.hx b/haxework/gui/MovieView.hx index ab32b89..bf696ec 100755 --- a/haxework/gui/MovieView.hx +++ b/haxework/gui/MovieView.hx @@ -4,7 +4,7 @@ import haxework.net.SwfLoader; import flash.display.MovieClip; //ToDo: sprite wrapper? -class MovieView extends View { +class MovieView extends View { public var movie(get, set):MovieClip; public var movieUrl(default, set):String; @@ -14,22 +14,22 @@ class MovieView extends View { } private function get_movie():MovieClip { - return content; + return cast content; } private function set_movie(value:MovieClip):MovieClip { var index:Int = 0; if (parent != null && content != null) { - index = parent.content.getChildIndex(content); - parent.content.removeChild(content); + index = parent.container.getChildIndex(content); + parent.container.removeChild(content); } content = value; content.visible = visible; if (parent != null) { - parent.content.addChildAt(content, index); + parent.container.addChildAt(content, index); } invalidate(); - return content; + return cast content; } private function set_movieUrl(value:String):String { diff --git a/haxework/gui/Root.hx b/haxework/gui/Root.hx index 907122e..8678d99 100755 --- a/haxework/gui/Root.hx +++ b/haxework/gui/Root.hx @@ -12,10 +12,10 @@ class Root { public static var instance(default, null):Root; - public var view(default, null):IView; + public var view(default, null):IView; public var autoSize(default, default):Bool; - public function new(view:IView, autoSize:Bool = true) { + public function new(view:IView, autoSize:Bool = true) { if (instance != null) throw new Error("Only one instance"); instance = this; this.view = view; diff --git a/haxework/gui/SpriteView.hx b/haxework/gui/SpriteView.hx index 60bb9d8..9685d48 100755 --- a/haxework/gui/SpriteView.hx +++ b/haxework/gui/SpriteView.hx @@ -3,12 +3,18 @@ package haxework.gui; import flash.display.Graphics; import flash.display.Sprite; -class SpriteView extends View { +class SpriteView extends View { + + public var contentAsSprite(get, null):Sprite; public function new() { super(new Sprite()); } + inline private function get_contentAsSprite():Sprite { + return cast content; + } + #if dev_layout override public function update():Void { super.update(); diff --git a/haxework/gui/TextView.hx b/haxework/gui/TextView.hx index c002594..75260f5 100755 --- a/haxework/gui/TextView.hx +++ b/haxework/gui/TextView.hx @@ -12,7 +12,7 @@ import flash.text.TextFormat; import flash.display.Sprite; import flash.text.TextField; -class TextView extends SpriteView implements ITextView { +class TextView extends SpriteView implements ITextView { public var textField(default, null):TextField; public var text(get, set):String; @@ -60,7 +60,7 @@ class TextView extends SpriteView implements ITextView { textFormat.size = 16; textFormat.leading = 0; textFormat.align = TextFormatAlign.CENTER; - content.addChild(textField); + contentAsSprite.addChild(textField); } private function buildTextField():TextField { diff --git a/haxework/gui/ToggleButtonView.hx b/haxework/gui/ToggleButtonView.hx index 13d0b6c..7e1d37b 100755 --- a/haxework/gui/ToggleButtonView.hx +++ b/haxework/gui/ToggleButtonView.hx @@ -6,7 +6,7 @@ import haxework.gui.skin.ISkin; class ToggleButtonView extends ButtonView { public var on(default, set):Bool; - public var onSkin(default, set):ISkin>; + public var onSkin(default, set):ISkin; public var onText(default, set):String; @@ -20,13 +20,13 @@ class ToggleButtonView extends ButtonView { return on; } - private function set_onSkin(value:ISkin>):ISkin> { + private function set_onSkin(value:ISkin):ISkin { onSkin = value; invalidate(); return onSkin; } - override private function currentSkin():ISkin> { + override private function currentSkin():ISkin { return on ? onSkin : skin; } diff --git a/haxework/gui/View.hx b/haxework/gui/View.hx index 405b993..79a78f3 100755 --- a/haxework/gui/View.hx +++ b/haxework/gui/View.hx @@ -1,7 +1,8 @@ package haxework.gui; +import flash.display.InteractiveObject; +import flash.display.DisplayObject; import flash.errors.Error; -import haxework.gui.IView.Content; import haxework.gui.skin.ISize; import haxework.gui.core.SizeType; import haxework.gui.core.HAlign; @@ -13,7 +14,7 @@ import haxework.gui.skin.ISkin; import flash.display.Sprite; -class View implements IView { +class View implements IView { private static var counter:Int = 0; public static var updater(default, null):Updater = new Updater(); @@ -48,17 +49,17 @@ class View implements IView { public var bottomMargin(default, set):Float; public var margins(null, set):Float; - public var content(default, null):C; - public var skin(default, set):ISkin>; + public var content(default, null):DisplayObject; + public var skin(default, set):ISkin; - public var parent(default, null):Null>; + public var parent(default, null):Null; public var inLayout(default, set):Bool; public var visible(default, set):Bool; public var index(default, set):Int; public var mouseEnabled(default, set):Bool = true; - public function new(content:C) { + public function new(content:DisplayObject) { id = Type.getClassName(Type.getClass(this)) + counter++; this.content = content; x = 0; @@ -73,7 +74,7 @@ class View implements IView { index = -1; } - private function currentSkin():ISkin> { + private function currentSkin():ISkin { return skin; } @@ -91,7 +92,7 @@ class View implements IView { content.x = x; content.y = y; } - var skin:ISkin> = currentSkin(); + var skin:ISkin = currentSkin(); if (contentSize && skin != null && Std.is(skin, ISize)) { var size:ISize = cast(skin, ISize); if (!Math.isNaN(size.width)) width = size.width; @@ -263,7 +264,7 @@ class View implements IView { return value; } - private function set_skin(value:ISkin>):ISkin> { + private function set_skin(value:ISkin):ISkin { skin = value; invalidate(); return skin; @@ -296,7 +297,9 @@ class View implements IView { private function set_mouseEnabled(value:Bool):Bool { if (mouseEnabled != value) { mouseEnabled = value; - if (content != null) content.mouseEnabled = mouseEnabled; + if (content != null && Std.is(content, InteractiveObject)) { + cast(content, InteractiveObject).mouseEnabled = mouseEnabled; + } } return mouseEnabled; } @@ -306,7 +309,7 @@ class View implements IView { class Updater { public var stage(null, set):Stage; - private var invalidated:Array>; + private var invalidated:Array; public function new() { invalidated = []; @@ -317,7 +320,7 @@ class Updater { return value; } - public function invalidate(view:IView):Void { + public function invalidate(view:IView):Void { if (Lambda.indexOf(invalidated, view) == -1) invalidated.push(view); } diff --git a/haxework/gui/ViewBuilder.hx b/haxework/gui/ViewBuilder.hx old mode 100644 new mode 100755 index 5211263..3ddd23f --- a/haxework/gui/ViewBuilder.hx +++ b/haxework/gui/ViewBuilder.hx @@ -152,7 +152,7 @@ private class Builder { if (["type", "style"].indexOf(key) > -1) continue; var value = getValue(name, key, Reflect.field(template, key)); if (value != null) { - exprs.push(Context.parse(name + "." + key + " = cast " + value, getPosition())); + exprs.push(Context.parse(name + "." + key + " = " + value, getPosition())); } } return name; diff --git a/haxework/gui/frame/FrameSwitcher.hx b/haxework/gui/frame/FrameSwitcher.hx index 96e204d..7ca5c27 100755 --- a/haxework/gui/frame/FrameSwitcher.hx +++ b/haxework/gui/frame/FrameSwitcher.hx @@ -5,28 +5,28 @@ import flash.display.Sprite; import haxework.gui.IView; import haxework.gui.GroupView; -class FrameSwitcher extends GroupView implements IFrameSwitcher { +class FrameSwitcher extends GroupView implements IFrameSwitcher { - public var current(default, null):Null>; - private var frames:Map>; + public var current(default, null):Null; + private var frames:Map; public var animateFactory(default, default):Class; private var animate:IAnimate; public function new() { super(); - frames = new Map>(); + frames = new Map(); current = null; } - private function buildAnimate(view:IView):Null { + private function buildAnimate(view:IView):Null { if (animateFactory != null) { return Type.createInstance(animateFactory, [view]); } return null; } - public function change(id:String):IView { + public function change(id:String):IView { var prev = null; if (current != null) { if (current.id == id) return current; @@ -34,7 +34,8 @@ class FrameSwitcher extends GroupView implements IFrameSwitcher { } current = frames.get(id); addView(current); - if (content.stage != null) content.stage.focus = current.content; + //ToDo: + if (content.stage != null) content.stage.focus = cast(current, SpriteView).contentAsSprite; var onShowMethod:Dynamic = Reflect.field(current, "onShow"); if (onShowMethod != null) Reflect.callMethod(current, onShowMethod, []); if (animate != null) animate.cancel(); @@ -49,7 +50,7 @@ class FrameSwitcher extends GroupView implements IFrameSwitcher { return current; } - private function removePrev(prev:Null>):Void { + private function removePrev(prev:Null):Void { if (prev != null) { var onHideMethod:Dynamic = Reflect.field(prev, "onHide"); if (onHideMethod != null) Reflect.callMethod(prev, onHideMethod, []); @@ -57,7 +58,7 @@ class FrameSwitcher extends GroupView implements IFrameSwitcher { } } - override public function set_views(value:Array>):Array> { + override public function set_views(value:Array):Array { views = []; if (value.length > 0) { for (view in value) { diff --git a/haxework/gui/frame/IFrameSwitcher.hx b/haxework/gui/frame/IFrameSwitcher.hx index afe0304..d6612f6 100755 --- a/haxework/gui/frame/IFrameSwitcher.hx +++ b/haxework/gui/frame/IFrameSwitcher.hx @@ -2,7 +2,7 @@ package haxework.gui.frame; import haxework.gui.IView; -interface IFrameSwitcher extends IView { - public var current(default, null):Null>; - public function change(id:String):IView; +interface IFrameSwitcher extends IView { + public var current(default, null):Null; + public function change(id:String):IView; } \ No newline at end of file diff --git a/haxework/gui/layout/DefaultLayout.hx b/haxework/gui/layout/DefaultLayout.hx index e75c1d4..b06d42c 100755 --- a/haxework/gui/layout/DefaultLayout.hx +++ b/haxework/gui/layout/DefaultLayout.hx @@ -10,7 +10,7 @@ class DefaultLayout implements ILayout { } - public function place(group:IGroupView, views:Array>):Void { + public function place(group:IGroupView, views:Array):Void { for (view in views) { setViewWidth(group, view); setViewHeight(group, view); @@ -19,8 +19,8 @@ class DefaultLayout implements ILayout { } } - private function filterViews(group:IGroupView, views:Array>):Array> { - return Lambda.array(Lambda.filter(views, function(view:IView):Bool { + private function filterViews(group:IGroupView, views:Array):Array { + return Lambda.array(Lambda.filter(views, function(view:IView):Bool { return if (view.inLayout) { true; } else { @@ -33,7 +33,7 @@ class DefaultLayout implements ILayout { })); } - private function setViewWidth(group:IGroupView, view:IView):Void { + private function setViewWidth(group:IGroupView, view:IView):Void { if (view.widthType == SizeType.PERCENT) { view.w = view.pWidth / 100 * (group.width - view.leftMargin - view.rightMargin - group.leftPadding - group.rightPadding); } else if (group.contentSize && group.width < view.width) { @@ -41,7 +41,7 @@ class DefaultLayout implements ILayout { } } - private function setViewHeight(group:IGroupView, view:IView):Void { + private function setViewHeight(group:IGroupView, view:IView):Void { if (view.heightType == SizeType.PERCENT) { view.h = view.pHeight / 100 * (group.height - view.topMargin - view.bottomMargin - group.topPadding - group.bottomPadding); } else if (group.contentSize && group.height < view.height) { @@ -49,7 +49,7 @@ class DefaultLayout implements ILayout { } } - private function placeViewHorizontal(group:IGroupView, view:IView):Void { + private function placeViewHorizontal(group:IGroupView, view:IView):Void { var align:HAlign = view.hAlign; if (align == HAlign.NONE) align = group.layoutHAlign; switch (align) { @@ -63,7 +63,7 @@ class DefaultLayout implements ILayout { } } - private function placeViewVertical(group:IGroupView, view:IView):Void { + private function placeViewVertical(group:IGroupView, view:IView):Void { var align:VAlign = view.vAlign; if (align == VAlign.NONE) align = group.layoutVAlign; switch (align) { diff --git a/haxework/gui/layout/HorizontalLayout.hx b/haxework/gui/layout/HorizontalLayout.hx index 7eea315..ef9325c 100755 --- a/haxework/gui/layout/HorizontalLayout.hx +++ b/haxework/gui/layout/HorizontalLayout.hx @@ -10,7 +10,7 @@ class HorizontalLayout extends DefaultLayout { super(); } - override public function place(group:IGroupView, views:Array>):Void { + override public function place(group:IGroupView, views:Array):Void { views = filterViews(group, views); var fixedSize:Float = group.layoutMargin * (views.length - 1); diff --git a/haxework/gui/layout/ILayout.hx b/haxework/gui/layout/ILayout.hx index c056a0f..dbde671 100755 --- a/haxework/gui/layout/ILayout.hx +++ b/haxework/gui/layout/ILayout.hx @@ -1,5 +1,5 @@ package haxework.gui.layout; interface ILayout { - public function place(group:IGroupView, views:Array>):Void; + public function place(group:IGroupView, views:Array):Void; } \ No newline at end of file diff --git a/haxework/gui/layout/VerticalLayout.hx b/haxework/gui/layout/VerticalLayout.hx index 15a1af4..14af951 100755 --- a/haxework/gui/layout/VerticalLayout.hx +++ b/haxework/gui/layout/VerticalLayout.hx @@ -9,7 +9,7 @@ class VerticalLayout extends DefaultLayout { super(); } - override public function place(group:IGroupView, views:Array>):Void { + override public function place(group:IGroupView, views:Array):Void { views = filterViews(group, views); var fixedSize:Float = group.layoutMargin * (views.length - 1); diff --git a/haxework/gui/list/HListView.hx b/haxework/gui/list/HListView.hx index cbdb867..e37bb0d 100755 --- a/haxework/gui/list/HListView.hx +++ b/haxework/gui/list/HListView.hx @@ -11,20 +11,19 @@ class HListView extends ListView { public function new() { super(new HorizontalLayout(), new VerticalLayout()); - container.layoutHAlign = HAlign.LEFT; - container.layoutVAlign = VAlign.MIDDLE; + box.layoutHAlign = HAlign.LEFT; + box.layoutVAlign = VAlign.MIDDLE; } override private function recalcSize(item:IListItemView):Void { - var view:IView = item; - itemSize = view.width + view.leftMargin + view.rightMargin + container.layoutMargin; - size = Math.ceil(Math.max(0, container.width / itemSize)) + 2; - sizeDiff = size - ((container.width - container.layoutMargin - 1) / itemSize); + itemSize = item.width + item.leftMargin + item.rightMargin + box.layoutMargin; + size = Math.ceil(Math.max(0, box.width / itemSize)) + 2; + sizeDiff = size - ((box.width - box.layoutMargin - 1) / itemSize); } override private function set_offsetDiff(value:Float):Float { - container.leftPadding = -value * itemSize; - mask.leftMargin = -container.leftPadding; + box.leftPadding = -value * itemSize; + mask.leftMargin = -box.leftPadding; return super.set_offsetDiff(value); } diff --git a/haxework/gui/list/HScrollSkin.hx b/haxework/gui/list/HScrollSkin.hx index 49a2b9b..5e2a6ac 100755 --- a/haxework/gui/list/HScrollSkin.hx +++ b/haxework/gui/list/HScrollSkin.hx @@ -4,7 +4,7 @@ import haxework.gui.skin.ISkin; import flash.display.Sprite; import flash.display.Graphics; -class HScrollSkin implements ISkin { +class HScrollSkin implements ISkin { public var foreColor(default, default):Int; public var backColor(default, default):Int; @@ -15,7 +15,7 @@ class HScrollSkin implements ISkin { } public function draw(view:ScrollView):Void { - var graphics:Graphics = view.content.graphics; + var graphics:Graphics = view.contentAsSprite.graphics; graphics.clear(); graphics.beginFill(backColor); graphics.drawRect(0, 0, view.width, view.height); diff --git a/haxework/gui/list/ListView.hx b/haxework/gui/list/ListView.hx index abe1bc6..aeb817e 100755 --- a/haxework/gui/list/ListView.hx +++ b/haxework/gui/list/ListView.hx @@ -35,7 +35,7 @@ class ListView extends GroupView implements ScrollListener { public var selected(default, set):Array; private var main:GroupView; - private var container:GroupView; + private var box:GroupView; private var mask:SpriteView; private var itemSize:Float; @@ -50,17 +50,17 @@ class ListView extends GroupView implements ScrollListener { main.pWidth = 100; main.pHeight = 100; addView(main); - container = new GroupView(layout); - container.pWidth = 100; - container.pHeight = 100; - main.addView(container); + box = new GroupView(layout); + box.pWidth = 100; + box.pHeight = 100; + main.addView(box); mask = new SpriteView(); mask.pWidth = 100; mask.pHeight = 100; mask.inLayout = false; mask.skin = new ColorSkin(0xffffff); - container.content.mask = mask.content; - container.addView(mask); + box.content.mask = mask.content; + box.addView(mask); dispatcher = new Dispatcher>(); itemSize = 0; offset = 0; @@ -202,14 +202,14 @@ class ListView extends GroupView implements ScrollListener { var item:IListItemView = Type.createInstance(factory, []); items.push(item); setClickListener(item); - container.addView(item); + box.addView(item); } } else if (diff < 0) { for (i in 0...-diff) { var item:IListItemView = items.pop(); item.content.removeEventListener(MouseEvent.CLICK, itemsListeners.get(item)); itemsListeners.remove(item); - container.removeView(item); + box.removeView(item); } } } @@ -232,11 +232,11 @@ class ListView extends GroupView implements ScrollListener { } override private function set_layoutMargin(value:Float):Float { - return container.layoutMargin = value; + return box.layoutMargin = value; } } -interface IListItemView extends IView { +interface IListItemView extends IView { public var item_index(default, default):Int; public var data(default, set):D; } diff --git a/haxework/gui/list/ScrollView.hx b/haxework/gui/list/ScrollView.hx index b1fe752..e8487c2 100755 --- a/haxework/gui/list/ScrollView.hx +++ b/haxework/gui/list/ScrollView.hx @@ -17,7 +17,7 @@ class ScrollView extends SpriteView { public function new() { super(); - content.buttonMode = true; + contentAsSprite.buttonMode = true; position = 0; ratio = 1; dispatcher = new Dispatcher(); diff --git a/haxework/gui/list/VListView.hx b/haxework/gui/list/VListView.hx index 5419fad..6f960b2 100755 --- a/haxework/gui/list/VListView.hx +++ b/haxework/gui/list/VListView.hx @@ -11,20 +11,19 @@ class VListView extends ListView { public function new() { super(new VerticalLayout(), new HorizontalLayout()); - container.layoutHAlign = HAlign.CENTER; - container.layoutVAlign = VAlign.TOP; + box.layoutHAlign = HAlign.CENTER; + box.layoutVAlign = VAlign.TOP; } override private function recalcSize(item:IListItemView):Void { - var view:IView = item; - itemSize = view.height + view.topMargin + view.bottomMargin + container.layoutMargin; - size = Math.ceil(Math.max(0, container.height / itemSize)) + 2; - sizeDiff = size - ((container.height - container.layoutMargin - 1) / itemSize); + itemSize = item.height + item.topMargin + item.bottomMargin + box.layoutMargin; + size = Math.ceil(Math.max(0, box.height / itemSize)) + 2; + sizeDiff = size - ((box.height - box.layoutMargin - 1) / itemSize); } override private function set_offsetDiff(value:Float):Float { - container.topPadding = -value * itemSize; - mask.topMargin = -container.topPadding; + box.topPadding = -value * itemSize; + mask.topMargin = -box.topPadding; return super.set_offsetDiff(value); } diff --git a/haxework/gui/list/VScrollSkin.hx b/haxework/gui/list/VScrollSkin.hx index 904c70d..b41bf4b 100755 --- a/haxework/gui/list/VScrollSkin.hx +++ b/haxework/gui/list/VScrollSkin.hx @@ -4,7 +4,7 @@ import haxework.gui.skin.ISkin; import flash.display.Sprite; import flash.display.Graphics; -class VScrollSkin implements ISkin { +class VScrollSkin implements ISkin { public var foreColor(default, default):Int; public var backColor(default, default):Int; @@ -15,7 +15,7 @@ class VScrollSkin implements ISkin { } public function draw(view:ScrollView):Void { - var graphics:Graphics = view.content.graphics; + var graphics:Graphics = view.contentAsSprite.graphics; graphics.clear(); graphics.beginFill(backColor); graphics.drawRect(0, 0, view.width, view.height); diff --git a/haxework/gui/popup/PopupManager.hx b/haxework/gui/popup/PopupManager.hx old mode 100644 new mode 100755 index 2a4e795..bff027d --- a/haxework/gui/popup/PopupManager.hx +++ b/haxework/gui/popup/PopupManager.hx @@ -16,7 +16,7 @@ class PopupManager { } public function show(popup:PopupView):Void { - cast(Root.instance.view, IGroupView).addView(popup); + cast(Root.instance.view, IGroupView).addView(popup); if (showAnimateFactory != null) { Type.createInstance(showAnimateFactory, [popup]).start(null); } @@ -28,11 +28,11 @@ class PopupManager { popups.remove(popup); if (closeAnimateFactory != null) { Type.createInstance(closeAnimateFactory, [popup]).start(function(_) { - cast(Root.instance.view, IGroupView).removeView(popup); + cast(Root.instance.view, IGroupView).removeView(popup); popup.onClose(); }); } else { - cast(Root.instance.view, IGroupView).removeView(popup); + cast(Root.instance.view, IGroupView).removeView(popup); popup.onClose(); } } diff --git a/haxework/gui/popup/PopupView.hx b/haxework/gui/popup/PopupView.hx index 6ed42bd..d90c55e 100755 --- a/haxework/gui/popup/PopupView.hx +++ b/haxework/gui/popup/PopupView.hx @@ -11,7 +11,7 @@ import haxework.gui.ButtonView; import haxework.gui.skin.ColorSkin; import haxework.gui.GroupView; -class PopupView> extends GroupView { +class PopupView extends GroupView { private var buttonId:String; private var contentView:V; diff --git a/haxework/gui/skin/BitmapSkin.hx b/haxework/gui/skin/BitmapSkin.hx index 9e9dced..7b064fa 100755 --- a/haxework/gui/skin/BitmapSkin.hx +++ b/haxework/gui/skin/BitmapSkin.hx @@ -9,7 +9,7 @@ import haxework.gui.ButtonView.ButtonState; import flash.display.Graphics; import flash.display.Sprite; -class BitmapSkin implements ISkin implements ISize { +class BitmapSkin implements ISkin implements ISize { public var width(default, null):Float; public var height(default, null):Float; @@ -37,7 +37,7 @@ class BitmapSkin implements ISkin implements ISize { public function draw(view:SpriteView):Void { if (image == null) return; - DrawUtil.draw(view.content.graphics, image, new Rectangle(0, 0, view.width, view.height), fillType, color); + DrawUtil.draw(view.contentAsSprite.graphics, image, new Rectangle(0, 0, view.width, view.height), fillType, color); } } \ No newline at end of file diff --git a/haxework/gui/skin/ButtonBitmapSkin.hx b/haxework/gui/skin/ButtonBitmapSkin.hx index 2f6646d..2e60fd3 100755 --- a/haxework/gui/skin/ButtonBitmapSkin.hx +++ b/haxework/gui/skin/ButtonBitmapSkin.hx @@ -9,7 +9,7 @@ import haxework.gui.ButtonView.ButtonState; import flash.display.Graphics; import flash.display.Sprite; -class ButtonBitmapSkin implements ISkin implements ISize { +class ButtonBitmapSkin implements ISkin implements ISize { public var width(default, null):Float; public var height(default, null):Float; @@ -64,7 +64,7 @@ class ButtonBitmapSkin implements ISkin implements ISize { public function draw(view:ButtonView):Void { if (images == null) return; var image:BitmapData = view.disabled ? disableImage == null ? disable : disableImage : images.get(view.state); - DrawUtil.draw(view.content.graphics, image, new Rectangle(0, 0, view.width, view.height), fillType, color); + DrawUtil.draw(view.contentAsSprite.graphics, image, new Rectangle(0, 0, view.width, view.height), fillType, color); } } \ No newline at end of file diff --git a/haxework/gui/skin/ButtonColorSkin.hx b/haxework/gui/skin/ButtonColorSkin.hx index 580a18b..ec00cd9 100755 --- a/haxework/gui/skin/ButtonColorSkin.hx +++ b/haxework/gui/skin/ButtonColorSkin.hx @@ -5,7 +5,7 @@ import haxework.gui.ButtonView.ButtonState; import flash.display.Graphics; import flash.display.Sprite; -class ButtonColorSkin implements ISkin { +class ButtonColorSkin implements ISkin { public var color(default, set_color):Int; public var alpha(default, default):Float; @@ -28,7 +28,7 @@ class ButtonColorSkin implements ISkin { public function draw(view:ButtonView):Void { var color:Int = selectColor(view); - var graphics:Graphics = view.content.graphics; + var graphics:Graphics = view.contentAsSprite.graphics; graphics.clear(); graphics.beginFill(color, alpha); graphics.drawRect(0, 0, view.width, view.height); diff --git a/haxework/gui/skin/ColorSkin.hx b/haxework/gui/skin/ColorSkin.hx index 497f144..7379ca4 100755 --- a/haxework/gui/skin/ColorSkin.hx +++ b/haxework/gui/skin/ColorSkin.hx @@ -3,7 +3,7 @@ package haxework.gui.skin; import flash.display.Graphics; import flash.display.Sprite; -class ColorSkin implements ISkin> { +class ColorSkin implements ISkin { public var color(default, default):Int; public var alpha(default, default):Float; @@ -13,8 +13,8 @@ class ColorSkin implements ISkin> { this.alpha = alpha; } - public function draw(view:IView):Void { - var graphics:Graphics = view.content.graphics; + public function draw(view:SpriteView):Void { + var graphics:Graphics = view.contentAsSprite.graphics; graphics.clear(); graphics.beginFill(color, alpha); graphics.drawRect(0, 0, view.width, view.height); diff --git a/haxework/gui/skin/FakeSkin.hx b/haxework/gui/skin/FakeSkin.hx index d56b551..965fadb 100755 --- a/haxework/gui/skin/FakeSkin.hx +++ b/haxework/gui/skin/FakeSkin.hx @@ -3,11 +3,11 @@ package haxework.gui.skin; import flash.display.Graphics; import flash.display.Sprite; -class FakeSkin implements ISkin> { +class FakeSkin implements ISkin { public function new() {} - public function draw(view:IView):Void { + public function draw(view:IView):Void { /*var g:Graphics = view.content.graphics; g.clear(); g.lineStyle(1, 0x00ff00); diff --git a/haxework/gui/skin/ISkin.hx b/haxework/gui/skin/ISkin.hx index f61375d..32e4da0 100755 --- a/haxework/gui/skin/ISkin.hx +++ b/haxework/gui/skin/ISkin.hx @@ -2,6 +2,6 @@ package haxework.gui.skin; import haxework.gui.IView.Content; -interface ISkin> { +interface ISkin { public function draw(view:V):Void; } \ No newline at end of file diff --git a/haxework/gui/skin/ProgressSkin.hx b/haxework/gui/skin/ProgressSkin.hx index 20e0a26..e331867 100755 --- a/haxework/gui/skin/ProgressSkin.hx +++ b/haxework/gui/skin/ProgressSkin.hx @@ -4,7 +4,7 @@ import flash.display.Graphics; import flash.display.Sprite; import haxework.gui.skin.ISkin; -class ProgressSkin implements ISkin { +class ProgressSkin implements ISkin { public var foreColor:Int; public var backColor:Int; @@ -12,7 +12,7 @@ class ProgressSkin implements ISkin { public function new() {} public function draw(view:ProgressView):Void { - var graphics:Graphics = view.content.graphics; + var graphics:Graphics = view.contentAsSprite.graphics; graphics.clear(); graphics.beginFill(backColor); graphics.drawRect(0, 0, view.width, view.height);