Nifty layout

In the documentation, it states: "Usually, you lay out the GUI using XML, but using Java will soon be a second option. "

I was wondering what the status of this feature is and if it will be forthcoming any time in the near future?

I think it’s in the soon to be released NiftyGui 1.3

But surely @void256 can confirm.

It is in nifty 1.3

We are waiting for it to be finalized so we can include it in jME3, there are still some minor issues with the controls in that version

Very cool. Thanks for the quick response.

I have one more question. What is the current best strategy for handling multiple resolutions? In JMEDesktop I just set everything up at my max resolution (1920x1024) in an absolute fashion and then scaled the entire scene to the current screen resolution stretching as needed. I understand that Nifty scales images but not text. So is something like this currently even possible? I’ve searched high and low and surprisingly I don’t see too much talk on the subject. I’ve also tried screwing around with it on my own and like I said, I got images to scale OK (although in some there were some dithering issues with transparency), but I’m not sure about text. Obviously when you drop to a lower resolution the text is too large.

My requirements are to pack as much data onto some screens as possible and have the layout hold together for different resolutions. I get the sense that that’s not really possible with Nifty. Am I wrong?

It will be part of 1.3 and it’s working pretty well already. We’ve blogged about it some time ago Nifty Builder Java Classes … and looking at the date of that blog post. It’s about time for 1.3 >_<

As momoko_fan pointed out the main issue preventing 1.3 being already available is the overhaul of the standard controls. We’d like to give the same treatment to all of the standard controls as we’ve already did for the ListBox overhaul.

Please be a little more patient with us. Nifty 1.3 will be released in 2011! I promise! :slight_smile:

About resizing GUIs … yes that is still a somewhat unresolved issue. The main problem is the font resizing. You can probably get away using percent size values for width/height and rescale images but it’s not as easy with fonts.

Someone suggested to either define specific font sizes for different resolutions so say: use font-a for 640x480 and use font-b for 1024x768 with the fonts having different sizes. Another approach would be to define a base resolution and then scale the font size relativ to this base size.

I’m still unsure about what would work :confused: Any more opinions about this?

I don’t see why we should scale fonts? The OS doesn’t do that.

You should only scale fonts when you have monitors with different DPIs, otherwise, just keep them the same size but fit them into their bounding box by moving words if they go beyond it, etc.

Well it would be for much the same reason you can scale images. Lets say you have a status bar at the top of your screen that is 30 pixels high. And on that status bar you have text that is 20 pixels high. You are probably going to want to scale that bar to a percentage based on the resolution so the bar only takes up the same amount of proportional screen real estate. If the text does not also rescale it will appear either too large or too small to fit properly over the bar.

In much game the font stays at the same size (so look smaller) as you increase the resolution.

What is usually done is to have 3 font sizes : small, medium, big, and let the user chose the one that suit him.

Maybe we should allow user to choose then, if to autoscale fonts with resolution or fit them into the bounds instead.

I suppose that is a possible solution, but from a design perspective it would be preferable if the font just scaled itself, otherwise the design could end up looking clunky. It’s the one huge advantage that SwingGui has over Nifty at the moment. In SwingGui I can just setup one layout (absolute) then at startup detect the users resolution and scale the gui to match and I’m assured that everything will look right no matter the resolution or aspect ratio.

Yes, but I imagine that autoscaling of elements and especially of “Bitmap based fonts” will probably look odd and blurry, especially when scaling very large from a relative small base font size, or?

To get something more specific to maybe add and test this. How exactly would you like that to be specified, especially for fonts?

[xml]<label id=“label” text=“Hello World” align=“left” textHAlign=“left” width=“50%” ??? height=“50%” ??? />[/xml]

And how should Nifty calculate/translate width/height values to font size?

Well you would setup your gui at the higest resolution available to your application and tell the library what that is. It could then automagically scale the fonts based upon the current resolution. It would also prevent any blurriness since you’d be scaling the fonts down instead of up. Pretty simple really.