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)
有一些其他作者为不同语言制作的核弹绑定。我不能保证它们的质量,因为我不一定精通这两种语言。此外,我们不能保证所有的绑定都是最新的。
- Java by Guillaume Legris
- D by Mateusz Muszyński
- Golang by golang-ui@github.com
- Rust by snuk182@github.com
- Chicken by wasamasa@github.com
- Nim by zacharycarter@github.com
- Lua
- LÖVE-Nuklear by Kevin Harrison
- MoonNuklear by Stefano Trettel
- Python
- pyNuklear by William Emerison Six (ctypes-based wrapper)
- pynk by nathanrw@github.com (cffi binding)
- CSharp/.NET by cartman300@github.com
致谢
由 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)