Metapyziks/FacePuncher — pull request #8 by Deseteral (2014-05-18 12:52:00+00:00)
Title: User Interface

This is initial part of my code for building user interfaces.

It provides five different widgets:
* `Frame`
* `Label`
* `Button`
* `TextBox`
* `ProgressBar`

New widgets can be build by inheriting from `Widget` and `UsableWidget` abstract classes.

`UIManager` object is root node for every other widget.

Example:
```csharp
UIManager ui = new UIManager();

Frame mainFrame = new Frame("main_frame", new Position(0, 0), 26, 18, "Frame title");
Label lblTest = new Label("lbl_test", new Position(2, 2), "This is a label widget");
Button btnTest = new Button("btn_test", new Position(2, 4), "I'm a button!");

mainFrame.AddChild(lblTest);
mainFrame.AddChild(btnTest);
ui.AddChild(mainFrame);

ui.CalculateSelectableWidgets();
```

As you can see there's probably still a lot of work that could be done to simplify the syntax.

The `UIManager#CalculateSelectableWidgets` needs to be called once, each time a widget is added or removed.

Then in main game loop `UIManager#Draw` should be called, just before `Display.Refresh`.

You can assign an action to every `UsableWidget` (e.g. `Button`) like this:
```csharp
btnConnect.Use = () =>
{
// your code here
};
```
`UsableWidget#Use` is a function delegate that's invoked when selected widget is used.
It takes no arguments, and probably that's another thing to be improved.

Things that needs to be done:
* XML loader
* Add proper handling of widgets width and height (now only `Frame` is using it)
* Add multi-line support for `Label`
* Relative positioning for widgets stored in other widgets implementing `IWidgetContainer` interface
* Currently you can scroll through widgets using `W` and `S` keys, this is something we may want to change

I've decided to work on this later, because I wanted to see how it works with shiny new networking code, and then if it's get merged submit smaller Pull Requests of specific features.

Also I need your feedback about my code and documentation. This is my first time submitting a pull request to an open source project, and first time working with someone.
I'm a little bit scared :neutral_face: