use of com.kotcrab.vis.ui.widget.MenuItem 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.MenuItem in project HyperLap2D by rednblackgames.
the class UIDropDownMenu method initView.
private void initView() {
clear();
for (int i = 0; i < currentActionList.size; i++) {
String itemName = actionNames.get(currentActionList.get(i));
MenuItem menuItem = new MenuItem(itemName, new MenuItemListener(ITEM_CLICKED, currentActionList.get(i)));
addItem(menuItem);
}
}
use of com.kotcrab.vis.ui.widget.MenuItem in project HyperLap2D by rednblackgames.
the class FileMenu method reInitRecent.
public void reInitRecent(ArrayList<String> paths) {
if (recentProjectsMenuItems == null || recentProjectsPopupMenu == null)
return;
if (recentProjectsMenuItems.size != 0) {
recentProjectsMenuItems.clear();
}
if (recentProjectsPopupMenu.hasChildren()) {
recentProjectsPopupMenu.remove();
recentProjectsPopupMenu.clearChildren();
}
addRecent(paths);
if (paths.size() > 0) {
recentProjectsPopupMenu.addSeparator();
}
MenuItem menuItem = new MenuItem("Clear history", new MenuItemListener(CLEAR_RECENT, null, FILE_MENU));
recentProjectsMenuItems.add(menuItem);
recentProjectsPopupMenu.addItem(menuItem);
remove();
}
use of com.kotcrab.vis.ui.widget.MenuItem in project HyperLap2D by rednblackgames.
the class HyperLap2DMenuBar method addMenuItem.
public void addMenuItem(String menu, String subMenuName, String notificationName) {
if (menu.equals(MenuAPI.FILE_MENU)) {
fileMenu.addSeparator();
fileMenu.addItem(new MenuItem(subMenuName, new MenuItemListener(notificationName, null, menu)));
}
if (menu.equals(MenuAPI.EDIT_MENU)) {
editMenu.addSeparator();
editMenu.addItem(new MenuItem(subMenuName, new MenuItemListener(notificationName, null, menu)));
}
if (menu.equals(MenuAPI.RESOURCE_MENU)) {
resourcesMenu.addSeparator();
resourcesMenu.addItem(new MenuItem(subMenuName, new MenuItemListener(notificationName, null, menu)));
}
if (menu.equals(MenuAPI.WINDOW_MENU)) {
windowMenu.addSeparator();
windowMenu.addItem(new MenuItem(subMenuName, new MenuItemListener(notificationName, null, menu)));
}
if (menu.equals(MenuAPI.HELP_MENU)) {
helpMenu.addSeparator();
helpMenu.addItem(new MenuItem(subMenuName, new MenuItemListener(notificationName, null, menu)));
}
}
use of com.kotcrab.vis.ui.widget.MenuItem in project HyperLap2D by rednblackgames.
the class StickyNoteActor method showPopupMenu.
private void showPopupMenu() {
H2DPopupMenu popupMenu = new H2DPopupMenu();
MenuItem rename = new MenuItem("Remove note");
rename.addListener(new ClickListener(Input.Buttons.LEFT) {
@Override
public void clicked(InputEvent event, float x, float y) {
facade.sendNotification(MsgAPI.ACTION_REMOVE_STICKY_NOTE, id);
}
});
popupMenu.addItem(rename);
MenuItem changeColor = new MenuItem("Change color");
changeColor.addListener(new ClickListener(Input.Buttons.LEFT) {
boolean init = false;
@Override
public void clicked(InputEvent event, float x, float y) {
ColorPicker picker = new HyperLapColorPicker(new ColorPickerAdapter() {
@Override
public void finished(Color newColor) {
setColor(newColor);
StickyNoteVO payload = ModifyStickyNoteCommand.payload(StickyNoteActor.this);
facade.sendNotification(MsgAPI.ACTION_MODIFY_STICKY_NOTE, payload);
}
@Override
public void changed(Color newColor) {
if (init)
setColor(newColor);
}
});
init = true;
picker.setColor(getColor());
Sandbox.getInstance().getUIStage().addActor(picker.fadeIn());
}
});
popupMenu.addItem(changeColor);
Sandbox sandbox = Sandbox.getInstance();
UIStage uiStage = sandbox.getUIStage();
popupMenu.showMenu(Sandbox.getInstance().getUIStage(), sandbox.getInputX(), uiStage.getHeight() - sandbox.getInputY());
}
Aggregations