use of com.kotcrab.vis.ui.widget.PopupMenu in project HyperLap2D by rednblackgames.
the class NodeEditorDialog method findOrCreatePopupMenu.
private PopupMenu findOrCreatePopupMenu(PopupMenu popupMenu, String[] menuSplit, int startIndex) {
for (Actor child : popupMenu.getChildren()) {
MenuItem childMenuItem = (MenuItem) child;
if (childMenuItem.getLabel().getText().toString().equals(menuSplit[startIndex]) && childMenuItem.getSubMenu() != null) {
if (startIndex + 1 < menuSplit.length) {
return findOrCreatePopupMenu(childMenuItem.getSubMenu(), menuSplit, startIndex + 1);
} else {
return childMenuItem.getSubMenu();
}
}
}
PopupMenu createdPopup = new H2DPopupMenu();
MenuItem createdMenuItem = new MenuItem(menuSplit[startIndex]);
createdMenuItem.setSubMenu(createdPopup);
popupMenu.addItem(createdMenuItem);
if (startIndex + 1 < menuSplit.length) {
return findOrCreatePopupMenu(createdPopup, menuSplit, startIndex + 1);
} else {
return createdPopup;
}
}
use of com.kotcrab.vis.ui.widget.PopupMenu in project gdx-graph by MarcinSc.
the class GraphContainer method processRightClick.
private void processRightClick(float x, float y) {
if (!containedInWindow(x, y)) {
NodeGroupImpl nodeGroup = null;
for (Map.Entry<NodeGroupImpl, Rectangle> nodeGroupEntry : nodeGroups.entrySet()) {
Rectangle rectangle = nodeGroupEntry.getValue();
if (rectangle.contains(x, y) && y > rectangle.y + rectangle.height - GROUP_LABEL_HEIGHT) {
// Hit the label
nodeGroup = nodeGroupEntry.getKey();
break;
}
}
if (nodeGroup != null) {
final NodeGroupImpl finalNodeGroup = nodeGroup;
PopupMenu popupMenu = new PopupMenu();
MenuItem rename = new MenuItem("Rename group");
rename.addListener(new ChangeListener() {
@Override
public void changed(ChangeEvent event, Actor actor) {
Dialogs.showInputDialog(getStage(), "Enter group name", "Name", new InputValidator() {
@Override
public boolean validateInput(String input) {
return !input.trim().isEmpty();
}
}, new InputDialogListener() {
@Override
public void finished(String input) {
finalNodeGroup.setName(input.trim());
fire(new GraphChangedEvent(false, false));
}
@Override
public void canceled() {
}
});
}
});
popupMenu.addItem(rename);
MenuItem remove = new MenuItem("Remove group");
remove.addListener(new ChangeListener() {
@Override
public void changed(ChangeEvent event, Actor actor) {
nodeGroups.remove(finalNodeGroup);
fire(new GraphChangedEvent(false, false));
}
});
popupMenu.addItem(remove);
popupMenu.showMenu(getStage(), x + getX(), y + getY());
} else {
PopupMenu popupMenu = popupMenuProducer.createPopupMenu(x, y);
popupMenu.showMenu(getStage(), x + getX(), y + getY());
}
}
}
use of com.kotcrab.vis.ui.widget.PopupMenu in project talos by rockbite.
the class ModuleWrapperGroup method init.
public void init(Skin skin) {
this.skin = skin;
frameImage = new Image(skin.getDrawable("group_frame"));
frameImage.setColor(44 / 255f, 140 / 255f, 209 / 255f, 1f);
addActor(frameImage);
topHit = new Actor();
topHit.setTouchable(Touchable.enabled);
addActor(topHit);
title = new EditableLabel("GROUP NAME", skin);
addActor(title);
settings = new ImageButton(skin, "settings");
settings.setSize(25, 25);
addActor(settings);
settings.addListener(new ClickListener() {
@Override
public void clicked(InputEvent event, float x, float y) {
final Vector2 vec = new Vector2(Gdx.input.getX(), Gdx.input.getY());
(TalosMain.Instance().UIStage().getStage().getViewport()).unproject(vec);
settingsPopup.showMenu(TalosMain.Instance().UIStage().getStage(), vec.x, vec.y);
}
});
settingsPopup = new PopupMenu();
MenuItem changeColorMenuItem = new MenuItem("Change Color");
MenuItem ungroupMenuItem = new MenuItem("Ungroup");
settingsPopup.addItem(changeColorMenuItem);
settingsPopup.addItem(ungroupMenuItem);
changeColorMenuItem.addListener(new ClickListener() {
@Override
public void clicked(InputEvent event, float x, float y) {
TalosMain.Instance().UIStage().showColorPicker(new ColorPickerAdapter() {
@Override
public void changed(Color newColor) {
super.changed(newColor);
frameImage.setColor(newColor);
}
});
}
});
ungroupMenuItem.addListener(new ClickListener() {
@Override
public void clicked(InputEvent event, float x, float y) {
super.clicked(event, x, y);
TalosMain.Instance().NodeStage().moduleBoardWidget.removeGroup(ModuleWrapperGroup.this);
}
});
topHit.addListener(new ClickListener() {
Vector2 tmp = new Vector2();
Vector2 pos = new Vector2();
Vector2 diff = new Vector2();
@Override
public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) {
pos.set(x, y);
topHit.localToStageCoordinates(pos);
TalosMain.Instance().NodeStage().moduleBoardWidget.setSelectedWrappers(wrappers);
return true;
}
@Override
public void touchDragged(InputEvent event, float x, float y, int pointer) {
tmp.set(x, y);
topHit.localToStageCoordinates(tmp);
diff.set(tmp).sub(pos);
moveGroupBy(diff.x, diff.y);
pos.set(tmp);
super.touchDragged(event, x, y, pointer);
}
});
setTouchable(Touchable.childrenOnly);
frameImage.setTouchable(Touchable.disabled);
}
use of com.kotcrab.vis.ui.widget.PopupMenu in project talos by rockbite.
the class HierarchyWidget method showContextMenu.
private void showContextMenu(GameObject gameObject) {
contextualMenu.clearItems();
contextualMenu.addItem("Convert to Prefab", new ClickListener() {
@Override
public void clicked(InputEvent event, float x, float y) {
FilteredTree.Node item = (FilteredTree.Node) tree.getSelection().first();
GameObject gameObject = objectMap.get(item.getName());
SceneEditorAddon.get().workspace.convertToPrefab(gameObject);
}
});
contextualMenu.addSeparator();
contextualMenu.addItem("Cut", new ClickListener() {
@Override
public void clicked(InputEvent event, float x, float y) {
}
});
contextualMenu.addItem("Copy", new ClickListener() {
@Override
public void clicked(InputEvent event, float x, float y) {
}
});
contextualMenu.addItem("Paste", new ClickListener() {
@Override
public void clicked(InputEvent event, float x, float y) {
}
});
contextualMenu.addSeparator();
contextualMenu.addItem("Rename", new ClickListener() {
@Override
public void clicked(InputEvent event, float x, float y) {
}
});
contextualMenu.addItem("Duplicate", new ClickListener() {
@Override
public void clicked(InputEvent event, float x, float y) {
}
});
contextualMenu.addItem("Delete", new ClickListener() {
@Override
public void clicked(InputEvent event, float x, float y) {
Array<GameObject> gameObjects = new Array<>();
for (Object nodeObject : tree.getSelection()) {
FilteredTree.Node node = (FilteredTree.Node) nodeObject;
if (objectMap.containsKey(node.getName())) {
GameObject gameObject = objectMap.get(node.getName());
gameObjects.add(gameObject);
}
}
SceneEditorAddon.get().workspace.deleteGameObjects(gameObjects);
}
});
contextualMenu.addSeparator();
PopupMenu popupMenu = new PopupMenu();
ObjectMap<String, XmlReader.Element> confMap = SceneEditorAddon.get().workspace.templateListPopup.getConfMap();
for (String key : confMap.keys()) {
XmlReader.Element element = confMap.get(key);
MenuItem item = new MenuItem(element.getAttribute("title"));
final String name = element.getAttribute("name");
item.addListener(new ClickListener() {
@Override
public void clicked(InputEvent event, float x, float y) {
SceneEditorAddon.get().workspace.createObjectByTypeName(name, new Vector2(), gameObject);
}
});
popupMenu.addItem(item);
}
MenuItem createMenu = contextualMenu.addItem("Create", new ClickListener() {
@Override
public void clicked(InputEvent event, float x, float y) {
super.clicked(event, x, y);
}
});
createMenu.setSubMenu(popupMenu);
contextualMenu.show(getStage());
}
use of com.kotcrab.vis.ui.widget.PopupMenu in project talos by rockbite.
the class ProjectExplorerWidget method showContextMenu.
public void showContextMenu(Array<FileHandle> files) {
contextualMenu.clearItems();
contextualMenu.addItem("Cut", new ClickListener() {
@Override
public void clicked(InputEvent event, float x, float y) {
invokeCut(files);
}
});
contextualMenu.addItem("Copy", new ClickListener() {
@Override
public void clicked(InputEvent event, float x, float y) {
invokeCopy(files);
}
});
contextualMenu.addItem("Paste", new ClickListener() {
@Override
public void clicked(InputEvent event, float x, float y) {
FileHandle destination = files.first();
invokePaste(destination);
}
});
contextualMenu.addSeparator();
contextualMenu.addItem("Rename", new ClickListener() {
@Override
public void clicked(InputEvent event, float x, float y) {
String path = files.first().path();
if (path != null) {
FileHandle handle = Gdx.files.absolute(path);
if (handle.isDirectory()) {
if (nodes.get(path) != null) {
RowWidget widget = (RowWidget) nodes.get(path).getActor();
widget.label.setEditMode();
}
} else {
// check if its in the other guy
directoryViewWidget.startRenameFor(handle);
}
}
}
});
contextualMenu.addItem("Delete", new ClickListener() {
@Override
public void clicked(InputEvent event, float x, float y) {
String path = files.first().path();
Array<String> paths = new Array<>();
for (FileHandle file : files) {
paths.add(file.path());
}
deletePath(paths);
}
});
if (files.size == 1 && files.first().isDirectory()) {
contextualMenu.addSeparator();
PopupMenu popupMenu = new PopupMenu();
createSubMenuItem(popupMenu, "New Directory", new ClickListener() {
@Override
public void clicked(InputEvent event, float x, float y) {
String path = files.first().path();
if (path != null) {
FileHandle handle = Gdx.files.absolute(path);
if (handle.isDirectory()) {
FileHandle newHandle = findAvailableHandleIn(handle, "New Directory");
newHandle.mkdirs();
loadDirectoryTree((String) rootNode.getObject());
FilteredTree.Node newNode = nodes.get(newHandle.path());
expand(newHandle.path());
select(newNode.getParent());
RowWidget widget = (RowWidget) newNode.getActor();
directoryViewWidget.reload();
directoryViewWidget.startRenameFor(newHandle);
}
}
}
});
createSubMenuItem(popupMenu, "New Scene", new ClickListener() {
@Override
public void clicked(InputEvent event, float x, float y) {
String path = files.first().path();
FileHandle sceneDestination = AssetImporter.suggestNewName(path, "New Scene", "scn");
Scene mainScene = new Scene(sceneDestination.path());
mainScene.save();
directoryViewWidget.reload();
}
});
createSubMenuItem(popupMenu, "Particle Effect", new ClickListener() {
@Override
public void clicked(InputEvent event, float x, float y) {
String path = files.first().path();
FileHandle tlsDestination = AssetImporter.suggestNewName(path, "New Effect", "tls");
FileHandle metadataHandle = AssetImporter.makeSimilar(tlsDestination, "meta");
FileHandle originalTls = Gdx.files.internal("addons/scene/missing/sample.tls");
originalTls.copyTo(tlsDestination);
TlsMetadata metadata = new TlsMetadata();
metadata.tlsChecksum = AssetImporter.checkSum(tlsDestination);
AssetImporter.saveMetadata(metadataHandle, metadata);
directoryViewWidget.reload();
}
});
MenuItem createMenu = contextualMenu.addItem("Create", new ClickListener() {
@Override
public void clicked(InputEvent event, float x, float y) {
super.clicked(event, x, y);
}
});
createMenu.setSubMenu(popupMenu);
}
contextualMenu.show(getStage());
}
Aggregations