コード例 #1
0
  @Override
  public void updatePosition(int parentX, int parentY, int parentSizeX, int parentSizeY) {
    // at most as big as the parent
    this.ySize = calcCappedYSize(parentSizeY - 10);
    // slider needed?
    if (getDisplayedRows() < getTotalRows()) {
      slider.enable();
      this.xSize = columns * slot.w + slider.width + 2 * border.w;
    } else {
      slider.disable();
      this.xSize = columns * slot.w + border.w * 2;
    }

    // update position
    super.updatePosition(parentX, parentY, parentSizeX, parentSizeY);

    // connected needs to move to the side
    if (connected) {
      if (yOffset == 0) {
        if (right) {
          border.cornerTopLeft = overlapTop;
        } else {
          border.cornerTopRight = overlapTop;
        }
      }

      xOffset = (border.w - 1) * (right ? -1 : 1);
      guiLeft += xOffset;
    } else {
      xOffset = 0;
    }

    // move it a bit
    this.guiTop += yOffset;

    border.setPosition(guiLeft, guiTop);
    border.setSize(xSize, ySize);

    int y = guiTop + border.h;
    int h = ySize - border.h * 2;

    if (shouldDrawName()) {
      y += textBackground.h;
      h -= textBackground.h;
    }
    slider.setPosition(guiLeft + columns * slot.w + border.w, y);
    slider.setSize(h);
    slider.setSliderParameters(0, getTotalRows() - getDisplayedRows(), 1);

    updateSlots();
  }
コード例 #2
0
  protected void updateSlider() {
    int max = 0;
    if (sliderActive) {
      slider.show();
      max =
          slotCount / columns
              - rows
              + 1; // the assumption here is that for an active slider this always is >0
    } else {
      slider.hide();
    }

    slider.setPosition(guiLeft + xSize - slider.width, guiTop);
    slider.setSize(ySize);
    slider.setSliderParameters(0, max, 1);
  }