use of com.kotcrab.vis.ui.widget.MenuItem in project HyperLap2D by rednblackgames.
the class FileMenu method addRecent.
public void addRecent(ArrayList<String> paths) {
for (String path : paths) {
MenuItem menuItem = new MenuItem(getFolderNameAndPath(path), new MenuItemListener(RECENT_PROJECTS, path, FILE_MENU));
recentProjectsMenuItems.add(menuItem);
recentProjectsPopupMenu.addItem(menuItem);
}
}
use of com.kotcrab.vis.ui.widget.MenuItem in project HyperLap2D by rednblackgames.
the class NodeEditorDialog method createGraphPopupMenu.
private H2DPopupMenu createGraphPopupMenu(final float popupX, final float popupY) {
H2DPopupMenu popupMenu = new H2DPopupMenu();
for (final GraphBoxProducer<ActionFieldType> producer : graphBoxProducers) {
if (producer.isUnique())
continue;
String menuLocation = producer.getMenuLocation();
if (menuLocation != null) {
String[] menuSplit = menuLocation.split("/");
PopupMenu targetMenu = findOrCreatePopupMenu(popupMenu, menuSplit, 0);
final String title = producer.getName();
MenuItem valueMenuItem = new MenuItem(title);
valueMenuItem.addListener(new ClickListener(Input.Buttons.LEFT) {
@Override
public void clicked(InputEvent event, float x, float y) {
String id = UUID.randomUUID().toString().replace("-", "");
GraphBox<ActionFieldType> graphBox = producer.createDefault(skin, id);
graphContainer.addGraphBox(graphBox, title, true, popupX, popupY);
}
});
targetMenu.addItem(valueMenuItem);
}
}
return popupMenu;
}
use of com.kotcrab.vis.ui.widget.MenuItem in project HyperLap2D by rednblackgames.
the class GraphContainer method setupListeners.
private void setupListeners() {
addListener(new ClickListener(Input.Buttons.RIGHT) {
@Override
public void clicked(InputEvent event, 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;
H2DPopupMenu popupMenu = new H2DPopupMenu();
MenuItem rename = new MenuItem("Rename group");
rename.addListener(new ClickListener(Input.Buttons.LEFT) {
@Override
public void clicked(InputEvent event, float x, float y) {
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() {
}
}).setText(finalNodeGroup.getName(), true);
}
});
popupMenu.addItem(rename);
MenuItem remove = new MenuItem("Remove group");
remove.addListener(new ClickListener(Input.Buttons.LEFT) {
@Override
public void clicked(InputEvent event, float x, float y) {
nodeGroups.remove(finalNodeGroup);
fire(new GraphChangedEvent(false, false));
}
});
popupMenu.addItem(remove);
showPopupMenu(popupMenu);
} else {
H2DPopupMenu popupMenu = popupMenuProducer.createPopupMenu(x, y);
showPopupMenu(popupMenu);
}
}
}
});
addListener(new ClickListener(Input.Buttons.LEFT) {
@Override
public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) {
processLeftClick(x, y);
return super.touchDown(event, x, y, pointer, button);
}
@Override
public void touchUp(InputEvent event, float x, float y, int pointer, int button) {
super.touchUp(event, x, y, pointer, button);
processLeftClick(x, y);
}
});
DragListener dragListener = new DragListener() {
private float canvasXStart;
private float canvasYStart;
private NodeGroup dragGroup;
private float movedByX = 0;
private float movedByY = 0;
@Override
public void dragStart(InputEvent event, float x, float y, int pointer) {
if (event.getTarget() == GraphContainer.this) {
canvasXStart = canvasX;
canvasYStart = canvasY;
movedByX = 0;
movedByY = 0;
dragGroup = 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
dragGroup = nodeGroupEntry.getKey();
break;
}
}
}
}
@Override
public void drag(InputEvent event, float x, float y, int pointer) {
if (event.getTarget() == GraphContainer.this) {
if (dragGroup != null) {
movingSelected = true;
float moveByX = x - getDragStartX() - movedByX;
float moveByY = y - getDragStartY() - movedByY;
for (String nodeId : dragGroup.getNodeIds()) {
getBoxWindow(nodeId).moveBy(moveByX, moveByY);
}
movedByX += moveByX;
movedByY += moveByY;
windowsMoved();
updateNodeGroups();
movingSelected = false;
} else {
navigateTo(canvasXStart + getDragStartX() - x, canvasYStart + getDragStartY() - y);
}
}
}
};
dragListener.setTapSquareSize(0f);
dragListener.setButton(Input.Buttons.MIDDLE);
addListener(dragListener);
}
use of com.kotcrab.vis.ui.widget.MenuItem in project Eidolons by IDemiurge.
the class MenuPanel method initControlMenus.
public void initControlMenus(LE_ControlPanel[] panels) {
Menu.MenuStyle style = (StyleHolder.getMenuStyle());
TextButton.TextButtonStyle btnStyle = (StyleHolder.getMenuBtnStyle());
for (LE_ControlPanel panel : panels) {
Menu menu = new Menu(TabbedControlPanel.getTitleFromClass(panel.getClazz()), style);
addMenu(menu);
for (Method method : panel.getClazz().getMethods()) {
MenuItem item = new MenuItem(StringMaster.format(method.getName()));
item.addListener(createItemListener(item, method, panel.getHandler()));
menu.addItem(item);
item.setStyle(btnStyle);
}
}
}
Aggregations