abstract enums

This commit is contained in:
2015-05-12 17:15:09 +03:00
parent 256c3e0457
commit 6ca134c3ee
5 changed files with 20 additions and 19 deletions

View File

@@ -1,8 +1,8 @@
package haxework.gui.core; package haxework.gui.core;
@:fakeEnum(String) enum HAlign { @:enum abstract HAlign(String) {
NONE; var NONE = "NONE";
LEFT; var LEFT = "LEFT";
CENTER; var CENTER = "CENTER";
RIGHT; var RIGHT = "RIGHT";
} }

View File

@@ -1,8 +1,8 @@
package haxework.gui.core; package haxework.gui.core;
@:fakeEnum(String) enum VAlign { @:enum abstract VAlign(String) {
NONE; var NONE = "NONE";
TOP; var TOP = "TOP";
MIDDLE; var MIDDLE = "MIDDLE";
BOTTOM; var BOTTOM = "BOTTOM";
} }

View File

@@ -45,6 +45,7 @@ class HorizontalLayout extends DefaultLayout {
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 _:
} }
for (view in views) { for (view in views) {

View File

@@ -44,6 +44,7 @@ class VerticalLayout extends DefaultLayout {
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 _:
} }
for (view in views) { for (view in views) {

View File

@@ -8,14 +8,14 @@ import flash.geom.Rectangle;
import flash.display.BitmapData; import flash.display.BitmapData;
import flash.display.Graphics; import flash.display.Graphics;
@:fakeEnum(String) enum FillType { @:enum abstract FillType(String) {
NONE; var NONE = "NONE";
DEFAULT; var DEFAULT = "DEFAULT";
COVER; var COVER = "COVER";
CONTAIN; var CONTAIN = "CONTAIN";
REPEAT; var REPEAT = "REPEAT";
STRETCH; var STRETCH = "STRETCH";
NINEPATH; var NINEPATH = "NINEPATH";
} }
class DrawUtil { class DrawUtil {
@@ -31,7 +31,6 @@ class DrawUtil {
var m:Matrix = new Matrix(); var m:Matrix = new Matrix();
var sx:Float = 1.0; var sx:Float = 1.0;
var sy:Float = 1.0; var sy:Float = 1.0;
fillType = Type.createEnum(FillType, Std.string(fillType));
switch (fillType) { switch (fillType) {
case FillType.REPEAT: case FillType.REPEAT:
graphics.beginBitmapFill(image, m, true, false); graphics.beginBitmapFill(image, m, true, false);