BitmapTextField fix

This commit is contained in:
2015-06-25 17:15:49 +03:00
parent 78fb9bac50
commit 462ee023c3
2 changed files with 19 additions and 24 deletions

View File

@@ -201,32 +201,23 @@ class TextView extends SpriteView implements ITextView<Sprite, TextField> {
} }
private function placeTextField(textField:TextField):Void { private function placeTextField(textField:TextField):Void {
//if (fill) {
// textField.width = width - paddings * 2;
// textField.height = height - paddings * 2;
// textField.x = paddings;
// textField.y = paddings;
//} else {
textField.width = width; textField.width = width;
textField.height = _textHeight; textField.height = _textHeight;
//#if html5 textField.height = _textHeight; #end textField.x = switch (layoutHAlign) {
textField.x = switch (layoutHAlign) { case HAlign.NONE: 0;
case HAlign.NONE: 0; case HAlign.LEFT: leftPadding;
case HAlign.LEFT: leftPadding; case HAlign.CENTER: (width - textField.width) / 2 + leftPadding - rightPadding;
case HAlign.CENTER: (width - textField.width) / 2 + leftPadding - rightPadding; case HAlign.RIGHT: width - textField.width - rightPadding;
case HAlign.RIGHT: width - textField.width - rightPadding; default: 0;
default: 0; }
} textField.y = switch (layoutVAlign) {
textField.y = switch (layoutVAlign) { case VAlign.NONE: 0;
case VAlign.NONE: 0; case VAlign.TOP: topPadding;
case VAlign.TOP: topPadding; case VAlign.MIDDLE: (height - _textHeight) / 2 + topPadding - bottomPadding;
case VAlign.MIDDLE: (height - _textHeight) / 2 + topPadding - bottomPadding; case VAlign.BOTTOM: height - _textHeight - bottomPadding;
case VAlign.BOTTOM: height - _textHeight - bottomPadding; default: 0;
default: 0; }
}
//}
} }
override private function set_mouseEnabled(value:Bool):Bool { override private function set_mouseEnabled(value:Bool):Bool {

6
haxework/text/BitmapTextField.hx Normal file → Executable file
View File

@@ -1,5 +1,6 @@
package haxework.text; package haxework.text;
import haxe.Timer;
import flash.text.TextFormat; import flash.text.TextFormat;
import flash.events.Event; import flash.events.Event;
import flash.display.Bitmap; import flash.display.Bitmap;
@@ -97,7 +98,10 @@ class BitmapTextField extends TextField {
private function redraw() { private function redraw() {
var size = TextUtil.getSize(this); var size = TextUtil.getSize(this);
bitmap.bitmapData = draw(this, size.x, size.y, shadowColor, shadowAlpha, shadow, stroke); //ToDo: openfl 3.0.6 -> 3.1.0
Timer.delay(function() {
bitmap.bitmapData = draw(this, size.x, size.y, shadowColor, shadowAlpha, shadow, stroke);
}, 1);
bitmap.x = x; bitmap.x = x;
bitmap.y = y; bitmap.y = y;
_invalidated = false; _invalidated = false;