本文整理了Java中com.badlogic.gdx.scenes.scene2d.ui.WidgetGroup
类的一些代码示例,展示了WidgetGroup
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。WidgetGroup
类的具体详情如下:
包路径:com.badlogic.gdx.scenes.scene2d.ui.WidgetGroup
类名称:WidgetGroup
[英]A Group that participates in layout and provides a minimum, preferred, and maximum size.
The default preferred size of a widget group is 0 and this is almost always overridden by a subclass. The default minimum size returns the preferred size, so a subclass may choose to return 0 for minimum size if it wants to allow itself to be sized smaller than the preferred size. The default maximum size is 0, which means no maximum size.
See Layout for details on how a widget group should participate in layout. A widget group's mutator methods should call #invalidate() or #invalidateHierarchy() as needed. By default, invalidateHierarchy is called when child widgets are added and removed.
[中]参与布局并提供最小、首选和最大规模的组。
小部件组的默认首选大小为0,并且几乎总是被子类覆盖。默认的最小大小返回首选大小,因此如果子类希望允许自己的大小小于首选大小,则可以选择返回0作为最小大小。默认最大大小为0,这意味着没有最大大小。
有关小部件组应如何参与布局的详细信息,请参见布局。小部件组的mutator方法应该根据需要调用#invalidate()或#invalidateHierarchy()。默认情况下,在添加和删除子小部件时调用invalidateHierarchy。
代码示例来源:origin: libgdx/libgdx
/** @param actor May be null. */
public void setActor (T actor) {
if (actor == this) throw new IllegalArgumentException("actor cannot be the Container.");
if (actor == this.actor) return;
if (this.actor != null) super.removeActor(this.actor);
this.actor = actor;
if (actor != null) super.addActor(actor);
}
代码示例来源:origin: libgdx/libgdx
public void validate () {
if (!layoutEnabled) return;
Group parent = getParent();
if (fillParent && parent != null) {
float parentWidth, parentHeight;
Stage stage = getStage();
if (stage != null && parent == stage.getRoot()) {
parentWidth = stage.getWidth();
parentHeight = parent.getHeight();
if (getWidth() != parentWidth || getHeight() != parentHeight) {
setWidth(parentWidth);
setHeight(parentHeight);
invalidate();
layout();
layout();
if (!needsLayout) break;
代码示例来源:origin: libgdx/libgdx
public void invalidateHierarchy () {
invalidate();
Group parent = getParent();
if (parent instanceof Layout) ((Layout)parent).invalidateHierarchy();
}
代码示例来源:origin: libgdx/libgdx
public void draw (Batch batch, float parentAlpha) {
drawBackground(batch, parentAlpha);
Color color = getColor();
batch.setColor(color.r, color.g, color.b, color.a * parentAlpha);
float plusMinusWidth = Math.max(style.plus.getMinWidth(), style.minus.getMinWidth());
draw(batch, rootNodes, padding, plusMinusWidth);
super.draw(batch, parentAlpha); // Draw actors.
}
代码示例来源:origin: libgdx/libgdx
public Actor hit (float x, float y, boolean touchable) {
if (clip) {
if (touchable && getTouchable() == Touchable.disabled) return null;
if (x < 0 || x >= getWidth() || y < 0 || y >= getHeight()) return null;
}
return super.hit(x, y, touchable);
}
代码示例来源:origin: libgdx/libgdx
public boolean removeActor (Actor actor, boolean unfocus) {
if (actor == null) throw new IllegalArgumentException("actor cannot be null.");
if (actor != this.actor) return false;
this.actor = null;
return super.removeActor(actor, unfocus);
}
代码示例来源:origin: libgdx/libgdx
public void invalidate () {
super.invalidate();
sizeInvalid = true;
}
代码示例来源:origin: libgdx/libgdx
/** Creates a new widget group containing the specified actors. */
public WidgetGroup (Actor... actors) {
for (Actor actor : actors)
addActor(actor);
}
代码示例来源:origin: stackoverflow.com
emptyPlayerHealthBar = new Image(HUDatlas.findRegion("empty-health-bar"));
playerHealthBar = new Image(HUDatlas.findRegion("health-bar"));
// creating the group
WidgetGroup group = new WidgetGroup();
group.addActor(playerHealthBar);
group.addActor(emptyPlayerHealthBar);
// creating the table
table = new Table(skin);
table.setBounds(0, 0, Gdx.graphics.getWidth(), 50);
table.debug().left().top().add(group);
stage.addActor(table);
代码示例来源:origin: kotcrab/vis-ui
@Override
public void setBounds (final float x, final float y, final float width, final float height) {
super.setBounds(x, y, width, height);
getActor().setWidth(width);
getActor().setHeight(height);
// Child position omitted on purpose.
}
代码示例来源:origin: kotcrab/vis-ui
/** Toast manager will create own group to host toasts and put it into the stage root. */
public ToastManager (Stage stage) {
WidgetGroup widgetGroup = new WidgetGroup();
widgetGroup.setFillParent(true);
widgetGroup.setTouchable(Touchable.childrenOnly);
stage.addActor(widgetGroup);
this.root = widgetGroup;
}
代码示例来源:origin: libgdx/libgdx
public void act (float delta) {
super.act(delta);
代码示例来源:origin: crashinvaders/gdx-texture-packer-gui
public ToastManager(Stage stage) {
WidgetGroup widgetGroup = new WidgetGroup();
widgetGroup.setFillParent(true);
stage.addActor(widgetGroup);
this.root = widgetGroup;
}
代码示例来源:origin: kotcrab/vis-ui
@Override
public boolean onEnd (Draggable draggable, Actor actor, float stageX, float stageY) {
boolean result = super.onEnd(draggable, actor, stageX, stageY);
if (result == APPROVE) return APPROVE;
if (dragged == false) return CANCEL;
// check if any actor corner is over some other tab
tabsPane.stageToLocalCoordinates(tmpVector.set(stageX, stageY));
if (tabsPane.hit(tmpVector.x, tmpVector.y, true) != null) return CANCEL;
if (tabsPane.hit(tmpVector.x + actor.getWidth(), tmpVector.y, true) != null) return CANCEL;
if (tabsPane.hit(tmpVector.x, tmpVector.y - actor.getHeight(), true) != null) return CANCEL;
if (tabsPane.hit(tmpVector.x + actor.getWidth(), tmpVector.y - actor.getHeight(), true) != null)
return CANCEL;
Vector2 stagePos = tabsPane.localToStageCoordinates(tmpVector.setZero());
tmpRect.set(stagePos.x, stagePos.y, tabsPane.getGroup().getWidth(), tabsPane.getGroup().getHeight());
if (tmpRect.contains(stageX, stageY) == false) return CANCEL;
if (tabsPane.isHorizontalFlow() || tabsPane.isVerticalFlow()) {
DRAG_POSITION.set(stageX, stageY);
tabsPane.addActor(actor);
return APPROVE;
}
return CANCEL;
}
});
代码示例来源:origin: peakgames/libgdx-stagebuilder
@Override
public void setHeight(float height) {
super.setHeight(height);
if (isVertical) {
measure = height;
}
}
代码示例来源:origin: peakgames/libgdx-stagebuilder
@Override
public void setWidth(float width) {
super.setWidth(width);
if (!isVertical) {
measure = width;
}
}
代码示例来源:origin: crashinvaders/gdx-texture-packer-gui
@Override
protected WidgetGroup getNewInstanceOfGroup(LmlActorBuilder builder) {
return new WidgetGroup();
}
代码示例来源:origin: libgdx/libgdx
public void draw (Batch batch, float parentAlpha) {
drawBackground(batch, parentAlpha);
Color color = getColor();
batch.setColor(color.r, color.g, color.b, color.a * parentAlpha);
float plusMinusWidth = Math.max(style.plus.getMinWidth(), style.minus.getMinWidth());
draw(batch, rootNodes, padding, plusMinusWidth);
super.draw(batch, parentAlpha); // Draw actors.
}
代码示例来源:origin: libgdx/libgdx
public Actor hit (float x, float y, boolean touchable) {
if (clip) {
if (touchable && getTouchable() == Touchable.disabled) return null;
if (x < 0 || x >= getWidth() || y < 0 || y >= getHeight()) return null;
}
return super.hit(x, y, touchable);
}
代码示例来源:origin: libgdx/libgdx
public boolean removeActor (Actor actor, boolean unfocus) {
if (actor == null) throw new IllegalArgumentException("actor cannot be null.");
if (actor != this.actor) return false;
this.actor = null;
return super.removeActor(actor, unfocus);
}
内容来源于网络,如有侵权,请联系作者删除!