[removed] couple of things from NinePatch.
public static final int BOTTOM_CENTER = 7;\r
public static final int BOTTOM_RIGHT = 8;\r
\r
- final TextureRegion[] patches;\r
- final Color color = new Color();\r
+ final TextureRegion[] patches; \r
\r
public NinePatch(TextureRegion ... patches) {\r
if(patches.length != 9) throw new IllegalArgumentException("NinePatch needs nine TextureRegions");\r
}\r
}\r
\r
- public void setColor(Color color) {\r
- this.color.set(color);\r
- }\r
- \r
- public void setColor(float r, float g, float b, float a) {\r
- this.color.set(r, g, b, a);\r
- }\r
- \r
public void draw(SpriteBatch batch, float x, float y, float width, float height) {\r
- draw(batch, x, y, width, height, 1);\r
- }\r
- \r
- public void draw(SpriteBatch batch, float x, float y, float width, float height, float alphaModulation) {\r
float widthTopBottom = width - (patches[TOP_LEFT].getRegionWidth() + patches[TOP_RIGHT].getRegionWidth());\r
float heightLeftRight = height - (patches[TOP_LEFT].getRegionHeight() + patches[BOTTOM_LEFT].getRegionHeight()); \r
float widthCenter = widthTopBottom; \r
final NinePatch upPatch = style.up;\r
\r
if(invalidated) layout();\r
- if(isPressed) downPatch.draw(batch, x, y, width, height, parentAlpha);\r
- else upPatch.draw(batch, x, y, width, height, parentAlpha);\r
+ \r
+ batch.setColor(color.r, color.g, color.b, color.a * parentAlpha);\r
+ if(isPressed) downPatch.draw(batch, x, y, width, height);\r
+ else upPatch.draw(batch, x, y, width, height);\r
\r
float textY = (int)(height * 0.5f) + (int)(bounds.height * 0.5f);\r
- font.setColor(fontColor);\r
+ font.setColor(fontColor.r, fontColor.g, fontColor.b, fontColor.a * parentAlpha);\r
font.drawMultiLine(batch, text, x + (int)(width * 0.5f), y + textY, 0, HAlignment.CENTER);\r
}\r
\r
final Color fontColor = style.fontColor;\r
\r
if(invalidated) layout();\r
+ \r
+ batch.setColor(color.r, color.g, color.b, color.a * parentAlpha);\r
if(isChecked) batch.draw(checkedRegion, x + boxPos.x, y + boxPos.y);\r
else batch.draw(uncheckedRegion, x + boxPos.x, y + boxPos.y);\r
\r
- font.setColor(fontColor);\r
+ font.setColor(fontColor.r, fontColor.g, fontColor.b, fontColor.a * parentAlpha);\r
font.draw(batch, label, x + textPos.x, y + textPos.y);\r
}\r
\r
final Color fontColor = style.fontColor;\r
\r
if(invalidated) layout();\r
- background.draw(batch, x, y, width, height, parentAlpha);\r
+ \r
+ batch.setColor(color.r, color.g, color.b, color.a * parentAlpha);\r
+ background.draw(batch, x, y, width, height);\r
if(entries.length > 0) {\r
float availableWidth = width - background.getLeftWidth() - background.getRightWidth();\r
int numGlyphs = font.computeVisibleGlyphs(entries[selection], 0, entries[selection].length(), availableWidth);\r
bounds.set(font.getBounds(entries[selection]));\r
bounds.height -= font.getDescent();\r
float textY = (int)(height / 2) + (int)(bounds.height / 2);\r
- font.setColor(fontColor);\r
+ font.setColor(fontColor.r, fontColor.g, fontColor.b, fontColor.a * parentAlpha);\r
font.draw(batch, entries[selection], x + background.getLeftWidth(), y + textY, 0, numGlyphs); \r
}\r
\r
final BitmapFont font = style.font;\r
final Color fontColor = style.fontColor;\r
\r
+ batch.setColor(color.r, color.g, color.b, color.a * parentAlpha);\r
listBackground.draw(batch, x, y, width, height);\r
float posY = height;\r
for(int i = 0; i < entries.length; i++) {\r
if(selected == i) {\r
listSelection.draw(batch, x, y + posY - entryHeight, width, entryHeight); \r
}\r
- font.setColor(fontColor);\r
+ font.setColor(fontColor.r, fontColor.g, fontColor.b, fontColor.a * parentAlpha);\r
font.draw(batch, entries[i], x + textOffsetX, y + posY - textOffsetY);\r
posY -= entryHeight;\r
}\r
final NinePatch upPatch = style.up;\r
\r
if(invalidated) layout();\r
- if(isPressed) downPatch.draw(batch, x, y, width, height, parentAlpha);\r
- else upPatch.draw(batch, x, y, width, height, parentAlpha);\r
+ \r
+ batch.setColor(color.r, color.g, color.b, color.a * parentAlpha);\r
+ if(isPressed) downPatch.draw(batch, x, y, width, height);\r
+ else upPatch.draw(batch, x, y, width, height);\r
\r
float imageX = (width - bounds.width) * 0.5f;\r
float imageY = (height - bounds.height) * 0.5f;\r
- \r
+\r
batch.draw(image, x + imageX, y + imageY, imageWidth, imageHeight);\r
}\r
\r
final NinePatch upPatch = style.up;\r
\r
if(invalidated) layout();\r
- if(isPressed) downPatch.draw(batch, x, y, width, height, parentAlpha);\r
- else upPatch.draw(batch, x, y, width, height, parentAlpha);\r
+ \r
+ batch.setColor(color.r, color.g, color.b, color.a * parentAlpha);\r
+ if(isPressed) downPatch.draw(batch, x, y, width, height);\r
+ else upPatch.draw(batch, x, y, width, height);\r
\r
float imageX = (width - bounds.width) * 0.5f;\r
float imageY = (height - bounds.height) * 0.5f;\r
- \r
+ \r
batch.draw(image, x + imageX, y + imageY, imageWidth, imageHeight);\r
}\r
\r
final Color fontColor = style.fontColor;\r
\r
if(invalidated) layout();\r
- font.setColor(fontColor); \r
+ font.setColor(fontColor.r, fontColor.g, fontColor.b, fontColor.a * parentAlpha); \r
font.drawMultiLine(batch, label, x + textPos.x, y + height); \r
}\r
\r
final Color fontColorUnselected = style.fontColorUnselected;\r
\r
if(invalidated) layout();\r
+ batch.setColor(color.r, color.g, color.b, color.a * parentAlpha);\r
\r
float posY = height;\r
for(int i = 0; i < entries.length; i++) {\r
if(selected == i) {\r
selectedPatch.draw(batch, x, y + posY - entryHeight, Math.max(prefWidth, width), entryHeight);\r
- font.setColor(fontColorSelected);\r
+ font.setColor(fontColorSelected.r, fontColorSelected.g, fontColorSelected.b, fontColorSelected.a * parentAlpha);\r
} else {\r
- font.setColor(fontColorUnselected);\r
+ font.setColor(fontColorUnselected.r, fontColorUnselected.g, fontColorUnselected.b, fontColorUnselected.a * parentAlpha);\r
}\r
font.draw(batch, entries[i], x + textOffsetX, y + posY - textOffsetY);\r
posY -= entryHeight;\r
public void draw(SpriteBatch batch, float parentAlpha) {\r
final NinePatch background = style.background;\r
\r
+ batch.setColor(color.r, color.g, color.b, color.a * parentAlpha);\r
background.draw(batch, x, y, width, height); \r
setupTransform(batch);\r
applyLayout();\r
setupTransform(batch); \r
\r
// if invalidated layout!\r
- if(invalidated) layout();\r
+ if(invalidated) layout(); \r
\r
// calculate the bounds for the scrollbars, the widget\r
// area and the scissor area. Nasty...\r
calculateBoundsAndPositions(batch.getTransformMatrix()); \r
\r
// first draw the background ninepatch\r
+ batch.setColor(color.r, color.g, color.b, color.a * parentAlpha);\r
background.draw(batch, 0, 0, width, height); \r
\r
// enable scissors for widget area and draw that damn\r
ScissorStack.popScissors();\r
\r
// render scrollbars and knobs on top.\r
+ batch.setColor(color.r, color.g, color.b, color.a * parentAlpha);\r
if(hasHScroll) {\r
hScroll.draw(batch, hScrollBounds.x, hScrollBounds.y, hScrollBounds.width, hScrollBounds.height);\r
hScrollKnob.draw(batch, hScrollKnobBounds.x, hScrollKnobBounds.y, hScrollKnobBounds.width, hScrollKnobBounds.height);\r
final NinePatch slider = style.slider;\r
\r
if(invalidated) layout();\r
+ \r
+ batch.setColor(color.r, color.g, color.b, color.a * parentAlpha);\r
sliderPos = value / (max-min) * (width - knob.getRegionWidth());\r
sliderPos = Math.max(0, sliderPos);\r
sliderPos = Math.min(width - knob.getRegionWidth(), sliderPos);\r
protected void draw(SpriteBatch batch, float parentAlpha) {\r
NinePatch handle = style.handle;\r
\r
- setupTransform(batch); \r
+ setupTransform(batch); \r
calculateBoundsAndPositions(batch.getTransformMatrix()); \r
for(int i = 0; i < children.size(); i++) {\r
ScissorStack.pushScissors(scissors[i]); \r
drawChild(children.get(i), batch, parentAlpha);\r
ScissorStack.popScissors();\r
}\r
- handle.draw(batch, handleBounds.x, handleBounds.y, handleBounds.width, handleBounds.height, parentAlpha);\r
+ batch.setColor(color.r, color.g, color.b, color.a);\r
+ handle.draw(batch, handleBounds.x, handleBounds.y, handleBounds.width, handleBounds.height);\r
if(invalidated) layout();\r
resetTransform(batch);\r
}\r
\r
if (invalidated) layout();\r
\r
- background.draw(batch, x, y, width, height, parentAlpha);\r
+ batch.setColor(color.r, color.g, color.b, color.a * parentAlpha);\r
+ background.draw(batch, x, y, width, height);\r
float textY = (int)(height / 2) + (int)(textBounds.height / 2);\r
- font.setColor(fontColor);\r
+ font.setColor(fontColor.r, fontColor.g, fontColor.b, fontColor.a * parentAlpha);\r
calculateOffsets();\r
\r
- if(hasSelection) {\r
+ if(hasSelection) { \r
batch.draw(selection, x + selectionX + background.getLeftWidth() + renderOffset, y + textY - textBounds.height, selectionWidth, textBounds.height);\r
}\r
- font.draw(batch, text, x + background.getLeftWidth() + textOffset, y + textY, visibleTextStart, visibleTextEnd);\r
+ \r
+ font.draw(batch, text, x + background.getLeftWidth() + textOffset, y + textY, visibleTextStart, visibleTextEnd); \r
if (parent.keyboardFocusedActor == this) {\r
blink();\r
- if (cursorOn) {\r
+ if (cursorOn) { \r
cursorPatch.draw(batch, x + background.getLeftWidth() + glyphPositions.get(cursor) + renderOffset - 1, y + textY\r
- textBounds.height, cursorPatch.getTotalWidth(), textBounds.height);\r
\r
final NinePatch upPatch = style.up;\r
\r
if(invalidated) layout();\r
+ \r
+ batch.setColor(color.r, color.g, color.b, color.a * parentAlpha);\r
if (isPressed)\r
- downPatch.draw(batch, x, y, width, height, parentAlpha);\r
+ downPatch.draw(batch, x, y, width, height);\r
else\r
- upPatch.draw(batch, x, y, width, height, parentAlpha);\r
+ upPatch.draw(batch, x, y, width, height);\r
\r
float textY = (int) (height / 2) + (int) (bounds.height / 2);\r
- font.setColor(fontColor);\r
+ font.setColor(fontColor.r, fontColor.g, fontColor.b, fontColor.a * parentAlpha);\r
font.drawMultiLine(batch, text, x + (int) (width / 2), y + textY, 0,\r
HAlignment.CENTER);\r
}\r
final NinePatch backgroundPatch = style.background;\r
final BitmapFont titleFont = style.titleFont;\r
final Color titleFontColor = style.titleFontColor;\r
- \r
-// invalidate(); // HACK, invalidate is not properly distributed it seems! Comment, then start qpre and resize window, see options pane!\r
-// layout(); // HACK, since we can't access the invalidated flag of the Table we derrive from.\r
\r
setupTransform(batch);\r
applyLayout();\r
calculateBoundsAndScissors(batch.getTransformMatrix());\r
\r
+ batch.setColor(color.r, color.g, color.b, color.a * parentAlpha);\r
backgroundPatch.draw(batch, 0, 0, width, height);\r
float textY = height - (int)(backgroundPatch.getTopHeight() / 2) + (int)(textBounds.height / 2);\r
- titleFont.setColor(titleFontColor);\r
+ titleFont.setColor(titleFontColor.r, titleFontColor.g, titleFontColor.b, titleFontColor.a * parentAlpha);\r
titleFont.drawMultiLine(batch, title, (int)(width / 2), textY, 0, HAlignment.CENTER);\r
batch.flush();\r
\r