Package com.badlogic.gdx.scenes.scene2d

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


      actor.x = 0;
      actor.y = 0;
      actor.width = width;
      actor.height = height;
      if (actor instanceof Layout) {
        Layout layout = (Layout)actor;
        layout.invalidate();
        layout.layout();
      }
    }
  }
View Full Code Here


    float areaHeight = height - background.getTopHeight() - background.getBottomHeight();

    // Get widget's desired width.
    float widgetWidth, widgetHeight;
    if (widget instanceof Layout) {
      Layout layout = (Layout)widget;
      widgetWidth = layout.getPrefWidth();
      widgetHeight = layout.getPrefHeight();
    } else {
      widgetWidth = widget.width;
      widgetHeight = widget.height;
    }

    // Figure out if we need horizontal/vertical scrollbars,
    hasHScroll = false;
    hasVScroll = false;
    if (widgetWidth > areaWidth) hasHScroll = true;
    if (widgetHeight > areaHeight) hasVScroll = true;

    // Check again, now taking into account the area that's taken up by any enabled scrollbars.
    if (hasVScroll && (widgetWidth > areaWidth - vScrollKnob.getTotalWidth())) {
      hasHScroll = true;
      areaWidth -= vScrollKnob.getTotalWidth();
    }
    if (hasHScroll && (widgetHeight > areaHeight - hScrollKnob.getTotalHeight())) {
      hasVScroll = true;
      areaHeight -= hScrollKnob.getTotalHeight();
    }

    // If the widget is smaller than the available space, make it take up the available space.
    widgetWidth = Math.max(areaWidth, widgetWidth);
    widgetHeight = Math.max(areaHeight, widgetHeight);
    if (widget.width != widgetWidth || widget.height != widgetHeight) {
      widget.width = widgetWidth;
      widget.height = widgetHeight;
      if (widget instanceof Layout) {
        Layout layout = (Layout)widget;
        layout.invalidate();
        layout.layout();
      }
    }

    // Set the bounds and scroll knob sizes if scrollbars are needed.
    if (hasHScroll) {
View Full Code Here

  private void calculateBoundsAndPositions (Matrix4 batchTransform) {
    // Get widget's desired width.
    float widgetWidth, widgetHeight;
    if (widget instanceof Layout) {
      Layout layout = (Layout)widget;
      widgetWidth = layout.getPrefWidth();
      widgetHeight = layout.getPrefHeight();
    } else {
      widgetWidth = widget.width;
      widgetHeight = widget.height;
    }
View Full Code Here

  @Override
  public void layout () {
    if (!needsLayout) return;
    needsLayout = false;
    if (widget instanceof Layout) {
      Layout layout = (Layout)widget;
      layout.invalidate();
      layout.layout();
    }
  }
View Full Code Here

      int widgetHeight = c.getWidgetHeight();
      actor.y = table.height - c.getWidgetY() - widgetHeight;
      actor.width = c.getWidgetWidth();
      actor.height = widgetHeight;
      if (actor instanceof Layout) {
        Layout layout = (Layout)actor;
        layout.invalidate();
        layout.layout();
      }
    }
  }
View Full Code Here

  public void layout () {
    if (!invalidated) return;
    invalidated = false;

    if (firstWidget instanceof Layout) {
      Layout layout = (Layout)firstWidget;
      layout.layout();
      firstWidget.width = layout.getPrefWidth();
      firstWidget.height = layout.getPrefHeight();
    }
    if (secondWidget instanceof Layout) {
      Layout layout = (Layout)secondWidget;
      layout.layout();
      secondWidget.width = layout.getPrefWidth();
      secondWidget.height = layout.getPrefHeight();
    }
  }
View Full Code Here

    if (widget == null) return;
   
    // Get widget's desired width.
    float widgetWidth, widgetHeight;
    if (widget instanceof Layout) {
      Layout layout = (Layout)widget;
      widgetWidth = layout.getPrefWidth();
      widgetHeight = layout.getPrefHeight();
    } else {
      widgetWidth = widget.width;
      widgetHeight = widget.height;
    }

    // Figure out if we need horizontal/vertical scrollbars.
    scrollX = false;
    scrollY = false;
    if (!disableX && widgetWidth > areaWidth) scrollX = true;
    if (!disableY && widgetHeight > areaHeight) scrollY = true;

    // Check again, now taking into account the area that's taken up by any enabled scrollbars.
    if (!disableX && scrollY && widgetWidth > areaWidth - vScrollKnob.getTotalWidth()) {
      scrollX = true;
      areaWidth -= vScrollKnob.getTotalWidth();
    }
    if (!disableY && scrollX && widgetHeight > areaHeight - hScrollKnob.getTotalHeight()) {
      scrollY = true;
      areaHeight -= hScrollKnob.getTotalHeight();
    }

    // Set the widget area bounds.
    widgetAreaBounds.set(bgLeftWidth, bgBottomHeight + (scrollX ? hScrollKnob.getTotalHeight() : 0), areaWidth, areaHeight);
    amountX = MathUtils.clamp(amountX, 0, widgetAreaBounds.x);
    amountY = MathUtils.clamp(amountY, 0, widgetAreaBounds.y);

    // If the widget is smaller than the available space, make it take up the available space.
    widgetWidth = disableX ? width : Math.max(areaWidth, widgetWidth);
    widgetHeight = disableY ? height : Math.max(areaHeight, widgetHeight);
    if (widget.width != widgetWidth || widget.height != widgetHeight) {
      widget.width = widgetWidth;
      widget.height = widgetHeight;
    }

    // Set the bounds and scroll knob sizes if scrollbars are needed.
    if (scrollX) {
      hScrollBounds.set(bgLeftWidth, bgBottomHeight, areaWidth, hScrollKnob.getTotalHeight());
      hKnobBounds.width = Math.max(hScrollKnob.getTotalWidth(), (int)(hScrollBounds.width * areaWidth / widget.width));
      hKnobBounds.height = hScrollKnob.getTotalHeight();
      hKnobBounds.x = hScrollBounds.x + (int)((hScrollBounds.width - hKnobBounds.width) * getScrollPercentX());
      hKnobBounds.y = hScrollBounds.y;
    }
    if (scrollY) {
      vScrollBounds.set(width - bgRightWidth - vScrollKnob.getTotalWidth(), height - bgTopHeight - areaHeight,
        vScrollKnob.getTotalWidth(), areaHeight);
      vKnobBounds.width = vScrollKnob.getTotalWidth();
      vKnobBounds.height = Math.max(vScrollKnob.getTotalHeight(), (int)(vScrollBounds.height * areaHeight / widget.height));
      vKnobBounds.x = vScrollBounds.x;
      vKnobBounds.y = vScrollBounds.y + (int)((vScrollBounds.height - vKnobBounds.height) * (1 - getScrollPercentY()));
    }

    if (widget instanceof Layout) {
      Layout layout = (Layout)widget;
      layout.invalidate();
      layout.validate();
    }
  }
View Full Code Here

      firstWidget.x = firstWidgetBounds.x;
      firstWidget.y = firstWidgetBounds.y;
      firstWidget.width = firstWidgetBounds.width;
      firstWidget.height = firstWidgetBounds.height;
      if (firstWidget instanceof Layout) {
        Layout layout = (Layout)firstWidget;
        layout.invalidate();
        layout.validate();
      }
    }
    if (secondWidget != null && secondWidget.width != secondWidgetBounds.width
      || secondWidget.height != secondWidgetBounds.height) {
      secondWidget.x = secondWidgetBounds.x;
      secondWidget.y = secondWidgetBounds.y;
      secondWidget.width = secondWidgetBounds.width;
      secondWidget.height = secondWidgetBounds.height;
      if (secondWidget instanceof Layout) {
        Layout layout = (Layout)secondWidget;
        layout.invalidate();
        layout.validate();
      }
    }
  }
View Full Code Here

TOP

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

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.