Skip to content
Permalink
Browse files
Better selection and cursor size.
Before commit:
![](http://i.imgur.com/9gLpbdg.png)

After:
![](http://i.imgur.com/yEJ1bzC.png)

For an older skin using the "includePaddingInMetrics" method from the blog, I had to use this to get previous behavior:

```
protected void drawSelection (Drawable selection, Batch batch, BitmapFont font, float x, float y) {
	float adjust = font.getDescent() / 2;
	textHeight += adjust;
	super.drawSelection(selection, batch, font, x, y + adjust);
	textHeight -= adjust;
}

protected void drawCursor (Drawable cursorPatch, Batch batch, BitmapFont font, float x, float y) {
	float adjust = font.getDescent() / 2;
	textHeight += adjust;
	super.drawCursor(cursorPatch, batch, font, x, y + adjust);
	textHeight -= adjust;
}
```
  • Loading branch information
NathanSweet committed Jun 28, 2015
1 parent b65dd66 commit 2a830de
Showing 1 changed file with 2 additions and 3 deletions.
@@ -336,7 +336,7 @@ protected float getTextY (BitmapFont font, Drawable background) {
/** Draws selection rectangle **/
protected void drawSelection (Drawable selection, Batch batch, BitmapFont font, float x, float y) {
selection.draw(batch, x + selectionX + renderOffset + fontOffset, y - textHeight - font.getDescent(), selectionWidth,
textHeight + font.getDescent() / 2);
textHeight);
}

protected void drawText (Batch batch, BitmapFont font, float x, float y) {
@@ -345,8 +345,7 @@ protected void drawText (Batch batch, BitmapFont font, float x, float y) {

protected void drawCursor (Drawable cursorPatch, Batch batch, BitmapFont font, float x, float y) {
cursorPatch.draw(batch, x + textOffset + glyphPositions.get(cursor) - glyphPositions.get(visibleTextStart) + fontOffset
+ font.getData().cursorX, y - textHeight - font.getDescent(), cursorPatch.getMinWidth(), textHeight + font.getDescent()
/ 2);
+ font.getData().cursorX, y - textHeight - font.getDescent(), cursorPatch.getMinWidth(), textHeight);
}

void updateDisplayText () {

0 comments on commit 2a830de

Please sign in to comment.