use of com.ray3k.skincomposer.dialog.scenecomposer.DialogSceneComposerModel.SimActor in project skin-composer by raeleus.
the class TextAreaListeners method textAreaFocusTraversalListener.
public static EventListener textAreaFocusTraversalListener(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 label = new Label("Focus Traversal:", skin, "scene-label-colored");
popTable.add(label);
popTable.row();
var textButton = new TextButton(simTextArea.focusTraversal ? "TRUE" : "FALSE", skin, "scene-small");
textButton.setChecked(simTextArea.focusTraversal);
popTable.add(textButton).minWidth(100);
textButton.addListener(handListener);
textButton.addListener(new TextTooltip("Whether the TextArea allows for the use of focus traversal keys.", tooltipManager, skin, "scene"));
textButton.addListener(new ChangeListener() {
@Override
public void changed(ChangeEvent event, Actor actor) {
textButton.setText(textButton.isChecked() ? "TRUE" : "FALSE");
events.textAreaFocusTraversal(textButton.isChecked());
}
});
}
};
popTableClickListener.update();
return popTableClickListener;
}
use of com.ray3k.skincomposer.dialog.scenecomposer.DialogSceneComposerModel.SimActor 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.skincomposer.dialog.scenecomposer.DialogSceneComposerModel.SimActor in project skin-composer by raeleus.
the class TextAreaListeners method textAreaDisabledListener.
public static EventListener textAreaDisabledListener(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 label = new Label("Disabled:", skin, "scene-label-colored");
popTable.add(label);
popTable.row();
var textButton = new TextButton(simTextArea.disabled ? "TRUE" : "FALSE", skin, "scene-small");
textButton.setChecked(simTextArea.disabled);
popTable.add(textButton).minWidth(100);
textButton.addListener(handListener);
textButton.addListener(new TextTooltip("Whether the TextArea is disabled initially.", tooltipManager, skin, "scene"));
textButton.addListener(new ChangeListener() {
@Override
public void changed(ChangeEvent event, Actor actor) {
textButton.setText(textButton.isChecked() ? "TRUE" : "FALSE");
events.textAreaDisabled(textButton.isChecked());
}
});
}
};
popTableClickListener.update();
return popTableClickListener;
}
use of com.ray3k.skincomposer.dialog.scenecomposer.DialogSceneComposerModel.SimActor 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.ray3k.skincomposer.dialog.scenecomposer.DialogSceneComposerModel.SimActor in project skin-composer by raeleus.
the class TableListeners method tablePaddingListener.
public static EventListener tablePaddingListener(final DialogSceneComposerEvents events, SimActor simActor) {
var simTable = (DialogSceneComposerModel.SimTable) 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();
popTable.defaults().reset();
var changeListener = new ChangeListener() {
@Override
public void changed(ChangeEvent event, Actor actor) {
TextButton paddingButton = popTable.findActor("padding-button");
paddingButton.setText(paddingButton.isChecked() ? "Enabled" : "Disabled");
Spinner padLeft = popTable.findActor("pad-left");
padLeft.setTouchable(paddingButton.isChecked() ? Touchable.enabled : Touchable.disabled);
padLeft.getTextField().setDisabled(!paddingButton.isChecked());
padLeft.getButtonMinus().setDisabled(!paddingButton.isChecked());
padLeft.getButtonPlus().setDisabled(!paddingButton.isChecked());
Spinner padRight = popTable.findActor("pad-right");
padRight.setTouchable(paddingButton.isChecked() ? Touchable.enabled : Touchable.disabled);
padRight.getTextField().setDisabled(!paddingButton.isChecked());
padRight.getButtonMinus().setDisabled(!paddingButton.isChecked());
padRight.getButtonPlus().setDisabled(!paddingButton.isChecked());
Spinner padTop = popTable.findActor("pad-top");
padTop.setTouchable(paddingButton.isChecked() ? Touchable.enabled : Touchable.disabled);
padTop.getTextField().setDisabled(!paddingButton.isChecked());
padTop.getButtonMinus().setDisabled(!paddingButton.isChecked());
padTop.getButtonPlus().setDisabled(!paddingButton.isChecked());
Spinner padBottom = popTable.findActor("pad-bottom");
padBottom.setTouchable(paddingButton.isChecked() ? Touchable.enabled : Touchable.disabled);
padBottom.getTextField().setDisabled(!paddingButton.isChecked());
padBottom.getButtonMinus().setDisabled(!paddingButton.isChecked());
padBottom.getButtonPlus().setDisabled(!paddingButton.isChecked());
events.tablePadding(paddingButton.isChecked(), (float) padLeft.getValue(), (float) padRight.getValue(), (float) padTop.getValue(), (float) padBottom.getValue());
}
};
var label = new Label("Padding", skin, "scene-label-colored");
popTable.add(label).colspan(2);
popTable.row();
popTable.defaults().right().spaceRight(5);
var textButton = new TextButton(simTable.paddingEnabled ? "Enabled" : "Disabled", skin, "scene-small");
textButton.setChecked(simTable.paddingEnabled);
textButton.setName("padding-button");
popTable.add(textButton).minWidth(150).colspan(2);
textButton.addListener(handListener);
textButton.addListener(new TextTooltip("Whether the button is checked initially.", tooltipManager, skin, "scene"));
textButton.addListener(changeListener);
popTable.row();
label = new Label("Left:", skin, "scene-label-colored");
popTable.add(label);
var spinner = new Spinner(0, 1, true, Spinner.Orientation.RIGHT_STACK, skin, "scene");
spinner.setName("pad-left");
spinner.setValue(simTable.padLeft);
spinner.setTouchable(simTable.paddingEnabled ? Touchable.enabled : Touchable.disabled);
spinner.getTextField().setDisabled(!simTable.paddingEnabled);
spinner.getButtonMinus().setDisabled(!simTable.paddingEnabled);
spinner.getButtonPlus().setDisabled(!simTable.paddingEnabled);
popTable.add(spinner);
spinner.getTextField().addListener(ibeamListener);
spinner.getButtonMinus().addListener(handListener);
spinner.getButtonPlus().addListener(handListener);
spinner.addListener(new TextTooltip("The padding on the left of the contents.", tooltipManager, skin, "scene"));
spinner.addListener(changeListener);
popTable.row();
label = new Label("Right:", skin, "scene-label-colored");
popTable.add(label);
spinner = new Spinner(0, 1, true, Spinner.Orientation.RIGHT_STACK, skin, "scene");
spinner.setName("pad-right");
spinner.setValue(simTable.padRight);
spinner.setTouchable(simTable.paddingEnabled ? Touchable.enabled : Touchable.disabled);
spinner.getTextField().setDisabled(!simTable.paddingEnabled);
spinner.getButtonMinus().setDisabled(!simTable.paddingEnabled);
spinner.getButtonPlus().setDisabled(!simTable.paddingEnabled);
popTable.add(spinner);
spinner.getTextField().addListener(ibeamListener);
spinner.getButtonMinus().addListener(handListener);
spinner.getButtonPlus().addListener(handListener);
spinner.addListener(new TextTooltip("The padding on the right of the contents.", tooltipManager, skin, "scene"));
spinner.addListener(changeListener);
popTable.row();
label = new Label("Top:", skin, "scene-label-colored");
popTable.add(label);
spinner = new Spinner(0, 1, true, Spinner.Orientation.RIGHT_STACK, skin, "scene");
spinner.setName("pad-top");
spinner.setValue(simTable.padTop);
spinner.setTouchable(simTable.paddingEnabled ? Touchable.enabled : Touchable.disabled);
spinner.getTextField().setDisabled(!simTable.paddingEnabled);
spinner.getButtonMinus().setDisabled(!simTable.paddingEnabled);
spinner.getButtonPlus().setDisabled(!simTable.paddingEnabled);
popTable.add(spinner);
spinner.getTextField().addListener(ibeamListener);
spinner.getButtonMinus().addListener(handListener);
spinner.getButtonPlus().addListener(handListener);
spinner.addListener(new TextTooltip("The padding on the top of the contents.", tooltipManager, skin, "scene"));
spinner.addListener(changeListener);
popTable.row();
label = new Label("Bottom:", skin, "scene-label-colored");
popTable.add(label);
spinner = new Spinner(0, 1, true, Spinner.Orientation.RIGHT_STACK, skin, "scene");
spinner.setName("pad-bottom");
spinner.setValue(simTable.padBottom);
spinner.setTouchable(simTable.paddingEnabled ? Touchable.enabled : Touchable.disabled);
spinner.getTextField().setDisabled(!simTable.paddingEnabled);
spinner.getButtonMinus().setDisabled(!simTable.paddingEnabled);
spinner.getButtonPlus().setDisabled(!simTable.paddingEnabled);
popTable.add(spinner);
spinner.getTextField().addListener(ibeamListener);
spinner.getButtonMinus().addListener(handListener);
spinner.getButtonPlus().addListener(handListener);
spinner.addListener(new TextTooltip("The padding on the bottom of the contents.", tooltipManager, skin, "scene"));
spinner.addListener(changeListener);
}
};
popTableClickListener.update();
return popTableClickListener;
}
Aggregations