nuklear/Readme.md

101 lines
5.0 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-12-18 06:43:39 -08:00
# CURRENTLY UNDER HEAVY REFACTORING! (do not use at the moment)
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)
2015-12-17 07:48:35 -08:00
- Small codebase (~9kLOC)
2015-05-17 05:39:02 -07:00
- Focus on portability, efficiency, simplicity and minimal internal state
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
2015-05-11 03:45:22 -07:00
- Configurable style and colors
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)
2015-11-19 12:02:36 -08:00
![demo](https://cloud.githubusercontent.com/assets/8057201/11282359/3325e3c6-8eff-11e5-86cb-cf02b0596087.png)
2015-09-19 08:59:10 -07:00
![node](https://cloud.githubusercontent.com/assets/8057201/9976995/e81ac04a-5ef7-11e5-872b-acd54fbeee03.gif)
2015-05-09 06:22:23 -07:00
2015-04-25 07:44:43 -07:00
## Example
```c
enum {EASY, HARD};
2015-12-01 01:50:12 -08:00
int option = EASY;
float value = 0.6f;
2015-06-28 01:09:53 -07:00
2015-11-19 12:02:36 -08:00
struct zr_context context;
2015-11-22 11:19:32 -08:00
zr_begin(&context, &window, "Show");
2015-11-19 12:02:36 -08:00
{
zr_layout_row_static(&context, 30, 80, 1);
if (zr_button_text(&context, "button", ZR_BUTTON_DEFAULT)) {
/* event handling */
2015-04-25 07:44:43 -07:00
}
2015-11-19 12:02:36 -08:00
zr_layout_row_dynamic(&context, 30, 2);
if (zr_option(&context, "easy", option == EASY)) option = EASY;
if (zr_option(&context, "hard", option == HARD)) option = HARD;
zr_label(&context, "Volume:", ZR_TEXT_LEFT);
zr_slider_float(&context, 0, &value, 1.0f, 0.1f);
zr_layout_row_end(&context);
2015-04-25 07:44:43 -07:00
}
2015-11-19 12:02:36 -08:00
zr_end(&context, &window);
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
2015-11-26 11:18:08 -08:00
## Documentation
2015-12-10 15:04:17 -08:00
Zahnrad currently relies heavily on documentation provided inside the `zahnrad.h` header file, consisting
of descriptions and important information about modules, data types and functions.
While being quite limited in delivering information about the general high-level libray composition it
should still offer some understanding about the inner workings and stand as a practical usage reference.
2015-11-26 11:18:08 -08:00
2015-12-10 15:04:17 -08:00
## Examples
A number of usage examples can be found inside the `example` and `demo` folder which should yield a
basic overview how to embed the libray into different platforms with varying APIs and provided functionality
and hopefully offer a basic understanding of zahnrad's UI API.
In general it is advised to start by reading `example/demo`. It consists of a basic embedding example into
SDL, OpenGL and [NanoVG](https://github.com/memononen/nanovg) with a very simple set of used widgets and layouting.
2015-11-26 11:18:08 -08:00
2015-12-10 15:04:17 -08:00
As soon as a basic understanding of the library is accumulated it is recommended to look into the `demo/` folder with your platform
of choice. For now a basic platform layer was implemented for Linux(X11), Windows(win32) and OpenGL with SDL and GLFW.
Both platform specific demos (X11, win32) use their respectable window, input, draw and font API and don't have any
outside dependencies which should qualify them as the first platform to compile, run and test.
For hardware supported rendering, font both the SDL and GLFW version use zahnrad's internal vertex buffer output
and font baker.
2015-11-26 11:18:08 -08:00
2015-12-10 15:04:17 -08:00
Up until now you should hopefully have a basic grip of how to use zahnrad UI API and be able to embed zahnrad into
your plaform. From here on `demo/demo.c` should provide a basic reference on how use most widgets and layouting.
Finally for some small actual working example apps both `example/filex` with implementation of a linux only
file browser and `example/nodedit` with a basic node editor skeleton are provided. Especially the `nodedit` example
should show how far you can bend the this library to your own needs.
2015-11-26 11:18:08 -08:00