Example usage for com.badlogic.gdx.scenes.scene2d.utils Drawable getRightWidth

List of usage examples for com.badlogic.gdx.scenes.scene2d.utils Drawable getRightWidth

Introduction

In this page you can find the example usage for com.badlogic.gdx.scenes.scene2d.utils Drawable getRightWidth.

Prototype

public float getRightWidth();

Source Link

Usage

From source file:CB_UI_Base.GL_UI.GL_View_Base.java

License:Open Source License

/**
 * * setting the drawableBackground and changes the Borders (do own Borders afterwards)
 **//*from   w w w  .j  av a 2  s .  c om*/
public void setBackground(Drawable background) {
    if (isDisposed)
        return;
    drawableBackground = background;
    if (background != null) {
        leftBorder = background.getLeftWidth();
        rightBorder = background.getRightWidth();
        topBorder = background.getTopHeight();
        bottomBorder = background.getBottomHeight(); // this.BottomHeight;
    } else {
        leftBorder = 0;
        rightBorder = 0;
        topBorder = 0;
        bottomBorder = 0; // this.BottomHeight;
    }
    innerWidth = getWidth() - leftBorder - rightBorder;
    innerHeight = getHeight() - topBorder - bottomBorder;
}

From source file:CB_UI_Base.GL_UI.utils.EmptyDrawable.java

License:Apache License

/** Creates a new empty drawable with the same sizing information as the specified drawable. */
public EmptyDrawable(Drawable drawable) {
    leftWidth = drawable.getLeftWidth();
    rightWidth = drawable.getRightWidth();
    topHeight = drawable.getTopHeight();
    bottomHeight = drawable.getBottomHeight();
    minWidth = drawable.getMinWidth();// w w  w  .j a  va2  s.c om
    minHeight = drawable.getMinHeight();
}

From source file:com.anstrat.gui.SnapScrollPane.java

License:Apache License

public void layout() {
    final Drawable bg = style.background;
    final Drawable hScrollKnob = style.hScrollKnob;
    final Drawable vScrollKnob = style.vScrollKnob;

    float bgLeftWidth = 0, bgRightWidth = 0, bgTopHeight = 0, bgBottomHeight = 0;
    if (bg != null) {
        bgLeftWidth = bg.getLeftWidth();
        bgRightWidth = bg.getRightWidth();
        bgTopHeight = bg.getTopHeight();
        bgBottomHeight = bg.getBottomHeight();
    }//from   w ww .  j  a  va 2s. c  o  m

    float width = getWidth();
    float height = getHeight();

    float scrollbarHeight = 0;
    if (hScrollKnob != null)
        scrollbarHeight = hScrollKnob.getMinHeight();
    if (style.hScroll != null)
        scrollbarHeight = Math.max(scrollbarHeight, style.hScroll.getMinHeight());
    float scrollbarWidth = 0;
    if (vScrollKnob != null)
        scrollbarWidth = vScrollKnob.getMinWidth();
    if (style.vScroll != null)
        scrollbarWidth = Math.max(scrollbarWidth, style.vScroll.getMinWidth());

    // Get available space size by subtracting background's padded area.
    areaWidth = width - bgLeftWidth - bgRightWidth;
    areaHeight = height - bgTopHeight - bgBottomHeight;

    if (widget == null)
        return;

    // Get widget's desired width.
    float widgetWidth, widgetHeight;
    if (widget instanceof Layout) {
        Layout layout = (Layout) widget;
        widgetWidth = layout.getPrefWidth();
        widgetHeight = layout.getPrefHeight();
    } else {
        widgetWidth = widget.getWidth();
        widgetHeight = widget.getHeight();
    }

    // Determine if horizontal/vertical scrollbars are needed.
    scrollX = forceOverscrollX || (widgetWidth > areaWidth && !disableX);
    scrollY = forceOverscrollY || (widgetHeight > areaHeight && !disableY);

    boolean fade = fadeScrollBars;
    if (!fade) {
        // Check again, now taking into account the area that's taken up by any enabled scrollbars.
        if (scrollY) {
            areaWidth -= scrollbarWidth;
            if (!scrollX && widgetWidth > areaWidth && !disableX) {
                scrollX = true;
            }
        }
        if (scrollX) {
            areaHeight -= scrollbarHeight;
            if (!scrollY && widgetHeight > areaHeight && !disableY) {
                scrollY = true;
                areaWidth -= scrollbarWidth;
            }
        }
    }

    // Set the widget area bounds.
    widgetAreaBounds.set(bgLeftWidth, bgBottomHeight, areaWidth, areaHeight);

    if (fade) {
        // Make sure widget is drawn under fading scrollbars.
        if (scrollX)
            areaHeight -= scrollbarHeight;
        if (scrollY)
            areaWidth -= scrollbarWidth;
    } else {
        if (scrollbarsOnTop) {
            // Make sure widget is drawn under non-fading scrollbars.
            if (scrollX)
                widgetAreaBounds.height += scrollbarHeight;
            if (scrollY)
                widgetAreaBounds.width += scrollbarWidth;
        } else {
            // Offset widget area y for horizontal scrollbar.
            if (scrollX)
                widgetAreaBounds.y += scrollbarHeight;
        }
    }

    // If the widget is smaller than the available space, make it take up the available space.
    widgetWidth = disableX ? width : Math.max(areaWidth, widgetWidth);
    widgetHeight = disableY ? height : Math.max(areaHeight, widgetHeight);

    maxX = widgetWidth - areaWidth;
    maxY = widgetHeight - areaHeight;
    if (fade) {
        // Make sure widget is drawn under fading scrollbars.
        if (scrollX)
            maxY -= scrollbarHeight;
        if (scrollY)
            maxX -= scrollbarWidth;
    }
    amountX = MathUtils.clamp(amountX, 0, maxX);
    amountY = MathUtils.clamp(amountY, 0, maxY);

    // Set the bounds and scroll knob sizes if scrollbars are needed.
    if (scrollX) {
        if (hScrollKnob != null) {
            float hScrollHeight = style.hScroll != null ? style.hScroll.getMinHeight()
                    : hScrollKnob.getMinHeight();
            hScrollBounds.set(bgLeftWidth, bgBottomHeight, areaWidth, hScrollHeight);
            hKnobBounds.width = Math.max(hScrollKnob.getMinWidth(),
                    (int) (hScrollBounds.width * areaWidth / widget.getWidth()));
            hKnobBounds.height = hScrollKnob.getMinHeight();
            hKnobBounds.x = hScrollBounds.x
                    + (int) ((hScrollBounds.width - hKnobBounds.width) * getScrollPercentX());
            hKnobBounds.y = hScrollBounds.y;
        } else {
            hScrollBounds.set(0, 0, 0, 0);
            hKnobBounds.set(0, 0, 0, 0);
        }
    }
    if (scrollY) {
        if (vScrollKnob != null) {
            float vScrollWidth = style.vScroll != null ? style.vScroll.getMinWidth()
                    : vScrollKnob.getMinWidth();
            vScrollBounds.set(width - bgRightWidth - vScrollWidth, height - bgTopHeight - areaHeight,
                    vScrollWidth, areaHeight);
            vKnobBounds.width = vScrollKnob.getMinWidth();
            vKnobBounds.height = Math.max(vScrollKnob.getMinHeight(),
                    (int) (vScrollBounds.height * areaHeight / widgetHeight));
            vKnobBounds.x = width - bgRightWidth - vScrollKnob.getMinWidth();
            vKnobBounds.y = vScrollBounds.y
                    + (int) ((vScrollBounds.height - vKnobBounds.height) * (1 - getScrollPercentY()));
        } else {
            vScrollBounds.set(0, 0, 0, 0);
            vKnobBounds.set(0, 0, 0, 0);
        }
    }

    if (widget.getWidth() != widgetWidth || widget.getHeight() != widgetHeight) {
        widget.setWidth(widgetWidth);
        widget.setHeight(widgetHeight);
        if (widget instanceof Layout) {
            Layout layout = (Layout) widget;
            layout.invalidate();
            layout.validate();
        }
    } else {
        if (widget instanceof Layout)
            ((Layout) widget).validate();
    }
}

From source file:com.bladecoder.engineeditor.ui.components.CustomList.java

License:Apache License

public void layout() {
    final BitmapFont font = style.font;
    final BitmapFont subfont = style.subtitleFont;
    final Drawable selectedDrawable = style.selection;

    cellRenderer.layout(style);//from  w w  w .ja v  a  2 s. co  m

    GlyphLayout textLayout = new GlyphLayout();

    prefWidth = 0;
    for (int i = 0; i < items.size; i++) {

        textLayout.setText(font, cellRenderer.getCellTitle(items.get(i)));

        prefWidth = Math.max(textLayout.width, prefWidth);

        if (cellRenderer.hasImage()) {
            TextureRegion r = cellRenderer.getCellImage(items.get(i));

            float ih = r.getRegionHeight();
            float iw = r.getRegionWidth();

            if (ih > getItemHeight() - 10) {
                ih = getItemHeight() - 10;
                iw *= ih / r.getRegionHeight();
            }

            prefWidth = Math.max(iw + textLayout.width, prefWidth);
        }

        if (cellRenderer.hasSubtitle()) {
            String subtitle = cellRenderer.getCellSubTitle(items.get(i));

            if (subtitle != null) {
                textLayout.setText(subfont, subtitle);
                prefWidth = Math.max(textLayout.width, prefWidth);
            }
        }
    }

    prefWidth += selectedDrawable.getLeftWidth() + selectedDrawable.getRightWidth();

    prefHeight = items.size * cellRenderer.getItemHeight();

    Drawable background = style.background;
    if (background != null) {
        prefWidth += background.getLeftWidth() + background.getRightWidth();
        prefHeight += background.getTopHeight() + background.getBottomHeight();
    }
}

From source file:com.bladecoder.engineeditor.ui.components.CustomList.java

License:Apache License

@Override
public void draw(Batch batch, float parentAlpha) {
    validate();/*from  w w  w.jav a 2 s  .  co m*/

    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();
    }

    for (int i = 0; i < items.size; i++) {
        if (cullingArea == null || (itemY - cellRenderer.getItemHeight() <= cullingArea.y + cullingArea.height
                && itemY >= cullingArea.y)) {
            T item = items.get(i);
            boolean selected = selection.contains(item);

            cellRenderer.draw(batch, parentAlpha, item, selected, x, y + itemY, width,
                    cellRenderer.getItemHeight());

        } else if (itemY < cullingArea.y) {
            break;
        }
        itemY -= cellRenderer.getItemHeight();
    }
}

From source file:com.calanti.androidnativekeyboardinputtest.libgdxModified_1_9_3.CalTextField.java

License:Apache License

@Override
public void draw(Batch batch, float parentAlpha) {
    Stage stage = getStage();/*from w  w w  . j a va  2  s . c o m*/
    focused = stage != null && stage.getKeyboardFocus() == this;
    if (!focused)
        keyRepeatTask.cancel();

    final BitmapFont font = style.font;
    final Color fontColor = (disabled && style.disabledFontColor != null) ? style.disabledFontColor
            : ((focused && style.focusedFontColor != null) ? style.focusedFontColor : style.fontColor);
    final Drawable selection = style.selection;
    final Drawable cursorPatch = style.cursor;
    final Drawable background = (disabled && style.disabledBackground != null) ? style.disabledBackground
            : ((focused && style.focusedBackground != null) ? style.focusedBackground : style.background);

    Color color = getColor();
    float x = getX();
    float y = getY();
    float width = getWidth();
    float height = getHeight();

    batch.setColor(color.r, color.g, color.b, color.a * parentAlpha);
    float bgLeftWidth = 0, bgRightWidth = 0;
    if (background != null) {
        background.draw(batch, x, y, width, height);
        bgLeftWidth = background.getLeftWidth();
        bgRightWidth = background.getRightWidth();
    }

    float textY = getTextY(font, background);
    calculateOffsets();

    if (focused && hasSelection && selection != null) {
        drawSelection(selection, batch, font, x + bgLeftWidth, y + textY);
    }

    float yOffset = font.isFlipped() ? -textHeight : 0;
    if (displayText.length() == 0) {
        if (!focused && messageText != null) {
            if (style.messageFontColor != null) {
                font.setColor(style.messageFontColor.r, style.messageFontColor.g, style.messageFontColor.b,
                        style.messageFontColor.a * color.a * parentAlpha);
            } else
                font.setColor(0.7f, 0.7f, 0.7f, color.a * parentAlpha);
            BitmapFont messageFont = style.messageFont != null ? style.messageFont : font;
            messageFont.draw(batch, messageText, x + bgLeftWidth, y + textY + yOffset, 0, messageText.length(),
                    width - bgLeftWidth - bgRightWidth, textHAlign, false, "...");
        }
    } else {
        font.setColor(fontColor.r, fontColor.g, fontColor.b, fontColor.a * color.a * parentAlpha);
        drawText(batch, font, x + bgLeftWidth, y + textY + yOffset);
    }
    if (focused && !disabled) {
        blink();
        if (cursorOn && cursorPatch != null) {
            drawCursor(cursorPatch, batch, font, x + bgLeftWidth, y + textY);
        }
    }
}

From source file:com.kotcrab.vis.ui.widget.VisTextField.java

License:Apache License

@Override
public void draw(Batch batch, float parentAlpha) {
    Stage stage = getStage();//from w w w. ja  va2  s . c om
    boolean focused = stage != null && stage.getKeyboardFocus() == this;
    if (!focused)
        keyRepeatTask.cancel();

    final BitmapFont font = style.font;
    final Color fontColor = (disabled && style.disabledFontColor != null) ? style.disabledFontColor
            : ((focused && style.focusedFontColor != null) ? style.focusedFontColor : style.fontColor);
    final Drawable selection = style.selection;
    final Drawable cursorPatch = style.cursor;
    Drawable background = (disabled && style.disabledBackground != null) ? style.disabledBackground
            : ((focused && style.focusedBackground != null) ? style.focusedBackground : style.background);

    // vis
    if (!disabled && clickListener.isOver() && style.backgroundOver != null)
        background = style.backgroundOver;

    Color color = getColor();
    float x = getX();
    float y = getY();
    float width = getWidth();
    float height = getHeight();

    batch.setColor(color.r, color.g, color.b, color.a * parentAlpha);
    float bgLeftWidth = 0, bgRightWidth = 0;
    if (background != null) {
        background.draw(batch, x, y, width, height);
        bgLeftWidth = background.getLeftWidth();
        bgRightWidth = background.getRightWidth();
    }

    float textY = getTextY(font, background);
    calculateOffsets();

    if (focused && hasSelection && selection != null) {
        drawSelection(selection, batch, font, x + bgLeftWidth, y + textY);
    }

    float yOffset = font.isFlipped() ? -textHeight : 0;
    if (displayText.length() == 0) {
        if (!focused && messageText != null) {
            if (style.messageFontColor != null) {
                font.setColor(style.messageFontColor.r, style.messageFontColor.g, style.messageFontColor.b,
                        style.messageFontColor.a * color.a * parentAlpha);
            } else
                font.setColor(0.7f, 0.7f, 0.7f, color.a * parentAlpha);
            BitmapFont messageFont = style.messageFont != null ? style.messageFont : font;
            messageFont.draw(batch, messageText, x + bgLeftWidth, y + textY + yOffset, 0, messageText.length(),
                    width - bgLeftWidth - bgRightWidth, textHAlign, false, "...");
        }
    } else {
        font.setColor(fontColor.r, fontColor.g, fontColor.b, fontColor.a * color.a * parentAlpha);
        drawText(batch, font, x + bgLeftWidth, y + textY + yOffset);
    }
    if (drawBorder && focused && !disabled) {
        blink();
        if (cursorOn && cursorPatch != null) {
            drawCursor(cursorPatch, batch, font, x + bgLeftWidth, y + textY);
        }
    }

    // vis
    if (isDisabled() == false && inputValid == false && style.errorBorder != null)
        style.errorBorder.draw(batch, getX(), getY(), getWidth(), getHeight());
    else if (focusBorderEnabled && drawBorder && style.focusBorder != null)
        style.focusBorder.draw(batch, getX(), getY(), getWidth(), getHeight());

}

From source file:com.meizu.taskmanager.ui.ScrollPane.java

License:Apache License

public void layout() {
    final Drawable bg = style.background;
    final Drawable hScrollKnob = style.hScrollKnob;
    final Drawable vScrollKnob = style.vScrollKnob;

    float bgLeftWidth = 0, bgRightWidth = 0, bgTopHeight = 0, bgBottomHeight = 0;
    if (bg != null) {
        bgLeftWidth = bg.getLeftWidth();
        bgRightWidth = bg.getRightWidth();
        bgTopHeight = bg.getTopHeight();
        bgBottomHeight = bg.getBottomHeight();
    }/*from   ww w .  j ava  2 s  .  c om*/

    float width = getWidth();
    float height = getHeight();

    float scrollbarHeight = 0;
    if (hScrollKnob != null)
        scrollbarHeight = hScrollKnob.getMinHeight();
    if (style.hScroll != null)
        scrollbarHeight = Math.max(scrollbarHeight, style.hScroll.getMinHeight());
    float scrollbarWidth = 0;
    if (vScrollKnob != null)
        scrollbarWidth = vScrollKnob.getMinWidth();
    if (style.vScroll != null)
        scrollbarWidth = Math.max(scrollbarWidth, style.vScroll.getMinWidth());

    // Get available space size by subtracting background's padded area.
    areaWidth = width - bgLeftWidth - bgRightWidth;
    areaHeight = height - bgTopHeight - bgBottomHeight;

    if (widget == null)
        return;

    // Get widget's desired width.
    float widgetWidth, widgetHeight;
    if (widget instanceof Layout) {
        Layout layout = (Layout) widget;
        widgetWidth = layout.getPrefWidth();
        widgetHeight = layout.getPrefHeight();
    } else {
        widgetWidth = widget.getWidth();
        widgetHeight = widget.getHeight();
    }

    // Determine if horizontal/vertical scrollbars are needed.
    scrollX = forceScrollX || (widgetWidth > areaWidth && !disableX);
    scrollY = forceScrollY || (widgetHeight > areaHeight && !disableY);

    boolean fade = fadeScrollBars;
    if (!fade) {
        // Check again, now taking into account the area that's taken up by any enabled scrollbars.
        if (scrollY) {
            areaWidth -= scrollbarWidth;
            if (!scrollX && widgetWidth > areaWidth && !disableX)
                scrollX = true;
        }
        if (scrollX) {
            areaHeight -= scrollbarHeight;
            if (!scrollY && widgetHeight > areaHeight && !disableY) {
                scrollY = true;
                areaWidth -= scrollbarWidth;
            }
        }
    }

    // The bounds of the scrollable area for the widget.
    widgetAreaBounds.set(bgLeftWidth, bgBottomHeight, areaWidth, areaHeight);

    if (fade) {
        // Make sure widget is drawn under fading scrollbars.
        if (scrollX && scrollY) {
            areaHeight -= scrollbarHeight;
            areaWidth -= scrollbarWidth;
        }
    } else {
        if (scrollbarsOnTop) {
            // Make sure widget is drawn under non-fading scrollbars.
            if (scrollX)
                widgetAreaBounds.height += scrollbarHeight;
            if (scrollY)
                widgetAreaBounds.width += scrollbarWidth;
        } else {
            // Offset widget area y for horizontal scrollbar at bottom.
            if (scrollX && hScrollOnBottom)
                widgetAreaBounds.y += scrollbarHeight;
            // Offset widget area x for vertical scrollbar at left.
            if (scrollY && !vScrollOnRight)
                widgetAreaBounds.x += scrollbarWidth;
        }
    }

    // If the widget is smaller than the available space, make it take up the available space.
    widgetWidth = disableX ? areaWidth : Math.max(areaWidth, widgetWidth);
    widgetHeight = disableY ? areaHeight : Math.max(areaHeight, widgetHeight);

    maxX = widgetWidth - areaWidth;
    maxY = widgetHeight - areaHeight;
    if (fade) {
        // Make sure widget is drawn under fading scrollbars.
        if (scrollX)
            maxY -= scrollbarHeight;
        if (scrollY)
            maxX -= scrollbarWidth;
    }
    scrollX(MathUtils.clamp(amountX, 0, maxX));
    scrollY(MathUtils.clamp(amountY, 0, maxY));

    // Set the bounds and scroll knob sizes if scrollbars are needed.
    if (scrollX) {
        if (hScrollKnob != null) {
            float hScrollHeight = style.hScroll != null ? style.hScroll.getMinHeight()
                    : hScrollKnob.getMinHeight();
            // The corner gap where the two scroll bars intersect might have to flip from right to left.
            float boundsX = vScrollOnRight ? bgLeftWidth : bgLeftWidth + scrollbarWidth;
            // Scrollbar on the top or bottom.
            float boundsY = hScrollOnBottom ? bgBottomHeight : height - bgTopHeight - hScrollHeight;
            hScrollBounds.set(boundsX, boundsY, areaWidth, hScrollHeight);
            if (variableSizeKnobs)
                hKnobBounds.width = Math.max(hScrollKnob.getMinWidth(),
                        (int) (hScrollBounds.width * areaWidth / widgetWidth));
            else
                hKnobBounds.width = hScrollKnob.getMinWidth();

            hKnobBounds.height = hScrollKnob.getMinHeight();

            hKnobBounds.x = hScrollBounds.x
                    + (int) ((hScrollBounds.width - hKnobBounds.width) * getScrollPercentX());
            hKnobBounds.y = hScrollBounds.y;
        } else {
            hScrollBounds.set(0, 0, 0, 0);
            hKnobBounds.set(0, 0, 0, 0);
        }
    }
    if (scrollY) {
        if (vScrollKnob != null) {
            float vScrollWidth = style.vScroll != null ? style.vScroll.getMinWidth()
                    : vScrollKnob.getMinWidth();
            // the small gap where the two scroll bars intersect might have to flip from bottom to top
            float boundsX, boundsY;
            if (hScrollOnBottom) {
                boundsY = height - bgTopHeight - areaHeight;
            } else {
                boundsY = bgBottomHeight;
            }
            // bar on the left or right
            if (vScrollOnRight) {
                boundsX = width - bgRightWidth - vScrollWidth;
            } else {
                boundsX = bgLeftWidth;
            }
            vScrollBounds.set(boundsX, boundsY, vScrollWidth, areaHeight);
            vKnobBounds.width = vScrollKnob.getMinWidth();
            if (variableSizeKnobs)
                vKnobBounds.height = Math.max(vScrollKnob.getMinHeight(),
                        (int) (vScrollBounds.height * areaHeight / widgetHeight));
            else
                vKnobBounds.height = vScrollKnob.getMinHeight();

            if (vScrollOnRight) {
                vKnobBounds.x = width - bgRightWidth - vScrollKnob.getMinWidth();
            } else {
                vKnobBounds.x = bgLeftWidth;
            }
            vKnobBounds.y = vScrollBounds.y
                    + (int) ((vScrollBounds.height - vKnobBounds.height) * (1 - getScrollPercentY()));
        } else {
            vScrollBounds.set(0, 0, 0, 0);
            vKnobBounds.set(0, 0, 0, 0);
        }
    }

    widget.setSize(widgetWidth, widgetHeight);
    if (widget instanceof Layout)
        ((Layout) widget).validate();
}

From source file:com.minikara.ttfinput.TextField.java

License:Apache License

@Override
public void draw(Batch batch, float parentAlpha) {
    Stage stage = getStage();/* w  w w . ja  v a 2  s.  c  o m*/
    boolean focused = stage != null && stage.getKeyboardFocus() == this;
    if (!focused)
        keyRepeatTask.cancel();

    final BitmapFont font = style.font;
    final Color fontColor = (disabled && style.disabledFontColor != null) ? style.disabledFontColor
            : ((focused && style.focusedFontColor != null) ? style.focusedFontColor : style.fontColor);
    final Drawable selection = style.selection;
    final Drawable cursorPatch = style.cursor;
    final Drawable background = (disabled && style.disabledBackground != null) ? style.disabledBackground
            : ((focused && style.focusedBackground != null) ? style.focusedBackground : style.background);

    Color color = getColor();
    float x = getX();
    float y = getY();
    float width = getWidth();
    float height = getHeight();

    batch.setColor(color.r, color.g, color.b, color.a * parentAlpha);
    float bgLeftWidth = 0, bgRightWidth = 0;
    if (background != null) {
        background.draw(batch, x, y, width, height);
        bgLeftWidth = background.getLeftWidth();
        bgRightWidth = background.getRightWidth();
    }

    float textY = getTextY(font, background);
    calculateOffsets();

    if (focused && hasSelection && selection != null) {
        drawSelection(selection, batch, font, x + bgLeftWidth, y + textY);
    }

    float yOffset = font.isFlipped() ? -textHeight : 0;
    if (displayText.length() == 0) {
        if (!focused && messageText != null) {
            if (style.messageFontColor != null) {
                font.setColor(style.messageFontColor.r, style.messageFontColor.g, style.messageFontColor.b,
                        style.messageFontColor.a * color.a * parentAlpha);
            } else
                font.setColor(0.7f, 0.7f, 0.7f, color.a * parentAlpha);
            BitmapFont messageFont = style.messageFont != null ? style.messageFont : font;
            messageFont.draw(batch, messageText, x + bgLeftWidth, y + textY + yOffset,
                    width - bgLeftWidth - bgRightWidth, textHAlign, false);
        }
    } else {
        font.setColor(fontColor.r, fontColor.g, fontColor.b, fontColor.a * color.a * parentAlpha);
        drawText(batch, font, x + bgLeftWidth, y + textY + yOffset);
    }
    if (focused && !disabled) {
        blink();
        if (cursorOn && cursorPatch != null) {
            drawCursor(cursorPatch, batch, font, x + bgLeftWidth, y + textY);
        }
    }
}

From source file:com.ray3k.skincomposer.AnimatedDrawable.java

License:Open Source License

private void recalcSize() {
    if (drawables.size > 0) {
        float bottomHeight = 0.0f;
        float leftWidth = 0.0f;
        float minHeight = 0.0f;
        float minWidth = 0.0f;
        float rightWidth = 0.0f;
        float topHeight = 0.0f;

        for (Drawable drawable : drawables) {
            bottomHeight = Math.max(bottomHeight, drawable.getBottomHeight());
            leftWidth = Math.max(leftWidth, drawable.getLeftWidth());
            minHeight = Math.max(minHeight, drawable.getMinHeight());
            minWidth = Math.max(minWidth, drawable.getMinWidth());
            rightWidth = Math.max(rightWidth, drawable.getRightWidth());
            topHeight = Math.max(topHeight, drawable.getTopHeight());
        }//from  w w  w  .j a v a 2  s  .  c o m

        setBottomHeight(bottomHeight);
        setLeftWidth(leftWidth);
        setMinHeight(minHeight);
        setMinWidth(minWidth);
        setRightWidth(rightWidth);
        setTopHeight(topHeight);
    }
}