List of usage examples for com.badlogic.gdx.graphics.g2d BitmapFont getDescent
public float getDescent()
From source file:com.bladecoder.engineeditor.ui.components.CellRenderer.java
License:Apache License
public void draw(Batch batch, float parentAlpha, T item, boolean selected, float x, float y, float width, float height) { BitmapFont font = style.font; Drawable selectedDrawable = style.selection; Color fontColorSelected = style.fontColorSelected; Color fontColorUnselected = style.fontColorUnselected; if (selected) { selectedDrawable.draw(batch, x, y - height, width, height); font.setColor(fontColorSelected.r, fontColorSelected.g, fontColorSelected.b, fontColorSelected.a * parentAlpha); } else {//from w w w.j av a 2 s . c o m font.setColor(fontColorUnselected.r, fontColorUnselected.g, fontColorUnselected.b, fontColorUnselected.a * parentAlpha); } if (hasImage()) { TextureRegion r = getCellImage(item); float ih = r.getRegionHeight(); float iw = r.getRegionWidth(); if (ih > getItemHeight() - MARGIN) { ih = getItemHeight() - MARGIN; iw *= ih / r.getRegionHeight(); } batch.draw(r, x, y - ih - MARGIN / 2, iw, ih); x += iw; } font.draw(batch, getCellTitle(item), x + textOffsetX, y - textOffsetY); if (hasSubtitle()) { String sub = getCellSubTitle(item); if (sub != null) { if (selected) { style.subtitleFont.setColor(fontColorSelected.r, fontColorSelected.g, fontColorSelected.b, fontColorSelected.a * parentAlpha * 0.5f); } else { style.subtitleFont.setColor(fontColorUnselected.r, fontColorUnselected.g, fontColorUnselected.b, fontColorUnselected.a * parentAlpha * 0.5f); } style.subtitleFont.draw(batch, sub, x + textOffsetX, y - textOffsetY - (font.getCapHeight() - font.getDescent() * 2)); } } }
From source file:com.bladecoder.engineeditor.ui.components.CellRenderer.java
License:Apache License
public void layout(CustomListStyle style) { this.style = style; BitmapFont font = style.font; Drawable selectedDrawable = style.selection; textOffsetX = selectedDrawable.getLeftWidth(); textOffsetY = selectedDrawable.getTopHeight() - font.getDescent(); itemHeight = font.getCapHeight() - font.getDescent() * 2; if (hasSubtitle()) { itemHeight += style.subtitleFont.getCapHeight() - style.subtitleFont.getDescent() * 2; ;//from w w w.j a va 2 s .c om } itemHeight += selectedDrawable.getTopHeight() + selectedDrawable.getBottomHeight(); }
From source file:com.calanti.androidnativekeyboardinputtest.libgdxModified_1_9_3.CalTextField.java
License:Apache License
protected float getTextY(BitmapFont font, Drawable background) { float height = getHeight(); float textY = textHeight / 2 + font.getDescent(); if (background != null) { float bottom = background.getBottomHeight(); textY = textY + (height - background.getTopHeight() - bottom) / 2 + bottom; } else {// ww w. j a v a 2 s . c o m textY = textY + height / 2; } if (font.usesIntegerPositions()) textY = (int) textY; return textY; }
From source file:com.calanti.androidnativekeyboardinputtest.libgdxModified_1_9_3.CalTextField.java
License:Apache License
/** 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); /** calanti addition - better width support */ float sx = x + selectionX + renderOffset + fontOffset; float sy = y - textHeight - font.getDescent(); float w = Math.max(selectionWidth, selection.getMinWidth()); float h = textHeight; selection.draw(batch, sx, sy, w, h); }
From source file:com.calanti.androidnativekeyboardinputtest.libgdxModified_1_9_3.CalTextField.java
License:Apache License
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); /** calanti addition - proper centering of cursor */ float cx = x + textOffset + glyphPositions.get(cursor) - glyphPositions.get(visibleTextStart) + fontOffset + font.getData().cursorX - cursorPatch.getMinWidth() / 2; float cy = y - textHeight - font.getDescent(); float w = cursorPatch.getMinWidth(); float h = textHeight; cursorPatch.draw(batch, cx, cy, w, h); }
From source file:com.idp.engine.ui.graphics.base.IdpLogger.java
/** * Sets font that will be used to render the log. * @param font//from ww w . j av a2s . c o m */ public void setFont(BitmapFont font) { this.font = font; if (font != null) { this.font.setColor(Color.LIGHT_GRAY); this.font.setUseIntegerPositions(true); this.lineLength = (int) (Gdx.graphics.getWidth() / font.getSpaceWidth()); this.lineHeight = (int) (font.getCapHeight() - font.getDescent() + 2); if (blackRectangle != null) blackRectangle.dispose(); this.blackRectangle = new Texture(1, 1, Pixmap.Format.RGB565); } }
From source file:com.kotcrab.vis.ui.widget.VisTextArea.java
License:Apache License
@Override protected void drawSelection(Drawable selection, Batch batch, BitmapFont font, float x, float y) { int i = firstLineShowing * 2; float offsetY = 0; int minIndex = Math.min(cursor, selectionStart); int maxIndex = Math.max(cursor, selectionStart); while (i + 1 < linesBreak.size && i < (firstLineShowing + linesShowing) * 2) { int lineStart = linesBreak.get(i); int lineEnd = linesBreak.get(i + 1); if (!((minIndex < lineStart && minIndex < lineEnd && maxIndex < lineStart && maxIndex < lineEnd) || (minIndex > lineStart && minIndex > lineEnd && maxIndex > lineStart && maxIndex > lineEnd))) { int start = Math.max(linesBreak.get(i), minIndex); int end = Math.min(linesBreak.get(i + 1), maxIndex); float selectionX = glyphPositions.get(start) - glyphPositions.get(linesBreak.get(i)); float selectionWidth = glyphPositions.get(end) - glyphPositions.get(start); selection.draw(batch, x + selectionX + fontOffset, y - textHeight - font.getDescent() - offsetY, selectionWidth, font.getLineHeight()); }// w ww .j ava 2s . c o m offsetY += font.getLineHeight(); i += 2; } }
From source file:com.kotcrab.vis.ui.widget.VisTextArea.java
License:Apache License
@Override protected void drawCursor(Drawable cursorPatch, Batch batch, BitmapFont font, float x, float y) { float textOffset = cursor >= glyphPositions.size || cursorLine * 2 >= linesBreak.size ? 0 : glyphPositions.get(cursor) - glyphPositions.get(linesBreak.items[cursorLine * 2]); cursorX = textOffset + fontOffset + font.getData().cursorX; cursorPatch.draw(batch, x + cursorX, y - font.getDescent() / 2 - (cursorLine - firstLineShowing + 1) * font.getLineHeight(), cursorPatch.getMinWidth(), font.getLineHeight()); }
From source file:com.kotcrab.vis.ui.widget.VisTextArea.java
License:Apache License
public float getCursorY() { BitmapFont font = style.font; return -(-font.getDescent() / 2 - (cursorLine - firstLineShowing + 1) * font.getLineHeight()); }
From source file:com.kotcrab.vis.ui.widget.VisTextField.java
License:Apache License
/** Draws selection rectangle **/ protected void drawSelection(Drawable selection, Batch batch, BitmapFont font, float x, float y) { selection.draw(batch, x + selectionX + textOffset + fontOffset, y - textHeight - font.getDescent(), selectionWidth, textHeight); }