[view] GroupView: add maskEnable; Color: fromString improve
This commit is contained in:
@@ -44,7 +44,25 @@ abstract Color(Int) {
|
||||
}
|
||||
|
||||
@:from static public inline function fromString(value:String):Color {
|
||||
return new Color(Std.parseInt('0x${value.split('#').pop()}'));
|
||||
return new Color(switch value {
|
||||
case "white": 0xFFFFFF;
|
||||
case "silver": 0xC0C0C0;
|
||||
case "gray": 0x808080;
|
||||
case "black": 0x000000;
|
||||
case "red": 0xFF0000;
|
||||
case "maroon": 0x800000;
|
||||
case "yellow": 0xFFFF00;
|
||||
case "olive": 0x808000;
|
||||
case "lime": 0x00FF00;
|
||||
case "green": 0x008000;
|
||||
case "aqua": 0x00FFFF;
|
||||
case "teal": 0x008080;
|
||||
case "blue": 0x0000FF;
|
||||
case "navy": 0x000080;
|
||||
case "fuchsia": 0xFF00FF;
|
||||
case "purple": 0x800080;
|
||||
case x: Std.parseInt('0x${x.split('#').pop()}');
|
||||
});
|
||||
}
|
||||
|
||||
@:to public inline function toString():String {
|
||||
|
||||
@@ -79,6 +79,7 @@ class OverflowControl {
|
||||
private var _mask:Sprite;
|
||||
private var scrollX(get, null):HScrollBarView;
|
||||
private var scrollY(get, null):VScrollBarView;
|
||||
private var maskEnable(default, set):Bool;
|
||||
|
||||
public var overflowControlX(default, null):OverflowControl;
|
||||
public var overflowControlY(default, null):OverflowControl;
|
||||
@@ -88,8 +89,6 @@ class OverflowControl {
|
||||
container = new Sprite();
|
||||
content.addChild(container);
|
||||
_mask = new Sprite();
|
||||
content.addChild(_mask);
|
||||
container.mask = _mask;
|
||||
this.layout = layout != null ? layout : new DefaultLayout();
|
||||
this.overflow = overflow != null ? overflow : new Overflow();
|
||||
views = [];
|
||||
@@ -101,6 +100,21 @@ class OverflowControl {
|
||||
content.addEventListener(TouchEvent.TOUCH_BEGIN, onTouchBegin);
|
||||
}
|
||||
|
||||
private function set_maskEnable(value:Bool):Bool {
|
||||
if (maskEnable != value) {
|
||||
maskEnable = value;
|
||||
if (maskEnable) {
|
||||
content.addChild(_mask);
|
||||
container.mask = _mask;
|
||||
} else {
|
||||
content.removeChild(_mask);
|
||||
container.mask = null;
|
||||
}
|
||||
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
private function onMouseWheelEvent(event:MouseEvent):Void {
|
||||
if (overflowY > 1) {
|
||||
#if flash event.preventDefault(); #end
|
||||
@@ -157,10 +171,12 @@ class OverflowControl {
|
||||
}
|
||||
|
||||
public function set_overflowX(value:Float):Float {
|
||||
maskEnable = value > 1;
|
||||
return overflowX = overflowControlX.overflow = value;
|
||||
}
|
||||
|
||||
public function set_overflowY(value:Float):Float {
|
||||
maskEnable = value > 1;
|
||||
return overflowY = overflowControlY.overflow = value;
|
||||
}
|
||||
|
||||
@@ -177,7 +193,9 @@ class OverflowControl {
|
||||
overflowControlY.size = height;
|
||||
_mask.graphics.clear();
|
||||
_mask.graphics.beginFill(0, 1);
|
||||
_mask.graphics.drawRect(0, 0, width, height);
|
||||
if (!Math.isNaN(width) && !Math.isNaN(height) && width > 0 && height > 0) {
|
||||
_mask.graphics.drawRect(0, 0, width, height);
|
||||
}
|
||||
_mask.graphics.endFill();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user