A few days ago I was madly wondering if I could do an XML editor in 3D with Lemur and JME. Already clear - this is not a game. Today a (splitt-) picture of my test. Now I still have to incorporate all of the inputs.
Does anyone have an idea how I can implement the popup menu in Lemur as sensibly as possible?
(Lemur 1.15.0 + Lemur proto-1.12.0)
My preliminary implementation:
PopUpMenu pm = new PopUpMenu();
pm.scale(1.8f);
pm.setLocalTranslation(400, 600, 100);
// Make some test data for the list.
for( int i = 0; i < 10; i++ ) {
pm.addMenuItem("Menu item " + (i+1));
}
pm.show();
package com.simsilica.lemur;
import com.simsilica.lemur.component.ChangeItemListener;
import com.simsilica.lemur.component.MenuItem;
import com.simsilica.lemur.core.VersionedList;
import com.simsilica.lemur.event.PopupState;
import java.util.Iterator;
/**
*
* @author Janusch Rentenatus
*/
public class PopUpMenu extends Container implements ChangeItemListener {
private VersionedList<MenuItem> menuList;
private boolean uptodate;
public PopUpMenu() {
menuList = new VersionedList<>();
uptodate = false;
}
public void addMenuItem(MenuItem item) {
uptodate = false;
menuList.add(item);
}
public void addMenuItem(String itemText) {
uptodate = false;
menuList.add(new MenuItem(itemText));
}
public Iterator<MenuItem> itemIterator() {
return menuList.iterator();
}
public boolean removeMenuItem(MenuItem item) {
uptodate = false;
return menuList.remove(item);
}
@Override
public void itemChanged(MenuItem item) {
uptodate = false;
}
protected void rebuild() {
clearChildren();
for (MenuItem menuItem : menuList) {
Button clickMe = addChild(new Button(menuItem.getItemText()));
clickMe.addClickCommands(menuItem.getClickCommands());
clickMe.setBackground(null);
}
uptodate = true;
}
public void showMenu() {
PopUpMenu pm = new PopUpMenu();
pm.scale(1.8f);
// Make some test data for the list.
for (int i = 0; i < 10; i++) {
pm.addMenuItem("Menu item " + (i + 1));
}
pm.show();
final Vector2f click2d = app.getInputManager().getCursorPosition();
float width = app.getCamera().getWidth();
Vector3f size = pm.getPreferredSize();
pm.setLocalTranslation(
Math.min(click2d.x, width - size.x*1.8f ),
Math.max(click2d.y, size.y*1.8f),
100);
}
}
After I invented an explainable AI, presented my idea to actuaries and tinkered with a prototype for xAI,
I would like to upload a new video for this XML project today.
Now I have implemented the arrow keys. Without shift: line up and down, with shift: entry same deep up and down. Selected entry is focused. The angle of the camera is converted.
It’s been so long since I continued working on this project. I’ve been busy for a year now implementing a really explainable AI that sucks.
Back to the XML project:
I would also like to use my editor to tinker with a model generation at some point.
Now I’m working on a popup list picker. Here in the video class names of Lemur. Now I ‘just’ have to finish the search field…
Edit: The filter is today done. Wildcard “*” and “?” can be used. There is an imaginary “*” in front of each uper case letter, except the first character in the filter.
To render the ListBox I also use my own Sel Text Field (based on Aufricer solutioin) with multiselection. Marking has long been a grandient and not just monochromatic.