Fix font logic for search field rendering

This commit is contained in:
drdev
2014-08-16 16:59:41 +00:00
parent 05a28accc2
commit 6de1ca70d9
2 changed files with 2 additions and 9 deletions

View File

@@ -75,7 +75,6 @@ public class TextSearchFilter<T extends InventoryItem> extends ItemFilter<T> {
public void setRatio(String ratio0) {
txtSearch.ratio = ratio0;
txtSearch.ratioWidth = txtSearch.getFont().getBounds(ratio0).width;
}
public String getCaption() {
@@ -87,7 +86,6 @@ public class TextSearchFilter<T extends InventoryItem> extends ItemFilter<T> {
protected class SearchField extends FTextField {
private String ratio = "(0 / 0)";
private float ratioWidth;
private SearchField() {
setFont(FONT);
@@ -97,7 +95,7 @@ public class TextSearchFilter<T extends InventoryItem> extends ItemFilter<T> {
@Override
protected float getRightPadding() {
return ratioWidth + 2 * PADDING;
return renderedFont.getBounds(ratio).width + 2 * PADDING;
}
@Override

View File

@@ -327,6 +327,7 @@ public class FTextField extends FDisplayObject implements ITextField {
while (textBounds.width > availableTextWidth || textBounds.height > h) {
if (renderedFont.canShrink()) { //shrink font to fit if possible
renderedFont = renderedFont.shrink();
availableTextWidth = w - getLeftPadding() - getRightPadding();
textBounds = renderedFont.getMultiLineBounds(text);
}
else {
@@ -337,12 +338,6 @@ public class FTextField extends FDisplayObject implements ITextField {
//draw selection if key input is active
if (isEditing) {
float selLeft = getTextLeft();
if (alignment == HAlignment.CENTER) {
}
else if (alignment == HAlignment.RIGHT) {
}
if (selStart > 0) {
selLeft += renderedFont.getBounds(text.substring(0, selStart)).width;
}