mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-17 11:18:01 +00:00
Fix font logic for search field rendering
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user