if (child instanceof Layout) { Layout layout = (Layout)child; prefWidth = Math.max(prefWidth, layout.getPrefWidth()); prefHeight = Math.max(prefHeight, layout.getPrefHeight()); minWidth = Math.max(minWidth, layout.getMinWidth()); minHeight = Math.max(minHeight, layout.getMinHeight()); childMaxWidth = layout.getMaxWidth(); childMaxHeight = layout.getMaxHeight(); } else { prefWidth = Math.max(prefWidth, child.getWidth());
@Override public void layout () { clampSplitAmount(); 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(); } }
public void invalidateHierarchy () { if (!layoutEnabled) return; invalidate(); Group parent = getParent(); if (parent instanceof Layout) ((Layout)parent).invalidateHierarchy(); }
/** Called during layout to clamp the {@link #splitAmount} within the set limits. By default it imposes the limits of the * {@linkplain #getMinSplitAmount() min amount}, {@linkplain #getMaxSplitAmount() max amount}, and min sizes of the children. This * method is internally called in response to layout, so it should not call {@link #invalidate()}. */ protected void clampSplitAmount () { float effectiveMinAmount = minAmount, effectiveMaxAmount = maxAmount; if (vertical){ float availableHeight = getHeight() - style.handle.getMinHeight(); if (firstWidget instanceof Layout) effectiveMinAmount = Math.max(effectiveMinAmount, Math.min(((Layout)firstWidget).getMinHeight() / availableHeight, 1)); if (secondWidget instanceof Layout) effectiveMaxAmount = Math.min(effectiveMaxAmount, 1 - Math.min(((Layout)secondWidget).getMinHeight() / availableHeight, 1)); } else { float availableWidth = getWidth() - style.handle.getMinWidth(); if (firstWidget instanceof Layout) effectiveMinAmount = Math.max(effectiveMinAmount, Math.min(((Layout)firstWidget).getMinWidth() / availableWidth, 1)); if (secondWidget instanceof Layout) effectiveMaxAmount = Math.min(effectiveMaxAmount, 1 - Math.min(((Layout)secondWidget).getMinWidth() / availableWidth, 1)); } if (effectiveMinAmount > effectiveMaxAmount) // Locked handle. Average the position. splitAmount = 0.5f * (effectiveMinAmount + effectiveMaxAmount); else splitAmount = Math.max(Math.min(splitAmount, effectiveMaxAmount), effectiveMinAmount); }
private void computeSize (Array<Node> nodes, float indent, float plusMinusWidth) { 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 + plusMinusWidth; Actor actor = node.actor; if (actor instanceof Layout) { Layout layout = (Layout)actor; rowWidth += layout.getPrefWidth(); node.height = layout.getPrefHeight(); } 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()); } prefWidth = Math.max(prefWidth, rowWidth); prefHeight -= node.height + ySpacing; if (node.expanded) computeSize(node.children, indent + indentSpacing, plusMinusWidth); } }
if (child instanceof Layout) { layout = (Layout)child; width = layout.getPrefWidth(); height = layout.getPrefHeight(); if (height > groupHeight) height = Math.max(groupHeight, layout.getMinHeight()); } else { width = child.getWidth(); width = Math.max(width, layout.getMinWidth()); float maxWidth = layout.getMaxWidth(); if (maxWidth > 0 && width > maxWidth) width = maxWidth; child.setBounds(x, y, width, height); if (layout != null) layout.validate();
if (child instanceof Layout) { layout = (Layout)child; width = layout.getPrefWidth(); if (width > groupWidth) width = Math.max(groupWidth, layout.getMinWidth()); height = layout.getPrefHeight(); } else { width = child.getWidth(); height = Math.max(height, layout.getMinHeight()); float maxHeight = layout.getMaxHeight(); if (maxHeight > 0 && height > maxHeight) height = maxHeight; x += width + space; if (layout != null) layout.validate();
if (child instanceof Layout) { Layout layout = (Layout)child; width = layout.getPrefWidth(); if (width > groupWidth) width = Math.max(groupWidth, layout.getMinWidth()); height = layout.getPrefHeight(); } else { width = child.getWidth(); if (child instanceof Layout) { Layout layout = (Layout)child; prefWidth += layout.getPrefWidth(); prefHeight = Math.max(prefHeight, layout.getPrefHeight()); } else { prefWidth += child.getWidth();
if (child instanceof Layout) { Layout layout = (Layout)child; width = layout.getPrefWidth(); height = layout.getPrefHeight(); if (height > groupHeight) height = Math.max(groupHeight, layout.getMinHeight()); } else { width = child.getWidth(); if (child instanceof Layout) { Layout layout = (Layout)child; prefWidth = Math.max(prefWidth, layout.getPrefWidth()); prefHeight += layout.getPrefHeight(); } else { prefWidth = Math.max(prefWidth, child.getWidth());
if (widget instanceof Layout) { Layout layout = (Layout)widget; widgetWidth = layout.getPrefWidth(); widgetHeight = layout.getPrefHeight(); } else { widgetWidth = widget.getWidth(); if (widget instanceof Layout) ((Layout)widget).validate();
private void computeSize (Array<Node> nodes, float indent, float plusMinusWidth) { 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 + plusMinusWidth; 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()); } prefWidth = Math.max(prefWidth, rowWidth); prefHeight -= node.height + ySpacing; if (node.expanded) computeSize(node.children, indent + indentSpacing, plusMinusWidth); } }
public float get (Actor context) { if (context instanceof Layout) return ((Layout)context).getPrefWidth(); return context == null ? 0 : context.getWidth(); } };
public float get (Actor context) { if (context instanceof Layout) return ((Layout)context).getPrefHeight(); return context == null ? 0 : context.getHeight(); } };
public float getMinWidth () { float first = firstWidget instanceof Layout ? ((Layout)firstWidget).getMinWidth() : 0; float second = secondWidget instanceof Layout ? ((Layout)secondWidget).getMinWidth() : 0; if (vertical) return Math.max(first, second); return first + style.handle.getMinWidth() + second; }
public float getMinHeight () { float first = firstWidget instanceof Layout ? ((Layout)firstWidget).getMinHeight() : 0; float second = secondWidget instanceof Layout ? ((Layout)secondWidget).getMinHeight() : 0; if (!vertical) return Math.max(first, second); return first + style.handle.getMinHeight() + second; }
public float get (Actor context) { if (context instanceof Layout) return ((Layout)context).getMaxWidth(); return context == null ? 0 : context.getWidth(); } };
public float get (Actor context) { if (context instanceof Layout) return ((Layout)context).getMaxHeight(); return context == null ? 0 : context.getHeight(); } };
public boolean act (float delta) { ((Layout)target).setLayoutEnabled(enabled); return true; }
private float layout (Array<Node> nodes, float indent, float y, float plusMinusWidth) { float ySpacing = this.ySpacing; float spacing = iconSpacingLeft + iconSpacingRight; for (int i = 0, n = nodes.size; i < n; i++) { Node node = nodes.get(i); float x = indent + plusMinusWidth; if (node.icon != null) x += spacing + node.icon.getMinWidth(); if (node.actor instanceof Layout) ((Layout)node.actor).pack(); y -= node.getHeight(); node.actor.setPosition(x, y); y -= ySpacing; if (node.expanded) y = layout(node.children, indent + indentSpacing, y, plusMinusWidth); } return y; }
if (child instanceof Layout) { layout = (Layout)child; width = layout.getPrefWidth(); height = layout.getPrefHeight(); } else { width = child.getWidth(); width = Math.max(width, layout.getMinWidth()); float maxWidth = layout.getMaxWidth(); if (maxWidth > 0 && width > maxWidth) width = maxWidth; child.setBounds(x, y, width, height); if (layout != null) layout.validate();