Package com.badlogic.gdx.scenes.scene2d

Examples of com.badlogic.gdx.scenes.scene2d.Actor


      private void focusChanged (FocusEvent event) {
        Stage stage = getStage();
        if (isModal && stage != null && stage.getRoot().getChildren().size > 0
          && stage.getRoot().getChildren().peek() == Dialog.this) { // Dialog is top most actor.
          Actor newFocusedActor = event.getRelatedActor();
          if (newFocusedActor != null && !newFocusedActor.isDescendantOf(Dialog.this)) event.cancel();
        }
      }
    });
  }
View Full Code Here


  public Dialog show (Stage stage) {
    clearActions();
    removeCaptureListener(ignoreTouchDown);

    previousKeyboardFocus = null;
    Actor actor = stage.getKeyboardFocus();
    if (actor != null && !actor.isDescendantOf(this)) previousKeyboardFocus = actor;

    previousScrollFocus = null;
    actor = stage.getScrollFocus();
    if (actor != null && !actor.isDescendantOf(this)) stage.setScrollFocus(previousScrollFocus);

    pack();
    setPosition(Math.round((stage.getWidth() - getWidth()) / 2), Math.round((stage.getHeight() - getHeight()) / 2));
    stage.addActor(this);
    stage.setKeyboardFocus(this);
View Full Code Here

    super.setParent(parent);
    if (parent == null) {
      Stage stage = getStage();
      if (stage != null) {
        if (previousKeyboardFocus != null && previousKeyboardFocus.getStage() == null) previousKeyboardFocus = null;
        Actor actor = stage.getKeyboardFocus();
        if (actor == null || actor.isDescendantOf(this)) stage.setKeyboardFocus(previousKeyboardFocus);

        if (previousScrollFocus != null && previousScrollFocus.getStage() == null) previousScrollFocus = null;
        actor = stage.getScrollFocus();
        if (actor == null || actor.isDescendantOf(this)) stage.setScrollFocus(previousScrollFocus);
      }
    }
  }
View Full Code Here

        float widgetWidth = Math.round(c.getWidgetWidth());
        float widgetHeight = Math.round(c.getWidgetHeight());
        float widgetX = Math.round(c.getWidgetX());
        float widgetY = height - Math.round(c.getWidgetY()) - widgetHeight;
        c.setWidgetBounds(widgetX, widgetY, widgetWidth, widgetHeight);
        Actor actor = (Actor)c.getWidget();
        if (actor != null) actor.setBounds(widgetX, widgetY, widgetWidth, widgetHeight);
      }
    } else {
      for (int i = 0, n = cells.size(); i < n; i++) {
        Cell c = cells.get(i);
        if (c.getIgnore()) continue;
        float widgetHeight = c.getWidgetHeight();
        float widgetY = height - c.getWidgetY() - widgetHeight;
        c.setWidgetY(widgetY);
        Actor actor = (Actor)c.getWidget();
        if (actor != null) actor.setBounds(c.getWidgetX(), widgetY, c.getWidgetWidth(), widgetHeight);
      }
    }
    // Validate children separately from sizing actors to ensure actors without a cell are validated.
    Array<Actor> children = table.getChildren();
    for (int i = 0, n = children.size; i < n; i++) {
      Actor child = children.get(i);
      if (child instanceof Layout) ((Layout)child).validate();
    }
  }
View Full Code Here

      else
        debugRenderer = new ImmediateModeRenderer10(64);
    }

    float x = 0, y = 0;
    Actor parent = getTable();
    while (parent != null) {
      if (parent instanceof Group) {
        x += parent.getX();
        y += parent.getY();
      }
      parent = parent.getParent();
    }

    debugRenderer.begin(batch.getProjectionMatrix(), GL10.GL_LINES);
    for (int i = 0, n = debugRects.size; i < n; i++) {
      DebugRect rect = debugRects.get(i);
View Full Code Here

    if (!vertical)
      calculateHorizBoundsAndPositions();
    else
      calculateVertBoundsAndPositions();

    Actor firstWidget = this.firstWidget;
    if (firstWidget != null) {
      Rectangle firstWidgetBounds = this.firstWidgetBounds;
      firstWidget.setBounds(firstWidgetBounds.x, firstWidgetBounds.y, firstWidgetBounds.width, firstWidgetBounds.height);
      if (firstWidget instanceof Layout) ((Layout)firstWidget).validate();
    }
    Actor secondWidget = this.secondWidget;
    if (secondWidget != null) {
      Rectangle secondWidgetBounds = this.secondWidgetBounds;
      secondWidget.setBounds(secondWidgetBounds.x, secondWidgetBounds.y, secondWidgetBounds.width, secondWidgetBounds.height);
      if (secondWidget instanceof Layout) ((Layout)secondWidget).validate();
    }
  }
View Full Code Here

      Gdx.input.setOnscreenKeyboardVisible(false);
  }

  private TextField findNextTextField (Array<Actor> actors, TextField best, Vector2 bestCoords, Vector2 currentCoords, boolean up) {
    for (int i = 0, n = actors.size; i < n; i++) {
      Actor actor = actors.get(i);
      if (actor == this) continue;
      if (actor instanceof TextField) {
        TextField textField = (TextField)actor;
        if (textField.isDisabled() || !textField.focusTraversal) continue;
        Vector2 actorCoords = actor.getParent().localToStageCoordinates(tmp3.set(actor.getX(), actor.getY()));
        if ((actorCoords.y < currentCoords.y || (actorCoords.y == currentCoords.y && actorCoords.x > currentCoords.x)) ^ up) {
          if (best == null
            || (actorCoords.y > bestCoords.y || (actorCoords.y == bestCoords.y && actorCoords.x < bestCoords.x)) ^ up) {
            best = (TextField)actor;
            bestCoords.set(actorCoords);
View Full Code Here

    float ySpacing = this.ySpacing;
    float spacing = iconSpacingLeft + iconSpacingRight;
    for (int i = 0, n = nodes.size; i < n; i++) {
      Node node = nodes.get(i);
      float rowWidth = indent + iconSpacingRight;
      Actor actor = node.actor;
      if (actor instanceof Layout) {
        Layout layout = (Layout)actor;
        rowWidth += layout.getPrefWidth();
        node.height = layout.getPrefHeight();
        layout.pack();
      } else {
        rowWidth += actor.getWidth();
        node.height = actor.getHeight();
      }
      if (node.icon != null) {
        rowWidth += spacing + node.icon.getMinWidth();
        node.height = Math.max(node.height, node.icon.getMinHeight());
      }
View Full Code Here

  private float layout (Array<Node> nodes, float indent, float y) {
    float ySpacing = this.ySpacing;
    for (int i = 0, n = nodes.size; i < n; i++) {
      Node node = nodes.get(i);
      Actor actor = node.actor;
      float x = indent;
      if (node.icon != null) x += node.icon.getMinWidth();
      y -= node.height;
      node.actor.setPosition(x, y);
      y -= ySpacing;
View Full Code Here

  private void draw (SpriteBatch batch, Array<Node> nodes, float indent) {
    Drawable plus = style.plus, minus = style.minus;
    float x = getX(), y = getY();
    for (int i = 0, n = nodes.size; i < n; i++) {
      Node node = nodes.get(i);
      Actor actor = node.actor;

      if (selectedNodes.contains(node, true) && style.selection != null) {
        style.selection.draw(batch, x, y + actor.getY() - ySpacing / 2, getWidth(), node.height + ySpacing);
      } else if (node == overNode && style.over != null) {
        style.over.draw(batch, x, y + actor.getY() - ySpacing / 2, getWidth(), node.height + ySpacing);
      }

      if (node.icon != null) {
        float iconY = actor.getY() + Math.round((node.height - node.icon.getMinHeight()) / 2);
        batch.setColor(actor.getColor());
        node.icon.draw(batch, x + node.actor.getX() - iconSpacingRight - node.icon.getMinWidth(), y + iconY,
          node.icon.getMinWidth(), node.icon.getMinHeight());
        batch.setColor(Color.WHITE);
      }

      if (node.children.size == 0) continue;

      Drawable expandIcon = node.expanded ? minus : plus;
      float iconY = actor.getY() + Math.round((node.height - expandIcon.getMinHeight()) / 2);
      expandIcon.draw(batch, x + indent - iconSpacingLeft, y + iconY, expandIcon.getMinWidth(), expandIcon.getMinHeight());
      if (node.expanded) draw(batch, node.children, indent + indentSpacing);
    }
  }
View Full Code Here

TOP

Related Classes of com.badlogic.gdx.scenes.scene2d.Actor

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.