Nuklear

一个单头 ANSI C gui 库。(A single-header ANSI C gui library)

Github stars Tracking Chart

Nuklear

所有的开发都转移到了其他地方。

亲爱的访客,

这个版本库、问题跟踪器等已被放弃,改为 https://github.com/Immediate-Mode-UI/Nuklear。在这个问题跟踪器中的任何活动,任何拉取请求等都将被忽略。
期待您在 https://github.com/Immediate-Mode-UI/Nuklear 的反馈。

这是一个用 ANSI C 语言编写的最小状态即时模式图形用户界面工具包,并获得了公共领域的授权。它被设计为一个简单的可嵌入应用的用户界面,没有任何依赖性,默认的渲染后端或操作系统窗口和输入处理,而是通过使用简单的输入状态作为输入,并将描述原始形状的绘制命令作为输出,提供了一个非常模块化的库方法。因此,它没有提供一个分层的库,试图抽象出许多平台和渲染后端,而是只关注实际的 UI。

特性

  • 即时模式图形用户界面工具包
  • 单头库
  • 用C89(ANSI C)书写
  • 小代码库(~18kLOC)
  • 注重便携性、效率和简单性
  • 无依赖性(如果不需要,甚至连标准库都不需要)。
  • 完全可剥皮和定制
  • 低内存占用率,如有需要,可进行全内存控制
  • 支持UTF-8
  • 无全局或隐藏状态
  • 可定制的库模块(你可以只编译和使用你需要的东西)
  • 可选的字体烘焙机和顶点缓冲区输出
  • 文档

构建

这个库是自包含在一个头文件中的,可以在只用头模式或在实现模式下使用。默认情况下,只使用头文件模式,允许在其他头文件中包含这个头文件,不包含实际的实现。

实现模式需要在#include这个文件之前,在一个 .c/.cpp 文件中定义预处理程序宏 NK_IMPLEMENTATION,例如。

#define NK_IMPLEMENTATION
#include "nuklear.h"

重要:每次 include "nuklear.h" 时,你都必须定义相同的可选标志。这一点非常重要,如果不这样做,要么导致编译器错误,要么导致更糟糕的堆栈损坏。

图集

(恕删略)

示例

/* init gui state */
struct nk_context ctx;
nk_init_fixed(&ctx, calloc(1, MAX_MEMORY), MAX_MEMORY, &font);

enum {EASY, HARD};
static int op = EASY;
static float value = 0.6f;
static int i =  20;

if (nk_begin(&ctx, "Show", nk_rect(50, 50, 220, 220),
    NK_WINDOW_BORDER|NK_WINDOW_MOVABLE|NK_WINDOW_CLOSABLE)) {
    /* fixed widget pixel width */
    nk_layout_row_static(&ctx, 30, 80, 1);
    if (nk_button_label(&ctx, "button")) {
        /* event handling */
    }

    /* fixed widget window ratio width */
    nk_layout_row_dynamic(&ctx, 30, 2);
    if (nk_option_label(&ctx, "easy", op == EASY)) op = EASY;
    if (nk_option_label(&ctx, "hard", op == HARD)) op = HARD;

    /* custom widget pixel width */
    nk_layout_row_begin(&ctx, NK_STATIC, 30, 2);
    {
        nk_layout_row_push(&ctx, 50);
        nk_label(&ctx, "Volume:", NK_TEXT_LEFT);
        nk_layout_row_push(&ctx, 110);
        nk_slider_float(&ctx, 0, &value, 1.0f, 0.1f);
    }
    nk_layout_row_end(&ctx);
}
nk_end(&ctx);

绑定(Bindings)

有一些其他作者为不同语言制作的核弹绑定。我不能保证它们的质量,因为我不一定精通这两种语言。此外,我们不能保证所有的绑定都是最新的。

致谢

由 Micha Mettke 和 GitHub 的每个直接或间接贡献者开发。

嵌入 Sean Barrett 的 stb_texedit、stb_truetype 和 stb_rectpack(公有领域) 嵌入 Tristan Grimmer 的 ProggyClean.ttf 字体(MIT 许可)。

非常感谢 Omar Cornut (ocornut@github),感谢他的 imgui 库给了我这个库的灵感,感谢 Casey Muratori 的手工英雄和他的原始即时模式图形用户界面的想法,感谢 Sean Barrett 的惊人的单头,它恢复了我对库的信心,让我创造了一些自己的库。最后是 Apoorva Joshi,感谢他的 singe-header 文件打包器

许可证

------------------------------------------------------------------------------
This software is available under 2 licenses -- choose whichever you prefer.
------------------------------------------------------------------------------
ALTERNATIVE A - MIT License
Copyright (c) 2017 Micha Mettke
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.
------------------------------------------------------------------------------
ALTERNATIVE B - Public Domain (www.unlicense.org)
This is free and unencumbered software released into the public domain.
Anyone is free to copy, modify, publish, use, compile, sell, or distribute this
software, either in source code form or as a compiled binary, for any purpose,
commercial or non-commercial, and by any means.
In jurisdictions that recognize copyright laws, the author or authors of this
software dedicate any and all copyright interest in the software to the public
domain. We make this dedication for the benefit of the public at large and to
the detriment of our heirs and successors. We intend this dedication to be an
overt act of relinquishment in perpetuity of all present and future rights to
this software under copyright law.
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 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.
-----------------------------------------------------------------------------


(The first version translated by vz on 2020.08.22)

Main metrics

Overview
Name With Ownervurtun/nuklear
Primary LanguageC
Program languageMakefile (Language Count: 4)
PlatformLinux, Mac, Windows
License:
所有者活动
Created At2015-03-25 13:32:06
Pushed At2020-01-03 21:36:41
Last Commit At2019-12-02 00:01:55
Release Count0
用户参与
Stargazers Count13.8k
Watchers Count544
Fork Count1.1k
Commits Count1.7k
Has Issues Enabled
Issues Count657
Issue Open Count206
Pull Requests Count200
Pull Requests Open Count30
Pull Requests Close Count49
项目设置
Has Wiki Enabled
Is Archived
Is Fork
Is Locked
Is Mirror
Is Private

Nuklear

ALL DEVELOPMENT MOVED ELSEWHERE

Dear visitor,

this repository, issue tracker, etc. is abandoned in favor of https://github.com/Immediate-Mode-UI/Nuklear . Any activity in this issue tracker, any pull requests, etc. will be ignored.

Looking forward to hearing from you in https://github.com/Immediate-Mode-UI/Nuklear

Nuklear community

Build Status

This is a minimal state immediate mode graphical user interface toolkit
written in ANSI C and licensed under public domain. It was designed as a simple
embeddable user interface for application and does not have any dependencies,
a default render backend or OS window and input handling but instead provides a very modular
library approach by using simple input state for input and draw
commands describing primitive shapes as output. So instead of providing a
layered library that tries to abstract over a number of platform and
render backends it only focuses on the actual UI.

Features

  • Immediate mode graphical user interface toolkit
  • Single header library
  • Written in C89 (ANSI C)
  • Small codebase (~18kLOC)
  • Focus on portability, efficiency and simplicity
  • No dependencies (not even the standard library if not wanted)
  • Fully skinnable and customizable
  • Low memory footprint with total memory control if needed or wanted
  • UTF-8 support
  • No global or hidden state
  • Customizable library modules (you can compile and use only what you need)
  • Optional font baker and vertex buffer output
  • Documentation

Building

This library is self contained in one single header file and can be used either
in header only mode or in implementation mode. The header only mode is used
by default when included and allows including this header in other headers
and does not contain the actual implementation.

The implementation mode requires to define the preprocessor macro
NK_IMPLEMENTATION in one .c/.cpp file before #includeing this file, e.g.:

#define NK_IMPLEMENTATION
#include "nuklear.h"

IMPORTANT: Every time you include "nuklear.h" you have to define the same optional flags.
This is very important not doing it either leads to compiler errors or even worse stack corruptions.

screenshot
screen
screen2
node
skinning
gamepad

Example

/* init gui state */
struct nk_context ctx;
nk_init_fixed(&ctx, calloc(1, MAX_MEMORY), MAX_MEMORY, &font);

enum {EASY, HARD};
static int op = EASY;
static float value = 0.6f;
static int i =  20;

if (nk_begin(&ctx, "Show", nk_rect(50, 50, 220, 220),
    NK_WINDOW_BORDER