跳到正文
Hacker News (official RSS)(yappologistic.github.io)·· 13 天前品質評分63

CUI 推出以單一 C99 程式碼庫打造的原生 UI 元件

CUI – Native UI components for C

重點導讀

CUI 提供以單一 C99 程式碼庫打造的原生 UI 元件,涵蓋桌面應用所需的完整介面,並支援鍵盤操作與 Spring 動態效果。

  • - 元件與大小:約 129 個元件。
  • 頁面標示程式庫約 201 KB,設計原則則稱完整應用約 250 KB。

AI 伴隨問答

自備 Key 深度分析

針對這篇報導有疑問?可直接點選快捷問題或向 AI 追問背景脈絡與技術細節:

正文

Native UI components for

Spring motion and full keyboard support, from one C99 codebase.

git clone https://github.com/yappologistic/CUI

  • ~129 components
  • ~201 KB a complete app
  • < 0.25 ms per frame
  • Win · Mac · Linux one C99 codebase
  • 0 dependencies

01

Everything a desktop app needs

Not a box of primitives: complete components, designed together, that look finished without styling. Each tile below is running; click into one and use it.

Browse all components

Data grid

Thousands of rows, sorting, filters and spreadsheet selection.

Docs

TypeError: Cannot read properties of null (reading 'putImageData') at Preview.paint (https://yappologistic.github.io/CUI/js/preview.js:272:18) at Preview.start (https://yappologistic.github.io/CUI/js/preview.js:103:10)

Command palette

Fuzzy search with groups and shortcuts.

Docs

TypeError: Cannot read properties of null (reading 'putImageData') at Preview.paint (https://yappologistic.github.io/CUI/js/preview.js:272:18) at Preview.start (https://yappologistic.github.io/CUI/js/preview.js:103:10)

Node editor

Pan, zoom and wire nodes together.

Docs

TypeError: Cannot read properties of null (reading 'putImageData') at Preview.paint (https://yappologistic.github.io/CUI/js/preview.js:272:18) at Preview.start (https://yappologistic.github.io/CUI/js/preview.js:103:10)

Property inspector

Typed editors in folding groups.

Docs

TypeError: Cannot read properties of null (reading 'putImageData') at Preview.paint (https://yappologistic.github.io/CUI/js/preview.js:272:18) at Preview.start (https://yappologistic.github.io/CUI/js/preview.js:103:10)

Charts

Lines, bars, donuts and a dozen more.

Docs

TypeError: Cannot read properties of null (reading 'putImageData') at Preview.paint (https://yappologistic.github.io/CUI/js/preview.js:272:18) at Preview.start (https://yappologistic.github.io/CUI/js/preview.js:103:10)

Chat

Bubbles, replies and reactions.

Docs

TypeError: Cannot read properties of null (reading 'putImageData') at Preview.paint (https://yappologistic.github.io/CUI/js/preview.js:272:18) at Preview.start (https://yappologistic.github.io/CUI/js/preview.js:103:10)

02

Your interface is plain C

Components are functions that draw themselves and return what happened. Your variables are the state, and the whole screen is described again every frame, so there is nothing to keep in sync.

How immediate mode works

#include <cui/cui.h>
#include <cui/cui_app.h>

int main(void) {
cui_app *app = cui_app_create(&(cui_app_desc){ .title = "My app" });
if (!app) return 1;
bool notify = true;
int clicks = 0;
while (cui_app_frame(app)) {
cui_ctx *ui = cui_app_ui(app);
cui_column(ui, .pad = 24, .gap = 12) {
cui_heading(ui, "Welcome", 2);
cui_switch(ui, "Email me when a build fails", &notify);
if (cui_button(ui, "Count", .variant = CUI_BUTTON_PRIMARY)) clicks++;
cui_textf(ui, "Clicked %d times", clicks);
}
}
cui_app_destroy(app);
return 0;
}
```

03

Make it yours

Light and dark, eight accents, and semantic tokens your own drawing follows too. Try them on a live page of components.

Theming

TypeError: Cannot read properties of null (reading 'putImageData') at Preview.paint (https://yappologistic.github.io/CUI/js/preview.js:272:18) at Preview.start (https://yappologistic.github.io/CUI/js/preview.js:103:10)

04

Small, fast and careful

Native apps should start instantly and stay out of the way. These are the numbers and rules CUI is held to.

Design principles

  • ### 0.1 to 0.25 ms a frame

A full screen builds, lays out and paints in a fraction of a millisecond. An idle app uses no CPU.

  • ### About 250 KB

That is a complete app. CUI has no dependencies, and the library is one C99 codebase.

  • ### Win32, Cocoa and X11

Or SDL2 and GLFW, drawn with OpenGL or the software renderer. The core only emits triangles, so your own renderer works too.

  • ### Keyboard and reduced motion

Every component works from the keyboard and every animation has a reduced motion path. Text meets 4.5:1 contrast.

05

Learn it in an afternoon

Six short guides take you from your first window to your own components and your own renderer.

Start with the first guide

Start with one window

Build CUI, open a window and draw your first components in a few minutes.

Photograph: Ansel Adams, _The Tetons and the Snake River_, 1942. U.S. National Archives, public domain.

來源: Hacker News (official RSS) (yappologistic.github.io)
開啟原文

讀者討論

理性交流 · 即時討論