use of com.ray3k.skincomposer.dialog.DialogListener in project skin-composer by raeleus.
the class ImageTextButtonListeners method imageTextButtonColorListener.
public static EventListener imageTextButtonColorListener(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("Color:", skin, "scene-label-colored");
popTable.add(label);
popTable.row();
var imageButton = new ImageButton(skin, "scene-color");
imageButton.getImage().setColor(simImageTextButton.color == null ? Color.WHITE : simImageTextButton.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.imageTextButtonColor(colorData);
}
}, new DialogListener() {
@Override
public void opened() {
}
@Override
public void closed() {
}
});
}
});
popTable.row();
label = new Label(simImageTextButton.color == null ? "white" : simImageTextButton.color.getName(), skin, "scene-label-colored");
popTable.add(label);
}
};
popTableClickListener.update();
return popTableClickListener;
}
use of com.ray3k.skincomposer.dialog.DialogListener in project skin-composer by raeleus.
the class Main method initDefaults.
private void initDefaults() {
if (Utils.isMac())
System.setProperty("java.awt.headless", "true");
skin.getFont("font").getData().markupEnabled = true;
// copy defaults.json to temp folder if it doesn't exist
var fileHandle = appFolder.child("texturepacker/atlas-export-settings.json");
if (!fileHandle.exists()) {
Gdx.files.internal("atlas-export-settings.json").copyTo(fileHandle);
}
// copy atlas settings for preview to temp folder if it doesn't exist
fileHandle = appFolder.child("texturepacker/atlas-internal-settings.json");
if (!fileHandle.exists()) {
Gdx.files.internal("atlas-internal-settings.json").copyTo(fileHandle);
}
// copy white-pixel.png for pixel drawables
fileHandle = appFolder.child("texturepacker/white-pixel.png");
if (!fileHandle.exists()) {
Gdx.files.internal("white-pixel.png").copyTo(fileHandle);
}
// copy preview fonts to preview fonts folder if they do not exist
fileHandle = appFolder.child("preview fonts/IBMPlexSerif-Medium.ttf");
if (!fileHandle.exists()) {
Gdx.files.internal("preview fonts/IBMPlexSerif-Medium.ttf").copyTo(fileHandle);
}
fileHandle = appFolder.child("preview fonts/Pacifico-Regular.ttf");
if (!fileHandle.exists()) {
Gdx.files.internal("preview fonts/Pacifico-Regular.ttf").copyTo(fileHandle);
}
fileHandle = appFolder.child("preview fonts/PressStart2P-Regular.ttf");
if (!fileHandle.exists()) {
Gdx.files.internal("preview fonts/PressStart2P-Regular.ttf").copyTo(fileHandle);
}
fileHandle = appFolder.child("preview fonts/SourceSansPro-Regular.ttf");
if (!fileHandle.exists()) {
Gdx.files.internal("preview fonts/SourceSansPro-Regular.ttf").copyTo(fileHandle);
}
ibeamListener = new IbeamListener();
dialogFactory = new DialogFactory();
projectData = new ProjectData();
projectData.randomizeId();
projectData.setMaxUndos(30);
atlasData = projectData.getAtlasData();
jsonData = projectData.getJsonData();
newVersion = VERSION;
if (projectData.isCheckingForUpdates()) {
checkForUpdates(this);
}
undoableManager = new UndoableManager(this);
desktopWorker.attachLogListener();
desktopWorker.setCloseListener(() -> {
dialogFactory.showCloseDialog(new DialogListener() {
@Override
public void opened() {
desktopWorker.removeFilesDroppedListener(rootTable.getFilesDroppedListener());
}
@Override
public void closed() {
desktopWorker.addFilesDroppedListener(rootTable.getFilesDroppedListener());
}
});
return false;
});
loadingAnimation = skin.get("loading-animation", TenPatchDrawable.class);
loadingAnimation2 = skin.get("loading-animation2", TenPatchDrawable.class);
projectData.getAtlasData().clearTempData();
handListener = new HandListener();
scrollFocusListener = new ScrollFocusListener(stage);
verticalResizeArrowListener = new ResizeArrowListener(true);
horizontalResizeArrowListener = new ResizeArrowListener(false);
tooltipManager = new TooltipManager();
tooltipManager.animations = false;
tooltipManager.initialTime = .4f;
tooltipManager.resetTime = 0.0f;
tooltipManager.subsequentTime = 0.0f;
tooltipManager.hideAll();
tooltipManager.instant();
}
use of com.ray3k.skincomposer.dialog.DialogListener in project skin-composer by raeleus.
the class ButtonListeners method buttonColorListener.
public static EventListener buttonColorListener(final DialogSceneComposerEvents events, SimActor simActor) {
var simButton = (DialogSceneComposerModel.SimButton) 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(simButton.color == null ? Color.WHITE : simButton.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.buttonColor(colorData);
}
}, new DialogListener() {
@Override
public void opened() {
}
@Override
public void closed() {
}
});
}
});
popTable.row();
label = new Label(simButton.color == null ? "white" : simButton.color.getName(), skin, "scene-label-colored");
popTable.add(label);
}
};
popTableClickListener.update();
return popTableClickListener;
}
use of com.ray3k.skincomposer.dialog.DialogListener in project skin-composer by raeleus.
the class CheckBoxListeners method checkBoxColorListener.
public static EventListener checkBoxColorListener(final DialogSceneComposerEvents events, SimActor simActor) {
var simCheckBox = (DialogSceneComposerModel.SimCheckBox) 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(simCheckBox.color == null ? Color.WHITE : simCheckBox.color.color);
popTable.add(imageButton).minWidth(100);
imageButton.addListener(handListener);
imageButton.addListener(new TextTooltip("Select the color of the CheckBox.", 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.checkBoxColor(colorData);
}
}, new DialogListener() {
@Override
public void opened() {
}
@Override
public void closed() {
}
});
}
});
popTable.row();
label = new Label(simCheckBox.color == null ? "white" : simCheckBox.color.getName(), skin, "scene-label-colored");
popTable.add(label);
}
};
popTableClickListener.update();
return popTableClickListener;
}
use of com.ray3k.skincomposer.dialog.DialogListener in project skin-composer by raeleus.
the class DialogSceneComposer method showSettingsDialog.
public PopTable showSettingsDialog() {
var root = new PopTable(skin);
root.setHideOnUnfocus(true);
root.setModal(true);
root.setKeepSizedWithinStage(true);
root.setKeepCenteredInWindow(true);
root.pad(20);
var label = new Label("Settings", skin, "scene-title-bg");
label.setAlignment(Align.center);
root.add(label).growX().padBottom(10);
root.row();
var table = new Table();
root.add(table).growX();
table.defaults().left().space(5);
label = new Label("Package", skin, "scene-label-colored");
table.add(label);
var textField = new TextField(rootActor.packageString, skin, "scene");
var keyboardFocus = textField;
table.add(textField).width(300).uniformX();
textField.addListener(ibeamListener);
textField.addListener(new ChangeListener() {
@Override
public void changed(ChangeEvent event, Actor actor) {
events.rootPackage(((TextField) actor).getText());
}
});
table.row();
label = new Label("Class", skin, "scene-label-colored");
table.add(label);
textField = new TextField(rootActor.classString, skin, "scene");
table.add(textField).uniformX().fillX();
textField.addListener(ibeamListener);
textField.addListener(new ChangeListener() {
@Override
public void changed(ChangeEvent event, Actor actor) {
events.rootClass(((TextField) actor).getText());
}
});
table.row();
label = new Label("Skin Path", skin, "scene-label-colored");
table.add(label);
textField = new TextField(rootActor.skinPath, skin, "scene");
table.add(textField).uniformX().fillX();
textField.addListener(ibeamListener);
textField.addListener(new ChangeListener() {
@Override
public void changed(ChangeEvent event, Actor actor) {
events.rootSkinPath(((TextField) actor).getText());
}
});
table.row();
label = new Label("Background Color", skin, "scene-label-colored");
table.add(label);
var imageButton = new ImageButton(new ImageButton.ImageButtonStyle(skin.get("scene-color", ImageButton.ImageButtonStyle.class)));
imageButton.getImage().setColor(rootActor.backgroundColor == null ? Color.WHITE : rootActor.backgroundColor.color);
table.add(imageButton).left();
imageButton.addListener(handListener);
imageButton.addListener(new ChangeListener() {
@Override
public void changed(ChangeEvent event, Actor actor) {
dialogFactory.showDialogColors(new StyleProperty(), (colorData, pressedCancel) -> {
if (!pressedCancel) {
events.rootBackgroundColor(colorData);
imageButton.getImage().setColor(colorData == null ? Color.WHITE : colorData.color);
}
}, new DialogListener() {
@Override
public void opened() {
}
@Override
public void closed() {
}
});
}
});
root.show(getStage());
getStage().setKeyboardFocus(keyboardFocus);
return root;
}
Aggregations