Note: Icons are in development
and will be available with 0.92a

GUI

  • Written in Lua
  • Object oriented
  • Eventdriven
  • Skinsupport

Written in Lua

The GUI system is written in Lua and is open source (MIT License). It is using the Luxinia core functions to draw everything, but generally, it could be wrapped to. I.e., a 3D GUI interface could be written, based on the eventdriven model.

Object oriented

The object oriented design makes it easy to extend and write GUIs? within Lua. Though it is similiar to C++ or Java, lua offers a system that allows a simpler use of the classes. I.e. if a Button class has a method that is called when the button is clicked, you normaly need to create the object and register a function that should be called then. Not so in Lua. You can overload functions directly on the object - no need to write a new class:

mybutton = SkinableButton:new(10,28,28,22,nil,"Clickme!") 
function mybutton:onClicked() -- overload default method
  print("clicked!")
end

This is pretty straight forward code. If you would use C or C++ you could of course use a function pointer that you assign - but you couldn't write the function directly at the place where you create the button.

If you would use Java instead, you would be able to write your callback fucntion directly where you need it - but it requires much more lines of code and a couple of classes.

Eventdriven

The GUI module is using a event system that is inspired from Java. You have similar classes, i.e keylisteners, actionlisteners and mouselisteners - although it is simplified. However you can receive the same kind of events - mouse exits, key releases, mouse clicks and so on.

Skinsupport

As the image to the right shows, you can create your own kind of skin for your GUI, using the same classes. You simply have to create a few images containing different images for your custom buttons. The images are split up into 9 areas. The corners areas are not stretched, the edges are stretched vertically or horizontally. The center part is strechted to the size it requires.

In Luxinia 0.92a, the skin components are no longer responsible for their visual appearance. The new Skin2D? class cares now about the visual representation. The Components only tell which way they should look like now and the skin decides how this should be interpreted now.

Custom skins can be build that may be display information in a much different way than the skinned images does - yet the Component classes won't care about this. You can easily create your own skinning without the need to spend a thought on how to find out which component the user clicked or how to react on it - just create your own drawing functions (or use the existing) and tell Luxinia what to do in case something happened!

It couldn't be simpler than that!


Texture from which the gui
components are created


Resulting GUI look and feel