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