use of com.badlogic.gdx.scenes.scene2d.utils.Drawable in project libgdx by libgdx.
the class List method draw.
@Override
public void draw(Batch batch, float parentAlpha) {
validate();
BitmapFont font = style.font;
Drawable selectedDrawable = style.selection;
Color fontColorSelected = style.fontColorSelected;
Color fontColorUnselected = style.fontColorUnselected;
Color color = getColor();
batch.setColor(color.r, color.g, color.b, color.a * parentAlpha);
float x = getX(), y = getY(), width = getWidth(), height = getHeight();
float itemY = height;
Drawable background = style.background;
if (background != null) {
background.draw(batch, x, y, width, height);
float leftWidth = background.getLeftWidth();
x += leftWidth;
itemY -= background.getTopHeight();
width -= leftWidth + background.getRightWidth();
}
font.setColor(fontColorUnselected.r, fontColorUnselected.g, fontColorUnselected.b, fontColorUnselected.a * parentAlpha);
for (int i = 0; i < items.size; i++) {
if (cullingArea == null || (itemY - itemHeight <= cullingArea.y + cullingArea.height && itemY >= cullingArea.y)) {
T item = items.get(i);
boolean selected = selection.contains(item);
if (selected) {
selectedDrawable.draw(batch, x, y + itemY - itemHeight, width, itemHeight);
font.setColor(fontColorSelected.r, fontColorSelected.g, fontColorSelected.b, fontColorSelected.a * parentAlpha);
}
drawItem(batch, font, i, item, x + textOffsetX, y + itemY - textOffsetY);
if (selected) {
font.setColor(fontColorUnselected.r, fontColorUnselected.g, fontColorUnselected.b, fontColorUnselected.a * parentAlpha);
}
} else if (itemY < cullingArea.y) {
break;
}
itemY -= itemHeight;
}
}
use of com.badlogic.gdx.scenes.scene2d.utils.Drawable in project libgdx by libgdx.
the class ProgressBar method getPrefHeight.
public float getPrefHeight() {
if (vertical)
return 140;
else {
final Drawable knob = getKnobDrawable();
final Drawable bg = (disabled && style.disabledBackground != null) ? style.disabledBackground : style.background;
return Math.max(knob == null ? 0 : knob.getMinHeight(), bg == null ? 0 : bg.getMinHeight());
}
}
use of com.badlogic.gdx.scenes.scene2d.utils.Drawable in project libgdx by libgdx.
the class Button method setStyle.
public void setStyle(ButtonStyle style) {
if (style == null)
throw new IllegalArgumentException("style cannot be null.");
this.style = style;
Drawable background = null;
if (isPressed() && !isDisabled()) {
background = style.down == null ? style.up : style.down;
} else {
if (isDisabled() && style.disabled != null)
background = style.disabled;
else if (isChecked && style.checked != null)
background = (isOver() && style.checkedOver != null) ? style.checkedOver : style.checked;
else if (isOver() && style.over != null)
background = style.over;
else
background = style.up;
}
setBackground(background);
}
use of com.badlogic.gdx.scenes.scene2d.utils.Drawable in project libgdx by libgdx.
the class ImageButton method updateImage.
private void updateImage() {
Drawable drawable = null;
if (isDisabled() && style.imageDisabled != null)
drawable = style.imageDisabled;
else if (isPressed() && style.imageDown != null)
drawable = style.imageDown;
else if (isChecked && style.imageChecked != null)
drawable = (style.imageCheckedOver != null && isOver()) ? style.imageCheckedOver : style.imageChecked;
else if (isOver() && style.imageOver != null)
drawable = style.imageOver;
else if (//
style.imageUp != null)
drawable = style.imageUp;
image.setDrawable(drawable);
}
use of com.badlogic.gdx.scenes.scene2d.utils.Drawable in project libgdx by libgdx.
the class ImageTextButton method updateImage.
private void updateImage() {
Drawable drawable = null;
if (isDisabled() && style.imageDisabled != null)
drawable = style.imageDisabled;
else if (isPressed() && style.imageDown != null)
drawable = style.imageDown;
else if (isChecked && style.imageChecked != null)
drawable = (style.imageCheckedOver != null && isOver()) ? style.imageCheckedOver : style.imageChecked;
else if (isOver() && style.imageOver != null)
drawable = style.imageOver;
else if (//
style.imageUp != null)
drawable = style.imageUp;
image.setDrawable(drawable);
}
Aggregations