visual improvements
@ -1,22 +1,39 @@
|
||||
package eu.jonahbauer.wizard.client.libgdx.listeners;
|
||||
|
||||
import com.badlogic.gdx.scenes.scene2d.Actor;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.SelectBox;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.Skin;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.TextField;
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.*;
|
||||
import com.badlogic.gdx.scenes.scene2d.utils.ChangeListener;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
|
||||
@RequiredArgsConstructor
|
||||
public class ResetErrorListener extends ChangeListener {
|
||||
private final Skin skin;
|
||||
private final Actor target;
|
||||
private final String style;
|
||||
|
||||
public ResetErrorListener(Skin skin) {
|
||||
this(skin, null);
|
||||
}
|
||||
|
||||
public ResetErrorListener(Skin skin, Actor target) {
|
||||
this(skin, target, "default");
|
||||
}
|
||||
|
||||
public ResetErrorListener(Skin skin, Actor target, String style) {
|
||||
this.skin = skin;
|
||||
this.target = target;
|
||||
this.style = style;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void changed(ChangeEvent event, Actor actor) {
|
||||
if (event.getTarget() instanceof TextField textField) {
|
||||
textField.setStyle(skin.get(TextField.TextFieldStyle.class));
|
||||
} else if (event.getTarget() instanceof SelectBox<?> box) {
|
||||
box.setStyle(skin.get(SelectBox.SelectBoxStyle.class));
|
||||
var target = this.target != null ? this.target : event.getTarget();
|
||||
if (target instanceof TextField textField) {
|
||||
textField.setStyle(skin.get(style, TextField.TextFieldStyle.class));
|
||||
} else if (target instanceof SelectBox<?> box) {
|
||||
box.setStyle(skin.get(style, SelectBox.SelectBoxStyle.class));
|
||||
} else if (target instanceof List<?> list) {
|
||||
list.setStyle(skin.get(style, List.ListStyle.class));
|
||||
} else if (target instanceof ScrollPane scrollPane) {
|
||||
scrollPane.setStyle(skin.get(style, ScrollPane.ScrollPaneStyle.class));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Before Width: | Height: | Size: 90 KiB After Width: | Height: | Size: 104 KiB |
After Width: | Height: | Size: 223 B |
Before Width: | Height: | Size: 311 B After Width: | Height: | Size: 225 B |
Before Width: | Height: | Size: 85 B |
After Width: | Height: | Size: 185 B |
Before Width: | Height: | Size: 119 B |
Before Width: | Height: | Size: 236 B After Width: | Height: | Size: 248 B |
Before Width: | Height: | Size: 241 B After Width: | Height: | Size: 253 B |