Search in sources :

Example 6 with Drawable

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);
}
Also used : Drawable(com.badlogic.gdx.scenes.scene2d.utils.Drawable)

Example 7 with Drawable

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);
}
Also used : Color(com.badlogic.gdx.graphics.Color) Drawable(com.badlogic.gdx.scenes.scene2d.utils.Drawable) Matrix4(com.badlogic.gdx.math.Matrix4)

Example 8 with Drawable

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());
}
Also used : Drawable(com.badlogic.gdx.scenes.scene2d.utils.Drawable) BitmapFont(com.badlogic.gdx.graphics.g2d.BitmapFont)

Example 9 with Drawable

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();
}
Also used : Actor(com.badlogic.gdx.scenes.scene2d.Actor) Drawable(com.badlogic.gdx.scenes.scene2d.utils.Drawable) Stage(com.badlogic.gdx.scenes.scene2d.Stage)

Example 10 with Drawable

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);
}
Also used : Drawable(com.badlogic.gdx.scenes.scene2d.utils.Drawable)

Aggregations

Drawable (com.badlogic.gdx.scenes.scene2d.utils.Drawable)34 BitmapFont (com.badlogic.gdx.graphics.g2d.BitmapFont)10 Color (com.badlogic.gdx.graphics.Color)9 SpriteDrawable (com.badlogic.gdx.scenes.scene2d.utils.SpriteDrawable)7 NinePatchDrawable (com.badlogic.gdx.scenes.scene2d.utils.NinePatchDrawable)6 Actor (com.badlogic.gdx.scenes.scene2d.Actor)5 TextureRegionDrawable (com.badlogic.gdx.scenes.scene2d.utils.TextureRegionDrawable)5 TiledDrawable (com.badlogic.gdx.scenes.scene2d.utils.TiledDrawable)5 GdxRuntimeException (com.badlogic.gdx.utils.GdxRuntimeException)5 Sprite (com.badlogic.gdx.graphics.g2d.Sprite)4 TextureRegion (com.badlogic.gdx.graphics.g2d.TextureRegion)4 GlyphLayout (com.badlogic.gdx.graphics.g2d.GlyphLayout)3 NinePatch (com.badlogic.gdx.graphics.g2d.NinePatch)3 ListStyle (com.badlogic.gdx.scenes.scene2d.ui.List.ListStyle)3 ScrollPaneStyle (com.badlogic.gdx.scenes.scene2d.ui.ScrollPane.ScrollPaneStyle)3 ChangeListener (com.badlogic.gdx.scenes.scene2d.utils.ChangeListener)3 Array (com.badlogic.gdx.utils.Array)3 FileHandle (com.badlogic.gdx.files.FileHandle)2 AtlasRegion (com.badlogic.gdx.graphics.g2d.TextureAtlas.AtlasRegion)2 AtlasSprite (com.badlogic.gdx.graphics.g2d.TextureAtlas.AtlasSprite)2