I have no love for the over-use of XML everywhere, but I have found that the hierarchical-nature of XML makes it a decent way to create understandable UI layouts in complex scenarios. It’s much easier to see what a container contains compared to staring at code. Is that what you have in mind? If not, what specifically do you find easier about XML over code? I think it also usually reduces the number of lines spent for configuration, but…
I see Lemur’s use of constructors in the example above gets around the usual verbosity problem of a pure-code method nicely (compared vs line after line of setPropertiesAgainAndAgain()). (Passing in dependencies via constructor instead of using setters for everything, what a novel concept… )
Event handlers is where I think the big payoff for XML layout reducing code ugliness/verbosity tends to be, and before Java 8 it’s still an issue… but I guess Lambdas and IDE code templates are a decent answer to that:
Still not sure I’d want to tackle a complex business UI like this, but for Lemur’s target “market”, in what cases would an XML or other hierarchical format benefit much? Not saying it couldn’t, just asking.
Well yeah, the hierachic way of xml is way more readable and I really hate when most of my code looks like guiElement.setSomething();.
Also historically I have some background in html, so I’m more used to doing it that way.
Just my 2 cents about Lemur.
I used it in a game on android, and achieved to even replace the default material to have my own, shader based transitions between screens. so yes, it’s very flexible.
Also appart from the UI part there are several utilities in Lemur that are worth your time: InputMapper (hell, I said it so many times… but we should really get that one to core…), VersionedObjects and VersionnedReference are some gems you’ll find very useful.
Basically I always use Lemur now when I start a project, even a quick and dirty test project, because I know that I’ll be able to pull out an UI in a matter of minutes.
Yeah, I think there’s something to be said for viewing UI layout code in a hierarchical format. Doesn’t need to be an XML-like format but I would suggest that if something like this is ever created, one of the goals should be to support that type of structuring.
Hierarchies are fine when you have single level nesting but it starts to get really ugly as soon as you have a grid (99% of UI panels). So many UIs boil down to a list of name/value pairs and it’s extremely frustrating if you have to put each of those in some separate “row” structure.
Even text markup has (thankfully) moved away from hierarchies and in that case a table/grid is rare.
For UIs, it’s so common. Coming up with a nice descriptor DSL for that is tricky.
Historically I’ve usually avoided grid-based layouts for that reason (+probably others) and stuck with absolute positioning within smaller containers organized in some flexible hierarchical structure, but you need a UI layout utility to make that sane if things get complex.
Lemur example of creating a two-column name/value pair panel… probably the single most common UI panel:
Container container = new Container();
container.addChild(new Label("Name:"));
name = container.addChild(new TextField("Joe Smith"), 1); // 1 for the second column, versus 0 for the first
container.addChild(new Label("Age:"));
age = container.addChild(new TextField("42"), 1);
You can explicitly specify rows and columns but if you ever have to add a new row or rearrange anything then you go through some hell. By convention, Lemur keeps track of this for you.
Similarly, if the container was row-major instead of column major Then the labels would be above the fields and each pair in their own column.
I’ve created SOOOOO many user interfaces in my life… from back in the DOS ASCII graphics days, on through X/Motif, Win3.1, OS/2, Java, etc… you get a feel for what is convenient and what isn’t after a while. This is not even the first UI library I’ve written (probably closer to 6th or 7th.)
The only problem I have with Lemur is that for any GUI-heavy mobile application, you are in trouble, because there is no batching, so your draw count can become crazy.
Or is there some simple solution for this already?
It’s just regular spatials that mostly use the same materials (at least with any of the default styling). So you might be able to just stick it under a BatchNode and call it done.
Others have used Lemur in mobile applications and haven’t complained yet. I assume they’ve found some way to make it work.
Just a quick question (I don’t have time to check your documentation right now):
How easy is it to put your own meshes and geometries as those spatial?
At worst, you just have to wrap them in a custom component which is not too difficult. I don’t (yet) have a built in component for injecting your own arbitrary 3D spatial but it’s definitely on my to-do list.
Right now, I think Lemur and Nifty are equally good.
Although Nifty may be more dynamic, Lemur compensates with it’s simplicity: I just set up a basic GUI in 1 min without any knowledge of Lemur. For Nifty it would have taken like 15 mins.
If Lemur would have a little bit more support for 3D spatials, it would be superior.
I switched to Lemur after using Nifty for a while. It seemed like every time I needed to modify the Nifty code I had to find a link to the pdf file to download for the documentation and it just didn’t work in an intuitive way.
That said I think Nifty is probably pretty powerful if you know how to use it. But it’s pretty difficult to use.
Plus, Lemur is developed by @pspeed which has answered 95% of all of my questions on here within hours whether they are about Lemur or general game dev.