use of com.ray3k.stripe.RangeSlider in project skin-composer by raeleus.
the class TextAreaListeners method textAreaSelectionListener.
public static EventListener textAreaSelectionListener(final DialogSceneComposerEvents events, SimActor simActor) {
var simTextArea = (DialogSceneComposerModel.SimTextArea) 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: (" + simTextArea.cursorPosition + ")", skin, "scene-label-colored");
table.add(positionLabel);
table.row();
var slider = new Slider(0, simTextArea.text == null ? 0 : simTextArea.text.length(), 1, false, skin, "scene");
slider.setValue(simTextArea.cursorPosition);
table.add(slider).minWidth(200);
slider.addListener(handListener);
slider.addListener(new TextTooltip("The cursor position when the TextArea has keyboard focus.", tooltipManager, skin, "scene"));
slider.addListener(new ChangeListener() {
@Override
public void changed(ChangeEvent event, Actor actor) {
events.textAreaCursorPosition(MathUtils.round(slider.getValue()));
positionLabel.setText("Cursor Position: (" + simTextArea.cursorPosition + ")");
}
});
table.row();
var selectionLabel = new Label("Selection: (" + simTextArea.selectionStart + ", " + simTextArea.selectionEnd + ")", skin, "scene-label-colored");
table.add(selectionLabel);
table.row();
var rangeSlider = new RangeSlider(skin, "scene");
rangeSlider.setMinimum(0);
rangeSlider.setMaximum(simTextArea.text == null ? 0 : simTextArea.text.length());
rangeSlider.setIncrement(1);
rangeSlider.setValueBegin(simTextArea.selectionStart);
rangeSlider.setValueEnd(simTextArea.selectionEnd);
rangeSlider.setDisabled(simTextArea.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 TextArea has keyboard focus.", tooltipManager, skin, "scene"));
rangeSlider.addListener(new ValueBeginChangeListener() {
@Override
public void changed(ValueBeginChangeEvent event, float value, Actor actor) {
events.textAreaSelectionStart(MathUtils.round(value));
}
});
rangeSlider.addListener(new ValueEndChangeListener() {
@Override
public void changed(ValueEndChangeEvent event, float value, Actor actor) {
events.textAreaSelectionEnd(MathUtils.round(value));
}
});
rangeSlider.addListener(new ChangeListener() {
@Override
public void changed(ChangeEvent event, Actor actor) {
selectionLabel.setText("Selection: (" + simTextArea.selectionStart + ", " + simTextArea.selectionEnd + ")");
}
});
table.row();
var label = new Label("Select All: ", skin, "scene-label-colored");
table.add(label);
table.row();
var textButton = new TextButton(simTextArea.selectAll ? "TRUE" : "FALSE", skin, "scene-small");
textButton.setChecked(simTextArea.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.textAreaSelectAll(textButton.isChecked());
rangeSlider.setDisabled(textButton.isChecked());
}
});
}
};
popTableClickListener.update();
return popTableClickListener;
}
use of com.ray3k.stripe.RangeSlider 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;
}
Aggregations