use of com.ray3k.skincomposer.dialog.scenecomposer.DialogSceneComposerModel.SimActor in project skin-composer by raeleus.
the class TextFieldListeners method textFieldSelectionListener.
public static EventListener textFieldSelectionListener(final DialogSceneComposerEvents events, SimActor simActor) {
var simTextField = (DialogSceneComposerModel.SimTextField) simActor;
var popTableClickListener = new PopTableClickListener(skin) {
{
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 table = new Table();
popTable.add(table);
var positionLabel = new Label("Cursor Position: (" + simTextField.cursorPosition + ")", skin, "scene-label-colored");
table.add(positionLabel);
table.row();
var slider = new Slider(0, simTextField.text == null ? 0 : simTextField.text.length(), 1, false, skin, "scene");
slider.setValue(simTextField.cursorPosition);
table.add(slider).minWidth(200);
slider.addListener(handListener);
slider.addListener(new TextTooltip("The cursor position when the textfield has keyboard focus.", tooltipManager, skin, "scene"));
slider.addListener(new ChangeListener() {
@Override
public void changed(ChangeEvent event, Actor actor) {
events.textFieldCursorPosition(MathUtils.round(slider.getValue()));
positionLabel.setText("Cursor Position: (" + simTextField.cursorPosition + ")");
}
});
table.row();
var selectionLabel = new Label("Selection: (" + simTextField.selectionStart + ", " + simTextField.selectionEnd + ")", skin, "scene-label-colored");
table.add(selectionLabel);
table.row();
var rangeSlider = new RangeSlider(skin, "scene");
rangeSlider.setMinimum(0);
rangeSlider.setMaximum(simTextField.text == null ? 0 : simTextField.text.length());
rangeSlider.setIncrement(1);
rangeSlider.setValueBegin(simTextField.selectionStart);
rangeSlider.setValueEnd(simTextField.selectionEnd);
rangeSlider.setDisabled(simTextField.selectAll);
table.add(rangeSlider).minWidth(200);
rangeSlider.getKnobBegin().addListener(handListener);
rangeSlider.getKnobEnd().addListener(handListener);
rangeSlider.addListener(new TextTooltip("The text range to be selected if this textField has keyboard focus.", tooltipManager, skin, "scene"));
rangeSlider.addListener(new ValueBeginChangeListener() {
@Override
public void changed(ValueBeginChangeEvent event, float value, Actor actor) {
events.textFieldSelectionStart(MathUtils.round(value));
}
});
rangeSlider.addListener(new ValueEndChangeListener() {
@Override
public void changed(ValueEndChangeEvent event, float value, Actor actor) {
events.textFieldSelectionEnd(MathUtils.round(value));
}
});
rangeSlider.addListener(new ChangeListener() {
@Override
public void changed(ChangeEvent event, Actor actor) {
selectionLabel.setText("Selection: (" + simTextField.selectionStart + ", " + simTextField.selectionEnd + ")");
}
});
table.row();
var label = new Label("Select All: ", skin, "scene-label-colored");
table.add(label);
table.row();
var textButton = new TextButton(simTextField.selectAll ? "TRUE" : "FALSE", skin, "scene-small");
textButton.setChecked(simTextField.selectAll);
table.add(textButton).minWidth(100);
textButton.addListener(handListener);
textButton.addListener(new TextTooltip("Convenience option to select all text.", tooltipManager, skin, "scene"));
textButton.addListener(new ChangeListener() {
@Override
public void changed(ChangeEvent event, Actor actor) {
textButton.setText(textButton.isChecked() ? "TRUE" : "FALSE");
events.textFieldSelectAll(textButton.isChecked());
rangeSlider.setDisabled(textButton.isChecked());
}
});
}
};
popTableClickListener.update();
return popTableClickListener;
}
use of com.ray3k.skincomposer.dialog.scenecomposer.DialogSceneComposerModel.SimActor in project skin-composer by raeleus.
the class ImageListeners method imageScalingListener.
public static EventListener imageScalingListener(final DialogSceneComposerEvents events, SimActor simActor) {
var scalingNames = new Array<>(new String[] { "none", "fill", "fillX", "fillY", "fit", "stretch", "stretchX", "stretchY" });
var simImage = (DialogSceneComposerModel.SimImage) simActor;
var selectBox = new SelectBox<String>(skin, "scene");
selectBox.setItems(scalingNames);
var popTableClickListener = new PopTableClickListener(skin) {
{
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("Scaling:", skin, "scene-label-colored");
popTable.add(label);
popTable.row();
selectBox.setSelected(simImage.scaling);
popTable.add(selectBox);
selectBox.addListener(handListener);
selectBox.addListener(new TextTooltip("The scaling strategy applied to the image.", tooltipManager, skin, "scene"));
selectBox.addListener(new ChangeListener() {
@Override
public void changed(ChangeEvent event, Actor actor) {
events.imageScaling(selectBox.getSelected());
}
});
}
};
popTableClickListener.update();
return popTableClickListener;
}
use of com.ray3k.skincomposer.dialog.scenecomposer.DialogSceneComposerModel.SimActor in project skin-composer by raeleus.
the class ImageTextButtonListeners method imageTextButtonCheckedListener.
public static EventListener imageTextButtonCheckedListener(final DialogSceneComposerEvents events, SimActor simActor) {
var simImageTextButton = (DialogSceneComposerModel.SimImageTextButton) simActor;
var popTableClickListener = new PopTableClickListener(skin) {
{
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("Checked:", skin, "scene-label-colored");
popTable.add(label);
popTable.row();
var textButton = new TextButton(simImageTextButton.checked ? "TRUE" : "FALSE", skin, "scene-small");
textButton.setChecked(simImageTextButton.checked);
popTable.add(textButton).minWidth(100);
textButton.addListener(handListener);
textButton.addListener(new TextTooltip("Whether the button is checked initially.", tooltipManager, skin, "scene"));
textButton.addListener(new ChangeListener() {
@Override
public void changed(ChangeEvent event, Actor actor) {
textButton.setText(textButton.isChecked() ? "TRUE" : "FALSE");
events.imageTextButtonChecked(textButton.isChecked());
}
});
}
};
popTableClickListener.update();
return popTableClickListener;
}
use of com.ray3k.skincomposer.dialog.scenecomposer.DialogSceneComposerModel.SimActor in project skin-composer by raeleus.
the class ProgressBarListeners method progressBarOrientationListener.
public static EventListener progressBarOrientationListener(final DialogSceneComposerEvents events, SimActor simActor) {
var simProgressBar = (DialogSceneComposerModel.SimProgressBar) simActor;
var popTableClickListener = new PopTableClickListener(skin) {
{
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("Orientation:", skin, "scene-label-colored");
popTable.add(label);
popTable.row();
var draggableTextList = new DraggableTextList(true, skin, "scene");
draggableTextList.setDraggable(false);
draggableTextList.addAllTexts("Horizontal", "Vertical");
draggableTextList.setSelected(simProgressBar.vertical ? 1 : 0);
popTable.add(draggableTextList);
draggableTextList.addListener(handListener);
draggableTextList.addListener(new TextTooltip("The orientation of the ProgressBar.", tooltipManager, skin, "scene"));
draggableTextList.addListener(new ChangeListener() {
@Override
public void changed(ChangeEvent event, Actor actor) {
events.progressBarVertical(draggableTextList.getSelectedIndex() == 1);
}
});
}
};
popTableClickListener.update();
return popTableClickListener;
}
use of com.ray3k.skincomposer.dialog.scenecomposer.DialogSceneComposerModel.SimActor in project skin-composer by raeleus.
the class ProgressBarListeners method progressBarRoundListener.
public static EventListener progressBarRoundListener(final DialogSceneComposerEvents events, SimActor simActor) {
var simProgressBar = (DialogSceneComposerModel.SimProgressBar) simActor;
var popTableClickListener = new PopTableClickListener(skin) {
{
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("Round:", skin, "scene-label-colored");
popTable.add(label);
popTable.row();
var textButton = new TextButton(simProgressBar.round ? "TRUE" : "FALSE", skin, "scene-small");
textButton.setChecked(simProgressBar.round);
popTable.add(textButton).minWidth(100);
textButton.addListener(handListener);
textButton.addListener(new TextTooltip("Whether the ProgressBar inner positions are rounded to integer.", tooltipManager, skin, "scene"));
textButton.addListener(new ChangeListener() {
@Override
public void changed(ChangeEvent event, Actor actor) {
textButton.setText(textButton.isChecked() ? "TRUE" : "FALSE");
events.progressBarRound(textButton.isChecked());
}
});
}
};
popTableClickListener.update();
return popTableClickListener;
}
Aggregations