jME gui framework

Howdy,



I’ve been working on a gui framework for jME for a few weeks. I thought it was time to introduce it and start getting some feedback before I get too far down the road.



What is it?



It’s a gui api/framework that integrates with jME’s scene graph.



What’s in it?



The basic component is Widget, a Java interface.



These are some of the Widget implementations:



WidgetImpl – a basic Widget implementation that extends Spatial and doesn’t draw anything.

WidgetContainerAbstract – extends Node, implements Widget and uses WidgetImpl to handle some of the Widget implementation details.

WidgetText – draws text.

WidgetButton – extends WidgetContainer and handles mouse clicks.

WidgetPanel - a simple visible (paints a background color) container for other Widgets.

WidgetScrollPanel – has scrollbars

WidgetRolloutPanel – has a button that hides/unhides a WidgetScrollPanel

WidgetRolloutPanelContainer – manages WidgetRolloutPanels



There are other derived classes, mostly buttons, and several support classes for fonts, bounds, borders, input, etc.



I tried to put all the classes that are Renderer specific in the package com.synthaworks.widget.impl.lwjgl. I might have missed a couple. If you find one let me know.



I decided to take a layout manager approach for the construction of the user interface. I didn’t try to implement java.awt.LayoutManager, I just borrowed some of the concepts. Right now there are three layout managers, WidgetBorderLayout, WidgetFlowLayout, and WidgetAbsoluteLayout. Don’t expect them to work exactly like their Java counterparts.



WidgetFrameAbstract is a class that provides the functionality for dispatching input actions and the entry point for drawing the Widgets.



The framework uses Observer/Observable to handle ‘event’ notification, i.e. a button click. In the past I’ve run into complications using AWT’s event handling mechanism, particularly when I need to cut across the component hierarchy. The Observer/Observable pattern is implemented in Java and it’s easy to use. If a Widget needs to know about an event it just implements Observer and registers with the Widget it’s interested in. You can take a look a WidgetTestApp2, the call to addMouseButtonDownObserver(), and WidgetButton to see how it works.



The naming conventions I use consist of prefixing the Widget related class name with Widget and, if it’s an abstract class, I append Abstract to the end of the class name. I probably haven’t been entirely consistent with this so if you find an inconsistency or have an idea for a better way to do it, let me know.



How’s it work?



I have written a couple of example applications.



WidgetTestApp1 - primarily demonstrates WidgetRolloutPanelContainer and WidgetRolloutPanels. You can change some of the booleans in the TestFrame class to see a plain WidgetScrollerPanel.



WidgetTestApp2 - demonstrates mixing WidgetButtons with a jME camera view and performing an action when a button is clicked.



I included a couple of Windows batch files to run the test applications. You may need to make some adjustments to get them to work on your system.



I’ll be writing more test applications.



There’s currently no documentation, but I’ll be happy to answer any questions you might have.



I created a few class diagrams to illustrate the class hierarchy and how it relates to jME.



You can view them here.

http://www.synthaworks.com/jme/gui/WidgetUML.png



What’s the plan?



The next widget I plan to implement is WidgetContainer3d, (name subject to change). WidgetContainer3d will ‘own’ a camera and facilitate having multiple 3D views on the screen at the same time.



I also plan to create WidgetTextEdit (single line), WidgetTextEditor (multi-line), and WidgetConsole (like the Quake console).



Some other Widgets that come to mind are WidgetProgressBar, WidgetSpinner, WidgetCheckbox, WidgetMenu, WidgetToolBar, etc.



Fonts are a weak area. At this point I haven’t found a solution I’m happy with. If I don’t find one I will eventually take a shot at implementing one. If you know of one let me know.





Why a gui framework for jME?



I’ve been working on a 3D modeler and I decided to design it like a 3D game, hopefully making game content creation a little easier. The problem I encountered was a lack of a sufficiently sophisticated gui framework to support what I have in mind, no Swing or AWT and a single OpenGL context.



Along the way I discovered jME. The more I learned about it the more I liked it, so I decided to write a gui framework for it. What I envision for the framework is probably overkill for most games but I suppose too much is better than not enough.



I am also interested in donating the gui framework code to the jME project, either to the core project or as a subproject. With permission, I would like to call it ‘jMEgui’ and use the package structure ‘com.jme.widget’ for the source code. I see this as a good opportunity for me to give something back the the open source community.



So, where’s the beef?



Sorry for the length of the preceding . . . you can download the source and class files here.

http://www.synthaworks.com/jme/gui/jmegui.zip



I welcome any questions, comments, suggestions or feedback you might have. Especially if you see something that should be designed or implemented differently, due to my lack of understanding of jME, OpenGL, Java, or programming in general. :slight_smile:



Thanks,

Gregg





The above post is me, wasn’t logged in. Gregg, I’m e-mailing you re: possibly adding it into the baseline.

Hi,

Impressive!!!

You have done a great job man!

I think I can say welcome on board.

Now I will have to do a better job than ever…

Thanks Arman.



I think you guys are doing an excellent job with jME.



I’m looking forward to working with you and creating some cool stuff with jME. :smiley:



Gregg