Exemplo n.º 1
0
  protected void drawMyself() {
    super.drawMyself();
    getValue();
    if (scrolling) {
      /*
       * Cause the menu to re-layout in case we've changed preferred size.
       */
      menu.layout();
    }

    float px = menu.getStyle().getF("f.padX");
    float py = menu.getStyle().getF("f.padY");

    float curX = x + px;
    MenuUtils.drawLeftText(this, getName() + ":", curX);
    curX += tWidth;

    curX = getX() + getWidth() - px - nWidth;
    if (shouldPerformFill()) MenuUtils.drawSingleGradientRect(this, curX, y, nWidth, height);
    /*
     * update the "value" object using Reflection.
     */
    MenuUtils.drawText(this, stringValue, true, true, curX, y, nWidth, height);
  }
Exemplo n.º 2
0
  protected void drawMyself() {
    float ro = getStyle().getF("f.roundOff");
    Color strokeC = getStrokeColor();
    Stroke stroke = getStroke();
    float px = getStyle().getF("f.padX");
    float py = getStyle().getF("f.padY");

    roundRect.setRoundRect(x, y, width, height, ro, ro);
    Graphics2D g2 = menu.buff.g2;

    /*
     * Set the correct fill gradient
     */
    //		if (!isEnabled())
    //		{
    //			g2.setPaint(getStyle().getC("c.disabled"));
    //		} else
    if (isOpen() && parent == menu) {
      g2.setPaint(getStyle().getGradient(MenuItem.DOWN, y, y + height));
    } else if (!hasChildren() && getState() == MenuItem.DOWN) {
      g2.setPaint(getStyle().getGradient(MenuItem.DOWN, y, y + height));
    } else g2.setPaint(getStyle().getGradient(getState(), y, y + height));

    /*
     * Only perform the fill if the mood is right.
     */
    //		if (getState() != MenuItem.UP || isOpen())
    //		{
    //			if (!isEnabled())
    //			{
    //				;
    //			} else if (menu.hovered != null && menu.hovered != this
    //					&& !isAncestorOfHovered())
    //			{
    //				;
    //			} else
    //			{
    //				g2.fill(roundRect);
    //				g2.setPaint(strokeC);
    //				g2.setStroke(stroke);
    //				g2.draw(roundRect);
    //			}
    //		}
    if (shouldPerformFill()) {
      g2.fill(roundRect);
      g2.setPaint(strokeC);
      g2.setStroke(stroke);
      g2.draw(roundRect);
    }

    /*
     * Draw the text, triangle, and shortcut.
     */
    float curX = x + px;
    MenuUtils.drawLeftText(this, getName(), curX);
    curX += tWidth;
    if (shortcut != null) {
      PFont font = getStyle().getFont("font");
      float fs = getStyle().getF("f.fontSize");

      float rightX = getX() + getWidth();
      curX = rightX - shortcutWidth;
      // curX += getStyle().padX;
      float shortSize = fs * shortcutTextSize;
      float descent = UIUtils.getTextDescent(menu.buff, font, shortSize, true);
      g2.setFont(font.getFont().deriveFont(shortSize));
      g2.setPaint(strokeC.brighter(100));
      float ht = UIUtils.getTextHeight(menu.canvas.g, font, shortSize, shortcut.label, true);
      float yOffset = (height - ht) / 2f + descent;
      yOffset += ht / 2;
      g2.drawString(shortcut.label, curX, y + yOffset);
    }
    curX += shortcutWidth;
    if (drawChildrenTriangle && items.size() > 0) {
      if (layoutMode == LAYOUT_BELOW && getState() != MenuItem.UP && !isOpen()) {
        curX = x + width / 2;
        at.setToIdentity();
        at.translate(curX, y + height + py / 2);
        at.rotate(PApplet.HALF_PI);
        Area a2 = tri.createTransformedArea(at);
        g2.setPaint(strokeC);
        g2.fill(a2);
      } else if (layoutMode != LAYOUT_BELOW) {
        curX = x + width - triWidth - px;
        at.setToIdentity();
        at.translate(curX, y + height / 2);
        Area a2 = tri.createTransformedArea(at);
        g2.setPaint(strokeC);
        g2.fill(a2);
      }
    }
  }
Exemplo n.º 3
0
 protected void drawBefore() {
   if (isOpen() && items.size() > 0)
     MenuUtils.drawBackgroundRoundRect(
         this, subItemRect.x, subItemRect.y, subItemRect.width, subItemRect.height);
 }