尊敬的访客,
该存储库、问题跟踪器等已被放弃,取而代之的是 https://github.com/Immediate-Mode-UI/Nuklear 。此问题跟踪器中的任何活动、任何拉取请求等都将被忽略。
期待在 https://github.com/Immediate-Mode-UI/Nuklear 中收到您的来信
核社区
这是一个用 ANSI C 编写并在公共领域获得许可的最小状态立即模式图形用户界面工具包。它被设计为一个简单的可嵌入应用程序用户界面,没有任何依赖项、默认渲染后端或操作系统窗口和输入处理,而是通过使用简单的输入状态作为输入和绘制命令来描述原始形状,从而提供了一种非常模块化的库方法输出。因此,它没有提供尝试抽象多个平台并渲染后端的分层库,而是只关注实际的 UI。
该库自包含在一个头文件中,可以在仅头文件模式或实现模式下使用。包含时默认使用仅标头模式,并允许将此标头包含在其他标头中,但不包含实际实现。
该实现模式要求在#include
之前在一个.c/.cpp 文件中定义预处理器宏NK_IMPLEMENTATION
,例如:
#define NK_IMPLEMENTATION
#include "nuklear.h"
重要提示:每次包含“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 );
其他作者创建了许多针对不同语言的 nuklear 绑定。我无法测试它们的质量,因为我不一定精通这两种语言。此外,不保证所有绑定始终保持最新:
由 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 的单头文件加壳器。
------------------------------------------------------------------------------
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.
-----------------------------------------------------------------------------