Skip to content
/ eui Public

UI and drawing library with a small footprint written in C89

License

Notifications You must be signed in to change notification settings

erysdren/eui

Repository files navigation

eui

eui is a small UI and drawing library designed for homebrew games, debug UIs, embedded systems, and low resolution or low color depth displays.

The base eui library is only two files, eui.c and eui.h. To add eui to your project, just clone the files into your source tree and compile.

While CMake is used to build the test and example programs, it is not required for eui itself.

Features

  • Nested frames with relative element positioning and alignment.
  • Automatic text justification.
  • Automatic shape clipping.
  • Built-in 8x8 and 8x14 pixel fonts.
  • Integer math only.
  • Draws into a raw pixel buffer by default.
  • Supports 1, 2, 4, and 8 bits-per-pixel drawing.
  • No dynamic memory allocation.
  • Automatic or configurable Z-index for frames.

Todo

  • Write full API documentation outside of the header.
  • Re-add previously removed code as optional modules (widgets, shapes, bitmaps).
  • Support segmented memory model with appropriately placed FAR pointers.
  • Support VGA text mode with alternative glyph drawing routines.

Usage

Here is a basic eui usage example that assumes 4 bit color and the default 16 color VGA palette.

/* set alignment to the center of the frame */
eui_frame_align_set(EUI_ALIGN_MIDDLE, EUI_ALIGN_MIDDLE);

/* draw 192x64 box and draw a 2px border */
eui_draw_box(0, 0, 192, 64, 0x0F);
eui_draw_box_border(0, 0, 192, 64, 2, 0x02);

/* create child frame with 8 pixels of padding on each side */
eui_frame_push(0, 0, 176, 48);

/* set child frame alignment to top-left */
eui_frame_align_set(EUI_ALIGN_START, EUI_ALIGN_START);

/* draw a string with the default 8x8 font */
eui_draw_text(0, 0, 0x00, "Hello, world!");

/* destroy child frame */
eui_frame_pop();

Hello, world!

Configuration Switches

  • EUI_MAX_FRAMES: Maximum number of nested frames. Default: 1024
  • EUI_MAX_DRAWCMDS: Maximum number of queueable draw commands. Default: 8192

Source Code Guide

Modules

Examples

Tested Compilers & Platforms

  • Borland C++ 3.1 (MS-DOS)
  • Clang 14.0.6 (Linux)
  • GCC 6.3.0 (IA16)
  • GCC 12.2.0 (Linux, Windows, MS-DOS)
  • Open Watcom v2 (MS-DOS)
  • TCC 0.9.27 (Linux)

Credits

License

MIT License

Copyright (c) 2023-2024 erysdren (it/she/they)

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

About

UI and drawing library with a small footprint written in C89

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published