Package com.badlogic.gdx.scenes.scene2d.utils

Examples of com.badlogic.gdx.scenes.scene2d.utils.Drawable


    float x = getX();
    float y = getY();
    float w = getWidth();
    float h = getHeight();

    final Drawable bg = style.background;
    if (bg != null) bg.draw(batch, x, y, w, h);

    final Drawable knob = style.knob;
    if (knob != null) {
      x += knobPosition.x - knob.getMinWidth() / 2f;
      y += knobPosition.y - knob.getMinHeight() / 2f;
      knob.draw(batch, x, y, knob.getMinWidth(), knob.getMinHeight());
    }
  }
View Full Code Here


    return style;
  }

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

    itemHeight = font.getCapHeight() - font.getDescent() * 2;
    itemHeight += selectedDrawable.getTopHeight() + selectedDrawable.getBottomHeight();

    textOffsetX = selectedDrawable.getLeftWidth();
    textOffsetY = selectedDrawable.getTopHeight() - font.getDescent();

    prefWidth = 0;
    for (int i = 0; i < items.size; i++) {
      TextBounds bounds = font.getBounds(items.get(i).toString());
      prefWidth = Math.max(bounds.width, prefWidth);
    }
    prefWidth += selectedDrawable.getLeftWidth() + selectedDrawable.getRightWidth();
    prefHeight = items.size * itemHeight;

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

  @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)) {
View Full Code Here

      screenCoords.set(tmpCoords);

      // Show the list above or below the select box, limited to a number of items and the available height in the stage.
      float itemHeight = list.getItemHeight();
      float height = itemHeight * (maxListCount <= 0 ? items.size : Math.min(maxListCount, items.size));
      Drawable scrollPaneBackground = getStyle().background;
      if (scrollPaneBackground != null)
        height += scrollPaneBackground.getTopHeight() + scrollPaneBackground.getBottomHeight();
      Drawable listBackground = list.getStyle().background;
      if (listBackground != null) height += listBackground.getTopHeight() + listBackground.getBottomHeight();

      float heightBelow = tmpCoords.y;
      float heightAbove = stage.getCamera().viewportHeight - tmpCoords.y - SelectBox.this.getHeight();
      boolean below = true;
      if (height > heightBelow) {
View Full Code Here

    boolean focused = stage != null && stage.getKeyboardFocus() == this;

    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;
    if (background != null) {
      background.draw(batch, x, y, width, height);
      bgLeftWidth = background.getLeftWidth();
    }

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

View Full Code Here

  public CheckBoxStyle getStyle () {
    return style;
  }

  public void draw (Batch batch, float parentAlpha) {
    Drawable checkbox = null;
    if (isDisabled) {
      if (isChecked && style.checkboxOnDisabled != null)
        checkbox = style.checkboxOnDisabled;
      else
        checkbox = style.checkboxOffDisabled;
View Full Code Here

        text.append("...");
      }
    } else
      text = this.text;

    Drawable background = style.background;
    float x = 0, y = 0;
    if (background != null) {
      x = background.getLeftWidth();
      y = background.getBottomHeight();
      width -= background.getLeftWidth() + background.getRightWidth();
      height -= background.getBottomHeight() + background.getTopHeight();
    }
    if ((labelAlign & Align.top) != 0) {
      y += cache.getFont().isFlipped() ? 0 : height - bounds.height;
      y += style.font.getDescent();
    } else if ((labelAlign & Align.bottom) != 0) {
View Full Code Here

  public float getPrefWidth () {
    if (wrap) return 0;
    if (sizeInvalid) scaleAndComputeSize();
    float width = bounds.width;
    Drawable background = style.background;
    if (background != null) width += background.getLeftWidth() + background.getRightWidth();
    return width;
  }
View Full Code Here

  }

  public float getPrefHeight () {
    if (sizeInvalid) scaleAndComputeSize();
    float height = bounds.height - style.font.getDescent() * 2;
    Drawable background = style.background;
    if (background != null) height += background.getTopHeight() + background.getBottomHeight();
    return height;
  }
View Full Code Here

TOP

Related Classes of com.badlogic.gdx.scenes.scene2d.utils.Drawable

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.