[view] big update
This commit is contained in:
@@ -5,6 +5,7 @@
|
|||||||
--macro haxework.parser.Parser.auto()
|
--macro haxework.parser.Parser.auto()
|
||||||
-debug
|
-debug
|
||||||
-D native_trace
|
-D native_trace
|
||||||
|
#-D dev_layout
|
||||||
-swf-version 10.1
|
-swf-version 10.1
|
||||||
-swf-header 800:600:30:000000
|
-swf-header 800:600:30:000000
|
||||||
|
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ views:
|
|||||||
- $type: haxework.view.ImageView
|
- $type: haxework.view.ImageView
|
||||||
geometry.padding: 10
|
geometry.padding: 10
|
||||||
image: $r:image:logo
|
image: $r:image:logo
|
||||||
|
stretch: true
|
||||||
- id: tabs
|
- id: tabs
|
||||||
$type: haxework.view.HGroupView
|
$type: haxework.view.HGroupView
|
||||||
layout.margin: 5
|
layout.margin: 5
|
||||||
@@ -61,7 +62,7 @@ views:
|
|||||||
skinId: button
|
skinId: button
|
||||||
text: Color
|
text: Color
|
||||||
+onPress: "$code:choiceColor()"
|
+onPress: "$code:choiceColor()"
|
||||||
# separator
|
# separator
|
||||||
- $type: haxework.view.SpriteView
|
- $type: haxework.view.SpriteView
|
||||||
geometry.size.stretch: true
|
geometry.size.stretch: true
|
||||||
- $type: haxework.view.ButtonView
|
- $type: haxework.view.ButtonView
|
||||||
|
|||||||
@@ -1,16 +1,16 @@
|
|||||||
package haxework;
|
package haxework;
|
||||||
|
|
||||||
import haxework.view.Root;
|
|
||||||
import haxework.view.IView;
|
|
||||||
import flash.Lib;
|
import flash.Lib;
|
||||||
import haxework.animate.Animate;
|
import haxework.animate.Animate;
|
||||||
import haxework.animate.FadeAnimate;
|
import haxework.animate.FadeAnimate;
|
||||||
import haxework.animate.UnFadeAnimate;
|
import haxework.animate.UnFadeAnimate;
|
||||||
import haxework.view.popup.PopupManager;
|
|
||||||
import haxework.net.manage.ILoaderManager;
|
import haxework.net.manage.ILoaderManager;
|
||||||
import haxework.net.manage.LoaderManager;
|
import haxework.net.manage.LoaderManager;
|
||||||
import haxework.resources.IResources;
|
import haxework.resources.IResources;
|
||||||
import haxework.resources.Resources;
|
import haxework.resources.Resources;
|
||||||
|
import haxework.view.IView;
|
||||||
|
import haxework.view.popup.PopupManager;
|
||||||
|
import haxework.view.Root;
|
||||||
|
|
||||||
class App {
|
class App {
|
||||||
|
|
||||||
@@ -23,8 +23,8 @@ class App {
|
|||||||
resources = new Resources();
|
resources = new Resources();
|
||||||
loaderManager = new LoaderManager();
|
loaderManager = new LoaderManager();
|
||||||
popupManager = new PopupManager();
|
popupManager = new PopupManager();
|
||||||
popupManager.showAnimateFactory = UnFadeAnimate;
|
popupManager.showAnimateFactory = function(v) return new UnFadeAnimate(v);
|
||||||
popupManager.closeAnimateFactory = FadeAnimate;
|
popupManager.closeAnimateFactory = function(v) return new FadeAnimate(v);
|
||||||
app = this;
|
app = this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,9 @@
|
|||||||
package haxework.animate;
|
package haxework.animate;
|
||||||
|
|
||||||
import flash.events.Event;
|
import flash.display.DisplayObject;
|
||||||
import flash.display.Stage;
|
import flash.display.Stage;
|
||||||
|
import flash.events.Event;
|
||||||
|
import haxework.view.IView;
|
||||||
|
|
||||||
class Animate implements IAnimate {
|
class Animate implements IAnimate {
|
||||||
public static var defaultDuraion = 300;
|
public static var defaultDuraion = 300;
|
||||||
@@ -22,14 +24,22 @@ class Animate implements IAnimate {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private var callback:Animate -> Void;
|
private var callback:Animate -> Void;
|
||||||
|
private var view:IView<Dynamic>;
|
||||||
private var duration:Int;
|
private var duration:Int;
|
||||||
private var startTime:Float;
|
private var startTime:Float;
|
||||||
private var progress:Float;
|
private var progress:Float;
|
||||||
|
|
||||||
public function new(duration:Int) {
|
private var object(get, null):DisplayObject;
|
||||||
|
|
||||||
|
public function new(view:IView<Dynamic>, duration:Int = -1) {
|
||||||
|
this.view = view;
|
||||||
this.duration = duration > -1 ? duration : defaultDuraion;
|
this.duration = duration > -1 ? duration : defaultDuraion;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private inline function get_object():DisplayObject {
|
||||||
|
return cast view.content;
|
||||||
|
}
|
||||||
|
|
||||||
public function start(callback:IAnimate -> Void, custom:Bool = false):Void {
|
public function start(callback:IAnimate -> Void, custom:Bool = false):Void {
|
||||||
startTime = Date.now().getTime();
|
startTime = Date.now().getTime();
|
||||||
this.callback = callback;
|
this.callback = callback;
|
||||||
|
|||||||
@@ -8,13 +8,12 @@ import haxework.view.IView;
|
|||||||
|
|
||||||
class CircleMaskAnimate extends Animate {
|
class CircleMaskAnimate extends Animate {
|
||||||
|
|
||||||
private var view:IView<DisplayObject>;
|
|
||||||
private var mask:Sprite;
|
private var mask:Sprite;
|
||||||
private var cyrcle:Sprite;
|
private var cyrcle:Sprite;
|
||||||
private var size:Float;
|
private var size:Float;
|
||||||
|
|
||||||
public function new(view:IView<DisplayObject>, duration:Int = -1) {
|
public function new(view:IView<DisplayObject>, duration:Int = -1) {
|
||||||
super(duration);
|
super(view, duration);
|
||||||
this.view = view;
|
this.view = view;
|
||||||
this.mask = new Sprite();
|
this.mask = new Sprite();
|
||||||
this.cyrcle = new Sprite();
|
this.cyrcle = new Sprite();
|
||||||
|
|||||||
@@ -1,29 +1,20 @@
|
|||||||
package haxework.animate;
|
package haxework.animate;
|
||||||
|
|
||||||
import flash.display.DisplayObject;
|
|
||||||
import haxework.animate.IAnimate;
|
|
||||||
import haxework.view.IView;
|
|
||||||
import haxework.animate.Animate;
|
import haxework.animate.Animate;
|
||||||
|
import haxework.animate.IAnimate;
|
||||||
|
|
||||||
class FadeAnimate extends Animate {
|
class FadeAnimate extends Animate {
|
||||||
|
|
||||||
private var view:IView<DisplayObject>;
|
|
||||||
|
|
||||||
public function new(view:IView<DisplayObject>, duration:Int = -1) {
|
|
||||||
super(duration);
|
|
||||||
this.view = view;
|
|
||||||
}
|
|
||||||
|
|
||||||
override public function start(callback:IAnimate -> Void, custom:Bool = false):Void {
|
override public function start(callback:IAnimate -> Void, custom:Bool = false):Void {
|
||||||
view.content.alpha = 1.0;
|
object.alpha = 1.0;
|
||||||
super.start(callback, custom);
|
super.start(callback, custom);
|
||||||
}
|
}
|
||||||
|
|
||||||
override private function update(time:Float):Void {
|
override private function update(time:Float):Void {
|
||||||
super.update(time);
|
super.update(time);
|
||||||
view.content.alpha = 1 - (progress * 1.0);
|
object.alpha = 1 - (progress * 1.0);
|
||||||
if (progress >= 1) {
|
if (progress >= 1) {
|
||||||
view.content.alpha = 0.0;
|
object.alpha = 0.0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,24 +1,14 @@
|
|||||||
package haxework.animate;
|
package haxework.animate;
|
||||||
|
|
||||||
import flash.display.DisplayObject;
|
|
||||||
import haxework.view.IView;
|
|
||||||
|
|
||||||
class SlideAnimate extends Animate {
|
class SlideAnimate extends Animate {
|
||||||
|
|
||||||
private var view:IView<DisplayObject>;
|
|
||||||
|
|
||||||
public function new(view:IView<DisplayObject>, duration:Int = -1) {
|
|
||||||
super(duration);
|
|
||||||
this.view = view;
|
|
||||||
}
|
|
||||||
|
|
||||||
override public function start(callback:IAnimate -> Void, custom:Bool = false):Void {
|
override public function start(callback:IAnimate -> Void, custom:Bool = false):Void {
|
||||||
view.content.x = view.x - this.view.width + this.view.width / progress;
|
object.x = view.x - this.view.width + this.view.width / progress;
|
||||||
super.start(callback, custom);
|
super.start(callback, custom);
|
||||||
}
|
}
|
||||||
|
|
||||||
override private function update(time:Float):Void {
|
override private function update(time:Float):Void {
|
||||||
super.update(time);
|
super.update(time);
|
||||||
view.content.x = view.x - this.view.width + this.view.width / Math.min(1, progress);
|
object.x = view.x - this.view.width + this.view.width / Math.min(1, progress);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,28 +1,19 @@
|
|||||||
package haxework.animate;
|
package haxework.animate;
|
||||||
|
|
||||||
import flash.display.DisplayObject;
|
|
||||||
import haxework.view.IView;
|
|
||||||
import haxework.animate.Animate;
|
import haxework.animate.Animate;
|
||||||
|
|
||||||
class UnFadeAnimate extends Animate {
|
class UnFadeAnimate extends Animate {
|
||||||
|
|
||||||
private var view:IView<DisplayObject>;
|
|
||||||
|
|
||||||
public function new(view:IView<DisplayObject>, duration:Int = -1) {
|
|
||||||
super(duration);
|
|
||||||
this.view = view;
|
|
||||||
}
|
|
||||||
|
|
||||||
override public function start(callback:IAnimate -> Void, custom:Bool = false):Void {
|
override public function start(callback:IAnimate -> Void, custom:Bool = false):Void {
|
||||||
view.content.alpha = 0.0;
|
object.alpha = 0.0;
|
||||||
super.start(callback, custom);
|
super.start(callback, custom);
|
||||||
}
|
}
|
||||||
|
|
||||||
override private function update(time:Float):Void {
|
override private function update(time:Float):Void {
|
||||||
super.update(time);
|
super.update(time);
|
||||||
view.content.alpha = progress * 1.0;
|
object.alpha = progress * 1.0;
|
||||||
if (progress >= 1) {
|
if (progress >= 1) {
|
||||||
view.content.alpha = 1.0;
|
object.alpha = 1.0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ enum ButtonState {
|
|||||||
UP;
|
UP;
|
||||||
OVER;
|
OVER;
|
||||||
DOWN;
|
DOWN;
|
||||||
|
DISABLED;
|
||||||
}
|
}
|
||||||
|
|
||||||
class ButtonView extends LabelView {
|
class ButtonView extends LabelView {
|
||||||
@@ -84,10 +85,11 @@ class ButtonView extends LabelView {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private function get_state():ButtonState {
|
private function get_state():ButtonState {
|
||||||
|
if (disabled) return DISABLED;
|
||||||
#if mobile
|
#if mobile
|
||||||
return downed ? ButtonState.DOWN : ButtonState.UP;
|
return downed ? DOWN : UP;
|
||||||
#else
|
#else
|
||||||
return (downed && overed) ? ButtonState.DOWN : overed ? ButtonState.OVER : ButtonState.UP;
|
return (downed && overed) ? DOWN : overed ? OVER : UP;
|
||||||
#end
|
#end
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ class ImageView extends SpriteView {
|
|||||||
public var imageUrl(default, set):String;
|
public var imageUrl(default, set):String;
|
||||||
public var color(default, set):Int = -1;
|
public var color(default, set):Int = -1;
|
||||||
public var fillType(default, set):FillType;
|
public var fillType(default, set):FillType;
|
||||||
|
public var stretch:Bool;
|
||||||
|
|
||||||
private var bitmapSkin:BitmapSkin = new BitmapSkin();
|
private var bitmapSkin:BitmapSkin = new BitmapSkin();
|
||||||
private var coloredImage:BitmapData;
|
private var coloredImage:BitmapData;
|
||||||
@@ -33,6 +34,9 @@ class ImageView extends SpriteView {
|
|||||||
|
|
||||||
private function set_image(value:BitmapData):BitmapData {
|
private function set_image(value:BitmapData):BitmapData {
|
||||||
if (image != value) {
|
if (image != value) {
|
||||||
|
if (stretch) {
|
||||||
|
setContentSize(value.width, value.height, "image");
|
||||||
|
}
|
||||||
image = value;
|
image = value;
|
||||||
if (color > -1) {
|
if (color > -1) {
|
||||||
coloredImage = BitmapUtil.colorize(image, color);
|
coloredImage = BitmapUtil.colorize(image, color);
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ class ScrollView extends HGroupView {
|
|||||||
|
|
||||||
public function new() {
|
public function new() {
|
||||||
super();
|
super();
|
||||||
|
layout.overflow = true;
|
||||||
skin = [Skin.color(0x000000, 0.0)];
|
skin = [Skin.color(0x000000, 0.0)];
|
||||||
mask = new Sprite();
|
mask = new Sprite();
|
||||||
content.addChild(mask);
|
content.addChild(mask);
|
||||||
|
|||||||
@@ -3,8 +3,7 @@ package haxework.view;
|
|||||||
import flash.display.DisplayObject;
|
import flash.display.DisplayObject;
|
||||||
import flash.display.InteractiveObject;
|
import flash.display.InteractiveObject;
|
||||||
import haxework.view.core.Geometry;
|
import haxework.view.core.Geometry;
|
||||||
import haxework.view.skin.ISkin.ISizeSkin;
|
import haxework.view.skin.ISkin;
|
||||||
import haxework.view.skin.ISkin.SkinSet;
|
|
||||||
import haxework.resources.IResources;
|
import haxework.resources.IResources;
|
||||||
|
|
||||||
class View<C:DisplayObject> implements IView<C> {
|
class View<C:DisplayObject> implements IView<C> {
|
||||||
@@ -61,20 +60,10 @@ class View<C:DisplayObject> implements IView<C> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function update():Void {
|
public function update():Void {
|
||||||
/*for (skin in this.skin) {
|
|
||||||
if (Std.is(skin, ISizeSkin)) {
|
|
||||||
var sizeSkin:ISizeSkin = cast skin;
|
|
||||||
setContentSize(sizeSkin.width, sizeSkin.height, "skin");
|
|
||||||
}
|
|
||||||
}*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function redraw():Void {
|
public function redraw():Void {
|
||||||
for (skin in this.skin) {
|
for (skin in this.skin) {
|
||||||
if (Std.is(skin, ISizeSkin)) {
|
|
||||||
var sizeSkin:ISizeSkin = cast skin;
|
|
||||||
setContentSize(sizeSkin.width, sizeSkin.height, "skin");
|
|
||||||
}
|
|
||||||
skin.draw(this);
|
skin.draw(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -86,6 +86,9 @@ class Geometry {
|
|||||||
public var width(get, never):SizeValue;
|
public var width(get, never):SizeValue;
|
||||||
public var height(get, never):SizeValue;
|
public var height(get, never):SizeValue;
|
||||||
|
|
||||||
|
public var minWidth(get, never):Float;
|
||||||
|
public var minHeight(get, never):Float;
|
||||||
|
|
||||||
public function new() {
|
public function new() {
|
||||||
this.padding = [];
|
this.padding = [];
|
||||||
this.margin = [];
|
this.margin = [];
|
||||||
@@ -95,32 +98,36 @@ class Geometry {
|
|||||||
this.position = Position.LAYOUT;
|
this.position = Position.LAYOUT;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function get_minWidth():Float {
|
||||||
|
var result = size.fixed.width;
|
||||||
|
for (s in size.content.iterator()) {
|
||||||
|
result = Math.max(result, s.width);
|
||||||
|
}
|
||||||
|
result += padding.horizontal;
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function get_minHeight():Float {
|
||||||
|
var result = size.fixed.height;
|
||||||
|
for (s in size.content.iterator()) {
|
||||||
|
result = Math.max(result, s.height);
|
||||||
|
}
|
||||||
|
result += padding.vertical;
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
public function get_width():SizeValue {
|
public function get_width():SizeValue {
|
||||||
if (size.percent.width > -1) {
|
if (size.percent.width > -1) {
|
||||||
return PERCENT(size.percent.width);
|
return PERCENT(size.percent.width);
|
||||||
}
|
}
|
||||||
var result = size.fixed.width;
|
return FIXED(minWidth);
|
||||||
if (result < 0) {
|
|
||||||
for (s in size.content.iterator()) {
|
|
||||||
result = Math.max(result, s.width);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
result += padding.horizontal;
|
|
||||||
return FIXED(result);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function get_height():SizeValue {
|
public function get_height():SizeValue {
|
||||||
if (size.percent.height > -1) {
|
if (size.percent.height > -1) {
|
||||||
return PERCENT(size.percent.height);
|
return PERCENT(size.percent.height);
|
||||||
}
|
}
|
||||||
var result = size.fixed.height;
|
return FIXED(minHeight);
|
||||||
if (result < 0) {
|
|
||||||
for (s in size.content.iterator()) {
|
|
||||||
result = Math.max(result, s.height);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
result += padding.vertical;
|
|
||||||
return FIXED(result);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setMargin(margin:Box):Geometry {
|
public function setMargin(margin:Box):Geometry {
|
||||||
|
|||||||
@@ -31,20 +31,22 @@ class DefaultLayout extends Layout {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private function setViewWidth(group:IGroupView, view:IView<Dynamic>):Void {
|
private function setViewWidth(group:IGroupView, view:IView<Dynamic>):Void {
|
||||||
switch (view.geometry.width) {
|
view.width = switch view.geometry.width {
|
||||||
case FIXED(value):
|
case FIXED(value):
|
||||||
view.width = value;
|
value;
|
||||||
case PERCENT(value):
|
case PERCENT(value):
|
||||||
view.width = value / 100 * (group.width - view.geometry.margin.horizontal - group.geometry.padding.horizontal);
|
var calcWidth = value / 100 * (group.width - view.geometry.margin.horizontal - group.geometry.padding.horizontal);
|
||||||
|
Math.max(view.geometry.minWidth, calcWidth);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private function setViewHeight(group:IGroupView, view:IView<Dynamic>):Void {
|
private function setViewHeight(group:IGroupView, view:IView<Dynamic>):Void {
|
||||||
switch (view.geometry.height) {
|
view.height = switch view.geometry.height {
|
||||||
case FIXED(value):
|
case FIXED(value):
|
||||||
view.height = value;
|
value;
|
||||||
case PERCENT(value):
|
case PERCENT(value):
|
||||||
view.height = value / 100 * (group.height - view.geometry.margin.vertical - group.geometry.padding.vertical);
|
var calcHeigth = value / 100 * (group.height - view.geometry.margin.vertical - group.geometry.padding.vertical);
|
||||||
|
Math.max(view.geometry.minHeight, calcHeigth);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -26,10 +26,11 @@ class HorizontalLayout extends DefaultLayout {
|
|||||||
case FIXED(value):
|
case FIXED(value):
|
||||||
maxSize = Math.max(maxSize, value);
|
maxSize = Math.max(maxSize, value);
|
||||||
case _:
|
case _:
|
||||||
|
maxSize = Math.max(maxSize, view.geometry.minHeight);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
group.setContentSize(fixedSize, maxSize, "group");
|
if (!overflow) group.setContentSize(fixedSize, maxSize, "group");
|
||||||
|
|
||||||
leftSize -= fixedSize;
|
leftSize -= fixedSize;
|
||||||
for (view in views) {
|
for (view in views) {
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ interface ILayout {
|
|||||||
public var hAlign(default, default):HAlign;
|
public var hAlign(default, default):HAlign;
|
||||||
public var vAlign(default, default):VAlign;
|
public var vAlign(default, default):VAlign;
|
||||||
public var margin(default, default):Float;
|
public var margin(default, default):Float;
|
||||||
|
public var overflow(default, default):Bool;
|
||||||
|
|
||||||
public function place(group:IGroupView, views:Array<IView<Dynamic>>):Void;
|
public function place(group:IGroupView, views:Array<IView<Dynamic>>):Void;
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
package haxework.view.layout;
|
package haxework.view.layout;
|
||||||
|
|
||||||
import haxework.view.core.VAlign;
|
import haxework.view.core.VAlign;
|
||||||
import haxework.view.core.HAlign;
|
import haxework.view.core.HAlign;
|
||||||
|
|
||||||
@@ -7,6 +8,7 @@ class Layout implements ILayout {
|
|||||||
public var hAlign(default, default):HAlign;
|
public var hAlign(default, default):HAlign;
|
||||||
public var vAlign(default, default):VAlign;
|
public var vAlign(default, default):VAlign;
|
||||||
public var margin(default, default):Float;
|
public var margin(default, default):Float;
|
||||||
|
public var overflow(default, default):Bool;
|
||||||
|
|
||||||
public function new() {
|
public function new() {
|
||||||
hAlign = NONE;
|
hAlign = NONE;
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package haxework.view.layout;
|
package haxework.view.layout;
|
||||||
|
|
||||||
import haxework.view.core.VAlign;
|
import haxework.view.core.VAlign;
|
||||||
|
|
||||||
typedef Row = {
|
typedef Row = {
|
||||||
var width:Float;
|
var width:Float;
|
||||||
var height:Float;
|
var height:Float;
|
||||||
@@ -34,7 +35,7 @@ class TailLayout extends DefaultLayout {
|
|||||||
setViewHeight(group, view);
|
setViewHeight(group, view);
|
||||||
if (
|
if (
|
||||||
(rowSize > 0 && row.views.length >= rowSize) ||
|
(rowSize > 0 && row.views.length >= rowSize) ||
|
||||||
(rowSize == 0 && row.width + view.width + margin + group.geometry.margin.horizontal > group.width)
|
(/*rowSize == 0 && */row.width + view.width + margin + group.geometry.margin.horizontal > group.width)
|
||||||
) {
|
) {
|
||||||
row.width -= margin;
|
row.width -= margin;
|
||||||
w = Math.max(w, row.width);
|
w = Math.max(w, row.width);
|
||||||
|
|||||||
@@ -26,10 +26,11 @@ class VerticalLayout extends DefaultLayout {
|
|||||||
case FIXED(value):
|
case FIXED(value):
|
||||||
maxSize = Math.max(maxSize, value);
|
maxSize = Math.max(maxSize, value);
|
||||||
case _:
|
case _:
|
||||||
|
maxSize = Math.max(maxSize, view.geometry.minWidth);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
group.setContentSize(maxSize, fixedSize, "group");
|
if (!overflow) group.setContentSize(maxSize, fixedSize, "group");
|
||||||
|
|
||||||
leftSize -= fixedSize;
|
leftSize -= fixedSize;
|
||||||
for (view in views) {
|
for (view in views) {
|
||||||
|
|||||||
@@ -48,6 +48,7 @@ class ListView<D> extends GroupView {
|
|||||||
addView(main);
|
addView(main);
|
||||||
box = new GroupView(layout);
|
box = new GroupView(layout);
|
||||||
box.geometry.size.stretch = true;
|
box.geometry.size.stretch = true;
|
||||||
|
box.layout.overflow = true;
|
||||||
main.addView(box);
|
main.addView(box);
|
||||||
mask = new SpriteView();
|
mask = new SpriteView();
|
||||||
mask.geometry.size.stretch = true;
|
mask.geometry.size.stretch = true;
|
||||||
|
|||||||
@@ -8,8 +8,8 @@ typedef P = PopupView<Dynamic>;
|
|||||||
|
|
||||||
class PopupManager {
|
class PopupManager {
|
||||||
|
|
||||||
public var showAnimateFactory(default, default):Class<IAnimate>;
|
public var showAnimateFactory(default, default):IView<Dynamic> -> IAnimate;
|
||||||
public var closeAnimateFactory(default, default):Class<IAnimate>;
|
public var closeAnimateFactory(default, default):IView<Dynamic> -> IAnimate;
|
||||||
|
|
||||||
private var popups:Array<P>;
|
private var popups:Array<P>;
|
||||||
|
|
||||||
@@ -20,7 +20,7 @@ class PopupManager {
|
|||||||
public function show(popup:P):Void {
|
public function show(popup:P):Void {
|
||||||
cast(Root.instance.view, IGroupView).addView(popup);
|
cast(Root.instance.view, IGroupView).addView(popup);
|
||||||
if (showAnimateFactory != null) {
|
if (showAnimateFactory != null) {
|
||||||
Type.createInstance(showAnimateFactory, [popup]).start(null);
|
showAnimateFactory(popup).start(null);
|
||||||
}
|
}
|
||||||
popups.push(popup);
|
popups.push(popup);
|
||||||
}
|
}
|
||||||
@@ -28,7 +28,7 @@ class PopupManager {
|
|||||||
public function close(popup:P):Void {
|
public function close(popup:P):Void {
|
||||||
popups.remove(popup);
|
popups.remove(popup);
|
||||||
if (closeAnimateFactory != null) {
|
if (closeAnimateFactory != null) {
|
||||||
Type.createInstance(closeAnimateFactory, [popup]).start(function(_) {
|
closeAnimateFactory(popup).start(function(_) {
|
||||||
cast(Root.instance.view, IGroupView).removeView(popup);
|
cast(Root.instance.view, IGroupView).removeView(popup);
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
package haxework.view.popup;
|
package haxework.view.popup;
|
||||||
|
|
||||||
|
import flash.display.DisplayObject;
|
||||||
|
import flash.events.MouseEvent;
|
||||||
import haxework.view.core.Geometry.Position;
|
import haxework.view.core.Geometry.Position;
|
||||||
import haxework.view.GroupView;
|
import haxework.view.GroupView;
|
||||||
import haxework.view.skin.Skin;
|
import haxework.view.skin.Skin;
|
||||||
@@ -9,6 +11,7 @@ import promhx.Promise;
|
|||||||
class PopupView<R> extends GroupView {
|
class PopupView<R> extends GroupView {
|
||||||
@:provide var manager:PopupManager;
|
@:provide var manager:PopupManager;
|
||||||
|
|
||||||
|
public var background(default, null):IView<Dynamic>;
|
||||||
public var view(default, set):IView<Dynamic>;
|
public var view(default, set):IView<Dynamic>;
|
||||||
private var deferred:Deferred<R>;
|
private var deferred:Deferred<R>;
|
||||||
|
|
||||||
@@ -16,12 +19,29 @@ class PopupView<R> extends GroupView {
|
|||||||
super();
|
super();
|
||||||
geometry.size.stretch = true;
|
geometry.size.stretch = true;
|
||||||
geometry.position = Position.ABSOLUTE;
|
geometry.position = Position.ABSOLUTE;
|
||||||
skin = [Skin.color(0x000000, 0.6)];
|
background = buildBackground();
|
||||||
|
background.content.addEventListener(MouseEvent.CLICK, onBackgroundClick);
|
||||||
|
addView(background);
|
||||||
|
}
|
||||||
|
|
||||||
|
private function buildBackground():IView<Dynamic> {
|
||||||
|
var result = new SpriteView();
|
||||||
|
result.geometry.size.stretch = true;
|
||||||
|
result.geometry.position = Position.ABSOLUTE;
|
||||||
|
result.skin = [Skin.color(0x000000, 0.6)];
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
private function onBackgroundClick(event:MouseEvent):Void {
|
||||||
|
reject("background");
|
||||||
}
|
}
|
||||||
|
|
||||||
private function set_view(value:IView<Dynamic>):IView<Dynamic> {
|
private function set_view(value:IView<Dynamic>):IView<Dynamic> {
|
||||||
this.view = value;
|
if (view != null) {
|
||||||
this.views = [value];
|
removeView(view);
|
||||||
|
}
|
||||||
|
view = value;
|
||||||
|
addView(view);
|
||||||
return this.view;
|
return this.view;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,17 +2,15 @@ package haxework.view.skin;
|
|||||||
|
|
||||||
import flash.display.BitmapData;
|
import flash.display.BitmapData;
|
||||||
import flash.geom.Rectangle;
|
import flash.geom.Rectangle;
|
||||||
import haxework.view.skin.ISkin.ISizeSkin;
|
|
||||||
import haxework.view.utils.DrawUtil;
|
import haxework.view.utils.DrawUtil;
|
||||||
|
|
||||||
class BitmapSkin implements ISkin<SpriteView> implements ISizeSkin {
|
class BitmapSkin implements ISkin<SpriteView> {
|
||||||
public var width(default, null):Float;
|
|
||||||
public var height(default, null):Float;
|
|
||||||
|
|
||||||
public var image(null, set):BitmapData;
|
public var image(null, set):BitmapData;
|
||||||
public var color(default, default):Int;
|
public var color(default, default):Int;
|
||||||
public var fillType(default, default):FillType;
|
public var fillType(default, default):FillType;
|
||||||
|
|
||||||
|
public var content:Bool;
|
||||||
|
|
||||||
public function new(image:BitmapData = null, fillType = null, color = -1) {
|
public function new(image:BitmapData = null, fillType = null, color = -1) {
|
||||||
if (image != null) {
|
if (image != null) {
|
||||||
this.image = image;
|
this.image = image;
|
||||||
@@ -24,8 +22,6 @@ class BitmapSkin implements ISkin<SpriteView> implements ISizeSkin {
|
|||||||
private function set_image(value:BitmapData):BitmapData {
|
private function set_image(value:BitmapData):BitmapData {
|
||||||
if (image != value) {
|
if (image != value) {
|
||||||
image = value;
|
image = value;
|
||||||
width = image.width;
|
|
||||||
height = image.height;
|
|
||||||
}
|
}
|
||||||
return image;
|
return image;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,14 +3,10 @@ package haxework.view.skin;
|
|||||||
import flash.display.BitmapData;
|
import flash.display.BitmapData;
|
||||||
import flash.geom.Rectangle;
|
import flash.geom.Rectangle;
|
||||||
import haxework.view.ButtonView.ButtonState;
|
import haxework.view.ButtonView.ButtonState;
|
||||||
import haxework.view.skin.ISkin.ISizeSkin;
|
|
||||||
import haxework.view.utils.BitmapUtil;
|
import haxework.view.utils.BitmapUtil;
|
||||||
import haxework.view.utils.DrawUtil;
|
import haxework.view.utils.DrawUtil;
|
||||||
|
|
||||||
class ButtonBitmapSkin implements ISkin<ButtonView> implements ISizeSkin {
|
class ButtonBitmapSkin implements ISkin<ButtonView> {
|
||||||
|
|
||||||
public var width(default, null):Float;
|
|
||||||
public var height(default, null):Float;
|
|
||||||
|
|
||||||
public var fillType(default, default):FillType;
|
public var fillType(default, default):FillType;
|
||||||
public var color(default, default):Int;
|
public var color(default, default):Int;
|
||||||
@@ -33,8 +29,6 @@ class ButtonBitmapSkin implements ISkin<ButtonView> implements ISizeSkin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private function set_image(value:BitmapData):BitmapData {
|
private function set_image(value:BitmapData):BitmapData {
|
||||||
width = value.width;
|
|
||||||
height = value.height;
|
|
||||||
images.set(ButtonState.UP, value);
|
images.set(ButtonState.UP, value);
|
||||||
images.set(ButtonState.DOWN, BitmapUtil.multiply(value, 0.8));
|
images.set(ButtonState.DOWN, BitmapUtil.multiply(value, 0.8));
|
||||||
images.set(ButtonState.OVER, BitmapUtil.multiply(value, 1.2));
|
images.set(ButtonState.OVER, BitmapUtil.multiply(value, 1.2));
|
||||||
@@ -43,8 +37,6 @@ class ButtonBitmapSkin implements ISkin<ButtonView> implements ISizeSkin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private function set_upImage(value:BitmapData):BitmapData {
|
private function set_upImage(value:BitmapData):BitmapData {
|
||||||
width = value.width;
|
|
||||||
height = value.height;
|
|
||||||
images.set(ButtonState.UP, value);
|
images.set(ButtonState.UP, value);
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,17 +1,16 @@
|
|||||||
package haxework.view.skin;
|
package haxework.view.skin;
|
||||||
|
|
||||||
import flash.display.LineScaleMode;
|
|
||||||
import flash.display.JointStyle;
|
|
||||||
import flash.display.CapsStyle;
|
import flash.display.CapsStyle;
|
||||||
import flash.display.Graphics;
|
import flash.display.Graphics;
|
||||||
|
import flash.display.JointStyle;
|
||||||
|
import flash.display.LineScaleMode;
|
||||||
import haxework.color.ColorUtil;
|
import haxework.color.ColorUtil;
|
||||||
import haxework.view.ButtonView.ButtonState;
|
import haxework.view.ButtonView;
|
||||||
|
|
||||||
class ButtonColorSkin implements ISkin<ButtonView> {
|
class ButtonColorSkin implements ISkin<ButtonView> {
|
||||||
|
|
||||||
public var color(default, set):Int;
|
public var color(default, set):Int;
|
||||||
public var alpha(default, default):Float;
|
public var alpha(default, default):Float;
|
||||||
public var disable(default, default):Int;
|
|
||||||
public var round(default, default):Float;
|
public var round(default, default):Float;
|
||||||
private var colors:Map<ButtonState, Int>;
|
private var colors:Map<ButtonState, Int>;
|
||||||
|
|
||||||
@@ -23,15 +22,16 @@ class ButtonColorSkin implements ISkin<ButtonView> {
|
|||||||
|
|
||||||
private function set_color(value:Int):Int {
|
private function set_color(value:Int):Int {
|
||||||
colors = new Map<ButtonState, Int>();
|
colors = new Map<ButtonState, Int>();
|
||||||
colors.set(ButtonState.UP, value);
|
colors.set(UP, value);
|
||||||
colors.set(ButtonState.DOWN, ColorUtil.diff(value, -24));
|
colors.set(DOWN, ColorUtil.diff(value, -24));
|
||||||
colors.set(ButtonState.OVER, ColorUtil.diff(value, 24));
|
colors.set(OVER, ColorUtil.diff(value, 24));
|
||||||
//disable = ColorUtil.multiply(value, 0.6);
|
colors.set(OVER, ColorUtil.diff(value, 24));
|
||||||
|
colors.set(DISABLED, ColorUtil.multiply(value, 0.6));
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function draw(view:ButtonView):Void {
|
public function draw(view:ButtonView):Void {
|
||||||
var color:Int = selectColor(view);
|
var color:Int = colors.get(view.state);
|
||||||
if (Std.is(view, ToggleButtonView)) {
|
if (Std.is(view, ToggleButtonView)) {
|
||||||
if (!cast(view, ToggleButtonView).on) {
|
if (!cast(view, ToggleButtonView).on) {
|
||||||
color = ColorUtil.multiply(color, 0.5);
|
color = ColorUtil.multiply(color, 0.5);
|
||||||
@@ -44,8 +44,4 @@ class ButtonColorSkin implements ISkin<ButtonView> {
|
|||||||
graphics.lineStyle();
|
graphics.lineStyle();
|
||||||
graphics.endFill();
|
graphics.endFill();
|
||||||
}
|
}
|
||||||
|
|
||||||
private function selectColor(view:ButtonView):Int {
|
|
||||||
return view.disabled ? disable : colors.get(view.state);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,9 +4,4 @@ interface ISkin<V:IView<Dynamic>> {
|
|||||||
public function draw(view: V): Void;
|
public function draw(view: V): Void;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface ISizeSkin {
|
|
||||||
public var width(default, null):Float;
|
|
||||||
public var height(default, null):Float;
|
|
||||||
}
|
|
||||||
|
|
||||||
typedef SkinSet = Array<ISkin<Dynamic>>;
|
typedef SkinSet = Array<ISkin<Dynamic>>;
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import haxework.color.ColorUtil;
|
|||||||
class TabColorSkin extends ButtonColorSkin {
|
class TabColorSkin extends ButtonColorSkin {
|
||||||
|
|
||||||
override public function draw(view:ButtonView):Void {
|
override public function draw(view:ButtonView):Void {
|
||||||
var color:Int = selectColor(view);
|
var color:Int = colors.get(view.state);
|
||||||
if (Std.is(view, ToggleButtonView)) {
|
if (Std.is(view, ToggleButtonView)) {
|
||||||
if (!cast(view, ToggleButtonView).on) {
|
if (!cast(view, ToggleButtonView).on) {
|
||||||
color = ColorUtil.multiply(color, 0.5);
|
color = ColorUtil.multiply(color, 0.5);
|
||||||
|
|||||||
Reference in New Issue
Block a user