Skip to content

Tutorial 02 . Panel

Jean-David Moisan edited this page Oct 24, 2020 · 3 revisions

Simple Panel Example

It's easy enough to have a single Component. It's also easy to have many.

First create a Panel:

Panel container = new Panel();

Give it a Layout:

container.Layout = new LayoutVertical();

You can give it a position and a size with:

container.Position = new Point(20, 30);
container.Width = 200;
container.Height = 300;

Now you can add some Labels to the Panel:

container.Add(new Label("Hello"));
container.Add(new Label("World"));
container.Add(new Label("!"));

In your update loop, call the following functions:

container.UpdateSetup();
container.UpdateInput();
container.Update();

The UpdateSetup() calls the Layout to position the labels.

And in the draw loop:

GuiHelper.DrawGui(container);
Clone this wiki locally