use of com.badlogic.gdx.scenes.scene2d.utils.ChangeListener.ChangeEvent in project libgdx by libgdx.
the class Benchmark3DTest method create.
@Override
public void create() {
super.create();
GLProfiler.enable();
randomizeLights();
cam.position.set(10, 10, 10);
cam.lookAt(0, 0, 0);
cam.update();
showAxes = true;
lighting = true;
vertexCountLabel = new Label("Vertices: 999", skin);
vertexCountLabel.setPosition(0, fpsLabel.getTop());
hud.addActor(vertexCountLabel);
textureBindsLabel = new Label("Texture bindings: 999", skin);
textureBindsLabel.setPosition(0, vertexCountLabel.getTop());
hud.addActor(textureBindsLabel);
shaderSwitchesLabel = new Label("Shader switches: 999", skin);
shaderSwitchesLabel.setPosition(0, textureBindsLabel.getTop());
hud.addActor(shaderSwitchesLabel);
drawCallsLabel = new Label("Draw calls: 999", skin);
drawCallsLabel.setPosition(0, shaderSwitchesLabel.getTop());
hud.addActor(drawCallsLabel);
glCallsLabel = new Label("GL calls: 999", skin);
glCallsLabel.setPosition(0, drawCallsLabel.getTop());
hud.addActor(glCallsLabel);
lightsLabel = new Label("Lights: 999", skin);
lightsLabel.setPosition(0, glCallsLabel.getTop());
hud.addActor(lightsLabel);
lightingCheckBox = new CheckBox("Lighting", skin);
lightingCheckBox.setChecked(lighting);
lightingCheckBox.addListener(new ChangeListener() {
@Override
public void changed(ChangeEvent event, Actor actor) {
lighting = lightingCheckBox.isChecked();
}
});
lightingCheckBox.setPosition(hudWidth - lightingCheckBox.getWidth(), gridCheckBox.getTop());
hud.addActor(lightingCheckBox);
lightsCheckBox = new CheckBox("Randomize lights", skin);
lightsCheckBox.setChecked(false);
lightsCheckBox.addListener(new ChangeListener() {
@Override
public void changed(ChangeEvent event, Actor actor) {
lightsCheckBox.setChecked(false);
randomizeLights();
}
});
lightsCheckBox.setPosition(hudWidth - lightsCheckBox.getWidth(), lightingCheckBox.getTop());
hud.addActor(lightsCheckBox);
moveCheckBox.remove();
rotateCheckBox.remove();
}
use of com.badlogic.gdx.scenes.scene2d.utils.ChangeListener.ChangeEvent in project libgdx by libgdx.
the class TextField method changeText.
/** @param oldText May be null.
* @return True if the text was changed. */
boolean changeText(String oldText, String newText) {
if (newText.equals(oldText))
return false;
text = newText;
ChangeEvent changeEvent = Pools.obtain(ChangeEvent.class);
boolean cancelled = fire(changeEvent);
text = cancelled ? oldText : newText;
Pools.free(changeEvent);
return !cancelled;
}
use of com.badlogic.gdx.scenes.scene2d.utils.ChangeListener.ChangeEvent in project libgdx by libgdx.
the class Touchpad method calculatePositionAndValue.
void calculatePositionAndValue(float x, float y, boolean isTouchUp) {
float oldPositionX = knobPosition.x;
float oldPositionY = knobPosition.y;
float oldPercentX = knobPercent.x;
float oldPercentY = knobPercent.y;
float centerX = knobBounds.x;
float centerY = knobBounds.y;
knobPosition.set(centerX, centerY);
knobPercent.set(0f, 0f);
if (!isTouchUp) {
if (!deadzoneBounds.contains(x, y)) {
knobPercent.set((x - centerX) / knobBounds.radius, (y - centerY) / knobBounds.radius);
float length = knobPercent.len();
if (length > 1)
knobPercent.scl(1 / length);
if (knobBounds.contains(x, y)) {
knobPosition.set(x, y);
} else {
knobPosition.set(knobPercent).nor().scl(knobBounds.radius).add(knobBounds.x, knobBounds.y);
}
}
}
if (oldPercentX != knobPercent.x || oldPercentY != knobPercent.y) {
ChangeEvent changeEvent = Pools.obtain(ChangeEvent.class);
if (fire(changeEvent)) {
knobPercent.set(oldPercentX, oldPercentY);
knobPosition.set(oldPositionX, oldPositionY);
}
Pools.free(changeEvent);
}
}
use of com.badlogic.gdx.scenes.scene2d.utils.ChangeListener.ChangeEvent in project libgdx by libgdx.
the class ProgressBar method setValue.
/** Sets the progress bar position, rounded to the nearest step size and clamped to the minimum and maximum values.
* {@link #clamp(float)} can be overridden to allow values outside of the progress bar's min/max range.
* @return false if the value was not changed because the progress bar already had the value or it was canceled by a
* listener. */
public boolean setValue(float value) {
value = clamp(Math.round(value / stepSize) * stepSize);
float oldValue = this.value;
if (value == oldValue)
return false;
float oldVisualValue = getVisualValue();
this.value = value;
ChangeEvent changeEvent = Pools.obtain(ChangeEvent.class);
boolean cancelled = fire(changeEvent);
if (cancelled)
this.value = oldValue;
else if (animateDuration > 0) {
animateFromValue = oldVisualValue;
animateTime = animateDuration;
}
Pools.free(changeEvent);
return !cancelled;
}
use of com.badlogic.gdx.scenes.scene2d.utils.ChangeListener.ChangeEvent in project libgdx by libgdx.
the class Button method setChecked.
void setChecked(boolean isChecked, boolean fireEvent) {
if (this.isChecked == isChecked)
return;
if (buttonGroup != null && !buttonGroup.canCheck(this, isChecked))
return;
this.isChecked = isChecked;
if (fireEvent) {
ChangeEvent changeEvent = Pools.obtain(ChangeEvent.class);
if (fire(changeEvent))
this.isChecked = !isChecked;
Pools.free(changeEvent);
}
}
Aggregations