fixe
This commit is contained in:
@@ -29,10 +29,12 @@ class ButtonView extends LabelView {
|
|||||||
content.buttonMode = true;
|
content.buttonMode = true;
|
||||||
content.mouseChildren = false;
|
content.mouseChildren = false;
|
||||||
content.addEventListener(MouseEvent.CLICK, onMouseClick);
|
content.addEventListener(MouseEvent.CLICK, onMouseClick);
|
||||||
|
#if !mobile
|
||||||
content.addEventListener(MouseEvent.MOUSE_OVER, onMouseOver);
|
content.addEventListener(MouseEvent.MOUSE_OVER, onMouseOver);
|
||||||
content.addEventListener(MouseEvent.MOUSE_OUT, onMouseOut);
|
content.addEventListener(MouseEvent.MOUSE_OUT, onMouseOut);
|
||||||
|
#end
|
||||||
content.addEventListener(MouseEvent.MOUSE_DOWN, onMouseDown);
|
content.addEventListener(MouseEvent.MOUSE_DOWN, onMouseDown);
|
||||||
//content.addEventListener(MouseEvent.MOUSE_UP, onMouseUp);
|
content.addEventListener(MouseEvent.MOUSE_UP, onMouseUp);
|
||||||
}
|
}
|
||||||
|
|
||||||
private function onMouseClick(event:MouseEvent):Void {
|
private function onMouseClick(event:MouseEvent):Void {
|
||||||
@@ -76,7 +78,11 @@ class ButtonView extends LabelView {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private function get_state():ButtonState {
|
private function get_state():ButtonState {
|
||||||
|
#if mobile
|
||||||
|
return downed ? ButtonState.DOWN : ButtonState.UP;
|
||||||
|
#else
|
||||||
return (downed && overed) ? ButtonState.DOWN : overed ? ButtonState.OVER : ButtonState.UP;
|
return (downed && overed) ? ButtonState.DOWN : overed ? ButtonState.OVER : ButtonState.UP;
|
||||||
|
#end
|
||||||
}
|
}
|
||||||
|
|
||||||
private function set_onPress(value:ButtonViewListener<Dynamic>):ButtonViewListener<Dynamic> {
|
private function set_onPress(value:ButtonViewListener<Dynamic>):ButtonViewListener<Dynamic> {
|
||||||
|
|||||||
@@ -28,6 +28,8 @@ interface IView<C:Content> {
|
|||||||
public var w(default, set):Float;
|
public var w(default, set):Float;
|
||||||
public var h(default, set):Float;
|
public var h(default, set):Float;
|
||||||
|
|
||||||
|
public var r(default, set):Float;
|
||||||
|
|
||||||
public var widthType(default, null):SizeType;
|
public var widthType(default, null):SizeType;
|
||||||
public var heightType(default, null):SizeType;
|
public var heightType(default, null):SizeType;
|
||||||
|
|
||||||
|
|||||||
@@ -38,6 +38,6 @@ class Root {
|
|||||||
var content:DisplayObject = view.content;
|
var content:DisplayObject = view.content;
|
||||||
view.width = content.stage.stageWidth;
|
view.width = content.stage.stageWidth;
|
||||||
view.height = content.stage.stageHeight;
|
view.height = content.stage.stageHeight;
|
||||||
//L.d("Screen", content.stage.stageWidth + "x" + content.stage.stageHeight);
|
L.d("Screen", content.stage.stageWidth + "x" + content.stage.stageHeight);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,6 +25,8 @@ class View<C:Content> implements IView<C> {
|
|||||||
public var w(default, set):Float;
|
public var w(default, set):Float;
|
||||||
public var h(default, set):Float;
|
public var h(default, set):Float;
|
||||||
|
|
||||||
|
public var r(default, set):Float;
|
||||||
|
|
||||||
public var widthType(default, null):SizeType;
|
public var widthType(default, null):SizeType;
|
||||||
public var heightType(default, null):SizeType;
|
public var heightType(default, null):SizeType;
|
||||||
|
|
||||||
@@ -117,6 +119,7 @@ class View<C:Content> implements IView<C> {
|
|||||||
private function set_w(value:Float):Float {
|
private function set_w(value:Float):Float {
|
||||||
if (w != value) {
|
if (w != value) {
|
||||||
w = value;
|
w = value;
|
||||||
|
if (!Math.isNaN(r)) h = w / r;
|
||||||
invalidate();
|
invalidate();
|
||||||
}
|
}
|
||||||
return w;
|
return w;
|
||||||
@@ -124,11 +127,21 @@ class View<C:Content> implements IView<C> {
|
|||||||
private function set_h(value:Float):Float {
|
private function set_h(value:Float):Float {
|
||||||
if (h != value) {
|
if (h != value) {
|
||||||
h = value;
|
h = value;
|
||||||
|
if (!Math.isNaN(r)) w = h * r;
|
||||||
invalidate();
|
invalidate();
|
||||||
}
|
}
|
||||||
return h;
|
return h;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function set_r(value:Float):Float {
|
||||||
|
if (r != value) {
|
||||||
|
r = value;
|
||||||
|
invalidate();
|
||||||
|
invalidateParent();
|
||||||
|
}
|
||||||
|
return r;
|
||||||
|
}
|
||||||
|
|
||||||
private function get_width():Float {
|
private function get_width():Float {
|
||||||
return w;
|
return w;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
package haxework.gui.core;
|
package haxework.gui.core;
|
||||||
|
|
||||||
enum HAlign {
|
@:fakeEnum(String) enum HAlign {
|
||||||
NONE;
|
NONE;
|
||||||
LEFT;
|
LEFT;
|
||||||
CENTER;
|
CENTER;
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
package haxework.gui.core;
|
package haxework.gui.core;
|
||||||
|
|
||||||
enum VAlign {
|
@:fakeEnum(String) enum VAlign {
|
||||||
NONE;
|
NONE;
|
||||||
TOP;
|
TOP;
|
||||||
MIDDLE;
|
MIDDLE;
|
||||||
|
|||||||
@@ -40,12 +40,11 @@ class HorizontalLayout extends DefaultLayout {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var x:Float;
|
var x:Float = 0;
|
||||||
switch (group.layoutHAlign) {
|
switch (group.layoutHAlign) {
|
||||||
case HAlign.LEFT: x = group.leftPadding;
|
case HAlign.LEFT: x = group.leftPadding;
|
||||||
case HAlign.CENTER: x = (group.width - fixedSize) / 2 + group.leftPadding - group.rightPadding;
|
case HAlign.CENTER: x = (group.width - fixedSize) / 2 + group.leftPadding - group.rightPadding;
|
||||||
case HAlign.RIGHT: x = group.width - fixedSize - group.rightPadding;
|
case HAlign.RIGHT: x = group.width - fixedSize - group.rightPadding;
|
||||||
case HAlign.NONE: x = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for (view in views) {
|
for (view in views) {
|
||||||
|
|||||||
@@ -39,12 +39,11 @@ class VerticalLayout extends DefaultLayout {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var y:Float;
|
var y:Float = 0;
|
||||||
switch (group.layoutVAlign) {
|
switch (group.layoutVAlign) {
|
||||||
case VAlign.TOP: y = group.topPadding;
|
case VAlign.TOP: y = group.topPadding;
|
||||||
case VAlign.MIDDLE: y = (group.height - fixedSize) / 2 + group.topPadding - group.bottomPadding;
|
case VAlign.MIDDLE: y = (group.height - fixedSize) / 2 + group.topPadding - group.bottomPadding;
|
||||||
case VAlign.BOTTOM: y = group.height - fixedSize - group.bottomPadding;
|
case VAlign.BOTTOM: y = group.height - fixedSize - group.bottomPadding;
|
||||||
case VAlign.NONE: y = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for (view in views) {
|
for (view in views) {
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ class ButtonColorSkin implements ISkin<Sprite, ButtonView> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function draw(view:ButtonView):Void {
|
public function draw(view:ButtonView):Void {
|
||||||
var color:Int = view.disabled ? disable : colors.get(view.state);
|
var color:Int = selectColor(view);
|
||||||
var graphics:Graphics = view.content.graphics;
|
var graphics:Graphics = view.content.graphics;
|
||||||
graphics.clear();
|
graphics.clear();
|
||||||
graphics.beginFill(color, alpha);
|
graphics.beginFill(color, alpha);
|
||||||
@@ -35,4 +35,7 @@ class ButtonColorSkin implements ISkin<Sprite, ButtonView> {
|
|||||||
graphics.endFill();
|
graphics.endFill();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function selectColor(view:ButtonView):Int {
|
||||||
|
return view.disabled ? disable : colors.get(view.state);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user