Beispiel #1
0
  protected void drawBackground(SpriteBatch batch, float parentAlpha) {
    if (style.stageBackground != null) {
      Color color = getColor();
      batch.setColor(color.r, color.g, color.b, color.a * parentAlpha);
      Stage stage = getStage();
      Vector2 position = stageToLocalCoordinates(Vector2.tmp.set(0, 0));
      Vector2 size = stageToLocalCoordinates(Vector2.tmp2.set(stage.getWidth(), stage.getHeight()));
      style.stageBackground.draw(
          batch, getX() + position.x, getY() + position.y, getX() + size.x, getY() + size.y);
    }

    super.drawBackground(batch, parentAlpha);
    // Draw the title without the batch transformed or clipping applied.
    float x = getX(), y = getY() + getHeight();
    TextBounds bounds = titleCache.getBounds();
    if ((titleAlignment & Align.left) != 0) x += getPadLeft();
    else if ((titleAlignment & Align.right) != 0) x += getWidth() - bounds.width - getPadRight();
    else x += (getWidth() - bounds.width) / 2;
    if ((titleAlignment & Align.top) == 0) {
      if ((titleAlignment & Align.bottom) != 0) y -= getPadTop() - bounds.height;
      else y -= (getPadTop() - bounds.height) / 2;
    }
    titleCache.setColor(Color.tmp.set(getColor()).mul(style.titleFontColor));
    titleCache.setPosition((int) x, (int) y);
    titleCache.draw(batch, parentAlpha);
  }
Beispiel #2
0
  @Override
  protected void drawBackground(SpriteBatch batch, float parentAlpha) {
    Color color = getColor();
    batch.setColor(color.r, color.g, color.b, color.a * parentAlpha);
    Stage stage = getStage();
    Vector2 position = stageToLocalCoordinates(Vector2.tmp.set(0, 0));
    Vector2 size = stageToLocalCoordinates(Vector2.tmp2.set(stage.getWidth(), stage.getHeight()));
    style.stageBackground.draw(
        batch, getX() + position.x, getY() + position.y, getX() + size.x, getY() + size.y);

    super.drawBackground(batch, parentAlpha);
  }
Beispiel #3
0
 public void draw(Batch batch, float parentAlpha) {
   validate();
   drawBackground(batch, parentAlpha);
   if (isTransform()) {
     applyTransform(batch, computeTransform());
     if (clip) {
       boolean draw =
           background == null
               ? clipBegin(0, 0, getWidth(), getHeight())
               : clipBegin(
                   layout.getPadLeft(),
                   layout.getPadBottom(),
                   getWidth() - layout.getPadLeft() - layout.getPadRight(),
                   getHeight() - layout.getPadBottom() - layout.getPadTop());
       if (draw) {
         drawChildren(batch, parentAlpha);
         clipEnd();
       }
     } else drawChildren(batch, parentAlpha);
     resetTransform(batch);
   } else super.draw(batch, parentAlpha);
 }