BitmapText.setColor(color) now behaves as expected and
sets the default color for all letters even after a text change. git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@6999 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
This commit is contained in:
parent
7aa8f746db
commit
88506617ce
@ -143,7 +143,7 @@ public class BitmapText extends Node {
|
|||||||
* @param color new color of text
|
* @param color new color of text
|
||||||
*/
|
*/
|
||||||
public void setColor(ColorRGBA color) {
|
public void setColor(ColorRGBA color) {
|
||||||
letters.setColor(0, block.getText().length(), color);
|
letters.setColor(color);
|
||||||
letters.invalidate(); // TODO: Don't have to align.
|
letters.invalidate(); // TODO: Don't have to align.
|
||||||
needRefresh = true;
|
needRefresh = true;
|
||||||
}
|
}
|
||||||
|
@ -20,6 +20,7 @@ class Letters {
|
|||||||
private float totalWidth;
|
private float totalWidth;
|
||||||
private float totalHeight;
|
private float totalHeight;
|
||||||
private ColorTags colorTags = new ColorTags();
|
private ColorTags colorTags = new ColorTags();
|
||||||
|
private ColorRGBA baseColor = null;
|
||||||
|
|
||||||
Letters(BitmapFont font, StringBlock bound, boolean rightToLeft) {
|
Letters(BitmapFont font, StringBlock bound, boolean rightToLeft) {
|
||||||
final String text = bound.getText();
|
final String text = bound.getText();
|
||||||
@ -41,6 +42,11 @@ class Letters {
|
|||||||
LetterQuad l = head;
|
LetterQuad l = head;
|
||||||
for (int i = 0; i < plainText.length(); i++) {
|
for (int i = 0; i < plainText.length(); i++) {
|
||||||
l = l.addNextCharacter(plainText.charAt(i));
|
l = l.addNextCharacter(plainText.charAt(i));
|
||||||
|
if (baseColor != null) {
|
||||||
|
// Give the letter a default color if
|
||||||
|
// one has been provided.
|
||||||
|
l.setColor( baseColor );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -296,6 +302,15 @@ class Letters {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the base color for all new letter quads and resets
|
||||||
|
* the color of existing letter quads.
|
||||||
|
*/
|
||||||
|
void setColor( ColorRGBA color ) {
|
||||||
|
baseColor = color;
|
||||||
|
setColor( 0, block.getText().length(), color );
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param start start index to set style. inclusive.
|
* @param start start index to set style. inclusive.
|
||||||
* @param end end index to set style. EXCLUSIVE.
|
* @param end end index to set style. EXCLUSIVE.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user