> For the complete documentation index, see [llms.txt](https://lados-organization.gitbook.io/goku/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://lados-organization.gitbook.io/goku/chapter-9-the-user-interface-layer.md).

# Chapter 9: The User Interface Layer

The UI layer is a crucial component of our GUI system as it is responsible for managing and rendering all UI elements. In our `Layer` struct, we have two types of UI elements: `Button` and `Checkbox`. These two elements are stored in `Vec`s which will allow us to manage any number of these elements.

We provide methods for adding new elements (`add_button`, `add_checkbox`), rendering elements (`render`), and handling mouse click events (`handle_mouse_click`).

In the `render` method, we loop over all buttons and call their `render` method. Later, we could extend this to render other types of UI elements as well.

The `handle_mouse_click` method, given a mouse click's x and y coordinates, checks if any button or checkbox was clicked, and if so, triggers the associated actions.
