Ejemplo n.º 1
0
  /**
   * Sets the scroll offset so the specified rectangle is fully in view, if possible. Coordinates
   * are in the scroll pane widget's coordinate system.
   */
  public void scrollTo(float x, float y, float width, float height) {
    float amountX = this.amountX;
    if (x + width > amountX + areaWidth) amountX = x + width - areaWidth;
    if (x < amountX) amountX = x;
    scrollX(MathUtils.clamp(amountX, 0, maxX));

    float amountY = this.amountY;
    if (amountY > maxY - y - height + areaHeight) amountY = maxY - y - height + areaHeight;
    if (amountY < maxY - y) amountY = maxY - y;
    scrollY(MathUtils.clamp(amountY, 0, maxY));
  }
Ejemplo n.º 2
0
  /**
   * Sets the scroll offset so the specified rectangle is fully in view and centered vertically in
   * the scroll pane, if possible. Coordinates are in the scroll pane widget's coordinate system.
   */
  public void scrollToCenter(float x, float y, float width, float height) {
    float amountX = this.amountX;
    if (x + width > amountX + areaWidth) amountX = x + width - areaWidth;
    if (x < amountX) amountX = x;
    scrollX(MathUtils.clamp(amountX, 0, maxX));

    float amountY = this.amountY;
    float centerY = maxY - y + areaHeight / 2 - height / 2;
    if (amountY < centerY - areaHeight / 4 || amountY > centerY + areaHeight / 4) amountY = centerY;
    scrollY(MathUtils.clamp(amountY, 0, maxY));
  }
Ejemplo n.º 3
0
 void clamp() {
   if (!clamp) return;
   scrollX(
       overscrollX
           ? MathUtils.clamp(amountX, -overscrollDistance, maxX + overscrollDistance)
           : MathUtils.clamp(amountX, 0, maxX));
   scrollY(
       overscrollY
           ? MathUtils.clamp(amountY, -overscrollDistance, maxY + overscrollDistance)
           : MathUtils.clamp(amountY, 0, maxY));
 }