use of com.badlogic.gdx.scenes.scene2d.utils.Drawable in project libgdx by libgdx.
the class SplitPane method calculateVertBoundsAndPositions.
private void calculateVertBoundsAndPositions() {
Drawable handle = style.handle;
float width = getWidth();
float height = getHeight();
float availHeight = height - handle.getMinHeight();
float topAreaHeight = (int) (availHeight * splitAmount);
float bottomAreaHeight = availHeight - topAreaHeight;
float handleHeight = handle.getMinHeight();
firstWidgetBounds.set(0, height - topAreaHeight, width, topAreaHeight);
secondWidgetBounds.set(0, 0, width, bottomAreaHeight);
handleBounds.set(0, bottomAreaHeight, width, handleHeight);
}
use of com.badlogic.gdx.scenes.scene2d.utils.Drawable in project libgdx by libgdx.
the class SplitPane method draw.
@Override
public void draw(Batch batch, float parentAlpha) {
validate();
Color color = getColor();
Drawable handle = style.handle;
applyTransform(batch, computeTransform());
Matrix4 transform = batch.getTransformMatrix();
if (firstWidget != null) {
batch.flush();
getStage().calculateScissors(firstWidgetBounds, firstScissors);
if (ScissorStack.pushScissors(firstScissors)) {
if (firstWidget.isVisible())
firstWidget.draw(batch, parentAlpha * color.a);
batch.flush();
ScissorStack.popScissors();
}
}
if (secondWidget != null) {
batch.flush();
getStage().calculateScissors(secondWidgetBounds, secondScissors);
if (ScissorStack.pushScissors(secondScissors)) {
if (secondWidget.isVisible())
secondWidget.draw(batch, parentAlpha * color.a);
batch.flush();
ScissorStack.popScissors();
}
}
batch.setColor(color.r, color.g, color.b, parentAlpha * color.a);
handle.draw(batch, handleBounds.x, handleBounds.y, handleBounds.width, handleBounds.height);
resetTransform(batch);
}
use of com.badlogic.gdx.scenes.scene2d.utils.Drawable in project libgdx by libgdx.
the class TextArea method sizeChanged.
// OVERRIDE from TextField
@Override
protected void sizeChanged() {
// Cause calculateOffsets to recalculate the line breaks.
lastText = null;
// The number of lines showed must be updated whenever the height is updated
BitmapFont font = style.font;
Drawable background = style.background;
float availableHeight = getHeight() - (background == null ? 0 : background.getBottomHeight() + background.getTopHeight());
linesShowing = (int) Math.floor(availableHeight / font.getLineHeight());
}
use of com.badlogic.gdx.scenes.scene2d.utils.Drawable in project libgdx by libgdx.
the class Button method draw.
public void draw(Batch batch, float parentAlpha) {
validate();
boolean isDisabled = isDisabled();
boolean isPressed = isPressed();
boolean isChecked = isChecked();
boolean isOver = isOver();
Drawable background = null;
if (isDisabled && style.disabled != null)
background = style.disabled;
else if (isPressed && style.down != null)
background = style.down;
else if (isChecked && style.checked != null)
background = (style.checkedOver != null && isOver) ? style.checkedOver : style.checked;
else if (isOver && style.over != null)
background = style.over;
else if (//
style.up != null)
background = style.up;
setBackground(background);
float offsetX = 0, offsetY = 0;
if (isPressed && !isDisabled) {
offsetX = style.pressedOffsetX;
offsetY = style.pressedOffsetY;
} else if (isChecked && !isDisabled) {
offsetX = style.checkedOffsetX;
offsetY = style.checkedOffsetY;
} else {
offsetX = style.unpressedOffsetX;
offsetY = style.unpressedOffsetY;
}
Array<Actor> children = getChildren();
for (int i = 0; i < children.size; i++) children.get(i).moveBy(offsetX, offsetY);
super.draw(batch, parentAlpha);
for (int i = 0; i < children.size; i++) children.get(i).moveBy(-offsetX, -offsetY);
Stage stage = getStage();
if (stage != null && stage.getActionsRequestRendering() && isPressed != clickListener.isPressed())
Gdx.graphics.requestRendering();
}
use of com.badlogic.gdx.scenes.scene2d.utils.Drawable in project libgdx by libgdx.
the class CheckBox method draw.
public void draw(Batch batch, float parentAlpha) {
Drawable checkbox = null;
if (isDisabled()) {
if (isChecked && style.checkboxOnDisabled != null)
checkbox = style.checkboxOnDisabled;
else
checkbox = style.checkboxOffDisabled;
}
if (checkbox == null) {
if (isChecked && style.checkboxOn != null)
checkbox = style.checkboxOn;
else if (isOver() && style.checkboxOver != null && !isDisabled())
checkbox = style.checkboxOver;
else
checkbox = style.checkboxOff;
}
image.setDrawable(checkbox);
super.draw(batch, parentAlpha);
}
Aggregations