nuklear/Readme.md

91 lines
3.5 KiB
Markdown
Raw Normal View History

2015-09-09 10:33:32 -07:00
# Zahnrad
2015-07-25 13:16:35 -07:00
[![Coverity Status](https://scan.coverity.com/projects/5863/badge.svg)](https://scan.coverity.com/projects/5863)
2015-11-19 12:02:36 -08:00
This is a minimal state immediate mode graphical user interface toolkit
2015-11-26 11:18:08 -08:00
written in ANSI C and licensed under zlib. It was designed as a simple embeddable user interface for
2015-12-10 15:04:17 -08:00
application and does not have any direct dependencies,
a default renderbackend or OS window and input handling but instead provides a very modular
library approach by using simple input state for input and draw
2015-09-17 08:31:43 -07:00
commands describing primitive shapes as output. So instead of providing a
layered library that tries to abstract over a number of platform and
2015-11-19 12:02:36 -08:00
render backends it only focuses on the actual UI.
2015-03-11 06:00:59 -07:00
2015-03-14 09:05:30 -07:00
## Features
2015-04-16 07:20:00 -07:00
- Immediate mode graphical user interface toolkit
2015-03-14 09:05:30 -07:00
- Written in C89 (ANSI C)
- Small codebase (~12kLOC)
- Focus on portability, efficiency and simplicity
2015-12-10 15:04:17 -08:00
- No dependencies (not even the standard library)
2015-05-17 05:39:02 -07:00
- No global or hidden state
- Fully skinnable and customizable
2015-04-30 07:12:21 -07:00
- UTF-8 support
2015-03-24 05:08:42 -07:00
2015-11-19 12:02:36 -08:00
## Optional
2015-11-26 11:18:08 -08:00
- Vertex buffer output
- Font handling
2015-11-19 12:02:36 -08:00
## Building
The library is self-contained within four different files that only have to be
copied and compiled into your application. Files zahnrad.c and zahnrad.h make up
2015-09-17 08:31:43 -07:00
the core of the library, while stb_rect_pack.h and stb_truetype.h are
for a optional font handling implementation and can be removed if not needed.
- zahnrad.c
- zahnrad.h
2015-11-19 12:02:36 -08:00
- stb_rect_pack.h (optional)
- stb_truetype.h (optional)
2015-09-17 08:35:45 -07:00
There are no dependencies or a particular building process required. You just have
to compile the .c file and #include zahnrad.h into your project. To actually
2015-09-17 08:31:43 -07:00
run you have to provide the input state, configuration style and memory
for draw commands to the library. After the GUI was executed all draw commands
have to be either executed or optionally converted into a vertex buffer to
draw the GUI.
2015-05-09 06:22:23 -07:00
## Gallery
2015-12-12 02:53:15 -08:00
![screenshot](https://cloud.githubusercontent.com/assets/8057201/11761525/ae06f0ca-a0c6-11e5-819d-5610b25f6ef4.gif)
2016-03-04 11:46:45 -08:00
![screen](https://cloud.githubusercontent.com/assets/8057201/13538240/acd96876-e249-11e5-9547-5ac0b19667a0.png)
![screen2](https://cloud.githubusercontent.com/assets/8057201/13538243/b04acd4c-e249-11e5-8fd2-ad7744a5b446.png)
2015-09-19 08:59:10 -07:00
![node](https://cloud.githubusercontent.com/assets/8057201/9976995/e81ac04a-5ef7-11e5-872b-acd54fbeee03.gif)
2016-03-30 11:09:20 -07:00
![skinning](https://cloud.githubusercontent.com/assets/8057201/14152357/25df939e-f6b3-11e5-8587-b19e863e0d1b.png)
2015-05-09 06:22:23 -07:00
2015-04-25 07:44:43 -07:00
## Example
```c
2015-12-30 07:31:08 -08:00
/* init gui state */
struct zr_context ctx;
2016-01-08 05:15:56 -08:00
zr_init_fixed(&ctx, calloc(1, MAX_MEMORY), MAX_MEMORY, &font);
2015-12-30 07:31:08 -08:00
enum {EASY, HARD};
2015-12-30 07:31:08 -08:00
int op = EASY;
2015-12-01 01:50:12 -08:00
float value = 0.6f;
2015-12-30 07:31:08 -08:00
int i = 20;
2016-02-16 09:48:40 -08:00
struct zr_panel layout;
2016-01-14 06:25:35 -08:00
zr_begin(&ctx, &layout, "Show", zr_rect(50, 50, 220, 220),
2016-01-04 12:34:48 -08:00
ZR_WINDOW_BORDER|ZR_WINDOW_MOVEABLE|ZR_WINDOW_CLOSEABLE);
{
/* fixed widget pixel width */
zr_layout_row_static(&ctx, 30, 80, 1);
if (zr_button_text(&ctx, "button", ZR_BUTTON_DEFAULT)) {
/* event handling */
2015-12-30 07:31:08 -08:00
}
2015-06-28 01:09:53 -07:00
2016-01-04 12:34:48 -08:00
/* fixed widget window ratio width */
zr_layout_row_dynamic(&ctx, 30, 2);
if (zr_option(&ctx, "easy", op == EASY)) op = EASY;
if (zr_option(&ctx, "hard", op == HARD)) op = HARD;
/* custom widget pixel width */
zr_layout_row_begin(&ctx, ZR_STATIC, 30, 2);
{
zr_layout_row_push(&ctx, 50);
zr_label(&ctx, "Volume:", ZR_TEXT_LEFT);
zr_layout_row_push(&ctx, 110);
zr_slider_float(&ctx, 0, &value, 1.0f, 0.1f);
2015-04-25 07:44:43 -07:00
}
2016-01-04 12:34:48 -08:00
zr_layout_row_end(&ctx);
2015-04-25 07:44:43 -07:00
}
2016-01-04 12:34:48 -08:00
zr_end(ctx);
2015-04-25 07:44:43 -07:00
```
2015-09-30 01:23:45 -07:00
![example](https://cloud.githubusercontent.com/assets/8057201/10187981/584ecd68-675c-11e5-897c-822ef534a876.png)
2015-04-25 07:44:43 -07:00