示例#1
0
  @Override
  public void draw(Batch batch, float parentAlpha) {
    validate();

    Color color = getColor();

    Drawable handle = style.handle;
    applyTransform(batch, computeTransform());
    Matrix4 transform = batch.getTransformMatrix();
    if (firstWidget != null) {
      getStage().calculateScissors(firstWidgetBounds, firstScissors);
      if (ScissorStack.pushScissors(firstScissors)) {
        if (firstWidget.isVisible()) firstWidget.draw(batch, parentAlpha * color.a);
        batch.flush();
        ScissorStack.popScissors();
      }
    }
    if (secondWidget != null) {
      getStage().calculateScissors(secondWidgetBounds, secondScissors);
      if (ScissorStack.pushScissors(secondScissors)) {
        if (secondWidget.isVisible()) secondWidget.draw(batch, parentAlpha * color.a);
        batch.flush();
        ScissorStack.popScissors();
      }
    }
    batch.setColor(color.r, color.g, color.b, parentAlpha * color.a);
    handle.draw(batch, handleBounds.x, handleBounds.y, handleBounds.width, handleBounds.height);
    resetTransform(batch);
  }
示例#2
0
  public void updateProperties() {
    if (editActors == null) return;

    updateProperties = true;

    Actor model = editActors.get(0);
    getStage().setKeyboardFocus(null);
    name.setText(model.getName());
    visible.setChecked(model.isVisible());
    positionX.setText(String.format(Locale.ENGLISH, "%.2f", model.getX()));
    positionY.setText(String.format(Locale.ENGLISH, "%.2f", model.getY()));
    rotation.setText(String.format(Locale.ENGLISH, "%.2f", model.getRotation()));
    lockRatio.setChecked(Math.abs(model.getScaleX() - model.getScaleY()) < 0.01f);
    scaleX.setText(String.format(Locale.ENGLISH, "%.2f", model.getScaleX()));
    scaleY.setText(String.format(Locale.ENGLISH, "%.2f", model.getScaleY()));
    Color color = model.getColor();
    r.setText(String.format(Locale.ENGLISH, "%.0f", color.r * 255));
    g.setText(String.format(Locale.ENGLISH, "%.0f", color.g * 255));
    b.setText(String.format(Locale.ENGLISH, "%.0f", color.b * 255));
    a.setText(String.format(Locale.ENGLISH, "%.0f", color.a * 255));

    scaleY.setDisabled(lockRatio.isChecked());
    scaleY.setColor(lockRatio.isChecked() ? disableColor : enableColor);

    updateProperties = false;
  }
示例#3
0
  private void drawRecursive(Actor actor) {
    if (!invisibleActors && !actor.isVisible()) return;

    if (allActors) actor.debug();

    if (actor.getDebug()) {
      actor.getDebugRects(debugRects);
      for (DebugRect debugRect : debugRects) drawRect(actor, debugRect);
      debugRects.clear();
      debugRectPool.freeAll(usedRects);
      usedRects.clear();
    }

    boolean draw = true;
    Rectangle scissorBounds = null;
    if (actor instanceof Group) scissorBounds = ((Group) actor).getScissorBounds();
    if (scissorBounds != null) {
      shapes.flush();
      draw = ScissorStack.pushScissors(scissorBounds);
    }
    if (draw) {
      // Children are still rendered, even if the group has no debugging enabled.
      if (actor instanceof Group) {
        Group group = (Group) actor;
        for (Actor child : group.getChildren()) drawRecursive(child);
      }

      if (scissorBounds != null) {
        shapes.flush();
        ScissorStack.popScissors();
      }
    }
  }
示例#4
0
 private static void drawDebug(Array<Actor> actors, Batch batch) {
   for (int i = 0, n = actors.size; i < n; i++) {
     Actor actor = actors.get(i);
     if (!actor.isVisible()) continue;
     if (actor instanceof Table) ((Table) actor).layout.drawDebug(batch);
     if (actor instanceof Group) drawDebug(((Group) actor).getChildren(), batch);
   }
 }
 private Actor setupLastElement() {
   final int nextElement = (currentElement - 1 + getChildren().size) % getChildren().size;
   final Actor next = getChildren().get(nextElement);
   if (!next.isVisible()) {
     next.getColor().a = 0;
     next.setVisible(true);
     next.setPosition(-animationXOffset, 0);
     next.clearActions();
   }
   return next;
 }
示例#6
0
文件: Group.java 项目: btdiehr/libgdx
 public Actor hit(float x, float y) {
   if (getTouchable() == Touchable.disabled) return null;
   Array<Actor> children = this.children;
   for (int i = children.size - 1; i >= 0; i--) {
     Actor child = children.get(i);
     if (!child.isVisible()) continue;
     child.parentToLocalCoordinates(point.set(x, y));
     Actor hit = child.hit(point.x, point.y);
     if (hit != null) return hit;
   }
   return super.hit(x, y);
 }
示例#7
0
文件: Group.java 项目: btdiehr/libgdx
 /**
  * Draws all children. {@link #applyTransform(SpriteBatch)} should be called before and {@link
  * #resetTransform(SpriteBatch)} after this method if {@link #setTransform(boolean) transform} is
  * true. If {@link #setTransform(boolean) transform} is false these methods don't need to be
  * called, children positions are temporarily offset by the group position when drawn. This method
  * avoids drawing children completely outside the {@link #setCullingArea(Rectangle) culling area},
  * if set.
  */
 protected void drawChildren(SpriteBatch batch, float parentAlpha) {
   parentAlpha *= getColor().a;
   DelayedRemovalArray<Actor> children = this.children;
   children.begin();
   if (cullingArea != null) {
     // Draw children only if inside culling area.
     if (transform) {
       for (int i = 0, n = children.size; i < n; i++) {
         Actor child = children.get(i);
         if (!child.isVisible()) continue;
         float x = child.getX();
         float y = child.getY();
         if (x <= cullingArea.x + cullingArea.width
             && y <= cullingArea.y + cullingArea.height
             && x + child.getWidth() >= cullingArea.x
             && y + child.getHeight() >= cullingArea.y) {
           child.draw(batch, parentAlpha);
         }
       }
       batch.flush();
     } else {
       // No transform for this group, offset each child.
       float offsetX = getX();
       float offsetY = getY();
       setPosition(0, 0);
       for (int i = 0, n = children.size; i < n; i++) {
         Actor child = children.get(i);
         if (!child.isVisible()) continue;
         float x = child.getX();
         float y = child.getY();
         if (x <= cullingArea.x + cullingArea.width
             && y <= cullingArea.y + cullingArea.height
             && x + child.getWidth() >= cullingArea.x
             && y + child.getHeight() >= cullingArea.y) {
           child.translate(offsetX, offsetY);
           child.draw(batch, parentAlpha);
           child.setPosition(x, y);
         }
       }
       setPosition(offsetX, offsetY);
     }
   } else {
     if (transform) {
       for (int i = 0, n = children.size; i < n; i++) {
         Actor child = children.get(i);
         if (!child.isVisible()) continue;
         child.draw(batch, parentAlpha);
       }
       batch.flush();
     } else {
       // No transform for this group, offset each child.
       float offsetX = getX();
       float offsetY = getY();
       setPosition(0, 0);
       for (int i = 0, n = children.size; i < n; i++) {
         Actor child = children.get(i);
         if (!child.isVisible()) continue;
         float x = child.getX();
         float y = child.getY();
         child.translate(offsetX, offsetY);
         child.draw(batch, parentAlpha);
         child.setPosition(x, y);
       }
       setPosition(offsetX, offsetY);
     }
   }
   children.end();
 }