Exemplo n.º 1
0
  @Override
  public void render(MVP mvp) {
    final float contentSize = 0.9f;

    SimpleTexturedShader shader = injector.getInstance(SimpleTexturedShader.class);
    shader.activate();

    // Draw the background texture
    shader.setMVPMatrix(mvp.collapse());
    shader.setTexture(backgroundTexture);
    shader.draw();

    // If the click action has an icon
    if (action.hasIconTexture()) {
      drawIcon(mvp, shader);
    }

    drawActionName(mvp, contentSize);

    // If the action cannot be performed
    if (!action.isExecutable()) {
      // Draw the unavailable overlay
      shader.setMVPMatrix(mvp.collapse());
      shader.setTexture(unselectableTexture);
      shader.draw();
    }
  }
Exemplo n.º 2
0
  private void drawActionName(final MVP mvp, final float contentSize) {
    final float[] nameModel = mvp.peekCopy(MVP.Type.MODEL);

    // Move to the left edge of the menu item
    Matrix.translateM(nameModel, Constants.NO_OFFSET, -0.45f, 0.0f, 0.0f);

    // Shrink the content text to the correct size
    float nameWidth = (1.0f / aspectRatio);
    Matrix.scaleM(nameModel, Constants.NO_OFFSET, nameWidth, 1.0f, 1.0f);

    // Align the left edge of the text with the left edge of the menu item
    Matrix.translateM(nameModel, Constants.NO_OFFSET, text.getWidth() / 2.0f, 0.0f, 0.0f);

    // Perform the text draw
    mvp.push(MVP.Type.MODEL, nameModel);
    text.render(mvp);
    mvp.pop(MVP.Type.MODEL);
  }
Exemplo n.º 3
0
  private void drawIcon(final MVP mvp, final SimpleTexturedShader shader) {
    final Device device = injector.getInstance(Device.class);
    final float[] iconModel = mvp.peekCopy(MVP.Type.MODEL);

    // Move to the right edge of the entire menu item
    Matrix.translateM(iconModel, Constants.NO_OFFSET, 0.5f, 0.0f, 0.0f);

    // Scale the icon to be 1:1 square to the menu item height
    Matrix.scaleM(
        iconModel, Constants.NO_OFFSET, 1.0f / aspectRatio / device.getAspectRatio(), 1.0f, 1.0f);

    // Align the right edge of the icon to the right edge of the menu item
    Matrix.translateM(iconModel, Constants.NO_OFFSET, -0.5f, 0.0f, 0.0f);

    // Shrink the icon size down to fit in the margins
    final float contentSize = 0.5f;
    Matrix.scaleM(iconModel, Constants.NO_OFFSET, contentSize, contentSize, 1.0f);

    // Perform the icon draw
    shader.setMVPMatrix(mvp.collapseM(iconModel));
    shader.setTexture(action.getIconTexture());
    shader.draw();
  }