From 2e6dbb7b38d411e949a8b5e27a4aa760ddc3ac5f Mon Sep 17 00:00:00 2001 From: shmyga Date: Fri, 24 Apr 2015 14:24:04 +0300 Subject: [PATCH] fixes for html5 --- haxework/gui/TextView.hx | 10 +++++----- haxework/gui/utils/DrawUtil.hx | 1 + 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/haxework/gui/TextView.hx b/haxework/gui/TextView.hx index 3ea603e..d97230d 100755 --- a/haxework/gui/TextView.hx +++ b/haxework/gui/TextView.hx @@ -34,7 +34,7 @@ class TextView extends SpriteView implements ITextView { layoutVAlign = VAlign.NONE; textField = buildTextField(); textField.width = 1; - textField.height = #if html5 25 #else 1 #end; + textField.height = 1; textField.wordWrap = true; textFormat = textField.defaultTextFormat; textFormat.font = "Arial"; @@ -93,11 +93,7 @@ class TextView extends SpriteView implements ITextView { private function set_align(value:TextFormatAlign):TextFormatAlign { if (align != value) { align = value; - #if (flash || html5) textFormat.align = value; - #else - textFormat.align = Std.string(value); - #end invalidate(); } return align; @@ -148,6 +144,7 @@ class TextView extends SpriteView implements ITextView { textField.autoSize = fill ? TextFieldAutoSize.NONE : TextFieldAutoSize.LEFT; var t:String = currentText(); if (t != null) textField.text = t; + textField.setTextFormat(textFormat); if (contentSize && !Std.is(skin, ISize)) { width = textField.width + paddings * 2; height = textField.height + paddings * 2; @@ -173,17 +170,20 @@ class TextView extends SpriteView implements ITextView { textField.x = paddings; textField.y = paddings; } else { + #if html5 textField.height = textField.textHeight; #end textField.x = switch (layoutHAlign) { case HAlign.NONE: 0; case HAlign.LEFT: paddings; case HAlign.CENTER: (width - textField.width) / 2; case HAlign.RIGHT: width - textField.width - paddings; + default: 0; } textField.y = switch (layoutVAlign) { case VAlign.NONE: 0; case VAlign.TOP: paddings; case VAlign.MIDDLE: (height - textField.height) / 2; case VAlign.BOTTOM: height - textField.height - paddings; + default: 0; } } } diff --git a/haxework/gui/utils/DrawUtil.hx b/haxework/gui/utils/DrawUtil.hx index ac2134e..0be8346 100755 --- a/haxework/gui/utils/DrawUtil.hx +++ b/haxework/gui/utils/DrawUtil.hx @@ -31,6 +31,7 @@ class DrawUtil { var m:Matrix = new Matrix(); var sx:Float = 1.0; var sy:Float = 1.0; + fillType = Type.createEnum(FillType, Std.string(fillType)); switch (fillType) { case FillType.REPEAT: graphics.beginBitmapFill(image, m, true, false);