Glue:GlueVault:Component Pages:Squid GUI Integration


Squid GUI is a UI framework by IONSTAR Studios. It provides functionality for a number of common controls like buttons, check boxes, labels, drop down lists, and much more. You can even expand on it by creating your own custom controls. For information regarding the Squid GUI library, please refer to their website here:

A simple layout system has been created to make developing your GUIs as easy as possible. Keep in mind that this is fairly bare-bones and will be expanded upon over time.

Sample Project

You can download a sample project here: Download

This sample project includes several things:

  1. Graphics for the controls provided by IONSTAR’s SquidGUI package
  2. An Arial10 Spritefont
  3. A sample XML layout
  4. Code which handles most of the internal plumbing of getting the UI to draw on the screen.
  5. A sample “GUI Logic” entity which demonstrates how to hook your GUI interaction events back to your screen.

This sample project will let you dive right in and see how everything works. However, if you need a more hands-on tutorial please keep reading to learn how this all works.

Creating a GUI

There’s essentially three steps to creating a GUI:

  1. Create the XML layout
  2. Create the GUI interaction logic class
  3. Add the interaction class to your screen

This guide will take you through each of these steps with a simple example. To start, we’ll create a window with an “Exit Button” inside it. When this button is clicked, a confirmation box will appear. If the user confirms, the entire application will shut down.

Creating an XML Layout

Each layout must contain at least one window. Components such as buttons, check boxes, and labels are contained inside of the window.

We’ll use this layout for this example.

This sample layout will create a window with a button labeled “Exit”. The button will be 425 pixels wide and 40 pixels tall.

When working with position, it’s important to keep in mind that all controls start at the origin of its parent window. So in this case, the button will be 50 pixels down from the center of the window.

Here’s a screenshot of how the screen should look:

Demo exit.png

Supported Component Types

These are the currently supported component types:

  1. Window
  2. Label
  3. Textbox
  4. Button
  5. Checkbox

Note that you can add additional types to the SquidLayoutManager class file.

Creating the GUI Interaction Logic

Now that we have a layout, we need to provide interaction logic to the UI. In other words, when the user clicks the “Exit Button” we want a pop-up to appear.

To start, let’s look at the class called MainMenuLogic in the example project.

This class is deriving from GUIDrawableBatch, which is used for all GUI interaction classes. This abstracts all of the lower level drawing and input logic, so you can focus on making the UI actually do stuff.

Let’s look at the constructor.

It’s very important to note the constructor is passing “MainMenu” into the base constructor. This is actually a reference to the file name of the layout which is MainMenu.xml

Next, refer to the LoadControls() method.

Here, we’re loading the window and button into memory based on the component’s “Name” field which is defined in the XML layout.

The rest is fairly straightforward. The HookEvents subscribes the method ExitButton_MouseClick to the MouseClick event provided by Squid. This calls a pop-up message box.

Demo popup.png

Finally, when the pop up menu’s “Yes” button is clicked, it will fire the ExitConfirmClicked method which shuts down the game.

Add the interaction class to your screen

Now that we have the interaction class created, we need to instantiate it on the screen. For the example project, we’re using the screen named “DemoScreen”.

This next part is super easy – check out our DemoScreen code.

And that’s all there is to it! You could start doing some more complicated things like raising events from the MainMenuLogic class and responding to them from the screen. However, that is outside the scope of this guide.


Squid GUI offers a great way to develop user interfaces in FlatRedBall. You can really do a lot with its simple XML configuration and it can be expanded upon fairly easily.