当前位置: 首页>>代码示例>>Java>>正文


Java Layout.getPrefWidth方法代码示例

本文整理汇总了Java中com.badlogic.gdx.scenes.scene2d.utils.Layout.getPrefWidth方法的典型用法代码示例。如果您正苦于以下问题:Java Layout.getPrefWidth方法的具体用法?Java Layout.getPrefWidth怎么用?Java Layout.getPrefWidth使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.badlogic.gdx.scenes.scene2d.utils.Layout的用法示例。


在下文中一共展示了Layout.getPrefWidth方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: computeSize

import com.badlogic.gdx.scenes.scene2d.utils.Layout; //导入方法依赖的package包/类
private void computeSize (Array<Node> nodes, float indent) {
	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());
		}
		prefWidth = Math.max(prefWidth, rowWidth);
		prefHeight -= node.height + ySpacing;
		if (node.expanded) computeSize(node.children, indent + indentSpacing);
	}
}
 
开发者ID:basherone,项目名称:libgdxcn,代码行数:26,代码来源:Tree.java

示例2: computeSize

import com.badlogic.gdx.scenes.scene2d.utils.Layout; //导入方法依赖的package包/类
private void computeSize () {
	sizeInvalid = false;
	SnapshotArray<Actor> children = getChildren();
	int n = children.size;
	prefWidth = padLeft + padRight + spacing * (n - 1);
	prefHeight = 0;
	for (int i = 0; i < n; i++) {
		Actor child = children.get(i);
		if (child instanceof Layout) {
			Layout layout = (Layout)child;
			prefWidth += layout.getPrefWidth();
			prefHeight = Math.max(prefHeight, layout.getPrefHeight());
		} else {
			prefWidth += child.getWidth();
			prefHeight = Math.max(prefHeight, child.getHeight());
		}
	}
	prefHeight += padTop + padBottom;
	if (round) {
		prefWidth = Math.round(prefWidth);
		prefHeight = Math.round(prefHeight);
	}
}
 
开发者ID:basherone,项目名称:libgdxcn,代码行数:24,代码来源:HorizontalGroup.java

示例3: getPrefWidth

import com.badlogic.gdx.scenes.scene2d.utils.Layout; //导入方法依赖的package包/类
@Override
public float getPrefWidth() {
    if (actor == null) return 0f;

    if (actor instanceof Layout) {
        Layout layout = (Layout) actor;
        return layout.getPrefWidth() * getScaleX();
    } else {
        return origWidth * getScaleX();
    }
}
 
开发者ID:crashinvaders,项目名称:gdx-texture-packer-gui,代码行数:12,代码来源:TransformScalableWrapper.java

示例4: getPrefWidth

import com.badlogic.gdx.scenes.scene2d.utils.Layout; //导入方法依赖的package包/类
@Override
public float getPrefWidth() {
    if (actor == null) return 0f;

    if (actor instanceof Layout) {
        Layout layout = (Layout) actor;
        return layout.getPrefWidth() * scaleX;
    } else {
        return origWidth * scaleX;
    }
}
 
开发者ID:crashinvaders,项目名称:gdx-texture-packer-gui,代码行数:12,代码来源:ScalarScalableWrapper.java

示例5: computeSize

import com.badlogic.gdx.scenes.scene2d.utils.Layout; //导入方法依赖的package包/类
private void computeSize()
{
	prefWidth = 0;
	prefHeight = 0;
	sizeInvalid = false;
	SnapshotArray<Actor> children = getChildren();
	float groupHeight = getHeight();
	float y = 0;
	float maxWidth = 0;
	for (int i = 0, n = children.size; i < n; i++)
	{
		Actor child = children.get(i);
		float width = child.getWidth();
		float height = child.getHeight();
		if (child instanceof Layout)
		{
			Layout layout = (Layout) child;
			width = layout.getPrefWidth();
			height = layout.getPrefHeight();
		}
		if (y + height <= groupHeight)
		{
			prefHeight += height + spacing;
			y += height + spacing;
			maxWidth = Math.max(width, maxWidth);
		} else
		{
			prefWidth += maxWidth + spacing;
			maxWidth = width;
			y = height + spacing;
		}
	}
	prefWidth += maxWidth;
}
 
开发者ID:infinity8,项目名称:Roguelike,代码行数:35,代码来源:VerticalFlowGroup.java

示例6: computeSize

import com.badlogic.gdx.scenes.scene2d.utils.Layout; //导入方法依赖的package包/类
private void computeSize()
{
	prefWidth = 0;
	prefHeight = 0;
	sizeInvalid = false;
	SnapshotArray<Actor> children = getChildren();
	float groupWidth = getWidth();
	float x = 0;
	float maxHeight = 0;
	for (int i = 0, n = children.size; i < n; i++)
	{
		Actor child = children.get(i);
		float width = child.getWidth();
		float height = child.getHeight();
		if (child instanceof Layout)
		{
			Layout layout = (Layout) child;
			width = layout.getPrefWidth();
			height = layout.getPrefHeight();
		}
		if (x + width <= groupWidth)
		{
			prefWidth += width + spacing;
			x += width + spacing;
			maxHeight = Math.max(height, maxHeight);
		} else
		{
			prefHeight += maxHeight + spacing;
			maxHeight = height;
			x = width + spacing;
		}
	}
	prefHeight += maxHeight;
}
 
开发者ID:infinity8,项目名称:Roguelike,代码行数:35,代码来源:HorizontalFlowGroup.java

示例7: computeSize

import com.badlogic.gdx.scenes.scene2d.utils.Layout; //导入方法依赖的package包/类
private void computeSize () {
	prefWidth = 0;
	prefHeight = getHeight();
	sizeInvalid = false;

	SnapshotArray<Actor> children = getChildren();

	float y = 0;
	float columnWidth = 0;

	for (int i = 0; i < children.size; i++) {
		Actor child = children.get(i);
		float width = child.getWidth();
		float height = child.getHeight();
		if (child instanceof Layout) {
			Layout layout = (Layout) child;
			width = layout.getPrefWidth();
			height = layout.getPrefHeight();
		}

		if (y + height > getHeight()) {
			y = 0;
			prefWidth += columnWidth + spacing;
			columnWidth = width;
		} else {
			columnWidth = Math.max(width, columnWidth);
		}

		y += height + spacing;
	}

	//handle last column width
	prefWidth += columnWidth + spacing;
}
 
开发者ID:kotcrab,项目名称:vis-editor,代码行数:35,代码来源:VerticalFlowGroup.java

示例8: computeSize

import com.badlogic.gdx.scenes.scene2d.utils.Layout; //导入方法依赖的package包/类
private void computeSize () {
	prefWidth = getWidth();
	prefHeight = 0;
	sizeInvalid = false;

	SnapshotArray<Actor> children = getChildren();

	float x = 0;
	float rowHeight = 0;

	for (int i = 0; i < children.size; i++) {
		Actor child = children.get(i);
		float width = child.getWidth();
		float height = child.getHeight();
		if (child instanceof Layout) {
			Layout layout = (Layout) child;
			width = layout.getPrefWidth();
			height = layout.getPrefHeight();
		}

		if (x + width > getWidth()) {
			x = 0;
			prefHeight += rowHeight + spacing;
			rowHeight = height;
		} else {
			rowHeight = Math.max(height, rowHeight);
		}

		x += width + spacing;
	}

	//handle last row height
	prefHeight += rowHeight + spacing;
}
 
开发者ID:kotcrab,项目名称:vis-editor,代码行数:35,代码来源:HorizontalFlowGroup.java


注:本文中的com.badlogic.gdx.scenes.scene2d.utils.Layout.getPrefWidth方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。