Skip to content

Screen

Overview

The Screen widget is the root container for an mGui application. It is typically full-screen, holds all other widgets, and defines the UI background color.

Create

// initialize display
mgui_init(SCREEN_WIDTH, SCREEN_HEIGHT, MGUI_BUFFER_SIZE_KB, 30);

mgui_widget_t* screen = mgui_allocate_widget(
    NULL, MGUI_WIDGET_SCREEN,
    (mgui_area_t){0, 0, SCREEN_WIDTH, SCREEN_HEIGHT},
    MGUI_COLOR_GRAY);

Common actions

  • Free the screen and all children:
mgui_widget_free_screen(&screen);
  • Add children to the screen as normal (pass screen as the parent):
mgui_widget_t* panel = mgui_allocate_widget(screen, MGUI_WIDGET_BOX,
    (mgui_area_t){10, 10, 200, 120}, MGUI_COLOR_PURPLE);

That's all — use the Screen as your application's root container.