Native UI components for C: about 150 of them, with spring motion and full keyboard support. Windows, macOS and Linux, no dependencies.
翻译准备中
开发工具GitHub @yappologistic自行安装运营者未确认
试用过了吗? 点一下就好,无需登录。
尚未收集仓库信息。
尚未检测到更新。GitHub 发布版本后会显示在这里。
制作者的介绍仅有上面的一句话。 更多详情请阅读仓库 README。 仓库 README ↗
正在加载完整 README。
查看完整 README ↗A UI library for C that draws its own components.
Live site · Getting started · Tutorial · Components · Downloads
Every image on this page is drawn by CUI, from plain C.
CUI is an immediate-mode UI library written in C99. You describe the screen with function calls every frame. CUI lays it out, handles the mouse and keyboard, and draws it with OpenGL or its own software renderer, in a window on Windows, macOS or Linux, or in a browser through WebAssembly.
cui.h and cui.c) dropped into your project.#include <cui/cui.h>
#include <cui/cui_app.h>
int main(void) {
cui_app *app = cui_app_create(&(cui_app_desc){
.title = "Hello", .width = 420, .height = 300 });
if (!app) return 1;
bool notifications = true;
int clicks = 0;
while (cui_app_frame(app)) {
cui_ctx *ui = cui_app_ui(app);
cui_column(ui, .pad = 32, .gap = 16) {
cui_heading(ui, "Hello, CUI", 2);
cui_secondary(ui, "A native window, a few components "
"and no dependencies.");
cui_switch(ui, "Notifications", ¬ifications);
cui_row(ui, .gap = 8) {
if (cui_button(ui, "Click me", .variant = CUI_BUTTON_PRIMARY))
clicks++;
cui_textf(ui, "Clicked %d times", clicks);
}
}
}
cui_app_destroy(app);
return 0;
}
A component is a function call. It draws itself, handles input and returns what happened: cui_button returns true on the frame it is clicked.
Options are named arguments. Leave one out and it takes its default.
Your variables are the state. The screen is described again every frame, so there are no widgets to create, keep or update.
CUI draws every component itself. It does not wrap the system's buttons and menus, so an app looks the same on every system and does not look like the system's own apps. "Native" here means compiled code in a real window, with nothing interpreted and no web view.
How it sits beside the libraries you may know:
CUI is a good fit for a desktop tool, an editor, a dashboard or a game's interface written in C or C++, where you want it small and want it to look finished without designing every control. Read Limitations before you decide.
With CMake (GCC, Clang, MSVC and MinGW are tested):
include(FetchContent)
FetchContent_Declare(cui
GIT_REPOSITORY https://github.com/yappologistic/CUI.git
GIT_TAG v1.4.0)
FetchContent_MakeAvailable(cui)
target_link_libraries(my_app PRIVATE cui::cui)
cui_app_target(my_app) # no console window on Windows, and only the code your app uses
Without CMake, take cui.h and cui.c from a release and compile them with your program. Getting started has the exact commands for both, and CI runs those commands on every push.
To build the library and run an example:
git clone https://github.com/yappologistic/CUI.git
cmake -S CUI -B build -DCMAKE_BUILD_TYPE=Release
cmake --build build
./build/examples/tracker
Linux needs the X11 development headers (libx11-dev). Windows and macOS need nothing beyond the system SDK.
以上为 README 的开头部分。其余内容请阅读原文。 查看完整 README ↗