Examples of NinePatch


Examples of com.badlogic.gdx.graphics.g2d.NinePatch

  public void layout () {
  }

  @Override
  public void draw (SpriteBatch batch, float parentAlpha) {
    final NinePatch background = style.background;
    final BitmapFont font = style.font;
    final Color fontColor = style.fontColor;

    batch.setColor(color.r, color.g, color.b, color.a * parentAlpha);
    background.draw(batch, x, y, width, height);
    if (items.length > 0) {
      float availableWidth = width - background.getLeftWidth() - background.getRightWidth();
      int numGlyphs = font.computeVisibleGlyphs(items[selection], 0, items[selection].length(), availableWidth);
      bounds.set(font.getBounds(items[selection]));
      float textY = (int)(height / 2) + (int)(bounds.height / 2);
      font.setColor(fontColor.r, fontColor.g, fontColor.b, fontColor.a * parentAlpha);
      font.draw(batch, items[selection], x + background.getLeftWidth(), y + textY, 0, numGlyphs);
    }

    // calculate screen coords where list should be displayed
    ScissorStack.toWindowCoordinates(stage.getCamera(), batch.getTransformMatrix(), screenCoords.set(x, y));
  }
View Full Code Here

Examples of com.badlogic.gdx.graphics.g2d.NinePatch

      layout();
    }

    private void layout () {
      final BitmapFont font = style.font;
      final NinePatch listSelection = style.listSelection;

      float prefWidth = 0;
      float prefHeight = 0;

      for (int i = 0; i < items.length; i++) {
        String item = items[i];
        TextBounds bounds = font.getBounds(item);
        prefWidth = Math.max(bounds.width, prefWidth);

      }

      itemHeight = font.getCapHeight() + -font.getDescent() * 2;
      itemHeight += listSelection.getTopHeight() + listSelection.getBottomHeight();
      itemHeight *= ComboBox.this.parent.scaleY;
      prefWidth += listSelection.getLeftWidth() + listSelection.getRightWidth();
      prefHeight = items.length * itemHeight;
      textOffsetX = listSelection.getLeftWidth();
      textOffsetY = listSelection.getTopHeight() + -font.getDescent();

      width = Math.max(prefWidth, ComboBox.this.width);
      width *= ComboBox.this.parent.scaleX;
      height = prefHeight;
      y -= height;
View Full Code Here

Examples of com.badlogic.gdx.graphics.g2d.NinePatch

      y -= height;
    }

    @Override
    public void draw (SpriteBatch batch, float parentAlpha) {
      final NinePatch listBackground = style.listBackground;
      final NinePatch listSelection = style.listSelection;
      final BitmapFont font = style.font;
      final Color fontColor = style.fontColor;

      batch.setColor(color.r, color.g, color.b, color.a * parentAlpha);
      listBackground.draw(batch, x, y, width, height);
      float posY = height;
      for (int i = 0; i < items.length; i++) {
        if (selected == i) {
          listSelection.draw(batch, x, y + posY - itemHeight, width, itemHeight);
        }
        font.setColor(fontColor.r, fontColor.g, fontColor.b, fontColor.a * parentAlpha);
        font.setScale(ComboBox.this.parent.scaleX, ComboBox.this.parent.scaleY);
        font.draw(batch, items[i], x + textOffsetX, y + posY - textOffsetY);
        font.setScale(1, 1);
View Full Code Here

Examples of com.badlogic.gdx.graphics.g2d.NinePatch

      lastBlink = time;
    }
  }

  private void calculateOffsets () {
    final NinePatch background = style.background;

    float position = glyphPositions.get(cursor);
    float distance = position - Math.abs(renderOffset);
    float visibleWidth = width - background.getLeftWidth() - background.getRightWidth();

    // check whether the cursor left the left or right side of
    // the visible area and adjust renderoffset.
    if (distance <= 0) {
      if (cursor > 0)
View Full Code Here

Examples of com.badlogic.gdx.graphics.g2d.NinePatch

  @Override
  public void draw (SpriteBatch batch, float parentAlpha) {
    final BitmapFont font = style.font;
    final Color fontColor = style.fontColor;
    final NinePatch background = style.background;
    final TextureRegion selection = style.selection;
    final NinePatch cursorPatch = style.cursor;

    batch.setColor(color.r, color.g, color.b, color.a * parentAlpha);
    background.draw(batch, x, y, width, height);
    float textY = (int)(height / 2) + (int)(textBounds.height / 2) + font.getDescent() / 2;
    font.setColor(fontColor.r, fontColor.g, fontColor.b, fontColor.a * parentAlpha);
    calculateOffsets();

    if (hasSelection) {
      batch.draw(selection, x + selectionX + background.getLeftWidth() + renderOffset,
        y + textY - textBounds.height - font.getDescent() / 2, selectionWidth, textBounds.height);
    }

    font.draw(batch, text, x + background.getLeftWidth() + textOffset, y + textY, visibleTextStart, visibleTextEnd);
    if (parent.keyboardFocusedActor == this) {
      blink();
      if (cursorOn) {
        cursorPatch.draw(batch, x + background.getLeftWidth() + glyphPositions.get(cursor) + renderOffset - 1, y + textY
          - textBounds.height - font.getDescent(), cursorPatch.getTotalWidth(), textBounds.height + font.getDescent() / 2);
      }
    }
  }
View Full Code Here

Examples of com.badlogic.gdx.graphics.g2d.NinePatch

  public float getPrefWidth () {
    return 150;
  }

  public float getPrefHeight () {
    NinePatch background = style.background;
    return background.getBottomHeight() + background.getTopHeight() + textBounds.height;
  }
View Full Code Here

Examples of com.badlogic.gdx.graphics.g2d.NinePatch

    ScissorStack.calculateScissors(stage.getCamera(), transform, firstWidgetBounds, scissors[0]);
    ScissorStack.calculateScissors(stage.getCamera(), transform, secondWidgetBounds, scissors[1]);
  }

  private void calculateHorizBoundsAndPositions () {
    NinePatch handle = style.handle;

    float availWidth = width - handle.getTotalWidth();
    float leftAreaWidth = (int)(availWidth * splitAmount);
    float rightAreaWidth = (availWidth - leftAreaWidth);
    float handleWidth = (handle.getTotalWidth());

    firstWidgetBounds.set(0, 0, leftAreaWidth, height);
    secondWidgetBounds.set(leftAreaWidth + handleWidth, 0, rightAreaWidth, height);
    handleBounds.set(leftAreaWidth, 0, handleWidth, height);
  }
View Full Code Here

Examples of com.badlogic.gdx.graphics.g2d.NinePatch

    secondWidgetBounds.set(leftAreaWidth + handleWidth, 0, rightAreaWidth, height);
    handleBounds.set(leftAreaWidth, 0, handleWidth, height);
  }

  private void calculateVertBoundsAndPositions () {
    NinePatch handle = style.handle;

    float availHeight = height - handle.getTotalHeight();
    float topAreaHeight = (int)(availHeight * splitAmount);
    float bottomAreaHeight = (availHeight - topAreaHeight);
    float handleHeight = handle.getTotalHeight();

    firstWidgetBounds.set(0, height - topAreaHeight, width, topAreaHeight);
    secondWidgetBounds.set(0, 0, width, bottomAreaHeight);
    handleBounds.set(0, bottomAreaHeight, width, handleHeight);
  }
View Full Code Here

Examples of com.badlogic.gdx.graphics.g2d.NinePatch

    handleBounds.set(0, bottomAreaHeight, width, handleHeight);
  }

  @Override
  public void draw (SpriteBatch batch, float parentAlpha) {
    NinePatch handle = style.handle;

    applyTransform(batch);
    calculateBoundsAndPositions(batch.getTransformMatrix());
    for (int i = 0; i < children.size(); i++) {
      ScissorStack.pushScissors(scissors[i]);
      drawChild(children.get(i), batch, parentAlpha);
      ScissorStack.popScissors();
    }
    batch.setColor(color.r, color.g, color.b, color.a);
    handle.draw(batch, handleBounds.x, handleBounds.y, handleBounds.width, handleBounds.height);
    if (invalidated) layout();
    resetTransform(batch);
  }
View Full Code Here

Examples of com.badlogic.gdx.graphics.g2d.NinePatch

    super.touchUp(x, y, pointer);
  }

  @Override
  public void touchDragged (float x, float y, int pointer) {
    NinePatch handle = style.handle;

    if (touchDrag) {
      if (!vertical) {
        float delta = x - lastPoint.x;
        float availWidth = width - handle.getTotalWidth();
        float dragX = handlePos.x + delta;
        handlePos.x = dragX;
        dragX = Math.max(0, dragX);
        dragX = Math.min(availWidth, dragX);
        splitAmount = dragX / availWidth;
        if (splitAmount < minAmount) splitAmount = minAmount;
        if (splitAmount > maxAmount) splitAmount = maxAmount;
        invalidate();
        lastPoint.set(x, y);
      } else {
        float delta = y - lastPoint.y;
        float availHeight = height - handle.getTotalHeight();
        float dragY = handlePos.y + delta;
        handlePos.y = dragY;
        dragY = Math.max(0, dragY);
        dragY = Math.min(availHeight, dragY);
        splitAmount = 1 - (dragY / availHeight);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.