Exemplo n.º 1
0
 void setAutoScrollMarker() {
   int scrollPos = scrollbarV.getValue();
   AnimationState animationState = getAnimationState();
   animationState.setAnimationState(
       STATE_AUTO_SCROLL_UP, autoScrollDirection < 0 && scrollPos > 0);
   animationState.setAnimationState(
       STATE_AUTO_SCROLL_DOWN, autoScrollDirection > 0 && scrollPos < scrollbarV.getMaxValue());
 }
Exemplo n.º 2
0
 @Override
 protected void paint(GUI gui) {
   if (dragButton != null) {
     AnimationState as = dragButton.getAnimationState();
     as.setAnimationState(STATE_DOWNARROW_ARMED, scrollbarV.isDownRightButtonArmed());
     as.setAnimationState(STATE_RIGHTARROW_ARMED, scrollbarH.isDownRightButtonArmed());
   }
   super.paint(gui);
 }
  public void update() {
    AnimationState current = state;

    current = state.update(this);
    int t = 0;
    while (current != state) {
      state = current;
      current = state.update(this);

      t++;
      if (t > 6) break;
    }
  }
 static void paintSkin(
     JComponent component, Skin skin, Graphics g, int dx, int dy, int dw, int dh, State state) {
   if (VISTA_ANIMATION_DISABLED) {
     skin.paintSkinRaw(g, dx, dy, dw, dh, state);
     return;
   }
   triggerAnimation(component, skin.part, state);
   AnimationController controller = getAnimationController();
   synchronized (controller) {
     AnimationState animationState = null;
     Map<Part, AnimationState> map = controller.animationStateMap.get(component);
     if (map != null) {
       animationState = map.get(skin.part);
     }
     if (animationState != null) {
       animationState.paintSkin(skin, g, dx, dy, dw, dh, state);
     } else {
       skin.paintSkinRaw(g, dx, dy, dw, dh, state);
     }
   }
 }
 public Sprite getCurrentSprite() {
   return state.getAnimation().getCurrentSprite();
 }
Exemplo n.º 6
0
  @Override
  protected void layout() {
    if (content != null) {
      int innerWidth = getInnerWidth();
      int innerHeight = getInnerHeight();
      int availWidth = innerWidth;
      int availHeight = innerHeight;
      innerWidth += vscrollbarOffset.getX();
      innerHeight += hscrollbarOffset.getY();
      int scrollbarHX = hscrollbarOffset.getX();
      int scrollbarHY = innerHeight;
      int scrollbarVX = innerWidth;
      int scrollbarVY = vscrollbarOffset.getY();
      int requiredWidth;
      int requiredHeight;
      boolean repeat;
      boolean visibleH = false;
      boolean visibleV = false;

      switch (fixed) {
        case HORIZONTAL:
          requiredWidth = availWidth;
          requiredHeight = content.getPreferredHeight();
          break;
        case VERTICAL:
          requiredWidth = content.getPreferredWidth();
          requiredHeight = availHeight;
          break;
        default:
          requiredWidth = content.getPreferredWidth();
          requiredHeight = content.getPreferredHeight();
          break;
      }

      // System.out.println("required="+requiredWidth+","+requiredHeight+"
      // avail="+availWidth+","+availHeight);

      int hScrollbarMax = 0;
      int vScrollbarMax = 0;

      // don't add scrollbars if we have zero size
      if (availWidth > 0 && availHeight > 0) {
        do {
          repeat = false;

          if (fixed != Fixed.HORIZONTAL) {
            hScrollbarMax = Math.max(0, requiredWidth - availWidth);
            if (hScrollbarMax > 0
                || scrollbarsAlwaysVisible
                || ((scrollbarsToggleFlags & 3) == 3)) {
              repeat |= !visibleH;
              visibleH = true;
              int prefHeight = scrollbarH.getPreferredHeight();
              scrollbarHY = innerHeight - prefHeight;
              availHeight = Math.max(0, scrollbarHY - contentScrollbarSpacing.getY());
            }
          } else {
            hScrollbarMax = 0;
            requiredWidth = availWidth;
          }

          if (fixed != Fixed.VERTICAL) {
            vScrollbarMax = Math.max(0, requiredHeight - availHeight);
            if (vScrollbarMax > 0
                || scrollbarsAlwaysVisible
                || ((scrollbarsToggleFlags & 12) == 12)) {
              repeat |= !visibleV;
              visibleV = true;
              int prefWidth = scrollbarV.getPreferredWidth();
              scrollbarVX = innerWidth - prefWidth;
              availWidth = Math.max(0, scrollbarVX - contentScrollbarSpacing.getX());
            }
          } else {
            vScrollbarMax = 0;
            requiredHeight = availHeight;
          }
        } while (repeat);
      }

      // if a scrollbar visibility state has changed set it's flag to
      // detect layout loops
      if (visibleH && !scrollbarH.isVisible()) {
        scrollbarsToggleFlags |= 1;
      }
      if (!visibleH && scrollbarH.isVisible()) {
        scrollbarsToggleFlags |= 2;
      }
      if (visibleV && !scrollbarV.isVisible()) {
        scrollbarsToggleFlags |= 4;
      }
      if (!visibleV && scrollbarV.isVisible()) {
        scrollbarsToggleFlags |= 8;
      }

      boolean changedH = visibleH ^ scrollbarH.isVisible();
      boolean changedV = visibleV ^ scrollbarV.isVisible();
      if (changedH || changedV) {
        if ((changedH && fixed == Fixed.VERTICAL) || (changedV && fixed == Fixed.HORIZONTAL)) {
          invalidateLayout();
        } else {
          invalidateLayoutLocally();
        }
      }

      int pageSizeX, pageSizeY;
      if (content instanceof CustomPageSize) {
        CustomPageSize customPageSize = (CustomPageSize) content;
        pageSizeX = customPageSize.getPageSizeX(availWidth);
        pageSizeY = customPageSize.getPageSizeY(availHeight);
      } else {
        pageSizeX = availWidth;
        pageSizeY = availHeight;
      }

      scrollbarH.setVisible(visibleH);
      scrollbarH.setMinMaxValue(0, hScrollbarMax);
      scrollbarH.setSize(
          Math.max(0, scrollbarVX - scrollbarHX), Math.max(0, innerHeight - scrollbarHY));
      scrollbarH.setPosition(getInnerX() + scrollbarHX, getInnerY() + scrollbarHY);
      scrollbarH.setPageSize(Math.max(1, pageSizeX));
      scrollbarH.setStepSize(Math.max(1, pageSizeX / 10));

      scrollbarV.setVisible(visibleV);
      scrollbarV.setMinMaxValue(0, vScrollbarMax);
      scrollbarV.setSize(
          Math.max(0, innerWidth - scrollbarVX), Math.max(0, scrollbarHY - scrollbarVY));
      scrollbarV.setPosition(getInnerX() + scrollbarVX, getInnerY() + scrollbarVY);
      scrollbarV.setPageSize(Math.max(1, pageSizeY));
      scrollbarV.setStepSize(Math.max(1, pageSizeY / 10));

      if (dragButton != null) {
        dragButton.setVisible(visibleH && visibleV);
        dragButton.setSize(
            Math.max(0, innerWidth - scrollbarVX), Math.max(0, innerHeight - scrollbarHY));
        dragButton.setPosition(getInnerX() + scrollbarVX, getInnerY() + scrollbarHY);
      }

      contentArea.setPosition(getInnerX(), getInnerY());
      contentArea.setSize(availWidth, availHeight);
      if (content instanceof Scrollable) {
        content.setPosition(contentArea.getX(), contentArea.getY());
        content.setSize(availWidth, availHeight);
      } else if (expandContentSize) {
        content.setSize(Math.max(availWidth, requiredWidth), Math.max(availHeight, requiredHeight));
      } else {
        content.setSize(Math.max(0, requiredWidth), Math.max(0, requiredHeight));
      }

      AnimationState animationState = getAnimationState();
      animationState.setAnimationState(STATE_HORIZONTAL_SCROLLBAR_VISIBLE, visibleH);
      animationState.setAnimationState(STATE_VERTICAL_SCROLLBAR_VISIBLE, visibleV);

      scrollContent();
    } else {
      scrollbarH.setVisible(false);
      scrollbarV.setVisible(false);
    }
  }