BlockOut is a data-driven GUI library MineCraft, utilizing XML (or code) to define a GUI layout, offering a hierarchical structure of containers and elements and alignment.
As part of my work on another mod (the 1.7/SMP rewrite of the MineColonies), I am writing a GUI toolkit / library that allows us to write much more complex GUIs with minimal code.
MineColonies is open source, and BlockOut is a standalone package within MineColonies, though as of this writing the BlockOut package is not pushed to the public repo, as I am doing some last minute additions and tuning. When it is pushed up, BlockOut will be available under GPL, and eventually released separately with a more liberal license (likely BSD).
BlockOut is designed to be easy to add in, and easy to extend with additional custom controls, or even alternative styles of existing controls.
Data driven GUI layout engine utilizing XML for layout definition
Hierarchical GUI elements
Inheritance of Layouts - layouts can base off other layouts
Absolute (pixel) and relative (percentage) positioning and size of elements
Colors can be specified by name, integer, hex, rgb(), rgba()
Easy access to panes via optional name ID
User-extensible with custom elements; new elements or add additional styles of existing elements
Localization support - automatic LanguageRegistry text replacement
GUI elements currently implemented:
Item icon (stack)
Text input field
Scrolling list - Buttons and other GUI elements work inside scrolling list elements, including scrolling lists inside scrolling lists
Scrolling view (non-list predefined)
Switchable View (easy toggling/cycling through child views)
BlockOut's design is heavily influenced by an old GUI framework called PowerPlant.
The root of BlockOut is the Pane class. A Pane defines the fundamental interfaces for rendering and user interaction, but by itself it doesn't do much.
View is a Pane subclass which can contain other Panes.
Window is a View subclass, and is the visual root of the UI that is displayed. Windows create a GuiScreen proxy for display.
In general practice, you will create a subclass of Window, and pass a resource location of your XML definition to the super constructor. If you have special additional setup you wish to perform (set custom strings, add a list DataProvider, etc) you can do so by overriding onOpened(). If you have clickable buttons, you can implement Button.Handler and override onButtonClicked().
The above image depicts a test window, showing text labels, item icons, scrolling list (with scrolling lists in children), buttons, and an image (as a backdrop).
These are the 4 files for the Window shown above (the forum post editor doesn't like pasting XML):