New GUI library available

Just a quick note first about NUI…



StandardGameState.initCamera needs to be protected… not private.



Now:

So I'm trying to figure out how I'm going to implement scrolling.

Setting the forced cull on sub components is just not going to cut it. I'm setting up a simple example where my frame window is 400x400 and I'm putting a UIImagePanel in it that's 600x600. So I want to cull only the extra 200 pixels that shouldn't be shown through the scroll area's viewport.

So I'm figuring that I have two options.
    1. render to texture the size of the scroll area.
    2. create some sort of mini camera that only shows the scroll area and let camera culling do it's job.
    [/list:u]
    It seems that I'll have to special rendering either way.

    Does anyone see a better way of doing this?
"itistoday" wrote:
Edit: Wait.. I might be wrong... downloading what might be it now (thought it was just the RE). Will post back as soon as it's installed.
Ok, yes I was wrong. It's just that Apple has made it really difficult to actually select this version once you install it. For anyone who cares:

Once you install Java 1.5 from here, in the terminal do this:

# cd /System/Library/Frameworks/JavaVM.framework/Versions/
# sudo rm CurrentJDK
# sudo ln -s 1.5.0 CurrentJDK


And now all your commands (which are actually symbolic links in /usr/bin/) will point to the new version. This makes me think that this isn't really quite yet too stable...

Doah! What happened to the 5.0 version of the NUI? I decided to bite the bullet and upgrade and now that I’ve done that, it’s not there. I only see nui_0.13_JDK14.zip (which I know I can use, but still).



Also, when might we see this in CVS?

CVS is up to Mojo and company. I’ve made the mistake of commiting before I was told, and am not going to do it again. :wink:



Anyhow… if you want 5.0 then just do a search for ‘JAVA50’ all the source and you’ll see the commented out code.

Thanks. Looks great so far. Nice job.

http://www.resonus.net/tiki-browse_image.php?imageId=6



Go get the new version of NUI! It now supports multi and single line text, drawn via the well known Java2D awt methods to an image an then rendered on a quad!



You can have any kind of text you wish. My next step will be to allow for text selection and cursor positioning.





Mojo… I think I’d like to commit soon.

Looks great, Guurk.



As far as committing… I plan on seperation of packages soon (like this weekend), so checking it into com.jme.ui would just mean it has to move again. Let me confirm how I want these seperations to take place, and I’ll give you the new package names/directory structure and you can check it in with that.



Most likely, it will be com.jmex.ui

I’m not sure if this is a direct replacement to ui package or not, that’s your call. I’ve been working in a different package so that I don’t break people’s code.



Anyhow, I’m still having a rough time figuring out how to get the scrolling done. Any advice per my comment earlier about that would be appreciated.



After taking a look at other gui libraries I see that noone has actually been able to do true scrollable regions other than for some simple things: text areas and lists.



From that perspective I think that I’ll finish up the gui library allong those lines.



With scrolling in place on text areas and a new list box, along with a progress bar it’ll be a full gui library. I can’t think of anything that wouldn’t be able to be created with that in place.

Honestly, I don’t know how I’d go about scrollable either. Something worth thinking about is: RenderToTexture the entire list to scroll, adjust the texture coordinates of a quad (using the scroll buttons).



So, as you push the up arrow on the scroll bar you adjust the texture coordinates of the quad to go down the texture.



Then you’d have to figure out selection of an item, current texture coordinates offset + mouse area or something.



I don’t know.

PM samskivert, maybe he’s got some ideas on how to do it.

I’m not much help. I don’t know much about how clipping is handled in the 3D world, so I don’t know if setting up a separate camera with clipping confined to the “viewport” of the scrolled area is better or worse than rendering the viewport to a texture and “clipping” with texture coordinates. I suspect the latter is easier to get working, but I haven’t played with JME’s render to texture facilities at all.

"guurk" wrote:
You can have any kind of text you wish.
Mojo... I think I'd like to commit soon.

Sorry for posting a bit delayed, rl issues :)

IMO it would be a giant possibility to be able to render html text onto a quad using Java2D. There is a class named BasicHTML, which has a static method createHTMLView. You need a JComponent (you can easily create a JLabel without ever adding it to a container!) and what you receive is a View which is capable of rendering HTML text into a Graphics2D context. It's basically like that:


... someMethod(String value, Graphics2D g) {
        JLabel label = new JLabel();
        Dimension d = new Dimension(64, 64);
        label.setMaximumSize(d);
        label.setMinimumSize(d);
        label.setPreferredSize(d);
        Rectangle rect = new Rectangle(d);
        String text = "<html><font color="#ffffff"><i><b>" + value + "</b></i></font></html>";
        View v = BasicHTML.createHTMLView(label, text);
        g.setBackground(new Color(0f, 0f, 0f, 0f));
        g.clearRect(0, 0, 64, 64);
        g.setClip(rect);
        g.setTransform(new AffineTransform(1, 0, 0, -1, 0, 64));
        v.paint(g, rect);
...
}


I had to do the AffineTransform in my case in order to mirror around the Y-axis, maybe it's due to the way I convert the buffer into a texture.

In my test app it works nicely and I think it would be a wonderful addition to a great GUI.

Actually, after discovering all this stuff with rendering to a graphics device from swing components, it almost makes me think of trashing the whole gui again and just providing a way to do swing in opengl… :stuck_out_tongue_winking_eye:



That said I think your idea is a good one. I’ll add a flag in the constructor of the UIBitmapText that allows you to interpret the text as HTML instead of standard text. Then I’ll draw it out per your example instead of the standard way.



Great idea!

So, after doing a little googling…



Agile2D Home



I found that. It’s basically a replacement for the underlying drawing stuff for swing with an opengl rendering pipeline using gl4java.



I don’t see why I couldn’t do the same. Especially since the above library had to roll their own versions of stuff that’s already in jME.



Are there any other votes for doing something like this?



My thinking is that you could even then be able to use the new synth custom xml based look and feel definitions that are part of Java 5.0. Or you could always write your own look and feel the old Java plaf way (like metal).



Bottom line is that you could write your gui in standard way that you are used to in Swing, or AWT. And then change 1 line and you have the same gui in jME.



Thoughts?



– as a side note, my UIBitmapText now supports HTML (thanks batman.ac!)…

That certainly sounds like a good option. This frees you from having to implement individual widgets, and just allow swing to handle that. Sounds like something worth pursuing.

Wasn’t jME supposed to be decoupling itself from AWT though? Swing relies heavily on AWT… Although if jME is being separated into modules, I expect there’d be two GUI modules - guurk’s new one and the agile2d-style Swing/AWT-based one?

What’s the problem with AWT/Swing?

I would probably agree with you chaosdeathfish. I’ve always wanted to be able to compile jME with GCJ, and the support for AWT there was never very good. However, GCJ is making headway.



We’ve wanted to remove dependancy on AWT for that reason and we’ve started writing our own Image library to handle that. There have been some other reasons too, just search the forums and you’ll find the discussions.



Using Swing/AWT within OpenGL would be something that would allow a lot of current developers to feel more at home developing games with jME. It’d probably be a good feature to bring more users.



For what it’s worth, I’d say that having two libraries is probably the best way to go. Not to mention that I’d hate to throw away all my hard work :P.

I agree. I wouldn’t throw away what you’ve got so far. Do you still plan on completing that first (ie. scrollable windows)?

Hate to ask a bonehead question, but the XML stuff has me a little confused. I’m trying to create a button with three seperate textures, one for each state. How would I define this with or without the XML? Somehow, what I’ve been trying is not getting the texture loaded it seems.