I’ve been trying with nifty gui for a while now, and more and more I dislike it. I don’t like the xml layout stuff, I absolutely hate the builder-pattern stuff.
I’m working as a Java developer and we are using GWT as a web gui framework. Its widget based (similiar to Java Swing) and easily extensible. You can just extend from the Widgets themselfes and change their properties directly. For example the ListBox (a drop down menu box, or combo box): you instantiate it and add items to it. Straight forward. But in Nifty GUI you create a ListBoxBuilder where you cannot add items directly - you first have to get a Element object from somewhere else and get the ListBoxControll from it, and then you can add items to it. This leads to code which is very spread out, but in this example the instantiation of the object should be close to the data-filling of it.
Another thing: If you want to replace a panel at an already existing panel, you have to make realy crazy stuff. Thats because you have only PanelBuilders and no Panel-class, only Elements, and you constantly have to call some stuff on the Nifty object. Its just not intuitive at all, I think its a bad design. It’s not useable for complex GUIs where you want to write your own reusable components and so on.
Sry for ranting, but I’m just so frustrated with this, especially coming from a GWT background.
Is there any other GUI library which is compatible with JME3 AND has a more widget-base approach?
Lemur tries to be similar to Swing and as a consequence becomes similar to GWT.
Code to create a container with default styling:
[java]
// Create a panel with child layouts
Container container = new Container();
// Add some labels and buttons to it
container.addChild(new Label(“My Label”));
container.addChild(new Button(“Button 1”));
container.addChild(new Button(“Button 2”));
guiNode.attachChild(container);
[/java]
By default, Container uses a SpringGridLayout so it supports rows and columns of components. There is also a BorderLayout which works similar to swing’s.
Lemur tries hard to be a “minimal” wrapper around JME-provided stuff, upon which you can easily build your own custom components. So every GUI element is simply a Node and you can plop them anywhere in your scene (3d or 2d). For the most part, you can use the mouse picking stuff on its own or the input management on its own or have them overlap your regular 3D scenes and the built-in GUI elements.
In other words, the same listeners you’d use to wire up mouse clicks on some GUI element can also be used to detect clicks on an in-game model.
I developed it originally for Mythruna as a way to do 3d UIs. I try really hard to keep it as nicely separate services that can be combined to be a full-blown GUI API but can also still be used separately where needed.
Currently, it’s biggest downsides are a lack of tutorials/documentation and the fact that I haven’t gotten around to writing the more advanced elements (like tables and list boxes), though in some cases these are not particularly hard to write on what’s been done already. It also lacks a built in animation/effect system though I am working on one. One iteration was partially prototyped in Monkey Trap.
Thanks for your responses!
I think ToneGod-GUI is what I’m looking for. The only thing I’m asking myself right now is: Do you have to position everything in absolute values or is there some form of layout-system, where you simply layout stuff horizontally or vertically? Because that seems to be lacking.
@pspeed: Thats some really impressive GUI you have there, respect! But I don’t want to create such a complex and animated UI for my project. But damn that looks nice
@Wasserleiche said:
Thanks for your responses!
I think ToneGod-GUI is what I'm looking for. The only thing I'm asking myself right now is: Do you have to position everything in absolute values or is there some form of layout-system, where you simply layout stuff horizontally or vertically? Because that seems to be lacking.
@pspeed: Thats some really impressive GUI you have there, respect! But I don’t want to create such a complex and animated UI for my project. But damn that looks nice
Thanks. Though, obviously, you don’t have to make anything so complicated (though really it’s no more complicated than a 2D UI). Monkey Trap has a much simpler main menu with a roll-out panel for network settings.
For the record, here is the same code sample with horizontal layout:
[java]
// Create a panel with child layouts
Container container = new Container(new SpringGridLayout(Axis.X, Axis.Y, FillMode.EVEN, FillMode.EVEN));
// Add some labels and buttons to it
container.addChild(new Label(“My Label”));
container.addChild(new Button(“Button 1″));
container.addChild(new Button(“Button 2″));
guiNode.attachChild(container);
[/java]
…or a two column setup:
[java]
// Create a panel with child layouts (row major)
Container container = new Container();
// Two column label: value layout
container.addChild(new Label(“My Label A:”));
container.addChild(new Label(“My Value A”), 1);
container.addChild(new Label(“My Label B:”));
container.addChild(new TextField(“My Value B”), 1);
ToneGod has a ton of widgets, but no layout support it seems - you have to position everything absolute
Lemur has layouts, but key widgets are missing (e.g .a CombBox).
I really need certain widgets like the ComboBox, and I think I can live with having to position everything in absolute values. So I guess I made my choice
@Wasserleiche said:
Here is what I found out about ToneGod and Lemur:
- ToneGod has a ton of widgets, but no layout support it seems - you have to position everything absolute
- Lemur has layouts, but key widgets are missing (e.g .a CombBox).
I really need certain widgets like the ComboBox, and I think I can live with having to position everything in absolute values. So I guess I made my choice
Thanks for all of your replies!
Oddly enough, when I get around to writing a doc on creating custom elements, combo box is the one I will use. There are so many variations and it’s a nice example that interacts with a lot of different things. It’s really waiting on a proper list box implementation. In Mythruna, I ended up using a slider + label instead in some places where a combo would have also made sense.