Examples of NinePatch


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

  }

  @Override
  public void draw (SpriteBatch batch, float parentAlpha) {
    final TextureRegion knob = style.knob;
    final NinePatch slider = style.slider;

    batch.setColor(color.r, color.g, color.b, color.a * parentAlpha);
    sliderPos = (value - min) / (max - min) * (width - knob.getRegionWidth());
    sliderPos = Math.max(0, sliderPos);
    sliderPos = Math.min(width - knob.getRegionWidth(), sliderPos);

    float maxHeight = Math.max(knob.getRegionHeight(), slider.getTotalHeight());
    slider.draw(batch, x, y + (int)((maxHeight - slider.getTotalHeight()) * 0.5f), width, slider.getTotalHeight());
    batch.draw(knob, x + sliderPos, y + (int)((maxHeight - knob.getRegionHeight()) * 0.5f));
  }
 
View Full Code Here

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

    // selectable screen background
    background = ResourceFactory.newSprite( "bgnd.jpg" );
    background.setSize( width, height );

    // panel background
    NinePatch np = new NinePatch( ResourceFactory.newTexture( "brushed.png", false ), 0, 0, 0, 0 );
    np.setColor( new Color( 0.3f, 0.3f, 0.3f, 1f ) );
    NinePatchDrawable npBack = new NinePatchDrawable( np );

    // build the top panel and add all of its widgets
    Table topPanel = buildTopPanel( npBack, width, height );
    topPanel.add( buildGlobalSettingsWidgets() );
View Full Code Here

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

  /** Returns a registered ninepatch. If no ninepatch is found but a region exists with the name, a ninepatch is created from the
   * region and stored in the skin. If the region is an {@link AtlasRegion} then the {@link AtlasRegion#splits} are used,
   * otherwise the ninepatch will have the region as the center patch. */
  public NinePatch getPatch (String name) {
    NinePatch patch = optional(name, NinePatch.class);
    if (patch != null) return patch;

    try {
      TextureRegion region = getRegion(name);
      if (region instanceof AtlasRegion) {
        int[] splits = ((AtlasRegion)region).splits;
        if (splits != null) {
          patch = new NinePatch(region, splits[0], splits[1], splits[2], splits[3]);
          int[] pads = ((AtlasRegion)region).pads;
          if (pads != null) patch.setPadding(pads[0], pads[1], pads[2], pads[3]);
        }
      }
      if (patch == null) patch = new NinePatch(region);
      add(name, patch, NinePatch.class);
      return patch;
    } catch (GdxRuntimeException ex) {
      throw new GdxRuntimeException("No NinePatch, TextureRegion, or Texture registered with name: " + name);
    }
View Full Code Here

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

    } catch (GdxRuntimeException ignored) {
    }

    // Check for explicit registration of ninepatch, sprite, or tiled drawable.
    if (drawable == null) {
      NinePatch patch = optional(name, NinePatch.class);
      if (patch != null)
        drawable = new NinePatchDrawable(patch);
      else {
        Sprite sprite = optional(name, Sprite.class);
        if (sprite != null)
View Full Code Here

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

      sprite.setColor(tint);
      return new SpriteDrawable(sprite);
    }
    if (drawable instanceof NinePatchDrawable) {
      NinePatchDrawable patchDrawable = new NinePatchDrawable((NinePatchDrawable)drawable);
      patchDrawable.setPatch(new NinePatch(patchDrawable.getPatch(), tint));
      return patchDrawable;
    }
    if (drawable instanceof SpriteDrawable) {
      SpriteDrawable spriteDrawable = new SpriteDrawable((SpriteDrawable)drawable);
      Sprite sprite = spriteDrawable.getSprite();
View Full Code Here

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

  }

  @Override
  public void draw (SpriteBatch batch, float parentAlpha) {
    BitmapFont font = style.font;
    NinePatch selectedPatch = style.selectedPatch;
    Color fontColorSelected = style.fontColorSelected;
    Color fontColorUnselected = style.fontColorUnselected;

    batch.setColor(color.r, color.g, color.b, color.a * parentAlpha);

    font.setColor(fontColorUnselected.r, fontColorUnselected.g, fontColorUnselected.b, fontColorUnselected.a * parentAlpha);
    float itemY = height;
    for (int i = 0; i < items.length; i++) {
      if (cullingArea == null ||
        (itemY - itemHeight <= cullingArea.y + cullingArea.height && itemY >= cullingArea.y)) {
        if (selected == i) {
          selectedPatch.draw(batch, x, y + itemY - itemHeight, Math.max(prefWidth, width), itemHeight);
          font.setColor(fontColorSelected.r, fontColorSelected.g, fontColorSelected.b, fontColorSelected.a * parentAlpha);
        }
        font.draw(batch, items[i], x + textOffsetX, y + itemY - textOffsetY);
        if (selected == i) {
          font.setColor(fontColorUnselected.r, fontColorUnselected.g, fontColorUnselected.b, fontColorUnselected.a
View Full Code Here

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

      items = (String[])objects;

    selected = 0;

    final BitmapFont font = style.font;
    final NinePatch selectedPatch = style.selectedPatch;

    itemHeight = font.getCapHeight() - font.getDescent() * 2;
    itemHeight += selectedPatch.getTopHeight() + selectedPatch.getBottomHeight();
    prefWidth += selectedPatch.getLeftWidth() + selectedPatch.getRightWidth();
    textOffsetX = selectedPatch.getLeftWidth();
    textOffsetY = selectedPatch.getTopHeight() - font.getDescent();

    prefWidth = 0;
    for (int i = 0; i < items.length; i++) {
      TextBounds bounds = font.getBounds(items[i]);
      prefWidth = Math.max(bounds.width, prefWidth);
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 TextureRegion selection = style.selection;
    final NinePatch cursorPatch = style.cursor;

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

    float textY = (int)(height / 2 + textBounds.height / 2 + font.getDescent());
    calculateOffsets();

    boolean focused = stage != null && stage.getKeyboardFocus() == this;
    if (focused && hasSelection && selection != null) {
      batch.draw(selection, x + selectionX + bgLeftWidth + renderOffset,
        y + textY - textBounds.height - font.getDescent() / 2, selectionWidth, textBounds.height);
    }

    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 * parentAlpha);
        } else
          font.setColor(0.7f, 0.7f, 0.7f, parentAlpha);
        BitmapFont messageFont = style.messageFont != null ? style.messageFont : font;
        font.draw(batch, messageText, x + bgLeftWidth, y + textY);
      }
    } else {
      font.setColor(fontColor.r, fontColor.g, fontColor.b, fontColor.a * parentAlpha);
      font.draw(batch, displayText, x + bgLeftWidth + textOffset, y + textY, visibleTextStart, visibleTextEnd);
    }
    if (focused) {
      blink();
      if (cursorOn && cursorPatch != null) {
        cursorPatch.draw(batch, x + bgLeftWidth + 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

    }
    // Find Texture, TextureRegion and NinePatch in asset manager.
    if (layout.assetManager != null) {
      if (memberType == NinePatch.class) {
        if (layout.assetManager.isLoaded(value, Texture.class))
          return new NinePatch(new TextureRegion(layout.assetManager.get(value, Texture.class)));
      } else if (memberType == Texture.class) {
        if (layout.assetManager.isLoaded(value, Texture.class)) return layout.assetManager.get(value, Texture.class);
      } else if (memberType == TextureRegion.class) {
        if (layout.assetManager.isLoaded(value, Texture.class))
          return new TextureRegion(layout.assetManager.get(value, Texture.class));
View Full Code Here

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

  }

  @Override
  public void draw (SpriteBatch batch, float parentAlpha) {
    final TextureRegion knob = style.knob;
    final NinePatch slider = style.slider;

    batch.setColor(color.r, color.g, color.b, color.a * parentAlpha);
    sliderPos = (value - min) / (max - min) * (width - knob.getRegionWidth());
    sliderPos = Math.max(0, sliderPos);
    sliderPos = Math.min(width - knob.getRegionWidth(), sliderPos);

    slider.draw(batch, x, y + (int)((height - slider.getTotalHeight()) * 0.5f), width, slider.getTotalHeight());
    batch.draw(knob, x + sliderPos, y + (int)((height - knob.getRegionHeight()) * 0.5f));
  }
 
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.