-
Notifications
You must be signed in to change notification settings - Fork 16
GML is a gui library for use with OpenComputers. It provides a variety of standard gui elements and a very flexible style system using a slightly simplified variant of css called GSS.
GML aims to provide a very robust foundation, automatically providing as many of the general features of modern GUIs as possible, so that programmers using it to make their own GUIs can focus on their specific applications, layouts, and styles, without having to reinvent the basic underlying mechanics.
GML stands for Gui Markup Languages, for reasons that will not become obvious until much later in it's development.
This wiki contains detailed pages on each type of object, listing it's methods and properties. If you prefer, you can dive right in and look at the sample programs in the source repo, which will be kept up-to-date and demonstrate all implemented features of the library. For a quick start on style, you can check out the default gss style definition, also in the repo.
still in development, there are currently only 4 types of gui elements available:
The root gui container objects. Contains any number of child elements.
This will be the first thing you make when making any gui.
The most basic component, just has some text. That's it. Can't have focus, doesn't respond to clicks.
Just sits there, having text.
A button. Click on it, stuff happens. Focusable, also clicked if you hit enter when it has keyboard focus. Has a text label as a caption, and a wide array of style options.
A one-line text input field. Focusable, handles the full array of keyboard and mouse input in every way you could hope for. Field scrolls to hold arbitrarily long input strings.
Has a list of items with built-in scroll bar, click to select items... y'know, ListBoxes. Boxes with lists in them.
Implements a shared clipboard with content typing and cut/copy/paste events.
Currently only supported by the textfield but implemented in a general way so all future components where it makes sense will be able to use it.
Again, barely used presently, with only the drag-select scrolling behavior of textfields, but implemented with events to be ready for drag-and-drop operations using a dragproxy model in the future.
Positions passed to all element creation functions support sides - "top", "left", etc - as well as "center" as alternatives to hard-coded numerical values. Also supports negative position values, which are treated as offsets from the right or bottom edge of the object to the right/bottom edge of the parent object.
There are currently only two public functions in the library, most of the work is done through the gui objects returned by gml.create()
gml.create(x,y,width,height)
Creates a new GUI object. Gui is the top-level object, the container that owns, manages, and renders everything else. Function returns a gui object table.
gml.loadStyle(styleName)
Attempts to load a gui style sheet with the specified name. Will add .gss if styleName doesn't already end with it. Only the file name is required, it will search the directory containing the current running program, the current working directory, the /lib directory, and the /usr/lib directory, in that order. Returns a style table; this can be applied to a complete gui and all it's elements by assigning it to gui.style.
Note that you must explicitly re-draw by calling element:draw() to apply a new style to an active element or gui.