use of com.badlogic.gdx.scenes.scene2d.InputEvent in project skin-composer by raeleus.
the class SplitPaneListeners method splitPaneSplitListener.
public static EventListener splitPaneSplitListener(final DialogSceneComposerEvents events, SimActor simActor) {
var simSplitPane = (DialogSceneComposerModel.SimSplitPane) simActor;
var popTableClickListener = new PopTableClickListener(skin) {
{
getPopTable().key(Keys.ENTER, popTable::hide);
getPopTable().key(Keys.NUMPAD_ENTER, popTable::hide);
getPopTable().key(Keys.ESCAPE, popTable::hide);
}
@Override
public void clicked(InputEvent event, float x, float y) {
super.clicked(event, x, y);
update();
}
public void update() {
var popTable = getPopTable();
popTable.clearChildren();
var label = new Label("Split:", skin, "scene-label-colored");
popTable.add(label).spaceRight(5);
var splitSpinner = new Spinner(0, .1f, false, Spinner.Orientation.RIGHT_STACK, skin, "scene");
var splitMinSpinner = new Spinner(0, .1f, false, Spinner.Orientation.RIGHT_STACK, skin, "scene");
var splitMaxSpinner = new Spinner(0, .1f, false, Spinner.Orientation.RIGHT_STACK, skin, "scene");
splitSpinner.setName("pad-left");
splitSpinner.setValue(simSplitPane.split);
splitSpinner.setMinimum((double) simSplitPane.splitMin);
splitSpinner.setMaximum((double) simSplitPane.splitMax);
popTable.add(splitSpinner);
splitSpinner.getTextField().addListener(ibeamListener);
splitSpinner.getButtonMinus().addListener(handListener);
splitSpinner.getButtonPlus().addListener(handListener);
splitSpinner.addListener(new TextTooltip("The distance in pixels that the user is allowed to scroll beyond the bounds if overscroll is enabled.", tooltipManager, skin, "scene"));
splitSpinner.addListener(new ChangeListener() {
@Override
public void changed(ChangeEvent event, Actor actor) {
events.splitPaneSplit((float) ((Spinner) actor).getValue());
}
});
popTable.row();
label = new Label("Split Min:", skin, "scene-label-colored");
popTable.add(label).spaceRight(5);
splitMinSpinner.setName("pad-left");
splitMinSpinner.setValue(simSplitPane.splitMin);
splitMinSpinner.setMinimum(0);
splitMinSpinner.setMaximum(simSplitPane.splitMax);
popTable.add(splitMinSpinner);
splitMinSpinner.getTextField().addListener(ibeamListener);
splitMinSpinner.getButtonMinus().addListener(handListener);
splitMinSpinner.getButtonPlus().addListener(handListener);
splitMinSpinner.addListener(new TextTooltip("The minimum speed that scroll returns to the widget bounds when overscroll is enabled.", tooltipManager, skin, "scene"));
splitMinSpinner.addListener(new ChangeListener() {
@Override
public void changed(ChangeEvent event, Actor actor) {
events.splitPaneSplitMin((float) ((Spinner) actor).getValue());
splitSpinner.setMinimum(splitMinSpinner.getValue());
splitMaxSpinner.setMinimum(splitMinSpinner.getValue());
}
});
popTable.row();
label = new Label("Split Max:", skin, "scene-label-colored");
popTable.add(label).spaceRight(5);
splitMaxSpinner.setName("pad-left");
splitMaxSpinner.setValue(simSplitPane.splitMax);
splitMaxSpinner.setMinimum(simSplitPane.splitMin);
splitMaxSpinner.setMaximum(1);
popTable.add(splitMaxSpinner);
splitMaxSpinner.getTextField().addListener(ibeamListener);
splitMaxSpinner.getButtonMinus().addListener(handListener);
splitMaxSpinner.getButtonPlus().addListener(handListener);
splitMaxSpinner.addListener(new TextTooltip("The maximum speed that scroll returns to the widget bounds when overscroll is enabled.", tooltipManager, skin, "scene"));
splitMaxSpinner.addListener(new ChangeListener() {
@Override
public void changed(ChangeEvent event, Actor actor) {
events.splitPaneSplitMax((float) ((Spinner) actor).getValue());
splitSpinner.setMaximum(splitMaxSpinner.getValue());
splitMinSpinner.setMaximum(splitMaxSpinner.getValue());
}
});
}
};
popTableClickListener.update();
return popTableClickListener;
}
use of com.badlogic.gdx.scenes.scene2d.InputEvent in project skin-composer by raeleus.
the class BigSpinner method addWidgets.
private void addWidgets() {
buttonMinus = new Button(style.buttonMinusStyle);
buttonPlus = new Button(style.buttonPlusStyle);
textField = new TextField("", style.textFieldStyle) {
@Override
public void next(boolean up) {
if (up) {
if (transversalPrevious != null) {
getStage().setKeyboardFocus(transversalPrevious);
if (transversalPrevious instanceof TextField) {
((TextField) transversalPrevious).selectAll();
}
} else {
super.next(up);
}
} else {
if (transversalNext != null) {
getStage().setKeyboardFocus(transversalNext);
if (transversalNext instanceof TextField) {
((TextField) transversalNext).selectAll();
}
} else {
super.next(up);
}
}
}
};
textField.setAlignment(Align.center);
textField.addListener(new InputListener() {
@Override
public boolean keyDown(InputEvent event, int keycode) {
if (keycode == Keys.UP) {
addValue();
fire(new ChangeListener.ChangeEvent());
} else if (keycode == Keys.DOWN) {
subtractValue();
fire(new ChangeListener.ChangeEvent());
}
return false;
}
});
textField.setTextFieldFilter(new TextField.TextFieldFilter() {
@Override
public boolean acceptChar(TextField textField1, char c) {
boolean returnValue = false;
if ((c >= 48 && c <= 57) || c == 45 || (!rounding && c == 46)) {
returnValue = true;
}
return returnValue;
}
});
updateText();
if (null != orientation)
switch(orientation) {
case HORIZONTAL:
add(buttonMinus);
add(textField).prefWidth(style.textFieldStyle.background.getMinWidth()).minWidth(style.textFieldStyle.background.getMinWidth()).growX();
add(buttonPlus);
break;
case HORIZONTAL_FLIPPED:
add(buttonPlus);
add(textField).prefWidth(style.textFieldStyle.background.getMinWidth()).minWidth(style.textFieldStyle.background.getMinWidth()).growX();
add(buttonMinus);
break;
case VERTICAL:
add(buttonPlus);
row();
add(textField).prefWidth(style.textFieldStyle.background.getMinWidth()).minWidth(style.textFieldStyle.background.getMinWidth()).growX();
row();
add(buttonMinus);
break;
case VERTICAL_FLIPPED:
add(buttonMinus);
row();
add(textField).prefWidth(style.textFieldStyle.background.getMinWidth()).minWidth(style.textFieldStyle.background.getMinWidth()).growX();
row();
add(buttonPlus);
break;
case RIGHT_STACK:
{
add(textField).prefWidth(style.textFieldStyle.background.getMinWidth()).minWidth(style.textFieldStyle.background.getMinWidth()).growX();
VerticalGroup group = new VerticalGroup();
add(group);
group.addActor(buttonPlus);
group.addActor(buttonMinus);
break;
}
case LEFT_STACK:
{
VerticalGroup group = new VerticalGroup();
add(group);
group.addActor(buttonPlus);
group.addActor(buttonMinus);
add(textField).prefWidth(35.0f).minWidth(35.0f).growX();
break;
}
default:
break;
}
buttonMinus.addListener(new ChangeListener() {
@Override
public void changed(ChangeEvent event, Actor actor) {
subtractValue();
}
});
buttonPlus.addListener(new ChangeListener() {
@Override
public void changed(ChangeEvent event, Actor actor) {
addValue();
}
});
textField.addListener(new ChangeListener() {
@Override
public void changed(ChangeEvent event, Actor actor) {
BigSpinner parent = (BigSpinner) actor;
String text = textField.getText();
if (text.matches("\\-?(\\d+\\.?\\d*)|(\\.\\d+)")) {
BigDecimal value = new BigDecimal(text);
if (usingMinimum && value.compareTo(parent.value) < 0) {
value = parent.minimum;
} else if (usingMaximum && value.compareTo(parent.value) > 0) {
value = parent.maximum;
}
parent.value = value;
} else {
if (usingMinimum) {
parent.value = parent.minimum;
} else {
parent.value = BigDecimal.valueOf(0);
}
}
}
});
textField.addListener(new FocusListener() {
@Override
public void keyboardFocusChanged(FocusEvent event, Actor actor, boolean focused) {
BigSpinner parent = (BigSpinner) textField.getParent();
if (usingMinimum && parent.value.compareTo(parent.minimum) < 0) {
parent.value = parent.minimum;
}
if (usingMaximum && parent.value.compareTo(parent.maximum) > 0) {
parent.value = parent.maximum;
}
parent.updateText();
}
});
final BigSpinner spinner = this;
addCaptureListener(new ChangeListener() {
@Override
public void changed(ChangeEvent event, Actor actor) {
event.setTarget(spinner);
}
});
}
use of com.badlogic.gdx.scenes.scene2d.InputEvent in project Eidolons by IDemiurge.
the class PlaceTooltip method updateAct.
@Override
public void updateAct(float delta) {
clearChildren();
TextureRegion r = TextureCache.getOrCreateR(place.getImagePath());
ValueContainer container = new ValueContainer(r, place.getName());
float size = GdxMaster.adjustSize(128);
if (size < r.getRegionHeight() && size < r.getRegionWidth())
container.overrideImageSize(size, size);
add(container);
setBackground(new NinePatchDrawable(NinePatchFactory.getTooltip()));
// return ;
if (place.getRoutes().isEmpty()) {
return;
}
row();
TablePanel<ValueContainer> routesInfo = new TablePanel<>();
routesInfo.defaults().space(5);
add(routesInfo);
routesInfo.addListener(new ClickListener() {
@Override
public void exit(InputEvent event, float x, float y, int pointer, Actor toActor) {
if (toActor == routesInfo)
return;
if (toActor == null) {
if (getWidth() >= x)
return;
if (getWidth() >= y)
return;
}
if (GdxMaster.getAncestors(toActor).contains(routesInfo))
return;
if (!checkActorExitRemoves(toActor))
return;
super.exit(event, x, y, pointer, toActor);
GuiEventManager.trigger(MapEvent.ROUTES_PANEL_HOVER_OFF);
}
});
int i = 0;
for (Route sub : place.getRoutes()) {
// reverse pic pos
TextureRegion tex = TextureCache.getOrCreateR(sub.getImagePath());
ValueContainer routeInfo = new ValueContainer(tex, sub.getName(), sub.getLength() + " leagues");
routeInfo.setBackground(new NinePatchDrawable(NinePatchFactory.getTooltip()));
routesInfo.add(routeInfo).left().padLeft(5).uniform(true, false);
routeInfo.setUserObject(sub);
routeInfo.addListener(new ClickListener() {
@Override
public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) {
// getTapCount()
GuiEventManager.trigger(MapEvent.ROUTE_HOVERED, sub);
return super.touchDown(event, x, y, pointer, button);
}
@Override
public void exit(InputEvent event, float x, float y, int pointer, Actor toActor) {
super.exit(event, x, y, pointer, toActor);
GuiEventManager.trigger(MapEvent.ROUTE_HOVERED, null);
}
@Override
public void enter(InputEvent event, float x, float y, int pointer, Actor fromActor) {
super.enter(event, x, y, pointer, fromActor);
GuiEventManager.trigger(MapEvent.ROUTE_HOVERED, sub);
}
});
if (i % 2 == 1)
routesInfo.row();
i++;
}
}
use of com.badlogic.gdx.scenes.scene2d.InputEvent in project Eidolons by IDemiurge.
the class EditorParticleMaster method clicked.
public void clicked(int x, int y) {
String path = EditorMapView.getInstance().getGuiStage().getEmitterPalette().getSelectedEmitterPath();
EmitterActor last = particles.create(path, x, y);
last.start();
stack.push(last);
final DAY_TIME time = this.time;
last.addListener(new ClickListener() {
@Override
public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) {
if (button == 1) {
removeEmitter(last, time);
}
return super.touchDown(event, x, y, pointer, button);
}
});
MapMaster.addToListMap(map, time, last);
// layer
// centering? emitters probably self-center...
last.setPosition(x, y);
layers.get(time).addActor(last);
GuiEventManager.trigger(MapEvent.EMITTER_CREATED, last);
}
use of com.badlogic.gdx.scenes.scene2d.InputEvent in project Eidolons by IDemiurge.
the class EmitterPalette method init.
public void init() {
clear();
setSize(GdxMaster.getWidth() - 300, 256);
// int columns = (int) (getWidth() / 64);
defaults().padLeft(200).top().right().width(GdxMaster.getWidth() - 300);
Map<String, List<File>> presets = new LinkedHashMap<>();
List<File> subfolders = FileManager.getFilesFromDirectory(PathFinder.getSfxPath(), true);
subfolders.forEach(file -> {
if (!file.isDirectory()) {
MapMaster.addToListMap(presets, "main", file);
} else
presets.put(file.getName(), FileManager.getFilesFromDirectory(file.getPath(), false));
});
LabelStyle style = StyleHolder.getSizedLabelStyle(FONT.MAIN, 15);
for (String sub : presets.keySet()) {
HorizontalFlowGroup table = new HorizontalFlowGroup(0);
table.setWidth(getWidth() - 100);
boolean bg = presets.get(sub).size() < 55;
for (File preset : presets.get(sub)) {
// textButton?
ValueContainer label = new ValueContainer(new Label(preset.getName(), style));
NinePatch patch = NinePatchFactory.getTooltip();
patch.scale(0.7f, 0.7f);
if (bg)
label.setBackground(new NinePatchDrawable(patch));
label.addListener(new ClickListener() {
@Override
public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) {
if (Gdx.input.isKeyPressed(Keys.SHIFT_LEFT)) {
// EmitterMaster.
}
EditorManager.setMode(MAP_EDITOR_MOUSE_MODE.EMITTER);
if (selectedLabel != null)
selectedLabel.setColor(1, 1, 1, 1);
if (sub.equals("main"))
selected = preset.getName();
else
selected = StrPathBuilder.build(sub, preset.getName());
selectedLabel = label;
label.setColor(1, 0.3f, 0.8f, 1);
return super.touchDown(event, x, y, pointer, button);
}
});
table.addActor(label);
}
addTab(table, sub);
}
}
Aggregations