Nifty HUD causing fps drop

window.addChild(s);

Lol, it worked:

Itā€™s not appearing where I want it to, and itā€™s tiny.

So, this is where I want to use it as a basic value changing slider, how do I use it as a scrollbar for a deep container? Any simple way to link middle mouse to it after?

    DefaultRangedValueModel m = new DefaultRangedValueModel(50000, 1000000, 60000);       
    Slider s = new Slider(m, Axis.X, "glass") ;       
    window.addChild(s, 4);
    window.addChild(new Label(String.valueOf(m.getValue())));

Chances are you need to nest an additional containerā€¦ Iā€™m not sure what layout you are actually going for so I canā€™t offer more advice than that.

Edit: also provide the rest of the code for that window because the layout looks strange even so.

I am trying to change all my Nifty to Lemur, here is what I am working on now:

I need horizontal sliders inside a scrollable container

What does ā€œneed to nest an additional containerā€ mean?

Well, that one should be no problem. Take the ,4 out of your add call because thatā€™s trying to stick it in a columnā€¦ but you only have one column, really.

Edit: though that greatly depends on how the rest of your container is setupā€¦ which I canā€™t see.

Ok, I managed to add horizontal scrollbars by putting them in a new container.

    Container c = window.addChild(new Container());                
    
    DefaultRangedValueModel m1 = new DefaultRangedValueModel(50000, 1000000, 60000);   
    DefaultRangedValueModel m2 = new DefaultRangedValueModel(50000, 1000000, 60000);  
    DefaultRangedValueModel m3 = new DefaultRangedValueModel(50000, 1000000, 60000);  
   
    Slider s = c.addChild(new Slider(m1, Axis.X, "glass"));        
    s.setDelta(10000);
    c.addChild(new Label("Value: "+String.valueOf(m1.getValue())));  
    
    s = c.addChild(new Slider(m2, Axis.X, "glass"));        
    s.setDelta(10000);
    c.addChild(new Label("Value: "+String.valueOf(m2.getValue())));  
    
    s = c.addChild(new Slider(m3, Axis.X, "glass"));        
    s.setDelta(10000);
    c.addChild(new Label("Value: "+String.valueOf(m3.getValue())));  

So, 2 questions:

  1. Best way to update labels to show new values (Onclick/OnSlide)?

  2. Canā€™t add a container inside a scrollbar, do you have an example on how to create a scroll-able window?

It kind of depends on how ā€˜correctā€™ you want to be. Often I just update them based on clicks and value changes. If you wanted to be more MVC then you create a Label subclass that updates itself based on a VersionedObject and then build up your model from those. The RangedValueModel is already a VersionedObject and so will plug right into that. Not sure what clicking should do in this caseā€¦ with a button orā€¦?

You might also take a look at PropertyPanel which for many cases can be used to wire up bean properties directly. At the very least, looking at the code might give you some ideas on how to wire things.

Unfortunately, JME doesnā€™t expose clipping to us like it did for Nifty (nifty renders through backdoors and special APIs provided to it). Until it does, it is really hard for Lemur to support something like a scrollable container. You can use a ListBox for many thingsā€¦ including the GUI you are creatingā€¦ but itā€™s less efficient.

Sometimes itā€™s better to try to break up your UI into RollupPanels or different tabs in a TabbePanel.

Sorry I havenā€™t fleshed those docs out better yet.

Thatā€™s what I did to break-up all of the settings panels in the SimArboreal Editor and IsoSurface Demo. The SimAboreal Editor is kind of a proper UI that mixes some of all of what Iā€™ve talked about. Might be worth looking at how I did that, too.
http://simsilica.github.io/SimArboreal-Editor/

1 Like