use of com.ray3k.stripe.PopTableClickListener in project skin-composer by raeleus.
the class ImageButtonListeners method imageButtonNameListener.
public static EventListener imageButtonNameListener(final DialogSceneComposer dialogSceneComposer) {
var simImageButton = (DialogSceneComposerModel.SimImageButton) dialogSceneComposer.simActor;
var textField = new TextField("", skin, "scene");
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);
dialogSceneComposer.getStage().setKeyboardFocus(textField);
textField.setSelection(0, textField.getText().length());
update();
}
public void update() {
var popTable = getPopTable();
popTable.clearChildren();
var label = new Label("Name:", skin, "scene-label-colored");
popTable.add(label);
popTable.row();
textField.setText(simImageButton.name);
popTable.add(textField).minWidth(TEXT_FIELD_WIDTH);
textField.addListener(ibeamListener);
textField.addListener(new TextTooltip("The name of the button to allow for convenient searching via Group#findActor().", tooltipManager, skin, "scene"));
textField.addListener(new ChangeListener() {
@Override
public void changed(ChangeEvent event, Actor actor) {
dialogSceneComposer.events.imageButtonName(textField.getText());
}
});
textField.addListener(new InputListener() {
@Override
public boolean keyDown(InputEvent event, int keycode) {
if (keycode == Input.Keys.ENTER || keycode == Keys.NUMPAD_ENTER) {
popTable.hide();
return true;
} else {
return false;
}
}
});
dialogSceneComposer.getStage().setKeyboardFocus(textField);
textField.setSelection(0, textField.getText().length());
}
};
popTableClickListener.update();
return popTableClickListener;
}
use of com.ray3k.stripe.PopTableClickListener in project skin-composer by raeleus.
the class ImageButtonListeners method imageButtonColorListener.
public static EventListener imageButtonColorListener(final DialogSceneComposerEvents events, SimActor simActor) {
var simImageButton = (DialogSceneComposerModel.SimImageButton) 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("Color:", skin, "scene-label-colored");
popTable.add(label);
popTable.row();
var imageButton = new ImageButton(skin, "scene-color");
imageButton.getImage().setColor(simImageButton.color == null ? Color.WHITE : simImageButton.color.color);
popTable.add(imageButton).minWidth(100);
imageButton.addListener(handListener);
imageButton.addListener(new TextTooltip("Select the color of the button.", tooltipManager, skin, "scene"));
imageButton.addListener(new ChangeListener() {
@Override
public void changed(ChangeEvent event, Actor actor) {
popTable.hide();
dialogFactory.showDialogColors(new StyleProperty(), (colorData, pressedCancel) -> {
if (!pressedCancel) {
events.imageButtonColor(colorData);
}
}, new DialogListener() {
@Override
public void opened() {
}
@Override
public void closed() {
}
});
}
});
popTable.row();
label = new Label(simImageButton.color == null ? "white" : simImageButton.color.getName(), skin, "scene-label-colored");
popTable.add(label);
}
};
popTableClickListener.update();
return popTableClickListener;
}
use of com.ray3k.stripe.PopTableClickListener in project skin-composer by raeleus.
the class DialogSceneComposer method rootBackgroundColorListener.
private EventListener rootBackgroundColorListener() {
var popTableClickListener = new PopTableClickListener(skin) {
@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("Color:", skin, "scene-label-colored");
popTable.add(label);
popTable.row();
var imageButton = new ImageButton(skin, "scene-color");
imageButton.getImage().setColor(rootActor.backgroundColor == null ? Color.WHITE : rootActor.backgroundColor.color);
popTable.add(imageButton).minWidth(100);
imageButton.addListener(handListener);
imageButton.addListener(new TextTooltip("Select the color of the background.", tooltipManager, skin, "scene"));
imageButton.addListener(new ChangeListener() {
@Override
public void changed(ChangeEvent event, Actor actor) {
popTable.hide();
dialogFactory.showDialogColors(new StyleProperty(), (colorData, pressedCancel) -> {
if (!pressedCancel) {
events.rootBackgroundColor(colorData);
}
}, new DialogListener() {
@Override
public void opened() {
}
@Override
public void closed() {
}
});
}
});
popTable.row();
label = new Label(rootActor.backgroundColor == null ? "white" : rootActor.backgroundColor.getName(), skin, "scene-label-colored");
popTable.add(label);
}
};
popTableClickListener.update();
return popTableClickListener;
}
use of com.ray3k.stripe.PopTableClickListener in project skin-composer by raeleus.
the class DialogSceneComposer method populatePath.
public void populatePath() {
var root = pathTable;
root.clear();
var objects = new Array<DialogSceneComposerModel.SimActor>();
objects.add(simActor);
var object = simActor;
while (object != null) {
if (object.parent != null) {
object = object.parent;
objects.add(object);
} else {
object = null;
}
}
while (objects.size > 0) {
object = objects.pop();
var textButton = new TextButton(object.toString(), skin, object == simActor ? "scene-small-highlighted" : "scene-small");
textButton.setUserObject(object);
root.add(textButton);
textButton.addListener(handListener);
textButton.addListener(new ChangeListener() {
@Override
public void changed(ChangeEvent event, Actor actor) {
simActor = (DialogSceneComposerModel.SimActor) textButton.getUserObject();
populateProperties();
model.updatePreview();
populatePath();
}
});
if (objects.size > 0) {
var image = new Image(skin, "scene-icon-path-seperator");
root.add(image);
}
}
var popTableClickListener = new PopTableClickListener(skin);
var popTable = popTableClickListener.getPopTable();
var popSubTable = new Table();
var scrollPane = new ScrollPane(popSubTable, skin, "scene");
popTable.add(scrollPane).grow();
if (simActor instanceof DialogSceneComposerModel.SimTable) {
var table = (DialogSceneComposerModel.SimTable) simActor;
if (table.cells.size > 0) {
var image = new Image(skin, "scene-icon-path-child-seperator");
root.add(image);
var textButton = new TextButton("Select Child", skin, "scene-small");
root.add(textButton);
textButton.addListener(handListener);
int row = 0;
for (var cell : table.cells) {
var textButton1 = new TextButton(cell.toString(), skin, "scene-small");
if (cell.row > row) {
popSubTable.row();
row++;
}
popSubTable.add(textButton1).colspan(cell.colSpan).fillX();
textButton1.addListener(handListener);
textButton1.addListener(new ChangeListener() {
@Override
public void changed(ChangeEvent event, Actor actor) {
simActor = cell;
populateProperties();
model.updatePreview();
populatePath();
popTable.hide();
}
});
}
textButton.addListener(popTableClickListener);
}
} else if (simActor instanceof SimSingleChild) {
var simSingleChild = (SimSingleChild) simActor;
if (simSingleChild.getChild() != null) {
var image = new Image(skin, "scene-icon-path-child-seperator");
root.add(image);
var textButton = new TextButton(simSingleChild.getChild().toString(), skin, "scene-small");
root.add(textButton);
textButton.addListener(handListener);
textButton.addListener(new ChangeListener() {
@Override
public void changed(ChangeEvent event, Actor actor) {
simActor = simSingleChild.getChild();
populateProperties();
model.updatePreview();
populatePath();
}
});
}
} else if (simActor instanceof SimMultipleChildren) {
var simMultipleChildren = (SimMultipleChildren) simActor;
if (simMultipleChildren.getChildren().size > 0) {
var image = new Image(skin, "scene-icon-path-child-seperator");
root.add(image);
if (simMultipleChildren.getChildren().size == 1) {
var textButton = new TextButton(simMultipleChildren.getChildren().first().toString(), skin, "scene-small");
root.add(textButton);
textButton.addListener(handListener);
textButton.addListener(new ChangeListener() {
@Override
public void changed(ChangeEvent event, Actor actor) {
simActor = simMultipleChildren.getChildren().first();
populateProperties();
model.updatePreview();
populatePath();
}
});
} else {
var textButton = new TextButton("Select Child", skin, "scene-small");
root.add(textButton);
textButton.addListener(handListener);
for (var child : simMultipleChildren.getChildren()) {
var textButton1 = new TextButton(child.toString(), skin, "scene-small");
popSubTable.add(textButton1).row();
textButton1.addListener(handListener);
textButton1.addListener(new ChangeListener() {
@Override
public void changed(ChangeEvent event, Actor actor) {
simActor = child;
populateProperties();
populatePath();
model.updatePreview();
popTable.hide();
}
});
}
textButton.addListener(popTableClickListener);
}
}
}
root.add().growX();
}
use of com.ray3k.stripe.PopTableClickListener in project skin-composer by raeleus.
the class SelectBoxListeners method selectBoxScrollingListener.
public static EventListener selectBoxScrollingListener(final DialogSceneComposerEvents events, SimActor simActor) {
var simSelectBox = (DialogSceneComposerModel.SimSelectBox) 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("Scrolling Disabled:", skin, "scene-label-colored");
popTable.add(label);
popTable.row();
var textButton = new TextButton(simSelectBox.scrollingDisabled ? "TRUE" : "FALSE", skin, "scene-small");
textButton.setChecked(simSelectBox.scrollingDisabled);
popTable.add(textButton).minWidth(100);
textButton.addListener(handListener);
textButton.addListener(new TextTooltip("Whether the SelectBox scrolling is diabled", tooltipManager, skin, "scene"));
textButton.addListener(new ChangeListener() {
@Override
public void changed(ChangeEvent event, Actor actor) {
textButton.setText(textButton.isChecked() ? "TRUE" : "FALSE");
events.selectBoxScrollingDisabled(textButton.isChecked());
}
});
}
};
popTableClickListener.update();
return popTableClickListener;
}
Aggregations